记得上下班打卡 | git大法好,push需谨慎

Commit d0a538c3 authored by 张国柄's avatar 张国柄

~API:店铺管理:公告通知;

parent c4cb3e63
......@@ -54,8 +54,13 @@ public class GoblinRedisConst {
*/
public static final String BASIC_GOODS_SKU = PREFIX.concat("bsc:goods_sku:");
/* ----------------------------------------------------------------- */
/**
* 店铺公告
* {goblin:store_ntc:${store_id}, com.liquidnet.service.goblin.dto.vo.GoblinGoodsSkuInfoVo}
*/
public static final String STORE_NOTICE = PREFIX.concat("store_ntc:");
/* ----------------------------------------------------------------- */
public static final String FRONT_TOP_BANNER = PREFIX.concat("front_top_banner"); //前端顶部banner
......
......@@ -17,12 +17,13 @@ public class GoblinStoreMgtNoticeAddParam implements Serializable {
@ApiModelProperty(position = 10, required = true, value = "店铺ID[64]")
@NotBlank(message = "店铺ID不能为空")
private String storeId;
@ApiModelProperty(position = 11, required = false, value = "公告ID[32]")
@ApiModelProperty(position = 11, required = false, value = "公告ID[编辑时必传]")
private String noticeId;
@ApiModelProperty(position = 12, required = true, value = "公告内容", example = "...")
@NotBlank(message = "公告内容不能为空") @Size(max = 50, message = "公告内容长度限制50个字符")
private String content;
@ApiModelProperty(position = 13, required = true, value = "发布时间[yyyy-MM-dd HH:mm:ss]")
@NotBlank(message = "发布时间不能为空")
@Pattern(regexp = LnsRegex.Valid.DATETIME_FULL, message = "发布时间格式有误")
private String releaseTime;
@ApiModelProperty(position = 14, required = true, value = "长期有效[0-否|1-是]", allowableValues = "0,1", example = "1")
......
......@@ -4,6 +4,10 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
@ApiModel(value = "GoblinStoreMgtNoticeFilterParam", description = "店铺管理:公告通知:公告列表筛选条件入参")
......@@ -11,7 +15,16 @@ import java.io.Serializable;
public class GoblinStoreMgtNoticeFilterParam implements Serializable {
private static final long serialVersionUID = -4698854628491039006L;
@ApiModelProperty(position = 10, required = true, value = "店铺ID[64]")
@NotBlank(message = "店铺ID不能为空")
private String storeId;
@ApiModelProperty(position = 11, required = false, value = "关键字[50]")
private String keyword;
@ApiModelProperty(position = 12, required = true, value = "当前记录起始索引", example = "1")
@Min(value = 1, message = "起始索引无效")
@NotNull(message = "起始索引无效")
private Integer pageNum;
@ApiModelProperty(position = 13, required = true, value = "每页显示记录数", example = "20")
@Max(value = 100, message = "显示记录数无效")
@NotNull(message = "显示记录数无效")
private Integer pageSize;
}
package com.liquidnet.service.goblin.dto.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.liquidnet.commons.lang.util.DateUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
......@@ -11,6 +12,7 @@ import java.time.LocalDateTime;
@ApiModel(value = "GoblinStoreNoticeVo", description = "店铺公告通知")
@Data
@JsonIgnoreProperties(ignoreUnknown = true)
public class GoblinStoreNoticeVo implements Serializable, Cloneable {
private static final long serialVersionUID = 156629407699728873L;
@ApiModelProperty(position = 10, value = "店铺ID")
......@@ -29,6 +31,8 @@ public class GoblinStoreNoticeVo implements Serializable, Cloneable {
private LocalDateTime cancellTime;
@ApiModelProperty(position = 16, value = "公告状态[0-待发布|1-已发布]")
private String status;
@ApiModelProperty(position = 17, value = "删除标记[0-未删除|1-删除]")
private String delFlg;
private String createdBy;
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = DateUtil.DATE_FULL_STR)
......
package com.liquidnet.service.goblin.service.manage;
import com.liquidnet.service.base.PagedResult;
import com.liquidnet.service.goblin.dto.manage.GoblinStoreMgtNoticeFilterParam;
import com.liquidnet.service.goblin.dto.vo.GoblinStoreNoticeVo;
import java.util.List;
public interface IGoblinStoreMgtNoticeService {
/**
* 店铺管理:公告通知:列表
*
* @param filterParam GoblinStoreMgtNoticeFilterParam
* @return PagedResult<GoblinStoreNoticeVo>
*/
PagedResult<GoblinStoreNoticeVo> pageList(GoblinStoreMgtNoticeFilterParam filterParam);
/**
* 店铺管理:公告通知:添加
*
* @param storeNoticeVo GoblinStoreNoticeVo
*/
void addSave(GoblinStoreNoticeVo storeNoticeVo);
/**
* 店铺管理:公告通知:编辑
*
* @param updateStoreNoticeVo GoblinStoreNoticeVo
* @return boolean
*/
boolean editSave(GoblinStoreNoticeVo updateStoreNoticeVo);
/**
* 店铺管理:公告通知:发布
*
* @param uid UID
* @param storeId 店铺ID
* @param noticeIdList List<String>
* @return boolean
*/
boolean releaseProcessing(String uid, String storeId, List<String> noticeIdList);
/**
* 店铺管理:公告通知:删除
*
* @param uid UID
* @param storeId 店铺ID
* @param noticeIdList List<String>
* @return boolean
*/
boolean removeProcessing(String uid, String storeId, List<String> noticeIdList);
}
......@@ -62,6 +62,11 @@ public class GoblinStoreNotice implements Serializable {
*/
private String status;
/**
* 删除标记[0-未删除|1-删除]
*/
private String delFlg;
private String createdBy;
private LocalDateTime createdAt;
......
......@@ -192,10 +192,11 @@ create table goblin_store_notice
notice_id varchar(32) not null comment '公告id',
store_id varchar(64) not null comment '店铺id',
content varchar(255) not null comment '公告内容',
releaseTime datetime not null comment '发布时间',
release_time datetime not null comment '发布时间',
long_lasting char default '0' comment '长期有效[0-否|1-是]',
cancellTime datetime not null comment '结束时间',
cancell_time datetime null comment '结束时间',
status char default '0' comment '公告状态[0-待发布|1-已发布]',
del_flg char default '0' comment '删除标记[0-未删除|1-删除]',
created_by varchar(64) not null,
created_at datetime not null,
updated_by varchar(64) null,
......
......@@ -2,9 +2,8 @@ package com.liquidnet.service.goblin.controller.manage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import com.liquidnet.commons.lang.util.CollectionUtil;
import com.liquidnet.commons.lang.util.CurrentUtil;
import com.liquidnet.commons.lang.util.JsonUtils;
import com.liquidnet.common.exception.constant.ErrorCode;
import com.liquidnet.commons.lang.util.*;
import com.liquidnet.service.base.ErrorMapping;
import com.liquidnet.service.base.PagedResult;
import com.liquidnet.service.base.ResponseDto;
......@@ -18,6 +17,7 @@ import com.liquidnet.service.goblin.dto.vo.GoblinStoreCertInfoVo;
import com.liquidnet.service.goblin.dto.vo.GoblinStoreConfigVo;
import com.liquidnet.service.goblin.dto.vo.GoblinStoreInfoVo;
import com.liquidnet.service.goblin.dto.vo.GoblinStoreNoticeVo;
import com.liquidnet.service.goblin.service.manage.IGoblinStoreMgtNoticeService;
import com.liquidnet.service.goblin.service.manage.IGoblinStoreMgtService;
import com.liquidnet.service.goblin.util.GoblinRedisUtils;
import com.liquidnet.service.goblin.util.ObjectUtil;
......@@ -49,6 +49,8 @@ public class GoblinStoreMgtController {
GoblinRedisUtils goblinRedisUtils;
@Autowired
IGoblinStoreMgtService goblinStoreMgtService;
@Autowired
IGoblinStoreMgtNoticeService goblinStoreMgtNoticeService;
@ApiOperationSupport(order = 1)
@ApiOperation(value = "店铺管理:店铺列表")
......@@ -190,11 +192,14 @@ public class GoblinStoreMgtController {
@PostMapping(value = {"notice/list"})
public ResponseDto<PagedResult<GoblinStoreNoticeVo>> noticeList(@Valid @RequestBody GoblinStoreMgtNoticeFilterParam noticeFilterParam) {
String currentUid = CurrentUtil.getCurrentUid();
// TODO: 2022/1/12 zhanggb 逻辑校验
if (!goblinRedisUtils.hasStoreId(currentUid, noticeFilterParam.getStoreId())) {
log.warn("店铺管理:公告通知:列表:无权查看该店铺[UID={},storeId={}]", currentUid, noticeFilterParam.getStoreId());
return ResponseDto.success();
}
if (log.isDebugEnabled()) {
log.debug("店铺管理:公告通知:列表[UID={},noticeFilterParam={}]", currentUid, JsonUtils.toJson(noticeFilterParam));
}
return ResponseDto.success();
return ResponseDto.success(goblinStoreMgtNoticeService.pageList(noticeFilterParam));
}
@ApiOperationSupport(order = 8)
......@@ -202,11 +207,34 @@ public class GoblinStoreMgtController {
@PostMapping(value = {"notice/add"})
public ResponseDto<Object> noticeAdd(@Valid @RequestBody GoblinStoreMgtNoticeAddParam noticeAddParam) {
String currentUid = CurrentUtil.getCurrentUid();
// TODO: 2022/1/12 zhanggb 逻辑校验
if (!goblinRedisUtils.hasStoreId(currentUid, noticeAddParam.getStoreId())) {
log.warn("店铺管理:公告通知:添加:无权操作该店铺[UID={},storeId={}]", currentUid, noticeAddParam.getStoreId());
return ResponseDto.failure(ErrorMapping.get("149002"));
}
if (log.isDebugEnabled()) {
log.debug("店铺管理:公告通知:添加[UID={},noticeAddParam={}]", currentUid, JsonUtils.toJson(noticeAddParam));
}
return ResponseDto.success();
if (noticeAddParam.getLongLasting().equals("0") && null == noticeAddParam.getCancellTime()) {
return ResponseDto.failure(ErrorCode.HTTP_PARAM_ERROR.getCode(), "结束时间不能为空");
}
LocalDateTime now = LocalDateTime.now();
GoblinStoreNoticeVo addStoreNoticeVo = GoblinStoreNoticeVo.getNew();
addStoreNoticeVo.setStoreId(noticeAddParam.getStoreId());
addStoreNoticeVo.setNoticeId(IDGenerator.nextMilliId());
addStoreNoticeVo.setContent(noticeAddParam.getContent());
addStoreNoticeVo.setReleaseTime(DateUtil.Formatter.yyyyMMddHHmmss.parse(noticeAddParam.getReleaseTime()));
addStoreNoticeVo.setLongLasting(noticeAddParam.getLongLasting());
if (noticeAddParam.getLongLasting().equals("0")) {
addStoreNoticeVo.setCancellTime(DateUtil.Formatter.yyyyMMddHHmmss.parse(noticeAddParam.getCancellTime()));
}
addStoreNoticeVo.setStatus(addStoreNoticeVo.getReleaseTime().compareTo(now) > 0 ? "0" : "1");
addStoreNoticeVo.setDelFlg("0");
addStoreNoticeVo.setCreatedBy(currentUid);
addStoreNoticeVo.setCreatedAt(now);
goblinStoreMgtNoticeService.addSave(addStoreNoticeVo);
return ResponseDto.success(addStoreNoticeVo.getNoticeId());
}
@ApiOperationSupport(order = 9)
......@@ -214,11 +242,38 @@ public class GoblinStoreMgtController {
@PostMapping(value = {"notice/edit"})
public ResponseDto<Object> noticeEdit(@Valid @RequestBody GoblinStoreMgtNoticeAddParam noticeEditParam) {
String currentUid = CurrentUtil.getCurrentUid();
// TODO: 2022/1/12 zhanggb 逻辑校验
if (!goblinRedisUtils.hasStoreId(currentUid, noticeEditParam.getStoreId())) {
log.warn("店铺管理:公告通知:编辑:无权操作该店铺[UID={},storeId={}]", currentUid, noticeEditParam.getStoreId());
return ResponseDto.failure(ErrorMapping.get("149002"));
}
List<GoblinStoreNoticeVo> noticeVos = goblinRedisUtils.getStoreNoticeVos(noticeEditParam.getStoreId(), LocalDateTime.now());
if (CollectionUtils.isEmpty(noticeVos)) {
log.warn("店铺管理:公告通知:编辑:无效操作,请先添加公告[UID={},noticeEditParam={}]", currentUid, JsonUtils.toJson(noticeEditParam));
return ResponseDto.failure(ErrorMapping.get("149001"));
}
if (log.isDebugEnabled()) {
log.debug("店铺管理:公告通知:编辑[UID={},noticeEditParam={}]", currentUid, JsonUtils.toJson(noticeEditParam));
}
return ResponseDto.success();
Optional<GoblinStoreNoticeVo> optional = noticeVos.stream().filter(r -> r.getNoticeId().equals(noticeEditParam.getNoticeId())).findAny();
if (!optional.isPresent() || optional.get().getStatus().equals("1")) {
log.warn("店铺管理:公告通知:编辑:无效操作,公告已发布或不存在[UID={},noticeEditParam={}]", currentUid, JsonUtils.toJson(noticeEditParam));
return ResponseDto.failure(ErrorMapping.get("149001"));
}
LocalDateTime now = LocalDateTime.now();
GoblinStoreNoticeVo updateStoreNoticeVo = GoblinStoreNoticeVo.getNew();
updateStoreNoticeVo.setStoreId(noticeEditParam.getStoreId());
updateStoreNoticeVo.setNoticeId(noticeEditParam.getNoticeId());
updateStoreNoticeVo.setContent(noticeEditParam.getContent());
updateStoreNoticeVo.setReleaseTime(DateUtil.Formatter.yyyyMMddHHmmss.parse(noticeEditParam.getReleaseTime()));
updateStoreNoticeVo.setLongLasting(noticeEditParam.getLongLasting());
if (noticeEditParam.getLongLasting().equals("0")) {
updateStoreNoticeVo.setCancellTime(DateUtil.Formatter.yyyyMMddHHmmss.parse(noticeEditParam.getCancellTime()));
}
updateStoreNoticeVo.setStatus(updateStoreNoticeVo.getReleaseTime().compareTo(now) > 0 ? "0" : "1");
updateStoreNoticeVo.setUpdatedBy(currentUid);
updateStoreNoticeVo.setUpdatedAt(now);
return ResponseDto.success(goblinStoreMgtNoticeService.editSave(updateStoreNoticeVo));
}
@ApiOperationSupport(order = 10)
......@@ -226,10 +281,25 @@ public class GoblinStoreMgtController {
@PostMapping(value = {"notice/operate"})
public ResponseDto<Object> noticeOperate(@Valid @RequestBody GoblinStoreMgtNoticeActionParam noticeActionParam) {
String currentUid = CurrentUtil.getCurrentUid();
// TODO: 2022/1/12 zhanggb 逻辑校验
if (!goblinRedisUtils.hasStoreId(currentUid, noticeActionParam.getStoreId())) {
log.warn("店铺管理:公告通知:管理:无权操作该店铺[UID={},storeId={}]", currentUid, noticeActionParam.getStoreId());
return ResponseDto.failure(ErrorMapping.get("149002"));
}
if (log.isDebugEnabled()) {
log.debug("店铺管理:公告通知:管理[UID={},noticeActionParam={}]", currentUid, JsonUtils.toJson(noticeActionParam));
}
return ResponseDto.success();
boolean operateResultFlg;
switch (noticeActionParam.getAction()) {
case "RELEASE":
operateResultFlg = goblinStoreMgtNoticeService.releaseProcessing(currentUid, noticeActionParam.getStoreId(), noticeActionParam.getNoticeIdList());
break;
case "REMOVE":
operateResultFlg = goblinStoreMgtNoticeService.removeProcessing(currentUid, noticeActionParam.getStoreId(), noticeActionParam.getNoticeIdList());
break;
default:
log.warn("Invalid operation[UID={},noticeActionParam={}]", currentUid, JsonUtils.toJson(noticeActionParam));
return ResponseDto.failure(ErrorMapping.get("149001"));
}
return operateResultFlg ? ResponseDto.success() : ResponseDto.failure();
}
}
......@@ -114,7 +114,7 @@ public class GoblinStoreMgtGoodsController {
goblinstoreMgtGoodsService.goodsRemove(storeMgtGoodsActionParam, currentUid);
break;
default:
log.warn("Invalid operation[action={}]", storeMgtGoodsActionParam.getAction());
log.warn("Invalid operation[UID={},storeMgtGoodsActionParam={}]", currentUid, JsonUtils.toJson(storeMgtGoodsActionParam));
return ResponseDto.failure(ErrorMapping.get("149001"));
}
return ResponseDto.success();
......
package com.liquidnet.service.goblin.service.impl.manage;
import com.liquidnet.commons.lang.util.CollectionUtil;
import com.liquidnet.commons.lang.util.JsonUtils;
import com.liquidnet.service.base.PagedResult;
import com.liquidnet.service.base.SqlMapping;
import com.liquidnet.service.base.constant.MQConst;
import com.liquidnet.service.goblin.dto.manage.GoblinStoreMgtNoticeFilterParam;
import com.liquidnet.service.goblin.dto.vo.GoblinStoreNoticeVo;
import com.liquidnet.service.goblin.service.manage.IGoblinStoreMgtNoticeService;
import com.liquidnet.service.goblin.util.GoblinMongoUtils;
import com.liquidnet.service.goblin.util.GoblinRedisUtils;
import com.liquidnet.service.goblin.util.ObjectUtil;
import com.liquidnet.service.goblin.util.QueueUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.LinkedList;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* <p>
* 店铺公告 服务实现类
* </p>
*
* @author zhanggb
* Created by IntelliJ IDEA at 2022/1/17
*/
@Slf4j
@Service
public class GoblinStoreMgtNoticeServiceImpl implements IGoblinStoreMgtNoticeService {
@Autowired
QueueUtils queueUtils;
@Autowired
GoblinRedisUtils goblinRedisUtils;
@Autowired
GoblinMongoUtils goblinMongoUtils;
@Override
public PagedResult<GoblinStoreNoticeVo> pageList(GoblinStoreMgtNoticeFilterParam filterParam) {
log.info("====={}", JsonUtils.toJson(goblinRedisUtils.getStoreNoticeVo(filterParam.getStoreId(), LocalDateTime.now())));
PagedResult<GoblinStoreNoticeVo> storeNoticeVoPagedResult = goblinMongoUtils.getStoreNoticeVos(filterParam);
if (!CollectionUtils.isEmpty(storeNoticeVoPagedResult.getList())) {
List<GoblinStoreNoticeVo> storeNoticeVoList = ObjectUtil.getGoblinStoreNoticeVoArrayList();
LocalDateTime now = LocalDateTime.now();
storeNoticeVoPagedResult.getList().forEach(r -> {
if (r.getStatus().equals("0") && r.getReleaseTime().isBefore(now)) {
r.setStatus("1");
r.setUpdatedAt(r.getReleaseTime());
storeNoticeVoList.add(r);
}
});
if (!CollectionUtils.isEmpty(storeNoticeVoList) && goblinMongoUtils.updateStoreNoticeVoByBulk(storeNoticeVoList)) {
List<String> noticeIdList = storeNoticeVoList.stream().map(GoblinStoreNoticeVo::getNoticeId).collect(Collectors.toList());
List<GoblinStoreNoticeVo> storeNoticeVos = goblinRedisUtils.getStoreNoticeVos(filterParam.getStoreId(), now);
boolean toUpdateFlg = false;
for (GoblinStoreNoticeVo r : storeNoticeVos) {
if (noticeIdList.contains(r.getNoticeId())) {
r.setStatus("1");
r.setUpdatedAt(r.getReleaseTime());
toUpdateFlg = true;
}
}
if (toUpdateFlg) {
goblinRedisUtils.setStoreNoticeVos(filterParam.getStoreId(), storeNoticeVos);
}
}
}
return storeNoticeVoPagedResult;
}
@Override
public void addSave(GoblinStoreNoticeVo storeNoticeVo) {
goblinMongoUtils.setStoreNoticeVo(storeNoticeVo);
List<GoblinStoreNoticeVo> storeNoticeVos = goblinRedisUtils.getStoreNoticeVos(storeNoticeVo.getStoreId(), storeNoticeVo.getCreatedAt());
storeNoticeVos.add(storeNoticeVo);
goblinRedisUtils.setStoreNoticeVos(storeNoticeVo.getStoreId(),
storeNoticeVos.stream().sorted(Comparator.comparing(GoblinStoreNoticeVo::getReleaseTime).thenComparing(GoblinStoreNoticeVo::getCreatedAt)).collect(Collectors.toList()));
queueUtils.sendMsgByRedis(MQConst.GoblinQueue.SQL_STORE.getKey(),
SqlMapping.get("goblin_store_notice.insert",
storeNoticeVo.getNoticeId(), storeNoticeVo.getStoreId(), storeNoticeVo.getContent(),
storeNoticeVo.getReleaseTime(), storeNoticeVo.getLongLasting(), storeNoticeVo.getCancellTime(),
storeNoticeVo.getStatus(), storeNoticeVo.getCreatedBy(), storeNoticeVo.getCreatedAt())
);
}
@Override
public boolean editSave(GoblinStoreNoticeVo updateStoreNoticeVo) {
if (goblinMongoUtils.updateStoreNoticeVo(updateStoreNoticeVo)) {
String storeId = updateStoreNoticeVo.getStoreId();
List<GoblinStoreNoticeVo> storeNoticeVos = goblinRedisUtils.getStoreNoticeVos(storeId, updateStoreNoticeVo.getUpdatedAt());
storeNoticeVos.forEach(r -> {
if (r.getNoticeId().equals(updateStoreNoticeVo.getNoticeId())) {
r.setContent(updateStoreNoticeVo.getContent());
r.setReleaseTime(updateStoreNoticeVo.getReleaseTime());
r.setLongLasting(updateStoreNoticeVo.getLongLasting());
r.setCancellTime(updateStoreNoticeVo.getCancellTime());
r.setStatus(updateStoreNoticeVo.getStatus());
r.setUpdatedBy(updateStoreNoticeVo.getUpdatedBy());
r.setUpdatedAt(updateStoreNoticeVo.getUpdatedAt());
}
});
goblinRedisUtils.setStoreNoticeVos(storeId,
storeNoticeVos.stream().sorted(Comparator.comparing(GoblinStoreNoticeVo::getReleaseTime).thenComparing(GoblinStoreNoticeVo::getCreatedAt)).collect(Collectors.toList()));
queueUtils.sendMsgByRedis(MQConst.GoblinQueue.SQL_STORE.getKey(),
SqlMapping.get("goblin_store_notice.update",
updateStoreNoticeVo.getContent(), updateStoreNoticeVo.getReleaseTime(), updateStoreNoticeVo.getLongLasting(),
updateStoreNoticeVo.getCancellTime(), updateStoreNoticeVo.getStatus(), updateStoreNoticeVo.getUpdatedBy(),
updateStoreNoticeVo.getUpdatedAt(), updateStoreNoticeVo.getNoticeId())
);
}
return false;
}
@Override
public boolean releaseProcessing(String uid, String storeId, List<String> noticeIdList) {
LocalDateTime now = LocalDateTime.now();
if (goblinMongoUtils.updateStoreNoticeVoByRelease(uid, now, storeId, noticeIdList)) {
List<GoblinStoreNoticeVo> storeNoticeVos = goblinRedisUtils.getStoreNoticeVos(storeId, now);
storeNoticeVos.forEach(r -> {
if (noticeIdList.contains(r.getNoticeId())) {
r.setReleaseTime(now);
r.setStatus("1");
r.setUpdatedBy(uid);
r.setUpdatedAt(now);
}
});
goblinRedisUtils.setStoreNoticeVos(storeId, storeNoticeVos);
LinkedList<Object[]> updateStoreNoticeObjs = CollectionUtil.linkedListObjectArr();
noticeIdList.forEach(noticeId -> updateStoreNoticeObjs.add(new Object[]{now, uid, now, storeId, noticeId}));
queueUtils.sendMsgByRedis(MQConst.GoblinQueue.SQL_STORE.getKey(),
SqlMapping.get("goblin_store_notice.release", updateStoreNoticeObjs));
return true;
}
return false;
}
@Override
public boolean removeProcessing(String uid, String storeId, List<String> noticeIdList) {
LocalDateTime now = LocalDateTime.now();
if (goblinMongoUtils.updateStoreNoticeVoByRemove(uid, now, storeId, noticeIdList)) {
List<GoblinStoreNoticeVo> storeNoticeVos = goblinRedisUtils.getStoreNoticeVos(storeId, now);
storeNoticeVos.removeIf(r -> noticeIdList.contains(r.getNoticeId()));
goblinRedisUtils.setStoreNoticeVos(storeId, storeNoticeVos);
LinkedList<Object[]> revStoreNoticeObjs = CollectionUtil.linkedListObjectArr();
noticeIdList.forEach(noticeId -> revStoreNoticeObjs.add(new Object[]{uid, now, storeId, noticeId}));
queueUtils.sendMsgByRedis(MQConst.GoblinQueue.SQL_STORE.getKey(),
SqlMapping.get("goblin_store_notice.remove", revStoreNoticeObjs));
return true;
}
return false;
}
}
......@@ -5,6 +5,7 @@ import com.liquidnet.service.base.SqlMapping;
import com.liquidnet.service.base.constant.MQConst;
import com.liquidnet.service.goblin.dto.vo.GoblinStoreConfigVo;
import com.liquidnet.service.goblin.dto.vo.GoblinStoreInfoVo;
import com.liquidnet.service.goblin.enums.GoblinStoreConf;
import com.liquidnet.service.goblin.service.manage.IGoblinStoreMgtService;
import com.liquidnet.service.goblin.util.GoblinMongoUtils;
import com.liquidnet.service.goblin.util.GoblinRedisUtils;
......@@ -51,18 +52,29 @@ public class GoblinStoreMgtServiceImpl implements IGoblinStoreMgtService {
LocalDateTime now = LocalDateTime.now();
List<GoblinStoreConfigVo> storeConfigVos = goblinRedisUtils.getStoreConfigVos(storeId);
List<GoblinStoreConfigVo> updateStoreConfigVoList = ObjectUtil.getGoblinStoreConfigVoArrayList();
storeConfigVos.forEach(configVo -> {
boolean toUpdateStoreStatusFlg = false;
for (GoblinStoreConfigVo configVo : storeConfigVos) {
String updateConfVal = confMap.get(configVo.getConfigKey());
if (configVo.getConfigKey().equals(GoblinStoreConf.BUSINESS_STATUS.name())) {
toUpdateStoreStatusFlg = !configVo.getConfigVal().equals(updateConfVal);
}
if (StringUtils.isNotEmpty(updateConfVal)) {
configVo.setConfigVal(updateConfVal);
configVo.setUpdatedBy(uid);
configVo.setUpdatedAt(now);
updateStoreConfigVoList.add(configVo);
}
});
}
if (!CollectionUtils.isEmpty(updateStoreConfigVoList) && goblinMongoUtils.updateStoreConfigVos(updateStoreConfigVoList)) {
// goblinRedisUtils.setStoreConfigVos(storeId, storeConfigVos);// TODO: 2022/1/17 zhanggb==
if (toUpdateStoreStatusFlg) {
GoblinStoreInfoVo storeInfoVo = goblinRedisUtils.getStoreInfoVo(storeId);
storeInfoVo.setStatus(confMap.get(GoblinStoreConf.BUSINESS_STATUS.name()));
goblinMongoUtils.updateStoreInfoVo(storeInfoVo);
// goblinRedisUtils.setStoreInfoVo(storeInfoVo);// TODO: 2022/1/17 zhanggb==
}
LinkedList<Object[]> updateStoreConfigVoObjs = CollectionUtil.linkedListObjectArr();
updateStoreConfigVoList.forEach(uc -> updateStoreConfigVoObjs.add(new Object[]{uc.getConfigVal(), uc.getUpdatedBy(), uc.getUpdatedAt(), uc.getStoreId(), uc.getConfigKey()}));
queueUtils.sendMsgByRedis(MQConst.GoblinQueue.SQL_STORE.getKey(),
......
......@@ -5,6 +5,7 @@ import com.liquidnet.commons.lang.util.DateUtil;
import com.liquidnet.service.base.PagedResult;
import com.liquidnet.service.goblin.constant.GoblinStatusConst;
import com.liquidnet.service.goblin.dto.manage.GoblinStoreMgtGoodsFilterParam;
import com.liquidnet.service.goblin.dto.manage.GoblinStoreMgtNoticeFilterParam;
import com.liquidnet.service.goblin.dto.manage.vo.GoblinMgtCategorySpecVo;
import com.liquidnet.service.goblin.dto.manage.vo.GoblinStoreMgtGoodsListVo;
import com.liquidnet.service.goblin.dto.vo.*;
......@@ -32,7 +33,6 @@ import org.springframework.util.CollectionUtils;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.regex.Pattern;
......@@ -121,6 +121,86 @@ public class GoblinMongoUtils {
return (List<GoblinServiceSupportVo>) mongoTemplate.insert(vos, GoblinServiceSupportVo.class.getSimpleName());
}
/* ---------------------------------------- 店铺公告数据源 ---------------------------------------- */
public PagedResult<GoblinStoreNoticeVo> getStoreNoticeVos(GoblinStoreMgtNoticeFilterParam filterParam) {
Criteria criteria = Criteria.where("storeId").is(filterParam.getStoreId()).and("delFlg").is("0");
if (StringUtils.isNotBlank(filterParam.getKeyword())) {
Pattern pattern = Pattern.compile("^.*" + filterParam.getKeyword() + ".*$", Pattern.CASE_INSENSITIVE);
criteria.andOperator(
Criteria.where("content").regex(pattern)
);
}
Query query = Query.query(criteria);
long count = mongoTemplate.count(query, GoblinStoreNoticeVo.class.getSimpleName());
PagedResult<GoblinStoreNoticeVo> pagedResult = ObjectUtil.getGoblinStoreNoticeVoPagedResult();
if (count <= 0) return pagedResult;
query.with(PageRequest.of(filterParam.getPageNum() - 1, filterParam.getPageSize()));
query.with(Sort.by(Sort.Order.desc("createdAt")));
List<GoblinStoreNoticeVo> storeNoticeVos = mongoTemplate.find(query, GoblinStoreNoticeVo.class, GoblinStoreNoticeVo.class.getSimpleName());
return pagedResult.setList(storeNoticeVos).setTotal(count, filterParam.getPageSize());
}
/**
* 查取指定店铺有效的公告通知
*
* @param storeId 店铺ID
* @return List<GoblinStoreNoticeVo>
*/
public List<GoblinStoreNoticeVo> getStoreNoticeVos(String storeId, LocalDateTime nowTime) {
return mongoTemplate.find(Query.query(Criteria.where("storeId").is(storeId).and("delFlg").is("0")
.orOperator(
Criteria.where("releaseTime").gte(nowTime),
Criteria.where("longLasting").is("0").and("cancellTime").gte(nowTime),
Criteria.where("longLasting").is("1")
)
).with(Sort.by(Sort.Order.asc("releaseTime"), Sort.Order.asc("createdAt"))),
GoblinStoreNoticeVo.class, GoblinStoreNoticeVo.class.getSimpleName());
}
public void setStoreNoticeVo(GoblinStoreNoticeVo vo) {
mongoTemplate.insert(vo, GoblinStoreNoticeVo.class.getSimpleName());
}
public boolean updateStoreNoticeVo(GoblinStoreNoticeVo vo) {
return mongoTemplate.getCollection(GoblinStoreNoticeVo.class.getSimpleName())
.updateOne(
Query.query(Criteria.where("storeId").is(vo.getStoreId()).and("delFlg").is("0").and("noticeId").is(vo.getNoticeId())).getQueryObject(),
ObjectUtil.cloneBasicDBObject().append("$set", mongoConverter.convertToMongoType(vo))
).getModifiedCount() > 0;
}
public boolean updateStoreNoticeVoByBulk(List<GoblinStoreNoticeVo> vos) {
List<WriteModel<Document>> list = ObjectUtil.getWriteModelDocumentArrayList();
vos.forEach(r -> {
if (StringUtils.isNotEmpty(r.getStoreId())) {
list.add(new UpdateOneModel<>(
Query.query(Criteria.where("storeId").is(r.getStoreId()).and("noticeId").is(r.getNoticeId())).getQueryObject(),
Update.update("releaseTime", r.getReleaseTime()).set("status", r.getStatus()).set("updatedBy", r.getUpdatedBy()).set("updatedAt", r.getUpdatedAt()).getUpdateObject()
));
}
});
return mongoTemplate.getCollection(GoblinStoreNoticeVo.class.getSimpleName()).bulkWrite(list).getModifiedCount() > 0;
}
public boolean updateStoreNoticeVoByRelease(String uid, LocalDateTime nowTime, String storeId, List<String> noticeIdList) {
return mongoTemplate.getCollection(GoblinStoreNoticeVo.class.getSimpleName()).updateMany(
Query.query(Criteria.where("storeId").is(storeId).and("delFlg").is("0").and("noticeId").in(noticeIdList.toArray()).and("status").is("0")).getQueryObject(),
Update.update("status", "1").set("releaseTime", nowTime).set("updatedBy", uid).set("updatedAt", nowTime).getUpdateObject()
).getModifiedCount() > 0;
}
public boolean updateStoreNoticeVoByRemove(String uid, LocalDateTime nowTime, String storeId, List<String> noticeIdList) {
return mongoTemplate.getCollection(GoblinStoreNoticeVo.class.getSimpleName()).updateMany(
Query.query(Criteria.where("storeId").is(storeId).and("delFlg").is("0").and("noticeId").in(noticeIdList.toArray())).getQueryObject(),
Update.update("delFlg", "1").set("updatedBy", uid).set("updatedAt", nowTime).getUpdateObject()
).getModifiedCount() > 0;
}
/* ---------------------------------------- 店铺配置数据源 ---------------------------------------- */
public List<GoblinStoreConfigVo> getStoreConfigVos(String storeId) {
......@@ -220,7 +300,7 @@ public class GoblinMongoUtils {
// SPU分页
public PagedResult<GoblinStoreMgtGoodsListVo> getGoodsInfoVo(GoblinStoreMgtGoodsFilterParam filterParam) {
Criteria criteria = new Criteria();
Criteria criteria = Criteria.where("delFlg").is("0");
if (StringUtils.isNotBlank(filterParam.getKeyword())) {
Pattern pattern = Pattern.compile("^.*" + filterParam.getKeyword() + ".*$", Pattern.CASE_INSENSITIVE);
criteria.andOperator(
......@@ -252,7 +332,7 @@ public class GoblinMongoUtils {
if (null != filterParam.getPriceLe()) {
criteria.andOperator(Criteria.where("priceGe").lte(filterParam.getPriceLe()));
}
Query query = Query.query(criteria.and("delFlg").is("0"));
Query query = Query.query(criteria);
long count = mongoTemplate.count(query, GoblinGoodsInfoVo.class.getSimpleName());
......@@ -520,7 +600,7 @@ public class GoblinMongoUtils {
public String storeMoney(String storeId, String spuId) {
String spuName = "店铺总收入";
Criteria criteria = Criteria.where("status").in(GoblinStatusConst.Status.ORDER_LOG_STATUS_11.getValue(), GoblinStatusConst.Status.ORDER_LOG_STATUS_22.getValue(), GoblinStatusConst.Status.ORDER_LOG_STATUS_28.getValue()).and("storeId").is(storeId);
Aggregation aggregation ;
Aggregation aggregation;
if (spuId != null) {
criteria = criteria.and("spuId").is(spuId);
Query query = Query.query(Criteria.where("spuId").is(spuId));
......@@ -537,7 +617,7 @@ public class GoblinMongoUtils {
.first("spuId").as("spuId")
.first("skuPriceActual").as("skuPriceActual")
.sum("skuPriceActualBig").as("skuPriceActualBig"));
}else{
} else {
aggregation = Aggregation.newAggregation(
Aggregation.match(criteria),
Aggregation.group("storeId")
......
......@@ -12,6 +12,7 @@ import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
......@@ -150,12 +151,44 @@ public class GoblinRedisUtils {
return vos;
}
/* ---------------------------------------- 店铺公告数据源 ---------------------------------------- */
public GoblinStoreNoticeVo getStoreNoticeVo(String storeId, LocalDateTime nowTime) {
List<GoblinStoreNoticeVo> noticeVos = this.getStoreNoticeVos(storeId, nowTime);
int size = noticeVos.size();
for (int i = size-1; i >= 0; i--) {
GoblinStoreNoticeVo noticeVo = noticeVos.get(i);
if (noticeVo.getReleaseTime().isBefore(nowTime)) {
noticeVos.removeIf(r -> (
(r.getLongLasting().equals("0") && r.getCancellTime().isBefore(nowTime))
|| r.getReleaseTime().isBefore(noticeVo.getReleaseTime())
));
this.setStoreNoticeVos(storeId, noticeVos);
return noticeVo;
}
}
return null;
}
public List<GoblinStoreNoticeVo> getStoreNoticeVos(String storeId, LocalDateTime nowTime) {
String rk = GoblinRedisConst.STORE_NOTICE.concat(storeId);
List<GoblinStoreNoticeVo> vos = (List<GoblinStoreNoticeVo>) redisUtil.get(rk);
if (CollectionUtils.isEmpty(vos) && !CollectionUtils.isEmpty(vos = goblinMongoUtils.getStoreNoticeVos(storeId, nowTime))) {
// redisUtil.set(rk, vos);
}
return vos;
}
public boolean setStoreNoticeVos(String storeId, List<GoblinStoreNoticeVo> vos) {
return redisUtil.set(GoblinRedisConst.STORE_NOTICE.concat(storeId), vos);
}
/* ---------------------------------------- 店铺配置数据源 ---------------------------------------- */
public List<GoblinStoreConfigVo> getStoreConfigVos(String storeId) {
String rk = GoblinRedisConst.BASIC_STORE_CONF.concat(storeId);
List<GoblinStoreConfigVo> vos = (List<GoblinStoreConfigVo>) redisUtil.get(rk);
if (CollectionUtils.isEmpty(vos) && null != (vos = goblinMongoUtils.getStoreConfigVos(storeId))) {
if (CollectionUtils.isEmpty(vos) && !CollectionUtils.isEmpty(vos = goblinMongoUtils.getStoreConfigVos(storeId))) {
// redisUtil.set(rk, vos);// TODO: 2022/1/12 zhanggb==
}
return vos;
......
......@@ -18,6 +18,7 @@ import java.util.ArrayList;
public class ObjectUtil {
private static final PagedResult<GoblinStoreMgtGoodsListVo> goblinStoreMgtGoodsVoPagedResult = new PagedResult<>();
private static final PagedResult<GoblinStoreNoticeVo> goblinStoreNoticeVoPagedResult = new PagedResult<>();
private static final ArrayList<GoblinGoodsInfoVo> goblinGoodsInfoVoArrayList = new ArrayList<>();
private static final ArrayList<GoblinFrontBanner> goblinFrontBannerArrayList = new ArrayList<>();
......@@ -25,6 +26,7 @@ public class ObjectUtil {
private static final ArrayList<GoblinSelfMarketingVo> goblinSelfMarketingVoArrayList = new ArrayList<>();
private static final ArrayList<GoblinStoreMgtThumbVo> goblinStoreMgtThumbVoArrayList = new ArrayList<>();
private static final ArrayList<GoblinStoreConfigVo> goblinStoreConfigVoArrayList = new ArrayList<>();
private static final ArrayList<GoblinStoreNoticeVo> goblinStoreNoticeVoArrayList = new ArrayList<>();
private static final ArrayList<GoblinGoodsSkuInfoVo> goblinGoodsSkuInfoVoArrayList = new ArrayList<>();
private static final ArrayList<GoblinGoodsSpecVo> goblinGoodsSpecVoArrayList = new ArrayList<>();
private static final ArrayList<GoblinGoodsSpecValueVo> goblinGoodsSpecValueVoArrayList = new ArrayList<>();
......@@ -50,38 +52,45 @@ public class ObjectUtil {
private static final ArrayList<GoblinZhengzaiPushVo> goblinZhengzaiPushVoArrayList = new ArrayList<>();
private static final ArrayList<GoblinStoreOrderListVo> goblinStoreOrderListVoArrayList = new ArrayList<>();
private static final ArrayList<GoblinStoreOrderListSkuVo> goblinStoreOrderListSkuVoArrayList = new ArrayList<>();
private static final ArrayList<GoblinShoppingCartVo> goblinShoppingCartVoArrayList=new ArrayList<>();
private static final ArrayList<GoblinShoppingCartVoDetail> goblinShoppingCartVoDetailArrayList=new ArrayList<>();
private static final ArrayList<GoblinStoreBackOrderListVo> goblinStoreBackOrderListVoArrayList=new ArrayList<>();
private static final ArrayList<GoblinAppOrderListVo> goblinAppOrderListVoArrayList=new ArrayList<>();
private static final ArrayList<GoblinBackOrderSkuVo> goblinBackOrderSkuVoArrayList=new ArrayList<>();
private static final ArrayList<GoblinShoppingCartVo> goblinShoppingCartVoArrayList = new ArrayList<>();
private static final ArrayList<GoblinShoppingCartVoDetail> goblinShoppingCartVoDetailArrayList = new ArrayList<>();
private static final ArrayList<GoblinStoreBackOrderListVo> goblinStoreBackOrderListVoArrayList = new ArrayList<>();
private static final ArrayList<GoblinAppOrderListVo> goblinAppOrderListVoArrayList = new ArrayList<>();
private static final ArrayList<GoblinBackOrderSkuVo> goblinBackOrderSkuVoArrayList = new ArrayList<>();
private static final ArrayList<GoblinFrontNavigationVo> goblinFrontNavigationVoArrayList=new ArrayList<>();
private static final ArrayList<GoblinFrontNavigationVo> goblinFrontNavigationVoArrayList = new ArrayList<>();
private static final BasicDBObject basicDBObject = new BasicDBObject();
private static final ArrayList<WriteModel<Document>> writeModelDocumentArrayList = new ArrayList<>();
public static ArrayList<GoblinFrontNavigationVo> getgoblinFrontNavigationVoArrayList() {
return (ArrayList<GoblinFrontNavigationVo>) goblinFrontNavigationVoArrayList.clone();
}
public static PagedResult<GoblinStoreMgtGoodsListVo> getGoblinStoreMgtGoodsVoPagedResult() {
return goblinStoreMgtGoodsVoPagedResult.clone();
}
public static PagedResult<GoblinStoreNoticeVo> getGoblinStoreNoticeVoPagedResult() {
return goblinStoreNoticeVoPagedResult.clone();
}
public static ArrayList<GoblinBackOrderSkuVo> goblinBackOrderSkuVoArrayList() {
return (ArrayList<GoblinBackOrderSkuVo>) goblinBackOrderSkuVoArrayList.clone();
}
public static ArrayList<GoblinShoppingCartVo> goblinShoppingCartVoArrayList() {
return (ArrayList<GoblinShoppingCartVo>) goblinShoppingCartVoArrayList.clone();
}
public static ArrayList<GoblinAppOrderListVo> goblinAppOrderListVoArrayList() {
return (ArrayList<GoblinAppOrderListVo>) goblinAppOrderListVoArrayList.clone();
}
public static ArrayList<GoblinStoreBackOrderListVo> goblinStoreBackOrderListVoArrayList() {
return (ArrayList<GoblinStoreBackOrderListVo>) goblinStoreBackOrderListVoArrayList.clone();
}
public static ArrayList<GoblinShoppingCartVoDetail> goblinShoppingCartVoDetailArrayList() {
return (ArrayList<GoblinShoppingCartVoDetail>) goblinShoppingCartVoDetailArrayList.clone();
}
public static ArrayList<GoblinStoreOrderListSkuVo> getGoblinStoreOrderListSkuVoArrayList() {
return (ArrayList<GoblinStoreOrderListSkuVo>) goblinStoreOrderListSkuVoArrayList.clone();
}
......@@ -154,6 +163,10 @@ public class ObjectUtil {
return (ArrayList<GoblinStoreConfigVo>) goblinStoreConfigVoArrayList.clone();
}
public static ArrayList<GoblinStoreNoticeVo> getGoblinStoreNoticeVoArrayList() {
return (ArrayList<GoblinStoreNoticeVo>) goblinStoreNoticeVoArrayList.clone();
}
public static ArrayList<GoblinGoodsSkuInfoVo> getGoblinGoodsSkuInfoVoArrayList() {
return (ArrayList<GoblinGoodsSkuInfoVo>) goblinGoodsSkuInfoVoArrayList.clone();
}
......@@ -207,6 +220,10 @@ public class ObjectUtil {
}
public static ArrayList<GoblinFrontNavigationVo> getgoblinFrontNavigationVoArrayList() {
return (ArrayList<GoblinFrontNavigationVo>) goblinFrontNavigationVoArrayList.clone();
}
public static BasicDBObject cloneBasicDBObject() {
return (BasicDBObject) basicDBObject.clone();
}
......
......@@ -10,6 +10,12 @@ goblin_store_certification.update_by_cert=UPDATE goblin_store_certification SET
goblin_store_certification.update_by_del=UPDATE goblin_store_certification SET del_flg=1,updated_by=?,updated_at=? WHERE store_id=?
#---- 店铺配置信息
goblin_store_config.update=UPDATE goblin_store_config SET config_val=?,updated_by=?,updated_at=? WHERE store_id=? AND config_key=?
#---- 店铺公告信息
goblin_store_notice.insert=INSERT INTO goblin_store_notice (notice_id,store_id,content,release_time,long_lasting,cancell_time,status,created_by,created_at)VALUES(?,?,?,?,?,?,?,?,?)
goblin_store_notice.update=UPDATE goblin_store_notice set content=?,release_time=?,long_lasting=?,cancell_time=?,status=?,updated_by=?,updated_at=? WHERE notice_id=?
goblin_store_notice.release=UPDATE goblin_store_notice SET release_time=?,status='1',updated_by=?,updated_at=? WHERE store_id=? AND notice_id=?
goblin_store_notice.remove=UPDATE goblin_store_notice SET del_flg='1',updated_by=?,updated_at=? WHERE store_id=? AND notice_id=?
#---- 商品信息
goblin_goods.insert=INSERT INTO goblin_goods (spu_id,spu_no,name,subtitle,sell_price, price_ge,price_le,intro,details,cover_pic, video,spec_mode,store_id,cate_fid,cate_sid, cate_tid,store_cate_fid,store_cate_sid,store_cate_tid,brand_id, shelves_handle,shelves_time,spu_validity,virtual_flg,status, shelves_status,spu_appear,shelves_at,created_by,created_at, logistics_template)VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
goblin_goods.update_by_shelves=UPDATE goblin_goods SET shelves_status=?,shelves_at=?,updated_by=?,updated_at=? WHERE spu_id=? AND store_id=? AND spu_appear='0'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment