作者 刘朕
1 个管道 的构建 通过 耗费 1 秒

数据导出调试

... ... @@ -15,10 +15,11 @@ use think\Db;
class TestController extends HomeBaseController
{
protected $uid = 83; //451
public function prob()
{
$uid = 451;
$uid = $this->uid;
$user = Db::name('user')->where('id',$uid)->find();
$indent = Db::name('indent')->where('salesman_uid',$uid)->order('create_time','desc')->select();
$arr = collection($indent)->toArray();
... ... @@ -31,43 +32,28 @@ class TestController extends HomeBaseController
6 => '待取货'
];
foreach ($arr as &$v) {
$money = Db::name('money_income')->where('uid',$uid)->where('indent_id',$v['id'])->value('money');
$fact_money = Db::name('money_income')->where('uid',$uid)->where('indent_id',$v['id'])->sum('money');
if($v['state'] == 3 || $v['state'] == 5) {
$money = Db::name('money_income')->where('uid',$uid)->where('indent_id',$v['id'])->value('money');
$fact_money = Db::name('money_income')->where('uid',$uid)->where('indent_id',$v['id'])->sum('money');
// $income = Db::name('money_income')->where('uid',$uid)->where('indent_id',$v['id'])->select();
// $v['income'] = collection($income)->toArray();
// $data[] = [
// 'id' => $v['id'],
// 'money' => $money,
// 'number' => $v['book_num'],
// 'name' => $v['name'],
// 'phone' => $v['phone'],
// 'school' => $v['school'].'-'.$v['grade'].$v['class'],
// 'state' => $state_arr[$v['state']],
// 'create_time' => date('Y-m-d H:i:s',$v['create_time']),
// 'pay_time' => date('Y-m-d H:i:s',$v['pay_time']),
// 'region' => $v['region'],
// 'beiyong_address' => $v['beiyong_address'],
// 'award' => $money,
// 'fact_award' => $fact_money,
// 'is_error' => $fact_money != $money ? '是' : '否'
// ];
$data[] = [
$v['id'],
$money,
$v['book_num'],
$v['name'],
$v['phone'],
$v['school'].'-'.$v['grade'].$v['class'],
$state_arr[$v['state']],
date('Y-m-d H:i:s',$v['create_time']),
date('Y-m-d H:i:s',$v['pay_time']),
$v['region'],
$v['beiyong_address'],
$money,
$fact_money,
$fact_money != $money ? '是' : '否'
];
$data[] = [
$v['id'],
$money,
$v['book_num'],
$v['name'],
$v['phone'],
$v['school'].'-'.$v['grade'].$v['class'],
$state_arr[$v['state']],
date('Y-m-d H:i:s',$v['create_time']),
date('Y-m-d H:i:s',$v['pay_time']),
$v['region'],
$v['beiyong_address'],
$money,
$fact_money,
$fact_money != $money ? '是' : '否'
];
}
}
$this->excel($user,$data);
print_r($arr);exit;
... ... @@ -75,7 +61,7 @@ class TestController extends HomeBaseController
public function income()
{
$uid = 451;
$uid = $this->uid;
$user = Db::name('user')->where('id',$uid)->find();
$indent = Db::name('money_income')->where('uid',$uid)->order('create_time','desc')->select();
$arr = collection($indent)->toArray();
... ... @@ -95,7 +81,7 @@ class TestController extends HomeBaseController
public function withdraw_log()
{
$uid = 451;
$uid = $this->uid;
$money_expend = Db::name('money_expend')->where('uid',$uid)->where('state',1)->order('create_time','desc')->select();
$money_expend = collection($money_expend)->toArray();
$data = [];
... ... @@ -226,7 +212,7 @@ class TestController extends HomeBaseController
$excel->getActiveSheet()->setCellValue("$letter[$i]1", "$tableheader[$i]");
}
//填充表格信息
for ($i = 3; $i <= count($data2) + 1; $i++) {
for ($i = 2; $i <= count($data2) + 1; $i++) {
$j = 0;
foreach ($data2[$i - 2] as $key => $value) {
$excel->getActiveSheet()->setCellValue("$letter[$j]$i", "$value");
... ...