修改商品统计代码
This commit is contained in:
parent
a614fea407
commit
9e30337399
@ -14,8 +14,9 @@ class ProductStatisticLogic extends BaseLogic
|
|||||||
|
|
||||||
public function get_product_ranking($where)
|
public function get_product_ranking($where)
|
||||||
{
|
{
|
||||||
$list = StoreProductLog::where($where)->with('storeName')
|
$list = StoreProductLog::where($where)->with('store')
|
||||||
->field([
|
->field([
|
||||||
|
'store_id',
|
||||||
'product_id',
|
'product_id',
|
||||||
'SUM(visit_num) as visit',
|
'SUM(visit_num) as visit',
|
||||||
'COUNT(distinct(uid)) as user',
|
'COUNT(distinct(uid)) as user',
|
||||||
@ -30,7 +31,7 @@ class ProductStatisticLogic extends BaseLogic
|
|||||||
'COUNT(distinct(pay_uid))-1 as repeats'
|
'COUNT(distinct(pay_uid))-1 as repeats'
|
||||||
])->group('product_id')->order('pay' . ' desc')->limit(20)->select()->toArray();
|
])->group('product_id')->order('pay' . ' desc')->limit(20)->select()->toArray();
|
||||||
foreach ($list as $key => &$item) {
|
foreach ($list as $key => &$item) {
|
||||||
if (!$item['store_name'] || !$item['image']) {
|
if (!$item['store_name']) {
|
||||||
unset($list[$key]);
|
unset($list[$key]);
|
||||||
}
|
}
|
||||||
if ($item['profit'] == null) $item['profit'] = 0;
|
if ($item['profit'] == null) $item['profit'] = 0;
|
||||||
|
@ -4,6 +4,7 @@ namespace app\common\model\store_product_log;
|
|||||||
|
|
||||||
|
|
||||||
use app\common\model\BaseModel;
|
use app\common\model\BaseModel;
|
||||||
|
use app\common\model\system_store\SystemStore;
|
||||||
use think\model\concern\SoftDelete;
|
use think\model\concern\SoftDelete;
|
||||||
|
|
||||||
|
|
||||||
@ -18,6 +19,11 @@ class StoreProductLog extends BaseModel
|
|||||||
protected $name = 'store_product_log';
|
protected $name = 'store_product_log';
|
||||||
protected $deleteTime = 'delete_time';
|
protected $deleteTime = 'delete_time';
|
||||||
|
|
||||||
|
public function store()
|
||||||
|
{
|
||||||
|
return $this->hasOne(SystemStore::class, 'id', 'store_id')
|
||||||
|
->bind(['store_name' => 'name', 'store_phone' => 'phone', 'store_detailed_address' => 'detailed_address', 'store_simple_address' => 'address']);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user