Kirin 1 gadu atpakaļ
vecāks
revīzija
cd5fcc41fe

+ 15 - 9
app/controller/api/v1/user/UserExtractController.php

@@ -12,6 +12,7 @@ namespace app\controller\api\v1\user;
 
 use app\Request;
 use app\services\user\UserExtractServices;
+use crmeb\services\WithdrawService;
 use think\facade\Config;
 
 /**
@@ -51,14 +52,14 @@ class UserExtractController
     public function cash(Request $request)
     {
         $extractInfo = $request->postMore([
-            ['alipay_code', ''],
-            ['extract_type', ''],
+//            ['alipay_code', ''],
+            ['extract_type', 'bank'],
             ['money', 0],
-            ['name', ''],
-            ['bankname', ''],
-            ['cardnum', ''],
-            ['weixin', ''],
-            ['qrcode_url', ''],
+//            ['name', ''],
+//            ['bankname', ''],
+//            ['cardnum', ''],
+//            ['weixin', ''],
+//            ['qrcode_url', ''],
         ]);
         $extractType = Config::get('pay.extractType', []);
         if (!in_array($extractInfo['extract_type'], $extractType))
@@ -70,8 +71,13 @@ class UserExtractController
         if ($extractInfo['extract_type'] == 'alipay') {
             if (!$extractInfo['alipay_code']) return app('json')->fail('请输入支付宝账号');
         } else if ($extractInfo['extract_type'] == 'bank') {
-            if (!$extractInfo['cardnum']) return app('json')->fail('请输入银行卡账号');
-            if (!$extractInfo['bankname']) return app('json')->fail('请输入开户行信息');
+//            if (!$extractInfo['cardnum']) return app('json')->fail('请输入银行卡账号');
+//            if (!$extractInfo['bankname']) return app('json')->fail('请输入开户行信息');
+
+//            $bank_info = WithdrawService::init()::contractInfo($user['enterprise_professional_facilitator_id']);
+//            if ($bank_info['is_contract']) {
+//                return app('json')->fail('签约已完成');
+//            }
         } else if ($extractInfo['extract_type'] == 'weixin' && sys_config('brokerage_type') == 0) {
             if (!$extractInfo['weixin']) return app('json')->fail('请输入微信账号');
         }

+ 24 - 17
app/services/user/UserExtractServices.php

@@ -20,6 +20,7 @@ use app\services\wechat\WechatUserServices;
 use crmeb\exceptions\AdminException;
 use crmeb\services\wechat\Payment;
 use crmeb\services\FormBuilder as Form;
+use crmeb\services\WithdrawService;
 use crmeb\traits\ServicesTrait;
 use think\exception\ValidateException;
 use think\facade\Route as Url;
@@ -127,9 +128,9 @@ class UserExtractServices extends BaseServices
         /** @var UserServices $userServices */
         $userServices = app()->make(UserServices::class);
         $user = $userServices->getUserInfo($uid);
-		if (!$user) {
-			throw new ValidateException('用户不存在');
-		}
+        if (!$user) {
+            throw new ValidateException('用户不存在');
+        }
         /** @var UserBrokerageServices $userBrokerageServices */
         $userBrokerageServices = app()->make(UserBrokerageServices::class);
         $this->transaction(function () use ($user, $userBrokerageServices, $uid, $id, $extract_number, $message, $userServices, $status, $fail_time) {
@@ -163,31 +164,31 @@ class UserExtractServices extends BaseServices
             if (!$this->dao->update($id, ['status' => 1])) {
                 throw new AdminException('修改失败');
             }
-			//配置开启自动到零钱
+            //配置开启自动到零钱
             if (sys_config('brokerage_type', 0)) {
                 /** @var WechatUserServices $wechatServices */
                 $wechatServices = app()->make(WechatUserServices::class);
                 $openid = $wechatServices->getWechatOpenid((int)$userExtract['uid'], 'wechat');
                 if ($openid) {//公众号用户
-					$type = Payment::WEB;
-				} else {//小程序用户
-					$openid = $wechatServices->getWechatOpenid((int)$userExtract['uid'], 'routine');
-					$type = Payment::MINI;
-				}
-				//app微信用户
-				if (!$openid) {
-					$openid = $wechatServices->getWechatOpenid((int)$userExtract['uid'], 'app');
-					$type = Payment::APP;
-				}
-				if ($openid) {
-					/** @var StoreOrderCreateServices $services */
+                    $type = Payment::WEB;
+                } else {//小程序用户
+                    $openid = $wechatServices->getWechatOpenid((int)$userExtract['uid'], 'routine');
+                    $type = Payment::MINI;
+                }
+                //app微信用户
+                if (!$openid) {
+                    $openid = $wechatServices->getWechatOpenid((int)$userExtract['uid'], 'app');
+                    $type = Payment::APP;
+                }
+                if ($openid) {
+                    /** @var StoreOrderCreateServices $services */
                     $services = app()->make(StoreOrderCreateServices::class);
                     $wechat_order_id = $services->getNewOrderId();
                     $res = Payment::merchantPay($openid, $wechat_order_id, $extractNumber, '提现佣金到零钱', $type);
                     if (!$res) {
                         throw new ValidateException('企业付款到零钱失败,请稍后再试');
                     }
-				} else {
+                } else {
                     throw new ValidateException('该用户暂不支持企业付款到零钱,请手动转账');
                 }
             }
@@ -382,6 +383,12 @@ class UserExtractServices extends BaseServices
         if (!$user) {
             throw new ValidateException('数据不存在');
         }
+        $bank_info = WithdrawService::init()::contractInfo($user['enterprise_professional_facilitator_id']);
+        if (!$bank_info['is_contract']) {
+            throw new ValidateException('签约未完成');
+        }
+        $data['cardnum'] = $bank_info['bank_code'];
+        $data['bankname'] = '灵活用工提现';
         /** @var UserBrokerageServices $userBrokerageServices */
         $userBrokerageServices = app()->make(UserBrokerageServices::class);
         $data['broken_commission'] = $userBrokerageServices->getUserFrozenPrice($uid);

+ 2 - 1
config/pay.php

@@ -15,7 +15,8 @@ return [
     //支付方式
     'payType' => ['weixin' => '微信支付', 'yue' => '余额支付', 'offline' => '线下支付'],
     //提现方式
-    'extractType' => ['alipay', 'bank', 'weixin'],
+//    'extractType' => ['alipay', 'bank', 'weixin'],
+    'extractType' => ['bank'],
     //配送方式
     'deliveryType' => ['send' => '商家配送', 'express' => '快递配送'],
     //驱动模式