Commit 3061ca3d by yuanchao

20240329

parent 6b76675f
......@@ -114,8 +114,11 @@
<version>6.6.14</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.6</version> <!-- 使用最新的稳定版本 -->
</dependency>
<!-- 微信支付 SDK -->
<dependency>
<groupId>com.github.wxpay</groupId>
......@@ -129,11 +132,25 @@
</dependency>-->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.6</version>
</dependency>
<dependency>
<groupId>com.github.wechatpay-apiv3</groupId>
<artifactId>wechatpay-apache-httpclient</artifactId>
<version>0.4.7</version>
</dependency>
<!-- <dependency>
<groupId>com.github.wechatpay-apiv3</groupId>
<artifactId>wechatpay-java</artifactId>
<version>0.2.12</version>
</dependency>-->
<dependency>
<groupId>com.baomidou</groupId>
<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
......@@ -16,12 +16,12 @@ import com.qianhe.system.domain.WaterOrder;
import com.qianhe.system.mapper.WaterOrderMapper;
import com.qianhe.system.service.IWaterOrderService;
import com.qianhe.system.utils.WechatPayRequest;
import com.wechat.pay.contrib.apache.httpclient.util.PemUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import sun.misc.BASE64Decoder;
import javax.annotation.Resource;
import java.io.IOException;
......@@ -29,8 +29,10 @@ import java.math.BigDecimal;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.security.KeyFactory;
import java.security.PrivateKey;
import java.security.Signature;
import java.security.spec.PKCS8EncodedKeySpec;
import java.text.SimpleDateFormat;
import java.util.Base64;
import java.util.HashMap;
......@@ -63,11 +65,39 @@ public class PayController {
@Autowired
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")
public AjaxResult transactions(WaterGoods goods) throws IOException {
public AjaxResult transactions(WaterGoods goods) throws Exception {
// 统一参数封装
Map<String, Object> params = new HashMap<>(10);
......@@ -78,11 +108,14 @@ public class PayController {
// 3.description body:商品描述。
params.put("description", goods.getTitle());
// 4.out_trade_no:商户订单号,由商户自定义。
params.put("out_trade_no", getOrerNum());
params.put("out_trade_no", goods.getOrderNo());
// 5.notify_url:接收微信支付异步通知回调地址。
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);
// 金额单位为分
amountMap.put("total", (int)Math.floor(Double.parseDouble(goods.getTotalPrice())*100));
amountMap.put("currency", "CNY");
......@@ -128,6 +161,7 @@ public class PayController {
// 签名方式
map.put("signType", "RSA");
// 获取签名
String sign = getPaySign(timeStamp,nonceStr,"prepay_id="+prepayId);
......@@ -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;
log.info("微信支付签名原文:{}", sourceText);
byte[] sign = SecureUtil.sign(SignAlgorithm.SHA256withRSA)
/*byte[] sign = SecureUtil.sign(SignAlgorithm.SHA256withRSA)
.setPrivateKey(wechatPayConfig.getPrivateKey(wechatPayConfig.getKeyPemPath()))
.sign(sourceText);*/
PrivateKey key = getPrivateKey(pk);
byte[] sign = SecureUtil.sign(SignAlgorithm.SHA256withRSA)
.setPrivateKey(key)
.sign(sourceText);
String paySign = Base64Encoder.encode(sign);
log.info("微信支付签名密文:{}", paySign);
return paySign;
}
/**
* 生成订单编号
* @return
*/
public String getOrerNum(){
String orderNum = "";
//获取当前年月日
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;
public static PrivateKey getPrivateKey(String key) throws Exception {
byte[] keyBytes;
keyBytes = (new BASE64Decoder()).decodeBuffer(key);
PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(keyBytes);
KeyFactory keyFactory = KeyFactory.getInstance("RSA");
PrivateKey privateKey = keyFactory.generatePrivate(keySpec);
return privateKey;
}
/**
* 获取一定长度的随机字符串
*
......
......@@ -210,11 +210,8 @@ public class WaterOrderController extends BaseController
@RepeatSubmit(message = "订单已提交,请勿重复操作!")
public AjaxResult add(@RequestBody WaterOrderVo waterOrderVo)
{
int i = waterOrderService.insertWaterOrder(waterOrderVo);
if (i == -1){
return AjaxResult.error("该地址超出配送范围,请重新选择地址!");
}
return toAjax(i);
String ddh = waterOrderService.insertWaterOrder(waterOrderVo);
return success(ddh);
}
/**
......
......@@ -162,6 +162,8 @@ public class WaterStationController extends BaseController
*/
@GetMapping("/getRecentlyStation1")
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);
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 {
* @return
*/
@GetMapping("/login")
public AjaxResult login(@RequestParam("code") String code){
public AjaxResult login(@RequestParam("code") String code,@RequestParam("phoneNum") String phoneNum){
AjaxResult ajaxResult = AjaxResult.success();
//根据code查询微信用户的openid和session_key
Map<String, String> wxLoginInfo = wxUserInfoUtils.getWxLoginInfo(code);
WxLoginBody wxLoginBody = new WxLoginBody();
wxLoginBody.setOpenId(wxLoginInfo.get("openid"));
wxLoginBody.setPhone(phoneNum);
MpLoginUser login = wxLoginService.ssLogin(wxLoginBody);
if (StringUtils.isNull(login)) {
return AjaxResult.error("login error");
......@@ -105,10 +106,10 @@ public class SsWxLogin {
return success(waterUserService.updateUserByOpenId(waterUser));
}
/**
/* *//**
* 获取用户信息
* @return
*/
*//*
@GetMapping("/getUserInfo")
public AjaxResult getUserInfo(){
//获取当前登录用户openid
......@@ -129,6 +130,33 @@ public class SsWxLogin {
}
map.put("waterStationUser",waterStationUser);
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 {
*/
@GetMapping("/login")
public AjaxResult login(@RequestParam("code") String code){
public AjaxResult login(@RequestParam("code") String code,@RequestParam("phoneNum") String phoneNum){
AjaxResult ajaxResult = AjaxResult.success();
//根据code查询微信用户的openid和session_key
Map<String, String> wxLoginInfo = wxUserInfoUtils.getWxLoginInfo(code);
WxLoginBody wxLoginBody = new WxLoginBody();
wxLoginBody.setOpenId(wxLoginInfo.get("openid"));
wxLoginBody.setPhone(phoneNum);
MpLoginUser login = wxLoginService.login(wxLoginBody);
if (StringUtils.isNull(login)) {
return AjaxResult.error("login error");
......@@ -103,9 +104,9 @@ public class WxLogin {
* @return
*/
@GetMapping("/getUserInfo")
public AjaxResult 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,"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
private String openId;
private String totalPrice;
private String orderNo;
}
......@@ -9,6 +9,7 @@ import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import java.math.BigDecimal;
import java.util.Date;
/**
......@@ -42,4 +43,7 @@ public class WaterGoodsSpe
/** 创建时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTime;
/** 价格 */
private BigDecimal price;
}
......@@ -5,6 +5,8 @@ import com.baomidou.mybatisplus.annotation.TableId;
import com.qianhe.common.annotation.Excel;
import lombok.Data;
import java.math.BigDecimal;
/**
* 商品规格子表对象 water_spe_val
*
......@@ -16,7 +18,7 @@ public class WaterSpeVal
{
@TableId(value = "id", type = IdType.AUTO)
private Long id;
private String id;
/** 商品规格id */
private Long speId;
......@@ -27,4 +29,8 @@ public class WaterSpeVal
/** 规格值 */
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
*/
public WaterGoods selectWaterGoodsById(Long id);
WaterGoods selectWaterGoodsById1(Long id);
WaterGoods selectGoodsIdByCarId(Long id);
WaterGoods getPriceByID(Long id);
/**
* 查询商品列表
*
......
......@@ -56,6 +56,8 @@ public interface WaterOrderMapper
*/
public int updateWaterOrder(WaterOrderVo waterOrderVo);
int updateByOrderNum(WaterOrderVo waterOrderVo);
/**
* 删除订单
*
......
......@@ -78,6 +78,9 @@ public interface WaterSpeMapper
*/
public int deleteWaterSpeValBySpeId(Long id);
int deleteWaterGoodsSpeValBySpeId(Long id);
/**
* 批量删除商品规格规格值
*
......@@ -91,4 +94,6 @@ public interface WaterSpeMapper
* @param 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
* @param waterOrderVo 订单
* @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 {
return waterGoodsCartMapper.updateWaterGoodsCart(waterGoodsCart2);
}
//根据商品id查询商品信息
WaterGoods waterGoods = waterGoodsMapper.selectWaterGoodsById(waterGoodsCart.getGoodsId());
WaterGoods waterGoods = waterGoodsMapper.selectWaterGoodsById1(waterGoodsCart.getGoodsId());
//根据规格值id查询规格值
WaterGoodsSpeVal waterGoodsSpeVal = waterGoodsSpeMapper.selectWaterGoodsSpeValById(waterGoodsCart.getGoodsSpeValId());
waterGoodsCart.setGoodsName(waterGoods.getTitle());
......
......@@ -53,7 +53,9 @@ public class WaterGoodsServiceImpl implements IWaterGoodsService
@Override
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
WaterGoodsVo waterGoodsVo = new WaterGoodsVo();
BeanUtils.copyProperties(waterGoods,waterGoodsVo);
......@@ -471,7 +473,7 @@ public class WaterGoodsServiceImpl implements IWaterGoodsService
@Override
public WaterGoodsVo getGoodsXq(WaterGoodsVo waterGoodsVo) {
//根据商品id查询商品详细信息
WaterGoods waterGoods = waterGoodsMapper.selectWaterGoodsById(waterGoodsVo.getId());
WaterGoods waterGoods = waterGoodsMapper.selectWaterGoodsById1(waterGoodsVo.getId());
//转vo
WaterGoodsVo waterGoodsVo1 = new WaterGoodsVo();
BeanUtils.copyProperties(waterGoods,waterGoodsVo1);
......
......@@ -112,29 +112,32 @@ public class WaterOrderServiceImpl implements IWaterOrderService
*/
@Override
@Transactional
public int insertWaterOrder(WaterOrderVo waterOrderVo)
public String insertWaterOrder(WaterOrderVo waterOrderVo)
{
//判断用户下单是否有地址
if (StringUtils.isNull(waterOrderVo.getUserAddressId())){
/*if (StringUtils.isNull(waterOrderVo.getUserAddressId())){
throw new ServiceException("未选择地址!");
}
}*/
//判断用户地址是否在配送范围之内
List<WaterStationVo> stations = getStation(waterOrderVo);
//前端已做下单控制,此处不用再做处理
/*List<WaterStationVo> stations = getStation(waterOrderVo);
if (stations.size() <= 0){
return -1;
}
WaterStationVo station = stations.get(0);
}*/
/* WaterStationVo station = stations.get(0);
waterOrderVo.setStationId(station.getId());
waterOrderVo.setStationName(station.getStationName());
waterOrderVo.setStationPhone(station.getPhoneNum());
waterOrderVo.setStationProvince(station.getProvince());
waterOrderVo.setStationCity(station.getCity());
waterOrderVo.setStationArea(station.getArea());
waterOrderVo.setStationAddress(station.getStationAddress());
waterOrderVo.setStationAddress(station.getStationAddress());*/
waterOrderVo.setCreateUser(waterOrderVo.getUserId().toString());
waterOrderVo.setCreateTime(DateUtils.getNowDate());
waterOrderVo.setOrderNum(getOrerNum());
String ddh = getOrerNum();
waterOrderVo.setOrderNum(ddh);
//判断支付方式是否为水票支付
if(waterOrderVo.getPayType() == 2){
//水票支付,修改订单状态为待接单
......@@ -150,7 +153,7 @@ public class WaterOrderServiceImpl implements IWaterOrderService
int i = waterOrderMapper.insertWaterOrder(waterOrderVo);
//新增订单商品
insertWaterOrderGoods(waterOrderVo);
return i;
return ddh;
}
/**
......@@ -226,7 +229,7 @@ public class WaterOrderServiceImpl implements IWaterOrderService
//根据商品信息查询购物车商品信息
WaterGoodsCart waterGoodsCart = new WaterGoodsCart();
waterGoodsCart.setUserId(waterOrderVo.getUserId());
waterGoodsCart.setGoodsId(waterOrderGoods.getGoodsId());
waterGoodsCart.setId(waterOrderGoods.getGoodsId());
waterGoodsCart.setGoodsSpeVal(waterOrderGoods.getGoodsSpe());
List<WaterGoodsCart> list = waterGoodsCartMapper.selectWaterGoodsCartList(waterGoodsCart);
WaterGoodsCart waterGoodsCart1 = list.get(0);
......@@ -234,7 +237,7 @@ public class WaterOrderServiceImpl implements IWaterOrderService
waterGoodsCartMapper.deleteWaterGoodsCartById(waterGoodsCart1.getId());
}
//根据商品id查询商品信息
WaterGoods waterGoods = waterGoodsMapper.selectWaterGoodsById(waterOrderGoods.getGoodsId());
WaterGoods waterGoods = waterGoodsMapper.selectWaterGoodsById1(waterOrderGoods.getGoodsId());
//判断商品是否下架
if (waterGoods.getStatus() == 0) {
throw new ServiceException("该商品已下架,请您重新选择商品!");
......
......@@ -14,6 +14,7 @@ import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
/**
* 商品规格Service业务层处理
......@@ -87,6 +88,9 @@ public class WaterSpeServiceImpl implements IWaterSpeService
Long id = waterSpeVo.getId();
if (StringUtils.isNotNull(waterSpeValList)){
for (WaterSpeVal waterSpeVal : waterSpeValList) {
String idd = UUID.randomUUID().toString();
waterSpeVal.setId(idd);
waterSpeVal.setSpeValId(idd);
waterSpeVal.setSpeId(id);
waterSpeVals.add(waterSpeVal);
}
......@@ -94,6 +98,7 @@ public class WaterSpeServiceImpl implements IWaterSpeService
if (waterSpeVals.size() > 0){
//批量新增
waterSpeMapper.batchInsertWaterSpeVal(waterSpeVals);
waterSpeMapper.batchInsertWaterGoodsSpeVal(waterSpeVals);
}
}
......@@ -108,6 +113,7 @@ public class WaterSpeServiceImpl implements IWaterSpeService
{
//删除商品规格关联的规格规格值
waterSpeMapper.deleteWaterSpeValBySpeId(waterSpeVo.getId());
waterSpeMapper.deleteWaterGoodsSpeValBySpeId(waterSpeVo.getId());
//新增规格规格值
insertWaterSpeVal(waterSpeVo);
return waterSpeMapper.updateWaterSpe(waterSpeVo);
......
......@@ -256,13 +256,16 @@ public class WaterStationServiceImpl implements IWaterStationService
double[] doubles;
if(address1.contains(address)){
doubles = AMapUtils.addressToGPS(address);
doubles = AMapUtils.addressToGPS(address1);
}else {
doubles = AMapUtils.addressToGPS(address+address1);
}
double lon = doubles[0];
double lat = doubles[1];
System.out.println(lon+"-------------"+lat);
//查询所有站点信息
List<WaterStation> waterStations = waterStationMapper.selectWaterStationList(new WaterStation());
List<WaterStationVo> waterStationVoList = new ArrayList<>();
......@@ -270,6 +273,7 @@ public class WaterStationServiceImpl implements IWaterStationService
for (WaterStation waterStation : waterStations) {
//计算距离
double distance = PositionUtil.getDistance1(lon, lat, waterStation.getStationLonTen(), waterStation.getStationLatTen());
System.out.println("dis---------------"+distance);
if(distance<5000){
WaterStationVo waterStationVo = new 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 {
waterUser.setUserType("1");
waterUser.setOpenId(wxLoginBody.getOpenId());
waterUser.setCreateTime(DateUtils.getNowDate());
waterUser.setPhoneNum(Long.valueOf(wxLoginBody.getPhone()));
waterUserMapper.insertWaterUser(waterUser);
MpLoginUser loginUser = new MpLoginUser();
......@@ -56,6 +57,7 @@ public class WxLoginServiceImpl implements IWxLoginService {
loginUser.setUserId(user.getId());
loginUser.setNickName(user.getNickName());
loginUser.setIsNewUser("0");
loginUser.setPhone(Long.valueOf(wxLoginBody.getPhone()));
return loginUser;
}
//不存在,新增用户
......@@ -64,6 +66,7 @@ public class WxLoginServiceImpl implements IWxLoginService {
waterUser.setUserType("2");
waterUser.setOpenId(wxLoginBody.getOpenId());
waterUser.setCreateTime(DateUtils.getNowDate());
waterUser.setPhoneNum(Long.valueOf(wxLoginBody.getPhone()));
waterUserMapper.insertWaterUser(waterUser);
MpLoginUser loginUser = new MpLoginUser();
......
package com.qianhe.system.utils;
import com.alibaba.fastjson.JSONObject;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
import java.util.Base64;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
......@@ -20,6 +24,7 @@ public class AMapUtils {
public static final String KEY = "6dc239658cd94e2007b4f3c933106693";
private static Pattern pattern = Pattern.compile("\"location\":\"(\\d+\\.\\d+),(\\d+\\.\\d+)\"");
/**
* 通过具体位置,获取对应地图上的坐标: 经度、纬度
*
......@@ -28,7 +33,10 @@ public class AMapUtils {
*/
public static double[] addressToGPS(String address) {
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;
URLConnection httpsConn = null;
try {
......@@ -42,16 +50,20 @@ public class AMapUtils {
if (httpsConn != null) {
insr = new InputStreamReader( httpsConn.getInputStream(), "UTF-8");
br = new BufferedReader(insr);
System.out.println("res--------------"+br);
String data = "";
String line = null;
while((line= br.readLine())!=null){
data+=line;
}
System.out.println("data----------"+data);
Matcher matcher = pattern.matcher(data);
if (matcher.find() && matcher.groupCount() == 2) {
double[] gps = new double[2];
gps[0] = Double.valueOf(matcher.group(1));
gps[1] = Double.valueOf(matcher.group(2));
System.out.println("0000000000000"+gps[0]);
System.out.println("1111111111111"+gps[1]);
return gps;
}
}
......@@ -62,11 +74,14 @@ public class AMapUtils {
return null;
}
/*public static void main(String[] args) {
public static void main(String[] args) {
String address = "广州市总统大酒店";
double[] doubles = addressToGPS(address);
System.out.println(address+"、经度: "+doubles[0]);
System.out.println(address+"、纬度: "+doubles[1]);
}*/
double[]a = addressToGPS(address);
System.out.println(a[0]+a[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;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.util.EntityUtils;
import javax.servlet.ServletInputStream;
import javax.servlet.http.HttpServletRequest;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.time.DateTimeException;
import java.time.Duration;
......@@ -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;
import com.qianhe.system.domain.WaterGoodsSpeVal;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
......@@ -36,4 +37,7 @@ public class WaterGoodsSpeVo {
/** 商品关联规格值集合 */
private List<WaterGoodsSpeVal> waterGoodsSpeValList;
/** 价格 */
private BigDecimal price;
}
......@@ -7,6 +7,7 @@ import com.qianhe.common.annotation.Excel;
import com.qianhe.system.domain.WaterSpeVal;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
......@@ -29,4 +30,7 @@ public class WaterSpeVo
/** 商品规格子表集合 */
private List<WaterSpeVal> waterSpeValList;
/** 价格 */
private BigDecimal price;
}
......@@ -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
username: root
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
# password: 123456
# 从库数据源
......
......@@ -71,13 +71,13 @@ spring:
# redis 配置
redis:
# 地址
host: 127.0.0.1
host: 1.116.38.25
# 端口,默认为6379
port: 6379
port: 7789
# 数据库索引
database: 2
# 密码
password:
password: qianheRedis2021
# 连接超时时间
timeout: 10s
lettuce:
......@@ -153,9 +153,10 @@ wx:
apiV3Key: 2562AB35D9BFE5CB875FA73954B6F5WW #微信支付v3密钥
#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
......
......@@ -16,7 +16,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<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>
<select id="selectWaterGoodsImgList" parameterType="WaterGoodsImg" resultMap="WaterGoodsImgResult">
......
......@@ -19,13 +19,32 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<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>
<select id="selectWaterGoodsList" parameterType="WaterGoods" resultMap="WaterGoodsResult">
<include refid="selectWaterGoodsVo"/>
<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="goodsTypeId != null "> and goods_type_id = #{goodsTypeId}</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"
<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 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_type_id in (select id from water_goods_type where del_flag = '0' and type_name = '主页轮播图'))
</select>
<select id="selectWaterGoodsById" parameterType="Long" resultMap="WaterGoodsResult">
<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}
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>
<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"
<select id="selectGoodsSp" resultMap="WaterGoodsResult">
<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
</select>
</mapper>
......@@ -11,10 +11,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="goodsId" column="goods_id" />
<result property="createUser" column="create_user" />
<result property="createTime" column="create_time" />
<result property="price" column="price" />
</resultMap>
<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>
<select id="selectWaterGoodsSpeList" parameterType="WaterGoodsSpe" resultMap="WaterGoodsSpeResult">
......@@ -59,6 +60,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="goodsId != null">#{goodsId},</if>
<if test="createUser != null">#{createUser},</if>
<if test="createTime != null">#{createTime},</if>
<if test="price != null">#{price},</if>
</trim>
</insert>
......@@ -70,6 +72,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="goodsId != null">goods_id = #{goodsId},</if>
<if test="createUser != null">create_user = #{createUser},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="price != null">price = #{price},</if>
</trim>
where id = #{id}
</update>
......
......@@ -264,6 +264,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where id = #{id}
</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 water_order set del_flag = '1' where id = #{id}
</update>
......
......@@ -9,10 +9,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="speTitle" column="spe_title" />
<result property="createUser" column="create_user" />
<result property="createTime" column="create_time" />
<result property="price" column="price" />
</resultMap>
<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>
<select id="selectWaterSpeList" parameterType="WaterSpe" resultMap="WaterSpeResult">
......@@ -25,16 +26,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<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>
del_flag = '0'
<if test="speId != null "> and spe_id = #{speId}</if>
a.del_flag = '0'
and
b.del_flag = '0'
and
a.id = b.spe_val_id
<if test="speId != null "> and a.spe_id = #{speId}</if>
</where>
</select>
<select id="selectWaterSpeById" parameterType="Long" resultMap="WaterSpeResult">
<include refid="selectWaterSpeVo"/>
where id = #{id}
where
del_flag = '0'
and
id = #{id}
</select>
<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"
<if test="speTitle != null">spe_title,</if>
<if test="createUser != null and createUser != ''">create_user,</if>
<if test="createTime != null">create_time,</if>
<if test="price != null">price,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="speTitle != null">#{speTitle},</if>
<if test="createUser != null and createUser != ''">#{createUser},</if>
<if test="createTime != null">#{createTime},</if>
<if test="price != null">#{price},</if>
</trim>
</insert>
......@@ -57,6 +70,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="speTitle != null">spe_title = #{speTitle},</if>
<if test="createUser != null and createUser != ''">create_user = #{createUser},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="price != null">price = #{price},</if>
</trim>
where id = #{id}
</update>
......@@ -74,6 +88,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<update id="deleteWaterSpeValBySpeId" parameterType="Long">
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 id="deleteWaterSpeValBySpeIds" parameterType="String">
......@@ -84,10 +103,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</update>
<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
<foreach collection="list" item="item" separator=",">
(#{item.speId}, #{item.spe}, #{item.speVal})
(#{item.speId}, #{item.spe}, #{item.speVal},#{item.price},#{item.speValId})
</foreach>
</insert>
</mapper>
......@@ -37,7 +37,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
order by su.create_time DESC
</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
from water_station_user su LEFT JOIN water_station s ON s.id = su.station_id
where su.id = #{id}
......@@ -46,6 +46,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectWaterStationUserByPhone" parameterType="Long" resultMap="WaterStationUserResult">
<include refid="selectWaterStationUserVo"/>
where phone = #{phone}
and del_flag = '0'
</select>
<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
.antMatchers("/wx/**").permitAll()
//放行送水小程序登录相关接口
.antMatchers("/ssWx/getWxLoginInfo/**", "/ssWx/login/**", "/ssWx/getPhoneNumber/**","/ssWx/updateUser").permitAll()
//微信回调
.antMatchers("/callback/payNotify/").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