Merge branch 'dev_180508_联盟红人推广' of http://git.yoho.cn/yoho30/yohobuy-union into dev_180508_联盟红人推广
Conflicts: server/src/main/java/com/yoho/unions/server/restapi/UnionShareRest.java
Showing
7 changed files
with
49 additions
and
23 deletions
@@ -77,6 +77,7 @@ | @@ -77,6 +77,7 @@ | ||
77 | <value>/UnionClickCountDayRest/count</value> | 77 | <value>/UnionClickCountDayRest/count</value> |
78 | <value>/UnionShareRest/getShareInfoByUid</value> | 78 | <value>/UnionShareRest/getShareInfoByUid</value> |
79 | <value>/UnionShareRest/addSettlement</value> | 79 | <value>/UnionShareRest/addSettlement</value> |
80 | + <value>/UnionShareRest/queryUnionShareOrder</value> | ||
80 | 81 | ||
81 | </list> | 82 | </list> |
82 | </property> | 83 | </property> |
@@ -7,6 +7,8 @@ public class UnionShareOrders { | @@ -7,6 +7,8 @@ public class UnionShareOrders { | ||
7 | 7 | ||
8 | private String orderCode; | 8 | private String orderCode; |
9 | 9 | ||
10 | + private String settlementCode; | ||
11 | + | ||
10 | private Integer promoteUid; | 12 | private Integer promoteUid; |
11 | 13 | ||
12 | private String status; | 14 | private String status; |
@@ -102,4 +104,12 @@ public class UnionShareOrders { | @@ -102,4 +104,12 @@ public class UnionShareOrders { | ||
102 | public void setUpdateTime(Integer updateTime) { | 104 | public void setUpdateTime(Integer updateTime) { |
103 | this.updateTime = updateTime; | 105 | this.updateTime = updateTime; |
104 | } | 106 | } |
107 | + | ||
108 | + public String getSettlementCode() { | ||
109 | + return settlementCode; | ||
110 | + } | ||
111 | + | ||
112 | + public void setSettlementCode(String settlementCode) { | ||
113 | + this.settlementCode = settlementCode; | ||
114 | + } | ||
105 | } | 115 | } |
@@ -9,6 +9,8 @@ import org.slf4j.LoggerFactory; | @@ -9,6 +9,8 @@ import org.slf4j.LoggerFactory; | ||
9 | import org.springframework.beans.factory.annotation.Autowired; | 9 | import org.springframework.beans.factory.annotation.Autowired; |
10 | import org.springframework.stereotype.Component; | 10 | import org.springframework.stereotype.Component; |
11 | 11 | ||
12 | +import java.util.List; | ||
13 | + | ||
12 | /** | 14 | /** |
13 | * Created by mingdan.ge on 2018/5/10. | 15 | * Created by mingdan.ge on 2018/5/10. |
14 | */ | 16 | */ |
@@ -27,9 +29,12 @@ public class UnionSettleUpdateConsumer implements YhConsumer { | @@ -27,9 +29,12 @@ public class UnionSettleUpdateConsumer implements YhConsumer { | ||
27 | if (null == o) { | 29 | if (null == o) { |
28 | return; | 30 | return; |
29 | } | 31 | } |
30 | - ShareSettlementBo bo = JsonUtil.jsonToObject(o.toString(), ShareSettlementBo.class); | ||
31 | - //TODO 提现结算单状态变更 | ||
32 | - unionShareService.updateSettlementStatus(bo); | 32 | + List<Object> list = JsonUtil.jsonToObject(o.toString(), List.class); |
33 | + list.forEach(l->{ | ||
34 | + ShareSettlementBo bo = JsonUtil.jsonToObject(l.toString(), ShareSettlementBo.class); | ||
35 | + //TODO 提现结算单状态变更 | ||
36 | + unionShareService.updateSettlementStatus(bo); | ||
37 | + }); | ||
33 | 38 | ||
34 | } catch (Exception e) { | 39 | } catch (Exception e) { |
35 | logger.warn("UnionSettleUpdateConsumer,handleMessage fail! obj is {}, e {}",o,e.getMessage()); | 40 | logger.warn("UnionSettleUpdateConsumer,handleMessage fail! obj is {}, e {}",o,e.getMessage()); |
@@ -9,6 +9,8 @@ import org.slf4j.LoggerFactory; | @@ -9,6 +9,8 @@ import org.slf4j.LoggerFactory; | ||
9 | import org.springframework.beans.factory.annotation.Autowired; | 9 | import org.springframework.beans.factory.annotation.Autowired; |
10 | import org.springframework.stereotype.Component; | 10 | import org.springframework.stereotype.Component; |
11 | 11 | ||
12 | +import java.util.List; | ||
13 | + | ||
12 | /** | 14 | /** |
13 | * Created by mingdan.ge on 2018/5/10. | 15 | * Created by mingdan.ge on 2018/5/10. |
14 | */ | 16 | */ |
@@ -28,10 +30,12 @@ public class UnionShareOrderConsumer implements YhConsumer { | @@ -28,10 +30,12 @@ public class UnionShareOrderConsumer implements YhConsumer { | ||
28 | return; | 30 | return; |
29 | } | 31 | } |
30 | 32 | ||
31 | - ShareOrderBo bo = JsonUtil.jsonToObject(o.toString(), ShareOrderBo.class); | ||
32 | - //TODO 订单插入或更新 | ||
33 | - unionShareService.saveOrUpdateOrder(bo); | ||
34 | - | 33 | + List<Object> list = JsonUtil.jsonToObject(o.toString(), List.class); |
34 | + list.forEach(l->{ | ||
35 | + ShareOrderBo bo = JsonUtil.jsonToObject(l.toString(), ShareOrderBo.class); | ||
36 | + //TODO 订单插入或更新 | ||
37 | + unionShareService.saveOrUpdateOrder(bo); | ||
38 | + }); | ||
35 | } catch (Exception e) { | 39 | } catch (Exception e) { |
36 | logger.warn("UnionShareOrderConsumer,handleMessage fail! obj is {}, e {}",o,e.getMessage()); | 40 | logger.warn("UnionShareOrderConsumer,handleMessage fail! obj is {}, e {}",o,e.getMessage()); |
37 | } | 41 | } |
@@ -12,9 +12,11 @@ import org.slf4j.Logger; | @@ -12,9 +12,11 @@ import org.slf4j.Logger; | ||
12 | import org.slf4j.LoggerFactory; | 12 | import org.slf4j.LoggerFactory; |
13 | import org.springframework.beans.factory.annotation.Autowired; | 13 | import org.springframework.beans.factory.annotation.Autowired; |
14 | import org.springframework.stereotype.Controller; | 14 | import org.springframework.stereotype.Controller; |
15 | +import org.springframework.web.bind.annotation.RequestBody; | ||
15 | import org.springframework.web.bind.annotation.RequestMapping; | 16 | import org.springframework.web.bind.annotation.RequestMapping; |
16 | import org.springframework.web.bind.annotation.ResponseBody; | 17 | import org.springframework.web.bind.annotation.ResponseBody; |
17 | 18 | ||
19 | +import java.math.BigDecimal; | ||
18 | import java.util.List; | 20 | import java.util.List; |
19 | 21 | ||
20 | /** | 22 | /** |
@@ -32,18 +34,18 @@ public class UnionShareRest { | @@ -32,18 +34,18 @@ public class UnionShareRest { | ||
32 | 34 | ||
33 | @RequestMapping("/getShareInfoByUid") | 35 | @RequestMapping("/getShareInfoByUid") |
34 | @ResponseBody | 36 | @ResponseBody |
35 | - public UnionResponse getShareInfoByUid(int uid){ | 37 | + public ShareUserSettlementInfoBo getShareInfoByUid(@RequestBody int uid){ |
36 | log.info("getShareInfoByUid,uid is {}",uid); | 38 | log.info("getShareInfoByUid,uid is {}",uid); |
37 | ShareUserSettlementInfoBo result = unionShareService.getUserSettleMentInfo(uid); | 39 | ShareUserSettlementInfoBo result = unionShareService.getUserSettleMentInfo(uid); |
38 | - return new UnionResponse(200, "getShareInfoByUid success", result); | 40 | + return result; |
39 | } | 41 | } |
40 | 42 | ||
41 | @RequestMapping("/addSettlement") | 43 | @RequestMapping("/addSettlement") |
42 | @ResponseBody | 44 | @ResponseBody |
43 | - public UnionResponse addSettlement(int uid){ | 45 | + public UnionResponse addSettlement(@RequestBody int uid){ |
44 | log.info("addSettlement,uid is {}",uid); | 46 | log.info("addSettlement,uid is {}",uid); |
45 | - unionShareService.addSettlement(uid); | ||
46 | - return new UnionResponse(200, "addSettlement success", null); | 47 | + BigDecimal result = unionShareService.addSettlement(uid); |
48 | + return new UnionResponse(200, "addSettlement success", result); | ||
47 | } | 49 | } |
48 | 50 | ||
49 | /** | 51 | /** |
@@ -10,6 +10,8 @@ import com.yoho.unions.dal.model.UnionShareUser; | @@ -10,6 +10,8 @@ import com.yoho.unions.dal.model.UnionShareUser; | ||
10 | 10 | ||
11 | import java.util.List; | 11 | import java.util.List; |
12 | 12 | ||
13 | +import java.math.BigDecimal; | ||
14 | + | ||
13 | /** | 15 | /** |
14 | * 联盟红人推广返利 | 16 | * 联盟红人推广返利 |
15 | * Created by mingdan.ge on 2018/5/10. | 17 | * Created by mingdan.ge on 2018/5/10. |
@@ -29,7 +31,7 @@ public interface IUnionShareService { | @@ -29,7 +31,7 @@ public interface IUnionShareService { | ||
29 | /** | 31 | /** |
30 | * 提现 | 32 | * 提现 |
31 | */ | 33 | */ |
32 | - void addSettlement(Integer uid); | 34 | + BigDecimal addSettlement(Integer uid); |
33 | 35 | ||
34 | /** | 36 | /** |
35 | * 获取用户可提现金额、已提现金额、是否可以提现 | 37 | * 获取用户可提现金额、已提现金额、是否可以提现 |
@@ -239,6 +239,7 @@ public class UnionShareServiceImpl implements IUnionShareService { | @@ -239,6 +239,7 @@ public class UnionShareServiceImpl implements IUnionShareService { | ||
239 | bo.getProductList().forEach(p->{ | 239 | bo.getProductList().forEach(p->{ |
240 | UnionShareOrdersProduct insertPro = new UnionShareOrdersProduct(); | 240 | UnionShareOrdersProduct insertPro = new UnionShareOrdersProduct(); |
241 | BeanUtils.copyProperties(p, insertPro); | 241 | BeanUtils.copyProperties(p, insertPro); |
242 | + insertPro.setOrderCode(bo.getOrderCode()); | ||
242 | unionShareOrdersProductMapper.insertSelective(insertPro); | 243 | unionShareOrdersProductMapper.insertSelective(insertPro); |
243 | }); | 244 | }); |
244 | logger.info("insertOrder end,req is {}",bo); | 245 | logger.info("insertOrder end,req is {}",bo); |
@@ -281,32 +282,32 @@ public class UnionShareServiceImpl implements IUnionShareService { | @@ -281,32 +282,32 @@ public class UnionShareServiceImpl implements IUnionShareService { | ||
281 | * 提现 | 282 | * 提现 |
282 | */ | 283 | */ |
283 | @Override | 284 | @Override |
284 | - public void addSettlement(Integer uid) { | 285 | + public BigDecimal addSettlement(Integer uid) { |
285 | logger.info("addSettlement enter,uid is {}",uid); | 286 | logger.info("addSettlement enter,uid is {}",uid); |
286 | if (uid == null ) { | 287 | if (uid == null ) { |
287 | - return; | 288 | + return null; |
288 | } | 289 | } |
289 | //查询该用户是否为特邀用户 | 290 | //查询该用户是否为特邀用户 |
290 | int count = unionShareUserMapper.selectCountByUid(uid); | 291 | int count = unionShareUserMapper.selectCountByUid(uid); |
291 | if (count == 0) { | 292 | if (count == 0) { |
292 | //不是特邀用户 | 293 | //不是特邀用户 |
293 | - return; | 294 | + return null; |
294 | } | 295 | } |
295 | //查询是否有处理中的提现 | 296 | //查询是否有处理中的提现 |
296 | if (hasSettlement(uid)) { | 297 | if (hasSettlement(uid)) { |
297 | //有处理中的提现单,不可提现 | 298 | //有处理中的提现单,不可提现 |
298 | - return; | 299 | + return null; |
299 | } | 300 | } |
300 | 301 | ||
301 | //查询当前是否有可提现的订单 | 302 | //查询当前是否有可提现的订单 |
302 | int orderCount = unionShareOrdersMapper.selectCountByCondition(uid,ShareOrdersStatusEnum.CAN_SETTLE.getCode()); | 303 | int orderCount = unionShareOrdersMapper.selectCountByCondition(uid,ShareOrdersStatusEnum.CAN_SETTLE.getCode()); |
303 | if (orderCount == 0 ) { | 304 | if (orderCount == 0 ) { |
304 | //没有可以提现的订单 | 305 | //没有可以提现的订单 |
305 | - return; | 306 | + return null; |
306 | } | 307 | } |
307 | //todo 生成取现单,绑定订单,考虑是否异步操作 | 308 | //todo 生成取现单,绑定订单,考虑是否异步操作 |
308 | - relateSettlementAndOrder(uid); | ||
309 | - | 309 | + BigDecimal amount = relateSettlementAndOrder(uid); |
310 | + return amount; | ||
310 | } | 311 | } |
311 | 312 | ||
312 | /** | 313 | /** |
@@ -392,7 +393,7 @@ public class UnionShareServiceImpl implements IUnionShareService { | @@ -392,7 +393,7 @@ public class UnionShareServiceImpl implements IUnionShareService { | ||
392 | /** | 393 | /** |
393 | * 提现关联订单 | 394 | * 提现关联订单 |
394 | * */ | 395 | * */ |
395 | - public void relateSettlementAndOrder(int uid) { | 396 | + public BigDecimal relateSettlementAndOrder(int uid) { |
396 | 397 | ||
397 | //生成提现编号 | 398 | //生成提现编号 |
398 | String settlementCode = createSettlementCode(); | 399 | String settlementCode = createSettlementCode(); |
@@ -401,7 +402,7 @@ public class UnionShareServiceImpl implements IUnionShareService { | @@ -401,7 +402,7 @@ public class UnionShareServiceImpl implements IUnionShareService { | ||
401 | int updateTime = DateUtil.getCurrentTimeSecond(); | 402 | int updateTime = DateUtil.getCurrentTimeSecond(); |
402 | int count=unionShareOrdersMapper.updateStatusByUid(uid,settlementCode, ShareOrdersStatusEnum.CAN_SETTLE.getCode(), ShareOrdersStatusEnum.SETTLE.getCode(), updateTime); | 403 | int count=unionShareOrdersMapper.updateStatusByUid(uid,settlementCode, ShareOrdersStatusEnum.CAN_SETTLE.getCode(), ShareOrdersStatusEnum.SETTLE.getCode(), updateTime); |
403 | if (count == 0) { | 404 | if (count == 0) { |
404 | - return; | 405 | + return null; |
405 | } | 406 | } |
406 | //计算提现金额 | 407 | //计算提现金额 |
407 | BigDecimal totalAmount=unionShareOrdersMapper.selectAmountBySettleCode(uid, settlementCode); | 408 | BigDecimal totalAmount=unionShareOrdersMapper.selectAmountBySettleCode(uid, settlementCode); |
@@ -431,7 +432,7 @@ public class UnionShareServiceImpl implements IUnionShareService { | @@ -431,7 +432,7 @@ public class UnionShareServiceImpl implements IUnionShareService { | ||
431 | orderCodes.addAll(periodOrders); | 432 | orderCodes.addAll(periodOrders); |
432 | } | 433 | } |
433 | if (orderCodes.size() == 0) { | 434 | if (orderCodes.size() == 0) { |
434 | - return; | 435 | + return null; |
435 | } | 436 | } |
436 | 437 | ||
437 | 438 | ||
@@ -443,6 +444,7 @@ public class UnionShareServiceImpl implements IUnionShareService { | @@ -443,6 +444,7 @@ public class UnionShareServiceImpl implements IUnionShareService { | ||
443 | BeanUtils.copyProperties(insertReq,bo); | 444 | BeanUtils.copyProperties(insertReq,bo); |
444 | bo.setOrderCodes(orderCodes); | 445 | bo.setOrderCodes(orderCodes); |
445 | yhProducer.send(SETTLEMENT_TOPIC, bo); | 446 | yhProducer.send(SETTLEMENT_TOPIC, bo); |
447 | + return totalAmount; | ||
446 | } | 448 | } |
447 | 449 | ||
448 | /** | 450 | /** |
-
Please register or login to post a comment