| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- <?php
- namespace addons\CloudStock\api\services;
- use addons\CloudStock\common\models\CloudStockAgentOrder;
- use common\enums\StatusEnum;
- use RuntimeException;
- class CloudStockAgentOrderService extends \addons\CloudStock\common\services\CloudStockAgentOrderService
- {
- /**
- * 修改收货地址
- *
- * @param array $params
- * @param bool $isCheckOnlyOnce
- * @param callable|null $callback
- *
- * @return bool
- */
- public function modifyAddress(array $params, bool $isCheckOnlyOnce = true, callable $callback = null): bool
- {
- $callback = function (CloudStockAgentOrder $order, array &$params) use ($callback) {
- if ($order['user_id'] != $this->user_id) {
- throw new RuntimeException('订单不存在');
- }
- // 验证新地址的运费
- $address = $this->checkNewAddressFreight($order, $params['address_id']);
- $params = array_merge($params, $address);
- if ($callback !== null) {
- $callback($order, $params);
- }
- };
- return parent::modifyAddress($params, $isCheckOnlyOnce, $callback);
- }
- /**
- * 获取订单订单明细
- *
- * @param int $id
- *
- * @return array
- */
- public function getOrderDetail(int $id): array
- {
- return CloudStockAgentOrder::find()
- ->where([
- 'mall_id' => $this->mall_id,
- 'id' => $id,
- 'status' => StatusEnum::ENABLED,
- 'user_id' => $this->user_id
- ])
- ->asArray()
- ->select('id, address, mobile, name')
- ->one() ?: [];
- }
- }
|