SalesOrder.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. namespace App\Model;
  3. use App\Scopes\DepartmentScope;
  4. use Illuminate\Database\Eloquent\Model;
  5. class SalesOrder extends Model
  6. {
  7. protected $fillable = ['userData'];
  8. protected $table = "sales_order"; //指定表
  9. const CREATED_AT = 'crt_time';
  10. const UPDATED_AT = 'upd_time';
  11. protected $dateFormat = 'U';
  12. const Order_type_one = 1;//安装件
  13. const Order_type_two = 2;//快递件
  14. public static $order_type = [
  15. self::Order_type_one => '安装件',
  16. self::Order_type_two => '快递件',
  17. ];
  18. const Model_type_one = 1; // 线下订单合同
  19. const Model_type_two = 2; // 分社订货合同
  20. const Model_type_three = 3; // 二手车精品加装合同
  21. public static $model_type = [
  22. self::Model_type_one,
  23. self::Model_type_two,
  24. self::Model_type_three
  25. ];
  26. const State_zero = 0;//未派单
  27. const State_one = 1;//已派销售
  28. const State_two = 2;//已派公司或分社
  29. const State_three = 3;//已下施工单
  30. const State_four = 4;//退换货
  31. public static $state = [
  32. self::State_zero => '未派单',
  33. self::State_one => '已派销售',
  34. self::State_two => '已派总设或分社',
  35. self::State_three => '已下施工单',
  36. self::State_four => '退换货',
  37. ];
  38. public static $prefix = [
  39. self::Model_type_one => 'T9XS.',
  40. self::Model_type_two => 'T9SO.',
  41. self::Model_type_three => 'T9XS.'
  42. ];
  43. public static $user = [];
  44. public static $is_search = false;
  45. public function __construct(array $attributes = [])
  46. {
  47. if(! empty($attributes['userData'])) {
  48. self::$user = $attributes['userData'];
  49. self::$is_search = true;
  50. }
  51. parent::__construct($attributes);
  52. }
  53. protected static function boot(){
  54. parent::boot();
  55. if(self::$is_search){
  56. static::addGlobalScope(new DepartmentScope(self::$user));
  57. }
  58. }
  59. }