From 6cbffc01a8cf7dd1f5d31b3a3a1cf17a3b01050b Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Thu, 20 Jun 2024 11:41:14 +0800 Subject: [PATCH 1/7] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=BA=97=E9=93=BA?= =?UTF-8?q?=E6=98=8E=E7=BB=86=E6=9F=A5=E8=AF=A2=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/user/UserController.php | 12 ++++ app/admin/lists/user/UserLists.php | 1 - app/admin/logic/user/UserLogic.php | 58 +++++++++++++++++++ app/admin/validate/user/UserValidate.php | 6 ++ .../store_finance_flow/StoreFinanceFlow.php | 6 ++ app/common/model/vip_flow/VipFlow.php | 6 ++ 6 files changed, 88 insertions(+), 1 deletion(-) diff --git a/app/admin/controller/user/UserController.php b/app/admin/controller/user/UserController.php index b2046e78..0a8b8503 100644 --- a/app/admin/controller/user/UserController.php +++ b/app/admin/controller/user/UserController.php @@ -65,4 +65,16 @@ class UserController extends BaseAdminController } return $this->fail(UserLogic::getError()); } + + //采购款明细、余额明细、礼品券明细、返还金明细 + public function fundList() + { + $params = (new UserValidate())->goCheck('fund'); + $res = UserLogic::dealDetails($params); + $res['page_no'] = $params['page_no']; + $res['page_size'] = $params['page_size']; + return $this->success('ok', $res); + + } + } \ No newline at end of file diff --git a/app/admin/lists/user/UserLists.php b/app/admin/lists/user/UserLists.php index 2a55422a..c2c4471c 100644 --- a/app/admin/lists/user/UserLists.php +++ b/app/admin/lists/user/UserLists.php @@ -63,7 +63,6 @@ class UserLists extends BaseAdminDataLists implements ListsExcelInterface $data['sex_text'] = $data->sex_text; })->toArray(); foreach ($lists as &$item) { - //返还金,采购款明细、余额明细、礼品券明细、返还金明细 $item['channel'] = UserTerminalEnum::getTermInalDesc($item['channel']); $item['user_address'] = UserAddress::where([ 'uid'=>$item['id'],'is_default'=>YesNoEnum::YES diff --git a/app/admin/logic/user/UserLogic.php b/app/admin/logic/user/UserLogic.php index ff86b002..0f0afc31 100644 --- a/app/admin/logic/user/UserLogic.php +++ b/app/admin/logic/user/UserLogic.php @@ -13,13 +13,18 @@ // +---------------------------------------------------------------------- namespace app\admin\logic\user; +use app\common\enum\OrderEnum; use app\common\enum\user\UserTerminalEnum; +use app\common\enum\YesNoEnum; use app\common\logic\BaseLogic; +use app\common\model\finance\CapitalFlow; use app\common\model\store_finance_flow\StoreFinanceFlow; use app\common\model\user\User; use app\common\model\user\UserAddress; use app\common\model\user\UserRecharge; use app\common\model\user_label\UserLabel; +use app\common\model\user_sign\UserSign; +use app\common\model\vip_flow\VipFlow; use think\facade\Db; use app\common\service\FileService; use Webman\Config; @@ -178,4 +183,57 @@ class UserLogic extends BaseLogic $params['field'] => $params['value'] ]); } + + public static function dealDetails($params) + { + switch ($params['type']){ + case 1: + //采购款明细 + $query =CapitalFlow::where(['uid'=>$params['id']]); + $count = $query->count(); + $data = $query + ->page($params['page_no'],$params['page_size']) + ->select()->toArray(); + break; + case 2: + //余额明细 + + $query = StoreFinanceFlow::with(['store']) + ->where([ + 'other_uid'=>$params['id'],'financial_type'=> OrderEnum::VIP_ORDER_OBTAINS, + 'financial_pm'=>YesNoEnum::YES + ]); + $count = $query->count(); + $data = $query + ->page($params['page_no'],$params['page_size']) + ->select()->toArray(); + + break; + case 3: + //礼品券明细 + $query = UserSign::where(['uid'=>$params['id']]); + $count = $query->count(); + $data =$query + ->page($params['page_no'],$params['page_size']) + ->select()->toArray(); + break; + case 4: + //返还金明细 -todo back + $query = VipFlow::with('store')->where(['user_id'=>$params['id']]); + $count = $query->count(); + $data = $query + ->page($params['page_no'],$params['page_size']) + ->select()->toArray(); + break; + default: + $data = []; + $count = 0; + } + return [ + 'list' => $data, + 'count' => $count + ]; + + + } } diff --git a/app/admin/validate/user/UserValidate.php b/app/admin/validate/user/UserValidate.php index 90911234..f08c1518 100644 --- a/app/admin/validate/user/UserValidate.php +++ b/app/admin/validate/user/UserValidate.php @@ -34,6 +34,7 @@ class UserValidate extends BaseValidate 'village' => 'require', 'brigade' => 'require', 'user_ship' => 'require', + 'type' => 'require|number', ]; @@ -57,9 +58,14 @@ class UserValidate extends BaseValidate 'village' => '村', 'brigade' => ' 队', 'user_ship' => ' 会员类型', + 'type' => '查询类型', ]; + public function sceneFund() + { + return $this->only(['type','id']); + } /** * @notes 添加场景 * @return UserValidate diff --git a/app/common/model/store_finance_flow/StoreFinanceFlow.php b/app/common/model/store_finance_flow/StoreFinanceFlow.php index cbe88609..c3d44962 100644 --- a/app/common/model/store_finance_flow/StoreFinanceFlow.php +++ b/app/common/model/store_finance_flow/StoreFinanceFlow.php @@ -4,6 +4,7 @@ namespace app\common\model\store_finance_flow; use app\common\model\BaseModel; +use app\common\model\system_store\SystemStore; use app\common\model\system_store\SystemStoreStaff; use app\common\model\user\User; use think\model\concern\SoftDelete; @@ -20,6 +21,11 @@ class StoreFinanceFlow extends BaseModel protected $name = 'store_finance_flow'; protected $deleteTime = 'delete_time'; + public function store() + { + return $this->hasOne(SystemStore::class, 'id','store_id') + ->bind(['store_name'=>'name', 'store_phone'=>'phone','store_detailed_address'=>'detailed_address','store_simple_address'=>'address']); + } public function user() { return $this->hasOne(User::class, 'id', 'user_id')->bind(['nickname']); diff --git a/app/common/model/vip_flow/VipFlow.php b/app/common/model/vip_flow/VipFlow.php index 9cc49847..9c62aa87 100644 --- a/app/common/model/vip_flow/VipFlow.php +++ b/app/common/model/vip_flow/VipFlow.php @@ -3,6 +3,7 @@ namespace app\common\model\vip_flow; use app\common\model\BaseModel; +use app\common\model\system_store\SystemStore; use think\model\concern\SoftDelete; class VipFlow extends BaseModel @@ -11,4 +12,9 @@ class VipFlow extends BaseModel protected $name = 'vip_flow'; protected $deleteTime = 'delete_time'; + public function store() + { + return $this->hasOne(SystemStore::class, 'id','store_id') + ->bind(['store_name'=>'name', 'store_phone'=>'phone','store_detailed_address'=>'detailed_address','store_simple_address'=>'address']); + } } \ No newline at end of file From 5e9a77d38cf905347ae3415f557a1e3a5f2f74a5 Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Thu, 20 Jun 2024 11:44:16 +0800 Subject: [PATCH 2/7] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/user/UserController.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/admin/controller/user/UserController.php b/app/admin/controller/user/UserController.php index 0a8b8503..d8649e36 100644 --- a/app/admin/controller/user/UserController.php +++ b/app/admin/controller/user/UserController.php @@ -69,7 +69,12 @@ class UserController extends BaseAdminController //采购款明细、余额明细、礼品券明细、返还金明细 public function fundList() { - $params = (new UserValidate())->goCheck('fund'); + (new UserValidate())->goCheck('fund'); + $page_no = (int)$this->request->post('page_no', 1); + $page_size = (int)$this->request->post('page_size', 15); + $params = $this->request->post(); + $params['page_no'] = $page_no > 0 ? $page_no : 1; + $params['page_size'] = $page_size > 0 ? $page_size : 15; $res = UserLogic::dealDetails($params); $res['page_no'] = $params['page_no']; $res['page_size'] = $params['page_size']; From bc16d06bb64a7b5cc26798b0a794fba63a04a19b Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Thu, 20 Jun 2024 11:50:46 +0800 Subject: [PATCH 3/7] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=9B=9E=E9=80=80?= =?UTF-8?q?=E5=95=86=E6=88=B7=E7=AB=AF=E6=97=B6=E9=97=B4=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/store/logic/WorkbenchLogic.php | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/app/store/logic/WorkbenchLogic.php b/app/store/logic/WorkbenchLogic.php index ea4e9de5..5b7f8872 100644 --- a/app/store/logic/WorkbenchLogic.php +++ b/app/store/logic/WorkbenchLogic.php @@ -45,21 +45,24 @@ class WorkbenchLogic extends BaseLogic public static function index($params) { $data = []; - $startTimeDefault = date('Y-m-d',time()); - $endTimeDefault =date('Y-m-d', strtotime($startTimeDefault) + 86400); + $startTime = $params['start_time']; + $endTime = $params['end_time']; + $endTime = date('Y-m-d', strtotime($endTime) + 86400); + $dateDiff = (new \DateTime($endTime))->diff(new \DateTime($startTime)); + $orderLogic = new StoreOrderLogic(); //订单总金额 - $data['order_amount'] = $orderLogic->storeOrderSumByDate($params['store_id'], $startTimeDefault, $endTimeDefault); + $data['order_amount'] = $orderLogic->storeOrderSumByDate($params['store_id'], $startTime, $endTime); //余额支付总金额 - $data['balance_amount'] = $orderLogic->storeOrderSumByDate($params['store_id'], $startTimeDefault, $endTimeDefault, ['pay_type' => PayEnum::BALANCE_PAY]); + $data['balance_amount'] = $orderLogic->storeOrderSumByDate($params['store_id'], $startTime, $endTime, ['pay_type' => PayEnum::BALANCE_PAY]); //线下收银总金额 - $data['cashier_amount'] = $orderLogic->storeOrderSumByDate($params['store_id'], $startTimeDefault, $endTimeDefault, ['shipping_type' => 3]); + $data['cashier_amount'] = $orderLogic->storeOrderSumByDate($params['store_id'], $startTime, $endTime, ['shipping_type' => 3]); //现金收银总金额 - $data['cash_amount'] = StoreCashFinanceFlow::where('store_id', $params['store_id'])->whereBetweenTime('create_time', $startTimeDefault, $endTimeDefault)->sum('cash_price'); + $data['cash_amount'] = StoreCashFinanceFlow::where('store_id', $params['store_id'])->whereBetweenTime('create_time', $startTime, $endTime)->sum('cash_price'); //核销订单金额 - $data['verify_amount'] = $orderLogic->storeOrderSumByDate($params['store_id'], $startTimeDefault, $endTimeDefault, ['shipping_type' => 2]); + $data['verify_amount'] = $orderLogic->storeOrderSumByDate($params['store_id'], $startTime, $endTime, ['shipping_type' => 2]); //门店收益金额 - $data['income_amount'] = $orderLogic->storeOrderSumByDate($params['store_id'], $startTimeDefault, $endTimeDefault, [], 'profit'); + $data['income_amount'] = $orderLogic->storeOrderSumByDate($params['store_id'], $startTime, $endTime, [], 'profit'); //门店收款金额 $data['receipt_amount'] = UserRecharge::where([ 'store_id'=>$params['store_id'], @@ -68,14 +71,10 @@ class WorkbenchLogic extends BaseLogic //门店成交用户数 $data['user_number'] = StoreOrder::where('store_id', $params['store_id']) ->where('paid', 1) - ->whereBetweenTime('pay_time', $startTimeDefault, $endTimeDefault) + ->whereBetweenTime('pay_time', $startTime, $endTime) ->group('uid') ->count(); - $startTime = $params['start_time']; - $endTime = $params['end_time']; - $endTime = date('Y-m-d', strtotime($endTime) + 86400); - $dateDiff = (new \DateTime($endTime))->diff(new \DateTime($startTime)); if ($dateDiff->days == 1) { $group = 'HOUR(pay_time)'; $i = 0; From 5df4f2d569c4343518e9b9ccba4741b9358d0d10 Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Thu, 20 Jun 2024 13:39:29 +0800 Subject: [PATCH 4/7] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/user/UserController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/admin/controller/user/UserController.php b/app/admin/controller/user/UserController.php index d8649e36..d7a0e5bc 100644 --- a/app/admin/controller/user/UserController.php +++ b/app/admin/controller/user/UserController.php @@ -69,7 +69,7 @@ class UserController extends BaseAdminController //采购款明细、余额明细、礼品券明细、返还金明细 public function fundList() { - (new UserValidate())->goCheck('fund'); + (new UserValidate())->post()->goCheck('fund'); $page_no = (int)$this->request->post('page_no', 1); $page_size = (int)$this->request->post('page_size', 15); $params = $this->request->post(); From 4e6c195d43c65ce0a7987dbf7b88a048effde61d Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Thu, 20 Jun 2024 13:44:11 +0800 Subject: [PATCH 5/7] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/user/UserController.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/admin/controller/user/UserController.php b/app/admin/controller/user/UserController.php index d7a0e5bc..2f83ae7b 100644 --- a/app/admin/controller/user/UserController.php +++ b/app/admin/controller/user/UserController.php @@ -69,10 +69,10 @@ class UserController extends BaseAdminController //采购款明细、余额明细、礼品券明细、返还金明细 public function fundList() { - (new UserValidate())->post()->goCheck('fund'); - $page_no = (int)$this->request->post('page_no', 1); - $page_size = (int)$this->request->post('page_size', 15); - $params = $this->request->post(); + (new UserValidate())->get()->goCheck('fund'); + $page_no = (int)$this->request->get('page_no', 1); + $page_size = (int)$this->request->get('page_size', 15); + $params = $this->request->get(); $params['page_no'] = $page_no > 0 ? $page_no : 1; $params['page_size'] = $page_size > 0 ? $page_size : 15; $res = UserLogic::dealDetails($params); From 304f5fddce92f34cdf02d994929485036586cc45 Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Thu, 20 Jun 2024 13:46:20 +0800 Subject: [PATCH 6/7] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/logic/user/UserLogic.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/admin/logic/user/UserLogic.php b/app/admin/logic/user/UserLogic.php index 0f0afc31..3cf62ac2 100644 --- a/app/admin/logic/user/UserLogic.php +++ b/app/admin/logic/user/UserLogic.php @@ -230,7 +230,7 @@ class UserLogic extends BaseLogic $count = 0; } return [ - 'list' => $data, + 'lists' => $data, 'count' => $count ]; From aafe828da740702994e1a2106cad712ab9418ccb Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Thu, 20 Jun 2024 14:05:35 +0800 Subject: [PATCH 7/7] =?UTF-8?q?=E9=97=A8=E5=BA=97=E5=95=86=E5=93=81?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E4=BF=AE=E6=94=B9=E7=BB=9F=E8=AE=A1=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/store/controller/WorkbenchController.php | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/app/store/controller/WorkbenchController.php b/app/store/controller/WorkbenchController.php index 6617466c..92188eed 100644 --- a/app/store/controller/WorkbenchController.php +++ b/app/store/controller/WorkbenchController.php @@ -102,9 +102,21 @@ class WorkbenchController extends BaseAdminController // ] public function get_basic(\app\admin\controller\WorkbenchController $workbench) { - $params = $this->request->get(); - $params['store_id'] = $this->request->adminInfo['store_id']; - return $workbench->get_basic(); + $dateRange = $this->request->get('date'); + // 拆分日期范围 + list($startDate, $endDate) = explode('-', $dateRange); + $startTime = str_replace('/', '-', $startDate); + $endTime = str_replace('/', '-', $endDate); + if (empty($startTime)) { //如果没有传开始时间,则默认获取最近7天的数据 + $startTime = strtotime(date('Y-m-d')); + $endTime = $startTime + 86400; + } + $where = [ + ['create_time', 'between', [$startTime, $endTime]], + ['store_id','=',$this->request->adminInfo['store_id']] + ]; + $data = \app\admin\logic\WorkbenchLogic::get_basic($where); + return $this->data($data); } // #[