From 6049aca86fff761bbff1daf7c4d19f4ce6563f29 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Thu, 8 Aug 2024 15:40:00 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E9=85=8D=E9=80=81=E5=91=98=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DeliveryServiceController.php | 95 +++++++++++++++++ .../store_order/StoreOrderController.php | 13 +++ .../delivery_service/DeliveryServiceLists.php | 65 ++++++++++++ .../delivery_service/DeliveryServiceLogic.php | 100 ++++++++++++++++++ .../WarehouseProductLogic.php | 12 ++- .../DeliveryServiceValidate.php | 88 +++++++++++++++ .../delivery_service/DeliveryService.php | 22 ++++ 7 files changed, 390 insertions(+), 5 deletions(-) create mode 100644 app/admin/controller/delivery_service/DeliveryServiceController.php create mode 100644 app/admin/lists/delivery_service/DeliveryServiceLists.php create mode 100644 app/admin/logic/delivery_service/DeliveryServiceLogic.php create mode 100644 app/admin/validate/delivery_service/DeliveryServiceValidate.php create mode 100644 app/common/model/delivery_service/DeliveryService.php diff --git a/app/admin/controller/delivery_service/DeliveryServiceController.php b/app/admin/controller/delivery_service/DeliveryServiceController.php new file mode 100644 index 000000000..66ce172e5 --- /dev/null +++ b/app/admin/controller/delivery_service/DeliveryServiceController.php @@ -0,0 +1,95 @@ +dataLists(new DeliveryServiceLists()); + } + + + /** + * @notes 添加配送员 + * @return \think\response\Json + * @author admin + * @date 2024/08/08 14:07 + */ + public function add() + { + $params = (new DeliveryServiceValidate())->post()->goCheck('add'); + $result = DeliveryServiceLogic::add($params); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(DeliveryServiceLogic::getError()); + } + + + /** + * @notes 编辑配送员 + * @return \think\response\Json + * @author admin + * @date 2024/08/08 14:07 + */ + public function edit() + { + $params = (new DeliveryServiceValidate())->post()->goCheck('edit'); + $result = DeliveryServiceLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(DeliveryServiceLogic::getError()); + } + + + /** + * @notes 删除配送员 + * @return \think\response\Json + * @author admin + * @date 2024/08/08 14:07 + */ + public function delete() + { + $params = (new DeliveryServiceValidate())->post()->goCheck('delete'); + DeliveryServiceLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取配送员详情 + * @return \think\response\Json + * @author admin + * @date 2024/08/08 14:07 + */ + public function detail() + { + $params = (new DeliveryServiceValidate())->goCheck('detail'); + $result = DeliveryServiceLogic::detail($params); + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/app/admin/controller/store_order/StoreOrderController.php b/app/admin/controller/store_order/StoreOrderController.php index 0aa21ccc8..c9238c136 100644 --- a/app/admin/controller/store_order/StoreOrderController.php +++ b/app/admin/controller/store_order/StoreOrderController.php @@ -123,4 +123,17 @@ class StoreOrderController extends BaseAdminController return $this->success('退款成功'); } + /** + * 设置配送员 + */ + public function set_delivery(){ + $id=$this->request->post('id'); + $delivery_uid=$this->request->post('delivery_uid'); + $res=StoreOrder::where('id',$id)->update(['delivery_uid'=>$delivery_uid]); + if($res){ + return $this->success('设置成功'); + } + return $this->success('设置失败'); + + } } \ No newline at end of file diff --git a/app/admin/lists/delivery_service/DeliveryServiceLists.php b/app/admin/lists/delivery_service/DeliveryServiceLists.php new file mode 100644 index 000000000..e4dd2792a --- /dev/null +++ b/app/admin/lists/delivery_service/DeliveryServiceLists.php @@ -0,0 +1,65 @@ + ['uid', 'nickname', 'phone', 'status'], + ]; + } + + + /** + * @notes 获取配送员列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author admin + * @date 2024/08/08 14:07 + */ + public function lists(): array + { + return DeliveryService::where($this->searchWhere) + ->field(['id', 'uid', 'nickname', 'phone', 'status']) + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select() + ->toArray(); + } + + + /** + * @notes 获取配送员数量 + * @return int + * @author admin + * @date 2024/08/08 14:07 + */ + public function count(): int + { + return DeliveryService::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/admin/logic/delivery_service/DeliveryServiceLogic.php b/app/admin/logic/delivery_service/DeliveryServiceLogic.php new file mode 100644 index 000000000..c9a1eba72 --- /dev/null +++ b/app/admin/logic/delivery_service/DeliveryServiceLogic.php @@ -0,0 +1,100 @@ + $params['uid'], + 'nickname' => $params['nickname'], + 'phone' => $params['phone'], + 'status' => $params['status'] + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 编辑配送员 + * @param array $params + * @return bool + * @author admin + * @date 2024/08/08 14:07 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + DeliveryService::where('id', $params['id'])->update([ + 'uid' => $params['uid'], + 'nickname' => $params['nickname'], + 'phone' => $params['phone'], + 'status' => $params['status'] + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 删除配送员 + * @param array $params + * @return bool + * @author admin + * @date 2024/08/08 14:07 + */ + public static function delete(array $params): bool + { + return DeliveryService::destroy($params['id']); + } + + + /** + * @notes 获取配送员详情 + * @param $params + * @return array + * @author admin + * @date 2024/08/08 14:07 + */ + public static function detail($params): array + { + return DeliveryService::findOrEmpty($params['id'])->toArray(); + } +} \ No newline at end of file diff --git a/app/admin/logic/warehouse_product/WarehouseProductLogic.php b/app/admin/logic/warehouse_product/WarehouseProductLogic.php index 6ef86a0d9..25f6b2d04 100644 --- a/app/admin/logic/warehouse_product/WarehouseProductLogic.php +++ b/app/admin/logic/warehouse_product/WarehouseProductLogic.php @@ -157,13 +157,15 @@ class WarehouseProductLogic extends BaseLogic } elseif ($res['financial_pm'] == 0) { $find = SystemStoreStorage::where(['outbound_id' => $res['id']])->find(); if ($find) { - $stock = StoreBranchProduct::where(['store_id' => $res['store_id'], 'product_id' => $res['product_id']])->value('stock'); - if ($stock < $res['nums']) { - self::setError('商品库存不足,无法退回'); - return false; + if($find['status']==1){ + $stock = StoreBranchProduct::where(['store_id' => $res['store_id'], 'product_id' => $res['product_id']])->value('stock'); + if ($stock < $res['nums']) { + self::setError('商品库存不足,无法退回'); + return false; + } + StoreBranchProduct::where(['store_id' => $res['store_id'], 'product_id' => $res['product_id']])->dec('stock', $res['nums'])->update(); } $find->delete(); - StoreBranchProduct::where(['store_id' => $res['store_id'], 'product_id' => $res['product_id']])->dec('stock', $res['nums'])->update(); } WarehouseProductStorege::where('warehouse_id', $res['warehouse_id'])->inc('nums', $res['nums'])->update(); } diff --git a/app/admin/validate/delivery_service/DeliveryServiceValidate.php b/app/admin/validate/delivery_service/DeliveryServiceValidate.php new file mode 100644 index 000000000..9932064c4 --- /dev/null +++ b/app/admin/validate/delivery_service/DeliveryServiceValidate.php @@ -0,0 +1,88 @@ + 'require', + 'uid' => 'require', + 'nickname' => 'require', + 'phone' => 'require', + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + 'uid' => '配送员uid', + 'nickname' => '配送员名称', + 'phone' => '手机号码', + ]; + + + /** + * @notes 添加场景 + * @return DeliveryServiceValidate + * @author admin + * @date 2024/08/08 14:07 + */ + public function sceneAdd() + { + return $this->only(['uid','nickname','phone']); + } + + + /** + * @notes 编辑场景 + * @return DeliveryServiceValidate + * @author admin + * @date 2024/08/08 14:07 + */ + public function sceneEdit() + { + return $this->only(['id','uid','nickname','phone']); + } + + + /** + * @notes 删除场景 + * @return DeliveryServiceValidate + * @author admin + * @date 2024/08/08 14:07 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return DeliveryServiceValidate + * @author admin + * @date 2024/08/08 14:07 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + +} \ No newline at end of file diff --git a/app/common/model/delivery_service/DeliveryService.php b/app/common/model/delivery_service/DeliveryService.php new file mode 100644 index 000000000..6c0789f06 --- /dev/null +++ b/app/common/model/delivery_service/DeliveryService.php @@ -0,0 +1,22 @@ +