123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- <?php
- namespace App\Models;
- use Illuminate\Database\Eloquent\Model;
- class SupplementOrderTask extends Model
- {
- protected $table = 'jx_supplement_order_task';
- public $timestamps = false;
- protected static $unguarded = true;
- /**
- * 配置批量创建助推订单规则
- * */
- public static function setConfig($params)
- {
- if(is_numeric($params['config_id'])) {
- $taskModel = self::find($params['config_id']);
- if(empty($taskModel)) return 1081;
- if($taskModel->status != 1) return 1082;
- } else {
- $taskModel = new self;
- }
- $taskModel->title = $params['title'];
- $taskModel->admin_id = $params['admin_id'];
- $taskModel->customer_id = $params['cust_id'];
- $taskModel->advertiser_id = $params['advertiser_id'];
- $taskModel->campaign_type = $params['campaign_type'];
- $taskModel->unit_charge_type = $params['unit_charge_type'];
- $taskModel->unit_price_type = $params['unit_price_type'];
- $taskModel->pay_method = $params['pay_method'];
- $taskModel->amount = $params['amount'];
- $taskModel->promotion_duration = $params['promotion_duration'];
- $taskModel->target_type = $params['target_type'];
- $taskModel->target_info = $params['target_info'];
- $taskModel->unit_price = $params['unit_price'];
- $taskModel->create_type = $params['create_type'];
- $taskModel->exec_time = $params['exec_time'];
- $taskModel->times = $params['times'];
- $taskModel->filter = json_encode(json_decode($params['filter'], true), 256);
- $result = $taskModel->save();
- return $result ? 0 : 1083;
- }
- /**
- * 获取任务列表
- * */
- public static function getTaskList($customerId, $page, $pageSize)
- {
- $queryModel = self::where('customer_id', $customerId)->where('enable', 1);
- $count = $queryModel->count();
- $list = $queryModel->selectRaw("id as config_id, title, admin_id, advertiser_id, create_type, exec_time, status, updated_at")
- ->offset(($page-1) * $pageSize)->limit($pageSize)
- ->orderBy('id', 'desc')->get();
- return [$list, $count];
- }
- }
|