ShippingTemplatesDao.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. declare (strict_types=1);
  12. namespace app\dao\product\shipping;
  13. use app\dao\BaseDao;
  14. use app\model\product\shipping\ShippingTemplates;
  15. /**
  16. * 运费模版
  17. * Class ShippingTemplatesDao
  18. * @package app\dao\product\shipping
  19. */
  20. class ShippingTemplatesDao extends BaseDao
  21. {
  22. /**
  23. * 设置模型
  24. * @return string
  25. */
  26. protected function setModel(): string
  27. {
  28. return ShippingTemplates::class;
  29. }
  30. /**
  31. * 获取选择模板列表
  32. * @param array $where
  33. * @return array
  34. */
  35. public function getSelectList(array $where = [])
  36. {
  37. return $this->search($where)->order('sort DESC,id DESC')->column('id,name');
  38. }
  39. /**
  40. * 获取
  41. * @param array $where
  42. * @param int $page
  43. * @param int $limit
  44. * @return array
  45. * @throws \think\db\exception\DataNotFoundException
  46. * @throws \think\db\exception\DbException
  47. * @throws \think\db\exception\ModelNotFoundException
  48. */
  49. public function getShippingList(array $where, int $page, int $limit)
  50. {
  51. return $this->search($where)->order('sort DESC,id DESC')->page($page, $limit)->select()->toArray();
  52. }
  53. /**
  54. * 插入数据返回主键id
  55. * @param array $data
  56. * @return int|string
  57. */
  58. public function insertGetId(array $data)
  59. {
  60. return $this->getModel()->insertGetId($data);
  61. }
  62. /**
  63. * 获取运费模板指定条件下的数据
  64. * @param array $where
  65. * @param string $field
  66. * @param string $key
  67. * @return array
  68. */
  69. public function getShippingColumn(array $where, string $field, string $key)
  70. {
  71. return $this->search($where)->column($field, $key);
  72. }
  73. }