From 5b27ec955fa3b69fe467c5b3681230d5a827bb2d Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Thu, 6 Jun 2024 16:10:12 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E6=97=A5=E3=80=81=E5=91=A8=E3=80=81=E6=9C=88=E8=B4=A6=E5=8D=95?= =?UTF-8?q?=E5=88=97=E8=A1=A8API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../StoreFinanceFlowController.php | 33 ++++++++ .../SystemStoreStatisticsController.php | 4 +- .../StoreFinanceFlowDayLists.php | 75 +++++++++++++++++++ .../StoreFinanceFlowMonthLists.php | 75 +++++++++++++++++++ .../StoreFinanceFlowWeekLists.php | 75 +++++++++++++++++++ .../lists/system_store/SystemStoreLists.php | 6 +- .../lists/user_recharge/UserRechargeLists.php | 18 ++++- .../logic/system_store/SystemStoreLogic.php | 23 ++++-- 8 files changed, 297 insertions(+), 12 deletions(-) create mode 100644 app/admin/lists/store_finance_flow/StoreFinanceFlowDayLists.php create mode 100644 app/admin/lists/store_finance_flow/StoreFinanceFlowMonthLists.php create mode 100644 app/admin/lists/store_finance_flow/StoreFinanceFlowWeekLists.php diff --git a/app/admin/controller/store_finance_flow/StoreFinanceFlowController.php b/app/admin/controller/store_finance_flow/StoreFinanceFlowController.php index a5bae6f02..a63bf0025 100644 --- a/app/admin/controller/store_finance_flow/StoreFinanceFlowController.php +++ b/app/admin/controller/store_finance_flow/StoreFinanceFlowController.php @@ -4,7 +4,10 @@ namespace app\admin\controller\store_finance_flow; use app\admin\controller\BaseAdminController; +use app\admin\lists\store_finance_flow\StoreFinanceFlowDayLists; use app\admin\lists\store_finance_flow\StoreFinanceFlowLists; +use app\admin\lists\store_finance_flow\StoreFinanceFlowMonthLists; +use app\admin\lists\store_finance_flow\StoreFinanceFlowWeekLists; use app\admin\logic\store_finance_flow\StoreFinanceFlowLogic; use app\admin\validate\store_finance_flow\StoreFinanceFlowValidate; @@ -28,6 +31,36 @@ class StoreFinanceFlowController extends BaseAdminController { return $this->dataLists(new StoreFinanceFlowLists()); } + /** + * @notes 获取日账单列表 + * @return \think\response\Json + * @author admin + * @date 2024/05/31 16:56 + */ + public function day_bill_lists() + { + return $this->dataLists(new StoreFinanceFlowDayLists()); + } + /** + * @notes 获取周账单列表 + * @return \think\response\Json + * @author admin + * @date 2024/05/31 16:56 + */ + public function week_bill_lists() + { + return $this->dataLists(new StoreFinanceFlowWeekLists()); + } + /** + * @notes 获取月账单列表 + * @return \think\response\Json + * @author admin + * @date 2024/05/31 16:56 + */ + public function month_bill_lists() + { + return $this->dataLists(new StoreFinanceFlowMonthLists()); + } diff --git a/app/admin/controller/system_store/SystemStoreStatisticsController.php b/app/admin/controller/system_store/SystemStoreStatisticsController.php index 3f8d79e99..8f639f64e 100644 --- a/app/admin/controller/system_store/SystemStoreStatisticsController.php +++ b/app/admin/controller/system_store/SystemStoreStatisticsController.php @@ -261,7 +261,7 @@ class SystemStoreStatisticsController extends BaseAdminController [ "id"=> 46, "name"=> "王多鱼的商超", - "image"=> "https=>//multi-store.crmeb.net/uploads/attach/2024/05/20240527/f9b8b3c3cd5f1113bd7d374dc55d320a.jpg", + "image"=> "https:multi-store.crmeb.net/uploads/attach/2024/05/20240527/f9b8b3c3cd5f1113bd7d374dc55d320a.jpg", "store_price"=> 797.88, "store_product_count"=> 18, "store_order_price"=> 1275.16, @@ -270,7 +270,7 @@ class SystemStoreStatisticsController extends BaseAdminController [ "id"=> 43, "name"=> "这是直营店", - "image"=> "https=>//multi-store.crmeb.net/uploads/attach/2024/05/20240524/9066528e73e2db60d31a704d321ba4a5.jpeg", + "image"=> "https:multi-store.crmeb.net/uploads/attach/2024/05/20240524/9066528e73e2db60d31a704d321ba4a5.jpeg", "store_price"=> 203.11, "store_product_count"=> 10, "store_order_price"=> 579.01, diff --git a/app/admin/lists/store_finance_flow/StoreFinanceFlowDayLists.php b/app/admin/lists/store_finance_flow/StoreFinanceFlowDayLists.php new file mode 100644 index 000000000..c5aadb565 --- /dev/null +++ b/app/admin/lists/store_finance_flow/StoreFinanceFlowDayLists.php @@ -0,0 +1,75 @@ + ['store_id', 'uid', 'staff_id'], + 'between_time'=>'create_time' + ]; + } + + + /** + * @notes 获取门店日账单列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author admin + * @date 2024/05/31 16:56 + */ + public function lists(): array + { + return StoreFinanceFlow::where($this->searchWhere) + ->field(' + FROM_UNIXTIME(create_time, "%Y-%m-%d") as date, + SUM(CASE WHEN financial_pm = 1 THEN number ELSE 0 END) as income, + SUM(CASE WHEN financial_pm = 0 THEN number ELSE 0 END) as expenditure + ') + ->limit($this->limitOffset, $this->limitLength) + ->group('date') + ->order('date', 'desc') + ->select()->each(function ($item) { + $item['name']='日账单'; + $item['enter']=bcdiv($item['income'],$item['expenditure'],2); + return $item; + }) + ->toArray(); + } + + + /** + * @notes 获取门店日账单数量 + * @return int + * @author admin + * @date 2024/05/31 16:56 + */ + public function count(): int + { + return StoreFinanceFlow::where($this->searchWhere)->group('create_time') + ->count(); + } +} diff --git a/app/admin/lists/store_finance_flow/StoreFinanceFlowMonthLists.php b/app/admin/lists/store_finance_flow/StoreFinanceFlowMonthLists.php new file mode 100644 index 000000000..d35ab1269 --- /dev/null +++ b/app/admin/lists/store_finance_flow/StoreFinanceFlowMonthLists.php @@ -0,0 +1,75 @@ + ['store_id', 'uid', 'staff_id'], + 'between_time' => 'create_time' + ]; + } + + + /** + * @notes 获取门店月账单列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author admin + * @date 2024/05/31 16:56 + */ + public function lists(): array + { + return StoreFinanceFlow::where($this->searchWhere) + ->field(' + CONCAT(YEAR(FROM_UNIXTIME(create_time, "%Y-%m-%d")), "年", MONTH(FROM_UNIXTIME(create_time, "%Y-%m-%d")), "月") as date, + SUM(CASE WHEN financial_pm = 1 THEN number ELSE 0 END) as income, + SUM(CASE WHEN financial_pm = 0 THEN number ELSE 0 END) as expenditure + ') + ->limit($this->limitOffset, $this->limitLength) + ->group('date') + ->order('date', 'desc') + ->select()->each(function ($item) { + $item['name']='月账单'; + $item['enter']=bcdiv($item['income'],$item['expenditure'],2); + return $item; + }) + ->toArray(); + } + + + /** + * @notes 获取门店月账单数量 + * @return int + * @author admin + * @date 2024/05/31 16:56 + */ + public function count(): int + { + return StoreFinanceFlow::where($this->searchWhere)->group('create_time') + ->count(); + } +} diff --git a/app/admin/lists/store_finance_flow/StoreFinanceFlowWeekLists.php b/app/admin/lists/store_finance_flow/StoreFinanceFlowWeekLists.php new file mode 100644 index 000000000..33cf129f7 --- /dev/null +++ b/app/admin/lists/store_finance_flow/StoreFinanceFlowWeekLists.php @@ -0,0 +1,75 @@ + ['store_id', 'uid', 'staff_id'], + 'between_time' => 'create_time' + ]; + } + + + /** + * @notes 获取门店周账单列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author admin + * @date 2024/05/31 16:56 + */ + public function lists(): array + { + return StoreFinanceFlow::where($this->searchWhere) + ->field(' + CONCAT("第", YEARweek(FROM_UNIXTIME(create_time, "%Y-%m-%d")), "周(", MONTH(FROM_UNIXTIME(create_time, "%Y-%m-%d")), "月)") as date, + SUM(CASE WHEN financial_pm = 1 THEN number ELSE 0 END) as income, + SUM(CASE WHEN financial_pm = 0 THEN number ELSE 0 END) as expenditure + ') + ->limit($this->limitOffset, $this->limitLength) + ->group('date') + ->order('date', 'desc') + ->select()->each(function ($item) { + $item['name']='周账单'; + $item['enter']=bcdiv($item['income'],$item['expenditure'],2); + return $item; + }) + ->toArray(); + } + + + /** + * @notes 获取门店周账单数量 + * @return int + * @author admin + * @date 2024/05/31 16:56 + */ + public function count(): int + { + return StoreFinanceFlow::where($this->searchWhere)->group('create_time') + ->count(); + } +} diff --git a/app/admin/lists/system_store/SystemStoreLists.php b/app/admin/lists/system_store/SystemStoreLists.php index 791210a99..40b3804ea 100644 --- a/app/admin/lists/system_store/SystemStoreLists.php +++ b/app/admin/lists/system_store/SystemStoreLists.php @@ -6,7 +6,7 @@ namespace app\admin\lists\system_store; use app\admin\lists\BaseAdminDataLists; use app\common\model\system_store\SystemStore; use app\common\lists\ListsSearchInterface; - +use app\common\model\system_store\SystemStoreStaff; /** * 门店列表列表 @@ -47,7 +47,9 @@ class SystemStoreLists extends BaseAdminDataLists implements ListsSearchInterfac ->field(['id', 'name', 'phone', 'detailed_address', 'image', 'is_show','day_start','day_end']) ->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) - ->select() + ->select()->each(function ($item){ + $item['staff_name'] =SystemStoreStaff::where('store_id',$item['id'])->where('is_admin',1)->value('staff_name'); + }) ->toArray(); } diff --git a/app/admin/lists/user_recharge/UserRechargeLists.php b/app/admin/lists/user_recharge/UserRechargeLists.php index 6a64019b7..6a9101e65 100644 --- a/app/admin/lists/user_recharge/UserRechargeLists.php +++ b/app/admin/lists/user_recharge/UserRechargeLists.php @@ -6,7 +6,7 @@ namespace app\admin\lists\user_recharge; use app\admin\lists\BaseAdminDataLists; use app\common\model\user_recharge\UserRecharge; use app\common\lists\ListsSearchInterface; - +use app\common\model\user\User; /** * 充值记录列表 @@ -27,6 +27,7 @@ class UserRechargeLists extends BaseAdminDataLists implements ListsSearchInterfa { return [ '=' => ['paid', 'pay_time'], + 'between_time'=>'create_time' ]; } @@ -46,7 +47,20 @@ class UserRechargeLists extends BaseAdminDataLists implements ListsSearchInterfa ->field(['id', 'uid', 'order_id', 'price', 'recharge_type', 'paid', 'pay_time']) ->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) - ->select() + ->select()->each(function ($item) { + $item['nickname']=User::where('id',$item['uid'])->value('nickname'); + if($item['pay_time']>0){ + $item['pay_time']=date('Y-m-d H:i:s',$item['pay_time']); + }else{ + $item['pay_time']=''; + } + if($item['paid']==1){ + $item['paid_name']='已充值'; + }else{ + $item['paid_name']='未充值'; + } + return $item; + }) ->toArray(); } diff --git a/app/admin/logic/system_store/SystemStoreLogic.php b/app/admin/logic/system_store/SystemStoreLogic.php index c07cc136f..f33dc41d7 100644 --- a/app/admin/logic/system_store/SystemStoreLogic.php +++ b/app/admin/logic/system_store/SystemStoreLogic.php @@ -52,7 +52,7 @@ class SystemStoreLogic extends BaseLogic 'account' => $params['phone'], 'pwd' => $password, 'avatar' => $params['image'], - 'staff_name' => $params['name'], + 'staff_name' => $params['staff_name'], 'phone' => $params['phone'], 'is_admin' => 1, 'status' => 1, @@ -95,17 +95,24 @@ class SystemStoreLogic extends BaseLogic 'area' => $params['area_code'], 'street' => $params['street_code'], ]); - if($params['password']!=''){ + $res=SystemStoreStaff::where('store_id', $params['id'])->where('is_admin', 1)->where('account', $params['phone'])->find(); + if($params['password']!=''&&$res){ $passwordSalt = Config::get('project.unique_identification'); $password = create_password($params['password'], $passwordSalt); $taff = [ 'pwd' => $password, 'avatar' => $params['image'], - 'staff_name' => $params['name'], + 'staff_name' => $params['staff_name'], ]; - SystemStoreStaff::where('store_id', $params['id'])->where('is_admin', 1)->where('account', $params['phone'])->update($taff); + SystemStoreStaff::where('id', $res['id'])->update($taff); + } + if($params['staff_name']!=''&&$res){ + $taff = [ + 'avatar' => $params['image'], + 'staff_name' => $params['staff_name'], + ]; + SystemStoreStaff::where('id', $res['id'])->update($taff); } - Db::commit(); return true; } catch (\Exception $e) { @@ -138,6 +145,10 @@ class SystemStoreLogic extends BaseLogic */ public static function detail($params): array { - return SystemStore::findOrEmpty($params['id'])->toArray(); + $data=SystemStore::findOrEmpty($params['id'])->toArray(); + if($data){ + $data['staff_name']=SystemStoreStaff::where('store_id', $params['id'])->where('is_admin', 1)->value('staff_name'); + } + return $data; } }