1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- <?php
- namespace App\Models;
- use Illuminate\Database\Eloquent\Model;
- class JxTransformRecord extends Model
- {
- protected $table = 'jx_transform_record';
- public $timestamps = false;
- protected static $unguarded = true;
- const PLATFORM_LIST = [1 => '大航海'];
- /**
- * 获取订单列表
- *
- * 该方法根据提供的参数筛选订单,并分页返回订单列表及总数
- * 主要涉及根据订单金额、回传状态、客户和广告主等条件进行筛选
- *
- * @param array $params 筛选条件数组,包含金额范围、回传状态、客户ID和广告主ID等
- * @param int $page 当前页码,用于计算偏移量
- * @param int $pageSize 每页显示的记录数
- *
- * @return array 返回包含订单总数和订单列表的数组
- */
- public static function getTransformList($params, $page, $pageSize)
- {
- # 初始化查询模型
- $queryModel = self::query();
- # 按用户行为类型筛选
- if (is_numeric($params['transform_type'])) {
- $queryModel->where('transform_type', $params['transform_type']);
- }
- # 按回传状态筛选
- if (is_numeric($params['report_action_type'])) {
- $queryModel->where('report_action_type', $params['report_action_type']);
- }
- # 按客户筛选
- if ($params['customer_id']) {
- $queryModel->where('customer_id', $params['customer_id']);
- }
- # 按广告主筛选
- if ($params['advertiser_id']) {
- $queryModel->where('advertiser_id', $params['advertiser_id']);
- }
- # 按起始时间筛选
- if ($params['start_time']) {
- $queryModel->where('created_at', '>=', $params['start_time'] . ' 00:00:00');
- }
- # 按结束时间筛选
- if ($params['end_time']) {
- $queryModel->where('created_at', '<=', $params['end_time'] . ' 23:59:59');
- }
- # 计算满足条件的订单总数
- $count = $queryModel->count();
- # 执行查询,获取当前页的订单列表
- $list = $queryModel->select('id', 'platform', 'transform_type', 'callback_url', 'report_action_type', 'report_order_status', 'customer_id', 'advertiser_id', 'created_at', 'task_id')
- ->offset(($page - 1) * $pageSize)->limit($pageSize)
- ->orderBy('id', 'desc')
- ->get();
- # 返回订单总数和订单列表
- return [$list, $count];
- }
- public static function saveData($data) {
- return self::create($data);
- }
- public static function getInfo($adPlacementLogId, $transformType) {
- return self::query()->where('ad_placement_log_id', $adPlacementLogId)->where('transform_type', $transformType)->first();
- }
- }
|