コード例 #1
0
ファイル: TgPremote.php プロジェクト: hucongyang/pink
 /**
  * 充值后,插入推广员的收入记录
  * @param type $tuid(推广用户)
  * @param type $income(充值金额)
  * @return null
  */
 public function insertTgIncome($tuid, $income)
 {
     if (!$tuid) {
         return null;
     }
     //根据推广用户返回推广员
     $tgy = $this->dbConnection->createCommand()->select('uid')->from($this->tableName())->where('tuid=:tuid', array(':tuid' => $tuid))->queryRow();
     if (!empty($tgy)) {
         //写入推广收入日志
         $this->dbConnection->createCommand()->insert('tg_log', array('uid' => $tgy['uid'], 'tuid' => $tuid, 'incoins' => $income, 'type' => 2, 'addtime' => time()));
         //更新推广员的收入
         $income = $income * Yii::app()->params['payfl'] * Yii::app()->params['coinratio'];
         $paysql = "update usercoins set TgCoins = TgCoins+" . $income . ", WinCoins = WinCoins+" . $income . " where UserId = '" . $tgy['uid'] . "'";
         $this->db->execute($paysql);
         //添加收入记录
         $coinhistory = new Coinshistory();
         $coinhistory->Uid = $tgy['uid'];
         $coinhistory->Coins = $income * Yii::app()->params['payfl'] * Yii::app()->params['coinratio'];
         $coinhistory->Type = 4;
         $coinhistory->CallId = 0;
         $coinhistory->datetime = time();
         $coinhistory->save();
         //更新对应推广关系的充值状态
         $sql = "update tg_premote set paid=1 where tuid ='" . $tuid . "'";
         return $this->db->execute($sql);
     }
 }
コード例 #2
0
ファイル: EpayController.php プロジェクト: hucongyang/pink
 /**
  * 充值callback处理
  */
 public function actionPayCallback()
 {
     $p2_Order = Yii::app()->request->getParam('p2_Order');
     $p5_CardNo = Yii::app()->request->getParam('p5_CardNo');
     $r1_Code = Yii::app()->request->getParam('r1_Code');
     $p8_cardStatus = Yii::app()->request->getParam('p8_cardStatus');
     $p3_Amt = Yii::app()->request->getParam('p3_Amt');
     $paymodel = PayOrder::model()->findByPk($p2_Order - 200000000000);
     $result = $paymodel->pay_result;
     if (!$paymodel) {
         exit;
     }
     if ($result == 0) {
         $epay = new Epay();
         if ($p3_Amt != $paymodel->total_fee) {
             $paymodel->remark = "回调金额与订单不符";
             $paymodel->pay_result = -2;
         } else {
             if ($r1_Code == 1) {
                 $paymodel->order_id = $p2_Order - 200000000000;
                 $paymodel->pay_result = 1;
             } else {
                 if ($p8_cardStatus == 1) {
                     $paymodel->pay_result = -1;
                 } else {
                     $paymodel->pay_result = $p8_cardStatus;
                 }
                 $paymodel->remark = $epay->getError($p8_cardStatus);
             }
         }
         $paymodel->total_fee = $p3_Amt;
         $paymodel->time_update = time();
         //获取对应用户的手机号
         $mobile = User::model()->getUserMobile($paymodel->uid);
         if ($paymodel->save()) {
             //易付通支付详情记录
             $epaymodel = $this->loadModel(array("p2_Order" => $p2_Order));
             if ($r1_Code == 1) {
                 $epaymodel->status = 1;
                 //更新用户账户金币
                 $income = $p3_Amt * Yii::app()->params['coinratio'];
                 $coins = PayOrder::model()->addCoins($paymodel->uid, $income);
                 //更新推广员的收入
                 TgPremote::model()->insertTgIncome($paymodel->uid, $p3_Amt);
                 //添加收入记录
                 $coinhistory = new Coinshistory();
                 $coinhistory->Uid = $paymodel->uid;
                 $coinhistory->Coins = $income;
                 $coinhistory->Type = 8;
                 $coinhistory->CallId = 0;
                 $coinhistory->datetime = time();
                 $coinhistory->save();
                 //短信通知用户充值结果
                 $this->sendSMS($mobile, "石榴裙温馨提醒:尊敬的" . $mobile . "用户,您好!您卡号为" . $p5_CardNo . "的充值卡充值成功!充值金额为" . $p3_Amt . "元。", 3);
             } else {
                 $epaymodel->status = 2;
                 $epaymodel->p8_cardStatus = $p8_cardStatus;
                 $epaymodel->error = $epay->getError($p8_cardStatus);
                 //短信通知用户充值结果
                 $this->sendSMS($mobile, "石榴裙温馨提醒:尊敬的" . $mobile . "用户,您好!您卡号为" . $p5_CardNo . "的充值卡充值失败,请重新充值。", 3);
             }
             $epaymodel->r1_Code = $r1_Code;
             $epaymodel->p7_realAmount = Yii::app()->request->getParam('p7_realAmount');
             $epaymodel->pb_BalanceAmt = Yii::app()->request->getParam('pb_BalanceAmt');
             $epaymodel->pc_BalanceAct = Yii::app()->request->getParam('pc_BalanceAct');
             if ($coins) {
                 echo "success";
             }
         } else {
             print_r($paymodel->errors);
         }
     }
 }
コード例 #3
0
ファイル: UserController.php プロジェクト: hucongyang/pink
 /**
  * 添加推广号
  */
 public function actionAddPremote()
 {
     if (!isset($_POST['uid']) || !$_POST['uid']) {
         $this->_exit($this->_error['20007'], '20007');
     }
     if (!isset($_POST['tuid']) || !$_POST['tuid']) {
         $this->_exit($this->_error['20063'], '20063');
     }
     $params = array();
     $params['tuid'] = intval($_POST['tuid']);
     $params['uid'] = trim($_POST['uid']);
     $tuid = $params['tuid'] - Yii::app()->params['tgbase'];
     $user = User::model()->findByPk($params['uid']);
     $params['regtime'] = $user['RegisterTime'];
     //判断推广号是否存在
     $u = User::model()->findByPk($tuid);
     if (!$u) {
         $this->_exit($this->_error['20064'], '20064');
     }
     //判断记录是否已存在
     $pro = TgPremote::model()->findOne($params['uid'], $tuid);
     if (!empty($pro)) {
         $this->_exit($this->_error['20065'], '20065');
     }
     if (TgPremote::model()->addPremote($params)) {
         //添加推广号的奖励(此处奖励新用户,推广员的奖励统一由推广员系统后台脚本发放)
         $incoins = Yii::app()->params['profl'] * Yii::app()->params['coinratio'];
         $usercoin = Usercoins::model()->findByPk($params['uid']);
         $usercoin->FreeCoins = $usercoin->FreeCoins + $incoins;
         $usercoin->save();
         //添加收入记录
         $inhistory = new Coinshistory();
         $inhistory->Uid = $params['uid'];
         $inhistory->Coins = Yii::model()->params['profl'];
         $inhistory->Type = 2;
         $inhistory->CallId = 0;
         $inhistory->datetime = time();
         $inhistory->save();
         $this->_exit($this->_error['20000'], '20000');
     } else {
         $this->_exit($this->_error['21000'], '21000');
     }
 }