From d87470bc954bbbf06c900bec286eba5dd87be5ca Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Thu, 16 May 2024 10:28:29 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/lists/goods/GoodsLists.php | 6 +- app/admin/lists/supplier/SupplierLists.php | 12 ++-- app/admin/logic/goods/GoodsLogic.php | 8 --- app/admin/logic/supplier/SupplierLogic.php | 8 --- .../controller/order/StatisticsController.php | 9 +++ app/api/lists/order/StatisticsList.php | 66 +++++++++++++++++++ app/common/model/goods/Goods.php | 9 ++- app/common/model/supplier/Supplier.php | 13 ++++ 8 files changed, 101 insertions(+), 30 deletions(-) create mode 100644 app/api/controller/order/StatisticsController.php create mode 100644 app/api/lists/order/StatisticsList.php diff --git a/app/admin/lists/goods/GoodsLists.php b/app/admin/lists/goods/GoodsLists.php index d820608..e4d86cb 100644 --- a/app/admin/lists/goods/GoodsLists.php +++ b/app/admin/lists/goods/GoodsLists.php @@ -51,10 +51,10 @@ class GoodsLists extends BaseAdminDataLists implements ListsSearchInterface ->order(['id' => 'desc']) ->select()->each(function($data){ if(!empty($data['sys_labels'])){ - $goodslabel = GoodsLabel::where('id','in',trim($data['sys_labels'],','))->column('name'); - $data['sys_labels_text'] = implode(',',$goodslabel); + $goodslabel = GoodsLabel::where('id','in',$data['sys_labels'])->column('id,name'); + $data['sys_labels_arr'] = $goodslabel; }else{ - $data['sys_labels_text'] = ''; + $data['sys_labels_arr'] = []; } }) ->toArray(); diff --git a/app/admin/lists/supplier/SupplierLists.php b/app/admin/lists/supplier/SupplierLists.php index b46e776..dcd374f 100644 --- a/app/admin/lists/supplier/SupplierLists.php +++ b/app/admin/lists/supplier/SupplierLists.php @@ -48,12 +48,12 @@ class SupplierLists extends BaseAdminDataLists implements ListsSearchInterface ->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) ->select()->each(function($data){ - if(!empty($data['sys_labels'])){ - $goodslabel = GoodsLabel::where('id','in',trim($data['sys_labels'],','))->column('name'); - $data['sys_labels_text'] = implode(',',$goodslabel); - }else{ - $data['sys_labels_text'] = ''; - } + if(!empty($data['sys_labels'])){ + $goodslabel = GoodsLabel::where('id','in',$data['sys_labels'])->column('id,name'); + $data['sys_labels_arr'] = $goodslabel; + }else{ + $data['sys_labels_arr'] = []; + } }) ->toArray(); } diff --git a/app/admin/logic/goods/GoodsLogic.php b/app/admin/logic/goods/GoodsLogic.php index f3404ef..1a81924 100644 --- a/app/admin/logic/goods/GoodsLogic.php +++ b/app/admin/logic/goods/GoodsLogic.php @@ -27,10 +27,6 @@ class GoodsLogic extends BaseLogic */ public static function add(array $params): bool { - if($params['sys_labels']){ - $sys_labels=explode(',',$params['sys_labels']); - $params['sys_labels']=','.implode(',',$sys_labels).','; - } Db::startTrans(); try { Goods::create([ @@ -75,10 +71,6 @@ class GoodsLogic extends BaseLogic */ public static function edit(array $params): bool { - if($params['sys_labels']){ - $sys_labels=explode(',',$params['sys_labels']); - $params['sys_labels']=','.implode(',',$sys_labels).','; - } Db::startTrans(); try { Goods::where('id', $params['id'])->update([ diff --git a/app/admin/logic/supplier/SupplierLogic.php b/app/admin/logic/supplier/SupplierLogic.php index aff9852..0a25910 100644 --- a/app/admin/logic/supplier/SupplierLogic.php +++ b/app/admin/logic/supplier/SupplierLogic.php @@ -27,10 +27,6 @@ class SupplierLogic extends BaseLogic */ public static function add(array $params): bool { - if($params['sys_labels']){ - $sys_labels=explode(',',$params['sys_labels']); - $params['sys_labels']=','.implode(',',$sys_labels).','; - } Db::startTrans(); try { Supplier::create([ @@ -80,10 +76,6 @@ class SupplierLogic extends BaseLogic */ public static function edit(array $params): bool { - if($params['sys_labels']){ - $sys_labels=explode(',',$params['sys_labels']); - $params['sys_labels']=','.implode(',',$sys_labels).','; - } Db::startTrans(); try { Supplier::where('id', $params['id'])->update([ diff --git a/app/api/controller/order/StatisticsController.php b/app/api/controller/order/StatisticsController.php new file mode 100644 index 0000000..ee1a11b --- /dev/null +++ b/app/api/controller/order/StatisticsController.php @@ -0,0 +1,9 @@ +<?php +namespace app\api\controller\order; +use app\api\controller\BaseApiController; + +class StatisticsController extends BaseApiController{ + public function lists(){ + + } +} \ No newline at end of file diff --git a/app/api/lists/order/StatisticsList.php b/app/api/lists/order/StatisticsList.php new file mode 100644 index 0000000..b79d043 --- /dev/null +++ b/app/api/lists/order/StatisticsList.php @@ -0,0 +1,66 @@ +<?php + +namespace app\api\lists\order; + + +use app\admin\lists\BaseAdminDataLists; +use app\common\lists\ListsSearchInterface; +use app\common\model\goods\Goods; +use app\common\model\retail\Cashierclass; +use app\common\model\retail\Cashierinfo; + +/** + * 统计列表 + * Class RetailOrderList + * @package app\api\order + */ +class StatisticsList extends BaseAdminDataLists implements ListsSearchInterface +{ + + + /** + * @notes 设置搜索条件 + * @return \string[][] + * @author likeadmin + */ + public function setSearch(): array + { + return [ + '=' => ['paid','status','source'], + 'between_time' => 'create_time', + '%like%' => ['number'], + ]; + } + + + /** + * @notes 零售订单列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @date 2024/04/27 11:26 + */ + public function lists(): array + { + $userId=$this->request->userId; + if(!$userId) return []; + return Cashierclass::where($this->searchWhere)->where('uid',$userId) + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select() + ->toArray(); + } + + + /** + * @notes 零售订单数量 + * @return int + * @date 2024/04/27 11:26 + */ + public function count(): int + { + return Cashierclass::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/common/model/goods/Goods.php b/app/common/model/goods/Goods.php index 1c00e10..a90f123 100644 --- a/app/common/model/goods/Goods.php +++ b/app/common/model/goods/Goods.php @@ -23,17 +23,16 @@ class Goods extends BaseModel { return explode(',',$value); } - public function setSysLabelAttr($value) + public function setSysLabelsAttr($value) { if (!empty($value)) { - if (!is_array($value)) - return ','. $value .','; - return ','. implode(',', $value) .','; + $sys_labels=explode(',',$value); + return ','.implode(',',$sys_labels).','; } return $value; } - public function getSysLabelAttr($value) + public function getSysLabelsAttr($value) { if (!$value) return []; return explode(',',rtrim(ltrim($value,','),',')); diff --git a/app/common/model/supplier/Supplier.php b/app/common/model/supplier/Supplier.php index 9a62d47..c048839 100644 --- a/app/common/model/supplier/Supplier.php +++ b/app/common/model/supplier/Supplier.php @@ -19,6 +19,19 @@ class Supplier extends BaseModel protected $name = 'supplier'; protected $deleteTime = 'delete_time'; + public function setSysLabelsAttr($value) + { + if (!empty($value)) { + $sys_labels=explode(',',$value); + return ','.implode(',',$sys_labels).','; + } + return $value; + } + public function getSysLabelsAttr($value) + { + if (!$value) return []; + return explode(',',rtrim(ltrim($value,','),',')); + } public function userAuth() { return $this->hasOne(UserAuth::class, 'id', 'uid')->bind(['openid']);