|
@@ -5,12 +5,6 @@ import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest;
|
|
|
import com.github.binarywang.wxpay.constant.WxPayConstants;
|
|
|
import com.github.binarywang.wxpay.exception.WxPayException;
|
|
|
import com.github.binarywang.wxpay.service.WxPayService;
|
|
|
-import com.hcloud.microserver.h5.biz.WechatManagerComponent;
|
|
|
-import com.hcloud.microserver.h5.common.BaseInfoDO;
|
|
|
-import com.hcloud.microserver.h5.common.CarbonBaseController;
|
|
|
-import com.hcloud.microserver.h5.config.WxMpConfiguration;
|
|
|
-import com.hcloud.microserver.h5.service.OrderInfoService;
|
|
|
-import com.hcloud.microserver.h5.service.OrderPayService;
|
|
|
import com.hcloud.microserver.commoncore.annotation.AuthCarbonValidate;
|
|
|
import com.hcloud.microserver.commoncore.base.ResponseBase;
|
|
|
import com.hcloud.microserver.commoncore.base.ResultVO;
|
|
@@ -23,6 +17,11 @@ import com.hcloud.microserver.commoncore.util.UUIDUtils;
|
|
|
import com.hcloud.microserver.facade.carbon.forms.CustomerInfoForm;
|
|
|
import com.hcloud.microserver.facade.carbon.forms.GoodsOrderInfoForm;
|
|
|
import com.hcloud.microserver.facade.carbon.forms.GoodsPayOrderForm;
|
|
|
+import com.hcloud.microserver.h5.biz.WechatManagerComponent;
|
|
|
+import com.hcloud.microserver.h5.common.BaseInfoDO;
|
|
|
+import com.hcloud.microserver.h5.common.CarbonBaseController;
|
|
|
+import com.hcloud.microserver.h5.service.OrderInfoService;
|
|
|
+import com.hcloud.microserver.h5.service.OrderPayService;
|
|
|
import io.swagger.annotations.*;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import me.chanjar.weixin.common.bean.WxJsapiSignature;
|
|
@@ -30,7 +29,6 @@ import me.chanjar.weixin.common.error.WxErrorException;
|
|
|
import me.chanjar.weixin.common.util.http.URIUtil;
|
|
|
import me.chanjar.weixin.mp.api.WxMpService;
|
|
|
import me.chanjar.weixin.mp.api.WxMpUserService;
|
|
|
-import me.chanjar.weixin.mp.bean.result.WxMpOAuth2AccessToken;
|
|
|
import me.chanjar.weixin.mp.bean.result.WxMpUser;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
@@ -55,15 +53,15 @@ import java.util.concurrent.TimeUnit;
|
|
|
@Api(description = "H5微信api服务")
|
|
|
public class WechatManagerController extends CarbonBaseController {
|
|
|
|
|
|
- private static final String WECHAT_AUTH_SCOPE="snsapi_userinfo";
|
|
|
+ private static final String WECHAT_AUTH_SCOPE = "snsapi_userinfo";
|
|
|
|
|
|
- private static final String WECHAT_AUTH_BASE_SCOPE="snsapi_base";
|
|
|
+ private static final String WECHAT_AUTH_BASE_SCOPE = "snsapi_base";
|
|
|
|
|
|
- private static final String WECHAT_USER_INFO="wechatUserInfo";
|
|
|
+ private static final String WECHAT_USER_INFO = "wechatUserInfo";
|
|
|
|
|
|
- private static final String WECHAT_PAY_FLAG_TEST="test";
|
|
|
+ private static final String WECHAT_PAY_FLAG_TEST = "test";
|
|
|
|
|
|
- private static final String WECHAT_INFO_PREFIX="weChatInfoPrefix_";
|
|
|
+ private static final String WECHAT_INFO_PREFIX = "weChatInfoPrefix_";
|
|
|
|
|
|
@Value("${wx.mp.appId}")
|
|
|
private String appid;
|
|
@@ -95,82 +93,79 @@ public class WechatManagerController extends CarbonBaseController {
|
|
|
private WxPayService wxPayService;
|
|
|
|
|
|
@Autowired
|
|
|
- private OrderInfoService orderClient;
|
|
|
+ private OrderInfoService orderInfoService;
|
|
|
|
|
|
@Autowired
|
|
|
- private OrderPayService orderPayClient;
|
|
|
+ private OrderPayService orderPayService;
|
|
|
|
|
|
@Autowired
|
|
|
private RedisUtils redisUtils;
|
|
|
|
|
|
- @ApiOperation(value = "微信登录",notes = "微信登录")
|
|
|
+ @ApiOperation(value = "微信登录", notes = "微信登录")
|
|
|
@ApiImplicitParams({
|
|
|
- @ApiImplicitParam(name = "furl",value = "授权成功后的", dataType = "String",paramType = "query"),
|
|
|
- @ApiImplicitParam(name = "authScope",value = "授权范围", dataType = "Integer",paramType = "query"),
|
|
|
- @ApiImplicitParam(name = "token",value = "当前用户token", dataType = "String",paramType = "query")
|
|
|
+ @ApiImplicitParam(name = "furl", value = "授权成功后的", dataType = "String", paramType = "query"),
|
|
|
+ @ApiImplicitParam(name = "authScope", value = "授权范围", dataType = "Integer", paramType = "query"),
|
|
|
+ @ApiImplicitParam(name = "token", value = "当前用户token", dataType = "String", paramType = "query")
|
|
|
})
|
|
|
- @ApiResponse(code =0,message = "查询成功")
|
|
|
+ @ApiResponse(code = 0, message = "查询成功")
|
|
|
@GetMapping("/login")
|
|
|
- @AuthCarbonValidate
|
|
|
+ @AuthCarbonValidate
|
|
|
public void login(@RequestParam("furl") String furl,
|
|
|
Integer authScope,
|
|
|
- String token){
|
|
|
- if(null!=furl && !"".equals(weChatForwardUrl)){
|
|
|
+ String token) {
|
|
|
+ if (null != furl && !"".equals(weChatForwardUrl)) {
|
|
|
weChatForwardUrl = furl;
|
|
|
}
|
|
|
- if(Objects.nonNull(token)){
|
|
|
+ if (Objects.nonNull(token)) {
|
|
|
BaseInfoDO baseInfoDO = this.initiSaveObject(token);
|
|
|
- if(Objects.nonNull(baseInfoDO)){
|
|
|
+ if (Objects.nonNull(baseInfoDO)) {
|
|
|
//登录失效跳转登录首页
|
|
|
- currentCustomerId=baseInfoDO.getCustomerId();
|
|
|
- }
|
|
|
+ currentCustomerId = baseInfoDO.getCustomerId();
|
|
|
+ }
|
|
|
globalToken = token;
|
|
|
|
|
|
}
|
|
|
- log.info("currentCustomerId is ================>{}",currentCustomerId);
|
|
|
- final WxMpService wxMpService = WxMpConfiguration.getMpServices().get(appid);
|
|
|
+ log.info("currentCustomerId is ================>{}", currentCustomerId);
|
|
|
String authUrls = "";
|
|
|
- if(authScope==2){
|
|
|
- authUrls= wxMpService.getOAuth2Service().buildAuthorizationUrl(weChatBaseUrl,WECHAT_AUTH_BASE_SCOPE, URIUtil.encodeURIComponent(weChatForwardUrl));
|
|
|
- }else{
|
|
|
- authUrls= wxMpService.getOAuth2Service().buildAuthorizationUrl(wechatRedirectUrl,WECHAT_AUTH_SCOPE, URIUtil.encodeURIComponent(weChatForwardUrl));
|
|
|
+ if (authScope == 2) {
|
|
|
+ authUrls = wxMpService.oauth2buildAuthorizationUrl(weChatBaseUrl, WECHAT_AUTH_BASE_SCOPE, URIUtil.encodeURIComponent(weChatForwardUrl));
|
|
|
+ } else {
|
|
|
+ authUrls = wxMpService.oauth2buildAuthorizationUrl(wechatRedirectUrl, WECHAT_AUTH_SCOPE, URIUtil.encodeURIComponent(weChatForwardUrl));
|
|
|
}
|
|
|
try {
|
|
|
- log.info("authUrls===============>{}",authUrls);
|
|
|
+ log.info("authUrls===============>{}", authUrls);
|
|
|
this.getResponseObject().sendRedirect(authUrls);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
- log.error("请求微信权限地址错误请检查配置参数,配置的url:{}",authUrls);
|
|
|
+ log.error("请求微信权限地址错误请检查配置参数,配置的url:{}", authUrls);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- @ApiOperation(value = "获取微信用户基本信息",notes = "微信静默授权接口请勿随意调用")
|
|
|
- @ApiResponse(code =500,message = "请求的配置参数有问题")
|
|
|
+ @ApiOperation(value = "获取微信用户基本信息", notes = "微信静默授权接口请勿随意调用")
|
|
|
+ @ApiResponse(code = 500, message = "请求的配置参数有问题")
|
|
|
@GetMapping("/baseLogin")
|
|
|
@AuthCarbonValidate
|
|
|
- public void baseLogin(@RequestParam("code") String code){
|
|
|
- log.info("currentCustomerId======================>{}",currentCustomerId);
|
|
|
- log.info("global token==========================>{}",globalToken);
|
|
|
- if(null!=code && !"".equals(code)){
|
|
|
- log.info("微信权限认证code是====================>{}",code);
|
|
|
- final WxMpService wxMpService = WxMpConfiguration.getMpServices().get(appid);
|
|
|
+ public void baseLogin(@RequestParam("code") String code) {
|
|
|
+ log.info("currentCustomerId======================>{}", currentCustomerId);
|
|
|
+ log.info("global token==========================>{}", globalToken);
|
|
|
+ if (null != code && !"".equals(code)) {
|
|
|
+ log.info("微信权限认证code是====================>{}", code);
|
|
|
try {
|
|
|
-
|
|
|
- WxMpOAuth2AccessToken accessToken = wxMpService.getOAuth2Service().getAccessToken(code);
|
|
|
+ String accessToken = wxMpService.getAccessToken();
|
|
|
// WxMpOAuth2AccessToken accessToken = wxMpService.oauth2getAccessToken(code);
|
|
|
- if(accessToken!=null ){
|
|
|
- log.info("accessToken object is:{}",accessToken);
|
|
|
+ if (accessToken != null) {
|
|
|
+ log.info("accessToken object is:{}", accessToken);
|
|
|
WxMpUserService userService = wxMpService.getUserService();
|
|
|
- WxMpUser wxMpUser = userService.userInfo(accessToken.getAccessToken());
|
|
|
+ WxMpUser wxMpUser = userService.userInfo(accessToken);
|
|
|
// WxMpUser wxMpUser = wxMpService.oauth2getUserInfo(accessToken,"");
|
|
|
- log.info("wxMpUser object is:{}",wxMpUser);
|
|
|
- if(null!=currentCustomerId && !"".equals(currentCustomerId)){
|
|
|
+ log.info("wxMpUser object is:{}", wxMpUser);
|
|
|
+ if (null != currentCustomerId && !"".equals(currentCustomerId)) {
|
|
|
//微信授权信息写入登录缓存用户微信支付
|
|
|
Map resultMap = (Map) redisUtils.getValue(globalToken);
|
|
|
- if(Objects.nonNull(resultMap)){
|
|
|
- resultMap.put(GlobleConstant.WECHAT_INFO_PREFIX,wxMpUser);
|
|
|
+ if (Objects.nonNull(resultMap)) {
|
|
|
+ resultMap.put(GlobleConstant.WECHAT_INFO_PREFIX, wxMpUser);
|
|
|
}
|
|
|
- redisUtils.setValue(globalToken,resultMap, GlobleConstant.TOKEN_EXPIRES_SECOND,TimeUnit.SECONDS);
|
|
|
+ redisUtils.setValue(globalToken, resultMap, GlobleConstant.TOKEN_EXPIRES_SECOND, TimeUnit.SECONDS);
|
|
|
}
|
|
|
this.getResponseObject().sendRedirect(weChatForwardUrl);
|
|
|
}
|
|
@@ -181,31 +176,30 @@ public class WechatManagerController extends CarbonBaseController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- @ApiOperation(value = "获取微信用户信息",notes = "微信回调接口请勿直接请求")
|
|
|
- @ApiResponse(code =500,message = "请求的配置参数有问题")
|
|
|
+ @ApiOperation(value = "获取微信用户信息", notes = "微信回调接口请勿直接请求")
|
|
|
+ @ApiResponse(code = 500, message = "请求的配置参数有问题")
|
|
|
@GetMapping("/doLogin")
|
|
|
@AuthCarbonValidate
|
|
|
- public void doLogin(@RequestParam("code") String code){
|
|
|
- if(null!=code && !"".equals(code)){
|
|
|
- log.info("微信权限认证code是====================>{}",code);
|
|
|
- final WxMpService wxMpService = WxMpConfiguration.getMpServices().get(appid);
|
|
|
+ public void doLogin(@RequestParam("code") String code) {
|
|
|
+ if (null != code && !"".equals(code)) {
|
|
|
+ log.info("微信权限认证code是====================>{}", code);
|
|
|
try {
|
|
|
- WxMpOAuth2AccessToken accessToken = wxMpService.getOAuth2Service().getAccessToken(code);
|
|
|
+ String accessToken = wxMpService.getAccessToken();
|
|
|
// WxMpOAuth2AccessToken accessToken = wxMpService.oauth2getAccessToken(code);
|
|
|
- if(accessToken!=null ){
|
|
|
- log.info("accessToken object is:{}",accessToken);
|
|
|
+ if (accessToken != null) {
|
|
|
+ log.info("accessToken object is:{}", accessToken);
|
|
|
WxMpUserService userService = wxMpService.getUserService();
|
|
|
- WxMpUser wxMpUser = userService.userInfo(accessToken.getAccessToken());
|
|
|
+ WxMpUser wxMpUser = userService.userInfo(accessToken);
|
|
|
// WxMpUser wxMpUser = wxMpService.oauth2getUserInfo(accessToken,"");
|
|
|
- log.info("wxMpUser object is:{}",wxMpUser);
|
|
|
- Map map = weChatManager.getWechatAccessToken(wxMpUser);
|
|
|
- if(null!=map && map.size()>0){
|
|
|
- String token = (String) map.get(GlobleConstant.ACCESS_TOKEN);
|
|
|
- log.info("redirectUrl======================>{}",weChatForwardUrl+"?accessToken="+token);
|
|
|
- this.getResponseObject().sendRedirect(weChatForwardUrl+"?accessToken="+token);
|
|
|
- }else {
|
|
|
- this.getResponseObject().sendRedirect(weChatForwardUrl);
|
|
|
- }
|
|
|
+ log.info("wxMpUser object is:{}", wxMpUser);
|
|
|
+ Map map = weChatManager.getWechatAccessToken(wxMpUser);
|
|
|
+ if (null != map && map.size() > 0) {
|
|
|
+ String token = (String) map.get(GlobleConstant.ACCESS_TOKEN);
|
|
|
+ log.info("redirectUrl======================>{}", weChatForwardUrl + "?accessToken=" + token);
|
|
|
+ this.getResponseObject().sendRedirect(weChatForwardUrl + "?accessToken=" + token);
|
|
|
+ } else {
|
|
|
+ this.getResponseObject().sendRedirect(weChatForwardUrl);
|
|
|
+ }
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
log.error("微信参数错误,请查看参数配置谢谢");
|
|
@@ -214,40 +208,40 @@ public class WechatManagerController extends CarbonBaseController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- @ApiOperation(value = "退出登录",notes = "退出登录,删除缓存信息")
|
|
|
- @ApiResponse(code =500,message = "请求的配置参数有问题")
|
|
|
+ @ApiOperation(value = "退出登录", notes = "退出登录,删除缓存信息")
|
|
|
+ @ApiResponse(code = 500, message = "请求的配置参数有问题")
|
|
|
@GetMapping("/logout")
|
|
|
@AuthCarbonValidate
|
|
|
- public ResponseBase logout(){
|
|
|
+ public ResponseBase logout() {
|
|
|
BaseInfoDO baseInfoDO = this.initiSaveObject();
|
|
|
- if(baseInfoDO==null){responseError(new ResultVO(ResultEnum.TOKEN_EXPIRED));}
|
|
|
+ if (baseInfoDO == null) {
|
|
|
+ responseError(new ResultVO(ResultEnum.TOKEN_EXPIRED));
|
|
|
+ }
|
|
|
String accessToken = this.getRequestObject().getHeader(ACCESS_TOKEN);
|
|
|
redisUtils.deleteKey(accessToken);
|
|
|
return responseSuccess(new ResultVO(ResultEnum.SUCCESS));
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
- @ApiOperation(value = "微信支付接口(二次支付)",notes = "微信支付接口请勿随意调用(二次支付)")
|
|
|
+ @ApiOperation(value = "微信支付接口(二次支付)", notes = "微信支付接口请勿随意调用(二次支付)")
|
|
|
@ApiImplicitParams({
|
|
|
- @ApiImplicitParam(name = "orderId",value = "订单编号", dataType = "String",paramType = "query"),
|
|
|
- @ApiImplicitParam(name = "tradeType",value = "交易方式(NATIVE,APP,JSAPI,MWEB)", dataType = "String",paramType = "query")
|
|
|
+ @ApiImplicitParam(name = "orderId", value = "订单编号", dataType = "String", paramType = "query"),
|
|
|
+ @ApiImplicitParam(name = "tradeType", value = "交易方式(NATIVE,APP,JSAPI,MWEB)", dataType = "String", paramType = "query")
|
|
|
})
|
|
|
- @ApiResponse(code =500,message = "请求的配置参数有问题")
|
|
|
+ @ApiResponse(code = 500, message = "请求的配置参数有问题")
|
|
|
@AuthCarbonValidate
|
|
|
@GetMapping("/pay")
|
|
|
public ResponseBase pay(@RequestParam("orderId") String orderId,
|
|
|
- @RequestParam("tradeType") String tradeType){
|
|
|
+ @RequestParam("tradeType") String tradeType) {
|
|
|
try {
|
|
|
BaseInfoDO baseInfoDO = this.initiSaveObject();
|
|
|
WxMpUser wxMpUser = this.initiWwChatInfo();
|
|
|
- if(Objects.isNull(baseInfoDO)){
|
|
|
+ if (Objects.isNull(baseInfoDO)) {
|
|
|
return responseError(new ResultVO(ResultEnum.TOKEN_EXPIRED));
|
|
|
}
|
|
|
//验证商品订单是否已经支付
|
|
|
- GoodsOrderInfoForm orderInfoById = orderClient.getOrderInfoById(orderId);
|
|
|
- if(orderInfoById==null){
|
|
|
+ GoodsOrderInfoForm orderInfoById = orderInfoService.getOrderInfoById(orderId);
|
|
|
+ if (orderInfoById == null) {
|
|
|
return responseEnum(ResultEnum.ORDER_PAY_DUPLICATE);
|
|
|
}
|
|
|
// Map orderInfoMap = (Map) resultVO.getData();
|
|
@@ -255,38 +249,40 @@ public class WechatManagerController extends CarbonBaseController {
|
|
|
// Double payMoney = (Double) orderInfoMap.get("orderAmount");
|
|
|
// Double orderCarbonAmount = (Double) orderInfoMap.get("orderCarbonAmount");
|
|
|
// JavaBeanUtils.mapToEntity(orderInfoMap, GoodsOrderInfoForm.class);
|
|
|
- GoodsOrderInfoForm orderInfoForm = orderInfoById;
|
|
|
+ GoodsOrderInfoForm orderInfoForm = orderInfoById;
|
|
|
Double payMoney = Double.valueOf(orderInfoById.getOrderAmount().toString());
|
|
|
Double orderCarbonAmount = Double.valueOf(orderInfoById.getOrderCarbonAmount().toString());
|
|
|
- log.info("orderInfo===================>{}",orderInfoForm);
|
|
|
- if(orderInfoForm.getOrderStatus()!=1){
|
|
|
+ log.info("orderInfo===================>{}", orderInfoForm);
|
|
|
+ if (orderInfoForm.getOrderStatus() != 1) {
|
|
|
return responseError(new ResultVO(ResultEnum.ORDER_PAY_COMPLETE));
|
|
|
}
|
|
|
CustomerInfoForm customerInfoForm = weChatManager.getCustomerInfoByCustomerId(orderInfoForm.getFkCustomerGuid());
|
|
|
- log.info("customerInfo=======================>{}",customerInfoForm);
|
|
|
+ log.info("customerInfo=======================>{}", customerInfoForm);
|
|
|
//生成支付订单,并返回支付订单编号
|
|
|
BigDecimal orderAmount = BigDecimal.valueOf(payMoney);
|
|
|
orderInfoForm.setOrderAmount(orderAmount);
|
|
|
String payNo = this.insertPayOrderInfo(orderInfoForm);
|
|
|
- if(payNo==null){return responseError(new ResultVO(308,"支付订单生成失败"));}
|
|
|
- log.info("pay order no=======================>{}",payNo);
|
|
|
+ if (payNo == null) {
|
|
|
+ return responseError(new ResultVO(308, "支付订单生成失败"));
|
|
|
+ }
|
|
|
+ log.info("pay order no=======================>{}", payNo);
|
|
|
//调用微信统一下单接口
|
|
|
- log.info("money=====================>{}",payMoney);
|
|
|
+ log.info("money=====================>{}", payMoney);
|
|
|
Object unOrder = null;
|
|
|
- if(WxPayConstants.TradeType.JSAPI.equals(tradeType)){
|
|
|
- unOrder = this.wxUnifiedOrder(payNo,orderAmount,tradeType,wxMpUser.getOpenId());
|
|
|
- }else{
|
|
|
- unOrder = this.wxUnifiedOrder(payNo,orderAmount,tradeType,null);
|
|
|
+ if (WxPayConstants.TradeType.JSAPI.equals(tradeType)) {
|
|
|
+ unOrder = this.wxUnifiedOrder(payNo, orderAmount, tradeType, wxMpUser.getOpenId());
|
|
|
+ } else {
|
|
|
+ unOrder = this.wxUnifiedOrder(payNo, orderAmount, tradeType, null);
|
|
|
}
|
|
|
- log.info("pay order result======================>{}",unOrder);
|
|
|
+ log.info("pay order result======================>{}", unOrder);
|
|
|
//支付倒计时
|
|
|
- GoodsPayOrderForm payOrderForm = orderPayClient.getPayOrderByNo(payNo);
|
|
|
-// ResultVO payOrderVo = orderPayClient.getPayOrderInfoByPayNo(payNo);
|
|
|
+ GoodsPayOrderForm payOrderForm = orderPayService.getPayOrderByNo(payNo);
|
|
|
+// ResultVO payOrderVo = orderPayService.getPayOrderInfoByPayNo(payNo);
|
|
|
// Map payOrderMap = (Map) payOrderVo.getData();
|
|
|
// log.info("payOrderMap=================>{}",payOrderMap);
|
|
|
// GoodsPayOrderForm payOrderForm = JavaBeanUtils.mapToEntity(payOrderMap, GoodsPayOrderForm.class);
|
|
|
- String orderKey ="ord:"+payOrderForm.getOrderNo();
|
|
|
- redisUtils.setValue(orderKey,payOrderForm,900,TimeUnit.SECONDS);
|
|
|
+ String orderKey = "ord:" + payOrderForm.getOrderNo();
|
|
|
+ redisUtils.setValue(orderKey, payOrderForm, 900, TimeUnit.SECONDS);
|
|
|
return responseSuccess(success(unOrder));
|
|
|
} catch (Exception ex) {
|
|
|
ex.printStackTrace();
|
|
@@ -294,11 +290,11 @@ public class WechatManagerController extends CarbonBaseController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- @ApiOperation(value = "微信支付结果回调",notes = "微信支付结果回调请勿直接调用")
|
|
|
- @ApiResponse(code =500,message = "请求的配置参数有问题")
|
|
|
+ @ApiOperation(value = "微信支付结果回调", notes = "微信支付结果回调请勿直接调用")
|
|
|
+ @ApiResponse(code = 500, message = "请求的配置参数有问题")
|
|
|
@AuthCarbonValidate
|
|
|
@PostMapping("/payResultNotified")
|
|
|
- public String payOrderResultNotify(HttpServletRequest request){
|
|
|
+ public String payOrderResultNotify(HttpServletRequest request) {
|
|
|
String xmlResult = HttpKit.readData(request);
|
|
|
boolean isPayOk = false;
|
|
|
WxPayOrderNotifyResult wxPayOrderNotifyResult = null;
|
|
@@ -307,26 +303,26 @@ public class WechatManagerController extends CarbonBaseController {
|
|
|
if (WxPayConstants.ResultCode.SUCCESS.equals(wxPayOrderNotifyResult.getResultCode())) {
|
|
|
isPayOk = true;
|
|
|
}
|
|
|
- log.info("WxPayOrderNotifyResult is ===================>{}",wxPayOrderNotifyResult);
|
|
|
- if(isPayOk){
|
|
|
+ log.info("WxPayOrderNotifyResult is ===================>{}", wxPayOrderNotifyResult);
|
|
|
+ if (isPayOk) {
|
|
|
String payNo = wxPayOrderNotifyResult.getOutTradeNo();
|
|
|
// 更新订单信息(含商品订单,支付订单信息)
|
|
|
- int i = orderClient.updateFullOrderInfo(payNo, 2);
|
|
|
-// ResultVO resultVO = orderClient.updateOrderInfoAndPayOrderInfo(payNo);
|
|
|
- if(i<1){
|
|
|
+ int i = orderInfoService.updateFullOrderInfo(payNo, 2);
|
|
|
+// ResultVO resultVO = orderInfoService.updateOrderInfoAndPayOrderInfo(payNo);
|
|
|
+ if (i < 1) {
|
|
|
log.error("更新订单信息失败,请联系开发人员");
|
|
|
return setXML("FAIL", "");
|
|
|
}
|
|
|
//删除已支付成功的支付订单缓存信息
|
|
|
- GoodsPayOrderForm goodsPayOrderForm = orderPayClient.getPayOrderByNo(payNo);
|
|
|
+ GoodsPayOrderForm goodsPayOrderForm = orderPayService.getPayOrderByNo(payNo);
|
|
|
GoodsPayOrderForm payOrderForm = goodsPayOrderForm;
|
|
|
-// ResultVO payOrderVo = orderPayClient.getPayOrderInfoByPayNo(payNo);
|
|
|
+// ResultVO payOrderVo = orderPayService.getPayOrderInfoByPayNo(payNo);
|
|
|
// Map payOrderMap = (Map) payOrderVo.getData();
|
|
|
// GoodsPayOrderForm payOrderForm = JavaBeanUtils.mapToEntity(payOrderMap, GoodsPayOrderForm.class);
|
|
|
- redisUtils.deleteKey("ord:"+payOrderForm.getOrderNo());
|
|
|
+ redisUtils.deleteKey("ord:" + payOrderForm.getOrderNo());
|
|
|
//返回响应信息给微信接口
|
|
|
return setXML("SUCCESS", "OK");
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
// 支付失败, 记录流水失败
|
|
|
return setXML("FAIL", "");
|
|
|
}
|
|
@@ -337,7 +333,8 @@ public class WechatManagerController extends CarbonBaseController {
|
|
|
return setXML("FAIL", "");
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ @Autowired
|
|
|
+ private WxMpService wxMpService;
|
|
|
|
|
|
@ApiOperation(value = "微信js签名接口", notes = "微信js签名接口")
|
|
|
@ApiResponses({
|
|
@@ -346,7 +343,6 @@ public class WechatManagerController extends CarbonBaseController {
|
|
|
@AuthCarbonValidate
|
|
|
@GetMapping("getJsapiTicket")
|
|
|
public ResponseBase getJsapiTicket(String url) {
|
|
|
- final WxMpService wxMpService = WxMpConfiguration.getMpServices().get(appid);
|
|
|
WxJsapiSignature jsapiSignature = null;
|
|
|
ResultVO resultVO = new ResultVO();
|
|
|
try {
|
|
@@ -368,23 +364,24 @@ public class WechatManagerController extends CarbonBaseController {
|
|
|
})
|
|
|
@AuthCarbonValidate
|
|
|
@GetMapping("/checkWxMap")
|
|
|
- public ResponseBase checkWxMap(){
|
|
|
+ public ResponseBase checkWxMap() {
|
|
|
Map resultMap = new HashMap();
|
|
|
WxMpUser wxMpUser = this.initiWwChatInfo();
|
|
|
- if(Objects.nonNull(wxMpUser)){
|
|
|
- resultMap.put("status",1);
|
|
|
+ if (Objects.nonNull(wxMpUser)) {
|
|
|
+ resultMap.put("status", 1);
|
|
|
return responseSuccess(success(resultMap));
|
|
|
}
|
|
|
- resultMap.put("status",0);
|
|
|
+ resultMap.put("status", 0);
|
|
|
return responseError(success(resultMap));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 生成支付订单
|
|
|
+ *
|
|
|
* @param orderInfoForm
|
|
|
*/
|
|
|
- private String insertPayOrderInfo(GoodsOrderInfoForm orderInfoForm){
|
|
|
- if(null!= orderInfoForm && !"".equals(orderInfoForm.getOrderNo())){
|
|
|
+ private String insertPayOrderInfo(GoodsOrderInfoForm orderInfoForm) {
|
|
|
+ if (null != orderInfoForm && !"".equals(orderInfoForm.getOrderNo())) {
|
|
|
GeneratorIdUtils generatorIdUtils = new GeneratorIdUtils();
|
|
|
String orderNum = generatorIdUtils.nextId();
|
|
|
GoodsPayOrderForm goodsPayOrderForm = new GoodsPayOrderForm();
|
|
@@ -396,10 +393,10 @@ public class WechatManagerController extends CarbonBaseController {
|
|
|
goodsPayOrderForm.setPayStatus(1);
|
|
|
goodsPayOrderForm.setPayNo(orderNum);
|
|
|
goodsPayOrderForm.setPayTime(new Date());
|
|
|
- log.info("goodsPayOrderForm==================>{}",goodsPayOrderForm);
|
|
|
- int i = orderPayClient.saveSelective(goodsPayOrderForm);
|
|
|
-// ResultVO resultVO = orderPayClient.savePayOrderInfo(goodsPayOrderForm);
|
|
|
- if(i>0){
|
|
|
+ log.info("goodsPayOrderForm==================>{}", goodsPayOrderForm);
|
|
|
+ int i = orderPayService.saveSelective(goodsPayOrderForm);
|
|
|
+// ResultVO resultVO = orderPayService.savePayOrderInfo(goodsPayOrderForm);
|
|
|
+ if (i > 0) {
|
|
|
return orderNum;
|
|
|
}
|
|
|
}
|
|
@@ -408,14 +405,15 @@ public class WechatManagerController extends CarbonBaseController {
|
|
|
|
|
|
/**
|
|
|
* 微信统一下单
|
|
|
- * @param payNo 支付订单号
|
|
|
- * @param money 支付金额
|
|
|
+ *
|
|
|
+ * @param payNo 支付订单号
|
|
|
+ * @param money 支付金额
|
|
|
* @param tradeType 交易类型
|
|
|
- * @param wxId 微信openid(只用于jsaip交易方式)
|
|
|
+ * @param wxId 微信openid(只用于jsaip交易方式)
|
|
|
* @return
|
|
|
* @throws WxPayException
|
|
|
*/
|
|
|
- private Object wxUnifiedOrder(String payNo,BigDecimal money,String tradeType,String wxId) throws WxPayException {
|
|
|
+ private Object wxUnifiedOrder(String payNo, BigDecimal money, String tradeType, String wxId) throws WxPayException {
|
|
|
WxPayUnifiedOrderRequest orderRequest = new WxPayUnifiedOrderRequest();
|
|
|
orderRequest.setNonceStr(UUIDUtils.randomUUID());
|
|
|
//商品描述
|
|
@@ -425,9 +423,9 @@ public class WechatManagerController extends CarbonBaseController {
|
|
|
//元转成分
|
|
|
BigDecimal cmoney = money.multiply(new BigDecimal(100));
|
|
|
int i = cmoney.intValue();
|
|
|
- if(WECHAT_PAY_FLAG_TEST.equalsIgnoreCase(payFlag)){
|
|
|
+ if (WECHAT_PAY_FLAG_TEST.equalsIgnoreCase(payFlag)) {
|
|
|
orderRequest.setTotalFee(1);
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
orderRequest.setTotalFee(i);
|
|
|
}
|
|
|
//终端ip
|
|
@@ -438,7 +436,7 @@ public class WechatManagerController extends CarbonBaseController {
|
|
|
//交易类型
|
|
|
orderRequest.setTradeType(tradeType);
|
|
|
//用户标识 获取用户openid
|
|
|
- if(wxId!=null){
|
|
|
+ if (wxId != null) {
|
|
|
orderRequest.setOpenid(wxId);
|
|
|
}
|
|
|
// 这个可能是偏向原生一点的统一下单,返回的参数有很多没用的 或者null值 建议使用 createOrder下单
|