【產品名稱】:CRMEB PRO版 / 多店版
【產品版本】:v2.3.1(20221122)
【部署方式】:linux / docker
【部署環境】:本地環境 / 線上環境
【php版本】:7.4
【Mysql版本】:5.8
【使用終端】:小程序
商品詳情頁有銷量
拼團詳情頁累計銷量為0
查看前端代碼讀取的 storeInfo.total 字段
查看后端代碼有關聯查詢 with(['total']),在 app/model/activity/combination/StoreCombination.php 大概136行
/**
* 一對一關聯
* 商品關聯商品商品詳情
* @return \think\model\relation\HasOne
*/
public function total()
{
return $this->hasOne(StoreProduct::class, 'id', 'product_id')->where('is_show', 1)->where('is_del', 0)->field(['SUM(sales+ficti) as total', 'id', 'price'])->bind([
'total' => 'total', 'product_price' => 'price'
]);
}
函數名和返回的bind屬性total重名了,在model返回中被hidden掉了
修復如下:
修改 public function total() 為 public function totals()
修改 app/services/activity/combination/StoreCombinationServices.php 文件 combinationDetail 函數(大概375行)
原始代碼:
$storeInfo = $this->dao->getOne(['id' => $id], '*', ['descriptions', 'total']);
修改為:
$storeInfo = $this->dao->getOne(['id' => $id], '*', ['descriptions', 'totals']);
修改 app/dao/activity/combination/StoreCombinationDao.php 文件 validProduct 函數 (大概137行)
原始代碼:
return $this->search($where)->where('id', $id)->with(['total'])->field($field)->order('add_time desc')->find();
修改為:
return $this->search($where)->where('id', $id)->with(['totals'])->field($field)->order('add_time desc')->find();
修改后可以正常顯示累計銷量
最終修復還是已官方修復為準,以上為本人臨時的修補方案。