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
Showing
7 changed files
with
142 additions
and
17 deletions
@@ -7,7 +7,7 @@ import org.slf4j.helpers.MessageFormatter; | @@ -7,7 +7,7 @@ import org.slf4j.helpers.MessageFormatter; | ||
7 | */ | 7 | */ |
8 | public enum ShareOrdersKeyEnum { | 8 | public enum ShareOrdersKeyEnum { |
9 | 9 | ||
10 | - ORDER_LIST("yh:union:share:orderList:","type:{}:status:{}:page:{}:limit:{}",600,"订单列表"), | 10 | + ORDER_LIST("yh:union:share:orderList:","type:{}:tab:{}:status:{}:page:{}:limit:{}",600,"订单列表"), |
11 | ORDER_INFO("yh:union:share:orderInfo:","key:{}:orderCode:{}",600,"订单详情"), | 11 | ORDER_INFO("yh:union:share:orderInfo:","key:{}:orderCode:{}",600,"订单详情"), |
12 | ACTIVITY_ORDER("yh:union:share:activityOrder:","key:{}",600,"订单详情"), | 12 | ACTIVITY_ORDER("yh:union:share:activityOrder:","key:{}",600,"订单详情"), |
13 | USER_SETTLEMENT("yh:union:share:userSettlement:","type:{}",600,"用户提现未提现总计"), | 13 | USER_SETTLEMENT("yh:union:share:userSettlement:","type:{}",600,"用户提现未提现总计"), |
@@ -9,19 +9,20 @@ public enum ShareOrdersStatusEnum { | @@ -9,19 +9,20 @@ public enum ShareOrdersStatusEnum { | ||
9 | 9 | ||
10 | //10-已支付 -> 20-可结算、91-不可结算取消、92-不可结算退货、93-不可结算换货、100 因拆单作废 | 10 | //10-已支付 -> 20-可结算、91-不可结算取消、92-不可结算退货、93-不可结算换货、100 因拆单作废 |
11 | //20-可结算 -> 30-打款中 -> 40-已打款 | 11 | //20-可结算 -> 30-打款中 -> 40-已打款 |
12 | - PAY(1,"10","已支付"), | ||
13 | - CAN_SETTLE(2,"20","可结算"), | ||
14 | - SETTLE(3,"30","打款中"), | ||
15 | - HAS_SETTLE(4,"40","已打款"), | ||
16 | - ORDER_CANCEL(2,"91","不可结算取消"), | ||
17 | - ORDER_RETURN(2,"92","不可结算退货"), | ||
18 | - ORDER_EXCHANGE(2,"93","不可结算换货"), | ||
19 | - ORDER_DISCARD(2,"100","因拆单作废"),//前台不展示100类 | ||
20 | - ACTIVITY_DISCARD(2,"200","活动作废");//前台不展示200类 | 12 | + PAY(1,"10","已支付","待确认"), |
13 | + CAN_SETTLE(2,"20","可结算","已达成"), | ||
14 | + SETTLE(3,"30","打款中","打款中"), | ||
15 | + HAS_SETTLE(4,"40","已打款","已打款"), | ||
16 | + ORDER_CANCEL(2,"91","不可结算取消","未达成"), | ||
17 | + ORDER_RETURN(2,"92","不可结算退货","未达成"), | ||
18 | + ORDER_EXCHANGE(2,"93","不可结算换货","未达成"), | ||
19 | + ORDER_DISCARD(2,"100","因拆单作废","未达成"),//前台不展示100类 | ||
20 | + ACTIVITY_DISCARD(2,"200","活动作废","未达成");//前台不展示200类 | ||
21 | 21 | ||
22 | private int level;//低level可以变为高level | 22 | private int level;//低level可以变为高level |
23 | private String code; | 23 | private String code; |
24 | private String desc; | 24 | private String desc; |
25 | + private String otherDesc; | ||
25 | 26 | ||
26 | ShareOrdersStatusEnum(int level,String code, String desc) { | 27 | ShareOrdersStatusEnum(int level,String code, String desc) { |
27 | this.level = level; | 28 | this.level = level; |
@@ -29,6 +30,13 @@ public enum ShareOrdersStatusEnum { | @@ -29,6 +30,13 @@ public enum ShareOrdersStatusEnum { | ||
29 | this.desc = desc; | 30 | this.desc = desc; |
30 | } | 31 | } |
31 | 32 | ||
33 | + ShareOrdersStatusEnum(int level,String code, String desc, String otherDesc) { | ||
34 | + this.level = level; | ||
35 | + this.code = code; | ||
36 | + this.desc = desc; | ||
37 | + this.otherDesc = otherDesc; | ||
38 | + } | ||
39 | + | ||
32 | public static int getLevelByCode(String code) { | 40 | public static int getLevelByCode(String code) { |
33 | for (ShareOrdersStatusEnum e : values()) { | 41 | for (ShareOrdersStatusEnum e : values()) { |
34 | if (e.getCode().equals(code)) { | 42 | if (e.getCode().equals(code)) { |
@@ -51,6 +59,18 @@ public enum ShareOrdersStatusEnum { | @@ -51,6 +59,18 @@ public enum ShareOrdersStatusEnum { | ||
51 | return null; | 59 | return null; |
52 | } | 60 | } |
53 | 61 | ||
62 | + public static String getOtherDescByCode(String code){ | ||
63 | + if(StringUtils.isEmpty(code)){ | ||
64 | + return null; | ||
65 | + } | ||
66 | + for(ShareOrdersStatusEnum e:values()){ | ||
67 | + if (code.equals(e.getCode())) { | ||
68 | + return e.getOtherDesc(); | ||
69 | + } | ||
70 | + } | ||
71 | + return null; | ||
72 | + } | ||
73 | + | ||
54 | public static boolean isFailOrder(String status) { | 74 | public static boolean isFailOrder(String status) { |
55 | return (!status.equals(ShareOrdersStatusEnum.CAN_SETTLE)) && (ShareOrdersStatusEnum.getLevelByCode(status)==2); | 75 | return (!status.equals(ShareOrdersStatusEnum.CAN_SETTLE)) && (ShareOrdersStatusEnum.getLevelByCode(status)==2); |
56 | } | 76 | } |
@@ -77,4 +97,12 @@ public enum ShareOrdersStatusEnum { | @@ -77,4 +97,12 @@ public enum ShareOrdersStatusEnum { | ||
77 | public void setDesc(String desc) { | 97 | public void setDesc(String desc) { |
78 | this.desc = desc; | 98 | this.desc = desc; |
79 | } | 99 | } |
100 | + | ||
101 | + public String getOtherDesc() { | ||
102 | + return otherDesc; | ||
103 | + } | ||
104 | + | ||
105 | + public void setOtherDesc(String otherDesc) { | ||
106 | + this.otherDesc = otherDesc; | ||
107 | + } | ||
80 | } | 108 | } |
1 | package com.yoho.unions.server.mqconsumer; | 1 | package com.yoho.unions.server.mqconsumer; |
2 | 2 | ||
3 | +import com.yoho.core.common.utils.DateUtil; | ||
3 | import com.yoho.core.common.utils.JsonUtil; | 4 | import com.yoho.core.common.utils.JsonUtil; |
4 | import com.yoho.core.rabbitmq.YhConsumer; | 5 | import com.yoho.core.rabbitmq.YhConsumer; |
5 | import com.yoho.service.model.union.bo.ShareOrderBo; | 6 | import com.yoho.service.model.union.bo.ShareOrderBo; |
@@ -9,7 +10,7 @@ import org.slf4j.LoggerFactory; | @@ -9,7 +10,7 @@ import org.slf4j.LoggerFactory; | ||
9 | import org.springframework.beans.factory.annotation.Autowired; | 10 | import org.springframework.beans.factory.annotation.Autowired; |
10 | import org.springframework.stereotype.Component; | 11 | import org.springframework.stereotype.Component; |
11 | 12 | ||
12 | -import java.util.List; | 13 | +import java.util.*; |
13 | 14 | ||
14 | /** | 15 | /** |
15 | * Created by mingdan.ge on 2018/5/10. | 16 | * Created by mingdan.ge on 2018/5/10. |
@@ -31,15 +32,33 @@ public class UnionShareOrderConsumer implements YhConsumer { | @@ -31,15 +32,33 @@ public class UnionShareOrderConsumer implements YhConsumer { | ||
31 | } | 32 | } |
32 | 33 | ||
33 | List<Object> list = JsonUtil.jsonToObject(o.toString(), List.class); | 34 | List<Object> list = JsonUtil.jsonToObject(o.toString(), List.class); |
35 | + Map<Integer,Set<Integer>> uids = new HashMap<>(); | ||
34 | list.forEach(l->{ | 36 | list.forEach(l->{ |
35 | try { | 37 | try { |
36 | ShareOrderBo bo = JsonUtil.jsonToObject(l.toString(), ShareOrderBo.class); | 38 | ShareOrderBo bo = JsonUtil.jsonToObject(l.toString(), ShareOrderBo.class); |
37 | // 订单插入或更新 | 39 | // 订单插入或更新 |
38 | unionShareService.saveOrUpdateOrder(bo); | 40 | unionShareService.saveOrUpdateOrder(bo); |
41 | + Set<Integer> dates=uids.get(bo.getPromoteUid()); | ||
42 | + if (dates == null) { | ||
43 | + dates = new HashSet<>(); | ||
44 | + } | ||
45 | + dates.add(Integer.valueOf(DateUtil.getDateStrBySecond(bo.getOrderTime(),"yyyyMM"))); | ||
46 | + uids.put(bo.getPromoteUid(), dates); | ||
39 | } catch (Exception e) { | 47 | } catch (Exception e) { |
40 | logger.warn("UnionShareOrderConsumer,handleMessage fail! bo is {}, e {}",l,e.getMessage()); | 48 | logger.warn("UnionShareOrderConsumer,handleMessage fail! bo is {}, e {}",l,e.getMessage()); |
41 | } | 49 | } |
42 | }); | 50 | }); |
51 | + logger.info("UnionShareOrderConsumer,begin to updateMonthData,uids is {},o is {}",uids, o); | ||
52 | + //更新dates月用户月收益数据 | ||
53 | + uids.forEach((u,dates)->{ | ||
54 | + //todo 更新uid月预估收益,里面是否需要校验一下log表和order表 | ||
55 | + try { | ||
56 | + unionShareService.updateMonthData(u,dates); | ||
57 | + } catch (Exception e) { | ||
58 | + logger.warn("UnionShareOrderConsumer,updateMonthData error,uid is {},dates is {},e is {}",u, dates,e.getMessage()); | ||
59 | + } | ||
60 | + }); | ||
61 | + logger.info("UnionShareOrderConsumer,updateMonthData end,uids is {},o is {}",uids, o); | ||
43 | } catch (Exception e) { | 62 | } catch (Exception e) { |
44 | logger.warn("UnionShareOrderConsumer,handleMessage fail! obj is {}, e {}",o,e.getMessage()); | 63 | logger.warn("UnionShareOrderConsumer,handleMessage fail! obj is {}, e {}",o,e.getMessage()); |
45 | } | 64 | } |
@@ -3,6 +3,7 @@ package com.yoho.unions.server.service; | @@ -3,6 +3,7 @@ package com.yoho.unions.server.service; | ||
3 | import java.math.BigDecimal; | 3 | import java.math.BigDecimal; |
4 | import java.util.List; | 4 | import java.util.List; |
5 | import java.util.Map; | 5 | import java.util.Map; |
6 | +import java.util.Set; | ||
6 | 7 | ||
7 | import com.alibaba.fastjson.JSONArray; | 8 | import com.alibaba.fastjson.JSONArray; |
8 | import com.alibaba.fastjson.JSONObject; | 9 | import com.alibaba.fastjson.JSONObject; |
@@ -43,6 +44,8 @@ public interface IUnionShareService { | @@ -43,6 +44,8 @@ public interface IUnionShareService { | ||
43 | */ | 44 | */ |
44 | void saveOrUpdateOrder(ShareOrderBo bo); | 45 | void saveOrUpdateOrder(ShareOrderBo bo); |
45 | 46 | ||
47 | + void updateMonthData(int promoteUid, Set<Integer> date); | ||
48 | + | ||
46 | List<UnionShareOrdersActivity> queryWaitActivity(); | 49 | List<UnionShareOrdersActivity> queryWaitActivity(); |
47 | 50 | ||
48 | void dealWithWaitActivity(UnionShareOrdersActivity activity); | 51 | void dealWithWaitActivity(UnionShareOrdersActivity activity); |
@@ -167,6 +170,11 @@ public interface IUnionShareService { | @@ -167,6 +170,11 @@ public interface IUnionShareService { | ||
167 | UninoShareIncomeRankBo queryRank(UninoShareIncomeRankReqBo bo); | 170 | UninoShareIncomeRankBo queryRank(UninoShareIncomeRankReqBo bo); |
168 | 171 | ||
169 | /** | 172 | /** |
173 | + * 处理马甲用户随机增任务 | ||
174 | + * */ | ||
175 | + void dealWithVirtualUserTask(UnionShareVirtualAddBo bo); | ||
176 | + | ||
177 | + /** | ||
170 | * 查询用户绑定银行卡信息 | 178 | * 查询用户绑定银行卡信息 |
171 | * @param parm | 179 | * @param parm |
172 | * @return | 180 | * @return |
@@ -953,12 +953,18 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport | @@ -953,12 +953,18 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport | ||
953 | return cacheResult; | 953 | return cacheResult; |
954 | } | 954 | } |
955 | //数据库获取数据 | 955 | //数据库获取数据 |
956 | + UnionShareOrders unionShareOrders = unionShareOrdersMapper.selectByPrimaryKey(activityOrderId); | ||
957 | + if (unionShareOrders == null) { | ||
958 | + return null; | ||
959 | + } | ||
956 | UnionShareOrdersActivityLogs activityLog = getLogsByOrderId(activityOrderId); | 960 | UnionShareOrdersActivityLogs activityLog = getLogsByOrderId(activityOrderId); |
957 | if (activityLog == null) { | 961 | if (activityLog == null) { |
958 | return null; | 962 | return null; |
959 | } | 963 | } |
960 | UnionShareOrdersActivity activity=queryActivity(activityLog.getActivityId()); | 964 | UnionShareOrdersActivity activity=queryActivity(activityLog.getActivityId()); |
961 | UnionShareOrdersActivityLogsBo activityLogBo = new UnionShareOrdersActivityLogsBo(); | 965 | UnionShareOrdersActivityLogsBo activityLogBo = new UnionShareOrdersActivityLogsBo(); |
966 | + activityLogBo.setStatus(unionShareOrders.getStatus()); | ||
967 | + activityLogBo.setStatusStr(ShareOrdersStatusEnum.getOtherDescByCode(unionShareOrders.getStatus())); | ||
962 | activityLogBo.setActivityName(activityLog.getActivityName()); | 968 | activityLogBo.setActivityName(activityLog.getActivityName()); |
963 | DecimalFormat df1 = new DecimalFormat("0.00"); | 969 | DecimalFormat df1 = new DecimalFormat("0.00"); |
964 | if (activityLog.getStatus() == 0) { | 970 | if (activityLog.getStatus() == 0) { |
@@ -1048,9 +1054,10 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport | @@ -1048,9 +1054,10 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport | ||
1048 | 1054 | ||
1049 | @Override | 1055 | @Override |
1050 | public PageResponseBO<UnionShareOrders> queryOrderList(UnionShareOrderReqBO unionShareOrderReqBO) { | 1056 | public PageResponseBO<UnionShareOrders> queryOrderList(UnionShareOrderReqBO unionShareOrderReqBO) { |
1057 | + logger.info("queryOrderList,bo is {}",unionShareOrderReqBO); | ||
1051 | //先从缓存获取 | 1058 | //先从缓存获取 |
1052 | - PageResponseBO<UnionShareOrders> cacheResult = getFromRedis(ShareOrdersKeyEnum.ORDER_LIST, unionShareOrderReqBO.getUid(),PageResponseBO.class, unionShareOrderReqBO.getTab1().toString(), | ||
1053 | - unionShareOrderReqBO.getTab2().toString(), String.valueOf(unionShareOrderReqBO.getPage()), String.valueOf(unionShareOrderReqBO.getSize()),unionShareOrderReqBO.getType().toString()); | 1059 | + PageResponseBO<UnionShareOrders> cacheResult = getFromRedis(ShareOrdersKeyEnum.ORDER_LIST, unionShareOrderReqBO.getUid(),PageResponseBO.class,unionShareOrderReqBO.getType().toString(), unionShareOrderReqBO.getTab1().toString(), |
1060 | + unionShareOrderReqBO.getTab2().toString(), String.valueOf(unionShareOrderReqBO.getPage()), String.valueOf(unionShareOrderReqBO.getSize())); | ||
1054 | if (cacheResult != null) { | 1061 | if (cacheResult != null) { |
1055 | logger.debug("UnionShareServiceImpl :: queryOrderList get redis cache ,uid is {},cacheResult is {}",unionShareOrderReqBO.getUid(),cacheResult); | 1062 | logger.debug("UnionShareServiceImpl :: queryOrderList get redis cache ,uid is {},cacheResult is {}",unionShareOrderReqBO.getUid(),cacheResult); |
1056 | return cacheResult; | 1063 | return cacheResult; |
@@ -1079,8 +1086,8 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport | @@ -1079,8 +1086,8 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport | ||
1079 | } | 1086 | } |
1080 | response.setList(unionShareOrdersList); | 1087 | response.setList(unionShareOrdersList); |
1081 | //设置缓存 | 1088 | //设置缓存 |
1082 | - addToRedis(ShareOrdersKeyEnum.ORDER_LIST,unionShareOrderReqBO.getUid(),response,unionShareOrderReqBO.getTab1().toString(), unionShareOrderReqBO.getTab2().toString(), | ||
1083 | - String.valueOf(unionShareOrderReqBO.getPage()), String.valueOf(unionShareOrderReqBO.getSize()),unionShareOrderReqBO.getType().toString()); | 1089 | + addToRedis(ShareOrdersKeyEnum.ORDER_LIST,unionShareOrderReqBO.getUid(),response,unionShareOrderReqBO.getType().toString(),unionShareOrderReqBO.getTab1().toString(), unionShareOrderReqBO.getTab2().toString(), |
1090 | + String.valueOf(unionShareOrderReqBO.getPage()), String.valueOf(unionShareOrderReqBO.getSize())); | ||
1084 | return response; | 1091 | return response; |
1085 | } | 1092 | } |
1086 | 1093 | ||
@@ -2022,5 +2029,20 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport | @@ -2022,5 +2029,20 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport | ||
2022 | 2029 | ||
2023 | return paramMap; | 2030 | return paramMap; |
2024 | } | 2031 | } |
2025 | - | 2032 | + |
2033 | + /** | ||
2034 | + * 更新联盟用户月预估收入 | ||
2035 | + * */ | ||
2036 | + @Override | ||
2037 | + public void updateMonthData(int promoteUid, Set<Integer> date){ | ||
2038 | + //todo | ||
2039 | + } | ||
2040 | + | ||
2041 | + /** | ||
2042 | + * 处理马甲用户随机增任务 | ||
2043 | + * */ | ||
2044 | + @Override | ||
2045 | + public void dealWithVirtualUserTask(UnionShareVirtualAddBo bo){ | ||
2046 | + //todo | ||
2047 | + } | ||
2026 | } | 2048 | } |
1 | +package com.yoho.unions.server.task; | ||
2 | + | ||
3 | +import com.yoho.service.model.union.bo.UnionShareVirtualAddBo; | ||
4 | +import com.yoho.unions.common.redis.RedisValueCache; | ||
5 | +import com.yoho.unions.dal.model.UnionShareOrdersActivity; | ||
6 | +import com.yoho.unions.server.service.IUnionShareService; | ||
7 | +import org.apache.commons.collections.CollectionUtils; | ||
8 | +import org.slf4j.Logger; | ||
9 | +import org.slf4j.LoggerFactory; | ||
10 | +import org.springframework.beans.factory.annotation.Autowired; | ||
11 | +import org.springframework.scheduling.annotation.Scheduled; | ||
12 | +import org.springframework.stereotype.Component; | ||
13 | + | ||
14 | +import javax.annotation.Resource; | ||
15 | +import java.util.List; | ||
16 | + | ||
17 | +/** | ||
18 | + * 马甲用户隔日随机增 | ||
19 | + * Created by mingdan.ge on 2018/8/8. | ||
20 | + */ | ||
21 | +@Component | ||
22 | +public class CpsVirtualUserTask { | ||
23 | + | ||
24 | + private Logger logger = LoggerFactory.getLogger(CpsVirtualUserTask.class); | ||
25 | + | ||
26 | + @Autowired | ||
27 | + IUnionShareService unionShareService; | ||
28 | + | ||
29 | + @Resource | ||
30 | + RedisValueCache redisValueCache; | ||
31 | + | ||
32 | + private static String VIRTUAL_ADD_KEY = "yh:union:share:virtual:add"; | ||
33 | + | ||
34 | + // 每天07:30执行 | ||
35 | + @Scheduled(cron = "* 30 7 * * ?") | ||
36 | + public void run() { | ||
37 | + logger.info("CpsVirtualUserTask.run,query redis for virtual."); | ||
38 | + //查询是否有随机增是预操作 | ||
39 | + UnionShareVirtualAddBo addBo=redisValueCache.get(VIRTUAL_ADD_KEY, UnionShareVirtualAddBo.class); | ||
40 | + if (addBo == null) { | ||
41 | + logger.info("CpsVirtualUserTask.run,query redis for virtual end.does not need"); | ||
42 | + } | ||
43 | + logger.info("CpsVirtualUserTask.run,start to deal with {}.",addBo); | ||
44 | + //todo 随机增当月数据 | ||
45 | + unionShareService.dealWithVirtualUserTask(addBo); | ||
46 | + | ||
47 | + } | ||
48 | +} |
@@ -16,7 +16,7 @@ qiniu.secretkey=pyoJzPygXIkFWrc1BAsH6tAJ0yweTchpJwGKEwhm | @@ -16,7 +16,7 @@ qiniu.secretkey=pyoJzPygXIkFWrc1BAsH6tAJ0yweTchpJwGKEwhm | ||
16 | qiniu.domain = test | 16 | qiniu.domain = test |
17 | qiniu.bucket = test | 17 | qiniu.bucket = test |
18 | 18 | ||
19 | -zkAddress=192.168.102.45:2181 | 19 | +zkAddress=127.0.0.1:2181 |
20 | # web context | 20 | # web context |
21 | web.context=union | 21 | web.context=union |
22 | 22 |
-
Please register or login to post a comment