Commit 3061ca3d by yuanchao

20240329

parent 6b76675f
...@@ -114,8 +114,11 @@ ...@@ -114,8 +114,11 @@
<version>6.6.14</version> <version>6.6.14</version>
</dependency> </dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.6</version> <!-- 使用最新的稳定版本 -->
</dependency>
<!-- 微信支付 SDK --> <!-- 微信支付 SDK -->
<dependency> <dependency>
<groupId>com.github.wxpay</groupId> <groupId>com.github.wxpay</groupId>
...@@ -129,11 +132,25 @@ ...@@ -129,11 +132,25 @@
</dependency>--> </dependency>-->
<dependency> <dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.6</version>
</dependency>
<dependency>
<groupId>com.github.wechatpay-apiv3</groupId> <groupId>com.github.wechatpay-apiv3</groupId>
<artifactId>wechatpay-apache-httpclient</artifactId> <artifactId>wechatpay-apache-httpclient</artifactId>
<version>0.4.7</version> <version>0.4.7</version>
</dependency> </dependency>
<!-- <dependency>
<groupId>com.github.wechatpay-apiv3</groupId>
<artifactId>wechatpay-java</artifactId>
<version>0.2.12</version>
</dependency>-->
<dependency> <dependency>
<groupId>com.baomidou</groupId> <groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId> <artifactId>mybatis-plus-boot-starter</artifactId>
......
package com.qianhe.system.controller;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @author yc
* @version 1.0
* @className CCBBackController
* @date 2024/3/28 11:00
* @description 建行回调
*/
@RestController
@Slf4j
@RequestMapping("/ccbback")
public class CCBBackController {
private String pubKey = "";
}
\ No newline at end of file
package com.qianhe.system.controller;
import com.google.gson.Gson;
import com.qianhe.common.core.domain.AjaxResult;
import com.qianhe.system.domain.WaterGoods;
import com.qianhe.system.utils.MD5;
import org.apache.http.HttpEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import static com.qianhe.common.core.domain.AjaxResult.success;
/**
* @author yc
* @version 1.0
* @className BankPay
* @date 2024/3/26 9:17
* @description 建行支付
*/
@RestController
@RequestMapping("/ccbPay")
public class CCBPayController {
String pk = "";
/**
* 预支付订单生成入口
*/
@GetMapping("/pay")
public AjaxResult bankPay(WaterGoods goods) throws IOException {
String MERCHANTID = "105000149005386";
String POSID = "081113098";
String BRANCHID = "370000000";
String ORDERID = "1234665";
String PAYMENT = "0.01";
String CURCODE = "01";
String TXCODE = "530590";
String REMARK1 = "";
String REMARK2 = "";
String TYPE = "1";
String PUB = "c2660ff6f7c5d64570352f21020111";
String GATEWAY = "0";
String CLIENTIP = "127.0.0.1";
String REGINFO = "";
String PROINFO = "test";
String REFERER = "";
String TRADE_TYPE = "MINIPRO";
String SUB_APPID = "wx3c0181d9800dfbf2";
String SUB_OPENID = "orQvH66uR0zvOhHx1sxq49qEln9s";
String macStr = "MERCHANTID=105000149005386";
macStr+=POSID;
macStr+=BRANCHID;
macStr+=ORDERID;
macStr+=PAYMENT;
macStr+=CURCODE;
macStr+=TXCODE;
macStr+=REMARK1;
macStr+=REMARK2;
macStr+=TYPE;
macStr+=PUB;
macStr+=GATEWAY;
macStr+=CLIENTIP;
macStr+=REGINFO;
macStr+=PROINFO;
macStr+=REFERER;
macStr+=TRADE_TYPE;
macStr+=SUB_APPID;
macStr+=SUB_OPENID;
String macStrMd5 = MD5.EncodeByMD5(macStr);
String url = "https://ibsbjstar.ccb.com.cn/CCBIS/ccbMain?CCB_IBSVersion=V6";
url += "&MERCHANTID="+MERCHANTID;
url += "&POSID="+POSID;
url += "&BRANCHID="+BRANCHID;
url += "&ORDERID="+ORDERID;
url += "&PAYMENT="+PAYMENT;
url += "&CURCODE="+CURCODE;
url += "&TXCODE="+TXCODE;
url += "&REMARK1="+REMARK1;
url += "&REMARK2="+REMARK2;
url += "&TYPE="+TYPE;
url += "&GATEWAY="+GATEWAY;
url += "&CLIENTIP="+CLIENTIP;
url += "&REGINFO="+REGINFO;
url += "&PROINFO="+PROINFO;
url += "&REFERER="+REFERER;
url += "&TRADE_TYPE="+TRADE_TYPE;
url += "&SUB_APPID="+SUB_APPID;
url += "&SUB_OPENID="+SUB_OPENID;
url += "&MAC="+macStrMd5;
System.out.println("mac===="+macStr);
System.out.println("md5加密mac===="+macStrMd5);
System.out.println("请求url==="+url);
CloseableHttpClient httpclient = HttpClients.createDefault();
HttpPost httppost = new HttpPost(url);
CloseableHttpResponse response = httpclient.execute(httppost);
String result = "";
// 将签名时数据和签名一起返回前端用于前端吊起支付
Map<String, Object> resultMap = new HashMap<>();
try {
HttpEntity entity = response.getEntity();
result = EntityUtils.toString(entity);
EntityUtils.consume(entity);
System.out.println(result);
Gson gson = new Gson();
Map<String, Object> map = new HashMap<String, Object>();
//解析PAYURL
map = gson.fromJson(result, map.getClass());
String success =(String) map.get("SUCCESS");
String payUrl =(String) map.get("PAYURL");
System.out.println("payUrl的值为:"+payUrl);
//发起PAYURL请求
httppost = new HttpPost(payUrl);
response = httpclient.execute(httppost);
entity = response.getEntity();
String payResult = EntityUtils.toString(entity);
EntityUtils.consume(entity);
//解析PAYURL请求
map = gson.fromJson(payResult, map.getClass());
String ERRCODE =(String) map.get("ERRCODE");
System.out.println("ERRCODE的值为:"+ERRCODE);
if(ERRCODE.equals("000000")){
String appId = (String) map.get("appId");
String timeStamp = (String) map.get("timeStamp");
String nonceStr = (String) map.get("nonceStr");
String packageS = (String) map.get("package");
String signType = (String) map.get("signType");
String paySign = (String) map.get("paySign");
// 小程序id
resultMap.put("appId", appId);
// 时间戳
resultMap.put("timeStamp", timeStamp);
// 随机字符串
resultMap.put("nonceStr", nonceStr);
// 预支付交易会话ID
resultMap.put("package", packageS);
// 签名方式
resultMap.put("signType", signType);
// 签名
resultMap.put("paySign", paySign);
}
} finally {
response.close();
}
return success(resultMap);
}
}
\ No newline at end of file
...@@ -3,23 +3,48 @@ package com.qianhe.system.controller; ...@@ -3,23 +3,48 @@ package com.qianhe.system.controller;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference; import com.alibaba.fastjson.TypeReference;
import com.qianhe.system.config.WechatPayConfig; import com.qianhe.system.config.WechatPayConfig;
import com.qianhe.system.domain.WaterWxpayOrder; import com.qianhe.system.domain.*;
import com.qianhe.system.mapper.WaterOrderLogMapper;
import com.qianhe.system.mapper.WaterOrderMapper;
import com.qianhe.system.mapper.WaterWxpayOrderMapper; import com.qianhe.system.mapper.WaterWxpayOrderMapper;
import com.qianhe.system.utils.WechatPayValidator; import com.qianhe.system.utils.WechatPayValidator;
import com.qianhe.system.vo.WaterOrderVo;
import com.wechat.pay.contrib.apache.httpclient.auth.PrivateKeySigner;
import com.wechat.pay.contrib.apache.httpclient.auth.Verifier; import com.wechat.pay.contrib.apache.httpclient.auth.Verifier;
import com.wechat.pay.contrib.apache.httpclient.auth.WechatPay2Credentials;
import com.wechat.pay.contrib.apache.httpclient.cert.CertificatesManager;
import com.wechat.pay.contrib.apache.httpclient.exception.HttpCodeException;
import com.wechat.pay.contrib.apache.httpclient.exception.NotFoundException;
import com.wechat.pay.contrib.apache.httpclient.util.PemUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.math.BigDecimal;
import java.security.GeneralSecurityException;
import java.security.NoSuchAlgorithmException;
import java.security.PrivateKey;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.concurrent.locks.ReentrantLock; import java.util.concurrent.locks.ReentrantLock;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/** /**
* @author yc * @author yc
...@@ -36,15 +61,44 @@ public class CallbackController { ...@@ -36,15 +61,44 @@ public class CallbackController {
@Resource @Resource
private WechatPayConfig wechatPayConfig; private WechatPayConfig wechatPayConfig;
@Resource
private Verifier verifier;
@Autowired @Autowired
private WaterWxpayOrderMapper wxpayOrderMapper; private WaterWxpayOrderMapper wxpayOrderMapper;
private final ReentrantLock lock = new ReentrantLock(); @Autowired
private WaterOrderLogMapper orderLogMapper;
@Autowired
private WaterOrderMapper orderMapper;
private final ReentrantLock lock = new ReentrantLock();
private String pk = "MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQC+vQS+6VGcsX6i\n" +
"Au5HhEXviSfTuI+F3ZHGD/9m/3sPNxIsiA/46E9vk0+Ulxmaxr5x6KNbyko/XVmQ\n" +
"MN1vxFO/rGpqk24shDWZpxyMEwMxvw4EcbhbGmzRoxmrwUbujmJznIq6JcqqaBHa\n" +
"Z9LwHzVWtOZsRwHVr6KivRZr27bN3aEv26nnMTDkg1tkwi0AKG4EmxlYU5zjnFXh\n" +
"3TDkOZYZsq24bXllSCXlTCCWpBgPbNyBzAshT3M9nD4GeW+sqrnsVMEbaSxjd6xg\n" +
"uB28OCxyOb1BJKXEZYQJBmQ+ik8GoNQtx/00tE1Y5GPH+QONs1sYlQhu4FFTtvvS\n" +
"069DIOfjAgMBAAECggEBAKg8NkxhpS9tSwGBTkRcQgdGVY+kMUtkpCgrgh2J6DQC\n" +
"YhBPLq9f0HjcWQv5vobLF72G8VeL9LMxFkddImNrqmbcn7xDL6EqN9DAGijeuCmP\n" +
"l8CJwY7xntvFXWYmAvd1NRc+EwqfPMPTKTQX8XEERdqlkrwcYVzmHrAl0fnugK3Q\n" +
"btsO931xHGJ98CSVOMURiRmTdjKAahXYIlWfU0Xdqb+16uIPD31tLC17Kf5+Odpd\n" +
"Rv9rxLBrp6FxuA+fwkKT+f3bNxLOQfmsb+0nuE/8lNe3VslV96K+CUB7MELQ3wx3\n" +
"hQ5BgVa3JNpOlY5TMjyP+Yi+OEA+KJ/xPMKsieP6fFECgYEA+FxERDwoAWjn5V5x\n" +
"7yVAJ4Vnd5WaIxIU6J8YDjDX5CEzXsICoubxioAPbZoC93T/6h8WGWvm3s8FfIlp\n" +
"dWRIAK/YA4fqAwcEyTuk6p2upU1IAyjz09n+OshIvBZ+j/b05xFk5nMM616HZrAn\n" +
"mIB1isDn8UhKPKjhx2JatOvdBqsCgYEAxJsAoizmYHYeY0aW+HX2h9LqImxCuPmK\n" +
"izaMZCxq9RBGwGT/UyHXo3CBr+SILvjAYtKDi5danIygiVp76yBWBQQmKh5f0z7m\n" +
"FoPRwmf7o1qMV+KuFdydLuinA5864aONOEeoQOBuWP6fJ11+37ezVTsUyuC+fjhX\n" +
"1+uNnhNqg6kCgYBjXxd5bdBb8AuI/Kb9lpv6tCfX8yW/DocLJEzNsMFQ5+/T5DCF\n" +
"2X2feumxYsP5GvkiRdnjxgaT86UwVRK7A6rDi5gUoZcCKxbBJXow3XJ5dVhw2zvj\n" +
"8f8EqgpgJ2fwVlFa+tyyUCpFKodmkOjm3c8p+1FSeygo6TGdQz8j0JOZDQKBgQCx\n" +
"+2RybFVOZAAUfXX0jc3VneGpsfohPH7okkQ7914IZmi2iXf/CTcO1a4BztBePYDk\n" +
"tZCykR1NdZ1rWsetzsMwnVXzcTXsphdjsIf3B21tr243rZVNYz/ElIeFpuOGGyqg\n" +
"FXbC7KnY1QC9gU13N/UYJnknRJgO6fDUHoFA5nDZqQKBgADTGuWavhnw1SCRYZhz\n" +
"QtonO5hXjNjwZHcmEaEneI3+9X64TQgXY1hQe3WWLUwDNyAhlsT8y1Jl1kgL0tJP\n" +
"mxz0fsu47RdFR1rX+3ZIF5jNaxR6UIN2GQLlhvB7PCl7znKpph/nVthTO681Vx3V\n" +
"mP/wQpwy8cWtmbyl7lcvVRN5";
String serialNo = "2562AB35D9BFE5CB875FA73954B6F51421E0F364";
/** /**
* 支付回调处理 * 支付回调处理
* *
...@@ -53,7 +107,7 @@ public class CallbackController { ...@@ -53,7 +107,7 @@ public class CallbackController {
* @return * @return
*/ */
@PostMapping("/payNotify/") @PostMapping("/payNotify/")
public Map<String, String> payNotify(HttpServletRequest request, HttpServletResponse response) { public Map<String, String> payNotify(HttpServletRequest request, HttpServletResponse response) throws GeneralSecurityException, IOException, NotFoundException, HttpCodeException {
log.info("支付回调"); log.info("支付回调");
// 处理通知参数 // 处理通知参数
...@@ -68,24 +122,25 @@ public class CallbackController { ...@@ -68,24 +122,25 @@ public class CallbackController {
// 解密resource中的通知数据 // 解密resource中的通知数据
String resource = bodyMap.get("resource").toString(); String resource = bodyMap.get("resource").toString();
Map<String, Object> resourceMap = WechatPayValidator.decryptFromResource(resource, wechatPayConfig.getApiV3Key(), 1); Map<String, Object> resourceMap = WechatPayValidator.decryptFromResource(resource, wechatPayConfig.getApiV3Key(), 1);
System.out.println("resourceMap============"+resourceMap);
String outTradeNo = resourceMap.get("out_trade_no").toString(); String outTradeNo = resourceMap.get("out_trade_no").toString();
String appId = resourceMap.get("app_id").toString(); String attach = resourceMap.get("attach").toString();
String appId = resourceMap.get("appid").toString();
String tradeType = resourceMap.get("trade_type").toString(); String tradeType = resourceMap.get("trade_type").toString();
String tradeState = resourceMap.get("trade_state").toString(); String tradeState = resourceMap.get("trade_state").toString();
String desc = resourceMap.get("trade_state_desc").toString(); String desc = resourceMap.get("trade_state_desc").toString();
String successTime = resourceMap.get("success_time").toString(); String successTime = resourceMap.get("success_time").toString();
Object amount = resourceMap.get("amount");
Map<String,Object> amountMap = object2Map(amount);
String payerTotal = amountMap.get("payer_total").toString();
String total = amountMap.get("total").toString();
String currency = amountMap.get("currency").toString();
String payerCurrency = amountMap.get("payer_currency").toString();
Object payer = resourceMap.get("payer");
Map<String,Object> payerMap = object2Map(payer);
String openId = payerMap.get("openid").toString();
String bankType = resourceMap.get("bank_type").toString(); String bankType = resourceMap.get("bank_type").toString();
Object payer = resourceMap.get("payer");
UserPay user = JSONObject.parseObject(JSONObject.toJSONString(payer),UserPay.class);
String openId = user.getOpenId();
Object amount = resourceMap.get("amount");
Amount amount1 = JSONObject.parseObject(JSONObject.toJSONString(amount),Amount.class);
String total = amount1.getTotal();
WaterWxpayOrder wxpayOrder = new WaterWxpayOrder(); WaterWxpayOrder wxpayOrder = new WaterWxpayOrder();
wxpayOrder.setOutTradeNo(outTradeNo); wxpayOrder.setOutTradeNo(outTradeNo);
wxpayOrder.setTradeState(tradeState); wxpayOrder.setTradeState(tradeState);
...@@ -95,17 +150,30 @@ public class CallbackController { ...@@ -95,17 +150,30 @@ public class CallbackController {
wxpayOrder.setAppId(appId); wxpayOrder.setAppId(appId);
wxpayOrder.setTradeType(tradeType); wxpayOrder.setTradeType(tradeType);
wxpayOrder.setBankType(bankType); wxpayOrder.setBankType(bankType);
wxpayOrder.setPayerTotal(payerTotal);
wxpayOrder.setTotal(total);
wxpayOrder.setCurrency(currency);
wxpayOrder.setPayerCurrency(payerCurrency);
int pay = wxpayOrderMapper.insertWxpay(wxpayOrder); int pay = wxpayOrderMapper.insertWxpay(wxpayOrder);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssX");
Date date = sdf.parse(successTime);
WaterOrderLog orderLog = new WaterOrderLog();
orderLog.setPayNum(attach);
orderLog.setPayTime(date);
orderLog.setPayMoney(new BigDecimal(total));
int iLog = orderLogMapper.insertWaterOrderLog(orderLog);
if(desc.equals("支付成功")){
WaterOrderVo orderVo = new WaterOrderVo();
orderVo.setOrderNum(attach);
int orderI = orderMapper.updateByOrderNum(orderVo);
}
// String transactionId = resourceMap.get("transaction_id").toString(); // String transactionId = resourceMap.get("transaction_id").toString();
// 更改状态 获取订单号 修改订单状态为已支付 // 更改状态 获取订单号 修改订单状态为已支付
// TODO 根据订单号,做幂等处理,并且在对业务数据进行状态检查和处理之前,要采用数据锁进行并发控制,以避免函数重入造成的数据混乱 // TODO 根据订单号,做幂等处理,并且在对业务数据进行状态检查和处理之前,要采用数据锁进行并发控制,以避免函数重入造成的数据混乱
log.warn("=========== 根据订单号,做幂等处理 ==========="); log.warn("=========== 根据订单号,做幂等处理 ===========");
} catch (ParseException e) {
e.printStackTrace();
} finally { } finally {
//要主动释放锁 //要主动释放锁
lock.unlock(); lock.unlock();
...@@ -149,7 +217,7 @@ public class CallbackController { ...@@ -149,7 +217,7 @@ public class CallbackController {
* @return * @return
*/ */
@PostMapping("/refundNotify") @PostMapping("/refundNotify")
public Map<String, String> refundNotify(HttpServletRequest request, HttpServletResponse response) { public Map<String, String> refundNotify(HttpServletRequest request, HttpServletResponse response) throws NotFoundException, HttpCodeException, GeneralSecurityException, IOException {
log.info("退款回调"); log.info("退款回调");
// 处理通知参数 // 处理通知参数
...@@ -181,28 +249,58 @@ public class CallbackController { ...@@ -181,28 +249,58 @@ public class CallbackController {
return trueMsg(response); return trueMsg(response);
} }
private Map<String, Object> getNotifyBody(HttpServletRequest request) { private Map<String, Object> getNotifyBody(HttpServletRequest request) throws GeneralSecurityException, IOException, NotFoundException, HttpCodeException {
//处理通知参数 //处理通知参数
String body = WechatPayValidator.readData(request); String body = WechatPayValidator.getRequestBody(request);
log.info("退款回调参数:{}", body); log.info("退款回调参数:{}", body);
// 转换为Map // 转换为Map
Map<String, Object> bodyMap = JSONObject.parseObject(body, new TypeReference<Map<String, Object>>() { Map<String, Object> bodyMap = JSONObject.parseObject(body, new TypeReference<Map<String, Object>>() {
}); });
// 微信的通知ID(通知的唯一ID)
String notifyId = bodyMap.get("id").toString();
// 验证签名信息 //微信传递过来的签名
WechatPayValidator wechatPayValidator String signature = request.getHeader("Wechatpay-Signature");
= new WechatPayValidator(verifier, notifyId, body);
if (!wechatPayValidator.validate(request)) { //证书序列号(微信平台)
String serialNo = request.getHeader("Wechatpay-Serial");
log.error("通知验签失败");
return null; //随机串
String nonceStr = request.getHeader("Wechatpay-Nonce");
String timestamp = request.getHeader("Wechatpay-Timestamp");
PrivateKey pk1 = PemUtil.loadPrivateKey(new ByteArrayInputStream(pk.getBytes("utf-8")));
// 获取证书管理器实例
CertificatesManager certificatesManager = CertificatesManager.getInstance();
// 向证书管理器增加需要自动更新平台证书的商户信息
certificatesManager.putMerchant(wechatPayConfig.getMchId(),
new WechatPay2Credentials(wechatPayConfig.getMchId(), new PrivateKeySigner(wechatPayConfig.getSerialNo(), pk1)),
wechatPayConfig.getApiV3Key().getBytes("UTF-8"));
// 从证书管理器中获取verifier
Verifier verifier = certificatesManager.getVerifier(wechatPayConfig.getMchId());
String VerifySignature = Stream.of(timestamp, nonceStr, body).collect(Collectors.joining("\n", "", "\n"));
boolean verify = verifier.verify(serialNo, VerifySignature.getBytes(), signature);
if(!verify){
log.info("通知验签失败");
} }
log.info("通知验签成功"); log.info("通知验签成功");
return bodyMap; return bodyMap;
} }
private Map<String, String> falseMsg(HttpServletResponse response) { private Map<String, String> falseMsg(HttpServletResponse response) {
Map<String, String> resMap = new HashMap<>(8); Map<String, String> resMap = new HashMap<>(8);
//失败应答 //失败应答
......
...@@ -16,12 +16,12 @@ import com.qianhe.system.domain.WaterOrder; ...@@ -16,12 +16,12 @@ import com.qianhe.system.domain.WaterOrder;
import com.qianhe.system.mapper.WaterOrderMapper; import com.qianhe.system.mapper.WaterOrderMapper;
import com.qianhe.system.service.IWaterOrderService; import com.qianhe.system.service.IWaterOrderService;
import com.qianhe.system.utils.WechatPayRequest; import com.qianhe.system.utils.WechatPayRequest;
import com.wechat.pay.contrib.apache.httpclient.util.PemUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import sun.misc.BASE64Decoder;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.io.IOException; import java.io.IOException;
...@@ -29,8 +29,10 @@ import java.math.BigDecimal; ...@@ -29,8 +29,10 @@ import java.math.BigDecimal;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.security.KeyFactory;
import java.security.PrivateKey; import java.security.PrivateKey;
import java.security.Signature; import java.security.Signature;
import java.security.spec.PKCS8EncodedKeySpec;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Base64; import java.util.Base64;
import java.util.HashMap; import java.util.HashMap;
...@@ -63,11 +65,39 @@ public class PayController { ...@@ -63,11 +65,39 @@ public class PayController {
@Autowired @Autowired
private WaterOrderMapper waterOrderMapper; private WaterOrderMapper waterOrderMapper;
private String pk = "MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQC+vQS+6VGcsX6i\n" +
"Au5HhEXviSfTuI+F3ZHGD/9m/3sPNxIsiA/46E9vk0+Ulxmaxr5x6KNbyko/XVmQ\n" +
"MN1vxFO/rGpqk24shDWZpxyMEwMxvw4EcbhbGmzRoxmrwUbujmJznIq6JcqqaBHa\n" +
"Z9LwHzVWtOZsRwHVr6KivRZr27bN3aEv26nnMTDkg1tkwi0AKG4EmxlYU5zjnFXh\n" +
"3TDkOZYZsq24bXllSCXlTCCWpBgPbNyBzAshT3M9nD4GeW+sqrnsVMEbaSxjd6xg\n" +
"uB28OCxyOb1BJKXEZYQJBmQ+ik8GoNQtx/00tE1Y5GPH+QONs1sYlQhu4FFTtvvS\n" +
"069DIOfjAgMBAAECggEBAKg8NkxhpS9tSwGBTkRcQgdGVY+kMUtkpCgrgh2J6DQC\n" +
"YhBPLq9f0HjcWQv5vobLF72G8VeL9LMxFkddImNrqmbcn7xDL6EqN9DAGijeuCmP\n" +
"l8CJwY7xntvFXWYmAvd1NRc+EwqfPMPTKTQX8XEERdqlkrwcYVzmHrAl0fnugK3Q\n" +
"btsO931xHGJ98CSVOMURiRmTdjKAahXYIlWfU0Xdqb+16uIPD31tLC17Kf5+Odpd\n" +
"Rv9rxLBrp6FxuA+fwkKT+f3bNxLOQfmsb+0nuE/8lNe3VslV96K+CUB7MELQ3wx3\n" +
"hQ5BgVa3JNpOlY5TMjyP+Yi+OEA+KJ/xPMKsieP6fFECgYEA+FxERDwoAWjn5V5x\n" +
"7yVAJ4Vnd5WaIxIU6J8YDjDX5CEzXsICoubxioAPbZoC93T/6h8WGWvm3s8FfIlp\n" +
"dWRIAK/YA4fqAwcEyTuk6p2upU1IAyjz09n+OshIvBZ+j/b05xFk5nMM616HZrAn\n" +
"mIB1isDn8UhKPKjhx2JatOvdBqsCgYEAxJsAoizmYHYeY0aW+HX2h9LqImxCuPmK\n" +
"izaMZCxq9RBGwGT/UyHXo3CBr+SILvjAYtKDi5danIygiVp76yBWBQQmKh5f0z7m\n" +
"FoPRwmf7o1qMV+KuFdydLuinA5864aONOEeoQOBuWP6fJ11+37ezVTsUyuC+fjhX\n" +
"1+uNnhNqg6kCgYBjXxd5bdBb8AuI/Kb9lpv6tCfX8yW/DocLJEzNsMFQ5+/T5DCF\n" +
"2X2feumxYsP5GvkiRdnjxgaT86UwVRK7A6rDi5gUoZcCKxbBJXow3XJ5dVhw2zvj\n" +
"8f8EqgpgJ2fwVlFa+tyyUCpFKodmkOjm3c8p+1FSeygo6TGdQz8j0JOZDQKBgQCx\n" +
"+2RybFVOZAAUfXX0jc3VneGpsfohPH7okkQ7914IZmi2iXf/CTcO1a4BztBePYDk\n" +
"tZCykR1NdZ1rWsetzsMwnVXzcTXsphdjsIf3B21tr243rZVNYz/ElIeFpuOGGyqg\n" +
"FXbC7KnY1QC9gU13N/UYJnknRJgO6fDUHoFA5nDZqQKBgADTGuWavhnw1SCRYZhz\n" +
"QtonO5hXjNjwZHcmEaEneI3+9X64TQgXY1hQe3WWLUwDNyAhlsT8y1Jl1kgL0tJP\n" +
"mxz0fsu47RdFR1rX+3ZIF5jNaxR6UIN2GQLlhvB7PCl7znKpph/nVthTO681Vx3V\n" +
"mP/wQpwy8cWtmbyl7lcvVRN5";
/** /**
* 预支付订单生成入口 * 预支付订单生成入口
*/ */
@GetMapping("/transactions") @GetMapping("/transactions")
public AjaxResult transactions(WaterGoods goods) throws IOException { public AjaxResult transactions(WaterGoods goods) throws Exception {
// 统一参数封装 // 统一参数封装
Map<String, Object> params = new HashMap<>(10); Map<String, Object> params = new HashMap<>(10);
...@@ -78,11 +108,14 @@ public class PayController { ...@@ -78,11 +108,14 @@ public class PayController {
// 3.description body:商品描述。 // 3.description body:商品描述。
params.put("description", goods.getTitle()); params.put("description", goods.getTitle());
// 4.out_trade_no:商户订单号,由商户自定义。 // 4.out_trade_no:商户订单号,由商户自定义。
params.put("out_trade_no", getOrerNum()); params.put("out_trade_no", goods.getOrderNo());
// 5.notify_url:接收微信支付异步通知回调地址。 // 5.notify_url:接收微信支付异步通知回调地址。
params.put("notify_url", wechatPayConfig.getNotifyUrl()); params.put("notify_url", wechatPayConfig.getNotifyUrl());
// 6.total_fee:订单总金额,单位为分。 //6.
params.put("attach",goods.getOrderNo());
// 7.total_fee:订单总金额,单位为分。
Map<String, Object> amountMap = new HashMap<>(4); Map<String, Object> amountMap = new HashMap<>(4);
// 金额单位为分 // 金额单位为分
amountMap.put("total", (int)Math.floor(Double.parseDouble(goods.getTotalPrice())*100)); amountMap.put("total", (int)Math.floor(Double.parseDouble(goods.getTotalPrice())*100));
amountMap.put("currency", "CNY"); amountMap.put("currency", "CNY");
...@@ -128,6 +161,7 @@ public class PayController { ...@@ -128,6 +161,7 @@ public class PayController {
// 签名方式 // 签名方式
map.put("signType", "RSA"); map.put("signType", "RSA");
// 获取签名 // 获取签名
String sign = getPaySign(timeStamp,nonceStr,"prepay_id="+prepayId); String sign = getPaySign(timeStamp,nonceStr,"prepay_id="+prepayId);
...@@ -138,49 +172,32 @@ public class PayController { ...@@ -138,49 +172,32 @@ public class PayController {
} }
public String getPaySign(String timeStamp, String nonceStr, String packageStr) throws IOException { public String getPaySign(String timeStamp, String nonceStr, String packageStr) throws Exception {
String sourceText = wechatPayConfig.getAppId() + StrUtil.LF + timeStamp + StrUtil.LF + nonceStr + StrUtil.LF + packageStr + StrUtil.LF; String sourceText = wechatPayConfig.getAppId() + StrUtil.LF + timeStamp + StrUtil.LF + nonceStr + StrUtil.LF + packageStr + StrUtil.LF;
log.info("微信支付签名原文:{}", sourceText); log.info("微信支付签名原文:{}", sourceText);
byte[] sign = SecureUtil.sign(SignAlgorithm.SHA256withRSA) /*byte[] sign = SecureUtil.sign(SignAlgorithm.SHA256withRSA)
.setPrivateKey(wechatPayConfig.getPrivateKey(wechatPayConfig.getKeyPemPath())) .setPrivateKey(wechatPayConfig.getPrivateKey(wechatPayConfig.getKeyPemPath()))
.sign(sourceText);*/
PrivateKey key = getPrivateKey(pk);
byte[] sign = SecureUtil.sign(SignAlgorithm.SHA256withRSA)
.setPrivateKey(key)
.sign(sourceText); .sign(sourceText);
String paySign = Base64Encoder.encode(sign); String paySign = Base64Encoder.encode(sign);
log.info("微信支付签名密文:{}", paySign); log.info("微信支付签名密文:{}", paySign);
return paySign; return paySign;
} }
/** public static PrivateKey getPrivateKey(String key) throws Exception {
* 生成订单编号 byte[] keyBytes;
* @return keyBytes = (new BASE64Decoder()).decodeBuffer(key);
*/ PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(keyBytes);
public String getOrerNum(){ KeyFactory keyFactory = KeyFactory.getInstance("RSA");
String orderNum = ""; PrivateKey privateKey = keyFactory.generatePrivate(keySpec);
//获取当前年月日 return privateKey;
SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
String today = format.format(DateUtils.getNowDate());
Long rqbh = Long.parseLong(today + "0001");
while (true){
WaterOrder waterOrder = new WaterOrder();
waterOrder.setOrderNum(rqbh.toString());
WaterOrder waterOrder1 = waterOrderMapper.selectWaterOrderNumByOrderNum(rqbh.toString());
if (StringUtils.isNotNull(waterOrder1)){
rqbh ++;
}else {
break;
}
}
//生成随机四位英文字母
Random random = new Random();
String randomletters = "";
for (int i = 0; i < 4; i++) {
int index = random.nextInt(26);
char letter = (char) ('A' + index);
randomletters += letter;
}
orderNum = rqbh + randomletters;
return orderNum;
} }
/** /**
* 获取一定长度的随机字符串 * 获取一定长度的随机字符串
* *
......
...@@ -210,11 +210,8 @@ public class WaterOrderController extends BaseController ...@@ -210,11 +210,8 @@ public class WaterOrderController extends BaseController
@RepeatSubmit(message = "订单已提交,请勿重复操作!") @RepeatSubmit(message = "订单已提交,请勿重复操作!")
public AjaxResult add(@RequestBody WaterOrderVo waterOrderVo) public AjaxResult add(@RequestBody WaterOrderVo waterOrderVo)
{ {
int i = waterOrderService.insertWaterOrder(waterOrderVo); String ddh = waterOrderService.insertWaterOrder(waterOrderVo);
if (i == -1){ return success(ddh);
return AjaxResult.error("该地址超出配送范围,请重新选择地址!");
}
return toAjax(i);
} }
/** /**
......
...@@ -162,6 +162,8 @@ public class WaterStationController extends BaseController ...@@ -162,6 +162,8 @@ public class WaterStationController extends BaseController
*/ */
@GetMapping("/getRecentlyStation1") @GetMapping("/getRecentlyStation1")
public AjaxResult getRecentlyStation1(@RequestParam("address") String address, @RequestParam("address1") String address1){ public AjaxResult getRecentlyStation1(@RequestParam("address") String address, @RequestParam("address1") String address1){
System.out.println("address====================="+address);
System.out.println("address1+++++++++++++++++++"+address1);
WaterStationVo recentlyStation = waterStationService.getRecentlyStation1(address, address1); WaterStationVo recentlyStation = waterStationService.getRecentlyStation1(address, address1);
return success(recentlyStation); return success(recentlyStation);
} }
......
package com.qianhe.system.controller;
import com.qianhe.common.annotation.Log;
import com.qianhe.common.core.controller.BaseController;
import com.qianhe.common.core.domain.AjaxResult;
import com.qianhe.common.core.page.TableDataInfo;
import com.qianhe.common.enums.BusinessType;
import com.qianhe.system.domain.WaterGoods;
import com.qianhe.system.domain.WaterStock;
import com.qianhe.system.domain.WaterUser;
import com.qianhe.system.service.IWaterStockService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* @author yc
* @version 1.0
* @className WaterStockController
* @date 2024/3/22 8:34
* @description
*/
@RestController
@RequestMapping("/system/stock")
public class WaterStockController extends BaseController {
@Autowired
private IWaterStockService stockService;
@PostMapping("/list")
public TableDataInfo list(@RequestBody WaterStock stock){
startPage();
List<WaterStock> list = stockService.list(stock);
return getDataTable(list);
}
@PostMapping("/add")
public AjaxResult add(@RequestBody WaterStock stock){
return toAjax(stockService.insertStock(stock));
}
@PostMapping("/edit")
public AjaxResult edit(@RequestBody WaterStock stock){
return toAjax(stockService.updateStock(stock));
}
@PostMapping("/delete")
public AjaxResult delete(@RequestBody WaterStock stock){
return toAjax(stockService.deleteStock(stock));
}
@GetMapping("/goodsList")
public TableDataInfo goodsList(){
startPage();
List<WaterStock> list = stockService.goodsList();
return getDataTable(list);
}
@PostMapping("/speList")
public TableDataInfo speList(@RequestBody WaterStock stock){
startPage();
List<WaterStock> list = stockService.speList(stock);
return getDataTable(list);
}
@GetMapping("/stationList")
public TableDataInfo stationList(){
startPage();
List<WaterStock> list = stockService.stationList();
return getDataTable(list);
}
}
\ No newline at end of file
...@@ -74,13 +74,14 @@ public class SsWxLogin { ...@@ -74,13 +74,14 @@ public class SsWxLogin {
* @return * @return
*/ */
@GetMapping("/login") @GetMapping("/login")
public AjaxResult login(@RequestParam("code") String code){ public AjaxResult login(@RequestParam("code") String code,@RequestParam("phoneNum") String phoneNum){
AjaxResult ajaxResult = AjaxResult.success(); AjaxResult ajaxResult = AjaxResult.success();
//根据code查询微信用户的openid和session_key //根据code查询微信用户的openid和session_key
Map<String, String> wxLoginInfo = wxUserInfoUtils.getWxLoginInfo(code); Map<String, String> wxLoginInfo = wxUserInfoUtils.getWxLoginInfo(code);
WxLoginBody wxLoginBody = new WxLoginBody(); WxLoginBody wxLoginBody = new WxLoginBody();
wxLoginBody.setOpenId(wxLoginInfo.get("openid")); wxLoginBody.setOpenId(wxLoginInfo.get("openid"));
wxLoginBody.setPhone(phoneNum);
MpLoginUser login = wxLoginService.ssLogin(wxLoginBody); MpLoginUser login = wxLoginService.ssLogin(wxLoginBody);
if (StringUtils.isNull(login)) { if (StringUtils.isNull(login)) {
return AjaxResult.error("login error"); return AjaxResult.error("login error");
...@@ -105,10 +106,10 @@ public class SsWxLogin { ...@@ -105,10 +106,10 @@ public class SsWxLogin {
return success(waterUserService.updateUserByOpenId(waterUser)); return success(waterUserService.updateUserByOpenId(waterUser));
} }
/** /* *//**
* 获取用户信息 * 获取用户信息
* @return * @return
*/ *//*
@GetMapping("/getUserInfo") @GetMapping("/getUserInfo")
public AjaxResult getUserInfo(){ public AjaxResult getUserInfo(){
//获取当前登录用户openid //获取当前登录用户openid
...@@ -129,6 +130,33 @@ public class SsWxLogin { ...@@ -129,6 +130,33 @@ public class SsWxLogin {
} }
map.put("waterStationUser",waterStationUser); map.put("waterStationUser",waterStationUser);
return AjaxResult.success(map); return AjaxResult.success(map);
}*/
/**
* 获取用户信息
* @return
*/
@GetMapping("/getUserInfo")
public AjaxResult getUserInfo(WaterUser user){
//获取当前登录用户openid
//String openId = userInfoUtil.getOpenId();
String openId = user.getOpenId();
Map<String,Object> map = new HashMap<>();
//根据openid查询用户信息
WaterUser waterUser = waterUserService.selectUserByOpenId(openId,"2");
map.put("userId",waterUser.getId());
map.put("nickName",waterUser.getNickName());
map.put("phoneNum",waterUser.getPhoneNum());
map.put("stationName",waterUser.getStationName());
map.put("userType",waterUser.getUserType());
map.put("userGender",waterUser.getUserGender());
//查询送水工站点信息
WaterStationUserVo waterStationUser = waterStationUserService.selectWaterStationUserByPhone(waterUser.getPhoneNum());
if (StringUtils.isNull(waterStationUser)){
return AjaxResult.warn("未查询到你的站点信息,请联系管理员!");
}
map.put("waterStationUser",waterStationUser);
return AjaxResult.success(map);
} }
/** /**
......
...@@ -67,13 +67,14 @@ public class WxLogin { ...@@ -67,13 +67,14 @@ public class WxLogin {
*/ */
@GetMapping("/login") @GetMapping("/login")
public AjaxResult login(@RequestParam("code") String code){ public AjaxResult login(@RequestParam("code") String code,@RequestParam("phoneNum") String phoneNum){
AjaxResult ajaxResult = AjaxResult.success(); AjaxResult ajaxResult = AjaxResult.success();
//根据code查询微信用户的openid和session_key //根据code查询微信用户的openid和session_key
Map<String, String> wxLoginInfo = wxUserInfoUtils.getWxLoginInfo(code); Map<String, String> wxLoginInfo = wxUserInfoUtils.getWxLoginInfo(code);
WxLoginBody wxLoginBody = new WxLoginBody(); WxLoginBody wxLoginBody = new WxLoginBody();
wxLoginBody.setOpenId(wxLoginInfo.get("openid")); wxLoginBody.setOpenId(wxLoginInfo.get("openid"));
wxLoginBody.setPhone(phoneNum);
MpLoginUser login = wxLoginService.login(wxLoginBody); MpLoginUser login = wxLoginService.login(wxLoginBody);
if (StringUtils.isNull(login)) { if (StringUtils.isNull(login)) {
return AjaxResult.error("login error"); return AjaxResult.error("login error");
...@@ -103,9 +104,9 @@ public class WxLogin { ...@@ -103,9 +104,9 @@ public class WxLogin {
* @return * @return
*/ */
@GetMapping("/getUserInfo") @GetMapping("/getUserInfo")
public AjaxResult getUserInfo(){ public AjaxResult getUserInfo(WaterUser user){
//获取当前登录用户openid //获取当前登录用户openid
String openId = userInfoUtil.getOpenId(); String openId = user.getOpenId();
Map<String,Object> map = new HashMap<>(); Map<String,Object> map = new HashMap<>();
//根据openid查询用户信息 //根据openid查询用户信息
WaterUser waterUser = waterUserService.selectUserByOpenId(openId,"1"); WaterUser waterUser = waterUserService.selectUserByOpenId(openId,"1");
......
package com.qianhe.system.domain;
import lombok.Data;
/**
* @author yc
* @version 1.0
* @className Amount
* @date 2024/3/26 17:28
* @description
*/
@Data
public class Amount {
private String total;
private String payerTotal;
private String currency;
private String payCurrency;
}
\ No newline at end of file
package com.qianhe.system.domain;
import lombok.Data;
/**
* @author yc
* @version 1.0
* @className ICCBackEntity
* @date 2024/3/28 11:06
* @description 建行回调实体类
*/
@Data
public class CCBBackEntity {
private String POSID; //商户柜台代码
private String BRANCHID;//分行代码
private String ORDERID; //定单号
private String PAYMENT; //付款金额
private String CURCODE; //币种
private String REMARK1; //备注一
private String REMARK2; //备注二
private String ACC_TYPE; //账户类型 服务器通知中有此字段返回且参与验签
private String SUCCESS; //成功标志 成功-Y,失败-N
private String TYPE; //接口类型 分行业务人员在P2员工渠道后台设置防钓鱼的开关。 1.开关关闭时,无此字段返回且不参与验签 2.开关打开时,有此字段返回且参与验签。参数值为 1-防钓鱼接口
private String REFERER; //Referer信息 分行业务人员在P2员工渠道后台设置防钓鱼开关。 1.开关关闭时,无此字段返回且不参与验签。 2.开关打开时,有此字段返回且参与验签
private String CLIENTIP; //客户端IP 分行业务人员在P2员工渠道后台设置防钓鱼的开关。 1.开关关闭时,无此字段返回且不参与验签 2.开关打开时,有此字段返回且参与验签。参数值为 客户在建行系统中的IP
private String ACCDATE; //系统记账日期 商户登陆商户后台设置返回记账日期的开关 1.开关关闭时,无此字段返回且不参与验签。 2.开关打开时,有此字段返回且参与验签。参数值格式为YYYYMMDD(如20100907)。
private String USRMSG; //支付账户信息 分行业务人员在P2员工渠道后台设置防钓鱼开关和返回账户信息的开关。 1.开关关闭时,无此字段返回且不参与验签。2.开关打开但支付失败时,无此字段返回且不参与验签。3.开关打开且支付成功时,有此字段返回且参与验签。无PAYTYPE返回时,参数值格式如下:“姓名|账号加密后的密文”。有PAYTYPE返回时,该参数值为空。
private String USRINFO; //客户加密信息 分行业务人员在P2员工渠道后台设置防钓鱼开关和客户信息加密返回的开关。 1.开关关闭时,无此字段返回且不参与验签
private String PAYTYPE; //支付方式 ALIPAY:支付宝 WEIXIN:微信 为空:建行龙支付 该字段有返回时参与验签,无此字段返回时不参与验签。
private String SIGN; //数字签名
}
\ No newline at end of file
package com.qianhe.system.domain;
import lombok.Data;
/**
* @author yc
* @version 1.0
* @className UserPay
* @date 2024/3/26 16:19
* @description
*/
@Data
public class UserPay {
private String openId;
}
\ No newline at end of file
...@@ -68,4 +68,6 @@ public class WaterGoods ...@@ -68,4 +68,6 @@ public class WaterGoods
private String openId; private String openId;
private String totalPrice; private String totalPrice;
private String orderNo;
} }
...@@ -9,6 +9,7 @@ import lombok.Data; ...@@ -9,6 +9,7 @@ import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle; import org.apache.commons.lang3.builder.ToStringStyle;
import java.math.BigDecimal;
import java.util.Date; import java.util.Date;
/** /**
...@@ -42,4 +43,7 @@ public class WaterGoodsSpe ...@@ -42,4 +43,7 @@ public class WaterGoodsSpe
/** 创建时间 */ /** 创建时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTime; private Date createTime;
/** 价格 */
private BigDecimal price;
} }
...@@ -5,6 +5,8 @@ import com.baomidou.mybatisplus.annotation.TableId; ...@@ -5,6 +5,8 @@ import com.baomidou.mybatisplus.annotation.TableId;
import com.qianhe.common.annotation.Excel; import com.qianhe.common.annotation.Excel;
import lombok.Data; import lombok.Data;
import java.math.BigDecimal;
/** /**
* 商品规格子表对象 water_spe_val * 商品规格子表对象 water_spe_val
* *
...@@ -16,7 +18,7 @@ public class WaterSpeVal ...@@ -16,7 +18,7 @@ public class WaterSpeVal
{ {
@TableId(value = "id", type = IdType.AUTO) @TableId(value = "id", type = IdType.AUTO)
private Long id; private String id;
/** 商品规格id */ /** 商品规格id */
private Long speId; private Long speId;
...@@ -27,4 +29,8 @@ public class WaterSpeVal ...@@ -27,4 +29,8 @@ public class WaterSpeVal
/** 规格值 */ /** 规格值 */
private String speVal; private String speVal;
private BigDecimal price;
private String speValId;
} }
package com.qianhe.system.domain;
import lombok.Data;
/**
* @author yc
* @version 1.0
* @className WaterStock
* @date 2024/3/21 16:37
* @description
*/
@Data
public class WaterStock {
private Long id;
private String stationName;
private Long stationId;
private String goodsName;
private Long goodsId;
private String speName;
private Long speId;
private Long nowStock;
private String delFlag;
}
\ No newline at end of file
...@@ -23,6 +23,12 @@ public interface WaterGoodsMapper ...@@ -23,6 +23,12 @@ public interface WaterGoodsMapper
*/ */
public WaterGoods selectWaterGoodsById(Long id); public WaterGoods selectWaterGoodsById(Long id);
WaterGoods selectWaterGoodsById1(Long id);
WaterGoods selectGoodsIdByCarId(Long id);
WaterGoods getPriceByID(Long id);
/** /**
* 查询商品列表 * 查询商品列表
* *
......
...@@ -56,6 +56,8 @@ public interface WaterOrderMapper ...@@ -56,6 +56,8 @@ public interface WaterOrderMapper
*/ */
public int updateWaterOrder(WaterOrderVo waterOrderVo); public int updateWaterOrder(WaterOrderVo waterOrderVo);
int updateByOrderNum(WaterOrderVo waterOrderVo);
/** /**
* 删除订单 * 删除订单
* *
......
...@@ -78,6 +78,9 @@ public interface WaterSpeMapper ...@@ -78,6 +78,9 @@ public interface WaterSpeMapper
*/ */
public int deleteWaterSpeValBySpeId(Long id); public int deleteWaterSpeValBySpeId(Long id);
int deleteWaterGoodsSpeValBySpeId(Long id);
/** /**
* 批量删除商品规格规格值 * 批量删除商品规格规格值
* *
...@@ -91,4 +94,6 @@ public interface WaterSpeMapper ...@@ -91,4 +94,6 @@ public interface WaterSpeMapper
* @param waterSpeVals * @param waterSpeVals
*/ */
void batchInsertWaterSpeVal(List<WaterSpeVal> waterSpeVals); void batchInsertWaterSpeVal(List<WaterSpeVal> waterSpeVals);
void batchInsertWaterGoodsSpeVal(List<WaterSpeVal> waterSpeVals);
} }
package com.qianhe.system.mapper;
import com.qianhe.system.domain.WaterStock;
import java.util.List;
/**
* @author yc
* @version 1.0
* @className WaterStockMapper
* @date 2024/3/22 8:10
* @description
*/
public interface WaterStockMapper {
List<WaterStock> list(WaterStock stock);
int updateStock(WaterStock stock);
int insertStock(WaterStock stock);
int deleteStock(WaterStock stock);
List<WaterStock> goodsList();
List<WaterStock> speList(WaterStock stock);
List<WaterStock> stationList();
}
\ No newline at end of file
...@@ -37,7 +37,7 @@ public interface IWaterOrderService ...@@ -37,7 +37,7 @@ public interface IWaterOrderService
* @param waterOrderVo 订单 * @param waterOrderVo 订单
* @return 结果 * @return 结果
*/ */
public int insertWaterOrder(WaterOrderVo waterOrderVo); public String insertWaterOrder(WaterOrderVo waterOrderVo);
/** /**
* 修改订单 * 修改订单
......
package com.qianhe.system.service;
import com.qianhe.system.domain.WaterStock;
import java.util.List;
/**
* @author yc
* @version 1.0
* @className IWaterStockService
* @date 2024/3/22 8:12
* @description
*/
public interface IWaterStockService {
List<WaterStock> list(WaterStock stock);
int updateStock(WaterStock stock);
int insertStock(WaterStock stock);
int deleteStock(WaterStock stock);
List<WaterStock> goodsList();
List<WaterStock> speList(WaterStock stock);
List<WaterStock> stationList();
}
\ No newline at end of file
...@@ -70,7 +70,7 @@ public class WaterGoodsCartServiceImpl implements IWaterGoodsCartService { ...@@ -70,7 +70,7 @@ public class WaterGoodsCartServiceImpl implements IWaterGoodsCartService {
return waterGoodsCartMapper.updateWaterGoodsCart(waterGoodsCart2); return waterGoodsCartMapper.updateWaterGoodsCart(waterGoodsCart2);
} }
//根据商品id查询商品信息 //根据商品id查询商品信息
WaterGoods waterGoods = waterGoodsMapper.selectWaterGoodsById(waterGoodsCart.getGoodsId()); WaterGoods waterGoods = waterGoodsMapper.selectWaterGoodsById1(waterGoodsCart.getGoodsId());
//根据规格值id查询规格值 //根据规格值id查询规格值
WaterGoodsSpeVal waterGoodsSpeVal = waterGoodsSpeMapper.selectWaterGoodsSpeValById(waterGoodsCart.getGoodsSpeValId()); WaterGoodsSpeVal waterGoodsSpeVal = waterGoodsSpeMapper.selectWaterGoodsSpeValById(waterGoodsCart.getGoodsSpeValId());
waterGoodsCart.setGoodsName(waterGoods.getTitle()); waterGoodsCart.setGoodsName(waterGoods.getTitle());
......
...@@ -53,7 +53,9 @@ public class WaterGoodsServiceImpl implements IWaterGoodsService ...@@ -53,7 +53,9 @@ public class WaterGoodsServiceImpl implements IWaterGoodsService
@Override @Override
public WaterGoodsVo selectWaterGoodsById(Long id) public WaterGoodsVo selectWaterGoodsById(Long id)
{ {
WaterGoods waterGoods = waterGoodsMapper.selectWaterGoodsById(id); WaterGoods waterGoods = waterGoodsMapper.selectWaterGoodsById1(id);
WaterGoods goodsPrice = waterGoodsMapper.getPriceByID(id);
waterGoods.setPrice(goodsPrice.getPrice());
//转vo //转vo
WaterGoodsVo waterGoodsVo = new WaterGoodsVo(); WaterGoodsVo waterGoodsVo = new WaterGoodsVo();
BeanUtils.copyProperties(waterGoods,waterGoodsVo); BeanUtils.copyProperties(waterGoods,waterGoodsVo);
...@@ -471,7 +473,7 @@ public class WaterGoodsServiceImpl implements IWaterGoodsService ...@@ -471,7 +473,7 @@ public class WaterGoodsServiceImpl implements IWaterGoodsService
@Override @Override
public WaterGoodsVo getGoodsXq(WaterGoodsVo waterGoodsVo) { public WaterGoodsVo getGoodsXq(WaterGoodsVo waterGoodsVo) {
//根据商品id查询商品详细信息 //根据商品id查询商品详细信息
WaterGoods waterGoods = waterGoodsMapper.selectWaterGoodsById(waterGoodsVo.getId()); WaterGoods waterGoods = waterGoodsMapper.selectWaterGoodsById1(waterGoodsVo.getId());
//转vo //转vo
WaterGoodsVo waterGoodsVo1 = new WaterGoodsVo(); WaterGoodsVo waterGoodsVo1 = new WaterGoodsVo();
BeanUtils.copyProperties(waterGoods,waterGoodsVo1); BeanUtils.copyProperties(waterGoods,waterGoodsVo1);
......
...@@ -112,29 +112,32 @@ public class WaterOrderServiceImpl implements IWaterOrderService ...@@ -112,29 +112,32 @@ public class WaterOrderServiceImpl implements IWaterOrderService
*/ */
@Override @Override
@Transactional @Transactional
public int insertWaterOrder(WaterOrderVo waterOrderVo) public String insertWaterOrder(WaterOrderVo waterOrderVo)
{ {
//判断用户下单是否有地址 //判断用户下单是否有地址
if (StringUtils.isNull(waterOrderVo.getUserAddressId())){ /*if (StringUtils.isNull(waterOrderVo.getUserAddressId())){
throw new ServiceException("未选择地址!"); throw new ServiceException("未选择地址!");
} }*/
//判断用户地址是否在配送范围之内 //判断用户地址是否在配送范围之内
List<WaterStationVo> stations = getStation(waterOrderVo); //前端已做下单控制,此处不用再做处理
/*List<WaterStationVo> stations = getStation(waterOrderVo);
if (stations.size() <= 0){ if (stations.size() <= 0){
return -1; return -1;
} }*/
WaterStationVo station = stations.get(0); /* WaterStationVo station = stations.get(0);
waterOrderVo.setStationId(station.getId()); waterOrderVo.setStationId(station.getId());
waterOrderVo.setStationName(station.getStationName()); waterOrderVo.setStationName(station.getStationName());
waterOrderVo.setStationPhone(station.getPhoneNum()); waterOrderVo.setStationPhone(station.getPhoneNum());
waterOrderVo.setStationProvince(station.getProvince()); waterOrderVo.setStationProvince(station.getProvince());
waterOrderVo.setStationCity(station.getCity()); waterOrderVo.setStationCity(station.getCity());
waterOrderVo.setStationArea(station.getArea()); waterOrderVo.setStationArea(station.getArea());
waterOrderVo.setStationAddress(station.getStationAddress()); waterOrderVo.setStationAddress(station.getStationAddress());*/
waterOrderVo.setCreateUser(waterOrderVo.getUserId().toString()); waterOrderVo.setCreateUser(waterOrderVo.getUserId().toString());
waterOrderVo.setCreateTime(DateUtils.getNowDate()); waterOrderVo.setCreateTime(DateUtils.getNowDate());
waterOrderVo.setOrderNum(getOrerNum()); String ddh = getOrerNum();
waterOrderVo.setOrderNum(ddh);
//判断支付方式是否为水票支付 //判断支付方式是否为水票支付
if(waterOrderVo.getPayType() == 2){ if(waterOrderVo.getPayType() == 2){
//水票支付,修改订单状态为待接单 //水票支付,修改订单状态为待接单
...@@ -150,7 +153,7 @@ public class WaterOrderServiceImpl implements IWaterOrderService ...@@ -150,7 +153,7 @@ public class WaterOrderServiceImpl implements IWaterOrderService
int i = waterOrderMapper.insertWaterOrder(waterOrderVo); int i = waterOrderMapper.insertWaterOrder(waterOrderVo);
//新增订单商品 //新增订单商品
insertWaterOrderGoods(waterOrderVo); insertWaterOrderGoods(waterOrderVo);
return i; return ddh;
} }
/** /**
...@@ -226,7 +229,7 @@ public class WaterOrderServiceImpl implements IWaterOrderService ...@@ -226,7 +229,7 @@ public class WaterOrderServiceImpl implements IWaterOrderService
//根据商品信息查询购物车商品信息 //根据商品信息查询购物车商品信息
WaterGoodsCart waterGoodsCart = new WaterGoodsCart(); WaterGoodsCart waterGoodsCart = new WaterGoodsCart();
waterGoodsCart.setUserId(waterOrderVo.getUserId()); waterGoodsCart.setUserId(waterOrderVo.getUserId());
waterGoodsCart.setGoodsId(waterOrderGoods.getGoodsId()); waterGoodsCart.setId(waterOrderGoods.getGoodsId());
waterGoodsCart.setGoodsSpeVal(waterOrderGoods.getGoodsSpe()); waterGoodsCart.setGoodsSpeVal(waterOrderGoods.getGoodsSpe());
List<WaterGoodsCart> list = waterGoodsCartMapper.selectWaterGoodsCartList(waterGoodsCart); List<WaterGoodsCart> list = waterGoodsCartMapper.selectWaterGoodsCartList(waterGoodsCart);
WaterGoodsCart waterGoodsCart1 = list.get(0); WaterGoodsCart waterGoodsCart1 = list.get(0);
...@@ -234,7 +237,7 @@ public class WaterOrderServiceImpl implements IWaterOrderService ...@@ -234,7 +237,7 @@ public class WaterOrderServiceImpl implements IWaterOrderService
waterGoodsCartMapper.deleteWaterGoodsCartById(waterGoodsCart1.getId()); waterGoodsCartMapper.deleteWaterGoodsCartById(waterGoodsCart1.getId());
} }
//根据商品id查询商品信息 //根据商品id查询商品信息
WaterGoods waterGoods = waterGoodsMapper.selectWaterGoodsById(waterOrderGoods.getGoodsId()); WaterGoods waterGoods = waterGoodsMapper.selectWaterGoodsById1(waterOrderGoods.getGoodsId());
//判断商品是否下架 //判断商品是否下架
if (waterGoods.getStatus() == 0) { if (waterGoods.getStatus() == 0) {
throw new ServiceException("该商品已下架,请您重新选择商品!"); throw new ServiceException("该商品已下架,请您重新选择商品!");
......
...@@ -14,6 +14,7 @@ import org.springframework.stereotype.Service; ...@@ -14,6 +14,7 @@ import org.springframework.stereotype.Service;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.UUID;
/** /**
* 商品规格Service业务层处理 * 商品规格Service业务层处理
...@@ -87,6 +88,9 @@ public class WaterSpeServiceImpl implements IWaterSpeService ...@@ -87,6 +88,9 @@ public class WaterSpeServiceImpl implements IWaterSpeService
Long id = waterSpeVo.getId(); Long id = waterSpeVo.getId();
if (StringUtils.isNotNull(waterSpeValList)){ if (StringUtils.isNotNull(waterSpeValList)){
for (WaterSpeVal waterSpeVal : waterSpeValList) { for (WaterSpeVal waterSpeVal : waterSpeValList) {
String idd = UUID.randomUUID().toString();
waterSpeVal.setId(idd);
waterSpeVal.setSpeValId(idd);
waterSpeVal.setSpeId(id); waterSpeVal.setSpeId(id);
waterSpeVals.add(waterSpeVal); waterSpeVals.add(waterSpeVal);
} }
...@@ -94,6 +98,7 @@ public class WaterSpeServiceImpl implements IWaterSpeService ...@@ -94,6 +98,7 @@ public class WaterSpeServiceImpl implements IWaterSpeService
if (waterSpeVals.size() > 0){ if (waterSpeVals.size() > 0){
//批量新增 //批量新增
waterSpeMapper.batchInsertWaterSpeVal(waterSpeVals); waterSpeMapper.batchInsertWaterSpeVal(waterSpeVals);
waterSpeMapper.batchInsertWaterGoodsSpeVal(waterSpeVals);
} }
} }
...@@ -108,6 +113,7 @@ public class WaterSpeServiceImpl implements IWaterSpeService ...@@ -108,6 +113,7 @@ public class WaterSpeServiceImpl implements IWaterSpeService
{ {
//删除商品规格关联的规格规格值 //删除商品规格关联的规格规格值
waterSpeMapper.deleteWaterSpeValBySpeId(waterSpeVo.getId()); waterSpeMapper.deleteWaterSpeValBySpeId(waterSpeVo.getId());
waterSpeMapper.deleteWaterGoodsSpeValBySpeId(waterSpeVo.getId());
//新增规格规格值 //新增规格规格值
insertWaterSpeVal(waterSpeVo); insertWaterSpeVal(waterSpeVo);
return waterSpeMapper.updateWaterSpe(waterSpeVo); return waterSpeMapper.updateWaterSpe(waterSpeVo);
......
...@@ -256,13 +256,16 @@ public class WaterStationServiceImpl implements IWaterStationService ...@@ -256,13 +256,16 @@ public class WaterStationServiceImpl implements IWaterStationService
double[] doubles; double[] doubles;
if(address1.contains(address)){ if(address1.contains(address)){
doubles = AMapUtils.addressToGPS(address); doubles = AMapUtils.addressToGPS(address1);
}else { }else {
doubles = AMapUtils.addressToGPS(address+address1); doubles = AMapUtils.addressToGPS(address+address1);
} }
double lon = doubles[0]; double lon = doubles[0];
double lat = doubles[1]; double lat = doubles[1];
System.out.println(lon+"-------------"+lat);
//查询所有站点信息 //查询所有站点信息
List<WaterStation> waterStations = waterStationMapper.selectWaterStationList(new WaterStation()); List<WaterStation> waterStations = waterStationMapper.selectWaterStationList(new WaterStation());
List<WaterStationVo> waterStationVoList = new ArrayList<>(); List<WaterStationVo> waterStationVoList = new ArrayList<>();
...@@ -270,6 +273,7 @@ public class WaterStationServiceImpl implements IWaterStationService ...@@ -270,6 +273,7 @@ public class WaterStationServiceImpl implements IWaterStationService
for (WaterStation waterStation : waterStations) { for (WaterStation waterStation : waterStations) {
//计算距离 //计算距离
double distance = PositionUtil.getDistance1(lon, lat, waterStation.getStationLonTen(), waterStation.getStationLatTen()); double distance = PositionUtil.getDistance1(lon, lat, waterStation.getStationLonTen(), waterStation.getStationLatTen());
System.out.println("dis---------------"+distance);
if(distance<5000){ if(distance<5000){
WaterStationVo waterStationVo = new WaterStationVo(); WaterStationVo waterStationVo = new WaterStationVo();
BeanUtils.copyProperties(waterStation,waterStationVo); BeanUtils.copyProperties(waterStation,waterStationVo);
......
package com.qianhe.system.service.impl;
import com.qianhe.system.domain.WaterStock;
import com.qianhe.system.mapper.WaterStockMapper;
import com.qianhe.system.service.IWaterStockService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @author yc
* @version 1.0
* @className WaterStockServiceImpl
* @date 2024/3/22 8:12
* @description
*/
@Service
public class WaterStockServiceImpl implements IWaterStockService {
@Autowired
private WaterStockMapper stockMapper;
@Override
public List<WaterStock> list(WaterStock stock) {
return stockMapper.list(stock);
}
@Override
public int updateStock(WaterStock stock) {
return stockMapper.updateStock(stock);
}
@Override
public int insertStock(WaterStock stock) {
return stockMapper.insertStock(stock);
}
@Override
public int deleteStock(WaterStock stock) {
return stockMapper.deleteStock(stock);
}
@Override
public List<WaterStock> goodsList() {
return stockMapper.goodsList();
}
@Override
public List<WaterStock> speList(WaterStock stock) {
return stockMapper.speList(stock);
}
@Override
public List<WaterStock> stationList() {
return stockMapper.stationList();
}
}
\ No newline at end of file
...@@ -35,6 +35,7 @@ public class WxLoginServiceImpl implements IWxLoginService { ...@@ -35,6 +35,7 @@ public class WxLoginServiceImpl implements IWxLoginService {
waterUser.setUserType("1"); waterUser.setUserType("1");
waterUser.setOpenId(wxLoginBody.getOpenId()); waterUser.setOpenId(wxLoginBody.getOpenId());
waterUser.setCreateTime(DateUtils.getNowDate()); waterUser.setCreateTime(DateUtils.getNowDate());
waterUser.setPhoneNum(Long.valueOf(wxLoginBody.getPhone()));
waterUserMapper.insertWaterUser(waterUser); waterUserMapper.insertWaterUser(waterUser);
MpLoginUser loginUser = new MpLoginUser(); MpLoginUser loginUser = new MpLoginUser();
...@@ -56,6 +57,7 @@ public class WxLoginServiceImpl implements IWxLoginService { ...@@ -56,6 +57,7 @@ public class WxLoginServiceImpl implements IWxLoginService {
loginUser.setUserId(user.getId()); loginUser.setUserId(user.getId());
loginUser.setNickName(user.getNickName()); loginUser.setNickName(user.getNickName());
loginUser.setIsNewUser("0"); loginUser.setIsNewUser("0");
loginUser.setPhone(Long.valueOf(wxLoginBody.getPhone()));
return loginUser; return loginUser;
} }
//不存在,新增用户 //不存在,新增用户
...@@ -64,6 +66,7 @@ public class WxLoginServiceImpl implements IWxLoginService { ...@@ -64,6 +66,7 @@ public class WxLoginServiceImpl implements IWxLoginService {
waterUser.setUserType("2"); waterUser.setUserType("2");
waterUser.setOpenId(wxLoginBody.getOpenId()); waterUser.setOpenId(wxLoginBody.getOpenId());
waterUser.setCreateTime(DateUtils.getNowDate()); waterUser.setCreateTime(DateUtils.getNowDate());
waterUser.setPhoneNum(Long.valueOf(wxLoginBody.getPhone()));
waterUserMapper.insertWaterUser(waterUser); waterUserMapper.insertWaterUser(waterUser);
MpLoginUser loginUser = new MpLoginUser(); MpLoginUser loginUser = new MpLoginUser();
......
package com.qianhe.system.utils; package com.qianhe.system.utils;
import com.alibaba.fastjson.JSONObject;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
import java.net.URLConnection; import java.net.URLConnection;
import java.net.URLEncoder;
import java.util.Base64;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
...@@ -20,6 +24,7 @@ public class AMapUtils { ...@@ -20,6 +24,7 @@ public class AMapUtils {
public static final String KEY = "6dc239658cd94e2007b4f3c933106693"; public static final String KEY = "6dc239658cd94e2007b4f3c933106693";
private static Pattern pattern = Pattern.compile("\"location\":\"(\\d+\\.\\d+),(\\d+\\.\\d+)\""); private static Pattern pattern = Pattern.compile("\"location\":\"(\\d+\\.\\d+),(\\d+\\.\\d+)\"");
/** /**
* 通过具体位置,获取对应地图上的坐标: 经度、纬度 * 通过具体位置,获取对应地图上的坐标: 经度、纬度
* *
...@@ -28,7 +33,10 @@ public class AMapUtils { ...@@ -28,7 +33,10 @@ public class AMapUtils {
*/ */
public static double[] addressToGPS(String address) { public static double[] addressToGPS(String address) {
try { try {
String url = String .format("http://restapi.amap.com/v3/geocode/geo?&s=rsv3&address=%s&key=%s", address, KEY); System.out.println("adddddddddddddd"+address);
address = URLEncoder.encode(address,"UTF-8");
String url = String.format("http://restapi.amap.com/v3/geocode/geo?&s=rsv3&address=%s&key=%s", address, KEY);
URL myURL = null; URL myURL = null;
URLConnection httpsConn = null; URLConnection httpsConn = null;
try { try {
...@@ -42,16 +50,20 @@ public class AMapUtils { ...@@ -42,16 +50,20 @@ public class AMapUtils {
if (httpsConn != null) { if (httpsConn != null) {
insr = new InputStreamReader( httpsConn.getInputStream(), "UTF-8"); insr = new InputStreamReader( httpsConn.getInputStream(), "UTF-8");
br = new BufferedReader(insr); br = new BufferedReader(insr);
System.out.println("res--------------"+br);
String data = ""; String data = "";
String line = null; String line = null;
while((line= br.readLine())!=null){ while((line= br.readLine())!=null){
data+=line; data+=line;
} }
System.out.println("data----------"+data);
Matcher matcher = pattern.matcher(data); Matcher matcher = pattern.matcher(data);
if (matcher.find() && matcher.groupCount() == 2) { if (matcher.find() && matcher.groupCount() == 2) {
double[] gps = new double[2]; double[] gps = new double[2];
gps[0] = Double.valueOf(matcher.group(1)); gps[0] = Double.valueOf(matcher.group(1));
gps[1] = Double.valueOf(matcher.group(2)); gps[1] = Double.valueOf(matcher.group(2));
System.out.println("0000000000000"+gps[0]);
System.out.println("1111111111111"+gps[1]);
return gps; return gps;
} }
} }
...@@ -62,11 +74,14 @@ public class AMapUtils { ...@@ -62,11 +74,14 @@ public class AMapUtils {
return null; return null;
} }
/*public static void main(String[] args) {
public static void main(String[] args) {
String address = "广州市总统大酒店"; String address = "广州市总统大酒店";
double[] doubles = addressToGPS(address); double[]a = addressToGPS(address);
System.out.println(address+"、经度: "+doubles[0]); System.out.println(a[0]+a[1]);
System.out.println(address+"、纬度: "+doubles[1]); }
}*/
} }
\ No newline at end of file
package com.qianhe.system.utils;
import com.google.gson.ExclusionStrategy;
import com.google.gson.FieldAttributes;
import com.google.gson.FieldNamingPolicy;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.annotations.Expose;
/** Gson工具类 */
public class GsonUtil {
private GsonUtil() {}
private static final Gson gson;
static {
gson =
new GsonBuilder()
.disableHtmlEscaping()
.setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES)
.addSerializationExclusionStrategy(
new ExclusionStrategy() {
@Override
public boolean shouldSkipField(FieldAttributes fieldAttributes) {
final Expose expose = fieldAttributes.getAnnotation(Expose.class);
return expose != null && !expose.serialize();
}
@Override
public boolean shouldSkipClass(Class<?> aClass) {
return false;
}
})
.addDeserializationExclusionStrategy(
new ExclusionStrategy() {
@Override
public boolean shouldSkipField(FieldAttributes fieldAttributes) {
final Expose expose = fieldAttributes.getAnnotation(Expose.class);
return expose != null && !expose.deserialize();
}
@Override
public boolean shouldSkipClass(Class<?> aClass) {
return false;
}
})
.create();
}
/**
* 获取自定义设置的Gson对象
*
* @return Gson对象
*/
public static Gson getGson() {
return gson;
}
/**
* 转换对象为JSON格式字符串
*
* @param object 待转换对象
* @return JSON格式字符串
*/
public static String toJson(Object object) {
return gson.toJson(object);
}
}
package com.qianhe.system.utils;
import java.io.UnsupportedEncodingException;
import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
/**
* @author yc
* @version 1.0
* @className MD5
* @date 2024/3/28 17:44
* @description
*/
public class MD5 {
/**
* 对字符串进行32位MD5加密
* @param str
* @return
*/
public static String EncodeByMD5(String str) {
try {
// 将字符串转换为UTF-8编码的字节数组
byte[] inputBytes = str.getBytes("UTF-8");
// 创建一个 MessageDigest 实例,指定使用 MD5 算法
MessageDigest md = MessageDigest.getInstance("MD5");
// 计算 MD5 哈希值
byte[] hashBytes = md.digest(inputBytes);
// 将字节数组转换为十六进制字符串
StringBuilder hexString = new StringBuilder();
for (byte b : hashBytes) {
String hex = Integer.toHexString(0xff & b);
if (hex.length() == 1) {
hexString.append('0');
}
hexString.append(hex);
}
// 打印 MD5 哈希值
System.out.println("MD5 哈希值:" + hexString.toString());
return hexString.toString();
} catch (UnsupportedEncodingException | NoSuchAlgorithmException e) {
e.printStackTrace();
}
return null;
}
private static String fillMD5(String md5){
//如果不够32位则回调自身补零,最后返回32位长度的签名
return md5.length()==32?md5:fillMD5("0"+md5);
}
public static void main(String[] args) {
String input = "MERCHANTID=105000182492747&POSID=078751081&BRANCHID=370000000&ORDERID=1734395575583854593&PAYMENT=0.01&CURCODE=01&TXCODE=530590&REMARK1=1&REMARK2=&TYPE=1&PUB=0d6c325f2c31bc1561ba1317020111&GATEWAY=0&CLIENTIP=127.0.0.1&REGINFO=ou5vA6wS-mxPBQfVszdl922jNKGY&PROINFO=%u5730%u70b9&REFERER=&TRADE_TYPE=MINIPRO&SUB_APPID=wxb9998f75c8e7b657&SUB_OPENID=ou5vA6wS-mxPBQfVszdl922jNKGY"; // 要加密的字符串
try {
// 将字符串转换为UTF-8编码的字节数组
byte[] inputBytes = input.getBytes("UTF-8");
// 创建一个 MessageDigest 实例,指定使用 MD5 算法
MessageDigest md = MessageDigest.getInstance("MD5");
// 计算 MD5 哈希值
byte[] hashBytes = md.digest(inputBytes);
// 将字节数组转换为十六进制字符串
StringBuilder hexString = new StringBuilder();
for (byte b : hashBytes) {
String hex = Integer.toHexString(0xff & b);
if (hex.length() == 1) {
hexString.append('0');
}
hexString.append(hex);
}
// 打印 MD5 哈希值
System.out.println("MD5 哈希值:" + hexString.toString());
} catch (UnsupportedEncodingException | NoSuchAlgorithmException e) {
e.printStackTrace();
}
}
}
\ No newline at end of file
...@@ -9,9 +9,11 @@ import org.apache.http.HttpEntity; ...@@ -9,9 +9,11 @@ import org.apache.http.HttpEntity;
import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.util.EntityUtils; import org.apache.http.util.EntityUtils;
import javax.servlet.ServletInputStream;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.IOException; import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.time.DateTimeException; import java.time.DateTimeException;
import java.time.Duration; import java.time.Duration;
...@@ -188,4 +190,27 @@ public class WechatPayValidator { ...@@ -188,4 +190,27 @@ public class WechatPayValidator {
} }
} }
public static String getRequestBody(HttpServletRequest request) {
StringBuffer sb = new StringBuffer();
try (ServletInputStream inputStream = request.getInputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
) {
String line;
while ((line = reader.readLine()) != null) {
sb.append(line);
}
} catch (IOException e) {
log.error("读取数据流异常:{}", e);
}
return sb.toString();
}
} }
\ No newline at end of file
...@@ -7,6 +7,7 @@ import com.qianhe.common.annotation.Excel; ...@@ -7,6 +7,7 @@ import com.qianhe.common.annotation.Excel;
import com.qianhe.system.domain.WaterGoodsSpeVal; import com.qianhe.system.domain.WaterGoodsSpeVal;
import lombok.Data; import lombok.Data;
import java.math.BigDecimal;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
...@@ -36,4 +37,7 @@ public class WaterGoodsSpeVo { ...@@ -36,4 +37,7 @@ public class WaterGoodsSpeVo {
/** 商品关联规格值集合 */ /** 商品关联规格值集合 */
private List<WaterGoodsSpeVal> waterGoodsSpeValList; private List<WaterGoodsSpeVal> waterGoodsSpeValList;
/** 价格 */
private BigDecimal price;
} }
...@@ -7,6 +7,7 @@ import com.qianhe.common.annotation.Excel; ...@@ -7,6 +7,7 @@ import com.qianhe.common.annotation.Excel;
import com.qianhe.system.domain.WaterSpeVal; import com.qianhe.system.domain.WaterSpeVal;
import lombok.Data; import lombok.Data;
import java.math.BigDecimal;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
...@@ -29,4 +30,7 @@ public class WaterSpeVo ...@@ -29,4 +30,7 @@ public class WaterSpeVo
/** 商品规格子表集合 */ /** 商品规格子表集合 */
private List<WaterSpeVal> waterSpeValList; private List<WaterSpeVal> waterSpeValList;
/** 价格 */
private BigDecimal price;
} }
...@@ -9,7 +9,7 @@ spring: ...@@ -9,7 +9,7 @@ spring:
url: jdbc:mysql://1.116.38.25:3986/slsy?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&useOldAliasMetadataBehavior=true url: jdbc:mysql://1.116.38.25:3986/slsy?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&useOldAliasMetadataBehavior=true
username: root username: root
password: qianhe2022 password: qianhe2022
# url: jdbc:mysql://192.168.1.110:3306/slsy?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&useOldAliasMetadataBehavior=true # url: jdbc:mysql://192.168.0.105:3306/slsy?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&useOldAliasMetadataBehavior=true
# username: root # username: root
# password: 123456 # password: 123456
# 从库数据源 # 从库数据源
......
...@@ -71,13 +71,13 @@ spring: ...@@ -71,13 +71,13 @@ spring:
# redis 配置 # redis 配置
redis: redis:
# 地址 # 地址
host: 127.0.0.1 host: 1.116.38.25
# 端口,默认为6379 # 端口,默认为6379
port: 6379 port: 7789
# 数据库索引 # 数据库索引
database: 2 database: 2
# 密码 # 密码
password: password: qianheRedis2021
# 连接超时时间 # 连接超时时间
timeout: 10s timeout: 10s
lettuce: lettuce:
...@@ -153,9 +153,10 @@ wx: ...@@ -153,9 +153,10 @@ wx:
apiV3Key: 2562AB35D9BFE5CB875FA73954B6F5WW #微信支付v3密钥 apiV3Key: 2562AB35D9BFE5CB875FA73954B6F5WW #微信支付v3密钥
#apiKey: asdkjfhakjsdhf12321349898aksjhdj #微信支付v2密钥 #apiKey: asdkjfhakjsdhf12321349898aksjhdj #微信支付v2密钥
#支付通知回调 #支付通知回调
notifyUrl: https://www.dyzmxx.com/callback/payNotify/ notifyUrl: https://www.dyzmxx.com/ss/callback/payNotify/
backNotifyUrl: https://www.dyzmxx.com/ss/ccbback/payNotify/
#退款通知回调 #退款通知回调
refundNotifyUrl: https://www.dyzmxx.com/callback/refundNotify/ refundNotifyUrl: https://www.dyzmxx.com/ss/callback/refundNotify/
#证书地址 #证书地址
keyPemPath: apiclient_key.pem keyPemPath: apiclient_key.pem
......
...@@ -16,7 +16,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -16,7 +16,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap> </resultMap>
<sql id="selectWaterGoodsImgVo"> <sql id="selectWaterGoodsImgVo">
select id, img_name, type, sizea, url, md5, img_type, goods_id from water_goods_img select id, img_name, type, sizea, replace(url,'/prod-api','') url, md5, img_type, goods_id from water_goods_img
</sql> </sql>
<select id="selectWaterGoodsImgList" parameterType="WaterGoodsImg" resultMap="WaterGoodsImgResult"> <select id="selectWaterGoodsImgList" parameterType="WaterGoodsImg" resultMap="WaterGoodsImgResult">
......
...@@ -19,13 +19,32 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -19,13 +19,32 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap> </resultMap>
<sql id="selectWaterGoodsVo"> <sql id="selectWaterGoodsVo">
select id, title, goods_type_id, belong_station_id, cover_img, details_img, price, volume, create_user, create_time, status from water_goods select distinct a.id id, title, goods_type_id, belong_station_id, cover_img, details_img, c.price, volume, a.create_user, a.create_time, status
from
water_goods a
left join
water_goods_spe b
on
a.id = b.goods_id
left join
(select a.* from water_goods_spe_val a
left join (select spe_id,min(id) id from water_goods_spe_val where del_flag = '0' group by spe_id ) b
on a.spe_id = b.spe_id and a.id =b.id
where b.id is not null) c
on
b.water_spe_id = c.spe_id
</sql> </sql>
<select id="selectWaterGoodsList" parameterType="WaterGoods" resultMap="WaterGoodsResult"> <select id="selectWaterGoodsList" parameterType="WaterGoods" resultMap="WaterGoodsResult">
<include refid="selectWaterGoodsVo"/> <include refid="selectWaterGoodsVo"/>
<where> <where>
del_flag = '0' a.status = '1'
and
a.del_flag = '0'
and
b.del_flag ='0'
and
c.del_flag = '0'
<if test="title != null and title != ''"> and title like concat('%', #{title}, '%')</if> <if test="title != null and title != ''"> and title like concat('%', #{title}, '%')</if>
<if test="goodsTypeId != null "> and goods_type_id = #{goodsTypeId}</if> <if test="goodsTypeId != null "> and goods_type_id = #{goodsTypeId}</if>
<if test="belongStationId != null "> and belong_station_id like concat('%', #{belongStationId}, '%')</if> <if test="belongStationId != null "> and belong_station_id like concat('%', #{belongStationId}, '%')</if>
...@@ -41,14 +60,43 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -41,14 +60,43 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectWaterGoodsList1" resultMap="WaterGoodsResult"> <select id="selectWaterGoodsList1" resultMap="WaterGoodsResult">
-- select url cover_img from water_goods_img where img_type = 1 and goods_id = (select id from water_goods where title = '主页轮播图') -- select url cover_img from water_goods_img where img_type = 1 and goods_id = (select id from water_goods where title = '主页轮播图')
select url cover_img from water_goods_img where del_flag = '0' select replace(url,'/prod-api','') cover_img from water_goods_img where del_flag = '0'
and goods_id in (SELECT id from water_goods WHERE del_flag = '0' and goods_id in (SELECT id from water_goods WHERE del_flag = '0'
AND goods_type_id in (select id from water_goods_type where del_flag = '0' and type_name = '主页轮播图')) AND goods_type_id in (select id from water_goods_type where del_flag = '0' and type_name = '主页轮播图'))
</select> </select>
<select id="selectWaterGoodsById" parameterType="Long" resultMap="WaterGoodsResult"> <select id="selectWaterGoodsById" parameterType="Long" resultMap="WaterGoodsResult">
<include refid="selectWaterGoodsVo"/> <include refid="selectWaterGoodsVo"/>
where
a.status = '1'
and
a.del_flag = '0'
<!-- and
b.del_flag ='0'
and
c.del_flag = '0'-->
and
a.id = #{id}
</select>
<select id="selectWaterGoodsById1" parameterType="Long" resultMap="WaterGoodsResult">
select *
from water_goods
where id = #{id} where id = #{id}
and status = '1'
and del_flag = '0'
</select>
<select id="getPriceByID" parameterType="Long" resultMap="WaterGoodsResult">
select price from water_goods_spe_val where spe_id =
(select water_spe_id from water_goods_spe where goods_id = #{id} and del_flag = '0')
and del_flag = '0'
</select>
<select id="selectGoodsIdByCarId" parameterType="Long" resultMap="WaterGoodsResult">
select goods_id id from water_goods_cart where goods_id = #{id}
</select> </select>
<insert id="insertWaterGoods" parameterType="com.qianhe.system.vo.WaterGoodsVo" useGeneratedKeys="true" keyProperty="id"> <insert id="insertWaterGoods" parameterType="com.qianhe.system.vo.WaterGoodsVo" useGeneratedKeys="true" keyProperty="id">
...@@ -163,7 +211,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -163,7 +211,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectGoodsSp" resultMap="WaterGoodsResult"> <select id="selectGoodsSp" resultMap="WaterGoodsResult">
<include refid="selectWaterGoodsVo"/> <include refid="selectWaterGoodsVo"/>
WHERE del_flag = '0' AND goods_type_id WHERE
a.status = '1'
and
a.del_flag = '0'
<!-- and
b.del_flag ='0'
and
c.del_flag = '0'-->
AND goods_type_id
IN (SELECT id FROM water_goods_type WHERE del_flag = '0' AND type_name like concat('%', '水票', '%')) order by create_time DESC LIMIT 1 IN (SELECT id FROM water_goods_type WHERE del_flag = '0' AND type_name like concat('%', '水票', '%')) order by create_time DESC LIMIT 1
</select> </select>
</mapper> </mapper>
...@@ -11,10 +11,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -11,10 +11,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="goodsId" column="goods_id" /> <result property="goodsId" column="goods_id" />
<result property="createUser" column="create_user" /> <result property="createUser" column="create_user" />
<result property="createTime" column="create_time" /> <result property="createTime" column="create_time" />
<result property="price" column="price" />
</resultMap> </resultMap>
<sql id="selectWaterGoodsSpeVo"> <sql id="selectWaterGoodsSpeVo">
select id, water_spe_id, spe_title, goods_id, create_user, create_time from water_goods_spe select id, water_spe_id, spe_title, goods_id, create_user, create_time,price from water_goods_spe
</sql> </sql>
<select id="selectWaterGoodsSpeList" parameterType="WaterGoodsSpe" resultMap="WaterGoodsSpeResult"> <select id="selectWaterGoodsSpeList" parameterType="WaterGoodsSpe" resultMap="WaterGoodsSpeResult">
...@@ -59,6 +60,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -59,6 +60,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="goodsId != null">#{goodsId},</if> <if test="goodsId != null">#{goodsId},</if>
<if test="createUser != null">#{createUser},</if> <if test="createUser != null">#{createUser},</if>
<if test="createTime != null">#{createTime},</if> <if test="createTime != null">#{createTime},</if>
<if test="price != null">#{price},</if>
</trim> </trim>
</insert> </insert>
...@@ -70,6 +72,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -70,6 +72,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="goodsId != null">goods_id = #{goodsId},</if> <if test="goodsId != null">goods_id = #{goodsId},</if>
<if test="createUser != null">create_user = #{createUser},</if> <if test="createUser != null">create_user = #{createUser},</if>
<if test="createTime != null">create_time = #{createTime},</if> <if test="createTime != null">create_time = #{createTime},</if>
<if test="price != null">price = #{price},</if>
</trim> </trim>
where id = #{id} where id = #{id}
</update> </update>
......
...@@ -264,6 +264,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -264,6 +264,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where id = #{id} where id = #{id}
</update> </update>
<update id="updateByOrderNum" parameterType="com.qianhe.system.vo.WaterOrderVo">
update water_order set pay_state = '1' ,order_state = '2' where order_num = #{orderNum}
</update>
<update id="deleteWaterOrderById" parameterType="Long"> <update id="deleteWaterOrderById" parameterType="Long">
update water_order set del_flag = '1' where id = #{id} update water_order set del_flag = '1' where id = #{id}
</update> </update>
......
...@@ -9,10 +9,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -9,10 +9,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="speTitle" column="spe_title" /> <result property="speTitle" column="spe_title" />
<result property="createUser" column="create_user" /> <result property="createUser" column="create_user" />
<result property="createTime" column="create_time" /> <result property="createTime" column="create_time" />
<result property="price" column="price" />
</resultMap> </resultMap>
<sql id="selectWaterSpeVo"> <sql id="selectWaterSpeVo">
select id, spe_title, create_user, create_time from water_spe select id, spe_title, create_user, create_time,price from water_spe
</sql> </sql>
<select id="selectWaterSpeList" parameterType="WaterSpe" resultMap="WaterSpeResult"> <select id="selectWaterSpeList" parameterType="WaterSpe" resultMap="WaterSpeResult">
...@@ -25,16 +26,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -25,16 +26,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select> </select>
<select id="selectWaterSpeValList" parameterType="WaterSpeVal" resultType="WaterSpeVal"> <select id="selectWaterSpeValList" parameterType="WaterSpeVal" resultType="WaterSpeVal">
select id, spe_id, spe, spe_val from water_spe_val select a.id, a.spe_id, a.spe, a.spe_val,b.price from water_spe_val a
left join
water_goods_spe_val b
on a.spe_id = b.spe_id
<where> <where>
del_flag = '0' a.del_flag = '0'
<if test="speId != null "> and spe_id = #{speId}</if> and
b.del_flag = '0'
and
a.id = b.spe_val_id
<if test="speId != null "> and a.spe_id = #{speId}</if>
</where> </where>
</select> </select>
<select id="selectWaterSpeById" parameterType="Long" resultMap="WaterSpeResult"> <select id="selectWaterSpeById" parameterType="Long" resultMap="WaterSpeResult">
<include refid="selectWaterSpeVo"/> <include refid="selectWaterSpeVo"/>
where id = #{id} where
del_flag = '0'
and
id = #{id}
</select> </select>
<insert id="insertWaterSpe" parameterType="com.qianhe.system.vo.WaterSpeVo" useGeneratedKeys="true" keyProperty="id"> <insert id="insertWaterSpe" parameterType="com.qianhe.system.vo.WaterSpeVo" useGeneratedKeys="true" keyProperty="id">
...@@ -43,11 +54,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -43,11 +54,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="speTitle != null">spe_title,</if> <if test="speTitle != null">spe_title,</if>
<if test="createUser != null and createUser != ''">create_user,</if> <if test="createUser != null and createUser != ''">create_user,</if>
<if test="createTime != null">create_time,</if> <if test="createTime != null">create_time,</if>
<if test="price != null">price,</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="speTitle != null">#{speTitle},</if> <if test="speTitle != null">#{speTitle},</if>
<if test="createUser != null and createUser != ''">#{createUser},</if> <if test="createUser != null and createUser != ''">#{createUser},</if>
<if test="createTime != null">#{createTime},</if> <if test="createTime != null">#{createTime},</if>
<if test="price != null">#{price},</if>
</trim> </trim>
</insert> </insert>
...@@ -57,6 +70,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -57,6 +70,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="speTitle != null">spe_title = #{speTitle},</if> <if test="speTitle != null">spe_title = #{speTitle},</if>
<if test="createUser != null and createUser != ''">create_user = #{createUser},</if> <if test="createUser != null and createUser != ''">create_user = #{createUser},</if>
<if test="createTime != null">create_time = #{createTime},</if> <if test="createTime != null">create_time = #{createTime},</if>
<if test="price != null">price = #{price},</if>
</trim> </trim>
where id = #{id} where id = #{id}
</update> </update>
...@@ -74,6 +88,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -74,6 +88,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<update id="deleteWaterSpeValBySpeId" parameterType="Long"> <update id="deleteWaterSpeValBySpeId" parameterType="Long">
update water_spe_val set del_flag = '1' where spe_id = #{id} update water_spe_val set del_flag = '1' where spe_id = #{id}
</update>
<update id="deleteWaterGoodsSpeValBySpeId" parameterType="Long">
update water_goods_spe_val set del_flag = '1' where spe_id = #{id}
</update> </update>
<update id="deleteWaterSpeValBySpeIds" parameterType="String"> <update id="deleteWaterSpeValBySpeIds" parameterType="String">
...@@ -84,10 +103,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -84,10 +103,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</update> </update>
<insert id="batchInsertWaterSpeVal"> <insert id="batchInsertWaterSpeVal">
insert into water_spe_val(spe_id, spe, spe_val) insert into water_spe_val(id,spe_id, spe, spe_val)
values
<foreach collection="list" item="item" separator=",">
(#{item.id},#{item.speId}, #{item.spe}, #{item.speVal})
</foreach>
</insert>
<insert id="batchInsertWaterGoodsSpeVal">
insert into water_goods_spe_val(spe_id, spe, spe_val,price,spe_val_id)
values values
<foreach collection="list" item="item" separator=","> <foreach collection="list" item="item" separator=",">
(#{item.speId}, #{item.spe}, #{item.speVal}) (#{item.speId}, #{item.spe}, #{item.speVal},#{item.price},#{item.speValId})
</foreach> </foreach>
</insert> </insert>
</mapper> </mapper>
...@@ -37,7 +37,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -37,7 +37,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
order by su.create_time DESC order by su.create_time DESC
</select> </select>
<select id="selectWaterStationUserById" parameterType="Long" resultMap="WaterStationUserResult"> <select id="selectWaterStationUserById" parameterType="Long" resultType="com.qianhe.system.domain.WaterStationUser">
select su.id, su.name, su.age, su.gender, su.phone, su.id_num, su.station_id, s.station_name, su.create_time, su.create_user select su.id, su.name, su.age, su.gender, su.phone, su.id_num, su.station_id, s.station_name, su.create_time, su.create_user
from water_station_user su LEFT JOIN water_station s ON s.id = su.station_id from water_station_user su LEFT JOIN water_station s ON s.id = su.station_id
where su.id = #{id} where su.id = #{id}
...@@ -46,6 +46,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -46,6 +46,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectWaterStationUserByPhone" parameterType="Long" resultMap="WaterStationUserResult"> <select id="selectWaterStationUserByPhone" parameterType="Long" resultMap="WaterStationUserResult">
<include refid="selectWaterStationUserVo"/> <include refid="selectWaterStationUserVo"/>
where phone = #{phone} where phone = #{phone}
and del_flag = '0'
</select> </select>
<insert id="insertWaterStationUser" parameterType="WaterStationUser" useGeneratedKeys="true" keyProperty="id"> <insert id="insertWaterStationUser" parameterType="WaterStationUser" useGeneratedKeys="true" keyProperty="id">
......
<?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.qianhe.system.mapper.WaterStockMapper">
<select id="list" parameterType="com.qianhe.system.domain.WaterStock" resultType="com.qianhe.system.domain.WaterStock">
select * from water_stock
<where>
del_flag != 1
<if test="stationName != null and stationName != ''"> and station_name like concat('%', #{stationName}, '%')</if>
<if test="goodsName != null and goodsName != ''"> and goods_name like concat('%', #{goodsName}, '%')</if>
<if test="speName != null and speName != ''"> and spe_name like concat('%', #{speName}, '%')</if>
<if test="id != null and id != ''"> and id =#{id}</if>
</where>
</select>
<insert id="insertStock" parameterType="com.qianhe.system.domain.WaterStock" useGeneratedKeys="true" keyProperty="id">
insert into water_stock
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="stationName != null">station_name,</if>
<if test="stationId != null">station_id,</if>
<if test="goodsName != null">goods_name,</if>
<if test="goodsId != null">goods_id,</if>
<if test="speName != null">spe_name,</if>
<if test="speId != null">spe_id,</if>
<if test="nowStock != null">now_stock</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="stationName != null">#{stationName},</if>
<if test="stationId != null">#{stationId},</if>
<if test="goodsName != null">#{goodsName},</if>
<if test="goodsId != null">#{goodsId},</if>
<if test="speName != null">#{speName},</if>
<if test="speId != null">#{speId},</if>
<if test="nowStock != null">#{nowStock}</if>
</trim>
</insert>
<update id="updateStock" parameterType="com.qianhe.system.domain.WaterStock">
update water_stock
<trim prefix="SET" suffixOverrides=",">
<if test="stationName != null">station_name=#{stationName},</if>
<if test="stationId != null">station_id=#{stationId},</if>
<if test="goodsName != null">goods_name=#{goodsName},</if>
<if test="goodsId != null">goods_id=#{goodsId},</if>
<if test="speName != null">spe_name=#{speName},</if>
<if test="speId != null">spe_id=#{speId},</if>
<if test="nowStock != null">now_stock=#{nowStock}</if>
</trim>
where id = #{id}
</update>
<update id="deleteStock" parameterType="com.qianhe.system.domain.WaterStock">
update water_stock set del_flag = '1' where id = #{id}
</update>
<select id="goodsList" resultType="com.qianhe.system.domain.WaterStock" >
select distinct id goods_id,title goods_name from water_goods where del_flag = '0' and status = '1'
</select>
<select id="speList" parameterType="com.qianhe.system.domain.WaterStock" resultType="com.qianhe.system.domain.WaterStock" >
select distinct a.id spe_id,a.spe_title spe_name from water_spe a
left join
water_goods_spe b
on
a.id = b.water_spe_id
where
b.goods_id = #{id}
</select>
<select id="stationList" resultType="com.qianhe.system.domain.WaterStock" >
select distinct id station_id,station_name from water_station where del_flag = '0'
</select>
</mapper>
...@@ -117,6 +117,8 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter ...@@ -117,6 +117,8 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
.antMatchers("/wx/**").permitAll() .antMatchers("/wx/**").permitAll()
//放行送水小程序登录相关接口 //放行送水小程序登录相关接口
.antMatchers("/ssWx/getWxLoginInfo/**", "/ssWx/login/**", "/ssWx/getPhoneNumber/**","/ssWx/updateUser").permitAll() .antMatchers("/ssWx/getWxLoginInfo/**", "/ssWx/login/**", "/ssWx/getPhoneNumber/**","/ssWx/updateUser").permitAll()
//微信回调
.antMatchers("/callback/payNotify/").permitAll()
//通用接口放行 //通用接口放行
.antMatchers("/common/**").permitAll() .antMatchers("/common/**").permitAll()
//测试放行所有接口 //测试放行所有接口
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment