充值赠送问题
This commit is contained in:
@@ -15,6 +15,8 @@ import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -74,6 +76,16 @@ public class SaleSummaryController {
|
||||
*/
|
||||
@GetMapping("/print")
|
||||
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) {
|
||||
param.setShopId(StpKit.USER.getShopId());
|
||||
}
|
||||
|
||||
@@ -178,7 +178,9 @@ public class MkShopRechargeServiceImpl extends ServiceImpl<MkShopRechargeMapper,
|
||||
.setType(1)
|
||||
.setBizEnum(bizEnum)
|
||||
.setRelationId(paymentId);
|
||||
BigDecimal rechargeAmount = BigDecimal.ZERO;
|
||||
shopUserMoneyEditDTO.setMoney(amount);
|
||||
Long flowId = shopUserService.updateMoney(shopUserMoneyEditDTO);
|
||||
BigDecimal rechargeAmount = amount;
|
||||
BigDecimal giftAmount = BigDecimal.ZERO;
|
||||
BigDecimal giftPoints = BigDecimal.ZERO;
|
||||
Integer giftCoupon = 0;
|
||||
@@ -186,47 +188,45 @@ public class MkShopRechargeServiceImpl extends ServiceImpl<MkShopRechargeMapper,
|
||||
// 标准充值
|
||||
if (rechargeDetailId != null) {
|
||||
MkShopRechargeDetail rechargeDetail = shopRechargeDetailService.getById(rechargeDetailId);
|
||||
shopUserMoneyEditDTO.setMoney(rechargeDetail.getAmount());
|
||||
rechargeAmount = rechargeDetail.getAmount();
|
||||
try {
|
||||
// 赠送金额
|
||||
ShopUserMoneyEditDTO shopUserMoneyEditRewardDTO = new ShopUserMoneyEditDTO()
|
||||
.setId(shopUserId)
|
||||
.setType(1)
|
||||
.setBizEnum(ShopUserFlowBizEnum.AWARD_IN)
|
||||
.setRelationId(paymentId);
|
||||
shopUserMoneyEditRewardDTO.setMoney(rechargeDetail.getRewardAmount());
|
||||
Long editId = shopUserService.updateMoney(shopUserMoneyEditRewardDTO);
|
||||
giftAmount = rechargeDetail.getRewardAmount();
|
||||
// 发放积分
|
||||
if (rechargeDetail.getRewardPoints() != null) {
|
||||
giftPoints = BigDecimal.valueOf(rechargeDetail.getRewardPoints());
|
||||
pointsUserService.alterPoints(null, shopUserId, shopUser.getMainShopId(), PointsConstant.ADD, rechargeDetail.getRewardPoints(), editId, "充值赠送");
|
||||
}
|
||||
// 发放优惠券
|
||||
if (StrUtil.isNotBlank(rechargeDetail.getCouponInfoList())) {
|
||||
List<CouponInfoDTO> list = JSONArray.parseArray(rechargeDetail.getCouponInfoList()).toJavaList(CouponInfoDTO.class);
|
||||
for (CouponInfoDTO item : list) {
|
||||
if (item.getId() == null) {
|
||||
return;
|
||||
}
|
||||
giftCoupon = giftCoupon + item.getNum();
|
||||
shopCouponRecordService.grant(shopId, new MkRewardCouponDTO().setCouponId(item.getId())
|
||||
.setNum(item.getNum())
|
||||
.setUserId(shopUser.getUserId())
|
||||
.setShopId(shopId), "充值赠券");
|
||||
if (rechargeDetail != null) {
|
||||
if (rechargeDetail.getRewardAmount() != null && rechargeDetail.getRewardAmount().compareTo(BigDecimal.ZERO) > 0) {
|
||||
// 赠送金额
|
||||
ShopUserMoneyEditDTO shopUserMoneyEditRewardDTO = new ShopUserMoneyEditDTO()
|
||||
.setId(shopUserId)
|
||||
.setType(1)
|
||||
.setRechargeId(flowId)
|
||||
.setBizEnum(ShopUserFlowBizEnum.AWARD_IN)
|
||||
.setRelationId(paymentId);
|
||||
shopUserMoneyEditRewardDTO.setMoney(rechargeDetail.getRewardAmount());
|
||||
shopUserService.updateMoney(shopUserMoneyEditRewardDTO);
|
||||
giftAmount = rechargeDetail.getRewardAmount();
|
||||
}
|
||||
// 发放积分
|
||||
if (rechargeDetail.getRewardPoints() != null && rechargeDetail.getRewardPoints() > 0) {
|
||||
giftPoints = BigDecimal.valueOf(rechargeDetail.getRewardPoints());
|
||||
pointsUserService.alterPoints(null, shopUserId, shopUser.getMainShopId(), PointsConstant.ADD, rechargeDetail.getRewardPoints(), flowId, "充值赠送");
|
||||
}
|
||||
// 发放优惠券
|
||||
if (StrUtil.isNotBlank(rechargeDetail.getCouponInfoList())) {
|
||||
List<CouponInfoDTO> list = JSONArray.parseArray(rechargeDetail.getCouponInfoList()).toJavaList(CouponInfoDTO.class);
|
||||
for (CouponInfoDTO item : list) {
|
||||
if (item.getId() == null) {
|
||||
return;
|
||||
}
|
||||
giftCoupon = giftCoupon + item.getNum();
|
||||
shopCouponRecordService.grant(shopId, new MkRewardCouponDTO().setCouponId(item.getId())
|
||||
.setNum(item.getNum())
|
||||
.setUserId(shopUser.getUserId())
|
||||
.setShopId(shopId), "充值赠券");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("recharge充值有问题", e);
|
||||
}
|
||||
// 自定义金额
|
||||
} else {
|
||||
shopUserMoneyEditDTO.setMoney(amount);
|
||||
rechargeAmount = amount;
|
||||
}
|
||||
Long flowId = shopUserService.updateMoney(shopUserMoneyEditDTO);
|
||||
BigDecimal finalRechargeAmount = rechargeAmount;
|
||||
BigDecimal finalGiftAmount = giftAmount;
|
||||
BigDecimal finalGiftPoints = giftPoints;
|
||||
|
||||
@@ -76,17 +76,6 @@ public interface PrinterImpl {
|
||||
}
|
||||
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();
|
||||
StringBuilder builder = new StringBuilder();
|
||||
// 标题:店铺名称 + 充值凭证
|
||||
builder.append(getFormatLabel(record.getShopName(), signLabelInfo.center)).append(signLabelInfo.br);
|
||||
builder.append(getFormatLabel("充值凭证", signLabelInfo.center)).append(signLabelInfo.br);
|
||||
builder.append(getFormatLabel(record.getShopName(), signLabelInfo.s, 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(StrUtil.format("手机号: {}", 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("充值用户:" + record.getUserName(), signLabelInfo.s)).append(signLabelInfo.br);
|
||||
builder.append(getFormatLabel("手机号:" + record.getUserPhone(), 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(getFormatLabel(leftRightAlign("充值金额:", record.getRechargeAmount().stripTrailingZeros().toPlainString(), 16), signLabelInfo.f)).append(signLabelInfo.br);
|
||||
|
||||
Reference in New Issue
Block a user