|
@@ -1,16 +1,18 @@
|
|
|
package com.rongwei.bscommon.system.service.impl;
|
|
|
|
|
|
import com.rongwei.bscommon.system.service.PointService;
|
|
|
+import com.rongwei.bscommon.system.service.QhsePointsRedemptionService;
|
|
|
+import com.rongwei.bscommon.system.utils.QHSEUtils;
|
|
|
import com.rongwei.bsentity.domain.QhsePointsRecordUserDo;
|
|
|
+import com.rongwei.bsentity.domain.QhsePointsRedemptionDo;
|
|
|
+import com.rongwei.rwadmincommon.system.vo.SysUserVo;
|
|
|
import com.rongwei.rwcommon.base.R;
|
|
|
+import com.rongwei.rwcommon.utils.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import java.util.List;
|
|
|
-import java.util.stream.Collectors;
|
|
|
-
|
|
|
/**
|
|
|
* PointServiceImpl class
|
|
|
*
|
|
@@ -21,4 +23,36 @@ import java.util.stream.Collectors;
|
|
|
public class PointServiceImpl implements PointService {
|
|
|
private static final Logger log = LoggerFactory.getLogger(PointServiceImpl.class);
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private QhsePointsRedemptionService qhsePointsRedemptionService;
|
|
|
+ @Autowired
|
|
|
+ private QhsePointsRecordUserServiceImpl qhsePointsRecordUserService;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public R userPointExchange(String id) {
|
|
|
+ if (StringUtils.isBlank(id)) {
|
|
|
+ return R.error("参数异常");
|
|
|
+ }
|
|
|
+ QhsePointsRedemptionDo redemptionDo = qhsePointsRedemptionService.getById(id);
|
|
|
+ if (redemptionDo == null) {
|
|
|
+ return R.error("无法获取兑换记录");
|
|
|
+ }
|
|
|
+ String mainid = redemptionDo.getMainid();
|
|
|
+ if (StringUtils.isBlank(mainid)) {
|
|
|
+ return R.error("无法获取用户积分信息");
|
|
|
+ }
|
|
|
+ QhsePointsRecordUserDo pointsRecordUserDo = qhsePointsRecordUserService.getById(mainid);
|
|
|
+ if (pointsRecordUserDo == null) {
|
|
|
+ log.error("无法根据ID:{}获取到用户积分信息", mainid);
|
|
|
+ return R.error("无法获取用户积分信息");
|
|
|
+ }
|
|
|
+ SysUserVo currentUser = QHSEUtils.getCurrentUser();
|
|
|
+ // 本次兑换使用的积分
|
|
|
+ int usepoints = redemptionDo.getUsepoints() == null ? 0 : redemptionDo.getUsepoints();
|
|
|
+
|
|
|
+ qhsePointsRecordUserService.getBaseMapper().updateCurrentpointAndStatus(pointsRecordUserDo.getId(),
|
|
|
+ -usepoints, currentUser.getId(), currentUser.getName());
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
+
|
|
|
}
|