CustomerNotVisit.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. namespace app\model;
  3. use think\Model;
  4. class CustomerNotVisit extends Model
  5. {
  6. /**
  7. * 关联员工
  8. *
  9. * @return BelongsTo
  10. */
  11. public function employee()
  12. {
  13. return $this->belongsTo(Employee::class, 'employee_id');
  14. }
  15. /**
  16. * 关联设计师
  17. * @return BelongsTo
  18. */
  19. public function designer()
  20. {
  21. return $this->belongsTo(Employee::class, 'employee_id');
  22. }
  23. /**
  24. * 关联客户
  25. *
  26. * @return BelongsTo
  27. */
  28. public function customer()
  29. {
  30. return $this->belongsTo(Customer::class, 'customer_id');
  31. }
  32. /**
  33. * 关联部门
  34. */
  35. public function org()
  36. {
  37. return $this->belongsTo(Org::class, 'org_id');
  38. }
  39. /**
  40. * 状态属性获取
  41. */
  42. public function getStateAttr($value)
  43. {
  44. $states = [
  45. '待确认' => [0, '待确认', '0'],
  46. '未到访' => [1, '未到访', '1'],
  47. '已到店' => [2, '已到访', '确认到店', '确定到店', '已到店', '2'],
  48. '已到场' => [3, '确定到场', '确认到场', '已到场', '3'],
  49. '已量房' => [4, '已量房', '确定量房', '确认量房', '4'],
  50. '已交定' => [5, '定金', '交定', '已交定', '5'],
  51. '已签单' => [6, '签单', '已签单', '6'],
  52. '无效' => [7, '无效', '7']
  53. ];
  54. foreach ($states as $k => $arr) {
  55. if (in_array($value, $arr)) return $k;
  56. }
  57. return $value;
  58. }
  59. /**
  60. * 格式化时间
  61. */
  62. public function getAddtimeAttr($value)
  63. {
  64. return date('Y-n-j', strtotime($value));
  65. }
  66. }