...
|
...
|
@@ -3,6 +3,7 @@ |
|
|
namespace app\admin\controller;
|
|
|
|
|
|
use app\common\controller\Backend;
|
|
|
use EasyWeChat\Factory;
|
|
|
use think\Db;
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -18,10 +19,22 @@ class UserCommissionApply extends Backend |
|
|
* @var \app\admin\model\UserCommissionApply
|
|
|
*/
|
|
|
protected $model = null;
|
|
|
protected $config = null;
|
|
|
|
|
|
public function _initialize()
|
|
|
{
|
|
|
parent::_initialize();
|
|
|
|
|
|
// 微信企业付款到零钱配置
|
|
|
$config = json_decode(\addons\shopro\model\Config::get(['name' => 'wechat'])->value, true);
|
|
|
// app_id
|
|
|
$platformConfig = json_decode(\addons\shopro\model\Config::get(['name' => 'wxMiniProgram'])->value, true);
|
|
|
$config['app_id'] = $platformConfig['app_id'];
|
|
|
// 微信支付证书
|
|
|
$config['cert_path'] = ROOT_PATH . 'public' . $config['cert_client'];
|
|
|
$config['key_path'] = ROOT_PATH . 'public' . $config['cert_key'];
|
|
|
$this->config = $config;
|
|
|
|
|
|
$this->model = new \app\admin\model\UserCommissionApply;
|
|
|
$this->view->assign("statusList", $this->model->getStatusList());
|
|
|
}
|
...
|
...
|
@@ -93,6 +106,22 @@ class UserCommissionApply extends Backend |
|
|
\addons\shopro\model\User::commissionAdd($apply->user_id, $apply->money, 'cash_error', $apply->id);
|
|
|
}
|
|
|
|
|
|
// 微信企业付款到零钱
|
|
|
$userOauth = \addons\shopro\model\UserOauth::get($apply->user_id);
|
|
|
if($userOauth){
|
|
|
$app = Factory::payment($this->config);
|
|
|
$partner_trade_no = date('Ymd') . substr(implode(NULL, array_map('ord', str_split(substr(uniqid(), 7, 13), 1))), 0, 8);
|
|
|
$app->transfer->toBalance([
|
|
|
'partner_trade_no' => $partner_trade_no, // 商户订单号,需保持唯一性(只能是字母或者数字,不能包含有符号)
|
|
|
'openid' => $userOauth['openid'],
|
|
|
'check_name' => 'NO_CHECK', // NO_CHECK:不校验真实姓名, FORCE_CHECK:强校验真实姓名
|
|
|
// 're_user_name' => '王小帅', // 如果 check_name 设置为FORCE_CHECK,则必填用户真实姓名
|
|
|
'amount' => $apply->money * 100, // 企业付款金额,单位为分
|
|
|
'desc' => '佣金提现', // 企业付款操作说明信息。必填
|
|
|
]);
|
|
|
$apply->isUpdate(true)->save(['partner_trade_no'=>$partner_trade_no]);
|
|
|
}
|
|
|
|
|
|
// 提现结果通知
|
|
|
// $user = \addons\shopro\model\User::where('id', $apply['user_id'])->find();
|
|
|
// $user->notify(
|
...
|
...
|
@@ -108,4 +137,16 @@ class UserCommissionApply extends Backend |
|
|
return $this->success('操作成功', null, $apply);
|
|
|
}
|
|
|
|
|
|
// 查询付款到零钱的订单
|
|
|
public function searchToBalance($partner_trade_no){
|
|
|
$config = json_decode(\addons\shopro\model\Config::get(['name' => 'wechat'])->value, true);
|
|
|
$platformConfig = json_decode(\addons\shopro\model\Config::get(['name' => 'wxMiniProgram'])->value, true);
|
|
|
$config['app_id'] = $platformConfig['app_id'];
|
|
|
// 微信支付证书
|
|
|
$config['cert_path'] = ROOT_PATH . 'public' . $config['cert_client'];
|
|
|
$config['key_path'] = ROOT_PATH . 'public' . $config['cert_key'];
|
|
|
$result = Factory::payment($config)->transfer->queryBalanceOrder($partner_trade_no);
|
|
|
halt($result);
|
|
|
}
|
|
|
|
|
|
} |
...
|
...
|
|