From 3f25450980e13537556075cba41acd87cbfeab75 Mon Sep 17 00:00:00 2001 From: lqmac Date: Mon, 3 Jun 2024 16:11:03 +0800 Subject: [PATCH] 1 --- app/command/ProfitSharing.php | 2 +- app/command/ProfitSharingResult.php | 18 +++++++++++------- .../payment/gateway/driver/wechat/V3.php | 2 -- app/store/model/store/Role.php | 2 +- app/store/model/store/RoleMenu.php | 4 ++-- config/database.php | 2 +- 6 files changed, 16 insertions(+), 14 deletions(-) diff --git a/app/command/ProfitSharing.php b/app/command/ProfitSharing.php index fcee2215..46e4a641 100644 --- a/app/command/ProfitSharing.php +++ b/app/command/ProfitSharing.php @@ -167,7 +167,7 @@ class ProfitSharing extends Command $ret = $payment->addReceiver("MERCHANT_ID", $platform_wechat_config['mchId'], "武汉市汉阳区静好电子商务商行(个体工商户)", "HEADQUARTER"); //exit(); $transaction_id = $payment_trade->trade_no; - $out_trade_no = "PS".date("YmdHis").mt_rand(1000,9999); + $out_trade_no = "ps".date("YmdHis").mt_rand(1000,9999); $receivers = [ [ "type" => "MERCHANT_ID", diff --git a/app/command/ProfitSharingResult.php b/app/command/ProfitSharingResult.php index abe6a98c..24ed405a 100644 --- a/app/command/ProfitSharingResult.php +++ b/app/command/ProfitSharingResult.php @@ -92,10 +92,12 @@ class ProfitSharingResult extends Command //支付信息初始化 $PaymentModel = new Payment; $templateInfo = $PaymentModel->getPaymentInfo(PaymentMethodEnum::WECHAT, ClientEnum::MP_WEIXIN, $order->store_id, $order->merchant_id); + $options = $templateInfo['template']['config'][PaymentMethodEnum::WECHAT]; $payment = PaymentFacade::store(PaymentMethodEnum::WECHAT)->setOptions($options, ClientEnum::MP_WEIXIN); - + // var_dump($payment); + // exit(); $payment_trade = PaymentTrade::where('trade_id', $order->trade_id)->field('trade_no')->find(); if (!$payment_trade) { @@ -105,12 +107,14 @@ class ProfitSharingResult extends Command $transaction_id = $payment_trade->trade_no; $sharing = $payment->profitsharingQuery($order->out_order_no, $transaction_id); var_dump($sharing); - var_dump($sharing->return_code); - var_dump($sharing->result_code); - //更新 - $ret = Order::where('order_id',$order->order_id)->update(['profitsharing_status' => 2, 'profitsharing_time' => time()]); - echo "微信支付分账结果".PHP_EOL; - var_dump($ret); + + if ($sharing['state'] == "FINISHED") { + //更新 + $ret = Order::where('order_id',$order->order_id)->update(['profitsharing_status' => 2, 'profitsharing_time' => time()]); + echo "微信支付分账结果".PHP_EOL; + var_dump($ret); + } + } catch (\Exception $e) { echo $e->getMessage(); continue; diff --git a/app/common/library/payment/gateway/driver/wechat/V3.php b/app/common/library/payment/gateway/driver/wechat/V3.php index 54b1b0f6..3c9cfab1 100644 --- a/app/common/library/payment/gateway/driver/wechat/V3.php +++ b/app/common/library/payment/gateway/driver/wechat/V3.php @@ -169,9 +169,7 @@ class V3 { // 下单的参数 $params = ['transaction_id' => $transaction_id]; - var_dump($params); $url = $this->getProfitUrl()."/".$out_order_no."?transaction_id=".$transaction_id; - echo $url; try { $resp = $this->getApp() ->chain($url) diff --git a/app/store/model/store/Role.php b/app/store/model/store/Role.php index 09a97218..e384123e 100644 --- a/app/store/model/store/Role.php +++ b/app/store/model/store/Role.php @@ -108,7 +108,7 @@ class Role extends RoleModel $this->save($data); // 新增角色菜单关系记录 - RoleMenuModel::increased((int)$this['role_id'], $data['menus']); + RoleMenuModel::increased((int)$this['role_id'], $data['menus'], $data['store_id']); }); return true; } diff --git a/app/store/model/store/RoleMenu.php b/app/store/model/store/RoleMenu.php index 38301141..2109545a 100644 --- a/app/store/model/store/RoleMenu.php +++ b/app/store/model/store/RoleMenu.php @@ -27,14 +27,14 @@ class RoleMenu extends RoleMenuModel * @param array $menuIds * @return array|false */ - public static function increased(int $roleId, array $menuIds) + public static function increased(int $roleId, array $menuIds, int $storeId = 0) { $data = []; foreach ($menuIds as $menuId) { $data[] = [ 'role_id' => $roleId, 'menu_id' => $menuId, - 'store_id' => self::$storeId, + 'store_id' => $storeId ? $storeId : self::$storeId, ]; } return (new static)->addAll($data); diff --git a/config/database.php b/config/database.php index 40f054b6..cf68d182 100644 --- a/config/database.php +++ b/config/database.php @@ -49,7 +49,7 @@ return [ // 数据库连接参数 'params' => [], // 数据库编码默认采用utf8 - 'charset' => env('database.charset', 'utf8'), + 'charset' => env('database.charset', 'utf8mb4'), // 数据库表前缀 'prefix' => env('database.prefix', 'yoshop_'),