feat: 添加StoreProduct模型以获取商品信息

This commit is contained in:
mkm 2024-06-21 14:51:35 +08:00
parent 84a6854825
commit 1fb3f295ad

View File

@ -3,6 +3,7 @@
namespace app\admin\logic\statistic;
use app\common\logic\BaseLogic;
use app\common\model\store_product\StoreProduct;
use app\common\model\store_product_log\StoreProductLog;
/**
@ -16,7 +17,7 @@ class ProductStatisticLogic extends BaseLogic
{
$time = explode('-', $where['create_time']);
$time = [strtotime($time[0]), strtotime($time[1])];
$list = StoreProductLog::whereBetweenTime('create_time',$time[0],$time[1])->with('store')
$list = StoreProductLog::whereBetweenTime('create_time',$time[0],$time[1])
->field([
'store_id',
'product_id',
@ -36,6 +37,9 @@ class ProductStatisticLogic extends BaseLogic
if (!$item['store_name']) {
unset($list[$key]);
}
$find=StoreProduct::where('id',$item['product_id'])->field('store_name,image')->find();
$item['store_name']=$find['store_name'];
$item['image']=$find['image'];
if ($item['profit'] == null) $item['profit'] = 0;
if ($item['changes'] == null) $item['changes'] = 0;
if ($item['repeats'] == null) {