示例#1
0
 public function actionCreate()
 {
     $model = new MUser();
     if (\Yii::$app->request->isPost) {
         $model->load(\Yii::$app->request->post());
         if ($model->save()) {
             return $this->redirect(['index']);
         } else {
             U::W($model->getErrors());
         }
     }
     return $this->render('create', ['model' => $model]);
 }
示例#2
0
 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);
 }