Merge branch 'hotfix_0407_skupnotexist2' into test6.9.24
Showing
7 changed files
with
142 additions
and
8 deletions
@@ -3,6 +3,7 @@ package com.yohoufo.dal.order; | @@ -3,6 +3,7 @@ package com.yohoufo.dal.order; | ||
3 | import java.math.BigDecimal; | 3 | import java.math.BigDecimal; |
4 | import java.util.List; | 4 | import java.util.List; |
5 | 5 | ||
6 | +import com.yohoufo.dal.order.model.SellerWalletCompensate; | ||
6 | import org.apache.ibatis.annotations.Param; | 7 | import org.apache.ibatis.annotations.Param; |
7 | 8 | ||
8 | import com.yohoufo.dal.order.model.SellerWallet; | 9 | import com.yohoufo.dal.order.model.SellerWallet; |
@@ -15,6 +16,8 @@ public interface SellerWalletMapper { | @@ -15,6 +16,8 @@ public interface SellerWalletMapper { | ||
15 | 16 | ||
16 | SellerWallet selectByPrimaryKey(Integer id); | 17 | SellerWallet selectByPrimaryKey(Integer id); |
17 | 18 | ||
19 | + List<SellerWalletCompensate> selectByCompensate(@Param("list") List<Integer> uids); | ||
20 | + | ||
18 | 21 | ||
19 | List<SellerWallet> selectByUids(@Param("list") List<Integer> uids); | 22 | List<SellerWallet> selectByUids(@Param("list") List<Integer> uids); |
20 | 23 |
@@ -20,6 +20,8 @@ public interface StoredSellerMapper { | @@ -20,6 +20,8 @@ public interface StoredSellerMapper { | ||
20 | int updateByUidSelective(StoredSeller record); | 20 | int updateByUidSelective(StoredSeller record); |
21 | 21 | ||
22 | StoredSeller selectByUid(int uid); | 22 | StoredSeller selectByUid(int uid); |
23 | + | ||
24 | + List<StoredSeller> selectByUidList(List<Integer> uids); | ||
23 | 25 | ||
24 | int clearUserData(@Param("uid") Integer uid); | 26 | int clearUserData(@Param("uid") Integer uid); |
25 | 27 |
1 | +package com.yohoufo.dal.order.model; | ||
2 | + | ||
3 | +import lombok.Data; | ||
4 | +import lombok.ToString; | ||
5 | + | ||
6 | +import java.math.BigDecimal; | ||
7 | +import java.util.List; | ||
8 | + | ||
9 | +@Data | ||
10 | +@ToString | ||
11 | +public class SellerWalletCompensate { | ||
12 | + | ||
13 | + private Integer uid; | ||
14 | + BigDecimal earnestMoney; | ||
15 | + List<Integer> skups; | ||
16 | + BigDecimal availableAmount; | ||
17 | + BigDecimal lockAmount; | ||
18 | +} |
@@ -22,6 +22,54 @@ | @@ -22,6 +22,54 @@ | ||
22 | where id = #{id,jdbcType=INTEGER} | 22 | where id = #{id,jdbcType=INTEGER} |
23 | </select> | 23 | </select> |
24 | 24 | ||
25 | + <select id="selectByCompensate" resultType="com.yohoufo.dal.order.model.SellerWalletCompensate"> | ||
26 | + SELECT | ||
27 | + t.earnest_money earnestMoney, t.uid, t.skups, sw.amount availableAmount, | ||
28 | + sw.lock_amount lockAmount | ||
29 | + FROM | ||
30 | + ( | ||
31 | + SELECT | ||
32 | + sum(so.earnest_money) earnest_money, | ||
33 | + so.uid, | ||
34 | + group_concat(sog.id) skups | ||
35 | + FROM | ||
36 | + ufo_order.seller_order so, | ||
37 | + ufo_order.seller_order_goods sog | ||
38 | + WHERE | ||
39 | + sog.id = so.skup | ||
40 | + AND ( | ||
41 | + sog. STATUS = 1 | ||
42 | + OR ( | ||
43 | + sog. STATUS = 2 | ||
44 | + AND so.skup IN ( | ||
45 | + SELECT | ||
46 | + bog.skup | ||
47 | + FROM | ||
48 | + ufo_order.buyer_order bo, | ||
49 | + ufo_order.buyer_order_goods bog | ||
50 | + WHERE | ||
51 | + bo. STATUS IN (0, 1, 2, 3, 32,31) | ||
52 | + AND bo.order_code = bog.order_code | ||
53 | + ) | ||
54 | + ) | ||
55 | + ) | ||
56 | + AND so.payment = 11 | ||
57 | + <if test="list != null"> | ||
58 | + and so.uid in | ||
59 | + <foreach item="item" index="index" collection="list" open="(" separator="," close=")"> | ||
60 | + #{item} | ||
61 | + </foreach> | ||
62 | + </if> | ||
63 | + GROUP BY | ||
64 | + so.uid | ||
65 | + ) t, | ||
66 | + ufo_order.seller_wallet sw | ||
67 | + WHERE | ||
68 | + t.uid = sw.uid | ||
69 | + AND t.earnest_money - sw.lock_amount != 0 | ||
70 | + | ||
71 | + </select> | ||
72 | + | ||
25 | 73 | ||
26 | <select id="selectByUids" resultMap="BaseResultMap" parameterType="java.lang.Integer" > | 74 | <select id="selectByUids" resultMap="BaseResultMap" parameterType="java.lang.Integer" > |
27 | select | 75 | select |
@@ -116,6 +116,20 @@ public class OrderHelpController { | @@ -116,6 +116,20 @@ public class OrderHelpController { | ||
116 | 116 | ||
117 | @IgnoreSignature | 117 | @IgnoreSignature |
118 | @IgnoreSession | 118 | @IgnoreSession |
119 | + @RequestMapping(value = "/compensate") | ||
120 | + public ApiResponse compensate(@RequestParam(value = "uids", required = false) List<Integer> uids) { | ||
121 | + | ||
122 | + storedSellerService.compensate(uids); | ||
123 | + return new ApiResponse.ApiResponseBuilder() | ||
124 | + .code(200) | ||
125 | + .message("降级成功") | ||
126 | + .build(); | ||
127 | + | ||
128 | + } | ||
129 | + | ||
130 | + | ||
131 | + @IgnoreSignature | ||
132 | + @IgnoreSession | ||
119 | @RequestMapping(value = "/orderPay") | 133 | @RequestMapping(value = "/orderPay") |
120 | public ApiResponse orderPay(@RequestParam(value = "orderCodes") List<Long> orderCodes){ | 134 | public ApiResponse orderPay(@RequestParam(value = "orderCodes") List<Long> orderCodes){ |
121 | 135 |
@@ -13,10 +13,11 @@ import java.util.Map; | @@ -13,10 +13,11 @@ import java.util.Map; | ||
13 | */ | 13 | */ |
14 | public interface IStoredSellerService { | 14 | public interface IStoredSellerService { |
15 | 15 | ||
16 | - /** | ||
17 | - * 增加orderPay记录 | ||
18 | - * @param uids | ||
19 | - */ | 16 | + |
17 | + | ||
18 | + void compensate(List<Integer> uids); | ||
19 | + | ||
20 | + | ||
20 | public void orderPay(List<Long> orderCodes); | 21 | public void orderPay(List<Long> orderCodes); |
21 | 22 | ||
22 | boolean isStoredSeller(Integer uid); | 23 | boolean isStoredSeller(Integer uid); |
@@ -46,6 +46,7 @@ import org.springframework.integration.context.Orderable; | @@ -46,6 +46,7 @@ import org.springframework.integration.context.Orderable; | ||
46 | import org.springframework.stereotype.Service; | 46 | import org.springframework.stereotype.Service; |
47 | 47 | ||
48 | import java.math.BigDecimal; | 48 | import java.math.BigDecimal; |
49 | +import java.text.CollationElementIterator; | ||
49 | import java.time.LocalDateTime; | 50 | import java.time.LocalDateTime; |
50 | import java.time.ZoneOffset; | 51 | import java.time.ZoneOffset; |
51 | import java.util.Arrays; | 52 | import java.util.Arrays; |
@@ -388,10 +389,7 @@ public class StoreSellerServiceImpl implements IStoredSellerService { | @@ -388,10 +389,7 @@ public class StoreSellerServiceImpl implements IStoredSellerService { | ||
388 | OrdersPayMapper ordersPayMapper; | 389 | OrdersPayMapper ordersPayMapper; |
389 | 390 | ||
390 | 391 | ||
391 | - /** | ||
392 | - * 增加orderPay记录 | ||
393 | - * @param uids | ||
394 | - */ | 392 | + |
395 | public void orderPay(List<Long> orderCodes){ | 393 | public void orderPay(List<Long> orderCodes){ |
396 | 394 | ||
397 | // 查询卖家正在上架中的商品 & 支付方式是11 & orderspay中没有记录 | 395 | // 查询卖家正在上架中的商品 & 支付方式是11 & orderspay中没有记录 |
@@ -431,6 +429,56 @@ public class StoreSellerServiceImpl implements IStoredSellerService { | @@ -431,6 +429,56 @@ public class StoreSellerServiceImpl implements IStoredSellerService { | ||
431 | } | 429 | } |
432 | } | 430 | } |
433 | 431 | ||
432 | + | ||
433 | + | ||
434 | + | ||
435 | + public void compensate(List<Integer> uids){ | ||
436 | + | ||
437 | + if (CollectionUtils.isEmpty(uids)){ | ||
438 | + return; | ||
439 | + } | ||
440 | + | ||
441 | + // 超级 | ||
442 | + List<StoredSeller> storedSellerList = storedSellerMapper.selectByUidList(uids); | ||
443 | + if (CollectionUtils.isEmpty(storedSellerList)){ | ||
444 | + return; | ||
445 | + } | ||
446 | + List<StoredSeller> filterStoredList = storedSellerList.stream().filter(x->x.getEntryType()==EntrySellerType.COMMON.getCode() && x.getValidStatus()==1).collect(Collectors.toList()); | ||
447 | + | ||
448 | + List<SellerWalletCompensate> sellerWalletCompensates = sellerWalletMapper.selectByCompensate(filterStoredList.stream().map(StoredSeller::getUid).collect(Collectors.toList())); | ||
449 | + | ||
450 | + for (SellerWalletCompensate s : sellerWalletCompensates){ | ||
451 | + | ||
452 | + double compensate = YHMath.sub(s.getEarnestMoney().doubleValue(), s.getLockAmount().doubleValue()); | ||
453 | + | ||
454 | + if (compensate<0){ | ||
455 | + scriptLogger.info("[{}] no need manual handle1 data {}", s.getUid(), s); | ||
456 | + continue; | ||
457 | + } | ||
458 | + | ||
459 | + if (compensate<0){ | ||
460 | + scriptLogger.info("[{}] need manual handle1 data {}", s.getUid(), s); | ||
461 | + continue; | ||
462 | + } | ||
463 | + | ||
464 | + if (YHMath.sub(s.getAvailableAmount().doubleValue(), compensate) < 0){ | ||
465 | + scriptLogger.info("[{}] need manual handle2 data {}", s.getUid(), s); | ||
466 | + continue; | ||
467 | + } | ||
468 | + | ||
469 | + BigDecimal earnestMoney = new BigDecimal(compensate); | ||
470 | + earnestMoney = earnestMoney.setScale(2, BigDecimal.ROUND_HALF_UP); | ||
471 | + | ||
472 | + MerchantOrderAttachInfo moai = MerchantOrderAttachInfo.builder().uid(s.getUid()) | ||
473 | + .earnestMoney(earnestMoney) | ||
474 | + .type(SellerWalletDetail.Type.PUBLISH.getValue()).build(); | ||
475 | + merchantOrderPaymentService.useEarnest(s.getUid(), earnestMoney, moai); | ||
476 | + scriptLogger.info("[{}] compensate lock money {} success", s.getUid(), s); | ||
477 | + | ||
478 | + } | ||
479 | + | ||
480 | + } | ||
481 | + | ||
434 | /** | 482 | /** |
435 | * 将原来的超级卖家降级 | 483 | * 将原来的超级卖家降级 |
436 | */ | 484 | */ |
-
Please register or login to post a comment