Commit 077b355abd3398253c084562c03abe27faeb4729

Authored by teemitop
1 parent 21bdd5ea

数据统计

... ... @@ -574,58 +574,114 @@ class Card extends Common
}
/**
* 商家卡券-数据统计-统计列表
* 商家卡券-数据统计-某个商家订单详情
*/
public function sellercarddatalog(){
$data = Request::except('file');
if(Request::isAjax()){
$data = Request::except('file');
$where = '';
$channel = $data['channel'] ? $data['channel'] : 1;
$where .= ($channel && $channel==4) ? ' re.type_id in (1,2,3)' : " re.type_id in ($channel)";
$where .= $data['key'] ? ' and s.sellername like "%'.$data['key'].'%"' : "";
$where .= ($channel && $channel==4) ? 'rel.type_id in (1,2,3)' : 'rel.type_id in (1,2,3)';//"rel.type_id in ($channel)";
//证明是需要根据名称搜索,忽略隐藏域商家ID
$where .= $data['key'] ? ' AND s.sellername = "%'.$data['key'].'%"' : ' AND s.id = '.$data['seller_id'].'';
//日期
$time = $data['time'] ? explode(' - ', $data['time']) : '';
$start = $time ? strtotime(date($time[0],time())) : 0;
$end = $time ? strtotime(date($time[1],time())) : 0;
$where .= $data['time'] ? ' AND r.cdate BETWEEN '.$start.' AND '.$end : '';
$offset = ($data["page"] - 1) * $data["limit"];
$limit = " LIMIT $offset,".$data['limit'];
//卡券信息
//订单信息
$rs = Db::query("SELECT
s.*
r.id,
r.sid,
r.tableinfo,
r.ddate,
r.ddate_solt,
r.rname,
r.sex,
s.sellername,
data_rel.cid,
data_rel.oid
FROM
`xt-member-two-LINE`.xt_dc_dz_card_info AS s
LEFT JOIN `xt-member-two-LINE`.xt_dc_dz_seller_type_rel AS re ON re.sid = s.sid
WHERE s.owner = 2 AND
".$where." order by s.sid".$limit);
`xt-member-two-LINE`.xt_dc_reserve AS r
LEFT JOIN `xt-member-two-LINE`.xt_seller AS s ON r.sid = s.id
LEFT JOIN `xt-member-two-LINE`.xt_dc_dz_seller_type_rel AS rel ON rel.sid = s.id
LEFT JOIN `xt-member-two-LINE`.xt_dc_dz_card_data_rel AS data_rel ON data_rel.rid = r.id
WHERE
".$where.$limit);
//格式化数据
foreach ($rs as $key => $value) {
$rs[$key]['create_time'] = date("Y年m月d日",$value['create_time']);
switch ($value['status']) {
$rs[$key]['rname'] = $value['sex']==1 ? $value['rname'].'先生' : ($value['sex']==2 ? $value['rname'].'女士' : $value['rname']);
$rs[$key]['ddate'] = date("Y年m月d日",$value['ddate']);
$rs[$key]['tableinfo'] = $value['tableinfo'] ? implode(',', array_column(json_decode($value['tableinfo']), 'name')) : '';
switch ($value['ddate_solt']) {
case '1':
$rs[$key]['status'] = '已投放';
$rs[$key]['ddate_solt'] = '早餐';
break;
case '2':
$rs[$key]['status'] = '未投放';
$rs[$key]['ddate_solt'] = '午餐';
break;
case '3':
$rs[$key]['status'] = '停止投放';
$rs[$key]['ddate_solt'] = '晚餐';
break;
default:
# code...
break;
}
//查询账单所牵扯的卡券
if($value['oid']) {
$card_title = Db::query("SELECT
i.card_title
FROM
`xt-member-two-LINE`.xt_dc_dz_discount_act act
LEFT JOIN `xt-member-two-LINE`.xt_dc_dz_card_data_rel rel ON act.cid = rel.id
LEFT JOIN `xt-member-two-LINE`.xt_dc_dz_card_info i ON rel.cid = i.id
WHERE
orderid = ".$value['oid']);
$rs[$key]['card_title'] = implode("<br/>", array_column($card_title, 'card_title'));
//查询提前买单账单金额
$price = Db::query("SELECT
should_price,
actual_price
FROM
`xt-member-two-LINE`.xt_dc_dz_seller_flowing_log
WHERE
rid = ".$value['id']);
$rs[$key]['should_price'] = $price ? $price['should_price'] : '';
$rs[$key]['actual_price'] = $price ? $price['actual_price'] : '';
}
}
//获取总条数
$total = Db::query("SELECT
s.id
FROM
`xt-member-two-LINE`.xt_dc_dz_card_info AS s
LEFT JOIN `xt-member-two-LINE`.xt_dc_dz_seller_type_rel AS re ON re.sid = s.sid
WHERE s.owner = 2 AND
".$where."");
r.id,
r.sid,
r.tableinfo,
r.ddate,
r.ddate_solt,
r.rname,
r.sex,
s.sellername,
data_rel.cid,
data_rel.oid
FROM
`xt-member-two-LINE`.xt_dc_reserve AS r
LEFT JOIN `xt-member-two-LINE`.xt_seller AS s ON r.sid = s.id
LEFT JOIN `xt-member-two-LINE`.xt_dc_dz_seller_type_rel AS rel ON rel.sid = s.id
LEFT JOIN `xt-member-two-LINE`.xt_dc_dz_card_data_rel AS data_rel ON data_rel.rid = r.id
WHERE
".$where);
return $result = ['code'=>0,'msg'=>'获取成功!','data'=>$rs,'count'=>count($total),'rel'=>1];
}
$this->assign ( 'sid',$data['id']);
$this->assign ( 'title','商家卡券信息统计');
return $this->fetch();
}
... ...
... ... @@ -17,14 +17,6 @@
<i class="fa fa-file-image-o"></i> 数据统计
</a>
</blockquote>
<blockquote class="layui-elem-quote">
<a href="{:url('card/sellercarddatalist')}" class="layui-btn layui-btn-sm layui-btn-danger">
<i class="fa fa-file-image-o"></i> 卡券数据
</a>
<a href="{:url('card/sellercarddatalog')}" class="layui-btn layui-btn-sm">
<i class="fa fa-file-image-o"></i> 使用记录
</a>
</blockquote>
<div class="demoTable">
商家名称:<div class="layui-inline">
... ... @@ -53,6 +45,10 @@
</div>
{include file="common/foot"/}
<script type="text/html" id="action">
<a href="{:url('sellercarddatalog')}?id={{d.sid}}&name={{d.sellername}}" class="layui-btn layui-btn-xs">查看订单</a>
</script>
<script>
layui.use(['table','form','laydate'], function() {
var table = layui.table,laydate = layui.laydate,form = layui.form,$ = layui.jquery,layer = layui.layer;
... ... @@ -74,7 +70,8 @@
{field: 'write_off_people_number', align: 'center', title: '核销人数'},
{field: 'write_off_people_frequency', align: 'center', title: '核销次数'},
{field: 'amount_receivable', align: 'center', title: '应收金额'},
{field: 'paid_in_amount', align: 'center', title: '实收金额'}
{field: 'paid_in_amount', align: 'center', title: '实收金额'},
{align: 'center', width:200,title: '操作', toolbar: '#action'}
]]
,id: 'cardReload'
,page: true
... ...
{include file="common/head"/}
<style>
.layui-table-cell {
height: auto;
}
</style>
<div class="admin-main layui-anim layui-anim-upbit">
<fieldset class="layui-elem-field layui-field-title">
<legend>{:$title}</legend>
... ... @@ -17,16 +22,9 @@
<i class="fa fa-file-image-o"></i> 数据统计
</a>
</blockquote>
<blockquote class="layui-elem-quote">
<a href="{:url('card/sellercarddatalist')}" class="layui-btn layui-btn-sm">
<i class="fa fa-file-image-o"></i> 卡券数据
</a>
<a href="{:url('card/sellercarddatalog')}" class="layui-btn layui-btn-sm layui-btn-danger">
<i class="fa fa-file-image-o"></i> 使用记录
</a>
</blockquote>
<div class="demoTable">
<input type="hidden" name="sid" id="sid" value="{:$sid}" autocomplete="off">
商家名称:<div class="layui-inline">
<input class="layui-input" name="key" id="key" placeholder="{:lang('pleaseEnter')}店铺名称" autocomplete="off">
</div>
... ... @@ -44,10 +42,7 @@
<div class="layui-inline">
<label class="layui-form-label">日期范围</label>
<div class="layui-input-inline">
<input type="text" class="layui-input" id="start" placeholder="yyyy-MM-dd">
</div>至
<div class="layui-input-inline">
<input type="text" class="layui-input" id="end" placeholder="yyyy-MM-dd">
<input type="text" class="layui-input" id="time" placeholder="默认查询所有">
</div>
</div>
<button class="layui-btn" id="search" data-type="reload">查询统计</button>
... ... @@ -61,19 +56,22 @@
var table = layui.table,laydate = layui.laydate,form = layui.form,$ = layui.jquery,layer = layui.layer;
var tableIn = table.render({
elem: '#list',
url: '{:url("sellercarddatalist")}',
url: '{:url("sellercarddatalog")}',
method: 'post',
title: '卡券列表',
toolbar: '#toolbarDemo',
where:{seller_id:$('#sid').val()},//将默认参数传递与后台
cols: [[
{field: 'id', title: '商家卡券编号',hide:true, fixed: true},
{field: 'sid', title: '商家编号', fixed: true},
{field: 'sellername', title: '商家名称'},
{field: 'card_title', title: '卡券名称'},
{field: 'price', align: 'center',title: '金额'},
{field: 'create_time', align: 'center', title: '创建日期'},
{field: 'creator', align: 'center', title: '创建人'},
{field: 'status', align: 'center',title: '状态'}
{field: 'ddate', title: '到店日期'},
{field: 'ddate_solt', title: '时段'},
{field: 'tableinfo', title: '包间名称'},
{field: 'rname', title: '客户姓名'},
{field: 'card_title',title: '卡券'},
{field: 'should_price', align: 'center',title: '应收金额'},
{field: 'actual_price', align: 'center', title: '实收金额'}
]]
,id: 'cardReload'
,page: true
... ... @@ -121,14 +119,10 @@
}
};
//开启公历节日
laydate.render({
elem: '#start'
,calendar: true
});
//日期插件
laydate.render({
elem: '#end'
,calendar: true
});
elem: '#time'
,range: true
})
})
</script>
\ No newline at end of file
... ...