You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.7 KiB
45 lines
1.7 KiB
<?php
|
|
|
|
|
|
namespace App\Admin\Common;
|
|
|
|
|
|
use App\Models\ImsCjdcUser;
|
|
use EasyWeChat\Factory;
|
|
|
|
class WxPay
|
|
{
|
|
/**
|
|
* 企业付配置
|
|
* @param array $data
|
|
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
|
* @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
|
|
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
|
* @throws \GuzzleHttp\Exception\GuzzleException
|
|
*/
|
|
public static function transfers($data = [])
|
|
{
|
|
$app = Factory::payment(config('wechat.payment.default'));
|
|
$res = $app->transfer->toBalance([
|
|
'partner_trade_no' => $data['partner_trade_no'], // 商户订单号,需保持唯一性(只能是字母或者数字,不能包含有符号)
|
|
'openid' => $data['openid'],
|
|
'check_name' => 'NO_CHECK', // NO_CHECK:不校验真实姓名, FORCE_CHECK:强校验真实姓名
|
|
're_user_name' => $data['re_user_name'], // 如果 check_name 设置为FORCE_CHECK,则必填用户真实姓名
|
|
'amount' => $data['amount'], // 企业付款金额,单位为分
|
|
'desc' => $data['desc'], // 企业付款操作说明信息。必填
|
|
]);
|
|
return $res;
|
|
}
|
|
|
|
public static function pay($model,$form)
|
|
{
|
|
$data = [];
|
|
$user = ImsCjdcUser::find($model->user_id);
|
|
$data['openid'] = $user->openid;
|
|
$data['amount'] = $form->model()->money * 100;
|
|
$data['partner_trade_no'] = $form->model()->id;
|
|
$data['re_user_name'] = $model->name;
|
|
$data['desc'] = $model->name;
|
|
return self::transfers($data);
|
|
}
|
|
}
|