|
|
@@ -9,6 +9,7 @@ import com.etotem.cfc.dto.ProductOrderDTO;
|
|
|
import com.etotem.cfc.entity.AfterSalesRequest;
|
|
|
import com.etotem.cfc.entity.AssessmentProduct;
|
|
|
import com.etotem.cfc.entity.Product;
|
|
|
+import com.etotem.cfc.entity.ProductGiftRule;
|
|
|
import com.etotem.cfc.entity.ProductOrder;
|
|
|
import com.etotem.cfc.entity.User;
|
|
|
import com.etotem.cfc.mapper.AfterSalesRequestMapper;
|
|
|
@@ -94,6 +95,12 @@ public class ProductOrderService {
|
|
|
@Resource
|
|
|
private SupplyHierarchyService supplyHierarchyService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private ProductGiftRuleService productGiftRuleService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private MembershipService membershipService;
|
|
|
+
|
|
|
public Result<ProductOrderDTO> create(CreateProductOrderDTO dto, Long buyerId) {
|
|
|
if (buyerId == null) {
|
|
|
return Result.error("请先登录");
|
|
|
@@ -363,6 +370,27 @@ public class ProductOrderService {
|
|
|
log.error("发放测评额度失败: orderNo={}", orderNo, e);
|
|
|
// 不阻塞支付流程
|
|
|
}
|
|
|
+ // 商品赠送会员:原价购买且配置赠送规则时,支付成功后自动赠送会员
|
|
|
+ try {
|
|
|
+ if (paidProduct != null) {
|
|
|
+ ProductGiftRule giftRule = productGiftRuleService.getActiveByProductId(paidProduct.getId());
|
|
|
+ if (giftRule != null) {
|
|
|
+ // 原价判定:无积分抵扣、无优惠券、无折扣
|
|
|
+ boolean fullPrice = (order.getPointsUsed() == null || order.getPointsUsed() == 0)
|
|
|
+ && order.getCouponId() == null
|
|
|
+ && (order.getDiscountAmount() == null || order.getDiscountAmount() == 0);
|
|
|
+ if (fullPrice && order.getFamilyId() != null) {
|
|
|
+ boolean granted = membershipService.grantMembershipByGift(
|
|
|
+ order.getFamilyId(), order.getBuyerId(), giftRule.getLevelCode(),
|
|
|
+ order.getOrderNo(), order.getTransactionId());
|
|
|
+ log.info("商品订单{}赠送会员{}结果={}", orderNo, giftRule.getLevelCode(), granted);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("商品赠送会员失败: orderNo={}", orderNo, e);
|
|
|
+ // 不阻塞支付流程
|
|
|
+ }
|
|
|
return Result.success("支付成功");
|
|
|
}
|
|
|
|