Nav apraksta

SupplementOrderTask.php 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. namespace App\Models;
  3. use Illuminate\Database\Eloquent\Model;
  4. class SupplementOrderTask extends Model
  5. {
  6. protected $table = 'jx_supplement_order_task';
  7. public $timestamps = false;
  8. protected static $unguarded = true;
  9. /**
  10. * 配置批量创建助推订单规则
  11. * */
  12. public static function setConfig($params)
  13. {
  14. if(is_numeric($params['config_id'])) {
  15. $taskModel = self::find($params['config_id']);
  16. if(empty($taskModel)) return 1081;
  17. if($taskModel->status != 1) return 1082;
  18. } else {
  19. $taskModel = new self;
  20. }
  21. $taskModel->title = $params['title'];
  22. $taskModel->admin_id = $params['admin_id'];
  23. $taskModel->customer_id = $params['cust_id'];
  24. $taskModel->advertiser_id = $params['advertiser_id'];
  25. $taskModel->campaign_type = $params['campaign_type'];
  26. $taskModel->unit_charge_type = $params['unit_charge_type'];
  27. $taskModel->unit_price_type = $params['unit_price_type'];
  28. $taskModel->pay_method = $params['pay_method'];
  29. $taskModel->amount = $params['amount'];
  30. $taskModel->promotion_duration = $params['promotion_duration'];
  31. $taskModel->target_type = $params['target_type'];
  32. $taskModel->target_info = $params['target_info'];
  33. $taskModel->unit_price = $params['unit_price'];
  34. $taskModel->create_type = $params['create_type'];
  35. $taskModel->exec_time = $params['exec_time'];
  36. $taskModel->times = $params['times'];
  37. $taskModel->filter = json_encode(json_decode($params['filter'], true), 256);
  38. $result = $taskModel->save();
  39. return $result ? 0 : 1083;
  40. }
  41. /**
  42. * 获取任务列表
  43. * */
  44. public static function getTaskList($customerId, $page, $pageSize)
  45. {
  46. $queryModel = self::where('customer_id', $customerId)->where('enable', 1);
  47. $count = $queryModel->count();
  48. $list = $queryModel->selectRaw("id as config_id, title, admin_id, advertiser_id, create_type, exec_time, status, updated_at")
  49. ->offset(($page-1) * $pageSize)->limit($pageSize)
  50. ->orderBy('id', 'desc')->get();
  51. return [$list, $count];
  52. }
  53. }