Example #1
0
 /**
  * 绑定银行卡确认操作
  * @param $request_no 订单号
  * @param $ticket 推进参数
  * @param $valid_code 手机验证码
  * @return array
  */
 public static function bankCardAdvance($request_no, $ticket, $valid_code)
 {
     $flag = SinaBank::find()->where(['request_no' => $request_no, 'ticket' => $ticket, 'status' => SinaBank::STATUS_CONFIRM])->one();
     if ($flag) {
         $sina = new sina();
         $advance = $sina->binding_bank_card_advance($ticket, $valid_code);
         if ($advance['response_code'] == 'APPLY_SUCCESS') {
             $flag->status = SinaBank::STATUS_BINGING;
             $flag->card_id = $advance['card_id'];
             $flag->valid_code = $valid_code;
             $flag->msg = $advance['response_message'];
             if ($flag->save()) {
                 //修改网站账户信息
                 $customer = Info::find()->where(['member_id' => $flag->uid])->one();
                 $customer->bank_card_phone = $flag->phone_no;
                 $customer->bank_card = $flag->bank_account_no;
                 UcenterMember::updateAll(['status' => UcenterMember::STATUS_BIND], ['id' => $flag->uid]);
                 if ($customer->save()) {
                     //赠送绑卡体验金
                     member::give_experience_gold('绑定银行卡', $flag->uid);
                     $return = array('errorNum' => '0', 'errorMsg' => 'success', 'data' => null);
                     return $return;
                 } else {
                     $return = array('errorNum' => '1', 'errorMsg' => '存储错误', 'data' => null);
                     return $return;
                 }
             } else {
                 $return = array('errorNum' => '1', 'errorMsg' => '存储错误', 'data' => null);
                 return $return;
             }
         } elseif ($advance['response_code'] == 'ILLEGAL_ARGUMENT') {
             $flag->valid_code = $valid_code;
             $flag->msg = $advance['response_message'];
             $flag->status = SinaBank::STATUS_ERROR;
             $flag->save();
             $return = array('errorNum' => '1', 'errorMsg' => '验证码失效', 'data' => null);
             return $return;
         } else {
             $flag->valid_code = $valid_code;
             $flag->msg = $advance['response_message'];
             $flag->status = SinaBank::STATUS_ERROR;
             $flag->save();
             $return = array('errorNum' => '1', 'errorMsg' => $advance['response_message'], 'data' => null);
             return $return;
         }
     } else {
         $return = array('errorNum' => '1', 'errorMsg' => '请重新获取验证码', 'data' => null);
         return $return;
     }
 }