| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- <?php
- namespace app\v1\logic\customer;
- use plugin\saiadmin\basic\BaseLogic;
- use plugin\saiadmin\exception\ApiException;
- use plugin\saiadmin\utils\Helper;
- use app\v1\model\customer\SdkOrder;
- use DateTime;
- use support\Redis;
- use support\think\Db;
- /**
- * 用户订单记录逻辑层
- */
- class SdkOrderLogic extends BaseLogic
- {
- /**
- * 构造函数
- */
- public function __construct()
- {
- $this->model = new SdkOrder();
- }
- /**
- * 获取订单列表
- */
- public function getOrderList($params)
- {
- $orderBy = $params['orderBy'] ?: 'pay_date';
- $orderType = $params['orderType'] ?: 'DESC';
-
- if(!$params['pay_time']){
- throw new ApiException('请选择时间范围');
- }
- // 获取年月
- $monthRange = getMonthRange($params['pay_time'][0], $params['pay_time'][1]);
- $eqWhere = ["game_id", "user_name", "order_id", "trade_id", "role_id", "role_name"];
- $where = [];
- foreach ($eqWhere as $field){
- if (!empty($params[$field])) {
- $where[$field] = $params[$field];
- }
- }
- if($params['send_status']!=''){
- $where['send_status'] = $params['send_status'];
- }
- if($params['sync_status']!=''){
- $where['sync_status'] = $params['sync_status'];
- }
- $where[] = ['pay_time', 'between', [strtotime($params['pay_time'][0]), strtotime($params['pay_time'][1])]];
- $db = Db::connect('db_game_log');
- $unionQuery = [];
- foreach ($monthRange as $month){
- $tableName = 'sdk_order_' . $month;
- $unionQuery[] = $db->table($tableName)->where($where)->buildSql();
- }
- $fullSql = "(" . implode(' UNION ALL ', $unionQuery) . ") as unTable";
- echo $fullSql;
- $list = $db->table($fullSql)->order($orderBy, $orderType)->paginate($params['limit'])->toArray();
-
- $list['data'] = $this->trandformListColumn($list['data'], ['game', 'pay_channel']);
- $allMoney = $db->table($fullSql)->where(["sync_status"=>1])->value("round(sum(money), 2)");
- $list['totalRow'] = [
- 'money' => $allMoney,
- ];
- return $list;
- }
- /**
- * 补发
- */
- public function send($order_id)
- {
- return Redis::lpush("request_cp_callback_queue", $order_id);
- }
- }
|