Просмотр исходного кода

Weenier 168otc项目部署 0630

wesmiler 3 лет назад
Родитель
Сommit
bc042b3868

+ 23 - 1
app/Http/Controllers/Admin/PaymentController.php

@@ -31,8 +31,30 @@ class PaymentController extends Backend
         $this->service = new MemberPaymentService();
     }
 
+    /**
+     * 列表
+     * @return mixed
+     */
     public function index()
     {
-        return parent::index(); // TODO: Change the autogenerated stub
+        $type = request()->get('type', 1);
+        $pageSize = request()->get('limit', 99);
+        $list = $this->service->getOptionList($this->userInfo['user_id'], $type, $pageSize);
+        $message = array(
+            "msg" => '操作成功',
+            "code" => 0,
+            "data" => isset($list['list'])? $list['list']:[],
+            "count" => isset($list['total'])? $list['total']:0,
+        );
+        return $message;
     }
+
+    /**
+     * 编辑/新增
+     * @return array|mixed
+     */
+    public function edit(){
+        return $this->service->edit($this->userInfo['user_id']);
+    }
+
 }

+ 2 - 1
app/Models/MemberPaymentModel.php

@@ -36,8 +36,9 @@ class MemberPaymentModel extends BaseModel
             if ($info['logo']) {
                 $info['logo'] = get_image_url($info['logo']);
             }
-            
+
         }
         return $info;
     }
+
 }

+ 71 - 0
app/Services/Api/MemberPaymentService.php

@@ -13,6 +13,8 @@ namespace App\Services\Api;
 
 use App\Models\MemberPaymentModel;
 use App\Services\BaseService;
+use App\Services\ConfigService;
+use Earnp\GoogleAuthenticator\GoogleAuthenticator;
 
 /**
  * 会员收款方式-服务类
@@ -189,4 +191,73 @@ class MemberPaymentService extends BaseService
              return $this->model->insert($data);
          }
     }
+
+    /**
+     * 后台添加/编辑
+     * @return array
+     */
+    public function edit($userId){
+        $data = request()->all();
+
+        $id = isset($data['id'])? intval($data['id']) : 0;
+        $googleCode = isset($data['google_code'])? $data['google_code'] : '';
+        $type = isset($data['type'])? $data['type'] : 1;
+        $bankCard = isset($data['bank_card'])? $data['bank_card'] : '';
+        if($type ==1){
+            if(empty($bankCard) || !preg_match("/^[1-9][0-9]{12,19}/")){
+                return returnJson('银行卡号格式不正确,请输入13-19位银行卡号');
+            }
+
+            if($this->model->where(['bank_card'=> $bankCard])->whereNotIn('id', $id)->value('id')){
+                return returnJson('您添加的银行卡号已存在,请核对正确或联系客服处理');
+            }
+        }
+
+        if(empty($googleCode)){
+            return returnJson('请输入您的谷歌验证码,或先绑定再来操作');
+        }
+
+        $userInfo = \App\Services\Common\MemberService::make()->getInfo($userId);
+        if(empty($userInfo)){
+            return returnJson('您的账号异常无法操作,请联系客服处理');
+        }
+
+        $googleSecret = isset($info['google_secret'])? $info['google_secret'] : '';
+        if(empty($googleSecret)){
+           return returnJson(2017);
+        }
+
+        if (!GoogleAuthenticator::CheckCode($googleSecret, $googleCode)) {
+            return returnJson(2018);
+        }
+
+        $limitCount = ConfigService::make()->getConfigByCode('payment_limit_num');
+        $limitCount = $limitCount>0? $limitCount : 30;
+        if($this->model->where(['user_id'=> $userId, 'mark'=> 1])->count('id') >= $limitCount){
+            return returnJson('您当前的收款账号数量已经超出限制,请删除无用账号或联系客服处理');
+        }
+
+        // LOGO
+        if(isset($data['logo'])){
+            $logo = trim($data['logo']);
+            if (strpos($logo, "temp")) {
+                $data['logo'] = save_image($logo, 'business');
+            } else {
+                $data['logo'] = str_replace(IMG_URL, "", $data['logo']);
+            }
+        }
+
+        // QRCODE
+        if(isset($data['qrcode'])){
+            $qrcode = trim($data['qrcode']);
+            if (strpos($qrcode, "temp")) {
+                $data['qrcode'] = save_image($qrcode, 'business');
+            } else {
+                $data['qrcode'] = str_replace(IMG_URL, "", $data['qrcode']);
+            }
+        }
+
+        $data['user_id'] = $userId;
+        return parent::edit($data);
+    }
 }

+ 0 - 3
app/Services/Common/CoinLogService.php

@@ -476,9 +476,6 @@ class CoinLogService extends BaseService
                 }
             }
 
-
-
-
             // 退还
             if($total>0){
                 $userInfo = MemberService::make()->getInfo($userId);