UserQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/account/controller/AccountController.java
@@ -12,7 +12,6 @@ import com.stylefeng.guns.modular.account.server.UserWithdrawalService; import com.stylefeng.guns.modular.system.model.UserBankAccount; import com.stylefeng.guns.modular.system.model.UserInfo; import com.stylefeng.guns.modular.system.model.UserWithdrawal; import com.stylefeng.guns.modular.system.service.IUserInfoService; import com.stylefeng.guns.modular.system.util.ResultUtil; import io.swagger.annotations.Api; @@ -72,10 +71,10 @@ return ResultUtil.error("不能重复添加银行卡"); } List<UserWithdrawal> userId = userWithdrawalService.selectList(new EntityWrapper<UserWithdrawal>().eq("phone", user.getPhone()).eq("userType",1)); if(userId.size()==0){ return ResultUtil.error("请先进行个人用户进件信息填写"); } // List<UserWithdrawal> userId = userWithdrawalService.selectList(new EntityWrapper<UserWithdrawal>().eq("phone", user.getPhone()).eq("userType",1)); // if(userId.size()==0){ // return ResultUtil.error("请先进行个人用户进件信息填写"); // } userBankAccount.setUserId(uid); UserBankAccount userBankAccount1 = new UserBankAccount(); BeanUtils.copyProperties(userBankAccount, userBankAccount1); @@ -93,7 +92,7 @@ // userBankAccount1.setAcctValidationFailureMsg(settleAcctResp.getAcctValidationFailureMsg()); // userBankAccount1.setAcctValidationFinishedAt(settleAcctResp.getAcctValidationFinishedAt().toString()); // userBankAccount1.setSettleAcctId(settleAcctResp.getSettleAcctId()); bankAccountService.updateById(userBankAccount1); // bankAccountService.updateById(userBankAccount1); return ResultUtil.success(); }catch (Exception e){ e.printStackTrace(); UserQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/api/OrderController.java
@@ -1568,15 +1568,12 @@ System.out.println("完成订单微信支付回调"); Map<String, String> map = payMoneyUtil.weixinpayCallback(request); System.out.println("wx支付信息:"+map); if(null != map){ String order_id = map.get("transaction_id"); String out_trade_no = map.get("out_trade_no"); String result = map.get("result"); String total_fee = map.get("total_fee"); String transaction_id = map.get("transaction_id"); if(ToolUtil.isNotEmpty(out_trade_no) && ToolUtil.isNotEmpty(order_id)){ PrintWriter out = response.getWriter(); out.write(result); UserQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/call/server/impl/OrderCallServiceImpl.java
@@ -2,7 +2,6 @@ import com.baomidou.mybatisplus.mapper.EntityWrapper; import com.baomidou.mybatisplus.service.impl.ServiceImpl; import com.stylefeng.guns.modular.CharteredCar.model.OrderCharteredCar; import com.stylefeng.guns.modular.account.controller.AppOrderController; import com.stylefeng.guns.modular.call.dao.OrderCallMapper; import com.stylefeng.guns.modular.call.model.OrderCall; @@ -71,10 +70,10 @@ if(userInfo.getBalance() == null || userInfo.getBalance() < money){ return ResultUtil.error("余额不足,无法完成支付"); } resultUtil= appOrderController.moneyPay(orderId,userInfo.getId(),money); if(resultUtil.getCode()==500){ return ResultUtil.error("电子余额不足,无法完成支付"); } // resultUtil= appOrderController.moneyPay(orderId,userInfo.getId(),money); // if(resultUtil.getCode()==500){ // return ResultUtil.error("电子余额不足,无法完成支付"); // } userInfo.setBalance(new BigDecimal(userInfo.getBalance()).subtract(new BigDecimal(money)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); UserQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/crossCity/server/impl/OrderCrossCityServiceImpl.java
@@ -1031,13 +1031,12 @@ if(userInfo.getBalance() == null || userInfo.getBalance() < orderMoney){ return ResultUtil.error("余额不足,无法完成支付"); } if(orderMoney > 0){ resultUtil= appOrderController.moneyPay(orderId,userInfo.getId(),orderMoney); if(resultUtil.getCode()==500){ return ResultUtil.error("电子余额不足,无法完成支付"); } } // if(orderMoney > 0){ // resultUtil= appOrderController.moneyPay(orderId,userInfo.getId(),orderMoney); // if(resultUtil.getCode()==500){ // return ResultUtil.error("电子余额不足,无法完成支付"); // } // } userInfo.setBalance(new BigDecimal(userInfo.getBalance()).subtract(new BigDecimal(orderMoney)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); @@ -1529,10 +1528,10 @@ if(userInfo.getBalance() != null && userInfo.getBalance() < query.getMoney()){ return ResultUtil.error("余额不足,无法完成支付"); } resultUtil= appOrderController.moneyPay(id,userInfo.getId(),query.getMoney()); if(resultUtil.getCode()==500){ return ResultUtil.error("电子余额不足,无法完成支付"); } // resultUtil= appOrderController.moneyPay(id,userInfo.getId(),query.getMoney()); // if(resultUtil.getCode()==500){ // return ResultUtil.error("电子余额不足,无法完成支付"); // } userInfo.setBalance(new BigDecimal(userInfo.getBalance()).subtract(new BigDecimal(query.getMoney())).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); //添加交易明细 @@ -2574,10 +2573,10 @@ return ResultUtil.error("余额不足,无法完成支付"); } resultUtil= appOrderController.moneyPay(orderId,userInfo.getId(),money); if(resultUtil.getCode()==500){ return ResultUtil.error("电子余额不足,无法完成支付"); } // resultUtil= appOrderController.moneyPay(orderId,userInfo.getId(),money); // if(resultUtil.getCode()==500){ // return ResultUtil.error("电子余额不足,无法完成支付"); // } userInfo.setBalance(new BigDecimal(userInfo.getBalance()).subtract(new BigDecimal(money)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); SysIntegral query1 = sysIntegralMapper.query(orderCrossCity.getCompanyId()); UserQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/smallLogistics/server/impl/OrderLogisticsServiceImpl.java
@@ -777,12 +777,12 @@ if(userInfo.getBalance() == null || userInfo.getBalance() < orderMoney){ return ResultUtil.error("余额不足,无法完成支付"); } if(orderMoney>0) { resultUtil = appOrderController.moneyPay(orderId, userInfo.getId(), orderMoney); if (resultUtil.getCode() == 500) { return ResultUtil.error("电子余额不足,无法完成支付"); } } // if(orderMoney>0) { // resultUtil = appOrderController.moneyPay(orderId, userInfo.getId(), orderMoney); // if (resultUtil.getCode() == 500) { // return ResultUtil.error("电子余额不足,无法完成支付"); // } // } userInfo.setBalance(new BigDecimal(userInfo.getBalance()).subtract(new BigDecimal(orderMoney)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); SysIntegral query1 = sysIntegralMapper.query(orderLogistics.getCompanyId()); @@ -867,10 +867,10 @@ if(userInfo.getBalance() == null || userInfo.getBalance() < orderMoney){ return ResultUtil.error("余额不足,无法完成支付"); } resultUtil= appOrderController.moneyPay(orderId,userInfo.getId(),orderMoney); if(resultUtil.getCode()==500){ return ResultUtil.error("电子余额不足,无法完成支付"); } // resultUtil= appOrderController.moneyPay(orderId,userInfo.getId(),orderMoney); // if(resultUtil.getCode()==500){ // return ResultUtil.error("电子余额不足,无法完成支付"); // } userInfo.setBalance(new BigDecimal(userInfo.getBalance()).subtract(new BigDecimal(orderMoney)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); @@ -1618,10 +1618,10 @@ if(userInfo.getBalance() == null || userInfo.getBalance() < money){ return ResultUtil.error("余额不足,无法完成支付"); } resultUtil= appOrderController.moneyPay(orderId,userInfo.getId(),money); if(resultUtil.getCode()==500){ return ResultUtil.error("电子余额不足,无法完成支付"); } // resultUtil= appOrderController.moneyPay(orderId,userInfo.getId(),money); // if(resultUtil.getCode()==500){ // return ResultUtil.error("电子余额不足,无法完成支付"); // } userInfo.setBalance(new BigDecimal(userInfo.getBalance()).subtract(new BigDecimal(money)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); UserQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/specialTrain/server/impl/OrderPrivateCarServiceImpl.java
@@ -1095,10 +1095,10 @@ if(userInfo.getBalance() != null && userInfo.getBalance() < query.getMoney()){ return ResultUtil.error("余额不足,无法完成支付"); } resultUtil= appOrderController.moneyPay(id,userInfo.getId(),query.getMoney()); if(resultUtil.getCode()==500){ return ResultUtil.error("电子余额不足,无法完成支付"); } // resultUtil= appOrderController.moneyPay(id,userInfo.getId(),query.getMoney()); // if(resultUtil.getCode()==500){ // return ResultUtil.error("电子余额不足,无法完成支付"); // } userInfo.setBalance(new BigDecimal(userInfo.getBalance()).subtract(new BigDecimal(query.getMoney())).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); //添加交易明细 transactionDetailsService.saveData(uid, "快车取消订单", query.getMoney(), 2, 1, 1, 1, id); @@ -2613,10 +2613,10 @@ if(userInfo.getBalance() == null || userInfo.getBalance() < money){ return ResultUtil.error("余额不足,无法完成支付"); } resultUtil= appOrderController.moneyPay(orderId,userInfo.getId(),money); if(resultUtil.getCode()==500){ return ResultUtil.error("电子余额不足,无法完成支付"); } // resultUtil= appOrderController.moneyPay(orderId,userInfo.getId(),money); // if(resultUtil.getCode()==500){ // return ResultUtil.error("电子余额不足,无法完成支付"); // } userInfo.setBalance(new BigDecimal(userInfo.getBalance()).subtract(new BigDecimal(money)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); SysIntegral query1 = sysIntegralMapper.query(orderPrivateCar.getCompanyId()); UserQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/TaxiCardServiceImpl.java
@@ -24,7 +24,10 @@ import java.math.BigDecimal; import java.text.SimpleDateFormat; import java.util.*; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; import java.util.List; import java.util.stream.Collectors; @Service @@ -365,10 +368,10 @@ if(userInfo.getBalance() == null || userInfo.getBalance() < taxiCard.getSellingPrice()){ return ResultUtil.error("余额不足,无法完成支付", ""); } resultUtil= appOrderController.moneyPay(taxiCardPayment.getId(),userInfo.getId(),taxiCard.getSellingPrice()); if(resultUtil.getCode()==500){ return ResultUtil.error("电子余额不足,无法完成支付"); } // resultUtil= appOrderController.moneyPay(taxiCardPayment.getId(),userInfo.getId(),taxiCard.getSellingPrice()); // if(resultUtil.getCode()==500){ // return ResultUtil.error("电子余额不足,无法完成支付"); // } userInfo.setBalance(new BigDecimal(userInfo.getBalance()).subtract(new BigDecimal(taxiCard.getSellingPrice())).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); //添加交易明细 transactionDetailsService.saveData(uid, "购买出行卡", taxiCard.getSellingPrice(), 2, 1, 1, 6, taxiCardPayment.getId()); UserQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/UserInfoServiceImpl.java
@@ -16,12 +16,13 @@ import com.stylefeng.guns.modular.system.model.*; import com.stylefeng.guns.modular.system.service.*; import com.stylefeng.guns.modular.system.util.*; import com.stylefeng.guns.modular.system.util.qianyuntong.AESUtils; import com.stylefeng.guns.modular.system.util.qianyuntong.SMSUtil; import com.stylefeng.guns.modular.system.util.qianyuntong.UserUtil; import com.stylefeng.guns.modular.system.util.qianyuntong.model.LoginWeChatXiao; import com.stylefeng.guns.modular.system.util.qianyuntong.model.QYTUserInfo; import com.stylefeng.guns.modular.system.util.qianyuntong.model.RegisterViaMobile; import com.stylefeng.guns.modular.system.util.qianyuntong.model.RegisterViaMobileRequest; import com.stylefeng.guns.modular.system.util.qianyuntong.model.SendSmsRequest; import com.stylefeng.guns.modular.system.warpper.LoginWarpper; import com.stylefeng.guns.modular.taxi.model.PaymentRecord; import com.stylefeng.guns.modular.taxi.service.IPaymentRecordService; @@ -146,21 +147,21 @@ sb.append((int) (random.nextDouble() * 10)); } String authCode = sb.toString(); String templateCode = ""; switch (type){ case 1: templateCode = "SMS_154775435";//身份验证 break; case 2: templateCode = "SMS_154775434";//登录确认 break; case 3: templateCode = "SMS_154775432";//用户注册 break; case 4: templateCode = "SMS_154775431";//修改密码 break; } // String templateCode = ""; // switch (type){ // case 1: // templateCode = "SMS_154775435";//身份验证 // break; // case 2: // templateCode = "SMS_154775434";//登录确认 // break; // case 3: // templateCode = "SMS_154775432";//用户注册 // break; // case 4: // templateCode = "SMS_154775431";//修改密码 // break; // } // String sData = aLiSendSms.sendSms(phone, "SMS_229715276", "{\"code\":\"" + authCode + "\"}"); // JSONObject jsonObject = JSON.parseObject(sData); // String message = jsonObject.getString("Message"); @@ -168,11 +169,24 @@ // System.err.println(message); // return ResultUtil.error(message); // } //中台没有用户数据,需要走注册接口,验证码校验走中台 List<QYTUserInfo> infoByPhone = UserUtil.getUserInfoByPhone(phone); if (null == infoByPhone || infoByPhone.isEmpty()) { SMSUtil.sendVerifyCode(phone); String sms = "短信验证码【" + authCode + "】已发到您的手机,验证码将在5分钟后失效,请及时登录!"; } else { SendSmsRequest request = new SendSmsRequest(); request.setDestAddress(phone); request.setTemplateId("TPL202410290001"); Map<String, String> templateParams = new HashMap<>(); templateParams.put("code", authCode); request.setTemplateParams(templateParams); request.setCode("code"); request.setSpId("T8d5hdfg"); SMSUtil.sendSms(request); //发送验证码短信 redisTemplate.opsForValue().set(phone, authCode, 5, TimeUnit.MINUTES);//设置五分钟过期 System.out.println("【" + phone + "】" + sms); } return ResultUtil.success(); } @@ -208,19 +222,39 @@ */ @Override public synchronized ResultUtil<LoginWarpper> captchaLogin(String phone, String code, String registIp, String registAreaCode,String loginType) throws Exception { UserInfo userInfo = userInfoMapper.queryByPhone(phone); String nickName = null; if (null == userInfo) { nickName = this.getDefaultName(); } else { nickName = userInfo.getNickName(); } //调中台接口查询用户 List<QYTUserInfo> infoByPhone = UserUtil.getUserInfoByPhone(phone); if (null == infoByPhone || infoByPhone.isEmpty()) { RegisterViaMobileRequest request = new RegisterViaMobileRequest(); request.setMobile(phone); request.setEncryptType("aesbase64"); request.setPassword(AESUtils.encryptBase64("123456")); request.setNickname(nickName); request.setVerify_code(code); request.setVerify_code_type("0"); RegisterViaMobile register = UserUtil.registerViaMobile(request); if (!"0".equals(register.getStatus())) { return ResultUtil.error(register.getDesc()); } } else { boolean b = this.checkCaptcha(phone, code); if (!b) { return ResultUtil.error("验证码无效"); } } UserInfo userInfo = userInfoMapper.queryByPhone(phone); if (null == userInfo) { ArrayList<UserBankAccount> userBankAccounts = new ArrayList<>(); userInfo = new UserInfo(); userInfo.setPhone(phone); userInfo.setPassWord(ShiroKit.md5("", salt)); userInfo.setNickName(this.getDefaultName()); userInfo.setNickName(nickName); userInfo.setRegistIp(registIp); userInfo.setIsAuth(1); userInfo.setConsumption(0D); @@ -250,20 +284,6 @@ } }).start(); } //调中台接口查询用户 List<QYTUserInfo> infoByPhone = UserUtil.getUserInfoByPhone(phone); if (null == infoByPhone || infoByPhone.isEmpty()) { RegisterViaMobileRequest request = new RegisterViaMobileRequest(); request.setMobile(phone); request.setPassword("123456"); request.setNickname(userInfo.getNickName()); request.setVerify_code(code); request.setVerify_code_type("1"); RegisterViaMobile register = UserUtil.registerViaMobile(request); if (!"0".equals(register.getStatus())) { return ResultUtil.error(register.getDesc()); } } if (userInfo.getState() == 2) { return ResultUtil.error("账号被冻结"); @@ -547,15 +567,9 @@ } jsonObject.put(userInfo.getId().toString(), userInfo.getAppletsOpenId()); redisTemplate.opsForValue().set("appletOpenId", jsonObject.toJSONString()); //调中台微信登录接口 LoginWeChatXiao loginWeChatXiao = UserUtil.loginWeChatXiao(jscode); if (null == loginWeChatXiao) { return ResultUtil.error("微信登录请求失败,请重试"); } //调用单点登录的逻辑 this.singlePointLogin(userInfo.getId(), loginType); String token = loginWeChatXiao.getToken(); String token = this.getToken(userInfo, "", loginType); redisTemplate.opsForValue().set(token.substring(token.length() - 32), String.valueOf(userInfo.getId()), 180, TimeUnit.DAYS); redisTemplate.opsForValue().set("USER_" + type + "_" + userInfo.getPhone(), token.substring(token.length() - 32)); redisTemplate.opsForValue().set("USER_" + type + "_" + userInfo.getId(), token); @@ -837,30 +851,35 @@ */ @Override public ResultUtil bindingPhone(Integer uid, String phone, String code,String loginType) throws Exception { boolean b = this.checkCaptcha(phone, code); if (!b) { return ResultUtil.error("验证码无效"); } UserInfo userInfo = this.selectById(uid); UserInfo userInfo1 = userInfoMapper.queryByPhone(phone); if (null != userInfo1) { String nickName = null; if (null == userInfo) { nickName = this.getDefaultName(); } else { nickName = userInfo.getNickName(); } //调中台接口查询用户 List<QYTUserInfo> infoByPhone = UserUtil.getUserInfoByPhone(phone); if (null == infoByPhone || infoByPhone.isEmpty()) { RegisterViaMobileRequest request = new RegisterViaMobileRequest(); request.setMobile(phone); request.setPassword("123456"); request.setNickname(userInfo.getNickName()); request.setEncryptType("aesbase64"); request.setPassword(AESUtils.encryptBase64("123456")); request.setNickname(nickName); request.setVerify_code(code); request.setVerify_code_type("1"); request.setVerify_code_type("0"); RegisterViaMobile register = UserUtil.registerViaMobile(request); if (!"0".equals(register.getStatus())) { return ResultUtil.error(register.getDesc()); } } else { boolean b = this.checkCaptcha(phone, code); if (!b) { return ResultUtil.error("验证码无效"); } } UserInfo userInfo1 = userInfoMapper.queryByPhone(phone); if (null != userInfo1) { userInfo1.setOpenId(userInfo.getOpenId()); userInfo1.setUnionid(userInfo.getUnionid()); userInfo1.setAppletsOpenId(userInfo.getAppletsOpenId()); @@ -916,21 +935,6 @@ loginWarpper.setPhone(2); return ResultUtil.success(loginWarpper); } //调中台接口查询用户 List<QYTUserInfo> infoByPhone = UserUtil.getUserInfoByPhone(phone); if (null == infoByPhone || infoByPhone.isEmpty()) { RegisterViaMobileRequest request = new RegisterViaMobileRequest(); request.setMobile(phone); request.setPassword("123456"); request.setNickname(userInfo.getNickName()); request.setVerify_code(code); request.setVerify_code_type("1"); RegisterViaMobile register = UserUtil.registerViaMobile(request); if (!"0".equals(register.getStatus())) { return ResultUtil.error(register.getDesc()); } } userInfo.setPhone(phone); userInfo.setUpdateTime(new Date()); @@ -1435,7 +1439,7 @@ */ public String getDefaultName(){ int num = this.selectCount(new EntityWrapper<UserInfo>().ne("flag", 3)) + 1000001; return "JYX" + String.valueOf(num).substring(1); return "GRJY" + String.valueOf(num).substring(1); } /** UserQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/qianyuntong/AESUtils.java
New file @@ -0,0 +1,155 @@ package com.stylefeng.guns.modular.system.util.qianyuntong; import org.apache.commons.codec.binary.Base64; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.crypto.BadPaddingException; import javax.crypto.Cipher; import javax.crypto.IllegalBlockSizeException; import javax.crypto.NoSuchPaddingException; import javax.crypto.spec.SecretKeySpec; import java.io.UnsupportedEncodingException; import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; public class AESUtils { private static Logger logger = LoggerFactory.getLogger(AESUtils.class); private static String ALG = "AES"; private static String CHARSET = "UTF-8"; private static String KEY1 = "lur8apa4zu484pvj"; public AESUtils() { } private static byte[] encrypt(byte[] content, String password, String iv) { try { SecretKeySpec key = new SecretKeySpec(password.getBytes(CHARSET), ALG); Cipher cipher = Cipher.getInstance(ALG); cipher.init(1, key); return cipher.doFinal(content); } catch (NoSuchAlgorithmException var5) { var5.printStackTrace(); } catch (NoSuchPaddingException var6) { var6.printStackTrace(); } catch (InvalidKeyException var7) { var7.printStackTrace(); } catch (UnsupportedEncodingException var8) { var8.printStackTrace(); } catch (IllegalBlockSizeException var9) { var9.printStackTrace(); } catch (BadPaddingException var10) { var10.printStackTrace(); } return null; } private static byte[] decrypt(byte[] content, String password, String iv) { try { SecretKeySpec key = new SecretKeySpec(password.getBytes(CHARSET), ALG); Cipher cipher = Cipher.getInstance(ALG); cipher.init(2, key); return cipher.doFinal(content); } catch (NoSuchAlgorithmException var5) { var5.printStackTrace(); } catch (NoSuchPaddingException var6) { var6.printStackTrace(); } catch (InvalidKeyException var7) { var7.printStackTrace(); } catch (IllegalBlockSizeException var8) { var8.printStackTrace(); } catch (BadPaddingException var9) { var9.printStackTrace(); } catch (UnsupportedEncodingException var10) { var10.printStackTrace(); } return null; } private static String parseByte2HexStr(byte[] buf) { StringBuffer sb = new StringBuffer(); for(int i = 0; i < buf.length; ++i) { String hex = Integer.toHexString(buf[i] & 255); if (hex.length() == 1) { hex = '0' + hex; } sb.append(hex.toUpperCase()); } return sb.toString(); } private static byte[] parseHexStr2Byte(String hexStr) { if (hexStr.length() < 1) { return null; } else { byte[] result = new byte[hexStr.length() / 2]; for(int i = 0; i < hexStr.length() / 2; ++i) { int high = Integer.parseInt(hexStr.substring(i * 2, i * 2 + 1), 16); int low = Integer.parseInt(hexStr.substring(i * 2 + 1, i * 2 + 2), 16); result[i] = (byte)(high * 16 + low); } return result; } } public static String decryptHex(String content) { return decryptHex(content, KEY1); } public static String decryptHex(String content, String password) { try { return new String(decrypt(parseHexStr2Byte(content), password, ""), CHARSET); } catch (Exception var3) { return ""; } } public static String decryptBase64(String content) { try { return decryptBase64(content, KEY1); } catch (Exception var2) { return ""; } } public static String decryptBase64(String content, String password) { try { return new String(decrypt(Base64.decodeBase64(content), password, ""), CHARSET); } catch (Exception var3) { return ""; } } public static String encryptHex(String content) { return encryptHex(content, KEY1); } public static String encryptHex(String content, String password) { try { return parseByte2HexStr(encrypt(content.getBytes(CHARSET), password, "")); } catch (Exception var3) { return ""; } } public static String encryptBase64(String content) { return encryptBase64(content, KEY1); } public static String encryptBase64(String content, String password) { try { return Base64.encodeBase64String(encrypt(content.getBytes(CHARSET), password, "")); } catch (Exception var3) { logger.error("", var3); return ""; } } } UserQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/qianyuntong/QianYunTongProperties.java
@@ -7,18 +7,43 @@ * @Date 2025/6/6 15:03 */ public interface QianYunTongProperties { /** * 小程序appId */ String appId = "wxcc3c9058e2b294db"; /** * */ String encryptedData = "645HaSm7meo0GLKQZZvagq3JkWZXYlOfvhf8YKqNjWklpzx3IjM2S/wkmlUOz/iPvDVYRgBD2+V1WCHT6fMbOjJnR/0W9bwVGOSSaoyYpZdPR5x8f/6OR1B3e3qfJWFKJf0Za4n9JJTwStCTuMHWRIE0IgYtj3zSb2WI1AzDyLeR7MMgW0q+red2ujtrKGR4pe0NoXB2qZKHj4whBuGUiw=="; /** * */ String iv = "Zz2ZL9Yu43pp38p5CcocJA=="; /************************************开发/测试start***********************************/ // /** // * appkey // */ // String appkey = "10001104"; // /** // * 私钥地址 // */ // String privateKeyPath = "C:\\Users\\39373\\Desktop\\黔云通\\private_key_test.pem"; // /** // * 私钥地址 // */ // String privateKeyPath = "/root/server/app/key/private_key_test.pem"; // /** // * 消费者账号 // */ // String userName = "xiaofei"; // /** // * 状态 // * 1:生产环境 // * 2:测试环境 // */ // String status = "1"; // /** // * API地址 // */ // String apiUrl = "https://test-zhongtai.stqcloud.com:10070"; // /** // * 桶名 // */ // String bucketName = "bucuTest0625"; /************************************开发/测试end***********************************/ /************************************生产start***********************************/ /** * appkey */ @@ -26,11 +51,15 @@ /** * 私钥地址 */ String privateKeyPath = "/root/server/app/key/private_key_test.pem"; // String privateKeyPath = "C:\\Users\\39373\\Desktop\\黔云通\\private_key.pem"; /** * 私钥地址 */ String privateKeyPath = "/root/server/app/key/private_key.pem"; /** * 消费者账号 */ String userName = "xiaofei"; String userName = "xiwang"; /** * 状态 * 1:生产环境 @@ -40,11 +69,23 @@ /** * API地址 */ String apiUrl = "https://test-zhongtai.stqcloud.com:10070"; String apiUrl = "http://jjzhongtai.stqcloud.com:10010"; /** * 桶名 */ String bucketName = "qyt20250702"; /************************************生产end***********************************/ /** * 小程序appId */ String appId = "wxcc3c9058e2b294db"; /** * HOS的基础路径(公共前缀) */ String endPoint = "119.4.112.68:27741"; String endPoint = "http://119.4.112.68:27741/v1"; /** * 账户的ID */ UserQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/qianyuntong/SMSUtil.java
@@ -2,8 +2,10 @@ import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.google.gson.Gson; import com.open.common.util.OpenApiClient; import com.open.common.util.SystemParameterNames; import com.stylefeng.guns.modular.system.util.qianyuntong.model.SendSmsRequest; import lombok.extern.slf4j.Slf4j; import java.text.SimpleDateFormat; @@ -64,4 +66,61 @@ } return object.getString("code"); } public static void main(String[] args) { SendSmsRequest request = new SendSmsRequest(); request.setDestAddress("15828353127"); request.setTemplateId("TPL202410290001"); Map<String, String> templateParams = new HashMap<>(); templateParams.put("code", "1234"); request.setTemplateParams(templateParams); request.setCode("code"); request.setSpId("T8d5hdfg"); SMSUtil.sendSms(request); } /** * 根据模板发送短信 * * @param request * @return */ public static Boolean sendSms(SendSmsRequest request) { //请求路径 String url = QianYunTongProperties.apiUrl + "/openapi/rest/1.0/sendSmsByTpl"; //私钥文件 String skprivateKeyFile = QianYunTongProperties.privateKeyPath; //注意:私钥文件需要开发者手动新建.pem文件,将委办局提供的私钥串复制进文件里用于sign加密 String appKey = QianYunTongProperties.appkey;//appkey Map<String, String> headers = new HashMap<>(); headers.put("Content-Type", "application/json"); Map<String, Object> contentMap = new HashMap<String, Object>(); Date nowdate = new Date(); SimpleDateFormat date = new SimpleDateFormat("yyyyMMddHHmmss"); String timeStamp = date.format(nowdate); String messageId = UUID.randomUUID().toString().replaceAll("-", ""); contentMap.put(SystemParameterNames.getAppKey(), appKey); contentMap.put(SystemParameterNames.getMessage_id(), messageId); contentMap.put(SystemParameterNames.getUserName(), QianYunTongProperties.userName); contentMap.put(SystemParameterNames.getStatus(), QianYunTongProperties.status); contentMap.put("content", new Gson().toJson(request)); log.info("【根据模板发送短信】请求地址:" + url); log.info("【根据模板发送短信】请求参数:" + JSON.toJSONString(contentMap)); String result = OpenApiClient.sendCommonHttpRequst(url, headers, "POST", skprivateKeyFile, timeStamp, contentMap); log.info("【根据模板发送短信】请求结果:" + result); JSONObject jsonObject = JSON.parseObject(result); String retCode = jsonObject.getString("retCode"); if (!"0".equals(retCode)) { log.error("【根据模板发送短信】请求失败:" + result); throw new RuntimeException("【根据模板发送短信】请求失败:" + result); } JSONObject object = jsonObject.getJSONObject("object"); String status = object.getString("status"); if (!"0".equals(status)) { log.error("【根据模板发送短信】失败:" + object.toJSONString()); throw new RuntimeException("【根据模板发送短信】失败:" + object.toJSONString()); } return true; } } UserQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/qianyuntong/UserUtil.java
@@ -1,15 +1,11 @@ package com.stylefeng.guns.modular.system.util.qianyuntong; import cn.hutool.http.HttpRequest; import cn.hutool.http.HttpResponse; import cn.hutool.http.HttpUtil; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.google.gson.Gson; import com.open.common.util.OpenApiClient; import com.open.common.util.SystemParameterNames; import com.stylefeng.guns.modular.system.util.UUIDUtil; import com.stylefeng.guns.modular.system.util.qianyuntong.model.*; import lombok.extern.slf4j.Slf4j; @@ -215,43 +211,5 @@ } /** * 微信小程序登录 * * @param code * @return */ public static LoginWeChatXiao loginWeChatXiao(String code) { HttpRequest post = HttpUtil.createPost("https://casme.teamshub.com/webapp-backstage/ajax/loginWeChatXiao/v1.0"); post.header("Content-Type", "text/plain;charset=UTF-8"); post.header("Accept-encodeing", "UTF-8"); JSONObject body = new JSONObject(); body.put("version", "1.0"); try { body.put("id", UUIDUtil.getRandomCode(6)); } catch (Exception e) { throw new RuntimeException(e); } body.put("type", "loginWeChatXiao"); body.put("action", "request"); body.put("code", code); body.put("appId", QianYunTongProperties.appId); body.put("encryptedData", QianYunTongProperties.encryptedData); body.put("iv", QianYunTongProperties.iv); post.body(body.toJSONString()); HttpResponse execute = post.execute(); if (200 != execute.getStatus()) { log.error("微信登录失败"); return null; } JSONObject jsonObject = JSON.parseObject(execute.body()); Integer status = jsonObject.getInteger("status"); if (0 != status) { log.error("微信登录失败:" + jsonObject.getString("desc")); return null; } LoginWeChatXiao loginWeChatXiao = jsonObject.getObject("data", LoginWeChatXiao.class); return loginWeChatXiao; } } UserQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/qianyuntong/model/SendSmsRequest.java
New file @@ -0,0 +1,33 @@ package com.stylefeng.guns.modular.system.util.qianyuntong.model; import lombok.Data; import java.util.Map; /** * @author zhibing.pu * @Date 2025/7/2 15:41 */ @Data public class SendSmsRequest { /** * 目标地址 */ private String destAddress; /** * 模板id */ private String templateId; /** * 参数集合 */ private Map<String, String> templateParams; /** * 模板中占位符key */ private String code; /** * 签名SPID */ private String spId; } UserQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/taxi/service/impl/OrderTaxiServiceImpl.java
@@ -204,6 +204,12 @@ public synchronized ResultUtil<BaseWarpper> taxiOrder(OrderTaxi orderTaxi, Integer uid) throws Exception { //定义用户所属公司 UserInfo userInfo1 = userInfoService.selectById(uid); if (null == userInfo1 || userInfo1.getFlag() == 3) { return ResultUtil.error("无效的账户"); } if (2 == userInfo1.getState()) { return ResultUtil.error("账号已被冻结,请联系管理员"); } Company query = companyCityService.query(String.valueOf(orderTaxi.getStartLon()), String.valueOf(orderTaxi.getStartLat())); if(null == query){ return ResultUtil.error("出发点暂未开通"); @@ -613,10 +619,10 @@ if(userInfo.getBalance() != null && userInfo.getBalance() < query.getMoney()){ return ResultUtil.error("余额不足,无法完成支付"); } resultUtil= appOrderController.moneyPay(id,userInfo.getId(),query.getMoney()); if(resultUtil.getCode()==500){ return ResultUtil.error("电子余额不足,无法完成支付"); } // resultUtil= appOrderController.moneyPay(id,userInfo.getId(),query.getMoney()); // if(resultUtil.getCode()==500){ // return ResultUtil.error("电子余额不足,无法完成支付"); // } userInfo.setBalance(new BigDecimal(userInfo.getBalance()).subtract(new BigDecimal(query.getMoney())).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); //添加交易明细 @@ -1880,7 +1886,7 @@ userRedPacketRecord.setUserId(orderTaxi.getUserId()); userRedPacketRecordService.insert(userRedPacketRecord); } appOrderController.moneyPay(orderTaxi.getId(),orderTaxi.getUserId(),money); // appOrderController.moneyPay(orderTaxi.getId(),orderTaxi.getUserId(),money); return ResultUtil.success(baseWarpper); } @@ -2163,10 +2169,10 @@ if(userInfo.getBalance() == null || userInfo.getBalance() < money){ return ResultUtil.error("余额不足,无法完成支付"); } resultUtil= appOrderController.moneyPay(orderId,userInfo.getId(),money); if(resultUtil.getCode()==500){ return ResultUtil.error("电子余额不足,无法完成支付"); } // resultUtil= appOrderController.moneyPay(orderId,userInfo.getId(),money); // if(resultUtil.getCode()==500){ // return ResultUtil.error("电子余额不足,无法完成支付"); // } userInfo.setBalance(new BigDecimal(userInfo.getBalance()).subtract(new BigDecimal(money)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); SysIntegral query1 = sysIntegralMapper.query(orderTaxi.getCompanyId()); UserQYTTravel/guns-admin/src/main/resources/application-dev.yml
New file @@ -0,0 +1,116 @@ server: port: 8006 guns: swagger-open: true #是否开启swagger (true/false) kaptcha-open: false #是否开启登录时验证码 (true/false) file-upload-path: d:/tmp #文件上传目录(不配置的话为java.io.tmpdir目录) picture-server-address: http://192.168.0.43/resources/ #图片服务器地址 spring-session-open: false #是否开启spring session,如果是多机环境需要开启(true/false) session-invalidate-time: 1800 #session失效时间(只在单机环境下生效,多机环境在SpringSessionConfig类中配置) 单位:秒 session-validation-interval: 900 #多久检测一次失效的session(只在单机环境下生效) 单位:秒 spring: application: name: user-server profiles: # active: dev active: prod mvc: static-path-pattern: /static/** view: prefix: /WEB-INF/view devtools: restart: enabled: false additional-paths: src/main/java exclude: static/**,WEB-INF/view/** servlet: multipart: max-request-size: 100MB max-file-size: 100MB redis: host: 172.21.35.151 port: 6512 password: SC_cache@20#25 database: 0 timeout: 1000 cluster: nodes: 172.21.35.151:6512,172.21.35.152:6512,172.21.35.153:6512,172.21.35.151:6513,172.21.35.152:6513,172.21.35.153:6513 mybatis-plus: typeAliasesPackage: com.stylefeng.guns.modular configuration: log-impl: org.apache.ibatis.logging.slf4j.Slf4jImpl eureka: client: service-url: #注册中心地址 defaultZone: http://sinata:sinata@127.0.0.1:8000/eureka #启用身份验证的方式连接 register-with-eureka: true #在注册中心进行注册 fetch-registry: true #从Eureka中获取注册信息。 --- #配置Swagger接口扫描范围 swagger: base-package: com.stylefeng.guns.modular spring: datasource: url: jdbc:mysql://172.21.35.140:8066/traffic_scdb?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=CONVERT_TO_NULL&useSSL=false&serverTimezone=Asia/Shanghai username: traffic_scusr password: QYT_sc@20#25 db-name: traffic_scdb #用来搜集数据库的所有表 filters: wall,mergeStat --- spring: data: mongodb: uri: mongodb://qyt_jtcx:qyt_jtcx2025@172.21.35.195:27017,172.21.35.196:27017/traveling_track --- wx: grantType: authorization_code #填authorization_code appid: 111 #应用唯一标识,在微信开放平台提交应用审核通过后获得 appSecret: 111 #应用密钥AppSecret,在微信开放平台提交应用审核通过后获得 appletsAppid: wxcc3c9058e2b294db #小程序APPid appletsAppSecret: 5610fc6126255ca5f7bd9fa4330338b6 # mchId: 111 #微信支付分配的商户号 key: 111 #key为商户平台设置的密钥key: --- alipay: appid: 111 #应用程序唯一标识 appPrivateKey: 111 #开发者应用私钥 alipayPublicKey: ; #应用公钥 alipay_public_key: 111 #支付宝公钥 --- juhe: #聚合数据 appKey: 111 # --- #支付回调地址 #正式环境 callbackPath: https://traffic.qytzt.cn/user --- #交通部推送数据功能开关 pushMinistryOfTransport: false