yegang 2 rokov pred
rodič
commit
9cf18ddc41

+ 10 - 1
src/main/java/com/sw/service/impl/TMaskServiceImpl.java

@@ -1,5 +1,6 @@
 package com.sw.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.sw.dao.SysUserDao;
 import com.sw.dao.TMaskDao;
@@ -54,10 +55,18 @@ public class TMaskServiceImpl extends ServiceImpl<TMaskDao, TMask> implements TM
         tOrder.setCreateTime(new Date());
         tOrder.setState("1");
         tOrder.setMid(mid);
-        tOrder.setUid(uid+"");
+        tOrder.setUid(uid);
         int insert = tOrderDao.insert(tOrder);
         //4.设置成功缓存
         redisTemplate.opsForSet().add("sucess",uid);
         return "抢购成功,订单号为"+tOrder.getId();
     }
+    @Override
+    public boolean decrease(Integer maskId, Integer remain) {
+        UpdateWrapper<TMask> update = new UpdateWrapper<TMask>();
+        update.eq("id", maskId)
+                .set("mask_stock", remain);
+        return this.update(update);
+    }
+}
 }