Browse Source

rebase on dev

xiongzhu 4 years ago
parent
commit
4acc2cbdaa

+ 2 - 0
src/main/java/com/izouma/nineth/config/Constants.java

@@ -37,5 +37,7 @@ public interface Constants {
         String GIFT     = "gift";
         String MINT     = "mintOrder";
         String RECHARGE = "recharge";
+
+        String AUCTION = "auctionOrder";
     }
 }

+ 0 - 2
src/main/java/com/izouma/nineth/repo/CollectionRepo.java

@@ -167,7 +167,5 @@ public interface CollectionRepo extends JpaRepository<Collection, Long>, JpaSpec
             "and c.stock > 0 ", nativeQuery = true)
     String lowestPrice(String search);
 
-    List<Collection> findAllByOasisIdInAndStockGreaterThan(List<Long> oasisIds, int stock);
-
     Collection findFirstByOnShelfAndAssetId(boolean onShelf, Long assetId);
 }

+ 6 - 6
src/main/java/com/izouma/nineth/service/AssetService.java

@@ -376,13 +376,13 @@ public class AssetService {
         asset.setConsignment(false);
         asset.setPublicCollectionId(null);
         switch (reason) {
-            case TransferReason.GIFT:
+            case GIFT:
                 asset.setStatus(AssetStatus.GIFTED);
                 break;
-            case "拍卖":
+            case AUCTION:
                 asset.setStatus(AssetStatus.AUCTIONED);
                 break;
-            case TransferReason.TRANSFER:
+            case TRANSFER:
                 asset.setStatus(AssetStatus.TRANSFERRED);
         }
         asset.setOwner(toUser.getNickname());
@@ -612,7 +612,7 @@ public class AssetService {
         assetRepo.save(asset);
     }
 
-//    @Cacheable(cacheNames = "fmaa", key = "#userId+'#'+#mintActivityId+'#'+#pageable.hashCode()")
+    //    @Cacheable(cacheNames = "fmaa", key = "#userId+'#'+#mintActivityId+'#'+#pageable.hashCode()")
     public PageWrapper<Asset> findMintActivityAssetsWrap(Long userId, Long mintActivityId, Pageable pageable) {
         return PageWrapper.of(findMintActivityAssets(userId, mintActivityId, pageable));
     }
@@ -626,8 +626,8 @@ public class AssetService {
             if (tags.isEmpty()) return new PageImpl<>(Collections.emptyList());
             return assetRepo.findAll((Specification<Asset>) (root, query, criteriaBuilder) ->
                     query.distinct(true).where(criteriaBuilder.equal(root.get("userId"), userId),
-                            criteriaBuilder.equal(root.get("status"), AssetStatus.NORMAL),
-                            root.join("tags").get("id").in(tags.stream().map(Tag::getId).toArray()))
+                                    criteriaBuilder.equal(root.get("status"), AssetStatus.NORMAL),
+                                    root.join("tags").get("id").in(tags.stream().map(Tag::getId).toArray()))
                             .getRestriction(), pageable);
         } else {
             return assetRepo.findByUserIdAndStatusAndNameLike(userId, AssetStatus.NORMAL,

+ 4 - 3
src/main/java/com/izouma/nineth/service/AuctionOrderService.java

@@ -1,5 +1,6 @@
 package com.izouma.nineth.service;
 
+import com.izouma.nineth.config.Constants;
 import com.izouma.nineth.config.RedisKeys;
 import com.izouma.nineth.domain.*;
 import com.izouma.nineth.dto.PageQuery;
@@ -359,15 +360,15 @@ public class AuctionOrderService {
         try {
             switch (payMethod) {
                 case HMPAY:
-                    orderPayService.refund(order.getId().toString(), order.getTotalPrice(), "hmPay");
+                    orderPayService.refund(order.getId().toString(), order.getTransactionId(), order.getTotalPrice(), Constants.PayChannel.HM);
                     log.info("退款成功{}", order.getId());
                     break;
                 case SANDPAY:
-                    orderPayService.refund(order.getId().toString(), order.getTotalPrice(), "sandPay");
+                    orderPayService.refund(order.getId().toString(), order.getTransactionId(), order.getTotalPrice(), Constants.PayChannel.SAND);
                     log.info("退款成功{}", order.getId());
                     break;
                 case PAYEASE:
-                    orderPayService.refund(order.getId().toString(), order.getTotalPrice(), "payEase");
+                    orderPayService.refund(order.getId().toString(), order.getTransactionId(), order.getTotalPrice(), Constants.PayChannel.PE);
                     log.info("退款成功{}", order.getId());
                     break;
             }

+ 36 - 58
src/main/java/com/izouma/nineth/service/OrderPayService.java

@@ -38,25 +38,25 @@ import java.util.stream.Stream;
 public class OrderPayService {
     private static String PAY_CHANNEL = Constants.PayChannel.SAND;
 
-    private final OrderService       orderService;
-    private final OrderRepo          orderRepo;
-    private final MintOrderRepo      mintOrderRepo;
-    private final GiftOrderRepo      giftOrderRepo;
-    private final SandPayService     sandPayService;
-    private final HMPayService       hmPayService;
-    private final GeneralProperties  generalProperties;
-    private final UserBalanceService userBalanceService;
-    private final RocketMQTemplate   rocketMQTemplate;
-    private final GiftOrderService   giftOrderService;
-    private final MintOrderService   mintOrderService;
-    private final UserRepo           userRepo;
-    private final SnowflakeIdWorker  snowflakeIdWorker;
-    private final RechargeOrderRepo  rechargeOrderRepo;
-    private final SysConfigService   sysConfigService;
-    private final PasswordEncoder    passwordEncoder;
-    private final PayEaseService     payEaseService;
-    private final UserBankCardRepo   userBankCardRepo;
-    private final AuctionOrderRepo   auctionOrderRepo;
+    private final OrderService        orderService;
+    private final OrderRepo           orderRepo;
+    private final MintOrderRepo       mintOrderRepo;
+    private final GiftOrderRepo       giftOrderRepo;
+    private final SandPayService      sandPayService;
+    private final HMPayService        hmPayService;
+    private final GeneralProperties   generalProperties;
+    private final UserBalanceService  userBalanceService;
+    private final RocketMQTemplate    rocketMQTemplate;
+    private final GiftOrderService    giftOrderService;
+    private final MintOrderService    mintOrderService;
+    private final UserRepo            userRepo;
+    private final SnowflakeIdWorker   snowflakeIdWorker;
+    private final RechargeOrderRepo   rechargeOrderRepo;
+    private final SysConfigService    sysConfigService;
+    private final PasswordEncoder     passwordEncoder;
+    private final PayEaseService      payEaseService;
+    private final UserBankCardRepo    userBankCardRepo;
+    private final AuctionOrderRepo    auctionOrderRepo;
     private final AuctionOrderService auctionOrderService;
 
     public static void setPayChannel(String payChannel) {
@@ -368,20 +368,28 @@ public class OrderPayService {
             throw new BusinessException("订单状态错误");
         }
         switch (PAY_CHANNEL) {
-            case "sandPay":
-                return sandPayService.requestAlipay(orderId + "", order.getTotalPrice(),
-                        "拍卖:" + order.getName(), "拍卖:" + order.getName(),
-                        SandPayService.getTimeout(order.getCreatedAt(), 180),
-                        "{\"type\":\"auctionOrder\",\"id\":\"" + orderId + "\"}");
-            case "hmPay":
+            case Constants.PayChannel.SAND:
+                return sandPayService.pay(orderId + "", "拍卖:" + order.getName(), order.getTotalPrice(),
+                        order.getCreatedAt().plusMinutes(3), "auctionOrder");
+            case Constants.PayChannel.HM:
                 return hmPayService.requestAlipay(orderId + "", order.getTotalPrice(),
-                        "拍卖:" + order.getName(),
-                        HMPayService.getTimeout(order.getCreatedAt(), 180),
-                        "auctionOrder", generalProperties.getHost() + "/9th/home");
+                        "拍卖:" + order.getName(), HMPayService.getTimeout(order.getCreatedAt(), 180),
+                        Constants.OrderNotifyType.AUCTION, generalProperties.getHost() + "/9th/home");
         }
         throw new BusinessException("绿洲宇宙冷却系统已启动,请稍后支付");
     }
 
+    @Cacheable(value = "payOrder", key = "'auctionOrder#'+#orderId")
+    public String payAuctionQuick(Long orderId) {
+        AuctionOrder order = auctionOrderRepo.findById(orderId).orElseThrow(new BusinessException("订单不存在"));
+        if (order.getStatus() != AuctionOrderStatus.NOT_PAID) {
+            throw new BusinessException("订单状态错误");
+        }
+        return sandPayService.payQuick(orderId + "", "拍卖:" + order.getName(),
+                order.getTotalPrice(), order.getCreatedAt().plusMinutes(3), Constants.OrderNotifyType.AUCTION,
+                generalProperties.getHost() + "/9th/home");
+    }
+
     public void payAuctionOrderBalance(Long orderId, Long userId, String tradeCode) {
         AuctionOrder order = auctionOrderRepo.findById(orderId).orElseThrow(new BusinessException("订单不存在"));
         if (order.getStatus() != AuctionOrderStatus.NOT_PAID) {
@@ -413,34 +421,4 @@ public class OrderPayService {
         return payEaseService.pay("拍卖:" + order.getAuctionId(), orderId.toString(), order.getTotalPrice(),
                 order.getUserId().toString(), bindCardId, "auctionOrder");
     }
-
-    public JSONObject refund(String orderId, BigDecimal amount, String channel) {
-        switch (channel) {
-            case "sandPay": {
-                JSONObject res = sandPayService.refund(orderId, amount);
-                if (!"000000".equals(res.getJSONObject("head").getString("respCode"))) {
-                    throw new BusinessException("退款失败");
-                }
-                break;
-            }
-            case "hmPay": {
-                JSONObject res = hmPayService.refund(orderId, amount);
-                if (!"REFUND_SUCCESS".equals(res.getString("sub_code"))) {
-                    throw new BusinessException("退款失败");
-                }
-                break;
-            }
-            case "payEase": {
-                JSONObject res = payEaseService.refund(orderId, amount);
-                String status = res.getString("status");
-                if (!"SUCCESS".equals(status)) {
-                    String error = res.getString("error");
-                    throw new BusinessException("退款失败:" + error);
-                }
-                break;
-            }
-        }
-        throw new BusinessException("退款失败");
-    }
-
 }

+ 0 - 29
src/main/java/com/izouma/nineth/service/SandPayService.java

@@ -287,35 +287,6 @@ public class SandPayService {
         return requestServer(header, body, "https://cashier.sandpay.com.cn/qr/api/order/refund");
     }
 
-    @Cacheable(value = "sandPay", key = "#orderId")
-    public String payAuctionOrder(Long orderId) {
-        AuctionOrder order = auctionOrderRepo.findById(orderId).orElseThrow(new BusinessException("订单不存在"));
-        if (order.getStatus() != AuctionOrderStatus.NOT_PAID) {
-            throw new BusinessException("订单状态错误");
-        }
-        JSONObject extend = new JSONObject();
-        extend.put("type", "auctionOrder");
-        extend.put("id", orderId);
-
-        JSONObject res = requestAlipayRaw(orderId.toString(), order.getTotalPrice(), "拍卖:" + order.getAuctionId(),
-                "拍卖:" + order.getName(), 180, extend.toJSONString());
-        if (res == null)
-            throw new BusinessException("下单失败,请稍后再试");
-
-        if (!"000000".equals(res.getJSONObject("head").getString("respCode"))) {
-            String msg = res.getJSONObject("head").getString("respMsg");
-            if (msg.contains("超限")) {
-                throw new BusinessException("超过商户单日额度");
-            }
-            if (msg.contains("商户状态")) {
-                throw new BusinessException("超过商户单日额度");
-            }
-            throw new BusinessException(msg);
-        }
-
-        return res.getJSONObject("body").getString("qrCode");
-    }
-
     public JSONObject transfer(String id, String name, String bank, BigDecimal amount) {
         JSONObject request = new JSONObject();
         DecimalFormat df = new DecimalFormat("000000000000", DecimalFormatSymbols.getInstance(Locale.US));

+ 0 - 35
src/main/java/com/izouma/nineth/web/OrderPayController.java

@@ -117,41 +117,6 @@ public class OrderPayController {
         return orderPayService.payOrderQuick(id);
     }
 
-    @ApiOperation("衫德h5拍卖")
-    @RequestMapping(value = "/auction/alipay_h5", method = RequestMethod.GET, produces = "text/html")
-    @ResponseBody
-    public String payAuctionOrder(@RequestParam Long id) {
-        return sandPayService.payAuctionQuick(id);
-    }
-
-    @RequestMapping(value = "/auction/alipay_wx", method = RequestMethod.GET)
-    public String payAuctionOrderAlipayWx(Long id, Model model) {
-        String payUrl = sandPayService.auctionOrderQR(id);
-        model.addAttribute("payUrl", payUrl);
-        model.addAttribute("orderId", id);
-        return "AlipayHtml";
-    }
-
-    @RequestMapping(value = "/auction/alipay_qr", method = RequestMethod.GET)
-    @ResponseBody
-    public String payAuctionOrderAlipayQR(Long id, Model model) {
-        return sandPayService.auctionOrderQR(id);
-    }
-
-    @RequestMapping(value = "/auction/alipay_app", method = RequestMethod.GET)
-    @ResponseBody
-    public String payAuctionOrderAlipayApp(Long id, Model model) {
-        return sandPayService.auctionOrderQR(id);
-    }
-
-    @ApiOperation("衫德h5拍卖")
-    @RequestMapping(value = "/auction/sand_pay", method = RequestMethod.GET, produces = "text/html")
-    @ResponseBody
-    public String auctionSandPay(@RequestParam Long id) {
-        return sandPayService.payAuctionQuick(id);
-    }
-
-
     @RequestMapping(value = "/gift/alipay_h5", method = RequestMethod.GET)
     @ResponseBody
     public String payGiftOrderAlipayH5(Long id, Model model) throws BaseAdaPayException {

+ 1 - 1
src/main/java/com/izouma/nineth/web/OrderPayControllerV2.java

@@ -174,7 +174,7 @@ public class OrderPayControllerV2 {
     @RequestMapping(value = "/auction/sandQuick", method = RequestMethod.GET, produces = "text/html")
     @ResponseBody
     public String payAuctionQuick(@RequestParam Long id) {
-        return sandPayService.payAuctionQuick(id);
+        return orderPayService.payAuctionQuick(id);
     }
 
     @RequestMapping(value = "auction/balance", method = RequestMethod.GET)

+ 1 - 2
src/main/java/com/izouma/nineth/web/SandPayController.java

@@ -37,8 +37,7 @@ public class SandPayController {
     private RocketMQTemplate    rocketMQTemplate;
     private GiftOrderService    giftOrderService;
     private MintOrderService    mintOrderService;
-    private UserBalanceService userBalanceService;
-    private AuctionOrderService auctionOrderService;
+    private UserBalanceService  userBalanceService;
 
     @PostMapping("/notify")
     public Object notifyOrder(HttpServletRequest req, HttpServletResponse resp) {

+ 0 - 1
src/test/java/com/izouma/nineth/service/AuctionRecordServiceTest.java

@@ -12,7 +12,6 @@ public class AuctionRecordServiceTest extends ApplicationTests {
 
     @Test
     public void test() {
-        auctionRecordService.recordInfos(new PageQuery()).getContent().forEach(System.out::println);
     }
 
 }