getChannelId(); $distribution_channel_name = $this->getChannelName(); $distribution_channel_name = ''; $start_time = $request->has('start_time') && !empty($request->input('start_time')) ? date('Ymd',strtotime($request->input('start_time'))) : ''; $end_time = $request->has('end_time') && !empty($request->input('end_time')) ? date('Ymd',strtotime($request->input('end_time'))) : ''; $end_time = self::getMaxDay($end_time); $search_name = $request->has('search_name') ? $request->input('search_name') : ''; $params = [ 'channel_id'=>$distribution_channel_id, 'channel_name'=>$distribution_channel_name, 'search_name'=>$search_name, 'start_date'=>$start_time, 'end_date'=>$end_time, ]; $bills = BillService::getBillList($params); return response()->pagination(new BillTransformer(), $bills); } /** * @apiVersion 1.0.0 * @apiDescription 获取结算导出 * @api {GET} exportBills 获取结算导出 * @apiGroup Finance * @apiName exportBills * @apiParam {String} [search_name] 搜索名称 * @apiParam {String} [start_time] 开始时间2017-01-01.(可不传) * @apiParam {String} [end_time] 结束时间2017-02-01.(可不传) */ function export(Request $request) { $distribution_channel_id = $this->getChannelId(); $distribution_channel_name = $this->getChannelName(); $distribution_channel_name = ''; $start_time = $request->has('start_time') ? date('Ymd',strtotime($request->input('start_time'))) : ''; $end_time = $request->has('end_time') ? date('Ymd',strtotime($request->input('end_time'))) : ''; $end_time = self::getMaxDay($end_time); $search_name = $request->has('search_name') ? $request->input('search_name') : ''; $params = [ 'channel_id'=>$distribution_channel_id, 'channel_name'=>$distribution_channel_name, 'search_name'=>$search_name, 'start_date'=>$start_time, 'end_date'=>$end_time, ]; $bills = BillService::getBillList($params, true); header("Content-type:application/vnd.ms-excel"); header("Content-Disposition:attachment;filename=" . "结算" . date("YmdHis") . ".csv"); echo iconv("UTF-8","GBK","\"结算日期\",\"充值金额\",\"佣金比例\",\"扣税金额\",\"结算金额\"\r\n"); if($bills) { foreach($bills as $bill) { echo("\"" . iconv("UTF-8","GBK",date('Y-m-d',strtotime($bill->date))) . "\","); echo("\"" . (float)$bill->recharge_amount . "\","); echo("\"" . ($bill->rate).'%' . "\","); echo("\"" . (float)$bill->tallage . "\","); echo("\"" . (float)$bill->settlement_price. "\"\r\n"); } } exit(); } }