ShippingTemplateRegionDao.php 1.5 KB

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