ProductAssistSkuDao.php 977 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. namespace app\common\dao\store\product;
  3. use app\common\dao\BaseDao;
  4. use app\common\model\store\product\ProductAssistSku;
  5. use think\facade\Db;
  6. class ProductAssistSkuDao extends BaseDao
  7. {
  8. protected function getModel(): string
  9. {
  10. return ProductAssistSku::class;
  11. }
  12. public function clear($id)
  13. {
  14. $this->getModel()::getDB()->where('product_assist_id',$id)->delete();
  15. }
  16. public function descStock(int $product_assist_id, string $unique, int $desc)
  17. {
  18. return $this->getModel()::getDB()->where('product_assist_id', $product_assist_id)->where('unique', $unique)->update([
  19. 'stock' => Db::raw('stock-' . $desc)
  20. ]);
  21. }
  22. public function incStock(int $product_assist_id, string $unique, int $desc)
  23. {
  24. return $this->getModel()::getDB()->where('product_assist_id', $product_assist_id)->where('unique', $unique)->update([
  25. 'stock' => Db::raw('stock+' . $desc)
  26. ]);
  27. }
  28. }