From d83d80e0c0aade1a163f31fce112fe2e0c04ff92 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Mon, 26 Aug 2024 13:25:21 +0800 Subject: [PATCH 1/3] =?UTF-8?q?feat:=20=E6=9B=B4=E6=96=B0=E5=BA=93?= =?UTF-8?q?=E5=AD=98=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 --- .../logic/store_branch_product/StoreBranchProductLogic.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/admin/logic/store_branch_product/StoreBranchProductLogic.php b/app/admin/logic/store_branch_product/StoreBranchProductLogic.php index d96e71286..47fb6eda8 100644 --- a/app/admin/logic/store_branch_product/StoreBranchProductLogic.php +++ b/app/admin/logic/store_branch_product/StoreBranchProductLogic.php @@ -90,12 +90,12 @@ class StoreBranchProductLogic extends BaseLogic $stock = bcadd($find['stock'], $params['nums'], 2); $branchStock = bcadd($storeBranchProduct['stock'], $params['nums'], 2); - StoreBranchProduct::where('id', $params['id'])->update(['stock' => $stock, 'total_price' => bcmul($branchStock, $find['purchase'], 2)]); + StoreBranchProduct::where('id', $params['id'])->update(['stock' => $branchStock, 'total_price' => bcmul($branchStock, $find['purchase'], 2)]); StoreProduct::where('id', $params['product_id'])->update(['stock' => $stock, 'total_price' => bcmul($stock, $find['purchase'], 2)]); } else { $branchStock = bcsub($storeBranchProduct['stock'], $params['nums'], 2); $stock = bcsub($find['stock'], $params['nums'], 2); - StoreBranchProduct::where('id', $params['id'])->update(['stock' => $stock, 'total_price' => bcmul($branchStock, $find['purchase'], 2)]); + StoreBranchProduct::where('id', $params['id'])->update(['stock' => $branchStock, 'total_price' => bcmul($branchStock, $find['purchase'], 2)]); StoreProduct::where('id', $params['product_id'])->update(['stock' => $stock, 'total_price' => bcmul($stock, $find['purchase'], 2)]); } Db::commit(); From edf4c743088bdd16500b3728335854be9c318b32 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Mon, 26 Aug 2024 14:15:30 +0800 Subject: [PATCH 2/3] =?UTF-8?q?feat(warehouse=5Forder):=20=E6=A0=B9?= =?UTF-8?q?=E6=8D=AE=E4=B8=8D=E5=90=8C=E7=B1=BB=E5=9E=8B=E8=AE=A1=E7=AE=97?= =?UTF-8?q?=E6=80=BB=E4=BB=B7=20feat(supplier):=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E6=90=9C=E7=B4=A2=E6=9D=A1=E4=BB=B6=20feat(cart):=20=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E6=96=B0=E9=80=BB=E8=BE=91=E5=88=A4=E6=96=AD=E5=92=8C?= =?UTF-8?q?=E5=8D=95=E5=85=83=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../WarehouseOrderController.php | 8 ++++ app/admin/lists/supplier/SupplierLists.php | 3 +- app/store/controller/cart/CartController.php | 40 +++++++++++-------- 3 files changed, 33 insertions(+), 18 deletions(-) diff --git a/app/admin/controller/warehouse_order/WarehouseOrderController.php b/app/admin/controller/warehouse_order/WarehouseOrderController.php index 053a82baa..5c2876fb4 100644 --- a/app/admin/controller/warehouse_order/WarehouseOrderController.php +++ b/app/admin/controller/warehouse_order/WarehouseOrderController.php @@ -237,6 +237,14 @@ class WarehouseOrderController extends BaseAdminController $value->store_name = $find['store_name'] ?? ''; $value->store_info = $find['store_info'] ?? ''; if($type==2){ + $value->price = $find['purchase']; + $value->total_price=bcmul($find['purchase'],$value['nums'],2); + $total_price+=$value->total_price; + }elseif($type==3){ + $value->price = $find['cost']; + $value->total_price=bcmul($find['cost'],$value['nums'],2); + $total_price+=$value->total_price; + }elseif($type==4){ $value->price = $find['price']; $value->total_price=bcmul($find['price'],$value['nums'],2); $total_price+=$value->total_price; diff --git a/app/admin/lists/supplier/SupplierLists.php b/app/admin/lists/supplier/SupplierLists.php index ad24c85e3..a9321cc6b 100644 --- a/app/admin/lists/supplier/SupplierLists.php +++ b/app/admin/lists/supplier/SupplierLists.php @@ -26,7 +26,8 @@ class SupplierLists extends BaseAdminDataLists implements ListsSearchInterface public function setSearch(): array { return [ - '=' => ['mer_name', 'phone'], + '=' => ['phone'], + '%like%'=>['mer_name'] ]; } diff --git a/app/store/controller/cart/CartController.php b/app/store/controller/cart/CartController.php index 97666dd81..3f4641e2f 100644 --- a/app/store/controller/cart/CartController.php +++ b/app/store/controller/cart/CartController.php @@ -7,6 +7,7 @@ use app\api\validate\CartValidate; use app\common\model\store_branch_product\StoreBranchProduct; use app\store\lists\cart\CartList; use app\common\model\order\Cart; +use app\common\model\store_product_unit\StoreProductUnit; use app\store\controller\BaseAdminController; @@ -24,31 +25,38 @@ class CartController extends BaseAdminController { $params = (new CartValidate())->post()->goCheck('StoreAdd'); $adminInfo = $this->adminInfo; - $params['uid'] = $this->request->post('uid')??0; + $params['uid'] = $this->request->post('uid') ?? 0; $params['staff_id'] = $adminInfo['admin_id']; $params['store_id'] = $adminInfo['store_id']; - $result = Cart::where(['uid' => 0,'staff_id'=>$adminInfo['admin_id'], 'store_id' => $adminInfo['store_id'], 'product_id' => $params['product_id'], 'is_fail' => 0, 'is_pay' => 0])->find(); + $result = Cart::where(['uid' => 0, 'staff_id' => $adminInfo['admin_id'], 'store_id' => $adminInfo['store_id'], 'product_id' => $params['product_id'], 'is_fail' => 0, 'is_pay' => 0])->find(); //判断起批发价 - $batch = StoreBranchProduct::where( - ['product_id'=>$params['product_id'], - 'store_id' => $adminInfo['store_id'] + $branchProduct = StoreBranchProduct::where( + [ + 'product_id' => $params['product_id'], + 'store_id' => $adminInfo['store_id'] ] - )->value('batch'); - if($params['cart_num'] < $batch){ - return $this->fail('起批发量低于最低值'.$batch); + )->find(); + if ($params['cart_num'] < $branchProduct['batch']) { + return $this->fail('起批发量低于最低值' . $branchProduct['batch']); } $count = Cart::where(['uid' => $params['uid'], 'is_pay' => 0])->count(); if ($count > 100) { return $this->fail('购物车商品不能大于100个,请先结算'); } + if ($params['cart_num'] < 1) { + $is_bulk = StoreProductUnit::where('id', $branchProduct['unit'])->value('is_bulk'); + if ($is_bulk == 0) { + return $this->fail('非计量商品,不能有小数'); + } + } //数量下单判断 -// $stock = StoreBranchProduct::where( -// ['product_id'=>$params['product_id'], -// 'store_id'=>$params['store_id'] -// ])->value('stock')??0; -// if ($params['cart_num'] >$stock) { -// return $this->fail('库存数量不足'); -// } + // $stock = StoreBranchProduct::where( + // ['product_id'=>$params['product_id'], + // 'store_id'=>$params['store_id'] + // ])->value('stock')??0; + // if ($params['cart_num'] >$stock) { + // return $this->fail('库存数量不足'); + // } if ($result) { $res = CartLogic::edit($params); } else { @@ -96,6 +104,4 @@ class CartController extends BaseAdminController return $this->fail(CartLogic::getError()); } } - - } From 727a091c5a0f66fa40ff9f52facb9ea209b4fa95 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Mon, 26 Aug 2024 17:20:56 +0800 Subject: [PATCH 3/3] =?UTF-8?q?feat:=20=E7=A7=BB=E9=99=A4=E8=B4=AD?= =?UTF-8?q?=E7=89=A9=E8=BD=A6=E5=92=8C=E8=AE=A2=E5=8D=95=E7=BB=9F=E8=AE=A1?= =?UTF-8?q?=E4=B8=AD=E7=9A=84withTrashed=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/lists/order/CartList.php | 1 - app/store/logic/WorkbenchLogic.php | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/app/api/lists/order/CartList.php b/app/api/lists/order/CartList.php index 36bad71ea..a16c31e08 100644 --- a/app/api/lists/order/CartList.php +++ b/app/api/lists/order/CartList.php @@ -74,7 +74,6 @@ class CartList extends BaseAdminDataLists implements ListsSearchInterface, Lists foreach ($list as $key => &$item) { $find = StoreBranchProduct::where(['product_id' => $item['product_id'], 'store_id' => $item['store_id']]) ->field($field) - ->withTrashed() ->find(); if ($find) { if ($off_activity == 1) { diff --git a/app/store/logic/WorkbenchLogic.php b/app/store/logic/WorkbenchLogic.php index 6988ba07d..10faeb625 100644 --- a/app/store/logic/WorkbenchLogic.php +++ b/app/store/logic/WorkbenchLogic.php @@ -372,8 +372,8 @@ class WorkbenchLogic extends BaseLogic $dateDiff = (new \DateTime($endTime))->diff(new \DateTime($startTime)); $data['visit_count'] = StoreVisit::where('store_id', $storeId)->whereBetweenTime('create_time', $startTime, $endTime)->count(); $data['visit_user_count'] = StoreVisit::where('store_id', $storeId)->whereBetweenTime('create_time', $startTime, $endTime)->group('uid')->count(); - $data['add_cart_count'] = Cart::where('store_id', $storeId)->whereBetweenTime('create_time', $startTime, $endTime)->withTrashed()->group('product_id')->count(); - $data['add_order_count'] = StoreOrderCartInfo::where('store_id', $storeId)->whereBetweenTime('create_time', $startTime, $endTime)->withTrashed()->group('product_id')->count(); + $data['add_cart_count'] = Cart::where('store_id', $storeId)->whereBetweenTime('create_time', $startTime, $endTime)->group('product_id')->count(); + $data['add_order_count'] = StoreOrderCartInfo::where('store_id', $storeId)->whereBetweenTime('create_time', $startTime, $endTime)->group('product_id')->count(); $data['pay_count'] = StoreOrder::alias('t1') ->join('store_order_cart_info t2', 't1.id = t2.oid') ->where('t1.store_id', $storeId)