bug--代码规范优化,升级fastjson1.2.73

This commit is contained in:
taochengbo
2020-08-29 16:17:15 +08:00
parent 574c7219ac
commit 0f05897962
64 changed files with 727 additions and 275 deletions

View File

@ -62,17 +62,17 @@ public class WxMpConfiguration {
MenuHandler menuHandler,MsgHandler msgHandler,UnsubscribeHandler unsubscribeHandler,
SubscribeHandler subscribeHandler,ScanHandler scanHandler,
RedisUtils redisUtils){
this.logHandler = logHandler;
this.nullHandler = nullHandler;
this.kfSessionHandler = kfSessionHandler;
this.storeCheckNotifyHandler = storeCheckNotifyHandler;
this.locationHandler = locationHandler;
this.menuHandler = menuHandler;
this.msgHandler = msgHandler;
this.unsubscribeHandler = unsubscribeHandler;
this.subscribeHandler = subscribeHandler;
this.scanHandler = scanHandler;
this.redisUtils = redisUtils;
WxMpConfiguration.logHandler = logHandler;
WxMpConfiguration.nullHandler = nullHandler;
WxMpConfiguration.kfSessionHandler = kfSessionHandler;
WxMpConfiguration.storeCheckNotifyHandler = storeCheckNotifyHandler;
WxMpConfiguration.locationHandler = locationHandler;
WxMpConfiguration.menuHandler = menuHandler;
WxMpConfiguration.msgHandler = msgHandler;
WxMpConfiguration.unsubscribeHandler = unsubscribeHandler;
WxMpConfiguration.subscribeHandler = subscribeHandler;
WxMpConfiguration.scanHandler = scanHandler;
WxMpConfiguration.redisUtils = redisUtils;
}

View File

@ -34,7 +34,7 @@ public class WxPayConfiguration {
@Autowired
public WxPayConfiguration(RedisUtils redisUtils) {
this.redisUtils = redisUtils;
WxPayConfiguration.redisUtils = redisUtils;
}
/**

View File

@ -4,6 +4,7 @@ import cn.binarywang.wx.miniapp.api.WxMaService;
import cn.binarywang.wx.miniapp.bean.WxMaSubscribeMessage;
import cn.hutool.core.util.StrUtil;
import co.yixiang.config.SubscribeProperties;
import co.yixiang.constant.ShopConstants;
import co.yixiang.modules.user.domain.YxUser;
import co.yixiang.modules.user.service.YxUserService;
import co.yixiang.modules.user.service.dto.WechatUserDto;
@ -42,14 +43,16 @@ public class WeiXinSubscribeService {
public void rechargeSuccessNotice(String time,String price,Long uid){
String openid = this.getUserOpenid(uid);
if(StrUtil.isBlank(openid)) return;
if(StrUtil.isBlank(openid)) {
return;
}
Map<String,String> map = new HashMap<>();
map.put("first","您的账户金币发生变动,详情如下:");
map.put("keyword1","充值");
map.put("keyword2",time);
map.put("keyword3",price);
map.put("remark","yshop为你服务");
map.put("remark", ShopConstants.YSHOP_WECHAT_PUSH_REMARK);
String tempId = this.getTempId(WechatTempateEnum.RECHARGE_SUCCESS.getValue());
this.sendSubscribeMsg( openid, tempId, "/user/account",map);
}
@ -64,7 +67,9 @@ public class WeiXinSubscribeService {
public void paySuccessNotice(String orderId,String price,Long uid){
String openid = this.getUserOpenid(uid);
if(StrUtil.isBlank(openid)) return;
if(StrUtil.isBlank(openid)) {
return;
}
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss");
Map<String,String> map = new HashMap<>();
map.put("amount1",price);
@ -87,14 +92,17 @@ public class WeiXinSubscribeService {
String openid = this.getUserOpenid(uid);
if(StrUtil.isBlank(openid)) return;
if(StrUtil.isBlank(openid)) {
return;
}
Map<String,String> map = new HashMap<>();
map.put("first","您的订单退款申请被通过,钱款将很快还至您的支付账户。");
map.put("keyword1",orderId);//订单号
//订单号
map.put("keyword1",orderId);
map.put("keyword2",price);
map.put("keyword3", time);
map.put("remark","yshop为你服务");
map.put("remark",ShopConstants.YSHOP_WECHAT_PUSH_REMARK);
String tempId = this.getTempId(WechatTempateEnum.REFUND_SUCCESS.getValue());
this.sendSubscribeMsg( openid,tempId, "/order/detail/"+orderId,map);
}
@ -111,14 +119,16 @@ public class WeiXinSubscribeService {
String openid = this.getUserOpenid(uid);
if(StrUtil.isEmpty(openid)) return;
if(StrUtil.isEmpty(openid)) {
return;
}
Map<String,String> map = new HashMap<>();
map.put("first","亲,宝贝已经启程了,好想快点来到你身边。");
map.put("keyword2",deliveryName);
map.put("keyword1",orderId);
map.put("keyword3",deliveryId);
map.put("remark","yshop为你服务");
map.put("remark",ShopConstants.YSHOP_WECHAT_PUSH_REMARK);
String tempId = this.getTempId(WechatTempateEnum.DELIVERY_SUCCESS.getValue());
this.sendSubscribeMsg( openid,tempId, "/order/detail/"+orderId,map);
}
@ -170,11 +180,17 @@ public class WeiXinSubscribeService {
*/
private String getUserOpenid(Long uid){
YxUser yxUser = userService.getById(uid);
if(yxUser == null) return "";
if(yxUser == null) {
return "";
}
WechatUserDto wechatUserDto = yxUser.getWxProfile();
if(wechatUserDto == null) return "";
if(StrUtil.isBlank(wechatUserDto.getRoutineOpenid())) return "";
if(wechatUserDto == null) {
return "";
}
if(StrUtil.isBlank(wechatUserDto.getRoutineOpenid())) {
return "";
}
return wechatUserDto.getRoutineOpenid();
}

View File

@ -72,21 +72,29 @@ public class WeixinPayService {
long uid = 0;
int payPrice = 0;
BigDecimal bigDecimal = new BigDecimal(100);
if(BillDetailEnum.TYPE_3.getValue().equals(attach)){ //普通支付
//普通支付
if(BillDetailEnum.TYPE_3.getValue().equals(attach)){
YxStoreOrderQueryVo orderInfo = storeOrderService.getOrderInfo(orderId,null);
if(ObjectUtil.isNull(orderInfo)) throw new YshopException("订单不存在");
if(ObjectUtil.isNull(orderInfo)) {
throw new YshopException("订单不存在");
}
if(orderInfo.getPaid().equals(OrderInfoEnum.PAY_STATUS_1.getValue())) {
throw new YshopException("该订单已支付");
}
if(orderInfo.getPayPrice().compareTo(BigDecimal.ZERO) <= 0) throw new YshopException("该支付无需支付");
if(orderInfo.getPayPrice().compareTo(BigDecimal.ZERO) <= 0) {
throw new YshopException("该支付无需支付");
}
uid = orderInfo.getUid().intValue();
payPrice = bigDecimal.multiply(orderInfo.getPayPrice()).intValue();//计算分
//计算分
payPrice = bigDecimal.multiply(orderInfo.getPayPrice()).intValue();
}else{ //充值
YxUserRecharge userRecharge = userRechargeService.getOne(Wrappers.<YxUserRecharge>lambdaQuery()
.eq(YxUserRecharge::getOrderId,orderId));
if(userRecharge == null) throw new BusinessException("充值订单不存在");
if(userRecharge == null) {
throw new BusinessException("充值订单不存在");
}
if(userRecharge.getPaid().equals(OrderInfoEnum.PAY_STATUS_1.getValue())) {
throw new YshopException("该订单已支付");
@ -97,7 +105,9 @@ public class WeixinPayService {
YxUser yxUser = userService.getById(uid);
if(yxUser == null) throw new YshopException("用户错误");
if(yxUser == null) {
throw new YshopException("用户错误");
}
WechatUserDto wechatUserDto = yxUser.getWxProfile();
@ -151,15 +161,18 @@ public class WeixinPayService {
public void refundOrder(String orderId, Integer totalFee) {
YxStoreOrderQueryVo orderInfo = storeOrderService.getOrderInfo(orderId,null);
if(PayTypeEnum.YUE.getValue().equals(orderInfo.getPayType())) return;
if(PayTypeEnum.YUE.getValue().equals(orderInfo.getPayType())) {
return;
}
WxPayService wxPayService = WxPayConfiguration.getPayService(PayMethodEnum.WECHAT);
WxPayRefundRequest wxPayRefundRequest = new WxPayRefundRequest();
wxPayRefundRequest.setTotalFee(totalFee);//订单总金额
//订单总金额
wxPayRefundRequest.setTotalFee(totalFee);
wxPayRefundRequest.setOutTradeNo(orderId);
wxPayRefundRequest.setOutRefundNo(orderId);
wxPayRefundRequest.setRefundFee(totalFee);//退款金额
//退款金额
wxPayRefundRequest.setRefundFee(totalFee);
wxPayRefundRequest.setNotifyUrl(this.getApiUrl() + "/api/notify/refund");
try {

View File

@ -10,6 +10,7 @@ package co.yixiang.mp.service;
import cn.hutool.core.util.StrUtil;
import co.yixiang.api.YshopException;
import co.yixiang.constant.ShopConstants;
import co.yixiang.modules.user.domain.YxUser;
import co.yixiang.modules.user.service.YxUserService;
import co.yixiang.modules.user.service.dto.WechatUserDto;
@ -57,14 +58,16 @@ public class WeixinTemplateService {
public void rechargeSuccessNotice(String time,String price,Long uid){
String openid = this.getUserOpenid(uid);
if(StrUtil.isBlank(openid)) return;
if(StrUtil.isBlank(openid)) {
return;
}
Map<String,String> map = new HashMap<>();
map.put("first","您的账户金币发生变动,详情如下:");
map.put("keyword1","充值");
map.put("keyword2",time);
map.put("keyword3",price);
map.put("remark","yshop为你服务");
map.put("remark", ShopConstants.YSHOP_WECHAT_PUSH_REMARK);
String tempId = this.getTempId(WechatTempateEnum.RECHARGE_SUCCESS.getValue());
this.sendWxMpTemplateMessage( openid, tempId, this.getSiteUrl()+"/user/account",map);
}
@ -80,13 +83,16 @@ public class WeixinTemplateService {
String openid = this.getUserOpenid(uid);
if(StrUtil.isBlank(openid)) return;
if(StrUtil.isBlank(openid)) {
return;
}
Map<String,String> map = new HashMap<>();
map.put("first","您的订单已支付成功,我们会尽快为您发货。");
map.put("keyword1",orderId);//订单号
//订单号
map.put("keyword1",orderId);
map.put("keyword2",price);
map.put("remark","yshop为你服务");
map.put("remark",ShopConstants.YSHOP_WECHAT_PUSH_REMARK);
String tempId = this.getTempId(WechatTempateEnum.PAY_SUCCESS.getValue());
this.sendWxMpTemplateMessage( openid,tempId, this.getSiteUrl()+"/order/detail/"+orderId,map);
}
@ -102,14 +108,17 @@ public class WeixinTemplateService {
String openid = this.getUserOpenid(uid);
if(StrUtil.isBlank(openid)) return;
if(StrUtil.isBlank(openid)) {
return;
}
Map<String,String> map = new HashMap<>();
map.put("first","您的订单退款申请被通过,钱款将很快还至您的支付账户。");
map.put("keyword1",orderId);//订单号
//订单号
map.put("keyword1",orderId);
map.put("keyword2",price);
map.put("keyword3", time);
map.put("remark","yshop为你服务");
map.put("remark",ShopConstants.YSHOP_WECHAT_PUSH_REMARK);
String tempId = this.getTempId(WechatTempateEnum.REFUND_SUCCESS.getValue());
this.sendWxMpTemplateMessage( openid,tempId, this.getSiteUrl()+"/order/detail/"+orderId,map);
}
@ -126,14 +135,16 @@ public class WeixinTemplateService {
String openid = this.getUserOpenid(uid);
if(StrUtil.isEmpty(openid)) return;
if(StrUtil.isEmpty(openid)) {
return;
}
Map<String,String> map = new HashMap<>();
map.put("first","亲,宝贝已经启程了,好想快点来到你身边。");
map.put("keyword2",deliveryName);
map.put("keyword1",orderId);
map.put("keyword3",deliveryId);
map.put("remark","yshop为你服务");
map.put("remark",ShopConstants.YSHOP_WECHAT_PUSH_REMARK);
String tempId = this.getTempId(WechatTempateEnum.DELIVERY_SUCCESS.getValue());
this.sendWxMpTemplateMessage( openid,tempId, this.getSiteUrl()+"/order/detail/"+orderId,map);
}
@ -173,7 +184,9 @@ public class WeixinTemplateService {
YxWechatTemplate yxWechatTemplate = yxWechatTemplateService.lambdaQuery()
.eq(YxWechatTemplate::getTempkey,key)
.one();
if (yxWechatTemplate == null) throw new YshopException("请后台配置key:" + key + "模板消息id");
if (yxWechatTemplate == null) {
throw new YshopException("请后台配置key:" + key + "模板消息id");
}
return yxWechatTemplate.getTempid();
}
@ -197,11 +210,17 @@ public class WeixinTemplateService {
*/
private String getUserOpenid(Long uid){
YxUser yxUser = userService.getById(uid);
if(yxUser == null) return "";
if(yxUser == null) {
return "";
}
WechatUserDto wechatUserDto = yxUser.getWxProfile();
if(wechatUserDto == null) return "";
if(StrUtil.isBlank(wechatUserDto.getOpenid())) return "";
if(wechatUserDto == null) {
return "";
}
if(StrUtil.isBlank(wechatUserDto.getOpenid())) {
return "";
}
return wechatUserDto.getOpenid();
}