From df4a0feb5d47300964c96a65cce6c64ba60282cc Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Fri, 20 Sep 2024 10:53:00 +0800 Subject: [PATCH 01/32] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E4=BF=A1=E6=81=AF=E6=9F=A5=E8=AF=A2=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../StoreOrderCartInfoTwoLists.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/app/admin/lists/store_order_cart_info/StoreOrderCartInfoTwoLists.php b/app/admin/lists/store_order_cart_info/StoreOrderCartInfoTwoLists.php index 6d5716796..5f099fa53 100644 --- a/app/admin/lists/store_order_cart_info/StoreOrderCartInfoTwoLists.php +++ b/app/admin/lists/store_order_cart_info/StoreOrderCartInfoTwoLists.php @@ -14,6 +14,7 @@ use app\common\model\store_order_cart_info\StoreOrderCartInfo; use app\common\model\store_product\StoreProduct; use app\common\model\store_product_unit\StoreProductUnit; use app\common\model\system_store\SystemStore; +use app\common\model\user\User; /** * 订单购物详情列表 @@ -75,11 +76,24 @@ class StoreOrderCartInfoTwoLists extends BaseAdminDataLists implements ListsSear return $query->limit($this->limitOffset, $this->limitLength) ->select()->each(function ($item) use($is_group){ $find = StoreProduct::where('id', $item['product_id'])->field('image,unit,cate_id,store_name,store_info')->find(); + $item['nickname']=''; + $item['mobile']=''; if ($find) { $item['image'] = $find['image']; //商品图片 if($is_group==1){ $item['store_name'] = $find['store_name'].'-'.$item['create_time']; //商品名称 }else{ + if($item['uid']>0){ + $user=User::where('id',$item['uid'])->field('real_name,mobile')->find(); + if($user){ + $item['mobile']=$user['mobile']; + if($user['real_name']!=''){ + $item['nickname']=$user['real_name']; + }else{ + $item['nickname']=$user['mobile']; + } + } + } $item['store_name'] = $find['store_name']; //商品名称 } $item['store_info'] = $find['store_info']; //商品规格 @@ -156,6 +170,8 @@ class StoreOrderCartInfoTwoLists extends BaseAdminDataLists implements ListsSear 'cart_num' => '数量', 'price' => '单价', 'total_price' => '总价', + 'nickname' => '用户', + 'mobile' => '手机', 'create_time' => '时间', ]; } From bd113c4ea28d0dd52ce881c737d068449e54a32f Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Fri, 20 Sep 2024 10:55:38 +0800 Subject: [PATCH 02/32] =?UTF-8?q?feat(StoreOrderCartInfoTwoLists):=20?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=9F=A5=E8=AF=A2=E9=80=BB=E8=BE=91=EF=BC=8C?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=AF=B9UID=E7=9A=84=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../store_order_cart_info/StoreOrderCartInfoTwoLists.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/admin/lists/store_order_cart_info/StoreOrderCartInfoTwoLists.php b/app/admin/lists/store_order_cart_info/StoreOrderCartInfoTwoLists.php index 5f099fa53..e35cd1912 100644 --- a/app/admin/lists/store_order_cart_info/StoreOrderCartInfoTwoLists.php +++ b/app/admin/lists/store_order_cart_info/StoreOrderCartInfoTwoLists.php @@ -71,7 +71,7 @@ class StoreOrderCartInfoTwoLists extends BaseAdminDataLists implements ListsSear if ($is_group == 1) { $query->field('store_id,product_id,price,SUM(total_price) as total_price,SUM(cart_num) as cart_num')->group(['store_id', 'product_id']); } else { - $query->field('store_id,product_id,price,total_price,cart_num,create_time'); + $query->field('store_id,product_id,price,total_price,cart_num,create_time,uid'); } return $query->limit($this->limitOffset, $this->limitLength) ->select()->each(function ($item) use($is_group){ @@ -83,7 +83,7 @@ class StoreOrderCartInfoTwoLists extends BaseAdminDataLists implements ListsSear if($is_group==1){ $item['store_name'] = $find['store_name'].'-'.$item['create_time']; //商品名称 }else{ - if($item['uid']>0){ + if(isset($item['uid'])&&$item['uid']>0){ $user=User::where('id',$item['uid'])->field('real_name,mobile')->find(); if($user){ $item['mobile']=$user['mobile']; From 28c25f9b3212fbecc5326771da69b9c88b06af1b Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Fri, 20 Sep 2024 11:07:33 +0800 Subject: [PATCH 03/32] =?UTF-8?q?feat(StoreOrderCartInfoTwoLists):=20?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=AF=BC=E5=87=BA=E8=AE=A2=E5=8D=95=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../store_order_cart_info/StoreOrderCartInfoTwoLists.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/admin/lists/store_order_cart_info/StoreOrderCartInfoTwoLists.php b/app/admin/lists/store_order_cart_info/StoreOrderCartInfoTwoLists.php index e35cd1912..f8ed19442 100644 --- a/app/admin/lists/store_order_cart_info/StoreOrderCartInfoTwoLists.php +++ b/app/admin/lists/store_order_cart_info/StoreOrderCartInfoTwoLists.php @@ -65,6 +65,7 @@ class StoreOrderCartInfoTwoLists extends BaseAdminDataLists implements ListsSear $this->searchWhere[] = ['create_time', 'between', [strtotime(date('Y-m-d 00:00:00')), strtotime(date('Y-m-d 23:59:59'))]]; } $is_group=$this->request->get('is_group'); + $export=$this->request->get('export',0); $this->searchWhere[] = ['is_pay', '=', 1]; $this->searchWhere[] = ['status', '>=', 0]; $query = StoreOrderCartInfo::where($this->searchWhere); @@ -74,10 +75,14 @@ class StoreOrderCartInfoTwoLists extends BaseAdminDataLists implements ListsSear $query->field('store_id,product_id,price,total_price,cart_num,create_time,uid'); } return $query->limit($this->limitOffset, $this->limitLength) - ->select()->each(function ($item) use($is_group){ + ->select()->each(function ($item) use($is_group,$export){ $find = StoreProduct::where('id', $item['product_id'])->field('image,unit,cate_id,store_name,store_info')->find(); $item['nickname']=''; $item['mobile']=''; + $item['order_id']=''; + if($export>0){ + $item['order_id']=StoreOrder::where('id',$item['oid'])->value('order_id'); + } if ($find) { $item['image'] = $find['image']; //商品图片 if($is_group==1){ @@ -162,6 +167,7 @@ class StoreOrderCartInfoTwoLists extends BaseAdminDataLists implements ListsSear ]; } else { $data = [ + 'order_id' => '订单', 'system_store' => '门店', 'store_name' => '商品名称', 'store_info' => '规格', From e97088cd6a753280661c974a0f2f278c73fbe790 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Fri, 20 Sep 2024 11:10:13 +0800 Subject: [PATCH 04/32] =?UTF-8?q?feat(StoreOrderCartInfoTwoLists):=20?= =?UTF-8?q?=E6=A0=B9=E6=8D=AE=E8=AF=B7=E6=B1=82=E5=8F=82=E6=95=B0=E8=B0=83?= =?UTF-8?q?=E6=95=B4=E5=AF=BC=E5=87=BA=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../store_order_cart_info/StoreOrderCartInfoTwoLists.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/admin/lists/store_order_cart_info/StoreOrderCartInfoTwoLists.php b/app/admin/lists/store_order_cart_info/StoreOrderCartInfoTwoLists.php index f8ed19442..c7ed6245f 100644 --- a/app/admin/lists/store_order_cart_info/StoreOrderCartInfoTwoLists.php +++ b/app/admin/lists/store_order_cart_info/StoreOrderCartInfoTwoLists.php @@ -65,7 +65,7 @@ class StoreOrderCartInfoTwoLists extends BaseAdminDataLists implements ListsSear $this->searchWhere[] = ['create_time', 'between', [strtotime(date('Y-m-d 00:00:00')), strtotime(date('Y-m-d 23:59:59'))]]; } $is_group=$this->request->get('is_group'); - $export=$this->request->get('export',0); + $export=$this->request->get('export'); $this->searchWhere[] = ['is_pay', '=', 1]; $this->searchWhere[] = ['status', '>=', 0]; $query = StoreOrderCartInfo::where($this->searchWhere); @@ -80,7 +80,7 @@ class StoreOrderCartInfoTwoLists extends BaseAdminDataLists implements ListsSear $item['nickname']=''; $item['mobile']=''; $item['order_id']=''; - if($export>0){ + if($export==2){ $item['order_id']=StoreOrder::where('id',$item['oid'])->value('order_id'); } if ($find) { From 29b750b177844d0b7c62a19bbb77f9a267eaa401 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Fri, 20 Sep 2024 11:13:54 +0800 Subject: [PATCH 05/32] =?UTF-8?q?feat(StoreOrderCartInfoTwoLists):=20?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=9F=A5=E8=AF=A2=E5=AD=97=E6=AE=B5=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0oid?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lists/store_order_cart_info/StoreOrderCartInfoTwoLists.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/admin/lists/store_order_cart_info/StoreOrderCartInfoTwoLists.php b/app/admin/lists/store_order_cart_info/StoreOrderCartInfoTwoLists.php index c7ed6245f..b07e8d8c8 100644 --- a/app/admin/lists/store_order_cart_info/StoreOrderCartInfoTwoLists.php +++ b/app/admin/lists/store_order_cart_info/StoreOrderCartInfoTwoLists.php @@ -72,7 +72,7 @@ class StoreOrderCartInfoTwoLists extends BaseAdminDataLists implements ListsSear if ($is_group == 1) { $query->field('store_id,product_id,price,SUM(total_price) as total_price,SUM(cart_num) as cart_num')->group(['store_id', 'product_id']); } else { - $query->field('store_id,product_id,price,total_price,cart_num,create_time,uid'); + $query->field('store_id,product_id,price,total_price,cart_num,create_time,uid,oid'); } return $query->limit($this->limitOffset, $this->limitLength) ->select()->each(function ($item) use($is_group,$export){ From 1b876d13dcf22187826f0a305dbb7b8283621faa Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Sat, 21 Sep 2024 21:45:16 +0800 Subject: [PATCH 06/32] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9=E4=BA=86?= =?UTF-8?q?=E6=94=AF=E4=BB=98=E9=80=BB=E8=BE=91=E4=BB=A5=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E6=B5=AE=E7=82=B9=E6=95=B0=E9=87=91=E9=A2=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/logic/PaymentLogic.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/common/logic/PaymentLogic.php b/app/common/logic/PaymentLogic.php index 433c6a625..f834602a8 100644 --- a/app/common/logic/PaymentLogic.php +++ b/app/common/logic/PaymentLogic.php @@ -90,7 +90,7 @@ class PaymentLogic extends BaseLogic 'auth_code' => (string)$auth_code ], 'amount' => [ - 'total' => intval($order['pay_price'] * 100), + 'total' => intval(bcmul($order['pay_price'],100)), ], 'scene_info' => [ "store_info" => [ From 04eabec632494e2dddbbb353c7714e5967107b17 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Sun, 22 Sep 2024 11:45:25 +0800 Subject: [PATCH 07/32] =?UTF-8?q?feat:=20=E4=BD=BF=E7=94=A8withTrashed?= =?UTF-8?q?=E6=96=B9=E6=B3=95=E6=9F=A5=E8=AF=A2=E5=B8=A6=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E6=A0=87=E8=AE=B0=E7=9A=84=E4=BA=A7=E5=93=81=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lists/store_order_cart_info/StoreOrderCartInfoLists.php | 2 +- app/admin/lists/warehouse_product/WarehouseProductLists.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/admin/lists/store_order_cart_info/StoreOrderCartInfoLists.php b/app/admin/lists/store_order_cart_info/StoreOrderCartInfoLists.php index 7a6dab6aa..e2441d5e6 100644 --- a/app/admin/lists/store_order_cart_info/StoreOrderCartInfoLists.php +++ b/app/admin/lists/store_order_cart_info/StoreOrderCartInfoLists.php @@ -53,7 +53,7 @@ class StoreOrderCartInfoLists extends BaseAdminDataLists implements ListsSearchI return StoreOrderCartInfo::where($this->searchWhere) ->field('id,oid,uid,product_id,store_id,cart_num,price,total_price,create_time')->limit($this->limitOffset, $this->limitLength) ->select()->each(function ($item) { - $find=StoreProduct::where('id',$item['product_id'])->field('image,unit,store_name,store_info')->find(); + $find=StoreProduct::where('id',$item['product_id'])->field('image,unit,store_name,store_info')->withTrashed()->find(); $item['nickname']='无'; $item['mobile']=''; if($find){ diff --git a/app/admin/lists/warehouse_product/WarehouseProductLists.php b/app/admin/lists/warehouse_product/WarehouseProductLists.php index db24996c7..5ca083b90 100644 --- a/app/admin/lists/warehouse_product/WarehouseProductLists.php +++ b/app/admin/lists/warehouse_product/WarehouseProductLists.php @@ -52,7 +52,7 @@ class WarehouseProductLists extends BaseAdminDataLists implements ListsSearchInt { if ($this->request->get('product_id')) { $product_id = $this->request->get('product_id'); - $ids = StoreProduct::where('store_name', 'like', '%' . $product_id . '%')->column('id'); + $ids = StoreProduct::where('store_name', 'like', '%' . $product_id . '%')->withTrashed()->column('id'); if ($ids) { $this->searchWhere[] = ['product_id', 'in', $ids]; $this->ids = $ids; @@ -62,7 +62,7 @@ class WarehouseProductLists extends BaseAdminDataLists implements ListsSearchInt } if ($this->request->get('bar_code')) { $bar_code = $this->request->get('bar_code'); - $ids = StoreProduct::where('bar_code', 'like', '%' . $bar_code . '%')->column('id'); + $ids = StoreProduct::where('bar_code', 'like', '%' . $bar_code . '%')->withTrashed()->column('id'); if ($ids) { $this->searchWhere[] = ['product_id', 'in', $ids]; $this->ids = $ids; From 0c485b8433651ea8fd84623c6490c69fb12c0f5c Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Sun, 22 Sep 2024 12:00:36 +0800 Subject: [PATCH 08/32] =?UTF-8?q?feat(WarehouseOrderController):=20?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BB=93=E5=BA=93=E8=AE=A2=E5=8D=95=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E6=96=B9=E6=B3=95=EF=BC=8C=E5=8A=A0=E5=85=A5=E8=BD=AF?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/warehouse_order/WarehouseOrderController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/admin/controller/warehouse_order/WarehouseOrderController.php b/app/admin/controller/warehouse_order/WarehouseOrderController.php index 787347de1..071cfa386 100644 --- a/app/admin/controller/warehouse_order/WarehouseOrderController.php +++ b/app/admin/controller/warehouse_order/WarehouseOrderController.php @@ -228,9 +228,9 @@ class WarehouseOrderController extends BaseAdminController $total_price=0; foreach ($data as $key => &$value) { if(in_array($order['store_id'],[17,18])){ - $find = StoreBranchProduct::where('product_id', $value->product_id)->where('store_id',$order['store_id'])->find(); + $find = StoreBranchProduct::where('product_id', $value->product_id)->where('store_id',$order['store_id'])->withTrashed()->find(); }else{ - $find = StoreProduct::where('id', $value->product_id)->find(); + $find = StoreProduct::where('id', $value->product_id)->withTrashed()->find(); } $value->store_name = $find['store_name'] ?? ''; $value->store_info = $find['store_info'] ?? ''; From a8f1887b4530a187a87688d0503fa77e42c26494 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Mon, 23 Sep 2024 15:14:09 +0800 Subject: [PATCH 09/32] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E5=B0=8F?= =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E5=AF=BC=E8=88=AA=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/logic/store_order/StoreOrderLogic.php | 7 ++++++- app/api/controller/store/StoreController.php | 15 +++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/app/admin/logic/store_order/StoreOrderLogic.php b/app/admin/logic/store_order/StoreOrderLogic.php index 02a3e8f97..94910e3b0 100644 --- a/app/admin/logic/store_order/StoreOrderLogic.php +++ b/app/admin/logic/store_order/StoreOrderLogic.php @@ -49,7 +49,12 @@ class StoreOrderLogic extends BaseLogic $v['store_id'] = $params['store_id']; $v['cart_num'] = $v['stock']; if(in_array($params['store_id'],$vendors_store)){ - StoreBranchProduct::where('id', $v['id'])->update(['price' => $v['price'], 'vip_price' => $v['price'], 'cost' => $v['price'], 'purchase' => $v['price']]); + if(isset($v['purchase']) && $v['purchase'] > 0){ + $purchase = $v['purchase']; + }else{ + $purchase=$v['price']; + } + StoreBranchProduct::where('id', $v['id'])->update(['price' => $v['price'], 'vip_price' => $v['price'], 'cost' => $v['price'], 'purchase' => $purchase]); } unset($v['id']); $res = CartLogic::add($v); diff --git a/app/api/controller/store/StoreController.php b/app/api/controller/store/StoreController.php index cbf9528f2..ab251819a 100644 --- a/app/api/controller/store/StoreController.php +++ b/app/api/controller/store/StoreController.php @@ -194,4 +194,19 @@ class StoreController extends BaseApiController return $this->success('ok',['count'=>$count,'create_log'=>$createLog]); } + + /** + * 小程序导航 + */ + public function menu_list(){ + $menu=[ + ['name'=>'每日配送统计'], + ['name'=>'累计配送统计'], + ['name'=>'每日销量统计'], + ['name'=>'累计销量统计'], + ['name'=>'商品库存'], + ['name'=>'店铺收支'] + ]; + return $this->success('ok',['menu'=>$menu]); + } } From 1d8e9a9a36378f946effc2e927d06dc6f85205cc Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Mon, 23 Sep 2024 18:45:57 +0800 Subject: [PATCH 10/32] =?UTF-8?q?feat(menu):=20=E6=9B=B4=E6=96=B0=E5=BA=97?= =?UTF-8?q?=E9=93=BA=E8=8F=9C=E5=8D=95=E9=93=BE=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BranchProductController.php | 19 ++++ app/api/controller/store/StoreController.php | 13 ++- .../StoreOrderCartInfoController.php | 29 +++++ .../branch_product/BranchProductLists.php | 104 ++++++++++++++++++ .../StoreOrderCartInfoLists.php | 95 ++++++++++++++++ 5 files changed, 254 insertions(+), 6 deletions(-) create mode 100644 app/api/controller/branch_product/BranchProductController.php create mode 100644 app/api/controller/store_order_cart_info/StoreOrderCartInfoController.php create mode 100644 app/api/lists/branch_product/BranchProductLists.php create mode 100644 app/api/lists/store_order_cart_info/StoreOrderCartInfoLists.php diff --git a/app/api/controller/branch_product/BranchProductController.php b/app/api/controller/branch_product/BranchProductController.php new file mode 100644 index 000000000..c08f43515 --- /dev/null +++ b/app/api/controller/branch_product/BranchProductController.php @@ -0,0 +1,19 @@ +dataLists(new BranchProductLists()); + } +} diff --git a/app/api/controller/store/StoreController.php b/app/api/controller/store/StoreController.php index ab251819a..462caf03d 100644 --- a/app/api/controller/store/StoreController.php +++ b/app/api/controller/store/StoreController.php @@ -200,12 +200,13 @@ class StoreController extends BaseApiController */ public function menu_list(){ $menu=[ - ['name'=>'每日配送统计'], - ['name'=>'累计配送统计'], - ['name'=>'每日销量统计'], - ['name'=>'累计销量统计'], - ['name'=>'商品库存'], - ['name'=>'店铺收支'] + ['name'=>'每日配送统计','url'=>'/pagesOrder/deliveryOrder/index'], + ['name'=>'累计配送统计','url'=>'/pagesOrder/deliveryOrder/count'], + ['name'=>'每日销量统计','url'=>'/pagesOrder/productSales/index'], + ['name'=>'累计销量统计','url'=>'/pagesOrder/productSales/count'], + ['name'=>'商品库存','url'=>'/pagesOrder/store_product/index'], + ['name'=>'订单列表','url'=>'/pagesOrder/delivery/index'], + ['name'=>'店铺收支'], ]; return $this->success('ok',['menu'=>$menu]); } diff --git a/app/api/controller/store_order_cart_info/StoreOrderCartInfoController.php b/app/api/controller/store_order_cart_info/StoreOrderCartInfoController.php new file mode 100644 index 000000000..3eb6b0fea --- /dev/null +++ b/app/api/controller/store_order_cart_info/StoreOrderCartInfoController.php @@ -0,0 +1,29 @@ +dataLists(new CateLists()); + } + + +} diff --git a/app/api/lists/branch_product/BranchProductLists.php b/app/api/lists/branch_product/BranchProductLists.php new file mode 100644 index 000000000..109f22be7 --- /dev/null +++ b/app/api/lists/branch_product/BranchProductLists.php @@ -0,0 +1,104 @@ + [ 'cate_id', 'top_cate_id', 'two_cate_id'], + '%pipe_like%' => ['store_name' => 'store_name|bar_code'], + ]; + } + /** + * @notes 设置支持排序字段 + * @return string[] + * @date 2021/12/29 10:07 + * @remark 格式: ['前端传过来的字段名' => '数据库中的字段名']; + */ + public function setSortFields(): array + { + return ['sell' => 'price', 'sales' => 'sales',]; + } + + + /** + * @notes 设置默认排序 + * @return string[] + * @date 2021/12/29 10:06 + */ + public function setDefaultOrder(): array + { + return ['sort'=>'desc','price' => 'asc', 'id' => 'desc']; + } + + /** + * @notes 获取商品列表列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author likeadmin + * @date 2024/04/23 11:28 + */ + public function lists(): array + { + // $order = $this->request->get('order', ''); + // $field = $this->request->get('field', ''); + // if (empty($order) || empty($field)) { + // $order = $this->sortOrder; + // } else { + // $order = [$field => $order]; + // } + $fields = 'id,top_cate_id,cate_id,store_name,cost,vip_price,purchase,price,bar_code,image,sales,store_info,unit,batch,two_cate_id,stock,is_lack'; + + $tag = ''; + + $this->searchWhere[] = ['is_show', '=', 1]; + $this->searchWhere[] = ['product_type', 'in', [0,4]]; + return StoreBranchProduct::where($this->searchWhere) + ->field($fields) + ->with(['className', 'unitName']) + ->limit($this->limitOffset, $this->limitLength) + ->order($this->sortOrder) + ->select()->each(function ($item) use ($tag) { + if($item['is_lack']==1){ + $tag='缺货'; + } + $item['tag'] = $tag; + return $item; + }) + ->toArray(); + } + + + /** + * @notes 获取商品列表数量 + * @return int + * @author likeadmin + * @date 2024/04/23 11:28 + */ + public function count(): int + { + return StoreBranchProduct::where($this->searchWhere) + ->count(); + } +} diff --git a/app/api/lists/store_order_cart_info/StoreOrderCartInfoLists.php b/app/api/lists/store_order_cart_info/StoreOrderCartInfoLists.php new file mode 100644 index 000000000..8bc43530a --- /dev/null +++ b/app/api/lists/store_order_cart_info/StoreOrderCartInfoLists.php @@ -0,0 +1,95 @@ + 'create_time' + ]; + } + + + /** + * @notes 获取地址列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @date 2024/04/27 11:26 + */ + public function lists(): array + { + $store_id=$this->request->__get('store_id'); + if(!$store_id) return []; + // if ($this->request->get('start_time') == '') { + // $this->searchWhere[] = ['create_time', 'between', [strtotime(date('Y-m-d 00:00:00')), strtotime(date('Y-m-d 23:59:59'))]]; + // } + $is_group=$this->request->get('is_group'); + $this->searchWhere[] = ['is_pay', '=', 1]; + $this->searchWhere[] = ['status', '>=', 0]; + $this->searchWhere[] = ['store_id', '=', 1]; + $query = StoreOrderCartInfo::where($this->searchWhere); + if ($is_group == 1) { + $query->field('store_id,product_id,price,SUM(total_price) as total_price,SUM(cart_num) as cart_num')->group(['store_id', 'product_id']); + } else { + $query->field('store_id,product_id,price,total_price,cart_num,create_time,uid,oid'); + } + return $query->limit($this->limitOffset, $this->limitLength) + ->select()->each(function ($item){ + $find = StoreProduct::where('id', $item['product_id'])->field('image,unit,cate_id,store_name,store_info')->withTrashed()->find(); + if ($find) { + $item['image'] = $find['image']; //商品图片 + + $item['store_name'] = $find['store_name']; //商品名称 + + $item['store_info'] = $find['store_info']; //商品规格 + $item['unit_name'] = StoreProductUnit::where('id', $find['unit'])->value('name') ?? ''; + $item['cate_name'] = StoreCategory::where('id', $find['cate_id'])->value('name') ?? ''; + } else { + $item['image'] = ''; //商品图片 + $item['store_name'] = ''; //商品名称 + $item['store_info'] = ''; //商品规格-(数据库叫商品简介) + $item['unit_name'] = ''; // + $item['cate_name'] = ''; // + $item['system_store'] = ''; // + } + return $item; //返回处理后的数据。 + }) + ->toArray(); + } + + + /** + * @notes 获取地址数量 + * @return int + * @date 2024/04/27 11:26 + */ + public function count(): int + { + return StoreOrderCartInfo::where($this->searchWhere)->count(); + } + +} \ No newline at end of file From 64396fe1b5d7596e8521d7253746fb3b12ebd7bc Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Wed, 25 Sep 2024 17:40:46 +0800 Subject: [PATCH 11/32] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E4=BA=86?= =?UTF-8?q?=E6=A0=B9=E6=8D=AE=E8=AE=A2=E5=8D=95ID=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E8=AE=A2=E5=8D=95=E8=AF=A6=E7=BB=86=E4=BF=A1=E6=81=AF=E7=9A=84?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../WarehouseOrderController.php | 8 ++ .../StoreOrderCartInfoController.php | 13 +- .../SystemStoreStorageController.php | 39 ++++++ app/api/lists/order/OrderList.php | 1 - .../StoreOrderCartInfoGroupLists.php | 96 +++++++++++++++ .../StoreOrderCartInfoLists.php | 21 ++-- .../SystemStoreStorageGroupLists.php | 115 +++++++++++++++++ .../SystemStoreStorageLists.php | 116 ++++++++++++++++++ app/api/logic/order/OrderLogic.php | 1 - app/common/service/xlsx/OrderDetail.php | 10 +- 10 files changed, 403 insertions(+), 17 deletions(-) create mode 100644 app/api/controller/system_store_storage/SystemStoreStorageController.php create mode 100644 app/api/lists/store_order_cart_info/StoreOrderCartInfoGroupLists.php create mode 100644 app/api/lists/system_store_storage/SystemStoreStorageGroupLists.php create mode 100644 app/api/lists/system_store_storage/SystemStoreStorageLists.php diff --git a/app/admin/controller/warehouse_order/WarehouseOrderController.php b/app/admin/controller/warehouse_order/WarehouseOrderController.php index 071cfa386..5c0a32030 100644 --- a/app/admin/controller/warehouse_order/WarehouseOrderController.php +++ b/app/admin/controller/warehouse_order/WarehouseOrderController.php @@ -10,6 +10,7 @@ use app\admin\logic\warehouse_order\WarehouseOrderLogic; use app\admin\logic\warehouse_product\WarehouseProductLogic; use app\admin\validate\warehouse_order\WarehouseOrderValidate; use app\common\model\store_branch_product\StoreBranchProduct; +use app\common\model\store_order\StoreOrder; use app\common\model\store_product\StoreProduct; use app\common\model\store_product_unit\StoreProductUnit; use app\common\model\system_store\SystemStore; @@ -263,6 +264,13 @@ class WarehouseOrderController extends BaseAdminController $order['delivery_time']=date('Y-m-d H:i:s',$order['delivery_time']); $order['pay_time']=$order['create_time']; $order['order_id']=$order['code']; + + if($order['oid']>0){ + $orders=StoreOrder::where('id',$order['oid'])->findOrEmpty(); + $order['real_name']=$orders['real_name']; + $order['user_phone']=$orders['user_phone']; + $order['user_address']=$orders['user_address']; + } $file_path = $xlsx->export($data, $system_store, $order); return $this->success('导出成功', ['url' => $file_path]); diff --git a/app/api/controller/store_order_cart_info/StoreOrderCartInfoController.php b/app/api/controller/store_order_cart_info/StoreOrderCartInfoController.php index 3eb6b0fea..e85d6710d 100644 --- a/app/api/controller/store_order_cart_info/StoreOrderCartInfoController.php +++ b/app/api/controller/store_order_cart_info/StoreOrderCartInfoController.php @@ -4,8 +4,8 @@ namespace app\api\controller\store_order_cart_info; use app\api\controller\BaseApiController; -use app\api\lists\store_order_cart_info\CateLists; - +use app\api\lists\store_order_cart_info\StoreOrderCartInfoGroupLists; +use app\api\lists\store_order_cart_info\StoreOrderCartInfoLists; /** * 商品销量控制器 @@ -22,8 +22,13 @@ class StoreOrderCartInfoController extends BaseApiController */ public function lists() { - return $this->dataLists(new CateLists()); + $this->request->__set('store_id',5); + return $this->dataLists(new StoreOrderCartInfoLists()); } - + public function group_lists() + { + $this->request->__set('store_id',5); + return $this->dataLists(new StoreOrderCartInfoGroupLists()); + } } diff --git a/app/api/controller/system_store_storage/SystemStoreStorageController.php b/app/api/controller/system_store_storage/SystemStoreStorageController.php new file mode 100644 index 000000000..a2dcf4cea --- /dev/null +++ b/app/api/controller/system_store_storage/SystemStoreStorageController.php @@ -0,0 +1,39 @@ +dataLists(new SystemStoreStorageLists()); + } + /** + * @notes 获取商品分类列表 + * @return + * @author likeadmin + * @date 2024/04/23 10:27 + */ + public function group_lists() + { + return $this->dataLists(new SystemStoreStorageGroupLists()); + } + +} diff --git a/app/api/lists/order/OrderList.php b/app/api/lists/order/OrderList.php index 5e6652654..525ebac18 100644 --- a/app/api/lists/order/OrderList.php +++ b/app/api/lists/order/OrderList.php @@ -46,7 +46,6 @@ class OrderList extends BaseAdminDataLists implements ListsSearchInterface $userId = $this->request->userId; if (!$userId) return []; $data = StoreOrder::with(['store'])->where($this->searchWhere)->where(['uid'=>$userId]) - ->whereIn('shipping_type',[1,2]) ->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) ->select() diff --git a/app/api/lists/store_order_cart_info/StoreOrderCartInfoGroupLists.php b/app/api/lists/store_order_cart_info/StoreOrderCartInfoGroupLists.php new file mode 100644 index 000000000..31aaa6659 --- /dev/null +++ b/app/api/lists/store_order_cart_info/StoreOrderCartInfoGroupLists.php @@ -0,0 +1,96 @@ + 'create_time' + ]; + } + + + /** + * @notes 获取地址列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @date 2024/04/27 11:26 + */ + public function lists(): array + { + $store_id = $this->request->__get('store_id'); + if (!$store_id) return []; + if ($this->request->get('store_name')) { + $store_name = $this->request->get('store_name'); + $ids = StoreProduct::where('store_name', 'like', '%' . $store_name . '%')->column('id'); + if ($ids) { + $this->searchWhere[] = ['product_id', 'in', $ids]; + } else { + return []; + } + } + $this->searchWhere[] = ['is_pay', '=', 1]; + $this->searchWhere[] = ['status', '>=', 0]; + $this->searchWhere[] = ['store_id', '=', $store_id]; + $query = StoreOrderCartInfo::where($this->searchWhere); + $query->field('store_id,product_id,price,sum(total_price) as total_price,sum(cart_num) as cart_num'); + return $query->limit($this->limitOffset, $this->limitLength) + ->group('product_id') + ->select()->each(function ($item) { + $find = StoreProduct::where('id', $item['product_id'])->field('image,unit,cate_id,store_name,store_info')->withTrashed()->find(); + if ($find) { + $item['image'] = $find['image']; //商品图片 + + $item['store_name'] = $find['store_name']; //商品名称 + + $item['store_info'] = $find['store_info']; //商品规格 + $item['unit_name'] = StoreProductUnit::where('id', $find['unit'])->value('name') ?? ''; + $item['cate_name'] = StoreCategory::where('id', $find['cate_id'])->value('name') ?? ''; + } else { + $item['image'] = ''; //商品图片 + $item['store_name'] = ''; //商品名称 + $item['store_info'] = ''; //商品规格-(数据库叫商品简介) + $item['unit_name'] = ''; // + $item['cate_name'] = ''; // + $item['system_store'] = ''; // + } + return $item; //返回处理后的数据。 + }) + ->toArray(); + } + + + /** + * @notes 获取地址数量 + * @return int + * @date 2024/04/27 11:26 + */ + public function count(): int + { + return StoreOrderCartInfo::where($this->searchWhere)->count(); + } +} diff --git a/app/api/lists/store_order_cart_info/StoreOrderCartInfoLists.php b/app/api/lists/store_order_cart_info/StoreOrderCartInfoLists.php index 8bc43530a..b15faf5b0 100644 --- a/app/api/lists/store_order_cart_info/StoreOrderCartInfoLists.php +++ b/app/api/lists/store_order_cart_info/StoreOrderCartInfoLists.php @@ -44,19 +44,20 @@ class StoreOrderCartInfoLists extends BaseAdminDataLists implements ListsSearchI { $store_id=$this->request->__get('store_id'); if(!$store_id) return []; - // if ($this->request->get('start_time') == '') { - // $this->searchWhere[] = ['create_time', 'between', [strtotime(date('Y-m-d 00:00:00')), strtotime(date('Y-m-d 23:59:59'))]]; - // } - $is_group=$this->request->get('is_group'); + if ($this->request->get('store_name')) { + $store_name = $this->request->get('store_name'); + $ids = StoreProduct::where('store_name', 'like', '%' . $store_name . '%')->column('id'); + if ($ids) { + $this->searchWhere[] = ['product_id', 'in', $ids]; + } else { + return []; + } + } $this->searchWhere[] = ['is_pay', '=', 1]; $this->searchWhere[] = ['status', '>=', 0]; - $this->searchWhere[] = ['store_id', '=', 1]; + $this->searchWhere[] = ['store_id', '=', $store_id]; $query = StoreOrderCartInfo::where($this->searchWhere); - if ($is_group == 1) { - $query->field('store_id,product_id,price,SUM(total_price) as total_price,SUM(cart_num) as cart_num')->group(['store_id', 'product_id']); - } else { - $query->field('store_id,product_id,price,total_price,cart_num,create_time,uid,oid'); - } + $query->field('store_id,product_id,price,total_price,cart_num,create_time,uid,oid'); return $query->limit($this->limitOffset, $this->limitLength) ->select()->each(function ($item){ $find = StoreProduct::where('id', $item['product_id'])->field('image,unit,cate_id,store_name,store_info')->withTrashed()->find(); diff --git a/app/api/lists/system_store_storage/SystemStoreStorageGroupLists.php b/app/api/lists/system_store_storage/SystemStoreStorageGroupLists.php new file mode 100644 index 000000000..84fbaca3d --- /dev/null +++ b/app/api/lists/system_store_storage/SystemStoreStorageGroupLists.php @@ -0,0 +1,115 @@ + 'create_time', + ]; + } + /** + * @notes 设置支持排序字段 + * @return string[] + * @date 2021/12/29 10:07 + * @remark 格式: ['前端传过来的字段名' => '数据库中的字段名']; + */ + public function setSortFields(): array + { + return []; + } + + + /** + * @notes 设置默认排序 + * @return string[] + * @date 2021/12/29 10:06 + */ + public function setDefaultOrder(): array + { + return ['id' => 'desc']; + } + + /** + * @notes 获取商品列表列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author likeadmin + * @date 2024/04/23 11:28 + */ + public function lists(): array + { + $fields = 'store_id,product_id,sum(nums) as nums,mark'; + if ($this->request->get('store_name')) { + $store_name = $this->request->get('store_name'); + $ids = StoreProduct::where('store_name', 'like', '%' . $store_name . '%')->column('id'); + if ($ids) { + $this->searchWhere[] = ['product_id', 'in', $ids]; + } else { + return []; + } + } + $this->searchWhere[] = ['type', '=', 1]; + $this->searchWhere[] = ['status', '=', 1]; + return SystemStoreStorage::where($this->searchWhere) + ->field($fields) + ->group('product_id') + ->limit($this->limitOffset, $this->limitLength) + ->order($this->sortOrder) + ->select()->each(function ($item) { + $find=StoreProduct::where('id', $item['product_id'])->with(['className', 'unitName']) + ->field('id,store_name,image,unit,cate_id,store_info')->find(); + if($find){ + $item['store_name'] = $find['store_name']; + $item['image'] = $find['image']; + $item['unit_name'] = $find['unit_name']; + $item['class_name'] = $find['class_name']; + $item['store_info'] = $find['store_info']; + }else{ + $item['product_name'] = ''; + $item['product_image'] = ''; + $item['product_unit'] = ''; + $item['product_cate'] = ''; + $item['store_info'] = ''; + } + return $item; + }) + ->toArray(); + } + + + /** + * @notes 获取商品列表数量 + * @return int + * @author likeadmin + * @date 2024/04/23 11:28 + */ + public function count(): int + { + return SystemStoreStorage::where($this->searchWhere) + ->count(); + } +} diff --git a/app/api/lists/system_store_storage/SystemStoreStorageLists.php b/app/api/lists/system_store_storage/SystemStoreStorageLists.php new file mode 100644 index 000000000..f3674d2cb --- /dev/null +++ b/app/api/lists/system_store_storage/SystemStoreStorageLists.php @@ -0,0 +1,116 @@ + 'create_time', + ]; + } + /** + * @notes 设置支持排序字段 + * @return string[] + * @date 2021/12/29 10:07 + * @remark 格式: ['前端传过来的字段名' => '数据库中的字段名']; + */ + public function setSortFields(): array + { + return []; + } + + + /** + * @notes 设置默认排序 + * @return string[] + * @date 2021/12/29 10:06 + */ + public function setDefaultOrder(): array + { + return ['id' => 'desc']; + } + + /** + * @notes 获取商品列表列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author likeadmin + * @date 2024/04/23 11:28 + */ + public function lists(): array + { + $fields = 'id,store_id,staff_id,product_id,warehouse_id,nums,mark,status'; + if ($this->request->get('store_name')) { + $store_name = $this->request->get('store_name'); + $ids = StoreProduct::where('store_name', 'like', '%' . $store_name . '%')->column('id'); + if ($ids) { + $this->searchWhere[] = ['product_id', 'in', $ids]; + } else { + return []; + } + } + $this->searchWhere[] = ['type', '=', 1]; + return SystemStoreStorage::where($this->searchWhere) + ->field($fields) + ->limit($this->limitOffset, $this->limitLength) + ->order($this->sortOrder) + ->select()->each(function ($item) { + if($item['staff_id']>0){ + $item['staff_name']=SystemStoreStaff::where('id', $item['staff_id'])->value('staff_name'); + } + $find=StoreProduct::where('id', $item['product_id'])->with(['className', 'unitName']) + ->field('id,store_name,image,unit,cate_id,store_info')->find(); + if($find){ + $item['store_name'] = $find['store_name']; + $item['image'] = $find['image']; + $item['unit_name'] = $find['unit_name']; + $item['class_name'] = $find['class_name']; + $item['store_info'] = $find['store_info']; + }else{ + $item['product_name'] = ''; + $item['product_image'] = ''; + $item['product_unit'] = ''; + $item['product_cate'] = ''; + $item['store_info'] = ''; + } + return $item; + }) + ->toArray(); + } + + + /** + * @notes 获取商品列表数量 + * @return int + * @author likeadmin + * @date 2024/04/23 11:28 + */ + public function count(): int + { + return SystemStoreStorage::where($this->searchWhere) + ->count(); + } +} diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index a3f0b74c8..046e50d24 100644 --- a/app/api/logic/order/OrderLogic.php +++ b/app/api/logic/order/OrderLogic.php @@ -217,7 +217,6 @@ class OrderLogic extends BaseLogic // } //成本价 收益 $order = [ - 'create_time' => time(), 'order_id' => $params['order_id'] ?? getNewOrderId('PF'), 'total_price' => self::$total_price, //总价 'cost' => self::$cost, //成本价1- diff --git a/app/common/service/xlsx/OrderDetail.php b/app/common/service/xlsx/OrderDetail.php index 2fa5e115d..d210cad63 100644 --- a/app/common/service/xlsx/OrderDetail.php +++ b/app/common/service/xlsx/OrderDetail.php @@ -109,8 +109,16 @@ class OrderDetail $sheet->setCellValue('A' . $count + 12, '下单人',); $sheet->mergeCells('B' . ($count + 12) . ':C' . $count + 12); + $sheet->setCellValue('B' . ($count + 12), $order['real_name']??''); + $sheet->setCellValue('D' . $count + 12, '电话'); - + $sheet->mergeCells('E' . ($count + 12) . ':F' . $count + 12); + $sheet->setCellValue('E' . ($count + 12), $order['user_phone']??''); + + $sheet->setCellValue('G' . $count + 12, '地址'); + $sheet->mergeCells('H' . ($count + 12) . ':J' . $count + 12); + $sheet->setCellValue('H' . ($count + 12), $order['user_address']??''); + $sheet->setCellValue('A' . $count + 13, '仓库',); $sheet->mergeCells('B' . ($count + 13) . ':C' . $count + 13); $sheet->setCellValue('D' . $count + 13, '送货'); From 21baf23272ab8f8352c0b0090e95c5d912f2d22b Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Wed, 25 Sep 2024 17:59:54 +0800 Subject: [PATCH 12/32] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9=E5=95=86?= =?UTF-8?q?=E5=93=81=E5=88=97=E8=A1=A8API=EF=BC=8C=E5=A2=9E=E5=8A=A0'total?= =?UTF-8?q?=5Fprice'=E5=AD=97=E6=AE=B5=EF=BC=8C=E4=BF=AE=E5=A4=8D'is=5Flac?= =?UTF-8?q?k'=E5=88=A4=E6=96=AD=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lists/branch_product/BranchProductLists.php | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/app/api/lists/branch_product/BranchProductLists.php b/app/api/lists/branch_product/BranchProductLists.php index 109f22be7..d74a6a815 100644 --- a/app/api/lists/branch_product/BranchProductLists.php +++ b/app/api/lists/branch_product/BranchProductLists.php @@ -68,24 +68,16 @@ class BranchProductLists extends BaseApiDataLists implements ListsSearchInterfac // } else { // $order = [$field => $order]; // } - $fields = 'id,top_cate_id,cate_id,store_name,cost,vip_price,purchase,price,bar_code,image,sales,store_info,unit,batch,two_cate_id,stock,is_lack'; - - $tag = ''; - - $this->searchWhere[] = ['is_show', '=', 1]; + $fields = 'id,top_cate_id,cate_id,store_name,cost,vip_price,purchase,price,bar_code,image,sales,store_info,unit,batch,two_cate_id,stock,total_price'; + + $this->searchWhere[] = ['status', '=', 1]; $this->searchWhere[] = ['product_type', 'in', [0,4]]; return StoreBranchProduct::where($this->searchWhere) ->field($fields) ->with(['className', 'unitName']) ->limit($this->limitOffset, $this->limitLength) ->order($this->sortOrder) - ->select()->each(function ($item) use ($tag) { - if($item['is_lack']==1){ - $tag='缺货'; - } - $item['tag'] = $tag; - return $item; - }) + ->select() ->toArray(); } From 0b42d7553abe4ab57cec1a24edaa36fc1ba45153 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Wed, 25 Sep 2024 20:45:48 +0800 Subject: [PATCH 13/32] =?UTF-8?q?feat(BranchProductLists):=20=E6=A0=B9?= =?UTF-8?q?=E6=8D=AE=E8=AF=B7=E6=B1=82=E5=8F=82=E6=95=B0=E8=B0=83=E6=95=B4?= =?UTF-8?q?=E5=95=86=E5=93=81=E5=88=97=E8=A1=A8API=EF=BC=8C=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E5=BA=93=E5=AD=98=E5=92=8C=E9=94=80=E5=94=AE=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=EF=BC=8C=E4=BF=AE=E5=A4=8D=E6=9F=A5=E8=AF=A2=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../branch_product/BranchProductLists.php | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/app/api/lists/branch_product/BranchProductLists.php b/app/api/lists/branch_product/BranchProductLists.php index d74a6a815..d4853886e 100644 --- a/app/api/lists/branch_product/BranchProductLists.php +++ b/app/api/lists/branch_product/BranchProductLists.php @@ -7,6 +7,8 @@ use app\api\lists\BaseApiDataLists; use app\common\model\store_product\StoreProduct; use app\common\lists\ListsSearchInterface; use app\common\model\store_branch_product\StoreBranchProduct; +use app\common\model\store_order_cart_info\StoreOrderCartInfo; +use app\common\model\warehouse_product\WarehouseProduct; /** * 商品列表列表 @@ -61,23 +63,23 @@ class BranchProductLists extends BaseApiDataLists implements ListsSearchInterfac */ public function lists(): array { - // $order = $this->request->get('order', ''); - // $field = $this->request->get('field', ''); - // if (empty($order) || empty($field)) { - // $order = $this->sortOrder; - // } else { - // $order = [$field => $order]; - // } - $fields = 'id,top_cate_id,cate_id,store_name,cost,vip_price,purchase,price,bar_code,image,sales,store_info,unit,batch,two_cate_id,stock,total_price'; + $store_id = $this->request->__get('store_id'); + if (!$store_id) return []; + + $fields = 'id,top_cate_id,cate_id,product_id,store_name,cost,vip_price,purchase,price,bar_code,image,sales,store_info,unit,batch,two_cate_id,stock,total_price'; $this->searchWhere[] = ['status', '=', 1]; + $this->searchWhere[] = ['store_id', '=', $store_id]; $this->searchWhere[] = ['product_type', 'in', [0,4]]; return StoreBranchProduct::where($this->searchWhere) ->field($fields) ->with(['className', 'unitName']) ->limit($this->limitOffset, $this->limitLength) ->order($this->sortOrder) - ->select() + ->select()->each(function($item){ + $item->distribution_nums=WarehouseProduct::where(['store_id'=>$item['store_id'],'product_id'=>$item['product_id'],'financial_pm'=>0])->sum('nums'); + $item->sales=StoreOrderCartInfo::where(['product_id'=>$item['product_id'],'store_id'=>$item['store_id'],'is_pay'=>1])->sum('cart_num'); + }) ->toArray(); } From 6ffd57704b1d9b43df5ca8048f4214acf1fc8352 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Wed, 25 Sep 2024 22:24:30 +0800 Subject: [PATCH 14/32] =?UTF-8?q?feat(StoreController):=20=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E5=BA=97=E9=93=BA=E8=8F=9C=E5=8D=95=E9=93=BE=E6=8E=A5?= =?UTF-8?q?=EF=BC=8C=E6=B7=BB=E5=8A=A0=E5=BA=97=E9=93=BA=E6=94=B6=E6=94=AF?= =?UTF-8?q?=E5=AF=BC=E8=88=AA=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/store/StoreController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/api/controller/store/StoreController.php b/app/api/controller/store/StoreController.php index 462caf03d..5bbfb08e5 100644 --- a/app/api/controller/store/StoreController.php +++ b/app/api/controller/store/StoreController.php @@ -206,7 +206,7 @@ class StoreController extends BaseApiController ['name'=>'累计销量统计','url'=>'/pagesOrder/productSales/count'], ['name'=>'商品库存','url'=>'/pagesOrder/store_product/index'], ['name'=>'订单列表','url'=>'/pagesOrder/delivery/index'], - ['name'=>'店铺收支'], + ['name'=>'店铺收支','url'=>'/pagesOrder/statistics/index'], ]; return $this->success('ok',['menu'=>$menu]); } From b65ce4717a878fb562614707d4384f97a955e6ac Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Thu, 26 Sep 2024 10:56:02 +0800 Subject: [PATCH 15/32] =?UTF-8?q?feat:=20=E9=87=8D=E6=9E=84=E4=BA=86?= =?UTF-8?q?=E9=80=80=E6=AC=BE=E9=80=BB=E8=BE=91=EF=BC=8C=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E4=BA=86=E4=BB=A3=E7=A0=81=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../logic/store_order/StoreOrderLogic.php | 38 +++---------------- app/common/logic/PayNotifyLogic.php | 2 +- 2 files changed, 6 insertions(+), 34 deletions(-) diff --git a/app/admin/logic/store_order/StoreOrderLogic.php b/app/admin/logic/store_order/StoreOrderLogic.php index 94910e3b0..57a1a28d2 100644 --- a/app/admin/logic/store_order/StoreOrderLogic.php +++ b/app/admin/logic/store_order/StoreOrderLogic.php @@ -132,49 +132,21 @@ class StoreOrderLogic extends BaseLogic $refund = (new \app\common\logic\store_order\StoreOrderLogic()) ->refund($params['order_id'], $money, $pay_price); if ($refund) { - $refund_price = $params['refund_price']; - $refund_num = 0; - foreach ($params['product_arr'] as $k => $v) { - $find = StoreOrderCartInfo::where('oid', $detail['id'])->where('product_id', $v['product_id'])->find(); - if ($find) { - $refund_num += $v['cart_num']; - $cart_num = bcsub($find['cart_num'], $v['cart_num']); - $total_price = bcmul($find['price'], $cart_num); - $data = ['cart_num' => $cart_num, 'total_price' => $total_price]; - StoreOrderCartInfo::where('id', $find['id'])->update($data); - $arr = StoreFinanceFlowProduct::where('oid', $detail['id'])->where('product_id', $v['product_id'])->select()->toArray(); - foreach ($arr as $key => $value) { - $value['cart_num'] = $cart_num; - $value['total_price'] = bcmul($cart_num, $value['price'], 2); - $value['number'] = bcmul($value['total_price'], $value['rate'], 2); - StoreFinanceFlowProduct::where('id', $value['id'])->update(['delete_time' => time()]); - unset($value['id']); - $value['create_time'] = strtotime($value['create_time']); - $value['update_time'] = strtotime($value['update_time']); - StoreFinanceFlowProduct::create($value); - } - } - } - $village_uid = StoreFinanceFlow::where('order_id', $detail['id'])->where('financial_type', 14)->value('other_uid'); - $brigade_uid = StoreFinanceFlow::where('order_id', $detail['id'])->where('financial_type', 15)->value('other_uid'); - $transaction_id = StoreFinanceFlow::where('order_id', $detail['id'])->value('transaction_id'); - StoreFinanceFlow::where('order_id', $detail['id'])->update(['delete_time' => time()]); - $detail['refund_price']=$refund_price; - CommissionnLogic::setStore($detail, $village_uid, $brigade_uid, $transaction_id); - - StoreOrder::where('id', $detail['oid'])->update(['refund_price' => $refund_price, 'refund_num' => $refund_num]); + self::refundProduct($detail, $params); return '退款成功'; } } //余额支付 采购款支付 if (in_array($detail['pay_type'], [PayEnum::BALANCE_PAY, PayEnum::PURCHASE_FUNDS])) { PayNotifyLogic::balance_purchase_refund($detail,0,$params['refund_price']); + self::refundProduct($detail, $params); return '退款成功'; } //现金支付 if ($detail['pay_type'] = PayEnum::CASH_PAY) { PayNotifyLogic::cash_refund($params['order_id']); + self::refundProduct($detail, $params); return '退款成功'; } @@ -208,7 +180,7 @@ class StoreOrderLogic extends BaseLogic } } - public function refundProduct($detail, $params) + public static function refundProduct($detail, $params) { $refund_price = $params['refund_price']; $refund_num = 0; @@ -237,9 +209,9 @@ class StoreOrderLogic extends BaseLogic $brigade_uid = StoreFinanceFlow::where('order_id', $detail['id'])->where('financial_type', 15)->value('other_uid'); $transaction_id = StoreFinanceFlow::where('order_id', $detail['id'])->value('transaction_id'); StoreFinanceFlow::where('order_id', $detail['id'])->update(['delete_time' => time()]); + $detail['refund_price']=$refund_price; CommissionnLogic::setStore($detail, $village_uid, $brigade_uid, $transaction_id); StoreOrder::where('id', $detail['oid'])->update(['refund_price' => $refund_price, 'refund_num' => $refund_num]); - StoreOrderCartInfo::where('oid', $detail['id'])->update(['is_pay' => -1]); } } diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index 7ec32a306..ae5f8b2c2 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -855,7 +855,7 @@ class PayNotifyLogic extends BaseLogic $updateData[] = [ 'id' => $StoreBranchProduct['id'], 'stock' => $StoreBranchProduct['stock'] + $v['cart_num'], - // 'sales' => ['inc', $v['cart_num']] + 'sales' => ['dec', $v['cart_num']] // 'sales' => ['inc', $v['cart_num']] ]; } From 8a66d9162071f41e553cffb9672d5793b8906623 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Thu, 26 Sep 2024 11:38:54 +0800 Subject: [PATCH 16/32] =?UTF-8?q?feat(system=5Fstore=5Fstorage):=20?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=95=86=E5=93=81=E5=85=A5=E5=BA=93API?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SystemStoreStorageController.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/app/api/controller/system_store_storage/SystemStoreStorageController.php b/app/api/controller/system_store_storage/SystemStoreStorageController.php index a2dcf4cea..2aec9d636 100644 --- a/app/api/controller/system_store_storage/SystemStoreStorageController.php +++ b/app/api/controller/system_store_storage/SystemStoreStorageController.php @@ -6,7 +6,8 @@ namespace app\api\controller\system_store_storage; use app\api\controller\BaseApiController; use app\api\lists\system_store_storage\SystemStoreStorageLists; use app\api\lists\system_store_storage\SystemStoreStorageGroupLists; - +use app\common\model\store_branch_product\StoreBranchProduct; +use app\common\model\system_store_storage\SystemStoreStorage; /** * 门店入库控制器 @@ -36,4 +37,15 @@ class SystemStoreStorageController extends BaseApiController return $this->dataLists(new SystemStoreStorageGroupLists()); } + public function warehousing_add() { + $params = $this->request->post(); + $find=SystemStoreStorage::where('id',$params['id'])->find(); + if($find){ + $find->status=1; + $find->save(); + StoreBranchProduct::where(['product_id'=>$find['product_id'],'store_id'=>$find['store_id']])->inc('stock',$find['nums'])->update(); + return $this->success('操作成功'); + } + return $this->fail('操作失败'); + } } From 4e2fcf669f0e157a42a33d0227e02a0e8e2d6d27 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Thu, 26 Sep 2024 17:21:44 +0800 Subject: [PATCH 17/32] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E9=97=A8?= =?UTF-8?q?=E5=BA=97=E5=85=A5=E5=BA=93=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SystemStoreStorageController.php | 3 +++ .../store_branch_product/StoreBranchProduct.php | 12 ++++++++++-- app/common/model/store_order/StoreOrder.php | 12 +++++++++++- .../store_order_cart_info/StoreOrderCartInfo.php | 12 +++++++++++- app/common/model/store_product/StoreProduct.php | 12 ++++++++++-- app/common/model/user/User.php | 10 +++++++++- .../model/warehouse_product/WarehouseProduct.php | 12 +++++++++++- .../WarehouseProductStorege.php | 12 +++++++++++- 8 files changed, 76 insertions(+), 9 deletions(-) diff --git a/app/api/controller/system_store_storage/SystemStoreStorageController.php b/app/api/controller/system_store_storage/SystemStoreStorageController.php index 2aec9d636..c1e1fd1a1 100644 --- a/app/api/controller/system_store_storage/SystemStoreStorageController.php +++ b/app/api/controller/system_store_storage/SystemStoreStorageController.php @@ -37,6 +37,9 @@ class SystemStoreStorageController extends BaseApiController return $this->dataLists(new SystemStoreStorageGroupLists()); } + /** + * @notes 门店入库 + */ public function warehousing_add() { $params = $this->request->post(); $find=SystemStoreStorage::where('id',$params['id'])->find(); diff --git a/app/common/model/store_branch_product/StoreBranchProduct.php b/app/common/model/store_branch_product/StoreBranchProduct.php index ae0ad6b83..e03539d9e 100644 --- a/app/common/model/store_branch_product/StoreBranchProduct.php +++ b/app/common/model/store_branch_product/StoreBranchProduct.php @@ -41,10 +41,18 @@ class StoreBranchProduct extends BaseModel { return $this->hasOne(StoreProduct::class,'id','product_id'); } - + public static function onBeforeWrite($data) + { + try { + $where = $data->getWhere(); + $find = self::where($where)->field(array_keys($data->toArray()))->find()->toArray(); + channelLog(array_merge($find, $where),'branch_product','更新前'); + } catch (Throwable $e) { + Log::error('branch_product:' . $e->getMessage()); + } + } public static function onAfterWrite($data){ try{ - channelLog($data->getOrigin(),'branch_product','更新前'); channelLog($data->toArray(),'branch_product','更新后'); }catch(Throwable $e){ Log::error('branch_product:'.$e->getMessage()); diff --git a/app/common/model/store_order/StoreOrder.php b/app/common/model/store_order/StoreOrder.php index 815958362..d87ac40fe 100644 --- a/app/common/model/store_order/StoreOrder.php +++ b/app/common/model/store_order/StoreOrder.php @@ -101,9 +101,19 @@ class StoreOrder extends BaseModel ->group('days')->select()->toArray(); } + public static function onBeforeWrite($data) + { + try { + $where = $data->getWhere(); + $find = self::where($where)->field(array_keys($data->toArray()))->find()->toArray(); + channelLog(array_merge($find, $where),'store_order','更新前'); + } catch (Throwable $e) { + Log::error('store_order:' . $e->getMessage()); + } + } + public static function onAfterWrite($data){ try{ - channelLog($data->getOrigin(),'store_order','更新前'); channelLog($data->toArray(),'store_order','更新后'); }catch(Throwable $e){ Log::error('store_order:'.$e->getMessage()); diff --git a/app/common/model/store_order_cart_info/StoreOrderCartInfo.php b/app/common/model/store_order_cart_info/StoreOrderCartInfo.php index 93b2b3518..677c9a710 100644 --- a/app/common/model/store_order_cart_info/StoreOrderCartInfo.php +++ b/app/common/model/store_order_cart_info/StoreOrderCartInfo.php @@ -21,9 +21,19 @@ class StoreOrderCartInfo extends BaseModel return $this->hasOne(StoreBranchProduct::class,'id','product_id')->bind(['store_name','image','unit','price']); } + public static function onBeforeWrite($data) + { + try { + $where = $data->getWhere(); + $find = self::where($where)->field(array_keys($data->toArray()))->find()->toArray(); + channelLog(array_merge($find, $where),'store_order_cart_info','更新前'); + } catch (Throwable $e) { + Log::error('store_order_cart_info:' . $e->getMessage()); + } + } + public static function onAfterWrite($data){ try{ - channelLog($data->getOrigin(),'store_order_cart_info','更新前'); channelLog($data->toArray(),'store_order_cart_info','更新后'); }catch(Throwable $e){ Log::error('store_order_cart_info:'.$e->getMessage()); diff --git a/app/common/model/store_product/StoreProduct.php b/app/common/model/store_product/StoreProduct.php index ddcfe97e9..8d95ef264 100644 --- a/app/common/model/store_product/StoreProduct.php +++ b/app/common/model/store_product/StoreProduct.php @@ -33,10 +33,18 @@ class StoreProduct extends BaseModel return $this->hasOne(StoreCategory::class,'id','cate_id')->bind(['class_name'=>'name']); } - + public static function onBeforeWrite($data) + { + try { + $where = $data->getWhere(); + $find = self::where($where)->field(array_keys($data->toArray()))->find()->toArray(); + channelLog(array_merge($find, $where),'product','更新前'); + } catch (Throwable $e) { + Log::error('product:' . $e->getMessage()); + } + } public static function onAfterWrite($data){ try{ - channelLog($data->getOrigin(),'product','更新前'); channelLog($data->toArray(),'product','更新后'); }catch(Throwable $e){ Log::error('product:'.$e->getMessage()); diff --git a/app/common/model/user/User.php b/app/common/model/user/User.php index 704b7ed2a..8d615a728 100644 --- a/app/common/model/user/User.php +++ b/app/common/model/user/User.php @@ -197,9 +197,17 @@ class User extends BaseModel })->field("FROM_UNIXTIME($create_time,'$timeType') as days,count(id) as num")->group('days')->select()->toArray(); } + public static function onBeforeWrite($data){ + try{ + $where=$data->getWhere(); + $find=self::where($where)->field(array_keys($data->toArray()))->find()->toArray(); + channelLog(array_merge($find,$where),'user','更新前'); + }catch(Throwable $e){ + Log::error('user:'.$e->getMessage()); + } + } public static function onAfterWrite($data){ try{ - channelLog($data->getOrigin(),'user','更新前'); channelLog($data->toArray(),'user','更新后'); }catch(Throwable $e){ Log::error('user:'.$e->getMessage()); diff --git a/app/common/model/warehouse_product/WarehouseProduct.php b/app/common/model/warehouse_product/WarehouseProduct.php index 24e61c73e..7ca934e18 100644 --- a/app/common/model/warehouse_product/WarehouseProduct.php +++ b/app/common/model/warehouse_product/WarehouseProduct.php @@ -19,9 +19,19 @@ class WarehouseProduct extends BaseModel protected $name = 'warehouse_product'; protected $deleteTime = 'delete_time'; + public static function onBeforeWrite($data) + { + try { + $where = $data->getWhere(); + $find = self::where($where)->field(array_keys($data->toArray()))->find()->toArray(); + channelLog(array_merge($find, $where),'warehouse_product','更新前'); + } catch (Throwable $e) { + Log::error('warehouse_product:' . $e->getMessage()); + } + } + public static function onAfterWrite($data){ try{ - channelLog($data->getOrigin(),'warehouse_product','更新前'); channelLog($data->toArray(),'warehouse_product','更新后'); }catch(Throwable $e){ Log::error('warehouse_product:'.$e->getMessage()); diff --git a/app/common/model/warehouse_product_storege/WarehouseProductStorege.php b/app/common/model/warehouse_product_storege/WarehouseProductStorege.php index 9d86d6924..e120dcf09 100644 --- a/app/common/model/warehouse_product_storege/WarehouseProductStorege.php +++ b/app/common/model/warehouse_product_storege/WarehouseProductStorege.php @@ -18,10 +18,20 @@ class WarehouseProductStorege extends BaseModel use SoftDelete; protected $name = 'warehouse_product_storege'; protected $deleteTime = 'delete_time'; + + public static function onBeforeWrite($data) + { + try { + $where = $data->getWhere(); + $find = self::where($where)->field(array_keys($data->toArray()))->find()->toArray(); + channelLog(array_merge($find, $where), 'warehouse_product_storege', '更新前'); + } catch (Throwable $e) { + Log::error('warehouse_product_storege:' . $e->getMessage()); + } + } public static function onAfterWrite($data) { try { - channelLog($data->getOrigin(), 'warehouse_product_storege', '更新前'); channelLog($data->toArray(), 'warehouse_product_storege', '更新后'); } catch (Throwable $e) { Log::error('warehouse_product_storege:' . $e->getMessage()); From 5e13b684a8a7e9b9725eda393506cbc51c4b35b3 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Thu, 26 Sep 2024 21:20:57 +0800 Subject: [PATCH 18/32] =?UTF-8?q?feat(OrderController):=20=E5=9C=A8?= =?UTF-8?q?=E8=AE=A2=E5=8D=95API=E4=B8=AD=E5=A2=9E=E5=8A=A0=E7=B3=BB?= =?UTF-8?q?=E7=BB=9F=E7=BB=B4=E6=8A=A4=E6=9A=82=E5=81=9C=E4=BA=A4=E6=98=93?= =?UTF-8?q?=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/order/OrderController.php | 2 ++ app/store/controller/store_order/StoreOrderController.php | 1 + 2 files changed, 3 insertions(+) diff --git a/app/api/controller/order/OrderController.php b/app/api/controller/order/OrderController.php index 3a126f617..fdfea135d 100644 --- a/app/api/controller/order/OrderController.php +++ b/app/api/controller/order/OrderController.php @@ -121,6 +121,8 @@ class OrderController extends BaseApiController */ public function createOrder() { + return $this->fail('系统维护中,暂停交易。维护时间2024年9月27日-28日'); + $cartId = (array)$this->request->post('cart_id', []); $store_id =$this->request->post('store_id', 0); $pay_type = (int)$this->request->post('pay_type'); diff --git a/app/store/controller/store_order/StoreOrderController.php b/app/store/controller/store_order/StoreOrderController.php index 5d7939187..228780a16 100644 --- a/app/store/controller/store_order/StoreOrderController.php +++ b/app/store/controller/store_order/StoreOrderController.php @@ -159,6 +159,7 @@ class StoreOrderController extends BaseAdminController */ public function createOrder() { + return $this->fail('系统维护中,暂停交易。维护时间2024年9月27日-28日'); $cartId = (array)$this->request->post('cart_id', []); $pay_type = (int)$this->request->post('pay_type'); $addressId = (int)$this->request->post('address_id'); From 362c3481405359b8671afbe8be6d5218719f21ef Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Thu, 26 Sep 2024 21:29:19 +0800 Subject: [PATCH 19/32] =?UTF-8?q?feat(OrderController,=20StoreOrderControl?= =?UTF-8?q?ler):=20=E7=A7=BB=E9=99=A4=E7=B3=BB=E7=BB=9F=E7=BB=B4=E6=8A=A4?= =?UTF-8?q?=E6=9A=82=E5=81=9C=E4=BA=A4=E6=98=93=E6=8F=90=E7=A4=BA=EF=BC=8C?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=AE=A2=E5=8D=95API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/order/OrderController.php | 2 -- app/store/controller/store_order/StoreOrderController.php | 1 - 2 files changed, 3 deletions(-) diff --git a/app/api/controller/order/OrderController.php b/app/api/controller/order/OrderController.php index fdfea135d..3a126f617 100644 --- a/app/api/controller/order/OrderController.php +++ b/app/api/controller/order/OrderController.php @@ -121,8 +121,6 @@ class OrderController extends BaseApiController */ public function createOrder() { - return $this->fail('系统维护中,暂停交易。维护时间2024年9月27日-28日'); - $cartId = (array)$this->request->post('cart_id', []); $store_id =$this->request->post('store_id', 0); $pay_type = (int)$this->request->post('pay_type'); diff --git a/app/store/controller/store_order/StoreOrderController.php b/app/store/controller/store_order/StoreOrderController.php index 228780a16..5d7939187 100644 --- a/app/store/controller/store_order/StoreOrderController.php +++ b/app/store/controller/store_order/StoreOrderController.php @@ -159,7 +159,6 @@ class StoreOrderController extends BaseAdminController */ public function createOrder() { - return $this->fail('系统维护中,暂停交易。维护时间2024年9月27日-28日'); $cartId = (array)$this->request->post('cart_id', []); $pay_type = (int)$this->request->post('pay_type'); $addressId = (int)$this->request->post('address_id'); From e2e470d0926aa74839224ad25e2163f24743c5f9 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Fri, 27 Sep 2024 18:16:07 +0800 Subject: [PATCH 20/32] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E5=BA=97?= =?UTF-8?q?=E9=93=BA=E6=94=B6=E6=94=AFAPI=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BranchProductController.php | 3 ++ app/api/controller/store/StoreController.php | 43 +++++++++++++++++++ .../StoreOrderCartInfoController.php | 7 ++- .../SystemStoreStorageController.php | 11 +++++ .../SystemStoreStorageGroupLists.php | 5 +++ .../SystemStoreStorageLists.php | 6 +++ 6 files changed, 73 insertions(+), 2 deletions(-) diff --git a/app/api/controller/branch_product/BranchProductController.php b/app/api/controller/branch_product/BranchProductController.php index c08f43515..df4786119 100644 --- a/app/api/controller/branch_product/BranchProductController.php +++ b/app/api/controller/branch_product/BranchProductController.php @@ -4,6 +4,7 @@ namespace app\api\controller\branch_product; use app\api\controller\BaseApiController; use app\api\lists\branch_product\BranchProductLists; +use app\common\model\system_store\SystemStoreStaff; class BranchProductController extends BaseApiController { @@ -14,6 +15,8 @@ class BranchProductController extends BaseApiController */ public function lists() { + $store_id=SystemStoreStaff::where('uid',$this->userId)->value('store_id'); + $this->request->__set('store_id',$store_id); return $this->dataLists(new BranchProductLists()); } } diff --git a/app/api/controller/store/StoreController.php b/app/api/controller/store/StoreController.php index 5bbfb08e5..a9b554b3b 100644 --- a/app/api/controller/store/StoreController.php +++ b/app/api/controller/store/StoreController.php @@ -13,10 +13,15 @@ use app\common\enum\PayEnum; use app\common\logic\PaymentLogic; use app\common\logic\PayNotifyLogic; use app\common\model\Config; +use app\common\model\store_finance_flow\StoreFinanceFlow; +use app\common\model\store_order\StoreOrder; +use app\common\model\system_store\SystemStore; +use app\common\model\system_store\SystemStoreStaff; use app\common\model\user\User; use app\common\model\user\UserAddress; use app\common\model\user_create_log\UserCreateLog; use app\common\model\user_recharge\UserRecharge; +use app\common\model\warehouse_product\WarehouseProduct; use app\common\service\Curl; use Exception; use support\Cache; @@ -210,4 +215,42 @@ class StoreController extends BaseApiController ]; return $this->success('ok',['menu'=>$menu]); } + + /** + * 店铺收支 + */ + public function store_statistics(){ + $store_id=SystemStoreStaff::where('uid',$this->userId)->value('store_id'); + if(!$store_id){ + return $this->fail('请先绑定店铺'); + } + $total_price=WarehouseProduct::where('store_id',$store_id)->where('financial_pm',0)->sum('total_price'); + $order=StoreOrder::where('store_id',$store_id)->where('refund_status',0)->field('sum(refund_price) as refund_price,sum(pay_price) as pay_price')->find(); + $pay_price=bcsub($order['pay_price'],$order['refund_price'],2); + + $commission=StoreFinanceFlow::where('store_id',$store_id)->where('financial_pm',0)->where('financial_type',3)->sum('number'); + $bond=StoreFinanceFlow::where('store_id',$store_id)->where('financial_pm',0)->where('financial_type',11)->sum('number'); + $vip=StoreFinanceFlow::where('store_id',$store_id)->where('financial_pm',0)->where('financial_type',12)->sum('number'); + $village=StoreFinanceFlow::where('store_id',$store_id)->where('financial_pm',0)->where('financial_type',14)->sum('number'); + $brigade=StoreFinanceFlow::where('store_id',$store_id)->where('financial_pm',0)->where('financial_type',15)->sum('number'); + $attrition=StoreFinanceFlow::where('store_id',$store_id)->where('financial_pm',0)->where('financial_type',16)->sum('number'); + + $money=bcadd($commission,$bond,2); + $money=bcadd($money,$vip,2); + $money=bcadd($money,$village,2); + $money=bcadd($money,$brigade,2); + $expenditure=bcadd($money,$attrition,2); + + + $store_money=SystemStore::where('id',$store_id)->value('store_money'); + + $list=[ + ['name'=>'手续费','data'=>[$commission]], + ['name'=>'保证金','data'=>[$bond]], + ['name'=>'厨师','data'=>[$vip]], + ['name'=>'村长','data'=>[$village]], + ['name'=>'队长','data'=>[$brigade]], + ]; + return $this->success('ok',['total_price'=>$total_price,'pay_price'=>$pay_price,'list'=>$list,'attrition'=>$attrition,'store_money'=>$store_money,'expenditure'=>$expenditure]); + } } diff --git a/app/api/controller/store_order_cart_info/StoreOrderCartInfoController.php b/app/api/controller/store_order_cart_info/StoreOrderCartInfoController.php index e85d6710d..5134d6129 100644 --- a/app/api/controller/store_order_cart_info/StoreOrderCartInfoController.php +++ b/app/api/controller/store_order_cart_info/StoreOrderCartInfoController.php @@ -6,6 +6,7 @@ namespace app\api\controller\store_order_cart_info; use app\api\controller\BaseApiController; use app\api\lists\store_order_cart_info\StoreOrderCartInfoGroupLists; use app\api\lists\store_order_cart_info\StoreOrderCartInfoLists; +use app\common\model\system_store\SystemStoreStaff; /** * 商品销量控制器 @@ -22,13 +23,15 @@ class StoreOrderCartInfoController extends BaseApiController */ public function lists() { - $this->request->__set('store_id',5); + $store_id=SystemStoreStaff::where('uid',$this->userId)->value('store_id'); + $this->request->__set('store_id',$store_id); return $this->dataLists(new StoreOrderCartInfoLists()); } public function group_lists() { - $this->request->__set('store_id',5); + $store_id=SystemStoreStaff::where('uid',$this->userId)->value('store_id'); + $this->request->__set('store_id',$store_id); return $this->dataLists(new StoreOrderCartInfoGroupLists()); } } diff --git a/app/api/controller/system_store_storage/SystemStoreStorageController.php b/app/api/controller/system_store_storage/SystemStoreStorageController.php index c1e1fd1a1..a9eb68379 100644 --- a/app/api/controller/system_store_storage/SystemStoreStorageController.php +++ b/app/api/controller/system_store_storage/SystemStoreStorageController.php @@ -7,6 +7,7 @@ use app\api\controller\BaseApiController; use app\api\lists\system_store_storage\SystemStoreStorageLists; use app\api\lists\system_store_storage\SystemStoreStorageGroupLists; use app\common\model\store_branch_product\StoreBranchProduct; +use app\common\model\system_store\SystemStoreStaff; use app\common\model\system_store_storage\SystemStoreStorage; /** @@ -24,6 +25,11 @@ class SystemStoreStorageController extends BaseApiController */ public function lists() { + $store_id=SystemStoreStaff::where('uid',$this->userId)->value('store_id'); + if(!$store_id){ + return $this->fail('请先绑定店铺'); + } + $this->request->__set('store_id',$store_id); return $this->dataLists(new SystemStoreStorageLists()); } /** @@ -34,6 +40,11 @@ class SystemStoreStorageController extends BaseApiController */ public function group_lists() { + $store_id=SystemStoreStaff::where('uid',$this->userId)->value('store_id'); + if(!$store_id){ + return $this->fail('请先绑定店铺'); + } + $this->request->__set('store_id',$store_id); return $this->dataLists(new SystemStoreStorageGroupLists()); } diff --git a/app/api/lists/system_store_storage/SystemStoreStorageGroupLists.php b/app/api/lists/system_store_storage/SystemStoreStorageGroupLists.php index 84fbaca3d..f44c869fc 100644 --- a/app/api/lists/system_store_storage/SystemStoreStorageGroupLists.php +++ b/app/api/lists/system_store_storage/SystemStoreStorageGroupLists.php @@ -62,6 +62,11 @@ class SystemStoreStorageGroupLists extends BaseApiDataLists implements ListsSear */ public function lists(): array { + $store_id=$this->request->__get('store_id'); + if(!$store_id){ + return []; + } + $this->searchWhere[] = ['store_id', '=', $store_id]; $fields = 'store_id,product_id,sum(nums) as nums,mark'; if ($this->request->get('store_name')) { $store_name = $this->request->get('store_name'); diff --git a/app/api/lists/system_store_storage/SystemStoreStorageLists.php b/app/api/lists/system_store_storage/SystemStoreStorageLists.php index f3674d2cb..eccaa3362 100644 --- a/app/api/lists/system_store_storage/SystemStoreStorageLists.php +++ b/app/api/lists/system_store_storage/SystemStoreStorageLists.php @@ -62,6 +62,12 @@ class SystemStoreStorageLists extends BaseApiDataLists implements ListsSearchInt */ public function lists(): array { + $store_id=$this->request->__get('store_id'); + if(!$store_id){ + return []; + } + $this->searchWhere[] = ['store_id', '=', $store_id]; + $fields = 'id,store_id,staff_id,product_id,warehouse_id,nums,mark,status'; if ($this->request->get('store_name')) { $store_name = $this->request->get('store_name'); From a0bc9222074fc06c93fba56f92bfc738e7529984 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Sat, 28 Sep 2024 09:24:54 +0800 Subject: [PATCH 21/32] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9=E4=BA=86?= =?UTF-8?q?=E8=AE=A2=E5=8D=95=E7=9B=B8=E5=85=B3=E7=9A=84API=E9=80=BB?= =?UTF-8?q?=E8=BE=91=EF=BC=8C=E7=A7=BB=E9=99=A4=E4=BA=86=E4=B8=8D=E5=BF=85?= =?UTF-8?q?=E8=A6=81=E7=9A=84=E7=BB=8F=E7=BA=AC=E5=BA=A6=E5=8F=82=E6=95=B0?= =?UTF-8?q?=EF=BC=8C=E5=B9=B6=E4=BC=98=E5=8C=96=E4=BA=86=E6=88=90=E6=9C=AC?= =?UTF-8?q?=E8=AE=A1=E7=AE=97=E6=96=B9=E5=BC=8F=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/order/OrderController.php | 8 +----- app/api/logic/order/OrderLogic.php | 26 +++----------------- app/common/logic/PayNotifyLogic.php | 2 +- 3 files changed, 6 insertions(+), 30 deletions(-) diff --git a/app/api/controller/order/OrderController.php b/app/api/controller/order/OrderController.php index 3a126f617..9b0e7b86c 100644 --- a/app/api/controller/order/OrderController.php +++ b/app/api/controller/order/OrderController.php @@ -339,18 +339,12 @@ class OrderController extends BaseApiController public function detail() { $order_id = (int)$this->request->get('order_id'); - $lat = $this->request->get('lat', ''); - $lng = $this->request->get('long', ''); $where = [ 'id' => $order_id, 'uid' => $this->userId, ]; $url = 'https://' . $this->request->host(true); - $parm = [ - 'lat' => $lat, - 'long' => $lng - ]; - $order = OrderLogic::detail($where, $url, $parm); + $order = OrderLogic::detail($where, $url); if ($order) { return $this->data($order); } else { diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index 046e50d24..c420d9581 100644 --- a/app/api/logic/order/OrderLogic.php +++ b/app/api/logic/order/OrderLogic.php @@ -149,7 +149,7 @@ class OrderLogic extends BaseLogic //利润 // $cart_select[$k]['profit'] = bcmul($v['cart_num'], $onePrice, 2); //利润 - $cart_select[$k]['purchase'] = bcmul($v['cart_num'], $find['purchase'], 2) ?? 0; //成本 + $cart_select[$k]['total_purchase'] = bcmul($v['cart_num'], $find['purchase'], 2) ?? 0; //成本 $cart_select[$k]['pay_price'] = bcmul($v['cart_num'], $price, 2); //订单支付金额 $cart_select[$k]['store_price'] = bcmul($v['cart_num'], $find['cost'], 2) ?? 0; //商户价 $cart_select[$k]['vip_price'] = bcmul($v['cart_num'], $find['vip_price'], 2) ?? 0; //vip售价 @@ -181,13 +181,14 @@ class OrderLogic extends BaseLogic $cart_select[$k]['cart_info'] = json_encode($cartInfo); //理论上每笔都是拆分了 $cart_select[$k]['name'] = $find['store_name']; + $cart_select[$k]['purchase'] = $find['purchase']; $cart_select[$k]['imgs'] = $find['image']; $cart_select[$k]['store_id'] = $params['store_id'] ?? 0; $cart_select[$k]['unit_name'] = StoreProductUnit::where(['id' => $find['unit']])->value('name'); $cart_select[$k]['total_price'] = $cart_select[$k]['pay_price']; self::$total_price = bcadd(self::$total_price, $cart_select[$k]['total_price'], 2); self::$pay_price = bcadd(self::$pay_price, $cart_select[$k]['pay_price'], 2); - self::$cost = bcadd(self::$cost, $cart_select[$k]['purchase'], 2); + self::$cost = bcadd(self::$cost, $cart_select[$k]['total_purchase'], 2); self::$store_price = bcadd(self::$store_price, $cart_select[$k]['store_price'], 2); //商户价 self::$deduction_price = bcadd(self::$deduction_price, $deduction_price, 2); //抵扣金额 // self::$frozen_money = bcadd(self::$frozen_money, $cart_select[$k]['vip_frozen_price'], 2); //返还金额 @@ -343,7 +344,6 @@ class OrderLogic extends BaseLogic $goods_list[$k]['oid'] = $order->id; $goods_list[$k]['uid'] = $uid; $goods_list[$k]['cart_id'] = implode(',', $cartId); - $goods_list[$k]['delivery_id'] = $params['store_id']; //商家id } (new StoreOrderCartInfo())->saveAll($goods_list); $where = ['is_pay' => 0]; @@ -500,13 +500,11 @@ class OrderLogic extends BaseLogic if ($find) { $find['goods_list'] = StoreOrderCartInfo::where('oid', $find['id']) - ->field('product_id,cart_num nums,store_id')->select()->each(function ($item) use ($find) { + ->field('product_id,cart_num nums,store_id,price')->select()->each(function ($item) { $find = StoreProduct::where('id', $item['product_id'])->withTrashed()->find(); - $item['store_name'] = $find['store_name']; $item['nums'] = floatval($item['nums']); $item['image'] = $find['image']; - $item['price'] = $find['price']; $item['unit_name'] = StoreProductUnit::where('id', $find['unit'])->value('name') ?? ''; $item['msg'] = '预计48小时发货'; return $item; @@ -523,22 +521,6 @@ class OrderLogic extends BaseLogic $tmpFilename = $generator->getBarcode($find['verify_code'], $generator::TYPE_CODE_128); $find['verify_base64'] = 'data:image/png;base64,' . base64_encode($tmpFilename); } - //处理返回最近的店铺 - if ($param['lat'] && $param['long']) { - $storeAll = SystemStore::field('id,name,phone,address,detailed_address,latitude,longitude')->select()->toArray(); - $nearestStore = null; - $minDistance = PHP_FLOAT_MAX; - foreach ($storeAll as $value) { - $value['distance'] = haversineDistance($value['latitude'], $value['longitude'], $param['lat'], $param['long']); - if ($value['distance'] < $minDistance) { - $minDistance = $value['distance']; - $nearestStore = $value; - } - } - if ($nearestStore) { - $find['near_store'] = $nearestStore; - } - } } return $find; } diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index ae5f8b2c2..2647d6275 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -684,7 +684,7 @@ class PayNotifyLogic extends BaseLogic } try { - $info = StoreOrderCartInfo::where('oid', $order['id'])->field('store_id,product_id,price,cart_num')->select(); + $info = StoreOrderCartInfo::where('oid', $order['id'])->field('store_id,product_id,price,purchase,cart_num')->select(); $comm = new CommissionProductLogic(); foreach ($info as $k => $v) { $comm->calculate_product_flow($v, $order, $village_uid, $brigade_uid, $user_ship); From 218aa8c23f8fcb29ae6f707eea260b176b5f0dbf Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Sat, 28 Sep 2024 09:48:04 +0800 Subject: [PATCH 22/32] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9=E4=BC=9A?= =?UTF-8?q?=E5=91=98=E5=88=A9=E6=B6=A6=E8=AE=A1=E7=AE=97=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/logic/CommissionProductLogic.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/common/logic/CommissionProductLogic.php b/app/common/logic/CommissionProductLogic.php index 0e3e29b48..ba685ae95 100644 --- a/app/common/logic/CommissionProductLogic.php +++ b/app/common/logic/CommissionProductLogic.php @@ -120,9 +120,11 @@ class CommissionProductLogic extends BaseLogic $data[] =$this->attrition('零售损耗', $order, $find, $price, $total_price,$attrition_number); } } elseif ($user['user_ship'] == 1) { - $vip_number = bcmul($total_price, 0.06, 2); //会员利润 - $data[] = $this->vip_user('零售会员', $order, $find, $uid, $price, $total_price, $vip_number,0.06); - $number1 = bcadd($number1, $vip_number, 2); + if(bcsub($user['total_recharge_amount'],$user['purchase_funds'],2)>$user['first_purchase_funds']){ + $vip_number = bcmul($total_price, 0.06, 2); //会员利润 + $data[] = $this->vip_user('零售会员', $order, $find, $uid, $price, $total_price, $vip_number,0.06); + $number1 = bcadd($number1, $vip_number, 2); + } if ($rose >= 12 && $village_uid>0) { $village_number = bcmul($total_price, 0.01, 2); //村长利润 $data[] =$this->village('零售村长', $order, $find, $village_uid, $price, $total_price, $village_number,0.01); From bb562f86ee34c57e34d9476996f6d2aaa2314eb0 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Sat, 28 Sep 2024 10:54:09 +0800 Subject: [PATCH 23/32] =?UTF-8?q?feat:=20=E6=9B=B4=E6=96=B0=E4=BA=86?= =?UTF-8?q?=E5=BC=82=E5=B8=B8=E5=A4=84=E7=90=86=E6=9C=BA=E5=88=B6=EF=BC=8C?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BA=86=E4=BB=A3=E7=A0=81=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/logic/order/OrderLogic.php | 2 +- app/common/logic/CommissionProductLogic.php | 5 +++-- .../store_branch_product/StoreBranchProduct.php | 8 ++++++-- app/common/model/store_order/StoreOrder.php | 12 ++++++++---- .../store_order_cart_info/StoreOrderCartInfo.php | 8 ++++++-- app/common/model/store_product/StoreProduct.php | 8 ++++++-- app/common/model/user/User.php | 8 ++++++-- .../model/warehouse_product/WarehouseProduct.php | 8 ++++++-- .../WarehouseProductStorege.php | 8 ++++++-- 9 files changed, 48 insertions(+), 19 deletions(-) diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index c420d9581..856c5b75a 100644 --- a/app/api/logic/order/OrderLogic.php +++ b/app/api/logic/order/OrderLogic.php @@ -351,7 +351,7 @@ class OrderLogic extends BaseLogic Db::commit(); return $order; - } catch (\Exception $e) { + } catch (\Throwable $e) { Db::rollback(); throw new BusinessException($e->getMessage()); } diff --git a/app/common/logic/CommissionProductLogic.php b/app/common/logic/CommissionProductLogic.php index ba685ae95..13584e2a7 100644 --- a/app/common/logic/CommissionProductLogic.php +++ b/app/common/logic/CommissionProductLogic.php @@ -120,7 +120,9 @@ class CommissionProductLogic extends BaseLogic $data[] =$this->attrition('零售损耗', $order, $find, $price, $total_price,$attrition_number); } } elseif ($user['user_ship'] == 1) { - if(bcsub($user['total_recharge_amount'],$user['purchase_funds'],2)>$user['first_purchase_funds']){ + if($order['pay_type']==18 && bcsub($user['total_recharge_amount'],$user['purchase_funds'],2)<$user['first_purchase_funds']){ + + }else{ $vip_number = bcmul($total_price, 0.06, 2); //会员利润 $data[] = $this->vip_user('零售会员', $order, $find, $uid, $price, $total_price, $vip_number,0.06); $number1 = bcadd($number1, $vip_number, 2); @@ -158,7 +160,6 @@ class CommissionProductLogic extends BaseLogic if ($rose >= 6) { $data[] = $this->platform('零售平台', $order, $find, $price, $total_price,$platform_number); } - (new StoreFinanceFlowProduct())->saveAll($data); } diff --git a/app/common/model/store_branch_product/StoreBranchProduct.php b/app/common/model/store_branch_product/StoreBranchProduct.php index e03539d9e..494edb295 100644 --- a/app/common/model/store_branch_product/StoreBranchProduct.php +++ b/app/common/model/store_branch_product/StoreBranchProduct.php @@ -45,8 +45,12 @@ class StoreBranchProduct extends BaseModel { try { $where = $data->getWhere(); - $find = self::where($where)->field(array_keys($data->toArray()))->find()->toArray(); - channelLog(array_merge($find, $where),'branch_product','更新前'); + if($data){ + $find = self::where($where)->field(array_keys($data->toArray()))->find(); + if($find){ + channelLog(array_merge($find->toArray(), $where),'branch_product','更新前'); + } + } } catch (Throwable $e) { Log::error('branch_product:' . $e->getMessage()); } diff --git a/app/common/model/store_order/StoreOrder.php b/app/common/model/store_order/StoreOrder.php index d87ac40fe..e373c780f 100644 --- a/app/common/model/store_order/StoreOrder.php +++ b/app/common/model/store_order/StoreOrder.php @@ -105,10 +105,14 @@ class StoreOrder extends BaseModel { try { $where = $data->getWhere(); - $find = self::where($where)->field(array_keys($data->toArray()))->find()->toArray(); - channelLog(array_merge($find, $where),'store_order','更新前'); + if($data){ + $find = self::where($where)->field(array_keys($data->toArray()))->find(); + if($find){ + channelLog(array_merge($find->toArray(), $where),'store_order','更新前'); + } + } } catch (Throwable $e) { - Log::error('store_order:' . $e->getMessage()); + Log::error('store_order:更新前' . $e->getMessage()); } } @@ -116,7 +120,7 @@ class StoreOrder extends BaseModel try{ channelLog($data->toArray(),'store_order','更新后'); }catch(Throwable $e){ - Log::error('store_order:'.$e->getMessage()); + Log::error('store_order:更新后'.$e->getMessage()); } } } diff --git a/app/common/model/store_order_cart_info/StoreOrderCartInfo.php b/app/common/model/store_order_cart_info/StoreOrderCartInfo.php index 677c9a710..a3c407b10 100644 --- a/app/common/model/store_order_cart_info/StoreOrderCartInfo.php +++ b/app/common/model/store_order_cart_info/StoreOrderCartInfo.php @@ -25,8 +25,12 @@ class StoreOrderCartInfo extends BaseModel { try { $where = $data->getWhere(); - $find = self::where($where)->field(array_keys($data->toArray()))->find()->toArray(); - channelLog(array_merge($find, $where),'store_order_cart_info','更新前'); + if($data){ + $find = self::where($where)->field(array_keys($data->toArray()))->find(); + if($find){ + channelLog(array_merge($find->toArray(),$where),'store_order_cart_info','更新前'); + } + } } catch (Throwable $e) { Log::error('store_order_cart_info:' . $e->getMessage()); } diff --git a/app/common/model/store_product/StoreProduct.php b/app/common/model/store_product/StoreProduct.php index 8d95ef264..9dcaed539 100644 --- a/app/common/model/store_product/StoreProduct.php +++ b/app/common/model/store_product/StoreProduct.php @@ -37,8 +37,12 @@ class StoreProduct extends BaseModel { try { $where = $data->getWhere(); - $find = self::where($where)->field(array_keys($data->toArray()))->find()->toArray(); - channelLog(array_merge($find, $where),'product','更新前'); + if($data){ + $find = self::where($where)->field(array_keys($data->toArray()))->find(); + if ($find) { + channelLog(array_merge($find->toArray(), $where), 'product', '更新前'); + } + } } catch (Throwable $e) { Log::error('product:' . $e->getMessage()); } diff --git a/app/common/model/user/User.php b/app/common/model/user/User.php index 8d615a728..78c226694 100644 --- a/app/common/model/user/User.php +++ b/app/common/model/user/User.php @@ -200,8 +200,12 @@ class User extends BaseModel public static function onBeforeWrite($data){ try{ $where=$data->getWhere(); - $find=self::where($where)->field(array_keys($data->toArray()))->find()->toArray(); - channelLog(array_merge($find,$where),'user','更新前'); + if($data){ + $find=self::where($where)->field(array_keys($data->toArray()))->find(); + if($find){ + channelLog(array_merge($find->toArray(),$where),'user','更新前'); + } + } }catch(Throwable $e){ Log::error('user:'.$e->getMessage()); } diff --git a/app/common/model/warehouse_product/WarehouseProduct.php b/app/common/model/warehouse_product/WarehouseProduct.php index 7ca934e18..fb086e088 100644 --- a/app/common/model/warehouse_product/WarehouseProduct.php +++ b/app/common/model/warehouse_product/WarehouseProduct.php @@ -23,8 +23,12 @@ class WarehouseProduct extends BaseModel { try { $where = $data->getWhere(); - $find = self::where($where)->field(array_keys($data->toArray()))->find()->toArray(); - channelLog(array_merge($find, $where),'warehouse_product','更新前'); + if($data){ + $find = self::where($where)->field(array_keys($data->toArray()))->find(); + if($find){ + channelLog(array_merge($find->toArray(), $where),'warehouse_product','更新前'); + } + } } catch (Throwable $e) { Log::error('warehouse_product:' . $e->getMessage()); } diff --git a/app/common/model/warehouse_product_storege/WarehouseProductStorege.php b/app/common/model/warehouse_product_storege/WarehouseProductStorege.php index e120dcf09..172b611f8 100644 --- a/app/common/model/warehouse_product_storege/WarehouseProductStorege.php +++ b/app/common/model/warehouse_product_storege/WarehouseProductStorege.php @@ -23,8 +23,12 @@ class WarehouseProductStorege extends BaseModel { try { $where = $data->getWhere(); - $find = self::where($where)->field(array_keys($data->toArray()))->find()->toArray(); - channelLog(array_merge($find, $where), 'warehouse_product_storege', '更新前'); + if($data){ + $find = self::where($where)->field(array_keys($data->toArray()))->find(); + if($find){ + channelLog(array_merge($find->toArray(), $where), 'warehouse_product_storege', '更新前'); + } + } } catch (Throwable $e) { Log::error('warehouse_product_storege:' . $e->getMessage()); } From 2a17dde78dbcf6c464dd6bdca3113f5576ca17ab Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Sat, 28 Sep 2024 14:58:04 +0800 Subject: [PATCH 24/32] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E9=80=BB=E8=BE=91=EF=BC=8C=E5=BC=95=E5=85=A5=E4=BF=9D?= =?UTF-8?q?=E8=AF=81=E9=87=91=E9=80=BB=E8=BE=91=EF=BC=8C=E8=B0=83=E6=95=B4?= =?UTF-8?q?=E9=97=A8=E5=BA=97=E5=88=A9=E6=B6=A6=E8=AE=A1=E7=AE=97=E6=96=B9?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/logic/order/OrderLogic.php | 4 ++-- app/common/logic/CommissionnLogic.php | 11 ++++++++++- app/common/logic/StoreFinanceFlowLogic.php | 15 +++++++++++---- .../StoreFinanceFlowProduct.php | 9 --------- 4 files changed, 23 insertions(+), 16 deletions(-) diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index 856c5b75a..ecd3643f6 100644 --- a/app/api/logic/order/OrderLogic.php +++ b/app/api/logic/order/OrderLogic.php @@ -8,6 +8,7 @@ use app\common\enum\UserShipEnum; use app\common\enum\YesNoEnum; use app\common\logic\BaseLogic; use app\common\logic\CapitalFlowLogic; +use app\common\logic\CommissionnLogic; use app\common\logic\PayNotifyLogic; use app\common\logic\StoreFinanceFlowLogic; use app\common\logic\UserSignLogic; @@ -566,8 +567,7 @@ class OrderLogic extends BaseLogic 'store_id' => $params['store_id'], 'staff_id' => $params['staff_id'] ?? 0, ], ['id' => $order['id']]); - //修改商品统计记录标识 - (new StoreProductLog())->where('oid', $order['id'])->update(['store_id' => $params['store_id']]); + (new StoreOrderCartInfo())->update([ 'verify_code' => $params['verify_code'] . '-1', 'writeoff_time' => time(), diff --git a/app/common/logic/CommissionnLogic.php b/app/common/logic/CommissionnLogic.php index 44b9ae9b1..d070ea47a 100644 --- a/app/common/logic/CommissionnLogic.php +++ b/app/common/logic/CommissionnLogic.php @@ -77,26 +77,35 @@ class CommissionnLogic extends BaseLogic $financeLogic->in($transaction_id, bcsub($order['pay_price'],$order['refund_price'],2), OrderEnum::USER_ORDER_PAY, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); //用户订单支付 //缴纳齐全了就加商户没有就加到平台 + //查询保证金额度 和已交保证金 $money_limt = SystemStore::where('id', $order['store_id'])->field('paid_deposit,security_deposit')->find(); - $deposit = bcsub($money_limt['security_deposit'], $money_limt['paid_deposit'], 2); //保证金剩余额度 + //保证金剩余额度 + $deposit = bcsub($money_limt['security_deposit'], $money_limt['paid_deposit'], 2); + //门店利润 $store_profit = StoreFinanceFlowProduct::where('oid', $order['id'])->where('type', $type)->sum('number'); if ($deposit > 0) { + //如果保证金大于利润就全部扣除利润到保证金中 if ($deposit > $store_profit) { if ($store_profit > 0) { + //添加到门店保证中 $financeLogic->out($transaction_id, $store_profit, OrderEnum::ORDER_MARGIN, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); + //添加到门店余额中 $financeLogic->in($transaction_id, 0, OrderEnum::MERCHANT_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); //平台手续费 } } else { + //利润减去保证金 $money = bcsub($store_profit, $deposit, 2); if ($deposit > 0) { $financeLogic->out($transaction_id, $deposit, OrderEnum::ORDER_MARGIN, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); } if ($money) { + //添加到门店余额中 $financeLogic->in($transaction_id, $money, OrderEnum::MERCHANT_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); //平台手续费 } } } else { if ($store_profit > 0) { + //添加到门店余额中 $financeLogic->in($transaction_id, $store_profit, OrderEnum::MERCHANT_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); //平台手续费 } } diff --git a/app/common/logic/StoreFinanceFlowLogic.php b/app/common/logic/StoreFinanceFlowLogic.php index 98b3131be..1a2e06f8a 100644 --- a/app/common/logic/StoreFinanceFlowLogic.php +++ b/app/common/logic/StoreFinanceFlowLogic.php @@ -146,13 +146,20 @@ class StoreFinanceFlowLogic extends BaseLogic */ public function updateStatusStore($order_id, $store_id, $money, $deposit) { - StoreFinanceFlow::where(['order_id' => $order_id, 'financial_type' => 11])->update(['status' => 1]); - StoreFinanceFlow::where(['order_id' => $order_id, 'financial_type' => 2])->update(['status' => 1]); $store = SystemStore::where('id', $store_id)->find(); $capitalFlowDao = new CapitalFlowLogic($store, 'store'); if ($money > 0) { - $capitalFlowDao->storeIncome('store_money_add', 'order', $order_id, $money,'','store_money'); - SystemStore::where('id', $store_id)->inc('store_money', $money)->update(); + //判断是否是押金 + if($store['paid_deposit']<$store['security_deposit']){ + StoreFinanceFlow::where(['order_id' => $order_id, 'financial_type' => 11])->update(['status' => 1,'number'=>$money]); + StoreFinanceFlow::where(['order_id' => $order_id, 'financial_type' => 2])->update(['status' => 1,'number'=>0]); + + $capitalFlowDao->storeIncome('store_paid_deposit_add', 'order', $order_id, $money,'','paid_deposit'); + SystemStore::where('id', $store_id)->inc('paid_deposit', $money)->update(); + }else{ + $capitalFlowDao->storeIncome('store_money_add', 'order', $order_id, $money,'','store_money'); + SystemStore::where('id', $store_id)->inc('store_money', $money)->update(); + } } if ($deposit > 0) { $capitalFlowDao->storeIncome('store_paid_deposit_add', 'order', $order_id, $deposit,'','paid_deposit'); diff --git a/app/common/model/store_finance_flow_product/StoreFinanceFlowProduct.php b/app/common/model/store_finance_flow_product/StoreFinanceFlowProduct.php index bea36cb01..daa72cf84 100644 --- a/app/common/model/store_finance_flow_product/StoreFinanceFlowProduct.php +++ b/app/common/model/store_finance_flow_product/StoreFinanceFlowProduct.php @@ -18,13 +18,4 @@ class StoreFinanceFlowProduct extends BaseModel use SoftDelete; protected $name = 'store_finance_flow_product'; protected $deleteTime = 'delete_time'; - - public static function onAfterWrite($data){ - try{ - channelLog($data->getOrigin(),'store_finance_flow_product','更新前'); - channelLog($data->toArray(),'store_finance_flow_product','更新后'); - }catch(Throwable $e){ - Log::error('store_finance_flow_product:'.$e->getMessage()); - } - } } \ No newline at end of file From e58b0fbac58c232ac1b9b19c80c02ee1dc83804b Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Sat, 28 Sep 2024 15:32:31 +0800 Subject: [PATCH 25/32] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0`onBeforeWrite`?= =?UTF-8?q?=E5=92=8C`onAfterWrite`=E6=96=B9=E6=B3=95=E5=9C=A8`StoreFinance?= =?UTF-8?q?Flow`=E5=92=8C`SystemStore`=E6=A8=A1=E5=9E=8B=E4=B8=AD=E4=BB=A5?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=E6=9B=B4=E6=96=B0=E5=89=8D=E5=90=8E=E7=9A=84?= =?UTF-8?q?=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../store_finance_flow/StoreFinanceFlow.php | 16 ++++++++++++++-- app/common/model/system_store/SystemStore.php | 16 +++++++++++++++- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/app/common/model/store_finance_flow/StoreFinanceFlow.php b/app/common/model/store_finance_flow/StoreFinanceFlow.php index 38f79b90c..c1e701280 100644 --- a/app/common/model/store_finance_flow/StoreFinanceFlow.php +++ b/app/common/model/store_finance_flow/StoreFinanceFlow.php @@ -36,10 +36,22 @@ class StoreFinanceFlow extends BaseModel { return $this->hasOne(SystemStoreStaff::class, 'id', 'staff_id')->bind(['staff_name']); } - + public static function onBeforeWrite($data) + { + try { + $where = $data->getWhere(); + if($data){ + $find = self::where($where)->field(array_keys($data->toArray()))->find(); + if($find){ + channelLog(array_merge($find->toArray(),$where),'store_finance_flow','更新前'); + } + } + } catch (Throwable $e) { + Log::error('store_finance_flow:' . $e->getMessage()); + } + } public static function onAfterWrite($data){ try{ - channelLog($data->getOrigin(),'store_finance_flow','更新前'); channelLog($data->toArray(),'store_finance_flow','更新后'); }catch(Throwable $e){ Log::error('store_finance_flow:'.$e->getMessage()); diff --git a/app/common/model/system_store/SystemStore.php b/app/common/model/system_store/SystemStore.php index ff209e545..320d93f30 100644 --- a/app/common/model/system_store/SystemStore.php +++ b/app/common/model/system_store/SystemStore.php @@ -19,9 +19,23 @@ class SystemStore extends BaseModel protected $name = 'system_store'; protected $deleteTime = 'delete_time'; + public static function onBeforeWrite($data) + { + try { + $where = $data->getWhere(); + if($data){ + $find = self::where($where)->field(array_keys($data->toArray()))->find(); + if($find){ + channelLog(array_merge($find->toArray(),$where),'system_store','更新前'); + } + } + } catch (Throwable $e) { + Log::error('system_store:' . $e->getMessage()); + } + } + public static function onAfterWrite($data){ try{ - channelLog($data->getOrigin(),'system_store','更新前'); channelLog($data->toArray(),'system_store','更新后'); }catch(Throwable $e){ Log::error('system_store:'.$e->getMessage()); From 2ce312d7f89b915f4bea3964676bc27e183e1d43 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Sat, 28 Sep 2024 16:28:47 +0800 Subject: [PATCH 26/32] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9=E9=9B=B6?= =?UTF-8?q?=E5=94=AE=E4=BC=9A=E5=91=98=E5=88=A9=E6=B6=A6=E8=AE=A1=E7=AE=97?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/logic/CommissionProductLogic.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/common/logic/CommissionProductLogic.php b/app/common/logic/CommissionProductLogic.php index 13584e2a7..f66edeab7 100644 --- a/app/common/logic/CommissionProductLogic.php +++ b/app/common/logic/CommissionProductLogic.php @@ -123,9 +123,11 @@ class CommissionProductLogic extends BaseLogic if($order['pay_type']==18 && bcsub($user['total_recharge_amount'],$user['purchase_funds'],2)<$user['first_purchase_funds']){ }else{ - $vip_number = bcmul($total_price, 0.06, 2); //会员利润 - $data[] = $this->vip_user('零售会员', $order, $find, $uid, $price, $total_price, $vip_number,0.06); - $number1 = bcadd($number1, $vip_number, 2); + if($rose<6){ + $vip_number = bcmul($total_price, 0.06, 2); //会员利润 + $data[] = $this->vip_user('零售会员', $order, $find, $uid, $price, $total_price, $vip_number,0.06); + $number1 = bcadd($number1, $vip_number, 2); + } } if ($rose >= 12 && $village_uid>0) { $village_number = bcmul($total_price, 0.01, 2); //村长利润 From 189964de004eaa6a360a8b8aadf803d5f69263c6 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Sat, 28 Sep 2024 16:37:03 +0800 Subject: [PATCH 27/32] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9=E9=9B=B6?= =?UTF-8?q?=E5=94=AE=E4=BC=9A=E5=91=98=E5=88=A9=E6=B6=A6=E8=AE=A1=E7=AE=97?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/logic/CommissionProductLogic.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/common/logic/CommissionProductLogic.php b/app/common/logic/CommissionProductLogic.php index f66edeab7..5f23c58a6 100644 --- a/app/common/logic/CommissionProductLogic.php +++ b/app/common/logic/CommissionProductLogic.php @@ -123,7 +123,7 @@ class CommissionProductLogic extends BaseLogic if($order['pay_type']==18 && bcsub($user['total_recharge_amount'],$user['purchase_funds'],2)<$user['first_purchase_funds']){ }else{ - if($rose<6){ + if($rose>=9){ $vip_number = bcmul($total_price, 0.06, 2); //会员利润 $data[] = $this->vip_user('零售会员', $order, $find, $uid, $price, $total_price, $vip_number,0.06); $number1 = bcadd($number1, $vip_number, 2); From 9da0f8942d7bb14993dd35de7784082c1c0729ec Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Mon, 30 Sep 2024 10:36:41 +0800 Subject: [PATCH 28/32] =?UTF-8?q?feat:=20=E8=B0=83=E6=95=B4=E9=9B=B6?= =?UTF-8?q?=E5=94=AE=E4=BC=9A=E5=91=98=E5=88=A9=E6=B6=A6=E8=AE=A1=E7=AE=97?= =?UTF-8?q?=E6=9D=A1=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/logic/CommissionProductLogic.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/common/logic/CommissionProductLogic.php b/app/common/logic/CommissionProductLogic.php index 5f23c58a6..8f39e9738 100644 --- a/app/common/logic/CommissionProductLogic.php +++ b/app/common/logic/CommissionProductLogic.php @@ -123,7 +123,7 @@ class CommissionProductLogic extends BaseLogic if($order['pay_type']==18 && bcsub($user['total_recharge_amount'],$user['purchase_funds'],2)<$user['first_purchase_funds']){ }else{ - if($rose>=9){ + if($rose>=10){ $vip_number = bcmul($total_price, 0.06, 2); //会员利润 $data[] = $this->vip_user('零售会员', $order, $find, $uid, $price, $total_price, $vip_number,0.06); $number1 = bcadd($number1, $vip_number, 2); From 3a100dc66219c94b4a1c6b70fa9a0aaa4830e4a2 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Mon, 30 Sep 2024 16:44:47 +0800 Subject: [PATCH 29/32] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E9=A2=84?= =?UTF-8?q?=E8=AE=A2=E5=8D=95=E8=A1=A8=E5=92=8C=E9=A2=84=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E8=B4=AD=E7=89=A9=E8=AF=A6=E6=83=85=E8=A1=A8=E7=9A=84API?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BeforehandOrderController.php | 92 ++++++++++++ .../BeforehandOrderCartInfoController.php | 104 +++++++++++++ .../beforehand_order/BeforehandOrderLists.php | 65 +++++++++ .../BeforehandOrderCartInfoLists.php | 70 +++++++++ .../beforehand_order/BeforehandOrderLogic.php | 135 +++++++++++++++++ .../BeforehandOrderCartInfoLogic.php | 138 ++++++++++++++++++ .../beforehand_order/BeforehandOrder.php | 22 +++ .../BeforehandOrderCartInfo.php | 22 +++ 8 files changed, 648 insertions(+) create mode 100644 app/admin/controller/beforehand_order/BeforehandOrderController.php create mode 100644 app/admin/controller/beforehand_order_cart_info/BeforehandOrderCartInfoController.php create mode 100644 app/admin/lists/beforehand_order/BeforehandOrderLists.php create mode 100644 app/admin/lists/beforehand_order_cart_info/BeforehandOrderCartInfoLists.php create mode 100644 app/admin/logic/beforehand_order/BeforehandOrderLogic.php create mode 100644 app/admin/logic/beforehand_order_cart_info/BeforehandOrderCartInfoLogic.php create mode 100644 app/common/model/beforehand_order/BeforehandOrder.php create mode 100644 app/common/model/beforehand_order_cart_info/BeforehandOrderCartInfo.php diff --git a/app/admin/controller/beforehand_order/BeforehandOrderController.php b/app/admin/controller/beforehand_order/BeforehandOrderController.php new file mode 100644 index 000000000..683ff87c8 --- /dev/null +++ b/app/admin/controller/beforehand_order/BeforehandOrderController.php @@ -0,0 +1,92 @@ +dataLists(new BeforehandOrderLists()); + } + + + /** + * @notes 添加预订单表 + * @return \think\response\Json + * @author admin + * @date 2024/09/30 11:26 + */ + public function add() + { + $params =$this->request->post(); + $params['admin_id'] = $this->adminId; + $result = BeforehandOrderLogic::add($params); + return $this->success('添加成功', [], 1, 1); + } + + + /** + * @notes 编辑预订单表 + * @return \think\response\Json + * @author admin + * @date 2024/09/30 11:26 + */ + public function edit() + { + $params =$this->request->post(); + $result = BeforehandOrderLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(BeforehandOrderLogic::getError()); + } + + + /** + * @notes 删除预订单表 + * @return \think\response\Json + * @author admin + * @date 2024/09/30 11:26 + */ + public function delete() + { + $params =$this->request->post(); + BeforehandOrderLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取预订单表详情 + * @return \think\response\Json + * @author admin + * @date 2024/09/30 11:26 + */ + public function detail() + { + $params = (new BeforehandOrderValidate())->goCheck('detail'); + $result = BeforehandOrderLogic::detail($params); + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/app/admin/controller/beforehand_order_cart_info/BeforehandOrderCartInfoController.php b/app/admin/controller/beforehand_order_cart_info/BeforehandOrderCartInfoController.php new file mode 100644 index 000000000..7f31a85ec --- /dev/null +++ b/app/admin/controller/beforehand_order_cart_info/BeforehandOrderCartInfoController.php @@ -0,0 +1,104 @@ +dataLists(new BeforehandOrderCartInfoLists()); + } + + + /** + * @notes 添加预订单购物详情表 + * @return \think\response\Json + * @author admin + * @date 2024/09/30 11:32 + */ + public function add() + { + $params = $this->request->post(); + $result = BeforehandOrderCartInfoLogic::add($params); + return $this->success('添加成功', [], 1, 1); + + } + /** + * @notes 添加预订单购物详情表 + * @return \think\response\Json + * @author admin + * @date 2024/09/30 11:32 + */ + public function append_add() + { + $params = $this->request->post(); + $result = BeforehandOrderCartInfoLogic::appendAdd($params); + return $this->success('追加成功', [], 1, 1); + + } + + + /** + * @notes 编辑预订单购物详情表 + * @return \think\response\Json + * @author admin + * @date 2024/09/30 11:32 + */ + public function edit() + { + $params = $this->request->post(); + $result = BeforehandOrderCartInfoLogic::edit($params); + return $this->success('编辑成功', [], 1, 1); + + } + + + /** + * @notes 删除预订单购物详情表 + * @return \think\response\Json + * @author admin + * @date 2024/09/30 11:32 + */ + public function delete() + { + $params = $this->request->post(); + BeforehandOrderCartInfoLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取预订单购物详情表详情 + * @return \think\response\Json + * @author admin + * @date 2024/09/30 11:32 + */ + public function detail() + { + $params = $this->request->get(); + $result = BeforehandOrderCartInfoLogic::detail($params); + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/app/admin/lists/beforehand_order/BeforehandOrderLists.php b/app/admin/lists/beforehand_order/BeforehandOrderLists.php new file mode 100644 index 000000000..1526fea26 --- /dev/null +++ b/app/admin/lists/beforehand_order/BeforehandOrderLists.php @@ -0,0 +1,65 @@ + ['store_id', 'order_id', 'uid','paid','status',], + ]; + } + + + /** + * @notes 获取预订单表列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author admin + * @date 2024/09/30 11:26 + */ + public function lists(): array + { + return BeforehandOrder::where($this->searchWhere) + ->field(['id', 'store_id', 'order_id', 'uid', 'total_num', 'total_price', 'pay_price', 'deduction_price','create_time', 'source', 'status', 'mark']) + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select() + ->toArray(); + } + + + /** + * @notes 获取预订单表数量 + * @return int + * @author admin + * @date 2024/09/30 11:26 + */ + public function count(): int + { + return BeforehandOrder::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/admin/lists/beforehand_order_cart_info/BeforehandOrderCartInfoLists.php b/app/admin/lists/beforehand_order_cart_info/BeforehandOrderCartInfoLists.php new file mode 100644 index 000000000..54a3a61d7 --- /dev/null +++ b/app/admin/lists/beforehand_order_cart_info/BeforehandOrderCartInfoLists.php @@ -0,0 +1,70 @@ + ['bhoid', 'uid', 'product_id'], + ]; + } + + + /** + * @notes 获取预订单购物详情表列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author admin + * @date 2024/09/30 11:32 + */ + public function lists(): array + { + return BeforehandOrderCartInfo::where($this->searchWhere) + ->field(['id', 'bhoid', 'uid', 'product_id', 'attr_value_id', 'is_pay', 'purchase', 'price', 'total_price', 'cart_num']) + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select()->each(function($item){ + $find=StoreProduct::where('id',$item['product_id'])->field('store_name,image')->withTrashed()->find(); + $item['store_name']=$find['store_name']; + $item['image']=$find['image']; + return $item; + }) + ->toArray(); + } + + + /** + * @notes 获取预订单购物详情表数量 + * @return int + * @author admin + * @date 2024/09/30 11:32 + */ + public function count(): int + { + return BeforehandOrderCartInfo::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/admin/logic/beforehand_order/BeforehandOrderLogic.php b/app/admin/logic/beforehand_order/BeforehandOrderLogic.php new file mode 100644 index 000000000..1f9d3796c --- /dev/null +++ b/app/admin/logic/beforehand_order/BeforehandOrderLogic.php @@ -0,0 +1,135 @@ + $v) { + $datas[$k]['product_id'] = $v['product_id']; + $datas[$k]['uid'] = $uid; + $datas[$k]['cart_num'] = $v['nums']; + $datas[$k]['price'] = $v['purchase']; + $datas[$k]['total_price'] = $v['total_price']; + $datas[$k]['create_time'] = time(); + $datas[$k]['update_time'] =time(); + $total_num += $v['nums']; + $total_price += $v['total_price']; + } + $order = BeforehandOrder::create([ + 'order_id' => getNewOrderId('YG'), + 'admin_id' => $params['admin_id']??0, + 'uid' => $uid, + 'total_num' => $total_num, + 'total_price' => $total_price, + 'pay_price' => 0, + 'pay_type' => 0, + 'deduction_price' => 0, + 'paid' => 0, + 'source' => 0, + 'mark' => $params['mark']??'' + ]); + foreach ($datas as $k => $v) { + $datas[$k]['bhoid'] = $order['id']; + } + (new BeforehandOrderCartInfo())->saveAll($datas); + Db::commit(); + return true; + } catch (\Throwable $e) { + Db::rollback(); + throw new BusinessException($e->getMessage()); + } + } + + + /** + * @notes 编辑预订单表 + * @param array $params + * @return bool + * @author admin + * @date 2024/09/30 11:26 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + BeforehandOrder::where('id', $params['id'])->update([ + 'store_id' => $params['store_id'], + 'order_id' => $params['order_id'], + 'uid' => $params['uid'], + 'cart_id' => $params['cart_id'], + 'total_num' => $params['total_num'], + 'total_price' => $params['total_price'], + 'pay_price' => $params['pay_price'], + 'deduction_price' => $params['deduction_price'], + 'paid' => $params['paid'], + 'pay_time' => $params['pay_time'], + 'pay_type' => $params['pay_type'], + 'source' => $params['source'], + 'status' => $params['status'], + 'mark' => $params['mark'] + ]); + + Db::commit(); + return true; + } catch (\Throwable $e) { + Db::rollback(); + throw new BusinessException($e->getMessage()); + } + } + + + /** + * @notes 删除预订单表 + * @param array $params + * @return bool + * @author admin + * @date 2024/09/30 11:26 + */ + public static function delete(array $params): bool + { + return BeforehandOrder::destroy($params['id']); + } + + + /** + * @notes 获取预订单表详情 + * @param $params + * @return array + * @author admin + * @date 2024/09/30 11:26 + */ + public static function detail($params): array + { + return BeforehandOrder::findOrEmpty($params['id'])->toArray(); + } +} diff --git a/app/admin/logic/beforehand_order_cart_info/BeforehandOrderCartInfoLogic.php b/app/admin/logic/beforehand_order_cart_info/BeforehandOrderCartInfoLogic.php new file mode 100644 index 000000000..837e99643 --- /dev/null +++ b/app/admin/logic/beforehand_order_cart_info/BeforehandOrderCartInfoLogic.php @@ -0,0 +1,138 @@ + $params['oid'], + 'uid' => $params['uid'], + 'product_id' => $params['product_id'], + 'attr_value_id' => $params['attr_value_id'], + 'is_pay' => $params['is_pay'], + 'purchase' => $params['purchase'], + 'price' => $params['price'], + 'total_price' => $params['total_price'], + 'cart_num' => $params['cart_num'], + 'old_cart_id' => $params['old_cart_id'] + ]); + + Db::commit(); + return true; + } catch (\Throwable $e) { + Db::rollback(); + throw new BusinessException($e->getMessage()); + } + } + /** + * @notes 追加预订单购物详情表 + */ + public static function appendAdd(array $params): bool + { + Db::startTrans(); + try { + $datas = []; + $uid=$params['uid'] ?? 0; + $bhoid=$params['id']; + foreach ($params['product_arr'] as $k => $v) { + $datas[$k]['product_id'] = $v['id']; + $datas[$k]['uid'] = $uid; + $datas[$k]['bhoid'] = $bhoid; + $datas[$k]['cart_num'] = $v['nums']; + $datas[$k]['price'] = $v['purchase']; + $datas[$k]['total_price'] = $v['total_price']; + $datas[$k]['create_time'] = time(); + $datas[$k]['update_time'] =time(); + } + (new BeforehandOrderCartInfo())->saveAll($datas); + + $info=BeforehandOrderCartInfo::where('bhoid',$bhoid)->field('sum(cart_num) as cart_num,sum(total_price) as total_price')->find(); + BeforehandOrder::where('id',$bhoid)->update(['total_price'=>$info['total_price'],'total_num'=>$info['cart_num']]); + Db::commit(); + return true; + } catch (\Throwable $e) { + Db::rollback(); + throw new BusinessException($e->getMessage()); + } + } + + + /** + * @notes 编辑预订单购物详情表 + * @param array $params + * @return bool + * @author admin + * @date 2024/09/30 11:32 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + BeforehandOrderCartInfo::where('id', $params['id'])->update([ + 'price' => $params['purchase'], + 'total_price' => $params['total_price'], + 'cart_num' => $params['nums'], + ]); + $bhoid=$params['bhoid']; + $info=BeforehandOrderCartInfo::where('bhoid',$bhoid)->field('sum(cart_num) as cart_num,sum(total_price) as total_price')->find(); + BeforehandOrder::where('id',$bhoid)->update(['total_price'=>$info['total_price'],'total_num'=>$info['cart_num']]); + Db::commit(); + return true; + } catch (\Throwable $e) { + Db::rollback(); + throw new BusinessException($e->getMessage()); + } + } + + + /** + * @notes 删除预订单购物详情表 + * @param array $params + * @return bool + * @author admin + * @date 2024/09/30 11:32 + */ + public static function delete(array $params): bool + { + return BeforehandOrderCartInfo::destroy($params['id']); + } + + + /** + * @notes 获取预订单购物详情表详情 + * @param $params + * @return array + * @author admin + * @date 2024/09/30 11:32 + */ + public static function detail($params): array + { + return BeforehandOrderCartInfo::findOrEmpty($params['id'])->toArray(); + } +} \ No newline at end of file diff --git a/app/common/model/beforehand_order/BeforehandOrder.php b/app/common/model/beforehand_order/BeforehandOrder.php new file mode 100644 index 000000000..e7944436d --- /dev/null +++ b/app/common/model/beforehand_order/BeforehandOrder.php @@ -0,0 +1,22 @@ + Date: Mon, 30 Sep 2024 17:36:27 +0800 Subject: [PATCH 30/32] =?UTF-8?q?feat:=20=E7=A7=BB=E9=99=A4=E4=BA=86?= =?UTF-8?q?=E6=BA=90=E7=B1=BB=E5=9E=8B=E5=AD=97=E6=AE=B5source?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/logic/beforehand_order/BeforehandOrderLogic.php | 1 - 1 file changed, 1 deletion(-) diff --git a/app/admin/logic/beforehand_order/BeforehandOrderLogic.php b/app/admin/logic/beforehand_order/BeforehandOrderLogic.php index 1f9d3796c..c9c597871 100644 --- a/app/admin/logic/beforehand_order/BeforehandOrderLogic.php +++ b/app/admin/logic/beforehand_order/BeforehandOrderLogic.php @@ -55,7 +55,6 @@ class BeforehandOrderLogic extends BaseLogic 'pay_type' => 0, 'deduction_price' => 0, 'paid' => 0, - 'source' => 0, 'mark' => $params['mark']??'' ]); foreach ($datas as $k => $v) { From 2e4bee3216cefb100b35996a4d4d81ccad73d2ff Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Sat, 5 Oct 2024 16:21:09 +0800 Subject: [PATCH 31/32] =?UTF-8?q?feat:=20=E8=B0=83=E6=95=B4=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E7=9B=B8=E5=85=B3=E9=80=BB=E8=BE=91=EF=BC=8C=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E9=97=A8=E5=BA=97=E5=88=A9=E6=B6=A6=E8=AE=A1=E7=AE=97?= =?UTF-8?q?=E6=96=B9=E5=BC=8F=EF=BC=8C=E7=A7=BB=E9=99=A4=E6=BA=90=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E5=AD=97=E6=AE=B5source?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BeforehandOrderController.php | 32 ++++++-- .../BeforehandOrderCartInfoController.php | 25 +++++- .../PurchaseProductOfferController.php | 16 +++- .../store_order/StoreOrderController.php | 2 +- .../beforehand_order/BeforehandOrderLists.php | 2 +- .../BeforehandOrderThreeLists.php | 79 +++++++++++++++++++ .../BeforehandOrderTwoLists.php | 79 +++++++++++++++++++ .../BeforehandOrderCartInfoLists.php | 7 +- .../PurchaseProductOfferLists.php | 6 ++ .../beforehand_order/BeforehandOrderLogic.php | 74 ++++++++++++++++- .../BeforehandOrderCartInfoLogic.php | 72 ++++++++++++++--- .../PurchaseProductOfferLogic.php | 53 ++++++++----- .../PurchaseProductOfferValidate.php | 2 +- app/api/controller/order/OrderController.php | 6 +- 14 files changed, 405 insertions(+), 50 deletions(-) create mode 100644 app/admin/lists/beforehand_order/BeforehandOrderThreeLists.php create mode 100644 app/admin/lists/beforehand_order/BeforehandOrderTwoLists.php diff --git a/app/admin/controller/beforehand_order/BeforehandOrderController.php b/app/admin/controller/beforehand_order/BeforehandOrderController.php index 683ff87c8..cfbd4a466 100644 --- a/app/admin/controller/beforehand_order/BeforehandOrderController.php +++ b/app/admin/controller/beforehand_order/BeforehandOrderController.php @@ -5,6 +5,8 @@ namespace app\admin\controller\beforehand_order; use app\admin\controller\BaseAdminController; use app\admin\lists\beforehand_order\BeforehandOrderLists; +use app\admin\lists\beforehand_order\BeforehandOrderTwoLists; +use app\admin\lists\beforehand_order\BeforehandOrderThreeLists; use app\admin\logic\beforehand_order\BeforehandOrderLogic; @@ -28,6 +30,14 @@ class BeforehandOrderController extends BaseAdminController return $this->dataLists(new BeforehandOrderLists()); } + public function warehousing_lists() + { + return $this->dataLists(new BeforehandOrderTwoLists()); + } + public function outbound_lists() + { + return $this->dataLists(new BeforehandOrderThreeLists()); + } /** * @notes 添加预订单表 @@ -37,12 +47,22 @@ class BeforehandOrderController extends BaseAdminController */ public function add() { - $params =$this->request->post(); + $params = $this->request->post(); $params['admin_id'] = $this->adminId; $result = BeforehandOrderLogic::add($params); return $this->success('添加成功', [], 1, 1); } - + /** + * 一键出库 + */ + public function createOutboundOrder() + { + $params=$this->request->post(); + $params['admin_id'] = $this->adminId; + $result = BeforehandOrderLogic::createOutboundOrder($params); + + return $this->success('出库成功', [], 1, 1); + } /** * @notes 编辑预订单表 @@ -52,7 +72,7 @@ class BeforehandOrderController extends BaseAdminController */ public function edit() { - $params =$this->request->post(); + $params = $this->request->post(); $result = BeforehandOrderLogic::edit($params); if (true === $result) { return $this->success('编辑成功', [], 1, 1); @@ -69,7 +89,7 @@ class BeforehandOrderController extends BaseAdminController */ public function delete() { - $params =$this->request->post(); + $params = $this->request->post(); BeforehandOrderLogic::delete($params); return $this->success('删除成功', [], 1, 1); } @@ -87,6 +107,4 @@ class BeforehandOrderController extends BaseAdminController $result = BeforehandOrderLogic::detail($params); return $this->data($result); } - - -} \ No newline at end of file +} diff --git a/app/admin/controller/beforehand_order_cart_info/BeforehandOrderCartInfoController.php b/app/admin/controller/beforehand_order_cart_info/BeforehandOrderCartInfoController.php index 7f31a85ec..e5376131e 100644 --- a/app/admin/controller/beforehand_order_cart_info/BeforehandOrderCartInfoController.php +++ b/app/admin/controller/beforehand_order_cart_info/BeforehandOrderCartInfoController.php @@ -6,8 +6,7 @@ namespace app\admin\controller\beforehand_order_cart_info; use app\admin\controller\BaseAdminController; use app\admin\lists\beforehand_order_cart_info\BeforehandOrderCartInfoLists; use app\admin\logic\beforehand_order_cart_info\BeforehandOrderCartInfoLogic; -use app\admin\validate\beforehand_order_cart_info\BeforehandOrderCartInfoValidate; - +use app\common\model\beforehand_order_cart_info\BeforehandOrderCartInfo; /** * 预订单购物详情表控制器 @@ -57,7 +56,29 @@ class BeforehandOrderCartInfoController extends BaseAdminController } + /** + * @notes 编辑预订单购物详情无需采购 + */ + public function procurement_status(){ + $id=$this->request->post('id'); + $res=BeforehandOrderCartInfo::where('id',$id)->update(['is_buyer'=>-1]); + if($res){ + return $this->success('操作成功',[],1,1); + }else{ + return $this->fail('操作失败'); + } + } + + /** + * @notes 一键入库 + */ + public function one_click_storage(){ + $params=$this->request->post(); + $params['admin_id']=$this->adminId; + BeforehandOrderCartInfoLogic::oneClickStorage($params); + return $this->success('入库成功', [], 1, 1); + } /** * @notes 编辑预订单购物详情表 * @return \think\response\Json diff --git a/app/admin/controller/purchase_product_offer/PurchaseProductOfferController.php b/app/admin/controller/purchase_product_offer/PurchaseProductOfferController.php index 0e92a4f87..f35f8665e 100644 --- a/app/admin/controller/purchase_product_offer/PurchaseProductOfferController.php +++ b/app/admin/controller/purchase_product_offer/PurchaseProductOfferController.php @@ -64,12 +64,22 @@ class PurchaseProductOfferController extends BaseAdminController return $this->fail('参数错误'); break; } - if (PurchaseProductOfferLogic::hasError()) { - return $this->fail(PurchaseProductOfferLogic::getError()); - } return $this->success('设置成功', [], 1, 1); } + /** + * @notes 设置采购信息 + * @return \think\response\Json + * @author admin + * @date 2024/08/14 15:06 + */ + public function setProcureInfo() + { + $params = $this->request->post(); + PurchaseProductOfferLogic::setProcureInfo($params); + + return $this->success('设置成功', [], 1, 1); + } /** diff --git a/app/admin/controller/store_order/StoreOrderController.php b/app/admin/controller/store_order/StoreOrderController.php index efa371bbe..450daca0d 100644 --- a/app/admin/controller/store_order/StoreOrderController.php +++ b/app/admin/controller/store_order/StoreOrderController.php @@ -213,7 +213,7 @@ class StoreOrderController extends BaseAdminController 'warehouse_id' => $warehouse_id, 'store_id' => $store_id, 'supplier_id' => 0, - 'code' => getNewOrderId('PS'), + 'code' => getNewOrderId('CK'), 'admin_id' => $this->adminId, 'financial_pm' => 0, 'batch' => 0, diff --git a/app/admin/lists/beforehand_order/BeforehandOrderLists.php b/app/admin/lists/beforehand_order/BeforehandOrderLists.php index 1526fea26..979124c4f 100644 --- a/app/admin/lists/beforehand_order/BeforehandOrderLists.php +++ b/app/admin/lists/beforehand_order/BeforehandOrderLists.php @@ -43,7 +43,7 @@ class BeforehandOrderLists extends BaseAdminDataLists implements ListsSearchInte public function lists(): array { return BeforehandOrder::where($this->searchWhere) - ->field(['id', 'store_id', 'order_id', 'uid', 'total_num', 'total_price', 'pay_price', 'deduction_price','create_time', 'source', 'status', 'mark']) + ->field(['id','order_id', 'uid','total_num', 'total_price', 'pay_price', 'deduction_price','create_time', 'status', 'mark']) ->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) ->select() diff --git a/app/admin/lists/beforehand_order/BeforehandOrderThreeLists.php b/app/admin/lists/beforehand_order/BeforehandOrderThreeLists.php new file mode 100644 index 000000000..be66e40ec --- /dev/null +++ b/app/admin/lists/beforehand_order/BeforehandOrderThreeLists.php @@ -0,0 +1,79 @@ +request->get('id'))->value('outbound_id'); + if(empty($outbound_id)){ + return []; + } + $this->searchWhere[]=['oid','=',$outbound_id]; + $this->searchWhere[]=['financial_pm','=',0]; + return WarehouseProduct::where($this->searchWhere)->select() + ->each(function($item){ + $find=StoreProduct::where('id',$item['product_id'])->field('store_name,image,unit')->withTrashed()->find(); + $item['store_name']=$find['store_name']; + $item['image']=$find['image']; + if($item['unit']==0){ + $item['unit_name']=StoreProductUnit::where('id',$find['unit'])->value('name'); + }else{ + $item['unit_name']=StoreProductUnit::where('id',$item['unit'])->value('name'); + } + return $item; + }) + ->toArray(); + } + + + /** + * @notes 获取预订单表数量 + * @return int + * @author admin + * @date 2024/09/30 11:26 + */ + public function count(): int + { + return WarehouseProduct::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/admin/lists/beforehand_order/BeforehandOrderTwoLists.php b/app/admin/lists/beforehand_order/BeforehandOrderTwoLists.php new file mode 100644 index 000000000..cb5f87803 --- /dev/null +++ b/app/admin/lists/beforehand_order/BeforehandOrderTwoLists.php @@ -0,0 +1,79 @@ +request->get('id'))->value('warehousing_id'); + if(empty($warehousing_id)){ + return []; + } + $this->searchWhere[]=['oid','=',$warehousing_id]; + $this->searchWhere[]=['financial_pm','=',1]; + return WarehouseProduct::where($this->searchWhere)->select() + ->each(function($item){ + $find=StoreProduct::where('id',$item['product_id'])->field('store_name,image,unit')->withTrashed()->find(); + $item['store_name']=$find['store_name']; + $item['image']=$find['image']; + if($item['unit']==0){ + $item['unit_name']=StoreProductUnit::where('id',$find['unit'])->value('name'); + }else{ + $item['unit_name']=StoreProductUnit::where('id',$item['unit'])->value('name'); + } + return $item; + }) + ->toArray(); + } + + + /** + * @notes 获取预订单表数量 + * @return int + * @author admin + * @date 2024/09/30 11:26 + */ + public function count(): int + { + return WarehouseProduct::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/admin/lists/beforehand_order_cart_info/BeforehandOrderCartInfoLists.php b/app/admin/lists/beforehand_order_cart_info/BeforehandOrderCartInfoLists.php index 54a3a61d7..b6c7f5e2e 100644 --- a/app/admin/lists/beforehand_order_cart_info/BeforehandOrderCartInfoLists.php +++ b/app/admin/lists/beforehand_order_cart_info/BeforehandOrderCartInfoLists.php @@ -7,6 +7,7 @@ use app\admin\lists\BaseAdminDataLists; use app\common\model\beforehand_order_cart_info\BeforehandOrderCartInfo; use app\common\lists\ListsSearchInterface; use app\common\model\store_product\StoreProduct; +use app\common\model\warehouse_product_storege\WarehouseProductStorege; /** * 预订单购物详情表列表 @@ -43,13 +44,15 @@ class BeforehandOrderCartInfoLists extends BaseAdminDataLists implements ListsSe public function lists(): array { return BeforehandOrderCartInfo::where($this->searchWhere) - ->field(['id', 'bhoid', 'uid', 'product_id', 'attr_value_id', 'is_pay', 'purchase', 'price', 'total_price', 'cart_num']) + ->field(['id', 'bhoid', 'uid', 'is_buyer','buyer_uid','product_id', 'attr_value_id', 'is_pay', 'purchase', 'price', 'total_price', 'cart_num']) ->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) ->select()->each(function($item){ - $find=StoreProduct::where('id',$item['product_id'])->field('store_name,image')->withTrashed()->find(); + $find=StoreProduct::where('id',$item['product_id'])->field('store_name,image,unit')->withTrashed()->find(); + $item['warehouse_stock']=WarehouseProductStorege::where('product_id',$item['product_id'])->value('nums')??0; $item['store_name']=$find['store_name']; $item['image']=$find['image']; + $item['unit']=$find['unit']; return $item; }) ->toArray(); diff --git a/app/admin/lists/purchase_product_offer/PurchaseProductOfferLists.php b/app/admin/lists/purchase_product_offer/PurchaseProductOfferLists.php index 565a3c411..afd7ed30e 100644 --- a/app/admin/lists/purchase_product_offer/PurchaseProductOfferLists.php +++ b/app/admin/lists/purchase_product_offer/PurchaseProductOfferLists.php @@ -9,6 +9,7 @@ use app\common\lists\ListsSearchInterface; use app\common\model\delivery_service\DeliveryService; use app\common\model\store_product\StoreProduct; use app\common\model\store_product_unit\StoreProductUnit; +use app\common\model\supplier\Supplier; /** * 采购供应链商品列表 @@ -67,6 +68,11 @@ class PurchaseProductOfferLists extends BaseAdminDataLists implements ListsSearc $item->buyer_confirm_name='采购完成'; } } + if($item->supplier_id>0){ + $item->supplier_name=Supplier::where('id',$item->supplier_id)->value('mer_name'); + }else{ + $item->supplier_name=''; + } if($item->is_storage==1){ $item->is_storage_name='已入库'; }else{ diff --git a/app/admin/logic/beforehand_order/BeforehandOrderLogic.php b/app/admin/logic/beforehand_order/BeforehandOrderLogic.php index c9c597871..503d91528 100644 --- a/app/admin/logic/beforehand_order/BeforehandOrderLogic.php +++ b/app/admin/logic/beforehand_order/BeforehandOrderLogic.php @@ -2,10 +2,14 @@ namespace app\admin\logic\beforehand_order; - +use app\admin\logic\store_product\StoreProductLogic; +use app\admin\logic\warehouse_product\WarehouseProductLogic; use app\common\model\beforehand_order\BeforehandOrder; use app\common\logic\BaseLogic; use app\common\model\beforehand_order_cart_info\BeforehandOrderCartInfo; +use app\common\model\store_product\StoreProduct; +use app\common\model\warehouse_order\WarehouseOrder; +use app\common\model\warehouse_product\WarehouseProduct; use support\exception\BusinessException; use think\facade\Db; @@ -106,6 +110,74 @@ class BeforehandOrderLogic extends BaseLogic } } + /** + * @notes 一键入库 + * @param array $params + * @return bool + * @author admin + * @date 2024/09/30 11:26 + */ + public static function createOutboundOrder(array $params): bool + { + $warehouse_id= $params['warehouse_id']; + $store_id= $params['store_id']; + $admin_id= $params['admin_id']; + $delivery_time= $params['delivery_time']; + $mark= $params['remark']??''; + $order=BeforehandOrder::where('id', $params['bhoid'])->find(); + if(!$order){ + throw new BusinessException('该订单不存在'); + } + if($order['outbound_id']>0){ + throw new BusinessException('该订单已创建出库单'); + } + $info=BeforehandOrderCartInfo::where('bhoid', $params['bhoid'])->select(); + Db::startTrans(); + try { + $arr = [ + 'oid' => 0, + 'warehouse_id' => $warehouse_id, + 'store_id' => $store_id, + 'supplier_id' => 0, + 'code' => getNewOrderId('CK'), + 'admin_id' => $admin_id, + 'financial_pm' => 0, + 'batch' => 0, + 'mark' => $mark, + ]; + $arr['delivery_time'] = strtotime($delivery_time); + $res = WarehouseOrder::create($arr); + foreach ($info as $key => $arr) { + $data = [ + 'warehouse_id' => $warehouse_id, + 'product_id' => $arr['product_id'], + 'store_id' => $store_id, + 'financial_pm' => 0, + 'batch' => 1, + 'nums' => $arr['cart_num'], + 'status' => 1, + 'admin_id' => $admin_id, + ]; + $storeProduct = StoreProduct::where('id', $arr['product_id'])->findOrEmpty()->toArray(); + if ($arr['cart_num'] == 0) { + StoreProductLogic::ordinary($arr, $store_id, $admin_id, $storeProduct); + } else { + $data['total_price'] =$arr['total_price']; + $data['purchase'] = $storeProduct['purchase']; + $data['oid'] = $res['id']; + WarehouseProductLogic::add($data); + $finds = WarehouseProduct::where('oid', $res['id'])->field('sum(nums) as nums,sum(total_price) as total_price')->find(); + WarehouseOrder::where('id', $res['id'])->update(['total_price' => $finds['total_price'], 'nums' => $finds['nums']]); + } + } + BeforehandOrder::update(['outbound_id'=>$res['id']],['id'=>$params['bhoid']]); + Db::commit(); + return true; + } catch (\Throwable $e) { + Db::rollback(); + throw new BusinessException($e->getMessage()); + } + } /** * @notes 删除预订单表 diff --git a/app/admin/logic/beforehand_order_cart_info/BeforehandOrderCartInfoLogic.php b/app/admin/logic/beforehand_order_cart_info/BeforehandOrderCartInfoLogic.php index 837e99643..5a3ad6766 100644 --- a/app/admin/logic/beforehand_order_cart_info/BeforehandOrderCartInfoLogic.php +++ b/app/admin/logic/beforehand_order_cart_info/BeforehandOrderCartInfoLogic.php @@ -2,10 +2,12 @@ namespace app\admin\logic\beforehand_order_cart_info; - +use app\admin\logic\warehouse_product\WarehouseProductLogic; use app\common\model\beforehand_order_cart_info\BeforehandOrderCartInfo; use app\common\logic\BaseLogic; use app\common\model\beforehand_order\BeforehandOrder; +use app\common\model\purchase_product_offer\PurchaseProductOffer; +use app\common\model\warehouse_order\WarehouseOrder; use support\exception\BusinessException; use think\facade\Db; @@ -58,8 +60,8 @@ class BeforehandOrderCartInfoLogic extends BaseLogic Db::startTrans(); try { $datas = []; - $uid=$params['uid'] ?? 0; - $bhoid=$params['id']; + $uid = $params['uid'] ?? 0; + $bhoid = $params['id']; foreach ($params['product_arr'] as $k => $v) { $datas[$k]['product_id'] = $v['id']; $datas[$k]['uid'] = $uid; @@ -68,12 +70,12 @@ class BeforehandOrderCartInfoLogic extends BaseLogic $datas[$k]['price'] = $v['purchase']; $datas[$k]['total_price'] = $v['total_price']; $datas[$k]['create_time'] = time(); - $datas[$k]['update_time'] =time(); + $datas[$k]['update_time'] = time(); } (new BeforehandOrderCartInfo())->saveAll($datas); - $info=BeforehandOrderCartInfo::where('bhoid',$bhoid)->field('sum(cart_num) as cart_num,sum(total_price) as total_price')->find(); - BeforehandOrder::where('id',$bhoid)->update(['total_price'=>$info['total_price'],'total_num'=>$info['cart_num']]); + $info = BeforehandOrderCartInfo::where('bhoid', $bhoid)->field('sum(cart_num) as cart_num,sum(total_price) as total_price')->find(); + BeforehandOrder::where('id', $bhoid)->update(['total_price' => $info['total_price'], 'total_num' => $info['cart_num']]); Db::commit(); return true; } catch (\Throwable $e) { @@ -99,9 +101,9 @@ class BeforehandOrderCartInfoLogic extends BaseLogic 'total_price' => $params['total_price'], 'cart_num' => $params['nums'], ]); - $bhoid=$params['bhoid']; - $info=BeforehandOrderCartInfo::where('bhoid',$bhoid)->field('sum(cart_num) as cart_num,sum(total_price) as total_price')->find(); - BeforehandOrder::where('id',$bhoid)->update(['total_price'=>$info['total_price'],'total_num'=>$info['cart_num']]); + $bhoid = $params['bhoid']; + $info = BeforehandOrderCartInfo::where('bhoid', $bhoid)->field('sum(cart_num) as cart_num,sum(total_price) as total_price')->find(); + BeforehandOrder::where('id', $bhoid)->update(['total_price' => $info['total_price'], 'total_num' => $info['cart_num']]); Db::commit(); return true; } catch (\Throwable $e) { @@ -110,7 +112,57 @@ class BeforehandOrderCartInfoLogic extends BaseLogic } } + /** + * 一键入库 + */ + public static function oneClickStorage($params) + { + $count = PurchaseProductOffer::where(['order_id' => $params['bhoid'], 'is_storage' => 0, 'buyer_nums' => 0])->count('id'); + $warehousing_id = BeforehandOrder::where('id', $params['bhoid'])->value('warehousing_id'); + if ($count > 0 || $warehousing_id > 0) { + throw new BusinessException('请勿重复入库'); + } + $offer_list = PurchaseProductOffer::where(['order_id' => $params['bhoid'], 'is_storage' => 0])->select(); + Db::startTrans(); + try { + $code = getNewOrderId('RK'); + $arr = [ + 'warehouse_id' => $params['warehouse_id'], + 'supplier_id' => 0, + 'admin_id' => $params['admin_id'], + 'financial_pm' => 1, + 'batch' => 0, + 'code' => $code, + 'mark' => $params['remark'] ?? '', + 'total_price' => $params['total_price'], + 'completed_amount' => $params['completed_amount'] ?? 0, + 'outstanding_amount' => $params['outstanding_amount'] ?? 0, + ]; + $res = WarehouseOrder::create($arr); + foreach ($offer_list as $k => $v) { + $data['admin_id'] = $params['admin_id']; + $data['store_id'] = 0; + $data['oid'] = $res['id']; + $data['supplier_id'] = $v['supplier_id']; + $data['warehouse_id'] = $params['warehouse_id']; + $data['code'] = $code; + $data['product_id'] = $v['product_id']; + $data['nums'] = $v['buyer_nums']; + $data['purchase'] = $v['price']; + $data['total_price'] = $v['total_price']; + $data['financial_pm'] = 1; + WarehouseProductLogic::add($data); + PurchaseProductOffer::where('id', $v['id'])->update(['status' => 1, 'is_storage' => 1]); + } + BeforehandOrder::where('id', $params['bhoid'])->update(['warehousing_id' => $res['id']]); + Db::commit(); + return true; + } catch (\Throwable $e) { + Db::rollback(); + throw new BusinessException($e->getMessage()); + } + } /** * @notes 删除预订单购物详情表 * @param array $params @@ -135,4 +187,4 @@ class BeforehandOrderCartInfoLogic extends BaseLogic { return BeforehandOrderCartInfo::findOrEmpty($params['id'])->toArray(); } -} \ No newline at end of file +} diff --git a/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php b/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php index 32fd6aac4..bb341c594 100644 --- a/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php +++ b/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php @@ -5,7 +5,6 @@ namespace app\admin\logic\purchase_product_offer; use app\common\model\purchase_product_offer\PurchaseProductOffer; use app\common\logic\BaseLogic; -use app\common\model\delivery_service\DeliveryService; use support\exception\BusinessException; use think\facade\Db; @@ -31,23 +30,15 @@ class PurchaseProductOfferLogic extends BaseLogic Db::startTrans(); try { PurchaseProductOffer::create([ - 'supplier_id' => $params['supplier_id'], 'order_id' => $params['order_id'], 'product_id' => $params['product_id'], - 'price' => $params['price'], - 'nums' => $params['nums'], 'unit' => $params['unit'], 'is_buyer' => $params['is_buyer'], - 'buyer_confirm' => $params['buyer_confirm'], - 'is_storage' => $params['is_storage'], - 'is_stream' => $params['is_stream'], 'need_num' => $params['need_num'], - 'notes' => $params['notes'], + 'notes' => $params['notes'] ?? '', 'buyer_id' => $params['buyer_id'], - 'status' => $params['status'], - 'stream_admin_id' => $params['stream_admin_id'], - 'stream_time' => $params['stream_time'], - 'storage_admin_id' => $params['storage_admin_id'] + 'status' => 0, + ]); Db::commit(); @@ -92,7 +83,31 @@ class PurchaseProductOfferLogic extends BaseLogic Db::commit(); return true; - } catch (\Exception $e) { + } catch (\Throwable $e) { + Db::rollback(); + throw new BusinessException($e->getMessage()); + } + } + /** + * @notes 设置采购信息 + * @param array $params + * @return bool + * @author admin + * @date 2024/08/14 15:06 + */ + public static function setProcureInfo(array $params): bool + { + Db::startTrans(); + try { + PurchaseProductOffer::update([ + 'buyer_nums' => $params['buyer_nums'], + 'supplier_id' => $params['supplier_id'], + 'price' => $params['price'], + 'total_price' => $params['total_price'], + ],['id'=>$params['id']]); + Db::commit(); + return true; + } catch (\Throwable $e) { Db::rollback(); throw new BusinessException($e->getMessage()); } @@ -103,20 +118,20 @@ class PurchaseProductOfferLogic extends BaseLogic */ public static function buyer($params) { - if($params['is_buyer']==1){ - if($params['buyer_id']==''){ + if ($params['is_buyer'] == 1) { + if ($params['buyer_id'] == '') { throw new BusinessException('采购人不能为空'); } - $data['buyer_id']=$params['buyer_id']; - $data['buyer_nums']=$params['buyer_nums']; + $data['buyer_id'] = $params['buyer_id']; + $data['buyer_nums'] = $params['buyer_nums']; } Db::startTrans(); try { - $data['is_buyer']=$params['is_buyer']; + $data['is_buyer'] = $params['is_buyer']; PurchaseProductOffer::where('id', $params['id'])->update($data); Db::commit(); return true; - } catch (\Exception $e) { + } catch (\Throwable $e) { Db::rollback(); throw new BusinessException($e->getMessage()); } diff --git a/app/admin/validate/purchase_product_offer/PurchaseProductOfferValidate.php b/app/admin/validate/purchase_product_offer/PurchaseProductOfferValidate.php index fedc5e9a7..2322ebcbb 100644 --- a/app/admin/validate/purchase_product_offer/PurchaseProductOfferValidate.php +++ b/app/admin/validate/purchase_product_offer/PurchaseProductOfferValidate.php @@ -52,7 +52,7 @@ class PurchaseProductOfferValidate extends BaseValidate */ public function sceneAdd() { - return $this->only(['supplier_id','product_id','price','nums','is_buyer','need_num']); + return $this->only(['product_id','is_buyer','need_num']); } diff --git a/app/api/controller/order/OrderController.php b/app/api/controller/order/OrderController.php index 9b0e7b86c..c5ef5d356 100644 --- a/app/api/controller/order/OrderController.php +++ b/app/api/controller/order/OrderController.php @@ -462,9 +462,9 @@ class OrderController extends BaseApiController $params = (new OrderValidate())->post()->goCheck('add'); $uid = $this->userId; //拆单逻辑 - $res = OrderLogic::dealRefund($uid, $params); - $detail = StoreOrder::where('id', $params['id'])->where('refund_status', 1)->find(); - if ($detail && $res != 2) { + // $res = OrderLogic::dealRefund($uid, $params); + $detail = StoreOrder::where('id', $params['id'])->where('uid',$uid)->where('status','<>',2)->where('paid',1)->find(); + if ($detail) { $res = StoreOrderLogic::refund($detail, ['order_id' => $detail['order_id']]); if ($res != false) { return $this->success($res); From 4387eef6f186a1f55353fc70fe0cbdd86ffbd7a9 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Mon, 7 Oct 2024 13:30:14 +0800 Subject: [PATCH 32/32] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=95=86=E5=93=81?= =?UTF-8?q?=E5=85=A5=E5=BA=93=E5=92=8C=E9=87=87=E8=B4=AD=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修改了商品入库逻辑,支持未在门店的商品直接入库 - 优化了采购报价单操作,包括添加、编辑和查询相关功能 - 调整了仓库商品出库逻辑,支持财务相关操作 - 修复了一些与商品库存相关的逻辑问题 --- .../PurchaseProductOfferController.php | 6 +- .../SystemStoreStorageController.php | 23 +++- .../beforehand_order/BeforehandOrderLists.php | 12 +- .../BeforehandOrderThreeLists.php | 6 + .../BeforehandOrderTwoLists.php | 6 + .../BeforehandOrderCartInfoLists.php | 9 ++ .../beforehand_order/BeforehandOrderLogic.php | 92 +++++++------- .../PurchaseProductOfferLogic.php | 17 ++- .../WarehouseProductLogic.php | 118 +++++++++++++----- .../SystemStoreStorageController.php | 38 ++++-- 10 files changed, 219 insertions(+), 108 deletions(-) diff --git a/app/admin/controller/purchase_product_offer/PurchaseProductOfferController.php b/app/admin/controller/purchase_product_offer/PurchaseProductOfferController.php index f35f8665e..f1c5eb635 100644 --- a/app/admin/controller/purchase_product_offer/PurchaseProductOfferController.php +++ b/app/admin/controller/purchase_product_offer/PurchaseProductOfferController.php @@ -40,10 +40,8 @@ class PurchaseProductOfferController extends BaseAdminController { $params = (new PurchaseProductOfferValidate())->post()->goCheck('add'); $result = PurchaseProductOfferLogic::add($params); - if (true === $result) { - return $this->success('添加成功', [], 1, 1); - } - return $this->fail(PurchaseProductOfferLogic::getError()); + return $this->success('设置成功', [], 1, 1); + } diff --git a/app/admin/controller/system_store_storage/SystemStoreStorageController.php b/app/admin/controller/system_store_storage/SystemStoreStorageController.php index 475cd5f86..e33c3ebb2 100644 --- a/app/admin/controller/system_store_storage/SystemStoreStorageController.php +++ b/app/admin/controller/system_store_storage/SystemStoreStorageController.php @@ -5,9 +5,11 @@ namespace app\admin\controller\system_store_storage; use app\admin\controller\BaseAdminController; use app\admin\lists\system_store_storage\SystemStoreStorageLists; +use app\admin\logic\store_product\StoreProductLogic; use app\admin\logic\system_store_storage\SystemStoreStorageLogic; use app\admin\validate\system_store_storage\SystemStoreStorageValidate; use app\common\model\store_branch_product\StoreBranchProduct; +use app\common\model\store_product\StoreProduct; use app\common\model\system_store_storage\SystemStoreStorage; /** @@ -56,7 +58,7 @@ class SystemStoreStorageController extends BaseAdminController */ public function edit() { - return $this->fail('暂不支持入库操作'); + // return $this->fail('暂不支持入库操作'); // $params = (new SystemStoreStorageValidate())->post()->goCheck('edit'); // $params['admin_id']=$this->adminId; @@ -69,10 +71,21 @@ class SystemStoreStorageController extends BaseAdminController if($id==0){ return $this->fail('参数错误'); } - $res=SystemStoreStorage::where(['id' => $id])->update(['status'=>1,'staff_id'=>$this->adminId,'mark'=>'入库时间:'.date('Y-m-d H:i:s',time())]); - if($res){ - $find=SystemStoreStorage::where(['id' => $id])->find(); - StoreBranchProduct::where(['product_id'=>$find['product_id'],'store_id'=>$find['store_id']])->inc('stock',$find['nums'])->update(); + $find=SystemStoreStorage::where(['id' => $id])->find(); + + if($find){ + $find->save(['status'=>1,'staff_id'=>$this->adminId,'mark'=>'入库时间:'.date('Y-m-d H:i:s',time())]); + $branch_product=StoreBranchProduct::where(['product_id'=>$find['product_id'],'store_id'=>$find['store_id']])->find(); + if($branch_product){ + $branch_product->save(['stock'=>$branch_product['stock']+$find['nums']]); + }else{ + $storeProduct = StoreProduct::where('id', $find['product_id'])->findOrEmpty(); + $storeBranchProduct = StoreProductLogic::ordinary(['id' => $find['product_id']], $find['store_id'], $this->adminId, $storeProduct); + $storeBranchProduct->stock = $find['nums']; + $storeBranchProduct->save(); + } + + return $this->success('操作成功',[]); } return $this->fail('操作失败'); diff --git a/app/admin/lists/beforehand_order/BeforehandOrderLists.php b/app/admin/lists/beforehand_order/BeforehandOrderLists.php index 979124c4f..0026a05de 100644 --- a/app/admin/lists/beforehand_order/BeforehandOrderLists.php +++ b/app/admin/lists/beforehand_order/BeforehandOrderLists.php @@ -6,7 +6,7 @@ namespace app\admin\lists\beforehand_order; use app\admin\lists\BaseAdminDataLists; use app\common\model\beforehand_order\BeforehandOrder; use app\common\lists\ListsSearchInterface; - +use app\common\model\auth\Admin; /** * 预订单表列表 @@ -43,10 +43,16 @@ class BeforehandOrderLists extends BaseAdminDataLists implements ListsSearchInte public function lists(): array { return BeforehandOrder::where($this->searchWhere) - ->field(['id','order_id', 'uid','total_num', 'total_price', 'pay_price', 'deduction_price','create_time', 'status', 'mark']) + ->field(['id','order_id', 'uid','total_num','total_price','admin_id', 'pay_price', 'deduction_price','create_time', 'status', 'mark']) ->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) - ->select() + ->select()->each(function ($item){ + if($item->admin_id){ + $item->admin_name=Admin::where(['id'=>$item->admin_id])->value('name'); + }else{ + $item->admin_name=''; + } + }) ->toArray(); } diff --git a/app/admin/lists/beforehand_order/BeforehandOrderThreeLists.php b/app/admin/lists/beforehand_order/BeforehandOrderThreeLists.php index be66e40ec..38ff72fc0 100644 --- a/app/admin/lists/beforehand_order/BeforehandOrderThreeLists.php +++ b/app/admin/lists/beforehand_order/BeforehandOrderThreeLists.php @@ -8,6 +8,7 @@ use app\common\model\beforehand_order\BeforehandOrder; use app\common\lists\ListsSearchInterface; use app\common\model\store_product\StoreProduct; use app\common\model\store_product_unit\StoreProductUnit; +use app\common\model\supplier\Supplier; use app\common\model\warehouse_product\WarehouseProduct; /** @@ -59,6 +60,11 @@ class BeforehandOrderThreeLists extends BaseAdminDataLists implements ListsSearc }else{ $item['unit_name']=StoreProductUnit::where('id',$item['unit'])->value('name'); } + if($item['supplier_id']){ + $item['supplier_name']=Supplier::where('id',$item['supplier_id'])->value('mer_name'); + }else{ + $item['supplier_name']=''; + } return $item; }) ->toArray(); diff --git a/app/admin/lists/beforehand_order/BeforehandOrderTwoLists.php b/app/admin/lists/beforehand_order/BeforehandOrderTwoLists.php index cb5f87803..539019f23 100644 --- a/app/admin/lists/beforehand_order/BeforehandOrderTwoLists.php +++ b/app/admin/lists/beforehand_order/BeforehandOrderTwoLists.php @@ -8,6 +8,7 @@ use app\common\model\beforehand_order\BeforehandOrder; use app\common\lists\ListsSearchInterface; use app\common\model\store_product\StoreProduct; use app\common\model\store_product_unit\StoreProductUnit; +use app\common\model\supplier\Supplier; use app\common\model\warehouse_product\WarehouseProduct; /** @@ -59,6 +60,11 @@ class BeforehandOrderTwoLists extends BaseAdminDataLists implements ListsSearchI }else{ $item['unit_name']=StoreProductUnit::where('id',$item['unit'])->value('name'); } + if($item['supplier_id']){ + $item['supplier_name']=Supplier::where('id',$item['supplier_id'])->value('mer_name'); + }else{ + $item['supplier_name']=''; + } return $item; }) ->toArray(); diff --git a/app/admin/lists/beforehand_order_cart_info/BeforehandOrderCartInfoLists.php b/app/admin/lists/beforehand_order_cart_info/BeforehandOrderCartInfoLists.php index b6c7f5e2e..be622775b 100644 --- a/app/admin/lists/beforehand_order_cart_info/BeforehandOrderCartInfoLists.php +++ b/app/admin/lists/beforehand_order_cart_info/BeforehandOrderCartInfoLists.php @@ -6,6 +6,7 @@ namespace app\admin\lists\beforehand_order_cart_info; use app\admin\lists\BaseAdminDataLists; use app\common\model\beforehand_order_cart_info\BeforehandOrderCartInfo; use app\common\lists\ListsSearchInterface; +use app\common\model\purchase_product_offer\PurchaseProductOffer; use app\common\model\store_product\StoreProduct; use app\common\model\warehouse_product_storege\WarehouseProductStorege; @@ -53,6 +54,14 @@ class BeforehandOrderCartInfoLists extends BaseAdminDataLists implements ListsSe $item['store_name']=$find['store_name']; $item['image']=$find['image']; $item['unit']=$find['unit']; + if($item->bhoid){ + $status=PurchaseProductOffer::where('order_id',$item->bhoid)->where('product_id',$item->product_id)->value('status'); + if($status==1){ + $item->status_name='已完成'; + }else{ + $item->status_name='采购中'; + } + } return $item; }) ->toArray(); diff --git a/app/admin/logic/beforehand_order/BeforehandOrderLogic.php b/app/admin/logic/beforehand_order/BeforehandOrderLogic.php index 503d91528..2d56ed909 100644 --- a/app/admin/logic/beforehand_order/BeforehandOrderLogic.php +++ b/app/admin/logic/beforehand_order/BeforehandOrderLogic.php @@ -35,9 +35,9 @@ class BeforehandOrderLogic extends BaseLogic Db::startTrans(); try { $datas = []; - $total_num=0; - $total_price=0; - $uid=$params['uid'] ?? 0; + $total_num = 0; + $total_price = 0; + $uid = $params['uid'] ?? 0; foreach ($params['product_arr'] as $k => $v) { $datas[$k]['product_id'] = $v['product_id']; $datas[$k]['uid'] = $uid; @@ -45,13 +45,13 @@ class BeforehandOrderLogic extends BaseLogic $datas[$k]['price'] = $v['purchase']; $datas[$k]['total_price'] = $v['total_price']; $datas[$k]['create_time'] = time(); - $datas[$k]['update_time'] =time(); + $datas[$k]['update_time'] = time(); $total_num += $v['nums']; $total_price += $v['total_price']; } $order = BeforehandOrder::create([ 'order_id' => getNewOrderId('YG'), - 'admin_id' => $params['admin_id']??0, + 'admin_id' => $params['admin_id'] ?? 0, 'uid' => $uid, 'total_num' => $total_num, 'total_price' => $total_price, @@ -59,7 +59,7 @@ class BeforehandOrderLogic extends BaseLogic 'pay_type' => 0, 'deduction_price' => 0, 'paid' => 0, - 'mark' => $params['mark']??'' + 'mark' => $params['mark'] ?? '' ]); foreach ($datas as $k => $v) { $datas[$k]['bhoid'] = $order['id']; @@ -119,58 +119,54 @@ class BeforehandOrderLogic extends BaseLogic */ public static function createOutboundOrder(array $params): bool { - $warehouse_id= $params['warehouse_id']; - $store_id= $params['store_id']; - $admin_id= $params['admin_id']; - $delivery_time= $params['delivery_time']; - $mark= $params['remark']??''; - $order=BeforehandOrder::where('id', $params['bhoid'])->find(); - if(!$order){ + $warehouse_id = $params['warehouse_id']; + $store_id = $params['store_id']; + $admin_id = $params['admin_id']; + $delivery_time = $params['delivery_time']; + $mark = $params['remark'] ?? ''; + $order = BeforehandOrder::where('id', $params['bhoid'])->find(); + if (!$order) { throw new BusinessException('该订单不存在'); } - if($order['outbound_id']>0){ + if ($order['outbound_id'] > 0) { throw new BusinessException('该订单已创建出库单'); } - $info=BeforehandOrderCartInfo::where('bhoid', $params['bhoid'])->select(); + $info = BeforehandOrderCartInfo::where('bhoid', $params['bhoid'])->select(); Db::startTrans(); try { - $arr = [ - 'oid' => 0, + $arr = [ + 'oid' => 0, + 'warehouse_id' => $warehouse_id, + 'store_id' => $store_id, + 'supplier_id' => 0, + 'code' => getNewOrderId('CK'), + 'admin_id' => $admin_id, + 'financial_pm' => 0, + 'batch' => 0, + 'mark' => $mark, + ]; + $arr['delivery_time'] = strtotime($delivery_time); + $res = WarehouseOrder::create($arr); + foreach ($info as $key => $arr) { + $data = [ 'warehouse_id' => $warehouse_id, + 'product_id' => $arr['product_id'], 'store_id' => $store_id, - 'supplier_id' => 0, - 'code' => getNewOrderId('CK'), - 'admin_id' => $admin_id, 'financial_pm' => 0, - 'batch' => 0, - 'mark' => $mark, + 'batch' => 1, + 'nums' => $arr['cart_num'], + 'status' => 1, + 'admin_id' => $admin_id, + 'total_price' => $arr['total_price'], + 'purchase' => $arr['price'], + 'oid' => $res['id'], + 'code' => $res['code'], ]; - $arr['delivery_time'] = strtotime($delivery_time); - $res = WarehouseOrder::create($arr); - foreach ($info as $key => $arr) { - $data = [ - 'warehouse_id' => $warehouse_id, - 'product_id' => $arr['product_id'], - 'store_id' => $store_id, - 'financial_pm' => 0, - 'batch' => 1, - 'nums' => $arr['cart_num'], - 'status' => 1, - 'admin_id' => $admin_id, - ]; - $storeProduct = StoreProduct::where('id', $arr['product_id'])->findOrEmpty()->toArray(); - if ($arr['cart_num'] == 0) { - StoreProductLogic::ordinary($arr, $store_id, $admin_id, $storeProduct); - } else { - $data['total_price'] =$arr['total_price']; - $data['purchase'] = $storeProduct['purchase']; - $data['oid'] = $res['id']; - WarehouseProductLogic::add($data); - $finds = WarehouseProduct::where('oid', $res['id'])->field('sum(nums) as nums,sum(total_price) as total_price')->find(); - WarehouseOrder::where('id', $res['id'])->update(['total_price' => $finds['total_price'], 'nums' => $finds['nums']]); - } - } - BeforehandOrder::update(['outbound_id'=>$res['id']],['id'=>$params['bhoid']]); + WarehouseProductLogic::setOutbound($data); + } + $finds = WarehouseProduct::where('oid', $res['id'])->field('sum(nums) as nums,sum(total_price) as total_price')->find(); + WarehouseOrder::where('id', $res['id'])->update(['total_price' => $finds['total_price'], 'nums' => $finds['nums']]); + BeforehandOrder::update(['outbound_id' => $res['id']], ['id' => $params['bhoid']]); Db::commit(); return true; } catch (\Throwable $e) { diff --git a/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php b/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php index bb341c594..54822b384 100644 --- a/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php +++ b/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php @@ -5,6 +5,7 @@ namespace app\admin\logic\purchase_product_offer; use app\common\model\purchase_product_offer\PurchaseProductOffer; use app\common\logic\BaseLogic; +use app\common\model\beforehand_order_cart_info\BeforehandOrderCartInfo; use support\exception\BusinessException; use think\facade\Db; @@ -40,7 +41,7 @@ class PurchaseProductOfferLogic extends BaseLogic 'status' => 0, ]); - + BeforehandOrderCartInfo::where(['bhoid'=>$params['order_id'],'product_id'=>$params['product_id']])->update(['is_buyer'=>1]); Db::commit(); return true; } catch (\Exception $e) { @@ -99,12 +100,20 @@ class PurchaseProductOfferLogic extends BaseLogic { Db::startTrans(); try { - PurchaseProductOffer::update([ + $offer=PurchaseProductOffer::where(['id'=>$params['id']])->find(); + $offer->save([ 'buyer_nums' => $params['buyer_nums'], 'supplier_id' => $params['supplier_id'], - 'price' => $params['price'], + 'price' => $params['purchase'], 'total_price' => $params['total_price'], - ],['id'=>$params['id']]); + ]); + $find=BeforehandOrderCartInfo::where(['bhoid'=>$params['bhoid'],'product_id'=>$offer['product_id']])->find(); + if($find){ + $find->purchase=$params['purchase']; + $find->total_price=bcmul($find['cart_num'],$params['price'],2); + $find->price=$params['price']; + $find->save(); + } Db::commit(); return true; } catch (\Throwable $e) { diff --git a/app/admin/logic/warehouse_product/WarehouseProductLogic.php b/app/admin/logic/warehouse_product/WarehouseProductLogic.php index 336528981..69b21bbb1 100644 --- a/app/admin/logic/warehouse_product/WarehouseProductLogic.php +++ b/app/admin/logic/warehouse_product/WarehouseProductLogic.php @@ -52,7 +52,7 @@ class WarehouseProductLogic extends BaseLogic // if ($after_nums < 0) { // throw new BusinessException('库存不足,warehouse_id:'.$params['warehouse_id'].'product_id:'.$params['product_id']); // } - WarehouseProductStorege::update(['nums'=>$after_nums, 'total_price' => $total_price],['id'=> $storege['id']]); + WarehouseProductStorege::update(['nums' => $after_nums, 'total_price' => $total_price], ['id' => $storege['id']]); //门店加库存 $storeBranchProduct = StoreBranchProduct::where('product_id', $params['product_id'])->where('store_id', $params['store_id'])->find(); @@ -74,7 +74,7 @@ class WarehouseProductLogic extends BaseLogic throw new BusinessException('商品不存在'); } $total_price = bcmul($after_nums, $storeProduct['purchase'], 2); - WarehouseProductStorege::update(['nums' => $after_nums, 'total_price' => $total_price],['id'=>$storege['id']]); + WarehouseProductStorege::update(['nums' => $after_nums, 'total_price' => $total_price], ['id' => $storege['id']]); } } $before_nums = $storege['nums']; @@ -85,16 +85,16 @@ class WarehouseProductLogic extends BaseLogic throw new BusinessException('商品不存在'); } $total_price = bcmul($after_nums, $storeProduct['purchase'], 2); - $data=[ + $data = [ 'warehouse_id' => $params['warehouse_id'], 'product_id' => $params['product_id'], 'nums' => $params['nums'], - 'total_price'=>$total_price + 'total_price' => $total_price ]; - if($params['financial_pm']==0){ - $data['nums']=-$params['nums']; + if ($params['financial_pm'] == 0) { + $data['nums'] = -$params['nums']; } - $storege=WarehouseProductStorege::create($data); + $storege = WarehouseProductStorege::create($data); } $batch_count = WarehouseProduct::where(['product_id' => $params['product_id'], 'warehouse_id' => $params['warehouse_id'], 'financial_pm' => $params['financial_pm'], 'store_id' => $params['store_id']])->count(); $data = [ @@ -141,6 +141,59 @@ class WarehouseProductLogic extends BaseLogic } } + /** + * 设置出库商品 + */ + public static function setOutbound(array $params, $type = 1) + { + Db::startTrans(); + try { + $after_nums = 0; + $storege = WarehouseProductStorege::where('warehouse_id', $params['warehouse_id'])->where('product_id', $params['product_id'])->find(); + if ($storege) { + SystemStoreStorage::create([ + 'store_id' => $params['store_id'], + 'admin_id' => $params['admin_id'], + 'staff_id' => 0, + 'type' => 1, + 'product_id' => $params['product_id'], + 'nums' => $params['nums'], + 'status' =>0 + ]); + $after_nums = bcsub($storege['nums'], $params['nums']); + $total_price = bcmul($after_nums, $params['purchase'], 2); + WarehouseProductStorege::update(['nums' =>bcsub($storege['nums'], $params['nums']), 'total_price' => $total_price], ['id' => $storege['id']]); + } else { + throw new BusinessException('仓库商品不存在'); + } + + $batch_count = WarehouseProduct::where(['product_id' => $params['product_id'], 'warehouse_id' => $params['warehouse_id'], 'financial_pm' => $params['financial_pm'], 'store_id' => $params['store_id']])->count(); + $data = [ + 'warehouse_id' => $params['warehouse_id'], + 'supplier_id' => $params['supplier_id'] ?? 0, + 'oid' => $params['oid'] ?? 0, + 'store_id' => $params['store_id'] ?? 0, + 'product_id' => $params['product_id'], + 'financial_pm' => $params['financial_pm'], + 'batch' => $batch_count + 1, + 'nums' => $params['nums'], + 'before_nums' => $storege['nums'], + 'after_nums' => $after_nums, + 'purchase' => $params['purchase'] ?? '', + 'total_price' => $params['total_price'] ?? '', + 'admin_id' => $params['admin_id'], + 'code' => $params['code'] ?? '', + 'status' => 1, + 'mark' => $params['mark'] ?? '', + ]; + $res = WarehouseProduct::create($data); + Db::commit(); + return $res; + } catch (\Throwable $e) { + Db::rollback(); + throw new BusinessException($e->getMessage()); + } + } /** * @notes 编辑商品仓储信息 @@ -156,28 +209,28 @@ class WarehouseProductLogic extends BaseLogic try { $before_nums = 0; $after_nums = 0; - $find=WarehouseOrder::where('id',$params['oid'])->find(); - if($find){ + $find = WarehouseOrder::where('id', $params['oid'])->find(); + if ($find) { $res = WarehouseProduct::where('id', $params['id'])->find(); - if($find['financial_pm']==1){ - WarehouseProductStorege::where('warehouse_id',$res['warehouse_id'])->where('product_id',$res['product_id'])->dec('nums',$res['nums'])->update(); - StoreBranchProduct::where('store_id',$res['store_id'])->where('product_id',$res['product_id'])->dec('stock',$res['nums'])->update(); - - $warehouseProductStorege=WarehouseProductStorege::where('warehouse_id',$res['warehouse_id'])->where('product_id',$res['product_id'])->find(); - WarehouseProductStorege::where('warehouse_id',$res['warehouse_id'])->where('product_id',$res['product_id'])->inc('nums',$params['nums'])->update(); - StoreBranchProduct::where('store_id',$res['store_id'])->where('product_id',$res['product_id'])->inc('stock',$params['nums'])->update(); - $before_nums=$warehouseProductStorege['nums']; - $after_nums=$warehouseProductStorege['nums']+$params['nums']; - }else{ - WarehouseProductStorege::where('warehouse_id',$res['warehouse_id'])->where('product_id',$res['product_id'])->inc('nums',$res['nums'])->update(); - StoreBranchProduct::where('store_id',$res['store_id'])->where('product_id',$res['product_id'])->dec('stock',$res['nums'])->update(); - - $warehouseProductStorege=WarehouseProductStorege::where('warehouse_id',$res['warehouse_id'])->where('product_id',$res['product_id'])->find(); - WarehouseProductStorege::where('warehouse_id',$res['warehouse_id'])->where('product_id',$res['product_id'])->dec('nums',$params['nums'])->update(); - StoreBranchProduct::where('store_id',$res['store_id'])->where('product_id',$res['product_id'])->inc('stock',$params['nums'])->update(); - $before_nums=$warehouseProductStorege['nums']; - $after_nums=bcsub($warehouseProductStorege['nums'],$params['nums'],2); + if ($find['financial_pm'] == 1) { + WarehouseProductStorege::where('warehouse_id', $res['warehouse_id'])->where('product_id', $res['product_id'])->dec('nums', $res['nums'])->update(); + StoreBranchProduct::where('store_id', $res['store_id'])->where('product_id', $res['product_id'])->dec('stock', $res['nums'])->update(); + + $warehouseProductStorege = WarehouseProductStorege::where('warehouse_id', $res['warehouse_id'])->where('product_id', $res['product_id'])->find(); + WarehouseProductStorege::where('warehouse_id', $res['warehouse_id'])->where('product_id', $res['product_id'])->inc('nums', $params['nums'])->update(); + StoreBranchProduct::where('store_id', $res['store_id'])->where('product_id', $res['product_id'])->inc('stock', $params['nums'])->update(); + $before_nums = $warehouseProductStorege['nums']; + $after_nums = $warehouseProductStorege['nums'] + $params['nums']; + } else { + WarehouseProductStorege::where('warehouse_id', $res['warehouse_id'])->where('product_id', $res['product_id'])->inc('nums', $res['nums'])->update(); + StoreBranchProduct::where('store_id', $res['store_id'])->where('product_id', $res['product_id'])->dec('stock', $res['nums'])->update(); + + $warehouseProductStorege = WarehouseProductStorege::where('warehouse_id', $res['warehouse_id'])->where('product_id', $res['product_id'])->find(); + WarehouseProductStorege::where('warehouse_id', $res['warehouse_id'])->where('product_id', $res['product_id'])->dec('nums', $params['nums'])->update(); + StoreBranchProduct::where('store_id', $res['store_id'])->where('product_id', $res['product_id'])->inc('stock', $params['nums'])->update(); + $before_nums = $warehouseProductStorege['nums']; + $after_nums = bcsub($warehouseProductStorege['nums'], $params['nums'], 2); } WarehouseProduct::where('id', $params['id'])->update([ 'nums' => $params['nums'], @@ -241,14 +294,15 @@ class WarehouseProductLogic extends BaseLogic * @param $id * @return void */ - public static function settlement($id){ + public static function settlement($id) + { Db::startTrans(); try { - $find=WarehouseProduct::where(['id'=>$id,'financial_pm'=>1,'is_pay'=>0])->find(); - if($find){ - $find->is_pay=1; + $find = WarehouseProduct::where(['id' => $id, 'financial_pm' => 1, 'is_pay' => 0])->find(); + if ($find) { + $find->is_pay = 1; $find->save(); - } else{ + } else { throw new BusinessException('没有查到出入库信息'); } Db::commit(); diff --git a/app/api/controller/system_store_storage/SystemStoreStorageController.php b/app/api/controller/system_store_storage/SystemStoreStorageController.php index a9eb68379..37a98012e 100644 --- a/app/api/controller/system_store_storage/SystemStoreStorageController.php +++ b/app/api/controller/system_store_storage/SystemStoreStorageController.php @@ -2,11 +2,12 @@ namespace app\api\controller\system_store_storage; - +use app\admin\logic\store_product\StoreProductLogic; use app\api\controller\BaseApiController; use app\api\lists\system_store_storage\SystemStoreStorageLists; use app\api\lists\system_store_storage\SystemStoreStorageGroupLists; use app\common\model\store_branch_product\StoreBranchProduct; +use app\common\model\store_product\StoreProduct; use app\common\model\system_store\SystemStoreStaff; use app\common\model\system_store_storage\SystemStoreStorage; @@ -25,11 +26,11 @@ class SystemStoreStorageController extends BaseApiController */ public function lists() { - $store_id=SystemStoreStaff::where('uid',$this->userId)->value('store_id'); - if(!$store_id){ + $store_id = SystemStoreStaff::where('uid', $this->userId)->value('store_id'); + if (!$store_id) { return $this->fail('请先绑定店铺'); } - $this->request->__set('store_id',$store_id); + $this->request->__set('store_id', $store_id); return $this->dataLists(new SystemStoreStorageLists()); } /** @@ -40,24 +41,37 @@ class SystemStoreStorageController extends BaseApiController */ public function group_lists() { - $store_id=SystemStoreStaff::where('uid',$this->userId)->value('store_id'); - if(!$store_id){ + $store_id = SystemStoreStaff::where('uid', $this->userId)->value('store_id'); + if (!$store_id) { return $this->fail('请先绑定店铺'); } - $this->request->__set('store_id',$store_id); + $this->request->__set('store_id', $store_id); return $this->dataLists(new SystemStoreStorageGroupLists()); } /** * @notes 门店入库 */ - public function warehousing_add() { + public function warehousing_add() + { $params = $this->request->post(); - $find=SystemStoreStorage::where('id',$params['id'])->find(); - if($find){ - $find->status=1; + $find = SystemStoreStorage::where('id', $params['id'])->find(); + if ($find) { + $id = SystemStoreStaff::where('uid', $this->userId)->value('id'); + $find->staff_id = $id; + $find->mark = '入库时间:' . date('Y-m-d H:i:s'); + $find->status = 1; $find->save(); - StoreBranchProduct::where(['product_id'=>$find['product_id'],'store_id'=>$find['store_id']])->inc('stock',$find['nums'])->update(); + + $branch_product=StoreBranchProduct::where(['product_id'=>$find['product_id'],'store_id'=>$find['store_id']])->find(); + if($branch_product){ + $branch_product->save(['stock'=>$branch_product['stock']+$find['nums']]); + }else{ + $storeProduct = StoreProduct::where('id', $find['product_id'])->findOrEmpty(); + $storeBranchProduct = StoreProductLogic::ordinary(['id' => $find['product_id']], $find['store_id'], 0, $storeProduct); + $storeBranchProduct->stock = $find['nums']; + $storeBranchProduct->save(); + } return $this->success('操作成功'); } return $this->fail('操作失败');