|
|
@@ -366,23 +366,9 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
if (relation != null && relation.getStatus() == GroupsRelation.Status.outside) {
|
|
|
orderDon.setIsOt(true);
|
|
|
}
|
|
|
- if (isNoLogin == null || !isNoLogin) {
|
|
|
+ if (orderDon.getYhsId() == 0) {
|
|
|
//虚拟商品订单,是否是分销订单
|
|
|
- if (goodsDon.getType() == 1 || goodsDon.getType() == 2) {
|
|
|
- //若该订单使用了规定推广者的兑换码 增加上下级关系
|
|
|
- if (StrUtil.isNotBlank(orderDon.getCouponExCode()) && orderDon.getUserId() != 0) {
|
|
|
- addDistributeCouponCode(orderDon.getUserId(), orderDon.getCouponExCode());
|
|
|
- }
|
|
|
- UserDistributeShared userDistributeShared = userDistributeSharedMapper.selectOne(Wrappers.lambdaQuery(UserDistributeShared.class).eq(UserDistributeShared::getUserId, user.getId()).last("limit 1"));
|
|
|
- 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);
|
|
|
- orderDon.setCpsPopularizeId(userDistributeShared.getDsPopularizeId());
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ setDistributeOrderMark(orderDon, goodsDon.getType(), user.getId());
|
|
|
}
|
|
|
if (relationId != 0) {
|
|
|
Long gtSkuId = groupsRelationMapper.getGroupTripsSkuIdByRelationId(relationId);
|
|
|
@@ -778,6 +764,7 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
OrderDon orderDon = new OrderDon();
|
|
|
orderDon.setOrderNo(donNo);
|
|
|
orderDon.setOpenId(payOpenId);
|
|
|
+ orderDon.setYhsId(yhsId);
|
|
|
orderDon.setMoney(sku.getPrice().multiply(BigDecimal.valueOf(payRequest.getNum())));
|
|
|
orderDon.setSkuId(renewSkuId);
|
|
|
orderDon.setRelationId(relation.getId());
|
|
|
@@ -794,17 +781,9 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
if (relation != null && relation.getStatus() == GroupsRelation.Status.outside) {
|
|
|
orderDon.setIsOt(true);
|
|
|
}
|
|
|
- //虚拟商品订单,是否是分销订单
|
|
|
- if (goodsDon.getType() == 1) {
|
|
|
- UserDistributeShared userDistributeShared = userDistributeSharedMapper.selectOne(Wrappers.lambdaQuery(UserDistributeShared.class).eq(UserDistributeShared::getUserId, user.getId()).last("limit 1"));
|
|
|
- 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);
|
|
|
- orderDon.setCpsPopularizeId(userDistributeShared.getDsPopularizeId());
|
|
|
- }
|
|
|
- }
|
|
|
+ if (orderDon.getYhsId() == 0) {
|
|
|
+ //虚拟商品订单,是否是分销订单
|
|
|
+ setDistributeOrderMark(orderDon, goodsDon.getType(), userId);
|
|
|
}
|
|
|
orderDon.setRealMoney(orderDon.getMoney());
|
|
|
//扣除使用优惠券、余额的订单金额
|
|
|
@@ -2176,6 +2155,61 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public void setDistributeOrderMark(OrderDon orderDon, Integer goodsType, Long userId) {
|
|
|
+ if (userId == null || userId == 0) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //虚拟商品订单,是否是分销订单
|
|
|
+ if (goodsType == 1 || goodsType == 2) {
|
|
|
+ //若该订单使用了规定推广者的兑换码 增加上下级关系
|
|
|
+ if (StrUtil.isNotBlank(orderDon.getCouponExCode()) && orderDon.getUserId() != 0) {
|
|
|
+ addDistributeCouponCode(orderDon.getUserId(), orderDon.getCouponExCode());
|
|
|
+ }
|
|
|
+ UserDistributeShared userDistributeShared = userDistributeSharedMapper.selectOne(Wrappers.lambdaQuery(UserDistributeShared.class).eq(UserDistributeShared::getUserId, userId).last("limit 1"));
|
|
|
+ if (userDistributeShared != null) {
|
|
|
+ orderDon.setIsDistribute(true);
|
|
|
+ UserDistribute userDistribute = userDistributeMapper.selectOne(Wrappers.lambdaQuery(UserDistribute.class).eq(UserDistribute::getUserId, userDistributeShared.getSharedId()));
|
|
|
+ if (userDistribute != null) {
|
|
|
+ //直接去除
|
|
|
+ if (!userDistributeShared.getIsBind()) {
|
|
|
+ orderDon.setIsDistribute(false);
|
|
|
+ } else {
|
|
|
+ //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());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public GoodsDonSku adjustGoodsDonSku(Long yhsId, Long skuId) {
|
|
|
GoodsDonSku sku;
|
|
|
if (yhsId != null) {
|