Commit 57510bc1 by jiang'yun

修改问题

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