Commit 042e8a9c by 吕明尚

Merge branch 'refs/heads/test' into test-lms

# Conflicts:
#	share-system/src/main/java/share/system/service/impl/SOrderServiceImpl.java
parents d8b12a0a 04476972
...@@ -77,18 +77,6 @@ public class SharingActivitiesController extends BaseController { ...@@ -77,18 +77,6 @@ public class SharingActivitiesController extends BaseController {
return toAjax(sharingActivitiesService.insertSharingActivities(sharingActivities)); return toAjax(sharingActivitiesService.insertSharingActivities(sharingActivities));
} }
/**
* 新增分享活动绑定关系
*/
// @PreAuthorize("@ss.hasPermi('system:activities:addSharingActivities')")
@Log(title = "分享活动绑定关系", businessType = BusinessType.INSERT)
@PostMapping("/addSharingActivities")
public AjaxResult addSharingActivities(@RequestBody SharingActivities sharingActivities) {
AjaxResult ajaxResult = sharingActivitiesService.addSharingActivities(sharingActivities);
return ajaxResult;
}
/** /**
* 修改分享活动绑定关系 * 修改分享活动绑定关系
......
...@@ -11,7 +11,6 @@ import share.common.core.page.TableDataInfo; ...@@ -11,7 +11,6 @@ import share.common.core.page.TableDataInfo;
import share.common.enums.YesNoEnum; import share.common.enums.YesNoEnum;
import share.system.domain.Activity; import share.system.domain.Activity;
import share.system.domain.vo.ActivityDto; import share.system.domain.vo.ActivityDto;
import share.system.domain.vo.ActivityVo;
import share.system.service.ActivityService; import share.system.service.ActivityService;
import java.util.Date; import java.util.Date;
...@@ -43,7 +42,7 @@ public class ActivityController extends BaseController { ...@@ -43,7 +42,7 @@ public class ActivityController extends BaseController {
@GetMapping("/query") @GetMapping("/query")
public AjaxResult query(ActivityDto dto) { public AjaxResult query(ActivityDto dto) {
dto.setIsOpen(Long.valueOf(YesNoEnum.yes.getIndex())); dto.setIsOpen(Long.valueOf(YesNoEnum.yes.getIndex()));
Map<Date, List<ActivityVo>> map = activityService.queryList(dto); Map<Date, List<Activity>> map = activityService.queryList(dto);
return success(map); return success(map);
} }
......
package share.web.controller.system;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import share.common.annotation.Log;
import share.common.core.controller.BaseController;
import share.common.core.domain.AjaxResult;
import share.common.core.page.TableDataInfo;
import share.common.enums.BusinessType;
import share.common.utils.poi.ExcelUtil;
import share.system.domain.EquityFundLog;
import share.system.service.EquityFundLogService;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
* 权益金记录Controller
*
* @author wuwenlong
* @date 2024-09-10
*/
@RestController
@RequestMapping("/equityFundLog")
public class EquityFundLogController extends BaseController {
@Autowired
private EquityFundLogService equityFundLogService;
/**
* 查询权益金记录列表
*/
@PreAuthorize("@ss.hasPermi('system:equityFundLog:list')")
@GetMapping("/list")
public TableDataInfo list(EquityFundLog equityFundLog) {
startPage();
List<EquityFundLog> list = equityFundLogService.selectEquityFundLogList(equityFundLog);
return getDataTable(list);
}
/**
* 获取权益金记录详细信息
*/
@PreAuthorize("@ss.hasPermi('system:equityFundLog:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id) {
return success(equityFundLogService.selectEquityFundLogById(id));
}
}
...@@ -124,6 +124,9 @@ public class RedisTask { ...@@ -124,6 +124,9 @@ public class RedisTask {
@Autowired @Autowired
private EquityFundLogService equityFundLogService; private EquityFundLogService equityFundLogService;
@Autowired
private DurationLogService durationLogService;
//15分钟的常量 //15分钟的常量
final long FIFTEEN_MINUTES = 60 * 15; final long FIFTEEN_MINUTES = 60 * 15;
...@@ -341,32 +344,38 @@ public class RedisTask { ...@@ -341,32 +344,38 @@ public class RedisTask {
redisUtil.delete(o); redisUtil.delete(o);
throw new BaseException("订单不存在!"); throw new BaseException("订单不存在!");
} }
//查询是否有上级
LambdaQueryWrapper<SharingActivities> sharingActivitiesLambdaQueryWrapper = new LambdaQueryWrapper<>();
sharingActivitiesLambdaQueryWrapper.eq(SharingActivities::getNewUid, sOrder.getConsumerId());
sharingActivitiesLambdaQueryWrapper.eq(SharingActivities::getIsDelete, YesNoEnum.no.getIndex());
SharingActivities sharingActivities = sharingActivitiesService.getOne(sharingActivitiesLambdaQueryWrapper);
if (ObjectUtil.isNotEmpty(sharingActivities)) {
//查询当前用户是否只有一个订单 //查询当前用户是否只有一个订单
LambdaQueryWrapper<SOrder> sOrderLambdaQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<SOrder> sOrderLambdaQueryWrapper = new LambdaQueryWrapper<>();
sOrderLambdaQueryWrapper.eq(SOrder :: getConsumerId,sOrder.getConsumerId()); sOrderLambdaQueryWrapper.eq(SOrder::getConsumerId, sOrder.getConsumerId());
sOrderLambdaQueryWrapper.eq(SOrder::getPayStatus, YesNoEnum.yes.getIndex()); sOrderLambdaQueryWrapper.eq(SOrder::getPayStatus, YesNoEnum.yes.getIndex());
sOrderLambdaQueryWrapper.notIn(SOrder::getRefundStatus, RefundStatusEnum.getRefundedStatus()); sOrderLambdaQueryWrapper.notIn(SOrder::getRefundStatus, RefundStatusEnum.getRefundedStatus());
sOrderLambdaQueryWrapper.in(SOrder::getStatus, OrderStatusEnum.getUnfinishOrderStatus()); sOrderLambdaQueryWrapper.in(SOrder::getStatus, OrderStatusEnum.getUnfinishOrderStatus());
sOrderLambdaQueryWrapper.eq(SOrder::getIsDelete, YesNoEnum.no.getIndex()); sOrderLambdaQueryWrapper.eq(SOrder::getIsDelete, YesNoEnum.no.getIndex());
List<SOrder> sOrderList = isOrderService.list(sOrderLambdaQueryWrapper); List<SOrder> sOrderList = isOrderService.list(sOrderLambdaQueryWrapper);
if (sOrderList.size() == 1){ if (sOrderList.size() == 1) {
//查询是否有上级
LambdaQueryWrapper<SharingActivities> sharingActivitiesLambdaQueryWrapper = new LambdaQueryWrapper<>();
sharingActivitiesLambdaQueryWrapper.eq(SharingActivities :: getNewUid,sOrder.getConsumerId());
sharingActivitiesLambdaQueryWrapper.eq(SharingActivities :: getActivityType,"0");
sharingActivitiesLambdaQueryWrapper.eq(SharingActivities :: getIsDelete,YesNoEnum.no.getIndex());
SharingActivities sharingActivities = sharingActivitiesService.getOne(sharingActivitiesLambdaQueryWrapper);
if (ObjectUtil.isNotEmpty(sharingActivities)){
LambdaQueryWrapper<ConsumerWallet> consumerWalletLambdaQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<ConsumerWallet> consumerWalletLambdaQueryWrapper = new LambdaQueryWrapper<>();
consumerWalletLambdaQueryWrapper.eq(ConsumerWallet::getConsumerId,sharingActivities.getUid()); consumerWalletLambdaQueryWrapper.eq(ConsumerWallet::getConsumerId, sharingActivities.getUid());
ConsumerWallet consumerWallet = consumerWalletService.getOne(consumerWalletLambdaQueryWrapper); ConsumerWallet consumerWallet = consumerWalletService.getOne(consumerWalletLambdaQueryWrapper);
if (ObjectUtil.isNotEmpty(consumerWallet)){ if (ObjectUtil.isNotEmpty(consumerWallet)) {
//添加时长 //添加时长
BigDecimal anHour = new BigDecimal(1.0); BigDecimal anHour = new BigDecimal(1.0);
consumerWallet.setRemainingDuration(consumerWallet.getRemainingDuration().add(anHour)); consumerWallet.setRemainingDuration(consumerWallet.getRemainingDuration().add(anHour));
consumerWallet.setUpdateTime(DateUtils.getNowDate()); consumerWallet.setUpdateTime(DateUtils.getNowDate());
consumerWalletService.updateConsumerWallet(consumerWallet); consumerWalletService.updateConsumerWallet(consumerWallet);
}else { DurationLog durationLog = new DurationLog();
durationLog.setConsumerId(consumerWallet.getConsumerId());
durationLog.setVariableDuration(anHour);
durationLog.setCurrentDuration(consumerWallet.getRemainingDuration());
durationLog.setOperationType(YesNoEnum.yes.getIndex());
durationLog.setOperationTime(DateUtils.getNowDate());
durationLogService.insertDurationLog(durationLog);
} else {
//新增钱包 //新增钱包
ConsumerWallet newConsumerWallet = new ConsumerWallet(); ConsumerWallet newConsumerWallet = new ConsumerWallet();
BigDecimal defaultVlue = new BigDecimal(0.0); BigDecimal defaultVlue = new BigDecimal(0.0);
...@@ -379,24 +388,28 @@ public class RedisTask { ...@@ -379,24 +388,28 @@ public class RedisTask {
newConsumerWallet.setRemainingDuration(newConsumerWallet.getRemainingDuration().add(anHour)); newConsumerWallet.setRemainingDuration(newConsumerWallet.getRemainingDuration().add(anHour));
newConsumerWallet.setUpdateTime(DateUtils.getNowDate()); newConsumerWallet.setUpdateTime(DateUtils.getNowDate());
consumerWalletService.insertConsumerWallet(newConsumerWallet); consumerWalletService.insertConsumerWallet(newConsumerWallet);
DurationLog newDurationLog = new DurationLog();
newDurationLog.setConsumerId(consumerWallet.getConsumerId());
newDurationLog.setVariableDuration(anHour);
newDurationLog.setCurrentDuration(consumerWallet.getRemainingDuration());
newDurationLog.setOperationType(YesNoEnum.yes.getIndex());
newDurationLog.setOperationTime(DateUtils.getNowDate());
durationLogService.insertDurationLog(newDurationLog);
} }
} }
}
//查询是否有上级
LambdaQueryWrapper<SharingActivities> sharingActivitiesLambdaQueryWrapper = new LambdaQueryWrapper<>();
sharingActivitiesLambdaQueryWrapper.eq(SharingActivities :: getNewUid,sOrder.getConsumerId());
sharingActivitiesLambdaQueryWrapper.eq(SharingActivities :: getActivityType,"1");
sharingActivitiesLambdaQueryWrapper.eq(SharingActivities :: getIsDelete,YesNoEnum.no.getIndex());
SharingActivities sharingActivities = sharingActivitiesService.getOne(sharingActivitiesLambdaQueryWrapper);
if (ObjectUtil.isNotEmpty(sharingActivities)){
//查询会员用户类型 //查询会员用户类型
LambdaQueryWrapper<ConsumerMember> consumerMemberLambdaQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<ConsumerMember> consumerMemberWrapper = new LambdaQueryWrapper<>();
consumerMemberLambdaQueryWrapper.eq(ConsumerMember::getConsumerId,sharingActivities.getUid()); consumerMemberWrapper.eq(ConsumerMember::getConsumerId, sharingActivities.getUid());
ConsumerMember consumerMember = consumerMemberService.getOne(consumerMemberLambdaQueryWrapper); ConsumerMember consumerMember = consumerMemberService.getOne(consumerMemberWrapper);
LambdaQueryWrapper<ConsumerMember> newConsumerMemberQueryWrapper = new LambdaQueryWrapper<>();
newConsumerMemberQueryWrapper.eq(ConsumerMember::getConsumerId, sharingActivities.getUid());
ConsumerMember newConsumerMember = consumerMemberService.getOne(newConsumerMemberQueryWrapper);
//判断是否为权益会员和会员是否有效 //判断是否为权益会员和会员是否有效
if ("2".equals(consumerMember.getMemberType()) && new Date().getTime() < consumerMember.getExpirationDate().getTime() ){ if (YesNoEnum.yes.getIndex().equals(consumerMember.getIsRecharge()) && new Date().getTime() < consumerMember.getExpirationDate().getTime()
&& YesNoEnum.yes.getIndex().equals(newConsumerMember.getIsRecharge()) && new Date().getTime() < newConsumerMember.getExpirationDate().getTime()) {
Boolean aBoolean = redisTemplate.hasKey(ReceiptRdeisEnum.EQUITY_MEMBERS_TIME + sharingActivities.getUid().toString()); Boolean aBoolean = redisTemplate.hasKey(ReceiptRdeisEnum.EQUITY_MEMBERS_TIME + sharingActivities.getUid().toString());
if (aBoolean){ Boolean newAboolean = redisTemplate.hasKey(ReceiptRdeisEnum.EQUITY_MEMBERS_TIME + sharingActivities.getNewUid().toString());
if (aBoolean && newAboolean) {
LambdaQueryWrapper<ConsumerWallet> consumerWalletLambdaQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<ConsumerWallet> consumerWalletLambdaQueryWrapper = new LambdaQueryWrapper<>();
consumerWalletLambdaQueryWrapper.eq(ConsumerWallet::getConsumerId, sharingActivities.getUid()); consumerWalletLambdaQueryWrapper.eq(ConsumerWallet::getConsumerId, sharingActivities.getUid());
ConsumerWallet consumerWallet = consumerWalletService.getOne(consumerWalletLambdaQueryWrapper); ConsumerWallet consumerWallet = consumerWalletService.getOne(consumerWalletLambdaQueryWrapper);
...@@ -430,7 +443,6 @@ public class RedisTask { ...@@ -430,7 +443,6 @@ public class RedisTask {
} }
} }
} }
} }
if (extracted(o, sOrders, sOrder)) return; if (extracted(o, sOrders, sOrder)) return;
...@@ -651,16 +663,16 @@ public class RedisTask { ...@@ -651,16 +663,16 @@ public class RedisTask {
consumerMember.setIsRights(YesNoEnum.no.getIndex()); consumerMember.setIsRights(YesNoEnum.no.getIndex());
if (ObjectUtil.isNotEmpty(consumerMember)) { if (ObjectUtil.isNotEmpty(consumerMember)) {
if (consumerMember.getIsRecharge().equals(YesNoEnum.yes.getIndex())) { if (consumerMember.getIsRecharge().equals(YesNoEnum.yes.getIndex())) {
consumerMember.setMemberType(MemberTypeEnum.RECHARGE.getIndex()); consumerMember.setExpirationDate(DateUtils.addYears(new Date(), 100));
} else { } else {
consumerMember.setMemberType(MemberTypeEnum.NORMAL.getIndex()); consumerMember.setExpirationDate(DateUtils.addYears(new Date(), 100));
} }
MemberConfig memberConfigServiceOne = memberConfigService.getOne(new LambdaQueryWrapper<MemberConfig>() // MemberConfig memberConfigServiceOne = memberConfigService.getOne(new LambdaQueryWrapper<MemberConfig>()
.eq(MemberConfig::getMemberType, consumerMember.getMemberType()) //// .eq(MemberConfig::getMemberType, consumerMember.getMemberType())
.eq(MemberConfig::getMembershipLevel, consumerMember.getMembershipLevel()) // .eq(MemberConfig::getMembershipLevel, consumerMember.getMembershipLevel())
); // );
consumerMember.setMemberConfigId(memberConfigServiceOne.getId()); // consumerMember.setMemberConfigId(memberConfigServiceOne.getId());
consumerMember.setExpirationDate(DateUtils.addYears(new Date(), memberConfigServiceOne.getValidityPeriod().intValue())); // consumerMember.setExpirationDate(DateUtils.addYears(new Date(), memberConfigServiceOne.getValidityPeriod().intValue()));
consumerMemberService.updateConsumerMember(consumerMember); consumerMemberService.updateConsumerMember(consumerMember);
} }
redisUtil.delete(key); redisUtil.delete(key);
...@@ -697,7 +709,7 @@ public class RedisTask { ...@@ -697,7 +709,7 @@ public class RedisTask {
return; return;
} }
//查询会员配置 //查询会员配置
MemberConfig memberConfig = memberConfigService.getById(consumerMember.getMemberConfigId()); MemberConfig memberConfig = memberConfigService.getOne(new LambdaQueryWrapper<MemberConfig>().eq(MemberConfig::getMembershipLevel, consumerMember.getMembershipLevel()));
final BigDecimal[] sum = {BigDecimal.ZERO}; final BigDecimal[] sum = {BigDecimal.ZERO};
//计算扣除进度 //计算扣除进度
memberProgressLogs.stream().forEach(log -> { memberProgressLogs.stream().forEach(log -> {
...@@ -712,11 +724,6 @@ public class RedisTask { ...@@ -712,11 +724,6 @@ public class RedisTask {
//设置为0 //设置为0
consumerMember.setMembershipProgress(BigDecimal.ZERO); consumerMember.setMembershipProgress(BigDecimal.ZERO);
consumerMember.setMembershipLevel(0L); consumerMember.setMembershipLevel(0L);
MemberConfig memberConfigServiceOne = memberConfigService.getOne(new LambdaQueryWrapper<MemberConfig>()
.eq(MemberConfig::getMemberType, consumerMember.getMemberType())
.eq(MemberConfig::getMembershipLevel, consumerMember.getMembershipLevel())
);
consumerMember.setMemberConfigId(memberConfigServiceOne.getId());
//判断会员进度是否大于扣除进度 //判断会员进度是否大于扣除进度
} else if (consumerMember.getMembershipProgress().compareTo(sum[0].abs()) >= 0) { } else if (consumerMember.getMembershipProgress().compareTo(sum[0].abs()) >= 0) {
//会员进度减去扣除进度 //会员进度减去扣除进度
...@@ -731,11 +738,6 @@ public class RedisTask { ...@@ -731,11 +738,6 @@ public class RedisTask {
//等级降一级 //等级降一级
if (consumerMember.getMembershipLevel() > 0L) { if (consumerMember.getMembershipLevel() > 0L) {
consumerMember.setMembershipLevel(consumerMember.getMembershipLevel() - 1); consumerMember.setMembershipLevel(consumerMember.getMembershipLevel() - 1);
MemberConfig memberConfigServiceOne = memberConfigService.getOne(new LambdaQueryWrapper<MemberConfig>()
.eq(MemberConfig::getMemberType, consumerMember.getMemberType())
.eq(MemberConfig::getMembershipLevel, consumerMember.getMembershipLevel())
);
consumerMember.setMemberConfigId(memberConfigServiceOne.getId());
} }
} }
} }
......
...@@ -38,17 +38,17 @@ public class ConsumerMember extends BaseEntity { ...@@ -38,17 +38,17 @@ public class ConsumerMember extends BaseEntity {
@Excel(name = "会员等级") @Excel(name = "会员等级")
private Long membershipLevel; private Long membershipLevel;
/** // /**
* 会员类型 // * 会员类型
*/ // */
@Excel(name = "会员类型") // @Excel(name = "会员类型")
private Long memberType; // private Long memberType;
/** // /**
* 会员配置id // * 会员配置id
*/ // */
@Excel(name = "会员配置id") // @Excel(name = "会员配置id")
private Long memberConfigId; // private Long memberConfigId;
/** /**
* 会员有效期 * 会员有效期
......
...@@ -32,11 +32,11 @@ public class MemberConfig extends BaseEntity { ...@@ -32,11 +32,11 @@ public class MemberConfig extends BaseEntity {
@Excel(name = "会员等级") @Excel(name = "会员等级")
private Long membershipLevel; private Long membershipLevel;
/** // /**
* 会员类型 // * 会员类型
*/ // */
@Excel(name = "会员类型") // @Excel(name = "会员类型")
private Long memberType; // private Long memberType;
/** /**
* 等级名称 * 等级名称
...@@ -56,17 +56,17 @@ public class MemberConfig extends BaseEntity { ...@@ -56,17 +56,17 @@ public class MemberConfig extends BaseEntity {
@Excel(name = "折扣比例") @Excel(name = "折扣比例")
private BigDecimal discountRatio; private BigDecimal discountRatio;
/** // /**
* 会员有效期 // * 会员有效期
*/ // */
@Excel(name = "会员有效期") // @Excel(name = "会员有效期")
private Long validityPeriod; // private Long validityPeriod;
/** // /**
* 会员进度 // * 会员进度
*/ // */
@Excel(name = "会员进度") // @Excel(name = "会员进度")
private Long membershipProgress; // private Long membershipProgress;
/** /**
* 是否删除 * 是否删除
...@@ -82,12 +82,11 @@ public class MemberConfig extends BaseEntity { ...@@ -82,12 +82,11 @@ public class MemberConfig extends BaseEntity {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId()) .append("id", getId())
.append("membershipLevel", getMembershipLevel()) .append("membershipLevel", getMembershipLevel())
.append("memberType", getMemberType())
.append("levelName", getLevelName()) .append("levelName", getLevelName())
.append("limitRequirements", getLimitRequirements()) .append("limitRequirements", getLimitRequirements())
.append("discountRatio", getDiscountRatio()) .append("discountRatio", getDiscountRatio())
.append("validityPeriod", getValidityPeriod()) // .append("validityPeriod", getValidityPeriod())
.append("membershipProgress", getMembershipProgress()) // .append("membershipProgress", getMembershipProgress())
.append("isDelete", getIsDelete()) .append("isDelete", getIsDelete())
.append("createBy", getCreateBy()) .append("createBy", getCreateBy())
.append("createTime", getCreateTime()) .append("createTime", getCreateTime())
......
...@@ -49,7 +49,4 @@ public class WxRegisterPhoneRequest implements Serializable { ...@@ -49,7 +49,4 @@ public class WxRegisterPhoneRequest implements Serializable {
@ApiModelProperty(value = "上级id") @ApiModelProperty(value = "上级id")
private Long uid; private Long uid;
@ApiModelProperty(value = "活动类型")
private String activityType;
} }
...@@ -3,7 +3,6 @@ package share.system.service; ...@@ -3,7 +3,6 @@ package share.system.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import share.system.domain.Activity; import share.system.domain.Activity;
import share.system.domain.vo.ActivityDto; import share.system.domain.vo.ActivityDto;
import share.system.domain.vo.ActivityVo;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
...@@ -64,5 +63,5 @@ public interface ActivityService extends IService<Activity> { ...@@ -64,5 +63,5 @@ public interface ActivityService extends IService<Activity> {
*/ */
public int deleteActivityById(Long id); public int deleteActivityById(Long id);
Map<Date, List<ActivityVo>> queryList(ActivityDto dto); Map<Date, List<Activity>> queryList(ActivityDto dto);
} }
...@@ -61,5 +61,5 @@ public interface SharingActivitiesService extends IService<SharingActivities> ...@@ -61,5 +61,5 @@ public interface SharingActivitiesService extends IService<SharingActivities>
*/ */
public int deleteSharingActivitiesById(Long id); public int deleteSharingActivitiesById(Long id);
AjaxResult addSharingActivities(SharingActivities sharingActivities);
} }
...@@ -10,6 +10,8 @@ import com.cronutils.model.time.ExecutionTime; ...@@ -10,6 +10,8 @@ import com.cronutils.model.time.ExecutionTime;
import com.cronutils.parser.CronParser; import com.cronutils.parser.CronParser;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import share.common.enums.MemberTypeEnum;
import share.common.enums.YesNoEnum;
import share.common.utils.DateUtils; import share.common.utils.DateUtils;
import share.common.utils.StringUtils; import share.common.utils.StringUtils;
import share.common.utils.bean.BeanUtils; import share.common.utils.bean.BeanUtils;
...@@ -18,7 +20,6 @@ import share.system.domain.ConsumerMember; ...@@ -18,7 +20,6 @@ import share.system.domain.ConsumerMember;
import share.system.domain.SConsumer; import share.system.domain.SConsumer;
import share.system.domain.SStore; import share.system.domain.SStore;
import share.system.domain.vo.ActivityDto; import share.system.domain.vo.ActivityDto;
import share.system.domain.vo.ActivityVo;
import share.system.mapper.ActivityMapper; import share.system.mapper.ActivityMapper;
import share.system.service.ActivityService; import share.system.service.ActivityService;
import share.system.service.ConsumerMemberService; import share.system.service.ConsumerMemberService;
...@@ -119,7 +120,7 @@ public class ActivityServiceImpl extends ServiceImpl<ActivityMapper, Activity> i ...@@ -119,7 +120,7 @@ public class ActivityServiceImpl extends ServiceImpl<ActivityMapper, Activity> i
} }
@Override @Override
public Map<Date, List<ActivityVo>> queryList(ActivityDto dto) { public Map<Date, List<Activity>> queryList(ActivityDto dto) {
SConsumer user = sConsumerService.getInfo(); SConsumer user = sConsumerService.getInfo();
if (ObjectUtil.isEmpty(user)) { if (ObjectUtil.isEmpty(user)) {
return new HashMap<>(); return new HashMap<>();
...@@ -137,19 +138,25 @@ public class ActivityServiceImpl extends ServiceImpl<ActivityMapper, Activity> i ...@@ -137,19 +138,25 @@ public class ActivityServiceImpl extends ServiceImpl<ActivityMapper, Activity> i
} }
Activity activity = new Activity(); Activity activity = new Activity();
BeanUtils.copyProperties(dto, activity); BeanUtils.copyProperties(dto, activity);
activity.setMemberType(MemberTypeEnum.NORMAL.getIndex());
if (consumerMember.getIsRecharge().equals(YesNoEnum.yes.getIndex())) {
activity.setMemberType(MemberTypeEnum.RECHARGE.getIndex());
}
if (consumerMember.getIsRights().equals(YesNoEnum.yes.getIndex())) {
activity.setMemberType(MemberTypeEnum.RIGHTS.getIndex());
}
List<Activity> activities = selectActivityList(activity); List<Activity> activities = selectActivityList(activity);
CronParser cronParser = new CronParser(CronDefinitionBuilder.instanceDefinitionFor(CronType.QUARTZ)); CronParser cronParser = new CronParser(CronDefinitionBuilder.instanceDefinitionFor(CronType.QUARTZ));
Map<Date, List<ActivityVo>> map = new HashMap<>(); Map<Date, List<Activity>> map = new HashMap<>();
days.stream().forEach(day -> { days.stream().forEach(day -> {
List<ActivityVo> voList = new ArrayList<>(); List<Activity> voList = new ArrayList<>();
activities.stream().forEach(item -> { activities.stream().forEach(item -> {
Cron cron = cronParser.parse(item.getCronExpression()); Cron cron = cronParser.parse(item.getCronExpression());
ExecutionTime executionTime = ExecutionTime.forCron(cron); ExecutionTime executionTime = ExecutionTime.forCron(cron);
boolean match = executionTime.isMatch(ZonedDateTime.ofInstant(day.toInstant(), ZoneId.systemDefault())); boolean match = executionTime.isMatch(ZonedDateTime.ofInstant(day.toInstant(), ZoneId.systemDefault()));
if (match && consumerMember.getMemberType().equals(item.getMemberType())) { if (match) {
ActivityVo activityVo = new ActivityVo(); voList.add(item);
BeanUtils.copyProperties(item, activityVo);
voList.add(activityVo);
} }
}); });
if (voList.size() > 0) { if (voList.size() > 0) {
......
...@@ -769,17 +769,16 @@ public class CallbackServiceImpl implements CallbackService { ...@@ -769,17 +769,16 @@ public class CallbackServiceImpl implements CallbackService {
//查询是否有上级 //查询是否有上级
SharingActivities sharingActivities = sharingActivitiesService.getOne(new LambdaQueryWrapper<SharingActivities>() SharingActivities sharingActivities = sharingActivitiesService.getOne(new LambdaQueryWrapper<SharingActivities>()
.eq(SharingActivities::getNewUid, consumerId) .eq(SharingActivities::getNewUid, consumerId)
.eq(SharingActivities::getActivityType, "1")
.eq(SharingActivities::getIsDelete, YesNoEnum.no.getIndex())); .eq(SharingActivities::getIsDelete, YesNoEnum.no.getIndex()));
if (ObjectUtil.isNotEmpty(sharingActivities)) { if (ObjectUtil.isNotEmpty(sharingActivities)) {
//查询会员用户类型 //查询会员用户类型
LambdaQueryWrapper<ConsumerMember> consumerMemberLambdaQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<ConsumerMember> consumerMemberLambdaQueryWrapper = new LambdaQueryWrapper<>();
consumerMemberLambdaQueryWrapper.eq(ConsumerMember::getConsumerId,sharingActivities.getUid()); consumerMemberLambdaQueryWrapper.eq(ConsumerMember::getConsumerId, sharingActivities.getUid());
ConsumerMember consumerMember = consumerMemberService.getOne(consumerMemberLambdaQueryWrapper); ConsumerMember consumerMember = consumerMemberService.getOne(consumerMemberLambdaQueryWrapper);
//判断是否为权益会员和会员是否有效 //判断是否为权益会员和会员是否有效
if ("2".equals(consumerMember.getMemberType()) && new Date().getTime() < consumerMember.getExpirationDate().getTime() ){ if (YesNoEnum.yes.getIndex().equals(consumerMember.getIsRights()) && new Date().getTime() < consumerMember.getExpirationDate().getTime()) {
Boolean aBoolean = redisTemplate.hasKey(ReceiptRdeisEnum.EQUITY_MEMBERS_TIME + sharingActivities.getUid().toString()); Boolean aBoolean = redisTemplate.hasKey(ReceiptRdeisEnum.EQUITY_MEMBERS_TIME + sharingActivities.getUid().toString());
if (aBoolean){ if (aBoolean) {
String equityFund = sysConfigService.selectConfigByKey("sys.equityFundLog.equityFund"); String equityFund = sysConfigService.selectConfigByKey("sys.equityFundLog.equityFund");
//查询上级用户是否有钱包 //查询上级用户是否有钱包
ConsumerWallet consumerWallet = consumerWalletService.getOne(new LambdaQueryWrapper<ConsumerWallet>() ConsumerWallet consumerWallet = consumerWalletService.getOne(new LambdaQueryWrapper<ConsumerWallet>()
...@@ -826,6 +825,81 @@ public class CallbackServiceImpl implements CallbackService { ...@@ -826,6 +825,81 @@ public class CallbackServiceImpl implements CallbackService {
} }
} }
} }
// /**
// * 新增权益金日志
// * @param consumerId 用户ID
// * @param payPrice 消费金额
// * @param equityOrderNo 订单编号
// * @param terminalTrace 终端流水号
// * @param type 权益类型
// */
// private void addEquityFundLogRights(Long consumerId, BigDecimal payPrice, String equityOrderNo, String terminalTrace, String type) {
// //查询是否有上级
// SharingActivities sharingActivities = sharingActivitiesService.getOne(new LambdaQueryWrapper<SharingActivities>()
// .eq(SharingActivities::getNewUid, consumerId)
// .eq(SharingActivities::getIsDelete, YesNoEnum.no.getIndex()));
// if (ObjectUtil.isNotEmpty(sharingActivities)) {
// //查询会员用户类型
// LambdaQueryWrapper<ConsumerMember> consumerMemberWrapper = new LambdaQueryWrapper<>();
// consumerMemberWrapper.eq(ConsumerMember::getConsumerId, sharingActivities.getUid());
// ConsumerMember consumerMember = consumerMemberService.getOne(consumerMemberWrapper);
// LambdaQueryWrapper<ConsumerMember> newConsumerMemberWrapper = new LambdaQueryWrapper<>();
// newConsumerMemberWrapper.eq(ConsumerMember::getConsumerId, sharingActivities.getUid());
// ConsumerMember newConsumerMember = consumerMemberService.getOne(newConsumerMemberWrapper);
// //判断是否为权益会员和会员是否有效
// if ("2".equals(consumerMember.getMemberType()) && new Date().getTime() < consumerMember.getExpirationDate().getTime()
// && "2".equals(newConsumerMember.getMemberType()) && new Date().getTime() < newConsumerMember.getExpirationDate().getTime()) {
// Boolean aBoolean = redisTemplate.hasKey(ReceiptRdeisEnum.EQUITY_MEMBERS_TIME + sharingActivities.getUid().toString());
// Boolean newAboolean = redisTemplate.hasKey(ReceiptRdeisEnum.EQUITY_MEMBERS_TIME + sharingActivities.getNewUid().toString());
// if (aBoolean && newAboolean) {
// String equityFund = sysConfigService.selectConfigByKey("sys.equityFundLog.equityFund");
// //查询上级用户是否有钱包
// ConsumerWallet consumerWallet = consumerWalletService.getOne(new LambdaQueryWrapper<ConsumerWallet>()
// .eq(ConsumerWallet::getConsumerId, sharingActivities.getUid()));
// if (ObjectUtil.isNotEmpty(consumerWallet)) {
// consumerWallet.setEquityFund(consumerWallet.getEquityFund().add(payPrice.multiply(new BigDecimal(equityFund))));
// consumerWallet.setAccumulateEquityFund(consumerWallet.getAccumulateEquityFund().
// add(payPrice.multiply(new BigDecimal(equityFund))));
// consumerWallet.setUpdateTime(DateUtils.getNowDate());
// consumerWalletService.updateConsumerWallet(consumerWallet);
// } else {
// //新增钱包
// ConsumerWallet newConsumerWallet = new ConsumerWallet();
// BigDecimal defaultVlue = new BigDecimal(0.0);
// newConsumerWallet.setConsumerId(sharingActivities.getUid());
// newConsumerWallet.setBalance(defaultVlue);
// newConsumerWallet.setRemainingIntegral(defaultVlue);
// newConsumerWallet.setRemainingDuration(defaultVlue);
// newConsumerWallet.setEquityFund(consumerWallet.getEquityFund().add(payPrice.multiply(new BigDecimal(equityFund).setScale(2, RoundingMode.HALF_UP))));
// newConsumerWallet.setAccumulateEquityFund(consumerWallet.getAccumulateEquityFund()
// .add(payPrice.multiply(new BigDecimal(equityFund).setScale(2, RoundingMode.HALF_UP))));
// consumerWalletService.insertConsumerWallet(newConsumerWallet);
// }
// //添加权益金日志记录
// //下级用户
// SConsumer newConsumer = consumerService.getById(consumerId);
// //上级用户
// SConsumer consumer = consumerService.getById(sharingActivities.getUid());
// EquityFundLog equityFundLog = new EquityFundLog();
// equityFundLog.setEquityFund(payPrice.multiply(new BigDecimal(equityFund).setScale(2, RoundingMode.HALF_UP)));
// equityFundLog.setEquityFundType(type);
// equityFundLog.setOutTradeNo(equityOrderNo);
// equityFundLog.setTerminalTrace(terminalTrace);
// equityFundLog.setUid(sharingActivities.getUid());
// equityFundLog.setNewUid(sharingActivities.getNewUid());
// equityFundLog.setPhone(consumer.getPhone());
// equityFundLog.setAccount(consumer.getAccount());
// equityFundLog.setNickName(consumer.getNickName());
// equityFundLog.setNewPhone(newConsumer.getPhone());
// equityFundLog.setNewAccount(newConsumer.getAccount());
// equityFundLog.setNewNickName(newConsumer.getNickName());
// equityFundLogService.insertEquityFundLog(equityFundLog);
// }
// }
// }
// }
/** /**
* 支付订单回调通知 * 支付订单回调通知
......
...@@ -138,7 +138,7 @@ public class ConsumerWalletServiceImpl extends ServiceImpl<ConsumerWalletMapper, ...@@ -138,7 +138,7 @@ public class ConsumerWalletServiceImpl extends ServiceImpl<ConsumerWalletMapper,
public boolean addConsumerWallet(ConsumerWallet consumerWallet) { public boolean addConsumerWallet(ConsumerWallet consumerWallet) {
int i = consumerWalletMapper.insertConsumerWallet(consumerWallet); int i = consumerWalletMapper.insertConsumerWallet(consumerWallet);
ConsumerMember one = consumerMemberService.getOne(new LambdaQueryWrapper<ConsumerMember>().eq(ConsumerMember::getConsumerId, consumerWallet.getConsumerId())); ConsumerMember one = consumerMemberService.getOne(new LambdaQueryWrapper<ConsumerMember>().eq(ConsumerMember::getConsumerId, consumerWallet.getConsumerId()));
MemberConfig memberConfig = memberConfigService.getById(one.getMemberConfigId()); MemberConfig memberConfig = memberConfigService.getOne(new LambdaQueryWrapper<MemberConfig>().eq(MemberConfig::getMembershipLevel, one.getMembershipLevel()));
if (consumerWallet.getBalance().compareTo(new BigDecimal(0)) > 0) { if (consumerWallet.getBalance().compareTo(new BigDecimal(0)) > 0) {
BalanceLog balanceLog = new BalanceLog(); BalanceLog balanceLog = new BalanceLog();
balanceLog.setConsumerId(consumerWallet.getConsumerId()); balanceLog.setConsumerId(consumerWallet.getConsumerId());
...@@ -175,14 +175,20 @@ public class ConsumerWalletServiceImpl extends ServiceImpl<ConsumerWalletMapper, ...@@ -175,14 +175,20 @@ public class ConsumerWalletServiceImpl extends ServiceImpl<ConsumerWalletMapper,
memberProgressLog.setOperationTime(new Date()); memberProgressLog.setOperationTime(new Date());
memberProgressLog.setOperationType(YesNoEnum.yes.getIndex()); memberProgressLog.setOperationType(YesNoEnum.yes.getIndex());
memberProgressLog.setCreateTime(new Date()); memberProgressLog.setCreateTime(new Date());
memberProgressLog.setExpirationTime(DateUtils.addYears(new Date(), memberConfig.getValidityPeriod().intValue())); if (one.getIsRecharge().equals(YesNoEnum.yes.getIndex())) {
memberProgressLog.setExpirationTime(DateUtils.addYears(new Date(), 100));
}
if (one.getIsRights().equals(YesNoEnum.yes.getIndex())) {
memberProgressLog.setExpirationTime(DateUtils.addYears(new Date(), 1));
}
memberProgressLogService.save(memberProgressLog); memberProgressLogService.save(memberProgressLog);
MemberConfig newOne = memberConfigService.getOne(new LambdaQueryWrapper<MemberConfig>() MemberConfig newOne = memberConfigService.getOne(new LambdaQueryWrapper<MemberConfig>()
.eq(MemberConfig::getMemberType, one.getMemberType()) // .eq(MemberConfig::getMemberType, one.getMemberType())
.eq(MemberConfig::getMembershipLevel, one.getMembershipLevel() + 1L)); .eq(MemberConfig::getMembershipLevel, one.getMembershipLevel() + 1L));
if (ObjectUtil.isNotEmpty(newOne) && one.getMembershipProgress().compareTo(BigDecimal.valueOf(newOne.getLimitRequirements())) >= 0) { if (ObjectUtil.isNotEmpty(newOne) && one.getMembershipProgress().compareTo(BigDecimal.valueOf(newOne.getLimitRequirements())) >= 0) {
one.setMembershipLevel(one.getMembershipLevel() + 1L); one.setMembershipLevel(one.getMembershipLevel() + 1L);
one.setMemberConfigId(newOne.getId()); // one.setMemberConfigId(newOne.getId());
consumerMemberService.updateConsumerMember(one); consumerMemberService.updateConsumerMember(one);
} }
logger.debug("统计累计积分"); logger.debug("统计累计积分");
...@@ -199,11 +205,12 @@ public class ConsumerWalletServiceImpl extends ServiceImpl<ConsumerWalletMapper, ...@@ -199,11 +205,12 @@ public class ConsumerWalletServiceImpl extends ServiceImpl<ConsumerWalletMapper,
BigDecimal oldIntegral = consumerWallet.getRemainingIntegral(); BigDecimal oldIntegral = consumerWallet.getRemainingIntegral();
RechargeConf rechargeConf = rechargeConfService.selectRechargeConfById(recharge.getRechargeConfId()); RechargeConf rechargeConf = rechargeConfService.selectRechargeConfById(recharge.getRechargeConfId());
if (one.getMemberType().equals(MemberTypeEnum.RECHARGE.getIndex())) { if (one.getIsRecharge().equals(YesNoEnum.yes.getIndex())) {
MemberConfig memberConfig = memberConfigService.getOne(new LambdaQueryWrapper<MemberConfig>() // MemberConfig memberConfig = memberConfigService.getOne(new LambdaQueryWrapper<MemberConfig>()
.eq(MemberConfig::getMembershipLevel, one.getMembershipLevel()) // .eq(MemberConfig::getMembershipLevel, one.getMembershipLevel())
.eq(MemberConfig::getMemberType, MemberTypeEnum.RECHARGE.getIndex())); // .eq(MemberConfig::getMemberType, MemberTypeEnum.RECHARGE.getIndex())
one.setExpirationDate(DateUtils.addYears(new Date(), memberConfig.getValidityPeriod().intValue())); // );
one.setExpirationDate(DateUtils.addYears(new Date(), 1));
} }
logger.debug("修改会员用户"); logger.debug("修改会员用户");
...@@ -261,20 +268,26 @@ public class ConsumerWalletServiceImpl extends ServiceImpl<ConsumerWalletMapper, ...@@ -261,20 +268,26 @@ public class ConsumerWalletServiceImpl extends ServiceImpl<ConsumerWalletMapper,
memberProgressLog.setOperationTime(new Date()); memberProgressLog.setOperationTime(new Date());
memberProgressLog.setOperationType(YesNoEnum.yes.getIndex()); memberProgressLog.setOperationType(YesNoEnum.yes.getIndex());
memberProgressLog.setCreateTime(new Date()); memberProgressLog.setCreateTime(new Date());
memberProgressLog.setExpirationTime(DateUtils.addYears(new Date(), memberConfigService.getById(one.getMemberConfigId()).getValidityPeriod().intValue())); if (one.getIsRecharge().equals(YesNoEnum.yes.getIndex())) {
memberProgressLog.setExpirationTime(DateUtils.addYears(new Date(), 100));
}
if (one.getIsRights().equals(YesNoEnum.yes.getIndex())) {
memberProgressLog.setExpirationTime(DateUtils.addYears(new Date(), 1));
}
memberProgressLogService.save(memberProgressLog); memberProgressLogService.save(memberProgressLog);
one.setMembershipProgress(one.getMembershipProgress().add(divide)); one.setMembershipProgress(one.getMembershipProgress().add(divide));
} }
//查询当前会员类型和下一级的会员配置 //查询当前会员类型和下一级的会员配置
MemberConfig memberConfigServiceOne = memberConfigService.getOne(new LambdaQueryWrapper<MemberConfig>() MemberConfig memberConfigServiceOne = memberConfigService.getOne(new LambdaQueryWrapper<MemberConfig>()
.eq(MemberConfig::getMemberType, one.getMemberType()) // .eq(MemberConfig::getMemberType, one.getMemberType())
.eq(MemberConfig::getMembershipLevel, one.getMembershipLevel() + 1L)); .eq(MemberConfig::getMembershipLevel, one.getMembershipLevel() + 1L));
if (ObjectUtil.isNotEmpty(memberConfigServiceOne)) { if (ObjectUtil.isNotEmpty(memberConfigServiceOne)) {
//判断是否升级 //判断是否升级
if (one.getMembershipProgress().compareTo(BigDecimal.valueOf(memberConfigServiceOne.getLimitRequirements())) >= 0) { if (one.getMembershipProgress().compareTo(BigDecimal.valueOf(memberConfigServiceOne.getLimitRequirements())) >= 0) {
one.setMembershipLevel(one.getMembershipLevel() + 1L); one.setMembershipLevel(one.getMembershipLevel() + 1L);
one.setMemberConfigId(memberConfigServiceOne.getId()); // one.setMemberConfigId(memberConfigServiceOne.getId());
} }
} }
consumerMemberService.updateConsumerMember(one); consumerMemberService.updateConsumerMember(one);
...@@ -317,7 +330,7 @@ public class ConsumerWalletServiceImpl extends ServiceImpl<ConsumerWalletMapper, ...@@ -317,7 +330,7 @@ public class ConsumerWalletServiceImpl extends ServiceImpl<ConsumerWalletMapper,
List<Long> ids = orderList.stream().map(SOrder::getCouponId).filter(Objects::nonNull).collect(Collectors.toList()); List<Long> ids = orderList.stream().map(SOrder::getCouponId).filter(Objects::nonNull).collect(Collectors.toList());
if (CollectionUtil.isEmpty(ids)) { if (CollectionUtil.isEmpty(ids)) {
logger.debug("优惠券为空"); logger.debug("优惠券为空");
if (one.getMemberType().equals(MemberTypeEnum.RECHARGE.getIndex())) { if (one.getIsRecharge().equals(YesNoEnum.yes.getIndex())) {
return; return;
} }
} else { } else {
...@@ -332,7 +345,7 @@ public class ConsumerWalletServiceImpl extends ServiceImpl<ConsumerWalletMapper, ...@@ -332,7 +345,7 @@ public class ConsumerWalletServiceImpl extends ServiceImpl<ConsumerWalletMapper,
}); });
} }
logger.debug("优惠券购买金额:" + consumption[0]); logger.debug("优惠券购买金额:" + consumption[0]);
if (one.getMemberType().equals(MemberTypeEnum.RIGHTS.getIndex())) { if (one.getIsRights().equals(YesNoEnum.yes.getIndex())) {
//orderList累加payPrice //orderList累加payPrice
consumption[0] = consumption[0].add(orderList.stream().map(SOrder::getPayPrice).reduce(BigDecimal.ZERO, BigDecimal::add)); consumption[0] = consumption[0].add(orderList.stream().map(SOrder::getPayPrice).reduce(BigDecimal.ZERO, BigDecimal::add));
logger.debug("订单实付金额:" + consumption[0]); logger.debug("订单实付金额:" + consumption[0]);
...@@ -353,10 +366,16 @@ public class ConsumerWalletServiceImpl extends ServiceImpl<ConsumerWalletMapper, ...@@ -353,10 +366,16 @@ public class ConsumerWalletServiceImpl extends ServiceImpl<ConsumerWalletMapper,
memberProgressLog.setOperationTime(new Date()); memberProgressLog.setOperationTime(new Date());
memberProgressLog.setOperationType(YesNoEnum.yes.getIndex()); memberProgressLog.setOperationType(YesNoEnum.yes.getIndex());
memberProgressLog.setCreateTime(new Date()); memberProgressLog.setCreateTime(new Date());
memberProgressLog.setExpirationTime(DateUtils.addYears(new Date(), memberConfig.getValidityPeriod().intValue())); if (one.getIsRecharge().equals(YesNoEnum.yes.getIndex())) {
memberProgressLog.setExpirationTime(DateUtils.addYears(new Date(), 100));
}
if (one.getIsRights().equals(YesNoEnum.yes.getIndex())) {
memberProgressLog.setExpirationTime(DateUtils.addYears(new Date(), 1));
}
if (memberProgressLogService.save(memberProgressLog) && integralLogService.save(integralLog)) { if (memberProgressLogService.save(memberProgressLog) && integralLogService.save(integralLog)) {
List<MemberConfig> list = memberConfigService.list(new LambdaQueryWrapper<MemberConfig>() List<MemberConfig> list = memberConfigService.list(new LambdaQueryWrapper<MemberConfig>()
.eq(MemberConfig::getMemberType, one.getMemberType()) // .eq(MemberConfig::getMemberType, one.getMemberType())
.orderBy(true, false, MemberConfig::getMembershipLevel)); .orderBy(true, false, MemberConfig::getMembershipLevel));
//转Map limitRequirements,MemberConfig //转Map limitRequirements,MemberConfig
Map<Long, MemberConfig> memberConfigMap = list.stream().collect(Collectors.toMap(MemberConfig::getMembershipLevel, Function.identity())); Map<Long, MemberConfig> memberConfigMap = list.stream().collect(Collectors.toMap(MemberConfig::getMembershipLevel, Function.identity()));
...@@ -366,7 +385,7 @@ public class ConsumerWalletServiceImpl extends ServiceImpl<ConsumerWalletMapper, ...@@ -366,7 +385,7 @@ public class ConsumerWalletServiceImpl extends ServiceImpl<ConsumerWalletMapper,
consumption[0].compareTo(BigDecimal.valueOf(memberConfigMap.get(entry.getKey() + 1).getLimitRequirements())) < 0 consumption[0].compareTo(BigDecimal.valueOf(memberConfigMap.get(entry.getKey() + 1).getLimitRequirements())) < 0
&& entry.getKey().compareTo(Collections.max(memberConfigMap.keySet())) < 0) { && entry.getKey().compareTo(Collections.max(memberConfigMap.keySet())) < 0) {
one.setMembershipLevel(entry.getKey()); one.setMembershipLevel(entry.getKey());
one.setMemberConfigId(entry.getValue().getId()); // one.setMemberConfigId(entry.getValue().getId());
one.setMembershipProgress(consumption[0].add(one.getMembershipProgress())); one.setMembershipProgress(consumption[0].add(one.getMembershipProgress()));
consumerMemberService.updateConsumerMember(one); consumerMemberService.updateConsumerMember(one);
consumerWallet.setRemainingIntegral(consumerWallet.getRemainingIntegral().add(consumption[0])); consumerWallet.setRemainingIntegral(consumerWallet.getRemainingIntegral().add(consumption[0]));
...@@ -374,7 +393,7 @@ public class ConsumerWalletServiceImpl extends ServiceImpl<ConsumerWalletMapper, ...@@ -374,7 +393,7 @@ public class ConsumerWalletServiceImpl extends ServiceImpl<ConsumerWalletMapper,
return; return;
} else if (consumption[0].compareTo(BigDecimal.valueOf(memberConfigMap.get(Collections.max(memberConfigMap.keySet())).getLimitRequirements())) >= 0) { } else if (consumption[0].compareTo(BigDecimal.valueOf(memberConfigMap.get(Collections.max(memberConfigMap.keySet())).getLimitRequirements())) >= 0) {
one.setMembershipLevel(Collections.max(memberConfigMap.keySet())); one.setMembershipLevel(Collections.max(memberConfigMap.keySet()));
one.setMemberConfigId(memberConfigMap.get(Collections.max(memberConfigMap.keySet())).getId()); // one.setMemberConfigId(memberConfigMap.get(Collections.max(memberConfigMap.keySet())).getId());
one.setMembershipProgress(consumption[0].add(one.getMembershipProgress())); one.setMembershipProgress(consumption[0].add(one.getMembershipProgress()));
consumerMemberService.updateConsumerMember(one); consumerMemberService.updateConsumerMember(one);
consumerWallet.setRemainingIntegral(consumerWallet.getRemainingIntegral().add(consumption[0])); consumerWallet.setRemainingIntegral(consumerWallet.getRemainingIntegral().add(consumption[0]));
...@@ -391,7 +410,7 @@ public class ConsumerWalletServiceImpl extends ServiceImpl<ConsumerWalletMapper, ...@@ -391,7 +410,7 @@ public class ConsumerWalletServiceImpl extends ServiceImpl<ConsumerWalletMapper,
public void accumulatedConsumptionStatistics(Long consumerId) { public void accumulatedConsumptionStatistics(Long consumerId) {
ConsumerWallet consumerWallet = consumerWalletService.getOne(new LambdaQueryWrapper<ConsumerWallet>().eq(ConsumerWallet::getConsumerId, consumerId)); ConsumerWallet consumerWallet = consumerWalletService.getOne(new LambdaQueryWrapper<ConsumerWallet>().eq(ConsumerWallet::getConsumerId, consumerId));
ConsumerMember one = consumerMemberService.getOne(new LambdaQueryWrapper<ConsumerMember>().eq(ConsumerMember::getConsumerId, consumerId)); ConsumerMember one = consumerMemberService.getOne(new LambdaQueryWrapper<ConsumerMember>().eq(ConsumerMember::getConsumerId, consumerId));
MemberConfig memberConfig = memberConfigService.getById(one.getMemberConfigId()); MemberConfig memberConfig = memberConfigService.getOne(new LambdaQueryWrapper<MemberConfig>().eq(MemberConfig::getMembershipLevel, one.getMembershipLevel()));
accumulatedConsumptionStatistics(consumerWallet, one, memberConfig); accumulatedConsumptionStatistics(consumerWallet, one, memberConfig);
} }
} }
...@@ -11,7 +11,6 @@ import org.slf4j.LoggerFactory; ...@@ -11,7 +11,6 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import share.common.core.redis.RedisUtil; import share.common.core.redis.RedisUtil;
import share.common.enums.MemberTypeEnum;
import share.common.enums.ReceiptRdeisEnum; import share.common.enums.ReceiptRdeisEnum;
import share.common.enums.YesNoEnum; import share.common.enums.YesNoEnum;
import share.common.exception.base.BaseException; import share.common.exception.base.BaseException;
...@@ -141,7 +140,7 @@ public class EquityMembersOrderServiceImpl extends ServiceImpl<EquityMembersOrde ...@@ -141,7 +140,7 @@ public class EquityMembersOrderServiceImpl extends ServiceImpl<EquityMembersOrde
} }
ConsumerMember consumerMember = consumerMemberService.getOne(new LambdaQueryWrapper<ConsumerMember>() ConsumerMember consumerMember = consumerMemberService.getOne(new LambdaQueryWrapper<ConsumerMember>()
.eq(ConsumerMember::getConsumerId, user.getId()) .eq(ConsumerMember::getConsumerId, user.getId())
.eq(ConsumerMember::getMemberType, MemberTypeEnum.RIGHTS.getIndex()) // .eq(ConsumerMember::getMemberType, MemberTypeEnum.RIGHTS.getIndex())
); );
if (ObjectUtil.isNotEmpty(consumerMember)) { if (ObjectUtil.isNotEmpty(consumerMember)) {
Date expirationDate = consumerMember.getExpirationDate(); Date expirationDate = consumerMember.getExpirationDate();
...@@ -173,11 +172,11 @@ public class EquityMembersOrderServiceImpl extends ServiceImpl<EquityMembersOrde ...@@ -173,11 +172,11 @@ public class EquityMembersOrderServiceImpl extends ServiceImpl<EquityMembersOrde
ConsumerMember newConsumerMember = new ConsumerMember(); ConsumerMember newConsumerMember = new ConsumerMember();
newConsumerMember.setConsumerId(equityMembersOrder.getConsumerId()); newConsumerMember.setConsumerId(equityMembersOrder.getConsumerId());
newConsumerMember.setMembershipLevel(equityMembersOrderConfig.getDefaultLevel()); newConsumerMember.setMembershipLevel(equityMembersOrderConfig.getDefaultLevel());
newConsumerMember.setMemberType(MemberTypeEnum.RIGHTS.getIndex()); // newConsumerMember.setMemberType(MemberTypeEnum.RIGHTS.getIndex());
MemberConfig memberConfig = memberConfigService.getOne(new LambdaQueryWrapper<MemberConfig>() MemberConfig memberConfig = memberConfigService.getOne(new LambdaQueryWrapper<MemberConfig>()
.eq(MemberConfig::getMembershipLevel, equityMembersOrderConfig.getDefaultLevel()) .eq(MemberConfig::getMembershipLevel, equityMembersOrderConfig.getDefaultLevel()));
.eq(MemberConfig::getMemberType, MemberTypeEnum.RIGHTS.getIndex())); // .eq(MemberConfig::getMemberType, MemberTypeEnum.RIGHTS.getIndex()));
newConsumerMember.setMemberConfigId(memberConfig.getId()); // newConsumerMember.setMemberConfigId(memberConfig.getId());
newConsumerMember.setExpirationDate(DateUtils.addYears(DateUtils.parseDate(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM, new Date())), newConsumerMember.setExpirationDate(DateUtils.addYears(DateUtils.parseDate(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM, new Date())),
equityMembersOrderConfig.getValidityPeriod().intValue())); equityMembersOrderConfig.getValidityPeriod().intValue()));
newConsumerMember.setMembershipProgress(equityMembersOrderConfig.getGiftPoints()); newConsumerMember.setMembershipProgress(equityMembersOrderConfig.getGiftPoints());
...@@ -189,7 +188,7 @@ public class EquityMembersOrderServiceImpl extends ServiceImpl<EquityMembersOrde ...@@ -189,7 +188,7 @@ public class EquityMembersOrderServiceImpl extends ServiceImpl<EquityMembersOrde
memberProgressLog.setOperationType(YesNoEnum.yes.getIndex()); memberProgressLog.setOperationType(YesNoEnum.yes.getIndex());
memberProgressLog.setOperationTime(new Date()); memberProgressLog.setOperationTime(new Date());
memberProgressLog.setCreateTime(new Date()); memberProgressLog.setCreateTime(new Date());
memberProgressLog.setExpirationTime(DateUtils.addYears(new Date(), Math.toIntExact(memberConfig.getValidityPeriod()))); memberProgressLog.setExpirationTime(DateUtils.addYears(new Date(), 1));
memberProgressLogService.save(memberProgressLog); memberProgressLogService.save(memberProgressLog);
} }
newConsumerMember.setCreateTime(new Date()); newConsumerMember.setCreateTime(new Date());
...@@ -206,21 +205,22 @@ public class EquityMembersOrderServiceImpl extends ServiceImpl<EquityMembersOrde ...@@ -206,21 +205,22 @@ public class EquityMembersOrderServiceImpl extends ServiceImpl<EquityMembersOrde
} else { } else {
MemberConfig memberConfigServiceOne = memberConfigService.getOne(new LambdaQueryWrapper<MemberConfig>() MemberConfig memberConfigServiceOne = memberConfigService.getOne(new LambdaQueryWrapper<MemberConfig>()
.eq(MemberConfig::getMembershipLevel, consumerMember.getMembershipLevel()) .eq(MemberConfig::getMembershipLevel, consumerMember.getMembershipLevel())
.eq(MemberConfig::getMemberType, MemberTypeEnum.RIGHTS.getIndex())); // .eq(MemberConfig::getMemberType, MemberTypeEnum.RIGHTS.getIndex())
if (consumerMember.getMemberType().equals(MemberTypeEnum.RIGHTS.getIndex())) { );
if (consumerMember.getIsRights().equals(YesNoEnum.yes.getIndex())) {
//在原来的基础上增加有效期 //在原来的基础上增加有效期
consumerMember.setExpirationDate(DateUtils.addYears(DateUtils.parseDate(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM, consumerMember.getExpirationDate())), consumerMember.setExpirationDate(DateUtils.addYears(DateUtils.parseDate(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM, consumerMember.getExpirationDate())),
memberConfigServiceOne.getValidityPeriod().intValue())); 1));
extracted(equityMembersOrder, equityMembersOrderConfig, consumerMember, consumerWallet, memberConfigServiceOne); extracted(equityMembersOrder, equityMembersOrderConfig, consumerMember, consumerWallet, memberConfigServiceOne);
consumerMemberService.updateConsumerMember(consumerMember); consumerMemberService.updateConsumerMember(consumerMember);
logger.debug("权益会员原来的基础上增加有效期"); logger.debug("权益会员原来的基础上增加有效期");
} else { } else {
consumerMember.setIsRights(YesNoEnum.yes.getIndex()); consumerMember.setIsRights(YesNoEnum.yes.getIndex());
//修改会员类型为权益会员 //修改会员类型为权益会员
consumerMember.setMemberType(MemberTypeEnum.RIGHTS.getIndex()); // consumerMember.setMemberType(MemberTypeEnum.RIGHTS.getIndex());
consumerMember.setMemberConfigId(memberConfigServiceOne.getId()); // consumerMember.setMemberConfigId(memberConfigServiceOne.getId());
consumerMember.setExpirationDate(DateUtils.addYears(DateUtils.parseDate(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM, new Date())), consumerMember.setExpirationDate(DateUtils.addYears(DateUtils.parseDate(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM, new Date())),
memberConfigServiceOne.getValidityPeriod().intValue())); 1));
extracted(equityMembersOrder, equityMembersOrderConfig, consumerMember, consumerWallet, memberConfigServiceOne); extracted(equityMembersOrder, equityMembersOrderConfig, consumerMember, consumerWallet, memberConfigServiceOne);
consumerMemberService.updateConsumerMember(consumerMember); consumerMemberService.updateConsumerMember(consumerMember);
logger.debug("修改会员类型为权益会员"); logger.debug("修改会员类型为权益会员");
...@@ -267,7 +267,7 @@ public class EquityMembersOrderServiceImpl extends ServiceImpl<EquityMembersOrde ...@@ -267,7 +267,7 @@ public class EquityMembersOrderServiceImpl extends ServiceImpl<EquityMembersOrde
memberProgressLog.setOperationType(YesNoEnum.yes.getIndex()); memberProgressLog.setOperationType(YesNoEnum.yes.getIndex());
memberProgressLog.setOperationTime(new Date()); memberProgressLog.setOperationTime(new Date());
memberProgressLog.setCreateTime(new Date()); memberProgressLog.setCreateTime(new Date());
memberProgressLog.setExpirationTime(DateUtils.addYears(new Date(), Math.toIntExact(memberConfigServiceOne.getValidityPeriod()))); memberProgressLog.setExpirationTime(DateUtils.addYears(new Date(), 1));
IntegralLog integralLog = new IntegralLog(); IntegralLog integralLog = new IntegralLog();
integralLog.setConsumerId(equityMembersOrder.getConsumerId()); integralLog.setConsumerId(equityMembersOrder.getConsumerId());
...@@ -283,13 +283,13 @@ public class EquityMembersOrderServiceImpl extends ServiceImpl<EquityMembersOrde ...@@ -283,13 +283,13 @@ public class EquityMembersOrderServiceImpl extends ServiceImpl<EquityMembersOrde
} }
//查询当前会员类型和下一级的会员配置 //查询当前会员类型和下一级的会员配置
MemberConfig one = memberConfigService.getOne(new LambdaQueryWrapper<MemberConfig>() MemberConfig one = memberConfigService.getOne(new LambdaQueryWrapper<MemberConfig>()
.eq(MemberConfig::getMemberType, consumerMember.getMemberType()) // .eq(MemberConfig::getMemberType, consumerMember.getMemberType())
.eq(MemberConfig::getMembershipLevel, consumerMember.getMembershipLevel() + 1L)); .eq(MemberConfig::getMembershipLevel, consumerMember.getMembershipLevel() + 1L));
if (ObjectUtil.isNotEmpty(one)) { if (ObjectUtil.isNotEmpty(one)) {
//判断是否升级 //判断是否升级
if (ObjectUtil.isNotEmpty(one) && consumerMember.getMembershipProgress().compareTo(BigDecimal.valueOf(one.getLimitRequirements())) >= 0) { if (ObjectUtil.isNotEmpty(one) && consumerMember.getMembershipProgress().compareTo(BigDecimal.valueOf(one.getLimitRequirements())) >= 0) {
consumerMember.setMembershipLevel(consumerMember.getMembershipLevel() + 1L); consumerMember.setMembershipLevel(consumerMember.getMembershipLevel() + 1L);
consumerMember.setMemberConfigId(one.getId()); // consumerMember.setMemberConfigId(one.getId());
} }
} }
} }
......
...@@ -11,7 +11,6 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -11,7 +11,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import share.common.enums.GiveTypeEnum; import share.common.enums.GiveTypeEnum;
import share.common.enums.MemberTypeEnum;
import share.common.enums.YesNoEnum; import share.common.enums.YesNoEnum;
import share.common.exception.base.BaseException; import share.common.exception.base.BaseException;
import share.common.utils.BaseUtil; import share.common.utils.BaseUtil;
...@@ -158,13 +157,14 @@ public class RechargeServiceImpl extends ServiceImpl<RechargeMapper, Recharge> i ...@@ -158,13 +157,14 @@ public class RechargeServiceImpl extends ServiceImpl<RechargeMapper, Recharge> i
ConsumerMember consumerMember = new ConsumerMember(); ConsumerMember consumerMember = new ConsumerMember();
consumerMember.setConsumerId(recharge.getConsumerId()); consumerMember.setConsumerId(recharge.getConsumerId());
consumerMember.setMembershipLevel(0L); consumerMember.setMembershipLevel(0L);
consumerMember.setMemberType(MemberTypeEnum.RECHARGE.getIndex()); // consumerMember.setMemberType(MemberTypeEnum.RECHARGE.getIndex());
MemberConfig memberConfig = memberConfigService.getOne(new LambdaQueryWrapper<MemberConfig>() MemberConfig memberConfig = memberConfigService.getOne(new LambdaQueryWrapper<MemberConfig>()
.eq(MemberConfig::getMembershipLevel, 0L) .eq(MemberConfig::getMembershipLevel, 0L)
.eq(MemberConfig::getMemberType, MemberTypeEnum.RECHARGE.getIndex())); // .eq(MemberConfig::getMemberType, MemberTypeEnum.RECHARGE.getIndex())
consumerMember.setMemberConfigId(memberConfig.getId()); );
// consumerMember.setMemberConfigId(memberConfig.getId());
consumerMember.setMembershipProgress(BigDecimal.ZERO); consumerMember.setMembershipProgress(BigDecimal.ZERO);
consumerMember.setExpirationDate(DateUtils.addYears(new Date(), memberConfig.getValidityPeriod().intValue())); consumerMember.setExpirationDate(DateUtils.addYears(new Date(), 100));
consumerMember.setCreateTime(new Date()); consumerMember.setCreateTime(new Date());
consumerMember.setIsRecharge(YesNoEnum.yes.getIndex()); consumerMember.setIsRecharge(YesNoEnum.yes.getIndex());
consumerMemberService.save(consumerMember); consumerMemberService.save(consumerMember);
...@@ -172,9 +172,9 @@ public class RechargeServiceImpl extends ServiceImpl<RechargeMapper, Recharge> i ...@@ -172,9 +172,9 @@ public class RechargeServiceImpl extends ServiceImpl<RechargeMapper, Recharge> i
extracted(recharge); extracted(recharge);
} else { } else {
ConsumerWallet consumerWallet = consumerWalletService.getOne(new LambdaQueryWrapper<ConsumerWallet>().eq(ConsumerWallet::getConsumerId, recharge.getConsumerId())); ConsumerWallet consumerWallet = consumerWalletService.getOne(new LambdaQueryWrapper<ConsumerWallet>().eq(ConsumerWallet::getConsumerId, recharge.getConsumerId()));
if (one.getMemberType().equals(MemberTypeEnum.RECHARGE.getIndex())) { if (one.getIsRecharge().equals(YesNoEnum.yes.getIndex())) {
consumerWalletService.editConsumerWallet(consumerWallet, recharge, one); consumerWalletService.editConsumerWallet(consumerWallet, recharge, one);
} else if (one.getMemberType().equals(MemberTypeEnum.RIGHTS.getIndex())) { } else if (one.getIsRights().equals(YesNoEnum.yes.getIndex())) {
if (ObjectUtil.isEmpty(consumerWallet)) { if (ObjectUtil.isEmpty(consumerWallet)) {
extracted(recharge); extracted(recharge);
} else { } else {
......
...@@ -313,7 +313,6 @@ public class SConsumerCenterServiceImpl extends ServiceImpl<SConsumerMapper, SCo ...@@ -313,7 +313,6 @@ public class SConsumerCenterServiceImpl extends ServiceImpl<SConsumerMapper, SCo
if (uid != null){ if (uid != null){
//添加绑定关系 //添加绑定关系
SharingActivities sharingActivities = new SharingActivities(); SharingActivities sharingActivities = new SharingActivities();
sharingActivities.setActivityType(request.getActivityType());
sharingActivities.setUid(uid); sharingActivities.setUid(uid);
sharingActivities.setNewUid(id); sharingActivities.setNewUid(id);
sharingActivities.setCreateTime(DateUtils.getNowDate()); sharingActivities.setCreateTime(DateUtils.getNowDate());
......
...@@ -208,11 +208,11 @@ public class SConsumerServiceImpl extends ServiceImpl<SConsumerMapper, SConsumer ...@@ -208,11 +208,11 @@ public class SConsumerServiceImpl extends ServiceImpl<SConsumerMapper, SConsumer
List<ConsumerMonthlyCardVo> consumerMonthlyCardVo = consumerMonthlyCardService.selectByConsumerId(); List<ConsumerMonthlyCardVo> consumerMonthlyCardVo = consumerMonthlyCardService.selectByConsumerId();
if (ObjectUtil.isNotEmpty(consumerMember)) { if (ObjectUtil.isNotEmpty(consumerMember)) {
vo.setConsumerMember(consumerMember); vo.setConsumerMember(consumerMember);
MemberConfig memberConfig = memberConfigService.getById(consumerMember.getMemberConfigId()); MemberConfig memberConfig = memberConfigService.getOne(new LambdaQueryWrapper<MemberConfig>().eq(MemberConfig::getMembershipLevel, consumerMember.getMembershipLevel()));
MemberConfigVo memberConfigVo = new MemberConfigVo(); MemberConfigVo memberConfigVo = new MemberConfigVo();
BeanUtils.copyProperties(memberConfig, memberConfigVo); BeanUtils.copyProperties(memberConfig, memberConfigVo);
MemberConfig nexMemberConfig = memberConfigService.getOne(new LambdaQueryWrapper<MemberConfig>() MemberConfig nexMemberConfig = memberConfigService.getOne(new LambdaQueryWrapper<MemberConfig>()
.eq(MemberConfig::getMemberType, memberConfig.getMemberType()) // .eq(MemberConfig::getMemberType, memberConfig.getMemberType())
.eq(MemberConfig::getMembershipLevel, memberConfig.getMembershipLevel() + 1) .eq(MemberConfig::getMembershipLevel, memberConfig.getMembershipLevel() + 1)
); );
if (ObjectUtil.isNotEmpty(nexMemberConfig)) { if (ObjectUtil.isNotEmpty(nexMemberConfig)) {
......
...@@ -1175,7 +1175,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme ...@@ -1175,7 +1175,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
} }
membershipProgress = consumerMember.getMembershipProgress().add(sOrder.getBalance()) membershipProgress = consumerMember.getMembershipProgress().add(sOrder.getBalance())
.add(coupon.getCouponPayPrice()); .add(coupon.getCouponPayPrice());
if (consumerMember.getMemberType().equals(MemberTypeEnum.RIGHTS.getIndex())) { if (consumerMember.getIsRights().equals(YesNoEnum.yes.getIndex())) {
integral = integral.add(sOrder.getPayPrice()); integral = integral.add(sOrder.getPayPrice());
membershipProgress = membershipProgress.add(sOrder.getPayPrice()); membershipProgress = membershipProgress.add(sOrder.getPayPrice());
} }
...@@ -1184,7 +1184,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme ...@@ -1184,7 +1184,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
integral = consumerWallet.getRemainingIntegral().add(sOrder.getBalance()); integral = consumerWallet.getRemainingIntegral().add(sOrder.getBalance());
} }
membershipProgress = consumerMember.getMembershipProgress().add(sOrder.getBalance()); membershipProgress = consumerMember.getMembershipProgress().add(sOrder.getBalance());
if (consumerMember.getMemberType().equals(MemberTypeEnum.RIGHTS.getIndex())) { if (consumerMember.getIsRights().equals(YesNoEnum.yes.getIndex())) {
integral = integral.add(sOrder.getPayPrice()); integral = integral.add(sOrder.getPayPrice());
membershipProgress = membershipProgress.add(sOrder.getPayPrice()); membershipProgress = membershipProgress.add(sOrder.getPayPrice());
} }
...@@ -1206,41 +1206,42 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme ...@@ -1206,41 +1206,42 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
memberProgressLog.setCurrentProgress(consumerMember.getMembershipProgress()); memberProgressLog.setCurrentProgress(consumerMember.getMembershipProgress());
//查询当前会员类型和下一级的会员配置 //查询当前会员类型和下一级的会员配置
MemberConfig one = memberConfigService.getOne(new LambdaQueryWrapper<MemberConfig>() MemberConfig one = memberConfigService.getOne(new LambdaQueryWrapper<MemberConfig>()
.eq(MemberConfig::getMemberType, consumerMember.getMemberType()) // .eq(MemberConfig::getMemberType, consumerMember.getMemberType())
.eq(MemberConfig::getMembershipLevel, consumerMember.getMembershipLevel() + 1L)); .eq(MemberConfig::getMembershipLevel, consumerMember.getMembershipLevel() + 1L));
if (consumerMember.getMemberType().equals(MemberTypeEnum.NORMAL.getIndex())) { if (consumerMember.getMemberType().equals(MemberTypeEnum.NORMAL.getIndex())) {
if (consumerMember.getIsRecharge().equals(YesNoEnum.yes.getIndex())) { if (consumerMember.getIsRecharge().equals(YesNoEnum.yes.getIndex())) {
consumerMember.setMemberType(MemberTypeEnum.RECHARGE.getIndex()); // consumerMember.setMemberType(MemberTypeEnum.RECHARGE.getIndex());
if (ObjectUtil.isNotEmpty(one) && membershipProgress.compareTo(BigDecimal.valueOf(one.getLimitRequirements())) >= 0) { if (ObjectUtil.isNotEmpty(one) && membershipProgress.compareTo(BigDecimal.valueOf(one.getLimitRequirements())) >= 0) {
consumerMember.setMembershipLevel(consumerMember.getMembershipLevel() + 1L); consumerMember.setMembershipLevel(consumerMember.getMembershipLevel() + 1L);
consumerMember.setMemberConfigId(one.getId()); // consumerMember.setMemberConfigId(one.getId());
} }
} else if (consumerMember.getIsRights().equals(YesNoEnum.yes.getIndex())) { } else if (consumerMember.getIsRights().equals(YesNoEnum.yes.getIndex())) {
consumerMember.setMemberType(MemberTypeEnum.RIGHTS.getIndex()); // consumerMember.setMemberType(MemberTypeEnum.RIGHTS.getIndex());
if (ObjectUtil.isNotEmpty(one) && membershipProgress.compareTo(BigDecimal.valueOf(one.getLimitRequirements())) >= 0) { if (ObjectUtil.isNotEmpty(one) && membershipProgress.compareTo(BigDecimal.valueOf(one.getLimitRequirements())) >= 0) {
consumerMember.setMembershipLevel(consumerMember.getMembershipLevel() + 1L); consumerMember.setMembershipLevel(consumerMember.getMembershipLevel() + 1L);
consumerMember.setMemberConfigId(one.getId()); // consumerMember.setMemberConfigId(one.getId());
}
}
} else {
if (ObjectUtil.isNotEmpty(one)) {
//判断是否升级
if (ObjectUtil.isNotEmpty(one) && membershipProgress.compareTo(BigDecimal.valueOf(one.getLimitRequirements())) >= 0) {
consumerMember.setMembershipLevel(consumerMember.getMembershipLevel() + 1L);
consumerMember.setMemberConfigId(one.getId());
}
} }
} }
// if (ObjectUtil.isNotEmpty(one)) {
// //判断是否升级
// if (ObjectUtil.isNotEmpty(one) && membershipProgress.compareTo(BigDecimal.valueOf(one.getLimitRequirements())) >= 0) {
// consumerMember.setMembershipLevel(consumerMember.getMembershipLevel() + 1L);
// consumerMember.setMemberConfigId(one.getId());
// }
//
// }
memberProgressLog.setVariableProgress(membershipProgress.subtract(consumerMember.getMembershipProgress())); memberProgressLog.setVariableProgress(membershipProgress.subtract(consumerMember.getMembershipProgress()));
consumerMember.setMembershipProgress(membershipProgress); consumerMember.setMembershipProgress(membershipProgress);
memberProgressLog.setOperationType(YesNoEnum.yes.getIndex()); memberProgressLog.setOperationType(YesNoEnum.yes.getIndex());
memberProgressLog.setOperationTime(new Date()); memberProgressLog.setOperationTime(new Date());
memberProgressLog.setCreateTime(new Date()); memberProgressLog.setCreateTime(new Date());
memberProgressLog.setExpirationTime(DateUtils.addYears(new Date(), if (consumerMember.getIsRecharge().equals(YesNoEnum.yes.getIndex())) {
Math.toIntExact(memberConfigService.getOne(new LambdaQueryWrapper<MemberConfig>(). memberProgressLog.setExpirationTime(DateUtils.addYears(new Date(), 100));
eq(MemberConfig::getId, consumerMember.getMemberConfigId())).getValidityPeriod()))); }
if (!consumerMember.getMemberType().equals(MemberTypeEnum.NORMAL.getIndex())) { if (consumerMember.getIsRights().equals(YesNoEnum.yes.getIndex())) {
memberProgressLog.setExpirationTime(DateUtils.addYears(new Date(), 1));
}
if (consumerMember.getIsRights().equals(YesNoEnum.yes.getIndex()) || consumerMember.getIsRecharge().equals(YesNoEnum.yes.getIndex())) {
memberProgressLogService.save(memberProgressLog); memberProgressLogService.save(memberProgressLog);
consumerMemberService.updateConsumerMember(consumerMember); consumerMemberService.updateConsumerMember(consumerMember);
} }
...@@ -1333,7 +1334,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme ...@@ -1333,7 +1334,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
} }
membershipProgress = consumerMember.getMembershipProgress() membershipProgress = consumerMember.getMembershipProgress()
.subtract(sOrder.getBalance()).subtract(coupon.getCouponPayPrice()); .subtract(sOrder.getBalance()).subtract(coupon.getCouponPayPrice());
if (consumerMember.getMemberType().equals(MemberTypeEnum.RIGHTS.getIndex())) { if (consumerMember.getIsRights().equals(YesNoEnum.yes.getIndex())) {
integral = integral.subtract(sOrder.getPayPrice()); integral = integral.subtract(sOrder.getPayPrice());
membershipProgress = membershipProgress.subtract(sOrder.getPayPrice()); membershipProgress = membershipProgress.subtract(sOrder.getPayPrice());
} }
...@@ -1342,7 +1343,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme ...@@ -1342,7 +1343,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
integral = consumerWallet.getRemainingIntegral().subtract(sOrder.getBalance()); integral = consumerWallet.getRemainingIntegral().subtract(sOrder.getBalance());
} }
membershipProgress = consumerMember.getMembershipProgress().subtract(sOrder.getBalance()); membershipProgress = consumerMember.getMembershipProgress().subtract(sOrder.getBalance());
if (consumerMember.getMemberType().equals(MemberTypeEnum.RIGHTS.getIndex())) { if (consumerMember.getIsRights().equals(YesNoEnum.yes.getIndex())) {
integral = integral.subtract(sOrder.getPayPrice()); integral = integral.subtract(sOrder.getPayPrice());
membershipProgress = membershipProgress.subtract(sOrder.getPayPrice()); membershipProgress = membershipProgress.subtract(sOrder.getPayPrice());
} }
...@@ -1365,53 +1366,59 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme ...@@ -1365,53 +1366,59 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
memberProgressLog.setCurrentProgress(consumerMember.getMembershipProgress()); memberProgressLog.setCurrentProgress(consumerMember.getMembershipProgress());
//查询当前会员类型和当前等级的会员配置 //查询当前会员类型和当前等级的会员配置
MemberConfig one = memberConfigService.getOne(new LambdaQueryWrapper<MemberConfig>() MemberConfig one = memberConfigService.getOne(new LambdaQueryWrapper<MemberConfig>()
.eq(MemberConfig::getMemberType, consumerMember.getMemberType()) // .eq(MemberConfig::getMemberType, consumerMember.getMemberType())
.eq(MemberConfig::getMembershipLevel, consumerMember.getMembershipLevel())); .eq(MemberConfig::getMembershipLevel, consumerMember.getMembershipLevel()));
if (consumerMember.getMemberType().equals(MemberTypeEnum.NORMAL.getIndex())) { // if (consumerMember.getMemberType().equals(MemberTypeEnum.NORMAL.getIndex())) {
if (consumerMember.getIsRecharge().equals(YesNoEnum.yes.getIndex())) { // if (consumerMember.getIsRecharge().equals(YesNoEnum.yes.getIndex())) {
if (consumerMember.getMembershipLevel().compareTo(0L) > 0) { // if (consumerMember.getMembershipLevel().compareTo(0L) > 0) {
consumerMember.setMemberType(MemberTypeEnum.RECHARGE.getIndex()); // consumerMember.setMemberType(MemberTypeEnum.RECHARGE.getIndex());
if (ObjectUtil.isNotEmpty(one) && membershipProgress.compareTo(BigDecimal.valueOf(one.getLimitRequirements())) < 0) { // if (ObjectUtil.isNotEmpty(one) && membershipProgress.compareTo(BigDecimal.valueOf(one.getLimitRequirements())) < 0) {
consumerMember.setMembershipLevel(consumerMember.getMembershipLevel() - 1L); // consumerMember.setMembershipLevel(consumerMember.getMembershipLevel() - 1L);
consumerMember.setMemberConfigId(memberConfigService.getOne(new LambdaQueryWrapper<MemberConfig>() // consumerMember.setMemberConfigId(memberConfigService.getOne(new LambdaQueryWrapper<MemberConfig>()
.eq(MemberConfig::getMemberType, consumerMember.getMemberType()) // .eq(MemberConfig::getMemberType, consumerMember.getMemberType())
.eq(MemberConfig::getMembershipLevel, consumerMember.getMembershipLevel())).getId()); // .eq(MemberConfig::getMembershipLevel, consumerMember.getMembershipLevel())).getId());
} // }
} // }
} else if (consumerMember.getIsRights().equals(YesNoEnum.yes.getIndex())) { // } else if (consumerMember.getIsRights().equals(YesNoEnum.yes.getIndex())) {
if (consumerMember.getMembershipLevel().compareTo(0L) > 0) { // if (consumerMember.getMembershipLevel().compareTo(0L) > 0) {
consumerMember.setMemberType(MemberTypeEnum.RIGHTS.getIndex()); // consumerMember.setMemberType(MemberTypeEnum.RIGHTS.getIndex());
if (ObjectUtil.isNotEmpty(one) && membershipProgress.compareTo(BigDecimal.valueOf(one.getLimitRequirements())) < 0) { // if (ObjectUtil.isNotEmpty(one) && membershipProgress.compareTo(BigDecimal.valueOf(one.getLimitRequirements())) < 0) {
consumerMember.setMembershipLevel(consumerMember.getMembershipLevel() - 1L); // consumerMember.setMembershipLevel(consumerMember.getMembershipLevel() - 1L);
consumerMember.setMemberConfigId(memberConfigService.getOne(new LambdaQueryWrapper<MemberConfig>() // consumerMember.setMemberConfigId(memberConfigService.getOne(new LambdaQueryWrapper<MemberConfig>()
.eq(MemberConfig::getMemberType, consumerMember.getMemberType()) // .eq(MemberConfig::getMemberType, consumerMember.getMemberType())
.eq(MemberConfig::getMembershipLevel, consumerMember.getMembershipLevel())).getId()); // .eq(MemberConfig::getMembershipLevel, consumerMember.getMembershipLevel())).getId());
} // }
} // }
} // }
} else { // } else {
if (consumerMember.getMembershipLevel().compareTo(0L) > 0) { if (consumerMember.getMembershipLevel().compareTo(0L) > 0) {
if (ObjectUtil.isNotEmpty(one)) { if (ObjectUtil.isNotEmpty(one)) {
//判断是否升级 //判断是否升级
if (ObjectUtil.isNotEmpty(one) && membershipProgress.compareTo(BigDecimal.valueOf(one.getLimitRequirements())) < 0) { if (ObjectUtil.isNotEmpty(one) && membershipProgress.compareTo(BigDecimal.valueOf(one.getLimitRequirements())) < 0) {
consumerMember.setMembershipLevel(consumerMember.getMembershipLevel() - 1L); consumerMember.setMembershipLevel(consumerMember.getMembershipLevel() - 1L);
consumerMember.setMemberConfigId(memberConfigService.getOne(new LambdaQueryWrapper<MemberConfig>() // consumerMember.setMemberConfigId(memberConfigService.getOne(new LambdaQueryWrapper<MemberConfig>()
.eq(MemberConfig::getMemberType, consumerMember.getMemberType()) // .eq(MemberConfig::getMemberType, consumerMember.getMemberType())
.eq(MemberConfig::getMembershipLevel, consumerMember.getMembershipLevel())).getId()); // .eq(MemberConfig::getMembershipLevel, consumerMember.getMembershipLevel())).getId());
}
} }
} }
} }
memberProgressLog.setVariableProgress(consumerMember.getMembershipProgress().subtract(membershipProgress)); memberProgressLog.setVariableProgress(consumerMember.getMembershipProgress().subtract(membershipProgress));
consumerMember.setMembershipProgress(membershipProgress); consumerMember.setMembershipProgress(membershipProgress);
memberProgressLog.setOperationType(YesNoEnum.no.getIndex()); memberProgressLog.setOperationType(YesNoEnum.no.getIndex());
memberProgressLog.setOperationTime(new Date()); memberProgressLog.setOperationTime(new Date());
memberProgressLog.setCreateTime(new Date()); memberProgressLog.setCreateTime(new Date());
Long validityPeriod = memberConfigService.getById(consumerMember.getMemberConfigId()).getValidityPeriod(); if (consumerMember.getIsRecharge().equals(YesNoEnum.yes.getIndex())) {
memberProgressLog.setExpirationTime(DateUtils.addYears(new Date(), validityPeriod.intValue())); memberProgressLog.setExpirationTime(DateUtils.addYears(new Date(), 100));
if (!consumerMember.getMemberType().equals(MemberTypeEnum.NORMAL.getIndex()) && membershipProgress.compareTo(BigDecimal.ZERO) >= 0) { }
if (consumerMember.getIsRights().equals(YesNoEnum.yes.getIndex())) {
memberProgressLog.setExpirationTime(DateUtils.addYears(new Date(), 1));
}
if ((consumerMember.getIsRecharge().equals(YesNoEnum.yes.getIndex()) || consumerMember.getIsRights().equals(YesNoEnum.yes.getIndex()))
&& membershipProgress.compareTo(BigDecimal.ZERO) >= 0) {
memberProgressLogService.save(memberProgressLog); memberProgressLogService.save(memberProgressLog);
consumerMemberService.updateConsumerMember(consumerMember); consumerMemberService.updateConsumerMember(consumerMember);
} }
...@@ -2479,6 +2486,22 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme ...@@ -2479,6 +2486,22 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
// priceResponse.setAvailableBalance(consumerWallet.getBalance()); // priceResponse.setAvailableBalance(consumerWallet.getBalance());
// priceResponse.setAvailableDuration(consumerWallet.getRemainingDuration()); // priceResponse.setAvailableDuration(consumerWallet.getRemainingDuration());
// } // }
consumerWallet = consumerWalletService.getOne(new LambdaQueryWrapper<ConsumerWallet>().eq(ConsumerWallet::getConsumerId, user.getId()));
consumerMember = consumerMemberService.getOne(new LambdaQueryWrapper<ConsumerMember>().eq(ConsumerMember::getConsumerId, user.getId()));
if (ObjectUtil.isNotEmpty(consumerMember)) {
queryWrapper.eq(Activity::getIsOpen, YesNoEnum.yes.getIndex());
if (consumerMember.getIsRights().equals(YesNoEnum.yes.getIndex())) {
queryWrapper.eq(Activity::getMemberType, MemberTypeEnum.RIGHTS.getIndex());
} else if (consumerMember.getIsRecharge().equals(YesNoEnum.yes.getIndex()) && consumerMember.getIsRights().equals(YesNoEnum.no.getIndex())) {
queryWrapper.eq(Activity::getMemberType, MemberTypeEnum.RECHARGE.getIndex());
} else {
queryWrapper.eq(Activity::getMemberType, MemberTypeEnum.NORMAL.getIndex());
}
}
if (ObjectUtil.isNotEmpty(consumerWallet)) {
priceResponse.setAvailableBalance(consumerWallet.getBalance());
priceResponse.setAvailableDuration(consumerWallet.getRemainingDuration());
}
} }
SRoom room = roomService.getById(request.getRoomId()); SRoom room = roomService.getById(request.getRoomId());
BigDecimal totalPrice = computeTotalPrice(room.getPrice(), request.getPreStartDate(), request.getPreEndDate()); BigDecimal totalPrice = computeTotalPrice(room.getPrice(), request.getPreStartDate(), request.getPreEndDate());
...@@ -2642,6 +2665,41 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme ...@@ -2642,6 +2665,41 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
// priceResponse.setTotalFeeNow(priceResponse.getPayFee()); // priceResponse.setTotalFeeNow(priceResponse.getPayFee());
// priceResponse.setMemberDiscount(priceResponse.getTotalFee().subtract(priceResponse.getPayFee())); // priceResponse.setMemberDiscount(priceResponse.getTotalFee().subtract(priceResponse.getPayFee()));
// } // }
if (ObjectUtil.isNotEmpty(consumerMember)) {
MemberConfig memberConfig = memberConfigService.getOne(new LambdaQueryWrapper<MemberConfig>().eq(MemberConfig::getMembershipLevel, consumerMember.getMembershipLevel()));
BigDecimal payFee = priceResponse.getPayFee();
BigDecimal divide = priceResponse.getPayFee().multiply(memberConfig.getDiscountRatio()).divide(new BigDecimal(100), 2, RoundingMode.HALF_UP);
if (payFee.compareTo(divide) == 0) {
priceResponse.setDiscount(BigDecimal.ZERO);
}
//总金额乘以折扣比例除以100
priceResponse.setPayFee(divide);
priceResponse.setDiscountFee(priceResponse.getTotalFee().subtract(priceResponse.getPayFee()));
priceResponse.setTotalFeeNow(divide);
priceResponse.setMemberDiscount(payFee.subtract(divide));
// priceResponse.setCouponFee(priceResponse.getDiscountFee());
if (ObjectUtil.isNotEmpty(priceResponse.getDiscountFee()) && priceResponse.getTotalFee().compareTo(new BigDecimal(0.00)) > 0) {
priceResponse.setDiscountRatio(priceResponse.getDiscountFee().divide(priceResponse.getTotalFee(), 2, RoundingMode.HALF_UP).multiply(new BigDecimal(100)));
} else {
priceResponse.setDiscountRatio(new BigDecimal(0));
}
}
if (ObjectUtil.isNotEmpty(consumerWallet)) {
if (consumerWallet.getBalance().compareTo(priceResponse.getPayFee()) >= 0) {
priceResponse.setBalance(priceResponse.getPayFee());
priceResponse.setRemainingBalance(consumerWallet.getBalance().subtract(priceResponse.getPayFee()));
totalFee = new BigDecimal(0);
} else if (consumerWallet.getBalance().compareTo(priceResponse.getPayFee()) < 0) {
priceResponse.setBalance(consumerWallet.getBalance());
totalFee = priceResponse.getPayFee().subtract(consumerWallet.getBalance());
}
priceResponse.setPayFee(totalFee);
}
if (ObjectUtil.isEmpty(consumerWallet) && ObjectUtil.isEmpty(consumerMember)) {
priceResponse.setTotalFeeNow(priceResponse.getPayFee());
priceResponse.setMemberDiscount(priceResponse.getTotalFee().subtract(priceResponse.getPayFee()));
}
} else { } else {
priceResponse.setDiscount(BigDecimal.ZERO); priceResponse.setDiscount(BigDecimal.ZERO);
...@@ -2660,7 +2718,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme ...@@ -2660,7 +2718,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
private BigDecimal getBigDecimal(ConsumerWallet consumerWallet, Activity activity, BigDecimal timeLong, private BigDecimal getBigDecimal(ConsumerWallet consumerWallet, Activity activity, BigDecimal timeLong,
ComputedOrderPriceResponse priceResponse, BigDecimal totalFee, SRoom room, OrderComputedPriceRequest request, ConsumerMember consumerMember) { ComputedOrderPriceResponse priceResponse, BigDecimal totalFee, SRoom room, OrderComputedPriceRequest request, ConsumerMember consumerMember) {
if (ObjectUtil.isNotEmpty(consumerWallet) && ObjectUtil.isNotEmpty(consumerMember)) { if (ObjectUtil.isNotEmpty(consumerWallet) && ObjectUtil.isNotEmpty(consumerMember)) {
MemberConfig memberConfig = memberConfigService.getById(consumerMember.getMemberConfigId()); MemberConfig memberConfig = memberConfigService.getOne(new LambdaQueryWrapper<MemberConfig>().eq(MemberConfig::getMembershipLevel, consumerMember.getMembershipLevel()));
CronParser cronParser = new CronParser(CronDefinitionBuilder.instanceDefinitionFor(CronType.QUARTZ)); CronParser cronParser = new CronParser(CronDefinitionBuilder.instanceDefinitionFor(CronType.QUARTZ));
priceResponse.setDuration(BigDecimal.ZERO); priceResponse.setDuration(BigDecimal.ZERO);
priceResponse.setRemainingDuration(BigDecimal.ZERO); priceResponse.setRemainingDuration(BigDecimal.ZERO);
...@@ -2825,7 +2883,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme ...@@ -2825,7 +2883,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
private BigDecimal getBigDecimal(OrderComputedPriceRequest request, Activity activity, BigDecimal payPrice, SConsumer user, ConsumerMember consumerMember) { private BigDecimal getBigDecimal(OrderComputedPriceRequest request, Activity activity, BigDecimal payPrice, SConsumer user, ConsumerMember consumerMember) {
if (ObjectUtil.isNotEmpty(user)) { if (ObjectUtil.isNotEmpty(user)) {
MemberConfig memberConfig = memberConfigService.getById(consumerMember.getMemberConfigId()); MemberConfig memberConfig = memberConfigService.getOne(new LambdaQueryWrapper<MemberConfig>().eq(MemberConfig::getMembershipLevel, consumerMember.getMembershipLevel()));
if (ObjectUtil.isNotEmpty(activity)) { if (ObjectUtil.isNotEmpty(activity)) {
CronParser cronParser = new CronParser(CronDefinitionBuilder.instanceDefinitionFor(CronType.QUARTZ)); CronParser cronParser = new CronParser(CronDefinitionBuilder.instanceDefinitionFor(CronType.QUARTZ));
Cron cron = cronParser.parse(activity.getCronExpression()); Cron cron = cronParser.parse(activity.getCronExpression());
...@@ -2885,46 +2943,6 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme ...@@ -2885,46 +2943,6 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
return payPrice; return payPrice;
} }
private BigDecimal getBigDecimal(ConsumerMonthlyCard consumerMonthlyCard, BigDecimal timeLong,
ComputedOrderPriceResponse priceResponse, BigDecimal totalFee, SRoom room) {
if (consumerMonthlyCard.getFreeDuration().compareTo(timeLong) >= 0) {
priceResponse.setDuration(timeLong);
priceResponse.setRemainingDuration(consumerMonthlyCard.getFreeDuration().subtract(timeLong));
priceResponse.setDiscount(BigDecimal.ZERO);
totalFee = new BigDecimal(0);
priceResponse.setMemberDiscount(new BigDecimal(0.00));
priceResponse.setTotalFeeNow(priceResponse.getTotalFee());
priceResponse.setPayFee(BigDecimal.ZERO);
priceResponse.setMonthlyCardId(consumerMonthlyCard.getId());
} else if (consumerMonthlyCard.getFreeDuration().compareTo(timeLong) < 0) {
priceResponse.setDuration(consumerMonthlyCard.getFreeDuration());
priceResponse.setRemainingDuration(new BigDecimal(0));
BigDecimal remainingBalance = consumerMonthlyCard.getFreeDuration().multiply(room.getPrice());
remainingBalance = totalFee.subtract(remainingBalance);
priceResponse.setTotalFeeNow(remainingBalance);
priceResponse.setMemberDiscount(totalFee.subtract(remainingBalance));
totalFee = remainingBalance;
priceResponse.setPayFee(remainingBalance);
priceResponse.setMonthlyCardId(consumerMonthlyCard.getId());
}
return totalFee;
}
private BigDecimal getBigDecimal(List<ConsumerSecondaryCard> consumerSecondaryCardList,
ComputedOrderPriceResponse priceResponse, SPack byId, BigDecimal payPrice) {
//获取集合中次数最少的次卡,次数不低于0
ConsumerSecondaryCard consumerSecondaryCard = consumerSecondaryCardList.stream().min(Comparator.comparing(ConsumerSecondaryCard::getNumber)).get();
if (consumerSecondaryCard.getPackId().equals(byId.getId())) {
priceResponse.setDiscount(BigDecimal.ZERO);
priceResponse.setMemberDiscount(BigDecimal.ZERO);
priceResponse.setTotalFeeNow(payPrice);
priceResponse.setPayFee(BigDecimal.ZERO);
priceResponse.setSecondaryCardId(consumerSecondaryCard.getId());
payPrice = BigDecimal.ZERO;
}
return payPrice;
}
private BigDecimal computeTotalPrice(Long packId, BigDecimal totalPrice) { private BigDecimal computeTotalPrice(Long packId, BigDecimal totalPrice) {
SPack pack = packService.getById(packId); SPack pack = packService.getById(packId);
if (Objects.isNull(pack)) { if (Objects.isNull(pack)) {
......
package share.system.service.impl; package share.system.service.impl;
import java.time.YearMonth;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
...@@ -10,6 +11,7 @@ import org.springframework.data.redis.core.RedisTemplate; ...@@ -10,6 +11,7 @@ import org.springframework.data.redis.core.RedisTemplate;
import share.common.core.domain.AjaxResult; import share.common.core.domain.AjaxResult;
import share.common.core.redis.RedisUtil; import share.common.core.redis.RedisUtil;
import share.common.enums.ReceiptRdeisEnum; import share.common.enums.ReceiptRdeisEnum;
import share.common.enums.YesNoEnum;
import share.common.utils.DateUtils; import share.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -107,28 +109,4 @@ public class SharingActivitiesServiceImpl extends ServiceImpl<SharingActivitiesM ...@@ -107,28 +109,4 @@ public class SharingActivitiesServiceImpl extends ServiceImpl<SharingActivitiesM
return sharingActivitiesMapper.deleteSharingActivitiesById(id); return sharingActivitiesMapper.deleteSharingActivitiesById(id);
} }
/**
* 新增分享活动绑定关系
* @param sharingActivities
* @return
*/
@Override
public AjaxResult addSharingActivities(SharingActivities sharingActivities) {
sharingActivities.setCreateTime(DateUtils.getNowDate());
Long newUid = sharingActivities.getNewUid();
SharingActivities sharingActivities1 = sharingActivitiesMapper.selectOne(new LambdaQueryWrapper<SharingActivities>().eq(SharingActivities::getNewUid, newUid));
if (ObjectUtil.isNotEmpty(sharingActivities1)){
return AjaxResult.success("此用户以绑定其他权益会员");
}
Boolean B = redisTemplate.hasKey(ReceiptRdeisEnum.EQUITY_MEMBERS_TIME + sharingActivities.getUid().toString());
if (!B){
return AjaxResult.success("分享用户权益过期");
}
sharingActivitiesMapper.insertSharingActivities(sharingActivities);
Boolean aBoolean = redisTemplate.hasKey(ReceiptRdeisEnum.EQUITY_MEMBERS_TIME + sharingActivities.getUid().toString());
if (!aBoolean){
sharingActivitiesMapper.deleteSharingActivitiesById(sharingActivities.getId());
}
return AjaxResult.success();
}
} }
...@@ -11,8 +11,8 @@ ...@@ -11,8 +11,8 @@
<result property="phone" column="phone"/> <result property="phone" column="phone"/>
<result property="avatar" column="avatar"/> <result property="avatar" column="avatar"/>
<result property="membershipLevel" column="membership_level"/> <result property="membershipLevel" column="membership_level"/>
<result property="memberType" column="member_type"/> <!-- <result property="memberType" column="member_type"/>-->
<result property="memberConfigId" column="member_config_id"/> <!-- <result property="memberConfigId" column="member_config_id"/>-->
<result property="expirationDate" column="expiration_date"/> <result property="expirationDate" column="expiration_date"/>
<result property="membershipProgress" column="membership_progress"/> <result property="membershipProgress" column="membership_progress"/>
<result property="isRecharge" column="is_recharge"/> <result property="isRecharge" column="is_recharge"/>
...@@ -29,8 +29,6 @@ ...@@ -29,8 +29,6 @@
select id, select id,
consumer_id, consumer_id,
membership_level, membership_level,
member_type,
member_config_id,
expiration_date, expiration_date,
membership_progress, membership_progress,
is_recharge, is_recharge,
...@@ -51,8 +49,6 @@ ...@@ -51,8 +49,6 @@
c.phone, c.phone,
c.avatar, c.avatar,
m. membership_level, m. membership_level,
m.member_type,
m.member_config_id,
m.expiration_date, m.expiration_date,
m.membership_progress, m.membership_progress,
m.is_recharge, m.is_recharge,
...@@ -71,8 +67,6 @@ ...@@ -71,8 +67,6 @@
</if> </if>
<if test="consumerId != null ">and m.consumer_id = #{consumerId}</if> <if test="consumerId != null ">and m.consumer_id = #{consumerId}</if>
<if test="membershipLevel != null ">and m.membership_level = #{membershipLevel}</if> <if test="membershipLevel != null ">and m.membership_level = #{membershipLevel}</if>
<if test="memberType != null ">and m.member_type = #{memberType}</if>
<if test="memberConfigId != null ">and m.member_config_id = #{memberConfigId}</if>
<if test="expirationDate != null ">and m.expiration_date = #{expirationDate}</if> <if test="expirationDate != null ">and m.expiration_date = #{expirationDate}</if>
<if test="membershipProgress != null ">and m.membership_progress = #{membershipProgress}</if> <if test="membershipProgress != null ">and m.membership_progress = #{membershipProgress}</if>
</where> </where>
...@@ -89,8 +83,6 @@ ...@@ -89,8 +83,6 @@
c.phone, c.phone,
c.avatar, c.avatar,
m.membership_level, m.membership_level,
m.member_type,
m.member_config_id,
m.expiration_date, m.expiration_date,
m.membership_progress, m.membership_progress,
m.is_recharge, m.is_recharge,
...@@ -112,8 +104,6 @@ ...@@ -112,8 +104,6 @@
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
<if test="consumerId != null">consumer_id,</if> <if test="consumerId != null">consumer_id,</if>
<if test="membershipLevel != null">membership_level,</if> <if test="membershipLevel != null">membership_level,</if>
<if test="memberType != null">member_type,</if>
<if test="memberConfigId != null">member_config_id,</if>
<if test="expirationDate != null">expiration_date,</if> <if test="expirationDate != null">expiration_date,</if>
<if test="membershipProgress != null">membership_progress,</if> <if test="membershipProgress != null">membership_progress,</if>
<if test="isRecharge != null">is_recharge,</if> <if test="isRecharge != null">is_recharge,</if>
...@@ -128,8 +118,6 @@ ...@@ -128,8 +118,6 @@
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="consumerId != null">#{consumerId},</if> <if test="consumerId != null">#{consumerId},</if>
<if test="membershipLevel != null">#{membershipLevel},</if> <if test="membershipLevel != null">#{membershipLevel},</if>
<if test="memberType != null">#{memberType},</if>
<if test="memberConfigId != null">#{memberConfigId},</if>
<if test="expirationDate != null">#{expirationDate},</if> <if test="expirationDate != null">#{expirationDate},</if>
<if test="membershipProgress != null">#{membershipProgress},</if> <if test="membershipProgress != null">#{membershipProgress},</if>
<if test="isRecharge != null">#{isRecharge},</if> <if test="isRecharge != null">#{isRecharge},</if>
...@@ -148,8 +136,6 @@ ...@@ -148,8 +136,6 @@
<trim prefix="SET" suffixOverrides=","> <trim prefix="SET" suffixOverrides=",">
<if test="consumerId != null">consumer_id = #{consumerId},</if> <if test="consumerId != null">consumer_id = #{consumerId},</if>
<if test="membershipLevel != null">membership_level = #{membershipLevel},</if> <if test="membershipLevel != null">membership_level = #{membershipLevel},</if>
<if test="memberType != null">member_type = #{memberType},</if>
<if test="memberConfigId != null">member_config_id = #{memberConfigId},</if>
<if test="expirationDate != null">expiration_date = #{expirationDate},</if> <if test="expirationDate != null">expiration_date = #{expirationDate},</if>
<if test="membershipProgress != null">membership_progress = #{membershipProgress},</if> <if test="membershipProgress != null">membership_progress = #{membershipProgress},</if>
<if test="isRecharge != null">is_recharge = #{isRecharge},</if> <if test="isRecharge != null">is_recharge = #{isRecharge},</if>
......
...@@ -7,12 +7,12 @@ ...@@ -7,12 +7,12 @@
<resultMap type="MemberConfig" id="MemberConfigResult"> <resultMap type="MemberConfig" id="MemberConfigResult">
<result property="id" column="id"/> <result property="id" column="id"/>
<result property="membershipLevel" column="membership_level"/> <result property="membershipLevel" column="membership_level"/>
<result property="memberType" column="member_type"/> <!-- <result property="memberType" column="member_type"/>-->
<result property="levelName" column="level_name"/> <result property="levelName" column="level_name"/>
<result property="limitRequirements" column="limit_requirements"/> <result property="limitRequirements" column="limit_requirements"/>
<result property="discountRatio" column="discount_ratio"/> <result property="discountRatio" column="discount_ratio"/>
<result property="validityPeriod" column="validity_period"/> <!-- <result property="validityPeriod" column="validity_period"/>-->
<result property="membershipProgress" column="membership_progress"/> <!-- <result property="membershipProgress" column="membership_progress"/>-->
<result property="isDelete" column="is_delete"/> <result property="isDelete" column="is_delete"/>
<result property="createBy" column="create_by"/> <result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/> <result property="createTime" column="create_time"/>
...@@ -24,12 +24,9 @@ ...@@ -24,12 +24,9 @@
<sql id="selectMemberConfigVo"> <sql id="selectMemberConfigVo">
select id, select id,
membership_level, membership_level,
member_type,
level_name, level_name,
limit_requirements, limit_requirements,
discount_ratio, discount_ratio,
validity_period,
membership_progress,
is_delete, is_delete,
create_by, create_by,
create_time, create_time,
...@@ -43,12 +40,10 @@ ...@@ -43,12 +40,10 @@
<include refid="selectMemberConfigVo"/> <include refid="selectMemberConfigVo"/>
<where> <where>
<if test="membershipLevel != null ">and membership_level = #{membershipLevel}</if> <if test="membershipLevel != null ">and membership_level = #{membershipLevel}</if>
<if test="memberType != null ">and member_type = #{memberType}</if>
<if test="levelName != null and levelName != ''">and level_name like concat('%', #{levelName}, '%')</if> <if test="levelName != null and levelName != ''">and level_name like concat('%', #{levelName}, '%')</if>
<if test="limitRequirements != null ">and limit_requirements = #{limitRequirements}</if> <if test="limitRequirements != null ">and limit_requirements = #{limitRequirements}</if>
<if test="discountRatio != null ">and discount_ratio = #{discountRatio}</if> <if test="discountRatio != null ">and discount_ratio = #{discountRatio}</if>
<if test="validityPeriod != null ">and validity_period = #{validityPeriod}</if> >
<if test="membershipProgress != null ">and membership_progress = #{membershipProgress}</if>
<if test="isDelete != null ">and is_delete = #{isDelete}</if> <if test="isDelete != null ">and is_delete = #{isDelete}</if>
</where> </where>
</select> </select>
...@@ -62,12 +57,10 @@ ...@@ -62,12 +57,10 @@
insert into s_member_config insert into s_member_config
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
<if test="membershipLevel != null">membership_level,</if> <if test="membershipLevel != null">membership_level,</if>
<if test="memberType != null">member_type,</if>
<if test="levelName != null">level_name,</if> <if test="levelName != null">level_name,</if>
<if test="limitRequirements != null">limit_requirements,</if> <if test="limitRequirements != null">limit_requirements,</if>
<if test="discountRatio != null">discount_ratio,</if> <if test="discountRatio != null">discount_ratio,</if>
<if test="validityPeriod != null">validity_period,</if>
<if test="membershipProgress != null">membership_progress,</if>
<if test="isDelete != null">is_delete,</if> <if test="isDelete != null">is_delete,</if>
<if test="createBy != null">create_by,</if> <if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if> <if test="createTime != null">create_time,</if>
...@@ -77,12 +70,10 @@ ...@@ -77,12 +70,10 @@
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="membershipLevel != null">#{membershipLevel},</if> <if test="membershipLevel != null">#{membershipLevel},</if>
<if test="memberType != null">#{memberType},</if>
<if test="levelName != null">#{levelName},</if> <if test="levelName != null">#{levelName},</if>
<if test="limitRequirements != null">#{limitRequirements},</if> <if test="limitRequirements != null">#{limitRequirements},</if>
<if test="discountRatio != null">#{discountRatio},</if> <if test="discountRatio != null">#{discountRatio},</if>
<if test="validityPeriod != null">#{validityPeriod},</if>
<if test="membershipProgress != null">#{membershipProgress},</if>
<if test="isDelete != null">#{isDelete},</if> <if test="isDelete != null">#{isDelete},</if>
<if test="createBy != null">#{createBy},</if> <if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if> <if test="createTime != null">#{createTime},</if>
...@@ -96,12 +87,10 @@ ...@@ -96,12 +87,10 @@
update s_member_config update s_member_config
<trim prefix="SET" suffixOverrides=","> <trim prefix="SET" suffixOverrides=",">
<if test="membershipLevel != null">membership_level = #{membershipLevel},</if> <if test="membershipLevel != null">membership_level = #{membershipLevel},</if>
<if test="memberType != null">member_type = #{memberType},</if>
<if test="levelName != null">level_name = #{levelName},</if> <if test="levelName != null">level_name = #{levelName},</if>
<if test="limitRequirements != null">limit_requirements = #{limitRequirements},</if> <if test="limitRequirements != null">limit_requirements = #{limitRequirements},</if>
<if test="discountRatio != null">discount_ratio = #{discountRatio},</if> <if test="discountRatio != null">discount_ratio = #{discountRatio},</if>
<if test="validityPeriod != null">validity_period = #{validityPeriod},</if>
<if test="membershipProgress != null">membership_progress = #{membershipProgress},</if>
<if test="isDelete != null">is_delete = #{isDelete},</if> <if test="isDelete != null">is_delete = #{isDelete},</if>
<if test="createBy != null">create_by = #{createBy},</if> <if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if> <if test="createTime != null">create_time = #{createTime},</if>
......
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