Authored by chenchao

super entry seller

@@ -16,6 +16,15 @@ @@ -16,6 +16,15 @@
16 from super_entry_seller 16 from super_entry_seller
17 where uid = #{uid,jdbcType=INTEGER} 17 where uid = #{uid,jdbcType=INTEGER}
18 </select> 18 </select>
  19 +
  20 +
  21 + <select id="selectAll" parameterType="java.lang.Short" resultMap="BaseResultMap">
  22 + select
  23 + <include refid="Base_Column_List" />
  24 + from super_entry_seller
  25 + where status = #{status,jdbcType=SMALLINT}
  26 + </select>
  27 +
19 <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer"> 28 <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
20 delete from super_entry_seller 29 delete from super_entry_seller
21 where uid = #{uid,jdbcType=INTEGER} 30 where uid = #{uid,jdbcType=INTEGER}
@@ -16,6 +16,7 @@ import com.yohoufo.order.model.request.OrderRequest; @@ -16,6 +16,7 @@ import com.yohoufo.order.model.request.OrderRequest;
16 import com.yohoufo.order.model.response.OrderSubmitResp; 16 import com.yohoufo.order.model.response.OrderSubmitResp;
17 import com.yohoufo.order.service.handler.SellerOrderComputeHandler; 17 import com.yohoufo.order.service.handler.SellerOrderComputeHandler;
18 import com.yohoufo.order.service.impl.SellerOrderService; 18 import com.yohoufo.order.service.impl.SellerOrderService;
  19 +import com.yohoufo.order.service.impl.SellerService;
19 import org.apache.kafka.common.requests.LeaderAndIsrRequest; 20 import org.apache.kafka.common.requests.LeaderAndIsrRequest;
20 import org.slf4j.Logger; 21 import org.slf4j.Logger;
21 import org.slf4j.LoggerFactory; 22 import org.slf4j.LoggerFactory;
@@ -279,4 +280,19 @@ public class SellerOrderController { @@ -279,4 +280,19 @@ public class SellerOrderController {
279 return new ApiResponse.ApiResponseBuilder().code(200).data(orderListInfoRsp).message("刷新成功").build(); 280 return new ApiResponse.ApiResponseBuilder().code(200).data(orderListInfoRsp).message("刷新成功").build();
280 } 281 }
281 282
  283 + @Autowired
  284 + private SellerService sellerService;
  285 +
  286 +
  287 + @RequestMapping(params = "method=ufo.order.isSurperEntrySeller")
  288 + @ResponseBody
  289 + public ApiResponse isSurperEntrySeller(
  290 + @RequestParam("uid") int uid) {
  291 +
  292 + boolean isSuper = sellerService.isSuperEntrySeller(uid);
  293 + return new ApiResponse.ApiResponseBuilder().code(200).data(isSuper).message("刷新成功").build();
  294 + }
  295 +
  296 +
  297 +
282 } 298 }
@@ -19,4 +19,5 @@ public class BatchPublishTailEvent extends Event { @@ -19,4 +19,5 @@ public class BatchPublishTailEvent extends Event {
19 19
20 private SellerOrderSubmitHandler.ForkJoinResult fjr; 20 private SellerOrderSubmitHandler.ForkJoinResult fjr;
21 private SellerWallet sellerWallet; 21 private SellerWallet sellerWallet;
  22 + private boolean isSurper;
22 } 23 }
1 package com.yohoufo.order.model.request; 1 package com.yohoufo.order.model.request;
2 2
3 import com.yohobuy.ufo.model.order.bo.MerchantOrderAttachInfo; 3 import com.yohobuy.ufo.model.order.bo.MerchantOrderAttachInfo;
4 -import com.yohoufo.dal.order.model.SellerWalletDetail;  
5 import com.yohoufo.order.common.RefundCase; 4 import com.yohoufo.order.common.RefundCase;
6 import lombok.AllArgsConstructor; 5 import lombok.AllArgsConstructor;
7 import lombok.Data; 6 import lombok.Data;
@@ -34,4 +33,6 @@ public class PaymentRequest { @@ -34,4 +33,6 @@ public class PaymentRequest {
34 private RefundCase refundCase; 33 private RefundCase refundCase;
35 34
36 private MerchantOrderAttachInfo refundattch; 35 private MerchantOrderAttachInfo refundattch;
  36 +
  37 + private boolean isSuper;
37 } 38 }
@@ -80,7 +80,7 @@ public class SellerOrderCancelDeliverDelayMsgConsumer implements YhConsumer { @@ -80,7 +80,7 @@ public class SellerOrderCancelDeliverDelayMsgConsumer implements YhConsumer {
80 transferService.transfer(tmReq); 80 transferService.transfer(tmReq);
81 // 81 //
82 BigDecimal goodsMoney = buyerOrder.getAmount(); 82 BigDecimal goodsMoney = buyerOrder.getAmount();
83 - PaymentRequest req = PaymentRequest.builder().uid(buyerUid) 83 + PaymentRequest req = PaymentRequest.builder().uid(buyerUid).refundCase(RefundCase.BUYER_GOODS_MONEY)
84 .orderCode(orderCode).refundAmount(goodsMoney.doubleValue()) 84 .orderCode(orderCode).refundAmount(goodsMoney.doubleValue())
85 .build(); 85 .build();
86 BillLogEvent.BillLogEventBuilder bleb = BillLogEvent.builder() 86 BillLogEvent.BillLogEventBuilder bleb = BillLogEvent.builder()
@@ -28,17 +28,19 @@ public class BatchPublishTailHandler implements IEventHandler<BatchPublishTailEv @@ -28,17 +28,19 @@ public class BatchPublishTailHandler implements IEventHandler<BatchPublishTailEv
28 @Override 28 @Override
29 @Subscribe 29 @Subscribe
30 public void handle(BatchPublishTailEvent event) { 30 public void handle(BatchPublishTailEvent event) {
31 - batchPublishTailProcess(event.getFjr(), event.getSellerWallet()); 31 + batchPublishTailProcess(event.getFjr(), event.getSellerWallet(), event.isSurper());
32 } 32 }
33 33
34 - private void batchPublishTailProcess(SellerOrderSubmitHandler.ForkJoinResult fjr, SellerWallet sellerWallet){ 34 + private void batchPublishTailProcess(SellerOrderSubmitHandler.ForkJoinResult fjr, SellerWallet sellerWallet, boolean isSurper){
35 35
36 // (异步实现)记录保证金流水 36 // (异步实现)记录保证金流水
37 - List<OrderInfo> orderList = fjr.getSellerOrderList().parallelStream().map(sellerOrder ->  
38 - OrderInfo.builder().orderCode(sellerOrder.getOrderCode())  
39 - .amount(sellerOrder.getEarnestMoney()).build()  
40 - ).collect(Collectors.toList());  
41 - merchantOrderPaymentService.useEarnestAddWalletDetail(sellerWallet, orderList); 37 + if(!isSurper) {
  38 + List<OrderInfo> orderList = fjr.getSellerOrderList().parallelStream().map(sellerOrder ->
  39 + OrderInfo.builder().orderCode(sellerOrder.getOrderCode())
  40 + .amount(sellerOrder.getEarnestMoney()).build()
  41 + ).collect(Collectors.toList());
  42 + merchantOrderPaymentService.useEarnestAddWalletDetail(sellerWallet, orderList);
  43 + }
42 //(异步实现)同步数据到prd,记录支付, 44 //(异步实现)同步数据到prd,记录支付,
43 productProxyService.batchCreateSkup(fjr.getSellerOrderGoodsList()); 45 productProxyService.batchCreateSkup(fjr.getSellerOrderGoodsList());
44 productProxyService.sellerBatchUpdateStatus(fjr.getSkupIds(), ProductProxyService.PrdShelvelStatus.on); 46 productProxyService.sellerBatchUpdateStatus(fjr.getSkupIds(), ProductProxyService.PrdShelvelStatus.on);
@@ -84,6 +84,9 @@ public class AppraiseService { @@ -84,6 +84,9 @@ public class AppraiseService {
84 @Autowired 84 @Autowired
85 private CacheCleaner cacheCleaner; 85 private CacheCleaner cacheCleaner;
86 86
  87 + @Autowired
  88 + private SellerService sellerService;
  89 +
87 90
88 public ApiResponse appraiseSuccess(Integer expressCompanyId, Long orderCode, String wayBillCode,Integer depotNum){ 91 public ApiResponse appraiseSuccess(Integer expressCompanyId, Long orderCode, String wayBillCode,Integer depotNum){
89 ApiResponse apiResponse=new ApiResponse(); 92 ApiResponse apiResponse=new ApiResponse();
@@ -152,15 +155,18 @@ public class AppraiseService { @@ -152,15 +155,18 @@ public class AppraiseService {
152 */ 155 */
153 //refund earnestMoney 156 //refund earnestMoney
154 BigDecimal earnestMoney = sellerOrder.getEarnestMoney(); 157 BigDecimal earnestMoney = sellerOrder.getEarnestMoney();
155 - PaymentRequest req = PaymentRequest.builder().uid(sellerUid) 158 + PaymentRequest refundReqOfSeller = PaymentRequest.builder().uid(sellerUid)
  159 + .refundCase(RefundCase.SELLER_EARNEST_MONEY)
156 .orderCode(sellerOrderCode).refundAmount(earnestMoney.doubleValue()) 160 .orderCode(sellerOrderCode).refundAmount(earnestMoney.doubleValue())
157 .build(); 161 .build();
158 - if (PaymentHelper.isWallet(sellerOrder.getPayment())){ 162 + boolean sellerIsSurper = sellerService.isSuperEntrySeller(sellerUid);
  163 + refundReqOfSeller.setSuper(sellerIsSurper);
  164 + if (!sellerIsSurper && PaymentHelper.isWallet(sellerOrder.getPayment())){
159 SellerWalletDetail.Type swdType = SellerWalletDetail.Type.APPRAISE_OK; 165 SellerWalletDetail.Type swdType = SellerWalletDetail.Type.APPRAISE_OK;
160 MerchantOrderAttachInfo moai = MerchantOrderAttachInfo.builder().uid(sellerUid) 166 MerchantOrderAttachInfo moai = MerchantOrderAttachInfo.builder().uid(sellerUid)
161 .orderCode(sellerOrderCode).skup(skup).earnestMoney(sellerOrder.getEarnestMoney()) 167 .orderCode(sellerOrderCode).skup(skup).earnestMoney(sellerOrder.getEarnestMoney())
162 .type(swdType.getValue()).build(); 168 .type(swdType.getValue()).build();
163 - req.setRefundattch(moai); 169 + refundReqOfSeller.setRefundattch(moai);
164 } 170 }
165 171
166 BillLogEvent.BillLogEventBuilder bleb = BillLogEvent.builder() 172 BillLogEvent.BillLogEventBuilder bleb = BillLogEvent.builder()
@@ -170,20 +176,21 @@ public class AppraiseService { @@ -170,20 +176,21 @@ public class AppraiseService {
170 SellerOrderGoods sellerOrderGoods; 176 SellerOrderGoods sellerOrderGoods;
171 sellerOrderGoods = sellerOrderGoodsMapper.selectByPrimaryKey(skup); 177 sellerOrderGoods = sellerOrderGoodsMapper.selectByPrimaryKey(skup);
172 try { 178 try {
173 - payRefundService.refund(req, bleb); 179 + payRefundService.refund(refundReqOfSeller, bleb);
174 //通知卖家退还保证金 180 //通知卖家退还保证金
175 BuyerConfirmEvent buyerConfirmEvent = BuyerConfirmEvent.builder().uid(buyerUid).orderCode(orderCode).build(); 181 BuyerConfirmEvent buyerConfirmEvent = BuyerConfirmEvent.builder().uid(buyerUid).orderCode(orderCode).build();
176 EventBusPublisher.publishEvent(buyerConfirmEvent); 182 EventBusPublisher.publishEvent(buyerConfirmEvent);
177 //记录物流信息 183 //记录物流信息
178 expressInfoService.appraiseSuccess(buyerUid, expressCompanyId, orderCode, wayBillCode, depotNum); 184 expressInfoService.appraiseSuccess(buyerUid, expressCompanyId, orderCode, wayBillCode, depotNum);
179 //平台已发货给买家 185 //平台已发货给买家
180 -  
181 inBoxFacade.appraisePassNotice(buyerUid, orderCode, sellerOrderGoods); 186 inBoxFacade.appraisePassNotice(buyerUid, orderCode, sellerOrderGoods);
182 }catch (Exception ex){ 187 }catch (Exception ex){
183 - LOGGER.warn("in appraiseSuccess,refund fail, req {}", req, ex);  
184 - BillLogEvent sellerBillLogEvent = bleb.tradeStatus(BillTradeStatus.FAIL.getCode())  
185 - .build();  
186 - EventBusPublisher.publishEvent(sellerBillLogEvent); 188 + LOGGER.warn("in appraiseSuccess,refund fail, refundReqOfSeller {}", refundReqOfSeller, ex);
  189 + if (!sellerIsSurper) {
  190 + BillLogEvent sellerBillLogEvent = bleb.tradeStatus(BillTradeStatus.FAIL.getCode())
  191 + .build();
  192 + EventBusPublisher.publishEvent(sellerBillLogEvent);
  193 + }
187 String content = "鉴定通过时,订单"+ orderCode + "退还保证金失败"; 194 String content = "鉴定通过时,订单"+ orderCode + "退还保证金失败";
188 AlarmConfig alarmConfig = AlarmConfig.APPRAISE_SUCCESS; 195 AlarmConfig alarmConfig = AlarmConfig.APPRAISE_SUCCESS;
189 SmsAlarmEvent smsAlarmEvent = new SmsAlarmEvent(alarmConfig.getRefundName(), alarmConfig.name(), content); 196 SmsAlarmEvent smsAlarmEvent = new SmsAlarmEvent(alarmConfig.getRefundName(), alarmConfig.name(), content);
@@ -28,7 +28,6 @@ import com.yohoufo.order.service.proxy.CouponProxyService; @@ -28,7 +28,6 @@ import com.yohoufo.order.service.proxy.CouponProxyService;
28 import com.yohoufo.order.service.proxy.InBoxFacade; 28 import com.yohoufo.order.service.proxy.InBoxFacade;
29 import com.yohoufo.order.utils.LoggerUtils; 29 import com.yohoufo.order.utils.LoggerUtils;
30 import com.yohoufo.order.utils.PaymentHelper; 30 import com.yohoufo.order.utils.PaymentHelper;
31 -import lombok.Data;  
32 import lombok.Setter; 31 import lombok.Setter;
33 import org.slf4j.Logger; 32 import org.slf4j.Logger;
34 import org.springframework.beans.factory.annotation.Autowired; 33 import org.springframework.beans.factory.annotation.Autowired;
@@ -78,6 +77,9 @@ public class BuyerOrderCancelService { @@ -78,6 +77,9 @@ public class BuyerOrderCancelService {
78 @Autowired 77 @Autowired
79 private InBoxFacade inBoxFacade; 78 private InBoxFacade inBoxFacade;
80 79
  80 + @Autowired
  81 + private SellerService sellerService;
  82 +
81 83
82 public void cancel(BeforeSellerDeliverEvent bsdEvent){ 84 public void cancel(BeforeSellerDeliverEvent bsdEvent){
83 OrderDynamicConfig.BuyerCancelCompensateNode compensate = orderDynamicConfig.getBeforeSellerDeliverBCCN(); 85 OrderDynamicConfig.BuyerCancelCompensateNode compensate = orderDynamicConfig.getBeforeSellerDeliverBCCN();
@@ -210,34 +212,36 @@ public class BuyerOrderCancelService { @@ -210,34 +212,36 @@ public class BuyerOrderCancelService {
210 int sellerUid = sellerOrder.getUid(); 212 int sellerUid = sellerOrder.getUid();
211 long sellerOrderCode = sellerOrder.getOrderCode(); 213 long sellerOrderCode = sellerOrder.getOrderCode();
212 BigDecimal earnestMoney = sellerOrder.getEarnestMoney(); 214 BigDecimal earnestMoney = sellerOrder.getEarnestMoney();
213 - PaymentRequest req = PaymentRequest.builder().uid(sellerUid) 215 + PaymentRequest refundReqOfSeller = PaymentRequest.builder().uid(sellerUid)
214 .orderCode(sellerOrderCode).refundAmount(earnestMoney.doubleValue()) 216 .orderCode(sellerOrderCode).refundAmount(earnestMoney.doubleValue())
215 .build(); 217 .build();
216 - if (PaymentHelper.isWallet(sellerOrder.getPayment())){ 218 + boolean sellerIsSurper = sellerService.isSuperEntrySeller(sellerUid);
  219 + refundReqOfSeller.setSuper(sellerIsSurper);
  220 + if (!sellerIsSurper && PaymentHelper.isWallet(sellerOrder.getPayment())){
217 221
218 MerchantOrderAttachInfo moai = MerchantOrderAttachInfo.builder().uid(sellerUid) 222 MerchantOrderAttachInfo moai = MerchantOrderAttachInfo.builder().uid(sellerUid)
219 .orderCode(sellerOrderCode).skup(skup).earnestMoney(sellerOrder.getEarnestMoney()) 223 .orderCode(sellerOrderCode).skup(skup).earnestMoney(sellerOrder.getEarnestMoney())
220 .type(swdType.getValue()).build(); 224 .type(swdType.getValue()).build();
221 - req.setRefundattch(moai); 225 + refundReqOfSeller.setRefundattch(moai);
222 } 226 }
223 227
224 BillLogEvent.BillLogEventBuilder bleb = BillLogEvent.builder() 228 BillLogEvent.BillLogEventBuilder bleb = BillLogEvent.builder()
225 .buyerUid(buyerUid).sellerUid(sellerUid).orderCode(sellerOrder.getOrderCode()) 229 .buyerUid(buyerUid).sellerUid(sellerUid).orderCode(sellerOrder.getOrderCode())
226 .payType(sellerOrder.getPayment()).refundCase(RefundCase.SELLER_EARNEST_MONEY) 230 .payType(sellerOrder.getPayment()).refundCase(RefundCase.SELLER_EARNEST_MONEY)
227 .skup(skup); 231 .skup(skup);
228 - logger.info("in BuyerCancelAfterProcessTask call begin payRefundService.refund seller, buyerUid {}, orderCode {}, skup {} req {}",  
229 - buyerUid, orderCode, skup, req );  
230 - prb = payRefundService.refund(req, bleb);  
231 - logger.info("in BuyerCancelAfterProcessTask call after payRefundService.refund seller, buyerUid {}, orderCode {}, skup {} req {}",  
232 - buyerUid, orderCode, skup, req ); 232 + logger.info("in BuyerCancelAfterProcessTask call begin payRefundService.refund seller, buyerUid {}, orderCode {}, skup {} refundReqOfSeller {}",
  233 + buyerUid, orderCode, skup, refundReqOfSeller );
  234 + prb = payRefundService.refund(refundReqOfSeller, bleb);
  235 + logger.info("in BuyerCancelAfterProcessTask call after payRefundService.refund seller, buyerUid {}, orderCode {}, skup {} refundReqOfSeller {}",
  236 + buyerUid, orderCode, skup, refundReqOfSeller );
233 //(转账)瓜分指定赔偿款给卖家和平台 237 //(转账)瓜分指定赔偿款给卖家和平台
234 238
235 TransferMoneyRequest tmReq = TransferMoneyRequest.builder().buyerOrderCode(orderCode) 239 TransferMoneyRequest tmReq = TransferMoneyRequest.builder().buyerOrderCode(orderCode)
236 .type(transferCase.getCode()).transferCase(transferCase).build(); 240 .type(transferCase.getCode()).transferCase(transferCase).build();
237 - logger.info("in BuyerCancelAfterProcessTask call begin paymentService.transferMon, buyerUid {}, orderCode {}, skup {} req {}", 241 + logger.info("in BuyerCancelAfterProcessTask call begin paymentService.transferMon, buyerUid {}, orderCode {}, skup {} refundReqOfSeller {}",
238 buyerUid, orderCode, skup, tmReq ); 242 buyerUid, orderCode, skup, tmReq );
239 paymentService.transferMon(tmReq); 243 paymentService.transferMon(tmReq);
240 - logger.info("in BuyerCancelAfterProcessTask call after paymentService.transferMon, buyerUid {}, orderCode {}, skup {} req {}", 244 + logger.info("in BuyerCancelAfterProcessTask call after paymentService.transferMon, buyerUid {}, orderCode {}, skup {} refundReqOfSeller {}",
241 buyerUid, orderCode, skup, tmReq ); 245 buyerUid, orderCode, skup, tmReq );
242 246
243 //(退费)扣除赔偿款,计算剩余的货款,退给买家 247 //(退费)扣除赔偿款,计算剩余的货款,退给买家
@@ -253,10 +257,10 @@ public class BuyerOrderCancelService { @@ -253,10 +257,10 @@ public class BuyerOrderCancelService {
253 .buyerUid(buyerUid).sellerUid(sellerUid).orderCode(orderCode) 257 .buyerUid(buyerUid).sellerUid(sellerUid).orderCode(orderCode)
254 .payType(buyerOrder.getPayment()).refundCase(RefundCase.BUYER_GOODS_MONEY) 258 .payType(buyerOrder.getPayment()).refundCase(RefundCase.BUYER_GOODS_MONEY)
255 .skup(skup); 259 .skup(skup);
256 - logger.info("in BuyerCancelAfterProcessTask call begin payRefundService.refund buyer, buyerUid {}, orderCode {}, skup {} req {}", 260 + logger.info("in BuyerCancelAfterProcessTask call begin payRefundService.refund buyer, buyerUid {}, orderCode {}, skup {} refundReqOfSeller {}",
257 buyerUid, orderCode, skup, rprOfBuyer ); 261 buyerUid, orderCode, skup, rprOfBuyer );
258 payRefundService.refund(rprOfBuyer, blebOfBuyer); 262 payRefundService.refund(rprOfBuyer, blebOfBuyer);
259 - logger.info("in BuyerCancelAfterProcessTask call after payRefundService.refund buyer, buyerUid {}, orderCode {}, skup {} req {}", 263 + logger.info("in BuyerCancelAfterProcessTask call after payRefundService.refund buyer, buyerUid {}, orderCode {}, skup {} refundReqOfSeller {}",
260 buyerUid, orderCode, skup, rprOfBuyer ); 264 buyerUid, orderCode, skup, rprOfBuyer );
261 265
262 logger.info("out BuyerCancelAfterProcessTask call buyerUid {}, orderCode {}, skup {}, transferCase {}, compensate {}", 266 logger.info("out BuyerCancelAfterProcessTask call buyerUid {}, orderCode {}, skup {}, transferCase {}, compensate {}",
@@ -2,6 +2,7 @@ package com.yohoufo.order.service.impl; @@ -2,6 +2,7 @@ package com.yohoufo.order.service.impl;
2 2
3 import com.yohoufo.common.alarm.EventBusPublisher; 3 import com.yohoufo.common.alarm.EventBusPublisher;
4 import com.yohoufo.order.common.BillTradeStatus; 4 import com.yohoufo.order.common.BillTradeStatus;
  5 +import com.yohoufo.order.common.RefundCase;
5 import com.yohoufo.order.constants.RefundContant; 6 import com.yohoufo.order.constants.RefundContant;
6 import com.yohoufo.order.event.BillLogEvent; 7 import com.yohoufo.order.event.BillLogEvent;
7 import com.yohoufo.order.model.PayRefundBo; 8 import com.yohoufo.order.model.PayRefundBo;
@@ -25,12 +26,19 @@ public class PayRefundService { @@ -25,12 +26,19 @@ public class PayRefundService {
25 26
26 public PayRefundBo refund(PaymentRequest refundReq, BillLogEvent.BillLogEventBuilder bleBuilder){ 27 public PayRefundBo refund(PaymentRequest refundReq, BillLogEvent.BillLogEventBuilder bleBuilder){
27 logger.info("in pay refund, refundReq {}", refundReq); 28 logger.info("in pay refund, refundReq {}", refundReq);
  29 + boolean toSeller = refundReq.getRefundCase() !=null && RefundCase.SELLER_EARNEST_MONEY == refundReq.getRefundCase();
  30 + if(refundReq.isSuper() && toSeller){
  31 + return null;
  32 + }
28 PayRefundBo refundResp = paymentService.refund(refundReq); 33 PayRefundBo refundResp = paymentService.refund(refundReq);
  34 +
  35 +
  36 +
29 BillLogEvent buyererBillLogEvent; 37 BillLogEvent buyererBillLogEvent;
30 - int status ; 38 + int status;
31 if (refundReq != null && RefundContant.PAYMENT_REFUND_RESULTCODE_SUCCESS == refundResp.getRefundStatus()) { 39 if (refundReq != null && RefundContant.PAYMENT_REFUND_RESULTCODE_SUCCESS == refundResp.getRefundStatus()) {
32 status = BillTradeStatus.SUCCESS.getCode(); 40 status = BillTradeStatus.SUCCESS.getCode();
33 - }else{ 41 + } else {
34 status = BillTradeStatus.FAIL.getCode(); 42 status = BillTradeStatus.FAIL.getCode();
35 } 43 }
36 buyererBillLogEvent = bleBuilder.tradeStatus(status).build(); 44 buyererBillLogEvent = bleBuilder.tradeStatus(status).build();
@@ -86,6 +86,9 @@ public class SellerOrderCancelService { @@ -86,6 +86,9 @@ public class SellerOrderCancelService {
86 @Autowired 86 @Autowired
87 private PayRefundService payRefundService; 87 private PayRefundService payRefundService;
88 88
  89 + @Autowired
  90 + private SellerService sellerService;
  91 +
89 /** 92 /**
90 * TODO 如何控制好并发,必须控制不能重复转账 退款 93 * TODO 如何控制好并发,必须控制不能重复转账 退款
91 * 使用乐观锁,带着查询到的状态且符合条件时再去更新 94 * 使用乐观锁,带着查询到的状态且符合条件时再去更新
@@ -281,7 +284,6 @@ public class SellerOrderCancelService { @@ -281,7 +284,6 @@ public class SellerOrderCancelService {
281 } 284 }
282 285
283 286
284 -  
285 private int cancelAfterPayButNotBuyAction(SellerOrder sellerOrder){ 287 private int cancelAfterPayButNotBuyAction(SellerOrder sellerOrder){
286 /**case 2: 支付完成,没有买家下单 288 /**case 2: 支付完成,没有买家下单
287 * actions as blow: 289 * actions as blow:
@@ -303,10 +305,12 @@ public class SellerOrderCancelService { @@ -303,10 +305,12 @@ public class SellerOrderCancelService {
303 305
304 if(result > 0 ){ 306 if(result > 0 ){
305 double earnestMoney = sellerOrder.getEarnestMoney().doubleValue(); 307 double earnestMoney = sellerOrder.getEarnestMoney().doubleValue();
  308 + boolean isSurper = sellerService.isSuperEntrySeller(sellerUid);
306 PaymentRequest refundReq = PaymentRequest.builder().uid(sellerUid) 309 PaymentRequest refundReq = PaymentRequest.builder().uid(sellerUid)
307 - .orderCode(orderCode) 310 + .orderCode(orderCode).isSuper(isSurper)
308 .refundAmount(earnestMoney).build(); 311 .refundAmount(earnestMoney).build();
309 - if (PaymentHelper.isWallet(sellerOrder.getPayment())){ 312 +
  313 + if (!isSurper && PaymentHelper.isWallet(sellerOrder.getPayment())){
310 SellerWalletDetail.Type swdType = SellerWalletDetail.Type.SELLER_OFF; 314 SellerWalletDetail.Type swdType = SellerWalletDetail.Type.SELLER_OFF;
311 MerchantOrderAttachInfo moai = MerchantOrderAttachInfo.builder().uid(sellerUid) 315 MerchantOrderAttachInfo moai = MerchantOrderAttachInfo.builder().uid(sellerUid)
312 .orderCode(orderCode).skup(skup).earnestMoney(sellerOrder.getEarnestMoney()) 316 .orderCode(orderCode).skup(skup).earnestMoney(sellerOrder.getEarnestMoney())
@@ -326,9 +330,11 @@ public class SellerOrderCancelService { @@ -326,9 +330,11 @@ public class SellerOrderCancelService {
326 sellerUid, orderCode, skup, earnestMoney); 330 sellerUid, orderCode, skup, earnestMoney);
327 }catch (Exception ex){ 331 }catch (Exception ex){
328 logger.warn("in appraiseSuccess, refund fail, req {}", refundReq, ex); 332 logger.warn("in appraiseSuccess, refund fail, req {}", refundReq, ex);
329 - BillLogEvent sellerBillLogEvent = bleb.tradeStatus(BillTradeStatus.FAIL.getCode())  
330 - .build();  
331 - EventBusPublisher.publishEvent(sellerBillLogEvent); 333 + if (!isSurper) {
  334 + BillLogEvent sellerBillLogEvent = bleb.tradeStatus(BillTradeStatus.FAIL.getCode())
  335 + .build();
  336 + EventBusPublisher.publishEvent(sellerBillLogEvent);
  337 + }
332 String content = "用户" + sellerUid + "退保证金订单"+ orderCode +"失败"; 338 String content = "用户" + sellerUid + "退保证金订单"+ orderCode +"失败";
333 SmsAlarmEvent smsAlarmEvent = new SmsAlarmEvent("notPaidSellerOrder.selfCancel", "cancelBeforeBuy", content); 339 SmsAlarmEvent smsAlarmEvent = new SmsAlarmEvent("notPaidSellerOrder.selfCancel", "cancelBeforeBuy", content);
334 EventBusPublisher.publishEvent(smsAlarmEvent); 340 EventBusPublisher.publishEvent(smsAlarmEvent);
@@ -393,7 +399,8 @@ public class SellerOrderCancelService { @@ -393,7 +399,8 @@ public class SellerOrderCancelService {
393 399
394 BigDecimal goodsMoney = buyerOrder.getAmount(); 400 BigDecimal goodsMoney = buyerOrder.getAmount();
395 PaymentRequest refundReq = PaymentRequest.builder().uid(buyerUid) 401 PaymentRequest refundReq = PaymentRequest.builder().uid(buyerUid)
396 - .orderCode(buyerOrderCode).refundAmount(goodsMoney.doubleValue()) 402 + .orderCode(buyerOrderCode).refundCase(RefundCase.BUYER_GOODS_MONEY)
  403 + .refundAmount(goodsMoney.doubleValue())
397 .build(); 404 .build();
398 BillLogEvent.BillLogEventBuilder bleb = BillLogEvent.builder() 405 BillLogEvent.BillLogEventBuilder bleb = BillLogEvent.builder()
399 .buyerUid(buyerUid).sellerUid(sellerUid).orderCode(buyerOrderCode) 406 .buyerUid(buyerUid).sellerUid(sellerUid).orderCode(buyerOrderCode)
@@ -552,7 +559,10 @@ public class SellerOrderCancelService { @@ -552,7 +559,10 @@ public class SellerOrderCancelService {
552 .orderCode(orderCode) 559 .orderCode(orderCode)
553 .refundAmount(earnestMoney).build(); 560 .refundAmount(earnestMoney).build();
554 Integer payment = sellerOrder.getPayment(); 561 Integer payment = sellerOrder.getPayment();
555 - if(PaymentHelper.isWallet(payment)){ 562 + boolean sellerIsSurper = sellerService.isSuperEntrySeller(sellerUid);
  563 + refundReq.setSuper(sellerIsSurper);
  564 + //
  565 + if(!sellerIsSurper && PaymentHelper.isWallet(payment)){
556 MerchantOrderAttachInfo moai = MerchantOrderAttachInfo.builder().uid(sellerUid) 566 MerchantOrderAttachInfo moai = MerchantOrderAttachInfo.builder().uid(sellerUid)
557 .orderCode(orderCode).skup(skup).earnestMoney(sellerOrder.getEarnestMoney()) 567 .orderCode(orderCode).skup(skup).earnestMoney(sellerOrder.getEarnestMoney())
558 .type(SellerWalletDetail.Type.SYSTEM_OFF.getValue()).build(); 568 .type(SellerWalletDetail.Type.SYSTEM_OFF.getValue()).build();
@@ -572,9 +582,11 @@ public class SellerOrderCancelService { @@ -572,9 +582,11 @@ public class SellerOrderCancelService {
572 }catch (Exception ex){ 582 }catch (Exception ex){
573 logger.warn("in yoho Off Shelve Cancel, refund earnestMoney fail, seller {}, order code {}, skup {}, earnestMoney {}", 583 logger.warn("in yoho Off Shelve Cancel, refund earnestMoney fail, seller {}, order code {}, skup {}, earnestMoney {}",
574 sellerUid, orderCode, skup, earnestMoney, ex); 584 sellerUid, orderCode, skup, earnestMoney, ex);
575 - BillLogEvent sellerBillLogEvent = bleb.tradeStatus(BillTradeStatus.FAIL.getCode())  
576 - .build();  
577 - EventBusPublisher.publishEvent(sellerBillLogEvent); 585 + if(!sellerIsSurper) {
  586 + BillLogEvent sellerBillLogEvent = bleb.tradeStatus(BillTradeStatus.FAIL.getCode())
  587 + .build();
  588 + EventBusPublisher.publishEvent(sellerBillLogEvent);
  589 + }
578 String content = "下架skup时,退用户" + sellerUid + "保证金订单"+ orderCode +"失败"; 590 String content = "下架skup时,退用户" + sellerUid + "保证金订单"+ orderCode +"失败";
579 SmsAlarmEvent smsAlarmEvent = new SmsAlarmEvent("PaidSellerOrder.PlatformCancel", "cancelBeforeBuy", content); 591 SmsAlarmEvent smsAlarmEvent = new SmsAlarmEvent("PaidSellerOrder.PlatformCancel", "cancelBeforeBuy", content);
580 EventBusPublisher.publishEvent(smsAlarmEvent); 592 EventBusPublisher.publishEvent(smsAlarmEvent);
@@ -248,11 +248,15 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi @@ -248,11 +248,15 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi
248 @Autowired 248 @Autowired
249 private InBoxFacade inBoxFacade; 249 private InBoxFacade inBoxFacade;
250 250
  251 + @Autowired
  252 + private SellerService sellerService;
  253 +
251 public OrderSubmitResp batchPublishPrds(SellerOrderContext ctx, SellerOrderSubmitReq req) throws GatewayException { 254 public OrderSubmitResp batchPublishPrds(SellerOrderContext ctx, SellerOrderSubmitReq req) throws GatewayException {
252 // 一串校验 255 // 一串校验
253 //扣减保证金 256 //扣减保证金
254 final int num = req.getNum(); 257 final int num = req.getNum();
255 int uid = req.getUid(); 258 int uid = req.getUid();
  259 + boolean isSurper = sellerService.isSuperEntrySeller(uid);
256 SellerOrderComputeResult socr = ctx.getSellerOrderComputeResult(); 260 SellerOrderComputeResult socr = ctx.getSellerOrderComputeResult();
257 BigDecimal singleEarestMoney = socr.getEarnestMoney().getEarnestMoney(); 261 BigDecimal singleEarestMoney = socr.getEarnestMoney().getEarnestMoney();
258 BigDecimal mEarestMoney = sellerOrderPrepareProcessor.checkNGetMergeEarnestMoney(uid, singleEarestMoney, num, ctx.getSalePrice()); 262 BigDecimal mEarestMoney = sellerOrderPrepareProcessor.checkNGetMergeEarnestMoney(uid, singleEarestMoney, num, ctx.getSalePrice());
@@ -260,7 +264,7 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi @@ -260,7 +264,7 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi
260 MerchantOrderAttachInfo moai = MerchantOrderAttachInfo.builder().uid(uid) 264 MerchantOrderAttachInfo moai = MerchantOrderAttachInfo.builder().uid(uid)
261 .storageId(ctx.getStorageId()).earnestMoney(mEarestMoney) 265 .storageId(ctx.getStorageId()).earnestMoney(mEarestMoney)
262 .type(swdType.getValue()).build(); 266 .type(swdType.getValue()).build();
263 - SellerWallet sellerWallet = merchantOrderPaymentService.useEarnest(uid, mEarestMoney, moai); 267 + SellerWallet sellerWallet = isSurper ? new SellerWallet() : merchantOrderPaymentService.useEarnest(uid, mEarestMoney, moai);
264 // invoke pay by wallet 268 // invoke pay by wallet
265 boolean paySuccess = Objects.nonNull(sellerWallet); 269 boolean paySuccess = Objects.nonNull(sellerWallet);
266 if (!paySuccess){ 270 if (!paySuccess){
@@ -281,7 +285,7 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi @@ -281,7 +285,7 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi
281 forkNum = num - (i-1) * MAX_DEAL; 285 forkNum = num - (i-1) * MAX_DEAL;
282 } 286 }
283 log.info("batch publish uid {} storageId {} forkNum {} num {}", uid, req.getStorageId(), forkNum, num); 287 log.info("batch publish uid {} storageId {} forkNum {} num {}", uid, req.getStorageId(), forkNum, num);
284 - BatchProcessTask batchProcessTask = new BatchProcessTask(ctx, cdl, forkNum, sellerWallet); 288 + BatchProcessTask batchProcessTask = new BatchProcessTask(ctx, cdl, forkNum, sellerWallet, isSurper);
285 ForkJoinTask<SellerOrderSubmitHandler.ForkJoinResult> fjt = ThreadPoolFactory.getForkJoinPool().submit(batchProcessTask); 289 ForkJoinTask<SellerOrderSubmitHandler.ForkJoinResult> fjt = ThreadPoolFactory.getForkJoinPool().submit(batchProcessTask);
286 taskList.add(fjt); 290 taskList.add(fjt);
287 } 291 }
@@ -334,11 +338,13 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi @@ -334,11 +338,13 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi
334 totalRefundEM = totalRefundEM.add(so.getEarnestMoney()); 338 totalRefundEM = totalRefundEM.add(so.getEarnestMoney());
335 } 339 }
336 SellerWalletDetail.Type swdType = SellerWalletDetail.Type.SELLER_OFF; 340 SellerWalletDetail.Type swdType = SellerWalletDetail.Type.SELLER_OFF;
337 - MerchantOrderAttachInfo moai = MerchantOrderAttachInfo.builder().uid(req.getUid()) 341 + int uid = req.getUid();
  342 + boolean isSurper = sellerService.isSuperEntrySeller(uid);
  343 + MerchantOrderAttachInfo moai = MerchantOrderAttachInfo.builder().uid(uid)
338 .earnestMoney(totalRefundEM).productCount(needCancelSkups.size()) 344 .earnestMoney(totalRefundEM).productCount(needCancelSkups.size())
339 .seriNo(String.valueOf(batchNo)) 345 .seriNo(String.valueOf(batchNo))
340 .type(swdType.getValue()).build(); 346 .type(swdType.getValue()).build();
341 - SellerWallet sellerWallet = merchantOrderPaymentService.refundEarnest(req.getUid(), totalRefundEM, moai, 0L, SellerWalletDetail.Type.SELLER_OFF ); 347 + SellerWallet sellerWallet = isSurper? new SellerWallet() : merchantOrderPaymentService.refundEarnest(req.getUid(), totalRefundEM, moai, 0L, SellerWalletDetail.Type.SELLER_OFF );
342 //2.1 划账成功 348 //2.1 划账成功
343 if (Objects.nonNull(sellerWallet)) { 349 if (Objects.nonNull(sellerWallet)) {
344 // 3 修改 seller_order(状态)sell_order_goods(状态) 350 // 3 修改 seller_order(状态)sell_order_goods(状态)
@@ -355,9 +361,11 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi @@ -355,9 +361,11 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi
355 sellerOrderGoodsMapper.updateByPrimaryKeys(sogc, needCancelSkups); 361 sellerOrderGoodsMapper.updateByPrimaryKeys(sogc, needCancelSkups);
356 362
357 //4 划账记录 363 //4 划账记录
358 - List<OrderInfo> orderList = soList.parallelStream().map(so->OrderInfo.builder()  
359 - .orderCode(so.getOrderCode()).amount(so.getEarnestMoney()).build()).collect(Collectors.toList());;  
360 - merchantOrderPaymentService.unshelveAddWalletDetail(sellerWallet, orderList); 364 + if (!isSurper) {
  365 + List<OrderInfo> orderList = soList.parallelStream().map(so -> OrderInfo.builder()
  366 + .orderCode(so.getOrderCode()).amount(so.getEarnestMoney()).build()).collect(Collectors.toList());
  367 + merchantOrderPaymentService.unshelveAddWalletDetail(sellerWallet, orderList);
  368 + }
361 SkupDto skupDto = tskupMap.values().iterator().next(); 369 SkupDto skupDto = tskupMap.values().iterator().next();
362 SellerOrderGoods sellerOrderGoods = skupDto.getSellerOrderGoods(); 370 SellerOrderGoods sellerOrderGoods = skupDto.getSellerOrderGoods();
363 inBoxFacade.sellerPlaySelf(sellerOrderGoods.getUid(), sellerOrderGoods.getProductName()); 371 inBoxFacade.sellerPlaySelf(sellerOrderGoods.getUid(), sellerOrderGoods.getProductName());
@@ -575,8 +583,8 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi @@ -575,8 +583,8 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi
575 .earnestMoney(totalDiffMoney).productCount(skupMap.size()) 583 .earnestMoney(totalDiffMoney).productCount(skupMap.size())
576 .seriNo(String.valueOf(req.getBatchNo())) 584 .seriNo(String.valueOf(req.getBatchNo()))
577 .type(swdType.getValue()).build(); 585 .type(swdType.getValue()).build();
578 -  
579 - SellerWallet sellerWallet = merchantOrderPaymentService.changePriceUseEarnest(uid, totalDiffMoney, moai); 586 + boolean isSurper = sellerService.isSuperEntrySeller(uid);
  587 + SellerWallet sellerWallet = isSurper ? new SellerWallet() : merchantOrderPaymentService.changePriceUseEarnest(uid, totalDiffMoney, moai);
580 int successCnt = 0; 588 int successCnt = 0;
581 int failCnt = 0; 589 int failCnt = 0;
582 if(Objects.nonNull(sellerWallet)) { 590 if(Objects.nonNull(sellerWallet)) {
@@ -600,10 +608,12 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi @@ -600,10 +608,12 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi
600 608
601 //4 划账记录 609 //4 划账记录
602 List<SellerOrder> psoList = sellerOrderMapper.selectBySkups(skupSet); 610 List<SellerOrder> psoList = sellerOrderMapper.selectBySkups(skupSet);
603 - List<OrderInfo> orderList = psoList.parallelStream().map(  
604 - so-> OrderInfo.builder().orderCode(so.getOrderCode()).amount(diffEarnestMoney).build())  
605 - .collect(Collectors.toList());  
606 - merchantOrderPaymentService.changePriceAddWalletDetail(sellerWallet, orderList ); 611 + if(!isSurper) {
  612 + List<OrderInfo> orderList = psoList.parallelStream().map(
  613 + so -> OrderInfo.builder().orderCode(so.getOrderCode()).amount(diffEarnestMoney).build())
  614 + .collect(Collectors.toList());
  615 + merchantOrderPaymentService.changePriceAddWalletDetail(sellerWallet, orderList);
  616 + }
607 successCnt = skupMap.size(); 617 successCnt = skupMap.size();
608 List<RedisKeyBuilder> skupDetailRKBs = getSkupDetailRKBs(skupMap); 618 List<RedisKeyBuilder> skupDetailRKBs = getSkupDetailRKBs(skupMap);
609 skupDetailRKBs.add(CacheKeyBuilder.orderListKey(req.getUid(), TabType.SELL.getValue())); 619 skupDetailRKBs.add(CacheKeyBuilder.orderListKey(req.getUid(), TabType.SELL.getValue()));
@@ -650,11 +660,15 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi @@ -650,11 +660,15 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi
650 660
651 private SellerWallet sellerWallet; 661 private SellerWallet sellerWallet;
652 662
653 - public BatchProcessTask(SellerOrderContext ctx, CountDownLatch countDownLatch, int num, SellerWallet sellerWallet) { 663 + private boolean isSurper;
  664 +
  665 + public BatchProcessTask(SellerOrderContext ctx, CountDownLatch countDownLatch,
  666 + int num, SellerWallet sellerWallet, boolean isSurper) {
654 this.ctx = ctx; 667 this.ctx = ctx;
655 this.countDownLatch = countDownLatch; 668 this.countDownLatch = countDownLatch;
656 this.num = num; 669 this.num = num;
657 this.sellerWallet = sellerWallet; 670 this.sellerWallet = sellerWallet;
  671 + this.isSurper = isSurper;
658 } 672 }
659 673
660 @Override 674 @Override
@@ -670,7 +684,8 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi @@ -670,7 +684,8 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi
670 cacheCleaner.cleanList(uid, TabType.SELL.getValue()); 684 cacheCleaner.cleanList(uid, TabType.SELL.getValue());
671 // (异步实现)记录保证金流水 685 // (异步实现)记录保证金流水
672 //(异步实现)同步数据到prd,记录支付, 686 //(异步实现)同步数据到prd,记录支付,
673 - BatchPublishTailEvent bpte = BatchPublishTailEvent.builder().fjr(fjr).sellerWallet(sellerWallet).build(); 687 + BatchPublishTailEvent bpte = BatchPublishTailEvent.builder().isSurper(isSurper)
  688 + .fjr(fjr).sellerWallet(sellerWallet).build();
674 EventBusPublisher.publishEvent(bpte); 689 EventBusPublisher.publishEvent(bpte);
675 countDownLatch.countDown(); 690 countDownLatch.countDown();
676 }catch (Exception ex){ 691 }catch (Exception ex){