From 84d9254fbaa17cff88b374857dde710d8b54e2c6 Mon Sep 17 00:00:00 2001 From: yuyang Date: Fri, 10 Dec 2021 09:59:47 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=94=AF=E4=BB=98=E5=AE=9D?= =?UTF-8?q?=E5=85=85=E5=80=BC=E6=94=AF=E4=BB=98=E5=AE=9D=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E5=8F=B7=E6=9C=AA=E5=85=A5=E5=BA=93=EF=BC=8C=E7=9F=AD=E4=BF=A1?= =?UTF-8?q?=E5=8F=96=E6=B6=88=E7=B3=BB=E7=BB=9F=E5=BC=82=E5=B8=B8=E5=85=A5?= =?UTF-8?q?=E5=BA=93=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../general/service/XhpcSmsServiceImpl.java | 28 +-------- .../controller/AlipayPaymentController.java | 61 +++---------------- 2 files changed, 10 insertions(+), 79 deletions(-) diff --git a/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/service/XhpcSmsServiceImpl.java b/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/service/XhpcSmsServiceImpl.java index 06b96f48..12d213e3 100644 --- a/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/service/XhpcSmsServiceImpl.java +++ b/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/service/XhpcSmsServiceImpl.java @@ -65,7 +65,6 @@ public class XhpcSmsServiceImpl implements IXhpcSmsService { @Override public AjaxResult send(String phone, String content, String random, String signatureName, String templateId, Map paramMap) { - logger.info("---------------1111phone---------------"+phone); //调用接口 String pattern = "^([1][0-9]{10})"; Pattern compile = Pattern.compile(pattern); @@ -74,38 +73,31 @@ public class XhpcSmsServiceImpl implements IXhpcSmsService { if (!isMatch) { return AjaxResult.error("1003", "请输入正确的手机号"); } - logger.info("---------------2222---------------"); //添加短信记录 XhpcSms xhpcSms =new XhpcSms(); try { - logger.info("---------------33333---------------"); //用户使用的Key String pvToken = "pvToken:" + phone; //用户频繁调用的判断的Key String token = "token:" + phone; - logger.info("-------------4444-----------------"); String cacheObject = REDIS.getCacheObject(token); System.out.println("过了redis"); if (cacheObject != null) { return AjaxResult.error("1012", "操作过于频繁,请于1分钟后重试"); } - logger.info("--------------555----------------"); //使用阿里云发送通知短信 Map neededParam = null; try { neededParam = aliyunSmsNotice(phone, signatureName, templateId, paramMap); } catch (Exception e) { - System.out.println(e.getMessage()); throw new RuntimeException("阿里短信服务异常,neededParam为null"); } - System.out.println("过了阿里云"); if (!"".equals(random) && random != null) { xhpcSms.setCode(random); } xhpcSms.setPhone(phone); xhpcSms.setContent(neededParam.get("templateContent")); - logger.info("===============666============="); xhpcSms.setCreateTime(new Date()); xhpcSms.setRemark(neededParam.get("jsonResult")); @@ -117,7 +109,6 @@ public class XhpcSmsServiceImpl implements IXhpcSmsService { REDIS.setCacheObject(token, random, 60L, TimeUnit.SECONDS); xhpcSms.setStatus(0); xhpcSmsMapper.addXhpcSms(xhpcSms); - logger.info("************777****************"); return AjaxResult.success(); } else { xhpcSms.setStatus(1); @@ -125,10 +116,9 @@ public class XhpcSmsServiceImpl implements IXhpcSmsService { return AjaxResult.error(1012, "服务器繁忙,请稍后再试"); } } catch (Exception e) { - logger.info("+++++++++++888+++++++++++++++++"); e.printStackTrace(); - xhpcSms.setStatus(3); - xhpcSmsMapper.addXhpcSms(xhpcSms); + // xhpcSms.setStatus(3); + // xhpcSmsMapper.addXhpcSms(xhpcSms); return AjaxResult.error(1010,"服务器繁忙,请稍后再试"); } } @@ -186,20 +176,6 @@ public class XhpcSmsServiceImpl implements IXhpcSmsService { return messageInfoMap; } - public static void main(String[] args) { - - for (int i = 0; i < 50; i++) { - Random rnd = new Random(); - int j = rnd.nextInt(999999); - System.out.println("number>> " + j); - if (j < 100000) { - j = j + 100000; - } - System.out.println("number " + Long.valueOf(j)); - } - - } - /** * 使用阿里云服务发送通知短信 * diff --git a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/controller/AlipayPaymentController.java b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/controller/AlipayPaymentController.java index 060e785f..432b2813 100644 --- a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/controller/AlipayPaymentController.java +++ b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/controller/AlipayPaymentController.java @@ -1,5 +1,6 @@ package com.xhpc.payment.controller; +import cn.hutool.core.date.DateUtil; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.alipay.api.AlipayApiException; @@ -11,7 +12,9 @@ import com.alipay.api.internal.util.AlipaySignature; import com.alipay.api.internal.util.AntCertificationUtil; import com.alipay.api.request.AlipayTradeAppPayRequest; import com.alipay.api.request.AlipayTradeCreateRequest; +import com.alipay.api.request.AlipayTradeRoyaltyRelationBindRequest; import com.alipay.api.response.AlipayTradeCreateResponse; +import com.alipay.api.response.AlipayTradeRoyaltyRelationBindResponse; import com.xhpc.common.api.PowerPileService; import com.xhpc.common.core.constant.HttpStatus; import com.xhpc.common.core.constant.StatusConstants; @@ -32,10 +35,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.env.Environment; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletRequest; import java.math.BigDecimal; @@ -173,8 +173,9 @@ public class AlipayPaymentController { if ("TRADE_SUCCESS".equals(tradeStatus)) { // 业务参数主要转码回来 JSONObject jsonObject = JSON.parseObject(URLDecoder.decode(passbackParams)); + logger.info("<<<<<<<<<<<>>>>>>>>"+jsonObject.toString()); String out_trade_no = jsonObject.getString("out_trade_no"); - String transaction_id = jsonObject.getString("transaction_id"); + String transaction_id = params.get("trade_no"); paymentCallback(out_trade_no, transaction_id); } }catch (Exception e){ @@ -249,7 +250,7 @@ public class AlipayPaymentController { XhpcRechargeOrder xhpcRechargeOrder = iXhpcRechargeOrderService.infoRechargeOrderNumber(out_trade_no); if (StringUtils.isNotNull(xhpcRechargeOrder)) { //修改充值订单状态 - iXhpcRechargeOrderService.updateRechargeOrder(xhpcRechargeOrder.getRechargeOrderId(), StatusConstants.OPERATION_WX_TYPE, StatusConstants.RECHARGE_ORDER_STATUS_SUCCESS, transaction_id); + iXhpcRechargeOrderService.updateRechargeOrder(xhpcRechargeOrder.getRechargeOrderId(), StatusConstants.OPERATION_ALI_PAY_TYPE, StatusConstants.RECHARGE_ORDER_STATUS_SUCCESS, transaction_id); } Map appUserInfo = xhpcUserAccountStatementMapper.appUserInfo(xhpcRechargeOrder.getUserId()); if (StringUtils.isNotNull(appUserInfo)) { @@ -294,53 +295,6 @@ public class AlipayPaymentController { } - - public static void main(String[] args) { - try{ - -// String st ="{gmt_create=2021-10-15 10:14:13, charset=UTF-8, seller_email=27555730@qq.com, subject=小华充电, sign=PNRU8Rck2aTVWqgoVOOsaZFujrlt7AQrsZKWw8S4RP7Ctehgj607PZ0j8364YLuIL9SKY1G7pPAP1Zfgur1uRw5CiqygqBkDl+jVu4Wh1BYUs8Qe0S5rKHGWk27uGi2gGdEvwCoPpzOnfHpGUbz3dhlqb03rkROAHHUNgOeKeMyzU5sfUB6z/tDpXoB3bcqZoEeaBba/mlu7L3QgqAXTRVLaE5tPntZfe5Ag/Sh3M9YX+07ktxA4khvCpRsB84yT3DTAKj8qY/IWnlsf4iUcU0A8GuGRAjkYNwadOIH3N/ngmS9LPkDME+TwoJ8F1gFpx6xbYSSbq8AtoGedujJXpA==, buyer_id=2088912814256712, invoice_amount=2.84, notify_id=2021101500222101424056715726105484, fund_bill_list=[{\"amount\":\"2.16\",\"fundChannel\":\"COUPON\"},{\"amount\":\"2.84\",\"fundChannel\":\"ALIPAYACCOUNT\"}], notify_type=trade_status_sync, trade_status=TRADE_SUCCESS, receipt_amount=5.00, buyer_pay_amount=5.00, app_id=2021002156615717, sign_type=RSA2, seller_id=2088631279527183, gmt_payment=2021-10-15 10:14:23, notify_time=2021-10-15 10:14:24, passback_params=%7B%22customerId%22%3A19%2C%22money%22%3A%225%22%2C%22out_trade_no%22%3A%22000000120211015101411117%22%7D, version=1.0, out_trade_no=000000120211015101411117, total_amount=5.00, trade_no=2021101522001456715750880678, auth_app_id=2021002156615717, buyer_logon_id=181****4652, point_amount=0.00}"; -// System.out.println("map:"+st); -// String resultInfo=st.substring(1,st.length()-1); -// //resultInfo=resultInfo.replace(", ","&"); -// System.out.println("resultInfo="+resultInfo); -// //回调的待验签字符串 -// //String resultInfo = "gmt_create=2021-10-14 18:55:50&charset=UTF-8&seller_email=27555730@qq.com&subject=小华充电&sign=DN7OEd6MwL1d+RsevKOPD9XGGV4hJFZ/gKRuqh2wCIN9FWlutMp654XyTPCu1jOGYaCQkjycJiriq+Cxqp6bXa0bAEKdrl+3bqfE1Cx9YjL5nvgYLuhfhoH7rrFsJVBE92lh7O541f+w8HNrTSG5Xa6lUUuqb55MEHx2GKvAISM9BChSK279FvLQV7rhmhO840QIJCgQkwm6sueLg1tVnH9nkcd0YRrE924n+mYzdRAS6Ekq2MlE2vOjHslO796oIKY0EyHb4z6liSupkmiZgQ2v5DppXiS6+/H6uLyOBMhIgMdO9ZmYRkUtHkq7emYmvjFwR2lRdy/qqnGW3OFbGw==&buyer_id=2088912814256712&invoice_amount=5.00¬ify_id=2021101400222185603056715724775024&fund_bill_list=[{\"amount\":\"5.00\",\"fundChannel\":\"ALIPAYACCOUNT\"}]¬ify_type=trade_status_sync&trade_status=TRADE_SUCCESS&receipt_amount=5.00&buyer_pay_amount=5.00&app_id=2021002156615717&sign_type=RSA2&seller_id=2088631279527183&gmt_payment=2021-10-14 18:56:03¬ify_time=2021-10-14 19:10:21&passback_params=%7B%22customerId%22%3A13%2C%22money%22%3A%225%22%2C%22out_trade_no%22%3A%22000000120211014185549114%22%7D&version=1.0&out_trade_no=000000120211014185549114&total_amount=5.00&trade_no=2021101422001456715747823733&auth_app_id=2021002156615717&buyer_logon_id=181****4652&point_amount=0.00"; -// String charset="utf-8"; -// //支付宝公钥证书 -// String alipayPublicCertPath="I:\\顶想\\充电桩\\支付宝\\10-13\\alipayCertPublicKey_RSA2.crt"; -// //签名方式 -// String sign_type="RSA2"; -// //对待签名字符串数据通过&进行拆分 -// String [] temp = resultInfo.split(", "); -// LinkedHashMap map = new LinkedHashMap(); -// //把拆分数据放在map集合内 -// for (int i = 0; i < temp.length; i++) { -// String[] arr = temp[i].split("=", 2); //通过"="号分割成2个数据 -// String[] tempAagin = new String[arr.length]; //再开辟一个数组用来接收分割后的数据 -// for (int j = 0; j < arr.length; j++) { -// tempAagin[j] = arr[j]; -// } -// map.put(tempAagin[0], tempAagin[1]); -// } -// System.out.println("map:"+map); -// //验签方法 -// boolean signVerified= AlipaySignature.rsaCertCheckV1(map, alipayPublicCertPath, charset,sign_type); -// if(signVerified){ -// // TODO 验签成功后 -// System.out.println("验签成功后:success"); -// }else{ -// System.out.println("验签失败后:fail"); -// } - - - - }catch (Exception e){ - e.printStackTrace(); - } - - } - - /** * 从公钥证书中提取公钥 * @@ -352,4 +306,5 @@ public class AlipayPaymentController { return AntCertificationUtil.getAlipayPublicKey(alipayPublicCertPath); } + }