/**
* 商品详情页
* $goods_id 商品id
*/
public function detail()
{
$goods_id = $this->input->get('goodsId');
$user_id = $this->input->get('userId');
$user_key = $this->input->get('userKey');
if (!$goods_id) {
//提示错误
error_output("参数错误");
} else {
// 是否检查用户已买过
$is_check_user_bought = 0;
$goods_info = $this->goods_model->get_detail($goods_id);
if (!$goods_info) {
error_output('商品不存在');
}
// 如果有传参用户ID和用户Key
if ($user_id && $user_key) {
// 验证user_key是否正确
if (!$this->users_model->get_user_by_user_id_and_user_key($user_id, $user_key)) {
error_output('userKey验证失败');
}
$is_check_user_bought = 1;
}
$result = array(
'status' => 1,
'id' => $goods_info['goods_id'],
'name' => $goods_info['goods_name'],
'desc' => $goods_info['goods_desc'],
'marketPrice' => $goods_info['market_price'],
'discountPrice1' => $goods_info['discount_price1'],
'discountPrice2' => $goods_info['discount_price2'],
'stock' => $goods_info['stock'],
'payType' => $goods_info['pay_type'],
'thumbPicUrl' => json_decode($goods_info['goods_thumb_img']),
'picUrls' => json_decode($goods_info['goods_img_path']),
'discountStartTime' => $goods_info['discount_start_time']*1000, //毫秒
'discountEndTime' => $goods_info['discount_end_time']*1000, //毫秒
);
$partner_info = $this->partners_model->get_detail($goods_info['partner_id']);
if($partner_info)
{
$result['partnerName'] = $partner_info['partner_name'];
$result['partnerLogo'] = $partner_info['partner_logo'];
//$result['partnerUrl'] = $partner_info['partner_url'];
$result['partnerUrl'] = "http://localhost/skill/partner/bingdian.html";
$result['weixinCode'] = $partner_info['weixin_code'];
}
$tv_info = $this->tv_model->get_detail($goods_info['tv_id']);
if($tv_info)
{
$result['tvId'] = $tv_info['tv_id'];
$result['tvName'] = $tv_info['tv_name'];
$result['tvAbbreviate'] = $tv_info['tv_abbreviate'];
}
$array = array(1,'2';34f3);
$result['isBought'] = 0;
$result['isKillButNoPay'] = 0;
if ($is_check_user_bought) {
// 判断用户是否已秒杀过该商品但是未支付
if ($this->orders_goods_model->check_user_is_kill_but_no_pay($user_id, $goods_id)) {
$result['isKillButNoPay'] = 1;
}
// 判断用户是否已买过该商品
if ($this->orders_goods_model->check_user_bought_goods($user_id, $goods_id)) {
$result['isBought'] = 1;
}
}
json_output($result);
}
}
商品详情接口
最新推荐文章于 2024-04-25 13:46:04 发布