123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260 |
- <?php
- namespace App\Http\Controllers\Api;
- use App\Service\OrderService;
- use Illuminate\Http\Request;
- use App\Http\Controllers\Controller;
- class OrderController extends Controller
- {
- /**
- * 获取订单数据统计
- * */
- public function dataStat(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'corpid' => 'nullable|string',
- 'start_date' => 'nullable|date_format:Y-m-d',
- 'end_date' => 'nullable|date_format:Y-m-d',
- 'type' => 'nullable|in:1,2'
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $params['corpid'] = $request->input('corpid');
- $params['order_id'] = $request->input('order_id');
- $params['unionid'] = $request->input('unionid');
- $params['pay_status'] = $request->input('pay_status');
- $params['order_source'] = $request->input('order_source');
- $params['start_date'] = $request->input('start_date');
- $params['end_date'] = $request->input('end_date');
- $params['user_reg_st'] = $request->input('user_reg_st'); // 用户注册起始时间
- $params['user_reg_et'] = $request->input('user_reg_et'); // 用户注册截止时间
- $params['appid'] = $request->input('appid');
- $params['order_type'] = $request->input('order_type'); // 订单类型 1mp投放订单 2adq投放订单
- $params['plat_order_type'] = $request->input('plat_order_type'); // 订单来源 0小程序 1H5
- $params['is_ad_user'] = $request->input('is_ad_user'); // 收入来源 0运营 1投放
- $params['sys_group_id'] = $request->input('sys_group_id');
- $params['account_id'] = $request->input('account_id');
- $params['order_pay_type'] = $request->input('order_pay_type'); // 订单支付类型 1小程序虚拟支付 2其他支付
- $params['ad_report_action_type'] = $request->input('ad_report_action_type');// 1下单 2付费 0全部
- $params['corp_id'] = $request->input('corp_id');
- # 获取订单数据统计
- $data = OrderService::dataStatSecond($params);
- return self::returnValue(['data' => $data]);
- }
- /**
- * 订单列表
- * */
- public function lists(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'corpid' => 'required|string',
- 'start_date' => 'nullable|date_format:Y-m-d',
- 'end_date' => 'nullable|date_format:Y-m-d',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $params['corpid'] = $request->input('corpid');
- $params['order_id'] = $request->input('order_id');
- $params['unionid'] = $request->input('unionid');
- $params['pay_status'] = $request->input('pay_status');
- $params['order_source'] = $request->input('order_source');
- $params['start_date'] = $request->input('start_date');
- $params['end_date'] = $request->input('end_date');
- $params['user_reg_st'] = $request->input('user_reg_st'); // 用户注册起始时间
- $params['user_reg_et'] = $request->input('user_reg_et'); // 用户注册截止时间
- $params['appid'] = $request->input('appid');
- $params['order_type'] = $request->input('order_type'); // 订单类型 1mp投放订单 2adq投放订单
- $params['plat_order_type'] = $request->input('plat_order_type'); // 订单来源 0小程序 1H5
- $params['is_ad_user'] = $request->input('is_ad_user'); // 收入来源 0运营 1投放
- $params['account_id'] = $request->input('account_id');
- $params['sys_group_id'] = $request->input('sys_group_id');
- $params['order_pay_type'] = $request->input('order_pay_type');
- $params['ad_report_action_type'] = $request->input('ad_report_action_type');// 1下单 2付费 0全部
- $params['corp_id'] = $request->input('corp_id');
- $page = $request->input('page', 1);
- $pageSize = $request->input('page_size', 20);
- # 获取订单数据统计
- list($list, $count) = OrderService::getOrderList($params, $params['corpid'], $page, $pageSize);
- return self::returnPageValue($list, $count, $pageSize, $page);
- }
- public function actionUpload(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'order_id' => 'required'
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $orderId = $request->input('order_id');
- $orderDataId = $request->input('order_data_id');
- $errcode = 0;
- OrderService::actionUpload($orderId, $orderDataId, $errcode);
- return self::returnValue([], $errcode);
- }
- public function orderExport(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'corpid' => 'nullable|string',
- 'start_date' => 'nullable|date_format:Y-m-d',
- 'end_date' => 'nullable|date_format:Y-m-d',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $params['corpid'] = $request->input('corpid');
- $params['order_id'] = $request->input('order_id');
- $params['order_source'] = $request->input('order_source');
- $params['start_date'] = $request->input('start_date');
- $params['end_date'] = $request->input('end_date');
- $params['appid'] = $request->input('appid');
- $params['plat_order_type'] = $request->input('plat_order_type'); // 订单来源 0小程序 1H5
- $params['is_ad_user'] = $request->input('is_ad_user'); // 收入来源 0运营 1投放
- $params['sys_group_id'] = $request->input('sys_group_id');
- $params['account_id'] = $request->input('account_id');
- $errcode = 0;
- OrderService::orderExport($params, $errcode);
- }
- // 数据看板订单列表
- public function orderList(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'corpid' => 'nullable|string',
- 'start_date' => 'nullable|date_format:Y-m-d',
- 'end_date' => 'nullable|date_format:Y-m-d',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $params['corpid'] = $request->input('corpid');
- $params['order_id'] = $request->input('order_id');
- $params['order_source'] = $request->input('order_source');
- $params['start_date'] = $request->input('start_date');
- $params['end_date'] = $request->input('end_date');
- $params['appid'] = $request->input('appid');
- $params['plat_order_type'] = $request->input('plat_order_type'); // 订单来源 0小程序 1H5
- $params['is_ad_user'] = $request->input('is_ad_user'); // 收入来源 0运营 1投放
- $params['sys_group_id'] = $request->input('sys_group_id');
- $params['account_id'] = $request->input('account_id');
- $params['order_pay_type'] = $request->input('order_pay_type');
- $page = $request->input('page', 1);
- $pageSize = $request->input('page_size', 20);
- list($list, $count) = OrderService::orderList($params, $page, $pageSize);
- return self::returnPageValue($list, $count, $pageSize, $page);
- }
- public function platformList()
- {
- $list = config('platform.base');
- $data = [];
- foreach ($list as $k => $v) {
- $data[] = [
- 'platform_id' => $k,
- 'platform_title' => $v,
- ];
- }
- return self::returnValue($data);
- }
- public function orderExportOffline(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'corpid' => 'nullable|string',
- 'start_date' => 'nullable|date_format:Y-m-d',
- 'end_date' => 'nullable|date_format:Y-m-d',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $params['corpid'] = $request->input('corpid');
- $params['order_id'] = $request->input('order_id');
- $params['order_source'] = $request->input('order_source');
- $params['start_date'] = $request->input('start_date');
- $params['end_date'] = $request->input('end_date');
- $params['appid'] = $request->input('appid');
- $params['plat_order_type'] = $request->input('plat_order_type'); // 订单来源 0小程序 1H5
- $params['is_ad_user'] = $request->input('is_ad_user'); // 收入来源 0运营 1投放
- $params['sys_group_id'] = $request->input('sys_group_id');
- $params['account_id'] = $request->input('account_id');
- $params['order_pay_type'] = $request->input('order_pay_type');
- $errcode = 0;
- OrderService::orderExportOffline($params, $errcode);
- return self::returnValue([], $errcode);
- }
- public function orderExportList(Request $request)
- {
- $page = $request->input('page', 1);
- $pageSize = $request->input('page_size', 20);
- $sysGroupId = $request->input('sys_group_id');
- list($res, $count) = OrderService::orderExportList($sysGroupId, $page, $pageSize);
- return self::returnPageValue($res, $count, $pageSize, $page);
- }
- # 设置第三方平台订单金额分成比例
- public function setShareInProportionConf(Request $request) {
- $validator = \Validator::make($request->all(),[
- 'sys_group_id' => 'required|numeric|in:1,2,3,4,5,6,7,9',
- 'order_source' => 'required|numeric|in:1,2,3,4,5,6,7,8,9',
- 'android_percent' => 'required',
- 'ios_percent' => 'required',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $sysGroupId = $request->input('sys_group_id');
- $orderSource = $request->input('order_source');
- $androidPercent = $request->input('android_percent');
- $iosPercent = $request->input('ios_percent');
- $errcode = 0;
- OrderService::setShareInProportionConf($sysGroupId, $orderSource, $androidPercent, $iosPercent, $errcode);
- return self::returnValue('', $errcode);
- }
- # 获取第三方平台订单金额分成比例
- public function getShareInProportionConf(Request $request) {
- $validator = \Validator::make($request->all(),[
- 'sys_group_id' => 'required|numeric',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $sysGroupId = $request->input('sys_group_id');
- $data = OrderService::getShareInProportionConf($sysGroupId);
- return self::returnValue($data);
- }
- }
|