Jelajahi Sumber

提现调整字段调整

zhangxiaobin 1 tahun lalu
induk
melakukan
932c202fbe

+ 14 - 0
application/admin/controller/Withdraw.php

@@ -4,6 +4,7 @@ namespace app\admin\controller;
 
 use app\admin\model\Message;
 use app\common\controller\Backend;
+use app\common\service\MoneyService;
 use think\Exception;
 use think\exception\PDOException;
 use think\exception\ValidateException;
@@ -121,6 +122,19 @@ class Withdraw extends Backend
                     }
                 } elseif ($params['status'] == 'successed') {
                     $remark = '提现'.$row['money'].'通过';
+                    //通过提现到用户账户
+                    /*if (isset($params['type']) && $params['type'] == 'alipay') {
+                        $moneyService = new MoneyService();
+                        $withdrawParams = [
+                            'money' => $params['real_money'],
+                            'alipay_account' => $params['account'],
+                            'name' => $params['name'],
+                        ];
+                        $withdrawRes = $moneyService->withdrawTransfer($withdrawParams);
+                        if (!$withdrawRes['status']) {
+                            throw new Exception($withdrawRes['msg']);
+                        }
+                    }*/
                 }
                 if (!empty($remark)) {
                     //审核结果消息通知

+ 1 - 0
application/admin/lang/zh-cn/withdraw.php

@@ -4,6 +4,7 @@ return [
     'User_id'          => '会员ID',
     'Money'            => '金额',
     'Handingfee'       => '手续费',
+    'Real_money'       => '实际金额',
     'Taxes'            => '税费',
     'Type'             => '类型',
     'wechat'           => '微信',

+ 6 - 0
application/admin/view/withdraw/edit.html

@@ -18,6 +18,12 @@
             <input id="c-handingfee" data-rule="required" class="form-control" step="0.01" name="row[handingfee]" type="number" value="{$row.handingfee|htmlentities}">
         </div>
     </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Real_money')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-real_money" data-rule="required" class="form-control" step="0.01" name="row[real_money]" type="number" value="{$row.real_money|htmlentities}">
+        </div>
+    </div>
     <!--<div class="form-group">
         <label class="control-label col-xs-12 col-sm-2">{:__('Taxes')}:</label>
         <div class="col-xs-12 col-sm-8">

+ 1 - 0
application/api/controller/Usercenter.php

@@ -1289,6 +1289,7 @@ class UserCenter extends Common
                 'user_id'       => $userId,//用户ID
                 'money'         => $moneys,//金额
                 'handingfee'    => $platformMoney,//手续费
+                'real_money'    => bcsub($moneys,$platformMoney,2),//金额
                 'taxes'         => 0.00,//税费
                 'type'          => $typeStr,//类型
                 'account'       => $account,//提现账户

+ 38 - 20
application/common/service/MoneyService.php

@@ -2,6 +2,8 @@
 
 namespace app\common\service;
 
+use think\Exception;
+
 class MoneyService
 {
     private $model =  '';
@@ -15,28 +17,44 @@ class MoneyService
     }
 
     //提现转账(新版2020-01-01)
-    public function withdrawTransfer() {
-        $info = [
-            'money' => 0.10,
-            'alipay_account' => '13651955934',
-            'name' => '张效彬',
+    public function withdrawTransfer($params=[]) {
+        $result = [
+            'status' => 1,
+            'msg' => '',
+            'data' => [],
         ];
-        $data['out_biz_no'] = getMillisecond() . mt_rand(1, 1000); //商户订单号
-        $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语音提现'; //转账业务的标题,用于在支付宝用户的账单里显示
+        try {
+            $money = isset($params['money']) ? $params['money'] : '';
+            $alipayAccount= isset($params['alipay_account']) ? $params['alipay_account'] : '';
+            $name= isset($params['name']) ? $params['name'] : '';
+            $info = [
+                'money' => $money,
+                'alipay_account' => $alipayAccount,
+                'name' => $name,
+            ];
+            $data['out_biz_no'] = getMillisecond() . mt_rand(1, 1000); //商户订单号
+            $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();
-        $result =$alipay->AliPayWithdraw($data);
+            $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;
     }
 }

+ 9 - 4
extend/AliPay/AliPay.php

@@ -264,13 +264,18 @@ class AliPay {
         $responseResult = $alipayClient->execute($request);
         $responseApiName = str_replace(".","_",$request->getApiMethodName())."_response";
         $responsecode = $responseResult->$responseApiName->code;
-        if(!empty($responsecode)&&$responsecode==10000){
+        $result = [
+            'code' => $responsecode,
+            'sub_msg' => $responseResult->$responseApiName->sub_msg,
+        ];
+        return $result;
+        /*if(!empty($responsecode)&&$responsecode==10000){
 //            echo("调用成功");
-            return true;
+            return $responseResult->$responseApiName;
         } else{
 //            echo("调用失败");
-            return false;
-        }
+            return $responseResult->$responseApiName;
+        }*/
     }
 
     /**

+ 1 - 0
public/assets/js/backend/withdraw.js

@@ -31,6 +31,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                         {field: 'user.money', title: __('User.money'), operate:'BETWEEN'},
                         {field: 'money', title: __('Money'), operate:'BETWEEN'},
                         {field: 'handingfee', title: __('Handingfee'), operate:'BETWEEN'},
+                        {field: 'real_money', title: __('Real_money'), operate:'BETWEEN'},
                         //{field: 'taxes', title: __('Taxes'), operate:'BETWEEN'},
                         {field: 'type', title: __('Type'), searchList: Config.typeList, formatter: Table.api.formatter.status},
                         {field: 'account', title: __('Account'), operate: 'LIKE'},