123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- <?php
- namespace App\Http\Controllers\Channel\Finance;
- use App\Http\Controllers\Channel\Finance\Transformers\BillTransformer;
- use App\Modules\Finance\Services\BillService;
- use Illuminate\Http\Request;
- class BillsController extends BaseController
- {
-
-
- function get_list(Request $request) {
- $distribution_channel_id = $this->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);
- }
-
- 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();
- }
- }
|