Merge branch 'master' of gitee.com:beijing_hongye_huicheng/lilishop
This commit is contained in:
commit
ecfe856fa7
@ -1,6 +1,5 @@
|
||||
package cn.lili.common.utils;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
|
||||
import java.beans.BeanInfo;
|
||||
@ -10,7 +9,6 @@ import java.lang.reflect.Method;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.regex.Matcher;
|
||||
@ -49,99 +47,6 @@ public class StringUtils extends StrUtil {
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 将object转为数字
|
||||
*
|
||||
* @param obj 需要转object的对象
|
||||
* @param checked 如果为true格式不正确抛出异常
|
||||
* @return
|
||||
*/
|
||||
public static int toInt(Object obj, boolean checked) {
|
||||
int value = 0;
|
||||
if (obj == null) {
|
||||
return 0;
|
||||
}
|
||||
try {
|
||||
value = Convert.toInt(obj.toString());
|
||||
} catch (Exception ex) {
|
||||
if (checked) {
|
||||
throw new RuntimeException("整型数字格式不正确");
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将一个字串转为long,如果无空,则返回默认值
|
||||
*
|
||||
* @param str 要转换的数字字串
|
||||
* @param defaultValue 默认值
|
||||
* @return
|
||||
*/
|
||||
public static Long toLong(String str, Long defaultValue) {
|
||||
Long value = defaultValue;
|
||||
if (str == null || "".equals(str)) {
|
||||
return defaultValue;
|
||||
}
|
||||
try {
|
||||
value = Long.parseLong(str);
|
||||
} catch (Exception ex) {
|
||||
return defaultValue;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将一个object转为double 如果object 为 null 则返回0;
|
||||
*
|
||||
* @param obj 需要转成Double的对象
|
||||
* @param checked 如果为true格式不正确抛出异常
|
||||
* @return
|
||||
*/
|
||||
public static Double toDouble(Object obj, boolean checked) {
|
||||
Double value = 0d;
|
||||
if (obj == null) {
|
||||
if (checked) {
|
||||
throw new RuntimeException("数字格式不正确");
|
||||
} else {
|
||||
return 0D;
|
||||
}
|
||||
}
|
||||
try {
|
||||
value = Double.valueOf(obj.toString());
|
||||
} catch (Exception ex) {
|
||||
if (checked) {
|
||||
throw new RuntimeException("数字格式不正确");
|
||||
} else {
|
||||
return 0D;
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将一个字串转为Double,如果无空,则返回默认值
|
||||
*
|
||||
* @param str 要转换的数字字串
|
||||
* @param defaultValue 默认值
|
||||
* @return
|
||||
*/
|
||||
public static Double toDouble(String str, Double defaultValue) {
|
||||
Double value = defaultValue;
|
||||
if (str == null || "".equals(str)) {
|
||||
return 0d;
|
||||
}
|
||||
try {
|
||||
value = Double.valueOf(str);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
value = defaultValue;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取随机数
|
||||
*
|
||||
@ -158,18 +63,6 @@ public class StringUtils extends StrUtil {
|
||||
return sRand;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 判断一个数组是否为空,并且长度大于0
|
||||
*
|
||||
* @param list
|
||||
* @return true 不空/false 空
|
||||
*/
|
||||
public static boolean isNotEmpty(List list) {
|
||||
|
||||
return list != null && list.size() > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 切个字符串,如果超出长度则切割
|
||||
*
|
||||
|
@ -1,11 +1,14 @@
|
||||
package cn.lili.modules.goods.serviceimpl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.json.JSONArray;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import cn.lili.common.utils.PageUtil;
|
||||
import cn.lili.common.utils.StringUtils;
|
||||
import cn.lili.modules.goods.entity.dos.*;
|
||||
import cn.lili.modules.goods.entity.dos.Category;
|
||||
import cn.lili.modules.goods.entity.dos.DraftGoods;
|
||||
import cn.lili.modules.goods.entity.dos.GoodsGallery;
|
||||
import cn.lili.modules.goods.entity.dos.GoodsSku;
|
||||
import cn.lili.modules.goods.entity.dto.DraftGoodsDTO;
|
||||
import cn.lili.modules.goods.entity.dto.DraftGoodsSearchParams;
|
||||
import cn.lili.modules.goods.entity.dto.GoodsParamsDTO;
|
||||
@ -135,16 +138,16 @@ public class DraftGoodsServiceImpl extends ServiceImpl<DraftGoodsMapper, DraftGo
|
||||
sku.setSn(m.getValue() != null ? m.getValue().toString() : "");
|
||||
break;
|
||||
case "cost":
|
||||
sku.setCost(StringUtils.toDouble(m.getValue(), false));
|
||||
sku.setCost(Convert.toDouble(m.getValue()));
|
||||
break;
|
||||
case "price":
|
||||
sku.setPrice(StringUtils.toDouble(m.getValue(), false));
|
||||
sku.setPrice(Convert.toDouble(m.getValue()));
|
||||
break;
|
||||
case "quantity":
|
||||
sku.setQuantity(StringUtils.toInt(m.getValue(), false));
|
||||
sku.setQuantity(Convert.toInt(m.getValue()));
|
||||
break;
|
||||
case "weight":
|
||||
sku.setWeight(StringUtils.toDouble(m.getValue(), false));
|
||||
sku.setWeight(Convert.toDouble(m.getValue()));
|
||||
break;
|
||||
default:
|
||||
specMap.put(m.getKey(), m.getValue());
|
||||
|
@ -2,6 +2,7 @@ package cn.lili.modules.goods.serviceimpl;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import cn.lili.common.cache.Cache;
|
||||
@ -11,7 +12,6 @@ import cn.lili.common.rocketmq.RocketmqSendCallbackBuilder;
|
||||
import cn.lili.common.rocketmq.tags.GoodsTagsEnum;
|
||||
import cn.lili.common.security.context.UserContext;
|
||||
import cn.lili.common.utils.PageUtil;
|
||||
import cn.lili.common.utils.StringUtils;
|
||||
import cn.lili.config.rocketmq.RocketmqCustomProperties;
|
||||
import cn.lili.modules.goods.entity.dos.Goods;
|
||||
import cn.lili.modules.goods.entity.dos.GoodsSku;
|
||||
@ -644,7 +644,7 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
||||
}
|
||||
//设置规格商品缩略图
|
||||
//如果规格没有图片,则用商品图片复盖。有则增加规格图片,放在商品图片集合之前
|
||||
if (spec.getValue() != null && StringUtils.isNotEmpty(spec.getValue().toString())) {
|
||||
if (spec.getValue() != null && StrUtil.isNotEmpty(spec.getValue().toString())) {
|
||||
thumbnail = goodsGalleryService.getGoodsGallery(images.get(0).get("url")).getThumbnail();
|
||||
small = goodsGalleryService.getGoodsGallery(images.get(0).get("url")).getSmall();
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package cn.lili.modules.order.order.entity.dto;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.lili.common.security.context.UserContext;
|
||||
import cn.lili.common.security.enums.UserEnums;
|
||||
import cn.lili.common.utils.DateUtil;
|
||||
@ -97,60 +98,56 @@ public class OrderSearchParams extends PageVO {
|
||||
QueryWrapper<T> wrapper = new QueryWrapper<>();
|
||||
|
||||
//关键字查询
|
||||
if (StringUtils.isNotEmpty(keywords)) {
|
||||
if (StrUtil.isNotEmpty(keywords)) {
|
||||
wrapper.like("o.sn", keywords);
|
||||
wrapper.like("oi.goods_name", keywords);
|
||||
}
|
||||
//按卖家查询
|
||||
wrapper.eq(StringUtils.equals(UserContext.getCurrentUser().getRole().name(), UserEnums.STORE.name()), "o.store_id", UserContext.getCurrentUser().getStoreId());
|
||||
wrapper.eq(StrUtil.equals(UserContext.getCurrentUser().getRole().name(), UserEnums.STORE.name()), "o.store_id", UserContext.getCurrentUser().getStoreId());
|
||||
|
||||
//店铺查询
|
||||
wrapper.eq(StringUtils.equals(UserContext.getCurrentUser().getRole().name(), UserEnums.MANAGER.name())
|
||||
wrapper.eq(StrUtil.equals(UserContext.getCurrentUser().getRole().name(), UserEnums.MANAGER.name())
|
||||
&& StringUtils.isNotEmpty(storeId), "o.store_id", storeId);
|
||||
|
||||
//按买家查询
|
||||
wrapper.eq(StringUtils.equals(UserContext.getCurrentUser().getRole().name(), UserEnums.MEMBER.name()), "o.member_id", UserContext.getCurrentUser().getId());
|
||||
wrapper.eq(StrUtil.equals(UserContext.getCurrentUser().getRole().name(), UserEnums.MEMBER.name()), "o.member_id", UserContext.getCurrentUser().getId());
|
||||
|
||||
//按照买家查询
|
||||
wrapper.like(StringUtils.isNotEmpty(memberId), "o.member_id", memberId);
|
||||
wrapper.like(StrUtil.isNotEmpty(memberId), "o.member_id", memberId);
|
||||
|
||||
//按订单编号查询
|
||||
wrapper.like(StringUtils.isNotEmpty(orderSn), "o.sn", orderSn);
|
||||
wrapper.like(StrUtil.isNotEmpty(orderSn), "o.sn", orderSn);
|
||||
|
||||
//按时间查询
|
||||
wrapper.ge(startDate != null, "o.create_time", startDate);
|
||||
|
||||
wrapper.le(endDate != null, "o.create_time", DateUtil.endOfDate(endDate));
|
||||
//按购买人用户名
|
||||
wrapper.like(StringUtils.isNotEmpty(buyerName), "o.member_name", buyerName);
|
||||
wrapper.like(StrUtil.isNotEmpty(buyerName), "o.member_name", buyerName);
|
||||
|
||||
//按订单类型
|
||||
if (StringUtils.isNotEmpty(orderType)) {
|
||||
wrapper.and(queryWrapper -> queryWrapper.eq("o.order_type", orderType).or()
|
||||
.eq("o.order_promotion_type", orderType));
|
||||
}
|
||||
|
||||
wrapper.eq(StrUtil.isNotEmpty(orderType), "o.order_type", orderType);
|
||||
|
||||
//物流查询
|
||||
wrapper.like(StringUtils.isNotEmpty(shipName), "o.consignee_name", shipName);
|
||||
wrapper.like(StrUtil.isNotEmpty(shipName), "o.consignee_name", shipName);
|
||||
|
||||
//按商品名称查询
|
||||
wrapper.like(StringUtils.isNotEmpty(goodsName), "oi.goods_name", goodsName);
|
||||
wrapper.like(StrUtil.isNotEmpty(goodsName), "oi.goods_name", goodsName);
|
||||
|
||||
//付款方式
|
||||
wrapper.like(StringUtils.isNotEmpty(paymentType), "o.payment_type", paymentType);
|
||||
wrapper.like(StrUtil.isNotEmpty(paymentType), "o.payment_type", paymentType);
|
||||
|
||||
//按支付方式
|
||||
wrapper.eq(StringUtils.isNotEmpty(paymentMethod), "o.payment_method", paymentMethod);
|
||||
wrapper.eq(StrUtil.isNotEmpty(paymentMethod), "o.payment_method", paymentMethod);
|
||||
|
||||
//订单状态
|
||||
wrapper.eq(StringUtils.isNotEmpty(orderStatus), "o.order_status", orderStatus);
|
||||
wrapper.eq(StrUtil.isNotEmpty(orderStatus), "o.order_status", orderStatus);
|
||||
|
||||
//付款状态
|
||||
wrapper.eq(StringUtils.isNotEmpty(payStatus), "o.pay_status", payStatus);
|
||||
wrapper.eq(StrUtil.isNotEmpty(payStatus), "o.pay_status", payStatus);
|
||||
|
||||
//订单来源
|
||||
wrapper.like(StringUtils.isNotEmpty(clientType), "o.client_type", clientType);
|
||||
wrapper.like(StrUtil.isNotEmpty(clientType), "o.client_type", clientType);
|
||||
|
||||
|
||||
//按标签查询
|
||||
|
@ -4,7 +4,6 @@ import cn.lili.common.cache.Cache;
|
||||
import cn.lili.common.cache.CachePrefix;
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.exception.ServiceException;
|
||||
import cn.lili.common.utils.StringUtils;
|
||||
import cn.lili.modules.page.entity.dos.Article;
|
||||
import cn.lili.modules.page.entity.dos.ArticleCategory;
|
||||
import cn.lili.modules.page.entity.enums.ArticleCategoryEnum;
|
||||
@ -54,12 +53,6 @@ public class ArticleCategoryServiceImpl extends ServiceImpl<ArticleCategoryMappe
|
||||
|
||||
@Override
|
||||
public ArticleCategory saveArticleCategory(ArticleCategory articleCategory) {
|
||||
//不能添加重复的分类名称
|
||||
List<ArticleCategory> list = this.list(
|
||||
new LambdaQueryWrapper<ArticleCategory>().eq(ArticleCategory::getArticleCategoryName, articleCategory.getArticleCategoryName()));
|
||||
if (StringUtils.isNotEmpty(list)) {
|
||||
throw new ServiceException(ResultCode.ARTICLE_CATEGORY_NAME_EXIST);
|
||||
}
|
||||
//非顶级分类
|
||||
if (articleCategory.getParentId() != null && !parentId.equals(articleCategory.getParentId())) {
|
||||
ArticleCategory parent = this.getById(articleCategory.getParentId());
|
||||
|
@ -56,7 +56,7 @@ public class AdminUserServiceImpl extends ServiceImpl<AdminUserMapper, AdminUser
|
||||
/**
|
||||
* 角色长度
|
||||
*/
|
||||
private int rolesMaxSize =10;
|
||||
private int rolesMaxSize = 10;
|
||||
|
||||
@Override
|
||||
public IPage<AdminUserVO> adminUserPage(Page initPage, QueryWrapper<AdminUser> initWrapper) {
|
||||
@ -120,7 +120,7 @@ public class AdminUserServiceImpl extends ServiceImpl<AdminUserMapper, AdminUser
|
||||
try {
|
||||
return managerTokenGenerate.createToken(username, false);
|
||||
} catch (Exception e) {
|
||||
log.error("管理员登录错误",e);
|
||||
log.error("管理员登录错误", e);
|
||||
}
|
||||
return null;
|
||||
|
||||
@ -231,7 +231,7 @@ public class AdminUserServiceImpl extends ServiceImpl<AdminUserMapper, AdminUser
|
||||
* @param roles 角色id集合
|
||||
*/
|
||||
private void updateRole(String userId, List<String> roles) {
|
||||
if (!StringUtils.isNotEmpty(roles)) {
|
||||
if (roles.isEmpty() || roles == null) {
|
||||
return;
|
||||
}
|
||||
List<UserRole> userRoles = new ArrayList<>(roles.size());
|
||||
|
@ -1,5 +1,6 @@
|
||||
package cn.lili.modules.search.serviceimpl;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import cn.lili.common.cache.Cache;
|
||||
import cn.lili.common.utils.StringUtils;
|
||||
@ -392,11 +393,11 @@ public class EsGoodsSearchServiceImpl implements EsGoodsSearchService {
|
||||
if(prices.length==0){
|
||||
return;
|
||||
}
|
||||
double min = StringUtils.toDouble(prices[0], 0.0);
|
||||
double min = Convert.toDouble(prices[0], 0.0);
|
||||
double max = Integer.MAX_VALUE;
|
||||
|
||||
if (prices.length == 2) {
|
||||
max = StringUtils.toDouble(prices[1], Double.MAX_VALUE);
|
||||
max = Convert.toDouble(prices[1], Double.MAX_VALUE);
|
||||
}
|
||||
filterBuilder.must(QueryBuilders.rangeQuery("price").from(min).to(max).includeLower(true).includeUpper(true));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user