|
@@ -13,11 +13,14 @@ import com.alibaba.fastjson.JSONObject; |
|
@@ -13,11 +13,14 @@ import com.alibaba.fastjson.JSONObject; |
13
|
import com.yoho.core.common.utils.DateUtil;
|
13
|
import com.yoho.core.common.utils.DateUtil;
|
14
|
import com.yoho.error.ServiceError;
|
14
|
import com.yoho.error.ServiceError;
|
15
|
import com.yoho.error.exception.ServiceException;
|
15
|
import com.yoho.error.exception.ServiceException;
|
|
|
16
|
+import com.yoho.tools.common.beans.ApiResponse;
|
16
|
import com.yohobuy.ufo.model.order.bo.OrderInfo;
|
17
|
import com.yohobuy.ufo.model.order.bo.OrderInfo;
|
17
|
import com.yohobuy.ufo.model.order.common.OrderCodeType;
|
18
|
import com.yohobuy.ufo.model.order.common.OrderCodeType;
|
18
|
import com.yohobuy.ufo.model.order.common.OrderStatus;
|
19
|
import com.yohobuy.ufo.model.order.common.OrderStatus;
|
19
|
import com.yohobuy.ufo.model.order.common.TabType;
|
20
|
import com.yohobuy.ufo.model.order.common.TabType;
|
|
|
21
|
+import com.yohobuy.ufo.model.user.resp.AuthorizeResultRespVO;
|
20
|
import com.yohoufo.common.alarm.CommonAlarmEventPublisher;
|
22
|
import com.yohoufo.common.alarm.CommonAlarmEventPublisher;
|
|
|
23
|
+import com.yohoufo.common.caller.UfoServiceCaller;
|
21
|
import com.yohoufo.common.utils.TimeUtils;
|
24
|
import com.yohoufo.common.utils.TimeUtils;
|
22
|
import com.yohoufo.dal.order.EntrySellerRechargeOrderMapper;
|
25
|
import com.yohoufo.dal.order.EntrySellerRechargeOrderMapper;
|
23
|
import com.yohoufo.dal.order.OrdersPayMapper;
|
26
|
import com.yohoufo.dal.order.OrdersPayMapper;
|
|
@@ -53,6 +56,9 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService { |
|
@@ -53,6 +56,9 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService { |
53
|
|
56
|
|
54
|
@Autowired
|
57
|
@Autowired
|
55
|
private CacheCleaner cacheCleaner;
|
58
|
private CacheCleaner cacheCleaner;
|
|
|
59
|
+
|
|
|
60
|
+ @Autowired
|
|
|
61
|
+ UfoServiceCaller ufoServiceCaller;
|
56
|
|
62
|
|
57
|
/**
|
63
|
/**
|
58
|
* 更新订单状态
|
64
|
* 更新订单状态
|
|
@@ -70,12 +76,22 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService { |
|
@@ -70,12 +76,22 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService { |
70
|
|
76
|
|
71
|
@Override
|
77
|
@Override
|
72
|
public void processAfterPay(OrderInfo orderInfo) {
|
78
|
public void processAfterPay(OrderInfo orderInfo) {
|
|
|
79
|
+ logger.info("充值后回调,处理processAfterPay,orderInfo={}", orderInfo);
|
73
|
// 首次充值,调用认证成功接口
|
80
|
// 首次充值,调用认证成功接口
|
74
|
if (orderInfo.getType() == TYPE_FIRST_RECHARGE) {
|
81
|
if (orderInfo.getType() == TYPE_FIRST_RECHARGE) {
|
75
|
- // TODO
|
82
|
+ try {
|
|
|
83
|
+ logger.info("首次充值后回调,调用商家入驻接口,uid={}", orderInfo.getUid());
|
|
|
84
|
+ ufoServiceCaller.call("ufo.user.addUserAsStoredSeller", ApiResponse.class, orderInfo.getUid());
|
|
|
85
|
+ } catch (Exception e) {
|
|
|
86
|
+ logger.error("首次充值后回调,商家入驻接口失败,uid={}", orderInfo.getUid());
|
|
|
87
|
+ CommonAlarmEventPublisher.publish("商家入驻失败", "ufo.user.addUserAsStoredSeller", "首次充值后回调,商家入驻接口失败:uid=" + orderInfo.getUid() + ",充值订单号为:" + orderInfo.getOrderCode());
|
|
|
88
|
+ return;
|
|
|
89
|
+ }
|
76
|
}
|
90
|
}
|
|
|
91
|
+
|
77
|
BigDecimal amount = orderInfo.getAmount();
|
92
|
BigDecimal amount = orderInfo.getAmount();
|
78
|
SellerWallet sw = sellerWalletMapper.selectByUidAndType(orderInfo.getUid(), 1);
|
93
|
SellerWallet sw = sellerWalletMapper.selectByUidAndType(orderInfo.getUid(), 1);
|
|
|
94
|
+ logger.info("充值后回调,处理总账表,orderCode={}", orderInfo.getOrderCode());
|
79
|
if (orderInfo.getType() == TYPE_FIRST_RECHARGE) {
|
95
|
if (orderInfo.getType() == TYPE_FIRST_RECHARGE) {
|
80
|
if (sw != null) {
|
96
|
if (sw != null) {
|
81
|
logger.error("首次充值保证金余额{},发现钱包已存在,uid={}", amount, orderInfo.getUid());
|
97
|
logger.error("首次充值保证金余额{},发现钱包已存在,uid={}", amount, orderInfo.getUid());
|
|
@@ -90,7 +106,9 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService { |
|
@@ -90,7 +106,9 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService { |
90
|
sw.setType(1);
|
106
|
sw.setType(1);
|
91
|
sw.setCreateTime(TimeUtils.getTimeStampSecond());
|
107
|
sw.setCreateTime(TimeUtils.getTimeStampSecond());
|
92
|
sw.setUpdateTime(0);
|
108
|
sw.setUpdateTime(0);
|
|
|
109
|
+ logger.info("首次充值后回调,处理总账表新增账号,bean={}", sw);
|
93
|
sellerWalletMapper.insert(sw);
|
110
|
sellerWalletMapper.insert(sw);
|
|
|
111
|
+ logger.info("首次充值后回调,处理总账表新增账号成功,bean={}", sw);
|
94
|
} else {
|
112
|
} else {
|
95
|
// 修改钱包余额
|
113
|
// 修改钱包余额
|
96
|
if (sw == null) {
|
114
|
if (sw == null) {
|
|
@@ -106,12 +124,14 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService { |
|
@@ -106,12 +124,14 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService { |
106
|
|
124
|
|
107
|
sw.setAmount(orderInfo.getAmount());
|
125
|
sw.setAmount(orderInfo.getAmount());
|
108
|
sw.setUpdateTime(TimeUtils.getTimeStampSecond());
|
126
|
sw.setUpdateTime(TimeUtils.getTimeStampSecond());
|
|
|
127
|
+ logger.info("后期充值,处理总账表增加余额,bean={}", sw);
|
109
|
if (sellerWalletMapper.addMoney(sw) == 0) {
|
128
|
if (sellerWalletMapper.addMoney(sw) == 0) {
|
110
|
logger.error("充值保证金余额{},更新表返回0,uid={}", amount, orderInfo.getUid());
|
129
|
logger.error("充值保证金余额{},更新表返回0,uid={}", amount, orderInfo.getUid());
|
111
|
CommonAlarmEventPublisher.publish("充值保证金余额失败", "ufo.order.recharge", "更新表返回0,uid=" + orderInfo.getUid() + ",充值订单号为:" + orderInfo.getOrderCode()+", 充值金额为:"+amount);
|
130
|
CommonAlarmEventPublisher.publish("充值保证金余额失败", "ufo.order.recharge", "更新表返回0,uid=" + orderInfo.getUid() + ",充值订单号为:" + orderInfo.getOrderCode()+", 充值金额为:"+amount);
|
112
|
return;
|
131
|
return;
|
113
|
}
|
132
|
}
|
114
|
}
|
133
|
}
|
|
|
134
|
+ logger.info("{}修改钱包表余额成功,orderCode={}", orderInfo.getOrderCode());
|
115
|
|
135
|
|
116
|
// 增加充值记录
|
136
|
// 增加充值记录
|
117
|
SellerWalletDetail swd = new SellerWalletDetail();
|
137
|
SellerWalletDetail swd = new SellerWalletDetail();
|
|
@@ -121,11 +141,14 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService { |
|
@@ -121,11 +141,14 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService { |
121
|
swd.setWalletId(sw.getId());
|
141
|
swd.setWalletId(sw.getId());
|
122
|
swd.setAmount(orderInfo.getAmount());
|
142
|
swd.setAmount(orderInfo.getAmount());
|
123
|
swd.setCreateTime(TimeUtils.getTimeStampSecond());
|
143
|
swd.setCreateTime(TimeUtils.getTimeStampSecond());
|
|
|
144
|
+ logger.info("充值后,处理增加钱包明细,bean={}", swd);
|
124
|
sellerWalletDetailMapper.insert(swd);
|
145
|
sellerWalletDetailMapper.insert(swd);
|
|
|
146
|
+ logger.info("充值后,处理增加钱包明细成功,orderCode={}", orderInfo.getOrderCode());
|
125
|
|
147
|
|
|
|
148
|
+ logger.info("充值后,删除订单列表缓存,uid={}", orderInfo.getUid());
|
126
|
cacheCleaner.delete(Arrays.asList(
|
149
|
cacheCleaner.delete(Arrays.asList(
|
127
|
- CacheKeyBuilder.orderListKey(orderInfo.getUid(), TabType.BUY.getValue()),
|
|
|
128
|
- CacheKeyBuilder.orderDetailKey(orderInfo.getUid(), TabType.BUY.getValue(), orderInfo.getOrderCode())));
|
150
|
+ CacheKeyBuilder.orderListKey(orderInfo.getUid(), TabType.SELL.getValue()),
|
|
|
151
|
+ CacheKeyBuilder.orderDetailKey(orderInfo.getUid(), TabType.SELL.getValue(), orderInfo.getOrderCode())));
|
129
|
}
|
152
|
}
|
130
|
|
153
|
|
131
|
|
154
|
|
|
@@ -295,7 +318,9 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService { |
|
@@ -295,7 +318,9 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService { |
295
|
swd.setWalletId(sw.getId());
|
318
|
swd.setWalletId(sw.getId());
|
296
|
swd.setAmount(amount);
|
319
|
swd.setAmount(amount);
|
297
|
swd.setCreateTime(TimeUtils.getTimeStampSecond());
|
320
|
swd.setCreateTime(TimeUtils.getTimeStampSecond());
|
|
|
321
|
+ logger.info("支付保证金,钱包明细记录,bean={}", swd);
|
298
|
sellerWalletDetailMapper.insert(swd);
|
322
|
sellerWalletDetailMapper.insert(swd);
|
|
|
323
|
+ logger.info("支付保证金,钱包明细记录成功,bean={}", swd);
|
299
|
}
|
324
|
}
|
300
|
|
325
|
|
301
|
// 退还保证金
|
326
|
// 退还保证金
|
|
@@ -307,11 +332,15 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService { |
|
@@ -307,11 +332,15 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService { |
307
|
swd.setWalletId(sw.getId());
|
332
|
swd.setWalletId(sw.getId());
|
308
|
swd.setAmount(amount);
|
333
|
swd.setAmount(amount);
|
309
|
swd.setCreateTime(TimeUtils.getTimeStampSecond());
|
334
|
swd.setCreateTime(TimeUtils.getTimeStampSecond());
|
|
|
335
|
+ logger.info("退还保证金,钱包明细记录,bean={}", swd);
|
310
|
sellerWalletDetailMapper.insert(swd);
|
336
|
sellerWalletDetailMapper.insert(swd);
|
|
|
337
|
+ logger.info("退还保证金,钱包明细记录成功,bean={}", swd);
|
311
|
}
|
338
|
}
|
312
|
|
339
|
|
313
|
// 退出入驻:归还所有保证金 总账+明细
|
340
|
// 退出入驻:归还所有保证金 总账+明细
|
314
|
public BigDecimal returnEarnest(Integer uid, long orderCode) {
|
341
|
public BigDecimal returnEarnest(Integer uid, long orderCode) {
|
|
|
342
|
+ logger.info("商家退出,退还保证金,钱包归零处理开始,uid={},orderCode={}", uid, orderCode);
|
|
|
343
|
+
|
315
|
SellerWallet sw = sellerWalletMapper.selectByUidAndType(uid, 1);
|
344
|
SellerWallet sw = sellerWalletMapper.selectByUidAndType(uid, 1);
|
316
|
|
345
|
|
317
|
if (sw == null) {
|
346
|
if (sw == null) {
|
|
@@ -320,6 +349,7 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService { |
|
@@ -320,6 +349,7 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService { |
320
|
return null;
|
349
|
return null;
|
321
|
}
|
350
|
}
|
322
|
BigDecimal amount = sw.getAmount();
|
351
|
BigDecimal amount = sw.getAmount();
|
|
|
352
|
+ logger.info("商家退出,退还保证金,钱包归零处理,钱包信息={}", sw);
|
323
|
|
353
|
|
324
|
if (sw.getStatus() == null || sw.getStatus() == 0) {
|
354
|
if (sw.getStatus() == null || sw.getStatus() == 0) {
|
325
|
logger.error("退还所有保证金{},钱包不可用,uid={}", amount, uid);
|
355
|
logger.error("退还所有保证金{},钱包不可用,uid={}", amount, uid);
|
|
@@ -327,14 +357,13 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService { |
|
@@ -327,14 +357,13 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService { |
327
|
return null;
|
357
|
return null;
|
328
|
}
|
358
|
}
|
329
|
|
359
|
|
330
|
- sw.setAmount(amount);
|
|
|
331
|
sw.setUpdateTime(TimeUtils.getTimeStampSecond());
|
360
|
sw.setUpdateTime(TimeUtils.getTimeStampSecond());
|
332
|
if (sellerWalletMapper.returnMoney(sw) == 0) {
|
361
|
if (sellerWalletMapper.returnMoney(sw) == 0) {
|
333
|
logger.error("退还所有证金失败,更新表返回0,uid={}", uid);
|
362
|
logger.error("退还所有证金失败,更新表返回0,uid={}", uid);
|
334
|
CommonAlarmEventPublisher.publish("退还所有保证金失败", "ufo.order.recharge", "更新表返回0,uid=" + uid + ", 退还金额为:"+ amount);
|
363
|
CommonAlarmEventPublisher.publish("退还所有保证金失败", "ufo.order.recharge", "更新表返回0,uid=" + uid + ", 退还金额为:"+ amount);
|
335
|
return null;
|
364
|
return null;
|
336
|
}
|
365
|
}
|
337
|
-
|
366
|
+ logger.info("商家退出,退还保证金,钱包归零处理,余额扣除成功,钱包信息={}", sw);
|
338
|
// 增加充值记录
|
367
|
// 增加充值记录
|
339
|
SellerWalletDetail swd = new SellerWalletDetail();
|
368
|
SellerWalletDetail swd = new SellerWalletDetail();
|
340
|
swd.setOrderCode(orderCode);
|
369
|
swd.setOrderCode(orderCode);
|
|
@@ -343,12 +372,14 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService { |
|
@@ -343,12 +372,14 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService { |
343
|
swd.setWalletId(sw.getId());
|
372
|
swd.setWalletId(sw.getId());
|
344
|
swd.setAmount(amount);
|
373
|
swd.setAmount(amount);
|
345
|
swd.setCreateTime(TimeUtils.getTimeStampSecond());
|
374
|
swd.setCreateTime(TimeUtils.getTimeStampSecond());
|
|
|
375
|
+ logger.info("商家退出,退还保证金,钱包归零处理,增加扣减明细,bean={}", swd);
|
346
|
sellerWalletDetailMapper.insert(swd);
|
376
|
sellerWalletDetailMapper.insert(swd);
|
347
|
|
377
|
|
348
|
return amount;
|
378
|
return amount;
|
349
|
}
|
379
|
}
|
350
|
|
380
|
|
351
|
private SellerWallet changeEarnest(Integer uid, BigDecimal money, String message) {
|
381
|
private SellerWallet changeEarnest(Integer uid, BigDecimal money, String message) {
|
|
|
382
|
+ logger.info("{}修改钱包表入口,uid={},money={}", message, uid, money);
|
352
|
// 使用钱包余额,支付保证金
|
383
|
// 使用钱包余额,支付保证金
|
353
|
SellerWallet sw = sellerWalletMapper.selectByUidAndType(uid, 1);
|
384
|
SellerWallet sw = sellerWalletMapper.selectByUidAndType(uid, 1);
|
354
|
|
385
|
|
|
@@ -370,11 +401,13 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService { |
|
@@ -370,11 +401,13 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService { |
370
|
|
401
|
|
371
|
sw.setAmount(money.multiply(new BigDecimal("-1")));
|
402
|
sw.setAmount(money.multiply(new BigDecimal("-1")));
|
372
|
sw.setUpdateTime(TimeUtils.getTimeStampSecond());
|
403
|
sw.setUpdateTime(TimeUtils.getTimeStampSecond());
|
|
|
404
|
+ logger.info("{}修改钱包表余额,bean={}", sw);
|
373
|
if (sellerWalletMapper.addMoney(sw) == 0) {
|
405
|
if (sellerWalletMapper.addMoney(sw) == 0) {
|
374
|
logger.error(message + "失败,(并发)更新表返回0,uid={}", uid);
|
406
|
logger.error(message + "失败,(并发)更新表返回0,uid={}", uid);
|
375
|
CommonAlarmEventPublisher.publish(message + "失败", "ufo.order.recharge", "(并发)更新表返回0,uid=" + uid + ", 金额为:"+ money);
|
407
|
CommonAlarmEventPublisher.publish(message + "失败", "ufo.order.recharge", "(并发)更新表返回0,uid=" + uid + ", 金额为:"+ money);
|
376
|
return null;
|
408
|
return null;
|
377
|
}
|
409
|
}
|
|
|
410
|
+ logger.info("{}修改钱包表余额成功,bean={}", sw);
|
378
|
return sw;
|
411
|
return sw;
|
379
|
}
|
412
|
}
|
380
|
|
413
|
|
|
@@ -392,20 +425,26 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService { |
|
@@ -392,20 +425,26 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService { |
392
|
JSONObject attach = new JSONObject();
|
425
|
JSONObject attach = new JSONObject();
|
393
|
attach.put("order_type", OrderCodeType.SELLER_TYPE.getType());
|
426
|
attach.put("order_type", OrderCodeType.SELLER_TYPE.getType());
|
394
|
ordersPay.setAttach(attach.toJSONString());
|
427
|
ordersPay.setAttach(attach.toJSONString());
|
|
|
428
|
+ logger.info("增加支付记录orders_pay,bean={}", ordersPay);
|
395
|
ordersPayDao.insertSelective(ordersPay);
|
429
|
ordersPayDao.insertSelective(ordersPay);
|
|
|
430
|
+ logger.info("增加支付记录orders_pay成功,orderCode={}", swd.getOrderCode());
|
396
|
}
|
431
|
}
|
397
|
|
432
|
|
398
|
- public void changePriceUpdateOrdersPay(SellerWalletDetail swd) {
|
433
|
+ public int changePriceUpdateOrdersPay(SellerWalletDetail swd) {
|
399
|
// 增加支付记录
|
434
|
// 增加支付记录
|
400
|
OrdersPay ordersPay = new OrdersPay();
|
435
|
OrdersPay ordersPay = new OrdersPay();
|
401
|
ordersPay.setOrderCode(swd.getOrderCode());
|
436
|
ordersPay.setOrderCode(swd.getOrderCode());
|
402
|
ordersPay.setUid(swd.getUid());
|
437
|
ordersPay.setUid(swd.getUid());
|
403
|
ordersPay.setAmount(swd.getAmount());
|
438
|
ordersPay.setAmount(swd.getAmount());
|
404
|
String message = "修改保证金order_pay记录金额";
|
439
|
String message = "修改保证金order_pay记录金额";
|
405
|
- if (ordersPayDao.addMoney(ordersPay) == 0) {
|
440
|
+ logger.info("商家修改价格,修改支付记录金额orders_pay,bean={}", ordersPay);
|
|
|
441
|
+ int result;
|
|
|
442
|
+ if ((result = ordersPayDao.addMoney(ordersPay)) == 0) {
|
406
|
logger.error(message + "{}失败,修改DB返回记录数为0,orderCode={}", swd.getAmount(), swd.getOrderCode());
|
443
|
logger.error(message + "{}失败,修改DB返回记录数为0,orderCode={}", swd.getAmount(), swd.getOrderCode());
|
407
|
CommonAlarmEventPublisher.publish(message + "失败", "ufo.order.changePriceOrdersPay", "修改DB返回记录数为0,orderCode=" + swd.getOrderCode()+", 金额为:"+swd.getAmount());
|
444
|
CommonAlarmEventPublisher.publish(message + "失败", "ufo.order.changePriceOrdersPay", "修改DB返回记录数为0,orderCode=" + swd.getOrderCode()+", 金额为:"+swd.getAmount());
|
408
|
}
|
445
|
}
|
|
|
446
|
+ logger.info("商家修改价格,修改支付记录金额orders_pay成功,orderCode={}", swd.getOrderCode());
|
|
|
447
|
+ return result;
|
409
|
}
|
448
|
}
|
410
|
|
449
|
|
411
|
} |
450
|
} |