DiyDao.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2022 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\system\diy;
  12. use app\common\dao\BaseDao;
  13. use app\common\model\system\diy\Diy;
  14. use think\facade\Db;
  15. class DiyDao extends BaseDao
  16. {
  17. protected function getModel(): string
  18. {
  19. return Diy::class;
  20. }
  21. public function setUsed($id, $merId)
  22. {
  23. $res = $this->getModel()::getDb()->find($id);
  24. $this->getModel()::getDb()->where('mer_id', $merId)->where('is_default' ,0)->update(['status'=>0]);
  25. if (!$res['is_default']) {
  26. $this->getModel()::getDb()->where('mer_id', $merId)->where('id',$id)->update(['status'=> 1]);
  27. }
  28. }
  29. public function merExists(int $merId, int $id)
  30. {
  31. return ($this->getModel()::getDb()->where('mer_id', $merId)->where($this->getPk(), $id)->count() > 0 );
  32. }
  33. }