diff --git a/app/api/controller/StoreKeeper.php b/app/api/controller/StoreKeeper.php index 52aed918..a0911ae2 100644 --- a/app/api/controller/StoreKeeper.php +++ b/app/api/controller/StoreKeeper.php @@ -243,6 +243,21 @@ class StoreKeeper extends Controller return $this->renderError($model->getError() ?: '操作失败'); } + /** + * 修改物流信息 + * @param int $orderId + * @return Json + */ + public function updateDelivery(int $orderId): Json + { + // 订单详情 + $model = OrderModel::detail($orderId); + if ($model->updateDelivery($this->postForm())) { + return $this->renderSuccess('操作成功'); + } + return $this->renderError($model->getError() ?: '操作失败'); + } + /** * 审核:用户取消订单 * @param $orderId diff --git a/app/store/model/Order.php b/app/store/model/Order.php index d3773494..c994a5bd 100644 --- a/app/store/model/Order.php +++ b/app/store/model/Order.php @@ -65,14 +65,11 @@ class Order extends OrderModel $filterOr = []; if (!empty($param['searchValue']) && $param['searchType'] == 'all') { -// $filterOr = [ -// ['order.order_no', 'like', "%{$param['searchValue']}%"], -// ['user.nick_name', 'like', "%{$param['searchValue']}%"], -// ['address.name', 'like', "%{$param['searchValue']}%"], -// ['address.phone', 'like', "%{$param['searchValue']}%"], -// ]; $filterOr = [ - ['order.order_no|user.nick_name|address.name|address.phone', 'like', "%{$param['searchValue']}%"] + ['order.order_no', 'like', "%{$param['searchValue']}%"], + ['user.nick_name', 'like', "%{$param['searchValue']}%"], + ['address.name', 'like', "%{$param['searchValue']}%"], + ['address.phone', 'like', "%{$param['searchValue']}%"], ]; } @@ -88,8 +85,7 @@ class Order extends OrderModel ->where($filter) ->where('order.is_delete', '=', 0); if (!empty($filterOr)) { -// $query = $query->whereOr($filterOr); - $query = $query->where($filterOr); + $query = $query->whereOr($filterOr); } $list = $query->order(['order.create_time' => 'desc']) ->paginate(10); @@ -125,7 +121,7 @@ class Order extends OrderModel // 设置订单类型条件 $dataTypeFilter = $this->getFilterDataType($param['dataType']); // 获取数据列表 - $query = $this->with(['goods.image', 'user.avatar', 'address']) + $query = $this->with(['goods.image', 'user.avatar', 'address', 'delivery']) ->alias('order') ->field('order.*') ->leftJoin('user', 'user.user_id = order.user_id') @@ -320,6 +316,31 @@ class Order extends OrderModel } + /** + * 修改物流信息 + * @param array $data + * @return bool + */ + public function updateDelivery(array $data): bool + { + if ($this['pay_status'] != PayStatusEnum::SUCCESS + || $this['delivery_status'] == DeliveryStatusEnum::DELIVERED || $this['delivery_type'] != 10) { + $this->error = "订单号[{$this['order_no']}]不满足修改条件!"; + return false; + } + if (empty($data['express_id']) || empty($data['express_no'])) { + $this->error = "请补全物流信息!"; + return false; + } + $update = [ + 'express_id' => $data['express_id'], + 'express_no' => $data['express_no'], + + ]; + return (bool)\app\common\model\order\Delivery::where(['order_id' => $this['order_id']])->update($update); + + } + /** * 修改商家备注 * @param array $data diff --git a/app/store/model/OrderRefund.php b/app/store/model/OrderRefund.php index 5b256551..caf33856 100644 --- a/app/store/model/OrderRefund.php +++ b/app/store/model/OrderRefund.php @@ -37,20 +37,12 @@ class OrderRefund extends OrderRefundModel { // 检索查询条件 $filter = $this->getFilter($param); - //不是店长查询当前用户订单 - // if(!UserService::isStore()) { - // $filter[] = ['user.user_id' ,'=', UserService::getCurrentLoginUserId() ]; - // } $filterOr = []; if (!empty($param['searchValue']) && $param['searchType'] == 'all') { -// $filterOr = [ -// ['order.order_no', 'like', "%{$param['searchValue']}%"], -// ['user.nick_name', 'like', "%{$param['searchValue']}%"], -// ['order.user_id', '=', (int)$param['searchValue']] -// ]; - $filterOr = [ - ['order.order_no|user.nick_name|order.user_id', 'like', "%{$param['searchValue']}%"] + ['order.order_no', 'like', "%{$param['searchValue']}%"], + ['user.nick_name', 'like', "%{$param['searchValue']}%"], + ['order.user_id', '=', (int)$param['searchValue']] ]; } @@ -61,8 +53,7 @@ class OrderRefund extends OrderRefundModel ->join('user', 'user.user_id = order.user_id') ->where($filter); if(!empty($filterOr)){ -// $query = $query->whereOr($filterOr); - $query = $query->where($filterOr); + $query = $query->whereOr($filterOr); } $list = $query->order(['refund.create_time' => 'desc', 'refund.' . $this->getPk()]) ->paginate(10);