1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- <?php
- namespace app\common\service;
- use think\Exception;
- class MoneyService
- {
- private $model = '';
- /**
- * 初始化方法
- */
- public function __construct()
- {
- $this->model = new \app\common\model\User();
- }
- //提现转账(新版2020-01-01)
- public function withdrawTransfer($params=[]) {
- $result = [
- 'status' => 1,
- 'msg' => '',
- 'data' => [],
- ];
- try {
- $money = isset($params['money']) ? $params['money'] : '';
- $alipayAccount= isset($params['alipay_account']) ? $params['alipay_account'] : '';
- $name= isset($params['name']) ? $params['name'] : '';
- $out_biz_no = isset($params['out_biz_no']) ? $params['out_biz_no'] : getMillisecond() . mt_rand(1, 1000);
- $payTest = config('pay_test');
- if ($payTest == 1) {
- // $money = 0.1;
- }
- $info = [
- 'money' => $money,
- 'alipay_account' => $alipayAccount,
- 'name' => $name,
- ];
- $data['out_biz_no'] = $out_biz_no; //商户订单号
- $data['trans_amount'] = $info['money']; //订单总金额,单位为元,精确到小数点后两位
- $data['product_code'] = 'TRANS_ACCOUNT_NO_PWD';//业务产品码,收发现金红包固定为:STD_RED_PACKET;单笔无密转账到支付宝账户固定为:TRANS_ACCOUNT_NO_PWD;单笔无密转账到银行卡固定为:TRANS_BANKCARD_NO_PWD
- $data['biz_scene'] = 'DIRECT_TRANSFER'; //描述特定的业务场景,可传的参数如下:PERSONAL_COLLECTION:C2C现金红包-领红包;DIRECT_TRANSFER:B2C现金红包、单笔无密转账到支付宝/银行卡
- $data['order_title'] = 'GG语音提现'; //转账业务的标题,用于在支付宝用户的账单里显示
- $data['payee_info'] = [
- 'identity' => $info['alipay_account'],//收款方支付宝id或支付宝账户
- 'identity_type' => 'ALIPAY_LOGON_ID',//ALIPAY_USER_ID:支付宝会员的用户 ID,可通过 获取会员信息 能力获取。ALIPAY_LOGON_ID:支付宝登录号,支持邮箱和手机号格式。
- 'name' => $info['name'],//当 identity_type=ALIPAY_LOGON_ID 时,本字段必填。若传入该属性,则在支付宝回单中将会显示这个属性。
- ];
- //转账备注(支持200个英文/100个汉字)。当付款方为企业账户,且转账金额达到(大于等于)50000元,remark不能为空。收款方可见,会展示在收款用户的收支详情中。
- $data['remark'] = 'GG语音提现';
- require_once("../extend/AliPay/AliPay.php");
- $alipay =new \AliPay();
- $alipayResult =$alipay->AliPayWithdraw($data);
- if ($alipayResult['code'] != 10000) {
- throw new Exception($alipayResult['sub_msg']);
- }
- } catch (Exception $e) {
- $result['status'] = 0;
- $result['msg'] = $e->getMessage();
- }
- return $result;
- }
- }
|