?> <?php if ($order->buyerCanPay()) { echo "<span class='btn' id='xianxia_pay' oid=" . $order->oid . " status=" . MOrder::PAY_KIND_CASH . ">线下支付</span>"; } ?> </span> </li> <li class="table-view-cell"><span class="orderitem">订单状态</span> <?php echo MOrder::getOrderStatusName($order->status); ?> <?php if ($order->buyerCanCancel()) { echo "<span class='btn btn-negative' id='qxdd_attr' oid=" . $order->oid . " status=" . MOrder::STATUS_BUYER_CLOSED . ">取消订单</span>"; } ?> <?php if ($order->buyerCanRefund()) { echo "<span class='btn btn-negative' id='tk_attr' oid=" . $order->oid . " status=" . MOrder::STATUS_BUYER_REFUND_CLOSED . ">退款</span>"; } ?> <?php
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); }
//echo $this->render('_search', ['model' => $searchModel]); ?> <?php $columns = ['oid', ['label' => '营业厅', 'attribute' => 'office.title', 'value' => function ($model, $key, $index, $column) { return empty($model->office->title) ? '' : $model->office->title; }, 'filter' => false, 'headerOptions' => array('style' => 'width:80px;')], ['label' => '微信昵称', 'value' => function ($model, $key, $index, $column) { $user = $model->user; return empty($user) ? '' : $user->nickname; }, 'filter' => false, 'headerOptions' => array('style' => 'width:80px;')], ['attribute' => 'detail', 'headerOptions' => array('style' => 'width:100px;')], ['attribute' => 'feesum', 'value' => function ($model, $key, $index, $column) { return "¥" . sprintf("%0.2f", $model->feesum / 100); }], ['attribute' => 'create_time', 'filterType' => GridView::FILTER_DATE, 'format' => 'raw', 'width' => '250px', 'filterWidgetOptions' => ['type' => \kartik\widgets\DatePicker::TYPE_RANGE, 'separator' => '至', 'attribute2' => 'create_time_2', 'pluginOptions' => ['format' => 'yyyy-mm-dd', 'language' => 'zh-CN']]], ['label' => '买家身份信息', 'value' => function ($model, $key, $index, $column) { return "{$model->username}, {$model->userid}, {$model->usermobile}"; }, 'headerOptions' => array('style' => 'width:120px;')], ['label' => '留言', 'attribute' => 'memo'], ['label' => '备注', 'attribute' => 'memo_reply'], ['attribute' => 'status', 'value' => function ($model, $key, $index, $column) { return $model->statusName; }, 'filter' => MOrder::getOrderStatusName()], ['attribute' => 'pay_kind', 'label' => '付款方式', 'value' => function ($model, $key, $index, $column) { return MOrder::getOrderPayKindOption($model->pay_kind); }, 'filter' => MOrder::getOrderPayKindOption(), 'headerOptions' => array('style' => 'width:60px;')], ['label' => '用户', 'value' => function ($model, $key, $index, $column) { if (!empty($model->user)) { if ($model->user->bindMobileIsInside('wx_vip')) { return '老'; } else { return '新'; } } return '--'; }], ['class' => 'yii\\grid\\ActionColumn', 'template' => '{view} {update} {chat}', 'buttons' => ['chat' => function ($url, $model) { return Html::a('<span class="glyphicon glyphicon-comment"></span>', $url, ['title' => Yii::t('yii', '发送消息给用户'), 'data-method' => 'post', 'data-pjax' => '0']); }]]]; /* echo DynaGrid::widget([
public function actionOrder($filename = 'order.csv', $date = null) { $filepathname = Yii::$app->getRuntimePath() . DIRECTORY_SEPARATOR . 'exported_data' . DIRECTORY_SEPARATOR . $filename; $fh = fopen($filepathname, 'w'); if (null === $date) { $date = \app\models\U::getFirstDate(date('Y'), date('m')); } $total_count = \app\models\MOrder::find()->where(['>', 'create_time', $date])->count(); //$total_count = \app\models\MUser::find()->count(); $step = 300; $start = 0; while ($start < $total_count) { $orders = \app\models\MOrder::find()->offset($start)->limit($step)->where(['>', 'create_time', $date])->orderBy(['create_time' => SORT_ASC])->all(); fprintf($fh, "营业厅, 订单号, 商品, 价格, 订单时间, 身份证, 用户姓名, 联系电话, 支付方式, 订单状态, 开通, 备注, 用户类型\n"); foreach ($orders as $order) { $office = \app\models\MOffice::findOne(['office_id' => $order->office_id]); if (!empty($office)) { $office_title = $office->title; } else { $office_title = ""; } $user = \app\models\MUser::findOne(['openid' => $order->openid]); $customerFlag = '--'; /* if ($user->bindMobileIsInside('wx_t1')) { $customerFlag = '老'; } elseif ($user->bindMobileIsInside('wx_t2')) { $customerFlag = '老'; }elseif ($user->bindMobileIsInside('wx_t3')) { $customerFlag = '老'; } else { $customerFlag = '新'; } */ if ($user->bindMobileIsInside('wx_oldcustomer')) { $customerFlag = '老'; } else { $customerFlag = '新'; } $pay_kind = \app\models\MOrder::getOrderPayKindOption($order->pay_kind); $price = $order->feesum / 100; $paystatus = \app\models\MOrder::getOrderStatusName($order->status); //echo $office_title."\t".$order->oid."\t".$order->title."\t".$price."\t".$order->create_time."\t".$order->userid."\t".$order->username."\t".$order->usermobile."\t".$pay_kind."\t".$order->memo."\t".$order->customerFlag."\t\n"; fprintf($fh, "%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s\n", $office_title, $order->oid, $order->title, $price, $order->create_time, $order->userid, $order->username, $order->usermobile, $pay_kind, $paystatus, $order->kaitong, $order->memo, $order->customerFlag); } $start += $step; } fclose($fh); }