正在显示
1 个修改的文件
包含
41 行增加
和
0 行删除
@@ -3,6 +3,7 @@ | @@ -3,6 +3,7 @@ | ||
3 | namespace app\admin\controller; | 3 | namespace app\admin\controller; |
4 | 4 | ||
5 | use app\common\controller\Backend; | 5 | use app\common\controller\Backend; |
6 | +use EasyWeChat\Factory; | ||
6 | use think\Db; | 7 | use think\Db; |
7 | 8 | ||
8 | /** | 9 | /** |
@@ -18,10 +19,22 @@ class UserCommissionApply extends Backend | @@ -18,10 +19,22 @@ class UserCommissionApply extends Backend | ||
18 | * @var \app\admin\model\UserCommissionApply | 19 | * @var \app\admin\model\UserCommissionApply |
19 | */ | 20 | */ |
20 | protected $model = null; | 21 | protected $model = null; |
22 | + protected $config = null; | ||
21 | 23 | ||
22 | public function _initialize() | 24 | public function _initialize() |
23 | { | 25 | { |
24 | parent::_initialize(); | 26 | parent::_initialize(); |
27 | + | ||
28 | + // 微信企业付款到零钱配置 | ||
29 | + $config = json_decode(\addons\shopro\model\Config::get(['name' => 'wechat'])->value, true); | ||
30 | + // app_id | ||
31 | + $platformConfig = json_decode(\addons\shopro\model\Config::get(['name' => 'wxMiniProgram'])->value, true); | ||
32 | + $config['app_id'] = $platformConfig['app_id']; | ||
33 | + // 微信支付证书 | ||
34 | + $config['cert_path'] = ROOT_PATH . 'public' . $config['cert_client']; | ||
35 | + $config['key_path'] = ROOT_PATH . 'public' . $config['cert_key']; | ||
36 | + $this->config = $config; | ||
37 | + | ||
25 | $this->model = new \app\admin\model\UserCommissionApply; | 38 | $this->model = new \app\admin\model\UserCommissionApply; |
26 | $this->view->assign("statusList", $this->model->getStatusList()); | 39 | $this->view->assign("statusList", $this->model->getStatusList()); |
27 | } | 40 | } |
@@ -93,6 +106,22 @@ class UserCommissionApply extends Backend | @@ -93,6 +106,22 @@ class UserCommissionApply extends Backend | ||
93 | \addons\shopro\model\User::commissionAdd($apply->user_id, $apply->money, 'cash_error', $apply->id); | 106 | \addons\shopro\model\User::commissionAdd($apply->user_id, $apply->money, 'cash_error', $apply->id); |
94 | } | 107 | } |
95 | 108 | ||
109 | + // 微信企业付款到零钱 | ||
110 | + $userOauth = \addons\shopro\model\UserOauth::get($apply->user_id); | ||
111 | + if($userOauth){ | ||
112 | + $app = Factory::payment($this->config); | ||
113 | + $partner_trade_no = date('Ymd') . substr(implode(NULL, array_map('ord', str_split(substr(uniqid(), 7, 13), 1))), 0, 8); | ||
114 | + $app->transfer->toBalance([ | ||
115 | + 'partner_trade_no' => $partner_trade_no, // 商户订单号,需保持唯一性(只能是字母或者数字,不能包含有符号) | ||
116 | + 'openid' => $userOauth['openid'], | ||
117 | + 'check_name' => 'NO_CHECK', // NO_CHECK:不校验真实姓名, FORCE_CHECK:强校验真实姓名 | ||
118 | +// 're_user_name' => '王小帅', // 如果 check_name 设置为FORCE_CHECK,则必填用户真实姓名 | ||
119 | + 'amount' => $apply->money * 100, // 企业付款金额,单位为分 | ||
120 | + 'desc' => '佣金提现', // 企业付款操作说明信息。必填 | ||
121 | + ]); | ||
122 | + $apply->isUpdate(true)->save(['partner_trade_no'=>$partner_trade_no]); | ||
123 | + } | ||
124 | + | ||
96 | // 提现结果通知 | 125 | // 提现结果通知 |
97 | // $user = \addons\shopro\model\User::where('id', $apply['user_id'])->find(); | 126 | // $user = \addons\shopro\model\User::where('id', $apply['user_id'])->find(); |
98 | // $user->notify( | 127 | // $user->notify( |
@@ -108,4 +137,16 @@ class UserCommissionApply extends Backend | @@ -108,4 +137,16 @@ class UserCommissionApply extends Backend | ||
108 | return $this->success('操作成功', null, $apply); | 137 | return $this->success('操作成功', null, $apply); |
109 | } | 138 | } |
110 | 139 | ||
140 | + // 查询付款到零钱的订单 | ||
141 | + public function searchToBalance($partner_trade_no){ | ||
142 | + $config = json_decode(\addons\shopro\model\Config::get(['name' => 'wechat'])->value, true); | ||
143 | + $platformConfig = json_decode(\addons\shopro\model\Config::get(['name' => 'wxMiniProgram'])->value, true); | ||
144 | + $config['app_id'] = $platformConfig['app_id']; | ||
145 | + // 微信支付证书 | ||
146 | + $config['cert_path'] = ROOT_PATH . 'public' . $config['cert_client']; | ||
147 | + $config['key_path'] = ROOT_PATH . 'public' . $config['cert_key']; | ||
148 | + $result = Factory::payment($config)->transfer->queryBalanceOrder($partner_trade_no); | ||
149 | + halt($result); | ||
150 | + } | ||
151 | + | ||
111 | } | 152 | } |
-
请 注册 或 登录 后发表评论