指定2023预售书只有妇幼生殖vip送积分,其他vip送优惠券

This commit is contained in:
wyn
2026-06-02 17:53:57 +08:00
parent a3ffd72d6e
commit 13b32ccd55
3 changed files with 16 additions and 16 deletions

View File

@@ -1094,10 +1094,10 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrder> impl
if(buyOrder.getOrderType().equals("vip")){
userVipService.refundVip(buyOrder);
}else{
//撤回本订单购买赠送的优惠券
couponService.refundZSCouponHistoryByOrder(buyOrder);
//恢复用户权益(点穴/时辰取穴/五运六气/肿瘤古方)
myUserService.rollbackUserPowers(buyOrder,user, orderProducts);
//撤回本订单购买赠送的优惠券
couponService.refundZSCouponHistoryByOrder(buyOrder);
//撤回电子书权限
userEbookBuyService.rollbackUserEbooks(buyOrder, orderProducts);
//撤回课程权限

View File

@@ -324,16 +324,19 @@ public class CouponServiceImpl extends ServiceImpl<CouponDao, CouponEntity> impl
isVip = true;
}
System.out.println("isVip:"+isVip);
boolean isFyszVip = userVipList.stream().anyMatch(userVip -> Integer.valueOf(10).equals(userVip.getType()));
BigDecimal refundAllJF = BigDecimal.ZERO;
Boolean isRefundCoupon = false;
for (Map<String,Object> map : buyOrderProducts) {
ShopProduct shopProduct = shopProductDao.selectById(map.get("product_id").toString());
System.out.println("goodsType:"+shopProduct.getGoodsType());
if ("03".equals(shopProduct.getGoodsType())){
int productId = Integer.parseInt(map.get("product_id").toString());
int couponId = Integer.parseInt(map.get("coupon_id").toString());
CouponEntity couponEntity = couponDao.selectById(couponId);
boolean shouldRefundJf = couponEntity.getCouponType()==0 && ((productId == 2023 && isFyszVip) || (productId != 2023 && isVip));
//现金券
if (couponEntity.getCouponType()==0 && isVip){
if (shouldRefundJf){
BigDecimal quantity = new BigDecimal(map.get("quantity").toString());
BigDecimal sumRefundJF = couponEntity.getCouponAmount().multiply(quantity);
refundAllJF = refundAllJF.add(sumRefundJF);
@@ -376,17 +379,20 @@ public class CouponServiceImpl extends ServiceImpl<CouponDao, CouponEntity> impl
List<Map<String,Object>> buyOrderProducts = couponToProductDao.selectJoinMaps(wrapper);
for (Map<String,Object> map : buyOrderProducts) {
ShopProduct shopProduct = shopProductDao.selectById(map.get("product_id").toString());
//vip身份用户买送优惠券的预售书时候不送优惠券改自动送积分
//预售书赠送规则:
//1) 指定预售书(2023)仅妇幼生殖vip(type=10)且现金券时,改为送积分
//2) 其他预售书保持原规则任意vip且现金券时改为送积分
if ("03".equals(shopProduct.getGoodsType())){
MyUserEntity userEntity = userDao.selectById(order.getUserId());
List<UserVip> userVipList = userVipDao.selectList(new LambdaQueryWrapper<UserVip>()
.eq(UserVip::getUserId, userEntity.getId())
.eq(UserVip::getState,0));
if (userVipList.size() > 0) {
int couponId = Integer.parseInt(map.get("coupon_id").toString());
CouponEntity couponEntity = couponDao.selectById(couponId);
//现金券
if (couponEntity.getCouponType()==0){
int productId = Integer.parseInt(map.get("product_id").toString());
int couponId = Integer.parseInt(map.get("coupon_id").toString());
CouponEntity couponEntity = couponDao.selectById(couponId);
boolean isFyszVip = userVipList.stream().anyMatch(userVip -> Integer.valueOf(10).equals(userVip.getType()));
boolean couponToJf = couponEntity.getCouponType() == 0 && ((productId == 2023 && isFyszVip) || (productId != 2023 && userVipList.size() > 0));
if (couponToJf){
BigDecimal jf = BigDecimal.ZERO;
for (int i=0;i<Integer.parseInt(map.get("quantity").toString());i++){
R res = insertCouponHistory(order,couponId,order.getUserId(), 1,1,
@@ -407,12 +413,6 @@ public class CouponServiceImpl extends ServiceImpl<CouponDao, CouponEntity> impl
jfTransactionDetails.setRemark("vip用户买预售书送的优惠券换积分,订单号:"+order.getOrderSn());
jfTransactionDetailsDao.insert(jfTransactionDetails);
}
}else {
for (int i=0;i<Integer.parseInt(map.get("quantity").toString());i++){
insertCouponHistory(Integer.parseInt(map.get("coupon_id").toString()),
order.getUserId(), 1,0,"购买商品"+shopProduct.getProductName()+"赠送");
}
}
}else {
for (int i=0;i<Integer.parseInt(map.get("quantity").toString());i++){
insertCouponHistory(Integer.parseInt(map.get("coupon_id").toString()),

View File

@@ -37,7 +37,7 @@ public class JfTransactionDetailsServiceImpl extends ServiceImpl<JfTransactionDe
public void recordZsJfTransaction(BuyOrder buyOrder, MyUserEntity user, BigDecimal refundJF) {
JfTransactionDetails jfTransactionDetails = new JfTransactionDetails();
jfTransactionDetails.setUserId(buyOrder.getUserId());
jfTransactionDetails.setChangeAmount(refundJF);
jfTransactionDetails.setChangeAmount(refundJF.abs().negate());
jfTransactionDetails.setActType(1);
jfTransactionDetails.setUserBalance(user.getJf());
jfTransactionDetails.setRelationId(buyOrder.getOrderId());