|
@@ -127,7 +127,7 @@ public class PtCardServiceImpl implements IPtCardService {
|
|
|
*/
|
|
*/
|
|
|
@Override
|
|
@Override
|
|
|
public Boolean insertByBo(PtCardBo bo) {
|
|
public Boolean insertByBo(PtCardBo bo) {
|
|
|
- if(ObjUtil.isEmpty(bo.getLastPay())){
|
|
|
|
|
|
|
+ if (ObjUtil.isEmpty(bo.getLastPay())) {
|
|
|
bo.setLastPay(DateUtil.offsetDay(DateUtil.date(), -1));
|
|
bo.setLastPay(DateUtil.offsetDay(DateUtil.date(), -1));
|
|
|
}
|
|
}
|
|
|
bo.setLastMeal(0L);
|
|
bo.setLastMeal(0L);
|
|
@@ -154,10 +154,10 @@ public class PtCardServiceImpl implements IPtCardService {
|
|
|
public Boolean updateByBo(PtCardBo bo) {
|
|
public Boolean updateByBo(PtCardBo bo) {
|
|
|
PtCard update = MapstructUtils.convert(bo, PtCard.class);
|
|
PtCard update = MapstructUtils.convert(bo, PtCard.class);
|
|
|
validEntityBeforeSave(update);
|
|
validEntityBeforeSave(update);
|
|
|
- int count = baseMapper.updateById(update) ;
|
|
|
|
|
|
|
+ int count = baseMapper.updateById(update);
|
|
|
PtCardVo vo = baseMapper.selectVoById(bo.getCardId());
|
|
PtCardVo vo = baseMapper.selectVoById(bo.getCardId());
|
|
|
kafkaNormalProducer.sendKafkaMessage(KafkaTopicConstants.SYNC_DATA_TOPIC, EventTypeConstants.CARD, EventSenderEnum.BACKSTAGE.code(), vo);
|
|
kafkaNormalProducer.sendKafkaMessage(KafkaTopicConstants.SYNC_DATA_TOPIC, EventTypeConstants.CARD, EventSenderEnum.BACKSTAGE.code(), vo);
|
|
|
- return count>0;
|
|
|
|
|
|
|
+ return count > 0;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -177,9 +177,9 @@ public class PtCardServiceImpl implements IPtCardService {
|
|
|
@Override
|
|
@Override
|
|
|
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
|
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
|
|
if (isValid) {
|
|
if (isValid) {
|
|
|
- //TODO 做一些业务上的校验,判断是否需要校验
|
|
|
|
|
|
|
+ // TODO 做一些业务上的校验,判断是否需要校验
|
|
|
}
|
|
}
|
|
|
- //ids.forEach(id->{
|
|
|
|
|
|
|
+ // ids.forEach(id->{
|
|
|
// sendCloudConsume(baseMapper.selectVoById(id));
|
|
// sendCloudConsume(baseMapper.selectVoById(id));
|
|
|
//});
|
|
//});
|
|
|
return baseMapper.deleteByIds(ids) > 0;
|
|
return baseMapper.deleteByIds(ids) > 0;
|
|
@@ -198,11 +198,11 @@ public class PtCardServiceImpl implements IPtCardService {
|
|
|
public int resetLifespan(Long[] userIds, String lifespan) {
|
|
public int resetLifespan(Long[] userIds, String lifespan) {
|
|
|
for (Long userId : userIds) {
|
|
for (Long userId : userIds) {
|
|
|
baseMapper.update(null, new LambdaUpdateWrapper<PtCard>()
|
|
baseMapper.update(null, new LambdaUpdateWrapper<PtCard>()
|
|
|
- .set(PtCard::getLifespan, lifespan)
|
|
|
|
|
- .set(PtCard::getChangeTime, DateUtil.date())
|
|
|
|
|
- .eq(PtCard::getStatus, '1')
|
|
|
|
|
- .eq(PtCard::getUserId, userId));
|
|
|
|
|
- //sendCloudConsume(baseMapper.selectVoById(userId));
|
|
|
|
|
|
|
+ .set(PtCard::getLifespan, lifespan)
|
|
|
|
|
+ .set(PtCard::getChangeTime, DateUtil.date())
|
|
|
|
|
+ .eq(PtCard::getStatus, '1')
|
|
|
|
|
+ .eq(PtCard::getUserId, userId));
|
|
|
|
|
+ // sendCloudConsume(baseMapper.selectVoById(userId));
|
|
|
}
|
|
}
|
|
|
return userIds.length;
|
|
return userIds.length;
|
|
|
}
|
|
}
|
|
@@ -218,12 +218,13 @@ public class PtCardServiceImpl implements IPtCardService {
|
|
|
*/
|
|
*/
|
|
|
@Override
|
|
@Override
|
|
|
public int resetCardType(Long[] userIds, String cardType) {
|
|
public int resetCardType(Long[] userIds, String cardType) {
|
|
|
- Arrays.stream(userIds).forEach(userId -> {baseMapper.update(null, new LambdaUpdateWrapper<PtCard>()
|
|
|
|
|
- .set(PtCard::getCardType, cardType)
|
|
|
|
|
- .set(PtCard::getChangeTime, DateUtil.date())
|
|
|
|
|
- .eq(PtCard::getStatus, '1')
|
|
|
|
|
- .eq(PtCard::getUserId, userId));
|
|
|
|
|
- //sendCloudConsume(baseMapper.selectVoById(userId));
|
|
|
|
|
|
|
+ Arrays.stream(userIds).forEach(userId -> {
|
|
|
|
|
+ baseMapper.update(null, new LambdaUpdateWrapper<PtCard>()
|
|
|
|
|
+ .set(PtCard::getCardType, cardType)
|
|
|
|
|
+ .set(PtCard::getChangeTime, DateUtil.date())
|
|
|
|
|
+ .eq(PtCard::getStatus, '1')
|
|
|
|
|
+ .eq(PtCard::getUserId, userId));
|
|
|
|
|
+ // sendCloudConsume(baseMapper.selectVoById(userId));
|
|
|
});
|
|
});
|
|
|
return userIds.length;
|
|
return userIds.length;
|
|
|
}
|
|
}
|
|
@@ -246,7 +247,8 @@ public class PtCardServiceImpl implements IPtCardService {
|
|
|
if (listVo.isEmpty()) {
|
|
if (listVo.isEmpty()) {
|
|
|
list.add(CardOpenEnum.NO.message());
|
|
list.add(CardOpenEnum.NO.message());
|
|
|
} else {
|
|
} else {
|
|
|
- String cardInfo = listVo.stream().anyMatch(p -> p.getFactoryId() == 0) ? CardOpenEnum.VIRTUAL.message() : CardOpenEnum.ENTITY.message();
|
|
|
|
|
|
|
+ String cardInfo = listVo.stream().anyMatch(
|
|
|
|
|
+ p -> p.getFactoryId() == 0) ? CardOpenEnum.VIRTUAL.message() : CardOpenEnum.ENTITY.message();
|
|
|
list.add(cardInfo);
|
|
list.add(cardInfo);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -261,12 +263,12 @@ public class PtCardServiceImpl implements IPtCardService {
|
|
|
*/
|
|
*/
|
|
|
@Override
|
|
@Override
|
|
|
public boolean lockCard(Long cardId) {
|
|
public boolean lockCard(Long cardId) {
|
|
|
- //sendCloudConsume(baseMapper.selectVoById(cardId));
|
|
|
|
|
|
|
+ // sendCloudConsume(baseMapper.selectVoById(cardId));
|
|
|
return baseMapper.update(null, new LambdaUpdateWrapper<PtCard>()
|
|
return baseMapper.update(null, new LambdaUpdateWrapper<PtCard>()
|
|
|
- .set(PtCard::getStatus, '2')
|
|
|
|
|
- .set(PtCard::getChangeTime, DateUtil.date())
|
|
|
|
|
- .eq(PtCard::getStatus, '1')
|
|
|
|
|
- .eq(PtCard::getCardId, cardId)) > 0;
|
|
|
|
|
|
|
+ .set(PtCard::getStatus, '2')
|
|
|
|
|
+ .set(PtCard::getChangeTime, DateUtil.date())
|
|
|
|
|
+ .eq(PtCard::getStatus, '1')
|
|
|
|
|
+ .eq(PtCard::getCardId, cardId)) > 0;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -277,12 +279,12 @@ public class PtCardServiceImpl implements IPtCardService {
|
|
|
*/
|
|
*/
|
|
|
@Override
|
|
@Override
|
|
|
public boolean unlockCard(Long cardId) {
|
|
public boolean unlockCard(Long cardId) {
|
|
|
- //sendCloudConsume(baseMapper.selectVoById(cardId));
|
|
|
|
|
|
|
+ // sendCloudConsume(baseMapper.selectVoById(cardId));
|
|
|
return baseMapper.update(null, new LambdaUpdateWrapper<PtCard>()
|
|
return baseMapper.update(null, new LambdaUpdateWrapper<PtCard>()
|
|
|
- .set(PtCard::getStatus, '1')
|
|
|
|
|
- .set(PtCard::getChangeTime, DateUtil.date())
|
|
|
|
|
- .eq(PtCard::getStatus, '2')
|
|
|
|
|
- .eq(PtCard::getCardId, cardId)) > 0;
|
|
|
|
|
|
|
+ .set(PtCard::getStatus, '1')
|
|
|
|
|
+ .set(PtCard::getChangeTime, DateUtil.date())
|
|
|
|
|
+ .eq(PtCard::getStatus, '2')
|
|
|
|
|
+ .eq(PtCard::getCardId, cardId)) > 0;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -294,25 +296,26 @@ public class PtCardServiceImpl implements IPtCardService {
|
|
|
*/
|
|
*/
|
|
|
@Override
|
|
@Override
|
|
|
public BigDecimal computeCommission(PtBagBo bo) {
|
|
public BigDecimal computeCommission(PtBagBo bo) {
|
|
|
- //当前账户的卡类
|
|
|
|
|
|
|
+ // 当前账户的卡类
|
|
|
PtCardtypeVo cardTypeVo = cardTypeService.queryByCode(bo.getCardTypeId());
|
|
PtCardtypeVo cardTypeVo = cardTypeService.queryByCode(bo.getCardTypeId());
|
|
|
- //卡类对应的管理费
|
|
|
|
|
|
|
+ // 卡类对应的管理费
|
|
|
BigDecimal commissionRate = new BigDecimal(cardTypeVo.getCommissionCharge());
|
|
BigDecimal commissionRate = new BigDecimal(cardTypeVo.getCommissionCharge());
|
|
|
if (commissionRate.compareTo(BigDecimal.ZERO) > 0) {
|
|
if (commissionRate.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
- //设置有管理费率,需要计算管理费
|
|
|
|
|
|
|
+ // 设置有管理费率,需要计算管理费
|
|
|
BigDecimal commission;
|
|
BigDecimal commission;
|
|
|
String commType = parameterService.selectParamByCode("COMMISSION_TYPE");
|
|
String commType = parameterService.selectParamByCode("COMMISSION_TYPE");
|
|
|
- //从系统参数表中拿收管理费的设置
|
|
|
|
|
|
|
+ // 从系统参数表中拿收管理费的设置
|
|
|
if (Constants.TAKE_COMMISSION.equals(commType)) {
|
|
if (Constants.TAKE_COMMISSION.equals(commType)) {
|
|
|
- //按比例收取
|
|
|
|
|
- commission = bo.getReceiptMoney().multiply(commissionRate.divide(new BigDecimal(100), 2, RoundingMode.HALF_UP)).setScale(2, RoundingMode.HALF_UP);
|
|
|
|
|
|
|
+ // 按比例收取
|
|
|
|
|
+ commission = bo.getReceiptMoney().multiply(commissionRate.divide(new BigDecimal(100), 2, RoundingMode.HALF_UP)).setScale(2,
|
|
|
|
|
+ RoundingMode.HALF_UP);
|
|
|
} else {
|
|
} else {
|
|
|
- //直接设置
|
|
|
|
|
|
|
+ // 直接设置
|
|
|
commission = commissionRate;
|
|
commission = commissionRate;
|
|
|
}
|
|
}
|
|
|
return commission;
|
|
return commission;
|
|
|
} else {
|
|
} else {
|
|
|
- //没有设置管理费,设置为0
|
|
|
|
|
|
|
+ // 没有设置管理费,设置为0
|
|
|
return BigDecimal.ZERO;
|
|
return BigDecimal.ZERO;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -369,10 +372,10 @@ public class PtCardServiceImpl implements IPtCardService {
|
|
|
List<PtCardVo> list = this.queryList(bo);
|
|
List<PtCardVo> list = this.queryList(bo);
|
|
|
if (ObjUtil.isNotNull(list) && !list.isEmpty()) {
|
|
if (ObjUtil.isNotNull(list) && !list.isEmpty()) {
|
|
|
PtCardVo vo = list.get(0);
|
|
PtCardVo vo = list.get(0);
|
|
|
- if(ObjUtil.isEmpty(vo.getLastPay())){
|
|
|
|
|
- vo.setLastPay(DateUtil.offsetDay(DateUtil.date(),-1));
|
|
|
|
|
|
|
+ if (ObjUtil.isEmpty(vo.getLastPay())) {
|
|
|
|
|
+ vo.setLastPay(DateUtil.offsetDay(DateUtil.date(), -1));
|
|
|
}
|
|
}
|
|
|
- if (ObjUtil.isEmpty(vo.getLastMeal())|| ObjUtil.isNull(vo.getLastMeal())) {
|
|
|
|
|
|
|
+ if (ObjUtil.isEmpty(vo.getLastMeal()) || ObjUtil.isNull(vo.getLastMeal())) {
|
|
|
vo.setLastMeal(0L);
|
|
vo.setLastMeal(0L);
|
|
|
}
|
|
}
|
|
|
return vo;
|
|
return vo;
|
|
@@ -491,12 +494,14 @@ public class PtCardServiceImpl implements IPtCardService {
|
|
|
|
|
|
|
|
return baseMapper.update(null, lpw) > 0;
|
|
return baseMapper.update(null, lpw) > 0;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 更新当天的消费信息
|
|
* 更新当天的消费信息
|
|
|
- * @param cardNo 卡流水号
|
|
|
|
|
- * @param mealType 餐类
|
|
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param cardNo 卡流水号
|
|
|
|
|
+ * @param mealType 餐类
|
|
|
* @param consumeValue 消费金额
|
|
* @param consumeValue 消费金额
|
|
|
- * @param consumeDate 消费日期
|
|
|
|
|
|
|
+ * @param consumeDate 消费日期
|
|
|
* @return 更新结果
|
|
* @return 更新结果
|
|
|
*/
|
|
*/
|
|
|
@Override
|
|
@Override
|
|
@@ -527,4 +532,21 @@ public class PtCardServiceImpl implements IPtCardService {
|
|
|
|
|
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 注销指定用户的卡片
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param userId 用户Id
|
|
|
|
|
+ * @param operatorId 操作员Id
|
|
|
|
|
+ * @return 注销结果
|
|
|
|
|
+ */
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public Boolean cancelCard(Long userId, Long operatorId) {
|
|
|
|
|
+ LambdaUpdateWrapper<PtCard> luw = new LambdaUpdateWrapper<PtCard>().set(PtCard::getStatus, CardStatusEnum.CLOSE.code().toString())
|
|
|
|
|
+ .set(PtCard::getChangeTime, DateUtil.date())
|
|
|
|
|
+ .set(PtCard::getUpdateBy, operatorId)
|
|
|
|
|
+ .eq(PtCard::getUserId, userId)
|
|
|
|
|
+ .eq(PtCard::getStatus, CardStatusEnum.NORMAL.code().toString());
|
|
|
|
|
+ return baseMapper.update(null, luw) >= 0;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|