From 84f39f0ac7d94a355b95e558229dde0beac6d138 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Wed, 28 Aug 2024 11:09:24 +0800 Subject: [PATCH 1/6] =?UTF-8?q?feat(CartController):=20=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E8=B4=AD=E7=89=A9=E8=BD=A6=E5=95=86=E5=93=81=E8=B5=B7=E6=89=B9?= =?UTF-8?q?=E5=8F=91=E9=87=8F=E5=88=A4=E6=96=AD=E5=92=8C=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/order/CartController.php | 17 ++++++++++++++--- app/api/lists/order/CartList.php | 5 +++-- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/app/api/controller/order/CartController.php b/app/api/controller/order/CartController.php index 03fea3e5b..90a35cd75 100644 --- a/app/api/controller/order/CartController.php +++ b/app/api/controller/order/CartController.php @@ -25,7 +25,7 @@ class CartController extends BaseApiController $params = (new CartValidate())->post()->goCheck('add'); $params['uid'] = $this->request->userId; $result = Cart::where(['uid' => $params['uid'], 'store_id' => $params['store_id'], 'product_id' => $params['product_id'], 'is_fail' => 0, 'is_pay' => 0, 'delete_time' => null])->find(); - + $params['cart_num']=bcadd($params['cart_num'],0,2); //判断起批发价 $branchProduct = StoreBranchProduct::where( [ @@ -36,7 +36,6 @@ class CartController extends BaseApiController if (!$branchProduct) { return $this->fail('商品不存在'); } - $params['cart_num']=intval($params['cart_num']); if ($params['cart_num'] < $branchProduct['batch']) { return $this->fail('起批发量低于最低值' . $branchProduct['batch']); } @@ -85,7 +84,19 @@ class CartController extends BaseApiController { $params = (new CartValidate())->post()->goCheck('change'); $params['uid'] = $this->request->userId; - $params['cart_num']=intval($params['cart_num']); + $params['cart_num']=bcadd($params['cart_num'],0,2); + if (convertNumber($params['cart_num']) === false) { + $branchProduct = StoreBranchProduct::where( + [ + 'product_id' => $params['product_id'], + 'store_id' => $params['store_id'] + ] + )->find(); + $is_bulk = StoreProductUnit::where('id', $branchProduct['unit'])->value('is_bulk'); + if ($is_bulk == 0) { + return $this->fail('非计量商品,不能有小数,请编辑购物车'); + } + } $res = CartLogic::edit($params, 'dec'); if ($res) { return $this->success('修改成功'); diff --git a/app/api/lists/order/CartList.php b/app/api/lists/order/CartList.php index a16c31e08..5b6c770c9 100644 --- a/app/api/lists/order/CartList.php +++ b/app/api/lists/order/CartList.php @@ -65,9 +65,9 @@ class CartList extends BaseAdminDataLists implements ListsSearchInterface, Lists ->toArray(); $off_activity = Config::where('name', 'off_activity')->value('value'); $user_ship = User::where('id', $userId)->value('user_ship'); - $field = 'product_id,image,price,cost,store_name,unit,delete_time,vip_price,top_cate_id'; + $field = 'product_id,image,price,cost,store_name,unit,delete_time,vip_price,top_cate_id,batch'; if (in_array($user_ship, [4, 6, 7])) { - $field = 'product_id,image,cost price,cost,store_name,unit,delete_time,vip_price,top_cate_id'; + $field = 'product_id,image,cost price,cost,store_name,unit,delete_time,vip_price,top_cate_id,batch'; } $this->user_ship = $user_ship; $this->off_activity = $off_activity; @@ -84,6 +84,7 @@ class CartList extends BaseAdminDataLists implements ListsSearchInterface, Lists } $item['goods_total_price'] = bcmul($item['cart_num'], $find['price'], 2); $this->total_price = bcadd($this->total_price, $item['goods_total_price'], 2); + $item['batch'] = $find['batch']; $item['imgs'] = $find['image']; $item['price'] = $find['price']; $item['cost'] = $find['cost']; From b2baeec62c088f9147bf53eb4d348d5ac99e30fd Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Wed, 28 Aug 2024 15:21:55 +0800 Subject: [PATCH 2/6] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9=E5=95=86?= =?UTF-8?q?=E5=93=81=E5=BA=93=E5=AD=98=E6=9B=B4=E6=96=B0=E9=80=BB=E8=BE=91?= =?UTF-8?q?=EF=BC=8C=E5=A2=9E=E5=8A=A0=E6=97=A5=E5=BF=97=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../StoreBranchProductLists.php | 1 + .../StoreBranchProductLogic.php | 23 +++++- .../WarehouseProductLogic.php | 22 +++++- app/api/controller/IndexController.php | 6 ++ app/api/controller/order/CartController.php | 12 ++- app/api/lists/cate/CateLists.php | 18 ++--- app/api/lists/order/CartList.php | 8 +- app/api/lists/order/OrderList.php | 3 - app/api/lists/product/ProductLists.php | 15 ++-- app/api/lists/product/StoreProductLists.php | 16 ++-- app/api/logic/order/OrderLogic.php | 12 ++- app/common/logic/CommissionProductLogic.php | 7 +- app/common/logic/PayNotifyLogic.php | 46 ++++++++--- .../StoreBranchProduct.php | 2 - .../model/store_product/StoreProduct.php | 4 +- .../WarehouseProductStorege.php | 10 ++- app/functions.php | 19 ++++- app/store/controller/cart/CartController.php | 18 ++++- app/store/lists/cart/CartList.php | 5 +- config/log.php | 76 ++++++++++++++++++- 20 files changed, 239 insertions(+), 84 deletions(-) diff --git a/app/admin/lists/store_branch_product/StoreBranchProductLists.php b/app/admin/lists/store_branch_product/StoreBranchProductLists.php index 7681a721d..6b2f16248 100644 --- a/app/admin/lists/store_branch_product/StoreBranchProductLists.php +++ b/app/admin/lists/store_branch_product/StoreBranchProductLists.php @@ -12,6 +12,7 @@ use app\common\lists\ListsSearchInterface; use app\common\model\store_branch_product\StoreBranchProduct; use app\common\lists\ListsExcelInterface; use app\common\lists\ListsSortInterface; +use app\common\model\store_product\StoreProduct; /** * 门店商品辅助表 diff --git a/app/admin/logic/store_branch_product/StoreBranchProductLogic.php b/app/admin/logic/store_branch_product/StoreBranchProductLogic.php index cf365b69b..0b19ba485 100644 --- a/app/admin/logic/store_branch_product/StoreBranchProductLogic.php +++ b/app/admin/logic/store_branch_product/StoreBranchProductLogic.php @@ -81,19 +81,38 @@ class StoreBranchProductLogic extends BaseLogic { Db::startTrans(); try { - $find = StoreProduct::where('id', $params['product_id'])->find(); - $storeBranchProduct = StoreBranchProduct::where('id', $params['id'])->find(); + $find = StoreProduct::where('id', $params['product_id'])->find()->toArray(); + $storeBranchProduct = StoreBranchProduct::where('id', $params['id'])->find()->toArray(); if ($type == 1) { $stock = bcadd($find['stock'], $params['nums'], 2); $branchStock = bcadd($storeBranchProduct['stock'], $params['nums'], 2); + onBeforeUpdate($storeBranchProduct,'branch_product'); StoreBranchProduct::where('id', $params['id'])->update(['stock' => $branchStock, 'total_price' => bcmul($branchStock, $find['purchase'], 2)]); + $storeBranchProduct['stock']=$branchStock; + $storeBranchProduct['total_price']=bcmul($branchStock, $find['purchase'], 2); + onAfterUpdate($storeBranchProduct,'branch_product'); + + onBeforeUpdate($find,'product'); StoreProduct::where('id', $params['product_id'])->update(['stock' => $stock, 'total_price' => bcmul($stock, $find['purchase'], 2)]); + $find['stock']=$stock; + $find['total_price']=bcmul($stock, $find['purchase'], 2); + onAfterUpdate($find,'product'); } else { $branchStock = bcsub($storeBranchProduct['stock'], $params['nums'], 2); $stock = bcsub($find['stock'], $params['nums'], 2); + + onBeforeUpdate($storeBranchProduct,'branch_product'); StoreBranchProduct::where('id', $params['id'])->update(['stock' => $branchStock, 'total_price' => bcmul($branchStock, $find['purchase'], 2)]); + $storeBranchProduct['stock']=$branchStock; + $storeBranchProduct['total_price']=bcmul($branchStock, $find['purchase'], 2); + onAfterUpdate($storeBranchProduct,'branch_product'); + + onBeforeUpdate($find,'product'); StoreProduct::where('id', $params['product_id'])->update(['stock' => $stock, 'total_price' => bcmul($stock, $find['purchase'], 2)]); + $find['stock']=$stock; + $find['total_price']=bcmul($stock, $find['purchase'], 2); + onAfterUpdate($find,'product'); } Db::commit(); return true; diff --git a/app/admin/logic/warehouse_product/WarehouseProductLogic.php b/app/admin/logic/warehouse_product/WarehouseProductLogic.php index 8dc2575af..2134c5133 100644 --- a/app/admin/logic/warehouse_product/WarehouseProductLogic.php +++ b/app/admin/logic/warehouse_product/WarehouseProductLogic.php @@ -42,11 +42,23 @@ class WarehouseProductLogic extends BaseLogic $storege = WarehouseProductStorege::where('warehouse_id', $params['warehouse_id'])->where('product_id', $params['product_id'])->find(); if ($storege) { if ($params['financial_pm'] == 0) { + $storeProduct = StoreProduct::where('id', $params['product_id'])->findOrEmpty()->toArray(); + if (!$storeProduct) { + throw new BusinessException('商品不存在'); + } $after_nums = $storege['nums'] - $params['nums']; + $total_price = bcmul($after_nums, $storeProduct['purchase'], 2); + // if ($after_nums < 0) { // throw new BusinessException('库存不足,warehouse_id:'.$params['warehouse_id'].'product_id:'.$params['product_id']); // } - WarehouseProductStorege::where('id', $storege['id'])->dec('nums', $params['nums'])->update(); + onBeforeUpdate($storege->toArray(),'product_storege'); + WarehouseProductStorege::where('id', $storege['id'])->update(['nums'=>$after_nums, 'total_price' => $total_price]); + $storege=$storege->toArray(); + $storege['nums']=$after_nums; + $storege['total_price']=$total_price; + onAfterUpdate($storege,'product_storege'); + //门店加库存 $storeBranchProduct = StoreBranchProduct::where('product_id', $params['product_id'])->where('store_id', $params['store_id'])->find(); if (!$storeBranchProduct) { @@ -67,7 +79,12 @@ class WarehouseProductLogic extends BaseLogic throw new BusinessException('商品不存在'); } $total_price = bcmul($after_nums, $storeProduct['purchase'], 2); + onBeforeUpdate($storege->toArray(),'product_storege'); WarehouseProductStorege::where('id', $storege['id'])->update(['nums' => $after_nums, 'total_price' => $total_price]); + $storege=$storege->toArray(); + $storege['nums']=$after_nums; + $storege['total_price']=$total_price; + onAfterUpdate($storege,'product_storege'); } } $before_nums = $storege['nums']; @@ -78,12 +95,13 @@ class WarehouseProductLogic extends BaseLogic throw new BusinessException('商品不存在'); } $total_price = bcmul($after_nums, $storeProduct['purchase'], 2); - WarehouseProductStorege::create([ + $storege=WarehouseProductStorege::create([ 'warehouse_id' => $params['warehouse_id'], 'product_id' => $params['product_id'], 'nums' => $params['nums'], 'total_price'=>$total_price ]); + onAfterUpdate($storege->toArray(),'product_storege'); } $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 = [ diff --git a/app/api/controller/IndexController.php b/app/api/controller/IndexController.php index dbe09f340..2a090cd52 100644 --- a/app/api/controller/IndexController.php +++ b/app/api/controller/IndexController.php @@ -44,9 +44,15 @@ class IndexController extends BaseApiController public function index() { + $a=StoreProduct::where('is_show',1)->select(); + foreach($a as $k=>$v){ + $find=StoreBranchProduct::where('product_id',$v['id'])->find(); + StoreProduct::where('id',$v['id'])->update(['top_cate_id'=>$find['top_cate_id'],'two_cate_id'=>$find['two_cate_id'],'cate_id'=>$find['cate_id']]); + } return json([1]); } + /** * @notes 下载文件 */ diff --git a/app/api/controller/order/CartController.php b/app/api/controller/order/CartController.php index 90a35cd75..5810409fa 100644 --- a/app/api/controller/order/CartController.php +++ b/app/api/controller/order/CartController.php @@ -7,7 +7,7 @@ use app\api\validate\CartValidate; use app\api\controller\BaseApiController; use app\api\lists\order\CartList; use app\common\model\order\Cart; -use app\common\model\store_branch_product\StoreBranchProduct; +use app\common\model\store_product\StoreProduct; use app\common\model\store_product_unit\StoreProductUnit; class CartController extends BaseApiController @@ -27,10 +27,9 @@ class CartController extends BaseApiController $result = Cart::where(['uid' => $params['uid'], 'store_id' => $params['store_id'], 'product_id' => $params['product_id'], 'is_fail' => 0, 'is_pay' => 0, 'delete_time' => null])->find(); $params['cart_num']=bcadd($params['cart_num'],0,2); //判断起批发价 - $branchProduct = StoreBranchProduct::where( + $branchProduct = StoreProduct::where( [ - 'product_id' => $params['product_id'], - 'store_id' => $params['store_id'] + 'id' => $params['product_id'], ] )->find(); if (!$branchProduct) { @@ -86,10 +85,9 @@ class CartController extends BaseApiController $params['uid'] = $this->request->userId; $params['cart_num']=bcadd($params['cart_num'],0,2); if (convertNumber($params['cart_num']) === false) { - $branchProduct = StoreBranchProduct::where( + $branchProduct = StoreProduct::where( [ - 'product_id' => $params['product_id'], - 'store_id' => $params['store_id'] + 'id' => $params['product_id'], ] )->find(); $is_bulk = StoreProductUnit::where('id', $branchProduct['unit'])->value('is_bulk'); diff --git a/app/api/lists/cate/CateLists.php b/app/api/lists/cate/CateLists.php index 8157169f4..21c52e4be 100644 --- a/app/api/lists/cate/CateLists.php +++ b/app/api/lists/cate/CateLists.php @@ -6,7 +6,7 @@ namespace app\api\lists\cate; use app\admin\lists\BaseAdminDataLists; use app\common\model\cate\Cate; use app\common\lists\ListsSearchInterface; -use app\common\model\store_branch_product\StoreBranchProduct; +use app\common\model\store_product\StoreProduct; use app\Request; use think\facade\Db; @@ -28,7 +28,7 @@ class CateLists extends BaseAdminDataLists implements ListsSearchInterface public function setSearch(): array { return [ - '=' => ['name', 'data', 'store_id', 'sort'], + '=' => ['name', 'data', 'sort'], ]; } @@ -47,17 +47,17 @@ class CateLists extends BaseAdminDataLists implements ListsSearchInterface $level = Request()->get('level', 1); $pid = $this->request->get('pid',0); // $this->searchWhere[] = ['stock', '>', 0]; - $this->searchWhere[] = ['status', '=', 1]; + $this->searchWhere[] = ['is_show', '=', 1]; if($pid && $level ==2){ $this->searchWhere[] = ['top_cate_id','=',$pid]; - $cate_arr = StoreBranchProduct::where($this->searchWhere)->distinct() + $cate_arr = StoreProduct::where($this->searchWhere)->distinct() ->column('two_cate_id'); }elseif($pid && $level ==3){ $this->searchWhere[] = ['two_cate_id','=',$pid]; - $cate_arr = StoreBranchProduct::where($this->searchWhere)->distinct() + $cate_arr = StoreProduct::where($this->searchWhere)->distinct() ->column('cate_id'); }else{ - $cate_arr = StoreBranchProduct::where($this->searchWhere)->distinct() + $cate_arr = StoreProduct::where($this->searchWhere)->distinct() ->column('top_cate_id'); } $lists = []; @@ -85,14 +85,14 @@ class CateLists extends BaseAdminDataLists implements ListsSearchInterface $pid = $this->request->get('pid',0); if($pid && $level ==2){ $this->searchWhere[] = ['top_cate_id','=',$pid]; - $cate_arr = StoreBranchProduct::where($this->searchWhere)->distinct() + $cate_arr = StoreProduct::where($this->searchWhere)->distinct() ->column('two_cate_id'); }elseif($pid && $level ==3){ $this->searchWhere[] = ['two_cate_id','=',$pid]; - $cate_arr = StoreBranchProduct::where($this->searchWhere)->distinct() + $cate_arr = StoreProduct::where($this->searchWhere)->distinct() ->column('cate_id'); }else{ - $cate_arr = StoreBranchProduct::where($this->searchWhere)->distinct() + $cate_arr = StoreProduct::where($this->searchWhere)->distinct() ->column('top_cate_id'); } return Cate::where('id', 'in', $cate_arr)->count(); diff --git a/app/api/lists/order/CartList.php b/app/api/lists/order/CartList.php index 5b6c770c9..e734eb108 100644 --- a/app/api/lists/order/CartList.php +++ b/app/api/lists/order/CartList.php @@ -9,7 +9,7 @@ use app\common\model\order\Cart; use app\common\lists\ListsExtendInterface; use app\common\model\Config; use app\common\model\dict\DictType; -use app\common\model\store_branch_product\StoreBranchProduct; +use app\common\model\store_product\StoreProduct; use app\common\model\store_product_attr_value\StoreProductAttrValue; use app\common\model\store_product_unit\StoreProductUnit; use app\common\model\user\User; @@ -65,14 +65,14 @@ class CartList extends BaseAdminDataLists implements ListsSearchInterface, Lists ->toArray(); $off_activity = Config::where('name', 'off_activity')->value('value'); $user_ship = User::where('id', $userId)->value('user_ship'); - $field = 'product_id,image,price,cost,store_name,unit,delete_time,vip_price,top_cate_id,batch'; + $field = 'id,id product_id,image,price,cost,store_name,unit,delete_time,vip_price,top_cate_id,batch'; if (in_array($user_ship, [4, 6, 7])) { - $field = 'product_id,image,cost price,cost,store_name,unit,delete_time,vip_price,top_cate_id,batch'; + $field = 'id,id product_id,image,cost price,cost,store_name,unit,delete_time,vip_price,top_cate_id,batch'; } $this->user_ship = $user_ship; $this->off_activity = $off_activity; foreach ($list as $key => &$item) { - $find = StoreBranchProduct::where(['product_id' => $item['product_id'], 'store_id' => $item['store_id']]) + $find = StoreProduct::where(['id' => $item['product_id']]) ->field($field) ->find(); if ($find) { diff --git a/app/api/lists/order/OrderList.php b/app/api/lists/order/OrderList.php index a08142f77..5e6652654 100644 --- a/app/api/lists/order/OrderList.php +++ b/app/api/lists/order/OrderList.php @@ -5,11 +5,8 @@ namespace app\api\lists\order; use app\admin\lists\BaseAdminDataLists; use app\common\lists\ListsSearchInterface; -use app\common\model\store_branch_product\StoreBranchProduct; use app\common\model\store_order\StoreOrder; 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 Picqer\Barcode\BarcodeGeneratorPNG; /** diff --git a/app/api/lists/product/ProductLists.php b/app/api/lists/product/ProductLists.php index d15d822f2..ac126989f 100644 --- a/app/api/lists/product/ProductLists.php +++ b/app/api/lists/product/ProductLists.php @@ -6,11 +6,8 @@ namespace app\api\lists\product; use app\api\lists\BaseApiDataLists; use app\common\lists\ListsExtendInterface; use app\common\lists\ListsSortInterface; -use app\common\model\dict\DictType; -use app\common\model\store_branch_product\StoreBranchProduct; use app\common\model\store_product\StoreProduct; use app\common\lists\ListsSearchInterface; -use app\common\model\cate\Cate; use app\common\model\Config; use app\common\model\user\User; //use app\common\model\goods\GoodsLabel; @@ -35,7 +32,7 @@ class ProductLists extends BaseApiDataLists implements ListsSearchInterface, Lis public function setSearch(): array { return [ - '=' => ['store_id', 'cate_id', 'top_cate_id', 'two_cate_id'], + '=' => [ 'cate_id', 'top_cate_id', 'two_cate_id'], '%pipe_like%' => ['store_name' => 'store_name|bar_code'], ]; } @@ -79,7 +76,7 @@ class ProductLists extends BaseApiDataLists implements ListsSearchInterface, Lis } else { $order = [$field => $order]; } - $fields = 'id,product_id,top_cate_id,cate_id,store_name,cost,store_id,vip_price,purchase,price,bar_code,image,sales,store_info,delete_time,unit,batch,top_cate_id,two_cate_id,stock'; + $fields = 'id,id product_id,top_cate_id,cate_id,store_name,cost,vip_price,purchase,price,bar_code,image,sales,store_info,delete_time,unit,batch,top_cate_id,two_cate_id,stock'; $off_activity = Config::where('name', 'off_activity')->value('value'); if ($off_activity == 1) { $tag = '赠10%品牌礼品券'; @@ -96,13 +93,13 @@ class ProductLists extends BaseApiDataLists implements ListsSearchInterface, Lis if ($uid > 0) { $user_ship = User::where('id', $uid)->value('user_ship'); if (in_array($user_ship, [4, 6, 7])) { - $fields = 'id,product_id,top_cate_id,cate_id,store_name,cost,store_id,vip_price,purchase,cost price,bar_code,image,sales,store_info,delete_time,unit,batch,top_cate_id,two_cate_id,stock'; + $fields = 'id,id product_id,top_cate_id,cate_id,store_name,cost,vip_price,purchase,cost price,bar_code,image,sales,store_info,delete_time,unit,batch,top_cate_id,two_cate_id,stock'; } } $this->off_activity = $off_activity; - $this->searchWhere[] = ['status', '=', 1]; + $this->searchWhere[] = ['is_show', '=', 1]; // $this->searchWhere[] = ['stock', '>', 0]; - return StoreBranchProduct::where($this->searchWhere) + return StoreProduct::where($this->searchWhere) ->field($fields) ->with(['className', 'unitName']) ->limit($this->limitOffset, $this->limitLength) @@ -126,7 +123,7 @@ class ProductLists extends BaseApiDataLists implements ListsSearchInterface, Lis */ public function count(): int { - return StoreBranchProduct::where($this->searchWhere) + return StoreProduct::where($this->searchWhere) ->count(); } public function extend() diff --git a/app/api/lists/product/StoreProductLists.php b/app/api/lists/product/StoreProductLists.php index f9c4b2d09..ee66cd1c3 100644 --- a/app/api/lists/product/StoreProductLists.php +++ b/app/api/lists/product/StoreProductLists.php @@ -7,7 +7,6 @@ use app\api\lists\BaseApiDataLists; use app\common\lists\ListsExtendInterface; use app\common\lists\ListsSortInterface; use app\common\model\dict\DictType; -use app\common\model\store_branch_product\StoreBranchProduct; use app\common\model\store_product\StoreProduct; use app\common\lists\ListsSearchInterface; use app\common\model\cate\Cate; @@ -72,22 +71,17 @@ class StoreProductLists extends BaseApiDataLists implements ListsSearchInterface */ public function lists(): array { - $store_id= $this->request->__get('store_id'); - if($store_id){ - $this->searchWhere[] = ['store_id', '=', $store_id]; - } - - $fields = 'id,product_id,cate_id,store_name,cost,store_id,vip_price,purchase,price,bar_code,image,sales,store_info,delete_time,unit,batch,top_cate_id,two_cate_id,stock'; + $fields = 'id,id product_id,cate_id,store_name,cost,store_id,vip_price,purchase,price,bar_code,image,sales,store_info,delete_time,unit,batch,top_cate_id,two_cate_id,stock'; $type=$this->request->get('type',0); if($type==1){ - $fields = 'id,product_id,cate_id,store_name,cost,store_id,vip_price,purchase,cost price,bar_code,image,sales,store_info,delete_time,unit,batch,top_cate_id,two_cate_id,stock'; + $fields = 'id,id product_id,cate_id,store_name,cost,store_id,vip_price,purchase,cost price,bar_code,image,sales,store_info,delete_time,unit,batch,top_cate_id,two_cate_id,stock'; }elseif($type==2){ - $fields = 'id,product_id,cate_id,store_name,cost,store_id,vip_price,purchase,purchase price,bar_code,image,sales,store_info,delete_time,unit,batch,top_cate_id,two_cate_id,stock'; + $fields = 'id,id product_id,cate_id,store_name,cost,store_id,vip_price,purchase,purchase price,bar_code,image,sales,store_info,delete_time,unit,batch,top_cate_id,two_cate_id,stock'; } $this->searchWhere[] = ['status', '=', 1]; // $this->searchWhere[] = ['stock', '>', 0]; - return StoreBranchProduct::where($this->searchWhere) + return StoreProduct::where($this->searchWhere) ->field($fields) ->with(['className', 'unitName']) ->limit($this->limitOffset, $this->limitLength) @@ -105,7 +99,7 @@ class StoreProductLists extends BaseApiDataLists implements ListsSearchInterface */ public function count(): int { - return StoreBranchProduct::where($this->searchWhere) + return StoreProduct::where($this->searchWhere) ->count(); } } diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index 19f9e74ad..1dda5e8c4 100644 --- a/app/api/logic/order/OrderLogic.php +++ b/app/api/logic/order/OrderLogic.php @@ -87,9 +87,9 @@ class OrderLogic extends BaseLogic self::$fresh_price = 0; //生鲜金额 /** 计算价格 */ $off_activity = Config::where('name', 'off_activity')->value('value'); - $field = 'product_id id,store_name,image,unit,price,vip_price,cost,purchase,cate_id,store_info,rose'; + $field = 'id,store_name,image,unit,price,vip_price,cost,purchase,cate_id,store_info,rose'; foreach ($cart_select as $k => $v) { - $find = StoreBranchProduct::where(['product_id' => $v['product_id'],'store_id'=>$params['store_id']])->field($field)->find(); + $find = StoreProduct::where(['id' => $v['product_id']])->field($field)->find(); if (!$find) { throw new BusinessException('商品不存在'); } @@ -452,7 +452,7 @@ class OrderLogic extends BaseLogic return []; } $goods_arr = array_unique($goods_id); - $select = StoreBranchProduct::where('product_id', 'in', $goods_arr)->with('unitName')->field('id,store_name,price,image,unit')->select(); + $select = StoreProduct::where('id', 'in', $goods_arr)->with('unitName')->field('id,store_name,price,image,unit')->select(); return $select->toArray(); } catch (\Throwable $e) { throw new BusinessException($e->getMessage()); @@ -495,10 +495,8 @@ class OrderLogic extends BaseLogic $find['goods_list'] = StoreOrderCartInfo::where('oid', $find['id']) ->field('product_id,cart_num nums,store_id')->select()->each(function ($item) use ($find) { - $find = StoreBranchProduct::where('product_id', $item['product_id'])->where('store_id', $find['store_id'])->find(); - if (empty($find)) { - $find = StoreProduct::where('id', $item['product_id'])->withTrashed()->find(); - } + $find = StoreProduct::where('id', $item['product_id'])->withTrashed()->find(); + $item['store_name'] = $find['store_name']; $item['nums'] = floatval($item['nums']); $item['image'] = $find['image']; diff --git a/app/common/logic/CommissionProductLogic.php b/app/common/logic/CommissionProductLogic.php index b2ceaef7a..54f53d86f 100644 --- a/app/common/logic/CommissionProductLogic.php +++ b/app/common/logic/CommissionProductLogic.php @@ -22,17 +22,14 @@ class CommissionProductLogic extends BaseLogic */ function calculate_product_flow($find, $order, $village_uid = 0, $brigade_uid = 0, $user_ship = 0, $spread_user_ship = 0) { - $product = StoreBranchProduct::where('product_id', $find['product_id'])->where('store_id', $order['store_id'])->find(); - if (!$product) { - $product = StoreProduct::where('id', $find['product_id'])->find(); - } + $product = StoreProduct::where('id', $find['product_id'])->find(); if ($product) { if ($product['product_type'] == 4) { $this->c($find, $order, $village_uid, $brigade_uid, $user_ship, $product); return true; } else { if ($user_ship == 5) { - $top_cate_id = StoreBranchProduct::where('product_id', $find['product_id'])->value('top_cate_id'); + $top_cate_id = $product['top_cate_id']; if ($top_cate_id == 15189) { $this->b($find, $order, $product,$user_ship); return true; diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index 1bdacd40c..efa80f521 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -574,20 +574,42 @@ class PayNotifyLogic extends BaseLogic { StoreOrderCartInfo::where('oid', $order['id'])->update(['is_pay' => 1]); $arr = StoreOrderCartInfo::where('oid', $order['id'])->field('id,oid,product_id,store_id,cart_num')->select(); - foreach ($arr as $k => $v) { - $branchProduct=StoreBranchProduct::where('product_id', $v['product_id'])->where('store_id',$v['store_id'])->find(); - if($branchProduct){ - $stock=bcsub($branchProduct['stock'],$v['cart_num'],2); - StoreProduct::where('id',$branchProduct['id'])->update(['stock'=>$stock,'total_price'=>bcmul($stock,$branchProduct['purchase'],2), - 'sales'=>bcmul($branchProduct['sales'],$v['cart_num'],2)]); - } - $storeProduct=StoreProduct::where('id', $v['product_id'])->find(); - if($storeProduct){ - $stock=bcsub($storeProduct['stock'],$v['cart_num'],2); - StoreProduct::where('id', $v['product_id'])->update(['stock'=>$stock,'total_price'=>bcmul($stock,$storeProduct['purchase'],2), - 'sales'=>bcmul($storeProduct['sales'],$v['cart_num'],2)]); + try{ + foreach ($arr as $k => $v) { + $branchProduct=StoreBranchProduct::where('product_id', $v['product_id'])->where('store_id',$v['store_id'])->find(); + if($branchProduct){ + $stock=bcsub($branchProduct['stock'],$v['cart_num'],2); + onBeforeUpdate($branchProduct->toArray(),'branch_product'); + + StoreBranchProduct::where('id',$branchProduct['id'])->update(['stock'=>$stock,'total_price'=>bcmul($stock,$branchProduct['purchase'],2), + 'sales'=>bcadd($branchProduct['sales'],$v['cart_num'],2)]); + + $branchProduct=$branchProduct->toArray(); + $branchProduct['stock']=$stock; + $branchProduct['total_price']=bcmul($stock,$branchProduct['purchase'],2); + $branchProduct['sales']=bcadd($branchProduct['sales'],$v['cart_num'],2); + onAfterUpdate($branchProduct,'branch_product'); + } + $storeProduct=StoreProduct::where('id', $v['product_id'])->find(); + if($storeProduct){ + $stock=bcsub($storeProduct['stock'],$v['cart_num'],2); + onBeforeUpdate($storeProduct->toArray(),'product'); + + StoreProduct::where('id', $v['product_id'])->update(['stock'=>$stock,'total_price'=>bcmul($stock,$storeProduct['purchase'],2), + 'sales'=>bcadd($storeProduct['sales'],$v['cart_num'],2)]); + + $storeProduct=$storeProduct->toArray(); + $storeProduct['stock']=$stock; + $storeProduct['total_price']=bcmul($stock,$storeProduct['purchase'],2); + $storeProduct['sales']=bcadd($storeProduct['sales'],$v['cart_num'],2); + onAfterUpdate($storeProduct,'product'); + } } + }catch (\Throwable $e) { + Log::error('订单库存更新失败:' . $e->getMessage()); + // 异常处理代码,例如记录日志或发送通知等。 } + $financeLogic = new StoreFinanceFlowLogic(); $off_activity = Config::where('name', 'off_activity')->value('value'); $village_uid = 0; diff --git a/app/common/model/store_branch_product/StoreBranchProduct.php b/app/common/model/store_branch_product/StoreBranchProduct.php index 124eb2233..c74b0bcd5 100644 --- a/app/common/model/store_branch_product/StoreBranchProduct.php +++ b/app/common/model/store_branch_product/StoreBranchProduct.php @@ -36,10 +36,8 @@ class StoreBranchProduct extends BaseModel } - public function store() { return $this->hasOne(StoreProduct::class,'id','product_id'); } - } \ No newline at end of file diff --git a/app/common/model/store_product/StoreProduct.php b/app/common/model/store_product/StoreProduct.php index dc810fdda..7f8b6fbb5 100644 --- a/app/common/model/store_product/StoreProduct.php +++ b/app/common/model/store_product/StoreProduct.php @@ -6,6 +6,7 @@ namespace app\common\model\store_product; use app\common\model\BaseModel; use app\common\model\store_category\StoreCategory; use app\common\model\store_product_unit\StoreProductUnit; +use support\Log; use think\model\concern\SoftDelete; @@ -31,8 +32,5 @@ class StoreProduct extends BaseModel { return $this->hasOne(StoreCategory::class,'id','cate_id')->bind(['class_name'=>'name']); - } - - } \ No newline at end of file diff --git a/app/common/model/warehouse_product_storege/WarehouseProductStorege.php b/app/common/model/warehouse_product_storege/WarehouseProductStorege.php index 074aa2d02..b8c71cf67 100644 --- a/app/common/model/warehouse_product_storege/WarehouseProductStorege.php +++ b/app/common/model/warehouse_product_storege/WarehouseProductStorege.php @@ -4,6 +4,7 @@ namespace app\common\model\warehouse_product_storege; use app\common\model\BaseModel; +use support\Log; use think\model\concern\SoftDelete; @@ -18,5 +19,12 @@ class WarehouseProductStorege extends BaseModel protected $name = 'warehouse_product_storege'; protected $deleteTime = 'delete_time'; - + public function onBeforeUpdate($product){ + $log = Log::channel('product_storege'); + $log->info('更新前:'.json_encode($product)); + } + public function onAfterUpdate($product){ + $log = Log::channel('product_storege'); + $log->info('更新后:'.json_encode($product)); + } } \ No newline at end of file diff --git a/app/functions.php b/app/functions.php index e2b128000..7087f1979 100644 --- a/app/functions.php +++ b/app/functions.php @@ -5,7 +5,7 @@ */ use app\common\service\FileService; - +use support\Log; if (!function_exists('substr_symbol_behind')) { /** @@ -500,3 +500,20 @@ if (!function_exists('convertNumber')) { } } } + +/** + * 日志记录 + * @param product + * @param branch_product + * @param product_storege + */ +function onBeforeUpdate($data, $type) +{ + $log = Log::channel($type); + $log->info('更新前:',$data); +} +function onAfterUpdate($data, $type) +{ + $log = Log::channel($type); + $log->info('更新后:' ,$data); +} diff --git a/app/store/controller/cart/CartController.php b/app/store/controller/cart/CartController.php index 29d3cf937..3674f732e 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\StoreProduct; use app\common\model\store_product_unit\StoreProductUnit; use app\store\controller\BaseAdminController; @@ -30,10 +31,9 @@ class CartController extends BaseAdminController $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(); //判断起批发价 - $branchProduct = StoreBranchProduct::where( + $branchProduct = StoreProduct::where( [ - 'product_id' => $params['product_id'], - 'store_id' => $adminInfo['store_id'] + 'id' => $params['product_id'], ] )->find(); if ($params['cart_num'] < $branchProduct['batch']) { @@ -76,6 +76,18 @@ class CartController extends BaseAdminController { $params = (new CartValidate())->post()->goCheck('StoreChange'); $adminInfo = $this->adminInfo; + $params['cart_num']=bcadd($params['cart_num'],0,2); + if (convertNumber($params['cart_num']) === false) { + $branchProduct = StoreProduct::where( + [ + 'id' => $params['product_id'], + ] + )->find(); + $is_bulk = StoreProductUnit::where('id', $branchProduct['unit'])->value('is_bulk'); + if ($is_bulk == 0) { + return $this->fail('非计量商品,不能有小数,请编辑购物车'); + } + } $params['uid'] = 0; $params['staff_id'] = $adminInfo['admin_id']; $params['store_id'] = $adminInfo['store_id']; diff --git a/app/store/lists/cart/CartList.php b/app/store/lists/cart/CartList.php index 27ca4ecf3..bfa55e9de 100644 --- a/app/store/lists/cart/CartList.php +++ b/app/store/lists/cart/CartList.php @@ -12,6 +12,7 @@ use app\common\model\store_product_attr_value\StoreProductAttrValue; use app\common\model\store_product_unit\StoreProductUnit; use app\common\model\user\User; use app\common\lists\ListsExtendInterface; +use app\common\model\store_product\StoreProduct; /** * 购物车列表 @@ -70,8 +71,8 @@ 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('product_id,image,price,cost,store_name,unit,delete_time,vip_price,top_cate_id') + $find = StoreProduct::where(['id' => $item['product_id']]) + ->field('id,id product_id,image,price,cost,store_name,unit,delete_time,vip_price,top_cate_id') ->find(); if ($find) { if ($off_activity == 1) { diff --git a/config/log.php b/config/log.php index ee8448c4a..7db7057d5 100644 --- a/config/log.php +++ b/config/log.php @@ -1,4 +1,5 @@ [ 'class' => Monolog\Formatter\LineFormatter::class, - 'constructor' => [null, 'Y-m-d H:i:s', true,true], + 'constructor' => [null, 'Y-m-d H:i:s', true, true], + ], + ] + ], + ], + // log2通道 + 'product' => [ + // 处理默认通道的handler,可以设置多个 + 'handlers' => [ + [ + // handler类的名字 + 'class' => Monolog\Handler\RotatingFileHandler::class, + // handler类的构造函数参数 + 'constructor' => [ + runtime_path() . '/product/'.date('Ym').'/.log', + 2048, + Monolog\Logger::DEBUG, + true, + 0755 + ], + // 格式相关 + 'formatter' => [ + // 格式化处理类的名字 + 'class' => Monolog\Formatter\LineFormatter::class, + // 格式化处理类的构造函数参数 + 'constructor' => [null, 'Y-m-d H:i:s', true], + ], + ] + ], + ], + 'branch_product' => [ + // 处理默认通道的handler,可以设置多个 + 'handlers' => [ + [ + // handler类的名字 + 'class' => Monolog\Handler\RotatingFileHandler::class, + // handler类的构造函数参数 + 'constructor' => [ + runtime_path() . '/branch_product/'.date('Ym').'/.log', + 2048, + Monolog\Logger::DEBUG, + true, + 0755 + ], + // 格式相关 + 'formatter' => [ + // 格式化处理类的名字 + 'class' => Monolog\Formatter\LineFormatter::class, + // 格式化处理类的构造函数参数 + 'constructor' => [null, 'Y-m-d H:i:s', true], + ], + ] + ], + ], + 'product_storege' => [ + // 处理默认通道的handler,可以设置多个 + 'handlers' => [ + [ + // handler类的名字 + 'class' => Monolog\Handler\RotatingFileHandler::class, + // handler类的构造函数参数 + 'constructor' => [ + runtime_path() . '/product_storege/'.date('Ym').'/.log', + 2048, + Monolog\Logger::DEBUG, + true, + 0755 + ], + // 格式相关 + 'formatter' => [ + // 格式化处理类的名字 + 'class' => Monolog\Formatter\LineFormatter::class, + // 格式化处理类的构造函数参数 + 'constructor' => [null, 'Y-m-d H:i:s', true], ], ] ], From 4cef86fb877ef19b2380110b5d048140b1a052fb Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Wed, 28 Aug 2024 15:47:22 +0800 Subject: [PATCH 3/6] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9SystemStoreLists?= =?UTF-8?q?=E7=B1=BB=E4=BB=A5=E4=BC=98=E5=8C=96=E8=B4=AD=E7=89=A9=E8=BD=A6?= =?UTF-8?q?=E5=95=86=E5=93=81=E5=BA=93=E5=AD=98=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 --- app/api/lists/store/SystemStoreLists.php | 101 +++++++++++++---------- 1 file changed, 57 insertions(+), 44 deletions(-) diff --git a/app/api/lists/store/SystemStoreLists.php b/app/api/lists/store/SystemStoreLists.php index 9f52831f3..64c1d6c6b 100644 --- a/app/api/lists/store/SystemStoreLists.php +++ b/app/api/lists/store/SystemStoreLists.php @@ -48,62 +48,76 @@ class SystemStoreLists extends BaseAdminDataLists implements ListsSearchInterfac */ public function lists(): array { - $latitude = $this->request->get('latitude',''); - $longitude = $this->request->get('longitude',''); - $cart_id = $this->request->get('cart_id',''); -// if(empty($longitude) || empty($latitude)){ -// throw new Exception('缺失经纬度'); -// } - $where[]=['is_show','=',YesNoEnum::YES]; + $latitude = $this->request->get('latitude', ''); + $longitude = $this->request->get('longitude', ''); + $cart_id = $this->request->get('cart_id', ''); + // if(empty($longitude) || empty($latitude)){ + // throw new Exception('缺失经纬度'); + // } + $where[] = ['is_show', '=', YesNoEnum::YES]; $data = SystemStore::where($this->searchWhere)->where($where) - ->field(['id', 'name', 'phone', 'detailed_address', 'image', 'is_show', - 'day_time','is_store','latitude','longitude','day_start','day_end','is_store' - ,'is_send','abbreviation' + ->field([ + 'id', + 'name', + 'phone', + 'detailed_address', + 'image', + 'is_show', + 'day_time', + 'is_store', + 'latitude', + 'longitude', + 'day_start', + 'day_end', + 'is_store', + 'is_send', + 'abbreviation' ]) ->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) ->select() ->toArray(); - if($cart_id){ - if($latitude && $longitude){ - $cart_id = explode(',',$cart_id); - $cart_select = Cart::whereIn('id', $cart_id) - ->field('id,product_id,cart_num,store_id')->select()->toArray(); - foreach ($cart_select as $v) { - foreach ($data as &$values){ - $store = StoreBranchProduct::where([ - 'store_id'=>$values['id'], - 'product_id'=>$v['product_id'], - ])->field('id,store_name,stock')->withTrashed()->find(); - if(empty($store)){ - $store['stock'] =0; - } - $values['reservation'] = 0; - if($store['stock'] < $v['cart_num']){ - $values['reservation'] = 1; - } - $values['distance'] = haversineDistance($values['latitude'],$values['longitude'],$latitude,$longitude); - } + if ($cart_id) { + if ($latitude && $longitude) { + foreach ($data as &$values) { + $values['distance'] = haversineDistance($values['latitude'], $values['longitude'], $latitude, $longitude); + $values['reservation'] = 1; } - }else{ - foreach ($data as &$values){ + + // $cart_id = explode(',',$cart_id); + // $cart_select = Cart::whereIn('id', $cart_id) + // ->field('id,product_id,cart_num,store_id')->select()->toArray(); + // foreach ($cart_select as $v) { + // foreach ($data as &$values){ + // $store = StoreBranchProduct::where([ + // 'store_id'=>$values['id'], + // 'product_id'=>$v['product_id'], + // ])->field('id,store_name,stock')->withTrashed()->find(); + // if(empty($store)){ + // $store['stock'] =0; + // } + // $values['reservation'] = 0; + // if($store['stock'] < $v['cart_num']){ + // } + // } + + // } + } else { + foreach ($data as &$values) { $values['distance'] = 0; } } - - }else{ - if($latitude && $longitude){ - foreach ($data as &$value){ - $value['distance'] = haversineDistance($value['latitude'],$value['longitude'],$latitude,$longitude); - + } else { + if ($latitude && $longitude) { + foreach ($data as &$value) { + $value['distance'] = haversineDistance($value['latitude'], $value['longitude'], $latitude, $longitude); } - }else{ - foreach ($data as &$values){ + } else { + foreach ($data as &$values) { $values['distance'] = 0; } } - } usort($data, function ($a, $b) { @@ -121,8 +135,7 @@ class SystemStoreLists extends BaseAdminDataLists implements ListsSearchInterfac */ public function count(): int { - $where[]=['is_show','=',YesNoEnum::YES]; + $where[] = ['is_show', '=', YesNoEnum::YES]; return SystemStore::where($this->searchWhere)->where($where)->count(); } - -} \ No newline at end of file +} From a2b121462ca37b9fafbe6857c674dc6dee2a4b43 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Wed, 28 Aug 2024 16:43:08 +0800 Subject: [PATCH 4/6] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E5=95=86=E5=93=81=E7=8A=B6=E6=80=81=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 --- .../store_product/StoreProductController.php | 10 ++++++ .../logic/store_product/StoreProductLogic.php | 35 ++++++++++++++++--- 2 files changed, 41 insertions(+), 4 deletions(-) diff --git a/app/admin/controller/store_product/StoreProductController.php b/app/admin/controller/store_product/StoreProductController.php index 50cc68465..55c5f43d7 100644 --- a/app/admin/controller/store_product/StoreProductController.php +++ b/app/admin/controller/store_product/StoreProductController.php @@ -62,6 +62,16 @@ class StoreProductController extends BaseAdminController } + /** + * @notes 修改商品状态 + * @return \think\response\Json + * @date 2024/05/31 10:53 + */ + public function status(){ + $params=$this->request->post(); + StoreProduct::where('id',$params['id'])->update(['is_show'=>$params['is_show']]); + return $this->success('操作成功',[],1,1); + } /** * @notes 删除商品列表 diff --git a/app/admin/logic/store_product/StoreProductLogic.php b/app/admin/logic/store_product/StoreProductLogic.php index 875b9cc96..d8f28f88f 100644 --- a/app/admin/logic/store_product/StoreProductLogic.php +++ b/app/admin/logic/store_product/StoreProductLogic.php @@ -36,6 +36,16 @@ class StoreProductLogic extends BaseLogic */ public static function add(array $params): bool { + $count=count($params['cate_arr']); + $top_cate_id=0; + $two_cate_id=0; + if($count==3){ + $top_cate_id=$params['cate_arr'][0]; + $two_cate_id=$params['cate_arr'][1]; + }elseif($count==2){ + $top_cate_id=$params['cate_arr'][0]; + $two_cate_id=$params['cate_arr'][0]; + } Db::startTrans(); try { $data = [ @@ -43,6 +53,8 @@ class StoreProductLogic extends BaseLogic 'image' => $params['image'], 'store_info' => $params['store_info'] ?? '', 'bar_code' => $params['bar_code'] ?? '', + 'top_cate_id' => $top_cate_id, + 'two_cate_id' => $two_cate_id, 'cate_id' => $params['cate_id'], 'unit' => $params['unit'], 'stock' => 0, @@ -57,6 +69,7 @@ class StoreProductLogic extends BaseLogic 'batch' => $params['batch'] ?? 0, 'store_batch' => $params['store_batch'] ?? 1, 'product_type' => $params['product_type'] ?? 0, + 'is_show' => $params['is_show'] ?? 0, ]; // if ($params['rose'] > 0) { // $rose_price = bcmul($params['cost'], $params['rose'], 2); @@ -171,11 +184,23 @@ class StoreProductLogic extends BaseLogic { Db::startTrans(); try { + $count=count($params['cate_arr']); + $top_cate_id=0; + $two_cate_id=0; + if($count==3){ + $top_cate_id=$params['cate_arr'][0]; + $two_cate_id=$params['cate_arr'][1]; + }elseif($count==2){ + $top_cate_id=$params['cate_arr'][0]; + $two_cate_id=$params['cate_arr'][0]; + } $data = [ 'store_name' => $params['store_name'], 'image' => $params['image'], 'bar_code' => $params['bar_code'] ?? '', 'store_info' => $params['store_info'] ?? '', + 'top_cate_id' => $top_cate_id, + 'two_cate_id' => $two_cate_id, 'cate_id' => $params['cate_id'], 'unit' => $params['unit'], 'stock' => $params['stock'], @@ -189,12 +214,12 @@ class StoreProductLogic extends BaseLogic 'store_batch' => $params['store_batch'] ?? 1, 'manufacturer_information' => $params['manufacturer_information'] ?? '', 'swap' => $params['swap'] ?? 0, - 'rose' => $params['rose'] ?? 0, + 'is_show' => $params['is_show'] ?? 0, ]; StoreProduct::where('id', $params['id'])->update($data); - $dealCate = self::dealChangeCate($params['cate_id']); + // $dealCate = self::dealChangeCate($params['cate_id']); //修改 StoreBranchProduct::where('product_id', $params['id'])->update([ 'price' => $params['price'], @@ -206,11 +231,13 @@ class StoreProductLogic extends BaseLogic 'manufacturer_information' => $params['manufacturer_information'] ?? '', 'store_info' => $params['store_info'] ?? '', 'cate_id' => $params['cate_id'], - 'top_cate_id' => $dealCate['top_cate_id'], - 'two_cate_id' => $dealCate['two_cate_id'], + 'top_cate_id' => $top_cate_id, + 'two_cate_id' => $two_cate_id, + 'cate_id' => $params['cate_id'], 'bar_code' => $params['bar_code'], 'purchase' => $params['purchase'], 'rose' => $params['rose'] ?? 0, + 'status' => $params['is_show'] ?? 0, 'image' => $params['image'], 'store_batch' => $params['store_batch'] ?? 1, From fc779f1e7ea58812def34c720a31d9d55ae7c234 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Wed, 28 Aug 2024 18:01:04 +0800 Subject: [PATCH 5/6] =?UTF-8?q?feat(UserLists.php):=20=E6=B7=BB=E5=8A=A0'b?= =?UTF-8?q?etween=5Ftime'=E6=9F=A5=E8=AF=A2=E6=9D=A1=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/lists/user/UserLists.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/admin/lists/user/UserLists.php b/app/admin/lists/user/UserLists.php index a419056cc..e94de5530 100644 --- a/app/admin/lists/user/UserLists.php +++ b/app/admin/lists/user/UserLists.php @@ -29,6 +29,7 @@ class UserLists extends BaseAdminDataLists implements ListsExcelInterface,ListsS '=' => ['store_id','user_ship','is_disable'], '%like%' => ['account','mobile'], '%pipe_like%' => ['nickname'=>'nickname|real_name'], + 'between_time' => 'vip_time' ]; } From 4a2378f15b2faed051184bc33480d6fb6a995e4b Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Wed, 28 Aug 2024 20:39:02 +0800 Subject: [PATCH 6/6] =?UTF-8?q?feat(WarehouseProductStorege.php):=20?= =?UTF-8?q?=E7=A7=BB=E9=99=A4=E4=BA=86=E5=95=86=E5=93=81=E5=BA=93=E5=AD=98?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=97=A5=E5=BF=97=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../warehouse_product_storege/WarehouseProductStorege.php | 8 -------- 1 file changed, 8 deletions(-) diff --git a/app/common/model/warehouse_product_storege/WarehouseProductStorege.php b/app/common/model/warehouse_product_storege/WarehouseProductStorege.php index b8c71cf67..fd8cefcd0 100644 --- a/app/common/model/warehouse_product_storege/WarehouseProductStorege.php +++ b/app/common/model/warehouse_product_storege/WarehouseProductStorege.php @@ -19,12 +19,4 @@ class WarehouseProductStorege extends BaseModel protected $name = 'warehouse_product_storege'; protected $deleteTime = 'delete_time'; - public function onBeforeUpdate($product){ - $log = Log::channel('product_storege'); - $log->info('更新前:'.json_encode($product)); - } - public function onAfterUpdate($product){ - $log = Log::channel('product_storege'); - $log->info('更新后:'.json_encode($product)); - } } \ No newline at end of file