打印数据
This commit is contained in:
@@ -9,6 +9,7 @@ import com.czg.account.entity.ShopUser;
|
||||
import com.czg.account.service.ShopConfigService;
|
||||
import com.czg.account.service.ShopInfoService;
|
||||
import com.czg.account.service.ShopUserService;
|
||||
import com.czg.config.RabbitPublisher;
|
||||
import com.czg.constant.TableValueConstant;
|
||||
import com.czg.enums.ShopUserFlowBizEnum;
|
||||
import com.czg.exception.CzgException;
|
||||
@@ -20,6 +21,7 @@ import com.czg.market.entity.ShopCoupon;
|
||||
import com.czg.market.enums.PointsConstant;
|
||||
import com.czg.market.service.*;
|
||||
import com.czg.market.vo.*;
|
||||
import com.czg.print.RechargePrintDTO;
|
||||
import com.czg.utils.AssertUtil;
|
||||
import com.czg.utils.FunUtils;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
@@ -32,6 +34,7 @@ import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -60,6 +63,8 @@ public class MkShopRechargeServiceImpl extends ServiceImpl<MkShopRechargeMapper,
|
||||
private ShopInfoService shopInfoService;
|
||||
@DubboReference
|
||||
private ShopConfigService shopConfigService;
|
||||
@Resource
|
||||
private RabbitPublisher rabbitPublisher;
|
||||
|
||||
@Override
|
||||
public MkShopRechargeVO detailApp(Long shopId) {
|
||||
@@ -72,7 +77,7 @@ public class MkShopRechargeServiceImpl extends ServiceImpl<MkShopRechargeMapper,
|
||||
}
|
||||
|
||||
@Override
|
||||
public MkShopRechargeVO detail(Long shopId) throws CzgException{
|
||||
public MkShopRechargeVO detail(Long shopId) throws CzgException {
|
||||
shopId = shopInfoService.getMainIdByShopId(shopId);
|
||||
ShopInfo shopInfo = shopInfoService.getById(shopId);
|
||||
if (shopInfo.getMainId() != null) {
|
||||
@@ -164,7 +169,7 @@ public class MkShopRechargeServiceImpl extends ServiceImpl<MkShopRechargeMapper,
|
||||
|
||||
@Override
|
||||
public void recharge(Long shopId, Long shopUserId, Long rechargeDetailId, BigDecimal amount, Long paymentId,
|
||||
String payType, ShopUserFlowBizEnum bizEnum, boolean isNoJoin) {
|
||||
String payType, LocalDateTime payTime, ShopUserFlowBizEnum bizEnum, boolean isNoJoin, String operator) {
|
||||
log.info("充值回调, 用户id: {}, 金额: {}, rechargeDetailId: {}", shopUserId, amount, rechargeDetailId);
|
||||
ShopUser shopUser = shopUserService.getById(shopUserId);
|
||||
ShopUserMoneyEditDTO shopUserMoneyEditDTO = new ShopUserMoneyEditDTO()
|
||||
@@ -172,12 +177,17 @@ public class MkShopRechargeServiceImpl extends ServiceImpl<MkShopRechargeMapper,
|
||||
.setType(1)
|
||||
.setBizEnum(bizEnum)
|
||||
.setRelationId(paymentId);
|
||||
BigDecimal rechargeAmount = BigDecimal.ZERO;
|
||||
BigDecimal giftAmount = BigDecimal.ZERO;
|
||||
BigDecimal giftPoints = BigDecimal.ZERO;
|
||||
Integer giftCoupon = 0;
|
||||
|
||||
// 标准充值
|
||||
if (rechargeDetailId != null) {
|
||||
MkShopRechargeDetail rechargeDetail = shopRechargeDetailService.getById(rechargeDetailId);
|
||||
shopUserMoneyEditDTO.setMoney(rechargeDetail.getAmount());
|
||||
FunUtils.asyncSafeRunVoid(() -> {
|
||||
rechargeAmount = rechargeDetail.getAmount();
|
||||
try {
|
||||
// 赠送金额
|
||||
ShopUserMoneyEditDTO shopUserMoneyEditRewardDTO = new ShopUserMoneyEditDTO()
|
||||
.setId(shopUserId)
|
||||
@@ -186,28 +196,56 @@ public class MkShopRechargeServiceImpl extends ServiceImpl<MkShopRechargeMapper,
|
||||
.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())) {
|
||||
JSONArray.parseArray(rechargeDetail.getCouponInfoList()).toJavaList(CouponInfoDTO.class).forEach(item -> {
|
||||
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;
|
||||
}
|
||||
shopUserService.updateMoney(shopUserMoneyEditDTO);
|
||||
Long flowId = shopUserService.updateMoney(shopUserMoneyEditDTO);
|
||||
BigDecimal finalRechargeAmount = rechargeAmount;
|
||||
BigDecimal finalGiftAmount = giftAmount;
|
||||
BigDecimal finalGiftPoints = giftPoints;
|
||||
Integer finalGiftCoupon = giftCoupon;
|
||||
FunUtils.asyncSafeRunVoid(() -> {
|
||||
RechargePrintDTO rechargePrintDTO = new RechargePrintDTO();
|
||||
rechargePrintDTO.setUserId(shopUserId);
|
||||
rechargePrintDTO.setUserName(shopUser.getNickName());
|
||||
rechargePrintDTO.setUserPhone(shopUser.getPhone());
|
||||
rechargePrintDTO.setPayTime(payTime);
|
||||
rechargePrintDTO.setRechargeAmount(finalRechargeAmount);
|
||||
rechargePrintDTO.setGiftAmount(finalGiftAmount);
|
||||
rechargePrintDTO.setGiftPoints(finalGiftPoints);
|
||||
rechargePrintDTO.setGiftCoupon(finalGiftCoupon);
|
||||
rechargePrintDTO.setPayType(bizEnum.getMsg());
|
||||
rechargePrintDTO.setBalance(shopUser.getAmount().add(finalRechargeAmount).add(finalGiftAmount));
|
||||
rechargePrintDTO.setRechargeId(flowId.toString());
|
||||
rechargePrintDTO.setOperator(operator);
|
||||
rabbitPublisher.sendOtherPrintMsg(shopId, rechargePrintDTO, "RECHARGE");
|
||||
});
|
||||
FunUtils.asyncSafeRunVoid(() -> {
|
||||
memberConfigService.deliver(shopUser, TableValueConstant.MemberExpFlow.Type.RECHARGE, amount, null, rechargeDetailId);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user