210 lines
8.6 KiB
PHP
210 lines
8.6 KiB
PHP
<?php
|
|
/**
|
|
* SaaSMall商城系统 - 团队十年电商经验汇集巨献!
|
|
* =========================================================
|
|
* Copy right 2019-2029 成都SAAS云科技有限公司, 保留所有权利。
|
|
* ----------------------------------------------
|
|
* 官方网址: https://www.gobuysaas.com
|
|
* =========================================================
|
|
*/
|
|
namespace addon\topic\api\controller;
|
|
use addon\topic\model\Poster;
|
|
use addon\topic\model\Topic as TopicModel;
|
|
use addon\topic\model\TopicGoods as TopicGoodsModel;
|
|
use app\api\controller\BaseApi;
|
|
use app\api\controller\Goodssku;
|
|
use app\model\system\Promotion as PrmotionModel;
|
|
use app\model\web\DiyView as DiyViewModel;
|
|
|
|
/**
|
|
* 专题活动商品
|
|
*/
|
|
class Topicgoods extends BaseApi
|
|
{
|
|
|
|
/**
|
|
* 详情信息
|
|
*/
|
|
public function detail()
|
|
{
|
|
$id = isset($this->params['topic_id']) ? $this->params['topic_id'] : 0;
|
|
if (empty($id)) {
|
|
return $this->response($this->error('', 'REQUEST_ID'));
|
|
}
|
|
$topic_goods_model = new TopicGoodsModel();
|
|
$condition = [
|
|
['ptg.id', '=', $id],
|
|
['pt.status', '=', 2]
|
|
];
|
|
$goods_sku_detail = $topic_goods_model->getTopicGoodsDetail($condition)['data'];
|
|
if (empty($goods_sku_detail)) return $this->response($this->error());
|
|
$info = $this->defDiy();
|
|
if (!empty($goods_sku_detail['diy_id'])) {
|
|
$diy_view = new DiyViewModel();
|
|
$diyview[] = ['site_id', '=', $this->site_id];
|
|
$diyview[] = ['id', '=', 81];
|
|
$info = $diy_view->getSiteDiyViewDetail($diyview);
|
|
}
|
|
|
|
if($goods_sku_detail['topic_adv']){
|
|
$goods_sku_detail['sku_image'] =$goods_sku_detail['topic_adv'];
|
|
$goods_sku_detail['sku_images']=$goods_sku_detail['topic_adv'];
|
|
}
|
|
if($goods_sku_detail['content']){
|
|
$goods_sku_detail['goods_content']=$goods_sku_detail['content'];
|
|
}
|
|
$goods_sku_detail['goods_name']=$goods_sku_detail['topic_name'];
|
|
$goods_sku_detail['sku_name']=$goods_sku_detail['topic_name'];
|
|
|
|
$res['goods_sku_detail'] = $goods_sku_detail;
|
|
$diyData = json_decode($info['data']['value'], true);
|
|
if (!empty($goods_sku_detail['music_url'])) {
|
|
$diyData['value'][] = [
|
|
'imageSize' => 50,
|
|
'autoplay' => 1,
|
|
'bottomPosition' => 2,
|
|
'btnBottom' => 30,
|
|
'componentName' => 'Music',
|
|
'musicSrc' => $goods_sku_detail['music_url'],
|
|
'imageUrl' => 'upload/uniapp/music.png',
|
|
];
|
|
$res['goods_sku_detail']['diyData'] = $diyData;
|
|
}
|
|
if (!empty($goods_sku_detail['goods_spec_format'])) {
|
|
$goods_spec_format = $topic_goods_model->getGoodsSpecFormat($goods_sku_detail['topic_id'], $this->site_id, $goods_sku_detail['goods_spec_format']);
|
|
$res['goods_sku_detail']['goods_spec_format'] = json_encode($goods_spec_format);
|
|
}
|
|
// 处理公共数据
|
|
$goods_sku_api = new Goodssku();
|
|
$goods_sku_api->handleGoodsDetailData($res['goods_sku_detail']);
|
|
return $this->response($this->success($res));
|
|
}
|
|
|
|
|
|
public function defDiy()
|
|
{
|
|
$diy['value'] = '{"global":{"title":"默认模版","pageBgColor":"#FFFFFF","topNavColor":"#FFFFFF","topNavBg":false,"navBarSwitch":true,"navStyle":1,"textNavColor":"#333333","topNavImg":"","moreLink":{"name":""},"openBottomNav":true,"textImgPosLink":"center","mpCollect":false,"popWindow":{"imageUrl":"","count":-1,"isFull":-1,"autoClose":5,"background":"#FFFFFF","show":0,"link":{"name":""},"imgWidth":"","imgHeight":"","global.popWindow.background":"#FFFFFF"},"bgUrl":"","imgWidth":"","imgHeight":"","template":{"pageBgColor":"","textColor":"#303133","componentBgColor":"","componentAngle":"round","topAroundRadius":0,"bottomAroundRadius":0,"elementBgColor":"","elementAngle":"round","topElementAroundRadius":0,"bottomElementAroundRadius":0,"margin":{"top":0,"bottom":0,"both":0}}},"value":[]}';
|
|
return $this->success($diy);
|
|
}
|
|
|
|
/**
|
|
* 查询商品SKU集合
|
|
* @return false|string
|
|
*/
|
|
public function goodsSku()
|
|
{
|
|
$goods_id = isset($this->params['goods_id']) ? $this->params['goods_id'] : 0;
|
|
$topic_id = isset($this->params['topic_id']) ? $this->params['topic_id'] : 0;
|
|
|
|
if (empty($topic_id)) {
|
|
return $this->response($this->error('', 'REQUEST_ID'));
|
|
}
|
|
if (empty($goods_id)) {
|
|
return $this->response($this->error('', 'REQUEST_ID'));
|
|
}
|
|
$topic_goods_model = new TopicGoodsModel();
|
|
$condition = [
|
|
['ptg.topic_id', '=', $topic_id],
|
|
['ptg.goods_id', '=', $goods_id],
|
|
['pt.status', '=', 2]
|
|
];
|
|
$list = $topic_goods_model->getTopicGoodsSkuList($condition);
|
|
if (!empty($list['data'])) {
|
|
foreach ($list['data'] as $k => $v) {
|
|
if (!empty($v['goods_spec_format'])) {
|
|
$goods_spec_format = $topic_goods_model->getGoodsSpecFormat($v['topic_id'], $this->site_id, $v['goods_spec_format']);
|
|
$list['data'][$k]['goods_spec_format'] = json_encode($goods_spec_format);
|
|
}
|
|
}
|
|
}
|
|
|
|
return $this->response($list);
|
|
}
|
|
|
|
/**
|
|
* 【废弃】获取商品基本信息
|
|
* @return false|string
|
|
*/
|
|
public function info()
|
|
{
|
|
$sku_id = isset($this->params['sku_id']) ? $this->params['sku_id'] : 0;
|
|
$topic_id = isset($this->params['topic_id']) ? $this->params['topic_id'] : 0;
|
|
if (empty($sku_id)) {
|
|
return $this->response($this->error('', 'REQUEST_SKU_ID'));
|
|
}
|
|
if (empty($topic_id)) {
|
|
return $this->response($this->error('', 'REQUEST_ID'));
|
|
}
|
|
|
|
$topic_goods_model = new TopicGoodsModel();
|
|
$condition = [
|
|
['ptg.topic_id', '=', $topic_id],
|
|
['ptg.sku_id', '=', $sku_id],
|
|
['pt.status', '=', 2]
|
|
];
|
|
$goods_sku_detail = $topic_goods_model->getTopicGoodsDetail($condition);
|
|
$goods_sku_detail = $goods_sku_detail['data'];
|
|
$res['goods_sku_detail'] = $goods_sku_detail;
|
|
if (!empty($goods_sku_detail)) {
|
|
$goods_spec_format = $topic_goods_model->getGoodsSpecFormat($goods_sku_detail['topic_id'], $this->site_id, $goods_sku_detail['goods_spec_format']);
|
|
$res['goods_sku_detail']['goods_spec_format'] = json_encode($goods_spec_format);
|
|
} else {
|
|
$sku_id = $topic_goods_model->getGoodsSpecFormat($topic_id, $this->site_id, '', $sku_id);
|
|
$res = ['type' => 'again', 'sku_id' => $sku_id];
|
|
}
|
|
|
|
return $this->response($this->success($res));
|
|
}
|
|
|
|
/**
|
|
* 列表信息
|
|
*/
|
|
public function page()
|
|
{
|
|
$topic_id = isset($this->params['topic_id']) ? $this->params['topic_id'] : 0;
|
|
$page = isset($this->params['page']) ? $this->params['page'] : 1;
|
|
$page_size = isset($this->params['page_size']) ? $this->params['page_size'] : PAGE_LIST_ROWS;
|
|
|
|
if (empty($topic_id)) {
|
|
return $this->response($this->error('', 'REQUEST_TOPIC_ID'));
|
|
}
|
|
$condition = [
|
|
['nptg.topic_id', '=', $topic_id],
|
|
['ngs.goods_state', '=', 1],
|
|
['ngs.is_delete', '=', 0],
|
|
['nptg.default', '=', 1]
|
|
];
|
|
$order = 'nptg.id asc';
|
|
$topic_goods_model = new TopicGoodsModel();
|
|
|
|
$topic_model = new TopicModel();
|
|
$info = $topic_model->getTopicInfo([["topic_id", "=", $topic_id]], 'bg_color,topic_adv,topic_name');
|
|
$info = $info['data'];
|
|
|
|
$res = $topic_goods_model->getTopicGoodsPageList($condition, $page, $page_size, $order);
|
|
// $res[ 'data' ][ 'bg_color' ] = $info[ 'bg_color' ];
|
|
$res['data']['topic_adv'] = $info['topic_adv'];
|
|
$res['data']['topic_name'] = $info['topic_name'];
|
|
|
|
$promotion_model = new PrmotionModel();
|
|
$zone_config = $promotion_model->getPromotionZoneConfig('topic', $this->site_id)['data']['value'];
|
|
$res['data']['bg_color'] = $zone_config['bg_color'];
|
|
|
|
return $this->response($res);
|
|
}
|
|
|
|
/**
|
|
* 获取商品海报
|
|
*/
|
|
public function poster()
|
|
{
|
|
$this->checkToken();
|
|
$promotion_type = 'topic';
|
|
$qrcode_param = json_decode($this->params['qrcode_param'], true);
|
|
$qrcode_param['source_member'] = $this->member_id;
|
|
$poster = new Poster();
|
|
$res = $poster->goods($this->params['app_type'], $this->params['page'], $qrcode_param, $promotion_type, $this->site_id);
|
|
return $this->response($res);
|
|
}
|
|
}
|