Commit 2ce89df05dc885f99db85a2fefa078260165bcb9
1 parent
5cde1c03
update:微信支付。
Showing
12 changed files
with
173 additions
and
52 deletions
etrade-order/src/main/java/com/diligrp/etrade/order/api/OrderController.java
@@ -372,22 +372,6 @@ public class OrderController { | @@ -372,22 +372,6 @@ public class OrderController { | ||
372 | return ParameterDetection.detection(result); | 372 | return ParameterDetection.detection(result); |
373 | } | 373 | } |
374 | Message message = orderService.orderWeChatPayBatch(orderWeChatPayBatch, OrderOrderType.BUYER_ORDER.getCodeInteger(),OrderOrderState.BUYER_WECHAT_PAY); | 374 | Message message = orderService.orderWeChatPayBatch(orderWeChatPayBatch, OrderOrderType.BUYER_ORDER.getCodeInteger(),OrderOrderState.BUYER_WECHAT_PAY); |
375 | - | ||
376 | - //临时代码 | ||
377 | - WeChatPayTradeBackDto weChatPayTradeBackDto = (WeChatPayTradeBackDto) message.getData(); | ||
378 | - WeChatPayTradeCallBackDto weChatPayTradeCallBackDto = new WeChatPayTradeCallBackDto(); | ||
379 | - weChatPayTradeCallBackDto.setPaymentId(weChatPayTradeBackDto.getPaymentId()); | ||
380 | - weChatPayTradeCallBackDto.setState(WeChatPayState.SUCCESS.getCode()); | ||
381 | - weChatPayTradeCallBackDto.setWhen(LocalDateTime.now()); | ||
382 | - List<Order> orderList = orderService.wxChatPayCallBack(weChatPayTradeCallBackDto); | ||
383 | - if(CollectionUtils.isEmpty(orderList)){ | ||
384 | - return Message.success("没有订单发生变更"); | ||
385 | - }else{ | ||
386 | - for (Order order : orderList){ | ||
387 | - orderService.finishOrder(order); | ||
388 | - } | ||
389 | - } | ||
390 | - //临时代码结束 | ||
391 | return message; | 375 | return message; |
392 | } | 376 | } |
393 | 377 |
etrade-order/src/main/java/com/diligrp/etrade/order/dao/OrderMapper.java
@@ -125,4 +125,10 @@ public interface OrderMapper extends MybatisMapperSupport { | @@ -125,4 +125,10 @@ public interface OrderMapper extends MybatisMapperSupport { | ||
125 | * @return | 125 | * @return |
126 | */ | 126 | */ |
127 | OrderDto selectOrderState(String code); | 127 | OrderDto selectOrderState(String code); |
128 | + | ||
129 | + /** | ||
130 | + * 更新订单库存为已扣减 | ||
131 | + * @param ids | ||
132 | + */ | ||
133 | + void updateDeductState(@Param("ids")List<Long> ids); | ||
128 | } | 134 | } |
etrade-order/src/main/java/com/diligrp/etrade/order/domain/OrderWeChatPayBatch.java
@@ -54,7 +54,6 @@ public class OrderWeChatPayBatch { | @@ -54,7 +54,6 @@ public class OrderWeChatPayBatch { | ||
54 | @Valid | 54 | @Valid |
55 | private OrderDeliveryDto delivery; | 55 | private OrderDeliveryDto delivery; |
56 | 56 | ||
57 | - @NotBlank(message = "登陆编码不能为空") | ||
58 | private String code; | 57 | private String code; |
59 | 58 | ||
60 | public String getPayType() { | 59 | public String getPayType() { |
etrade-order/src/main/java/com/diligrp/etrade/order/model/Order.java
@@ -281,6 +281,8 @@ public class Order { | @@ -281,6 +281,8 @@ public class Order { | ||
281 | 281 | ||
282 | /** 运费 */ | 282 | /** 运费 */ |
283 | private Long transportFee; | 283 | private Long transportFee; |
284 | + /** 运费 */ | ||
285 | + private Integer stockDeductionState; | ||
284 | 286 | ||
285 | public Integer getAchieveType() { | 287 | public Integer getAchieveType() { |
286 | return achieveType; | 288 | return achieveType; |
@@ -745,4 +747,12 @@ public class Order { | @@ -745,4 +747,12 @@ public class Order { | ||
745 | public void setTransportFee(Long transportFee) { | 747 | public void setTransportFee(Long transportFee) { |
746 | this.transportFee = transportFee; | 748 | this.transportFee = transportFee; |
747 | } | 749 | } |
750 | + | ||
751 | + public Integer getStockDeductionState() { | ||
752 | + return stockDeductionState; | ||
753 | + } | ||
754 | + | ||
755 | + public void setStockDeductionState(Integer stockDeductionState) { | ||
756 | + this.stockDeductionState = stockDeductionState; | ||
757 | + } | ||
748 | } | 758 | } |
749 | \ No newline at end of file | 759 | \ No newline at end of file |
etrade-order/src/main/java/com/diligrp/etrade/order/service/impl/OrderGoodsServiceImpl.java
@@ -265,6 +265,10 @@ public class OrderGoodsServiceImpl implements OrderGoodsService { | @@ -265,6 +265,10 @@ public class OrderGoodsServiceImpl implements OrderGoodsService { | ||
265 | @Transactional | 265 | @Transactional |
266 | @Override | 266 | @Override |
267 | public void deduct(Order order,Long operateId,String operateName) { | 267 | public void deduct(Order order,Long operateId,String operateName) { |
268 | + //检测是否扣减过,已扣减则不再继续扣减 | ||
269 | + if(order.getStockDeductionState()!=null&&order.getStockDeductionState().equals(OrderDeductionState.DEDUCT_FINISH.getCodeInteger())){ | ||
270 | + return ; | ||
271 | + } | ||
268 | List<ProductDto> realgoods = getProductDtoByOrderId(order.getId(),order.getMarketId(),OrderGoodState.NORMAL.getCodeInteger()); | 272 | List<ProductDto> realgoods = getProductDtoByOrderId(order.getId(),order.getMarketId(),OrderGoodState.NORMAL.getCodeInteger()); |
269 | Map<Long,ProductDto> deductGoods = new HashMap<>(); | 273 | Map<Long,ProductDto> deductGoods = new HashMap<>(); |
270 | for(ProductDto productDto :realgoods){ | 274 | for(ProductDto productDto :realgoods){ |
@@ -286,6 +290,7 @@ public class OrderGoodsServiceImpl implements OrderGoodsService { | @@ -286,6 +290,7 @@ public class OrderGoodsServiceImpl implements OrderGoodsService { | ||
286 | goods.add(stock); | 290 | goods.add(stock); |
287 | try{ | 291 | try{ |
288 | stockService.deduct(goods); | 292 | stockService.deduct(goods); |
293 | + order.setStockDeductionState(OrderDeductionState.DEDUCT_FINISH.getCodeInteger()); | ||
289 | }catch (StockNotFoundException | InsufficientStockException e){ | 294 | }catch (StockNotFoundException | InsufficientStockException e){ |
290 | throw new InsufficientStockException(e.getCode(),"支付失败,"+productDto.getProductName()+"库存不足。"); | 295 | throw new InsufficientStockException(e.getCode(),"支付失败,"+productDto.getProductName()+"库存不足。"); |
291 | } | 296 | } |
@@ -296,7 +301,16 @@ public class OrderGoodsServiceImpl implements OrderGoodsService { | @@ -296,7 +301,16 @@ public class OrderGoodsServiceImpl implements OrderGoodsService { | ||
296 | public void deductBatch(List<Order> orders, Long operateId, String operateName) { | 301 | public void deductBatch(List<Order> orders, Long operateId, String operateName) { |
297 | List<ProductExtDto> realgoods = new ArrayList<>(); | 302 | List<ProductExtDto> realgoods = new ArrayList<>(); |
298 | for(Order order : orders){ | 303 | for(Order order : orders){ |
304 | + //判断订单是否已经扣减过库存 | ||
305 | + if(order.getStockDeductionState()!=null&&OrderDeductionState.DEDUCT_FINISH.getCodeInteger().equals(order.getStockDeductionState())){ | ||
306 | + continue; | ||
307 | + } | ||
299 | realgoods.addAll(orderGoodsMapper.getProductDtoWithOrder(order.getId(),order.getShopId(),order.getMarketId(),order.getShopCustomerId(),OrderGoodState.NORMAL.getCodeInteger())); | 308 | realgoods.addAll(orderGoodsMapper.getProductDtoWithOrder(order.getId(),order.getShopId(),order.getMarketId(),order.getShopCustomerId(),OrderGoodState.NORMAL.getCodeInteger())); |
309 | + //变更订单库存扣减状态 | ||
310 | + order.setStockDeductionState(OrderDeductionState.DEDUCT_FINISH.getCodeInteger()); | ||
311 | + } | ||
312 | + if(realgoods.size()<1){ | ||
313 | + return ; | ||
300 | } | 314 | } |
301 | Map<Long,ProductExtDto> deductGoods = new HashMap<>(); | 315 | Map<Long,ProductExtDto> deductGoods = new HashMap<>(); |
302 | for(ProductExtDto productExtDto :realgoods){ | 316 | for(ProductExtDto productExtDto :realgoods){ |
@@ -318,6 +332,7 @@ public class OrderGoodsServiceImpl implements OrderGoodsService { | @@ -318,6 +332,7 @@ public class OrderGoodsServiceImpl implements OrderGoodsService { | ||
318 | goods.add(stock); | 332 | goods.add(stock); |
319 | try{ | 333 | try{ |
320 | stockService.deduct(goods); | 334 | stockService.deduct(goods); |
335 | + | ||
321 | }catch (StockNotFoundException | InsufficientStockException e){ | 336 | }catch (StockNotFoundException | InsufficientStockException e){ |
322 | throw new InsufficientStockException(e.getCode(),"支付失败,"+productExtDto.getProductName()+"库存不足。"); | 337 | throw new InsufficientStockException(e.getCode(),"支付失败,"+productExtDto.getProductName()+"库存不足。"); |
323 | } | 338 | } |
etrade-order/src/main/java/com/diligrp/etrade/order/service/impl/OrderServiceImpl.java
@@ -647,6 +647,7 @@ public class OrderServiceImpl implements OrderService { | @@ -647,6 +647,7 @@ public class OrderServiceImpl implements OrderService { | ||
647 | try{ | 647 | try{ |
648 | //扣减库存T | 648 | //扣减库存T |
649 | orderGoodsService.deductBatch(orderMap,orderPayBatch.getPayerCustomerId(),orderPayBatch.getPayerCustomerName()); | 649 | orderGoodsService.deductBatch(orderMap,orderPayBatch.getPayerCustomerId(),orderPayBatch.getPayerCustomerName()); |
650 | + orderMapper.updateDeductState(orderMap.stream().map(Order::getId).collect(Collectors.toList())); | ||
650 | LOGGER.info("支付完成写入流水"); | 651 | LOGGER.info("支付完成写入流水"); |
651 | orderPaymentService.sendSerialRecord(serialRecordDtos); | 652 | orderPaymentService.sendSerialRecord(serialRecordDtos); |
652 | }catch (OrderException oe){ | 653 | }catch (OrderException oe){ |
@@ -791,7 +792,7 @@ public class OrderServiceImpl implements OrderService { | @@ -791,7 +792,7 @@ public class OrderServiceImpl implements OrderService { | ||
791 | weChatPayTradeDto.setAmount(orderWeChatPayBatch.getTotlePayAmount().multiply(NumberTransform.ONE_HUNDERD).longValue()); | 792 | weChatPayTradeDto.setAmount(orderWeChatPayBatch.getTotlePayAmount().multiply(NumberTransform.ONE_HUNDERD).longValue()); |
792 | weChatPayTradeDto.setMarketId(orderWeChatPayBatch.getMarketId()); | 793 | weChatPayTradeDto.setMarketId(orderWeChatPayBatch.getMarketId()); |
793 | weChatPayTradeDto.setType(orderWeChatPayBatch.getPayType()); | 794 | weChatPayTradeDto.setType(orderWeChatPayBatch.getPayType()); |
794 | - weChatPayTradeDto.setCode(orderWeChatPayBatch.getCode()); | 795 | + //weChatPayTradeDto.setCode(orderWeChatPayBatch.getCode()); |
795 | weChatPayTradeDto.setOutTradeNo(orderWeChatPayBatch.getCodes().get(0)); | 796 | weChatPayTradeDto.setOutTradeNo(orderWeChatPayBatch.getCodes().get(0)); |
796 | weChatPayTradeDto.setGoodsDesc(shop.getName()); | 797 | weChatPayTradeDto.setGoodsDesc(shop.getName()); |
797 | weChatPayTradeDto.setNotifyUrl(OrderConstant.WECHATPAY_BACK_API); | 798 | weChatPayTradeDto.setNotifyUrl(OrderConstant.WECHATPAY_BACK_API); |
@@ -832,7 +833,8 @@ public class OrderServiceImpl implements OrderService { | @@ -832,7 +833,8 @@ public class OrderServiceImpl implements OrderService { | ||
832 | } | 833 | } |
833 | //扣减库存T | 834 | //扣减库存T |
834 | orderGoodsService.deductBatch(orderList,orderWeChatPayBatch.getPayerCustomerId(),orderWeChatPayBatch.getPayerCustomerName()); | 835 | orderGoodsService.deductBatch(orderList,orderWeChatPayBatch.getPayerCustomerId(),orderWeChatPayBatch.getPayerCustomerName()); |
835 | - | 836 | + //更新扣减库存状态 |
837 | + orderMapper.updateDeductState(orderList.stream().map(Order::getId).collect(Collectors.toList())); | ||
836 | //返回数据,由小程序发起微信支付。 | 838 | //返回数据,由小程序发起微信支付。 |
837 | return Message.success(weChatPayTradeBackDto); | 839 | return Message.success(weChatPayTradeBackDto); |
838 | } | 840 | } |
etrade-order/src/main/java/com/diligrp/etrade/order/type/OrderDeductionState.java
0 → 100644
1 | +package com.diligrp.etrade.order.type; | ||
2 | + | ||
3 | +import com.diligrp.etrade.core.type.IEnumType; | ||
4 | + | ||
5 | +/** | ||
6 | + * 操作类型 | ||
7 | + */ | ||
8 | +public enum OrderDeductionState implements IEnumType { | ||
9 | + UN_DEDUCT("未扣减", 1), | ||
10 | + DEDUCT_FINISH("已扣减", 2) | ||
11 | + ; | ||
12 | + | ||
13 | + private String name; | ||
14 | + private Integer code; | ||
15 | + | ||
16 | + private OrderDeductionState(String name, Integer code) { | ||
17 | + this.name = name; | ||
18 | + this.code = code; | ||
19 | + } | ||
20 | + | ||
21 | + public static OrderDeductionState getByCode(Integer code) { | ||
22 | + for (OrderDeductionState temp : OrderDeductionState.values()) { | ||
23 | + if (temp.getCodeInteger().equals(code)) { | ||
24 | + return temp; | ||
25 | + } | ||
26 | + } | ||
27 | + return null; | ||
28 | + } | ||
29 | + | ||
30 | + public static String getNameByCode(Integer code) { | ||
31 | + for (OrderDeductionState temp : OrderDeductionState.values()) { | ||
32 | + if (temp.getCodeInteger().equals(code)) { | ||
33 | + return temp.getName(); | ||
34 | + } | ||
35 | + } | ||
36 | + return null; | ||
37 | + } | ||
38 | + | ||
39 | + public Integer getCodeInteger() { | ||
40 | + return this.code; | ||
41 | + } | ||
42 | + | ||
43 | + public String getName() { | ||
44 | + return this.name; | ||
45 | + } | ||
46 | + | ||
47 | + public int getCode() { | ||
48 | + return this.code; | ||
49 | + } | ||
50 | + | ||
51 | + public String toString() { | ||
52 | + return this.name; | ||
53 | + } | ||
54 | +} | ||
0 | \ No newline at end of file | 55 | \ No newline at end of file |
etrade-order/src/main/resources/com/diligrp/etrade/dao/mapper/order/OrderMapper.xml
@@ -59,6 +59,7 @@ | @@ -59,6 +59,7 @@ | ||
59 | <result column="achieve_address" jdbcType="VARCHAR" property="achieveAddress" /> | 59 | <result column="achieve_address" jdbcType="VARCHAR" property="achieveAddress" /> |
60 | <result column="achieve_state" jdbcType="INTEGER" property="achieveState" /> | 60 | <result column="achieve_state" jdbcType="INTEGER" property="achieveState" /> |
61 | <result column="transport_fee" jdbcType="BIGINT" property="transportFee" /> | 61 | <result column="transport_fee" jdbcType="BIGINT" property="transportFee" /> |
62 | + <result column="stock_deduction_state" jdbcType="BIGINT" property="stockDeductionState" /> | ||
62 | </resultMap> | 63 | </resultMap> |
63 | <sql id="Base_Column_List"> | 64 | <sql id="Base_Column_List"> |
64 | id, code, mapping_code, market_id, buyer_code, buyer_id,buyer_store_customer_id, buyer_name, buyer_account_id, | 65 | id, code, mapping_code, market_id, buyer_code, buyer_id,buyer_store_customer_id, buyer_name, buyer_account_id, |
@@ -68,7 +69,7 @@ | @@ -68,7 +69,7 @@ | ||
68 | pay_time, order_state, `state`, version, creater_id, creater, created_time, modifier_id, | 69 | pay_time, order_state, `state`, version, creater_id, creater, created_time, modifier_id, |
69 | modifier, modified_time, verify_ids, verifier,verify_state, verifier_time, cancel_id, cancel_name, | 70 | modifier, modified_time, verify_ids, verifier,verify_state, verifier_time, cancel_id, cancel_name, |
70 | cancel_time, out_time,`source`,totle_seller_fee,district_id,district_name,sub_district_id,sub_district_name,location | 71 | cancel_time, out_time,`source`,totle_seller_fee,district_id,district_name,sub_district_id,sub_district_name,location |
71 | - ,order_status,relation_id,achieve_type,achieve_address,achieve_state,transport_fee | 72 | + ,order_status,relation_id,achieve_type,achieve_address,achieve_state,transport_fee,stock_deduction_state |
72 | </sql> | 73 | </sql> |
73 | <sql id="Dto_Column_List"> | 74 | <sql id="Dto_Column_List"> |
74 | id, | 75 | id, |
@@ -383,6 +384,15 @@ | @@ -383,6 +384,15 @@ | ||
383 | set order.totle_seller_fee = #{totleSellerFee} | 384 | set order.totle_seller_fee = #{totleSellerFee} |
384 | where id = #{id,jdbcType=BIGINT} | 385 | where id = #{id,jdbcType=BIGINT} |
385 | </update> | 386 | </update> |
387 | + <update id="updateDeductState" parameterType="java.util.List"> | ||
388 | + update `order` | ||
389 | + set order.stock_deduction_state = 2 | ||
390 | + where id in ( | ||
391 | + <foreach collection="ids" item="id" separator=","> | ||
392 | + #{id} | ||
393 | + </foreach> | ||
394 | + ) | ||
395 | + </update> | ||
386 | 396 | ||
387 | <select id="getOrderByCode" resultMap="BaseResultMap"> | 397 | <select id="getOrderByCode" resultMap="BaseResultMap"> |
388 | SELECT | 398 | SELECT |
etrade-rpc/src/main/java/com/diligrp/etrade/rpc/PayRpc.java
@@ -112,4 +112,31 @@ public interface PayRpc { | @@ -112,4 +112,31 @@ public interface PayRpc { | ||
112 | */ | 112 | */ |
113 | @RequestMapping(value = "/wechat/api/gateway.do?service=wechat.payment.service:exists", method = RequestMethod.POST) | 113 | @RequestMapping(value = "/wechat/api/gateway.do?service=wechat.payment.service:exists", method = RequestMethod.POST) |
114 | Message<WeChatPayFunctionBackDto> checkWeChatPayChannel(@RequestBody WeChatPayFunctionDto requestDto, @RequestHeader HttpHeaders headers); | 114 | Message<WeChatPayFunctionBackDto> checkWeChatPayChannel(@RequestBody WeChatPayFunctionDto requestDto, @RequestHeader HttpHeaders headers); |
115 | + | ||
116 | + /** | ||
117 | + * 微信杭州银行支付 | ||
118 | + * @param requestDto | ||
119 | + * @param headers | ||
120 | + * @return | ||
121 | + */ | ||
122 | + @RequestMapping(value = "/wechat/api/gateway.do?service=hzbank.payment.service:prepay", method = RequestMethod.POST) | ||
123 | + Message<WeChatPayTradeBackDto> wechatHgPay(@RequestBody WeChatPayTradeDto requestDto, @RequestHeader HttpHeaders headers); | ||
124 | + | ||
125 | + /** | ||
126 | + * 微信杭州银行预支付关闭 | ||
127 | + * @param requestDto | ||
128 | + * @param headers | ||
129 | + * @return | ||
130 | + */ | ||
131 | + @RequestMapping(value = "/wechat/api/gateway.do?service=hzbank.payment.service:close", method = RequestMethod.POST) | ||
132 | + Message<WeChatPayFunctionBackDto> wechatHgPayClose(@RequestBody WeChatPayFunctionDto requestDto, @RequestHeader HttpHeaders headers); | ||
133 | + | ||
134 | + /** | ||
135 | + * 微信杭州银行预支付状态查询 | ||
136 | + * @param requestDto | ||
137 | + * @param headers | ||
138 | + * @return | ||
139 | + */ | ||
140 | + @RequestMapping(value = "/wechat/api/gateway.do?service=hzbank.payment.service:state", method = RequestMethod.POST) | ||
141 | + Message<WeChatPayFunctionBackDto> wechatHgPayCheckState(@RequestBody WeChatPayFunctionDto requestDto, @RequestHeader HttpHeaders headers); | ||
115 | } | 142 | } |
etrade-rpc/src/main/java/com/diligrp/etrade/rpc/dto/WeChatPayTradeBackDto.java
@@ -40,6 +40,13 @@ public class WeChatPayTradeBackDto { | @@ -40,6 +40,13 @@ public class WeChatPayTradeBackDto { | ||
40 | */ | 40 | */ |
41 | private String paySign; | 41 | private String paySign; |
42 | 42 | ||
43 | + // token | ||
44 | + private String tokenCode; | ||
45 | + // 小程序跳转地址 | ||
46 | + private String tokenCodeUrl; | ||
47 | + // token过期时间 | ||
48 | + private String tokenEnd; | ||
49 | + | ||
43 | 50 | ||
44 | public String getPaymentId() { | 51 | public String getPaymentId() { |
45 | return paymentId; | 52 | return paymentId; |
@@ -96,4 +103,28 @@ public class WeChatPayTradeBackDto { | @@ -96,4 +103,28 @@ public class WeChatPayTradeBackDto { | ||
96 | public void setPaySign(String paySign) { | 103 | public void setPaySign(String paySign) { |
97 | this.paySign = paySign; | 104 | this.paySign = paySign; |
98 | } | 105 | } |
106 | + | ||
107 | + public String getTokenCode() { | ||
108 | + return tokenCode; | ||
109 | + } | ||
110 | + | ||
111 | + public void setTokenCode(String tokenCode) { | ||
112 | + this.tokenCode = tokenCode; | ||
113 | + } | ||
114 | + | ||
115 | + public String getTokenCodeUrl() { | ||
116 | + return tokenCodeUrl; | ||
117 | + } | ||
118 | + | ||
119 | + public void setTokenCodeUrl(String tokenCodeUrl) { | ||
120 | + this.tokenCodeUrl = tokenCodeUrl; | ||
121 | + } | ||
122 | + | ||
123 | + public String getTokenEnd() { | ||
124 | + return tokenEnd; | ||
125 | + } | ||
126 | + | ||
127 | + public void setTokenEnd(String tokenEnd) { | ||
128 | + this.tokenEnd = tokenEnd; | ||
129 | + } | ||
99 | } | 130 | } |
etrade-rpc/src/main/java/com/diligrp/etrade/rpc/dto/WeChatPayTradeDto.java
@@ -13,10 +13,10 @@ import java.util.List; | @@ -13,10 +13,10 @@ import java.util.List; | ||
13 | public class WeChatPayTradeDto { | 13 | public class WeChatPayTradeDto { |
14 | 14 | ||
15 | /** | 15 | /** |
16 | - * 支付方式-JSAPI, NATIVE等 | 16 | + * 支付方式-Cashier |
17 | */ | 17 | */ |
18 | - @NotNull(message = "payType should not be null") | ||
19 | - private String type; | 18 | + |
19 | + private String type = "Cashier"; | ||
20 | /** | 20 | /** |
21 | * 微信商品描述-微信扫码支付时显示-不超过128个字符 | 21 | * 微信商品描述-微信扫码支付时显示-不超过128个字符 |
22 | */ | 22 | */ |
etrade-rpc/src/main/java/com/diligrp/etrade/rpc/resolver/WeChatPayRpcResolver.java
@@ -58,21 +58,13 @@ public class WeChatPayRpcResolver { | @@ -58,21 +58,13 @@ public class WeChatPayRpcResolver { | ||
58 | public Message<WeChatPayTradeBackDto> createWeChatPayTrade(WeChatPayTradeDto weChatPayTradeDto){ | 58 | public Message<WeChatPayTradeBackDto> createWeChatPayTrade(WeChatPayTradeDto weChatPayTradeDto){ |
59 | //创建提交单 | 59 | //创建提交单 |
60 | weChatPayTradeDto.setNotifyUrl(backBaseUrl+weChatPayTradeDto.getNotifyUrl()); | 60 | weChatPayTradeDto.setNotifyUrl(backBaseUrl+weChatPayTradeDto.getNotifyUrl()); |
61 | + weChatPayTradeDto.setType("Cashier"); | ||
61 | weChatPayTradeDto.setDescription(weChatPayTradeDto.getDescription()==null?"电子交易结算":weChatPayTradeDto.getDescription()); | 62 | weChatPayTradeDto.setDescription(weChatPayTradeDto.getDescription()==null?"电子交易结算":weChatPayTradeDto.getDescription()); |
62 | //组装headers | 63 | //组装headers |
63 | HttpHeaders prepareHeaders = creatHeader(weChatPayTradeDto.getMarketId().toString(),PAY_STATE_PREPARE); | 64 | HttpHeaders prepareHeaders = creatHeader(weChatPayTradeDto.getMarketId().toString(),PAY_STATE_PREPARE); |
64 | - //临时代码 TODO | ||
65 | - WeChatPayTradeBackDto backDto = new WeChatPayTradeBackDto(); | ||
66 | - backDto.setPaymentId(new Snowflake().nextIdStr()); | ||
67 | - backDto.setPaySign("PaySign"); | ||
68 | - backDto.setCodeUrl("codeUrl"); | ||
69 | - backDto.setSignType("SignType"); | ||
70 | - backDto.setPacket("packet"); | ||
71 | - backDto.setNonceStr("NonceStr"); | ||
72 | - Message<WeChatPayTradeBackDto> prepareJsonObject = Message.success(backDto); | ||
73 | - //Message<WeChatPayTradeBackDto> prepareJsonObject = payRpc.wechatPay(weChatPayTradeDto, prepareHeaders); | 65 | + Message<WeChatPayTradeBackDto> prepareJsonObject = payRpc.wechatHgPay(weChatPayTradeDto, prepareHeaders); |
74 | if(!prepareJsonObject.getCode().equals(200)){ | 66 | if(!prepareJsonObject.getCode().equals(200)){ |
75 | - log.info("创建交易入参{},请求体头部为{},请求结果为{}",prepareHeaders,prepareHeaders,prepareJsonObject); | 67 | + log.info("创建交易入参{},请求体头部为{},请求结果为{}",weChatPayTradeDto,prepareHeaders,prepareJsonObject); |
76 | throw new PlatformServiceException(ErrorCode.SYSTEM_UNKNOWN_ERROR, "创建交易信息失败:" + prepareJsonObject.getMessage()); | 68 | throw new PlatformServiceException(ErrorCode.SYSTEM_UNKNOWN_ERROR, "创建交易信息失败:" + prepareJsonObject.getMessage()); |
77 | }else { | 69 | }else { |
78 | return prepareJsonObject; | 70 | return prepareJsonObject; |
@@ -87,14 +79,7 @@ public class WeChatPayRpcResolver { | @@ -87,14 +79,7 @@ public class WeChatPayRpcResolver { | ||
87 | public Message<WeChatPayFunctionBackDto> checkWeChatPayState(WeChatPayFunctionDto weChatPayFunctionDto){ | 79 | public Message<WeChatPayFunctionBackDto> checkWeChatPayState(WeChatPayFunctionDto weChatPayFunctionDto){ |
88 | //组装headers | 80 | //组装headers |
89 | HttpHeaders prepareHeaders = creatHeader(weChatPayFunctionDto.getMarketId().toString(), PAY_STATE_CHECK); | 81 | HttpHeaders prepareHeaders = creatHeader(weChatPayFunctionDto.getMarketId().toString(), PAY_STATE_CHECK); |
90 | - //临时代码 TODO | ||
91 | - WeChatPayFunctionBackDto weChatPayFunctionBackDto = new WeChatPayFunctionBackDto(); | ||
92 | - weChatPayFunctionBackDto.setState(WeChatPayState.SUCCESS.getCode()); | ||
93 | - weChatPayFunctionBackDto.setPaymentId(weChatPayFunctionBackDto.getPaymentId()); | ||
94 | - weChatPayFunctionBackDto.setWhen(LocalDateTime.now()); | ||
95 | - weChatPayFunctionBackDto.setStateCode("101"); | ||
96 | - Message<WeChatPayFunctionBackDto> cancelJsonObject = Message.success(weChatPayFunctionBackDto); | ||
97 | - //Message<WeChatPayFunctionBackDto> cancelJsonObject = payRpc.wechatPayCheckState(weChatPayFunctionDto, prepareHeaders); | 82 | + Message<WeChatPayFunctionBackDto> cancelJsonObject = payRpc.wechatHgPayCheckState(weChatPayFunctionDto, prepareHeaders); |
98 | 83 | ||
99 | if(!cancelJsonObject.getCode().equals(200)){ | 84 | if(!cancelJsonObject.getCode().equals(200)){ |
100 | log.info("撤销交易入参{},请求体头部为{},请求结果为{}",weChatPayFunctionDto,prepareHeaders,cancelJsonObject); | 85 | log.info("撤销交易入参{},请求体头部为{},请求结果为{}",weChatPayFunctionDto,prepareHeaders,cancelJsonObject); |
@@ -110,17 +95,15 @@ public class WeChatPayRpcResolver { | @@ -110,17 +95,15 @@ public class WeChatPayRpcResolver { | ||
110 | * @return true 关闭成功 | 95 | * @return true 关闭成功 |
111 | */ | 96 | */ |
112 | public Boolean closeWeChatPay(WeChatPayFunctionDto weChatPayFunctionDto){ | 97 | public Boolean closeWeChatPay(WeChatPayFunctionDto weChatPayFunctionDto){ |
113 | - //临时代码 TODO | ||
114 | - return true; | ||
115 | //组装headers | 98 | //组装headers |
116 | -// HttpHeaders prepareHeaders = creatHeader(weChatPayFunctionDto.getMarketId().toString(), PAY_STATE_CLOSE); | ||
117 | -// Message<WeChatPayFunctionBackDto> cancelJsonObject = payRpc.wechatPayClose(weChatPayFunctionDto, prepareHeaders); | ||
118 | -// if(!cancelJsonObject.getCode().equals(200)){ | ||
119 | -// log.info("关闭微信支付订单入参{},请求体头部为{},请求结果为{}",weChatPayFunctionDto,prepareHeaders,cancelJsonObject); | ||
120 | -// throw new PlatformServiceException(ErrorCode.SYSTEM_UNKNOWN_ERROR, "关闭微信支付订单失败:" + cancelJsonObject.getMessage()); | ||
121 | -// }else { | ||
122 | -// return true; | ||
123 | -// } | 99 | + HttpHeaders prepareHeaders = creatHeader(weChatPayFunctionDto.getMarketId().toString(), PAY_STATE_CLOSE); |
100 | + Message<WeChatPayFunctionBackDto> cancelJsonObject = payRpc.wechatHgPayClose(weChatPayFunctionDto, prepareHeaders); | ||
101 | + if(!cancelJsonObject.getCode().equals(200)){ | ||
102 | + log.info("关闭微信支付订单入参{},请求体头部为{},请求结果为{}",weChatPayFunctionDto,prepareHeaders,cancelJsonObject); | ||
103 | + throw new PlatformServiceException(ErrorCode.SYSTEM_UNKNOWN_ERROR, "关闭微信支付订单失败:" + cancelJsonObject.getMessage()); | ||
104 | + }else { | ||
105 | + return true; | ||
106 | + } | ||
124 | } | 107 | } |
125 | 108 | ||
126 | // /** | 109 | // /** |