Commit 57510bc1 by jiang'yun

修改问题

parent 34ac4fea
package com.qianhe.system.config;
import com.wechat.pay.contrib.apache.httpclient.WechatPayHttpClientBuilder;
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.WechatPay2Credentials;
import com.wechat.pay.contrib.apache.httpclient.auth.WechatPay2Validator;
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.Data;
import lombok.extern.slf4j.Slf4j;
import org.apache.http.impl.client.CloseableHttpClient;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.security.GeneralSecurityException;
import java.security.PrivateKey;
/**
* @author yc
* @version 1.0
* @className WechatPayConfig
* @date 2024/3/15 14:55
* @description
*/
@Component
@Data
@Slf4j
@ConfigurationProperties(prefix = "wx")
public class WechatPayConfig {
/**
* 应用编号
*/
private String appId;
/**
* 商户号
*/
private String mchId;
/**
* APIv3密钥
*/
private String apiV3Key;
/**
* 支付通知回调地址
*/
private String notifyUrl;
/**
* 退款回调地址
*/
private String refundNotifyUrl;
/**
* API 证书中的 key.pem
*/
private String keyPemPath;
/**
* 商户序列号
*/
private String serialNo;
/**
* 获取商户的私钥文件
*
* @param keyPemPath
* @return
*/
public PrivateKey getPrivateKey(String keyPemPath) {
InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream(keyPemPath);
if (inputStream == null) {
throw new RuntimeException("私钥文件不存在");
}
return PemUtil.loadPrivateKey(inputStream);
}
/**
* 获取证书管理器实例
*
* @return
*/
@Bean
public Verifier getVerifier() throws GeneralSecurityException, IOException, HttpCodeException, NotFoundException {
log.info("获取证书管理器实例");
//获取商户私钥
PrivateKey privateKey = getPrivateKey(keyPemPath);
//私钥签名对象
PrivateKeySigner privateKeySigner = new PrivateKeySigner(serialNo, privateKey);
//身份认证对象
WechatPay2Credentials wechatPay2Credentials = new WechatPay2Credentials(mchId, privateKeySigner);
// 使用定时更新的签名验证器,不需要传入证书
CertificatesManager certificatesManager = CertificatesManager.getInstance();
certificatesManager.putMerchant(mchId, wechatPay2Credentials, apiV3Key.getBytes(StandardCharsets.UTF_8));
return certificatesManager.getVerifier(mchId);
}
/**
* 获取支付http请求对象
*
* @param verifier
* @return
*/
@Bean(name = "wxPayClient")
public CloseableHttpClient getWxPayClient(Verifier verifier) {
//获取商户私钥
PrivateKey privateKey = getPrivateKey(keyPemPath);
WechatPayHttpClientBuilder builder = WechatPayHttpClientBuilder.create()
.withMerchant(mchId, serialNo, privateKey)
.withValidator(new WechatPay2Validator(verifier));
// 通过WechatPayHttpClientBuilder构造的HttpClient,会自动的处理签名和验签,并进行证书自动更新
return builder.build();
}
}
\ No newline at end of file
//package com.qianhe.system.config;
//
//import com.wechat.pay.contrib.apache.httpclient.WechatPayHttpClientBuilder;
//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.WechatPay2Credentials;
//import com.wechat.pay.contrib.apache.httpclient.auth.WechatPay2Validator;
//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.Data;
//import lombok.extern.slf4j.Slf4j;
//import org.apache.http.impl.client.CloseableHttpClient;
//import org.springframework.boot.context.properties.ConfigurationProperties;
//import org.springframework.context.annotation.Bean;
//import org.springframework.stereotype.Component;
//
//import java.io.IOException;
//import java.io.InputStream;
//import java.nio.charset.StandardCharsets;
//import java.security.GeneralSecurityException;
//import java.security.PrivateKey;
//
///**
// * @author yc
// * @version 1.0
// * @className WechatPayConfig
// * @date 2024/3/15 14:55
// * @description
// */
//
//@Component
//@Data
//@Slf4j
//@ConfigurationProperties(prefix = "wx")
//public class WechatPayConfig {
// /**
// * 应用编号
// */
// private String appId;
// /**
// * 商户号
// */
// private String mchId;
//
// /**
// * APIv3密钥
// */
// private String apiV3Key;
// /**
// * 支付通知回调地址
// */
// private String notifyUrl;
// /**
// * 退款回调地址
// */
// private String refundNotifyUrl;
//
// /**
// * API 证书中的 key.pem
// */
// private String keyPemPath;
//
// /**
// * 商户序列号
// */
// private String serialNo;
//
//
// /**
// * 获取商户的私钥文件
// *
// * @param keyPemPath
// * @return
// */
// public PrivateKey getPrivateKey(String keyPemPath) {
//
// InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream(keyPemPath);
// if (inputStream == null) {
// throw new RuntimeException("私钥文件不存在");
// }
// return PemUtil.loadPrivateKey(inputStream);
// }
//
// /**
// * 获取证书管理器实例
// *
// * @return
// */
// @Bean
// public Verifier getVerifier() throws GeneralSecurityException, IOException, HttpCodeException, NotFoundException {
//
// log.info("获取证书管理器实例");
//
// //获取商户私钥
// PrivateKey privateKey = getPrivateKey(keyPemPath);
//
// //私钥签名对象
// PrivateKeySigner privateKeySigner = new PrivateKeySigner(serialNo, privateKey);
//
// //身份认证对象
// WechatPay2Credentials wechatPay2Credentials = new WechatPay2Credentials(mchId, privateKeySigner);
//
// // 使用定时更新的签名验证器,不需要传入证书
// CertificatesManager certificatesManager = CertificatesManager.getInstance();
// certificatesManager.putMerchant(mchId, wechatPay2Credentials, apiV3Key.getBytes(StandardCharsets.UTF_8));
//
// return certificatesManager.getVerifier(mchId);
// }
//
//
// /**
// * 获取支付http请求对象
// *
// * @param verifier
// * @return
// */
// @Bean(name = "wxPayClient")
// public CloseableHttpClient getWxPayClient(Verifier verifier) {
//
// //获取商户私钥
// PrivateKey privateKey = getPrivateKey(keyPemPath);
//
// WechatPayHttpClientBuilder builder = WechatPayHttpClientBuilder.create()
// .withMerchant(mchId, serialNo, privateKey)
// .withValidator(new WechatPay2Validator(verifier));
//
// // 通过WechatPayHttpClientBuilder构造的HttpClient,会自动的处理签名和验签,并进行证书自动更新
// return builder.build();
// }
//
//}
\ No newline at end of file
......@@ -30,9 +30,11 @@ public class MessageController {
//根据appId、appSecret获取access_token
public String getAccessToken() {
String url = accessTokenUri;
System.out.println("accessTokenUrl"+url);
// 利用hutool的http工具类请求获取access_token
String result = HttpUtil.get(url);
JSONObject jsonObject = JSONUtil.parseObj(result);
System.out.println(jsonObject);
return jsonObject.getStr("access_token");
}
......@@ -55,16 +57,28 @@ public class MessageController {
return "ok";
}
@GetMapping("/getToken")
public String getToken() {
String url = accessTokenUri;
System.out.println(url);
// 利用hutool的http工具类请求获取access_token
String result = HttpUtil.get(url);
JSONObject jsonObject = JSONUtil.parseObj(result);
return jsonObject.getStr("access_token");
}
//公众号发送
@GetMapping("/gzhSend")
public void gzhSend(){
JSONObject body=new JSONObject();
//获取标签标签tagid
//
String accessToken= getAccessToken();
System.out.println("========================================="+accessToken);
System.out.println("=========================================accessToken"+accessToken);
//获取标签标签tagid
String post = HttpUtil.post("https://api.weixin.qq.com/cgi-bin/tags/get?access_token=" + accessToken, body.toString());
System.out.println("=========================================tag"+post);
JSONObject jsonObjectTag = JSONUtil.parseObj(post);
System.out.println("=========================================jsonObjectTag"+jsonObjectTag);
int tagid=100;
......@@ -80,19 +94,19 @@ public class MessageController {
System.out.println("++++++++++++++++++++++++"+jsonObject);
//发送模板消息
String requestUrl = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + accessToken;
// body.set("touser","oRYXP0xFdoL6y_KfDJqqVrSzWz3M");//姜
body.set("touser","oRYXP0yahhI3RuBY2zM5iSnudap8");//王琪
body.set("template_id","uHjot1RT24Ws9he-8EVffVHq6hQgqPVTD1Y4w8wRHg8");
JSONObject json=new JSONObject();
json.set("thing27",new JSONObject().set("value","测试"));
json.set("amount24",new JSONObject().set("value", "16"));
json.set("time4",new JSONObject().set("value","2024-04-19"));
json.set("phone_number8",new JSONObject().set("value", "13325057900"));
body.set("data",json);
String resp = HttpUtil.post(requestUrl,body.toString());
JSONObject result = JSONUtil.parseObj(resp);
System.out.println("发送消息:" + resp);
System.out.println("发送消息:" + result);
// String requestUrl = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + accessToken;
//// body.set("touser","oRYXP0xFdoL6y_KfDJqqVrSzWz3M");//姜
// body.set("touser","oRYXP0yahhI3RuBY2zM5iSnudap8");//王琪
// body.set("template_id","uHjot1RT24Ws9he-8EVffVHq6hQgqPVTD1Y4w8wRHg8");
// JSONObject json=new JSONObject();
// json.set("thing27",new JSONObject().set("value","测试"));
// json.set("amount24",new JSONObject().set("value", "16"));
// json.set("time4",new JSONObject().set("value","2024-04-19"));
// json.set("phone_number8",new JSONObject().set("value", "13325057900"));
// body.set("data",json);
// String resp = HttpUtil.post(requestUrl,body.toString());
// JSONObject result = JSONUtil.parseObj(resp);
// System.out.println("发送消息:" + resp);
// System.out.println("发送消息:" + result);
}
}
\ No newline at end of file
......@@ -276,6 +276,7 @@ public class WaterOrderController extends BaseController
public TableDataInfo getWaterOrderListByStationId(WaterOrderVo waterOrderVo){
List<WaterOrderVo> list = waterOrderService.getWaterOrderListByStationId(waterOrderVo);
//查询该站点所有订单
waterOrderVo.setPageNum(null);
List<WaterOrderVo> list1 = waterOrderService.getWaterOrderListByStationId(waterOrderVo);
......@@ -285,6 +286,15 @@ public class WaterOrderController extends BaseController
List<WaterGoodsImg> waterGoodsImgs = waterGoodsImgService.selectWaterGoodsImgList(new WaterGoodsImg());
if (list.size() > 0){
for (WaterOrderVo order : list) {
if(order.getPayType()!=null){
if(1==order.getPayType()){
order.setPayTypeName("微信支付");
}else if(2==order.getPayType()){
order.setPayTypeName("水票");
}else if(3==order.getPayType()){
order.setPayTypeName("记账");
}
}
List<WaterOrderGoods> waterOrderGoodsList = new ArrayList<>();
for (WaterOrderGoods waterOrderGood : waterOrderGoods) {
if (order.getId().equals(waterOrderGood.getOrderId())){
......
......@@ -89,4 +89,25 @@ public class WaterUserController extends BaseController
{
return toAjax(waterUserService.deleteWaterUserByIds(ids));
}
/**
* 首页统计数量
* @return
*/
@GetMapping("/getUserSl")
public AjaxResult getUserSl()
{
return AjaxResult.success(waterUserService.getUserSl());
}
/**
* 查询用户是否可以记账
* @return
*/
@GetMapping("/getSfjz")
public AjaxResult getSfjz(WaterUser waterUser)
{
return AjaxResult.success(waterUserService.getSfjz(waterUser));
}
}
......@@ -13,6 +13,7 @@ import com.qianhe.framework.util.UserInfoUtil;
import com.qianhe.framework.web.service.MpTokenService;
import com.qianhe.system.domain.WaterStationUser;
import com.qianhe.system.domain.WaterUser;
import com.qianhe.system.mapper.WaterStationUserMapper;
import com.qianhe.system.service.IWaterStationUserService;
import com.qianhe.system.service.api.IWxLoginService;
import com.qianhe.system.service.impl.WaterUserServiceImpl;
......@@ -46,6 +47,9 @@ public class SsWxLogin {
@Autowired
private IWaterStationUserService waterStationUserService;
@Autowired
private WaterStationUserMapper waterStationUserMapper;
/**
* 获取用户openid和session_key
* @param code 微信临时登录凭证
......@@ -76,20 +80,36 @@ public class SsWxLogin {
@GetMapping("/login")
public AjaxResult login(@RequestParam("code") String code,@RequestParam("phoneNum") String phoneNum){
AjaxResult ajaxResult = AjaxResult.success();
//查询当前用户是否为配送工
WaterStationUserVo waterStationUserVo = waterStationUserMapper.selectWaterStationUserByPhone(Long.parseLong(phoneNum));
if(waterStationUserVo==null){
return AjaxResult.error("您无权限登录,请联系管理员!");
}
//根据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");
}
ajaxResult.put("loginInfo",wxLoginInfo);
ajaxResult.put("isNewUser",login.getIsNewUser());
AsyncManager.me().execute(AsyncFactory.recordLogininfor(login.getNickName(), Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success")));
String token = mpTokenService.createToken(login);
WaterStationUserVo userVo=new WaterStationUserVo();
userVo.setPhone(Long.parseLong(phoneNum));
userVo.setWxOpenid(wxLoginInfo.get("openid"));
int i =waterStationUserMapper.updateWaterStationUserByphone(userVo);
// WxLoginBody wxLoginBody = new WxLoginBody();
// wxLoginBody.setOpenId(wxLoginInfo.get("openid"));
// wxLoginBody.setPhone(phoneNum);
//
// MpLoginUser login = wxLoginService.ssLogin(wxLoginBody);
// if (StringUtils.isNull(login)) {
// return AjaxResult.error("您无权限登录,请联系管理员!");
// }
waterStationUserVo.setOpenId(waterStationUserVo.getWxOpenid());
ajaxResult.put("loginInfo",waterStationUserVo);
ajaxResult.put("isNewUser","0");
AsyncManager.me().execute(AsyncFactory.recordLogininfor(waterStationUserVo.getName(), Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success")));
MpLoginUser loginUser = new MpLoginUser();
loginUser.setOpenId(waterStationUserVo.getWxOpenid());
loginUser.setUserId(waterStationUserVo.getId());
loginUser.setNickName(waterStationUserVo.getName());
loginUser.setIsNewUser("0");
String token = mpTokenService.createToken(loginUser);
ajaxResult.put(Constants.TOKEN, token);
return ajaxResult;
}
......@@ -143,28 +163,30 @@ public class SsWxLogin {
String openId = user.getOpenId();
Map<String,Object> map = new HashMap<>();
//根据openid查询用户信息
WaterUser waterUser = waterUserService.selectUserByOpenId(openId,"2");
WaterStationUser waterUser=waterStationUserMapper.selectUserByOpenId(openId);
if (StringUtils.isNull(waterUser)){
return AjaxResult.warn("未查询到你的站点信息,请联系管理员!");
}
waterUser.setOpenId(waterUser.getWxOpenid());
map.put("userId",waterUser.getId());
map.put("nickName",waterUser.getNickName());
map.put("phoneNum",waterUser.getPhoneNum());
map.put("nickName",waterUser.getName());
map.put("phoneNum",waterUser.getPhone());
map.put("stationName",waterUser.getStationName());
map.put("userType",waterUser.getUserType());
map.put("userGender",waterUser.getUserGender());
AsyncManager.me().execute(AsyncFactory.recordLogininfor(waterUser.getNickName(), Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success")));
map.put("userType","2");
map.put("userGender",waterUser.getGender());
AsyncManager.me().execute(AsyncFactory.recordLogininfor(waterUser.getName(), Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success")));
//存在
MpLoginUser loginUser = new MpLoginUser();
loginUser.setOpenId(openId);
loginUser.setUserId(waterUser.getId());
loginUser.setNickName(waterUser.getNickName());
loginUser.setNickName(waterUser.getName());
loginUser.setIsNewUser("0");
String token = mpTokenService.createToken(loginUser);
map.put(Constants.TOKEN, token);
//查询送水工站点信息
WaterStationUserVo waterStationUser = waterStationUserService.selectWaterStationUserByPhone(waterUser.getPhoneNum());
if (StringUtils.isNull(waterStationUser)){
return AjaxResult.warn("未查询到你的站点信息,请联系管理员!");
}
map.put("waterStationUser",waterStationUser);
// WaterStationUserVo waterStationUser = waterStationUserService.selectWaterStationUserByPhone(waterUser.getPhone());
map.put("waterStationUser",waterUser);
return AjaxResult.success(map);
}
......
......@@ -80,4 +80,6 @@ public class WaterGoods
//规格
private String spe;
private BigDecimal sjjg;
private String speVal;
}
......@@ -66,4 +66,6 @@ public class WaterGoodsCart {
/** 详情图集合 */
private List<WaterGoodsImg> detailsImgs;
private String speVal;
}
......@@ -202,6 +202,7 @@ public class WaterOrder extends BaseEntity
private String tkbh;
private String authCode;
private String wctype;
}
......@@ -39,6 +39,9 @@ public class WaterOrderGoods
/** 规格详情 */
private String goodsSpe;
//规格数量
private String speVal;
/** 商品id */
private Long goodsId;
......
......@@ -59,5 +59,11 @@ public class WaterStationUser
/** 公众号用户openid */
@Excel(name = "公众号用户openid")
private String openId;
//送水小程序openid
private String wxOpenid;
private String isOpen;
private String stationName;
}
......@@ -55,4 +55,8 @@ public class WaterUser
/** 微信小程序open_id */
private String openId;
//是否可以记账
private String sfjz;
}
......@@ -2,6 +2,7 @@ package com.qianhe.system.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qianhe.system.domain.WaterStationUser;
import com.qianhe.system.domain.WaterUser;
import com.qianhe.system.vo.WaterStationUserVo;
import org.apache.ibatis.annotations.Param;
......@@ -69,4 +70,10 @@ public interface WaterStationUserMapper extends BaseMapper<WaterStationUser>
* @return
*/
WaterStationUserVo selectWaterStationUserByPhone(@Param("phone") Long phone);
int updateWaterStationUserByphone(WaterStationUserVo userVo);
WaterStationUser selectUserByOpenId(String openId);
}
......@@ -6,6 +6,7 @@ import com.qianhe.system.domain.WaterUser;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
* 用户Mapper接口
......@@ -84,4 +85,7 @@ public interface WaterUserMapper extends BaseMapper<WaterUser>
* @return 结果
*/
int deleteWaterUserAddressByIds(Long[] ids);
Map<String, Integer> getUserSl();
}
......@@ -6,6 +6,7 @@ import com.qianhe.system.domain.WaterUser;
import com.qianhe.system.vo.WaterUserVo;
import java.util.List;
import java.util.Map;
/**
* 用户Service接口
......@@ -76,4 +77,8 @@ public interface IWaterUserService extends IService<WaterUser>
* @return
*/
int updateUserByOpenId(WaterUser waterUser);
Map<String, Integer> getUserSl();
Boolean getSfjz(WaterUser waterUser);
}
......@@ -75,10 +75,11 @@ public class WaterGoodsCartServiceImpl implements IWaterGoodsCartService {
WaterGoodsSpeVal waterGoodsSpeVal = waterGoodsSpeMapper.selectWaterGoodsSpeValById(waterGoodsCart.getGoodsSpeValId());
waterGoodsCart.setGoodsName(waterGoods.getTitle());
waterGoodsCart.setGoodsTypeId(waterGoods.getGoodsTypeId());
waterGoodsCart.setGoodsSpeVal(waterGoodsSpeVal.getSpe() + ":" + waterGoodsSpeVal.getSpeVal());
waterGoodsCart.setGoodsSpeVal(waterGoodsSpeVal.getSpe() + "*" + waterGoodsSpeVal.getSpeVal());
waterGoodsCart.setGoodsPrice(waterGoodsSpeVal.getPrice());
waterGoodsCart.setGoodsTotal(waterGoodsSpeVal.getPrice());
waterGoodsCart.setCreateUser(waterGoodsCart.getUserId().toString());
waterGoodsCart.setSpeVal(waterGoodsSpeVal.getSpeVal());
waterGoodsCart.setGoodsNum(1);
waterGoodsCart.setCreateTime(DateUtils.getNowDate());
return waterGoodsCartMapper.insertWaterGoodsCart(waterGoodsCart);
......
......@@ -503,8 +503,10 @@ public class WaterGoodsServiceImpl implements IWaterGoodsService
waterGoodsVo1.setGoodsSpeValId(waterGoodsVo.getGoodsSpeValId());
//根据商品关联规格值id查询商品关联规格值
WaterGoodsSpeVal waterGoodsSpeVal = waterGoodsSpeMapper.selectWaterGoodsSpeValById(waterGoodsVo.getGoodsSpeValId());
waterGoodsVo1.setGoodsSpeVal(waterGoodsSpeVal.getSpe() + ":" + waterGoodsSpeVal.getSpeVal());
waterGoodsVo1.setGoodsSpeVal(waterGoodsSpeVal.getSpe() + "*" + waterGoodsSpeVal.getSpeVal());
waterGoodsVo1.setPrice(waterGoodsSpeVal.getPrice());
waterGoodsVo1.setSpe(waterGoodsSpeVal.getSpe() );
waterGoodsVo1.setSpeVal(waterGoodsSpeVal.getSpeVal() );
//查询商品图片
WaterGoodsImg waterGoodsImg = new WaterGoodsImg();
waterGoodsImg.setGoodsId(waterGoodsVo.getId());
......
......@@ -152,23 +152,25 @@ public class WaterOrderServiceImpl implements IWaterOrderService
String ddh = getOrerNum();
waterOrderVo.setOrderNum(ddh);
//判断支付方式是否为水票支付
if(waterOrderVo.getPayType() == 2){
//水票支付,修改订单状态为待接单
waterOrderVo.setOrderState(2);
waterOrderVo.setPayState(1);
waterOrderVo.setOrderType(1);
}else {
//判断支付方式是否为银行支付
if(waterOrderVo.getPayType() == 1 ){
//银行支付,修改订单状态为待付款
waterOrderVo.setOrderState(1);
waterOrderVo.setPayState(0);
waterOrderVo.setOrderType(1);
}else {
//水票支付,修改订单状态为待接单
waterOrderVo.setOrderState(2);
waterOrderVo.setPayState(1);
waterOrderVo.setOrderType(1);
}
int i = waterOrderMapper.insertWaterOrder(waterOrderVo);
//新增订单商品
insertWaterOrderGoods(waterOrderVo);
//判断支付方式是否为水票支付
if(waterOrderVo.getPayType() == 2){
if(waterOrderVo.getPayType() != 1 ){
gzhSend(waterOrderVo);
}
return ddh;
......@@ -349,7 +351,7 @@ public class WaterOrderServiceImpl implements IWaterOrderService
if (waterOrderVo.getOrderState() == 5){
//判断该订单是否已经支付,支付后取消,需要退款,将该订单改为退款订单
//判断该订单支付方式是否为水票支付,水票支付不涉及退款
if (waterOrder.getPayType() == 2){
if (waterOrder.getPayType() == 2 || waterOrder.getPayType() == 3){
//为水票支付,该订单状态改为已取消
waterOrderVo.setOrderState(5);
}else {
......@@ -373,7 +375,7 @@ public class WaterOrderServiceImpl implements IWaterOrderService
if(time1.equals(time2)){
//相等说明下单时间的晚上0点
//TODO 执行退款操作\
//先生成退款单号
//先生成退款单号
String tkbh = getTkNum();
waterOrderVo.setTkbh(tkbh);
waterOrder.setTkbh(tkbh);
......@@ -528,6 +530,19 @@ public class WaterOrderServiceImpl implements IWaterOrderService
public int updateCompleteState(WaterOrderVo waterOrderVo) {
//设置送达时间
waterOrderVo.setDelieverOver(DateUtils.getNowDate());
//判断送水工是否点击已完成
if (waterOrderVo.getCompleteState() == 1){
waterOrderVo.setOrderState(4);
waterOrderVo.setConfirmState(1);
waterOrderVo.setTakeTime(DateUtils.getNowDate());
waterOrderVo.setFinishTime(DateUtils.getNowDate());
waterOrderVo.setWctype("送水工");
}else {
waterOrderVo.setOrderState(6);
waterOrderVo.setConfirmState(2);
waterOrderVo.setFinishTime(DateUtils.getNowDate());
waterOrderVo.setWctype("送水工");
}
return waterOrderMapper.updateWaterOrder(waterOrderVo);
}
......@@ -545,11 +560,13 @@ public class WaterOrderServiceImpl implements IWaterOrderService
waterOrderVo.setCompleteState(1);
waterOrderVo.setTakeTime(DateUtils.getNowDate());
waterOrderVo.setFinishTime(DateUtils.getNowDate());
waterOrderVo.setWctype("用户");
i += waterOrderMapper.updateWaterOrder(waterOrderVo);
}else if (waterOrderVo.getConfirmState() == 2){
waterOrderVo.setOrderState(6);
waterOrderVo.setCompleteState(2);
waterOrderVo.setFinishTime(DateUtils.getNowDate());
waterOrderVo.setWctype("用户");
i += waterOrderMapper.updateWaterOrder(waterOrderVo);
}
return i;
......@@ -649,7 +666,7 @@ public class WaterOrderServiceImpl implements IWaterOrderService
@Override
public int updateOrderPayType(WaterOrderVo waterOrderVo) {
//判断是否为水票支付,为水票支付,则订单直接变为待接单
if (waterOrderVo.getPayType() == 2){
if (waterOrderVo.getPayType() == 2 || waterOrderVo.getPayType() == 3){
waterOrderVo.setOrderState(2);
waterOrderVo.setPayState(1);
}
......
......@@ -99,7 +99,7 @@ public class WaterSpeServiceImpl implements IWaterSpeService
if (waterSpeVals.size() > 0){
//批量新增
waterSpeMapper.batchInsertWaterSpeVal(waterSpeVals);
waterSpeMapper.batchInsertWaterGoodsSpeVal(waterSpeVals);
// waterSpeMapper.batchInsertWaterGoodsSpeVal(waterSpeVals);
}
}
......
......@@ -144,7 +144,7 @@ public class WaterStationServiceImpl implements IWaterStationService
public int updateWaterStation(WaterStation waterStation)
{
//删除该站点用户
waterStationMapper.deleteWaterStationUserByStationId(waterStation.getId());
// waterStationMapper.deleteWaterStationUserByStationId(waterStation.getId());
WaterStation w = gaodeToTencent(waterStation.getStationLon(),waterStation.getStationLat());
waterStation.setStationLonTen(w.getStationLonTen());
waterStation.setStationLatTen(w.getStationLatTen());
......
......@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qianhe.common.core.domain.model.WxLoginBody;
import com.qianhe.common.utils.DateUtils;
import com.qianhe.common.utils.StringUtils;
import com.qianhe.system.domain.WaterUser;
import com.qianhe.system.domain.WaterUserAddress;
import com.qianhe.system.mapper.WaterUserAddressMapper;
......@@ -15,6 +16,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
/**
* 用户Service业务层处理
......@@ -133,4 +135,27 @@ public class WaterUserServiceImpl extends ServiceImpl<WaterUserMapper,WaterUser>
public int updateUserByOpenId(WaterUser waterUser) {
return waterUserMapper.updateUserByOpenId(waterUser);
}
@Override
public Map<String, Integer> getUserSl() {
return waterUserMapper.getUserSl();
}
@Override
public Boolean getSfjz(WaterUser waterUser) {
WaterUser waterUser1 = waterUserMapper.selectUserByOpenId(waterUser.getOpenId(), "1");
if(waterUser1==null){
return false;
}
if(StringUtils.isNotNull(waterUser1.getSfjz())){
if("是".equals(waterUser1.getSfjz())){
return true;
}else {
return false;
}
}else {
return false;
}
}
}
......@@ -50,6 +50,7 @@ public class WxLoginServiceImpl implements IWxLoginService {
public MpLoginUser ssLogin(WxLoginBody wxLoginBody) {
//根据用户openid查询用户是否存在
WaterUser user = waterUserMapper.selectUserByOpenId(wxLoginBody.getOpenId(),"2");
if (StringUtils.isNotNull(user)){
//存在
MpLoginUser loginUser = new MpLoginUser();
......
package com.qianhe.system.utils;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.apache.http.HttpEntity;
import org.apache.http.HttpStatus;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.util.EntityUtils;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
/**
* @author yc
* @version 1.0
* @className WechatPayRequest
* @date 2024/3/15 14:56
* @description
*/
@Component
@Slf4j
public class WechatPayRequest {
@Resource
private CloseableHttpClient wxPayClient;
/**
* 支付请求
*
* @param url
* @param paramsStr
* @return
*/
public String wechatHttpOrderPost(String url, String paramsStr) {
try {
HttpPost httpPost = new HttpPost(url);
StringEntity stringEntity = new StringEntity(paramsStr, "utf-8");
stringEntity.setContentType("application/json");
httpPost.setEntity(stringEntity);
httpPost.setHeader("Accept", "application/json");
CloseableHttpResponse response = wxPayClient.execute(httpPost);
//响应体
HttpEntity entity = response.getEntity();
String body = entity == null ? "" : EntityUtils.toString(entity);
//响应状态码
int statusCode = response.getStatusLine().getStatusCode();
//处理成功,204是,关闭订单时微信返回的正常状态码
if (statusCode == HttpStatus.SC_OK || statusCode == HttpStatus.SC_NO_CONTENT) {
log.info("成功, 返回结果 = " + body);
} else {
String msg = "微信支付请求失败,响应码 = " + statusCode + ",返回结果 = " + body;
log.info("支付模块-生成订单 = " + msg);
throw new RuntimeException(msg);
}
return body;
} catch (Exception e) {
throw new RuntimeException(e.getMessage());
}
}
/**
* 退款请求
*
* @param url
* @param paramsStr
* @return
*/
public String wechatHttpPost(String url, String paramsStr) {
try {
HttpPost httpPost = new HttpPost(url);
StringEntity stringEntity = new StringEntity(paramsStr, "utf-8");
stringEntity.setContentType("application/json");
httpPost.setEntity(stringEntity);
httpPost.setHeader("Accept", "application/json");
CloseableHttpResponse response = wxPayClient.execute(httpPost);
//响应体
HttpEntity entity = response.getEntity();
String body = entity == null ? "" : EntityUtils.toString(entity);
//响应状态码
int statusCode = response.getStatusLine().getStatusCode();
//处理成功,204是,关闭订单时微信返回的正常状态码
if (statusCode == HttpStatus.SC_OK || statusCode == HttpStatus.SC_NO_CONTENT) {
log.info("成功, 返回结果 = " + body);
// 请求成功或已处理成功,返回成功的响应
return "退款处理中";
} else if (statusCode == HttpStatus.SC_BAD_REQUEST || statusCode == HttpStatus.SC_INTERNAL_SERVER_ERROR) {
// 请求参数错误或系统错误,返回失败的响应
JSONObject json = JSONObject.parseObject(body);
return json.getString("message");
} else if (statusCode == HttpStatus.SC_FORBIDDEN) {
// 权限问题,没有退款权限
return "没有退款权限";
} else if (statusCode == HttpStatus.SC_NOT_FOUND) {
// 订单号不存在
return "订单号不存在";
} else if (statusCode == 429) {
// 频率限制
return "退款请求频率过高,请稍后重试";
} else if (statusCode == HttpStatus.SC_PAYMENT_REQUIRED) {
// 余额不足
return "商户余额不足,请充值后重试";
} else {
// 其他状态码,返回通用的失败响应
return "退款失败,请稍后重试";
}
} catch (Exception e) {
log.info("支付模块-退款失败 = " + e.getMessage());
JSONObject json = JSONObject.parseObject(e.getMessage());
return json.getString("message");
}
}
}
\ No newline at end of file
//package com.qianhe.system.utils;
//
//import com.alibaba.fastjson.JSONObject;
//import lombok.extern.slf4j.Slf4j;
//import org.apache.http.HttpEntity;
//import org.apache.http.HttpStatus;
//import org.apache.http.client.methods.CloseableHttpResponse;
//import org.apache.http.client.methods.HttpPost;
//import org.apache.http.entity.StringEntity;
//import org.apache.http.impl.client.CloseableHttpClient;
//import org.apache.http.util.EntityUtils;
//import org.springframework.stereotype.Component;
//
//import javax.annotation.Resource;
//
///**
// * @author yc
// * @version 1.0
// * @className WechatPayRequest
// * @date 2024/3/15 14:56
// * @description
// */
//
//@Component
//@Slf4j
//public class WechatPayRequest {
// @Resource
// private CloseableHttpClient wxPayClient;
//
// /**
// * 支付请求
// *
// * @param url
// * @param paramsStr
// * @return
// */
// public String wechatHttpOrderPost(String url, String paramsStr) {
// try {
// HttpPost httpPost = new HttpPost(url);
// StringEntity stringEntity = new StringEntity(paramsStr, "utf-8");
// stringEntity.setContentType("application/json");
// httpPost.setEntity(stringEntity);
// httpPost.setHeader("Accept", "application/json");
//
// CloseableHttpResponse response = wxPayClient.execute(httpPost);
// //响应体
// HttpEntity entity = response.getEntity();
// String body = entity == null ? "" : EntityUtils.toString(entity);
// //响应状态码
// int statusCode = response.getStatusLine().getStatusCode();
// //处理成功,204是,关闭订单时微信返回的正常状态码
// if (statusCode == HttpStatus.SC_OK || statusCode == HttpStatus.SC_NO_CONTENT) {
// log.info("成功, 返回结果 = " + body);
// } else {
// String msg = "微信支付请求失败,响应码 = " + statusCode + ",返回结果 = " + body;
// log.info("支付模块-生成订单 = " + msg);
// throw new RuntimeException(msg);
// }
// return body;
// } catch (Exception e) {
// throw new RuntimeException(e.getMessage());
// }
// }
//
// /**
// * 退款请求
// *
// * @param url
// * @param paramsStr
// * @return
// */
// public String wechatHttpPost(String url, String paramsStr) {
// try {
// HttpPost httpPost = new HttpPost(url);
// StringEntity stringEntity = new StringEntity(paramsStr, "utf-8");
// stringEntity.setContentType("application/json");
// httpPost.setEntity(stringEntity);
// httpPost.setHeader("Accept", "application/json");
//
// CloseableHttpResponse response = wxPayClient.execute(httpPost);
// //响应体
// HttpEntity entity = response.getEntity();
// String body = entity == null ? "" : EntityUtils.toString(entity);
// //响应状态码
// int statusCode = response.getStatusLine().getStatusCode();
//
// //处理成功,204是,关闭订单时微信返回的正常状态码
// if (statusCode == HttpStatus.SC_OK || statusCode == HttpStatus.SC_NO_CONTENT) {
// log.info("成功, 返回结果 = " + body);
// // 请求成功或已处理成功,返回成功的响应
// return "退款处理中";
// } else if (statusCode == HttpStatus.SC_BAD_REQUEST || statusCode == HttpStatus.SC_INTERNAL_SERVER_ERROR) {
// // 请求参数错误或系统错误,返回失败的响应
// JSONObject json = JSONObject.parseObject(body);
// return json.getString("message");
// } else if (statusCode == HttpStatus.SC_FORBIDDEN) {
// // 权限问题,没有退款权限
// return "没有退款权限";
// } else if (statusCode == HttpStatus.SC_NOT_FOUND) {
// // 订单号不存在
// return "订单号不存在";
// } else if (statusCode == 429) {
// // 频率限制
// return "退款请求频率过高,请稍后重试";
// } else if (statusCode == HttpStatus.SC_PAYMENT_REQUIRED) {
// // 余额不足
// return "商户余额不足,请充值后重试";
// } else {
// // 其他状态码,返回通用的失败响应
// return "退款失败,请稍后重试";
// }
// } catch (Exception e) {
// log.info("支付模块-退款失败 = " + e.getMessage());
// JSONObject json = JSONObject.parseObject(e.getMessage());
// return json.getString("message");
// }
// }
//
//
//}
\ No newline at end of file
......@@ -50,6 +50,8 @@ public class WaterGoodsCartVo {
/** 商品价格 */
private BigDecimal price;
private String speVal;
/** 商品数量 */
private Integer goodsNum;
......
......@@ -77,6 +77,8 @@ public class WaterGoodsVo {
private String spe;
private BigDecimal sjjg;
private String speVal;
/** 封面图集合 */
private List<WaterGoodsImg> coverImgs;
......
......@@ -181,4 +181,9 @@ public class WaterOrderVo {
private String zfsj;
private String tkbh;
private String payTypeName;
private String wctype;
}
......@@ -54,4 +54,6 @@ public class WaterStationUserVo {
@Excel(name = "公众号用户openid")
private String openId;
private String wxOpenid;
}
......@@ -2,11 +2,14 @@ package com.qianhe.web.controller.common;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.qianhe.common.utils.file.MimeTypeUtils;
import com.qianhe.common.utils.uuid.UUID;
import com.qianhe.system.utils.OSSUtil;
import org.apache.commons.io.FilenameUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -147,6 +150,11 @@ public class CommonController
{
//原始文件名
String originalFilename = file.getOriginalFilename();
String hz = getExtension(file);
if(!isAllowedExtension(hz, MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION)){
return AjaxResult.error("文件格式错误,请重新上传!");
}
//截取文件名后缀 xxx.png
String extension = originalFilename.substring(originalFilename.lastIndexOf("."));
// //构造新文件名称
......@@ -167,31 +175,67 @@ public class CommonController
}
/**
* 本地资源通用下载
* 判断MIME类型是否是允许的MIME类型
*
* @param extension
* @param allowedExtension
* @return
*/
@GetMapping("/download/resource")
public void resourceDownload(String resource, HttpServletRequest request, HttpServletResponse response)
throws Exception
public static final boolean isAllowedExtension(String extension, String[] allowedExtension)
{
try
for (String str : allowedExtension)
{
if (!FileUtils.checkAllowDownload(resource))
if (str.equalsIgnoreCase(extension))
{
throw new Exception(StringUtils.format("资源文件({})非法,不允许下载。 ", resource));
return true;
}
// 本地资源路径
String localPath = RuoYiConfig.getProfile();
// 数据库资源地址
String downloadPath = localPath + StringUtils.substringAfter(resource, Constants.RESOURCE_PREFIX);
// 下载名称
String downloadName = StringUtils.substringAfterLast(downloadPath, "/");
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
FileUtils.setAttachmentResponseHeader(response, downloadName);
FileUtils.writeBytes(downloadPath, response.getOutputStream());
}
catch (Exception e)
return false;
}
/**
* 获取文件名的后缀
*
* @param file 表单文件
* @return 后缀名
*/
public static final String getExtension(MultipartFile file)
{
String extension = FilenameUtils.getExtension(file.getOriginalFilename());
if (StringUtils.isEmpty(extension))
{
log.error("下载文件失败", e);
extension = MimeTypeUtils.getExtension(Objects.requireNonNull(file.getContentType()));
}
return extension;
}
/**
* 本地资源通用下载
*/
// @GetMapping("/download/resource")
// public void resourceDownload(String resource, HttpServletRequest request, HttpServletResponse response)
// throws Exception
// {
// try
// {
// if (!FileUtils.checkAllowDownload(resource))
// {
// throw new Exception(StringUtils.format("资源文件({})非法,不允许下载。 ", resource));
// }
// // 本地资源路径
// String localPath = RuoYiConfig.getProfile();
// // 数据库资源地址
// String downloadPath = localPath + StringUtils.substringAfter(resource, Constants.RESOURCE_PREFIX);
// // 下载名称
// String downloadName = StringUtils.substringAfterLast(downloadPath, "/");
// response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
// FileUtils.setAttachmentResponseHeader(response, downloadName);
// FileUtils.writeBytes(downloadPath, response.getOutputStream());
// }
// catch (Exception e)
// {
// log.error("下载文件失败", e);
// }
// }
}
......@@ -21,11 +21,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="status" column="status" />
<result property="createUser" column="create_user" />
<result property="createTime" column="create_time" />
<result property="speVal" column="spe_val" />
</resultMap>
<sql id="selectWaterGoodsCartVo">
select id, user_id, goods_id, goods_name, goods_type_id, goods_type_name,
goods_spe_id, goods_spe_val_id, goods_spe_val, goods_price, goods_num, goods_total, is_select, status, create_user, create_time
goods_spe_id, goods_spe_val_id, goods_spe_val, goods_price, goods_num, goods_total, is_select, status, create_user, create_time,spe_val
from water_goods_cart
</sql>
......@@ -72,6 +73,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="status != null">status,</if>
<if test="createUser != null">create_user,</if>
<if test="createTime != null">create_time,</if>
<if test="speVal != null">spe_val,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="userId != null">#{userId},</if>
......@@ -88,6 +90,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="status != null">#{status},</if>
<if test="createUser != null">(select nick_name from water_user where id = #{createUser}),</if>
<if test="createTime != null">#{createTime},</if>
<if test="speVal != null">#{speVal},</if>
</trim>
</insert>
......@@ -108,6 +111,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="status != null">status = #{status},</if>
<if test="createUser != null">create_user = #{createUser},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="speVal != null">spe_val = #{speVal},</if>
</trim>
where id = #{id}
</update>
......
......@@ -20,10 +20,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="spjj" column="spjj" />
<result property="spe" column="spe" />
<result property="sjjg" column="sjjg" />
<result property="speVal" column="spe_val" />
</resultMap>
<sql id="selectWaterGoodsVo">
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,a.spjj, c.spe,c.sjjg
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,a.spjj, c.spe,c.spe_val,c.sjjg
from
water_goods a
left join
......
......@@ -41,7 +41,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<select id="selectWaterGoodsSpeValById" parameterType="String" resultType="WaterGoodsSpeVal">
select id, spe_id, spe, spe_val, price from water_goods_spe_val
select id, spe_id, spe, spe_val, price,spe_val from water_goods_spe_val
where id = #{id}
</select>
......
......@@ -19,10 +19,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="remark" column="remark" />
<result property="createTime" column="create_time" />
<result property="createUser" column="create_user" />
<result property="speVal" column="spe_val" />
</resultMap>
<sql id="selectWaterOrderGoodsVo">
select id, order_id, order_num, goods_type_id, goods_type, goods_spe, goods_id, goods_title, goods_num, goods_price, goods_total, remark, create_time, create_user from water_order_goods
select id, order_id, order_num, goods_type_id, goods_type, goods_spe, goods_id, goods_title, goods_num, goods_price, goods_total, remark, create_time, create_user,spe_val from water_order_goods
</sql>
<select id="selectWaterOrderGoodsList" parameterType="WaterOrderGoods" resultMap="WaterOrderGoodsResult">
......@@ -41,6 +42,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="goodsTotal != null "> and goods_total = #{goodsTotal}</if>
<if test="createTime != null "> and create_time = #{createTime}</if>
<if test="createUser != null and createUser != ''"> and create_user = #{createUser}</if>
<if test="speVal != null and speVal != ''"> and spe_val = #{speVal}</if>
</where>
</select>
......@@ -65,6 +67,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="remark != null">remark,</if>
<if test="createTime != null">create_time,</if>
<if test="createUser != null">create_user,</if>
<if test="speVal != null">spe_val,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="orderId != null">#{orderId},</if>
......@@ -80,6 +83,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="remark != null">#{remark},</if>
<if test="createTime != null">#{createTime},</if>
<if test="createUser != null">#{createUser},</if>
<if test="speVal != null">#{speVal},</if>
</trim>
</insert>
......@@ -99,6 +103,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="remark != null">remark = #{remark},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="createUser != null">create_user = #{createUser},</if>
<if test="speVal != null">spe_val = #{speVal},</if>
</trim>
where id = #{id}
</update>
......
......@@ -51,6 +51,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="orderType" column="order_type" />
<result property="returnOrderResult" column="return_order_result" />
<result property="xdsj" column="xdsj" />
<result property="wctype" column="wctype" />
</resultMap>
<sql id="selectWaterOrderVo">
......@@ -60,7 +61,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
pay_state, pay_type, pay_num, cancel_result, user_address_id, name, province,
city, area, address, lon, lat, mobile, deliever_time, deliever_name, deliever_mobile,
create_time, create_user, deliever_over, take_time, finish_time, remark, goods_val,
order_type, return_order_result,xdsj from water_order
order_type, return_order_result,xdsj,wctype from water_order
</sql>
<select id="selectWaterOrderList" parameterType="com.qianhe.system.vo.WaterOrderVo" resultMap="WaterOrderResult">
......@@ -107,6 +108,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="remark != null and remark != ''"> and remark = #{remark}</if>
<if test="goodsVal != null "> and goods_val = #{goodsVal}</if>
<if test="orderType != null "> and order_type = #{orderType}</if>
<if test="wctype != null "> and wctype = #{wctype}</if>
<if test="startTime != null and startTime != '' and endTime != null and endTime != '' "> and create_time BETWEEN #{startTime} AND #{endTime}</if>
</where>
order by create_time DESC
......@@ -164,6 +166,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="goodsVal != null">goods_val,</if>
<if test="orderType != null">order_type,</if>
<if test="returnOrderResult != null">return_order_result,</if>
<if test="wctype != null">wctype,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="orderNum != null">#{orderNum},</if>
......@@ -213,6 +216,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="goodsVal != null">#{goodsVal},</if>
<if test="orderType != null">#{orderType},</if>
<if test="returnOrderResult != null">#{returnOrderResult},</if>
<if test="wctype != null">#{wctype},</if>
</trim>
</insert>
......@@ -245,6 +249,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="payState != null">pay_state = #{payState},</if>
<if test="payType != null">pay_type = #{payType},</if>
<if test="payNum != null">pay_num = #{payNum},</if>
<if test="wctype != null">wctype = #{wctype},</if>
<if test="userAddressId != null">
user_address_id = #{userAddressId},
name = (select name from water_user_address where id = #{userAddressId}),
......@@ -302,12 +307,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<insert id="batchInsertWaterOrderGoods">
insert into water_order_goods(order_id, order_num, goods_type_id, goods_type, goods_spe, goods_id, goods_title,
goods_num, goods_price, goods_total, remark, create_time, create_user)
goods_num, goods_price, goods_total, remark, create_time, create_user,spe_val)
values
<foreach collection="list" item="item" separator=",">
(#{item.orderId}, #{item.orderNum}, #{item.goodsTypeId}, (select type_name from water_goods_type where id = #{item.goodsTypeId}),
#{item.goodsSpe}, #{item.goodsId}, #{item.goodsTitle}, #{item.goodsNum}, #{item.goodsPrice}, #{item.goodsTotal}
, #{item.remark}, #{item.createTime}, (select nick_name from water_user where id = #{item.createUser}))
, #{item.remark}, #{item.createTime}, (select nick_name from water_user where id = #{item.createUser}),#{item.speVal})
</foreach>
</insert>
......@@ -332,25 +337,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="getOrderNumByStation2" parameterType="com.qianhe.system.vo.WaterOrderVo" resultType="Map">
select
(select count(*) userTotal from water_user where del_flag = '0') userTotal,
(select count(*) todayUserTotal from water_user where del_flag = '0' and DATE_FORMAT(create_time, '%Y-%m-%d') = DATE_FORMAT('2024-04-01', '%Y-%m-%d') )todayUserTotal,
(select count(*) monUserTotal from water_user where del_flag = '0' and DATE_FORMAT(create_time, '%Y-%m') = DATE_FORMAT('2024-04-01', '%Y-%m') )monUserTotal,
(select count(*) yearlUserTotal from water_user where del_flag = '0' and DATE_FORMAT(create_time, '%Y') = DATE_FORMAT('2024-04-01', '%Y') )yearlUserTotal,
COUNT(id) as todayOrderNum,
(SELECT COUNT(id) as inComOrderNum FROM `water_order` WHERE del_flag = '0' and order_state = 1) as comOrderNum,
(SELECT COUNT(id) as inComOrderNum FROM `water_order` WHERE del_flag = '0' and order_state = 3) as proOrderNum,
/*(SELECT COUNT(id) as totalOrderNum FROM `water_order` WHERE del_flag = '0' ) as totalOrderNum,*/
(SELECT COUNT(id) as inComOrderNum FROM `water_order` WHERE del_flag = '0' and order_state in (2,3)) as inComOrderNum,
(select sum(goods_total) totalPrice from water_order_goods where order_id in
(select id FROM `water_order` WHERE del_flag = '0')) totalPrice,
ifnull((select sum(goods_total) totalPrice from water_order_goods where order_id in
(select id FROM `water_order` WHERE del_flag = '0' and order_state = 4)),0) comPrice,
ifnull((select sum(goods_total) totalPrice from water_order_goods where order_id in
(select id FROM `water_order` WHERE del_flag = '0' and order_state = 3)),0) proPrice,
ifnull((select sum(goods_total) totalPrice from water_order_goods where order_id in
(select id FROM `water_order` WHERE del_flag = '0' and order_state = 3)),0) unPaidPrice
FROM `water_order`
WHERE del_flag = '0' and order_state != 1 and DATE_FORMAT(create_time, '%Y-%m-%d') = DATE_FORMAT(#{createTime}, '%Y-%m-%d');
sum( case when order_state=1 then 1 else 0 end ) as inComOrderNum,
sum( case when order_state=4 then 1 else 0 end ) as comOrderNum,
sum( case when order_state in (2,3) then 1 else 0 end ) as proOrderNum,
sum( case when order_state in (5,6,7) then 1 else 0 end ) as yqxdd,
sum( case when order_state=4 then goods_val else 0 end ) as comPrice,
sum( case when order_state in (2,3) then goods_val else 0 end ) as proPrice,
sum( case when order_state=1 then goods_val else 0 end ) as unPaidPrice,
sum( case when order_state!=1 then goods_val else 0 end ) as yqxddje
from water_order a where del_flag = '0'
</select>
......
......@@ -26,18 +26,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<select id="selectWaterSpeValList" parameterType="WaterSpeVal" resultType="WaterSpeVal">
select a.id, a.spe_id, a.spe, a.spe_val,b.price,b.sjjg,b.pp,b.cd from water_spe_val a
left join
water_goods_spe_val b
on a.spe_id = b.spe_id
<where>
a.del_flag = '0'
and
b.del_flag = '0'
and
a.id = b.spe_val_id
select a.* from water_spe_val a
where
1=1
<if test="speId != null "> and a.spe_id = #{speId}</if>
</where>
</select>
<select id="selectWaterSpeById" parameterType="Long" resultMap="WaterSpeResult">
......@@ -103,10 +97,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</update>
<insert id="batchInsertWaterSpeVal">
insert into water_spe_val(id,spe_id, spe, spe_val)
insert into water_spe_val(id,spe_id, spe, spe_val,cd,pp)
values
<foreach collection="list" item="item" separator=",">
(#{item.id},#{item.speId}, #{item.spe}, #{item.speVal})
(#{item.id},#{item.speId}, #{item.spe}, #{item.speVal}, #{item.cd}, #{item.pp})
</foreach>
</insert>
......
......@@ -17,14 +17,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="createUser" column="create_user" />
<result property="isOpen" column="is_open" />
<result property="openId" column="open_id" />
<result property="wxOpenid" column="wx_openid" />
</resultMap>
<sql id="selectWaterStationUserVo">
select a.id, name, age, gender, phone, id_num, station_id, a.create_time, a.create_user,b.is_open, open_id from water_station_user a left join water_station b on a.station_id=b.id
select a.id, name, age, gender, phone, id_num, station_id, a.create_time, a.create_user,b.is_open, open_id,wx_openid from water_station_user a left join water_station b on a.station_id=b.id
</sql>
<select id="selectWaterStationUserList" parameterType="WaterStationUser" resultMap="WaterStationUserResult">
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, su.open_id
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, su.open_id,su.wx_openid
from water_station_user su LEFT JOIN water_station s ON s.id = su.station_id
<where>
su.del_flag = '0'
......@@ -41,7 +42,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<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, su.open_id
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, su.open_id,su.wx_openid
from water_station_user su LEFT JOIN water_station s ON s.id = su.station_id
where su.id = #{id}
</select>
......@@ -51,6 +52,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where a.phone = #{phone}
and a.del_flag = '0'
</select>
<select id="selectUserByOpenId" resultType="com.qianhe.system.domain.WaterStationUser">
select a.*,s.is_open,s.station_name from water_station_user a
LEFT JOIN water_station s ON a.station_id = s.id
where wx_openid=#{openid}
</select>
<insert id="insertWaterStationUser" parameterType="WaterStationUser" useGeneratedKeys="true" keyProperty="id">
insert into water_station_user
......@@ -64,6 +70,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="createTime != null">create_time,</if>
<if test="createUser != null">create_user,</if>
<if test="openId != null">open_id,</if>
<if test="wxOpenid != null">wx_openid,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="name != null">#{name},</if>
......@@ -75,6 +82,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="createTime != null">#{createTime},</if>
<if test="createUser != null">#{createUser},</if>
<if test="openId != null">#{openId},</if>
<if test="wxOpenid != null">#{wxOpenid},</if>
</trim>
</insert>
......@@ -90,6 +98,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="createTime != null">create_time = #{createTime},</if>
<if test="createUser != null">create_user = #{createUser},</if>
<if test="openId != null">open_id = #{openId},</if>
<if test="wxOpenid != null">wx_openid = #{wxOpenid},</if>
</trim>
where id = #{id}
</update>
......@@ -104,4 +113,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{id}
</foreach>
</update>
<update id="updateWaterStationUserByphone">
update water_station_user
set wx_openid = #{wxOpenid}
where phone = #{phone}
</update>
</mapper>
......@@ -14,10 +14,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="createTime" column="create_time" />
<result property="status" column="status" />
<result property="openId" column="open_id" />
<result property="sfjz" column="sfjz" />
</resultMap>
<sql id="selectWaterUserVo">
select id, nick_name, phone_num, station_name, user_type, user_gender, create_time, status, open_id from water_user
select id, nick_name, phone_num, station_name, user_type, user_gender, create_time, status, open_id,sfjz from water_user
</sql>
<select id="selectWaterUserList" parameterType="WaterUser" resultMap="WaterUserResult">
......@@ -31,6 +32,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="userGender != null "> and user_gender = #{userGender}</if>
<if test="status != null "> and status = #{status}</if>
<if test="openId != null and openId != ''"> and open_id = #{openId}</if>
<if test="sfjz != null and sfjz != ''"> and sfjz = #{sfjz}</if>
</where>
order by create_time DESC
</select>
......@@ -44,6 +46,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectWaterUserVo"/>
where open_id = #{openId} and user_type = #{userType} and status != '1'
</select>
<select id="getUserSl" resultType="java.util.Map">
select count(1) zyh,
sum(case when date_format(create_time,'%Y-%m-%d')=date_format(now(),'%Y-%m-%d') then 1 else 0 end ) brxz,
sum(case when date_format(create_time,'%Y-%m')=date_format(now(),'%Y-%m') then 1 else 0 end ) byxz,
sum(case when date_format(create_time,'%Y')=date_format(now(),'%Y') then 1 else 0 end ) bnxz
from water_user where status='0'
</select>
<insert id="insertWaterUser" parameterType="WaterUser" useGeneratedKeys="true" keyProperty="id">
insert into water_user
......@@ -56,6 +65,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="createTime != null">create_time,</if>
<if test="status != null">status,</if>
<if test="openId != null">open_id,</if>
<if test="sfjz != null">sfjz,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="nickName != null">#{nickName},</if>
......@@ -66,6 +76,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="createTime != null">#{createTime},</if>
<if test="status != null">#{status},</if>
<if test="openId != null">#{openId},</if>
<if test="sfjz != null">#{sfjz},</if>
</trim>
</insert>
......@@ -80,6 +91,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="createTime != null">create_time = #{createTime},</if>
<if test="status != null">status = #{status},</if>
<if test="openId != null">open_id = #{openId},</if>
<if test="sfjz != null">sfjz = #{sfjz},</if>
</trim>
where id = #{id}
</update>
......@@ -93,6 +105,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="userGender != null">user_gender = #{userGender},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="status != null">status = #{status},</if>
<if test="sfjz != null">sfjz = #{sfjz},</if>
</trim>
where open_id = #{openId} and user_type = #{userType}
</update>
......
......@@ -70,6 +70,8 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
return isNull(objects) || (objects.length == 0);
}
/**
* * 判断一个对象数组是否非空
*
......
......@@ -127,15 +127,27 @@ public class ScheduleUtils
*/
public static boolean whiteList(String invokeTarget)
{
String packageName = StringUtils.substringBefore(invokeTarget, "(");
int count = StringUtils.countMatches(packageName, ".");
if (count > 1)
// String packageName = StringUtils.substringBefore(invokeTarget, "(");
// int count = StringUtils.countMatches(packageName, ".");
// if (count > 1)
// {
// return StringUtils.containsAnyIgnoreCase(invokeTarget, Constants.JOB_WHITELIST_STR);
// }
// Object obj = SpringUtils.getBean(StringUtils.split(invokeTarget, ".")[0]);
// String beanPackageName = obj.getClass().getPackage().getName();
// return StringUtils.containsAnyIgnoreCase(beanPackageName, Constants.JOB_WHITELIST_STR)
// && !StringUtils.containsAnyIgnoreCase(beanPackageName, Constants.JOB_ERROR_STR);
if (StringUtils.isEmpty(invokeTarget) )
{
return StringUtils.containsAnyIgnoreCase(invokeTarget, Constants.JOB_WHITELIST_STR);
return false;
}
Object obj = SpringUtils.getBean(StringUtils.split(invokeTarget, ".")[0]);
String beanPackageName = obj.getClass().getPackage().getName();
return StringUtils.containsAnyIgnoreCase(beanPackageName, Constants.JOB_WHITELIST_STR)
&& !StringUtils.containsAnyIgnoreCase(beanPackageName, Constants.JOB_ERROR_STR);
for (CharSequence testStr : Constants.JOB_WHITELIST_STR)
{
if (invokeTarget.equals(testStr))
{
return true;
}
}
return false;
}
}
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