public function actionGoodssave() { $this->layout = false; $gh_id = U::getSessionParam('gh_id'); $openid = U::getSessionParam('openid'); Yii::$app->wx->setGhId($gh_id); $order = new MOrder(); $order->oid = MOrder::generateOid(); $order->gh_id = $gh_id; $order->openid = $openid; $order->cid = $_GET["cid"]; $good = MGoods::findOne(['goods_id' => $order->cid]); $order->title = $good->title; //利用该字段做一个标记,在myorder 页面中兼容老的商品表item。 $order->attr = 'goods'; $order->val_pkg_3g4g = isset($_GET['pkg3g4g']) ? $_GET['pkg3g4g'] : ''; $order->val_pkg_period = isset($_GET['pkgPeriod']) ? $_GET['pkgPeriod'] : 0; $order->val_pkg_monthprice = isset($_GET['pkgMonthprice']) ? $_GET['pkgMonthprice'] : 0; $order->val_pkg_plan = isset($_GET['pkgPlan']) ? $_GET['pkgPlan'] : ''; //$order->feesum = $_GET['feeSum'] * 100; $order->feesum = $_GET['feeSum'] * 100; $order->office_id = isset($_GET['office']) && $_GET['office'] != MOrder::NO_CHOICE ? $_GET['office'] : 0; $order->userid = isset($_GET['userid']) && $_GET['userid'] != MOrder::NO_CHOICE ? $_GET['userid'] : ''; $order->username = isset($_GET['username']) && $_GET['username'] != MOrder::NO_CHOICE ? $_GET['username'] : ''; $order->usermobile = isset($_GET['usermobile']) && $_GET['usermobile'] != MOrder::NO_CHOICE ? $_GET['usermobile'] : ''; //$order->pay_kind = isset($_GET['pay_kind']) ? $_GET['pay_kind'] : MOrder::PAY_KIND_CASH; $order->address = isset($_GET['address']) && $_GET['address'] != MOrder::NO_CHOICE ? $_GET['address'] : ''; $order->kaitong = isset($_GET['kaitong']) && $_GET['kaitong'] != MOrder::NO_CHOICE ? $_GET['kaitong'] : ''; $order->memo = isset($_GET['memo']) && $_GET['memo'] != MOrder::NO_CHOICE ? $_GET['memo'] : ''; $order->detail = $order->getDetailStr(); /* if ($_GET['selectNum'] != MOrder::NO_CHOICE) { $order->select_mobnum = $_GET['selectNum']; $mobnum = MMobnum::findOne($_GET['selectNum']); if ($mobnum === null || $mobnum->status != MMobnum::STATUS_UNUSED) { return json_encode(['status' => 1, 'errmsg' => $mobnum === null ? "mobile doest not exist" : "mobile locked!"]); } } else { $order->select_mobnum = ''; } */ $order->select_mobnum = ''; /* $wid = Yii::$app->request->get('wid', ''); if (!empty($wid)) { list($scene_id, $scene_src_id) = explode('_', $wid); $order->scene_id = $scene_id; $order->scene_src_id = $scene_src_id; if (empty($order->item)) { U::W("@@@@@@@@@@@@@@@@@@@NULL@@@@@@@@@@@@@@@@@@@@@@@@@@@"); } $order->scene_amt = $order->feesum * $order->item->scene_percent / 100; } */ if ($order->save(false)) { //send wx message and sm $manager = MStaff::findOne(['office_id' => $order->office_id, 'is_manager' => 1]); if ($manager !== null && !empty($manager->openid)) { //U::W('sendWxm'); $manager->sendWxm($order->getWxNoticeToManager()); //U::W('sendSm'); //$manager->sendSm($order->getSmNoticeToManager()); try { $arr = $order->sendTemplateNoticeToManager($manager); } catch (\Exception $e) { U::W($e->getMessage()); } } else { U::W(['Have no manager or the manager has not binded openid', $order]); } /* // send wx message to user //$arr = Yii::$app->wx->WxMessageCustomSend(['touser'=>$openid, 'msgtype'=>'text', 'text'=>['content'=>$order->getWxNotice()]]); $arr = $order->sendTemplateNoticeToCustom(); */ } else { U::W([__METHOD__, $order->getErrors()]); } $jsApiParameters = $order->GetOrderJsApiParameters(); return json_encode(['oid' => $order->oid, 'status' => 0, 'pay_url' => $jsApiParameters]); }
public function actionClientGoodsView($id) { $g = MGoods::findOne(['goods_id' => $id]); return $this->render('clientGoodsView', ['model' => $g]); }
/** * Finds the MGoods model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return MGoods the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = MGoods::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
public static function zujieAjax($goods_id, $user_id) { $goods = MGoods::findOne(['goods_id' => $goods_id]); $user = User::findOne(['id' => $user_id]); U::W($goods); $order = new MOrder(); if (empty($goods) || empty($user)) { U::W("----------goods or user is null--------"); return \yii\helpers\Json::encode(['code' => 1]); } $order->oid = uniqid(); $order->feesum = 0; $order->status = 1; $order->goods_id = $goods->goods_id; $order->title = $goods->title; $order->userid = $user->id; $order->username = $user->username; $order->usermobile = $user->mobile; $order->address = "--"; $order->memo = "--"; $order->memo_reply = "--"; $order->save(false); return \yii\helpers\Json::encode(['code' => 0]); }