From cf5c4179a66d322e433fc6ba4df210b413355138 Mon Sep 17 00:00:00 2001 From: tangqian Date: Thu, 18 May 2023 16:35:54 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=BE=AE=E4=BF=A1=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E6=94=AF=E4=BB=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/buy/TopUpOrderController.java | 23 +++++--- .../shop/service/order/StoreOrderService.java | 2 + .../order/impl/StoreOrderServiceImpl.java | 24 ++++++-- .../shop/support/pay/AliPayStrategy.java | 4 +- .../shop/support/pay/WxPayStrategy.java | 1 + .../src/main/resources/1/apiclient_cert.p12 | Bin 2798 -> 2774 bytes .../src/main/resources/1/apiclient_cert.pem | 42 +++++++------- .../src/main/resources/1/apiclient_key.pem | 52 +++++++++--------- .../src/main/resources/application-local.yaml | 20 +++---- 9 files changed, 95 insertions(+), 73 deletions(-) diff --git a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/app/buy/TopUpOrderController.java b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/app/buy/TopUpOrderController.java index 8db055756..9e1dad4cd 100644 --- a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/app/buy/TopUpOrderController.java +++ b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/app/buy/TopUpOrderController.java @@ -1,6 +1,7 @@ package cn.iocoder.yudao.module.shop.controller.app.buy; import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated; import cn.iocoder.yudao.module.shop.request.member.OrderContentRequest; import cn.iocoder.yudao.module.shop.request.member.RefundRequest; import cn.iocoder.yudao.module.shop.response.member.InitOrderResponse; @@ -9,11 +10,9 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; +import javax.annotation.security.PermitAll; import javax.servlet.http.HttpServletRequest; import javax.validation.Valid; @@ -32,22 +31,21 @@ public class TopUpOrderController { @Autowired private StoreOrderService storeOrderService; - + @PreAuthenticated @Operation(summary = "会员充值") @RequestMapping(value = "/memberTopUp", method = RequestMethod.POST) public CommonResult memberTopUp(@Valid @RequestBody OrderContentRequest request, HttpServletRequest servletRequest) throws Exception { log.info("initOrder会员充值===>{}", request); return CommonResult.success(storeOrderService.memberTopUp(request, servletRequest)); } - + @PreAuthenticated @Operation(summary = "退款") @RequestMapping(value = "/memberRefund", method = RequestMethod.POST) public CommonResult memberRefund(@Valid @RequestBody RefundRequest request, HttpServletRequest servletRequest) throws Exception { log.info("memberRefund会员退款===>{}", request); return CommonResult.success(storeOrderService.memberRefund(request, servletRequest)); } - - + @PreAuthenticated @Operation(summary = "申请退款") @RequestMapping(value = "/memberApplyRefund", method = RequestMethod.POST) public CommonResult memberApplyRefund(@Valid @RequestBody RefundRequest request){ @@ -55,4 +53,13 @@ public class TopUpOrderController { return CommonResult.success(storeOrderService.memberApplyRefund(request)); } + + @PermitAll + @Operation(summary = "获取openid") + @RequestMapping(value = "/getOpenId", method = RequestMethod.GET) + public CommonResult getOpenId(@RequestParam(value = "code") String code){ + log.info("获取openid===>{}", code); + return CommonResult.success(storeOrderService.getOpenId(code)); + } + } diff --git a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/order/StoreOrderService.java b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/order/StoreOrderService.java index 295f253ad..c14a08a89 100644 --- a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/order/StoreOrderService.java +++ b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/order/StoreOrderService.java @@ -403,4 +403,6 @@ public interface StoreOrderService extends IService { Boolean wxPayNotify(WxPayOrderNotifyV3Result.DecryptNotifyResult result); Boolean memberApplyRefund(RefundRequest request); + + String getOpenId(String code); } diff --git a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/order/impl/StoreOrderServiceImpl.java b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/order/impl/StoreOrderServiceImpl.java index 6af19f45a..ebe288fc5 100644 --- a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/order/impl/StoreOrderServiceImpl.java +++ b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/order/impl/StoreOrderServiceImpl.java @@ -46,7 +46,6 @@ import cn.iocoder.yudao.module.shop.utils.RedisUtil; import cn.iocoder.yudao.module.shop.vo.order.LogisticsResultVo; import cn.iocoder.yudao.module.shop.vo.order.StoreDateRangeSqlPram; import cn.iocoder.yudao.module.shop.vo.order.StoreOrderInfoOldVo; -import cn.iocoder.yudao.module.shop.vo.product.MyRecord; import com.alipay.api.AlipayApiException; import com.alipay.api.internal.util.AlipaySignature; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; @@ -59,6 +58,10 @@ import com.github.pagehelper.Page; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import lombok.extern.slf4j.Slf4j; +import me.chanjar.weixin.common.bean.oauth2.WxOAuth2AccessToken; +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.common.service.WxOAuth2Service; +import me.chanjar.weixin.mp.api.WxMpService; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -130,12 +133,9 @@ public class StoreOrderServiceImpl extends ServiceImpl 0; } + @Override + public String getOpenId(String code) { + WxOAuth2AccessToken accessToken = null; + try { + accessToken = wxMpService.getOAuth2Service().getAccessToken(code); + return accessToken.getOpenId(); + } catch (WxErrorException e) { + e.printStackTrace(); + } + return null; + } + private RechargeOrderDO initializeOrder(OrderContentRequest request, String code, MemberUserRespDTO user) { RechargeOrderDO orderDO = new RechargeOrderDO(); diff --git a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/support/pay/AliPayStrategy.java b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/support/pay/AliPayStrategy.java index 43143873d..e8992adf6 100644 --- a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/support/pay/AliPayStrategy.java +++ b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/support/pay/AliPayStrategy.java @@ -52,11 +52,11 @@ public class AliPayStrategy implements IPayStrategy { bizContent.put("total_amount", orderDO.getPayPrice()); //订单标题,不可使用特殊符号 bizContent.put("subject", "会员充值"); - bizContent.put("product_code", "FAST_INSTANT_TRADE_PAY"); + bizContent.put("product_code", "QUICK_WAP_WAY"); request.setBizContent(bizContent.toString()); AlipayTradeWapPayResponse response = null; try { - response = alipayClient.pageExecute(request); + response = alipayClient.pageExecute(request,"get"); orderResponse.setBody(response.getBody()); } catch (AlipayApiException e) { e.printStackTrace(); diff --git a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/support/pay/WxPayStrategy.java b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/support/pay/WxPayStrategy.java index 790a70c2a..1e95a8279 100644 --- a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/support/pay/WxPayStrategy.java +++ b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/support/pay/WxPayStrategy.java @@ -36,6 +36,7 @@ public class WxPayStrategy implements IPayStrategy{ private WxPayOneAutoConfiguration wxPayOneAutoConfiguration; @Autowired private WxPayProperties payProperties; + @Override public InitOrderResponse pay(RechargeOrderDO orderDO, HttpServletRequest servletRequest,String openid) { InitOrderResponse response = new InitOrderResponse(); diff --git a/yudao-server/src/main/resources/1/apiclient_cert.p12 b/yudao-server/src/main/resources/1/apiclient_cert.p12 index 68aaa88cda12faa117b44ed5e5396d59591a2060..c63d0f08feaf5e2f3015778807ee12719821b454 100644 GIT binary patch delta 2643 zcmV-Z3as_+71k9%FoFuw0s#Xsf(o1l2`Yw2hW8Bt2LYgh3XKGU3W+d+3WYF&1qTKR zDuzgg_YDCD2B3lj_%MP5^a23@FoFc_kw6`PJ_y}j)rw8#0s;sCfPw_TeWLVn`*Z5o z!5w#SQY!Xyd*!4(SHLHy%l$p)Ctq~z7?_njzGjJj%TyOlA~m*_6^E6I-c>Zp{cOY`%n~wx z22X1%K#-#dspX?q)Px$R!UvotCe*t|_H;*tJEjF(7pW;ME#D7X43hfHVM)PW)|J?< zgHFrhVs&P&4-GBouw`LGZ2y|R%EqA_#wbz-?4jY@BicqX7=`55tCGHG>$FfdDwnxR z%(q~ilag|MMEqFnu%34kYf6K{7D&f`xT?#f5u)d6swD*c8Z3Uz70E?E#7EwpQsW3P zv|g8!?@G50mIPY};A=QNfVBpQ1L2)y zh)sqyX@$pbfga;vr{}$t(>Ywu-?|7Sonb3N=91qfxnVbd;U(vT zC2z000s;XQrE((JjRTCd_*bR{X2Dwk9(Dh+hu%VueO5q|S}%|Ww2xj^7< zfWju9fcPFw4x`reP!4ihKA7fz`?-9tgc{|D2b#0CqJRmsRB7ZOVP&&+55#BhqR7AU zY`Iny(+h3H6Be)gk14f@kykJ$^mS5dfmf~oOS-18_aD9{Ke9f4<^f>1IoW0mwuC^( zr?2RM-d&7#jl@>#auco}>>R6d3%`({_-JR2-R1Y7soIkV!&CZU36Nrc)LQfA22t+3 zcbAieiy~SWOVLlmcP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