|
@@ -641,7 +641,7 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
|
|
|
Long tradeOrderId = order.getId();
|
|
|
String OrderNum = order.getNo();
|
|
|
Long payIntegral = order.getPayIntegral();//每个订单使用的积分
|
|
|
- integralService.updateUserIntegral(userId, CaclEnum.ORDER_PAY_INTEGRAL, payIntegral * (-1), 0L, tradeOrderId, OrderNum);
|
|
|
+ integralService.updateUserIntegral(userId,userId, CaclEnum.ORDER_PAY_INTEGRAL, payIntegral * (-1), 0L, tradeOrderId, OrderNum);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -713,20 +713,25 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
|
|
|
return virtualOrder;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
- * 把商品的推广费总额,转换为直推人获得的冻结积分
|
|
|
+ * 把商品的推广费总额,转换为消费者本人(直推人)、或消费者的推荐人 获得的冻结积分
|
|
|
*
|
|
|
* @param promotionExpenses 商品的推广费总额
|
|
|
+ * @param grossProfitPerc 推荐人/消费者本人额度 百分比
|
|
|
* @return 输入推广费,对应的直推人获得的冻结积分
|
|
|
*/
|
|
|
public static Long promotionExpenses2GrossProfitAncestorQuota(
|
|
|
+ /*
|
|
|
+ 商品的推广费总额
|
|
|
+ */
|
|
|
Integer promotionExpenses,
|
|
|
/*
|
|
|
* 毛利 = 成本 * 0.38... (推广费用)
|
|
|
*/
|
|
|
String grossProfitPerc,
|
|
|
/*
|
|
|
- * 推广-推荐人额度 百分比
|
|
|
+ * 推广-推荐人/消费者本人额度 百分比
|
|
|
*/
|
|
|
String grossProfitAncestorQuotaPerc
|
|
|
) {
|
|
@@ -873,6 +878,7 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
|
|
|
//查询订单提成比例
|
|
|
QueryWrapper<OrderPercentageDO> queryWrapper = new QueryWrapper<>();
|
|
|
OrderPercentageDO orderPercentageDO = orderPercentageMapper.selectOne(queryWrapper);//表中只有一条记录
|
|
|
+
|
|
|
/*
|
|
|
* 毛利 = 成本 * 0.38... (推广费用)
|
|
|
*/
|
|
@@ -886,9 +892,19 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
|
|
|
*/
|
|
|
String grossProfitUserQuotaPerc = orderPercentageDO.getGrossProfitUserQuotaPerc();
|
|
|
|
|
|
+ /*
|
|
|
+ * 推荐人(上一级) 百分比
|
|
|
+ */
|
|
|
+ String grossProfitAncestorQuotaPerc = orderPercentageDO.getGrossProfitAncestorQuotaPerc();
|
|
|
+
|
|
|
//add by Ben 根据支付订单id,查询所有 支付订单 对应的 订单
|
|
|
List<TradeOrderDO> TradeOrderDOList = tradeOrderMapper.selectList("pay_order_id", payOrderId);
|
|
|
|
|
|
+ //购物者ID
|
|
|
+ Long memberUserIdOfTradeOrder = TradeOrderDOList.get(0).getUserId();
|
|
|
+ //20240604 推荐人(上级用户ID)
|
|
|
+ Long ancesterUserId = tradeOrderMapper.selectAncesterByMemberUserId(memberUserIdOfTradeOrder);
|
|
|
+
|
|
|
for (TradeOrderDO tradeOrderDO : TradeOrderDOList) {
|
|
|
|
|
|
Long tradeOrderId = tradeOrderDO.getId();
|
|
@@ -943,6 +959,9 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
|
|
|
}
|
|
|
|
|
|
Long totalFreezeAmount = 0L;//用户总的冻结积分
|
|
|
+
|
|
|
+ Long totalAncestorFreezeAmount = 0L;//推荐人总的冻结积分
|
|
|
+
|
|
|
for (TradeOrderItemDO tradeOrderItemDO : TradeOrderItemList) {
|
|
|
ProductSkuDO productSkuDO = skuDOMap.get(tradeOrderItemDO.getSkuId());
|
|
|
//这类商品的总推广费
|
|
@@ -956,12 +975,22 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
|
|
|
grossProfitUserQuotaPerc//消费者自得额度 百分比
|
|
|
);
|
|
|
|
|
|
+
|
|
|
+ //把商品项的推广费,转换为这项商品推荐人(上级)获得的冻结积分
|
|
|
+ Long ancestorItemFreezeAmount =
|
|
|
+ promotionExpenses2GrossProfitAncestorQuota(promotionExpenses,
|
|
|
+ grossProfitPerc,//毛利 = 成本 * 0.38... (推广费用)
|
|
|
+ grossProfitAncestorQuotaPerc//消费者自得额度 百分比
|
|
|
+ );
|
|
|
+
|
|
|
totalFreezeAmount += itemFreezeAmount;
|
|
|
+ totalAncestorFreezeAmount += ancestorItemFreezeAmount;
|
|
|
|
|
|
//记录用户在此订单项获得的冻结积分
|
|
|
TradeOrderItemDO toid = new TradeOrderItemDO();
|
|
|
toid.setId(tradeOrderItemDO.getId());
|
|
|
toid.setIncreaseIntegral(itemFreezeAmount);
|
|
|
+ toid.setAncestorIncreaseIntegral(ancestorItemFreezeAmount);//20240504 add by Ben
|
|
|
tradeOrderItemMapper.updateById(toid);
|
|
|
}
|
|
|
|
|
@@ -969,7 +998,13 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
|
|
|
// Integer freezeAmount = promotionExpenses2GrossProfitAncestorQuota(orderPercentageMapper,totalPromotionExpenses);
|
|
|
|
|
|
String OrderNum = order.getNo();
|
|
|
- integralService.updateUserIntegral(tradeOrderDO.getUserId(), CaclEnum.ORDER_PAY_INTEGRAL, 0L, totalFreezeAmount, tradeOrderId, OrderNum);
|
|
|
+ //修改购物者本人获得的冻结积分
|
|
|
+ integralService.updateUserIntegral(tradeOrderDO.getUserId(),tradeOrderDO.getUserId(),CaclEnum.ORDER_PAY_INTEGRAL, 0L, totalFreezeAmount, tradeOrderId, OrderNum);
|
|
|
+
|
|
|
+ //修改推荐人(上级)获得的冻结积分
|
|
|
+ integralService.updateUserIntegral(tradeOrderDO.getUserId(),ancesterUserId, CaclEnum.ORDER_PAY_INTEGRAL_ANCESTER, 0L, totalAncestorFreezeAmount, tradeOrderId, OrderNum);
|
|
|
+ log.warn("[TradeOrderUpdateServiceImpl.updateOrderPaid]$$$:[tradeOrderId({}),ancesterUserId({}),totalAncestorFreezeAmount({})]" + new Date(),
|
|
|
+ tradeOrderId,ancesterUserId, totalAncestorFreezeAmount);
|
|
|
|
|
|
allTradeOrderTotalFreezeAmount += totalFreezeAmount;//用户获得总的待确权冻结积分
|
|
|
|
|
@@ -1268,7 +1303,7 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
|
|
|
String orderNum = order.getNo();
|
|
|
//如果订单有使用积分,则退回积分
|
|
|
if (payIntegral > 0) {
|
|
|
- integralService.updateUserIntegral(userId, CaclEnum.ORDER_CANCEL_BY_USER_REFUND_INTEGRAL, payIntegral, 0L, tradeOrderId, orderNum);
|
|
|
+ integralService.updateUserIntegral(userId,userId, CaclEnum.ORDER_CANCEL_BY_USER_REFUND_INTEGRAL, payIntegral, 0L, tradeOrderId, orderNum);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1300,7 +1335,7 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
|
|
|
Long userId = order.getUserId();
|
|
|
//如果订单有使用积分,则退回积分
|
|
|
if (payIntegral > 0) {
|
|
|
- integralService.updateUserIntegral(userId, CaclEnum.ORDER_CANCEL_BY_SYSTEM_REFUND_INTEGRAL, payIntegral, 0L, tradeOrderId, orderNum);
|
|
|
+ integralService.updateUserIntegral(userId, userId,CaclEnum.ORDER_CANCEL_BY_SYSTEM_REFUND_INTEGRAL, payIntegral, 0L, tradeOrderId, orderNum);
|
|
|
}
|
|
|
|
|
|
count++;
|