|
|
@@ -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);
|
|
|
+ }
|
|
|
}
|