From 300e5a691980491cf0fbd96e27056712df6ceb6c Mon Sep 17 00:00:00 2001 From: zengyyh Date: Wed, 28 Aug 2024 10:52:58 +0800 Subject: [PATCH] 1 --- app/api/controller/sharp/Goods.php | 7 +++++++ app/common/model/sharp/Goods.php | 7 ++++++- app/common/model/successful.php | 27 +++++++++++++++++++++++---- app/store/controller/Successful.php | 4 +--- 4 files changed, 37 insertions(+), 8 deletions(-) diff --git a/app/api/controller/sharp/Goods.php b/app/api/controller/sharp/Goods.php index a3df1f79..ee1535a5 100644 --- a/app/api/controller/sharp/Goods.php +++ b/app/api/controller/sharp/Goods.php @@ -18,6 +18,7 @@ use app\api\service\User as UserService; use app\api\service\sharp\Active as ActiveService; use app\common\service\qrcode\sharp\Goods as GoodsPoster; use cores\exception\BaseException; +use app\api\service\Setting as SettingService; /** * 整点秒杀-商品管理 @@ -57,6 +58,12 @@ class Goods extends Controller // 获取秒杀活动商品详情 $service = new ActiveService; $data = $service->getActiveGoodsDetail($activeTimeId, $sharpGoodsId); + $storeId = $data['active']['store_id']; + $merchantId = $data['goods']['merchant_id']; + //获取客服设置 + $service = new SettingService; + $setting = $service->getGoodsCustomer($merchantId,$storeId); + $data['setting'] = $setting; return $this->renderSuccess($data); } diff --git a/app/common/model/sharp/Goods.php b/app/common/model/sharp/Goods.php index 084920a2..5d0f01a2 100644 --- a/app/common/model/sharp/Goods.php +++ b/app/common/model/sharp/Goods.php @@ -112,7 +112,12 @@ class Goods extends BaseModel $item['goods_image'] = !empty($item['goods']['goods_image']) ? $item['goods']['goods_image'] : ''; // 秒杀商品原价 (获取主商品价格) //$item['original_price'] = !empty($item['goods']['original_price']) ? $item['goods']['original_price']: $item['goods']['goods_price_min']; - $item['original_price'] = isset($item['goods']['original_price']) ? $item['goods']['original_price'] : $item['goods']['goods_price_min']; + if (isset($item['goods']) && $item['goods'] !== null) { + $item['original_price'] = isset($item['goods']['original_price']) ? $item['goods']['original_price'] : $item['goods']['goods_price_min']; + } else { + // 可以设置一个默认值或处理逻辑 + $item['original_price'] = null; // 或者其他默认值 + } // 回调函数 is_callable($callback) && call_user_func($callback, $item); } diff --git a/app/common/model/successful.php b/app/common/model/successful.php index 85f55c0f..d901bca3 100644 --- a/app/common/model/successful.php +++ b/app/common/model/successful.php @@ -32,13 +32,13 @@ class successful extends BaseModel * @param array $param 查询参数 * @return \think\Paginator */ - public function list($page ,$pageSize): \think\Paginator + public function list(array $param): \think\Paginator { // 假设从数据库查询数据 - $query = self::order('sort', 'asc')->paginate($pageSize); - + $filter = $this->getFilter($param); // 使用分页方法 - return $query; + $list = $this->where($filter)->order('sort', 'asc')->paginate($param['pageSize'] ?? 15);; + return $list; } /** @@ -65,4 +65,23 @@ class successful extends BaseModel } return false; } + + /** + * 设置查询条件 + * @param array $param + * @return array + */ + private function getFilter(array $param): array + { + // 设置默认的检索数据 + $params = $this->setQueryDefaultValue($param, [ + 'successful' => '', // 查询内容 + ]); + // 检索查询条件 + $filter = []; + // 用户昵称/订单号 + !empty($params['successful']) && $filter[] = ['successful', 'like', "%{$params['successful']}%"]; + return $filter; + } + } \ No newline at end of file diff --git a/app/store/controller/Successful.php b/app/store/controller/Successful.php index 6ac4f2be..3832289f 100644 --- a/app/store/controller/Successful.php +++ b/app/store/controller/Successful.php @@ -25,9 +25,7 @@ class Successful extends Controller public function getList() { $model = new SuccessfulModel; - $page = $this->request->param('page',1); - $pageSize = $this->request->param('pageSize',15); - $list = $model->list($page,$pageSize); + $list = $model->list($this->request->param()); if(empty($list)){ return $this->renderSuccess('暂无数据'); }