コード例 #1
0
 /**
  * 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']);
 }
コード例 #2
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;
     }
     $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'));
 }
コード例 #3
0
 public function actionInfoview()
 {
     $uid = Yii::$app->user->id;
     $info = Info::find()->where(['member_id' => $uid])->one();
     //投资总额
     $invest_total = 0;
     $model_order = Order::find()->where(['member_id' => Yii::$app->user->id, 'status' => 1])->all();
     if (count($model_order) > 0) {
         foreach ($model_order as $K => $V) {
             $invest_total += $V->money;
         }
     }
     return $this->view('infoview', compact('info', 'invest_total'));
 }
コード例 #4
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;
         }
     }
 }
コード例 #5
0
ファイル: SignController.php プロジェクト: wuwenhan/huoqiwang
 public static function Ucenter()
 {
     $model = UcenterMember::find()->where(['id' => Yii::$app->user->id])->one();
     //个人账户
     $model_asset = Info::find()->where(['member_id' => Yii::$app->user->id])->one();
     $session = yii::$app->session;
     $session->open();
     if (isset($session['last_time'])) {
         $updated_at = $session['last_time'];
     } else {
         $updated_at = $model->updated_at;
     }
     $balance = $model_asset->balance;
     $username = yii::$app->user->identity->username;
     return compact('updated_at', 'balance', 'username');
 }
コード例 #6
0
ファイル: InfoSearch.php プロジェクト: wuwenhan/huoqiwang
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params, $order = 'member_id DESC')
 {
     $query = Info::find()->orderBy($order);
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 10]]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $ucmember = new UcenterMember();
     $ucmember = $ucmember->find()->andWhere(['username' => $this->member_id])->one();
     $uid = $ucmember ? $ucmember->id : '';
     $query->andFilterWhere(['member_id' => $uid, 'balance' => $this->balance, 'freeze' => $this->freeze, 'create_at' => $this->create_at, 'update_at' => $this->update_at]);
     $query->andFilterWhere(['like', 'bank_card', $this->bank_card])->andFilterWhere(['like', 'bank_card_phone', $this->bank_card_phone]);
     return $dataProvider;
 }
コード例 #7
0
ファイル: lianlian.php プロジェクト: wuwenhan/huoqiwang
 /**
  * 获取用户绑卡信息
  * @param $uid
  * @return bool
  */
 public static function getBankcard($uid)
 {
     $info = Info::findOne($uid);
     if ($info) {
         $bank_card = $info->bank_card;
         $bank_code = $info->bank_card_phone;
         if ($bank_card != "" && $bank_code != "") {
             $bank = array('01020000' => "工商银行", '01030000' => '农业银行', '01040000' => '中国银行', '01050000' => '建设银行', '03080000' => '招商银行', '03100000' => '浦发银行', '03030000' => '光大银行', '03070000' => '平安银行', '03040000' => '华夏银行', '03090000' => '兴业银行', '03020000' => '中信银行', '01000000' => '储蓄银行', '03050000' => '民生银行', '03060000' => '广发银行');
             $bank_name = $bank[$bank_code];
             $data['bank_card'] = $bank_card;
             $data['bank_name'] = $bank_name;
             return $data;
         } else {
             return false;
         }
     } else {
         return false;
     }
 }
コード例 #8
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'));
 }
コード例 #9
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'));
     }
 }
コード例 #10
0
ファイル: Balance.php プロジェクト: wuwenhan/huoqiwang
 /**
  * 测试数据---充值行为
  * @param $uid
  * @param $money
  * @return bool
  */
 public static function setBalance2($uid, $money)
 {
     $customer = Info::find()->where(['member_id' => $uid])->one();
     $money1 = $customer->balance;
     $customer->balance = $money + $money1;
     if ($customer->save()) {
         $log = self::logSave($uid, $money, "setBalabce", self::SUCCEED, '00000', "充值成功");
         return true;
     } else {
         $log = self::logSave($uid, $money, "setBalabce", self::ERROR, '00000', "充值失败");
         return false;
     }
 }
コード例 #11
0
ファイル: sinapay.php プロジェクト: wuwenhan/huoqiwang
 /**
  * 接收充值回调
  */
 public function notify_deposit($data)
 {
     $out_trade_no = $data['outer_trade_no'];
     if (!empty($out_trade_no)) {
         $trade = new SinaNotifyDeposit();
         $trade->outer_trade_no = $out_trade_no;
         $trade->inner_trade_no = $data['inner_trade_no'];
         $trade->deposit_amount = $data['deposit_amount'];
         $trade->deposit_status = $data['deposit_status'];
         $trade->pay_method = array_key_exists('pay_method', $data) ? $data['pay_method'] : '';
         $trade->save();
         $success = strtoupper($trade->deposit_status) == 'SUCCESS';
         // 处理新浪充值记录
         $sinaDeposit = SinaDeposit::find()->where(['out_trade_no' => $out_trade_no])->one();
         if ($success) {
             $sinaDeposit->status = SinaDeposit::STATUS_SUCCESS;
             $sinaDeposit->msg = "充值成功";
             //更新绑定银行卡金额操作 ---TODO
             $uid = $sinaDeposit->uid;
             $amount = $sinaDeposit->amount;
             self::updatebank($uid, $amount);
         } else {
             $sinaDeposit->status = SinaDeposit::STATUS_ERROR;
             $sinaDeposit->msg = "充值失败";
         }
         $sinaDeposit->save();
         // 处理账户余额
         $uid = $sinaDeposit->uid;
         $customer = Info::find()->where(['member_id' => $uid])->one();
         $freeze = $customer->freeze ? $customer->freeze : 0;
         $customer->freeze = $freeze - $trade->deposit_amount;
         if ($success) {
             $customer->balance += $trade->deposit_amount;
         }
         $customer->save();
         // 处理用户充值记录
         //获取银行卡号
         $bank_user = self::isBinding($uid);
         $bank_account_no = $uid;
         if (!$bank_user['errorNum']) {
             $bank_account_no = $bank_user['data']['bank_account_no'];
         }
         $depositLog = Log::find()->where(['member_id' => $uid, 'trade_no' => $out_trade_no])->one();
         while ($depositLog == null) {
             sleep(1);
             $depositLog = Log::find()->where(['member_id' => $uid, 'trade_no' => $out_trade_no])->one();
         }
         if ($success) {
             $depositLog->status = Log::STATUS_RECHAR_SUC;
             $depositLog->remark = "充值成功";
         } else {
             $depositLog->status = Log::STATUS_RECHAR_ERR;
             $depositLog->remark = "充值失败";
         }
         $depositLog->save();
     }
 }
コード例 #12
0
ファイル: SiteController.php プロジェクト: wuwenhan/huoqiwang
 public function actionExportuser()
 {
     $users = UcenterMember::find()->asArray()->all();
     $data = array();
     if ($users !== null) {
         foreach ($users as $key => $value) {
             $data[$key]['id'] = $value['id'];
             $data[$key]['phone'] = $value['phone'];
             $data[$key]['real_name'] = $value['real_name'];
             $data[$key]['created_at'] = date('Y-m-d :H-m-s', $value['created_at']);
             $data[$key]['create_area'] = $value['create_area'];
             $status = $value['status'];
             if ($status == UcenterMember::STATUS_ACTIVE) {
                 $data[$key]['status'] = '注册用户';
             } elseif ($status == UcenterMember::STATUS_REAL) {
                 $data[$key]['status'] = '实名用户';
             } elseif ($status == UcenterMember::STATUS_BIND) {
                 $data[$key]['status'] = '绑卡用户';
             }
             //账户信息
             $info = Info::find()->where(['member_id' => $value['id']])->one();
             //账户余额
             $data[$key]['balance'] = $info['balance'];
             //在投资金
             $data[$key]['invest'] = $info['invest'];
             //可用收益
             $data[$key]['profit'] = $info['profit'];
             //累计收益
             $data[$key]['total_revenue'] = $info['total_revenue'];
             //充值--投资--赎回--提现
             //首次充值
             $rechar_at = Log::find()->where(['member_id' => $value['id'], 'status' => Log::STATUS_RECHAR_SUC])->orderBy('id asc')->one();
             //充值总金额
             $rechar_sum = Log::find()->where(['member_id' => $value['id'], 'status' => Log::STATUS_RECHAR_SUC])->sum('step');
             //首次投资时间
             $invest_at = Log::find()->where(['member_id' => $value['id'], 'status' => Log::STATUS_INVEST_SUC])->orderBy('id asc')->one();
             //投资总额
             $invest_sum = Log::find()->where(['member_id' => $value['id'], 'status' => Log::STATUS_INVEST_SUC])->sum('step');
             //赎回总额
             $redem_sum = Log::find()->where(['member_id' => $value['id'], 'status' => Log::STATUS_REDEM_SUC])->sum('step');
             //提现总额
             $withdraw_sum = Log::find()->where(['member_id' => $value['id'], 'status' => Log::STATUS_WITHDRAW_SUC])->sum('step');
             //首次充值时间
             $data[$key]['rechar_at'] = $rechar_at ? date('Y-m-d :H-m-s', $rechar_at['create_at']) : 0;
             $data[$key]['rechar_sum'] = $rechar_sum;
             //首次投资时间
             $data[$key]['invest_at'] = $invest_at ? date('Y-m-d :H-m-s', $invest_at['create_at']) : 0;
             $data[$key]['invest_sum'] = $invest_sum;
             //赎回
             $data[$key]['redem_sum'] = $redem_sum;
             //提现
             $data[$key]['withdraw_sum'] = $withdraw_sum;
             //未领取红包奖励
             $red = member::get_user_red_packet($value['id']);
             $data[$key]['red_usable'] = $red['data']['red_sum'];
             //总的红包奖励
             $red1 = member::get_rad_list($value['id']);
             $data[$key]['red_sum'] = $red1['data']['sum'];
         }
         return Utils::exportExcel($data, array('用户id', '用户手机号', '用户真实姓名', '用户注册时间', '用户注册地区', '用户状态', '用户账户余额', '在投资金', '可用收益', '累计收益', '首次充值时间', '充值总金额', '首次投资时间', '投资总额', '赎回总额', '提现总额', '未领取红包', '红包奖励总额'), '数据分析' . date('Y-m-d-H-m-s'));
     }
 }
コード例 #13
0
ファイル: setting.php プロジェクト: wuwenhan/huoqiwang
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">
    <br>
コード例 #14
0
ファイル: AloneMethod.php プロジェクト: wuwenhan/huoqiwang
 /**
  * Auther:langxi
  * $member_id:用户id、$coupon_id:加息劵id
  * (仅)用户使用加息劵,使用时间,结束时间,能否使用加息劵判断。
  */
 public static function useRaise($member_id, $coupon_id)
 {
     if (!$member_id || !is_numeric($member_id) || !is_int($member_id) || !$coupon_id || !is_numeric($coupon_id) || !is_int($coupon_id)) {
         $result = array('errorNum' => '1', 'errorMsg' => '参数错误', 'data' => null);
         return $result;
     }
     $is_user = Info::find()->where(['member_id' => $member_id])->asArray()->one();
     if (!$is_user) {
         $result = array('errorNum' => '1', 'errorMsg' => '参数错误', 'data' => null);
         return $result;
     }
     $is_coupon = RaiseCard::find()->where(['id' => $coupon_id, 'member_id' => $member_id])->asArray()->one();
     if (!$is_coupon) {
         $result = array('errorNum' => '1', 'errorMsg' => '参数错误', 'data' => null);
         return $result;
     }
     //判断加息是否达到每日加息最大值,若达到则提示用户,加息劵不可使用
     $Raise = (new \yii\db\Query())->select(['sum(rate)'])->from(['activity_raise_card'])->where(['member_id' => $member_id, 'status' => 1])->createCommand();
     $TotalRaise = $Raise->queryAll();
     $max_raise = self::getRaise();
     if ($TotalRaise['0']['sum(rate)'] > $max_raise) {
         $result = array('errorNum' => '1', 'errorMsg' => '今日加息已达到最大值,请明日再用', 'data' => null);
         return $result;
     } else {
         $card = Card::find()->where(['id' => $coupon_id])->asArray()->one();
         $validity_time = $card['validity_time'];
         $Raise = RaiseCard::find()->where(['member_id' => $member_id, 'id' => $coupon_id])->asArray()->one();
         $raise_id = $Raise['id'];
         $Raise = RaiseCard::findOne($raise_id);
         $Raise->use_at = time();
         $Raise->use_end_time = time() + $validity_time * 3600 * 24;
         $Raise->status = '1';
         $Raise = $Raise->save();
         if (!$Raise) {
             $result = array('errorNum' => '1', 'errorMsg' => '加息劵使用失败', 'data' => null);
             return $result;
         } else {
             $result = array('errorNum' => '0', 'errorMsg' => 'success', 'data' => null);
             return $result;
         }
     }
 }
コード例 #15
0
ファイル: SiteController.php プロジェクト: wuwenhan/huoqiwang
 public function actionMember()
 {
     Utils::ensureOpenId();
     $openId = Yii::$app->request->get('open_id');
     if (($usermodel = UcenterMember::findOne(['openid' => $openId])) !== null) {
         Yii::$app->user->login($usermodel);
     } elseif (yii::$app->user->isGuest) {
         return $this->redirect(['site/signin']);
     }
     $uid = yii::$app->user->id;
     /* $datas = AloneMethod::user_collect(118);
        var_dump($datas);exit;*/
     $model = UcenterMember::find()->where(['id' => $uid])->one();
     //个人账户
     $income_yesterday = Income::find()->where(['member_id' => $uid, 'created_at' => strtotime(date('Y-m-d', time()))])->one()->smoney;
     //体验金收益
     $experience_income = Income::find()->where(['member_id' => $uid, 'created_at' => strtotime(date('Y-m-d', time()))])->one()->goldincome;
     //红包收益
     $railscard = Income::find()->where(['member_id' => $uid, 'created_at' => strtotime(date('Y-m-d', time()))])->one()->railscard;
     $model_asset = Info::find()->where(['member_id' => Yii::$app->user->id])->one();
     $balance = $model_asset->balance;
     //当前余额
     $income_total = $model_asset->total_revenue;
     //累计收益
     //投资总额
     $invest_total = 0;
     $model_order = Order::find()->where(['member_id' => Yii::$app->user->id, 'status' => 1])->all();
     if (count($model_order) > 0) {
         foreach ($model_order as $K => $V) {
             $invest_total += $V->money;
         }
     }
     // 体验金
     $experience_money = 0;
     $money = Gold::find()->where(['<', 'created_at', time()])->andWhere(['>', 'end_at', time()])->andWhere(['uid' => $uid, 'status' => Gold::STATUS_ACTIVE])->sum('money');
     if ($money) {
         $experience_money = sprintf("%.2f", $money);
     }
     return $this->view('member', compact("model", 'income_yesterday', 'balance', 'income_total', 'invest_total', 'experience_money', 'experience_income', 'railscard'));
 }
コード例 #16
0
ファイル: InfoController.php プロジェクト: wuwenhan/huoqiwang
 /**
  * Finds the Info model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Info the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Info::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
コード例 #17
0
ファイル: Invest.php プロジェクト: wuwenhan/huoqiwang
 /**
  *Auther:langxi
  *
  *检测用户状态 银行卡手机号 真实姓名身份证号  及是否被锁定
  * @param $member_id
  * @return bool
  * @throws ErrorException
  */
 private static function checkMember($member_id)
 {
     $member_id = (int) $member_id;
     if (!is_numeric($member_id)) {
         $result = '参数错误';
         return $result;
     }
     $card = Info::find()->where(['member_id' => $member_id])->asArray()->one();
     if (!$card) {
         $result = '此账户不存在';
         return $result;
     } else {
         if (empty($card['bank_card']) || empty($card['bank_card_phone'])) {
             $result = '银行卡或银行卡对应手机号不存在';
             return $result;
         }
     }
     $member = UcenterMember::find()->where(['id' => $member_id])->asArray()->one();
     if (!$member) {
         $result = '用户不存在';
         return $result;
     }
     $real_name = $member['real_name'];
     $idcard = $member['idcard'];
     if (empty($real_name) || empty($idcard)) {
         $result = '真实姓名或身份证号不存在';
         return $result;
     }
     $status = $member['lock'];
     if ($status != UcenterMember::TYPE_UNLOCK) {
         $result = '用户被锁定';
         return $result;
     }
     return false;
 }
コード例 #18
0
ファイル: main.php プロジェクト: wuwenhan/huoqiwang
<?php

use yii\helpers\Html;
use common\models\base\fund\Income;
use common\models\setting\Setting;
use common\models\base\asset\Info;
/* @var $this \yii\web\View */
/* @var $content string */
$directoryAsset = Yii::$app->assetManager->getPublishedUrl('@almasaeed/');
//收益数据包
if (!yii::$app->user->isGuest) {
    $income_array = Income::find()->where("created_at>=" . strtotime(date("Y-m-d")) . " AND member_id=" . yii::$app->user->id)->asArray()->one();
    $profit = Info::findOne(['member_id' => yii::$app->user->id])->profit;
    $income_total = Info::findOne(['member_id' => yii::$app->user->id])->total_revenue;
} else {
    $income_array = "";
    $profit = "";
    $income_total = "";
}
// footer数据表
try {
    $tel1 = Setting::findOne(['code' => 'phone'])->value;
    $tel2 = Setting::findOne(['code' => 'tell'])->value;
    $email = Setting::findOne(['code' => 'email'])->value;
    $work = Setting::findOne(['code' => 'work'])->value;
} catch (ErrorException $e) {
    $tel1 = "";
    $tel2 = "";
    $email = "";
    $work = "";
}
コード例 #19
0
ファイル: Withdrawals.php プロジェクト: wuwenhan/huoqiwang
 /**
  *Auther:langxi
  *
  *检测用户状态 银行卡手机号 真实姓名身份证号  及是否被锁定
  * @param $member_id
  * @return bool
  * @throws ErrorException
  */
 private static function checkMember($member_id)
 {
     if (!$member_id || !is_numeric($member_id) || !is_int($member_id)) {
         $result = array('errorNum' => '1', 'errorMsg' => '参数错误', 'data' => null);
         return $result;
     }
     $card = Info::find()->where(['member_id' => $member_id])->asArray()->one();
     if (!$card) {
         $result = array('errorNum' => '1', 'errorMsg' => '此账户不存在1', 'data' => null);
         return $result;
     } else {
         if (empty($card['bank_card']) || empty($card['bank_card_phone'])) {
             $result = array('errorNum' => '1', 'errorMsg' => '未绑定银行卡及银行卡关联手机号', 'data' => null);
             return $result;
         }
     }
     $member = UcenterMember::find()->where(['id' => $member_id])->asArray()->one();
     $real_name = $member['real_name'];
     $idcard = $member['idcard'];
     if (empty($real_name) || empty($idcard)) {
         $result = array('errorNum' => '1', 'errorMsg' => '未进行实名认证', 'data' => null);
         return $result;
     }
     $status = $member['lock'];
     if ($status != UcenterMember::TYPE_UNLOCK) {
         $result = array('errorNum' => '1', 'errorMsg' => '用户被锁定', 'data' => null);
         return $result;
     }
     return false;
 }
コード例 #20
0
 public static function Ucenter()
 {
     $model = UcenterMember::find()->where('id=' . Yii::$app->user->id)->one();
     //个人账户
     $model_asset = Info::find()->where('member_id=' . Yii::$app->user->id)->one();
     $updated_at = $model->updated_at;
     $balance = $model_asset->balance;
     $username = yii::$app->user->identity->username;
     return compact('updated_at', 'balance', 'username');
 }
コード例 #21
0
 /**
  * 用户退款
  * @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"));
     }
 }
コード例 #22
0
 private static function datas()
 {
     $uid = yii::$app->user->id;
     $model = UcenterMember::find()->where(['id' => Yii::$app->user->id])->one();
     //个人账户
     $model_asset = Info::find()->where(['member_id' => Yii::$app->user->id])->one();
     if (!isset($model_asset)) {
         //跳转至绑定银行卡
         echo "<script>alert('您还没有绑定银行卡');</script>";
         echo "<script>location.href='" . \yii\helpers\Url::to(['money/bindcard']) . "'</script>";
         exit;
     }
     //收益总额
     $income_total = $model_asset->total_revenue;
     //当前收益
     $income_current = $model_asset->profit;
     //昨日收益
     try {
         $income_yesterday = Income::find()->where(['member_id' => yii::$app->user->id, 'created_at' => strtotime(date('Y-m-d', time()))])->one()->smoney;
     } catch (ErrorException $e) {
         $income_yesterday = 0;
     }
     //  		 体验金
     $experience_money = 0;
     $money = Gold::find()->where(['<', 'created_at', time()])->andWhere(['>', 'end_at', time()])->andWhere(['uid' => $uid, 'status' => Gold::STATUS_ACTIVE])->sum('money');
     if ($money) {
         $experience_money = sprintf("%.2f", $money);
     }
     //投资总额
     $invest_total = 0;
     $model_order = Order::find()->where(['member_id' => Yii::$app->user->id, 'status' => 1])->all();
     if (count($model_order) > 0) {
         foreach ($model_order as $K => $V) {
             $invest_total += $V->money;
         }
     }
     //用户投资记录
     $query1 = (new Query())->select("A.step,A.create_at,B.title")->from("asset_log AS A")->where('A.member_id=' . Yii::$app->user->id . " AND A.action='Invest/invest' AND A.status=2 ")->join("left join", "fund_product AS B", "A.product_id=B.id")->orderBy("A.id DESC");
     $pages = new Pagination(['totalCount' => $query1->count(), 'pageSize' => '10']);
     $array_investlog = $query1->offset($pages->offset)->limit($pages->limit)->all();
     $pages_offset = $pages->offset;
     //用户交易记录
     $query2 = Log::find()->where(['member_id' => Yii::$app->user->id, 'status' => [1, 2, 3, 4]]);
     $pages_trade = new Pagination(['totalCount' => $query2->count(), 'pageSize' => '2']);
     $array_tradelog = $query2->offset($pages_trade->offset)->limit($pages_trade->limit)->orderBy("id DESC")->all();
     $pages_trade_offset = $pages_trade->offset;
     //当前投资记录
     $query3 = (new Query())->select("A.step,A.create_at,B.title")->from("asset_log AS A")->where('A.member_id=' . Yii::$app->user->id . " AND A.action='Invest/invest' AND A.status=2 ")->join("left join", "fund_product AS B", "A.product_id=B.id")->limit(4)->orderBy("A.id DESC")->createCommand();
     $invest_log = $query3->queryAll();
     //数据包变量
     $amount_total = $model_asset->balance + $invest_total + $income_current;
     $session = yii::$app->session;
     $session->open();
     if (isset($session['last_time'])) {
         $updated_at = $session['last_time'];
     } else {
         $updated_at = $model->updated_at;
     }
     $phone = $model->phone;
     $balance = $model_asset->balance;
     $freeze = $model_asset->freeze;
     return $infos_rar = compact("invest_total", "income_total", "amount_total", "updated_at", "phone", "balance", "freeze", "invest_log", "array_investlog", "array_tradelog", "pages", "pages_trade", "pages_offset", "pages_trade_offset", "income_current", "income_yesterday", "experience_money");
 }
コード例 #23
0
 public function actionIndex()
 {
     error_reporting(0);
     //取出后台设置最大红包
     $maxincome = Setting::getCode('maxincome');
     //取出后台设置的每人最大红白
     $maxpeople = Setting::getCode('maxpeople');
     //后台设置体验金利率
     $goldrate = Setting::getCode('goldrate');
     //设定时区
     date_default_timezone_set('PRC');
     //取出当前时间
     $btime = date('Y-m-d' . '00:00:00', time());
     //转换成“开始”的时间戳
     $btimestr = strtotime($btime);
     //
     //判定今日是否已经计算了收益---防止收益被多次计算
     $count = Income::find()->where(['>', 'created_at', $btimestr])->count();
     if ($count) {
         return '收益已经计算过了';
     }
     //查询昨天以前所有的投资订单,查询order表
     $order = Order::find()->select('member_id,sum(money) as smoney,product_id')->andWhere(['<', 'start_at', Utils::alldaytostr($btimestr)[1]])->andWhere(['status' => 1])->groupBy(['member_id', 'product_id'])->asArray()->all();
     $arrnew = array();
     //循环所有投资
     //        $test = 0;
     foreach ($order as $k => $v) {
         //查询订单下对应项目
         $product = Product::findOne($v['product_id']);
         //查询昨天的生成的利息
         $income = Income::find()->andWhere(['member_id' => $v['member_id']])->andWhere(['between', 'created_at', Utils::alldaytostr($btimestr)[0], Utils::alldaytostr($btimestr)[1]])->one();
         //查询增值卡昨天信息
         //            $railscard = RaiseCard::find()
         //                ->select('member_id,sum(rate) as srate')
         //                ->andWhere(['member_id'=>$v['member_id']])
         //                ->andWhere(['<', 'use_at',Utils::alldaytostr($btimestr)[1]])
         //                ->andWhere(['>', 'use_end_time',Utils::alldaytostr($btimestr)[1]])
         //                ->andWhere(['status'=>RaiseCard::STATUS_USE])
         //                ->groupBy(['member_id'])
         //                ->asArray()
         //                ->one();
         //昨日签到人数
         $count = SignIn::find()->joinWith(['info' => function ($query) {
             /** @var \yii\db\ActiveQuery $query */
             $query->andWhere(['>', 'asset_info.invest', '1000']);
         }])->andWhere(['between', 'sign_in.sign_in_time', Utils::alldaytostr($btimestr)[0], Utils::alldaytostr($btimestr)[1]])->asArray()->count();
         //每人赠送利息,如果每人分的利息大于设置的每人获得的最大利息,就用设置的每人利息,如果小于就用分的利息
         $everyincome = 0;
         if ($count) {
             $everyincome = $maxincome / $count > $maxpeople ? $maxpeople : $maxincome / $count;
         }
         //取出昨天这个人有没有签到
         $rails = SignIn::find()->andWhere(['uid' => $v['member_id']])->andWhere(['between', 'sign_in_time', Utils::alldaytostr($btimestr)[0], Utils::alldaytostr($btimestr)[1]])->asArray()->one();
         //判断订单是否有总金额
         $smoney = isset($v['smoney']) ? $v['smoney'] : 0;
         //查询该用户体验金
         //            $all = Gold::find()->select('experience_gold.id,experience_gold.rid,sum(experience_gold.money) as gmoney')->andWhere(['uid'=>$v['member_id']])->joinWith(['rule' => function ($query) {
         //                /** @var \yii\db\ActiveQuery $query */
         //                $query->andWhere(['experience_rule.status'=>Rule::STATUS_ACTIVE]);
         //            }])->asArray()->all();
         //
         //            //查询发放给该用户体验金昨天信息
         //            $sendgold = RaiseCard::find()
         //                ->select('member_id,sum(rate) as srate')
         //                ->andWhere(['member_id'=>$v['member_id']])
         //                ->andWhere(['<', 'validity_start_at',Utils::alldaytostr($btimestr)[1]])
         //                ->andWhere(['>', 'validity_out_at',Utils::alldaytostr($btimestr)[1]])
         //                ->andWhere(['status'=>RaiseCard::STATUS_USE])
         //                ->asArray()
         //                ->one();
         //查询该用户体验金-----TODO
         $all = Gold::find()->select('uid,sum(money) as smoney')->andWhere(['uid' => $v['member_id'], 'status' => Gold::STATUS_ACTIVE])->andWhere(['<', 'created_at', time()])->andWhere(['>', 'end_at', time()])->asArray()->one();
         //            $summoney = 0;
         //            foreach($all as $kmmy=>$vmmy){
         //                $newbetime = strtotime(date('Y-m-d'.' 00:00:00',time()));
         //                $endtime = $vmmy['created_at'] + 3600 * 24 * $vmmy['time'];
         //                if($vmmy['created_at']<$newbetime && $endtime>$newbetime){
         //                    $summoney +=$all[$kmmy]['money'];
         //                }
         //            }
         //            var_dump($summoney);
         //            var_dump($all);
         //查询发放给该用户体验金昨天信息
         //            $sendgold = RaiseCard::find()
         //                ->select('member_id,sum(rate) as srate')
         //                ->andWhere(['member_id'=>$v['member_id']])
         //                ->andWhere(['<', 'validity_start_at',Utils::alldaytostr($btimestr)[1]])
         //                ->andWhere(['>', 'validity_out_at',Utils::alldaytostr($btimestr)[1]])
         //                ->groupBy(['member_id'])
         //                ->asArray()
         //                ->one();
         //计算利率,增息卡的利率+项目的利率
         //            $railscardrate = isset($railscard)? $railscard['srate']+$product->rate/365:$product->rate/365;
         //TODO
         $railscardrate = isset($railscard) ? $railscard['srate'] + $product->rate : $product->rate;
         //活动期间利率调整TODO
         date_default_timezone_set('PRC');
         //活动开始时间
         $begin_time = strtotime('2015-10-1');
         //活动结束时间
         $end_time = strtotime('2015-10-7');
         //当前时间
         $now_time = time();
         if ($now_time > $begin_time && $now_time < $end_time) {
             $railscardrate = '0.101';
         }
         $railscardrate = '0.08';
         //组成新数组,用户的id
         $arrnew[$v['member_id']]['member_id'] = $v['member_id'];
         //用户昨日利息,因利息也会产生利息,所以昨日利息乘以利率
         // $arrnew[$v['member_id']]['smoney'] += isset($income)?($smoney+$income->smoney)*Utils::moneyFormat($railscardrate) :$smoney*Utils::moneyFormat($railscardrate);
         //投资总额---记录当前再投资金
         $arrnew[$v['member_id']]['money'] += $v['smoney'];
         //计算收益--TODO
         $arrnew[$v['member_id']]['smoney'] += ceil($smoney * $railscardrate * 100 / 365) / 100;
         //取不包含红包体验金收益
         $arrnew[$v['member_id']]['iincome'] += ceil($smoney * $railscardrate * 100 / 365) / 100;
         //用户的昨日之前的累计利息
         // isset($income)? $arrnew[$v['member_id']]['newmoney'] = $arrnew[$v['member_id']]['smoney']+$income->newmoney : $arrnew[$v['member_id']]['newmoney'] += $smoney*Utils::moneyFormat($railscardrate);
         // TODO
         isset($income) ? $arrnew[$v['member_id']]['newmoney'] = $arrnew[$v['member_id']]['smoney'] + $income->newmoney : ($arrnew[$v['member_id']]['newmoney'] += ceil($smoney * $railscardrate * 100 / 365) / 100);
         //签到获取的利息
         $arrnew[$v['member_id']]['railscard'] = $rails ? $everyincome : 0;
         //在投金额大于1元--计算体验金收益
         if ($smoney >= 1) {
             //计算该用户体验金获取的利息
             $arrnew[$v['member_id']]['goldincome'] = ceil($all['smoney'] * $railscardrate * 100 / 365) / 100;
         }
         //每人的利率
         $arrnew[$v['member_id']]['rate'] = $railscardrate;
     }
     foreach ($arrnew as $k => &$v) {
         //求出每个用户的昨日利率
         $v['rate'] = Utils::moneyFormat(($v['smoney'] + $v['railscard']) * 365 / $v['money']);
         //总利息加上签到获取的利息
         $v['newmoney'] = $v['railscard'] + $v['newmoney'] + $v['goldincome'];
         //利息加上签到获取的利息
         $v['smoney'] = $v['railscard'] + $v['smoney'] + $v['goldincome'];
         //利息计算时的投资---
         //            $v['money'] = $v['money']  + $v['goldincome'] + $v['railscard'];
         // -- 计算在投金额不应该增加利息产生的金额
         $v['money'] = $v['money'];
     }
     //循环数组
     foreach ($arrnew as $vs) {
         $_model = new Income();
         //查出用户表的余额
         $Info = Info::find()->where(['member_id' => $vs['member_id']])->one();
         if ($Info) {
             $Info->profit = $Info->profit + $vs['smoney'];
             $Info->total_revenue = $Info->total_revenue + $vs['smoney'];
             $Info->save();
         }
         //取出昨天这个人有没有签到
         $signin = SignIn::find()->andWhere(['uid' => $vs['member_id']])->andWhere(['between', 'sign_in_time', Utils::alldaytostr($btimestr)[0], Utils::alldaytostr($btimestr)[1]])->one();
         if ($signin && $vs['money'] >= 1000) {
             $signin->sign_in_money = $vs['railscard'];
             $signin->status = SignIn::STATUS_FINISH;
             $signin->save();
             $_model->railscard = $vs['railscard'];
         }
         $_model->member_id = $vs['member_id'];
         $_model->smoney = $vs['smoney'];
         $_model->money = $vs['money'];
         $_model->rate = $vs['rate'];
         $_model->newmoney = $vs['newmoney'];
         $_model->goldincome = $vs['goldincome'];
         $_model->iincome = $vs['iincome'];
         //生成每日利息表的数据
         $_model->save();
     }
     //推荐大师活动
     //获取所有用户信息
     $users = UcenterMember::find()->select(['id'])->asArray()->all();
     if ($users !== null) {
         //获取所有用户id值
         foreach ($users as $key => $value) {
             //循环用户信息--判定其推荐人中是否有符合奖励规则的人--有进行推荐表中状态更改
             AloneMethod::produce_red_packet($value['id']);
         }
     }
     //判定推荐表中用户是否符合拿取奖励规则
     if ($users !== null) {
         foreach ($users as $key => $value) {
             AloneMethod::send_red_packet($value['id']);
         }
     }
     echo "成功";
 }
コード例 #24
0
ファイル: lianlianClass.php プロジェクト: wuwenhan/huoqiwang
 public function returnNotify()
 {
     $llpayNotify = new LLpayNotify($this->llpay_config);
     $verify_result = $llpayNotify->verifyNotify();
     if ($verify_result) {
         //验证成功
         /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
         //请在这里加上商户的业务逻辑程序代
         //——请根据您的业务逻辑来编写程序(以下代码仅作参考)——
         //获取连连支付的通知返回参数,可参考技术文档中服务器异步通知参数列表
         $is_notify = true;
         $json = new JSON();
         $str = file_get_contents("php://input");
         $val = $json->decode($str);
         $oid_partner = trim($val->{'oid_partner'});
         $dt_order = trim($val->{'dt_order'});
         $no_order = trim($val->{'no_order'});
         $oid_paybill = trim($val->{'oid_paybill'});
         $money_order = trim($val->{'money_order'});
         $result_pay = trim($val->{'result_pay'});
         $settle_date = trim($val->{'settle_date'});
         $info_order = trim($val->{'info_order'});
         $pay_type = trim($val->{'pay_type'});
         $bank_code = trim($val->{'bank_code'});
         $sign_type = trim($val->{'sign_type'});
         $sign = trim($val->{'sign'});
         ///如果同步接受操作没有处理成功
         $pay = payLL::findOne(['no_order' => $no_order, 'status' => self::CONFIRM]);
         if ($pay) {
             if ($result_pay == 'SUCCESS') {
                 //验证支付金额
                 if ($pay->money_order == $money_order) {
                     //支付成功了--更新数据
                     $pay->status = self::SUCCESS;
                     $pay->remark = "success";
                     $pay->sign_type = $sign_type;
                     $pay->sign = $sign;
                     $pay->oid_paybill = $oid_paybill;
                     $pay->settle_date = $settle_date;
                     $pay->money_lianlian = $money_order;
                     $pay->pay_type = $pay_type;
                     $pay->bank_code = $bank_code;
                     $res = $pay->save();
                     if ($res) {
                         $card_no = $pay->card_no;
                         $uid = $pay->uid;
                         $info = Info::find()->where(['member_id' => $uid])->one();
                         $newmoney = $info->balance;
                         $info->balance = $newmoney + $money_order;
                         $info->bank_card = $card_no;
                         $info->bank_card_phone = $bank_code;
                         $info->save();
                     }
                 } else {
                     $pay->status = self::ERROR;
                     $pay->remark = "订单金额错误";
                     $pay->sign_type = $sign_type;
                     $pay->sign = $sign;
                     $pay->oid_paybill = $oid_paybill;
                     $pay->settle_date = $settle_date;
                     $pay->money_lianlian = $money_order;
                     $pay->pay_type = $pay_type;
                     $pay->bank_code = $bank_code;
                     $pay->save();
                 }
             }
         }
         file_put_contents("log.txt", "异步通知 验证成功\n", FILE_APPEND);
         die("{'ret_code':'0000','ret_msg':'交易成功'}");
         //请不要修改或删除
         /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     } else {
         file_put_contents("log.txt", "异步通知 验证失败\n", FILE_APPEND);
         //验证失败
         die("{'ret_code':'9999','ret_msg':'验签失败'}");
         //调试用,写文本函数记录程序运行情况是否正常
         //logResult("这里写入想要调试的代码变量值,或其他运行的结果记录");
     }
 }
コード例 #25
0
ファイル: UcenterMember.php プロジェクト: wuwenhan/huoqiwang
 /**
  * 联合查询
  * @return \yii\db\ActiveQuery
  */
 public function getInfo()
 {
     return $this->hasOne(Info::className(), ['member_id' => 'id']);
 }
コード例 #26
0
ファイル: Balance.php プロジェクト: wuwenhan/huoqiwang
 /**
  * 用户短信确认充值
  * @param $orderid 充值订单号
  * @param $validatecode 短信验证码
  * @return string
  * @throws ErrorException
  */
 public static function confirmSet($orderid, $validatecode)
 {
     $orderid = (string) $orderid;
     $validatecode = (string) $validatecode;
     $yeepay = yeepay::confirmPayment($orderid, $validatecode);
     //易宝接口完成充值行为
     if (!$yeepay['errorNum']) {
         $yeepay = $yeepay['data'];
         $uid = $yeepay['uid'];
         $money = (double) ($yeepay['money'] / 100);
         $customer = Info::find()->where(['member_id' => $uid])->one();
         //写入网站的账户信息
         if ($customer) {
             $balance = $customer->balance;
             $customer->balance = $money + $balance;
             $flag = $customer->save();
             if ($flag) {
                 $log = self::logSave($uid, $money, "setBalabce", self::SUCCEED, $yeepay['orderid'], "充值成功");
                 if ($log) {
                     $return = array('errorNum' => '0', 'errorMsg' => 'success', 'data' => null);
                     return $return;
                 } else {
                     $return = array('errorNum' => '1', 'errorMsg' => '充值记录错误', 'data' => null);
                     return $return;
                 }
             } else {
                 self::logSave($uid, $money, "setBalabce", self::ERROR, $yeepay['orderid'], "更新账户数据失败");
                 $return = array('errorNum' => '1', 'errorMsg' => '更新账户数据失败', 'data' => null);
                 return $return;
             }
         } else {
             $customer = new Info();
             $customer->member_id = $uid;
             $customer->balance = $money;
             $flag = $customer->save();
             if ($flag) {
                 $log = self::logSave($uid, $money, "setBalabce", self::SUCCEED, $yeepay['orderid'], "充值成功");
                 if ($log) {
                     $return = array('errorNum' => '0', 'errorMsg' => 'success', 'data' => null);
                     return $return;
                 } else {
                     $return = array('errorNum' => '1', 'errorMsg' => '充值记录错误', 'data' => null);
                     return $return;
                 }
             } else {
                 self::logSave($uid, $money, "setBalabce", self::ERROR, $yeepay['orderid'], "更新账户数据失败");
                 $return = array('errorNum' => '1', 'errorMsg' => '更新账户数据失败', 'data' => null);
                 return $return;
             }
         }
     } else {
         $return = array('errorNum' => '1', 'errorMsg' => '短息确认失败', 'data' => null);
         return $return;
     }
 }
コード例 #27
0
ファイル: member.php プロジェクト: wuwenhan/huoqiwang
 /**
  *以后做推广活动进行的注册操作
  * @param $phone 手机号
  * @param $pwd  密码
  * @param $phone_code 手机验证码
  * @param $from 用户来源
  * @param string  $userIp 注册ip
  * @param string  $from  注册来源
  * @return array
  */
 public static function the_promotion_register($phone, $pwd, $phone_code, $from)
 {
     //注册来源
     $from = $from;
     //判定手机号是否注册
     $flag = self::phoneIsRegister($phone);
     if ($flag) {
         $return = array('errorNum' => '1', 'errorMsg' => '此手机号已注册,请直接登录', 'data' => null);
         return $return;
     } elseif (!preg_match('/^(?![0-9]+$)(?![a-z]+$)(?![A-Z]+$)[0-9a-zA-Z]{6,16}$/', $pwd)) {
         $return = array('errorNum' => '1', 'errorMsg' => '密码应该是数字、字母组成的6到16位字符', 'data' => null);
         return $return;
     }
     //手机短息验证码验证
     $check = Port::checkPhnoe($phone, $phone_code);
     $session_key = "";
     //生成app的密码
     $app_pwd = md5(sha1($pwd) . time());
     // 根据ip获取地区---Yii::$app->request->userIp
     $userIp = Yii::$app->request->userIp;
     $area = self::get_area($userIp);
     $area = $area ? $area : '地球';
     if (!$check['errorNum']) {
         //事物回滚
         $transaction = \Yii::$app->db->beginTransaction();
         try {
             $user = new UcenterMember();
             $user->username = $phone;
             $user->phone = $phone;
             $user->setPassword(trim($pwd));
             $user->create_ip = $userIp;
             $user->create_area = $area;
             $user->create_channel = (int) $from;
             $user->status = UcenterMember::STATUS_ACTIVE;
             $user->lock = UcenterMember::TYPE_UNLOCK;
             //app密码设定
             $user->app_pwd = $app_pwd;
             ///
             $user->generateAuthKey();
             if ($user->save()) {
                 //生成邀请码
                 $new_uid = $user->id;
                 $invitation_code = 'v' . $new_uid * 99;
                 $user->invitation_code = $invitation_code;
                 $user->save();
                 //初始换用户账户
                 $asset_info = new Info();
                 $asset_info->member_id = $user['id'];
                 $asset_info->balance = 0;
                 $asset_info->freeze = 0;
                 if ($asset_info->save()) {
                     $uid = $user['id'];
                     //注册动作完成---进行登录操作
                     $log = new Log();
                     $log->member_id = $uid;
                     $log->login_ip = Yii::$app->request->userIp;
                     $log->login_time = time();
                     $log->login_area = $area;
                     $log->status = self::LOG_CONFIM;
                     $res = $log->save();
                     if ($res) {
                         $session_key = self::verification($uid) . '--' . $from;
                         $session = new Sessionkey();
                         $session->uid = $uid;
                         $session->sessionkey = $session_key;
                         $session->status = self::STATUS_ACTIVE;
                         $res = $session->save();
                         if ($res) {
                             $log->status = self::LOG_SUSSESS;
                             $log->save();
                             //新用户注册送体验金---6666
                             self::give_experience_gold(1, $user['id']);
                         } else {
                             $return = array('errorNum' => '1', 'errorMsg' => '登陆失败', 'data' => null);
                             return $return;
                         }
                     } else {
                         $return = array('errorNum' => '1', 'errorMsg' => '登陆记录失败', 'data' => null);
                         return $return;
                     }
                 } else {
                     $return = array('errorNum' => '1', 'errorMsg' => '账户初始化失败', 'data' => null);
                     return $return;
                 }
             } else {
                 $return = array('errorNum' => '1', 'errorMsg' => '注册失败', 'data' => null);
                 return $return;
             }
             $transaction->commit();
             //事务成功提交后返回数据
             $data = array('sessionkey' => $session_key, 'balance' => 0, 'phone' => $phone, 'app_pwd' => $app_pwd);
             $return = array('errorNum' => '0', 'errorMsg' => 'success', 'data' => $data);
             return $return;
         } catch (\Exception $e) {
             $transaction->rollBack();
             $remark = $e->getMessage();
             $result = array('errorNum' => '1', 'errorMsg' => $remark, 'data' => null);
             return $result;
         }
     } else {
         $return = array('errorNum' => '1', 'errorMsg' => $check['errorMsg'], 'data' => null);
         return $return;
     }
 }