From a944e9936fbcfbdbf8871f79b09099406992b367 Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Thu, 27 Jun 2024 15:37:04 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=88=86=E7=B1=BB?= =?UTF-8?q?=E5=90=8C=E6=AD=A5=E5=B0=8F=E7=A8=8B=E5=BA=8F=E5=88=86=E7=B1=BB?= =?UTF-8?q?=E7=9B=B8=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../logic/store_product/StoreProductLogic.php | 33 +++++++++++++++++-- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/app/admin/logic/store_product/StoreProductLogic.php b/app/admin/logic/store_product/StoreProductLogic.php index bcecea565..6887fa881 100644 --- a/app/admin/logic/store_product/StoreProductLogic.php +++ b/app/admin/logic/store_product/StoreProductLogic.php @@ -127,6 +127,33 @@ class StoreProductLogic extends BaseLogic } } + /* + * 传入三级或者二级分类返还上级分类 一级那全是相同 + */ + public static function dealChangeCate($cate_id) + { + $value =[]; + $last_cate = Db::name('store_category')->where('id',$cate_id)->value('pid'); + if(!empty($last_cate)){ + //2 + $value['two_cate_id'] = $last_cate; + //1 + $first_cate = Db::name('store_category')->where('id',$value['two_cate_id'])->value('pid'); + if(empty($first_cate)){//顶级了 + $value['two_cate_id'] = $cate_id; + $value['top_cate_id'] = $last_cate; + }else{ + $value['top_cate_id'] = $first_cate; + } + + }else{ + //1-2 选的1级目录 + $value['two_cate_id'] = $cate_id; + $value['top_cate_id'] = $cate_id; + } + return $value; + } + /** * @notes 编辑商品列表 * @param array $params @@ -175,15 +202,15 @@ class StoreProductLogic extends BaseLogic self::updateGoodsclass($params['cate_id'], $value['store_id']); } }*/ - - + $dealCate = self::dealChangeCate($params['cate_id']); //修改 StoreBranchProduct::where('product_id', $params['id'])->update([ 'price' => $params['price'], 'vip_price' => $params['vip_price'], 'cost' => $params['cost'],'unit'=>$params['unit'], 'batch'=>$params['batch'],'store_name'=>$params['store_name'], 'manufacturer_information' => $params['manufacturer_information']??'', - 'store_info' => $params['store_info']??'', + 'store_info' => $params['store_info']??'','cate_id'=>$params['cate_id'], + 'top_cate_id'=>$dealCate['top_cate_id'],'two_cate_id'=>$dealCate['two_cate_id'] ]); Db::commit(); From abd9e2cb82afa8cf25c715dcef852be5a9098461 Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Thu, 27 Jun 2024 15:41:50 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=A4=8D=E5=88=B6?= =?UTF-8?q?=E5=92=8C=E6=8E=A8=E9=80=81=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../logic/store_product/StoreProductLogic.php | 3 ++ app/queue/redis/StoreStorageSend.php | 30 +++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/app/admin/logic/store_product/StoreProductLogic.php b/app/admin/logic/store_product/StoreProductLogic.php index 6887fa881..1220fab27 100644 --- a/app/admin/logic/store_product/StoreProductLogic.php +++ b/app/admin/logic/store_product/StoreProductLogic.php @@ -310,6 +310,7 @@ class StoreProductLogic extends BaseLogic $attr_value = StoreProductAttrValue::where('product_id', $id)->findOrEmpty(); Db::startTrans(); try { + $dealCate = self::dealChangeCate($find['cate_id']); $product = [ 'product_id' => $find['id'], 'image' => $find['image'], @@ -318,6 +319,8 @@ class StoreProductLogic extends BaseLogic 'keyword' => $find['keyword'], 'bar_code' => $find['bar_code'], 'cate_id' => $find['cate_id'], + 'top_cate_id' => $dealCate['top_cate_id'], + 'two_cate_id' => $dealCate['two_cate_id'], 'price' => $find['price'], 'unit' => $find['unit'], 'store_id' => $store_id, diff --git a/app/queue/redis/StoreStorageSend.php b/app/queue/redis/StoreStorageSend.php index 02e7eefe6..04f5ad9ba 100644 --- a/app/queue/redis/StoreStorageSend.php +++ b/app/queue/redis/StoreStorageSend.php @@ -46,6 +46,7 @@ class StoreStorageSend implements Consumer $attr_value = StoreProductAttrValue::where('product_id', $product_arr['id'])->findOrEmpty(); Db::startTrans(); try { + $dealCate = self::dealChangeCate($find['cate_id']); $product = [ 'product_id' => $find['id'], 'image' => $find['image'], @@ -54,6 +55,8 @@ class StoreStorageSend implements Consumer 'keyword' => $find['keyword'], 'bar_code' => $find['bar_code'], 'cate_id' => $find['cate_id'], + 'top_cate_id' => $dealCate['top_cate_id'], + 'two_cate_id' => $dealCate['two_cate_id'], 'price' => $find['price'], // 'cost' => $find['cost'], //v1.0 'cost' => $find['cost'], @@ -179,4 +182,31 @@ class StoreStorageSend implements Consumer Log::error('store-storage队列消费失败: ' . $e->getMessage() . ',line:' . $e->getLine() . ',file:' . $e->getFile()); return $package; } + + /* + * 传入三级或者二级分类返还上级分类 一级那全是相同 + */ + public static function dealChangeCate($cate_id) + { + $value =[]; + $last_cate = Db::name('store_category')->where('id',$cate_id)->value('pid'); + if(!empty($last_cate)){ + //2 + $value['two_cate_id'] = $last_cate; + //1 + $first_cate = Db::name('store_category')->where('id',$value['two_cate_id'])->value('pid'); + if(empty($first_cate)){//顶级了 + $value['two_cate_id'] = $cate_id; + $value['top_cate_id'] = $last_cate; + }else{ + $value['top_cate_id'] = $first_cate; + } + + }else{ + //1-2 选的1级目录 + $value['two_cate_id'] = $cate_id; + $value['top_cate_id'] = $cate_id; + } + return $value; + } } From 10ed5f432c2a385733e8cb33860bb398ff22e37d Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Thu, 27 Jun 2024 16:01:13 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E8=80=81=E6=95=B0=E6=8D=AE=E5=85=BC?= =?UTF-8?q?=E5=AE=B9=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/lists/store_order/StoreOrderLists.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/admin/lists/store_order/StoreOrderLists.php b/app/admin/lists/store_order/StoreOrderLists.php index 7ba04fd0b..39c010c45 100644 --- a/app/admin/lists/store_order/StoreOrderLists.php +++ b/app/admin/lists/store_order/StoreOrderLists.php @@ -80,8 +80,8 @@ class StoreOrderLists extends BaseAdminDataLists implements ListsSearchInterface $product = StoreOrderCartInfo::where('oid', $item['id'])->field(['id', 'oid', 'product_id', 'cart_info']) ->limit(3)->select(); foreach ($product as &$items) { - $items['store_name'] = $items['cart_info']['name']; - $items['image'] = $items['cart_info']['image']; + $items['store_name'] = $items['cart_info']['name']??''; + $items['image'] = $items['cart_info']['image']??''; } $item['product'] = $product; return $item; From cf3dc5d25909ba397e099da881a576df49080111 Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Thu, 27 Jun 2024 16:12:02 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=97=A8=E5=BA=97?= =?UTF-8?q?=E6=94=B6=E6=AC=BE=E9=80=BB=E8=BE=91=E7=9A=84=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/statistics/logic/OrderLogic.php | 12 ++++++++++++ app/store/logic/WorkbenchLogic.php | 3 ++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/app/statistics/logic/OrderLogic.php b/app/statistics/logic/OrderLogic.php index 3f1617ac7..274653768 100644 --- a/app/statistics/logic/OrderLogic.php +++ b/app/statistics/logic/OrderLogic.php @@ -67,6 +67,18 @@ class OrderLogic extends BaseLogic return bcadd($todayAmount, $pay_price, 2); } + public static function dealFlexiblePrice($where,$start,$end) + { + $todayAmount = UserRecharge::where($where) + ->whereBetweenTime('create_time', $start, $end) + ->sum('price'); + $pay_price = StoreOrder::where($where) + ->whereBetweenTime('create_time', $start, $end) + ->sum('pay_price'); + return bcadd($todayAmount, $pay_price, 2); + + } + public static function sales($where,$time){ $select=StoreOrder::where($where)->whereDay('create_time',$time)->limit(10)->order('id desc')->field('id,order_id,pay_price,create_time')->select(); return $select?->toArray(); diff --git a/app/store/logic/WorkbenchLogic.php b/app/store/logic/WorkbenchLogic.php index 72431a400..748df2080 100644 --- a/app/store/logic/WorkbenchLogic.php +++ b/app/store/logic/WorkbenchLogic.php @@ -84,7 +84,8 @@ class WorkbenchLogic extends BaseLogic $data['income_amount'] = StoreFinanceFlow::where($storeFinanceWhere)->whereBetweenTime('create_time', $startTime, $endTime)->sum('number'); //门店收款金额 $all_where['paid'] = 1; - $data['receipt_amount'] = OrderLogic::dayPayPrice($all_where,date('Y-m-d',time())); +// $data['receipt_amount'] = OrderLogic::dayPayPrice($all_where,date('Y-m-d',time())); + $data['receipt_amount'] = OrderLogic::dealFlexiblePrice($all_where,$startTime,$endTime); // $data['receipt_amount'] = UserRecharge::where($userRechargeWhere)->whereBetweenTime('create_time', $startTime, $endTime)->sum('price'); //保证金金额 $data['deposit_amount'] = StoreFinanceFlow::where($storeFinanceWhereTwo)->whereBetweenTime('create_time', $startTime, $endTime)->sum('number');