feat: 数据库导入新商品、调整数据库字段、无内容展示封面、自定义参数修改

master
yin5th 2023-09-18 10:41:31 +08:00
parent d6cd61b289
commit a4a0929a4d
3 changed files with 67 additions and 2 deletions

View File

@ -106,6 +106,9 @@ class GoodsLogic extends Logic
// 转数组
$goodsDetailArr = $goodsDetail->toArray();
$goodsDetailArr['poster'] = !empty($goodsDetailArr['poster']) ? UrlServer::getFileUrl($goodsDetailArr['poster']) : '';
if (empty($goodsDetailArr['content'])) {
$goodsDetailArr['content'] = '<img src="'.$goodsDetailArr['image'].'" />';
}
// 新增点击记录
GoodsClick::create([
@ -295,6 +298,16 @@ class GoodsLogic extends Logic
protected static function str2arr(string $str): array
{
// 先判断是否可以解析成数组 [{"skuId":null,"propId":null,"propName":"核心规格","propVal":"适用于M1R-FF04-12"},{"skuId":null,"propId":null,"propName":"箱规","propVal":"-"},{"skuId":null,"propId":null,"propName":"适用品牌","propVal":"DONGCHENG/东成"},{"skuId":null,"propId":null,"propName":"适用机型","propVal":"M1R-FF04-12"},{"skuId":null,"propId":null,"propName":"销售单位","propVal":"个"}]
$parseArr = json_decode($str, true);
if (is_array($parseArr)) {
$result = [];
foreach ($parseArr as $arr) {
$result[] = ['key' => $arr['propName'] ?? '', 'value' => $arr['propVal']];
}
return $result;
}
// $str = "参数1:值1;参数2:值2";
// 使用分号分割数组

View File

@ -41,6 +41,58 @@ use app\common\model\shop\Shop;
*/
class GoodsLogic extends Logic
{
/*
* 商品统计
*/
public static function statistics($shop_id){
$where = [
['del', '<>', GoodsEnum::DEL_TRUE],
['shop_id', '=', $shop_id],
];
$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;
}
/**
* @notes 商品统计
* @param $shop_id
@ -51,7 +103,7 @@ class GoodsLogic extends Logic
* @author 段誉
* @date 2022/4/7 11:57
*/
public static function statistics($shop_id){
public static function statistics_bak($shop_id){
$where = [
['del', '<>', GoodsEnum::DEL_TRUE],
['shop_id', '=', $shop_id]

View File

@ -73,7 +73,7 @@
<div class="layui-tab layui-tab-card" lay-filter="like-tabs">
<ul class="layui-tab-title">
<li data-type='1' class="layui-this">销售中商品({$statistics.sell})</li>
<li data-type='2' >库存预警商品({$statistics.warn})</li>
<!-- <li data-type='2' >库存预警商品({$statistics.warn})</li>-->
<li data-type='3' >仓库中商品({$statistics.warehouse})</li>
<li data-type='4' >回收站商品({$statistics.recycle})</li>
<li data-type='5' >待审核商品({$statistics.audit_stay})</li>