|
@@ -126,66 +126,67 @@ class StoreProductController
|
|
|
*/
|
|
|
public function detail(Request $request, $id, $type = 0)
|
|
|
{
|
|
|
- try {
|
|
|
- if ($request->isLogin())
|
|
|
- $user = $request->user();
|
|
|
- if (!$id || !($storeInfo = StoreProduct::getValidProduct($id, $user['sp_user'] ?? 0))) return app('json')->fail('商品不存在或已下架');
|
|
|
- $siteUrl = sys_config('site_url');
|
|
|
- $storeInfo['image'] = set_file_url($storeInfo['image'], $siteUrl);
|
|
|
- $storeInfo['image_base'] = set_file_url($storeInfo['image'], $siteUrl);
|
|
|
- $storeInfo['code_base'] = QrcodeService::getWechatQrcodePath($id . '_product_detail_wap.jpg', '/detail/' . $id);
|
|
|
- $uid = $request->uid();
|
|
|
- $data['uid'] = $uid;
|
|
|
- $storeInfo['description'] = htmlspecialchars_decode(StoreDescription::getDescription($id));
|
|
|
-
|
|
|
- $storeInfo['description'] = preg_replace_callback('#<img.*?src="([^"]*)"[^>]*>#i', function ($imagsSrc) {
|
|
|
- return isset($imagsSrc[1]) && isset($imagsSrc[0]) ? str_replace($imagsSrc[1], str_replace('\\', '/', $imagsSrc[1]), $imagsSrc[0]) : '';
|
|
|
- }, $storeInfo['description']);
|
|
|
- $storeInfo['userCollect'] = StoreProductRelation::isProductRelation($id, $uid, 'collect');
|
|
|
- $storeInfo['userLike'] = StoreProductRelation::isProductRelation($id, $uid, 'like');
|
|
|
- list($productAttr, $productValue) = StoreProductAttr::getProductAttrDetail($id, $uid, $type);
|
|
|
- StoreVisit::setView($uid, $id, $storeInfo['cate_id'], 'viwe');
|
|
|
- $data['storeInfo'] = StoreProduct::setLevelPrice($storeInfo, $uid, true);
|
|
|
- $data['similarity'] = StoreProduct::cateIdBySimilarityProduct($storeInfo['cate_id'], 'id,store_name,image,price,sales,ficti', 4, $uid());
|
|
|
- $data['productAttr'] = $productAttr;
|
|
|
- $data['productValue'] = $productValue;
|
|
|
- $data['priceName'] = 0;
|
|
|
- if ($uid) {
|
|
|
- $user = $request->user();
|
|
|
- if (!$user->is_promoter) {
|
|
|
- $price = StoreOrder::where(['paid' => 1, 'refund_status' => 0, 'uid' => $uid])->sum('pay_price');
|
|
|
- $status = is_brokerage_statu($price);
|
|
|
- if ($status) {
|
|
|
- User::where('uid', $uid)->update(['is_promoter' => 1]);
|
|
|
- $user->is_promoter = 1;
|
|
|
- }
|
|
|
- }
|
|
|
- if ($user->is_promoter) {
|
|
|
- $data['priceName'] = StoreProduct::getPacketPrice($storeInfo, $productValue);
|
|
|
+ if ($request->isLogin())
|
|
|
+ $user = $request->user();
|
|
|
+ if (!$id || !($storeInfo = StoreProduct::getValidProduct($id, $user['sp_user'] ?? 0))) return app('json')->fail('商品不存在或已下架');
|
|
|
+ $siteUrl = sys_config('site_url');
|
|
|
+ $storeInfo['image'] = set_file_url($storeInfo['image'], $siteUrl);
|
|
|
+ $storeInfo['image_base'] = set_file_url($storeInfo['image'], $siteUrl);
|
|
|
+ $storeInfo['code_base'] = QrcodeService::getWechatQrcodePath($id . '_product_detail_wap.jpg', '/detail/' . $id);
|
|
|
+ $uid = $request->uid();
|
|
|
+ $data['uid'] = $uid;
|
|
|
+ var_dump(11);
|
|
|
+ $storeInfo['description'] = htmlspecialchars_decode(StoreDescription::getDescription($id));
|
|
|
+
|
|
|
+ $storeInfo['description'] = preg_replace_callback('#<img.*?src="([^"]*)"[^>]*>#i', function ($imagsSrc) {
|
|
|
+ return isset($imagsSrc[1]) && isset($imagsSrc[0]) ? str_replace($imagsSrc[1], str_replace('\\', '/', $imagsSrc[1]), $imagsSrc[0]) : '';
|
|
|
+ }, $storeInfo['description']);
|
|
|
+ $storeInfo['userCollect'] = StoreProductRelation::isProductRelation($id, $uid, 'collect');
|
|
|
+ $storeInfo['userLike'] = StoreProductRelation::isProductRelation($id, $uid, 'like');
|
|
|
+ list($productAttr, $productValue) = StoreProductAttr::getProductAttrDetail($id, $uid, $type);
|
|
|
+ StoreVisit::setView($uid, $id, $storeInfo['cate_id'], 'viwe');
|
|
|
+ var_dump(22);
|
|
|
+ $data['storeInfo'] = StoreProduct::setLevelPrice($storeInfo, $uid, true);
|
|
|
+ $data['similarity'] = StoreProduct::cateIdBySimilarityProduct($storeInfo['cate_id'], 'id,store_name,image,price,sales,ficti', 4, $uid());
|
|
|
+ $data['productAttr'] = $productAttr;
|
|
|
+ $data['productValue'] = $productValue;
|
|
|
+ $data['priceName'] = 0;
|
|
|
+ if ($uid) {
|
|
|
+ $user = $request->user();
|
|
|
+ if (!$user->is_promoter) {
|
|
|
+ $price = StoreOrder::where(['paid' => 1, 'refund_status' => 0, 'uid' => $uid])->sum('pay_price');
|
|
|
+ $status = is_brokerage_statu($price);
|
|
|
+ if ($status) {
|
|
|
+ User::where('uid', $uid)->update(['is_promoter' => 1]);
|
|
|
+ $user->is_promoter = 1;
|
|
|
}
|
|
|
- if (!strlen(trim($data['priceName'])))
|
|
|
- $data['priceName'] = 0;
|
|
|
}
|
|
|
- $data['reply'] = StoreProductReply::getRecProductReply($storeInfo['id']);
|
|
|
- $data['replyCount'] = StoreProductReply::productValidWhere()->where('product_id', $storeInfo['id'])->count();
|
|
|
- if ($data['replyCount']) {
|
|
|
- $goodReply = StoreProductReply::productValidWhere()->where('product_id', $storeInfo['id'])->where('product_score', 5)->count();
|
|
|
- $data['replyChance'] = $goodReply;
|
|
|
- if ($goodReply) {
|
|
|
- $data['replyChance'] = bcdiv($goodReply, $data['replyCount'], 2);
|
|
|
- $data['replyChance'] = bcmul($data['replyChance'], 100, 2);
|
|
|
- }
|
|
|
- } else $data['replyChance'] = 0;
|
|
|
- $data['mer_id'] = $storeInfo['mer_id'];
|
|
|
- $data['system_store'] = ($res = SystemStore::getStoreDispose()) ? $res : [];
|
|
|
- $data['good_list'] = StoreProduct::getGoodList(18, $user['sp_user'] ?? 0, 'image,store_name,price,id,ot_price');
|
|
|
- $data['mapKey'] = sys_config('tengxun_map_key');
|
|
|
- $data['store_self_mention'] = (int)sys_config('store_self_mention') ?? 0;
|
|
|
- $data['activity'] = StoreProduct::activity($data['storeInfo']['id'], false);
|
|
|
- return app('json')->successful($data);
|
|
|
- }catch (Exception $exception){
|
|
|
- var_dump($exception->getTrace());
|
|
|
+ if ($user->is_promoter) {
|
|
|
+ $data['priceName'] = StoreProduct::getPacketPrice($storeInfo, $productValue);
|
|
|
+ }
|
|
|
+ if (!strlen(trim($data['priceName'])))
|
|
|
+ $data['priceName'] = 0;
|
|
|
}
|
|
|
+ var_dump(331);
|
|
|
+ $data['reply'] = StoreProductReply::getRecProductReply($storeInfo['id']);
|
|
|
+ $data['replyCount'] = StoreProductReply::productValidWhere()->where('product_id', $storeInfo['id'])->count();
|
|
|
+ if ($data['replyCount']) {
|
|
|
+ $goodReply = StoreProductReply::productValidWhere()->where('product_id', $storeInfo['id'])->where('product_score', 5)->count();
|
|
|
+ $data['replyChance'] = $goodReply;
|
|
|
+ if ($goodReply) {
|
|
|
+ $data['replyChance'] = bcdiv($goodReply, $data['replyCount'], 2);
|
|
|
+ $data['replyChance'] = bcmul($data['replyChance'], 100, 2);
|
|
|
+ }
|
|
|
+ } else $data['replyChance'] = 0;
|
|
|
+ var_dump(44);
|
|
|
+ $data['mer_id'] = $storeInfo['mer_id'];
|
|
|
+ $data['system_store'] = ($res = SystemStore::getStoreDispose()) ? $res : [];
|
|
|
+ $data['good_list'] = StoreProduct::getGoodList(18, $user['sp_user'] ?? 0, 'image,store_name,price,id,ot_price');
|
|
|
+ $data['mapKey'] = sys_config('tengxun_map_key');
|
|
|
+ $data['store_self_mention'] = (int)sys_config('store_self_mention') ?? 0;
|
|
|
+ $data['activity'] = StoreProduct::activity($data['storeInfo']['id'], false);
|
|
|
+ var_dump(55);
|
|
|
+ return app('json')->successful($data);
|
|
|
}
|
|
|
|
|
|
|