18 changed files with 471 additions and 51 deletions
-
4pom.xml
-
2src/main/java/com/example/demo/Util/BaseDES.java
-
107src/main/java/com/example/demo/Util/DESGB.java
-
227src/main/java/com/example/demo/Util/GoldTistV2.java
-
21src/main/java/com/example/demo/controller/AuditController.java
-
14src/main/java/com/example/demo/controller/ConsumeController.java
-
1src/main/java/com/example/demo/domain/entity/DetailY.java
-
4src/main/java/com/example/demo/domain/vo/Meium.java
-
3src/main/java/com/example/demo/mapper/ConsumeMapper.java
-
36src/main/java/com/example/demo/mapper/StatisticsMapper.java
-
12src/main/java/com/example/demo/serviceImpl/AuditServiceImpl.java
-
7src/main/java/com/example/demo/serviceImpl/ConsumeServiceImpl.java
-
29src/main/java/com/example/demo/serviceImpl/RechargeServiceImpl.java
-
1src/main/java/com/example/demo/sevice/ConsumeService.java
-
2src/main/resources/application.yml
-
3src/main/resources/mapper/ConsumeMapper.xml
-
8src/main/resources/mapper/DetailYMapper.xml
-
41src/main/resources/mapper/StatisticsMapper.xml
@ -0,0 +1,107 @@ |
|||||
|
package com.example.demo.Util; |
||||
|
|
||||
|
|
||||
|
import java.security.*; |
||||
|
import javax.crypto.*; |
||||
|
|
||||
|
public class DESGB { |
||||
|
private static String strDefaultKey = "testhlsoft"; |
||||
|
|
||||
|
private Cipher encryptCipher = null; |
||||
|
|
||||
|
private Cipher decryptCipher = null; |
||||
|
|
||||
|
public static String byteArr2HexStr(byte[] arrB) throws Exception { |
||||
|
int iLen = arrB.length; |
||||
|
|
||||
|
StringBuffer sb = new StringBuffer(iLen * 2); |
||||
|
for (int i = 0; i < iLen; i++) { |
||||
|
int intTmp = arrB[i]; |
||||
|
|
||||
|
while (intTmp < 0) { |
||||
|
intTmp = intTmp + 256; |
||||
|
} |
||||
|
|
||||
|
if (intTmp < 16) { |
||||
|
sb.append("0"); |
||||
|
} |
||||
|
sb.append(Integer.toString(intTmp, 16)); |
||||
|
} |
||||
|
return sb.toString(); |
||||
|
} |
||||
|
|
||||
|
public static byte[] hexStr2ByteArr(String strIn) throws Exception { |
||||
|
byte[] arrB = strIn.getBytes(); |
||||
|
int iLen = arrB.length; |
||||
|
|
||||
|
byte[] arrOut = new byte[iLen / 2]; |
||||
|
for (int i = 0; i < iLen; i = i + 2) { |
||||
|
String strTmp = new String(arrB, i, 2); |
||||
|
arrOut[i / 2] = (byte) Integer.parseInt(strTmp, 16); |
||||
|
} |
||||
|
return arrOut; |
||||
|
} |
||||
|
|
||||
|
public DESGB() throws Exception { |
||||
|
this(strDefaultKey); |
||||
|
} |
||||
|
|
||||
|
public DESGB(String strKey) throws Exception { |
||||
|
|
||||
|
Key key = getKey(strKey.getBytes()); |
||||
|
|
||||
|
encryptCipher = Cipher.getInstance("DES"); |
||||
|
encryptCipher.init(Cipher.ENCRYPT_MODE, key); |
||||
|
|
||||
|
decryptCipher = Cipher.getInstance("DES"); |
||||
|
decryptCipher.init(Cipher.DECRYPT_MODE, key); |
||||
|
} |
||||
|
|
||||
|
public byte[] encrypt(byte[] arrB) throws Exception { |
||||
|
return encryptCipher.doFinal(arrB); |
||||
|
} |
||||
|
|
||||
|
public String encrypt(String strIn) throws Exception { |
||||
|
return byteArr2HexStr(encrypt(strIn.getBytes())); |
||||
|
} |
||||
|
|
||||
|
public byte[] decrypt(byte[] arrB) throws Exception { |
||||
|
return decryptCipher.doFinal(arrB); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @功能描述: 解决中文乱码问题 |
||||
|
* @开发人员: 弘历研发部 刘志红 于 2024-1-28上午11:27:38 创建 |
||||
|
* @参数介绍: @param strIn |
||||
|
* @参数介绍: @return |
||||
|
* @参数介绍: @throws Exception |
||||
|
* @返回数据: String |
||||
|
* @版本编号: V1.0 |
||||
|
*/ |
||||
|
public String decrypt(String strIn) throws Exception { |
||||
|
return new String(decrypt(hexStr2ByteArr(strIn)),"UTF-8"); |
||||
|
} |
||||
|
|
||||
|
private Key getKey(byte[] arrBTmp) throws Exception { |
||||
|
|
||||
|
byte[] arrB = new byte[8]; |
||||
|
|
||||
|
for (int i = 0; i < arrBTmp.length && i < arrB.length; i++) { |
||||
|
arrB[i] = arrBTmp[i]; |
||||
|
} |
||||
|
|
||||
|
Key key = new javax.crypto.spec.SecretKeySpec(arrB, "DES"); |
||||
|
|
||||
|
return key; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
public static void main(String args[]) { |
||||
|
try { |
||||
|
DESGB d = new DESGB(); |
||||
|
System.out.println(d.decrypt("d19f27abb3486c689304600788c604e700abf96d6bd1c9ca")); |
||||
|
} catch (Exception e) { |
||||
|
e.printStackTrace(); |
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,227 @@ |
|||||
|
package com.example.demo.Util; |
||||
|
|
||||
|
import java.io.BufferedReader; |
||||
|
import java.io.IOException; |
||||
|
import java.io.InputStream; |
||||
|
import java.io.InputStreamReader; |
||||
|
import java.net.HttpURLConnection; |
||||
|
import java.net.URL; |
||||
|
import java.net.URLEncoder; |
||||
|
import java.security.MessageDigest; |
||||
|
import java.security.NoSuchAlgorithmException; |
||||
|
import java.util.ArrayList; |
||||
|
import java.util.Collections; |
||||
|
import java.util.List; |
||||
|
import java.util.Random; |
||||
|
|
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* @开发目的: 测试使用 |
||||
|
* @开发人员: 弘历研发部 刘志红 |
||||
|
* @开发时间: 2024-1-26下午1:42:18 |
||||
|
* @软件版本: V1.0 |
||||
|
*/ |
||||
|
public class GoldTistV2 { |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
private static String url = "http://hcm.rzfwq.com/hwhcnewA/"; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* <pre> |
||||
|
* 发送不带参数的GET的HTTP请求 |
||||
|
* </pre> |
||||
|
* |
||||
|
* @param reqUrl HTTP请求URL |
||||
|
* @return HTTP响应的字符串 |
||||
|
*/ |
||||
|
public static String doGet(String reqUrl) { |
||||
|
HttpURLConnection url_con = null; |
||||
|
String responseContent = null; |
||||
|
try { |
||||
|
StringBuffer params = new StringBuffer(); |
||||
|
String queryUrl = reqUrl; |
||||
|
int paramIndex = reqUrl.indexOf("?"); |
||||
|
|
||||
|
if (paramIndex > 0) { |
||||
|
queryUrl = reqUrl.substring(0, paramIndex); |
||||
|
String parameters = reqUrl.substring(paramIndex + 1, reqUrl.length()); |
||||
|
String[] paramArray = parameters.split("&"); |
||||
|
for (int i = 0; i < paramArray.length; i++) { |
||||
|
String string = paramArray[i]; |
||||
|
int index = string.indexOf("="); |
||||
|
if (index > 0) { |
||||
|
String parameter = string.substring(0, index); |
||||
|
String value = string.substring(index + 1, string.length()); |
||||
|
params.append(parameter); |
||||
|
params.append("="); |
||||
|
params.append(URLEncoder.encode(value, "UTF-8")); |
||||
|
params.append("&"); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
params = params.deleteCharAt(params.length() - 1); |
||||
|
} |
||||
|
|
||||
|
URL url = new URL(queryUrl); |
||||
|
url_con = (HttpURLConnection) url.openConnection(); |
||||
|
url_con.setRequestMethod("GET"); |
||||
|
System.setProperty("sun.net.client.defaultConnectTimeout", String.valueOf(500000));// (单位:毫秒)jdk1.4换成这个,连接超时 |
||||
|
System.setProperty("sun.net.client.defaultReadTimeout", String.valueOf(500000)); // (单位:毫秒)jdk1.4换成这个,读操作超时 |
||||
|
// url_con.setConnectTimeout(5000);//(单位:毫秒)jdk |
||||
|
// 1.5换成这个,连接超时 |
||||
|
// url_con.setReadTimeout(5000);//(单位:毫秒)jdk 1.5换成这个,读操作超时 |
||||
|
url_con.setDoOutput(true); |
||||
|
byte[] b = params.toString().getBytes(); |
||||
|
url_con.getOutputStream().write(b, 0, b.length); |
||||
|
url_con.getOutputStream().flush(); |
||||
|
url_con.getOutputStream().close(); |
||||
|
InputStream in = url_con.getInputStream(); |
||||
|
BufferedReader rd = new BufferedReader(new InputStreamReader(in, "UTF-8")); |
||||
|
String tempLine = rd.readLine(); |
||||
|
StringBuffer temp = new StringBuffer(); |
||||
|
String crlf = System.getProperty("line.separator"); |
||||
|
while (tempLine != null) { |
||||
|
temp.append(tempLine); |
||||
|
temp.append(crlf); |
||||
|
tempLine = rd.readLine(); |
||||
|
} |
||||
|
responseContent = temp.toString(); |
||||
|
rd.close(); |
||||
|
in.close(); |
||||
|
} |
||||
|
catch (IOException e) { |
||||
|
e.printStackTrace(); |
||||
|
}finally { |
||||
|
if (url_con != null) { |
||||
|
url_con.disconnect(); |
||||
|
} |
||||
|
} |
||||
|
return responseContent; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 生成 MD5 签名 |
||||
|
* |
||||
|
* @param params 待签名的参数数组 |
||||
|
* @param secretKey 密钥 |
||||
|
* @return 签名的 MD5 哈希值,若出现异常则返回 null |
||||
|
*/ |
||||
|
public static String generateSignature(String[] params, String secretKey) { |
||||
|
// 将参数数组转换为列表,以便进行排序 |
||||
|
List<String> paramList = new ArrayList<String>(); |
||||
|
Collections.addAll(paramList, params); |
||||
|
// 对参数列表进行排序 |
||||
|
Collections.sort(paramList); |
||||
|
|
||||
|
// 拼接排序后的参数 |
||||
|
StringBuilder paramString = new StringBuilder(); |
||||
|
for (String param : paramList) { |
||||
|
paramString.append(param); |
||||
|
} |
||||
|
|
||||
|
// 拼接密钥 |
||||
|
paramString.append(secretKey); |
||||
|
|
||||
|
try { |
||||
|
// 获取 MD5 消息摘要实例 |
||||
|
MessageDigest md = MessageDigest.getInstance("MD5"); |
||||
|
// 计算摘要,明确指定字符编码为 UTF-8 |
||||
|
byte[] digest = md.digest(paramString.toString().getBytes("UTF-8")); |
||||
|
// 将字节数组转换为十六进制字符串 |
||||
|
StringBuilder hexString = new StringBuilder(); |
||||
|
for (byte b : digest) { |
||||
|
String hex = Integer.toHexString(0xFF & b); |
||||
|
if (hex.length() == 1) { |
||||
|
hexString.append('0'); |
||||
|
} |
||||
|
hexString.append(hex); |
||||
|
} |
||||
|
return hexString.toString(); |
||||
|
} catch (NoSuchAlgorithmException e) { |
||||
|
e.printStackTrace(); |
||||
|
return null; |
||||
|
} catch (java.io.UnsupportedEncodingException e) { |
||||
|
e.printStackTrace(); |
||||
|
return null; |
||||
|
} |
||||
|
} |
||||
|
/** |
||||
|
* @功能描述: 生成随机数 |
||||
|
* @开发人员: 弘历研发部 刘志红 于 2024-1-25下午5:45:36 创建 |
||||
|
* @参数介绍: @param len |
||||
|
* @参数介绍: @return |
||||
|
* @返回数据: String |
||||
|
* @版本编号: V1.0 |
||||
|
*/ |
||||
|
public static String RandomUid(int len){ |
||||
|
String characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghjklmnpqrstuvwxyz23456789"; |
||||
|
StringBuilder result = new StringBuilder(); |
||||
|
Random rnd = new Random(); |
||||
|
int strlen = characters.length(); |
||||
|
while (result.length() < 8) { // length of the random string. |
||||
|
int index = (int) (rnd.nextFloat() * strlen); |
||||
|
result.append(characters.charAt(index)); |
||||
|
} |
||||
|
return "JB"+result.toString(); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 类型说明: |
||||
|
* |
||||
|
55 免费金币 金币系统退商品 |
||||
|
56 永久金币 金币系统退商品 |
||||
|
57 任务金币 金币系统退商品 |
||||
|
58 免费金币 金币系统退金币 |
||||
|
59 任务金币 金币系统退金币 |
||||
|
* @功能描述: 金币平台更新客户金币 |
||||
|
* @开发人员: 弘历研发部 刘志红 于 2025-3-21下午1:58:13 创建 |
||||
|
* @参数介绍: @param jwcode 账号 |
||||
|
* @参数介绍: @param lx 类型 |
||||
|
* @参数介绍: @param jbs 金币数量 |
||||
|
* @参数介绍: @param remark 备注 |
||||
|
* @参数介绍: @param yjjb 永久金币 |
||||
|
* @参数介绍: @param czr 操作人 |
||||
|
* @参数介绍: @param goodsname 商品名称 |
||||
|
* @参数介绍: @return |
||||
|
* @返回数据: String 返回状态1加成功2减成功其他失败 -5 金币不足 -6 类型错误 -7签名错误 |
||||
|
* @版本编号: V1.0 |
||||
|
*/ |
||||
|
public static String addCoinNew(String jwcode, int lx, double jbs, |
||||
|
String remark,double yjjb,String czr,String goodsname){ |
||||
|
//查错误使用 |
||||
|
String sjzfc = RandomUid(10); |
||||
|
String resp = ""; |
||||
|
try { |
||||
|
DESGB desjbkc = new DESGB("Jbxt.205"); |
||||
|
String sk = "jwcode="+jwcode+"&number="+jbs+"&uid="+sjzfc+"&remark="+ |
||||
|
remark+"&czr="+czr+"&yjjb="+yjjb+"&czpt=4&goodsname="+goodsname+"&type="+lx; |
||||
|
System.out.println("签名前:"+sk); |
||||
|
String sign = generateSignature(sk.split("&"),"222251821eba7efab6d48e388b8f6baa"); |
||||
|
sk = desjbkc.encrypt(new String(sk.getBytes(), "UTF-8")); |
||||
|
System.out.println(url+"goldUpdate_sign.gold?app=4&sk="+sk+"&sign="+sign); |
||||
|
resp = doGet(url+"goldUpdate_sign.gold?app=4&sk="+sk+"&sign="+sign); |
||||
|
}catch (Exception e){ |
||||
|
System.out.println("加金币异常"+e.toString()); |
||||
|
} |
||||
|
System.out.println(resp); |
||||
|
return resp; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
public static void main(String[] args) throws Exception { |
||||
|
//调用demo |
||||
|
addCoinNew("94226013",55,-1,"退1金币测试",0,"刘志宏","文章11"); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
} |
@ -0,0 +1,41 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8" ?> |
||||
|
<!DOCTYPE mapper |
||||
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
|
|
||||
|
<mapper namespace="com.example.demo.mapper.StatisticsMapper"> |
||||
|
<select id="getMeium" resultType="com.example.demo.domain.vo.Meium"> |
||||
|
SELECT |
||||
|
u.area, |
||||
|
SUM(d.recharge_coin) / 100 AS rechargeSumCoin, |
||||
|
SUM(d.free_coin) / 100 AS freeSumCoin, |
||||
|
SUM(d.task_coin) / 100 AS taskSumCoin, |
||||
|
(SUM(d.recharge_coin) + SUM(d.free_coin) + SUM(d.task_coin)) / 100 AS totalRechargeSum |
||||
|
FROM |
||||
|
detail_y d |
||||
|
LEFT JOIN |
||||
|
user u |
||||
|
ON |
||||
|
u.jwcode = d.jwcode |
||||
|
<where> |
||||
|
<!-- 动态判断 update_type 是否传入 --> |
||||
|
<if test="updateType != null"> |
||||
|
AND update_type = #{updateType} |
||||
|
</if> |
||||
|
<!-- 动态判断时间范围 --> |
||||
|
<choose> |
||||
|
<when test="searchStartTime != null and searchEndTime != null"> |
||||
|
AND DATE(d.create_time) BETWEEN DATE(#{searchStartTime}) AND DATE(#{searchEndTime}) |
||||
|
</when> |
||||
|
</choose> |
||||
|
</where> |
||||
|
GROUP BY |
||||
|
u.area |
||||
|
<if test="sortField != null and sortField != ''"> |
||||
|
ORDER BY ${sortField} |
||||
|
<if test="sortOrder != null and sortOrder != ''"> |
||||
|
${sortOrder} |
||||
|
</if> |
||||
|
</if> |
||||
|
</select> |
||||
|
</mapper> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue