DeliveryStation.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\common\model\delivery;
  12. use app\common\model\BaseModel;
  13. use app\common\model\system\merchant\Merchant;
  14. use crmeb\services\DeliverySevices;
  15. class DeliveryStation extends BaseModel
  16. {
  17. public static function tablePk(): string
  18. {
  19. return 'station_id';
  20. }
  21. public static function tableName(): string
  22. {
  23. return 'delivery_station';
  24. }
  25. public function getBusinessAttr($value, $data)
  26. {
  27. $res = DeliverySevices::create($data['type'])->getBusiness();
  28. foreach ($res as $v) {
  29. if ($value == $v['key']) {
  30. return $v;
  31. }
  32. }
  33. return $value;
  34. }
  35. public function merchant()
  36. {
  37. return $this->hasOne(Merchant::class, 'mer_id','mer_id');
  38. }
  39. public function searchStationNameAttr($query,$value)
  40. {
  41. $query->whereLike('station_name',"%{$value}%");
  42. }
  43. public function searchKeywordAttr($query,$value)
  44. {
  45. $query->whereLike('station_name|contact_name|phone',"%{$value}%");
  46. }
  47. public function searchStatusAttr($query,$value)
  48. {
  49. $query->where('status',$value);
  50. }
  51. public function searchMerIdAttr($query,$value)
  52. {
  53. $query->where('mer_id',$value);
  54. }
  55. public function searchStationIdAttr($query,$value)
  56. {
  57. $query->where('station_id',$value);
  58. }
  59. public function searchIsDelAttr($query,$value)
  60. {
  61. $query->where('is_del',$value);
  62. }
  63. public function searchTypeAttr($query,$value)
  64. {
  65. $query->where('type',$value);
  66. }
  67. public function searchDateAttr($query,$value)
  68. {
  69. getModelTime($query, $value, 'create_time');
  70. }
  71. }