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

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

~API:店铺审核+初始化配置;

~API:公告添加入参必填调整;
parent 1daf5707
...@@ -29,7 +29,7 @@ public class GoblinStoreMgtNoticeAddParam implements Serializable { ...@@ -29,7 +29,7 @@ public class GoblinStoreMgtNoticeAddParam implements Serializable {
@NotBlank(message = "长期有效参数不能为空") @NotBlank(message = "长期有效参数不能为空")
@Pattern(regexp = "\\b(0|1)\\b", message = "长期有效参数无效") @Pattern(regexp = "\\b(0|1)\\b", message = "长期有效参数无效")
private String longLasting; private String longLasting;
@ApiModelProperty(position = 15, required = true, value = "结束时间[yyyy-MM-dd HH:mm:ss]") @ApiModelProperty(position = 15, required = false, value = "结束时间,长期有效时无需指定[yyyy-MM-dd HH:mm:ss]")
@Pattern(regexp = LnsRegex.Valid.DATETIME_FULL, message = "结束时间格式有误") @Pattern(regexp = LnsRegex.Valid.DATETIME_FULL, message = "结束时间格式有误")
private String cancellTime; private String cancellTime;
} }
...@@ -2,6 +2,7 @@ package com.liquidnet.service.goblin.dto.vo; ...@@ -2,6 +2,7 @@ package com.liquidnet.service.goblin.dto.vo;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import com.liquidnet.commons.lang.util.DateUtil; import com.liquidnet.commons.lang.util.DateUtil;
import com.liquidnet.service.goblin.entity.GoblinStoreConfig;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
...@@ -60,4 +61,15 @@ public class GoblinStoreConfigVo implements Serializable, Cloneable { ...@@ -60,4 +61,15 @@ public class GoblinStoreConfigVo implements Serializable, Cloneable {
return new GoblinStoreConfigVo(); return new GoblinStoreConfigVo();
} }
} }
public GoblinStoreConfigVo copy(GoblinStoreConfig source) {
if (null == source) return this;
this.setStoreId(source.getStoreId());
this.setConfigName(source.getConfigName());
this.setConfigKey(source.getConfigKey());
this.setConfigVal(source.getConfigVal());
this.setConfigDesc(source.getConfigDesc());
this.setConfigType(source.getConfigType());
return this;
}
} }
package com.liquidnet.client.admin.zhengzai.goblin.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.liquidnet.service.goblin.dto.vo.GoblinStoreConfigVo;
import com.liquidnet.service.goblin.entity.GoblinStoreConfig;
import java.util.List;
/**
* <p>
* 店铺设置 服务类
* </p>
*
* @author liquidnet
* @since 2021-12-27
*/
public interface IGoblinStoreConfigService extends IService<GoblinStoreConfig> {
/**
* 初始化店铺配置
*
* @param storeId 店铺ID
* @return List<GoblinStoreConfig>
*/
List<GoblinStoreConfigVo> initStoreConfigs(String storeId);
}
package com.liquidnet.client.admin.zhengzai.goblin.service.impl;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.liquidnet.client.admin.zhengzai.goblin.service.IGoblinStoreConfigService;
import com.liquidnet.common.exception.LiquidnetServiceException;
import com.liquidnet.commons.lang.util.JsonUtils;
import com.liquidnet.service.goblin.dto.vo.GoblinStoreConfigVo;
import com.liquidnet.service.goblin.entity.GoblinStoreConfig;
import com.liquidnet.service.goblin.mapper.GoblinStoreConfigMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
/**
* <p>
* 店铺设置 服务实现类
* </p>
*
* @author liquidnet
* @since 2021-12-27
*/
@Slf4j
@Service
public class GoblinStoreConfigServiceImpl extends ServiceImpl<GoblinStoreConfigMapper, GoblinStoreConfig> implements IGoblinStoreConfigService {
@Override
public List<GoblinStoreConfigVo> initStoreConfigs(String storeId) {
List<GoblinStoreConfig> initStoreConfigList = this.list(Wrappers.lambdaQuery(GoblinStoreConfig.class).eq(GoblinStoreConfig::getStoreId, "0"));
if (!CollectionUtils.isEmpty(initStoreConfigList)) {
List<GoblinStoreConfigVo> initStoreConfigVoList = new ArrayList<>();
String operator = "system";
LocalDateTime now = LocalDateTime.now();
initStoreConfigList.forEach(c -> {
c.setStoreId(storeId);
c.setCreatedBy(operator);
c.setCreatedAt(now);
initStoreConfigVoList.add(GoblinStoreConfigVo.getNew().copy(c));
});
if (this.saveBatch(initStoreConfigList)) {
return initStoreConfigVoList;
}
}
log.warn("店铺审核:初始化配置失败:店铺初始配置为空或数据存储失败[initStoreConfigList={}]", JsonUtils.toJson(initStoreConfigList));
throw new LiquidnetServiceException();
}
}
...@@ -3,8 +3,10 @@ package com.liquidnet.client.admin.zhengzai.goblin.service.impl; ...@@ -3,8 +3,10 @@ package com.liquidnet.client.admin.zhengzai.goblin.service.impl;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.liquidnet.client.admin.zhengzai.goblin.service.IGoblinStoreConfigService;
import com.liquidnet.client.admin.zhengzai.goblin.service.IGoblinStoreInfoService; import com.liquidnet.client.admin.zhengzai.goblin.service.IGoblinStoreInfoService;
import com.liquidnet.common.exception.LiquidnetServiceException; import com.liquidnet.common.exception.LiquidnetServiceException;
import com.liquidnet.service.goblin.dto.vo.GoblinStoreConfigVo;
import com.liquidnet.service.goblin.dto.vo.GoblinStoreInfoVo; import com.liquidnet.service.goblin.dto.vo.GoblinStoreInfoVo;
import com.liquidnet.service.goblin.entity.GoblinStoreInfo; import com.liquidnet.service.goblin.entity.GoblinStoreInfo;
import com.liquidnet.service.goblin.mapper.GoblinStoreInfoMapper; import com.liquidnet.service.goblin.mapper.GoblinStoreInfoMapper;
...@@ -19,6 +21,7 @@ import org.springframework.stereotype.Service; ...@@ -19,6 +21,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.List;
/** /**
* <p> * <p>
...@@ -33,6 +36,8 @@ import java.time.LocalDateTime; ...@@ -33,6 +36,8 @@ import java.time.LocalDateTime;
public class GoblinStoreInfoServiceImpl extends ServiceImpl<GoblinStoreInfoMapper, GoblinStoreInfo> implements IGoblinStoreInfoService { public class GoblinStoreInfoServiceImpl extends ServiceImpl<GoblinStoreInfoMapper, GoblinStoreInfo> implements IGoblinStoreInfoService {
@Autowired @Autowired
private MongoTemplate mongoTemplate; private MongoTemplate mongoTemplate;
@Autowired
private IGoblinStoreConfigService goblinStoreConfigService;
@Override @Override
@Transactional @Transactional
...@@ -48,6 +53,12 @@ public class GoblinStoreInfoServiceImpl extends ServiceImpl<GoblinStoreInfoMappe ...@@ -48,6 +53,12 @@ public class GoblinStoreInfoServiceImpl extends ServiceImpl<GoblinStoreInfoMappe
lambdaUpdateWrapper.set(GoblinStoreInfo::getUpdatedAt, now); lambdaUpdateWrapper.set(GoblinStoreInfo::getUpdatedAt, now);
if (this.update(lambdaUpdateWrapper)) { if (this.update(lambdaUpdateWrapper)) {
if (status.equals("3")) {// 审核通过即生成店铺配置
List<GoblinStoreConfigVo> storeConfigVos = goblinStoreConfigService.initStoreConfigs(storeId);
mongoTemplate.insert(storeConfigVos, GoblinStoreConfigVo.class.getSimpleName());
// TODO: 2022/1/13 zhanggb redis
}
Query query = Query.query(Criteria.where("storeId").is(storeId)); Query query = Query.query(Criteria.where("storeId").is(storeId));
Update update = Update.update("status", status); Update update = Update.update("status", status);
update.set("reason", reason); update.set("reason", reason);
...@@ -58,7 +69,7 @@ public class GoblinStoreInfoServiceImpl extends ServiceImpl<GoblinStoreInfoMappe ...@@ -58,7 +69,7 @@ public class GoblinStoreInfoServiceImpl extends ServiceImpl<GoblinStoreInfoMappe
log.error("店铺管理:店铺审核:MDB更新失败[storeId={},status={},operator={}]", storeId, status, operator); log.error("店铺管理:店铺审核:MDB更新失败[storeId={},status={},operator={}]", storeId, status, operator);
throw new LiquidnetServiceException(); throw new LiquidnetServiceException();
} }
// TODO: 2021/12/29 zhanggb 同步REDIS // TODO: 2021/12/29 zhanggb redis
return true; return true;
} }
......
...@@ -177,10 +177,10 @@ create table goblin_store_config ...@@ -177,10 +177,10 @@ create table goblin_store_config
create index idx_gsc_store_id on goblin_store_config (store_id); create index idx_gsc_store_id on goblin_store_config (store_id);
# insert into goblin_store_config (store_id, config_name, config_key, config_val, created_by, created_at) insert into goblin_store_config (store_id, config_name, config_key, config_val, created_by, created_at)
# values (0, '联系客服', 'ONOFF_CUSTOMER_SERVICE', 'ON', 'admin', sysdate()), values (0, '联系客服', 'ONOFF_CUSTOMER_SEV', 'ON', 'admin', sysdate()),
# (0, '售罄展示', 'ONOFF_SOLD_OUT_SHOW', 'ON', 'admin', sysdate()), (0, '售罄展示', 'ONOFF_SOLD_OUT_SHOW', 'ON', 'admin', sysdate()),
# (0, '库存不足', 'LIMIT_WARNING_STOCK', '5', 'admin', sysdate()); (0, '库存不足', 'LIMIT_WARNING_STOCK', '5', 'admin', sysdate());
# -- >>------------------------------------------------------------------------------------ # -- >>------------------------------------------------------------------------------------
drop table if exists goblin_store_notice; drop table if exists goblin_store_notice;
create table goblin_store_notice create table goblin_store_notice
...@@ -335,7 +335,7 @@ create table goblin_goods_sku ...@@ -335,7 +335,7 @@ create table goblin_goods_sku
warning_stock int null comment '预警库存', warning_stock int null comment '预警库存',
price decimal(20, 2) not null comment '单品现价', price decimal(20, 2) not null comment '单品现价',
price_member decimal(20, 2) not null comment '单品会员价格', price_member decimal(20, 2) not null comment '单品会员价格',
weight decimal(20, 2) not null comment '单品的重量', weight decimal(20, 2) null comment '单品的重量',
buy_factor char default '0' comment '购买限制[0-全部用户|1-仅会员|2-指定用户]', buy_factor char default '0' comment '购买限制[0-全部用户|1-仅会员|2-指定用户]',
buy_roster varchar(256) null comment '购买限制人员名单[购买限制为2-指定用户时必填]', buy_roster varchar(256) null comment '购买限制人员名单[购买限制为2-指定用户时必填]',
buy_limit int null comment '限量[0-无限制|X:限购数量]', buy_limit int null comment '限量[0-无限制|X:限购数量]',
......
...@@ -100,8 +100,7 @@ public class GoblinStoreMgtCertificationController { ...@@ -100,8 +100,7 @@ public class GoblinStoreMgtCertificationController {
@PostMapping("cancel") @PostMapping("cancel")
public ResponseDto<Object> certificationCancel(@NotBlank(message = "店铺ID不能为空") @RequestParam String storeId) { public ResponseDto<Object> certificationCancel(@NotBlank(message = "店铺ID不能为空") @RequestParam String storeId) {
String currentUid = CurrentUtil.getCurrentUid(); String currentUid = CurrentUtil.getCurrentUid();
// if (!goblinRedisUtils.hasStoreId(currentUid, storeId)) { if (!goblinRedisUtils.hasStoreId(currentUid, storeId)) {
if (!goblinRedisUtils.hasStoreId(currentUid, storeId) || storeId.equals("1")) {// TODO: 2022/1/7 zhanggb del
return ResponseDto.failure(ErrorMapping.get("149002")); return ResponseDto.failure(ErrorMapping.get("149002"));
} }
log.info("删除店铺[UID={},storeId={}]", currentUid, storeId); log.info("删除店铺[UID={},storeId={}]", currentUid, storeId);
......
...@@ -36,8 +36,7 @@ public class GoblinStoreMgtCertificationServiceImpl implements IGoblinStoreMgtCe ...@@ -36,8 +36,7 @@ public class GoblinStoreMgtCertificationServiceImpl implements IGoblinStoreMgtCe
String uid = CurrentUtil.getCurrentUid(); String uid = CurrentUtil.getCurrentUid();
LocalDateTime now = LocalDateTime.now(); LocalDateTime now = LocalDateTime.now();
// if (null == storeInfoVo) { if (null == storeInfoVo) {
if (null == storeInfoVo || storeInfoVo.getStoreId().equals("1")) {// TODO: 2022/1/6 zhanggb del
storeInfoVo = GoblinStoreInfoVo.getNew(); storeInfoVo = GoblinStoreInfoVo.getNew();
storeInfoVo.setStoreId(IDGenerator.get32UUID()); storeInfoVo.setStoreId(IDGenerator.get32UUID());
storeInfoVo.setUid(uid); storeInfoVo.setUid(uid);
...@@ -150,6 +149,7 @@ public class GoblinStoreMgtCertificationServiceImpl implements IGoblinStoreMgtCe ...@@ -150,6 +149,7 @@ public class GoblinStoreMgtCertificationServiceImpl implements IGoblinStoreMgtCe
if (goblinMongoUtils.delStoreInfoVo(storeId, uid, now)) { if (goblinMongoUtils.delStoreInfoVo(storeId, uid, now)) {
goblinRedisUtils.delStoreId(CurrentUtil.getCurrentUid(), storeId); goblinRedisUtils.delStoreId(CurrentUtil.getCurrentUid(), storeId);
goblinRedisUtils.delStoreInfoVo(storeId); goblinRedisUtils.delStoreInfoVo(storeId);
// TODO: 2022/1/13 zhanggb redis.config.store
List<String> delSpuIdList = goblinMongoUtils.delGoodsInfoVoByStoreId(storeId, uid, now); List<String> delSpuIdList = goblinMongoUtils.delGoodsInfoVoByStoreId(storeId, uid, now);
delSpuIdList.forEach(spuId -> goblinRedisUtils.delGoodsInfoVo(spuId)); delSpuIdList.forEach(spuId -> goblinRedisUtils.delGoodsInfoVo(spuId));
...@@ -162,12 +162,10 @@ public class GoblinStoreMgtCertificationServiceImpl implements IGoblinStoreMgtCe ...@@ -162,12 +162,10 @@ public class GoblinStoreMgtCertificationServiceImpl implements IGoblinStoreMgtCe
updateStoreObjs.add(new Object[]{uid, now, storeId}); updateStoreObjs.add(new Object[]{uid, now, storeId});
toMqSqls.add(SqlMapping.get("goblin_store_certification.update_by_del")); toMqSqls.add(SqlMapping.get("goblin_store_certification.update_by_del"));
toMqSqls.add(SqlMapping.get("goblin_goods.update_by_del")); toMqSqls.add(SqlMapping.get("goblin_goods.update_by_del_store"));
LinkedList<Object[]> updateGoodsObjs = CollectionUtil.linkedListObjectArr(); LinkedList<Object[]> updateGoodsObjs = CollectionUtil.linkedListObjectArr();
updateGoodsObjs.add(new Object[]{uid, now, uid, now, storeId}); updateGoodsObjs.add(new Object[]{uid, now, uid, now, storeId});
toMqSqls.add(SqlMapping.get("goblin_goods_sku.update_by_del")); toMqSqls.add(SqlMapping.get("goblin_goods_sku.update_by_del_store"));
// TODO: 2022/1/10 redis+规格|标签|服务支持关联入库
queueUtils.sendMsgByRedis(MQConst.GoblinQueue.SQL_STORE.getKey(), SqlMapping.gets(toMqSqls, updateStoreObjs, updateStoreObjs, updateGoodsObjs, updateGoodsObjs)); queueUtils.sendMsgByRedis(MQConst.GoblinQueue.SQL_STORE.getKey(), SqlMapping.gets(toMqSqls, updateStoreObjs, updateStoreObjs, updateGoodsObjs, updateGoodsObjs));
} }
......
...@@ -105,7 +105,7 @@ public class GoblinMongoUtils { ...@@ -105,7 +105,7 @@ public class GoblinMongoUtils {
public List<GoblinStoreConfigVo> getStoreConfigVo(String storeId) { public List<GoblinStoreConfigVo> getStoreConfigVo(String storeId) {
Query query = Query.query(Criteria.where("storeId").is(storeId)); Query query = Query.query(Criteria.where("storeId").is(storeId));
query.fields().include("config_name").include("config_key").include("config_val"); query.fields().include("configName").include("configKey").include("configVal");
return mongoTemplate.find(query, return mongoTemplate.find(query,
GoblinStoreConfigVo.class, GoblinStoreConfigVo.class.getSimpleName()); GoblinStoreConfigVo.class, GoblinStoreConfigVo.class.getSimpleName());
} }
...@@ -131,12 +131,12 @@ public class GoblinMongoUtils { ...@@ -131,12 +131,12 @@ public class GoblinMongoUtils {
} }
public GoblinStoreInfoVo getStoreInfoVo(String storeId) { public GoblinStoreInfoVo getStoreInfoVo(String storeId) {
return mongoTemplate.findOne(Query.query(Criteria.where("storeId").is(storeId)), return mongoTemplate.findOne(Query.query(Criteria.where("storeId").is(storeId).and("delFlg").is("0")),
GoblinStoreInfoVo.class, GoblinStoreInfoVo.class.getSimpleName()); GoblinStoreInfoVo.class, GoblinStoreInfoVo.class.getSimpleName());
} }
public GoblinStoreInfoVo getStoreInfoVoByUid(String uid) { public GoblinStoreInfoVo getStoreInfoVoByUid(String uid) {
return mongoTemplate.findOne(Query.query(Criteria.where("uid").is(uid)), return mongoTemplate.findOne(Query.query(Criteria.where("uid").is(uid).and("delFlg").is("0")),
GoblinStoreInfoVo.class, GoblinStoreInfoVo.class.getSimpleName()); GoblinStoreInfoVo.class, GoblinStoreInfoVo.class.getSimpleName());
} }
...@@ -148,20 +148,20 @@ public class GoblinMongoUtils { ...@@ -148,20 +148,20 @@ public class GoblinMongoUtils {
} }
public boolean delGoodsInfoVo(String spuId) { public boolean delGoodsInfoVo(String spuId) {
return mongoTemplate.remove(Query.query(Criteria.where("spuId").is(spuId)), return mongoTemplate.remove(Query.query(Criteria.where("spuId").is(spuId).and("delFlg").is("0")),
GoblinGoodsInfoVo.class, GoblinGoodsInfoVo.class.getSimpleName()).getDeletedCount() > 0; GoblinGoodsInfoVo.class, GoblinGoodsInfoVo.class.getSimpleName()).getDeletedCount() > 0;
} }
public boolean delGoodsInfoVoBySpuIds(String storeId, List<String> spuIdList, String uid, LocalDateTime time) { public boolean delGoodsInfoVoBySpuIds(String storeId, List<String> spuIdList, String uid, LocalDateTime time) {
return mongoTemplate.updateMulti( return mongoTemplate.updateMulti(
Query.query(Criteria.where("store_id").is(storeId).and("spuId").in(spuIdList.toArray())), Query.query(Criteria.where("store_id").is(storeId).and("spuId").in(spuIdList.toArray()).and("delFlg").is("0")),
Update.update("delFlg", 1).set("updatedBy", uid).set("updatedAt", time).set("deletedBy", uid).set("deletedAt", time), Update.update("delFlg", 1).set("updatedBy", uid).set("updatedAt", time).set("deletedBy", uid).set("deletedAt", time),
GoblinGoodsInfoVo.class.getSimpleName() GoblinGoodsInfoVo.class.getSimpleName()
).getModifiedCount() > 0; ).getModifiedCount() > 0;
} }
public List<String> delGoodsInfoVoByStoreId(String storeId, String uid, LocalDateTime time) { public List<String> delGoodsInfoVoByStoreId(String storeId, String uid, LocalDateTime time) {
Query query = Query.query(Criteria.where("storeId").is(storeId).and("shelves_status").is("3")); Query query = Query.query(Criteria.where("storeId").is(storeId).and("delFlg").is("0").and("shelves_status").is("3"));
query.fields().include("spuId"); query.fields().include("spuId");
List<GoblinGoodsInfoVo> storeSpus = mongoTemplate.find(query, GoblinGoodsInfoVo.class, GoblinGoodsInfoVo.class.getSimpleName()); List<GoblinGoodsInfoVo> storeSpus = mongoTemplate.find(query, GoblinGoodsInfoVo.class, GoblinGoodsInfoVo.class.getSimpleName());
...@@ -229,13 +229,13 @@ public class GoblinMongoUtils { ...@@ -229,13 +229,13 @@ public class GoblinMongoUtils {
// SPU信息 // SPU信息
public GoblinGoodsInfoVo getGoodsInfoVo(String spuId) { public GoblinGoodsInfoVo getGoodsInfoVo(String spuId) {
return mongoTemplate.findOne(Query.query(Criteria.where("spuId").is(spuId).and("shelvesStatus").is("3")), return mongoTemplate.findOne(Query.query(Criteria.where("spuId").is(spuId).and("delFlg").is("0").and("shelvesStatus").is("3")),
GoblinGoodsInfoVo.class, GoblinGoodsInfoVo.class.getSimpleName()); GoblinGoodsInfoVo.class, GoblinGoodsInfoVo.class.getSimpleName());
} }
// SPU信息 // SPU信息
public GoblinGoodsInfoVo getMgtGoodsInfoVo(String spuId) { public GoblinGoodsInfoVo getMgtGoodsInfoVo(String spuId) {
return mongoTemplate.findOne(Query.query(Criteria.where("spuId").is(spuId)), return mongoTemplate.findOne(Query.query(Criteria.where("spuId").is(spuId).and("delFlg").is("0")),
GoblinGoodsInfoVo.class, GoblinGoodsInfoVo.class.getSimpleName()); GoblinGoodsInfoVo.class, GoblinGoodsInfoVo.class.getSimpleName());
} }
...@@ -243,7 +243,7 @@ public class GoblinMongoUtils { ...@@ -243,7 +243,7 @@ public class GoblinMongoUtils {
public boolean updateGoodsInfoVo(GoblinGoodsInfoVo vo) { public boolean updateGoodsInfoVo(GoblinGoodsInfoVo vo) {
return mongoTemplate.getCollection(GoblinGoodsInfoVo.class.getSimpleName()) return mongoTemplate.getCollection(GoblinGoodsInfoVo.class.getSimpleName())
.updateOne( .updateOne(
Query.query(Criteria.where("spuId").is(vo.getSpuId())).getQueryObject(), Query.query(Criteria.where("spuId").is(vo.getSpuId()).and("delFlg").is("0")).getQueryObject(),
ObjectUtil.cloneBasicDBObject().append("$set", mongoConverter.convertToMongoType(vo)) ObjectUtil.cloneBasicDBObject().append("$set", mongoConverter.convertToMongoType(vo))
).getModifiedCount() > 0; ).getModifiedCount() > 0;
} }
...@@ -265,12 +265,12 @@ public class GoblinMongoUtils { ...@@ -265,12 +265,12 @@ public class GoblinMongoUtils {
} }
public boolean delGoodsSkuInfoVo(String skuId) { public boolean delGoodsSkuInfoVo(String skuId) {
return mongoTemplate.remove(Query.query(Criteria.where("skuId").is(skuId)), return mongoTemplate.remove(Query.query(Criteria.where("skuId").is(skuId).and("delFlg").is("0")),
GoblinGoodsSkuInfoVo.class, GoblinGoodsSkuInfoVo.class.getSimpleName()).getDeletedCount() > 0; GoblinGoodsSkuInfoVo.class, GoblinGoodsSkuInfoVo.class.getSimpleName()).getDeletedCount() > 0;
} }
public List<String> delGoodsSkuInfoVoByStoreId(String storeId, String uid, LocalDateTime time) { public List<String> delGoodsSkuInfoVoByStoreId(String storeId, String uid, LocalDateTime time) {
Query query = Query.query(Criteria.where("storeId").is(storeId).and("shelves_status").is("3")); Query query = Query.query(Criteria.where("storeId").is(storeId).and("delFlg").is("0").and("shelves_status").is("3"));
query.fields().include("skuId"); query.fields().include("skuId");
List<GoblinGoodsSkuInfoVo> storeSkus = mongoTemplate.find(query, GoblinGoodsSkuInfoVo.class, GoblinGoodsSkuInfoVo.class.getSimpleName()); List<GoblinGoodsSkuInfoVo> storeSkus = mongoTemplate.find(query, GoblinGoodsSkuInfoVo.class, GoblinGoodsSkuInfoVo.class.getSimpleName());
...@@ -289,13 +289,13 @@ public class GoblinMongoUtils { ...@@ -289,13 +289,13 @@ public class GoblinMongoUtils {
// SKU信息 // SKU信息
public GoblinGoodsSkuInfoVo getGoodsSkuInfoVo(String skuId) { public GoblinGoodsSkuInfoVo getGoodsSkuInfoVo(String skuId) {
return mongoTemplate.findOne(Query.query(Criteria.where("skuId").is(skuId).and("shelvesStatus").is("3")), return mongoTemplate.findOne(Query.query(Criteria.where("skuId").is(skuId).and("delFlg").is("0").and("shelvesStatus").is("3")),
GoblinGoodsSkuInfoVo.class, GoblinGoodsSkuInfoVo.class.getSimpleName()); GoblinGoodsSkuInfoVo.class, GoblinGoodsSkuInfoVo.class.getSimpleName());
} }
// SKU信息 // SKU信息
public GoblinGoodsSkuInfoVo getMgtGoodsSkuInfoVo(String skuId) { public GoblinGoodsSkuInfoVo getMgtGoodsSkuInfoVo(String skuId) {
return mongoTemplate.findOne(Query.query(Criteria.where("skuId").is(skuId)), return mongoTemplate.findOne(Query.query(Criteria.where("skuId").is(skuId).and("delFlg").is("0")),
GoblinGoodsSkuInfoVo.class, GoblinGoodsSkuInfoVo.class.getSimpleName()); GoblinGoodsSkuInfoVo.class, GoblinGoodsSkuInfoVo.class.getSimpleName());
} }
...@@ -303,20 +303,20 @@ public class GoblinMongoUtils { ...@@ -303,20 +303,20 @@ public class GoblinMongoUtils {
public boolean updateGoodsSkuInfoVo(GoblinGoodsSkuInfoVo vo) { public boolean updateGoodsSkuInfoVo(GoblinGoodsSkuInfoVo vo) {
return mongoTemplate.getCollection(GoblinGoodsSkuInfoVo.class.getSimpleName()) return mongoTemplate.getCollection(GoblinGoodsSkuInfoVo.class.getSimpleName())
.updateOne( .updateOne(
Query.query(Criteria.where("skuId").is(vo.getSkuId())).getQueryObject(), Query.query(Criteria.where("skuId").is(vo.getSkuId()).and("delFlg").is("0")).getQueryObject(),
ObjectUtil.cloneBasicDBObject().append("$set", mongoConverter.convertToMongoType(vo)) ObjectUtil.cloneBasicDBObject().append("$set", mongoConverter.convertToMongoType(vo))
).getModifiedCount() > 0; ).getModifiedCount() > 0;
} }
public boolean updateGoodsSkuInfoVoBySpuId(GoblinGoodsSkuInfoVo vo) { public boolean updateGoodsSkuInfoVoBySpuId(GoblinGoodsSkuInfoVo vo) {
return mongoTemplate.getCollection(GoblinGoodsSkuInfoVo.class.getSimpleName()).updateMany( return mongoTemplate.getCollection(GoblinGoodsSkuInfoVo.class.getSimpleName()).updateMany(
Query.query(Criteria.where("spuId").is(vo.getSpuId())).getQueryObject(), Query.query(Criteria.where("spuId").is(vo.getSpuId()).and("delFlg").is("0")).getQueryObject(),
ObjectUtil.cloneBasicDBObject().append("$set", mongoConverter.convertToMongoType(vo)) ObjectUtil.cloneBasicDBObject().append("$set", mongoConverter.convertToMongoType(vo))
).getModifiedCount() > 0; ).getModifiedCount() > 0;
} }
public boolean updateGoodsSkuInfoVoByShelves(String storeId, List<String> spuIdList, boolean shelvesFlg, String uid, LocalDateTime time) { public boolean updateGoodsSkuInfoVoByShelves(String storeId, List<String> spuIdList, boolean shelvesFlg, String uid, LocalDateTime time) {
return mongoTemplate.updateMulti(Query.query(Criteria.where("storeId").is(storeId).and("spuId").in(spuIdList.toArray())), return mongoTemplate.updateMulti(Query.query(Criteria.where("storeId").is(storeId).and("delFlg").is("0").and("spuId").in(spuIdList.toArray())),
Update.update("shelvesStatus", shelvesFlg ? "3" : "1").set("shelvesAt", time).set("updatedBy", uid).set("updatedAt", time), Update.update("shelvesStatus", shelvesFlg ? "3" : "1").set("shelvesAt", time).set("updatedBy", uid).set("updatedAt", time),
GoblinGoodsSkuInfoVo.class.getSimpleName()).getModifiedCount() > 0; GoblinGoodsSkuInfoVo.class.getSimpleName()).getModifiedCount() > 0;
} }
......
...@@ -89,7 +89,7 @@ public class GoblinRedisUtils { ...@@ -89,7 +89,7 @@ public class GoblinRedisUtils {
List<GoblinStoreGoodsCategoryVo> vos = null; List<GoblinStoreGoodsCategoryVo> vos = null;
if (valStrIsEmptyFlg && !CollectionUtils.isEmpty(vos = goblinMongoUtils.getStoreGoodsCategoryVos(storeId))) { if (valStrIsEmptyFlg && !CollectionUtils.isEmpty(vos = goblinMongoUtils.getStoreGoodsCategoryVos(storeId))) {
valStr = JsonUtils.toJson(vos); valStr = JsonUtils.toJson(vos);
// redisUtil.set(rk, valStr);// TODO: 2022/1/11 zhanggb 暂不启用 // redisUtil.set(rk, valStr);// TODO: 2022/1/11 zhanggb==
} else if (!valStrIsEmptyFlg) { } else if (!valStrIsEmptyFlg) {
vos = JsonUtils.fromJson(valStr, new TypeReference<List<GoblinStoreGoodsCategoryVo>>() { vos = JsonUtils.fromJson(valStr, new TypeReference<List<GoblinStoreGoodsCategoryVo>>() {
}); });
...@@ -103,7 +103,7 @@ public class GoblinRedisUtils { ...@@ -103,7 +103,7 @@ public class GoblinRedisUtils {
String rk = GoblinRedisConst.BASIC_STORE_CONF.concat(storeId); String rk = GoblinRedisConst.BASIC_STORE_CONF.concat(storeId);
List<GoblinStoreConfigVo> vos = (List<GoblinStoreConfigVo>) redisUtil.get(rk); List<GoblinStoreConfigVo> vos = (List<GoblinStoreConfigVo>) redisUtil.get(rk);
if (CollectionUtils.isEmpty(vos) && null != (vos = goblinMongoUtils.getStoreConfigVo(storeId))) { if (CollectionUtils.isEmpty(vos) && null != (vos = goblinMongoUtils.getStoreConfigVo(storeId))) {
// redisUtil.set(rk, vos);// TODO: 2022/1/12 zhanggb 暂不设置 // redisUtil.set(rk, vos);// TODO: 2022/1/12 zhanggb==
} }
return vos; return vos;
} }
...@@ -137,10 +137,9 @@ public class GoblinRedisUtils { ...@@ -137,10 +137,9 @@ public class GoblinRedisUtils {
} }
public List<String> getStoreIds(String uid) { public List<String> getStoreIds(String uid) {
// return (List<String>) redisUtil.get(GoblinRedisConst.BASIC_USTORE.concat(uid)); // List<String> list = (List<String>) redisUtil.get(GoblinRedisConst.BASIC_USTORE.concat(uid));
// return Arrays.asList("1");// TODO: 2022/1/5 zhanggb // return CollectionUtils.isEmpty(list) ? Arrays.asList("1") : list;
List<String> list = (List<String>) redisUtil.get(GoblinRedisConst.BASIC_USTORE.concat(uid)); return (List<String>) redisUtil.get(GoblinRedisConst.BASIC_USTORE.concat(uid));
return CollectionUtils.isEmpty(list) ? Arrays.asList("1") : list;
} }
public boolean hasStoreId(String uid, String storeId) { public boolean hasStoreId(String uid, String storeId) {
...@@ -166,14 +165,25 @@ public class GoblinRedisUtils { ...@@ -166,14 +165,25 @@ public class GoblinRedisUtils {
String rk = GoblinRedisConst.BASIC_STORE.concat(storeId); String rk = GoblinRedisConst.BASIC_STORE.concat(storeId);
GoblinStoreInfoVo vo = (GoblinStoreInfoVo) redisUtil.get(rk); GoblinStoreInfoVo vo = (GoblinStoreInfoVo) redisUtil.get(rk);
if (null == vo && null != (vo = goblinMongoUtils.getStoreInfoVo(storeId))) { if (null == vo && null != (vo = goblinMongoUtils.getStoreInfoVo(storeId))) {
// redisUtil.set(rk, vo);// TODO: 2022/1/4 zhanggb:暂不设置 // redisUtil.set(rk, vo);// TODO: 2022/1/4 zhanggb==
} }
return vo; return vo;
} }
public GoblinStoreInfoVo getStoreInfoVoByUid(String uid) { public GoblinStoreInfoVo getStoreInfoVoByUid(String uid) {
List<String> storeIds = this.getStoreIds(uid); List<String> storeIds = this.getStoreIds(uid);
return CollectionUtils.isEmpty(storeIds) ? goblinMongoUtils.getStoreInfoVoByUid(uid) : this.getStoreInfoVo(storeIds.get(0)); GoblinStoreInfoVo storeInfoVo;
if (CollectionUtils.isEmpty(storeIds)) {
storeInfoVo = goblinMongoUtils.getStoreInfoVoByUid(uid);
if (null != storeInfoVo) {
storeIds = CollectionUtil.arrayListString();
storeIds.add(storeInfoVo.getStoreId());
this.setStoreIds(uid, storeIds);
}
} else {
storeInfoVo = this.getStoreInfoVo(storeIds.get(0));
}
return storeInfoVo;
} }
/* ---------------------------------------- 商品数据源 ---------------------------------------- */ /* ---------------------------------------- 商品数据源 ---------------------------------------- */
...@@ -196,7 +206,7 @@ public class GoblinRedisUtils { ...@@ -196,7 +206,7 @@ public class GoblinRedisUtils {
String rk = GoblinRedisConst.BASIC_GOODS.concat(spuId); String rk = GoblinRedisConst.BASIC_GOODS.concat(spuId);
GoblinGoodsInfoVo vo = (GoblinGoodsInfoVo) redisUtil.get(rk); GoblinGoodsInfoVo vo = (GoblinGoodsInfoVo) redisUtil.get(rk);
if (null == vo && null != (vo = goblinMongoUtils.getGoodsInfoVo(spuId))) { if (null == vo && null != (vo = goblinMongoUtils.getGoodsInfoVo(spuId))) {
// redisUtil.set(rk, vo);// TODO: 2022/1/4 zhanggb:暂不设置 // redisUtil.set(rk, vo);// TODO: 2022/1/4 zhanggb==
vo = !vo.getDelFlg().equals("0") ? null : vo; vo = !vo.getDelFlg().equals("0") ? null : vo;
} }
...@@ -207,7 +217,7 @@ public class GoblinRedisUtils { ...@@ -207,7 +217,7 @@ public class GoblinRedisUtils {
String rk = GoblinRedisConst.BASIC_GOODS.concat(spuId); String rk = GoblinRedisConst.BASIC_GOODS.concat(spuId);
GoblinGoodsInfoVo vo = (GoblinGoodsInfoVo) redisUtil.get(rk); GoblinGoodsInfoVo vo = (GoblinGoodsInfoVo) redisUtil.get(rk);
if (null == vo && null != (vo = goblinMongoUtils.getMgtGoodsInfoVo(spuId))) { if (null == vo && null != (vo = goblinMongoUtils.getMgtGoodsInfoVo(spuId))) {
// redisUtil.set(rk, vo);// TODO: 2022/1/4 zhanggb:暂不设置 // redisUtil.set(rk, vo);// TODO: 2022/1/4 zhanggb==
} }
return vo; return vo;
} }
...@@ -230,7 +240,7 @@ public class GoblinRedisUtils { ...@@ -230,7 +240,7 @@ public class GoblinRedisUtils {
String rk = GoblinRedisConst.BASIC_GOODS_SKU.concat(skuId); String rk = GoblinRedisConst.BASIC_GOODS_SKU.concat(skuId);
GoblinGoodsSkuInfoVo vo = (GoblinGoodsSkuInfoVo) redisUtil.get(rk); GoblinGoodsSkuInfoVo vo = (GoblinGoodsSkuInfoVo) redisUtil.get(rk);
if (null == vo && null != (vo = goblinMongoUtils.getGoodsSkuInfoVo(skuId))) { if (null == vo && null != (vo = goblinMongoUtils.getGoodsSkuInfoVo(skuId))) {
// redisUtil.set(rk, vo);// TODO: 2022/1/4 zhanggb:暂不设置 // redisUtil.set(rk, vo);// TODO: 2022/1/4 zhanggb==
vo = !vo.getDelFlg().equals("0") ? null : vo; vo = !vo.getDelFlg().equals("0") ? null : vo;
} }
...@@ -241,7 +251,7 @@ public class GoblinRedisUtils { ...@@ -241,7 +251,7 @@ public class GoblinRedisUtils {
String rk = GoblinRedisConst.BASIC_GOODS_SKU.concat(skuId); String rk = GoblinRedisConst.BASIC_GOODS_SKU.concat(skuId);
GoblinGoodsSkuInfoVo vo = (GoblinGoodsSkuInfoVo) redisUtil.get(rk); GoblinGoodsSkuInfoVo vo = (GoblinGoodsSkuInfoVo) redisUtil.get(rk);
if (null == vo && null != (vo = goblinMongoUtils.getMgtGoodsSkuInfoVo(skuId))) { if (null == vo && null != (vo = goblinMongoUtils.getMgtGoodsSkuInfoVo(skuId))) {
// redisUtil.set(rk, vo);// TODO: 2022/1/4 zhanggb:暂不设置 // redisUtil.set(rk, vo);// TODO: 2022/1/4 zhanggb==
} }
return vo; return vo;
} }
......
...@@ -11,10 +11,12 @@ goblin_store_certification.update_by_del=UPDATE goblin_store_certification SET d ...@@ -11,10 +11,12 @@ goblin_store_certification.update_by_del=UPDATE goblin_store_certification SET d
#---- 商品信息 #---- 商品信息
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.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' 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'
goblin_goods.update_by_del_store=UPDATE goblin_goods SET del_flg=1,updated_by=?,updated_at=?,deleted_by=?,deleted_at=? WHERE store_id=?
goblin_goods.update_by_del=UPDATE goblin_goods SET del_flg=1,updated_by=?,updated_at=?,deleted_by=?,deleted_at=? WHERE spu_id=? AND store_id=? goblin_goods.update_by_del=UPDATE goblin_goods SET del_flg=1,updated_by=?,updated_at=?,deleted_by=?,deleted_at=? WHERE spu_id=? AND store_id=?
goblin_goods_sku.insert=INSERT INTO goblin_goods_sku (sku_id,spu_id,sku_no,name,subtitle, sell_price,sku_pic,sku_isbn,stock,sku_stock, warning_stock,price,price_member,weight,buy_factor, buy_roster,buy_limit,store_id,sku_validity,virtual_flg, status,shelves_status,sku_appear,shelves_at,created_by, created_at,logistics_template)VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) goblin_goods_sku.insert=INSERT INTO goblin_goods_sku (sku_id,spu_id,sku_no,name,subtitle, sell_price,sku_pic,sku_isbn,stock,sku_stock, warning_stock,price,price_member,weight,buy_factor, buy_roster,buy_limit,store_id,sku_validity,virtual_flg, status,shelves_status,sku_appear,shelves_at,created_by, created_at,logistics_template)VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
goblin_goods_sku.update_by_shelves=UPDATE goblin_goods_sku SET shelves_status=?,shelves_at=?,updated_by=?,updated_at=? WHERE spu_id=? AND store_id=? AND sku_appear='0' goblin_goods_sku.update_by_shelves=UPDATE goblin_goods_sku SET shelves_status=?,shelves_at=?,updated_by=?,updated_at=? WHERE spu_id=? AND store_id=? AND sku_appear='0'
goblin_goods_sku.update_by_del_store=UPDATE goblin_goods_sku SET del_flg=1,updated_by=?,updated_at=?,deleted_by=?,deleted_at=? WHERE store_id=?
goblin_goods_sku.update_by_del=UPDATE goblin_goods_sku SET del_flg=1,updated_by=?,updated_at=?,deleted_by=?,deleted_at=? WHERE spu_id=? AND store_id=? goblin_goods_sku.update_by_del=UPDATE goblin_goods_sku SET del_flg=1,updated_by=?,updated_at=?,deleted_by=?,deleted_at=? WHERE spu_id=? AND store_id=?
goblin_goods_image.insert=INSERT INTO goblin_goods_image (spu_id,url)VALUES(?,?) goblin_goods_image.insert=INSERT INTO goblin_goods_image (spu_id,url)VALUES(?,?)
......
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