|
|
@@ -1393,6 +1393,49 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
BigDecimal returnPoints = returnMoney.multiply(BigDecimal.valueOf(distributePointsExchangeMoney.getPoints())).divide(distributePointsExchangeMoney.getMoney(), 2, RoundingMode.HALF_DOWN);
|
|
|
points = returnPoints;
|
|
|
}
|
|
|
+ //是否使用优惠券 且优惠券折扣小于低于9折
|
|
|
+ if (order.getCouponUserId() != 0) {
|
|
|
+ //优惠券折扣是否小于低于9折
|
|
|
+ CouponUser couponUser = couponUserMapper.getCouponByCouponUserId(order.getCouponUserId());
|
|
|
+ BigDecimal plat_discount = couponUser.getDiscount();
|
|
|
+ BigDecimal nineDis = BigDecimal.valueOf(0.90);
|
|
|
+ if (plat_discount != null && plat_discount.compareTo(BigDecimal.ZERO) > 0 && plat_discount.compareTo(nineDis) <= 0) {
|
|
|
+ //是否参与渠道分销规则
|
|
|
+ //用户下单订单 是否使用 优惠券小于低于9折
|
|
|
+ //分销利润金额 减去(规格原价 * 目前使用的折扣 - 规格原价 * 渠道自身折扣 /2)
|
|
|
+ BigDecimal realMoney = order.getRealMoney();
|
|
|
+ //查询渠道对应的折扣
|
|
|
+ Coupon coupon = couponDistributePopularizeMapper.selectDiscountCouponByUserId(userDistribute.getId());
|
|
|
+ //未配置对应折扣
|
|
|
+ //按优惠多少对半平摊
|
|
|
+ if (coupon == null) {
|
|
|
+ BigDecimal avg = realMoney.multiply(plat_discount).divide(BigDecimal.valueOf(2));
|
|
|
+ points = points.subtract(avg.multiply(BigDecimal.valueOf(distributePointsExchangeMoney.getPoints())).divide(distributePointsExchangeMoney.getMoney(), 2, RoundingMode.HALF_DOWN));
|
|
|
+ if (points.compareTo(BigDecimal.ZERO) < 0) {
|
|
|
+ points = BigDecimal.ZERO;
|
|
|
+ }
|
|
|
+ distributeWaitingSendPoints.setIsRule(true);
|
|
|
+ }
|
|
|
+ if (coupon != null) {
|
|
|
+ BigDecimal distribute_discount = coupon.getDiscount();
|
|
|
+
|
|
|
+ BigDecimal ds_money = realMoney.multiply(distribute_discount);
|
|
|
+ BigDecimal plat_ds_money = realMoney.multiply(plat_discount);
|
|
|
+ BigDecimal subtractMoney = ds_money.subtract(plat_ds_money);
|
|
|
+ if (subtractMoney.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
+ BigDecimal avg = subtractMoney.divide(BigDecimal.valueOf(2));
|
|
|
+ points = points.subtract(avg.multiply(BigDecimal.valueOf(distributePointsExchangeMoney.getPoints())).divide(distributePointsExchangeMoney.getMoney(), 2, RoundingMode.HALF_DOWN));
|
|
|
+ if (points.compareTo(BigDecimal.ZERO) < 0) {
|
|
|
+ points = BigDecimal.ZERO;
|
|
|
+ }
|
|
|
+ distributeWaitingSendPoints.setIsRule(true);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
distributeWaitingSendPoints.setPoints(points);
|
|
|
if (points != null && points.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
log.info("用户{}邀请{},产生分销订单分发积分记录入库", userDistributeShared.getSharedId(), order.getUserId());
|
|
|
@@ -2062,6 +2105,9 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
BigDecimal discountMoney = orderDon.getMoney().multiply(coupon.getDiscount());
|
|
|
orderDon.setMoney(discountMoney);
|
|
|
couponMoney = orderDon.getRealMoney().subtract(discountMoney);
|
|
|
+ //记录折扣 用于分销
|
|
|
+ couponUser.setDiscount(coupon.getDiscount());
|
|
|
+ couponUserMapper.updateById(couponUser);
|
|
|
} else if (coupon.getType() == Coupon.Type.reduce) {
|
|
|
if (goodsType == 2) {
|
|
|
if (skuMoney.compareTo(coupon.getReduceCondition()) < 0) {
|
|
|
@@ -2327,8 +2373,36 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
if (userDistributeShared != null) {
|
|
|
orderDon.setIsDistribute(true);
|
|
|
UserDistribute userDistribute = userDistributeMapper.selectOne(Wrappers.lambdaQuery(UserDistribute.class).eq(UserDistribute::getUserId, userDistributeShared.getSharedId()));
|
|
|
- if (userDistribute != null) {
|
|
|
- orderDon.setIsFixedDistribute(true);
|
|
|
+ if (userDistribute != null && userDistributeShared.getIsBind()) {
|
|
|
+ //45天内是否下单成功
|
|
|
+ Date createdTime = userDistributeShared.getCreatedTime();
|
|
|
+ DateTime forty_five = DateUtil.offsetDay(createdTime, 45);
|
|
|
+ //在45天内
|
|
|
+ Boolean is_fit = false;
|
|
|
+ boolean before = DateTime.now().isBefore(forty_five);
|
|
|
+ //超过45天还未下过单
|
|
|
+ //直接不参与后续的 提成
|
|
|
+ if (before) {
|
|
|
+ is_fit = true;
|
|
|
+ } else {
|
|
|
+ int count = this.count(Wrappers.lambdaQuery(OrderDon.class)
|
|
|
+ .eq(OrderDon::getUserId, userId)
|
|
|
+ .notIn(OrderDon::getStatus, Constant.noOrderAllStatus)
|
|
|
+ .le(OrderDon::getCreatedTime, forty_five));
|
|
|
+ if (count > 0) {
|
|
|
+ is_fit = true;
|
|
|
+ } else {
|
|
|
+ userDistributeShared.setIsBind(false);
|
|
|
+ userDistributeSharedMapper.updateById(userDistributeShared);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //未达标
|
|
|
+ if (is_fit) {
|
|
|
+ orderDon.setIsFixedDistribute(true);
|
|
|
+ } else {
|
|
|
+ orderDon.setIsDistribute(false);
|
|
|
+ orderDon.setIsFixedDistribute(false);
|
|
|
+ }
|
|
|
orderDon.setCpsPopularizeId(userDistributeShared.getDsPopularizeId());
|
|
|
}
|
|
|
}
|