From 090955158fe3d080ae3c32d6f01be7d3b38244e3 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Sat, 29 Jun 2024 10:19:08 +0800 Subject: [PATCH 001/115] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=88=86=E6=B6=A6?= =?UTF-8?q?=E9=80=BB=E8=BE=91=E4=B8=8E=E8=B4=A2=E5=8A=A1=E6=B5=81=E6=B0=B4?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../UserProductStorageLists.php | 2 +- app/common/logic/CommissionLogic.php | 104 ++++++++++-------- app/common/logic/PayNotifyLogic.php | 29 +---- app/common/logic/StoreFinanceFlowLogic.php | 56 +++++++++- 4 files changed, 115 insertions(+), 76 deletions(-) diff --git a/app/admin/lists/user_product_storage/UserProductStorageLists.php b/app/admin/lists/user_product_storage/UserProductStorageLists.php index e7efd4b25..6a0cb49a1 100644 --- a/app/admin/lists/user_product_storage/UserProductStorageLists.php +++ b/app/admin/lists/user_product_storage/UserProductStorageLists.php @@ -29,7 +29,7 @@ class UserProductStorageLists extends BaseAdminDataLists implements ListsSearchI { return [ '=' => ['uid', 'oid', 'product_id'], - 'between_time' => ['create_time'], + 'between_time' => 'create_time', ]; } diff --git a/app/common/logic/CommissionLogic.php b/app/common/logic/CommissionLogic.php index 7777efc1b..ce89bd771 100644 --- a/app/common/logic/CommissionLogic.php +++ b/app/common/logic/CommissionLogic.php @@ -12,63 +12,62 @@ class CommissionLogic extends BaseLogic /** * 走村长分润 */ - public static function setVillage($order,$village_uid=0,$brigade_uid=0, $transaction_id=0) + public static function setVillage($order, $village_uid = 0, $brigade_uid = 0, $transaction_id = 0) { - $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);//队长 + $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);//其他 + $platform = self::platform($order, 0.02, $transaction_id); //平台 + $store = self::store($order, 0.05, $transaction_id, 0); //门店 + $attrition = self::attrition($order, 0.02,$transaction_id,16); //损耗 - $moeny=bcadd(bcadd(bcadd(bcadd($user_1,$user_2,2),$user_3,2),$platform,2),bcadd($store,$user_4,2),2); + $moeny = bcadd(bcadd(bcadd(bcadd($user_1, $user_2, 2), $user_3, 2), $platform, 2), bcadd($store, $attrition, 2), 2); self::suppliter($order, $moeny, $transaction_id); } /** * 走队长分润 */ - public static function setBrigade($order,$village_uid=0,$brigade_uid=0, $transaction_id=0) + public static function setBrigade($order, $village_uid = 0, $brigade_uid = 0, $transaction_id = 0) { - $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);//村长 + $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);//其他 + $platform = self::platform($order, 0.02, $transaction_id); //平台 + $store = self::store($order, 0.05, $transaction_id, 0); //门店 + $attrition = self::attrition($order, 0.02,$transaction_id,16); //损耗 - $moeny=bcadd(bcadd(bcadd(bcadd($user_1,$user_2,2),$user_3,2),$platform,2),bcadd($store,$user_4,2),2); + $moeny = bcadd(bcadd(bcadd(bcadd($user_1, $user_2, 2), $user_3, 2), $platform, 2), bcadd($store, $attrition, 2), 2); self::suppliter($order, $moeny, $transaction_id); } /** * 走厨师分润 */ - public static function setCook($order,$village_uid=0,$brigade_uid=0, $transaction_id=0) + public static function setCook($order, $village_uid = 0, $brigade_uid = 0, $transaction_id = 0) { - $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);//队长 + $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);//其他 + $platform = self::platform($order, 0.02, $transaction_id); //平台 + $store = self::store($order, 0.05, $transaction_id, 0); //门店 + $attrition = self::attrition($order, 0.02,$transaction_id,16); //损耗 - $moeny=bcadd(bcadd(bcadd(bcadd($user_1,$user_2,2),$user_3,2),$platform,2),bcadd($store,$user_4,2),2); + $moeny = bcadd(bcadd(bcadd(bcadd($user_1, $user_2, 2), $user_3, 2), $platform, 2), bcadd($store, $attrition, 2), 2); self::suppliter($order, $moeny, $transaction_id); } /** * 走线下分润 */ - public static function setStore($order, $transaction_id=0) + public static function setStore($order, $transaction_id = 0) { - $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); - + $platform = self::platform($order, 0.05, $transaction_id); //平台 + $store = self::store($order, 0.02, $transaction_id, 0); //门店 + $attrition = self::attrition($order, 0.01,$transaction_id,16); //损耗 + $moeny = bcadd(bcadd($platform, $store, 2), $attrition, 2); + self::suppliter($order, $moeny, $transaction_id); } @@ -78,8 +77,8 @@ class CommissionLogic extends BaseLogic public static function platform($order, $platformRate, $transaction_id) { $financeLogic = new StoreFinanceFlowLogic(); - $financeLogic->order=$order; - $financeLogic->user['uid']=$order['uid']; + $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']); //平台手续费 @@ -94,9 +93,9 @@ class CommissionLogic extends BaseLogic 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); + $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']); @@ -106,12 +105,12 @@ class CommissionLogic extends BaseLogic /** * 门店分润 */ - public static function store($order, $platformRate, $transaction_id,$uid) + public static function store($order, $platformRate, $transaction_id, $uid) { $financeLogic = new StoreFinanceFlowLogic(); - $financeLogic->user['uid']=$order['uid']; - $financeLogic->other_arr['vip_uid']=$uid; - $financeLogic->order=$order; + $financeLogic->user['uid'] = $order['uid']; + $financeLogic->other_arr['vip_uid'] = $uid; + $financeLogic->order = $order; $financeLogic->in($transaction_id, $order['pay_price'], OrderEnum::USER_ORDER_PAY, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); //用户订单支付 //缴纳齐全了就加商户没有就加到平台 @@ -149,7 +148,7 @@ class CommissionLogic extends BaseLogic /** * 分给用户 */ - public static function user($order, $userRate, $transaction_id,$uid=0,$enum = 0) + public static function user($order, $userRate, $transaction_id, $uid = 0, $enum = 0) { $financeLogic = new StoreFinanceFlowLogic(); $fees = bcmul($order['pay_price'], $userRate, 2); @@ -160,13 +159,30 @@ class CommissionLogic extends BaseLogic $capitalFlowDao = new CapitalFlowLogic($GiveUser); $capitalFlowDao->userIncome('system_balance_add', 'order', $order['id'], $fees); } - $financeLogic->user['uid']=$order['uid']; - $financeLogic->other_arr['vip_uid']=$uid; - $financeLogic->order=$order; + $financeLogic->user['uid'] = $order['uid']; + $financeLogic->other_arr['vip_uid'] = $uid; + $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; } + + /** + * 损耗金 + */ + public static function attrition($order, $userRate, $transaction_id, $enum) + { + $financeLogic = new StoreFinanceFlowLogic(); + $financeLogic->order = $order; + $financeLogic->user['uid'] = $order['uid']; + $fees = bcmul($order['pay_price'], $userRate, 2); + if ($fees > 0) { + SystemStore::where('id', $order['store_id'])->inc('attrition', $fees)->update(); + $financeLogic->in($transaction_id, $fees, $enum, $order['store_id'], $order['staff_id'], 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 2f526d1de..5746101c0 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -452,7 +452,7 @@ class PayNotifyLogic extends BaseLogic $deal_money = bcdiv($extra['amount']['refund'], 100, 2); $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) { //用户余额 + if ($order['pay_type'] == PayEnum::BALANCE_PAY) { //用户余额支付 $user->now_money = bcadd($user->now_money, $deal_money, 2); $user->save(); //增加数量 @@ -460,7 +460,7 @@ class PayNotifyLogic extends BaseLogic //退款 $capitalFlowDao->userIncome('system_balance_back', 'system_back', $order['id'], $deal_money); } - if ($order['pay_type'] == PayEnum::PURCHASE_FUNDS) { //采购款 + if ($order['pay_type'] == PayEnum::PURCHASE_FUNDS) { //采购款支付 $user->purchase_funds = bcadd($user->purchase_funds, $deal_money, 2); $user->save(); //增加数量 @@ -480,7 +480,7 @@ class PayNotifyLogic extends BaseLogic //微信日志 user_order_refund $capitalFlowDao->userIncome('user_order_refund', 'system_back', $order['id'], $deal_money, '', 1); //处理财务流水退还 - self::store_finance_back($orderSn); + (new StoreFinanceFlowLogic())->store_finance_back($orderSn); self::addStock($order['id']); //微信 return true; // self::afterPay($order,$extra['transaction_id']); @@ -521,28 +521,7 @@ class PayNotifyLogic extends BaseLogic - /** - * 财务退还金额相关 - * @param $orderSn - * @return void - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException - */ - public static function store_finance_back($orderSn) - { - $data = StoreFinanceFlow::where('order_sn', $orderSn) - ->where(['financial_pm' => 1]) - ->select()->toArray(); - foreach ($data as &$value) { - unset($value['id']); - $value['financial_record_sn'] = (new StoreFinanceFlowLogic)->getSn(); - $value['financial_pm'] = 0; - $value['financial_type'] = OrderEnum::PAY_BACK; - $value['create_time'] = time(); - } - (new StoreFinanceFlow)->saveAll($data); - } + /** * 现金退款相关 diff --git a/app/common/logic/StoreFinanceFlowLogic.php b/app/common/logic/StoreFinanceFlowLogic.php index 44b3e75ed..0f06287a7 100644 --- a/app/common/logic/StoreFinanceFlowLogic.php +++ b/app/common/logic/StoreFinanceFlowLogic.php @@ -70,6 +70,7 @@ class StoreFinanceFlowLogic extends BaseLogic switch ($financialType) { case OrderEnum::MERCHANT_ORDER_OBTAINS: // 商户 case OrderEnum::ORDER_MARGIN: // 商户保证金 + case OrderEnum::OTHER_ORDER_OBTAINS: // 损耗 $data['type'] = OrderEnum::MERCHANT; break; case OrderEnum::PLATFORM_ORDER_OBTAINS: // 平台 @@ -144,20 +145,63 @@ class StoreFinanceFlowLogic extends BaseLogic */ public function updateStatusStore($order_id, $store_id, $money, $deposit) { - 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) { + 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) { + 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,'status'=>0])->find(); - StoreFinanceFlow::where(['order_id' => $order_id,'financial_type' => 16])->update(['status' => 1]); + $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) { if ($find['number'] > 0) { SystemStore::where('id', $store_id)->inc('attrition', $find['number'])->update(); } } } + + /** + * 财务退还金额相关 + * @param $orderSn + * @return void + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + */ + public function store_finance_back($orderSn) + { + $data = StoreFinanceFlow::where('order_sn', $orderSn) + ->where(['financial_pm' => 1]) + ->select()->toArray(); + foreach ($data as &$value) { + unset($value['id']); + $value['financial_record_sn'] = (new StoreFinanceFlowLogic)->getSn(); + $value['financial_pm'] = 0; + $value['financial_type'] = OrderEnum::PAY_BACK; + $value['create_time'] = time(); + if ($value['status'] == 1) { + switch ($value['type']) { + case 0: + $user = User::where('id', $value['other_uid'])->findOrEmpty(); + $capitalFlowDao = new CapitalFlowLogic($user); + $capitalFlowDao->userExpense('system_now_money_back', 'system_back', $value['order_id'], $value['number']); + break; + case 1: + if ($value['number'] > 0 &&$value['financial_type']==2) { + SystemStore::where('id', $value['store_id'])->dec('store_money',$value['number'])->update(); + } + if ($value['number'] > 0 &&$value['financial_type']==11) { + SystemStore::where('id', $value['store_id'])->dec('paid_deposit',$value['number'])->update(); + } + if ($value['number'] > 0 &&$value['financial_type']==16) { + SystemStore::where('id', $value['store_id'])->dec('attrition',$value['number'])->update(); + } + break; + } + } + } + (new StoreFinanceFlow)->saveAll($data); + } } From 26f47a0a43b52208b63aab5239dc26bb70af8f76 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Sat, 29 Jun 2024 11:41:26 +0800 Subject: [PATCH 002/115] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E6=8D=9F=E8=80=97?= =?UTF-8?q?=E6=B3=A8=E9=87=8A=EF=BC=8C=E5=88=A0=E9=99=A4BackController?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/BackController.php | 138 --------------------- app/common/logic/BackLogic.php | 120 ++++++++++++++++++ app/common/logic/StoreFinanceFlowLogic.php | 2 +- 3 files changed, 121 insertions(+), 139 deletions(-) delete mode 100644 app/api/controller/BackController.php create mode 100644 app/common/logic/BackLogic.php diff --git a/app/api/controller/BackController.php b/app/api/controller/BackController.php deleted file mode 100644 index 50860985d..000000000 --- a/app/api/controller/BackController.php +++ /dev/null @@ -1,138 +0,0 @@ -=', $startTime) - ->where('create_time', '<', $endTime) - ->group('user_id, pay_type') - ->field('user_id, pay_type, COUNT(*) as transaction_count, SUM(number) as total_amount') - ->select()->toArray(); - - // 遍历查询结果并分类 现金不进入反的逻辑 - //3余额 18采购款 7微信小程序 9微信条码 13 支付宝条码支付 - $Balance = []; - $Procurement = []; - $WechatMiniPay = []; - $WechatBarcodePay = []; - $AliBarcodePay = []; - foreach ($result as $row) { - $payType = $row['pay_type']; - $userId = $row['user_id']; - $totalAmount = $row['total_amount']; - switch ($payType) { - case 3: - $user_now_money = User::where( - [ - 'id' => $userId - ] - )->withTrashed()->value('now_money'); - $Balance[] = [ - 'id' => $userId, - 'now_money' => bcadd($user_now_money, $totalAmount, 2), - ]; - break; - case 7: - $WechatMiniPay[] = [ - 'id' => $userId, - 'total_amount' => $totalAmount, - ]; - break; - case 9: - $WechatBarcodePay[] = [ - 'id' => $userId, - 'total_amount' => $totalAmount, - ]; - break; - case 13: - $AliBarcodePay[] = [ - 'id' => $userId, - 'total_amount' => $totalAmount, - ]; - break; - case 18: - $purchase_funds_money = User::where( - [ - 'id' => $userId - ] - )->withTrashed()->value('purchase_funds'); - $Procurement[] = [ - 'id' => $userId, - 'purchase_funds' => bcadd($purchase_funds_money, $totalAmount, 2), - ]; - break; - } - - } - //入记录表的话查询后便利入 3余额 18采购款 - if ($Balance) { - (new User())->saveAll($Balance); - $this->dealCapital($startTime, $endTime, 3); - } - if ($Procurement) { - (new User())->saveAll($Procurement); - $this->dealCapital($startTime, $endTime, 18); - } - //7微信小程序 9微信条码 13 支付宝条码支付 - - - } - - public function dealCapital($startTime, $endTime, $pay_type) - { - $vipFrozen = VipFlow::where('create_time', '>=', $startTime) - ->where('create_time', '<', $endTime) - ->where('pay_type', $pay_type)->select()->toArray(); - if ($pay_type == 18) { - $category_title = 'system_purchase_add'; - $title = '系统增加采购款'; - $mark = '系统增加采购款'; - $filed = 'purchase_funds'; - } else { - $category_title = 'system_balance_add'; - $title = '系统增加余额'; - $mark = '系统反余额冻结'; - $filed = 'now_money'; - } - - $newArr = []; - foreach ($vipFrozen as $k => $value) { - $user_funds = User::where('id', $value['user_id'])->value($filed); - $newArr[$k]['uid'] = $value['user_id']; - $newArr[$k]['category'] = $category_title; - $newArr[$k]['link_type'] = 'order'; - $newArr[$k]['link_id'] = $value['order_id']; - $newArr[$k]['amount'] = $value['number']; - $newArr[$k]['before_balance'] = $user_funds; - $newArr[$k]['balance'] = bcadd($user_funds, $value['number'], 2); - $newArr[$k]['create_time'] = date('Y-m-d H:i:s'); - $newArr[$k]['type'] = 'in'; - $newArr[$k]['title'] = $title . "{$value['number']}元"; - $newArr[$k]['mark'] = $mark; - } - (new CapitalFlow())->saveAll($newArr); - - } - - -} \ No newline at end of file diff --git a/app/common/logic/BackLogic.php b/app/common/logic/BackLogic.php new file mode 100644 index 000000000..1187b28d2 --- /dev/null +++ b/app/common/logic/BackLogic.php @@ -0,0 +1,120 @@ +=', $startTime) + ->where('create_time', '<', $endTime) + ->where('status', 0) + ->where('type', 0) + ->select(); + //3余额 18采购款 7微信小程序 9微信条码 13 支付宝条码支付 + foreach ($result as $row) { + switch ($row['pay_type']) { + case 3: + case 18: + $this->dealCapital($row['pay_type'],$row); + break; + case 7: + case 9: + $this->wechat_refund($row['pay_type'],$row); + break; + case 13: + $this->ali_pay_refund($row['pay_type'],$row); + break; + } + } + //7微信小程序 9微信条码 13 支付宝条码支付 + + + } + + public function dealCapital($pay_type, $order) + { + + $user = User::where('id', $order['user_id'])->find(); + if ($pay_type == 18) { + $category_title = 'system_purchase_add'; + $title = '系统增加采购款'; + $mark = '系统增加采购款'; + $filed = 'purchase_funds'; + $user->purchase_funds = bcadd($user['purchase_funds'], $order['number'], 2); + } else { + $category_title = 'system_balance_add'; + $title = '系统增加余额'; + $mark = '系统反余额冻结'; + $filed = 'now_money'; + $user->now_money = bcadd($user['now_money'], $order['number'], 2); + } + $user->save(); + $newArr['uid'] = $order['user_id']; + $newArr['category'] = $category_title; + $newArr['link_type'] = 'order'; + $newArr['link_id'] = $order['order_id']; + $newArr['amount'] = $order['number']; + $newArr['before_balance'] = $user[$filed]; + $newArr['balance'] = bcadd($user[$filed], $order['number'], 2); + $newArr['create_time'] = date('Y-m-d H:i:s'); + $newArr['type'] = 'in'; + $newArr['title'] = $title . "{$order['number']}元"; + $newArr['mark'] = $mark; + CapitalFlow::create($newArr); + } + + public function wechat_refund($pay_type, $row){ + $pay_price=StoreOrder::where('id',$row['order_id'])->value('pay_price'); + $order = [ + 'out_trade_no' => (string)$row['order_sn'], + 'out_refund_no' => time(), + 'reason' => '待返还金返还', + 'amount' => [ + 'refund' => bcmul($row['number'], 100), + 'total' => bcmul($pay_price, 100), + 'currency' => 'CNY', + ], + ]; + try{ + $this->payService->wechat->refund($order); + VipFlow::where('id',$row['id'])->update(['status'=>1]); + }catch (\Exception $e){ + Log::error('微信退款失败'.$e->getMessage(),$row->toArray()); + } + } + + public function ali_pay_refund($pay_type, $row){ + $order = [ + 'out_trade_no' => (string)$row['order_sn'], + 'refund_reason' => '待返还金返还', + 'refund_amount' => $row['number'], + ]; + try{ + $this->payService->alipay->refund($order); + VipFlow::where('id',$row['id'])->update(['status'=>1]); + }catch (\Exception $e){ + Log::error('支付宝退款失败'.$e->getMessage(),$row->toArray()); + } + } +} diff --git a/app/common/logic/StoreFinanceFlowLogic.php b/app/common/logic/StoreFinanceFlowLogic.php index 0f06287a7..ab6999160 100644 --- a/app/common/logic/StoreFinanceFlowLogic.php +++ b/app/common/logic/StoreFinanceFlowLogic.php @@ -70,7 +70,7 @@ class StoreFinanceFlowLogic extends BaseLogic switch ($financialType) { case OrderEnum::MERCHANT_ORDER_OBTAINS: // 商户 case OrderEnum::ORDER_MARGIN: // 商户保证金 - case OrderEnum::OTHER_ORDER_OBTAINS: // 损耗 + case OrderEnum::OTHER_ORDER_OBTAINS: // 损耗' $data['type'] = OrderEnum::MERCHANT; break; case OrderEnum::PLATFORM_ORDER_OBTAINS: // 平台 From cd952ac0195e102d78408481391e4fac3d1c1b35 Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Sat, 29 Jun 2024 11:43:40 +0800 Subject: [PATCH 003/115] =?UTF-8?q?=E5=86=BB=E7=BB=93=E5=92=8C=E8=A7=A3?= =?UTF-8?q?=E5=86=BB=E7=A4=BC=E5=93=81=E5=88=B8=E9=80=BB=E8=BE=91=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E5=92=8C=E6=96=B0=E5=A2=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/logic/order/OrderLogic.php | 40 ++++++++++++++++- app/api/logic/user/UserLogic.php | 1 + app/common/logic/PayNotifyLogic.php | 66 ++++++++++++++++++++++++++--- 3 files changed, 101 insertions(+), 6 deletions(-) diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index 2393ae4d6..07844f967 100644 --- a/app/api/logic/order/OrderLogic.php +++ b/app/api/logic/order/OrderLogic.php @@ -444,7 +444,12 @@ class OrderLogic extends BaseLogic if($order['uid'] && $order['pay_price'] >= 500){ $user_number = bcmul($order['pay_price'], '0.10', 2); User::where('id', $order['uid'])->inc('integral', $user_number)->update(); - UserSign::where(['uid' => $order['uid'],'order_id' => $order['order_id']])->update(['status'=>1]); + //todo 核销加冻结礼品券 解冻礼品券 + self::addUserSing($order,2,$user_number);//冻结 + + self::addUserSing($order,4,$user_number,1,1);//解冻 + + UserSign::where(['uid' => $order['uid'],'order_id' => $order['order_id'],'title'=>1])->update(['status'=>1]); } if ($order['spread_uid'] > 0) { $spread_find=$financeFlow->where(['order_id'=>$order['id'],'financial_pm'=>1,'financial_type'=>12,'other_uid'=>$order['spread_uid']])->find(); @@ -464,6 +469,39 @@ class OrderLogic extends BaseLogic } } + /** + * 处理冻结和解冻 礼品券得记录 + * @param $order // 订单 + * @param $category // 分类 + * @param $number // 金额 + * @param int $pm //收支 0支出 1获得 + * @type $type //类型 0冻结 1解冻 + * @return true + */ + public static function addUserSing($order, $category, $number, int $pm=0, $type=0) + { + $user_sing = new UserSign(); + $sing = [ + 'uid' => $order['uid'], + 'order_id' => $order['order_id'], +// 'title' => '购买商品获得兑换券', +// 'title' => PayNotifyLogic::getTitle($category,$number), + 'title' => $category, + 'financial_pm' => $pm, + 'store_id' => $order['store_id'], + 'number' => $number, + 'type' => $type, + 'status' => 1, + ]; + $user_sing->save($sing); + return true; + } + + + + + + //不走二次分钱的核销 public static function lessWriteOff($params): bool { diff --git a/app/api/logic/user/UserLogic.php b/app/api/logic/user/UserLogic.php index 9bc09a05e..154f77dcc 100644 --- a/app/api/logic/user/UserLogic.php +++ b/app/api/logic/user/UserLogic.php @@ -312,6 +312,7 @@ class UserLogic extends BaseLogic $query->where('financial_pm',0); } $count = $query->count(); + //todo 有就拿有得 没得就去获取对应得文本内容 $data =$query ->page($params['page_no'],$params['page_size']) ->order('id','desc') diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index 2f526d1de..ea9ee0b3d 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -621,10 +621,27 @@ class PayNotifyLogic extends BaseLogic { $total_vip = bcmul($order['price'], 0.1, 2); $user_sing = new UserSign(); - $sing = [ + //冻结 + $sing[] = [ 'uid' => $order['uid'], 'order_id' => $order['order_id'], - 'title' => '充值获得冻结兑换券', +// 'title' => '充值获得冻结兑换券', +// 'title' => self::getTitle(7,$total_vip), + 'title' =>7, + 'financial_pm' => 1, + 'store_id' => $order['store_id'], +// 'type' => 1, + 'status' => 1, + 'number' => $total_vip, + 'back_num' => $total_vip, + ]; + //礼品券得 + $sing[] = [ + 'uid' => $order['uid'], + 'order_id' => $order['order_id'], +// 'title' => '充值获得冻结兑换券', +// 'title' => self::getTitle(4,$total_vip), + 'title' => 4, 'financial_pm' => 1, 'store_id' => $order['store_id'], 'type' => 1, @@ -632,7 +649,9 @@ class PayNotifyLogic extends BaseLogic 'number' => $total_vip, 'back_num' => $total_vip, ]; - $user_sing->save($sing); + + $user_sing->saveAll($sing); + User::where('id', $order->uid)->inc('integral', $total_vip)->update(); return true; @@ -791,10 +810,13 @@ class PayNotifyLogic extends BaseLogic $sing = [ 'uid' => $order['uid'], 'order_id' => $order['order_id'], - 'title' => '购买商品获得兑换券', +// 'title' => '购买商品获得兑换券', +// 'title' => self::getTitle(1,$user_number), + 'title' => 1, 'financial_pm' => 1, 'store_id' => $order['store_id'], 'number' => $user_number, + 'status' => 0, ]; $user_sing->save($sing); } @@ -817,7 +839,9 @@ class PayNotifyLogic extends BaseLogic $sing = [ 'uid' => $order['uid'], 'order_id' => $order['order_id'], - 'title' => '购买商品获得兑换券', +// 'title' => '购买商品获得兑换券', +// 'title' => self::getTitle(1,$user_number), + 'title' => 1, 'financial_pm' => 1, 'store_id' => $order['store_id'], 'number' => $user_number, @@ -1055,4 +1079,36 @@ class PayNotifyLogic extends BaseLogic (new StoreBranchProduct())->saveAll($updateData); } + + + //礼品券相关对应文本 + public static function getTitle($category, $amount) + { + switch ($category) { + /**冻结券**/ + //收入 + case 1: + return "购买商品{$amount}元获得冻结卷"; + case 7: + return "充值{$amount}元获得冻结卷"; + //支出 + case 2: + return "核销商品{$amount}元解冻冻结卷"; + case 3: + return "退款{$amount}元扣除冻结卷"; + /**礼品券**/ + //收入 + case 4: + return "核销金额{$amount}元获得礼品卷"; + //支出 + case 5: + return "兑换{$amount}元商品扣除礼品卷"; + case 6: + return "退款{$amount}元扣除礼品卷"; + default: + return "订单支付{$amount}元"; + } + } + + } From b679ffa226d1cdd153a12076b60b95118be7c2c9 Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Sat, 29 Jun 2024 11:59:27 +0800 Subject: [PATCH 004/115] =?UTF-8?q?=E6=95=B4=E5=90=88=E5=9B=9E=E8=B0=83?= =?UTF-8?q?=E6=89=A3=E5=AF=B9=E5=BA=94=E5=BE=97=E7=A4=BC=E5=93=81=E5=88=B8?= =?UTF-8?q?=E5=B7=B2=E7=BB=8F=E5=8A=A0=E8=AE=B0=E5=BD=95=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/logic/order/OrderLogic.php | 2 +- app/common/logic/PayNotifyLogic.php | 76 ++++++++++++++++++++++------- 2 files changed, 60 insertions(+), 18 deletions(-) diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index 07844f967..c1e798d17 100644 --- a/app/api/logic/order/OrderLogic.php +++ b/app/api/logic/order/OrderLogic.php @@ -444,7 +444,7 @@ class OrderLogic extends BaseLogic if($order['uid'] && $order['pay_price'] >= 500){ $user_number = bcmul($order['pay_price'], '0.10', 2); User::where('id', $order['uid'])->inc('integral', $user_number)->update(); - //todo 核销加冻结礼品券 解冻礼品券 + // 核销加冻结礼品券 解冻礼品券 self::addUserSing($order,2,$user_number);//冻结 self::addUserSing($order,4,$user_number,1,1);//解冻 diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index 74ea6cc44..0ca0ac786 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -142,10 +142,12 @@ class PayNotifyLogic extends BaseLogic $sing[] = [ 'uid' => $order['uid'], 'order_id' => $order['order_id'], - 'title' => '订单扣除兑换券', +// 'title' => '订单扣除兑换券', + 'title' => 5, + 'financial_pm' => 0, 'store_id' => $order['store_id'], 'number' => $order['pay_price'], - 'financial_pm' => 0, + 'type' => 1, 'user_ship' => $user['user_ship'], ]; (new UserSign())->saveAll($sing); @@ -435,6 +437,10 @@ class PayNotifyLogic extends BaseLogic 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::addNewUserSing($orderRe,3,$orderRe->refund_price);//冻结 + + self::addNewUserSing($orderRe,6,$orderRe->refund_price,0,1);//解冻 self::descUserSing($orderRe); // d($purchase_funds,$orderRe['refund_price'],$orderRe); return true; @@ -469,12 +475,17 @@ class PayNotifyLogic extends BaseLogic $capitalFlowDao->userIncome('system_purchase_back', 'system_back', $order['id'], $deal_money); } if ($check_user_sing) { + //退还 兑换券 + self::addNewUserSing($order,3,$order->refund_price);//冻结 + self::addNewUserSing($order,6,$order->refund_price,0,1);//解冻 self::descUserSing($order); } return true; } //积分 if ($check_user_sing) { + self::addNewUserSing($order,3,$order->refund_price);//冻结 + self::addNewUserSing($order,6,$order->refund_price,0,1);//解冻 self::descUserSing($order); } //微信日志 user_order_refund @@ -485,28 +496,59 @@ class PayNotifyLogic extends BaseLogic return true; // self::afterPay($order,$extra['transaction_id']); } + //冻结券和礼品券得操作 + + /** + * 处理冻结和解冻 礼品券得记录 + * @param $order // 订单 + * @param $category // 分类 + * @param $number // 金额 + * @param int $pm //收支 0支出 1获得 + * @type $type //类型 0冻结 1解冻 + * @return true + */ + public static function addNewUserSing($order, $category, $number, int $pm=0, $type=0) + { + $user_sing = new UserSign(); + $sing = [ + 'uid' => $order['uid'], + 'order_id' => $order['order_id'], +// 'title' => '购买商品获得兑换券', +// 'title' => PayNotifyLogic::getTitle($category,$number), + 'title' => $category, + 'financial_pm' => $pm, + 'store_id' => $order['store_id'], + 'number' => $number, + 'type' => $type, + 'status' => 1, + ]; + $user_sing->save($sing); + return true; + } + //退积分-->订单 public static function descUserSing($order) { - $user_sing = new UserSign(); +// $user_sing = new UserSign(); if ($order['uid'] > 0) { $user_number = bcmul($order['refund_price'], '0.10', 2); - $sing = [ - 'uid' => $order['uid'], - 'order_id' => $order['order_id'], - 'title' => '退款扣除兑换券', - 'financial_pm' => 0, - 'store_id' => $order['store_id'], - 'number' => $user_number, - ]; - $user_sing->save($sing); - //删除之前获得的兑换券 - UserSign::where([ - 'order_id' => $order['order_id'], - 'financial_pm' => 1, - ])->update(['delete_time' => time()]); +// $sing = [ +// 'uid' => $order['uid'], +// 'order_id' => $order['order_id'], +// 'title' => '退款扣除兑换券', +// 'financial_pm' => 0, +// 'store_id' => $order['store_id'], +// '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'])->withTrashed()->find(); if ($now_int) { if ($now_int['integral'] > $user_number) { From 2cafc398192a87387eb1480f4cae198e4d5e8144 Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Sat, 29 Jun 2024 13:49:48 +0800 Subject: [PATCH 005/115] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=9F=A5=E8=AF=A2?= =?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/api/controller/user/UserController.php | 14 +++++++ app/api/logic/user/UserLogic.php | 45 +++++++++++++++++++++- 2 files changed, 58 insertions(+), 1 deletion(-) diff --git a/app/api/controller/user/UserController.php b/app/api/controller/user/UserController.php index 08c0bbbc2..82e0e16be 100644 --- a/app/api/controller/user/UserController.php +++ b/app/api/controller/user/UserController.php @@ -245,6 +245,20 @@ class UserController extends BaseApiController } + public function userSing() + { + (new UserValidate())->get()->goCheck('fund'); + $page_no = (int)$this->request->get('page_no', 1); + $page_size = (int)$this->request->get('page_size', 15); + $params = $this->request->get(); + $params['page_no'] = $page_no > 0 ? $page_no : 1; + $params['page_size'] = $page_size > 0 ? $page_size : 15; + $res = UserLogic::userSingList($params,$this->userId); + $res['page_no'] = $params['page_no']; + $res['page_size'] = $params['page_size']; + return $this->success('ok', $res); + } + /** * 用户信息 */ diff --git a/app/api/logic/user/UserLogic.php b/app/api/logic/user/UserLogic.php index 154f77dcc..f12c1f1d5 100644 --- a/app/api/logic/user/UserLogic.php +++ b/app/api/logic/user/UserLogic.php @@ -5,6 +5,7 @@ namespace app\api\logic\user; use app\api\service\UserTokenService; use app\common\{logic\BaseLogic, + logic\PayNotifyLogic, model\dict\DictData, model\finance\CapitalFlow, model\store_finance_flow\StoreFinanceFlow, @@ -253,6 +254,48 @@ class UserLogic extends BaseLogic } + public static function userSingList($params,$uid) + { + switch ($params['type']){ + case 1: + $query = UserSign::where(['uid'=>$uid,'type'=>1]); + if($params['mark'] == 1){ + $query->where('financial_pm',1);//获得 + } + if($params['mark'] == 2){ + $query->where('financial_pm',0); + } + $count = $query->count(); + $data =$query + ->page($params['page_no'],$params['page_size']) + ->order('id','desc') + ->select()?->toArray(); + break; + default: + $query = UserSign::where(['uid'=>$uid,'type'=>0]); + if($params['mark'] == 1){ + $query->where('financial_pm',1);//获得 + } + if($params['mark'] == 2){ + $query->where('financial_pm',0); + } + $count = $query->count(); + $data =$query + ->page($params['page_no'],$params['page_size']) + ->order('id','desc') + ->select()?->toArray(); + } + foreach ($data as &$value){ + if(!preg_match('/[\x{4e00}-\x{9fa5}]/u', $value['title'])){ + $value['title'] = PayNotifyLogic::getTitle($value['title'],$value['number']); + } + } + return [ + 'lists' => $data, + 'count' => $count + ]; + + } public static function dealDetails($params,$uid) { @@ -306,7 +349,7 @@ class UserLogic extends BaseLogic //礼品券明细 $query = UserSign::where(['uid'=>$uid]); if($params['mark'] == 1){ - $query->where('financial_pm',1); + $query->where('financial_pm',1);//获得 } if($params['mark'] == 2){ $query->where('financial_pm',0); From e975c3e28e5cd426fb4ae07385cec057c8340c02 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Sat, 29 Jun 2024 13:52:42 +0800 Subject: [PATCH 006/115] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=80=80=E6=AC=BE?= =?UTF-8?q?=E5=85=85=E5=80=BC=E7=8A=B6=E6=80=81=E7=AD=9B=E9=80=89=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/logic/statistic/TradeStatisticLogic.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/admin/logic/statistic/TradeStatisticLogic.php b/app/admin/logic/statistic/TradeStatisticLogic.php index 9ffded419..c8ffe14f3 100644 --- a/app/admin/logic/statistic/TradeStatisticLogic.php +++ b/app/admin/logic/statistic/TradeStatisticLogic.php @@ -602,7 +602,7 @@ class TradeStatisticLogic extends BaseLogic { /** 普通商品订单支付金额 */ $storeOrder = new StoreOrder(); - $where['refund_status'] = isset($where['refund_status']) ? $where['refund_status'] : [0, 3]; + $where['refund_status'] = 0; $where['paid'] = 1; $timeKey = $this->TimeConvert($where['create_time'], $isNum); @@ -647,7 +647,7 @@ class TradeStatisticLogic extends BaseLogic switch ($selectType) { case "sum": - $totalMoney = $userRechage->where(['paid' => 1]) + $totalMoney = $userRechage->where(['paid' => 1,'status'=>1]) ->when(isset($where['create_time']), function ($query) use ($where) { $query->whereBetweenTime('create_time', strtotime($where['timeKey']['start_time']), strtotime($where['timeKey']['end_time'])); }) From d4eef002fe3bc14d57f4011f14047512b7026ec1 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Sat, 29 Jun 2024 14:00:55 +0800 Subject: [PATCH 007/115] =?UTF-8?q?=E7=A6=81=E7=94=A8=E5=95=86=E5=93=81?= =?UTF-8?q?=E9=80=80=E6=AC=BE=E9=87=91=E9=A2=9D=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../logic/statistic/TradeStatisticLogic.php | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/app/admin/logic/statistic/TradeStatisticLogic.php b/app/admin/logic/statistic/TradeStatisticLogic.php index c8ffe14f3..6ed89ef2e 100644 --- a/app/admin/logic/statistic/TradeStatisticLogic.php +++ b/app/admin/logic/statistic/TradeStatisticLogic.php @@ -385,20 +385,20 @@ class TradeStatisticLogic extends BaseLogic // $Chain['out'] = $outTotalCurve; //商品退款金额 - $outOrderRefund = $this->getOrderRefundTotalMoney(['create_time' => $where['create_time']], 'sum'); - $lastOutOrderRefund = $this->getOrderRefundTotalMoney(['create_time' => $dateWhere['create_time']], 'sum', "", $isNum); - $outOrderRefundCurve = $this->getOrderRefundTotalMoney(['create_time' => $where['create_time']], 'group', 'create_time'); - $orderRefundChain = countRate($outOrderRefund, $lastOutOrderRefund); - $topData[12] = [ - 'title' => '商品退款金额', - 'desc' => '用户成功退款的商品金额', - 'total_money' => $outOrderRefund, - 'rate' => $orderRefundChain, - 'value' => $outOrderRefundCurve['y'], - 'type' => 0, - 'sign' => 'refund', - ]; - $Chain['refund'] = $outOrderRefundCurve; + // $outOrderRefund = $this->getOrderRefundTotalMoney(['create_time' => $where['create_time']], 'sum'); + // $lastOutOrderRefund = $this->getOrderRefundTotalMoney(['create_time' => $dateWhere['create_time']], 'sum', "", $isNum); + // $outOrderRefundCurve = $this->getOrderRefundTotalMoney(['create_time' => $where['create_time']], 'group', 'create_time'); + // $orderRefundChain = countRate($outOrderRefund, $lastOutOrderRefund); + // $topData[12] = [ + // 'title' => '商品退款金额', + // 'desc' => '用户成功退款的商品金额', + // 'total_money' => $outOrderRefund, + // 'rate' => $orderRefundChain, + // 'value' => $outOrderRefundCurve['y'], + // 'type' => 0, + // 'sign' => 'refund', + // ]; + // $Chain['refund'] = $outOrderRefundCurve; From 61f7ce9332cd67b156a3dfa2842d4302ddc18e5c Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Sat, 29 Jun 2024 14:14:01 +0800 Subject: [PATCH 008/115] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=A4=BC=E5=93=81?= =?UTF-8?q?=E5=88=B8=E7=BB=9F=E8=AE=A1=E6=8F=8F=E8=BF=B0=E4=B8=8E=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/logic/statistic/TradeStatisticLogic.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/admin/logic/statistic/TradeStatisticLogic.php b/app/admin/logic/statistic/TradeStatisticLogic.php index 6ed89ef2e..7297e10c7 100644 --- a/app/admin/logic/statistic/TradeStatisticLogic.php +++ b/app/admin/logic/statistic/TradeStatisticLogic.php @@ -328,13 +328,13 @@ class TradeStatisticLogic extends BaseLogic ]; $Chain['deposit'] = $OrderDepositCurve; //兑换礼品券 - $userSign = $this->getUserSign($where, 'sum'); - $userSignTwo = $this->getUserSign($where, 'sum', "", $isNum); - $userSignGroup = $this->getUserSign($where, 'group', "create_time"); + $userSign = $this->getOrderTotalMoney(['pay_type' => 19, 'create_time' => $where['create_time']], 'sum'); + $userSignTwo = $this->getOrderTotalMoney(['pay_type' => 19, 'create_time' => $dateWhere['create_time']], 'sum', "", $isNum); + $userSignGroup = $this->getOrderTotalMoney(['pay_type' => 19, 'create_time' => $where['create_time']], 'group', 'create_time'); $userSignRate = countRate($userSign, $userSignTwo); $topData[9] = [ - 'title' => '兑换礼品券', - 'desc' => '后台给推广员支付的兑换礼品券,以实际支付为准', + 'title' => '礼品券消耗', + 'desc' => '用户下单时使用礼品券实际支付的金额', 'total_money' => $userSign, 'rate' => $userSignRate, 'value' => $userSignGroup['y'], From 70920df001468a715cab199bfe280a963a6f7e10 Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Sat, 29 Jun 2024 14:40:20 +0800 Subject: [PATCH 009/115] =?UTF-8?q?=E4=BC=9A=E5=91=98=E4=B8=8B=E5=8D=95?= =?UTF-8?q?=E4=B8=8D=E5=8A=A0=E5=85=91=E6=8D=A2=E5=88=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/order/OrderController.php | 1 - app/common/logic/PayNotifyLogic.php | 23 +++++++++++--------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/app/api/controller/order/OrderController.php b/app/api/controller/order/OrderController.php index bb8b584d6..6e6e9e17b 100644 --- a/app/api/controller/order/OrderController.php +++ b/app/api/controller/order/OrderController.php @@ -131,7 +131,6 @@ class OrderController extends BaseApiController } $order = OrderLogic::createOrder($cartId, $addressId, $user, $params); - if ($order != false) { if ($order['pay_price'] <= 0) { $pay_type = 3; diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index 0ca0ac786..7276b3a56 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -66,7 +66,7 @@ class PayNotifyLogic extends BaseLogic public static function balancePay($orderSn, $extra = []) { $order = StoreOrder::where('order_id', $orderSn)->findOrEmpty(); - + self::afterPay($order);d(444); $user = User::where('id', $order['uid'])->find(); if ($user['now_money'] < $order['pay_price']) { throw new \Exception('余额不足'); @@ -826,7 +826,9 @@ 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 && $order['pay_type'] !=PayEnum::PURCHASE_FUNDS) { + $user_ship = User::where('id', $order['uid'])->value('user_ship');//会员不加兑换券 + if ($order['uid'] > 0 && $order['total_price'] >= 500 + && $order['pay_type'] !=PayEnum::PURCHASE_FUNDS && $user_ship !=1) { $user_number = bcmul($order['pay_price'], '0.10', 2); $sing = [ 'uid' => $order['uid'], @@ -848,14 +850,7 @@ class PayNotifyLogic extends BaseLogic //用户下单该用户等级为1得时候才处理冻结金额 $user = User::where('id', $order['uid'])->find(); $user_ship = $user['user_ship']; - //纯在分销关系的时候要去判断分销出来的用户的采购款的额度 (只有会员按照这个逻辑拆分,其余的还是按照正常的支付金额) - if ($user['user_ship'] == 1 && $order['pay_type'] != PayEnum::CASH_PAY) { - $vipFrozenAmount = self::dealFrozenPrice($order['id']); - //为1的时候要去减活动价 - $order['pay_price'] = bcsub($order['pay_price'], $vipFrozenAmount, 2); - self::dealVipAmount($order, $order['pay_type']); - } - if($order['total_price'] >= 500 && $order['pay_type'] !=PayEnum::PURCHASE_FUNDS){ + if($order['total_price'] >= 500 && $order['pay_type'] !=PayEnum::PURCHASE_FUNDS && $user_ship !=1){ $user_number = bcmul($order['pay_price'], '0.10', 2); $sing = [ 'uid' => $order['uid'], @@ -870,6 +865,14 @@ class PayNotifyLogic extends BaseLogic ]; $user_sing->save($sing); } + //纯在分销关系的时候要去判断分销出来的用户的采购款的额度 (只有会员按照这个逻辑拆分,其余的还是按照正常的支付金额) + if ($user['user_ship'] == 1 && $order['pay_type'] != PayEnum::CASH_PAY) { + $vipFrozenAmount = self::dealFrozenPrice($order['id']); + //为1的时候要去减活动价 + $order['pay_price'] = bcsub($order['pay_price'], $vipFrozenAmount, 2); + self::dealVipAmount($order, $order['pay_type']); + } + } //查询用户对应的村长和队长 $address = UserAddress::where(['uid' => $order['uid'], 'is_default' => 1])->find(); From f7f60c47d9f212b61231ad164048828c4fe72de8 Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Sat, 29 Jun 2024 14:45:39 +0800 Subject: [PATCH 010/115] =?UTF-8?q?=E6=B3=A8=E9=87=8A=E9=AA=8C=E8=AF=81?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/store/controller/user/UserController.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/app/store/controller/user/UserController.php b/app/store/controller/user/UserController.php index dd6b82e4b..47e6b8653 100644 --- a/app/store/controller/user/UserController.php +++ b/app/store/controller/user/UserController.php @@ -40,16 +40,16 @@ class UserController extends BaseAdminController { $params = (new UserValidate())->post()->goCheck('storeAdd'); $code = $params['code']; - if($code && $params['mobile']){ - $remark = $params['mobile'].'_userArchives'; - $codeCache = Cache::get($remark); - if(empty($codeCache)){ - return $this->fail('验证码不存在'); - } - if ($codeCache != $code) { - return $this->fail('验证码错误'); - } - } +// if($code && $params['mobile']){ +// $remark = $params['mobile'].'_userArchives'; +// $codeCache = Cache::get($remark); +// if(empty($codeCache)){ +// return $this->fail('验证码不存在'); +// } +// if ($codeCache != $code) { +// return $this->fail('验证码错误'); +// } +// } UserLogic::StoreAdd($params); if (UserLogic::hasError() ) { return $this->fail(UserLogic::getError()); From ed983e0971a4c31d8ab65da20f52273d0fdf2728 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Sat, 29 Jun 2024 14:46:23 +0800 Subject: [PATCH 011/115] =?UTF-8?q?=E6=9B=B4=E6=96=B0UserShip=E6=A8=A1?= =?UTF-8?q?=E5=9E=8B=E4=B8=8E=E7=9B=B8=E5=85=B3=E6=8E=A7=E5=88=B6=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../user_ship/UserShipController .php | 95 ++++++++++++++++++ app/admin/lists/user_label/UserLabelLists.php | 2 +- .../UserProductStorageLists.php | 8 +- app/admin/lists/user_ship/UserShipLists.php | 65 ++++++++++++ app/admin/logic/user_ship/UserShipLogic.php | 98 +++++++++++++++++++ .../validate/user_ship/UserShipValidate.php | 88 +++++++++++++++++ app/api/controller/LiuController.php | 2 +- app/api/logic/order/OrderLogic.php | 2 +- app/api/logic/user/UserLogic.php | 2 +- app/common/lists/user/UserShipLists.php | 2 +- app/common/logic/PayNotifyLogic copy.php | 2 +- app/common/logic/PayNotifyLogic.php | 2 +- .../model/{user => user_ship}/UserShip.php | 2 +- app/store/lists/user/UserLists.php | 2 +- 14 files changed, 362 insertions(+), 10 deletions(-) create mode 100644 app/admin/controller/user_ship/UserShipController .php create mode 100644 app/admin/lists/user_ship/UserShipLists.php create mode 100644 app/admin/logic/user_ship/UserShipLogic.php create mode 100644 app/admin/validate/user_ship/UserShipValidate.php rename app/common/model/{user => user_ship}/UserShip.php (84%) diff --git a/app/admin/controller/user_ship/UserShipController .php b/app/admin/controller/user_ship/UserShipController .php new file mode 100644 index 000000000..bac737514 --- /dev/null +++ b/app/admin/controller/user_ship/UserShipController .php @@ -0,0 +1,95 @@ +dataLists(new UserShipLists()); + } + + + /** + * @notes 添加会员类型 + * @return \think\response\Json + * @author admin + * @date 2024/06/29 14:18 + */ + public function add() + { + $params = (new UserShipValidate())->post()->goCheck('add'); + $result = UserShipLogic::add($params); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(UserShipLogic::getError()); + } + + + /** + * @notes 编辑会员类型 + * @return \think\response\Json + * @author admin + * @date 2024/06/29 14:18 + */ + public function edit() + { + $params = (new UserShipValidate())->post()->goCheck('edit'); + $result = UserShipLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(UserShipLogic::getError()); + } + + + /** + * @notes 删除会员类型 + * @return \think\response\Json + * @author admin + * @date 2024/06/29 14:18 + */ + public function delete() + { + $params = (new UserShipValidate())->post()->goCheck('delete'); + UserShipLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取会员类型详情 + * @return \think\response\Json + * @author admin + * @date 2024/06/29 14:18 + */ + public function detail() + { + $params = (new UserShipValidate())->goCheck('detail'); + $result = UserShipLogic::detail($params); + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/app/admin/lists/user_label/UserLabelLists.php b/app/admin/lists/user_label/UserLabelLists.php index 53261482b..79639ed74 100644 --- a/app/admin/lists/user_label/UserLabelLists.php +++ b/app/admin/lists/user_label/UserLabelLists.php @@ -6,7 +6,7 @@ namespace app\admin\lists\user_label; use app\admin\lists\BaseAdminDataLists; use app\common\model\user_label\UserLabel; use app\common\lists\ListsSearchInterface; -use app\common\model\user\UserShip; +use app\common\model\user_ship\UserShip; /** * 用户标签列表 diff --git a/app/admin/lists/user_product_storage/UserProductStorageLists.php b/app/admin/lists/user_product_storage/UserProductStorageLists.php index 6a0cb49a1..f44c9f8a3 100644 --- a/app/admin/lists/user_product_storage/UserProductStorageLists.php +++ b/app/admin/lists/user_product_storage/UserProductStorageLists.php @@ -48,9 +48,15 @@ class UserProductStorageLists extends BaseAdminDataLists implements ListsSearchI $status=$this->request->get('status',1); if($status==1){ $this->searchWhere[]=['status','=',1];//只显示正常状态的记录,不显示已出库完的记录 + $field='id,uid,oid,product_id,sum(nums) nums,status,create_time'; + $group='product_id'; + }else{ + $field='id,uid,oid,product_id,nums,status,create_time'; + $group=null; } return UserProductStorage::where($this->searchWhere) - ->field(['id', 'uid', 'oid', 'product_id', 'nums', 'status','create_time']) + ->field($field) + ->group($group) ->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) ->select()->each(function($item){ diff --git a/app/admin/lists/user_ship/UserShipLists.php b/app/admin/lists/user_ship/UserShipLists.php new file mode 100644 index 000000000..faf9b87b8 --- /dev/null +++ b/app/admin/lists/user_ship/UserShipLists.php @@ -0,0 +1,65 @@ + ['title'], + ]; + } + + + /** + * @notes 获取会员类型列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author admin + * @date 2024/06/29 14:18 + */ + public function lists(): array + { + return UserShip::where($this->searchWhere) + ->field(['id', 'title', 'discount', 'limit', 'sort']) + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select() + ->toArray(); + } + + + /** + * @notes 获取会员类型数量 + * @return int + * @author admin + * @date 2024/06/29 14:18 + */ + public function count(): int + { + return UserShip::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/admin/logic/user_ship/UserShipLogic.php b/app/admin/logic/user_ship/UserShipLogic.php new file mode 100644 index 000000000..0166b1a84 --- /dev/null +++ b/app/admin/logic/user_ship/UserShipLogic.php @@ -0,0 +1,98 @@ + $params['title'], + 'limit' => $params['limit'], + 'sort' => $params['sort'] + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 编辑会员类型 + * @param array $params + * @return bool + * @author admin + * @date 2024/06/29 14:18 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + UserShip::where('id', $params['id'])->update([ + 'title' => $params['title'], + 'limit' => $params['limit'], + 'sort' => $params['sort'] + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 删除会员类型 + * @param array $params + * @return bool + * @author admin + * @date 2024/06/29 14:18 + */ + public static function delete(array $params): bool + { + return UserShip::destroy($params['id']); + } + + + /** + * @notes 获取会员类型详情 + * @param $params + * @return array + * @author admin + * @date 2024/06/29 14:18 + */ + public static function detail($params): array + { + return UserShip::findOrEmpty($params['id'])->toArray(); + } +} \ No newline at end of file diff --git a/app/admin/validate/user_ship/UserShipValidate.php b/app/admin/validate/user_ship/UserShipValidate.php new file mode 100644 index 000000000..e9a3899d3 --- /dev/null +++ b/app/admin/validate/user_ship/UserShipValidate.php @@ -0,0 +1,88 @@ + 'require', + 'title' => 'require', + 'limit' => 'require', + 'sort' => 'require', + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + 'title' => '会员名称', + 'limit' => '充值金额', + 'sort' => '排序倒序', + ]; + + + /** + * @notes 添加场景 + * @return UserShipValidate + * @author admin + * @date 2024/06/29 14:18 + */ + public function sceneAdd() + { + return $this->only(['title','limit','sort']); + } + + + /** + * @notes 编辑场景 + * @return UserShipValidate + * @author admin + * @date 2024/06/29 14:18 + */ + public function sceneEdit() + { + return $this->only(['id','title','limit','sort']); + } + + + /** + * @notes 删除场景 + * @return UserShipValidate + * @author admin + * @date 2024/06/29 14:18 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return UserShipValidate + * @author admin + * @date 2024/06/29 14:18 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + +} \ No newline at end of file diff --git a/app/api/controller/LiuController.php b/app/api/controller/LiuController.php index b70056582..1560f7d58 100644 --- a/app/api/controller/LiuController.php +++ b/app/api/controller/LiuController.php @@ -27,7 +27,7 @@ use app\common\model\system_store\SystemStore; use app\common\model\user\User; use app\common\model\user\UserAddress; use app\common\model\user\UserRecharge; -use app\common\model\user\UserShip; +use app\common\model\user_ship\UserShip; use app\common\model\user_sign\UserSign; use app\common\model\vip_flow\VipFlow; use app\common\service\pay\PayService; diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index c1e798d17..8ad7e2586 100644 --- a/app/api/logic/order/OrderLogic.php +++ b/app/api/logic/order/OrderLogic.php @@ -25,7 +25,7 @@ use app\common\model\system_store\SystemStore; use app\common\model\system_store\SystemStoreStaff; use app\common\model\user\User; use app\common\model\user\UserAddress; -use app\common\model\user\UserShip; +use app\common\model\user_ship\UserShip; use app\common\model\user_sign\UserSign; use app\common\model\user_spread_log\UserSpreadLog; use Picqer\Barcode\BarcodeGeneratorJPG; diff --git a/app/api/logic/user/UserLogic.php b/app/api/logic/user/UserLogic.php index f12c1f1d5..6a5d2b628 100644 --- a/app/api/logic/user/UserLogic.php +++ b/app/api/logic/user/UserLogic.php @@ -16,7 +16,7 @@ use app\common\{logic\BaseLogic, model\user\User, model\user\UserAuth, model\user\UserRecharge, - model\user\UserShip, + model\user_ship\UserShip, model\user_sign\UserSign, model\vip_flow\VipFlow, service\SmsService, diff --git a/app/common/lists/user/UserShipLists.php b/app/common/lists/user/UserShipLists.php index 5b4614510..8356504b1 100644 --- a/app/common/lists/user/UserShipLists.php +++ b/app/common/lists/user/UserShipLists.php @@ -5,7 +5,7 @@ namespace app\common\lists\user; use app\admin\lists\BaseAdminDataLists; -use app\common\model\user\UserShip; +use app\common\model\user_ship\UserShip; /** * 会员类型 diff --git a/app/common/logic/PayNotifyLogic copy.php b/app/common/logic/PayNotifyLogic copy.php index 3f641cfbc..015e4ec93 100644 --- a/app/common/logic/PayNotifyLogic copy.php +++ b/app/common/logic/PayNotifyLogic copy.php @@ -23,7 +23,7 @@ use app\common\model\system_store\SystemStore; use app\common\model\user\User; use app\common\model\user\UserAddress; use app\common\model\user\UserRecharge; -use app\common\model\user\UserShip; +use app\common\model\user_ship\UserShip; use app\common\model\user_sign\UserSign; use app\common\service\Curl; use app\common\service\PushService; diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index 0ca0ac786..6b4cec2be 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -23,7 +23,7 @@ use app\common\model\system_store\SystemStore; use app\common\model\user\User; use app\common\model\user\UserAddress; use app\common\model\user\UserRecharge; -use app\common\model\user\UserShip; +use app\common\model\user_ship\UserShip; use app\common\model\user_sign\UserSign; use app\common\model\vip_flow\VipFlow; use app\common\service\Curl; diff --git a/app/common/model/user/UserShip.php b/app/common/model/user_ship/UserShip.php similarity index 84% rename from app/common/model/user/UserShip.php rename to app/common/model/user_ship/UserShip.php index 7d0a05ed1..1cfc60f27 100644 --- a/app/common/model/user/UserShip.php +++ b/app/common/model/user_ship/UserShip.php @@ -1,6 +1,6 @@ Date: Sat, 29 Jun 2024 14:55:46 +0800 Subject: [PATCH 012/115] =?UTF-8?q?=E8=B0=83=E7=94=A8=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/model/user/User.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/common/model/user/User.php b/app/common/model/user/User.php index ea80beca0..290132284 100644 --- a/app/common/model/user/User.php +++ b/app/common/model/user/User.php @@ -7,6 +7,7 @@ namespace app\common\model\user; use app\common\enum\user\UserEnum; use app\common\model\BaseModel; use app\common\model\user_label\UserLabel; +use app\common\model\user_ship\UserShip; use app\common\service\FileService; use think\model\concern\SoftDelete; From a4fdbc525696936d97edc72bee720901d4fd78e0 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Sat, 29 Jun 2024 14:56:22 +0800 Subject: [PATCH 013/115] =?UTF-8?q?=E8=B0=83=E6=95=B4=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E4=BC=9A=E5=91=98=E7=B1=BB=E5=9E=8B=E7=AE=A1=E7=90=86=E6=8E=A7?= =?UTF-8?q?=E5=88=B6=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../{UserShipController .php => UserShipController.php} | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) rename app/admin/controller/user_ship/{UserShipController .php => UserShipController.php} (99%) diff --git a/app/admin/controller/user_ship/UserShipController .php b/app/admin/controller/user_ship/UserShipController.php similarity index 99% rename from app/admin/controller/user_ship/UserShipController .php rename to app/admin/controller/user_ship/UserShipController.php index bac737514..123681b4f 100644 --- a/app/admin/controller/user_ship/UserShipController .php +++ b/app/admin/controller/user_ship/UserShipController.php @@ -90,6 +90,4 @@ class UserShipController extends BaseAdminController $result = UserShipLogic::detail($params); return $this->data($result); } - - -} \ No newline at end of file +} From af4af0d1ed4b62a0a8237dfc6a78936ba6bc657c Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Sat, 29 Jun 2024 15:06:41 +0800 Subject: [PATCH 014/115] =?UTF-8?q?=E8=B4=AD=E7=89=A9=E8=BD=A6=E9=80=BB?= =?UTF-8?q?=E8=BE=91=E5=85=BC=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/order/CartController.php | 6 ++++- app/api/logic/order/CartLogic.php | 29 +++++++++++++++------ 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/app/api/controller/order/CartController.php b/app/api/controller/order/CartController.php index 0f0346d9b..7496016df 100644 --- a/app/api/controller/order/CartController.php +++ b/app/api/controller/order/CartController.php @@ -48,7 +48,11 @@ class CartController extends BaseApiController return $this->fail('库存数量不足'); } if ($result) { - $res = CartLogic::edit($params); + if(isset($params['type']) && $params['type'] == 1){ + $res = CartLogic::add($params); + }else{ + $res = CartLogic::edit($params); + } } else { $res = CartLogic::add($params); } diff --git a/app/api/logic/order/CartLogic.php b/app/api/logic/order/CartLogic.php index 8afb470ba..9b2d32d14 100644 --- a/app/api/logic/order/CartLogic.php +++ b/app/api/logic/order/CartLogic.php @@ -33,16 +33,29 @@ class CartLogic extends BaseLogic } Db::startTrans(); try { - $cart = Cart::create([ + //check + $check = Cart::where([ 'uid' => $params['uid'], - 'type' => $params['type']??'', + 'store_id' => $params['store_id'], 'product_id' => $params['product_id'], - 'store_id' => $params['store_id']??0, - 'staff_id' => $params['staff_id']??0, - 'product_attr_unique' => '', - 'cart_num' => $params['cart_num'], - 'is_new' => $params['is_new']??0, - ]); + 'is_pay'=>0 + ])->field('id')->find(); + if($check){ + Cart::where('id',$check['id'])->inc('cart_num',$params['cart_num']) + ->update(); + $cart['id'] = $check['id']; + }else{ + $cart = Cart::create([ + 'uid' => $params['uid'], + 'type' => $params['type']??'', + 'product_id' => $params['product_id'], + 'store_id' => $params['store_id']??0, + 'staff_id' => $params['staff_id']??0, + 'product_attr_unique' => '', + 'cart_num' => $params['cart_num'], + 'is_new' => $params['is_new']??0, + ]); + } StoreProductLog::create([ 'type'=>'cart', 'uid' => $params['uid'], From 18134f3f37c851fb961674815b9c348a3b4551da Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Sat, 29 Jun 2024 15:11:54 +0800 Subject: [PATCH 015/115] =?UTF-8?q?=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/logic/PayNotifyLogic.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index 09093047d..5adc09b02 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -66,7 +66,7 @@ class PayNotifyLogic extends BaseLogic public static function balancePay($orderSn, $extra = []) { $order = StoreOrder::where('order_id', $orderSn)->findOrEmpty(); - self::afterPay($order);d(444); + self::afterPay($order); $user = User::where('id', $order['uid'])->find(); if ($user['now_money'] < $order['pay_price']) { throw new \Exception('余额不足'); From 8d73511117dbbb8331eeb7ff958395975ef93d91 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Sat, 29 Jun 2024 15:14:40 +0800 Subject: [PATCH 016/115] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=91=98=E5=B7=A5ID?= =?UTF-8?q?=E5=88=B0=E8=B4=A2=E5=8A=A1=E5=A4=84=E7=90=86=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/logic/CommissionLogic.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/common/logic/CommissionLogic.php b/app/common/logic/CommissionLogic.php index ce89bd771..d569dc5ef 100644 --- a/app/common/logic/CommissionLogic.php +++ b/app/common/logic/CommissionLogic.php @@ -81,7 +81,7 @@ class CommissionLogic extends BaseLogic $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->in($transaction_id, $fees, OrderEnum::ORDER_HANDLING_FEES, $order['store_id'], $order['staff_id'], 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(); } @@ -97,7 +97,7 @@ class CommissionLogic extends BaseLogic $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->in($transaction_id, $fees, OrderEnum::SUPPLIER_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 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(); } @@ -122,7 +122,7 @@ class CommissionLogic extends BaseLogic 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']); //平台手续费 + $financeLogic->in($transaction_id, 0, OrderEnum::MERCHANT_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); //平台手续费 } } else { $money = bcsub($store_profit, $deposit, 2); @@ -132,13 +132,13 @@ class CommissionLogic extends BaseLogic } 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']); //平台手续费 + $financeLogic->in($transaction_id, $money, OrderEnum::MERCHANT_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); //平台手续费 } } } 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']); //平台手续费 + $financeLogic->in($transaction_id, $store_profit, OrderEnum::MERCHANT_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); //平台手续费 } } $financeLogic->save(); @@ -162,7 +162,7 @@ class CommissionLogic extends BaseLogic $financeLogic->user['uid'] = $order['uid']; $financeLogic->other_arr['vip_uid'] = $uid; $financeLogic->order = $order; - $financeLogic->in($transaction_id, $fees, $enum, $order['store_id'], 0, 0, $order['pay_type']); + $financeLogic->in($transaction_id, $fees, $enum, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); $financeLogic->out($transaction_id, $fees, $enum, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); $financeLogic->save(); } From 4d4772a0359122d3752e27c8b3c4a10beb8aa4df Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Sat, 29 Jun 2024 15:27:49 +0800 Subject: [PATCH 017/115] =?UTF-8?q?=E7=A7=BB=E9=99=A4VipLogic=E4=B8=AD?= =?UTF-8?q?=E7=9A=84afterPay=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/logic/VipLogic.php | 135 ---------------------------------- 1 file changed, 135 deletions(-) diff --git a/app/common/logic/VipLogic.php b/app/common/logic/VipLogic.php index d47b95051..3131a9973 100644 --- a/app/common/logic/VipLogic.php +++ b/app/common/logic/VipLogic.php @@ -42,142 +42,7 @@ class VipLogic extends BaseLogic 'create_time'=>time() ]; Db::name('vip_flow')->insert($data); - //todo 限制执行 -// self::afterPay($order,$transaction_id,$total_vip); return true; } - - - - - - - public static function afterPay($order, $transaction_id = 0,$Vipmoney=0) - { - $financeLogic = new StoreFinanceFlowLogic(); - $financeLogic->order = $order; - $financeLogic->user = ['uid' => $order['uid']]; - - $financeLogic->in($transaction_id, $Vipmoney, OrderEnum::USER_ORDER_PAY); //用户订单支付 - $count_frees = 0; - - //平台手续费 - $fees = bcdiv(bcmul($Vipmoney, '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']); //商户平台手续费支出 - } - // $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($Vipmoney, '0.05', 2), 1, 2); - $count_frees = bcadd($count_frees, $store_profit, 2); - if ($deposit > 0) { - if ($deposit > $store_profit) { - if ($store_profit > 0) { - $financeLogic->out($transaction_id, $store_profit, OrderEnum::ORDER_MARGIN, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); - } - } else { - $money = bcsub($store_profit, $deposit, 2); - if ($deposit > 0) { - $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']); //平台手续费 - } - } - } 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']); //平台手续费 - } - } - - if ($order['is_vip'] >= 1) { - if ($order['spread_uid'] > 0) { - $financeLogic->other_arr['vip_uid'] = $order['spread_uid']; - $fees = bcdiv(bcmul($Vipmoney, '0.08', 2), 1, 2); - $count_frees = bcadd($count_frees, $fees, 2); - if ($fees > 0) { - User::where('id', $order['spread_uid'])->inc('now_money', $fees)->update(); - $financeLogic->in($transaction_id, $fees, OrderEnum::VIP_ORDER_OBTAINS, $order['store_id'], 0, 0, $order['pay_type']); //vip订单获得 - $financeLogic->out($transaction_id, $fees, OrderEnum::VIP_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); - } - } - $fees = bcdiv(bcmul($Vipmoney, '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) { - $village_uid = User::where('id', 'in', $arr1)->where('user_ship', 2)->value('id'); - if($village_uid){ - User::where('id', $village_uid)->inc('integral', $fees)->update(); - } - } - $arr2 = UserAddress::where(['village' => $address['village'], 'brigade' => $address['brigade'], 'is_default' => 1])->column('uid'); - if ($arr2) { - $brigade_uid = User::where('id', 'in', $arr1)->where('user_ship', 3)->value('id'); - if($brigade_uid){ - User::where('id', $brigade_uid)->inc('integral', $fees)->update(); - } - } - } - } - if ($fees > 0) { - //村长获得 - $sing=[]; - $user_sing=new UserSign(); - - $sing[]=[ - 'uid'=>$village_uid, - 'title'=>'村长订单获得兑换券', - 'store_id'=>$order['store_id'], - 'number'=>$fees, - ]; - $sing[]=[ - 'uid'=>$brigade_uid, - 'title'=>'队长订单获得兑换券', - 'store_id'=>$order['store_id'], - 'number'=>$fees, - ]; - // if ($village_uid > 0) { - // $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) { - // $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($Vipmoney, $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(); - - } - - } \ No newline at end of file From 18c660df094c91855dfa43ece3a71ffd8f090e6d Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Sat, 29 Jun 2024 15:32:38 +0800 Subject: [PATCH 018/115] =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=A4=9A=E4=BD=99?= =?UTF-8?q?=E8=B0=83=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/logic/PayNotifyLogic.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index 5adc09b02..e5852bd60 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -66,7 +66,6 @@ class PayNotifyLogic extends BaseLogic public static function balancePay($orderSn, $extra = []) { $order = StoreOrder::where('order_id', $orderSn)->findOrEmpty(); - self::afterPay($order); $user = User::where('id', $order['uid'])->find(); if ($user['now_money'] < $order['pay_price']) { throw new \Exception('余额不足'); @@ -219,9 +218,10 @@ class PayNotifyLogic extends BaseLogic // if($count){ // self::addFlowLog($order); // } - // if($order['shipping_type'] == 3){ + //收银台下单直接到账 +// if($order['shipping_type'] == 3){ // self::descStock($order['id']); - // } +// } // Redis::send('push-platform-print', ['id' => $order['id']], 60); From 355b18900e591353d6e648819e544943921fda06 Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Sat, 29 Jun 2024 15:41:23 +0800 Subject: [PATCH 019/115] =?UTF-8?q?=E6=94=B6=E9=93=B6=E5=8F=B0=E7=8E=B0?= =?UTF-8?q?=E9=87=91=E6=94=AF=E4=BB=98=E7=9B=B4=E6=8E=A5=E5=8A=A0=E8=A7=A3?= =?UTF-8?q?=E5=86=BB=E7=A4=BC=E5=93=81=E5=88=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/logic/PayNotifyLogic.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index e5852bd60..b59545a3c 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -756,7 +756,25 @@ class PayNotifyLogic extends BaseLogic self::dealProductLog($order); if ($order['shipping_type'] == 3) { self::descStock($order['id']); + //直接加到礼品券中 + $user_sing = new UserSign(); + $total_vip = bcmul($order['price'], 0.1, 2); + $sing[] = [ + 'uid' => $order['uid'], + 'order_id' => $order['order_id'], + 'title' => 8, + 'financial_pm' => 1, + 'store_id' => $order['store_id'], + 'type' => 1, + 'status' => 1, + 'number' => $total_vip, + 'back_num' => $total_vip, + ]; + $user_sing->saveAll($sing); + User::where('id', $order->uid)->inc('integral', $total_vip)->update(); } + + // Redis::send('push-platform-print', ['id' => $order['id']]); return true; } @@ -1129,6 +1147,8 @@ class PayNotifyLogic extends BaseLogic return "兑换{$amount}元商品扣除礼品卷"; case 6: return "退款{$amount}元扣除礼品卷"; + case 8: + return "收银台支付{$amount}元增加礼品卷"; default: return "订单支付{$amount}元"; } From e63582acec9cfac06e0708cc9ec5f5dd713c3ff3 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Sat, 29 Jun 2024 15:52:12 +0800 Subject: [PATCH 020/115] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=85=91=E6=8D=A2?= =?UTF-8?q?=E5=88=B8=E9=80=BB=E8=BE=91=E5=92=8C=E5=A2=9E=E5=8A=A0=E6=B3=A8?= =?UTF-8?q?=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/logic/CommissionLogic.php | 2 +- app/common/logic/PayNotifyLogic.php | 148 +++++++++++++++------------ 2 files changed, 85 insertions(+), 65 deletions(-) diff --git a/app/common/logic/CommissionLogic.php b/app/common/logic/CommissionLogic.php index d569dc5ef..f866f4a8c 100644 --- a/app/common/logic/CommissionLogic.php +++ b/app/common/logic/CommissionLogic.php @@ -46,7 +46,7 @@ class CommissionLogic extends BaseLogic */ public static function setCook($order, $village_uid = 0, $brigade_uid = 0, $transaction_id = 0) { - $user_1 = self::user($order, 0.07, $transaction_id, 0, 12); //会员、厨师 + $user_1 = self::user($order, 0.07, $transaction_id, $order['spread_uid'], 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); //队长 diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index 5adc09b02..1c70f4805 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -142,7 +142,7 @@ class PayNotifyLogic extends BaseLogic $sing[] = [ 'uid' => $order['uid'], 'order_id' => $order['order_id'], -// 'title' => '订单扣除兑换券', + // 'title' => '订单扣除兑换券', 'title' => 5, 'financial_pm' => 0, 'store_id' => $order['store_id'], @@ -427,22 +427,22 @@ class PayNotifyLogic extends BaseLogic $orderRe->refund_time = time(); $orderRe->remarks = ''; $orderRe->save(); - $purchase_funds = User::where('id',$orderRe['uid'])->value('purchase_funds'); - $user = User::where('id',$orderRe['uid'])->find(); + $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['refund_price'])->update(); + if ($purchase_funds >= $orderRe['price']) { + 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(); + } 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::addNewUserSing($orderRe,3,$orderRe->refund_price);//冻结 + self::addNewUserSing($orderRe, 3, $orderRe->refund_price); //冻结 - self::addNewUserSing($orderRe,6,$orderRe->refund_price,0,1);//解冻 + self::addNewUserSing($orderRe, 6, $orderRe->refund_price, 0, 1); //解冻 self::descUserSing($orderRe); -// d($purchase_funds,$orderRe['refund_price'],$orderRe); + // d($purchase_funds,$orderRe['refund_price'],$orderRe); return true; } $order->status = OrderEnum::REFUND_PAY; @@ -476,16 +476,16 @@ class PayNotifyLogic extends BaseLogic } if ($check_user_sing) { //退还 兑换券 - self::addNewUserSing($order,3,$order->refund_price);//冻结 - self::addNewUserSing($order,6,$order->refund_price,0,1);//解冻 + self::addNewUserSing($order, 3, $order->refund_price); //冻结 + self::addNewUserSing($order, 6, $order->refund_price, 0, 1); //解冻 self::descUserSing($order); } return true; } //积分 if ($check_user_sing) { - self::addNewUserSing($order,3,$order->refund_price);//冻结 - self::addNewUserSing($order,6,$order->refund_price,0,1);//解冻 + self::addNewUserSing($order, 3, $order->refund_price); //冻结 + self::addNewUserSing($order, 6, $order->refund_price, 0, 1); //解冻 self::descUserSing($order); } //微信日志 user_order_refund @@ -507,14 +507,14 @@ class PayNotifyLogic extends BaseLogic * @type $type //类型 0冻结 1解冻 * @return true */ - public static function addNewUserSing($order, $category, $number, int $pm=0, $type=0) + public static function addNewUserSing($order, $category, $number, int $pm = 0, $type = 0) { $user_sing = new UserSign(); $sing = [ 'uid' => $order['uid'], 'order_id' => $order['order_id'], -// 'title' => '购买商品获得兑换券', -// 'title' => PayNotifyLogic::getTitle($category,$number), + // 'title' => '购买商品获得兑换券', + // 'title' => PayNotifyLogic::getTitle($category,$number), 'title' => $category, 'financial_pm' => $pm, 'store_id' => $order['store_id'], @@ -531,23 +531,23 @@ class PayNotifyLogic extends BaseLogic //退积分-->订单 public static function descUserSing($order) { -// $user_sing = new UserSign(); + // $user_sing = new UserSign(); if ($order['uid'] > 0) { $user_number = bcmul($order['refund_price'], '0.10', 2); -// $sing = [ -// 'uid' => $order['uid'], -// 'order_id' => $order['order_id'], -// 'title' => '退款扣除兑换券', -// 'financial_pm' => 0, -// 'store_id' => $order['store_id'], -// 'number' => $user_number, -// ]; -// $user_sing->save($sing); -// //删除之前获得的兑换券 -// UserSign::where([ -// 'order_id' => $order['order_id'], -// 'financial_pm' => 1, -// ])->update(['delete_time' => time()]); + // $sing = [ + // 'uid' => $order['uid'], + // 'order_id' => $order['order_id'], + // 'title' => '退款扣除兑换券', + // 'financial_pm' => 0, + // 'store_id' => $order['store_id'], + // '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'])->withTrashed()->find(); if ($now_int) { @@ -646,12 +646,12 @@ class PayNotifyLogic extends BaseLogic $sing[] = [ 'uid' => $order['uid'], 'order_id' => $order['order_id'], -// 'title' => '充值获得冻结兑换券', -// 'title' => self::getTitle(7,$total_vip), - 'title' =>7, + // 'title' => '充值获得冻结兑换券', + // 'title' => self::getTitle(7,$total_vip), + 'title' => 7, 'financial_pm' => 1, 'store_id' => $order['store_id'], -// 'type' => 1, + // 'type' => 1, 'status' => 1, 'number' => $total_vip, 'back_num' => $total_vip, @@ -660,8 +660,8 @@ class PayNotifyLogic extends BaseLogic $sing[] = [ 'uid' => $order['uid'], 'order_id' => $order['order_id'], -// 'title' => '充值获得冻结兑换券', -// 'title' => self::getTitle(4,$total_vip), + // 'title' => '充值获得冻结兑换券', + // 'title' => self::getTitle(4,$total_vip), 'title' => 4, 'financial_pm' => 1, 'store_id' => $order['store_id'], @@ -826,15 +826,17 @@ 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(); - $user_ship = User::where('id', $order['uid'])->value('user_ship');//会员不加兑换券 - if ($order['uid'] > 0 && $order['total_price'] >= 500 - && $order['pay_type'] !=PayEnum::PURCHASE_FUNDS && $user_ship !=1) { + $user_ship = User::where('id', $order['uid'])->value('user_ship'); //会员不加兑换券 + if ( + $order['uid'] > 0 && $order['total_price'] >= 500 + && $order['pay_type'] != PayEnum::PURCHASE_FUNDS && $user_ship != 1 + ) { $user_number = bcmul($order['pay_price'], '0.10', 2); $sing = [ 'uid' => $order['uid'], 'order_id' => $order['order_id'], -// 'title' => '购买商品获得兑换券', -// 'title' => self::getTitle(1,$user_number), + // 'title' => '购买商品获得兑换券', + // 'title' => self::getTitle(1,$user_number), 'title' => 1, 'financial_pm' => 1, 'store_id' => $order['store_id'], @@ -874,21 +876,41 @@ class PayNotifyLogic extends BaseLogic } } - //查询用户对应的村长和队长 - $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; - } - } - if ($order['spread_uid'] > 0 || $user_ship>0) { - if($order['spread_uid'] > 0 && $user_ship == 0){ + 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'); + if ($user_ship == 2) { + $village_uid = $order['spread_uid']; + $address = UserAddress::where(['uid' => $order['spread_uid'], 'is_default' => 1])->find(); + if ($address) { + $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; + } + } + } elseif ($user_ship == 3) { + $brigade_uid = $order['spread_uid']; + $address = UserAddress::where(['uid' => $order['spread_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; + } + } + } + } else { + //查询用户对应的村长和队长 + $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; + } + } } switch ($user_ship) { case 1: // 行业会员 @@ -1109,8 +1131,8 @@ class PayNotifyLogic extends BaseLogic public static function getTitle($category, $amount) { switch ($category) { - /**冻结券**/ - //收入 + /**冻结券**/ + //收入 case 1: return "购买商品{$amount}元获得冻结卷"; case 7: @@ -1120,11 +1142,11 @@ class PayNotifyLogic extends BaseLogic return "核销商品{$amount}元解冻冻结卷"; case 3: return "退款{$amount}元扣除冻结卷"; - /**礼品券**/ - //收入 + /**礼品券**/ + //收入 case 4: return "核销金额{$amount}元获得礼品卷"; - //支出 + //支出 case 5: return "兑换{$amount}元商品扣除礼品卷"; case 6: @@ -1133,6 +1155,4 @@ class PayNotifyLogic extends BaseLogic return "订单支付{$amount}元"; } } - - } From e81368017089dcc674f7525407bf4faf837292c4 Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Sat, 29 Jun 2024 15:53:04 +0800 Subject: [PATCH 021/115] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=8F=96=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/logic/PayNotifyLogic.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index b59545a3c..7606ea4ad 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -754,11 +754,12 @@ class PayNotifyLogic extends BaseLogic $cashFlowLogic = new CashFlowLogic(); $cashFlowLogic->insert($order['store_id'], $order['pay_price']); self::dealProductLog($order); + if ($order['shipping_type'] == 3) { self::descStock($order['id']); //直接加到礼品券中 $user_sing = new UserSign(); - $total_vip = bcmul($order['price'], 0.1, 2); + $total_vip = bcmul($order['pay_price'], 0.1, 2); $sing[] = [ 'uid' => $order['uid'], 'order_id' => $order['order_id'], From b63052f6047135e818028d851398e960cd9368c4 Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Sat, 29 Jun 2024 16:10:04 +0800 Subject: [PATCH 022/115] =?UTF-8?q?=E5=9B=9E=E8=B0=83=E6=97=A5=E5=BF=97?= =?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/common/logic/PayNotifyLogic.php | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index adcef5d72..b7edff3d2 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -404,6 +404,13 @@ class PayNotifyLogic extends BaseLogic self::dealProductLog($order); if ($order['shipping_type'] == 3) { self::descStock($order['id']); + //直接加对应兑换券 + if ($order->uid >0) { + $total_vip = bcmul($order['pay_price'], 0.1, 2); + self::addNewUserSing($order,8,$total_vip,1,1); + User::where('id', $order->uid)->inc('integral', $total_vip)->update(); + } + } if (!empty($extra['payer']['openid']) && $order->pay_type == 7) { Redis::send('push-delivery', ['order_id' => $order['order_id'], 'openid' => $extra['payer']['openid']], 4); @@ -811,6 +818,13 @@ class PayNotifyLogic extends BaseLogic self::dealProductLog($order); if ($order['shipping_type'] == 3) { self::descStock($order['id']); + //直接加兑换券到对应得账户 + if ($order->uid >0) { + $total_vip = bcmul($order['pay_price'], 0.1, 2); + self::addNewUserSing($order,8,$total_vip,1,1); + User::where('id', $order->uid)->inc('integral', $total_vip)->update(); + } + } // if ($order->pay_type == 9) { @@ -848,7 +862,7 @@ class PayNotifyLogic extends BaseLogic $user_ship = User::where('id', $order['uid'])->value('user_ship'); //会员不加兑换券 if ( $order['uid'] > 0 && $order['total_price'] >= 500 - && $order['pay_type'] != PayEnum::PURCHASE_FUNDS && $user_ship != 1 + && $order['pay_type'] != PayEnum::PURCHASE_FUNDS && $user_ship != 1 && $order['shipping_type'] !=3 ) { $user_number = bcmul($order['pay_price'], '0.10', 2); $sing = [ @@ -871,7 +885,8 @@ class PayNotifyLogic extends BaseLogic //用户下单该用户等级为1得时候才处理冻结金额 $user = User::where('id', $order['uid'])->find(); $user_ship = $user['user_ship']; - if($order['total_price'] >= 500 && $order['pay_type'] !=PayEnum::PURCHASE_FUNDS && $user_ship !=1){ + if($order['total_price'] >= 500 && $order['pay_type'] !=PayEnum::PURCHASE_FUNDS && $user_ship !=1 + && $order['shipping_type'] !=3){ $user_number = bcmul($order['pay_price'], '0.10', 2); $sing = [ 'uid' => $order['uid'], From 01f0dab6de2fcd4ecf63dff3ff9e1422f1f5ca53 Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Sat, 29 Jun 2024 16:13:34 +0800 Subject: [PATCH 023/115] =?UTF-8?q?=E9=A2=84=E7=95=99=E4=BD=99=E9=A2=9D?= =?UTF-8?q?=E6=94=AF=E4=BB=98=E5=85=91=E6=8D=A2=E5=88=B8=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 | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index b7edff3d2..67bccf421 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -94,9 +94,15 @@ 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) { + //预留收银台余额支付得兑换券逻辑 + if ($order->uid >0) { + $total_vip = bcmul($order['pay_price'], 0.1, 2); + self::addNewUserSing($order,8,$total_vip,1,1); + User::where('id', $order->uid)->inc('integral', $total_vip)->update(); + } +// self::descStock($order['id']); + } self::afterPay($order); if ($extra && $extra['store_id']) { $params = [ From 1761d038b47a9e1fe92442d425d4b6cb60b3aa0c Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Sat, 29 Jun 2024 16:19:45 +0800 Subject: [PATCH 024/115] =?UTF-8?q?=E8=AE=A2=E5=8D=95=E5=95=86=E5=AE=B6?= =?UTF-8?q?=E5=B1=95=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/lists/store_order/StoreOrderLists.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/admin/lists/store_order/StoreOrderLists.php b/app/admin/lists/store_order/StoreOrderLists.php index 39c010c45..3da16980b 100644 --- a/app/admin/lists/store_order/StoreOrderLists.php +++ b/app/admin/lists/store_order/StoreOrderLists.php @@ -30,7 +30,7 @@ class StoreOrderLists extends BaseAdminDataLists implements ListsSearchInterface public function setSearch(): array { return [ - '=' => ['order_id', 'pay_type', 'staff_id', 'shipping_type', 'delivery_id','paid', 'status', 'is_writeoff'], + '=' => ['order_id','store_id', 'pay_type', 'staff_id', 'shipping_type', 'delivery_id','paid', 'status', 'is_writeoff'], 'between_time' => 'create_time' ]; } @@ -47,7 +47,7 @@ class StoreOrderLists extends BaseAdminDataLists implements ListsSearchInterface */ public function lists(): array { - return StoreOrder::with(['staff'])->where($this->searchWhere) + return StoreOrder::with(['staff','store'])->where($this->searchWhere) ->when(!empty($this->request->adminInfo['store_id']), function ($query) { $query->where('store_id', $this->request->adminInfo['store_id']); }) From 4177bf71edc604ef9d7bd4aeb946e347879f8228 Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Sat, 29 Jun 2024 16:36:59 +0800 Subject: [PATCH 025/115] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=8F=96=E5=80=BC?= =?UTF-8?q?=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/logic/order/OrderLogic.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index 8ad7e2586..bb935fa49 100644 --- a/app/api/logic/order/OrderLogic.php +++ b/app/api/logic/order/OrderLogic.php @@ -416,7 +416,7 @@ class OrderLogic extends BaseLogic } Db::startTrans(); try { - StoreOrder::update([ + StoreOrder::update([ 'verify_code'=>$params['verify_code'].'-1', 'status' => OrderEnum::RECEIVED_GOODS, 'is_writeoff' => OrderEnum::IS_OK, @@ -454,7 +454,7 @@ class OrderLogic extends BaseLogic if ($order['spread_uid'] > 0) { $spread_find=$financeFlow->where(['order_id'=>$order['id'],'financial_pm'=>1,'financial_type'=>12,'other_uid'=>$order['spread_uid']])->find(); if($spread_find){ - $financeFlowLogic->updateStatusUser($spread_find['id'],$order['spread_uid'],$spread_find['number'],$order['order_id']); + $financeFlowLogic->updateStatusUser($spread_find['id'],$order['spread_uid'],$spread_find['number'],$order['id']); } } $deposit=$financeFlow->where(['order_id'=>$order['id'],'financial_pm'=>1,'financial_type'=>11])->value('number')??0; From 2ae18e951c4716a8bd06caaf5ab92e80fb62251c Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Sat, 29 Jun 2024 16:49:16 +0800 Subject: [PATCH 026/115] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E6=94=AF?= =?UTF-8?q?=E4=BB=98=E9=80=9A=E7=9F=A5=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../UserProductStorageController.php | 46 +++++++++++++++++++ .../UserProductStorageLogic.php | 10 +++- 2 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 app/api/controller/user_product_storage/UserProductStorageController.php diff --git a/app/api/controller/user_product_storage/UserProductStorageController.php b/app/api/controller/user_product_storage/UserProductStorageController.php new file mode 100644 index 000000000..806a56204 --- /dev/null +++ b/app/api/controller/user_product_storage/UserProductStorageController.php @@ -0,0 +1,46 @@ +dataLists(new UserProductStorageLists()); + } + + /** + * 预约 + */ + public function reservation(){ + + $params=$this->request->post(); + $info=$params['info']; + $uid=$this->userId; + $store_id=$params['store_id']; + $times=$params['times']; + UserProductStorageLogic::supply($info,$uid,$store_id,0,$times); + if(UserProductStorageLogic::hasError()){ + return $this->fail(UserProductStorageLogic::getError()); + } + return $this->success('操作成功'); + } +} \ No newline at end of file diff --git a/app/common/logic/user_product_storage/UserProductStorageLogic.php b/app/common/logic/user_product_storage/UserProductStorageLogic.php index ed775d912..27d4c9cff 100644 --- a/app/common/logic/user_product_storage/UserProductStorageLogic.php +++ b/app/common/logic/user_product_storage/UserProductStorageLogic.php @@ -39,10 +39,13 @@ class UserProductStorageLogic extends BaseLogic /** * 出库 */ - public static function supply($data,$uid,$store_id){ + public static function supply($data,$uid,$store_id,$status=1,$times=''){ Db::startTrans(); try { $data_log=[]; + if($times!=''){ + $times=strtotime($times); + } foreach ($data as $k=>$v){ $find=UserProductStorage::where('uid',$uid)->where('product_id',$v['product_id'])->find(); if($find){ @@ -62,6 +65,11 @@ class UserProductStorageLogic extends BaseLogic $data_log[$k]['store_id']=$store_id; $data_log[$k]['financial_pm']=0; $data_log[$k]['nums']=$v['nums']; + $data_log[$k]['times']=$times; + $data_log[$k]['status']=$status; + }else{ + self::setError('没有查询到该商品'); + return false; } } (new UserProductStorageLog())->saveAll($data_log); From 04e8f6ecccbb4f664f2bce0949091f853c3955d4 Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Sat, 29 Jun 2024 16:50:24 +0800 Subject: [PATCH 027/115] =?UTF-8?q?=E5=88=9B=E5=BB=BA=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E6=9C=80=E8=BF=91=E5=BA=97=E9=93=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/logic/order/OrderLogic.php | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index bb935fa49..de3534856 100644 --- a/app/api/logic/order/OrderLogic.php +++ b/app/api/logic/order/OrderLogic.php @@ -166,11 +166,30 @@ class OrderLogic extends BaseLogic $order['is_vip'] = 1; } + //处理返回最近的店铺 + $store['near_store'] = []; + if($params['lat'] && $params['long']){ + $storeAll = SystemStore::field('id,name,phone,address,detailed_address,latitude,longitude')->select()->toArray(); + $nearestStore = null; + $minDistance = PHP_FLOAT_MAX; + foreach ($storeAll as $value){ + $value['distance'] = haversineDistance($value['latitude'],$value['longitude'],$params['lat'] ,$params['long']); + if ($value['distance'] < $minDistance) { + $minDistance = $value['distance']; + $nearestStore = $value; + } + } + if ($nearestStore) { + $store['near_store'] =$nearestStore; + } + + } + } catch (\Exception $e) { self::setError($e->getMessage()); return false; } - return ['order' => $order, 'cart_list' => $cart_select]; + return ['order' => $order, 'cart_list' => $cart_select,'shopInfo'=>$store]; } /** From fb7a7fe68ff0fb71088956ae1f5e3088330397ed Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Sat, 29 Jun 2024 16:52:03 +0800 Subject: [PATCH 028/115] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/logic/order/OrderLogic.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index de3534856..fa680a536 100644 --- a/app/api/logic/order/OrderLogic.php +++ b/app/api/logic/order/OrderLogic.php @@ -189,7 +189,7 @@ class OrderLogic extends BaseLogic self::setError($e->getMessage()); return false; } - return ['order' => $order, 'cart_list' => $cart_select,'shopInfo'=>$store]; + return ['order' => $order, 'cart_list' => $cart_select,'shopInfo'=>$store['near_store']]; } /** From 9ac84ac72fc7768c55c972397c005bdac8f47c47 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Sat, 29 Jun 2024 17:16:56 +0800 Subject: [PATCH 029/115] =?UTF-8?q?feat:=20=E5=88=9B=E5=BB=BA=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E5=95=86=E5=93=81=E5=AD=98=E5=82=A8=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E7=B1=BBUserProductStorageLists?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../UserProductStorageLists.php | 92 +++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 app/api/lists/user_product_storage/UserProductStorageLists.php diff --git a/app/api/lists/user_product_storage/UserProductStorageLists.php b/app/api/lists/user_product_storage/UserProductStorageLists.php new file mode 100644 index 000000000..674f9e6e9 --- /dev/null +++ b/app/api/lists/user_product_storage/UserProductStorageLists.php @@ -0,0 +1,92 @@ + ['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 + { + $status=$this->request->get('status',1); + if($status==1){ + $this->searchWhere[]=['status','=',1];//只显示正常状态的记录,不显示已出库完的记录 + $field='id,uid,oid,product_id,sum(nums) nums,status,create_time'; + $group='product_id'; + }else{ + $field='id,uid,oid,product_id,nums,status,create_time'; + $group=null; + } + $this->searchWhere[]=['uid','=',$this->userId]; + return UserProductStorage::where($this->searchWhere) + ->field($field) + ->group($group) + ->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']; + $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{ + $item['status_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 From 9d27d32f370e06d2c690753cc380c7521fa0606a Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Sat, 29 Jun 2024 17:31:24 +0800 Subject: [PATCH 030/115] =?UTF-8?q?=E6=A3=80=E9=AA=8C=E4=B8=8B=E5=8D=95?= =?UTF-8?q?=E5=BE=97=E5=88=9B=E5=BB=BA=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/order/OrderController.php | 15 +++++++ app/api/logic/order/OrderLogic.php | 47 ++++++++++++++++++++ app/api/validate/OrderValidate.php | 7 +++ 3 files changed, 69 insertions(+) diff --git a/app/api/controller/order/OrderController.php b/app/api/controller/order/OrderController.php index 6e6e9e17b..1e2835ed7 100644 --- a/app/api/controller/order/OrderController.php +++ b/app/api/controller/order/OrderController.php @@ -99,6 +99,21 @@ class OrderController extends BaseApiController return $this->data($res); } + public function checkInventory() + { + $params = (new OrderValidate())->post()->goCheck('cart'); + $res = OrderLogic::checkLeft($params, $this->userId); + if (!$res) { + $msg = OrderLogic::getError(); + if ($msg == '购物车为空') { + return $this->data([]); + } + return $this->fail(OrderLogic::getError()); + } + return $this->data($res); + } + + /** * 创建订单 */ diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index fa680a536..0b2475af9 100644 --- a/app/api/logic/order/OrderLogic.php +++ b/app/api/logic/order/OrderLogic.php @@ -216,6 +216,7 @@ class OrderLogic extends BaseLogic $_order['pay_type'] = $orderInfo['order']['pay_type']; $_order['verify_code'] = $verify_code; $_order['reservation_time'] = null; + $_order['reservation'] = $params['reservation']??0;//是否需要预约 if (isset($params['reservation_time']) && $params['reservation_time']) { $_order['reservation_time'] = $params['reservation_time']; $_order['reservation'] = YesNoEnum::YES; @@ -264,6 +265,52 @@ class OrderLogic extends BaseLogic } } + /** + * 检验丢失 + * @param $params + * @return array|false + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + */ + public static function checkLeft($params,$uid) + { + $where = ['is_pay' => 0]; + $cart_select = Cart::whereIn('id', $params['cart_id']) + ->where($where)->field('id,product_id,cart_num,store_id')->select()->toArray(); + if (empty($cart_select)) { + self::setError('购物车为空'); + return false; + } + $newArr = []; + //检查购物车对比店铺得商品数量差异 + foreach ($cart_select as $v) { + $store = StoreBranchProduct::where([ + 'store_id'=>$v['store_id'], + 'product_id'=>$v['product_id'], + ])->field('id,store_name,stock')->withTrashed()->find(); + if($store['stock'] < $v['cart_num']){ + //缺失 + $newArr[] = [ + 'uid'=>$uid, + 'store_id'=>$v['store_id'], + 'product_id'=>$v['product_id'], + 'missing_quantity'=> $v['cart_num'] - $store['stock'] + ]; + } + } + + if($newArr){ + return [ + 'detail'=>$newArr, + 'reservation'=>1 + ]; + } + return [ + 'detail'=>[], + 'reservation'=>0 + ]; + } /** * @notes 获取订单号 diff --git a/app/api/validate/OrderValidate.php b/app/api/validate/OrderValidate.php index f223800f6..7d518c202 100644 --- a/app/api/validate/OrderValidate.php +++ b/app/api/validate/OrderValidate.php @@ -23,6 +23,7 @@ class OrderValidate extends BaseValidate 'id' => 'require|number', 'old_cart_id' => 'require|array', 'refund_type' => 'require|number', + 'cart_id' => 'require', ]; @@ -37,8 +38,14 @@ class OrderValidate extends BaseValidate 'id' => '订单id', 'old_cart_id' => '购物车id', 'refund_type' => '退款申请类型', + 'cart_id' => '购物车id', ]; + public function sceneCart() + { + return $this->only(['cart_id']); + } + /** * @notes 添加场景 From e702f786fd7841c5c5fb4206290d67940adfc7e8 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Sat, 29 Jun 2024 17:38:18 +0800 Subject: [PATCH 031/115] =?UTF-8?q?feat(config):=20=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E5=99=A8=E7=9B=91=E5=90=AC=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../logic/user_product_storage/UserProductStorageLogic.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/common/logic/user_product_storage/UserProductStorageLogic.php b/app/common/logic/user_product_storage/UserProductStorageLogic.php index 27d4c9cff..1c15f4b3e 100644 --- a/app/common/logic/user_product_storage/UserProductStorageLogic.php +++ b/app/common/logic/user_product_storage/UserProductStorageLogic.php @@ -51,6 +51,7 @@ class UserProductStorageLogic extends BaseLogic if($find){ if($find['nums']<$v['nums']){ self::setError('库存不足'); + Db::commit(); return false; } $nums=bcsub($find['nums'],$v['nums']); @@ -69,6 +70,7 @@ class UserProductStorageLogic extends BaseLogic $data_log[$k]['status']=$status; }else{ self::setError('没有查询到该商品'); + Db::commit(); return false; } } From 82a4fddcfeaad06cd43e07a74ee433ba94156bce Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Sat, 29 Jun 2024 18:04:21 +0800 Subject: [PATCH 032/115] =?UTF-8?q?=E5=A4=84=E7=90=86=E5=B0=8F=E7=A8=8B?= =?UTF-8?q?=E5=BA=8F=E6=96=B0=E5=A2=9E=E8=AE=A2=E5=8D=95=E5=95=86=E5=93=81?= =?UTF-8?q?=E7=BC=BA=E5=A4=B1=E6=96=B0=E5=A2=9E=E5=88=B0=E7=BC=BA=E5=A4=B1?= =?UTF-8?q?=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/logic/order/OrderLogic.php | 7 ++++-- app/common/logic/PayNotifyLogic.php | 37 +++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index 0b2475af9..c34a390fa 100644 --- a/app/api/logic/order/OrderLogic.php +++ b/app/api/logic/order/OrderLogic.php @@ -273,9 +273,12 @@ class OrderLogic extends BaseLogic * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ - public static function checkLeft($params,$uid) + public static function checkLeft($params,$uid,$type =0) { - $where = ['is_pay' => 0]; + $where = []; + if(empty($type)){ + $where = ['is_pay' => 0]; + } $cart_select = Cart::whereIn('id', $params['cart_id']) ->where($where)->field('id,product_id,cart_num,store_id')->select()->toArray(); if (empty($cart_select)) { diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index 67bccf421..d72900ca9 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -104,6 +104,9 @@ class PayNotifyLogic extends BaseLogic // self::descStock($order['id']); } self::afterPay($order); + if($order['reservation'] == 1&& in_array($order['shipping_type'],[1,2])){ + self::dealGoodsLeft($order['cart_id'],$order['uid'],$order['id']); + } if ($extra && $extra['store_id']) { $params = [ 'verify_code' => $order['verify_code'], @@ -215,6 +218,10 @@ class PayNotifyLogic extends BaseLogic OrderLogic::writeOff($params); } self::dealProductLog($order); + if($order['reservation'] == 1&& in_array($order['shipping_type'],[1,2])){ + self::dealGoodsLeft($order['cart_id'],$order['uid'],$order['id']); + } + // $count = UserSign::where([ // 'uid'=>$order['uid'], // 'type'=>1, @@ -405,6 +412,9 @@ class PayNotifyLogic extends BaseLogic $capitalFlowDao->userExpense('user_order_pay', 'order', $order['id'], $order->pay_price, '', 1, $order['store_id']); } $order->save(); + if($order['reservation'] == 1&& in_array($order['shipping_type'],[1,2])){ + self::dealGoodsLeft($order['cart_id'],$order['uid'],$order['id']); + } self::afterPay($order, $extra['transaction_id']); // self::addUserSing($order); self::dealProductLog($order); @@ -1167,6 +1177,33 @@ class PayNotifyLogic extends BaseLogic } + /** + * 处理商品缺失新增到缺失列表 + * @param $cart_id //购物车ids + * @param $uid //用户id + * @param $oid //订单id + * @return void + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + */ + public static function dealGoodsLeft($cart_id,$uid,$oid) + { + $cart_id['cart_id'] = explode(',',$cart_id); + $data = OrderLogic::checkLeft($cart_id,$uid,1); + $format = $data['detail']; + foreach ($format as &$value){ + $value['oid'] =$oid; + $value['create_time'] =time(); + } + Db::name('store_product_miss')->insertAll($format); + + } + + + + + //礼品券相关对应文本 public static function getTitle($category, $amount) { From 4268069a1696f005e3270e5580dcda3e786879e5 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Sat, 29 Jun 2024 18:25:46 +0800 Subject: [PATCH 033/115] =?UTF-8?q?feat(config):=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E5=99=A8=E7=9B=91=E5=90=AC=E5=9C=B0=E5=9D=80?= =?UTF-8?q?=E4=B8=BA=E7=8E=AF=E5=A2=83=E5=8F=98=E9=87=8FHOST?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/server.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/server.php b/config/server.php index fb3af3c30..3b49e4ce2 100644 --- a/config/server.php +++ b/config/server.php @@ -13,7 +13,7 @@ */ return [ - 'listen' => 'http://0.0.0.0:8545', + 'listen' => getenv('HOST'), 'transport' => 'tcp', 'context' => [], 'name' => 'webman', From fab1cb9b3bff7e144c9ccfd36ff81d6bbee9e664 Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Mon, 1 Jul 2024 09:19:25 +0800 Subject: [PATCH 034/115] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=88=9B=E5=BB=BA?= =?UTF-8?q?=E8=AE=A2=E5=8D=95=E8=87=AA=E6=8F=90=E6=A0=A1=E9=AA=8C=E5=BE=97?= =?UTF-8?q?=E9=80=BB=E8=BE=91=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/logic/order/OrderLogic.php | 4 ++-- app/api/validate/OrderValidate.php | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index c34a390fa..8c1bfc471 100644 --- a/app/api/logic/order/OrderLogic.php +++ b/app/api/logic/order/OrderLogic.php @@ -289,14 +289,14 @@ class OrderLogic extends BaseLogic //检查购物车对比店铺得商品数量差异 foreach ($cart_select as $v) { $store = StoreBranchProduct::where([ - 'store_id'=>$v['store_id'], + 'store_id'=>$params['store_id'], 'product_id'=>$v['product_id'], ])->field('id,store_name,stock')->withTrashed()->find(); if($store['stock'] < $v['cart_num']){ //缺失 $newArr[] = [ 'uid'=>$uid, - 'store_id'=>$v['store_id'], + 'store_id'=>$params['store_id'], 'product_id'=>$v['product_id'], 'missing_quantity'=> $v['cart_num'] - $store['stock'] ]; diff --git a/app/api/validate/OrderValidate.php b/app/api/validate/OrderValidate.php index 7d518c202..ca8a6ec38 100644 --- a/app/api/validate/OrderValidate.php +++ b/app/api/validate/OrderValidate.php @@ -24,6 +24,7 @@ class OrderValidate extends BaseValidate 'old_cart_id' => 'require|array', 'refund_type' => 'require|number', 'cart_id' => 'require', + 'store_id' => 'require', ]; @@ -39,11 +40,12 @@ class OrderValidate extends BaseValidate 'old_cart_id' => '购物车id', 'refund_type' => '退款申请类型', 'cart_id' => '购物车id', + 'store_id' => '店铺id', ]; public function sceneCart() { - return $this->only(['cart_id']); + return $this->only(['cart_id','store_id']); } From 677eaf781da96bd1b4f554a7560682ac11244f5e Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Mon, 1 Jul 2024 09:23:37 +0800 Subject: [PATCH 035/115] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=9B=9E=E8=B0=83?= =?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 | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index d72900ca9..20fb69e4a 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -105,7 +105,11 @@ class PayNotifyLogic extends BaseLogic } self::afterPay($order); if($order['reservation'] == 1&& in_array($order['shipping_type'],[1,2])){ - self::dealGoodsLeft($order['cart_id'],$order['uid'],$order['id']); + $checkArr =[ + 'cart_id'=>$order['cart_id'], + 'store_id'=>$order['store_id'], + ]; + self::dealGoodsLeft($checkArr,$order['uid'],$order['id']); } if ($extra && $extra['store_id']) { $params = [ @@ -219,7 +223,11 @@ class PayNotifyLogic extends BaseLogic } self::dealProductLog($order); if($order['reservation'] == 1&& in_array($order['shipping_type'],[1,2])){ - self::dealGoodsLeft($order['cart_id'],$order['uid'],$order['id']); + $checkArr =[ + 'cart_id'=>$order['cart_id'], + 'store_id'=>$order['store_id'], + ]; + self::dealGoodsLeft($checkArr,$order['uid'],$order['id']); } // $count = UserSign::where([ @@ -413,7 +421,11 @@ class PayNotifyLogic extends BaseLogic } $order->save(); if($order['reservation'] == 1&& in_array($order['shipping_type'],[1,2])){ - self::dealGoodsLeft($order['cart_id'],$order['uid'],$order['id']); + $checkArr =[ + 'cart_id'=>$order['cart_id'], + 'store_id'=>$order['store_id'], + ]; + self::dealGoodsLeft($checkArr,$order['uid'],$order['id']); } self::afterPay($order, $extra['transaction_id']); // self::addUserSing($order); From a1504ba09095f2e59a9ceae7f04ae63a668cd2a0 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Mon, 1 Jul 2024 09:25:33 +0800 Subject: [PATCH 036/115] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E7=BB=8F?= =?UTF-8?q?=E7=BA=AC=E5=BA=A6=E5=88=A4=E6=96=AD=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 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index c34a390fa..798b7983c 100644 --- a/app/api/logic/order/OrderLogic.php +++ b/app/api/logic/order/OrderLogic.php @@ -168,7 +168,7 @@ class OrderLogic extends BaseLogic } //处理返回最近的店铺 $store['near_store'] = []; - if($params['lat'] && $params['long']){ + if((isset($params['lat'])&&$params['lat']!='')&&(isset($params['long']) &&$params['lat']!='')){ $storeAll = SystemStore::field('id,name,phone,address,detailed_address,latitude,longitude')->select()->toArray(); $nearestStore = null; $minDistance = PHP_FLOAT_MAX; From 00f71306b5c4c4bb3e83ec418ae6bbfb58e37fc7 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Mon, 1 Jul 2024 09:41:04 +0800 Subject: [PATCH 037/115] =?UTF-8?q?feat(UserShipLists):=20=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E7=94=A8=E6=88=B7=E7=AD=89=E7=BA=A7=E9=99=90=E5=88=B6?= =?UTF-8?q?=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 +- app/common/lists/user/UserShipLists.php | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/app/api/controller/user/UserController.php b/app/api/controller/user/UserController.php index 82e0e16be..12a550175 100644 --- a/app/api/controller/user/UserController.php +++ b/app/api/controller/user/UserController.php @@ -279,7 +279,7 @@ class UserController extends BaseApiController $user['address_info']=$address; return $this->success('ok',$user->toArray()); }else{ - return $this->fail('用户不存在'); + return $this->fail('用户不存在',[],0,0); } } return $this->success('ok',[]); diff --git a/app/common/lists/user/UserShipLists.php b/app/common/lists/user/UserShipLists.php index 8356504b1..325f25b35 100644 --- a/app/common/lists/user/UserShipLists.php +++ b/app/common/lists/user/UserShipLists.php @@ -37,12 +37,10 @@ class UserShipLists extends BaseAdminDataLists public function lists(): array { - $field = "id,title"; + $field = "id,title,limit"; $arr=[]; - if($this->request->__get('id')){ - $this->searchWhere[]=['id','in',[1,4]]; - }else{ - $arr[]=['id'=>0,'title'=>'一般用户']; + if(!$this->request->__get('id')){ + $arr[]=['id'=>0,'title'=>'一般用户','limit'=>0]; } $lists = UserShip::where($this->searchWhere) ->limit($this->limitOffset, $this->limitLength) From 6a87e5870568173110bf0484141a6d3f91e70e56 Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Mon, 1 Jul 2024 09:42:49 +0800 Subject: [PATCH 038/115] =?UTF-8?q?=E5=85=BC=E5=AE=B9=E5=BA=97=E9=93=BA?= =?UTF-8?q?=E6=97=A0=E5=95=86=E5=93=81=E5=BE=97=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 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index d68fbee83..56b8d6479 100644 --- a/app/api/logic/order/OrderLogic.php +++ b/app/api/logic/order/OrderLogic.php @@ -292,6 +292,9 @@ class OrderLogic extends BaseLogic 'store_id'=>$params['store_id'], 'product_id'=>$v['product_id'], ])->field('id,store_name,stock')->withTrashed()->find(); + if(empty($store)){ + $store['stock'] =0; + } if($store['stock'] < $v['cart_num']){ //缺失 $newArr[] = [ From 0838dba50746ec79f740c9499c92691901f6fe57 Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Mon, 1 Jul 2024 10:00:49 +0800 Subject: [PATCH 039/115] =?UTF-8?q?=E6=80=BB=E5=90=8E=E5=8F=B0=E9=99=90?= =?UTF-8?q?=E5=88=B6=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/lists/store_product/StoreProductLists.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/admin/lists/store_product/StoreProductLists.php b/app/admin/lists/store_product/StoreProductLists.php index cdaa4ba66..338ab1517 100644 --- a/app/admin/lists/store_product/StoreProductLists.php +++ b/app/admin/lists/store_product/StoreProductLists.php @@ -29,7 +29,8 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa public function setSearch(): array { return [ - '=' => ['cate_id'], + '=' => ['cate_id','is_show'], + '<='=> ['stock'], '%like%' => ['store_name'], ]; } From 229725c4499241ab2c50103165c8b3112d2b1de2 Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Mon, 1 Jul 2024 10:47:03 +0800 Subject: [PATCH 040/115] =?UTF-8?q?=E6=8C=89=E7=85=A7=E6=AF=94=E4=BE=8B?= =?UTF-8?q?=E9=A2=84=E8=AE=BE=E9=80=80=E5=85=91=E6=8D=A2=E5=88=B8=E5=92=8C?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=85=91=E6=8D=A2=E5=88=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/logic/order/OrderLogic.php | 4 +- app/common/logic/PayNotifyLogic.php | 65 +++++++++++++++++++++++------ 2 files changed, 55 insertions(+), 14 deletions(-) diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index 56b8d6479..f3ced1881 100644 --- a/app/api/logic/order/OrderLogic.php +++ b/app/api/logic/order/OrderLogic.php @@ -514,7 +514,9 @@ class OrderLogic extends BaseLogic } } if($order['uid'] && $order['pay_price'] >= 500){ - $user_number = bcmul($order['pay_price'], '0.10', 2); + $level = User::where('id',$order['uid'])->value('user_ship'); + $discount = PayNotifyLogic::getDiscount($level); + $user_number = bcmul($order['pay_price'], $discount, 2); User::where('id', $order['uid'])->inc('integral', $user_number)->update(); // 核销加冻结礼品券 解冻礼品券 self::addUserSing($order,2,$user_number);//冻结 diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index 20fb69e4a..f5582aeb6 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -97,7 +97,9 @@ class PayNotifyLogic extends BaseLogic if ($order['shipping_type'] == 3) { //预留收银台余额支付得兑换券逻辑 if ($order->uid >0) { - $total_vip = bcmul($order['pay_price'], 0.1, 2); + $level = User::where('id',$order->uid)->value('user_ship'); + $discount = self::getDiscount($level); + $total_vip = bcmul($order['pay_price'], $discount, 2); self::addNewUserSing($order,8,$total_vip,1,1); User::where('id', $order->uid)->inc('integral', $total_vip)->update(); } @@ -434,7 +436,9 @@ class PayNotifyLogic extends BaseLogic self::descStock($order['id']); //直接加对应兑换券 if ($order->uid >0) { - $total_vip = bcmul($order['pay_price'], 0.1, 2); + $level = User::where('id',$order->uid)->value('user_ship'); + $discount = self::getDiscount($level); + $total_vip = bcmul($order['pay_price'], $discount, 2); self::addNewUserSing($order,8,$total_vip,1,1); User::where('id', $order->uid)->inc('integral', $total_vip)->update(); } @@ -473,9 +477,12 @@ class PayNotifyLogic extends BaseLogic $capitalFlowDao->userExpense('user_order_purchase_pay', 'order', $orderRe['id'], $purchase_funds, '', 1, $orderRe['store_id']); } //退还 充值得兑换券 - self::addNewUserSing($orderRe, 3, $orderRe->refund_price); //冻结 + $level = User::where('id',$order->uid)->value('user_ship'); + $discount = self::getDiscount($level); + $total_price = bcmul($orderRe->refund_price, $discount, 2); + self::addNewUserSing($orderRe, 3,$total_price); //冻结 - self::addNewUserSing($orderRe, 6, $orderRe->refund_price, 0, 1); //解冻 + self::addNewUserSing($orderRe, 6, $total_price, 0, 1); //解冻 self::descUserSing($orderRe); // d($purchase_funds,$orderRe['refund_price'],$orderRe); return true; @@ -492,6 +499,9 @@ class PayNotifyLogic extends BaseLogic $capitalFlowDao = new CapitalFlowLogic($user); $deal_money = bcdiv($extra['amount']['refund'], 100, 2); $check_user_sing = UserSign::where('order_id', $order['order_id'])->count(); + //对应比例得退礼品券逻辑 + $discount = self::getDiscount($user->user_ship); + $total_price = bcmul($order->refund_price, $discount, 2); 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); @@ -509,18 +519,19 @@ class PayNotifyLogic extends BaseLogic //退款 $capitalFlowDao->userIncome('system_purchase_back', 'system_back', $order['id'], $deal_money); } + if ($check_user_sing) { //退还 兑换券 - self::addNewUserSing($order, 3, $order->refund_price); //冻结 - self::addNewUserSing($order, 6, $order->refund_price, 0, 1); //解冻 + self::addNewUserSing($order, 3, $total_price); //冻结 + self::addNewUserSing($order, 6, $total_price, 0, 1); //解冻 self::descUserSing($order); } return true; } //积分 if ($check_user_sing) { - self::addNewUserSing($order, 3, $order->refund_price); //冻结 - self::addNewUserSing($order, 6, $order->refund_price, 0, 1); //解冻 + self::addNewUserSing($order, 3, $total_price); //冻结 + self::addNewUserSing($order, 6, $total_price, 0, 1); //解冻 self::descUserSing($order); } //微信日志 user_order_refund @@ -568,7 +579,9 @@ class PayNotifyLogic extends BaseLogic { // $user_sing = new UserSign(); if ($order['uid'] > 0) { - $user_number = bcmul($order['refund_price'], '0.10', 2); + $level = User::where('id',$order['uid'])->value('user_ship'); + $discount = self::getDiscount($level); + $user_number = bcmul($order['refund_price'], $discount, 2); // $sing = [ // 'uid' => $order['uid'], // 'order_id' => $order['order_id'], @@ -794,7 +807,9 @@ class PayNotifyLogic extends BaseLogic self::descStock($order['id']); //直接加到礼品券中 $user_sing = new UserSign(); - $total_vip = bcmul($order['pay_price'], 0.1, 2); + $level = User::where('id',$order['uid'])->value('user_ship'); + $discount = self::getDiscount($level); + $total_vip = bcmul($order['pay_price'], $discount, 2); $sing[] = [ 'uid' => $order['uid'], 'order_id' => $order['order_id'], @@ -848,7 +863,9 @@ class PayNotifyLogic extends BaseLogic self::descStock($order['id']); //直接加兑换券到对应得账户 if ($order->uid >0) { - $total_vip = bcmul($order['pay_price'], 0.1, 2); + $level = User::where('id',$order['uid'])->value('user_ship'); + $discount = self::getDiscount($level); + $total_vip = bcmul($order['pay_price'], $discount, 2); self::addNewUserSing($order,8,$total_vip,1,1); User::where('id', $order->uid)->inc('integral', $total_vip)->update(); } @@ -892,7 +909,9 @@ class PayNotifyLogic extends BaseLogic $order['uid'] > 0 && $order['total_price'] >= 500 && $order['pay_type'] != PayEnum::PURCHASE_FUNDS && $user_ship != 1 && $order['shipping_type'] !=3 ) { - $user_number = bcmul($order['pay_price'], '0.10', 2); + $level = User::where('id',$order['uid'])->value('user_ship'); + $discount = self::getDiscount($level); + $user_number = bcmul($order['pay_price'], $discount, 2); $sing = [ 'uid' => $order['uid'], 'order_id' => $order['order_id'], @@ -915,7 +934,8 @@ class PayNotifyLogic extends BaseLogic $user_ship = $user['user_ship']; if($order['total_price'] >= 500 && $order['pay_type'] !=PayEnum::PURCHASE_FUNDS && $user_ship !=1 && $order['shipping_type'] !=3){ - $user_number = bcmul($order['pay_price'], '0.10', 2); + $discount = self::getDiscount($user_ship); + $user_number = bcmul($order['pay_price'], $discount, 2); $sing = [ 'uid' => $order['uid'], 'order_id' => $order['order_id'], @@ -1214,6 +1234,25 @@ class PayNotifyLogic extends BaseLogic + /** + * 会员等级对应得折扣比例 + * @param $level + * @return float|mixed + */ + public static function getDiscount($level) + { + switch ($level) { + case 0://普通 + return Config::where('name','ordinary_member')->value('value')??0.1; + case 1://vip + return Config::where('name','vip_member')->value('value')??0.1; + case 4://商户 + return Config::where('name','merchant')->value('value')??0.1; + default: + return 0.1; + } + } + //礼品券相关对应文本 From b63ae912bb2fd3468ce907ab5b5e3ecb47970c03 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Mon, 1 Jul 2024 11:04:08 +0800 Subject: [PATCH 041/115] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E6=8E=A8=E9=80=81=E5=8A=9F=E8=83=BD=E5=BC=82=E5=B8=B8?= =?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/common/logic/PayNotifyLogic.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index 20fb69e4a..ddd28efe8 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -879,6 +879,12 @@ class PayNotifyLogic extends BaseLogic $village_uid = 0; $brigade_uid = 0; $user_ship = 0; + try{ + Redis::send('order_wetcha_push_send', ['order' => $order]); + }catch(\Exception $e){ + Log::error('订单推送失败:'.$e->getMessage()); + // 异常处理代码,例如记录日志或发送通知等。 + } if ($off_activity == 1) { //-----活动价结算更改 $financeLogic->order = $order; From 15eba343860698372727f5994798925ec2885045 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Mon, 1 Jul 2024 11:16:04 +0800 Subject: [PATCH 042/115] =?UTF-8?q?feat(LoginController):=20=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E7=99=BB=E5=BD=95=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/LoginController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/admin/controller/LoginController.php b/app/admin/controller/LoginController.php index 89c51f54a..59f555ea2 100644 --- a/app/admin/controller/LoginController.php +++ b/app/admin/controller/LoginController.php @@ -37,8 +37,8 @@ class LoginController extends BaseAdminController */ public function account() { - $params = $this->request->post(); -// $params = (new LoginValidate())->post()->goCheck(); + // $params = $this->request->post(); + $params = (new LoginValidate())->post()->goCheck(); return $this->data((new LoginLogic())->login($params)); } From f880a035d404d9ae197f7fda700352a248b183d5 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Mon, 1 Jul 2024 11:34:44 +0800 Subject: [PATCH 043/115] =?UTF-8?q?feat(order):=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E8=AE=A2=E5=8D=95=E9=80=BB=E8=BE=91=EF=BC=8C=E5=8C=85=E6=8B=AC?= =?UTF-8?q?=E5=88=9B=E5=BB=BA=E8=AE=A2=E5=8D=95=E3=80=81=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E8=AE=A2=E5=8D=95=E3=80=81=E6=A0=B8=E9=94=80=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E7=AD=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/logic/order/OrderLogic.php | 205 +++++++++++++++-------------- 1 file changed, 103 insertions(+), 102 deletions(-) diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index f3ced1881..b00605f3a 100644 --- a/app/api/logic/order/OrderLogic.php +++ b/app/api/logic/order/OrderLogic.php @@ -50,8 +50,9 @@ class OrderLogic extends BaseLogic public static $pay_price; public static $cost; public static $profit; - public static $store_price;//门店零售价 + public static $store_price; //门店零售价 public static $activity_price; + public static $deduction_price; /** * @notes 获取购物车商品信息 @@ -74,41 +75,45 @@ class OrderLogic extends BaseLogic self::$profit = 0; //利润 self::$activity_price = 0; //活动减少 self::$store_price = 0; //门店零售价 + $deduction_price = 0; //抵扣金额 /** 计算价格 */ - $off_activity=Config::where('name','off_activity')->value('value'); - $field='id branch_product_id,store_name,image,unit,price,vip_price,cost,purchase,product_id'; + $off_activity = Config::where('name', 'off_activity')->value('value'); + $field = 'id branch_product_id,store_name,image,unit,price,vip_price,cost,purchase,product_id'; foreach ($cart_select as $k => $v) { $find = StoreBranchProduct::where(['product_id' => $v['product_id'], 'store_id' => $params['store_id']])->field($field)->withTrashed()->find(); if (!$find) { continue; } unset($cart_select[$k]['id']); - if($off_activity==1){ - $price=$find['cost']; - }else{ - $price=$find['price']; + $cart_select[$k]['total_price'] = bcmul($v['cart_num'], $find['price'], 2); //订单总价 + if ($off_activity == 1) { + $price = $find['cost']; + } else { + $price = $find['price']; } $cart_select[$k]['price'] = $price; $cart_select[$k]['cost'] = $find['cost']; - $cart_select[$k]['total_price'] = bcmul($v['cart_num'], $find['price'], 2); //订单总价 - $cart_select[$k]['deduction_price'] =self::$activity_price;//抵扣金额 $cart_select[$k]['vip'] = 0; //利润 // $cart_select[$k]['profit'] = bcmul($v['cart_num'], $onePrice, 2); //利润 $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]['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售价 + if($cart_select[$k]['total_price']>$cart_select[$k]['pay_price']){ + $deduction_price=bcsub($cart_select[$k]['total_price'],$find['deduction_price'],2); + $cart_select[$k]['deduction_price'] =$deduction_price;//抵扣金额 + } $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'] ); + // 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']; $cartInfo['image'] = $find['image']; @@ -122,20 +127,21 @@ class OrderLogic extends BaseLogic self::$total_price = bcadd(self::$total_price, $cart_select[$k]['total_price'], 2); self::$pay_price = bcadd(self::$pay_price, $cart_select[$k]['pay_price'], 2); self::$cost = bcadd(self::$cost, $cart_select[$k]['purchase'], 2); - self::$store_price = bcadd(self::$store_price, $cart_select[$k]['store_price'], 2);//门店零售价格 + self::$store_price = bcadd(self::$store_price, $cart_select[$k]['store_price'], 2); //门店零售价格 + self::$deduction_price=bcadd(self::$deduction_price,$deduction_price,2);//抵扣金额 // self::$profit = bcadd(self::$profit, $cart_select[$k]['profit'], 2); } //加支付方式限制 - $pay_type = isset($params['pay_type'])?$params['pay_type']:0; - if ($user && $user['user_ship'] == 1 && $pay_type !=17) { + $pay_type = isset($params['pay_type']) ? $params['pay_type'] : 0; + if ($user && $user['user_ship'] == 1 && $pay_type != 17) { $pay_price = self::$pay_price; - }else{ - $pay_price =bcsub(self::$pay_price, self::$activity_price, 2); //减去活动优惠金额 + } else { + $pay_price = bcsub(self::$pay_price, self::$activity_price, 2); //减去活动优惠金额 } -// if($pay_price < 500){ -// throw new Exception('金额低于500'); -// } + // if($pay_price < 500){ + // throw new Exception('金额低于500'); + // } //成本价 收益 $order = [ @@ -153,43 +159,40 @@ class OrderLogic extends BaseLogic 'shipping_type' => $params['shipping_type'] ?? 2, //配送方式 1=快递 ,2=门店自提 'activity' => '减免', 'activity_price' => self::$activity_price, - 'activities' => self::$activity_price>0?1:0, - 'deduction_price' => self::$activity_price, + 'activities' => self::$activity_price > 0 ? 1 : 0, + 'deduction_price' => self::$deduction_price, 'is_vip' => 0, - 'is_storage' => $params['is_storage']??0, + 'is_storage' => $params['is_storage'] ?? 0, ]; $order['default_delivery'] = 0; if ($params['store_id']) { $order['default_delivery'] = SystemStore::where('id', $params['store_id'])->value('is_send'); } - if($user && $user['user_ship']>=1 &&$user['user_ship']<=3){ + if ($user && $user['user_ship'] >= 1 && $user['user_ship'] <= 3) { $order['is_vip'] = 1; - } //处理返回最近的店铺 $store['near_store'] = []; - if((isset($params['lat'])&&$params['lat']!='')&&(isset($params['long']) &&$params['lat']!='')){ + if ((isset($params['lat']) && $params['lat'] != '') && (isset($params['long']) && $params['lat'] != '')) { $storeAll = SystemStore::field('id,name,phone,address,detailed_address,latitude,longitude')->select()->toArray(); $nearestStore = null; $minDistance = PHP_FLOAT_MAX; - foreach ($storeAll as $value){ - $value['distance'] = haversineDistance($value['latitude'],$value['longitude'],$params['lat'] ,$params['long']); + foreach ($storeAll as $value) { + $value['distance'] = haversineDistance($value['latitude'], $value['longitude'], $params['lat'], $params['long']); if ($value['distance'] < $minDistance) { $minDistance = $value['distance']; $nearestStore = $value; } } if ($nearestStore) { - $store['near_store'] =$nearestStore; + $store['near_store'] = $nearestStore; } - } - } catch (\Exception $e) { self::setError($e->getMessage()); return false; } - return ['order' => $order, 'cart_list' => $cart_select,'shopInfo'=>$store['near_store']]; + return ['order' => $order, 'cart_list' => $cart_select, 'shopInfo' => $store['near_store']]; } /** @@ -199,29 +202,29 @@ class OrderLogic extends BaseLogic static public function createOrder($cartId, $addressId, $user = null, $params = []) { $order_id = getNewOrderId('PF'); - $code = rand(1,10).'-'.substr($order_id, -5); + $code = rand(1, 10) . '-' . substr($order_id, -5); $verify_code = createCode($code); $params['order_id'] = $order_id; - $params['verify_code'] =$verify_code; + $params['verify_code'] = $verify_code; $orderInfo = self::cartIdByOrderInfo($cartId, $addressId, $user, $params); if (!$orderInfo) { return false; } - $uid=$user['id']??0; + $uid = $user['id'] ?? 0; $_order = $orderInfo['order']; $_order['uid'] = $uid; - $_order['spread_uid'] =$params['spread_uid']??0; - $_order['real_name'] = $user['real_name']??''; - $_order['mobile'] = $user['mobile']??''; + $_order['spread_uid'] = $params['spread_uid'] ?? 0; + $_order['real_name'] = $user['real_name'] ?? ''; + $_order['mobile'] = $user['mobile'] ?? ''; $_order['pay_type'] = $orderInfo['order']['pay_type']; $_order['verify_code'] = $verify_code; $_order['reservation_time'] = null; - $_order['reservation'] = $params['reservation']??0;//是否需要预约 + $_order['reservation'] = $params['reservation'] ?? 0; //是否需要预约 if (isset($params['reservation_time']) && $params['reservation_time']) { $_order['reservation_time'] = $params['reservation_time']; $_order['reservation'] = YesNoEnum::YES; } - if ($addressId > 0 &&$uid>0 ) { + if ($addressId > 0 && $uid > 0) { $address = UserAddress::where(['id' => $addressId, 'uid' => $uid])->find(); if ($address) { $_order['real_name'] = $address['real_name']; @@ -235,8 +238,8 @@ class OrderLogic extends BaseLogic //生成核销码 $generator = new BarcodeGeneratorPNG(); $barcode = $generator->getBarcode($verify_code, $generator::TYPE_CODE_128); - $findPath = '/image/barcode/'.time().'.png'; - $savePath = public_path().$findPath; + $findPath = '/image/barcode/' . time() . '.png'; + $savePath = public_path() . $findPath; file_put_contents($savePath, $barcode); $_order['verify_img'] = $findPath; Db::startTrans(); @@ -248,9 +251,9 @@ class OrderLogic extends BaseLogic $goods_list[$k]['uid'] = $uid; $goods_list[$k]['cart_id'] = implode(',', $cartId); $goods_list[$k]['delivery_id'] = $params['store_id']; //商家id - $StoreBranchProduct = StoreBranchProduct::where('id',$v['branch_product_id'])->withTrashed()->find(); - if($StoreBranchProduct['stock']-$v['cart_num']<=0){ - Db::name('store_product_cate')->where(['cate_id'=>$StoreBranchProduct['cate_id'],'store_id'=>$params['store_id']])->update(['count'=>0]); + $StoreBranchProduct = StoreBranchProduct::where('id', $v['branch_product_id'])->withTrashed()->find(); + if ($StoreBranchProduct['stock'] - $v['cart_num'] <= 0) { + Db::name('store_product_cate')->where(['cate_id' => $StoreBranchProduct['cate_id'], 'store_id' => $params['store_id']])->update(['count' => 0]); } } (new StoreOrderCartInfo())->saveAll($goods_list); @@ -273,10 +276,10 @@ class OrderLogic extends BaseLogic * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ - public static function checkLeft($params,$uid,$type =0) + public static function checkLeft($params, $uid, $type = 0) { $where = []; - if(empty($type)){ + if (empty($type)) { $where = ['is_pay' => 0]; } $cart_select = Cart::whereIn('id', $params['cart_id']) @@ -289,32 +292,32 @@ class OrderLogic extends BaseLogic //检查购物车对比店铺得商品数量差异 foreach ($cart_select as $v) { $store = StoreBranchProduct::where([ - 'store_id'=>$params['store_id'], - 'product_id'=>$v['product_id'], + 'store_id' => $params['store_id'], + 'product_id' => $v['product_id'], ])->field('id,store_name,stock')->withTrashed()->find(); - if(empty($store)){ - $store['stock'] =0; + if (empty($store)) { + $store['stock'] = 0; } - if($store['stock'] < $v['cart_num']){ + if ($store['stock'] < $v['cart_num']) { //缺失 $newArr[] = [ - 'uid'=>$uid, - 'store_id'=>$params['store_id'], - 'product_id'=>$v['product_id'], - 'missing_quantity'=> $v['cart_num'] - $store['stock'] + 'uid' => $uid, + 'store_id' => $params['store_id'], + 'product_id' => $v['product_id'], + 'missing_quantity' => $v['cart_num'] - $store['stock'] ]; } } - if($newArr){ + if ($newArr) { return [ - 'detail'=>$newArr, - 'reservation'=>1 + 'detail' => $newArr, + 'reservation' => 1 ]; } return [ - 'detail'=>[], - 'reservation'=>0 + 'detail' => [], + 'reservation' => 0 ]; } @@ -385,7 +388,7 @@ class OrderLogic extends BaseLogic $data = []; foreach ($arr as $k => $v) { $data[$k]['product_id'] = $v['product_id']; -// $unique = StoreProductAttrValue::where('product_id', $v['product_id'])->value('v'); + // $unique = StoreProductAttrValue::where('product_id', $v['product_id'])->value('v'); $data[$k]['product_attr_unique'] = ''; $data[$k]['cart_num'] = $v['cart_num']; $data[$k]['type'] = ''; @@ -410,7 +413,7 @@ class OrderLogic extends BaseLogic } - public static function detail($params,$url='',$param=[]): array + public static function detail($params, $url = '', $param = []): array { $find = StoreOrder::where($params)->findOrEmpty()->toArray(); if ($find) { @@ -429,26 +432,24 @@ class OrderLogic extends BaseLogic $store = SystemStore::where('id', $find['store_id'])->field('id,name,phone,address,detailed_address')->find(); $find['store_info'] = $store; - if($find['verify_img']){ - $find['verify_img'] = $url.$find['verify_img']; + if ($find['verify_img']) { + $find['verify_img'] = $url . $find['verify_img']; } //处理返回最近的店铺 - if($param['lat'] && $param['long']){ + if ($param['lat'] && $param['long']) { $storeAll = SystemStore::field('id,name,phone,address,detailed_address,latitude,longitude')->select()->toArray(); $nearestStore = null; $minDistance = PHP_FLOAT_MAX; - foreach ($storeAll as $value){ - $value['distance'] = haversineDistance($value['latitude'],$value['longitude'],$param['lat'] ,$param['long']); + foreach ($storeAll as $value) { + $value['distance'] = haversineDistance($value['latitude'], $value['longitude'], $param['lat'], $param['long']); if ($value['distance'] < $minDistance) { $minDistance = $value['distance']; $nearestStore = $value; } } if ($nearestStore) { - $find['near_store'] =$nearestStore; - + $find['near_store'] = $nearestStore; } - } } return $find; @@ -488,52 +489,52 @@ class OrderLogic extends BaseLogic } Db::startTrans(); try { - StoreOrder::update([ - 'verify_code'=>$params['verify_code'].'-1', + StoreOrder::update([ + 'verify_code' => $params['verify_code'] . '-1', 'status' => OrderEnum::RECEIVED_GOODS, 'is_writeoff' => OrderEnum::IS_OK, 'update_time' => time(), 'store_id' => $params['store_id'], - 'staff_id' => $params['staff_id']??0, + 'staff_id' => $params['staff_id'] ?? 0, ], ['id' => $order['id']]); (new StoreOrderCartInfo())->update([ - 'verify_code'=>$params['verify_code'].'-1', + 'verify_code' => $params['verify_code'] . '-1', 'writeoff_time' => time(), 'is_writeoff' => YesNoEnum::YES, 'store_id' => $params['store_id'], - 'staff_id' => $params['staff_id']??0, + 'staff_id' => $params['staff_id'] ?? 0, 'update_time' => time(), ], ['oid' => $order['id']]); 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,16]])->select(); - foreach($select_1 as $k=>$v){ - if($v['other_uid']>0){ - $financeFlowLogic->updateStatusUser($v['id'],$v['other_uid'],$v['number'],$v['order_id']); + $financeFlow = new StoreFinanceFlow(); + $financeFlowLogic = new StoreFinanceFlowLogic(); + $select_1 = $financeFlow->where(['order_id' => $order['id'], 'financial_pm' => 1, 'financial_type' => ['in' => 14, 15, 16]])->select(); + foreach ($select_1 as $k => $v) { + if ($v['other_uid'] > 0) { + $financeFlowLogic->updateStatusUser($v['id'], $v['other_uid'], $v['number'], $v['order_id']); } } - if($order['uid'] && $order['pay_price'] >= 500){ - $level = User::where('id',$order['uid'])->value('user_ship'); + if ($order['uid'] && $order['pay_price'] >= 500) { + $level = User::where('id', $order['uid'])->value('user_ship'); $discount = PayNotifyLogic::getDiscount($level); $user_number = bcmul($order['pay_price'], $discount, 2); User::where('id', $order['uid'])->inc('integral', $user_number)->update(); // 核销加冻结礼品券 解冻礼品券 - self::addUserSing($order,2,$user_number);//冻结 + self::addUserSing($order, 2, $user_number); //冻结 - self::addUserSing($order,4,$user_number,1,1);//解冻 + self::addUserSing($order, 4, $user_number, 1, 1); //解冻 - UserSign::where(['uid' => $order['uid'],'order_id' => $order['order_id'],'title'=>1])->update(['status'=>1]); + UserSign::where(['uid' => $order['uid'], 'order_id' => $order['order_id'], 'title' => 1])->update(['status' => 1]); } if ($order['spread_uid'] > 0) { - $spread_find=$financeFlow->where(['order_id'=>$order['id'],'financial_pm'=>1,'financial_type'=>12,'other_uid'=>$order['spread_uid']])->find(); - if($spread_find){ - $financeFlowLogic->updateStatusUser($spread_find['id'],$order['spread_uid'],$spread_find['number'],$order['id']); + $spread_find = $financeFlow->where(['order_id' => $order['id'], 'financial_pm' => 1, 'financial_type' => 12, 'other_uid' => $order['spread_uid']])->find(); + if ($spread_find) { + $financeFlowLogic->updateStatusUser($spread_find['id'], $order['spread_uid'], $spread_find['number'], $order['id']); } } - $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); + $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); Db::commit(); return true; } catch (\Exception $e) { @@ -552,14 +553,14 @@ class OrderLogic extends BaseLogic * @type $type //类型 0冻结 1解冻 * @return true */ - public static function addUserSing($order, $category, $number, int $pm=0, $type=0) + public static function addUserSing($order, $category, $number, int $pm = 0, $type = 0) { $user_sing = new UserSign(); $sing = [ 'uid' => $order['uid'], 'order_id' => $order['order_id'], -// 'title' => '购买商品获得兑换券', -// 'title' => PayNotifyLogic::getTitle($category,$number), + // 'title' => '购买商品获得兑换券', + // 'title' => PayNotifyLogic::getTitle($category,$number), 'title' => $category, 'financial_pm' => $pm, 'store_id' => $order['store_id'], @@ -588,19 +589,19 @@ class OrderLogic extends BaseLogic Db::startTrans(); try { StoreOrder::update([ - 'verify_code'=>$params['verify_code'].'-1', + 'verify_code' => $params['verify_code'] . '-1', 'status' => OrderEnum::RECEIVED_GOODS, 'is_writeoff' => OrderEnum::IS_OK, 'update_time' => time(), 'store_id' => $params['store_id'], - 'staff_id' => $params['staff_id']??0, + 'staff_id' => $params['staff_id'] ?? 0, ], ['id' => $data['id']]); (new StoreOrderCartInfo())->update([ - 'verify_code'=>$params['verify_code'].'-1', + 'verify_code' => $params['verify_code'] . '-1', 'writeoff_time' => time(), 'is_writeoff' => YesNoEnum::YES, 'store_id' => $params['store_id'], - 'staff_id' => $params['staff_id']??0, + 'staff_id' => $params['staff_id'] ?? 0, 'update_time' => time(), ], ['oid' => $data['id']]); // $financeFlow = (new StoreFinanceFlowLogic)->getStoreOrder($data['id'], $data['store_id']); @@ -608,7 +609,7 @@ class OrderLogic extends BaseLogic // $capitalFlowLogic = new CapitalFlowLogic($data->store, 'store'); // $capitalFlowLogic->storeIncome('store_order_income', 'order', $data['id'], $financeFlow['number']); // } - $order=StoreOrder::where('id',$data['id'])->find(); + $order = StoreOrder::where('id', $data['id'])->find(); PayNotifyLogic::descSwap($order['id']); Db::commit(); return true; From f878847d28773935a656b8b81d770474b31a231f Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Mon, 1 Jul 2024 11:50:08 +0800 Subject: [PATCH 044/115] =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E5=BA=97?= =?UTF-8?q?=E9=93=BA=E5=88=97=E8=A1=A8=E5=A2=9E=E5=8A=A0=E6=98=AF=E5=90=A6?= =?UTF-8?q?=E5=8F=AF=E5=BD=93=E6=97=A5=E8=8E=B7=E5=8F=96=E7=9A=84=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/lists/store/SystemStoreLists.php | 31 ++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/app/api/lists/store/SystemStoreLists.php b/app/api/lists/store/SystemStoreLists.php index 52bef3231..301b80b05 100644 --- a/app/api/lists/store/SystemStoreLists.php +++ b/app/api/lists/store/SystemStoreLists.php @@ -5,6 +5,8 @@ namespace app\api\lists\store; use app\admin\lists\BaseAdminDataLists; use app\common\enum\YesNoEnum; +use app\common\model\order\Cart; +use app\common\model\store_branch_product\StoreBranchProduct; use app\common\model\system_store\SystemStore; use app\common\lists\ListsSearchInterface; use app\MyBusinessException; @@ -48,6 +50,7 @@ class SystemStoreLists extends BaseAdminDataLists implements ListsSearchInterfac { $latitude = $this->request->get('latitude',''); $longitude = $this->request->get('longitude',''); + $cart_id = $this->request->get('cart_id',''); if(empty($longitude) || empty($latitude)){ throw new Exception('缺失经纬度'); } @@ -61,10 +64,34 @@ class SystemStoreLists extends BaseAdminDataLists implements ListsSearchInterfac ->order(['id' => 'desc']) ->select() ->toArray(); + if($cart_id){ + $cart_id = explode(',',$cart_id); + $cart_select = Cart::whereIn('id', $cart_id) + ->field('id,product_id,cart_num,store_id')->select()->toArray(); + foreach ($cart_select as $v) { + foreach ($data as &$values){ + $store = StoreBranchProduct::where([ + 'store_id'=>$values['id'], + 'product_id'=>$v['product_id'], + ])->field('id,store_name,stock')->withTrashed()->find(); + if(empty($store)){ + $store['stock'] =0; + } + $values['reservation'] = 0; + if($store['stock'] < $v['cart_num']){ + $values['reservation'] = 1; + } + $values['distance'] = haversineDistance($values['latitude'],$values['longitude'],$latitude,$longitude); + } - foreach ($data as &$value){ - $value['distance'] = haversineDistance($value['latitude'],$value['longitude'],$latitude,$longitude); + } + }else{ + foreach ($data as &$value){ + $value['distance'] = haversineDistance($value['latitude'],$value['longitude'],$latitude,$longitude); + + } } + usort($data, function ($a, $b) { return $a['distance'] <=> $b['distance']; }); From 970202fdc7ace23b707242b1694f4408e6b7601e Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Mon, 1 Jul 2024 12:01:43 +0800 Subject: [PATCH 045/115] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9=E4=BA=86?= =?UTF-8?q?=E6=9D=A1=E7=A0=81=E6=94=AF=E4=BB=98=E9=80=BB=E8=BE=91=E5=92=8C?= =?UTF-8?q?=E8=AE=A2=E5=8D=95=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/store/StoreController.php | 2 +- app/api/logic/order/OrderLogic.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/api/controller/store/StoreController.php b/app/api/controller/store/StoreController.php index 698fe944c..61410d882 100644 --- a/app/api/controller/store/StoreController.php +++ b/app/api/controller/store/StoreController.php @@ -110,7 +110,7 @@ class StoreController extends BaseApiController $order['pay_price']=$order['price']; $result = PaymentLogic::codepay($auth_code, $order,'条码支付'); if (PaymentLogic::hasError()) { - return $this->fail(PaymentLogic::getError(), $params); + return $this->fail(PaymentLogic::getError()); } if (isset($result['trade_state_desc']) && $result['trade_state_desc'] == '支付成功') { PayNotifyLogic::handle('recharge', $result['out_trade_no'], $result); diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index b00605f3a..9ee898e05 100644 --- a/app/api/logic/order/OrderLogic.php +++ b/app/api/logic/order/OrderLogic.php @@ -103,7 +103,7 @@ class OrderLogic extends BaseLogic $cart_select[$k]['vip_price'] = bcmul($v['cart_num'], $find['vip_price'], 2) ?? 0; //vip售价 if($cart_select[$k]['total_price']>$cart_select[$k]['pay_price']){ - $deduction_price=bcsub($cart_select[$k]['total_price'],$find['deduction_price'],2); + $deduction_price=bcsub($cart_select[$k]['total_price'],$cart_select[$k]['pay_price'],2); $cart_select[$k]['deduction_price'] =$deduction_price;//抵扣金额 } $cart_select[$k]['product_id'] = $find['product_id']; From ba33a7b98dea1b01f622c681ac4b27bb401a958a Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Mon, 1 Jul 2024 12:24:32 +0800 Subject: [PATCH 046/115] =?UTF-8?q?=E5=85=BC=E5=AE=B9=E6=94=AF=E4=BB=98?= =?UTF-8?q?=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/logic/order/OrderLogic.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index 9ee898e05..bb31af72d 100644 --- a/app/api/logic/order/OrderLogic.php +++ b/app/api/logic/order/OrderLogic.php @@ -75,6 +75,7 @@ class OrderLogic extends BaseLogic self::$profit = 0; //利润 self::$activity_price = 0; //活动减少 self::$store_price = 0; //门店零售价 + self::$deduction_price =0; $deduction_price = 0; //抵扣金额 /** 计算价格 */ $off_activity = Config::where('name', 'off_activity')->value('value'); @@ -101,7 +102,6 @@ class OrderLogic extends BaseLogic $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售价 - if($cart_select[$k]['total_price']>$cart_select[$k]['pay_price']){ $deduction_price=bcsub($cart_select[$k]['total_price'],$cart_select[$k]['pay_price'],2); $cart_select[$k]['deduction_price'] =$deduction_price;//抵扣金额 From b0c272de774b68517d5463f3186a2b81189a14de Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Mon, 1 Jul 2024 14:17:30 +0800 Subject: [PATCH 047/115] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E8=88=B9=E5=8F=AA=E4=BF=A1=E6=81=AF=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 --- app/api/lists/user/UserRechargeLists.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/api/lists/user/UserRechargeLists.php b/app/api/lists/user/UserRechargeLists.php index 62521a687..83bfecd61 100644 --- a/app/api/lists/user/UserRechargeLists.php +++ b/app/api/lists/user/UserRechargeLists.php @@ -8,6 +8,7 @@ use app\common\model\user\UserFeedback; use app\common\model\user_label\UserLabel; use app\common\model\user_recharge\UserRecharge; +use app\common\model\user_ship\UserShip; //用户充值表 class UserRechargeLists extends BaseAdminDataLists implements ListsSearchInterface @@ -47,8 +48,8 @@ use app\common\model\user_recharge\UserRecharge; if($data['recharge_type']=='INDUSTRYMEMBERS'){ $find =User::where('id',$data['uid'])->find(); $data['real_name']=$find['real_name']??''; - if($find &&$find['label_id']>0){ - $data['label_name']=UserLabel::where('label_id',$find['label_id'])->value('label_name'); + if($find &&$find['user_ship']>0){ + $data['ship_name']=UserShip::where('id',$find['user_ship'])->value('title'); } }else{ $data['real_name'] =User::where('id',$data['uid'])->value('real_name'); From 281394e1bc95bf62bc7271b7f43a2dc499023a9f Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Mon, 1 Jul 2024 14:34:35 +0800 Subject: [PATCH 048/115] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E8=88=B9=E5=8F=AA=E4=BF=A1=E6=81=AF=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 --- app/admin/logic/user/UserLogic.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/admin/logic/user/UserLogic.php b/app/admin/logic/user/UserLogic.php index 809056e1d..3c70dfa97 100644 --- a/app/admin/logic/user/UserLogic.php +++ b/app/admin/logic/user/UserLogic.php @@ -25,6 +25,7 @@ use app\common\model\user\UserAddress; use app\common\model\user\UserRecharge; use app\common\model\user_create_log\UserCreateLog; use app\common\model\user_label\UserLabel; +use app\common\model\user_ship\UserShip; use app\common\model\user_sign\UserSign; use app\common\model\vip_flow\VipFlow; use think\facade\Db; @@ -161,7 +162,7 @@ class UserLogic extends BaseLogic public static function detail(int $userId): array { $field = [ - 'id', 'account', 'nickname', 'avatar', 'real_name','integral','label_id', + 'id', 'account', 'nickname', 'avatar', 'real_name','integral','label_id','user_ship', 'sex', 'mobile', 'create_time', 'login_time', 'channel','now_money','purchase_funds' ]; @@ -171,7 +172,7 @@ class UserLogic extends BaseLogic $user['channel'] = UserTerminalEnum::getTermInalDesc($user['channel']); $user->sex = $user->getData('sex'); $user['number']=StoreFinanceFlow::where('other_uid',$userId)->where(['status'=>0,'financial_pm'=>1,'type'=>1])->sum('number'); - $user['label_name']=$user->label_id?UserLabel::where('label_id',$user->label_id)->value('label_name'):""; + $user['ship_name']=$user->user_ship>0?UserShip::where('id',$user->user_ship)->value('title'):""; return $user->toArray(); } From 5115ca1dee08e4fc992a8526f8a28cfc37bd244b Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Mon, 1 Jul 2024 14:37:49 +0800 Subject: [PATCH 049/115] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E4=BF=A1=E6=81=AF=E8=8E=B7=E5=8F=96=E8=88=B9=E5=8F=AA?= =?UTF-8?q?=E5=90=8D=E7=A7=B0=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/logic/user/UserLogic.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/admin/logic/user/UserLogic.php b/app/admin/logic/user/UserLogic.php index 3c70dfa97..7758fe67c 100644 --- a/app/admin/logic/user/UserLogic.php +++ b/app/admin/logic/user/UserLogic.php @@ -172,7 +172,7 @@ class UserLogic extends BaseLogic $user['channel'] = UserTerminalEnum::getTermInalDesc($user['channel']); $user->sex = $user->getData('sex'); $user['number']=StoreFinanceFlow::where('other_uid',$userId)->where(['status'=>0,'financial_pm'=>1,'type'=>1])->sum('number'); - $user['ship_name']=$user->user_ship>0?UserShip::where('id',$user->user_ship)->value('title'):""; + $user['user_ship_name']=$user->user_ship>0?UserShip::where('id',$user->user_ship)->value('title'):""; return $user->toArray(); } From f3196d4bac90b0a366dd257dc504a236a551a27b Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Mon, 1 Jul 2024 15:06:55 +0800 Subject: [PATCH 050/115] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E5=92=8C=E5=B7=A5=E7=89=8C=E9=80=BB=E8=BE=91=E4=BB=A5?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=9F=A5=E8=AF=A2=E6=95=88=E7=8E=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/logic/user/UserLogic.php | 2 +- app/store/logic/WorkbenchLogic.php | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/app/admin/logic/user/UserLogic.php b/app/admin/logic/user/UserLogic.php index 7758fe67c..32c02418b 100644 --- a/app/admin/logic/user/UserLogic.php +++ b/app/admin/logic/user/UserLogic.php @@ -172,7 +172,7 @@ class UserLogic extends BaseLogic $user['channel'] = UserTerminalEnum::getTermInalDesc($user['channel']); $user->sex = $user->getData('sex'); $user['number']=StoreFinanceFlow::where('other_uid',$userId)->where(['status'=>0,'financial_pm'=>1,'type'=>1])->sum('number'); - $user['user_ship_name']=$user->user_ship>0?UserShip::where('id',$user->user_ship)->value('title'):""; + $user['user_ship_name']=$user->user_ship>0?UserShip::where('id',$user->user_ship)->value('title'):"一般用户"; return $user->toArray(); } diff --git a/app/store/logic/WorkbenchLogic.php b/app/store/logic/WorkbenchLogic.php index e80449753..0120bbc53 100644 --- a/app/store/logic/WorkbenchLogic.php +++ b/app/store/logic/WorkbenchLogic.php @@ -628,7 +628,6 @@ class WorkbenchLogic extends BaseLogic //总的营业额的统计 总的利润的统计 总的成本合集的统计 总的加到保证金的 $all = StoreOrder::where(['paid' => YesNoEnum::YES, 'store_id' => $params['store_id']]); - $deposit_all = StoreFinanceFlow::where(['store_id' => $params['store_id'], 'status' => YesNoEnum::YES]) ->sum('number'); @@ -732,7 +731,7 @@ class WorkbenchLogic extends BaseLogic { $endTime = date('Y-m-d', strtotime($startTime) + 86400); //当日营业额的统计 当日利润的统计 当日成本合集的统计 当日加到保证金的 当日的现金收银 - $today = StoreOrder::where(['paid' => YesNoEnum::YES, 'store_id' => $store_id]); + $today = StoreOrder::where(['paid' => YesNoEnum::YES, 'store_id' => $store_id,'refund_status'=>0]); $turnover_today = $today ->whereBetweenTime('create_time', $startTime, $endTime) ->sum('pay_price'); From 017e62eada37454db12e8824b52c01c8d07e9178 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Mon, 1 Jul 2024 15:20:19 +0800 Subject: [PATCH 051/115] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E7=94=A8=E6=88=B7=E6=89=8B=E6=9C=BA=E5=8F=B7=E7=9A=84?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/lists/user/UserRechargeLists.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/api/lists/user/UserRechargeLists.php b/app/api/lists/user/UserRechargeLists.php index 83bfecd61..9dab4a757 100644 --- a/app/api/lists/user/UserRechargeLists.php +++ b/app/api/lists/user/UserRechargeLists.php @@ -50,6 +50,7 @@ use app\common\model\user_ship\UserShip; $data['real_name']=$find['real_name']??''; if($find &&$find['user_ship']>0){ $data['ship_name']=UserShip::where('id',$find['user_ship'])->value('title'); + $data['mobile']=$find['mobile']; } }else{ $data['real_name'] =User::where('id',$data['uid'])->value('real_name'); From f9ae43777fe52197f7be2c1313125a9626a00ace Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Mon, 1 Jul 2024 15:30:14 +0800 Subject: [PATCH 052/115] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E5=85=85=E5=80=BC=E5=88=97=E8=A1=A8=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/lists/user/UserRechargeLists.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/api/lists/user/UserRechargeLists.php b/app/api/lists/user/UserRechargeLists.php index 9dab4a757..8c2703bf0 100644 --- a/app/api/lists/user/UserRechargeLists.php +++ b/app/api/lists/user/UserRechargeLists.php @@ -45,6 +45,8 @@ use app\common\model\user_ship\UserShip; ->order(['id' => 'desc']) ->select()->each(function($data){ $data['label_name']=''; + $data['ship_name']=''; + $data['mobile']=''; if($data['recharge_type']=='INDUSTRYMEMBERS'){ $find =User::where('id',$data['uid'])->find(); $data['real_name']=$find['real_name']??''; From 21e888afe49c7f16e2501471701f0b603e19709b Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Mon, 1 Jul 2024 15:36:02 +0800 Subject: [PATCH 053/115] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E8=88=B9=E5=8F=AA=E4=BF=A1=E6=81=AF=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 --- app/api/lists/user_create_log/UserCreateLogLists.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/api/lists/user_create_log/UserCreateLogLists.php b/app/api/lists/user_create_log/UserCreateLogLists.php index 9b1a89eff..bb88d1ed0 100644 --- a/app/api/lists/user_create_log/UserCreateLogLists.php +++ b/app/api/lists/user_create_log/UserCreateLogLists.php @@ -8,6 +8,7 @@ use app\common\model\system_store\SystemStore; use app\common\lists\ListsSearchInterface; use app\common\model\user\User; use app\common\model\user_create_log\UserCreateLog; +use app\common\model\user_ship\UserShip; /** * 用户前端添加记录列表 @@ -48,8 +49,16 @@ class UserCreateLogLists extends BaseAdminDataLists implements ListsSearchInterf ->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) ->select()->each(function ($item){ + $data['ship_name']=''; + $data['mobile']=''; + $data['nickname']=''; + $find =User::where('id',$item['uid'])->find(); + if($find &&$find['user_ship']>0){ + $data['ship_name']=UserShip::where('id',$find['user_ship'])->value('title'); + $data['mobile']=$find['mobile']; + $item['nickname'] = User::where('id',$item['uid'])->value('real_name'); + } $item['system_store_name'] = SystemStore::where('id',$item['store_id'])->value('name'); - $item['nickname'] = User::where('id',$item['uid'])->value('real_name'); $item['create_nickname'] = User::where('id',$item['create_uid'])->value('real_name'); }) ->toArray(); From 64d978358ae1160298bf8b258d71c5736fdfaac0 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Mon, 1 Jul 2024 15:46:55 +0800 Subject: [PATCH 054/115] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9UserControlle?= =?UTF-8?q?r=E5=92=8COrderLogic=E7=B1=BB=E4=BB=A5=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E8=AE=A2=E5=8D=95=E5=A4=84=E7=90=86=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/user/UserController.php | 4 ++-- app/api/logic/order/OrderLogic.php | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/api/controller/user/UserController.php b/app/api/controller/user/UserController.php index 12a550175..301a16a8d 100644 --- a/app/api/controller/user/UserController.php +++ b/app/api/controller/user/UserController.php @@ -232,8 +232,8 @@ class UserController extends BaseApiController $params['page_size'] = $page_size > 0 ? $page_size : 15; $res = UserLogic::dealDetails($params,$this->userId); $integral = User::where('id',$this->userId)->value('integral'); - $number = UserSign::where('id',$this->userId)->where('status',0)->sum('number'); - $GetNumber = UserSign::where('id',$this->userId)->where('status',1)->sum('number'); + $number = 0;//UserSign::where('id',$this->userId)->where('status',0)->sum('number'); + $GetNumber = 0;//UserSign::where('id',$this->userId)->where('status',1)->sum('number'); $res['page_no'] = $params['page_no']; $res['page_size'] = $params['page_size']; $res['extend'] = [ diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index bb31af72d..1ca3ab514 100644 --- a/app/api/logic/order/OrderLogic.php +++ b/app/api/logic/order/OrderLogic.php @@ -83,9 +83,10 @@ class OrderLogic extends BaseLogic foreach ($cart_select as $k => $v) { $find = StoreBranchProduct::where(['product_id' => $v['product_id'], 'store_id' => $params['store_id']])->field($field)->withTrashed()->find(); if (!$find) { + unset($cart_select[$k]); continue; } - unset($cart_select[$k]['id']); + // unset($cart_select[$k]['id']); $cart_select[$k]['total_price'] = bcmul($v['cart_num'], $find['price'], 2); //订单总价 if ($off_activity == 1) { $price = $find['cost']; @@ -210,6 +211,7 @@ class OrderLogic extends BaseLogic if (!$orderInfo) { return false; } + d($orderInfo); $uid = $user['id'] ?? 0; $_order = $orderInfo['order']; $_order['uid'] = $uid; From a1c3de68dbb2b0fbe9c08c3ac9c8bb7004c61362 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Mon, 1 Jul 2024 15:48:10 +0800 Subject: [PATCH 055/115] =?UTF-8?q?feat:=20=E7=A7=BB=E9=99=A4=E4=BA=86?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E4=B8=AD=E7=9A=84=E8=B0=83=E8=AF=95=E8=AF=AD?= =?UTF-8?q?=E5=8F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/logic/order/OrderLogic.php | 1 - 1 file changed, 1 deletion(-) diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index 1ca3ab514..b4e262428 100644 --- a/app/api/logic/order/OrderLogic.php +++ b/app/api/logic/order/OrderLogic.php @@ -211,7 +211,6 @@ class OrderLogic extends BaseLogic if (!$orderInfo) { return false; } - d($orderInfo); $uid = $user['id'] ?? 0; $_order = $orderInfo['order']; $_order['uid'] = $uid; From a8d4e200c47527b910af9b5dfa510650842210b4 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Mon, 1 Jul 2024 15:56:23 +0800 Subject: [PATCH 056/115] =?UTF-8?q?feat(UserCreateLogLists.php):=20?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=94=A8=E6=88=B7=E5=88=9B=E5=BB=BA=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E5=88=97=E8=A1=A8=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/lists/user_create_log/UserCreateLogLists.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/api/lists/user_create_log/UserCreateLogLists.php b/app/api/lists/user_create_log/UserCreateLogLists.php index bb88d1ed0..fc9d05a73 100644 --- a/app/api/lists/user_create_log/UserCreateLogLists.php +++ b/app/api/lists/user_create_log/UserCreateLogLists.php @@ -49,13 +49,13 @@ class UserCreateLogLists extends BaseAdminDataLists implements ListsSearchInterf ->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) ->select()->each(function ($item){ - $data['ship_name']=''; - $data['mobile']=''; - $data['nickname']=''; + $item['ship_name']=''; + $item['mobile']=''; + $item['nickname']=''; $find =User::where('id',$item['uid'])->find(); if($find &&$find['user_ship']>0){ - $data['ship_name']=UserShip::where('id',$find['user_ship'])->value('title'); - $data['mobile']=$find['mobile']; + $item['ship_name']=UserShip::where('id',$find['user_ship'])->value('title'); + $item['mobile']=$find['mobile']; $item['nickname'] = User::where('id',$item['uid'])->value('real_name'); } $item['system_store_name'] = SystemStore::where('id',$item['store_id'])->value('name'); From 9b2bdc2c4f10d07e3b2d2226ee05912f3ef9a708 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Mon, 1 Jul 2024 16:00:14 +0800 Subject: [PATCH 057/115] =?UTF-8?q?feat(User):=20=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E6=B3=A8=E5=86=8C=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/logic/user/UserLogic.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/admin/logic/user/UserLogic.php b/app/admin/logic/user/UserLogic.php index 32c02418b..d911d34f3 100644 --- a/app/admin/logic/user/UserLogic.php +++ b/app/admin/logic/user/UserLogic.php @@ -93,6 +93,9 @@ class UserLogic extends BaseLogic 'label_id' => $params['label_id']??0, 'store_id' => $params['store_id']??0, ]; + if(isset($params['user_ship']) &&$params['user_ship']==4){ + $data['user_ship']=4; + } $res=User::create($data); UserCreateLog::create([ 'uid' => $res['id'], From f1f609563ab81146aa8245047cbe1791e0c914e0 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Mon, 1 Jul 2024 16:33:14 +0800 Subject: [PATCH 058/115] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E9=87=87?= =?UTF-8?q?=E8=B4=AD=E6=AC=BE=E6=94=AF=E4=BB=98=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/order/OrderController.php | 4 ++++ app/api/logic/order/OrderLogic.php | 3 +-- app/common/logic/PayNotifyLogic.php | 6 +++++- app/common/logic/PaymentLogic.php | 3 +++ 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/app/api/controller/order/OrderController.php b/app/api/controller/order/OrderController.php index 1e2835ed7..a72a22068 100644 --- a/app/api/controller/order/OrderController.php +++ b/app/api/controller/order/OrderController.php @@ -249,6 +249,10 @@ class OrderController extends BaseApiController } switch ($pay_type) { + case PayEnum::PURCHASE_FUNDS: + //采购款支付 + PayNotifyLogic::handle('purchase_funds', $order['order_id']); + return $this->success('采购款支付成功'); case PayEnum::BALANCE_PAY: //余额支付 PayNotifyLogic::handle('balancePay', $order['order_id']); diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index b4e262428..6df78f2ad 100644 --- a/app/api/logic/order/OrderLogic.php +++ b/app/api/logic/order/OrderLogic.php @@ -61,7 +61,6 @@ class OrderLogic extends BaseLogic */ static public function cartIdByOrderInfo($cartId, $addressId, $user = null, $params = []) { - $where = ['is_pay' => 0]; $cart_select = Cart::whereIn('id', $cartId)->where($where)->field('id,product_id,cart_num')->select()->toArray(); if (empty($cart_select)) { @@ -174,7 +173,7 @@ class OrderLogic extends BaseLogic } //处理返回最近的店铺 $store['near_store'] = []; - if ((isset($params['lat']) && $params['lat'] != '') && (isset($params['long']) && $params['lat'] != '')) { + if ((isset($params['lat']) && $params['lat'] != '') && (isset($params['long']) && $params['long'] != '')) { $storeAll = SystemStore::field('id,name,phone,address,detailed_address,latitude,longitude')->select()->toArray(); $nearestStore = null; $minDistance = PHP_FLOAT_MAX; diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index 05e9c128a..54b32748a 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -1227,7 +1227,11 @@ class PayNotifyLogic extends BaseLogic */ public static function dealGoodsLeft($cart_id,$uid,$oid) { - $cart_id['cart_id'] = explode(',',$cart_id); + if(is_array($cart_id)){ + $cart_id['cart_id'] = $cart_id; + }else{ + $cart_id['cart_id'] = explode(',',$cart_id); + } $data = OrderLogic::checkLeft($cart_id,$uid,1); $format = $data['detail']; foreach ($format as &$value){ diff --git a/app/common/logic/PaymentLogic.php b/app/common/logic/PaymentLogic.php index 51df608a2..a49df6407 100644 --- a/app/common/logic/PaymentLogic.php +++ b/app/common/logic/PaymentLogic.php @@ -8,6 +8,7 @@ use app\common\enum\PayEnum; use app\common\model\user\UserAuth; use app\common\service\pay\PayService; use Exception; +use support\Log; use function DI\string; @@ -101,6 +102,8 @@ class PaymentLogic extends BaseLogic try { $result = $wechat->wechat->pos($order)->toArray(); } catch (Exception $e) { + Log::error('条码支付报错',['message' => $e->extra['message']?? $e->getMessage(),'code'=>$e->getCode()]); + if (getenv('APP_DEBUG') == true) { self::$error = $e->extra['message'] ?? $e->getMessage(); } else { From 3174d2e0cafddaa748ec5fb960b4f34eeeb2da10 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Mon, 1 Jul 2024 17:15:18 +0800 Subject: [PATCH 059/115] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E9=80=BB=E8=BE=91=E4=BB=A3=E7=A0=81=EF=BC=8C=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E8=B4=AD=E7=89=A9=E8=BD=A6=E4=B8=AD=E4=B8=8D=E5=BF=85?= =?UTF-8?q?=E8=A6=81=E7=9A=84=20'id'=20=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/logic/order/OrderLogic.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index 6df78f2ad..e92ce680a 100644 --- a/app/api/logic/order/OrderLogic.php +++ b/app/api/logic/order/OrderLogic.php @@ -85,7 +85,7 @@ class OrderLogic extends BaseLogic unset($cart_select[$k]); continue; } - // unset($cart_select[$k]['id']); + unset($cart_select[$k]['id']); $cart_select[$k]['total_price'] = bcmul($v['cart_num'], $find['price'], 2); //订单总价 if ($off_activity == 1) { $price = $find['cost']; From fe70ce138d19aeb082b2886d32c6bb529322bb79 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Mon, 1 Jul 2024 17:28:42 +0800 Subject: [PATCH 060/115] =?UTF-8?q?feat(UserLists):=20=E6=A0=B9=E6=8D=AE?= =?UTF-8?q?=E8=A1=97=E9=81=93=E6=9F=A5=E8=AF=A2=E7=94=A8=E6=88=B7=E5=88=97?= =?UTF-8?q?=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/store/lists/user/UserLists.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/store/lists/user/UserLists.php b/app/store/lists/user/UserLists.php index 7ed2d0bbd..aeb929764 100644 --- a/app/store/lists/user/UserLists.php +++ b/app/store/lists/user/UserLists.php @@ -10,6 +10,7 @@ use app\store\lists\BaseAdminDataLists; use app\common\model\user\User; use app\common\model\user_ship\UserShip; use app\common\lists\ListsSearchInterface; +use app\common\model\user\UserAddress; class UserLists extends BaseAdminDataLists implements ListsSearchInterface { @@ -38,7 +39,13 @@ class UserLists extends BaseAdminDataLists implements ListsSearchInterface */ public function lists(): array { - + $street=$this->request->get('street',''); + if($street){ + $uid=UserAddress::where('village',$street)->group('uid')->column('uid'); + if($uid){ + $this->searchWhere=['uid','=',$uid]; + } + } $field = "id,nickname,real_name,sex,avatar,account,mobile,now_money,user_ship,create_time,purchase_funds,integral"; $lists = User::where($this->searchWhere) ->limit($this->limitOffset, $this->limitLength) From 3ee02c627507f9fa4634a4afd62ad2cde2ae5be3 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Mon, 1 Jul 2024 17:54:18 +0800 Subject: [PATCH 061/115] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E6=90=9C?= =?UTF-8?q?=E7=B4=A2=E6=9D=A1=E4=BB=B6=E4=BB=A5=E6=8E=92=E9=99=A4=E7=89=B9?= =?UTF-8?q?=E5=AE=9A=E7=94=A8=E6=88=B7=E7=AD=89=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/lists/user/UserShipLists.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/common/lists/user/UserShipLists.php b/app/common/lists/user/UserShipLists.php index 325f25b35..e66ec7f2c 100644 --- a/app/common/lists/user/UserShipLists.php +++ b/app/common/lists/user/UserShipLists.php @@ -42,6 +42,7 @@ class UserShipLists extends BaseAdminDataLists if(!$this->request->__get('id')){ $arr[]=['id'=>0,'title'=>'一般用户','limit'=>0]; } + $this->searchWhere[]=['id','<>',4]; $lists = UserShip::where($this->searchWhere) ->limit($this->limitOffset, $this->limitLength) ->field($field) From ab72e2095b84633bce8154b0ae8a111a93968fc7 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Mon, 1 Jul 2024 18:03:43 +0800 Subject: [PATCH 062/115] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E8=88=B9=E5=8F=AA=E4=BF=A1=E6=81=AF=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 --- app/api/controller/user/UserController.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/api/controller/user/UserController.php b/app/api/controller/user/UserController.php index 301a16a8d..78a8e4acd 100644 --- a/app/api/controller/user/UserController.php +++ b/app/api/controller/user/UserController.php @@ -10,6 +10,7 @@ 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_ship\UserShip; use app\common\model\user_sign\UserSign; use support\Cache; use think\Exception; @@ -276,6 +277,7 @@ class UserController extends BaseApiController $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['ship_name']=$user['user_ship']>0?UserShip::where('id',$user['user_ship'])->value('title'):''; $user['address_info']=$address; return $this->success('ok',$user->toArray()); }else{ From fd63af5cd025da469605845b7242d102b6614186 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Mon, 1 Jul 2024 18:05:06 +0800 Subject: [PATCH 063/115] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E4=BA=86?= =?UTF-8?q?=E5=BD=93uid=E4=B8=8D=E5=AD=98=E5=9C=A8=E6=97=B6=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=E7=A9=BA=E6=95=B0=E7=BB=84=E7=9A=84=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/store/lists/user/UserLists.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/store/lists/user/UserLists.php b/app/store/lists/user/UserLists.php index aeb929764..234e7f15d 100644 --- a/app/store/lists/user/UserLists.php +++ b/app/store/lists/user/UserLists.php @@ -44,6 +44,8 @@ class UserLists extends BaseAdminDataLists implements ListsSearchInterface $uid=UserAddress::where('village',$street)->group('uid')->column('uid'); if($uid){ $this->searchWhere=['uid','=',$uid]; + }else{ + return []; } } $field = "id,nickname,real_name,sex,avatar,account,mobile,now_money,user_ship,create_time,purchase_funds,integral"; From 4852860346af73018fc9b13c16729ffaf0e906c8 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Mon, 1 Jul 2024 18:09:12 +0800 Subject: [PATCH 064/115] =?UTF-8?q?feat(UserLists):=20=E6=A0=B9=E6=8D=AE?= =?UTF-8?q?=E8=A1=97=E9=81=93=E5=90=8D=E7=A7=B0=E6=9F=A5=E8=AF=A2=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/store/lists/user/UserLists.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/store/lists/user/UserLists.php b/app/store/lists/user/UserLists.php index 234e7f15d..898bf2f5e 100644 --- a/app/store/lists/user/UserLists.php +++ b/app/store/lists/user/UserLists.php @@ -41,7 +41,7 @@ class UserLists extends BaseAdminDataLists implements ListsSearchInterface { $street=$this->request->get('street',''); if($street){ - $uid=UserAddress::where('village',$street)->group('uid')->column('uid'); + $uid=UserAddress::where('street',$street)->group('uid')->column('uid'); if($uid){ $this->searchWhere=['uid','=',$uid]; }else{ From 8f4289f48f1cd32f44878ad5b25e8a38b5c8a0d4 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Mon, 1 Jul 2024 18:16:04 +0800 Subject: [PATCH 065/115] =?UTF-8?q?feat(UserLists):=20=E6=A0=B9=E6=8D=AE?= =?UTF-8?q?=E8=A1=97=E9=81=93=E4=BF=A1=E6=81=AF=E4=BF=AE=E6=94=B9=E6=90=9C?= =?UTF-8?q?=E7=B4=A2=E6=9D=A1=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/store/lists/user/UserLists.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/store/lists/user/UserLists.php b/app/store/lists/user/UserLists.php index 898bf2f5e..17e5a156d 100644 --- a/app/store/lists/user/UserLists.php +++ b/app/store/lists/user/UserLists.php @@ -43,7 +43,8 @@ class UserLists extends BaseAdminDataLists implements ListsSearchInterface if($street){ $uid=UserAddress::where('street',$street)->group('uid')->column('uid'); if($uid){ - $this->searchWhere=['uid','=',$uid]; + $this->searchWhere=[]; + $this->searchWhere[]=['id','in',$uid]; }else{ return []; } From 3278755dd407f697d22bc2f5367d3ad89fc94be4 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Mon, 1 Jul 2024 18:30:07 +0800 Subject: [PATCH 066/115] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E8=B6=85?= =?UTF-8?q?=E6=97=B6=E8=AE=A2=E5=8D=95=E9=80=9A=E7=9F=A5=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/queue/redis/CodePaySend.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/queue/redis/CodePaySend.php b/app/queue/redis/CodePaySend.php index 3c4d781ba..da3da4e95 100644 --- a/app/queue/redis/CodePaySend.php +++ b/app/queue/redis/CodePaySend.php @@ -55,6 +55,7 @@ class CodePaySend implements Consumer if($order){ $res=UserRecharge::where($data)->update(['status'=>-1]); if($res){ + PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type'=>'INDUSTRYMEMBERS','msg'=>'支付超时,订单已被取消,请重新提交订单','data'=>['id'=>$data['id'],'paid'=>0]]); PushService::push('wechat_mmp_' . $order['uid'], $order['uid'], ['type'=>'INDUSTRYMEMBERS','msg'=>'支付超时,订单已被取消,请重新提交订单','data'=>['id'=>$data['id'],'paid'=>0]]); } } From 3ae5eab67809367822ed74c62bf66238d0c4aaa0 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Tue, 2 Jul 2024 09:24:12 +0800 Subject: [PATCH 067/115] =?UTF-8?q?feat:=20=E7=A7=BB=E9=99=A4=E4=BA=86=20U?= =?UTF-8?q?serLists=20=E7=B1=BB=E4=B8=AD=E7=9A=84=E7=A9=BA=E6=90=9C?= =?UTF-8?q?=E7=B4=A2=E6=9D=A1=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/store/lists/user/UserLists.php | 1 - 1 file changed, 1 deletion(-) diff --git a/app/store/lists/user/UserLists.php b/app/store/lists/user/UserLists.php index 17e5a156d..91a532214 100644 --- a/app/store/lists/user/UserLists.php +++ b/app/store/lists/user/UserLists.php @@ -43,7 +43,6 @@ class UserLists extends BaseAdminDataLists implements ListsSearchInterface if($street){ $uid=UserAddress::where('street',$street)->group('uid')->column('uid'); if($uid){ - $this->searchWhere=[]; $this->searchWhere[]=['id','in',$uid]; }else{ return []; From 08f6eedff4b81ab6c44e8791ca7184a733a5f443 Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Tue, 2 Jul 2024 09:44:23 +0800 Subject: [PATCH 068/115] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../StoreBranchProductLists.php | 25 +------------------ 1 file changed, 1 insertion(+), 24 deletions(-) diff --git a/app/admin/lists/store_branch_product/StoreBranchProductLists.php b/app/admin/lists/store_branch_product/StoreBranchProductLists.php index c4ced3bf6..50b5906e7 100644 --- a/app/admin/lists/store_branch_product/StoreBranchProductLists.php +++ b/app/admin/lists/store_branch_product/StoreBranchProductLists.php @@ -32,6 +32,7 @@ class StoreBranchProductLists extends BaseAdminDataLists implements ListsSearchI '=' => ['product_id', 'cate_id','store_id','status'], '%pipe_like%' => ['store_name_code'=>'store_name|bar_code'], '%like%' => ['store_name'], + '<='=> ['stock'], ]; } @@ -47,7 +48,6 @@ class StoreBranchProductLists extends BaseAdminDataLists implements ListsSearchI */ public function lists(): array { - $status = $this->params['status'] ?? ''; $class_all=$this->request->get('class_all'); $where=[]; if($class_all){ @@ -69,17 +69,6 @@ class StoreBranchProductLists extends BaseAdminDataLists implements ListsSearchI ->when(!empty($this->adminInfo['store_id']), function ($query) { $query->where('store_id', $this->adminInfo['store_id']); }) - ->when(!empty($status), function ($query) use ($status) { - if ($status == 1) { - $query->where('status', $status); - } elseif ($status == 2) { - $query->where('status', 0); - } elseif ($status == 3) { - $query->where('stock', '<=', 0); - } elseif ($status == 4) { - $query->where('stock', '<', 10)->where('stock', '>', 0); - } - }) ->limit($this->limitOffset, $this->limitLength) ->order(['sort' => 'desc','stock'=>'desc','id' => 'desc']) ->select() @@ -101,22 +90,10 @@ class StoreBranchProductLists extends BaseAdminDataLists implements ListsSearchI */ public function count(): int { - $status = $this->params['status'] ?? ''; return StoreBranchProduct::where($this->searchWhere) ->when(!empty($this->adminInfo['store_id']), function ($query) { $query->where('store_id', $this->adminInfo['store_id']); }) - ->when(!empty($status), function ($query) use ($status) { - if ($status == 1) { - $query->where('status', $status); - } elseif ($status == 2) { - $query->where('status', 0); - } elseif ($status == 3) { - $query->where('stock', '<=', 0); - } elseif ($status == 4) { - $query->where('stock', '<', 10)->where('stock', '>', 0); - } - }) ->count(); } From 54844d161ee455b79d1c889004e4cde58387921f Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Tue, 2 Jul 2024 10:43:53 +0800 Subject: [PATCH 069/115] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=88=87=E6=8D=A2?= =?UTF-8?q?=E5=BA=97=E9=93=BA=E7=9A=84=E9=80=BB=E8=BE=91=E5=92=8C=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E7=9A=84=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/lists/order/OrderList.php | 4 ++++ app/api/logic/order/OrderLogic.php | 7 +++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/app/api/lists/order/OrderList.php b/app/api/lists/order/OrderList.php index e97c09067..410e066f4 100644 --- a/app/api/lists/order/OrderList.php +++ b/app/api/lists/order/OrderList.php @@ -8,6 +8,7 @@ use app\common\lists\ListsSearchInterface; use app\common\model\store_branch_product\StoreBranchProduct; use app\common\model\store_order\StoreOrder; use app\common\model\store_order_cart_info\StoreOrderCartInfo; +use app\common\model\store_product\StoreProduct; use app\common\model\store_product_unit\StoreProductUnit; /** @@ -56,6 +57,9 @@ class OrderList extends BaseAdminDataLists implements ListsSearchInterface ->field('product_id,cart_num,verify_code,is_writeoff,writeoff_time,old_cart_id,cart_info')->limit(3)->select() ->each(function ($v) use ($item) { $find = StoreBranchProduct::where('product_id', $v['product_id'])->where('store_id', $item['store_id'])->withTrashed()->find(); + if(empty($find)){ + $find = StoreProduct::where('id', $v['product_id'])->withTrashed()->find(); + } $v['store_name'] = $find['store_name']; $v['image'] = $find['image']; // $v['price'] = $find['price']; diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index e92ce680a..01059da59 100644 --- a/app/api/logic/order/OrderLogic.php +++ b/app/api/logic/order/OrderLogic.php @@ -82,8 +82,11 @@ class OrderLogic extends BaseLogic foreach ($cart_select as $k => $v) { $find = StoreBranchProduct::where(['product_id' => $v['product_id'], 'store_id' => $params['store_id']])->field($field)->withTrashed()->find(); if (!$find) { - unset($cart_select[$k]); - continue; +// unset($cart_select[$k]); +// continue; + $field = 'id branch_product_id,store_name,image,unit,price,vip_price,cost,purchase, id product_id'; + $find = StoreProduct::where(['id' => $v['product_id']])->field($field)->withTrashed()->find(); + $cart_select[$k]['status'] = 1;//缺货标识 } unset($cart_select[$k]['id']); $cart_select[$k]['total_price'] = bcmul($v['cart_num'], $find['price'], 2); //订单总价 From 3c9c20e0f42aa996af3a5a5d6dfa163a125a0ac1 Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Tue, 2 Jul 2024 10:51:32 +0800 Subject: [PATCH 070/115] =?UTF-8?q?=E6=B3=A8=E9=87=8A=E5=88=86=E7=B1=BB?= =?UTF-8?q?=E5=87=8F=E5=B0=91=E6=95=B0=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/logic/order/OrderLogic.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index 01059da59..806562612 100644 --- a/app/api/logic/order/OrderLogic.php +++ b/app/api/logic/order/OrderLogic.php @@ -254,10 +254,10 @@ class OrderLogic extends BaseLogic $goods_list[$k]['uid'] = $uid; $goods_list[$k]['cart_id'] = implode(',', $cartId); $goods_list[$k]['delivery_id'] = $params['store_id']; //商家id - $StoreBranchProduct = StoreBranchProduct::where('id', $v['branch_product_id'])->withTrashed()->find(); - if ($StoreBranchProduct['stock'] - $v['cart_num'] <= 0) { - Db::name('store_product_cate')->where(['cate_id' => $StoreBranchProduct['cate_id'], 'store_id' => $params['store_id']])->update(['count' => 0]); - } +// $StoreBranchProduct = StoreBranchProduct::where('id', $v['branch_product_id'])->withTrashed()->find(); +// if ($StoreBranchProduct['stock'] - $v['cart_num'] <= 0) { +// Db::name('store_product_cate')->where(['cate_id' => $StoreBranchProduct['cate_id'], 'store_id' => $params['store_id']])->update(['count' => 0]); +// } } (new StoreOrderCartInfo())->saveAll($goods_list); $where = ['is_pay' => 0]; From e1283949342dc0465d49b42293213d2691f74fa5 Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Tue, 2 Jul 2024 10:58:00 +0800 Subject: [PATCH 071/115] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=AF=A6=E6=83=85?= =?UTF-8?q?=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/api/logic/order/OrderLogic.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index 806562612..591795956 100644 --- a/app/api/logic/order/OrderLogic.php +++ b/app/api/logic/order/OrderLogic.php @@ -424,6 +424,9 @@ class OrderLogic extends BaseLogic $find['goods_list'] = StoreOrderCartInfo::where('oid', $find['id']) ->field('product_id,cart_num nums,store_id')->select()->each(function ($item) use ($find) { $find = StoreBranchProduct::where('product_id', $item['product_id'])->where('store_id', $find['store_id'])->find(); + if(empty($find)){ + $find = StoreProduct::where('id', $item['product_id'])->withTrashed()->find(); + } $item['store_name'] = $find['store_name']; $item['image'] = $find['image']; $item['price'] = $find['price']; From c331a2735c0d8019f97e4b51be3e8b24ff3f483a Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Tue, 2 Jul 2024 10:59:48 +0800 Subject: [PATCH 072/115] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=94=B6=E9=93=B6?= =?UTF-8?q?=E5=8F=B0=E6=94=AF=E4=BB=98=E9=99=90=E5=88=B6?= 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 cbba40a69..0857a18b4 100644 --- a/app/store/controller/store_order/StoreOrderController.php +++ b/app/store/controller/store_order/StoreOrderController.php @@ -142,7 +142,7 @@ class StoreOrderController extends BaseAdminController $params = $this->request->post(); if ( $auth_code == '' && $pay_type != PayEnum::CASH_PAY && $pay_type != PayEnum::PURCHASE_FUNDS - && $pay_type != PayEnum::GIFT_FUNDS + && $pay_type != PayEnum::GIFT_FUNDS && $pay_type != PayEnum::BALANCE_PAY ) { return $this->fail('支付条码不能为空'); } From 4b849edc76f48d34523c9a96429e095358838325 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Tue, 2 Jul 2024 11:02:00 +0800 Subject: [PATCH 073/115] =?UTF-8?q?feat(UserController):=20=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E7=94=A8=E6=88=B7=E7=AD=BE=E5=88=B0=E9=80=BB=E8=BE=91?= =?UTF-8?q?=EF=BC=8C=E4=BF=AE=E5=A4=8D=E7=A7=AF=E5=88=86=E8=AE=A1=E7=AE=97?= =?UTF-8?q?=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/user/UserController.php | 4 +- app/api/logic/order/OrderLogic.php | 56 ++------- app/common/logic/PayNotifyLogic.php | 109 +---------------- app/common/logic/UserSignLogic.php | 115 ++++++++++++++++++ app/common/model/user_sign copy/UserSign.php | 21 ++++ .../store_order/StoreOrderController.php | 1 + 6 files changed, 153 insertions(+), 153 deletions(-) create mode 100644 app/common/logic/UserSignLogic.php create mode 100644 app/common/model/user_sign copy/UserSign.php diff --git a/app/api/controller/user/UserController.php b/app/api/controller/user/UserController.php index 78a8e4acd..a1b0142b5 100644 --- a/app/api/controller/user/UserController.php +++ b/app/api/controller/user/UserController.php @@ -233,8 +233,8 @@ class UserController extends BaseApiController $params['page_size'] = $page_size > 0 ? $page_size : 15; $res = UserLogic::dealDetails($params,$this->userId); $integral = User::where('id',$this->userId)->value('integral'); - $number = 0;//UserSign::where('id',$this->userId)->where('status',0)->sum('number'); - $GetNumber = 0;//UserSign::where('id',$this->userId)->where('status',1)->sum('number'); + $number = UserSign::where('id',$this->userId)->where('status',0)->sum('number'); + $GetNumber = UserSign::where('id',$this->userId)->where('status',1)->sum('number'); $res['page_no'] = $params['page_no']; $res['page_size'] = $params['page_size']; $res['extend'] = [ diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index e92ce680a..040ccd663 100644 --- a/app/api/logic/order/OrderLogic.php +++ b/app/api/logic/order/OrderLogic.php @@ -10,6 +10,7 @@ use app\common\logic\BaseLogic; use app\common\logic\CapitalFlowLogic; use app\common\logic\PayNotifyLogic; use app\common\logic\StoreFinanceFlowLogic; +use app\common\logic\UserSignLogic; use app\common\model\Config; use app\common\model\dict\DictData; use app\common\model\dict\DictType; @@ -161,15 +162,15 @@ class OrderLogic extends BaseLogic 'activity_price' => self::$activity_price, 'activities' => self::$activity_price > 0 ? 1 : 0, 'deduction_price' => self::$deduction_price, - 'is_vip' => 0, + 'source' => 0, 'is_storage' => $params['is_storage'] ?? 0, ]; $order['default_delivery'] = 0; if ($params['store_id']) { $order['default_delivery'] = SystemStore::where('id', $params['store_id'])->value('is_send'); } - if ($user && $user['user_ship'] >= 1 && $user['user_ship'] <= 3) { - $order['is_vip'] = 1; + if (isset($params['source']) && $params['source'] > 0) { + $order['source'] = $params['source']; } //处理返回最近的店铺 $store['near_store'] = []; @@ -514,18 +515,6 @@ class OrderLogic extends BaseLogic $financeFlowLogic->updateStatusUser($v['id'], $v['other_uid'], $v['number'], $v['order_id']); } } - if ($order['uid'] && $order['pay_price'] >= 500) { - $level = User::where('id', $order['uid'])->value('user_ship'); - $discount = PayNotifyLogic::getDiscount($level); - $user_number = bcmul($order['pay_price'], $discount, 2); - User::where('id', $order['uid'])->inc('integral', $user_number)->update(); - // 核销加冻结礼品券 解冻礼品券 - self::addUserSing($order, 2, $user_number); //冻结 - - self::addUserSing($order, 4, $user_number, 1, 1); //解冻 - - UserSign::where(['uid' => $order['uid'], 'order_id' => $order['order_id'], 'title' => 1])->update(['status' => 1]); - } if ($order['spread_uid'] > 0) { $spread_find = $financeFlow->where(['order_id' => $order['id'], 'financial_pm' => 1, 'financial_type' => 12, 'other_uid' => $order['spread_uid']])->find(); if ($spread_find) { @@ -535,6 +524,10 @@ class OrderLogic extends BaseLogic $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); + //积分结算 + if($order['is_storage']==0&&$order['source']==1){ + UserSignLogic::WriteOff($order); + } Db::commit(); return true; } catch (\Exception $e) { @@ -544,39 +537,6 @@ class OrderLogic extends BaseLogic } } - /** - * 处理冻结和解冻 礼品券得记录 - * @param $order // 订单 - * @param $category // 分类 - * @param $number // 金额 - * @param int $pm //收支 0支出 1获得 - * @type $type //类型 0冻结 1解冻 - * @return true - */ - public static function addUserSing($order, $category, $number, int $pm = 0, $type = 0) - { - $user_sing = new UserSign(); - $sing = [ - 'uid' => $order['uid'], - 'order_id' => $order['order_id'], - // 'title' => '购买商品获得兑换券', - // 'title' => PayNotifyLogic::getTitle($category,$number), - 'title' => $category, - 'financial_pm' => $pm, - 'store_id' => $order['store_id'], - 'number' => $number, - 'type' => $type, - 'status' => 1, - ]; - $user_sing->save($sing); - return true; - } - - - - - - //不走二次分钱的核销 public static function lessWriteOff($params): bool { diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index 54b32748a..45f2a2a80 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -2,6 +2,7 @@ namespace app\common\logic; +use app\admin\logic\user_ship\UserShipLogic; use app\api\logic\order\OrderLogic; use app\common\enum\OrderEnum; use app\common\enum\PayEnum; @@ -667,66 +668,6 @@ class PayNotifyLogic extends BaseLogic return true; } - //入冻结礼品券 - public static function addUserSing($order) - { - $user_sing = new UserSign(); - if ($order['uid'] > 0 && $order['total_price'] >= 500) { - $user_number = bcmul($order['pay_price'], '0.10', 2); - $sing = [ - 'uid' => $order['uid'], - 'order_id' => $order['order_id'], - 'title' => '购买商品获得兑换券', - 'financial_pm' => 1, - 'store_id' => $order['store_id'], - 'number' => $user_number, - ]; - $user_sing->save($sing); - } - return true; - } - - public static function dealRechargeFrozen($order) - { - $total_vip = bcmul($order['price'], 0.1, 2); - $user_sing = new UserSign(); - //冻结 - $sing[] = [ - 'uid' => $order['uid'], - 'order_id' => $order['order_id'], - // 'title' => '充值获得冻结兑换券', - // 'title' => self::getTitle(7,$total_vip), - 'title' => 7, - 'financial_pm' => 1, - 'store_id' => $order['store_id'], - // 'type' => 1, - 'status' => 1, - 'number' => $total_vip, - 'back_num' => $total_vip, - ]; - //礼品券得 - $sing[] = [ - 'uid' => $order['uid'], - 'order_id' => $order['order_id'], - // 'title' => '充值获得冻结兑换券', - // 'title' => self::getTitle(4,$total_vip), - 'title' => 4, - 'financial_pm' => 1, - 'store_id' => $order['store_id'], - 'type' => 1, - 'status' => 1, - 'number' => $total_vip, - 'back_num' => $total_vip, - ]; - - $user_sing->saveAll($sing); - - User::where('id', $order->uid)->inc('integral', $total_vip)->update(); - - return true; - } - - /** * 充值 */ @@ -755,11 +696,9 @@ class PayNotifyLogic extends BaseLogic 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) { - self::dealRechargeFrozen($order); - } + + UserSignLogic::dealRechargeFrozen($user,$order,$order['user_ship']); + //更新等级 $user->user_ship = $order['user_ship']; @@ -902,6 +841,8 @@ class PayNotifyLogic extends BaseLogic Log::error('订单推送失败:'.$e->getMessage()); // 异常处理代码,例如记录日志或发送通知等。 } + //积分写入 + UserSignLogic::OrderWrite($order); if ($off_activity == 1) { //-----活动价结算更改 $financeLogic->order = $order; @@ -910,27 +851,6 @@ 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(); - $user_ship = User::where('id', $order['uid'])->value('user_ship'); //会员不加兑换券 - if ( - $order['uid'] > 0 && $order['total_price'] >= 500 - && $order['pay_type'] != PayEnum::PURCHASE_FUNDS && $user_ship != 1 && $order['shipping_type'] !=3 - ) { - $level = User::where('id',$order['uid'])->value('user_ship'); - $discount = self::getDiscount($level); - $user_number = bcmul($order['pay_price'], $discount, 2); - $sing = [ - 'uid' => $order['uid'], - 'order_id' => $order['order_id'], - // 'title' => '购买商品获得兑换券', - // 'title' => self::getTitle(1,$user_number), - 'title' => 1, - 'financial_pm' => 1, - 'store_id' => $order['store_id'], - 'number' => $user_number, - 'status' => 0, - ]; - $user_sing->save($sing); - } return false; } if ($order['uid'] > 0) { @@ -938,23 +858,6 @@ class PayNotifyLogic extends BaseLogic //用户下单该用户等级为1得时候才处理冻结金额 $user = User::where('id', $order['uid'])->find(); $user_ship = $user['user_ship']; - if($order['total_price'] >= 500 && $order['pay_type'] !=PayEnum::PURCHASE_FUNDS && $user_ship !=1 - && $order['shipping_type'] !=3){ - $discount = self::getDiscount($user_ship); - $user_number = bcmul($order['pay_price'], $discount, 2); - $sing = [ - 'uid' => $order['uid'], - 'order_id' => $order['order_id'], -// 'title' => '购买商品获得兑换券', -// 'title' => self::getTitle(1,$user_number), - 'title' => 1, - 'financial_pm' => 1, - 'store_id' => $order['store_id'], - 'number' => $user_number, - 'status' => 0, - ]; - $user_sing->save($sing); - } //纯在分销关系的时候要去判断分销出来的用户的采购款的额度 (只有会员按照这个逻辑拆分,其余的还是按照正常的支付金额) if ($user['user_ship'] == 1 && $order['pay_type'] != PayEnum::CASH_PAY) { $vipFrozenAmount = self::dealFrozenPrice($order['id']); diff --git a/app/common/logic/UserSignLogic.php b/app/common/logic/UserSignLogic.php new file mode 100644 index 000000000..9c12a7a70 --- /dev/null +++ b/app/common/logic/UserSignLogic.php @@ -0,0 +1,115 @@ +uid)->count(); + if ($count == 0 && in_array($user_ship, [1, 2, 3, 5, 6, 7, 8])) { + $write = self::write($order, $total_vip, 0, 1); + self::write_log($write, $total_vip, 0); + User::where('id', $order->uid)->inc('integral', $total_vip)->update(); + } else { + $write = self::write($order, $total_vip, 0, 0); + self::write_log($write, $total_vip, 0); + } + return true; + } + + /** + * 来自订单 + */ + public static function OrderWrite($order) + { + $total_vip = bcmul($order['price'], 0.1, 2); + + //非收银台订单冻结里礼品卷 + if ($order['source'] == 0) { + $write = self::write($order, $total_vip, 1, 0); + } else { + $write = self::write($order, $total_vip, 1, 1); + self::write_log($write, $total_vip, 1); + User::where('id', $order->uid)->inc('integral', $total_vip)->update(); + } + } + + /** + * 核销 + */ + public static function WriteOff($order){ + $find=UserSign::where(['order_id'=>$order['order_id'],'status'=>0,'financial_pm'=>1,'order_type'=>1])->find(); + if($find){ + $find->status=1; + $find->save(); + User::where('id', $order->uid)->inc('integral', $find['number'])->update(); + self::write_log($find,$find['number'], 1); + + } + } + /** + * 储存商品积分结算 + */ + public static function storage($order){ + $find=UserSign::where(['order_id'=>$order['order_id'],'status'=>0,'financial_pm'=>1,'order_type'=>1])->find(); + if($find){ + // if($or) + // $find->status=1; + // $find->save(); + // User::where('id', $order->uid)->inc('integral', $find['number'])->update(); + // self::write_log($find,$find['number'], 1); + + } + } + + + public static function write($order, $total_vip, $order_type = 0, $status = 0, $title = 4, $pm = 1) + { + //礼品券得 + $sing = [ + 'uid' => $order['uid'], + 'order_id' => $order['order_id'], + 'title' => $title, + 'financial_pm' => $pm, + 'store_id' => $order['store_id'], + 'status' => $status, + 'number' => $total_vip, + 'back_num' => $total_vip, + 'order_type' => $order_type, + + ]; + return UserSign::create($sing); + } + public static function write_log($write, $total_vip, $order_type = 0, $title = 4, $pm = 1) + { + //礼品券日志记录 + $sing = [ + 'uid' => $write['uid'], + 'sid' => $write['id'], + 'order_id' => $write['order_id'], + 'title' => $title, + 'financial_pm' => $pm, + 'order_type' => $order_type, + 'status' => 1, + 'number' => $total_vip, + ]; + UserSignLog::create($sing); + } + +} diff --git a/app/common/model/user_sign copy/UserSign.php b/app/common/model/user_sign copy/UserSign.php new file mode 100644 index 000000000..253b31a46 --- /dev/null +++ b/app/common/model/user_sign copy/UserSign.php @@ -0,0 +1,21 @@ +request->adminInfo['store_id']; //当前登录的店铺id,用于判断是否是当前店铺的订单 $params['shipping_type'] =3; + $params['source'] =1; $order = OrderLogic::createOrder($cartId, $addressId, $user, $params); if ($order != false) { switch ($pay_type) { From 83fce9e9dd40bd2a2d67f836b359cfa3e1d2b01b Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Tue, 2 Jul 2024 11:31:52 +0800 Subject: [PATCH 074/115] =?UTF-8?q?feat:=20=E7=A7=BB=E9=99=A4=E6=94=AF?= =?UTF-8?q?=E4=BB=98=E7=B1=BB=E5=9E=8B=E4=B8=BA3=E6=97=B6=E7=9A=84?= =?UTF-8?q?=E5=85=91=E6=8D=A2=E5=88=B8=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 | 41 +++-------------------------- app/common/logic/UserSignLogic.php | 2 +- 2 files changed, 4 insertions(+), 39 deletions(-) diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index 45f2a2a80..484f0b79f 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -96,14 +96,6 @@ class PayNotifyLogic extends BaseLogic $capitalFlowDao->userExpense('user_order_balance_pay', 'order', $order['id'], $order['pay_price'], '', 0, $order['store_id']); self::dealProductLog($order); if ($order['shipping_type'] == 3) { - //预留收银台余额支付得兑换券逻辑 - if ($order->uid >0) { - $level = User::where('id',$order->uid)->value('user_ship'); - $discount = self::getDiscount($level); - $total_vip = bcmul($order['pay_price'], $discount, 2); - self::addNewUserSing($order,8,$total_vip,1,1); - User::where('id', $order->uid)->inc('integral', $total_vip)->update(); - } // self::descStock($order['id']); } self::afterPay($order); @@ -154,18 +146,18 @@ class PayNotifyLogic extends BaseLogic $user->integral = bcsub($user['integral'], $order['pay_price'], 2); $user->save(); //入礼品券表扣款记录 - $sing[] = [ + $sing = [ 'uid' => $order['uid'], 'order_id' => $order['order_id'], // 'title' => '订单扣除兑换券', 'title' => 5, 'financial_pm' => 0, + 'status' => 1, 'store_id' => $order['store_id'], 'number' => $order['pay_price'], - 'type' => 1, 'user_ship' => $user['user_ship'], ]; - (new UserSign())->saveAll($sing); + UserSign::create($sing); if ($extra && $extra['store_id']) { $params = [ @@ -744,24 +736,6 @@ class PayNotifyLogic extends BaseLogic if ($order['shipping_type'] == 3) { self::descStock($order['id']); - //直接加到礼品券中 - $user_sing = new UserSign(); - $level = User::where('id',$order['uid'])->value('user_ship'); - $discount = self::getDiscount($level); - $total_vip = bcmul($order['pay_price'], $discount, 2); - $sing[] = [ - 'uid' => $order['uid'], - 'order_id' => $order['order_id'], - 'title' => 8, - 'financial_pm' => 1, - 'store_id' => $order['store_id'], - 'type' => 1, - 'status' => 1, - 'number' => $total_vip, - 'back_num' => $total_vip, - ]; - $user_sing->saveAll($sing); - User::where('id', $order->uid)->inc('integral', $total_vip)->update(); } @@ -800,15 +774,6 @@ class PayNotifyLogic extends BaseLogic self::dealProductLog($order); if ($order['shipping_type'] == 3) { self::descStock($order['id']); - //直接加兑换券到对应得账户 - if ($order->uid >0) { - $level = User::where('id',$order['uid'])->value('user_ship'); - $discount = self::getDiscount($level); - $total_vip = bcmul($order['pay_price'], $discount, 2); - self::addNewUserSing($order,8,$total_vip,1,1); - User::where('id', $order->uid)->inc('integral', $total_vip)->update(); - } - } // if ($order->pay_type == 9) { diff --git a/app/common/logic/UserSignLogic.php b/app/common/logic/UserSignLogic.php index 9c12a7a70..dfcbf4c76 100644 --- a/app/common/logic/UserSignLogic.php +++ b/app/common/logic/UserSignLogic.php @@ -38,7 +38,7 @@ class UserSignLogic extends BaseLogic */ public static function OrderWrite($order) { - $total_vip = bcmul($order['price'], 0.1, 2); + $total_vip = bcmul($order['pay_price'], 0.1, 2); //非收银台订单冻结里礼品卷 if ($order['source'] == 0) { From 5522ebc920f37961adb4a298778f7389432a43f5 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Tue, 2 Jul 2024 11:41:34 +0800 Subject: [PATCH 075/115] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E7=A7=AF=E5=88=86=E7=BB=93=E7=AE=97=E6=9D=A1=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/logic/order/OrderLogic.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index a691a76b0..df902eb98 100644 --- a/app/api/logic/order/OrderLogic.php +++ b/app/api/logic/order/OrderLogic.php @@ -531,7 +531,7 @@ class OrderLogic extends BaseLogic $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); //积分结算 - if($order['is_storage']==0&&$order['source']==1){ + if($order['is_storage']==0&&$order['source']==0){ UserSignLogic::WriteOff($order); } Db::commit(); From 78a44016e5bf88423d715dfc8723c68774fde5d6 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Tue, 2 Jul 2024 11:46:40 +0800 Subject: [PATCH 076/115] =?UTF-8?q?rename:=20=E9=87=8D=E5=91=BD=E5=90=8D?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E7=AD=BE=E5=88=B0=E6=A8=A1=E5=9E=8B=E6=96=87?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../UserSign.php => user_sign_log/UserSignLog.php} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename app/common/model/{user_sign copy/UserSign.php => user_sign_log/UserSignLog.php} (100%) diff --git a/app/common/model/user_sign copy/UserSign.php b/app/common/model/user_sign_log/UserSignLog.php similarity index 100% rename from app/common/model/user_sign copy/UserSign.php rename to app/common/model/user_sign_log/UserSignLog.php From a717662cb9e2e6e9f9121468cb4d0a0ce65f8eb0 Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Tue, 2 Jul 2024 11:51:54 +0800 Subject: [PATCH 077/115] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=9F=A5=E8=AF=A2?= =?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/api/logic/user/UserLogic.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/api/logic/user/UserLogic.php b/app/api/logic/user/UserLogic.php index 6a5d2b628..5376a200b 100644 --- a/app/api/logic/user/UserLogic.php +++ b/app/api/logic/user/UserLogic.php @@ -89,6 +89,7 @@ class UserLogic extends BaseLogic ->find(); //判断是不是员工 if($data){ + $GetNumber = $data['integral']; $data = $data->toArray(); $all =UserShip::field('id,title,limit')->select()->toArray(); $new = self::getNextArrayByID($all,$data['user_ship']); @@ -117,11 +118,11 @@ class UserLogic extends BaseLogic 'is_writeoff'=>0,'uid'=>$uid ])->whereIn('shipping_type',[1,2])->count(); $data['openid'] = UserAuth::where(['user_id'=>$uid,'terminal'=>1])->value('openid'); - $number=UserSign::where('uid',$uid)->where('status',0)->sum('number'); - $data['integral']=bcadd($data['integral'],$number,2); +// $number=UserSign::where('uid',$uid)->where('status',0)->sum('number'); +// $data['integral']=bcadd($data['integral'],$number,2); - $number = UserSign::where('uid',$uid)->where(['status'=>0,'financial_pm'=>1])->sum('number'); - $GetNumber = UserSign::where('uid',$uid)->where('status',1)->sum('number'); + $number = UserSign::where('uid',$uid)->where(['type'=>0,'status'=>1])->sum('number'); +// $GetNumber = UserSign::where('uid',$uid)->where('status',1)->sum('number'); $data['number'] =bcadd($number,0,2); $data['GetNumber'] =bcadd($GetNumber,0,2); }else{ From 7421de9d1025acdabac210b3a2ec7623a7f2765a Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Tue, 2 Jul 2024 13:54:21 +0800 Subject: [PATCH 078/115] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=BB=8F=E7=BA=AC?= =?UTF-8?q?=E5=BA=A6=E9=BB=98=E8=AE=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/lists/store/SystemStoreLists.php | 47 ++++++++++++++---------- app/api/logic/order/OrderLogic.php | 5 ++- 2 files changed, 31 insertions(+), 21 deletions(-) diff --git a/app/api/lists/store/SystemStoreLists.php b/app/api/lists/store/SystemStoreLists.php index 301b80b05..4462b893b 100644 --- a/app/api/lists/store/SystemStoreLists.php +++ b/app/api/lists/store/SystemStoreLists.php @@ -51,9 +51,9 @@ class SystemStoreLists extends BaseAdminDataLists implements ListsSearchInterfac $latitude = $this->request->get('latitude',''); $longitude = $this->request->get('longitude',''); $cart_id = $this->request->get('cart_id',''); - if(empty($longitude) || empty($latitude)){ - throw new Exception('缺失经纬度'); - } +// if(empty($longitude) || empty($latitude)){ +// throw new Exception('缺失经纬度'); +// } $where[]=['is_show','=',YesNoEnum::YES]; $data = SystemStore::where($this->searchWhere)->where($where) ->field(['id', 'name', 'phone', 'detailed_address', 'image', 'is_show', @@ -65,26 +65,33 @@ class SystemStoreLists extends BaseAdminDataLists implements ListsSearchInterfac ->select() ->toArray(); if($cart_id){ - $cart_id = explode(',',$cart_id); - $cart_select = Cart::whereIn('id', $cart_id) - ->field('id,product_id,cart_num,store_id')->select()->toArray(); - foreach ($cart_select as $v) { - foreach ($data as &$values){ - $store = StoreBranchProduct::where([ - 'store_id'=>$values['id'], - 'product_id'=>$v['product_id'], - ])->field('id,store_name,stock')->withTrashed()->find(); - if(empty($store)){ - $store['stock'] =0; + if($latitude && $longitude){ + $cart_id = explode(',',$cart_id); + $cart_select = Cart::whereIn('id', $cart_id) + ->field('id,product_id,cart_num,store_id')->select()->toArray(); + foreach ($cart_select as $v) { + foreach ($data as &$values){ + $store = StoreBranchProduct::where([ + 'store_id'=>$values['id'], + 'product_id'=>$v['product_id'], + ])->field('id,store_name,stock')->withTrashed()->find(); + if(empty($store)){ + $store['stock'] =0; + } + $values['reservation'] = 0; + if($store['stock'] < $v['cart_num']){ + $values['reservation'] = 1; + } + $values['distance'] = haversineDistance($values['latitude'],$values['longitude'],$latitude,$longitude); } - $values['reservation'] = 0; - if($store['stock'] < $v['cart_num']){ - $values['reservation'] = 1; - } - $values['distance'] = haversineDistance($values['latitude'],$values['longitude'],$latitude,$longitude); - } + } + }else{ + foreach ($data as &$values){ + $values['distance'] = 0; + } } + }else{ foreach ($data as &$value){ $value['distance'] = haversineDistance($value['latitude'],$value['longitude'],$latitude,$longitude); diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index df902eb98..3ea2e26aa 100644 --- a/app/api/logic/order/OrderLogic.php +++ b/app/api/logic/order/OrderLogic.php @@ -176,7 +176,6 @@ class OrderLogic extends BaseLogic $order['source'] = $params['source']; } //处理返回最近的店铺 - $store['near_store'] = []; if ((isset($params['lat']) && $params['lat'] != '') && (isset($params['long']) && $params['long'] != '')) { $storeAll = SystemStore::field('id,name,phone,address,detailed_address,latitude,longitude')->select()->toArray(); $nearestStore = null; @@ -188,9 +187,13 @@ class OrderLogic extends BaseLogic $nearestStore = $value; } } + $store['near_store'] =[]; if ($nearestStore) { $store['near_store'] = $nearestStore; } + }else{ + $store_id = getenv('STORE_ID') ?? 1; + $store['near_store'] =SystemStore::where('id', $store_id)->field('id,name,phone,address,detailed_address,latitude,longitude')->find()??[]; } } catch (\Exception $e) { self::setError($e->getMessage()); From e4c80b9565fc955d04c55e916edb2b7faeb7cf65 Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Tue, 2 Jul 2024 14:09:32 +0800 Subject: [PATCH 079/115] =?UTF-8?q?=E6=B3=A8=E9=87=8A=E5=BA=97=E9=93=BA?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E9=99=90=E5=88=B6=E9=A1=B5=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/store/logic/WorkbenchLogic.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/store/logic/WorkbenchLogic.php b/app/store/logic/WorkbenchLogic.php index 0120bbc53..610582805 100644 --- a/app/store/logic/WorkbenchLogic.php +++ b/app/store/logic/WorkbenchLogic.php @@ -137,9 +137,9 @@ class WorkbenchLogic extends BaseLogic $recharge_field = 'from_unixtime(pay_time,"%Y-%m") as pay_time,sum(price) as pay_price'; } $data['order_list'] = StoreOrder::with('user')->where($where) - ->whereBetweenTime('pay_time', $startTime, $endTime) +// ->whereBetweenTime('pay_time', $startTime, $endTime) ->order('pay_time', 'desc') - ->limit(6) +// ->limit(6) ->select()->each(function($item){ $item->pay_time=$item->pay_time>0?date('Y-m-d H:i:s',$item->pay_time):''; }) From 0b3fc8a7b6705adc6a08ab993c3ae6d4adb43983 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Tue, 2 Jul 2024 14:30:20 +0800 Subject: [PATCH 080/115] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E7=AD=BE=E5=88=B0=E9=80=BB=E8=BE=91=E5=92=8C=E6=94=AF?= =?UTF-8?q?=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/controller/user/UserController.php | 21 ++-- app/api/lists/user_sign/UserSignLists.php | 79 ++++++++++++++ .../lists/user_sign_log/UserSignLogLists.php | 78 ++++++++++++++ app/api/logic/user/UserLogic.php | 3 +- app/common/logic/PayNotifyLogic.php | 33 ------ app/common/logic/UserSignLogic.php | 101 ++++++++++++++---- 6 files changed, 249 insertions(+), 66 deletions(-) create mode 100644 app/api/lists/user_sign/UserSignLists.php create mode 100644 app/api/lists/user_sign_log/UserSignLogLists.php diff --git a/app/api/controller/user/UserController.php b/app/api/controller/user/UserController.php index a1b0142b5..e66171fde 100644 --- a/app/api/controller/user/UserController.php +++ b/app/api/controller/user/UserController.php @@ -3,6 +3,8 @@ namespace app\api\controller\user; use app\api\controller\BaseApiController; +use app\api\lists\user_sign\UserSignLists; +use app\api\lists\user_sign_log\UserSignLogLists; use app\api\logic\user\UserLogic; use app\api\service\UserTokenService; use app\api\validate\UserValidate; @@ -246,18 +248,19 @@ class UserController extends BaseApiController } + /** + * 礼品券/冻结券 + */ public function userSing() { (new UserValidate())->get()->goCheck('fund'); - $page_no = (int)$this->request->get('page_no', 1); - $page_size = (int)$this->request->get('page_size', 15); - $params = $this->request->get(); - $params['page_no'] = $page_no > 0 ? $page_no : 1; - $params['page_size'] = $page_size > 0 ? $page_size : 15; - $res = UserLogic::userSingList($params,$this->userId); - $res['page_no'] = $params['page_no']; - $res['page_size'] = $params['page_size']; - return $this->success('ok', $res); + $type = (int)$this->request->get('type', 1); + if($type==1){ + return $this->dataLists(new UserSignLists()); + }else{ + return $this->dataLists(new UserSignLogLists()); + } + } /** diff --git a/app/api/lists/user_sign/UserSignLists.php b/app/api/lists/user_sign/UserSignLists.php new file mode 100644 index 000000000..af18f8785 --- /dev/null +++ b/app/api/lists/user_sign/UserSignLists.php @@ -0,0 +1,79 @@ +request->get('type',1); + $mark=$this->request->get('mark',''); + if($type==1){ + $this->searchWhere[]=['type','in',[4,9,8,2]]; + $this->searchWhere[]=['status','=',1]; + } + if($mark==1){ + $this->searchWhere[]=['financial_pm','=',1]; + }elseif($mark==2){ + $this->searchWhere[]=['financial_pm','=',0]; + } + $list=UserSign::where($this->searchWhere)->order('id desc') + ->limit($this->limitOffset, $this->limitLength) + ->select()->each(function ($item){ + $item['title']=UserSignLogic::getTitle($item['type'],$item['number']); + return $item; + }); + return $list?->toArray(); + + } + + + /** + * @notes 获取用户标签数量 + * @return int + * @author admin + * @date 2024/06/17 17:02 + */ + public function count(): int + { + return UserLabel::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/api/lists/user_sign_log/UserSignLogLists.php b/app/api/lists/user_sign_log/UserSignLogLists.php new file mode 100644 index 000000000..a5f5834da --- /dev/null +++ b/app/api/lists/user_sign_log/UserSignLogLists.php @@ -0,0 +1,78 @@ +request->get('type',1); + $mark=$this->request->get('mark',''); + if($type==1){ + $this->searchWhere[]=['type','in',[1,7,3]]; + $this->searchWhere[]=['status','=',1]; + } + if($mark==1){ + $this->searchWhere[]=['financial_pm','=',1]; + }elseif($mark==2){ + $this->searchWhere[]=['financial_pm','=',0]; + } + $list=UserSignLog::where($this->searchWhere)->order('id desc') + ->limit($this->limitOffset, $this->limitLength) + ->select()->each(function ($item){ + $item['title']=UserSignLogic::getTitle($item['type'],$item['number']); + return $item; + }); + return $list?->toArray(); + } + + + /** + * @notes 获取用户标签数量 + * @return int + * @author admin + * @date 2024/06/17 17:02 + */ + public function count(): int + { + return UserLabel::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/api/logic/user/UserLogic.php b/app/api/logic/user/UserLogic.php index 6a5d2b628..3088e7392 100644 --- a/app/api/logic/user/UserLogic.php +++ b/app/api/logic/user/UserLogic.php @@ -21,6 +21,7 @@ use app\common\{logic\BaseLogic, model\vip_flow\VipFlow, service\SmsService, service\wechat\WeChatMnpService}; +use app\common\logic\UserSignLogic; use app\common\model\user_label\UserLabel; use support\Cache; use think\facade\Db; @@ -287,7 +288,7 @@ class UserLogic extends BaseLogic } foreach ($data as &$value){ if(!preg_match('/[\x{4e00}-\x{9fa5}]/u', $value['title'])){ - $value['title'] = PayNotifyLogic::getTitle($value['title'],$value['number']); + $value['title'] = UserSignLogic::getTitle($value['title'],$value['number']); } } return [ diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index 484f0b79f..c2b36788c 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -1130,37 +1130,4 @@ class PayNotifyLogic extends BaseLogic return 0.1; } } - - - - //礼品券相关对应文本 - public static function getTitle($category, $amount) - { - switch ($category) { - /**冻结券**/ - //收入 - case 1: - return "购买商品{$amount}元获得冻结卷"; - case 7: - return "充值{$amount}元获得冻结卷"; - //支出 - case 2: - return "核销商品{$amount}元解冻冻结卷"; - case 3: - return "退款{$amount}元扣除冻结卷"; - /**礼品券**/ - //收入 - case 4: - return "核销金额{$amount}元获得礼品卷"; - //支出 - case 5: - return "兑换{$amount}元商品扣除礼品卷"; - case 6: - return "退款{$amount}元扣除礼品卷"; - case 8: - return "收银台支付{$amount}元增加礼品卷"; - default: - return "订单支付{$amount}元"; - } - } } diff --git a/app/common/logic/UserSignLogic.php b/app/common/logic/UserSignLogic.php index dfcbf4c76..dfaf79ea2 100644 --- a/app/common/logic/UserSignLogic.php +++ b/app/common/logic/UserSignLogic.php @@ -23,12 +23,13 @@ class UserSignLogic extends BaseLogic $total_vip = bcmul($order['price'], 0.1, 2); $count = UserSign::where('uid', $order->uid)->count(); if ($count == 0 && in_array($user_ship, [1, 2, 3, 5, 6, 7, 8])) { - $write = self::write($order, $total_vip, 0, 1); - self::write_log($write, $total_vip, 0); + //首充 + $write = self::write($order, $total_vip, 0, 1,9); + self::write_log($write, $total_vip, 0,9); User::where('id', $order->uid)->inc('integral', $total_vip)->update(); } else { - $write = self::write($order, $total_vip, 0, 0); - self::write_log($write, $total_vip, 0); + $write = self::write($order, $total_vip, 0, 0,7); + self::write_log($write, $total_vip, 0,7); } return true; } @@ -40,12 +41,12 @@ class UserSignLogic extends BaseLogic { $total_vip = bcmul($order['pay_price'], 0.1, 2); - //非收银台订单冻结里礼品卷 if ($order['source'] == 0) { - $write = self::write($order, $total_vip, 1, 0); + //非收银台订单冻结礼品卷 + self::write($order, $total_vip, 1, 0,1); } else { - $write = self::write($order, $total_vip, 1, 1); - self::write_log($write, $total_vip, 1); + $write = self::write($order, $total_vip, 1, 1,4); + self::write_log($write, $total_vip, 1,4); User::where('id', $order->uid)->inc('integral', $total_vip)->update(); } } @@ -53,22 +54,23 @@ class UserSignLogic extends BaseLogic /** * 核销 */ - public static function WriteOff($order){ - $find=UserSign::where(['order_id'=>$order['order_id'],'status'=>0,'financial_pm'=>1,'order_type'=>1])->find(); - if($find){ - $find->status=1; + public static function WriteOff($order) + { + $find = UserSign::where(['order_id' => $order['order_id'], 'status' => 0, 'financial_pm' => 1, 'order_type' => 1])->find(); + if ($find) { + $find->status = 1; $find->save(); User::where('id', $order->uid)->inc('integral', $find['number'])->update(); - self::write_log($find,$find['number'], 1); - + self::write_log($find, $find['number'], 1,4); } } /** * 储存商品积分结算 */ - public static function storage($order){ - $find=UserSign::where(['order_id'=>$order['order_id'],'status'=>0,'financial_pm'=>1,'order_type'=>1])->find(); - if($find){ + public static function storage($order) + { + $find = UserSign::where(['order_id' => $order['order_id'], 'status' => 0, 'financial_pm' => 1, 'order_type' => 1])->find(); + if ($find) { // if($or) // $find->status=1; // $find->save(); @@ -78,14 +80,24 @@ class UserSignLogic extends BaseLogic } } - - public static function write($order, $total_vip, $order_type = 0, $status = 0, $title = 4, $pm = 1) + /** + * @param type 1:购买商品冻结 + * @param type 2:核销商品解冻 + * @param type 3:退款扣除冻结 + * @param type 4:核销金额获得 + * @param type 5:兑换商品扣除 + * @param type 6:退款扣除礼品 + * @param type 7:充值冻结 + * @param type 8:收银台支付增加 + * @param type 9:首充获得 + */ + public static function write($order, $total_vip, $order_type = 0, $status = 0, $type = 4, $pm = 1) { //礼品券得 $sing = [ 'uid' => $order['uid'], 'order_id' => $order['order_id'], - 'title' => $title, + 'type' => $type, 'financial_pm' => $pm, 'store_id' => $order['store_id'], 'status' => $status, @@ -96,14 +108,25 @@ class UserSignLogic extends BaseLogic ]; return UserSign::create($sing); } - public static function write_log($write, $total_vip, $order_type = 0, $title = 4, $pm = 1) + /** + * @param type 1:购买商品冻结 + * @param type 2:核销商品解冻 + * @param type 3:退款扣除冻结 + * @param type 4:核销金额获得 + * @param type 5:兑换商品扣除 + * @param type 6:退款扣除礼品 + * @param type 7:充值冻结 + * @param type 8:收银台支付增加 + * @param type 9:首充获得 + */ + public static function write_log($write, $total_vip, $order_type = 0, $type = 4, $pm = 1) { //礼品券日志记录 $sing = [ 'uid' => $write['uid'], 'sid' => $write['id'], 'order_id' => $write['order_id'], - 'title' => $title, + 'type' => $type, 'financial_pm' => $pm, 'order_type' => $order_type, 'status' => 1, @@ -111,5 +134,37 @@ class UserSignLogic extends BaseLogic ]; UserSignLog::create($sing); } - + + //礼品券相关对应文本 + public static function getTitle($type, $amount) + { + switch ($type) { + /**冻结券**/ + //收入 + case 1: + return "购买商品{$amount}元获得冻结券"; + case 7: + return "充值{$amount}元获得冻结券"; + //支出 + case 2: + return "核销商品{$amount}元解冻冻结券"; + case 3: + return "退款{$amount}元扣除冻结券"; + /**礼品券**/ + //收入 + case 4: + return "核销金额{$amount}元获得礼品券"; + //支出 + case 5: + return "兑换{$amount}元商品扣除礼品券"; + case 6: + return "退款{$amount}元扣除礼品券"; + case 8: + return "收银台支付{$amount}元增加礼品券"; + case 9: + return "首充{$amount}元获得礼品券"; + default: + return "订单支付{$amount}元"; + } + } } From c2a46c93a9b61e3e0a0ccaddbfbd6780208e353d Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Tue, 2 Jul 2024 14:36:27 +0800 Subject: [PATCH 081/115] =?UTF-8?q?feat(BaseApiDataLists):=20=E7=A7=BB?= =?UTF-8?q?=E9=99=A4=E5=B9=B6=E6=B3=A8=E9=87=8A=E6=8E=89export=E5=B1=9E?= =?UTF-8?q?=E6=80=A7=E5=8F=8A=E7=9B=B8=E5=85=B3=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/lists/BaseApiDataLists.php | 4 ++-- app/api/lists/user_sign/UserSignLists.php | 2 +- app/api/lists/user_sign_log/UserSignLogLists.php | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/api/lists/BaseApiDataLists.php b/app/api/lists/BaseApiDataLists.php index 38d01a3a0..5077e6d0b 100644 --- a/app/api/lists/BaseApiDataLists.php +++ b/app/api/lists/BaseApiDataLists.php @@ -8,7 +8,7 @@ abstract class BaseApiDataLists extends BaseDataLists protected array $userInfo = []; protected int $userId = 0; - public string $export; + // public string $export; public function __construct() { @@ -17,7 +17,7 @@ abstract class BaseApiDataLists extends BaseDataLists $this->userInfo = $this->request->userInfo; $this->userId = $this->request->userId; } - $this->export = $this->request->get('export', ''); + // $this->export = $this->request->get('export', ''); } diff --git a/app/api/lists/user_sign/UserSignLists.php b/app/api/lists/user_sign/UserSignLists.php index af18f8785..44e4697fb 100644 --- a/app/api/lists/user_sign/UserSignLists.php +++ b/app/api/lists/user_sign/UserSignLists.php @@ -73,7 +73,7 @@ class UserSignLists extends BaseApiDataLists implements ListsSearchInterface */ public function count(): int { - return UserLabel::where($this->searchWhere)->count(); + return UserSign::where($this->searchWhere)->count(); } } \ No newline at end of file diff --git a/app/api/lists/user_sign_log/UserSignLogLists.php b/app/api/lists/user_sign_log/UserSignLogLists.php index a5f5834da..3f7966495 100644 --- a/app/api/lists/user_sign_log/UserSignLogLists.php +++ b/app/api/lists/user_sign_log/UserSignLogLists.php @@ -72,7 +72,7 @@ class UserSignLogLists extends BaseApiDataLists implements ListsSearchInterface */ public function count(): int { - return UserLabel::where($this->searchWhere)->count(); + return UserSignLog::where($this->searchWhere)->count(); } } \ No newline at end of file From 13d4ac1fad024d2881e7500e032d02b7d9981c8b Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Tue, 2 Jul 2024 14:42:26 +0800 Subject: [PATCH 082/115] =?UTF-8?q?feat(UserShipLists):=20=E6=A0=B9?= =?UTF-8?q?=E6=8D=AEtype=5Fid=E5=88=A4=E6=96=AD=E6=98=AF=E5=90=A6=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E6=90=9C=E7=B4=A2=E6=9D=A1=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/lists/user/UserShipLists.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/common/lists/user/UserShipLists.php b/app/common/lists/user/UserShipLists.php index e66ec7f2c..55672fc82 100644 --- a/app/common/lists/user/UserShipLists.php +++ b/app/common/lists/user/UserShipLists.php @@ -42,7 +42,10 @@ class UserShipLists extends BaseAdminDataLists if(!$this->request->__get('id')){ $arr[]=['id'=>0,'title'=>'一般用户','limit'=>0]; } - $this->searchWhere[]=['id','<>',4]; + $type_id=$this->request->get('type_id',0); + if($type_id!=4){ + $this->searchWhere[]=['id','<>',4]; + } $lists = UserShip::where($this->searchWhere) ->limit($this->limitOffset, $this->limitLength) ->field($field) From faa314d14af1e736f2a8ff0126fccc57f4aad854 Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Tue, 2 Jul 2024 14:42:48 +0800 Subject: [PATCH 083/115] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=BA=97=E9=93=BA?= =?UTF-8?q?=E5=95=86=E5=93=81=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/store/logic/WorkbenchLogic.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/store/logic/WorkbenchLogic.php b/app/store/logic/WorkbenchLogic.php index 610582805..fdc3a7003 100644 --- a/app/store/logic/WorkbenchLogic.php +++ b/app/store/logic/WorkbenchLogic.php @@ -904,7 +904,9 @@ class WorkbenchLogic extends BaseLogic 'SUM(collect_num) as collect', 'ROUND((COUNT(distinct(pay_uid))-1)/COUNT(distinct(uid)),2) as changes', 'COUNT(distinct(pay_uid))-1 as repeats' - ])->group('product_id')->order('pay', ' desc')->limit(20)->select()->toArray(); + ])->group('product_id')->order('pay', 'desc') + ->limit(20) + ->select()->toArray(); foreach ($list as $key => &$item) { $find = StoreProduct::where('id', $item['product_id'])->field('store_name,image')->find(); $item['store_name'] = $find['store_name']; From e9c25fd1dea82e92deea0a47b7354b40ab2fb328 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Tue, 2 Jul 2024 14:51:39 +0800 Subject: [PATCH 084/115] =?UTF-8?q?feat:=20=E8=B0=83=E6=95=B4=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E7=AD=BE=E5=88=B0=E9=80=BB=E8=BE=91=E4=BB=A5=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E9=A6=96=E5=85=85=E5=92=8C=E7=A4=BC=E5=93=81=E5=88=B8?= =?UTF-8?q?=E7=9A=84=E5=86=BB=E7=BB=93=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/logic/UserSignLogic.php | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/app/common/logic/UserSignLogic.php b/app/common/logic/UserSignLogic.php index dfaf79ea2..52b705856 100644 --- a/app/common/logic/UserSignLogic.php +++ b/app/common/logic/UserSignLogic.php @@ -24,12 +24,12 @@ class UserSignLogic extends BaseLogic $count = UserSign::where('uid', $order->uid)->count(); if ($count == 0 && in_array($user_ship, [1, 2, 3, 5, 6, 7, 8])) { //首充 - $write = self::write($order, $total_vip, 0, 1,9); - self::write_log($write, $total_vip, 0,9); + $write = self::write($order, $total_vip, 0, 1, 9); + self::write_log($write, $total_vip, 0, 9); User::where('id', $order->uid)->inc('integral', $total_vip)->update(); } else { - $write = self::write($order, $total_vip, 0, 0,7); - self::write_log($write, $total_vip, 0,7); + $write = self::write($order, $total_vip, 0, 0, 7); + self::write_log($write, $total_vip, 0, 7); } return true; } @@ -42,12 +42,17 @@ class UserSignLogic extends BaseLogic $total_vip = bcmul($order['pay_price'], 0.1, 2); if ($order['source'] == 0) { - //非收银台订单冻结礼品卷 - self::write($order, $total_vip, 1, 0,1); + //冻结礼品券 + if ($order['pay_price'] >= 500) { + self::write_log($order, $total_vip, 1, 0, 1); + } } else { - $write = self::write($order, $total_vip, 1, 1,4); - self::write_log($write, $total_vip, 1,4); - User::where('id', $order->uid)->inc('integral', $total_vip)->update(); + //不冻结礼品券 + if ($order['pay_price'] >= 500) { + $write = self::write($order, $total_vip, 1, 1, 4); + self::write_log($write, $total_vip, 1, 4); + User::where('id', $order->uid)->inc('integral', $total_vip)->update(); + } } } @@ -61,7 +66,8 @@ class UserSignLogic extends BaseLogic $find->status = 1; $find->save(); User::where('id', $order->uid)->inc('integral', $find['number'])->update(); - self::write_log($find, $find['number'], 1,4); + self::write_log($find, $find['number'], 1, 2); + self::write_log($find, $find['number'], 1, 4); } } /** From 3e72886b7a56d10c6cb7bbcadeb854fabafb0707 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Tue, 2 Jul 2024 15:01:05 +0800 Subject: [PATCH 085/115] =?UTF-8?q?feat(UserLogic):=20=E4=BF=AE=E6=AD=A3?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E7=AD=BE=E5=88=B0=E9=80=BB=E8=BE=91=E9=94=99?= =?UTF-8?q?=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/logic/user/UserLogic.php | 3 +-- app/common/logic/UserSignLogic.php | 3 ++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/api/logic/user/UserLogic.php b/app/api/logic/user/UserLogic.php index 84f25096f..1f6fe7daa 100644 --- a/app/api/logic/user/UserLogic.php +++ b/app/api/logic/user/UserLogic.php @@ -122,8 +122,7 @@ class UserLogic extends BaseLogic // $number=UserSign::where('uid',$uid)->where('status',0)->sum('number'); // $data['integral']=bcadd($data['integral'],$number,2); - $number = UserSign::where('uid',$uid)->where(['type'=>0,'status'=>1])->sum('number'); -// $GetNumber = UserSign::where('uid',$uid)->where('status',1)->sum('number'); + $number = UserSign::where('uid',$uid)->where(['status'=>0])->sum('number'); $data['number'] =bcadd($number,0,2); $data['GetNumber'] =bcadd($GetNumber,0,2); }else{ diff --git a/app/common/logic/UserSignLogic.php b/app/common/logic/UserSignLogic.php index 52b705856..2afcfac8c 100644 --- a/app/common/logic/UserSignLogic.php +++ b/app/common/logic/UserSignLogic.php @@ -44,7 +44,8 @@ class UserSignLogic extends BaseLogic if ($order['source'] == 0) { //冻结礼品券 if ($order['pay_price'] >= 500) { - self::write_log($order, $total_vip, 1, 0, 1); + $write = self::write($order, $total_vip, 0, 0, 4); + self::write_log($write, $total_vip, 1, 0, 1); } } else { //不冻结礼品券 From f1e93d4aeb8fdd95b17baeddc5027703c4aa796b Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Tue, 2 Jul 2024 15:15:42 +0800 Subject: [PATCH 086/115] =?UTF-8?q?feat(UserSignLogic):=20=E6=A0=B9?= =?UTF-8?q?=E6=8D=AE=E8=AE=A2=E5=8D=95=E6=9D=A5=E6=BA=90=E8=B0=83=E6=95=B4?= =?UTF-8?q?=E7=A4=BC=E5=93=81=E5=88=B8=E5=86=BB=E7=BB=93=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/logic/UserSignLogic.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/common/logic/UserSignLogic.php b/app/common/logic/UserSignLogic.php index 2afcfac8c..91a55b93e 100644 --- a/app/common/logic/UserSignLogic.php +++ b/app/common/logic/UserSignLogic.php @@ -44,8 +44,8 @@ class UserSignLogic extends BaseLogic if ($order['source'] == 0) { //冻结礼品券 if ($order['pay_price'] >= 500) { - $write = self::write($order, $total_vip, 0, 0, 4); - self::write_log($write, $total_vip, 1, 0, 1); + $write = self::write($order, $total_vip, 1, 0, 4); + self::write_log($write, $total_vip, 1, 1, 1); } } else { //不冻结礼品券 From 5c5837508127bec198014a4fa11d850e03f82c76 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Tue, 2 Jul 2024 15:20:23 +0800 Subject: [PATCH 087/115] =?UTF-8?q?feat(UserLists):=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=88=97=E8=A1=A8=E8=BF=94=E5=9B=9E=E9=87=91?= =?UTF-8?q?=E9=A2=9D=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/lists/user/UserLists.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/store/lists/user/UserLists.php b/app/store/lists/user/UserLists.php index 91a532214..c7a74cbed 100644 --- a/app/store/lists/user/UserLists.php +++ b/app/store/lists/user/UserLists.php @@ -57,9 +57,7 @@ class UserLists extends BaseAdminDataLists implements ListsSearchInterface $data['sex_text'] = $data->sex_text; $data['mobile'] = substr_replace($data['mobile'], '****', 3, 4); $data['user_ship_name'] =$data['user_ship']==0?'一般用户':UserShip::where('id',$data['user_ship'])->value('title'); - $data['return_money'] = StoreFinanceFlow:: - where(['user_id'=>$data['id'],'status'=>0,'financial_pm'=>0]) - ->sum('number'); + $data['return_money'] = StoreFinanceFlow::where(['other_uid'=>$data['id'],'status'=>0,'financial_pm'=>19,'type'=>0])->sum('number'); $data['amount_frozen'] = UserSign::where('uid',$data['id'])->where('status',0)->sum('number'); $data['get_frozen'] = UserSign::where('uid',$data['id'])->where('status',1)->sum('number'); From f8da0b9a96e58b5c2d7370802897ac150490ef67 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Tue, 2 Jul 2024 15:23:40 +0800 Subject: [PATCH 088/115] =?UTF-8?q?feat:=20=E6=9B=B4=E6=96=B0=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E5=88=97=E8=A1=A8=E5=8A=9F=E8=83=BD=E4=BB=A5=E5=8C=85?= =?UTF-8?q?=E6=8B=ACVIP=E6=B5=81=E6=B0=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/store/lists/user/UserLists.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/store/lists/user/UserLists.php b/app/store/lists/user/UserLists.php index c7a74cbed..69755ebc6 100644 --- a/app/store/lists/user/UserLists.php +++ b/app/store/lists/user/UserLists.php @@ -11,6 +11,7 @@ use app\common\model\user\User; use app\common\model\user_ship\UserShip; use app\common\lists\ListsSearchInterface; use app\common\model\user\UserAddress; +use app\common\model\vip_flow\VipFlow; class UserLists extends BaseAdminDataLists implements ListsSearchInterface { @@ -57,7 +58,9 @@ class UserLists extends BaseAdminDataLists implements ListsSearchInterface $data['sex_text'] = $data->sex_text; $data['mobile'] = substr_replace($data['mobile'], '****', 3, 4); $data['user_ship_name'] =$data['user_ship']==0?'一般用户':UserShip::where('id',$data['user_ship'])->value('title'); - $data['return_money'] = StoreFinanceFlow::where(['other_uid'=>$data['id'],'status'=>0,'financial_pm'=>19,'type'=>0])->sum('number'); + $data['return_money'] = VipFlow:: + where(['user_id'=>$data['id'],'status'=>0]) + ->sum('number')??0; $data['amount_frozen'] = UserSign::where('uid',$data['id'])->where('status',0)->sum('number'); $data['get_frozen'] = UserSign::where('uid',$data['id'])->where('status',1)->sum('number'); From 098b431bed66cb93e23cde10a86d8b63e75d0ed0 Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Tue, 2 Jul 2024 15:27:00 +0800 Subject: [PATCH 089/115] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E5=B1=95=E7=A4=BA=E5=95=86=E5=93=81=E5=BA=93=E5=AD=98=E4=B8=BA?= =?UTF-8?q?=E7=A9=BA=E7=9A=84=E7=9B=B8=E5=85=B3=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/lists/product/ProductLists.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/api/lists/product/ProductLists.php b/app/api/lists/product/ProductLists.php index 9d299fedd..422e96207 100644 --- a/app/api/lists/product/ProductLists.php +++ b/app/api/lists/product/ProductLists.php @@ -89,10 +89,10 @@ class ProductLists extends BaseAdminDataLists implements ListsSearchInterface, L }else{ $order = [$field => $order]; } - $fields = 'id,product_id,cate_id,store_name,cost,store_id,vip_price,purchase,price,bar_code,image,sales,store_info,delete_time,unit,batch,top_cate_id,two_cate_id'; + $fields = 'id,product_id,cate_id,store_name,cost,store_id,vip_price,purchase,price,bar_code,image,sales,store_info,delete_time,unit,batch,top_cate_id,two_cate_id,stock'; $this->searchWhere[] = ['status', '=', 1]; - $this->searchWhere[] = ['stock', '>', 0]; +// $this->searchWhere[] = ['stock', '>', 0]; return StoreBranchProduct::where($this->searchWhere) ->field($fields) ->with(['className', 'unitName']) From e9ae9ee246892430e55829dcae313f5733e46651 Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Tue, 2 Jul 2024 15:29:51 +0800 Subject: [PATCH 090/115] =?UTF-8?q?=E5=8F=96=E6=B6=88=E4=B8=8B=E5=8D=95?= =?UTF-8?q?=E6=95=B0=E9=87=8F=E9=99=90=E5=88=B6=E7=9B=B4=E6=8E=A5=E4=B8=BA?= =?UTF-8?q?=E6=AC=A1=E6=97=A5=E9=A2=84=E6=8F=90=E5=8D=95=E5=AD=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/order/CartController.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/api/controller/order/CartController.php b/app/api/controller/order/CartController.php index 7496016df..e9ad6d214 100644 --- a/app/api/controller/order/CartController.php +++ b/app/api/controller/order/CartController.php @@ -40,13 +40,13 @@ class CartController extends BaseApiController return $this->fail('购物车商品不能大于100个,请先结算'); } //数量下单判断 - $stock = StoreBranchProduct::where( - ['product_id'=>$params['product_id'], - 'store_id'=>$params['store_id'] - ])->value('stock')??0; - if ($params['cart_num'] >$stock) { - return $this->fail('库存数量不足'); - } +// $stock = StoreBranchProduct::where( +// ['product_id'=>$params['product_id'], +// 'store_id'=>$params['store_id'] +// ])->value('stock')??0; +// if ($params['cart_num'] >$stock) { +// return $this->fail('库存数量不足'); +// } if ($result) { if(isset($params['type']) && $params['type'] == 1){ $res = CartLogic::add($params); From 1f122be8dc050e368669605c5aaab9194eb4ee78 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Tue, 2 Jul 2024 15:32:38 +0800 Subject: [PATCH 091/115] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E7=AD=BE=E5=88=B0=E5=88=97=E8=A1=A8API=E6=9F=A5?= =?UTF-8?q?=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/lists/user_sign/UserSignLists.php | 2 ++ app/common/logic/UserSignLogic.php | 3 --- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/app/api/lists/user_sign/UserSignLists.php b/app/api/lists/user_sign/UserSignLists.php index 44e4697fb..e8b763631 100644 --- a/app/api/lists/user_sign/UserSignLists.php +++ b/app/api/lists/user_sign/UserSignLists.php @@ -43,6 +43,7 @@ class UserSignLists extends BaseApiDataLists implements ListsSearchInterface */ public function lists(): array { + $type=$this->request->get('type',1); $mark=$this->request->get('mark',''); if($type==1){ @@ -54,6 +55,7 @@ class UserSignLists extends BaseApiDataLists implements ListsSearchInterface }elseif($mark==2){ $this->searchWhere[]=['financial_pm','=',0]; } + $this->searchWhere[]=['uid','=',$this->userId]; $list=UserSign::where($this->searchWhere)->order('id desc') ->limit($this->limitOffset, $this->limitLength) ->select()->each(function ($item){ diff --git a/app/common/logic/UserSignLogic.php b/app/common/logic/UserSignLogic.php index 91a55b93e..b320aed4a 100644 --- a/app/common/logic/UserSignLogic.php +++ b/app/common/logic/UserSignLogic.php @@ -27,9 +27,6 @@ class UserSignLogic extends BaseLogic $write = self::write($order, $total_vip, 0, 1, 9); self::write_log($write, $total_vip, 0, 9); User::where('id', $order->uid)->inc('integral', $total_vip)->update(); - } else { - $write = self::write($order, $total_vip, 0, 0, 7); - self::write_log($write, $total_vip, 0, 7); } return true; } From 970f8c0a45c4607cb7ce9db1d1e0aa5f1820f5b6 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Tue, 2 Jul 2024 15:34:01 +0800 Subject: [PATCH 092/115] =?UTF-8?q?feat(UserSignLogLists):=20=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E4=BA=86=E6=A0=B9=E6=8D=AE=E7=94=A8=E6=88=B7ID?= =?UTF-8?q?=E6=90=9C=E7=B4=A2=E7=9A=84=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/lists/user_sign_log/UserSignLogLists.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/api/lists/user_sign_log/UserSignLogLists.php b/app/api/lists/user_sign_log/UserSignLogLists.php index 3f7966495..adbe2c542 100644 --- a/app/api/lists/user_sign_log/UserSignLogLists.php +++ b/app/api/lists/user_sign_log/UserSignLogLists.php @@ -54,6 +54,7 @@ class UserSignLogLists extends BaseApiDataLists implements ListsSearchInterface }elseif($mark==2){ $this->searchWhere[]=['financial_pm','=',0]; } + $this->searchWhere[]=['uid','=',$this->userId]; $list=UserSignLog::where($this->searchWhere)->order('id desc') ->limit($this->limitOffset, $this->limitLength) ->select()->each(function ($item){ From c78b12ec2dbea410a4cec77ba85fe841de61478d Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Tue, 2 Jul 2024 15:40:56 +0800 Subject: [PATCH 093/115] =?UTF-8?q?feat(UserSignLogic):=20=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E7=94=A8=E6=88=B7=E7=AD=BE=E5=88=B0=E9=80=BB=E8=BE=91?= =?UTF-8?q?=EF=BC=8C=E5=A2=9E=E5=8A=A0=E6=97=A5=E5=BF=97=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/logic/UserSignLogic.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/common/logic/UserSignLogic.php b/app/common/logic/UserSignLogic.php index b320aed4a..05f7a1e25 100644 --- a/app/common/logic/UserSignLogic.php +++ b/app/common/logic/UserSignLogic.php @@ -25,6 +25,7 @@ class UserSignLogic extends BaseLogic if ($count == 0 && in_array($user_ship, [1, 2, 3, 5, 6, 7, 8])) { //首充 $write = self::write($order, $total_vip, 0, 1, 9); + self::write_log($write, $total_vip, 0, 7); self::write_log($write, $total_vip, 0, 9); User::where('id', $order->uid)->inc('integral', $total_vip)->update(); } @@ -48,6 +49,7 @@ class UserSignLogic extends BaseLogic //不冻结礼品券 if ($order['pay_price'] >= 500) { $write = self::write($order, $total_vip, 1, 1, 4); + self::write_log($write, $total_vip, 1, 1); self::write_log($write, $total_vip, 1, 4); User::where('id', $order->uid)->inc('integral', $total_vip)->update(); } @@ -166,7 +168,7 @@ class UserSignLogic extends BaseLogic case 8: return "收银台支付{$amount}元增加礼品券"; case 9: - return "首充{$amount}元获得礼品券"; + return "充值{$amount}元获得礼品券"; default: return "订单支付{$amount}元"; } From 60300206f4ee0f41a82453e96ef5d6f82f545db2 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Tue, 2 Jul 2024 15:47:13 +0800 Subject: [PATCH 094/115] =?UTF-8?q?feat(StoreOrderLists):=20=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E6=94=B6=E9=93=B6=E5=8F=B0=E8=AE=A2=E5=8D=95=E6=94=AF?= =?UTF-8?q?=E4=BB=98=E7=B1=BB=E5=9E=8B=E6=9F=A5=E8=AF=A2=E6=9D=A1=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/store/lists/store_order/StoreOrderLists.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/store/lists/store_order/StoreOrderLists.php b/app/store/lists/store_order/StoreOrderLists.php index 416fc983a..0376bf320 100644 --- a/app/store/lists/store_order/StoreOrderLists.php +++ b/app/store/lists/store_order/StoreOrderLists.php @@ -50,7 +50,7 @@ class StoreOrderLists extends BaseAdminDataLists implements ListsSearchInterface $is_sashier = $this->request->get('is_sashier'); if ($is_sashier == 1) { //收银台订单 $this->searchWhere[] = ['store_id', '=', $store_id]; - $this->searchWhere[] = ['pay_type', 'in', [17, 9, 13, 18,19]]; + // $this->searchWhere[] = ['pay_type', 'in', [17,3, 9, 13, 18,19]]; } elseif ($is_sashier == 2) { //小程序订单 $this->searchWhere[] = ['pay_type', 'in', [7, 3, 18,19]]; } From 2f443ec364bc06fc715394ec8d06151b55a820b8 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Tue, 2 Jul 2024 15:59:47 +0800 Subject: [PATCH 095/115] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9UserSignLists?= =?UTF-8?q?,=20UserSignLogLists=E5=92=8CUserSignLogic=E7=B1=BB=E4=BB=A5?= =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E6=96=B0=E7=9A=84=E8=AE=A2=E5=8D=95=E5=A4=84?= =?UTF-8?q?=E7=90=86=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/lists/user_sign/UserSignLists.php | 9 +++- .../lists/user_sign_log/UserSignLogLists.php | 9 +++- app/api/logic/user/UserLogic.php | 46 ------------------- app/common/logic/UserSignLogic.php | 20 ++++---- 4 files changed, 26 insertions(+), 58 deletions(-) diff --git a/app/api/lists/user_sign/UserSignLists.php b/app/api/lists/user_sign/UserSignLists.php index e8b763631..7f13520db 100644 --- a/app/api/lists/user_sign/UserSignLists.php +++ b/app/api/lists/user_sign/UserSignLists.php @@ -7,6 +7,8 @@ use app\api\lists\BaseApiDataLists; use app\common\model\user_label\UserLabel; use app\common\lists\ListsSearchInterface; use app\common\logic\UserSignLogic; +use app\common\model\store_order\StoreOrder; +use app\common\model\user_recharge\UserRecharge; use app\common\model\user_ship\UserShip; use app\common\model\user_sign\UserSign; @@ -59,7 +61,12 @@ class UserSignLists extends BaseApiDataLists implements ListsSearchInterface $list=UserSign::where($this->searchWhere)->order('id desc') ->limit($this->limitOffset, $this->limitLength) ->select()->each(function ($item){ - $item['title']=UserSignLogic::getTitle($item['type'],$item['number']); + if($item['order_type']==0){ + $price=UserRecharge::where('order_id',$item['order_id'])->value('price')??0; + }else{ + $price=StoreOrder::where('order_id',$item['order_id'])->value('pay_price')??0; + } + $item['title']=UserSignLogic::getTitle($item['type'],$price,$item['number']); return $item; }); return $list?->toArray(); diff --git a/app/api/lists/user_sign_log/UserSignLogLists.php b/app/api/lists/user_sign_log/UserSignLogLists.php index adbe2c542..907c707a2 100644 --- a/app/api/lists/user_sign_log/UserSignLogLists.php +++ b/app/api/lists/user_sign_log/UserSignLogLists.php @@ -7,6 +7,8 @@ use app\api\lists\BaseApiDataLists; use app\common\model\user_label\UserLabel; use app\common\lists\ListsSearchInterface; use app\common\logic\UserSignLogic; +use app\common\model\store_order\StoreOrder; +use app\common\model\user_recharge\UserRecharge; use app\common\model\user_ship\UserShip; use app\common\model\user_sign_log\UserSignLog; @@ -58,7 +60,12 @@ class UserSignLogLists extends BaseApiDataLists implements ListsSearchInterface $list=UserSignLog::where($this->searchWhere)->order('id desc') ->limit($this->limitOffset, $this->limitLength) ->select()->each(function ($item){ - $item['title']=UserSignLogic::getTitle($item['type'],$item['number']); + if($item['order_type']==0){ + $price=UserRecharge::where('order_id',$item['order_id'])->value('price')??0; + }else{ + $price=StoreOrder::where('order_id',$item['order_id'])->value('pay_price')??0; + } + $item['title']=UserSignLogic::getTitle($item['type'],$price,$item['number']); return $item; }); return $list?->toArray(); diff --git a/app/api/logic/user/UserLogic.php b/app/api/logic/user/UserLogic.php index 1f6fe7daa..67b4ee755 100644 --- a/app/api/logic/user/UserLogic.php +++ b/app/api/logic/user/UserLogic.php @@ -244,9 +244,6 @@ class UserLogic extends BaseLogic } - - - public static function dealPayPassword($params,$uid) { $password = payPassword($params['password']); @@ -255,49 +252,6 @@ class UserLogic extends BaseLogic } - public static function userSingList($params,$uid) - { - switch ($params['type']){ - case 1: - $query = UserSign::where(['uid'=>$uid,'type'=>1]); - if($params['mark'] == 1){ - $query->where('financial_pm',1);//获得 - } - if($params['mark'] == 2){ - $query->where('financial_pm',0); - } - $count = $query->count(); - $data =$query - ->page($params['page_no'],$params['page_size']) - ->order('id','desc') - ->select()?->toArray(); - break; - default: - $query = UserSign::where(['uid'=>$uid,'type'=>0]); - if($params['mark'] == 1){ - $query->where('financial_pm',1);//获得 - } - if($params['mark'] == 2){ - $query->where('financial_pm',0); - } - $count = $query->count(); - $data =$query - ->page($params['page_no'],$params['page_size']) - ->order('id','desc') - ->select()?->toArray(); - } - foreach ($data as &$value){ - if(!preg_match('/[\x{4e00}-\x{9fa5}]/u', $value['title'])){ - $value['title'] = UserSignLogic::getTitle($value['title'],$value['number']); - } - } - return [ - 'lists' => $data, - 'count' => $count - ]; - - } - public static function dealDetails($params,$uid) { switch ($params['type']){ diff --git a/app/common/logic/UserSignLogic.php b/app/common/logic/UserSignLogic.php index 05f7a1e25..7b22bcd0c 100644 --- a/app/common/logic/UserSignLogic.php +++ b/app/common/logic/UserSignLogic.php @@ -142,33 +142,33 @@ class UserSignLogic extends BaseLogic } //礼品券相关对应文本 - public static function getTitle($type, $amount) + public static function getTitle($type, $amount,$number) { switch ($type) { /**冻结券**/ //收入 case 1: - return "购买商品{$amount}元获得冻结券"; + return "购买商品{$amount}元获得{$number}元冻结券"; case 7: - return "充值{$amount}元获得冻结券"; + return "充值{$amount}元获得{$number}元冻结券"; //支出 case 2: - return "核销商品{$amount}元解冻冻结券"; + return "核销商品{$amount}元解冻{$number}元礼品券"; case 3: - return "退款{$amount}元扣除冻结券"; + return "退款{$amount}元扣除{$number}元冻结券"; /**礼品券**/ //收入 case 4: - return "核销金额{$amount}元获得礼品券"; + return "核销金额{$amount}元获得{$number}元礼品券"; //支出 case 5: - return "兑换{$amount}元商品扣除礼品券"; + return "兑换{$amount}元商品扣除{$number}元礼品券"; case 6: - return "退款{$amount}元扣除礼品券"; + return "退款{$amount}元扣除{$number}元礼品券"; case 8: - return "收银台支付{$amount}元增加礼品券"; + return "收银台支付{$amount}元增加{$number}元礼品券"; case 9: - return "充值{$amount}元获得礼品券"; + return "充值{$amount}元解冻{$number}元礼品券"; default: return "订单支付{$amount}元"; } From e5dafb14370e3166ae9e8da62eb6cd4cfbd7f173 Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Tue, 2 Jul 2024 16:01:50 +0800 Subject: [PATCH 096/115] =?UTF-8?q?=E4=BD=99=E9=A2=9D=E6=94=AF=E4=BB=98?= =?UTF-8?q?=E7=9F=AD=E4=BF=A1=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/logic/store_order/StoreOrderLogic.php | 5 +++-- .../controller/store_order/StoreOrderController.php | 13 +++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/app/common/logic/store_order/StoreOrderLogic.php b/app/common/logic/store_order/StoreOrderLogic.php index 8b5a8943a..94f657b58 100644 --- a/app/common/logic/store_order/StoreOrderLogic.php +++ b/app/common/logic/store_order/StoreOrderLogic.php @@ -378,12 +378,13 @@ class StoreOrderLogic extends BaseLogic } $template = getenv('SMS_TEMPLATE'); $check =(new SmsService())->client($phone,$template,$code); - if($check){ if($type == 1){ $remark = $param['uid'].'_smsPay'; - }else{ + }elseif($type == 2){ $remark = $param['uid'].'_giftPay'; + }else{ + $remark = $param['uid'].'_moneyPay';//余额支付 } Cache::set($remark,$code,5*60); return true; diff --git a/app/store/controller/store_order/StoreOrderController.php b/app/store/controller/store_order/StoreOrderController.php index 635f5e47a..87f41a515 100644 --- a/app/store/controller/store_order/StoreOrderController.php +++ b/app/store/controller/store_order/StoreOrderController.php @@ -118,6 +118,10 @@ class StoreOrderController extends BaseAdminController if ($order['order']['pay_price'] > $user['integral']) { return $this->fail('当前用户礼品券不足支付'); } + }elseif($params['type'] == 3){ + if ($order['order']['pay_price'] > $user['now_money']) { + return $this->fail('当前用户余额不足支付'); + } } $res = (new StoreOrderLogic())->dealSendSms($params, $params['type']); @@ -165,6 +169,15 @@ class StoreOrderController extends BaseAdminController } } + if ($pay_type == PayEnum::BALANCE_PAY) { + $remark = $uid . '_moneyPay'; + $code = Cache::get($remark); + if ($code && isset($params['code']) && $code != $params['code']) { + throw new Exception('验证码错误'); + } + } + + $user = null; if ($uid) { $user = User::where('id', $uid)->find(); From 0dd210e470b29f39e7139bfbcc4b0176068f9de2 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Tue, 2 Jul 2024 16:02:30 +0800 Subject: [PATCH 097/115] =?UTF-8?q?feat(StoreOrderLists):=20=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E6=94=B6=E9=93=B6=E5=8F=B0=E5=92=8C=E5=B0=8F=E7=A8=8B?= =?UTF-8?q?=E5=BA=8F=E8=AE=A2=E5=8D=95=E7=9A=84=E6=90=9C=E7=B4=A2=E6=9D=A1?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/store/lists/store_order/StoreOrderLists.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/store/lists/store_order/StoreOrderLists.php b/app/store/lists/store_order/StoreOrderLists.php index 0376bf320..7f1d9b8a4 100644 --- a/app/store/lists/store_order/StoreOrderLists.php +++ b/app/store/lists/store_order/StoreOrderLists.php @@ -50,9 +50,9 @@ class StoreOrderLists extends BaseAdminDataLists implements ListsSearchInterface $is_sashier = $this->request->get('is_sashier'); if ($is_sashier == 1) { //收银台订单 $this->searchWhere[] = ['store_id', '=', $store_id]; - // $this->searchWhere[] = ['pay_type', 'in', [17,3, 9, 13, 18,19]]; + $this->searchWhere[] = ['source', '=', 1]; } elseif ($is_sashier == 2) { //小程序订单 - $this->searchWhere[] = ['pay_type', 'in', [7, 3, 18,19]]; + $this->searchWhere[] = ['source', '=', 0]; } $status = $this->request->get('status',''); switch ($status){ From 23bf1ecee8b509d94e54514486b320d3556955af Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Tue, 2 Jul 2024 16:10:44 +0800 Subject: [PATCH 098/115] =?UTF-8?q?feat(UserSignLogic):=20=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E6=A0=B8=E9=94=80=E5=95=86=E5=93=81=E8=8E=B7=E5=BE=97?= =?UTF-8?q?=E9=80=BB=E8=BE=91=E5=B9=B6=E6=9B=B4=E6=96=B0=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/logic/UserSignLogic.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/app/common/logic/UserSignLogic.php b/app/common/logic/UserSignLogic.php index 7b22bcd0c..741d47700 100644 --- a/app/common/logic/UserSignLogic.php +++ b/app/common/logic/UserSignLogic.php @@ -26,7 +26,7 @@ class UserSignLogic extends BaseLogic //首充 $write = self::write($order, $total_vip, 0, 1, 9); self::write_log($write, $total_vip, 0, 7); - self::write_log($write, $total_vip, 0, 9); + self::write_log($write, $total_vip, 0, 9,0); User::where('id', $order->uid)->inc('integral', $total_vip)->update(); } return true; @@ -50,7 +50,7 @@ class UserSignLogic extends BaseLogic if ($order['pay_price'] >= 500) { $write = self::write($order, $total_vip, 1, 1, 4); self::write_log($write, $total_vip, 1, 1); - self::write_log($write, $total_vip, 1, 4); + self::write_log($write, $total_vip, 1, 2,0); User::where('id', $order->uid)->inc('integral', $total_vip)->update(); } } @@ -66,8 +66,8 @@ class UserSignLogic extends BaseLogic $find->status = 1; $find->save(); User::where('id', $order->uid)->inc('integral', $find['number'])->update(); - self::write_log($find, $find['number'], 1, 2); - self::write_log($find, $find['number'], 1, 4); + self::write_log($find, $find['number'], 1, 2,0); + // self::write_log($find, $find['number'], 1, 4); } } /** @@ -90,12 +90,12 @@ class UserSignLogic extends BaseLogic * @param type 1:购买商品冻结 * @param type 2:核销商品解冻 * @param type 3:退款扣除冻结 - * @param type 4:核销金额获得 + * @param type 4:核销商品获得 * @param type 5:兑换商品扣除 * @param type 6:退款扣除礼品 * @param type 7:充值冻结 * @param type 8:收银台支付增加 - * @param type 9:首充获得 + * @param type 9:充值解冻 */ public static function write($order, $total_vip, $order_type = 0, $status = 0, $type = 4, $pm = 1) { @@ -118,12 +118,12 @@ class UserSignLogic extends BaseLogic * @param type 1:购买商品冻结 * @param type 2:核销商品解冻 * @param type 3:退款扣除冻结 - * @param type 4:核销金额获得 + * @param type 4:核销商品获得 * @param type 5:兑换商品扣除 * @param type 6:退款扣除礼品 * @param type 7:充值冻结 * @param type 8:收银台支付增加 - * @param type 9:首充获得 + * @param type 9:充值解冻 */ public static function write_log($write, $total_vip, $order_type = 0, $type = 4, $pm = 1) { @@ -159,7 +159,7 @@ class UserSignLogic extends BaseLogic /**礼品券**/ //收入 case 4: - return "核销金额{$amount}元获得{$number}元礼品券"; + return "核销商品{$amount}元获得{$number}元礼品券"; //支出 case 5: return "兑换{$amount}元商品扣除{$number}元礼品券"; From 77c14d6508219171ec384db91efaf9b402700f3c Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Tue, 2 Jul 2024 16:33:09 +0800 Subject: [PATCH 099/115] =?UTF-8?q?=E6=94=B6=E9=93=B6=E5=8F=B0=E4=B8=8B?= =?UTF-8?q?=E5=8D=95=E5=BA=93=E5=AD=98=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../logic/store_order/StoreOrderLogic.php | 48 +++++++++++++++++++ app/store/controller/cart/CartController.php | 14 +++--- .../store_order/StoreOrderController.php | 17 +++++++ .../logic/store_order/StoreOrderLogic.php | 2 + .../store_order/StoreOrderValidate.php | 6 +++ 5 files changed, 80 insertions(+), 7 deletions(-) diff --git a/app/common/logic/store_order/StoreOrderLogic.php b/app/common/logic/store_order/StoreOrderLogic.php index 94f657b58..1ae877833 100644 --- a/app/common/logic/store_order/StoreOrderLogic.php +++ b/app/common/logic/store_order/StoreOrderLogic.php @@ -394,5 +394,53 @@ class StoreOrderLogic extends BaseLogic } +//检查缺失 + public static function checkLeft($params, $uid, $type = 0) + { + $where = []; + if (empty($type)) { + $where = ['is_pay' => 0]; + } + $cart_select = Cart::whereIn('id', $params['cart_id']) + ->where($where)->field('id,product_id,cart_num,store_id')->select()->toArray(); + if (empty($cart_select)) { + self::setError('购物车为空'); + return false; + } + $newArr = []; + //检查购物车对比店铺得商品数量差异 + foreach ($cart_select as $v) { + $store = StoreBranchProduct::where([ + 'store_id' => $params['store_id'], + 'product_id' => $v['product_id'], + ])->field('id,store_name,stock')->withTrashed()->find(); + if (empty($store)) { + $store['stock'] = 0; + } + if ($store['stock'] < $v['cart_num']) { + //缺失 + $newArr[] = [ + 'uid' => $uid, + 'store_id' => $params['store_id'], + 'product_id' => $v['product_id'], + 'missing_quantity' => $v['cart_num'] - $store['stock'] + ]; + } + } + + if ($newArr) { + return [ + 'detail' => $newArr, + 'reservation' => 1 + ]; + } + return [ + 'detail' => [], + 'reservation' => 0 + ]; + } + + + } diff --git a/app/store/controller/cart/CartController.php b/app/store/controller/cart/CartController.php index ae4587eee..97666dd81 100644 --- a/app/store/controller/cart/CartController.php +++ b/app/store/controller/cart/CartController.php @@ -42,13 +42,13 @@ class CartController extends BaseAdminController return $this->fail('购物车商品不能大于100个,请先结算'); } //数量下单判断 - $stock = StoreBranchProduct::where( - ['product_id'=>$params['product_id'], - 'store_id'=>$params['store_id'] - ])->value('stock')??0; - if ($params['cart_num'] >$stock) { - return $this->fail('库存数量不足'); - } +// $stock = StoreBranchProduct::where( +// ['product_id'=>$params['product_id'], +// 'store_id'=>$params['store_id'] +// ])->value('stock')??0; +// if ($params['cart_num'] >$stock) { +// return $this->fail('库存数量不足'); +// } if ($result) { $res = CartLogic::edit($params); } else { diff --git a/app/store/controller/store_order/StoreOrderController.php b/app/store/controller/store_order/StoreOrderController.php index 87f41a515..03f2eaad1 100644 --- a/app/store/controller/store_order/StoreOrderController.php +++ b/app/store/controller/store_order/StoreOrderController.php @@ -132,6 +132,23 @@ class StoreOrderController extends BaseAdminController } } + //检查库存足够与否 + public function checkInventory() + { + $params = (new StoreOrderValidate())->post()->goCheck('cart'); + $params['store_id'] = $this->request->adminInfo['store_id']??22; + $res = StoreOrderLogic::checkLeft($params, $params['uid']); + if (!$res) { + $msg = StoreOrderLogic::getError(); + if ($msg == '购物车为空') { + return $this->data([]); + } + return $this->fail(StoreOrderLogic::getError()); + } + return $this->data($res); + } + + /** * 创建订单 diff --git a/app/store/logic/store_order/StoreOrderLogic.php b/app/store/logic/store_order/StoreOrderLogic.php index f8808002c..80df42e05 100644 --- a/app/store/logic/store_order/StoreOrderLogic.php +++ b/app/store/logic/store_order/StoreOrderLogic.php @@ -3,6 +3,8 @@ namespace app\store\logic\store_order; +use app\common\model\order\Cart; +use app\common\model\store_branch_product\StoreBranchProduct; use app\common\model\store_order\StoreOrder; use app\common\logic\BaseLogic; use think\facade\Db; diff --git a/app/store/validate/store_order/StoreOrderValidate.php b/app/store/validate/store_order/StoreOrderValidate.php index adf8b8f9b..df8c18a78 100644 --- a/app/store/validate/store_order/StoreOrderValidate.php +++ b/app/store/validate/store_order/StoreOrderValidate.php @@ -35,9 +35,15 @@ class StoreOrderValidate extends BaseValidate 'id' => 'id', 'verify_code' => '核销码', 'type' => '发送短信类型', + 'cart_id' => '购物车id', ]; + public function sceneCart() + { + return $this->only(['cart_id']); + } + /** * @notes 添加场景 * @return StoreOrderValidate From 749911f8047fcd7ab64828cadf03055957f6d707 Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Tue, 2 Jul 2024 17:01:58 +0800 Subject: [PATCH 100/115] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=88=86=E9=A1=B5?= =?UTF-8?q?=E9=99=90=E5=88=B6=E9=80=BB=E8=BE=91=E6=A3=80=E6=B5=8B=E6=95=B0?= =?UTF-8?q?=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/store/logic/WorkbenchLogic.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/store/logic/WorkbenchLogic.php b/app/store/logic/WorkbenchLogic.php index fdc3a7003..4f3ff7681 100644 --- a/app/store/logic/WorkbenchLogic.php +++ b/app/store/logic/WorkbenchLogic.php @@ -905,7 +905,7 @@ class WorkbenchLogic extends BaseLogic 'ROUND((COUNT(distinct(pay_uid))-1)/COUNT(distinct(uid)),2) as changes', 'COUNT(distinct(pay_uid))-1 as repeats' ])->group('product_id')->order('pay', 'desc') - ->limit(20) +// ->limit(20) ->select()->toArray(); foreach ($list as $key => &$item) { $find = StoreProduct::where('id', $item['product_id'])->field('store_name,image')->find(); From d6aaceb425413c8616d45fc5ee3fe2b245560b73 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Tue, 2 Jul 2024 17:02:21 +0800 Subject: [PATCH 101/115] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E5=92=8C=E6=94=AF=E4=BB=98=E9=80=BB=E8=BE=91=EF=BC=8C?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=94=A8=E6=88=B7=E7=AD=89=E7=BA=A7=E5=88=A4?= =?UTF-8?q?=E6=96=AD=E5=92=8C=E7=A7=AF=E5=88=86=E8=AE=A1=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/logic/order/OrderLogic.php | 6 +- app/common/logic/PayNotifyLogic.php | 120 +++++++++--------- app/common/logic/UserSignLogic.php | 17 +-- .../UserProductStorageLogic.php | 17 +++ 4 files changed, 91 insertions(+), 69 deletions(-) diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index 3ea2e26aa..9a997a7bd 100644 --- a/app/api/logic/order/OrderLogic.php +++ b/app/api/logic/order/OrderLogic.php @@ -534,7 +534,11 @@ class OrderLogic extends BaseLogic $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); //积分结算 - if($order['is_storage']==0&&$order['source']==0){ + $user_ship=-1; + if($order['uid']){ + $user_ship=User::where('id',$order['uid'])->value('user_ship'); + } + if($order['is_storage']==0&&$order['source']==0&&in_array($user_ship,[0,4])){ UserSignLogic::WriteOff($order); } Db::commit(); diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index c2b36788c..566bfbf91 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -96,15 +96,15 @@ class PayNotifyLogic extends BaseLogic $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']); + // self::descStock($order['id']); } self::afterPay($order); - if($order['reservation'] == 1&& in_array($order['shipping_type'],[1,2])){ - $checkArr =[ - 'cart_id'=>$order['cart_id'], - 'store_id'=>$order['store_id'], + if ($order['reservation'] == 1 && in_array($order['shipping_type'], [1, 2])) { + $checkArr = [ + 'cart_id' => $order['cart_id'], + 'store_id' => $order['store_id'], ]; - self::dealGoodsLeft($checkArr,$order['uid'],$order['id']); + self::dealGoodsLeft($checkArr, $order['uid'], $order['id']); } if ($extra && $extra['store_id']) { $params = [ @@ -217,12 +217,12 @@ class PayNotifyLogic extends BaseLogic OrderLogic::writeOff($params); } self::dealProductLog($order); - if($order['reservation'] == 1&& in_array($order['shipping_type'],[1,2])){ - $checkArr =[ - 'cart_id'=>$order['cart_id'], - 'store_id'=>$order['store_id'], + if ($order['reservation'] == 1 && in_array($order['shipping_type'], [1, 2])) { + $checkArr = [ + 'cart_id' => $order['cart_id'], + 'store_id' => $order['store_id'], ]; - self::dealGoodsLeft($checkArr,$order['uid'],$order['id']); + self::dealGoodsLeft($checkArr, $order['uid'], $order['id']); } // $count = UserSign::where([ @@ -234,10 +234,10 @@ class PayNotifyLogic extends BaseLogic // if($count){ // self::addFlowLog($order); // } - //收银台下单直接到账 -// if($order['shipping_type'] == 3){ + //收银台下单直接到账 + // if($order['shipping_type'] == 3){ // self::descStock($order['id']); -// } + // } // Redis::send('push-platform-print', ['id' => $order['id']], 60); @@ -415,12 +415,12 @@ class PayNotifyLogic extends BaseLogic $capitalFlowDao->userExpense('user_order_pay', 'order', $order['id'], $order->pay_price, '', 1, $order['store_id']); } $order->save(); - if($order['reservation'] == 1&& in_array($order['shipping_type'],[1,2])){ - $checkArr =[ - 'cart_id'=>$order['cart_id'], - 'store_id'=>$order['store_id'], + if ($order['reservation'] == 1 && in_array($order['shipping_type'], [1, 2])) { + $checkArr = [ + 'cart_id' => $order['cart_id'], + 'store_id' => $order['store_id'], ]; - self::dealGoodsLeft($checkArr,$order['uid'],$order['id']); + self::dealGoodsLeft($checkArr, $order['uid'], $order['id']); } self::afterPay($order, $extra['transaction_id']); // self::addUserSing($order); @@ -428,14 +428,13 @@ class PayNotifyLogic extends BaseLogic if ($order['shipping_type'] == 3) { self::descStock($order['id']); //直接加对应兑换券 - if ($order->uid >0) { - $level = User::where('id',$order->uid)->value('user_ship'); + if ($order->uid > 0) { + $level = User::where('id', $order->uid)->value('user_ship'); $discount = self::getDiscount($level); $total_vip = bcmul($order['pay_price'], $discount, 2); - self::addNewUserSing($order,8,$total_vip,1,1); + self::addNewUserSing($order, 8, $total_vip, 1, 1); User::where('id', $order->uid)->inc('integral', $total_vip)->update(); } - } if (!empty($extra['payer']['openid']) && $order->pay_type == 7) { Redis::send('push-delivery', ['order_id' => $order['order_id'], 'openid' => $extra['payer']['openid']], 4); @@ -470,10 +469,10 @@ class PayNotifyLogic extends BaseLogic $capitalFlowDao->userExpense('user_order_purchase_pay', 'order', $orderRe['id'], $purchase_funds, '', 1, $orderRe['store_id']); } //退还 充值得兑换券 - $level = User::where('id',$order->uid)->value('user_ship'); + $level = User::where('id', $order->uid)->value('user_ship'); $discount = self::getDiscount($level); $total_price = bcmul($orderRe->refund_price, $discount, 2); - self::addNewUserSing($orderRe, 3,$total_price); //冻结 + self::addNewUserSing($orderRe, 3, $total_price); //冻结 self::addNewUserSing($orderRe, 6, $total_price, 0, 1); //解冻 self::descUserSing($orderRe); @@ -572,7 +571,7 @@ class PayNotifyLogic extends BaseLogic { // $user_sing = new UserSign(); if ($order['uid'] > 0) { - $level = User::where('id',$order['uid'])->value('user_ship'); + $level = User::where('id', $order['uid'])->value('user_ship'); $discount = self::getDiscount($level); $user_number = bcmul($order['refund_price'], $discount, 2); // $sing = [ @@ -689,8 +688,8 @@ class PayNotifyLogic extends BaseLogic } bcscale(2); - UserSignLogic::dealRechargeFrozen($user,$order,$order['user_ship']); - + UserSignLogic::dealRechargeFrozen($user, $order, $order['user_ship']); + //更新等级 $user->user_ship = $order['user_ship']; @@ -795,19 +794,27 @@ class PayNotifyLogic extends BaseLogic public static function afterPay($order, $transaction_id = 0) { $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; - try{ + try { Redis::send('order_wetcha_push_send', ['order' => $order]); - }catch(\Exception $e){ - Log::error('订单推送失败:'.$e->getMessage()); + } catch (\Exception $e) { + Log::error('订单推送失败:' . $e->getMessage()); // 异常处理代码,例如记录日志或发送通知等。 } + if ($order['uid'] > 0) { + // 结算金额 要支付的钱减去冻结得钱去走后面得逻辑 发得兑换券也要去减去 + //用户下单该用户等级为1得时候才处理冻结金额 + $user = User::where('id', $order['uid'])->find(); + $user_ship = $user['user_ship']; + + } //积分写入 - UserSignLogic::OrderWrite($order); + if(in_array($user_ship,[0,4])){ + UserSignLogic::OrderWrite($order); + } if ($off_activity == 1) { //-----活动价结算更改 $financeLogic->order = $order; @@ -818,19 +825,13 @@ class PayNotifyLogic extends BaseLogic $financeLogic->save(); return false; } - if ($order['uid'] > 0) { - // 结算金额 要支付的钱减去冻结得钱去走后面得逻辑 发得兑换券也要去减去 - //用户下单该用户等级为1得时候才处理冻结金额 - $user = User::where('id', $order['uid'])->find(); - $user_ship = $user['user_ship']; - //纯在分销关系的时候要去判断分销出来的用户的采购款的额度 (只有会员按照这个逻辑拆分,其余的还是按照正常的支付金额) - if ($user['user_ship'] == 1 && $order['pay_type'] != PayEnum::CASH_PAY) { - $vipFrozenAmount = self::dealFrozenPrice($order['id']); - //为1的时候要去减活动价 - $order['pay_price'] = bcsub($order['pay_price'], $vipFrozenAmount, 2); - self::dealVipAmount($order, $order['pay_type']); - } + //纯在分销关系的时候要去判断分销出来的用户的采购款的额度 (只有会员按照这个逻辑拆分,其余的还是按照正常的支付金额) + if ($user_ship== 1 && $order['pay_type'] != PayEnum::CASH_PAY) { + $vipFrozenAmount = self::dealFrozenPrice($order['id']); + //为1的时候要去减活动价 + $order['pay_price'] = bcsub($order['pay_price'], $vipFrozenAmount, 2); + self::dealVipAmount($order, $order['pay_type']); } if ($order['spread_uid'] > 0 || $user_ship > 0) { if ($order['spread_uid'] > 0 && $user_ship == 0) { @@ -1093,21 +1094,20 @@ class PayNotifyLogic extends BaseLogic * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ - public static function dealGoodsLeft($cart_id,$uid,$oid) + public static function dealGoodsLeft($cart_id, $uid, $oid) { - if(is_array($cart_id)){ + if (is_array($cart_id)) { $cart_id['cart_id'] = $cart_id; - }else{ - $cart_id['cart_id'] = explode(',',$cart_id); + } else { + $cart_id['cart_id'] = explode(',', $cart_id); } - $data = OrderLogic::checkLeft($cart_id,$uid,1); + $data = OrderLogic::checkLeft($cart_id, $uid, 1); $format = $data['detail']; - foreach ($format as &$value){ - $value['oid'] =$oid; - $value['create_time'] =time(); + foreach ($format as &$value) { + $value['oid'] = $oid; + $value['create_time'] = time(); } Db::name('store_product_miss')->insertAll($format); - } @@ -1120,12 +1120,12 @@ class PayNotifyLogic extends BaseLogic public static function getDiscount($level) { switch ($level) { - case 0://普通 - return Config::where('name','ordinary_member')->value('value')??0.1; - case 1://vip - return Config::where('name','vip_member')->value('value')??0.1; - case 4://商户 - return Config::where('name','merchant')->value('value')??0.1; + case 0: //普通 + return Config::where('name', 'ordinary_member')->value('value') ?? 0.1; + case 1: //vip + return Config::where('name', 'vip_member')->value('value') ?? 0.1; + case 4: //商户 + return Config::where('name', 'merchant')->value('value') ?? 0.1; default: return 0.1; } diff --git a/app/common/logic/UserSignLogic.php b/app/common/logic/UserSignLogic.php index 741d47700..a48cb7413 100644 --- a/app/common/logic/UserSignLogic.php +++ b/app/common/logic/UserSignLogic.php @@ -73,16 +73,17 @@ class UserSignLogic extends BaseLogic /** * 储存商品积分结算 */ - public static function storage($order) + public static function storage($order_id,$price) { - $find = UserSign::where(['order_id' => $order['order_id'], 'status' => 0, 'financial_pm' => 1, 'order_type' => 1])->find(); + $find = UserSign::where(['order_id' => $order_id, 'status' => 0, 'financial_pm' => 1, 'order_type' => 1])->find(); if ($find) { - // if($or) - // $find->status=1; - // $find->save(); - // User::where('id', $order->uid)->inc('integral', $find['number'])->update(); - // self::write_log($find,$find['number'], 1); - + self::write_log($find, $price, 1, 2,0); + self::write_log($find, $price, 1, 2,1); + if($price>$find['number']){ + $find->status = 1; + $find->save(); + } + User::where('id', $find['uid'])->inc('integral', $price)->update(); } } diff --git a/app/common/logic/user_product_storage/UserProductStorageLogic.php b/app/common/logic/user_product_storage/UserProductStorageLogic.php index 1c15f4b3e..fdea6c23f 100644 --- a/app/common/logic/user_product_storage/UserProductStorageLogic.php +++ b/app/common/logic/user_product_storage/UserProductStorageLogic.php @@ -3,7 +3,10 @@ namespace app\common\logic\user_product_storage; use app\common\logic\BaseLogic; +use app\common\logic\UserSignLogic; +use app\common\model\store_order\StoreOrder; use app\common\model\store_order_cart_info\StoreOrderCartInfo; +use app\common\model\user\User; use app\common\model\user_product_storage\UserProductStorage; use app\common\model\user_product_storage_log\UserProductStorageLog; use think\facade\Db; @@ -46,6 +49,7 @@ class UserProductStorageLogic extends BaseLogic if($times!=''){ $times=strtotime($times); } + $user_ship=User::where('id',$uid)->value('user_ship'); foreach ($data as $k=>$v){ $find=UserProductStorage::where('uid',$uid)->where('product_id',$v['product_id'])->find(); if($find){ @@ -60,6 +64,19 @@ class UserProductStorageLogic extends BaseLogic $find->status=0; } $find->save(); + if(in_array($user_ship,[0,4])){ + $cart_info=StoreOrderCartInfo::where(['oid'=>$find['oid'],'uid'=>$uid,'product_id'=>$find['product_id']])->value('cart_info'); + if($cart_info){ + $price=bcdiv($cart_info['pay_price'],$cart_info['cart_num'],2); + if($price){ + $price=bcmul($price,$v['nums'],2); + $rate=bcdiv($price,100,2); + $order_id= StoreOrder::where('id',$cart_info['oid'])->value('order_id'); + UserSignLogic::storage($order_id,$rate); + } + + } + } $data_log[$k]['uid']=$uid; $data_log[$k]['oid']=$find['oid']; $data_log[$k]['product_id']=$find['product_id']; From b17d9648502e62aa847db8a8b87b966e44013923 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Tue, 2 Jul 2024 17:30:30 +0800 Subject: [PATCH 102/115] =?UTF-8?q?feat:=20=E9=87=8D=E6=9E=84=E6=94=AF?= =?UTF-8?q?=E4=BB=98=E9=80=9A=E7=9F=A5=E9=80=BB=E8=BE=91=EF=BC=8C=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E4=BA=86=E5=85=91=E6=8D=A2=E5=88=B8=E7=9A=84=E5=A2=9E?= =?UTF-8?q?=E5=87=8F=E6=93=8D=E4=BD=9C=EF=BC=8C=E5=B9=B6=E7=A7=BB=E9=99=A4?= =?UTF-8?q?=E4=BA=86=E7=9B=B8=E5=85=B3=E5=86=97=E4=BD=99=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/logic/PayNotifyLogic.php | 101 +--------------------------- app/common/logic/UserSignLogic.php | 44 +++++++++--- 2 files changed, 39 insertions(+), 106 deletions(-) diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index 566bfbf91..954227c0a 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -427,14 +427,6 @@ class PayNotifyLogic extends BaseLogic self::dealProductLog($order); if ($order['shipping_type'] == 3) { self::descStock($order['id']); - //直接加对应兑换券 - if ($order->uid > 0) { - $level = User::where('id', $order->uid)->value('user_ship'); - $discount = self::getDiscount($level); - $total_vip = bcmul($order['pay_price'], $discount, 2); - self::addNewUserSing($order, 8, $total_vip, 1, 1); - User::where('id', $order->uid)->inc('integral', $total_vip)->update(); - } } if (!empty($extra['payer']['openid']) && $order->pay_type == 7) { Redis::send('push-delivery', ['order_id' => $order['order_id'], 'openid' => $extra['payer']['openid']], 4); @@ -469,14 +461,7 @@ class PayNotifyLogic extends BaseLogic $capitalFlowDao->userExpense('user_order_purchase_pay', 'order', $orderRe['id'], $purchase_funds, '', 1, $orderRe['store_id']); } //退还 充值得兑换券 - $level = User::where('id', $order->uid)->value('user_ship'); - $discount = self::getDiscount($level); - $total_price = bcmul($orderRe->refund_price, $discount, 2); - self::addNewUserSing($orderRe, 3, $total_price); //冻结 - - self::addNewUserSing($orderRe, 6, $total_price, 0, 1); //解冻 - self::descUserSing($orderRe); - // d($purchase_funds,$orderRe['refund_price'],$orderRe); + UserSignLogic::RefundRecharge($orderRe); return true; } $order->status = OrderEnum::REFUND_PAY; @@ -490,7 +475,6 @@ 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(); //对应比例得退礼品券逻辑 $discount = self::getDiscount($user->user_ship); $total_price = bcmul($order->refund_price, $discount, 2); @@ -511,21 +495,12 @@ class PayNotifyLogic extends BaseLogic //退款 $capitalFlowDao->userIncome('system_purchase_back', 'system_back', $order['id'], $deal_money); } + UserSignLogic::RefundOrder($order); - if ($check_user_sing) { - //退还 兑换券 - self::addNewUserSing($order, 3, $total_price); //冻结 - self::addNewUserSing($order, 6, $total_price, 0, 1); //解冻 - self::descUserSing($order); - } return true; } //积分 - if ($check_user_sing) { - self::addNewUserSing($order, 3, $total_price); //冻结 - self::addNewUserSing($order, 6, $total_price, 0, 1); //解冻 - self::descUserSing($order); - } + UserSignLogic::RefundOrder($order); //微信日志 user_order_refund $capitalFlowDao->userIncome('user_order_refund', 'system_back', $order['id'], $deal_money, '', 1); //处理财务流水退还 @@ -534,76 +509,6 @@ class PayNotifyLogic extends BaseLogic return true; // self::afterPay($order,$extra['transaction_id']); } - //冻结券和礼品券得操作 - - /** - * 处理冻结和解冻 礼品券得记录 - * @param $order // 订单 - * @param $category // 分类 - * @param $number // 金额 - * @param int $pm //收支 0支出 1获得 - * @type $type //类型 0冻结 1解冻 - * @return true - */ - public static function addNewUserSing($order, $category, $number, int $pm = 0, $type = 0) - { - $user_sing = new UserSign(); - $sing = [ - 'uid' => $order['uid'], - 'order_id' => $order['order_id'], - // 'title' => '购买商品获得兑换券', - // 'title' => PayNotifyLogic::getTitle($category,$number), - 'title' => $category, - 'financial_pm' => $pm, - 'store_id' => $order['store_id'], - 'number' => $number, - 'type' => $type, - 'status' => 1, - ]; - $user_sing->save($sing); - return true; - } - - - - //退积分-->订单 - public static function descUserSing($order) - { - // $user_sing = new UserSign(); - if ($order['uid'] > 0) { - $level = User::where('id', $order['uid'])->value('user_ship'); - $discount = self::getDiscount($level); - $user_number = bcmul($order['refund_price'], $discount, 2); - // $sing = [ - // 'uid' => $order['uid'], - // 'order_id' => $order['order_id'], - // 'title' => '退款扣除兑换券', - // 'financial_pm' => 0, - // 'store_id' => $order['store_id'], - // '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'])->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; - } - - - - /** * 现金退款相关 diff --git a/app/common/logic/UserSignLogic.php b/app/common/logic/UserSignLogic.php index a48cb7413..334f82a76 100644 --- a/app/common/logic/UserSignLogic.php +++ b/app/common/logic/UserSignLogic.php @@ -26,11 +26,25 @@ class UserSignLogic extends BaseLogic //首充 $write = self::write($order, $total_vip, 0, 1, 9); self::write_log($write, $total_vip, 0, 7); - self::write_log($write, $total_vip, 0, 9,0); + self::write_log($write, $total_vip, 0, 9, 0); User::where('id', $order->uid)->inc('integral', $total_vip)->update(); } return true; } + /** + * 充值退款 + */ + public static function RefundRecharge($order) + { + $find = UserSign::where('uid', $order['uid'])->where('order_id', $order['order_id'])->find(); + if ($find) { + $find->status = -1; + $find->save(); + $number = UserSignLog::where('sid', $find->id)->where('financial_pm', 0)->sum('number'); + self::write_log($find, $number, 0, 3, 0); + User::where('id', $order['uid'])->dec('integral', $number)->update(); + } + } /** * 来自订单 @@ -50,11 +64,25 @@ class UserSignLogic extends BaseLogic if ($order['pay_price'] >= 500) { $write = self::write($order, $total_vip, 1, 1, 4); self::write_log($write, $total_vip, 1, 1); - self::write_log($write, $total_vip, 1, 2,0); + self::write_log($write, $total_vip, 1, 2, 0); User::where('id', $order->uid)->inc('integral', $total_vip)->update(); } } } + /** + * 订单退款 + */ + public static function RefundOrder($order) + { + $find = UserSign::where('uid', $order['uid'])->where('order_id', $order['order_id'])->find(); + if ($find) { + $find->status = -1; + $find->save(); + $number = UserSignLog::where('sid', $find->id)->where('financial_pm', 0)->sum('number'); + self::write_log($find, $number, 0, 3, 0); + User::where('id', $order['uid'])->dec('integral', $number)->update(); + } + } /** * 核销 @@ -66,20 +94,20 @@ class UserSignLogic extends BaseLogic $find->status = 1; $find->save(); User::where('id', $order->uid)->inc('integral', $find['number'])->update(); - self::write_log($find, $find['number'], 1, 2,0); + self::write_log($find, $find['number'], 1, 2, 0); // self::write_log($find, $find['number'], 1, 4); } } /** * 储存商品积分结算 */ - public static function storage($order_id,$price) + public static function storage($order_id, $price) { $find = UserSign::where(['order_id' => $order_id, 'status' => 0, 'financial_pm' => 1, 'order_type' => 1])->find(); if ($find) { - self::write_log($find, $price, 1, 2,0); - self::write_log($find, $price, 1, 2,1); - if($price>$find['number']){ + self::write_log($find, $price, 1, 2, 0); + self::write_log($find, $price, 1, 2, 1); + if ($price > $find['number']) { $find->status = 1; $find->save(); } @@ -143,7 +171,7 @@ class UserSignLogic extends BaseLogic } //礼品券相关对应文本 - public static function getTitle($type, $amount,$number) + public static function getTitle($type, $amount, $number) { switch ($type) { /**冻结券**/ From e085325ebc738e341b7bcc6214072540cdedf6cf Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Tue, 2 Jul 2024 17:31:19 +0800 Subject: [PATCH 103/115] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=8A=A0=E5=85=A5?= =?UTF-8?q?=E5=95=86=E5=93=81=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 | 1 + 1 file changed, 1 insertion(+) diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index 566bfbf91..db75919d8 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -981,6 +981,7 @@ class PayNotifyLogic extends BaseLogic foreach ($productLog as &$value) { $value['pay_uid'] = $uid; $value['oid'] = $order['id']; + $value['store_id'] = $store_id; $cart_info = StoreOrderCartInfo::where([ 'uid' => $uid, 'old_cart_id' => $value['cart_id'], 'store_id' => $store_id ])->find(); From 7b5fff7a3cee6eea92194d8852421d3a755c0f9f Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Tue, 2 Jul 2024 17:39:53 +0800 Subject: [PATCH 104/115] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9UserSignLogic?= =?UTF-8?q?=E7=B1=BB=E4=B8=AD=E7=9A=84write=5Flog=E6=96=B9=E6=B3=95?= =?UTF-8?q?=E4=B8=BAwrite=E6=96=B9=E6=B3=95=EF=BC=8C=E5=B9=B6=E8=B0=83?= =?UTF-8?q?=E6=95=B4=E5=8F=82=E6=95=B0=EF=BC=8C=E5=90=8C=E6=97=B6=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E7=9B=B8=E5=85=B3=E7=94=A8=E6=88=B7=E7=9A=84integral?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/logic/UserSignLogic.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/common/logic/UserSignLogic.php b/app/common/logic/UserSignLogic.php index 334f82a76..841f0b844 100644 --- a/app/common/logic/UserSignLogic.php +++ b/app/common/logic/UserSignLogic.php @@ -41,7 +41,7 @@ class UserSignLogic extends BaseLogic $find->status = -1; $find->save(); $number = UserSignLog::where('sid', $find->id)->where('financial_pm', 0)->sum('number'); - self::write_log($find, $number, 0, 3, 0); + self::write($find, $number, 0, 1, 3, 0); User::where('id', $order['uid'])->dec('integral', $number)->update(); } } @@ -79,7 +79,7 @@ class UserSignLogic extends BaseLogic $find->status = -1; $find->save(); $number = UserSignLog::where('sid', $find->id)->where('financial_pm', 0)->sum('number'); - self::write_log($find, $number, 0, 3, 0); + self::write($find, $number, 0, 1, 3, 0); User::where('id', $order['uid'])->dec('integral', $number)->update(); } } From 4c511d39b3909393e0339e5bd436aa512bae35b1 Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Tue, 2 Jul 2024 17:44:20 +0800 Subject: [PATCH 105/115] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=9B=9E=E8=B0=83?= =?UTF-8?q?=E9=99=A4=E5=BC=80=E6=AC=A1=E6=97=A5=E5=9B=9E=E8=B0=83=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 | 15 ++++++++++++--- .../store_order/StoreOrderController.php | 5 ++++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index dc63ef3d7..e58fbfcb3 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -106,7 +106,7 @@ class PayNotifyLogic extends BaseLogic ]; self::dealGoodsLeft($checkArr, $order['uid'], $order['id']); } - if ($extra && $extra['store_id']) { + if ($extra && $extra['store_id'] && $order['reservation'] !=1) { $params = [ 'verify_code' => $order['verify_code'], 'store_id' => $extra['store_id'], @@ -208,7 +208,7 @@ class PayNotifyLogic extends BaseLogic // } // self::addUserSing($order); self::afterPay($order); - if ($extra && $extra['store_id']) { + if ($extra && $extra['store_id'] && $order['reservation'] !=1) { $params = [ 'verify_code' => $order['verify_code'], 'store_id' => $extra['store_id'], @@ -617,7 +617,7 @@ class PayNotifyLogic extends BaseLogic /** * 现金支付 */ - public static function cash_pay($orderSn) + public static function cash_pay($orderSn,$extra =[]) { $order = StoreOrder::where('order_id', $orderSn)->findOrEmpty(); @@ -642,6 +642,15 @@ class PayNotifyLogic extends BaseLogic self::descStock($order['id']); } + if ($extra && $extra['store_id'] && $order['reservation'] !=1) { + $params = [ + 'verify_code' => $order['verify_code'], + 'store_id' => $extra['store_id'], + 'staff_id' => $extra['staff_id'] + ]; + OrderLogic::writeOff($params); + } + // Redis::send('push-platform-print', ['id' => $order['id']]); return true; diff --git a/app/store/controller/store_order/StoreOrderController.php b/app/store/controller/store_order/StoreOrderController.php index 03f2eaad1..3114b9795 100644 --- a/app/store/controller/store_order/StoreOrderController.php +++ b/app/store/controller/store_order/StoreOrderController.php @@ -228,7 +228,10 @@ class StoreOrderController extends BaseAdminController return $this->success('礼品券支付成功', ['id' => $order['id']]); case PayEnum::CASH_PAY: //现金支付 - PayNotifyLogic::handle('cash_pay', $order['order_id']); + PayNotifyLogic::handle('cash_pay', $order['order_id'], [ + 'uid' => $uid, 'store_id' => $this->request->adminInfo['store_id'], + 'staff_id' => $this->request->adminInfo['admin_id'] + ]); return $this->success('现金支付成功', ['id' => $order['id']]); case PayEnum::WECHAT_PAY_BARCODE: From 5de3cf3a976bce18aa6f1f321ce12088cb2864a6 Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Tue, 2 Jul 2024 17:48:27 +0800 Subject: [PATCH 106/115] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=8E=B0=E9=87=91?= =?UTF-8?q?=E4=BB=98=E6=AC=BE=E7=9A=84=E7=9B=B4=E6=8E=A5=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/logic/PayNotifyLogic.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index e58fbfcb3..ee1555fc8 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -627,6 +627,9 @@ class PayNotifyLogic extends BaseLogic $order->paid = 1; $order->pay_time = time(); $order->status = 2; + if ($order['reservation'] ==1) { + $order->status = 1; + } if (!$order->save()) { throw new \Exception('订单保存出错'); } From a8fa8575892757a73e25738c47f041fe99ed23ac Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Tue, 2 Jul 2024 17:49:47 +0800 Subject: [PATCH 107/115] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E6=96=B0?= =?UTF-8?q?=E5=8A=9F=E8=83=BD(API)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/lists/user_sign/UserSignLists.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/api/lists/user_sign/UserSignLists.php b/app/api/lists/user_sign/UserSignLists.php index 7f13520db..b1ffe274c 100644 --- a/app/api/lists/user_sign/UserSignLists.php +++ b/app/api/lists/user_sign/UserSignLists.php @@ -49,7 +49,7 @@ class UserSignLists extends BaseApiDataLists implements ListsSearchInterface $type=$this->request->get('type',1); $mark=$this->request->get('mark',''); if($type==1){ - $this->searchWhere[]=['type','in',[4,9,8,2]]; + $this->searchWhere[]=['type','in',[4,9,8,2,3]]; $this->searchWhere[]=['status','=',1]; } if($mark==1){ From 84ad33d3fcf9cd78ee8be1087948d7cfa3c34fdc Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Tue, 2 Jul 2024 17:50:55 +0800 Subject: [PATCH 108/115] =?UTF-8?q?feat:=20=E7=A7=BB=E9=99=A4=E4=BA=86?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E7=AD=BE=E5=88=B0=E7=8A=B6=E6=80=81=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E7=9A=84=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/logic/UserSignLogic.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/app/common/logic/UserSignLogic.php b/app/common/logic/UserSignLogic.php index 841f0b844..ca8e81b39 100644 --- a/app/common/logic/UserSignLogic.php +++ b/app/common/logic/UserSignLogic.php @@ -38,8 +38,6 @@ class UserSignLogic extends BaseLogic { $find = UserSign::where('uid', $order['uid'])->where('order_id', $order['order_id'])->find(); if ($find) { - $find->status = -1; - $find->save(); $number = UserSignLog::where('sid', $find->id)->where('financial_pm', 0)->sum('number'); self::write($find, $number, 0, 1, 3, 0); User::where('id', $order['uid'])->dec('integral', $number)->update(); @@ -76,8 +74,6 @@ class UserSignLogic extends BaseLogic { $find = UserSign::where('uid', $order['uid'])->where('order_id', $order['order_id'])->find(); if ($find) { - $find->status = -1; - $find->save(); $number = UserSignLog::where('sid', $find->id)->where('financial_pm', 0)->sum('number'); self::write($find, $number, 0, 1, 3, 0); User::where('id', $order['uid'])->dec('integral', $number)->update(); From a1bfcec42a62c74adc1a292d33b17e9fbdad8cd7 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Tue, 2 Jul 2024 17:56:56 +0800 Subject: [PATCH 109/115] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E7=AD=BE=E5=88=B0=E9=80=BB=E8=BE=91=E4=BB=A5=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E7=A7=AF=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/logic/UserSignLogic.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/common/logic/UserSignLogic.php b/app/common/logic/UserSignLogic.php index ca8e81b39..fc7e63791 100644 --- a/app/common/logic/UserSignLogic.php +++ b/app/common/logic/UserSignLogic.php @@ -75,7 +75,7 @@ class UserSignLogic extends BaseLogic $find = UserSign::where('uid', $order['uid'])->where('order_id', $order['order_id'])->find(); if ($find) { $number = UserSignLog::where('sid', $find->id)->where('financial_pm', 0)->sum('number'); - self::write($find, $number, 0, 1, 3, 0); + self::write($find, $number, 1, 1, 3, 0); User::where('id', $order['uid'])->dec('integral', $number)->update(); } } From a77e0b57061780aef9f0308c6cefe4c95fa22685 Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Tue, 2 Jul 2024 18:06:16 +0800 Subject: [PATCH 110/115] =?UTF-8?q?=E5=9B=9E=E8=B0=83=E5=8A=A0=E5=85=A5?= =?UTF-8?q?=E5=95=86=E5=93=81=E6=97=A5=E5=BF=97=E5=A4=84=E7=90=86=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/logic/PayNotifyLogic.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index ee1555fc8..889d6a2ae 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -900,7 +900,7 @@ class PayNotifyLogic extends BaseLogic $value['oid'] = $order['id']; $value['store_id'] = $store_id; $cart_info = StoreOrderCartInfo::where([ - 'uid' => $uid, 'old_cart_id' => $value['cart_id'], 'store_id' => $store_id + 'uid' => $uid, 'old_cart_id' => $value['cart_id'], 'oid' => $value['oid'] ])->find(); $value['order_num'] = $cart_info['cart_num'] ?? 1; $value['pay_num'] = $cart_info['cart_num'] ?? 1; From b3b20746ca6fd5504866ee559beaf6e3ec3cc1b5 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Tue, 2 Jul 2024 18:08:28 +0800 Subject: [PATCH 111/115] =?UTF-8?q?feat(UserLists):=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E7=AD=BE=E5=88=B0=E5=86=BB=E7=BB=93=E9=87=91?= =?UTF-8?q?=E9=A2=9D=E8=AE=A1=E7=AE=97=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/store/lists/user/UserLists.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/store/lists/user/UserLists.php b/app/store/lists/user/UserLists.php index 69755ebc6..cc5d4a481 100644 --- a/app/store/lists/user/UserLists.php +++ b/app/store/lists/user/UserLists.php @@ -62,7 +62,9 @@ class UserLists extends BaseAdminDataLists implements ListsSearchInterface where(['user_id'=>$data['id'],'status'=>0]) ->sum('number')??0; $data['amount_frozen'] = UserSign::where('uid',$data['id'])->where('status',0)->sum('number'); - $data['get_frozen'] = UserSign::where('uid',$data['id'])->where('status',1)->sum('number'); + $number1 = UserSign::where('uid',$data['id'])->where('status',1)->where('type','<>',3)->sum('number'); + $number2 = UserSign::where('uid',$data['id'])->where('status',1)->where('type',3)->sum('number'); + $data['get_frozen']=bcsub($number1,$number2,2)??0; })->toArray(); return $lists; From c6ce41b2ef0d559ee08e5877e4682f1ee6a667c2 Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Tue, 2 Jul 2024 18:27:02 +0800 Subject: [PATCH 112/115] =?UTF-8?q?=E5=85=BC=E5=AE=B9=E6=9D=83=E9=99=90?= =?UTF-8?q?=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/logic/auth/AdminLogic.php | 2 +- app/store/logic/auth/AdminLogic.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/admin/logic/auth/AdminLogic.php b/app/admin/logic/auth/AdminLogic.php index b6967425f..0f92fa397 100644 --- a/app/admin/logic/auth/AdminLogic.php +++ b/app/admin/logic/auth/AdminLogic.php @@ -225,7 +225,7 @@ class AdminLogic extends BaseLogic { $admin = Admin::field([ 'id', 'account', 'name', 'disable', 'root', - 'multipoint_login', 'avatar', + 'multipoint_login', 'avatar','role_id' ])->findOrEmpty($params['id'])->toArray(); if ($action == 'detail') { diff --git a/app/store/logic/auth/AdminLogic.php b/app/store/logic/auth/AdminLogic.php index b0a1b4372..fd63d0ef4 100644 --- a/app/store/logic/auth/AdminLogic.php +++ b/app/store/logic/auth/AdminLogic.php @@ -225,7 +225,7 @@ class AdminLogic extends BaseLogic public static function detail($params, $action = 'detail'): array { $admin = SystemStoreStaff::field([ - 'id', 'account', 'staff_name', 'avatar', 'is_admin', 'is_manager', 'store_id' + 'id', 'account', 'staff_name', 'avatar', 'is_admin', 'is_manager', 'store_id','role_id' ])->findOrEmpty($params['id'])->toArray(); if ($action == 'detail') { From 7ffa50ac7b8f17cc1572b6224a17850ca822ea7b Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Tue, 2 Jul 2024 18:28:20 +0800 Subject: [PATCH 113/115] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E4=B8=8D=E5=AD=98=E5=9C=A8=E8=BF=94=E5=9B=9E=E9=94=99?= =?UTF-8?q?=E8=AF=AF?= 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, 2 insertions(+) diff --git a/app/store/controller/store_order/StoreOrderController.php b/app/store/controller/store_order/StoreOrderController.php index 3114b9795..2da343062 100644 --- a/app/store/controller/store_order/StoreOrderController.php +++ b/app/store/controller/store_order/StoreOrderController.php @@ -485,6 +485,8 @@ class StoreOrderController extends BaseAdminController $item['price'] = $item['cart_info']['price']; return $item; }); + }else { + return $this->fail('订单不存在'); } return $this->success('获取成功', $find?->toArray()); } From 1845833509cf90b384b7d6d16ff3b23abc69514b Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Tue, 2 Jul 2024 18:29:12 +0800 Subject: [PATCH 114/115] =?UTF-8?q?=E5=88=9B=E5=BB=BA=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E5=80=BC?= 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 3114b9795..d1e5a03ca 100644 --- a/app/store/controller/store_order/StoreOrderController.php +++ b/app/store/controller/store_order/StoreOrderController.php @@ -211,7 +211,7 @@ class StoreOrderController extends BaseAdminController 'store_id' => $this->request->adminInfo['store_id'], 'staff_id' => $this->request->adminInfo['admin_id'] ]); - return $this->success('余额支付成功'); + return $this->success('余额支付成功', ['id' => $order['id']]); case PayEnum::PURCHASE_FUNDS: //采购款支付 PayNotifyLogic::handle('purchase_funds', $order['order_id'], [ From 4ec0221c465ba279c8186bbffde97afac5c3508f Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Tue, 2 Jul 2024 18:34:47 +0800 Subject: [PATCH 115/115] =?UTF-8?q?feat(UserLists):=20=E4=BF=AE=E6=AD=A3?= =?UTF-8?q?=E8=AE=A1=E7=AE=97=E5=86=BB=E7=BB=93=E8=8E=B7=E5=BE=97=E6=95=B0?= =?UTF-8?q?=E9=87=8F=E7=9A=84=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/store/lists/user/UserLists.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/store/lists/user/UserLists.php b/app/store/lists/user/UserLists.php index cc5d4a481..08e05e13b 100644 --- a/app/store/lists/user/UserLists.php +++ b/app/store/lists/user/UserLists.php @@ -64,7 +64,11 @@ class UserLists extends BaseAdminDataLists implements ListsSearchInterface $data['amount_frozen'] = UserSign::where('uid',$data['id'])->where('status',0)->sum('number'); $number1 = UserSign::where('uid',$data['id'])->where('status',1)->where('type','<>',3)->sum('number'); $number2 = UserSign::where('uid',$data['id'])->where('status',1)->where('type',3)->sum('number'); - $data['get_frozen']=bcsub($number1,$number2,2)??0; + if($number1<$number2){ + $data['get_frozen']=0; + }else{ + $data['get_frozen']=bcsub($number1,$number2,2)??0; + } })->toArray(); return $lists;