|
|
@@ -108,6 +108,18 @@ public class ProductOrderService {
|
|
|
@Resource
|
|
|
private SupplySystemMemberMapper supplySystemMemberMapper;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private PpointConfigService ppointConfigService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private CommissionDistService commissionDistService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private PlatformPointsService platformPointsService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private SysConfigService sysConfigService;
|
|
|
+
|
|
|
@Resource
|
|
|
private SupplyHierarchyService supplyHierarchyService;
|
|
|
|
|
|
@@ -587,8 +599,38 @@ public class ProductOrderService {
|
|
|
order.setPaidAt(new Date());
|
|
|
order.setUpdatedAt(new Date());
|
|
|
orderMapper.updateById(order);
|
|
|
- commissionService.settle(order.getId(), "product", order.getBuyerId(),
|
|
|
- order.getTotalAmount(), order.getProductId());
|
|
|
+
|
|
|
+ // CF值:购买者本人按分润公式获得
|
|
|
+ try {
|
|
|
+ Product p = productMapper.selectById(order.getProductId());
|
|
|
+ if (p != null) {
|
|
|
+ int effectivePpoint = ppointConfigService.getEffectivePpoint(p.getId(), p.getCategoryId());
|
|
|
+ if (effectivePpoint > 0) {
|
|
|
+ String shareStr = sysConfigService.getValue("product_platform_points_share");
|
|
|
+ int shareBps = shareStr != null && !shareStr.isEmpty()
|
|
|
+ ? Integer.parseInt(shareStr) : 1000;
|
|
|
+ int cfValue = order.getTotalAmount() * effectivePpoint / 100 * shareBps / 10000;
|
|
|
+ if (cfValue > 0) {
|
|
|
+ platformPointsService.earn(order.getBuyerId(), cfValue,
|
|
|
+ "product_order", order.getId(),
|
|
|
+ "购买商品: " + order.getProductName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("购买者CF值发放失败: orderId={}, error={}", order.getId(), e.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ // CF值:推荐人按推荐链分润
|
|
|
+ try {
|
|
|
+ commissionDistService.distribute(order.getBuyerId(), order.getId(), order.getProductId());
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("推荐人分润失败: orderId={}, error={}", order.getId(), e.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ // 原佣金结算标记为废弃,保留兼容
|
|
|
+ // commissionService.settle(order.getId(), "product", order.getBuyerId(),
|
|
|
+ // order.getTotalAmount(), order.getProductId());
|
|
|
try {
|
|
|
if (order.getSupplySystemId() != null) {
|
|
|
User buyer = userMapper.selectById(order.getBuyerId());
|