From 41bdd754c77c17106a7909faa8004eb7ce4425c0 Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Fri, 28 Jun 2024 09:59:05 +0800 Subject: [PATCH 01/33] =?UTF-8?q?=E6=B3=A8=E9=87=8A=E8=B0=83=E8=AF=95?= =?UTF-8?q?=E4=BC=9A=E5=91=98baobei=E7=9F=AD=E4=BF=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/store/StoreController.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/app/api/controller/store/StoreController.php b/app/api/controller/store/StoreController.php index 21b5b5b5c..698fe944c 100644 --- a/app/api/controller/store/StoreController.php +++ b/app/api/controller/store/StoreController.php @@ -67,16 +67,16 @@ class StoreController extends BaseApiController $recharge_type = $this->request->post('recharge_type',''); //微信支付条码 $code = $this->request->post('code','');//验证码 $phone = $params['mobile']; - if($code && $phone){ - $remark = $phone.'_reporting'; - $codeCache = Cache::get($remark); - if(empty($codeCache)){ - return $this->fail('验证码不存在'); - } - if ($codeCache != $code) { - return $this->fail('验证码错误'); - } - } +// if($code && $phone){ +// $remark = $phone.'_reporting'; +// $codeCache = Cache::get($remark); +// if(empty($codeCache)){ +// return $this->fail('验证码不存在'); +// } +// if ($codeCache != $code) { +// return $this->fail('验证码错误'); +// } +// } if($params['price']>10000){ return $this->fail('充值金额不能大于10000'); } From 266e93f527a19f226fabe2bf916a634078530b4e Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Fri, 28 Jun 2024 10:20:49 +0800 Subject: [PATCH 02/33] =?UTF-8?q?feat(IndexController):=20=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E4=BA=86Push=E6=9C=8D=E5=8A=A1API=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/IndexController.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/api/controller/IndexController.php b/app/api/controller/IndexController.php index 060283c38..986de0b54 100644 --- a/app/api/controller/IndexController.php +++ b/app/api/controller/IndexController.php @@ -28,7 +28,7 @@ use Webman\RedisQueue\Redis; class IndexController extends BaseApiController { - public $notNeedLogin = ['index', 'app_update', 'express_list', 'province', 'city', 'area', 'street', 'village', 'brigade', 'config']; + public $notNeedLogin = ['index', 'app_update', 'express_list', 'province', 'city', 'area', 'street', 'village', 'brigade', 'config','push']; public function index() { @@ -176,4 +176,13 @@ return json($a); ]; return $this->success('ok', $list); } + + public function push() + { + $name=$this->request->get('name');//用户名 + $uid=$this->request->get('uid');//用户id + $type=$this->request->get('type','INDUSTRYMEMBERS');//类型 + $a= PushService::push($name, $uid, ['type'=>$type,'msg'=>'支付超时,订单已被取消,请重新提交订单','data'=>['id'=>5]]); + return $this->success('ok',['data'=> $a]); + } } From b5e8e527fe74a0aef2bac926323ae93e5c442066 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Fri, 28 Jun 2024 10:22:46 +0800 Subject: [PATCH 03/33] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E5=95=86=E5=93=81=E5=AD=98=E5=82=A8=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/logic/PayNotifyLogic.php | 44 +++---------------- .../UserProductStorageLogic.php | 3 ++ 2 files changed, 8 insertions(+), 39 deletions(-) diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index 5876e8a8f..0c671df28 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -98,6 +98,7 @@ class PayNotifyLogic extends BaseLogic // self::descStock($order['id']); // } self::afterPay($order); + UserProductStorageLogic::add($order); if ($extra && $extra['store_id']) { $params = [ 'verify_code' => $order['verify_code'], @@ -197,6 +198,7 @@ class PayNotifyLogic extends BaseLogic // } // self::addUserSing($order); self::afterPay($order); + UserProductStorageLogic::add($order); if ($extra && $extra['store_id']) { $params = [ 'verify_code' => $order['verify_code'], @@ -399,6 +401,7 @@ class PayNotifyLogic extends BaseLogic } $order->save(); self::afterPay($order, $extra['transaction_id']); + UserProductStorageLogic::add($order); // self::addUserSing($order); self::dealProductLog($order); if ($order['shipping_type'] == 3) { @@ -694,6 +697,7 @@ class PayNotifyLogic extends BaseLogic throw new \Exception('订单保存出错'); } self::afterPay($order); + UserProductStorageLogic::add($order); $cashFlowLogic = new CashFlowLogic(); $cashFlowLogic->insert($order['store_id'], $order['pay_price']); self::dealProductLog($order); @@ -730,6 +734,7 @@ class PayNotifyLogic extends BaseLogic if ($order->pay_type == 9) { $order->status = 2; self::afterPay($order); + UserProductStorageLogic::add($order); } self::dealProductLog($order); if ($order['shipping_type'] == 3) { @@ -898,45 +903,6 @@ class PayNotifyLogic extends BaseLogic } } if ($fees > 0) { - //村长获得 - // $sing = []; - - // $sing[] = [ - // 'uid' => $village_uid, - // 'order_id' => $order['order_id'], - // 'title' => '村长订单获得兑换券', - // 'store_id' => $order['store_id'], - // 'number' => $fees, - // 'financial_pm' => 1, - // 'user_ship' => 2, - // ]; - // $sing[] = [ - // 'uid' => $brigade_uid, - // 'order_id' => $order['order_id'], - // 'title' => '队长订单获得兑换券', - // 'store_id' => $order['store_id'], - // 'number' => $fees, - // 'financial_pm' => 1, - // 'user_ship' => 3, - // ]; - // $sing[] = [ - // 'uid' => $village_uid, - // 'order_id' => $order['order_id'], - // 'title' => '订单扣除兑换券', - // 'store_id' => $order['store_id'], - // 'number' => $fees, - // 'financial_pm' => 0, - // 'user_ship' => 2, - // ]; - // $sing[] = [ - // 'uid' => $brigade_uid, - // 'order_id' => $order['order_id'], - // 'title' => '订单扣除兑换券', - // 'store_id' => $order['store_id'], - // 'number' => $fees, - // 'financial_pm' => 0, - // 'user_ship' => 3, - // ]; if ($village_uid > 0) { // SystemStore::where('id', $village_uid)->inc('store_money', $fees)->update(); $financeLogic->other_arr['vip_uid'] = $village_uid; diff --git a/app/common/logic/user_product_storage/UserProductStorageLogic.php b/app/common/logic/user_product_storage/UserProductStorageLogic.php index 5fc6199b9..a0e8d99db 100644 --- a/app/common/logic/user_product_storage/UserProductStorageLogic.php +++ b/app/common/logic/user_product_storage/UserProductStorageLogic.php @@ -7,6 +7,9 @@ use app\common\model\store_order_cart_info\StoreOrderCartInfo; use app\common\model\user_product_storage\UserProductStorage; use app\common\model\user_product_storage_log\UserProductStorageLog; +/** + * 用户商品储存逻辑 + */ class UserProductStorageLogic extends BaseLogic { public static function add($order){ From 95cd3876fd9636c83008d9dda2ceb6ac57580351 Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Fri, 28 Jun 2024 11:29:18 +0800 Subject: [PATCH 04/33] =?UTF-8?q?=E9=87=87=E8=B4=AD=E6=AC=BE=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E8=AE=B0=E5=BD=95=E5=8F=98=E5=8C=96=E5=89=8D=E5=90=8E?= =?UTF-8?q?=E7=9A=84=E9=87=91=E9=A2=9D=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/logic/CapitalFlowLogic.php | 8 ++++---- app/common/logic/PayNotifyLogic.php | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/common/logic/CapitalFlowLogic.php b/app/common/logic/CapitalFlowLogic.php index 79be1a48f..361ee124c 100644 --- a/app/common/logic/CapitalFlowLogic.php +++ b/app/common/logic/CapitalFlowLogic.php @@ -39,8 +39,8 @@ class CapitalFlowLogic extends BaseLogic $model->link_id = $linkId; $model->amount = $amount; if($type){ - $model->before_balance = $this->user['now_money']; - $model->balance = $this->user['now_money']; + $model->before_balance = $this->user['purchase_funds']; + $model->balance = bcsub($this->user['purchase_funds'], $amount, 2); }else{ $model->before_balance = $this->user['now_money']; $model->balance = bcadd($this->user['now_money'], $amount, 2); @@ -73,8 +73,8 @@ class CapitalFlowLogic extends BaseLogic $model->link_id = $linkId; $model->amount = $amount; if($payType == OrderEnum::BALANCE_PAYMEN_NO){ - $model->before_balance = $this->user['now_money']; - $model->balance = $this->user['now_money']; + $model->before_balance = $this->user['purchase_funds']; + $model->balance = bcsub($this->user['purchase_funds'], $amount, 2); }else{ $model->before_balance = $this->user['now_money']; $model->balance = bcsub($this->user['now_money'], $amount, 2); diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index 2d4ad7b0e..ec4df291c 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -650,7 +650,7 @@ class PayNotifyLogic extends BaseLogic $user = User::where('id', $uid)->findOrEmpty(); //用户的财务add $capitalFlowDao = new CapitalFlowLogic($user); - $capitalFlowDao->userIncome('user_balance_recharge', 'user_recharge', $order['id'], $price); + $capitalFlowDao->userIncome('user_balance_recharge', 'user_recharge', $order['id'], $price,[],1); if ($user->isEmpty()) { return true; From 68d55fa04e88dc96fc680542b48cbe0415143341 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Fri, 28 Jun 2024 11:44:44 +0800 Subject: [PATCH 05/33] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9=E4=BA=86=20Sto?= =?UTF-8?q?reRefundOrderLists=20=E5=92=8C=20UserRechargeLists=20=E7=B1=BB?= =?UTF-8?q?=E4=BB=A5=E8=8E=B7=E5=8F=96=E7=94=A8=E6=88=B7=E7=9C=9F=E5=AE=9E?= =?UTF-8?q?=E5=A7=93=E5=90=8D=E5=92=8C=E6=98=B5=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../UserProductStorageController.php | 30 +++++++ .../UserProductStorageLogController.php | 32 ++++++++ .../store_order/StoreRefundOrderLists.php | 12 ++- .../UserProductStorageLists.php | 72 +++++++++++++++++ .../UserProductStorageLogLists.php | 78 +++++++++++++++++++ .../lists/user_recharge/UserRechargeLists.php | 6 +- 6 files changed, 228 insertions(+), 2 deletions(-) create mode 100644 app/admin/controller/user_product_storage/UserProductStorageController.php create mode 100644 app/admin/controller/user_product_storage_log/UserProductStorageLogController.php create mode 100644 app/admin/lists/user_product_storage/UserProductStorageLists.php create mode 100644 app/admin/lists/user_product_storage_log/UserProductStorageLogLists.php diff --git a/app/admin/controller/user_product_storage/UserProductStorageController.php b/app/admin/controller/user_product_storage/UserProductStorageController.php new file mode 100644 index 000000000..3b428e3bd --- /dev/null +++ b/app/admin/controller/user_product_storage/UserProductStorageController.php @@ -0,0 +1,30 @@ +dataLists(new UserProductStorageLists()); + } + +} \ No newline at end of file diff --git a/app/admin/controller/user_product_storage_log/UserProductStorageLogController.php b/app/admin/controller/user_product_storage_log/UserProductStorageLogController.php new file mode 100644 index 000000000..45365f762 --- /dev/null +++ b/app/admin/controller/user_product_storage_log/UserProductStorageLogController.php @@ -0,0 +1,32 @@ +dataLists(new UserProductStorageLogLists()); + } + +} \ No newline at end of file diff --git a/app/admin/lists/store_order/StoreRefundOrderLists.php b/app/admin/lists/store_order/StoreRefundOrderLists.php index efa8f82d9..8aff1b11d 100644 --- a/app/admin/lists/store_order/StoreRefundOrderLists.php +++ b/app/admin/lists/store_order/StoreRefundOrderLists.php @@ -6,6 +6,7 @@ use app\admin\lists\BaseAdminDataLists; use app\common\enum\OrderEnum; use app\common\lists\ListsSearchInterface; use app\common\model\store_order\StoreOrder; +use app\common\model\user\User; class StoreRefundOrderLists extends BaseAdminDataLists implements ListsSearchInterface { @@ -38,7 +39,7 @@ class StoreRefundOrderLists extends BaseAdminDataLists implements ListsSearchInt public function lists(): array { $this->searchWhere[] = ['refund_status','>', 0]; - return StoreOrder::with(['user', 'staff', 'product' => function ($query) { + return StoreOrder::with(['staff', 'product' => function ($query) { $query->field(['id', 'oid', 'product_id', 'cart_info']); }]) ->where($this->searchWhere) @@ -46,6 +47,15 @@ class StoreRefundOrderLists extends BaseAdminDataLists implements ListsSearchInt ->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) ->select()->each(function ($item) { + if ($item['uid'] <= 0) { + $item['nickname'] = '游客'; + } else { + $id = $item['uid']; + $user=User::where('id', $item['uid'])->field('real_name,nickname')->find(); + if($user){ + $item['nickname'] =$user['real_name']!=''?$user['real_name'].'|'.$id:$user['nickname'].'|'.$id; + } + } $item['pay_time'] = $item['pay_time'] > 0 ? date('Y-m-d H:i:s', $item['pay_time']) : ''; $item['refund_status_name'] = OrderEnum::refundStatus($item['refund_status']) ?? ''; $item['refund_type_name'] = OrderEnum::refundType($item['refund_type']) ?? ''; diff --git a/app/admin/lists/user_product_storage/UserProductStorageLists.php b/app/admin/lists/user_product_storage/UserProductStorageLists.php new file mode 100644 index 000000000..fdac3935e --- /dev/null +++ b/app/admin/lists/user_product_storage/UserProductStorageLists.php @@ -0,0 +1,72 @@ + ['uid', 'oid', 'product_id'], + 'between_time' => ['create_time'], + ]; + } + + + /** + * @notes 获取用户商品储存列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author admin + * @date 2024/06/28 11:05 + */ + public function lists(): array + { + return UserProductStorage::where($this->searchWhere) + ->field(['id', 'uid', 'oid', 'product_id', 'nums', 'status','create_time']) + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select()->each(function($item){ + $user=User::where('id',$item['uid'])->field('nickname,real_name')->find(); + $item['nickname']=$user['real_name']?$user['real_name'].'|'.$item['uid']:$user['nickname'].'|'.$item['uid']; + $item['store_name']=StoreProduct::where('id',$item['product_id'])->value('store_name'); + return $item; + }) + ->toArray(); + } + + + /** + * @notes 获取用户商品储存数量 + * @return int + * @author admin + * @date 2024/06/28 11:05 + */ + public function count(): int + { + return UserProductStorage::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/admin/lists/user_product_storage_log/UserProductStorageLogLists.php b/app/admin/lists/user_product_storage_log/UserProductStorageLogLists.php new file mode 100644 index 000000000..25b9c9d08 --- /dev/null +++ b/app/admin/lists/user_product_storage_log/UserProductStorageLogLists.php @@ -0,0 +1,78 @@ + ['create_time'], + ]; + } + + + /** + * @notes 获取用户商品储存操作日志列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author admin + * @date 2024/06/28 11:15 + */ + public function lists(): array + { + return UserProductStorageLog::where($this->searchWhere) + ->field(['id', 'oid', 'uid', 'product_id', 'store_id', 'financial_pm', 'nums']) + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select()->each(function($item){ + $user=User::where('id',$item['uid'])->field('nickname,real_name')->find(); + $item['system_store_name']=SystemStore::where('id',$item['store_id'])->value('name'); + $item['nickname']=$user['real_name']?$user['real_name'].'|'.$item['uid']:$user['nickname'].'|'.$item['uid']; + $item['store_name']=StoreProduct::where('id',$item['product_id'])->value('store_name'); + if($item['financial_pm']==1){ + $item['financial_pm']='增加'; + }else{ + $item['financial_pm']='减少'; + } + return $item; + }) + ->toArray(); + } + + + /** + * @notes 获取用户商品储存操作日志数量 + * @return int + * @author admin + * @date 2024/06/28 11:15 + */ + public function count(): int + { + return UserProductStorageLog::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/admin/lists/user_recharge/UserRechargeLists.php b/app/admin/lists/user_recharge/UserRechargeLists.php index a6f1f432e..096a193f4 100644 --- a/app/admin/lists/user_recharge/UserRechargeLists.php +++ b/app/admin/lists/user_recharge/UserRechargeLists.php @@ -48,7 +48,11 @@ class UserRechargeLists extends BaseAdminDataLists implements ListsSearchInterfa ->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) ->select()->each(function ($item) { - $item['nickname']=User::where('id',$item['uid'])->value('nickname'); + $id = $item['uid']; + $user=User::where('id', $item['uid'])->field('real_name,nickname')->find(); + if($user){ + $item['nickname'] =$user['real_name']!=''?$user['real_name'].'|'.$id:$user['nickname'].'|'.$id; + } if($item['pay_time']>0){ $item['pay_time']=date('Y-m-d H:i:s',$item['pay_time']); }else{ From 0138c13069300b9301db248a153ca049646dd7e5 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Fri, 28 Jun 2024 11:55:04 +0800 Subject: [PATCH 06/33] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E7=B3=BB?= =?UTF-8?q?=E7=BB=9F=E5=BA=97=E9=93=BA=E5=90=8D=E7=A7=B0=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lists/user_product_storage/UserProductStorageLists.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/admin/lists/user_product_storage/UserProductStorageLists.php b/app/admin/lists/user_product_storage/UserProductStorageLists.php index fdac3935e..e95554246 100644 --- a/app/admin/lists/user_product_storage/UserProductStorageLists.php +++ b/app/admin/lists/user_product_storage/UserProductStorageLists.php @@ -7,6 +7,7 @@ use app\admin\lists\BaseAdminDataLists; use app\common\model\user_product_storage\UserProductStorage; use app\common\lists\ListsSearchInterface; use app\common\model\store_product\StoreProduct; +use app\common\model\system_store\SystemStore; use app\common\model\user\User; /** @@ -52,6 +53,12 @@ class UserProductStorageLists extends BaseAdminDataLists implements ListsSearchI $user=User::where('id',$item['uid'])->field('nickname,real_name')->find(); $item['nickname']=$user['real_name']?$user['real_name'].'|'.$item['uid']:$user['nickname'].'|'.$item['uid']; $item['store_name']=StoreProduct::where('id',$item['product_id'])->value('store_name'); + $item['system_store_name']=SystemStore::where('id',$item['store_id'])->value('name'); + if($item['status']==1){ + $item['status_name']='正常'; + }else{ + $item['status_name']='已出库完'; + } return $item; }) ->toArray(); From c24b0f7900dda3a85b87bf655c66425a701d61a8 Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Fri, 28 Jun 2024 13:55:09 +0800 Subject: [PATCH 07/33] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BD=99=E9=A2=9D?= =?UTF-8?q?=E6=94=AF=E4=BB=98=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/logic/PayNotifyLogic.php | 9 ++++++++- .../user_product_storage/UserProductStorageLogic.php | 7 ++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index ec4df291c..83af6e9f7 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -66,11 +66,12 @@ class PayNotifyLogic extends BaseLogic public static function balancePay($orderSn, $extra = []) { $order = StoreOrder::where('order_id', $orderSn)->findOrEmpty(); + $user = User::where('id', $order['uid'])->find(); if ($user['now_money'] < $order['pay_price']) { throw new \Exception('余额不足'); } - $order->money = $order['pay_price']; +// $order->money = $order['pay_price']; $order->paid = 1; $order->pay_time = time(); if (!$order->save()) { @@ -107,6 +108,7 @@ class PayNotifyLogic extends BaseLogic ]; OrderLogic::writeOff($params); } + return true; // Redis::send('push-platform-print', ['id' => $order['id']], 60); // PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type' => 'store_merchant', 'msg' => '您有一笔新的订单']); } @@ -494,6 +496,11 @@ class PayNotifyLogic extends BaseLogic 'number' => $user_number, ]; $user_sing->save($sing); + //删除之前获得的兑换券 + UserSign::where([ + 'order_id'=>$order['order_id'], + 'financial_pm'=>1, + ])->update(['delete_time'=>time()]); $now_int = User::where('id',$order['uid'])->find(); if($now_int){ if($now_int['integral'] > $user_number){ diff --git a/app/common/logic/user_product_storage/UserProductStorageLogic.php b/app/common/logic/user_product_storage/UserProductStorageLogic.php index a0e8d99db..6e7ffd20a 100644 --- a/app/common/logic/user_product_storage/UserProductStorageLogic.php +++ b/app/common/logic/user_product_storage/UserProductStorageLogic.php @@ -6,6 +6,7 @@ use app\common\logic\BaseLogic; use app\common\model\store_order_cart_info\StoreOrderCartInfo; use app\common\model\user_product_storage\UserProductStorage; use app\common\model\user_product_storage_log\UserProductStorageLog; +use think\Exception; /** * 用户商品储存逻辑 @@ -13,7 +14,7 @@ use app\common\model\user_product_storage_log\UserProductStorageLog; class UserProductStorageLogic extends BaseLogic { public static function add($order){ - $arr=StoreOrderCartInfo::where('oid',$order['id'])->field('product_id,cart_num nums')->select(); + $arr=StoreOrderCartInfo::where('oid',$order['id'])->field('product_id,cart_num nums')->select()->toArray(); if($arr){ $data=$arr; $data_log=$arr; @@ -26,8 +27,8 @@ class UserProductStorageLogic extends BaseLogic $data_log[$k]['oid']=$order['id']; $data_log[$k]['financial_pm']=1; } - UserProductStorage::insertAll($data); - UserProductStorageLog::insertAll($data_log); + (new UserProductStorage())->saveAll($data); + (new UserProductStorageLog())->saveAll($data_log); } } From ee1960550d1e20e38607ccd8f920f2ef889705f3 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Fri, 28 Jun 2024 14:26:39 +0800 Subject: [PATCH 08/33] 1 --- app/api/controller/user/UserController.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/app/api/controller/user/UserController.php b/app/api/controller/user/UserController.php index 64988235f..f46c638dd 100644 --- a/app/api/controller/user/UserController.php +++ b/app/api/controller/user/UserController.php @@ -9,6 +9,7 @@ use app\api\validate\UserValidate; use app\common\enum\PayEnum; use app\common\logic\PaymentLogic; use app\common\model\user\User; +use app\common\model\user\UserAddress; use app\common\model\user_sign\UserSign; use support\Cache; use think\Exception; @@ -244,6 +245,19 @@ class UserController extends BaseApiController } - + /** + * 用户信息 + */ + public function other_user_info(){ + $mobile=$this->request->get('mobile'); + if($mobile){ + $user=User::where('mobile',$mobile)->field('id,avatar,real_name,nickname,mobile,user_ship,purchase_funds')->find(); + if($user){ + $user['address_info']=UserAddress::where('uid',$user['id'])->where('is_default',1)->find(); + } + return $this->success('ok',$user); + } + return $this->success('ok',[]); + } } From 660762b0a4457209b2b25f405d33ad5c548c00fd Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Fri, 28 Jun 2024 14:27:48 +0800 Subject: [PATCH 09/33] 1 --- .../logic/user_product_storage/UserProductStorageLogic.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/common/logic/user_product_storage/UserProductStorageLogic.php b/app/common/logic/user_product_storage/UserProductStorageLogic.php index a0e8d99db..a961d1d8a 100644 --- a/app/common/logic/user_product_storage/UserProductStorageLogic.php +++ b/app/common/logic/user_product_storage/UserProductStorageLogic.php @@ -6,12 +6,16 @@ use app\common\logic\BaseLogic; use app\common\model\store_order_cart_info\StoreOrderCartInfo; use app\common\model\user_product_storage\UserProductStorage; use app\common\model\user_product_storage_log\UserProductStorageLog; +use think\facade\Db; /** * 用户商品储存逻辑 */ class UserProductStorageLogic extends BaseLogic { + /** + * 入库逻辑处理 + */ public static function add($order){ $arr=StoreOrderCartInfo::where('oid',$order['id'])->field('product_id,cart_num nums')->select(); if($arr){ From f33079064724416a2cbe1c1bfb515fb91291d089 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Fri, 28 Jun 2024 14:43:19 +0800 Subject: [PATCH 10/33] =?UTF-8?q?feat(UserController):=20=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E7=94=A8=E6=88=B7=E5=9C=B0=E5=9D=80=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/user/UserController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/api/controller/user/UserController.php b/app/api/controller/user/UserController.php index f46c638dd..2074f4f88 100644 --- a/app/api/controller/user/UserController.php +++ b/app/api/controller/user/UserController.php @@ -255,7 +255,7 @@ class UserController extends BaseApiController if($user){ $user['address_info']=UserAddress::where('uid',$user['id'])->where('is_default',1)->find(); } - return $this->success('ok',$user); + return $this->success('ok',$user?->toArray()); } return $this->success('ok',[]); } From 44c1bb40fd294e4e1a7fc18eb0228c047eb20aba Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Fri, 28 Jun 2024 14:43:40 +0800 Subject: [PATCH 11/33] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=85=85=E5=80=BC?= =?UTF-8?q?=E9=80=80=E6=AC=BE=E9=80=80=E7=A4=BC=E5=93=81=E5=88=B8=E7=9A=84?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/logic/PayNotifyLogic.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index 83af6e9f7..2b314a3d3 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -431,7 +431,7 @@ class PayNotifyLogic extends BaseLogic $orderRe->refund_time = time(); $orderRe->remarks = ''; $orderRe->save(); - + self::descUserSing($orderRe); return true; } $order->status = OrderEnum::REFUND_PAY; @@ -480,8 +480,9 @@ class PayNotifyLogic extends BaseLogic return true; // self::afterPay($order,$extra['transaction_id']); } + - //退积分 + //退积分-->订单 public static function descUserSing($order) { $user_sing = new UserSign(); @@ -501,12 +502,12 @@ class PayNotifyLogic extends BaseLogic 'order_id'=>$order['order_id'], 'financial_pm'=>1, ])->update(['delete_time'=>time()]); - $now_int = User::where('id',$order['uid'])->find(); + $now_int = User::where('id',$order['uid'])->withTrashed()->find(); if($now_int){ if($now_int['integral'] > $user_number){ - User::where('id',$order['uid'])->dec('integral',$user_number)->update(); + User::where('id',$order['uid'])->withTrashed()->dec('integral',$user_number)->update(); }else{ - User::where('id',$order['uid'])->dec('integral',$now_int['integral'])->update(); + User::where('id',$order['uid'])->withTrashed()->dec('integral',$now_int['integral'])->update(); } } From 30cbd5eafe1bf35cdbad7d483a669afe06ecae3a Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Fri, 28 Jun 2024 15:03:14 +0800 Subject: [PATCH 12/33] =?UTF-8?q?feat:=20=E6=9B=B4=E6=96=B0=E4=BA=86?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=95=86=E5=93=81=E5=AD=98=E5=82=A8=E9=80=BB?= =?UTF-8?q?=E8=BE=91=E5=92=8C=E6=94=AF=E4=BB=98=E9=80=9A=E7=9F=A5=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../UserProductStorageLists.php | 6 ++- app/api/controller/user/UserController.php | 2 +- app/common/logic/PayNotifyLogic.php | 7 ++- app/common/logic/StoreFinanceFlowLogic.php | 5 ++ .../UserProductStorageLogic.php | 34 +++++++++++++- .../UserProductStorageController.php | 46 +++++++++++++++++++ app/store/logic/WorkbenchLogic.php | 4 ++ 7 files changed, 96 insertions(+), 8 deletions(-) create mode 100644 app/store/controller/user_product_storage/UserProductStorageController.php diff --git a/app/admin/lists/user_product_storage/UserProductStorageLists.php b/app/admin/lists/user_product_storage/UserProductStorageLists.php index e95554246..8a8c7ffe9 100644 --- a/app/admin/lists/user_product_storage/UserProductStorageLists.php +++ b/app/admin/lists/user_product_storage/UserProductStorageLists.php @@ -52,8 +52,10 @@ class UserProductStorageLists extends BaseAdminDataLists implements ListsSearchI ->select()->each(function($item){ $user=User::where('id',$item['uid'])->field('nickname,real_name')->find(); $item['nickname']=$user['real_name']?$user['real_name'].'|'.$item['uid']:$user['nickname'].'|'.$item['uid']; - $item['store_name']=StoreProduct::where('id',$item['product_id'])->value('store_name'); - $item['system_store_name']=SystemStore::where('id',$item['store_id'])->value('name'); + $find=StoreProduct::where('id',$item['product_id'])->field('store_name,image,price')->find(); + $item['store_name']=$find['store_name']; + $item['image']=$find['image']; + $item['price']=$find['price']; if($item['status']==1){ $item['status_name']='正常'; }else{ diff --git a/app/api/controller/user/UserController.php b/app/api/controller/user/UserController.php index 2074f4f88..f476f8c34 100644 --- a/app/api/controller/user/UserController.php +++ b/app/api/controller/user/UserController.php @@ -251,7 +251,7 @@ class UserController extends BaseApiController public function other_user_info(){ $mobile=$this->request->get('mobile'); if($mobile){ - $user=User::where('mobile',$mobile)->field('id,avatar,real_name,nickname,mobile,user_ship,purchase_funds')->find(); + $user=User::where('mobile',$mobile)->field('id,avatar,real_name,nickname,mobile,user_ship,purchase_funds,label_id')->find(); if($user){ $user['address_info']=UserAddress::where('uid',$user['id'])->where('is_default',1)->find(); } diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index 83af6e9f7..1acae8c26 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -99,7 +99,6 @@ class PayNotifyLogic extends BaseLogic // self::descStock($order['id']); // } self::afterPay($order); - UserProductStorageLogic::add($order); if ($extra && $extra['store_id']) { $params = [ 'verify_code' => $order['verify_code'], @@ -200,7 +199,6 @@ class PayNotifyLogic extends BaseLogic // } // self::addUserSing($order); self::afterPay($order); - UserProductStorageLogic::add($order); if ($extra && $extra['store_id']) { $params = [ 'verify_code' => $order['verify_code'], @@ -403,7 +401,6 @@ class PayNotifyLogic extends BaseLogic } $order->save(); self::afterPay($order, $extra['transaction_id']); - UserProductStorageLogic::add($order); // self::addUserSing($order); self::dealProductLog($order); if ($order['shipping_type'] == 3) { @@ -705,7 +702,9 @@ class PayNotifyLogic extends BaseLogic throw new \Exception('订单保存出错'); } self::afterPay($order); - UserProductStorageLogic::add($order); + if($order['is_storage']==1){ + UserProductStorageLogic::add($order); + } $cashFlowLogic = new CashFlowLogic(); $cashFlowLogic->insert($order['store_id'], $order['pay_price']); self::dealProductLog($order); diff --git a/app/common/logic/StoreFinanceFlowLogic.php b/app/common/logic/StoreFinanceFlowLogic.php index f5bb794f9..534ce5091 100644 --- a/app/common/logic/StoreFinanceFlowLogic.php +++ b/app/common/logic/StoreFinanceFlowLogic.php @@ -150,6 +150,11 @@ class StoreFinanceFlowLogic extends BaseLogic if($deposit){ SystemStore::where('id', $store_id)->inc('paid_deposit', $deposit)->update(); } + $find=StoreFinanceFlow::where(['order_id'=>$order_id,'financial_pm'=>1,'financial_type'=>16])->find(); + if($find){ + $find->update(['status' => 1]); + SystemStore::where('id', $store_id)->inc('attrition', $find['number'])->update(); + } } } diff --git a/app/common/logic/user_product_storage/UserProductStorageLogic.php b/app/common/logic/user_product_storage/UserProductStorageLogic.php index 3d17314d4..4125c73c4 100644 --- a/app/common/logic/user_product_storage/UserProductStorageLogic.php +++ b/app/common/logic/user_product_storage/UserProductStorageLogic.php @@ -6,7 +6,7 @@ use app\common\logic\BaseLogic; use app\common\model\store_order_cart_info\StoreOrderCartInfo; use app\common\model\user_product_storage\UserProductStorage; use app\common\model\user_product_storage_log\UserProductStorageLog; -use think\Exception; +use think\facade\Db; /** * 用户商品储存逻辑 @@ -36,4 +36,36 @@ class UserProductStorageLogic extends BaseLogic } } + /** + * 出库 + */ + public static function supply($data,$uid,$store_id){ + Db::startTrans(); + try { + $data_log=[]; + foreach ($data as $k=>$v){ + $find=UserProductStorage::where('uid',$uid)->where('product_id',$v['product_id'])->find(); + if($find){ + if($find['nums']<$v['nums']){ + self::setError('库存不足'); + return false; + } + $find->nums=bcsub($find['nums'],$v['nums']); + $find->saver(); + $data_log[$k]['uid']=$uid; + $data_log[$k]['oid']=$find['oid']; + $data_log[$k]['product_id']=$find['product_id']; + $data_log[$k]['store_id']=$store_id; + $data_log[$k]['financial_pm']=0; + $data_log[$k]['nums']=$v['nums']; + } + } + (new UserProductStorageLog())->saveAll($data_log); + Db::commit(); + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } } \ No newline at end of file diff --git a/app/store/controller/user_product_storage/UserProductStorageController.php b/app/store/controller/user_product_storage/UserProductStorageController.php new file mode 100644 index 000000000..60b159433 --- /dev/null +++ b/app/store/controller/user_product_storage/UserProductStorageController.php @@ -0,0 +1,46 @@ +dataLists(new UserProductStorageLists()); + } + + /** + * 出库 + */ + public function supply(){ + + $params=$this->request->post(); + $info=$params['info']; + $uid=$params['uid']; + $store_id=$this->adminInfo['store_id']; + d($params); + UserProductStorageLogic::supply($info,$uid,$store_id); + if(UserProductStorageLogic::hasError()){ + return $this->fail(UserProductStorageLogic::getError()); + } + return $this->success('操作成功'); + } +} \ No newline at end of file diff --git a/app/store/logic/WorkbenchLogic.php b/app/store/logic/WorkbenchLogic.php index 748df2080..21929fbe5 100644 --- a/app/store/logic/WorkbenchLogic.php +++ b/app/store/logic/WorkbenchLogic.php @@ -58,12 +58,14 @@ class WorkbenchLogic extends BaseLogic $cashFinanceWhere = []; $storeFinanceWhere = ['financial_type'=>2,'financial_pm'=>1]; $storeFinanceWhereTwo = ['financial_type'=>11,'financial_pm'=>0]; + $attritionWhere=[]; if ($params['store_id'] != 0) { $where['store_id'] = $params['store_id']; $userRechargeWhere['store_id'] = $params['store_id']; $cashFinanceWhere = ['store_id' => $params['store_id']]; $storeFinanceWhere['store_id'] = $params['store_id']; $storeFinanceWhereTwo['store_id'] = $params['store_id']; + $attritionWhere['store_id'] = $params['store_id']; } $orderLogic = new StoreOrderLogic(); //订单总金额 @@ -89,6 +91,8 @@ class WorkbenchLogic extends BaseLogic // $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'); + /**门店损耗金 */ + $data['attrition_amount'] = SystemStore::where($attritionWhere)->sum('attrition'); //门店成交用户数 $data['user_number'] = StoreOrder::where($where) ->whereBetweenTime('pay_time', $startTime, $endTime) From 4f029d5967cb70d641f5acb072012d374f09d08b Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Fri, 28 Jun 2024 15:10:23 +0800 Subject: [PATCH 13/33] =?UTF-8?q?feat(UserController):=20=E6=A0=B9?= =?UTF-8?q?=E6=8D=AE=E7=94=A8=E6=88=B7ID=E8=8E=B7=E5=8F=96=E5=9C=B0?= =?UTF-8?q?=E5=9D=80=E4=BF=A1=E6=81=AF=E5=B9=B6=E6=B7=BB=E5=8A=A0=E5=9C=B0?= =?UTF-8?q?=E5=9D=80=E5=88=AB=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/user/UserController.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/app/api/controller/user/UserController.php b/app/api/controller/user/UserController.php index f476f8c34..a853b2220 100644 --- a/app/api/controller/user/UserController.php +++ b/app/api/controller/user/UserController.php @@ -13,7 +13,7 @@ use app\common\model\user\UserAddress; use app\common\model\user_sign\UserSign; use support\Cache; use think\Exception; - +use think\facade\Db; /** * 用户控制器 @@ -253,7 +253,16 @@ class UserController extends BaseApiController if($mobile){ $user=User::where('mobile',$mobile)->field('id,avatar,real_name,nickname,mobile,user_ship,purchase_funds,label_id')->find(); if($user){ - $user['address_info']=UserAddress::where('uid',$user['id'])->where('is_default',1)->find(); + $address=UserAddress::where('uid',$user['id'])->where('is_default',1)->find(); + if($address){ + $city_name=Db::name('geo_city')->where('city_code',$address['city'])->value('city_name'); + $area_name=Db::name('geo_area')->where('area_code',$address['area'])->value('area_name'); + $street_name=Db::name('geo_street')->where('street_code',$address['street'])->value('street_name'); + $village_name=Db::name('geo_village')->where('village_code',$address['village'])->value('village_name'); + $brigade_name=Db::name('geo_brigade')->where('id',$address['brigade'])->value('brigade_name'); + $address['address_like']=$city_name.$area_name.$street_name.$village_name.$brigade_name; + } + $user['address_info']=$address; } return $this->success('ok',$user?->toArray()); } From 004ad3cccade236416bbf0d9648c8571ed72133e Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Fri, 28 Jun 2024 15:23:20 +0800 Subject: [PATCH 14/33] =?UTF-8?q?feat:=20=E8=B0=83=E6=95=B4=E5=88=86?= =?UTF-8?q?=E7=B1=BB=E5=88=97=E8=A1=A8API=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/lists/cate/CateLists.php | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/app/api/lists/cate/CateLists.php b/app/api/lists/cate/CateLists.php index 7139e303d..688f56c77 100644 --- a/app/api/lists/cate/CateLists.php +++ b/app/api/lists/cate/CateLists.php @@ -48,20 +48,17 @@ class CateLists extends BaseAdminDataLists implements ListsSearchInterface $pid = $this->request->get('pid',0); $this->searchWhere[] = ['stock', '>', 0]; $this->searchWhere[] = ['status', '=', 1]; - if($pid == 0 && $level ==1){ - $cate_arr = StoreBranchProduct::where($this->searchWhere)->distinct() - ->column('top_cate_id'); - } if($pid && $level ==2){ $this->searchWhere[] = ['top_cate_id','=',$pid]; $cate_arr = StoreBranchProduct::where($this->searchWhere)->distinct() ->column('two_cate_id'); - } - - if($pid && $level ==3){ + }elseif($pid && $level ==3){ $this->searchWhere[] = ['two_cate_id','=',$pid]; $cate_arr = StoreBranchProduct::where($this->searchWhere)->distinct() ->column('cate_id'); + }else{ + $cate_arr = StoreBranchProduct::where($this->searchWhere)->distinct() + ->column('top_cate_id'); } $lists = []; if ($cate_arr) { From eb362ad5573b059134590ec508e4736b84b3c9b8 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Fri, 28 Jun 2024 15:26:59 +0800 Subject: [PATCH 15/33] 1 --- app/api/controller/user/UserController.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/api/controller/user/UserController.php b/app/api/controller/user/UserController.php index a853b2220..08c0bbbc2 100644 --- a/app/api/controller/user/UserController.php +++ b/app/api/controller/user/UserController.php @@ -263,8 +263,10 @@ class UserController extends BaseApiController $address['address_like']=$city_name.$area_name.$street_name.$village_name.$brigade_name; } $user['address_info']=$address; + return $this->success('ok',$user->toArray()); + }else{ + return $this->fail('用户不存在'); } - return $this->success('ok',$user?->toArray()); } return $this->success('ok',[]); } From 02cad626715b3b73904e8e04f41a5fb5adb0371b Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Fri, 28 Jun 2024 15:49:39 +0800 Subject: [PATCH 16/33] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E6=A0=B9?= =?UTF-8?q?=E6=8D=AE=E7=94=A8=E6=88=B7=E6=98=B5=E7=A7=B0=E6=88=96=E7=9C=9F?= =?UTF-8?q?=E5=AE=9E=E5=A7=93=E5=90=8D=E6=90=9C=E7=B4=A2=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E7=9A=84=E5=8A=9F=E8=83=BD=EF=BC=8C=E5=8F=AA=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E6=AD=A3=E5=B8=B8=E7=8A=B6=E6=80=81=E7=9A=84=E5=BA=93=E5=AD=98?= =?UTF-8?q?=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/lists/user/UserLists.php | 2 +- .../user_product_storage/UserProductStorageLists.php | 1 + .../user_product_storage/UserProductStorageLogic.php | 8 ++++++-- .../user_product_storage/UserProductStorageController.php | 1 - 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/admin/lists/user/UserLists.php b/app/admin/lists/user/UserLists.php index c80f7966f..2ce801a64 100644 --- a/app/admin/lists/user/UserLists.php +++ b/app/admin/lists/user/UserLists.php @@ -41,7 +41,7 @@ class UserLists extends BaseAdminDataLists implements ListsExcelInterface $params = $this->params; $where = []; if(isset($params['nickname']) && $params['nickname'] != ''){ - $where[] = ['nickname','like','%'.$params['nickname'].'%']; + $where[] = ['real_name|nickname','like','%'.$params['nickname'].'%']; } if(isset($params['account']) && $params['account'] != ''){ $where[] = ['account','like','%'.$params['account'].'%']; diff --git a/app/admin/lists/user_product_storage/UserProductStorageLists.php b/app/admin/lists/user_product_storage/UserProductStorageLists.php index 8a8c7ffe9..25b60b617 100644 --- a/app/admin/lists/user_product_storage/UserProductStorageLists.php +++ b/app/admin/lists/user_product_storage/UserProductStorageLists.php @@ -45,6 +45,7 @@ class UserProductStorageLists extends BaseAdminDataLists implements ListsSearchI */ public function lists(): array { + $this->searchWhere[]=['status','=',1];//只显示正常状态的记录,不显示已出库完的记录 return UserProductStorage::where($this->searchWhere) ->field(['id', 'uid', 'oid', 'product_id', 'nums', 'status','create_time']) ->limit($this->limitOffset, $this->limitLength) diff --git a/app/common/logic/user_product_storage/UserProductStorageLogic.php b/app/common/logic/user_product_storage/UserProductStorageLogic.php index 4125c73c4..ed775d912 100644 --- a/app/common/logic/user_product_storage/UserProductStorageLogic.php +++ b/app/common/logic/user_product_storage/UserProductStorageLogic.php @@ -50,8 +50,12 @@ class UserProductStorageLogic extends BaseLogic self::setError('库存不足'); return false; } - $find->nums=bcsub($find['nums'],$v['nums']); - $find->saver(); + $nums=bcsub($find['nums'],$v['nums']); + $find->nums=$nums; + if($nums==0){ + $find->status=0; + } + $find->save(); $data_log[$k]['uid']=$uid; $data_log[$k]['oid']=$find['oid']; $data_log[$k]['product_id']=$find['product_id']; diff --git a/app/store/controller/user_product_storage/UserProductStorageController.php b/app/store/controller/user_product_storage/UserProductStorageController.php index 60b159433..d13a54e6a 100644 --- a/app/store/controller/user_product_storage/UserProductStorageController.php +++ b/app/store/controller/user_product_storage/UserProductStorageController.php @@ -36,7 +36,6 @@ class UserProductStorageController extends BaseAdminController $info=$params['info']; $uid=$params['uid']; $store_id=$this->adminInfo['store_id']; - d($params); UserProductStorageLogic::supply($info,$uid,$store_id); if(UserProductStorageLogic::hasError()){ return $this->fail(UserProductStorageLogic::getError()); From 6b59bb043dea4a65ebf7ba492e6aae2e7e32f232 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Fri, 28 Jun 2024 15:50:46 +0800 Subject: [PATCH 17/33] =?UTF-8?q?feat(UserProductStorageLists):=20?= =?UTF-8?q?=E6=A0=B9=E6=8D=AE=E8=AF=B7=E6=B1=82=E5=8F=82=E6=95=B0status?= =?UTF-8?q?=E6=9D=A5=E6=98=BE=E7=A4=BA=E4=B8=8D=E5=90=8C=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E7=9A=84=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lists/user_product_storage/UserProductStorageLists.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/admin/lists/user_product_storage/UserProductStorageLists.php b/app/admin/lists/user_product_storage/UserProductStorageLists.php index 25b60b617..e7efd4b25 100644 --- a/app/admin/lists/user_product_storage/UserProductStorageLists.php +++ b/app/admin/lists/user_product_storage/UserProductStorageLists.php @@ -45,7 +45,10 @@ class UserProductStorageLists extends BaseAdminDataLists implements ListsSearchI */ public function lists(): array { - $this->searchWhere[]=['status','=',1];//只显示正常状态的记录,不显示已出库完的记录 + $status=$this->request->get('status',1); + if($status==1){ + $this->searchWhere[]=['status','=',1];//只显示正常状态的记录,不显示已出库完的记录 + } return UserProductStorage::where($this->searchWhere) ->field(['id', 'uid', 'oid', 'product_id', 'nums', 'status','create_time']) ->limit($this->limitOffset, $this->limitLength) From 9f3a36201d87ef79be2aab3081d7188221e2de77 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Fri, 28 Jun 2024 16:10:50 +0800 Subject: [PATCH 18/33] =?UTF-8?q?feat(user):=20=E5=A2=9E=E5=8A=A0=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E6=A0=87=E7=AD=BE=E6=9F=A5=E8=AF=A2=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/logic/user/UserLogic.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/api/logic/user/UserLogic.php b/app/api/logic/user/UserLogic.php index e925a859f..d841c9c09 100644 --- a/app/api/logic/user/UserLogic.php +++ b/app/api/logic/user/UserLogic.php @@ -20,6 +20,7 @@ use app\common\{logic\BaseLogic, model\vip_flow\VipFlow, service\SmsService, service\wechat\WeChatMnpService}; +use app\common\model\user_label\UserLabel; use support\Cache; use think\facade\Db; @@ -83,7 +84,7 @@ class UserLogic extends BaseLogic { $data = User::with(['userShip'])->where('id',$uid) ->field('id,avatar,real_name,nickname,account,mobile,sex,login_ip,now_money,total_recharge_amount,user_ship - ,purchase_funds,integral,pay_password') + ,purchase_funds,integral,pay_password,label_id') ->find(); //判断是不是员工 if($data){ @@ -105,6 +106,7 @@ class UserLogic extends BaseLogic $data['store_id'] = $check['store_id']; } } + $data['label_name']=UserLabel::where('label_id',$data['label_id'])->value('label_name'); $data['return_money'] = Db::name('vip_flow')-> where(['user_id'=>$uid,'status'=>0]) ->sum('number'); From e7f1df05764caf7cd41ee49de51b7763181313d0 Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Fri, 28 Jun 2024 16:37:07 +0800 Subject: [PATCH 19/33] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=BA=97=E9=93=BA?= =?UTF-8?q?=E9=80=BB=E8=BE=91=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/logic/user/UserLogic.php | 2 +- app/store/lists/user/UserLists.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/admin/logic/user/UserLogic.php b/app/admin/logic/user/UserLogic.php index 3d02c5872..809056e1d 100644 --- a/app/admin/logic/user/UserLogic.php +++ b/app/admin/logic/user/UserLogic.php @@ -90,7 +90,7 @@ class UserLogic extends BaseLogic 'password' => $password, 'mobile' => $params['mobile'], 'label_id' => $params['label_id']??0, - + 'store_id' => $params['store_id']??0, ]; $res=User::create($data); UserCreateLog::create([ diff --git a/app/store/lists/user/UserLists.php b/app/store/lists/user/UserLists.php index 8b3437237..2a193332b 100644 --- a/app/store/lists/user/UserLists.php +++ b/app/store/lists/user/UserLists.php @@ -22,7 +22,7 @@ class UserLists extends BaseAdminDataLists implements ListsSearchInterface public function setSearch(): array { return [ - '=' => ['id','user_ship'], + '=' => ['id','user_ship','store_id'], '%like%' => ['mobile'], ]; } From d46d6139a00f96f76d28883b57ed5067163739ac Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Fri, 28 Jun 2024 16:49:53 +0800 Subject: [PATCH 20/33] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E9=87=87=E8=B4=AD?= =?UTF-8?q?=E6=AC=BE=E4=B8=8B=E5=8D=95=E4=B8=8D=E5=8F=8D=E5=85=91=E6=8D=A2?= =?UTF-8?q?=E5=88=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/logic/PayNotifyLogic.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index 8cc60abb3..944bb7a2a 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -778,7 +778,7 @@ class PayNotifyLogic extends BaseLogic $financeLogic->in($transaction_id, $order['pay_price'], OrderEnum::SUPPLIER_ORDER_OBTAINS, $order['store_id'], 0, 0, $order['pay_type']); $financeLogic->out($transaction_id, $order['pay_price'], OrderEnum::SUPPLIER_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); $financeLogic->save(); - if ($order['uid'] > 0 && $order['total_price'] >= 500 ) { + if ($order['uid'] > 0 && $order['total_price'] >= 500 && $order['pay_type'] !=PayEnum::PURCHASE_FUNDS) { $user_number = bcmul($order['pay_price'], '0.10', 2); $sing = [ 'uid' => $order['uid'], @@ -813,7 +813,7 @@ class PayNotifyLogic extends BaseLogic $order['pay_price'] = bcsub($order['pay_price'], $vipFrozenAmount, 2); self::dealVipAmount($order, $order['pay_type']); } - if($order['total_price'] >= 500 ){ + if($order['total_price'] >= 500 && $order['pay_type'] !=PayEnum::PURCHASE_FUNDS){ $user_number = bcmul($order['pay_price'], '0.10', 2); $sing = [ 'uid' => $order['uid'], From c0f64c83fcd6ccca14e83a0bb2741a673928ffc8 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Fri, 28 Jun 2024 16:58:57 +0800 Subject: [PATCH 21/33] =?UTF-8?q?feat(pay-notify-logic):=20=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E6=94=AF=E4=BB=98=E9=80=9A=E7=9F=A5=E9=80=BB=E8=BE=91?= =?UTF-8?q?=EF=BC=8C=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81=E7=BB=93=E6=9E=84?= =?UTF-8?q?=EF=BC=8C=E6=8F=90=E9=AB=98=E5=8F=AF=E8=AF=BB=E6=80=A7=E5=92=8C?= =?UTF-8?q?=E5=8F=AF=E7=BB=B4=E6=8A=A4=E6=80=A7=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/logic/CommissionLogic.php | 143 ++++------ app/common/logic/PayNotifyLogic.php | 384 ++++++++++----------------- 2 files changed, 205 insertions(+), 322 deletions(-) diff --git a/app/common/logic/CommissionLogic.php b/app/common/logic/CommissionLogic.php index 072731033..b239ef66f 100644 --- a/app/common/logic/CommissionLogic.php +++ b/app/common/logic/CommissionLogic.php @@ -12,105 +12,62 @@ class CommissionLogic extends BaseLogic /** * 走村长分润 */ - public static function setVillage($order, $transaction_id) + public static function setVillage($order,$village_uid=0,$brigade_uid=0, $transaction_id=0) { - $village_uid=0; - $brigade_uid=0; - if ($order['uid'] > 0) { - $address = UserAddress::where(['uid' => $order['uid'], 'is_default' => 1])->find(); - if ($address) { - $arr1 = UserAddress::where(['village' => $address['village'], 'is_default' => 1])->column('uid'); - if ($arr1) { - $uid = User::where('id', 'in', $arr1)->where('user_ship', 2)->value('id'); - if ($uid) { - $village_uid = $uid; - } - } - $arr2 = UserAddress::where(['village' => $address['village'], 'brigade' => $address['brigade'], 'is_default' => 1])->column('uid'); - if ($arr2) { - $uid = User::where('id', 'in', $arr1)->where('user_ship', 3)->value('id'); - if ($uid) { - $brigade_uid = $uid; - } - } - } - } - self::user($order, 0.05, $transaction_id,$village_uid,14);//村长 - self::user($order, 0.03, $transaction_id,0,12);//会员、厨师 - self::user($order, 0.01, $transaction_id,$brigade_uid,15);//队长 - self::user($order, 0.01, $transaction_id,0,16);//其他 + $user_1=self::user($order, 0.05, $transaction_id,$village_uid,14);//村长 + $user_2=self::user($order, 0.03, $transaction_id,0,12);//会员、厨师 + $user_3=self::user($order, 0.01, $transaction_id,$brigade_uid,15);//队长 + + $platform=self::platform($order, 0.02, $transaction_id);//平台 + $store=self::store($order, 0.05, $transaction_id,0);//门店 + $user_4=self::user($order, 0.02, $transaction_id,0,16);//其他 + + $moeny=bcadd(bcadd(bcadd(bcadd($user_1,$user_2,2),$user_3,2),$platform,2),bcadd($store,$user_4,2),2); + self::suppliter($order, $moeny, $transaction_id); } /** * 走队长分润 */ - public static function setBrigade($order, $transaction_id) + public static function setBrigade($order,$village_uid=0,$brigade_uid=0, $transaction_id=0) { - $village_uid=0; - $brigade_uid=0; - if ($order['uid'] > 0) { - $address = UserAddress::where(['uid' => $order['uid'], 'is_default' => 1])->find(); - if ($address) { - $arr1 = UserAddress::where(['village' => $address['village'], 'is_default' => 1])->column('uid'); - if ($arr1) { - $uid = User::where('id', 'in', $arr1)->where('user_ship', 2)->value('id'); - if ($uid) { - $village_uid = $uid; - } - } - $arr2 = UserAddress::where(['village' => $address['village'], 'brigade' => $address['brigade'], 'is_default' => 1])->column('uid'); - if ($arr2) { - $uid = User::where('id', 'in', $arr1)->where('user_ship', 3)->value('id'); - if ($uid) { - $brigade_uid = $uid; - } - } - } - } - self::user($order, 0.05, $transaction_id,$brigade_uid,14);//队长 - self::user($order, 0.03, $transaction_id,0,12);////会员、厨师 - self::user($order, 0.01, $transaction_id,$village_uid,15);//村长 - self::user($order, 0.01, $transaction_id,0,16);//其他 + $user_1=self::user($order, 0.05, $transaction_id,$brigade_uid,14);//队长 + $user_2=self::user($order, 0.03, $transaction_id,0,12);////会员、厨师 + $user_3=self::user($order, 0.01, $transaction_id,$village_uid,15);//村长 + + $platform=self::platform($order, 0.02, $transaction_id);//平台 + $store=self::store($order, 0.05, $transaction_id,0);//门店 + $user_4=self::user($order, 0.02, $transaction_id,0,16);//其他 + + $moeny=bcadd(bcadd(bcadd(bcadd($user_1,$user_2,2),$user_3,2),$platform,2),bcadd($store,$user_4,2),2); + self::suppliter($order, $moeny, $transaction_id); } /** * 走厨师分润 */ - public static function setCook($order, $transaction_id) + public static function setCook($order,$village_uid=0,$brigade_uid=0, $transaction_id=0) { - $village_uid=0; - $brigade_uid=0; - if ($order['uid'] > 0) { - $address = UserAddress::where(['uid' => $order['uid'], 'is_default' => 1])->find(); - if ($address) { - $arr1 = UserAddress::where(['village' => $address['village'], 'is_default' => 1])->column('uid'); - if ($arr1) { - $uid = User::where('id', 'in', $arr1)->where('user_ship', 2)->value('id'); - if ($uid) { - $village_uid = $uid; - } - } - $arr2 = UserAddress::where(['village' => $address['village'], 'brigade' => $address['brigade'], 'is_default' => 1])->column('uid'); - if ($arr2) { - $uid = User::where('id', 'in', $arr1)->where('user_ship', 3)->value('id'); - if ($uid) { - $brigade_uid = $uid; - } - } - } - } - self::user($order, 0.07, $transaction_id,0,12);//会员、厨师 - self::user($order, 0.01, $transaction_id,$village_uid,14);//村长 - self::user($order, 0.01, $transaction_id,$brigade_uid,15);//队长 - self::user($order, 0.01, $transaction_id,0,16);//其他 + $user_1=self::user($order, 0.07, $transaction_id,0,12);//会员、厨师 + $user_2=self::user($order, 0.01, $transaction_id,$village_uid,14);//村长 + $user_3=self::user($order, 0.01, $transaction_id,$brigade_uid,15);//队长 + + $platform=self::platform($order, 0.02, $transaction_id);//平台 + $store=self::store($order, 0.05, $transaction_id,0);//门店 + $user_4=self::user($order, 0.02, $transaction_id,0,16);//其他 + + $moeny=bcadd(bcadd(bcadd(bcadd($user_1,$user_2,2),$user_3,2),$platform,2),bcadd($store,$user_4,2),2); + self::suppliter($order, $moeny, $transaction_id); } /** * 走线下分润 */ - public static function setStore($order, $transaction_id) + public static function setStore($order, $transaction_id=0) { - self::platform($order, 0.05, $transaction_id);//平台 - self::store($order, 0.02, $transaction_id,0);//门店 - self::user($order, 0.01, $transaction_id,0,16);//其他 + $platform= self::platform($order, 0.05, $transaction_id);//平台 + $store= self::store($order, 0.02, $transaction_id,0);//门店 + $user= self::user($order, 0.01, $transaction_id,0,16);//其他 + $moeny=bcadd(bcadd($platform,$store,2),$user,2); + self::suppliter($order, $moeny, $transaction_id); } @@ -122,11 +79,27 @@ class CommissionLogic extends BaseLogic { $financeLogic = new StoreFinanceFlowLogic(); $financeLogic->order=$order; + $financeLogic->user['uid']=$order['uid']; $fees = bcdiv(bcmul($order['pay_price'], $platformRate, 2), 1, 2); if ($fees > 0) { $financeLogic->in($transaction_id, $fees, OrderEnum::ORDER_HANDLING_FEES, $order['store_id'], 0, 0, $order['pay_type']); //平台手续费 $financeLogic->out($transaction_id, $fees, OrderEnum::ORDER_HANDLING_FEES, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); //商户平台手续费支出 } + return $fees; + } + /** + * 供应链订单获得 + */ + public static function suppliter($order, $platformRate, $transaction_id) + { + $financeLogic = new StoreFinanceFlowLogic(); + $financeLogic->order=$order; + $financeLogic->user['uid']=$order['uid']; + $fees = bcsub($order['pay_price'], $platformRate,2); + if ($fees > 0) { + $financeLogic->in($transaction_id, $fees, OrderEnum::SUPPLIER_ORDER_OBTAINS, $order['store_id'], 0, 0, $order['pay_type']); + $financeLogic->out($transaction_id, $fees, OrderEnum::SUPPLIER_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); + } } /** * 门店分润 @@ -142,7 +115,7 @@ class CommissionLogic extends BaseLogic //缴纳齐全了就加商户没有就加到平台 $money_limt = SystemStore::where('id', $order['store_id'])->field('paid_deposit,security_deposit')->find(); $deposit = bcsub($money_limt['security_deposit'], $money_limt['paid_deposit'], 2); //保证金剩余额度 - $store_profit = bcdiv(bcmul($order['pay_price'], $platformRate, 2), 1, 2); + $store_profit = bcmul($order['pay_price'], $platformRate, 2); if ($deposit > 0) { if ($deposit > $store_profit) { if ($store_profit > 0) { @@ -167,6 +140,7 @@ class CommissionLogic extends BaseLogic $financeLogic->in($transaction_id, $store_profit, OrderEnum::MERCHANT_ORDER_OBTAINS, $order['store_id'], 0, 0, $order['pay_type']); //平台手续费 } } + return $store_profit; } /** @@ -188,8 +162,7 @@ class CommissionLogic extends BaseLogic $financeLogic->order=$order; $financeLogic->in($transaction_id, $fees, $enum, $order['store_id'], 0, 0, $order['pay_type']); $financeLogic->out($transaction_id, $fees, $enum, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); - - } + return $fees; } } diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index 8cc60abb3..66857b2de 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -71,14 +71,14 @@ class PayNotifyLogic extends BaseLogic if ($user['now_money'] < $order['pay_price']) { throw new \Exception('余额不足'); } -// $order->money = $order['pay_price']; + // $order->money = $order['pay_price']; $order->paid = 1; $order->pay_time = time(); if (!$order->save()) { throw new \Exception('订单保存出错'); } - if($order['is_storage']==1){ - $order->status=2; + if ($order['is_storage'] == 1) { + $order->status = 2; UserProductStorageLogic::add($order); } // 减去余额 @@ -95,9 +95,9 @@ class PayNotifyLogic extends BaseLogic $capitalFlowDao = new CapitalFlowLogic($user); $capitalFlowDao->userExpense('user_order_balance_pay', 'order', $order['id'], $order['pay_price'], '', 0, $order['store_id']); self::dealProductLog($order); -// if ($order['shipping_type'] == 3) { -// self::descStock($order['id']); -// } + // if ($order['shipping_type'] == 3) { + // self::descStock($order['id']); + // } self::afterPay($order); if ($extra && $extra['store_id']) { $params = [ @@ -184,8 +184,8 @@ class PayNotifyLogic extends BaseLogic if (!$order->save()) { throw new \Exception('订单保存出错'); } - if($order['is_storage']==1){ - $order->status=2; + if ($order['is_storage'] == 1) { + $order->status = 2; UserProductStorageLogic::add($order); } // 减去采购款 @@ -208,15 +208,15 @@ class PayNotifyLogic extends BaseLogic OrderLogic::writeOff($params); } self::dealProductLog($order); -// $count = UserSign::where([ -// 'uid'=>$order['uid'], -// 'type'=>1, -// 'status'=>0 -// ])->count(); -// -// if($count){ -// self::addFlowLog($order); -// } + // $count = UserSign::where([ + // 'uid'=>$order['uid'], + // 'type'=>1, + // 'status'=>0 + // ])->count(); + // + // if($count){ + // self::addFlowLog($order); + // } // if($order['shipping_type'] == 3){ // self::descStock($order['id']); // } @@ -225,85 +225,83 @@ class PayNotifyLogic extends BaseLogic // Redis::send('push-platform-print', ['id' => $order['id']], 60); // PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type' => 'store_merchant', 'msg' => '您有一笔新的订单']); } - + //采购款支付后如果有对应的冻结的话就去反对应的log public static function addFlowLog($order) { //查询当前用户有无对应的充值的冻结金额 - if($order['uid'] >0){ + if ($order['uid'] > 0) { $query = UserSign::where([ - 'uid'=>$order['uid'], - 'type'=>1, - 'status'=>0 + 'uid' => $order['uid'], + 'type' => 1, + 'status' => 0 ]); -// $query1 = clone $query; -// $ids = $query->column('id'); + // $query1 = clone $query; + // $ids = $query->column('id'); $check = $query->sum('number'); -// $count = $query1->count(); - if($check && $check >0){ - $backPurchase = bcmul($order['pay_price'],0.1,2); + // $count = $query1->count(); + if ($check && $check > 0) { + $backPurchase = bcmul($order['pay_price'], 0.1, 2); -// if($count == 1){ - //存在拆单子否 - //少了就冻结减去这个对应的金额 - $one = UserSign::where([ - 'uid'=>$order['uid'], - 'type'=>1, - 'status'=>0 - ])->find(); - $data = [ - 'sid'=>$one['id'], - 'uid' => $order['uid'], - 'order_id' => $order['order_id'], - 'title' => '充值获得冻结兑换券', - 'financial_pm' => 1, - 'type' => 1, - 'status' => 1, - ]; + // if($count == 1){ + //存在拆单子否 + //少了就冻结减去这个对应的金额 + $one = UserSign::where([ + 'uid' => $order['uid'], + 'type' => 1, + 'status' => 0 + ])->find(); + $data = [ + 'sid' => $one['id'], + 'uid' => $order['uid'], + 'order_id' => $order['order_id'], + 'title' => '充值获得冻结兑换券', + 'financial_pm' => 1, + 'type' => 1, + 'status' => 1, + ]; - if($one['number'] >= $backPurchase){ -// $wait = bcsub($one['number'],$backPurchase,2)??0; - $data['number'] =$backPurchase; + if ($one['number'] >= $backPurchase) { + // $wait = bcsub($one['number'],$backPurchase,2)??0; + $data['number'] = $backPurchase; - Db::name('user_sign_log')->insert($data); + Db::name('user_sign_log')->insert($data); - //总的减去采购款百分之十剩余的 -// if(empty($wait)){ -// UserSign::where('id',$one['id'])->update( -// [ -// 'number'=>0, -// 'status'=>1 -// ] -// ); -// }else{ -// //add -// UserSign::where('id',$one['id'])->update( -// [ -// 'number'=>$wait -// ] -// ); -// } - - //并且加到对应的用户的采购款中 -// User::where('id',$order['uid'])->inc('purchase_funds',$wait)->update(); - } - else{ - //对比采购款支付的多少 多了就拿冻结金额即可 - $data['number'] =$one['number']; - //都存到对应的log日志 - Db::name('user_sign_log')->insert($data); -// UserSign::where('id',$one['id'])->update( -// [ -// 'number'=>0, -// 'status'=>1 -// ] -// ); - //并且加到对应的用户的采购款中 -// User::where('id',$order['uid'])->inc('purchase_funds',$wait)->update(); - } + //总的减去采购款百分之十剩余的 + // if(empty($wait)){ + // UserSign::where('id',$one['id'])->update( + // [ + // 'number'=>0, + // 'status'=>1 + // ] + // ); + // }else{ + // //add + // UserSign::where('id',$one['id'])->update( + // [ + // 'number'=>$wait + // ] + // ); + // } + //并且加到对应的用户的采购款中 + // User::where('id',$order['uid'])->inc('purchase_funds',$wait)->update(); + } else { + //对比采购款支付的多少 多了就拿冻结金额即可 + $data['number'] = $one['number']; + //都存到对应的log日志 + Db::name('user_sign_log')->insert($data); + // UserSign::where('id',$one['id'])->update( + // [ + // 'number'=>0, + // 'status'=>1 + // ] + // ); + //并且加到对应的用户的采购款中 + // User::where('id',$order['uid'])->inc('purchase_funds',$wait)->update(); } - /* else{ + } + /* else{ //大于0的时候 //先处理金额大的再处理剩余的 //把所有的金额改为正的再加一条后再加 @@ -358,9 +356,8 @@ class PayNotifyLogic extends BaseLogic }*/ -// } + // } return true; - } return true; @@ -382,8 +379,8 @@ class PayNotifyLogic extends BaseLogic $order->status = 1; $order->paid = 1; $order->pay_time = time(); - if($order['is_storage']==1){ - $order->status=2; + if ($order['is_storage'] == 1) { + $order->status = 2; UserProductStorageLogic::add($order); } if ($order->pay_type != 10) { @@ -442,7 +439,7 @@ class PayNotifyLogic extends BaseLogic $user = User::where('id', $order['uid'])->findOrEmpty(); $capitalFlowDao = new CapitalFlowLogic($user); $deal_money = bcdiv($extra['amount']['refund'], 100, 2); - $check_user_sing = UserSign::where('order_id',$order['order_id'])->count(); + $check_user_sing = UserSign::where('order_id', $order['order_id'])->count(); if (in_array($order['pay_type'], [PayEnum::BALANCE_PAY, PayEnum::PURCHASE_FUNDS])) { if ($order['pay_type'] == PayEnum::BALANCE_PAY) { //用户余额 $user->now_money = bcadd($user->now_money, $deal_money, 2); @@ -460,13 +457,13 @@ class PayNotifyLogic extends BaseLogic //退款 $capitalFlowDao->userIncome('system_purchase_back', 'system_back', $order['id'], $deal_money); } - if($check_user_sing){ + if ($check_user_sing) { self::descUserSing($order); } return true; } //积分 - if($check_user_sing){ + if ($check_user_sing) { self::descUserSing($order); } //微信日志 user_order_refund @@ -478,12 +475,12 @@ class PayNotifyLogic extends BaseLogic // self::afterPay($order,$extra['transaction_id']); } - + //退积分-->订单 public static function descUserSing($order) { $user_sing = new UserSign(); - if ($order['uid'] > 0 ) { + if ($order['uid'] > 0) { $user_number = bcmul($order['refund_price'], '0.10', 2); $sing = [ 'uid' => $order['uid'], @@ -496,21 +493,19 @@ class PayNotifyLogic extends BaseLogic $user_sing->save($sing); //删除之前获得的兑换券 UserSign::where([ - 'order_id'=>$order['order_id'], - 'financial_pm'=>1, - ])->update(['delete_time'=>time()]); - $now_int = User::where('id',$order['uid'])->withTrashed()->find(); - if($now_int){ - if($now_int['integral'] > $user_number){ - User::where('id',$order['uid'])->withTrashed()->dec('integral',$user_number)->update(); - }else{ - User::where('id',$order['uid'])->withTrashed()->dec('integral',$now_int['integral'])->update(); + 'order_id' => $order['order_id'], + 'financial_pm' => 1, + ])->update(['delete_time' => time()]); + $now_int = User::where('id', $order['uid'])->withTrashed()->find(); + if ($now_int) { + if ($now_int['integral'] > $user_number) { + User::where('id', $order['uid'])->withTrashed()->dec('integral', $user_number)->update(); + } else { + User::where('id', $order['uid'])->withTrashed()->dec('integral', $now_int['integral'])->update(); } - } } return true; - } @@ -613,7 +608,7 @@ class PayNotifyLogic extends BaseLogic public static function dealRechargeFrozen($order) { - $total_vip = bcmul($order['price'],0.1,2); + $total_vip = bcmul($order['price'], 0.1, 2); $user_sing = new UserSign(); $sing = [ 'uid' => $order['uid'], @@ -626,8 +621,8 @@ class PayNotifyLogic extends BaseLogic 'number' => $total_vip, 'back_num' => $total_vip, ]; - $user_sing->save($sing); - User::where('id',$order->uid)->inc('integral',$total_vip)->update(); + $user_sing->save($sing); + User::where('id', $order->uid)->inc('integral', $total_vip)->update(); return true; } @@ -655,31 +650,30 @@ class PayNotifyLogic extends BaseLogic $user = User::where('id', $uid)->findOrEmpty(); //用户的财务add $capitalFlowDao = new CapitalFlowLogic($user); - $capitalFlowDao->userIncome('user_balance_recharge', 'user_recharge', $order['id'], $price,[],1); + $capitalFlowDao->userIncome('user_balance_recharge', 'user_recharge', $order['id'], $price, [], 1); if ($user->isEmpty()) { return true; } bcscale(2); // $user->now_money = bcadd($user->now_money, $price, 2);//v.1 - $check = UserSign::where(['uid'=>$order->uid,'type'=>1])->count(); - if(empty($check) && $user['user_ship'] == 0){ + $check = UserSign::where(['uid' => $order->uid, 'type' => 1])->count(); + if (empty($check) && $user['user_ship'] == 0) { self::dealRechargeFrozen($order); - } //更新等级 $user->user_ship = $order['user_ship']; - + $user->purchase_funds = bcadd($user->purchase_funds, $price, 2); $user->total_recharge_amount = bcadd($user->total_recharge_amount, $price, 2); $user->save(); - if($order['other_uid']>0){ - $uid=$order['other_uid']; + if ($order['other_uid'] > 0) { + $uid = $order['other_uid']; } - PushService::push('wechat_mmp_' . $uid, $uid, ['type'=>'INDUSTRYMEMBERS','msg'=>'订单支付成功','data'=>['id'=>$order['id'],'paid'=>1]]); - PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type'=>'INDUSTRYMEMBERS','msg'=>'订单支付成功','data'=>['id'=>$order['id'],'paid'=>1]]); + PushService::push('wechat_mmp_' . $uid, $uid, ['type' => 'INDUSTRYMEMBERS', 'msg' => '订单支付成功', 'data' => ['id' => $order['id'], 'paid' => 1]]); + PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type' => 'INDUSTRYMEMBERS', 'msg' => '订单支付成功', 'data' => ['id' => $order['id'], 'paid' => 1]]); if (!empty($extra['payer']['openid'])) { Redis::send('push-delivery', ['order_id' => $order['order_id'], 'openid' => $extra['payer']['openid'], 'logistics_type' => 3], 4); } @@ -703,7 +697,7 @@ class PayNotifyLogic extends BaseLogic throw new \Exception('订单保存出错'); } self::afterPay($order); - if($order['is_storage']==1){ + if ($order['is_storage'] == 1) { UserProductStorageLogic::add($order); } $cashFlowLogic = new CashFlowLogic(); @@ -770,6 +764,9 @@ class PayNotifyLogic extends BaseLogic $financeLogic = new StoreFinanceFlowLogic(); $user_sing = new UserSign(); $off_activity = Config::where('name', 'off_activity')->value('value'); + $village_uid = 0; + $brigade_uid = 0; + $user_ship = 0; if ($off_activity == 1) { //-----活动价结算更改 $financeLogic->order = $order; @@ -778,7 +775,7 @@ class PayNotifyLogic extends BaseLogic $financeLogic->in($transaction_id, $order['pay_price'], OrderEnum::SUPPLIER_ORDER_OBTAINS, $order['store_id'], 0, 0, $order['pay_type']); $financeLogic->out($transaction_id, $order['pay_price'], OrderEnum::SUPPLIER_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); $financeLogic->save(); - if ($order['uid'] > 0 && $order['total_price'] >= 500 ) { + if ($order['uid'] > 0 && $order['total_price'] >= 500) { $user_number = bcmul($order['pay_price'], '0.10', 2); $sing = [ 'uid' => $order['uid'], @@ -792,28 +789,19 @@ class PayNotifyLogic extends BaseLogic } return false; } - $vipFen = 0; if ($order['uid'] > 0) { // 结算金额 要支付的钱减去冻结得钱去走后面得逻辑 发得兑换券也要去减去 //用户下单该用户等级为1得时候才处理冻结金额 $user = User::where('id', $order['uid'])->find(); + $user_ship = $user['user_ship']; //纯在分销关系的时候要去判断分销出来的用户的采购款的额度 (只有会员按照这个逻辑拆分,其余的还是按照正常的支付金额) - if ($order['spread_uid'] > 0) { - $oldUser = User::where('id', $order['spread_uid'])->field('purchase_funds,user_ship')->find(); - if ($oldUser && $oldUser['user_ship'] == 1) { - if ($oldUser['purchase_funds'] < $order['pay_price']) { - $vipFen = $oldUser['purchase_funds']; - } - } - } elseif ($user['user_ship'] == 1 && $order['pay_type'] != PayEnum::CASH_PAY) { + if ($user['user_ship'] == 1 && $order['pay_type'] != PayEnum::CASH_PAY) { $vipFrozenAmount = self::dealFrozenPrice($order['id']); //为1的时候要去减活动价 - // $final_price = bcsub($order['pay_price'],$order['deduction_price'],2); - // d($final_price,$vipFrozenAmount); $order['pay_price'] = bcsub($order['pay_price'], $vipFrozenAmount, 2); self::dealVipAmount($order, $order['pay_type']); } - if($order['total_price'] >= 500 ){ + if ($order['total_price'] >= 500) { $user_number = bcmul($order['pay_price'], '0.10', 2); $sing = [ 'uid' => $order['uid'], @@ -826,119 +814,41 @@ class PayNotifyLogic extends BaseLogic ]; $user_sing->save($sing); } - - // User::where('id', $order['uid'])->inc('integral', $user_number)->update(); } - - - $financeLogic->order = $order; - $financeLogic->user = ['uid' => $order['uid']]; - // if ($order->pay_type != 9 || $order->pay_type != 10) { - $financeLogic->in($transaction_id, $order['pay_price'], OrderEnum::USER_ORDER_PAY, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); //用户订单支付 - $count_frees = 0; - - //平台手续费 - $fees = bcdiv(bcmul($order['pay_price'], '0.02', 2), 1, 2); - $count_frees = bcadd($count_frees, $fees, 2); - if ($fees > 0) { - $financeLogic->in($transaction_id, $fees, OrderEnum::ORDER_HANDLING_FEES, $order['store_id'], 0, 0, $order['pay_type']); //平台手续费 - $financeLogic->out($transaction_id, $fees, OrderEnum::ORDER_HANDLING_FEES, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); //商户平台手续费支出 + //查询用户对应的村长和队长 + $address = UserAddress::where(['uid' => $order['uid'], 'is_default' => 1])->find(); + if ($address) { + $arr1 = UserAddress::where(['village' => $address['village'], 'is_default' => 1])->column('uid'); + if ($arr1) { + $village_uid = User::where('id', 'in', $arr1)->where('user_ship', 2)->value('id') ?? 0; + } + $arr2 = UserAddress::where(['village' => $address['village'], 'brigade' => $address['brigade'], 'is_default' => 1])->column('uid'); + if ($arr2) { + $brigade_uid = User::where('id', 'in', $arr2)->where('user_ship', 3)->value('id') ?? 0; + } } - // $frozen = bcsub($order->profit, $fees, 2); - //缴纳齐全了就加商户没有就加到平台 - $money_limt = SystemStore::where('id', $order['store_id'])->field('paid_deposit,security_deposit')->find(); - $deposit = bcsub($money_limt['security_deposit'], $money_limt['paid_deposit'], 2); //保证金剩余额度 - $store_profit = bcdiv(bcmul($order['pay_price'], '0.05', 2), 1, 2); - $count_frees = bcadd($count_frees, $store_profit, 2); - if ($deposit > 0) { - if ($deposit > $store_profit) { - if ($store_profit > 0) { - // SystemStore::where('id', $order['store_id'])->inc('paid_deposit', $store_profit)->update(); - $financeLogic->out($transaction_id, $store_profit, OrderEnum::ORDER_MARGIN, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); - $financeLogic->in($transaction_id, 0, OrderEnum::MERCHANT_ORDER_OBTAINS, $order['store_id'], 0, 0, $order['pay_type']); //平台手续费 - } - } else { - $money = bcsub($store_profit, $deposit, 2); - if ($deposit > 0) { - // SystemStore::where('id', $order['store_id'])->inc('paid_deposit', $deposit)->update(); - $financeLogic->out($transaction_id, $deposit, OrderEnum::ORDER_MARGIN, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); - } - if ($money) { - // SystemStore::where('id', $order['store_id'])->inc('store_money', $money)->update(); - $financeLogic->in($transaction_id, $money, OrderEnum::MERCHANT_ORDER_OBTAINS, $order['store_id'], 0, 0, $order['pay_type']); //平台手续费 - } + if ($order['spread_uid'] > 0 || $user_ship>0) { + if($order['spread_uid'] > 0 && $user_ship == 0){ + $user_ship = User::where('id', $order['spread_uid'])->value('user_ship'); + } + switch ($user_ship) { + case 1: // 行业会员 + case 4: // 商户 + CommissionLogic::setCook($order, $village_uid, $brigade_uid, $transaction_id); + break; + case 2: // 村长 + CommissionLogic::setVillage($order, $village_uid, $brigade_uid, $transaction_id); + break; + case 3: // 队长 + CommissionLogic::setBrigade($order, $village_uid, $brigade_uid, $transaction_id); + break; + default: + CommissionLogic::setStore($order, $transaction_id); + break; } } else { - if ($store_profit > 0) { - // SystemStore::where('id', $order['store_id'])->inc('store_money', $store_profit)->update(); - $financeLogic->in($transaction_id, $store_profit, OrderEnum::MERCHANT_ORDER_OBTAINS, $order['store_id'], 0, 0, $order['pay_type']); //平台手续费 - } + CommissionLogic::setStore($order, $transaction_id); } - // if ($order['is_vip'] >= 1) { - if ($order['spread_uid'] > 0) { - if ($vipFen) { - $fees = bcdiv(bcmul($vipFen, '0.08', 2), 1, 2); - } else { - $fees = bcdiv(bcmul($order['pay_price'], '0.08', 2), 1, 2); - } - $count_frees = bcadd($count_frees, $fees, 2); - } - $fees = bcdiv(bcmul($order['pay_price'], '0.01', 2), 1, 2); - $count_frees = bcadd($count_frees, bcmul($fees, 3, 2), 2); - $village_uid = 0; - $brigade_uid = 0; - //查询用户对应的村长和队长 - if ($order['uid'] > 0) { - $address = UserAddress::where(['uid' => $order['uid'], 'is_default' => 1])->find(); - if ($address) { - $arr1 = UserAddress::where(['village' => $address['village'], 'is_default' => 1])->column('uid'); - if ($arr1) { - $uid = User::where('id', 'in', $arr1)->where('user_ship', 2)->value('id'); - if ($uid) { - // User::where('id', $uid)->inc('integral', $fees)->update(); - $village_uid = $uid; - } - } - $arr2 = UserAddress::where(['village' => $address['village'], 'brigade' => $address['brigade'], 'is_default' => 1])->column('uid'); - if ($arr2) { - $uid = User::where('id', 'in', $arr1)->where('user_ship', 3)->value('id'); - if ($uid) { - // User::where('id', $uid)->inc('integral', $fees)->update(); - $brigade_uid = $uid; - } - } - } - } - if ($fees > 0) { - if ($village_uid > 0) { - // SystemStore::where('id', $village_uid)->inc('store_money', $fees)->update(); - $financeLogic->other_arr['vip_uid'] = $village_uid; - } - $financeLogic->in($transaction_id, $fees, OrderEnum::VILLAGE_ORDER_OBTAINS, $order['store_id'], 0, 0, $order['pay_type']); - $financeLogic->out($transaction_id, $fees, OrderEnum::VILLAGE_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); - //队长获得 - if ($brigade_uid > 0) { - // SystemStore::where('id', $brigade_uid)->inc('store_money', $fees)->update(); - $financeLogic->other_arr['vip_uid'] = $brigade_uid; - } - $financeLogic->in($transaction_id, $fees, OrderEnum::BRIGADE_ORDER_OBTAINS, $order['store_id'], 0, 0, $order['pay_type']); - $financeLogic->out($transaction_id, $fees, OrderEnum::BRIGADE_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); - // $user_sing->saveAll($sing); - //其他获得 - $financeLogic->other_arr['vip_uid'] = 0; - $financeLogic->in($transaction_id, $fees, OrderEnum::OTHER_ORDER_OBTAINS, $order['store_id'], 0, 0, $order['pay_type']); - $financeLogic->out($transaction_id, $fees, OrderEnum::OTHER_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); - } - // } - $fees = bcsub($order['pay_price'], $count_frees, 2); - //供应链订单获得 - if ($fees > 0) { - $financeLogic->in($transaction_id, $fees, OrderEnum::SUPPLIER_ORDER_OBTAINS, $order['store_id'], 0, 0, $order['pay_type']); - $financeLogic->out($transaction_id, $fees, OrderEnum::SUPPLIER_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); - } - // } - $financeLogic->save(); - // } } /** From 21c37a5345ac59d6ace5e98ddcb0d62a70cfba58 Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Fri, 28 Jun 2024 17:14:30 +0800 Subject: [PATCH 22/33] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=9C=B0=E5=9D=80?= =?UTF-8?q?=E9=80=BB=E8=BE=91=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/lists/user/UserLists.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/app/admin/lists/user/UserLists.php b/app/admin/lists/user/UserLists.php index 2ce801a64..7976c871f 100644 --- a/app/admin/lists/user/UserLists.php +++ b/app/admin/lists/user/UserLists.php @@ -11,6 +11,7 @@ use app\common\lists\ListsExcelInterface; use app\common\model\user\User; use app\common\model\user\UserAddress; use app\common\model\vip_flow\VipFlow; +use support\Db; class UserLists extends BaseAdminDataLists implements ListsExcelInterface { @@ -76,6 +77,30 @@ class UserLists extends BaseAdminDataLists implements ListsExcelInterface $item['return_money'] = VipFlow:: where(['user_id'=>$item['id'],'status'=>0]) ->sum('number')??0; + $address = UserAddress::where('uid',$item['id'])->find(); + $item['city'] = ''; + $item['area'] = ''; + $item['street'] = ''; + $item['village'] = ''; + $item['brigade'] = ''; + if($address){ + if($address['city']){ + $item['city'] = \think\facade\Db::name('geo_city')->where('city_code',$address['city'])->value('city_name')??''; + } + if($address['area']){ + $item['area'] = \think\facade\Db::name('geo_area')->where('area_code',$address['area'])->value('area_name')??''; + } + if($address['street']){ + $item['street'] = \think\facade\Db::name('geo_street')->where('street_code',$address['street'])->value('street_name')??''; + } + if($address['village']){ + $item['village'] = \think\facade\Db::name('geo_village')->where('village_code',$address['village'])->value('village_name')??''; + } + if($address['brigade']){ + $item['brigade'] = $address['brigade'] ? $address['brigade'].'队':''; + } + } + $item['format_address'] = $item['city'].'/'.$item['area'].'/'.$item['street'].'/'.$item['village'].'/'. $item['brigade']; } return $lists; From d752188d79e9b0a385e1baee4ae4c40840805fa6 Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Fri, 28 Jun 2024 17:39:19 +0800 Subject: [PATCH 23/33] =?UTF-8?q?=E6=89=93=E5=BC=80=E5=86=BB=E7=BB=93?= =?UTF-8?q?=E6=AC=BE=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/logic/order/OrderLogic.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index a50baf6c9..f67932394 100644 --- a/app/api/logic/order/OrderLogic.php +++ b/app/api/logic/order/OrderLogic.php @@ -99,14 +99,15 @@ class OrderLogic extends BaseLogic $cart_select[$k]['purchase'] = bcmul($v['cart_num'], $find['purchase'], 2) ?? 0; //成本 $cart_select[$k]['pay_price'] = bcmul($v['cart_num'], $price, 2); //订单支付金额 $cart_select[$k]['store_price'] = bcmul($v['cart_num'], $find['cost'], 2)??0; //门店零售价 - // $cart_select[$k]['vip_price'] = bcmul($v['cart_num'], $find['vip_price'], 2)??0; //vip售价 + $cart_select[$k]['vip_price'] = bcmul($v['cart_num'], $find['vip_price'], 2)??0; //vip售价 $cart_select[$k]['product_id'] = $find['product_id']; $cart_select[$k]['old_cart_id'] = $v['id']; $cart_select[$k]['cart_num'] = $v['cart_num']; $cart_select[$k]['verify_code'] = $params['verify_code'] ?? ''; //vip1待返回金额 - // $cart_select[$k]['vip_frozen_price'] = bcsub($cart_select[$k]['pay_price'],$cart_select[$k]['vip_price'],2); + $cart_select[$k]['vip_frozen_price'] = bcsub($cart_select[$k]['pay_price'],$cart_select[$k]['vip_price'],2); + // d($cart_select[$k]['pay_price'],$cart_select[$k]['store_price'],$cart_select[$k]['vip_price'] ); $cartInfo = $cart_select[$k]; $cartInfo['name'] = $find['store_name']; From 5fdf3496f8634d517fee935637acc52893f31076 Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Fri, 28 Jun 2024 18:02:33 +0800 Subject: [PATCH 24/33] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=A4=BC=E5=93=81?= =?UTF-8?q?=E5=88=B8=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/logic/user/UserLogic.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/api/logic/user/UserLogic.php b/app/api/logic/user/UserLogic.php index d841c9c09..c4db81bc5 100644 --- a/app/api/logic/user/UserLogic.php +++ b/app/api/logic/user/UserLogic.php @@ -305,10 +305,10 @@ class UserLogic extends BaseLogic //礼品券明细 $query = UserSign::where(['uid'=>$uid]); if($params['mark'] == 1){ - $query->where('financial_pm',0); + $query->where('financial_pm',1); } if($params['mark'] == 2){ - $query->where('financial_pm',1); + $query->where('financial_pm',0); } $count = $query->count(); $data =$query From 52e63cb05d4625c891009626a600b687f06bc5fa Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Fri, 28 Jun 2024 18:04:15 +0800 Subject: [PATCH 25/33] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E6=94=AF?= =?UTF-8?q?=E4=BB=98=E9=80=9A=E7=9F=A5=E9=80=BB=E8=BE=91=E5=B9=B6=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E8=AE=A2=E5=8D=95=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/logic/CommissionLogic.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/common/logic/CommissionLogic.php b/app/common/logic/CommissionLogic.php index b239ef66f..7777efc1b 100644 --- a/app/common/logic/CommissionLogic.php +++ b/app/common/logic/CommissionLogic.php @@ -84,6 +84,7 @@ class CommissionLogic extends BaseLogic if ($fees > 0) { $financeLogic->in($transaction_id, $fees, OrderEnum::ORDER_HANDLING_FEES, $order['store_id'], 0, 0, $order['pay_type']); //平台手续费 $financeLogic->out($transaction_id, $fees, OrderEnum::ORDER_HANDLING_FEES, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); //商户平台手续费支出 + $financeLogic->save(); } return $fees; } @@ -99,6 +100,7 @@ class CommissionLogic extends BaseLogic if ($fees > 0) { $financeLogic->in($transaction_id, $fees, OrderEnum::SUPPLIER_ORDER_OBTAINS, $order['store_id'], 0, 0, $order['pay_type']); $financeLogic->out($transaction_id, $fees, OrderEnum::SUPPLIER_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); + $financeLogic->save(); } } /** @@ -140,6 +142,7 @@ class CommissionLogic extends BaseLogic $financeLogic->in($transaction_id, $store_profit, OrderEnum::MERCHANT_ORDER_OBTAINS, $order['store_id'], 0, 0, $order['pay_type']); //平台手续费 } } + $financeLogic->save(); return $store_profit; } @@ -162,6 +165,7 @@ class CommissionLogic extends BaseLogic $financeLogic->order=$order; $financeLogic->in($transaction_id, $fees, $enum, $order['store_id'], 0, 0, $order['pay_type']); $financeLogic->out($transaction_id, $fees, $enum, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); + $financeLogic->save(); } return $fees; } From 93de8124ec59246ac2a5e976b1df0bee179d136b Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Fri, 28 Jun 2024 18:07:51 +0800 Subject: [PATCH 26/33] =?UTF-8?q?=E8=BF=94=E5=9B=9E=E9=87=91decimal?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/logic/user/UserLogic.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/api/logic/user/UserLogic.php b/app/api/logic/user/UserLogic.php index c4db81bc5..9bc09a05e 100644 --- a/app/api/logic/user/UserLogic.php +++ b/app/api/logic/user/UserLogic.php @@ -110,6 +110,7 @@ class UserLogic extends BaseLogic $data['return_money'] = Db::name('vip_flow')-> where(['user_id'=>$uid,'status'=>0]) ->sum('number'); + $data['return_money'] = bcadd($data['return_money'],0,2); //小程序 未核销的订单 $data['no_writeoff'] = StoreOrder::where([ 'is_writeoff'=>0,'uid'=>$uid From bc7cdeed63f9ad095def6ca19cedc341944fda05 Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Fri, 28 Jun 2024 18:32:18 +0800 Subject: [PATCH 27/33] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E9=87=87=E8=B4=AD?= =?UTF-8?q?=E6=AC=BE=E9=80=80=E6=AC=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/logic/PayNotifyLogic.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index 7b568c8a2..7d626adc1 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -425,6 +425,13 @@ class PayNotifyLogic extends BaseLogic $orderRe->refund_time = time(); $orderRe->remarks = ''; $orderRe->save(); + $purchase_funds = User::where('id',$orderRe['uid'])->value('purchase_funds'); + if($purchase_funds >= $orderRe['price']){ + User::where('id',$orderRe['uid'])->dec('purchase_funds',$orderRe['price'])->update(); + }else{ + User::where('id',$orderRe['uid'])->dec('purchase_funds',$purchase_funds)->update(); + } + self::descUserSing($orderRe); return true; } From 51df5a3a94e81a054a7556aa45f7004863d0a78b Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Fri, 28 Jun 2024 18:38:14 +0800 Subject: [PATCH 28/33] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9=E4=BA=86?= =?UTF-8?q?=E8=AE=A2=E5=8D=95=E6=A0=B8=E9=94=80=E9=80=BB=E8=BE=91=E5=92=8C?= =?UTF-8?q?=E6=94=AF=E4=BB=98=E9=80=9A=E7=9F=A5=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/logic/order/OrderLogic.php | 73 ++----------------- app/common/logic/PayNotifyLogic copy.php | 2 +- app/common/logic/StoreFinanceFlowLogic.php | 61 +++++++++------- .../store_order/StoreOrderController.php | 4 +- 4 files changed, 42 insertions(+), 98 deletions(-) diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index f67932394..2393ae4d6 100644 --- a/app/api/logic/order/OrderLogic.php +++ b/app/api/logic/order/OrderLogic.php @@ -432,17 +432,14 @@ class OrderLogic extends BaseLogic 'staff_id' => $params['staff_id']??0, 'update_time' => time(), ], ['oid' => $order['id']]); - // $financeFlow = (new StoreFinanceFlowLogic)->getStoreOrder($data['id'], $data['store_id']); - // if (!empty($financeFlow)) { - // $capitalFlowLogic = new CapitalFlowLogic($data->store, 'store'); - // $capitalFlowLogic->storeIncome('store_order_income', 'order', $data['id'], $financeFlow['number']); - // } PayNotifyLogic::descStock($order['id']); $financeFlow=new StoreFinanceFlow(); $financeFlowLogic=new StoreFinanceFlowLogic(); - $select_1=$financeFlow->where(['order_id'=>$order['id'],'financial_pm'=>1,'financial_type'=>['in'=>14,15],'other_uid'=>['>'=>0]])->select(); + $select_1=$financeFlow->where(['order_id'=>$order['id'],'financial_pm'=>1,'financial_type'=>['in'=>14,15,16]])->select(); foreach($select_1 as $k=>$v){ - $financeFlowLogic->updateStatusUser($v['id'],$v['other_uid'],$v['number'],$v['order_id']); + if($v['other_uid']>0){ + $financeFlowLogic->updateStatusUser($v['id'],$v['other_uid'],$v['number'],$v['order_id']); + } } if($order['uid'] && $order['pay_price'] >= 500){ $user_number = bcmul($order['pay_price'], '0.10', 2); @@ -455,67 +452,9 @@ class OrderLogic extends BaseLogic $financeFlowLogic->updateStatusUser($spread_find['id'],$order['spread_uid'],$spread_find['number'],$order['order_id']); } } - $deposit=$financeFlow->where(['order_id'=>$order['id'],'financial_pm'=>1,'financial_type'=>11])->value('number'); - $money=$financeFlow->where(['order_id'=>$order['id'],'financial_pm'=>1,'financial_type'=>2])->value('number'); + $deposit=$financeFlow->where(['order_id'=>$order['id'],'financial_pm'=>1,'financial_type'=>11])->value('number')??0; + $money=$financeFlow->where(['order_id'=>$order['id'],'financial_pm'=>1,'financial_type'=>2])->value('number')??0; $financeFlowLogic->updateStatusStore($order['id'],$order['store_id'],$money,$deposit); - - /* $check = Db::name('user_sign_log')->where('order_id',$order['order_id']) - ->where(['status'=>0]) - ->find();//$check['number']扣的 - if($check){ -// User::where('id',$order['uid'])->inc('purchase_funds',$check['number'])->update(); -// $user_number = bcmul($order['pay_price'], '0.10', 2); - - $base = UserSign::where([ - 'uid'=>$order['uid'], - 'type'=>1, - 'status'=>1 - ])->find(); - $user_sing = new UserSign(); - if($base['number'] > 0 && $base['number'] >= $check['number']){ - $sing = [ - 'uid' => $order['uid'], - 'order_id' => $order['order_id'].'-b', - 'title' => '返还兑换券', - 'financial_pm' => 1, - 'store_id' => $order['store_id'], - 'status' => 1, - ]; - $sing['number'] = $check['number']; - $user_sing->save($sing); - User::where('id',$order['uid'])->inc('integral',$check['number'])->update(); - //减少 - UserSign::where('id',$check['sid'])->dec('number',$check['number'])->update(); - if($base['number'] == $check['number']){ - UserSign::where([ - 'id'=>$order['sid'] - ])->update(['status'=>1]); - } - } - if($base['number'] < $check['number']){ - $sing = [ - 'uid' => $order['uid'], - 'order_id' => $order['order_id'].'-b', - 'title' => '返还兑换券', - 'financial_pm' => 1, - 'store_id' => $order['store_id'], - 'status' => 1, - ]; - $sing['number'] = $base['number']; - $user_sing->save($sing); - - UserSign::where('id',$check['sid'])->dec('number',$base['number'])->update(); - User::where('id',$order['uid'])->inc('integral',$base['number'])->update(); - - - UserSign::where([ - 'id'=>$order['sid'] - ])->update(['status'=>1]); - } - - Db::name('user_sign_log')->where('order_id',$order['order_id'])->update(['status'=>1]); - }*/ - Db::commit(); return true; } catch (\Exception $e) { diff --git a/app/common/logic/PayNotifyLogic copy.php b/app/common/logic/PayNotifyLogic copy.php index a03f8fd3e..3f641cfbc 100644 --- a/app/common/logic/PayNotifyLogic copy.php +++ b/app/common/logic/PayNotifyLogic copy.php @@ -36,7 +36,7 @@ use Webman\RedisQueue\Redis; * Class PayNotifyLogic * @package app\api\logic */ -class PayNotifyLogic extends BaseLogic +class PayNotifyLogicaaa extends BaseLogic { public static function handle($action, $orderSn, $extra = [], $type = 'wechat') diff --git a/app/common/logic/StoreFinanceFlowLogic.php b/app/common/logic/StoreFinanceFlowLogic.php index 534ce5091..3d63b48d5 100644 --- a/app/common/logic/StoreFinanceFlowLogic.php +++ b/app/common/logic/StoreFinanceFlowLogic.php @@ -27,9 +27,9 @@ class StoreFinanceFlowLogic extends BaseLogic * @param $staffId * @param $status */ - public function out($transaction_id,$number, $financialType, $storeId = 0, $staffId = 0, $status = 1,$pay_type=7) + public function out($transaction_id, $number, $financialType, $storeId = 0, $staffId = 0, $status = 1, $pay_type = 7) { - $this->setData($number, $financialType, 0, $storeId, $staffId, $status,$transaction_id,$pay_type); + $this->setData($number, $financialType, 0, $storeId, $staffId, $status, $transaction_id, $pay_type); } /** @@ -41,22 +41,22 @@ class StoreFinanceFlowLogic extends BaseLogic * @param $staffId * @param $status */ - public function in($transaction_id,$number, $financialType, $storeId = 0, $staffId = 0, $status = 1,$pay_type=7) + public function in($transaction_id, $number, $financialType, $storeId = 0, $staffId = 0, $status = 1, $pay_type = 7) { - $this->setData($number, $financialType, 1, $storeId, $staffId, $status,$transaction_id,$pay_type); + $this->setData($number, $financialType, 1, $storeId, $staffId, $status, $transaction_id, $pay_type); } - public function setData($number, $financialType, $pm, $storeId, $staffId, $status,$transaction_id,$pay_type=7) + public function setData($number, $financialType, $pm, $storeId, $staffId, $status, $transaction_id, $pay_type = 7) { if (empty($this->financeSn)) { $this->financeSn = $this->getSn(); } - $data=[ + $data = [ 'order_id' => $this->order['id'], 'transaction_id' => $transaction_id, 'order_sn' => $this->order['order_id'], - 'user_id' => $this->user['uid']??0, - 'other_uid' => $this->other_arr['vip_uid']??0, + 'user_id' => $this->user['uid'] ?? 0, + 'other_uid' => $this->other_arr['vip_uid'] ?? 0, 'financial_type' => $financialType, 'financial_pm' => $pm, 'number' => $number, @@ -65,22 +65,22 @@ class StoreFinanceFlowLogic extends BaseLogic 'store_id' => $storeId !== '' ? $storeId : $this->order['store_id'], 'staff_id' => $staffId !== '' ? $staffId : $this->order['staff_id'], 'financial_record_sn' => $this->financeSn . ($this->index++), - 'create_time'=>time() + 'create_time' => time() ]; - switch($financialType){ + switch ($financialType) { case OrderEnum::MERCHANT_ORDER_OBTAINS: // 商户 case OrderEnum::ORDER_MARGIN: // 商户保证金 - $data['type'] =OrderEnum::MERCHANT; + $data['type'] = OrderEnum::MERCHANT; break; case OrderEnum::PLATFORM_ORDER_OBTAINS: // 平台 case OrderEnum::ORDER_HANDLING_FEES: // 手续费 - $data['type'] =OrderEnum::PLATFORM; + $data['type'] = OrderEnum::PLATFORM; break; - case OrderEnum::SUPPLIER_ORDER_OBTAINS: // 供应链 - $data['type'] =OrderEnum::SUPPLIER; + case OrderEnum::SUPPLIER_ORDER_OBTAINS: // 供应链 + $data['type'] = OrderEnum::SUPPLIER; break; default: // 用户 - $data['type'] =OrderEnum::USER; + $data['type'] = OrderEnum::USER; break; } $this->list[] = $data; @@ -131,30 +131,35 @@ class StoreFinanceFlowLogic extends BaseLogic /** * 核销后更新用户余额 */ - public function updateStatusUser($id,$uid,$money,$order_id){ + public function updateStatusUser($id, $uid, $money, $order_id) + { StoreFinanceFlow::where('id', $id)->update(['status' => 1]); - $find=User::where('id',$uid)->find(); + $find = User::where('id', $uid)->find(); $capitalFlowDao = new CapitalFlowLogic($find); $capitalFlowDao->userIncome('system_balance_add', 'order', $order_id, $money); - $find->inc('now_money',$money)->update(); + $find->inc('now_money', $money)->update(); } /** * 核销后更新门店余额 */ - public function updateStatusStore($order_id,$store_id,$money,$deposit){ - StoreFinanceFlow::where(['order_id'=>$order_id,'financial_pm'=>1,'financial_type'=>11])->update(['status' => 1]); - StoreFinanceFlow::where(['order_id'=>$order_id,'financial_pm'=>1,'financial_type'=>2])->update(['status' => 1]); - if($money){ + public function updateStatusStore($order_id, $store_id, $money, $deposit) + { + StoreFinanceFlow::where(['order_id' => $order_id, 'financial_pm' => 1, 'financial_type' => 11])->update(['status' => 1]); + StoreFinanceFlow::where(['order_id' => $order_id, 'financial_pm' => 1, 'financial_type' => 2])->update(['status' => 1]); + if ($money>0) { SystemStore::where('id', $store_id)->inc('store_money', $money)->update(); } - if($deposit){ + if ($deposit>0) { SystemStore::where('id', $store_id)->inc('paid_deposit', $deposit)->update(); } - $find=StoreFinanceFlow::where(['order_id'=>$order_id,'financial_pm'=>1,'financial_type'=>16])->find(); - if($find){ - $find->update(['status' => 1]); - SystemStore::where('id', $store_id)->inc('attrition', $find['number'])->update(); + + $find = StoreFinanceFlow::where(['order_id' => $order_id, 'financial_pm' => 1, 'financial_type' => 16])->find(); + if ($find) { + $find->status=1; + $find->save(); + if ($find['number'] > 0) { // 核销后更新库存 + SystemStore::where('id', $store_id)->inc('attrition', $find['number'])->update(); + } } } - } diff --git a/app/store/controller/store_order/StoreOrderController.php b/app/store/controller/store_order/StoreOrderController.php index 6527e6e78..e1ea16893 100644 --- a/app/store/controller/store_order/StoreOrderController.php +++ b/app/store/controller/store_order/StoreOrderController.php @@ -310,8 +310,8 @@ class StoreOrderController extends BaseAdminController public function writeoff_order() { $params = (new OrderValidate())->post()->goCheck('check'); - $count = StoreOrder::where('verify_code', $params['verify_code'])->count(); - if (empty($count)) { + $count = StoreOrder::where('verify_code', $params['verify_code'])->find(); + if (!$count) { return $this->fail('无该核销码请检查'); } $params['store_id'] = $this->adminInfo['store_id']; From 944480df4c76d42b9b083d04d3042b21db649c42 Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Fri, 28 Jun 2024 18:42:29 +0800 Subject: [PATCH 29/33] =?UTF-8?q?=E6=97=A5=E5=BF=97=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/logic/CapitalFlowLogic.php | 2 +- app/common/logic/PayNotifyLogic.php | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/common/logic/CapitalFlowLogic.php b/app/common/logic/CapitalFlowLogic.php index 361ee124c..a49be021e 100644 --- a/app/common/logic/CapitalFlowLogic.php +++ b/app/common/logic/CapitalFlowLogic.php @@ -40,7 +40,7 @@ class CapitalFlowLogic extends BaseLogic $model->amount = $amount; if($type){ $model->before_balance = $this->user['purchase_funds']; - $model->balance = bcsub($this->user['purchase_funds'], $amount, 2); + $model->balance = bcadd($this->user['purchase_funds'], $amount, 2); }else{ $model->before_balance = $this->user['now_money']; $model->balance = bcadd($this->user['now_money'], $amount, 2); diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index 7d626adc1..8e82076eb 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -426,12 +426,15 @@ class PayNotifyLogic extends BaseLogic $orderRe->remarks = ''; $orderRe->save(); $purchase_funds = User::where('id',$orderRe['uid'])->value('purchase_funds'); + $user = User::where('id',$orderRe['uid'])->find(); + $capitalFlowDao = new CapitalFlowLogic($user); if($purchase_funds >= $orderRe['price']){ User::where('id',$orderRe['uid'])->dec('purchase_funds',$orderRe['price'])->update(); + $capitalFlowDao->userExpense('user_order_purchase_pay', 'order', $orderRe['id'], $orderRe['pay_price'], '', 1, $orderRe['store_id']); }else{ User::where('id',$orderRe['uid'])->dec('purchase_funds',$purchase_funds)->update(); + $capitalFlowDao->userExpense('user_order_purchase_pay', 'order', $orderRe['id'], $purchase_funds, '', 1, $orderRe['store_id']); } - self::descUserSing($orderRe); return true; } From cdeeaaf71760efa274b2841fb8097b159e535b35 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Fri, 28 Jun 2024 18:45:55 +0800 Subject: [PATCH 30/33] =?UTF-8?q?feat:=20=E6=9B=B4=E6=96=B0=E5=BA=93?= =?UTF-8?q?=E5=AD=98=E9=80=BB=E8=BE=91=E6=A0=B8=E9=94=80=E5=90=8E=E7=8A=B6?= =?UTF-8?q?=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/logic/StoreFinanceFlowLogic.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/common/logic/StoreFinanceFlowLogic.php b/app/common/logic/StoreFinanceFlowLogic.php index 3d63b48d5..64df3e322 100644 --- a/app/common/logic/StoreFinanceFlowLogic.php +++ b/app/common/logic/StoreFinanceFlowLogic.php @@ -157,7 +157,7 @@ class StoreFinanceFlowLogic extends BaseLogic if ($find) { $find->status=1; $find->save(); - if ($find['number'] > 0) { // 核销后更新库存 + if ($find['number'] > 0) { SystemStore::where('id', $store_id)->inc('attrition', $find['number'])->update(); } } From aeff0c9d549b75f5ea7c4fa0e50b3bb68ecdbc53 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Fri, 28 Jun 2024 18:52:55 +0800 Subject: [PATCH 31/33] =?UTF-8?q?feat:=20=E6=9B=B4=E6=96=B0=E4=BA=86?= =?UTF-8?q?=E5=95=86=E5=BA=97=E8=B4=A2=E5=8A=A1=E6=B5=81=E6=B0=B4=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E6=9B=B4=E6=96=B0=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/logic/StoreFinanceFlowLogic.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/app/common/logic/StoreFinanceFlowLogic.php b/app/common/logic/StoreFinanceFlowLogic.php index 64df3e322..44b3e75ed 100644 --- a/app/common/logic/StoreFinanceFlowLogic.php +++ b/app/common/logic/StoreFinanceFlowLogic.php @@ -144,19 +144,17 @@ class StoreFinanceFlowLogic extends BaseLogic */ public function updateStatusStore($order_id, $store_id, $money, $deposit) { - StoreFinanceFlow::where(['order_id' => $order_id, 'financial_pm' => 1, 'financial_type' => 11])->update(['status' => 1]); - StoreFinanceFlow::where(['order_id' => $order_id, 'financial_pm' => 1, 'financial_type' => 2])->update(['status' => 1]); + StoreFinanceFlow::where(['order_id' => $order_id,'financial_type' => 11])->update(['status' => 1]); + StoreFinanceFlow::where(['order_id' => $order_id,'financial_type' => 2])->update(['status' => 1]); if ($money>0) { SystemStore::where('id', $store_id)->inc('store_money', $money)->update(); } if ($deposit>0) { SystemStore::where('id', $store_id)->inc('paid_deposit', $deposit)->update(); } - - $find = StoreFinanceFlow::where(['order_id' => $order_id, 'financial_pm' => 1, 'financial_type' => 16])->find(); + $find = StoreFinanceFlow::where(['order_id' => $order_id, 'financial_pm' => 1, 'financial_type' => 16,'status'=>0])->find(); + StoreFinanceFlow::where(['order_id' => $order_id,'financial_type' => 16])->update(['status' => 1]); if ($find) { - $find->status=1; - $find->save(); if ($find['number'] > 0) { SystemStore::where('id', $store_id)->inc('attrition', $find['number'])->update(); } From 1096901067638f3a8d3633f42ef2f982e7864d30 Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Fri, 28 Jun 2024 19:08:52 +0800 Subject: [PATCH 32/33] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=9B=9E=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/PayController.php | 2 +- app/common/logic/PayNotifyLogic.php | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/api/controller/PayController.php b/app/api/controller/PayController.php index 37bd0d970..df0eb1020 100644 --- a/app/api/controller/PayController.php +++ b/app/api/controller/PayController.php @@ -47,7 +47,7 @@ class PayController extends BaseApiController } else { if ($result && $result->event_type == 'REFUND.SUCCESS') { $ciphertext = $result->resource['ciphertext']; - Cache::set('6logC'.time(),json_encode($ciphertext)); + Cache::set('7logC'.time(),json_encode($ciphertext)); if ($ciphertext['refund_status'] === 'SUCCESS') { //处理订单 -1判断是退的一单还是拆分的订单 $out_trade_no = $ciphertext['out_trade_no'] . '-1'; diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index 8e82076eb..2f526d1de 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -429,13 +429,14 @@ class PayNotifyLogic extends BaseLogic $user = User::where('id',$orderRe['uid'])->find(); $capitalFlowDao = new CapitalFlowLogic($user); if($purchase_funds >= $orderRe['price']){ - User::where('id',$orderRe['uid'])->dec('purchase_funds',$orderRe['price'])->update(); - $capitalFlowDao->userExpense('user_order_purchase_pay', 'order', $orderRe['id'], $orderRe['pay_price'], '', 1, $orderRe['store_id']); + User::where('id',$orderRe['uid'])->dec('purchase_funds',$orderRe['refund_price'])->update(); + $capitalFlowDao->userExpense('user_order_purchase_pay', 'order', $orderRe['id'], $orderRe['refund_price'], '', 1, $orderRe['store_id']); }else{ User::where('id',$orderRe['uid'])->dec('purchase_funds',$purchase_funds)->update(); $capitalFlowDao->userExpense('user_order_purchase_pay', 'order', $orderRe['id'], $purchase_funds, '', 1, $orderRe['store_id']); } self::descUserSing($orderRe); +// d($purchase_funds,$orderRe['refund_price'],$orderRe); return true; } $order->status = OrderEnum::REFUND_PAY; From 919229c8dc1becd4f7c707339cdd8cc1339a61f9 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Fri, 28 Jun 2024 19:10:56 +0800 Subject: [PATCH 33/33] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9=E6=A0=B8?= =?UTF-8?q?=E9=94=80=E7=A0=81=E6=9F=A5=E8=AF=A2=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/store/controller/store_order/StoreOrderController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/store/controller/store_order/StoreOrderController.php b/app/store/controller/store_order/StoreOrderController.php index e1ea16893..cbba40a69 100644 --- a/app/store/controller/store_order/StoreOrderController.php +++ b/app/store/controller/store_order/StoreOrderController.php @@ -310,7 +310,7 @@ class StoreOrderController extends BaseAdminController public function writeoff_order() { $params = (new OrderValidate())->post()->goCheck('check'); - $count = StoreOrder::where('verify_code', $params['verify_code'])->find(); + $count = StoreOrder::where('verify_code', $params['verify_code'])->whereIn('status',[0,1])->where('refund_status',0)->find(); if (!$count) { return $this->fail('无该核销码请检查'); }