添加网站文件
This commit is contained in:
238
application/admin/logic/WorkersLogLogic.php
Normal file
238
application/admin/logic/WorkersLogLogic.php
Normal file
@@ -0,0 +1,238 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\logic;
|
||||
use app\admin\model\User;
|
||||
use app\api\model\Order;
|
||||
use app\api\model\OrderGoods;
|
||||
use app\common\model\AccountLog;
|
||||
use app\common\model\DistributionOrder;
|
||||
use think\Db;
|
||||
use think\helper\Time;
|
||||
|
||||
class WorkersLogLogic{
|
||||
public static function lists($get){
|
||||
$where = [];
|
||||
$where1 = [];
|
||||
$where2 = [];
|
||||
$where3 = [];
|
||||
|
||||
if (isset($get['start_time']) && $get['start_time'] && isset($get['end_time']) && $get['end_time']) {
|
||||
$where1[] = ['autotime', 'between', [strtotime($get['start_time']), strtotime($get['end_time'])]];
|
||||
$where2[] = ['create_time', 'between', [strtotime($get['start_time']), strtotime($get['end_time'])]];
|
||||
$where3[] = ['createtime', 'between', [strtotime($get['start_time']), strtotime($get['end_time'])]];
|
||||
|
||||
}
|
||||
|
||||
if(isset($get['create_end']) && $get['create_end']!=''){
|
||||
$where1[] = ['autotime','<=',strtotime($get['create_end'])];
|
||||
$where2[] = ['create_time','<=',strtotime($get['create_end'])];
|
||||
$where3[] = ['createtime','<=',strtotime($get['create_end'])];
|
||||
}
|
||||
|
||||
$count = Db::name('admin')
|
||||
|
||||
->count();
|
||||
|
||||
$list = Db::name('admin')
|
||||
->page($get['page'],$get['limit'])
|
||||
->order('id desc')
|
||||
->select();
|
||||
|
||||
foreach ($list as &$item){
|
||||
$item['fworder']=Db::name('order_exe')->where($where1)->where('admin',$item['id'])->where('staff_id','<>',Null)->where('staff_id','<>',0)->count();
|
||||
$item['nuorder']=Db::name('order')->where($where2)->where('admin_id',$item['id'])->where('pay_status',1)->Sum('order_amount');
|
||||
$item['adder']=Db::name('user_address')->where($where3)->where('admin_id',$item['id'])->count();
|
||||
|
||||
}
|
||||
return ['count'=>$count,'lists'=>$list];
|
||||
}
|
||||
|
||||
/**
|
||||
* note 每个资金记录页面的的变动类型
|
||||
* create_time 2020/11/23 9:55
|
||||
*/
|
||||
public static function orderSourceList($type){
|
||||
$list = [];
|
||||
switch ($type){
|
||||
case 1:
|
||||
$list = [
|
||||
[
|
||||
'source' => AccountLog::balance_pay_order,
|
||||
'name' => '订单支付',
|
||||
],
|
||||
[
|
||||
'source' => AccountLog::admin_add_money.','.AccountLog::recharge_money,
|
||||
'name' => '钱包充值',
|
||||
],
|
||||
[
|
||||
'source' => AccountLog::withdraw_to_balance,
|
||||
'name' => '佣金提现',
|
||||
],
|
||||
|
||||
];
|
||||
break;
|
||||
case 2:
|
||||
$list = [
|
||||
[
|
||||
'source' => AccountLog::register_add_integral,
|
||||
'name' => '关注赠送积分',
|
||||
],
|
||||
[
|
||||
'source' => AccountLog::invite_add_integral,
|
||||
'name' => '邀请赠送积分',
|
||||
],
|
||||
[
|
||||
'source' => AccountLog::sign_in_integral,
|
||||
'name' => '签到赠送积分',
|
||||
],
|
||||
[
|
||||
'source' => AccountLog::recharge_give_integral,
|
||||
'name' => '充值赠送积分',
|
||||
],
|
||||
[
|
||||
'source' => AccountLog::order_add_integral,
|
||||
'name' => '消费赠送积分',
|
||||
],
|
||||
[
|
||||
'source' => AccountLog::order_deduction_integral,
|
||||
'name' => '订单抵扣积分',
|
||||
],
|
||||
|
||||
];
|
||||
break;
|
||||
case 3:
|
||||
$list = [
|
||||
[
|
||||
'source' => AccountLog::sign_give_growth,
|
||||
'name' => '签到赠送成长值',
|
||||
],
|
||||
[
|
||||
'source' => AccountLog::recharge_give_growth,
|
||||
'name' => '充值赠送成长值',
|
||||
],
|
||||
[
|
||||
'source' => AccountLog::order_give_growth,
|
||||
'name' => '下单赠送成长值',
|
||||
],
|
||||
];
|
||||
break;
|
||||
}
|
||||
return $list;
|
||||
|
||||
}
|
||||
|
||||
public static function getTime(){
|
||||
$today = array_map(function ($time) {
|
||||
return date('Y-m-d H:i:s', $time);
|
||||
}, Time::today());
|
||||
$yesterday = array_map(function ($time) {
|
||||
return date('Y-m-d H:i:s', $time);
|
||||
}, Time::yesterday());
|
||||
|
||||
$days_ago7 = array_map(function ($time) {
|
||||
return date('Y-m-d H:i:s', $time);
|
||||
}, Time::dayToNow(7));
|
||||
|
||||
$days_ago30 = array_map(function ($time) {
|
||||
return date('Y-m-d H:i:s', $time);
|
||||
}, Time::dayToNow(30, true));
|
||||
$time = [
|
||||
'today' => $today,
|
||||
'yesterday' => $yesterday,
|
||||
'days_ago7' => $days_ago7,
|
||||
'days_ago30' => $days_ago30,
|
||||
];
|
||||
return $time;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//佣金记录
|
||||
public static function getDistributionLog($get)
|
||||
{
|
||||
$where = [];
|
||||
if (!empty($get['distribution_keyword_type']) and !empty($get['distribution_keyword']) and $get['distribution_keyword']) {
|
||||
switch ($get['distribution_keyword_type']) {
|
||||
case 'order_sn':
|
||||
$order_ids = Order::field('id,order_sn')->where('order_sn', $get['distribution_keyword'])->column('id');
|
||||
$og_ids = OrderGoods::field('id,order_id')->whereIn('id', $order_ids)->column('id');
|
||||
$where[] = ['order_goods_id', 'in', $og_ids];
|
||||
break;
|
||||
case 'nickname':
|
||||
$user_ids = User::field('id,sn,nickname')->where('nickname', 'like', '%'.$get['distribution_keyword'].'%')->column('id');
|
||||
$where[] = ['user_id', 'in', $user_ids];
|
||||
break;
|
||||
case 'user_sn':
|
||||
$user_ids = User::field('id,sn,nickname')->where('sn', 'like', '%'.$get['distribution_keyword'].'%')->column('id');
|
||||
$where[] = ['user_id', 'in', $user_ids];
|
||||
break;
|
||||
case 'mobile':
|
||||
$user_ids = User::field('id,sn,mobile')->where('mobile', '=', $get['distribution_keyword'])->column('id');
|
||||
$where[] = ['user_id', 'in', $user_ids];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($get['distribution_status']) and is_numeric($get['distribution_status'])) {
|
||||
$where[] = ['d.status', '=', $get['distribution_status']];
|
||||
}
|
||||
if (!empty($get['distribution_start_time']) and $get['distribution_start_time']) {
|
||||
$where[] = ['d.create_time', '>=', strtotime($get['distribution_start_time'])];
|
||||
}
|
||||
if (!empty($get['distribution_end_time']) and $get['distribution_end_time']) {
|
||||
$where[] = ['d.create_time', '<=', strtotime($get['distribution_end_time'])];
|
||||
}
|
||||
|
||||
// 查询结果
|
||||
$count = DistributionOrder::where($where)->alias('d')
|
||||
->join('order_goods og', 'order_goods_id = og.id')
|
||||
->count();
|
||||
$lists = DistributionOrder::field('d.*, og.order_id')
|
||||
->where($where)->alias('d')
|
||||
->join('order_goods og', 'order_goods_id = og.id')
|
||||
->with('user')
|
||||
->withAttr('order', function ($value, $data) {
|
||||
return Order::field('id,order_sn,order_amount')->where(['id'=>$data['order_id']])->find();
|
||||
})
|
||||
->page($get['page'], $get['limit'])
|
||||
->append(['order'])
|
||||
->order('d.id desc')
|
||||
->select();
|
||||
|
||||
foreach ($lists as &$item) {
|
||||
$item['status_text'] = DistributionOrder::getOrderStatus($item['status']);
|
||||
$item['create_time'] = date('Y-m-d H:i:s', $item['create_time']);
|
||||
}
|
||||
return ['count'=>$count, 'lists'=>$lists];
|
||||
}
|
||||
|
||||
|
||||
//佣金统计
|
||||
public static function withdrawTotalCount($get)
|
||||
{
|
||||
// 今天开始和结束时间戳
|
||||
list($startToday, $endToday) = Time::today();
|
||||
// 本月开始和结束时间戳
|
||||
list($startMonth, $endMonth) = Time::month();
|
||||
|
||||
if ($get['type'] == 'distribution') {
|
||||
// 获取分销佣金总计
|
||||
$distributionToday = DistributionOrder::where('status', 'in', [DistributionOrder::STATUS_WAIT_HANDLE, DistributionOrder::STATUS_SUCCESS])
|
||||
->where('create_time', '>=', $startToday)
|
||||
->where('create_time', '<=', $endToday)
|
||||
->sum('money');
|
||||
|
||||
$distributionMonth = DistributionOrder::where('status', 'in', [DistributionOrder::STATUS_WAIT_HANDLE, DistributionOrder::STATUS_SUCCESS])
|
||||
->where('create_time', '>=', $startMonth)
|
||||
->where('create_time', '<=', $endMonth)
|
||||
->sum('money');
|
||||
|
||||
$distributionTotal = DistributionOrder::where('status', 'in', [DistributionOrder::STATUS_WAIT_HANDLE, DistributionOrder::STATUS_SUCCESS])
|
||||
->sum('money');
|
||||
|
||||
return ['today'=>$distributionToday, 'month'=>$distributionMonth, 'total'=>$distributionTotal];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user