充值赠送问题

This commit is contained in:
2026-04-17 13:57:33 +08:00
parent 513baf34cd
commit b22b92c877
3 changed files with 51 additions and 50 deletions

View File

@@ -15,6 +15,8 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.List; import java.util.List;
/** /**
@@ -74,6 +76,16 @@ public class SaleSummaryController {
*/ */
@GetMapping("/print") @GetMapping("/print")
public CzgResult<Void> summaryPrint(SaleSummaryCountParam param) { public CzgResult<Void> summaryPrint(SaleSummaryCountParam param) {
LocalDateTime now = LocalDateTime.now();
LocalTime nowTime = now.toLocalTime();
// 起始 00:00结束 05:20
LocalTime start = LocalTime.of(0, 0);
LocalTime end = LocalTime.of(5, 20);
if (nowTime.isAfter(start) && nowTime.isBefore(end)) {
// 在 00:00 ~ 05:20 区间内
return CzgResult.failure("当前时间不支持打印打印时间5点20至24点");
}
if (param.getShopId() == null) { if (param.getShopId() == null) {
param.setShopId(StpKit.USER.getShopId()); param.setShopId(StpKit.USER.getShopId());
} }

View File

@@ -178,7 +178,9 @@ public class MkShopRechargeServiceImpl extends ServiceImpl<MkShopRechargeMapper,
.setType(1) .setType(1)
.setBizEnum(bizEnum) .setBizEnum(bizEnum)
.setRelationId(paymentId); .setRelationId(paymentId);
BigDecimal rechargeAmount = BigDecimal.ZERO; shopUserMoneyEditDTO.setMoney(amount);
Long flowId = shopUserService.updateMoney(shopUserMoneyEditDTO);
BigDecimal rechargeAmount = amount;
BigDecimal giftAmount = BigDecimal.ZERO; BigDecimal giftAmount = BigDecimal.ZERO;
BigDecimal giftPoints = BigDecimal.ZERO; BigDecimal giftPoints = BigDecimal.ZERO;
Integer giftCoupon = 0; Integer giftCoupon = 0;
@@ -186,22 +188,24 @@ public class MkShopRechargeServiceImpl extends ServiceImpl<MkShopRechargeMapper,
// 标准充值 // 标准充值
if (rechargeDetailId != null) { if (rechargeDetailId != null) {
MkShopRechargeDetail rechargeDetail = shopRechargeDetailService.getById(rechargeDetailId); MkShopRechargeDetail rechargeDetail = shopRechargeDetailService.getById(rechargeDetailId);
shopUserMoneyEditDTO.setMoney(rechargeDetail.getAmount());
rechargeAmount = rechargeDetail.getAmount();
try { try {
if (rechargeDetail != null) {
if (rechargeDetail.getRewardAmount() != null && rechargeDetail.getRewardAmount().compareTo(BigDecimal.ZERO) > 0) {
// 赠送金额 // 赠送金额
ShopUserMoneyEditDTO shopUserMoneyEditRewardDTO = new ShopUserMoneyEditDTO() ShopUserMoneyEditDTO shopUserMoneyEditRewardDTO = new ShopUserMoneyEditDTO()
.setId(shopUserId) .setId(shopUserId)
.setType(1) .setType(1)
.setRechargeId(flowId)
.setBizEnum(ShopUserFlowBizEnum.AWARD_IN) .setBizEnum(ShopUserFlowBizEnum.AWARD_IN)
.setRelationId(paymentId); .setRelationId(paymentId);
shopUserMoneyEditRewardDTO.setMoney(rechargeDetail.getRewardAmount()); shopUserMoneyEditRewardDTO.setMoney(rechargeDetail.getRewardAmount());
Long editId = shopUserService.updateMoney(shopUserMoneyEditRewardDTO); shopUserService.updateMoney(shopUserMoneyEditRewardDTO);
giftAmount = rechargeDetail.getRewardAmount(); giftAmount = rechargeDetail.getRewardAmount();
}
// 发放积分 // 发放积分
if (rechargeDetail.getRewardPoints() != null) { if (rechargeDetail.getRewardPoints() != null && rechargeDetail.getRewardPoints() > 0) {
giftPoints = BigDecimal.valueOf(rechargeDetail.getRewardPoints()); giftPoints = BigDecimal.valueOf(rechargeDetail.getRewardPoints());
pointsUserService.alterPoints(null, shopUserId, shopUser.getMainShopId(), PointsConstant.ADD, rechargeDetail.getRewardPoints(), editId, "充值赠送"); pointsUserService.alterPoints(null, shopUserId, shopUser.getMainShopId(), PointsConstant.ADD, rechargeDetail.getRewardPoints(), flowId, "充值赠送");
} }
// 发放优惠券 // 发放优惠券
if (StrUtil.isNotBlank(rechargeDetail.getCouponInfoList())) { if (StrUtil.isNotBlank(rechargeDetail.getCouponInfoList())) {
@@ -218,15 +222,11 @@ public class MkShopRechargeServiceImpl extends ServiceImpl<MkShopRechargeMapper,
} }
} }
}
} catch (Exception e) { } catch (Exception e) {
log.error("recharge充值有问题", e); log.error("recharge充值有问题", e);
} }
// 自定义金额
} else {
shopUserMoneyEditDTO.setMoney(amount);
rechargeAmount = amount;
} }
Long flowId = shopUserService.updateMoney(shopUserMoneyEditDTO);
BigDecimal finalRechargeAmount = rechargeAmount; BigDecimal finalRechargeAmount = rechargeAmount;
BigDecimal finalGiftAmount = giftAmount; BigDecimal finalGiftAmount = giftAmount;
BigDecimal finalGiftPoints = giftPoints; BigDecimal finalGiftPoints = giftPoints;

View File

@@ -76,17 +76,6 @@ public interface PrinterImpl {
} }
return ""; return "";
} }
/**
* @param num 最小1最大127不设置则为默认
*/
public String getRs(int num) {
if (StrUtil.isNotBlank(rs)) {
return StrUtil.format("<{}:{}>", rs, num);
}
return "";
}
} }
@@ -721,13 +710,13 @@ public interface PrinterImpl {
PrintSignLabel signLabelInfo = getSignLabelInfo(); PrintSignLabel signLabelInfo = getSignLabelInfo();
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
// 标题:店铺名称 + 充值凭证 // 标题:店铺名称 + 充值凭证
builder.append(getFormatLabel(record.getShopName(), signLabelInfo.center)).append(signLabelInfo.br); builder.append(getFormatLabel(record.getShopName(), signLabelInfo.s, signLabelInfo.center)).append(signLabelInfo.br);
builder.append(getFormatLabel("充值凭证", signLabelInfo.center)).append(signLabelInfo.br); builder.append(getFormatLabel("充值凭证", signLabelInfo.s, signLabelInfo.center)).append(signLabelInfo.br);
// 用户信息 // 用户信息
builder.append(getFormatLabel(StrUtil.format("充值用户: {}", record.getUserName(), signLabelInfo.s))).append(signLabelInfo.br); builder.append(getFormatLabel("充值用户:" + record.getUserName(), signLabelInfo.s)).append(signLabelInfo.br);
builder.append(getFormatLabel(StrUtil.format("手机号: {}", record.getUserPhone()), signLabelInfo.s)).append(signLabelInfo.br); builder.append(getFormatLabel("手机号:" + record.getUserPhone(), signLabelInfo.s)).append(signLabelInfo.br);
builder.append(getFormatLabel(StrUtil.format("支付时间: {}", DateUtil.format(record.getPayTime(), "yyyy/MM/dd HH:mm:ss")), signLabelInfo.s)).append(signLabelInfo.br); builder.append(getFormatLabel("支付时间:" + DateUtil.format(record.getPayTime(), "yyyy/MM/dd HH:mm:ss"), signLabelInfo.s)).append(signLabelInfo.br);
// 充值明细 // 充值明细
builder.append(getDividingLine()).append(signLabelInfo.br); builder.append(getDividingLine()).append(signLabelInfo.br);
builder.append(getFormatLabel(leftRightAlign("充值金额:", record.getRechargeAmount().stripTrailingZeros().toPlainString(), 16), signLabelInfo.f)).append(signLabelInfo.br); builder.append(getFormatLabel(leftRightAlign("充值金额:", record.getRechargeAmount().stripTrailingZeros().toPlainString(), 16), signLabelInfo.f)).append(signLabelInfo.br);