...
|
...
|
@@ -1727,8 +1727,8 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport |
|
|
} else {
|
|
|
activityLogBo.setAmountStr("¥"+df1.format(activityLog.getAmount()));
|
|
|
}
|
|
|
//活动类型:1-特殊返,2-订单返利翻x倍,3-额外返,4-cps新人额外返,5-邀新返
|
|
|
if (activity.getType() < 5) {
|
|
|
//活动类型:1-特殊返,2-订单返利翻x倍,3-额外返,4-cps新人额外返,5-邀新返, 6-邀新下单
|
|
|
if (activity.getType() != 5) {
|
|
|
activityLogBo.setOrdercodes(activityLog.getOrders().split(","));
|
|
|
activityLogBo.setTimeStr(DateUtils.int2DateStr(activity.getStartTime(),"yyyy.MM.dd HH:mm:ss")+"-"+DateUtils.int2DateStr(activity.getEndTime(),"yyyy.MM.dd HH:mm:ss"));
|
|
|
}else {//5-邀新返,邀请注册yoho返佣
|
...
|
...
|
@@ -2041,7 +2041,6 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport |
|
|
//获取总数
|
|
|
PageResponseBO<UnionShareUserInviteBo> response = new PageResponseBO<>();
|
|
|
|
|
|
//queryTimeType(预估收入实际):1-昨日,2-本月,3-上月
|
|
|
Integer count = unionShareUserInviteMapper.selectCountByInviterUid(req.getInviterUid());
|
|
|
if (count <= 0){
|
|
|
logger.info("UnionShareServiceImpl.queryInviteList count is 0");
|
...
|
...
|
@@ -2116,6 +2115,11 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport |
|
|
bo.setDateStr(DateUtil.getDateStrBySecond(bo.getDate(),"yyyy.MM.dd"));
|
|
|
DecimalFormat df = new DecimalFormat("0.00");
|
|
|
bo.setAmountStr("¥"+df.format(bo.getAmount()));
|
|
|
if (bo.getOrderAmount().compareTo(new BigDecimal("0")) > 0) {
|
|
|
bo.setOrderAmountStr("¥" + df.format(bo.getOrderAmount()));
|
|
|
} else {
|
|
|
bo.setOrderAmountStr("-" );
|
|
|
}
|
|
|
unionShareUserInvitesBo.add(bo);
|
|
|
});
|
|
|
response.setList(unionShareUserInvitesBo);
|
...
|
...
|
@@ -2354,10 +2358,14 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport |
|
|
|
|
|
}
|
|
|
if (unionShareOrders.getActivityId() != null&&ShareOrdersStatusEnum.isFailOrder(bo.getStatus())){
|
|
|
//该订单参加了加倍返活动,需要把加倍返日志作废
|
|
|
//该订单参加了加倍返或者邀新下单活动,需要把活动日志作废
|
|
|
UnionShareOrdersActivityLogs activityLog = getLogsByOrderId(unionShareOrders.getId());
|
|
|
if (activityLog != null) {
|
|
|
invalidActivityLog(activityLog.getId(), DateUtil.getCurrentTimeSecond());
|
|
|
if (activityLog.getActivityType() == 6) {
|
|
|
//活动类型6-邀新下单,需要把邀新下单活动佣金减去作废部分
|
|
|
invalidInviteYohoActivityAmount(unionShareOrders.getPromoteUid(), unionShareOrders.getOrderUid(), activityLog.getAmount());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
...
|
...
|
@@ -2451,6 +2459,20 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport |
|
|
updatelogs.setUpdateTime(now);
|
|
|
unionShareOrdersActivityLogsMapper.updateByPrimaryKeySelective(updatelogs);
|
|
|
}
|
|
|
//把邀新下单活动该订单增加的佣金部分减去
|
|
|
private void invalidInviteYohoActivityAmount(int inviterUid,int uid,BigDecimal amount) {
|
|
|
logger.info("invalidInviteYohoActivityAmount,inviterUid is {}, uid is {},amount is {}.",inviterUid, uid,amount);
|
|
|
UnionShareYohoUser unionShareYohoUser = unionShareYohoUserMapper.selectByUidAndInviter(inviterUid, uid);
|
|
|
if (unionShareYohoUser == null) {
|
|
|
return;
|
|
|
}
|
|
|
if (unionShareYohoUser.getOrderAmount().compareTo(amount) < 0) {
|
|
|
//数据有误,邀新佣金的下单总额居然小于单条邀新下单的佣金
|
|
|
logger.error("invalidInviteYohoActivityAmount,inviterUid is {}, uid is {},amount is {},orderAmount is {}.", inviterUid, uid, amount, unionShareYohoUser.getOrderAmount());
|
|
|
amount = unionShareYohoUser.getOrderAmount();
|
|
|
}
|
|
|
unionShareYohoUserMapper.updateOrderAmount(unionShareYohoUser.getId(), 2, amount, DateUtil.getCurrentTimeSeconds());
|
|
|
}
|
|
|
|
|
|
private boolean reJoinSomeExtraActivity(UnionShareOrdersActivityLogs activityLog){
|
|
|
logger.info("reJoinSomeExtraActivity,activityLog is {}",activityLog);
|
...
|
...
|
@@ -2554,6 +2576,7 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport |
|
|
logger.info("dealWithWaitActivity,activity is {},selectUidList",activity);
|
|
|
List<UnionShareOrdersUidBo> uids;
|
|
|
//满单返过滤维度:1-下单人满单,2-分享人满单
|
|
|
//todo 过滤掉参加了活动类型6的订单
|
|
|
if (activity.getExtraUidType() == 2) {
|
|
|
uids = unionShareOrdersMapper.selectPromoteUidList(activity.getStartTime(), activity.getEndTime());
|
|
|
} else {
|
...
|
...
|
@@ -2618,7 +2641,7 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport |
|
|
}
|
|
|
|
|
|
//查询某时间为进行中的活动
|
|
|
//type活动类型:1-特殊返,2-订单返利翻x倍,3-额外返,4-cps新人额外返
|
|
|
//type活动类型:1-特殊返,2-订单返利翻x倍,3-额外返,4-cps新人额外返,5-邀新返, 6-邀新下单
|
|
|
private List<UnionShareOrdersActivity> queryActivityByDate(Integer type,int date) {
|
|
|
logger.info("queryActivityByDate.date is {},type is {}.",date,type);
|
|
|
int dateInt=Integer.valueOf(DateUtil.getDateStrBySecond(date, "yyyyMMdd"));
|
...
|
...
|
@@ -2635,7 +2658,7 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport |
|
|
int beginTime = DateUtil.getLastDayStartInt(date, 0);
|
|
|
int endTime = DateUtil.getLastDayEndInt(date, 0);
|
|
|
// activities=unionShareOrdersActivityMapper.selectByDate(date);
|
|
|
//type活动类型:1-特殊返,2-订单返利翻x倍,3-额外返,4-cps新人额外返
|
|
|
//type活动类型:1-特殊返,2-订单返利翻x倍,3-额外返,4-cps新人额外返,5-邀新返, 6-邀新下单
|
|
|
activities = queryLastDaysIngActivity(type,beginTime,endTime);
|
|
|
if (CollectionUtils.isEmpty(activities)) {
|
|
|
return new ArrayList<>();
|
...
|
...
|
@@ -3036,11 +3059,12 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport |
|
|
return;
|
|
|
}
|
|
|
//活动返利
|
|
|
int type=2;
|
|
|
try {
|
|
|
//type活动类型:1-特殊返,2-订单返利翻x倍,3-额外返,4-cps新人额外返
|
|
|
List<UnionShareOrdersActivity> activityList = queryActivityByDate(2,order.getOrderTime());
|
|
|
List<UnionShareOrdersActivity> activityList = queryActivityByDate(type,order.getOrderTime());
|
|
|
for (UnionShareOrdersActivity a :activityList ) {
|
|
|
if(participateActivity(order,a)) {
|
|
|
if(participateActivity(order,a,type)) {
|
|
|
//参加了活动,参加一个加返活动就可以了
|
|
|
break;
|
|
|
}
|
...
|
...
|
@@ -3053,13 +3077,13 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport |
|
|
|
|
|
|
|
|
/**
|
|
|
* 参加加倍返活动
|
|
|
* 参加加倍返活动、邀新下单
|
|
|
* */
|
|
|
private boolean participateActivity(UnionShareOrders order,UnionShareOrdersActivity activity) {
|
|
|
private boolean participateActivity(UnionShareOrders order,UnionShareOrdersActivity activity,int type) {
|
|
|
logger.info("participateActivity,order is {},activity is {}",order,activity);
|
|
|
//1、判断是否符合活动条件
|
|
|
//活动类型:1-订单返利比例升级,2-订单返利翻x倍,3-额外返
|
|
|
if (activity.getType() != 2) {
|
|
|
if (activity.getType() != type) {
|
|
|
//额外返在活动结束后走定时任务
|
|
|
return false;
|
|
|
}
|
...
|
...
|
@@ -3080,14 +3104,11 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport |
|
|
return false;
|
|
|
}
|
|
|
|
|
|
//1.3 订单金额门槛
|
|
|
if (order.getLastOrderAmount().compareTo(activity.getOrderAmount()) < 0) {
|
|
|
return false;
|
|
|
}
|
|
|
//1.4 加倍返,需要报名才可以返佣
|
|
|
UnionShareOrdersActivityPagePre pagePre=unionOrdersActivityPagePreMapper.selectByUidAndActivityId(order.getPromoteUid(), activity.getId());
|
|
|
if (pagePre == null) {
|
|
|
return false;//未报名
|
|
|
//1.4 订单金额门槛
|
|
|
if (type == 2) {
|
|
|
if (order.getLastOrderAmount().compareTo(activity.getOrderAmount()) < 0) {
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//1.5 拼团订单处理:0-不做处理,1-剔除拼团订单,2-拼团参与
|
...
|
...
|
@@ -3111,17 +3132,43 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport |
|
|
}
|
|
|
}
|
|
|
|
|
|
//1.7 判断资格
|
|
|
if (type == 2) {
|
|
|
// 加倍返,需要报名才可以返佣
|
|
|
UnionShareOrdersActivityPagePre pagePre = unionOrdersActivityPagePreMapper.selectByUidAndActivityId(order.getPromoteUid(), activity.getId());
|
|
|
if (pagePre == null) {
|
|
|
return false;//未报名
|
|
|
}
|
|
|
}
|
|
|
Integer id=null;
|
|
|
if (type == 6) {
|
|
|
//邀新下单,需要有邀新记录且注册和下单时间差不超过7天才可以返佣
|
|
|
UnionShareYohoUser unionShareYohoUser = unionShareYohoUserMapper.selectByUidAndInviter(order.getPromoteUid(), order.getOrderUid());
|
|
|
if (unionShareYohoUser == null) {
|
|
|
return false;
|
|
|
}
|
|
|
if (unionShareYohoUser.getDate()+7*24*3600<order.getOrderTime()) {
|
|
|
return false;
|
|
|
}
|
|
|
id = unionShareYohoUser.getId();
|
|
|
}
|
|
|
|
|
|
//2、参加活动
|
|
|
//2.1 返利金额计算
|
|
|
BigDecimal extraAmount = activity.getAmount();
|
|
|
if (activity.getType() == 2) {
|
|
|
//活动类型:2-订单返利翻x倍
|
|
|
extraAmount = order.getAmount().multiply(new BigDecimal(activity.getPercent()).divide(new BigDecimal(10))).setScale(2,BigDecimal.ROUND_DOWN);
|
|
|
if (activity.getAmount().intValue()>0&&extraAmount.compareTo(activity.getAmount())>0) {
|
|
|
//订单返利金额高于封顶金额
|
|
|
extraAmount = activity.getAmount();
|
|
|
}
|
|
|
}
|
|
|
if (activity.getAmount().intValue()>0&&extraAmount.compareTo(activity.getAmount())>0) {
|
|
|
//订单返利金额高于封顶金额
|
|
|
extraAmount = activity.getAmount();
|
|
|
if (activity.getType() == 6&&order.getLastOrderAmount().compareTo(activity.getOrderAmount())<0) {
|
|
|
//活动类型:6-邀新下单,订单⾦额⼤于等于50,给分享⼈amount元返佣;⼩于50,按照订单⾦额percent%返佣
|
|
|
extraAmount = order.getLastOrderAmount().multiply(new BigDecimal(activity.getPercent()).divide(new BigDecimal(100))).setScale(2,BigDecimal.ROUND_DOWN);
|
|
|
}
|
|
|
|
|
|
order.setExtraAmount(extraAmount);
|
|
|
order.setAmount(order.getAmount().add(extraAmount));
|
|
|
|
...
|
...
|
@@ -3141,6 +3188,11 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport |
|
|
logger.info("participateActivity,order is {},activity is {},log is {}",order,activity,log);
|
|
|
unionShareOrdersActivityLogsMapper.insertSelective(log);
|
|
|
|
|
|
//2.3 更新邀新下单佣金
|
|
|
if (id != null) {
|
|
|
unionShareYohoUserMapper.updateOrderAmount(id,1,extraAmount,log.getCreateTime());
|
|
|
}
|
|
|
|
|
|
//3 更新订单返利金额
|
|
|
UnionShareOrders updateOrder = new UnionShareOrders();
|
|
|
updateOrder.setId(order.getId());
|
...
|
...
|
@@ -3211,14 +3263,27 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport |
|
|
|
|
|
//活动返利
|
|
|
try {
|
|
|
//type活动类型:1-特殊返,2-订单返利翻x倍,3-额外返,4-cps新人额外返
|
|
|
List<UnionShareOrdersActivity> activityList = queryActivityByDate(2,bo.getOrderTime());
|
|
|
for (UnionShareOrdersActivity a :activityList ) {
|
|
|
if(participateActivity(insertReq,a)) {
|
|
|
//参加了活动,参加一个加返活动就可以了
|
|
|
//type活动类型:1-特殊返,2-订单返利翻x倍,3-额外返,4-cps新人额外返,5-邀新返, 6-邀新下单
|
|
|
//优先参加活动类型6
|
|
|
boolean isInviteOrder = false;
|
|
|
List<UnionShareOrdersActivity> inviteActivityList = queryActivityByDate(6,bo.getOrderTime());
|
|
|
for (UnionShareOrdersActivity a :inviteActivityList ) {
|
|
|
if(participateActivity(insertReq,a,6)) {
|
|
|
//参加了活动6-邀新下单
|
|
|
isInviteOrder = true;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
if (!isInviteOrder) {
|
|
|
//不是邀新下单可以参加加倍返活动
|
|
|
List<UnionShareOrdersActivity> activityList = queryActivityByDate(2,bo.getOrderTime());
|
|
|
for (UnionShareOrdersActivity a :activityList ) {
|
|
|
if(participateActivity(insertReq,a,2)) {
|
|
|
//参加了活动,参加一个加返活动就可以了
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
logger.warn("insertOrder warn,fail to handle some activities.bo is {}",bo);
|
|
|
}
|
...
|
...
|
@@ -3717,6 +3782,7 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport |
|
|
redisHashCache.delete(ShareOrdersKeyEnum.USER_SETTLEMENT.getPreKey(),uid);
|
|
|
redisHashCache.delete(ShareOrdersKeyEnum.UNION_TYPE.getPreKey(),uid);
|
|
|
redisHashCache.delete(ShareOrdersKeyEnum.RECENTLY_ORDER_LIMIT_TEN.getPreKey(),uid);
|
|
|
redisHashCache.delete(ShareOrdersKeyEnum.INVITE_YOHO_LIST.getPreKey(),uid);
|
|
|
}
|
|
|
|
|
|
@Override
|
...
|
...
|
|