data_post['goods_id']))
{
return DataReturn('参数有误', -1);
}
// 商品详情方式
$is_use_mobile_detail = intval(MyC('common_app_is_use_mobile_detail'));
// 获取商品
$goods_id = intval($this->data_post['goods_id']);
$params = [
'where' => [
'id' => $goods_id,
'is_delete_time' => 0,
],
'is_photo' => true,
'is_spec' => true,
'is_content_app' => ($is_use_mobile_detail == 1),
];
$ret = GoodsService::GoodsList($params);
if(empty($ret['data'][0]) || $ret['data'][0]['is_delete_time'] != 0)
{
return DataReturn('商品不存在或已删除', -1);
}
// 商品详情处理
if($is_use_mobile_detail == 1)
{
unset($ret['data'][0]['content_web']);
} else {
// 标签处理,兼容小程序rich-text
$search = [
'
',
'
',
'
',
'
',
'',
'
',
'
$goods_id, 'user'=>$this->user]);
$ret['data'][0]['is_favor'] = ($ret_favor['code'] == 0) ? $ret_favor['data'] : 0;
// 商品评价总数
$ret['data'][0]['comments_count'] = GoodsCommentsService::GoodsCommentsTotal(['goods_id'=>$goods_id, 'is_show'=>1]);
// 商品访问统计
GoodsService::GoodsAccessCountInc(['goods_id'=>$goods_id]);
// 用户商品浏览
GoodsService::GoodsBrowseSave(['goods_id'=>$goods_id, 'user'=>$this->user]);
// 商品所属分类名称
$category = GoodsService::GoodsCategoryNames($goods_id);
$ret['data'][0]['category_names'] = $category['data'];
// 数据返回
$result = [
'goods' => $ret['data'][0],
'common_order_is_booking' => (int) MyC('common_order_is_booking'),
'common_app_is_use_mobile_detail' => $is_use_mobile_detail,
'common_app_is_online_service' => (int) MyC('common_app_is_online_service'),
'common_app_is_limitedtimediscount' => (int) MyC('common_app_is_limitedtimediscount'),
'common_app_is_good_thing' => (int) MyC('common_app_is_good_thing'),
'common_app_is_poster_share' => (int) MyC('common_app_is_poster_share'),
'common_cart_total' => BuyService::UserCartTotal(['user'=>$this->user]),
// 优惠劵
'plugins_coupon_data' => $this->PluginsCouponGoods($goods_id),
];
// 秒杀
if($result['common_app_is_limitedtimediscount'] == 1)
{
$ret = CallPluginsServiceMethod('limitedtimediscount', 'Service', 'GoodsDetailCountdown', $goods_id);
if($ret['code'] == 0)
{
$result['plugins_limitedtimediscount_data'] = $ret['data'];
}
}
return DataReturn('success', 0, $result);
}
/**
* 商品详情优惠劵
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2019-10-17
* @desc description
* @param [int] $goods_id [商品id]
*/
private function PluginsCouponGoods($goods_id)
{
// 获取基础配置信息
$base = CallPluginsData('coupon');
// 优惠劵列表
$coupon_params = [
'where' => [
'is_enable' => 1,
'is_user_receive' => 1,
],
'm' => 0,
'n' => 0,
'is_sure_receive' => 1,
'user' => $this->user,
];
$ret = CallPluginsServiceMethod('coupon', 'CouponService', 'CouponList', $coupon_params);
// 排除商品不支持的活动
if(!empty($ret['data']))
{
$ret['data'] = CallPluginsServiceMethod('coupon', 'BaseService', 'CouponListGoodsExclude', ['data'=>$ret['data'], 'goods_id'=>$goods_id]);
}
// 返回数据
return [
'base' => $base['data'],
'data' => $ret['data'],
];
}
/**
* 用户商品收藏
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2018-07-17
* @desc description
*/
public function Favor()
{
// 登录校验
$this->IsLogin();
// 开始操作
$params = $this->data_post;
$params['user'] = $this->user;
return GoodsService::GoodsFavor($params);
}
/**
* 商品规格类型
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2018-12-14
* @desc description
*/
public function SpecType()
{
// 开始处理
$params = $this->data_post;
$ret = GoodsService::GoodsSpecType($params);
if($ret['code'] == 0)
{
$ret['data'] = $ret['data']['spec_type'];
}
return $ret;
}
/**
* 商品规格信息
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2018-12-14
* @desc description
*/
public function SpecDetail()
{
// 开始处理
$params = $this->data_post;
$ret = GoodsService::GoodsSpecDetail($params);
if($ret['code'] == 0)
{
$ret['data'] = $ret['data']['spec_base'];
}
return $ret;
}
/**
* 商品分类
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2018-12-14
* @desc description
*/
public function Category()
{
// 开始处理
$params = $this->data_post;
$data = GoodsService::GoodsCategory($params);
return DataReturn('success', 0, $data);
}
/**
* 商品评分
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2019-07-11
* @desc description
* @return [type] [description]
*/
public function GoodsScore()
{
if(empty($this->data_post['goods_id']))
{
return DataReturn('参数有误', -1);
}
// 获取商品评分
return GoodsCommentsService::GoodsCommentsScore($this->data_post['goods_id']);
}
/**
* 商品评论
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @datetime 2019-05-13T21:47:41+0800
*/
public function Comments()
{
// 参数
$params = $this->data_post;
// 分页
$number = 10;
$page = max(1, isset($params['page']) ? intval($params['page']) : 1);
// 条件
$where = [
'goods_id' => $params['goods_id'],
'is_show' => 1,
];
// 获取总数
$total = GoodsCommentsService::GoodsCommentsTotal($where);
$page_total = ceil($total/$number);
$start = intval(($page-1)*$number);
// 获取列表
$data_params = array(
'm' => $start,
'n' => $number,
'where' => $where,
'is_public' => 1,
);
$data = GoodsCommentsService::GoodsCommentsList($data_params);
// 返回数据
$result = [
'number' => $number,
'total' => $total,
'page_total' => $page_total,
'data' => $data['data'],
];
return DataReturn('success', 0, $result);
}
/**
* 商品海报
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @datetime 2019-08-17T21:10:41+0800
*/
public function Poster()
{
// 是否开启海报功能
if(MyC('common_app_is_poster_share') == 1)
{
return CallPluginsServiceMethod('distribution', 'PosterGoodsService', 'GoodsCreateMiniWechat', $this->data_post);
}
return DataReturn('海报功能未启用', -100);
}
}
?>