ShippingTemplateUndeliveryDao.php 1.3 KB

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