successful([]); return app('json')->successful($combinationList->hidden(['info', 'product_id', 'start_time', 'stop_time', 'effective_time', 'images', 'mer_id', 'attr', 'sort', 'stock', 'add_time', 'is_del', 'is_show', 'browse', 'cost', 'is_show', 'postage', 'is_postage', 'is_host', 'mer_use', 'combination'])->toArray()); } /** * 活动商品详情 * @param Request $request * @param $id * @return mixed * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ public function detail(Request $request, $id) { if (!$id || !($combinationOne = StoreActivityProductModel::getActivityOne($id))) return app('json')->fail('活动商品不存在或已下架'); // echo 'ok';die; $combinationOne = $combinationOne->hidden(['mer_id', 'attr', 'sort', 'start_time', 'stop_time', 'effective_time', 'add_time', 'is_host', 'is_show', 'is_del', 'mer_use', 'cost', 'combination'])->toArray(); $combinationOne['images'] = json_decode($combinationOne['images'], true); $siteUrl = sys_config('site_url'); $combinationOne['image'] = set_file_url($combinationOne['image'], $siteUrl); $combinationOne['image_base'] = set_file_url($combinationOne['image'], $siteUrl); $combinationOne['code_base'] = QrcodeService::getWechatQrcodePath($id . '_activity_detail_wap.jpg', '/activity/group_detail/' . $id); $combinationOne['sale_stock'] = 0; if ($combinationOne['stock'] > 0) $combinationOne['sale_stock'] = 1; if (!strlen(trim($combinationOne['unit_name']))) $combinationOne['unit_name'] = '个'; $uid = $request->uid(); $combinationOne['userCollect'] = StoreProductRelation::isProductRelation($combinationOne['id'], $uid, 'collect', 'activity'); $combinationOne['description'] = htmlspecialchars_decode(StoreDescription::getDescription($id, 4)); $data['storeInfo'] = $combinationOne; // $data['reply'] = StoreProductReply::getRecProductReply($combinationOne['product_id']); // $data['replyCount'] = StoreProductReply::productValidWhere()->where('product_id', $combinationOne['product_id'])->count(); // if ($data['replyCount']) { // $goodReply = StoreProductReply::productValidWhere()->where('product_id', $combinationOne['product_id'])->where('product_score', 5)->count(); // $data['replyChance'] = $goodReply; // if ($goodReply) { // $data['replyChance'] = bcdiv($goodReply, $data['replyCount'], 2); // $data['replyChance'] = bcmul($data['replyChance'], 100, 3); // } // } else $data['replyChance'] = 0; list($productAttr, $productValue) = StoreProductAttr::getProductAttrDetail($id, $uid, 0, 4); foreach ($productValue as $k => $v) { $productValue[$k]['product_stock'] = StoreProductAttrValue::where('product_id', $combinationOne['product_id'])->where('type', 4)->where('suk', $v['suk'])->value('stock'); } $data['productAttr'] = $productAttr; $data['productValue'] = $productValue; $data['activity'] = StoreActivity::where("id={$combinationOne['aid']}")->find(); return app('json')->successful($data); } }