feat: 完善商品统计逻辑

master
yin5th 2023-09-15 14:58:36 +08:00
parent a01c567e48
commit 69f5fa1a92
2 changed files with 53 additions and 0 deletions

View File

@ -49,6 +49,54 @@ class GoodsLogic extends Logic
$where = [
['del', '<>', GoodsEnum::DEL_TRUE]
];
$goods = [];
// 销售中商品(含库存预警商品)
// 销售状态:上架中;删除状态:正常; 审核状态: 审核通过
$goods['sell'] = Goods::where($where)
->where('status', GoodsEnum::STATUS_SHELVES)
->where('del', GoodsEnum::DEL_NORMAL)
->where('audit_status', GoodsEnum::AUDIT_STATUS_OK)
->count();
// 仓库中商品
// 销售状态:仓库中;删除状态:正常; 审核状态: 审核通过
$goods['warehouse'] = Goods::where($where)
->where('status', GoodsEnum::STATUS_SOLD_OUT)
->where('del', GoodsEnum::DEL_NORMAL)
->where('audit_status', GoodsEnum::AUDIT_STATUS_OK)
->count();
// 回收站商品
// 销售状态:任意;删除状态:回收站; 审核状态: 审核通过
$goods['recycle'] = Goods::where($where)
->where('del', GoodsEnum::DEL_RECYCLE)
->where('audit_status', GoodsEnum::AUDIT_STATUS_OK)
->count();
// 待审核商品
// 销售状态:任意;删除状态:排除已删除; 审核状态: 待审核
$goods['audit_stay'] = Goods::where($where)
->where('audit_status', GoodsEnum::AUDIT_STATUS_STAY)
->count();
// 审核未通过商品
// 销售状态:任意;删除状态:排除已删除; 审核状态: 审核未通过
$goods['audit_refuse'] = Goods::where($where)
->where('audit_status', GoodsEnum::AUDIT_STATUS_REFUSE)
->count();
return $goods;
}
/*
* 商品统计
*/
public static function statistics_bak(){
$where = [
['del', '<>', GoodsEnum::DEL_TRUE]
];
$goods_list = Goods::where($where)
->field('id,status,stock,stock_warn,audit_status,del')
->select();

View File

@ -97,6 +97,10 @@
</div>
</script>
<script type="text/html" id="qr-info">
<img src="{{d.image}}" style="height:60px;width: 60px" class="image-show">
</script>
<script type="text/html" id="goods-info">
<img src="{{d.image}}" style="height:60px;width: 60px;margin-right: 5px;" class="image-show"> {{d.name}}
</script>
@ -351,6 +355,7 @@
function getList(type) {
like.tableLists('#goods-lists', '{:url("goods.goods/lists")}?type='+type, [
{title: '商家信息',width:280, templet: '#shop-info'}
,{title: '分享二维码',width:150, templet: '#qr-info'}
,{title: '商品信息',width:280, templet: '#goods-info'}
,{field: 'columnStr', title: '商品栏目',width:220}
,{field: 'price',title: '价格区间(元)', width: 180, align: 'center'}