'合并master'
This commit is contained in:
@@ -26,9 +26,21 @@
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<!--定时任务-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-quartz</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>log4j-to-slf4j</artifactId>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
@@ -69,16 +81,11 @@
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-pool2</artifactId>
|
||||
</dependency>
|
||||
<!--mongodb依赖配置-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-mongodb</artifactId>
|
||||
</dependency>
|
||||
<!-- <!– Websocket –>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.springframework.boot</groupId>-->
|
||||
<!-- <artifactId>spring-boot-starter-websocket</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- <!– Websocket –>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.springframework.boot</groupId>-->
|
||||
<!-- <artifactId>spring-boot-starter-websocket</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- MybatisPlus -->
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
@@ -88,7 +95,7 @@
|
||||
<dependency>
|
||||
<groupId>org.mybatis.spring.boot</groupId>
|
||||
<artifactId>mybatis-spring-boot-starter-test</artifactId>
|
||||
<version>1.3.2</version>
|
||||
<version>2.2.0</version>
|
||||
</dependency>
|
||||
<!-- Mysql Connector -->
|
||||
<dependency>
|
||||
@@ -265,11 +272,11 @@
|
||||
<artifactId>logstash-logback-encoder</artifactId>
|
||||
<version>${logstash-logback-encoder}</version>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>javax.interceptor</groupId>-->
|
||||
<!-- <artifactId>javax.interceptor-api</artifactId>-->
|
||||
<!-- <version>${interceptor-api}</version>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>javax.interceptor</groupId>-->
|
||||
<!-- <artifactId>javax.interceptor-api</artifactId>-->
|
||||
<!-- <version>${interceptor-api}</version>-->
|
||||
<!-- </dependency>-->
|
||||
<dependency>
|
||||
<groupId>de.codecentric</groupId>
|
||||
<artifactId>spring-boot-admin-starter-client</artifactId>
|
||||
|
||||
@@ -480,7 +480,11 @@ public enum CachePrefix {
|
||||
/**
|
||||
* 订单暂时缓存
|
||||
*/
|
||||
ORDER;
|
||||
ORDER,
|
||||
/**
|
||||
* 敏感词
|
||||
*/
|
||||
SENSITIVE;
|
||||
|
||||
|
||||
public static String removePrefix(String str) {
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
package cn.lili.cache.config.mongo;
|
||||
|
||||
import com.mongodb.MongoClientSettings;
|
||||
import com.mongodb.MongoCredential;
|
||||
import com.mongodb.ServerAddress;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.mongodb.config.AbstractMongoClientConfiguration;
|
||||
import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author paulG
|
||||
* @since 2020/10/22
|
||||
**/
|
||||
@Configuration
|
||||
@EnableMongoRepositories
|
||||
public class MongoConfig extends AbstractMongoClientConfiguration {
|
||||
|
||||
@Value("${spring.data.mongodb.database}")
|
||||
private String databaseName;
|
||||
|
||||
@Value("${spring.data.mongodb.uri}")
|
||||
private List<String> uri = new ArrayList<>();
|
||||
|
||||
@Value("${spring.data.mongodb.username}")
|
||||
private String username;
|
||||
|
||||
@Value("${spring.data.mongodb.password}")
|
||||
private String password;
|
||||
|
||||
@Value("${spring.data.mongodb.authentication-database}")
|
||||
private String authenticationDatabase;
|
||||
|
||||
@Override
|
||||
protected String getDatabaseName() {
|
||||
return databaseName;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configureClientSettings(MongoClientSettings.Builder builder) {
|
||||
builder.credential(MongoCredential.createCredential(username, authenticationDatabase, password.toCharArray()))
|
||||
.applyToClusterSettings(settings -> {
|
||||
List<ServerAddress> serverAddresses = new ArrayList<>();
|
||||
for (String s : uri) {
|
||||
String[] node = s.split(":");
|
||||
serverAddresses.add(new ServerAddress(node[0], Integer.parseInt(node[1])));
|
||||
}
|
||||
settings.hosts(serverAddresses);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -78,6 +78,7 @@ public class RedisConfig extends CachingConfigurerSupport {
|
||||
可参考 https://blog.csdn.net/u012240455/article/details/80538540
|
||||
*/
|
||||
ParserConfig.getGlobalInstance().addAccept("cn.lili.");
|
||||
ParserConfig.getGlobalInstance().addAccept("cn.hutool.json.");
|
||||
|
||||
return cacheManager;
|
||||
}
|
||||
|
||||
@@ -1,250 +0,0 @@
|
||||
package cn.lili.cache.util;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.DefaultTypedTuple;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* Redis封装工具类
|
||||
*
|
||||
* @author paulG
|
||||
* @since 2020/11/7
|
||||
**/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class RedisUtil {
|
||||
@Autowired
|
||||
private RedisTemplate redisTemplate;
|
||||
|
||||
//=============================common============================
|
||||
|
||||
/**
|
||||
* 指定缓存失效时间
|
||||
*
|
||||
* @param key 键
|
||||
* @param time 时间(秒)
|
||||
* @return 操作结果
|
||||
*/
|
||||
public boolean expire(String key, long time) {
|
||||
try {
|
||||
if (time > 0) {
|
||||
redisTemplate.expire(key, time, TimeUnit.SECONDS);
|
||||
}
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
log.error("指定缓存失效时间错误",e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//============================String=============================
|
||||
|
||||
/**
|
||||
* 普通缓存获取
|
||||
*
|
||||
* @param key 键
|
||||
* @return 值
|
||||
*/
|
||||
public Object get(String key) {
|
||||
return key == null ? null : redisTemplate.opsForValue().get(key);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 普通缓存获取
|
||||
*
|
||||
* @param key 键
|
||||
* @return 值
|
||||
*/
|
||||
public <T> T get(String key, Class<T> clazz) {
|
||||
Object o = key == null ? null : redisTemplate.opsForValue().get(key);
|
||||
return (T) o;
|
||||
}
|
||||
|
||||
/**
|
||||
* 普通缓存放入
|
||||
*
|
||||
* @param key 键
|
||||
* @param value 值
|
||||
* @return true成功 false失败
|
||||
*/
|
||||
public boolean set(String key, Object value) {
|
||||
try {
|
||||
redisTemplate.opsForValue().set(key, value);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
log.error("缓存放入错误",e);
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 普通缓存放入并设置时间
|
||||
*
|
||||
* @param key 键
|
||||
* @param value 值
|
||||
* @param time 时间(秒) time要大于0 如果time小于等于0 将设置无限期
|
||||
* @return true成功 false 失败
|
||||
*/
|
||||
public boolean set(String key, Object value, long time) {
|
||||
try {
|
||||
if (time > 0) {
|
||||
redisTemplate.opsForValue().set(key, value, time, TimeUnit.SECONDS);
|
||||
} else {
|
||||
set(key, value);
|
||||
}
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
log.error("普通缓存放入并设置时间错误",e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//================================Map=================================
|
||||
|
||||
|
||||
/**
|
||||
* 将数据放入set缓存
|
||||
*
|
||||
* @param key 键
|
||||
* @param values 值 可以是多个
|
||||
* @return 成功个数
|
||||
*/
|
||||
public long sSet(String key, Object... values) {
|
||||
try {
|
||||
return redisTemplate.opsForSet().add(key, values);
|
||||
} catch (Exception e) {
|
||||
log.error("将数据放入set缓存错误",e);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 将list放入缓存
|
||||
*
|
||||
* @param key 键
|
||||
* @param value 值
|
||||
* @return 操作结果
|
||||
*/
|
||||
public boolean lSet(String key, Object value) {
|
||||
try {
|
||||
redisTemplate.opsForList().rightPush(key, value);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
log.error("将list放入缓存错误",e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 将list放入缓存
|
||||
*
|
||||
* @param key 键
|
||||
* @param value 值
|
||||
* @param time 时间(秒)
|
||||
* @return 操作结果
|
||||
*/
|
||||
public boolean lSet(String key, Object value, long time) {
|
||||
try {
|
||||
redisTemplate.opsForList().rightPush(key, value);
|
||||
if (time > 0) {
|
||||
expire(key, time);
|
||||
}
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
log.error("将list放入缓存错误",e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 将list放入缓存
|
||||
*
|
||||
* @param key 键
|
||||
* @param value 值
|
||||
* @return 操作结果
|
||||
*/
|
||||
public boolean lSet(String key, List<Object> value) {
|
||||
try {
|
||||
redisTemplate.opsForList().rightPushAll(key, value);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
log.error("将list放入缓存错误",e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 将list放入缓存
|
||||
*
|
||||
* @param key 键
|
||||
* @param value 值
|
||||
* @param time 时间(秒)
|
||||
* @return 操作结果
|
||||
*/
|
||||
public boolean lSet(String key, List<Object> value, long time) {
|
||||
try {
|
||||
redisTemplate.opsForList().rightPushAll(key, value);
|
||||
if (time > 0) {
|
||||
expire(key, time);
|
||||
}
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
log.error("将list放入缓存错误",e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//===============================ZSet=================================
|
||||
|
||||
/**
|
||||
* 向Zset里添加成员
|
||||
*
|
||||
* @param key 键
|
||||
* @param score 分数
|
||||
* @param value 值
|
||||
* @return 操作结果
|
||||
*/
|
||||
public boolean zadd(String key, long score, String value) {
|
||||
return redisTemplate.opsForZSet().add(key, value, score);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取 某key 下 某一分值区间的队列
|
||||
*
|
||||
* @param key 键
|
||||
* @param from 起始位置
|
||||
* @param to 结束为止
|
||||
* @return 符合条件的结果集
|
||||
*/
|
||||
public Set<DefaultTypedTuple> zrangeByScoreWithScores(String key, int from, long to) {
|
||||
Set<DefaultTypedTuple> set = redisTemplate.opsForZSet().rangeByScoreWithScores(key, from, to);
|
||||
return set;
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除 Zset队列值
|
||||
*
|
||||
* @param key 键
|
||||
* @param value 值集合
|
||||
* @return 移除数量
|
||||
*/
|
||||
public Long zremove(String key, String... value) {
|
||||
return redisTemplate.opsForZSet().remove(key, value);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package cn.lili.modules.system.aspect.annotation;
|
||||
package cn.lili.common.aop.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package cn.lili.modules.system.aspect.interceptor;
|
||||
package cn.lili.common.aop.interceptor;
|
||||
|
||||
import cn.lili.common.aop.annotation.DemoSite;
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.exception.ServiceException;
|
||||
import cn.lili.common.properties.SystemSettingProperties;
|
||||
import cn.lili.modules.system.aspect.annotation.DemoSite;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.annotation.Before;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -23,7 +23,7 @@ public enum PromotionTypeEnum {
|
||||
/**
|
||||
* 有促销库存的活动类型
|
||||
*/
|
||||
static PromotionTypeEnum[] haveStockPromotion = new PromotionTypeEnum[]{PINTUAN, SECKILL, KANJIA, POINTS_GOODS};
|
||||
static final PromotionTypeEnum[] haveStockPromotion = new PromotionTypeEnum[]{PINTUAN, SECKILL, KANJIA, POINTS_GOODS};
|
||||
|
||||
private final String description;
|
||||
|
||||
|
||||
@@ -66,6 +66,8 @@ public enum ResultCode {
|
||||
GOODS_UPPER_ERROR(11004, "商品上架失败"),
|
||||
GOODS_AUTH_ERROR(11005, "商品审核失败"),
|
||||
POINT_GOODS_ERROR(11006, "积分商品业务异常,请稍后重试"),
|
||||
POINT_GOODS_NOT_EXIST(11020, "积分商品不存在"),
|
||||
POINT_GOODS_CATEGORY_EXIST(11021, "当前积分商品分类已存在"),
|
||||
GOODS_SKU_SN_ERROR(11007, "商品SKU货号不能为空"),
|
||||
GOODS_SKU_PRICE_ERROR(11008, "商品SKU价格不能小于等于0"),
|
||||
GOODS_SKU_COST_ERROR(11009, "商品SKU成本价不能小于等于0"),
|
||||
@@ -178,6 +180,7 @@ public enum ResultCode {
|
||||
ORDER_CAN_NOT_CANCEL(31012, "当前订单状态不可取消"),
|
||||
ORDER_BATCH_DELIVER_ERROR(31013, "批量发货,文件读取失败"),
|
||||
ORDER_ITEM_NOT_EXIST(31014, "当前订单项不存在!"),
|
||||
POINT_NOT_ENOUGH(31015, "当前会员积分不足购买当前积分商品!"),
|
||||
|
||||
|
||||
/**
|
||||
@@ -248,6 +251,7 @@ public enum ResultCode {
|
||||
PROMOTION_START_TIME_ERROR(40002, "活动起始时间不能小于当前时间"),
|
||||
PROMOTION_END_TIME_ERROR(40003, "活动结束时间不能小于当前时间"),
|
||||
PROMOTION_TIME_ERROR(40004, "活动起始时间必须大于结束时间"),
|
||||
PROMOTION_TIME_NOT_EXIST(40011, "活动起始时间和活动结束时间不能为空"),
|
||||
PROMOTION_SAME_ERROR(40005, "当前时间段已存在相同活动!"),
|
||||
PROMOTION_GOODS_ERROR(40006, "请选择要参与活动的商品"),
|
||||
PROMOTION_STATUS_END(40007, "当前活动已停止"),
|
||||
@@ -267,6 +271,11 @@ public enum ResultCode {
|
||||
COUPON_RECEIVE_ERROR(41005, "当前优惠券已经被领取完了,下次要早点来哦"),
|
||||
COUPON_NUM_INSUFFICIENT_ERROR(41006, "优惠券剩余领取数量不足"),
|
||||
COUPON_NOT_EXIST(41007, "当前优惠券不存在"),
|
||||
COUPON_DO_NOT_RECEIVER(41030, "当前优惠券不允许主动领取"),
|
||||
COUPON_ACTIVITY_NOT_EXIST(410022, "当前优惠券活动不存在"),
|
||||
COUPON_SAVE_ERROR(41020, "保存优惠券失败"),
|
||||
COUPON_ACTIVITY_SAVE_ERROR(41023, "保存优惠券活动失败"),
|
||||
COUPON_DELETE_ERROR(41021, "删除优惠券失败"),
|
||||
COUPON_LIMIT_NUM_LESS_THAN_0(41008, "领取限制数量不能为负数"),
|
||||
COUPON_LIMIT_GREATER_THAN_PUBLISH(41009, "领取限制数量超出发行数量"),
|
||||
COUPON_DISCOUNT_ERROR(41010, "优惠券折扣必须小于10且大于0"),
|
||||
@@ -294,7 +303,8 @@ public enum ResultCode {
|
||||
PINTUAN_DELETE_ERROR(42010, "删除拼团活动失败"),
|
||||
PINTUAN_JOIN_ERROR(42011, "不能参与自己发起的拼团活动!"),
|
||||
PINTUAN_LIMIT_NUM_ERROR(42012, "购买数量超过拼团活动限制数量!"),
|
||||
PINTUAN_NOT_EXIST_ERROR(42013, "当前拼团商品不存在!"),
|
||||
PINTUAN_NOT_EXIST_ERROR(42013, "当前拼团活动不存在!"),
|
||||
PINTUAN_GOODS_NOT_EXIST_ERROR(42014, "当前拼团商品不存在!"),
|
||||
|
||||
/**
|
||||
* 满额活动
|
||||
@@ -321,10 +331,12 @@ public enum ResultCode {
|
||||
*/
|
||||
SECKILL_NOT_START_ERROR(45000, "今日没有限时抢购活动,请明天再来看看吧。"),
|
||||
SECKILL_NOT_EXIST_ERROR(45001, "当前参与的秒杀活动不存在!"),
|
||||
SECKILL_APPLY_NOT_EXIST_ERROR(45010, "当前参与的秒杀活动不存在!"),
|
||||
SECKILL_UPDATE_ERROR(45002, "当前秒杀活动活动已经开始,无法修改!"),
|
||||
SECKILL_PRICE_ERROR(45003, "活动价格不能大于商品原价"),
|
||||
SECKILL_TIME_ERROR(45004, "时刻参数异常"),
|
||||
SECKILL_DELETE_ERROR(45005, "该秒杀活动活动的状态不能删除"),
|
||||
SECKILL_OPEN_ERROR(45010, "该秒杀活动活动的状态不能删除"),
|
||||
SECKILL_CLOSE_ERROR(45006, "该秒杀活动活动的状态不能关闭"),
|
||||
|
||||
|
||||
@@ -354,6 +366,7 @@ public enum ResultCode {
|
||||
KANJIA_GOODS_ACTIVE_HIGHEST_LOWEST_PRICE_ERROR(48005, "最低砍价金额不能高于最高砍价金额"),
|
||||
KANJIA_GOODS_ACTIVE_SETTLEMENT_PRICE_ERROR(48006, "结算金额不能高于商品金额"),
|
||||
KANJIA_GOODS_DELETE_ERROR(48007, "删除砍价商品异常"),
|
||||
KANJIA_GOODS_UPDATE_ERROR(48012, "更新砍价商品异常"),
|
||||
KANJIA_ACTIVITY_NOT_FOUND_ERROR(48008, "砍价记录不存在"),
|
||||
KANJIA_ACTIVITY_LOG_MEMBER_ERROR(48009, "当前会员已经帮砍"),
|
||||
KANJIA_ACTIVITY_MEMBER_ERROR(48010, "当前会员已经发起此砍价商品活动"),
|
||||
|
||||
@@ -14,6 +14,7 @@ import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.ConstraintViolationException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -122,4 +123,18 @@ public class GlobalControllerExceptionHandler {
|
||||
return ResultUtil.error(ResultCode.PARAMS_ERROR);
|
||||
}
|
||||
|
||||
/**
|
||||
* bean校验未通过异常
|
||||
*
|
||||
* @see javax.validation.Valid
|
||||
* @see org.springframework.validation.Validator
|
||||
* @see org.springframework.validation.DataBinder
|
||||
*/
|
||||
@ExceptionHandler(ConstraintViolationException.class)
|
||||
@ResponseStatus(HttpStatus.BAD_REQUEST)
|
||||
@ResponseBody
|
||||
public ResultMessage<Object> constraintViolationExceptionHandler(HttpServletRequest request, final Exception e, HttpServletResponse response) {
|
||||
ConstraintViolationException exception = (ConstraintViolationException) e;
|
||||
return ResultUtil.error(ResultCode.PARAMS_ERROR.code(), exception.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,11 @@ public class AuthUser implements Serializable {
|
||||
*/
|
||||
private String nickName;
|
||||
|
||||
/**
|
||||
* 头像
|
||||
*/
|
||||
private String face;
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@@ -58,16 +63,18 @@ public class AuthUser implements Serializable {
|
||||
*/
|
||||
private Boolean isSuper = false;
|
||||
|
||||
public AuthUser(String username, String id, String nickName, UserEnums role) {
|
||||
public AuthUser(String username, String id, String nickName, String face, UserEnums role) {
|
||||
this.username = username;
|
||||
this.face = face;
|
||||
this.id = id;
|
||||
this.role = role;
|
||||
this.nickName = nickName;
|
||||
}
|
||||
|
||||
public AuthUser(String username, String id, UserEnums manager, String nickName, Boolean isSuper) {
|
||||
public AuthUser(String username, String id, String face, UserEnums manager, String nickName, Boolean isSuper) {
|
||||
this.username = username;
|
||||
this.id = id;
|
||||
this.face = face;
|
||||
this.role = manager;
|
||||
this.isSuper = isSuper;
|
||||
this.nickName = nickName;
|
||||
|
||||
@@ -2,7 +2,6 @@ package cn.lili.common.security;
|
||||
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.exception.ServiceException;
|
||||
import cn.lili.common.security.AuthUser;
|
||||
import cn.lili.common.security.context.UserContext;
|
||||
import cn.lili.common.utils.BeanUtil;
|
||||
|
||||
|
||||
@@ -4,6 +4,9 @@ package cn.lili.common.security.filter;
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import cn.hutool.http.HtmlUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.owasp.html.HtmlPolicyBuilder;
|
||||
import org.owasp.html.PolicyFactory;
|
||||
import org.owasp.html.Sanitizers;
|
||||
|
||||
import javax.servlet.ReadListener;
|
||||
@@ -17,7 +20,6 @@ import java.io.InputStreamReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@@ -27,6 +29,7 @@ import java.util.Map;
|
||||
* @version v1.0
|
||||
* 2021-06-04 10:39
|
||||
*/
|
||||
@Slf4j
|
||||
public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper {
|
||||
|
||||
|
||||
@@ -35,7 +38,44 @@ public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper {
|
||||
*
|
||||
* @todo 这里的参数应该更智能些,例如iv,前端的参数包含这两个字母就会放过,这是有问题的
|
||||
*/
|
||||
private static final String[] IGNORE_FIELD = {"logo", "url", "photo", "intro", "content", "name", "image", "encrypted", "iv","mail"};
|
||||
private static final String[] IGNORE_FIELD = {
|
||||
"logo",
|
||||
"url",
|
||||
"photo",
|
||||
"intro",
|
||||
"content",
|
||||
"name",
|
||||
"image",
|
||||
"encrypted",
|
||||
"iv",
|
||||
"mail",
|
||||
"sell",
|
||||
"id",
|
||||
"price",
|
||||
"prop",
|
||||
"reply",
|
||||
"profile",
|
||||
"privateKey",
|
||||
"wechatpay",
|
||||
};
|
||||
|
||||
//允许的标签
|
||||
private static final String[] allowedTags = {"h1", "h2", "h3", "h4", "h5", "h6",
|
||||
"span", "strong",
|
||||
"img", "video", "source", "iframe", "code",
|
||||
"blockquote", "p", "div",
|
||||
"ul", "ol", "li",
|
||||
"table", "thead", "caption", "tbody", "tr", "th", "td", "br",
|
||||
"a"
|
||||
};
|
||||
|
||||
//需要转化的标签
|
||||
private static final String[] needTransformTags = {"article", "aside", "command", "datalist", "details", "figcaption", "figure",
|
||||
"footer", "header", "hgroup", "section", "summary"};
|
||||
|
||||
//带有超链接的标签
|
||||
private static final String[] linkTags = {"img", "video", "source", "a", "iframe"};
|
||||
|
||||
|
||||
public XssHttpServletRequestWrapper(HttpServletRequest request) {
|
||||
super(request);
|
||||
@@ -128,45 +168,72 @@ public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper {
|
||||
*/
|
||||
@Override
|
||||
public ServletInputStream getInputStream() throws IOException {
|
||||
//获取输入流
|
||||
ServletInputStream in = super.getInputStream();
|
||||
//用于存储输入流
|
||||
StringBuilder body = new StringBuilder();
|
||||
InputStreamReader reader = new InputStreamReader(in, StandardCharsets.UTF_8);
|
||||
BufferedReader bufferedReader = new BufferedReader(reader);
|
||||
//按行读取输入流
|
||||
String line = bufferedReader.readLine();
|
||||
while (line != null) {
|
||||
//将获取到的第一行数据append到StringBuffer中
|
||||
body.append(line);
|
||||
//继续读取下一行流,直到line为空
|
||||
line = bufferedReader.readLine();
|
||||
}
|
||||
//关闭流
|
||||
bufferedReader.close();
|
||||
reader.close();
|
||||
in.close();
|
||||
|
||||
if (CharSequenceUtil.isNotEmpty(body) && Boolean.TRUE.equals(JSONUtil.isJsonObj(body.toString()))) {
|
||||
//将body转换为map
|
||||
Map<String, Object> map = JSONUtil.parseObj(body.toString());
|
||||
//创建空的map用于存储结果
|
||||
Map<String, Object> resultMap = new HashMap<>(map.size());
|
||||
//遍历数组
|
||||
for (Map.Entry<String, Object> entry : map.entrySet()) {
|
||||
//如果map.get(key)获取到的是字符串就需要进行处理,如果不是直接存储resultMap
|
||||
if (map.get(entry.getKey()) instanceof String) {
|
||||
resultMap.put(entry.getKey(), filterXss(entry.getKey(), entry.getValue().toString()));
|
||||
} else {
|
||||
resultMap.put(entry.getKey(), entry.getValue());
|
||||
BufferedReader bufferedReader = null;
|
||||
|
||||
InputStreamReader reader = null;
|
||||
|
||||
//获取输入流
|
||||
ServletInputStream in = null;
|
||||
try {
|
||||
in = super.getInputStream();
|
||||
//用于存储输入流
|
||||
StringBuilder body = new StringBuilder();
|
||||
reader = new InputStreamReader(in, StandardCharsets.UTF_8);
|
||||
bufferedReader = new BufferedReader(reader);
|
||||
//按行读取输入流
|
||||
String line = bufferedReader.readLine();
|
||||
while (line != null) {
|
||||
//将获取到的第一行数据append到StringBuffer中
|
||||
body.append(line);
|
||||
//继续读取下一行流,直到line为空
|
||||
line = bufferedReader.readLine();
|
||||
}
|
||||
if (CharSequenceUtil.isNotEmpty(body) && Boolean.TRUE.equals(JSONUtil.isJsonObj(body.toString()))) {
|
||||
//将body转换为map
|
||||
Map<String, Object> map = JSONUtil.parseObj(body.toString());
|
||||
//创建空的map用于存储结果
|
||||
Map<String, Object> resultMap = new HashMap<>(map.size());
|
||||
//遍历数组
|
||||
for (Map.Entry<String, Object> entry : map.entrySet()) {
|
||||
//如果map.get(key)获取到的是字符串就需要进行处理,如果不是直接存储resultMap
|
||||
if (map.get(entry.getKey()) instanceof String) {
|
||||
resultMap.put(entry.getKey(), filterXss(entry.getKey(), entry.getValue().toString()));
|
||||
} else {
|
||||
resultMap.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
//将resultMap转换为json字符串
|
||||
String resultStr = JSONUtil.toJsonStr(resultMap);
|
||||
//将json字符串转换为字节
|
||||
final ByteArrayInputStream resultBIS = new ByteArrayInputStream(resultStr.getBytes());
|
||||
|
||||
//实现接口
|
||||
return new ServletInputStream() {
|
||||
@Override
|
||||
public boolean isFinished() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReady() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setReadListener(ReadListener readListener) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int read() {
|
||||
return resultBIS.read();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
//将resultMap转换为json字符串
|
||||
String resultStr = JSONUtil.toJsonStr(resultMap);
|
||||
//将json字符串转换为字节
|
||||
final ByteArrayInputStream resultBIS = new ByteArrayInputStream(resultStr.getBytes());
|
||||
|
||||
final ByteArrayInputStream bis = new ByteArrayInputStream(body.toString().getBytes());
|
||||
//实现接口
|
||||
return new ServletInputStream() {
|
||||
@Override
|
||||
@@ -181,48 +248,57 @@ public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper {
|
||||
|
||||
@Override
|
||||
public void setReadListener(ReadListener readListener) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int read() {
|
||||
return resultBIS.read();
|
||||
return bis.read();
|
||||
}
|
||||
};
|
||||
} catch (Exception e) {
|
||||
|
||||
log.error("get request inputStream error", e);
|
||||
return null;
|
||||
} finally {
|
||||
//关闭流
|
||||
if (bufferedReader != null) {
|
||||
bufferedReader.close();
|
||||
}
|
||||
if (reader != null) {
|
||||
reader.close();
|
||||
}
|
||||
if (in != null) {
|
||||
in.close();
|
||||
}
|
||||
}
|
||||
|
||||
//将json字符串转换为字节
|
||||
final ByteArrayInputStream bis = new ByteArrayInputStream(body.toString().getBytes());
|
||||
|
||||
//实现接口
|
||||
return new ServletInputStream() {
|
||||
@Override
|
||||
public boolean isFinished() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReady() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setReadListener(ReadListener readListener) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int read() {
|
||||
return bis.read();
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
private String cleanXSS(String value) {
|
||||
if (value != null) {
|
||||
value = Sanitizers.FORMATTING.and(Sanitizers.LINKS).sanitize(value);
|
||||
// 自定义策略
|
||||
PolicyFactory policy = new HtmlPolicyBuilder()
|
||||
.allowStandardUrlProtocols()
|
||||
//所有允许的标签
|
||||
.allowElements(allowedTags)
|
||||
//内容标签转化为div
|
||||
.allowElements((elementName, attributes) -> "div", needTransformTags)
|
||||
.allowAttributes("src", "href", "target", "width", "height").onElements(linkTags)
|
||||
//校验链接中的是否为http
|
||||
// .allowUrlProtocols("https")
|
||||
.toFactory();
|
||||
// basic prepackaged policies for links, tables, integers, images, styles, blocks
|
||||
value = Sanitizers.FORMATTING
|
||||
.and(Sanitizers.STYLES)
|
||||
.and(Sanitizers.IMAGES)
|
||||
.and(Sanitizers.LINKS)
|
||||
.and(Sanitizers.BLOCKS)
|
||||
.and(Sanitizers.TABLES)
|
||||
.and(policy)
|
||||
.sanitize(value);
|
||||
}
|
||||
return value;
|
||||
return HtmlUtil.unescape(value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -233,12 +309,13 @@ public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper {
|
||||
* @return 参数值
|
||||
*/
|
||||
private String filterXss(String name, String value) {
|
||||
if (CharSequenceUtil.containsAny(name.toLowerCase(Locale.ROOT), IGNORE_FIELD)) {
|
||||
// 忽略的处理,(过滤敏感字符)
|
||||
return HtmlUtil.unescape(HtmlUtil.filter(value));
|
||||
} else {
|
||||
return cleanXSS(value);
|
||||
}
|
||||
// if (CharSequenceUtil.containsAny(name.toLowerCase(Locale.ROOT), IGNORE_FIELD)) {
|
||||
// // 忽略的处理,(过滤敏感字符)
|
||||
// return value;
|
||||
// } else {
|
||||
// return cleanXSS(value);
|
||||
// }
|
||||
return cleanXSS(value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,12 +1,6 @@
|
||||
package cn.lili.modules.system.utils;
|
||||
package cn.lili.common.sensitive;
|
||||
|
||||
import cn.lili.modules.system.entity.dos.SensitiveWords;
|
||||
import cn.lili.modules.system.service.SensitiveWordsService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.ApplicationArguments;
|
||||
import org.springframework.boot.ApplicationRunner;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
@@ -21,9 +15,12 @@ import java.util.NavigableSet;
|
||||
* 2020-02-25 14:10:16
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class SensitiveWordsFilter implements Serializable, ApplicationRunner {
|
||||
public class SensitiveWordsFilter implements Serializable {
|
||||
|
||||
/**
|
||||
* 字符*
|
||||
*/
|
||||
public final static char WILDCARD_STAR = '*';
|
||||
|
||||
/**
|
||||
* 为2的n次方,考虑到敏感词大概在10k左右,
|
||||
@@ -37,98 +34,27 @@ public class SensitiveWordsFilter implements Serializable, ApplicationRunner {
|
||||
* 类似HashMap的桶,比较稀疏。
|
||||
* 使用2个字符的hash定位。
|
||||
*/
|
||||
protected static SensitiveWordsNode[] nodes;
|
||||
|
||||
@Autowired
|
||||
private SensitiveWordsService sensitiveWordsService;
|
||||
|
||||
protected static SensitiveWordsNode[] nodes = new SensitiveWordsNode[0];
|
||||
|
||||
/**
|
||||
* 增加一个敏感词,如果词的长度(trim后)小于2,则丢弃<br/>
|
||||
* 此方法(构建)并不是主要的性能优化点。
|
||||
*
|
||||
* @param word 敏感词
|
||||
* @return 操作结果
|
||||
* 更新中的nodes,用于防止动态更新时,原有nodes被清空,导致无法正常写入过滤词
|
||||
*/
|
||||
public static boolean put(String word) {
|
||||
protected static SensitiveWordsNode[] nodesUpdate;
|
||||
|
||||
//长度小于2的不加入
|
||||
if (word == null || word.trim().length() < 2) {
|
||||
return false;
|
||||
}
|
||||
//两个字符的不考虑
|
||||
if (word.length() == 2 && word.matches("\\w\\w")) {
|
||||
return false;
|
||||
}
|
||||
StringPointer sp = new StringPointer(word.trim());
|
||||
//计算头两个字符的hash
|
||||
int hash = sp.nextTwoCharHash(0);
|
||||
//计算头两个字符的mix表示(mix相同,两个字符相同)
|
||||
int mix = sp.nextTwoCharMix(0);
|
||||
//转为在hash桶中的位置
|
||||
int index = hash & (nodes.length - 1);
|
||||
|
||||
//从桶里拿第一个节点
|
||||
SensitiveWordsNode node = nodes[index];
|
||||
if (node == null) {
|
||||
//如果没有节点,则放进去一个
|
||||
node = new SensitiveWordsNode(mix);
|
||||
//并添加词
|
||||
node.words.add(sp);
|
||||
//放入桶里
|
||||
nodes[index] = node;
|
||||
} else {
|
||||
//如果已经有节点(1个或多个),找到正确的节点
|
||||
for (; node != null; node = node.next) {
|
||||
//匹配节点
|
||||
if (node.headTwoCharMix == mix) {
|
||||
node.words.add(sp);
|
||||
return true;
|
||||
}
|
||||
//如果匹配到最后仍然不成功,则追加一个节点
|
||||
if (node.next == null) {
|
||||
new SensitiveWordsNode(mix, node).words.add(sp);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除敏感词
|
||||
* 过滤铭感次
|
||||
*
|
||||
* @param word
|
||||
* @param sentence 过滤赐予
|
||||
* @return
|
||||
*/
|
||||
public static void remove(String word) {
|
||||
|
||||
StringPointer sp = new StringPointer(word.trim());
|
||||
//计算头两个字符的hash
|
||||
int hash = sp.nextTwoCharHash(0);
|
||||
//计算头两个字符的mix表示(mix相同,两个字符相同)
|
||||
int mix = sp.nextTwoCharMix(0);
|
||||
//转为在hash桶中的位置
|
||||
int index = hash & (nodes.length - 1);
|
||||
SensitiveWordsNode node = nodes[index];
|
||||
|
||||
for (; node != null; node = node.next) {
|
||||
//匹配节点
|
||||
if (node.headTwoCharMix == mix) {
|
||||
node.words.remove(sp);
|
||||
}
|
||||
|
||||
}
|
||||
public static String filter(String sentence) {
|
||||
return filter(sentence, WILDCARD_STAR);
|
||||
}
|
||||
|
||||
/**
|
||||
* 对句子进行敏感词过滤<br/>
|
||||
* 如果无敏感词返回输入的sentence对象,即可以用下面的方式判断是否有敏感词:<br/><code>
|
||||
* String result = filter.filter(sentence, CharacterConstant.WILDCARD_STAR);<br/>
|
||||
* if(result != sentence){<br/>
|
||||
* //有敏感词<br/>
|
||||
* }
|
||||
* </code>
|
||||
* 如果无敏感词返回输入的sentence对象,即可以用下面的方式判断是否有敏感词:<br/>
|
||||
*
|
||||
* @param sentence 句子
|
||||
* @param replace 敏感词的替换字符
|
||||
@@ -224,25 +150,96 @@ public class SensitiveWordsFilter implements Serializable, ApplicationRunner {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 初始化敏感词
|
||||
*
|
||||
* @param args
|
||||
* @throws Exception
|
||||
*/
|
||||
@Override
|
||||
public void run(ApplicationArguments args) {
|
||||
try {
|
||||
nodes = new SensitiveWordsNode[DEFAULT_INITIAL_CAPACITY];
|
||||
//加入平台添加的敏感词
|
||||
List<SensitiveWords> list = sensitiveWordsService.list();
|
||||
if (list != null && list.size() > 0) {
|
||||
for (SensitiveWords sensitiveWords : list) {
|
||||
put(sensitiveWords.getSensitiveWord());
|
||||
public static void init(List<String> words) {
|
||||
log.info("开始初始化敏感词");
|
||||
nodesUpdate = new SensitiveWordsNode[DEFAULT_INITIAL_CAPACITY];
|
||||
for (String word : words) {
|
||||
put(word);
|
||||
}
|
||||
nodes = nodesUpdate;
|
||||
}
|
||||
|
||||
/**
|
||||
* 增加一个敏感词,如果词的长度(trim后)小于2,则丢弃<br/>
|
||||
* 此方法(构建)并不是主要的性能优化点。
|
||||
*
|
||||
* @param word 敏感词
|
||||
* @return 操作结果
|
||||
*/
|
||||
public static boolean put(String word) {
|
||||
|
||||
//长度小于2的不加入
|
||||
if (word == null || word.trim().length() < 2) {
|
||||
return false;
|
||||
}
|
||||
//两个字符的不考虑
|
||||
if (word.length() == 2 && word.matches("\\w\\w")) {
|
||||
return false;
|
||||
}
|
||||
StringPointer sp = new StringPointer(word.trim());
|
||||
//计算头两个字符的hash
|
||||
int hash = sp.nextTwoCharHash(0);
|
||||
//计算头两个字符的mix表示(mix相同,两个字符相同)
|
||||
int mix = sp.nextTwoCharMix(0);
|
||||
//转为在hash桶中的位置
|
||||
int index = hash & (nodesUpdate.length - 1);
|
||||
|
||||
//从桶里拿第一个节点
|
||||
SensitiveWordsNode node = nodesUpdate[index];
|
||||
if (node == null) {
|
||||
//如果没有节点,则放进去一个
|
||||
node = new SensitiveWordsNode(mix);
|
||||
//并添加词
|
||||
node.words.add(sp);
|
||||
//放入桶里
|
||||
nodesUpdate[index] = node;
|
||||
} else {
|
||||
//如果已经有节点(1个或多个),找到正确的节点
|
||||
for (; node != null; node = node.next) {
|
||||
//匹配节点
|
||||
if (node.headTwoCharMix == mix) {
|
||||
node.words.add(sp);
|
||||
return true;
|
||||
}
|
||||
//如果匹配到最后仍然不成功,则追加一个节点
|
||||
if (node.next == null) {
|
||||
new SensitiveWordsNode(mix, node).words.add(sp);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("初始化敏感词错误", e);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除敏感词
|
||||
*
|
||||
* @param word
|
||||
* @return
|
||||
*/
|
||||
public static void remove(String word) {
|
||||
|
||||
StringPointer sp = new StringPointer(word.trim());
|
||||
//计算头两个字符的hash
|
||||
int hash = sp.nextTwoCharHash(0);
|
||||
//计算头两个字符的mix表示(mix相同,两个字符相同)
|
||||
int mix = sp.nextTwoCharMix(0);
|
||||
//转为在hash桶中的位置
|
||||
int index = hash & (nodes.length - 1);
|
||||
SensitiveWordsNode node = nodes[index];
|
||||
|
||||
for (; node != null; node = node.next) {
|
||||
//匹配节点
|
||||
if (node.headTwoCharMix == mix) {
|
||||
node.words.remove(sp);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package cn.lili.modules.system.utils;
|
||||
package cn.lili.common.sensitive;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.TreeSet;
|
||||
@@ -1,13 +1,14 @@
|
||||
package cn.lili.modules.system.utils;
|
||||
package cn.lili.common.sensitive;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 字符指针
|
||||
*
|
||||
* @author Bulbasaur
|
||||
* @since 2020-02-25 14:10:16
|
||||
*/
|
||||
public class StringPointer implements Serializable, CharSequence, Comparable<StringPointer>{
|
||||
public class StringPointer implements Serializable, CharSequence, Comparable<StringPointer> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -19,13 +20,13 @@ public class StringPointer implements Serializable, CharSequence, Comparable<Str
|
||||
|
||||
private int hash = 0;
|
||||
|
||||
public StringPointer(String str){
|
||||
public StringPointer(String str) {
|
||||
value = str.toCharArray();
|
||||
offset = 0;
|
||||
length = value.length;
|
||||
}
|
||||
|
||||
public StringPointer(char[] value, int offset, int length){
|
||||
public StringPointer(char[] value, int offset, int length) {
|
||||
this.value = value;
|
||||
this.offset = offset;
|
||||
this.length = length;
|
||||
@@ -34,10 +35,11 @@ public class StringPointer implements Serializable, CharSequence, Comparable<Str
|
||||
|
||||
/**
|
||||
* 计算该位置后(包含)2个字符的hash值
|
||||
*
|
||||
* @param i 从 0 到 length - 2
|
||||
* @return 从 0 到 length - 2
|
||||
*/
|
||||
public int nextTwoCharHash(int i){
|
||||
public int nextTwoCharHash(int i) {
|
||||
return 31 * value[offset + i] + value[offset + i + 1];
|
||||
}
|
||||
|
||||
@@ -48,25 +50,25 @@ public class StringPointer implements Serializable, CharSequence, Comparable<Str
|
||||
* @param i 从 0 到 length - 2
|
||||
* @return int值
|
||||
*/
|
||||
public int nextTwoCharMix(int i){
|
||||
public int nextTwoCharMix(int i) {
|
||||
return (value[offset + i] << 16) | value[offset + i + 1];
|
||||
}
|
||||
|
||||
/**
|
||||
* 该位置后(包含)的字符串,是否以某个词(word)开头
|
||||
*
|
||||
* @param i 从 0 到 length - 2
|
||||
* @param i 从 0 到 length - 2
|
||||
* @param word 词
|
||||
* @return 是否?
|
||||
*/
|
||||
public boolean nextStartsWith(int i, StringPointer word){
|
||||
public boolean nextStartsWith(int i, StringPointer word) {
|
||||
//是否长度超出
|
||||
if(word.length > length - i){
|
||||
if (word.length > length - i) {
|
||||
return false;
|
||||
}
|
||||
//从尾开始判断
|
||||
for(int c = word.length - 1; c >= 0; c --){
|
||||
if(value[offset + i + c] != word.value[word.offset + c]){
|
||||
for (int c = word.length - 1; c >= 0; c--) {
|
||||
if (value[offset + i + c] != word.value[word.offset + c]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -76,31 +78,31 @@ public class StringPointer implements Serializable, CharSequence, Comparable<Str
|
||||
/**
|
||||
* 填充(替换)
|
||||
*
|
||||
* @param begin 从此位置开始(含)
|
||||
* @param end 到此位置结束(不含)
|
||||
* @param begin 从此位置开始(含)
|
||||
* @param end 到此位置结束(不含)
|
||||
* @param fillWith 以此字符填充(替换)
|
||||
*/
|
||||
public void fill(int begin, int end, char fillWith){
|
||||
for(int i = begin; i < end; i ++){
|
||||
public void fill(int begin, int end, char fillWith) {
|
||||
for (int i = begin; i < end; i++) {
|
||||
value[offset + i] = fillWith;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int length(){
|
||||
public int length() {
|
||||
return length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public char charAt(int i){
|
||||
public char charAt(int i) {
|
||||
return value[offset + i];
|
||||
}
|
||||
|
||||
public StringPointer substring(int begin){
|
||||
public StringPointer substring(int begin) {
|
||||
return new StringPointer(value, offset + begin, length - begin);
|
||||
}
|
||||
|
||||
public StringPointer substring(int begin, int end){
|
||||
public StringPointer substring(int begin, int end) {
|
||||
return new StringPointer(value, offset + begin, end - begin);
|
||||
}
|
||||
|
||||
@@ -110,7 +112,7 @@ public class StringPointer implements Serializable, CharSequence, Comparable<Str
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(){
|
||||
public String toString() {
|
||||
return new String(value, offset, length);
|
||||
}
|
||||
|
||||
@@ -132,12 +134,12 @@ public class StringPointer implements Serializable, CharSequence, Comparable<Str
|
||||
return true;
|
||||
}
|
||||
if (anObject instanceof StringPointer) {
|
||||
StringPointer that = (StringPointer)anObject;
|
||||
StringPointer that = (StringPointer) anObject;
|
||||
if (length == that.length) {
|
||||
char[] v1 = this.value;
|
||||
char[] v2 = that.value;
|
||||
for(int i = 0; i < this.length; i ++){
|
||||
if(v1[this.offset + i] != v2[that.offset + i]){
|
||||
for (int i = 0; i < this.length; i++) {
|
||||
if (v1[this.offset + i] != v2[that.offset + i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package cn.lili.common.sensitive.init;
|
||||
|
||||
import cn.lili.cache.Cache;
|
||||
import cn.lili.cache.CachePrefix;
|
||||
import cn.lili.common.sensitive.SensitiveWordsFilter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.ApplicationArguments;
|
||||
import org.springframework.boot.ApplicationRunner;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 敏感词加载
|
||||
*
|
||||
* @author Chopper
|
||||
* @version v1.0
|
||||
* 2021-11-23 12:08
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class SensitiveWordsLoader implements ApplicationRunner {
|
||||
|
||||
@Autowired
|
||||
private Cache<List<String>> cache;
|
||||
|
||||
/**
|
||||
* 程序启动时,获取最新的需要过滤的敏感词
|
||||
* <p>
|
||||
* 这里即便缓存中为空也没关系,定时任务会定时重新加载敏感词
|
||||
*
|
||||
* @param args 启动参数
|
||||
*/
|
||||
@Override
|
||||
public void run(ApplicationArguments args) {
|
||||
List<String> sensitives = cache.get(CachePrefix.SENSITIVE.getPrefix());
|
||||
log.info("系统初始化敏感词");
|
||||
if (sensitives == null || sensitives.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
SensitiveWordsFilter.init(sensitives);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package cn.lili.common.sensitive.quartz;
|
||||
|
||||
import org.quartz.*;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* 定时执行配置
|
||||
*
|
||||
* @author Chopper
|
||||
* @version v1.0
|
||||
* 2021-11-23 16:30
|
||||
*/
|
||||
@Configuration
|
||||
public class QuartzConfig {
|
||||
|
||||
@Bean
|
||||
public JobDetail sensitiveQuartzDetail() {
|
||||
return JobBuilder.newJob(SensitiveQuartz.class).withIdentity("sensitiveQuartz").storeDurably().build();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Trigger sensitiveQuartzTrigger() {
|
||||
SimpleScheduleBuilder scheduleBuilder = SimpleScheduleBuilder.simpleSchedule()
|
||||
.withIntervalInSeconds(3600)
|
||||
.repeatForever();
|
||||
return TriggerBuilder.newTrigger().forJob(sensitiveQuartzDetail())
|
||||
.withIdentity("sensitiveQuartz")
|
||||
.withSchedule(scheduleBuilder)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package cn.lili.common.sensitive.quartz;
|
||||
|
||||
import cn.lili.cache.Cache;
|
||||
import cn.lili.cache.CachePrefix;
|
||||
import cn.lili.common.sensitive.SensitiveWordsFilter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.quartz.QuartzJobBean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 间隔更新敏感词
|
||||
*
|
||||
* @author Chopper
|
||||
* @version v1.0
|
||||
* 2021-11-23 16:31
|
||||
*/
|
||||
@Slf4j
|
||||
public class SensitiveQuartz extends QuartzJobBean {
|
||||
|
||||
@Autowired
|
||||
private Cache<List<String>> cache;
|
||||
|
||||
/**
|
||||
* 定时更新敏感词信息
|
||||
*
|
||||
* @param jobExecutionContext
|
||||
*/
|
||||
@Override
|
||||
protected void executeInternal(JobExecutionContext jobExecutionContext) {
|
||||
log.info("敏感词定时更新");
|
||||
List<String> sensitives = cache.get(CachePrefix.SENSITIVE.getPrefix());
|
||||
if (sensitives == null || sensitives.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
SensitiveWordsFilter.init(sensitives);
|
||||
}
|
||||
}
|
||||
@@ -3,11 +3,10 @@ package cn.lili.common.utils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.Base64;
|
||||
import java.util.Base64.Decoder;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
/**
|
||||
* base64转为multipartFile工具类
|
||||
*
|
||||
@@ -55,7 +54,7 @@ public class Base64DecodeMultipartFile implements MultipartFile {
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream getInputStream() throws IOException {
|
||||
public InputStream getInputStream() {
|
||||
return new ByteArrayInputStream(imgContent);
|
||||
}
|
||||
|
||||
@@ -66,8 +65,9 @@ public class Base64DecodeMultipartFile implements MultipartFile {
|
||||
stream = new FileOutputStream(dest);
|
||||
stream.write(imgContent);
|
||||
} catch (IOException e) {
|
||||
log.error("transferTo错误",e);
|
||||
}finally {
|
||||
log.error("transferTo错误", e);
|
||||
} finally {
|
||||
assert stream != null;
|
||||
stream.close();
|
||||
}
|
||||
}
|
||||
@@ -94,7 +94,7 @@ public class Base64DecodeMultipartFile implements MultipartFile {
|
||||
byte[] bytes = Base64.getDecoder().decode(base64);
|
||||
stream = new ByteArrayInputStream(bytes);
|
||||
} catch (Exception e) {
|
||||
log.error("base64ToInputStream错误",e);
|
||||
log.error("base64ToInputStream错误", e);
|
||||
}
|
||||
return stream;
|
||||
}
|
||||
@@ -111,13 +111,13 @@ public class Base64DecodeMultipartFile implements MultipartFile {
|
||||
}
|
||||
data = swapStream.toByteArray();
|
||||
} catch (IOException e) {
|
||||
log.error("转码错误",e);
|
||||
log.error("转码错误", e);
|
||||
} finally {
|
||||
if (in != null) {
|
||||
try {
|
||||
in.close();
|
||||
} catch (IOException e) {
|
||||
log.error("inputStreamToStream错误",e);
|
||||
log.error("inputStreamToStream错误", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ public class BeanUtil {
|
||||
* 复制属性
|
||||
*
|
||||
* @param objectFrom 源自对象
|
||||
* @param objectTo 复制给对象
|
||||
* @param objectTo 复制给对象
|
||||
*/
|
||||
public static void copyProperties(Object objectFrom, Object objectTo) {
|
||||
BeanUtils.copyProperties(objectFrom, objectTo);
|
||||
@@ -25,6 +25,7 @@ public class BeanUtil {
|
||||
|
||||
/**
|
||||
* 获取属性名数组
|
||||
*
|
||||
* @param o 获取字段的对象
|
||||
* @return 返回各个字段
|
||||
*/
|
||||
@@ -49,8 +50,9 @@ public class BeanUtil {
|
||||
|
||||
/**
|
||||
* 根据属性名获取属性值
|
||||
*
|
||||
* @param fieldName 属性名
|
||||
* @param o 对象
|
||||
* @param o 对象
|
||||
* @return 属性值
|
||||
*/
|
||||
public static Object getFieldValueByName(String fieldName, Object o) {
|
||||
@@ -69,6 +71,7 @@ public class BeanUtil {
|
||||
/**
|
||||
* 将对象转换为key value
|
||||
* A=a&B=b&C=c 格式
|
||||
*
|
||||
* @param object 对象
|
||||
* @return 格式化结果
|
||||
*/
|
||||
@@ -87,6 +90,7 @@ public class BeanUtil {
|
||||
String key = fieldNames[j];
|
||||
//获取值
|
||||
Object value = BeanUtil.getFieldValueByName(key, object);
|
||||
assert value != null;
|
||||
stringBuffer.append(key).append("=").append(value.toString());
|
||||
}
|
||||
return stringBuffer.toString();
|
||||
@@ -95,8 +99,9 @@ public class BeanUtil {
|
||||
/**
|
||||
* key value键值对 转换为 对象
|
||||
* A=a&B=b&C=c 格式 转换为对象
|
||||
*
|
||||
* @param str 对象字符串
|
||||
* @param t 范型
|
||||
* @param t 范型
|
||||
* @param <T> 范型
|
||||
* @return 格式化结果
|
||||
*/
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package cn.lili.common.utils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* 金额计算工具
|
||||
@@ -23,27 +25,29 @@ public final class CurrencyUtil {
|
||||
/**
|
||||
* 提供精确的加法运算。
|
||||
*
|
||||
* @param v1 被加数
|
||||
* @param v2 加数
|
||||
* @return 两个参数的和
|
||||
* @return 累加之和
|
||||
*/
|
||||
public static Double add(double v1, double v2) {
|
||||
BigDecimal b1 = new BigDecimal(v1);
|
||||
BigDecimal b2 = new BigDecimal(v2);
|
||||
return b1.add(b2).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
|
||||
public static Double add(double... params) {
|
||||
BigDecimal result = new BigDecimal("0");
|
||||
for (double param : params) {
|
||||
BigDecimal bigParam = BigDecimal.valueOf(param);
|
||||
result = result.add(bigParam).setScale(2, RoundingMode.HALF_UP);
|
||||
}
|
||||
return result.doubleValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* 提供精确的减法运算。
|
||||
* 提供精确的加法运算。
|
||||
*
|
||||
* @param v1 被减数
|
||||
* @param v2 减数
|
||||
* @return 两个参数的差
|
||||
* @return 累加之和
|
||||
*/
|
||||
public static double sub(double v1, double v2) {
|
||||
BigDecimal b1 = new BigDecimal(v1);
|
||||
BigDecimal b2 = new BigDecimal(v2);
|
||||
return b1.subtract(b2).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
|
||||
public static Double sub(double... params) {
|
||||
BigDecimal result = BigDecimal.valueOf(params[0]);
|
||||
params = Arrays.stream(params).skip(1).toArray();
|
||||
for (double param : params) {
|
||||
BigDecimal bigParam = BigDecimal.valueOf(param);
|
||||
result = result.subtract(bigParam).setScale(2, RoundingMode.HALF_UP);
|
||||
}
|
||||
return result.doubleValue();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -54,9 +58,9 @@ public final class CurrencyUtil {
|
||||
* @return 两个参数的积
|
||||
*/
|
||||
public static Double mul(double v1, double v2) {
|
||||
BigDecimal b1 = new BigDecimal(v1);
|
||||
BigDecimal b2 = new BigDecimal(v2);
|
||||
return b1.multiply(b2).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
|
||||
BigDecimal b1 = BigDecimal.valueOf(v1);
|
||||
BigDecimal b2 = BigDecimal.valueOf(v2);
|
||||
return b1.multiply(b2).setScale(2, RoundingMode.HALF_UP).doubleValue();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -72,9 +76,9 @@ public final class CurrencyUtil {
|
||||
throw new IllegalArgumentException(
|
||||
"The scale must be a positive integer or zero");
|
||||
}
|
||||
BigDecimal b1 = new BigDecimal(v1);
|
||||
BigDecimal b2 = new BigDecimal(v2);
|
||||
return b1.multiply(b2).setScale(scale, BigDecimal.ROUND_HALF_UP).doubleValue();
|
||||
BigDecimal b1 = BigDecimal.valueOf(v1);
|
||||
BigDecimal b2 = BigDecimal.valueOf(v2);
|
||||
return b1.multiply(b2).setScale(scale, RoundingMode.HALF_UP).doubleValue();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -105,26 +109,9 @@ public final class CurrencyUtil {
|
||||
if (v2 == 0) {
|
||||
return 0;
|
||||
}
|
||||
BigDecimal b1 = new BigDecimal(v1);
|
||||
BigDecimal b2 = new BigDecimal(v2);
|
||||
return b1.divide(b2, scale, BigDecimal.ROUND_HALF_UP).doubleValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* 提供精确的小数位四舍五入处理。
|
||||
*
|
||||
* @param v 需要四舍五入的数字
|
||||
* @param scale 小数点后保留几位
|
||||
* @return 四舍五入后的结果
|
||||
*/
|
||||
public static double round(double v, int scale) {
|
||||
if (scale < 0) {
|
||||
throw new IllegalArgumentException(
|
||||
"The scale must be a positive integer or zero");
|
||||
}
|
||||
BigDecimal b = new BigDecimal(v);
|
||||
BigDecimal one = new BigDecimal("1");
|
||||
return b.divide(one, scale, BigDecimal.ROUND_HALF_UP).doubleValue();
|
||||
BigDecimal b1 = BigDecimal.valueOf(v1);
|
||||
BigDecimal b2 = BigDecimal.valueOf(v2);
|
||||
return b1.divide(b2, scale, RoundingMode.HALF_UP).doubleValue();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -145,7 +132,6 @@ public final class CurrencyUtil {
|
||||
* @return double类型分
|
||||
*/
|
||||
public static double reversalFen(Double money) {
|
||||
double price = div(money, 100);
|
||||
return price;
|
||||
return div(money, 100);
|
||||
}
|
||||
}
|
||||
@@ -273,7 +273,7 @@ public class DateUtil {
|
||||
* @return 时间戳
|
||||
*/
|
||||
public static long getDateline(String date) {
|
||||
return toDate(date, STANDARD_DATE_FORMAT).getTime() / 1000;
|
||||
return Objects.requireNonNull(toDate(date, STANDARD_DATE_FORMAT)).getTime() / 1000;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -311,7 +311,7 @@ public class DateUtil {
|
||||
* @return 时间戳
|
||||
*/
|
||||
public static long getDateline(String date, String pattern) {
|
||||
return toDate(date, pattern).getTime() / 1000;
|
||||
return Objects.requireNonNull(toDate(date, pattern)).getTime() / 1000;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,19 +1,25 @@
|
||||
package cn.lili.common.utils;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.xkcoding.http.HttpUtil;
|
||||
import com.xkcoding.http.config.HttpConfig;
|
||||
import com.xkcoding.http.support.HttpHeader;
|
||||
import com.xkcoding.http.support.httpclient.HttpClientImpl;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* HttpUtil 工具,统一处理 http 请求,方便对 simple-http 做定制
|
||||
*
|
||||
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
|
||||
* @version 4.1
|
||||
* @since 1.0.0
|
||||
* HTTP 工具类
|
||||
* @author liushuai
|
||||
*/
|
||||
@Slf4j
|
||||
public class HttpUtils {
|
||||
|
||||
public HttpUtils(HttpConfig config) {
|
||||
@@ -105,4 +111,258 @@ public class HttpUtils {
|
||||
public String post(String url, Map<String, String> params, HttpHeader header, boolean encode) {
|
||||
return HttpUtil.post(url, params, header, encode);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 静态方法运行参数
|
||||
*/
|
||||
public static final int HTTP_CONN_TIMEOUT = 100000;
|
||||
public static final int HTTP_SOCKET_TIMEOUT = 100000;
|
||||
|
||||
/**
|
||||
* POST 静态方法请求
|
||||
*
|
||||
* @param reqUrl
|
||||
* @param parameters
|
||||
* @param encoding
|
||||
* @param connectTimeout
|
||||
* @param readTimeout
|
||||
* @return
|
||||
*/
|
||||
public static String doPost(String reqUrl, Map<String, String> parameters, String encoding, int connectTimeout,
|
||||
int readTimeout) {
|
||||
HttpURLConnection urlConn = null;
|
||||
try {
|
||||
urlConn = sendPost(reqUrl, parameters, encoding, connectTimeout, readTimeout);
|
||||
String responseContent = getContent(urlConn, encoding);
|
||||
return responseContent.trim();
|
||||
} finally {
|
||||
if (urlConn != null) {
|
||||
urlConn.disconnect();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* post携带json请求 静态方法
|
||||
*
|
||||
* @param reqUrl 请求地址
|
||||
* @param jsonParameters 参数
|
||||
* @return
|
||||
*/
|
||||
public static String doPostWithJson(String reqUrl, Map<String, String> jsonParameters) {
|
||||
|
||||
BufferedReader reader = null;
|
||||
try {
|
||||
//创建连接
|
||||
URL url = new URL(reqUrl);
|
||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||
connection.setDoOutput(true);
|
||||
connection.setDoInput(true);
|
||||
connection.setUseCaches(false);
|
||||
connection.setInstanceFollowRedirects(true);
|
||||
//设置请求方式
|
||||
connection.setRequestMethod("POST");
|
||||
//设置发送数据的格式
|
||||
connection.setRequestProperty("Content-Type", "application/json");
|
||||
connection.connect();
|
||||
//一定要用BufferedReader 来接收响应, 使用字节来接收响应的方法是接收不到内容的
|
||||
//utf-8编码
|
||||
OutputStreamWriter out = new OutputStreamWriter(connection.getOutputStream(), StandardCharsets.UTF_8);
|
||||
out.append(JSONObject.toJSONString(jsonParameters));
|
||||
out.flush();
|
||||
out.close();
|
||||
//读取响应
|
||||
reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8));
|
||||
String line;
|
||||
String res = "";
|
||||
while ((line = reader.readLine()) != null) {
|
||||
res += line;
|
||||
}
|
||||
reader.close();
|
||||
|
||||
return res;
|
||||
} catch (IOException e) {
|
||||
log.error("post请求错误", e);
|
||||
}
|
||||
//自定义错误信息
|
||||
return "error";
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* post携带json请求 静态方法
|
||||
*
|
||||
* @param reqUrl 请求地址
|
||||
* @param object 对象
|
||||
* @return
|
||||
*/
|
||||
public static String doPostWithJson(String reqUrl, Object object) {
|
||||
|
||||
BufferedReader reader = null;
|
||||
try {
|
||||
//创建连接
|
||||
URL url = new URL(reqUrl);
|
||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||
connection.setDoOutput(true);
|
||||
connection.setDoInput(true);
|
||||
connection.setUseCaches(false);
|
||||
connection.setInstanceFollowRedirects(true);
|
||||
//设置请求方式
|
||||
connection.setRequestMethod("POST");
|
||||
//设置发送数据的格式
|
||||
connection.setRequestProperty("Content-Type", "application/json");
|
||||
connection.connect();
|
||||
//一定要用BufferedReader 来接收响应, 使用字节来接收响应的方法是接收不到内容的
|
||||
//utf-8编码
|
||||
OutputStreamWriter out = new OutputStreamWriter(connection.getOutputStream(), StandardCharsets.UTF_8);
|
||||
out.append(JSONObject.toJSONString(object));
|
||||
out.flush();
|
||||
out.close();
|
||||
//读取响应
|
||||
reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8));
|
||||
String line;
|
||||
String res = "";
|
||||
while ((line = reader.readLine()) != null) {
|
||||
res += line;
|
||||
}
|
||||
reader.close();
|
||||
|
||||
return res;
|
||||
} catch (IOException e) {
|
||||
log.error("post错误", e);
|
||||
}
|
||||
//自定义错误信息
|
||||
return "error";
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送post请求
|
||||
*
|
||||
* @param reqUrl
|
||||
* @param parameters
|
||||
* @param encoding
|
||||
* @param connectTimeout
|
||||
* @param readTimeout
|
||||
* @return
|
||||
*/
|
||||
private static HttpURLConnection sendPost(String reqUrl,
|
||||
Map<String, String> parameters, String encoding, int connectTimeout, int readTimeout) {
|
||||
HttpURLConnection urlConn = null;
|
||||
try {
|
||||
String params = generatorParamString(parameters, encoding);
|
||||
URL url = new URL(reqUrl);
|
||||
urlConn = (HttpURLConnection) url.openConnection();
|
||||
urlConn.setRequestMethod("POST");
|
||||
//(单位:毫秒)jdk
|
||||
urlConn.setConnectTimeout(connectTimeout);
|
||||
//(单位:毫秒)jdk 1.5换成这个,读操作超时
|
||||
urlConn.setReadTimeout(readTimeout);
|
||||
urlConn.setDoOutput(true);
|
||||
//String按照字节处理是一个好方法
|
||||
byte[] b = params.getBytes(encoding);
|
||||
urlConn.getOutputStream().write(b, 0, b.length);
|
||||
urlConn.getOutputStream().flush();
|
||||
urlConn.getOutputStream().close();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e.getMessage(), e);
|
||||
}
|
||||
return urlConn;
|
||||
}
|
||||
|
||||
/**
|
||||
* get 请求 静态方法
|
||||
*
|
||||
* @param urlConn
|
||||
* @param encoding
|
||||
* @return
|
||||
*/
|
||||
private static String getContent(HttpURLConnection urlConn, String encoding) {
|
||||
try {
|
||||
String responseContent = null;
|
||||
InputStream in = urlConn.getInputStream();
|
||||
BufferedReader rd = new BufferedReader(new InputStreamReader(in, encoding));
|
||||
String tempLine = rd.readLine();
|
||||
StringBuffer tempStr = new StringBuffer();
|
||||
String crlf = System.getProperty("line.separator");
|
||||
while (tempLine != null) {
|
||||
tempStr.append(tempLine);
|
||||
tempStr.append(crlf);
|
||||
tempLine = rd.readLine();
|
||||
}
|
||||
responseContent = tempStr.toString();
|
||||
rd.close();
|
||||
in.close();
|
||||
return responseContent;
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get 请求 静态方法
|
||||
*
|
||||
* @param link
|
||||
* @param encoding
|
||||
* @return
|
||||
*/
|
||||
public static String doGet(String link, String encoding, int connectTimeout, int readTimeout) {
|
||||
HttpURLConnection conn = null;
|
||||
try {
|
||||
URL url = new URL(link);
|
||||
conn = (HttpURLConnection) url.openConnection();
|
||||
conn.setRequestMethod("GET");
|
||||
conn.setConnectTimeout(connectTimeout);
|
||||
conn.setReadTimeout(readTimeout);
|
||||
BufferedInputStream in = new BufferedInputStream(
|
||||
conn.getInputStream());
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
byte[] buf = new byte[1024];
|
||||
for (int i = 0; (i = in.read(buf)) > 0; ) {
|
||||
out.write(buf, 0, i);
|
||||
}
|
||||
out.flush();
|
||||
String s = out.toString(encoding);
|
||||
return s;
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e.getMessage(), e);
|
||||
} finally {
|
||||
if (conn != null) {
|
||||
conn.disconnect();
|
||||
conn = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 将parameters中数据转换成用"&"链接的http请求参数形式
|
||||
*
|
||||
* @param parameters
|
||||
* @return
|
||||
*/
|
||||
private static String generatorParamString(Map<String, String> parameters, String encoding) {
|
||||
StringBuffer params = new StringBuffer();
|
||||
if (parameters != null) {
|
||||
for (Iterator<String> iter = parameters.keySet().iterator(); iter
|
||||
.hasNext(); ) {
|
||||
String name = iter.next();
|
||||
String value = parameters.get(name);
|
||||
params.append(name + "=");
|
||||
try {
|
||||
params.append(URLEncoder.encode(value, encoding));
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
throw new RuntimeException(e.getMessage(), e);
|
||||
} catch (Exception e) {
|
||||
String message = String.format("'%s'='%s'", name, value);
|
||||
throw new RuntimeException(message, e);
|
||||
}
|
||||
if (iter.hasNext()) {
|
||||
params.append("&");
|
||||
}
|
||||
}
|
||||
}
|
||||
return params.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package cn.lili.modules.connect.util;
|
||||
package cn.lili.common.utils;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
@@ -1,5 +1,6 @@
|
||||
package cn.lili.common.vo;
|
||||
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import cn.lili.common.utils.StringUtils;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
@@ -31,17 +32,8 @@ public class PageVO implements Serializable {
|
||||
@ApiModelProperty(value = "需要驼峰转换蛇形", notes = "一般不做处理,如果数据库中就是蛇形,则这块需要处理。")
|
||||
private Boolean notConvert;
|
||||
|
||||
public Integer getMongoPageNumber() {
|
||||
int i = pageNumber - 1;
|
||||
if (i < 0) {
|
||||
return pageNumber;
|
||||
} else {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
public String getSort() {
|
||||
if (!StringUtils.isEmpty(sort)) {
|
||||
if (CharSequenceUtil.isNotEmpty(sort)) {
|
||||
if (notConvert == null || Boolean.FALSE.equals(notConvert)) {
|
||||
return StringUtils.camel2Underline(sort);
|
||||
} else {
|
||||
|
||||
@@ -31,8 +31,7 @@ public class SearchVO implements Serializable {
|
||||
if (StringUtils.isEmpty(startDate)) {
|
||||
return null;
|
||||
}
|
||||
Date date = DateUtil.toDate(startDate, DateUtil.STANDARD_DATE_FORMAT);
|
||||
return date;
|
||||
return DateUtil.toDate(startDate, DateUtil.STANDARD_DATE_FORMAT);
|
||||
}
|
||||
|
||||
public Date getConvertEndDate() {
|
||||
|
||||
@@ -244,7 +244,7 @@ public abstract class BaseElasticsearchService {
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
" },\n" +
|
||||
" \"isAuth\": {\n" +
|
||||
" \"authFlag\": {\n" +
|
||||
" \"type\": \"text\",\n" +
|
||||
" \"fields\": {\n" +
|
||||
" \"keyword\": {\n" +
|
||||
@@ -331,6 +331,9 @@ public abstract class BaseElasticsearchService {
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
" },\n" +
|
||||
" \"promotionMapJson\": {\n" +
|
||||
" \"type\": \"text\"\n" +
|
||||
" },\n" +
|
||||
" \"thumbnail\": {\n" +
|
||||
" \"type\": \"text\",\n" +
|
||||
" \"fields\": {\n" +
|
||||
|
||||
@@ -13,4 +13,9 @@ public class EsSuffix {
|
||||
*/
|
||||
public static final String GOODS_INDEX_NAME = "goods";
|
||||
|
||||
/**
|
||||
* 日志索引后缀
|
||||
*/
|
||||
public static final String LOGS_INDEX_NAME = "logs";
|
||||
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.elasticsearch.config.AbstractElasticsearchConfiguration;
|
||||
import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate;
|
||||
|
||||
import javax.annotation.PreDestroy;
|
||||
import java.io.IOException;
|
||||
@@ -56,18 +57,23 @@ public class ElasticsearchConfig extends AbstractElasticsearchConfiguration {
|
||||
.setDefaultCredentialsProvider(credential)
|
||||
.setKeepAliveStrategy(getConnectionKeepAliveStrategy())
|
||||
.setMaxConnPerRoute(10)
|
||||
.setDefaultIOReactorConfig(IOReactorConfig.custom().setIoThreadCount(1).build()));
|
||||
.setDefaultIOReactorConfig(IOReactorConfig.custom().setIoThreadCount(Runtime.getRuntime().availableProcessors()).build()));
|
||||
}
|
||||
|
||||
restBuilder.setRequestConfigCallback(requestConfigBuilder ->
|
||||
requestConfigBuilder.setConnectTimeout(1000) //time until a connection with the server is established.
|
||||
.setSocketTimeout(12 * 1000) //time of inactivity to wait for packets[data] to receive.
|
||||
.setConnectionRequestTimeout(2 * 1000)); //time to fetch a connection from the connection pool 0 for infinite.
|
||||
.setConnectionRequestTimeout(-1)); //time to fetch a connection from the connection pool 0 for infinite.
|
||||
|
||||
client = new RestHighLevelClient(restBuilder);
|
||||
return client;
|
||||
}
|
||||
|
||||
@Bean("elasticsearchRestTemplate")
|
||||
public ElasticsearchRestTemplate elasticsearchRestTemplate() {
|
||||
return new ElasticsearchRestTemplate(this.client);
|
||||
}
|
||||
|
||||
private HttpHost[] getHttpHosts() {
|
||||
List<String> clusterNodes = elasticsearchProperties.getClusterNodes();
|
||||
HttpHost[] httpHosts = new HttpHost[clusterNodes.size()];
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
package cn.lili.modules.connect.request;
|
||||
|
||||
import cn.lili.cache.Cache;
|
||||
import cn.lili.common.utils.HttpUtils;
|
||||
import cn.lili.common.utils.StringUtils;
|
||||
import cn.lili.common.utils.UrlBuilder;
|
||||
import cn.lili.common.utils.UuidUtils;
|
||||
import cn.lili.modules.connect.config.AuthConfig;
|
||||
import cn.lili.modules.connect.config.ConnectAuth;
|
||||
import cn.lili.modules.connect.entity.dto.AuthCallback;
|
||||
@@ -12,8 +14,6 @@ import cn.lili.modules.connect.entity.dto.ConnectAuthUser;
|
||||
import cn.lili.modules.connect.entity.enums.AuthResponseStatus;
|
||||
import cn.lili.modules.connect.exception.AuthException;
|
||||
import cn.lili.modules.connect.util.AuthChecker;
|
||||
import cn.lili.common.utils.HttpUtils;
|
||||
import cn.lili.modules.connect.util.UuidUtils;
|
||||
import com.xkcoding.http.util.UrlUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import cn.lili.common.security.token.Token;
|
||||
import cn.lili.modules.connect.entity.Connect;
|
||||
import cn.lili.modules.connect.entity.dto.ConnectAuthUser;
|
||||
import cn.lili.modules.connect.entity.dto.WechatMPLoginParams;
|
||||
import cn.lili.modules.member.entity.dto.ConnectQueryDTO;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import javax.naming.NoPermissionException;
|
||||
@@ -103,4 +104,12 @@ public interface ConnectService extends IService<Connect> {
|
||||
* @return token
|
||||
*/
|
||||
Token miniProgramAutoLogin(WechatMPLoginParams params);
|
||||
|
||||
/**
|
||||
* 根据查询dto获取查询对象
|
||||
*
|
||||
* @param connectQueryDTO
|
||||
* @return
|
||||
*/
|
||||
Connect queryConnect(ConnectQueryDTO connectQueryDTO);
|
||||
}
|
||||
@@ -12,6 +12,7 @@ import cn.lili.common.security.AuthUser;
|
||||
import cn.lili.common.security.context.UserContext;
|
||||
import cn.lili.common.security.token.Token;
|
||||
import cn.lili.common.utils.CookieUtil;
|
||||
import cn.lili.common.utils.HttpUtils;
|
||||
import cn.lili.common.utils.StringUtils;
|
||||
import cn.lili.modules.connect.entity.Connect;
|
||||
import cn.lili.modules.connect.entity.dto.ConnectAuthUser;
|
||||
@@ -20,6 +21,7 @@ import cn.lili.modules.connect.entity.enums.ConnectEnum;
|
||||
import cn.lili.modules.connect.mapper.ConnectMapper;
|
||||
import cn.lili.modules.connect.service.ConnectService;
|
||||
import cn.lili.modules.member.entity.dos.Member;
|
||||
import cn.lili.modules.member.entity.dto.ConnectQueryDTO;
|
||||
import cn.lili.modules.member.service.MemberService;
|
||||
import cn.lili.modules.member.token.MemberTokenGenerate;
|
||||
import cn.lili.modules.system.entity.dos.Setting;
|
||||
@@ -27,7 +29,6 @@ import cn.lili.modules.system.entity.dto.connect.WechatConnectSetting;
|
||||
import cn.lili.modules.system.entity.dto.connect.dto.WechatConnectSettingItem;
|
||||
import cn.lili.modules.system.entity.enums.SettingEnum;
|
||||
import cn.lili.modules.system.service.SettingService;
|
||||
import cn.lili.modules.system.utils.HttpUtils;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -232,6 +233,16 @@ public class ConnectServiceImpl extends ServiceImpl<ConnectMapper, Connect> impl
|
||||
return memberTokenGenerate.createToken(newMember.getUsername(), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Connect queryConnect(ConnectQueryDTO connectQueryDTO) {
|
||||
|
||||
LambdaQueryWrapper<Connect> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(StringUtils.isNotEmpty(connectQueryDTO.getUserId()), Connect::getUserId, connectQueryDTO.getUserId())
|
||||
.eq(StringUtils.isNotEmpty(connectQueryDTO.getUnionType()), Connect::getUnionType, connectQueryDTO.getUnionType())
|
||||
.eq(StringUtils.isNotEmpty(connectQueryDTO.getUnionId()), Connect::getUnionId, connectQueryDTO.getUnionId());
|
||||
return this.getOne(queryWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 会员绑定 绑定微信小程序
|
||||
* <p>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package cn.lili.modules.distribution.entity.dos;
|
||||
|
||||
import cn.lili.modules.member.entity.enums.WithdrawStatusEnum;
|
||||
import cn.lili.modules.wallet.entity.enums.WithdrawStatusEnum;
|
||||
import cn.lili.mybatis.BaseEntity;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
|
||||
@@ -5,7 +5,6 @@ import cn.lili.modules.order.order.entity.dos.StoreFlow;
|
||||
import cn.lili.mybatis.BaseIdEntity;
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
@@ -31,11 +30,6 @@ public class DistributionOrder extends BaseIdEntity {
|
||||
|
||||
private static final long serialVersionUID = 501799944909496507L;
|
||||
|
||||
@TableId
|
||||
@TableField
|
||||
@ApiModelProperty(value = "唯一标识", hidden = true)
|
||||
private String id;
|
||||
|
||||
@CreatedDate
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
package cn.lili.modules.distribution.entity.dto;
|
||||
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import cn.lili.common.security.context.UserContext;
|
||||
import cn.lili.common.utils.StringUtils;
|
||||
import cn.lili.common.vo.PageVO;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 分销员商品查询条件
|
||||
@@ -13,25 +16,35 @@ import lombok.Data;
|
||||
* @author pikachu
|
||||
* @since 2020-03-14 23:04:56
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class DistributionGoodsSearchParams extends PageVO {
|
||||
|
||||
@ApiModelProperty(value = "商品ID")
|
||||
private String goodsId;
|
||||
|
||||
@ApiModelProperty(value = "商品名称")
|
||||
private String goodsName;
|
||||
|
||||
@ApiModelProperty(value = "是否已选择")
|
||||
private boolean isChecked;
|
||||
|
||||
public <T> QueryWrapper<T> queryWrapper() {
|
||||
QueryWrapper<T> queryWrapper = this.distributionQueryWrapper();
|
||||
queryWrapper.eq(CharSequenceUtil.isNotEmpty(goodsId), "goods_id", goodsId);
|
||||
queryWrapper.eq(CharSequenceUtil.isNotEmpty(goodsName), "goods_name", goodsId);
|
||||
return queryWrapper;
|
||||
}
|
||||
|
||||
public <T> QueryWrapper<T> storeQueryWrapper() {
|
||||
QueryWrapper<T> queryWrapper = this.distributionQueryWrapper();
|
||||
queryWrapper.eq("dg.store_id", UserContext.getCurrentUser().getStoreId());
|
||||
queryWrapper.eq("dg.store_id", Objects.requireNonNull(UserContext.getCurrentUser()).getStoreId());
|
||||
return queryWrapper;
|
||||
}
|
||||
|
||||
public <T> QueryWrapper<T> distributionQueryWrapper() {
|
||||
QueryWrapper<T> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.like(StringUtils.isNotEmpty(goodsName), "dg.goods_name", goodsName);
|
||||
queryWrapper.like(CharSequenceUtil.isNotEmpty(goodsName), "dg.goods_name", goodsName);
|
||||
return queryWrapper;
|
||||
}
|
||||
|
||||
|
||||
@@ -49,10 +49,4 @@ public interface DistributionCashService extends IService<DistributionCash> {
|
||||
*/
|
||||
DistributionCash audit(@PathVariable String id, @RequestParam String result);
|
||||
|
||||
/**
|
||||
* 待处理分销员提现申请数量
|
||||
*
|
||||
* @return 待处理分销员提现申请数量
|
||||
*/
|
||||
Integer newDistributionCash();
|
||||
}
|
||||
@@ -21,10 +21,34 @@ public interface DistributionGoodsService extends IService<DistributionGoods> {
|
||||
* 根据条件分页查询分销商品信息
|
||||
*
|
||||
* @param distributionGoodsSearchParams 商品条件
|
||||
* @return
|
||||
* @return 分页分销商品信息
|
||||
*/
|
||||
IPage<DistributionGoodsVO> goodsPage(DistributionGoodsSearchParams distributionGoodsSearchParams);
|
||||
|
||||
|
||||
/**
|
||||
* 根据条件查询分销商品信息列表
|
||||
*
|
||||
* @param distributionGoodsSearchParams 条件
|
||||
* @return 分销商品信息列表
|
||||
*/
|
||||
List<DistributionGoods> getDistributionGoodsList(DistributionGoodsSearchParams distributionGoodsSearchParams);
|
||||
|
||||
/**
|
||||
* 根据条件查询分销商品信息
|
||||
*
|
||||
* @param distributionGoodsSearchParams 条件
|
||||
* @return 分销商品信息
|
||||
*/
|
||||
DistributionGoods getDistributionGoods(DistributionGoodsSearchParams distributionGoodsSearchParams);
|
||||
|
||||
/**
|
||||
* 根据条件删除分销商品
|
||||
*
|
||||
* @param distributionGoodsSearchParams 条件
|
||||
*/
|
||||
boolean deleteDistributionGoods(DistributionGoodsSearchParams distributionGoodsSearchParams);
|
||||
|
||||
/**
|
||||
* 获取分销商品
|
||||
*
|
||||
|
||||
@@ -13,14 +13,21 @@ public interface DistributionSelectedGoodsService extends IService<DistributionS
|
||||
/**
|
||||
* 分销员添加分销商品
|
||||
* @param distributionGoodsId 分销商品ID
|
||||
* @return
|
||||
* @return 是否添加成功
|
||||
*/
|
||||
boolean add(String distributionGoodsId);
|
||||
|
||||
/**
|
||||
* 分销员添加分销商品
|
||||
* 分销员删除分销商品
|
||||
* @param distributionGoodsId 分销商品ID
|
||||
* @return
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
boolean delete(String distributionGoodsId);
|
||||
|
||||
/**
|
||||
* 分销员删除分销商品(管理员操作)
|
||||
* @param distributionGoodsId 分销商品ID
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
boolean deleteByDistributionGoodsId(String distributionGoodsId);
|
||||
}
|
||||
|
||||
@@ -2,14 +2,10 @@ package cn.lili.modules.distribution.serviceimpl;
|
||||
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.exception.ServiceException;
|
||||
import cn.lili.modules.member.entity.enums.WithdrawStatusEnum;
|
||||
import cn.lili.rocketmq.RocketmqSendCallbackBuilder;
|
||||
import cn.lili.rocketmq.tags.MemberTagsEnum;
|
||||
import cn.lili.common.properties.RocketmqCustomProperties;
|
||||
import cn.lili.common.utils.CurrencyUtil;
|
||||
import cn.lili.mybatis.util.PageUtil;
|
||||
import cn.lili.common.utils.SnowFlake;
|
||||
import cn.lili.common.vo.PageVO;
|
||||
import cn.lili.common.properties.RocketmqCustomProperties;
|
||||
import cn.lili.modules.distribution.entity.dos.Distribution;
|
||||
import cn.lili.modules.distribution.entity.dos.DistributionCash;
|
||||
import cn.lili.modules.distribution.entity.enums.DistributionStatusEnum;
|
||||
@@ -17,13 +13,17 @@ import cn.lili.modules.distribution.entity.vos.DistributionCashSearchParams;
|
||||
import cn.lili.modules.distribution.mapper.DistributionCashMapper;
|
||||
import cn.lili.modules.distribution.service.DistributionCashService;
|
||||
import cn.lili.modules.distribution.service.DistributionService;
|
||||
import cn.lili.modules.member.entity.dto.MemberWithdrawalMessage;
|
||||
import cn.lili.modules.member.entity.enums.MemberWithdrawalDestinationEnum;
|
||||
import cn.lili.modules.member.service.MemberWalletService;
|
||||
import cn.lili.modules.order.trade.entity.enums.DepositServiceTypeEnum;
|
||||
import cn.lili.modules.wallet.entity.dto.MemberWalletUpdateDTO;
|
||||
import cn.lili.modules.wallet.entity.dto.MemberWithdrawalMessage;
|
||||
import cn.lili.modules.wallet.entity.enums.DepositServiceTypeEnum;
|
||||
import cn.lili.modules.wallet.entity.enums.MemberWithdrawalDestinationEnum;
|
||||
import cn.lili.modules.wallet.entity.enums.WithdrawStatusEnum;
|
||||
import cn.lili.modules.wallet.service.MemberWalletService;
|
||||
import cn.lili.mybatis.util.PageUtil;
|
||||
import cn.lili.rocketmq.RocketmqSendCallbackBuilder;
|
||||
import cn.lili.rocketmq.tags.MemberTagsEnum;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.apache.rocketmq.spring.core.RocketMQTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -130,7 +130,7 @@ public class DistributionCashServiceImpl extends ServiceImpl<DistributionCashMap
|
||||
distributorCash.setDistributionCashStatus(WithdrawStatusEnum.VIA_AUDITING.name());
|
||||
distributorCash.setPayTime(new Date());
|
||||
//提现到余额
|
||||
memberWalletService.increase(distributorCash.getPrice(), distribution.getMemberId(), "分销[" + distributorCash.getSn() + "]佣金提现到余额[" + distributorCash.getPrice() + "]", DepositServiceTypeEnum.WALLET_COMMISSION.name());
|
||||
memberWalletService.increase(new MemberWalletUpdateDTO(distributorCash.getPrice(), distribution.getMemberId(), "分销[" + distributorCash.getSn() + "]佣金提现到余额[" + distributorCash.getPrice() + "]", DepositServiceTypeEnum.WALLET_COMMISSION.name()));
|
||||
} else {
|
||||
memberWithdrawalMessage.setStatus(WithdrawStatusEnum.FAIL_AUDITING.name());
|
||||
//分销员可提现金额退回
|
||||
@@ -156,11 +156,4 @@ public class DistributionCashServiceImpl extends ServiceImpl<DistributionCashMap
|
||||
throw new ServiceException(ResultCode.DISTRIBUTION_CASH_NOT_EXIST);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer newDistributionCash() {
|
||||
QueryWrapper queryWrapper = Wrappers.query();
|
||||
queryWrapper.eq("distribution_cash_status", WithdrawStatusEnum.APPLY.name());
|
||||
return this.count(queryWrapper);
|
||||
}
|
||||
}
|
||||
@@ -70,6 +70,38 @@ public class DistributionGoodsServiceImpl extends ServiceImpl<DistributionGoodsM
|
||||
return this.baseMapper.getDistributionGoodsVO(PageUtil.initPage(searchParams), searchParams.distributionQueryWrapper());
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据条件查询分销商品信息列表
|
||||
*
|
||||
* @param distributionGoodsSearchParams 商品条件
|
||||
* @return 分销商品信息列表
|
||||
*/
|
||||
@Override
|
||||
public List<DistributionGoods> getDistributionGoodsList(DistributionGoodsSearchParams distributionGoodsSearchParams) {
|
||||
return this.list(distributionGoodsSearchParams.queryWrapper());
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据条件查询分销商品信息
|
||||
*
|
||||
* @param distributionGoodsSearchParams 条件
|
||||
* @return 分销商品信息
|
||||
*/
|
||||
@Override
|
||||
public DistributionGoods getDistributionGoods(DistributionGoodsSearchParams distributionGoodsSearchParams) {
|
||||
return this.getOne(distributionGoodsSearchParams.queryWrapper(), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据条件删除分销商品
|
||||
*
|
||||
* @param distributionGoodsSearchParams 条件
|
||||
*/
|
||||
@Override
|
||||
public boolean deleteDistributionGoods(DistributionGoodsSearchParams distributionGoodsSearchParams) {
|
||||
return this.remove(distributionGoodsSearchParams.queryWrapper());
|
||||
}
|
||||
|
||||
@Override
|
||||
public DistributionGoods distributionGoodsVO(String id) {
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@ import cn.hutool.core.date.DateField;
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import cn.lili.common.utils.CurrencyUtil;
|
||||
import cn.lili.mybatis.util.PageUtil;
|
||||
import cn.lili.modules.distribution.entity.dos.Distribution;
|
||||
import cn.lili.modules.distribution.entity.dos.DistributionOrder;
|
||||
import cn.lili.modules.distribution.entity.enums.DistributionOrderStatusEnum;
|
||||
@@ -14,6 +13,7 @@ import cn.lili.modules.distribution.service.DistributionOrderService;
|
||||
import cn.lili.modules.distribution.service.DistributionService;
|
||||
import cn.lili.modules.order.order.entity.dos.Order;
|
||||
import cn.lili.modules.order.order.entity.dos.StoreFlow;
|
||||
import cn.lili.modules.order.order.entity.dto.StoreFlowQueryDTO;
|
||||
import cn.lili.modules.order.order.entity.enums.PayStatusEnum;
|
||||
import cn.lili.modules.order.order.service.OrderService;
|
||||
import cn.lili.modules.order.order.service.StoreFlowService;
|
||||
@@ -21,6 +21,7 @@ import cn.lili.modules.system.entity.dos.Setting;
|
||||
import cn.lili.modules.system.entity.dto.DistributionSetting;
|
||||
import cn.lili.modules.system.entity.enums.SettingEnum;
|
||||
import cn.lili.modules.system.service.SettingService;
|
||||
import cn.lili.mybatis.util.PageUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
@@ -87,10 +88,9 @@ public class DistributionOrderServiceImpl extends ServiceImpl<DistributionOrderM
|
||||
//判断是否为分销订单,如果为分销订单则获取分销佣金
|
||||
if (order.getDistributionId() != null) {
|
||||
//根据订单编号获取有分销金额的店铺流水记录
|
||||
List<StoreFlow> storeFlowList = storeFlowService.list(new LambdaQueryWrapper<StoreFlow>()
|
||||
.eq(StoreFlow::getOrderSn, orderSn)
|
||||
.isNotNull(StoreFlow::getDistributionRebate));
|
||||
Double rebate = 0.0;
|
||||
List<StoreFlow> storeFlowList = storeFlowService
|
||||
.listStoreFlow(StoreFlowQueryDTO.builder().justDistribution(true).orderSn(orderSn).build());
|
||||
double rebate = 0.0;
|
||||
//循环店铺流水记录判断是否包含分销商品
|
||||
//包含分销商品则进行记录分销订单、计算分销总额
|
||||
for (StoreFlow storeFlow : storeFlowList) {
|
||||
@@ -165,7 +165,7 @@ public class DistributionOrderServiceImpl extends ServiceImpl<DistributionOrderM
|
||||
return;
|
||||
}
|
||||
//分销金额
|
||||
Double rebate = 0.0;
|
||||
double rebate = 0.0;
|
||||
|
||||
//包含分销商品则进行记录分销订单、计算分销总额
|
||||
for (DistributionOrder distributionOrder : distributionOrderList) {
|
||||
@@ -187,9 +187,7 @@ public class DistributionOrderServiceImpl extends ServiceImpl<DistributionOrderM
|
||||
@Override
|
||||
public void refundOrder(String afterSaleSn) {
|
||||
//判断是否为分销订单
|
||||
StoreFlow storeFlow = storeFlowService.getOne(new LambdaQueryWrapper<StoreFlow>()
|
||||
.eq(StoreFlow::getRefundSn, afterSaleSn)
|
||||
.isNotNull(StoreFlow::getDistributionRebate));
|
||||
StoreFlow storeFlow = storeFlowService.queryOne(StoreFlowQueryDTO.builder().justDistribution(true).refundSn(afterSaleSn).build());
|
||||
if (storeFlow != null) {
|
||||
|
||||
//获取收款分销订单
|
||||
@@ -199,12 +197,7 @@ public class DistributionOrderServiceImpl extends ServiceImpl<DistributionOrderM
|
||||
if (distributionOrder == null) {
|
||||
return;
|
||||
}
|
||||
//已提交无法重复提交
|
||||
if (distributionOrder.getDistributionOrderStatus().equals(DistributionOrderStatusEnum.CANCEL.name())) {
|
||||
return;
|
||||
}
|
||||
//如果未结算则将分销订单取消
|
||||
else if (distributionOrder.getDistributionOrderStatus().equals(DistributionOrderStatusEnum.WAIT_BILL.name())) {
|
||||
if (distributionOrder.getDistributionOrderStatus().equals(DistributionOrderStatusEnum.WAIT_BILL.name())) {
|
||||
this.update(new LambdaUpdateWrapper<DistributionOrder>()
|
||||
.eq(DistributionOrder::getOrderItemSn, storeFlow.getOrderItemSn())
|
||||
.set(DistributionOrder::getDistributionOrderStatus, DistributionOrderStatusEnum.CANCEL.name()));
|
||||
|
||||
@@ -46,4 +46,10 @@ public class DistributionSelectedGoodsServiceImpl extends ServiceImpl<Distributi
|
||||
.eq(DistributionSelectedGoods::getDistributionGoodsId, distributionGoodsId)
|
||||
.eq(DistributionSelectedGoods::getDistributionId, distributionId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteByDistributionGoodsId(String distributionGoodsId) {
|
||||
return this.remove(new LambdaQueryWrapper<DistributionSelectedGoods>()
|
||||
.eq(DistributionSelectedGoods::getDistributionGoodsId, distributionGoodsId));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,13 +37,4 @@ public interface FileManagerPlugin {
|
||||
*/
|
||||
void deleteFile(List<String> key);
|
||||
|
||||
/**
|
||||
* 根据原图生成规定尺寸的图片
|
||||
*
|
||||
* @param url 连接
|
||||
* @param width 宽
|
||||
* @param height 高
|
||||
* @return
|
||||
*/
|
||||
String getUrl(String url, Integer width, Integer height);
|
||||
}
|
||||
|
||||
@@ -183,11 +183,4 @@ public class AliFileManagerPlugin implements FileManagerPlugin {
|
||||
ossClient.shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUrl(String url, Integer width, Integer height) {
|
||||
//缩略图全路径
|
||||
//返回缩略图全路径
|
||||
return url + "?x-oss-process=style/" + width + "X" + height;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package cn.lili.modules.file.util;
|
||||
|
||||
/**
|
||||
* FileUtil
|
||||
*
|
||||
* @author Chopper
|
||||
* @version v1.0
|
||||
* 2021-11-22 11:19
|
||||
*/
|
||||
public class FileUtil {
|
||||
|
||||
/**
|
||||
* 根据原图生成规定尺寸的图片
|
||||
*
|
||||
* @param url 连接
|
||||
* @param width 宽
|
||||
* @param height 高
|
||||
* @return
|
||||
*/
|
||||
public static String getUrl(String url, Integer width, Integer height) {
|
||||
//缩略图全路径
|
||||
return url + "?x-oss-process=style/" + width + "X" + height;
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.exception.ServiceException;
|
||||
import cn.lili.modules.goods.entity.dto.GoodsOperationDTO;
|
||||
import cn.lili.modules.goods.entity.enums.GoodsStatusEnum;
|
||||
import cn.lili.modules.goods.entity.enums.GoodsTypeEnum;
|
||||
import cn.lili.mybatis.BaseEntity;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
@@ -107,7 +108,7 @@ public class Goods extends BaseEntity {
|
||||
private String templateId;
|
||||
|
||||
@ApiModelProperty(value = "审核状态")
|
||||
private String isAuth;
|
||||
private String authFlag;
|
||||
|
||||
@ApiModelProperty(value = "审核信息")
|
||||
private String authMessage;
|
||||
@@ -171,20 +172,20 @@ public class Goods extends BaseEntity {
|
||||
//循环sku,判定sku是否有效
|
||||
for (Map<String, Object> sku : goodsOperationDTO.getSkuList()) {
|
||||
//判定参数不能为空
|
||||
if (sku.get("sn") == null) {
|
||||
if (!sku.containsKey("sn") || sku.get("sn") == null) {
|
||||
throw new ServiceException(ResultCode.GOODS_SKU_SN_ERROR);
|
||||
}
|
||||
if (StringUtil.isEmpty(sku.get("price").toString()) || Convert.toDouble(sku.get("price")) <= 0) {
|
||||
if (!sku.containsKey("price") || StringUtil.isEmpty(sku.get("price").toString()) || Convert.toDouble(sku.get("price")) <= 0) {
|
||||
throw new ServiceException(ResultCode.GOODS_SKU_PRICE_ERROR);
|
||||
}
|
||||
if (StringUtil.isEmpty(sku.get("cost").toString()) || Convert.toDouble(sku.get("cost")) <= 0) {
|
||||
if (!sku.containsKey("cost") || StringUtil.isEmpty(sku.get("cost").toString()) || Convert.toDouble(sku.get("cost")) <= 0) {
|
||||
throw new ServiceException(ResultCode.GOODS_SKU_COST_ERROR);
|
||||
}
|
||||
//虚拟商品没有重量字段
|
||||
if (sku.containsKey("weight") && (StringUtil.isEmpty(sku.get("weight").toString()) || Convert.toDouble(sku.get("weight").toString()) < 0)) {
|
||||
if (this.goodsType.equals(GoodsTypeEnum.PHYSICAL_GOODS.name()) && (!sku.containsKey("weight") || sku.containsKey("weight") && (StringUtil.isEmpty(sku.get("weight").toString()) || Convert.toDouble(sku.get("weight").toString()) < 0))) {
|
||||
throw new ServiceException(ResultCode.GOODS_SKU_WEIGHT_ERROR);
|
||||
}
|
||||
if (StringUtil.isEmpty(sku.get("quantity").toString()) || Convert.toInt(sku.get("quantity").toString()) < 0) {
|
||||
if (!sku.containsKey("quantity") || StringUtil.isEmpty(sku.get("quantity").toString()) || Convert.toInt(sku.get("quantity").toString()) < 0) {
|
||||
throw new ServiceException(ResultCode.GOODS_SKU_QUANTITY_ERROR);
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ public class GoodsSku extends BaseEntity {
|
||||
private String freightTemplateId;
|
||||
|
||||
@ApiModelProperty(value = "是否是促销商品")
|
||||
private Boolean isPromotion;
|
||||
private Boolean promotionFlag;
|
||||
|
||||
@ApiModelProperty(value = "促销价")
|
||||
private Double promotionPrice;
|
||||
@@ -130,7 +130,7 @@ public class GoodsSku extends BaseEntity {
|
||||
* @see GoodsAuthEnum
|
||||
*/
|
||||
@ApiModelProperty(value = "审核状态")
|
||||
private String isAuth;
|
||||
private String authFlag;
|
||||
|
||||
@ApiModelProperty(value = "审核信息")
|
||||
private String authMessage;
|
||||
|
||||
@@ -9,6 +9,8 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* 商品查询条件
|
||||
*
|
||||
@@ -58,10 +60,13 @@ public class GoodsSearchParams extends PageVO {
|
||||
* @see GoodsAuthEnum
|
||||
*/
|
||||
@ApiModelProperty(value = "审核状态")
|
||||
private String isAuth;
|
||||
private String authFlag;
|
||||
|
||||
@ApiModelProperty(value = "库存数量")
|
||||
private Integer quantity;
|
||||
private Integer leQuantity;
|
||||
|
||||
@ApiModelProperty(value = "库存数量")
|
||||
private Integer geQuantity;
|
||||
|
||||
@ApiModelProperty(value = "是否为推荐商品")
|
||||
private Boolean recommend;
|
||||
@@ -81,7 +86,7 @@ public class GoodsSearchParams extends PageVO {
|
||||
queryWrapper.like("goods_name", goodsName);
|
||||
}
|
||||
if (CharSequenceUtil.isNotEmpty(id)) {
|
||||
queryWrapper.eq("id", id);
|
||||
queryWrapper.in("id", Arrays.asList(id.split(",")));
|
||||
}
|
||||
if (CharSequenceUtil.isNotEmpty(storeId)) {
|
||||
queryWrapper.eq("store_id", storeId);
|
||||
@@ -101,11 +106,14 @@ public class GoodsSearchParams extends PageVO {
|
||||
if (CharSequenceUtil.isNotEmpty(marketEnable)) {
|
||||
queryWrapper.eq("market_enable", marketEnable);
|
||||
}
|
||||
if (CharSequenceUtil.isNotEmpty(isAuth)) {
|
||||
queryWrapper.eq("is_auth", isAuth);
|
||||
if (CharSequenceUtil.isNotEmpty(authFlag)) {
|
||||
queryWrapper.eq("auth_flag", authFlag);
|
||||
}
|
||||
if (quantity != null) {
|
||||
queryWrapper.le("quantity", quantity);
|
||||
if (leQuantity != null) {
|
||||
queryWrapper.le("quantity", leQuantity);
|
||||
}
|
||||
if (geQuantity != null) {
|
||||
queryWrapper.ge("quantity", geQuantity);
|
||||
}
|
||||
if (recommend != null) {
|
||||
queryWrapper.le("recommend", recommend);
|
||||
@@ -123,9 +131,9 @@ public class GoodsSearchParams extends PageVO {
|
||||
if (CharSequenceUtil.isNotEmpty(price)) {
|
||||
String[] s = price.split("_");
|
||||
if (s.length > 1) {
|
||||
queryWrapper.ge("price", s[1]);
|
||||
queryWrapper.between("price", s[0], s[1]);
|
||||
} else {
|
||||
queryWrapper.le("price", s[0]);
|
||||
queryWrapper.ge("price", s[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
package cn.lili.modules.goods.entity.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
/**
|
||||
* 用于直播间前台使用的直播间商品DTO
|
||||
*
|
||||
* @author Bulbasaur
|
||||
* @since 2021/5/20 2:34 下午
|
||||
*/
|
||||
public class SimpleCommodity {
|
||||
|
||||
@ApiModelProperty(value = "图片")
|
||||
private String goodsImage;
|
||||
|
||||
@ApiModelProperty(value = "商品名称")
|
||||
private String name;
|
||||
}
|
||||
@@ -2,6 +2,9 @@ package cn.lili.modules.goods.mapper;
|
||||
|
||||
import cn.lili.modules.goods.entity.dos.GoodsSku;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 规格项数据处理层
|
||||
@@ -11,4 +14,13 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
*/
|
||||
public interface GoodsSkuMapper extends BaseMapper<GoodsSku> {
|
||||
|
||||
/**
|
||||
* 根据商品id获取全部skuId的集合
|
||||
*
|
||||
* @param goodsId goodsId
|
||||
* @return 全部skuId的集合
|
||||
*/
|
||||
@Select("SELECT id FROM li_goods_sku WHERE goods_id = #{goodsId}")
|
||||
List<String> getGoodsSkuIdByGoodsId(String goodsId);
|
||||
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import cn.lili.modules.goods.entity.dto.GoodsSearchParams;
|
||||
import cn.lili.modules.goods.entity.enums.GoodsAuthEnum;
|
||||
import cn.lili.modules.goods.entity.enums.GoodsStatusEnum;
|
||||
import cn.lili.modules.goods.entity.vos.GoodsVO;
|
||||
import cn.lili.modules.store.entity.dos.Store;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
@@ -48,7 +49,7 @@ public interface GoodsService extends IService<Goods> {
|
||||
* @param categoryId 分类ID
|
||||
* @return 商品数量
|
||||
*/
|
||||
Integer getGoodsCountByCategory(String categoryId);
|
||||
long getGoodsCountByCategory(String categoryId);
|
||||
|
||||
/**
|
||||
* 添加商品
|
||||
@@ -82,6 +83,15 @@ public interface GoodsService extends IService<Goods> {
|
||||
*/
|
||||
IPage<Goods> queryByParams(GoodsSearchParams goodsSearchParams);
|
||||
|
||||
|
||||
/**
|
||||
* 商品查询
|
||||
*
|
||||
* @param goodsSearchParams 查询参数
|
||||
* @return 商品信息
|
||||
*/
|
||||
List<Goods> queryListByParams(GoodsSearchParams goodsSearchParams);
|
||||
|
||||
/**
|
||||
* 批量审核商品
|
||||
*
|
||||
@@ -91,21 +101,6 @@ public interface GoodsService extends IService<Goods> {
|
||||
*/
|
||||
boolean auditGoods(List<String> goodsIds, GoodsAuthEnum goodsAuthEnum);
|
||||
|
||||
/**
|
||||
* 获取所有的已上架的商品数量
|
||||
*
|
||||
* @param goodsAuthEnum 商品审核枚举
|
||||
* @param goodsStatusEnum 商品状态枚举
|
||||
* @return 所有的已上架的商品数量
|
||||
*/
|
||||
Integer goodsNum(GoodsStatusEnum goodsStatusEnum, GoodsAuthEnum goodsAuthEnum);
|
||||
|
||||
/**
|
||||
* 获取今天的已上架的商品数量
|
||||
*
|
||||
* @return 今天的已上架的商品数量
|
||||
*/
|
||||
Integer todayUpperNum();
|
||||
|
||||
/**
|
||||
* 更新商品上架状态状态
|
||||
@@ -117,6 +112,15 @@ public interface GoodsService extends IService<Goods> {
|
||||
*/
|
||||
Boolean updateGoodsMarketAble(List<String> goodsIds, GoodsStatusEnum goodsStatusEnum, String underReason);
|
||||
|
||||
/**
|
||||
* 更新商品上架状态状态
|
||||
*
|
||||
* @param goodsIds 商品ID集合
|
||||
* @param goodsStatusEnum 更新的商品状态
|
||||
* @param underReason 下架原因
|
||||
* @return 更新结果
|
||||
*/
|
||||
Boolean managerUpdateGoodsMarketAble(List<String> goodsIds, GoodsStatusEnum goodsStatusEnum, String underReason);
|
||||
/**
|
||||
* 删除商品
|
||||
*
|
||||
@@ -143,9 +147,30 @@ public interface GoodsService extends IService<Goods> {
|
||||
void updateStock(String goodsId, Integer quantity);
|
||||
|
||||
/**
|
||||
* 更新SKU评价数量
|
||||
* 更新商品评价数量
|
||||
*
|
||||
* @param goodsId 商品ID
|
||||
*/
|
||||
void updateGoodsCommentNum(String goodsId);
|
||||
|
||||
/**
|
||||
* 更新商品的购买数量
|
||||
*
|
||||
* @param goodsId 商品ID
|
||||
* @param buyCount 购买数量
|
||||
*/
|
||||
void updateGoodsBuyCount(String goodsId, int buyCount);
|
||||
|
||||
/**
|
||||
* 批量更新商品的店铺信息
|
||||
* @param store
|
||||
*/
|
||||
void updateStoreDetail(Store store);
|
||||
/**
|
||||
* 统计店铺的商品数量
|
||||
* @param storeId 店铺id
|
||||
* @return
|
||||
*/
|
||||
long countStoreGoodsNum(String storeId);
|
||||
|
||||
}
|
||||
@@ -136,10 +136,18 @@ public interface GoodsSkuService extends IService<GoodsSku> {
|
||||
*/
|
||||
IPage<GoodsSku> getGoodsSkuByPage(GoodsSearchParams searchParams);
|
||||
|
||||
/**
|
||||
* 列表查询商品sku信息
|
||||
*
|
||||
* @param searchParams 查询参数
|
||||
* @return 商品sku信息
|
||||
*/
|
||||
List<GoodsSku> getGoodsSkuByList(GoodsSearchParams searchParams);
|
||||
|
||||
/**
|
||||
* 更新商品sku状态
|
||||
*
|
||||
* @param goods 商品信息(Id,MarketEnable/IsAuth)
|
||||
* @param goods 商品信息(Id,MarketEnable/AuthFlag)
|
||||
*/
|
||||
void updateGoodsSkuStatus(Goods goods);
|
||||
|
||||
@@ -186,4 +194,20 @@ public interface GoodsSkuService extends IService<GoodsSku> {
|
||||
* @param skuId SKUId
|
||||
*/
|
||||
void updateGoodsSkuCommentNum(String skuId);
|
||||
|
||||
/**
|
||||
* 更新商品sku促销价格
|
||||
*
|
||||
* @param skuId skuId
|
||||
* @param promotionPrice 促销价格
|
||||
*/
|
||||
void updateGoodsSkuPromotion(String skuId, Double promotionPrice);
|
||||
|
||||
/**
|
||||
* 根据商品id获取全部skuId的集合
|
||||
*
|
||||
* @param goodsId goodsId
|
||||
* @return 全部skuId的集合
|
||||
*/
|
||||
List<String> getSkuIdsByGoodsId(String goodsId);
|
||||
}
|
||||
@@ -70,7 +70,7 @@ public class CommodityServiceImpl extends ServiceImpl<CommodityMapper, Commodity
|
||||
private void checkCommodity(Commodity commodity) {
|
||||
//商品是否审核通过
|
||||
GoodsSku goodsSku = goodsSkuService.getById(commodity.getSkuId());
|
||||
if (!goodsSku.getIsAuth().equals(GoodsAuthEnum.PASS.name())) {
|
||||
if (!goodsSku.getAuthFlag().equals(GoodsAuthEnum.PASS.name())) {
|
||||
throw new ServiceException(goodsSku.getGoodsName() + " 未审核通过,不能添加直播商品");
|
||||
}
|
||||
//是否已添加规格商品
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package cn.lili.modules.goods.serviceimpl;
|
||||
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import cn.lili.modules.file.plugin.FileManagerPlugin;
|
||||
import cn.lili.modules.file.util.FileUtil;
|
||||
import cn.lili.modules.goods.entity.dos.GoodsGallery;
|
||||
import cn.lili.modules.goods.mapper.GoodsGalleryMapper;
|
||||
import cn.lili.modules.goods.service.GoodsGalleryService;
|
||||
@@ -29,11 +29,6 @@ import java.util.List;
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class GoodsGalleryServiceImpl extends ServiceImpl<GoodsGalleryMapper, GoodsGallery> implements GoodsGalleryService {
|
||||
/**
|
||||
* 文件
|
||||
*/
|
||||
@Autowired
|
||||
private FileManagerPlugin fileManagerPlugin;
|
||||
/**
|
||||
* 设置
|
||||
*/
|
||||
@@ -65,9 +60,9 @@ public class GoodsGalleryServiceImpl extends ServiceImpl<GoodsGalleryMapper, Goo
|
||||
Setting setting = settingService.get(SettingEnum.GOODS_SETTING.name());
|
||||
GoodsSetting goodsSetting = JSONUtil.toBean(setting.getSettingValue(), GoodsSetting.class);
|
||||
//缩略图
|
||||
String thumbnail = fileManagerPlugin.getUrl(origin, goodsSetting.getAbbreviationPictureWidth(), goodsSetting.getAbbreviationPictureHeight());
|
||||
String thumbnail = FileUtil.getUrl(origin, goodsSetting.getAbbreviationPictureWidth(), goodsSetting.getAbbreviationPictureHeight());
|
||||
//小图
|
||||
String small = fileManagerPlugin.getUrl(origin, goodsSetting.getSmallPictureWidth(), goodsSetting.getSmallPictureHeight());
|
||||
String small = FileUtil.getUrl(origin, goodsSetting.getSmallPictureWidth(), goodsSetting.getSmallPictureHeight());
|
||||
//赋值
|
||||
goodsGallery.setSmall(small);
|
||||
goodsGallery.setThumbnail(thumbnail);
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package cn.lili.modules.goods.serviceimpl;
|
||||
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
@@ -24,11 +22,15 @@ import cn.lili.modules.goods.entity.enums.GoodsStatusEnum;
|
||||
import cn.lili.modules.goods.entity.vos.GoodsSkuVO;
|
||||
import cn.lili.modules.goods.entity.vos.GoodsVO;
|
||||
import cn.lili.modules.goods.mapper.GoodsMapper;
|
||||
import cn.lili.modules.goods.service.*;
|
||||
import cn.lili.modules.goods.service.CategoryService;
|
||||
import cn.lili.modules.goods.service.GoodsGalleryService;
|
||||
import cn.lili.modules.goods.service.GoodsService;
|
||||
import cn.lili.modules.goods.service.GoodsSkuService;
|
||||
import cn.lili.modules.member.entity.dos.MemberEvaluation;
|
||||
import cn.lili.modules.member.entity.enums.EvaluationGradeEnum;
|
||||
import cn.lili.modules.member.service.MemberEvaluationService;
|
||||
import cn.lili.modules.store.entity.dos.FreightTemplate;
|
||||
import cn.lili.modules.store.entity.dos.Store;
|
||||
import cn.lili.modules.store.entity.vos.StoreVO;
|
||||
import cn.lili.modules.store.service.FreightTemplateService;
|
||||
import cn.lili.modules.store.service.StoreService;
|
||||
@@ -42,6 +44,7 @@ import cn.lili.rocketmq.tags.GoodsTagsEnum;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
@@ -51,10 +54,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 商品业务层实现
|
||||
@@ -107,11 +107,6 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
||||
*/
|
||||
@Autowired
|
||||
private RocketmqCustomProperties rocketmqCustomProperties;
|
||||
/**
|
||||
* 分类-参数
|
||||
*/
|
||||
@Autowired
|
||||
private CategoryParameterGroupService categoryParameterGroupService;
|
||||
|
||||
@Autowired
|
||||
private FreightTemplateService freightTemplateService;
|
||||
@@ -121,8 +116,8 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
||||
|
||||
@Override
|
||||
public List<Goods> getByBrandIds(List<String> brandIds) {
|
||||
LambdaQueryWrapper<Goods> lambdaQueryWrapper = new LambdaQueryWrapper<Goods> ();
|
||||
lambdaQueryWrapper.in(Goods::getBrandId,brandIds);
|
||||
LambdaQueryWrapper<Goods> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.in(Goods::getBrandId, brandIds);
|
||||
return list(lambdaQueryWrapper);
|
||||
}
|
||||
|
||||
@@ -149,7 +144,7 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Integer getGoodsCountByCategory(String categoryId) {
|
||||
public final long getGoodsCountByCategory(String categoryId) {
|
||||
QueryWrapper<Goods> queryWrapper = Wrappers.query();
|
||||
queryWrapper.like("category_path", categoryId);
|
||||
queryWrapper.eq("delete_flag", false);
|
||||
@@ -199,6 +194,9 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
||||
if (goodsOperationDTO.getGoodsGalleryList() != null && !goodsOperationDTO.getGoodsGalleryList().isEmpty()) {
|
||||
this.goodsGalleryService.add(goodsOperationDTO.getGoodsGalleryList(), goods.getId());
|
||||
}
|
||||
if (GoodsAuthEnum.TOBEAUDITED.name().equals(goods.getAuthFlag())) {
|
||||
this.deleteEsGoods(Collections.singletonList(goodsId));
|
||||
}
|
||||
cache.remove(CachePrefix.GOODS.getPrefix() + goodsId);
|
||||
}
|
||||
|
||||
@@ -246,7 +244,7 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
||||
if (CharSequenceUtil.isNotEmpty(goods.getParams())) {
|
||||
goodsVO.setGoodsParamsDTOList(JSONUtil.toList(goods.getParams(), GoodsParamsDTO.class));
|
||||
}
|
||||
|
||||
cache.put(CachePrefix.GOODS.getPrefix() + goodsId, goodsVO);
|
||||
return goodsVO;
|
||||
}
|
||||
|
||||
@@ -255,12 +253,23 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
||||
return this.page(PageUtil.initPage(goodsSearchParams), goodsSearchParams.queryWrapper());
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品查询
|
||||
*
|
||||
* @param goodsSearchParams 查询参数
|
||||
* @return 商品信息
|
||||
*/
|
||||
@Override
|
||||
public List<Goods> queryListByParams(GoodsSearchParams goodsSearchParams) {
|
||||
return this.list(goodsSearchParams.queryWrapper());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean auditGoods(List<String> goodsIds, GoodsAuthEnum goodsAuthEnum) {
|
||||
boolean result = false;
|
||||
for (String goodsId : goodsIds) {
|
||||
Goods goods = this.checkExist(goodsId);
|
||||
goods.setIsAuth(goodsAuthEnum.name());
|
||||
goods.setAuthFlag(goodsAuthEnum.name());
|
||||
result = this.updateById(goods);
|
||||
goodsSkuService.updateGoodsSkuStatus(goods);
|
||||
//删除之前的缓存
|
||||
@@ -273,33 +282,6 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer goodsNum(GoodsStatusEnum goodsStatusEnum, GoodsAuthEnum goodsAuthEnum) {
|
||||
LambdaQueryWrapper<Goods> queryWrapper = Wrappers.lambdaQuery();
|
||||
|
||||
queryWrapper.eq(Goods::getDeleteFlag, false);
|
||||
|
||||
if (goodsStatusEnum != null) {
|
||||
queryWrapper.eq(Goods::getMarketEnable, goodsStatusEnum.name());
|
||||
}
|
||||
if (goodsAuthEnum != null) {
|
||||
queryWrapper.eq(Goods::getIsAuth, goodsAuthEnum.name());
|
||||
}
|
||||
AuthUser currentUser = Objects.requireNonNull(UserContext.getCurrentUser());
|
||||
queryWrapper.eq(CharSequenceUtil.equals(currentUser.getRole().name(), UserEnums.STORE.name()),
|
||||
Goods::getStoreId, currentUser.getStoreId());
|
||||
|
||||
return this.count(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer todayUpperNum() {
|
||||
LambdaQueryWrapper<Goods> queryWrapper = Wrappers.lambdaQuery();
|
||||
queryWrapper.eq(Goods::getMarketEnable, GoodsStatusEnum.UPPER.name());
|
||||
queryWrapper.ge(Goods::getCreateTime, DateUtil.beginOfDay(new DateTime()));
|
||||
return this.count(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean updateGoodsMarketAble(List<String> goodsIds, GoodsStatusEnum goodsStatusEnum, String underReason) {
|
||||
boolean result;
|
||||
@@ -322,6 +304,41 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
||||
for (Goods goods : goodsList) {
|
||||
goodsSkuService.updateGoodsSkuStatus(goods);
|
||||
}
|
||||
|
||||
if (GoodsStatusEnum.DOWN.equals(goodsStatusEnum)) {
|
||||
this.deleteEsGoods(goodsIds);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean managerUpdateGoodsMarketAble(List<String> goodsIds, GoodsStatusEnum goodsStatusEnum, String underReason) {
|
||||
boolean result;
|
||||
|
||||
//如果商品为空,直接返回
|
||||
if (goodsIds == null || goodsIds.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
//检测管理员权限
|
||||
this.checkManagerAuthority();
|
||||
|
||||
LambdaUpdateWrapper<Goods> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
updateWrapper.set(Goods::getMarketEnable, goodsStatusEnum.name());
|
||||
updateWrapper.set(Goods::getUnderMessage, underReason);
|
||||
updateWrapper.in(Goods::getId, goodsIds);
|
||||
result = this.update(updateWrapper);
|
||||
|
||||
//修改规格商品
|
||||
LambdaQueryWrapper<Goods> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.in(Goods::getId, goodsIds);
|
||||
List<Goods> goodsList = this.list(queryWrapper);
|
||||
for (Goods goods : goodsList) {
|
||||
goodsSkuService.updateGoodsSkuStatus(goods);
|
||||
}
|
||||
if (GoodsStatusEnum.DOWN.equals(goodsStatusEnum)) {
|
||||
this.deleteEsGoods(goodsIds);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -341,12 +358,10 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
||||
for (Goods goods : goodsList) {
|
||||
//修改SKU状态
|
||||
goodsSkuService.updateGoodsSkuStatus(goods);
|
||||
//商品删除消息
|
||||
String destination = rocketmqCustomProperties.getGoodsTopic() + ":" + GoodsTagsEnum.GOODS_DELETE.name();
|
||||
//发送mq消息
|
||||
rocketMQTemplate.asyncSend(destination, JSONUtil.toJsonStr(goods), RocketmqSendCallbackBuilder.commonCallback());
|
||||
}
|
||||
|
||||
this.deleteEsGoods(goodsIds);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -389,13 +404,58 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
||||
goodEvaluationQueryWrapper.eq(MemberEvaluation::getId, goodsId);
|
||||
goodEvaluationQueryWrapper.eq(MemberEvaluation::getGrade, EvaluationGradeEnum.GOOD.name());
|
||||
//好评数量
|
||||
int highPraiseNum = memberEvaluationService.count(goodEvaluationQueryWrapper);
|
||||
long highPraiseNum = memberEvaluationService.count(goodEvaluationQueryWrapper);
|
||||
//好评率
|
||||
double grade = NumberUtil.mul(NumberUtil.div(highPraiseNum, goods.getCommentNum().doubleValue(), 2), 100);
|
||||
goods.setGrade(grade);
|
||||
this.updateById(goods);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新商品的购买数量
|
||||
*
|
||||
* @param goodsId 商品ID
|
||||
* @param buyCount 购买数量
|
||||
*/
|
||||
@Override
|
||||
public void updateGoodsBuyCount(String goodsId, int buyCount) {
|
||||
this.update(new LambdaUpdateWrapper<Goods>()
|
||||
.eq(Goods::getId, goodsId)
|
||||
.set(Goods::getBuyCount, buyCount));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateStoreDetail(Store store) {
|
||||
UpdateWrapper updateWrapper = new UpdateWrapper<>()
|
||||
.eq("store_id", store.getId())
|
||||
.set("store_name", store.getStoreName())
|
||||
.set("self_operated", store.getSelfOperated());
|
||||
this.update(updateWrapper);
|
||||
goodsSkuService.update(updateWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long countStoreGoodsNum(String storeId) {
|
||||
return this.count(
|
||||
new LambdaQueryWrapper<Goods>()
|
||||
.eq(Goods::getStoreId, storeId)
|
||||
.eq(Goods::getAuthFlag, GoodsAuthEnum.PASS.name())
|
||||
.eq(Goods::getMarketEnable, GoodsStatusEnum.UPPER.name()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 发送删除es索引的信息
|
||||
*
|
||||
* @param goodsIds 商品id
|
||||
*/
|
||||
private void deleteEsGoods(List<String> goodsIds) {
|
||||
//商品删除消息
|
||||
String destination = rocketmqCustomProperties.getGoodsTopic() + ":" + GoodsTagsEnum.GOODS_DELETE.name();
|
||||
//发送mq消息
|
||||
rocketMQTemplate.asyncSend(destination, JSONUtil.toJsonStr(goodsIds), RocketmqSendCallbackBuilder.commonCallback());
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加商品默认图片
|
||||
*
|
||||
@@ -453,7 +513,7 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
||||
Setting setting = settingService.get(SettingEnum.GOODS_SETTING.name());
|
||||
GoodsSetting goodsSetting = JSONUtil.toBean(setting.getSettingValue(), GoodsSetting.class);
|
||||
//是否需要审核
|
||||
goods.setIsAuth(Boolean.TRUE.equals(goodsSetting.getGoodsCheck()) ? GoodsAuthEnum.TOBEAUDITED.name() : GoodsAuthEnum.PASS.name());
|
||||
goods.setAuthFlag(Boolean.TRUE.equals(goodsSetting.getGoodsCheck()) ? GoodsAuthEnum.TOBEAUDITED.name() : GoodsAuthEnum.PASS.name());
|
||||
//判断当前用户是否为店铺
|
||||
if (Objects.requireNonNull(UserContext.getCurrentUser()).getRole().equals(UserEnums.STORE)) {
|
||||
StoreVO storeDetail = this.storeService.getStoreDetail();
|
||||
@@ -471,8 +531,8 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
||||
/**
|
||||
* 判断商品是否存在
|
||||
*
|
||||
* @param goodsId
|
||||
* @return
|
||||
* @param goodsId 商品id
|
||||
* @return 商品信息
|
||||
*/
|
||||
private Goods checkExist(String goodsId) {
|
||||
Goods goods = getById(goodsId);
|
||||
@@ -483,20 +543,6 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
||||
return goods;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查当前登录的店铺
|
||||
*
|
||||
* @return 当前登录的店铺
|
||||
*/
|
||||
private AuthUser checkStoreAuthority() {
|
||||
AuthUser currentUser = UserContext.getCurrentUser();
|
||||
if (currentUser == null || (currentUser.getRole().equals(UserEnums.STORE) && currentUser.getStoreId() == null)) {
|
||||
throw new ServiceException(ResultCode.USER_AUTHORITY_ERROR);
|
||||
} else if (currentUser.getRole().equals(UserEnums.STORE) && currentUser.getStoreId() != null) {
|
||||
return currentUser;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取UpdateWrapper(检查用户越权)
|
||||
@@ -512,6 +558,36 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
||||
return updateWrapper;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 检查当前登录的店铺
|
||||
*
|
||||
* @return 当前登录的店铺
|
||||
*/
|
||||
private AuthUser checkStoreAuthority() {
|
||||
AuthUser currentUser = UserContext.getCurrentUser();
|
||||
//如果当前会员不为空,且为店铺角色
|
||||
if (currentUser != null && (currentUser.getRole().equals(UserEnums.STORE) && currentUser.getStoreId() != null)) {
|
||||
return currentUser;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查当前登录的店铺
|
||||
*
|
||||
* @return 当前登录的店铺
|
||||
*/
|
||||
private AuthUser checkManagerAuthority() {
|
||||
AuthUser currentUser = UserContext.getCurrentUser();
|
||||
//如果当前会员不为空,且为店铺角色
|
||||
if (currentUser != null && (currentUser.getRole().equals(UserEnums.MANAGER))) {
|
||||
return currentUser;
|
||||
} else {
|
||||
throw new ServiceException(ResultCode.USER_AUTHORITY_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取QueryWrapper(检查用户越权)
|
||||
*
|
||||
|
||||
@@ -2,11 +2,12 @@ package cn.lili.modules.goods.serviceimpl;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
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.cache.Cache;
|
||||
import cn.lili.common.enums.PromotionTypeEnum;
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.exception.ServiceException;
|
||||
import cn.lili.common.properties.RocketmqCustomProperties;
|
||||
@@ -30,6 +31,10 @@ import cn.lili.modules.member.entity.dos.FootPrint;
|
||||
import cn.lili.modules.member.entity.dos.MemberEvaluation;
|
||||
import cn.lili.modules.member.entity.enums.EvaluationGradeEnum;
|
||||
import cn.lili.modules.member.service.MemberEvaluationService;
|
||||
import cn.lili.modules.promotion.entity.dos.PromotionGoods;
|
||||
import cn.lili.modules.promotion.entity.dto.search.PromotionGoodsSearchParams;
|
||||
import cn.lili.modules.promotion.entity.enums.CouponGetEnum;
|
||||
import cn.lili.modules.promotion.service.PromotionGoodsService;
|
||||
import cn.lili.modules.search.entity.dos.EsGoodsAttribute;
|
||||
import cn.lili.modules.search.entity.dos.EsGoodsIndex;
|
||||
import cn.lili.modules.search.service.EsGoodsIndexService;
|
||||
@@ -45,6 +50,8 @@ import org.apache.rocketmq.spring.core.RocketMQTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.transaction.event.TransactionPhase;
|
||||
import org.springframework.transaction.event.TransactionalEventListener;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -100,6 +107,9 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
||||
@Autowired
|
||||
private EsGoodsIndexService goodsIndexService;
|
||||
|
||||
@Autowired
|
||||
private PromotionGoodsService promotionGoodsService;
|
||||
|
||||
@Override
|
||||
public void add(List<Map<String, Object>> skuList, Goods goods) {
|
||||
// 检查是否需要生成索引
|
||||
@@ -113,7 +123,9 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
||||
}
|
||||
|
||||
this.updateStock(newSkuList);
|
||||
generateEs(goods);
|
||||
if (!newSkuList.isEmpty()) {
|
||||
generateEs(goods);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -130,9 +142,9 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
||||
//删除旧索引
|
||||
for (GoodsSkuVO goodsSkuVO : goodsListByGoodsId) {
|
||||
oldSkuIds.add(goodsSkuVO.getId());
|
||||
goodsIndexService.deleteIndexById(goodsSkuVO.getId());
|
||||
cache.remove(GoodsSkuService.getCacheKeys(goodsSkuVO.getId()));
|
||||
}
|
||||
goodsIndexService.deleteIndexByIds(oldSkuIds);
|
||||
this.removeByIds(oldSkuIds);
|
||||
//删除sku相册
|
||||
goodsGalleryService.removeByIds(oldSkuIds);
|
||||
@@ -152,7 +164,7 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
||||
skuInfo(sku, goods, map, null);
|
||||
newSkuList.add(sku);
|
||||
//如果商品状态值不对,则es索引移除
|
||||
if (goods.getIsAuth().equals(GoodsAuthEnum.PASS.name()) && goods.getMarketEnable().equals(GoodsStatusEnum.UPPER.name())) {
|
||||
if (goods.getAuthFlag().equals(GoodsAuthEnum.PASS.name()) && goods.getMarketEnable().equals(GoodsStatusEnum.UPPER.name())) {
|
||||
goodsIndexService.deleteIndexById(sku.getId());
|
||||
this.clearCache(sku.getId());
|
||||
}
|
||||
@@ -160,7 +172,9 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
||||
this.updateBatchById(newSkuList);
|
||||
}
|
||||
this.updateStock(newSkuList);
|
||||
generateEs(goods);
|
||||
if (GoodsAuthEnum.PASS.name().equals(goods.getAuthFlag()) && !newSkuList.isEmpty()) {
|
||||
generateEs(goods);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -202,14 +216,11 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
||||
//获取商品库存
|
||||
Integer integer = (Integer) cache.get(GoodsSkuService.getStockCacheKey(id));
|
||||
|
||||
//库存不为空
|
||||
if (integer != null) {
|
||||
//库存与缓存中不一致,
|
||||
if (!goodsSku.getQuantity().equals(integer)) {
|
||||
//写入最新的库存信息
|
||||
goodsSku.setQuantity(integer);
|
||||
cache.put(GoodsSkuService.getCacheKeys(goodsSku.getId()), goodsSku);
|
||||
}
|
||||
//库存不为空,库存与缓存中不一致
|
||||
if (integer != null && !goodsSku.getQuantity().equals(integer)) {
|
||||
//写入最新的库存信息
|
||||
goodsSku.setQuantity(integer);
|
||||
cache.put(GoodsSkuService.getCacheKeys(goodsSku.getId()), goodsSku);
|
||||
}
|
||||
return goodsSku;
|
||||
}
|
||||
@@ -219,23 +230,20 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
||||
Map<String, Object> map = new HashMap<>(16);
|
||||
//获取商品VO
|
||||
GoodsVO goodsVO = goodsService.getGoodsVO(goodsId);
|
||||
//如果skuid为空,则使用商品VO中sku信息获取
|
||||
if (CharSequenceUtil.isEmpty(skuId) || "undefined".equals(skuId)) {
|
||||
skuId = goodsVO.getSkuList().get(0).getId();
|
||||
}
|
||||
//从缓存拿商品Sku
|
||||
GoodsSku goodsSku = this.getGoodsSkuByIdFromCache(skuId);
|
||||
|
||||
|
||||
//如果规格为空则使用商品ID进行查询
|
||||
if (goodsSku == null) {
|
||||
skuId = goodsVO.getSkuList().get(0).getId();
|
||||
goodsSku = this.getGoodsSkuByIdFromCache(skuId);
|
||||
//如果使用商品ID无法查询SKU则返回错误
|
||||
if (goodsSku == null) {
|
||||
throw new ServiceException(ResultCode.GOODS_NOT_EXIST);
|
||||
}
|
||||
//如果使用商品ID无法查询SKU则返回错误
|
||||
if (goodsVO == null || goodsSku == null) {
|
||||
throw new ServiceException(ResultCode.GOODS_NOT_EXIST);
|
||||
}
|
||||
|
||||
//商品为空||商品下架||商品未审核通过||商品删除,则提示:商品已下架
|
||||
if (goodsVO == null || goodsVO.getMarketEnable().equals(GoodsStatusEnum.DOWN.name())
|
||||
|| !goodsVO.getIsAuth().equals(GoodsAuthEnum.PASS.name())
|
||||
//商品下架||商品未审核通过||商品删除,则提示:商品已下架
|
||||
if (GoodsStatusEnum.DOWN.name().equals(goodsVO.getMarketEnable())
|
||||
|| !GoodsAuthEnum.PASS.name().equals(goodsVO.getAuthFlag())
|
||||
|| Boolean.TRUE.equals(goodsVO.getDeleteFlag())) {
|
||||
throw new ServiceException(ResultCode.GOODS_NOT_EXIST);
|
||||
}
|
||||
@@ -243,7 +251,7 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
||||
//获取当前商品的索引信息
|
||||
EsGoodsIndex goodsIndex = goodsIndexService.findById(skuId);
|
||||
if (goodsIndex == null) {
|
||||
goodsIndex = goodsIndexService.resetEsGoodsIndex(goodsSku, goodsVO.getGoodsParamsDTOList());
|
||||
goodsIndex = goodsIndexService.getTempEsGoodsIndex(goodsSku, goodsVO.getGoodsParamsDTOList());
|
||||
|
||||
//发送mq消息
|
||||
String destination = rocketmqCustomProperties.getGoodsTopic() + ":" + GoodsTagsEnum.RESET_GOODS_INDEX.name();
|
||||
@@ -253,9 +261,34 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
||||
//商品规格
|
||||
GoodsSkuVO goodsSkuDetail = this.getGoodsSkuVO(goodsSku);
|
||||
|
||||
Map<String, Object> promotionMap = goodsIndex.getPromotionMap();
|
||||
//设置当前商品的促销价格
|
||||
if (goodsIndex.getPromotionMap() != null && !goodsIndex.getPromotionMap().isEmpty() && goodsIndex.getPromotionPrice() != null) {
|
||||
goodsSkuDetail.setPromotionPrice(goodsIndex.getPromotionPrice());
|
||||
if (promotionMap != null && !promotionMap.isEmpty()) {
|
||||
promotionMap = promotionMap.entrySet().stream().parallel().filter(i -> {
|
||||
JSONObject jsonObject = JSONUtil.parseObj(i.getValue());
|
||||
// 过滤活动赠送优惠券和无效时间的活动
|
||||
return (jsonObject.get("getType") == null || jsonObject.get("getType", String.class).equals(CouponGetEnum.FREE.name())) &&
|
||||
(jsonObject.get("startTime") != null && jsonObject.get("startTime", Date.class).getTime() <= System.currentTimeMillis()) &&
|
||||
(jsonObject.get("endTime") == null || jsonObject.get("endTime", Date.class).getTime() >= System.currentTimeMillis());
|
||||
}).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
|
||||
|
||||
Optional<Map.Entry<String, Object>> containsPromotion = promotionMap.entrySet().stream().filter(i ->
|
||||
i.getKey().contains(PromotionTypeEnum.SECKILL.name()) || i.getKey().contains(PromotionTypeEnum.PINTUAN.name())).findFirst();
|
||||
if (containsPromotion.isPresent()) {
|
||||
JSONObject jsonObject = JSONUtil.parseObj(containsPromotion.get().getValue());
|
||||
PromotionGoodsSearchParams searchParams = new PromotionGoodsSearchParams();
|
||||
searchParams.setSkuId(skuId);
|
||||
searchParams.setPromotionId(jsonObject.get("id").toString());
|
||||
PromotionGoods promotionsGoods = promotionGoodsService.getPromotionsGoods(searchParams);
|
||||
if (promotionsGoods != null && promotionsGoods.getPrice() != null) {
|
||||
goodsSkuDetail.setPromotionFlag(true);
|
||||
goodsSkuDetail.setPromotionPrice(promotionsGoods.getPrice());
|
||||
}
|
||||
} else {
|
||||
goodsSkuDetail.setPromotionFlag(false);
|
||||
goodsSkuDetail.setPromotionPrice(null);
|
||||
}
|
||||
|
||||
}
|
||||
map.put("data", goodsSkuDetail);
|
||||
|
||||
@@ -265,10 +298,10 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
||||
|
||||
//获取规格信息
|
||||
map.put("specs", this.groupBySkuAndSpec(goodsVO.getSkuList()));
|
||||
map.put("promotionMap", goodsIndex.getPromotionMap());
|
||||
map.put("promotionMap", promotionMap);
|
||||
|
||||
//获取参数信息
|
||||
if (goodsVO.getGoodsParamsDTOList() != null && goodsVO.getGoodsParamsDTOList().size() > 0) {
|
||||
if (goodsVO.getGoodsParamsDTOList() != null && !goodsVO.getGoodsParamsDTOList().isEmpty()) {
|
||||
map.put("goodsParamsDTOList", goodsVO.getGoodsParamsDTOList());
|
||||
}
|
||||
|
||||
@@ -284,14 +317,14 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
||||
/**
|
||||
* 更新商品sku状态
|
||||
*
|
||||
* @param goods 商品信息(Id,MarketEnable/IsAuth)
|
||||
* @param goods 商品信息(Id,MarketEnable/AuthFlag)
|
||||
*/
|
||||
@Override
|
||||
public void updateGoodsSkuStatus(Goods goods) {
|
||||
LambdaUpdateWrapper<GoodsSku> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
updateWrapper.eq(GoodsSku::getGoodsId, goods.getId());
|
||||
updateWrapper.set(GoodsSku::getMarketEnable, goods.getMarketEnable());
|
||||
updateWrapper.set(GoodsSku::getIsAuth, goods.getIsAuth());
|
||||
updateWrapper.set(GoodsSku::getAuthFlag, goods.getAuthFlag());
|
||||
updateWrapper.set(GoodsSku::getDeleteFlag, goods.getDeleteFlag());
|
||||
boolean update = this.update(updateWrapper);
|
||||
if (Boolean.TRUE.equals(update)) {
|
||||
@@ -300,7 +333,9 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
||||
cache.remove(GoodsSkuService.getCacheKeys(sku.getId()));
|
||||
cache.put(GoodsSkuService.getCacheKeys(sku.getId()), sku);
|
||||
}
|
||||
generateEs(goods);
|
||||
if (!goodsSkus.isEmpty()) {
|
||||
generateEs(goods);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -385,6 +420,17 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
||||
return this.page(PageUtil.initPage(searchParams), searchParams.queryWrapper());
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表查询商品sku信息
|
||||
*
|
||||
* @param searchParams 查询参数
|
||||
* @return 商品sku信息
|
||||
*/
|
||||
@Override
|
||||
public List<GoodsSku> getGoodsSkuByList(GoodsSearchParams searchParams) {
|
||||
return this.list(searchParams.queryWrapper());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateStocks(List<GoodsSkuStockDTO> goodsSkuStockDTOS) {
|
||||
for (GoodsSkuStockDTO goodsSkuStockDTO : goodsSkuStockDTOS) {
|
||||
@@ -462,7 +508,7 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
||||
goodEvaluationQueryWrapper.eq(MemberEvaluation::getGrade, EvaluationGradeEnum.GOOD.name());
|
||||
|
||||
//好评数量
|
||||
int highPraiseNum = memberEvaluationService.count(goodEvaluationQueryWrapper);
|
||||
long highPraiseNum = memberEvaluationService.count(goodEvaluationQueryWrapper);
|
||||
|
||||
//更新商品评价数量
|
||||
goodsSku.setCommentNum(goodsSku.getCommentNum() != null ? goodsSku.getCommentNum() + 1 : 1);
|
||||
@@ -476,8 +522,8 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
||||
|
||||
//修改规格索引,发送mq消息
|
||||
Map<String, Object> updateIndexFieldsMap = EsIndexUtil.getUpdateIndexFieldsMap(
|
||||
MapUtil.builder().put("id", goodsSku.getId()).build(),
|
||||
MapUtil.builder().put("commentNum", goodsSku.getCommentNum()).put("highPraiseNum", highPraiseNum)
|
||||
MapUtil.builder(new HashMap<String, Object>()).put("id", goodsSku.getId()).build(),
|
||||
MapUtil.builder(new HashMap<String, Object>()).put("commentNum", goodsSku.getCommentNum()).put("highPraiseNum", highPraiseNum)
|
||||
.put("grade", grade).build());
|
||||
String destination = rocketmqCustomProperties.getGoodsTopic() + ":" + GoodsTagsEnum.UPDATE_GOODS_INDEX_FIELD.name();
|
||||
rocketMQTemplate.asyncSend(destination, JSONUtil.toJsonStr(updateIndexFieldsMap), RocketmqSendCallbackBuilder.commonCallback());
|
||||
@@ -486,15 +532,48 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
||||
goodsService.updateGoodsCommentNum(goodsSku.getGoodsId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新商品sku促销价格
|
||||
*
|
||||
* @param skuId skuId
|
||||
* @param promotionPrice 促销价格
|
||||
*/
|
||||
@Override
|
||||
public void updateGoodsSkuPromotion(String skuId, Double promotionPrice) {
|
||||
LambdaUpdateWrapper<GoodsSku> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
updateWrapper.eq(GoodsSku::getId, skuId);
|
||||
updateWrapper.set(GoodsSku::getPromotionPrice, promotionPrice);
|
||||
updateWrapper.set(GoodsSku::getPromotionFlag, true);
|
||||
this.update(updateWrapper);
|
||||
cache.remove(GoodsSkuService.getCacheKeys(skuId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据商品id获取全部skuId的集合
|
||||
*
|
||||
* @param goodsId goodsId
|
||||
* @return 全部skuId的集合
|
||||
*/
|
||||
@Override
|
||||
public List<String> getSkuIdsByGoodsId(String goodsId) {
|
||||
return this.baseMapper.getGoodsSkuIdByGoodsId(goodsId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送生成ES商品索引
|
||||
*
|
||||
* @param goods 商品信息
|
||||
*/
|
||||
@Override
|
||||
@TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT)
|
||||
public void generateEs(Goods goods) {
|
||||
// 不生成没有审核通过且没有上架的商品
|
||||
if (!GoodsStatusEnum.UPPER.name().equals(goods.getMarketEnable()) || !GoodsAuthEnum.PASS.name().equals(goods.getAuthFlag())) {
|
||||
return;
|
||||
}
|
||||
String destination = rocketmqCustomProperties.getGoodsTopic() + ":" + GoodsTagsEnum.GENERATOR_GOODS_INDEX.name();
|
||||
//发送mq消息
|
||||
rocketMQTemplate.asyncSend(destination, JSONUtil.toJsonStr(goods), RocketmqSendCallbackBuilder.commonCallback());
|
||||
rocketMQTemplate.asyncSend(destination, goods.getId(), RocketmqSendCallbackBuilder.commonCallback());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -580,7 +659,7 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
||||
sku.setGoodsUnit(goods.getGoodsUnit());
|
||||
sku.setGrade(100D);
|
||||
//商品状态
|
||||
sku.setIsAuth(goods.getIsAuth());
|
||||
sku.setAuthFlag(goods.getAuthFlag());
|
||||
sku.setSalesModel(goods.getSalesModel());
|
||||
//卖家信息
|
||||
sku.setStoreId(goods.getStoreId());
|
||||
@@ -629,7 +708,7 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
||||
}
|
||||
//设置规格商品缩略图
|
||||
//如果规格没有图片,则用商品图片复盖。有则增加规格图片,放在商品图片集合之前
|
||||
if (spec.getValue() != null && StrUtil.isNotEmpty(spec.getValue().toString())) {
|
||||
if (CharSequenceUtil.isNotEmpty(spec.getValue().toString())) {
|
||||
thumbnail = goodsGalleryService.getGoodsGallery(images.get(0).get("url")).getThumbnail();
|
||||
small = goodsGalleryService.getGoodsGallery(images.get(0).get("url")).getSmall();
|
||||
}
|
||||
|
||||
@@ -3,11 +3,11 @@ package cn.lili.modules.goods.util;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.lili.common.enums.ClientTypeEnum;
|
||||
import cn.lili.common.exception.ServiceException;
|
||||
import cn.lili.common.utils.HttpUtils;
|
||||
import cn.lili.modules.goods.entity.dos.Commodity;
|
||||
import cn.lili.modules.goods.entity.dos.Studio;
|
||||
import cn.lili.modules.goods.entity.dto.GoodsInfo;
|
||||
import cn.lili.modules.message.util.WechatAccessTokenUtil;
|
||||
import cn.lili.modules.system.utils.HttpUtils;
|
||||
import cn.lili.modules.wechat.util.WechatAccessTokenUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -4,7 +4,7 @@ import cn.hutool.json.JSONObject;
|
||||
import cn.lili.common.enums.ClientTypeEnum;
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.exception.ServiceException;
|
||||
import cn.lili.modules.message.util.WechatAccessTokenUtil;
|
||||
import cn.lili.modules.wechat.util.WechatAccessTokenUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -105,8 +105,9 @@ public class WechatMediaUtil {
|
||||
} catch (Exception e) {
|
||||
log.error("微信媒体上传失败", e);
|
||||
}
|
||||
assert resultStr != null;
|
||||
JSONObject jsonObject = new JSONObject(resultStr.toString());
|
||||
log.info("微信媒体上传:" + jsonObject.toString());
|
||||
log.info("微信媒体上传:" + jsonObject);
|
||||
//判断是否传递成功,如果token过期则重新获取
|
||||
if (jsonObject.get("errcode") != null && ("40001").equals(jsonObject.get("errcode"))) {
|
||||
wechatAccessTokenUtil.removeAccessToken(ClientTypeEnum.WECHAT_MP);
|
||||
|
||||
@@ -3,7 +3,6 @@ package cn.lili.modules.member.entity.dos;
|
||||
import cn.lili.mybatis.BaseIdEntity;
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
@@ -27,11 +26,6 @@ public class MemberReceipt extends BaseIdEntity {
|
||||
|
||||
private static final long serialVersionUID = -8210927482915675995L;
|
||||
|
||||
@TableId
|
||||
@TableField
|
||||
@ApiModelProperty(value = "唯一标识", hidden = true)
|
||||
private String id;
|
||||
|
||||
@ApiModelProperty(value = "发票抬头")
|
||||
private String receiptTitle;
|
||||
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package cn.lili.modules.member.entity.dto;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 收藏数量变化DTO
|
||||
*
|
||||
* @author Chopper
|
||||
* @version v1.0
|
||||
* 2021-11-30 10:14
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class CollectionDTO {
|
||||
|
||||
/**
|
||||
* 变化的模型id
|
||||
* 商品id/店铺id
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 变化的数量
|
||||
* -1 减少1 / +1 增加1
|
||||
*/
|
||||
private Integer num;
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package cn.lili.modules.member.entity.dto;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* ConnectQueryDTO
|
||||
*
|
||||
* @author Chopper
|
||||
* @version v1.0
|
||||
* 2021-12-01 14:34
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
public class ConnectQueryDTO {
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
private String userId;
|
||||
|
||||
/**
|
||||
* 第三方id
|
||||
*/
|
||||
private String unionId;
|
||||
|
||||
/**
|
||||
* 联合登陆类型
|
||||
*/
|
||||
private String unionType;
|
||||
|
||||
}
|
||||
@@ -25,5 +25,5 @@ public class EvaluationNumberVO {
|
||||
private Integer worse;
|
||||
|
||||
@ApiModelProperty(value = "有图数量")
|
||||
private Integer haveImage;
|
||||
private Long haveImage;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package cn.lili.modules.member.mapper;
|
||||
|
||||
|
||||
import cn.lili.modules.member.entity.dos.Member;
|
||||
import cn.lili.modules.member.entity.vo.MemberDistributionVO;
|
||||
import cn.lili.modules.member.entity.vo.MemberVO;
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
@@ -28,13 +27,6 @@ public interface MemberMapper extends BaseMapper<Member> {
|
||||
@Select("select m.mobile from li_member m")
|
||||
List<String> getAllMemberMobile();
|
||||
|
||||
/**
|
||||
* 获取会员分布列表
|
||||
* @return 会员分布列表
|
||||
*/
|
||||
@Select("select client_enum,count(0) as num from li_member group by client_enum")
|
||||
List<MemberDistributionVO> distribution();
|
||||
|
||||
@Select("select * from li_member ${ew.customSqlSegment}")
|
||||
IPage<MemberVO> pageByMemberVO(IPage<MemberVO> page, @Param(Constants.WRAPPER) Wrapper<Member> queryWrapper);
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package cn.lili.modules.system.mapper;
|
||||
package cn.lili.modules.member.mapper;
|
||||
|
||||
import cn.lili.modules.store.entity.dos.StoreLogistics;
|
||||
import cn.lili.modules.system.entity.vo.StoreLogisticsVO;
|
||||
@@ -51,5 +51,5 @@ public interface FootprintService extends IService<FootPrint> {
|
||||
*
|
||||
* @return 当前会员的浏览记录数量
|
||||
*/
|
||||
Integer getFootprintNum();
|
||||
long getFootprintNum();
|
||||
}
|
||||
@@ -88,18 +88,5 @@ public interface MemberEvaluationService extends IService<MemberEvaluation> {
|
||||
*/
|
||||
EvaluationNumberVO getEvaluationNumber(String goodsId);
|
||||
|
||||
/**
|
||||
* 获取今天新增的评价数量
|
||||
*
|
||||
* @return 今日评价数量
|
||||
*/
|
||||
Integer todayMemberEvaluation();
|
||||
|
||||
/**
|
||||
* 获取等待回复评价数量
|
||||
*
|
||||
* @return 等待回复评价数量
|
||||
*/
|
||||
Integer getWaitReplyNum();
|
||||
|
||||
}
|
||||
@@ -9,13 +9,13 @@ import cn.lili.modules.member.entity.dos.Member;
|
||||
import cn.lili.modules.member.entity.dto.ManagerMemberEditDTO;
|
||||
import cn.lili.modules.member.entity.dto.MemberAddDTO;
|
||||
import cn.lili.modules.member.entity.dto.MemberEditDTO;
|
||||
import cn.lili.modules.member.entity.vo.MemberDistributionVO;
|
||||
import cn.lili.modules.member.entity.vo.MemberSearchVO;
|
||||
import cn.lili.modules.member.entity.vo.MemberVO;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 会员业务层
|
||||
@@ -197,20 +197,22 @@ public interface MemberService extends IService<Member> {
|
||||
*/
|
||||
Boolean updateMemberStatus(List<String> memberIds, Boolean status);
|
||||
|
||||
/**
|
||||
* 查看会员数据分布
|
||||
*
|
||||
* @return 会员数据分布
|
||||
*/
|
||||
List<MemberDistributionVO> distribution();
|
||||
|
||||
/**
|
||||
* 根据条件查询会员总数
|
||||
*
|
||||
* @param memberSearchVO
|
||||
* @return 会员总数
|
||||
*/
|
||||
Integer getMemberNum(MemberSearchVO memberSearchVO);
|
||||
long getMemberNum(MemberSearchVO memberSearchVO);
|
||||
|
||||
/**
|
||||
* 获取指定会员数据
|
||||
*
|
||||
* @param columns 指定获取的列
|
||||
* @param memberIds 会员ids
|
||||
* @return 指定会员数据
|
||||
*/
|
||||
List<Map<String, Object>> listFieldsByMemberIds(String columns, List<String> memberIds);
|
||||
|
||||
/**
|
||||
* 登出
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package cn.lili.modules.system.service;
|
||||
package cn.lili.modules.member.service;
|
||||
|
||||
import cn.lili.modules.store.entity.dos.StoreLogistics;
|
||||
import cn.lili.modules.system.entity.vo.StoreLogisticsVO;
|
||||
@@ -1,13 +1,13 @@
|
||||
package cn.lili.modules.member.serviceimpl;
|
||||
|
||||
import cn.lili.common.security.context.UserContext;
|
||||
import cn.lili.mybatis.util.PageUtil;
|
||||
import cn.lili.common.vo.PageVO;
|
||||
import cn.lili.modules.member.entity.dos.FootPrint;
|
||||
import cn.lili.modules.member.mapper.FootprintMapper;
|
||||
import cn.lili.modules.member.service.FootprintService;
|
||||
import cn.lili.modules.search.entity.dos.EsGoodsIndex;
|
||||
import cn.lili.modules.search.service.EsGoodsSearchService;
|
||||
import cn.lili.mybatis.util.PageUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
@@ -15,6 +15,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
@@ -81,19 +82,19 @@ public class FootprintServiceImpl extends ServiceImpl<FootprintMapper, FootPrint
|
||||
lambdaQueryWrapper.eq(FootPrint::getDeleteFlag, false);
|
||||
lambdaQueryWrapper.orderByDesc(FootPrint::getUpdateTime);
|
||||
List<String> skuIdList = this.baseMapper.footprintSkuIdList(PageUtil.initPage(pageVO), lambdaQueryWrapper);
|
||||
if (skuIdList.size() > 0) {
|
||||
if (!skuIdList.isEmpty()) {
|
||||
List<EsGoodsIndex> list = esGoodsSearchService.getEsGoodsBySkuIds(skuIdList);
|
||||
//去除为空的商品数据
|
||||
list.removeIf(Objects::isNull);
|
||||
return list;
|
||||
}
|
||||
return null;
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getFootprintNum() {
|
||||
public long getFootprintNum() {
|
||||
LambdaQueryWrapper<FootPrint> lambdaQueryWrapper = Wrappers.lambdaQuery();
|
||||
lambdaQueryWrapper.eq(FootPrint::getMemberId, UserContext.getCurrentUser().getId());
|
||||
lambdaQueryWrapper.eq(FootPrint::getMemberId, Objects.requireNonNull(UserContext.getCurrentUser()).getId());
|
||||
lambdaQueryWrapper.eq(FootPrint::getDeleteFlag, false);
|
||||
return this.count(lambdaQueryWrapper);
|
||||
}
|
||||
|
||||
@@ -1,24 +1,18 @@
|
||||
package cn.lili.modules.member.serviceimpl;
|
||||
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.exception.ServiceException;
|
||||
import cn.lili.rocketmq.RocketmqSendCallbackBuilder;
|
||||
import cn.lili.rocketmq.tags.GoodsTagsEnum;
|
||||
import cn.lili.common.security.context.UserContext;
|
||||
import cn.lili.mybatis.util.PageUtil;
|
||||
import cn.lili.common.vo.PageVO;
|
||||
import cn.lili.common.properties.RocketmqCustomProperties;
|
||||
import cn.lili.modules.member.entity.dos.GoodsCollection;
|
||||
import cn.lili.modules.member.entity.vo.GoodsCollectionVO;
|
||||
import cn.lili.modules.member.mapper.GoodsCollectionMapper;
|
||||
import cn.lili.modules.member.service.GoodsCollectionService;
|
||||
import cn.lili.mybatis.util.PageUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.apache.rocketmq.spring.core.RocketMQTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@@ -33,19 +27,8 @@ import java.util.Optional;
|
||||
*/
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
|
||||
public class GoodsCollectionServiceImpl extends ServiceImpl<GoodsCollectionMapper, GoodsCollection> implements GoodsCollectionService {
|
||||
|
||||
/**
|
||||
* rocketMq
|
||||
*/
|
||||
@Autowired
|
||||
private RocketMQTemplate rocketMQTemplate;
|
||||
/**
|
||||
* rocketMq配置
|
||||
*/
|
||||
@Autowired
|
||||
private RocketmqCustomProperties rocketmqCustomProperties;
|
||||
|
||||
@Override
|
||||
public IPage<GoodsCollectionVO> goodsCollection(PageVO pageVo) {
|
||||
@@ -73,10 +56,6 @@ public class GoodsCollectionServiceImpl extends ServiceImpl<GoodsCollectionMappe
|
||||
goodsCollection = new GoodsCollection(UserContext.getCurrentUser().getId(), skuId);
|
||||
|
||||
this.save(goodsCollection);
|
||||
//商品收藏消息
|
||||
String destination = rocketmqCustomProperties.getGoodsTopic() + ":" + GoodsTagsEnum.GOODS_COLLECTION.name();
|
||||
//发送mq消息
|
||||
rocketMQTemplate.asyncSend(destination, JSONUtil.toJsonStr(skuId), RocketmqSendCallbackBuilder.commonCallback());
|
||||
return goodsCollection;
|
||||
}
|
||||
throw new ServiceException(ResultCode.USER_COLLECTION_EXIST);
|
||||
|
||||
@@ -1,18 +1,13 @@
|
||||
package cn.lili.modules.member.serviceimpl;
|
||||
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.enums.SwitchEnum;
|
||||
import cn.lili.common.exception.ServiceException;
|
||||
import cn.lili.rocketmq.RocketmqSendCallbackBuilder;
|
||||
import cn.lili.rocketmq.tags.GoodsTagsEnum;
|
||||
import cn.lili.common.security.context.UserContext;
|
||||
import cn.lili.common.security.enums.UserEnums;
|
||||
import cn.lili.mybatis.util.PageUtil;
|
||||
import cn.lili.common.utils.StringUtils;
|
||||
import cn.lili.common.properties.RocketmqCustomProperties;
|
||||
import cn.lili.common.security.context.UserContext;
|
||||
import cn.lili.common.sensitive.SensitiveWordsFilter;
|
||||
import cn.lili.common.utils.StringUtils;
|
||||
import cn.lili.modules.goods.entity.dos.GoodsSku;
|
||||
import cn.lili.modules.goods.service.GoodsSkuService;
|
||||
import cn.lili.modules.member.entity.dos.Member;
|
||||
@@ -31,9 +26,9 @@ import cn.lili.modules.order.order.entity.dos.OrderItem;
|
||||
import cn.lili.modules.order.order.entity.enums.CommentStatusEnum;
|
||||
import cn.lili.modules.order.order.service.OrderItemService;
|
||||
import cn.lili.modules.order.order.service.OrderService;
|
||||
import cn.lili.modules.system.utils.CharacterConstant;
|
||||
import cn.lili.modules.system.utils.SensitiveWordsFilter;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import cn.lili.mybatis.util.PageUtil;
|
||||
import cn.lili.rocketmq.RocketmqSendCallbackBuilder;
|
||||
import cn.lili.rocketmq.tags.GoodsTagsEnum;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
@@ -121,7 +116,7 @@ public class MemberEvaluationServiceImpl extends ServiceImpl<MemberEvaluationMap
|
||||
//新增用户评价
|
||||
MemberEvaluation memberEvaluation = new MemberEvaluation(memberEvaluationDTO, goodsSku, member, order);
|
||||
//过滤商品咨询敏感词
|
||||
memberEvaluation.setContent(SensitiveWordsFilter.filter(memberEvaluation.getContent(), CharacterConstant.WILDCARD_STAR));
|
||||
memberEvaluation.setContent(SensitiveWordsFilter.filter(memberEvaluation.getContent()));
|
||||
//添加评价
|
||||
this.save(memberEvaluation);
|
||||
|
||||
@@ -196,20 +191,6 @@ public class MemberEvaluationServiceImpl extends ServiceImpl<MemberEvaluationMap
|
||||
return evaluationNumberVO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer todayMemberEvaluation() {
|
||||
return this.count(new LambdaQueryWrapper<MemberEvaluation>().ge(MemberEvaluation::getCreateTime, DateUtil.beginOfDay(new DateTime())));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getWaitReplyNum() {
|
||||
QueryWrapper<MemberEvaluation> queryWrapper = Wrappers.query();
|
||||
queryWrapper.eq(StringUtils.equals(UserContext.getCurrentUser().getRole().name(), UserEnums.STORE.name()),
|
||||
"store_id", UserContext.getCurrentUser().getStoreId());
|
||||
queryWrapper.eq("reply_status", false);
|
||||
return this.count(queryWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 检测会员评价
|
||||
*
|
||||
|
||||
@@ -1,27 +1,22 @@
|
||||
package cn.lili.modules.member.serviceimpl;
|
||||
|
||||
|
||||
import cn.lili.modules.member.entity.dos.Member;
|
||||
import cn.lili.modules.member.entity.enums.PointTypeEnum;
|
||||
import cn.lili.modules.member.mapper.MemberMapper;
|
||||
import cn.lili.modules.member.service.MemberService;
|
||||
import cn.lili.mybatis.util.PageUtil;
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import cn.lili.common.utils.StringUtils;
|
||||
import cn.lili.common.vo.PageVO;
|
||||
import cn.lili.modules.member.entity.dos.Member;
|
||||
import cn.lili.modules.member.entity.dos.MemberPointsHistory;
|
||||
import cn.lili.modules.member.entity.vo.MemberPointsHistoryVO;
|
||||
import cn.lili.modules.member.mapper.MemberPointsHistoryMapper;
|
||||
import cn.lili.modules.member.service.MemberPointsHistoryService;
|
||||
import cn.lili.modules.member.service.MemberService;
|
||||
import cn.lili.mybatis.util.PageUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 会员积分历史业务层实现
|
||||
*
|
||||
@@ -51,8 +46,8 @@ public class MemberPointsHistoryServiceImpl extends ServiceImpl<MemberPointsHist
|
||||
@Override
|
||||
public IPage<MemberPointsHistory> MemberPointsHistoryList(PageVO page, String memberId, String memberName) {
|
||||
LambdaQueryWrapper<MemberPointsHistory> lambdaQueryWrapper = new LambdaQueryWrapper<MemberPointsHistory>()
|
||||
.eq(memberId != null, MemberPointsHistory::getMemberId, memberId)
|
||||
.like(memberName != null, MemberPointsHistory::getMemberName, memberName);
|
||||
.eq(CharSequenceUtil.isNotEmpty(memberId), MemberPointsHistory::getMemberId, memberId)
|
||||
.like(CharSequenceUtil.isNotEmpty(memberName), MemberPointsHistory::getMemberName, memberName);
|
||||
//如果排序为空,则默认创建时间倒序
|
||||
if (StringUtils.isEmpty(page.getSort())) {
|
||||
page.setSort("createTime");
|
||||
|
||||
@@ -14,23 +14,19 @@ import cn.lili.common.security.AuthUser;
|
||||
import cn.lili.common.security.context.UserContext;
|
||||
import cn.lili.common.security.enums.UserEnums;
|
||||
import cn.lili.common.security.token.Token;
|
||||
import cn.lili.common.sensitive.SensitiveWordsFilter;
|
||||
import cn.lili.common.utils.BeanUtil;
|
||||
import cn.lili.common.utils.CookieUtil;
|
||||
import cn.lili.common.utils.StringUtils;
|
||||
import cn.lili.common.utils.UuidUtils;
|
||||
import cn.lili.common.vo.PageVO;
|
||||
import cn.lili.modules.connect.config.ConnectAuthEnum;
|
||||
import cn.lili.modules.connect.entity.Connect;
|
||||
import cn.lili.modules.connect.entity.dto.ConnectAuthUser;
|
||||
import cn.lili.modules.connect.service.ConnectService;
|
||||
import cn.lili.modules.connect.util.UuidUtils;
|
||||
import cn.lili.modules.member.aop.annotation.PointLogPoint;
|
||||
import cn.lili.modules.member.entity.dos.Member;
|
||||
import cn.lili.modules.member.entity.dto.ManagerMemberEditDTO;
|
||||
import cn.lili.modules.member.entity.dto.MemberAddDTO;
|
||||
import cn.lili.modules.member.entity.dto.MemberEditDTO;
|
||||
import cn.lili.modules.member.entity.dto.MemberPointMessage;
|
||||
import cn.lili.modules.member.entity.dto.*;
|
||||
import cn.lili.modules.member.entity.enums.PointTypeEnum;
|
||||
import cn.lili.modules.member.entity.vo.MemberDistributionVO;
|
||||
import cn.lili.modules.member.entity.vo.MemberSearchVO;
|
||||
import cn.lili.modules.member.entity.vo.MemberVO;
|
||||
import cn.lili.modules.member.mapper.MemberMapper;
|
||||
@@ -40,12 +36,9 @@ import cn.lili.modules.member.token.StoreTokenGenerate;
|
||||
import cn.lili.modules.store.entity.dos.Store;
|
||||
import cn.lili.modules.store.entity.enums.StoreStatusEnum;
|
||||
import cn.lili.modules.store.service.StoreService;
|
||||
import cn.lili.modules.system.utils.CharacterConstant;
|
||||
import cn.lili.modules.system.utils.SensitiveWordsFilter;
|
||||
import cn.lili.mybatis.util.PageUtil;
|
||||
import cn.lili.rocketmq.RocketmqSendCallbackBuilder;
|
||||
import cn.lili.rocketmq.tags.MemberTagsEnum;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
@@ -59,6 +52,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
@@ -109,7 +103,7 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, Member> impleme
|
||||
|
||||
@Override
|
||||
public Member findByUsername(String userName) {
|
||||
QueryWrapper<Member> queryWrapper = new QueryWrapper();
|
||||
QueryWrapper<Member> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("username", userName);
|
||||
return this.baseMapper.selectOne(queryWrapper);
|
||||
}
|
||||
@@ -126,7 +120,7 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, Member> impleme
|
||||
|
||||
@Override
|
||||
public boolean findByMobile(String uuid, String mobile) {
|
||||
QueryWrapper<Member> queryWrapper = new QueryWrapper();
|
||||
QueryWrapper<Member> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("mobile", mobile);
|
||||
Member member = this.baseMapper.selectOne(queryWrapper);
|
||||
if (member == null) {
|
||||
@@ -165,7 +159,7 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, Member> impleme
|
||||
throw new ServiceException(ResultCode.USER_PASSWORD_ERROR);
|
||||
}
|
||||
//对店铺状态的判定处理
|
||||
if (member.getHaveStore()) {
|
||||
if (Boolean.TRUE.equals(member.getHaveStore())) {
|
||||
Store store = storeService.getById(member.getStoreId());
|
||||
if (!store.getStoreDisable().equals(StoreStatusEnum.OPEN.name())) {
|
||||
throw new ServiceException(ResultCode.STORE_CLOSE_ERROR);
|
||||
@@ -180,11 +174,11 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, Member> impleme
|
||||
/**
|
||||
* 传递手机号或者用户名
|
||||
*
|
||||
* @param userName
|
||||
* @return
|
||||
* @param userName 手机号或者用户名
|
||||
* @return 会员信息
|
||||
*/
|
||||
private Member findMember(String userName) {
|
||||
QueryWrapper<Member> queryWrapper = new QueryWrapper();
|
||||
QueryWrapper<Member> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("username", userName).or().eq("mobile", userName);
|
||||
return this.getOne(queryWrapper);
|
||||
}
|
||||
@@ -192,10 +186,10 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, Member> impleme
|
||||
@Override
|
||||
public Token autoRegister(ConnectAuthUser authUser) {
|
||||
|
||||
if (StringUtils.isEmpty(authUser.getNickname())) {
|
||||
if (CharSequenceUtil.isEmpty(authUser.getNickname())) {
|
||||
authUser.setNickname("临时昵称");
|
||||
}
|
||||
if (StringUtils.isEmpty(authUser.getAvatar())) {
|
||||
if (CharSequenceUtil.isEmpty(authUser.getAvatar())) {
|
||||
authUser.setAvatar("https://i.loli.net/2020/11/19/LyN6JF7zZRskdIe.png");
|
||||
}
|
||||
try {
|
||||
@@ -321,6 +315,7 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, Member> impleme
|
||||
LambdaUpdateWrapper<Member> lambdaUpdateWrapper = Wrappers.lambdaUpdate();
|
||||
lambdaUpdateWrapper.eq(Member::getMobile, phone);
|
||||
lambdaUpdateWrapper.set(Member::getPassword, new BCryptPasswordEncoder().encode(password));
|
||||
cache.remove(CachePrefix.FIND_MOBILE + uuid);
|
||||
return this.update(lambdaUpdateWrapper);
|
||||
} else {
|
||||
throw new ServiceException(ResultCode.USER_PHONE_NOT_EXIST);
|
||||
@@ -351,7 +346,7 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, Member> impleme
|
||||
}
|
||||
//过滤会员昵称敏感词
|
||||
if (com.baomidou.mybatisplus.core.toolkit.StringUtils.isNotBlank(managerMemberEditDTO.getNickName())) {
|
||||
managerMemberEditDTO.setNickName(SensitiveWordsFilter.filter(managerMemberEditDTO.getNickName(), CharacterConstant.WILDCARD_STAR));
|
||||
managerMemberEditDTO.setNickName(SensitiveWordsFilter.filter(managerMemberEditDTO.getNickName()));
|
||||
}
|
||||
//如果密码不为空则加密密码
|
||||
if (com.baomidou.mybatisplus.core.toolkit.StringUtils.isNotBlank(managerMemberEditDTO.getPassword())) {
|
||||
@@ -369,13 +364,13 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, Member> impleme
|
||||
public IPage<MemberVO> getMemberPage(MemberSearchVO memberSearchVO, PageVO page) {
|
||||
QueryWrapper<Member> queryWrapper = Wrappers.query();
|
||||
//用户名查询
|
||||
queryWrapper.like(StringUtils.isNotBlank(memberSearchVO.getUsername()), "username", memberSearchVO.getUsername());
|
||||
queryWrapper.like(CharSequenceUtil.isNotBlank(memberSearchVO.getUsername()), "username", memberSearchVO.getUsername());
|
||||
//用户名查询
|
||||
queryWrapper.like(StringUtils.isNotBlank(memberSearchVO.getNickName()), "nick_name", memberSearchVO.getNickName());
|
||||
queryWrapper.like(CharSequenceUtil.isNotBlank(memberSearchVO.getNickName()), "nick_name", memberSearchVO.getNickName());
|
||||
//按照电话号码查询
|
||||
queryWrapper.like(StringUtils.isNotBlank(memberSearchVO.getMobile()), "mobile", memberSearchVO.getMobile());
|
||||
queryWrapper.like(CharSequenceUtil.isNotBlank(memberSearchVO.getMobile()), "mobile", memberSearchVO.getMobile());
|
||||
//按照会员状态查询
|
||||
queryWrapper.eq(StringUtils.isNotBlank(memberSearchVO.getDisabled()), "disabled",
|
||||
queryWrapper.eq(CharSequenceUtil.isNotBlank(memberSearchVO.getDisabled()), "disabled",
|
||||
memberSearchVO.getDisabled().equals(SwitchEnum.OPEN.name()) ? 1 : 0);
|
||||
queryWrapper.orderByDesc("create_time");
|
||||
return this.baseMapper.pageByMemberVO(PageUtil.initPage(page), queryWrapper);
|
||||
@@ -403,7 +398,7 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, Member> impleme
|
||||
}
|
||||
member.setPoint(currentPoint);
|
||||
member.setTotalPoint(totalPoint);
|
||||
Boolean result = this.updateById(member);
|
||||
boolean result = this.updateById(member);
|
||||
if (result) {
|
||||
//发送会员消息
|
||||
MemberPointMessage memberPointMessage = new MemberPointMessage();
|
||||
@@ -429,12 +424,6 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, Member> impleme
|
||||
return this.update(updateWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MemberDistributionVO> distribution() {
|
||||
List<MemberDistributionVO> memberDistributionVOS = this.baseMapper.distribution();
|
||||
return memberDistributionVOS;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据手机号获取会员
|
||||
*
|
||||
@@ -442,7 +431,7 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, Member> impleme
|
||||
* @return 会员
|
||||
*/
|
||||
private Member findByPhone(String mobilePhone) {
|
||||
QueryWrapper<Member> queryWrapper = new QueryWrapper();
|
||||
QueryWrapper<Member> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("mobile", mobilePhone);
|
||||
return this.baseMapper.selectOne(queryWrapper);
|
||||
}
|
||||
@@ -452,7 +441,7 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, Member> impleme
|
||||
*
|
||||
* @param uuid uuid
|
||||
* @param type 状态
|
||||
* @return
|
||||
* @return cookie中的联合登录对象
|
||||
*/
|
||||
private ConnectAuthUser getConnectAuthUser(String uuid, String type) {
|
||||
Object context = cache.get(ConnectService.cacheKey(type, uuid));
|
||||
@@ -470,10 +459,9 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, Member> impleme
|
||||
* @param type 状态
|
||||
*/
|
||||
private void loginBindUser(Member member, String unionId, String type) {
|
||||
LambdaQueryWrapper<Connect> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(Connect::getUnionId, unionId);
|
||||
queryWrapper.eq(Connect::getUnionType, type);
|
||||
Connect connect = connectService.getOne(queryWrapper);
|
||||
Connect connect = connectService.queryConnect(
|
||||
ConnectQueryDTO.builder().unionId(unionId).unionType(type).build()
|
||||
);
|
||||
if (connect == null) {
|
||||
connect = new Connect(member.getId(), unionId, type);
|
||||
connectService.save(connect);
|
||||
@@ -490,18 +478,16 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, Member> impleme
|
||||
String uuid = CookieUtil.getCookie(ConnectService.CONNECT_COOKIE, ThreadContextHolder.getHttpRequest());
|
||||
String connectType = CookieUtil.getCookie(ConnectService.CONNECT_TYPE, ThreadContextHolder.getHttpRequest());
|
||||
//如果联合登陆存储了信息
|
||||
if (StringUtils.isNotEmpty(uuid) && StringUtils.isNotEmpty(connectType)) {
|
||||
if (CharSequenceUtil.isNotEmpty(uuid) && CharSequenceUtil.isNotEmpty(connectType)) {
|
||||
try {
|
||||
//获取信息
|
||||
ConnectAuthUser connectAuthUser = getConnectAuthUser(uuid, connectType);
|
||||
if (connectAuthUser == null) {
|
||||
return;
|
||||
}
|
||||
//检测是否已经绑定过用户
|
||||
LambdaQueryWrapper<Connect> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(Connect::getUnionId, connectAuthUser.getUuid());
|
||||
queryWrapper.eq(Connect::getUnionType, connectType);
|
||||
Connect connect = connectService.getOne(queryWrapper);
|
||||
Connect connect = connectService.queryConnect(
|
||||
ConnectQueryDTO.builder().unionId(connectAuthUser.getUuid()).unionType(connectType).build()
|
||||
);
|
||||
if (connect == null) {
|
||||
connect = new Connect(member.getId(), connectAuthUser.getUuid(), connectType);
|
||||
connectService.save(connect);
|
||||
@@ -533,29 +519,24 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, Member> impleme
|
||||
String connectType = CookieUtil.getCookie(ConnectService.CONNECT_TYPE, ThreadContextHolder.getHttpRequest());
|
||||
|
||||
//如果联合登陆存储了信息
|
||||
if (StringUtils.isNotEmpty(uuid) && StringUtils.isNotEmpty(connectType)) {
|
||||
try {
|
||||
//枚举 联合登陆类型获取
|
||||
ConnectAuthEnum authInterface = ConnectAuthEnum.valueOf(connectType);
|
||||
if (CharSequenceUtil.isNotEmpty(uuid) && CharSequenceUtil.isNotEmpty(connectType)) {
|
||||
//枚举 联合登陆类型获取
|
||||
ConnectAuthEnum authInterface = ConnectAuthEnum.valueOf(connectType);
|
||||
|
||||
ConnectAuthUser connectAuthUser = getConnectAuthUser(uuid, connectType);
|
||||
if (connectAuthUser == null) {
|
||||
throw new ServiceException(ResultCode.USER_OVERDUE_CONNECT_ERROR);
|
||||
}
|
||||
//检测是否已经绑定过用户
|
||||
LambdaQueryWrapper<Connect> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(Connect::getUnionId, connectAuthUser.getUuid());
|
||||
queryWrapper.eq(Connect::getUnionType, connectType);
|
||||
Connect connect = connectService.getOne(queryWrapper);
|
||||
//没有关联则返回true,表示可以继续绑定
|
||||
if (connect == null) {
|
||||
connectAuthUser.setConnectEnum(authInterface);
|
||||
return connectAuthUser;
|
||||
} else {
|
||||
throw new ServiceException(ResultCode.USER_CONNECT_BANDING_ERROR);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw e;
|
||||
ConnectAuthUser connectAuthUser = getConnectAuthUser(uuid, connectType);
|
||||
if (connectAuthUser == null) {
|
||||
throw new ServiceException(ResultCode.USER_OVERDUE_CONNECT_ERROR);
|
||||
}
|
||||
//检测是否已经绑定过用户
|
||||
Connect connect = connectService.queryConnect(
|
||||
ConnectQueryDTO.builder().unionType(connectType).unionId(connectAuthUser.getUuid()).build()
|
||||
);
|
||||
//没有关联则返回true,表示可以继续绑定
|
||||
if (connect == null) {
|
||||
connectAuthUser.setConnectEnum(authInterface);
|
||||
return connectAuthUser;
|
||||
} else {
|
||||
throw new ServiceException(ResultCode.USER_CONNECT_BANDING_ERROR);
|
||||
}
|
||||
} else {
|
||||
throw new ServiceException(ResultCode.USER_CONNECT_NOT_EXIST_ERROR);
|
||||
@@ -563,19 +544,33 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, Member> impleme
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getMemberNum(MemberSearchVO memberSearchVO) {
|
||||
public long getMemberNum(MemberSearchVO memberSearchVO) {
|
||||
QueryWrapper<Member> queryWrapper = Wrappers.query();
|
||||
//用户名查询
|
||||
queryWrapper.like(StringUtils.isNotBlank(memberSearchVO.getUsername()), "username", memberSearchVO.getUsername());
|
||||
queryWrapper.like(CharSequenceUtil.isNotBlank(memberSearchVO.getUsername()), "username", memberSearchVO.getUsername());
|
||||
//按照电话号码查询
|
||||
queryWrapper.like(StringUtils.isNotBlank(memberSearchVO.getMobile()), "mobile", memberSearchVO.getMobile());
|
||||
queryWrapper.like(CharSequenceUtil.isNotBlank(memberSearchVO.getMobile()), "mobile", memberSearchVO.getMobile());
|
||||
//按照状态查询
|
||||
queryWrapper.eq(StringUtils.isNotBlank(memberSearchVO.getDisabled()), "disabled",
|
||||
queryWrapper.eq(CharSequenceUtil.isNotBlank(memberSearchVO.getDisabled()), "disabled",
|
||||
memberSearchVO.getDisabled().equals(SwitchEnum.OPEN.name()) ? 1 : 0);
|
||||
queryWrapper.orderByDesc("create_time");
|
||||
return this.count(queryWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定会员数据
|
||||
*
|
||||
* @param columns 指定获取的列
|
||||
* @param memberIds 会员ids
|
||||
* @return 指定会员数据
|
||||
*/
|
||||
@Override
|
||||
public List<Map<String, Object>> listFieldsByMemberIds(String columns, List<String> memberIds) {
|
||||
return this.listMaps(new QueryWrapper<Member>()
|
||||
.select(columns)
|
||||
.in(memberIds != null && !memberIds.isEmpty(), "id", memberIds));
|
||||
}
|
||||
|
||||
/**
|
||||
* 登出
|
||||
*/
|
||||
|
||||
@@ -3,16 +3,19 @@ package cn.lili.modules.member.serviceimpl;
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.exception.ServiceException;
|
||||
import cn.lili.common.security.context.UserContext;
|
||||
import cn.lili.mybatis.util.PageUtil;
|
||||
import cn.lili.common.vo.PageVO;
|
||||
import cn.lili.modules.member.entity.dos.StoreCollection;
|
||||
import cn.lili.modules.member.entity.dto.CollectionDTO;
|
||||
import cn.lili.modules.member.entity.vo.StoreCollectionVO;
|
||||
import cn.lili.modules.member.mapper.StoreCollectionMapper;
|
||||
import cn.lili.modules.member.service.StoreCollectionService;
|
||||
import cn.lili.modules.store.service.StoreService;
|
||||
import cn.lili.mybatis.util.PageUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Optional;
|
||||
@@ -26,6 +29,10 @@ import java.util.Optional;
|
||||
@Service
|
||||
public class StoreCollectionServiceImpl extends ServiceImpl<StoreCollectionMapper, StoreCollection> implements StoreCollectionService {
|
||||
|
||||
|
||||
@Autowired
|
||||
private StoreService storeService;
|
||||
|
||||
@Override
|
||||
public IPage<StoreCollectionVO> storeCollection(PageVO pageVo) {
|
||||
QueryWrapper<StoreCollectionVO> queryWrapper = new QueryWrapper();
|
||||
@@ -49,6 +56,7 @@ public class StoreCollectionServiceImpl extends ServiceImpl<StoreCollectionMappe
|
||||
.eq(StoreCollection::getStoreId, storeId)) == null) {
|
||||
StoreCollection storeCollection = new StoreCollection(UserContext.getCurrentUser().getId(), storeId);
|
||||
this.save(storeCollection);
|
||||
storeService.updateStoreCollectionNum(new CollectionDTO(storeId, 1));
|
||||
return storeCollection;
|
||||
}
|
||||
throw new ServiceException(ResultCode.USER_COLLECTION_EXIST);
|
||||
@@ -59,6 +67,7 @@ public class StoreCollectionServiceImpl extends ServiceImpl<StoreCollectionMappe
|
||||
QueryWrapper<StoreCollection> queryWrapper = new QueryWrapper();
|
||||
queryWrapper.eq("member_id", UserContext.getCurrentUser().getId());
|
||||
queryWrapper.eq("store_id", storeId);
|
||||
storeService.updateStoreCollectionNum(new CollectionDTO(storeId, -1));
|
||||
return this.remove(queryWrapper);
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
package cn.lili.modules.system.serviceimpl;
|
||||
package cn.lili.modules.member.serviceimpl;
|
||||
|
||||
import cn.lili.modules.member.mapper.StoreLogisticsMapper;
|
||||
import cn.lili.modules.member.service.StoreLogisticsService;
|
||||
import cn.lili.modules.store.entity.dos.StoreLogistics;
|
||||
import cn.lili.modules.system.entity.vo.StoreLogisticsVO;
|
||||
import cn.lili.modules.system.mapper.StoreLogisticsMapper;
|
||||
import cn.lili.modules.system.service.StoreLogisticsService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
@@ -52,7 +52,7 @@ public class MemberTokenGenerate extends AbstractTokenGenerate {
|
||||
member.setClientEnum(clientTypeEnum.name());
|
||||
memberService.updateById(member);
|
||||
|
||||
AuthUser authUser = new AuthUser(member.getUsername(), member.getId(),member.getNickName(), UserEnums.MEMBER);
|
||||
AuthUser authUser = new AuthUser(member.getUsername(), member.getId(), member.getNickName(), member.getFace(), UserEnums.MEMBER);
|
||||
//登陆成功生成token
|
||||
return tokenUtil.createToken(username, authUser, longTerm, UserEnums.MEMBER);
|
||||
}
|
||||
|
||||
@@ -38,10 +38,11 @@ public class StoreTokenGenerate extends AbstractTokenGenerate {
|
||||
if (!member.getHaveStore()) {
|
||||
throw new ServiceException(ResultCode.STORE_NOT_OPEN);
|
||||
}
|
||||
AuthUser user = new AuthUser(member.getUsername(), member.getId(), member.getNickName(), UserEnums.STORE);
|
||||
LambdaQueryWrapper<Store> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(Store::getMemberId, member.getId());
|
||||
Store store = storeService.getOne(queryWrapper);
|
||||
AuthUser user = new AuthUser(member.getUsername(), member.getId(), member.getNickName(), store.getStoreLogo(), UserEnums.STORE);
|
||||
|
||||
user.setStoreId(store.getId());
|
||||
user.setStoreName(store.getStoreName());
|
||||
return tokenUtil.createToken(username, user, longTerm, UserEnums.STORE);
|
||||
|
||||
@@ -1,12 +1,22 @@
|
||||
package cn.lili.modules.message.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import cn.lili.modules.message.entity.dos.ShortLink;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 短链接 业务层
|
||||
*
|
||||
* @author Chopper
|
||||
*/
|
||||
public interface ShortLinkService extends IService<ShortLink> {
|
||||
|
||||
/**
|
||||
* 根据模型,查询返回的集合
|
||||
*
|
||||
* @param shortLink 短链接模型
|
||||
* @return 端链接集合
|
||||
*/
|
||||
List<ShortLink> queryShortLinks(ShortLink shortLink);
|
||||
}
|
||||
@@ -3,16 +3,24 @@ package cn.lili.modules.message.serviceimpl;
|
||||
import cn.lili.modules.message.entity.dos.ShortLink;
|
||||
import cn.lili.modules.message.mapper.ShortLinkMapper;
|
||||
import cn.lili.modules.message.service.ShortLinkService;
|
||||
import cn.lili.mybatis.util.PageUtil;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 短链接 业务实现
|
||||
*
|
||||
* @author Chopper
|
||||
*/
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class ShortLinkServiceImpl extends ServiceImpl<ShortLinkMapper, ShortLink> implements ShortLinkService {
|
||||
|
||||
@Override
|
||||
public List<ShortLink> queryShortLinks(ShortLink shortLink) {
|
||||
return this.list(PageUtil.initWrapper(shortLink));
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package cn.lili.modules.order.order.aop;
|
||||
package cn.lili.modules.order.aftersale.aop;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package cn.lili.modules.order.order.aop;
|
||||
package cn.lili.modules.order.aftersale.aop;
|
||||
|
||||
import cn.lili.common.security.AuthUser;
|
||||
import cn.lili.common.security.context.UserContext;
|
||||
import cn.lili.common.security.enums.UserEnums;
|
||||
import cn.lili.common.utils.SpelUtil;
|
||||
import cn.lili.common.utils.ThreadPoolUtil;
|
||||
import cn.lili.modules.order.order.service.AfterSaleLogService;
|
||||
import cn.lili.modules.order.trade.entity.dos.AfterSaleLog;
|
||||
import cn.lili.modules.order.aftersale.entity.dos.AfterSaleLog;
|
||||
import cn.lili.modules.order.aftersale.service.AfterSaleLogService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.aspectj.lang.JoinPoint;
|
||||
import org.aspectj.lang.annotation.AfterReturning;
|
||||
@@ -32,7 +32,7 @@ public class AfterSaleOperationLogAspect {
|
||||
@Autowired
|
||||
private AfterSaleLogService afterSaleLogService;
|
||||
|
||||
@AfterReturning(returning = "rvt", pointcut = "@annotation(cn.lili.modules.order.order.aop.AfterSaleLogPoint)")
|
||||
@AfterReturning(returning = "rvt", pointcut = "@annotation(cn.lili.modules.order.aftersale.aop.AfterSaleLogPoint)")
|
||||
public void afterReturning(JoinPoint joinPoint, Object rvt) {
|
||||
try {
|
||||
AuthUser auth = UserContext.getCurrentUser();
|
||||
@@ -1,4 +1,4 @@
|
||||
package cn.lili.modules.order.order.entity.dos;
|
||||
package cn.lili.modules.order.aftersale.entity.dos;
|
||||
|
||||
import cn.lili.mybatis.BaseEntity;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
@@ -142,7 +142,7 @@ public class AfterSale extends BaseEntity {
|
||||
private String mLogisticsName;
|
||||
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
@ApiModelProperty(value = "买家发货时间")
|
||||
private Date mDeliverTime;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package cn.lili.modules.order.trade.entity.dos;
|
||||
package cn.lili.modules.order.aftersale.entity.dos;
|
||||
|
||||
import cn.lili.common.security.enums.UserEnums;
|
||||
import cn.lili.mybatis.BaseIdEntity;
|
||||
@@ -1,4 +1,4 @@
|
||||
package cn.lili.modules.order.order.entity.dos;
|
||||
package cn.lili.modules.order.aftersale.entity.dos;
|
||||
|
||||
import cn.lili.mybatis.BaseEntity;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
@@ -1,4 +1,4 @@
|
||||
package cn.lili.modules.order.order.entity.dto;
|
||||
package cn.lili.modules.order.aftersale.entity.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
@@ -1,7 +1,7 @@
|
||||
package cn.lili.modules.order.order.entity.dto;
|
||||
package cn.lili.modules.order.aftersale.entity.dto;
|
||||
|
||||
|
||||
import cn.lili.modules.promotion.entity.dto.BasePromotion;
|
||||
import cn.lili.modules.promotion.entity.dos.BasePromotions;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@@ -74,7 +74,7 @@ public class AfterSalePriceDetailDTO implements Serializable {
|
||||
* 参与的促销活动
|
||||
*/
|
||||
@ApiModelProperty(value = "参与的促销活动")
|
||||
private List<BasePromotion> joinPromotion;
|
||||
private List<BasePromotions> joinPromotion;
|
||||
|
||||
|
||||
public AfterSalePriceDetailDTO() {
|
||||
@@ -1,4 +1,4 @@
|
||||
package cn.lili.modules.order.order.entity.enums;
|
||||
package cn.lili.modules.order.aftersale.entity.enums;
|
||||
|
||||
/**
|
||||
* 交易投诉状态
|
||||
@@ -1,6 +1,6 @@
|
||||
package cn.lili.modules.order.order.entity.vo;
|
||||
package cn.lili.modules.order.aftersale.entity.vo;
|
||||
|
||||
import cn.lili.modules.order.order.entity.dos.AfterSale;
|
||||
import cn.lili.modules.order.aftersale.entity.dos.AfterSale;
|
||||
import cn.lili.modules.order.trade.entity.enums.AfterSaleStatusEnum;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
@@ -1,4 +1,4 @@
|
||||
package cn.lili.modules.order.order.entity.vo;
|
||||
package cn.lili.modules.order.aftersale.entity.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
@@ -1,12 +1,13 @@
|
||||
package cn.lili.modules.order.order.entity.vo;
|
||||
package cn.lili.modules.order.aftersale.entity.vo;
|
||||
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import cn.lili.common.security.context.UserContext;
|
||||
import cn.lili.common.security.enums.UserEnums;
|
||||
import cn.lili.common.utils.StringUtils;
|
||||
import cn.lili.common.vo.PageVO;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.util.Date;
|
||||
@@ -17,6 +18,7 @@ import java.util.Date;
|
||||
* @author paulG
|
||||
* @since 2020/12/4
|
||||
**/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class AfterSaleSearchParams extends PageVO {
|
||||
|
||||
@@ -44,6 +46,9 @@ public class AfterSaleSearchParams extends PageVO {
|
||||
@ApiModelProperty(value = "实际退款金额,可以为范围,如10_1000")
|
||||
private String actualRefundPrice;
|
||||
|
||||
@ApiModelProperty(value = "总价格,可以为范围,如10_1000")
|
||||
private String flowPrice;
|
||||
|
||||
/**
|
||||
* @see cn.lili.modules.order.trade.entity.enums.AfterSaleTypeEnum
|
||||
*/
|
||||
@@ -66,33 +71,33 @@ public class AfterSaleSearchParams extends PageVO {
|
||||
|
||||
public <T> QueryWrapper<T> queryWrapper() {
|
||||
QueryWrapper<T> queryWrapper = new QueryWrapper<>();
|
||||
if (StringUtils.isNotEmpty(sn)) {
|
||||
if (CharSequenceUtil.isNotEmpty(sn)) {
|
||||
queryWrapper.like("sn", sn);
|
||||
}
|
||||
if (StringUtils.isNotEmpty(orderSn)) {
|
||||
if (CharSequenceUtil.isNotEmpty(orderSn)) {
|
||||
queryWrapper.like("order_sn", orderSn);
|
||||
}
|
||||
//按买家查询
|
||||
if (StringUtils.equals(UserContext.getCurrentUser().getRole().name(), UserEnums.MEMBER.name())) {
|
||||
if (CharSequenceUtil.equals(UserContext.getCurrentUser().getRole().name(), UserEnums.MEMBER.name())) {
|
||||
queryWrapper.eq("member_id", UserContext.getCurrentUser().getId());
|
||||
}
|
||||
//按卖家查询
|
||||
if (StringUtils.equals(UserContext.getCurrentUser().getRole().name(), UserEnums.STORE.name())) {
|
||||
if (CharSequenceUtil.equals(UserContext.getCurrentUser().getRole().name(), UserEnums.STORE.name())) {
|
||||
queryWrapper.eq("store_id", UserContext.getCurrentUser().getStoreId());
|
||||
}
|
||||
|
||||
if (StringUtils.equals(UserContext.getCurrentUser().getRole().name(), UserEnums.MANAGER.name())
|
||||
&& StringUtils.isNotEmpty(storeId)
|
||||
if (CharSequenceUtil.equals(UserContext.getCurrentUser().getRole().name(), UserEnums.MANAGER.name())
|
||||
&& CharSequenceUtil.isNotEmpty(storeId)
|
||||
) {
|
||||
queryWrapper.eq("store_id", storeId);
|
||||
}
|
||||
if (StringUtils.isNotEmpty(memberName)) {
|
||||
if (CharSequenceUtil.isNotEmpty(memberName)) {
|
||||
queryWrapper.like("member_name", memberName);
|
||||
}
|
||||
if (StringUtils.isNotEmpty(storeName)) {
|
||||
if (CharSequenceUtil.isNotEmpty(storeName)) {
|
||||
queryWrapper.like("store_name", storeName);
|
||||
}
|
||||
if (StringUtils.isNotEmpty(goodsName)) {
|
||||
if (CharSequenceUtil.isNotEmpty(goodsName)) {
|
||||
queryWrapper.like("goods_name", goodsName);
|
||||
}
|
||||
//按时间查询
|
||||
@@ -102,10 +107,10 @@ public class AfterSaleSearchParams extends PageVO {
|
||||
if (endDate != null) {
|
||||
queryWrapper.le("create_time", endDate);
|
||||
}
|
||||
if (StringUtils.isNotEmpty(serviceStatus)) {
|
||||
if (CharSequenceUtil.isNotEmpty(serviceStatus)) {
|
||||
queryWrapper.eq("service_status", serviceStatus);
|
||||
}
|
||||
if (StringUtils.isNotEmpty(serviceType)) {
|
||||
if (CharSequenceUtil.isNotEmpty(serviceType)) {
|
||||
queryWrapper.eq("service_type", serviceType);
|
||||
}
|
||||
this.betweenWrapper(queryWrapper);
|
||||
@@ -114,20 +119,28 @@ public class AfterSaleSearchParams extends PageVO {
|
||||
}
|
||||
|
||||
private <T> void betweenWrapper(QueryWrapper<T> queryWrapper) {
|
||||
if (StringUtils.isNotEmpty(applyRefundPrice)) {
|
||||
if (CharSequenceUtil.isNotEmpty(applyRefundPrice)) {
|
||||
String[] s = applyRefundPrice.split("_");
|
||||
if (s.length > 1) {
|
||||
queryWrapper.ge("apply_refund_price", s[1]);
|
||||
queryWrapper.between("apply_refund_price", s[0], s[1]);
|
||||
} else {
|
||||
queryWrapper.le("apply_refund_price", s[0]);
|
||||
queryWrapper.ge("apply_refund_price", s[0]);
|
||||
}
|
||||
}
|
||||
if (StringUtils.isNotEmpty(actualRefundPrice)) {
|
||||
if (CharSequenceUtil.isNotEmpty(actualRefundPrice)) {
|
||||
String[] s = actualRefundPrice.split("_");
|
||||
if (s.length > 1) {
|
||||
queryWrapper.ge("actual_refund_price", s[1]);
|
||||
queryWrapper.between("actual_refund_price", s[0], s[1]);
|
||||
} else {
|
||||
queryWrapper.le("actual_refund_price", s[0]);
|
||||
queryWrapper.ge("actual_refund_price", s[0]);
|
||||
}
|
||||
}
|
||||
if (CharSequenceUtil.isNotEmpty(flowPrice)) {
|
||||
String[] s = flowPrice.split("_");
|
||||
if (s.length > 1) {
|
||||
queryWrapper.between("flow_price", s[0], s[1]);
|
||||
} else {
|
||||
queryWrapper.ge("flow_price", s[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
package cn.lili.modules.order.order.entity.vo;
|
||||
package cn.lili.modules.order.aftersale.entity.vo;
|
||||
|
||||
import cn.lili.modules.order.order.entity.dos.AfterSale;
|
||||
import jdk.nashorn.internal.objects.annotations.Getter;
|
||||
import cn.lili.modules.order.aftersale.entity.dos.AfterSale;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
@@ -15,7 +14,6 @@ public class AfterSaleVO extends AfterSale {
|
||||
/**
|
||||
* 初始化自身状态
|
||||
*/
|
||||
@Getter
|
||||
public AfterSaleAllowOperation getAfterSaleAllowOperationVO() {
|
||||
|
||||
//设置订单的可操作状态
|
||||
@@ -1,6 +1,6 @@
|
||||
package cn.lili.modules.order.trade.mapper;
|
||||
package cn.lili.modules.order.aftersale.mapper;
|
||||
|
||||
import cn.lili.modules.order.trade.entity.dos.AfterSaleLog;
|
||||
import cn.lili.modules.order.aftersale.entity.dos.AfterSaleLog;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
@@ -1,7 +1,7 @@
|
||||
package cn.lili.modules.order.order.mapper;
|
||||
package cn.lili.modules.order.aftersale.mapper;
|
||||
|
||||
import cn.lili.modules.order.order.entity.dos.AfterSale;
|
||||
import cn.lili.modules.order.order.entity.vo.AfterSaleVO;
|
||||
import cn.lili.modules.order.aftersale.entity.dos.AfterSale;
|
||||
import cn.lili.modules.order.aftersale.entity.vo.AfterSaleVO;
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
@@ -1,6 +1,6 @@
|
||||
package cn.lili.modules.order.order.mapper;
|
||||
package cn.lili.modules.order.aftersale.mapper;
|
||||
|
||||
import cn.lili.modules.order.order.entity.dos.AfterSaleReason;
|
||||
import cn.lili.modules.order.aftersale.entity.dos.AfterSaleReason;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
@@ -1,6 +1,6 @@
|
||||
package cn.lili.modules.order.order.service;
|
||||
package cn.lili.modules.order.aftersale.service;
|
||||
|
||||
import cn.lili.modules.order.trade.entity.dos.AfterSaleLog;
|
||||
import cn.lili.modules.order.aftersale.entity.dos.AfterSaleLog;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
@@ -1,6 +1,6 @@
|
||||
package cn.lili.modules.order.order.service;
|
||||
package cn.lili.modules.order.aftersale.service;
|
||||
|
||||
import cn.lili.modules.order.order.entity.dos.AfterSaleReason;
|
||||
import cn.lili.modules.order.aftersale.entity.dos.AfterSaleReason;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
@@ -1,13 +1,11 @@
|
||||
package cn.lili.modules.order.order.service;
|
||||
package cn.lili.modules.order.aftersale.service;
|
||||
|
||||
|
||||
import cn.lili.common.vo.PageVO;
|
||||
import cn.lili.modules.order.order.entity.dos.AfterSale;
|
||||
import cn.lili.modules.order.order.entity.dto.AfterSaleDTO;
|
||||
import cn.lili.modules.order.order.entity.vo.AfterSaleApplyVO;
|
||||
import cn.lili.modules.order.order.entity.vo.AfterSaleSearchParams;
|
||||
import cn.lili.modules.order.order.entity.vo.AfterSaleVO;
|
||||
import cn.lili.modules.statistics.entity.dto.StatisticsQueryParam;
|
||||
import cn.lili.modules.order.aftersale.entity.dos.AfterSale;
|
||||
import cn.lili.modules.order.aftersale.entity.dto.AfterSaleDTO;
|
||||
import cn.lili.modules.order.aftersale.entity.vo.AfterSaleApplyVO;
|
||||
import cn.lili.modules.order.aftersale.entity.vo.AfterSaleSearchParams;
|
||||
import cn.lili.modules.order.aftersale.entity.vo.AfterSaleVO;
|
||||
import cn.lili.modules.store.entity.dto.StoreAfterSaleAddressDTO;
|
||||
import cn.lili.modules.system.entity.vo.Traces;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
@@ -129,13 +127,6 @@ public interface AfterSaleService extends IService<AfterSale> {
|
||||
*/
|
||||
AfterSale cancel(String afterSaleSn);
|
||||
|
||||
/**
|
||||
* 获取待处理售后数量
|
||||
*
|
||||
* @param serviceType 售后类型
|
||||
* @return 待处理售后数量
|
||||
*/
|
||||
Integer applyNum(String serviceType);
|
||||
|
||||
/**
|
||||
* 根据售后单号获取店铺退货收货地址信息
|
||||
@@ -145,12 +136,4 @@ public interface AfterSaleService extends IService<AfterSale> {
|
||||
*/
|
||||
StoreAfterSaleAddressDTO getStoreAfterSaleAddressDTO(String sn);
|
||||
|
||||
/**
|
||||
* 获取统计的售后
|
||||
*
|
||||
* @param statisticsQueryParam 统计搜索参数
|
||||
* @param pageVO 分页
|
||||
* @return 售后分页列表
|
||||
*/
|
||||
IPage<AfterSale> getStatistics(StatisticsQueryParam statisticsQueryParam, PageVO pageVO);
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
package cn.lili.modules.order.order.serviceimpl;
|
||||
package cn.lili.modules.order.aftersale.serviceimpl;
|
||||
|
||||
import cn.lili.modules.order.order.service.AfterSaleLogService;
|
||||
import cn.lili.modules.order.trade.entity.dos.AfterSaleLog;
|
||||
import cn.lili.modules.order.trade.mapper.AfterSaleLogMapper;
|
||||
import cn.lili.modules.order.aftersale.entity.dos.AfterSaleLog;
|
||||
import cn.lili.modules.order.aftersale.mapper.AfterSaleLogMapper;
|
||||
import cn.lili.modules.order.aftersale.service.AfterSaleLogService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
@@ -1,8 +1,8 @@
|
||||
package cn.lili.modules.order.order.serviceimpl;
|
||||
package cn.lili.modules.order.aftersale.serviceimpl;
|
||||
|
||||
import cn.lili.modules.order.order.entity.dos.AfterSaleReason;
|
||||
import cn.lili.modules.order.order.mapper.AfterSaleReasonMapper;
|
||||
import cn.lili.modules.order.order.service.AfterSaleReasonService;
|
||||
import cn.lili.modules.order.aftersale.entity.dos.AfterSaleReason;
|
||||
import cn.lili.modules.order.aftersale.mapper.AfterSaleReasonMapper;
|
||||
import cn.lili.modules.order.aftersale.service.AfterSaleReasonService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user