Commit 9ffeceec authored by 332784038@qq.com's avatar 332784038@qq.com

Merge remote-tracking branch 'origin/release' into release

parents e15785a4 c5fbbba8
...@@ -48,14 +48,14 @@ public class ScoreRuleController { ...@@ -48,14 +48,14 @@ public class ScoreRuleController {
@PostMapping("/create") @PostMapping("/create")
@ApiOperation("创建积分规则") @ApiOperation("创建积分规则")
@Idempotent(timeout = 3) @Idempotent(timeout = 3)
@PreAuthorize("@ss.hasPermission('member:score-rule:create')") //@PreAuthorize("@ss.hasPermission('member:score-rule:create')")
public CommonResult<Long> createScoreRule(@Valid @RequestBody ScoreRuleCreateReqVO createReqVO) { public CommonResult<Long> createScoreRule(@Valid @RequestBody ScoreRuleCreateReqVO createReqVO) {
return success(scoreRuleService.createScoreRule(createReqVO)); return success(scoreRuleService.createScoreRule(createReqVO));
} }
@PostMapping("/update") @PostMapping("/update")
@ApiOperation("更新积分规则") @ApiOperation("更新积分规则")
@PreAuthorize("@ss.hasPermission('member:score-rule:update')") //@PreAuthorize("@ss.hasPermission('member:score-rule:update')")
public CommonResult<Boolean> updateScoreRule(@Valid @RequestBody ScoreRuleUpdateReqVO updateReqVO) { public CommonResult<Boolean> updateScoreRule(@Valid @RequestBody ScoreRuleUpdateReqVO updateReqVO) {
scoreRuleService.updateScoreRule(updateReqVO); scoreRuleService.updateScoreRule(updateReqVO);
return success(true); return success(true);
...@@ -63,7 +63,7 @@ public class ScoreRuleController { ...@@ -63,7 +63,7 @@ public class ScoreRuleController {
@PostMapping("/delete") @PostMapping("/delete")
@ApiOperation("删除积分规则") @ApiOperation("删除积分规则")
@PreAuthorize("@ss.hasPermission('member:score-rule:delete')") //@PreAuthorize("@ss.hasPermission('member:score-rule:delete')")
public CommonResult<Boolean> deleteScoreRule(@Valid @RequestBody IdReqVo idReqVo) { public CommonResult<Boolean> deleteScoreRule(@Valid @RequestBody IdReqVo idReqVo) {
scoreRuleService.deleteScoreRule(idReqVo.getId()); scoreRuleService.deleteScoreRule(idReqVo.getId());
return success(true); return success(true);
...@@ -71,7 +71,7 @@ public class ScoreRuleController { ...@@ -71,7 +71,7 @@ public class ScoreRuleController {
@PostMapping("/get") @PostMapping("/get")
@ApiOperation("获得积分规则详情") @ApiOperation("获得积分规则详情")
@PreAuthorize("@ss.hasPermission('member:score-rule:query')") //@PreAuthorize("@ss.hasPermission('member:score-rule:query')")
public CommonResult<ScoreRuleBackDetailVO> getScoreRule(@Valid @RequestBody IdReqVo idReqVo) { public CommonResult<ScoreRuleBackDetailVO> getScoreRule(@Valid @RequestBody IdReqVo idReqVo) {
ScoreRuleBackDetailVO scoreRuleBackDetailVO = scoreRuleService.getScoreRule(idReqVo.getId()); ScoreRuleBackDetailVO scoreRuleBackDetailVO = scoreRuleService.getScoreRule(idReqVo.getId());
return success(scoreRuleBackDetailVO); return success(scoreRuleBackDetailVO);
...@@ -80,7 +80,7 @@ public class ScoreRuleController { ...@@ -80,7 +80,7 @@ public class ScoreRuleController {
@PostMapping("/list") @PostMapping("/list")
@ApiOperation("获得积分规则列表") @ApiOperation("获得积分规则列表")
@ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class) @ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class)
@PreAuthorize("@ss.hasPermission('member:score-rule:query')") //@PreAuthorize("@ss.hasPermission('member:score-rule:query')")
public CommonResult<List<ScoreRuleBackVO>> getScoreRuleList(@NotNull @RequestParam Collection<Long> ids) { public CommonResult<List<ScoreRuleBackVO>> getScoreRuleList(@NotNull @RequestParam Collection<Long> ids) {
List<ScoreRuleBackVO> list = scoreRuleService.getScoreRuleList(ids); List<ScoreRuleBackVO> list = scoreRuleService.getScoreRuleList(ids);
return success(list); return success(list);
...@@ -88,7 +88,7 @@ public class ScoreRuleController { ...@@ -88,7 +88,7 @@ public class ScoreRuleController {
@PostMapping("/page") @PostMapping("/page")
@ApiOperation("获得积分规则分页") @ApiOperation("获得积分规则分页")
@PreAuthorize("@ss.hasPermission('member:score-rule:query')") //@PreAuthorize("@ss.hasPermission('member:score-rule:query')")
public CommonResult<PageResult<ScoreRuleBackVO>> getScoreRulePage(@Valid @RequestBody ScoreRuleQueryVO query, PageVO page) { public CommonResult<PageResult<ScoreRuleBackVO>> getScoreRulePage(@Valid @RequestBody ScoreRuleQueryVO query, PageVO page) {
PageResult<ScoreRuleBackVO> pageResult = scoreRuleService.getScoreRulePage(query, page); PageResult<ScoreRuleBackVO> pageResult = scoreRuleService.getScoreRulePage(query, page);
return success(pageResult); return success(pageResult);
...@@ -96,7 +96,7 @@ public class ScoreRuleController { ...@@ -96,7 +96,7 @@ public class ScoreRuleController {
@PostMapping("/status") @PostMapping("/status")
@ApiOperation("启用关闭") @ApiOperation("启用关闭")
@PreAuthorize("@ss.hasPermission('member:score-rule:update')") //@PreAuthorize("@ss.hasPermission('member:score-rule:update')")
public CommonResult<Boolean> updateStatus(@Valid @RequestBody ScoreRuleStatusReqVO scoreRuleStatusReqVO) { public CommonResult<Boolean> updateStatus(@Valid @RequestBody ScoreRuleStatusReqVO scoreRuleStatusReqVO) {
scoreRuleService.updateStatus(scoreRuleStatusReqVO); scoreRuleService.updateStatus(scoreRuleStatusReqVO);
return success(true); return success(true);
...@@ -105,14 +105,14 @@ public class ScoreRuleController { ...@@ -105,14 +105,14 @@ public class ScoreRuleController {
@PostMapping("/copy") @PostMapping("/copy")
@ApiOperation("复制规则") @ApiOperation("复制规则")
@Idempotent(timeout = 3) @Idempotent(timeout = 3)
@PreAuthorize("@ss.hasPermission('member:score-rule:create')") //@PreAuthorize("@ss.hasPermission('member:score-rule:create')")
public CommonResult<Long> copyScoreRule(@Valid @RequestBody IdReqVo idReqVo) { public CommonResult<Long> copyScoreRule(@Valid @RequestBody IdReqVo idReqVo) {
return success(scoreRuleService.copyScoreRule(idReqVo.getId())); return success(scoreRuleService.copyScoreRule(idReqVo.getId()));
} }
@PostMapping("/delay") @PostMapping("/delay")
@ApiOperation("延期规则") @ApiOperation("延期规则")
@PreAuthorize("@ss.hasPermission('member:score-rule:update')") //@PreAuthorize("@ss.hasPermission('member:score-rule:update')")
public CommonResult<Boolean> delayScoreRule(@Valid @RequestBody ScoreDelayReqVO scoreDelayReqVO) { public CommonResult<Boolean> delayScoreRule(@Valid @RequestBody ScoreDelayReqVO scoreDelayReqVO) {
scoreRuleService.delayScoreRule(scoreDelayReqVO); scoreRuleService.delayScoreRule(scoreDelayReqVO);
return success(true); return success(true);
...@@ -135,7 +135,7 @@ public class ScoreRuleController { ...@@ -135,7 +135,7 @@ public class ScoreRuleController {
@GetMapping("/export-excel") @GetMapping("/export-excel")
@ApiOperation("导出积分规则Excel") @ApiOperation("导出积分规则Excel")
@PreAuthorize("@ss.hasPermission('member:score-rule:export')") //@PreAuthorize("@ss.hasPermission('member:score-rule:export')")
@OperateLog(type = EXPORT) @OperateLog(type = EXPORT)
public void exportScoreRuleExcel(@Valid ScoreRuleQueryVO query, public void exportScoreRuleExcel(@Valid ScoreRuleQueryVO query,
HttpServletResponse response) throws IOException { HttpServletResponse response) throws IOException {
...@@ -147,7 +147,7 @@ public class ScoreRuleController { ...@@ -147,7 +147,7 @@ public class ScoreRuleController {
@PostMapping("/switch/set") @PostMapping("/switch/set")
@ApiOperation("设置会员工能开关") @ApiOperation("设置会员工能开关")
@PreAuthorize("@ss.hasPermission('member:score-rule:update')") //@PreAuthorize("@ss.hasPermission('member:score-rule:update')")
public CommonResult<Boolean> setScoreRuleSwitch(@RequestBody SwitchReqVo switchReqVo) { public CommonResult<Boolean> setScoreRuleSwitch(@RequestBody SwitchReqVo switchReqVo) {
return success(scoreRuleService.setScoreRuleSwitch(switchReqVo)); return success(scoreRuleService.setScoreRuleSwitch(switchReqVo));
} }
......
...@@ -11,6 +11,7 @@ import org.springframework.format.annotation.DateTimeFormat; ...@@ -11,6 +11,7 @@ import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date; import java.util.Date;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
/** /**
...@@ -86,6 +87,7 @@ public class UserBackVO { ...@@ -86,6 +87,7 @@ public class UserBackVO {
* 生日 * 生日
*/ */
@ExcelProperty("生日") @ExcelProperty("生日")
@JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY)
@ApiModelProperty(value = "生日") @ApiModelProperty(value = "生日")
private Date birthday; private Date birthday;
/** /**
......
...@@ -43,7 +43,7 @@ public class MemberUserScoreController { ...@@ -43,7 +43,7 @@ public class MemberUserScoreController {
@PostMapping("/page") @PostMapping("/page")
@ApiOperation("获得会员积分分页") @ApiOperation("获得会员积分分页")
@PreAuthorize("@ss.hasPermission('member:user-score:query')") //@PreAuthorize("@ss.hasPermission('member:user-score:query')")
public CommonResult<PageResult<MemberUserScoreBackVO>> getUserScorePage(@Valid @RequestBody MemberUserScoreQueryVO query) { public CommonResult<PageResult<MemberUserScoreBackVO>> getUserScorePage(@Valid @RequestBody MemberUserScoreQueryVO query) {
PageResult<MemberUserScoreBackVO> pageResult = userScoreService.getUserScorePage(query); PageResult<MemberUserScoreBackVO> pageResult = userScoreService.getUserScorePage(query);
return success(pageResult); return success(pageResult);
...@@ -52,7 +52,7 @@ public class MemberUserScoreController { ...@@ -52,7 +52,7 @@ public class MemberUserScoreController {
@PostMapping("/operate") @PostMapping("/operate")
@ApiOperation("操作积分") @ApiOperation("操作积分")
@Idempotent(timeout = 5) @Idempotent(timeout = 5)
@PreAuthorize("@ss.hasPermission('member:user-score:operate')") //@PreAuthorize("@ss.hasPermission('member:user-score:operate')")
public CommonResult<Boolean> operate(@Valid @RequestBody MemberUserScoreOperateQueryVO query) { public CommonResult<Boolean> operate(@Valid @RequestBody MemberUserScoreOperateQueryVO query) {
Map<String,Object> extParam = new HashMap<>(); Map<String,Object> extParam = new HashMap<>();
extParam.put("comment", query.getComment()); extParam.put("comment", query.getComment());
......
...@@ -29,7 +29,7 @@ public class MemberUserScoreLogController { ...@@ -29,7 +29,7 @@ public class MemberUserScoreLogController {
@PostMapping("/page") @PostMapping("/page")
@ApiOperation("获得积分记录分页") @ApiOperation("获得积分记录分页")
@PreAuthorize("@ss.hasPermission('member:user-score-log:query')") //@PreAuthorize("@ss.hasPermission('member:user-score-log:query')")
public CommonResult<PageResult<MemberUserScoreLogBackVO>> page(@Valid @RequestBody MemberUserScoreLogQueryVO query) { public CommonResult<PageResult<MemberUserScoreLogBackVO>> page(@Valid @RequestBody MemberUserScoreLogQueryVO query) {
PageResult<MemberUserScoreLogBackVO> pageResult = memberUserScoreLogService.getPage(query); PageResult<MemberUserScoreLogBackVO> pageResult = memberUserScoreLogService.getPage(query);
return success(pageResult); return success(pageResult);
......
...@@ -212,8 +212,8 @@ public class OrderVStrategy extends AbstractScoreRuleStrategy { ...@@ -212,8 +212,8 @@ public class OrderVStrategy extends AbstractScoreRuleStrategy {
userId = 0L; userId = 0L;
} }
} }
// 校验首单 // 校验首单:发货和收货都算首单,按客户查,只有发货人收货人都是首单才算首单
if (!isFirstOrderValid(userId, extraInfo)) { if (!isFirstOrderValid(consignorId, consigneeId, extraInfo)) {
return null; return null;
} }
// 校验积分上限,添加加分用户列表 // 校验积分上限,添加加分用户列表
...@@ -260,14 +260,14 @@ public class OrderVStrategy extends AbstractScoreRuleStrategy { ...@@ -260,14 +260,14 @@ public class OrderVStrategy extends AbstractScoreRuleStrategy {
/** /**
* 校验是否为首单且首单是否有效 * 校验是否为首单且首单是否有效
*/ */
private boolean isFirstOrderValid(Long userId, ScoreRuleOrderVExtraVO extraInfo) { private boolean isFirstOrderValid(Long consignorId, Long consigneeId, ScoreRuleOrderVExtraVO extraInfo) {
if (extraInfo.getFirstOrder() == YesOrNoTypeEnum.YES.ordinal()) { if (extraInfo.getFirstOrder() == YesOrNoTypeEnum.YES.ordinal()) {
if (userId == null || userId <= 0) { if (!orderApi.isFirstOrder(consignorId)) {
log.info("Order in shipping listener: The user is not member,userId:{}", userId); log.info("Order in shipping listener: consignor not first order,consignorId:{}", consignorId);
return false; return false;
} }
if (!orderApi.isFirstOrder(userId)) { if (!orderApi.isFirstOrder(consigneeId)) {
log.info("Order in shipping listener: Not first order,userId:{}", userId); log.info("Order in shipping listener: consignee not first order,consigneeId:{}", consigneeId);
return false; return false;
} }
} }
......
...@@ -72,7 +72,7 @@ public class ScoreRuleShareRecordServiceImpl extends AbstractService<ScoreRuleSh ...@@ -72,7 +72,7 @@ public class ScoreRuleShareRecordServiceImpl extends AbstractService<ScoreRuleSh
if (item.getIpAddress().contains("SHARE")) { if (item.getIpAddress().contains("SHARE")) {
String[] split = item.getIpAddress().split("_"); String[] split = item.getIpAddress().split("_");
item.setIpAddress(split[split.length - 1]); item.setIpAddress(split[split.length - 1]);
} else { } else if (item.getIpAddress().contains("RECOMMEND")) {
item.setIpAddress("-"); item.setIpAddress("-");
} }
item.setTypeZh(DictFrameworkUtils.getDictDataFromCache("score_rule_type", item.getType().toString()).getLabel()); item.setTypeZh(DictFrameworkUtils.getDictDataFromCache("score_rule_type", item.getType().toString()).getLabel());
......
...@@ -14,9 +14,9 @@ public interface OrderApi { ...@@ -14,9 +14,9 @@ public interface OrderApi {
*/ */
OrderRespDTO getOrder(Long id, String orderNo); OrderRespDTO getOrder(Long id, String orderNo);
/** /**
* 判断是否用户首单 * 判断客户是否首单
*/ */
boolean isFirstOrder(Long userId); boolean isFirstOrder(Long customerId);
/** /**
* 根据订单id获取所有订单项 * 根据订单id获取所有订单项
*/ */
......
...@@ -87,9 +87,9 @@ public class OrderApiImpl implements OrderApi { ...@@ -87,9 +87,9 @@ public class OrderApiImpl implements OrderApi {
} }
@Override @Override
public boolean isFirstOrder(Long userId) { public boolean isFirstOrder(Long customerId) {
Long count = orderService.selectCount(new LambdaQueryWrapper<OrderDO>().eq(OrderDO::getUserId, userId)); // 只要发过货或者收过货都不算首单
return count <= 0; return orderConsignorService.selectCount("customer_id", customerId) <= 1 && orderConsigneeService.selectCount("customer_id", customerId) <= 1;
} }
@Override @Override
......
...@@ -4,6 +4,7 @@ import cn.iocoder.yudao.module.reward.api.reward.dto.RedeemDetailForUserDTO; ...@@ -4,6 +4,7 @@ import cn.iocoder.yudao.module.reward.api.reward.dto.RedeemDetailForUserDTO;
import cn.iocoder.yudao.module.reward.api.reward.dto.RedeemRewardReqVO; import cn.iocoder.yudao.module.reward.api.reward.dto.RedeemRewardReqVO;
import cn.iocoder.yudao.module.reward.api.reward.dto.RedeemRewardRespDTO; import cn.iocoder.yudao.module.reward.api.reward.dto.RedeemRewardRespDTO;
import java.util.HashMap;
import java.util.List; import java.util.List;
/** /**
...@@ -25,8 +26,9 @@ public interface RedeemRewardApi { ...@@ -25,8 +26,9 @@ public interface RedeemRewardApi {
* @param redeemRewardReqVO * @param redeemRewardReqVO
* @param pointsRequire * @param pointsRequire
* @param rewardId * @param rewardId
* @param holdScore
*/ */
void executeRedeem(RedeemRewardReqVO redeemRewardReqVO, Integer pointsRequire, Long rewardId); void executeRedeem(RedeemRewardReqVO redeemRewardReqVO, Integer pointsRequire, Long rewardId, Integer holdScore);
/** /**
* 批量兑换礼品 * 批量兑换礼品
...@@ -42,8 +44,9 @@ public interface RedeemRewardApi { ...@@ -42,8 +44,9 @@ public interface RedeemRewardApi {
* @param redeemRewardReqVOList * @param redeemRewardReqVOList
* @param pointsRequire * @param pointsRequire
* @param rewardId * @param rewardId
* @param holdScoreMap
*/ */
void batchExecuteRedeem(List<RedeemRewardReqVO> redeemRewardReqVOList, Integer pointsRequire, Long rewardId); void batchExecuteRedeem(List<RedeemRewardReqVO> redeemRewardReqVOList, Integer pointsRequire, Long rewardId, HashMap<Long, Integer> holdScoreMap);
/** /**
* 客户端获取礼品详情 * 客户端获取礼品详情
......
...@@ -102,7 +102,7 @@ public class RedeemRewardApiImpl implements RedeemRewardApi { ...@@ -102,7 +102,7 @@ public class RedeemRewardApiImpl implements RedeemRewardApi {
throw exception(GET_LOCK_FAILED); throw exception(GET_LOCK_FAILED);
} }
RedeemRewardApi currentProxy = (RedeemRewardApi) AopContext.currentProxy(); RedeemRewardApi currentProxy = (RedeemRewardApi) AopContext.currentProxy();
currentProxy.executeRedeem(redeemRewardReqVO, rewardDO.getPointsRequire(), rewardDO.getId()); currentProxy.executeRedeem(redeemRewardReqVO, rewardDO.getPointsRequire(), rewardDO.getId(), memberUser.getHoldScore());
} catch (InterruptedException e) { } catch (InterruptedException e) {
throw exception(GET_LOCK_FAILED); throw exception(GET_LOCK_FAILED);
} finally { } finally {
...@@ -113,9 +113,9 @@ public class RedeemRewardApiImpl implements RedeemRewardApi { ...@@ -113,9 +113,9 @@ public class RedeemRewardApiImpl implements RedeemRewardApi {
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void executeRedeem(RedeemRewardReqVO redeemRewardReqVO, Integer pointsRequire, Long rewardId) { public void executeRedeem(RedeemRewardReqVO redeemRewardReqVO, Integer pointsRequire, Long rewardId, Integer holdScore) {
// 添加兑换记录 // 添加兑换记录
RewardRedeemDO redeemRecord = addRedeemRecord(redeemRewardReqVO, pointsRequire); RewardRedeemDO redeemRecord = addRedeemRecord(redeemRewardReqVO, pointsRequire, holdScore);
// 更新会员积分 // 更新会员积分
updateMemberScore(redeemRewardReqVO, pointsRequire, redeemRecord.getId(), redeemRecord.getRedemptionNumber()); updateMemberScore(redeemRewardReqVO, pointsRequire, redeemRecord.getId(), redeemRecord.getRedemptionNumber());
// 更新礼品 // 更新礼品
...@@ -187,11 +187,12 @@ public class RedeemRewardApiImpl implements RedeemRewardApi { ...@@ -187,11 +187,12 @@ public class RedeemRewardApiImpl implements RedeemRewardApi {
.build()); .build());
} }
private RewardRedeemDO addRedeemRecord(RedeemRewardReqVO redeemRewardReqVO, Integer pointsRequire) { private RewardRedeemDO addRedeemRecord(RedeemRewardReqVO redeemRewardReqVO, Integer pointsRequire, Integer holdScore) {
RewardRedeemDO rewardRedeemDO = BeanUtil.copyProperties(redeemRewardReqVO, RewardRedeemDO.class); RewardRedeemDO rewardRedeemDO = BeanUtil.copyProperties(redeemRewardReqVO, RewardRedeemDO.class);
rewardRedeemDO.setId(snowflakeGenerator.next()); rewardRedeemDO.setId(snowflakeGenerator.next());
rewardRedeemDO.setRedemptionNumber(rewardGenCodeUtils.generateRedemptionNumber()); rewardRedeemDO.setRedemptionNumber(rewardGenCodeUtils.generateRedemptionNumber());
rewardRedeemDO.setStatus(RewardRedeemStatusEnum.REDEEMING.getValue()); rewardRedeemDO.setStatus(RewardRedeemStatusEnum.REDEEMING.getValue());
rewardRedeemDO.setHoldScoreBeforeRedeem(holdScore);
rewardRedeemDO.setScoreCount(redeemRewardReqVO.getRewardCount() * pointsRequire); rewardRedeemDO.setScoreCount(redeemRewardReqVO.getRewardCount() * pointsRequire);
rewardRedeemMapper.insert(rewardRedeemDO); rewardRedeemMapper.insert(rewardRedeemDO);
return rewardRedeemDO; return rewardRedeemDO;
...@@ -214,6 +215,7 @@ public class RedeemRewardApiImpl implements RedeemRewardApi { ...@@ -214,6 +215,7 @@ public class RedeemRewardApiImpl implements RedeemRewardApi {
throw exception(REWARD_NOT_ENABLE); throw exception(REWARD_NOT_ENABLE);
} }
int totalCount = 0; int totalCount = 0;
HashMap<Long, Integer> holdScoreMap = new HashMap<>();
for (RedeemRewardReqVO redeemRewardReqVO : redeemRewardReqVOList) { for (RedeemRewardReqVO redeemRewardReqVO : redeemRewardReqVOList) {
UserRespDTO memberUser = memberUserApi.getUser(redeemRewardReqVO.getMemberId()); UserRespDTO memberUser = memberUserApi.getUser(redeemRewardReqVO.getMemberId());
if (memberUser == null) { if (memberUser == null) {
...@@ -230,6 +232,7 @@ public class RedeemRewardApiImpl implements RedeemRewardApi { ...@@ -230,6 +232,7 @@ public class RedeemRewardApiImpl implements RedeemRewardApi {
} }
} }
verifyMemberUser(redeemRewardReqVO, rewardDO, memberUser.getHoldScore()); verifyMemberUser(redeemRewardReqVO, rewardDO, memberUser.getHoldScore());
holdScoreMap.put(redeemRewardReqVO.getMemberId(), memberUser.getHoldScore());
// 记录兑换总数 // 记录兑换总数
totalCount += redeemRewardReqVO.getRewardCount(); totalCount += redeemRewardReqVO.getRewardCount();
// 判断兑换总数是否大于礼物数量 // 判断兑换总数是否大于礼物数量
...@@ -244,7 +247,7 @@ public class RedeemRewardApiImpl implements RedeemRewardApi { ...@@ -244,7 +247,7 @@ public class RedeemRewardApiImpl implements RedeemRewardApi {
throw exception(GET_LOCK_FAILED); throw exception(GET_LOCK_FAILED);
} }
RedeemRewardApi currentProxy = (RedeemRewardApi) AopContext.currentProxy(); RedeemRewardApi currentProxy = (RedeemRewardApi) AopContext.currentProxy();
currentProxy.batchExecuteRedeem(redeemRewardReqVOList, rewardDO.getPointsRequire(), rewardDO.getId()); currentProxy.batchExecuteRedeem(redeemRewardReqVOList, rewardDO.getPointsRequire(), rewardDO.getId(), holdScoreMap);
} catch (ServiceException e) { } catch (ServiceException e) {
log.error("batch redeem rewards exception:{}", e.getMessage()); log.error("batch redeem rewards exception:{}", e.getMessage());
throw e; throw e;
...@@ -258,9 +261,9 @@ public class RedeemRewardApiImpl implements RedeemRewardApi { ...@@ -258,9 +261,9 @@ public class RedeemRewardApiImpl implements RedeemRewardApi {
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void batchExecuteRedeem(List<RedeemRewardReqVO> redeemRewardReqVOList, Integer pointsRequire, Long rewardId) { public void batchExecuteRedeem(List<RedeemRewardReqVO> redeemRewardReqVOList, Integer pointsRequire, Long rewardId, HashMap<Long, Integer> holdScoreMap) {
for (RedeemRewardReqVO redeemRewardReqVO : redeemRewardReqVOList) { for (RedeemRewardReqVO redeemRewardReqVO : redeemRewardReqVOList) {
executeRedeem(redeemRewardReqVO, pointsRequire, rewardId); executeRedeem(redeemRewardReqVO, pointsRequire, rewardId, holdScoreMap.get(redeemRewardReqVO.getMemberId()));
} }
} }
......
...@@ -91,7 +91,7 @@ public class RewardController { ...@@ -91,7 +91,7 @@ public class RewardController {
rewardBackVOPageResult.getList().forEach(rewardBackVO -> { rewardBackVOPageResult.getList().forEach(rewardBackVO -> {
List<Integer> nodeId = new ArrayList<>(); List<Integer> nodeId = new ArrayList<>();
nodeId.add(rewardBackVO.getNodeId()); nodeId.add(rewardBackVO.getNodeId());
rewardBackVO.getNodeIds().add(new RewardBackVO.NodeAndPoints(nodeId, rewardBackVO.getPointsRequire(), rewardBackVO.getQuantityRemain())); rewardBackVO.getNodeIds().add(new RewardBackVO.NodeAndPoints(nodeId, rewardBackVO.getQuantityRemain(), rewardBackVO.getPointsRequire()));
}); });
return success(rewardBackVOPageResult); return success(rewardBackVOPageResult);
} }
......
...@@ -37,6 +37,13 @@ public class RewardRedeemDO extends BaseDO { ...@@ -37,6 +37,13 @@ public class RewardRedeemDO extends BaseDO {
* 兑换状态 * 兑换状态
*/ */
private Integer status; private Integer status;
/**
* 兑换前持有的积分
*/
private Integer holdScoreBeforeRedeem;
/**
* 兑换消耗积分数量
*/
private Integer scoreCount; private Integer scoreCount;
/** /**
* 兑换数量 * 兑换数量
......
...@@ -135,6 +135,13 @@ public class RewardServiceImpl extends AbstractService<RewardMapper, RewardDO> i ...@@ -135,6 +135,13 @@ public class RewardServiceImpl extends AbstractService<RewardMapper, RewardDO> i
throw exception(REWARD_NOT_EXISTS); throw exception(REWARD_NOT_EXISTS);
} }
RewardDO updateObj = new RewardDO(); RewardDO updateObj = new RewardDO();
// 此处为了兼容前端传值
List<RewardCreateReqVO.NodeAndPoints> nodeIds = updateReqVO.getNodeIds();
if (CollectionUtil.isEmpty(nodeIds)) {
throw exception(REWARD_NODE_AND_POINTS_LIST_ERROR);
}
RewardCreateReqVO.NodeAndPoints nodeAndPoints = nodeIds.get(0);
//未启用可编辑所有内容 //未启用可编辑所有内容
if (rewardDO.getStatus() == RewardStatusEnum.DISABLED.getValue()) { if (rewardDO.getStatus() == RewardStatusEnum.DISABLED.getValue()) {
// 校验领取方式 // 校验领取方式
...@@ -150,19 +157,15 @@ public class RewardServiceImpl extends AbstractService<RewardMapper, RewardDO> i ...@@ -150,19 +157,15 @@ public class RewardServiceImpl extends AbstractService<RewardMapper, RewardDO> i
} else { } else {
throw exception(REWARD_START_OR_END_TIME_NOT_ALLOW); throw exception(REWARD_START_OR_END_TIME_NOT_ALLOW);
} }
List<RewardUpdateReqVO.NodeAndPoints> nodeIds = updateReqVO.getNodeIds();
if (CollectionUtil.isEmpty(nodeIds)) {
throw exception(REWARD_NODE_AND_POINTS_LIST_ERROR);
}
RewardUpdateReqVO.NodeAndPoints nodeAndPoints = nodeIds.get(0);
updateObj = RewardConvert.INSTANCE.convert(updateReqVO); updateObj = RewardConvert.INSTANCE.convert(updateReqVO);
updateObj.setPointsRequire(nodeAndPoints.getPoints()); updateObj.setPointsRequire(nodeAndPoints.getPoints());
updateObj.setNodeId(nodeAndPoints.getNodeId()); updateObj.setNodeId(nodeAndPoints.getWareHouses().get(0));
updateObj.setQuantityRemain(nodeAndPoints.getQuantityRemain());
//已启用可编辑剩余数量和备注 //已启用可编辑剩余数量和备注
} else if (rewardDO.getStatus() == RewardStatusEnum.ENABLED.getValue()) { } else if (rewardDO.getStatus() == RewardStatusEnum.ENABLED.getValue()) {
updateObj.setId(updateReqVO.getId()); updateObj.setId(updateReqVO.getId());
updateObj.setQuantityRemain(updateReqVO.getQuantityRemain()); updateObj.setQuantityRemain(nodeAndPoints.getQuantityRemain());
updateObj.setRemarkEn(updateReqVO.getRemarkEn()); updateObj.setRemarkEn(updateReqVO.getRemarkEn());
updateObj.setRemarkFr(updateReqVO.getRemarkFr()); updateObj.setRemarkFr(updateReqVO.getRemarkFr());
updateObj.setRemarkZh(updateReqVO.getRemarkZh()); updateObj.setRemarkZh(updateReqVO.getRemarkZh());
......
...@@ -44,19 +44,9 @@ public class RewardUpdateReqVO { ...@@ -44,19 +44,9 @@ public class RewardUpdateReqVO {
@ApiModelProperty(value = "法文礼品图片") @ApiModelProperty(value = "法文礼品图片")
private String imgFr; private String imgFr;
//@ApiModelProperty(value = "兑换所需积分")
//@Min(value = 0)
//private Integer pointsRequire;
//@ApiModelProperty(value = "兑换网点")
//private Integer nodeId;
@ApiModelProperty(value = "兑换网点和积分列表", required = true) @ApiModelProperty(value = "兑换网点和积分列表", required = true)
@NotNull(message = "兑换网点列表不能为空") @NotNull(message = "兑换网点列表不能为空")
private List<RewardUpdateReqVO.NodeAndPoints> nodeIds; private List<RewardCreateReqVO.NodeAndPoints> nodeIds;
@ApiModelProperty(value = "剩余数量")
@Min(value = 0)
private Integer quantityRemain;
@ApiModelProperty(value = "活动开始时间") @ApiModelProperty(value = "活动开始时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
...@@ -84,12 +74,4 @@ public class RewardUpdateReqVO { ...@@ -84,12 +74,4 @@ public class RewardUpdateReqVO {
@ApiModelProperty(value = "法文备注") @ApiModelProperty(value = "法文备注")
@Size(max = 500, message = "法文备注长度不能超过500") @Size(max = 500, message = "法文备注长度不能超过500")
private String remarkFr; private String remarkFr;
@Data
public static class NodeAndPoints {
@ApiModelProperty(value = "兑换网点")
private Integer nodeId;
@ApiModelProperty(value = "兑换网点对应积分")
private Integer points;
}
} }
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
</select> </select>
<select id="detail" resultType="cn.iocoder.yudao.module.reward.vo.reward.RewardRedeemPageRespVO"> <select id="detail" resultType="cn.iocoder.yudao.module.reward.vo.reward.RewardRedeemPageRespVO">
select select
mus.hold_score as holdScore, err.hold_score_before_redeem as holdScore,
er.points_require as pointsRequire, er.points_require as pointsRequire,
er.start_time as startTime, er.start_time as startTime,
er.end_time as endTime, er.end_time as endTime,
......
...@@ -61,7 +61,7 @@ public class BannerController { ...@@ -61,7 +61,7 @@ public class BannerController {
@GetMapping("/get") @GetMapping("/get")
@ApiOperation("获得广告设置") @ApiOperation("获得广告设置")
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class) @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
@PreAuthorize("@ss.hasPermission('ecw:banner:query')") //@PreAuthorize("@ss.hasPermission('ecw:banner:query')")
public CommonResult<BannerBackVO> getBanner(@RequestParam("id") Long id) { public CommonResult<BannerBackVO> getBanner(@RequestParam("id") Long id) {
BannerDO banner = bannerService.getBanner(id); BannerDO banner = bannerService.getBanner(id);
return success(BannerConvert.INSTANCE.convert(banner)); return success(BannerConvert.INSTANCE.convert(banner));
...@@ -70,7 +70,7 @@ public class BannerController { ...@@ -70,7 +70,7 @@ public class BannerController {
@GetMapping("/list") @GetMapping("/list")
@ApiOperation("获得广告设置列表") @ApiOperation("获得广告设置列表")
@ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class) @ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class)
@PreAuthorize("@ss.hasPermission('ecw:banner:query')") //@PreAuthorize("@ss.hasPermission('ecw:banner:query')")
public CommonResult<List<BannerBackVO>> getBannerList(@RequestParam("ids") Collection<Long> ids) { public CommonResult<List<BannerBackVO>> getBannerList(@RequestParam("ids") Collection<Long> ids) {
List<BannerDO> list = bannerService.getBannerList(ids); List<BannerDO> list = bannerService.getBannerList(ids);
return success(BannerConvert.INSTANCE.convertList(list)); return success(BannerConvert.INSTANCE.convertList(list));
...@@ -78,7 +78,7 @@ public class BannerController { ...@@ -78,7 +78,7 @@ public class BannerController {
@GetMapping("/page") @GetMapping("/page")
@ApiOperation("获得广告设置分页") @ApiOperation("获得广告设置分页")
@PreAuthorize("@ss.hasPermission('ecw:banner:query')") //@PreAuthorize("@ss.hasPermission('ecw:banner:query')")
public CommonResult<PageResult<BannerBackVO>> getBannerPage(@Valid BannerQueryVO query, PageVO page) { public CommonResult<PageResult<BannerBackVO>> getBannerPage(@Valid BannerQueryVO query, PageVO page) {
PageResult<BannerDO> pageResult = bannerService.getBannerPage(query, page); PageResult<BannerDO> pageResult = bannerService.getBannerPage(query, page);
return success(BannerConvert.INSTANCE.convertPage(pageResult)); return success(BannerConvert.INSTANCE.convertPage(pageResult));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment