mirror of
https://github.com/crmeb/CRMEB.git
synced 2026-10-28 13:31:04 +00:00
fix(商品评价): 去掉已删 cartInfo 关联,推荐评价失败不拖垮好评统计
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
99e7a70245
commit
066cd52f8c
@ -54,8 +54,9 @@ class StoreProductReplyDao extends BaseDao
|
||||
*/
|
||||
public function getProductReply(int $productId)
|
||||
{
|
||||
// cartInfo 关联已随 eb_store_order_cart_info 删除,SKU 由本表 suk 承载,仅预加载 userInfo
|
||||
return $this->search(['product_id' => $productId, 'is_del' => 0, 'status' => 1])
|
||||
->with(['cartInfo', 'userInfo'])
|
||||
->with(['userInfo'])
|
||||
->order('add_time DESC,product_score DESC,service_score DESC,add_time DESC')
|
||||
->find();
|
||||
}
|
||||
|
||||
@ -840,11 +840,14 @@ class CenterProductServices extends BaseService
|
||||
$reply = null;
|
||||
$replyCount = 0;
|
||||
$replyChance = 0;
|
||||
$replyService = app()->make(\app\services\product\product\StoreProductReplyServices::class);
|
||||
// 统计与推荐评价拆开:推荐评价失败不应拖垮数量/好评率
|
||||
try {
|
||||
$replyService = app()->make(\app\services\product\product\StoreProductReplyServices::class);
|
||||
$reply = get_thumb_water($replyService->getRecProductReply($id), 'big', ['pics']);
|
||||
[$replyCount, $goodReply, $replyChance] = $replyService->getProductReplyData($id);
|
||||
} catch (\Throwable $e) {}
|
||||
try {
|
||||
$reply = get_thumb_water($replyService->getRecProductReply($id), 'big', ['pics']);
|
||||
} catch (\Throwable $e) {}
|
||||
|
||||
// ========== 9. 优惠券 ==========
|
||||
$coupons = [];
|
||||
|
||||
@ -246,17 +246,16 @@ class StoreProductReplyServices extends BaseService
|
||||
|
||||
if ($res) {
|
||||
$res = $res->toArray();
|
||||
if ($res['suk'] === '') {
|
||||
$res['suk'] = isset($res['cart_info']['productInfo']['attrInfo']) ? $res['cart_info']['productInfo']['attrInfo']['suk'] : '';
|
||||
}
|
||||
// SKU 以评价表 suk 为准(旧 cartInfo 关联已删除)
|
||||
$res['suk'] = (string)($res['suk'] ?? '');
|
||||
$res['nickname'] = anonymity($res['nickname']);
|
||||
$res['merchant_reply_time'] = date('Y-m-d H:i', $res['merchant_reply_time']);
|
||||
$replyTime = (int)($res['merchant_reply_time'] ?? 0);
|
||||
$res['merchant_reply_time'] = $replyTime > 0 ? date('Y-m-d H:i', $replyTime) : '';
|
||||
$res['add_time'] = time_tran($res['add_time']);
|
||||
$res['star'] = bcadd($res['product_score'], $res['service_score'], 2);
|
||||
$res['star'] = bcadd((string)$res['product_score'], (string)$res['service_score'], 2);
|
||||
$res['star'] = bcdiv($res['star'], '2', 0);
|
||||
$res['comment'] = $res['comment'] ?: '此用户没有填写评价';
|
||||
$res['pics'] = is_string($res['pics']) ? json_decode($res['pics'], true) : $res['pics'];
|
||||
unset($res['cartInfo']);
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user