title = '渠道统计列表'; $query = $this->_query($this->table); $date = input('date'); if ($date) { $date = str_replace('-', '', $date); $temp = explode('~', $date); $query->whereRaw('(replace(day, "-", "")+0) >= '. $temp[0] . ' and (replace(day, "-", "")+0) <= ' . $temp[1]); } $query->equal('day')->dateBetween('create_at'); $field = '*,(replace(day, "-", "")+0) as day_num'; $order = 'day_num desc,id desc'; $query->field($field); if (input('output') === 'json') { $result = $query->order($order)->page(true, false); $this->success('获取数据列表成功', $result); } else { $query->order($order)->page(); } } /** * 数据列表处理 * @param array $data * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ protected function _page_filter(&$data) { $this->clist = OrderService::instance()->getChannelList(false, false); $this->mlist = OrderService::instance()->getMerchantList(false, false); $this->plist = OrderService::instance()->getProductList(false, false); $service = AccountService::instance(); foreach ($data as &$vo) { //$vo['channel_yue'] = $service->db()->where(array('cid' => $vo['cid'], 'day' => $vo['day']))->sum('num'); $vo['order'] = $this->order_table($vo); $vo['account'] = $this->account_table($vo); $vo['cname'] = $this->clist[$vo['cid']]['name']; //$vo['pname'] = $this->plist[$vo['pid']]['name']; } } private function order_table($data) { $table = ''; $table .= ''; $table .= ''; $table .= '
订单总金额 订单失败金额 订单成功金额 渠道折扣金额
'.$data['order_total'].' '.$data['order_fail'].' '.$data['order_success'].' '.$data['order_channel_cash'].'
'; return $table; } private function account_table($data) { $table = ''; $table .= ''; $table .= ''; $table .= '
商户折扣金额 渠道折扣金额 账单利润
'.$data['account_success'].' '.$data['account_product_success'].' '.$data['account_profit'].'
'; return $table; } }