代码结构优化。默认拼团结束时间修改为24小时

This commit is contained in:
paulGao 2022-06-22 14:44:58 +08:00
parent 00964e6bbf
commit cb52fca2a4
9 changed files with 32 additions and 33 deletions

View File

@ -11,7 +11,6 @@ import org.redisson.config.ClusterServersConfig;
import org.redisson.config.Config;
import org.redisson.config.SentinelServersConfig;
import org.redisson.config.SingleServerConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
@ -56,13 +55,11 @@ import java.util.Map;
public class RedisConfig extends CachingConfigurerSupport {
private static final String REDIS_PREFIX = "redis://";
@Value("${lili.cache.timeout:7200}")
private Integer timeout;
@Autowired
private RedisProperties redisProperties;
/**
* 当有多个管理器的时候必须使用该注解在一个管理器上注释表示该管理器为默认的管理器
*
@ -101,7 +98,7 @@ public class RedisConfig extends CachingConfigurerSupport {
public RedisTemplate<Object, Object> redisTemplate(LettuceConnectionFactory lettuceConnectionFactory) {
RedisTemplate<Object, Object> template = new RedisTemplate<>();
//使用fastjson序列化
FastJsonRedisSerializer fastJsonRedisSerializer = new FastJsonRedisSerializer(Object.class);
FastJsonRedisSerializer<Object> fastJsonRedisSerializer = new FastJsonRedisSerializer<>(Object.class);
//value值的序列化采用fastJsonRedisSerializer
template.setValueSerializer(fastJsonRedisSerializer);
template.setHashValueSerializer(fastJsonRedisSerializer);
@ -113,7 +110,7 @@ public class RedisConfig extends CachingConfigurerSupport {
}
@Bean(destroyMethod = "shutdown")
public RedissonClient redisson() {
public RedissonClient redisson(RedisProperties redisProperties) {
Config config = new Config();
if (redisProperties.getSentinel() != null && !redisProperties.getSentinel().getNodes().isEmpty()) {
// 哨兵模式
@ -121,7 +118,7 @@ public class RedisConfig extends CachingConfigurerSupport {
sentinelServersConfig.setMasterName(redisProperties.getSentinel().getMaster());
List<String> sentinelAddress = new ArrayList<>();
for (String node : redisProperties.getCluster().getNodes()) {
sentinelAddress.add("redis://" + node);
sentinelAddress.add(REDIS_PREFIX + node);
}
sentinelServersConfig.setSentinelAddresses(sentinelAddress);
if (CharSequenceUtil.isNotEmpty(redisProperties.getSentinel().getPassword())) {
@ -132,7 +129,7 @@ public class RedisConfig extends CachingConfigurerSupport {
ClusterServersConfig clusterServersConfig = config.useClusterServers();
List<String> clusterNodes = new ArrayList<>();
for (String node : redisProperties.getCluster().getNodes()) {
clusterNodes.add("redis://" + node);
clusterNodes.add(REDIS_PREFIX + node);
}
clusterServersConfig.setNodeAddresses(clusterNodes);
if (CharSequenceUtil.isNotEmpty(redisProperties.getPassword())) {
@ -140,7 +137,7 @@ public class RedisConfig extends CachingConfigurerSupport {
}
} else {
SingleServerConfig singleServerConfig = config.useSingleServer();
singleServerConfig.setAddress("redis://" + redisProperties.getHost() + ":" + redisProperties.getPort());
singleServerConfig.setAddress(REDIS_PREFIX + redisProperties.getHost() + ":" + redisProperties.getPort());
if (CharSequenceUtil.isNotEmpty(redisProperties.getPassword())) {
singleServerConfig.setPassword(redisProperties.getPassword());
}

View File

@ -89,6 +89,7 @@ public class ConnectServiceImpl extends ServiceImpl<ConnectMapper, Connect> impl
}
return memberTokenGenerate.createToken(member, longTerm);
} catch (NoPermissionException e) {
log.error("联合登陆失败:", e);
throw e;
}
}
@ -121,7 +122,7 @@ public class ConnectServiceImpl extends ServiceImpl<ConnectMapper, Connect> impl
@Override
public void bind(String unionId, String type) {
AuthUser authUser = UserContext.getCurrentUser();
AuthUser authUser = Objects.requireNonNull(UserContext.getCurrentUser());
Connect connect = new Connect(authUser.getId(), unionId, type);
this.save(connect);
}
@ -160,6 +161,7 @@ public class ConnectServiceImpl extends ServiceImpl<ConnectMapper, Connect> impl
@Override
@Transactional
public Token miniProgramAutoLogin(WechatMPLoginParams params) {
Object cacheData = cache.get(CachePrefix.WECHAT_SESSION_PARAMS.getPrefix() + params.getUuid());
@ -186,8 +188,8 @@ public class ConnectServiceImpl extends ServiceImpl<ConnectMapper, Connect> impl
/**
* 通过微信返回等code 获取openid 等信息
*
* @param code
* @return
* @param code 微信code
* @return 微信返回的信息
*/
public JSONObject getConnect(String code) {
WechatConnectSettingItem setting = getWechatMPSetting();
@ -208,11 +210,12 @@ public class ConnectServiceImpl extends ServiceImpl<ConnectMapper, Connect> impl
* @param params 微信小程序自动登录参数
* @param openId 微信openid
* @param unionId 微信unionid
* @return
* @return token
*/
@Transactional(rollbackFor = Exception.class)
public Token phoneMpBindAndLogin(String sessionKey, WechatMPLoginParams params, String openId, String unionId) {
String encryptedData = params.getEncryptedData(), iv = params.getIv();
String encryptedData = params.getEncryptedData();
String iv = params.getIv();
JSONObject userInfo = this.getUserInfo(encryptedData, sessionKey, iv);
log.info("联合登陆返回:{}", userInfo.toString());
String phone = (String) userInfo.get("purePhoneNumber");
@ -259,9 +262,9 @@ public class ConnectServiceImpl extends ServiceImpl<ConnectMapper, Connect> impl
* 这样微信小程序注册之后其他app 公众号页面都可以实现绑定自动登录功能
* </p>
*
* @param openId
* @param unionId
* @param member
* @param openId 微信openid
* @param unionId 微信unionid
* @param member 会员
*/
private void bindMpMember(String openId, String unionId, Member member) {
@ -272,7 +275,7 @@ public class ConnectServiceImpl extends ServiceImpl<ConnectMapper, Connect> impl
lambdaQueryWrapper.eq(Connect::getUnionId, unionId);
lambdaQueryWrapper.eq(Connect::getUnionType, ConnectEnum.WECHAT.name());
List<Connect> connects = this.list(lambdaQueryWrapper);
if (connects.size() == 0) {
if (connects.isEmpty()) {
Connect connect = new Connect();
connect.setUnionId(unionId);
connect.setUserId(member.getId());
@ -281,7 +284,7 @@ public class ConnectServiceImpl extends ServiceImpl<ConnectMapper, Connect> impl
}
}//如果openid 不为空 则为账号绑定openid
if (CharSequenceUtil.isNotEmpty(openId)) {
LambdaQueryWrapper<Connect> lambdaQueryWrapper = new LambdaQueryWrapper();
LambdaQueryWrapper<Connect> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(Connect::getUnionId, openId);
lambdaQueryWrapper.eq(Connect::getUnionType, ConnectEnum.WECHAT_MP_OPEN_ID.name());
List<Connect> connects = this.list(lambdaQueryWrapper);

View File

@ -24,6 +24,7 @@ public class ManagerMemberEditDTO {
@ApiModelProperty(value = "会员用户名,用户名不能进行修改", required = true)
@NotNull(message = "会员用户名不能为空")
private String id;
@ApiModelProperty(value = "会员用户名,用户名不能进行修改", required = true)
@NotNull(message = "会员用户名不能为空")
private String username;
@ -48,7 +49,7 @@ public class ManagerMemberEditDTO {
private Integer sex;
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
@DateTimeFormat(pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern = "yyyy-MM-dd")
@ApiModelProperty(value = "会员生日")
private Date birthday;

View File

@ -811,10 +811,10 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
List<Order> list = this.getPintuanOrder(pintuanId, parentOrderSn);
int count = list.size();
if (count == 1) {
//如果为开团订单则发布一个小时的延时任务时间到达后如果未成团则自动结束未开启虚拟成团的情况下
//如果为开团订单则发布一个24小时的延时任务时间到达后如果未成团则自动结束未开启虚拟成团的情况下
PintuanOrderMessage pintuanOrderMessage = new PintuanOrderMessage();
//开团结束时间
long startTime = DateUtil.offsetMinute(new Date(), 2).getTime();
long startTime = DateUtil.offsetHour(new Date(), 24).getTime();
pintuanOrderMessage.setOrderSn(parentOrderSn);
pintuanOrderMessage.setPintuanId(pintuanId);
TimeTriggerMsg timeTriggerMsg = new TimeTriggerMsg(TimeExecuteConstant.PROMOTION_EXECUTOR,

View File

@ -299,7 +299,7 @@ public class PintuanServiceImpl extends AbstractPromotionsServiceImpl<PintuanMap
for (PromotionGoods promotionGood : promotionGoods) {
if (goodsSkuService.getGoodsSkuByIdFromCache(promotionGood.getSkuId()) == null) {
log.error("商品[" + promotionGood.getGoodsName() + "]不存在或处于不可售卖状态!");
throw new ServiceException();
throw new ServiceException("商品[" + promotionGood.getGoodsName() + "]不存在或处于不可售卖状态!");
}
//查询是否在同一时间段参与了拼团活动
Integer count = promotionGoodsService.findInnerOverlapPromotionGoods(PromotionTypeEnum.SECKILL.name(), promotionGood.getSkuId(), pintuan.getStartTime(), pintuan.getEndTime(), pintuan.getId());

View File

@ -133,12 +133,8 @@ public class PromotionTools {
promotionGoods.setStoreName(promotion.getStoreName());
}
promotionGoods.setTitle(promotion.getPromotionName());
if (promotionGoods.getStartTime() == null) {
promotionGoods.setStartTime(promotion.getStartTime());
}
if (promotionGoods.getEndTime() == null) {
promotionGoods.setEndTime(promotion.getEndTime());
}
promotionGoods.setStartTime(promotion.getStartTime());
promotionGoods.setEndTime(promotion.getEndTime());
promotionGoods.setPromotionType(promotionTypeEnum.name());
promotionGoods.setNum(0);
promotionGoods.setDeleteFlag(promotion.getDeleteFlag());

View File

@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotEmpty;
@ -18,6 +19,7 @@ import javax.validation.constraints.NotEmpty;
@Data
@TableName("li_custom_words")
@ApiModel(value = "自定义分词")
@EqualsAndHashCode(callSuper = true)
public class CustomWords extends BaseEntity {
private static final long serialVersionUID = 650889506808657977L;

View File

@ -4,7 +4,6 @@ import cn.lili.common.vo.PageVO;
import cn.lili.modules.search.entity.dos.EsGoodsIndex;
import cn.lili.modules.search.entity.dos.EsGoodsRelatedInfo;
import cn.lili.modules.search.entity.dto.EsGoodsSearchDTO;
import cn.lili.modules.search.entity.dto.HotWordsDTO;
import org.springframework.data.elasticsearch.core.SearchPage;
import java.util.List;

View File

@ -55,8 +55,8 @@ import java.util.*;
@Service
public class EsGoodsSearchServiceImpl implements EsGoodsSearchService {
// 最小分词匹配
private static final String MINIMUM_SHOULD_MATCH = "2";
// 最小分词匹配
private static final String MINIMUM_SHOULD_MATCH = "20%";
private static final String ATTR_PATH = "attrList";
private static final String ATTR_VALUE = "attrList.value";
@ -539,6 +539,7 @@ public class EsGoodsSearchServiceImpl implements EsGoodsSearchService {
.setMinScore(2);
//聚合搜索则将结果放入过滤条件
filterBuilder.must(functionScoreQueryBuilder);
filterBuilder.should(QueryBuilders.boolQuery().should(QueryBuilders.matchPhraseQuery("goodsName", keyword).boost(10)));
}
/**