...
|
...
|
@@ -16,7 +16,6 @@ import lombok.extern.slf4j.Slf4j; |
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.apache.commons.lang3.tuple.Pair;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import java.util.List;
|
...
|
...
|
@@ -59,9 +58,6 @@ public class InviteSettlementItemCreator { |
|
|
@Autowired
|
|
|
private ProductMapper productMapper;
|
|
|
|
|
|
@Value("${ufo.invite.productSortLimit}")
|
|
|
private String productSortLimit;
|
|
|
|
|
|
public void createInviteSettlementItem(Long buyerOrderCode, Integer status) {
|
|
|
if (status == OrderStatus.WAITING_RECEIVE.getCode() || status == OrderStatus.DONE.getCode()) {
|
|
|
BuyerOrder buyerOrder = buyerOrderMapper.selectByOrderCode(buyerOrderCode);
|
...
|
...
|
@@ -72,6 +68,7 @@ public class InviteSettlementItemCreator { |
|
|
request.setBuyerOrderCode(buyerOrder.getOrderCode());
|
|
|
request.setSellerUid(buyerOrder.getSellerUid());
|
|
|
request.setOrderAmount(buyerOrder.getAmount());
|
|
|
request.setOrderAttributes(buyerOrder.getAttributes());
|
|
|
request.setSkup(buyerOrderGoods.getSkup());
|
|
|
// 卖家商家单子上架时间
|
|
|
request.setOrderCreateTime(sellerOrder.getCreateTime());
|
...
|
...
|
@@ -93,7 +90,7 @@ public class InviteSettlementItemCreator { |
|
|
}
|
|
|
int inviterUid = invitee.getInviterUid();
|
|
|
|
|
|
int orderCreateTime = request.getOrderCreateTime();
|
|
|
|
|
|
Inviter inviter = inviterMapper.selectByPrimaryKey(invitee.getInviterId());
|
|
|
if (Objects.isNull(inviter)) {
|
|
|
log.warn("{} fail, can not find inviter", tag);
|
...
|
...
|
@@ -104,7 +101,7 @@ public class InviteSettlementItemCreator { |
|
|
return;
|
|
|
}
|
|
|
|
|
|
if (!checkWithInviteActivity(tag, orderCreateTime, invitee, inviter)) {
|
|
|
if (!checkActivity(tag, request, invitee, inviter)) {
|
|
|
return;
|
|
|
}
|
|
|
|
...
|
...
|
@@ -170,10 +167,6 @@ public class InviteSettlementItemCreator { |
|
|
// 受邀人非入驻商家
|
|
|
else if (nonStoredSellerOfInvitee(request)) {
|
|
|
return Pair.of(InviteSettlementItem.STATUS_DISABLE, "NON_STORED_SELLER");
|
|
|
}
|
|
|
// 品类无效
|
|
|
else if (!hitProductSortLimit(request.getSkup())) {
|
|
|
return Pair.of(InviteSettlementItem.STATUS_DISABLE, "PRODUCT_SORT_LIMIT");
|
|
|
} else {
|
|
|
return Pair.of(InviteSettlementItem.STATUS_ENABLE, "OK");
|
|
|
}
|
...
|
...
|
@@ -183,27 +176,36 @@ public class InviteSettlementItemCreator { |
|
|
return request.getSellerOrderPayment() != Payment.WALLET.getCode();
|
|
|
}
|
|
|
|
|
|
private boolean checkWithInviteActivity(String tag, int orderCreateTime, InviteRecord invitee, Inviter inviter) {
|
|
|
int inviterType = inviter.getType();
|
|
|
int inviteTime = invitee.getCreateTime();
|
|
|
private boolean checkActivity(String tag, InviteSettlementItemCreateRequest request, InviteRecord invitee, Inviter inviter) {
|
|
|
|
|
|
// 入驻商家
|
|
|
if (inviterType == INVITER_TYPE_STORED_SELLER) {
|
|
|
if (inviter.getType() == INVITER_TYPE_STORED_SELLER) {
|
|
|
InviteActivity activity = inviteActivityMapper.selectByPrimaryKey(invitee.getInviteActivityId());
|
|
|
if (Objects.isNull(activity)) {
|
|
|
log.warn("{} fail, can not find inviter ", tag);
|
|
|
return false;
|
|
|
}
|
|
|
// 验证品类是否满足条件
|
|
|
if (!checkActivityProductSortLimit(request.getSkup(), activity.getProductSortLimit())) {
|
|
|
log.warn("{} fail, can not hit product sort limit is {}", tag, activity.getProductSortLimit());
|
|
|
return false;
|
|
|
}
|
|
|
// 验证订单属性是否满足条件
|
|
|
if (!checkActivityOrderAttributesLimit(request.getOrderAttributes(), activity.getOrderAttributesLimit())) {
|
|
|
log.warn("{} fail, can not hit order attributes limit is {}", tag, activity.getOrderAttributesLimit());
|
|
|
return false;
|
|
|
}
|
|
|
// 验证是否过了奖励时间
|
|
|
int days = activity.getRewardDays() * 24 * 60 * 60;
|
|
|
if (inviteTime + days < orderCreateTime) {
|
|
|
if (!checkActivityRewardDays(request, invitee, activity.getRewardDays())) {
|
|
|
log.warn("{} fail, reward end.", tag);
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
private boolean hitProductSortLimit(Integer skup) {
|
|
|
private boolean checkActivityProductSortLimit(Integer skup, String productSortLimit) {
|
|
|
if (StringUtils.isBlank(productSortLimit)) {
|
|
|
return true;
|
|
|
}
|
...
|
...
|
@@ -214,5 +216,20 @@ public class InviteSettlementItemCreator { |
|
|
return productSortLimitList.contains(maxSortId);
|
|
|
}
|
|
|
|
|
|
private boolean checkActivityOrderAttributesLimit(Integer orderAttributes, String orderAttributesLimit) {
|
|
|
if (StringUtils.isBlank(orderAttributesLimit)) {
|
|
|
return true;
|
|
|
}
|
|
|
List<String> orderAttributesLimitList = Splitter.on(",").splitToList(orderAttributesLimit);
|
|
|
return orderAttributesLimitList.contains(orderAttributes.toString());
|
|
|
}
|
|
|
|
|
|
private boolean checkActivityRewardDays(InviteSettlementItemCreateRequest request, InviteRecord invitee, int rewardDays) {
|
|
|
int orderCreateTime = request.getOrderCreateTime();
|
|
|
int inviteTime = invitee.getCreateTime();
|
|
|
int rewardTime = inviteTime + (rewardDays * 24 * 60 * 60);
|
|
|
return rewardTime >= orderCreateTime;
|
|
|
}
|
|
|
|
|
|
|
|
|
} |
...
|
...
|
|