public function exchangeGoods() { $weixinUtil = new WeixinUtil(); // 验证是否已授权 $weixinUtil->authorize("exchange/coupon"); $openId = $weixinUtil->getOpenId(); $products = (new ExchangeGoodsModel())->getAllExchangeGoods(); $shops = (new ShopModel())->getAllShopAddress(); $lastOrder = (new OrderModel())->getLastOrder($openId); $this->view('exchange/exchangeGoods', array('products' => $products, 'shops' => $shops, 'lastOrder' => $lastOrder)); }
/** * 展示预约页面 * 选择美容师与预约时间 * 此处要验证授权 * * @param $shopId 店铺ID */ public function index($shopId) { $weixinUtil = new WeixinUtil(); // 验证是否已授权 $weixinUtil->authorize("appointment/index/{$shopId}"); // 获得预约项目 $projectId = (new CartUtil())->cart(); $projectId += 0; if (!$projectId) { $this->message('预约项目不存在!'); } $openId = $weixinUtil->getOpenId(); if ((new ProjectPropertyModel())->projectOnlyForNewUser($projectId, $openId)) { $this->message('此美容项目只针对新用户!'); } //是否已经选择了店铺,并且店铺是有效的 $shops = (new ShopModel())->getAllShops(); if (is_numeric($shopId) && array_key_exists($shopId, $shops)) { // 获得项目信息 $project = (new ProjectModel())->readOne($projectId); if (!$project) { $this->message('预约项目不存在!'); } // 跳转到 选择 美容师 $beauticians = (new BeauticianModel())->getAllBeauticians(); $lastOrder = (new OrderModel())->getLastOrder($openId); $days = DateUtil::buildDays(); $coupons = array(); if ($project['can_use_coupon']) { // 查询优惠券 $coupons = (new CustomerCouponModel())->getCustomerNotUseCouponList($openId); } $this->load->view('frontend/appointment/beautician', array('beauticians' => $beauticians, 'project' => $project, 'shopId' => $shopId, 'days' => $days, 'lastOrder' => $lastOrder, 'coupons' => $coupons)); } else { // 跳转到选择店铺 $returnUrl = urlencode(UrlUtil::createUrl('appointment/index')); ResponseUtil::redirect(UrlUtil::createUrl("shop/index?returnUrl={$returnUrl}")); } }
public function order($offset = 0) { $orderStatus = $this->input->get('type') + 0; $weixinUtil = new WeixinUtil(); $weixinUtil->authorize("userCenter/order/{$offset}/{$orderStatus}"); $openId = $weixinUtil->getOpenId(); $orderModel = new OrderModel(); // 获得订单信息 $where = array('open_id' => $openId); if ($orderStatus) { $where['order_status'] = $orderStatus; } $orders = $orderModel->getUserOrders($openId, $orderStatus, $offset); $orderCounts = $orderModel->getUserOrderCounts($openId, $orderStatus); if (isset($orderCounts[0])) { $orderCounts = array_pop($orderCounts); } $orderCounts = isset($orderCounts['rowCounts']) ? $orderCounts['rowCounts'] : 0; $pages = (new PaginationUtil($orderCounts, 'user-center'))->pagination(); $shopModel = new ShopModel(); $shops = $shopModel->getAllShops(); $shopAddress = $shopModel->getAllShopAddress(); $this->view('userCenter/order', array('pages' => $pages, 'orders' => $orders, 'orderStatus' => $orderStatus, 'shops' => $shops, 'offset' => $offset, 'shopAddress' => $shopAddress)); }