ShippingTemplatesRegionDao.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\dao\shipping;
  12. use app\dao\BaseDao;
  13. use app\model\shipping\ShippingTemplatesRegion;
  14. /**
  15. * 指定邮费
  16. * Class ShippingTemplatesRegionDao
  17. * @package app\dao\shipping
  18. */
  19. class ShippingTemplatesRegionDao extends BaseDao
  20. {
  21. /**
  22. * 设置模型
  23. * @return string
  24. */
  25. protected function setModel(): string
  26. {
  27. return ShippingTemplatesRegion::class;
  28. }
  29. /**
  30. * 获取运费模板列表并按照指定字段进行分组
  31. * @param array $where
  32. * @param string $group
  33. * @param string $field
  34. * @param string $key
  35. * @return mixed
  36. */
  37. public function getShippingGroupArray(array $where, string $group, string $field, string $key)
  38. {
  39. return $this->search($where)->group($group)->column($field, $key);
  40. }
  41. /**
  42. * 获取运费模板列表
  43. * @param array $where
  44. * @param string $field
  45. * @param string $key
  46. * @return array
  47. */
  48. public function getShippingArray(array $where, string $field, string $key)
  49. {
  50. return $this->search($where)->column($field, $key);
  51. }
  52. /**
  53. * 根据运费模板id和城市id获得包邮数据列表
  54. * @param array $tempIds
  55. * @param array $cityId
  56. * @param string $field
  57. * @param string $key
  58. * @return array
  59. */
  60. public function getTempRegionList(array $tempIds, array $cityId, string $field = '*', string $key = '*')
  61. {
  62. return $this->getModel()->whereIn('temp_id', $tempIds)->whereIn('city_id', $cityId)->order('city_id asc')->column($field, $key);
  63. }
  64. }