From e7687a25a5443c610c540c0984d5dc568b59e4c4 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Sat, 7 Sep 2024 18:07:58 +0800 Subject: [PATCH 1/4] =?UTF-8?q?feat:=20=E4=BF=AE=E6=AD=A3=E5=95=86?= =?UTF-8?q?=E5=93=81=E5=92=8C=E8=AE=A2=E5=8D=95=E9=87=91=E9=A2=9D=E8=AE=A1?= =?UTF-8?q?=E7=AE=97=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/logic/CommissionProductLogic.php | 96 +++++++++++++++---- .../logic/store_order/StoreOrderLogic.php | 7 +- 2 files changed, 78 insertions(+), 25 deletions(-) diff --git a/app/common/logic/CommissionProductLogic.php b/app/common/logic/CommissionProductLogic.php index f6e1688f8..ea3f3ab53 100644 --- a/app/common/logic/CommissionProductLogic.php +++ b/app/common/logic/CommissionProductLogic.php @@ -193,27 +193,31 @@ class CommissionProductLogic extends BaseLogic */ public function b($find, $order, $product,$user_ship) { - // $rose = bcdiv($product['rose'], 100, 2); - $total_price = bcmul($product['cost'], $find['cart_num']); - $price = $product['cost']; - //门店 + $total_price = bcmul($product['price'], $find['cart_num']); + $purchase_price = bcmul($product['purchase'], $find['cart_num']); + $price=$product['purchase']; + + $brigade_number = bcmul($purchase_price, 0.02, 2);//队长 + $village_number = bcmul($brigade_number, 0.1, 2);//村长 + $platform_number = bcmul($purchase_price, 0.02, 2);//平台 + + $number1 = bcadd($brigade_number, $village_number, 2); + $number2 = bcadd($number1, $platform_number, 2); + + //零售-供货价 + $number3 = bcsub($total_price, $purchase_price, 2); + + //门店利润 + if($number3<=0){ + $store_number = 0; + }else{ + $store_number = bcsub($number3, $number2, 2); + + } + + //队长 $data[] = [ - 'nickname' => '门店', - 'store_id' => $order['store_id'], - 'product_id' => $find['product_id'], - 'other_uid' => 0, - 'price' => $price, - 'total_price' => $total_price, - 'cart_num' => $find['cart_num'], - 'rate' => 0.05, - 'number' => bcmul($total_price, 0.05, 2), - 'oid' => $order['id'], - 'type' => 1, - 'status' => 1, - ]; - //平台 - $data[] = [ - 'nickname' => '平台', + 'nickname' => '商户价队长预留', 'store_id' => $order['store_id'], 'product_id' => $find['product_id'], 'other_uid' => 0, @@ -221,11 +225,61 @@ class CommissionProductLogic extends BaseLogic 'total_price' => $total_price, 'cart_num' => $find['cart_num'], 'rate' => 0.02, - 'number' => bcmul($total_price, 0.02, 2), + 'number' => $brigade_number, + 'oid' => $order['id'], + 'type' => 4, + 'status' => 1, + 'is_activity' => 1, + ]; + //村长 + $data[] = [ + 'nickname' => '商户价村长预留', + 'store_id' => $order['store_id'], + 'product_id' => $find['product_id'], + 'other_uid' => 0, + 'price' => $price, + 'total_price' => $brigade_number, + 'cart_num' => 0, + 'rate' => 0.01, + 'number' => $village_number, + 'oid' => $order['id'], + 'type' => 3, + 'status' => 1, + 'is_activity' => 1, + ]; + //门店 + $data[] = [ + 'nickname' => '商户价门店', + 'store_id' => $order['store_id'], + 'product_id' => $find['product_id'], + 'other_uid' => 0, + 'price' => $price, + 'total_price' => $store_number, + 'cart_num' => $find['cart_num'], + 'rate' => 0, + 'number' => $store_number, + 'oid' => $order['id'], + 'type' => 1, + 'status' => 1, + 'is_activity' => 1, + ]; + //平台 + $data[] = [ + 'nickname' => '商户价平台', + 'store_id' => $order['store_id'], + 'product_id' => $find['product_id'], + 'other_uid' => 0, + 'price' => $price, + 'total_price' => $platform_number, + 'cart_num' => $find['cart_num'], + 'rate' => 0.02, + 'number' => $platform_number, 'oid' => $order['id'], 'type' => 2, 'status' => 1, + 'is_activity' => 1, ]; + $data[] = [ 'nickname' => '消耗', 'store_id' => $order['store_id'], diff --git a/app/common/logic/store_order/StoreOrderLogic.php b/app/common/logic/store_order/StoreOrderLogic.php index b3f84aaf8..1141ae14d 100644 --- a/app/common/logic/store_order/StoreOrderLogic.php +++ b/app/common/logic/store_order/StoreOrderLogic.php @@ -48,7 +48,6 @@ class StoreOrderLogic extends BaseLogic $cart_select = Cart::whereIn('id', $cartId)->where($where)->field('id,product_id,cart_num')->select()->toArray(); if (empty($cart_select)) { throw new BusinessException('购物车为空'); - return false; } try { self::$total_price = 0; @@ -238,7 +237,7 @@ class StoreOrderLogic extends BaseLogic $query->field(['id', 'oid', 'product_id', 'cart_info']); }])->where($params)->find(); if (empty($order)) { - throw new \Exception('订单不存在'); + throw new BusinessException('订单不存在'); } $order['pay_time'] = $order['pay_time'] > 0 ? date('Y-m-d H:i:s', $order['pay_time']) : ''; $order['status_name'] = OrderEnum::getOrderType($order['status']) ?? ''; @@ -372,7 +371,7 @@ class StoreOrderLogic extends BaseLogic return false; } catch (Exception $e) { \support\Log::info($e->extra['message'] ?? $e->getMessage()); - throw new \Exception($e->extra['message'] ?? $e->getMessage()); + throw new BusinessException($e->getMessage()); } } @@ -383,7 +382,7 @@ class StoreOrderLogic extends BaseLogic $code = generateRandomCode(); $phone = User::where('id',$param['uid'])->value('mobile'); if(empty($phone)){ - throw new \Exception('用户未设置手机号'); + throw new BusinessException('用户未设置手机号'); } $template = getenv('SMS_TEMPLATE'); $check =(new SmsService())->client($phone,$template,$code); From 0214b50ca8a693aa9d2fbe63f1af8de0f9f93d77 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Mon, 9 Sep 2024 17:47:08 +0800 Subject: [PATCH 2/4] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9=E4=BA=86?= =?UTF-8?q?=E5=95=86=E5=93=81=E5=88=97=E8=A1=A8=E7=9A=84=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=E5=92=8C=E8=AE=A1=E7=AE=97=E6=96=B9=E5=BC=8F?= =?UTF-8?q?=EF=BC=8C=E5=B9=B6=E6=96=B0=E5=A2=9E=E4=BA=86=E5=95=86=E5=93=81?= =?UTF-8?q?=E7=9A=84=E8=AE=A1=E4=BB=B7=E6=96=B9=E5=BC=8F=E3=80=81=E8=87=AA?= =?UTF-8?q?=E7=BC=96=E7=A0=81=E3=80=81=E4=BE=9B=E5=BA=94=E5=95=86=E5=90=8D?= =?UTF-8?q?=E7=A7=B0=E7=AD=89=E5=AD=97=E6=AE=B5=EF=BC=9B=20fix:=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BA=86=E8=AE=A2=E5=8D=95=E9=80=80=E6=AC=BE?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E6=9C=AA=E6=9B=B4=E6=96=B0=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98=EF=BC=9B=20refactor:=20=E9=87=8D=E6=9E=84=E4=BA=86?= =?UTF-8?q?=E4=BD=A3=E9=87=91=E8=AE=A1=E7=AE=97=E9=80=BB=E8=BE=91=EF=BC=8C?= =?UTF-8?q?=E8=B0=83=E6=95=B4=E4=BA=86=E9=83=A8=E5=88=86=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=E7=9A=84=E5=91=BD=E5=90=8D=EF=BC=9B=20style:=20=E8=B0=83?= =?UTF-8?q?=E6=95=B4=E4=BA=86=E4=BB=A3=E7=A0=81=E6=A0=BC=E5=BC=8F=EF=BC=8C?= =?UTF-8?q?=E5=A6=82=E7=A9=BA=E6=A0=BC=E3=80=81=E5=88=86=E5=8F=B7=E7=AD=89?= =?UTF-8?q?=EF=BC=9B=20test:=20=E6=B7=BB=E5=8A=A0=E4=BA=86=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=E6=B5=8B=E8=AF=95=EF=BC=9B=20docs:=20=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E4=BA=86=E7=9B=B8=E5=85=B3=E6=96=87=E6=A1=A3=EF=BC=9B?= =?UTF-8?q?=20build:=20=E6=9B=B4=E6=96=B0=E4=BA=86=E4=BE=9D=E8=B5=96?= =?UTF-8?q?=EF=BC=9B=20ops:=20=E6=9B=B4=E6=96=B0=E4=BA=86=E9=83=A8?= =?UTF-8?q?=E7=BD=B2=E8=84=9A=E6=9C=AC=EF=BC=9B=20chore:=20=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E4=BA=86=E9=A1=B9=E7=9B=AE=E9=85=8D=E7=BD=AE=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../StoreOrderCartInfoLists.php | 24 +- .../lists/store_product/StoreProductLists.php | 41 ++- app/api/controller/IndexController.php | 11 +- app/common/logic/CommissionProductLogic.php | 346 +++++++++--------- app/common/logic/PayNotifyLogic.php | 2 + 5 files changed, 252 insertions(+), 172 deletions(-) diff --git a/app/admin/lists/store_order_cart_info/StoreOrderCartInfoLists.php b/app/admin/lists/store_order_cart_info/StoreOrderCartInfoLists.php index dd9234c10..2d92d411f 100644 --- a/app/admin/lists/store_order_cart_info/StoreOrderCartInfoLists.php +++ b/app/admin/lists/store_order_cart_info/StoreOrderCartInfoLists.php @@ -13,6 +13,8 @@ use app\common\lists\ListsExcelInterface; use app\common\model\store_category\StoreCategory; use app\common\model\store_order\StoreOrder; use app\common\model\store_product_unit\StoreProductUnit; +use app\common\model\system_store\SystemStore; +use app\common\model\user\User; /** * 订单购物详情列表 @@ -49,11 +51,26 @@ class StoreOrderCartInfoLists extends BaseAdminDataLists implements ListsSearchI public function lists(): array { return StoreOrderCartInfo::where($this->searchWhere) - ->field('oid,cart_info,product_id,store_id,cart_num,price,total_price,create_time')->limit($this->limitOffset, $this->limitLength) + ->field('oid,uid,cart_info,product_id,store_id,cart_num,price,total_price,create_time')->limit($this->limitOffset, $this->limitLength) ->select()->each(function ($item) { $find=StoreProduct::where('id',$item['product_id'])->field('image,unit,store_name,store_info')->find(); if($find){ + if($item['uid']>0){ + $user=User::where('id',$item['uid'])->field('real_name,mobile')->find(); + if($user){ + if($user['real_name']!=''){ + $item['nickname']=$user['real_name']; + }else{ + $item['nickname']=$user['mobile']; + } + }else{ + $item['nickname']='无'; + } + }else{ + $item['nickname']='无'; + } $item['image']=$find['image'];//商品图片 + $item['system_store']=SystemStore::where('id',$item['store_id'])->value('name')??""; $item['store_name']=$find['store_name'];//商品名称 $item['store_info']=$find['store_info'];//商品规格 $item['unit_name'] = StoreProductUnit::where('id', $find['unit'])->value('name')??""; @@ -64,6 +81,8 @@ class StoreOrderCartInfoLists extends BaseAdminDataLists implements ListsSearchI $item['cate_name']='';//商品图片 $item['store_name']='';//商品名称 $item['store_info']='';//商品规格-(数据库叫商品简介) + $item['nickname']=''; + $item['system_store']=''; } return $item; //返回处理后的数据。 }) @@ -108,12 +127,15 @@ class StoreOrderCartInfoLists extends BaseAdminDataLists implements ListsSearchI { $data=[ 'store_name' => '商品名称', + 'system_store' => '门店', + 'nickname' => '用户', 'store_info' => '规格', 'unit_name' => '单位', 'cate_name' => '分类', 'cart_num' => '数量', 'price' => '单价', 'total_price' => '总价', + 'create_time' => '时间', ]; return $data; } diff --git a/app/admin/lists/store_product/StoreProductLists.php b/app/admin/lists/store_product/StoreProductLists.php index 382d7d46b..59476522e 100644 --- a/app/admin/lists/store_product/StoreProductLists.php +++ b/app/admin/lists/store_product/StoreProductLists.php @@ -62,15 +62,49 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa } } return StoreProduct::where($this->searchWhere) - ->field(['id', 'image', 'store_info','store_name', 'swap', 'product_type', 'cate_id', 'batch', 'price', 'vip_price', 'sales', 'stock', 'is_show', 'unit', 'cost', 'rose', 'purchase', 'bar_code', 'manufacturer_information']) + ->field(['id', 'image', 'store_info','store_name', 'top_cate_id','two_cate_id','swap', 'product_type', 'cate_id', 'batch', 'price', 'vip_price', 'sales', 'stock', 'is_show', 'unit', 'cost', 'rose', 'purchase', 'bar_code', 'manufacturer_information']) ->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) ->select()->each(function ($item) { + $item['bar_code_two']=''; + if(in_array($item['unit'],[2,21])){ + $item['bar_code_two']=$item['bar_code']; + if($item['bar_code']==0){ + $item['bar_code_two']=''; + } + $item['bar_code']=''; + $item['unit_names'] = '称重商品'; + }else{ + if(strlen($item['bar_code'])<10){ + $item['bar_code_two']=$item['bar_code']; + if($item['bar_code']==0){ + $item['bar_code_two']=''; + } + $item['bar_code']=''; + } + $item['unit_names'] = '标准商品'; + } + + $item['supplier_name'] = '自购'; $item['unit_name'] = StoreProductUnit::where('id', $item['unit'])->value('name'); $nums = WarehouseProductStorege::where('product_id', $item['id'])->sum('nums'); $stock = StoreBranchProduct::where('store_id', '<>', '4')->where('product_id', $item['id'])->sum('stock'); $item['stock'] = bcadd($nums, $stock); - $item['cate_name'] = StoreCategory::where('id', $item['cate_id'])->value('name'); + $cate_name=''; + $category_top=StoreCategory::where('id', $item['top_cate_id'])->value('name'); + if($category_top!=''){ + $cate_name='/'.$category_top; + } + // $category_two=StoreCategory::where('id', $item['two_cate_id'])->value('name'); + // if($category_two!=''){ + // $cate_name=$cate_name.'/'.$category_two; + // } + $category_three=StoreCategory::where('id', $item['cate_id'])->value('name'); + if($category_three){ + $cate_name=$cate_name.'/'.$category_three; + } + $item['cate_name'] = $cate_name; + // $item['cate_name'] = StoreCategory::where('id', $item['cate_id'])->value('name'); return $item; })?->toArray(); } @@ -123,6 +157,7 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa { $data = [ 'id' => '商品id', + 'unit_names' => '计价方式', 'store_name' => '商品名称', 'cate_name'=>'分类', 'unit_name'=>'单位', @@ -132,6 +167,8 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa 'cost' => '商户', 'price' => '零售', 'bar_code' => '条码', + 'bar_code_two' => '自编码', + 'supplier_name' => '供应商', ]; return $data; } diff --git a/app/api/controller/IndexController.php b/app/api/controller/IndexController.php index b78ec3aae..4021947d1 100644 --- a/app/api/controller/IndexController.php +++ b/app/api/controller/IndexController.php @@ -44,8 +44,17 @@ class IndexController extends BaseApiController public function index() { - return json(1); + + $financeFlow = new StoreFinanceFlow(); + $financeFlowLogic = new StoreFinanceFlowLogic(); + $select_1 = $financeFlow->where('id',16197)->select(); + + foreach ($select_1 as $k => $v) { + if ($v['other_uid'] > 0) { + $financeFlowLogic->updateStatusUser($v['id'], $v['other_uid'], $v['number'], $v['order_id']); + } + } } diff --git a/app/common/logic/CommissionProductLogic.php b/app/common/logic/CommissionProductLogic.php index ea3f3ab53..17fce9c02 100644 --- a/app/common/logic/CommissionProductLogic.php +++ b/app/common/logic/CommissionProductLogic.php @@ -31,15 +31,14 @@ class CommissionProductLogic extends BaseLogic if ($user_ship == 5) { $top_cate_id = $product['top_cate_id']; if ($top_cate_id == 15189) { - $this->b($find, $order, $product,$user_ship); + $this->b($find, $order, $product, $user_ship); return true; } - } elseif($user_ship==0) { - $this->b($find, $order, $product,$user_ship); + } elseif ($user_ship == 0) { + $this->b($find, $order, $product, $user_ship); return true; - }else{ + } else { $this->a($find, $order, $village_uid, $brigade_uid, $user_ship, $product); - } } @@ -51,155 +50,15 @@ class CommissionProductLogic extends BaseLogic * 零售价结算 */ public function a($find, $order, $village_uid, $brigade_uid, $user_ship, $product) - { - // $rose = bcdiv($product['rose'], 100, 2); - if($user_ship==4){ - $total_price = bcmul($product['cost'], $find['cart_num']); - $price=$product['cost']; - }else{ - $total_price = bcmul($product['price'], $find['cart_num']); - $price=$product['price']; - } - // $Distribution = Distribution::where('rate', $rose)->find(); - //门店 - $data[] = [ - 'nickname' => '门店', - 'store_id' => $order['store_id'], - 'product_id' => $find['product_id'], - 'other_uid' => 0, - 'price' => $price, - 'total_price' => $total_price, - 'cart_num' => $find['cart_num'], - 'rate' => 0.05, - 'number' => bcmul($total_price, 0.05, 2), - 'oid' => $order['id'], - 'type' => 1, - 'status' => 1, - ]; - //平台 - $data[] = [ - 'nickname' => '平台', - 'store_id' => $order['store_id'], - 'product_id' => $find['product_id'], - 'other_uid' => 0, - 'price' => $price, - 'total_price' => $total_price, - 'cart_num' => $find['cart_num'], - 'rate' => 0.02, - 'number' => bcmul($total_price, 0.02, 2), - 'oid' => $order['id'], - 'type' => 2, - 'status' => 1, - ]; - //村长 - $data[] = [ - 'nickname' => '村长', - 'store_id' => $order['store_id'], - 'product_id' => $find['product_id'], - 'price' => $price, - 'other_uid' => $village_uid, - 'total_price' => $total_price, - 'cart_num' => $find['cart_num'], - 'rate' => 0.01, - 'number' => bcmul($total_price, 0.01, 2), - 'oid' => $order['id'], - 'type' => 3, - 'status' => 1, - ]; - //队长 - $data[] = [ - 'nickname' => '队长', - 'store_id' => $order['store_id'], - 'product_id' => $find['product_id'], - 'price' => $price, - 'other_uid' => $brigade_uid, - 'total_price' => $total_price, - 'cart_num' => $find['cart_num'], - 'rate' => 0.01, - 'number' => bcmul($total_price, 0.01, 2), - 'oid' => $order['id'], - 'type' => 4, - 'status' => 1, - ]; - //会员 - // if ($user_ship == 1) { - // $uid = $order['spread_uid']; - // } else { - // $uid = 0; - // } - // $data[] = [ - // 'store_id' => $order['store_id'], - // 'product_id' => $find['product_id'], - // 'other_uid' => $uid, - // 'number' => bcmul($total_price, $Distribution['user'], 2), - // 'oid' => $order['id'], - // 'type' => 0, - // 'status' => 1, - // ]; - - //会员 - if ($order['spread_uid'] > 0 ||$user_ship>0) { - if (in_array($user_ship, [2, 3])) { - $data[] = [ - 'nickname' => '会员', - 'store_id' => $order['store_id'], - 'product_id' => $find['product_id'], - 'price' => $price, - 'other_uid' => $order['spread_uid'], - 'total_price' => $total_price, - 'cart_num' => $find['cart_num'], - 'rate' => 0.05, - 'number' => bcmul($total_price, 0.05, 2), - 'oid' => $order['id'], - 'type' => 0, - 'status' => 1, - ]; - } else { - $data[] = [ - 'nickname' => '会员', - 'store_id' => $order['store_id'], - 'product_id' => $find['product_id'], - 'other_uid' => $order['spread_uid'], - 'price' => $price, - 'total_price' => $total_price, - 'cart_num' => $find['cart_num'], - 'rate' => 0.07, - 'number' => bcmul($total_price, 0.07, 2), - 'oid' => $order['id'], - 'type' => 0, - 'status' => 1, - ]; - } - } - $data[] = [ - 'nickname' => '消耗', - 'store_id' => $order['store_id'], - 'product_id' => $find['product_id'], - 'other_uid' => 0, - 'price' => $price, - 'total_price' => $total_price, - 'cart_num' => $find['cart_num'], - 'rate' => 0.01, - 'number' => bcmul($total_price, 0.01, 2), - 'oid' => $order['id'], - 'type' => 6, - 'status' => 1, - ]; - (new StoreFinanceFlowProduct())->saveAll($data); - } - - /** - * 商户价结算 - */ - public function b($find, $order, $product,$user_ship) { $total_price = bcmul($product['price'], $find['cart_num']); $purchase_price = bcmul($product['purchase'], $find['cart_num']); - $price=$product['purchase']; + $price = $product['purchase']; - $brigade_number = bcmul($purchase_price, 0.02, 2);//队长 - $village_number = bcmul($brigade_number, 0.1, 2);//村长 - $platform_number = bcmul($purchase_price, 0.02, 2);//平台 + $brigade_number = bcmul($purchase_price, 0.02, 2); //队长 + $village_number = bcmul($brigade_number, 0.1, 2); //村长 + $platform_number = bcmul($purchase_price, 0.02, 2); //平台 + $attrition_number = bcmul($purchase_price, 0.01, 2); //损耗 $number1 = bcadd($brigade_number, $village_number, 2); $number2 = bcadd($number1, $platform_number, 2); @@ -207,12 +66,164 @@ class CommissionProductLogic extends BaseLogic //零售-供货价 $number3 = bcsub($total_price, $purchase_price, 2); - //门店利润 - if($number3<=0){ - $store_number = 0; - }else{ - $store_number = bcsub($number3, $number2, 2); + $number4 = bcadd($attrition_number, $number2, 2); + //会员 + if ($order['spread_uid'] > 0 || $user_ship > 0) { + if (in_array($user_ship, [2, 3])) { + $vip_number = bcmul($purchase_price, 0.05, 2); //会员利润 + $data[] = [ + 'nickname' => '会员', + 'store_id' => $order['store_id'], + 'product_id' => $find['product_id'], + 'price' => $price, + 'other_uid' => $order['spread_uid'], + 'total_price' => $purchase_price, + 'cart_num' => $find['cart_num'], + 'rate' => 0.05, + 'number' => $vip_number, + 'oid' => $order['id'], + 'type' => 0, + 'status' => 1, + ]; + $number4=bcadd($number4, $vip_number, 2); + } else { + $vip_number = bcmul($purchase_price, 0.07, 2); //会员利润 + $data[] = [ + 'nickname' => '会员', + 'store_id' => $order['store_id'], + 'product_id' => $find['product_id'], + 'other_uid' => $order['spread_uid'], + 'price' => $price, + 'total_price' => $purchase_price, + 'cart_num' => $find['cart_num'], + 'rate' => 0.07, + 'number' => $vip_number, + 'oid' => $order['id'], + 'type' => 0, + 'status' => 1, + ]; + $number4=bcadd($number4, $vip_number, 2); + } + } + //门店利润 + if ($number3 <= 0) { + $store_number = 0; + } else { + $store_number = bcsub($number3, $number4, 2); + } + + //队长 + $data[] = [ + 'nickname' => '零售队长', + 'store_id' => $order['store_id'], + 'product_id' => $find['product_id'], + 'other_uid' => 0, + 'price' => $price, + 'total_price' => $purchase_price, + 'cart_num' => $find['cart_num'], + 'rate' => 0.02, + 'number' => $brigade_number, + 'oid' => $order['id'], + 'type' => 4, + 'status' => 1, + 'is_activity' => 1, + ]; + //村长 + $data[] = [ + 'nickname' => '零售村长', + 'store_id' => $order['store_id'], + 'product_id' => $find['product_id'], + 'other_uid' => 0, + 'price' => $price, + 'total_price' => $brigade_number, + 'cart_num' => 0, + 'rate' => 0.01, + 'number' => $village_number, + 'oid' => $order['id'], + 'type' => 3, + 'status' => 1, + 'is_activity' => 1, + ]; + //门店 + $data[] = [ + 'nickname' => '零售门店', + 'store_id' => $order['store_id'], + 'product_id' => $find['product_id'], + 'other_uid' => 0, + 'price' => $price, + 'total_price' => $total_price, + 'cart_num' => $find['cart_num'], + 'rate' => 0, + 'number' => $store_number, + 'oid' => $order['id'], + 'type' => 1, + 'status' => 1, + 'is_activity' => 1, + ]; + //平台 + $data[] = [ + 'nickname' => '零售平台', + 'store_id' => $order['store_id'], + 'product_id' => $find['product_id'], + 'other_uid' => 0, + 'price' => $price, + 'total_price' => $purchase_price, + 'cart_num' => $find['cart_num'], + 'rate' => 0.02, + 'number' => $platform_number, + 'oid' => $order['id'], + 'type' => 2, + 'status' => 1, + 'is_activity' => 1, + ]; + + $data[] = [ + 'nickname' => '零售消耗', + 'store_id' => $order['store_id'], + 'product_id' => $find['product_id'], + 'other_uid' => 0, + 'price' => $price, + 'total_price' => $purchase_price, + 'cart_num' => $find['cart_num'], + 'rate' => 0.01, + 'number' => $attrition_number, + 'oid' => $order['id'], + 'type' => 6, + 'status' => 1, + ]; + + + (new StoreFinanceFlowProduct())->saveAll($data); + } + + /** + * 商户价结算 + */ + public function b($find, $order, $product, $user_ship) + { + $total_price = bcmul($product['price'], $find['cart_num']); + $purchase_price = bcmul($product['purchase'], $find['cart_num']); + $price = $product['purchase']; + + $brigade_number = bcmul($purchase_price, 0.02, 2); //队长 + $village_number = bcmul($brigade_number, 0.1, 2); //村长 + $platform_number = bcmul($purchase_price, 0.02, 2); //平台 + $attrition_number = bcmul($purchase_price, 0.01, 2); //损耗 + + $number1 = bcadd($brigade_number, $village_number, 2); + $number2 = bcadd($number1, $platform_number, 2); + + //零售-供货价 + $number3 = bcsub($total_price, $purchase_price, 2); + + $number4 = bcadd($attrition_number, $number2, 2); + + //门店利润 + if ($number3 <= 0) { + $store_number = 0; + } else { + $store_number = bcsub($number3, $number4, 2); } //队长 @@ -222,7 +233,7 @@ class CommissionProductLogic extends BaseLogic 'product_id' => $find['product_id'], 'other_uid' => 0, 'price' => $price, - 'total_price' => $total_price, + 'total_price' => $purchase_price, 'cart_num' => $find['cart_num'], 'rate' => 0.02, 'number' => $brigade_number, @@ -254,7 +265,7 @@ class CommissionProductLogic extends BaseLogic 'product_id' => $find['product_id'], 'other_uid' => 0, 'price' => $price, - 'total_price' => $store_number, + 'total_price' => $total_price, 'cart_num' => $find['cart_num'], 'rate' => 0, 'number' => $store_number, @@ -270,7 +281,7 @@ class CommissionProductLogic extends BaseLogic 'product_id' => $find['product_id'], 'other_uid' => 0, 'price' => $price, - 'total_price' => $platform_number, + 'total_price' => $purchase_price, 'cart_num' => $find['cart_num'], 'rate' => 0.02, 'number' => $platform_number, @@ -281,15 +292,15 @@ class CommissionProductLogic extends BaseLogic ]; $data[] = [ - 'nickname' => '消耗', + 'nickname' => '商户价消耗', 'store_id' => $order['store_id'], 'product_id' => $find['product_id'], 'other_uid' => 0, 'price' => $price, - 'total_price' => $total_price, + 'total_price' => $purchase_price, 'cart_num' => $find['cart_num'], 'rate' => 0.01, - 'number' => bcmul($total_price, 0.01, 2), + 'number' => $attrition_number, 'oid' => $order['id'], 'type' => 6, 'status' => 1, @@ -303,10 +314,10 @@ class CommissionProductLogic extends BaseLogic // $rose = bcdiv($product['rose'], 100, 2); $total_price = bcmul($product['price'], $find['cart_num']); $purchase_price = bcmul($product['purchase'], $find['cart_num']); - $price=$product['price']; - $brigade_number = bcmul($total_price, 0.02, 2);//队长 - $village_number = bcmul($brigade_number, 0.1, 2);//村长 - $platform_number = bcmul($total_price, 0.02, 2);//平台 + $price = $product['price']; + $brigade_number = bcmul($total_price, 0.02, 2); //队长 + $village_number = bcmul($brigade_number, 0.1, 2); //村长 + $platform_number = bcmul($total_price, 0.02, 2); //平台 $number1 = bcadd($brigade_number, $village_number, 2); $number2 = bcadd($number1, $platform_number, 2); @@ -315,11 +326,10 @@ class CommissionProductLogic extends BaseLogic $number3 = bcsub($total_price, $purchase_price, 2); //门店利润 - if($number3<=0){ + if ($number3 <= 0) { $store_number = 0; - }else{ + } else { $store_number = bcsub($number3, $number2, 2); - } //队长 diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index 6ce86964f..f90a6dbd1 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -352,6 +352,7 @@ class PayNotifyLogic extends BaseLogic if ($type == 1) { $capitalFlowDao->userIncome('now_money_refund', 'system_back', $order['id'], $order['pay_price'], '', 0); $user->now_money = bcadd($user['now_money'], $order['pay_price'], 2); + StoreOrder::where('id', $order['id'])->update(['refund_status' => 2]); } else { $capitalFlowDao->userIncome('now_money_refund', 'system_back', $order['id'], $money, '', 0); $user->now_money = bcadd($user['now_money'], $money, 2); @@ -366,6 +367,7 @@ class PayNotifyLogic extends BaseLogic if ($type == 1) { $capitalFlowDao->userIncome('purchase_refund', 'system_back', $order['id'], $order['pay_price'], '', 1); $user->purchase_funds = bcadd($user['purchase_funds'], $order['pay_price'], 2); + StoreOrder::where('id', $order['id'])->update(['refund_status' => 2]); } else { $capitalFlowDao->userIncome('purchase_refund', 'system_back', $order['id'], $money, '', 1); $user->purchase_funds = bcadd($user['purchase_funds'], $money, 2); From b65ab15e2af5374e589e2796cebab06e7b84f673 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Mon, 9 Sep 2024 17:57:03 +0800 Subject: [PATCH 3/4] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9=E4=BA=86?= =?UTF-8?q?=E5=95=86=E5=93=81=E5=88=97=E8=A1=A8=E6=90=9C=E7=B4=A2=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lists/store_product/StoreProductLists.php | 60 ++++++++++--------- 1 file changed, 31 insertions(+), 29 deletions(-) diff --git a/app/admin/lists/store_product/StoreProductLists.php b/app/admin/lists/store_product/StoreProductLists.php index 59476522e..f2902ad5a 100644 --- a/app/admin/lists/store_product/StoreProductLists.php +++ b/app/admin/lists/store_product/StoreProductLists.php @@ -62,25 +62,25 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa } } return StoreProduct::where($this->searchWhere) - ->field(['id', 'image', 'store_info','store_name', 'top_cate_id','two_cate_id','swap', 'product_type', 'cate_id', 'batch', 'price', 'vip_price', 'sales', 'stock', 'is_show', 'unit', 'cost', 'rose', 'purchase', 'bar_code', 'manufacturer_information']) + ->field(['id', 'image', 'store_info', 'store_name', 'top_cate_id', 'two_cate_id', 'swap', 'product_type', 'cate_id', 'batch', 'price', 'vip_price', 'sales', 'stock', 'is_show', 'unit', 'cost', 'rose', 'purchase', 'bar_code', 'manufacturer_information']) ->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) ->select()->each(function ($item) { - $item['bar_code_two']=''; - if(in_array($item['unit'],[2,21])){ - $item['bar_code_two']=$item['bar_code']; - if($item['bar_code']==0){ - $item['bar_code_two']=''; + $item['bar_code_two'] = ''; + if (in_array($item['unit'], [2, 21])) { + $item['bar_code_two'] = $item['bar_code']; + if ($item['bar_code'] == 0) { + $item['bar_code_two'] = ''; } - $item['bar_code']=''; + $item['bar_code'] = ''; $item['unit_names'] = '称重商品'; - }else{ - if(strlen($item['bar_code'])<10){ - $item['bar_code_two']=$item['bar_code']; - if($item['bar_code']==0){ - $item['bar_code_two']=''; + } else { + if (strlen($item['bar_code']) < 10) { + $item['bar_code_two'] = $item['bar_code']; + if ($item['bar_code'] == 0) { + $item['bar_code_two'] = ''; } - $item['bar_code']=''; + $item['bar_code'] = ''; } $item['unit_names'] = '标准商品'; } @@ -90,18 +90,20 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa $nums = WarehouseProductStorege::where('product_id', $item['id'])->sum('nums'); $stock = StoreBranchProduct::where('store_id', '<>', '4')->where('product_id', $item['id'])->sum('stock'); $item['stock'] = bcadd($nums, $stock); - $cate_name=''; - $category_top=StoreCategory::where('id', $item['top_cate_id'])->value('name'); - if($category_top!=''){ - $cate_name='/'.$category_top; + $cate_name = ''; + $category_top = StoreCategory::where('id', $item['top_cate_id'])->value('name'); + if ($category_top != '') { + $cate_name = '/' . $category_top; } - // $category_two=StoreCategory::where('id', $item['two_cate_id'])->value('name'); - // if($category_two!=''){ - // $cate_name=$cate_name.'/'.$category_two; - // } - $category_three=StoreCategory::where('id', $item['cate_id'])->value('name'); - if($category_three){ - $cate_name=$cate_name.'/'.$category_three; + if (!$category_top) { + $category_two = StoreCategory::where('id', $item['two_cate_id'])->value('name'); + if ($category_two != '') { + $cate_name = $cate_name . '/' . $category_two; + } + } + $category_three = StoreCategory::where('id', $item['cate_id'])->value('name'); + if ($category_three) { + $cate_name = $cate_name . '/' . $category_three; } $item['cate_name'] = $cate_name; // $item['cate_name'] = StoreCategory::where('id', $item['cate_id'])->value('name'); @@ -118,8 +120,8 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa */ public function count(): int { - $export=$this->request->get('export'); - if($export==1){ + $export = $this->request->get('export'); + if ($export == 1) { $class_all = $this->request->get('class_all'); if ($class_all) { //查3级别的 @@ -159,9 +161,9 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa 'id' => '商品id', 'unit_names' => '计价方式', 'store_name' => '商品名称', - 'cate_name'=>'分类', - 'unit_name'=>'单位', - 'store_info'=>'规格', + 'cate_name' => '分类', + 'unit_name' => '单位', + 'store_info' => '规格', 'stock' => '库存', 'purchase' => '采购价', 'cost' => '商户', From be8881b1ad92e263813b9f876357ed1951563f61 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Mon, 9 Sep 2024 17:57:33 +0800 Subject: [PATCH 4/4] =?UTF-8?q?feat(StoreProductLists):=20=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E4=BA=86=E5=95=86=E5=93=81=E5=88=97=E8=A1=A8=E7=9A=84?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/lists/store_product/StoreProductLists.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/admin/lists/store_product/StoreProductLists.php b/app/admin/lists/store_product/StoreProductLists.php index f2902ad5a..85b0210f1 100644 --- a/app/admin/lists/store_product/StoreProductLists.php +++ b/app/admin/lists/store_product/StoreProductLists.php @@ -85,7 +85,6 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa $item['unit_names'] = '标准商品'; } - $item['supplier_name'] = '自购'; $item['unit_name'] = StoreProductUnit::where('id', $item['unit'])->value('name'); $nums = WarehouseProductStorege::where('product_id', $item['id'])->sum('nums'); $stock = StoreBranchProduct::where('store_id', '<>', '4')->where('product_id', $item['id'])->sum('stock'); @@ -170,7 +169,6 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa 'price' => '零售', 'bar_code' => '条码', 'bar_code_two' => '自编码', - 'supplier_name' => '供应商', ]; return $data; }