|
@@ -292,4 +292,30 @@ public class ClubServiceImpl implements ClubService {
|
|
|
map.put("userBeans", user.getUserBeans());
|
|
|
return ResponseJson.success(map);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ResponseJson archiveDeduction(Integer userId, Integer archiveId) {
|
|
|
+ // 查询是否已存在用户对该资料的抵扣记录
|
|
|
+ Integer historyId = clubMapper.findBeansHistoryByArchiveId(userId, archiveId);
|
|
|
+ if (null != historyId) {
|
|
|
+ return ResponseJson.error(-1,"请勿重复抵扣");
|
|
|
+ }
|
|
|
+ // 查询用户采美豆数量
|
|
|
+ Integer beansNum = clubMapper.getBeansNumByUserId(userId);
|
|
|
+ if (null == beansNum || beansNum < 50) {
|
|
|
+ return ResponseJson.error(-2, "抱歉,您的采美豆不足以抵扣,无法访问该商品资料");
|
|
|
+ }
|
|
|
+ UserBeansHistoryPo beansHistory = new UserBeansHistoryPo();
|
|
|
+ beansHistory.setUserId(userId);
|
|
|
+ beansHistory.setArchiveId(archiveId);
|
|
|
+ beansHistory.setBeansType(13);
|
|
|
+ beansHistory.setType(1);
|
|
|
+ beansHistory.setNum(500);
|
|
|
+ beansHistory.setPushStatus(0);
|
|
|
+ beansHistory.setAddTime(new Date());
|
|
|
+ registerMapper.insertBeansHistory(beansHistory);
|
|
|
+ beansNum = beansNum - 50;
|
|
|
+ clubMapper.updateUserBeans(userId, beansNum);
|
|
|
+ return ResponseJson.success("抵扣成功");
|
|
|
+ }
|
|
|
}
|