1
|
package com.yohoufo.order.service;
|
1
|
package com.yohoufo.order.service;
|
2
|
|
2
|
|
|
|
3
|
+import java.math.BigDecimal;
|
|
|
4
|
+import java.text.SimpleDateFormat;
|
|
|
5
|
+import java.util.ArrayList;
|
|
|
6
|
+import java.util.Arrays;
|
|
|
7
|
+import java.util.Date;
|
|
|
8
|
+import java.util.List;
|
|
|
9
|
+
|
|
|
10
|
+import org.slf4j.Logger;
|
|
|
11
|
+import org.slf4j.LoggerFactory;
|
|
|
12
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
13
|
+import org.springframework.stereotype.Service;
|
|
|
14
|
+
|
3
|
import com.alibaba.fastjson.JSONObject;
|
15
|
import com.alibaba.fastjson.JSONObject;
|
4
|
import com.yoho.core.common.utils.DateUtil;
|
16
|
import com.yoho.core.common.utils.DateUtil;
|
5
|
import com.yoho.error.ServiceError;
|
17
|
import com.yoho.error.ServiceError;
|
|
@@ -9,26 +21,26 @@ import com.yohobuy.ufo.model.order.bo.OrderInfo; |
|
@@ -9,26 +21,26 @@ import com.yohobuy.ufo.model.order.bo.OrderInfo; |
9
|
import com.yohobuy.ufo.model.order.common.OrderCodeType;
|
21
|
import com.yohobuy.ufo.model.order.common.OrderCodeType;
|
10
|
import com.yohobuy.ufo.model.order.common.OrderStatus;
|
22
|
import com.yohobuy.ufo.model.order.common.OrderStatus;
|
11
|
import com.yohobuy.ufo.model.order.common.TabType;
|
23
|
import com.yohobuy.ufo.model.order.common.TabType;
|
|
|
24
|
+import com.yohobuy.ufo.model.order.resp.PageResp;
|
12
|
import com.yohoufo.common.alarm.CommonAlarmEventPublisher;
|
25
|
import com.yohoufo.common.alarm.CommonAlarmEventPublisher;
|
13
|
import com.yohoufo.common.caller.UfoServiceCaller;
|
26
|
import com.yohoufo.common.caller.UfoServiceCaller;
|
14
|
import com.yohoufo.common.utils.TimeUtils;
|
27
|
import com.yohoufo.common.utils.TimeUtils;
|
15
|
-import com.yohoufo.dal.order.*;
|
|
|
16
|
-import com.yohoufo.dal.order.model.*;
|
28
|
+import com.yohoufo.dal.order.EntrySellerRechargeOrderMapper;
|
|
|
29
|
+import com.yohoufo.dal.order.OrdersPayMapper;
|
|
|
30
|
+import com.yohoufo.dal.order.OrdersPayRefundMapper;
|
|
|
31
|
+import com.yohoufo.dal.order.SellerWalletDetailMapper;
|
|
|
32
|
+import com.yohoufo.dal.order.SellerWalletMapper;
|
|
|
33
|
+import com.yohoufo.dal.order.model.EntrySellerRechargeOrder;
|
|
|
34
|
+import com.yohoufo.dal.order.model.OrdersPay;
|
|
|
35
|
+import com.yohoufo.dal.order.model.OrdersPayRefund;
|
|
|
36
|
+import com.yohoufo.dal.order.model.SellerWallet;
|
|
|
37
|
+import com.yohoufo.dal.order.model.SellerWalletDetail;
|
17
|
import com.yohoufo.order.common.Payment;
|
38
|
import com.yohoufo.order.common.Payment;
|
18
|
import com.yohoufo.order.model.request.PaymentRequest;
|
39
|
import com.yohoufo.order.model.request.PaymentRequest;
|
19
|
import com.yohoufo.order.model.response.PrepayResponse;
|
40
|
import com.yohoufo.order.model.response.PrepayResponse;
|
20
|
import com.yohoufo.order.service.cache.CacheCleaner;
|
41
|
import com.yohoufo.order.service.cache.CacheCleaner;
|
21
|
import com.yohoufo.order.service.cache.CacheKeyBuilder;
|
42
|
import com.yohoufo.order.service.cache.CacheKeyBuilder;
|
22
|
import com.yohoufo.order.service.impl.PaymentServiceImpl;
|
43
|
import com.yohoufo.order.service.impl.PaymentServiceImpl;
|
23
|
-import org.slf4j.Logger;
|
|
|
24
|
-import org.slf4j.LoggerFactory;
|
|
|
25
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
26
|
-import org.springframework.stereotype.Service;
|
|
|
27
|
-
|
|
|
28
|
-import java.math.BigDecimal;
|
|
|
29
|
-import java.util.Arrays;
|
|
|
30
|
-import java.util.Date;
|
|
|
31
|
-import java.util.List;
|
|
|
32
|
|
44
|
|
33
|
@Service
|
45
|
@Service
|
34
|
public class MerchantOrderPaymentService extends AbstractOrderPaymentService {
|
46
|
public class MerchantOrderPaymentService extends AbstractOrderPaymentService {
|
|
@@ -145,6 +157,9 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService { |
|
@@ -145,6 +157,9 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService { |
145
|
swd.setType(SellerWalletDetail.Type.RE_CHARGE.getValue());
|
157
|
swd.setType(SellerWalletDetail.Type.RE_CHARGE.getValue());
|
146
|
swd.setCreateTime(TimeUtils.getTimeStampSecond());
|
158
|
swd.setCreateTime(TimeUtils.getTimeStampSecond());
|
147
|
swd.setUpdateTime(0);
|
159
|
swd.setUpdateTime(0);
|
|
|
160
|
+ JSONObject att = new JSONObject();
|
|
|
161
|
+ att.put("payment", orderInfo.getPayment());
|
|
|
162
|
+ swd.setAttachValue(att.toJSONString());
|
148
|
logger.info("充值后,处理增加钱包明细,bean={}", swd);
|
163
|
logger.info("充值后,处理增加钱包明细,bean={}", swd);
|
149
|
sellerWalletDetailMapper.insert(swd);
|
164
|
sellerWalletDetailMapper.insert(swd);
|
150
|
logger.info("充值后,处理增加钱包明细成功,orderCode={}", orderInfo.getOrderCode());
|
165
|
logger.info("充值后,处理增加钱包明细成功,orderCode={}", orderInfo.getOrderCode());
|
|
@@ -295,6 +310,56 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService { |
|
@@ -295,6 +310,56 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService { |
295
|
return buildOrderInfo(buyerOrder);
|
310
|
return buildOrderInfo(buyerOrder);
|
296
|
}
|
311
|
}
|
297
|
|
312
|
|
|
|
313
|
+ public com.yohoufo.common.ApiResponse getMerchantWalletInfo(Integer uid) {
|
|
|
314
|
+ SellerWallet sw = sellerWalletMapper.selectByUidAndType(uid, 1);
|
|
|
315
|
+ if (sw == null) {
|
|
|
316
|
+ return new com.yohoufo.common.ApiResponse(400, "钱包不存在", null);
|
|
|
317
|
+ }
|
|
|
318
|
+ if (sw.getStatus() == null || sw.getStatus() == 0) {
|
|
|
319
|
+ return new com.yohoufo.common.ApiResponse(400, "钱包不可用", null);
|
|
|
320
|
+ }
|
|
|
321
|
+ JSONObject result = new JSONObject();
|
|
|
322
|
+ result.put("all", sw.getAmount().add(sw.getLockAmount()));
|
|
|
323
|
+ result.put("used", sw.getLockAmount());
|
|
|
324
|
+ result.put("avail", sw.getAmount());
|
|
|
325
|
+ return new com.yohoufo.common.ApiResponse(200, "查询成功", result);
|
|
|
326
|
+ }
|
|
|
327
|
+
|
|
|
328
|
+ public com.yohoufo.common.ApiResponse getMerchantWalletDetailInfo(Integer uid, int page, int limit) {
|
|
|
329
|
+ SellerWallet sw = sellerWalletMapper.selectByUidAndType(uid, 1);
|
|
|
330
|
+ if (sw == null) {
|
|
|
331
|
+ return new com.yohoufo.common.ApiResponse(400, "钱包不存在", null);
|
|
|
332
|
+ }
|
|
|
333
|
+ if (sw.getStatus() == null || sw.getStatus() == 0) {
|
|
|
334
|
+ return new com.yohoufo.common.ApiResponse(400, "钱包不可用", null);
|
|
|
335
|
+ }
|
|
|
336
|
+ int count = sellerWalletDetailMapper.selectUserDetailCount(uid);
|
|
|
337
|
+ PageResp<JSONObject> pageResp = new PageResp<>();
|
|
|
338
|
+ pageResp.setPage(page);
|
|
|
339
|
+ pageResp.setPageSize(limit);
|
|
|
340
|
+ pageResp.setTotal(count);
|
|
|
341
|
+ pageResp.setPagetotal((int) Math.ceil(count * 1.0 / limit));
|
|
|
342
|
+ if (count == 0) {
|
|
|
343
|
+ pageResp.setData(new ArrayList<>());
|
|
|
344
|
+ return new com.yohoufo.common.ApiResponse(200, "查询成功", pageResp);
|
|
|
345
|
+ } else {
|
|
|
346
|
+ List<SellerWalletDetail> resultList = sellerWalletDetailMapper.selectUserDetailCount(uid,
|
|
|
347
|
+ (page - 1) * limit, count);
|
|
|
348
|
+ List<JSONObject> array = new ArrayList<>();
|
|
|
349
|
+ pageResp.setData(array);
|
|
|
350
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日 HH:mm");
|
|
|
351
|
+ for (SellerWalletDetail detail : resultList) {
|
|
|
352
|
+ JSONObject result = new JSONObject();
|
|
|
353
|
+ result.put("amount", detail.getAmount());
|
|
|
354
|
+ result.put("type", sw.getType());
|
|
|
355
|
+ result.put("info", SellerWalletDetail.Type.of(sw.getType()).getName());
|
|
|
356
|
+ result.put("time", sdf.format(new Date(1000L * detail.getCreateTime())));
|
|
|
357
|
+ array.add(result);
|
|
|
358
|
+ }
|
|
|
359
|
+ return new com.yohoufo.common.ApiResponse(200, "查询成功", pageResp);
|
|
|
360
|
+ }
|
|
|
361
|
+ }
|
|
|
362
|
+
|
298
|
// 支付保证金:总账修改
|
363
|
// 支付保证金:总账修改
|
299
|
public SellerWallet useEarnest(Integer uid, BigDecimal money, String attach) {
|
364
|
public SellerWallet useEarnest(Integer uid, BigDecimal money, String attach) {
|
300
|
return changeEarnest(uid, money, 0L, attach, SellerWalletDetail.Type.PUBLISH);
|
365
|
return changeEarnest(uid, money, 0L, attach, SellerWalletDetail.Type.PUBLISH);
|