成长值
This commit is contained in:
@@ -34,7 +34,8 @@ public interface MkShopRechargeService extends IService<MkShopRecharge> {
|
||||
* @param isNoJoin 是否没有执行 加入会员的方法
|
||||
* 会员如果是条件开通 则 需要统计
|
||||
*/
|
||||
void recharge(Long shopId, Long shopUserId, Long rechargeDetailId, BigDecimal amount, Long paymentId, String payType, ShopUserFlowBizEnum bizEnum, boolean isNoJoin);
|
||||
void recharge(Long shopId, Long shopUserId, Long rechargeDetailId, BigDecimal amount, Long paymentId,
|
||||
String payType, ShopUserFlowBizEnum bizEnum, boolean isNoJoin);
|
||||
|
||||
List<RechargeListVO> getList(long loginIdAsLong);
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.czg.utils;
|
||||
|
||||
import cn.hutool.core.lang.func.Func0;
|
||||
import cn.hutool.core.thread.ThreadUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.transaction.support.TransactionSynchronization;
|
||||
import org.springframework.transaction.support.TransactionSynchronizationManager;
|
||||
@@ -42,6 +43,10 @@ public class FunUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static void asyncSafeRunVoid(Runnable func, String... msg) {
|
||||
ThreadUtil.execAsync(() -> safeRunVoid(func, msg));
|
||||
}
|
||||
|
||||
/**
|
||||
* 在事务提交后执行方法
|
||||
* 异步 执行
|
||||
|
||||
@@ -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.constant.TableValueConstant;
|
||||
import com.czg.enums.ShopUserFlowBizEnum;
|
||||
import com.czg.exception.CzgException;
|
||||
import com.czg.market.dto.CouponInfoDTO;
|
||||
@@ -174,9 +175,9 @@ public class MkShopRechargeServiceImpl extends ServiceImpl<MkShopRechargeMapper,
|
||||
|
||||
// 标准充值
|
||||
if (rechargeDetailId != null) {
|
||||
FunUtils.asyncSafeRunVoid(() -> {
|
||||
MkShopRechargeDetail rechargeDetail = shopRechargeDetailService.getById(rechargeDetailId);
|
||||
shopUserMoneyEditDTO.setMoney(rechargeDetail.getAmount());
|
||||
|
||||
// 赠送金额
|
||||
ShopUserMoneyEditDTO shopUserMoneyEditRewardDTO = new ShopUserMoneyEditDTO()
|
||||
.setId(shopUserId)
|
||||
@@ -185,35 +186,33 @@ public class MkShopRechargeServiceImpl extends ServiceImpl<MkShopRechargeMapper,
|
||||
.setRelationId(paymentId);
|
||||
shopUserMoneyEditRewardDTO.setMoney(rechargeDetail.getRewardAmount());
|
||||
Long editId = shopUserService.updateMoney(shopUserMoneyEditRewardDTO);
|
||||
|
||||
// 发放积分
|
||||
if (rechargeDetail.getRewardPoints() != null) {
|
||||
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 -> {
|
||||
if (item.getId() == null) {
|
||||
return;
|
||||
}
|
||||
// try {
|
||||
shopCouponRecordService.grant(shopId, new MkRewardCouponDTO().setCouponId(item.getId())
|
||||
.setNum(item.getNum())
|
||||
.setUserId(shopUser.getUserId())
|
||||
.setShopId(shopId), "充值赠券");
|
||||
// } catch (Exception e) {
|
||||
// log.warn("发放优惠券失败", e);
|
||||
// }
|
||||
});
|
||||
}
|
||||
});
|
||||
// 自定义金额
|
||||
} else {
|
||||
shopUserMoneyEditDTO.setMoney(amount);
|
||||
}
|
||||
shopUserService.updateMoney(shopUserMoneyEditDTO);
|
||||
FunUtils.asyncSafeRunVoid(() -> {
|
||||
memberConfigService.deliver(shopUser, TableValueConstant.MemberExpFlow.Type.RECHARGE, amount, null, rechargeDetailId);
|
||||
});
|
||||
if (isNoJoin) {
|
||||
FunUtils.transactionSafeRun(() -> memberConfigService.joinMemberByCondition(shopId, shopUser.getUserId(), shopUser));
|
||||
FunUtils.asyncSafeRunVoid(() -> memberConfigService.joinMemberByCondition(shopId, shopUser.getUserId(), shopUser));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -431,6 +431,7 @@ public class TbMemberConfigServiceImpl extends ServiceImpl<TbMemberConfigMapper,
|
||||
upShopUser.setStartTime(LocalDateTime.now());
|
||||
upShopUser.setEndTime(upShopUser.getStartTime().plusDays(20000));
|
||||
upShopUser.setIsVip(1);
|
||||
shopUser.setIsVip(1);
|
||||
if (shopUser.getJoinTime() != null) {
|
||||
upShopUser.setJoinTime(LocalDateTime.now());
|
||||
}
|
||||
|
||||
@@ -1259,10 +1259,8 @@ public class OrderInfoCustomServiceImpl implements OrderInfoCustomService {
|
||||
if (shopUser.getIsVip().equals(0)) {
|
||||
// 消费累计成为会员的情况
|
||||
memberConfigService.joinMemberByCondition(orderInfo.getShopId(), orderInfo.getUserId(), shopUser);
|
||||
} else {
|
||||
// 消费赠送成长值
|
||||
memberConfigService.deliver(shopUser, TableValueConstant.MemberExpFlow.Type.COST, orderInfo.getPayAmount(), null, orderInfo.getId());
|
||||
}
|
||||
memberConfigService.deliver(shopUser, TableValueConstant.MemberExpFlow.Type.COST, orderInfo.getPayAmount(), null, orderInfo.getId());
|
||||
}, "订单{}用户累计/赠送成长值失败", orderInfo.getId());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ public class OrderPaymentServiceImpl extends ServiceImpl<OrderPaymentMapper, Ord
|
||||
|
||||
@Override
|
||||
public BigDecimal countMemberInAmount(Long shopId, Long shopUserId) {
|
||||
return getOneAs(QueryWrapper.create().select("sum(amount)")
|
||||
return getOneAs(QueryWrapper.create().select("IFNULL(sum(amount), 0) as total_amount")
|
||||
.eq(OrderPayment::getShopId, 143)
|
||||
.eq(OrderPayment::getSourceType, PayTypeConstants.SourceType.MEMBER_IN)
|
||||
.eq(OrderPayment::getPayType, PayTypeConstants.PayType.PAY)
|
||||
|
||||
Reference in New Issue
Block a user