| | |
| | | import com.ruoyi.system.enums.BigGiftPackageOrderStatusEnum; |
| | | import com.ruoyi.system.enums.PhysicalGoodsOrderStatusEnum; |
| | | import com.ruoyi.system.model.TAppUser; |
| | | import com.ruoyi.system.model.TBigGiftPackage; |
| | | import com.ruoyi.system.model.TBigGiftPackageOrder; |
| | | import com.ruoyi.system.model.TPhysicalGoodsOrder; |
| | | import com.ruoyi.system.service.*; |
| | |
| | | public class ICBCNotifyServiceImpl implements ICBCNotifyService { |
| | | |
| | | private final ICBCConfig icbcConfig; |
| | | |
| | | private final TBigGiftPackageService bigGiftPackageService; |
| | | |
| | | private final TBigGiftPackageOrderService bigGiftPackageOrderService; |
| | | |
| | |
| | | bigGiftPackageOrderService.updateById(order); |
| | | log.info("订单{}状态更新为完成支付", order.getCode()); |
| | | |
| | | // 尾款支付完成后,必须计算分佣 |
| | | // 查询最新大礼包商品配置,获取积分结算价用于佣金计算 |
| | | TBigGiftPackage bigGiftPackage = bigGiftPackageService.getById(order.getBigGiftPackageId()); |
| | | if (bigGiftPackage == null || bigGiftPackage.getPointsSettlementPrice() == null) { |
| | | log.error("订单{}对应的大礼包商品配置不存在或积分结算价为空,无法计算佣金", order.getCode()); |
| | | sendResponse(response, signResult, msgId); |
| | | return; |
| | | } |
| | | |
| | | // 尾款支付完成后,使用大礼包商品配置的积分结算价计算分佣 |
| | | commissionTransactionFlowService.calculateAndSaveCommission( |
| | | order.getId(), |
| | | 1, // 订单类型:1=大礼包 |
| | | order.getOrderPrice(), |
| | | bigGiftPackage.getPointsSettlementPrice(), |
| | | order.getAppUserId() |
| | | ); |
| | | log.info("订单{}分佣计算完成", order.getCode()); |
| | | log.info("订单{}分佣计算完成,使用积分结算价:{}", order.getCode(), bigGiftPackage.getPointsSettlementPrice()); |
| | | |
| | | // 处理用户推荐状态和公司关联 |
| | | processUserReferrerAndCompany(order.getAppUserId()); |
| | |
| | | // 判断是否启用生效日 |
| | | Boolean effectDayFlag = order.getEffectDayFlag(); |
| | | if (effectDayFlag == null || !effectDayFlag) { |
| | | // 未启用生效日,立即计算分佣 |
| | | // 查询最新大礼包商品配置,获取积分结算价用于佣金计算 |
| | | TBigGiftPackage bigGiftPackage = bigGiftPackageService.getById(order.getBigGiftPackageId()); |
| | | if (bigGiftPackage == null || bigGiftPackage.getPointsSettlementPrice() == null) { |
| | | log.error("订单{}对应的大礼包商品配置不存在或积分结算价为空,无法计算佣金", order.getCode()); |
| | | return; |
| | | } |
| | | // 未启用生效日,使用大礼包商品配置的积分结算价立即计算分佣 |
| | | commissionTransactionFlowService.calculateAndSaveCommission( |
| | | order.getId(), |
| | | 1, // 订单类型:1=大礼包 |
| | | order.getOrderPrice(), |
| | | bigGiftPackage.getPointsSettlementPrice(), |
| | | order.getAppUserId() |
| | | ); |
| | | log.info("订单{}未启用生效日,立即计算分佣", order.getCode()); |
| | | log.info("订单{}未启用生效日,立即计算分佣,使用积分结算价:{}", order.getCode(), bigGiftPackage.getPointsSettlementPrice()); |
| | | } else { |
| | | // 启用生效日,不计算分佣(由定时任务处理) |
| | | log.info("订单{}启用生效日,延迟计算分佣", order.getCode()); |
| | |
| | | * @param appUserId 下单用户ID |
| | | */ |
| | | private void processUserReferrerAndCompany(Integer appUserId) { |
| | | log.info("开始处理用户{}推荐状态和公司关联", appUserId); |
| | | if (appUserId == null) { |
| | | return; |
| | | } |