代码缺陷问题处理
This commit is contained in:
parent
3785bdb3bb
commit
453b4426d8
@ -44,8 +44,8 @@ public class DistributionOrderExecute implements OrderStatusChangeEvent, EveryDa
|
||||
case CANCELLED: {
|
||||
//修改分销订单状态
|
||||
distributionOrderService.cancelOrder(orderMessage.getOrderSn());
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -69,6 +69,7 @@ public class PaymentExecute implements OrderStatusChangeEvent {
|
||||
case BANK_TRANSFER:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -50,6 +50,7 @@ public class WechatMessageExecute implements OrderStatusChangeEvent, TradeEvent
|
||||
} catch (Exception e) {
|
||||
log.error("微信消息发送失败", e);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ public class MemberMessageListener implements RocketMQListener<MessageExt> {
|
||||
e);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -22,6 +22,11 @@ public enum ResultCode {
|
||||
*/
|
||||
DEMO_SITE_EXCEPTION(400,"演示站点禁止使用"),
|
||||
|
||||
/**
|
||||
* 系统异常
|
||||
*/
|
||||
|
||||
WECHAT_CONNECT_NOT_EXIST(1001,"微信联合登录未配置"),
|
||||
/**
|
||||
* 分类
|
||||
*/
|
||||
|
@ -59,7 +59,15 @@ public class Base64DecodeMultipartFile implements MultipartFile {
|
||||
|
||||
@Override
|
||||
public void transferTo(File dest) throws IOException, IllegalStateException {
|
||||
new FileOutputStream(dest).write(imgContent);
|
||||
OutputStream stream = null;
|
||||
try {
|
||||
stream = new FileOutputStream(dest);
|
||||
stream.write(imgContent);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}finally {
|
||||
stream.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -57,13 +57,9 @@ public class HttpClientUtils {
|
||||
// 每个细化配置之最大并发数(不重要,在特殊场景很有用)
|
||||
static final int detailMaxPerRoute = 100;
|
||||
|
||||
private static CloseableHttpClient getHttpClient() {
|
||||
private synchronized static CloseableHttpClient getHttpClient() {
|
||||
if (null == httpClient) {
|
||||
synchronized (HttpClientUtils.class) {
|
||||
if (null == httpClient) {
|
||||
httpClient = init();
|
||||
}
|
||||
}
|
||||
httpClient = init();
|
||||
}
|
||||
return httpClient;
|
||||
}
|
||||
|
@ -1,48 +0,0 @@
|
||||
package cn.lili.modules.connect.service;
|
||||
|
||||
import cn.lili.common.utils.UrlBuilder;
|
||||
import cn.lili.modules.connect.config.ConnectAuthEnum;
|
||||
import cn.lili.modules.connect.entity.dto.AuthToken;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
||||
/**
|
||||
* 信任登录抽象类
|
||||
*
|
||||
* @author Chopper
|
||||
* @version v4.0
|
||||
* @Description:
|
||||
* @since 2020/12/4 10:57
|
||||
*/
|
||||
@Component
|
||||
public abstract class AbstractConnectLoginPlugin {
|
||||
|
||||
protected static String callBackUrl = "http://www.baidu.com";
|
||||
|
||||
/**
|
||||
* 获取授权登录的url
|
||||
*
|
||||
* @return URL
|
||||
*/
|
||||
protected abstract String getLoginUrl(String uuid);
|
||||
|
||||
/**
|
||||
* 回调地址
|
||||
*
|
||||
* @return 登录凭证
|
||||
*/
|
||||
protected String callbackUrl(String uuid, ConnectAuthEnum authInterface) {
|
||||
return UrlBuilder.fromBaseUrl(callBackUrl)
|
||||
.pathAppend("/buyer/connect/callback")
|
||||
.pathAppend("/" + authInterface.getName())
|
||||
.queryParam("uuid", uuid).build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 回调地址
|
||||
*
|
||||
* @return 登录凭证
|
||||
*/
|
||||
protected abstract AuthToken userInfo(String uuid);
|
||||
|
||||
}
|
@ -232,7 +232,7 @@ public class ConnectServiceImpl extends ServiceImpl<ConnectMapper, Connect> impl
|
||||
}
|
||||
|
||||
//如果没有会员,则根据手机号注册会员
|
||||
Member newMember = new Member("m" + phone,"111111",phone,params.getNickName(),params.getImage());
|
||||
Member newMember = new Member("m" + phone, "111111", phone, params.getNickName(), params.getImage());
|
||||
memberService.save(newMember);
|
||||
newMember = memberService.findByUsername(newMember.getUsername());
|
||||
bindMpMember(openId, unionId, newMember);
|
||||
@ -294,7 +294,7 @@ public class ConnectServiceImpl extends ServiceImpl<ConnectMapper, Connect> impl
|
||||
WechatConnectSetting wechatConnectSetting = JSONUtil.toBean(setting.getSettingValue(), WechatConnectSetting.class);
|
||||
|
||||
if (wechatConnectSetting == null) {
|
||||
return null;
|
||||
throw new ServiceException(ResultCode.WECHAT_CONNECT_NOT_EXIST);
|
||||
}
|
||||
//寻找对应对微信小程序登录配置
|
||||
for (WechatConnectSettingItem wechatConnectSettingItem : wechatConnectSetting.getWechatConnectSettingItems()) {
|
||||
@ -303,7 +303,7 @@ public class ConnectServiceImpl extends ServiceImpl<ConnectMapper, Connect> impl
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
throw new ServiceException(ResultCode.WECHAT_CONNECT_NOT_EXIST);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,82 +0,0 @@
|
||||
package cn.lili.modules.order.order.support;
|
||||
|
||||
|
||||
import cn.lili.modules.order.order.entity.enums.OrderOperateEnum;
|
||||
import cn.lili.modules.order.order.entity.enums.OrderStatusEnum;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 订单流程
|
||||
*
|
||||
* @author Chopper
|
||||
* @date 2020/11/17 7:40 下午
|
||||
*/
|
||||
public class OrderStep implements Cloneable {
|
||||
|
||||
|
||||
/**
|
||||
* 允许的操作
|
||||
*/
|
||||
private List<OrderOperateEnum> allowableOperate;
|
||||
|
||||
public OrderStep(OrderStatusEnum orderStatus, OrderOperateEnum... operates) {
|
||||
/**
|
||||
* 订单状态
|
||||
*/
|
||||
this.allowableOperate = new ArrayList<OrderOperateEnum>();
|
||||
for (OrderOperateEnum orderOperate : operates) {
|
||||
allowableOperate.add(orderOperate);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object clone() {
|
||||
OrderStep orderStep = null;
|
||||
try {
|
||||
orderStep = (OrderStep) super.clone();
|
||||
} catch (CloneNotSupportedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
ArrayList list = (ArrayList) allowableOperate;
|
||||
orderStep.allowableOperate = (List) list.clone();
|
||||
return orderStep;
|
||||
}
|
||||
|
||||
public List<OrderOperateEnum> getOperate() {
|
||||
return this.allowableOperate;
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws CloneNotSupportedException {
|
||||
OrderStep step1 = new OrderStep(OrderStatusEnum.UNPAID, OrderOperateEnum.CONFIRM, OrderOperateEnum.CANCEL);
|
||||
OrderStep step2 = (OrderStep) step1.clone();
|
||||
|
||||
step2.getOperate().remove(OrderOperateEnum.CONFIRM);
|
||||
step2.getOperate().add(OrderOperateEnum.PAY);
|
||||
|
||||
System.out.println(step1);
|
||||
System.out.println(step2);
|
||||
|
||||
step1.getOperate().forEach(orderOperateEnum -> {
|
||||
System.out.println(orderOperateEnum);
|
||||
});
|
||||
|
||||
System.out.println("--------");
|
||||
step2.getOperate().forEach(orderOperateEnum -> {
|
||||
System.out.println(orderOperateEnum);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
public boolean checkAllowable(OrderOperateEnum operate) {
|
||||
for (OrderOperateEnum orderOperate : allowableOperate) {
|
||||
if (operate.compareTo(orderOperate) == 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
@ -127,15 +127,4 @@ public class QrCodeKit {
|
||||
}
|
||||
return bool;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
String saveImgFilePath = "/Users//Documents/dev/IJPay/qrCode.png";
|
||||
boolean encode = encode("https://gitee.com/205/IJPay", BarcodeFormat.QR_CODE, 3,
|
||||
ErrorCorrectionLevel.H, "png", 200, 200, saveImgFilePath);
|
||||
if (encode) {
|
||||
Result result = decode(saveImgFilePath);
|
||||
String text = result.getText();
|
||||
System.out.println(text);
|
||||
}
|
||||
}
|
||||
}
|
@ -221,7 +221,7 @@ public class WechatPlugin implements Payment {
|
||||
//过期时间
|
||||
String timeExpire = DateTimeZoneUtil.dateToTimeZone(System.currentTimeMillis() + 1000 * 60 * 3);
|
||||
|
||||
String attach =URLEncoder.createDefault().encode(JSONUtil.toJsonStr(payParam), StandardCharsets.UTF_8);
|
||||
String attach = URLEncoder.createDefault().encode(JSONUtil.toJsonStr(payParam), StandardCharsets.UTF_8);
|
||||
|
||||
WechatPaymentSetting setting = wechatPaymentSetting();
|
||||
UnifiedOrderModel unifiedOrderModel = new UnifiedOrderModel()
|
||||
@ -355,7 +355,11 @@ public class WechatPlugin implements Payment {
|
||||
|
||||
//微信小程序,appid 需要单独获取,这里读取了联合登陆配置的appid ,实际场景小程序自动登录,所以这个appid是最为保险的做法
|
||||
//如果有2开需求,这里需要调整,修改这个appid的获取途径即可
|
||||
String appid = getWechatMPSetting().getAppId();
|
||||
WechatConnectSettingItem wechatConnectSettingItem = getWechatMPSetting();
|
||||
String appid = null;
|
||||
if (wechatConnectSettingItem != null) {
|
||||
appid = getWechatMPSetting().getAppId();
|
||||
}
|
||||
|
||||
String attach = URLEncoder.createDefault().encode(JSONUtil.toJsonStr(payParam), StandardCharsets.UTF_8);
|
||||
|
||||
@ -450,8 +454,8 @@ public class WechatPlugin implements Payment {
|
||||
JSONObject jsonObject = JSONUtil.parseObj(plainText);
|
||||
|
||||
String payParamStr = jsonObject.getStr("attach");
|
||||
String payParamJson = URLDecoder.decode(payParamStr,StandardCharsets.UTF_8);
|
||||
PayParam payParam = JSONUtil.toBean(payParamJson,PayParam.class);
|
||||
String payParamJson = URLDecoder.decode(payParamStr, StandardCharsets.UTF_8);
|
||||
PayParam payParam = JSONUtil.toBean(payParamJson, PayParam.class);
|
||||
|
||||
|
||||
String tradeNo = jsonObject.getStr("transaction_id");
|
||||
@ -654,7 +658,7 @@ public class WechatPlugin implements Payment {
|
||||
WechatConnectSetting wechatConnectSetting = JSONUtil.toBean(setting.getSettingValue(), WechatConnectSetting.class);
|
||||
|
||||
if (wechatConnectSetting == null) {
|
||||
return null;
|
||||
throw new ServiceException(ResultCode.WECHAT_CONNECT_NOT_EXIST);
|
||||
}
|
||||
//寻找对应对微信小程序登录配置
|
||||
for (WechatConnectSettingItem wechatConnectSettingItem : wechatConnectSetting.getWechatConnectSettingItems()) {
|
||||
@ -663,6 +667,6 @@ public class WechatPlugin implements Payment {
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
throw new ServiceException(ResultCode.WECHAT_CONNECT_NOT_EXIST);
|
||||
}
|
||||
}
|
||||
|
@ -70,13 +70,16 @@ public class PromotionServiceImpl implements PromotionService {
|
||||
log.info("更新促销活动状态:{}", promotionMessage);
|
||||
boolean result = false;
|
||||
switch (promotionTypeEnum) {
|
||||
//满减
|
||||
case FULL_DISCOUNT:
|
||||
result = this.updateFullDiscount(promotionMessage, esPromotionKey, promotionTypeEnum);
|
||||
break;
|
||||
//秒杀
|
||||
case SECKILL:
|
||||
SeckillVO seckill = this.mongoTemplate.findById(promotionMessage.getPromotionId(), SeckillVO.class);
|
||||
if (seckill == null) {
|
||||
this.throwPromotionException(promotionTypeEnum, promotionMessage.getPromotionId(), promotionMessage.getPromotionStatus());
|
||||
break;
|
||||
}
|
||||
seckill.setPromotionStatus(promotionMessage.getPromotionStatus());
|
||||
result = this.seckillService.update(promotionMessage.updateWrapper());
|
||||
@ -111,10 +114,12 @@ public class PromotionServiceImpl implements PromotionService {
|
||||
}
|
||||
this.mongoTemplate.save(seckill);
|
||||
break;
|
||||
//拼团
|
||||
case PINTUAN:
|
||||
PintuanVO pintuanVO = this.mongoTemplate.findById(promotionMessage.getPromotionId(), PintuanVO.class);
|
||||
if (pintuanVO == null) {
|
||||
this.throwPromotionException(promotionTypeEnum, promotionMessage.getPromotionId(), promotionMessage.getPromotionStatus());
|
||||
break;
|
||||
}
|
||||
pintuanVO.setPromotionStatus(promotionMessage.getPromotionStatus());
|
||||
result = this.pintuanService.update(promotionMessage.updateWrapper());
|
||||
@ -127,13 +132,16 @@ public class PromotionServiceImpl implements PromotionService {
|
||||
}
|
||||
this.mongoTemplate.save(pintuanVO);
|
||||
break;
|
||||
//优惠券
|
||||
case COUPON:
|
||||
result = this.updateCoupon(promotionMessage, esPromotionKey, promotionTypeEnum);
|
||||
break;
|
||||
//积分商品
|
||||
case POINTS_GOODS:
|
||||
PointsGoodsVO pointsGoodsVO = this.mongoTemplate.findById(promotionMessage.getPromotionId(), PointsGoodsVO.class);
|
||||
if (pointsGoodsVO == null) {
|
||||
this.throwPromotionException(promotionTypeEnum, promotionMessage.getPromotionId(), promotionMessage.getPromotionStatus());
|
||||
break;
|
||||
}
|
||||
pointsGoodsVO.setPromotionStatus(promotionMessage.getPromotionStatus());
|
||||
result = this.pointsGoodsService.update(promotionMessage.updateWrapper());
|
||||
@ -271,11 +279,15 @@ public class PromotionServiceImpl implements PromotionService {
|
||||
|
||||
private boolean updateFullDiscount(PromotionMessage promotionMessage, String esPromotionKey, PromotionTypeEnum promotionTypeEnum) {
|
||||
boolean result;
|
||||
//从mongo中获取促销备份
|
||||
FullDiscountVO fullDiscountVO = mongoTemplate.findById(promotionMessage.getPromotionId(), FullDiscountVO.class);
|
||||
if (fullDiscountVO == null) {
|
||||
this.throwPromotionException(promotionTypeEnum, promotionMessage.getPromotionId(), promotionMessage.getPromotionStatus());
|
||||
return false;
|
||||
}
|
||||
//写入促销状态
|
||||
fullDiscountVO.setPromotionStatus(promotionMessage.getPromotionStatus());
|
||||
//修改促销数据
|
||||
result = this.fullDiscountService.update(promotionMessage.updateWrapper());
|
||||
// clone一个活动信息,用于存放与索引中
|
||||
FullDiscountVO clone = ObjectUtil.clone(fullDiscountVO);
|
||||
@ -300,8 +312,10 @@ public class PromotionServiceImpl implements PromotionService {
|
||||
CouponVO couponVO = this.mongoTemplate.findById(promotionMessage.getPromotionId(), CouponVO.class);
|
||||
if (couponVO == null) {
|
||||
this.throwPromotionException(promotionTypeEnum, promotionMessage.getPromotionId(), promotionMessage.getPromotionStatus());
|
||||
return false;
|
||||
}
|
||||
couponVO.setPromotionStatus(promotionMessage.getPromotionStatus());
|
||||
|
||||
result = this.couponService.update(promotionMessage.updateWrapper());
|
||||
|
||||
LambdaUpdateWrapper<MemberCoupon> updateWrapper = new LambdaUpdateWrapper<MemberCoupon>().eq(MemberCoupon::getCouponId, couponVO.getId()).set(MemberCoupon::getMemberCouponStatus, MemberCouponStatusEnum.EXPIRE.name());
|
||||
|
@ -47,15 +47,18 @@ public enum DadaOrderStatusEnum {
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
//获取配送模版
|
||||
public static String getText(Integer status) {
|
||||
if (status != null) {
|
||||
//如果空,则直接返回
|
||||
if (status == null) {
|
||||
return null;
|
||||
}
|
||||
//对状态枚举值进行处理
|
||||
for (DadaOrderStatusEnum dadaOrderStatusEnum : DadaOrderStatusEnum.values()) {
|
||||
if (status.equals(dadaOrderStatusEnum.getStatus())) {
|
||||
return dadaOrderStatusEnum.getText();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
return WAIT_RECEIVING.getText();
|
||||
}
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ public class SensitiveWordsFilter implements Serializable, ApplicationRunner {
|
||||
* @param word
|
||||
* @return
|
||||
*/
|
||||
public static boolean remove(String word) {
|
||||
public static void remove(String word) {
|
||||
|
||||
StringPointer sp = new StringPointer(word.trim());
|
||||
// 计算头两个字符的hash
|
||||
@ -116,12 +116,9 @@ public class SensitiveWordsFilter implements Serializable, ApplicationRunner {
|
||||
// 匹配节点
|
||||
if (node.headTwoCharMix == mix) {
|
||||
node.words.remove(sp);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -144,7 +144,7 @@ public class AdminUserManagerController {
|
||||
public ResultMessage<Object> register(AdminUserDTO adminUser,
|
||||
@RequestParam(required = false) List<String> roles) {
|
||||
try {
|
||||
if (roles != null & roles.size() >= 10) {
|
||||
if (roles != null && roles.size() >= 10) {
|
||||
return ResultUtil.error(ResultCode.PERMISSION_BEYOND_TEN);
|
||||
}
|
||||
adminUserService.saveAdminUser(adminUser, roles);
|
||||
|
Loading…
x
Reference in New Issue
Block a user