public function actionIndex()
 {
     $uid = Yii::$app->user->id;
     $isAuthentic = member::isAuthentic(yii::$app->user->id);
     if ($isAuthentic['errorNum'] != 0) {
         header("Content-type: text/html; charset=utf-8");
         echo "<script>alert('您还没有实名制认证')</script>";
         echo "<script>window.location.href='" . \yii\helpers\Url::to(['site/step2']) . "'</script>";
         exit;
     }
     //判断用户是否绑定银行卡
     $is_bind = sinapay::isBinding($uid);
     $model = UcenterMember::find()->where(['id' => $uid])->one();
     if ($is_bind['errorNum'] != 0) {
         header("Content-type: text/html; charset=utf-8");
         echo "<script>alert('您还没有绑定银行卡');</script>";
         echo "<script>location.href='" . \yii\helpers\Url::to(['site/bindcard']) . "'</script>";
         exit;
     }
     $uid = Yii::$app->user->id;
     $info = Info::find()->where(['member_id' => $uid])->one();
     $limitConfig = sinapay::getsiteConfig();
     if ($limitConfig) {
         $withdraw_max = $limitConfig->withdraw_max;
         $withdraw_min = $limitConfig->withdraw_min;
         $withdraw_times = $limitConfig->withdraw_num;
     }
     return $this->view('index', compact('info', 'withdraw_max', 'withdraw_min', 'withdraw_times'));
 }
Example #2
0
 public static function authentication($uid, $name, $cardno)
 {
     $is = self::isAuthentic($uid);
     $iscard = self::idcardIsAuthentic($cardno);
     if ($is || $iscard) {
         throw new ErrorException('已经存在实名认证信息');
     } else {
         //调用验证接口
         // $res = Port::authentication($uid,$name,$cardno);
         //$res = Port::baiduIdentity($cardno);
         $res = sinapay::authentication($uid, $name, $cardno);
         if (!$res['errorNum']) {
             $member = UcenterMember::findOne($uid);
             $member->idcard = $cardno;
             $member->real_name = $name;
             $member->status = UcenterMember::STATUS_REAL;
             $flag = $member->save();
             if ($flag) {
                 return true;
             } else {
                 throw new ErrorException('实名信息存储失败');
             }
         } else {
             throw new ErrorException($res['errorMsg']);
         }
     }
 }
 public function actionIndex()
 {
     $uid = Yii::$app->user->id;
     //判断用户是否绑定银行卡
     $is_bind = sinapay::isBinding($uid);
     $datas = '';
     if ($is_bind[errorNum] == 0) {
         $datas = $is_bind[data];
     }
     return $this->view('index', compact("datas"));
 }
Example #4
0
 public function actionIndex()
 {
     $uid = Yii::$app->user->id;
     Utils::ensureOpenId();
     $openId = Yii::$app->request->get('open_id');
     if (($usermodel = UcenterMember::findOne(['openid' => $openId])) !== null) {
         Yii::$app->user->login($usermodel);
     } elseif (empty(Yii::$app->user->id)) {
         return $this->redirect(['site/signin']);
     }
     $isAuthentic = member::isAuthentic(yii::$app->user->id);
     if ($isAuthentic['errorNum'] != 0) {
         header("Content-type: text/html; charset=utf-8");
         echo "<script>alert('您还没有实名制认证')</script>";
         echo "<script>window.location.href='" . \yii\helpers\Url::to(['site/step2']) . "'</script>";
         exit;
     }
     //判断用户是否绑定银行卡
     $is_bind = sinapay::isBinding($uid);
     $model = UcenterMember::find()->where(['id' => $uid])->one();
     if ($is_bind['errorNum'] != 0) {
         header("Content-type: text/html; charset=utf-8");
         echo "<script>alert('您还没有绑定银行卡');</script>";
         echo "<script>location.href='" . \yii\helpers\Url::to(['site/bindcard']) . "'</script>";
         exit;
     }
     //全部记录
     $logs = AloneMethod::total_log($uid, 1, 15);
     $logs_pages = Log::find()->select(['step', 'remark', 'status', 'create_at'])->where(['member_id' => $uid])->andWhere(['>', 'status', '0'])->andWhere(['<>', 'step', '0.00'])->asArray()->all();
     $logs_pages = ceil(count($logs_pages) / 15);
     //$logs = Log::find()->select(['step','create_at','status'])->where(['member_id'=>$uid])->andWhere(['in','status',[1,2,3,4]])->orderBy('id desc')->asArray()->all();
     //充值
     $recharge = AloneMethod::recharge_log($uid, 1, 15);
     $recharge_pages = Log::find()->select(['step', 'remark', 'status', 'create_at'])->where(['member_id' => $uid, 'status' => Log::STATUS_RECHAR_SUC])->asArray()->all();
     $recharge_pages = ceil(count($recharge_pages) / 15);
     //投资
     $invest = AloneMethod::invest_log($uid, 1, 15);
     $invest_pages = Log::find()->select(['step', 'remark', 'status', 'create_at'])->where(['member_id' => $uid, 'status' => Log::STATUS_INVEST_SUC])->asArray()->all();
     $invest_pages = ceil(count($invest_pages) / 15);
     //赎回
     $ransom = AloneMethod::redeem_log($uid, 1, 15);
     $ransom_pages = Log::find()->select(['step', 'remark', 'status', 'create_at'])->where(['member_id' => $uid, 'status' => Log::STATUS_REDEM_SUC])->asArray()->all();
     $ransom_pages = ceil(count($recharge_pages) / 15);
     //提现
     $withdraw = AloneMethod::withdrawals_log($uid, 1, 15);
     $withdraw_pages = Log::find()->select(['step', 'remark', 'status', 'create_at'])->where(['member_id' => $uid, 'status' => Log::STATUS_WITHDRAW_SUC])->asArray()->all();
     $withdraw_pages = ceil(count($recharge_pages) / 15);
     return $this->view('index', compact('invest', 'recharge', 'withdraw', 'ransom', 'logs', 'logs_pages', 'recharge_pages', 'invest_pages', 'ransom_pages', 'withdraw_pages'));
 }
 /**
  * Updates an existing SinaFreeze model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUnlock($id)
 {
     $model = $this->findModel($id);
     $return = sinapay::balanceUnfreeze($model->out_freeze_no, $model->freeze_money, '解冻金额');
     if ($return['errorNum'] == 0) {
         \Yii::$app->getSession()->setFlash('warning', $return['errorMsg']);
         $info = new Info();
         $info->freeze -= $model->freeze_money;
         $info->balance += $model->freeze_money;
         $info->save();
     } else {
         \Yii::$app->getSession()->setFlash('warning', $return['errorMsg']);
     }
     return $this->redirect(['index']);
 }
Example #6
0
 public function actionIndex()
 {
     $uid = Yii::$app->user->id;
     $isAuthentic = member::isAuthentic(yii::$app->user->id);
     if ($isAuthentic['errorNum'] != 0) {
         header("Content-type: text/html; charset=utf-8");
         echo "<script>alert('您还没有实名制认证')</script>";
         echo "<script>window.location.href='" . \yii\helpers\Url::to(['site/step2']) . "'</script>";
         exit;
     }
     //判断用户是否绑定银行卡
     $is_bind = sinapay::isBinding($uid);
     $model = UcenterMember::find()->where(['id' => $uid])->one();
     if ($is_bind['errorNum'] != 0) {
         header("Content-type: text/html; charset=utf-8");
         echo "<script>alert('您还没有绑定银行卡');</script>";
         echo "<script>location.href='" . \yii\helpers\Url::to(['site/bindcard']) . "'</script>";
         exit;
     }
     $limitConfig = sinapay::getsiteConfig();
     if ($limitConfig) {
         $ransom_max = $limitConfig->ransom_max;
         $ransom_min = $limitConfig->ransom_min;
         $ransom_times = $limitConfig->ransom_num;
     }
     $collect = AloneMethod::user_collect($uid)[data];
     //在投金额和在投收益
     $red_packet = member::get_user_red_packet($uid)[data];
     //个人账户
     $model_asset = Info::find()->where('member_id=' . Yii::$app->user->id)->one();
     //投资总额
     $invest_total = 0;
     $model_order = Order::find()->where('member_id=' . Yii::$app->user->id . " AND status=1")->all();
     if (count($model_order) > 0) {
         foreach ($model_order as $K => $V) {
             $invest_total += $V->money;
         }
     }
     $invest_total += $model_asset->profit;
     return $this->view('index', compact('invest_total', 'ransom_max', 'ransom_min', 'ransom_times', 'collect', 'red_packet'));
 }
Example #7
0
 public function actionIndex()
 {
     if (Yii::$app->user->isGuest) {
         return $this->redirect(array('/site/signin'));
     }
     $uid = Yii::$app->user->id;
     $isAuthentic = member::isAuthentic(yii::$app->user->id);
     if ($isAuthentic['errorNum'] != 0) {
         header("Content-type: text/html; charset=utf-8");
         echo "<script>alert('您还没有实名制认证')</script>";
         echo "<script>window.location.href='" . \yii\helpers\Url::to(['site/step2']) . "'</script>";
         exit;
     }
     //判断用户是否绑定银行卡
     $is_bind = sinapay::isBinding($uid);
     $model = UcenterMember::find()->where(['id' => $uid])->one();
     if ($is_bind['errorNum'] != 0) {
         header("Content-type: text/html; charset=utf-8");
         echo "<script>alert('您还没有绑定银行卡');</script>";
         echo "<script>location.href='" . \yii\helpers\Url::to(['site/bindcard']) . "'</script>";
         exit;
     }
     if ($_GET) {
         $uid = Yii::$app->user->id;
         $info = Info::find()->where(['member_id' => $uid])->one();
         $product = Product::find(['id' => $_GET['id']])->one();
         //项目可投金额
         $kmoney = \frontend\actions\App\Invest::kmoney($_GET['id'])[data];
         $limitConfig = sinapay::getsiteConfig();
         if ($limitConfig) {
             $invest_max = $limitConfig->invest_max;
             $invest_min = $limitConfig->invest_min;
             $invest_times = $limitConfig->invest_num;
         }
         return $this->view('index', compact('info', 'product', 'invest_max', 'invest_min', 'invest_num', 'kmoney'));
     }
 }
Example #8
0
 public function actionInvestinfos()
 {
     if (\yii::$app->user->isGuest) {
         $this->redirect(['site/login']);
     }
     $pid = $_GET['id'];
     $uid = yii::$app->user->id;
     $model = Product::find()->where('id=' . $pid)->one();
     $model_asset = Info::find()->where(['member_id' => Yii::$app->user->id])->one();
     $model_orders = Order::find()->where('product_id=' . $pid)->asArray()->all();
     //本期投资记录
     $query = (new Query())->select("C.real_name,A.start_money,A.start_at")->from("fund_orders AS A")->where("product_id=" . $pid)->join("left join", "ucenter_member AS C", "A.member_id = C.id")->orderBy('start_at DESC');
     $rows = $query;
     $pages = new Pagination(['totalCount' => $rows->count(), 'pageSize' => '8']);
     $array_investlog = $rows->offset($pages->offset)->limit($pages->limit)->all();
     //最大投资限额——(后台设置里取值)
     $limitConfig = sinapay::getsiteConfig();
     $invest_max = 10000;
     $invest_min = 5;
     $invest_times = 3;
     if ($limitConfig) {
         $invest_max = $limitConfig->invest_max;
         $invest_min = $limitConfig->invest_min;
         $invest_times = $limitConfig->invest_num;
         //当日投资次数
         $today_num = Log::find()->where('member_id = ' . $uid . '  AND create_at > ' . strtotime(date("Y-m-d")) . ' AND status=2')->count();
     }
     $k_money = Invest::kmoney($pid);
     return $this->render('investinfos', compact("invest_max", "invest_min", "invest_times", "today_num", "model", "k_money", "model_orders", "array_investlog", "pages", "model_asset"));
 }
 /**
  * 全部跟新数据
  * @return \yii\web\Response
  */
 public function actionUpbalanceall()
 {
     $flag = sinapay::get_sina_balance_all();
     return $this->redirect(['index']);
 }
Example #10
0
 /**
  * Authre:langxi
  *
  * 用户赎回操作
  */
 public static function User_redeem($member_id, $money)
 {
     ini_set('max_execution_time', 60);
     //判断用户是否可进行赎回操作
     $is_go = Info::find()->select(['status'])->where(['member_id' => $member_id])->asArray()->one();
     if ($is_go['status'] > 0) {
         throw new ErrorException('处理中,请稍后再试');
     }
     Info::updateAll(['status' => Info::GO_THREE], ['member_id' => $member_id]);
     //赎回进行中
     //检查用户一日赎回
     $check_redeem = self::check_redeem($member_id, $money);
     if ($check_redeem) {
         Info::updateAll(['status' => '0'], ['member_id' => $member_id]);
         throw new ErrorException($check_redeem);
     }
     //判断赎回金额是否小于新浪账户与网站账户余额的差值,若小于则网站端进行赎回操作,先赎回利息,然后赎回订单中的金额。
     //若大于求取差值获取到网站需要赎回的金额和新浪部分需要赎回的金额,然后两端分别进行赎回操作,先赎回利息,然后赎回订单中的金额
     $asset = Info::find()->where(['member_id' => $member_id])->asArray()->one();
     $bank_card = $asset['bank_card'];
     //判断用户赎回金额是否可赎回。
     $order_money = (new \yii\db\Query())->select(['money'])->from('fund_orders')->where(['member_id' => $member_id])->andWhere(['>', 'money', '0'])->sum('money');
     if ($order_money + $asset['profit'] < $money) {
         Info::updateAll(['status' => '0'], ['member_id' => $member_id]);
         //赎回结束,操作状态变回常态
         throw new ErrorException('赎回金额大于在投金额,请重新输入');
     }
     $w_blance = self::showBlance($member_id);
     //网站余额
     $s_blance = sinapay::querySinaBalance($member_id);
     //调用第三方接口查看新浪账户可用余额(含货币基金
     if ($s_blance['errorNum']) {
         Info::updateAll(['status' => '0'], ['member_id' => $member_id]);
         //赎回结束,操作状态变回常态
         throw new ErrorException($s_blance['errorMsg'], 7003);
     }
     if ($w_blance > $s_blance['data']['available_balance']) {
         Info::updateAll(['status' => '0'], ['member_id' => $member_id]);
         //赎回结束,操作状态变回常态
         throw new ErrorException('账户异常请联系客服', 7003);
     }
     $m_fund = $s_blance['data']['available_balance'] - $w_blance;
     //新浪账户比网站账户多的钱
     if ($m_fund > $money) {
         //事物回滚
         $transaction = \Yii::$app->db->beginTransaction();
         try {
             //赎回金额小于新浪账户与网站账户的差值,仅网站端进行赎回操作
             $profit = (new \yii\db\Query())->select(['profit'])->from('asset_info')->where(['member_id' => $member_id])->one();
             $profit = $profit['profit'];
             //用户的可用收益
             if ($money <= $profit) {
                 //赎回金额小于等于用户可用收益
                 $info = Info::findOne($member_id);
                 $info->profit = $info['profit'] - $money;
                 $info = $info->save();
                 if (!$info) {
                     throw new ErrorException('赎回失败', 6001);
                 }
                 $info = Info::findOne(['member_id' => $member_id]);
                 $info->balance = $info->balance + $money;
                 $info = $info->save();
                 if (!$info) {
                     throw new ErrorException('赎回金额放入余额失败', 4002);
                 }
                 //由网站设定好的支付利息的账户进行利息支付
                 $sina_config = SinaConfig::find()->select(['sinapay_give_accrual'])->asArray()->one();
                 $profit_id = $sina_config['sinapay_give_accrual'];
                 $profit_info = Info::findOne($profit_id);
                 $profit_info->balance = $profit_info['balance'] - $money;
                 $profit_info = $profit_info->save();
                 if (!$profit_info) {
                     throw new ErrorException('支付利息账户资金减少失败');
                 }
                 //写入职员账户记录表中
                 $clerk = new ClerkLog();
                 $clerk->member_id = $member_id;
                 $clerk->clerk_id = $profit_id;
                 $clerk->behav = ClerkLog::CLERK_BEHAV_TWO;
                 $clerk->step = $money;
                 $clerk->remark = '支付利息职员';
                 $clerk = $clerk->save();
                 if (!$clerk) {
                     throw new ErrorException('写入职员账户记录失败');
                 }
                 //赎回成功进行记录
                 $assetlog = new Log();
                 $assetlog->member_id = $member_id;
                 $assetlog->step = $money;
                 $assetlog->action = 'Withdrawals/Redeem';
                 $assetlog->status = self::RSUCCEED;
                 //赎回成功
                 $assetlog->bankcard = $bank_card;
                 $assetlog->remark = '赎回成功';
                 $assetlog->save();
             } else {
                 //赎回金额大于用户可用收益
                 $info = Info::findOne($member_id);
                 $info->profit = 0;
                 $info = $info->save();
                 if (!$info) {
                     throw new ErrorException('赎回收益失败', 6001);
                 }
                 //由网站设定好的支付利息的账户进行利息支付
                 $sina_config = SinaConfig::find()->select(['sinapay_give_accrual'])->asArray()->one();
                 $profit_id = $sina_config['sinapay_give_accrual'];
                 $profit_info = Info::findOne($profit_id);
                 $profit_info->balance = $profit_info['balance'] - $profit;
                 $profit_info = $profit_info->save();
                 if (!$profit_info) {
                     throw new ErrorException('支付利息账户资金减少失败');
                 }
                 //写入职员账户记录表中
                 $clerk = new ClerkLog();
                 $clerk->member_id = $member_id;
                 $clerk->clerk_id = $profit_id;
                 $clerk->behav = ClerkLog::CLERK_BEHAV_TWO;
                 $clerk->step = $profit;
                 $clerk->remark = '支付利息职员';
                 $clerk = $clerk->save();
                 if (!$clerk) {
                     throw new ErrorException('写入职员账户记录失败');
                 }
                 $redeem_money = $money - $profit;
                 $Redeem = self::Redeem($member_id, $redeem_money);
                 if (!$Redeem) {
                     throw new ErrorException('生成赎回字典失败', 4002);
                 } else {
                     $Redeem = self::Set_redeem($Redeem);
                     if (!$Redeem) {
                         throw new ErrorException('赎回失败');
                     } else {
                         $info = Info::findOne(['member_id' => $member_id]);
                         $info->balance = $info->balance + $money;
                         $info->invest = $info['invest'] - $money;
                         $info = $info->save();
                         if (!$info) {
                             throw new ErrorException('赎回金额放入余额失败', 4002);
                         }
                         //赎回成功进行提现记录
                         $assetlog = new Log();
                         $assetlog->member_id = $member_id;
                         $assetlog->step = $money;
                         $assetlog->action = 'Withdrawals/Redeem';
                         $assetlog->status = self::RSUCCEED;
                         //赎回成功
                         $assetlog->bankcard = $bank_card;
                         $assetlog->remark = '赎回成功';
                         $assetlog->save();
                     }
                 }
             }
             $transaction->commit();
             Info::updateAll(['status' => '0'], ['member_id' => $member_id]);
             //赎回结束,操作状态变回常态
             return true;
         } catch (\Exception $e) {
             $transaction->rollBack();
             //对提现失败信息进行记录
             $remark = $e->getMessage();
             $assetlog = new Log();
             $assetlog->member_id = $member_id;
             $assetlog->step = $money;
             $assetlog->action = 'Withdrawals/Redeem';
             $assetlog->status = self::RERROR;
             //赎回失败
             $assetlog->bankcard = $bank_card;
             $assetlog->remark = '赎回失败' . $remark;
             $assetlog->save();
             Info::updateAll(['status' => '0'], ['member_id' => $member_id]);
             return false;
         }
     } else {
         //赎回金额大于新浪账户与网站账户的差值,取得新浪端赎回金额,网站与新浪都进行赎回操作
         $s_money = $money - $m_fund;
         //新浪端赎回金额
         $profit = (new \yii\db\Query())->select(['profit'])->from('asset_info')->where(['member_id' => $member_id])->one();
         $profit = $profit['profit'];
         //用户的可用收益
         if ($s_money <= $profit) {
             //事物回滚  赎回收益
             $transaction = \Yii::$app->db->beginTransaction();
             try {
                 //新浪赎回金额小于等于用户可用收益
                 $info = Info::findOne($member_id);
                 $info->profit = $info['profit'] - $money;
                 $info = $info->save();
                 if (!$info) {
                     throw new ErrorException('赎回失败', 6001);
                 }
                 //由网站设定好的支付利息的账户进行利息支付
                 $sina_config = SinaConfig::find()->select(['sinapay_give_accrual'])->asArray()->one();
                 $profit_id = $sina_config['sinapay_give_accrual'];
                 $profit_info = Info::findOne($profit_id);
                 $profit_info->balance = $profit_info['balance'] - $money;
                 $profit_info = $profit_info->save();
                 if (!$profit_info) {
                     throw new ErrorException('支付利息账户资金减少失败');
                 }
                 //写入职员账户记录表中
                 $clerk = new ClerkLog();
                 $clerk->member_id = $member_id;
                 $clerk->clerk_id = $profit_id;
                 $clerk->behav = ClerkLog::CLERK_BEHAV_TWO;
                 $clerk->step = $money;
                 $clerk->remark = '支付利息职员';
                 $clerk = $clerk->save();
                 if (!$clerk) {
                     throw new ErrorException('写入职员账户记录失败');
                 }
                 //调用第三方新浪接口赎回收益
                 $sina_ransom = sinapay::giveInterest($member_id, $s_money);
                 //赎回收益
                 if ($sina_ransom['errorNum']) {
                     throw new ErrorException($sina_ransom['errorMsg'], 7002);
                 }
                 $info = Info::findOne(['member_id' => $member_id]);
                 $info->balance = $info->balance + $money;
                 $info = $info->save();
                 if (!$info) {
                     throw new ErrorException('赎回金额放入余额失败', 4002);
                 }
                 //赎回成功进行提现记录
                 $assetlog = new Log();
                 $assetlog->member_id = $member_id;
                 $assetlog->step = $money;
                 $assetlog->action = 'Withdrawals/Redeem';
                 $assetlog->status = self::RSUCCEED;
                 //赎回成功
                 $assetlog->bankcard = $bank_card;
                 $assetlog->remark = '赎回成功';
                 $assetlog->trade_no = $sina_ransom['data']['trade_no'];
                 $assetlog->save();
                 $transaction->commit();
                 Info::updateAll(['status' => '0'], ['member_id' => $member_id]);
                 //赎回结束,操作状态变回常态
                 return true;
             } catch (\Exception $e) {
                 $transaction->rollBack();
                 //对提现失败信息进行记录
                 $remark = $e->getMessage();
                 $assetlog = new Log();
                 $assetlog->member_id = $member_id;
                 $assetlog->step = $money;
                 $assetlog->action = 'Withdrawals/Redeem';
                 $assetlog->status = self::RERROR;
                 //赎回失败
                 $assetlog->bankcard = $bank_card;
                 $assetlog->remark = '赎回失败' . $remark;
                 $assetlog->trade_no = $sina_ransom['data']['trade_no'];
                 $assetlog->save();
                 Info::updateAll(['status' => '0'], ['member_id' => $member_id]);
                 return false;
             }
         } else {
             //新浪赎回金额大于用户可用收益
             $rh_money = 0;
             //赎回金额
             if ($profit > 0) {
                 //收益大于0,赎回收益
                 //事物回滚 赎回收益
                 $transaction = \Yii::$app->db->beginTransaction();
                 try {
                     $info = Info::findOne($member_id);
                     $info->profit = 0;
                     $info = $info->save();
                     if (!$info) {
                         throw new ErrorException('赎回收益失败', 6001);
                     }
                     //由网站设定好的支付利息的账户进行利息支付
                     $sina_config = SinaConfig::find()->select(['sinapay_give_accrual'])->asArray()->one();
                     $profit_id = $sina_config['sinapay_give_accrual'];
                     $profit_info = Info::findOne($profit_id);
                     $profit_info->balance = $profit_info['balance'] - $profit;
                     $profit_info = $profit_info->save();
                     if (!$profit_info) {
                         throw new ErrorException('支付利息账户资金减少失败');
                     }
                     //写入职员账户记录表中
                     $clerk = new ClerkLog();
                     $clerk->member_id = $member_id;
                     $clerk->clerk_id = $profit_id;
                     $clerk->behav = ClerkLog::CLERK_BEHAV_TWO;
                     $clerk->step = $profit;
                     $clerk->remark = '支付利息职员';
                     $clerk = $clerk->save();
                     if (!$clerk) {
                         throw new ErrorException('写入职员账户记录失败');
                     }
                     $info = Info::findOne(['member_id' => $member_id]);
                     $info->balance = $info->balance + $profit;
                     $info = $info->save();
                     if (!$info) {
                         throw new ErrorException('赎回收益放入余额失败', 4002);
                     }
                     $sina_ransom = sinapay::giveInterest($member_id, (string) $profit);
                     //调用第三方接口赎回收益
                     if ($sina_ransom['errorNum']) {
                         throw new ErrorException($sina_ransom['errorMsg'], 7002);
                     }
                     $rh_money = $profit;
                     //赎回金额
                     $transaction->commit();
                 } catch (\Exception $e) {
                     $transaction->rollBack();
                     //对提现失败信息进行记录
                     $remark = $e->getMessage();
                     $assetlog = new Log();
                     $assetlog->member_id = $member_id;
                     $assetlog->step = $money;
                     $assetlog->action = 'Withdrawals/Redeem';
                     $assetlog->status = self::RERROR;
                     //赎回失败
                     $assetlog->bankcard = $bank_card;
                     $assetlog->remark = '赎回失败' . $remark;
                     $assetlog->save();
                     Info::updateAll(['status' => '0'], ['member_id' => $member_id]);
                     return false;
                 }
             }
             $money = $money - $profit;
             $redeem_dic = self::Redeem($member_id, $money);
             //获取债权字典
             foreach ($redeem_dic as $k => $v) {
                 //事物回滚
                 $transaction = \Yii::$app->db->beginTransaction();
                 try {
                     //网站赎回部分
                     //order表金额赎回
                     $order = Order::findOne($v['order_id']);
                     $order->money = $order['money'] - $v['thirdmoney'];
                     if ($order['money'] == '0') {
                         $order->status = Order::STATUS_DELETE;
                     }
                     $order = $order->save();
                     if (!$order) {
                         throw new ErrorException('赎回转让债权失败');
                     }
                     //thirdorder表金额赎回
                     $thirdorder = Thirdorder::findOne($v['thirdorder_id']);
                     $thirdorder->money = $thirdorder['money'] - $v['thirdmoney'];
                     if ($thirdorder['money'] == '0') {
                         $thirdorder->status = Thirdorder::STATUS_DELETED;
                     }
                     $thirdorder->mcmoney = $thirdorder['mcmoney'] + $v['thirdmoney'];
                     //用户赎回,最大债权人支付此金额,记录
                     $thirdorder->ocmoney = $thirdorder['ocmoney'] - $v['thirdmoney'];
                     //用户赎回,原始债权人金额减少,记录
                     $thirdorder = $thirdorder->save();
                     if (!$thirdorder) {
                         throw new ErrorException('赎回第三方转让债权失败');
                     }
                     //thirdproduct第三方债权已投金额减少
                     $thirdproduct = Thirdproduct::findOne($v['thirdproduct_id']);
                     $thirdproduct->invest_sum = $thirdproduct['invest_sum'] - $v['thirdmoney'];
                     $thirdproduct->mcmoney = $thirdproduct['mcmoney'] + $v['thirdmoney'];
                     //赎回导致最大债权人金额增加
                     $thirdproduct = $thirdproduct->save();
                     if (!$thirdproduct) {
                         throw new ErrorException('赎回第三方债权已投金额失败');
                     }
                     //获取债权的最大债权人id,将用户赎回的钱从最大债权人的账户中减去
                     $maxcreditor = Thirdproduct::find()->select(['maxcreditor'])->where(['id' => $v['thirdproduct_id']])->asArray()->one();
                     $maxcreditor = $maxcreditor['maxcreditor'];
                     $is_max = Catmiddle::find()->where(['cid' => '1', 'uid' => $maxcreditor])->asArray()->one();
                     if (!$is_max) {
                         throw new ErrorException('最大债权人异常');
                     }
                     $max_info = Info::findOne($maxcreditor);
                     $max_info->balance = $max_info['balance'] - $v['thirdmoney'];
                     $max_info = $max_info->save();
                     if (!$max_info) {
                         throw new ErrorException('消减最大债权人账户金额失败');
                     }
                     //写入职员账户记录表中
                     $clerk = new ClerkLog();
                     $clerk->member_id = $member_id;
                     $clerk->clerk_id = $maxcreditor;
                     $clerk->behav = ClerkLog::CLERK_BEHAV_TWO;
                     $clerk->step = $v['thirdmoney'];
                     $clerk->remark = '最大债权人';
                     $clerk = $clerk->save();
                     if (!$clerk) {
                         throw new ErrorException('写入职员账户记录失败');
                     }
                     //新浪赎回部分
                     $k_money = $s_money - $v['thirdmoney'];
                     //赎回金额
                     if ($k_money > 0) {
                         $s_money = $k_money;
                         //获取最大债权人
                         $maxcreditor = (new \yii\db\Query())->select(['maxcreditor'])->from('fund_thirdproduct')->where(['id' => $v['thirdproduct_id']])->one();
                         $maxcreditor = $maxcreditor['maxcreditor'];
                         //调用第三方新浪接口赎回
                         $sina_ransom = sinapay::sinaRansom($member_id, (string) $v['thirdmoney'], $maxcreditor);
                         if ($sina_ransom['errorNum']) {
                             throw new ErrorException($sina_ransom['errorMsg'], 7002);
                         }
                         $info = Info::findOne(['member_id' => $member_id]);
                         $info->balance = $info->balance + $v['thirdmoney'];
                         $info->invest = $info['invest'] - $v['thirdmoney'];
                         $info = $info->save();
                         if (!$info) {
                             $money_log = $money - $s_money + $v['thirdmoney'];
                             throw new ErrorException('成功赎回' . $money_log . '元', 4002);
                         }
                         $rh_money = $rh_money + $v['thirdmoney'];
                         //赎回金额
                     } else {
                         //获取最大债权人
                         $maxcreditor = (new \yii\db\Query())->select(['maxcreditor'])->from('fund_thirdproduct')->where(['id' => $v['thirdproduct_id']])->one();
                         $maxcreditor = $maxcreditor['maxcreditor'];
                         //调用第三方新浪接口赎回
                         $sina_ransom = sinapay::sinaRansom($member_id, (string) $s_money, $maxcreditor);
                         //暂定38为支付利息的用户id
                         if ($sina_ransom['errorNum']) {
                             throw new ErrorException($sina_ransom['errorMsg'], 7002);
                         }
                         $info = Info::findOne(['member_id' => $member_id]);
                         $info->balance = $info->balance + $s_money + $m_fund;
                         $info->invest = $info['invest'] - $s_money - $m_fund;
                         $info = $info->save();
                         if (!$info) {
                             $money_log = $money - $s_money + $m_fund;
                             throw new ErrorException('赎回' . $money_log . '元', 4002);
                         }
                         $rh_money = $rh_money + $s_money + $m_fund;
                         //赎回金额
                     }
                     $transaction->commit();
                 } catch (\Exception $e) {
                     $transaction->rollBack();
                     //对提现失败信息进行记录
                     $remark = $e->getMessage();
                     $assetlog = new Log();
                     $assetlog->member_id = $member_id;
                     $assetlog->step = $s_money;
                     $assetlog->action = 'Withdrawals/Redeem';
                     $assetlog->status = self::RERROR;
                     //赎回失败
                     $assetlog->bankcard = $bank_card;
                     $assetlog->remark = '赎回失败' . $remark;
                     $assetlog->trade_no = $sina_ransom['data']['trade_no'];
                     $assetlog->save();
                     Info::updateAll(['status' => '0'], ['member_id' => $member_id]);
                     throw new ErrorException($remark, 5005);
                     break;
                     //异常跳出赎回操作
                 }
             }
             $assetlog = new Log();
             $assetlog->member_id = $member_id;
             $assetlog->step = $rh_money;
             $assetlog->action = 'Withdrawals/Redeem';
             $assetlog->status = self::RSUCCEED;
             //赎回成功
             $assetlog->bankcard = $bank_card;
             $assetlog->remark = '赎回' . $rh_money . '元';
             $assetlog->trade_no = $sina_ransom['data']['trade_no'];
             $assetlog->save();
         }
         Info::updateAll(['status' => '0'], ['member_id' => $member_id]);
         return true;
     }
 }
Example #11
0
 public function actionDorecharge()
 {
     $uid = Yii::$app->user->id;
     if ($_POST) {
         //用户充值操作
         if (isset($_POST['code']) && isset($_POST['ticket']) && isset($_POST['out_trade_no'])) {
             $validate_code = $_POST['code'];
             $out_trade_no = $_POST['out_trade_no'];
             $ticket = $_POST['ticket'];
             try {
                 $info = sinapay::rechargeComfirm($out_trade_no, $ticket, $validate_code);
                 if ($info['errorNum'] == 0) {
                     echo "充值成功";
                     exit;
                 } elseif ($info['errorNum'] != 0) {
                     echo $info['errorMsg'];
                     exit;
                 }
             } catch (ErrorException $e) {
                 echo $e->getMessage();
                 exit;
             }
         } elseif (isset($_POST['money'])) {
             $phone = Info::find()->andWhere(['member_id' => $uid])->one()->bank_card_phone;
             //60秒发送一次验证码
             $time = time() - 60;
             $count = VerifyCode::find()->andWhere(['type' => 1, 'field' => $phone, 'status' => -1])->orderBy('b_time desc')->one();
             if ($time < $count['b_time']) {
                 $return = array('errorNum' => '1', 'errorMsg' => '请勿重复点击', 'data' => null);
                 echo json_encode($return);
                 exit;
             }
             $money = $_POST['money'];
             //充值金额
             try {
                 $info = sinapay::recharge($uid, $money);
                 echo json_encode($info);
                 exit;
             } catch (ErrorException $e) {
                 echo $e->getMessage();
                 exit;
             }
         } else {
             echo '您提交的信息不完整';
             exit;
         }
     }
 }
Example #12
0
 public function actionUnbundling($id)
 {
     $model = $this->findModel($id);
     if ($model->balance) {
         \Yii::$app->getSession()->setFlash('warning', '账户还有余额,请处理完余额再解绑银行卡');
         return $this->render('view', ['model' => $model]);
     }
     $return = sinapay::unbinding_bank_card($model->member_id);
     if ($return['errorNum'] == 0) {
         \Yii::$app->getSession()->setFlash('warning', '解绑成功');
         UcenterMember::updateAll(['status' => UcenterMember::STATUS_REAL], ['id' => $model->member_id]);
         //            SinaBank::updateAll(['status'=>SinaBank::STATUS_DELETED],['id' => $model->member_id,'status'=>SinaBank::STATUS_BINGING]);
         //            Info::updateAll(['bank_card'=>''],['id' => $model->member_id]);
     } else {
         \Yii::$app->getSession()->setFlash('warning', $return['errorMsg']);
     }
     return $this->render('view', ['model' => $model]);
 }
Example #13
0
<?php

use yii\helpers\Html;
use yii\helpers\Url;
use frontend\actions\sinapay;
use common\models\base\asset\Info;
/* @var $this yii\web\View */
$this->title = 'My Yii Application';
$upload = yii::$app->request->baseUrl . '/../../backend/web/upload/';
//判断用户是否绑定银行卡
$is_bind = sinapay::isBinding($user->id);
if ($is_bind['errorNum'] != 0) {
    $bind = false;
} else {
    $bind = true;
}
$info = Info::find()->andWhere(['member_id' => $user->id])->one();
?>
<style>
    .zhszlist{
        padding: 0 5%;
        background: #fff;
        color: #3c3c3c;
    }
    .f13 {
        font-size: 1.3rem;
    }
</style>
<div class="wapper bgd-f5f5f4">
<!--content-->
<div class="content">
Example #14
0
 /**
  * Auther:langxi
  * $member_id:用户id,$product_id:项目id,$money:用户投资钱数
  * 用户投资
  */
 public static function invest($member_id, $product_id, $money)
 {
     ini_set('max_execution_time', 60);
     $member_id = (int) $member_id;
     $product_id = (int) $product_id;
     $money = (double) $money;
     //判断用户是否可进行投资操作
     $is_go = Info::find()->select(['status'])->where(['member_id' => $member_id])->asArray()->one();
     if ($is_go['status'] > 0) {
         Info::updateAll(['status' => '0'], ['member_id' => $member_id]);
         $result = array('errorNum' => '1', 'errorMsg' => '处理中,请稍后再试', 'data' => null);
         return $result;
     }
     Info::updateAll(['status' => Info::GO_TWO], ['member_id' => $member_id]);
     //进行操作,状态变为投资处理中
     //检测用户投资资金,次数
     $check_invest = self::check_invest($member_id, $product_id, $money);
     if ($check_invest['errorNum']) {
         Info::updateAll(['status' => '0'], ['member_id' => $member_id]);
         return $check_invest;
     }
     //检测用户状态
     $checkMember = self::checkMember($member_id);
     if ($checkMember) {
         Info::updateAll(['status' => '0'], ['member_id' => $member_id]);
         return $checkMember;
     }
     //检测用户账户余额是否满足投资金额
     $card = Info::find()->where(['member_id' => $member_id])->asArray()->one();
     if ($card['balance'] < $money) {
         Info::updateAll(['status' => '0'], ['member_id' => $member_id]);
         $result = array('errorNum' => '1', 'errorMsg' => '账户金额不足,请进行充值', 'data' => null);
         return $result;
     }
     //检测投资金额是否满足项目的每次投资最大最小额度限制
     $checkMoney = self::checkMoney($product_id, $money);
     if ($checkMoney) {
         Info::updateAll(['status' => '0'], ['member_id' => $member_id]);
         return $checkMoney;
     }
     //检测项目状态
     $checkProduct = self::checkProduct($product_id, $money);
     if ($checkProduct) {
         Info::updateAll(['status' => '0'], ['member_id' => $member_id]);
         return $checkProduct;
     }
     $asset = Info::find()->where(['member_id' => $member_id])->asArray()->one();
     $bank_card = $asset['bank_card'];
     //用户银行卡
     $product = Product::find()->where(['id' => $product_id])->asArray()->one();
     $end_at = $product['end_at'];
     //项目投资终止时间
     //事物回滚
     $transaction = \Yii::$app->db->beginTransaction();
     try {
         //将账户中的钱取出,放入冻结金额中
         $asset = Info::findOne($member_id);
         $asset->balance = $asset['balance'] - $money;
         $asset->freeze = $asset['freeze'] + $money;
         $asset = $asset->save();
         if (!$asset) {
             throw new ErrorException('投资失败', 4002);
         }
         if ($product['type'] == Product::TYPE_THIRD) {
             //进行投资将钱放入order中  type=1债权转让项目(一对多)
             $order = new Order();
             $order->member_id = $member_id;
             $order->product_id = $product_id;
             $order->type = Product::TYPE_THIRD;
             $order->money = $money;
             $order->start_money = $money;
             $order->status = Order::STATUS_ACTIVE;
             //1标识订单状态进行
             $order->start_at = time();
             $order->end_at = $end_at;
             $order = $order->save();
             if (!$order) {
                 throw new ErrorException('投资失败', 4002);
             }
         } else {
             //进行投资将钱放入order中   type=0债权项目(一对一)
             $order = new Order();
             $order->member_id = $member_id;
             $order->product_id = $product_id;
             $order->type = Product::TYPE_PRO;
             $order->money = $money;
             $order->start_money = $money;
             $order->status = Order::STATUS_ACTIVE;
             //1标识订单状态进行
             $order->start_at = time();
             $order->end_at = $end_at;
             $order = $order->save();
             if (!$order) {
                 throw new ErrorException('投资失败', 4002);
             }
         }
         //检测用户是否投资过该项目,进行项目投资人数加一处理,项目已投金额增长
         $check_people = self::check_people($member_id, $product_id);
         if ($check_people) {
             $product = Product::find()->where(['id' => $product_id])->asArray()->one();
             $product_money = $product['invest_sum'] + $money;
             $total_money = $product['amount'];
             if ($product_money > $total_money) {
                 throw new ErrorException('您投资的金额大于该项目剩余的额度', 4002);
             }
             $product = Product::findOne($product_id);
             $product->invest_sum = $product['invest_sum'] + $money;
             if ($product['amount'] - $product['invest_sum'] < 10) {
                 $product->status = Product::STATUS_OUT;
             }
             $product->invest_people = $product['invest_people'] + 1;
             $res = $product->save();
             if (!$res) {
                 throw new ErrorException('项目已投金额、投资人数增加失败', 4002);
             }
         } else {
             $product = Product::find()->where(['id' => $product_id])->asArray()->one();
             $product_money = $product['invest_sum'] + $money;
             $total_money = $product['amount'];
             if ($product_money > $total_money) {
                 throw new ErrorException('您投资的金额大于该项目剩余的额度', 4002);
             }
             $product = Product::findOne($product_id);
             $product->invest_sum = $product['invest_sum'] + $money;
             if ($product['amount'] - $product['invest_sum'] < 10) {
                 $product->status = Product::STATUS_OUT;
             }
             $res = $product->save();
             if (!$res) {
                 throw new ErrorException('项目已投金额增加失败', 4002);
             }
         }
         //type=1为一对多项目债权转让,等于0为债权项目一对一(只存在于product表中于thirdproduct无关)
         //获取用户此次投资此项目的债权字典
         $thirdArr = self::creditor_dic($product_id, $money);
         //按照生成的债权字典,将钱分配给债权表
         $setthird = self::set_Third($thirdArr, $member_id);
         if ($setthird) {
             return $setthird;
         }
         //删减用户账户冻结金额
         $asset = Info::find()->where(['member_id' => $member_id])->asArray()->one();
         $freeze = $asset['freeze'];
         //获取用户账户新的冻结金额
         $asset = Info::findOne($member_id);
         $asset->freeze = $freeze - $money;
         $asset->invest = $asset['invest'] + $money;
         $asset->total_invest = $asset['total_invest'] + $money;
         //网站投资流程完成,增加用户累计投资额
         $asset = $asset->save();
         if (!$asset) {
             throw new ErrorException('删减冻结金额失败', 4002);
         }
         //投资成功进行投资记录
         $assetlog = new Log();
         $assetlog->member_id = $member_id;
         $assetlog->product_id = $product_id;
         $assetlog->step = $money;
         $assetlog->action = 'Invest/invest';
         $assetlog->status = self::INVESTSUCCEED;
         //2标识投资成功
         $assetlog->bankcard = $bank_card;
         $assetlog->remark = '投资成功';
         $assetlog->save();
         //处理债权字典,生成用于第三方代收的数据字典,键值为用户id,值为钱数 , $sina_pay为第三方代收函数需要的参数
         $sina_dic = array();
         foreach ($thirdArr as $v) {
             $sina_dic['m' . $v['maxcreditor']][] = array($v['mcmoney'], $v['maxcreditor']);
             $sina_dic['c' . $v['creditor']][] = array($v['ocmoney'], $v['creditor']);
         }
         $sina_pay = array();
         foreach ($sina_dic as $key => $val) {
             foreach ($val as $k => $v) {
                 if (!isset($sina_pay[$v['1']])) {
                     $sina_pay[$v['1']] = $v['0'];
                 } else {
                     $sina_pay[$v['1']] += $v['0'];
                 }
             }
         }
         //过滤掉金额为空的数组,得到第三方代收函数需要的参数,$sina_pay
         foreach ($sina_pay as $key => $value) {
             if (empty($value)) {
                 unset($sina_pay[$key]);
             }
         }
         //调用封装好的第三方接口
         $sina_invest = sinapay::invest((string) $member_id, (string) $product_id, (string) $money);
         //托管代收接口
         if ($sina_invest['errorNum']) {
             throw new ErrorException($sina_invest['errorMsg'], 7001);
         }
         $sina_peyee = sinapay::batchPay($sina_pay, $sina_invest['data']['out_trade_no']);
         //托管批量代付接口
         if ($sina_peyee['errorNum']) {
             $sina_refund = sinapay::hostingRefund($sina_invest['data']['identity_id'], $sina_invest['data']['out_trade_no'], $sina_invest['data']['money']);
             if ($sina_refund['errorNum']) {
                 throw new ErrorException($sina_refund['errorMsg'], 7001);
             }
             throw new ErrorException($sina_peyee['errorMsg'], 7001);
         }
         //总投资记录
         $total_log = self::total_log($member_id, $money);
         if ($total_log) {
             return $total_log;
         }
         $transaction->commit();
         Info::updateAll(['status' => '0'], ['member_id' => $member_id]);
         $result = array('errorNum' => '0', 'errorMsg' => 'success', 'data' => null);
         return $result;
     } catch (\Exception $e) {
         $transaction->rollBack();
         //对投资失败信息进行记录
         $remark = $e->getMessage();
         $assetlog = new Log();
         $assetlog->member_id = $member_id;
         $assetlog->product_id = $product_id;
         $assetlog->step = $money;
         $assetlog->action = 'Invest/Invest';
         $assetlog->status = self::INVESTERROR;
         //-2标识投资失败
         $assetlog->bankcard = $bank_card;
         $assetlog->remark = $remark;
         $assetlog->save();
         $result = array('errorNum' => '1', 'errorMsg' => $remark, 'data' => null);
         Info::updateAll(['status' => '0'], ['member_id' => $member_id]);
         return $result;
     }
 }
 /**
  * 用户退款
  * @return string
  * @throws NotFoundHttpException
  */
 public function actionRefund()
 {
     if (\App::$app->request->post()) {
         $uid = \App::$app->request->post()['Code']['uid'];
         $orig_outer_trade_no = \App::$app->request->post()['Code']['out_trade_no'];
         $refund_amount = \App::$app->request->post()['Code']['money'];
         $summary = \App::$app->request->post()['Code']['msg'];
         //获取新浪的账户余额
         $sina_balance = sinapay::querySinaBalance($uid);
         if ($sina_balance['errorNum'] == '0') {
             $available_balance = $sina_balance['data']['available_balance'];
         }
         //获取网站的账户信息
         $balance = Info::findOne(['member_id' => $uid]);
         $site_balabce = $balance['balance'];
         //调用新浪退款接口
         $sina = new sina();
         $out_trade_no = date('Ymd') . substr(implode(NULL, array_map('ord', str_split(substr(uniqid(), 7, 13), 1))), 0, 8) . str_pad(mt_rand(1, 99999), 5, '0', STR_PAD_LEFT);
         $refund = $sina->create_hosting_refund($out_trade_no, $orig_outer_trade_no, $refund_amount, $summary);
         if (!$refund) {
             throw new NotFoundHttpException('新浪接口错误');
         }
         if ($refund['response_code'] == "APPLY_SUCCESS") {
             //提交信息成功
             if ($refund['refund_status'] == 'SUCCESS' || $refund['refund_status'] == 'PAY_FINISHED') {
                 //更新账户信息
                 $sina_balance = sinapay::querySinaBalance($uid);
                 if ($sina_balance['errorNum'] == '0') {
                     $available_balance_now = $sina_balance['data']['available_balance'];
                 }
                 //获取网站的账户信息
                 $balance = Info::findOne(['member_id' => $uid]);
                 $site_balabce_now = $balance['balance'];
                 //返回数据
                 $data = array('available_balance' => $available_balance, 'site_balabce' => $site_balabce, 'available_balance_now' => $available_balance_now, 'site_balabce_now' => $site_balabce_now);
                 return $this->render('import', compact("data"));
             } else {
                 throw new NotFoundHttpException($refund['response_message']);
             }
         } else {
             throw new NotFoundHttpException($refund['response_message']);
         }
     } else {
         $data = array('available_balance' => '-1', 'site_balabce' => '-2', 'available_balance_now' => '-3', 'site_balabce_now' => '-4');
         return $this->render('import', compact("data"));
     }
 }
Example #16
0
 /**
  * 用户充值时做限定
  * @return array|string
  */
 public static function actionChecktodaydeposit()
 {
     $result = App::AppGet();
     try {
         if ($result['errorNum']) {
             $result = array('errorNum' => $result['errorNum'], 'errorMsg' => $result['errorMsg'], 'data' => null);
         } else {
             $data = $result['data'];
             if (array_key_exists('uid', $data)) {
                 $uid = $data['uid'];
                 $result = sinapay::checktodaydeposit($uid);
             } else {
                 $result = array('errorNum' => '1', 'errorMsg' => '参数错误', 'data' => null);
             }
         }
     } catch (ErrorException $e) {
         Yii::error(" 用户充值时做限定---异常 方法:actionChecktodaydeposit 参数:" . json_encode($result['data']), "app");
         Yii::trace($e->getMessage(), "app");
         $result = array('errorNum' => '7', 'errorMsg' => '服务器异常,请联系管理员', 'data' => null);
     }
     $result = App::AppReturn($result);
     return $result;
 }
Example #17
0
 public static function BankInfos()
 {
     $uid = yii::$app->user->id;
     $infos = sinapay::isBinding($uid);
     $bank_code = $infos['data']['bank_code'];
     $logo = '';
     switch ($bank_code) {
         case 'ICBC':
             $logo = 'ICBC';
             break;
         case 'ABC':
             $logo = 'ABC';
             break;
         case 'BOC':
             $logo = 'BOC';
             break;
         case 'CCB':
             $logo = 'CCB';
             break;
         case 'COMM':
             $logo = 'COMM';
             break;
         case 'SPDB':
             $logo = 'SPDB';
             break;
         case 'CIB':
             $logo = 'CIB';
             break;
         case 'CEB':
             $logo = 'CEB';
             break;
         case 'CMBC':
             $logo = 'CMBC';
             break;
         case 'CITIC':
             $logo = 'CITIC';
             break;
         case 'CMB':
             $logo = 'CMB';
             break;
         case 'PSBC':
             $logo = 'PSBC';
             break;
         case 'SZPAB':
             $logo = 'SZPAB';
             break;
         case 'BCCB':
             $logo = 'BCCB';
             break;
         case 'GDB':
             $logo = 'GDB';
             break;
         case 'CBHB':
             $logo = 'CBHB';
             break;
         case 'HXB':
             $logo = 'HXB';
             break;
         case 'BOS':
             $logo = 'BOS';
             break;
         case 'NJCB':
             $logo = 'NJCB';
             break;
         case 'CZB':
             $logo = 'CZB';
             break;
     }
     return $logo;
 }
Example #18
0
 /**
  * Authre:langxi
  *
  * 用户赎回操作
  */
 public static function User_redeem($member_id, $money, $update = 0)
 {
     ini_set('max_execution_time', 60);
     //判断用户是否可进行赎回操作
     $is_go = Info::find()->select(['status'])->where(['member_id' => $member_id])->asArray()->one();
     if ($is_go['status'] > 0) {
         $result = array('errorNum' => '1', 'errorMsg' => '处理中,请稍后再试', 'data' => null);
         return $result;
     }
     Info::updateAll(['status' => Info::GO_THREE], ['member_id' => $member_id]);
     //进行操作,状态变为处理中
     //检查用户一日赎回
     $check_redeem = self::check_redeem($member_id, $money);
     if ($check_redeem) {
         Info::updateAll(['status' => '0'], ['member_id' => $member_id]);
         //            $result = array('errorNum' => '1', 'errorMsg' => $check_redeem, 'data' => null);
         return $check_redeem;
     }
     //判断赎回金额是否小于新浪账户与网站账户余额的差值,若小于则网站端进行赎回操作,先赎回利息,然后赎回订单中的金额。
     //若大于求取差值获取到网站需要赎回的金额和新浪部分需要赎回的金额,然后两端分别进行赎回操作,先赎回利息,然后赎回订单中的金额
     $asset = Info::find()->where(['member_id' => $member_id])->asArray()->one();
     $bank_card = $asset['bank_card'];
     //获取用户在投收益
     $profit = $asset['profit'];
     //判断用户赎回金额是否可赎回。
     $order_money = (new \yii\db\Query())->select(['money'])->from('fund_orders')->where(['member_id' => $member_id])->andWhere(['>', 'money', '0'])->sum('money');
     //增加了活动红包begin
     if ($update) {
         $red_money = member::get_user_red_packet($member_id, $update);
         if (!$red_money['errorNum']) {
             $red = $red_money['data']['red_sum'];
             $order_money = $order_money + $red;
         }
     }
     ////活动红包end
     if ($order_money + $profit < $money) {
         Info::updateAll(['status' => '0'], ['member_id' => $member_id]);
         //赎回结束,操作状态变回常态
         $result = array('errorNum' => '1', 'errorMsg' => '赎回金额大于可赎回金额,请重新输入', 'data' => null);
         return $result;
     }
     $w_blance = self::showBlance($member_id);
     //网站余额
     $s_blance = sinapay::querySinaBalance($member_id);
     //调用第三方接口查看新浪账户可用余额(含货币基金
     if ($s_blance['errorNum']) {
         Info::updateAll(['status' => '0'], ['member_id' => $member_id]);
         //赎回结束,操作状态变回常态
         $result = array('errorNum' => '1', 'errorMsg' => $s_blance['errorMsg'], 'data' => null);
         return $result;
     }
     if ($w_blance > $s_blance['data']['available_balance']) {
         Info::updateAll(['status' => '0'], ['member_id' => $member_id]);
         //赎回结束,操作状态变回常态
         $result = array('errorNum' => '1', 'errorMsg' => '账户异常请联系客服', 'data' => null);
         return $result;
     }
     $m_fund = $s_blance['data']['available_balance'] - $w_blance;
     //新浪账户比网站账户多的钱--新浪的货币基金
     $red_packet = 0;
     $red = 0;
     //如果赎回和活动红包有关系 TODO
     if ($update) {
         //赎回时必须有在投金额
         $invest = $asset['invest'];
         if ($invest && $invest >= 1) {
             //获取那个时间点的金额
             $red_money = member::get_user_red_packet($member_id, $update);
             if (!$red_money['errorNum']) {
                 $red = $red_money['data']['red_sum'];
                 if ((double) $red > (double) $money) {
                     //如果只是提取一部分红包
                     $return = array('errorNum' => '1', 'errorMsg' => '红包必须全部赎回', 'data' => null);
                     return $return;
                 }
             } else {
                 $return = array('errorNum' => '1', 'errorMsg' => $red_money['errorMsg'], 'data' => null);
                 return $return;
             }
         }
     }
     //应该扣除红包的金额
     $red_packet = $red;
     //$m_fund ---新浪的货币基金
     //货币基金大于用户要赎回的资金--发上几率比较小
     if ($m_fund > $money) {
         //事物回滚
         $transaction = \Yii::$app->db->beginTransaction();
         try {
             //赎回金额小于新浪账户与网站账户的差值,仅网站端进行赎回操作
             $profit = (new \yii\db\Query())->select(['profit'])->from('asset_info')->where(['member_id' => $member_id])->one();
             //TODO --添加了红包++++++$red_packet;
             $profit = $profit['profit'] + $red_packet;
             //用户的可用收益
             // money 减去红包
             if ($money <= $profit) {
                 // 红包表的处理
                 if ($update) {
                     $info = Info::findOne($member_id);
                     $info->profit = $info['profit'] + $red_packet;
                     $info = $info->save();
                     if (!$info) {
                         throw new ErrorException('红包赎回失败', 6001);
                     }
                     $flag = member::draw_red_packet($member_id, $update);
                     if ($flag['errorNum']) {
                         throw new ErrorException('红包赎回失败', 6001);
                     }
                 }
                 //赎回金额小于等于用户可用收益
                 $info = Info::findOne($member_id);
                 $info->profit = $info['profit'] - $money;
                 $info = $info->save();
                 if (!$info) {
                     throw new ErrorException('赎回失败', 6001);
                 }
                 $info = Info::findOne(['member_id' => $member_id]);
                 $info->balance = $info->balance + $money;
                 $info = $info->save();
                 if (!$info) {
                     throw new ErrorException('赎回金额放入余额失败', 4002);
                 }
                 //由网站设定好的支付利息的账户进行利息支付
                 $sina_config = SinaConfig::find()->select(['sinapay_give_accrual'])->asArray()->one();
                 $profit_id = $sina_config['sinapay_give_accrual'];
                 $profit_info = Info::findOne($profit_id);
                 $profit_info->balance = $profit_info['balance'] - $money;
                 $profit_info = $profit_info->save();
                 if (!$profit_info) {
                     throw new ErrorException('支付利息账户资金减少失败');
                 }
                 //写入职员账户记录表中
                 $clerk = new ClerkLog();
                 $clerk->member_id = $member_id;
                 $clerk->clerk_id = $profit_id;
                 $clerk->behav = ClerkLog::CLERK_BEHAV_TWO;
                 $clerk->step = $money;
                 $clerk->remark = '支付利息职员';
                 $clerk = $clerk->save();
                 if (!$clerk) {
                     throw new ErrorException('写入职员账户记录失败');
                 }
                 //赎回成功进行提现记录
                 $assetlog = new Log();
                 $assetlog->member_id = $member_id;
                 $assetlog->step = $money;
                 $assetlog->action = 'Withdrawals/Redeem';
                 $assetlog->status = self::RSUCCEED;
                 //赎回成功
                 $assetlog->bankcard = $bank_card;
                 $assetlog->remark = '赎回成功';
                 $assetlog->save();
             } else {
                 //赎回金额大于用户可用收益
                 $info = Info::findOne($member_id);
                 $info->profit = 0;
                 $info = $info->save();
                 if (!$info) {
                     throw new ErrorException('赎回收益失败', 6001);
                 }
                 if ($update) {
                     $flag = member::draw_red_packet($member_id, $update);
                     if ($flag['errorNum']) {
                         throw new ErrorException('红包赎回失败', 6001);
                     }
                 }
                 //由网站设定好的支付利息的账户进行利息支付
                 $sina_config = SinaConfig::find()->select(['sinapay_give_accrual'])->asArray()->one();
                 $profit_id = $sina_config['sinapay_give_accrual'];
                 $profit_info = Info::findOne($profit_id);
                 $profit_info->balance = $profit_info['balance'] - $profit;
                 $profit_info = $profit_info->save();
                 if (!$profit_info) {
                     throw new ErrorException('支付利息账户资金减少失败');
                 }
                 //写入职员账户记录表中
                 $clerk = new ClerkLog();
                 $clerk->member_id = $member_id;
                 $clerk->clerk_id = $profit_id;
                 $clerk->behav = ClerkLog::CLERK_BEHAV_TWO;
                 $clerk->step = $profit;
                 $clerk->remark = '支付利息职员';
                 $clerk = $clerk->save();
                 if (!$clerk) {
                     throw new ErrorException('写入职员账户记录失败');
                 }
                 $redeem_money = $money - $profit;
                 // TODO
                 $Redeem = self::Redeem($member_id, $redeem_money);
                 if (!$Redeem) {
                     throw new ErrorException('生成赎回字典失败', 4002);
                 } else {
                     $Redeem = self::Set_redeem($Redeem);
                     if (!$Redeem) {
                         throw new ErrorException('赎回失败');
                     } else {
                         $info = Info::findOne(['member_id' => $member_id]);
                         $info->balance = $info->balance + $money;
                         $info->invest = $info['invest'] - $redeem_money;
                         $info = $info->save();
                         if (!$info) {
                             throw new ErrorException('赎回金额放入余额失败', 4002);
                         }
                         //赎回成功进行提现记录
                         $assetlog = new Log();
                         $assetlog->member_id = $member_id;
                         $assetlog->step = $redeem_money;
                         $assetlog->action = 'Withdrawals/Redeem';
                         $assetlog->status = self::RSUCCEED;
                         //赎回成功
                         $assetlog->bankcard = $bank_card;
                         $assetlog->remark = '赎回成功';
                         $assetlog->save();
                     }
                 }
             }
             $transaction->commit();
             Info::updateAll(['status' => '0'], ['member_id' => $member_id]);
             //赎回结束,操作状态变回常态
             $result = array('errorNum' => '0', 'errorMsg' => 'success', 'data' => null);
             return $result;
         } catch (\Exception $e) {
             $transaction->rollBack();
             //对提现失败信息进行记录
             $remark = $e->getMessage();
             \Yii::error($e->getTraceAsString(), 'app');
             $assetlog = new Log();
             $assetlog->member_id = $member_id;
             $assetlog->step = $money;
             $assetlog->action = 'Withdrawals/Redeem';
             $assetlog->status = self::RERROR;
             //赎回失败
             $assetlog->bankcard = $bank_card;
             $assetlog->remark = '赎回失败' . $remark;
             $assetlog->save();
             Info::updateAll(['status' => '0'], ['member_id' => $member_id]);
             //赎回结束,操作状态变回常态
             $result = array('errorNum' => '1', 'errorMsg' => $remark, 'data' => null);
             return $result;
         }
     } else {
         //赎回金额大于新浪账户与网站账户的差值,取得新浪端赎回金额,网站与新浪都进行赎回操作
         //---新浪货币基金不足以支撑赎回操作---$s_money ---除去新浪货币基金后要进行的赎回金额
         $s_money = $money - $m_fund;
         //新浪端赎回金额
         $profit = (new \yii\db\Query())->select(['profit'])->from('asset_info')->where(['member_id' => $member_id])->one();
         $profit = $profit['profit'];
         //用户的可用收益
         ///进行收益的赎回----假定把红包加到用户收益内
         //++++用户收益足以满足用户的赎回操作---用户直接赎回投资的收益就可以了
         if ($s_money <= $profit + $red_packet) {
             //事物回滚  赎回收益
             $transaction = \Yii::$app->db->beginTransaction();
             try {
                 //红包处理---加用户收益 TODO
                 if ($update) {
                     $info = Info::findOne($member_id);
                     $info->profit = $info['profit'] + $red_packet;
                     $info = $info->save();
                     if (!$info) {
                         throw new ErrorException('红包赎回失败', 6001);
                     }
                     $flag = member::draw_red_packet($member_id, $update);
                     if ($flag['errorNum']) {
                         throw new ErrorException('红包赎回失败', 6001);
                     }
                 }
                 //用户收益足以满足用户的赎回操作---用户直接赎回投资的收益就可以了
                 $info = Info::findOne($member_id);
                 $info->profit = $info['profit'] - $s_money;
                 $info = $info->save();
                 if (!$info) {
                     throw new ErrorException('赎回失败', 6001);
                 }
                 //用户只是赎回在投收益---网站给只利息就行了
                 $sina_config = SinaConfig::find()->select(['sinapay_give_accrual'])->asArray()->one();
                 $profit_id = $sina_config['sinapay_give_accrual'];
                 $profit_info = Info::findOne($profit_id);
                 $profit_info->balance = $profit_info['balance'] - $s_money;
                 $profit_info = $profit_info->save();
                 if (!$profit_info) {
                     throw new ErrorException('支付利息账户资金减少失败');
                 }
                 //写入职员账户记录表中
                 $clerk = new ClerkLog();
                 $clerk->member_id = $member_id;
                 $clerk->clerk_id = $profit_id;
                 $clerk->behav = ClerkLog::CLERK_BEHAV_TWO;
                 $clerk->step = $money;
                 $clerk->remark = '支付利息职员';
                 $clerk = $clerk->save();
                 if (!$clerk) {
                     throw new ErrorException('写入职员账户记录失败');
                 }
                 //--网站账户处理成功了----调用第三方新浪接口赎回收益
                 $sina_ransom = sinapay::giveInterest($member_id, $s_money);
                 //赎回收益
                 if ($sina_ransom['errorNum']) {
                     throw new ErrorException($sina_ransom['errorMsg'], 7002);
                 }
                 //更新网站中账户的余额和收益---涉及到货币基金--用户更新数据用$money---实际给付是$s_money
                 $info = Info::findOne(['member_id' => $member_id]);
                 $info->balance = $info->balance + $money;
                 $info = $info->save();
                 if (!$info) {
                     throw new ErrorException('赎回金额放入余额失败', 4002);
                 }
                 //赎回成功进行赎回记录
                 $assetlog = new Log();
                 $assetlog->member_id = $member_id;
                 $assetlog->step = $money;
                 $assetlog->action = 'Withdrawals/Redeem';
                 $assetlog->status = self::RSUCCEED;
                 //赎回成功
                 $assetlog->bankcard = $bank_card;
                 $assetlog->remark = '赎回成功';
                 $assetlog->save();
                 $transaction->commit();
                 Info::updateAll(['status' => '0'], ['member_id' => $member_id]);
                 //赎回结束,操作状态变回常态
                 $result = array('errorNum' => '0', 'errorMsg' => 'success', 'data' => null);
                 return $result;
             } catch (\Exception $e) {
                 $transaction->rollBack();
                 //对提现失败信息进行记录
                 $remark = $e->getMessage();
                 \Yii::error($e->getTraceAsString(), 'app');
                 $assetlog = new Log();
                 $assetlog->member_id = $member_id;
                 $assetlog->step = $money;
                 $assetlog->action = 'Withdrawals/Redeem';
                 $assetlog->status = self::RERROR;
                 //赎回失败
                 $assetlog->bankcard = $bank_card;
                 $assetlog->remark = '赎回失败' . $remark;
                 $assetlog->save();
                 Info::updateAll(['status' => '0'], ['member_id' => $member_id]);
                 //赎回结束,操作状态变回常态
                 $result = array('errorNum' => '1', 'errorMsg' => $remark, 'data' => null);
                 return $result;
             }
         } else {
             //用户的赎回金额大于用户可用收益---需要进行债权赎回操作
             $rh_money = 0;
             //赎回金额
             //如果有活动红包奖励--进行红包加到收益里操作
             //收益大于0,首先赎回收益
             if ($profit + $red_packet > 0) {
                 //事物回滚 赎回收益
                 $transaction = \Yii::$app->db->beginTransaction();
                 try {
                     //红包操作---增加用户的账户再投收益
                     $profit = $profit + $red_packet;
                     if ($update) {
                         $flag = member::draw_red_packet($member_id, $update);
                         if ($flag['errorNum']) {
                             throw new ErrorException('红包赎回失败', 6001);
                         }
                     }
                     //$s_money 是大于用户当前账户中的再投收益的--已经怎加活动奖励红包
                     $info = Info::findOne($member_id);
                     $info->profit = 0;
                     $info = $info->save();
                     if (!$info) {
                         throw new ErrorException('赎回收益失败', 6001);
                     }
                     //由网站设定好的支付利息的账户进行利息支付---再投收益全部赎回了
                     $sina_config = SinaConfig::find()->select(['sinapay_give_accrual'])->asArray()->one();
                     $profit_id = $sina_config['sinapay_give_accrual'];
                     $profit_info = Info::findOne($profit_id);
                     $profit_info->balance = $profit_info['balance'] - $profit;
                     $profit_info = $profit_info->save();
                     if (!$profit_info) {
                         throw new ErrorException('支付利息账户资金减少失败');
                     }
                     //写入职员账户记录表中
                     $clerk = new ClerkLog();
                     $clerk->member_id = $member_id;
                     $clerk->clerk_id = $profit_id;
                     $clerk->behav = ClerkLog::CLERK_BEHAV_TWO;
                     $clerk->step = $profit;
                     $clerk->remark = '支付利息职员';
                     $clerk = $clerk->save();
                     if (!$clerk) {
                         throw new ErrorException('写入职员账户记录失败');
                     }
                     $info = Info::findOne(['member_id' => $member_id]);
                     $info->balance = $info->balance + $profit;
                     $info = $info->save();
                     if (!$info) {
                         throw new ErrorException('赎回收益放入余额失败', 4002);
                     }
                     $sina_ransom = sinapay::giveInterest($member_id, (string) $profit);
                     //调用第三方接口赎回收益
                     if ($sina_ransom['errorNum']) {
                         throw new ErrorException($sina_ransom['errorMsg'], 7002);
                     }
                     //记录用户的赎回金额
                     $rh_money = $profit;
                     $transaction->commit();
                 } catch (\Exception $e) {
                     $transaction->rollBack();
                     //对提现失败信息进行记录
                     $remark = $e->getMessage();
                     \Yii::error($e->getTraceAsString(), 'app');
                     $assetlog = new Log();
                     $assetlog->member_id = $member_id;
                     $assetlog->step = $money;
                     $assetlog->action = 'Withdrawals/Redeem';
                     $assetlog->status = self::RERROR;
                     //赎回失败
                     $assetlog->bankcard = $bank_card;
                     $assetlog->remark = '赎回失败' . $remark;
                     $assetlog->save();
                     Info::updateAll(['status' => '0'], ['member_id' => $member_id]);
                     //赎回结束,操作状态变回常态
                     $result = array('errorNum' => '1', 'errorMsg' => $remark, 'data' => null);
                     return $result;
                 }
             }
             //用户已经赎回了所有的再投收益---计算还需要进行多少的债权赎回操作
             $money = $money - $profit;
             $redeem_dic = self::Redeem($member_id, $money);
             //获取债权字典--进行债权的赎回操作
             foreach ($redeem_dic as $k => $v) {
                 if ($v['thirdmoney'] == 0) {
                     continue;
                 }
                 //事物回滚
                 $transaction = \Yii::$app->db->beginTransaction();
                 try {
                     //网站赎回部分
                     //order表金额赎回
                     $order = Order::findOne($v['order_id']);
                     $order->money = $order['money'] - $v['thirdmoney'];
                     if ($order['money'] == '0') {
                         $order->status = Order::STATUS_DELETE;
                     }
                     $order = $order->save();
                     if (!$order) {
                         throw new ErrorException('赎回转让债权失败');
                     }
                     //thirdorder表金额赎回
                     $thirdorder = Thirdorder::findOne($v['thirdorder_id']);
                     $thirdorder->money = $thirdorder['money'] - $v['thirdmoney'];
                     if ($thirdorder['money'] == '0') {
                         $thirdorder->status = Thirdorder::STATUS_DELETED;
                     }
                     $thirdorder->mcmoney = $thirdorder['mcmoney'] + $v['thirdmoney'];
                     //用户赎回,最大债权人支付此金额,记录
                     $thirdorder->ocmoney = $thirdorder['ocmoney'] - $v['thirdmoney'];
                     //用户赎回,原始债权人金额减少,记录
                     $thirdorder = $thirdorder->save();
                     if (!$thirdorder) {
                         throw new ErrorException('赎回第三方转让债权失败');
                     }
                     //thirdproduct第三方债权已投金额减少
                     $thirdproduct = Thirdproduct::findOne($v['thirdproduct_id']);
                     $thirdproduct->invest_sum = $thirdproduct['invest_sum'] - $v['thirdmoney'];
                     $thirdproduct->mcmoney = $thirdproduct['mcmoney'] + $v['thirdmoney'];
                     //赎回导致最大债权人金额增加
                     $thirdproduct = $thirdproduct->save();
                     if (!$thirdproduct) {
                         throw new ErrorException('赎回第三方债权已投金额失败');
                     }
                     //获取债权的最大债权人id,将用户赎回的钱从最大债权人的账户中减去
                     $maxcreditor = Thirdproduct::find()->select(['maxcreditor'])->where(['id' => $v['thirdproduct_id']])->asArray()->one();
                     $maxcreditor = $maxcreditor['maxcreditor'];
                     $is_max = Catmiddle::find()->where(['cid' => '1', 'uid' => $maxcreditor])->asArray()->one();
                     if (!$is_max) {
                         throw new ErrorException('最大债权人异常');
                     }
                     $max_info = Info::findOne($maxcreditor);
                     $max_info->balance = $max_info['balance'] - $v['thirdmoney'];
                     $max_info = $max_info->save();
                     if (!$max_info) {
                         throw new ErrorException('消减最大债权人账户金额失败');
                     }
                     //写入职员账户记录表中
                     $clerk = new ClerkLog();
                     $clerk->member_id = $member_id;
                     $clerk->clerk_id = $maxcreditor;
                     $clerk->behav = ClerkLog::CLERK_BEHAV_TWO;
                     $clerk->step = $v['thirdmoney'];
                     $clerk->remark = '最大债权人';
                     $clerk = $clerk->save();
                     if (!$clerk) {
                         throw new ErrorException('写入职员账户记录失败');
                     }
                     //新浪赎回部分???
                     $k_money = $s_money - $v['thirdmoney'];
                     //赎回金额
                     if ($k_money > 0) {
                         $s_money = $k_money;
                         //获取最大债权人
                         $maxcreditor = (new \yii\db\Query())->select(['maxcreditor'])->from('fund_thirdproduct')->where(['id' => $v['thirdproduct_id']])->one();
                         $maxcreditor = $maxcreditor['maxcreditor'];
                         //调用第三方新浪接口赎回
                         //
                         $money_sina = sprintf("%.2f", $v['thirdmoney']);
                         if ($money_sina > 0) {
                             $sina_ransom = sinapay::sinaRansom($member_id, $money_sina, $maxcreditor);
                             //暂定38为支付利息的用户id
                             if ($sina_ransom['errorNum']) {
                                 throw new ErrorException($sina_ransom['errorMsg'], 7002);
                             }
                         }
                         $info = Info::findOne(['member_id' => $member_id]);
                         $info->balance = $info->balance + $v['thirdmoney'];
                         $info->invest = $info['invest'] - $v['thirdmoney'];
                         $info = $info->save();
                         if (!$info) {
                             $money_log = $money - $s_money + $v['thirdmoney'];
                             throw new ErrorException('成功赎回' . $money_log . '元', 4002);
                         }
                         $rh_money = $rh_money + $v['thirdmoney'];
                         //赎回金额
                     } else {
                         //获取最大债权人
                         $maxcreditor = (new \yii\db\Query())->select(['maxcreditor'])->from('fund_thirdproduct')->where(['id' => $v['thirdproduct_id']])->one();
                         $maxcreditor = $maxcreditor['maxcreditor'];
                         //调用第三方新浪接口赎回
                         $money_sina = sprintf("%.2f", $s_money);
                         if ($money_sina) {
                             $sina_ransom = sinapay::sinaRansom($member_id, $money_sina, $maxcreditor);
                             //暂定38为支付利息的用户id
                             if ($sina_ransom['errorNum']) {
                                 throw new ErrorException($sina_ransom['errorMsg'], 7002);
                             }
                         }
                         $info = Info::findOne(['member_id' => $member_id]);
                         $info->balance = $info->balance + $s_money + $m_fund;
                         $info->invest = $info['invest'] - $s_money - $m_fund;
                         $info = $info->save();
                         if (!$info) {
                             $money_log = $money - $s_money + $m_fund;
                             throw new ErrorException('赎回' . $money_log . '元', 4002);
                         }
                         $rh_money = $rh_money + $s_money + $m_fund;
                         //赎回金额
                     }
                     $transaction->commit();
                 } catch (\Exception $e) {
                     $transaction->rollBack();
                     //对提现失败信息进行记录
                     $remark = $e->getMessage();
                     \Yii::error($e->getTraceAsString(), 'app');
                     $assetlog = new Log();
                     $assetlog->member_id = $member_id;
                     $assetlog->step = $s_money;
                     $assetlog->action = 'Withdrawals/Redeem';
                     $assetlog->status = self::RERROR;
                     //赎回失败
                     $assetlog->bankcard = $bank_card;
                     $assetlog->remark = '赎回失败' . $remark;
                     $assetlog->save();
                     Info::updateAll(['status' => '0'], ['member_id' => $member_id]);
                     $result = array('errorNum' => '1', 'errorMsg' => $remark, 'data' => null);
                     return $result;
                     break;
                 }
             }
             $assetlog = new Log();
             $assetlog->member_id = $member_id;
             $assetlog->step = $rh_money;
             $assetlog->action = 'Withdrawals/Redeem';
             $assetlog->status = self::RSUCCEED;
             //赎回成功
             $assetlog->bankcard = $bank_card;
             $assetlog->remark = '赎回' . $rh_money . '元';
             //赎回金额
             $assetlog->save();
         }
         Info::updateAll(['status' => '0'], ['member_id' => $member_id]);
         //赎回结束,操作状态变回常态
         $result = array('errorNum' => '0', 'errorMsg' => 'success', 'data' => null);
         return $result;
     }
 }
Example #19
0
 public function actionDobindcard()
 {
     $uid = yii::$app->user->id;
     $model = UcenterMember::find()->where(['id' => $uid])->one();
     if ($_POST) {
         if ($_POST['bankcard'] && $_POST['phone'] && $_POST['code'] && isset($_POST['ticket']) && isset($_POST['request_no'])) {
             $valid_code = $_POST['code'];
             $request_no = $_POST['request_no'];
             $ticket = $_POST['ticket'];
             $info = sinapay::bankCardAdvance($request_no, $ticket, $valid_code);
             if ($info['errorNum'] == 1) {
                 return $this->goBack(['info' => $info['errorMsg'], 'model' => $model], Url::to(['bindcard']));
             }
             return $this->view('member');
         } else {
             return $this->goBack(['info' => '你没有输入完整', 'model' => $model], Url::to(['bindcard']));
         }
         //            $bandcard = $_POST['bankcard'];
         //            $phone = $_POST['phone'];
         //            $return = sinapay::bindingBankCard($uid,$bandcard,$phone);
         //            if($return['errorNum']==1){
         //                return $this->goBack([
         //                    'info' => $return['errorMsg'],
         //                    'model' => $model,
         //                ], Url::to(['bindcard']));
         //            }
         //            return $this->view('member');
     }
 }
Example #20
0
 public function actionWly()
 {
     $test = sinapay::bindingBankCard('118', '201510285310056139580', '15231231883');
     //		$test = Balance::isBinding('11');
     var_dump($test);
     exit;
     //		$test = Balance::bindbankcard(31,'6217000140004808851','131102199007042019','王利亚','15127281324','1');
     //		$test = Balance::bindBankcardConfirm(31,'88782b223a34b136e068380d4a7a67ce75209','544755');
     //		$test = Balance::setBalance('11',1);
     //		$test = Balance::confirmSet('201507244850494903618','434819');
     //		var_dump($test);
     //		短信验证 发送短信--验证手机
     //		$test = Port::ValidatePhone('15127281324');
     //		$test = Port::checkPhnoe('15127281324','775527');
     //		实名认证 身份证与姓名对应
     //		$test = member::authentication('52','王利亚','131102199007042019');
     //绑卡--》绑卡确认--(查询)》绑卡后支付--》支付确认--(查询)》订单查询---》提现操作
     //绑卡操作 输入信息---进行确认
     //      $test = yeepay::bindbankcard(12,'6217000140004808851','131102199007042019','王利亚','15127281324',1);
     //		$test = yeepay::bindBankcardConfirm('4b19627eba749b32d1ec46348ce347aa27322','068268');
     //		查询绑卡信息
     //		$test = yeepay::bankcardList('0276867a089e23c4201d0ddd7a62fa8b88403');
     //用户充值  充值金额--短信验证
     //      $test = yeepay::payment(11,1);
     //		$test = yeepay::confirmPayment('201507239952989849677','430672');
     //查询支付订单信息
     //		$test = yeepay::paymentQuery('201507225453102169489','411507233860836495');
     //$test = Balance::isBinding('11');
     //		用户提现
     //		$test = yeepay::withdraw(11,10);
     //订单查询
     //		$test = yeepay::payClearData('2015-07-01','2015-07-23');
     //		$test = Balance::bindbankcard('1','6217000140004808851','131102199007042019','王利亚','15127281324',1);
     //		$test = Balance::bindBankcardConfirm('1','3561ae0fc7db3bc677bb7672af27c46703124','105618');
     //		var_dump(Yii::$app->request->post());
     //app
     //是否实名验证
     //        $test = member::isAuthentic('1');
     //绑卡操作
     //        $test = Balance::bindbankcard(1,'6217000140004808851','15127281324',1);
     //        $test = Balance::bindBankcardConfirm(1,'61256eedde9796991433e599ba7b2cd046813','018850');
     //支付操作
     //        $test = Balance::setBalance(1,0.01);
     //        $test = Balance::confirmSet('201507319749100523334','109815');
     //获取绑卡信息
     //          $test = Balance::getBalance(1);
     //        $test = yeepay::withdraw(1,1);
     //        $test = Port::ValidatePhone('15127281324');
     //        var_dump($test);
     //        $test = User::getIdentity();
     //        var_dump($test);
     //        $test = \frontend\actions\member::phoneIsRegister('15127281324');
     //        $test = \frontend\actions\Port::ValidatePhone('15127281324');
     //        $test = member::register('8888811','123','123','1','1','1');
     //        var_dump($test);
     //         $test = Yii::$app->user->renewAuthStatus();
     //        $session = Yii::$app->getSession();
     //        $id = $session->getHasSessionId();
     //        $request = Yii::$app->getRequest();
     //        $test = member::phoneRegister('15127281324');
     //        $test = member::random();
     //        $test =VerifyCode::find()->where([
     //            'field' => '15127281324',
     //            'status' => -1
     //        ])->orderBy('b_time desc')->one();
     //        $test = \frontend\actions\member::getInvite('1');
     //        $test = \frontend\actions\member::authentication(24,'王利亚','131102199007042019');
     //          $test = member::phoneRegister('18518674993');
     //        $test = Port::ValidatePhone('15127281324');
     //        $test = Port::checkPhnoe('15127281324','079361');
     //        $test = member::register('18518674993','123456','123456','1','932513');
     //        $test = member::login('18518674993','123456');
     //        $test = member::logout(37);
     //        $test = member::isAuthentic(22);
     //        $test = \frontend\actions\Balance::bindbankcard2(27,'123456','11111');
     //        $test = \frontend\actions\Balance::setBalance2(27,100);
     //        $test = \frontend\actions\Balance::bindbankcard(22,'6217000140004808851','131102199007042019','王利亚','15127281324','1');
     //连连支付接口---参数uid,银行卡号,充值金额。---自动判定用户是否实名认证,非实名认证不能进行
     //          $test = lianlian::confirmation(24,'6217000140004808851','0.01');
     //        $test = lianlian::confirmation(25,'6227000140510442244','0.01');
     //        $test = \frontend\actions\member::getInvite('24');
     ////新浪支付
     //    $sina = new sina();
     //          $test = $sina->query_verify('HQW131102199007042019');
     //        $lili = new lianlianClass();
     //          $test = $sina->create_activate_member(time());
     //        $test = $sina->set_real_name('20150819100838','王','131102199007042000');
     //        $test = $sina->binding_verify();
     //        $test = $sina->unbinding_verify();
     //        $test = $sina->query_verify();
     //        $test = $lili->bankcardQuery('6217000140004808851');
     //        var_dump($test);
     //        $test = lianlian::getBankcard(1);
     //使用连连支付其他接口
     //        $ll = new lianlianClass();
     //订单查询接口 参数--商户订单号,订单时间,连连返回订单号
     //        $test = $ll->orderQuery('cc522b525ff348b9e58456c829e2e44a','20150808100430','2015080811466969');
     //银行卡查询接口
     //        $test = $ll->bankcardQuery('6226901805086869');
     // 用户在连连支付情况
     //        $test = $ll->userBankcard('d0bf2c2b6f14b7b1a10a5c3d797b4ba4');
     //        $test = $ll->bankcardunbind('3fef8327bc176698230248dbc1222579','2015080818510075');
     //        $test = \frontend\actions\member::getPhone('24');
     //实名-创建新浪会员
     //        $test = sinapay::authentication('88','王利亚','131102199007042019');
     //        $test = sinapay::bindingBankCard('96','6217000140004808851','15127281324');
     //        $test = sinapay::checktodaydeposit('101');
     //        $test = sinapay::bankCardInfo('6225880136674703');
     //        $test = sinapay::updatebank('44',100);
     //        $test = sinapay::bankCardAdvance('201508201001005397980','bdf307fc78ab438eb5991aa11c87809b','020346');
     //        $test = sinapay::queryBankCard('44');
     //        $test = sinapay::isBinding('44');
     //用户充值操作
     //        $test = sinapay::recharge('44',1000);
     //        $test = sinapay::getUserInfo('44');
     //        $test = sinapay::checkdeposit('44',49900);
     //        $test = sinapay::recharge('44','1');
     //        $test = sinapay::recharge('105','100');
     //        $test = sinapay::rechargeComfirm('201510125157981071041','5c8c0014fb344b13beaaf97f1dc73b6e','841149');
     //$test = $sina->query_hosting_deposit_order('1440052548HQW131102199007042019','201510054810154542450');
     //        $test = sinapay::bankCardInfo('6226901805086869');
     //        $test = $sina->query_verify('1440032322HQW131102199007042019');
     //        $test = $sina->query_balance('1440032322HQW131102199007042019');
     //查询网站用户金额
     //        $test = $sina->query_balance('20150831183009HQW610523198304110017'); //查询账户余额 44
     //        $test = $sina->query_balance('200004227922','MEMBER_ID',"BASIC"); //查询账户余额 44 938.09 -100
     //        $test = sinapay::querySinaBalance('74');//网站余额
     //          $test = sinapay::balanceFreeze('44','1','11');
     //        $test = $sina->query_balance('1440236114HQW131102199007042019'); //查询账户余额 27
     //        $test = $sina->query_balance('1440147796HQW131102199007042019'); //查询账户余额 38 190.09 +30
     //        $test = $sina->query_balance('1440144466HQW131102199007042019'); //查询账户余额 42 20
     //        $test = $sina->query_hosting_deposit('1440144466HQW131102199007042019','');
     //        $test = sinapay::rechargeComfirm('201508219810049981245','dc7a57ba64fa4a2985408bef17026c39','378446');
     //        $test = sinapay::invest('44','1','0.01');
     //        $test = sinapay::invest('44','10','10'); //用户投资
     //        $test = sinapay::invest('44','10','10'); //用户投资
     //        $test = sinapay::sitePeyee('38','100','201508221019949924038','1440032322HQW131102199007042019'); //网站收钱
     //        $test = sinapay::hostingRefund('1440052548HQW131102199007042019','201508249749555163125',100); //中间账户退款
     //        $test = $sina->query_hosting_refund_byorder('1440052548HQW131102199007042019','201508244848571033366');
     //          $test = sinapay::withdraw('44','19'); //用户提现 网站通过
     //          $test = sinapay::sianWithdraw('1440052548HQW131102199007042019','201508241011005040879');
     //        $test = sinapay::sinaRansom('1440052548HQW131102199007042019','201508231015152521185');
     //        $test = \frontend\actions\member::authentication('27','网名','131102199007042019');
     //        $test = $sina->query_hosting_withdraw_order('1440052548HQW131102199007042019','SAVING_POT','201508221025452508718');
     //        $test = $sina->create_hosting_withdraw('111111111111','1440052548HQW131102199007042019','SAVING_POT','10','31193');
     //        $test = sinapay::withdraw('44',1);
     //        $test = sinapay::sianWithdraw('1440052548HQW131102199007042019','201509075457555186256');
     //        $test = sinapay::hostingRefund('1440052548HQW131102199007042019','201508235753565114051',10,'123');
     //        $test = $sina->create_single_hosting_pay_trade(time(),'1440032322HQW131102199007042019','SAVING_POT','11','11111');
     //        $test = sinapay::query_hosting_withdraw_time('1440052548HQW131102199007042019',time()-72000000,time());
     $pay_uid = array('27' => '1', '42' => '2', '38' => '3');
     //        $test = sinapay::batchPay($pay_uid,'201508235753565114051');
     //        $test = sinapay::giveInterest('27','11'); //给利息
     //        $test = sinapay::collectSite(4000,array('44'=>'4000'));
     //        $test = sinapay::collectUser('44',1000);
     //        $test = sinapay::unbinding_bank_card('44');
     //        $test = sinapay::sinaRansom('27','11000','44');
     //        $test = sinapay::sianWithdrawOnly('44',1);
     //            $test = sinapay::getBankCard('44');
     //        $test = \frontend\actions\Port::sendSms2('15127281324','123456','3','4');
     //        $test = $sina->query_bank_card('1440817121HQW370105198910176257','32694');
     //        $test = sinapay::getUserInfo('44');
     //        $test = $sina->getConfig();
     //        $wei = new Weibopay();
     //        $test = $wei->getConfig();
     //        $test = sinapay::getConfig();
     //$test = \frontend\actions\Port::ValidatePhone('15127281324');
     //        $test = member::signIn('111','2');
     //        $test = member::get_yesterday_sign_in();
     //        $test = member::get_today_sign_in();
     //        $test = member::get_user_sign_in(1);
     //        $test = member::is_sign_today('21');
     //        $test = member::get_yesterday_user('1');
     //$test = $sina->create_activate_member(time());
     //        $test = Withdrawals::User_redeem('53','1000');
     //$test = Invest::invest('53','16','1100');
     //        $test = $sina->set_real_name('20150902161534HQW131102199007042019','伍文瀚','130603198803230318');
     //  $test = member::get_user_sign_in('1','4','2');
     //        $test = \frontend\actions\App\Invest::product_list(4,1);
     //        $test = member::phonpreg_matchster('18518674993');
     //        $test = member::set_invitation(5);
     //        $test = member::verify_code('57565356');
     //        $test = member::use_code('1');
     //        $test = member::register('18518674993','123456','123456','222222','3','48529853');
     //        $test = App::sessionkey_istimeout('f91f250602f33523296fa93d9ea086e447929--3');
     //        $test = sinapay::recharge('44',11.5);
     //        $test = member::get_invest_num('44');
     //        $test = sinapay::sianWithdrawOnly('44',1);
     //        $test = sinapay::getUserInfo('44');
     //        $test = member::set_invitation();
     //        $test = App\Invest::product_list('1','2');
     //        $test = sinapay::bankCardInfo('6226320130074914');
     //        $test = member::give_experience_gold('手机号注册','12');
     //        $test = \frontend\actions\Port::ValidatePhone('15127281324');
     //$test = \frontend\actions\Port::checkPhnoe('15127281324','095130');
     //        $test = sinapay::collectSite(4000,array('38'=>'4000'));
     //        $test = App\AloneMethod::invest_log('44','5','1');
     //        $test = sinapay::authentication('79','王利亚','131102199007042019');
     //        $test = sinapay::getUserInfo(44);
     //        $test = member::signIn('44','3');
     //        $test = sinapay::test('55','100');
     //        $test = sinapay::immediate_withdraw('44','200');
     //        $test = App\AloneMethod::reading_log('11','12');
     //        $test = App\AloneMethod::is_reading('12','12');
     //        $test = App\AloneMethod::is_msg(array('33','55','44','66'),'12');
     //        $test =  App\AloneMethod::ignore_all(array('33','55','44','66'),'12');
     //        $test = App\AloneMethod::is_exit_msg('44');
     //        $test = App\AloneMethod::user_msg_centor('44','1','4');
     //        $test = sinapay::sianWithdrawOnly('44','10');
     //        $test = sinapay::get_sina_balance_all('55');
     //        $test = sinapay::get_deal();
     //        $test = App\AloneMethod::experience_gold_log('44');
     //        $test = App\AloneMethod::cms_lunbo();
     //        $test = App\AloneMethod::encrypt('15127281324');
     //        $test = App\AloneMethod::decrypt('lmZhk5uVa2pna5Y=');
     //        $test = member::active_log('15127281324','22','18518674993',111,90,'中秋节');
     //        $test = member::get_invite_info('YW5lZ5lmnWaabWg=');
     //        $test = $sina->create_hosting_deposit();
     //        $test = sinapay::getUserInfo('44');
     //        $test = member::get_invite_info('22');
     //        $test = member::create_read_packet('15127281324',10);
     //        $test = member::update_red_packet('94','15127281324','18518674992','国庆节活动');
     //        $cookies = Yii::$app->response->cookies;
     //        $cookies->add(new \yii\web\Cookie([
     //            'name' => 'language',
     //            'value' => 'zh-CN',
     //        ]));
     //
     //        var_dump($cookies['language']->value);
     //      $test = member::get_red_packet('15127281324');
     //        $test = member::get_rad_list('44');
     //        $test = member::get_user_red_packet('44');
     //        $test = member::draw_red_packet('44',time());
     //        //活动期间利率调整TODO
     //        date_default_timezone_set('PRC');
     //        //活动开始时间
     //        $begin_time = strtotime('2015-9-24');
     //        $test = UcenterMember::find()->asArray()->all();
     //     获取所有用户信息
     //        echo '<hr/>';
     //        foreach($users as $key => $value){
     //            var_dump($value['id']);
     //        }
     //        if($users){
     //            foreach($users as $key=>$value){
     //                $flag = Gold::find()->where(['uid' => $value['id'],'rid' => '3','money' =>'8150'])->one();
     //                if(!$flag){
     //                    $rule = Rule::find()->where(['id' => '3', 'status' => Rule::STATUS_ACTIVE])->asArray()->one();
     //                    //判断规则是否生效
     //                    if ($rule['time']) {
     //                        $rul_money = $rule['money'];
     //                        $end_at = time() + $rule['time'] * 24 * 3600;
     //                        //增加体验金
     //                        $gold = new Gold();
     //                        $gold->uid = $value['id'];
     //                        $gold->rid = '3';
     //                        $gold->money = $rul_money;
     //                        $gold->end_at = $end_at;
     //                       echo  $gold = $gold->save();
     //                    }
     //                }
     //
     //            }
     //        }
     //        $test = App\AloneMethod::send_msg_all();
     //        $test = Port::ValidatePhone2('15127281324','1');
     //        $test = Port::checkPhnoe('15127281324','118812');
     //        $test = ArrayHelper::map()
     //        $test = Port::ValidatePhone2('15127281324','2','100');
     //        $prize_arr = array(
     //            '0' => array('id'=>1,'prize'=>'5','v'=>1),
     //            '1' => array('id'=>2,'prize'=>'4.5','v'=>5),
     //            '2' => array('id'=>3,'prize'=>'4','v'=>10),
     //            '3' => array('id'=>4,'prize'=>'3.5','v'=>20),
     //            '4' => array('id'=>5,'prize'=>'3','v'=>30),
     //            '5' => array('id'=>6,'prize'=>'2.5','v'=>40),
     //            '6' => array('id'=>7,'prize'=>'2','v'=>50),
     //            '7' => array('id'=>8,'prize'=>'1.5','v'=>60),
     //            '8' => array('id'=>9,'prize'=>'1','v'=>70),
     //            '9' => array('id'=>10,'prize'=>'0.5','v'=>100),
     //        );
     //        //读取奖项设定
     //        $prize = array();
     //        $test = HoldActivity::find()->where(['id' => 7])->asArray()->one();
     //        $radearray = explode('/',$test['red_money_rang']);
     //        if(count($radearray)){
     //            foreach($radearray as $key=>$value){
     //                $v1 = explode(',',$value);
     //                if(count($v1)){
     //                    $v2 = explode('-',$v1['0']);
     //                    $money = rand($v2['0']*100,$v2['1']*100)/100;
     //                    $prize[$key] = array('id' => $key+1,'prize' => $money,'v' => $v1['1']);
     //
     //                }
     //            }
     //        }
     //        $ridearray = explode(',',$test['rid_list']);
     //      echo in_array('3',$ridearray);
     //        $test = member::create_read_packet('15127281324',10,'11111');
     //        $test = App\Invest::goldtwo('94',10);
     //        $test = member::get_user_red_packet('94');
     ////
     //        $test = AloneMethod::get_continue_money('44',100,15);
     //        $test = AloneMethod::get_relation('96');
     //        $test = AloneMethod::produce_red_packet('96');
     //        $test = AloneMethod::send_red_packet('96');
     //        $test = AloneMethod::get_recommend_relation('96',1,4);
     //        $test = AloneMethod::produce_recommend('103');
     //        $test = member::draw_red_packet('100',time());
     //        $test = member::get_user_red_packet('100');
     //        $test = member::get_deposit_num('66');
     //        $test = member::give_experience_gold(4,10);
     //        $test = sinapay::immediate_withdraw(105,10);
     //        $test = member::phoneIsRegister(15127281324);
     //        $test = member::the_master_register('18518674990','w123456','344274','105');
     //        $test = App\AloneMethod::decrypt('15127281324');
     //        $test = sinapay::bankCardInfo('622600910075787620');
     //        $test = AloneMethod::produce_red_packet('106')
     //            $test = App\Withdrawals::Redeem('105',1);
     //        $test = member::get_rad_list('106');
     //        $test = sinapay::getUserInfo('106');
     //        $test = member::draw_red_packet('106', time());
     //        $test = 76.76;
     //        $cur = 60.76;
     //        $test = ($test * 100 - $cur*100)/100;
     //        var_dump($test);
     //        $cur = 16;
     //
     //        var_dump($test * 100 - $cur*100);
     //        $test = ($test * 100 - $cur*100)/100;
     //        var_dump($test);
     //        $test = Article::find()->where(['title' => '法律保障','status' => 1])->asArray()->one();
     //        $test = AloneMethod::get_recommend_relation('105');
     //        $test = App\Withdrawals::User_redeem('106',9.99);
     //        $test = AloneMethod::get_category_article('安全保障');
     //            $test = member::get_rad_list('106');
     ////短息接口
     //        $test = Port::ValidatePhone2('15127281324','1');//用户注册
     //        $test = Port::ValidatePhone2('18518674993','2',9999);//投资操作--慢
     //        $test = Port::ValidatePhone2('18518674993','3');//提现操作
     //        $test = Port::ValidatePhone2('18518674993','4');//重置密码
     //        $test = Port::ValidatePhone2('18518674993','5');//修改密码
     //        echo date('y-m-d:H-i-s');
     //        $test = AloneMethod::statistics();
     //        var_dump($test);
     //        $money_sina = sprintf("%.2f",99.0012);
     //        var_dump($money_sina);
     //        $virtual = new VirtualProduct();
     //        $virtual->money = 1;
     //        $virtual->name = '网';
     //        $virtual->pid = 1;
     //       return  $virtual->save();
     //        $testName = array(
     //            '伟','芳','娜','敏','静','秀英','丽','强','磊','洋','艳','勇','军','杰','娟','涛','超','明','霞','秀兰','刚','平','燕','辉',
     //            '玲','桂英','丹','萍','鹏','华','红','玉兰','飞','桂兰','英','梅','鑫','波','斌','莉','宇','浩','凯','秀珍','健','俊','帆',
     //            '雪','帅','慧','旭','宁','婷','玉梅','龙','林','玉珍','凤英','晶','欢','玉英','颖','红梅','佳','倩','阳','建华','亮','成',
     //            '琴','兰英','畅','建','云','洁','峰','建国','建军','柳','淑珍','春梅','海燕','晨','冬梅','秀荣','瑞','桂珍','莹','秀云','桂荣',
     //            '志强','秀梅','丽娟','婷婷','玉华','兵','雷','东','琳','雪梅','淑兰','丽丽','玉','秀芳','欣','淑英','桂芳','博','丽华','丹丹',
     //            '彬','桂香','坤','想','淑华','荣','秀华','桂芝','岩','杨','小红','金凤','文','利','楠','红霞','建平','瑜','桂花','璐','凤兰'
     //        );
     //        $testphone = array(
     //            134, 135, 136, 137, 138, 139, 147, 150, 151, 152, 157, 158, 159, 182, 187, 188, // china mobile
     //            130, 131, 132, 145, 155, 156, 185, 186, 145, // china unicom
     //            133 , 153 , 180 , 181 , 189, // chinatelecom
     //        );
     //        $chars = "0123456789";
     //        $str = '';
     //        for ($i = 0; $i < 4; $i++) {
     //            $str .= substr($chars, mt_rand(0, strlen($chars) - 1), 1);
     //        }
     //        $length = count($testphone);
     //        $key = mt_rand(0,$length-1);
     //        return $testphone[$key].'****'.$str;
     //        $length = count($testName);
     //        echo $length;
     //        $key = rand(0,$length-1);
     //        var_dump($testName[131]);
     //        var_dump('20150902164057HQW130733198702201538');
     //        $test = App\Invest::product_list('4','1');
     $test = member::the_promotion_register('15127281324', '12345t', '123456', '2');
     var_dump($test);
 }
Example #21
0
 public static function authentication($uid, $name, $cardno)
 {
     $iscard = self::idcardIsAuthentic($cardno);
     $is = self::isAuthentic($uid);
     if ($iscard || !$is['errorNum']) {
         $return = array('errorNum' => '1', 'errorMsg' => '已经存在实名认证信息', 'data' => null);
         return $return;
     } else {
         //调用验证接口
         //            $res = Port::authentication($uid,$name,$cardno);
         $res = sinapay::authentication($uid, $name, $cardno);
         if (!$res['errorNum']) {
             $member = UcenterMember::findOne($uid);
             $member->idcard = $cardno;
             $member->real_name = $name;
             $member->status = UcenterMember::STATUS_REAL;
             if ($member->save()) {
                 $return = array('errorNum' => '0', 'errorMsg' => 'success', 'data' => null);
                 return $return;
             } else {
                 $return = array('errorNum' => '1', 'errorMsg' => '实名信息存储失败', 'data' => null);
                 return $return;
             }
         } else {
             $errorMsg = $res['errorMsg'];
             $return = array('errorNum' => '1', 'errorMsg' => $errorMsg, 'data' => null);
             return $return;
         }
     }
 }