From 127445c0740ce0c3af09ebd1f4eb2a7888d01949 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Mon, 23 Dec 2024 15:39:18 +0800 Subject: [PATCH 01/38] =?UTF-8?q?feat(admin):=20=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E5=95=86=E5=93=81=E8=BF=9B=E9=94=80=E5=AD=98=E4=BB=B7=E6=A0=BC?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 StoreProductPriceLists 类中添加商品的 current_purchase、current_cost 和 current_price 字段 - 从 StoreProduct 模型中获取商品的 purchase、cost 和 price 信息 - 在列表中显示商品的当前进价、成本价和销售价 --- .../lists/store_product_price/StoreProductPriceLists.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/admin/lists/store_product_price/StoreProductPriceLists.php b/app/admin/lists/store_product_price/StoreProductPriceLists.php index f2560fc2..297a7d33 100644 --- a/app/admin/lists/store_product_price/StoreProductPriceLists.php +++ b/app/admin/lists/store_product_price/StoreProductPriceLists.php @@ -48,15 +48,18 @@ class StoreProductPriceLists extends BaseAdminDataLists implements ListsSearchIn $this->searchWhere[]=['product_id','in',$store_id]; } return StoreProductPrice::where($this->searchWhere) - ->field(['id','bhoid','offer_id', 'product_id', 'purchase_price', 'purchase_lv', 'purchase', 'cost_lv', 'cost', 'price_lv', 'price', 'price_config', 'status']) + ->field(['id','bhoid','offer_id', 'product_id', 'purchase_price', 'purchase_lv', 'purchase', 'cost_lv', 'cost', 'price_lv', 'price', 'price_config', 'status','create_time','mark']) ->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) ->select()->each(function($item){ - $find = StoreProduct::with('unitName')->where('id', $item['product_id'])->field('image,store_name,store_info,unit')->withTrashed()->find(); + $find = StoreProduct::with('unitName')->where('id', $item['product_id'])->field('image,purchase,cost,price,store_name,store_info,unit')->withTrashed()->find(); $item['unit_name']=$find['unitName']['name'] ?? ''; $item['store_name']=$find['store_name']; $item['store_info']=$find['store_info']; $item['image']=$find['image']; + $item['current_purchase']=$find['purchase']; + $item['current_cost']=$find['cost']; + $item['current_price']=$find['price']; $item['status_name']=$item['status']==0?"未设置":"已设置"; }) ->toArray(); From 93dad8118310d3de418ed45fd8a884adc2c0fcfb Mon Sep 17 00:00:00 2001 From: lewis <604446095@qq.com> Date: Mon, 23 Dec 2024 17:03:51 +0800 Subject: [PATCH 02/38] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=95=86=E5=93=81?= =?UTF-8?q?=E5=88=86=E7=B1=BB=E7=9A=84=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/LocalController.php | 89 ++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 app/admin/controller/LocalController.php diff --git a/app/admin/controller/LocalController.php b/app/admin/controller/LocalController.php new file mode 100644 index 00000000..6a592345 --- /dev/null +++ b/app/admin/controller/LocalController.php @@ -0,0 +1,89 @@ +request->file('file'); + $reader = IOFactory::createReader('Xlsx'); + $spreadsheet = $reader->load($file->getRealPath()); + $data = $spreadsheet->getActiveSheet()->toArray(); + $updateCount = 0; + $finishCount = Redis::get('finishCount'); + $finishCount = empty($finishCount) ? 0 : $finishCount; + if ($finishCount >= count($data)) { + echo '数据已更新完成'; + return; + } + $max = $finishCount + 100; + foreach ($data as $k => $row) { + if ($k < (1 + $finishCount) || empty($row[0])) { + continue; + } + if ($k > $max) { + break; + } + $product = StoreProduct::where('id', $row[0])->field('id,store_name,top_cate_id,two_cate_id,cate_id')->findOrEmpty()->toArray(); + if (empty($product)) { + continue; + } + $result = $this->updateProduct($product, $row); + if ($result) { + $updateCount++; + } + } + Redis::set('finishCount', 100 + $finishCount); + echo '更新成功:' . $updateCount . '条'; + } + + public function updateProduct($product, $row) + { + $topCateName = rtrim($row[1], '类'); + $secondCateName = rtrim($row[2], '类'); + $cateName = rtrim($row[3], '类'); + $topCate = StoreCategory::where('name', $topCateName)->value('id'); + $updateData = []; + if (!empty($topCate) && $topCate != $product['top_cate_id']) { + $updateData['top_cate_id'] = $topCate; + } + $secondCateId = StoreCategory::where('pid', $topCate)->where('name', $secondCateName)->value('id'); + if (empty($secondCateId)) { + $secondCate = new StoreCategory(); + $secondCate->name = $secondCateName; + $secondCate->pid = $topCate; + $secondCate->save(); + $secondCateId = $secondCate->id; + } + if ($secondCateId != $product['two_cate_id']) { + $updateData['two_cate_id'] = $secondCateId; + } + $cateId = StoreCategory::where('pid', $secondCateId)->where('name', $cateName)->value('id'); + if (empty($cateId)) { + $cate = new StoreCategory(); + $cate->name = $cateName; + $cate->pid = $secondCateId; + $cate->save(); + $cateId = $cate->id; + } + if ($cateId != $product['cate_id']) { + $updateData['cate_id'] = $cateId; + } + if (!empty($updateData)) { + StoreProduct::where('id', $row[0])->update($updateData); + echo '更新成功ID:' . $row[0] . PHP_EOL; + return true; + } + return false; + } + +} \ No newline at end of file From be6cf0aa3f343e2d6e71be2da84aa4f10bd9e0ce Mon Sep 17 00:00:00 2001 From: lewis <604446095@qq.com> Date: Mon, 23 Dec 2024 17:42:48 +0800 Subject: [PATCH 03/38] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=95=86=E5=93=81?= =?UTF-8?q?=E5=88=86=E7=B1=BB=E7=9A=84=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/LocalController.php | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/app/admin/controller/LocalController.php b/app/admin/controller/LocalController.php index 6a592345..bcb506ab 100644 --- a/app/admin/controller/LocalController.php +++ b/app/admin/controller/LocalController.php @@ -19,11 +19,10 @@ class LocalController extends BaseAdminController $spreadsheet = $reader->load($file->getRealPath()); $data = $spreadsheet->getActiveSheet()->toArray(); $updateCount = 0; - $finishCount = Redis::get('finishCount'); + $finishCount = Redis::get('updateFinishCount'); $finishCount = empty($finishCount) ? 0 : $finishCount; if ($finishCount >= count($data)) { - echo '数据已更新完成'; - return; + return $this->success('数据已更新完成'); } $max = $finishCount + 100; foreach ($data as $k => $row) { @@ -42,15 +41,15 @@ class LocalController extends BaseAdminController $updateCount++; } } - Redis::set('finishCount', 100 + $finishCount); - echo '更新成功:' . $updateCount . '条'; + Redis::set('updateFinishCount', 100 + $finishCount); + return $this->success('更新成功:' . $updateCount . '条'); } public function updateProduct($product, $row) { - $topCateName = rtrim($row[1], '类'); - $secondCateName = rtrim($row[2], '类'); - $cateName = rtrim($row[3], '类'); + $topCateName = $row[1]; + $secondCateName = $row[2]; + $cateName = $row[3]; $topCate = StoreCategory::where('name', $topCateName)->value('id'); $updateData = []; if (!empty($topCate) && $topCate != $product['top_cate_id']) { From df8f3523f680f85cf6c48879db2de5199639e4b3 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Mon, 23 Dec 2024 17:52:58 +0800 Subject: [PATCH 04/38] =?UTF-8?q?feat(printer):=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E8=AE=A2=E5=8D=95=E6=89=93=E5=8D=B0=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 PayNotifyLogic 中增加订单打印逻辑 - 实现 XpsdkPrintApi 类的订单打印方法 - 添加 OrderXprinterPushSend 队列消费者处理订单打印 - 优化打印内容格式,包括订单信息、商品列表等 --- app/common/logic/PayNotifyLogic.php | 3 + app/common/service/xpyun/XpsdkPrintApi.php | 73 ++++++++++++---------- app/queue/redis/OrderXprinterPushSend.php | 73 ++++++++++++++++++++++ 3 files changed, 115 insertions(+), 34 deletions(-) create mode 100644 app/queue/redis/OrderXprinterPushSend.php diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index b2b2a6d0..52f6c5e8 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -647,6 +647,9 @@ class PayNotifyLogic extends BaseLogic if ($order['uid'] != 1) { Redis::send('order_wetcha_push_send', ['order' => $order]); } + if($order['store_id']==21){ + Redis::send('order_xprinter_push_send', ['order' => $order]); + } } catch (\Exception $e) { Log::error('订单推送失败:' . $e->getMessage()); // 异常处理代码,例如记录日志或发送通知等。 diff --git a/app/common/service/xpyun/XpsdkPrintApi.php b/app/common/service/xpyun/XpsdkPrintApi.php index e363fec4..db9fd719 100644 --- a/app/common/service/xpyun/XpsdkPrintApi.php +++ b/app/common/service/xpyun/XpsdkPrintApi.php @@ -25,44 +25,49 @@ class XpsdkPrintApi * 注意:对齐标签L C R CB 请勿嵌套使用,嵌套使用内层标签有效,外层失效; * 同一行请勿使用多个对齐标签,否则只有最后一个对齐标签有效 */ - public function printFontAlign($sn) + public function printFontAlign($sn,$order) { + $system_store=$order['system_store']; + $system_phone=$order['system_phone']; + $verify_code=$order['verify_code']; + $order_id=$order['order_id']; + $create_time=$order['create_time']; + $pay_price=$order['pay_price']; + $total_price=$order['total_price']; + $deduction_price=$order['deduction_price']; + $pay_type_name=$order['pay_type_name']; + $printContent = << -
-L标签:左对齐
-
-R标签:右对齐
-
-C标签:居中对齐
-
-N标签:字体正常大小
-
-HB标签:字体变高一倍
-
-WB标签:字体变宽一倍
-
-B标签:字体放大一倍
-
-HB2标签:字体变高二倍
-
-WB2标签:字体变宽二倍
-
-B2标签:字体放大二倍
-
-BOLD标签:字体加粗
+{$system_store}
+============================== +核销码:{$verify_code} +单号:{$order_id} +下单时间:{$create_time} +============================== +单价 数量 小计 + EOF; +// 使用 for 循环生成商品列表 +foreach ($order['product_arr'] as $k=>$v) { + $printContent .= <<{$v['name']} +{$v['price']} *{$v['quantity']} {$v['subtotal']} +EOF; +} - $printContent = $printContent . '
'; - // 嵌套使用对齐和字体 - $printContent = $printContent . '嵌套使用:居中加粗
'; - - // 打印条形码和二维码 - $printContent = $printContent . '
'; - $printContent = $printContent . '9884822189'; - $printContent = $printContent . 'https://www.xpyun.net'; - +// 继续生成剩余的 printContent +$printContent .= << +============================== +合计:{$total_price}元 +优惠:{$deduction_price}元 +实付款:{$pay_price}元 +支付方式:{$pay_type_name} +店铺电话:{$system_phone} +============================== + 欢迎下次光临!
+EOF; $request = new PrintRequest(); $request->generateSign(); @@ -81,7 +86,7 @@ EOF; //打印模式: //值为 0 或不指定则会检查打印机是否在线,如果不在线 则不生成打印订单,直接返回设备不在线状态码;如果在线则生成打印订单,并返回打印订单号。 //值为 1不检查打印机是否在线,直接生成打印订单,并返回打印订单号。如果打印机不在线,订单将缓存在打印队列中,打印机正常在线时会自动打印。 - $request->mode = 1; + $request->mode = 0; $result = $this->service->xpYunPrint($request); return $result->content; diff --git a/app/queue/redis/OrderXprinterPushSend.php b/app/queue/redis/OrderXprinterPushSend.php new file mode 100644 index 00000000..01cb86f6 --- /dev/null +++ b/app/queue/redis/OrderXprinterPushSend.php @@ -0,0 +1,73 @@ +find(); + $cart_info=StoreOrderCartInfo::where('oid',$order['id'])->select()->each(function($item){ + $find = StoreProduct::with('unitName')->withTrashed()->find(); + $item['store_name']=$find['store_name']; + return $item; + }); + + $product_arr=[]; + foreach ($cart_info as $k=>$v){ + $product_arr[]=[ + 'name'=>$v['name'], + 'price'=>$v['price'].'元', + 'quantity'=>$v['cart_num'], + 'subtotal'=>$v['total_price'].'元' + ]; + } + + $api=new XpsdkPrintApi(); + $order=[ + 'system_store'=>$SystemStore['name']??'', + 'system_phone'=>$SystemStore['phone']??'', + 'verify_code'=>$order['verify_code'], + 'order_id'=>$order['order_id'], + 'create_time'=>$pay_time, + 'pay_price'=>$pay_price, + 'total_price'=>$total_price, + 'deduction_price'=>$deduction_price, + 'pay_type_name'=>$pay_type, + 'product_arr'=>$product_arr + ]; + ($api->printFontAlign('74AMP5N6DP21148',$order)); + } + // 消费失败时 + public function onConsumeFailure(\Throwable $exception, $package) + { + $package['max_attempts'] = 0; + Log::error('推送订单失败', ['order_id' => $package['data'], 'error' => $package['error']]); + return true; + } +} From 2be22adcb324bf5162870e6fee97b82ee9769315 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Mon, 23 Dec 2024 18:12:15 +0800 Subject: [PATCH 05/38] =?UTF-8?q?fix(printer):=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E5=B0=8F=E7=A5=A8=E6=89=93=E5=8D=B0=E5=95=86=E5=93=81=E5=90=8D?= =?UTF-8?q?=E7=A7=B0=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 PayNotifyLogic 中添加 XpsdkPrintApi 类的引用 - 在 OrderXprinterPushSend 中修正商品名称的获取方式 - 优化代码格式和结构,提高可读性 --- app/common/logic/PayNotifyLogic.php | 2 + app/queue/redis/OrderXprinterPushSend.php | 70 +++++++++++------------ 2 files changed, 37 insertions(+), 35 deletions(-) diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index 52f6c5e8..9539d11c 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -32,6 +32,7 @@ use app\common\model\user_sign\UserSign; use app\common\model\vip_flow\VipFlow; use app\common\service\Curl; use app\common\service\PushService; +use app\common\service\xpyun\XpsdkPrintApi; use support\exception\BusinessException; use support\Log; use think\facade\Db; @@ -54,6 +55,7 @@ class PayNotifyLogic extends BaseLogic return true; } catch (\Exception $e) { Db::rollback(); + d($e); Log::error('支付回调处理失败' . $e->getMessage() . ',lien:' . $e->getLine() . ',file:' . $e->getFile()); throw new BusinessException($e->getMessage()); } diff --git a/app/queue/redis/OrderXprinterPushSend.php b/app/queue/redis/OrderXprinterPushSend.php index 01cb86f6..ec6682c1 100644 --- a/app/queue/redis/OrderXprinterPushSend.php +++ b/app/queue/redis/OrderXprinterPushSend.php @@ -25,43 +25,43 @@ class OrderXprinterPushSend implements Consumer public function consume($data) { - $order=$data['order']; - $total_price = $order['total_price']; - $pay_price = $order['pay_price']; - $deduction_price = $order['deduction_price']; - $pay_time = date('Y-m-d H:i:s', $order['pay_time']); - $pay_type = PayEnum::getPaySceneDesc($order['pay_type']); - $SystemStore = SystemStore::where('id', $order['store_id'])->find(); - $cart_info=StoreOrderCartInfo::where('oid',$order['id'])->select()->each(function($item){ - $find = StoreProduct::with('unitName')->withTrashed()->find(); - $item['store_name']=$find['store_name']; - return $item; - }); + $order = $data['order']; + $total_price = $order['total_price']; + $pay_price = $order['pay_price']; + $deduction_price = $order['deduction_price']; + $pay_time = date('Y-m-d H:i:s', $order['pay_time']); + $pay_type = PayEnum::getPaySceneDesc($order['pay_type']); + $SystemStore = SystemStore::where('id', $order['store_id'])->find(); + $cart_info = StoreOrderCartInfo::where('oid', $order['id'])->select()->each(function ($item) { + $find = StoreProduct::where('id', $item['product_id'])->withTrashed()->find(); + $item['store_name'] = $find['store_name']; + return $item; + }); - $product_arr=[]; - foreach ($cart_info as $k=>$v){ - $product_arr[]=[ - 'name'=>$v['name'], - 'price'=>$v['price'].'元', - 'quantity'=>$v['cart_num'], - 'subtotal'=>$v['total_price'].'元' - ]; - } - - $api=new XpsdkPrintApi(); - $order=[ - 'system_store'=>$SystemStore['name']??'', - 'system_phone'=>$SystemStore['phone']??'', - 'verify_code'=>$order['verify_code'], - 'order_id'=>$order['order_id'], - 'create_time'=>$pay_time, - 'pay_price'=>$pay_price, - 'total_price'=>$total_price, - 'deduction_price'=>$deduction_price, - 'pay_type_name'=>$pay_type, - 'product_arr'=>$product_arr + $product_arr = []; + foreach ($cart_info as $k => $v) { + $product_arr[] = [ + 'name' => $v['store_name'], + 'price' => $v['price'] . '元', + 'quantity' => $v['cart_num'], + 'subtotal' => $v['total_price'] . '元' ]; - ($api->printFontAlign('74AMP5N6DP21148',$order)); + } + + $api = new XpsdkPrintApi(); + $order = [ + 'system_store' => $SystemStore['name'] ?? '', + 'system_phone' => $SystemStore['phone'] ?? '', + 'verify_code' => $order['verify_code'], + 'order_id' => $order['order_id'], + 'create_time' => $pay_time, + 'pay_price' => $pay_price, + 'total_price' => $total_price, + 'deduction_price' => $deduction_price, + 'pay_type_name' => $pay_type, + 'product_arr' => $product_arr + ]; + $res = ($api->printFontAlign('74AMP5N6DP21148', $order)); } // 消费失败时 public function onConsumeFailure(\Throwable $exception, $package) From 5727572e0d7bb01036f5cd5aafc2bb3e1861b345 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Tue, 24 Dec 2024 09:07:25 +0800 Subject: [PATCH 06/38] =?UTF-8?q?fix(queue):=20=E4=BC=98=E5=8C=96=E5=B0=8F?= =?UTF-8?q?=E7=A5=A8=E6=89=93=E5=8D=B0=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 增加了 DictData 模型的引用 - 使用商店 ID 查询打印机配置,并在存在时使用该配置进行打印 --- app/queue/redis/OrderXprinterPushSend.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/queue/redis/OrderXprinterPushSend.php b/app/queue/redis/OrderXprinterPushSend.php index ec6682c1..7518e2d9 100644 --- a/app/queue/redis/OrderXprinterPushSend.php +++ b/app/queue/redis/OrderXprinterPushSend.php @@ -3,6 +3,7 @@ namespace app\queue\redis; use app\common\enum\PayEnum; +use app\common\model\dict\DictData; use app\common\model\store_order_cart_info\StoreOrderCartInfo; use app\common\model\store_product\StoreProduct; use app\common\model\system_store\SystemStore; @@ -61,7 +62,10 @@ class OrderXprinterPushSend implements Consumer 'pay_type_name' => $pay_type, 'product_arr' => $product_arr ]; - $res = ($api->printFontAlign('74AMP5N6DP21148', $order)); + $value=DictData::where('name','xprinter_'.$order['store_id'])->value('value'); + if($value){ + $res = ($api->printFontAlign($value, $order)); + } } // 消费失败时 public function onConsumeFailure(\Throwable $exception, $package) From 1f82805875dec4eb668804a29109b57488410edf Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Tue, 24 Dec 2024 09:27:39 +0800 Subject: [PATCH 07/38] =?UTF-8?q?fix(app):=20=E4=BF=AE=E5=A4=8D=E6=94=AF?= =?UTF-8?q?=E4=BB=98=E5=9B=9E=E8=B0=83=E5=92=8C=E8=AE=A2=E5=8D=95=E6=8E=A8?= =?UTF-8?q?=E9=80=81=E7=9A=84=E7=9B=B8=E5=85=B3=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修改 PayNotifyLogic 中异常捕获,使用 Throwable 代替 Exception - 优化 OrderXprinterPushSend 中的订单信息获取和处理 --- app/common/logic/PayNotifyLogic.php | 3 ++- app/queue/redis/OrderXprinterPushSend.php | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index 9539d11c..c91074ee 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -11,6 +11,7 @@ use app\common\enum\user\UserShipEnum; use app\common\enum\YesNoEnum; use app\common\logic\user_product_storage\UserProductStorageLogic; use app\common\model\Config; +use app\common\model\dict\DictData; use app\common\model\dict\DictType; use app\common\model\finance\CapitalFlow; use app\common\model\finance\PayNotifyLog; @@ -53,7 +54,7 @@ class PayNotifyLogic extends BaseLogic self::$action($orderSn, $extra, $type); Db::commit(); return true; - } catch (\Exception $e) { + } catch (\Throwable $e) { Db::rollback(); d($e); Log::error('支付回调处理失败' . $e->getMessage() . ',lien:' . $e->getLine() . ',file:' . $e->getFile()); diff --git a/app/queue/redis/OrderXprinterPushSend.php b/app/queue/redis/OrderXprinterPushSend.php index 7518e2d9..205f0907 100644 --- a/app/queue/redis/OrderXprinterPushSend.php +++ b/app/queue/redis/OrderXprinterPushSend.php @@ -29,6 +29,7 @@ class OrderXprinterPushSend implements Consumer $order = $data['order']; $total_price = $order['total_price']; $pay_price = $order['pay_price']; + $store_id = $order['store_id']; $deduction_price = $order['deduction_price']; $pay_time = date('Y-m-d H:i:s', $order['pay_time']); $pay_type = PayEnum::getPaySceneDesc($order['pay_type']); @@ -62,7 +63,7 @@ class OrderXprinterPushSend implements Consumer 'pay_type_name' => $pay_type, 'product_arr' => $product_arr ]; - $value=DictData::where('name','xprinter_'.$order['store_id'])->value('value'); + $value=DictData::where('name','xprinter_'.$store_id)->value('value'); if($value){ $res = ($api->printFontAlign($value, $order)); } From 71d861dd78775235cd8205028b55ecb7ffe30ede Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Tue, 24 Dec 2024 10:38:40 +0800 Subject: [PATCH 08/38] =?UTF-8?q?fix(purchase):=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E9=87=87=E8=B4=AD=E4=BB=B7=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 - 新增供货价计算步骤,作为商户价和零售价的基础 - 修改商户价和零售价的计算方式,基于供货价进行加成 - 优化价格配置的生成逻辑,确保各层级价格正确计算 --- .../PurchaseProductOfferLogic.php | 55 ++++++++++++------- 1 file changed, 34 insertions(+), 21 deletions(-) diff --git a/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php b/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php index 96cceca8..18a927b3 100644 --- a/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php +++ b/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php @@ -358,18 +358,29 @@ class PurchaseProductOfferLogic extends BaseLogic if (!empty($productCatePriceRate)) { $storeProductGroupPrice = StoreProductGroupPrice::where('product_id', $product['id'])->select()->toArray(); $storeProductGroupPrice = reset_index($storeProductGroupPrice, 'group_id'); - foreach ($productCatePriceRate as $k => $v) { - if ($v['id'] == 4) { - $data['cost_lv'] = bcdiv($v['rate'], 100, 2); - $data['cost'] = bcmul($params['purchase'], bcadd($data['cost_lv'], 1, 2), 2); - continue; - } elseif ($v['id'] == 100001) { + $purchase=0; + foreach ($storeProductGroupPrice as $k => $v) { + if ($v['id'] == 100001) { + //供货 $data['purchase_lv'] = bcdiv($v['rate'], 100, 2); $data['purchase'] = bcmul($params['purchase'], bcadd($data['purchase_lv'], 1, 2), 2); + $purchase=$data['purchase']; + break; + } + } + + foreach ($productCatePriceRate as $k => $v) { + if ($v['id'] == 4 &&$purchase>0) { + //商户 + $data['cost_lv'] = bcdiv($v['rate'], 100, 2); + $data['purchase_lv'] = bcdiv($v['rate'], 100, 2); + $purchase=bcmul($purchase, bcadd($data['purchase_lv'], 1, 2), 2); + $data['cost'] = bcmul($purchase, bcadd($data['cost_lv'], 1, 2), 2); continue; - } elseif ($v['id'] == 100002) { + }elseif ($v['id'] == 100002 &&$purchase>0) { + //零售 $data['price_lv'] = bcdiv($v['rate'], 100, 2); - $data['price'] = bcmul($params['purchase'], bcadd($data['price_lv'], 1, 2), 1); + $data['price'] = bcmul($purchase, bcadd($data['price_lv'], 1, 2), 1); if ($product['two_cate_id'] == 15268) { $lastNum = substr($data['price'], -1); if ($lastNum <= 2) { @@ -383,20 +394,22 @@ class PurchaseProductOfferLogic extends BaseLogic continue; } $baseRate = 100 + $v['rate']; - $item = [ - 'product_id' => $product['id'], - 'group_id' => $v['id'], - 'group_name' => $v['title'], - 'price' => bcmul($params['purchase'], $baseRate / 100, 2), - 'price_type' => 3, - 'base_rate' => $baseRate, - ]; - if (isset($storeProductGroupPrice[$v['id']])) { - $item['base_rate'] = $storeProductGroupPrice[$v['id']]['base_rate']; - $item['price'] = bcmul($params['purchase'], $item['base_rate'] / 100, 2); - $item['id'] = $storeProductGroupPrice[$v['id']]['id']; + if($purchase>0){ + $item = [ + 'product_id' => $product['id'], + 'group_id' => $v['id'], + 'group_name' => $v['title'], + 'price' => bcmul($purchase, $baseRate / 100, 2), + 'price_type' => 3, + 'base_rate' => $baseRate, + ]; + if (isset($storeProductGroupPrice[$v['id']])) { + $item['base_rate'] = $storeProductGroupPrice[$v['id']]['base_rate']; + $item['price'] = bcmul($purchase, $item['base_rate'] / 100, 2); + $item['id'] = $storeProductGroupPrice[$v['id']]['id']; + } + $priceConfig[] = $item; } - $priceConfig[] = $item; } } $data['price_config'] = $priceConfig; From b2a3df87c493418353485d7b4a30f7ec4227980a Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Tue, 24 Dec 2024 10:47:55 +0800 Subject: [PATCH 09/38] =?UTF-8?q?refactor(purchase=5Fproduct=5Foffer):=20?= =?UTF-8?q?=E9=87=8D=E6=9E=84=E9=87=87=E8=B4=AD=E4=BA=A7=E5=93=81=E6=8A=A5?= =?UTF-8?q?=E4=BB=B7=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 注释掉 ProductOffer::push($offer) 行,暂时不推送报价信息 - 在 catch 块中添加调试信息输出,便于排查错误 - 修复商户和供货商价格计算逻辑,优化价格计算过程 --- .../purchase_product_offer/PurchaseProductOfferLogic.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php b/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php index 18a927b3..28e67e5d 100644 --- a/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php +++ b/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php @@ -221,10 +221,11 @@ class PurchaseProductOfferLogic extends BaseLogic }else{ $offer['pay_type_name']='没设置'; } - ProductOffer::push($offer); + // ProductOffer::push($offer); return true; } catch (\Throwable $e) { Db::rollback(); + d($e); throw new BusinessException($e->getMessage()); } } @@ -359,7 +360,7 @@ class PurchaseProductOfferLogic extends BaseLogic $storeProductGroupPrice = StoreProductGroupPrice::where('product_id', $product['id'])->select()->toArray(); $storeProductGroupPrice = reset_index($storeProductGroupPrice, 'group_id'); $purchase=0; - foreach ($storeProductGroupPrice as $k => $v) { + foreach ($productCatePriceRate as $k => $v) { if ($v['id'] == 100001) { //供货 $data['purchase_lv'] = bcdiv($v['rate'], 100, 2); @@ -368,13 +369,10 @@ class PurchaseProductOfferLogic extends BaseLogic break; } } - foreach ($productCatePriceRate as $k => $v) { if ($v['id'] == 4 &&$purchase>0) { //商户 $data['cost_lv'] = bcdiv($v['rate'], 100, 2); - $data['purchase_lv'] = bcdiv($v['rate'], 100, 2); - $purchase=bcmul($purchase, bcadd($data['purchase_lv'], 1, 2), 2); $data['cost'] = bcmul($purchase, bcadd($data['cost_lv'], 1, 2), 2); continue; }elseif ($v['id'] == 100002 &&$purchase>0) { From 785a3a861559f3dc3be70444a870844828a868b6 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Tue, 24 Dec 2024 10:48:12 +0800 Subject: [PATCH 10/38] =?UTF-8?q?fix(app):=20=E4=BF=AE=E5=A4=8D=E8=B4=AD?= =?UTF-8?q?=E4=B9=B0=E4=BA=A7=E5=93=81=E4=BC=98=E6=83=A0=E6=97=B6=E7=9A=84?= =?UTF-8?q?=E6=94=AF=E4=BB=98=E7=B1=BB=E5=9E=8B=E5=90=8D=E7=A7=B0=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 移除了对 ProductOffer::push($offer) 的注释,恢复了该功能 - 优化了 PurchaseProductOfferLogic 中的逻辑,确保正确显示支付类型名称 --- .../logic/purchase_product_offer/PurchaseProductOfferLogic.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php b/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php index 28e67e5d..782f1c02 100644 --- a/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php +++ b/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php @@ -221,7 +221,7 @@ class PurchaseProductOfferLogic extends BaseLogic }else{ $offer['pay_type_name']='没设置'; } - // ProductOffer::push($offer); + ProductOffer::push($offer); return true; } catch (\Throwable $e) { Db::rollback(); From e48a8e5d7d9816cd3990aaf390a1a294e496010f Mon Sep 17 00:00:00 2001 From: lewis <604446095@qq.com> Date: Tue, 24 Dec 2024 15:18:51 +0800 Subject: [PATCH 11/38] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=B4=BB=E5=8A=A8?= =?UTF-8?q?=E4=B8=93=E5=8C=BA=E5=95=86=E5=93=81=E5=88=97=E8=A1=A8=E5=92=8C?= =?UTF-8?q?=E5=AF=BC=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ActivityZoneController.php | 7 - .../controller/ActivityZoneFormController.php | 98 ++++++++++++ app/admin/lists/ActivityZoneFormLists.php | 87 +++++++++++ app/admin/lists/ActivityZoneLists.php | 12 +- .../lists/store_product/StoreProductLists.php | 4 +- app/admin/logic/ActivityZoneFormLogic.php | 145 ++++++++++++++++++ app/admin/logic/ActivityZoneLogic.php | 27 +--- .../validate/ActivityZoneFormValidate.php | 89 +++++++++++ app/admin/validate/ActivityZoneValidate.php | 18 +-- app/common/model/ActivityZoneForm.php | 19 +++ .../service/xlsx/ActivityZoneService.php | 6 +- 11 files changed, 459 insertions(+), 53 deletions(-) create mode 100644 app/admin/controller/ActivityZoneFormController.php create mode 100644 app/admin/lists/ActivityZoneFormLists.php create mode 100644 app/admin/logic/ActivityZoneFormLogic.php create mode 100644 app/admin/validate/ActivityZoneFormValidate.php create mode 100644 app/common/model/ActivityZoneForm.php diff --git a/app/admin/controller/ActivityZoneController.php b/app/admin/controller/ActivityZoneController.php index 54f92700..00d406c9 100644 --- a/app/admin/controller/ActivityZoneController.php +++ b/app/admin/controller/ActivityZoneController.php @@ -91,11 +91,4 @@ class ActivityZoneController extends BaseAdminController return $this->data($result); } - public function export() - { - $params = $this->request->get(); - $file_path = ActivityZoneLogic::export($params); - return $this->success('导出成功', ['url' => $file_path]); - } - } \ No newline at end of file diff --git a/app/admin/controller/ActivityZoneFormController.php b/app/admin/controller/ActivityZoneFormController.php new file mode 100644 index 00000000..876ea116 --- /dev/null +++ b/app/admin/controller/ActivityZoneFormController.php @@ -0,0 +1,98 @@ +dataLists(new ActivityZoneFormLists()); + } + + + /** + * @notes 添加 + * @return \think\response\Json + * @author admin + * @date 2024/12/20 10:52 + */ + public function add() + { + $params = (new ActivityZoneFormValidate())->post()->goCheck('add'); + $result = ActivityZoneFormLogic::add($params); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(ActivityZoneFormLogic::getError()); + } + + + /** + * @notes 编辑 + * @return \think\response\Json + * @author admin + * @date 2024/12/20 10:52 + */ + public function edit() + { + $params = (new ActivityZoneFormValidate())->post()->goCheck('edit'); + $result = ActivityZoneFormLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(ActivityZoneFormLogic::getError()); + } + + + /** + * @notes 删除 + * @return \think\response\Json + * @author admin + * @date 2024/12/20 10:52 + */ + public function delete() + { + $params = (new ActivityZoneFormValidate())->post()->goCheck('delete'); + ActivityZoneFormLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取详情 + * @return \think\response\Json + * @author admin + * @date 2024/12/20 10:52 + */ + public function detail() + { + $params = (new ActivityZoneFormValidate())->goCheck('detail'); + $result = ActivityZoneFormLogic::detail($params); + return $this->data($result); + } + + public function export() + { + $params = $this->request->get(); + $file_path = ActivityZoneFormLogic::export($params); + return $this->success('导出成功', ['url' => $file_path]); + } + +} \ No newline at end of file diff --git a/app/admin/lists/ActivityZoneFormLists.php b/app/admin/lists/ActivityZoneFormLists.php new file mode 100644 index 00000000..2c12baf5 --- /dev/null +++ b/app/admin/lists/ActivityZoneFormLists.php @@ -0,0 +1,87 @@ + ['type'], + '%like%' => ['title'], + ]; + } + + + /** + * @notes 获取列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author admin + * @date 2024/12/20 10:52 + */ + public function lists(): array + { + $query = ActivityZoneForm::where($this->searchWhere); + $cateIds = []; + $list = $query + ->field(['id', 'type', 'cate_ids', 'title', 'remark']) + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select() + ->each(function ($item) use (&$cateIds) { + $item['cate_ids'] = explode(',', $item['cate_ids']); + foreach ($item['cate_ids'] as $cateId) { + if (!empty($cateId) && !in_array($cateId, $cateIds)) { + $cateIds[] = $cateId; + } + } + }) + ->toArray(); + $cateList = StoreCategory::where('id', 'in', $cateIds)->field('id,name')->select()->toArray(); + $cateList = reset_index($cateList, 'id'); + foreach ($list as &$item) { + $item['cate_names'] = []; + foreach ($item['cate_ids'] as $cateId) { + if (isset($cateList[$cateId])) { + $item['cate_names'][] = $cateList[$cateId]['name']; + } + } + $item['cate_names'] = implode(',', $item['cate_names']); + } + return $list; + } + + + /** + * @notes 获取数量 + * @return int + * @author admin + * @date 2024/12/20 10:52 + */ + public function count(): int + { + $query = ActivityZoneForm::where($this->searchWhere); + return $query->count(); + } + +} \ No newline at end of file diff --git a/app/admin/lists/ActivityZoneLists.php b/app/admin/lists/ActivityZoneLists.php index 16a5d401..2a883a86 100644 --- a/app/admin/lists/ActivityZoneLists.php +++ b/app/admin/lists/ActivityZoneLists.php @@ -28,7 +28,7 @@ class ActivityZoneLists extends BaseAdminDataLists implements ListsSearchInterfa public function setSearch(): array { return [ - '=' => ['type'], + '=' => ['form_id'], ]; } @@ -45,12 +45,12 @@ class ActivityZoneLists extends BaseAdminDataLists implements ListsSearchInterfa public function lists(): array { $query = ActivityZone::where($this->searchWhere); - if (!empty($this->params['keyword'])) { - $productIds = StoreProduct::where('store_name', 'like', "%{$this->params['keyword']}%")->column('id'); + if (!empty($this->params['store_name'])) { + $productIds = StoreProduct::where('store_name', 'like', "%{$this->params['store_name']}%")->column('id'); $query->whereIn('product_id', $productIds); } $list = $query->with('product') - ->field(['id', 'type', 'product_id']) + ->field(['id', 'form_id', 'product_id']) ->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) ->select() @@ -74,8 +74,8 @@ class ActivityZoneLists extends BaseAdminDataLists implements ListsSearchInterfa public function count(): int { $query = ActivityZone::where($this->searchWhere); - if (!empty($this->params['keyword'])) { - $productIds = StoreProduct::where('store_name', 'like', "%{$this->params['keyword']}%")->column('id'); + if (!empty($this->params['store_name'])) { + $productIds = StoreProduct::where('store_name', 'like', "%{$this->params['store_name']}%")->column('id'); $query->whereIn('product_id', $productIds); } return $query->count(); diff --git a/app/admin/lists/store_product/StoreProductLists.php b/app/admin/lists/store_product/StoreProductLists.php index 9b7c897f..3bfcd58e 100644 --- a/app/admin/lists/store_product/StoreProductLists.php +++ b/app/admin/lists/store_product/StoreProductLists.php @@ -81,8 +81,8 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa $query->where('is_show', 1); } } - if (!empty($this->params['activity_zone_type'])) { - $exceptIds = ActivityZone::where('type', $this->params['activity_zone_type'])->column('product_id'); + if (!empty($this->params['activity_zone_form_id'])) { + $exceptIds = ActivityZone::where('form_id', $this->params['activity_zone_form_id'])->column('product_id'); $query->where('is_show', 1)->where('product_type', '<>', 5)->whereNotIn('id', $exceptIds); } $list = $query->limit($this->limitOffset, $this->limitLength) diff --git a/app/admin/logic/ActivityZoneFormLogic.php b/app/admin/logic/ActivityZoneFormLogic.php new file mode 100644 index 00000000..5f76614a --- /dev/null +++ b/app/admin/logic/ActivityZoneFormLogic.php @@ -0,0 +1,145 @@ +save($params); + $productIds = StoreProduct::where('two_cate_id', 'in', $secondCateIds)->whereOr('cate_id', 'in', $thirdCateIds)->column('id'); + $productInfo = []; + $time = time(); + foreach ($productIds as $productId) { + $productInfo[] = [ + 'product_id' => $productId, + 'form_id' => $activityZoneForm->id, + 'create_time' => $time, + 'update_time' => $time, + ]; + } + if (!empty($productInfo)) { + ActivityZone::insertAll($productInfo); + } + + Db::commit(); + return true; + } catch (\Throwable $e) { + Db::rollback(); + throw new BusinessException($e->getMessage()); + } + } + + + /** + * @notes 编辑 + * @param array $params + * @return bool + * @author admin + * @date 2024/12/20 10:52 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + ActivityZoneForm::where('id', $params['id'])->update([ + 'type' => $params['type'], + 'product_id' => $params['product_id'], + ]); + + Db::commit(); + return true; + } catch (\Throwable $e) { + Db::rollback(); + throw new BusinessException($e->getMessage()); + } + } + + + /** + * @notes 删除 + * @param array $params + * @return bool + * @author admin + * @date 2024/12/20 10:52 + */ + public static function delete(array $params): bool + { + return ActivityZoneForm::destroy($params['id']); + } + + + /** + * @notes 获取详情 + * @param $params + * @return array + * @author admin + * @date 2024/12/20 10:52 + */ + public static function detail($params): array + { + return ActivityZoneForm::findOrEmpty($params['id'])->toArray(); + } + + public static function export($params) + { + $service = new ActivityZoneService(); + $activityZoneForm = ActivityZoneForm::findOrEmpty($params['id'])->toArray(); + $products = ActivityZone::with('product')->field('id,product_id')->where('form_id', $params['id'])->select()->toArray(); + $unitIds = array_unique(array_column($products, 'unit')); + $unit = StoreProductUnit::whereIn('id', $unitIds)->field('id,name')->withTrashed()->select()->toArray(); + $unit = reset_index($unit, 'id'); + foreach ($products as &$item) { + $item['unit_name'] = $unit[$item['unit']]['name'] ?? ''; + unset($item['unit'], $item['product_id']); + } + $data = ConfigLogic::getDictByType('activity_zone'); + foreach ($data['activity_zone'] as $value) { + if ($value['value'] == $activityZoneForm['type']) { + $typeName = $value['remark']; + break; + } + } + return $service->export($products, $activityZoneForm['title'], $typeName ?? '', $activityZoneForm['remark']); + } + +} \ No newline at end of file diff --git a/app/admin/logic/ActivityZoneLogic.php b/app/admin/logic/ActivityZoneLogic.php index a5425ee0..5f4eec89 100644 --- a/app/admin/logic/ActivityZoneLogic.php +++ b/app/admin/logic/ActivityZoneLogic.php @@ -5,8 +5,6 @@ namespace app\admin\logic; use app\common\model\ActivityZone; use app\common\logic\BaseLogic; -use app\common\model\store_product_unit\StoreProductUnit; -use app\common\service\xlsx\ActivityZoneService; use support\exception\BusinessException; use think\facade\Db; @@ -35,7 +33,7 @@ class ActivityZoneLogic extends BaseLogic $time = time(); foreach ($params['product_ids'] as $product_id) { $insert[] = [ - 'type' => $params['type'], + 'form_id' => $params['form_id'], 'product_id' => $product_id, 'create_time' => $time, 'update_time' => $time, @@ -64,7 +62,7 @@ class ActivityZoneLogic extends BaseLogic Db::startTrans(); try { ActivityZone::where('id', $params['id'])->update([ - 'type' => $params['type'], + 'form_id' => $params['form_id'], 'product_id' => $params['product_id'], ]); @@ -102,25 +100,4 @@ class ActivityZoneLogic extends BaseLogic return ActivityZone::findOrEmpty($params['id'])->toArray(); } - public static function export($params) - { - $service = new ActivityZoneService(); - $products = ActivityZone::with('product')->field('id,product_id,type')->where('type', $params['type'])->select()->toArray(); - $unitIds = array_unique(array_column($products, 'unit')); - $unit = StoreProductUnit::whereIn('id', $unitIds)->field('id,name')->withTrashed()->select()->toArray(); - $unit = reset_index($unit, 'id'); - foreach ($products as &$item) { - $item['unit_name'] = $unit[$item['unit']]['name'] ?? ''; - unset($item['unit'], $item['product_id']); - } - $data = ConfigLogic::getDictByType('activity_zone'); - foreach ($data['activity_zone'] as $value) { - if ($value['value'] == $params['type']) { - $typeName = $value['remark']; - break; - } - } - return $service->export($products, $typeName ?? '', $params['remark']); - } - } \ No newline at end of file diff --git a/app/admin/validate/ActivityZoneFormValidate.php b/app/admin/validate/ActivityZoneFormValidate.php new file mode 100644 index 00000000..697f7cfd --- /dev/null +++ b/app/admin/validate/ActivityZoneFormValidate.php @@ -0,0 +1,89 @@ + 'require', + 'type' => 'require', + 'title' => 'require', + 'cate_ids' => 'require', + 'remark' => 'string', + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + 'type' => '类型', + 'product_ids' => '商品', + + ]; + + + /** + * @notes 添加场景 + * @return ActivityZoneValidate + * @author admin + * @date 2024/12/20 10:52 + */ + public function sceneAdd() + { + return $this->only(['type', 'title', 'cate_ids']); + } + + + /** + * @notes 编辑场景 + * @return ActivityZoneValidate + * @author admin + * @date 2024/12/20 10:52 + */ + public function sceneEdit() + { + return $this->only(['id', 'type', 'title', 'cate_ids']); + } + + + /** + * @notes 删除场景 + * @return ActivityZoneValidate + * @author admin + * @date 2024/12/20 10:52 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return ActivityZoneValidate + * @author admin + * @date 2024/12/20 10:52 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + +} \ No newline at end of file diff --git a/app/admin/validate/ActivityZoneValidate.php b/app/admin/validate/ActivityZoneValidate.php index eeb3621c..cb9cc65e 100644 --- a/app/admin/validate/ActivityZoneValidate.php +++ b/app/admin/validate/ActivityZoneValidate.php @@ -14,15 +14,14 @@ use app\common\validate\BaseValidate; class ActivityZoneValidate extends BaseValidate { - /** - * 设置校验规则 - * @var string[] - */ + /** + * 设置校验规则 + * @var string[] + */ protected $rule = [ 'id' => 'require', - 'type' => 'require', + 'form_id' => 'require', 'product_ids' => 'require', - ]; @@ -32,9 +31,8 @@ class ActivityZoneValidate extends BaseValidate */ protected $field = [ 'id' => 'id', - 'type' => '类型', + 'form_id' => '表单', 'product_ids' => '商品', - ]; @@ -46,7 +44,7 @@ class ActivityZoneValidate extends BaseValidate */ public function sceneAdd() { - return $this->only(['type','product_ids']); + return $this->only(['form_id', 'product_ids']); } @@ -58,7 +56,7 @@ class ActivityZoneValidate extends BaseValidate */ public function sceneEdit() { - return $this->only(['id','type','product_ids']); + return $this->only(['id', 'form_id', 'product_ids']); } diff --git a/app/common/model/ActivityZoneForm.php b/app/common/model/ActivityZoneForm.php new file mode 100644 index 00000000..ab50bf52 --- /dev/null +++ b/app/common/model/ActivityZoneForm.php @@ -0,0 +1,19 @@ +getActiveSheet(); @@ -26,7 +26,7 @@ class ActivityZoneService $sheet->mergeCells('A5:F5'); $sheet->mergeCells('B6:C6'); - $sheet->setCellValue('A1', "供 投 里 海 农 特 产 品 下 单 清 单({$typeName})"); + $sheet->setCellValue('A1', $title); $sheet->setCellValue('A2', '姓名:'); $sheet->setCellValue('C2', '电话:'); $sheet->setCellValue('E2', '会员角色:'); @@ -103,7 +103,7 @@ class ActivityZoneService $sheet->getStyle('A1:F' . ($count + 9))->applyFromArray($styleArray); $writer = new Xlsx($spreadsheet); - $url = '/export/' . date('Y-m') . "/供投里海农特产品下单清单({$typeName})" . date('YmdHi') . '.xlsx'; + $url = '/export/' . date('Y-m') . $title . date('YmdHi') . '.xlsx'; $file_path = public_path() . $url; if (!is_dir(dirname($file_path))) { mkdir(dirname($file_path), 0777, true); From c6941df7cc7b5572018dd579f1e7c88b42dcd9bb Mon Sep 17 00:00:00 2001 From: lewis <604446095@qq.com> Date: Tue, 24 Dec 2024 16:41:45 +0800 Subject: [PATCH 12/38] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=B4=BB=E5=8A=A8?= =?UTF-8?q?=E4=B8=93=E5=8C=BA=E5=95=86=E5=93=81=E5=88=97=E8=A1=A8=E5=AF=BC?= =?UTF-8?q?=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/service/xlsx/ActivityZoneService.php | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/app/common/service/xlsx/ActivityZoneService.php b/app/common/service/xlsx/ActivityZoneService.php index f0d0b6b8..8971f3fa 100644 --- a/app/common/service/xlsx/ActivityZoneService.php +++ b/app/common/service/xlsx/ActivityZoneService.php @@ -74,14 +74,10 @@ class ActivityZoneService } $count = count($data); $sheet->mergeCells('A' . ($count + 7) . ':F' . ($count + 7)); - $sheet->setCellValue('A' . ($count + 7), "专区类型:{$typeName}"); - $sheet->mergeCells('A' . ($count + 8) . ':F' . ($count + 8)); - $sheet->setCellValue('A' . ($count + 8), ""); - $sheet->mergeCells('A' . ($count + 9) . ':F' . ($count + 9)); - $sheet->setCellValue('A' . ($count + 9), "备注:{$remark}"); - $sheet->getRowDimension($count + 9)->setRowHeight(50); - $sheet->getStyle('A' . ($count + 9))->getAlignment()->setWrapText(true); - $sheet->getStyle('A' . ($count + 7). ':' . 'F' . ($count + 9))->applyFromArray($leftStyle); + $sheet->setCellValue('A' . ($count + 7), "备注:{$remark}"); + $sheet->getRowDimension($count + 7)->setRowHeight(50); + $sheet->getStyle('A' . ($count + 7))->getAlignment()->setWrapText(true); + $sheet->getStyle('A' . ($count + 7). ':' . 'F' . ($count + 7))->applyFromArray($leftStyle); // 设置单元格的样式 $styleArray = [ From a316fe15cc5f2c518e86513348be4b2fc93b4673 Mon Sep 17 00:00:00 2001 From: lewis <604446095@qq.com> Date: Tue, 24 Dec 2024 16:42:29 +0800 Subject: [PATCH 13/38] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=B4=BB=E5=8A=A8?= =?UTF-8?q?=E4=B8=93=E5=8C=BA=E5=95=86=E5=93=81=E5=88=97=E8=A1=A8=E5=AF=BC?= =?UTF-8?q?=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/service/xlsx/ActivityZoneService.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/common/service/xlsx/ActivityZoneService.php b/app/common/service/xlsx/ActivityZoneService.php index 8971f3fa..c936df08 100644 --- a/app/common/service/xlsx/ActivityZoneService.php +++ b/app/common/service/xlsx/ActivityZoneService.php @@ -96,7 +96,7 @@ class ActivityZoneService ], ], ]; - $sheet->getStyle('A1:F' . ($count + 9))->applyFromArray($styleArray); + $sheet->getStyle('A1:F' . ($count + 7))->applyFromArray($styleArray); $writer = new Xlsx($spreadsheet); $url = '/export/' . date('Y-m') . $title . date('YmdHi') . '.xlsx'; From f265a07cd5bb430b434dab81edb568fe076743f2 Mon Sep 17 00:00:00 2001 From: lewis <604446095@qq.com> Date: Tue, 24 Dec 2024 16:54:00 +0800 Subject: [PATCH 14/38] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=B4=BB=E5=8A=A8?= =?UTF-8?q?=E4=B8=93=E5=8C=BA=E5=95=86=E5=93=81=E5=88=97=E8=A1=A8=E5=AF=BC?= =?UTF-8?q?=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/logic/ActivityZoneFormLogic.php | 2 +- app/common/service/xlsx/ActivityZoneService.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/admin/logic/ActivityZoneFormLogic.php b/app/admin/logic/ActivityZoneFormLogic.php index 5f76614a..56a1c170 100644 --- a/app/admin/logic/ActivityZoneFormLogic.php +++ b/app/admin/logic/ActivityZoneFormLogic.php @@ -130,7 +130,7 @@ class ActivityZoneFormLogic extends BaseLogic $unit = reset_index($unit, 'id'); foreach ($products as &$item) { $item['unit_name'] = $unit[$item['unit']]['name'] ?? ''; - unset($item['unit'], $item['product_id']); + unset($item['unit'], $item['id']); } $data = ConfigLogic::getDictByType('activity_zone'); foreach ($data['activity_zone'] as $value) { diff --git a/app/common/service/xlsx/ActivityZoneService.php b/app/common/service/xlsx/ActivityZoneService.php index c936df08..53a0b178 100644 --- a/app/common/service/xlsx/ActivityZoneService.php +++ b/app/common/service/xlsx/ActivityZoneService.php @@ -68,7 +68,7 @@ class ActivityZoneService foreach ($data as $k => $v) { $column = $k + 7; $sheet->mergeCells("B{$column}:C{$column}"); - $sheet->setCellValue('A' . ($k + 7), $v['id']); + $sheet->setCellValue('A' . ($k + 7), $v['product_id']); $sheet->setCellValue("B{$column}", $v['store_name']); $sheet->setCellValue("D{$column}", $v['unit_name']); } From ed01ef1b9a833bb654b804111e6683ff2802929f Mon Sep 17 00:00:00 2001 From: lewis <604446095@qq.com> Date: Tue, 24 Dec 2024 17:32:49 +0800 Subject: [PATCH 15/38] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=B4=BB=E5=8A=A8?= =?UTF-8?q?=E4=B8=93=E5=8C=BA=E5=95=86=E5=93=81=E5=88=97=E8=A1=A8=E5=AF=BC?= =?UTF-8?q?=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/logic/ActivityZoneFormLogic.php | 31 ++++++++------- .../service/xlsx/ActivityZoneService.php | 39 ++++++++++++------- 2 files changed, 42 insertions(+), 28 deletions(-) diff --git a/app/admin/logic/ActivityZoneFormLogic.php b/app/admin/logic/ActivityZoneFormLogic.php index 56a1c170..c8854679 100644 --- a/app/admin/logic/ActivityZoneFormLogic.php +++ b/app/admin/logic/ActivityZoneFormLogic.php @@ -6,6 +6,7 @@ namespace app\admin\logic; use app\common\model\ActivityZone; use app\common\logic\BaseLogic; use app\common\model\ActivityZoneForm; +use app\common\model\store_category\StoreCategory; use app\common\model\store_product\StoreProduct; use app\common\model\store_product_unit\StoreProductUnit; use app\common\service\xlsx\ActivityZoneService; @@ -46,12 +47,12 @@ class ActivityZoneFormLogic extends BaseLogic $params['cate_ids'] = !empty($cateIds) ? implode(',', $cateIds) : ''; $activityZoneForm = new ActivityZoneForm(); $activityZoneForm->save($params); - $productIds = StoreProduct::where('two_cate_id', 'in', $secondCateIds)->whereOr('cate_id', 'in', $thirdCateIds)->column('id'); + $products = StoreProduct::field('id,two_cate_id,cate_id')->where('two_cate_id', 'in', $secondCateIds)->whereOr('cate_id', 'in', $thirdCateIds)->select()->toArray(); $productInfo = []; $time = time(); - foreach ($productIds as $productId) { + foreach ($products as $product) { $productInfo[] = [ - 'product_id' => $productId, + 'product_id' => $product['id'], 'form_id' => $activityZoneForm->id, 'create_time' => $time, 'update_time' => $time, @@ -124,22 +125,24 @@ class ActivityZoneFormLogic extends BaseLogic { $service = new ActivityZoneService(); $activityZoneForm = ActivityZoneForm::findOrEmpty($params['id'])->toArray(); - $products = ActivityZone::with('product')->field('id,product_id')->where('form_id', $params['id'])->select()->toArray(); + $productIds = ActivityZone::where('form_id', $params['id'])->column('product_id'); + $products = StoreProduct::field('id,unit,store_name,two_cate_id')->whereIn('id', $productIds)->order('two_cate_id')->select()->toArray(); $unitIds = array_unique(array_column($products, 'unit')); + $cateIds = array_unique(array_column($products, 'two_cate_id')); $unit = StoreProductUnit::whereIn('id', $unitIds)->field('id,name')->withTrashed()->select()->toArray(); + $categories = StoreCategory::whereIn('id', $cateIds)->field('id,name')->withTrashed()->select()->toArray(); $unit = reset_index($unit, 'id'); - foreach ($products as &$item) { - $item['unit_name'] = $unit[$item['unit']]['name'] ?? ''; - unset($item['unit'], $item['id']); - } - $data = ConfigLogic::getDictByType('activity_zone'); - foreach ($data['activity_zone'] as $value) { - if ($value['value'] == $activityZoneForm['type']) { - $typeName = $value['remark']; - break; + $categories = reset_index($categories, 'id'); + $data = []; + foreach ($products as $item) { + $currentCate = $categories[$item['two_cate_id']]['name'] ?? ''; + if (!empty($currentCate)) { + $item['unit_name'] = $unit[$item['unit']]['name'] ?? ''; + unset($item['unit'], $item['two_cate_id']); + $data[$currentCate][] = $item; } } - return $service->export($products, $activityZoneForm['title'], $typeName ?? '', $activityZoneForm['remark']); + return $service->export($data, $activityZoneForm['title'], $activityZoneForm['remark']); } } \ No newline at end of file diff --git a/app/common/service/xlsx/ActivityZoneService.php b/app/common/service/xlsx/ActivityZoneService.php index 53a0b178..d3ae3f3b 100644 --- a/app/common/service/xlsx/ActivityZoneService.php +++ b/app/common/service/xlsx/ActivityZoneService.php @@ -9,7 +9,7 @@ use PhpOffice\PhpSpreadsheet\Style\Alignment; class ActivityZoneService { - public function export($data, $title, $typeName, $remark) + public function export($data, $title, $remark) { $spreadsheet = new Spreadsheet(); $sheet = $spreadsheet->getActiveSheet(); @@ -65,19 +65,30 @@ class ActivityZoneService // 应用默认样式到A2:F5 $sheet->getStyle('A2:F5')->applyFromArray($leftStyle); - foreach ($data as $k => $v) { - $column = $k + 7; - $sheet->mergeCells("B{$column}:C{$column}"); - $sheet->setCellValue('A' . ($k + 7), $v['product_id']); - $sheet->setCellValue("B{$column}", $v['store_name']); - $sheet->setCellValue("D{$column}", $v['unit_name']); + $column = 7; + foreach ($data as $k => $item) { + $sheet->mergeCells("A{$column}:F{$column}"); + $sheet->setCellValue('A' . $column, $k); + $sheet->getStyle('A' . $column)->applyFromArray([ + 'font' => [ + 'bold' => true, + 'size' => 16, + ], + ]); + $column++; + foreach ($item as $value) { + $sheet->mergeCells("B{$column}:C{$column}"); + $sheet->setCellValue('A' . $column, $value['id']); + $sheet->setCellValue("B{$column}", $value['store_name']); + $sheet->setCellValue("D{$column}", $value['unit_name']); + $column++; + } } - $count = count($data); - $sheet->mergeCells('A' . ($count + 7) . ':F' . ($count + 7)); - $sheet->setCellValue('A' . ($count + 7), "备注:{$remark}"); - $sheet->getRowDimension($count + 7)->setRowHeight(50); - $sheet->getStyle('A' . ($count + 7))->getAlignment()->setWrapText(true); - $sheet->getStyle('A' . ($count + 7). ':' . 'F' . ($count + 7))->applyFromArray($leftStyle); + $sheet->mergeCells('A' . $column . ':F' . $column); + $sheet->setCellValue('A' . $column, "备注:{$remark}"); + $sheet->getRowDimension($column)->setRowHeight(50); + $sheet->getStyle('A' . $column)->getAlignment()->setWrapText(true); + $sheet->getStyle('A' . $column. ':' . 'F' . $column)->applyFromArray($leftStyle); // 设置单元格的样式 $styleArray = [ @@ -96,7 +107,7 @@ class ActivityZoneService ], ], ]; - $sheet->getStyle('A1:F' . ($count + 7))->applyFromArray($styleArray); + $sheet->getStyle('A1:F' . $column)->applyFromArray($styleArray); $writer = new Xlsx($spreadsheet); $url = '/export/' . date('Y-m') . $title . date('YmdHi') . '.xlsx'; From 77a1969ceb70dfb0982b4fd0f46b4f8f2eea292c Mon Sep 17 00:00:00 2001 From: lewis <604446095@qq.com> Date: Wed, 25 Dec 2024 11:38:11 +0800 Subject: [PATCH 16/38] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=87=87=E8=B4=AD?= =?UTF-8?q?=E5=8D=95=E7=94=9F=E6=88=90=E8=A7=84=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../purchase_product_offer/PurchaseProductOfferLogic.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php b/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php index 782f1c02..7ba297bd 100644 --- a/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php +++ b/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php @@ -41,7 +41,11 @@ class PurchaseProductOfferLogic extends BaseLogic { Db::startTrans(); try { - $procurementOrder = BeforehandOrder::where('order_type', 7)->where('buyer_id', $params['buyer_id'])->where('is_buying', 0)->where('create_time', '>=', strtotime('-3 days'))->find(); + $procurementOrder = BeforehandOrder::where('order_type', 7) + ->where('buyer_id', $params['buyer_id']) + ->where('is_buying', 0) + ->where('create_time', '>=', strtotime('today')) + ->find(); if (empty($procurementOrder)) { $procurementOrder = new BeforehandOrder(); $procurementOrder->order_id = getNewOrderId('CG'); From 04b98e4b63869656719aa671ee43bd2a5d717f70 Mon Sep 17 00:00:00 2001 From: lewis <604446095@qq.com> Date: Wed, 25 Dec 2024 14:10:28 +0800 Subject: [PATCH 17/38] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=88=86=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/LocalController.php | 42 +++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/app/admin/controller/LocalController.php b/app/admin/controller/LocalController.php index bcb506ab..485cd662 100644 --- a/app/admin/controller/LocalController.php +++ b/app/admin/controller/LocalController.php @@ -10,7 +10,47 @@ use support\Redis; class LocalController extends BaseAdminController { - public $notNeedLogin = ['index']; + public $notNeedLogin = []; + + public function fixCategory() + { + $topCate = StoreCategory::where('pid', 0)->field('id,name,pid')->order('name')->select()->toArray(); + $topCate = reset_index($topCate, 'name'); + $sql = []; + $time = time(); + foreach ($topCate as $item) { + if (isset($topCate[$item['name'] . '类'])) { + $target = $topCate[$item['name'] . '类']; + $sql[] = "##原分类id:{$item['id']},原分类名:{$item['name']},目标分类id:{$target['id']},目标分类名:{$target['name']}"; + $sql[] = "update la_store_product set top_cate_id={$target['id']} where top_cate_id={$item['id']};"; + $sql[] = "update la_store_product set two_cate_id={$target['id']} where two_cate_id={$item['id']};"; + $sql[] = "update la_store_category set delete_time=$time where id={$item['id']};"; + } + $secondCate = StoreCategory::where('pid', $item['id'])->field('id,name,pid')->order('name')->select()->toArray(); + $secondCate = reset_index($secondCate, 'name'); + foreach ($secondCate as $item2) { + if (isset($secondCate[$item2['name'] . '类'])) { + $target = $secondCate[$item2['name'] . '类']; + $sql[] = "##原分类id:{$item2['id']},原分类名:{$item2['name']},目标分类id:{$target['id']},目标分类名:{$target['name']}"; + $sql[] = "update la_store_product set two_cate_id={$target['id']} where two_cate_id={$item2['id']};"; + $sql[] = "update la_store_product set cate_id={$target['id']} where cate_id={$item2['id']};"; + $sql[] = "update la_store_category set delete_time=$time where id={$item2['id']};"; + } + $thirdCate = StoreCategory::where('pid', $item2['id'])->field('id,name,pid')->order('name')->select()->toArray(); + $thirdCate = reset_index($thirdCate, 'name'); + foreach ($thirdCate as $item3) { + if (isset($thirdCate[$item3['name'] . '类'])) { + $target = $thirdCate[$item3['name'] . '类']; + $sql[] = "##原分类id:{$item3['id']},原分类名:{$item3['name']},目标分类id:{$target['id']},目标分类名:{$target['name']}"; + $sql[] = "update la_store_product set cate_id={$target['id']} where cate_id={$item3['id']};"; + $sql[] = "update la_store_category set delete_time=$time where id={$item3['id']};"; + } + } + } + } + file_put_contents(public_path() . '/update.sql', implode(PHP_EOL, $sql)); + return $this->success('数据已更新完成', $sql); + } public function index() { From e063fcfe7f6c1875911b1250a6bb214b153b1d54 Mon Sep 17 00:00:00 2001 From: lewis <604446095@qq.com> Date: Wed, 25 Dec 2024 15:18:34 +0800 Subject: [PATCH 18/38] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=88=86=E7=BB=84?= =?UTF-8?q?=E4=BB=B7=E6=A0=BC=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../store_product_group_price/StoreProductGroupPriceLogic.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/admin/logic/store_product_group_price/StoreProductGroupPriceLogic.php b/app/admin/logic/store_product_group_price/StoreProductGroupPriceLogic.php index 53907af9..a9ac145d 100644 --- a/app/admin/logic/store_product_group_price/StoreProductGroupPriceLogic.php +++ b/app/admin/logic/store_product_group_price/StoreProductGroupPriceLogic.php @@ -105,7 +105,7 @@ class StoreProductGroupPriceLogic extends BaseLogic { $arr=StoreProductGroupPrice::where('product_id',$params['product_id'])->select()->toArray(); $purchase=StoreProduct::where('id',$params['product_id'])->value('purchase'); - $arr_two=UserShip::where('id','>',4)->select()->toArray(); + $arr_two=UserShip::where('id','>',0)->select()->toArray(); $arr_two[] = ['id' => 100001, 'title' => '供货价']; $arr_two[] = ['id' => 100002, 'title' => '零售价']; foreach ($arr_two as $k=>$v){ From e722c1a77326f8fdbab7280d9ee9142971c2951a Mon Sep 17 00:00:00 2001 From: lewis <604446095@qq.com> Date: Wed, 25 Dec 2024 17:55:53 +0800 Subject: [PATCH 19/38] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=B0=8F=E7=A8=8B?= =?UTF-8?q?=E5=BA=8F=E7=AB=AF=E6=8F=90=E4=BA=A4=E9=87=87=E8=B4=AD=E4=BF=A1?= =?UTF-8?q?=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PurchaseProductOfferController.php | 28 ++++++++-------- .../PurchaseProductOfferLists.php | 33 ++++++++++++------- .../PurchaseProductOffer.php | 6 ++++ 3 files changed, 42 insertions(+), 25 deletions(-) diff --git a/app/api/controller/purchase_product_offer/PurchaseProductOfferController.php b/app/api/controller/purchase_product_offer/PurchaseProductOfferController.php index 67f07da1..3261ab5a 100644 --- a/app/api/controller/purchase_product_offer/PurchaseProductOfferController.php +++ b/app/api/controller/purchase_product_offer/PurchaseProductOfferController.php @@ -3,6 +3,8 @@ namespace app\api\controller\purchase_product_offer; +use app\admin\lists\supplier\SupplierLists; +use app\admin\logic\purchase_product_offer\PurchaseProductOfferLogic; use app\api\lists\purchase_product_offer\PurchaseProductOfferLists; use app\api\controller\BaseApiController; use app\common\model\dict\DictData; @@ -34,21 +36,14 @@ class PurchaseProductOfferController extends BaseApiController * 提交采购信息 */ public function offer_update(){ - $params=$this->request->post(); - $data=[ - 'buyer_nums'=>$params['nums'], - 'price'=>$params['price'], - 'outbound_price'=>$params['outbound_price'], - 'total_price'=>$params['total_price'], - 'buyer_confirm'=>1, - 'pay_type'=>$params['pay_type']??0, - ]; - $res=PurchaseProductOffer::where('id',$params['id'])->where('buyer_id',$this->userId)->update($data); - if($res){ - return $this->success('提交成功'); - }else{ - return $this->fail('提交失败'); + + $params = $this->request->post(); + if($params['supplier_id']=='' ||$params['supplier_id']<=0){ + return $this->fail('请选择供应商'); } + $params['admin_id']=0; + PurchaseProductOfferLogic::setProcureInfo($params); + return $this->success('设置成功', [], 1, 1); } /** @@ -64,4 +59,9 @@ class PurchaseProductOfferController extends BaseApiController return $this->success('ok',$data); } + public function supplier() + { + return $this->dataLists(new SupplierLists()); + } + } \ No newline at end of file diff --git a/app/api/lists/purchase_product_offer/PurchaseProductOfferLists.php b/app/api/lists/purchase_product_offer/PurchaseProductOfferLists.php index 17f7f7ff..88a0faad 100644 --- a/app/api/lists/purchase_product_offer/PurchaseProductOfferLists.php +++ b/app/api/lists/purchase_product_offer/PurchaseProductOfferLists.php @@ -10,6 +10,7 @@ use app\common\model\store_product\StoreProduct; use app\common\model\store_product_unit\StoreProductUnit; use app\api\lists\BaseApiDataLists; use app\common\model\store_category\StoreCategory; +use app\common\model\supplier\Supplier; /** * 采购供应链商品列表 @@ -49,17 +50,16 @@ class PurchaseProductOfferLists extends BaseApiDataLists implements ListsSearchI }else{ return []; } - return PurchaseProductOffer::where($this->searchWhere) - ->field(['id', 'order_id', 'product_id', 'price', 'buyer_nums', 'unit', 'is_buyer', 'buyer_confirm','need_num', 'buyer_id', 'status', 'mark','update_time']) + $cateIds = []; + $list = PurchaseProductOffer::where($this->searchWhere) + ->with('product') + ->field(['id', 'order_id', 'product_id', 'price', 'total_price', 'buyer_nums', 'unit', 'is_buyer', 'buyer_confirm','need_num', 'buyer_id', 'status', 'mark','update_time', 'supplier_id', 'package', 'store_info', 'marques', 'after_sales', 'pay_type']) ->limit($this->limitOffset, $this->limitLength) - ->order(['product_id'=>'desc','id' => 'desc']) - ->select()->each(function($item){ - $find=StoreProduct::where('id',$item->product_id)->find(); - $item->store_name=$find->store_name; - $item->image=$find->image; - $item->store_info=$find->store_info; - $item->unit_name=StoreProductUnit::where('id',$item->unit)->value('name'); - $item->category_name=StoreCategory::where('id',$find->top_cate_id)->value('name'); + ->order(['id' => 'desc']) + ->select()->each(function($item) use(&$cateIds, &$supplierIds, &$unitIds) { + $item->store_name=$item->product->store_name ?? ''; + $item->image=$item->product->image ?? ''; + $cateIds[] = $item->product->top_cate_id ?? 0; if($item->is_buyer==1){ $item->is_buyer_name='需要采购'; }elseif($item->is_buyer==-1){ @@ -73,9 +73,20 @@ class PurchaseProductOfferLists extends BaseApiDataLists implements ListsSearchI $item->buyer_confirm_name='采购完成'; } } - }) ->toArray(); + $suppliers = Supplier::field('id,mer_name')->whereIn('id', array_unique(array_column($list,'supplier_id')))->select()->toArray(); + $suppliers = reset_index($suppliers, 'id'); + $units = StoreProductUnit::field('id,name')->whereIn('id', array_unique(array_column($list,'unit')))->select()->toArray(); + $units = reset_index($units, 'id'); + $categories = StoreCategory::field('id,name')->whereIn('id', array_unique($cateIds))->select()->toArray(); + $categories = reset_index($categories, 'id'); + foreach ($list as &$item) { + $item['supplier_name'] = $suppliers[$item['supplier_id']]['mer_name'] ?? ''; + $item['unit_name'] = $units[$item['unit']]['name'] ?? ''; + $item['category_name'] = !empty($item['product']['top_cate_id']) && !empty($categories[$item['product']['top_cate_id']]) ? $categories[$item['product']['top_cate_id']]['name'] : ''; + } + return $list; } diff --git a/app/common/model/purchase_product_offer/PurchaseProductOffer.php b/app/common/model/purchase_product_offer/PurchaseProductOffer.php index 1c6efb33..ba02ef4c 100644 --- a/app/common/model/purchase_product_offer/PurchaseProductOffer.php +++ b/app/common/model/purchase_product_offer/PurchaseProductOffer.php @@ -4,6 +4,7 @@ namespace app\common\model\purchase_product_offer; use app\common\model\BaseModel; +use app\common\model\store_product\StoreProduct; use think\model\concern\SoftDelete; @@ -20,5 +21,10 @@ class PurchaseProductOffer extends BaseModel protected $json = ['source_order_info']; protected $jsonAssoc = true; + + public function product() + { + return $this->hasOne(StoreProduct::class, 'id', 'product_id')->field('id,store_name,top_cate_id,image'); + } } \ No newline at end of file From 2bafdff0527587aab6d1d689927a61aa7b423968 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Thu, 26 Dec 2024 10:44:56 +0800 Subject: [PATCH 20/38] =?UTF-8?q?feat(DemoLogic):=20=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E4=BA=A7=E5=93=81=E4=BB=B7=E6=A0=BC=E5=B9=B6=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E9=85=92=E5=BA=97=E4=BB=B7=E6=A0=BC=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在更新 StoreProduct 价格后,添加成功更新的逻辑,将 ceshi_two 表中的状态设置为 1 - 新增酒店价格设置,与食堂价格设置类似 - 优化代码结构,提高可读性和维护性 --- app/api/logic/DemoLogic.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/app/api/logic/DemoLogic.php b/app/api/logic/DemoLogic.php index 6e8fb679..9d7fbd53 100644 --- a/app/api/logic/DemoLogic.php +++ b/app/api/logic/DemoLogic.php @@ -13,7 +13,10 @@ class DemoLogic extends BaseLogic $arr = Db::name('ceshi_two')->select(); foreach ($arr as $k => $v) { //门店供货、商户、零售 - StoreProduct::where('id', $v['product_id'])->update(['purchase' => $v['price'], 'cost' => bcadd($v['price1'], 0, 2), 'vip_price' => bcadd($v['price1'], 0, 2), 'price' => bcadd($v['price6'], 0, 2)]); + $res=StoreProduct::where('id', $v['product_id'])->update(['purchase' => $v['price'], 'cost' => bcadd($v['price1'], 0, 2), 'vip_price' => bcadd($v['price1'], 0, 2), 'price' => bcadd($v['price6'], 0, 2)]); + if($res){ + Db::name('ceshi_two')->where('product_id', $v['product_id'])->update(['status' => 1]); + } //种养殖 $find = Db::name('store_product_group_price')->where('product_id', $v['product_id'])->where('group_id', 5)->find(); if ($find) { @@ -21,13 +24,20 @@ class DemoLogic extends BaseLogic } else { Db::name('store_product_group_price')->insert(['product_id' => $v['product_id'], 'group_id' => 5, 'price' => bcadd($v['price8'], 0, 2), 'price_type' => 3, 'base_rate' => bcadd(bcmul($v['lv8'], 100), 100, 2)]); } - //酒店 + //食堂 $find2 = Db::name('store_product_group_price')->where('product_id', $v['product_id'])->where('group_id', 7)->find(); if ($find2) { Db::name('store_product_group_price')->where('product_id', $v['product_id'])->where('group_id', 7)->update(['price' => bcadd($v['price3'], 0, 2)]); } else { Db::name('store_product_group_price')->insert(['product_id' => $v['product_id'], 'group_id' => 7, 'price' => bcadd($v['price3'], 0, 2), 'price_type' => 3, 'base_rate' => bcadd(bcmul($v['lv3'], 100), 100, 2)]); } + //酒店 + $find2 = Db::name('store_product_group_price')->where('product_id', $v['product_id'])->where('group_id', 6)->find(); + if ($find2) { + Db::name('store_product_group_price')->where('product_id', $v['product_id'])->where('group_id', 6)->update(['price' => bcadd($v['price3'], 0, 2)]); + } else { + Db::name('store_product_group_price')->insert(['product_id' => $v['product_id'], 'group_id' => 6, 'price' => bcadd($v['price3'], 0, 2), 'price_type' => 3, 'base_rate' => bcadd(bcmul($v['lv3'], 100), 100, 2)]); + } //一条龙 $find3 = Db::name('store_product_group_price')->where('product_id', $v['product_id'])->where('group_id', 18)->find(); if ($find3) { @@ -50,7 +60,6 @@ class DemoLogic extends BaseLogic Db::name('store_product_group_price')->insert(['product_id' => $v['product_id'], 'group_id' => 19, 'price' => bcadd($v['price2'], 0, 2), 'price_type' => 3, 'base_rate' => bcadd(bcmul($v['lv2'], 100), 100, 2)]); } //食堂会员 - $find4 = Db::name('store_product_group_price')->where('product_id', $v['product_id'])->where('group_id', 20)->find(); if ($find4) { Db::name('store_product_group_price')->where('product_id', $v['product_id'])->where('group_id', 20)->update(['price' => bcadd($v['price4'], 0, 2)]); From a1b759b0aa95e0e8d32d730b528b560ef84a88e5 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Thu, 26 Dec 2024 11:27:58 +0800 Subject: [PATCH 21/38] =?UTF-8?q?refactor(warehouse):=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E4=BB=93=E5=BA=93=E4=BA=A7=E5=93=81=E9=80=BB=E8=BE=91=E4=B8=AD?= =?UTF-8?q?=E7=9A=84=E8=AE=A2=E5=8D=95=E7=B1=BB=E5=9E=8B=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将原有的 != 7 判断条件改为 in_array([1,4]),以提高代码可读性和维护性 - 此修改仅在 order_type 不等于 6 的情况下生效,不影响其他逻辑 --- app/admin/logic/warehouse_product/WarehouseProductLogic.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/admin/logic/warehouse_product/WarehouseProductLogic.php b/app/admin/logic/warehouse_product/WarehouseProductLogic.php index 905ad441..a7b3b257 100644 --- a/app/admin/logic/warehouse_product/WarehouseProductLogic.php +++ b/app/admin/logic/warehouse_product/WarehouseProductLogic.php @@ -125,7 +125,7 @@ class WarehouseProductLogic extends BaseLogic if ($params['order_type'] != 6) { $storege = WarehouseProductStorege::where('warehouse_id', $params['warehouse_id'])->where('product_id', $params['product_id'])->find(); if ($storege) { - if($params['order_type']!=7){ + if(in_array($params['order_type'],[1,4])){ SystemStoreStorage::create([ 'store_id' => $params['store_id'], 'admin_id' => $params['admin_id'], From a695d479340e44187ff89bdfd1a3e1c9ae7d7765 Mon Sep 17 00:00:00 2001 From: lewis <604446095@qq.com> Date: Thu, 26 Dec 2024 11:42:26 +0800 Subject: [PATCH 22/38] =?UTF-8?q?=E8=B0=83=E6=95=B4=E9=87=87=E8=B4=AD?= =?UTF-8?q?=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/lists/beforehand_order/BeforehandOrderLists.php | 2 ++ .../purchase_product_offer/PurchaseProductOfferLists.php | 1 - .../purchase_product_offer/PurchaseProductOfferLogic.php | 7 ++++--- app/admin/logic/store_product/StoreProductLogic.php | 4 ++++ 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/app/admin/lists/beforehand_order/BeforehandOrderLists.php b/app/admin/lists/beforehand_order/BeforehandOrderLists.php index d4a90faa..113d9ace 100644 --- a/app/admin/lists/beforehand_order/BeforehandOrderLists.php +++ b/app/admin/lists/beforehand_order/BeforehandOrderLists.php @@ -112,6 +112,8 @@ class BeforehandOrderLists extends BaseAdminDataLists implements ListsSearchInte $item->order_type_name = '往期补单'; } elseif ($item->order_type == 7) { $item->order_type_name = '采购订单'; + } elseif ($item->order_type == 8) { + $item->order_type_name = '其他订单'; } $item->msg = ''; $count1 = PurchaseProductOffer::where('order_id', $item->id)->where('buyer_confirm', 0)->count('id'); diff --git a/app/admin/lists/purchase_product_offer/PurchaseProductOfferLists.php b/app/admin/lists/purchase_product_offer/PurchaseProductOfferLists.php index 5d72a652..1d02eb60 100644 --- a/app/admin/lists/purchase_product_offer/PurchaseProductOfferLists.php +++ b/app/admin/lists/purchase_product_offer/PurchaseProductOfferLists.php @@ -72,7 +72,6 @@ class PurchaseProductOfferLists extends BaseAdminDataLists implements ListsSearc $item->order_sn=BeforehandOrder::where('id',$item['order_id'])->value('order_id'); $find=StoreProduct::where('id',$item->product_id)->withTrashed()->find(); $item->store_name=$find->store_name; - $item->store_info=$find->store_info; $item->image=$find->image; $item->unit_name=StoreProductUnit::where('id',$item->unit)->value('name'); $item->cate_name=StoreCategory::where('id',$find->cate_id)->value('name'); diff --git a/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php b/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php index 7ba297bd..a54b7d3d 100644 --- a/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php +++ b/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php @@ -62,9 +62,6 @@ class PurchaseProductOfferLogic extends BaseLogic } $find=StoreProduct::where('id',$params['product_id'])->find(); $purchaseProductOffer = PurchaseProductOffer::where(['order_id' => $procurementOrder['id'], 'product_id' => $params['product_id']])->find(); - $procurementOrder->total_price = bcadd($procurementOrder->total_price, bcmul($find['price'], $params['need_num'], 2), 2); - $procurementOrder->pay_price = $procurementOrder->total_price; - $procurementOrder->save(); if ($purchaseProductOffer) { $purchaseProductOffer->need_num = $purchaseProductOffer['need_num'] + $params['need_num']; if (!empty($purchaseProductOffer['source_order_info'])) { @@ -184,6 +181,10 @@ class PurchaseProductOfferLogic extends BaseLogic // $find = StoreProductPrice::where(['offer_id' => $params['id']])->find(); $product = StoreProduct::where('id', $offer['product_id'])->withTrashed()->field('id,store_name,top_cate_id,two_cate_id')->find(); $unit_name=StoreProductUnit::where('id', $offer['unit'])->value('name'); + $order = BeforehandOrder::where('id', $params['bhoid'])->find(); + $order->pay_price = bcadd($offer['total_price'], $order->pay_price, 2); + $order->total_price = $order->pay_price; + $order->save(); self::setProductGroupPrice($params, $product); // $data = []; // $dict_data = DictData::where('type_value', 'price_lv_' . $product['top_cate_id'])->field('name,value')->select(); diff --git a/app/admin/logic/store_product/StoreProductLogic.php b/app/admin/logic/store_product/StoreProductLogic.php index c16f39bc..924a5e01 100644 --- a/app/admin/logic/store_product/StoreProductLogic.php +++ b/app/admin/logic/store_product/StoreProductLogic.php @@ -73,6 +73,8 @@ class StoreProductLogic extends BaseLogic 'store_batch' => $params['store_batch'] ?? 1, 'product_type' => $params['product_type'] ?? 0, 'is_show' => $params['is_show'] ?? 0, + 'made_place' => $params['made_place'] ?? '', + 'shelf_life' => $params['shelf_life'] ?? 0, ]; $rose = 0; //零售-供货 @@ -222,6 +224,8 @@ class StoreProductLogic extends BaseLogic 'manufacturer_information' => $params['manufacturer_information'] ?? '', 'swap' => $params['swap'] ?? 0, 'is_show' => $params['is_show'] ?? 0, + 'made_place' => $params['made_place'] ?? '', + 'shelf_life' => $params['shelf_life'] ?? 0, ]; $rose = 0; //零售-供货 From 0e2b83587b693624c8b1129a1e63279f1ae0884b Mon Sep 17 00:00:00 2001 From: lewis <604446095@qq.com> Date: Thu, 26 Dec 2024 17:04:58 +0800 Subject: [PATCH 23/38] =?UTF-8?q?=E9=87=87=E8=B4=AD=E5=95=86=E5=93=81?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=94=9F=E4=BA=A7=E6=97=A5=E6=9C=9F=E3=80=81?= =?UTF-8?q?=E4=BF=9D=E8=B4=A8=E6=9C=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PurchaseProductOfferLists.php | 6 ++++ .../BeforehandOrderCartInfoLogic.php | 2 ++ .../PurchaseProductOfferLogic.php | 4 +++ .../logic/store_product/StoreProductLogic.php | 2 -- .../WarehouseProductLogic.php | 33 +++++++++---------- 5 files changed, 28 insertions(+), 19 deletions(-) diff --git a/app/admin/lists/purchase_product_offer/PurchaseProductOfferLists.php b/app/admin/lists/purchase_product_offer/PurchaseProductOfferLists.php index 1d02eb60..51529640 100644 --- a/app/admin/lists/purchase_product_offer/PurchaseProductOfferLists.php +++ b/app/admin/lists/purchase_product_offer/PurchaseProductOfferLists.php @@ -71,6 +71,12 @@ class PurchaseProductOfferLists extends BaseAdminDataLists implements ListsSearc ->select()->each(function($item) use($job_ids){ $item->order_sn=BeforehandOrder::where('id',$item['order_id'])->value('order_id'); $find=StoreProduct::where('id',$item->product_id)->withTrashed()->find(); + $item->store_info = empty($item['store_info']) ? ($find['store_info'] ?? '') : $item['store_info']; + $item->after_sales = empty($item['after_sales']) ? ($find['after_sales'] ?? '') : $item['after_sales']; + $item->marques = empty($item['marques']) ? ($find['marques'] ?? '') : $item['marques']; + $item->package = empty($item['package']) ? ($find['package'] ?? '') : $item['package']; + $item->expiration_date = $item->expiration_date ? date('Y-m-d', $item->expiration_date) : ''; + $item->manufacture = $item->manufacture ? date('Y-m-d', $item->manufacture) : ''; $item->store_name=$find->store_name; $item->image=$find->image; $item->unit_name=StoreProductUnit::where('id',$item->unit)->value('name'); diff --git a/app/admin/logic/beforehand_order_cart_info/BeforehandOrderCartInfoLogic.php b/app/admin/logic/beforehand_order_cart_info/BeforehandOrderCartInfoLogic.php index 6381f808..25f59a5d 100644 --- a/app/admin/logic/beforehand_order_cart_info/BeforehandOrderCartInfoLogic.php +++ b/app/admin/logic/beforehand_order_cart_info/BeforehandOrderCartInfoLogic.php @@ -235,6 +235,8 @@ class BeforehandOrderCartInfoLogic extends BaseLogic $data['purchase'] = $v['price']; $data['total_price'] = $v['total_price']; $data['financial_pm'] = 1; + $data['manufacture'] = $v['manufacture'] > 0 ? date('Y-m-d H:i:s', $v['manufacture']) : ''; + $data['expiration_date'] = $v['expiration_date'] > 0 ? date('Y-m-d H:i:s', $v['expiration_date']) : ''; $product_arr=[]; if($v['package']!=''){ $product_arr['package']=$v['package']; diff --git a/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php b/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php index a54b7d3d..74cce148 100644 --- a/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php +++ b/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php @@ -156,6 +156,8 @@ class PurchaseProductOfferLogic extends BaseLogic */ public static function setProcureInfo(array $params): bool { + $params['manufacture'] = !empty($params['manufacture']) ? strtotime($params['manufacture']) : ''; + $params['expiration_date'] = !empty($params['expiration_date']) ? strtotime($params['expiration_date']) : ''; $offer = PurchaseProductOffer::where(['id' => $params['id']])->find(); // $uid=Admin::where('id',$params['admin_id'])->value('uid'); // if($params['admin_id']!=1){ @@ -177,6 +179,8 @@ class PurchaseProductOfferLogic extends BaseLogic 'store_info' => $params['store_info'], 'marques' => $params['marques'], 'after_sales' => $params['after_sales'], + 'manufacture' => $params['manufacture'], + 'expiration_date' => $params['expiration_date'], ]); // $find = StoreProductPrice::where(['offer_id' => $params['id']])->find(); $product = StoreProduct::where('id', $offer['product_id'])->withTrashed()->field('id,store_name,top_cate_id,two_cate_id')->find(); diff --git a/app/admin/logic/store_product/StoreProductLogic.php b/app/admin/logic/store_product/StoreProductLogic.php index 924a5e01..fcf2663d 100644 --- a/app/admin/logic/store_product/StoreProductLogic.php +++ b/app/admin/logic/store_product/StoreProductLogic.php @@ -74,7 +74,6 @@ class StoreProductLogic extends BaseLogic 'product_type' => $params['product_type'] ?? 0, 'is_show' => $params['is_show'] ?? 0, 'made_place' => $params['made_place'] ?? '', - 'shelf_life' => $params['shelf_life'] ?? 0, ]; $rose = 0; //零售-供货 @@ -225,7 +224,6 @@ class StoreProductLogic extends BaseLogic 'swap' => $params['swap'] ?? 0, 'is_show' => $params['is_show'] ?? 0, 'made_place' => $params['made_place'] ?? '', - 'shelf_life' => $params['shelf_life'] ?? 0, ]; $rose = 0; //零售-供货 diff --git a/app/admin/logic/warehouse_product/WarehouseProductLogic.php b/app/admin/logic/warehouse_product/WarehouseProductLogic.php index a7b3b257..1a1962d6 100644 --- a/app/admin/logic/warehouse_product/WarehouseProductLogic.php +++ b/app/admin/logic/warehouse_product/WarehouseProductLogic.php @@ -193,7 +193,6 @@ class WarehouseProductLogic extends BaseLogic */ public static function edit(array $params) { - Db::startTrans(); try { $before_nums = 0; @@ -221,24 +220,24 @@ class WarehouseProductLogic extends BaseLogic $before_nums = $warehouseProductStorege['nums']; $after_nums = bcsub($warehouseProductStorege['nums'], $params['nums'], 2); } + $datas = [ + 'nums' => $params['nums'], + 'before_nums' => $before_nums, + 'after_nums' => $after_nums, + 'total_price' => $params['total_price'], + ]; if($find['financial_pm']==1){ - $datas=[ - 'nums' => $params['nums'], - 'supplier_id' => $params['supplier_id'], - 'pay_type' => $params['pay_type'], - 'purchase' => $params['purchase'], - 'before_nums' => $before_nums, - 'after_nums' => $after_nums, - 'total_price' => $params['total_price'], - ]; + $datas['supplier_id'] = $params['supplier_id']; + $datas['pay_type'] = $params['pay_type']; + $datas['purchase'] = $params['purchase']; }else{ - $datas=[ - 'nums' => $params['nums'], - 'price' => $params['price'], - 'before_nums' => $before_nums, - 'after_nums' => $after_nums, - 'total_price' => $params['total_price'], - ]; + $datas['price'] = $params['price']; + } + if (isset($params['manufacture']) && $params['manufacture'] != '') { + $datas['manufacture'] = strtotime($params['manufacture']); + } + if (isset($params['expiration_date']) && $params['expiration_date'] != '') { + $datas['expiration_date'] = strtotime($params['expiration_date']); } WarehouseProduct::where('id', $params['id'])->update($datas); $finds = WarehouseProduct::where('oid', $params['oid'])->field('sum(nums) as nums,sum(total_price) as total_price')->find(); From b2d125448ff8c8a7cd3ca7d19c96fd529401d062 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Thu, 26 Dec 2024 18:05:22 +0800 Subject: [PATCH 24/38] =?UTF-8?q?feat(admin):=20=E6=B7=BB=E5=8A=A0=20demo2?= =?UTF-8?q?=20=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 IndexController 中新增 demo2 方法 - 使用 DemoLogic::test() 进行逻辑处理 - 返回成功信息和处理结果 --- app/admin/controller/IndexController.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/admin/controller/IndexController.php b/app/admin/controller/IndexController.php index 0a45e2c1..1cbf5b38 100644 --- a/app/admin/controller/IndexController.php +++ b/app/admin/controller/IndexController.php @@ -1,6 +1,7 @@ fail($e->extra['message']); } } + public function demo2() + { + $res=DemoLogic::test(); + return $this->success('成功',$res); + } } \ No newline at end of file From bebbd7083d99a09a9a7022f22f7365c9c7381e61 Mon Sep 17 00:00:00 2001 From: lewis <604446095@qq.com> Date: Fri, 27 Dec 2024 11:08:11 +0800 Subject: [PATCH 25/38] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=87=87=E8=B4=AD?= =?UTF-8?q?=E5=95=86=E5=93=81=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../purchase_product_offer/PurchaseProductOfferLists.php | 4 ++++ .../model/purchase_product_offer/PurchaseProductOffer.php | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/api/lists/purchase_product_offer/PurchaseProductOfferLists.php b/app/api/lists/purchase_product_offer/PurchaseProductOfferLists.php index 88a0faad..02b6416c 100644 --- a/app/api/lists/purchase_product_offer/PurchaseProductOfferLists.php +++ b/app/api/lists/purchase_product_offer/PurchaseProductOfferLists.php @@ -57,6 +57,10 @@ class PurchaseProductOfferLists extends BaseApiDataLists implements ListsSearchI ->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) ->select()->each(function($item) use(&$cateIds, &$supplierIds, &$unitIds) { + $item->store_info = empty($item['store_info']) ? ($item['product']['store_info'] ?? '') : $item['store_info']; + $item->after_sales = empty($item['after_sales']) ? ($item['product']['after_sales'] ?? '') : $item['after_sales']; + $item->marques = empty($item['marques']) ? ($item['product']['marques'] ?? '') : $item['marques']; + $item->package = empty($item['package']) ? ($item['product']['package'] ?? '') : $item['package']; $item->store_name=$item->product->store_name ?? ''; $item->image=$item->product->image ?? ''; $cateIds[] = $item->product->top_cate_id ?? 0; diff --git a/app/common/model/purchase_product_offer/PurchaseProductOffer.php b/app/common/model/purchase_product_offer/PurchaseProductOffer.php index ba02ef4c..54b11150 100644 --- a/app/common/model/purchase_product_offer/PurchaseProductOffer.php +++ b/app/common/model/purchase_product_offer/PurchaseProductOffer.php @@ -24,7 +24,7 @@ class PurchaseProductOffer extends BaseModel public function product() { - return $this->hasOne(StoreProduct::class, 'id', 'product_id')->field('id,store_name,top_cate_id,image'); + return $this->hasOne(StoreProduct::class, 'id', 'product_id')->field('id,store_name,top_cate_id,image,store_info,package,marques,after_sales'); } } \ No newline at end of file From 69030f1fbc05931ebc4795af28a427a218a4121a Mon Sep 17 00:00:00 2001 From: lewis <604446095@qq.com> Date: Fri, 27 Dec 2024 11:31:54 +0800 Subject: [PATCH 26/38] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=B4=BB=E5=8A=A8?= =?UTF-8?q?=E4=B8=93=E5=8C=BA=E5=95=86=E5=93=81=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/logic/ActivityZoneFormLogic.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/admin/logic/ActivityZoneFormLogic.php b/app/admin/logic/ActivityZoneFormLogic.php index c8854679..f24cb03f 100644 --- a/app/admin/logic/ActivityZoneFormLogic.php +++ b/app/admin/logic/ActivityZoneFormLogic.php @@ -126,7 +126,7 @@ class ActivityZoneFormLogic extends BaseLogic $service = new ActivityZoneService(); $activityZoneForm = ActivityZoneForm::findOrEmpty($params['id'])->toArray(); $productIds = ActivityZone::where('form_id', $params['id'])->column('product_id'); - $products = StoreProduct::field('id,unit,store_name,two_cate_id')->whereIn('id', $productIds)->order('two_cate_id')->select()->toArray(); + $products = StoreProduct::field('id,unit,store_name,two_cate_id')->whereIn('id', $productIds)->order('two_cate_id asc,cate_id asc')->select()->toArray(); $unitIds = array_unique(array_column($products, 'unit')); $cateIds = array_unique(array_column($products, 'two_cate_id')); $unit = StoreProductUnit::whereIn('id', $unitIds)->field('id,name')->withTrashed()->select()->toArray(); From 26da169c1f12889f0f7224264f9f8f0a21931bf8 Mon Sep 17 00:00:00 2001 From: lewis <604446095@qq.com> Date: Fri, 27 Dec 2024 16:47:56 +0800 Subject: [PATCH 27/38] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=95=86=E5=93=81?= =?UTF-8?q?=E5=88=86=E7=B1=BB=E4=BB=B7=E6=A0=BC=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../store_category/StoreCategoryLists.php | 18 ++++++++++++------ .../PurchaseProductOfferLogic.php | 4 ++-- .../store_category/StoreCategoryLogic.php | 13 +++++++++++-- .../StoreProductGroupPriceLogic.php | 2 -- 4 files changed, 25 insertions(+), 12 deletions(-) diff --git a/app/admin/lists/store_category/StoreCategoryLists.php b/app/admin/lists/store_category/StoreCategoryLists.php index 0be91834..e9e67206 100644 --- a/app/admin/lists/store_category/StoreCategoryLists.php +++ b/app/admin/lists/store_category/StoreCategoryLists.php @@ -45,8 +45,6 @@ class StoreCategoryLists extends BaseAdminDataLists implements ListsSearchInterf public function lists(): array { $userGroups = UserShip::field('id,title')->select()->toArray(); - $userGroups[] = ['id' => 100001, 'title' => '供货价']; - $userGroups[] = ['id' => 100002, 'title' => '零售价']; return StoreCategory::where($this->searchWhere) ->field(['id', 'pid', 'name', 'data', 'pic', 'sort', 'price_rate']) ->limit($this->limitOffset, $this->limitLength) @@ -56,13 +54,21 @@ class StoreCategoryLists extends BaseAdminDataLists implements ListsSearchInterf $item['price_rate'] = $userGroups; } else { $priceRate = reset_index($item['price_rate'], 'id'); + unset($priceRate[100003], $priceRate[100004]); + $temp = []; foreach ($userGroups as $userGroup) { - if (!isset($priceRate[$userGroup['id']])) { - $userGroup['rate'] = 0; - $priceRate[] = $userGroup; + if ($userGroup['id'] == 21 && !empty($priceRate[100001]) && empty($userGroup['rate'])) { + $userGroup['rate'] = $priceRate[100001]['rate']; + unset($priceRate[100001]); + } elseif ($userGroup['id'] == 22 && !empty($priceRate[100002]) && empty($userGroup['rate'])) { + $userGroup['rate'] = $priceRate[100002]['rate']; + unset($priceRate[100002]); + } else { + $userGroup['rate'] = $priceRate[$userGroup['id']]['rate'] ?? 0; } + $temp[] = $userGroup; } - $item['price_rate'] = array_values($priceRate); + $item['price_rate'] = $temp; } $item['is_children'] = StoreCategory::where('pid', $item->id)->count(); // 判断是否有子分类 return $item->toArray(); diff --git a/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php b/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php index 74cce148..f7f231dc 100644 --- a/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php +++ b/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php @@ -370,7 +370,7 @@ class PurchaseProductOfferLogic extends BaseLogic $storeProductGroupPrice = reset_index($storeProductGroupPrice, 'group_id'); $purchase=0; foreach ($productCatePriceRate as $k => $v) { - if ($v['id'] == 100001) { + if ($v['id'] == 100001 || $v['id'] == 21) { //供货 $data['purchase_lv'] = bcdiv($v['rate'], 100, 2); $data['purchase'] = bcmul($params['purchase'], bcadd($data['purchase_lv'], 1, 2), 2); @@ -384,7 +384,7 @@ class PurchaseProductOfferLogic extends BaseLogic $data['cost_lv'] = bcdiv($v['rate'], 100, 2); $data['cost'] = bcmul($purchase, bcadd($data['cost_lv'], 1, 2), 2); continue; - }elseif ($v['id'] == 100002 &&$purchase>0) { + }elseif (($v['id'] == 100002 || $v['id'] == 22) &&$purchase>0) { //零售 $data['price_lv'] = bcdiv($v['rate'], 100, 2); $data['price'] = bcmul($purchase, bcadd($data['price_lv'], 1, 2), 1); diff --git a/app/admin/logic/store_category/StoreCategoryLogic.php b/app/admin/logic/store_category/StoreCategoryLogic.php index 5404dcad..0dcd944f 100644 --- a/app/admin/logic/store_category/StoreCategoryLogic.php +++ b/app/admin/logic/store_category/StoreCategoryLogic.php @@ -29,12 +29,17 @@ class StoreCategoryLogic extends BaseLogic { Db::startTrans(); try { + $priceRate = []; + foreach ($params['price_rate'] as $v) { + $priceRate[$v['id']] = $v; + } StoreCategory::create([ 'pid' => $params['pid'], 'name' => $params['name'], 'data' => $params['data'], 'pic' => $params['pic'], - 'sort' => $params['sort'] + 'sort' => $params['sort'], + 'price_rate' => array_values($priceRate) ]); Db::commit(); @@ -57,13 +62,17 @@ class StoreCategoryLogic extends BaseLogic { Db::startTrans(); try { + $priceRate = []; + foreach ($params['price_rate'] as $v) { + $priceRate[$v['id']] = $v; + } StoreCategory::where('id', $params['id'])->update([ 'pid' => $params['pid'], 'name' => $params['name'], 'data' => $params['data'], 'pic' => $params['pic'], 'sort' => $params['sort'], - 'price_rate' => $params['price_rate'] + 'price_rate' => array_values($priceRate) ]); Db::commit(); diff --git a/app/admin/logic/store_product_group_price/StoreProductGroupPriceLogic.php b/app/admin/logic/store_product_group_price/StoreProductGroupPriceLogic.php index a9ac145d..24621998 100644 --- a/app/admin/logic/store_product_group_price/StoreProductGroupPriceLogic.php +++ b/app/admin/logic/store_product_group_price/StoreProductGroupPriceLogic.php @@ -106,8 +106,6 @@ class StoreProductGroupPriceLogic extends BaseLogic $arr=StoreProductGroupPrice::where('product_id',$params['product_id'])->select()->toArray(); $purchase=StoreProduct::where('id',$params['product_id'])->value('purchase'); $arr_two=UserShip::where('id','>',0)->select()->toArray(); - $arr_two[] = ['id' => 100001, 'title' => '供货价']; - $arr_two[] = ['id' => 100002, 'title' => '零售价']; foreach ($arr_two as $k=>$v){ $arr_two[$k]['purchase']=$purchase; $arr_two[$k]['product_id']=$params['product_id']; From 91a119c896927f6980823a92e6e9db13c31b02f8 Mon Sep 17 00:00:00 2001 From: lewis <604446095@qq.com> Date: Fri, 27 Dec 2024 17:30:00 +0800 Subject: [PATCH 28/38] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=A2=84=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E9=87=87=E8=B4=AD=E5=95=86=E5=93=81=E7=9A=84=E9=94=99?= =?UTF-8?q?=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BeforehandOrderCartInfoController.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/app/admin/controller/beforehand_order_cart_info/BeforehandOrderCartInfoController.php b/app/admin/controller/beforehand_order_cart_info/BeforehandOrderCartInfoController.php index 9736a5ec..2f179371 100644 --- a/app/admin/controller/beforehand_order_cart_info/BeforehandOrderCartInfoController.php +++ b/app/admin/controller/beforehand_order_cart_info/BeforehandOrderCartInfoController.php @@ -85,11 +85,6 @@ class BeforehandOrderCartInfoController extends BaseAdminController } } $find->source_order_info = array_values($json); - $productPrice = StoreProduct::where('id',$res['product_id'])->value('price'); - $procurementOrder = BeforehandOrder::where('id', $find['order_id'])->find(); - $procurementOrder->total_price = bcsub($procurementOrder->total_price, bcmul($productPrice, $res['cart_num'], 2), 2); - $procurementOrder->pay_price = $procurementOrder->total_price; - $procurementOrder->save(); } if ($find->need_num <= 0) { $find->delete_time = time(); From ccc774593a6eb6b74604224311b4dd7f4a9f29d2 Mon Sep 17 00:00:00 2001 From: lewis <604446095@qq.com> Date: Fri, 27 Dec 2024 17:36:30 +0800 Subject: [PATCH 29/38] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=87=87=E8=B4=AD?= =?UTF-8?q?=E5=8D=95=E4=BB=B7=E6=A0=BC=E7=9A=84=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../logic/purchase_product_offer/PurchaseProductOfferLogic.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php b/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php index f7f231dc..e9cef4c8 100644 --- a/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php +++ b/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php @@ -186,7 +186,7 @@ class PurchaseProductOfferLogic extends BaseLogic $product = StoreProduct::where('id', $offer['product_id'])->withTrashed()->field('id,store_name,top_cate_id,two_cate_id')->find(); $unit_name=StoreProductUnit::where('id', $offer['unit'])->value('name'); $order = BeforehandOrder::where('id', $params['bhoid'])->find(); - $order->pay_price = bcadd($offer['total_price'], $order->pay_price, 2); + $order->pay_price = PurchaseProductOffer::where('order_id', $order['id'])->sum('total_price'); $order->total_price = $order->pay_price; $order->save(); self::setProductGroupPrice($params, $product); From 715f84d2f20978808d0b7414a0e4f030113341a4 Mon Sep 17 00:00:00 2001 From: lewis <604446095@qq.com> Date: Fri, 27 Dec 2024 17:56:18 +0800 Subject: [PATCH 30/38] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=87=87=E8=B4=AD?= =?UTF-8?q?=E5=8D=95=E4=BB=B7=E6=A0=BC=E7=9A=84=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PurchaseProductOfferLogic.php | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php b/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php index e9cef4c8..7caa7a63 100644 --- a/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php +++ b/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php @@ -183,7 +183,7 @@ class PurchaseProductOfferLogic extends BaseLogic 'expiration_date' => $params['expiration_date'], ]); // $find = StoreProductPrice::where(['offer_id' => $params['id']])->find(); - $product = StoreProduct::where('id', $offer['product_id'])->withTrashed()->field('id,store_name,top_cate_id,two_cate_id')->find(); + $product = StoreProduct::where('id', $offer['product_id'])->withTrashed()->field('id,store_name,top_cate_id,two_cate_id,cate_id')->find(); $unit_name=StoreProductUnit::where('id', $offer['unit'])->value('name'); $order = BeforehandOrder::where('id', $params['bhoid'])->find(); $order->pay_price = PurchaseProductOffer::where('order_id', $order['id'])->sum('total_price'); @@ -364,7 +364,7 @@ class PurchaseProductOfferLogic extends BaseLogic 'update_time' => time(), 'status' => 0, ]; - $productCatePriceRate = StoreCategory::where('id', $product['top_cate_id'])->value('price_rate'); + $productCatePriceRate = self::getProductCatePriceRate($product); if (!empty($productCatePriceRate)) { $storeProductGroupPrice = StoreProductGroupPrice::where('product_id', $product['id'])->select()->toArray(); $storeProductGroupPrice = reset_index($storeProductGroupPrice, 'group_id'); @@ -400,7 +400,7 @@ class PurchaseProductOfferLogic extends BaseLogic } continue; } - $baseRate = 100 + $v['rate']; + $baseRate = ($v['id'] == 100001 || $v['id'] == 21) ? 100 : 100 + $v['rate']; if($purchase>0){ $item = [ 'product_id' => $product['id'], @@ -427,4 +427,18 @@ class PurchaseProductOfferLogic extends BaseLogic StoreProductPrice::create($data); } } + + public static function getProductCatePriceRate($product) + { + $productCatePriceRate = StoreCategory::where('id', $product['cate_id'])->value('price_rate'); + if (!empty($productCatePriceRate)) { + return $productCatePriceRate; + } + $productCatePriceRate = StoreCategory::where('id', $product['two_cate_id'])->value('price_rate'); + if (!empty($productCatePriceRate)) { + return $productCatePriceRate; + } + return StoreCategory::where('id', $product['top_cate_id'])->value('price_rate'); + } + } From 35a646ca3eac2e5fb337027d7d607f91c2fa36da Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Sat, 28 Dec 2024 11:06:06 +0800 Subject: [PATCH 31/38] =?UTF-8?q?refactor(admin):=20=E7=A7=BB=E9=99=A4=20I?= =?UTF-8?q?ndexController=20=E4=B8=AD=E7=9A=84=E5=86=97=E4=BD=99=E5=8F=82?= =?UTF-8?q?=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 IndexController 类中的 demo2 方法中,移除了 success 方法的冗余参数 $res - 优化了代码结构,提高了代码的可读性和维护性 --- app/admin/controller/IndexController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/admin/controller/IndexController.php b/app/admin/controller/IndexController.php index 1cbf5b38..8adcaad5 100644 --- a/app/admin/controller/IndexController.php +++ b/app/admin/controller/IndexController.php @@ -28,6 +28,6 @@ class IndexController extends BaseAdminController public function demo2() { $res=DemoLogic::test(); - return $this->success('成功',$res); + return $this->success('成功'); } } \ No newline at end of file From 50d76b14b2a8e090c58ab8005dde3ee00b4d8552 Mon Sep 17 00:00:00 2001 From: lewis <604446095@qq.com> Date: Sat, 28 Dec 2024 16:03:57 +0800 Subject: [PATCH 32/38] =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=B4=BB=E5=8A=A8?= =?UTF-8?q?=E4=B8=93=E5=8C=BA=E5=95=86=E5=93=81=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/logic/ActivityZoneLogic.php | 37 +++++++++++++++++++ .../logic/store_product/StoreProductLogic.php | 8 +++- 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/app/admin/logic/ActivityZoneLogic.php b/app/admin/logic/ActivityZoneLogic.php index 5f4eec89..ea5ebbc4 100644 --- a/app/admin/logic/ActivityZoneLogic.php +++ b/app/admin/logic/ActivityZoneLogic.php @@ -5,6 +5,7 @@ namespace app\admin\logic; use app\common\model\ActivityZone; use app\common\logic\BaseLogic; +use app\common\model\ActivityZoneForm; use support\exception\BusinessException; use think\facade\Db; @@ -100,4 +101,40 @@ class ActivityZoneLogic extends BaseLogic return ActivityZone::findOrEmpty($params['id'])->toArray(); } + public function addProduct($product) + { + $activityFormId1 = ActivityZoneForm::whereRaw('FIND_IN_SET(:cate_id,cate_ids)', ['cate_id' => $product['two_cate_id']])->column('id'); + $activityFormId2 = ActivityZoneForm::whereRaw('FIND_IN_SET(:cate_id,cate_ids)', ['cate_id' => $product['cate_id']])->column('id'); + $activityFormIds = array_unique(array_merge($activityFormId1, $activityFormId2)); + foreach ($activityFormIds as $activityFormId) { + $activityZone = new ActivityZone(); + $activityZone->form_id = $activityFormId; + $activityZone->product_id = $product['id']; + $activityZone->save(); + } + } + + public function updateProduct($productId, $product) + { + $product['id'] = $productId; + $formIds = ActivityZone::where('product_id', $productId)->column('form_id'); + if (empty($formIds)) { + $this->addProduct($product); + return; + } + $forms = ActivityZoneForm::whereIn('id', $formIds)->select()->toArray(); + foreach ($forms as $form) { + $cateIds = explode(',', $form['cate_ids']); + if (!in_array($product['two_cate_id'], $cateIds) && !in_array($product['cate_id'], $cateIds)) { + ActivityZone::where('product_id', $productId)->where('form_id', $form['id'])->update(['delete_time' => time()]); + } + $this->addProduct($product); + } + } + + public function deleteProduct($productId) + { + ActivityZone::where('product_id', $productId)->update(['delete_time' => time()]); + } + } \ No newline at end of file diff --git a/app/admin/logic/store_product/StoreProductLogic.php b/app/admin/logic/store_product/StoreProductLogic.php index fcf2663d..9f4495c5 100644 --- a/app/admin/logic/store_product/StoreProductLogic.php +++ b/app/admin/logic/store_product/StoreProductLogic.php @@ -2,6 +2,7 @@ namespace app\admin\logic\store_product; +use app\admin\logic\ActivityZoneLogic; use app\admin\logic\warehouse_product\WarehouseProductLogic; use app\common\model\store_product\StoreProduct; use app\common\logic\BaseLogic; @@ -85,6 +86,8 @@ class StoreProductLogic extends BaseLogic } $data['rose']=$rose; $res = StoreProduct::create($data); + // 添加商品到活动专区 + (new ActivityZoneLogic())->addProduct($res); StoreProductAttrValue::create([ "bar_code" => $params["bar_code"] ?? '', "image" => $params["image"] ?? '', @@ -235,6 +238,8 @@ class StoreProductLogic extends BaseLogic } $data['rose']=$rose; StoreProduct::update($data, ['id' => $params['id']]); + // 修改活动专区商品 + (new ActivityZoneLogic())->updateProduct($params['id'], $data); // $dealCate = self::dealChangeCate($params['cate_id']); //修改 @@ -250,7 +255,6 @@ class StoreProductLogic extends BaseLogic 'cate_id' => $params['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' => $rose, @@ -279,6 +283,8 @@ class StoreProductLogic extends BaseLogic public static function delete(array $params): bool { $res = StoreProduct::destroy($params['id']); + // 删除活动专区商品 + (new ActivityZoneLogic())->deleteProduct($params['id']); StoreBranchProduct::where('product_id', $params['id'])->update(['delete_time' => time()]); return $res; } From a5e9c47a3608373d37f7a5b15fe1dc2a9c774afa Mon Sep 17 00:00:00 2001 From: lewis <604446095@qq.com> Date: Sat, 28 Dec 2024 16:25:55 +0800 Subject: [PATCH 33/38] =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=B4=BB=E5=8A=A8?= =?UTF-8?q?=E4=B8=93=E5=8C=BA=E5=95=86=E5=93=81=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/logic/ActivityZoneFormLogic.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/admin/logic/ActivityZoneFormLogic.php b/app/admin/logic/ActivityZoneFormLogic.php index f24cb03f..b51279f8 100644 --- a/app/admin/logic/ActivityZoneFormLogic.php +++ b/app/admin/logic/ActivityZoneFormLogic.php @@ -47,7 +47,7 @@ class ActivityZoneFormLogic extends BaseLogic $params['cate_ids'] = !empty($cateIds) ? implode(',', $cateIds) : ''; $activityZoneForm = new ActivityZoneForm(); $activityZoneForm->save($params); - $products = StoreProduct::field('id,two_cate_id,cate_id')->where('two_cate_id', 'in', $secondCateIds)->whereOr('cate_id', 'in', $thirdCateIds)->select()->toArray(); + $products = StoreProduct::field('id,two_cate_id,cate_id')->where('two_cate_id', 'in', $cateIds)->whereOr('cate_id', 'in', $cateIds)->select()->toArray(); $productInfo = []; $time = time(); foreach ($products as $product) { From 844c085df52beba8567932294835b58d4f360fa4 Mon Sep 17 00:00:00 2001 From: lewis <604446095@qq.com> Date: Mon, 30 Dec 2024 16:31:28 +0800 Subject: [PATCH 34/38] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BE=9B=E5=BA=94?= =?UTF-8?q?=E5=95=86=E5=88=97=E8=A1=A8=EF=BC=8C=E6=B7=BB=E5=8A=A0=E5=95=86?= =?UTF-8?q?=E5=93=81=E4=BB=B7=E6=A0=BC=E5=90=8C=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/LocalController.php | 101 ++++++++++++++++++++- app/admin/lists/supplier/SupplierLists.php | 2 +- 2 files changed, 101 insertions(+), 2 deletions(-) diff --git a/app/admin/controller/LocalController.php b/app/admin/controller/LocalController.php index 485cd662..11841001 100644 --- a/app/admin/controller/LocalController.php +++ b/app/admin/controller/LocalController.php @@ -4,13 +4,112 @@ namespace app\admin\controller; use app\common\model\store_category\StoreCategory; use app\common\model\store_product\StoreProduct; +use app\common\model\store_product_price\StoreProductPrice; use PhpOffice\PhpSpreadsheet\IOFactory; use support\Redis; +use think\facade\Db; class LocalController extends BaseAdminController { - public $notNeedLogin = []; + public $notNeedLogin = ['setPrice']; + + public function setPrice() + { + $file = $this->request->file('file'); + $reader = IOFactory::createReader('Xlsx'); + $spreadsheet = $reader->load($file->getRealPath()); + $data = $spreadsheet->getActiveSheet()->toArray(); + $insert = []; + $productIds = []; + foreach ($data as $k => $row) { + if ($k < 2) { + continue; + } + if (empty($row[0])) { + continue; + } + $productId = intval($row[0]); + if (empty($productId)) { + continue; + } + $productIds[] = $productId; + } + $products = StoreProduct::whereIn('id', $productIds)->field('id,store_name')->select()->toArray(); + $products = reset_index($products, 'id'); + $lastPurchasePrices = StoreProductPrice::whereIn('product_id', $productIds)->where('status', 1)->order('id desc')->select()->toArray(); + $lastPurchasePrices = reset_index($lastPurchasePrices, 'product_id'); + foreach ($data as $k => $row) { + if ($k < 2) { + continue; + } + if (empty($row[0])) { + continue; + } + $productId = intval($row[0]); + if (empty($productId)) { + continue; + } + $product = $products[$productId] ?? []; + if (empty($product)) { + continue; + } + $lastPurchasePrice = $lastPurchasePrices[$productId] ?? []; + if (empty($lastPurchasePrice)) { + continue; + } + $storeRate = rtrim($row[4] ?? 0, '%'); + $row[5] = rtrim($row[5] ?? 0, '%'); + $row[7] = rtrim($row[7] ?? 0, '%'); + $row[9] = rtrim($row[9] ?? 0, '%'); + $row[11] = rtrim($row[11] ?? 0, '%'); + $row[13] = rtrim($row[13] ?? 0, '%'); + $row[15] = rtrim($row[15] ?? 0, '%'); + $row[17] = rtrim($row[17] ?? 0, '%'); + $row[19] = rtrim($row[19] ?? 0, '%'); + $row[21] = rtrim($row[21] ?? 0, '%'); + $row[23] = rtrim($row[23] ?? 0, '%'); + $row[25] = rtrim($row[25] ?? 0, '%'); + $row[27] = rtrim($row[27] ?? 0, '%'); + $row[29] = rtrim($row[29] ?? 0, '%'); + $row[31] = rtrim($row[31] ?? 0, '%'); + $row[33] = rtrim($row[33] ?? 0, '%'); + $row[35] = rtrim($row[35] ?? 0, '%'); + $row[37] = rtrim($row[37] ?? 0, '%'); + $row[39] = rtrim($row[39] ?? 0, '%'); + $row[41] = rtrim($row[41] ?? 0, '%'); + $storePrice = $lastPurchasePrice['purchase_price'] * (1 + $storeRate / 100); + $item = [ + 'product_id' => $product['id'], + 'product_name' => $product['store_name'], + 'store_price' => $storePrice, + 'price_set' => json_encode([ + ['user_ship' => 23, 'rate' => $row[5], 'price' => bcmul($storePrice, (1 + $row[5] / 100), 2)], + ['user_ship' => 24, 'rate' => $row[7], 'price' => bcmul($storePrice, (1 + $row[7] / 100), 2)], + ['user_ship' => 25, 'rate' => $row[9], 'price' => bcmul($storePrice, (1 + $row[9] / 100), 2)], + ['user_ship' => 26, 'rate' => $row[11], 'price' => bcmul($storePrice, (1 + $row[11] / 100), 2)], + ['user_ship' => 27, 'rate' => $row[13], 'price' => bcmul($storePrice, (1 + $row[13] / 100), 2)], + ['user_ship' => 28, 'rate' => $row[15], 'price' => bcmul($storePrice, (1 + $row[15] / 100), 2)], + ['user_ship' => 29, 'rate' => $row[17], 'price' => bcmul($storePrice, (1 + $row[17] / 100), 2)], + ['user_ship' => 30, 'rate' => $row[19], 'price' => bcmul($storePrice, (1 + $row[19] / 100), 2)], + ['user_ship' => 31, 'rate' => $row[21], 'price' => bcmul($storePrice, (1 + $row[21] / 100), 2)], + ['user_ship' => 32, 'rate' => $row[23], 'price' => bcmul($storePrice, (1 + $row[23] / 100), 2)], + ['user_ship' => 33, 'rate' => $row[25], 'price' => bcmul($storePrice, (1 + $row[25] / 100), 2)], + ['user_ship' => 34, 'rate' => $row[27], 'price' => bcmul($storePrice, (1 + $row[27] / 100), 2)], + ['user_ship' => 35, 'rate' => $row[29], 'price' => bcmul($storePrice, (1 + $row[29] / 100), 2)], + ['user_ship' => 36, 'rate' => $row[31], 'price' => bcmul($storePrice, (1 + $row[31] / 100), 2)], + ['user_ship' => 37, 'rate' => $row[33], 'price' => bcmul($storePrice, (1 + $row[33] / 100), 2)], + ['user_ship' => 38, 'rate' => $row[35], 'price' => bcmul($storePrice, (1 + $row[35] / 100), 2)], + ['user_ship' => 39, 'rate' => $row[37], 'price' => bcmul($storePrice, (1 + $row[37] / 100), 2)], + ['user_ship' => 40, 'rate' => $row[39], 'price' => bcmul($storePrice, (1 + $row[39] / 100), 2)], + ['user_ship' => 41, 'rate' => $row[41], 'price' => bcmul($storePrice, (1 + $row[41] / 100), 2)], + ], JSON_UNESCAPED_UNICODE), + ]; + $insert[] = $item; + } + $count = Db::name('product_price_set')->insertAll($insert); + return $this->success('插入成功:' . $count . '条'); + } public function fixCategory() { diff --git a/app/admin/lists/supplier/SupplierLists.php b/app/admin/lists/supplier/SupplierLists.php index c0757cda..9d829980 100644 --- a/app/admin/lists/supplier/SupplierLists.php +++ b/app/admin/lists/supplier/SupplierLists.php @@ -45,7 +45,7 @@ class SupplierLists extends BaseAdminDataLists implements ListsSearchInterface { return Supplier::where($this->searchWhere) ->field(['id', 'category_id', 'mer_name', 'phone', 'settle_cycle', 'address', 'mark']) - ->limit($this->limitOffset, $this->limitLength) + ->limit($this->limitOffset, 100) ->order(['id' => 'desc']) ->select()->each(function ($item) { $item->total_completed_amount=WarehouseProduct::where('supplier_id',$item['id'])->where('financial_pm',1)->where('is_pay',1)->sum('total_price'); From c2a5ee0fdc3ec1c073427a470c1fdf71517badfb Mon Sep 17 00:00:00 2001 From: lewis <604446095@qq.com> Date: Mon, 30 Dec 2024 17:57:27 +0800 Subject: [PATCH 35/38] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=95=86=E5=93=81?= =?UTF-8?q?=E5=88=86=E7=BB=84=E4=BB=B7=E6=A0=BC=E8=AE=A1=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/LocalController.php | 122 ++++++++++++----------- 1 file changed, 66 insertions(+), 56 deletions(-) diff --git a/app/admin/controller/LocalController.php b/app/admin/controller/LocalController.php index 11841001..bba0ebdd 100644 --- a/app/admin/controller/LocalController.php +++ b/app/admin/controller/LocalController.php @@ -4,7 +4,7 @@ namespace app\admin\controller; use app\common\model\store_category\StoreCategory; use app\common\model\store_product\StoreProduct; -use app\common\model\store_product_price\StoreProductPrice; +use app\common\model\store_product_group_price\StoreProductGroupPrice; use PhpOffice\PhpSpreadsheet\IOFactory; use support\Redis; use think\facade\Db; @@ -21,6 +21,7 @@ class LocalController extends BaseAdminController $spreadsheet = $reader->load($file->getRealPath()); $data = $spreadsheet->getActiveSheet()->toArray(); $insert = []; + $update = []; $productIds = []; foreach ($data as $k => $row) { if ($k < 2) { @@ -35,10 +36,8 @@ class LocalController extends BaseAdminController } $productIds[] = $productId; } - $products = StoreProduct::whereIn('id', $productIds)->field('id,store_name')->select()->toArray(); + $products = StoreProduct::whereIn('id', $productIds)->field('id,store_name,purchase')->select()->toArray(); $products = reset_index($products, 'id'); - $lastPurchasePrices = StoreProductPrice::whereIn('product_id', $productIds)->where('status', 1)->order('id desc')->select()->toArray(); - $lastPurchasePrices = reset_index($lastPurchasePrices, 'product_id'); foreach ($data as $k => $row) { if ($k < 2) { continue; @@ -54,60 +53,71 @@ class LocalController extends BaseAdminController if (empty($product)) { continue; } - $lastPurchasePrice = $lastPurchasePrices[$productId] ?? []; - if (empty($lastPurchasePrice)) { - continue; - } - $storeRate = rtrim($row[4] ?? 0, '%'); - $row[5] = rtrim($row[5] ?? 0, '%'); - $row[7] = rtrim($row[7] ?? 0, '%'); - $row[9] = rtrim($row[9] ?? 0, '%'); - $row[11] = rtrim($row[11] ?? 0, '%'); - $row[13] = rtrim($row[13] ?? 0, '%'); - $row[15] = rtrim($row[15] ?? 0, '%'); - $row[17] = rtrim($row[17] ?? 0, '%'); - $row[19] = rtrim($row[19] ?? 0, '%'); - $row[21] = rtrim($row[21] ?? 0, '%'); - $row[23] = rtrim($row[23] ?? 0, '%'); - $row[25] = rtrim($row[25] ?? 0, '%'); - $row[27] = rtrim($row[27] ?? 0, '%'); - $row[29] = rtrim($row[29] ?? 0, '%'); - $row[31] = rtrim($row[31] ?? 0, '%'); - $row[33] = rtrim($row[33] ?? 0, '%'); - $row[35] = rtrim($row[35] ?? 0, '%'); - $row[37] = rtrim($row[37] ?? 0, '%'); - $row[39] = rtrim($row[39] ?? 0, '%'); - $row[41] = rtrim($row[41] ?? 0, '%'); - $storePrice = $lastPurchasePrice['purchase_price'] * (1 + $storeRate / 100); - $item = [ - 'product_id' => $product['id'], - 'product_name' => $product['store_name'], - 'store_price' => $storePrice, - 'price_set' => json_encode([ - ['user_ship' => 23, 'rate' => $row[5], 'price' => bcmul($storePrice, (1 + $row[5] / 100), 2)], - ['user_ship' => 24, 'rate' => $row[7], 'price' => bcmul($storePrice, (1 + $row[7] / 100), 2)], - ['user_ship' => 25, 'rate' => $row[9], 'price' => bcmul($storePrice, (1 + $row[9] / 100), 2)], - ['user_ship' => 26, 'rate' => $row[11], 'price' => bcmul($storePrice, (1 + $row[11] / 100), 2)], - ['user_ship' => 27, 'rate' => $row[13], 'price' => bcmul($storePrice, (1 + $row[13] / 100), 2)], - ['user_ship' => 28, 'rate' => $row[15], 'price' => bcmul($storePrice, (1 + $row[15] / 100), 2)], - ['user_ship' => 29, 'rate' => $row[17], 'price' => bcmul($storePrice, (1 + $row[17] / 100), 2)], - ['user_ship' => 30, 'rate' => $row[19], 'price' => bcmul($storePrice, (1 + $row[19] / 100), 2)], - ['user_ship' => 31, 'rate' => $row[21], 'price' => bcmul($storePrice, (1 + $row[21] / 100), 2)], - ['user_ship' => 32, 'rate' => $row[23], 'price' => bcmul($storePrice, (1 + $row[23] / 100), 2)], - ['user_ship' => 33, 'rate' => $row[25], 'price' => bcmul($storePrice, (1 + $row[25] / 100), 2)], - ['user_ship' => 34, 'rate' => $row[27], 'price' => bcmul($storePrice, (1 + $row[27] / 100), 2)], - ['user_ship' => 35, 'rate' => $row[29], 'price' => bcmul($storePrice, (1 + $row[29] / 100), 2)], - ['user_ship' => 36, 'rate' => $row[31], 'price' => bcmul($storePrice, (1 + $row[31] / 100), 2)], - ['user_ship' => 37, 'rate' => $row[33], 'price' => bcmul($storePrice, (1 + $row[33] / 100), 2)], - ['user_ship' => 38, 'rate' => $row[35], 'price' => bcmul($storePrice, (1 + $row[35] / 100), 2)], - ['user_ship' => 39, 'rate' => $row[37], 'price' => bcmul($storePrice, (1 + $row[37] / 100), 2)], - ['user_ship' => 40, 'rate' => $row[39], 'price' => bcmul($storePrice, (1 + $row[39] / 100), 2)], - ['user_ship' => 41, 'rate' => $row[41], 'price' => bcmul($storePrice, (1 + $row[41] / 100), 2)], - ], JSON_UNESCAPED_UNICODE), + $groupIds = [ + 5 => 23, + 7 => 24, + 9 => 25, + 11 => 26, + 13 => 27, + 15 => 28, + 17 => 29, + 19 => 30, + 21 => 31, + 23 => 32, + 25 => 33, + 27 => 34, + 29 => 35, + 31 => 36, + 33 => 37, + 35 => 1, + 37 => 18, + 39 => 22, ]; - $insert[] = $item; + for ($i = 5; $i < 35; $i = $i + 2) { + $rate = intval(rtrim($row[$i] ?? 0, '%')); + if (empty($rate)) { + continue; + } + $price = $row[$i + 1] ?? 0; + if (empty($price)) { + $price = $product['purchase'] * (1 + $rate / 100); + } + $item = [ + 'product_id' => $productId, + 'group_id' => $groupIds[$i], + 'price_type' => 3, + 'base_rate' => 100 + $rate, + 'price' => $price + ]; + $insert[] = $item; + } + $productGroupPrices = StoreProductGroupPrice::where('product_id', $productId)->whereIn('group_id', [1, 18, 22])->select()->toArray(); + $groupIds = array_flip($groupIds); + foreach ($productGroupPrices as $productGroupPrice) { + $cellId = $groupIds[$productGroupPrice['group_id']] ?? 0; + $rate = intval(rtrim($row[$cellId] ?? 0, '%')); + if (empty($rate)) { + continue; + } + $price = $row[$cellId + 1] ?? 0; + if (empty($price)) { + $price = $product['purchase'] * (1 + $rate / 100); + } + if ($price != $productGroupPrice['price']) { + $update[] = [ + 'id' => $productGroupPrice['id'], + 'base_rate' => $rate, + 'price' => $price, + ]; + } + } + } + if (count($insert) > 0) { + StoreProductGroupPrice::insertAll($insert); + } + if (count($update) > 0) { + (new StoreProductGroupPrice())->saveAll($update); } - $count = Db::name('product_price_set')->insertAll($insert); return $this->success('插入成功:' . $count . '条'); } From aee0609d171b84e8fb95d6ad2f07036712672323 Mon Sep 17 00:00:00 2001 From: lewis <604446095@qq.com> Date: Tue, 31 Dec 2024 11:29:25 +0800 Subject: [PATCH 36/38] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=95=86=E5=93=81?= =?UTF-8?q?=E5=88=86=E7=BB=84=E4=BB=B7=E6=A0=BC=E8=AE=A1=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/LocalController.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/admin/controller/LocalController.php b/app/admin/controller/LocalController.php index bba0ebdd..173bd853 100644 --- a/app/admin/controller/LocalController.php +++ b/app/admin/controller/LocalController.php @@ -7,7 +7,6 @@ use app\common\model\store_product\StoreProduct; use app\common\model\store_product_group_price\StoreProductGroupPrice; use PhpOffice\PhpSpreadsheet\IOFactory; use support\Redis; -use think\facade\Db; class LocalController extends BaseAdminController { @@ -118,7 +117,7 @@ class LocalController extends BaseAdminController if (count($update) > 0) { (new StoreProductGroupPrice())->saveAll($update); } - return $this->success('插入成功:' . $count . '条'); + return $this->success('插入成功:' . count($insert) . '条,更新成功:' . count($update) . '条'); } public function fixCategory() From 733adc5091beae593181b8dc1db28df910076016 Mon Sep 17 00:00:00 2001 From: lewis <604446095@qq.com> Date: Tue, 31 Dec 2024 13:35:42 +0800 Subject: [PATCH 37/38] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=95=86=E5=93=81?= =?UTF-8?q?=E9=87=87=E8=B4=AD=E4=BB=B7=E6=A0=BC=E8=AE=BE=E7=BD=AE=E7=9A=84?= =?UTF-8?q?=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PurchaseProductOfferLogic.php | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php b/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php index 7caa7a63..d1c286d2 100644 --- a/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php +++ b/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php @@ -431,14 +431,30 @@ class PurchaseProductOfferLogic extends BaseLogic public static function getProductCatePriceRate($product) { $productCatePriceRate = StoreCategory::where('id', $product['cate_id'])->value('price_rate'); - if (!empty($productCatePriceRate)) { + if (!empty($productCatePriceRate) && self::hasPurchase($productCatePriceRate)) { return $productCatePriceRate; } $productCatePriceRate = StoreCategory::where('id', $product['two_cate_id'])->value('price_rate'); - if (!empty($productCatePriceRate)) { + if (!empty($productCatePriceRate) && self::hasPurchase($productCatePriceRate)) { return $productCatePriceRate; } - return StoreCategory::where('id', $product['top_cate_id'])->value('price_rate'); + $productCatePriceRate = StoreCategory::where('id', $product['top_cate_id'])->value('price_rate'); + if (!empty($productCatePriceRate) && self::hasPurchase($productCatePriceRate)) { + return $productCatePriceRate; + } + return []; + } + + public static function hasPurchase(array $productCatePriceRate): bool + { + $res = true; + foreach ($productCatePriceRate as $item) { + if ($item['id'] == 21 && empty($item['rate'])) { + $res = false; + break; + } + } + return $res; } } From 77a1b62bb3ca7d3a684940dfb57c00b24669d2c2 Mon Sep 17 00:00:00 2001 From: lewis <604446095@qq.com> Date: Tue, 31 Dec 2024 14:13:35 +0800 Subject: [PATCH 38/38] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=95=86=E5=93=81?= =?UTF-8?q?=E9=87=87=E8=B4=AD=E4=BB=B7=E6=A0=BC=E8=AE=BE=E7=BD=AE=E7=9A=84?= =?UTF-8?q?=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../purchase_product_offer/PurchaseProductOfferLogic.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php b/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php index d1c286d2..fd04f6b2 100644 --- a/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php +++ b/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php @@ -378,7 +378,13 @@ class PurchaseProductOfferLogic extends BaseLogic break; } } + if (empty($storeProductGroupPrice)) { + return; + } foreach ($productCatePriceRate as $k => $v) { + if (empty($v['rate'])) { + continue; + } if ($v['id'] == 4 &&$purchase>0) { //商户 $data['cost_lv'] = bcdiv($v['rate'], 100, 2);