Authored by caoyan

Merge branch 'dev_180724_cps四期' of http://git.yoho.cn/yoho30/yohobuy-union into dev_180724_cps四期

# Conflicts:
#	server/src/main/java/com/yoho/unions/server/service/IUnionShareService.java
... ... @@ -7,7 +7,7 @@ import org.slf4j.helpers.MessageFormatter;
*/
public enum ShareOrdersKeyEnum {
ORDER_LIST("yh:union:share:orderList:","type:{}:status:{}:page:{}:limit:{}",600,"订单列表"),
ORDER_LIST("yh:union:share:orderList:","type:{}:tab:{}:status:{}:page:{}:limit:{}",600,"订单列表"),
ORDER_INFO("yh:union:share:orderInfo:","key:{}:orderCode:{}",600,"订单详情"),
ACTIVITY_ORDER("yh:union:share:activityOrder:","key:{}",600,"订单详情"),
USER_SETTLEMENT("yh:union:share:userSettlement:","type:{}",600,"用户提现未提现总计"),
... ...
... ... @@ -9,19 +9,20 @@ public enum ShareOrdersStatusEnum {
//10-已支付 -> 20-可结算、91-不可结算取消、92-不可结算退货、93-不可结算换货、100 因拆单作废
//20-可结算 -> 30-打款中 -> 40-已打款
PAY(1,"10","已支付"),
CAN_SETTLE(2,"20","可结算"),
SETTLE(3,"30","打款中"),
HAS_SETTLE(4,"40","已打款"),
ORDER_CANCEL(2,"91","不可结算取消"),
ORDER_RETURN(2,"92","不可结算退货"),
ORDER_EXCHANGE(2,"93","不可结算换货"),
ORDER_DISCARD(2,"100","因拆单作废"),//前台不展示100类
ACTIVITY_DISCARD(2,"200","活动作废");//前台不展示200类
PAY(1,"10","已支付","待确认"),
CAN_SETTLE(2,"20","可结算","已达成"),
SETTLE(3,"30","打款中","打款中"),
HAS_SETTLE(4,"40","已打款","已打款"),
ORDER_CANCEL(2,"91","不可结算取消","未达成"),
ORDER_RETURN(2,"92","不可结算退货","未达成"),
ORDER_EXCHANGE(2,"93","不可结算换货","未达成"),
ORDER_DISCARD(2,"100","因拆单作废","未达成"),//前台不展示100类
ACTIVITY_DISCARD(2,"200","活动作废","未达成");//前台不展示200类
private int level;//低level可以变为高level
private String code;
private String desc;
private String otherDesc;
ShareOrdersStatusEnum(int level,String code, String desc) {
this.level = level;
... ... @@ -29,6 +30,13 @@ public enum ShareOrdersStatusEnum {
this.desc = desc;
}
ShareOrdersStatusEnum(int level,String code, String desc, String otherDesc) {
this.level = level;
this.code = code;
this.desc = desc;
this.otherDesc = otherDesc;
}
public static int getLevelByCode(String code) {
for (ShareOrdersStatusEnum e : values()) {
if (e.getCode().equals(code)) {
... ... @@ -51,6 +59,18 @@ public enum ShareOrdersStatusEnum {
return null;
}
public static String getOtherDescByCode(String code){
if(StringUtils.isEmpty(code)){
return null;
}
for(ShareOrdersStatusEnum e:values()){
if (code.equals(e.getCode())) {
return e.getOtherDesc();
}
}
return null;
}
public static boolean isFailOrder(String status) {
return (!status.equals(ShareOrdersStatusEnum.CAN_SETTLE)) && (ShareOrdersStatusEnum.getLevelByCode(status)==2);
}
... ... @@ -77,4 +97,12 @@ public enum ShareOrdersStatusEnum {
public void setDesc(String desc) {
this.desc = desc;
}
public String getOtherDesc() {
return otherDesc;
}
public void setOtherDesc(String otherDesc) {
this.otherDesc = otherDesc;
}
}
... ...
package com.yoho.unions.server.mqconsumer;
import com.yoho.core.common.utils.DateUtil;
import com.yoho.core.common.utils.JsonUtil;
import com.yoho.core.rabbitmq.YhConsumer;
import com.yoho.service.model.union.bo.ShareOrderBo;
... ... @@ -9,7 +10,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.*;
/**
* Created by mingdan.ge on 2018/5/10.
... ... @@ -31,15 +32,33 @@ public class UnionShareOrderConsumer implements YhConsumer {
}
List<Object> list = JsonUtil.jsonToObject(o.toString(), List.class);
Map<Integer,Set<Integer>> uids = new HashMap<>();
list.forEach(l->{
try {
ShareOrderBo bo = JsonUtil.jsonToObject(l.toString(), ShareOrderBo.class);
// 订单插入或更新
unionShareService.saveOrUpdateOrder(bo);
Set<Integer> dates=uids.get(bo.getPromoteUid());
if (dates == null) {
dates = new HashSet<>();
}
dates.add(Integer.valueOf(DateUtil.getDateStrBySecond(bo.getOrderTime(),"yyyyMM")));
uids.put(bo.getPromoteUid(), dates);
} catch (Exception e) {
logger.warn("UnionShareOrderConsumer,handleMessage fail! bo is {}, e {}",l,e.getMessage());
}
});
logger.info("UnionShareOrderConsumer,begin to updateMonthData,uids is {},o is {}",uids, o);
//更新dates月用户月收益数据
uids.forEach((u,dates)->{
//todo 更新uid月预估收益,里面是否需要校验一下log表和order表
try {
unionShareService.updateMonthData(u,dates);
} catch (Exception e) {
logger.warn("UnionShareOrderConsumer,updateMonthData error,uid is {},dates is {},e is {}",u, dates,e.getMessage());
}
});
logger.info("UnionShareOrderConsumer,updateMonthData end,uids is {},o is {}",uids, o);
} catch (Exception e) {
logger.warn("UnionShareOrderConsumer,handleMessage fail! obj is {}, e {}",o,e.getMessage());
}
... ...
... ... @@ -3,6 +3,7 @@ package com.yoho.unions.server.service;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
import java.util.Set;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
... ... @@ -43,6 +44,8 @@ public interface IUnionShareService {
*/
void saveOrUpdateOrder(ShareOrderBo bo);
void updateMonthData(int promoteUid, Set<Integer> date);
List<UnionShareOrdersActivity> queryWaitActivity();
void dealWithWaitActivity(UnionShareOrdersActivity activity);
... ... @@ -167,6 +170,11 @@ public interface IUnionShareService {
UninoShareIncomeRankBo queryRank(UninoShareIncomeRankReqBo bo);
/**
* 处理马甲用户随机增任务
* */
void dealWithVirtualUserTask(UnionShareVirtualAddBo bo);
/**
* 查询用户绑定银行卡信息
* @param parm
* @return
... ...
... ... @@ -953,12 +953,18 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
return cacheResult;
}
//数据库获取数据
UnionShareOrders unionShareOrders = unionShareOrdersMapper.selectByPrimaryKey(activityOrderId);
if (unionShareOrders == null) {
return null;
}
UnionShareOrdersActivityLogs activityLog = getLogsByOrderId(activityOrderId);
if (activityLog == null) {
return null;
}
UnionShareOrdersActivity activity=queryActivity(activityLog.getActivityId());
UnionShareOrdersActivityLogsBo activityLogBo = new UnionShareOrdersActivityLogsBo();
activityLogBo.setStatus(unionShareOrders.getStatus());
activityLogBo.setStatusStr(ShareOrdersStatusEnum.getOtherDescByCode(unionShareOrders.getStatus()));
activityLogBo.setActivityName(activityLog.getActivityName());
DecimalFormat df1 = new DecimalFormat("0.00");
if (activityLog.getStatus() == 0) {
... ... @@ -1048,9 +1054,10 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
@Override
public PageResponseBO<UnionShareOrders> queryOrderList(UnionShareOrderReqBO unionShareOrderReqBO) {
logger.info("queryOrderList,bo is {}",unionShareOrderReqBO);
//先从缓存获取
PageResponseBO<UnionShareOrders> cacheResult = getFromRedis(ShareOrdersKeyEnum.ORDER_LIST, unionShareOrderReqBO.getUid(),PageResponseBO.class, unionShareOrderReqBO.getTab1().toString(),
unionShareOrderReqBO.getTab2().toString(), String.valueOf(unionShareOrderReqBO.getPage()), String.valueOf(unionShareOrderReqBO.getSize()),unionShareOrderReqBO.getType().toString());
PageResponseBO<UnionShareOrders> cacheResult = getFromRedis(ShareOrdersKeyEnum.ORDER_LIST, unionShareOrderReqBO.getUid(),PageResponseBO.class,unionShareOrderReqBO.getType().toString(), unionShareOrderReqBO.getTab1().toString(),
unionShareOrderReqBO.getTab2().toString(), String.valueOf(unionShareOrderReqBO.getPage()), String.valueOf(unionShareOrderReqBO.getSize()));
if (cacheResult != null) {
logger.debug("UnionShareServiceImpl :: queryOrderList get redis cache ,uid is {},cacheResult is {}",unionShareOrderReqBO.getUid(),cacheResult);
return cacheResult;
... ... @@ -1079,8 +1086,8 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
}
response.setList(unionShareOrdersList);
//设置缓存
addToRedis(ShareOrdersKeyEnum.ORDER_LIST,unionShareOrderReqBO.getUid(),response,unionShareOrderReqBO.getTab1().toString(), unionShareOrderReqBO.getTab2().toString(),
String.valueOf(unionShareOrderReqBO.getPage()), String.valueOf(unionShareOrderReqBO.getSize()),unionShareOrderReqBO.getType().toString());
addToRedis(ShareOrdersKeyEnum.ORDER_LIST,unionShareOrderReqBO.getUid(),response,unionShareOrderReqBO.getType().toString(),unionShareOrderReqBO.getTab1().toString(), unionShareOrderReqBO.getTab2().toString(),
String.valueOf(unionShareOrderReqBO.getPage()), String.valueOf(unionShareOrderReqBO.getSize()));
return response;
}
... ... @@ -2022,5 +2029,20 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
return paramMap;
}
/**
* 更新联盟用户月预估收入
* */
@Override
public void updateMonthData(int promoteUid, Set<Integer> date){
//todo
}
/**
* 处理马甲用户随机增任务
* */
@Override
public void dealWithVirtualUserTask(UnionShareVirtualAddBo bo){
//todo
}
}
... ...
package com.yoho.unions.server.task;
import com.yoho.service.model.union.bo.UnionShareVirtualAddBo;
import com.yoho.unions.common.redis.RedisValueCache;
import com.yoho.unions.dal.model.UnionShareOrdersActivity;
import com.yoho.unions.server.service.IUnionShareService;
import org.apache.commons.collections.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.List;
/**
* 马甲用户隔日随机增
* Created by mingdan.ge on 2018/8/8.
*/
@Component
public class CpsVirtualUserTask {
private Logger logger = LoggerFactory.getLogger(CpsVirtualUserTask.class);
@Autowired
IUnionShareService unionShareService;
@Resource
RedisValueCache redisValueCache;
private static String VIRTUAL_ADD_KEY = "yh:union:share:virtual:add";
// 每天07:30执行
@Scheduled(cron = "* 30 7 * * ?")
public void run() {
logger.info("CpsVirtualUserTask.run,query redis for virtual.");
//查询是否有随机增是预操作
UnionShareVirtualAddBo addBo=redisValueCache.get(VIRTUAL_ADD_KEY, UnionShareVirtualAddBo.class);
if (addBo == null) {
logger.info("CpsVirtualUserTask.run,query redis for virtual end.does not need");
}
logger.info("CpsVirtualUserTask.run,start to deal with {}.",addBo);
//todo 随机增当月数据
unionShareService.dealWithVirtualUserTask(addBo);
}
}
... ...
... ... @@ -16,7 +16,7 @@ qiniu.secretkey=pyoJzPygXIkFWrc1BAsH6tAJ0yweTchpJwGKEwhm
qiniu.domain = test
qiniu.bucket = test
zkAddress=192.168.102.45:2181
zkAddress=127.0.0.1:2181
# web context
web.context=union
... ...