From a4a0929a4d18061e48abbf40d99bd30724b68623 Mon Sep 17 00:00:00 2001 From: yin5th <541304803@qq.com> Date: Mon, 18 Sep 2023 10:41:31 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=95=B0=E6=8D=AE=E5=BA=93=E5=AF=BC?= =?UTF-8?q?=E5=85=A5=E6=96=B0=E5=95=86=E5=93=81=E3=80=81=E8=B0=83=E6=95=B4?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=BA=93=E5=AD=97=E6=AE=B5=E3=80=81=E6=97=A0?= =?UTF-8?q?=E5=86=85=E5=AE=B9=E5=B1=95=E7=A4=BA=E5=B0=81=E9=9D=A2=E3=80=81?= =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=E5=8F=82=E6=95=B0=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/app/api/logic/GoodsLogic.php | 13 +++++ server/app/shop/logic/goods/GoodsLogic.php | 54 ++++++++++++++++++++- server/app/shop/view/goods/goods/lists.html | 2 +- 3 files changed, 67 insertions(+), 2 deletions(-) diff --git a/server/app/api/logic/GoodsLogic.php b/server/app/api/logic/GoodsLogic.php index 8a12a9f4..39017189 100644 --- a/server/app/api/logic/GoodsLogic.php +++ b/server/app/api/logic/GoodsLogic.php @@ -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'] = ''; + } // 新增点击记录 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"; // 使用分号分割数组 diff --git a/server/app/shop/logic/goods/GoodsLogic.php b/server/app/shop/logic/goods/GoodsLogic.php index ca203c71..e96e82a2 100644 --- a/server/app/shop/logic/goods/GoodsLogic.php +++ b/server/app/shop/logic/goods/GoodsLogic.php @@ -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] diff --git a/server/app/shop/view/goods/goods/lists.html b/server/app/shop/view/goods/goods/lists.html index 7c9e456c..2bd09702 100644 --- a/server/app/shop/view/goods/goods/lists.html +++ b/server/app/shop/view/goods/goods/lists.html @@ -73,7 +73,7 @@