model = new SdkOrder(); } /** * 获取订单列表 */ public function getOrderList($params) { $orderBy = $params['orderBy'] ?: 'pay_date'; $orderType = $params['orderType'] ?: 'DESC'; if(!$params['pay_date']){ throw new ApiException('请选择时间范围'); } // 获取年月 $monthRange = getMonthsBetweenDates($params['pay_date'][0], $params['pay_date'][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]; } } $where[] = ['pay_date', 'between', [$params['pay_date'][0]." 00:00:00", $params['pay_date'][1]." 23:59:59"]]; $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"; $list = $db->table($fullSql)->order($orderBy, $orderType)->paginate($params['limit'])->toArray(); $list['data'] = $this->trandformListColumn($list['data'], ['game', 'pay_channel']); $list['totalRow'] = $db->table($fullSql)->where(["sync_status"=>1])->value("round(sum(money), 2)"); return $list; } /** * 补发 */ public function send($order_id) { return Redis::lpush("request_cp_callback_queue", $order_id); } }