OrderService.java 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494
  1. package com.izouma.nineth.service;
  2. import com.alibaba.fastjson.JSON;
  3. import com.alibaba.fastjson.JSONObject;
  4. import com.alibaba.fastjson.serializer.SerializerFeature;
  5. import com.alipay.api.AlipayClient;
  6. import com.alipay.api.request.AlipayTradeWapPayRequest;
  7. import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult;
  8. import com.github.binarywang.wxpay.bean.order.WxPayMwebOrderResult;
  9. import com.github.binarywang.wxpay.bean.request.WxPayRefundRequest;
  10. import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest;
  11. import com.github.binarywang.wxpay.constant.WxPayConstants;
  12. import com.github.binarywang.wxpay.exception.WxPayException;
  13. import com.github.binarywang.wxpay.service.WxPayService;
  14. import com.huifu.adapay.core.exception.BaseAdaPayException;
  15. import com.huifu.adapay.model.Payment;
  16. import com.izouma.nineth.config.AdapayProperties;
  17. import com.izouma.nineth.config.AlipayProperties;
  18. import com.izouma.nineth.config.WxPayProperties;
  19. import com.izouma.nineth.domain.Collection;
  20. import com.izouma.nineth.domain.*;
  21. import com.izouma.nineth.dto.PageQuery;
  22. import com.izouma.nineth.enums.*;
  23. import com.izouma.nineth.event.CreateAssetEvent;
  24. import com.izouma.nineth.event.TransferAssetEvent;
  25. import com.izouma.nineth.exception.BusinessException;
  26. import com.izouma.nineth.repo.*;
  27. import com.izouma.nineth.utils.JpaUtils;
  28. import com.izouma.nineth.utils.SnowflakeIdWorker;
  29. import lombok.AllArgsConstructor;
  30. import lombok.extern.slf4j.Slf4j;
  31. import org.apache.commons.codec.EncoderException;
  32. import org.apache.commons.codec.net.URLCodec;
  33. import org.springframework.context.event.EventListener;
  34. import org.springframework.core.env.Environment;
  35. import org.springframework.data.domain.Page;
  36. import org.springframework.data.redis.core.RedisTemplate;
  37. import org.springframework.scheduling.annotation.Scheduled;
  38. import org.springframework.stereotype.Service;
  39. import org.springframework.ui.Model;
  40. import javax.transaction.Transactional;
  41. import java.math.BigDecimal;
  42. import java.math.RoundingMode;
  43. import java.time.LocalDateTime;
  44. import java.util.*;
  45. import java.util.stream.Collectors;
  46. @Service
  47. @AllArgsConstructor
  48. @Slf4j
  49. public class OrderService {
  50. private OrderRepo orderRepo;
  51. private CollectionRepo collectionRepo;
  52. private UserAddressRepo userAddressRepo;
  53. private UserRepo userRepo;
  54. private Environment env;
  55. private AlipayClient alipayClient;
  56. private AlipayProperties alipayProperties;
  57. private WxPayService wxPayService;
  58. private WxPayProperties wxPayProperties;
  59. private AssetService assetService;
  60. private SysConfigService sysConfigService;
  61. private BlindBoxItemRepo blindBoxItemRepo;
  62. private AssetRepo assetRepo;
  63. private UserCouponRepo userCouponRepo;
  64. private CollectionService collectionService;
  65. private RedisTemplate<String, Object> redisTemplate;
  66. private CommissionRecordRepo commissionRecordRepo;
  67. private AdapayProperties adapayProperties;
  68. public Page<Order> all(PageQuery pageQuery) {
  69. return orderRepo.findAll(JpaUtils.toSpecification(pageQuery, Order.class), JpaUtils.toPageRequest(pageQuery));
  70. }
  71. @Transactional
  72. public Order create(Long userId, Long collectionId, int qty, Long addressId, Long userCouponId, Long invitor) {
  73. if (qty <= 0) throw new BusinessException("数量必须大于0");
  74. User user = userRepo.findByIdAndDelFalse(userId).orElseThrow(new BusinessException("用户不存在"));
  75. Collection collection = collectionRepo.findById(collectionId).orElseThrow(new BusinessException("藏品不存在"));
  76. User minter = userRepo.findById(collection.getMinterId()).orElseThrow(new BusinessException("铸造者不存在"));
  77. UserCoupon coupon = null;
  78. if (userCouponId != null) {
  79. coupon = userCouponRepo.findById(userCouponId).orElseThrow(new BusinessException("兑换券不存在"));
  80. if (coupon.isUsed()) {
  81. throw new BusinessException("该兑换券已使用");
  82. }
  83. if (coupon.isLimited() && !coupon.getCollectionIds().contains(collectionId)) {
  84. throw new BusinessException("该兑换券不可用");
  85. }
  86. }
  87. if (!collection.isOnShelf()) {
  88. throw new BusinessException("藏品已下架");
  89. }
  90. if (qty > collection.getStock()) {
  91. throw new BusinessException("库存不足");
  92. }
  93. if (!collection.isSalable()) {
  94. throw new BusinessException("该藏品当前不可购买");
  95. }
  96. if (collection.getType() == CollectionType.BLIND_BOX) {
  97. if (collection.getStartTime().isAfter(LocalDateTime.now())) {
  98. throw new BusinessException("盲盒未开售");
  99. }
  100. }
  101. UserAddress userAddress = null;
  102. if (addressId != null) {
  103. userAddress = userAddressRepo.findById(addressId).orElseThrow(new BusinessException("地址信息不存在"));
  104. }
  105. collection.setStock(collection.getStock() - qty);
  106. collection.setSale(collection.getSale() + qty);
  107. collectionRepo.save(collection);
  108. BigDecimal gasFee = sysConfigService.getBigDecimal("gas_fee");
  109. Order order = Order.builder()
  110. .userId(userId)
  111. .collectionId(collectionId)
  112. .name(collection.getName())
  113. .pic(collection.getPic())
  114. .detail(collection.getDetail())
  115. .properties(collection.getProperties())
  116. .category(collection.getCategory())
  117. .canResale(collection.isCanResale())
  118. .royalties(collection.getRoyalties())
  119. .serviceCharge(collection.getServiceCharge())
  120. .type(collection.getType())
  121. .minterId(collection.getMinterId())
  122. .minter(minter.getNickname())
  123. .minterAvatar(minter.getAvatar())
  124. .qty(qty)
  125. .price(collection.getPrice())
  126. .gasPrice(gasFee)
  127. .totalPrice(collection.getPrice().multiply(BigDecimal.valueOf(qty)).add(gasFee))
  128. .contactName(Optional.ofNullable(userAddress).map(UserAddress::getName).orElse(null))
  129. .contactPhone(Optional.ofNullable(userAddress).map(UserAddress::getPhone).orElse(null))
  130. .address(Optional.ofNullable(userAddress).map(u ->
  131. u.getProvinceId() + " " + u.getCityId() + " " + u.getDistrictId() + " " + u.getAddress())
  132. .orElse(null))
  133. .status(OrderStatus.NOT_PAID)
  134. .assetId(collection.getAssetId())
  135. .couponId(userCouponId)
  136. .invitor(invitor)
  137. .build();
  138. if (coupon != null) {
  139. coupon.setUsed(true);
  140. coupon.setUseTime(LocalDateTime.now());
  141. if (coupon.isNeedGas()) {
  142. order.setTotalPrice(order.getGasPrice());
  143. } else {
  144. order.setTotalPrice(BigDecimal.ZERO);
  145. }
  146. }
  147. if (collection.getSource() == CollectionSource.TRANSFER) {
  148. Asset asset = assetRepo.findById(collection.getAssetId()).orElseThrow(new BusinessException("资产不存在"));
  149. asset.setStatus(AssetStatus.TRADING);
  150. assetRepo.save(asset);
  151. collection.setOnShelf(false);
  152. collectionRepo.save(collection);
  153. }
  154. order = orderRepo.save(order);
  155. if (order.getTotalPrice().equals(BigDecimal.ZERO)) {
  156. notifyOrder(order.getId(), PayMethod.WEIXIN, null);
  157. }
  158. return order;
  159. }
  160. public void payOrderAlipay(Long id, Model model) {
  161. try {
  162. Order order = orderRepo.findByIdAndDelFalse(id).orElseThrow(new BusinessException("订单不存在"));
  163. if (order.getStatus() != OrderStatus.NOT_PAID) {
  164. throw new BusinessException("订单状态错误");
  165. }
  166. JSONObject bizContent = new JSONObject();
  167. bizContent.put("notifyUrl", alipayProperties.getNotifyUrl());
  168. bizContent.put("returnUrl", alipayProperties.getReturnUrl());
  169. bizContent.put("out_trade_no", String.valueOf(new SnowflakeIdWorker(0, 0).nextId()));
  170. bizContent.put("total_amount", order.getTotalPrice().stripTrailingZeros().toPlainString());
  171. bizContent.put("disable_pay_channels", "pcredit,creditCard");
  172. if (Arrays.stream(env.getActiveProfiles()).noneMatch(s -> s.equals("prod"))) {
  173. // 测试环境设为1分
  174. bizContent.put("total_amount", "0.01");
  175. }
  176. bizContent.put("subject", order.getName());
  177. bizContent.put("product_code", "QUICK_WAP_PAY");
  178. JSONObject body = new JSONObject();
  179. body.put("action", "payOrder");
  180. body.put("userId", order.getUserId());
  181. body.put("orderId", order.getId());
  182. bizContent.put("body", body.toJSONString());
  183. AlipayTradeWapPayRequest alipayRequest = new AlipayTradeWapPayRequest();
  184. alipayRequest.setReturnUrl(alipayProperties.getReturnUrl());
  185. alipayRequest.setNotifyUrl(alipayProperties.getNotifyUrl());
  186. alipayRequest.setBizContent(JSON.toJSONString(bizContent));
  187. String form = alipayClient.pageExecute(alipayRequest).getBody();
  188. model.addAttribute("form", form);
  189. } catch (BusinessException err) {
  190. model.addAttribute("errMsg", err.getError());
  191. } catch (Exception e) {
  192. model.addAttribute("errMsg", e.getMessage());
  193. }
  194. }
  195. public Object payOrderWeixin(Long id, String tradeType, String openId) throws WxPayException, EncoderException {
  196. Order order = orderRepo.findByIdAndDelFalse(id).orElseThrow(new BusinessException("订单不存在"));
  197. if (order.getStatus() != OrderStatus.NOT_PAID) {
  198. throw new BusinessException("订单状态错误");
  199. }
  200. WxPayUnifiedOrderRequest request = new WxPayUnifiedOrderRequest();
  201. request.setBody(order.getName());
  202. request.setOutTradeNo(String.valueOf(new SnowflakeIdWorker(1, 1).nextId()));
  203. request.setTotalFee(order.getTotalPrice().multiply(BigDecimal.valueOf(100)).intValue());
  204. if (Arrays.stream(env.getActiveProfiles()).noneMatch(s -> s.equals("prod"))) {
  205. // 测试环境设为1分
  206. // request.setTotalFee(1);
  207. }
  208. request.setSpbillCreateIp("180.102.110.170");
  209. request.setNotifyUrl(wxPayProperties.getNotifyUrl());
  210. request.setTradeType(tradeType);
  211. request.setOpenid(openId);
  212. request.setSignType("MD5");
  213. JSONObject body = new JSONObject();
  214. body.put("action", "payOrder");
  215. body.put("userId", order.getUserId());
  216. body.put("orderId", order.getId());
  217. request.setAttach(body.toJSONString());
  218. if (WxPayConstants.TradeType.MWEB.equals(tradeType)) {
  219. WxPayMwebOrderResult result = wxPayService.createOrder(request);
  220. return result.getMwebUrl() + "&redirect_url=" + new URLCodec().encode(wxPayProperties.getReturnUrl());
  221. } else if (WxPayConstants.TradeType.JSAPI.equals(tradeType)) {
  222. return wxPayService.<WxPayMpOrderResult>createOrder(request);
  223. }
  224. throw new BusinessException("不支持此付款方式");
  225. }
  226. public Object payAdapay(Long id, String payChannel, String openId) throws BaseAdaPayException {
  227. Order order = orderRepo.findByIdAndDelFalse(id).orElseThrow(new BusinessException("订单不存在"));
  228. Collection collection = collectionRepo.findById(order.getCollectionId())
  229. .orElseThrow(new BusinessException("藏品不存在"));
  230. User invitor = userRepo.findById(order.getInvitor()).orElse(null);
  231. if (order.getStatus() != OrderStatus.NOT_PAID) {
  232. throw new BusinessException("订单状态错误");
  233. }
  234. Map<String, Object> paymentParams = new HashMap<>();
  235. paymentParams.put("order_no", String.valueOf(new SnowflakeIdWorker(0, 0).nextId()));
  236. paymentParams.put("pay_amt", order.getTotalPrice().setScale(2, RoundingMode.HALF_UP).toPlainString());
  237. paymentParams.put("app_id", adapayProperties.getAppId());
  238. paymentParams.put("pay_channel", payChannel);
  239. paymentParams.put("goods_title", collection.getName());
  240. List<Map<String, Object>> divMembers = new ArrayList<>();
  241. BigDecimal restAmount = order.getTotalPrice().setScale(2, RoundingMode.HALF_UP);
  242. if (collection.getSource().equals(CollectionSource.TRANSFER)) {
  243. Asset asset = assetRepo.findById(collection.getAssetId()).orElseThrow(new BusinessException("无记录"));
  244. User owner = userRepo.findById(asset.getUserId()).orElseThrow(new BusinessException("拥有者用户不存在"));
  245. restAmount = divMoney(order.getTotalPrice(), restAmount, divMembers, "0",
  246. collection.getServiceCharge() + collection.getRoyalties(), true);
  247. restAmount = divMoney(order.getTotalPrice(), restAmount, divMembers, owner.getMemberId(),
  248. -1, false);
  249. } else {
  250. if (invitor != null) {
  251. restAmount = divMoney(order.getTotalPrice(), restAmount, divMembers, invitor.getMemberId(),
  252. invitor.getShareRatio().intValue(), false);
  253. }
  254. restAmount = divMoney(order.getTotalPrice(), restAmount, divMembers, "0",
  255. -1, true);
  256. }
  257. paymentParams.put("div_members", JSON.toJSONString(divMembers));
  258. if (restAmount.compareTo(BigDecimal.ZERO) != 0) {
  259. log.error("分账出错 {}", JSON.toJSONString(divMembers, SerializerFeature.PrettyFormat));
  260. throw new BusinessException("分账出错");
  261. }
  262. Map<String, Object> response = Payment.create(paymentParams);
  263. return response;
  264. }
  265. private BigDecimal divMoney(BigDecimal totalAmount, BigDecimal restAmount, List<Map<String, Object>> divMembers,
  266. String memberId, int ratio, boolean feeFlag) {
  267. if (ratio == -1 || (ratio > 0 && ratio < 100)) {
  268. BigDecimal divAmount = ratio == -1 ? restAmount :
  269. totalAmount.multiply(BigDecimal.valueOf(ratio))
  270. .divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP);
  271. Map<String, Object> divMem = new HashMap<>();
  272. divMem.put("member_id", memberId);
  273. divMem.put("amount", divAmount.toPlainString());
  274. divMem.put("fee_flag", feeFlag ? "Y" : "N");
  275. divMembers.add(divMem);
  276. return restAmount.subtract(divAmount);
  277. } else {
  278. throw new BusinessException("分账比例错误");
  279. }
  280. }
  281. @Transactional
  282. public void notifyOrder(Long orderId, PayMethod payMethod, String transactionId) {
  283. Order order = orderRepo.findById(orderId).orElseThrow(new BusinessException("订单不存在"));
  284. Collection collection = collectionRepo.findById(order.getCollectionId())
  285. .orElseThrow(new BusinessException("藏品不存在"));
  286. User user = userRepo.findById(order.getUserId()).orElseThrow(new BusinessException("用户不存在"));
  287. if (order.getStatus() == OrderStatus.NOT_PAID) {
  288. order.setStatus(OrderStatus.PROCESSING);
  289. order.setPayTime(LocalDateTime.now());
  290. order.setTransactionId(transactionId);
  291. order.setPayMethod(payMethod);
  292. if (order.getType() == CollectionType.BLIND_BOX) {
  293. BlindBoxItem winItem = collectionService.draw(collection.getId());
  294. order.setWinCollectionId(winItem.getCollectionId());
  295. orderRepo.save(order);
  296. assetService.createAsset(winItem, user, order.getId(), order.getPrice(), "出售",
  297. collectionService.getNextNumber(winItem.getCollectionId()));
  298. addSales(winItem.getMinterId());
  299. } else {
  300. if (collection.getSource() == CollectionSource.TRANSFER) {
  301. Asset asset = assetRepo.findById(collection.getAssetId()).orElse(null);
  302. assetService.transfer(asset, order.getPrice(), user, "转让", order.getId());
  303. collectionRepo.delete(collection);
  304. } else {
  305. orderRepo.save(order);
  306. assetService.createAsset(collection, user, order.getId(), order.getPrice(), "出售",
  307. collectionService.getNextNumber(order.getCollectionId()));
  308. }
  309. addSales(collection.getMinterId());
  310. }
  311. commission(order);
  312. } else if (order.getStatus() == OrderStatus.CANCELLED) {
  313. }
  314. }
  315. @EventListener
  316. public void onCreateAsset(CreateAssetEvent event) {
  317. Asset asset = event.getAsset();
  318. Order order = orderRepo.findById(asset.getOrderId()).orElseThrow(new BusinessException("订单不存在"));
  319. if (event.isSuccess()) {
  320. order.setTxHash(asset.getTxHash());
  321. order.setGasUsed(asset.getGasUsed());
  322. order.setBlockNumber(asset.getBlockNumber());
  323. order.setStatus(OrderStatus.FINISH);
  324. orderRepo.save(order);
  325. } else {
  326. log.error("创建asset失败");
  327. }
  328. }
  329. @EventListener
  330. public void onTransferAsset(TransferAssetEvent event) {
  331. Asset asset = event.getAsset();
  332. Order order = orderRepo.findById(asset.getOrderId()).orElseThrow(new BusinessException("订单不存在"));
  333. if (event.isSuccess()) {
  334. order.setTxHash(asset.getTxHash());
  335. order.setGasUsed(asset.getGasUsed());
  336. order.setBlockNumber(asset.getBlockNumber());
  337. order.setStatus(OrderStatus.FINISH);
  338. orderRepo.save(order);
  339. } else {
  340. log.error("创建asset失败");
  341. }
  342. }
  343. public void cancel(Long id) {
  344. Order order = orderRepo.findById(id).orElseThrow(new BusinessException("订单不存在"));
  345. cancel(order);
  346. }
  347. public void cancel(Order order) {
  348. if (order.getStatus() != OrderStatus.NOT_PAID) {
  349. throw new BusinessException("已支付订单无法取消");
  350. }
  351. Collection collection = collectionRepo.findById(order.getCollectionId())
  352. .orElseThrow(new BusinessException("藏品不存在"));
  353. User minter = userRepo.findById(collection.getMinterId()).orElseThrow(new BusinessException("铸造者不存在"));
  354. if (collection.getSource() == CollectionSource.TRANSFER) {
  355. Asset asset = assetRepo.findById(collection.getAssetId()).orElse(null);
  356. if (asset != null) {
  357. asset.setStatus(AssetStatus.NORMAL);
  358. assetRepo.save(asset);
  359. }
  360. collection.setOnShelf(true);
  361. }
  362. collection.setSale(collection.getSale() - 1);
  363. collection.setStock(collection.getStock() + 1);
  364. collectionRepo.save(collection);
  365. order.setStatus(OrderStatus.CANCELLED);
  366. order.setCancelTime(LocalDateTime.now());
  367. orderRepo.save(order);
  368. if (order.getCouponId() != null) {
  369. userCouponRepo.findById(order.getCouponId()).ifPresent(coupon -> {
  370. coupon.setUsed(false);
  371. coupon.setUseTime(null);
  372. userCouponRepo.save(coupon);
  373. });
  374. }
  375. }
  376. @Scheduled(fixedRate = 60000)
  377. public void batchCancel() {
  378. List<Order> orders = orderRepo.findByStatusAndCreatedAtBeforeAndDelFalse(OrderStatus.NOT_PAID,
  379. LocalDateTime.now().minusMinutes(5));
  380. orders.forEach(o -> {
  381. try {
  382. cancel(o);
  383. } catch (Exception ignored) {
  384. }
  385. });
  386. }
  387. public void refundCancelled(Order order) {
  388. }
  389. public synchronized void addSales(Long userId) {
  390. if (userId != null) {
  391. userRepo.findById(userId).ifPresent(user -> {
  392. user.setSales(user.getSales() + 1);
  393. userRepo.save(user);
  394. });
  395. }
  396. }
  397. public void setNumber() {
  398. for (Collection collection : collectionRepo.findAll()) {
  399. if (collection.getSource() != CollectionSource.OFFICIAL) continue;
  400. collection.setCurrentNumber(0);
  401. collectionRepo.save(collection);
  402. for (Asset asset : assetRepo.findByCollectionIdAndStatusIn(collection.getId(),
  403. Arrays.asList(AssetStatus.NORMAL, AssetStatus.GIFTING, AssetStatus.TRADING))) {
  404. asset.setNumber(collectionService.getNextNumber(collection.getId()));
  405. assetRepo.save(asset);
  406. }
  407. }
  408. }
  409. public void setSales() {
  410. List<Collection> collections = collectionRepo.findAll();
  411. List<User> minters = userRepo.findAllById(collections.stream().map(Collection::getMinterId)
  412. .collect(Collectors.toSet()));
  413. for (User minter : minters) {
  414. List<Collection> list = collections.stream().filter(c -> minter.getId().equals(c.getMinterId()))
  415. .collect(Collectors.toList());
  416. minter.setSales((int) orderRepo.findByCollectionIdIn(list.stream().map(Collection::getId)
  417. .collect(Collectors.toSet())).stream()
  418. .filter(o -> o.getStatus() != OrderStatus.CANCELLED).count());
  419. userRepo.save(minter);
  420. }
  421. }
  422. public void commission(Order order) {
  423. if (order.getInvitor() != null) {
  424. userRepo.findById(order.getInvitor()).ifPresent(user -> {
  425. BigDecimal shareRatio = user.getShareRatio();
  426. if (shareRatio != null && shareRatio.compareTo(BigDecimal.ZERO) > 0) {
  427. BigDecimal totalPrice = order.getTotalPrice().subtract(order.getGasPrice());
  428. commissionRecordRepo.save(CommissionRecord.builder()
  429. .orderId(order.getId())
  430. .totalPrice(totalPrice)
  431. .nickname(user.getNickname())
  432. .userId(user.getId())
  433. .shareRatio(user.getShareRatio())
  434. .phone(user.getPhone())
  435. .shareAmount(totalPrice.multiply(shareRatio)
  436. .divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP))
  437. .build());
  438. }
  439. });
  440. }
  441. }
  442. public void refund(Long id) throws WxPayException {
  443. Order order = orderRepo.findById(id).orElseThrow(new BusinessException("无记录"));
  444. if (order.getStatus() != OrderStatus.FINISH) {
  445. throw new BusinessException("订单未付款");
  446. }
  447. WxPayRefundRequest request = new WxPayRefundRequest();
  448. request.setTransactionId(order.getTransactionId());
  449. request.setTotalFee(order.getTotalPrice().multiply(BigDecimal.valueOf(100)).intValue());
  450. request.setRefundFee(order.getTotalPrice().multiply(BigDecimal.valueOf(100)).intValue());
  451. request.setOutRefundNo(String.valueOf(new SnowflakeIdWorker(0, 0).nextId()));
  452. wxPayService.refund(request);
  453. }
  454. }