/** * 显示订单详情 */ public function Detail($f3) { // 权限检查 $this->requirePrivilege('manage_order_goods_detail'); global $smarty; // 参数验证 $validator = new Validator($f3->get('GET')); $rec_id = $validator->required()->digits()->min(1)->validate('rec_id'); if (!$this->validate($validator)) { goto out_display; } // 取 order_goods $orderBasicService = new OrderBasicService(); $orderGoods = $orderBasicService->loadOrderGoodsById($rec_id); if ($orderGoods->isEmpty() || $orderGoods['order_id'] <= 0) { $this->addFlashMessage('订单ID非法'); goto out_display; } // 转换状态显示 $orderGoods['order_goods_status_desc'] = OrderGoodsService::$orderGoodsStatusDesc[$orderGoods['order_goods_status']]; // 额外优惠允许的最大金额 $allowExtraDiscount = $orderGoods['goods_price'] + $orderGoods['shipping_fee'] - $orderGoods['discount']; $maxExtraDiscount = round($allowExtraDiscount * $f3->get('sysConfig[max_order_goods_extra_discount_rate]'), 2); $maxExtraDiscount = max($maxExtraDiscount, $f3->get('sysConfig[max_order_goods_extra_discount_value]')); $maxExtraDiscount = min($maxExtraDiscount, $allowExtraDiscount); // 退款允许退的最大金额 $maxRefund = $orderGoods['goods_price'] + $orderGoods['shipping_fee'] - $orderGoods['discount'] - $orderGoods['extra_discount']; // 取商品信息 $goodsBasicService = new GoodsBasicService(); $goods = $goodsBasicService->loadGoodsById($orderGoods['goods_id'], 300); // 缓存 300 秒 // 取 order_info $orderInfo = $orderBasicService->loadOrderInfoById($orderGoods['order_id']); if ($orderInfo->isEmpty()) { $this->addFlashMessage('订单ID非法'); goto out_display; } $orderInfo['order_status_desc'] = OrderBasicService::$orderStatusDesc[$orderInfo['order_status']]; $orderInfo['pay_status_desc'] = OrderBasicService::$payStatusDesc[$orderInfo['pay_status']]; // 取订单来源信息 $orderReferService = new OrderReferService(); $orderRefer = $orderReferService->loadOrderReferByOrderId($orderInfo['order_id'], 300); //缓存5分钟 // 取用户账户 $userBasicService = new UserBasicService(); $userInfo = $userBasicService->loadUserById($orderInfo['user_id']); // 取得订单的操作日志 $orderActionService = new OrderActionService(); $orderLogArray = $orderActionService->fetchOrderLogArray($orderGoods['order_id'], $orderGoods['rec_id']); // 状态字段转换成可以显示的字符串 foreach ($orderLogArray as &$orderLog) { $orderLog['order_status'] = OrderBasicService::$orderStatusDesc[$orderLog['order_status']]; $orderLog['pay_status'] = OrderBasicService::$payStatusDesc[$orderLog['pay_status']]; $orderLog['order_goods_status'] = OrderGoodsService::$orderGoodsStatusDesc[$orderLog['order_goods_status']]; $orderLog['action_note'] = nl2br($orderLog['action_note']); } unset($orderLog); // 查询供货商信息 $supplierUserService = new SupplierUserService(); $supplierInfo = $supplierUserService->loadSupplierById($orderGoods['suppliers_id']); // 给模板赋值 $smarty->assign('orderGoods', $orderGoods); $smarty->assign('goods', $goods); $smarty->assign('maxExtraDiscount', $maxExtraDiscount); $smarty->assign('maxRefund', $maxRefund); $smarty->assign('orderInfo', $orderInfo); $smarty->assign('orderRefer', $orderRefer); $smarty->assign('userInfo', $userInfo); $smarty->assign('supplierInfo', $supplierInfo); $smarty->assign('orderLogArray', $orderLogArray); out_display: $smarty->display('order_goods_detail.tpl'); }
/** * 订单详情 */ public function Detail($f3) { // 权限检查 $this->requirePrivilege('manage_order_order_detail'); global $smarty; // 参数验证 $validator = new Validator($f3->get('GET')); $order_id = $validator->required('订单ID非法')->digits('订单ID非法')->min(1)->validate('order_id'); if (!$this->validate($validator)) { goto out_fail; } // 查询订单 $orderBasicService = new OrderBasicService(); $orderInfo = $orderBasicService->loadOrderInfoById($order_id); if ($orderInfo->isEmpty()) { $this->addFlashMessage('订单ID非法'); goto out_fail; } $orderInfo['order_status_desc'] = OrderBasicService::$orderStatusDesc[$orderInfo['order_status']]; $orderInfo['pay_status_desc'] = OrderBasicService::$payStatusDesc[$orderInfo['pay_status']]; $orderGoodsArray = $orderBasicService->fetchOrderGoodsArray($order_id); // 转换状态显示 foreach ($orderGoodsArray as &$orderGoodsItem) { $orderGoodsItem['order_goods_status_desc'] = OrderGoodsService::$orderGoodsStatusDesc[$orderGoodsItem['order_goods_status']]; } unset($orderGoodsItem); // 取订单来源信息 $orderReferService = new OrderReferService(); $orderRefer = $orderReferService->loadOrderReferByOrderId($orderInfo['order_id'], 300); //缓存5分钟 // 取用户账户 $userBasicService = new UserBasicService(); $userInfo = $userBasicService->loadUserById($orderInfo['user_id']); // 取得订单的操作日志 $orderActionService = new OrderActionService(); $orderLogArray = $orderActionService->fetchOrderLogArray($order_id, 0); // 状态字段转换成可以显示的字符串 foreach ($orderLogArray as &$orderLog) { $orderLog['order_status'] = OrderBasicService::$orderStatusDesc[$orderLog['order_status']]; $orderLog['pay_status'] = OrderBasicService::$payStatusDesc[$orderLog['pay_status']]; $orderLog['order_goods_status'] = OrderGoodsService::$orderGoodsStatusDesc[$orderLog['order_goods_status']]; $orderLog['action_note'] = nl2br($orderLog['action_note']); } unset($orderLog); // 给模板赋值 $smarty->assign('orderInfo', $orderInfo); $smarty->assign('orderRefer', $orderRefer); $smarty->assign('userInfo', $userInfo); $smarty->assign('orderGoodsArray', $orderGoodsArray); $smarty->assign('orderLogArray', $orderLogArray); $smarty->display('order_order_detail.tpl'); return; out_fail: // 失败从这里退出 RouteHelper::reRoute($this, '/Order/Order/Search'); }