Commit 56e83aee by 吕明尚

Merge branch 'refs/heads/dev' into test

parents eac9c43a 2d91f978
......@@ -8,6 +8,7 @@ import org.springframework.web.bind.annotation.RestController;
import share.common.core.controller.BaseController;
import share.common.core.domain.AjaxResult;
import share.common.core.page.TableDataInfo;
import share.common.enums.YesNoEnum;
import share.system.domain.Activity;
import share.system.domain.vo.ActivityDto;
import share.system.domain.vo.ActivityVo;
......@@ -41,6 +42,7 @@ public class ActivityController extends BaseController {
@GetMapping("/query")
public AjaxResult query(ActivityDto dto) {
dto.setIsOpen(Long.valueOf(YesNoEnum.yes.getIndex()));
Map<Date, List<ActivityVo>> map = activityService.queryList(dto);
return success(map);
}
......
......@@ -25,6 +25,7 @@ import share.common.constant.MqttConstants;
import share.common.core.redis.RedisUtil;
import share.common.enums.*;
import share.common.exception.base.BaseException;
import share.common.utils.DateUtils;
import share.system.domain.*;
import share.system.domain.vo.MqttxVo;
import share.system.service.*;
......@@ -432,6 +433,9 @@ public class RedisTask {
dvo.setRefreshNum(dvo.getRefreshNum() + 1);
// 将失败的消息放到redis最后重新发送
redisUtil.lPush(key2, dvo);
//次数超过3次,删除
} else if (dvo != null && dvo.getRefreshNum() >= 3) {
redisUtil.getRightPop(key2, 10L);
}
// 获取当前需要发送的消息
Object data = redisUtil.getIndex(key2, -1);
......@@ -472,6 +476,9 @@ public class RedisTask {
});
}
/**
* 自动发送权益会员过期短信
*/
public void AutoEquityMembersSms() {
Set<String> keys = redisTemplate.keys(ReceiptRdeisEnum.EQUITY_MEMBERS_TIME + "*");
if (keys.size() == 0) {
......@@ -483,11 +490,12 @@ public class RedisTask {
Date expirationTime = jsonObject.getDate("expirationTime");
Long consumerId = jsonObject.getLong("consumerId");
//判断当前的日期是否在第3天和第2天中
long expire = (expirationTime.getTime() - new Date().getTime()) / 1000 / 60 / 60;
long expire = (expirationTime.getTime() - new Date().getTime()) / 1000 / 60;
if (THREE_DAY < expire && expire < FOUR_DAY) {
SConsumer sConsumer = sConsumerService.getById(consumerId);
logger.debug("手机号为:{}的用户年度权益会员将在3天后失效", sConsumer.getPhone());
smsService.sendOneSms(sConsumer.getPhone(), "年度权益会员将在3天后失效,请及时续约保障权益会员的权益");
redisUtil.delete(key);
}
});
}
......@@ -504,22 +512,34 @@ public class RedisTask {
Date expirationTime = jsonObject.getDate("expirationTime");
Long consumerId = jsonObject.getLong("consumerId");
if (expirationTime.getTime() < new Date().getTime()) {
ConsumerWallet consumerWallet = consumerWalletService.getOne(new LambdaQueryWrapper<ConsumerWallet>().eq(ConsumerWallet::getConsumerId, consumerId));
ConsumerMember consumerMember = consumerMemberService.getOne(new LambdaQueryWrapper<ConsumerMember>().eq(ConsumerMember::getConsumerId, consumerId));
if (ObjectUtil.isNotEmpty(consumerWallet)) {
consumerMember.setMemberType(MemberTypeEnum.RECHARGE.getIndex());
} else {
consumerMember.setMemberType(MemberTypeEnum.NORMAL.getIndex());
consumerMember.setIsRights(YesNoEnum.no.getIndex());
if (ObjectUtil.isNotEmpty(consumerMember)) {
if (consumerMember.getIsRecharge().equals(YesNoEnum.yes.getIndex())) {
consumerMember.setMemberType(MemberTypeEnum.RECHARGE.getIndex());
} else {
consumerMember.setMemberType(MemberTypeEnum.NORMAL.getIndex());
}
MemberConfig memberConfigServiceOne = memberConfigService.getOne(new LambdaQueryWrapper<MemberConfig>()
.eq(MemberConfig::getMemberType, consumerMember.getMemberType())
.eq(MemberConfig::getMembershipLevel, consumerMember.getMembershipLevel())
);
consumerMember.setMemberConfigId(memberConfigServiceOne.getId());
consumerMember.setExpirationDate(DateUtils.addYears(new Date(), memberConfigServiceOne.getValidityPeriod().intValue()));
consumerMemberService.updateConsumerMember(consumerMember);
}
consumerMemberService.updateConsumerMember(consumerMember);
redisUtil.delete(key);
}
});
}
/**
* 会员等级滚动降级
*/
public void AutoProgressLog() {
//查询1年之前的数据
List<MemberProgressLog> list = memberProgressLogService.list(new LambdaQueryWrapper<MemberProgressLog>()
.gt(MemberProgressLog::getExpirationTime, new Date())
.lt(MemberProgressLog::getExpirationTime, new Date())
);
if (CollectionUtil.isEmpty(list)) {
return;
......@@ -531,32 +551,45 @@ public class RedisTask {
Map<Long, List<MemberProgressLog>> collect = list.stream().collect(Collectors.groupingBy(MemberProgressLog::getConsumerId));
consumerIds.stream().forEach(item -> {
List<MemberProgressLog> memberProgressLogs = collect.get(item);
if (memberProgressLogs.size() > 1) {
if (memberProgressLogs.size() > 0) {
//查询会员
ConsumerMember consumerMember = consumerMemberService.getOne(new LambdaQueryWrapper<ConsumerMember>().eq(ConsumerMember::getConsumerId, item));
//查询会员配置
MemberConfig memberConfig = memberConfigService.getById(consumerMember.getMemberConfigId());
final BigDecimal[] sum = {BigDecimal.ZERO};
//计算扣除进度
memberProgressLogs.stream().forEach(log -> {
if (log.getOperationType().equals(YesNoEnum.yes.getIndex())) {
sum[0] = sum[0].subtract(log.getVariableProgress());
} else if (log.getOperationType().equals(YesNoEnum.no.getIndex())) {
sum[0] = sum[0].add(log.getVariableProgress());
} else if (log.getOperationType().equals(YesNoEnum.no.getIndex())) {
sum[0] = sum[0].subtract(log.getVariableProgress());
}
});
ConsumerMember consumerMember = consumerMemberService.getOne(new LambdaQueryWrapper<ConsumerMember>().eq(ConsumerMember::getConsumerId, item));
MemberConfig memberConfig = memberConfigService.getById(consumerMember.getMemberConfigId());
if (consumerMember.getMembershipProgress().compareTo(sum[0]) >= 0) {
if (consumerMember.getMembershipProgress().compareTo(sum[0]) < 0) {
consumerMember.setMembershipProgress(BigDecimal.ZERO);
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]) >= 0) {
//会员进度减去扣除进度
BigDecimal subtract = consumerMember.getMembershipProgress().subtract(sum[0]);
consumerMember.setMembershipProgress(subtract);
if (subtract.compareTo(BigDecimal.valueOf(memberConfig.getLimitRequirements())) < 0) {
consumerMember.setMembershipLevel(memberConfig.getMembershipLevel() - 1);
MemberConfig memberConfigServiceOne = memberConfigService.getOne(new LambdaQueryWrapper<MemberConfig>()
.eq(MemberConfig::getMemberType, consumerMember.getMemberType())
.eq(MemberConfig::getMembershipLevel, consumerMember.getMembershipLevel())
);
consumerMember.setMemberConfigId(memberConfigServiceOne.getId());
//等级降一级
if (consumerMember.getMembershipLevel() > 0L) {
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());
}
}
} else {
consumerMember.setMembershipProgress(BigDecimal.ZERO);
consumerMember.setMembershipLevel(0L);
consumerMember.setMemberType(MemberTypeEnum.NORMAL.getIndex());
}
consumerMemberService.updateConsumerMember(consumerMember);
}
......
......@@ -3,8 +3,6 @@ package share.system.domain;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import share.common.annotation.Excel;
import share.common.core.domain.BaseEntity;
......@@ -66,6 +64,16 @@ public class ConsumerMember extends BaseEntity {
private BigDecimal membershipProgress;
/**
* 是否为充值
*/
private Integer isRecharge;
/**
* 是否为权益
*/
private Integer isRights;
/**
* 是否删除
*/
//逻辑删除注解(0 未删除 1 已删除)
......@@ -73,23 +81,4 @@ public class ConsumerMember extends BaseEntity {
@TableField(select = false)
private Long isDelete;
@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("consumerId", getConsumerId())
.append("membershipLevel", getMembershipLevel())
.append("memberType", getMemberType())
.append("memberConfigId", getMemberConfigId())
.append("expirationDate", getExpirationDate())
.append("membershipProgress", getMembershipProgress())
.append("isDelete", getIsDelete())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.append("remark", getRemark())
.toString();
}
}
......@@ -3,8 +3,6 @@ package share.system.domain;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import share.common.annotation.Excel;
import share.common.core.domain.BaseEntity;
......@@ -53,6 +51,18 @@ public class Recharge extends BaseEntity {
private BigDecimal giveAmount;
/**
* 充值赠送时长
*/
@Excel(name = "充值赠送时长")
private BigDecimal giveDuration;
/**
* 充值赠送积分
*/
@Excel(name = "充值赠送积分")
private BigDecimal giveIntegral;
/**
* 充值赠送方式;1-不送,2-送金额,3-送优惠券,4-送金额及优惠券
*/
@Excel(name = "充值赠送方式;1-不送,2-送金额,3-送优惠券,4-送金额及优惠券")
......@@ -122,31 +132,4 @@ public class Recharge extends BaseEntity {
@Excel(name = "支付时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date payTime;
@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("rechargeNo", getRechargeNo())
.append("rechargeAmount", getRechargeAmount())
.append("payType", getPayType())
.append("giveAmount", getGiveAmount())
.append("giveType", getGiveType())
.append("status", getStatus())
.append("consumerCouponIds", getConsumerCouponIds())
.append("rechargeConfId", getRechargeConfId())
.append("consumerId", getConsumerId())
.append("phone", getPhone())
.append("rechargeDate", getRechargeDate())
.append("isDelete", getIsDelete())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.append("remark", getRemark())
.append("outTradeNo", getOutTradeNo())
.append("terminalTrace", getTerminalTrace())
.append("payTime", getPayTime())
.toString();
}
}
......@@ -3,6 +3,8 @@ package share.system.domain.vo;
import lombok.Data;
import share.system.domain.MemberConfig;
import java.math.BigDecimal;
@Data
public class MemberConfigVo extends MemberConfig {
//下一级的额度要求
......@@ -11,4 +13,6 @@ public class MemberConfigVo extends MemberConfig {
private Long nextMembershipLevel;
//下一级的会员名称
private String nextMembershipName;
//下一周多少积分清零
private BigDecimal nextWeekClearIntegral;
}
......@@ -15,7 +15,6 @@ import org.springframework.integration.core.MessageProducer;
import org.springframework.integration.mqtt.core.DefaultMqttPahoClientFactory;
import org.springframework.integration.mqtt.core.MqttPahoClientFactory;
import org.springframework.integration.mqtt.event.MqttConnectionFailedEvent;
import org.springframework.integration.mqtt.event.MqttMessageDeliveredEvent;
import org.springframework.integration.mqtt.event.MqttMessageSentEvent;
import org.springframework.integration.mqtt.event.MqttSubscribedEvent;
import org.springframework.integration.mqtt.inbound.MqttPahoMessageDrivenChannelAdapter;
......@@ -23,7 +22,6 @@ import org.springframework.integration.mqtt.support.DefaultPahoMessageConverter;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.MessageHandler;
import javax.annotation.Resource;
import java.util.Date;
......@@ -154,7 +152,7 @@ public class MqttConfig {
//接收字节数组类型有效荷载
defaultPahoMessageConverter.setPayloadAsBytes(true);
adapter.setConverter(defaultPahoMessageConverter);
adapter.setQos(2);
adapter.setQos(0);
adapter.setOutputChannel(mqttInputChannel());
return adapter;
}
......@@ -188,7 +186,7 @@ public class MqttConfig {
@EventListener(MqttMessageSentEvent.class)
public void mqttMessageSentEvent(MqttMessageSentEvent event) {
log.info("mqttMessageSentEvent发送信息: date={}, info={}", new Date(), event.toString());
log.debug("mqttMessageSentEvent发送信息: date={}, info={}", new Date(), event.toString());
}
// @EventListener(MqttMessageDeliveredEvent.class)
......@@ -198,7 +196,7 @@ public class MqttConfig {
@EventListener(MqttSubscribedEvent.class)
public void mqttSubscribedEvent(MqttSubscribedEvent event) {
log.info("mqttSubscribedEvent订阅成功信息: date={}, info={}", new Date(), event.toString());
log.debug("mqttSubscribedEvent订阅成功信息: date={}, info={}", new Date(), event.toString());
}
......
......@@ -36,7 +36,7 @@ public class MqttMessageHandler implements MessageHandler {
String topic = message.getHeaders().get(MqttHeaders.RECEIVED_TOPIC).toString();
boolean exist = topic.startsWith("ydlink");
if (!exist) {
log.info("当前topic:{}未注册!不做处理!",topic);
log.debug("当前topic:{}未注册!不做处理!", topic);
return;
}
//MqttTopicHandler topicHandler = SpringUtil.getBean(mqttTopicEnum.getTopicHandlerBeanName(), TopicHandler.class);
......
......@@ -27,7 +27,7 @@ public class MqttTopicHandler {
*/
public void handler(Message<?> message) {
String topic = message.getHeaders().get(MqttHeaders.RECEIVED_TOPIC).toString();
log.info("topic:{}-->message received!", topic);
log.debug("topic:{}-->message received!", topic);
String payload = new String((byte[]) message.getPayload());
Assert.notNull(payload, "接收到的消息为空!");
dispose(payload, topic);
......@@ -41,7 +41,7 @@ public class MqttTopicHandler {
if (!ObjectUtil.isNull(payload)){
try {
mqttxService.mqttReport(topic, payload);
log.info("来自topic:{}的消息处理完毕!", topic);
log.debug("来自topic:{}的消息处理完毕!", topic);
} catch (Exception e) {
log.error("来自topic:{}的消息处理异常!原因:{}", topic, e);
}
......
......@@ -74,7 +74,7 @@ public class MultiMqttMessageHandler extends AbstractMessageHandler implements L
//负载均衡
Random random = new Random();
MyMqttPahoMessageHandler messageHandler = (MyMqttPahoMessageHandler) mqttHandlerMap.get(random.nextInt(handlerCount));
log.info("开始处理信息:{}", message.toString());
log.debug("开始处理信息:{}", message.toString());
messageHandler.handleMessageInternal(message);
}
......
......@@ -178,7 +178,7 @@ public class ConsumerWalletServiceImpl extends ServiceImpl<ConsumerWalletMapper,
BigDecimal divide = new BigDecimal(0);
RechargeConf rechargeConf = rechargeConfService.selectRechargeConfById(recharge.getRechargeConfId());
MemberConfig memberConfig = memberConfigService.getOne(new LambdaQueryWrapper<MemberConfig>()
.eq(MemberConfig::getMembershipLevel, 1L)
.eq(MemberConfig::getMembershipLevel, one.getMembershipLevel())
.eq(MemberConfig::getMemberType, MemberTypeEnum.RECHARGE.getIndex()));
one.setExpirationDate(DateUtils.addYears(new Date(), memberConfig.getValidityPeriod().intValue()));
logger.debug("修改会员用户");
......@@ -197,18 +197,6 @@ public class ConsumerWalletServiceImpl extends ServiceImpl<ConsumerWalletMapper,
}
int i = updateConsumerWallet(consumerWallet);
//查询当前会员类型和下一级的会员配置
MemberConfig memberConfigServiceOne = memberConfigService.getOne(new LambdaQueryWrapper<MemberConfig>()
.eq(MemberConfig::getMemberType, one.getMemberType())
.eq(MemberConfig::getMembershipLevel, one.getMembershipLevel() + 1L));
if (ObjectUtil.isNotEmpty(memberConfigServiceOne)) {
//判断是否升级
if (one.getMembershipProgress().compareTo(BigDecimal.valueOf(memberConfigServiceOne.getLimitRequirements())) >= 0) {
one.setMembershipLevel(one.getMembershipLevel() + 1L);
one.setMemberConfigId(one.getId());
}
}
if (consumerWallet.getBalance().compareTo(new BigDecimal(0)) > 0) {
BalanceLog balanceLog = new BalanceLog();
balanceLog.setConsumerId(consumerWallet.getConsumerId());
......@@ -252,7 +240,18 @@ public class ConsumerWalletServiceImpl extends ServiceImpl<ConsumerWalletMapper,
memberProgressLogService.save(memberProgressLog);
one.setMembershipProgress(one.getMembershipProgress().add(divide));
}
//查询当前会员类型和下一级的会员配置
MemberConfig memberConfigServiceOne = memberConfigService.getOne(new LambdaQueryWrapper<MemberConfig>()
.eq(MemberConfig::getMemberType, one.getMemberType())
.eq(MemberConfig::getMembershipLevel, one.getMembershipLevel() + 1L));
if (ObjectUtil.isNotEmpty(memberConfigServiceOne)) {
//判断是否升级
if (one.getMembershipProgress().compareTo(BigDecimal.valueOf(memberConfigServiceOne.getLimitRequirements())) >= 0) {
one.setMembershipLevel(one.getMembershipLevel() + 1L);
one.setMemberConfigId(one.getId());
}
}
consumerMemberService.updateConsumerMember(one);
return i == 1;
}
......
......@@ -133,6 +133,18 @@ public class EquityMembersOrderServiceImpl extends ServiceImpl<EquityMembersOrde
throw new BaseException("请绑定手机号");
}
}
ConsumerMember consumerMember = consumerMemberService.getOne(new LambdaQueryWrapper<ConsumerMember>()
.eq(ConsumerMember::getConsumerId, user.getId())
.eq(ConsumerMember::getMemberType, MemberTypeEnum.RIGHTS.getIndex())
);
if (ObjectUtil.isNotEmpty(consumerMember)) {
Date expirationDate = consumerMember.getExpirationDate();
//减去当前时间
int i = DateUtils.differentDaysByMillisecond(new Date(), expirationDate);
if (i > 365) {
throw new BaseException("目前只能购买两年权益会员");
}
}
EquityMembersOrder equityMembersOrder = generatEquityMembersOrder(request, user);
save(equityMembersOrder);
EquityMembersResultResponse response = orderPayService.saobeiEquityMembersOrderPayment(equityMembersOrder);
......@@ -161,6 +173,7 @@ public class EquityMembersOrderServiceImpl extends ServiceImpl<EquityMembersOrde
equityMembersOrderConfig.getValidityPeriod().intValue()));
newConsumerMember.setMembershipProgress(BigDecimal.ZERO);
newConsumerMember.setCreateTime(new Date());
newConsumerMember.setIsRights(YesNoEnum.yes.getIndex());
consumerMemberService.save(newConsumerMember);
logger.debug("新增权益会员");
Map<String, String> map = new HashMap<>();
......@@ -178,6 +191,7 @@ public class EquityMembersOrderServiceImpl extends ServiceImpl<EquityMembersOrde
consumerMemberService.updateConsumerMember(consumerMember);
logger.debug("权益会员原来的基础上增加有效期");
} else {
consumerMember.setIsRights(YesNoEnum.yes.getIndex());
//修改会员类型为权益会员
consumerMember.setMemberType(MemberTypeEnum.RIGHTS.getIndex());
consumerMember.setMemberConfigId(memberConfigService.getOne(new LambdaQueryWrapper<MemberConfig>()
......
......@@ -155,15 +155,16 @@ public class RechargeServiceImpl extends ServiceImpl<RechargeMapper, Recharge> i
//新增会员
ConsumerMember consumerMember = new ConsumerMember();
consumerMember.setConsumerId(recharge.getConsumerId());
consumerMember.setMembershipLevel(1L);
consumerMember.setMembershipLevel(0L);
consumerMember.setMemberType(MemberTypeEnum.RECHARGE.getIndex());
MemberConfig memberConfig = memberConfigService.getOne(new LambdaQueryWrapper<MemberConfig>()
.eq(MemberConfig::getMembershipLevel, 1L)
.eq(MemberConfig::getMembershipLevel, 0L)
.eq(MemberConfig::getMemberType, MemberTypeEnum.RECHARGE.getIndex()));
consumerMember.setMemberConfigId(memberConfig.getId());
consumerMember.setMembershipProgress(BigDecimal.ZERO);
consumerMember.setExpirationDate(DateUtils.addYears(new Date(), memberConfig.getValidityPeriod().intValue()));
consumerMember.setCreateTime(new Date());
consumerMember.setIsRecharge(YesNoEnum.yes.getIndex());
consumerMemberService.save(consumerMember);
logger.debug("新增充值会员");
extracted(recharge);
......@@ -234,6 +235,8 @@ public class RechargeServiceImpl extends ServiceImpl<RechargeMapper, Recharge> i
}
consumerWallet.setCreateTime(new Date());
logger.debug("新增会员钱包");
one.setIsRecharge(YesNoEnum.yes.getIndex());
consumerMemberService.updateConsumerMember(one);
consumerWalletService.addConsumerWallet(consumerWallet);
}
......@@ -245,7 +248,22 @@ public class RechargeServiceImpl extends ServiceImpl<RechargeMapper, Recharge> i
if (ObjectUtil.isEmpty(byId)) {
throw new BaseException("充值模板异常");
}
recharge.setRechargeAmount(byId.getRechargeAmount());
if (byId.getGiveType().contains(GiveTypeEnum.AMOUNT.getIndex())) {
recharge.setRechargeAmount(byId.getRechargeAmount());
} else {
recharge.setRechargeAmount(BigDecimal.ZERO);
}
if (byId.getGiveType().contains(GiveTypeEnum.DURATION.getIndex())) {
recharge.setGiveDuration(byId.getGiveDuration());
} else {
recharge.setGiveDuration(BigDecimal.ZERO);
}
if (byId.getGiveType().contains(GiveTypeEnum.INTEGRAL.getIndex())) {
BigDecimal Integral = recharge.getRechargeAmount().multiply(byId.getGiveRatio()).divide(new BigDecimal(100), 2, RoundingMode.HALF_UP);
recharge.setGiveIntegral(Integral);
} else {
recharge.setGiveIntegral(BigDecimal.ZERO);
}
recharge.setGiveAmount(byId.getGiveAmount());
recharge.setGiveType(byId.getGiveType());
recharge.setStatus(YesNoEnum.no.getIndex());
......
package share.system.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.ObjectUtil;
......@@ -15,9 +16,11 @@ import share.common.constant.SmsConstants;
import share.common.enums.ConsumerCouponUseStatusEnum;
import share.common.enums.PositionEnum;
import share.common.enums.RoleTypeEnum;
import share.common.enums.YesNoEnum;
import share.common.exception.base.BaseException;
import share.common.utils.BaseUtil;
import share.common.utils.DateUtil;
import share.common.utils.DateUtils;
import share.system.domain.*;
import share.system.domain.vo.FrontTokenComponent;
import share.system.domain.vo.MemberConfigVo;
......@@ -27,6 +30,8 @@ import share.system.mapper.SStoreConsumerMapper;
import share.system.request.RegisterThirdSConsumerRequest;
import share.system.service.*;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
/**
......@@ -53,6 +58,8 @@ public class SConsumerServiceImpl extends ServiceImpl<SConsumerMapper, SConsumer
private ConsumerMemberService consumerMemberService;
@Autowired
private MemberConfigService memberConfigService;
@Autowired
private MemberProgressLogService memberProgressLogService;
/**
* 查询会员用户
......@@ -206,6 +213,22 @@ public class SConsumerServiceImpl extends ServiceImpl<SConsumerMapper, SConsumer
memberConfigVo.setNextMembershipLevel(nexMemberConfig.getMembershipLevel());
memberConfigVo.setNextMembershipName(nexMemberConfig.getLevelName());
}
List<MemberProgressLog> memberProgressLogs = memberProgressLogService.list(new LambdaQueryWrapper<MemberProgressLog>()
.lt(MemberProgressLog::getExpirationTime, DateUtils.addDays(new Date(), 7))
.eq(MemberProgressLog::getConsumerId, currentUser.getId())
);
final BigDecimal[] sum = {BigDecimal.ZERO};
if (CollectionUtil.isNotEmpty(memberProgressLogs)) {
//计算扣除进度
memberProgressLogs.stream().forEach(log -> {
if (log.getOperationType().equals(YesNoEnum.yes.getIndex())) {
sum[0] = sum[0].add(log.getVariableProgress());
} else if (log.getOperationType().equals(YesNoEnum.no.getIndex())) {
sum[0] = sum[0].subtract(log.getVariableProgress());
}
});
}
memberConfigVo.setNextWeekClearIntegral(sum[0]);
vo.setMemberConfig(memberConfigVo);
}
if (ObjectUtil.isNotEmpty(consumerWallet)) {
......
......@@ -1137,13 +1137,23 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
memberProgressLog.setConsumerId(sOrder.getConsumerId());
memberProgressLog.setCurrentProgress(consumerMember.getMembershipProgress());
if (consumerMember.getMemberType().equals(MemberTypeEnum.NORMAL.getIndex())) {
MemberConfig memberConfig = memberConfigService.getById(consumerMember.getMemberConfigId());
if (ObjectUtil.isNotEmpty(memberConfig)) {
//判断是否升级
if (membershipProgress.compareTo(BigDecimal.valueOf(memberConfig.getLimitRequirements())) >= 0) {
if (consumerMember.getIsRecharge().equals(YesNoEnum.yes.getIndex())) {
consumerMember.setMemberType(MemberTypeEnum.RECHARGE.getIndex());
MemberConfig one = memberConfigService.getOne(new LambdaQueryWrapper<MemberConfig>()
.eq(MemberConfig::getMemberType, consumerMember.getMemberType())
.eq(MemberConfig::getMembershipLevel, consumerMember.getMembershipLevel() + 1L));
if (membershipProgress.compareTo(BigDecimal.valueOf(one.getLimitRequirements())) >= 0) {
consumerMember.setMembershipLevel(consumerMember.getMembershipLevel() + 1L);
consumerMember.setMemberConfigId(memberConfig.getId());
consumerMember.setMemberType(MemberTypeEnum.RECHARGE.getIndex());
consumerMember.setMemberConfigId(one.getId());
}
} else if (consumerMember.getIsRights().equals(YesNoEnum.yes.getIndex())) {
consumerMember.setMemberType(MemberTypeEnum.RIGHTS.getIndex());
MemberConfig one = memberConfigService.getOne(new LambdaQueryWrapper<MemberConfig>()
.eq(MemberConfig::getMemberType, consumerMember.getMemberType())
.eq(MemberConfig::getMembershipLevel, consumerMember.getMembershipLevel() + 1L));
if (membershipProgress.compareTo(BigDecimal.valueOf(one.getLimitRequirements())) >= 0) {
consumerMember.setMembershipLevel(consumerMember.getMembershipLevel() + 1L);
consumerMember.setMemberConfigId(one.getId());
}
}
} else {
......@@ -1159,18 +1169,18 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
}
}
}
memberProgressLog.setVariableProgress(membershipProgress.subtract(consumerMember.getMembershipProgress()));
consumerMember.setMembershipProgress(membershipProgress);
memberProgressLog.setOperationType(YesNoEnum.yes.getIndex());
memberProgressLog.setOperationTime(new Date());
memberProgressLog.setOperationType(YesNoEnum.yes.getIndex());
memberProgressLog.setOperationTime(new Date());
memberProgressLog.setCreateTime(new Date());
memberProgressLog.setExpirationTime(DateUtils.addYears(new Date(),
Math.toIntExact(memberConfigService.getOne(new LambdaQueryWrapper<MemberConfig>().
eq(MemberConfig::getId, consumerMember.getMemberConfigId())).getValidityPeriod())));
if (!consumerMember.getMemberType().equals(MemberTypeEnum.NORMAL.getIndex())) {
memberProgressLogService.save(memberProgressLog);
consumerMemberService.updateConsumerMember(consumerMember);
}
// }
}
}
......@@ -1337,9 +1347,9 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
order.setDuration(priceResponse.getDuration());
order.setDiscountRatio(priceResponse.getDiscountRatio());
if (priceResponse.getPayFee().compareTo(order.getPayPrice()) != 0
// || priceResponse.getDuration().compareTo(request.getDuration()) !=0
// || priceResponse.getBalance().compareTo(request.getBalance()) !=0
// || priceResponse.getDiscountRatio().compareTo(request.getDiscountRatio()) !=0
&& priceResponse.getDuration().compareTo(request.getDuration()) != 0
&& priceResponse.getBalance().compareTo(request.getBalance()) != 0
&& priceResponse.getDiscountRatio().compareTo(request.getDiscountRatio()) != 0
) {
throw new BaseException("订单金额异常!");
}
......@@ -1939,10 +1949,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
.eq(MemberConfig::getMembershipLevel, consumerMember.getMembershipLevel()));
if (ObjectUtil.isNotEmpty(memberConfigServiceOne)) {
consumerMember.setMemberConfigId(memberConfigServiceOne.getId());
} else {
consumerMember.setMemberType(MemberTypeEnum.NORMAL.getIndex());
}
}
}
memberProgressLog.setVariableProgress(sOrder.getBalance());
......@@ -2561,6 +2568,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
queryWrapper.eq(SOrder::getConsumerId, user.getId());
queryWrapper.in(SOrder::getStatus, OrderStatusEnum.getValidOrderStatus());
queryWrapper.eq(SOrder::getPayStatus, YesNoEnum.yes.getIndex());
queryWrapper.ge(SOrder::getDiscountRatio, new BigDecimal(50));
// queryWrapper.ne(SOrder::getPayPrice, new BigDecimal(0));
//预约结束时间大于等于今天的年月日
queryWrapper.ge(SOrder::getPreEndDate, DateUtils.parseDate(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, new Date())));
......@@ -2581,13 +2589,22 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
boolean match = executionTime.isMatch(ZonedDateTime.ofInstant(item.getPreStartDate().toInstant(), ZoneId.systemDefault()));
boolean match1 = executionTime.isMatch(ZonedDateTime.ofInstant(item.getPreEndDate().toInstant(), ZoneId.systemDefault()));
if (match && match1
// && (item.getPayPrice().compareTo(item.getTotalPrice().multiply(activity.getDiscountRatio()).divide(new BigDecimal(100)))) > 0
&& item.getDuration().compareTo(BigDecimal.ZERO) == 0
&& (item.getPayPrice().add(item.getBalance())).divide(item.getTotalPrice()).multiply(new BigDecimal(100)).compareTo(activity.getDiscountRatio()) == 0
) {
i.getAndIncrement();
}
});
if (i.get() == 0) {
payPrice = payPrice.multiply(activity.getDiscountRatio()).divide(new BigDecimal(100));
boolean match = executionTime.isMatch(ZonedDateTime.ofInstant(request.getPreStartDate().toInstant(), ZoneId.systemDefault()));
boolean match1 = executionTime.isMatch(ZonedDateTime.ofInstant(request.getPreEndDate().toInstant(), ZoneId.systemDefault()));
if (match && match1) {
payPrice = payPrice.multiply(activity.getDiscountRatio()).divide(new BigDecimal(100));
} else {
MemberConfig memberConfig = memberConfigService.getById(consumerMember.getMemberConfigId());
payPrice = payPrice.multiply(memberConfig.getDiscountRatio()).divide(new BigDecimal(100));
}
// payPrice = payPrice.multiply(activity.getDiscountRatio()).divide(new BigDecimal(100));
} else {
MemberConfig memberConfig = memberConfigService.getById(consumerMember.getMemberConfigId());
payPrice = payPrice.multiply(memberConfig.getDiscountRatio()).divide(new BigDecimal(100));
......
......@@ -45,7 +45,7 @@
<select id="selectActivityList" parameterType="Activity" resultMap="ActivityResult">
<include refid="selectActivityVo"/>
where is_open = 1 and is_delete = 0
where is_delete = 0
<if test="activityName != null and activityName != ''">and activity_name like concat('%', #{activityName},
'%')
</if>
......@@ -57,6 +57,7 @@
<if test="storeIds != null and storeIds != ''">and store_ids = #{storeIds}</if>
<if test="labelId != null ">and label_id = #{labelId}</if>
<if test="packId != null ">and pack_id = #{packId}</if>
<if test="isOpen != null or isOpen==0">and is_open = #{isOpen}</if>
<if test="cronExpression != null and cronExpression != ''">and cron_expression = #{cronExpression}</if>
</select>
......
......@@ -15,6 +15,8 @@
<result property="memberConfigId" column="member_config_id"/>
<result property="expirationDate" column="expiration_date"/>
<result property="membershipProgress" column="membership_progress"/>
<result property="isRecharge" column="is_recharge"/>
<result property="isRights" column="is_rights"/>
<result property="isDelete" column="is_delete"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
......@@ -31,6 +33,8 @@
member_config_id,
expiration_date,
membership_progress,
is_recharge,
is_rights,
is_delete,
create_by,
create_time,
......@@ -51,6 +55,8 @@
m.member_config_id,
m.expiration_date,
m.membership_progress,
m.is_recharge,
m.is_rights,
m.is_delete,
m.create_by,
m.create_time,
......@@ -87,6 +93,8 @@
m.member_config_id,
m.expiration_date,
m.membership_progress,
m.is_recharge,
m.is_rights,
m.is_delete,
m.create_by,
m.create_time,
......@@ -108,6 +116,8 @@
<if test="memberConfigId != null">member_config_id,</if>
<if test="expirationDate != null">expiration_date,</if>
<if test="membershipProgress != null">membership_progress,</if>
<if test="isRecharge != null">is_recharge,</if>
<if test="isRights != null">is_rights,</if>
<if test="isDelete != null">is_delete,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
......@@ -122,6 +132,8 @@
<if test="memberConfigId != null">#{memberConfigId},</if>
<if test="expirationDate != null">#{expirationDate},</if>
<if test="membershipProgress != null">#{membershipProgress},</if>
<if test="isRecharge != null">#{isRecharge},</if>
<if test="isRights != null">#{isRights},</if>
<if test="isDelete != null">#{isDelete},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
......@@ -140,6 +152,8 @@
<if test="memberConfigId != null">member_config_id = #{memberConfigId},</if>
<if test="expirationDate != null">expiration_date = #{expirationDate},</if>
<if test="membershipProgress != null">membership_progress = #{membershipProgress},</if>
<if test="isRecharge != null">is_recharge = #{isRecharge},</if>
<if test="isRights != null">is_rights = #{isRights},</if>
<if test="isDelete != null">is_delete = #{isDelete},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
......
......@@ -10,6 +10,8 @@
<result property="rechargeAmount" column="recharge_amount"/>
<result property="payType" column="pay_type"/>
<result property="giveAmount" column="give_amount"/>
<result property="giveDuration" column="give_duration"/>
<result property="giveIntegral" column="give_integral"/>
<result property="giveType" column="give_type"/>
<result property="status" column="status"/>
<result property="consumerCouponIds" column="consumer_coupon_ids"/>
......@@ -36,6 +38,8 @@
recharge_amount,
pay_type,
give_amount,
give_duration,
give_integral,
give_type,
status,
consumer_coupon_ids,
......@@ -61,6 +65,8 @@
r.recharge_amount,
r.pay_type,
r.give_amount,
r.give_duration,
r.give_integral,
r.give_type,
r. status,
r.consumer_coupon_ids,
......@@ -121,6 +127,8 @@
<if test="rechargeAmount != null">recharge_amount,</if>
<if test="payType != null">pay_type,</if>
<if test="giveAmount != null">give_amount,</if>
<if test="giveDuration != null">give_duration,</if>
<if test="giveIntegral != null">give_integral,</if>
<if test="giveType != null and giveType != ''">give_type,</if>
<if test="status != null">status,</if>
<if test="consumerCouponIds != null">consumer_coupon_ids,</if>
......@@ -143,6 +151,8 @@
<if test="rechargeAmount != null">#{rechargeAmount},</if>
<if test="payType != null">#{payType},</if>
<if test="giveAmount != null">#{giveAmount},</if>
<if test="giveDuration != null">#{giveDuration},</if>
<if test="giveIntegral != null">#{giveIntegral},</if>
<if test="giveType != null and giveType != ''">#{giveType},</if>
<if test="status != null">#{status},</if>
<if test="consumerCouponIds != null">#{consumerCouponIds},</if>
......@@ -169,6 +179,8 @@
<if test="rechargeAmount != null">recharge_amount = #{rechargeAmount},</if>
<if test="payType != null">pay_type = #{payType},</if>
<if test="giveAmount != null">give_amount = #{giveAmount},</if>
<if test="giveDuration != null">give_duration = #{giveDuration},</if>
<if test="giveIntegral != null">give_integral = #{giveIntegral},</if>
<if test="giveType != null and giveType != ''">give_type = #{giveType},</if>
<if test="status != null">status = #{status},</if>
<if test="consumerCouponIds != null">consumer_coupon_ids = #{consumerCouponIds},</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