秒杀活动启动修改mongo

修改部分代码规范
This commit is contained in:
lifenlong 2021-08-20 09:40:06 +08:00
parent 4e2176e049
commit 7276824a18
23 changed files with 80 additions and 111 deletions

View File

@ -12,6 +12,12 @@ import org.springframework.security.web.authentication.SavedRequestAwareAuthenti
import java.util.UUID;
/**
* Admin
*
* @author Chopper
* @since 2020/11/16 10:03 下午
*/
@Configuration
@EnableAutoConfiguration
@EnableAdminServer

View File

@ -54,6 +54,9 @@ public class DistributionOrderExecute implements OrderStatusChangeEvent, EveryDa
distributionOrderService.cancelOrder(orderMessage.getOrderSn());
break;
}
default: {
break;
}
}
}

View File

@ -207,7 +207,7 @@ public class RedisCache implements Cache {
RedisAtomicLong entityIdCounter = new RedisAtomicLong(key, redisTemplate.getConnectionFactory());
Long increment = entityIdCounter.getAndIncrement();
//初始设置过期时间
if ((null == increment || increment.longValue() == 0) && liveTime > 0) {
if ((null == increment || increment == 0) && liveTime > 0) {
entityIdCounter.expire(liveTime, TimeUnit.SECONDS);
}

View File

@ -41,11 +41,12 @@ public interface CategoryService extends IService<Category> {
List<CategoryVO> listAllChildren(String parentId);
/**
* 查询所有的分类父子关系 数据库获取
* 查询所有的分类父子关系
* 数据库获取
*
* @return 所有的分类父子关系
*/
List<CategoryVO> listAllChildrenDB();
List<CategoryVO> listAllChildren();
/**
* 获取指定分类的分类名称

View File

@ -85,9 +85,9 @@ public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, Category> i
@Override
public List<CategoryVO> getStoreCategory(String[] categories) {
List<String> arr = Arrays.asList(categories.clone());
List<CategoryVO> categoryVOS = categoryTree().stream()
List<CategoryVO> categoryVOList = categoryTree().stream()
.filter(item -> arr.contains(item.getId())).collect(Collectors.toList());
return categoryVOS;
return categoryVOList;
}
@ -115,7 +115,7 @@ public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, Category> i
}
@Override
public List<CategoryVO> listAllChildrenDB() {
public List<CategoryVO> listAllChildren() {
//获取全部分类
List<Category> list = this.list();
@ -147,18 +147,18 @@ public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, Category> i
@Override
public List<String> getCategoryNameByIds(List<String> ids) {
List<String> categoryName = new ArrayList<>();
List<Category> categoryVOs = (List<Category>) cache.get(CachePrefix.CATEGORY_ARRAY.getPrefix());
List<Category> categoryVOList = (List<Category>) cache.get(CachePrefix.CATEGORY_ARRAY.getPrefix());
//如果缓存中为空则重新获取缓存
if (categoryVOs == null) {
if (categoryVOList == null) {
categoryTree();
categoryVOs = (List<Category>) cache.get(CachePrefix.CATEGORY_ARRAY.getPrefix());
categoryVOList = (List<Category>) cache.get(CachePrefix.CATEGORY_ARRAY.getPrefix());
}
//还为空的话直接返回
if (categoryVOs == null) {
if (categoryVOList == null) {
return null;
}
//循环顶级分类
for (Category category : categoryVOs) {
for (Category category : categoryVOList) {
//循环查询的id匹配
for (String id : ids) {
if (category.getId().equals(id)) {
@ -273,13 +273,13 @@ public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, Category> i
LambdaQueryWrapper<Category> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(Category::getParentId, category.getId());
List<Category> categories = this.list(queryWrapper);
List<CategoryVO> categoryVOS = new ArrayList<>();
List<CategoryVO> categoryVOList = new ArrayList<>();
for (Category category1 : categories) {
categoryVOS.add(new CategoryVO(category1));
categoryVOList.add(new CategoryVO(category1));
}
category.setChildren(categoryVOS);
if (!categoryVOS.isEmpty()) {
categoryVOS.forEach(this::findAllChild);
category.setChildren(categoryVOList);
if (!categoryVOList.isEmpty()) {
categoryVOList.forEach(this::findAllChild);
}
}
@ -330,16 +330,16 @@ public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, Category> i
* 递归自身找到id等于parentId的对象获取他的children 返回
*
* @param parentId 父ID
* @param categoryVOS 分类VO
* @param categoryVOList 分类VO
* @return 子分类列表VO
*/
private List<CategoryVO> getChildren(String parentId, List<CategoryVO> categoryVOS) {
for (CategoryVO item : categoryVOS) {
private List<CategoryVO> getChildren(String parentId, List<CategoryVO> categoryVOList) {
for (CategoryVO item : categoryVOList) {
if (item.getId().equals(parentId)) {
return item.getChildren();
}
if (item.getChildren() != null && item.getChildren().size() > 0) {
return getChildren(parentId, categoryVOS);
return getChildren(parentId, categoryVOList);
}
}
return null;

View File

@ -15,16 +15,13 @@ import cn.lili.common.utils.StringUtils;
import cn.lili.modules.goods.entity.dos.Category;
import cn.lili.modules.goods.entity.dos.Goods;
import cn.lili.modules.goods.entity.dos.GoodsGallery;
import cn.lili.modules.goods.entity.dos.Parameters;
import cn.lili.modules.goods.entity.dto.GoodsOperationDTO;
import cn.lili.modules.goods.entity.dto.GoodsParamsDTO;
import cn.lili.modules.goods.entity.dto.GoodsParamsItemDTO;
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.GoodsSkuVO;
import cn.lili.modules.goods.entity.vos.GoodsVO;
import cn.lili.modules.goods.entity.vos.ParameterGroupVO;
import cn.lili.modules.goods.mapper.GoodsMapper;
import cn.lili.modules.goods.service.*;
import cn.lili.modules.member.entity.dos.MemberEvaluation;
@ -141,8 +138,6 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
this.setGoodsGalleryParam(goodsOperationDTO.getGoodsGalleryList().get(0), goods);
//添加商品参数
if (goodsOperationDTO.getGoodsParamsDTOList() != null && !goodsOperationDTO.getGoodsParamsDTOList().isEmpty()) {
//检测商品参数是否合法
//this.checkGoodsParams(goodsOperationDTO.getGoodsParamsDTOList(), goodsOperationDTO.getCategoryPath().substring(goodsOperationDTO.getCategoryPath().lastIndexOf(",") + 1));
//给商品参数填充值
goods.setParams(JSONUtil.toJsonStr(goodsOperationDTO.getGoodsParamsDTOList()));
}
@ -372,52 +367,6 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
goods.setThumbnail(goodsGallery.getThumbnail());
}
/**
* 检测商品参数是否非法传递
*
* @param goodsParamsDTOS 商品参数
* @param categoryId 分类id
*/
private void checkGoodsParams(List<GoodsParamsDTO> goodsParamsDTOS, String categoryId) {
//根据绑定的分了id查询出参数信息
List<ParameterGroupVO> parameterGroupVOS = categoryParameterGroupService.getCategoryParams(categoryId);
if (parameterGroupVOS.size() > 0) {
//绑定分类的参数集合
List<Parameters> parametersList = new ArrayList<>();
//循环分类绑定的参数信息 把它整理到新的分类参数集合中 用于最后的参数信息对比
for (ParameterGroupVO parameterGroupVO : parameterGroupVOS) {
List<Parameters> parameters = parameterGroupVO.getParams();
for (Parameters param : parameters) {
parametersList.add(param);
}
}
List<GoodsParamsItemDTO> goodsOperationParamList = new ArrayList<>();
//循环添加商品传递的参数信息 把它整理到新的分类参数集合中 用于最后的参数信息对比
for (GoodsParamsDTO goodsParamsDTO : goodsParamsDTOS) {
List<GoodsParamsItemDTO> goodsParamsItemDTOS = goodsParamsDTO.getGoodsParamsItemDTOList();
for (GoodsParamsItemDTO goodsParamsItemDTO : goodsParamsItemDTOS) {
goodsOperationParamList.add(goodsParamsItemDTO);
}
}
//两个参数集合进行对比
for (Parameters parameters : parametersList) {
for (GoodsParamsItemDTO goodsParamsItemDTO : goodsOperationParamList) {
if (parameters.getId().equals(goodsParamsItemDTO.getParamId())) {
//校验是否可以索引参数是否正确
if (!parameters.getIsIndex().equals(goodsParamsItemDTO.getIsIndex())) {
throw new ServiceException(ResultCode.GOODS_PARAMS_ERROR);
}
//校验是否必填参数是否正确
if (!parameters.getRequired().equals(goodsParamsItemDTO.getRequired())) {
throw new ServiceException(ResultCode.GOODS_PARAMS_ERROR);
}
}
}
}
}
}
/**
* 检查商品信息
* 如果商品是虚拟商品则无需配置配送模板

View File

@ -63,9 +63,11 @@ public class WechatMessageServiceImpl extends ServiceImpl<WechatMessageMapper, W
//设置行业
Map<String, Object> setIndustryParams = new HashMap<>();
setIndustryParams.put("industry_id1", 1);//互联网/电子商务
setIndustryParams.put("industry_id2", 5);//通信与运营商
Map<String, Object> setIndustryParams = new HashMap<>(16);
//互联网/电子商务
setIndustryParams.put("industry_id1", 1);
//通信与运营商
setIndustryParams.put("industry_id2", 5);
String context = HttpUtils.doPostWithJson(setIndustry + accessToken, setIndustryParams);
//获取已有模版删除

View File

@ -5,7 +5,6 @@ import cn.lili.common.enums.ClientTypeEnum;
import cn.lili.modules.order.order.entity.enums.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import jdk.nashorn.internal.objects.annotations.Getter;
import lombok.Data;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;
@ -31,7 +30,7 @@ public class OrderSimpleVO {
private Double flowPrice;
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "创建时间")
private Date createTime;
@ -135,7 +134,6 @@ public class OrderSimpleVO {
@ApiModelProperty(value = "货运状态")
private String deliverStatus;
@Getter
public List<OrderItemVO> getOrderItems() {
if (StringUtils.isEmpty(groupGoodsId)) {
return new ArrayList<>();
@ -162,7 +160,6 @@ public class OrderSimpleVO {
/**
* 初始化自身状态
*/
@Getter
public AllowOperation getAllowOperationVO() {
//设置订单的可操作状态
return new AllowOperation(this);

View File

@ -19,9 +19,19 @@ import java.util.List;
*/
public interface StoreFlowMapper extends BaseMapper<StoreFlow> {
/**
* 获取结算单的入账流水
* @param queryWrapper 查询条件
* @return 入账流水
*/
@Select("SELECT * FROM li_store_flow ${ew.customSqlSegment}")
List<StoreFlowPayDownloadVO> getStoreFlowPayDownloadVO(@Param(Constants.WRAPPER) Wrapper<StoreFlow> queryWrapper);
/**
* 获取结算单的退款流水
* @param queryWrapper 查询条件
* @return 退款流水
*/
@Select("SELECT * FROM li_store_flow ${ew.customSqlSegment}")
List<StoreFlowRefundDownloadVO> getStoreFlowRefundDownloadVO(@Param(Constants.WRAPPER) Wrapper<StoreFlow> queryWrapper);
}

View File

@ -52,19 +52,27 @@ import java.util.List;
@Transactional(rollbackFor = Exception.class)
public class KanjiaActivityGoodsServiceImpl extends ServiceImpl<KanJiaActivityGoodsMapper, KanjiaActivityGoods> implements KanjiaActivityGoodsService {
//规格商品
/**
* 规格商品
*/
@Autowired
private GoodsSkuService goodsSkuService;
//Rocketmq
/**
* Rocketmq
*/
@Autowired
private RocketmqCustomProperties rocketmqCustomProperties;
//延时任务
/**
* 延时任务
*/
@Autowired
private TimeTrigger timeTrigger;
//Mongo
/**
* Mongo
*/
@Autowired
private MongoTemplate mongoTemplate;

View File

@ -432,6 +432,7 @@ public class PromotionServiceImpl implements PromotionService {
this.goodsIndexService.updateEsGoodsIndex(seckillApply.getSkuId(), seckill1, promotionTypeEnum.name() + "-" + seckillApply.getTimeLine(), seckillApply.getPrice());
}
}
this.mongoTemplate.save(seckill);
return result;
}

View File

@ -169,7 +169,7 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements
//如果索引不存在则创建索引
createIndexRequest(indexName);
Map<String, Integer> resultMap = new HashMap<>();
Map<String, Integer> resultMap = new HashMap<>(16);
final String KEY_SUCCESS = "success";
final String KEY_FAIL = "fail";
final String KEY_PROCESSED = "processed";

View File

@ -95,6 +95,7 @@ public interface BillService extends IService<Bill> {
/**
* 下载结算单
* @response response
* @param id 结算单ID
*/
void download(HttpServletResponse response, String id);

View File

@ -23,6 +23,7 @@ import cn.lili.modules.store.entity.enums.BillStatusEnum;
import cn.lili.modules.store.entity.vos.BillListVO;
import cn.lili.modules.store.entity.vos.StoreDetailVO;
import cn.lili.modules.store.entity.vos.StoreFlowPayDownloadVO;
import cn.lili.modules.store.entity.vos.StoreFlowRefundDownloadVO;
import cn.lili.modules.store.mapper.BillMapper;
import cn.lili.modules.store.service.BillService;
import cn.lili.modules.store.service.StoreDetailService;
@ -223,6 +224,7 @@ public class BillServiceImpl extends ServiceImpl<BillMapper, Bill> implements Bi
return this.count(lambdaUpdateWrapper);
}
@Override
public void download(HttpServletResponse response, String id) {
Bill bill = this.getById(id);
@ -286,8 +288,8 @@ public class BillServiceImpl extends ServiceImpl<BillMapper, Bill> implements Bi
storeFlowlambdaQueryWrapper.eq(StoreFlow::getStoreId, bill.getStoreId());
storeFlowlambdaQueryWrapper.between(StoreFlow::getCreateTime, bill.getStartTime(), bill.getCreateTime());
storeFlowlambdaQueryWrapper.eq(StoreFlow::getFlowType, FlowTypeEnum.PAY.name());
storeFlowList = storeFlowMapper.getStoreFlowPayDownloadVO(storeFlowlambdaQueryWrapper);
writer.write(storeFlowList, true);
List<StoreFlowRefundDownloadVO> storeFlowRefundDownloadVOList = storeFlowMapper.getStoreFlowRefundDownloadVO(storeFlowlambdaQueryWrapper);
writer.write(storeFlowRefundDownloadVOList, true);
ServletOutputStream out = null;
try {

View File

@ -2,8 +2,8 @@ package cn.lili.modules.system.entity.dos;
import cn.lili.common.utils.StringUtils;
import cn.lili.modules.system.entity.plugin.InstantDelivery.dada.enums.DadaOrderStatusEnum;
import cn.lili.modules.system.entity.plugin.InstantDelivery.dada.vo.DdOrderBackVO;
import cn.lili.modules.system.entity.plugin.logistics.dada.enums.DadaOrderStatusEnum;
import cn.lili.modules.system.entity.plugin.logistics.dada.vo.DdOrderBackVO;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;

View File

@ -1,4 +1,4 @@
package cn.lili.modules.system.entity.plugin.InstantDelivery;
package cn.lili.modules.system.entity.plugin.logistics;
import cn.lili.modules.member.entity.dos.MemberAddress;
import cn.lili.modules.order.order.entity.dos.Order;

View File

@ -1,4 +1,4 @@
package cn.lili.modules.system.entity.plugin.InstantDelivery.dada;
package cn.lili.modules.system.entity.plugin.logistics.dada;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
@ -13,8 +13,8 @@ import cn.lili.modules.store.service.StoreDetailService;
import cn.lili.modules.system.entity.dos.InstantDeliveryLog;
import cn.lili.modules.system.entity.enums.InstantDeliveryUrl;
import cn.lili.modules.system.entity.plugin.ConfigItem;
import cn.lili.modules.system.entity.plugin.InstantDelivery.InstantDeliveryPlugin;
import cn.lili.modules.system.entity.plugin.InstantDelivery.dada.vo.DdOrderBackVO;
import cn.lili.modules.system.entity.plugin.logistics.InstantDeliveryPlugin;
import cn.lili.modules.system.entity.plugin.logistics.dada.vo.DdOrderBackVO;
import cn.lili.modules.system.entity.vo.CityResult;
import cn.lili.modules.system.entity.vo.InstantDeliveryResultVO;
import cn.lili.modules.system.service.InstantDeliveryLogService;
@ -95,20 +95,10 @@ public class DadaPlugin implements InstantDeliveryPlugin {
public InstantDeliveryResultVO addStore(StoreDetailVO storeDetailVO, Map config) {
JSONArray jsonArray = new JSONArray();
JSONObject jsonObject = new JSONObject();
// //门店名称
// jsonObject.put("station_name", storeDetailVO.getStoreName());
//业务类型(食品小吃-1,饮料-2,鲜花-3,文印票务-8,便利店-9,水果生鲜-13,同城电商-19, 医药-20,蛋糕-21,酒品-24,小商品市场-25,服装-26,汽修零配-27,数码-28,小龙虾-29,火锅-51,其他-5)
jsonObject.set("business", 19);
//城市名称(,上海)
// jsonObject.put("city_name", storeDetailVO.getCompanyCity());
//区域名称(,浦东新区)
// jsonObject.put("area_name", storeDetailVO.getCompanyCounty());
//门店地址
jsonObject.set("station_address", storeDetailVO.getCompanyAddress());
// //门店经度
// jsonObject.put("lng", storeDetailVO.getStoreLongitude());
// //门店纬度
// jsonObject.put("lat", storeDetailVO.getStoreLatitude());
//联系人姓名
jsonObject.set("contact_name", storeDetailVO.getLinkName());
//联系人电话

View File

@ -1,4 +1,4 @@
package cn.lili.modules.system.entity.plugin.InstantDelivery.dada.enums;
package cn.lili.modules.system.entity.plugin.logistics.dada.enums;
import lombok.Getter;
import lombok.Setter;

View File

@ -1,4 +1,4 @@
package cn.lili.modules.system.entity.plugin.InstantDelivery.dada.vo;
package cn.lili.modules.system.entity.plugin.logistics.dada.vo;
import com.fasterxml.jackson.databind.PropertyNamingStrategy;
import com.fasterxml.jackson.databind.annotation.JsonNaming;

View File

@ -3,7 +3,7 @@ package cn.lili.modules.system.entity.vo;
import cn.lili.modules.system.entity.dos.InstantDelivery;
import cn.lili.modules.system.entity.plugin.ConfigItem;
import cn.lili.modules.system.entity.plugin.InstantDelivery.InstantDeliveryPlugin;
import cn.lili.modules.system.entity.plugin.logistics.InstantDeliveryPlugin;
import com.google.common.reflect.TypeToken;
import com.google.gson.Gson;
import io.swagger.annotations.ApiModel;

View File

@ -3,7 +3,7 @@ package cn.lili.modules.system.serviceimpl;
import cn.lili.mybatis.util.PageUtil;
import cn.lili.common.vo.PageVO;
import cn.lili.modules.system.entity.dos.InstantDelivery;
import cn.lili.modules.system.entity.plugin.InstantDelivery.InstantDeliveryPlugin;
import cn.lili.modules.system.entity.plugin.logistics.InstantDeliveryPlugin;
import cn.lili.modules.system.entity.vo.InstantDeliveryVO;
import cn.lili.modules.system.mapper.InstantDeliveryMapper;
import cn.lili.modules.system.service.InstantDeliveryService;

View File

@ -54,7 +54,7 @@ public class CategoryManagerController {
@ApiOperation(value = "查询全部分类列表")
@GetMapping(value = "/allChildren")
public ResultMessage<List<CategoryVO>> list() {
return ResultUtil.data(this.categoryService.listAllChildrenDB());
return ResultUtil.data(this.categoryService.listAllChildren());
}
@PostMapping

View File

@ -10,7 +10,6 @@ import cn.lili.common.utils.StringUtils;
import cn.lili.common.vo.PageVO;
import cn.lili.common.vo.ResultMessage;
import cn.lili.common.vo.SearchVO;
import cn.lili.modules.system.aspect.annotation.DemoSite;
import cn.lili.modules.permission.entity.dos.AdminUser;
import cn.lili.modules.permission.entity.dto.AdminUserDTO;
import cn.lili.modules.permission.entity.vo.AdminUserVO;
@ -97,10 +96,10 @@ public class AdminUserManagerController {
AuthUser tokenUser = UserContext.getCurrentUser();
if (tokenUser != null) {
//查询当前管理员
AdminUser adminUserDB = adminUserService.findByUsername(tokenUser.getUsername());
adminUserDB.setAvatar(adminUser.getAvatar());
adminUserDB.setNickName(adminUser.getNickName());
if (!adminUserService.updateById(adminUserDB)) {
AdminUser oldAdminUser = adminUserService.findByUsername(tokenUser.getUsername());
oldAdminUser.setAvatar(adminUser.getAvatar());
oldAdminUser.setNickName(adminUser.getNickName());
if (!adminUserService.updateById(oldAdminUser)) {
throw new ServiceException(ResultCode.USER_EDIT_ERROR);
}
return ResultUtil.success(ResultCode.USER_EDIT_SUCCESS);