Merge branch 'dev' of https://gitea.lihaink.cn/mkm/multi-store into dev
This commit is contained in:
commit
140fe814c2
@ -65,4 +65,21 @@ class UserController extends BaseAdminController
|
||||
}
|
||||
return $this->fail(UserLogic::getError());
|
||||
}
|
||||
|
||||
//采购款明细、余额明细、礼品券明细、返还金明细
|
||||
public function fundList()
|
||||
{
|
||||
(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);
|
||||
$res['page_no'] = $params['page_no'];
|
||||
$res['page_size'] = $params['page_size'];
|
||||
return $this->success('ok', $res);
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -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
|
||||
|
@ -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 [
|
||||
'lists' => $data,
|
||||
'count' => $count
|
||||
];
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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']);
|
||||
|
@ -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']);
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
|
||||
// #[
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user