merge master
This commit is contained in:
commit
7dfffd60b8
@ -1,3 +1,6 @@
|
||||
## PS:数据库位置
|
||||
|
||||
点击跳转 https://gitee.com/beijing_hongye_huicheng/docker/tree/master/init/mysql 这里有与tag版本一致的sql,根据tag获取sql,如果使用master代码,则需要在lilishop项目根目录的update-sql目录中,获取对应的升级sql。
|
||||
|
||||
|
||||
使用master分支代码时,可能会无法运行,执行完初始化sql之后需要执行当前目录下'versiontXXXXtoMASTER.sql'。
|
@ -1,2 +0,0 @@
|
||||
/** 新增已退货数量 **/
|
||||
ALTER TABLE li_order_item ADD return_goods_number int DEFAULT 0 COMMENT '退货数量 ';
|
@ -1,3 +1,6 @@
|
||||
/** 新增已退货数量 **/
|
||||
ALTER TABLE li_order_item ADD return_goods_number int DEFAULT 0 COMMENT '退货数量 ';
|
||||
|
||||
|
||||
-- 促销重构sql
|
||||
ALTER TABLE li_coupon DROP COLUMN promotion_status;
|
@ -171,20 +171,20 @@ public class Goods extends BaseEntity {
|
||||
//循环sku,判定sku是否有效
|
||||
for (Map<String, Object> sku : goodsOperationDTO.getSkuList()) {
|
||||
//判定参数不能为空
|
||||
if (sku.get("sn") == null) {
|
||||
if (!sku.containsKey("sn") || sku.get("sn") == null) {
|
||||
throw new ServiceException(ResultCode.GOODS_SKU_SN_ERROR);
|
||||
}
|
||||
if (StringUtil.isEmpty(sku.get("price").toString()) || Convert.toDouble(sku.get("price")) <= 0) {
|
||||
if (!sku.containsKey("price") || StringUtil.isEmpty(sku.get("price").toString()) || Convert.toDouble(sku.get("price")) <= 0) {
|
||||
throw new ServiceException(ResultCode.GOODS_SKU_PRICE_ERROR);
|
||||
}
|
||||
if (StringUtil.isEmpty(sku.get("cost").toString()) || Convert.toDouble(sku.get("cost")) <= 0) {
|
||||
if (!sku.containsKey("cost") || StringUtil.isEmpty(sku.get("cost").toString()) || Convert.toDouble(sku.get("cost")) <= 0) {
|
||||
throw new ServiceException(ResultCode.GOODS_SKU_COST_ERROR);
|
||||
}
|
||||
//虚拟商品没有重量字段
|
||||
if (sku.containsKey("weight") && (StringUtil.isEmpty(sku.get("weight").toString()) || Convert.toDouble(sku.get("weight").toString()) < 0)) {
|
||||
if (!sku.containsKey("weight") || sku.containsKey("weight") && (StringUtil.isEmpty(sku.get("weight").toString()) || Convert.toDouble(sku.get("weight").toString()) < 0)) {
|
||||
throw new ServiceException(ResultCode.GOODS_SKU_WEIGHT_ERROR);
|
||||
}
|
||||
if (StringUtil.isEmpty(sku.get("quantity").toString()) || Convert.toInt(sku.get("quantity").toString()) < 0) {
|
||||
if (!sku.containsKey("quantity") || StringUtil.isEmpty(sku.get("quantity").toString()) || Convert.toInt(sku.get("quantity").toString()) < 0) {
|
||||
throw new ServiceException(ResultCode.GOODS_SKU_QUANTITY_ERROR);
|
||||
}
|
||||
|
||||
|
@ -112,6 +112,15 @@ public interface GoodsService extends IService<Goods> {
|
||||
*/
|
||||
Boolean updateGoodsMarketAble(List<String> goodsIds, GoodsStatusEnum goodsStatusEnum, String underReason);
|
||||
|
||||
/**
|
||||
* 更新商品上架状态状态
|
||||
*
|
||||
* @param goodsIds 商品ID集合
|
||||
* @param goodsStatusEnum 更新的商品状态
|
||||
* @param underReason 下架原因
|
||||
* @return 更新结果
|
||||
*/
|
||||
Boolean managerUpdateGoodsMarketAble(List<String> goodsIds, GoodsStatusEnum goodsStatusEnum, String underReason);
|
||||
/**
|
||||
* 删除商品
|
||||
*
|
||||
|
@ -307,6 +307,34 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean managerUpdateGoodsMarketAble(List<String> goodsIds, GoodsStatusEnum goodsStatusEnum, String underReason) {
|
||||
boolean result;
|
||||
|
||||
//如果商品为空,直接返回
|
||||
if (goodsIds == null || goodsIds.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
//检测管理员权限
|
||||
this.checkManagerAuthority();
|
||||
|
||||
LambdaUpdateWrapper<Goods> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
updateWrapper.set(Goods::getMarketEnable, goodsStatusEnum.name());
|
||||
updateWrapper.set(Goods::getUnderMessage, underReason);
|
||||
updateWrapper.in(Goods::getId, goodsIds);
|
||||
result = this.update(updateWrapper);
|
||||
|
||||
//修改规格商品
|
||||
LambdaQueryWrapper<Goods> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.in(Goods::getId, goodsIds);
|
||||
List<Goods> goodsList = this.list(queryWrapper);
|
||||
for (Goods goods : goodsList) {
|
||||
goodsSkuService.updateGoodsSkuStatus(goods);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean deleteGoods(List<String> goodsIds) {
|
||||
|
||||
@ -484,6 +512,20 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
||||
return goods;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取UpdateWrapper(检查用户越权)
|
||||
*
|
||||
* @return updateWrapper
|
||||
*/
|
||||
private LambdaUpdateWrapper<Goods> getUpdateWrapperByStoreAuthority() {
|
||||
LambdaUpdateWrapper<Goods> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
AuthUser authUser = this.checkStoreAuthority();
|
||||
updateWrapper.eq(Goods::getStoreId, authUser.getStoreId());
|
||||
return updateWrapper;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 检查当前登录的店铺
|
||||
*
|
||||
@ -498,17 +540,30 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查当前登录的店铺
|
||||
*
|
||||
* @return 当前登录的店铺
|
||||
*/
|
||||
private AuthUser checkManagerAuthority() {
|
||||
AuthUser currentUser = UserContext.getCurrentUser();
|
||||
//如果当前会员不为空,且为店铺角色
|
||||
if (currentUser != null && (currentUser.getRole().equals(UserEnums.MANAGER))) {
|
||||
return currentUser;
|
||||
} else {
|
||||
throw new ServiceException(ResultCode.USER_AUTHORITY_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取UpdateWrapper(检查用户越权)
|
||||
*
|
||||
* @return updateWrapper
|
||||
*/
|
||||
private LambdaUpdateWrapper<Goods> getUpdateWrapperByStoreAuthority() {
|
||||
private LambdaUpdateWrapper<Goods> getUpdateWrapperByManagerAuthority() {
|
||||
LambdaUpdateWrapper<Goods> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
AuthUser authUser = this.checkStoreAuthority();
|
||||
if (authUser != null) {
|
||||
updateWrapper.eq(Goods::getStoreId, authUser.getStoreId());
|
||||
}
|
||||
updateWrapper.eq(Goods::getStoreId, authUser.getStoreId());
|
||||
return updateWrapper;
|
||||
}
|
||||
|
||||
@ -520,9 +575,7 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
||||
private LambdaQueryWrapper<Goods> getQueryWrapperByStoreAuthority() {
|
||||
LambdaQueryWrapper<Goods> queryWrapper = new LambdaQueryWrapper<>();
|
||||
AuthUser authUser = this.checkStoreAuthority();
|
||||
if (authUser != null) {
|
||||
queryWrapper.eq(Goods::getStoreId, authUser.getStoreId());
|
||||
}
|
||||
queryWrapper.eq(Goods::getStoreId, authUser.getStoreId());
|
||||
return queryWrapper;
|
||||
}
|
||||
|
||||
|
@ -291,6 +291,9 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements
|
||||
@Override
|
||||
public void initIndex(List<EsGoodsIndex> goodsIndexList) {
|
||||
if (goodsIndexList == null || goodsIndexList.isEmpty()) {
|
||||
//初始化标识
|
||||
cache.put(CachePrefix.INIT_INDEX_PROCESS.getPrefix(), null);
|
||||
cache.put(CachePrefix.INIT_INDEX_FLAG.getPrefix(), false);
|
||||
return;
|
||||
}
|
||||
//索引名称拼接
|
||||
|
@ -155,7 +155,7 @@ public class SmsUtilAliImplService implements SmsUtil, AliSmsUtil {
|
||||
try {
|
||||
SendSmsResponse response = client.sendSms(sendSmsRequest);
|
||||
} catch (Exception e) {
|
||||
log.error("发送短信错误",e);
|
||||
log.error("发送短信错误", e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -191,7 +191,7 @@ public class SmsUtilAliImplService implements SmsUtil, AliSmsUtil {
|
||||
try {
|
||||
client.sendBatchSms(sendBatchSmsRequest);
|
||||
} catch (Exception e) {
|
||||
log.error("批量发送短信错误",e);
|
||||
log.error("批量发送短信错误", e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -363,7 +363,7 @@ public class SmsUtilAliImplService implements SmsUtil, AliSmsUtil {
|
||||
config.endpoint = "dysmsapi.aliyuncs.com";
|
||||
return new com.aliyun.dysmsapi20170525.Client(config);
|
||||
} catch (Exception e) {
|
||||
log.error("短信初始化错误",e);
|
||||
log.error("短信初始化错误", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -377,6 +377,6 @@ public class SmsUtilAliImplService implements SmsUtil, AliSmsUtil {
|
||||
* @return
|
||||
*/
|
||||
static String cacheKey(VerificationEnums verificationEnums, String mobile, String uuid) {
|
||||
return CachePrefix.SMS_CODE.getPrefix() + verificationEnums.name() + mobile;
|
||||
return CachePrefix.SMS_CODE.getPrefix() + verificationEnums.name() + uuid + mobile;
|
||||
}
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ public class GoodsManagerController {
|
||||
@PutMapping(value = "/{goodsId}/under")
|
||||
public ResultMessage<Object> underGoods(@PathVariable String goodsId, @NotEmpty(message = "下架原因不能为空") @RequestParam String reason) {
|
||||
List<String> goodsIds = Arrays.asList(goodsId.split(","));
|
||||
if (Boolean.TRUE.equals(goodsService.updateGoodsMarketAble(goodsIds, GoodsStatusEnum.DOWN, reason))) {
|
||||
if (Boolean.TRUE.equals(goodsService.managerUpdateGoodsMarketAble(goodsIds, GoodsStatusEnum.DOWN, reason))) {
|
||||
return ResultUtil.success();
|
||||
}
|
||||
throw new ServiceException(ResultCode.GOODS_UNDER_ERROR);
|
||||
|
Loading…
x
Reference in New Issue
Block a user