Merge branch 'hotfix_0823_现货寄存返利' into hotfix-20190826
Showing
12 changed files
with
231 additions
and
13 deletions
@@ -2,6 +2,7 @@ package com.yohoufo.dal.order; | @@ -2,6 +2,7 @@ package com.yohoufo.dal.order; | ||
2 | 2 | ||
3 | 3 | ||
4 | import com.yohoufo.dal.order.model.OrdersPayTransfer; | 4 | import com.yohoufo.dal.order.model.OrdersPayTransfer; |
5 | +import org.apache.ibatis.annotations.Param; | ||
5 | 6 | ||
6 | public interface OrdersPayTransferMapper { | 7 | public interface OrdersPayTransferMapper { |
7 | 8 | ||
@@ -11,6 +12,8 @@ public interface OrdersPayTransferMapper { | @@ -11,6 +12,8 @@ public interface OrdersPayTransferMapper { | ||
11 | 12 | ||
12 | OrdersPayTransfer selectByPrimaryKey(Integer id); | 13 | OrdersPayTransfer selectByPrimaryKey(Integer id); |
13 | 14 | ||
15 | + int selectByUidAndTransferType(@Param("uid") Integer uid, @Param("transferType") Integer transferType); | ||
16 | + | ||
14 | int updateByPrimaryKeySelective(OrdersPayTransfer record); | 17 | int updateByPrimaryKeySelective(OrdersPayTransfer record); |
15 | 18 | ||
16 | int updateByPrimaryKey(OrdersPayTransfer record); | 19 | int updateByPrimaryKey(OrdersPayTransfer record); |
@@ -48,6 +48,7 @@ public class SellerWalletDetail { | @@ -48,6 +48,7 @@ public class SellerWalletDetail { | ||
48 | SELLER_CANCEL("卖家不卖了", 31), | 48 | SELLER_CANCEL("卖家不卖了", 31), |
49 | SELLER_OVER_TIME("卖家发货超时", 32), | 49 | SELLER_OVER_TIME("卖家发货超时", 32), |
50 | APPRAISE_FAIL("鉴定不通过", 33), | 50 | APPRAISE_FAIL("鉴定不通过", 33), |
51 | + DEPOSIT_REBATE("申请寄存返利", 53), | ||
51 | SELLER_SHAM_SEND_OUT("卖家虚假发货", 34), | 52 | SELLER_SHAM_SEND_OUT("卖家虚假发货", 34), |
52 | MINI_FAULT_REJECT("瑕疵确认不接受", 35), | 53 | MINI_FAULT_REJECT("瑕疵确认不接受", 35), |
53 | BUYER_CANCEL_NO_DELIVERY("买家取消(无物流)", 41), | 54 | BUYER_CANCEL_NO_DELIVERY("买家取消(无物流)", 41), |
@@ -40,6 +40,14 @@ | @@ -40,6 +40,14 @@ | ||
40 | where buyer_order_code = #{buyerOrderCode,jdbcType=INTEGER} | 40 | where buyer_order_code = #{buyerOrderCode,jdbcType=INTEGER} |
41 | </select> | 41 | </select> |
42 | 42 | ||
43 | + <select id="selectByUidAndTransferType" resultType="java.lang.Integer" parameterType="java.lang.Integer" > | ||
44 | + select | ||
45 | + count(1) | ||
46 | + from orders_pay_transfer | ||
47 | + where uid = #{uid,jdbcType=INTEGER} | ||
48 | + and transfer_type = #{transferType,jdbcType=INTEGER} | ||
49 | + </select> | ||
50 | + | ||
43 | <insert id="insert" parameterType="com.yohoufo.dal.order.model.OrdersPayTransfer" useGeneratedKeys="true" keyProperty="id" > | 51 | <insert id="insert" parameterType="com.yohoufo.dal.order.model.OrdersPayTransfer" useGeneratedKeys="true" keyProperty="id" > |
44 | insert into orders_pay_transfer (id, buyer_order_code, seller_order_code, | 52 | insert into orders_pay_transfer (id, buyer_order_code, seller_order_code, |
45 | alipay_trade_id, transfer_type, uid, | 53 | alipay_trade_id, transfer_type, uid, |
1 | package com.yohoufo.order.common; | 1 | package com.yohoufo.order.common; |
2 | 2 | ||
3 | public enum TradeType { | 3 | public enum TradeType { |
4 | + deposit_rebate(4, "返利"), | ||
4 | compensateIncome(3, "补偿款"), | 5 | compensateIncome(3, "补偿款"), |
5 | goods_income(2, "货款"), | 6 | goods_income(2, "货款"), |
6 | guarantee_cash(1, "保证金"); | 7 | guarantee_cash(1, "保证金"); |
7 | 8 | ||
9 | + | ||
8 | int code; | 10 | int code; |
9 | 11 | ||
10 | 12 |
@@ -14,7 +14,8 @@ public enum TransferCase { | @@ -14,7 +14,8 @@ public enum TransferCase { | ||
14 | 14 | ||
15 | ALL_GOODS_MONEY_TO_SELLER(1, "货款->卖家"), | 15 | ALL_GOODS_MONEY_TO_SELLER(1, "货款->卖家"), |
16 | EARNEST_MONEY_TO_BUYER(3,"保证金->买家"), | 16 | EARNEST_MONEY_TO_BUYER(3,"保证金->买家"), |
17 | - PART_GOODS_MONEY_TO_SELLER(6,"部分货款->卖家"); | 17 | + PART_GOODS_MONEY_TO_SELLER(6,"部分货款->卖家"), |
18 | + DEPOSIT_REBATE_TO_USER(7, "申请寄存返利->用户"); | ||
18 | 19 | ||
19 | private int code; | 20 | private int code; |
20 | private String info; | 21 | private String info; |
@@ -31,6 +31,10 @@ public enum AlarmConfig { | @@ -31,6 +31,10 @@ public enum AlarmConfig { | ||
31 | "buyerOrder.transferEarnestMoney", | 31 | "buyerOrder.transferEarnestMoney", |
32 | "buyerOrder.refundGoodsMoney"), | 32 | "buyerOrder.refundGoodsMoney"), |
33 | 33 | ||
34 | + DEPOSIT_REBATE_FAIL("申请寄存返利", | ||
35 | + "appraiseOrder.depositRebate", | ||
36 | + ""), | ||
37 | + | ||
34 | SELLER_SHAM_SEND_OUT("卖家虚假发货", | 38 | SELLER_SHAM_SEND_OUT("卖家虚假发货", |
35 | "buyerOrder.transferEarnestMoney", | 39 | "buyerOrder.transferEarnestMoney", |
36 | "buyerOrder.refundGoodsMoney"); | 40 | "buyerOrder.refundGoodsMoney"); |
@@ -18,14 +18,13 @@ import com.yohoufo.order.model.request.OrderRequest; | @@ -18,14 +18,13 @@ import com.yohoufo.order.model.request.OrderRequest; | ||
18 | import com.yohoufo.order.model.request.SaveQualityCheckInfoRequest; | 18 | import com.yohoufo.order.model.request.SaveQualityCheckInfoRequest; |
19 | import com.yohoufo.order.service.IBuyerOrderService; | 19 | import com.yohoufo.order.service.IBuyerOrderService; |
20 | import com.yohoufo.order.service.IPaymentService; | 20 | import com.yohoufo.order.service.IPaymentService; |
21 | -import com.yohoufo.order.service.impl.BuyerOrderCancelService; | ||
22 | -import com.yohoufo.order.service.impl.BuyerOrderViewService; | ||
23 | -import com.yohoufo.order.service.impl.SellerOrderService; | 21 | +import com.yohoufo.order.service.impl.*; |
24 | import com.yohoufo.order.utils.LoggerUtils; | 22 | import com.yohoufo.order.utils.LoggerUtils; |
25 | import org.slf4j.Logger; | 23 | import org.slf4j.Logger; |
26 | import org.springframework.beans.factory.annotation.Autowired; | 24 | import org.springframework.beans.factory.annotation.Autowired; |
27 | import org.springframework.web.bind.annotation.*; | 25 | import org.springframework.web.bind.annotation.*; |
28 | 26 | ||
27 | +import java.util.List; | ||
29 | import java.util.Objects; | 28 | import java.util.Objects; |
30 | 29 | ||
31 | @RestController | 30 | @RestController |
@@ -48,6 +47,9 @@ public class ErpGWOrderController { | @@ -48,6 +47,9 @@ public class ErpGWOrderController { | ||
48 | BuyerOrderCancelService buyerOrderCancelService; | 47 | BuyerOrderCancelService buyerOrderCancelService; |
49 | 48 | ||
50 | @Autowired | 49 | @Autowired |
50 | + AppraiseOrderService appraiseOrderService; | ||
51 | + | ||
52 | + @Autowired | ||
51 | private BuyerOrderViewService buyerOrderViewService; | 53 | private BuyerOrderViewService buyerOrderViewService; |
52 | 54 | ||
53 | @RequestMapping(params = "method=ufo.buyer.orderNums") | 55 | @RequestMapping(params = "method=ufo.buyer.orderNums") |
@@ -161,6 +163,16 @@ public class ErpGWOrderController { | @@ -161,6 +163,16 @@ public class ErpGWOrderController { | ||
161 | return new ApiResponse.ApiResponseBuilder().code(200).message("鉴定中心确认收货成功").build(); | 163 | return new ApiResponse.ApiResponseBuilder().code(200).message("鉴定中心确认收货成功").build(); |
162 | } | 164 | } |
163 | 165 | ||
166 | + @IgnoreSession | ||
167 | + @IgnoreSignature | ||
168 | + @RequestMapping(value = "/depositRebate") | ||
169 | + public ApiResponse depositRebate(@RequestBody List<Long> orderCodeList) { | ||
170 | + LOG.info("method depositRebate in, req is {}", orderCodeList); | ||
171 | + appraiseOrderService.depositRebate(orderCodeList); | ||
172 | + LOG.info("method depositRebate, req is {}", orderCodeList); | ||
173 | + return new ApiResponse.ApiResponseBuilder().code(200).message("申请寄存返利").build(); | ||
174 | + } | ||
175 | + | ||
164 | 176 | ||
165 | /** | 177 | /** |
166 | * 后台手工确认的清关失败的订单 | 178 | * 后台手工确认的清关失败的订单 |
@@ -4,10 +4,19 @@ import com.yohobuy.ufo.model.order.common.OrderAttributes; | @@ -4,10 +4,19 @@ import com.yohobuy.ufo.model.order.common.OrderAttributes; | ||
4 | import com.yohobuy.ufo.model.order.req.DeliverToDepotReq; | 4 | import com.yohobuy.ufo.model.order.req.DeliverToDepotReq; |
5 | import com.yohoufo.dal.order.model.AppraiseOrder; | 5 | import com.yohoufo.dal.order.model.AppraiseOrder; |
6 | 6 | ||
7 | +import java.util.List; | ||
8 | + | ||
7 | public interface IGoodsService { | 9 | public interface IGoodsService { |
8 | 10 | ||
9 | 11 | ||
10 | /** | 12 | /** |
13 | + * 申请寄存返利 | ||
14 | + * @param orderCodeList | ||
15 | + */ | ||
16 | + void depositRebate(List<Long> orderCodeList); | ||
17 | + | ||
18 | + | ||
19 | + /** | ||
11 | * 发货 | 20 | * 发货 |
12 | * @param req | 21 | * @param req |
13 | */ | 22 | */ |
@@ -21,6 +21,22 @@ public class AlipayTransferChancelSelector { | @@ -21,6 +21,22 @@ public class AlipayTransferChancelSelector { | ||
21 | @Autowired | 21 | @Autowired |
22 | private ConfigReader configReader; | 22 | private ConfigReader configReader; |
23 | 23 | ||
24 | + /** | ||
25 | + * 申请寄存返利的单数 | ||
26 | + * @return | ||
27 | + */ | ||
28 | + public int getDepositRebateOrderCnt(){ | ||
29 | + return configReader.getInt("ufo.order.pay.depositRebateCnt", 4); | ||
30 | + } | ||
31 | + | ||
32 | + /** | ||
33 | + * 申请寄存返利一单返利数目 | ||
34 | + * @return | ||
35 | + */ | ||
36 | + public double getDepositRebateAmount(){ | ||
37 | + return configReader.getDouble("ufo.order.pay.depositRebatePerAmount", 40); | ||
38 | + } | ||
39 | + | ||
24 | public boolean isTransferWithAlipayExceedMillionTransfer() { | 40 | public boolean isTransferWithAlipayExceedMillionTransfer() { |
25 | boolean value = configReader.getBoolean("ufo.order.pay.exceedSwitch", false); | 41 | boolean value = configReader.getBoolean("ufo.order.pay.exceedSwitch", false); |
26 | if (value) { | 42 | if (value) { |
1 | package com.yohoufo.order.service.impl; | 1 | package com.yohoufo.order.service.impl; |
2 | 2 | ||
3 | import com.yohobuy.ufo.model.order.common.AppraiseOrderStatus; | 3 | import com.yohobuy.ufo.model.order.common.AppraiseOrderStatus; |
4 | +import com.yohobuy.ufo.model.order.common.OrderAttributes; | ||
5 | +import com.yohobuy.ufo.model.order.common.OrderCodeType; | ||
4 | import com.yohobuy.ufo.model.order.req.DeliverToDepotReq; | 6 | import com.yohobuy.ufo.model.order.req.DeliverToDepotReq; |
5 | import com.yohoufo.common.utils.DateUtil; | 7 | import com.yohoufo.common.utils.DateUtil; |
6 | import com.yohoufo.dal.order.AppraiseOrderGoodsMapper; | 8 | import com.yohoufo.dal.order.AppraiseOrderGoodsMapper; |
7 | import com.yohoufo.dal.order.AppraiseOrderMapper; | 9 | import com.yohoufo.dal.order.AppraiseOrderMapper; |
10 | +import com.yohoufo.dal.order.OrdersPayTransferMapper; | ||
8 | import com.yohoufo.dal.order.model.AppraiseOrder; | 11 | import com.yohoufo.dal.order.model.AppraiseOrder; |
9 | import com.yohoufo.dal.order.model.AppraiseOrderGoods; | 12 | import com.yohoufo.dal.order.model.AppraiseOrderGoods; |
13 | +import com.yohoufo.dal.order.model.SellerWalletDetail; | ||
14 | +import com.yohoufo.order.common.TransferCase; | ||
15 | +import com.yohoufo.order.constants.AlarmConfig; | ||
16 | +import com.yohoufo.order.model.request.TranseferCellNode; | ||
17 | +import com.yohoufo.order.model.request.TransferMoneyRequest; | ||
10 | import com.yohoufo.order.service.IGoodsService; | 18 | import com.yohoufo.order.service.IGoodsService; |
19 | +import com.yohoufo.order.service.handler.transfer.AlipayTransferChancelSelector; | ||
11 | import com.yohoufo.order.service.proxy.OrderStatusFlowService; | 20 | import com.yohoufo.order.service.proxy.OrderStatusFlowService; |
21 | +import com.yohoufo.order.service.support.codegenerator.OrderCodeGenerator; | ||
12 | import com.yohoufo.order.utils.LoggerUtils; | 22 | import com.yohoufo.order.utils.LoggerUtils; |
23 | +import com.yohoufo.order.utils.NamedThreadFactory; | ||
24 | +import org.apache.commons.collections.CollectionUtils; | ||
13 | import org.slf4j.Logger; | 25 | import org.slf4j.Logger; |
14 | import org.springframework.beans.factory.annotation.Autowired; | 26 | import org.springframework.beans.factory.annotation.Autowired; |
15 | 27 | ||
28 | +import java.math.BigDecimal; | ||
29 | +import java.util.List; | ||
30 | +import java.util.concurrent.ArrayBlockingQueue; | ||
31 | +import java.util.concurrent.ExecutorService; | ||
32 | +import java.util.concurrent.ThreadPoolExecutor; | ||
33 | +import java.util.concurrent.TimeUnit; | ||
34 | +import java.util.stream.Collectors; | ||
35 | + | ||
16 | public abstract class AbsGoodsServiceOrderService implements IGoodsService { | 36 | public abstract class AbsGoodsServiceOrderService implements IGoodsService { |
17 | private final Logger logger = LoggerUtils.getSellerOrderLogger(); | 37 | private final Logger logger = LoggerUtils.getSellerOrderLogger(); |
18 | @Autowired | 38 | @Autowired |
@@ -22,7 +42,85 @@ public abstract class AbsGoodsServiceOrderService implements IGoodsService { | @@ -22,7 +42,85 @@ public abstract class AbsGoodsServiceOrderService implements IGoodsService { | ||
22 | private OrderStatusFlowService orderStatusFlowService; | 42 | private OrderStatusFlowService orderStatusFlowService; |
23 | 43 | ||
24 | @Autowired | 44 | @Autowired |
25 | - private AppraiseOrderGoodsMapper appraiseOrderGoodsMapper; | 45 | + OrderCodeGenerator orderCodeGenerator; |
46 | + | ||
47 | + @Autowired | ||
48 | + private AlipayTransferChancelSelector alipayTransferChancelSelector; | ||
49 | + | ||
50 | + @Autowired | ||
51 | + TransferService transferService; | ||
52 | + | ||
53 | + @Autowired | ||
54 | + OrdersPayTransferMapper ordersPayTransferMapper; | ||
55 | + | ||
56 | + @Autowired | ||
57 | + AppraiseOrderGoodsMapper appraiseOrderGoodsMapper; | ||
58 | + | ||
59 | + private ExecutorService executorService = new ThreadPoolExecutor(5, 10, 60, TimeUnit.SECONDS, | ||
60 | + new ArrayBlockingQueue<>(1000), | ||
61 | + NamedThreadFactory.newThreadFactory("appraise")); | ||
62 | + | ||
63 | + /** | ||
64 | + * 申请寄存返利 | ||
65 | + * @param orderCodeList | ||
66 | + */ | ||
67 | + public void depositRebate(List<Long> orderCodeList){ | ||
68 | + | ||
69 | + logger.info("depositRebate param is {}", orderCodeList); | ||
70 | + | ||
71 | + if (CollectionUtils.isEmpty(orderCodeList)){ | ||
72 | + return; | ||
73 | + } | ||
74 | + | ||
75 | + // 过滤1: 通过code过滤出来 goods_service的订单号 | ||
76 | + List<Long> goodServiceOrderLists = orderCodeList.stream() | ||
77 | + .filter(orderCode -> orderCodeGenerator.expId(orderCode).getType() == OrderCodeType.GOODS_SERVICE.getType()) | ||
78 | + .collect(Collectors.toList()); | ||
79 | + | ||
80 | + // 过滤2: 通过查表 appaise_order & attribute | ||
81 | + List<AppraiseOrder> appraiseOrderList = appraiseOrderMapper.selectByOrderCodeList(goodServiceOrderLists); | ||
82 | + | ||
83 | + if (CollectionUtils.isEmpty(appraiseOrderList)){ | ||
84 | + return; | ||
85 | + } | ||
86 | + List<AppraiseOrder> depositCodeList = appraiseOrderList.stream() | ||
87 | + .filter(appraiseOrder -> appraiseOrder.getAttributes() == OrderAttributes.DEPOSITE.getCode()) | ||
88 | + .collect(Collectors.toList()); | ||
89 | + | ||
90 | + executorService.execute(() -> { | ||
91 | + // 只返4单 | ||
92 | + int DEFAULT_REBATE_CNT = alipayTransferChancelSelector.getDepositRebateOrderCnt(); | ||
93 | + BigDecimal rebate = new BigDecimal(alipayTransferChancelSelector.getDepositRebateAmount()); | ||
94 | + | ||
95 | + depositCodeList.stream().forEach(depositCode -> { | ||
96 | + | ||
97 | + int rebateCnt = ordersPayTransferMapper.selectByUidAndTransferType(depositCode.getUid(), TransferCase.DEPOSIT_REBATE_TO_USER.getCode()); | ||
98 | + logger.info("rebate transfer cnt {}, uid {}", rebateCnt, depositCode.getUid()); | ||
99 | + if (rebateCnt < DEFAULT_REBATE_CNT){ | ||
100 | + TransferCase transferCase = TransferCase.DEPOSIT_REBATE_TO_USER; | ||
101 | + TranseferCellNode transeferCellNode = new TranseferCellNode(); | ||
102 | + transeferCellNode.setUid(depositCode.getUid()); | ||
103 | + transeferCellNode.setAmount(rebate.setScale(2,BigDecimal.ROUND_HALF_DOWN)); | ||
104 | + | ||
105 | + TransferMoneyRequest tmReq = TransferMoneyRequest.builder() | ||
106 | + .sellerUid(depositCode.getUid()) | ||
107 | + .buyerOrderCode(depositCode.getOrderCode()) | ||
108 | + .type(transferCase.getCode()) | ||
109 | + .transferCase(transferCase) | ||
110 | + .transeferCellNode(transeferCellNode) | ||
111 | + .swdType(SellerWalletDetail.Type.DEPOSIT_REBATE) | ||
112 | + .alarmConfig(AlarmConfig.DEPOSIT_REBATE_FAIL) // 打款失败的时候警告 | ||
113 | + .build(); | ||
114 | + | ||
115 | + transferService.transfer(tmReq); | ||
116 | + } | ||
117 | + | ||
118 | + }); | ||
119 | + | ||
120 | + }); | ||
121 | + | ||
122 | + } | ||
123 | + | ||
26 | 124 | ||
27 | @Override | 125 | @Override |
28 | public int deliver2Depot(DeliverToDepotReq req){ | 126 | public int deliver2Depot(DeliverToDepotReq req){ |
@@ -19,23 +19,31 @@ import com.yohoufo.common.utils.DateUtil; | @@ -19,23 +19,31 @@ import com.yohoufo.common.utils.DateUtil; | ||
19 | import com.yohoufo.dal.order.AppraiseOrderGoodsMapper; | 19 | import com.yohoufo.dal.order.AppraiseOrderGoodsMapper; |
20 | import com.yohoufo.dal.order.AppraiseOrderMapper; | 20 | import com.yohoufo.dal.order.AppraiseOrderMapper; |
21 | import com.yohoufo.dal.order.AppraiseOrderMetaMapper; | 21 | import com.yohoufo.dal.order.AppraiseOrderMetaMapper; |
22 | +import com.yohoufo.dal.order.OrdersPayTransferMapper; | ||
22 | import com.yohoufo.dal.order.model.*; | 23 | import com.yohoufo.dal.order.model.*; |
23 | import com.yohoufo.order.common.ClientType; | 24 | import com.yohoufo.order.common.ClientType; |
25 | +import com.yohoufo.order.common.TransferCase; | ||
26 | +import com.yohoufo.order.constants.AlarmConfig; | ||
24 | import com.yohoufo.order.constants.MetaKey; | 27 | import com.yohoufo.order.constants.MetaKey; |
25 | import com.yohoufo.order.convert.AppraiseOrderGoodsConvertor; | 28 | import com.yohoufo.order.convert.AppraiseOrderGoodsConvertor; |
26 | import com.yohoufo.order.convert.SellerOrderConvertor; | 29 | import com.yohoufo.order.convert.SellerOrderConvertor; |
27 | import com.yohoufo.order.model.dto.AppraiseOrderContext; | 30 | import com.yohoufo.order.model.dto.AppraiseOrderContext; |
31 | +import com.yohoufo.order.model.request.TranseferCellNode; | ||
32 | +import com.yohoufo.order.model.request.TransferMoneyRequest; | ||
28 | import com.yohoufo.order.service.IExpressInfoService; | 33 | import com.yohoufo.order.service.IExpressInfoService; |
29 | import com.yohoufo.order.service.IGoodsService; | 34 | import com.yohoufo.order.service.IGoodsService; |
30 | import com.yohoufo.order.service.handler.GoodsServiceRefundHandler; | 35 | import com.yohoufo.order.service.handler.GoodsServiceRefundHandler; |
36 | +import com.yohoufo.order.service.handler.transfer.AlipayTransferChancelSelector; | ||
31 | import com.yohoufo.order.service.proxy.InBoxFacade; | 37 | import com.yohoufo.order.service.proxy.InBoxFacade; |
32 | import com.yohoufo.order.service.proxy.ProductProxyService; | 38 | import com.yohoufo.order.service.proxy.ProductProxyService; |
33 | import com.yohoufo.order.service.proxy.UserProxyService; | 39 | import com.yohoufo.order.service.proxy.UserProxyService; |
34 | import com.yohoufo.order.service.support.codegenerator.OrderCodeGenerator; | 40 | import com.yohoufo.order.service.support.codegenerator.OrderCodeGenerator; |
35 | import com.yohoufo.order.utils.AddressHelper; | 41 | import com.yohoufo.order.utils.AddressHelper; |
36 | import com.yohoufo.order.utils.LoggerUtils; | 42 | import com.yohoufo.order.utils.LoggerUtils; |
43 | +import com.yohoufo.order.utils.NamedThreadFactory; | ||
37 | import lombok.Builder; | 44 | import lombok.Builder; |
38 | import lombok.Data; | 45 | import lombok.Data; |
46 | +import org.apache.commons.collections.CollectionUtils; | ||
39 | import org.apache.commons.lang3.StringUtils; | 47 | import org.apache.commons.lang3.StringUtils; |
40 | import org.slf4j.Logger; | 48 | import org.slf4j.Logger; |
41 | import org.springframework.beans.factory.annotation.Autowired; | 49 | import org.springframework.beans.factory.annotation.Autowired; |
@@ -46,6 +54,10 @@ import java.util.ArrayList; | @@ -46,6 +54,10 @@ import java.util.ArrayList; | ||
46 | import java.util.List; | 54 | import java.util.List; |
47 | import java.util.Map; | 55 | import java.util.Map; |
48 | import java.util.Objects; | 56 | import java.util.Objects; |
57 | +import java.util.concurrent.ArrayBlockingQueue; | ||
58 | +import java.util.concurrent.ExecutorService; | ||
59 | +import java.util.concurrent.ThreadPoolExecutor; | ||
60 | +import java.util.concurrent.TimeUnit; | ||
49 | import java.util.function.Function; | 61 | import java.util.function.Function; |
50 | import java.util.stream.Collectors; | 62 | import java.util.stream.Collectors; |
51 | 63 | ||
@@ -68,10 +80,6 @@ public class AppraiseOrderService extends AbsGoodsServiceOrderService implements | @@ -68,10 +80,6 @@ public class AppraiseOrderService extends AbsGoodsServiceOrderService implements | ||
68 | @Autowired | 80 | @Autowired |
69 | IExpressInfoService expressInfoService; | 81 | IExpressInfoService expressInfoService; |
70 | 82 | ||
71 | - | ||
72 | - @Autowired | ||
73 | - private OrderCodeGenerator orderCodeGenerator; | ||
74 | - | ||
75 | @Autowired | 83 | @Autowired |
76 | private AppraiseOrderMetaMapper appraiseOrderMetaMapper; | 84 | private AppraiseOrderMetaMapper appraiseOrderMetaMapper; |
77 | 85 | ||
@@ -87,6 +95,18 @@ public class AppraiseOrderService extends AbsGoodsServiceOrderService implements | @@ -87,6 +95,18 @@ public class AppraiseOrderService extends AbsGoodsServiceOrderService implements | ||
87 | @Autowired | 95 | @Autowired |
88 | private PayRefundService payRefundService; | 96 | private PayRefundService payRefundService; |
89 | 97 | ||
98 | + @Autowired | ||
99 | + OrderCodeGenerator orderCodeGenerator; | ||
100 | + | ||
101 | + @Autowired | ||
102 | + private AlipayTransferChancelSelector alipayTransferChancelSelector; | ||
103 | + | ||
104 | + @Autowired | ||
105 | + TransferService transferService; | ||
106 | + | ||
107 | + @Autowired | ||
108 | + OrdersPayTransferMapper ordersPayTransferMapper; | ||
109 | + | ||
90 | 110 | ||
91 | public AppraiseOrderComputeResp compute(AppraiseOrderComputeReq req){ | 111 | public AppraiseOrderComputeResp compute(AppraiseOrderComputeReq req){ |
92 | logger.info("in AppraiseOrderService.compute req {}", req); | 112 | logger.info("in AppraiseOrderService.compute req {}", req); |
@@ -21,6 +21,7 @@ import com.yohoufo.dal.order.*; | @@ -21,6 +21,7 @@ import com.yohoufo.dal.order.*; | ||
21 | import com.yohoufo.dal.order.model.*; | 21 | import com.yohoufo.dal.order.model.*; |
22 | import com.yohoufo.order.common.BillTradeStatus; | 22 | import com.yohoufo.order.common.BillTradeStatus; |
23 | import com.yohoufo.order.common.HbfqEnum; | 23 | import com.yohoufo.order.common.HbfqEnum; |
24 | +import com.yohoufo.order.common.TradeType; | ||
24 | import com.yohoufo.order.common.TransferCase; | 25 | import com.yohoufo.order.common.TransferCase; |
25 | import com.yohoufo.order.constants.RefundContant; | 26 | import com.yohoufo.order.constants.RefundContant; |
26 | import com.yohoufo.order.model.PayQueryBo; | 27 | import com.yohoufo.order.model.PayQueryBo; |
@@ -100,9 +101,6 @@ public class PaymentServiceImpl implements IPaymentService { | @@ -100,9 +101,6 @@ public class PaymentServiceImpl implements IPaymentService { | ||
100 | MerchantOrderPaymentService merchantOrderPaymentService; | 101 | MerchantOrderPaymentService merchantOrderPaymentService; |
101 | 102 | ||
102 | @Autowired | 103 | @Autowired |
103 | - OrderCodeGenerator orderCodeGenerator; | ||
104 | - | ||
105 | - @Autowired | ||
106 | WeixinPayUFORealAppService weixinPayAppService; | 104 | WeixinPayUFORealAppService weixinPayAppService; |
107 | 105 | ||
108 | @Autowired | 106 | @Autowired |
@@ -171,6 +169,9 @@ public class PaymentServiceImpl implements IPaymentService { | @@ -171,6 +169,9 @@ public class PaymentServiceImpl implements IPaymentService { | ||
171 | @Autowired | 169 | @Autowired |
172 | private RefundManager refundManager; | 170 | private RefundManager refundManager; |
173 | 171 | ||
172 | + @Autowired | ||
173 | + OrderCodeGenerator orderCodeGenerator; | ||
174 | + | ||
174 | 175 | ||
175 | /** | 176 | /** |
176 | * 订单支付结果确认 | 177 | * 订单支付结果确认 |
@@ -419,6 +420,11 @@ public class PaymentServiceImpl implements IPaymentService { | @@ -419,6 +420,11 @@ public class PaymentServiceImpl implements IPaymentService { | ||
419 | 420 | ||
420 | 421 | ||
421 | private void penaltyEarnestIfWalletSellerOrder(BiFunction penaltyEarnestFunction, SellerWalletDetail.Type swdType, SellerOrder sellerOrder) { | 422 | private void penaltyEarnestIfWalletSellerOrder(BiFunction penaltyEarnestFunction, SellerWalletDetail.Type swdType, SellerOrder sellerOrder) { |
423 | + | ||
424 | + if (sellerOrder == null){ | ||
425 | + return; | ||
426 | + } | ||
427 | + | ||
422 | Integer sellerUid = sellerOrder.getUid(); | 428 | Integer sellerUid = sellerOrder.getUid(); |
423 | Long sellerOrderCode = sellerOrder.getOrderCode(); | 429 | Long sellerOrderCode = sellerOrder.getOrderCode(); |
424 | Integer skup = sellerOrder.getSkup(); | 430 | Integer skup = sellerOrder.getSkup(); |
@@ -462,6 +468,7 @@ public class PaymentServiceImpl implements IPaymentService { | @@ -462,6 +468,7 @@ public class PaymentServiceImpl implements IPaymentService { | ||
462 | Integer targetUid = transferMoneyModel.getTargetUid(); | 468 | Integer targetUid = transferMoneyModel.getTargetUid(); |
463 | int now = transferMoneyModel.getNow(); | 469 | int now = transferMoneyModel.getNow(); |
464 | 470 | ||
471 | + | ||
465 | penaltyEarnestIfWalletSellerOrder(request.getPenaltyEarnestFunction(), request.getSwdType(), sellerOrder); | 472 | penaltyEarnestIfWalletSellerOrder(request.getPenaltyEarnestFunction(), request.getSwdType(), sellerOrder); |
466 | 473 | ||
467 | OrdersPayTransfer transfer = createTransfer(buyerOrderCode, sellerOrderCode, transferCase.getCode(), null, targetUid, BigDecimal.ZERO, now); | 474 | OrdersPayTransfer transfer = createTransfer(buyerOrderCode, sellerOrderCode, transferCase.getCode(), null, targetUid, BigDecimal.ZERO, now); |
@@ -1310,7 +1317,12 @@ public class PaymentServiceImpl implements IPaymentService { | @@ -1310,7 +1317,12 @@ public class PaymentServiceImpl implements IPaymentService { | ||
1310 | } | 1317 | } |
1311 | 1318 | ||
1312 | public TransferMoneyModel invoke() { | 1319 | public TransferMoneyModel invoke() { |
1320 | + | ||
1313 | buyerOrderCode = request.getBuyerOrderCode(); | 1321 | buyerOrderCode = request.getBuyerOrderCode(); |
1322 | + | ||
1323 | + CodeMeta codeMeta = orderCodeGenerator.expId(buyerOrderCode); | ||
1324 | + // 买家订单号 | ||
1325 | + if (codeMeta.getType() == OrderCodeType.BUYER_TYPE.getType()){ | ||
1314 | logTag = String.format("transfer money orderCode is %s", buyerOrderCode); | 1326 | logTag = String.format("transfer money orderCode is %s", buyerOrderCode); |
1315 | // 订单号check | 1327 | // 订单号check |
1316 | if (buyerOrderCode < 1L) { | 1328 | if (buyerOrderCode < 1L) { |
@@ -1357,7 +1369,35 @@ public class PaymentServiceImpl implements IPaymentService { | @@ -1357,7 +1369,35 @@ public class PaymentServiceImpl implements IPaymentService { | ||
1357 | now = (int) (System.currentTimeMillis() / 1000); | 1369 | now = (int) (System.currentTimeMillis() / 1000); |
1358 | // 查看是否已经有转账记录 | 1370 | // 查看是否已经有转账记录 |
1359 | checkTransferExist(buyerOrderCode); | 1371 | checkTransferExist(buyerOrderCode); |
1372 | + } | ||
1373 | + // 商品服务 | ||
1374 | + else if(codeMeta.getType() == OrderCodeType.GOODS_SERVICE.getType()){ | ||
1375 | + | ||
1376 | + | ||
1377 | + logTag = String.format("transfer money orderCode is %s", buyerOrderCode); | ||
1378 | + | ||
1379 | + // 类型检查 | ||
1380 | + transferCase = TransferCase.getTransferCase(request.getType()); | ||
1381 | + if (transferCase == null) { | ||
1382 | + logger.warn("{}, transfer fail transferType invalid", logTag); | ||
1383 | + throw new ServiceException(ServiceError.ORDER_REQUEST_PARM_IS_EMPTY); | ||
1384 | + } | ||
1385 | + | ||
1386 | + // 商品返利的场合,不存在 买家订单号|卖家订单号的区分 | ||
1387 | + sellerOrderCode = buyerOrderCode; | ||
1388 | + targetUserType = TargetUserType.seller; | ||
1389 | + targetUid = request.getSellerUid(); | ||
1390 | + | ||
1391 | + if (targetUid == null || targetUid < 1) { | ||
1392 | + logger.warn("{}, transfer fail uid {} invalid", logTag, targetUid); | ||
1393 | + throw new ServiceException(400, "uid[" + targetUid + "]不合法"); | ||
1394 | + } | ||
1395 | + now = (int) (System.currentTimeMillis() / 1000); | ||
1396 | + | ||
1397 | + } | ||
1398 | + | ||
1360 | return this; | 1399 | return this; |
1400 | + | ||
1361 | } | 1401 | } |
1362 | 1402 | ||
1363 | 1403 | ||
@@ -1370,7 +1410,11 @@ public class PaymentServiceImpl implements IPaymentService { | @@ -1370,7 +1410,11 @@ public class PaymentServiceImpl implements IPaymentService { | ||
1370 | record.setUserType(targetUserType.getCode()); | 1410 | record.setUserType(targetUserType.getCode()); |
1371 | record.setPayType(1); | 1411 | record.setPayType(1); |
1372 | // 如果[全部货款->卖家],否则[补偿款->卖家或买家] 2:货款;3:补偿款 | 1412 | // 如果[全部货款->卖家],否则[补偿款->卖家或买家] 2:货款;3:补偿款 |
1373 | - record.setTradeType(transferCase == TransferCase.ALL_GOODS_MONEY_TO_SELLER ? 2 : 3); | 1413 | + if (transferCase == TransferCase.DEPOSIT_REBATE_TO_USER){ |
1414 | + record.setTradeType(TradeType.deposit_rebate.getCode()); // 返利 | ||
1415 | + }else{ | ||
1416 | + record.setTradeType(transferCase == TransferCase.ALL_GOODS_MONEY_TO_SELLER ? TradeType.goods_income.getCode() : TradeType.compensateIncome.getCode()); | ||
1417 | + } | ||
1374 | record.setIncomeOutcome(1); | 1418 | record.setIncomeOutcome(1); |
1375 | record.setTradeStatus(BillTradeStatus.NEW.getCode()); | 1419 | record.setTradeStatus(BillTradeStatus.NEW.getCode()); |
1376 | record.setCreateTime(now); | 1420 | record.setCreateTime(now); |
-
Please register or login to post a comment