Exemplo n.º 1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = SinaDeposit::find()->orderBy('id DESC');
     $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;
     }
     $query->andFilterWhere(['id' => $this->id, 'uid' => $this->uid, 'status' => $this->status, 'create_at' => $this->create_at, 'update_at' => $this->update_at]);
     $query->andFilterWhere(['like', 'identity_id', $this->identity_id])->andFilterWhere(['like', 'out_trade_no', $this->out_trade_no])->andFilterWhere(['like', 'account_type', $this->account_type])->andFilterWhere(['like', 'amount', $this->amount])->andFilterWhere(['like', 'payer_ip', $this->payer_ip])->andFilterWhere(['like', 'pay_method', $this->pay_method])->andFilterWhere(['like', 'ticket', $this->ticket])->andFilterWhere(['like', 'validate_code', $this->validate_code])->andFilterWhere(['like', 'msg', $this->msg]);
     return $dataProvider;
 }
Exemplo n.º 2
0
 /**
  * Finds the SinaDeposit model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return SinaDeposit the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = SinaDeposit::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Exemplo n.º 3
0
 /**
  * 用户充值短信确认
  * @return array|mixed|string
  */
 public function actionRechargeconfirm()
 {
     $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('out_trade_no', $data) && array_key_exists('ticket', $data) && array_key_exists('validate_code', $data)) {
                 $out_trade_no = $data['out_trade_no'];
                 $ticket = $data['ticket'];
                 $validate_code = $data['validate_code'];
                 $result = sinapay::rechargeComfirm($out_trade_no, $ticket, $validate_code);
                 if ($result['errorNum'] == '0') {
                     $cinfirm = SinaDeposit::find()->where(['out_trade_no' => $out_trade_no, 'ticket' => $ticket])->one();
                     $uid = $cinfirm->uid;
                     $result = (new sinapay())->findDepositResult($out_trade_no, $uid);
                     $count = 30;
                     while ($result['errorNum'] == '2' && $count--) {
                         sleep(1);
                         $result = (new sinapay())->findDepositResult($out_trade_no, $uid);
                     }
                 }
             } else {
                 $result = array('errorNum' => '1', 'errorMsg' => '参数错误', 'data' => null);
             }
         }
     } catch (ErrorException $e) {
         Yii::error("用户充值短信确认---异常 方法:actionRechargeconfirm 参数:" . json_encode($result['data']), "app");
         Yii::trace($e->getMessage(), "app");
         $result = array('errorNum' => '7', 'errorMsg' => '服务器异常,请联系管理员', 'data' => null);
     }
     $result = App::AppReturn($result);
     return $result;
 }
Exemplo n.º 4
0
 public function actionAjaxdata()
 {
     $betime = strtotime(date('Y-m-d' . ' 00:00:00', time()));
     $endtime = strtotime(date('Y-m-d' . ' 23:59:59', time()));
     $now = strftime('%Y-%m-%d', time());
     list($wstart, $wend) = Utils::lastNWeek(time(), 1);
     list($mstart, $mend) = Utils::lastMonth(time());
     list($qstart, $qend) = Utils::lastQuarter(time());
     $beginThismonth = mktime(0, 0, 0, date('m'), 1, date('Y'));
     $endThismonth = mktime(23, 59, 59, date('m'), date('t'), date('Y'));
     $today = [];
     $week = [];
     $month = [];
     $quart = [];
     $payment = SinaDeposit::find()->select('sum(amount) as smoney')->andWhere(['status' => SinaDeposit::STATUS_SUCCESS])->andWhere(['between', 'create_at', $betime, $endtime])->asArray()->one();
     $withdraw = SinaWithdraw::find()->select('sum(money) as smoney')->andWhere(['status' => SinaWithdraw::STATUS_SINA_SUCCESS])->andWhere(['between', 'create_at', $betime, $endtime])->asArray()->one();
     $wpayment = SinaDeposit::find()->select('sum(amount) as smoney')->andWhere(['status' => SinaDeposit::STATUS_SUCCESS])->andWhere(['between', 'create_at', strtotime($wstart), strtotime($wend)])->asArray()->one();
     $wwithdraw = SinaWithdraw::find()->select('sum(money) as smoney')->andWhere(['status' => SinaWithdraw::STATUS_SINA_SUCCESS])->andWhere(['between', 'create_at', strtotime($wstart), strtotime($wend)])->asArray()->one();
     $mpayment = SinaDeposit::find()->select('sum(amount) as smoney')->andWhere(['status' => SinaDeposit::STATUS_SUCCESS])->andWhere(['between', 'create_at', strtotime($mstart), strtotime($mend)])->asArray()->one();
     $mwithdraw = SinaWithdraw::find()->select('sum(money) as smoney')->andWhere(['status' => SinaWithdraw::STATUS_SINA_SUCCESS])->andWhere(['between', 'create_at', strtotime($mstart), strtotime($mend)])->asArray()->one();
     $qpayment = SinaDeposit::find()->select('sum(amount) as smoney')->andWhere(['status' => SinaDeposit::STATUS_SUCCESS])->andWhere(['between', 'create_at', strtotime($qstart), strtotime($qend)])->asArray()->one();
     $qwithdraw = SinaWithdraw::find()->select('sum(money) as smoney')->andWhere(['status' => SinaWithdraw::STATUS_SINA_SUCCESS])->andWhere(['between', 'create_at', strtotime($qstart), strtotime($qend)])->asArray()->one();
     $benpayment = SinaDeposit::find()->select('sum(amount) as smoney')->andWhere(['status' => SinaDeposit::STATUS_SUCCESS])->andWhere(['between', 'create_at', $beginThismonth, $endThismonth])->asArray()->one();
     $benwithdraw = SinaWithdraw::find()->select('sum(money) as smoney')->andWhere(['status' => SinaWithdraw::STATUS_SINA_SUCCESS])->andWhere(['between', 'create_at', $beginThismonth, $endThismonth])->asArray()->one();
     $oldpayment = SinaDeposit::find()->select('sum(amount) as smoney')->andWhere(['status' => SinaDeposit::STATUS_SUCCESS])->asArray()->one();
     $oldwithdraw = SinaWithdraw::find()->select('sum(money) as smoney')->andWhere(['status' => SinaWithdraw::STATUS_SINA_SUCCESS])->asArray()->one();
     $today = '今日提现' . ($withdraw['smoney'] ? $withdraw['smoney'] : '0') . '充值' . ($payment['smoney'] ? $payment['smoney'] : "0");
     $week = '上周提现' . ($wwithdraw['smoney'] ? $wwithdraw['smoney'] : '0') . '充值' . ($wpayment['smoney'] ? $wpayment['smoney'] : '0');
     $benmonth = '本月提现' . ($benwithdraw['smoney'] ? $benwithdraw['smoney'] : '0') . '充值' . ($benpayment['smoney'] ? $benpayment['smoney'] : "0");
     $month = '上月提现' . ($mwithdraw['smoney'] ? $mwithdraw['smoney'] : '0') . '充值' . ($mpayment['smoney'] ? $mpayment['smoney'] : "0");
     $quart = '上个季度提现' . ($qwithdraw['smoney'] ? $qwithdraw['smoney'] : '0') . '充值' . ($qpayment['smoney'] ? $qpayment['smoney'] : '0');
     $oldtotal = '总提现' . ($oldwithdraw['smoney'] ? $oldwithdraw['smoney'] : '0') . '充值' . ($oldpayment['smoney'] ? $oldpayment['smoney'] : '0');
     echo $today . ',' . $week . ',' . $benmonth . ',' . $month . ',' . $quart . ',' . $oldtotal;
 }
Exemplo n.º 5
0
 /**
  * 接收充值回调
  */
 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();
     }
 }
Exemplo n.º 6
0
<?php

use yii\helpers\Html;
use yii\grid\GridView;
/* @var $this yii\web\View */
/* @var $searchModel common\models\sinapay\SinaDepositSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Yii::t('app', '新浪充值记录');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="sina-deposit-index">



    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'uid', 'identity_id', 'out_trade_no', 'account_type', 'amount', 'payer_ip', ['attribute' => 'status', 'format' => 'html', 'value' => function ($model) {
    if ($model->status === 2) {
        $class = 'label-success';
    } elseif ($model->status === 1) {
        $class = 'label-warning';
    } else {
        $class = 'label-danger';
    }
    return '<span class="label ' . $class . '">' . $model->statusLabel . '</span>';
}, 'filter' => Html::activeDropDownList($searchModel, 'status', \common\models\sinapay\SinaDeposit::labels(), ['class' => 'form-control', 'prompt' => '请筛选'])], 'msg', ['attribute' => 'create_at', 'format' => ['date', 'php:Y-m-d H:i:s'], 'headerOptions' => ['width' => '100']]]]);
?>

</div>