ShippingTemplateUndeliveryDao.php 1.2 KB

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