123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164 |
- <?php
- // +----------------------------------------------------------------------
- // | ThinkAdmin
- // +----------------------------------------------------------------------
- // | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
- // +----------------------------------------------------------------------
- // | 官方网站: http://demo.thinkadmin.top
- // +----------------------------------------------------------------------
- // | 开源协议 ( https://mit-license.org )
- // +----------------------------------------------------------------------
- // | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
- // | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
- // +----------------------------------------------------------------------
- namespace app\admin\controller;
- use app\service\queue\ImportTable2Queue;
- use app\service\queue\WechatQueue;
- use library\Controller;
- use think\cache\driver\Redis;
- use think\Db;
- use think\facade\Validate;
- use app\common\library\PHPExcelService;
- /**
- * 快递管理
- * Class help_center
- */
- class Kd extends Controller
- {
-
- /**
- * 绑定数据表
- * @var string
- */
- protected $table = 'system_kd';
- /**
- * 快递数据管理
- * @auth true
- * @menu true
- * @throws \think\Exception
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\ModelNotFoundException
- * @throws \think\exception\DbException
- * @throws \think\exception\PDOException
- */
- public function index()
- {
- $this->title = '快递数据管理';
- sysoplog('快递管理', '访问快递管理页面');
- $this->_query('system_values')
- ->group('date')
- ->field('id,date')
- ->order('date desc')
- ->dateBetween('date')
- ->page();
- }
- /**
- * 数据列表处理
- * @auth true
- * @menu true
- * @param array $data
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\ModelNotFoundException
- * @throws \think\exception\DbException
- */
- protected function _index_page_filter(&$data){
- $kd = Db::name('system_kd')->field('name')->select();
- $this->kd = $kd;
- foreach ($data as &$v){
- foreach ($kd as &$a){
- if (in_array($a['name'],['中通','申通'])){
- $v[$a['name']] = Db::name('system_values2')
- ->where('date',$v['date'])
- ->where('name',$a['name'])
- ->sum('value') ? : 0;
- }else{
- $value = Db::name('system_values')
- ->where('date',$v['date'])
- ->where('name',$a['name'])
- ->sum('value') ? : 0;
- $value2 = Db::name('system_values2')
- ->where('date',$v['date'])
- ->where('name',$a['name'])
- ->sum('value') ? : 0;
- $v[$a['name']] = floatval(bcadd($value,$value2));
- }
- }
- }
- }
- /**
- * 快递数据管理
- * @auth false
- * @menu false
- * @throws \think\Exception
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\ModelNotFoundException
- * @throws \think\exception\DbException
- * @throws \think\exception\PDOException
- */
- public function index2()
- {
- $this->title = '快递数据管理';
- $query = $this->_query($this->table)->like('name');
- $query->order('id asc')
- ->page();
- }
- /**
- * 数据列表处理
- * @auth false
- * @menu false
- * @param array $data
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\ModelNotFoundException
- * @throws \think\exception\DbException
- */
- protected function _index2_page_filter(&$data)
- {
- $date = '';
- $start_date_time = '';
- $end_date_time = '';
- if (isset($_GET['date']) && $_GET['date']){
- $date = $_GET['date'];
- $time = explode(' - ',$date);
- $start_date_time = $time[0].' 00:00:00';
- $end_date_time = $time[1].' 23:59:59';
- }
- foreach ($data as &$v){
- if (in_array($v['name'],['中通','申通'])){
- $v['value'] = Db::name('system_values2')
- ->when($date,function ($query) use ($date,$start_date_time,$end_date_time){
- $query->whereBetweenTime('date',$start_date_time,$end_date_time);
- })
- ->where('name',$v['name'])
- ->sum('value') ? : 0;
- }else{
- $value = Db::name('system_values')
- ->when($date,function ($query) use ($date,$start_date_time,$end_date_time){
- $query->whereBetweenTime('date',$start_date_time,$end_date_time);
- })
- ->where('name',$v['name'])->sum('value') ? : 0;
- $value2 = Db::name('system_values2')
- ->when($date,function ($query) use ($date,$start_date_time,$end_date_time){
- $query->whereBetweenTime('date',$start_date_time,$end_date_time);
- })
- ->where('name',$v['name'])->sum('value') ? : 0;
- $v['value'] = floatval(bcadd($value,$value2));
- }
- }
- }
- }
|