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
- {
- /**
- * @apiDefine Finance 结算提现模块
- */
- /**
- * @apiVersion 1.0.0
- * @apiDescription 获取结算列表
- * @api {GET} bills 获取结算列表
- * @apiGroup Finance
- * @apiName bills
- * @apiParam {String} [search_name] 搜索名称
- * @apiParam {String} [start_time] 开始时间2017-01-01.(可不传)
- * @apiParam {String} [end_time] 结束时间2017-02-01.(可不传)
- * @apiSuccess {String} date 日期.
- * @apiSuccess {Number} recharge_amount 充值金额.
- * @apiSuccess {Number} settlement_price 结算金额.
- * @apiSuccess {Number} tallage 扣税金额.
- * @apiSuccess {String} rate 比例.
- * @apiSuccessExample {json} Success-Response:
- *
- * {
- * "code": 0,
- * "msg": "",
- * "data":
- * {
- * "list":[
- * {
- * "date": "2017-11-18",
- * "recharge_amount": 1100,
- * "settlement_price": 440,
- * "tallage": 0,
- * "rate": "0.40%"
- * }
- * ]
- * "meta":{
- * "total": 4,
- * "per_page": 15,
- * "current_page": 1,
- * "last_page": 1,
- * "next_page_url": "",
- * "prev_page_url": ""
- * }
- * }
- * }
- */
- 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);
- }
- /**
- * @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();
- }
- }
|