From 192169542e1217af42f1b252d5ff28c9b5b90729 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Thu, 13 Jun 2024 17:49:42 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9B=B4=E6=96=B0=E5=95=86=E5=93=81?= =?UTF-8?q?=E5=88=86=E7=B1=BB=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../StoreBranchProductLogic.php | 4 +-- .../logic/store_product/StoreProductLogic.php | 14 ++++----- app/api/controller/IndexController.php | 8 +++-- app/common/logic/PayNotifyLogic.php | 1 + app/queue/redis/StoreStorageSend.php | 2 +- app/store/controller/cate/CateController.php | 31 +++++++++++++++++++ .../StoreBranchProductLogic.php | 23 -------------- .../logic/store_product/StoreProductLogic.php | 23 -------------- 8 files changed, 48 insertions(+), 58 deletions(-) create mode 100644 app/store/controller/cate/CateController.php diff --git a/app/admin/logic/store_branch_product/StoreBranchProductLogic.php b/app/admin/logic/store_branch_product/StoreBranchProductLogic.php index 7222a920a..8ff39dd8a 100644 --- a/app/admin/logic/store_branch_product/StoreBranchProductLogic.php +++ b/app/admin/logic/store_branch_product/StoreBranchProductLogic.php @@ -69,7 +69,7 @@ class StoreBranchProductLogic extends BaseLogic }else{ if($params['statis']!=$StoreProduct['statis']){ if($params['statis']==1){ - StoreProductLogic::updateGoodsclass($params['cate_id']); + StoreProductLogic::updateGoodsclass($params['cate_id'],$StoreProduct['store_id']); }else{ self::store_product_cate_update($params['id'], $StoreProduct['cate_id'], $StoreProduct['store_id'],0); @@ -101,7 +101,7 @@ class StoreBranchProductLogic extends BaseLogic } } if($type==1){ - StoreProductLogic::updateGoodsclass($cate_id); + StoreProductLogic::updateGoodsclass($cate_id,$store_id); } } /** diff --git a/app/admin/logic/store_product/StoreProductLogic.php b/app/admin/logic/store_product/StoreProductLogic.php index 7629e7066..73fb5bc12 100644 --- a/app/admin/logic/store_product/StoreProductLogic.php +++ b/app/admin/logic/store_product/StoreProductLogic.php @@ -177,7 +177,7 @@ class StoreProductLogic extends BaseLogic /** * 更新商品分类 */ - public static function updateGoodsclass($cate_id, $type = 0) + public static function updateGoodsclass($cate_id, $store_id=0,$type = 0) { $one = StoreCategory::where('id', $cate_id)->find(); if ($one) { @@ -185,21 +185,21 @@ class StoreProductLogic extends BaseLogic $two = StoreCategory::where('id', $one['pid'])->find(); if ($two) { if ($two['pid'] != 0) { - self::cate_update($cate_id, $two['id'], 0, 3); - self::cate_update($two['id'], $two['pid'], 0, 2); - self::cate_update($two['pid'], 0, 0, 1); + self::cate_update($cate_id, $two['id'], $store_id, 3); + self::cate_update($two['id'], $two['pid'], $store_id, 2); + self::cate_update($two['pid'], 0, $store_id, 1); } } } } - public static function cate_update($cate_id = 0, $pid = 0, $product_id = 0, $level = 1) + public static function cate_update($cate_id = 0, $pid = 0, $store_id = 0, $level = 1) { - $find = Db::name('store_product_cate')->where(['store_id' => 1, 'cate_id' => $cate_id, 'level' => $level])->find(); + $find = Db::name('store_product_cate')->where(['store_id' => $store_id, 'cate_id' => $cate_id, 'level' => $level])->find(); if ($find) { Db::name('store_product_cate')->where('id', $find['id'])->inc('count', 1)->update(); } else { - Db::name('store_product_cate')->insert(['pid' => $pid, 'store_id' => 1, 'cate_id' => $cate_id, 'count' => 1, 'level' => $level, 'create_time' => time(), 'update_time' => time()]); + Db::name('store_product_cate')->insert(['pid' => $pid, 'store_id' => $store_id, 'cate_id' => $cate_id, 'count' => 1, 'level' => $level, 'create_time' => time(), 'update_time' => time()]); } } /** diff --git a/app/api/controller/IndexController.php b/app/api/controller/IndexController.php index 1205aadba..8a31ce440 100644 --- a/app/api/controller/IndexController.php +++ b/app/api/controller/IndexController.php @@ -2,9 +2,11 @@ namespace app\api\controller; +use app\admin\logic\store_product\StoreProductLogic; use app\admin\validate\tools\GenerateTableValidate; use app\admin\logic\tools\GeneratorLogic; use app\common\logic\store_order\StoreOrderLogic; +use app\common\model\store_branch_product\StoreBranchProduct; use app\common\service\pay\PayService; use app\common\service\wechat\WechatTemplate; use Exception; @@ -25,9 +27,11 @@ class IndexController extends BaseApiController public function index() { - Redis::send('push-platform-print', ['order_id' => 119]); - d(2); + $arr=StoreBranchProduct::where('store_id',5)->select(); + foreach ($arr as $item){ + StoreProductLogic::updateGoodsclass($item['cate_id'],5); + } try { $wechat = new PayService(1); $time = time(); diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index 5cbe5aebe..2aaa30f04 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -79,6 +79,7 @@ class PayNotifyLogic extends BaseLogic $capitalFlowDao->userExpense('user_order_pay', 'order', $order['id'], $order['pay_price']); self::afterPay($order); Redis::send('push-platform-print', ['id' => $order['id']], 60); + PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type' => 'store_merchant', 'msg' => '您有一笔新的订单']); } diff --git a/app/queue/redis/StoreStorageSend.php b/app/queue/redis/StoreStorageSend.php index a96e88ad4..97196696d 100644 --- a/app/queue/redis/StoreStorageSend.php +++ b/app/queue/redis/StoreStorageSend.php @@ -65,7 +65,7 @@ class StoreStorageSend implements Consumer if ($product_arr['stock'] > 0) { $this->storage($find, $store_id, $admin_id, $product_arr); } - StoreProductLogic::updateGoodsclass($find['cate_id']); + StoreProductLogic::updateGoodsclass($find['cate_id'],$store_id); Db::commit(); return true; } catch (\Exception $e) { diff --git a/app/store/controller/cate/CateController.php b/app/store/controller/cate/CateController.php new file mode 100644 index 000000000..870d369b9 --- /dev/null +++ b/app/store/controller/cate/CateController.php @@ -0,0 +1,31 @@ +dataLists(new CateLists()); + } + + +} diff --git a/app/store/logic/store_branch_product/StoreBranchProductLogic.php b/app/store/logic/store_branch_product/StoreBranchProductLogic.php index ad7a331ce..b08da5d3b 100644 --- a/app/store/logic/store_branch_product/StoreBranchProductLogic.php +++ b/app/store/logic/store_branch_product/StoreBranchProductLogic.php @@ -127,29 +127,6 @@ class StoreBranchProductLogic extends BaseLogic return StoreProduct::findOrEmpty($params['id'])->toArray(); } - /** - * 更新商品分类 - */ - public static function updateGoodsclass($id, $type = 0) - { - $pid = StoreCategory::where('id', $id)->value('pid'); - if ($pid) { - $goodsclass = StoreCategory::where('id', $pid)->field('pid,children')->find(); - if ($goodsclass) { - if (count($goodsclass['children']) >= 1) { - if (!in_array($id, $goodsclass['children'])) { - $arr = $goodsclass['children']; - array_push($arr, $id); - StoreCategory::where('id', $pid)->update(['children' => $arr]); - if ($goodsclass['pid'] != 0 && $type == 0) { - self::updateGoodsclass($pid, 1); - } - } - } - } - } - } - /** * @notes 商品上下架 * @param array $params diff --git a/app/store/logic/store_product/StoreProductLogic.php b/app/store/logic/store_product/StoreProductLogic.php index 1dd27998d..150040c2f 100644 --- a/app/store/logic/store_product/StoreProductLogic.php +++ b/app/store/logic/store_product/StoreProductLogic.php @@ -122,27 +122,4 @@ class StoreProductLogic extends BaseLogic { return StoreProduct::findOrEmpty($params['id'])->toArray(); } - - /** - * 更新商品分类 - */ - public static function updateGoodsclass($id, $type = 0) - { - $pid = StoreCategory::where('id', $id)->value('pid'); - if ($pid) { - $goodsclass = StoreCategory::where('id', $pid)->field('pid,children')->find(); - if ($goodsclass) { - if (count($goodsclass['children']) >= 1) { - if (!in_array($id, $goodsclass['children'])) { - $arr = $goodsclass['children']; - array_push($arr, $id); - StoreCategory::where('id', $pid)->update(['children' => $arr]); - if ($goodsclass['pid'] != 0 && $type == 0) { - self::updateGoodsclass($pid, 1); - } - } - } - } - } - } }