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