Ver código fonte

会员升级

Kirin 1 ano atrás
pai
commit
da42388a07
1 arquivos alterados com 57 adições e 57 exclusões
  1. 57 57
      app/services/user/UserExtractServices.php

+ 57 - 57
app/services/user/UserExtractServices.php

@@ -163,67 +163,67 @@ class UserExtractServices extends BaseServices
     {
         $extractNumber = $userExtract['extract_price'];
         $this->transaction(function () use ($id, $userExtract, $extractNumber) {
-            if ($userExtract['extract_type'] != 'bank') {
-                if (!$this->dao->update($id, ['status' => 1])) {
-                    throw new AdminException('修改失败');
+//            if ($userExtract['extract_type'] != 'bank') {
+            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;
                 }
-                //配置开启自动到零钱
-                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 */
-                        $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 {
-                        throw new ValidateException('该用户暂不支持企业付款到零钱,请手动转账');
+                //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 {
+                    throw new ValidateException('该用户暂不支持企业付款到零钱,请手动转账');
                 }
-                /** @var UserServices $userServices */
-                $userServices = app()->make(UserServices::class);
-                $userType = $userServices->value(['uid' => $userExtract['uid']], 'user_type');
-                $nickname = $userServices->value(['uid' => $userExtract['uid']], 'nickname');
-                $phone = $userServices->value(['uid' => $userExtract['uid']], 'phone');
+            }
+            /** @var UserServices $userServices */
+            $userServices = app()->make(UserServices::class);
+            $userType = $userServices->value(['uid' => $userExtract['uid']], 'user_type');
+            $nickname = $userServices->value(['uid' => $userExtract['uid']], 'nickname');
+            $phone = $userServices->value(['uid' => $userExtract['uid']], 'phone');
 
-                switch ($userExtract['extract_type']) {
-                    case 'bank':
-                        $order_id = $userExtract['bank_code'];
-                        break;
-                    case 'weixin':
-                        $order_id = $userExtract['wechat'];
-                        break;
-                    case 'alipay':
-                        $order_id = $userExtract['alipay_code'];
-                        break;
-                    default:
-                        $order_id = '';
-                        break;
-                }
-                //记录资金流水队列
-                CapitalFlowJob::dispatch([['order_id' => $order_id, 'store_id' => 0, 'uid' => $userExtract['uid'], 'nickname' => $nickname, 'phone' => $phone, 'price' => $extractNumber, 'pay_type' => $userExtract['extract_type']], 'extract']);
+            switch ($userExtract['extract_type']) {
+                case 'bank':
+                    $order_id = $userExtract['bank_code'];
+                    break;
+                case 'weixin':
+                    $order_id = $userExtract['wechat'];
+                    break;
+                case 'alipay':
+                    $order_id = $userExtract['alipay_code'];
+                    break;
+                default:
+                    $order_id = '';
+                    break;
+            }
+            //记录资金流水队列
+            CapitalFlowJob::dispatch([['order_id' => $order_id, 'store_id' => 0, 'uid' => $userExtract['uid'], 'nickname' => $nickname, 'phone' => $phone, 'price' => $extractNumber, 'pay_type' => $userExtract['extract_type']], 'extract']);
 
-                //消息推送
-                event('notice.notice', [['uid' => $userExtract['uid'], 'userType' => strtolower($userType), 'extractNumber' => $extractNumber, 'nickname' => $nickname], 'user_extract']);
-            } else {
-                if (!$this->dao->update($id, ['status' => 1])) {
-                    throw new AdminException('修改失败');
-                }
+            //消息推送
+            event('notice.notice', [['uid' => $userExtract['uid'], 'userType' => strtolower($userType), 'extractNumber' => $extractNumber, 'nickname' => $nickname], 'user_extract']);
+//            } else {
+//                if (!$this->dao->update($id, ['status' => 1])) {
+//                    throw new AdminException('修改失败');
+//                }
 //                $userServices = app()->make(UserServices::class);
 //                $userInfo = $userServices->get($userExtract['uid']);
 //                if (!$userInfo['professional_id']) {
@@ -244,7 +244,7 @@ class UserExtractServices extends BaseServices
 //                if ($res) {
 //                    $this->dao->update($id, ['trade_number' => $res['trade_number']]);
 //                }
-            }
+//            }
         });
         return true;
     }