ShippingTemplatesDao.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. declare (strict_types=1);
  12. namespace app\dao\shipping;
  13. use app\dao\BaseDao;
  14. use app\model\shipping\ShippingTemplates;
  15. /**
  16. *
  17. * Class ShippingTemplatesDao
  18. * @package app\dao\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. * @return array
  33. */
  34. public function getSelectList()
  35. {
  36. return $this->search()->order('sort DESC,id DESC')->column('id,name');
  37. }
  38. /**
  39. * 获取
  40. * @param array $where
  41. * @param int $page
  42. * @param int $limit
  43. * @return array
  44. * @throws \think\db\exception\DataNotFoundException
  45. * @throws \think\db\exception\DbException
  46. * @throws \think\db\exception\ModelNotFoundException
  47. */
  48. public function getShippingList(array $where, int $page, int $limit)
  49. {
  50. return $this->search($where)->order('sort DESC,id DESC')->page($page, $limit)->select()->toArray();
  51. }
  52. /**
  53. * 插入数据返回主键id
  54. * @param array $data
  55. * @return int|string
  56. */
  57. public function insertGetId(array $data)
  58. {
  59. return $this->getModel()->insertGetId($data);
  60. }
  61. /**
  62. * 获取运费模板指定条件下的数据
  63. * @param array $where
  64. * @param string $field
  65. * @param string $key
  66. * @return array
  67. */
  68. public function getShippingColumn(array $where, string $field, string $key)
  69. {
  70. return $this->search($where)->column($field, $key);
  71. }
  72. }