Compare commits
65 Commits
wangxinyua
...
master
Author | SHA1 | Date |
---|---|---|
|
9890af8f98 | |
|
3ec14d29f0 | |
|
81de100819 | |
|
6c330c126e | |
|
637411436c | |
|
aa7d1d5015 | |
|
60056f4ddc | |
|
5fd898b83d | |
|
7df5e777bd | |
|
24b4f9cd22 | |
|
0566362e70 | |
|
5e40809b6e | |
|
c2e5a0611a | |
|
3a04eb58f9 | |
|
da0d8c4400 | |
|
099e3f1452 | |
|
f4d708e7c9 | |
|
5839d305d9 | |
|
7b4e960de9 | |
|
f92f89f49e | |
|
32214230c4 | |
|
75c6950400 | |
|
7c71232dc7 | |
|
4981ed3c6b | |
|
d62d8d48b6 | |
|
12dc2bde93 | |
|
1cd0ef9c49 | |
|
3c8577ec54 | |
|
e83b040fe8 | |
|
beab7904bd | |
|
5615fa62e5 | |
|
571fe8f37d | |
|
5ef7b1c71c | |
|
f2e999e71f | |
|
66d7981199 | |
|
748f3e140d | |
|
5e17645aa6 | |
|
ea1184dcea | |
|
e9590be8fa | |
|
d7975931da | |
|
0bd2727388 | |
|
d432ae703c | |
|
96b82f0d3f | |
|
e5740f38cf | |
|
402616bd4f | |
|
f67fbb6380 | |
|
0aed87c444 | |
|
3c72e49be8 | |
|
164ffd354d | |
|
482d9a3eab | |
|
180e311b89 | |
|
fd752340b5 | |
|
b7c22080da | |
|
d011dce3ea | |
|
5bb3949e28 | |
|
145a88c3c9 | |
|
734511b6ce | |
|
49d185e7a6 | |
|
e0f1886980 | |
|
d1733dd9a3 | |
|
71ead9ebfd | |
|
7c9091b6bf | |
|
b98ec80a4f | |
|
e895310e0a | |
|
3f9602922a |
12
pom.xml
12
pom.xml
|
@ -17,6 +17,16 @@
|
|||
|
||||
<dependencies>
|
||||
|
||||
|
||||
|
||||
<!--引入支付宝支付 -->
|
||||
<dependency>
|
||||
<groupId>com.alipay.sdk</groupId>
|
||||
<artifactId>alipay-easysdk</artifactId>
|
||||
<version>2.2.1</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>com.alipay.sdk</groupId>
|
||||
<artifactId>alipay-sdk-java</artifactId>
|
||||
|
@ -89,6 +99,7 @@
|
|||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>3.2.6</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
|
@ -101,6 +112,7 @@
|
|||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-deploy-plugin</artifactId>
|
||||
<version>2.8.2</version>
|
||||
<configuration>
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
package com.muyu.config.util;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author A3385
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class CodeEntity implements Serializable {
|
||||
|
||||
|
||||
private String phone;
|
||||
|
||||
private String code;
|
||||
}
|
|
@ -0,0 +1,314 @@
|
|||
package com.muyu.config.util;
|
||||
|
||||
import com.muyu.common.core.utils.StringUtils;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.NameValuePair;
|
||||
import org.apache.http.client.HttpClient;
|
||||
import org.apache.http.client.entity.UrlEncodedFormEntity;
|
||||
import org.apache.http.client.methods.HttpDelete;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.client.methods.HttpPut;
|
||||
import org.apache.http.conn.ClientConnectionManager;
|
||||
import org.apache.http.conn.scheme.Scheme;
|
||||
import org.apache.http.conn.scheme.SchemeRegistry;
|
||||
import org.apache.http.conn.ssl.SSLSocketFactory;
|
||||
import org.apache.http.entity.ByteArrayEntity;
|
||||
import org.apache.http.entity.StringEntity;
|
||||
import org.apache.http.impl.client.DefaultHttpClient;
|
||||
import org.apache.http.message.BasicNameValuePair;
|
||||
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.TrustManager;
|
||||
import javax.net.ssl.X509TrustManager;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
import java.security.KeyManagementException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class HttpUtils {
|
||||
|
||||
/**
|
||||
* get
|
||||
*
|
||||
* @param host
|
||||
* @param path
|
||||
* @param method
|
||||
* @param headers
|
||||
* @param querys
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public static HttpResponse doGet(String host, String path, String method,
|
||||
Map<String, String> headers,
|
||||
Map<String, String> querys)
|
||||
throws Exception {
|
||||
HttpClient httpClient = wrapClient(host);
|
||||
|
||||
HttpGet request = new HttpGet(buildUrl(host, path, querys));
|
||||
for (Map.Entry<String, String> e : headers.entrySet()) {
|
||||
request.addHeader(e.getKey(), e.getValue());
|
||||
}
|
||||
|
||||
return httpClient.execute(request);
|
||||
}
|
||||
|
||||
/**
|
||||
* post form
|
||||
*
|
||||
* @param host
|
||||
* @param path
|
||||
* @param method
|
||||
* @param headers
|
||||
* @param querys
|
||||
* @param bodys
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public static HttpResponse doPost(String host, String path, String method,
|
||||
Map<String, String> headers,
|
||||
Map<String, String> querys,
|
||||
Map<String, String> bodys)
|
||||
throws Exception {
|
||||
HttpClient httpClient = wrapClient(host);
|
||||
|
||||
HttpPost request = new HttpPost(buildUrl(host, path, querys));
|
||||
for (Map.Entry<String, String> e : headers.entrySet()) {
|
||||
request.addHeader(e.getKey(), e.getValue());
|
||||
}
|
||||
|
||||
if (bodys != null) {
|
||||
List<NameValuePair> nameValuePairList = new ArrayList<NameValuePair>();
|
||||
|
||||
for (String key : bodys.keySet()) {
|
||||
nameValuePairList.add(new BasicNameValuePair(key, bodys.get(key)));
|
||||
}
|
||||
UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(nameValuePairList, "utf-8");
|
||||
formEntity.setContentType("application/x-www-form-urlencoded; charset=UTF-8");
|
||||
request.setEntity(formEntity);
|
||||
}
|
||||
|
||||
return httpClient.execute(request);
|
||||
}
|
||||
|
||||
/**
|
||||
* Post String
|
||||
*
|
||||
* @param host
|
||||
* @param path
|
||||
* @param method
|
||||
* @param headers
|
||||
* @param querys
|
||||
* @param body
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public static HttpResponse doPost(String host, String path, String method,
|
||||
Map<String, String> headers,
|
||||
Map<String, String> querys,
|
||||
String body)
|
||||
throws Exception {
|
||||
HttpClient httpClient = wrapClient(host);
|
||||
|
||||
HttpPost request = new HttpPost(buildUrl(host, path, querys));
|
||||
for (Map.Entry<String, String> e : headers.entrySet()) {
|
||||
request.addHeader(e.getKey(), e.getValue());
|
||||
}
|
||||
|
||||
if (StringUtils.isNotBlank(body)) {
|
||||
request.setEntity(new StringEntity(body, "utf-8"));
|
||||
}
|
||||
|
||||
return httpClient.execute(request);
|
||||
}
|
||||
|
||||
/**
|
||||
* Post stream
|
||||
*
|
||||
* @param host
|
||||
* @param path
|
||||
* @param method
|
||||
* @param headers
|
||||
* @param querys
|
||||
* @param body
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public static HttpResponse doPost(String host, String path, String method,
|
||||
Map<String, String> headers,
|
||||
Map<String, String> querys,
|
||||
byte[] body)
|
||||
throws Exception {
|
||||
HttpClient httpClient = wrapClient(host);
|
||||
|
||||
HttpPost request = new HttpPost(buildUrl(host, path, querys));
|
||||
for (Map.Entry<String, String> e : headers.entrySet()) {
|
||||
request.addHeader(e.getKey(), e.getValue());
|
||||
}
|
||||
|
||||
if (body != null) {
|
||||
request.setEntity(new ByteArrayEntity(body));
|
||||
}
|
||||
|
||||
return httpClient.execute(request);
|
||||
}
|
||||
|
||||
/**
|
||||
* Put String
|
||||
* @param host
|
||||
* @param path
|
||||
* @param method
|
||||
* @param headers
|
||||
* @param querys
|
||||
* @param body
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public static HttpResponse doPut(String host, String path, String method,
|
||||
Map<String, String> headers,
|
||||
Map<String, String> querys,
|
||||
String body)
|
||||
throws Exception {
|
||||
HttpClient httpClient = wrapClient(host);
|
||||
|
||||
HttpPut request = new HttpPut(buildUrl(host, path, querys));
|
||||
for (Map.Entry<String, String> e : headers.entrySet()) {
|
||||
request.addHeader(e.getKey(), e.getValue());
|
||||
}
|
||||
|
||||
if (StringUtils.isNotBlank(body)) {
|
||||
request.setEntity(new StringEntity(body, "utf-8"));
|
||||
}
|
||||
|
||||
return httpClient.execute(request);
|
||||
}
|
||||
|
||||
/**
|
||||
* Put stream
|
||||
* @param host
|
||||
* @param path
|
||||
* @param method
|
||||
* @param headers
|
||||
* @param querys
|
||||
* @param body
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public static HttpResponse doPut(String host, String path, String method,
|
||||
Map<String, String> headers,
|
||||
Map<String, String> querys,
|
||||
byte[] body)
|
||||
throws Exception {
|
||||
HttpClient httpClient = wrapClient(host);
|
||||
|
||||
HttpPut request = new HttpPut(buildUrl(host, path, querys));
|
||||
for (Map.Entry<String, String> e : headers.entrySet()) {
|
||||
request.addHeader(e.getKey(), e.getValue());
|
||||
}
|
||||
|
||||
if (body != null) {
|
||||
request.setEntity(new ByteArrayEntity(body));
|
||||
}
|
||||
|
||||
return httpClient.execute(request);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete
|
||||
*
|
||||
* @param host
|
||||
* @param path
|
||||
* @param method
|
||||
* @param headers
|
||||
* @param querys
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public static HttpResponse doDelete(String host, String path, String method,
|
||||
Map<String, String> headers,
|
||||
Map<String, String> querys)
|
||||
throws Exception {
|
||||
HttpClient httpClient = wrapClient(host);
|
||||
|
||||
HttpDelete request = new HttpDelete(buildUrl(host, path, querys));
|
||||
for (Map.Entry<String, String> e : headers.entrySet()) {
|
||||
request.addHeader(e.getKey(), e.getValue());
|
||||
}
|
||||
|
||||
return httpClient.execute(request);
|
||||
}
|
||||
|
||||
private static String buildUrl(String host, String path, Map<String, String> querys) throws UnsupportedEncodingException {
|
||||
StringBuilder sbUrl = new StringBuilder();
|
||||
sbUrl.append(host);
|
||||
if (!StringUtils.isBlank(path)) {
|
||||
sbUrl.append(path);
|
||||
}
|
||||
if (null != querys) {
|
||||
StringBuilder sbQuery = new StringBuilder();
|
||||
for (Map.Entry<String, String> query : querys.entrySet()) {
|
||||
if (0 < sbQuery.length()) {
|
||||
sbQuery.append("&");
|
||||
}
|
||||
if (StringUtils.isBlank(query.getKey()) && !StringUtils.isBlank(query.getValue())) {
|
||||
sbQuery.append(query.getValue());
|
||||
}
|
||||
if (!StringUtils.isBlank(query.getKey())) {
|
||||
sbQuery.append(query.getKey());
|
||||
if (!StringUtils.isBlank(query.getValue())) {
|
||||
sbQuery.append("=");
|
||||
sbQuery.append(URLEncoder.encode(query.getValue(), "utf-8"));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (0 < sbQuery.length()) {
|
||||
sbUrl.append("?").append(sbQuery);
|
||||
}
|
||||
}
|
||||
|
||||
return sbUrl.toString();
|
||||
}
|
||||
|
||||
private static HttpClient wrapClient(String host) {
|
||||
HttpClient httpClient = new DefaultHttpClient();
|
||||
if (host.startsWith("https://")) {
|
||||
sslClient(httpClient);
|
||||
}
|
||||
|
||||
return httpClient;
|
||||
}
|
||||
|
||||
private static void sslClient(HttpClient httpClient) {
|
||||
try {
|
||||
SSLContext ctx = SSLContext.getInstance("TLS");
|
||||
X509TrustManager tm = new X509TrustManager() {
|
||||
@Override
|
||||
public X509Certificate[] getAcceptedIssuers() {
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public void checkClientTrusted(X509Certificate[] xcs, String str) {
|
||||
|
||||
}
|
||||
@Override
|
||||
public void checkServerTrusted(X509Certificate[] xcs, String str) {
|
||||
|
||||
}
|
||||
};
|
||||
ctx.init(null, new TrustManager[] { tm }, null);
|
||||
SSLSocketFactory ssf = new SSLSocketFactory(ctx);
|
||||
ssf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
|
||||
ClientConnectionManager ccm = httpClient.getConnectionManager();
|
||||
SchemeRegistry registry = ccm.getSchemeRegistry();
|
||||
registry.register(new Scheme("https", 443, ssf));
|
||||
} catch (KeyManagementException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
} catch (NoSuchAlgorithmException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
package com.muyu.config.util;
|
||||
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
import org.springframework.cache.annotation.CachePut;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author A3385
|
||||
*/
|
||||
|
||||
public class MsgUtil {
|
||||
//取code
|
||||
@Cacheable(key = "#phone",value = "bbb")
|
||||
public String getCacheCode(String phone){
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
//把当前注解的返回值装进去 //存code
|
||||
@CachePut(key = "#codeEntity.phone",value = "bbb")
|
||||
public String saveCacheCode(CodeEntity codeEntity){
|
||||
return codeEntity.getCode();
|
||||
}
|
||||
|
||||
public static void sendMsg(String phone, String code){
|
||||
String result = null;
|
||||
String host = "https://gyyyx1.market.alicloudapi.com";
|
||||
String path = "/sms/smsSend";
|
||||
String method = "POST";
|
||||
String appcode = "033359549f644a32858017cd76df3f88";
|
||||
Map<String, String> headers = new HashMap<String, String>();
|
||||
//最后在header中的格式(中间是英文空格)为Authorization:APPCODE 83359fd73fe94948385f570e3c139105
|
||||
headers.put("Authorization", "APPCODE " + appcode);
|
||||
Map<String, String> querys = new HashMap<String, String>();
|
||||
querys.put("mobile", phone);
|
||||
querys.put("param", "**code**:"+code+",**minute**:5");
|
||||
|
||||
//smsSignId(短信前缀)和templateId(短信模板),可登录国阳云控制台自助申请。参考文档:http://help.guoyangyun.com/Problem/Qm.html
|
||||
|
||||
querys.put("smsSignId", "2e65b1bb3d054466b82f0c9d125465e2");
|
||||
querys.put("templateId", "908e94ccf08b4476ba6c876d13f084ad");
|
||||
Map<String, String> bodys = new HashMap<String, String>();
|
||||
|
||||
|
||||
try {
|
||||
/**
|
||||
* 重要提示如下:
|
||||
* HttpUtils请从\r\n\t \t* https://github.com/aliyun/api-gateway-demo-sign-java/blob/master/src/main/java/com/aliyun/api/gateway/demo/util/HttpUtils.java\r\n\t \t* 下载
|
||||
*
|
||||
* 相应的依赖请参照
|
||||
* https://github.com/aliyun/api-gateway-demo-sign-java/blob/master/pom.xml
|
||||
*/
|
||||
HttpResponse response = HttpUtils.doPost(host, path, method, headers, querys, bodys);
|
||||
// System.out.println(response.toString());
|
||||
//获取response的body
|
||||
result = EntityUtils.toString(response.getEntity());
|
||||
System.out.println(result);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
package com.muyu.config.util;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author dori
|
||||
* @date 2024/4/17 10:18
|
||||
* @description 实名认证
|
||||
*/
|
||||
public class SfUtil {
|
||||
public static Result<Standing> query(StandingRes standingRes) {
|
||||
String host = "https://kzidcardv1.market.alicloudapi.com";
|
||||
String path = "/api-mall/api/id_card/check";
|
||||
String method = "POST";
|
||||
String appcode = "8a8d22ef01b0444e9716c26f7d089149";
|
||||
Map<String, String> headers = new HashMap<String, String>();
|
||||
//最后在header中的格式(中间是英文空格)为Authorization:APPCODE 83359fd73fe94948385f570e3c139105
|
||||
headers.put("Authorization", "APPCODE " + appcode);
|
||||
//根据API的要求,定义相对应的Content-Type
|
||||
headers.put("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
|
||||
Map<String, String> querys = new HashMap<String, String>();
|
||||
Map<String, String> bodys = new HashMap<String, String>();
|
||||
bodys.put("name", standingRes.getName());
|
||||
bodys.put("idcard", standingRes.getIdCard());
|
||||
Standing standing = new Standing();
|
||||
try {
|
||||
/**
|
||||
* 重要提示如下:
|
||||
* HttpUtils请从
|
||||
* https://github.com/aliyun/api-gateway-demo-sign-java/blob/master/src/main/java/com/aliyun/api/gateway/demo/util/HttpUtils.java
|
||||
* 下载
|
||||
*
|
||||
* 相应的依赖请参照
|
||||
* https://github.com/aliyun/api-gateway-demo-sign-java/blob/master/pom.xml
|
||||
*/
|
||||
HttpResponse response = HttpUtils.doPost(host, path, method, headers, querys, bodys);
|
||||
// System.out.println(response.toString());
|
||||
//获取response的body
|
||||
String string = EntityUtils.toString(response.getEntity());
|
||||
JSONObject jsonObject = JSONObject.parseObject(string);
|
||||
String string1 = jsonObject.getString("data");
|
||||
standing = JSONObject.parseObject(string1, Standing.class);
|
||||
if(standing.getAddress()==null){
|
||||
return Result.error(500,null);
|
||||
}
|
||||
System.out.println(string1);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return Result.success(standing);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
package com.muyu.config.util;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Author: wangxinyuan
|
||||
* @Date: 2024/8/30 上午9:34
|
||||
*/
|
||||
@Data
|
||||
public class Standing {
|
||||
|
||||
|
||||
// 姓名
|
||||
private String name;
|
||||
|
||||
// 订单号
|
||||
private String result;
|
||||
|
||||
// 订单号
|
||||
private String orderNo;
|
||||
|
||||
// 性别
|
||||
private String sex;
|
||||
|
||||
// 身份证号码
|
||||
private String idCards;
|
||||
|
||||
// 出生日期
|
||||
private String birthday;
|
||||
|
||||
// 地址
|
||||
private String address;
|
||||
|
||||
// 描述
|
||||
private String desc;
|
||||
|
||||
//状态信息
|
||||
private String message;
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package com.muyu.config.util;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Author: wangxinyuan
|
||||
* @Date: 2024/8/30 上午10:43
|
||||
*/
|
||||
@Data
|
||||
public class StandingRes {
|
||||
|
||||
private String name;
|
||||
|
||||
private String idCard;
|
||||
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
package com.muyu.system.controller;
|
||||
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.system.domain.Connector;
|
||||
import com.muyu.system.domain.ConnectorUser;
|
||||
import com.muyu.system.service.BuyService;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
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;
|
||||
|
||||
/**
|
||||
* @Author:chaiyapeng
|
||||
* @Package:com.muyu.system.controller
|
||||
* @Project:cloud-system
|
||||
* @name:BuyInterface
|
||||
* @Date:2024/9/1 14:37
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/buy")
|
||||
@Tag(name = "BuyMapper", description = "购买接口")
|
||||
public class BuyInterface {
|
||||
@Autowired
|
||||
private BuyService buyService;
|
||||
|
||||
/**
|
||||
* 购买API接口
|
||||
* @param connectorUser
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/doBuyInterface")
|
||||
public Result doBuyInterface(@RequestBody ConnectorUser connectorUser){
|
||||
return buyService.doBuyInterface(connectorUser);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,146 @@
|
|||
package com.muyu.system.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alipay.api.AlipayApiException;
|
||||
import com.alipay.api.AlipayClient;
|
||||
import com.alipay.api.DefaultAlipayClient;
|
||||
import com.alipay.api.request.AlipayTradePagePayRequest;
|
||||
import com.alipay.api.response.AlipayTradePagePayResponse;
|
||||
import com.alipay.easysdk.factory.Factory;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.system.domain.PaymentParam;
|
||||
import com.muyu.config.util.SfUtil;
|
||||
import com.muyu.config.util.StandingRes;
|
||||
import com.muyu.system.service.SysUserService;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Author: wangxinyuan
|
||||
* @Date: 2024/8/25 下午3:21
|
||||
*/
|
||||
|
||||
@RestController
|
||||
@Tag(name = "PaymentController", description = "支付接口")
|
||||
@RequestMapping("/aliyun/pay")
|
||||
public class PaymentController {
|
||||
|
||||
|
||||
//appid
|
||||
private final String APP_ID = "9021000139609995";
|
||||
//应用私钥
|
||||
private final String APP_PRIVATE_KEY = "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDMbBAf8yRmFvLx2SEfhdjdidpqWzfeRkL8d3K0Sz9DC5xxnrrUujwQF7FfbmwR43oJy1mIrMffc2Fp3vpSjWgdOMfAJy5N0GlrDb4o/3mN3pH3xElfdz7VEw9jcIhLDEsV2LP3nnrbkEKoj93gnZsuMkTnO4yfsEyCZVL6rkK01R9Pcu3tKKLrY5n30U7aE1WOuKvE3pTmxkpdXaX3Q46npP8wHOY1x6kUzyFgjFip/E4HEE91OzqaVnirt6GkWm9m0VAiUOENthEbnSzKagoVuTV0lXoX0hzTJ4H/4Ees2wOE4pZzeK2xqrolD3/EIR31I1ztyz4hXJG3sBC3v7gFAgMBAAECggEAQP9jKSWAP02wtaFaXNGMIPTCE+spGm2wwuGgAR+j38eDWMUllpoYmu1NopBToGR52z9jGogFjVD8elNBuJnprtDtAnXyzR8lRbq66gJBPhC0zNkGk2ow+kLzM6UGUQZ5oVqj7mnfmoyGBV6pJ9A1FT06l2Nh1SyTRyq8daSO5TwE5wUl040YT5pFIy4TCL1NhJVqDU61kNZCzVrUN4Lorkvv4gAeYZGY0cX0QMWXxwq5N7dOAn1tbwuo3WHnJbva3KBOVCtkldZ7Z0iwFQsniZXuXk7NmpNKFuZiQArlR8pTqDJB1dUwua9Nw1c9T+0CvpGRUH2u3wFIWK/RYyh0gQKBgQDxZaam5Z4irNdlxv9ypwQiiSsar745cDsmKv7oE4mUkxQzcR1segK+og0aX2s6Oa25Cj64jSXqbY/Y2DsoIEFFDe9z2E52QEOsZcN51edLc88YsopSSSIgobA8/+hB+AHjlILNhrtghwbKBOxNR5vBM/QGmfWaGPqtA8HsD3DQcQKBgQDYyc56eLOPWLuREu1aFrNs4viJ8r4v+pZmLFrXHojPF3teQr6z+CnrnF7vKYAmnOVxD2M44LgRr7LYnswzDWLLvrAkhUCYiaTL+6dvgy0okkUGE5QjGPP889yiHef8b1fRKNaVM+hXkt452oqhh95ZMnN4/ugZ3Uiq3UF8Q4vq1QKBgEV/cn9SVDi/cjQHGrwzgWk//HzuY+G9ggn3DvRZy55Oyd4VjtcQOYIQvZz+I6zbtjwzyuLvIB9h86wGdOGUh7YN0QaVG+HHlrQniCOnhbOfX9xIarJOA9lJM6gcNQ3pDQIsW4w4YfHkbfvzduS43Qq+nl7YLHF1B5aQImCIAX7BAoGBAK135iG33a6RiR0P8R8KVS6G++uecrL/qEM/sLy78SsNFimZ7PEjXZ/rs0dahPHgz/PFJVdI8eEtH0YY4zritjBkeJvwiHzGfzi+OP+RDpyNVnADUKE5AVtiYyTSG2SyT6nNLM+dBoi0u9+9UPrqNnBXX3DtQBoaKGCYxSLDBf21AoGANG5wAjV+ME7uAYEvW9GlrvGmNmzyUuiZrYuYHCf76CTa+q0+P7o0WgKcWEXUSah08qF4EItUQuuw+PtFTFs/sorqa9QrZs/ozTt8Q4ms/tahFPkZOTJ8s1Az2jY3C9ERwS8ab3Q+kbLiXDTnWo4s7YqwpwMZd/abhs3SwCjzLDI=";
|
||||
private final String CHARSET = "UTF-8";
|
||||
// 支付宝公钥
|
||||
private final String ALIPAY_PUBLIC_KEY = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAnOq1vdnkd83CnZUWZVka7EWT0YgiGX8io6ul4GThlue66YNKoS/rKT1rHzyZqBwNG1qgeU7eH+UazuFK2GsxrDI1rSqzljkgQnkmwtjEsJYpXzFF5PTuW8bsDNHoXr5LsEyMaljyiNtBO3uc+Zbb0D6GcbnQUFGorMi9tKR28XjNJkvamohMhh+V5cb1FJtybliNoGAjA+Nh+aQVAXqFEPj3FX0qhPi4gRXniYL0o9ePaRtNg5pJ/uJ3G6llRi3+uZleD7XBSQCSf8ZZJfH8Bvr3mTQ/ObpyDub8VYnIkOgld4OAJRzqXJAyPFo0mRGhaeuSqviyRYGQK8/U8CrLkQIDAQAB";
|
||||
//这是沙箱接口路径
|
||||
private final String GATEWAY_URL ="https://openapi-sandbox.dl.alipaydev.com/gateway.do";
|
||||
private final String FORMAT = "JSON";
|
||||
//签名方式
|
||||
private final String SIGN_TYPE = "RSA2";
|
||||
//支付宝异步通知路径,付款完毕后会异步调用本项目的方法,必须为公网地址
|
||||
private final String NOTIFY_URL = "http://IP/aliyun/pay/yibu";
|
||||
//支付宝同步通知路径,也就是当付款完毕后跳转本项目的页面,可以不是公网地址
|
||||
private final String RETURN_URL = "http://IP/entertainment/payment";
|
||||
|
||||
|
||||
|
||||
|
||||
@RequestMapping(value = "/payZFB", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public Result<String> payZFB(@RequestBody PaymentParam paymentParam) throws AlipayApiException {
|
||||
AlipayClient alipayClient = new DefaultAlipayClient(GATEWAY_URL, APP_ID, APP_PRIVATE_KEY, FORMAT, CHARSET, ALIPAY_PUBLIC_KEY, SIGN_TYPE);
|
||||
AlipayTradePagePayRequest request = new AlipayTradePagePayRequest();
|
||||
//异步接收地址,仅支持http/https,公网可访问
|
||||
request.setNotifyUrl("");
|
||||
//同步跳转地址,仅支持http/https
|
||||
request.setReturnUrl(paymentParam.getReturnUrl());
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("outTradeNo", paymentParam.getOutTradeNo());
|
||||
String params = json.toString();
|
||||
/******必传参数******/
|
||||
JSONObject bizContent = new JSONObject();
|
||||
//商户订单号,商家自定义,保持唯一性
|
||||
bizContent.put("out_trade_no", paymentParam.getOutTradeNo());
|
||||
//支付金额,最小值0.01元
|
||||
bizContent.put("total_amount", paymentParam.getTotalAmount());
|
||||
//订单标题,不可使用特殊符号
|
||||
bizContent.put("subject", paymentParam.getSubject());
|
||||
//电脑网站支付场景固定传值FAST_INSTANT_TRADE_PAY
|
||||
bizContent.put("product_code", paymentParam.getProductCode());
|
||||
//支付宝请求的传值 可以在req中获取
|
||||
bizContent.put("body", params);
|
||||
/******可选参数******/
|
||||
request.setBizContent(bizContent.toString());
|
||||
AlipayTradePagePayResponse response = alipayClient.pageExecute(request);
|
||||
return Result.success(response.getBody());
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/notify") // 注意这里必须是POST接口
|
||||
public String payNotify(HttpServletRequest request) throws Exception {
|
||||
if (request.getParameter("trade_status").equals("TRADE_SUCCESS")) {
|
||||
System.out.println("=========支付宝异步回调========");
|
||||
|
||||
Map<String, String> params = new HashMap<>();
|
||||
Map<String, String[]> requestParams = request.getParameterMap();
|
||||
for (String name : requestParams.keySet()) {
|
||||
params.put(name, request.getParameter(name));
|
||||
// System.out.println(name + " = " + request.getParameter(name));
|
||||
}
|
||||
|
||||
String tradeNo = params.get("out_trade_no");
|
||||
String gmtPayment = params.get("gmt_payment");
|
||||
String alipayTradeNo = params.get("trade_no");
|
||||
// 支付宝验签
|
||||
if (Factory.Payment.Common().verifyNotify(params)) {
|
||||
// 验签通过
|
||||
System.out.println("交易名称: " + params.get("subject"));
|
||||
System.out.println("交易状态: " + params.get("trade_status"));
|
||||
System.out.println("支付宝交易凭证号: " + params.get("trade_no"));
|
||||
System.out.println("商户订单号: " + params.get("out_trade_no"));
|
||||
System.out.println("交易金额: " + params.get("total_amount"));
|
||||
System.out.println("买家在支付宝唯一id: " + params.get("buyer_id"));
|
||||
System.out.println("买家付款时间: " + params.get("gmt_payment"));
|
||||
System.out.println("买家付款金额: " + params.get("buyer_pay_amount"));
|
||||
}
|
||||
}
|
||||
return "success";
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private SysUserService userService;
|
||||
//TODO 充值记录添加
|
||||
@PostMapping("/records")
|
||||
public Result records(@RequestBody PaymentParam paymentParam) throws AlipayApiException {
|
||||
return Result.success(userService.addRecords(paymentParam));
|
||||
}
|
||||
|
||||
|
||||
//TODO 身份认证
|
||||
@PostMapping("/doPost")
|
||||
public Result doPost(@RequestBody @Valid StandingRes standingRes) {
|
||||
return SfUtil.query(standingRes);
|
||||
}
|
||||
|
||||
//TODO 发送验证码
|
||||
@PostMapping("/sendCode/{phonenumber}")
|
||||
public Result<String> sendCode(@PathVariable("phonenumber")String phonenumber){
|
||||
return Result.success(null,userService.sendCode(phonenumber));
|
||||
}
|
||||
|
||||
|
||||
//TODO 验证验证码
|
||||
@PostMapping("/checkCode/{phonenumber}/{code}")
|
||||
public Result<String> checkCode(@PathVariable("phonenumber")String phonenumber,@PathVariable("code")String code){
|
||||
return Result.success(null,userService.checkCode(phonenumber,code));
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -36,6 +36,7 @@ public class SysDictTypeController extends BaseController {
|
|||
return getDataTable(list);
|
||||
}
|
||||
|
||||
|
||||
@Log(title = "字典类型", businessType = BusinessType.EXPORT)
|
||||
@RequiresPermissions("system:dict:export")
|
||||
@PostMapping("/export")
|
||||
|
|
|
@ -40,6 +40,7 @@ public class SysLogininforController extends BaseController {
|
|||
return getDataTable(list);
|
||||
}
|
||||
|
||||
|
||||
@Log(title = "登录日志", businessType = BusinessType.EXPORT)
|
||||
@RequiresPermissions("system:logininfor:export")
|
||||
@PostMapping("/export")
|
||||
|
|
|
@ -15,6 +15,7 @@ import com.muyu.common.system.domain.SysUser;
|
|||
import com.muyu.common.system.domain.LoginUser;
|
||||
import com.muyu.system.domain.resp.ProfileResp;
|
||||
import com.muyu.system.service.SysUserService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
@ -26,6 +27,7 @@ import java.util.Arrays;
|
|||
*
|
||||
* @author muyu
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/user/profile")
|
||||
public class SysProfileController extends BaseController {
|
||||
|
@ -85,7 +87,7 @@ public class SysProfileController extends BaseController {
|
|||
*/
|
||||
@Log(title = "个人信息", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/updatePwd")
|
||||
public Result updatePwd (String oldPassword, String newPassword) {
|
||||
public Result updatePwd (@RequestParam(value = "oldPassword") String oldPassword, @RequestParam(value = "newPassword") String newPassword) {
|
||||
String username = SecurityUtils.getUsername();
|
||||
SysUser user = userService.selectUserByUserName(username);
|
||||
String password = user.getPassword();
|
||||
|
@ -105,6 +107,45 @@ public class SysProfileController extends BaseController {
|
|||
return error("修改密码异常,请联系管理员");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 重置手机号
|
||||
*/
|
||||
@Log(title = "重置手机号", businessType = BusinessType.UPDATE)
|
||||
@RequestMapping(value = "/updatePhonenumber/{phonenumber}",method = RequestMethod.POST)
|
||||
public Result updatePhonenumber(@PathVariable(value = "phonenumber") String phonenumber) {
|
||||
try {
|
||||
if (!isValidPhoneNumber(phonenumber)) {
|
||||
return error("手机号格式不正确");
|
||||
}
|
||||
String username = SecurityUtils.getUsername();
|
||||
SysUser user = userService.selectUserByUserName(username);
|
||||
if (user == null) {
|
||||
return error("用户不存在");
|
||||
}
|
||||
if (userService.updateUserPhonenumber(username, phonenumber) > 0) {
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
loginUser.getSysUser().setPhonenumber(phonenumber);
|
||||
tokenService.setLoginUser(loginUser);
|
||||
return success();
|
||||
} else {
|
||||
return error("修改手机号失败,请联系管理员");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// 记录异常日志
|
||||
log.error("更新手机号时发生异常", e);
|
||||
return error("系统异常,请稍后重试");
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isValidPhoneNumber(String phoneNumber) {
|
||||
// 正则表达式校验手机号格式
|
||||
String regex = "^1[3-9]\\d{9}$";
|
||||
return phoneNumber.matches(regex);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 头像上传
|
||||
*/
|
||||
|
|
|
@ -10,10 +10,8 @@ import com.muyu.common.log.enums.BusinessType;
|
|||
import com.muyu.common.security.annotation.InnerAuth;
|
||||
import com.muyu.common.security.annotation.RequiresPermissions;
|
||||
import com.muyu.common.security.utils.SecurityUtils;
|
||||
import com.muyu.common.system.domain.SysDept;
|
||||
import com.muyu.common.system.domain.SysRole;
|
||||
import com.muyu.common.system.domain.SysUser;
|
||||
import com.muyu.common.system.domain.LoginUser;
|
||||
import com.muyu.common.system.domain.*;
|
||||
import com.muyu.system.domain.ConnectorLog;
|
||||
import com.muyu.system.domain.resp.AuthRoleResp;
|
||||
import com.muyu.system.domain.resp.UserDetailInfoResp;
|
||||
import com.muyu.system.domain.resp.UserInfoResp;
|
||||
|
@ -26,6 +24,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|||
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
@ -57,6 +56,14 @@ public class SysUserController extends BaseController {
|
|||
@Autowired
|
||||
private SysConfigService configService;
|
||||
|
||||
|
||||
//查询12个月的消费记录
|
||||
@GetMapping("/months")
|
||||
public List<ConnectorLog>getMonthsSummary(ConnectorLog connectorLog){
|
||||
return userService.getMonthsSummary(connectorLog);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取用户列表
|
||||
*/
|
||||
|
@ -256,31 +263,70 @@ public class SysUserController extends BaseController {
|
|||
}
|
||||
|
||||
|
||||
//TODO 用户充值
|
||||
/**
|
||||
* 用户充值
|
||||
*/
|
||||
@Log(title = "用户充值", businessType = BusinessType.INSERT)
|
||||
@PostMapping ("/alipay/recharge")
|
||||
public Result userBalance(@RequestBody SysUser user){
|
||||
userService.checkUserAllowed(user);
|
||||
userService.checkUserDataScope(user.getUserId());
|
||||
user.setCreateBy(SecurityUtils.getUsername());
|
||||
return toAjax(userService.insertBalance(user));
|
||||
}
|
||||
|
||||
|
||||
//TODO
|
||||
// 查询当前用户的余额
|
||||
@GetMapping("/balance/{userId}")
|
||||
public Result userBalance(@PathVariable("userId") Long userId){
|
||||
userService.checkUserDataScope(userId);
|
||||
int rows = userService.selectBalance(userId);
|
||||
System.out.println(rows);
|
||||
return Result.success(rows);
|
||||
BigDecimal balance = userService.selectBalance(userId);
|
||||
String balanceString = balance.toPlainString();
|
||||
System.out.println(balanceString);
|
||||
return Result.success(balanceString);
|
||||
}
|
||||
|
||||
|
||||
//TODO
|
||||
@PostMapping("/addUserMoney")
|
||||
public Result<String> addUserMoney(@RequestBody SysUser user){
|
||||
return Result.success(userService.addUserMoney(user));
|
||||
}
|
||||
|
||||
|
||||
//TODO 查询充值记录
|
||||
@GetMapping("/userPayinfo")
|
||||
public Result<TableDataInfo<PaymentParam>> list (PaymentParam paymentParam) {
|
||||
startPage();
|
||||
List<PaymentParam> list = userService.selectPaymentParamList(paymentParam);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/*
|
||||
查詢購買記錄
|
||||
@param getBuyRecord
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/purchaseRecord")
|
||||
public Result<TableDataInfo<ConnectorLog>>record(ConnectorLog connectorLog){
|
||||
startPage();
|
||||
List<ConnectorLog> list = userService.selectRecordList(connectorLog);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
@Log(title = "记录", businessType = BusinessType.EXPORT)
|
||||
@RequiresPermissions("system:purchaseRecord:export")
|
||||
@PostMapping("/purchaseRecord/export")
|
||||
public void export (HttpServletResponse response, ConnectorLog connectorLog) {
|
||||
List<ConnectorLog> list = userService.selectRecordList(connectorLog);
|
||||
ExcelUtil<ConnectorLog> util = new ExcelUtil<ConnectorLog>(ConnectorLog.class);
|
||||
util.exportExcel(response, list, "记录");
|
||||
}
|
||||
|
||||
|
||||
@Log(title = "记录", businessType = BusinessType.EXPORT)
|
||||
@RequiresPermissions("system:pay:export")
|
||||
@PostMapping("/user/export")
|
||||
public void export (HttpServletResponse response, PaymentParam paymentParam) {
|
||||
List<PaymentParam> list = userService.selectPaymentParamList(paymentParam);
|
||||
ExcelUtil<PaymentParam> util = new ExcelUtil<PaymentParam>(PaymentParam.class);
|
||||
util.exportExcel(response, list, "记录");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,77 @@
|
|||
package com.muyu.system.domain;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @Author:chaiyapeng
|
||||
* @Package:com.muyu.domain
|
||||
* @Project:cloud-mart
|
||||
* @name:Connector
|
||||
* @Date:2024/8/26 10:03
|
||||
*/
|
||||
@Data
|
||||
public class Connector {
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private Long connectorId;
|
||||
/**
|
||||
* 接口名称
|
||||
*/
|
||||
private String connectorName;
|
||||
/**
|
||||
* 接口分类
|
||||
*/
|
||||
private String connectorSort;
|
||||
/**
|
||||
* 接口描述
|
||||
*/
|
||||
private String connectorDescribe;
|
||||
/**
|
||||
* 接口图片
|
||||
*/
|
||||
private String connectorPicture;
|
||||
/**
|
||||
* 公司
|
||||
*/
|
||||
private String connectorCompany;
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date connectorTime;
|
||||
/**
|
||||
* 价格
|
||||
*/
|
||||
private BigDecimal connectorPrice;
|
||||
/**
|
||||
* 剩余次数
|
||||
*/
|
||||
private Integer connectorResidueDegree;
|
||||
/**
|
||||
* 购买次数
|
||||
*/
|
||||
private Integer connectorFrequency;
|
||||
/**
|
||||
* API_URL
|
||||
*/
|
||||
private String connectorApiurl;
|
||||
/**
|
||||
* API_EYE
|
||||
*/
|
||||
private String connectorApikey;
|
||||
/**
|
||||
* 请求方式
|
||||
*/
|
||||
private String connectorRequest;
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
private Integer connectorStatus;
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package com.muyu.system.domain;
|
||||
|
||||
import com.muyu.common.core.annotation.Excel;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Author: wangxinyuan
|
||||
* @Date: 2024/9/3 下午12:08
|
||||
*/
|
||||
|
||||
@Data
|
||||
public class ConnectorLog {
|
||||
|
||||
//id
|
||||
@Excel(name = "序號")
|
||||
private Integer id;
|
||||
|
||||
//数据名称
|
||||
@Excel(name = "數據名稱")
|
||||
private String dataName;
|
||||
|
||||
//金额
|
||||
@Excel(name = "金額")
|
||||
private Double amount;
|
||||
|
||||
//消费时间
|
||||
@Excel(name = "消費時間")
|
||||
// @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
// @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private String createTime;
|
||||
|
||||
private String month;
|
||||
|
||||
private Double totalAmount;
|
||||
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
package com.muyu.system.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* @Author:chaiyapeng
|
||||
* @Package:com.muyu.system.domain
|
||||
* @Project:cloud-system
|
||||
* @name:ConnectorUser
|
||||
* @Date:2024/9/2 10:00
|
||||
*/
|
||||
@Data
|
||||
public class ConnectorUser {
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private Integer connectorUserId;
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
private Long userId;
|
||||
/**
|
||||
* 接口id
|
||||
*/
|
||||
private Integer connectorId;
|
||||
/**
|
||||
* 剩余次数
|
||||
*/
|
||||
private Integer connectorResidueDegree;
|
||||
/**
|
||||
* 购买次数
|
||||
*/
|
||||
private Integer connectorFrequency;
|
||||
/**
|
||||
* 测试次数
|
||||
*/
|
||||
private Integer textNumber;
|
||||
/**
|
||||
* 接口名称
|
||||
*/
|
||||
private String connectorName;
|
||||
/**
|
||||
* 价钱
|
||||
*/
|
||||
private Double connectorPrice;
|
||||
/**
|
||||
* 用户名称
|
||||
*/
|
||||
private String userName;
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package com.muyu.system.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.muyu.common.system.domain.SysUser;
|
||||
import com.muyu.system.domain.Connector;
|
||||
import com.muyu.system.domain.ConnectorLog;
|
||||
import com.muyu.system.domain.ConnectorUser;
|
||||
import org.apache.catalina.User;
|
||||
|
||||
/**
|
||||
* @Author:chaiyapeng
|
||||
* @Package:com.muyu.system.mapper
|
||||
* @Project:cloud-system
|
||||
* @name:BuyInterface
|
||||
* @Date:2024/9/1 14:38
|
||||
* 购买接口
|
||||
*/
|
||||
public interface BuyMapper extends BaseMapper<Connector> {
|
||||
Integer doBuyInterface(ConnectorUser connectorUser);
|
||||
|
||||
ConnectorUser selectConnectorUser(ConnectorUser connectorUserr);
|
||||
|
||||
Integer addConnectorUser(ConnectorUser connectorUser);
|
||||
|
||||
SysUser selectUser(Long userId);
|
||||
|
||||
void buyPrice(SysUser user);
|
||||
|
||||
int insertPurchaseRecord(ConnectorLog connectorLog);
|
||||
}
|
|
@ -42,4 +42,6 @@ public interface SysLogininforMapper extends BaseMapper<SysLogininfor> {
|
|||
* @return 结果
|
||||
*/
|
||||
public int cleanLogininfor ();
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
package com.muyu.system.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.muyu.common.system.domain.PaymentParam;
|
||||
import com.muyu.common.system.domain.SysUser;
|
||||
import com.muyu.system.domain.ConnectorLog;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -75,7 +78,7 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
|
|||
*/
|
||||
public int updateUser (SysUser user);
|
||||
|
||||
public int updateUserBalance (SysUser user);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
@ -144,5 +147,24 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
|
|||
public SysUser checkEmailUnique (String email);
|
||||
|
||||
|
||||
public int selectBalance(Long userId);
|
||||
|
||||
BigDecimal selectBalance(Long userId);
|
||||
|
||||
|
||||
int addUserMoney(SysUser user);
|
||||
|
||||
public int addRecords(PaymentParam paymentParam);
|
||||
|
||||
List<PaymentParam> selectPaymentParamList(PaymentParam paymentParam);
|
||||
|
||||
|
||||
|
||||
SysUser findByPhone(String phonenumber);
|
||||
|
||||
|
||||
int updateUserPhonenumber(@Param("username") String username, @Param("phonenumber") String phonenumber);
|
||||
|
||||
List<ConnectorLog> selectRecordList(ConnectorLog connectorLog);
|
||||
|
||||
List<ConnectorLog> selectMonthSummary(ConnectorLog connectorLog);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
package com.muyu.system.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.system.domain.Connector;
|
||||
import com.muyu.system.domain.ConnectorUser;
|
||||
|
||||
/**
|
||||
* @Author:chaiyapeng
|
||||
* @Package:com.muyu.system.service
|
||||
* @Project:cloud-system
|
||||
* @name:BuyService
|
||||
* @Date:2024/9/1 14:40
|
||||
* 购买接口
|
||||
*/
|
||||
public interface BuyService extends IService<Connector> {
|
||||
Result doBuyInterface(ConnectorUser connectorUser);
|
||||
}
|
|
@ -40,4 +40,7 @@ public interface SysLogininforService extends IService<SysLogininfor> {
|
|||
* 清空系统登录日志
|
||||
*/
|
||||
public void cleanLogininfor ();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
package com.muyu.system.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.muyu.common.system.domain.PaymentParam;
|
||||
import com.muyu.common.system.domain.SysUser;
|
||||
import com.muyu.system.domain.ConnectorLog;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -226,8 +229,27 @@ public interface SysUserService extends IService<SysUser> {
|
|||
*/
|
||||
public String importUser (List<SysUser> userList, Boolean isUpdateSupport, String operName);
|
||||
|
||||
int insertBalance(SysUser user);
|
||||
|
||||
|
||||
int selectBalance(Long userId);
|
||||
|
||||
BigDecimal selectBalance(Long userId);
|
||||
|
||||
|
||||
String addUserMoney(SysUser user);
|
||||
|
||||
public int addRecords(PaymentParam paymentParam);
|
||||
|
||||
List<PaymentParam> selectPaymentParamList(PaymentParam paymentParam);
|
||||
|
||||
|
||||
String sendCode(String phonenumber);
|
||||
|
||||
String checkCode(String phonenumber, String code);
|
||||
|
||||
|
||||
int updateUserPhonenumber(String username, String phonenumber);
|
||||
|
||||
List<ConnectorLog> selectRecordList(ConnectorLog connectorLog);
|
||||
|
||||
List<ConnectorLog> getMonthsSummary(ConnectorLog connectorLog);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,73 @@
|
|||
package com.muyu.system.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.security.utils.SecurityUtils;
|
||||
import com.muyu.common.system.domain.LoginUser;
|
||||
import com.muyu.common.system.domain.SysUser;
|
||||
import com.muyu.system.domain.Connector;
|
||||
import com.muyu.system.domain.ConnectorLog;
|
||||
import com.muyu.system.domain.ConnectorUser;
|
||||
import com.muyu.system.mapper.BuyMapper;
|
||||
import com.muyu.system.service.BuyService;
|
||||
import org.apache.catalina.User;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* @Author:chaiyapeng
|
||||
* @Package:com.muyu.system.service.impl
|
||||
* @Project:cloud-system
|
||||
* @name:BuyServiceImpl
|
||||
* @Date:2024/9/1 14:40
|
||||
* 购买接口
|
||||
*/
|
||||
@Service
|
||||
public class BuyServiceImpl extends ServiceImpl<BuyMapper, Connector> implements BuyService {
|
||||
@Resource
|
||||
private BuyMapper buyMapper;
|
||||
@Override
|
||||
public Result doBuyInterface(ConnectorUser connectorUser) {
|
||||
// //获取当前用户名
|
||||
// String username = SecurityUtils.getUsername();
|
||||
//获取当前用户ID
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
// //获取当前的用户信息
|
||||
// LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
connectorUser.setUserId(userId);
|
||||
SysUser user = buyMapper.selectUser(userId);
|
||||
if (user.getUserBalance()<connectorUser.getConnectorFrequency()*connectorUser.getConnectorPrice()){
|
||||
return Result.error("余额不足");
|
||||
}
|
||||
Integer i = buyMapper.doBuyInterface(connectorUser);
|
||||
if (i>0){
|
||||
user.setUserBalance(user.getUserBalance()-connectorUser.getConnectorFrequency()*connectorUser.getConnectorPrice());
|
||||
buyMapper.buyPrice(user);
|
||||
buyMapper.doBuyInterface(connectorUser);
|
||||
ConnectorLog connectorLog = new ConnectorLog();
|
||||
connectorLog.setDataName(connectorUser.getConnectorName());
|
||||
connectorLog.setAmount(connectorUser.getConnectorPrice());
|
||||
// 插入购买记录
|
||||
buyMapper.insertPurchaseRecord(connectorLog);
|
||||
return Result.success(i,"购买成功");
|
||||
}
|
||||
ConnectorUser connectorUser1 = buyMapper.selectConnectorUser(connectorUser);
|
||||
if (connectorUser1==null){
|
||||
Integer i1 = buyMapper.addConnectorUser(connectorUser);
|
||||
if (i1>0){
|
||||
user.setUserBalance(user.getUserBalance()-connectorUser.getConnectorFrequency()*connectorUser.getConnectorPrice());
|
||||
buyMapper.buyPrice(user);
|
||||
buyMapper.doBuyInterface(connectorUser);
|
||||
ConnectorLog connectorLog = new ConnectorLog();
|
||||
connectorLog.setDataName(connectorUser.getConnectorName());
|
||||
connectorLog.setAmount(connectorUser.getConnectorPrice());
|
||||
// 插入购买记录
|
||||
buyMapper.insertPurchaseRecord(connectorLog);
|
||||
return Result.success(i,"购买成功");
|
||||
}
|
||||
}
|
||||
return Result.error("购买失败");
|
||||
}
|
||||
}
|
|
@ -42,6 +42,8 @@ public class SysLogininforServiceImpl extends ServiceImpl<SysLogininforMapper, S
|
|||
return logininforMapper.selectLogininforList(logininfor);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 批量删除系统登录日志
|
||||
*
|
||||
|
@ -61,4 +63,6 @@ public class SysLogininforServiceImpl extends ServiceImpl<SysLogininforMapper, S
|
|||
public void cleanLogininfor () {
|
||||
logininforMapper.cleanLogininfor();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.muyu.system.service.impl;
|
||||
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import com.alipay.api.AlipayApiException;
|
||||
import com.alipay.api.AlipayClient;
|
||||
import com.alipay.api.DefaultAlipayClient;
|
||||
|
@ -7,15 +8,19 @@ import com.alipay.api.request.AlipayTradePagePayRequest;
|
|||
import com.alipay.api.response.AlipayTradePagePayResponse;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.muyu.common.core.constant.UserConstants;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.exception.ServiceException;
|
||||
import com.muyu.common.core.utils.SpringUtils;
|
||||
import com.muyu.common.core.utils.StringUtils;
|
||||
import com.muyu.common.core.utils.bean.BeanValidators;
|
||||
import com.muyu.common.datascope.annotation.DataScope;
|
||||
import com.muyu.common.security.utils.SecurityUtils;
|
||||
import com.muyu.common.system.domain.PaymentParam;
|
||||
import com.muyu.common.system.domain.SysRole;
|
||||
import com.muyu.common.system.domain.SysUser;
|
||||
import com.muyu.config.AlipayConfig;
|
||||
import com.muyu.config.util.MsgUtil;
|
||||
import com.muyu.system.domain.ConnectorLog;
|
||||
import com.muyu.system.domain.SysPost;
|
||||
import com.muyu.system.domain.SysUserPost;
|
||||
import com.muyu.system.domain.SysUserRole;
|
||||
|
@ -27,6 +32,7 @@ import lombok.extern.slf4j.Slf4j;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
@ -35,6 +41,7 @@ import java.math.BigDecimal;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.muyu.config.AlipayConfig.*;
|
||||
|
@ -128,10 +135,27 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|||
|
||||
|
||||
@Override
|
||||
public int selectBalance(Long userId) {
|
||||
int i = userMapper.selectBalance(userId);
|
||||
System.out.println(i);
|
||||
return i;
|
||||
public BigDecimal selectBalance(Long userId) {
|
||||
return userMapper.selectBalance(userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String addUserMoney(SysUser user) {
|
||||
int i = userMapper.addUserMoney(user);
|
||||
if(i <= 0){
|
||||
throw new RuntimeException("充值失败");
|
||||
}
|
||||
return "充值成功";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int addRecords(PaymentParam paymentParam) {
|
||||
return userMapper.addRecords(paymentParam);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PaymentParam> selectPaymentParamList(PaymentParam paymentParam) {
|
||||
return userMapper.selectPaymentParamList(paymentParam);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -268,38 +292,9 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|||
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int insertBalance(SysUser user) {
|
||||
// 创建支付宝客户端
|
||||
AlipayClient alipayClient = new DefaultAlipayClient(URL, APPID, RSA_PRIVATE_KEY, FORMAT, CHARSET, ALIPAY_PUBLIC_KEY, SIGNTYPE);
|
||||
AlipayTradePagePayRequest alipayRequest = new AlipayTradePagePayRequest();
|
||||
|
||||
|
||||
|
||||
// 发起支付请求
|
||||
try {
|
||||
//TODO 调用支付宝接口
|
||||
AlipayTradePagePayResponse response = alipayClient.pageExecute(alipayRequest);
|
||||
if (response.isSuccess()) {
|
||||
// 支付成功,更新用户余额
|
||||
SysUser sysUser = userMapper.selectUserById(user.getUserId());
|
||||
sysUser.setUserBalance(user.getUserBalance());
|
||||
// double currentBalance = sysUser.getUserBalance();
|
||||
// double newPaymentAmount = user.getPaymentAmount();
|
||||
// double newBalance = currentBalance + newPaymentAmount;
|
||||
// sysUser.setUserBalance(newBalance);
|
||||
userMapper.updateUserBalance(sysUser);
|
||||
} else {
|
||||
throw new RuntimeException("充值失败");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 注册用户信息
|
||||
|
@ -562,6 +557,50 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|||
return successMsg.toString();
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private RedisTemplate<String,String> redisTemplate;
|
||||
|
||||
@Override
|
||||
public String sendCode(String phonenumber) {
|
||||
SysUser byPhone = userMapper.findByPhone(phonenumber);
|
||||
if(byPhone == null){
|
||||
throw new RuntimeException("手机号不存在");
|
||||
}
|
||||
String code = RandomUtil.randomNumbers(4);
|
||||
System.out.println(code);
|
||||
redisTemplate.opsForValue().set(phonenumber,code,5, TimeUnit.MINUTES);
|
||||
MsgUtil.sendMsg(phonenumber,code);
|
||||
return "发送成功";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String checkCode(String phonenumber, String code) {
|
||||
if(redisTemplate.hasKey(phonenumber)){
|
||||
String s = redisTemplate.opsForValue().get(phonenumber);
|
||||
if(s.equals(code)){
|
||||
return Result.success().getMsg();
|
||||
}else{
|
||||
throw new RuntimeException("验证码错误");
|
||||
}
|
||||
}else{
|
||||
throw new RuntimeException("验证码已过期");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateUserPhonenumber(String username, String phonenumber) {
|
||||
return userMapper.updateUserPhonenumber(username,phonenumber);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ConnectorLog> selectRecordList(ConnectorLog connectorLog) {
|
||||
return userMapper.selectRecordList(connectorLog);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ConnectorLog> getMonthsSummary(ConnectorLog connectorLog) {
|
||||
return userMapper.selectMonthSummary(connectorLog);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ nacos:
|
|||
addr: 47.116.184.54:8848
|
||||
user-name: nacos
|
||||
password: nacos
|
||||
namespace: cloud-tx
|
||||
namespace: cloud-2112
|
||||
|
||||
# Spring
|
||||
spring:
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
<?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.muyu.system.mapper.BuyMapper">
|
||||
<insert id="addConnectorUser">
|
||||
INSERT INTO `text`.`connector_user`
|
||||
(`connector_user_id`, `user_id`, `connector_id`, `connector_residue_degree`, `connector_frequency`, `text_number`)
|
||||
VALUES (0,#{userId}, #{connectorId}, 0, 0,5)
|
||||
|
||||
</insert>
|
||||
|
||||
<insert id="insertPurchaseRecord">
|
||||
INSERT INTO `text`.`connect_log` ( `data_name`, `amount`, `create_time`)
|
||||
VALUES (#{dataName}, #{amount}, now());
|
||||
</insert>
|
||||
|
||||
|
||||
<update id="doBuyInterface">
|
||||
update connector_user set connector_residue_degree=connector_residue_degree+#{connectorFrequency},connector_frequency=connector_frequency+#{connectorFrequency} where connector_id=#{connectorId} and user_id=#{userId}
|
||||
</update>
|
||||
<update id="buyPrice">
|
||||
update sys_user set user_balance=#{userBalance} where user_id=#{userId}
|
||||
</update>
|
||||
<select id="selectConnectorUser" resultType="com.muyu.system.domain.ConnectorUser">
|
||||
SELECT
|
||||
connector_user.connector_user_id,
|
||||
connector_user.connector_residue_degree,
|
||||
connector_user.connector_frequency,
|
||||
sys_user.user_name,
|
||||
connector.connector_name,
|
||||
connector.connector_price
|
||||
FROM
|
||||
connector_user
|
||||
LEFT JOIN sys_user ON connector_user.user_id = sys_user.user_id
|
||||
LEFT JOIN connector ON connector_user.connector_id = connector.connector_id
|
||||
WHERE
|
||||
sys_user.user_id =#{userId} and connector.connector_name=#{connectorName}
|
||||
</select>
|
||||
<select id="selectUser" resultType="com.muyu.common.system.domain.SysUser">
|
||||
select *from sys_user where user_id=#{userId}
|
||||
</select>
|
||||
|
||||
</mapper>
|
|
@ -18,6 +18,8 @@
|
|||
values (#{userName}, #{status}, #{ipaddr}, #{msg}, sysdate())
|
||||
</insert>
|
||||
|
||||
|
||||
|
||||
<select id="selectLogininforList" parameterType="com.muyu.common.system.domain.SysLogininfor" resultMap="SysLogininforResult">
|
||||
select info_id, user_name, ipaddr, status, msg, access_time from sys_logininfor
|
||||
<where>
|
||||
|
@ -40,6 +42,7 @@
|
|||
order by info_id desc
|
||||
</select>
|
||||
|
||||
|
||||
<delete id="deleteLogininforByIds" parameterType="Long">
|
||||
delete from sys_logininfor where info_id in
|
||||
<foreach collection="array" item="infoId" open="(" separator="," close=")">
|
||||
|
|
|
@ -184,10 +184,48 @@
|
|||
and del_flag = '0'
|
||||
limit 1
|
||||
</select>
|
||||
<select id="selectBalance" resultType="java.lang.Integer">
|
||||
|
||||
<select id="selectBalance" resultType="java.math.BigDecimal">
|
||||
select user_balance from sys_user where user_id = #{userId}
|
||||
</select>
|
||||
|
||||
<select id="selectPaymentParamList" resultType="com.muyu.common.system.domain.PaymentParam">
|
||||
select
|
||||
id,
|
||||
out_trade_no,
|
||||
product_code,
|
||||
create_time,
|
||||
total_amount
|
||||
from pay_ment_param
|
||||
</select>
|
||||
|
||||
<select id="findByPhone" resultType="com.muyu.common.system.domain.SysUser">
|
||||
select phonenumber from sys_user where phonenumber = #{phone}
|
||||
</select>
|
||||
|
||||
<select id="selectRecordList" resultType="com.muyu.system.domain.ConnectorLog">
|
||||
select id,data_name,amount ,create_time from connect_log
|
||||
</select>
|
||||
|
||||
<select id="selectMonthSummary" resultType="com.muyu.system.domain.ConnectorLog">
|
||||
SELECT
|
||||
DATE_FORMAT(create_time, '%Y-%m') as month,
|
||||
SUM(amount) as totalAmount
|
||||
FROM
|
||||
connect_log
|
||||
WHERE
|
||||
create_time >= DATE_SUB(CURDATE(), INTERVAL 12 MONTH)
|
||||
GROUP BY
|
||||
DATE_FORMAT(create_time, '%Y-%m')
|
||||
ORDER BY
|
||||
DATE_FORMAT(create_time, '%Y-%m');
|
||||
</select>
|
||||
|
||||
|
||||
<update id="addUserMoney">
|
||||
update sys_user set user_balance = user_balance + #{userBalance} where user_id = #{userId}
|
||||
</update>
|
||||
|
||||
<insert id="insertUser" parameterType="com.muyu.common.system.domain.SysUser" useGeneratedKeys="true" keyProperty="userId">
|
||||
insert into sys_user(
|
||||
<if test="userId != null and userId != 0">user_id,</if>
|
||||
|
@ -221,6 +259,13 @@
|
|||
</insert>
|
||||
|
||||
|
||||
<insert id="addRecords">
|
||||
INSERT INTO `text`.`pay_ment_param` (`out_trade_no`, `total_amount`, `create_time`, `product_code`)
|
||||
VALUES (#{outTradeNo}, #{totalAmount}, now(), #{productCode});
|
||||
</insert>
|
||||
|
||||
|
||||
|
||||
|
||||
<update id="updateUser" parameterType="com.muyu.common.system.domain.SysUser">
|
||||
update sys_user
|
||||
|
@ -244,28 +289,7 @@
|
|||
</update>
|
||||
|
||||
|
||||
<update id="updateUserBalance" parameterType="com.muyu.common.system.domain.SysUser">
|
||||
update sys_user
|
||||
<set>
|
||||
<if test="deptId != null and deptId != 0">dept_id = #{deptId},</if>
|
||||
<if test="userName != null and userName != ''">user_name = #{userName},</if>
|
||||
<if test="nickName != null and nickName != ''">nick_name = #{nickName},</if>
|
||||
<if test="email != null ">email = #{email},</if>
|
||||
<if test="phonenumber != null ">phonenumber = #{phonenumber},</if>
|
||||
<if test="sex != null and sex != ''">sex = #{sex},</if>
|
||||
<if test="avatar != null and avatar != ''">avatar = #{avatar},</if>
|
||||
<if test="password != null and password != ''">password = #{password},</if>
|
||||
<if test="status != null and status != ''">status = #{status},</if>
|
||||
<if test="loginIp != null and loginIp != ''">login_ip = #{loginIp},</if>
|
||||
<if test="loginDate != null">login_date = #{loginDate},</if>
|
||||
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
|
||||
<if test="userBalance != null">user_balance = #{userBalance},</if>
|
||||
<if test="paymentAmount != null">payment_amount = #{paymentAmount},</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
update_time = sysdate()
|
||||
</set>
|
||||
where user_id = #{userId}
|
||||
</update>
|
||||
|
||||
|
||||
<update id="updateUserStatus" parameterType="com.muyu.common.system.domain.SysUser">
|
||||
update sys_user
|
||||
|
@ -285,6 +309,12 @@
|
|||
where user_name = #{userName}
|
||||
</update>
|
||||
|
||||
<update id="updateUserPhonenumber">
|
||||
update sys_user
|
||||
set phonenumber = #{phonenumber}
|
||||
where user_name = #{username}
|
||||
</update>
|
||||
|
||||
|
||||
<delete id="deleteUserById" parameterType="Long">
|
||||
update sys_user
|
||||
|
|
Loading…
Reference in New Issue