/** * 列出所有文章分类 * * @param $f3 */ public function ListCategory($f3) { // 检查缓存 $cacheKey = md5(__NAMESPACE__ . '\\' . __CLASS__ . '\\' . __METHOD__); if ($f3->get('GET[nocache]')) { goto nocache; } $categoryArray = $f3->get($cacheKey); if (!empty($categoryArray)) { goto out; } nocache: // 没有缓存数据 $categoryService = new CategoryService(); $categoryArray = $categoryService->fetchArticleCategoryArray(); $f3->set($cacheKey, $categoryArray, 300); //缓存 5 分钟 out: if (!$f3->get('GET[nocache]')) { $f3->expire(60); // 客户端缓存 1 分钟 } Ajax::header(); echo Ajax::buildResult(null, null, $categoryArray); }
public function get($f3) { Ajax::header(); $clientData = ClientDataHelper::getClientDataArray(); if (null == $clientData) { $clientData = array(); } echo Ajax::buildResult(null, null, json_encode($clientData)); }
public function ListOrderGoodsStatus($f3) { $outputArray = array(); foreach (OrderGoodsService::$orderGoodsStatusDesc as $index => $desc) { $outputArray[] = array('id' => $index, 'desc' => $desc); } $f3->expire(60); // 客户端缓存 1 分钟 Ajax::header(); echo Ajax::buildResult(null, null, $outputArray); }
public function ListSystem($f3) { // 检查缓存 $cacheKey = md5(__NAMESPACE__ . '\\' . __CLASS__ . '\\' . __METHOD__); $roleArray = $f3->get($cacheKey); if (!empty($roleArray)) { goto out; } $systemArray = array(array('system_tag' => PluginHelper::SYSTEM_SHOP, 'system_name' => '商城'), array('system_tag' => PluginHelper::SYSTEM_MOBILE, 'system_name' => '移动')); out: $f3->expire(600); // 让客户端缓存 10 分钟 Ajax::header(); echo Ajax::buildResult(null, null, $systemArray); }
public function ListRole($f3) { // 检查缓存 $cacheKey = md5(__NAMESPACE__ . '\\' . __CLASS__ . '\\' . __METHOD__); $roleArray = $f3->get($cacheKey); if (!empty($roleArray)) { goto out; } $metaRoleService = new MetaRoleService(); $roleArray = $metaRoleService->fetchRoleArray(); $f3->set($cacheKey, $roleArray, 300); //缓存 5 分钟 out: Ajax::header(); echo Ajax::buildResult(null, null, $roleArray); }
public function ListBrand($f3) { // 检查缓存 $cacheKey = md5(__NAMESPACE__ . '\\' . __CLASS__ . '\\' . __METHOD__); $brandArray = $f3->get($cacheKey); if (!empty($brandArray)) { goto out; } $brandService = new BrandService(); $brandArray = $brandService->fetchBrandIdNameArray(); $f3->set($cacheKey, $brandArray, 300); //缓存 5 分钟 out: $f3->expire(60); // 客户端缓存 1 分钟 Ajax::header(); echo Ajax::buildResult(null, null, $brandArray); }
public function ListExpress($f3) { // 检查缓存 $cacheKey = md5(__NAMESPACE__ . '\\' . __CLASS__ . '\\' . __METHOD__); $expressArray = $f3->get($cacheKey); if (!empty($expressArray)) { goto out; } $expressService = new ExpressService(); $expressArray = $expressService->fetchAvailableExpressArray(); $f3->set($cacheKey, $expressArray, 300); //缓存 5 分钟 out: $f3->expire(60); // 客户端缓存 1 分钟 Ajax::header(); echo Ajax::buildResult(null, null, $expressArray); }
/** * 列出在线客服 * * @param $f3 */ public function ListKefuIdName($f3) { // 检查缓存 $cacheKey = md5(__NAMESPACE__ . '\\' . __CLASS__ . '\\' . __METHOD__); $adminArray = $f3->get($cacheKey); if (!empty($adminArray)) { goto out; } $baseService = new BaseService(); $adminArray = $baseService->_fetchArray('admin_user', 'user_id,user_name', array(array('disable = 0'), array('is_kefu = 1')), array('order' => 'user_id desc'), 0, 0, 0); $f3->set($cacheKey, $adminArray, 300); //缓存 5 分钟 out: $f3->expire(60); // 客户端缓存 1 分钟 Ajax::header(); echo Ajax::buildResult(null, null, $adminArray); }
public function Json($f3) { $url = $f3->get('GET.url'); $url = trim($url); $cache = $f3->get('GET.cache'); // 缓存时间 $cache = trim($cache); $cache = intval($cache); if (!$cache || $cache <= 0) { // 不要缓存 goto fetch_data; } // 处理缓存 $cacheId = md5(__CLASS__ . '\\' . __METHOD__ . '\\' . $url); $jsonData = $f3->get($cacheId); if (!empty($jsonData)) { goto out; } fetch_data: $errorMessage = ''; if (empty($url)) { $errorMessage = 'url is empty'; goto out_fail; } $request = \Web::instance()->request($url); if (!$request) { $errorMessage = 'request fail for url [' . $url . ']'; goto out_fail; } $jsonData = json_decode($request['body']); if (!empty($jsonData) && $cache > 0) { // 放入缓存中 $f3->set($cacheId, $jsonData, $cache); } out: // 成功返回数据 Ajax::header(); echo Ajax::buildResult(null, null, $jsonData); return; out_fail: Ajax::header(); echo Ajax::buildResult(-1, $errorMessage, null); }
/** * 列出在线客服 * * @param $f3 */ public function ListKefuIdName($f3) { global $smarty; // 检查缓存 $smartyCacheId = 'Ajax|' . md5(__NAMESPACE__ . '\\' . __CLASS__ . '\\' . __METHOD__); enableSmartyCache(true, 600); // 缓存 10 分钟 // 判断是否有缓存 if ($smarty->isCached('empty.tpl', $smartyCacheId)) { goto out_display; } $baseService = new BaseService(); $adminArray = $baseService->_fetchArray('admin_user', 'user_id,user_name', array(array('disable = 0'), array('is_kefu = 1')), array('order' => 'user_id desc'), 0, 0, 0); $smarty->assign('outputContent', Ajax::buildResult(null, null, $adminArray)); out_display: $f3->expire(600); // 客户端缓存 10 分钟 Ajax::header(); $smarty->display('empty.tpl', $smartyCacheId); }
/** * 要求某个权限才能执行 * * @param string $needPrivilege * @param bool $isAjax 是否是 ajax 请求 * */ protected function requirePrivilege($needPrivilege, $isAjax = false) { if (!$this->hasPrivilege($needPrivilege)) { goto out_fail; } return; // 成功从这里返回 out_fail: // 失败,reroute 到错误页面 if ($isAjax) { $needPrivilegeName = $needPrivilege; $metaPrivilegeService = new MetaPrivilegeService(); $privilege = $metaPrivilegeService->loadPrivilegeItem($needPrivilege, 600); //缓存 10 分钟 if (!$privilege->isEmpty()) { $needPrivilegeName = $privilege['meta_name'] ?: $needPrivilegeName; } Ajax::header(); echo Ajax::buildResult(-1, '没有权限:' . $needPrivilegeName, null); die; } RouteHelper::reRoute($this, RouteHelper::makeUrl('/Error/Privilege', array('privilege' => $needPrivilege), true)); }
public function ajaxListAttrValue($f3) { // 权限检查 $this->requirePrivilege('manage_goods_edit_edit_get', true); // 参数验证 $validator = new Validator($f3->get('GET')); $goods_id = $validator->required()->digits()->min(1)->validate('goods_id'); $typeId = $validator->required()->digits()->min(1)->validate('typeId'); $errorMessage = ''; if (!$this->validate($validator)) { $errorMessage = implode('|', $this->flashMessageArray); goto out_fail; } $goodsTypeService = new GoodsTypeService(); // 取得属性值的树形结构 $goodsAttrValueTreeTable = $goodsTypeService->fetchGoodsAttrItemValueTreeTable($goods_id, $typeId); out: Ajax::header(); echo Ajax::buildResult(null, null, $goodsAttrValueTreeTable); return; out_fail: Ajax::header(); echo Ajax::buildResult(-1, $errorMessage, null); }
/** * 上传一张图片 * * @param $f3 */ public function Upload($f3) { // 权限检查 $this->requirePrivilege('manage_goods_edit_edit_post'); // 参数验证 $errorMessage = ''; $validator = new Validator($f3->get('POST')); $goods_id = $validator->required('商品ID不能为空')->digits()->min(1)->validate('goods_id'); if (!$this->validate($validator)) { $errorMessage = "param goods_id does not exist"; goto out_fail; } // 上传路径 $dataPathRoot = $f3->get('sysConfig[data_path_root]'); if (empty($dataPathRoot)) { $dataPathRoot = $f3->get('BASE') . '/data'; } // 上传路径对应的 URL 前缀 $dataUrlPrefix = $f3->get('sysConfig[data_url_prefix]'); if (empty($dataUrlPrefix)) { $dataUrlPrefix = $f3->get('BASE') . '/data'; } // 我们的文件上传操作全部采用 KindEditor 来做 $kindEditor = new \KindEditor\KindEditor(); $fileInfo = $kindEditor->doAction($dataPathRoot, $dataUrlPrefix, 'upload'); // 文件上传之后调用后续处理,生成缩略图 // 上传文件相对 dataPathRoot 的文件名 $imageOriginalFileRelativeName = $fileInfo['relativeName']; $pathInfoArray = pathinfo($imageOriginalFileRelativeName); //生成头图 $imageFileRelativeName = $pathInfoArray['dirname'] . '/' . $pathInfoArray['filename'] . '_' . $f3->get('sysConfig[image_width]') . 'x' . $f3->get('sysConfig[image_height]') . '.jpg'; StorageImageHelper::resizeImage($dataPathRoot, $imageOriginalFileRelativeName, $imageFileRelativeName, $f3->get('sysConfig[image_width]'), $f3->get('sysConfig[image_height]')); //生成缩略图 $imageThumbFileRelativeName = $pathInfoArray['dirname'] . '/' . $pathInfoArray['filename'] . '_' . $f3->get('sysConfig[image_thumb_width]') . 'x' . $f3->get('sysConfig[image_thumb_height]') . '.jpg'; StorageImageHelper::resizeImage($dataPathRoot, $imageOriginalFileRelativeName, $imageThumbFileRelativeName, $f3->get('sysConfig[image_thumb_width]'), $f3->get('sysConfig[image_thumb_height]')); //保存 goods_gallery 记录 $goodsGalleryService = new GoodsGalleryService(); // ID 为0,返回一个新建的 dataMapper $goodsGallery = $goodsGalleryService->_loadById('goods_gallery', 'img_id=?', 0); $goodsGallery->goods_id = $goods_id; $goodsGallery->img_desc = $fileInfo['originalName']; $goodsGallery->img_original = $imageOriginalFileRelativeName; $goodsGallery->img_url = $imageFileRelativeName; $goodsGallery->thumb_url = $imageThumbFileRelativeName; $goodsGallery->save(); //清除缓存,确保商品显示正确 ClearHelper::clearGoodsCacheById($goods_id); return; out_fail: // 失败从这里返回 AjaxHelper::header(); echo json_encode(array('error' => 1, 'message' => $errorMessage)); }
/** * 列出订单的来源系统 * * @param $f3 */ public function ListOrderSystemId($f3) { // 检查缓存 $cacheKey = md5(__NAMESPACE__ . '\\' . __CLASS__ . '\\' . __METHOD__); $resultArray = $f3->get($cacheKey); if (!empty($resultArray)) { goto out; } $baseService = new BaseService(); $queryResult = $baseService->_fetchArray('order_info', 'distinct(system_id)', array(array('system_id is not null')), null, 0, 0); if (empty($queryResult)) { $resultArray = array(); goto out; } // 构造词库 foreach ($queryResult as $queryItem) { $wordArray[] = $queryItem['system_id']; } // 字典服务转换显示 $metaDictionaryService = new MetaDictionaryService(); $resultArray = $metaDictionaryService->getWordArray($wordArray); $f3->set($cacheKey, $resultArray, 600); //缓存 10 分钟 out: Ajax::header(); echo Ajax::buildResult(null, null, $resultArray); }
/** * 列出整个商品分类树 * * @param $f3 */ public function ListCategoryTree($f3) { // 检查缓存 $cacheKey = md5(__NAMESPACE__ . '\\' . __CLASS__ . '\\' . __METHOD__); if ($f3->get('GET[nocache]')) { goto nocache; } $categoryTreeDisplayArray = $f3->get($cacheKey); if (!empty($categoryTreeDisplayArray)) { goto out; } nocache: // 没有缓存数据 $categoryService = new CategoryService(); $categoryTreeArray = $categoryService->fetchCategoryTreeArray(0, true); //构造显示数组 $categoryTreeDisplayArray = array(); function buildTreeDisplay(&$categoryDisplayArray, $categoryArray, $namePrefix) { foreach ($categoryArray as $categoryItem) { $categoryItem['meta_name'] = $namePrefix . $categoryItem['meta_name'] . ($categoryItem['meta_status'] ? '' : '(不显示)'); $categoryDisplayArray[] = $categoryItem; if (isset($categoryItem['child_list'])) { buildTreeDisplay($categoryDisplayArray, $categoryItem['child_list'], $namePrefix . '---------->'); } } } buildTreeDisplay($categoryTreeDisplayArray, $categoryTreeArray, ''); $f3->set($cacheKey, $categoryTreeDisplayArray, 300); //缓存 5 分钟 out: if (!$f3->get('GET[nocache]')) { $f3->expire(60); // 客户端缓存 1 分钟 } Ajax::header(); echo Ajax::buildResult(null, null, $categoryTreeDisplayArray); }
/** * 增加商品关联 * * @param $f3 */ public function ajaxAddLink($f3) { // 权限检查 $this->requirePrivilege('manage_goods_edit_edit_post', true); // 首先做参数验证 $validator = new Validator($f3->get('GET')); $errorMessage = ''; $goods_id = $validator->required()->digits()->min(1)->validate('goods_id'); $link_goods_id = $validator->required()->digits()->min(1)->validate('link_goods_id'); if (!$this->validate($validator)) { $errorMessage = implode('|', $this->flashMessageArray); goto out_fail; } $dataMapper = new DataMapper('link_goods'); $dataMapper->loadOne(array('goods_id = ? and link_goods_id = ?', $goods_id, $link_goods_id)); // 已经关联了,不要重复关联 if (!$dataMapper->isEmpty()) { goto out; } $authAdminUser = AuthHelper::getAuthUser(); // 添加记录 $dataMapper->goods_id = $goods_id; $dataMapper->link_goods_id = $link_goods_id; $dataMapper->admin_id = $authAdminUser['user_id']; $dataMapper->save(); //清除缓存,确保商品显示正确 ClearHelper::clearGoodsCacheById($goods_id); // 记录商品编辑日志 $goodsLogService = new GoodsLogService(); $goodsLogService->addGoodsLog($goods_id, $authAdminUser['user_id'], $authAdminUser['user_name'], '添加商品关联', $link_goods_id); out: Ajax::header(); echo Ajax::buildResult(null, null, null); return; out_fail: // 失败,返回出错信息 Ajax::header(); echo Ajax::buildResult(-1, $errorMessage, null); }
/** * 设置订单的快递信息 * * @param $f3 */ public function ajaxUpdate($f3) { // 参数验证 $validator = new Validator($f3->get('POST')); $rec_id = $validator->required('子订单ID不能为空')->digits('子订单ID必须是数字')->min(1)->validate('rec_id'); $shipping_id = $validator->digits('快递ID必须是数字')->min(1)->validate('shipping_id'); $shipping_no = $validator->validate('shipping_no'); if (!$this->validate($validator)) { goto out_fail; } // 取 order_goods $orderBasicService = new OrderBasicService(); $orderGoods = $orderBasicService->loadOrderGoodsById($rec_id); if ($orderGoods->isEmpty()) { $this->addFlashMessage('非法订单'); goto out_fail; } // 权限检查 $authSupplierUser = AuthHelper::getAuthUser(); if ($orderGoods['suppliers_id'] !== $authSupplierUser['suppliers_id']) { $this->addFlashMessage('非法订单'); goto out_fail; } // 取得快递名 if ($shipping_id > 0) { //取得快递信息 $expressService = new ExpressService(); $expressInfo = $expressService->loadMetaById($shipping_id); if ($expressInfo->isEmpty() || ExpressService::META_TYPE != $expressInfo['meta_type']) { $this->addFlashMessage('快递ID非法'); goto out_fail; } $shipping_name = $expressInfo['meta_name']; } else { $shipping_name = null; } // 更新快递信息 $orderGoods->shipping_id = $shipping_id; $orderGoods->shipping_name = $shipping_name; $orderGoods->shipping_no = $shipping_no; $orderGoods->save(); // 更新 order_info 的 update_time 字段 $orderInfo = $orderBasicService->loadOrderInfoById($orderGoods['order_id']); $orderInfo->update_time = Time::gmTime(); $orderInfo->save(); // 添加订单操作日志 if ($shipping_id > 0) { $action_note = '' . $shipping_id . ',' . $shipping_name . ',' . $shipping_no; } else { $action_note = '删除快递信息'; } $orderActionService = new OrderActionService(); $orderActionService->logOrderAction($orderGoods['order_id'], $orderGoods['rec_id'], $orderInfo['order_status'], $orderInfo['pay_status'], $orderGoods['order_goods_status'], $action_note, '供货商:[' . $authSupplierUser['suppliers_id'] . ']' . $authSupplierUser['suppliers_name'], 0, $orderInfo['shipping_status']); Ajax::header(); echo Ajax::buildResult(null, null, null); return; // 成功从这里返回 out_fail: // 失败从这里退出 Ajax::header(); $errorMessage = ''; foreach ($this->flashMessageArray as $messageItem) { $errorMessage .= $messageItem . ','; } echo Ajax::buildResult(-1, $errorMessage, null); }
/** * 从购物车中删除某个商品 */ public function Remove($f3) { // 首先做参数合法性验证 $validator = new Validator($f3->get('GET')); $goods_id = $validator->required('商品ID不能为空')->digits('商品ID非法')->min(1, true, '商品ID非法')->validate('goods_id'); $specListStr = $validator->validate('specListStr'); if (!$this->validate($validator)) { goto out; } $cartBasicService = new CartBasicService(); $cartBasicService->loadFromStorage(); // 加载购物车的数据 $cartContext =& $cartBasicService->getCartContextRef(); $cartContext->removeGoods($goods_id, $specListStr); $cartBasicService->syncStorage(); // 重新保存数据 out: // ajax 操作 if ($f3->get('GET[isAjax]')) { Ajax::header(); if ($validator->hasErrors()) { $errorMessage = implode('|', $this->flashMessageArray); echo Ajax::buildResult(-1, $errorMessage, null); return; } echo Ajax::buildResult(null, null, null); return; } // 网页操作 RouteHelper::reRoute($this, '/Cart/Show'); }
public function ListAttrItem($f3) { // 参数验证 $validator = new Validator($f3->get('GET')); $meta_id = $validator->required()->digits()->min(1)->validate('typeId'); $errorMessage = ''; if (!$this->validate($validator)) { $errorMessage = implode('|', $this->flashMessageArray); goto out_fail; } // 检查缓存 $cacheKey = md5(__FILE__ . '\\' . __METHOD__ . '\\' . $meta_id); $attrItemArray = $f3->get($cacheKey); if (!empty($attrItemArray)) { goto out; } $goodsTypeService = new GoodsTypeService(); $attrItemArray = $goodsTypeService->fetchGoodsTypeAttrItemArray($meta_id); $f3->set($cacheKey, $attrItemArray, 300); //缓存 5 分钟 out: $f3->expire(60); // 客户端缓存 1 分钟 Ajax::header(); echo Ajax::buildResult(null, null, $attrItemArray); return; out_fail: Ajax::header(); echo Ajax::buildResult(-1, $errorMessage, null); }
public function post($f3) { // 这里操作加入购物车 // 首先做参数合法性验证 $validator = new Validator($f3->get('POST')); $goods_id = $validator->required('商品id不能为空')->digits('商品id非法')->min(1, true, '商品id非法')->validate('goods_id'); $goodsChooseSpecListStr = $validator->validate('goods_choose_speclist'); $goodsChooseBuyCount = $validator->required('商品最少购买 1 件')->digits('商品最少购买 1 件')->min(1, true, '商品最少购买 1 件')->validate('goods_choose_buycount'); if (!$this->validate($validator)) { goto out_fail; } // 查询商品信息 $goodsBasicService = new GoodsBasicService(); $goodsInfo = $goodsBasicService->loadGoodsById($goods_id); // 商品不存在,不允许显示等 if ($goodsInfo->isEmpty() || !$goodsInfo->is_on_sale || !Utils::isTagExist(PluginHelper::SYSTEM_MOBILE, $goodsInfo['system_tag_list'])) { $this->addFlashMessage('商品不存在或者不能购买'); goto out_fail; } $cartBasicService = new CartBasicService(); // 购物车服务 $cartBasicService->loadFromStorage(); // 恢复购物车中已有的数据 $cartContext =& $cartBasicService->getCartContextRef(); // 取得 cartContext // 商品多组合选择 if (!empty($goodsChooseSpecListStr)) { // 检查商品 Spec 是否合法 $goodsSpecService = new GoodsSpecService(); $goodsSpecService->initWithJson($goodsInfo['goods_spec']); $goodsSpecDataArray = $goodsSpecService->getGoodsSpecDataArray($goodsChooseSpecListStr); if (!$goodsSpecDataArray) { $this->addFlashMessage('商品选择[' . $goodsChooseSpecListStr . ']非法'); goto out_fail; } // 检查商品库存 if ($goodsChooseBuyCount > @$goodsSpecDataArray['goods_number']) { $this->addFlashMessage($goodsChooseSpecListStr . '库存不足,只剩 ' . @$goodsSpecDataArray['goods_number'] . ' 件'); goto out_fail; } // 商品加入到购物车 $cartContext->addGoods($goods_id, $goodsChooseBuyCount, $goodsChooseSpecListStr, @$goodsSpecDataArray['goods_sn']); } else { // 检查库存 if ($goodsChooseBuyCount > $goodsInfo['goods_number']) { $this->addFlashMessage('库存不足,剩余 ' . $goodsInfo['goods_number'] . ' 件'); goto out_fail; } // 普通简单选择,加入购物车 $cartContext->addGoods($goods_id, $goodsChooseBuyCount); } $cartBasicService->syncStorage(); // 保存购物车的数据 out: Ajax::header(); echo Ajax::buildResult(null, null, null); return; out_fail: // 失败,返回出错信息 $errorMessage = implode('|', $this->flashMessageArray); Ajax::header(); echo Ajax::buildResult(-1, $errorMessage, null); }
public function ListChildTreeNodeAllStr($f3) { // 参数验证 $validator = new Validator($f3->get('GET')); $errorMessage = ''; $treeKey = $validator->required()->validate('treeKey'); $parentId = $validator->digits()->min(0)->validate('parentId'); $parentId = $parentId ?: 0; // 用户也可以通过 treeNodeName 来做查询 $treeNodeName = $validator->validate('treeNodeName'); if (!$this->validate($validator)) { $errorMessage = implode('|', $this->flashMessageArray); goto out_fail; } // 检查缓存 $cacheKey = md5(__NAMESPACE__ . '\\' . __CLASS__ . '\\' . __METHOD__ . '\\' . $treeKey . '\\' . $parentId . '\\' . $treeNodeName); $outputArray = $f3->get($cacheKey); if (!empty($outputArray)) { goto out; } $metaTreeService = new MetaTreeService(); if (!empty($treeNodeName)) { $treeNode = $metaTreeService->loadTreeNodeWithTreeKeyAndName($treeKey, $treeNodeName); if (!$treeNode->isEmpty()) { $parentId = $treeNode['meta_id']; } } // 取得树形的层级结构 $treeNodeArray = $metaTreeService->fetchChildTreeNodeArrayAll($treeKey, $parentId); // 构建显示输出 $outputArray = array(); function buildHierarchyArray(&$outputArray, $treeNodeArray, $separator = '') { $hierarchySeparator = '---------->'; foreach ($treeNodeArray as $treeNodeItem) { $outputItem = array(); $outputItem['meta_id'] = $treeNodeItem['meta_id']; $outputItem['meta_name'] = $treeNodeItem['meta_name']; $outputItem['display_text'] = $separator . $treeNodeItem['meta_name']; $outputArray[] = $outputItem; // 有子节点,递归建立子节点 if (isset($treeNodeItem['child_list'])) { buildHierarchyArray($outputArray, $treeNodeItem['child_list'], $separator . $hierarchySeparator); } } } buildHierarchyArray($outputArray, $treeNodeArray, ''); $f3->set($cacheKey, $outputArray, 600); //缓存 10 分钟 out: Ajax::header(); echo Ajax::buildResult(null, null, $outputArray); return; out_fail: // 失败,返回出错信息 Ajax::header(); echo Ajax::buildResult(-1, $errorMessage, null); }
public function ListOrderGoodsSupplierIdName($f3) { // 参数验证 $validator = new Validator($f3->get('GET')); //表单查询 $formQuery = array(); // 是否这个列表是用于供货商订单结算 $supplierForSettle = $validator->validate('supplier_for_settle'); //付款时间 $payTimeStartStr = $validator->required()->validate('pay_time_start'); $payTimeStart = Time::gmStrToTime($payTimeStartStr) ?: null; $payTimeEndStr = $validator->required()->validate('pay_time_end'); $payTimeEnd = Time::gmStrToTime($payTimeEndStr) ?: null; $formQuery['pay_time'] = array($payTimeStart, $payTimeEnd); //额外退款时间 $extraRefundTimeStartStr = $validator->required()->validate('extra_refund_time_start'); $extraRefundTimeStart = Time::gmStrToTime($extraRefundTimeStartStr) ?: null; $extraRefundTimeEndStr = $validator->required()->validate('extra_refund_time_end'); $extraRefundTimeEnd = Time::gmStrToTime($extraRefundTimeEndStr) ?: null; $formQuery['extra_refund_time'] = array($extraRefundTimeStart, $extraRefundTimeEnd); if (!($payTimeStart && $payTimeEnd) && !($extraRefundTimeStart && $extraRefundTimeEnd)) { goto out_fail; } // 取得供货商 id $condArray = array(); $condArray[] = array('oi.order_id = og.order_id'); // 这个列表是用于供货商订单结算,只取得需要结算的供货商 if (!empty($supplierForSettle)) { //只有付款了订单才显示 $condArray[] = array('order_goods_status > 0'); //只有发货了订单才需要结算 $condArray[] = array('og.shipping_id > 0'); //商家结算过了就不要显示出来了 $condArray[] = array('settle_id = 0'); } // 表单查询 $condArray = array_merge($condArray, QueryBuilder::buildQueryCondArray($formQuery)); $orderGoodsService = new OrderGoodsService(); $queryArray = $orderGoodsService->_fetchArray(array('order_info' => 'oi', 'order_goods' => 'og'), 'distinct(og.suppliers_id)', $condArray, array('order' => 'suppliers_id desc'), 0, $f3->get('sysConfig[max_query_record_count]'), 0); //最多限制 max_query_record_count 条记录 // 取得供货商 id 列表 $supplierIdArray = array(); foreach ($queryArray as $queryItem) { $supplierIdArray[] = $queryItem['suppliers_id']; } if (empty($supplierIdArray)) { // 没有数据,退出 goto out_fail; } // 取得供货商信息 $userSupplierService = new UserSupplierService(); $queryArray = $userSupplierService->fetchSupplierArrayBySupplierIdArray($supplierIdArray); $supplierArray = array(); foreach ($queryArray as $queryItem) { $supplierItem = array(); $supplierItem['suppliers_id'] = $queryItem['suppliers_id']; $supplierItem['suppliers_account'] = $queryItem['suppliers_account']; $supplierItem['suppliers_name'] = $queryItem['suppliers_name']; $supplierArray[] = $supplierItem; } // 正常从这里返回 Ajax::header(); echo Ajax::buildResult(null, null, $supplierArray); return; out_fail: Ajax::header(); echo Ajax::buildResult(null, null, array()); }