diff --git a/app/api/controller/Controller.php b/app/api/controller/Controller.php index f6306b69..14cbff55 100644 --- a/app/api/controller/Controller.php +++ b/app/api/controller/Controller.php @@ -121,9 +121,9 @@ class Controller extends BaseController if (!class_exists($item['class'])) { throwError("很抱歉,当前{$item['name']}不存在"); } - if (!call_user_func([$item['class'], $item['method']])) { - throwError("很抱歉,当前{$item['name']}暂未开启访问"); - } +// if (!call_user_func([$item['class'], $item['method']])) { +// throwError("很抱歉,当前{$item['name']}暂未开启访问"); +// } if (!empty($item['moduleKey']) && !StoreModuleModel::checkModuleKey($item['moduleKey'])) { throwError("很抱歉,当前{$item['name']}暂不支持访问"); } diff --git a/app/api/controller/Goods.php b/app/api/controller/Goods.php index 424de86e..b6b17ce5 100644 --- a/app/api/controller/Goods.php +++ b/app/api/controller/Goods.php @@ -243,6 +243,13 @@ class Goods extends Controller return $this->renderSuccess($goodsList); } + public function hotWord(): Json + { + $service = new GoodsService; + $list = $service->hotWord($this->request->param('page')); + return $this->renderSuccess($list); + } + /** * 生成商品海报 diff --git a/app/api/service/Goods.php b/app/api/service/Goods.php index 5e0d104a..78ba2d52 100644 --- a/app/api/service/Goods.php +++ b/app/api/service/Goods.php @@ -18,6 +18,7 @@ use app\api\model\GoodsSku as GoodsSkuModel; use app\api\model\Category as CategoryModel; use app\api\service\User as UserService; use app\common\model\store\Shop as ShopModel; +use app\common\model\goods\GoodsHotWord; use app\api\service\sharp\Active as ActiveService; use app\common\enum\Setting as SettingEnum; use app\common\service\Goods as GoodsService; @@ -203,29 +204,38 @@ class Goods extends GoodsService public function cityInfo($storeid): array { $model = new ShopModel; - $info = $model->where([ + $info = $model->with(['wechatImage'])->where([ 'is_delete' => 0, 'status' => 1, 'store_id' => $storeid, 'is_main' => 1, ])->field('shop_name,star,shop_hours,summary,phone, - province_id,city_id,region_id,shop_id,address,latitude,longitude')->find()->toArray(); + province_id,city_id,region_id,shop_id,address,latitude,longitude,wechat_img_id,history1,history2,history3,remark')->find()->toArray(); //todo wmc - $info['remark'] = ['手机选购', '电脑选购']; - $info['star'] = 5; + $info['remark'] = json_decode($info['remark']); $info['fuwu_hours'] = 5; $info['fuwu_num'] = 15; - $info['star'] = 5; - $info['wechat'] = 'https://www.saas.njrenzhou.com/uploads/10001/20240127/12bb1b1747e652d258443247a5c4777c.png'; - $info['history'] = ['time' => '2022-01-01', 'contenmt' => 'yml与2000年成立']; - $info['evaluate'] = [ - 'image' => 'https://www.saas.njrenzhou.com/uploads/10001/20240116/18adc22ad9ea021ab2586878fe1035b0.png', + // $info['wechat'] = 'https://www.saas.njrenzhou.com/uploads/10001/20240127/12bb1b1747e652d258443247a5c4777c.png'; + $history = []; + if (!empty($info['history1'])) { + $history[] = json_decode($info['history1'], true); + } + if (!empty($info['history2'])) { + $history[] = json_decode($info['history2'], true); + } + if (!empty($info['history3'])) { + $history[] = json_decode($info['history3'], true); + } + $info['history'] = $history; + // $info['history'] = ['time' => '2023-01-01', 'contenmt' => 'yml上市']; + $info['evaluate'][] = [ + 'image' => 'http://qiniu.shop.royaum.com.cn/10001/20240201/13f2e675794e25176352fc039dfb6dcb.jpg', 'nickname' => 'wmc', 'content' => '很好', ]; $info['imageList'] = [ - 'https://www.saas.njrenzhou.com/uploads/10001/20240116/18adc22ad9ea021ab2586878fe1035b0.png', - 'https://www.saas.njrenzhou.com/uploads/10001/20240116/18adc22ad9ea021ab2586878fe1035b0.png' + 'http://qiniu.shop.royaum.com.cn/10001/20240201/13f2e675794e25176352fc039dfb6dcb.jpg', + 'http://qiniu.shop.royaum.com.cn/10001/20240201/13f2e675794e25176352fc039dfb6dcb.jpg' ]; //读取门店停车场 @@ -238,6 +248,16 @@ class Goods extends GoodsService return $info; } + public function hotWord($page): array + { + if(empty($page) || $page == 1){ + $offset = 0; + }else{ + $offset = $page * 5; + } + return GoodsHotWord::order('sort desc')->limit($offset,5)->select()->toArray(); + } + // //抢购会场列表 // public function panicList() // { diff --git a/app/common/model/goods/GoodsHotWord.php b/app/common/model/goods/GoodsHotWord.php new file mode 100644 index 00000000..3759c586 --- /dev/null +++ b/app/common/model/goods/GoodsHotWord.php @@ -0,0 +1,30 @@ + +// +---------------------------------------------------------------------- +declare (strict_types=1); + +namespace app\common\model\goods; + +use cores\BaseModel; +use think\model\relation\HasOne; + +/** + * 商品服务与承诺模型 + * Class Service + */ +class GoodsHotWord extends BaseModel +{ + // 定义表名 + protected $name = 'goods_hot_word'; + + // 定义主键 + protected $pk = 'id'; + +} diff --git a/app/common/model/store/Shop.php b/app/common/model/store/Shop.php index a32955fa..649c84e6 100644 --- a/app/common/model/store/Shop.php +++ b/app/common/model/store/Shop.php @@ -46,6 +46,18 @@ class Shop extends BaseModel ->bind(['logo_url' => 'preview_url']); } + + /** + * 关联文章封面图 + * @return HasOne + */ + public function wechatImage(): HasOne + { + $module = self::getCalledModule(); + return $this->hasOne("app\\{$module}\\model\\UploadFile", 'file_id', 'wechat_img_id') + ->bind(['wechat' => 'preview_url']); + } + /** * 获取器:省市区id集 * @param $value