作者 景龙
1 个管道 的构建 失败 耗费 5 秒

增加银行卡列表

@@ -236,8 +236,8 @@ class Person extends Api @@ -236,8 +236,8 @@ class Person extends Api
236 if($data){ 236 if($data){
237 $this->error('不能重复绑定'); 237 $this->error('不能重复绑定');
238 } 238 }
239 - $data = $bank::create(['uid'=>$this->user_id,'bank_num'=>$bank_num,'open_bank'=>$open_bank]);  
240 - if($data){ 239 + $data1 = $bank::create(['uid'=>$this->user_id,'bank_num'=>$bank_num,'open_bank'=>$open_bank]);
  240 + if($data1){
241 $this->success('保存成功'); 241 $this->success('保存成功');
242 }else{ 242 }else{
243 $this->error('保存失败'); 243 $this->error('保存失败');
@@ -248,6 +248,76 @@ class Person extends Api @@ -248,6 +248,76 @@ class Person extends Api
248 } 248 }
249 249
250 /** 250 /**
  251 + * @ApiTitle (银行卡列表)
  252 + * @ApiSummary (银行卡列表)
  253 + * @ApiMethod (GET)
  254 + * @ApiRoute (/api/person/bankList)
  255 + * @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
  256 + * @ApiReturn ([
  257 + {
  258 + "id": 3,//银行卡id
  259 + "bank_num": "6228480028807779179",//银行卡号
  260 + "open_bank": "农业银行"//开户行
  261 + },
  262 + {
  263 + "id": 7,
  264 + "bank_num": "6228480028306448000",
  265 + "open_bank": "open_bank"
  266 + }
  267 + ])
  268 + */
  269 + public function bankList(){
  270 + if($this->request->isGet()){
  271 + $data = Db::table('gc_bank')
  272 + ->where(['uid'=>$this->user_id])
  273 + ->field('id,bank_num,open_bank')
  274 + ->select();
  275 + $this->success('成功', $data);
  276 + }else{
  277 + $this->error('请求方式错误');
  278 + }
  279 + }
  280 +
  281 + /**
  282 + * @ApiTitle (修改银行卡)
  283 + * @ApiSummary (修改银行卡)
  284 + * @ApiMethod (POST)
  285 + * @ApiRoute (/api/person/updateBank)
  286 + * @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
  287 + * @ApiReturn ({
  288 + "code": 1,
  289 + "msg": "修改成功",
  290 + "time": "1555652055",
  291 + "data": null
  292 + })
  293 + */
  294 + public function updateBank(){
  295 + if($this->request->isPost()) {
  296 + $id = $this->request->post('id');//银行卡id
  297 + $bank_num = $this->request->post('bank_num');//银行卡号
  298 + $open_bank = $this->request->post('open_bank');//开户行
  299 + $rule = config('site.update_bank');
  300 + $validate = new Validate($rule['rule'],$rule['msg']);
  301 + if (!$validate->check(['id'=>$id,'bank_num'=>$bank_num,'open_bank'=>$open_bank])) {
  302 + $this->error($validate->getError());
  303 + }
  304 + $data = Db::table('gc_bank')->where('id','neq',$id)->where(['uid'=>$this->user_id,'bank_num'=>$bank_num])->find();
  305 + if($data){
  306 + $this->error('此银行卡已绑定');
  307 + }
  308 + $bank = new Bank();
  309 + $data1 = $bank->where(['id'=>$id,'uid'=>$this->user_id])->update(['open_bank'=>$open_bank,'bank_num'=>$bank_num]);
  310 + if($data1){
  311 + $this->success('修改成功');
  312 + }else{
  313 + $this->error('修改失败');
  314 + }
  315 + }else{
  316 + $this->error('请求方式错误');
  317 + }
  318 + }
  319 +
  320 + /**
251 * 根据规则增加积分 321 * 根据规则增加积分
252 * @param $share_uid 322 * @param $share_uid
253 * @param $type 323 * @param $type
@@ -293,7 +293,22 @@ return array ( @@ -293,7 +293,22 @@ return array (
293 'bank_num.require' => '银行卡号不能为空', 293 'bank_num.require' => '银行卡号不能为空',
294 'bank_num' => '银行卡号格式不正确', 294 'bank_num' => '银行卡号格式不正确',
295 'open_bank.require' => '开户行不能为空', 295 'open_bank.require' => '开户行不能为空',
296 - 'open_bank' => '开户行最多不超过10个字符', 296 + 'open_bank.max' => '开户行最多不超过10个字符',
  297 + ]
  298 + ],
  299 + 'update_bank' => [
  300 + 'rule' => [
  301 + 'id' => 'require|number',
  302 + 'bank_num' => ['require','regex'=>'/^(\d{16}|\d{19})$/'],
  303 + 'open_bank' => 'require|max:10',
  304 + ],
  305 + 'msg' => [
  306 + 'id.require' => '银行卡id不能为空',
  307 + 'id.number' => '银行卡id必须是数字',
  308 + 'bank_num.require' => '银行卡号不能为空',
  309 + 'bank_num' => '银行卡号格式不正确',
  310 + 'open_bank.require' => '开户行不能为空',
  311 + 'open_bank.max' => '开户行最多不超过10个字符',
297 ] 312 ]
298 ], 313 ],
299 'pay' => [ 314 'pay' => [
此 diff 太大无法显示。