StoreSeckillActiveRepository.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. namespace app\common\repositories\store;
  3. use app\common\dao\store\StoreSeckillActiveDao;
  4. use app\common\repositories\BaseRepository;
  5. use app\common\repositories\store\product\ProductRepository;
  6. use app\common\repositories\store\product\SpuRepository;
  7. use FormBuilder\Factory\Elm;
  8. use think\exception\ValidateException;
  9. use think\facade\Route;
  10. class StoreSeckillActiveRepository extends BaseRepository
  11. {
  12. /**
  13. * @var StoreSeckillActiveDao
  14. */
  15. protected $dao;
  16. /**
  17. * StoreSeckillTimeRepository constructor.
  18. * @param StoreSeckillActiveDao $dao
  19. */
  20. public function __construct(StoreSeckillActiveDao $dao)
  21. {
  22. $this->dao = $dao;
  23. }
  24. public function updateSort(int $id,?int $merId,array $data)
  25. {
  26. $where[$this->dao->getPk()] = $id;
  27. if($merId) $where['mer_id'] = $merId;
  28. $ret = $this->dao->getWhere($where);
  29. if(!$ret) throw new ValidateException('数据不存在');
  30. app()->make(ProductRepository::class)->update($ret['product_id'],$data);
  31. $make = app()->make(SpuRepository::class);
  32. return $make->updateSort($ret['product_id'],$ret[$this->dao->getPk()],1,$data);
  33. }
  34. }