public function search($params) { //$query = MSceneDetail::find()->where('scene_amt<0'); $query = MSceneDetail::find(); $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['id' => SORT_DESC]], 'pagination' => ['pageSize' => 20]]); $this->addCondition($query, 'gh_id'); $this->addCondition($query, 'scene_id'); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $this->addCondition($query, 'scene_amt'); $this->addCondition($query, 'memo', true); if (trim($this->create_time) !== '') { $query->andWhere('date(create_time)>=:create_time', [':create_time' => $this->create_time]); } if (trim($this->create_time_2) !== '') { $query->andWhere('date(create_time)<=:create_time_2', [':create_time_2' => $this->create_time_2]); } $this->addCondition($query, 'status'); return $dataProvider; }
public function actionMemberupdate($id) { $model = MSceneDetail::findOne($id); if (!$model) { throw new NotFoundHttpException('no this gh'); } if (\Yii::$app->request->isPost) { $model->load(\Yii::$app->request->post()); if ($model->save()) { if ($model->status == MSceneDetail::STATUS_TIXIAN_OK) { $msg = "充值成功"; } else { $msg = "充值失败"; } if (!$model->user->sendWxm($msg)) { U::W("wx send failed"); } return $this->redirect(['memberlist']); } else { U::W($model->getErrors()); } } return $this->render('memberupdate', ['model' => $model]); }
public static function confirmSceneDetail() { $tableName = MSceneDetail::tableName(); $query = (new Query())->from($tableName)->where("status=:status AND scene_amt>0", [':status' => MSceneDetail::STATUS_INIT]); $amt = 0; foreach ($query->each() as $row) { if ($row['cat'] == MSceneDetail::CAT_FAN) { if (empty($row['openid_fan'])) { continue; } $fan = MUser::findOne(['gh_id' => $row['gh_id'], 'openid' => $row['openid_fan']]); if ($fan === null) { continue; } if ($fan->isActivedFan()) { U::W('ACTIVE id=' . $row['id']); $model = MSceneDetail::findOne($row['id']); $model->status = MSceneDetail::STATUS_CONFIRMED; if ($model->save(false)) { $user = MUser::findOne(['gh_id' => $row['gh_id'], 'openid' => $row['openid']]); U::W("SAVE BALANCE1 " . $user->scene_balance); $user->scene_balance += $model->scene_amt; U::W("SAVE BALANCE2 " . $user->scene_balance); $user->scene_balance_time = date("Y-m-d H:i:s"); $user->save(false); } } else { U::W('NO ACTIVE id=' . $row['id']); } } else { if ($row['cat'] == MSceneDetail::CAT_SIGN) { U::W('ACTIVE id=' . $row['id']); $model = MSceneDetail::findOne($row['id']); $model->status = MSceneDetail::STATUS_CONFIRMED; if ($model->save(false)) { $user = MUser::findOne(['gh_id' => $row['gh_id'], 'openid' => $row['openid']]); U::W("SAVE CAT_SIGN BALANCE1 " . $user->scene_balance); $user->scene_balance += $model->scene_amt; U::W("SAVE CAT_SIGN BALANCE2 " . $user->scene_balance); $user->scene_balance_time = date("Y-m-d H:i:s"); $user->save(false); } } } } }
use app\models\MSceneDetail; use app\models\MUser; /** * @var yii\web\View $this * @var yii\data\ActiveDataProvider $dataProvider * @var app\models\MUserSearch $searchModel */ $this->title = '会员管理'; $this->params['breadcrumbs'][] = $this->title; ?> <div class="muser-index"> <h1><?php //echo Html::encode($this->title) ?> </h1> <?php //echo $this->render('_search', ['model' => $searchModel]); ?> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'options' => ['class' => 'table-responsive'], 'tableOptions' => ['class' => 'table table-striped'], 'columns' => [['label' => 'ID', 'attribute' => 'id'], ['label' => '时间', 'attribute' => 'create_time'], ['label' => '提现沃点', 'attribute' => 'scene_amt'], ['label' => '充值手机号', 'attribute' => 'czhm'], ['label' => '类型', 'attribute' => 'memo'], ['label' => '提现状态审核', 'attribute' => 'status', 'value' => function ($model, $key, $index, $column) { return MSceneDetail::getSceneDetailStatusName($model->status); }, 'filter' => MSceneDetail::getSceneDetailStatusOption()], ['class' => 'yii\\grid\\ActionColumn', 'template' => '{memberupdate}', 'buttons' => ['memberupdate' => function ($url, $model) { return Html::a('<span class="glyphicon glyphicon-pencil"></span>', $url, ['title' => Yii::t('yii', 'Update'), 'data-pjax' => '0']); }]]]]); ?> </div>
public function actionTjyl() { $this->layout = 'wapy'; $gh_id = U::getSessionParam('gh_id'); $openid = U::getSessionParam('openid'); $model = MUser::findOne(['gh_id' => $gh_id, 'openid' => $openid]); if (empty($model->openidBindMobiles)) { Yii::$app->getSession()->set('RETURN_URL', Url::to()); return $this->redirect(['addbindmobile', 'gh_id' => $gh_id, 'openid' => $openid]); } $scenes = MSceneDetail::find()->where('gh_id=:gh_id AND scene_id=:scene_id AND scene_amt<0 ORDER BY create_time DESC', [':gh_id' => $gh_id, ':scene_id' => $model->scene_id])->all(); //可提现沃点 $ktxwd_scenes = MSceneDetail::find()->where('gh_id=:gh_id AND scene_id=:scene_id AND scene_amt>0 AND status=1 ORDER BY create_time DESC', [':gh_id' => $gh_id, ':scene_id' => $model->scene_id])->all(); //预期沃点 $yqwd_scenes = MSceneDetail::find()->where('gh_id=:gh_id AND scene_id=:scene_id AND scene_amt>0 AND status=0', [':gh_id' => $gh_id, ':scene_id' => $model->scene_id])->all(); //预期沃点 包含粉丝取消关注 $yqwd_fans_qx_scenes = MSceneDetail::find()->where('gh_id=:gh_id AND scene_id=:scene_id AND scene_amt>0 AND status<>1 ORDER BY create_time DESC', [':gh_id' => $gh_id, ':scene_id' => $model->scene_id])->all(); U::W(count($yqwd_fans_qx_scenes)); return $this->render('tjyl', ['gh_id' => $gh_id, 'openid' => $openid, 'user' => $model, 'scenes' => $scenes, 'ktxwd_scenes' => $ktxwd_scenes, 'yqwd_scenes' => $yqwd_scenes, 'yqwd_fans_qx_scenes' => $yqwd_fans_qx_scenes]); }
public function actionAjaxdata($cat) { //if (!Yii::$app->request->isAjax) // return; $this->layout = false; switch ($cat) { case 'orderclose': $oid = isset($_GET["oid"]) ? $_GET["oid"] : 1; $model = MOrder::findOne($oid); if ($model === null) { U::D(["invalid oid:{$oid}", __METHOD__]); } $model->status = MOrder::STATUS_BUYER_CLOSED; if ($model->save(true, ['status'])) { $mobnum = MMobnum::findOne($model->select_mobnum); if ($mobnum !== null) { $mobnum->status = MMobnum::STATUS_UNUSED; $mobnum->save(false); } $data['code'] = 0; } else { return json_encode(['code' => 1, 'errmsg' => 'save db error']); } break; case 'orderview': $oid = isset($_GET["oid"]) ? $_GET["oid"] : 1; $data = MOrder::find()->select('*')->where("oid=:oid", [':oid' => $oid])->asArray()->one(); $data['statusName'] = MOrder::getOrderStatusName($data['status']); $order = MOrder::findOne($oid); if ($order->status == MOrder::STATUS_SUBMITTED) { $jsApiParameters = $order->GetOrderJsApiParameters(); $data['url'] = $jsApiParameters; } else { $data['url'] = ''; } break; case 'myorder': $gh_id = U::getSessionParam('gh_id'); $openid = U::getSessionParam('openid'); $page = isset($_GET["currentPage"]) ? $_GET["currentPage"] : 1; $size = isset($_GET['size']) ? $_GET['size'] : 8; $data = MOrder::find()->select('*')->where("gh_id=:gh_id AND openid=:openid AND status!=:status", [':gh_id' => $gh_id, ':openid' => $openid, ':status' => MOrder::STATUS_DRAFT])->orderBy(['oid' => SORT_DESC])->offset(($page - 1) * $size)->limit($size)->asArray()->all(); foreach ($data as &$row) { $row['statusName'] = MOrder::getOrderStatusName($row['status']); } unset($row); break; case 'officeorder': $gh_id = U::getSessionParam('gh_id'); $openid = U::getSessionParam('openid'); $page = isset($_GET["currentPage"]) ? $_GET["currentPage"] : 1; $size = isset($_GET['size']) ? $_GET['size'] : 8; $orderby = isset($_GET["orderby"]) ? $_GET["orderby"] : 'oid'; $asc = isset($_GET["asc"]) ? $_GET["asc"] : 0; $office_id = isset($_GET["office_id"]) ? $_GET["office_id"] : 0; $data = MOrder::find()->select('*')->where("gh_id=:gh_id AND office_id=:office_id", [':gh_id' => $gh_id, ':office_id' => $office_id])->orderBy([$orderby => $asc == 1 ? SORT_ASC : SORT_DESC])->offset(($page - 1) * $size)->limit($size)->asArray()->all(); foreach ($data as &$row) { $row['statusName'] = MOrder::getOrderStatusName($row['status']); } unset($row); break; case 'mobileNum': $page = isset($_GET["currentPage"]) ? $_GET["currentPage"] : 1; $size = isset($_GET['size']) ? $_GET['size'] : 8; $feeSum = isset($_GET['feeSum']) ? $_GET['feeSum'] : 100000; $feeSum = $feeSum * 100; $cid = isset($_GET["cid"]) ? $_GET["cid"] : MItem::ITEM_CAT_DIY; $num_cat = MMobnum::getNumCat($cid); $data = MMobnum::find()->select('num,ychf,zdxf')->where("status=:status AND num_cat=:num_cat AND zdxf <= :zdxf", [':status' => MMobnum::STATUS_UNUSED, ':num_cat' => $num_cat, ':zdxf' => $feeSum])->offset(($page - 1) * $size)->limit($size)->asArray()->all(); break; case 'diskclick': $gh_id = U::getSessionParam('gh_id'); $openid = U::getSessionParam('openid'); $model = MDisk::findOne(['gh_id' => $gh_id, 'openid' => $openid]); if ($model === null) { $model = MDisk::initDefault($gh_id, $openid); } else { if ($model->cnt > 0) { $model->cnt = $model->cnt - 1; } else { return json_encode(['code' => 1, 'errmsg' => 'has no qualification']); } } $data = U::makeDiskResult(); if ($data['code'] == 0) { if ($data['value'] % 2 == 0) { $model->cnt = 0; $model->win = 1; $model->win_time = time(); } } $model->save(false); break; case 'diskRestCnt': $gh_id = U::getSessionParam('gh_id'); $openid = U::getSessionParam('openid'); $model = MDisk::findOne(['gh_id' => $gh_id, 'openid' => $openid]); if ($model === null) { $model = MDisk::initDefault($gh_id, $openid); $model->save(false); $model = MDisk::findOne(['gh_id' => $gh_id, 'openid' => $openid]); } $data = $model->getAttributes(); $cur_time = time(); if ($model->win == 1 && $cur_time - $model->win_time < 30 * 60) { $alreadyWin = 1; } else { $alreadyWin = 0; } $data['alreadyWin'] = $alreadyWin; $data['code'] = 0; break; case 'g2048Save': $gh_id = U::getSessionParam('gh_id'); $openid = U::getSessionParam('openid'); Yii::$app->wx->setGhId($gh_id); $user = MUser::findOne(['gh_id' => $gh_id, 'openid' => $openid]); if ($user === null) { $user = new MUser(); } if (!empty($user->subscribe)) { $model = new \app\models\MG2048(); $model->gh_id = $gh_id; $model->openid = $openid; $model->best = $_GET['best']; $model->score = $_GET['score']; $model->big_num = $_GET['bigNum']; if (!$model->save(false)) { U::W([__METHOD__, $model->getErrors()]); return json_encode(['code' => 1, 'errmsg' => 'save score to db error']); } } $data['code'] = 0; $data['isSubscribed'] = empty($user->subscribe) ? 0 : 1; $data['position'] = MG2048::getCurrentScorePosition($gh_id, $_GET['score']); break; case 'getnearestoffice': $gh_id = U::getSessionParam('gh_id'); $lat = $_GET["lat"]; $lon = $_GET["lon"]; $rows = MOffice::getNearestOffices($gh_id, $lon, $lat); U::W($rows); $data['code'] = 0; $data['offices'] = $rows; break; case 'pkginfo': $gh_id = U::getSessionParam('gh_id'); $cid = isset($_GET["cid"]) ? $_GET["cid"] : MItem::ITEM_CAT_MOBILE_APPLE_5S_32G_SILVER; $pkg3g4g = isset($_GET["pkg3g4g"]) ? $_GET["pkg3g4g"] : ''; $period = isset($_GET["pkgPeriod"]) ? $_GET["pkgPeriod"] : 12; $monthprice = isset($_GET["pkgMonthprice"]) ? $_GET["pkgMonthprice"] : 46; $plan = $_GET["pkgPlan"] == 'null' ? '' : $_GET["pkgPlan"]; //$data = MPkg::find()->select('*')->where( // "gh_id=:gh_id AND cid=:cid AND pkg3g4g=:pkg3g4g AND period=:period AND monthprice=:monthprice AND plan=:plan", // [':gh_id'=>$gh_id, ':cid'=>$cid, ':pkg3g4g'=>$pkg3g4g, ':period'=>$period, ':monthprice'=>$monthprice, ':plan'=>$plan])->asArray()->one(); $data = MPkg::find()->select('*')->where("gh_id=:gh_id AND cid=:cid AND pkg3g4g=:pkg3g4g AND period=:period AND monthprice=:monthprice", [':gh_id' => $gh_id, ':cid' => $cid, ':pkg3g4g' => $pkg3g4g, ':period' => $period, ':monthprice' => $monthprice])->asArray()->one(); //foreach($data as &$row) //{ // $row['statusName'] = MOrder::getOrderStatusName($row['status']); //} //unset($row); break; case 'wlinfo': U::W("++++++++++++++++++++++++++++++++++++++"); $wl_url_1 = isset($_GET["wl_url_1"]) ? $_GET["wl_url_1"] : ''; $wl_url_2 = isset($_GET["wl_url_2"]) ? $_GET["wl_url_2"] : ''; $wl_url = "http://www.kuaidi100.com/query?type=" . $wl_url_1 . "&postid=" . $wl_url_2; //U::W($wl_url); $data = file_get_contents($wl_url); //$data = substr($lucy_msg, 14, -2); $data = json_decode($data, true); //U::W($data); break; case 'woketixian': $gh_id = U::getSessionParam('gh_id'); $openid = U::getSessionParam('openid'); U::W("----------assdfsdf1-----------"); U::W($openid); Yii::$app->wx->setGhId($gh_id); $user = MUser::findOne(['gh_id' => $gh_id, 'openid' => $openid]); $model = new \app\models\MSceneDetail(); $model->gh_id = $gh_id; $model->openid = $openid; $model->scene_id = $user->scene_id; $model->scene_amt = -1 * $_GET['ljtx']; $model->memo = $_GET['memo']; $model->czhm = $_GET['czhm']; if (!$model->save(false)) { U::W([__METHOD__, $model->getErrors()]); return json_encode(['code' => 1, 'errmsg' => 'save score to db error']); } $user->scene_balance = $user->scene_balance - abs($model->scene_amt); if (!$user->save(false)) { U::W([__METHOD__, $model->getErrors()]); return json_encode(['code' => 1, 'errmsg' => 'save score to db error']); } $data['ljtx'] = abs($model->scene_amt); break; case 'wokeqdyl': $gh_id = U::getSessionParam('gh_id'); $openid = U::getSessionParam('openid'); U::W("----------wokeqdyl-----------"); U::W($openid); Yii::$app->wx->setGhId($gh_id); $user = MUser::findOne(['gh_id' => $gh_id, 'openid' => $openid]); U::W("\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$"); U::W($user); $model = new \app\models\MSceneDetail(); $model->gh_id = $gh_id; $model->openid = $openid; $model->scene_id = $user->scene_id; $money_max = 8; //每日签到有礼,8个沃点封顶; if ($user->sign_money == 0) { $user->sign_time = date("Y-m-d"); $user->sign_money = 1; } else { if (strtotime(date("Y-m-d")) - strtotime($user->sign_time) < 1) { //$user->sign_time = date("Y-m-d"); //$user->sign_money = 1; $data['sign_money'] = 'marked'; break; } else { if ((strtotime(date("Y-m-d")) - strtotime($user->sign_time)) / 86400 > 1) { $user->sign_time = date("Y-m-d"); $user->sign_money = 1; } else { $user->sign_time = date("Y-m-d"); $user->sign_money = 2 * $user->sign_money > $money_max ? $money_max : 2 * $user->sign_money; } } } $model->scene_amt = $user->sign_money; $model->memo = $_GET['memo']; $model->cat = MSceneDetail::CAT_SIGN; if (!$model->save(false)) { U::W([__METHOD__, $model->getErrors()]); return json_encode(['code' => 1, 'errmsg' => 'save score to db error']); } //$user->scene_balance = $user->scene_balance + abs($model->scene_amt); if (!$user->save(false)) { U::W([__METHOD__, $model->getErrors()]); return json_encode(['code' => 1, 'errmsg' => 'save score to db error']); } $data['sign_money'] = $user->sign_money; break; case 'czsjhm': $gh_id = U::getSessionParam('gh_id'); $openid = U::getSessionParam('openid'); Yii::$app->wx->setGhId($gh_id); $user = MUser::findOne(['gh_id' => $gh_id, 'openid' => $openid]); if ($user === null) { $user = new MUser(); } if (!empty($user->subscribe)) { $user->gh_id = $gh_id; $user->openid = $openid; $user->user_account_charge_mobile = $_GET['czhm1']; if (!$user->save(false)) { U::W([__METHOD__, $user->getErrors()]); return json_encode(['code' => 1, 'errmsg' => 'save score to db error']); } } $data['czsjhm'] = $user->user_account_charge_mobile; break; default: U::W(['invalid data cat', $cat, __METHOD__, $_GET]); return; } U::W([$data]); U::W(json_encode($data)); return json_encode($data); }
?> <div class="muser-update"> <div class="muser-form"> <?php $form = ActiveForm::begin(); ?> <?php echo $form->field($model, 'id')->textInput(['maxlength' => 10, 'readonly' => true]); ?> <?php echo $form->field($model, 'status')->dropDownList(MSceneDetail::getSceneDetailStatusOption())->label("提现状态审核"); ?> <div class="form-group"> <?php echo Html::submitButton($model->isNewRecord ? '创建' : '修改', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']); ?> </div> <?php ActiveForm::end(); ?> </div> </div>
protected function onUnsubscribe() { $this->saveAccessLogAll(); $FromUserName = $this->getRequest('FromUserName'); $gh_id = $this->getRequest('ToUserName'); $user = $this->getUser(); $scene_pid = $user->scene_pid; $user->subscribe = 0; //$user->scene_pid = 0; $user->gid = 0; $user->msg_cnt = 0; $user->save(false); $this->saveAccessLog(['scene_pid' => $user->scene_pid]); // cancel MSceneDetail if ($scene_pid > 0) { $arr = MSceneDetail::findAll(['gh_id' => $gh_id, 'scene_id' => $scene_pid, 'openid_fan' => $FromUserName]); foreach ($arr as $ar) { $ar->status = MSceneDetail::STATUS_CANCEL; if (!$ar->save(false)) { U::W([__METHOD__, __LINE__, $_GET, $ar->getErrors()]); } } } return Wechat::NO_RESP; }
public function getWokeYqwdLast7Days() { //已提沃点 if (empty($this->scene_id)) { return 0; } //今天 $d1 = MSceneDetail::find()->where('gh_id=:gh_id AND scene_id=:scene_id AND status=:status AND scene_amt>0 AND to_days(create_time)=to_days(now())', [':gh_id' => $this->gh_id, ':scene_id' => $this->scene_id, ':status' => MSceneDetail::STATUS_INIT])->sum('scene_amt'); if ($d1 == null) { $d1 = 0; } //昨天 $d2 = MSceneDetail::find()->where('gh_id=:gh_id AND scene_id=:scene_id AND status=:status AND scene_amt>0 AND to_days(now())-to_days(create_time)=1', [':gh_id' => $this->gh_id, ':scene_id' => $this->scene_id, ':status' => MSceneDetail::STATUS_INIT])->sum('scene_amt'); if ($d2 == null) { $d2 = 0; } $d3 = MSceneDetail::find()->where('gh_id=:gh_id AND scene_id=:scene_id AND status=:status AND scene_amt>0 AND to_days(now())-to_days(create_time)=2', [':gh_id' => $this->gh_id, ':scene_id' => $this->scene_id, ':status' => MSceneDetail::STATUS_INIT])->sum('scene_amt'); if ($d3 == null) { $d3 = 0; } $d4 = MSceneDetail::find()->where('gh_id=:gh_id AND scene_id=:scene_id AND status=:status AND scene_amt>0 AND to_days(now())-to_days(create_time)=3', [':gh_id' => $this->gh_id, ':scene_id' => $this->scene_id, ':status' => MSceneDetail::STATUS_INIT])->sum('scene_amt'); if ($d4 == null) { $d4 = 0; } $d5 = MSceneDetail::find()->where('gh_id=:gh_id AND scene_id=:scene_id AND status=:status AND scene_amt>0 AND to_days(now())-to_days(create_time)=4', [':gh_id' => $this->gh_id, ':scene_id' => $this->scene_id, ':status' => MSceneDetail::STATUS_INIT])->sum('scene_amt'); if ($d5 == null) { $d5 = 0; } $d6 = MSceneDetail::find()->where('gh_id=:gh_id AND scene_id=:scene_id AND status=:status AND scene_amt>0 AND to_days(now())-to_days(create_time)=5', [':gh_id' => $this->gh_id, ':scene_id' => $this->scene_id, ':status' => MSceneDetail::STATUS_INIT])->sum('scene_amt'); if ($d6 == null) { $d6 = 0; } $d7 = MSceneDetail::find()->where('gh_id=:gh_id AND scene_id=:scene_id AND status=:status AND scene_amt>0 AND to_days(now())-to_days(create_time)=6', [':gh_id' => $this->gh_id, ':scene_id' => $this->scene_id, ':status' => MSceneDetail::STATUS_INIT])->sum('scene_amt'); if ($d7 == null) { $d7 = 0; } $last7days = array($d1, $d2, $d3, $d4, $d5, $d6, $d7); U::W("###########\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\n"); U::W($last7days); //return array_values($last7days); return empty($last7days) ? 0 : $last7days; }