ShippingTemplateFreeDao.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. namespace app\common\dao\store\shipping;
  12. use think\facade\Db;
  13. use app\common\dao\BaseDao;
  14. use app\common\model\store\shipping\ShippingTemplateFree as model;
  15. class ShippingTemplateFreeDao extends BaseDao
  16. {
  17. /**
  18. * @Author:Qinii
  19. * @Date: 2020/5/8
  20. * @return string
  21. */
  22. protected function getModel(): string
  23. {
  24. return model::class;
  25. }
  26. /**
  27. * @Author:Qinii
  28. * @Date: 2020/5/8
  29. * @param $field
  30. * @param $value
  31. * @param null $except
  32. * @return bool
  33. */
  34. public function merFieldExists($field, $value, $except = null)
  35. {
  36. return ($this->getModel())::getDB()->when($except, function ($query, $except) use ($field) {
  37. $query->where($field, '<>', $except);
  38. })->where($field, $value)->count() > 0;
  39. }
  40. /**
  41. * 批量删除
  42. * @Author:Qinii
  43. * @Date: 2020/5/8
  44. * @param array $id
  45. * @param array $temp_id
  46. */
  47. public function batchRemove(array $id,array $temp_id)
  48. {
  49. if($id)
  50. ($this->getModel())::getDB()->where($this->getPk(),'in',$id)->delete();
  51. if($temp_id)
  52. ($this->getModel())::getDB()->where('temp_id','in',$temp_id)->delete();
  53. }
  54. /**
  55. * @Author:Qinii
  56. * @Date: 2020/5/13
  57. * @param array $data
  58. * @return mixed
  59. */
  60. public function insertAll(array $data)
  61. {
  62. return ($this->getModel()::getDB())->insertAll($data);
  63. }
  64. }