merge master
This commit is contained in:
@@ -55,7 +55,6 @@ public class SmsUtilAliImplService implements SmsUtil, AliSmsUtil {
|
||||
public void sendSmsCode(String mobile, VerificationEnums verificationEnums, String uuid) {
|
||||
|
||||
String code = CommonUtil.getRandomNum();
|
||||
code = "111111";
|
||||
|
||||
switch (verificationEnums) {
|
||||
//如果某个模版需要自定义,则在此处进行调整
|
||||
@@ -67,7 +66,7 @@ public class SmsUtilAliImplService implements SmsUtil, AliSmsUtil {
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("code", code);
|
||||
cache.put(cacheKey(verificationEnums, mobile, uuid), code, 300L);
|
||||
//this.sendSmsCode("北京宏业汇成科技有限公司",mobile, params, verificationEnums.getSmsTemplate());
|
||||
this.sendSmsCode("北京宏业汇成科技有限公司",mobile, params, "SMS_205755300");
|
||||
break;
|
||||
}
|
||||
case UPDATE_PASSWORD: {
|
||||
@@ -80,7 +79,7 @@ public class SmsUtilAliImplService implements SmsUtil, AliSmsUtil {
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("code", code);
|
||||
cache.put(cacheKey(verificationEnums, memberMobile, uuid), code, 300L);
|
||||
//this.sendSmsCode("北京宏业汇成科技有限公司",mobile, params, verificationEnums.getSmsTemplate());
|
||||
this.sendSmsCode("北京宏业汇成科技有限公司",mobile, params, "SMS_205755297");
|
||||
break;
|
||||
}
|
||||
//如果不是有效的验证码手段,则此处不进行短信操作
|
||||
@@ -162,19 +161,22 @@ public class SmsUtilAliImplService implements SmsUtil, AliSmsUtil {
|
||||
//设置参数添加短信签名
|
||||
com.aliyun.dysmsapi20170525.Client client = this.createClient();
|
||||
|
||||
System.out.println(smsSign.getBusinessLicense().substring(smsSign.getBusinessLicense().lastIndexOf(".") + 1));
|
||||
//营业执照
|
||||
AddSmsSignRequest.AddSmsSignRequestSignFileList signFileList0 = new AddSmsSignRequest.AddSmsSignRequestSignFileList()
|
||||
.setFileContents(Base64Utils.encode(smsSign.getBusinessLicense()))
|
||||
.setFileSuffix(smsSign.getBusinessLicense().substring(smsSign.getBusinessLicense().lastIndexOf(".") + 1));
|
||||
AddSmsSignRequest.AddSmsSignRequestSignFileList signFileList1 = new AddSmsSignRequest.AddSmsSignRequestSignFileList()
|
||||
.setFileContents(Base64Utils.encode(smsSign.getLicense()))
|
||||
.setFileSuffix(smsSign.getLicense().substring(smsSign.getBusinessLicense().lastIndexOf(".") + 1));
|
||||
//授权委托书
|
||||
// AddSmsSignRequest.AddSmsSignRequestSignFileList signFileList1 = new AddSmsSignRequest.AddSmsSignRequestSignFileList()
|
||||
// .setFileContents(Base64Utils.encode(smsSign.getLicense()))
|
||||
// .setFileSuffix(smsSign.getLicense().substring(smsSign.getLicense().lastIndexOf(".") + 1));
|
||||
//添加短信签名
|
||||
AddSmsSignRequest addSmsSignRequest = new AddSmsSignRequest()
|
||||
.setSignName(smsSign.getSignName())
|
||||
.setSignSource(smsSign.getSignSource())
|
||||
.setRemark(smsSign.getRemark())
|
||||
.setSignFileList(java.util.Arrays.asList(
|
||||
signFileList0,
|
||||
signFileList1
|
||||
signFileList0
|
||||
));
|
||||
AddSmsSignResponse response = client.addSmsSign(addSmsSignRequest);
|
||||
if (!response.getBody().getCode().equals("OK")) {
|
||||
|
||||
@@ -6,13 +6,11 @@ import cn.lili.common.security.enums.UserEnums;
|
||||
import cn.lili.common.token.Token;
|
||||
import cn.lili.common.token.TokenUtil;
|
||||
import cn.lili.common.token.base.AbstractTokenGenerate;
|
||||
import cn.lili.common.enums.SwitchEnum;
|
||||
import cn.lili.modules.member.entity.dos.Member;
|
||||
import cn.lili.modules.member.service.MemberService;
|
||||
import cn.lili.modules.store.entity.dos.Store;
|
||||
import cn.lili.modules.store.service.StoreService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -37,10 +35,10 @@ public class StoreTokenGenerate extends AbstractTokenGenerate {
|
||||
public Token createToken(String username, Boolean longTerm) {
|
||||
// 生成token
|
||||
Member member = memberService.findByUsername(username);
|
||||
if (member.getHaveStore().equals(SwitchEnum.CLOSE.name())) {
|
||||
if (!member.getHaveStore()) {
|
||||
throw new ServiceException("该会员未开通店铺");
|
||||
}
|
||||
AuthUser user = new AuthUser(member.getUsername(), member.getId(),member.getNickName(), UserEnums.STORE);
|
||||
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);
|
||||
|
||||
@@ -24,7 +24,6 @@ import cn.lili.modules.search.repository.EsGoodsIndexRepository;
|
||||
import cn.lili.modules.search.service.EsGoodsIndexService;
|
||||
import cn.lili.modules.search.service.EsGoodsSearchService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.assertj.core.util.IterableUtil;
|
||||
import org.elasticsearch.action.search.SearchResponse;
|
||||
@@ -44,6 +43,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 商品索引业务层实现
|
||||
*
|
||||
* @author paulG
|
||||
* @since 2020/10/14
|
||||
**/
|
||||
@@ -64,19 +64,26 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements
|
||||
|
||||
@Override
|
||||
public void addIndex(EsGoodsIndex goods) {
|
||||
//索引名称拼接
|
||||
String indexName = elasticsearchProperties.getIndexPrefix() + "_" + EsSuffix.GOODS_INDEX_NAME;
|
||||
try {
|
||||
//分词器分词
|
||||
AnalyzeRequest analyzeRequest = AnalyzeRequest.withIndexAnalyzer(indexName, "ik_max_word", goods.getGoodsName());
|
||||
AnalyzeResponse analyze = client.indices().analyze(analyzeRequest, RequestOptions.DEFAULT);
|
||||
List<AnalyzeResponse.AnalyzeToken> tokens = analyze.getTokens();
|
||||
|
||||
if (goods.getAttrList() != null && !goods.getAttrList().isEmpty()) {
|
||||
//保存分词
|
||||
for (EsGoodsAttribute esGoodsAttribute : goods.getAttrList()) {
|
||||
wordsToDb(esGoodsAttribute.getValue());
|
||||
}
|
||||
}
|
||||
//分析词条
|
||||
for (AnalyzeResponse.AnalyzeToken token : tokens) {
|
||||
//保存词条进入数据库
|
||||
wordsToDb(token.getTerm());
|
||||
}
|
||||
//生成索引
|
||||
goodsIndexRepository.save(goods);
|
||||
} catch (IOException e) {
|
||||
log.error("为商品[" + goods.getGoodsName() + "]生成索引异常", e);
|
||||
@@ -112,6 +119,7 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements
|
||||
@Override
|
||||
public void updateIndexCommentNum(String id, Integer commentNum, Integer highPraiseNum, Double grade) {
|
||||
EsGoodsIndex goodsIndex = this.findById(id);
|
||||
//写入新的商品数据
|
||||
goodsIndex.setCommentNum(commentNum);
|
||||
goodsIndex.setHighPraiseNum(highPraiseNum);
|
||||
goodsIndex.setGrade(grade);
|
||||
@@ -139,8 +147,10 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements
|
||||
|
||||
@Override
|
||||
public void initIndex(List<EsGoodsIndex> goodsIndexList) {
|
||||
//索引名称拼接
|
||||
String indexName = elasticsearchProperties.getIndexPrefix() + "_" + EsSuffix.GOODS_INDEX_NAME;
|
||||
// deleteIndexRequest(indexName);
|
||||
//如果索引不存在,则创建索引
|
||||
if (!indexExist(indexName)) {
|
||||
createIndexRequest(indexName);
|
||||
}
|
||||
@@ -156,11 +166,14 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements
|
||||
public void updateEsGoodsIndex(String id, BasePromotion promotion, String key, Double price) {
|
||||
EsGoodsIndex goodsIndex = findById(id);
|
||||
if (goodsIndex != null) {
|
||||
//如果有促销活动开始,则将促销金额写入
|
||||
if (promotion.getPromotionStatus().equals(PromotionStatusEnum.START.name()) && price != null) {
|
||||
goodsIndex.setPromotionPrice(price);
|
||||
} else {
|
||||
//否则促销金额为商品原价
|
||||
goodsIndex.setPromotionPrice(goodsIndex.getPrice());
|
||||
}
|
||||
//更新索引
|
||||
this.updateGoodsIndexPromotion(goodsIndex, key, promotion);
|
||||
} else {
|
||||
log.error("更新索引商品促销信息失败!skuId 为 【{}】的索引不存在!", id);
|
||||
@@ -170,6 +183,7 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements
|
||||
@Override
|
||||
public void updateEsGoodsIndexByList(List<PromotionGoods> promotionGoodsList, BasePromotion promotion, String key) {
|
||||
if (promotionGoodsList != null) {
|
||||
//循环更新 促销商品索引
|
||||
for (PromotionGoods promotionGoods : promotionGoodsList) {
|
||||
updateEsGoodsIndex(promotionGoods.getSkuId(), promotion, key, promotionGoods.getPrice());
|
||||
}
|
||||
@@ -186,15 +200,20 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements
|
||||
@Override
|
||||
public void updateEsGoodsIndexAllByList(BasePromotion promotion, String key) {
|
||||
List<EsGoodsIndex> goodsIndices;
|
||||
//如果storeid不为空,则表示是店铺活动
|
||||
if (promotion.getStoreId() != null) {
|
||||
EsGoodsSearchDTO searchDTO = new EsGoodsSearchDTO();
|
||||
searchDTO.setStoreId(promotion.getStoreId());
|
||||
//查询出店铺商品
|
||||
Page<EsGoodsIndex> esGoodsIndices = goodsSearchService.searchGoods(searchDTO, null);
|
||||
goodsIndices = esGoodsIndices.getContent();
|
||||
} else {
|
||||
//否则是平台活动
|
||||
Iterable<EsGoodsIndex> all = goodsIndexRepository.findAll();
|
||||
// 查询出全部商品
|
||||
goodsIndices = new ArrayList<>(IterableUtil.toCollection(all));
|
||||
}
|
||||
//更新商品索引
|
||||
for (EsGoodsIndex goodsIndex : goodsIndices) {
|
||||
this.updateGoodsIndexPromotion(goodsIndex, key, promotion);
|
||||
}
|
||||
@@ -202,8 +221,10 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements
|
||||
|
||||
@Override
|
||||
public void deleteEsGoodsPromotionIndexByList(List<String> skuIds, PromotionTypeEnum promotionType) {
|
||||
//批量删除活动索引
|
||||
for (String skuId : skuIds) {
|
||||
EsGoodsIndex goodsIndex = findById(skuId);
|
||||
//商品索引不为空
|
||||
if (goodsIndex != null) {
|
||||
Map<String, Object> promotionMap = goodsIndex.getPromotionMap();
|
||||
if (promotionMap != null && !promotionMap.isEmpty()) {
|
||||
@@ -220,16 +241,19 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除所以商品索引的无效促销活动
|
||||
* 清除所有商品索引的无效促销活动
|
||||
*/
|
||||
@Override
|
||||
public void cleanInvalidPromotion() {
|
||||
Iterable<EsGoodsIndex> all = goodsIndexRepository.findAll();
|
||||
for (EsGoodsIndex goodsIndex : all) {
|
||||
Map<String, Object> promotionMap = goodsIndex.getPromotionMap();
|
||||
//获取商品索引
|
||||
if (promotionMap != null && !promotionMap.isEmpty()) {
|
||||
//促销不为空则进行清洗
|
||||
for (Map.Entry<String, Object> entry : promotionMap.entrySet()) {
|
||||
BasePromotion promotion = (BasePromotion) entry.getValue();
|
||||
//判定条件为活动已结束
|
||||
if (promotion.getEndTime().getTime() > DateUtil.date().getTime()) {
|
||||
promotionMap.remove(entry.getKey());
|
||||
}
|
||||
@@ -258,6 +282,8 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements
|
||||
@Override
|
||||
public Map<String, Object> getPromotionMap(String id) {
|
||||
EsGoodsIndex goodsIndex = this.findById(id);
|
||||
|
||||
// 如果商品索引不为空,返回促销信息,否则返回空
|
||||
if (goodsIndex != null) {
|
||||
Map<String, Object> promotionMap = goodsIndex.getPromotionMap();
|
||||
if (promotionMap == null || promotionMap.isEmpty()) {
|
||||
@@ -278,11 +304,14 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements
|
||||
@Override
|
||||
public List<String> getPromotionIdByPromotionType(String id, PromotionTypeEnum promotionTypeEnum) {
|
||||
Map<String, Object> promotionMap = this.getPromotionMap(id);
|
||||
//如果没有促销信息,则返回新的
|
||||
if (promotionMap == null || promotionMap.isEmpty()) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
//对促销进行过滤
|
||||
List<String> keyCollect = promotionMap.keySet().stream().filter(i -> i.contains(promotionTypeEnum.name())).collect(Collectors.toList());
|
||||
List<String> promotionIds = new ArrayList<>();
|
||||
//写入促销id
|
||||
for (String key : keyCollect) {
|
||||
BasePromotion promotion = (BasePromotion) promotionMap.get(key);
|
||||
promotionIds.add(promotion.getId());
|
||||
@@ -299,25 +328,37 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements
|
||||
@Override
|
||||
public EsGoodsIndex resetEsGoodsIndex(GoodsSku goodsSku) {
|
||||
EsGoodsIndex index = new EsGoodsIndex(goodsSku);
|
||||
//获取活动信息
|
||||
Map<String, Object> goodsCurrentPromotionMap = promotionService.getGoodsCurrentPromotionMap(index);
|
||||
//写入促销信息
|
||||
index.setPromotionMap(goodsCurrentPromotionMap);
|
||||
this.addIndex(index);
|
||||
return index;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改商品活动索引
|
||||
*
|
||||
* @param goodsIndex 商品索引
|
||||
* @param key 关键字
|
||||
* @param promotion 活动
|
||||
*/
|
||||
private void updateGoodsIndexPromotion(EsGoodsIndex goodsIndex, String key, BasePromotion promotion) {
|
||||
Map<String, Object> promotionMap;
|
||||
//数据非空处理,如果空给一个新的信息
|
||||
if (goodsIndex.getPromotionMap() == null || goodsIndex.getPromotionMap().isEmpty()) {
|
||||
promotionMap = new HashMap<>(1);
|
||||
} else {
|
||||
promotionMap = goodsIndex.getPromotionMap();
|
||||
}
|
||||
|
||||
|
||||
//如果活动已结束
|
||||
if (promotion.getPromotionStatus().equals(PromotionStatusEnum.END.name()) || promotion.getPromotionStatus().equals(PromotionStatusEnum.CLOSE.name())) {
|
||||
//如果存在活动
|
||||
if (promotionMap.containsKey(key)) {
|
||||
//删除活动
|
||||
promotionMap.remove(key);
|
||||
} else {
|
||||
//不存在则说明是秒杀活动,尝试删除秒杀信息
|
||||
this.removePromotionKey(key, promotionMap, PromotionTypeEnum.SECKILL.name());
|
||||
}
|
||||
} else {
|
||||
@@ -337,9 +378,13 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements
|
||||
* @param needRemoveKeys 需移除的促销活动
|
||||
*/
|
||||
private void removePromotionKey(String currentKey, Map<String, Object> promotionMap, String... needRemoveKeys) {
|
||||
//判定是否需要移除
|
||||
if (CharSequenceUtil.containsAny(currentKey, needRemoveKeys)) {
|
||||
|
||||
List<String> removeKeys = new ArrayList<>();
|
||||
//促销循环
|
||||
for (String entry : promotionMap.keySet()) {
|
||||
//需要移除则进行移除处理
|
||||
for (String needRemoveKey : needRemoveKeys) {
|
||||
if (entry.contains(needRemoveKey) && currentKey.contains(needRemoveKey)) {
|
||||
removeKeys.add(entry);
|
||||
@@ -347,6 +392,7 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements
|
||||
}
|
||||
}
|
||||
}
|
||||
//移除促销信息
|
||||
promotionMap.keySet().removeAll(removeKeys);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ public class StoreEditDTO extends StoreDetail {
|
||||
private String storeDisable;
|
||||
|
||||
@ApiModelProperty(value = "是否自营", required = true)
|
||||
private Integer selfOperated;
|
||||
private Boolean selfOperated;
|
||||
|
||||
@ApiModelProperty(value = "经纬度")
|
||||
private String storeCenter;
|
||||
|
||||
@@ -3,7 +3,6 @@ package cn.lili.modules.store.serviceimpl;
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.enums.SwitchEnum;
|
||||
import cn.lili.common.exception.ServiceException;
|
||||
import cn.lili.common.security.context.UserContext;
|
||||
import cn.lili.common.utils.BeanUtil;
|
||||
@@ -98,24 +97,24 @@ public class StoreServiceImpl extends ServiceImpl<StoreMapper, Store> implements
|
||||
throw new ServiceException(ResultCode.USER_NOT_EXIST);
|
||||
}
|
||||
//判断是否拥有店铺
|
||||
if (SwitchEnum.OPEN.name().equals(member.getHaveStore())) {
|
||||
if (member.getHaveStore()) {
|
||||
throw new ServiceException(ResultCode.STORE_APPLY_DOUBLE_ERROR);
|
||||
}
|
||||
|
||||
//添加店铺
|
||||
Store store=new Store(member,adminStoreApplyDTO);
|
||||
Store store = new Store(member, adminStoreApplyDTO);
|
||||
this.save(store);
|
||||
|
||||
//判断是否存在店铺详情,如果没有则进行新建,如果存在则进行修改
|
||||
StoreDetail storeDetail = new StoreDetail(store,adminStoreApplyDTO);
|
||||
StoreDetail storeDetail = new StoreDetail(store, adminStoreApplyDTO);
|
||||
|
||||
storeDetailService.save(storeDetail);
|
||||
|
||||
//设置会员-店铺信息
|
||||
memberService.update(new LambdaUpdateWrapper<Member>()
|
||||
.eq(Member::getId,member.getId())
|
||||
.set(Member::getHaveStore,SwitchEnum.OPEN.name())
|
||||
.set(Member::getStoreId,store.getId()));
|
||||
.eq(Member::getId, member.getId())
|
||||
.set(Member::getHaveStore, true)
|
||||
.set(Member::getStoreId, store.getId()));
|
||||
return store;
|
||||
|
||||
}
|
||||
@@ -173,6 +172,12 @@ public class StoreServiceImpl extends ServiceImpl<StoreMapper, Store> implements
|
||||
store.setStoreDisable(StoreStatusEnum.OPEN.value());
|
||||
//添加店铺页面
|
||||
pageDataService.addStorePageData(store.getId());
|
||||
//修改会员 表示已有店铺
|
||||
Member member = memberService.getById(store.getMemberId());
|
||||
member.setHaveStore(true);
|
||||
member.setStoreId(id);
|
||||
memberService.updateById(member);
|
||||
|
||||
} else {
|
||||
store.setStoreDisable(StoreStatusEnum.REFUSED.value());
|
||||
}
|
||||
@@ -190,6 +195,7 @@ public class StoreServiceImpl extends ServiceImpl<StoreMapper, Store> implements
|
||||
goodsService.underStoreGoods(id);
|
||||
return this.updateById(store);
|
||||
}
|
||||
|
||||
throw new ServiceException(ResultCode.STORE_NOT_EXIST);
|
||||
}
|
||||
|
||||
@@ -281,26 +287,26 @@ public class StoreServiceImpl extends ServiceImpl<StoreMapper, Store> implements
|
||||
@Override
|
||||
public void updateStoreGoodsNum(String storeId) {
|
||||
//获取店铺已上架已审核通过商品数量
|
||||
Integer goodsNum=goodsService.count(new LambdaQueryWrapper<Goods>()
|
||||
.eq(Goods::getStoreId,storeId)
|
||||
Integer goodsNum = goodsService.count(new LambdaQueryWrapper<Goods>()
|
||||
.eq(Goods::getStoreId, storeId)
|
||||
.eq(Goods::getIsAuth, GoodsAuthEnum.PASS.name())
|
||||
.eq(Goods::getMarketEnable, GoodsStatusEnum.UPPER.name()));
|
||||
//修改店铺商品数量
|
||||
this.update(new LambdaUpdateWrapper<Store>()
|
||||
.set(Store::getGoodsNum,goodsNum)
|
||||
.eq(Store::getId,storeId));
|
||||
.set(Store::getGoodsNum, goodsNum)
|
||||
.eq(Store::getId, storeId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateStoreCollectionNum(String goodsId) {
|
||||
String storeId=goodsSkuService.getById(goodsId).getStoreId();
|
||||
String storeId = goodsSkuService.getById(goodsId).getStoreId();
|
||||
//获取店铺收藏数量
|
||||
Integer collectionNum=storeCollectionService.count(new LambdaQueryWrapper<StoreCollection>()
|
||||
.eq(StoreCollection::getStoreId,storeId));
|
||||
Integer collectionNum = storeCollectionService.count(new LambdaQueryWrapper<StoreCollection>()
|
||||
.eq(StoreCollection::getStoreId, storeId));
|
||||
//修改店铺收藏数量
|
||||
this.update(new LambdaUpdateWrapper<Store>()
|
||||
.set(Store::getCollectionNum,collectionNum)
|
||||
.eq(Store::getId,storeId));
|
||||
.set(Store::getCollectionNum, collectionNum)
|
||||
.eq(Store::getId, storeId));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user