feat: 业务团队交易数据统计

master
yin5th 2023-08-18 14:47:57 +08:00
parent 39afee861d
commit a14bd86005
4 changed files with 39 additions and 20 deletions

View File

@ -20,6 +20,7 @@
namespace app\admin\controller; namespace app\admin\controller;
use app\admin\logic\user\BusinessTeamLogic;
use app\common\basics\AdminBase; use app\common\basics\AdminBase;
use app\common\server\JsonServer; use app\common\server\JsonServer;
use app\admin\logic\StatisticsLogic; use app\admin\logic\StatisticsLogic;
@ -51,10 +52,11 @@ class Statistics extends AdminBase
$res = StatisticsLogic::trading($post); $res = StatisticsLogic::trading($post);
return JsonServer::success('',$res); return JsonServer::success('',$res);
} }
return view();
return view('', ['teamList' => BusinessTeamLogic::getBusinessTeamList()]);
} }
//会员分析 //会员分析
public function member() public function member()
{ {

View File

@ -38,7 +38,7 @@ class StatisticsLogic extends Logic
*/ */
public static function visit($post) public static function visit($post)
{ {
//获取今天的时间戳 //获取今天的时间戳
$today = strtotime('today'); $today = strtotime('today');
//近七天的开始日期 //近七天的开始日期
$start_time = $today - 86400 * 7; $start_time = $today - 86400 * 7;
@ -52,7 +52,7 @@ class StatisticsLogic extends Logic
$user_count = Db::name('stat') $user_count = Db::name('stat')
->where([['create_time', 'between', [$start_time, $end_time]]]) ->where([['create_time', 'between', [$start_time, $end_time]]])
->count('id'); ->count('id');
//当前时间戳 //当前时间戳
$start_t = time(); $start_t = time();
//echarts图表数据 //echarts图表数据
@ -90,7 +90,7 @@ class StatisticsLogic extends Logic
*/ */
public static function member($post) public static function member($post)
{ {
//获取今天的时间戳 //获取今天的时间戳
$today = strtotime('today'); $today = strtotime('today');
//近七天的开始日期 //近七天的开始日期
$start_time = $today - 86400 * 7; $start_time = $today - 86400 * 7;
@ -146,7 +146,7 @@ class StatisticsLogic extends Logic
*/ */
public static function trading($post) public static function trading($post)
{ {
//获取今天的时间戳 //获取今天的时间戳
$today = strtotime('today'); $today = strtotime('today');
//近七天的开始日期 //近七天的开始日期
$start_time = $today - 86400 * 7; $start_time = $today - 86400 * 7;
@ -157,10 +157,18 @@ class StatisticsLogic extends Logic
$start_time = strtotime($post['start_time']); $start_time = strtotime($post['start_time']);
$end_time = strtotime($post['end_time']); $end_time = strtotime($post['end_time']);
} }
$where = [];
if (isset($post['team_id']) && $post['team_id'] != '') {
$where[] = ['team_id', '=', $post['team_id']];
}
$order_num = Db::name('order') $order_num = Db::name('order')
->where($where)
->where([['create_time', 'between', [$start_time, $end_time]], ['pay_status', '>', PayEnum::UNPAID]]) ->where([['create_time', 'between', [$start_time, $end_time]], ['pay_status', '>', PayEnum::UNPAID]])
->count('id'); ->count('id');
$order_amount = Db::name('order') $order_amount = Db::name('order')
->where($where)
->where([['create_time', 'between', [$start_time, $end_time]], ['pay_status', '>', PayEnum::UNPAID]]) ->where([['create_time', 'between', [$start_time, $end_time]], ['pay_status', '>', PayEnum::UNPAID]])
->sum('order_amount'); ->sum('order_amount');
@ -177,9 +185,11 @@ class StatisticsLogic extends Logic
$start_now = strtotime(date('Y-m-d', $where_start)); $start_now = strtotime(date('Y-m-d', $where_start));
$end_now = strtotime(date('Y-m-d 23:59:59', $where_start)); $end_now = strtotime(date('Y-m-d 23:59:59', $where_start));
$order_num_add = Db::name('order') $order_num_add = Db::name('order')
->where($where)
->where([['create_time', 'between', [$start_now, $end_now]], ['pay_status', '>', PayEnum::UNPAID]]) ->where([['create_time', 'between', [$start_now, $end_now]], ['pay_status', '>', PayEnum::UNPAID]])
->count('id'); ->count('id');
$order_amount_add = Db::name('order') $order_amount_add = Db::name('order')
->where($where)
->where([['create_time', 'between', [$start_now, $end_now]], ['pay_status', '>', PayEnum::UNPAID]]) ->where([['create_time', 'between', [$start_now, $end_now]], ['pay_status', '>', PayEnum::UNPAID]])
->sum('order_amount'); ->sum('order_amount');
@ -274,7 +284,7 @@ class StatisticsLogic extends Logic
$get['search_key'] = 'sales_volume'; $get['search_key'] = 'sales_volume';
} }
// 商品列表 // 商品列表
$goods_count = Db::name('order')->alias('o') $goods_count = Db::name('order')->alias('o')
->join('order_goods og', 'og.order_id = o.id') ->join('order_goods og', 'og.order_id = o.id')
->join('shop s', 's.id = o.shop_id') ->join('shop s', 's.id = o.shop_id')

View File

@ -70,17 +70,12 @@ class BusinessTeamLogic extends Logic
} }
} }
public static function getBusinessTeamList($selected = []) public static function getBusinessTeamList()
{ {
$levelArr = BusinessTeam::field('id,name,phone') $levelArr = BusinessTeam::field('id,name,phone')
->order('id desc') ->order('id desc')
->select() ->select()
->toArray(); ->toArray();
foreach ($levelArr as &$item) {
if (in_array($item['id'], $selected)) {
$item['selected'] = true;
}
}
return $levelArr; return $levelArr;
} }

View File

@ -22,6 +22,17 @@
</div> </div>
</div> </div>
<div class="layui-inline">
<label class="layui-form-label">业务团队:</label>
<div class="layui-input-block">
<select name="team_id" id="team_id">
<option value="">全部</option>
{foreach $teamList as $team}
<option value="{$team.id}">{$team.name}</option>
{/foreach}
</select>
</div>
</div>
<div class="layui-inline"> <div class="layui-inline">
<button class="layui-btn layui-btn-sm layuiadmin-btn-ad {$view_theme_color}" lay-submit <button class="layui-btn layui-btn-sm layuiadmin-btn-ad {$view_theme_color}" lay-submit
lay-filter="menber-search">查询 lay-filter="menber-search">查询
@ -122,7 +133,7 @@
}); });
//清空查询 //清空查询
form.on('submit(menber-clear-search)', function () { form.on('submit(menber-clear-search)', function () {
$('#start_time').val(''); $('#start_time').val('');
$('#end_time').val(''); $('#end_time').val('');
graphData(); graphData();
@ -138,9 +149,10 @@
function graphData(){ function graphData(){
var start_time = $('#start_time').val(); var start_time = $('#start_time').val();
var end_time = $('#end_time').val(); var end_time = $('#end_time').val();
var team_id = $('#team_id').val();
like.ajax({ like.ajax({
url:'{:url("statistics/trading")}', url:'{:url("statistics/trading")}',
data: {'start_time':start_time,'end_time':end_time}, data: {'start_time':start_time,'end_time':end_time, 'team_id': team_id},
type: "post", type: "post",
success: function (res) { success: function (res) {
$('#order_num').text(res.data.order_num); $('#order_num').text(res.data.order_num);
@ -150,7 +162,7 @@
$('#end_time').val(res.data.end_time); $('#end_time').val(res.data.end_time);
start_time = res.data.start_time; start_time = res.data.start_time;
end_time = res.data.end_time; end_time = res.data.end_time;
var tradingNum = res.data.echarts_count; var tradingNum = res.data.echarts_count;
var newMember = res.data.echarts_order_num_add; var newMember = res.data.echarts_order_num_add;
var newAmountMember = res.data.echarts_order_amount_add; var newAmountMember = res.data.echarts_order_amount_add;
@ -173,7 +185,7 @@
} }
}); });
} }
//成交订单-图标设置 //成交订单-图标设置
@ -304,7 +316,7 @@
}; };
return option; return option;
} }
//营业额-图标设置 //营业额-图标设置
function setOptionView(tradingNum, newTrading, xData) { function setOptionView(tradingNum, newTrading, xData) {
option = { option = {
@ -433,7 +445,7 @@
}; };
return option; return option;
} }
}); });
</script> </script>