StoreSeckillActiveRepository.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2020 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\repositories\store;
  12. use app\common\dao\store\StoreSeckillActiveDao;
  13. use app\common\repositories\BaseRepository;
  14. use app\common\repositories\store\product\ProductRepository;
  15. use app\common\repositories\store\product\SpuRepository;
  16. use FormBuilder\Factory\Elm;
  17. use think\exception\ValidateException;
  18. use think\facade\Route;
  19. class StoreSeckillActiveRepository extends BaseRepository
  20. {
  21. /**
  22. * @var StoreSeckillActiveDao
  23. */
  24. protected $dao;
  25. /**
  26. * StoreSeckillTimeRepository constructor.
  27. * @param StoreSeckillActiveDao $dao
  28. */
  29. public function __construct(StoreSeckillActiveDao $dao)
  30. {
  31. $this->dao = $dao;
  32. }
  33. public function updateSort(int $id,?int $merId,array $data)
  34. {
  35. $where[$this->dao->getPk()] = $id;
  36. if($merId) $where['mer_id'] = $merId;
  37. $ret = $this->dao->getWhere($where);
  38. if(!$ret) throw new ValidateException('数据不存在');
  39. app()->make(ProductRepository::class)->update($ret['product_id'],$data);
  40. $make = app()->make(SpuRepository::class);
  41. return $make->updateSort($ret['product_id'],$ret[$this->dao->getPk()],1,$data);
  42. }
  43. }