...
|
...
|
@@ -19,6 +19,8 @@ import java.util.stream.Collectors; |
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
|
import com.yoho.service.model.union.request.*;
|
|
|
import com.yoho.service.model.union.response.*;
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.elasticsearch.common.collect.Maps;
|
...
|
...
|
@@ -57,20 +59,6 @@ import com.yoho.service.model.union.bo.UnionShareOrdersUidBo; |
|
|
import com.yoho.service.model.union.bo.UnionShareUserBankBo;
|
|
|
import com.yoho.service.model.union.bo.UnionShareUserBo;
|
|
|
import com.yoho.service.model.union.bo.UnionShareVirtualAddBo;
|
|
|
import com.yoho.service.model.union.request.UninoShareIncomeRankReqBo;
|
|
|
import com.yoho.service.model.union.request.UnionShareMessageReqBO;
|
|
|
import com.yoho.service.model.union.request.UnionShareOrderReqBO;
|
|
|
import com.yoho.service.model.union.request.UnionShareOrderSearchReqBO;
|
|
|
import com.yoho.service.model.union.request.UnionShareOrdersMonthReqBO;
|
|
|
import com.yoho.service.model.union.request.UnionShareUserApplyListReqBo;
|
|
|
import com.yoho.service.model.union.request.UnionShareUserApplyReqBo;
|
|
|
import com.yoho.service.model.union.request.UnionShareUserBankListReqBo;
|
|
|
import com.yoho.service.model.union.response.PageResponseBO;
|
|
|
import com.yoho.service.model.union.response.PageUnionShareOrderRspBO;
|
|
|
import com.yoho.service.model.union.response.UnionShareOrderRspBO;
|
|
|
import com.yoho.service.model.union.response.UnionShareStatisticsRspBO;
|
|
|
import com.yoho.service.model.union.response.UnionShareUserApplyListBo;
|
|
|
import com.yoho.service.model.union.response.UnionShareUserBankListBO;
|
|
|
import com.yoho.unions.common.enums.BankEnum;
|
|
|
import com.yoho.unions.common.enums.ShareOrdersKeyEnum;
|
|
|
import com.yoho.unions.common.enums.ShareOrdersStatusEnum;
|
...
|
...
|
@@ -436,6 +424,34 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport |
|
|
result.setTotal(total);
|
|
|
return result;
|
|
|
}
|
|
|
/**
|
|
|
* 查询申请记录
|
|
|
* @param req
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
public PageResponseBO<UnionShareUserRspBo> queryUnionShareUsers(UnionShareUserReqBO req) {
|
|
|
logger.info("queryUnionShareUsers.req is {}",req);
|
|
|
int total=this.unionShareUserMapper.selectTotalByCondition(req);
|
|
|
if(total==0){
|
|
|
logger.info("queryUnionShareUsers end.req is {},total is 0",req);
|
|
|
return null;
|
|
|
}
|
|
|
List<UnionShareUserRspBo> list=this.unionShareUserMapper.selectByCondition(req);
|
|
|
List<String> unionTypeList = list.stream().map(bo -> bo.getUnionType()).collect(Collectors.toList());
|
|
|
Map<Long, MktMarketingUrl> longMktMarketingUrlMap = mktMarketingUrlDAO.selectByUnionTypes(unionTypeList);
|
|
|
list.forEach(u->{
|
|
|
if (longMktMarketingUrlMap.containsKey(Long.valueOf(u.getUnionType()))) {
|
|
|
u.setUnionName(longMktMarketingUrlMap.get(Long.valueOf(u.getUnionType())).getName());
|
|
|
}
|
|
|
});
|
|
|
PageResponseBO<UnionShareUserRspBo> result=new PageResponseBO<>();
|
|
|
result.setList(list);
|
|
|
result.setPage(req.getPage());
|
|
|
result.setSize(req.getSize());
|
|
|
result.setTotal(total);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
private void covertSocialMedia(UnionShareUserApplyListBo bo) {
|
|
|
if (null != bo.getSocialMedia()) {
|
...
|
...
|
@@ -1369,21 +1385,21 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport |
|
|
if (result > 0 && (unionShareOrders.getExtraActivityId() != null||unionShareOrders.getExtraActivityId() != null)) {
|
|
|
if (ShareOrdersStatusEnum.isFailOrder(bo.getStatus())) {
|
|
|
//订单不可参与活动,重新处理该单参与的满单返
|
|
|
if (unionShareOrders.getExtraActivityId() != null) {
|
|
|
rehandSomeExtraActivity(unionShareOrders.getOrderUid(),unionShareOrders.getPromoteUid(),unionShareOrders.getExtraActivityId());
|
|
|
if (unionShareOrders.getExtraActivityId() != null && unionShareOrders.getExtraActivityId() > 0) {
|
|
|
rehandSomeExtraActivity(unionShareOrders.getOrderUid(), unionShareOrders.getPromoteUid(), unionShareOrders.getExtraActivityId());
|
|
|
}
|
|
|
if (unionShareOrders.getCpsExtraActivityId() != null) {
|
|
|
rehandSomeExtraActivity(null,unionShareOrders.getPromoteUid(),unionShareOrders.getCpsExtraActivityId());
|
|
|
if (unionShareOrders.getCpsExtraActivityId() != null && unionShareOrders.getCpsExtraActivityId() > 0) {
|
|
|
rehandSomeExtraActivity(null, unionShareOrders.getPromoteUid(), unionShareOrders.getCpsExtraActivityId());
|
|
|
}
|
|
|
}
|
|
|
if (ShareOrdersStatusEnum.CAN_SETTLE.getCode().equals(bo.getStatus())
|
|
|
|| ShareOrdersStatusEnum.getLevelByCode(bo.getStatus()) > ShareOrdersStatusEnum.CAN_SETTLE.getLevel()) {
|
|
|
//有效订单已完结,判断是否需要把该单的满返活动状态改成可结算
|
|
|
if (unionShareOrders.getExtraActivityId() != null) {
|
|
|
changeSomeExtraActivityStatus(unionShareOrders.getOrderUid(),unionShareOrders.getPromoteUid(),unionShareOrders.getExtraActivityId());
|
|
|
if (unionShareOrders.getExtraActivityId() != null && unionShareOrders.getExtraActivityId() > 0) {
|
|
|
changeSomeExtraActivityStatus(unionShareOrders.getOrderUid(), unionShareOrders.getPromoteUid(), unionShareOrders.getExtraActivityId());
|
|
|
}
|
|
|
if (unionShareOrders.getCpsExtraActivityId() != null) {
|
|
|
changeSomeExtraActivityStatus(null,unionShareOrders.getPromoteUid(),unionShareOrders.getCpsExtraActivityId());
|
|
|
if (unionShareOrders.getCpsExtraActivityId() != null && unionShareOrders.getCpsExtraActivityId() > 0) {
|
|
|
changeSomeExtraActivityStatus(null, unionShareOrders.getPromoteUid(), unionShareOrders.getCpsExtraActivityId());
|
|
|
}
|
|
|
}
|
|
|
|
...
|
...
|
@@ -1400,12 +1416,12 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport |
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取订单参与的满单返活动返利单
|
|
|
* 获取订单参与的满返活动返利单
|
|
|
* */
|
|
|
private UnionShareOrders getRelatedActivityOrder(Integer orderUid,int promoteUid,int activityId) {
|
|
|
logger.info("getRelatedActivityOrder,orderUid is {},,promoteUid is {},activityId is {}.",orderUid,promoteUid,activityId);
|
|
|
UnionShareOrdersActivity activity = queryActivity(activityId);
|
|
|
if (null == activity || activity.getType() != 3) {
|
|
|
if (null == activity || (activity.getType() != 3&& activity.getType() != 4)) {
|
|
|
return null;
|
|
|
}
|
|
|
//
|
...
|
...
|
@@ -1530,15 +1546,25 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport |
|
|
public void dealWithCpsNewUserActivity(UnionShareOrdersActivity activity,int beginTime,int endTime,int orderEndTime) {
|
|
|
logger.info("dealWithCpsNewUserActivity,activity is {},beginTime is {},endTime is {},orderEndTime is {}.",activity,beginTime,endTime,orderEndTime);
|
|
|
//查询可以参与活动的uid
|
|
|
Set<Integer> uids=unionShareUserApplyMapper.selectUidListByTime(activity.getStartTime(), activity.getEndTime());
|
|
|
if (activity.getStartTime() > beginTime) {
|
|
|
beginTime = activity.getStartTime();
|
|
|
}
|
|
|
if (activity.getEndTime() < endTime) {
|
|
|
endTime = activity.getEndTime();
|
|
|
}
|
|
|
if (endTime <= beginTime) {
|
|
|
return;
|
|
|
}
|
|
|
Set<Integer> uids=unionShareUserApplyMapper.selectUidListByTime(beginTime, endTime);
|
|
|
logger.info("dealWithCpsNewUserActivity,activity is {},beginTime is {},endTime is {},orderEndTime is {},selectUidListByTime, uids is {}",activity,beginTime,endTime,orderEndTime,uids);
|
|
|
if (CollectionUtils.isEmpty(uids)) {
|
|
|
return;
|
|
|
}
|
|
|
//查询uid名下分享订单
|
|
|
Map<Integer, List<UnionShareOrders>> uidOrders=unionShareOrdersMapper.selectNewPromoteUidsOrder(uids, orderEndTime);
|
|
|
List<UnionShareOrders> orders=unionShareOrdersMapper.selectNewPromoteUidsOrder(uids, orderEndTime);
|
|
|
Map<Integer, List<UnionShareOrders>> uidOrders=orders.stream().collect(Collectors.groupingBy(UnionShareOrders::getPromoteUid));
|
|
|
uids.forEach(u->{
|
|
|
joinNewCpsActivity(u,uidOrders.get(u), activity.getId());
|
|
|
joinNewCpsActivity(u, uidOrders.get(u), activity.getId());
|
|
|
});
|
|
|
|
|
|
//发放完成
|
...
|
...
|
@@ -1585,7 +1611,7 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport |
|
|
@Override
|
|
|
public List<UnionShareOrdersActivity> queryLastDaysIngActivity(int beginTime,int endTime) {
|
|
|
logger.info("queryLastDaysActivity.beginTime is {},endTime is {}.",beginTime,endTime);
|
|
|
if (beginTime <= endTime) {
|
|
|
if (beginTime >= endTime) {
|
|
|
return null;
|
|
|
}
|
|
|
|
...
|
...
|
@@ -1593,26 +1619,27 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport |
|
|
return activities;
|
|
|
}
|
|
|
|
|
|
//查询进行中的活动
|
|
|
private List<UnionShareOrdersActivity> queryActivity() {
|
|
|
logger.info("queryActivity.");
|
|
|
String activitiesCache = redisValueCache.get(ShareOrdersKeyEnum.ACTIVITY_ING_LIST.getPreKey(), String.class);
|
|
|
//查询某时间为进行中的活动
|
|
|
private List<UnionShareOrdersActivity> queryActivityByDate(int date) {
|
|
|
logger.info("queryActivityByDate.date is {}.",date);
|
|
|
String dateStr=DateUtil.getDateStrBySecond(date, "yyyyMMdd");
|
|
|
String activitiesCache = redisValueCache.get(ShareOrdersKeyEnum.ACTIVITY_ING_LIST.getPreKey()+dateStr, String.class);
|
|
|
List<UnionShareOrdersActivity> activities;
|
|
|
if (activitiesCache != null) {
|
|
|
activities = JSONObject.parseArray(activitiesCache, UnionShareOrdersActivity.class);
|
|
|
if (CollectionUtils.isNotEmpty(activities)) {
|
|
|
logger.info("queryActivity.get chache {}",activities);
|
|
|
logger.info("queryActivityByDate.date is {},dateStr is {},get chache {}",date,dateStr,activities);
|
|
|
return activities;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
activities=unionShareOrdersActivityMapper.selectByDate(DateUtil.getCurrentTimeSecond());
|
|
|
activities=unionShareOrdersActivityMapper.selectByDate(date);
|
|
|
if (CollectionUtils.isEmpty(activities)) {
|
|
|
return new ArrayList<>();
|
|
|
}
|
|
|
logger.info("queryActivity.add to redis.value is {}",activities);
|
|
|
redisValueCache.set(ShareOrdersKeyEnum.ACTIVITY_ING_LIST.getPreKey(),activities,ShareOrdersKeyEnum.ACTIVITY_ING_LIST.getCacheTime(),TimeUnit.SECONDS);
|
|
|
logger.info("queryActivityByDate.add to redis.value is {}",activities);
|
|
|
redisValueCache.set(ShareOrdersKeyEnum.ACTIVITY_ING_LIST.getPreKey()+dateStr,activities,ShareOrdersKeyEnum.ACTIVITY_ING_LIST.getCacheTime(),TimeUnit.SECONDS);
|
|
|
return activities;
|
|
|
}
|
|
|
//获取某时间段可参与活动的单数
|
...
|
...
|
@@ -1985,7 +2012,7 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport |
|
|
unionShareOrdersMapper.insertSelective(insertReq);
|
|
|
//活动返利
|
|
|
try {
|
|
|
List<UnionShareOrdersActivity> activityList = queryActivity();
|
|
|
List<UnionShareOrdersActivity> activityList = queryActivityByDate(bo.getOrderTime());
|
|
|
for (UnionShareOrdersActivity a :activityList ) {
|
|
|
if(participateActivity(insertReq,a)) {
|
|
|
//参加了活动,参加一个加返活动就可以了
|
...
|
...
|
@@ -2253,8 +2280,7 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport |
|
|
bo.setOrderCodes(orderCodes);
|
|
|
bo.setOrderList(orderList);
|
|
|
bo.setActivities(activityBos);
|
|
|
System.out.println(JsonUtil.objectToJSON(bo));
|
|
|
mqLog.info("relateSettlementAndOrder,send mq {} to erp,uid is {},settlementCode is {},bo is {}", SETTLEMENT_TOPIC, uid, settlementCode, bo);
|
|
|
mqLog.info("relateSettlementAndOrder,send mq {} to erp,uid is {},settlementCode is {},bo is {}", SETTLEMENT_TOPIC, uid, settlementCode, JsonUtil.objectToJSON(bo));
|
|
|
yhProducer.send(SETTLEMENT_TOPIC, bo);
|
|
|
settlementLog.info("relateSettlementAndOrder,send mq {} to erp success,uid is {},settlementCode is {},bo is {}", SETTLEMENT_TOPIC, uid, settlementCode, bo);
|
|
|
return totalAmount;
|
...
|
...
|
|