feat: 添加获取日、周、月账单列表API
This commit is contained in:
parent
fa4e005459
commit
5b27ec955f
@ -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());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -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,
|
||||
|
@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\lists\store_finance_flow;
|
||||
|
||||
|
||||
use app\admin\lists\BaseAdminDataLists;
|
||||
use app\common\model\store_finance_flow\StoreFinanceFlow;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
|
||||
|
||||
/**
|
||||
* 门店日账单列表
|
||||
* Class StoreFinanceFlowDayLists
|
||||
* @package app\admin\listsstore_finance_flow
|
||||
*/
|
||||
class StoreFinanceFlowDayLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
* @author admin
|
||||
* @date 2024/05/31 16:56
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['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();
|
||||
}
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\lists\store_finance_flow;
|
||||
|
||||
|
||||
use app\admin\lists\BaseAdminDataLists;
|
||||
use app\common\model\store_finance_flow\StoreFinanceFlow;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
|
||||
|
||||
/**
|
||||
* 门店月账单列表
|
||||
* Class StoreFinanceFlowMonthLists
|
||||
* @package app\admin\listsstore_finance_flow
|
||||
*/
|
||||
class StoreFinanceFlowMonthLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
* @author admin
|
||||
* @date 2024/05/31 16:56
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['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();
|
||||
}
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\lists\store_finance_flow;
|
||||
|
||||
|
||||
use app\admin\lists\BaseAdminDataLists;
|
||||
use app\common\model\store_finance_flow\StoreFinanceFlow;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
|
||||
|
||||
/**
|
||||
* 门店周账单列表
|
||||
* Class StoreFinanceFlowWeekLists
|
||||
* @package app\admin\listsstore_finance_flow
|
||||
*/
|
||||
class StoreFinanceFlowWeekLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
* @author admin
|
||||
* @date 2024/05/31 16:56
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['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();
|
||||
}
|
||||
}
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user