Merge branch 'master' into qiuqiu

This commit is contained in:
pikachu 2021-07-01 18:42:38 +08:00
commit f9662bd61a
98 changed files with 652 additions and 625 deletions

View File

@ -6,7 +6,7 @@
<parent> <parent>
<groupId>cn.lili</groupId> <groupId>cn.lili</groupId>
<artifactId>lili-shop-parent</artifactId> <artifactId>lili-shop-parent</artifactId>
<version>1.0.1</version> <version>4.2.0</version>
</parent> </parent>
<artifactId>admin</artifactId> <artifactId>admin</artifactId>

View File

@ -10,14 +10,14 @@
<parent> <parent>
<groupId>cn.lili</groupId> <groupId>cn.lili</groupId>
<artifactId>lili-shop-parent</artifactId> <artifactId>lili-shop-parent</artifactId>
<version>1.0.1</version> <version>4.2.0</version>
</parent> </parent>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>cn.lili</groupId> <groupId>cn.lili</groupId>
<artifactId>framework</artifactId> <artifactId>framework</artifactId>
<version>1.0.1</version> <version>4.2.0</version>
</dependency> </dependency>
<dependency> <dependency>

View File

@ -5,6 +5,7 @@ import cn.lili.common.security.context.UserContext;
import cn.lili.common.vo.ResultMessage; import cn.lili.common.vo.ResultMessage;
import cn.lili.modules.distribution.entity.dos.Distribution; import cn.lili.modules.distribution.entity.dos.Distribution;
import cn.lili.modules.distribution.entity.dos.DistributionOrder; import cn.lili.modules.distribution.entity.dos.DistributionOrder;
import cn.lili.modules.distribution.entity.dto.DistributionApplyDTO;
import cn.lili.modules.distribution.entity.vos.DistributionOrderSearchParams; import cn.lili.modules.distribution.entity.vos.DistributionOrderSearchParams;
import cn.lili.modules.distribution.service.DistributionOrderService; import cn.lili.modules.distribution.service.DistributionOrderService;
import cn.lili.modules.distribution.service.DistributionService; import cn.lili.modules.distribution.service.DistributionService;
@ -41,19 +42,15 @@ public class DistributionBuyerController {
//申请分销员 //申请分销员
@ApiOperation(value = "申请分销员") @ApiOperation(value = "申请分销员")
@ApiImplicitParams({
@ApiImplicitParam(name = "name", value = "姓名", required = true, paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "idNumber", value = "身份证号", required = true, paramType = "query", dataType = "String")
})
@PostMapping @PostMapping
public ResultMessage<Object> applyDistribution(@RequestParam String name, @RequestParam String idNumber) { public ResultMessage<Object> applyDistribution(DistributionApplyDTO distributionApplyDTO) {
return ResultUtil.data(distributionService.applyDistribution(name, idNumber)); return ResultUtil.data(distributionService.applyDistribution(distributionApplyDTO));
} }
@ApiOperation(value = "获取分销员分页订单列表") @ApiOperation(value = "获取分销员分页订单列表")
@GetMapping("/distributionOrder") @GetMapping("/distributionOrder")
public ResultMessage<IPage<DistributionOrder>> distributionOrderPage(DistributionOrderSearchParams distributionOrderSearchParams) { public ResultMessage<IPage<DistributionOrder>> distributionOrderPage(DistributionOrderSearchParams distributionOrderSearchParams) {
distributionOrderSearchParams.setDistributionId(UserContext.getCurrentUser().getId()); distributionOrderSearchParams.setDistributionId(distributionService.getDistribution().getId());
return ResultUtil.data(distributionOrderService.getDistributionOrderPage(distributionOrderSearchParams)); return ResultUtil.data(distributionOrderService.getDistributionOrderPage(distributionOrderSearchParams));
} }

View File

@ -11,6 +11,7 @@ import cn.lili.modules.distribution.service.DistributionSelectedGoodsService;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
@ -50,13 +51,25 @@ public class DistributionGoodsBuyerController {
} }
@ApiOperation(value = "选择分销商品") @ApiOperation(value = "选择分销商品")
@ApiImplicitParam(name = "distributionGoodsId", value = "分销ID", required = true, dataType = "String", paramType = "path") @ApiImplicitParams({
@ApiImplicitParam(name = "distributionGoodsId", value = "分销ID", required = true, dataType = "String", paramType = "path"),
@ApiImplicitParam(name = "checked", value = "是否选择", required = true, dataType = "boolean", paramType = "query")
})
@GetMapping(value = "/checked/{distributionGoodsId}") @GetMapping(value = "/checked/{distributionGoodsId}")
public ResultMessage<Object> distributionCheckGoods( public ResultMessage<Object> distributionCheckGoods(
@NotNull(message = "分销商品不能为空") @PathVariable("distributionGoodsId") String distributionGoodsId) { @NotNull(message = "分销商品不能为空") @PathVariable("distributionGoodsId") String distributionGoodsId,Boolean checked) {
if(distributionSelectedGoodsService.add(distributionGoodsId)){ Boolean result=false;
return ResultUtil.success(); if(checked){
result=distributionSelectedGoodsService.add(distributionGoodsId);
}else {
result=distributionSelectedGoodsService.delete(distributionGoodsId);
} }
throw new ServiceException(ResultCode.ERROR); //判断操作结果
if(result){
return ResultUtil.success(ResultCode.SUCCESS);
}else{
throw new ServiceException(ResultCode.ERROR);
}
} }
} }

View File

@ -66,7 +66,7 @@ public class MemberBuyerController {
if (smsUtil.verifyCode(mobile, VerificationEnums.LOGIN, uuid, code)) { if (smsUtil.verifyCode(mobile, VerificationEnums.LOGIN, uuid, code)) {
return ResultUtil.data(memberService.mobilePhoneLogin(mobile)); return ResultUtil.data(memberService.mobilePhoneLogin(mobile));
} else { } else {
throw new ServiceException("验证码错误"); throw new ServiceException(ResultCode.VERIFICATION_SMS_ERROR);
} }
} }

View File

@ -7,7 +7,7 @@
<parent> <parent>
<groupId>cn.lili</groupId> <groupId>cn.lili</groupId>
<artifactId>lili-shop-parent</artifactId> <artifactId>lili-shop-parent</artifactId>
<version>1.0.1</version> <version>4.2.0</version>
</parent> </parent>
<groupId>cn.lili</groupId> <groupId>cn.lili</groupId>
@ -17,7 +17,7 @@
<dependency> <dependency>
<groupId>cn.lili</groupId> <groupId>cn.lili</groupId>
<artifactId>framework</artifactId> <artifactId>framework</artifactId>
<version>1.0.1</version> <version>4.2.0</version>
</dependency> </dependency>
</dependencies> </dependencies>

View File

@ -100,7 +100,7 @@ public class UploadController {
fileService.save(newFile); fileService.save(newFile);
} catch (Exception e) { } catch (Exception e) {
log.error("文件上传失败", e); log.error("文件上传失败", e);
throw new ServiceException(ResultCode.OSS_EXCEPTION); throw new ServiceException(ResultCode.OSS_EXCEPTION_ERROR);
} }
return ResultUtil.data(result); return ResultUtil.data(result);
} }

View File

@ -77,7 +77,7 @@ spring:
default-datasource: default-datasource:
type: com.alibaba.druid.pool.DruidDataSource type: com.alibaba.druid.pool.DruidDataSource
driverClassName: com.mysql.cj.jdbc.Driver driverClassName: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://192.168.0.116:3306/Bulbasaur?useUnicode=true&characterEncoding=utf-8&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai url: jdbc:mysql://192.168.0.116:3306/lilishop?useUnicode=true&characterEncoding=utf-8&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
username: root username: root
password: lilishop password: lilishop
maxActive: 20 maxActive: 20
@ -194,9 +194,9 @@ logging:
# 输出级别 # 输出级别
level: level:
cn.lili: info cn.lili: info
# org.hibernate: debug org.hibernate: debug
# org.springframework: debug org.springframework: debug
# org.springframework.data.mongodb.core: debug org.springframework.data.mongodb.core: debug
file: file:
# 指定路径 # 指定路径
path: lili-logs path: lili-logs

View File

@ -8,14 +8,14 @@
<parent> <parent>
<groupId>cn.lili</groupId> <groupId>cn.lili</groupId>
<artifactId>lili-shop-parent</artifactId> <artifactId>lili-shop-parent</artifactId>
<version>1.0.1</version> <version>4.2.0</version>
</parent> </parent>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>cn.lili</groupId> <groupId>cn.lili</groupId>
<artifactId>framework</artifactId> <artifactId>framework</artifactId>
<version>1.0.1</version> <version>4.2.0</version>
</dependency> </dependency>
<dependency> <dependency>

View File

@ -59,7 +59,7 @@ public class NoticeMessageExecute implements TradeEvent, OrderStatusChangeEvent,
//如果订单状态不为空 //如果订单状态不为空
if (orderDetailVO != null) { if (orderDetailVO != null) {
Map<String, String> params = new HashMap<>(); Map<String, String> params = new HashMap<>();
switch (orderMessage.getNewStatus()){ switch (orderMessage.getNewStatus()) {
//如果订单新的状态为已取消 则发送取消订单站内信 //如果订单新的状态为已取消 则发送取消订单站内信
case CANCELLED: case CANCELLED:
params.put(NoticeMessageParameterEnum.CANCEL_REASON.getType(), orderDetailVO.getOrder().getCancelReason()); params.put(NoticeMessageParameterEnum.CANCEL_REASON.getType(), orderDetailVO.getOrder().getCancelReason());
@ -82,7 +82,7 @@ public class NoticeMessageExecute implements TradeEvent, OrderStatusChangeEvent,
break; break;
//如果是拼团订单发送拼团成功消息 //如果是拼团订单发送拼团成功消息
case UNDELIVERED: case UNDELIVERED:
if(orderDetailVO.getOrder().getOrderPromotionType().equals(OrderPromotionTypeEnum.PINTUAN.name())){ if (OrderPromotionTypeEnum.PINTUAN.name().equals(orderDetailVO.getOrder().getOrderPromotionType())) {
//拼团成功消息 //拼团成功消息
noticeMessageDTO.setNoticeMessageNodeEnum(NoticeMessageNodeEnum.PINTUAN_SUCCESS); noticeMessageDTO.setNoticeMessageNodeEnum(NoticeMessageNodeEnum.PINTUAN_SUCCESS);
} }
@ -148,11 +148,14 @@ public class NoticeMessageExecute implements TradeEvent, OrderStatusChangeEvent,
@Override @Override
public void memberPointChange(MemberPointMessage memberPointMessage) { public void memberPointChange(MemberPointMessage memberPointMessage) {
if (memberPointMessage == null) {
return;
}
//组织站内信参数 //组织站内信参数
NoticeMessageDTO noticeMessageDTO = new NoticeMessageDTO(); NoticeMessageDTO noticeMessageDTO = new NoticeMessageDTO();
noticeMessageDTO.setMemberId(memberPointMessage.getMemberId()); noticeMessageDTO.setMemberId(memberPointMessage.getMemberId());
Map<String, String> params = new HashMap<>(); Map<String, String> params = new HashMap<>();
if (memberPointMessage.getType().equals(1)) { if (memberPointMessage.getType()) {
params.put("expenditure_points", "0"); params.put("expenditure_points", "0");
params.put("income_points", memberPointMessage.getPoint().toString()); params.put("income_points", memberPointMessage.getPoint().toString());
} else { } else {

View File

@ -1,5 +1,6 @@
package cn.lili.event.impl; package cn.lili.event.impl;
import cn.hutool.core.convert.Convert;
import cn.lili.common.cache.Cache; import cn.lili.common.cache.Cache;
import cn.lili.event.OrderStatusChangeEvent; import cn.lili.event.OrderStatusChangeEvent;
import cn.lili.modules.goods.entity.dos.GoodsSku; import cn.lili.modules.goods.entity.dos.GoodsSku;
@ -188,7 +189,7 @@ public class StockUpdateExecute implements OrderStatusChangeEvent {
List skuStocks = cache.multiGet(skuKeys); List skuStocks = cache.multiGet(skuKeys);
//循环写入商品库存 //循环写入商品库存
for (int i = 0; i < skuStocks.size(); i++) { for (int i = 0; i < skuStocks.size(); i++) {
goodsSkus.get(i).setQuantity(Integer.parseInt(skuStocks.get(i).toString())); goodsSkus.get(i).setQuantity(Convert.toInt(skuStocks.get(i).toString()));
} }
//批量修改商品库存 //批量修改商品库存
goodsSkuService.updateBatchById(goodsSkus); goodsSkuService.updateBatchById(goodsSkus);
@ -197,7 +198,7 @@ public class StockUpdateExecute implements OrderStatusChangeEvent {
if (!promotionKey.isEmpty()) { if (!promotionKey.isEmpty()) {
List promotionStocks = cache.multiGet(promotionKey); List promotionStocks = cache.multiGet(promotionKey);
for (int i = 0; i < promotionKey.size(); i++) { for (int i = 0; i < promotionKey.size(); i++) {
promotionGoods.get(i).setQuantity(Integer.parseInt(promotionStocks.get(i).toString())); promotionGoods.get(i).setQuantity(Convert.toInt(promotionStocks.get(i).toString()));
Integer num = promotionGoods.get(i).getNum(); Integer num = promotionGoods.get(i).getNum();
promotionGoods.get(i).setNum((num != null ? num : 0) + order.getOrder().getGoodsNum()); promotionGoods.get(i).setNum((num != null ? num : 0) + order.getOrder().getGoodsNum());
} }
@ -232,7 +233,7 @@ public class StockUpdateExecute implements OrderStatusChangeEvent {
List skuStocks = cache.multiGet(skuKeys); List skuStocks = cache.multiGet(skuKeys);
//循环写入商品SKU库存 //循环写入商品SKU库存
for (int i = 0; i < skuStocks.size(); i++) { for (int i = 0; i < skuStocks.size(); i++) {
goodsSkus.get(i).setQuantity(Integer.parseInt(skuStocks.get(i).toString())); goodsSkus.get(i).setQuantity(Convert.toInt(skuStocks.get(i).toString()));
} }
log.info("订单取消,库存还原:{}", goodsSkus); log.info("订单取消,库存还原:{}", goodsSkus);
//批量修改商品库存 //批量修改商品库存

View File

@ -3,6 +3,10 @@ package cn.lili.listener;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import cn.lili.common.rocketmq.tags.GoodsTagsEnum; import cn.lili.common.rocketmq.tags.GoodsTagsEnum;
import cn.lili.event.GoodsCommentCompleteEvent; import cn.lili.event.GoodsCommentCompleteEvent;
import cn.lili.modules.distribution.entity.dos.DistributionGoods;
import cn.lili.modules.distribution.entity.dos.DistributionSelectedGoods;
import cn.lili.modules.distribution.service.DistributionGoodsService;
import cn.lili.modules.distribution.service.DistributionSelectedGoodsService;
import cn.lili.modules.goods.entity.dos.Goods; import cn.lili.modules.goods.entity.dos.Goods;
import cn.lili.modules.goods.entity.dos.GoodsSku; import cn.lili.modules.goods.entity.dos.GoodsSku;
import cn.lili.modules.goods.entity.dto.GoodsCompleteMessage; import cn.lili.modules.goods.entity.dto.GoodsCompleteMessage;
@ -15,6 +19,8 @@ import cn.lili.modules.member.service.GoodsCollectionService;
import cn.lili.modules.search.entity.dos.EsGoodsIndex; import cn.lili.modules.search.entity.dos.EsGoodsIndex;
import cn.lili.modules.search.service.EsGoodsIndexService; import cn.lili.modules.search.service.EsGoodsIndexService;
import cn.lili.modules.store.service.StoreService; import cn.lili.modules.store.service.StoreService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.common.message.MessageExt; import org.apache.rocketmq.common.message.MessageExt;
@ -57,6 +63,13 @@ public class GoodsMessageListener implements RocketMQListener<MessageExt> {
//商品评价 //商品评价
@Autowired @Autowired
private List<GoodsCommentCompleteEvent> goodsCommentCompleteEvents; private List<GoodsCommentCompleteEvent> goodsCommentCompleteEvents;
//分销商品
@Autowired
private DistributionGoodsService distributionGoodsService;
//分销员-商品关联表
@Autowired
private DistributionSelectedGoodsService distributionSelectedGoodsService;
@Override @Override
public void onMessage(MessageExt messageExt) { public void onMessage(MessageExt messageExt) {
@ -77,9 +90,10 @@ public class GoodsMessageListener implements RocketMQListener<MessageExt> {
break; break;
//审核商品 //审核商品
case GOODS_AUDIT: case GOODS_AUDIT:
break;
//删除商品 //删除商品
case GOODS_DELETE: case GOODS_DELETE:
storeService.updateStoreGoodsNum(new String(messageExt.getBody())); deleteGoods(messageExt);
break; break;
//规格删除 //规格删除
case SKU_DELETE: case SKU_DELETE:
@ -107,38 +121,72 @@ public class GoodsMessageListener implements RocketMQListener<MessageExt> {
break; break;
//购买商品完成 //购买商品完成
case BUY_GOODS_COMPLETE: case BUY_GOODS_COMPLETE:
String goodsCompleteMessageStr = new String(messageExt.getBody()); this.goodsBuyComplete(messageExt);
List<GoodsCompleteMessage> goodsCompleteMessageList = JSONUtil.toList(JSONUtil.parseArray(goodsCompleteMessageStr), GoodsCompleteMessage.class);
for (GoodsCompleteMessage goodsCompleteMessage : goodsCompleteMessageList) {
Goods goods = goodsService.getById(goodsCompleteMessage.getGoodsId());
if (goods != null) {
//更新商品购买数量
if (goods.getBuyCount() == null) {
goods.setBuyCount(0);
}
int buyCount = goods.getBuyCount() + goodsCompleteMessage.getBuyNum();
LambdaUpdateWrapper<Goods> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.eq(Goods::getId, goodsCompleteMessage.getGoodsId());
updateWrapper.set(Goods::getBuyCount, buyCount);
goodsService.update(updateWrapper);
} else {
log.error("商品Id为[" + goodsCompleteMessage.getGoodsId() + "的商品不存在,更新商品失败!");
}
GoodsSku goodsSku = goodsSkuService.getById(goodsCompleteMessage.getSkuId());
if (goodsSku != null) {
//更新商品购买数量
if (goodsSku.getBuyCount() == null) {
goodsSku.setBuyCount(0);
}
int buyCount = goodsSku.getBuyCount() + goodsCompleteMessage.getBuyNum();
goodsSku.setBuyCount(buyCount);
goodsSkuService.update(goodsSku);
goodsIndexService.updateIndexBuyNum(goodsCompleteMessage.getSkuId(), buyCount);
} else {
log.error("商品SkuId为[" + goodsCompleteMessage.getGoodsId() + "的商品不存在,更新商品失败!");
}
}
break; break;
} }
} }
/**
* 删除商品
* 1.更新店铺的商品数量
* 2.删除分销员-分销商品绑定关系
* 3.删除分销商品
* @param messageExt 消息
*/
private void deleteGoods(MessageExt messageExt){
Goods goods=JSONUtil.toBean(new String(messageExt.getBody()),Goods.class);
//更新店铺商品数量
storeService.updateStoreGoodsNum(goods.getStoreId());
//删除获取分销商品
DistributionGoods distributionGoods=distributionGoodsService.getOne(new LambdaQueryWrapper<DistributionGoods>()
.eq(DistributionGoods::getGoodsId,goods.getId()));
//删除分销商品绑定关系
distributionSelectedGoodsService.remove(new LambdaQueryWrapper<DistributionSelectedGoods>()
.eq(DistributionSelectedGoods::getDistributionGoodsId,distributionGoods.getId()));
//删除分销商品
distributionGoodsService.removeById(distributionGoods.getId());
}
/**
* 商品购买完成
* 1.更新商品购买数量
* 2.更新SKU购买数量
* 3.更新索引购买数量
* @param messageExt
*/
private void goodsBuyComplete(MessageExt messageExt){
String goodsCompleteMessageStr = new String(messageExt.getBody());
List<GoodsCompleteMessage> goodsCompleteMessageList = JSONUtil.toList(JSONUtil.parseArray(goodsCompleteMessageStr), GoodsCompleteMessage.class);
for (GoodsCompleteMessage goodsCompleteMessage : goodsCompleteMessageList) {
Goods goods = goodsService.getById(goodsCompleteMessage.getGoodsId());
if (goods != null) {
//更新商品购买数量
if (goods.getBuyCount() == null) {
goods.setBuyCount(0);
}
int buyCount = goods.getBuyCount() + goodsCompleteMessage.getBuyNum();
goodsService.update(new LambdaUpdateWrapper<Goods>()
.eq(Goods::getId, goodsCompleteMessage.getGoodsId())
.set(Goods::getBuyCount, buyCount));
} else {
log.error("商品Id为[" + goodsCompleteMessage.getGoodsId() + "的商品不存在,更新商品失败!");
}
GoodsSku goodsSku = goodsSkuService.getById(goodsCompleteMessage.getSkuId());
if (goodsSku != null) {
//更新商品购买数量
if (goodsSku.getBuyCount() == null) {
goodsSku.setBuyCount(0);
}
int buyCount = goodsSku.getBuyCount() + goodsCompleteMessage.getBuyNum();
goodsSku.setBuyCount(buyCount);
goodsSkuService.update(goodsSku);
goodsIndexService.updateIndexBuyNum(goodsCompleteMessage.getSkuId(), buyCount);
} else {
log.error("商品SkuId为[" + goodsCompleteMessage.getGoodsId() + "的商品不存在,更新商品失败!");
}
}
}
} }

View File

@ -1,5 +1,6 @@
package cn.lili.timetask.handler.impl.goods; package cn.lili.timetask.handler.impl.goods;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.lili.modules.goods.mapper.GoodsMapper; import cn.lili.modules.goods.mapper.GoodsMapper;
@ -40,7 +41,7 @@ public class GoodsExecute implements EveryDayExecute {
.between("create_time", DateUtil.yesterday(), new DateTime())); .between("create_time", DateUtil.yesterday(), new DateTime()));
for (Map<String, Object> map : list) { for (Map<String, Object> map : list) {
goodsMapper.addGoodsCommentNum(Integer.parseInt(map.get("num").toString()), map.get("goods_id").toString()); goodsMapper.addGoodsCommentNum(Convert.toInt(map.get("num").toString()), map.get("goods_id").toString());
} }
} }

View File

@ -3,6 +3,7 @@ package cn.lili.timetask.handler.impl.order;
import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import cn.lili.common.enums.ResultCode;
import cn.lili.common.exception.ServiceException; import cn.lili.common.exception.ServiceException;
import cn.lili.modules.member.entity.dto.MemberEvaluationDTO; import cn.lili.modules.member.entity.dto.MemberEvaluationDTO;
import cn.lili.modules.member.entity.enums.EvaluationGradeEnum; import cn.lili.modules.member.entity.enums.EvaluationGradeEnum;
@ -58,7 +59,7 @@ public class OrderEveryDayTaskExecute implements EveryDayExecute {
//自动确认收货 //自动确认收货
OrderSetting orderSetting = JSONUtil.toBean(setting.getSettingValue(), OrderSetting.class); OrderSetting orderSetting = JSONUtil.toBean(setting.getSettingValue(), OrderSetting.class);
if (orderSetting == null) { if (orderSetting == null) {
throw new ServiceException("系统配置异常"); throw new ServiceException(ResultCode.ORDER_SETTING_ERROR);
} }
//自动确认收货 //自动确认收货

View File

@ -1,5 +1,6 @@
package cn.lili.timetask.handler.impl.view; package cn.lili.timetask.handler.impl.view;
import cn.hutool.core.convert.Convert;
import cn.lili.common.cache.Cache; import cn.lili.common.cache.Cache;
import cn.lili.common.cache.CachePrefix; import cn.lili.common.cache.CachePrefix;
import cn.lili.common.utils.BeanUtil; import cn.lili.common.utils.BeanUtil;
@ -167,15 +168,15 @@ class PageViewStatistics {
//将字符串解析成需要的对象 //将字符串解析成需要的对象
str = str.substring(str.indexOf("}") + 2); str = str.substring(str.indexOf("}") + 2);
String[] dateStr = str.split("-"); String[] dateStr = str.split("-");
Integer year = Integer.parseInt(dateStr[0]); Integer year = Convert.toInt(dateStr[0]);
Integer month = Integer.parseInt(dateStr[1]); Integer month = Convert.toInt(dateStr[1]);
Integer day; Integer day;
//是否有店铺id //是否有店铺id
if (dateStr.length > 3) { if (dateStr.length > 3) {
day = Integer.parseInt(dateStr[2]); day = Convert.toInt(dateStr[2]);
this.storeId = dateStr[3]; this.storeId = dateStr[3];
} else { } else {
day = Integer.parseInt(dateStr[2]); day = Convert.toInt(dateStr[2]);
} }
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.YEAR, year); calendar.set(Calendar.YEAR, year);

View File

@ -7,7 +7,7 @@
<parent> <parent>
<groupId>cn.lili</groupId> <groupId>cn.lili</groupId>
<artifactId>lili-shop-parent</artifactId> <artifactId>lili-shop-parent</artifactId>
<version>1.0.1</version> <version>4.2.0</version>
</parent> </parent>
<artifactId>framework</artifactId> <artifactId>framework</artifactId>

View File

@ -1,6 +1,7 @@
package cn.lili.common.aop.limiter; package cn.lili.common.aop.limiter;
import cn.lili.common.aop.limiter.annotation.LimitPoint; import cn.lili.common.aop.limiter.annotation.LimitPoint;
import cn.lili.common.enums.ResultCode;
import cn.lili.common.exception.ServiceException; import cn.lili.common.exception.ServiceException;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -60,7 +61,7 @@ public class LimitInterceptor {
log.info("限制请求{}, 当前请求{},缓存key{}", limitCount, count.intValue(), key); log.info("限制请求{}, 当前请求{},缓存key{}", limitCount, count.intValue(), key);
//如果缓存里没有值或者他的值小于限制频率 //如果缓存里没有值或者他的值小于限制频率
if (count.intValue() >= limitCount) { if (count.intValue() >= limitCount) {
throw new ServiceException("访问过于频繁,请稍后再试"); throw new ServiceException(ResultCode.LIMIT_ERROR);
} }
} }
//如果从redis中执行都值判定为空则这里跳过 //如果从redis中执行都值判定为空则这里跳过

View File

@ -32,9 +32,10 @@ public enum ResultCode {
/** /**
* 系统异常 * 系统异常
*/ */
WECHAT_CONNECT_NOT_EXIST(1001, "微信联合登录未配置"), WECHAT_CONNECT_NOT_EXIST(1001, "微信联合登录未配置"),
VERIFICATION_EXIST(1002, "验证码服务异常"), VERIFICATION_EXIST(1002, "验证码服务异常"),
LIMIT_ERROR(1003,"访问过于频繁,请稍后再试"),
ILLEGAL_REQUEST_ERROR(1004, "非法请求,请重新刷新页面操作"),
/** /**
* 分类 * 分类
*/ */
@ -47,6 +48,7 @@ public enum ResultCode {
CATEGORY_SAVE_ERROR(10007, "此类别下存在商品不能删除"), CATEGORY_SAVE_ERROR(10007, "此类别下存在商品不能删除"),
CATEGORY_PARAMETER_SAVE_ERROR(10008, "分类绑定参数组添加失败"), CATEGORY_PARAMETER_SAVE_ERROR(10008, "分类绑定参数组添加失败"),
CATEGORY_PARAMETER_UPDATE_ERROR(10009, "分类绑定参数组添加失败"), CATEGORY_PARAMETER_UPDATE_ERROR(10009, "分类绑定参数组添加失败"),
CATEGORY_DELETE_FLAG_ERROR(10010, "子类状态不能与父类不一致!"),
/** /**
* 商品 * 商品
@ -64,209 +66,159 @@ public enum ResultCode {
GOODS_SKU_WEIGHT_ERROR(11010, "商品重量不能为负数"), GOODS_SKU_WEIGHT_ERROR(11010, "商品重量不能为负数"),
GOODS_SKU_QUANTITY_ERROR(11011, "商品库存数量不能为负数"), GOODS_SKU_QUANTITY_ERROR(11011, "商品库存数量不能为负数"),
GOODS_SKU_QUANTITY_NOT_ENOUGH(11011, "商品库存不足"), GOODS_SKU_QUANTITY_NOT_ENOUGH(11011, "商品库存不足"),
MUST_HAVE_GOODS_SKU(11012,"规格必须要有一个!"),
GOODS_PARAMS_ERROR(11013,"商品参数错误,刷新后重试"),
PHYSICAL_GOODS_NEED_TEMP(11014,"实物商品需选择配送模板"),
VIRTUAL_GOODS_NOT_NEED_TEMP(11015,"实物商品需选择配送模板"),
GOODS_TYPE_ERROR(11016, "需选择商品类型"),
/** /**
* 参数 * 参数
*/ */
PARAMETER_SAVE_ERROR(12001, "参数添加失败"), PARAMETER_SAVE_ERROR(12001, "参数添加失败"),
PARAMETER_UPDATE_ERROR(12002, "参数编辑失败"), PARAMETER_UPDATE_ERROR(12002, "参数编辑失败"),
/** /**
* 规格 * 规格
*/ */
SPEC_SAVE_ERROR(13001, "规格修改失败"), SPEC_SAVE_ERROR(13001, "规格修改失败"),
SPEC_UPDATE_ERROR(13002, "规格修改失败"), SPEC_UPDATE_ERROR(13002, "规格修改失败"),
SPEC_DELETE_ERROR(13003, "此规格已绑定分类不允许删除"), SPEC_DELETE_ERROR(13003, "此规格已绑定分类不允许删除"),
/** /**
* 品牌 * 品牌
*/ */
BRAND_SAVE_ERROR(14001, "品牌添加失败"), BRAND_SAVE_ERROR(14001, "品牌添加失败"),
BRAND_UPDATE_ERROR(14002, "品牌修改失败"), BRAND_UPDATE_ERROR(14002, "品牌修改失败"),
BRAND_DISABLE_ERROR(14003, "品牌禁用失败"), BRAND_DISABLE_ERROR(14003, "品牌禁用失败"),
BRAND_DELETE_ERROR(14004, "品牌删除失败"), BRAND_DELETE_ERROR(14004, "品牌删除失败"),
BRAND_NAME_EXIST_ERROR(20002, "品牌名称重复!"),
BRAND_USE_DISABLE_ERROR(20003, "当前品牌下存在分类不可禁用"),
BRAND_NOT_EXIST(20004, "品牌不存在"),
/** /**
* 用户 * 用户
*/ */
USER_EDIT_SUCCESS(20001, "用户修改成功"), USER_EDIT_SUCCESS(20001, "用户修改成功"),
USER_NOT_EXIST(20002, "用户不存在"), USER_NOT_EXIST(20002, "用户不存在"),
USER_NOT_LOGIN(20003, "用户未登录"), USER_NOT_LOGIN(20003, "用户未登录"),
USER_AUTH_EXPIRED(20004, "用户已退出,请重新登录"), USER_AUTH_EXPIRED(20004, "用户已退出,请重新登录"),
USER_AUTHORITY_ERROR(20005, "权限不足"), USER_AUTHORITY_ERROR(20005, "权限不足"),
USER_CONNECT_LOGIN_ERROR(20006, "未找到登录信息"), USER_CONNECT_LOGIN_ERROR(20006, "未找到登录信息"),
USER_NAME_EXIST(20007, "该用户名已被注册"), USER_NAME_EXIST(20007, "该用户名已被注册"),
USER_PHONE_EXIST(20008, "该手机号已被注册"), USER_PHONE_EXIST(20008, "该手机号已被注册"),
USER_PHONE_NOT_EXIST(20009, "手机号不存在"), USER_PHONE_NOT_EXIST(20009, "手机号不存在"),
USER_PASSWORD_ERROR(20010, "密码不正确"), USER_PASSWORD_ERROR(20010, "密码不正确"),
USER_NOT_PHONE(20011, "非当前用户的手机号"), USER_NOT_PHONE(20011, "非当前用户的手机号"),
USER_CONNECT_ERROR(20012, "联合第三方登录,授权信息错误"), USER_CONNECT_ERROR(20012, "联合第三方登录,授权信息错误"),
USER_RECEIPT_REPEAT_ERROR(20013, "会员发票信息重复"), USER_RECEIPT_REPEAT_ERROR(20013, "会员发票信息重复"),
USER_RECEIPT_NOT_EXIST(20014, "会员发票信息不存在"), USER_RECEIPT_NOT_EXIST(20014, "会员发票信息不存在"),
USER_EDIT_ERROR(20015, "用户修改失败"), USER_EDIT_ERROR(20015, "用户修改失败"),
USER_OLD_PASSWORD_ERROR(20016, "旧密码不正确"), USER_OLD_PASSWORD_ERROR(20016, "旧密码不正确"),
USER_COLLECTION_EXIST(20017, "无法重复收藏"), USER_COLLECTION_EXIST(20017, "无法重复收藏"),
USER_GRADE_IS_DEFAULT(20018, "会员等级为默认会员等级"), USER_GRADE_IS_DEFAULT(20018, "会员等级为默认会员等级"),
DELETE_EXIST(20019, "无法重复收藏"),
DELETE_EXIST(2001, "无法重复收藏"), USER_NOT_BINDING(20020,"未绑定用户"),
USER_AUTO_REGISTER_ERROR(20021,"自动注册失败,请稍后重试"),
USER_OVERDUE_CONNECT_ERROR(20022,"授权信息已过期,请重新授权/登录"),
USER_CONNECT_BANDING_ERROR(20023,"当前联合登陆方式,已绑定其他账号,需进行解绑操作"),
USER_CONNECT_NOT_EXIST_ERROR(20024, "暂无联合登陆信息,无法实现一键注册功能,请点击第三方登录进行授权"),
/** /**
* 权限 * 权限
*/ */
PERMISSION_DEPARTMENT_ROLE_ERROR(21001, "角色已绑定部门,请逐个删除"), PERMISSION_DEPARTMENT_ROLE_ERROR(21001, "角色已绑定部门,请逐个删除"),
PERMISSION_USER_ROLE_ERROR(21002, "角色已绑定管理员,请逐个删除"), PERMISSION_USER_ROLE_ERROR(21002, "角色已绑定管理员,请逐个删除"),
PERMISSION_MENU_ROLE_ERROR(21003, "菜单已绑定角色,请先删除或编辑角色"), PERMISSION_MENU_ROLE_ERROR(21003, "菜单已绑定角色,请先删除或编辑角色"),
PERMISSION_DEPARTMENT_DELETE_ERROR(21004, "部门已经绑定管理员,请先删除或编辑管理员"), PERMISSION_DEPARTMENT_DELETE_ERROR(21004, "部门已经绑定管理员,请先删除或编辑管理员"),
PERMISSION_BEYOND_TEN(21005, "最多可以设置10个角色"), PERMISSION_BEYOND_TEN(21005, "最多可以设置10个角色"),
/** /**
* 分销 * 分销
*/ */
DISTRIBUTION_CLOSE(22000, "分销功能关闭"), DISTRIBUTION_CLOSE(22000, "分销功能关闭"),
DISTRIBUTION_NOT_EXIST(22001, "分销员不存在"), DISTRIBUTION_NOT_EXIST(22001, "分销员不存在"),
DISTRIBUTION_IS_APPLY(22002, "分销员已申请,无需重复提交"), DISTRIBUTION_IS_APPLY(22002, "分销员已申请,无需重复提交"),
DISTRIBUTION_AUDIT_ERROR(22003, "审核分销员失败"), DISTRIBUTION_AUDIT_ERROR(22003, "审核分销员失败"),
DISTRIBUTION_RETREAT_ERROR(22004, "分销员清退失败"), DISTRIBUTION_RETREAT_ERROR(22004, "分销员清退失败"),
DISTRIBUTION_CASH_NOT_EXIST(22005, "分销员提现记录不存在"), DISTRIBUTION_CASH_NOT_EXIST(22005, "分销员提现记录不存在"),
DISTRIBUTION_GOODS_DOUBLE(22006, "不能重复添加分销商品"), DISTRIBUTION_GOODS_DOUBLE(22006, "不能重复添加分销商品"),
/** /**
* 购物车 * 购物车
*/ */
CART_ERROR(30001, "读取结算页的购物车异常"), CART_ERROR(30001, "读取结算页的购物车异常"),
CART_PINTUAN_NOT_EXIST_ERROR(30002, "拼团活动不存在错误"), CART_PINTUAN_NOT_EXIST_ERROR(30002, "拼团活动不存在错误"),
CART_PINTUAN_LIMIT_ERROR(30003, "购买数量超过拼团活动限制数量"), CART_PINTUAN_LIMIT_ERROR(30003, "购买数量超过拼团活动限制数量"),
SHIPPING_NOT_APPLY(30005, "购物商品不支持当前收货地址配送"), SHIPPING_NOT_APPLY(30005, "购物商品不支持当前收货地址配送"),
/** /**
* 订单 * 订单
*/ */
ORDER_ERROR(31001, "创建订单异常,请稍后重试"), ORDER_ERROR(31001, "创建订单异常,请稍后重试"),
ORDER_NOT_EXIST(31002, "订单不存在"), ORDER_NOT_EXIST(31002, "订单不存在"),
ORDER_DELIVERED_ERROR(31003, "订单状态错误,无法进行确认收货"), ORDER_DELIVERED_ERROR(31003, "订单状态错误,无法进行确认收货"),
ORDER_UPDATE_PRICE_ERROR(31004, "已支付的订单不能修改金额"), ORDER_UPDATE_PRICE_ERROR(31004, "已支付的订单不能修改金额"),
ORDER_LOGISTICS_ERROR(31005, "物流错误"), ORDER_LOGISTICS_ERROR(31005, "物流错误"),
ORDER_DELIVER_ERROR(31006, "物流错误"), ORDER_DELIVER_ERROR(31006, "物流错误"),
ORDER_NOT_USER(31007, "非当前会员的订单"), ORDER_NOT_USER(31007, "非当前会员的订单"),
ORDER_TAKE_ERROR(31008, "当前订单无法核销"), ORDER_TAKE_ERROR(31008, "当前订单无法核销"),
MEMBER_ADDRESS_NOT_EXIST(31009, "订单无收货地址,请先配置收货地址"), MEMBER_ADDRESS_NOT_EXIST(31009, "订单无收货地址,请先配置收货地址"),
ORDER_DELIVER_NUM_ERROR(31010, "没有待发货的订单"), ORDER_DELIVER_NUM_ERROR(31010, "没有待发货的订单"),
ORDER_NOT_SUPPORT_DISTRIBUTION(31011, "购物车中包含不支持配送的商品,请重新选择收货地址,或者重新选择商品"), ORDER_NOT_SUPPORT_DISTRIBUTION(31011, "购物车中包含不支持配送的商品,请重新选择收货地址,或者重新选择商品"),
ORDER_CAN_NOT_CANCEL(31012, "当前订单状态不可取消"), ORDER_CAN_NOT_CANCEL(31012, "当前订单状态不可取消"),
ORDER_BATCH_DELIVER_ERROR(31013, "批量发货,文件读取失败"),
ORDER_ITEM_NOT_EXIST(31014, "当前订单项不存在!"),
/** /**
* 支付 * 支付
*/ */
PAY_UN_WANTED(32000, "当前订单不需要付款,返回订单列表等待系统订单出库即可"), PAY_UN_WANTED(32000, "当前订单不需要付款,返回订单列表等待系统订单出库即可"),
PAY_SUCCESS(32001, "支付成功"), PAY_SUCCESS(32001, "支付成功"),
PAY_INCONSISTENT_ERROR(32002, "付款金额和应付金额不一致"), PAY_INCONSISTENT_ERROR(32002, "付款金额和应付金额不一致"),
PAY_DOUBLE_ERROR(32003, "订单已支付,不能再次进行支付"), PAY_DOUBLE_ERROR(32003, "订单已支付,不能再次进行支付"),
PAY_CASHIER_ERROR(32004, "收银台信息获取错误"), PAY_CASHIER_ERROR(32004, "收银台信息获取错误"),
PAY_ERROR(32005, "支付业务异常,请稍后重试"), PAY_ERROR(32005, "支付业务异常,请稍后重试"),
PAY_BAN(32006, "当前订单不需要付款,请返回订单列表重新操作"), PAY_BAN(32006, "当前订单不需要付款,请返回订单列表重新操作"),
PAY_PARTIAL_ERROR(32007, "该订单已部分支付,请前往订单中心进行支付"), PAY_PARTIAL_ERROR(32007, "该订单已部分支付,请前往订单中心进行支付"),
PAY_NOT_SUPPORT(32008, "支付暂不支持"), PAY_NOT_SUPPORT(32008, "支付暂不支持"),
PAY_CLIENT_TYPE_ERROR(32009, "错误的客户端"), PAY_CLIENT_TYPE_ERROR(32009, "错误的客户端"),
PAY_POINT_ENOUGH(32010, "积分不足,不能兑换"), PAY_POINT_ENOUGH(32010, "积分不足,不能兑换"),
PAY_NOT_EXIST_ORDER(32011, "支付订单不存在"), PAY_NOT_EXIST_ORDER(32011, "支付订单不存在"),
CAN_NOT_RECHARGE_WALLET(32012, "不能使用余额进行充值"), CAN_NOT_RECHARGE_WALLET(32012, "不能使用余额进行充值"),
/** /**
* 售后 * 售后
*/ */
AFTER_SALES_NOT_PAY_ERROR(33001, "当前订单未支付,不能申请售后"), AFTER_SALES_NOT_PAY_ERROR(33001, "当前订单未支付,不能申请售后"),
AFTER_SALES_CANCEL_ERROR(33002, "当前售后单无法取消"), AFTER_SALES_CANCEL_ERROR(33002, "当前售后单无法取消"),
AFTER_SALES_BAN(33003, "订单状态不允许申请售后,请联系平台或商家"), AFTER_SALES_BAN(33003, "订单状态不允许申请售后,请联系平台或商家"),
AFTER_SALES_DOUBLE_ERROR(33004, "售后已审核,无法重复操作"), AFTER_SALES_DOUBLE_ERROR(33004, "售后已审核,无法重复操作"),
AFTER_SALES_LOGISTICS_ERROR(33005, "物流公司错误,请重新选择"), AFTER_SALES_LOGISTICS_ERROR(33005, "物流公司错误,请重新选择"),
AFTER_STATUS_ERROR(33006, "售后状态错误,请刷新页面"), AFTER_STATUS_ERROR(33006, "售后状态错误,请刷新页面"),
RETURN_MONEY_OFFLINE_BANK_ERROR(33007, "当账号类型为银行转账时,银行信息不能为空"),
/** /**
* 投诉 * 投诉
*/ */
COMPLAINT_ORDER_ITEM_EMPTY_ERROR(33100, "订单不存在"), COMPLAINT_ORDER_ITEM_EMPTY_ERROR(33100, "订单不存在"),
COMPLAINT_SKU_EMPTY_ERROR(33101, "商品已下架,如需投诉请联系平台客服"), COMPLAINT_SKU_EMPTY_ERROR(33101, "商品已下架,如需投诉请联系平台客服"),
COMPLAINT_ERROR(33102, "投诉异常,请稍后重试"), COMPLAINT_ERROR(33102, "投诉异常,请稍后重试"),
COMPLAINT_NOT_EXIT(33103, "当前投诉记录不存在"),
COMPLAINT_ARBITRATION_RESULT_ERROR(33104, "结束订单投诉时,仲裁结果不能为空"),
COMPLAINT_APPEAL_CONTENT_ERROR(33105, "商家申诉时,申诉内容不能为空"),
/** /**
* 余额 * 余额
*/ */
WALLET_NOT_EXIT_ERROR(34000, "钱包不存在,请联系管理员"), WALLET_NOT_EXIT_ERROR(34000, "钱包不存在,请联系管理员"),
WALLET_INSUFFICIENT(34001, "余额不足以支付订单,请充值!"), WALLET_INSUFFICIENT(34001, "余额不足以支付订单,请充值!"),
WALLET_WITHDRAWAL_INSUFFICIENT(34002, "可提现金额不足!"), WALLET_WITHDRAWAL_INSUFFICIENT(34002, "可提现金额不足!"),
WALLET_ERROR_INSUFFICIENT(34003, "零钱提现失败!"), WALLET_ERROR_INSUFFICIENT(34003, "零钱提现失败!"),
WALLET_REMARK_ERROR(34004, "请填写审核备注!"), WALLET_REMARK_ERROR(34004, "请填写审核备注!"),
WALLET_APPLY_ERROR(34005, "提现申请异常!"), WALLET_APPLY_ERROR(34005, "提现申请异常!"),
/** /**
@ -275,87 +227,125 @@ public enum ResultCode {
EVALUATION_DOUBLE_ERROR(35001, "无法重复提交评价"), EVALUATION_DOUBLE_ERROR(35001, "无法重复提交评价"),
/** /**
* 签到 * 活动
*/ */
MEMBER_SIGN_REPEAT(40001, "请勿重复签到"), PROMOTION_GOODS_NOT_EXIT(40001, "当前促销商品不存在!"),
PROMOTION_SAME_ACTIVE_EXIST(40002,"当前时间内已存在同类活动"),
PROMOTION_START_TIME_ERROR(40003,"活动起始时间不能大于活动结束时间"),
PROMOTION_TIME_ERROR(40004,"活动起始时间必须大于当前时间"),
PROMOTION_SAME_ERROR(40005,"当前时间段已存在相同活动!"),
PROMOTION_GOODS_ERROR(40006,"请选择要参与活动的商品"),
PROMOTION_STATUS_END(40007,"当前活动已停止"),
PROMOTION_UPDATE_ERROR(40008,"当前活动已开始/结束,无法编辑!"),
/** /**
* 优惠券 * 优惠券
*/ */
COUPON_EDIT_STATUS_SUCCESS(41001, "修改状态成功!"), COUPON_EDIT_STATUS_SUCCESS(41001, "修改状态成功!"),
COUPON_CANCELLATION_SUCCESS(41002, "会员优惠券作废成功"), COUPON_CANCELLATION_SUCCESS(41002, "会员优惠券作废成功"),
COUPON_EXPIRED(41003, "优惠券已使用/已过期,不能使用"), COUPON_EXPIRED(41003, "优惠券已使用/已过期,不能使用"),
COUPON_EDIT_STATUS_ERROR(41004, "优惠券修改状态失败!"), COUPON_EDIT_STATUS_ERROR(41004, "优惠券修改状态失败!"),
COUPON_RECEIVE_ERROR(41005, "当前优惠券状态不可领取"),
COUPON_NUM_INSUFFICIENT_ERROR(41006, "优惠券剩余领取数量不足"),
COUPON_NOT_EXIST(41007, "当前优惠券不存在"),
COUPON_LIMIT_NUM_LESS_THAN_0(41008, "领取限制数量不能为负数"),
COUPON_LIMIT_GREATER_THAN_PUBLISH(41009, "领取限制数量超出发行数量"),
COUPON_DISCOUNT_ERROR(41010, "优惠券折扣必须小于10且大于0"),
COUPON_SCOPE_TYPE_GOODS_ERROR(41011, "当前关联范围类型为指定商品时,商品列表不能为空"),
COUPON_SCOPE_TYPE_CATEGORY_ERROR(41012, "当前关联范围类型为部分商品分类时范围关联的id不能为空"),
COUPON_SCOPE_TYPE_STORE_ERROR(41013, "当前关联范围类型为部分店铺分类时范围关联的id不能为空"),
COUPON_SCOPE_ERROR(41014, "指定商品范围关联id无效"),
COUPON_MEMBER_NOT_EXIST(41015, "没有当前会员优惠券"),
COUPON_MEMBER_STATUS_ERROR(41016, "当前会员优惠券已过期/作废无法变更状态!"),
/** /**
* 拼团 * 拼团
*/ */
PINTUAN_MANUAL_OPEN_SUCCESS(42001, "手动开启拼团活动成功"), PINTUAN_MANUAL_OPEN_SUCCESS(42001, "手动开启拼团活动成功"),
PINTUAN_MANUAL_CLOSE_SUCCESS(42002, "手动关闭拼团活动成功"), PINTUAN_MANUAL_CLOSE_SUCCESS(42002, "手动关闭拼团活动成功"),
PINTUAN_ADD_SUCCESS(42003, "添加拼团活动成功"), PINTUAN_ADD_SUCCESS(42003, "添加拼团活动成功"),
PINTUAN_EDIT_SUCCESS(42004, "修改拼团活动成功"), PINTUAN_EDIT_SUCCESS(42004, "修改拼团活动成功"),
PINTUAN_DELETE_SUCCESS(42005, "删除拼团活动成功"), PINTUAN_DELETE_SUCCESS(42005, "删除拼团活动成功"),
PINTUAN_MANUAL_OPEN_ERROR(42006, "手动开启拼团活动失败"), PINTUAN_MANUAL_OPEN_ERROR(42006, "手动开启拼团活动失败"),
PINTUAN_MANUAL_CLOSE_ERROR(42007, "手动关闭拼团活动失败"), PINTUAN_MANUAL_CLOSE_ERROR(42007, "手动关闭拼团活动失败"),
PINTUAN_ADD_ERROR(42008, "添加拼团活动失败"), PINTUAN_ADD_ERROR(42008, "添加拼团活动失败"),
PINTUAN_EDIT_ERROR(42009, "修改拼团活动失败"), PINTUAN_EDIT_ERROR(42009, "修改拼团活动失败"),
PINTUAN_DELETE_ERROR(42010, "删除拼团活动失败"), PINTUAN_DELETE_ERROR(42010, "删除拼团活动失败"),
PINTUAN_JOIN_ERROR(42011, "不能参与自己发起的拼团活动!"),
PINTUAN_LIMIT_NUM_ERROR(42012, "购买数量超过拼团活动限制数量!"),
PINTUAN_NOT_EXIST_ERROR(42013,"当前拼团商品不存在!"),
/** /**
* 满额活动 * 满额活动
*/ */
FULL_DISCOUNT_EDIT_SUCCESS(43001, "修改满优惠活动成功"), FULL_DISCOUNT_EDIT_SUCCESS(43001, "修改满优惠活动成功"),
FULL_DISCOUNT_EDIT_DELETE(43002, "删除满优惠活动成功"), FULL_DISCOUNT_EDIT_DELETE(43002, "删除满优惠活动成功"),
FULL_DISCOUNT_MODIFY_ERROR(43003,"当前编辑的满优惠活动已经开始或者已经结束,无法修改"),
FULL_DISCOUNT_NOT_EXIST_ERROR(43004,"当前要操作的满优惠活动不存在!"),
FULL_DISCOUNT_WAY_ERROR(43005,"请选择一种优惠方式!"),
FULL_DISCOUNT_GIFT_ERROR(43006,"请选择赠品!"),
FULL_DISCOUNT_COUPON_TIME_ERROR(43007,"赠送的优惠券有效时间必须大于活动时间"),
FULL_DISCOUNT_MONEY_ERROR(43008,"请填写满减金额"),
FULL_DISCOUNT_MONEY_GREATER_THAN_MINUS(43009,"满减金额不能大于优惠门槛"),
FULL_RATE_NUM_ERROR(43010,"请填写打折数值"),
/** /**
* 直播 * 直播
*/ */
STODIO_GOODS_EXIST_ERROR(44001,"直播商品已存在"), STODIO_GOODS_EXIST_ERROR(44001,"直播商品已存在"),
COMMODITY_ERROR(44002,"添加直播商品失败"),
/**
* 秒杀
*/
SECKILL_NOT_EXIST_ERROR(45001,"当前参与的秒杀活动不存在!"),
SECKILL_UPDATE_ERROR(45002,"当前秒杀活动活动已经开始,无法修改!"),
SECKILL_PRICE_ERROR(45003,"活动价格不能大于商品原价"),
SECKILL_TIME_ERROR(45004,"时刻参数异常"),
SECKILL_DELETE_ERROR(45005,"该秒杀活动活动的状态不能删除"),
SECKILL_CLOSE_ERROR(45006,"该秒杀活动活动的状态不能关闭"),
/**
* 优惠券活动
*/
COUPON_ACTIVITY_START_TIME_ERROR(46001,"活动时间小于当前时间,不能进行编辑删除操作"),
COUPON_ACTIVITY_MEMBER_ERROR(46002,"指定精准发券则必须指定会员,会员不可以为空"),
COUPON_ACTIVITY_ITEM_ERROR(46003,"优惠券活动必须指定优惠券,不能为空"),
COUPON_ACTIVITY_ITEM_MUST_NUM_ERROR(46004,"优惠券活动最多指定10个优惠券"),
COUPON_ACTIVITY_ITEM_NUM_ERROR(46005,"赠券数量必须大于0"),
/**
* 其他促销
*/
MEMBER_SIGN_REPEAT(47001, "请勿重复签到"),
POINT_GOODS_ACTIVE_STOCK_ERROR(47002, "活动库存数量不能高于商品库存"),
/** /**
* 店铺 * 店铺
*/ */
STORE_NOT_EXIST(50001, "此店铺不存在"), STORE_NOT_EXIST(50001, "此店铺不存在"),
STORE_NAME_EXIST_ERROR(50002, "店铺名称已存在!"), STORE_NAME_EXIST_ERROR(50002, "店铺名称已存在!"),
STORE_APPLY_DOUBLE_ERROR(50003, "已有店铺,无需重复申请!"), STORE_APPLY_DOUBLE_ERROR(50003, "已有店铺,无需重复申请!"),
STORE_NOT_OPEN(50004, "该会员未开通店铺"),
STORE_NOT_LOGIN_ERROR(50005, "未登录店铺"),
/** /**
* 结算单 * 结算单
*/ */
BILL_CHECK_ERROR(51001, "只有已出账结算单可以核对"), BILL_CHECK_ERROR(51001, "只有已出账结算单可以核对"),
BILL_COMPLETE_ERROR(51002, "只有已审核结算单可以支付"), BILL_COMPLETE_ERROR(51002, "只有已审核结算单可以支付"),
/** /**
* 文章 * 文章
*/ */
ARTICLE_CATEGORY_NAME_EXIST(60001, "文章分类名称已存在"), ARTICLE_CATEGORY_NAME_EXIST(60001, "文章分类名称已存在"),
ARTICLE_CATEGORY_PARENT_NOT_EXIST(60002, "文章分类父分类不存在"), ARTICLE_CATEGORY_PARENT_NOT_EXIST(60002, "文章分类父分类不存在"),
ARTICLE_CATEGORY_BEYOND_TWO(60003, "最多为二级分类,操作失败"), ARTICLE_CATEGORY_BEYOND_TWO(60003, "最多为二级分类,操作失败"),
ARTICLE_CATEGORY_DELETE_ERROR(60004, "该文章分类下存在子分类,不能删除"), ARTICLE_CATEGORY_DELETE_ERROR(60004, "该文章分类下存在子分类,不能删除"),
ARTICLE_CATEGORY_HAS_ARTICLE(60005, "该文章分类下存在文章,不能删除"), ARTICLE_CATEGORY_HAS_ARTICLE(60005, "该文章分类下存在文章,不能删除"),
ARTICLE_CATEGORY_NO_DELETION(60007, "默认文章分类不能进行删除"), ARTICLE_CATEGORY_NO_DELETION(60007, "默认文章分类不能进行删除"),
ARTICLE_NO_DELETION(60008, "默认文章不能进行删除"), ARTICLE_NO_DELETION(60008, "默认文章不能进行删除"),
@ -363,69 +353,67 @@ public enum ResultCode {
* 页面 * 页面
*/ */
PAGE_NOT_EXIST(61001, "页面不存在"), PAGE_NOT_EXIST(61001, "页面不存在"),
PAGE_OPEN_DELETE_ERROR(61002, "当前页面为开启状态,无法删除"), PAGE_OPEN_DELETE_ERROR(61002, "当前页面为开启状态,无法删除"),
PAGE_DELETE_ERROR(61003, "当前页面为唯一页面,无法删除"), PAGE_DELETE_ERROR(61003, "当前页面为唯一页面,无法删除"),
PAGE_RELEASE_ERROR(61004, "页面已发布,无需重复提交"), PAGE_RELEASE_ERROR(61004, "页面已发布,无需重复提交"),
/** /**
* 设置 * 设置
*/ */
SETTING_NOT_TO_SET(70001, "该参数不需要设置"), SETTING_NOT_TO_SET(70001, "该参数不需要设置"),
ALIPAY_NOT_SETTING(70002, "支付宝支付未配置"),
/** ALIPAY_EXCEPTION(70003, "支付宝支付错误,请稍后重试"),
* 短信 ALIPAY_PARAMS_EXCEPTION(70004, "支付宝参数异常"),
*/ LOGISTICS_NOT_SETTING(70005,"您还未配置快递查询"),
SMS_SIGN_EXIST_ERROR(80001, "短信签名已存在"), ORDER_SETTING_ERROR(70006,"系统订单配置异常"),
ALI_SMS_SETTING_ERROR(70007,"您还未配置阿里云短信"),
SMS_SIGN_EXIST_ERROR(70008, "短信签名已存在"),
/** /**
* 站内信 * 站内信
*/ */
NOTICE_NOT_EXIST(80101, "当前消息模板不存在"), NOTICE_NOT_EXIST(80001, "当前消息模板不存在"),
NOTICE_ERROR(80002, "修改站内信异常,请稍后重试"),
NOTICE_SEND_ERROR(80003, "发送站内信异常,请检查系统日志"),
NOTICE_ERROR(80102, "修改站内信异常,请稍后重试"),
/** /**
* OSS * OSS
*/ */
OSS_NOT_EXIST(80201, "OSS未配置"), OSS_NOT_EXIST(80101, "OSS未配置"),
OSS_EXCEPTION_ERROR(80102, "文件上传失败,请稍后重试"),
OSS_EXCEPTION(80202, "文件上传失败,请稍后重试"), OSS_DELETE_ERROR(80102, "图片删除失败"),
/** /**
* 验证码 * 验证码
*/ */
VERIFICATION_SEND_SUCCESS(80301, "短信验证码,发送成功"), VERIFICATION_SEND_SUCCESS(80201, "短信验证码,发送成功"),
VERIFICATION_ERROR(80202, "验证失败"),
VERIFICATION_ERROR(80302, "验证失败"), VERIFICATION_SMS_ERROR(80203, "短信验证码错误,请重新校验"),
VERIFICATION_SMS_EXPIRED_ERROR(80204, "验证码已失效,请重新校验"),
VERIFICATION_SMS_ERROR(80303, "短信验证码错误,请重新校验"),
VERIFICATION_SMS_EXPIRED_ERROR(80304, "验证码已失效,请重新校验"),
/**
* 配置错误
*/
ALIPAY_NOT_SETTING(80401, "支付宝支付未配置"),
ALIPAY_EXCEPTION(80402, "支付宝支付错误,请稍后重试"),
ALIPAY_PARAMS_EXCEPTION(80403, "支付宝参数异常"),
/** /**
* 微信相关异常 * 微信相关异常
*/ */
WECHAT_CONNECT_NOT_SETTING(80500, "微信联合登陆信息未配置"), WECHAT_CONNECT_NOT_SETTING(80300, "微信联合登陆信息未配置"),
WECHAT_PAYMENT_NOT_SETTING(80301, "微信支付信息未配置"),
WECHAT_QRCODE_ERROR(80302, "微信二维码生成异常"),
WECHAT_MP_MESSAGE_ERROR(80303, "微信小程序小消息订阅异常"),
WECHAT_JSAPI_SIGN_ERROR(80304,"微信JsApi签名异常"),
WECHAT_CERT_ERROR(80305,"证书获取失败"),
WECHAT_MP_MESSAGE_TMPL_ERROR(80306,"未能获取到微信模版消息id"),
WECHAT_ERROR(80307,"微信接口异常"),
APP_VERSION_EXIST(80307, "APP版本已存在"),
WECHAT_PAYMENT_NOT_SETTING(80501, "微信支付信息未配置"), /**
* 其他
*/
CUSTOM_WORDS_EXIST_ERROR(90000, "当前自定义分词已存在!"),
CUSTOM_WORDS_NOT_EXIST_ERROR(90001, "当前自定义分词不存在!"),
CUSTOM_WORDS_SECRET_KEY_ERROR(90002, "秘钥验证失败!"),
CONNECT_NOT_EXIST(90000,"登录方式不存在"),
WECHAT_QRCODE_ERROR(80502, "微信二维码生成异常"), ;
WECHAT_MP_MESSAGE_ERROR(80503, "微信小程序小消息订阅异常"),
APP_VERSION_EXIST(80600, "APP版本已存在");
private final Integer code; private final Integer code;
private final String message; private final String message;

View File

@ -4,6 +4,7 @@ import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import cn.lili.common.cache.Cache; import cn.lili.common.cache.Cache;
import cn.lili.common.cache.CachePrefix; import cn.lili.common.cache.CachePrefix;
import cn.lili.common.enums.ResultCode;
import cn.lili.common.exception.ServiceException; import cn.lili.common.exception.ServiceException;
import cn.lili.common.security.context.UserContext; import cn.lili.common.security.context.UserContext;
import cn.lili.common.sms.AliSmsUtil; import cn.lili.common.sms.AliSmsUtil;
@ -64,7 +65,7 @@ public class SmsUtilAliImplService implements SmsUtil, AliSmsUtil {
//获取短信配置 //获取短信配置
Setting setting = settingService.get(SettingEnum.SMS_SETTING.name()); Setting setting = settingService.get(SettingEnum.SMS_SETTING.name());
if (StrUtil.isBlank(setting.getSettingValue())) { if (StrUtil.isBlank(setting.getSettingValue())) {
throw new ServiceException("您还未配置阿里云短信"); throw new ServiceException(ResultCode.ALI_SMS_SETTING_ERROR);
} }
SmsSetting smsSetting = new Gson().fromJson(setting.getSettingValue(), SmsSetting.class); SmsSetting smsSetting = new Gson().fromJson(setting.getSettingValue(), SmsSetting.class);
@ -351,7 +352,7 @@ public class SmsUtilAliImplService implements SmsUtil, AliSmsUtil {
try { try {
Setting setting = settingService.get(SettingEnum.SMS_SETTING.name()); Setting setting = settingService.get(SettingEnum.SMS_SETTING.name());
if (StrUtil.isBlank(setting.getSettingValue())) { if (StrUtil.isBlank(setting.getSettingValue())) {
throw new ServiceException("您还未配置阿里云短信"); throw new ServiceException(ResultCode.ALI_SMS_SETTING_ERROR);
} }
SmsSetting smsSetting = new Gson().fromJson(setting.getSettingValue(), SmsSetting.class); SmsSetting smsSetting = new Gson().fromJson(setting.getSettingValue(), SmsSetting.class);

View File

@ -84,7 +84,7 @@ public class ManagerTokenGenerate extends AbstractTokenGenerate {
//for循环路径集合 //for循环路径集合
for (String path : paths) { for (String path : paths) {
//如果是超级权限 则计入超级权限 //如果是超级权限 则计入超级权限
if (menu.getIsSupper()) { if (menu.getIsSupper() != null && menu.getIsSupper()) {
//如果已有超级权限则这里就不做权限的累加 //如果已有超级权限则这里就不做权限的累加
if (!superPermissions.contains(path)) { if (!superPermissions.contains(path)) {
superPermissions.add(path); superPermissions.add(path);

View File

@ -1,5 +1,6 @@
package cn.lili.common.token.base.generate; package cn.lili.common.token.base.generate;
import cn.lili.common.enums.ResultCode;
import cn.lili.common.exception.ServiceException; import cn.lili.common.exception.ServiceException;
import cn.lili.common.security.AuthUser; import cn.lili.common.security.AuthUser;
import cn.lili.common.security.enums.UserEnums; import cn.lili.common.security.enums.UserEnums;
@ -19,7 +20,6 @@ import org.springframework.stereotype.Component;
* *
* @author Chopper * @author Chopper
* @version v4.0 * @version v4.0
* @Description:
* @since 2020/11/16 10:51 * @since 2020/11/16 10:51
*/ */
@Component @Component
@ -36,7 +36,7 @@ public class StoreTokenGenerate extends AbstractTokenGenerate {
//生成token //生成token
Member member = memberService.findByUsername(username); Member member = memberService.findByUsername(username);
if (!member.getHaveStore()) { if (!member.getHaveStore()) {
throw new ServiceException("该会员未开通店铺"); throw new ServiceException(ResultCode.STORE_NOT_OPEN);
} }
AuthUser user = new AuthUser(member.getUsername(), member.getId(), member.getNickName(), UserEnums.STORE); AuthUser user = new AuthUser(member.getUsername(), member.getId(), member.getNickName(), UserEnums.STORE);
LambdaQueryWrapper<Store> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<Store> queryWrapper = new LambdaQueryWrapper<>();

View File

@ -1,5 +1,6 @@
package cn.lili.common.utils; package cn.lili.common.utils;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import java.beans.BeanInfo; import java.beans.BeanInfo;
@ -61,7 +62,7 @@ public class StringUtils extends StrUtil {
return 0; return 0;
} }
try { try {
value = Integer.parseInt(obj.toString()); value = Convert.toInt(obj.toString());
} catch (Exception ex) { } catch (Exception ex) {
if (checked) { if (checked) {
throw new RuntimeException("整型数字格式不正确"); throw new RuntimeException("整型数字格式不正确");

View File

@ -8,26 +8,30 @@ import javax.validation.ConstraintValidatorContext;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
/**
* 电话校验
* 支持手机号+电话同时校验
*/
public class MobileValidator implements ConstraintValidator<Mobile, String> { public class MobileValidator implements ConstraintValidator<Mobile, String> {
@Override @Override
public boolean isValid(String value, ConstraintValidatorContext constraintValidatorContext) { public boolean isValid(String value, ConstraintValidatorContext constraintValidatorContext) {
Pattern p1 = null,p2 = null; Pattern p1 = null, p2 = null, p3 = null;
Matcher m = null; Matcher m = null;
boolean b = false; p1 = Pattern.compile("0\\d{2,3}[-]?\\d{7,8}|0\\d{2,3}\\s?\\d{7,8}|13[0-9]\\d{8}|15[1089]\\d{8}"); // 验证带区号的
p1 = Pattern.compile("^[0][1-9]{2,3}-[0-9]{5,10}$"); // 验证带区号的
p2 = Pattern.compile("^[1-9]{1}[0-9]{5,8}$"); // 验证没有区号的 p2 = Pattern.compile("^[1-9]{1}[0-9]{5,8}$"); // 验证没有区号的
if(value.length() >9) p3 = Pattern.compile("^0?(13[0-9]|14[0-9]|15[0-9]|16[0-9]|17[0-9]|18[0-9]|19[0-9])[0-9]{8}$");// 验证手机号
{ m = p1.matcher(value); if (value.length() == 11) {
b = m.matches(); m = p3.matcher(value);
}else{ } else if (value.length() > 9) {
m = p1.matcher(value);
} else {
m = p2.matcher(value); m = p2.matcher(value);
b = m.matches();
} }
return b; return m.matches();
} }
@Override @Override
public void initialize(Mobile constraintAnnotation) { public void initialize(Mobile constraintAnnotation) {

View File

@ -2,6 +2,7 @@ package cn.lili.common.verification.service.impl;
import cn.lili.common.cache.Cache; import cn.lili.common.cache.Cache;
import cn.lili.common.cache.CachePrefix; import cn.lili.common.cache.CachePrefix;
import cn.lili.common.enums.ResultCode;
import cn.lili.common.exception.ServiceException; import cn.lili.common.exception.ServiceException;
import cn.lili.common.utils.StringUtils; import cn.lili.common.utils.StringUtils;
import cn.lili.common.verification.SliderImageUtil; import cn.lili.common.verification.SliderImageUtil;
@ -47,7 +48,7 @@ public class VerificationServiceImpl implements VerificationService {
public Map<String, Object> createVerification(VerificationEnums verificationEnums, String uuid) throws IOException { public Map<String, Object> createVerification(VerificationEnums verificationEnums, String uuid) throws IOException {
if (uuid == null) { if (uuid == null) {
throw new ServiceException("非法请求,请重新刷新页面操作"); throw new ServiceException(ResultCode.ILLEGAL_REQUEST_ERROR);
} }
//获取验证码配置 //获取验证码配置

View File

@ -1,5 +1,6 @@
package cn.lili.config.elasticsearch; package cn.lili.config.elasticsearch;
import cn.hutool.core.convert.Convert;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.http.HttpHost; import org.apache.http.HttpHost;
@ -75,7 +76,7 @@ public class ElasticsearchConfig extends AbstractElasticsearchConfiguration {
HttpHost[] httpHosts = new HttpHost[clusterNodes.size()]; HttpHost[] httpHosts = new HttpHost[clusterNodes.size()];
for (int i = 0; i < clusterNodes.size(); i++) { for (int i = 0; i < clusterNodes.size(); i++) {
String[] node = clusterNodes.get(i).split(":"); String[] node = clusterNodes.get(i).split(":");
httpHosts[i] = new HttpHost(node[0], Integer.parseInt(node[1]), elasticsearchProperties.getSchema()); httpHosts[i] = new HttpHost(node[0], Convert.toInt(node[1]), elasticsearchProperties.getSchema());
} }
return httpHosts; return httpHosts;
} }

View File

@ -1,5 +1,6 @@
package cn.lili.config.sharding; package cn.lili.config.sharding;
import cn.hutool.core.convert.Convert;
import cn.lili.common.utils.DateUtil; import cn.lili.common.utils.DateUtil;
import com.google.common.collect.Range; import com.google.common.collect.Range;
import org.apache.shardingsphere.api.sharding.standard.PreciseShardingAlgorithm; import org.apache.shardingsphere.api.sharding.standard.PreciseShardingAlgorithm;
@ -34,10 +35,10 @@ public class CreateTimeShardingTableAlgorithm implements PreciseShardingAlgorith
Collection<String> collect = new ArrayList<>(); Collection<String> collect = new ArrayList<>();
Range<Integer> valueRange = rangeShardingValue.getValueRange(); Range<Integer> valueRange = rangeShardingValue.getValueRange();
Integer startMonth = Integer.parseInt(DateUtil.toString(valueRange.lowerEndpoint().longValue(), "MM")); Integer startMonth = Convert.toInt(DateUtil.toString(valueRange.lowerEndpoint().longValue(), "MM"));
Integer endMonth = Integer.parseInt(DateUtil.toString(valueRange.upperEndpoint().longValue(), "MM")); Integer endMonth = Convert.toInt(DateUtil.toString(valueRange.upperEndpoint().longValue(), "MM"));
Integer startYear = Integer.parseInt(DateUtil.toString(valueRange.lowerEndpoint().longValue(), "yyyy")); Integer startYear = Convert.toInt(DateUtil.toString(valueRange.lowerEndpoint().longValue(), "yyyy"));
Integer endYear = Integer.parseInt(DateUtil.toString(valueRange.upperEndpoint().longValue(), "yyyy")); Integer endYear = Convert.toInt(DateUtil.toString(valueRange.upperEndpoint().longValue(), "yyyy"));
//如果是同一年查询 //如果是同一年查询
//2020-1~2020-2 //2020-1~2020-2

View File

@ -4,6 +4,7 @@ import cn.hutool.core.convert.Convert;
import cn.hutool.json.JSONArray; import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject; import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import cn.lili.common.enums.ResultCode;
import cn.lili.common.exception.ServiceException; import cn.lili.common.exception.ServiceException;
import cn.lili.common.security.context.UserContext; import cn.lili.common.security.context.UserContext;
import cn.lili.common.security.enums.UserEnums; import cn.lili.common.security.enums.UserEnums;
@ -50,7 +51,8 @@ public class CommodityServiceImpl extends ServiceImpl<CommodityMapper, Commodity
//添加直播商品 //添加直播商品
JSONObject json = wechatLivePlayerUtil.addGoods(commodity); JSONObject json = wechatLivePlayerUtil.addGoods(commodity);
if(!json.getStr("errcode").equals("0")){ if(!json.getStr("errcode").equals("0")){
throw new ServiceException(json.getStr("errmsg")); log.error(json.getStr("errmsg"));
throw new ServiceException(ResultCode.COMMODITY_ERROR);
} }
commodity.setLiveGoodsId(Convert.toInt(json.getStr("goodsId"))); commodity.setLiveGoodsId(Convert.toInt(json.getStr("goodsId")));
commodity.setAuditId(json.getStr("auditId")); commodity.setAuditId(json.getStr("auditId"));

View File

@ -1,5 +1,6 @@
package cn.lili.modules.broadcast.serviceimpl; package cn.lili.modules.broadcast.serviceimpl;
import cn.hutool.core.convert.Convert;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import cn.lili.common.delayqueue.BroadcastMessage; import cn.lili.common.delayqueue.BroadcastMessage;
import cn.lili.common.enums.ResultCode; import cn.lili.common.enums.ResultCode;
@ -62,9 +63,9 @@ public class StudioServiceImpl extends ServiceImpl<StudioMapper, Studio> impleme
public Boolean create(Studio studio) { public Boolean create(Studio studio) {
try { try {
//创建小程序直播 //创建小程序直播
// Map<String, String> roomMap = wechatLivePlayerUtil.create(studio); Map<String, String> roomMap = wechatLivePlayerUtil.create(studio);
// studio.setRoomId(Integer.parseInt(roomMap.get("roomId"))); studio.setRoomId(Convert.toInt(roomMap.get("roomId")));
// studio.setQrCodeUrl(roomMap.get("qrcodeUrl")); studio.setQrCodeUrl(roomMap.get("qrcodeUrl"));
studio.setStoreId(UserContext.getCurrentUser().getStoreId()); studio.setStoreId(UserContext.getCurrentUser().getStoreId());
studio.setStatus(StudioStatusEnum.NEW.name()); studio.setStatus(StudioStatusEnum.NEW.name());
//直播间添加成功发送直播间开启关闭延时任务 //直播间添加成功发送直播间开启关闭延时任务
@ -72,7 +73,7 @@ public class StudioServiceImpl extends ServiceImpl<StudioMapper, Studio> impleme
//直播开启延时任务 //直播开启延时任务
BroadcastMessage broadcastMessage = new BroadcastMessage(studio.getId(), StudioStatusEnum.START.name()); BroadcastMessage broadcastMessage = new BroadcastMessage(studio.getId(), StudioStatusEnum.START.name());
TimeTriggerMsg timeTriggerMsg = new TimeTriggerMsg(TimeExecuteConstant.BROADCAST_EXECUTOR, TimeTriggerMsg timeTriggerMsg = new TimeTriggerMsg(TimeExecuteConstant.BROADCAST_EXECUTOR,
Long.parseLong(studio.getStartTime()), Long.parseLong(studio.getStartTime()) * 1000L,
broadcastMessage, broadcastMessage,
DelayQueueTools.wrapperUniqueKey(DelayTypeEnums.BROADCAST, studio.getId()), DelayQueueTools.wrapperUniqueKey(DelayTypeEnums.BROADCAST, studio.getId()),
rocketmqCustomProperties.getPromotionTopic()); rocketmqCustomProperties.getPromotionTopic());
@ -83,7 +84,7 @@ public class StudioServiceImpl extends ServiceImpl<StudioMapper, Studio> impleme
//直播结束延时任务 //直播结束延时任务
broadcastMessage = new BroadcastMessage(studio.getId(), StudioStatusEnum.END.name()); broadcastMessage = new BroadcastMessage(studio.getId(), StudioStatusEnum.END.name());
timeTriggerMsg = new TimeTriggerMsg(TimeExecuteConstant.BROADCAST_EXECUTOR, timeTriggerMsg = new TimeTriggerMsg(TimeExecuteConstant.BROADCAST_EXECUTOR,
Long.parseLong(studio.getEndTime()), broadcastMessage, Long.parseLong(studio.getEndTime()) * 1000L, broadcastMessage,
DelayQueueTools.wrapperUniqueKey(DelayTypeEnums.BROADCAST, studio.getId()), DelayQueueTools.wrapperUniqueKey(DelayTypeEnums.BROADCAST, studio.getId()),
rocketmqCustomProperties.getPromotionTopic()); rocketmqCustomProperties.getPromotionTopic());
//发送促销活动开始的延时任务 //发送促销活动开始的延时任务
@ -108,8 +109,8 @@ public class StudioServiceImpl extends ServiceImpl<StudioMapper, Studio> impleme
this.timeTrigger.edit( this.timeTrigger.edit(
TimeExecuteConstant.BROADCAST_EXECUTOR, TimeExecuteConstant.BROADCAST_EXECUTOR,
broadcastMessage, broadcastMessage,
Long.parseLong(oldStudio.getStartTime()), Long.parseLong(oldStudio.getStartTime()) * 1000L,
Long.parseLong(studio.getStartTime()), Long.parseLong(studio.getStartTime()) * 1000L,
DelayQueueTools.wrapperUniqueKey(DelayTypeEnums.BROADCAST, studio.getId()), DelayQueueTools.wrapperUniqueKey(DelayTypeEnums.BROADCAST, studio.getId()),
DateUtil.getDelayTime(Long.parseLong(studio.getStartTime())), DateUtil.getDelayTime(Long.parseLong(studio.getStartTime())),
rocketmqCustomProperties.getPromotionTopic()); rocketmqCustomProperties.getPromotionTopic());
@ -119,8 +120,8 @@ public class StudioServiceImpl extends ServiceImpl<StudioMapper, Studio> impleme
this.timeTrigger.edit( this.timeTrigger.edit(
TimeExecuteConstant.BROADCAST_EXECUTOR, TimeExecuteConstant.BROADCAST_EXECUTOR,
broadcastMessage, broadcastMessage,
Long.parseLong(oldStudio.getEndTime()), Long.parseLong(oldStudio.getEndTime()) * 1000L,
Long.parseLong(studio.getEndTime()), Long.parseLong(studio.getEndTime()) * 1000L,
DelayQueueTools.wrapperUniqueKey(DelayTypeEnums.BROADCAST, studio.getId()), DelayQueueTools.wrapperUniqueKey(DelayTypeEnums.BROADCAST, studio.getId()),
DateUtil.getDelayTime(Long.parseLong(studio.getEndTime())), DateUtil.getDelayTime(Long.parseLong(studio.getEndTime())),
rocketmqCustomProperties.getPromotionTopic()); rocketmqCustomProperties.getPromotionTopic());
@ -200,7 +201,7 @@ public class StudioServiceImpl extends ServiceImpl<StudioMapper, Studio> impleme
.eq(recommend != null, "recommend", true) .eq(recommend != null, "recommend", true)
.eq(status != null, "status", status) .eq(status != null, "status", status)
.orderByDesc("create_time"); .orderByDesc("create_time");
if (UserContext.getCurrentUser().getRole().equals(UserEnums.STORE)) { if (UserContext.getCurrentUser() != null && UserContext.getCurrentUser().getRole().equals(UserEnums.STORE)) {
queryWrapper.eq("store_id", UserContext.getCurrentUser().getStoreId()); queryWrapper.eq("store_id", UserContext.getCurrentUser().getStoreId());
} }
return this.page(PageUtil.initPage(pageVO), queryWrapper); return this.page(PageUtil.initPage(pageVO), queryWrapper);

View File

@ -1,5 +1,6 @@
package cn.lili.modules.connect.request; package cn.lili.modules.connect.request;
import cn.hutool.core.convert.Convert;
import cn.lili.common.cache.Cache; import cn.lili.common.cache.Cache;
import cn.lili.common.utils.StringUtils; import cn.lili.common.utils.StringUtils;
import cn.lili.common.utils.UrlBuilder; import cn.lili.common.utils.UrlBuilder;
@ -56,7 +57,7 @@ public class AuthAlipayRequest extends AuthDefaultRequest {
return AuthToken.builder() return AuthToken.builder()
.accessToken(response.getAccessToken()) .accessToken(response.getAccessToken())
.uid(response.getUserId()) .uid(response.getUserId())
.expireIn(Integer.parseInt(response.getExpiresIn())) .expireIn(Convert.toInt(response.getExpiresIn()))
.refreshToken(response.getRefreshToken()) .refreshToken(response.getRefreshToken())
.build(); .build();
} }
@ -86,7 +87,7 @@ public class AuthAlipayRequest extends AuthDefaultRequest {
.data(AuthToken.builder() .data(AuthToken.builder()
.accessToken(response.getAccessToken()) .accessToken(response.getAccessToken())
.uid(response.getUserId()) .uid(response.getUserId())
.expireIn(Integer.parseInt(response.getExpiresIn())) .expireIn(Convert.toInt(response.getExpiresIn()))
.refreshToken(response.getRefreshToken()) .refreshToken(response.getRefreshToken())
.build()) .build())
.build(); .build();

View File

@ -1,5 +1,6 @@
package cn.lili.modules.connect.request; package cn.lili.modules.connect.request;
import cn.hutool.core.convert.Convert;
import cn.lili.common.cache.Cache; import cn.lili.common.cache.Cache;
import cn.lili.common.utils.StringUtils; import cn.lili.common.utils.StringUtils;
import cn.lili.common.utils.UrlBuilder; import cn.lili.common.utils.UrlBuilder;
@ -118,7 +119,7 @@ public class AuthQQRequest extends AuthDefaultRequest {
} }
return AuthToken.builder() return AuthToken.builder()
.accessToken(accessTokenObject.get("access_token")) .accessToken(accessTokenObject.get("access_token"))
.expireIn(Integer.parseInt(accessTokenObject.getOrDefault("expires_in", "0"))) .expireIn(Convert.toInt(accessTokenObject.getOrDefault("expires_in", "0")))
.refreshToken(accessTokenObject.get("refresh_token")) .refreshToken(accessTokenObject.get("refresh_token"))
.build(); .build();
} }

View File

@ -108,11 +108,11 @@ public class ConnectServiceImpl extends ServiceImpl<ConnectMapper, Connect> impl
CookieUtil.addCookie(CONNECT_TYPE, type, 1800, ThreadContextHolder.getHttpResponse()); CookieUtil.addCookie(CONNECT_TYPE, type, 1800, ThreadContextHolder.getHttpResponse());
//自动登录失败则把信息缓存起来 //自动登录失败则把信息缓存起来
cache.put(ConnectService.cacheKey(type, uuid), authUser, 30L, TimeUnit.MINUTES); cache.put(ConnectService.cacheKey(type, uuid), authUser, 30L, TimeUnit.MINUTES);
throw new ServiceException("未绑定用户"); throw new ServiceException(ResultCode.USER_NOT_BINDING);
} }
} catch (Exception e) { } catch (Exception e) {
log.error("联合登陆异常:", e); log.error("联合登陆异常:", e);
throw new ServiceException("未知错误,请稍后重试"); throw new ServiceException(ResultCode.ERROR);
} }
return token; return token;
} }

View File

@ -137,7 +137,7 @@ public class ConnectUtil {
public AuthRequest getAuthRequest(String type) { public AuthRequest getAuthRequest(String type) {
ConnectAuthEnum authInterface = ConnectAuthEnum.valueOf(type); ConnectAuthEnum authInterface = ConnectAuthEnum.valueOf(type);
if (authInterface == null) { if (authInterface == null) {
throw new ServiceException("错误的登录方式"); throw new ServiceException(ResultCode.CONNECT_NOT_EXIST);
} }
AuthRequest authRequest = null; AuthRequest authRequest = null;
switch (authInterface) { switch (authInterface) {

View File

@ -1,6 +1,8 @@
package cn.lili.modules.distribution.entity.dos; package cn.lili.modules.distribution.entity.dos;
import cn.lili.base.BaseEntity; import cn.lili.base.BaseEntity;
import cn.lili.common.utils.BeanUtil;
import cn.lili.modules.distribution.entity.dto.DistributionApplyDTO;
import cn.lili.modules.distribution.entity.enums.DistributionStatusEnum; import cn.lili.modules.distribution.entity.enums.DistributionStatusEnum;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
@ -10,6 +12,8 @@ import lombok.NoArgsConstructor;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.Table; import javax.persistence.Table;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
/** /**
* 分销员对象 * 分销员对象
@ -28,13 +32,12 @@ public class Distribution extends BaseEntity {
private static final long serialVersionUID = -4878132663540847325L; private static final long serialVersionUID = -4878132663540847325L;
public Distribution(String memberId, String memberName, String name, String idNumber) { public Distribution(String memberId, String memberName, DistributionApplyDTO distributionApplyDTO) {
this.memberId = memberId; this.memberId = memberId;
this.memberName = memberName; this.memberName = memberName;
this.name = name;
this.idNumber = idNumber;
distributionOrderCount=0; distributionOrderCount=0;
this.distributionStatus = DistributionStatusEnum.APPLY.name(); this.distributionStatus = DistributionStatusEnum.APPLY.name();
BeanUtil.copyProperties(distributionApplyDTO, this);
} }
@ApiModelProperty(value = "会员id") @ApiModelProperty(value = "会员id")
@ -67,4 +70,19 @@ public class Distribution extends BaseEntity {
@ApiModelProperty(value = "分销员状态", required = true) @ApiModelProperty(value = "分销员状态", required = true)
private String distributionStatus; private String distributionStatus;
@Size(min = 1, max = 200, message = "结算银行开户行名称长度为1-200位")
@NotBlank(message = "结算银行开户行名称不能为空")
@ApiModelProperty(value = "结算银行开户行名称")
private String settlementBankAccountName;
@Size(min = 1, max = 200, message = "结算银行开户账号长度为1-200位")
@NotBlank(message = "结算银行开户账号不能为空")
@ApiModelProperty(value = "结算银行开户账号")
private String settlementBankAccountNum;
@Size(min = 1, max = 200, message = "结算银行开户支行名称长度为1-200位")
@NotBlank(message = "结算银行开户支行名称不能为空")
@ApiModelProperty(value = "结算银行开户支行名称")
private String settlementBankBranchName;
} }

View File

@ -38,7 +38,7 @@ public class DistributionSelectedGoods {
@ApiModelProperty(value = "分销员ID") @ApiModelProperty(value = "分销员ID")
private String distributionId; private String distributionId;
@ApiModelProperty(value = "分销品ID") @ApiModelProperty(value = "分销品ID")
private String distributionGoodsId; private String distributionGoodsId;
public DistributionSelectedGoods(String distributionId, String distributionGoodsId) { public DistributionSelectedGoods(String distributionId, String distributionGoodsId) {

View File

@ -0,0 +1,40 @@
package cn.lili.modules.distribution.entity.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
/**
* 分销员申请DTO
* @author Bulbasaur
* @date: 2021/6/30 11:07 上午
*
*/
@Data
public class DistributionApplyDTO {
@NotBlank(message = "姓名不能为空")
@ApiModelProperty(value = "会员姓名")
private String name;
@NotBlank(message = "身份证号不能为空")
@ApiModelProperty(value = "身份证号")
private String idNumber;
@Size(min = 1, max = 200, message = "结算银行开户行名称长度为1-200位")
@NotBlank(message = "结算银行开户行名称不能为空")
@ApiModelProperty(value = "结算银行开户行名称")
private String settlementBankAccountName;
@Size(min = 1, max = 200, message = "结算银行开户账号长度为1-200位")
@NotBlank(message = "结算银行开户账号不能为空")
@ApiModelProperty(value = "结算银行开户账号")
private String settlementBankAccountNum;
@Size(min = 1, max = 200, message = "结算银行开户支行名称长度为1-200位")
@NotBlank(message = "结算银行开户支行名称不能为空")
@ApiModelProperty(value = "结算银行开户支行名称")
private String settlementBankBranchName;
}

View File

@ -39,6 +39,9 @@ public class DistributionGoodsVO {
@ApiModelProperty(value = "商品编号") @ApiModelProperty(value = "商品编号")
private String sn; private String sn;
@ApiModelProperty(value = "商品ID")
private String goodsId;
@ApiModelProperty(value = "规格ID") @ApiModelProperty(value = "规格ID")
private String skuId; private String skuId;

View File

@ -55,8 +55,8 @@ public class DistributionOrderSearchParams extends PageVO {
queryWrapper.like(StringUtils.isNotBlank(distributionName), "distribution_name", distributionName); queryWrapper.like(StringUtils.isNotBlank(distributionName), "distribution_name", distributionName);
queryWrapper.eq(StringUtils.isNotBlank(distributionOrderStatus), "distribution_order_status", distributionOrderStatus); queryWrapper.eq(StringUtils.isNotBlank(distributionOrderStatus), "distribution_order_status", distributionOrderStatus);
queryWrapper.eq(StringUtils.isNotBlank(orderSn), "order_sn", orderSn); queryWrapper.eq(StringUtils.isNotBlank(orderSn), "order_sn", orderSn);
queryWrapper.eq(StringUtils.isNotBlank(StringUtils.toString(distributionId)), "distribution_id", distributionId); queryWrapper.eq(StringUtils.isNotBlank(distributionId), "distribution_id", distributionId);
queryWrapper.eq(StringUtils.isNotBlank(StringUtils.toString(storeId)), "store_id", storeId); queryWrapper.eq(StringUtils.isNotBlank(storeId), "store_id", storeId);
if (endTime != null && startTime != null) { if (endTime != null && startTime != null) {
queryWrapper.between("create_time", startTime, endTime); queryWrapper.between("create_time", startTime, endTime);
} }

View File

@ -16,6 +16,6 @@ public interface DistributionMapper extends BaseMapper<Distribution> {
@Update("UPDATE li_distribution set can_rebate = can_rebate+#{canRebate} WHERE id = #{distributionId}") @Update("UPDATE li_distribution set can_rebate = can_rebate+#{canRebate} WHERE id = #{distributionId}")
void subCanRebate(Double canRebate,String distributionId); void subCanRebate(Double canRebate,String distributionId);
@Update("UPDATE li_distribution set can_rebate = (can_rebate+#{canRebate}) AND rebate_total=(rebate_total+#{canRebate}) AND distribution_order_count=(distribution_order_count+1) WHERE id = #{distributionId}") @Update("UPDATE li_distribution set can_rebate = (can_rebate+#{canRebate}) , rebate_total=(rebate_total+#{canRebate}) , distribution_order_count=(distribution_order_count+1) WHERE id = #{distributionId}")
void addCanRebate(Double canRebate,String distributionId); void addCanRebate(Double canRebate,String distributionId);
} }

View File

@ -16,4 +16,11 @@ public interface DistributionSelectedGoodsService extends IService<DistributionS
* @return * @return
*/ */
boolean add(String distributionGoodsId); boolean add(String distributionGoodsId);
/**
* 分销员添加分销商品
* @param distributionGoodsId 分销商品ID
* @return
*/
boolean delete(String distributionGoodsId);
} }

View File

@ -2,6 +2,7 @@ package cn.lili.modules.distribution.service;
import cn.lili.common.vo.PageVO; import cn.lili.common.vo.PageVO;
import cn.lili.modules.distribution.entity.dos.Distribution; import cn.lili.modules.distribution.entity.dos.Distribution;
import cn.lili.modules.distribution.entity.dto.DistributionApplyDTO;
import cn.lili.modules.distribution.entity.dto.DistributionSearchParams; import cn.lili.modules.distribution.entity.dto.DistributionSearchParams;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
@ -36,7 +37,7 @@ public interface DistributionService extends IService<Distribution> {
* *
* @return * @return
*/ */
Distribution applyDistribution(String name, String idNumber); Distribution applyDistribution(DistributionApplyDTO distributionApplyDTO);
/** /**
* 审核分销申请 * 审核分销申请

View File

@ -4,6 +4,7 @@ import cn.lili.modules.distribution.entity.dos.DistributionSelectedGoods;
import cn.lili.modules.distribution.mapper.DistributionSelectedGoodsMapper; import cn.lili.modules.distribution.mapper.DistributionSelectedGoodsMapper;
import cn.lili.modules.distribution.service.DistributionSelectedGoodsService; import cn.lili.modules.distribution.service.DistributionSelectedGoodsService;
import cn.lili.modules.distribution.service.DistributionService; import cn.lili.modules.distribution.service.DistributionService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -32,4 +33,15 @@ public class DistributionSelectedGoodsServiceImpl extends ServiceImpl<Distributi
DistributionSelectedGoods distributionSelectedGoods=new DistributionSelectedGoods(distributionId,distributionGoodsId); DistributionSelectedGoods distributionSelectedGoods=new DistributionSelectedGoods(distributionId,distributionGoodsId);
return this.save(distributionSelectedGoods); return this.save(distributionSelectedGoods);
} }
@Override
public boolean delete(String distributionGoodsId) {
//检查分销功能开关
distributionService.checkDistributionSetting();
String distributionId=distributionService.getDistribution().getId();
return this.remove(new LambdaQueryWrapper<DistributionSelectedGoods>()
.eq(DistributionSelectedGoods::getDistributionGoodsId,distributionGoodsId)
.eq(DistributionSelectedGoods::getDistributionId,distributionId));
}
} }

View File

@ -6,9 +6,11 @@ import cn.lili.common.cache.CachePrefix;
import cn.lili.common.enums.ResultCode; import cn.lili.common.enums.ResultCode;
import cn.lili.common.exception.ServiceException; import cn.lili.common.exception.ServiceException;
import cn.lili.common.security.context.UserContext; import cn.lili.common.security.context.UserContext;
import cn.lili.common.utils.BeanUtil;
import cn.lili.common.utils.PageUtil; import cn.lili.common.utils.PageUtil;
import cn.lili.common.vo.PageVO; import cn.lili.common.vo.PageVO;
import cn.lili.modules.distribution.entity.dos.Distribution; import cn.lili.modules.distribution.entity.dos.Distribution;
import cn.lili.modules.distribution.entity.dto.DistributionApplyDTO;
import cn.lili.modules.distribution.entity.dto.DistributionSearchParams; import cn.lili.modules.distribution.entity.dto.DistributionSearchParams;
import cn.lili.modules.distribution.entity.enums.DistributionStatusEnum; import cn.lili.modules.distribution.entity.enums.DistributionStatusEnum;
import cn.lili.modules.distribution.mapper.DistributionMapper; import cn.lili.modules.distribution.mapper.DistributionMapper;
@ -64,7 +66,7 @@ public class DistributionServiceImpl extends ServiceImpl<DistributionMapper, Dis
} }
@Override @Override
public Distribution applyDistribution(String name, String idNumber) { public Distribution applyDistribution(DistributionApplyDTO distributionApplyDTO) {
//检查分销开关 //检查分销开关
checkDistributionSetting(); checkDistributionSetting();
@ -78,8 +80,7 @@ public class DistributionServiceImpl extends ServiceImpl<DistributionMapper, Dis
throw new ServiceException(ResultCode.DISTRIBUTION_IS_APPLY); throw new ServiceException(ResultCode.DISTRIBUTION_IS_APPLY);
}else if(distribution.getDistributionStatus().equals(DistributionStatusEnum.REFUSE.name())){ }else if(distribution.getDistributionStatus().equals(DistributionStatusEnum.REFUSE.name())){
distribution.setDistributionStatus(DistributionStatusEnum.APPLY.name()); distribution.setDistributionStatus(DistributionStatusEnum.APPLY.name());
distribution.setName(name); BeanUtil.copyProperties(distributionApplyDTO,distribution);
distribution.setIdNumber(idNumber);
this.updateById(distribution); this.updateById(distribution);
return distribution; return distribution;
} }
@ -88,7 +89,7 @@ public class DistributionServiceImpl extends ServiceImpl<DistributionMapper, Dis
//获取当前登录用户 //获取当前登录用户
Member member = memberService.getUserInfo(); Member member = memberService.getUserInfo();
//新建分销员 //新建分销员
distribution = new Distribution(member.getId(), member.getUsername(), name, idNumber); distribution = new Distribution(member.getId(), member.getNickName(), distributionApplyDTO);
//添加分销员 //添加分销员
this.save(distribution); this.save(distribution);

View File

@ -1,6 +1,7 @@
package cn.lili.modules.file.plugin.impl; package cn.lili.modules.file.plugin.impl;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.lili.common.enums.ResultCode;
import cn.lili.common.exception.ServiceException; import cn.lili.common.exception.ServiceException;
import cn.lili.modules.file.plugin.FileManagerPlugin; import cn.lili.modules.file.plugin.FileManagerPlugin;
import cn.lili.modules.system.entity.dos.Setting; import cn.lili.modules.system.entity.dos.Setting;
@ -76,7 +77,7 @@ public class AliFileManagerPlugin implements FileManagerPlugin {
if (ossSetting == null || nextInitSetting == null || nextInitSetting < System.currentTimeMillis()) { if (ossSetting == null || nextInitSetting == null || nextInitSetting < System.currentTimeMillis()) {
Setting setting = settingService.get(SettingEnum.OSS_SETTING.name()); Setting setting = settingService.get(SettingEnum.OSS_SETTING.name());
if (setting == null || StrUtil.isBlank(setting.getSettingValue())) { if (setting == null || StrUtil.isBlank(setting.getSettingValue())) {
throw new ServiceException("您还未配置阿里云OSS存储"); throw new ServiceException(ResultCode.OSS_NOT_EXIST);
} }
nextInitSetting = System.currentTimeMillis() + interval; nextInitSetting = System.currentTimeMillis() + interval;
ossSetting = new Gson().fromJson(setting.getSettingValue(), OssSetting.class); ossSetting = new Gson().fromJson(setting.getSettingValue(), OssSetting.class);
@ -107,13 +108,13 @@ public class AliFileManagerPlugin implements FileManagerPlugin {
log.error("Error Code: " + oe.getErrorCode()); log.error("Error Code: " + oe.getErrorCode());
log.error("Request ID: " + oe.getRequestId()); log.error("Request ID: " + oe.getRequestId());
log.error("Host ID: " + oe.getHostId()); log.error("Host ID: " + oe.getHostId());
throw new ServiceException("图片上传失败" + oe.getErrorMessage()); throw new ServiceException(ResultCode.OSS_EXCEPTION_ERROR);
} catch (ClientException ce) { } catch (ClientException ce) {
log.error("Caught an ClientException, which means the client encountered " log.error("Caught an ClientException, which means the client encountered "
+ "a serious internal problem while trying to communicate with OSS, " + "a serious internal problem while trying to communicate with OSS, "
+ "such as not being able to access the network."); + "such as not being able to access the network.");
log.error("Error Message: " + ce.getMessage()); log.error("Error Message: " + ce.getMessage());
throw new ServiceException("图片上传失败" + ce.getErrorMessage()); throw new ServiceException(ResultCode.OSS_EXCEPTION_ERROR);
} finally { } finally {
/* /*
* Do not forget to shut down the client finally to release all allocated resources. * Do not forget to shut down the client finally to release all allocated resources.
@ -138,13 +139,13 @@ public class AliFileManagerPlugin implements FileManagerPlugin {
log.error("Error Code: " + oe.getErrorCode()); log.error("Error Code: " + oe.getErrorCode());
log.error("Request ID: " + oe.getRequestId()); log.error("Request ID: " + oe.getRequestId());
log.error("Host ID: " + oe.getHostId()); log.error("Host ID: " + oe.getHostId());
throw new ServiceException("图片上传失败" + oe.getErrorMessage()); throw new ServiceException(ResultCode.OSS_EXCEPTION_ERROR);
} catch (ClientException ce) { } catch (ClientException ce) {
log.error("Caught an ClientException, which means the client encountered " log.error("Caught an ClientException, which means the client encountered "
+ "a serious internal problem while trying to communicate with OSS, " + "a serious internal problem while trying to communicate with OSS, "
+ "such as not being able to access the network."); + "such as not being able to access the network.");
log.error("Error Message: " + ce.getMessage()); log.error("Error Message: " + ce.getMessage());
throw new ServiceException("图片上传失败" + ce.getErrorMessage()); throw new ServiceException(ResultCode.OSS_EXCEPTION_ERROR);
} finally { } finally {
/* /*
* Do not forget to shut down the client finally to release all allocated resources. * Do not forget to shut down the client finally to release all allocated resources.
@ -169,13 +170,13 @@ public class AliFileManagerPlugin implements FileManagerPlugin {
log.error("Error Code: " + oe.getErrorCode()); log.error("Error Code: " + oe.getErrorCode());
log.error("Request ID: " + oe.getRequestId()); log.error("Request ID: " + oe.getRequestId());
log.error("Host ID: " + oe.getHostId()); log.error("Host ID: " + oe.getHostId());
throw new ServiceException("图片删除失败" + oe.getErrorMessage()); throw new ServiceException(ResultCode.OSS_DELETE_ERROR);
} catch (ClientException ce) { } catch (ClientException ce) {
log.error("Caught an ClientException, which means the client encountered " log.error("Caught an ClientException, which means the client encountered "
+ "a serious internal problem while trying to communicate with OSS, " + "a serious internal problem while trying to communicate with OSS, "
+ "such as not being able to access the network."); + "such as not being able to access the network.");
log.error("Error Message: " + ce.getMessage()); log.error("Error Message: " + ce.getMessage());
throw new ServiceException("图片删除失败" + ce.getErrorMessage()); throw new ServiceException(ResultCode.OSS_DELETE_ERROR);
} finally { } finally {
/* /*
* Do not forget to shut down the client finally to release all allocated resources. * Do not forget to shut down the client finally to release all allocated resources.

View File

@ -1,5 +1,6 @@
package cn.lili.modules.goods.entity.dos; package cn.lili.modules.goods.entity.dos;
import cn.hutool.core.convert.Convert;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import cn.lili.base.BaseEntity; import cn.lili.base.BaseEntity;
import cn.lili.common.enums.ResultCode; import cn.lili.common.enums.ResultCode;
@ -234,19 +235,19 @@ public class Goods extends BaseEntity {
if (sku.get("sn") == null) { if (sku.get("sn") == null) {
throw new ServiceException(ResultCode.GOODS_SKU_SN_ERROR); throw new ServiceException(ResultCode.GOODS_SKU_SN_ERROR);
} }
if (StringUtil.isEmpty(sku.get("price").toString()) || Integer.parseInt( sku.get("price").toString()) <= 0) { if (StringUtil.isEmpty(sku.get("price").toString()) || Convert.toDouble(sku.get("price")) <= 0) {
throw new ServiceException(ResultCode.GOODS_SKU_PRICE_ERROR); throw new ServiceException(ResultCode.GOODS_SKU_PRICE_ERROR);
} }
if (StringUtil.isEmpty(sku.get("cost").toString()) || Integer.parseInt( sku.get("cost").toString()) <= 0) { if (StringUtil.isEmpty(sku.get("cost").toString()) || Convert.toDouble(sku.get("cost")) <= 0) {
throw new ServiceException(ResultCode.GOODS_SKU_COST_ERROR); throw new ServiceException(ResultCode.GOODS_SKU_COST_ERROR);
} }
//虚拟商品没有重量字段 //虚拟商品没有重量字段
if(sku.containsKey("weight")) { if (sku.containsKey("weight")) {
if (StringUtil.isEmpty(sku.get("weight").toString()) || Integer.parseInt(sku.get("weight").toString()) < 0) { if (StringUtil.isEmpty(sku.get("weight").toString()) || Convert.toDouble(sku.get("weight").toString()) < 0) {
throw new ServiceException(ResultCode.GOODS_SKU_WEIGHT_ERROR); throw new ServiceException(ResultCode.GOODS_SKU_WEIGHT_ERROR);
} }
} }
if (StringUtil.isEmpty(sku.get("quantity").toString()) || Integer.parseInt( sku.get("quantity").toString()) < 0) { if (StringUtil.isEmpty(sku.get("quantity").toString()) || Convert.toInt(sku.get("quantity").toString()) < 0) {
throw new ServiceException(ResultCode.GOODS_SKU_QUANTITY_ERROR); throw new ServiceException(ResultCode.GOODS_SKU_QUANTITY_ERROR);
} }

View File

@ -10,6 +10,8 @@ import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select; import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update; import org.apache.ibatis.annotations.Update;
import java.util.List;
/** /**
* 规格项数据处理层 * 规格项数据处理层
* *
@ -19,12 +21,12 @@ import org.apache.ibatis.annotations.Update;
public interface GoodsMapper extends BaseMapper<Goods> { public interface GoodsMapper extends BaseMapper<Goods> {
/** /**
* 下架所有商家商品 * 根据店铺ID获取商品ID列表
* *
* @param storeId * @param storeId 店铺ID
*/ */
@Update("update li_goods set market_enable = 0 WHERE store_id = #{storeId}") @Select("SELECT id FROM li_goods WHERE store_id = #{storeId}")
void underStoreGoods(String storeId); List<String> getGoodsIdByStoreId(String storeId);
@Update("UPDATE li_goods SET comment_num = comment_num + #{commentNum} WHERE id = #{goodsId}") @Update("UPDATE li_goods SET comment_num = comment_num + #{commentNum} WHERE id = #{goodsId}")
void addGoodsCommentNum(Integer commentNum, String goodsId); void addGoodsCommentNum(Integer commentNum, String goodsId);

View File

@ -1,5 +1,6 @@
package cn.lili.modules.goods.serviceimpl; package cn.lili.modules.goods.serviceimpl;
import cn.lili.common.enums.ResultCode;
import cn.lili.common.exception.ServiceException; import cn.lili.common.exception.ServiceException;
import cn.lili.common.utils.PageUtil; import cn.lili.common.utils.PageUtil;
import cn.lili.modules.goods.entity.dos.Brand; import cn.lili.modules.goods.entity.dos.Brand;
@ -62,7 +63,7 @@ public class BrandServiceImpl extends ServiceImpl<BrandMapper, Brand> implements
public boolean addBrand(BrandVO brandVO) { public boolean addBrand(BrandVO brandVO) {
if (getOne(new LambdaQueryWrapper<Brand>().eq(Brand::getName, brandVO.getName())) != null) { if (getOne(new LambdaQueryWrapper<Brand>().eq(Brand::getName, brandVO.getName())) != null) {
throw new ServiceException("品牌名称重复!"); throw new ServiceException(ResultCode.BRAND_NAME_EXIST_ERROR);
} }
return this.save(brandVO); return this.save(brandVO);
} }
@ -71,7 +72,7 @@ public class BrandServiceImpl extends ServiceImpl<BrandMapper, Brand> implements
public boolean updateBrand(BrandVO brandVO) { public boolean updateBrand(BrandVO brandVO) {
this.checkExist(brandVO.getId()); this.checkExist(brandVO.getId());
if (getOne(new LambdaQueryWrapper<Brand>().eq(Brand::getName, brandVO.getName()).ne(Brand::getId, brandVO.getId())) != null) { if (getOne(new LambdaQueryWrapper<Brand>().eq(Brand::getName, brandVO.getName()).ne(Brand::getId, brandVO.getId())) != null) {
throw new ServiceException("品牌名称重复!"); throw new ServiceException(ResultCode.BRAND_NAME_EXIST_ERROR);
} }
return this.updateById(brandVO); return this.updateById(brandVO);
} }
@ -80,7 +81,7 @@ public class BrandServiceImpl extends ServiceImpl<BrandMapper, Brand> implements
public boolean brandDisable(String brandId, boolean disable) { public boolean brandDisable(String brandId, boolean disable) {
Brand brand = this.checkExist(brandId); Brand brand = this.checkExist(brandId);
if (Boolean.TRUE.equals(disable) && !categoryBrandService.getCategoryBrandListByBrandId(brandId).isEmpty()) { if (Boolean.TRUE.equals(disable) && !categoryBrandService.getCategoryBrandListByBrandId(brandId).isEmpty()) {
throw new ServiceException("当前品牌下存在分类不可禁用"); throw new ServiceException(ResultCode.BRAND_USE_DISABLE_ERROR);
} }
brand.setDeleteFlag(disable); brand.setDeleteFlag(disable);
return updateById(brand); return updateById(brand);
@ -90,7 +91,7 @@ public class BrandServiceImpl extends ServiceImpl<BrandMapper, Brand> implements
Brand brand = getById(brandId); Brand brand = getById(brandId);
if (brand == null) { if (brand == null) {
log.error("品牌ID为" + brandId + "的品牌不存在"); log.error("品牌ID为" + brandId + "的品牌不存在");
throw new ServiceException(); throw new ServiceException(ResultCode.BRAND_NOT_EXIST);
} }
return brand; return brand;
} }

View File

@ -3,6 +3,7 @@ package cn.lili.modules.goods.serviceimpl;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.lili.common.cache.Cache; import cn.lili.common.cache.Cache;
import cn.lili.common.cache.CachePrefix; import cn.lili.common.cache.CachePrefix;
import cn.lili.common.enums.ResultCode;
import cn.lili.common.exception.ServiceException; import cn.lili.common.exception.ServiceException;
import cn.lili.modules.goods.entity.dos.Category; import cn.lili.modules.goods.entity.dos.Category;
import cn.lili.modules.goods.entity.dos.CategoryParameterGroup; import cn.lili.modules.goods.entity.dos.CategoryParameterGroup;
@ -174,7 +175,7 @@ public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, Category> i
if (category.getParentId() != null && !category.getParentId().equals("0")) { if (category.getParentId() != null && !category.getParentId().equals("0")) {
Category parentCategory = this.getById(category.getParentId()); Category parentCategory = this.getById(category.getParentId());
if (!parentCategory.getDeleteFlag().equals(category.getDeleteFlag())) { if (!parentCategory.getDeleteFlag().equals(category.getDeleteFlag())) {
throw new ServiceException("子类状态不能与父类不一致!"); throw new ServiceException(ResultCode.CATEGORY_DELETE_FLAG_ERROR);
} }
} }
UpdateWrapper<Category> updateWrapper = new UpdateWrapper<>(); UpdateWrapper<Category> updateWrapper = new UpdateWrapper<>();

View File

@ -93,7 +93,10 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
@Override @Override
public void underStoreGoods(String storeId) { public void underStoreGoods(String storeId) {
this.baseMapper.underStoreGoods(storeId); //获取商品ID列表
List<String> list= this.baseMapper.getGoodsIdByStoreId(storeId);
//下架店铺下的商品
updateGoodsMarketAble(list,GoodsStatusEnum.DOWN,"店铺关闭");
} }
@Override @Override
@ -276,7 +279,7 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
//商品删除消息 //商品删除消息
String destination = rocketmqCustomProperties.getGoodsTopic() + ":" + GoodsTagsEnum.GOODS_DELETE.name(); String destination = rocketmqCustomProperties.getGoodsTopic() + ":" + GoodsTagsEnum.GOODS_DELETE.name();
//发送mq消息 //发送mq消息
rocketMQTemplate.asyncSend(destination, JSONUtil.toJsonStr(goods.getStoreId()), RocketmqSendCallbackBuilder.commonCallback()); rocketMQTemplate.asyncSend(destination, JSONUtil.toJsonStr(goods), RocketmqSendCallbackBuilder.commonCallback());
} }
return true; return true;
@ -364,11 +367,11 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
if(parameters.getId().equals(goodsParamsItemDTO.getParamId())){ if(parameters.getId().equals(goodsParamsItemDTO.getParamId())){
//校验是否可以索引参数是否正确 //校验是否可以索引参数是否正确
if(!parameters.getIsIndex().equals(goodsParamsItemDTO.getIsIndex())){ if(!parameters.getIsIndex().equals(goodsParamsItemDTO.getIsIndex())){
throw new ServiceException("商品参数错误,刷新后重试"); throw new ServiceException(ResultCode.GOODS_PARAMS_ERROR);
} }
//校验是否必填参数是否正确 //校验是否必填参数是否正确
if(!parameters.getRequired().equals(goodsParamsItemDTO.getRequired())){ if(!parameters.getRequired().equals(goodsParamsItemDTO.getRequired())){
throw new ServiceException("商品参数错误,刷新后重试"); throw new ServiceException(ResultCode.GOODS_PARAMS_ERROR);
} }
} }
} }
@ -392,16 +395,16 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
switch (goods.getGoodsType()) { switch (goods.getGoodsType()) {
case "PHYSICAL_GOODS": case "PHYSICAL_GOODS":
if (goods.getTemplateId().equals("0")) { if (goods.getTemplateId().equals("0")) {
throw new ServiceException("实物商品需选择配送模板"); throw new ServiceException(ResultCode.PHYSICAL_GOODS_NEED_TEMP);
} }
break; break;
case "VIRTUAL_GOODS": case "VIRTUAL_GOODS":
if (!goods.getTemplateId().equals("0")) { if (!goods.getTemplateId().equals("0")) {
throw new ServiceException("虚拟商品不需要选择配送模板"); throw new ServiceException(ResultCode.VIRTUAL_GOODS_NOT_NEED_TEMP);
} }
break; break;
default: default:
throw new ServiceException("需选择商品类型"); throw new ServiceException(ResultCode.GOODS_TYPE_ERROR);
} }
//检查商品是否存在--修改商品时使用 //检查商品是否存在--修改商品时使用
if (goods.getId() != null) { if (goods.getId() != null) {
@ -432,7 +435,7 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
goods.setStoreName(storeDetail.getStoreName()); goods.setStoreName(storeDetail.getStoreName());
goods.setSelfOperated(storeDetail.getSelfOperated()); goods.setSelfOperated(storeDetail.getSelfOperated());
} else { } else {
throw new ServiceException("当前未登录店铺"); throw new ServiceException(ResultCode.STORE_NOT_LOGIN_ERROR);
} }
} }

View File

@ -96,7 +96,7 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
// 添加商品sku // 添加商品sku
newSkuList = this.addGoodsSku(skuList, goods); newSkuList = this.addGoodsSku(skuList, goods);
} else { } else {
throw new ServiceException("规格必须要有一个!"); throw new ServiceException(ResultCode.MUST_HAVE_GOODS_SKU);
} }
this.updateStock(newSkuList); this.updateStock(newSkuList);
@ -107,7 +107,7 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
public void update(List<Map<String, Object>> skuList, Goods goods, Boolean regeneratorSkuFlag) { public void update(List<Map<String, Object>> skuList, Goods goods, Boolean regeneratorSkuFlag) {
// 是否存在规格 // 是否存在规格
if (skuList == null || skuList.isEmpty()) { if (skuList == null || skuList.isEmpty()) {
throw new ServiceException("规格必须要有一个!"); throw new ServiceException(ResultCode.MUST_HAVE_GOODS_SKU);
} }
List<GoodsSku> newSkuList; List<GoodsSku> newSkuList;
//删除旧的sku信息 //删除旧的sku信息
@ -173,8 +173,8 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
} }
String quantity = stringRedisTemplate.opsForValue().get(GoodsSkuService.getStockCacheKey(id)); String quantity = stringRedisTemplate.opsForValue().get(GoodsSkuService.getStockCacheKey(id));
if (quantity != null) { if (quantity != null) {
if (goodsSku.getQuantity() != Integer.parseInt(quantity)) { if (goodsSku.getQuantity() != Convert.toInt(quantity)) {
goodsSku.setQuantity(Integer.parseInt(quantity)); goodsSku.setQuantity(Convert.toInt(quantity));
this.updateById(goodsSku); this.updateById(goodsSku);
} }
} else { } else {
@ -190,6 +190,11 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
GoodsSku goodsSku = this.getGoodsSkuByIdFromCache(skuId); GoodsSku goodsSku = this.getGoodsSkuByIdFromCache(skuId);
GoodsVO goodsVO = goodsService.getGoodsVO(goodsId); GoodsVO goodsVO = goodsService.getGoodsVO(goodsId);
if (goodsVO == null || !goodsVO.getMarketEnable().equals(GoodsStatusEnum.UPPER.name())
|| !goodsVO.getIsAuth().equals(GoodsAuthEnum.PASS.name())
|| Boolean.TRUE.equals(goodsVO.getDeleteFlag())) {
throw new ServiceException(ResultCode.GOODS_NOT_EXIST);
}
//如果规格为空则使用商品ID进行查询 //如果规格为空则使用商品ID进行查询
if (goodsSku == null) { if (goodsSku == null) {
skuId = goodsVO.getSkuList().get(0).getId(); skuId = goodsVO.getSkuList().get(0).getId();
@ -198,8 +203,6 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
if (goodsSku == null) { if (goodsSku == null) {
throw new ServiceException(ResultCode.GOODS_NOT_EXIST); throw new ServiceException(ResultCode.GOODS_NOT_EXIST);
} }
} else if (!goodsSku.getMarketEnable().equals(GoodsStatusEnum.UPPER.name()) || !goodsVO.getIsAuth().equals(GoodsAuthEnum.PASS.name()) || Boolean.TRUE.equals(goodsSku.getDeleteFlag())) {
throw new ServiceException(ResultCode.GOODS_NOT_EXIST);
} }
//获取当前商品的索引信息 //获取当前商品的索引信息
EsGoodsIndex goodsIndex = goodsIndexService.findById(skuId); EsGoodsIndex goodsIndex = goodsIndexService.findById(skuId);
@ -223,6 +226,11 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
map.put("specs", this.groupBySkuAndSpec(goodsSkuDetail.getGoodsId())); map.put("specs", this.groupBySkuAndSpec(goodsSkuDetail.getGoodsId()));
map.put("promotionMap", goodsIndex.getPromotionMap()); map.put("promotionMap", goodsIndex.getPromotionMap());
//获取参数信息
if(goodsVO.getGoodsParamsDTOList().size()>0){
map.put("goodsParamsDTOList",goodsVO.getGoodsParamsDTOList());
}
//记录用户足迹 //记录用户足迹
if (UserContext.getCurrentUser() != null) { if (UserContext.getCurrentUser() != null) {
FootPrint footPrint = new FootPrint(UserContext.getCurrentUser().getId(), goodsId, skuId); FootPrint footPrint = new FootPrint(UserContext.getCurrentUser().getId(), goodsId, skuId);
@ -381,7 +389,7 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
String cacheKeys = GoodsSkuService.getStockCacheKey(skuId); String cacheKeys = GoodsSkuService.getStockCacheKey(skuId);
String stockStr = stringRedisTemplate.opsForValue().get(cacheKeys); String stockStr = stringRedisTemplate.opsForValue().get(cacheKeys);
if (stockStr != null) { if (stockStr != null) {
return Integer.parseInt(stockStr); return Convert.toInt(stockStr);
} else { } else {
GoodsSku goodsSku = getGoodsSkuByIdFromCache(skuId); GoodsSku goodsSku = getGoodsSkuByIdFromCache(skuId);
stringRedisTemplate.opsForValue().set(cacheKeys, goodsSku.getQuantity().toString()); stringRedisTemplate.opsForValue().set(cacheKeys, goodsSku.getQuantity().toString());
@ -452,7 +460,9 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
private void generateEsCheck(Goods goods) { private void generateEsCheck(Goods goods) {
//如果商品通过审核&&并且已上架 //如果商品通过审核&&并且已上架
List<GoodsSku> goodsSkuList = this.list(new LambdaQueryWrapper<GoodsSku>().eq(GoodsSku::getGoodsId, goods.getId())); List<GoodsSku> goodsSkuList = this.list(new LambdaQueryWrapper<GoodsSku>().eq(GoodsSku::getGoodsId, goods.getId()));
if (goods.getIsAuth().equals(GoodsAuthEnum.PASS.name()) && goods.getMarketEnable().equals(GoodsStatusEnum.UPPER.name()) && Boolean.FALSE.equals(goods.getDeleteFlag())) { if (goods.getIsAuth().equals(GoodsAuthEnum.PASS.name())
&& goods.getMarketEnable().equals(GoodsStatusEnum.UPPER.name())
&& Boolean.FALSE.equals(goods.getDeleteFlag())) {
List<EsGoodsIndex> goodsIndices = new ArrayList<>(); List<EsGoodsIndex> goodsIndices = new ArrayList<>();
for (GoodsSku goodsSku : goodsSkuList) { for (GoodsSku goodsSku : goodsSkuList) {
EsGoodsIndex esGoodsOld = goodsIndexService.findById(goodsSku.getId()); EsGoodsIndex esGoodsOld = goodsIndexService.findById(goodsSku.getId());

View File

@ -40,9 +40,9 @@ public class PointLogInterceptor {
point = Long.valueOf(obj[0].toString()); point = Long.valueOf(obj[0].toString());
} }
//变动类型 //变动类型
Integer type = 0; Boolean type = false;
if (obj[1] != null) { if (obj[1] != null) {
type = Integer.valueOf(obj[1].toString()); type = Boolean.valueOf(obj[1].toString());
} }
//会员ID //会员ID
String memberId = ""; String memberId = "";
@ -55,7 +55,7 @@ public class PointLogInterceptor {
MemberPointsHistory memberPointsHistory = new MemberPointsHistory(); MemberPointsHistory memberPointsHistory = new MemberPointsHistory();
memberPointsHistory.setMemberId(member.getId()); memberPointsHistory.setMemberId(member.getId());
memberPointsHistory.setMemberName(member.getUsername()); memberPointsHistory.setMemberName(member.getUsername());
memberPointsHistory.setPointType(type); memberPointsHistory.setPointType(type ? 1 : 0);
memberPointsHistory.setVariablePoint(point); memberPointsHistory.setVariablePoint(point);
memberPointsHistory.setBeforePoint(new Double(CurrencyUtil.sub(member.getPoint(), point)).longValue()); memberPointsHistory.setBeforePoint(new Double(CurrencyUtil.sub(member.getPoint(), point)).longValue());
memberPointsHistory.setPoint(member.getPoint()); memberPointsHistory.setPoint(member.getPoint());
@ -64,7 +64,7 @@ public class PointLogInterceptor {
memberPointsHistoryService.save(memberPointsHistory); memberPointsHistoryService.save(memberPointsHistory);
} }
} catch (Exception e) { } catch (Exception e) {
log.error("积分操作错误",e); log.error("积分操作错误", e);
} }

View File

@ -1,5 +1,6 @@
package cn.lili.modules.member.serviceimpl; package cn.lili.modules.member.serviceimpl;
import cn.lili.common.enums.ResultCode;
import cn.lili.common.exception.ServiceException; import cn.lili.common.exception.ServiceException;
import cn.lili.common.utils.StringUtils; import cn.lili.common.utils.StringUtils;
import cn.lili.modules.member.entity.dos.MemberNoticeSenter; import cn.lili.modules.member.entity.dos.MemberNoticeSenter;
@ -78,7 +79,7 @@ public class MemberNoticeSenterServiceImpl extends ServiceImpl<MemberNoticeSente
if (memberNoticeService.saveBatch(memberNotices)) { if (memberNoticeService.saveBatch(memberNotices)) {
return true; return true;
} else { } else {
throw new ServiceException("发送站内信异常,请检查系统日志"); throw new ServiceException(ResultCode.NOTICE_SEND_ERROR);
} }
} }
} }

View File

@ -1,6 +1,7 @@
package cn.lili.modules.member.serviceimpl; package cn.lili.modules.member.serviceimpl;
import cn.hutool.core.convert.Convert;
import cn.lili.common.cache.Cache; import cn.lili.common.cache.Cache;
import cn.lili.common.cache.CachePrefix; import cn.lili.common.cache.CachePrefix;
import cn.lili.common.enums.ResultCode; import cn.lili.common.enums.ResultCode;
@ -177,7 +178,7 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, Member> impleme
try { try {
String username = UuidUtils.getUUID(); String username = UuidUtils.getUUID();
Member member = new Member(username, UuidUtils.getUUID(), authUser.getAvatar(), authUser.getNickname(), Member member = new Member(username, UuidUtils.getUUID(), authUser.getAvatar(), authUser.getNickname(),
authUser.getGender() != null ? Integer.parseInt(authUser.getGender().getCode()) : 0); authUser.getGender() != null ? Convert.toInt(authUser.getGender().getCode()) : 0);
//保存会员 //保存会员
this.save(member); this.save(member);
Member loadMember = this.findByUsername(username); Member loadMember = this.findByUsername(username);
@ -189,7 +190,7 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, Member> impleme
throw e; throw e;
} catch (Exception e) { } catch (Exception e) {
log.error("自动注册异常:", e); log.error("自动注册异常:", e);
throw new ServiceException("自动注册失败,请稍后重试"); throw new ServiceException(ResultCode.USER_AUTO_REGISTER_ERROR);
} }
} }
@ -528,7 +529,7 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, Member> impleme
ConnectAuthUser connectAuthUser = getConnectAuthUser(uuid, connectType); ConnectAuthUser connectAuthUser = getConnectAuthUser(uuid, connectType);
if (connectAuthUser == null) { if (connectAuthUser == null) {
throw new ServiceException("授权信息已过期,请从新授权/登录"); throw new ServiceException(ResultCode.USER_OVERDUE_CONNECT_ERROR);
} }
//检测是否已经绑定过用户 //检测是否已经绑定过用户
LambdaQueryWrapper<Connect> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<Connect> queryWrapper = new LambdaQueryWrapper<>();
@ -540,13 +541,13 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, Member> impleme
connectAuthUser.setConnectEnum(authInterface); connectAuthUser.setConnectEnum(authInterface);
return connectAuthUser; return connectAuthUser;
} else { } else {
throw new ServiceException("当前联合登陆方式,已绑定其他账号,需进行解绑操作"); throw new ServiceException(ResultCode.USER_CONNECT_BANDING_ERROR);
} }
} catch (Exception e) { } catch (Exception e) {
throw e; throw e;
} }
} else { } else {
throw new ServiceException("暂无联合登陆信息,无法实现一键注册功能,请点击第三方登录进行授权"); throw new ServiceException(ResultCode.USER_CONNECT_NOT_EXIST_ERROR);
} }
} }

View File

@ -4,6 +4,7 @@ import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONArray; import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject; import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import cn.lili.common.enums.ResultCode;
import cn.lili.common.exception.ServiceException; import cn.lili.common.exception.ServiceException;
import cn.lili.modules.base.entity.enums.ClientTypeEnum; import cn.lili.modules.base.entity.enums.ClientTypeEnum;
import cn.lili.modules.message.entity.dos.WechatMPMessage; import cn.lili.modules.message.entity.dos.WechatMPMessage;
@ -114,7 +115,7 @@ public class WechatMPMessageServiceImpl extends ServiceImpl<WechatMPMessageMappe
if (tplContent.containsKey("priTmplId")) { if (tplContent.containsKey("priTmplId")) {
wechatMPMessage.setCode(tplContent.getStr("priTmplId")); wechatMPMessage.setCode(tplContent.getStr("priTmplId"));
} else { } else {
throw new ServiceException("未能获取到微信模版消息id"); throw new ServiceException(ResultCode.WECHAT_MP_MESSAGE_TMPL_ERROR);
} }
wechatMPMessage.setName(tplData.getSceneDesc()); wechatMPMessage.setName(tplData.getSceneDesc());

View File

@ -3,6 +3,7 @@ package cn.lili.modules.message.serviceimpl;
import cn.hutool.http.HttpUtil; import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONObject; import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import cn.lili.common.enums.ResultCode;
import cn.lili.common.exception.ServiceException; import cn.lili.common.exception.ServiceException;
import cn.lili.modules.base.entity.enums.ClientTypeEnum; import cn.lili.modules.base.entity.enums.ClientTypeEnum;
import cn.lili.modules.message.entity.dos.WechatMessage; import cn.lili.modules.message.entity.dos.WechatMessage;
@ -83,7 +84,7 @@ public class WechatMessageServiceImpl extends ServiceImpl<WechatMessageMapper, W
if (tplContent.containsKey("template_id")) { if (tplContent.containsKey("template_id")) {
wechatMessage.setCode(tplContent.getStr("template_id")); wechatMessage.setCode(tplContent.getStr("template_id"));
} else { } else {
throw new ServiceException("未能获取到微信模版消息id"); throw new ServiceException(ResultCode.WECHAT_MP_MESSAGE_TMPL_ERROR);
} }
wechatMessage.setName(tplData.getName()); wechatMessage.setName(tplData.getName());

View File

@ -4,6 +4,7 @@ import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONObject; import cn.hutool.json.JSONObject;
import cn.lili.common.cache.Cache; import cn.lili.common.cache.Cache;
import cn.lili.common.cache.CachePrefix; import cn.lili.common.cache.CachePrefix;
import cn.lili.common.enums.ResultCode;
import cn.lili.common.exception.ServiceException; import cn.lili.common.exception.ServiceException;
import cn.lili.modules.base.entity.enums.ClientTypeEnum; import cn.lili.modules.base.entity.enums.ClientTypeEnum;
import cn.lili.modules.connect.util.HttpUtils; import cn.lili.modules.connect.util.HttpUtils;
@ -105,7 +106,7 @@ public class WechatAccessTokenUtil {
return ticket; return ticket;
} catch (Exception e) { } catch (Exception e) {
log.error("微信JsApi签名异常", e); log.error("微信JsApi签名异常", e);
throw new ServiceException("微信JsApi签名异常"); throw new ServiceException(ResultCode.WECHAT_JSAPI_SIGN_ERROR);
} }
} }

View File

@ -3,6 +3,7 @@ package cn.lili.modules.message.util;
import cn.hutool.http.HttpUtil; import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONObject; import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import cn.lili.common.enums.ResultCode;
import cn.lili.common.exception.ServiceException; import cn.lili.common.exception.ServiceException;
import cn.lili.common.utils.DateUtil; import cn.lili.common.utils.DateUtil;
import cn.lili.common.utils.StringUtils; import cn.lili.common.utils.StringUtils;
@ -276,12 +277,13 @@ public class WechatMessageUtil {
if (jsonObject.getStr("errmsg").equals("ok")) { if (jsonObject.getStr("errmsg").equals("ok")) {
return; return;
} }
throw new ServiceException("微信接口异常,请联系管理员:错误码" + jsonObject.get("errcode") + "" + jsonObject.getStr("errmsg")); log.error("微信接口异常,错误码" + jsonObject.get("errcode") + "" + jsonObject.getStr("errmsg"));
throw new ServiceException(ResultCode.WECHAT_ERROR);
} }
} }
/** /**
* 如果返回信息有错误 * 如果返回信息有错误....................................................................................................................................................................................333333333333333333
* *
* @param string * @param string
*/ */

View File

@ -80,6 +80,10 @@ public class TradeBuilder {
/** /**
* 构造一笔交易 * 构造一笔交易
* 1.从缓存中读取交易数据
* 2.从购物车列表中筛选出已选择的SKU列表存入交易中
* 3.渲染整个交易0-> 校验商品 1- 满优惠渲染 2->渲染优惠 3->优惠券渲染 4->计算运费 5->计算价格 6->分销渲染 7->其他渲染
* 4.将已选择的购物车列表存入交易中
* *
* @param checkedWay 购物车类型 * @param checkedWay 购物车类型
* @return 购物车展示信息 * @return 购物车展示信息
@ -114,6 +118,8 @@ public class TradeBuilder {
/** /**
* 创建一笔交易 * 创建一笔交易
* 1.构造交易
* 2.创建交易
* *
* @param checkedWay 购物车类型 * @param checkedWay 购物车类型
* @return 交易信息 * @return 交易信息

View File

@ -1,6 +1,7 @@
package cn.lili.modules.order.cart.render.impl; package cn.lili.modules.order.cart.render.impl;
import cn.hutool.core.text.CharSequenceUtil; import cn.hutool.core.text.CharSequenceUtil;
import cn.lili.common.enums.ResultCode;
import cn.lili.common.exception.ServiceException; import cn.lili.common.exception.ServiceException;
import cn.lili.common.security.context.UserContext; import cn.lili.common.security.context.UserContext;
import cn.lili.common.utils.CurrencyUtil; import cn.lili.common.utils.CurrencyUtil;
@ -130,7 +131,7 @@ public class CheckDataRender implements CartRenderStep {
cn.lili.modules.order.order.entity.dos.Order parentOrder = orderService.getBySn(tradeDTO.getParentOrderSn()); cn.lili.modules.order.order.entity.dos.Order parentOrder = orderService.getBySn(tradeDTO.getParentOrderSn());
//参与活动判定 //参与活动判定
if (parentOrder.getMemberId().equals(UserContext.getCurrentUser().getId())) { if (parentOrder.getMemberId().equals(UserContext.getCurrentUser().getId())) {
throw new ServiceException("不能参与自己发起的拼团活动!"); throw new ServiceException(ResultCode.PINTUAN_JOIN_ERROR);
} }
} }
} }

View File

@ -1,6 +1,7 @@
package cn.lili.modules.order.cart.render.impl; package cn.lili.modules.order.cart.render.impl;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.lili.common.enums.ResultCode;
import cn.lili.common.exception.ServiceException; import cn.lili.common.exception.ServiceException;
import cn.lili.common.utils.CurrencyUtil; import cn.lili.common.utils.CurrencyUtil;
import cn.lili.common.utils.StringUtils; import cn.lili.common.utils.StringUtils;
@ -308,7 +309,7 @@ public class SkuPromotionRender implements CartRenderStep {
Integer limitNum = pintuan.getLimitNum(); Integer limitNum = pintuan.getLimitNum();
for (CartSkuVO cartSkuVO : tradeDTO.getSkuList()) { for (CartSkuVO cartSkuVO : tradeDTO.getSkuList()) {
if (limitNum != 0 && cartSkuVO.getNum() > limitNum) { if (limitNum != 0 && cartSkuVO.getNum() > limitNum) {
throw new ServiceException("购买数量超过拼团活动限制数量"); throw new ServiceException(ResultCode.PINTUAN_LIMIT_NUM_ERROR);
} }
} }
} }

View File

@ -162,6 +162,13 @@ public interface CartService {
/** /**
* 创建交易 * 创建交易
* 1.获取购物车类型不同的购物车类型有不同的订单逻辑
* 购物车类型购物车立即购买虚拟商品拼团积分
* 2.校验用户的收件人信息
* 3.设置交易的基础参数
* 4.交易信息存储到缓存中
* 5.创建交易
* 6.清除购物车选择数据
* *
* @param tradeParams 创建交易参数 * @param tradeParams 创建交易参数
* @return 交易信息 * @return 交易信息

View File

@ -219,27 +219,25 @@ public class Order extends BaseEntity {
BeanUtil.copyProperties(tradeDTO, this); BeanUtil.copyProperties(tradeDTO, this);
BeanUtil.copyProperties(cartVO.getPriceDetailDTO(), this); BeanUtil.copyProperties(cartVO.getPriceDetailDTO(), this);
BeanUtil.copyProperties(cartVO, this); BeanUtil.copyProperties(cartVO, this);
//订单类型判断--普通订单活动订单 //订单类型判断--普通订单虚拟订单
if (tradeDTO.getCartTypeEnum().equals(CartTypeEnum.CART) || tradeDTO.getCartTypeEnum().equals(CartTypeEnum.BUY_NOW)) { if (tradeDTO.getCartTypeEnum().equals(CartTypeEnum.CART) || tradeDTO.getCartTypeEnum().equals(CartTypeEnum.BUY_NOW)) {
this.setOrderType(OrderTypeEnum.NORMAL.name()); this.setOrderType(OrderTypeEnum.NORMAL.name());
} else if (tradeDTO.getCartTypeEnum().equals(CartTypeEnum.VIRTUAL)) { } else if (tradeDTO.getCartTypeEnum().equals(CartTypeEnum.VIRTUAL)) {
this.setOrderType(tradeDTO.getCartTypeEnum().name()); this.setOrderType(tradeDTO.getCartTypeEnum().name());
} else {
this.setOrderType(OrderTypeEnum.NORMAL.name());
} }
this.setId(oldId); this.setId(oldId);
//促销信息填充 //促销信息填充
if (cartVO.getSkuList().get(0).getPromotions() != null && tradeDTO.getCartTypeEnum().equals(CartTypeEnum.PINTUAN)) { // if (cartVO.getSkuList().get(0).getPromotions() != null && tradeDTO.getCartTypeEnum().equals(CartTypeEnum.PINTUAN)) {
Optional<String> pintuanId = cartVO.getSkuList().get(0).getPromotions().stream().filter(i -> i.getPromotionType().equals(PromotionTypeEnum.PINTUAN.name())).map(PromotionGoods::getPromotionId).findFirst(); // Optional<String> pintuanId = cartVO.getSkuList().get(0).getPromotions().stream().filter(i -> i.getPromotionType().equals(PromotionTypeEnum.PINTUAN.name())).map(PromotionGoods::getPromotionId).findFirst();
if (pintuanId.isPresent()) { // if (pintuanId.isPresent()) {
promotionId = pintuanId.get(); // promotionId = pintuanId.get();
this.setOrderType(OrderTypeEnum.PINTUAN.name()); // this.setOrderType(OrderTypeEnum.PINTUAN.name());
if (tradeDTO.getParentOrderSn() == null) { // if (tradeDTO.getParentOrderSn() == null) {
this.setParentOrderSn(""); // this.setParentOrderSn("");
} // }
} // }
} // }
//设置默认支付状态 //设置默认支付状态
this.setOrderStatus(OrderStatusEnum.UNPAID.name()); this.setOrderStatus(OrderStatusEnum.UNPAID.name());

View File

@ -13,17 +13,8 @@ public enum OrderTypeEnum {
*/ */
NORMAL, NORMAL,
/**
* 赠品订单
*/
GIFT,
/** /**
* 虚拟订单 * 虚拟订单
*/ */
VIRTUAL, VIRTUAL
/**
* 拼团订单
*/
PINTUAN
} }

View File

@ -69,9 +69,10 @@ public class AllowOperation implements Serializable {
//新订单允许支付 //新订单允许支付
this.pay = status.equals(OrderStatusEnum.UNPAID.name()) && payStatus.equals(PayStatusEnum.UNPAID.name()); this.pay = status.equals(OrderStatusEnum.UNPAID.name()) && payStatus.equals(PayStatusEnum.UNPAID.name());
//订单未发货就可以编辑收货人信息实物订单 //可编辑订单收件人信息=实物订单 && 订单未发货 && 订单未取消
this.editConsignee = order.getOrderType().equals(OrderTypeEnum.VIRTUAL.name()) && this.editConsignee = order.getOrderType().equals(OrderTypeEnum.NORMAL.name())
order.getDeliverStatus().equals(DeliverStatusEnum.UNDELIVERED.name()) && !status.equals(OrderStatusEnum.CANCELLED.name()); && order.getDeliverStatus().equals(DeliverStatusEnum.UNDELIVERED.name())
&& !status.equals(OrderStatusEnum.CANCELLED.name());
//是否允许被发货 //是否允许被发货
this.ship = editConsignee && status.equals(OrderStatusEnum.UNDELIVERED.name()); this.ship = editConsignee && status.equals(OrderStatusEnum.UNDELIVERED.name());

View File

@ -70,7 +70,9 @@ public interface OrderService extends IService<Order> {
OrderDetailVO queryDetail(String orderSn); OrderDetailVO queryDetail(String orderSn);
/** /**
* 创建交易 * 创建订单
* 1.检查交易信息
* 2.循环交易购物车列表创建订单以及相关信息
* *
* @param tradeDTO 交易DTO * @param tradeDTO 交易DTO
*/ */

View File

@ -14,6 +14,13 @@ public interface TradeService extends IService<Trade> {
/** /**
* 创建交易 * 创建交易
* 1.订单数据校验
* 2.积分预处理
* 3.优惠券预处理
* 4.添加交易
* 5.添加订单
* 6.将交易写入缓存供消费者调用
* 7.发送交易创建消息
* *
* @param tradeDTO 购物车视图 * @param tradeDTO 购物车视图
* @return 交易 * @return 交易

View File

@ -473,7 +473,7 @@ public class AfterSaleServiceImpl extends ServiceImpl<AfterSaleMapper, AfterSale
|| StringUtils.isEmpty(afterSaleDTO.getBankAccountName()) || StringUtils.isEmpty(afterSaleDTO.getBankAccountName())
|| StringUtils.isEmpty(afterSaleDTO.getBankAccountNumber()); || StringUtils.isEmpty(afterSaleDTO.getBankAccountNumber());
if (emptyBankParam) { if (emptyBankParam) {
throw new ServiceException("当账号类型为银行转账时,银行信息不能为空"); throw new ServiceException(ResultCode.RETURN_MONEY_OFFLINE_BANK_ERROR);
} }
} }

View File

@ -230,7 +230,7 @@ public class OrderComplaintServiceImpl extends ServiceImpl<OrderComplaintMapper,
private OrderComplaint checkOrderComplainExist(String id) { private OrderComplaint checkOrderComplainExist(String id) {
OrderComplaint orderComplaint = this.getById(id); OrderComplaint orderComplaint = this.getById(id);
if (orderComplaint == null) { if (orderComplaint == null) {
throw new ServiceException("当前投诉记录不存在"); throw new ServiceException(ResultCode.COMPLAINT_NOT_EXIT);
} }
return orderComplaint; return orderComplaint;
} }
@ -239,12 +239,12 @@ public class OrderComplaintServiceImpl extends ServiceImpl<OrderComplaintMapper,
ComplaintStatusEnum complaintStatusEnum = ComplaintStatusEnum.valueOf(operationParam.getComplainStatus()); ComplaintStatusEnum complaintStatusEnum = ComplaintStatusEnum.valueOf(operationParam.getComplainStatus());
if (complaintStatusEnum == ComplaintStatusEnum.COMPLETE) { if (complaintStatusEnum == ComplaintStatusEnum.COMPLETE) {
if (StrUtil.isEmpty(operationParam.getArbitrationResult())) { if (StrUtil.isEmpty(operationParam.getArbitrationResult())) {
throw new ServiceException("结束订单投诉时,仲裁结果不能为空"); throw new ServiceException(ResultCode.COMPLAINT_ARBITRATION_RESULT_ERROR);
} }
orderComplaint.setArbitrationResult(operationParam.getArbitrationResult()); orderComplaint.setArbitrationResult(operationParam.getArbitrationResult());
} else if (complaintStatusEnum == ComplaintStatusEnum.COMMUNICATION) { } else if (complaintStatusEnum == ComplaintStatusEnum.COMMUNICATION) {
if (StrUtil.isEmpty(operationParam.getAppealContent()) || operationParam.getImages() == null) { if (StrUtil.isEmpty(operationParam.getAppealContent()) || operationParam.getImages() == null) {
throw new ServiceException("商家申诉时,申诉内容不能为空"); throw new ServiceException(ResultCode.COMPLAINT_APPEAL_CONTENT_ERROR);
} }
orderComplaint.setContent(operationParam.getAppealContent()); orderComplaint.setContent(operationParam.getAppealContent());
orderComplaint.setImages(operationParam.getImages().get(0)); orderComplaint.setImages(operationParam.getImages().get(0));

View File

@ -1,5 +1,6 @@
package cn.lili.modules.order.order.serviceimpl; package cn.lili.modules.order.order.serviceimpl;
import cn.lili.common.enums.ResultCode;
import cn.lili.common.exception.ServiceException; import cn.lili.common.exception.ServiceException;
import cn.lili.modules.order.order.entity.dos.OrderItem; import cn.lili.modules.order.order.entity.dos.OrderItem;
import cn.lili.modules.order.order.entity.enums.CommentStatusEnum; import cn.lili.modules.order.order.entity.enums.CommentStatusEnum;
@ -58,7 +59,7 @@ public class OrderItemServiceImpl extends ServiceImpl<OrderItemMapper, OrderItem
queryWrapper.eq(OrderItem::getOrderSn, orderSn).eq(OrderItem::getSkuId, skuId); queryWrapper.eq(OrderItem::getOrderSn, orderSn).eq(OrderItem::getSkuId, skuId);
OrderItem orderItem = getOne(queryWrapper); OrderItem orderItem = getOne(queryWrapper);
if (orderItem == null) { if (orderItem == null) {
throw new ServiceException("当前订单项不存在!"); throw new ServiceException(ResultCode.ORDER_ITEM_NOT_EXIST);
} }
orderItem.setComplainId(complainId); orderItem.setComplainId(complainId);
orderItem.setComplainStatus(complainStatusEnum.name()); orderItem.setComplainStatus(complainStatusEnum.name());

View File

@ -203,8 +203,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
public Order cancel(String orderSn, String reason) { public Order cancel(String orderSn, String reason) {
Order order = OperationalJudgment.judgment(this.getBySn(orderSn)); Order order = OperationalJudgment.judgment(this.getBySn(orderSn));
//如果订单促销类型不为空&&订单是拼团订单并且订单未成团则抛出异常 //如果订单促销类型不为空&&订单是拼团订单并且订单未成团则抛出异常
if (StringUtils.isNotEmpty(order.getOrderPromotionType()) if (OrderPromotionTypeEnum.PINTUAN.name().equals(order.getOrderPromotionType())
&& order.getOrderPromotionType().equals(OrderPromotionTypeEnum.PINTUAN.name())
&& !order.getOrderStatus().equals(OrderStatusEnum.UNDELIVERED.name())) { && !order.getOrderStatus().equals(OrderStatusEnum.UNDELIVERED.name())) {
throw new ServiceException(ResultCode.ORDER_CAN_NOT_CANCEL); throw new ServiceException(ResultCode.ORDER_CAN_NOT_CANCEL);
} }
@ -286,7 +285,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
Order order = this.getBySn(orderSn); Order order = this.getBySn(orderSn);
//判断是否为拼团订单进行特殊处理 //判断是否为拼团订单进行特殊处理
//判断订单类型进行不同的订单确认操作 //判断订单类型进行不同的订单确认操作
if (order.getOrderPromotionType() != null && order.getOrderPromotionType().equals(OrderPromotionTypeEnum.PINTUAN.name())) { if (OrderPromotionTypeEnum.PINTUAN.name().equals(order.getOrderPromotionType())) {
this.checkPintuanOrder(order.getPromotionId(), order.getParentOrderSn()); this.checkPintuanOrder(order.getPromotionId(), order.getParentOrderSn());
} else { } else {
//判断订单类型 //判断订单类型
@ -545,7 +544,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
orderBatchDeliverDTOList.add(orderBatchDeliverDTO); orderBatchDeliverDTOList.add(orderBatchDeliverDTO);
} }
} catch (Exception e) { } catch (Exception e) {
throw new ServiceException("文件读取失败"); throw new ServiceException(ResultCode.ORDER_BATCH_DELIVER_ERROR);
} }
//循环检查是否符合规范 //循环检查是否符合规范
checkBatchDeliver(orderBatchDeliverDTOList); checkBatchDeliver(orderBatchDeliverDTOList);
@ -779,7 +778,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
//判断用户不能参与自己发起的拼团活动 //判断用户不能参与自己发起的拼团活动
Order parentOrder = this.getBySn(tradeDTO.getParentOrderSn()); Order parentOrder = this.getBySn(tradeDTO.getParentOrderSn());
if (parentOrder.getMemberId().equals(UserContext.getCurrentUser().getId())) { if (parentOrder.getMemberId().equals(UserContext.getCurrentUser().getId())) {
throw new ServiceException("不能参与自己发起的拼团活动!"); throw new ServiceException(ResultCode.PINTUAN_JOIN_ERROR);
} }
} }
} }
@ -795,7 +794,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
Pintuan pintuan = pintuanService.getPintuanById(order.getPromotionId()); Pintuan pintuan = pintuanService.getPintuanById(order.getPromotionId());
Integer limitNum = pintuan.getLimitNum(); Integer limitNum = pintuan.getLimitNum();
if (limitNum != 0 && order.getGoodsNum() > limitNum) { if (limitNum != 0 && order.getGoodsNum() > limitNum) {
throw new ServiceException("购买数量超过拼团活动限制数量"); throw new ServiceException(ResultCode.PINTUAN_LIMIT_NUM_ERROR);
} }
} }
} }

File diff suppressed because one or more lines are too long

View File

@ -34,6 +34,7 @@ public class ArticleCategoryVO extends ArticleCategory {
children.sort(new Comparator<ArticleCategoryVO>() { children.sort(new Comparator<ArticleCategoryVO>() {
@Override @Override
public int compare(ArticleCategoryVO o1, ArticleCategoryVO o2) { public int compare(ArticleCategoryVO o1, ArticleCategoryVO o2) {
System.out.println(o1.getArticleCategoryName()+":"+o2.getArticleCategoryName());
return o1.getSort().compareTo(o2.getSort()); return o1.getSort().compareTo(o2.getSort());
} }
}); });

View File

@ -57,7 +57,7 @@ public class CashierSupport {
HttpServletRequest request, HttpServletResponse response, HttpServletRequest request, HttpServletResponse response,
PayParam payParam) { PayParam payParam) {
if (paymentClientEnum == null || paymentMethodEnum == null) { if (paymentClientEnum == null || paymentMethodEnum == null) {
throw new ServiceException("未知的支付方式"); throw new ServiceException(ResultCode.PAY_NOT_SUPPORT);
} }
//获取支付插件 //获取支付插件
Payment payment = (Payment) SpringContextUtil.getBean(paymentMethodEnum.getPlugin()); Payment payment = (Payment) SpringContextUtil.getBean(paymentMethodEnum.getPlugin());

View File

@ -95,7 +95,7 @@ public class AliPayPlugin implements Payment {
@Override @Override
public ResultMessage<Object> JSApiPay(HttpServletRequest request, PayParam payParam) { public ResultMessage<Object> JSApiPay(HttpServletRequest request, PayParam payParam) {
throw new ServiceException("当前支付通道暂不支持"); throw new ServiceException(ResultCode.PAY_NOT_SUPPORT);
} }
@Override @Override

View File

@ -620,7 +620,7 @@ public class WechatPlugin implements Payment {
cache.put(CachePrefix.WECHAT_PLAT_FORM_CERT.getPrefix(), publicCert, second); cache.put(CachePrefix.WECHAT_PLAT_FORM_CERT.getPrefix(), publicCert, second);
} else { } else {
log.error("证书获取失败:{}" + body); log.error("证书获取失败:{}" + body);
throw new ServiceException("证书获取失败:" + body); throw new ServiceException(ResultCode.WECHAT_CERT_ERROR);
} }
return PayKit.getCertificate(publicCert); return PayKit.getCertificate(publicCert);
} catch (Exception e) { } catch (Exception e) {

View File

@ -199,13 +199,12 @@ public class AdminUserServiceImpl extends ServiceImpl<AdminUserMapper, AdminUser
if (roles.size() > 10) { if (roles.size() > 10) {
throw new ServiceException(ResultCode.PERMISSION_BEYOND_TEN); throw new ServiceException(ResultCode.PERMISSION_BEYOND_TEN);
} }
if (roles != null && roles.size() > 0) { if (roles.size() > 0) {
dbUser.setRoleIds(StringUtils.join(",", roles)); dbUser.setRoleIds(StringUtils.join(",", roles));
} }
this.save(dbUser); this.save(dbUser);
updateRole(adminUser.getId(), roles); dbUser = this.findByUsername(dbUser.getUsername());
updateRole(dbUser.getId(), roles);
} }

View File

@ -1,5 +1,6 @@
package cn.lili.modules.promotion.entity.vos; package cn.lili.modules.promotion.entity.vos;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.text.CharSequenceUtil; import cn.hutool.core.text.CharSequenceUtil;
import cn.lili.modules.promotion.entity.enums.PromotionStatusEnum; import cn.lili.modules.promotion.entity.enums.PromotionStatusEnum;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@ -85,9 +86,9 @@ public class PointsGoodsSearchParams {
if (CharSequenceUtil.isNotEmpty(points)) { if (CharSequenceUtil.isNotEmpty(points)) {
String[] s = points.split("_"); String[] s = points.split("_");
if (s.length > 1) { if (s.length > 1) {
query.addCriteria(Criteria.where("points").gte(Integer.parseInt(s[0])).lte(Integer.parseInt(s[1]))); query.addCriteria(Criteria.where("points").gte(Convert.toInt(s[0])).lte(Convert.toInt(s[1])));
} else { } else {
query.addCriteria(Criteria.where("points").gte(Integer.parseInt(s[0]))); query.addCriteria(Criteria.where("points").gte(Convert.toInt(s[0])));
} }
} }
if (recommend != null) { if (recommend != null) {

View File

@ -1,6 +1,7 @@
package cn.lili.modules.promotion.serviceimpl; package cn.lili.modules.promotion.serviceimpl;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import cn.lili.common.enums.ResultCode;
import cn.lili.common.exception.ServiceException; import cn.lili.common.exception.ServiceException;
import cn.lili.common.trigger.enums.DelayTypeEnums; import cn.lili.common.trigger.enums.DelayTypeEnums;
import cn.lili.common.trigger.interfaces.TimeTrigger; import cn.lili.common.trigger.interfaces.TimeTrigger;
@ -34,6 +35,8 @@ import org.springframework.stereotype.Service;
import java.util.*; import java.util.*;
import static cn.lili.common.enums.ResultCode.COUPON_ACTIVITY_ITEM_ERROR;
/** /**
* 优惠券活动业务层实现 * 优惠券活动业务层实现
* *
@ -208,25 +211,25 @@ public class CouponActivityServiceImpl extends ServiceImpl<CouponActivityMapper,
//检测活动时间超过当前时间不能进行操作 //检测活动时间超过当前时间不能进行操作
long nowTime = DateUtil.getDateline() * 1000; long nowTime = DateUtil.getDateline() * 1000;
if (couponActivity.getStartTime().getTime() < nowTime && couponActivity.getEndTime().getTime() > nowTime) { if (couponActivity.getStartTime().getTime() < nowTime && couponActivity.getEndTime().getTime() > nowTime) {
throw new ServiceException("活动时间小于当前时间,不能进行编辑删除操作"); throw new ServiceException(ResultCode.COUPON_ACTIVITY_START_TIME_ERROR);
} }
//活动时间需超过当前时间 //活动时间需超过当前时间
PromotionTools.checkPromotionTime(couponActivity.getStartTime().getTime(), couponActivity.getEndTime().getTime()); PromotionTools.checkPromotionTime(couponActivity.getStartTime().getTime(), couponActivity.getEndTime().getTime());
//指定会员判定 //指定会员判定
if (couponActivity.getActivityScope().equals(CouponActivitySendTypeEnum.DESIGNATED.name())) { if (couponActivity.getActivityScope().equals(CouponActivitySendTypeEnum.DESIGNATED.name())) {
if (couponActivity.getMemberDTOS().size() == 0) { if (couponActivity.getMemberDTOS().size() == 0) {
throw new ServiceException("指定精准发券则必须指定会员,会员不可以为空"); throw new ServiceException(ResultCode.COUPON_ACTIVITY_MEMBER_ERROR);
} }
} }
//优惠券数量判定 //优惠券数量判定
if (couponActivity.getCouponActivityItems().size() == 0) { if (couponActivity.getCouponActivityItems().size() == 0) {
throw new ServiceException("优惠券活动必须指定优惠券,不能为空"); throw new ServiceException(ResultCode.COUPON_ACTIVITY_ITEM_ERROR);
} else if (couponActivity.getCouponActivityItems().size() > 10) { } else if (couponActivity.getCouponActivityItems().size() > 10) {
throw new ServiceException("优惠券活动最多指定10个优惠券"); throw new ServiceException(ResultCode.COUPON_ACTIVITY_ITEM_MUST_NUM_ERROR);
} else { } else {
for (CouponActivityItem item : couponActivity.getCouponActivityItems()) { for (CouponActivityItem item : couponActivity.getCouponActivityItems()) {
if (item.getNum() == null || item.getNum() <= 0) { if (item.getNum() == null || item.getNum() <= 0) {
throw new ServiceException("赠券数量必须大于0"); throw new ServiceException(ResultCode.COUPON_ACTIVITY_ITEM_NUM_ERROR);
} }
} }
} }

View File

@ -1,6 +1,7 @@
package cn.lili.modules.promotion.serviceimpl; package cn.lili.modules.promotion.serviceimpl;
import cn.hutool.core.text.CharSequenceUtil; import cn.hutool.core.text.CharSequenceUtil;
import cn.lili.common.enums.ResultCode;
import cn.lili.common.trigger.util.DelayQueueTools; import cn.lili.common.trigger.util.DelayQueueTools;
import cn.lili.common.trigger.enums.DelayTypeEnums; import cn.lili.common.trigger.enums.DelayTypeEnums;
import cn.lili.common.trigger.message.PromotionMessage; import cn.lili.common.trigger.message.PromotionMessage;
@ -130,7 +131,7 @@ public class CouponServiceImpl extends ServiceImpl<CouponMapper, Coupon> impleme
List<CouponVO> couponVOS = this.mongoTemplate.find(query, CouponVO.class); List<CouponVO> couponVOS = this.mongoTemplate.find(query, CouponVO.class);
couponVOS = couponVOS.parallelStream().filter(i -> Boolean.FALSE.equals(i.getDeleteFlag())).collect(Collectors.toList()); couponVOS = couponVOS.parallelStream().filter(i -> Boolean.FALSE.equals(i.getDeleteFlag())).collect(Collectors.toList());
if (couponVOS.isEmpty()) { if (couponVOS.isEmpty()) {
throw new ServiceException("优惠券不存在"); throw new ServiceException(ResultCode.COUPON_NOT_EXIST);
} }
for (CouponVO couponVO : couponVOS) { for (CouponVO couponVO : couponVOS) {
if (promotionStatus.name().equals(PromotionStatusEnum.START.name())) { if (promotionStatus.name().equals(PromotionStatusEnum.START.name())) {
@ -282,23 +283,21 @@ public class CouponServiceImpl extends ServiceImpl<CouponMapper, Coupon> impleme
private void checkParam(CouponVO coupon) { private void checkParam(CouponVO coupon) {
if (coupon.getCouponLimitNum() < 0) { if (coupon.getCouponLimitNum() < 0) {
throw new ServiceException("领取限制数量不能为负数"); throw new ServiceException(ResultCode.COUPON_LIMIT_NUM_LESS_THAN_0);
} }
//如果发行数量是0则判断领取限制数量 //如果发行数量是0则判断领取限制数量
if (coupon.getPublishNum() != 0 && coupon.getCouponLimitNum() > coupon.getPublishNum()) { if (coupon.getPublishNum() != 0 && coupon.getCouponLimitNum() > coupon.getPublishNum()) {
throw new ServiceException("领取限制数量超出发行数量"); throw new ServiceException(ResultCode.COUPON_LIMIT_GREATER_THAN_PUBLISH);
} }
if (coupon.getCouponType().equals(CouponTypeEnum.PRICE.name()) && coupon.getPrice() > coupon.getConsumeThreshold()) { if (coupon.getCouponType().equals(CouponTypeEnum.DISCOUNT.name()) && (coupon.getCouponDiscount() < 0 && coupon.getCouponDiscount() > 10)) {
throw new ServiceException("优惠券面额必须小于优惠券消费限额"); throw new ServiceException(ResultCode.COUPON_DISCOUNT_ERROR);
} else if (coupon.getCouponType().equals(CouponTypeEnum.DISCOUNT.name()) && (coupon.getCouponDiscount() < 0 && coupon.getCouponDiscount() > 10)) {
throw new ServiceException("优惠券折扣必须小于10且大于0");
} }
if (coupon.getRangeDayType() != null && coupon.getRangeDayType().equals(CouponRangeDayEnum.FIXEDTIME.name())) { if (coupon.getRangeDayType() != null && coupon.getRangeDayType().equals(CouponRangeDayEnum.FIXEDTIME.name())) {
long nowTime = DateUtil.getDateline() * 1000; long nowTime = DateUtil.getDateline() * 1000;
if (coupon.getStartTime().getTime() < nowTime && coupon.getEndTime().getTime() > nowTime) { if (coupon.getStartTime().getTime() < nowTime && coupon.getEndTime().getTime() > nowTime) {
throw new ServiceException("活动时间小于当前时间,不能进行编辑删除操作"); throw new ServiceException(ResultCode.PROMOTION_TIME_ERROR);
} }
PromotionTools.checkPromotionTime(coupon.getStartTime().getTime(), coupon.getEndTime().getTime()); PromotionTools.checkPromotionTime(coupon.getStartTime().getTime(), coupon.getEndTime().getTime());
@ -316,24 +315,24 @@ public class CouponServiceImpl extends ServiceImpl<CouponMapper, Coupon> impleme
*/ */
private void checkCouponScope(CouponVO coupon) { private void checkCouponScope(CouponVO coupon) {
if (coupon.getScopeType().equals(CouponScopeTypeEnum.PORTION_GOODS.name()) && (coupon.getPromotionGoodsList() == null || coupon.getPromotionGoodsList().isEmpty())) { if (coupon.getScopeType().equals(CouponScopeTypeEnum.PORTION_GOODS.name()) && (coupon.getPromotionGoodsList() == null || coupon.getPromotionGoodsList().isEmpty())) {
throw new ServiceException("当前关联范围类型为指定商品时,商品列表不能为空"); throw new ServiceException(ResultCode.COUPON_SCOPE_TYPE_GOODS_ERROR);
} else if (coupon.getScopeType().equals(CouponScopeTypeEnum.PORTION_GOODS.name()) && CharSequenceUtil.isEmpty(coupon.getScopeId())) { } else if (coupon.getScopeType().equals(CouponScopeTypeEnum.PORTION_GOODS.name()) && CharSequenceUtil.isEmpty(coupon.getScopeId())) {
throw new ServiceException("当前关联范围类型为指定商品时范围关联的id不能为空"); throw new ServiceException(ResultCode.COUPON_SCOPE_TYPE_GOODS_ERROR);
} else if (coupon.getScopeType().equals(CouponScopeTypeEnum.PORTION_GOODS_CATEGORY.name()) && CharSequenceUtil.isEmpty(coupon.getScopeId())) { } else if (coupon.getScopeType().equals(CouponScopeTypeEnum.PORTION_GOODS_CATEGORY.name()) && CharSequenceUtil.isEmpty(coupon.getScopeId())) {
throw new ServiceException("当前关联范围类型为部分商品分类时范围关联的id不能为空"); throw new ServiceException(ResultCode.COUPON_SCOPE_TYPE_CATEGORY_ERROR);
} else if (coupon.getScopeType().equals(CouponScopeTypeEnum.PORTION_SHOP_CATEGORY.name()) && CharSequenceUtil.isEmpty(coupon.getScopeId())) { } else if (coupon.getScopeType().equals(CouponScopeTypeEnum.PORTION_SHOP_CATEGORY.name()) && CharSequenceUtil.isEmpty(coupon.getScopeId())) {
throw new ServiceException("当前关联范围类型为部分店铺分类时范围关联的id不能为空"); throw new ServiceException(ResultCode.COUPON_SCOPE_TYPE_STORE_ERROR);
} }
if (coupon.getScopeType().equals(CouponScopeTypeEnum.PORTION_GOODS.name())) { if (coupon.getScopeType().equals(CouponScopeTypeEnum.PORTION_GOODS.name())) {
String[] split = coupon.getScopeId().split(","); String[] split = coupon.getScopeId().split(",");
if (split.length <= 0) { if (split.length <= 0) {
throw new ServiceException("指定商品范围关联id无效"); throw new ServiceException(ResultCode.COUPON_SCOPE_ERROR);
} }
for (String id : split) { for (String id : split) {
GoodsSku goodsSku = goodsSkuService.getGoodsSkuByIdFromCache(id); GoodsSku goodsSku = goodsSkuService.getGoodsSkuByIdFromCache(id);
if (goodsSku == null) { if (goodsSku == null) {
throw new ServiceException("商品已下架"); throw new ServiceException(ResultCode.GOODS_NOT_EXIST);
} }
} }
} }
@ -375,7 +374,7 @@ public class CouponServiceImpl extends ServiceImpl<CouponMapper, Coupon> impleme
private CouponVO checkStatus(String id) { private CouponVO checkStatus(String id) {
CouponVO coupon = this.mongoTemplate.findById(id, CouponVO.class); CouponVO coupon = this.mongoTemplate.findById(id, CouponVO.class);
if (coupon == null) { if (coupon == null) {
throw new ServiceException("当前优惠券活动不存在"); throw new ServiceException(ResultCode.COUPON_NOT_EXIST);
} }
LambdaQueryWrapper<FullDiscount> queryWrapper = new LambdaQueryWrapper<FullDiscount>().eq(FullDiscount::getIsCoupon, true).eq(FullDiscount::getCouponId, id); LambdaQueryWrapper<FullDiscount> queryWrapper = new LambdaQueryWrapper<FullDiscount>().eq(FullDiscount::getIsCoupon, true).eq(FullDiscount::getCouponId, id);
FullDiscount fullDiscount = fullDiscountService.getOne(queryWrapper); FullDiscount fullDiscount = fullDiscountService.getOne(queryWrapper);

View File

@ -1,5 +1,6 @@
package cn.lili.modules.promotion.serviceimpl; package cn.lili.modules.promotion.serviceimpl;
import cn.lili.common.enums.ResultCode;
import cn.lili.common.trigger.util.DelayQueueTools; import cn.lili.common.trigger.util.DelayQueueTools;
import cn.lili.common.trigger.enums.DelayTypeEnums; import cn.lili.common.trigger.enums.DelayTypeEnums;
import cn.lili.common.trigger.message.PromotionMessage; import cn.lili.common.trigger.message.PromotionMessage;
@ -135,7 +136,7 @@ public class FullDiscountServiceImpl extends ServiceImpl<FullDiscountMapper, Ful
//检查满优惠活动是否存在 //检查满优惠活动是否存在
FullDiscountVO fullDiscount = this.checkFullDiscountExist(fullDiscountVO.getId()); FullDiscountVO fullDiscount = this.checkFullDiscountExist(fullDiscountVO.getId());
if (!fullDiscount.getPromotionStatus().equals(PromotionStatusEnum.NEW.name())) { if (!fullDiscount.getPromotionStatus().equals(PromotionStatusEnum.NEW.name())) {
throw new ServiceException("当前编辑的满优惠活动已经开始或者已经结束,无法修改"); throw new ServiceException(ResultCode.FULL_DISCOUNT_MODIFY_ERROR);
} }
//检查活动是否已经开始 //检查活动是否已经开始
PromotionTools.checkPromotionTime(fullDiscountVO.getStartTime().getTime(), fullDiscountVO.getEndTime().getTime()); PromotionTools.checkPromotionTime(fullDiscountVO.getStartTime().getTime(), fullDiscountVO.getEndTime().getTime());
@ -200,7 +201,7 @@ public class FullDiscountServiceImpl extends ServiceImpl<FullDiscountMapper, Ful
private FullDiscountVO checkFullDiscountExist(String id) { private FullDiscountVO checkFullDiscountExist(String id) {
FullDiscountVO fullDiscountVO = mongoTemplate.findById(id, FullDiscountVO.class); FullDiscountVO fullDiscountVO = mongoTemplate.findById(id, FullDiscountVO.class);
if (fullDiscountVO == null) { if (fullDiscountVO == null) {
throw new ServiceException("当前要操作的满优惠活动不存在"); throw new ServiceException(ResultCode.FULL_DISCOUNT_NOT_EXIST_ERROR);
} }
return fullDiscountVO; return fullDiscountVO;
} }
@ -212,7 +213,7 @@ public class FullDiscountServiceImpl extends ServiceImpl<FullDiscountMapper, Ful
*/ */
private void checkFullDiscount(FullDiscountVO fullDiscountVO) { private void checkFullDiscount(FullDiscountVO fullDiscountVO) {
if (fullDiscountVO.getIsFullMinus() == null && fullDiscountVO.getIsCoupon() == null && fullDiscountVO.getIsGift() == null && fullDiscountVO.getIsPoint() == null && fullDiscountVO.getIsFullRate() == null) { if (fullDiscountVO.getIsFullMinus() == null && fullDiscountVO.getIsCoupon() == null && fullDiscountVO.getIsGift() == null && fullDiscountVO.getIsPoint() == null && fullDiscountVO.getIsFullRate() == null) {
throw new ServiceException("请选择一种优惠方式"); throw new ServiceException(ResultCode.FULL_DISCOUNT_WAY_ERROR);
} }
//如果优惠方式是满减 //如果优惠方式是满减
if (Boolean.TRUE.equals(fullDiscountVO.getIsFullMinus())) { if (Boolean.TRUE.equals(fullDiscountVO.getIsFullMinus())) {
@ -224,7 +225,7 @@ public class FullDiscountServiceImpl extends ServiceImpl<FullDiscountMapper, Ful
//是否没有选择赠品 //是否没有选择赠品
boolean noGiftSelected = fullDiscountVO.getGiftId() == null; boolean noGiftSelected = fullDiscountVO.getGiftId() == null;
if (noGiftSelected) { if (noGiftSelected) {
throw new ServiceException("请选择赠品"); throw new ServiceException(ResultCode.FULL_DISCOUNT_GIFT_ERROR);
} }
} }
//如果优惠方式是赠优惠券 //如果优惠方式是赠优惠券
@ -252,7 +253,7 @@ public class FullDiscountServiceImpl extends ServiceImpl<FullDiscountMapper, Ful
QueryWrapper<FullDiscount> queryWrapper = PromotionTools.checkActiveTime(statTime, endTime, PromotionTypeEnum.FULL_DISCOUNT, storeId, id); QueryWrapper<FullDiscount> queryWrapper = PromotionTools.checkActiveTime(statTime, endTime, PromotionTypeEnum.FULL_DISCOUNT, storeId, id);
Integer sameNum = this.count(queryWrapper); Integer sameNum = this.count(queryWrapper);
if (sameNum > 0) { if (sameNum > 0) {
throw new ServiceException("当前时间内已存在同类活动"); throw new ServiceException(ResultCode.PROMOTION_SAME_ACTIVE_EXIST);
} }
} }
@ -266,11 +267,11 @@ public class FullDiscountServiceImpl extends ServiceImpl<FullDiscountMapper, Ful
//是否没有选择优惠券 //是否没有选择优惠券
boolean noCouponSelected = couponId == null; boolean noCouponSelected = couponId == null;
if (noCouponSelected) { if (noCouponSelected) {
throw new ServiceException("请选择优惠券"); throw new ServiceException(ResultCode.COUPON_NOT_EXIST);
} }
Coupon coupon = this.couponService.getById(couponId); Coupon coupon = this.couponService.getById(couponId);
if (coupon.getEndTime().getTime() < endTime) { if (coupon.getEndTime().getTime() < endTime) {
throw new ServiceException("赠送的优惠券有效时间必须大于活动时间"); throw new ServiceException(ResultCode.FULL_DISCOUNT_COUPON_TIME_ERROR);
} }
} }
@ -284,10 +285,10 @@ public class FullDiscountServiceImpl extends ServiceImpl<FullDiscountMapper, Ful
//是否没有填写满减金额 //是否没有填写满减金额
boolean noFullMinusInput = fullMinus == null || fullMinus == 0; boolean noFullMinusInput = fullMinus == null || fullMinus == 0;
if (noFullMinusInput) { if (noFullMinusInput) {
throw new ServiceException("请填写满减金额"); throw new ServiceException(ResultCode.FULL_DISCOUNT_MONEY_ERROR);
} }
if (fullMinus > fullMoney) { if (fullMinus > fullMoney) {
throw new ServiceException("满减金额不能大于优惠门槛"); throw new ServiceException(ResultCode.FULL_DISCOUNT_MONEY_GREATER_THAN_MINUS);
} }
} }
@ -300,11 +301,11 @@ public class FullDiscountServiceImpl extends ServiceImpl<FullDiscountMapper, Ful
//是否没有填写打折数值 //是否没有填写打折数值
boolean noFullRateInput = fullRate == null || fullRate == 0; boolean noFullRateInput = fullRate == null || fullRate == 0;
if (noFullRateInput) { if (noFullRateInput) {
throw new ServiceException("请填写打折数值"); throw new ServiceException(ResultCode.FULL_RATE_NUM_ERROR);
} }
int rateLimit = 10; int rateLimit = 10;
if (fullRate >= rateLimit || fullRate <= 0) { if (fullRate >= rateLimit || fullRate <= 0) {
throw new ServiceException("请填写打折数值"); throw new ServiceException(ResultCode.FULL_RATE_NUM_ERROR);
} }
} }

View File

@ -53,10 +53,10 @@ public class MemberCouponServiceImpl extends ServiceImpl<MemberCouponMapper, Mem
.eq(MemberCoupon::getMemberId, memberId); .eq(MemberCoupon::getMemberId, memberId);
int haveCoupons = this.count(queryWrapper); int haveCoupons = this.count(queryWrapper);
if (!PromotionStatusEnum.START.name().equals(coupon.getPromotionStatus())) { if (!PromotionStatusEnum.START.name().equals(coupon.getPromotionStatus())) {
throw new ServiceException("当前优惠券状态不可领取"); throw new ServiceException(ResultCode.COUPON_RECEIVE_ERROR);
} }
if (coupon.getPublishNum() != 0 && coupon.getReceivedNum() >= coupon.getPublishNum()) { if (coupon.getPublishNum() != 0 && coupon.getReceivedNum() >= coupon.getPublishNum()) {
throw new ServiceException("优惠券剩余领取数量不足"); throw new ServiceException(ResultCode.COUPON_NUM_INSUFFICIENT_ERROR);
} }
if (haveCoupons >= coupon.getCouponLimitNum()) { if (haveCoupons >= coupon.getCouponLimitNum()) {
throw new ServiceException("此优惠券最多领取" + coupon.getCouponLimitNum() + ""); throw new ServiceException("此优惠券最多领取" + coupon.getCouponLimitNum() + "");
@ -76,7 +76,7 @@ public class MemberCouponServiceImpl extends ServiceImpl<MemberCouponMapper, Mem
this.save(memberCoupon); this.save(memberCoupon);
couponService.receiveCoupon(couponId, 1); couponService.receiveCoupon(couponId, 1);
} else { } else {
throw new ServiceException("当前优惠券不存在"); throw new ServiceException(ResultCode.COUPON_NOT_EXIST);
} }
} }
@ -164,7 +164,7 @@ public class MemberCouponServiceImpl extends ServiceImpl<MemberCouponMapper, Mem
public void updateMemberCouponStatus(MemberCouponStatusEnum status, String id) { public void updateMemberCouponStatus(MemberCouponStatusEnum status, String id) {
MemberCoupon memberCoupon = this.getById(id); MemberCoupon memberCoupon = this.getById(id);
if (memberCoupon == null) { if (memberCoupon == null) {
throw new ServiceException("没有当前会员优惠券!"); throw new ServiceException(ResultCode.COUPON_MEMBER_NOT_EXIST);
} }
String memberCouponStatus = memberCoupon.getMemberCouponStatus(); String memberCouponStatus = memberCoupon.getMemberCouponStatus();
if (memberCouponStatus.equals(MemberCouponStatusEnum.NEW.name()) || memberCouponStatus.equals(MemberCouponStatusEnum.USED.name())) { if (memberCouponStatus.equals(MemberCouponStatusEnum.NEW.name()) || memberCouponStatus.equals(MemberCouponStatusEnum.USED.name())) {
@ -172,7 +172,7 @@ public class MemberCouponServiceImpl extends ServiceImpl<MemberCouponMapper, Mem
updateWrapper.eq(MemberCoupon::getId, id).set(MemberCoupon::getMemberCouponStatus, status.name()); updateWrapper.eq(MemberCoupon::getId, id).set(MemberCoupon::getMemberCouponStatus, status.name());
this.update(updateWrapper); this.update(updateWrapper);
} else { } else {
throw new ServiceException("当前会员优惠券已过期/作废无法变更状态!"); throw new ServiceException(ResultCode.COUPON_MEMBER_STATUS_ERROR);
} }
} }

View File

@ -1,6 +1,7 @@
package cn.lili.modules.promotion.serviceimpl; package cn.lili.modules.promotion.serviceimpl;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.lili.common.enums.ResultCode;
import cn.lili.common.trigger.util.DelayQueueTools; import cn.lili.common.trigger.util.DelayQueueTools;
import cn.lili.common.trigger.enums.DelayTypeEnums; import cn.lili.common.trigger.enums.DelayTypeEnums;
import cn.lili.common.trigger.message.PromotionMessage; import cn.lili.common.trigger.message.PromotionMessage;
@ -154,7 +155,7 @@ public class PintuanServiceImpl extends ServiceImpl<PintuanMapper, Pintuan> impl
PintuanVO pintuanVO = mongoTemplate.findById(id, PintuanVO.class); PintuanVO pintuanVO = mongoTemplate.findById(id, PintuanVO.class);
if (pintuanVO == null) { if (pintuanVO == null) {
log.error("拼团活动id[" + id + "]的拼团活动不存在!"); log.error("拼团活动id[" + id + "]的拼团活动不存在!");
throw new ServiceException("网络出现异常!"); throw new ServiceException(ResultCode.ERROR);
} }
return pintuanVO; return pintuanVO;
} }
@ -170,7 +171,7 @@ public class PintuanServiceImpl extends ServiceImpl<PintuanMapper, Pintuan> impl
Pintuan pintuan = this.getById(id); Pintuan pintuan = this.getById(id);
if (pintuan == null) { if (pintuan == null) {
log.error("拼团活动id[" + id + "]的拼团活动不存在!"); log.error("拼团活动id[" + id + "]的拼团活动不存在!");
throw new ServiceException("网络出现异常!"); throw new ServiceException(ResultCode.ERROR);
} }
return pintuan; return pintuan;
} }
@ -204,7 +205,7 @@ public class PintuanServiceImpl extends ServiceImpl<PintuanMapper, Pintuan> impl
public boolean modifyPintuan(PintuanVO pintuan) { public boolean modifyPintuan(PintuanVO pintuan) {
PintuanVO pintuanVO = this.checkExist(pintuan.getId()); PintuanVO pintuanVO = this.checkExist(pintuan.getId());
if (!pintuan.getPromotionStatus().equals(PromotionStatusEnum.NEW.name())) { if (!pintuan.getPromotionStatus().equals(PromotionStatusEnum.NEW.name())) {
throw new ServiceException("只有活动状态为新活动时(活动未开始)才可编辑!"); throw new ServiceException(ResultCode.PINTUAN_EDIT_ERROR);
} }
//检查促销时间 //检查促销时间
PromotionTools.checkPromotionTime(pintuan.getStartTime().getTime(), pintuan.getEndTime().getTime()); PromotionTools.checkPromotionTime(pintuan.getStartTime().getTime(), pintuan.getEndTime().getTime());
@ -358,7 +359,7 @@ public class PintuanServiceImpl extends ServiceImpl<PintuanMapper, Pintuan> impl
memberVO.setOrderSn(""); memberVO.setOrderSn("");
PromotionGoods promotionGoods = promotionGoodsService.getPromotionGoods(PromotionTypeEnum.PINTUAN, order.getPromotionId(), skuId); PromotionGoods promotionGoods = promotionGoodsService.getPromotionGoods(PromotionTypeEnum.PINTUAN, order.getPromotionId(), skuId);
if (promotionGoods == null) { if (promotionGoods == null) {
throw new ServiceException("当前拼团商品不存在!"); throw new ServiceException(ResultCode.PINTUAN_NOT_EXIST_ERROR);
} }
pintuanShareVO.setPromotionGoods(promotionGoods); pintuanShareVO.setPromotionGoods(promotionGoods);
Pintuan pintuanById = this.getPintuanById(order.getPromotionId()); Pintuan pintuanById = this.getPintuanById(order.getPromotionId());
@ -381,7 +382,7 @@ public class PintuanServiceImpl extends ServiceImpl<PintuanMapper, Pintuan> impl
QueryWrapper<Pintuan> queryWrapper = PromotionTools.checkActiveTime(startTime, endTime, PromotionTypeEnum.PINTUAN, storeId, pintuanId); QueryWrapper<Pintuan> queryWrapper = PromotionTools.checkActiveTime(startTime, endTime, PromotionTypeEnum.PINTUAN, storeId, pintuanId);
List<Pintuan> list = this.list(queryWrapper); List<Pintuan> list = this.list(queryWrapper);
if (!list.isEmpty()) { if (!list.isEmpty()) {
throw new ServiceException("当前时间段已存在相同活动!"); throw new ServiceException(ResultCode.PROMOTION_SAME_ERROR);
} }
} }
@ -484,7 +485,7 @@ public class PintuanServiceImpl extends ServiceImpl<PintuanMapper, Pintuan> impl
private PintuanVO checkExist(String pintuanId) { private PintuanVO checkExist(String pintuanId) {
PintuanVO pintuan = mongoTemplate.findById(pintuanId, PintuanVO.class); PintuanVO pintuan = mongoTemplate.findById(pintuanId, PintuanVO.class);
if (pintuan == null) { if (pintuan == null) {
throw new ServiceException("当前拼团活动不存在!"); throw new ServiceException(ResultCode.PINTUAN_NOT_EXIST_ERROR);
} }
return pintuan; return pintuan;
} }

View File

@ -1,6 +1,7 @@
package cn.lili.modules.promotion.serviceimpl; package cn.lili.modules.promotion.serviceimpl;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.lili.common.enums.ResultCode;
import cn.lili.common.trigger.util.DelayQueueTools; import cn.lili.common.trigger.util.DelayQueueTools;
import cn.lili.common.trigger.enums.DelayTypeEnums; import cn.lili.common.trigger.enums.DelayTypeEnums;
import cn.lili.common.trigger.message.PromotionMessage; import cn.lili.common.trigger.message.PromotionMessage;
@ -108,7 +109,7 @@ public class PointsGoodsServiceImpl extends ServiceImpl<PointsGoodsMapper, Point
pointsGoods.setGoodsSku(goodsSku); pointsGoods.setGoodsSku(goodsSku);
if (this.checkSkuDuplicate(pointsGoods.getSkuId(), pointsGoods.getId()) == null) { if (this.checkSkuDuplicate(pointsGoods.getSkuId(), pointsGoods.getId()) == null) {
if (PromotionStatusEnum.START.name().equals(pointsGoods.getPromotionStatus()) || PromotionStatusEnum.END.name().equals(pointsGoods.getPromotionStatus())) { if (PromotionStatusEnum.START.name().equals(pointsGoods.getPromotionStatus()) || PromotionStatusEnum.END.name().equals(pointsGoods.getPromotionStatus())) {
throw new ServiceException("当前活动已开始/结束,无法编辑!"); throw new ServiceException(ResultCode.PROMOTION_UPDATE_ERROR);
} }
PromotionTools.checkPromotionTime(pointsGoods.getStartTime().getTime(), pointsGoods.getEndTime().getTime()); PromotionTools.checkPromotionTime(pointsGoods.getStartTime().getTime(), pointsGoods.getEndTime().getTime());
result = this.updateById(pointsGoods); result = this.updateById(pointsGoods);
@ -304,7 +305,7 @@ public class PointsGoodsServiceImpl extends ServiceImpl<PointsGoodsMapper, Point
*/ */
private void checkParam(PointsGoods pointsGoods, GoodsSku goodsSku) { private void checkParam(PointsGoods pointsGoods, GoodsSku goodsSku) {
if (pointsGoods.getActiveStock() > goodsSku.getQuantity()) { if (pointsGoods.getActiveStock() > goodsSku.getQuantity()) {
throw new ServiceException("活动库存数量不能高于商品库存"); throw new ServiceException(ResultCode.POINT_GOODS_ACTIVE_STOCK_ERROR);
} }
} }
} }

View File

@ -1,6 +1,8 @@
package cn.lili.modules.promotion.serviceimpl; package cn.lili.modules.promotion.serviceimpl;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.text.CharSequenceUtil; import cn.hutool.core.text.CharSequenceUtil;
import cn.lili.common.enums.ResultCode;
import cn.lili.common.exception.ServiceException; import cn.lili.common.exception.ServiceException;
import cn.lili.common.utils.BeanUtil; import cn.lili.common.utils.BeanUtil;
import cn.lili.common.utils.DateUtil; import cn.lili.common.utils.DateUtil;
@ -269,10 +271,10 @@ public class PromotionGoodsServiceImpl extends ServiceImpl<PromotionGoodsMapper,
PromotionGoods promotionGoods = this.getPromotionGoods(typeEnum, promotionId, skuId); PromotionGoods promotionGoods = this.getPromotionGoods(typeEnum, promotionId, skuId);
if (promotionGoods == null) { if (promotionGoods == null) {
throw new ServiceException("当前促销商品不存在!"); throw new ServiceException(ResultCode.PROMOTION_GOODS_NOT_EXIT);
} }
if (promotionGoodsStock != null && CharSequenceUtil.isNotEmpty(promotionGoodsStock) && promotionGoods.getQuantity() == Integer.parseInt(promotionGoodsStock)) { if (promotionGoodsStock != null && CharSequenceUtil.isNotEmpty(promotionGoodsStock) && promotionGoods.getQuantity() == Convert.toInt(promotionGoodsStock)) {
return Integer.parseInt(promotionGoodsStock); return Convert.toInt(promotionGoodsStock);
} else { } else {
stringRedisTemplate.opsForValue().set(promotionStockKey, promotionGoods.getQuantity().toString()); stringRedisTemplate.opsForValue().set(promotionStockKey, promotionGoods.getQuantity().toString());
return promotionGoods.getQuantity(); return promotionGoods.getQuantity();
@ -310,7 +312,7 @@ public class PromotionGoodsServiceImpl extends ServiceImpl<PromotionGoodsMapper,
queryWrapper.eq(SeckillApply::getSeckillId, promotionId).eq(SeckillApply::getSkuId, skuId); queryWrapper.eq(SeckillApply::getSeckillId, promotionId).eq(SeckillApply::getSkuId, skuId);
SeckillApply seckillApply = seckillApplyService.getOne(queryWrapper); SeckillApply seckillApply = seckillApplyService.getOne(queryWrapper);
if (seckillApply == null) { if (seckillApply == null) {
throw new ServiceException("当前秒杀活动商品不存在!"); throw new ServiceException(ResultCode.SECKILL_NOT_EXIST_ERROR);
} }
LambdaUpdateWrapper<SeckillApply> updateWrapper = new LambdaUpdateWrapper<>(); LambdaUpdateWrapper<SeckillApply> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.eq(SeckillApply::getSeckillId, promotionId).eq(SeckillApply::getSkuId, skuId); updateWrapper.eq(SeckillApply::getSeckillId, promotionId).eq(SeckillApply::getSkuId, skuId);

View File

@ -3,6 +3,7 @@ package cn.lili.modules.promotion.serviceimpl;
import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateTime;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import cn.lili.common.enums.ResultCode;
import cn.lili.common.trigger.message.PromotionMessage; import cn.lili.common.trigger.message.PromotionMessage;
import cn.lili.common.exception.ServiceException; import cn.lili.common.exception.ServiceException;
import cn.lili.common.utils.DateUtil; import cn.lili.common.utils.DateUtil;
@ -452,6 +453,6 @@ public class PromotionServiceImpl implements PromotionService {
*/ */
private void throwPromotionException(PromotionTypeEnum type, String id, String status) { private void throwPromotionException(PromotionTypeEnum type, String id, String status) {
log.error("当前" + type.name() + "活动ID为[" + id + "] 不存在,更改活动状态至[ " + status + " ]失败!"); log.error("当前" + type.name() + "活动ID为[" + id + "] 不存在,更改活动状态至[ " + status + " ]失败!");
throw new ServiceException("当前活动已停止"); throw new ServiceException(ResultCode.PROMOTION_STATUS_END);
} }
} }

View File

@ -2,10 +2,12 @@ package cn.lili.modules.promotion.serviceimpl;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.text.CharSequenceUtil; import cn.hutool.core.text.CharSequenceUtil;
import cn.lili.common.cache.Cache; import cn.lili.common.cache.Cache;
import cn.lili.common.enums.ResultCode;
import cn.lili.common.exception.ServiceException; import cn.lili.common.exception.ServiceException;
import cn.lili.common.vo.PageVO; import cn.lili.common.vo.PageVO;
import cn.lili.modules.goods.entity.dos.GoodsSku; import cn.lili.modules.goods.entity.dos.GoodsSku;
@ -102,7 +104,7 @@ public class SeckillApplyServiceImpl extends ServiceImpl<SeckillApplyMapper, Sec
} else { } else {
//如缓存中存在则取缓存中转为展示的信息 //如缓存中存在则取缓存中转为展示的信息
for (Map.Entry<Object, Object> entry : cacheSeckill.entrySet()) { for (Map.Entry<Object, Object> entry : cacheSeckill.entrySet()) {
Integer timelineKey = Integer.parseInt(entry.getKey().toString()); Integer timelineKey = Convert.toInt(entry.getKey().toString());
if (timelineKey.equals(timeline)) { if (timelineKey.equals(timeline)) {
seckillGoodsVoS = (List<SeckillGoodsVO>) entry.getValue(); seckillGoodsVoS = (List<SeckillGoodsVO>) entry.getValue();
} }
@ -145,7 +147,7 @@ public class SeckillApplyServiceImpl extends ServiceImpl<SeckillApplyMapper, Sec
public void addSeckillApply(String seckillId, String storeId, List<SeckillApplyVO> seckillApplyList) { public void addSeckillApply(String seckillId, String storeId, List<SeckillApplyVO> seckillApplyList) {
SeckillVO seckill = mongoTemplate.findById(seckillId, SeckillVO.class); SeckillVO seckill = mongoTemplate.findById(seckillId, SeckillVO.class);
if (seckill == null) { if (seckill == null) {
throw new ServiceException("当前参与的秒杀活动不存在!"); throw new ServiceException(ResultCode.SECKILL_NOT_EXIST_ERROR);
} }
//检查秒杀活动申请是否合法 //检查秒杀活动申请是否合法
checkSeckillApplyList(seckill.getHours(), seckillApplyList, storeId); checkSeckillApplyList(seckill.getHours(), seckillApplyList, storeId);
@ -199,10 +201,10 @@ public class SeckillApplyServiceImpl extends ServiceImpl<SeckillApplyMapper, Sec
public void removeSeckillApplyByIds(String seckillId, List<String> ids) { public void removeSeckillApplyByIds(String seckillId, List<String> ids) {
SeckillVO seckillVO = this.mongoTemplate.findById(seckillId, SeckillVO.class); SeckillVO seckillVO = this.mongoTemplate.findById(seckillId, SeckillVO.class);
if (seckillVO == null) { if (seckillVO == null) {
throw new ServiceException("当前秒杀活动活动不存在!"); throw new ServiceException(ResultCode.SECKILL_NOT_EXIST_ERROR);
} }
if (seckillVO.getPromotionStatus().equals(PromotionStatusEnum.START.name())) { if (seckillVO.getPromotionStatus().equals(PromotionStatusEnum.START.name())) {
throw new ServiceException("当前秒杀活动活动已经开始,无法修改!"); throw new ServiceException(ResultCode.SECKILL_UPDATE_ERROR);
} }
seckillVO.getSeckillApplyList().removeIf(seckillApply -> ids.contains(seckillApply.getId())); seckillVO.getSeckillApplyList().removeIf(seckillApply -> ids.contains(seckillApply.getId()));
this.mongoTemplate.save(seckillVO); this.mongoTemplate.save(seckillVO);
@ -221,13 +223,13 @@ public class SeckillApplyServiceImpl extends ServiceImpl<SeckillApplyMapper, Sec
for (SeckillApplyVO seckillApply : seckillApplyList) { for (SeckillApplyVO seckillApply : seckillApplyList) {
seckillApply.setStoreId(storeId); seckillApply.setStoreId(storeId);
if (seckillApply.getPrice() > seckillApply.getOriginalPrice()) { if (seckillApply.getPrice() > seckillApply.getOriginalPrice()) {
throw new ServiceException("活动价格不能大于商品原价"); throw new ServiceException(ResultCode.SECKILL_PRICE_ERROR);
} }
//检查秒杀活动申请的时刻是否存在在秒杀活动的时间段内 //检查秒杀活动申请的时刻是否存在在秒杀活动的时间段内
String[] rangeHours = hours.split(","); String[] rangeHours = hours.split(",");
boolean containsSame = Arrays.stream(rangeHours).anyMatch(i -> i.equals(seckillApply.getTimeLine().toString())); boolean containsSame = Arrays.stream(rangeHours).anyMatch(i -> i.equals(seckillApply.getTimeLine().toString()));
if (!containsSame) { if (!containsSame) {
throw new ServiceException("时刻参数异常"); throw new ServiceException(ResultCode.SECKILL_TIME_ERROR);
} }
//检查商品是否参加多个时间段的活动 //检查商品是否参加多个时间段的活动
if (existSku.contains(seckillApply.getSkuId())) { if (existSku.contains(seckillApply.getSkuId())) {

View File

@ -1,5 +1,6 @@
package cn.lili.modules.promotion.serviceimpl; package cn.lili.modules.promotion.serviceimpl;
import cn.lili.common.enums.ResultCode;
import cn.lili.common.trigger.util.DelayQueueTools; import cn.lili.common.trigger.util.DelayQueueTools;
import cn.lili.common.trigger.enums.DelayTypeEnums; import cn.lili.common.trigger.enums.DelayTypeEnums;
import cn.lili.common.trigger.message.PromotionMessage; import cn.lili.common.trigger.message.PromotionMessage;
@ -153,7 +154,7 @@ public class SeckillServiceImpl extends ServiceImpl<SeckillMapper, Seckill> impl
//检查该秒杀活动是否存在 //检查该秒杀活动是否存在
SeckillVO seckill = checkSeckillExist(seckillVO.getId()); SeckillVO seckill = checkSeckillExist(seckillVO.getId());
if (PromotionStatusEnum.START.name().equals(seckillVO.getPromotionStatus())) { if (PromotionStatusEnum.START.name().equals(seckillVO.getPromotionStatus())) {
throw new ServiceException("活动已经开始,不能进行编辑删除操作"); throw new ServiceException(ResultCode.PROMOTION_UPDATE_ERROR);
} }
//检查秒杀活动参数 //检查秒杀活动参数
this.checkSeckillParam(seckillVO, seckillVO.getStoreId()); this.checkSeckillParam(seckillVO, seckillVO.getStoreId());
@ -193,7 +194,7 @@ public class SeckillServiceImpl extends ServiceImpl<SeckillMapper, Seckill> impl
DelayQueueTools.wrapperUniqueKey(DelayTypeEnums.PROMOTION, (PromotionTypeEnum.SECKILL.name() + seckill.getId())), DelayQueueTools.wrapperUniqueKey(DelayTypeEnums.PROMOTION, (PromotionTypeEnum.SECKILL.name() + seckill.getId())),
rocketmqCustomProperties.getPromotionTopic()); rocketmqCustomProperties.getPromotionTopic());
} else { } else {
throw new ServiceException("该秒杀活动活动的状态不能删除"); throw new ServiceException(ResultCode.SECKILL_DELETE_ERROR);
} }
} }
@ -237,7 +238,7 @@ public class SeckillServiceImpl extends ServiceImpl<SeckillMapper, Seckill> impl
rocketmqCustomProperties.getPromotionTopic()); rocketmqCustomProperties.getPromotionTopic());
} }
} else { } else {
throw new ServiceException("该秒杀活动活动的状态不能关闭"); throw new ServiceException(ResultCode.SECKILL_CLOSE_ERROR);
} }
} }
@ -279,7 +280,7 @@ public class SeckillServiceImpl extends ServiceImpl<SeckillMapper, Seckill> impl
private SeckillVO checkSeckillExist(String id) { private SeckillVO checkSeckillExist(String id) {
SeckillVO seckill = this.mongoTemplate.findById(id, SeckillVO.class); SeckillVO seckill = this.mongoTemplate.findById(id, SeckillVO.class);
if (seckill == null) { if (seckill == null) {
throw new ServiceException("当前秒杀活动活动不存在"); throw new ServiceException(ResultCode.SECKILL_NOT_EXIST_ERROR);
} }
return seckill; return seckill;
} }

View File

@ -1,6 +1,7 @@
package cn.lili.modules.promotion.tools; package cn.lili.modules.promotion.tools;
import cn.hutool.core.text.CharSequenceUtil; import cn.hutool.core.text.CharSequenceUtil;
import cn.lili.common.enums.ResultCode;
import cn.lili.common.exception.ServiceException; import cn.lili.common.exception.ServiceException;
import cn.lili.common.utils.DateUtil; import cn.lili.common.utils.DateUtil;
import cn.lili.common.vo.PageVO; import cn.lili.common.vo.PageVO;
@ -41,7 +42,7 @@ public class PromotionTools {
//如果促销活动选择的是部分商品参加活动 //如果促销活动选择的是部分商品参加活动
if (num != -1 && goodsList == null) { if (num != -1 && goodsList == null) {
throw new ServiceException("请选择要参与活动的商品"); throw new ServiceException(ResultCode.PROMOTION_GOODS_ERROR);
} }
} }
@ -59,12 +60,12 @@ public class PromotionTools {
//如果活动起始时间小于现在时间 //如果活动起始时间小于现在时间
if (startTime < nowTime) { if (startTime < nowTime) {
throw new ServiceException("活动起始时间必须大于当前时间"); throw new ServiceException(ResultCode.PROMOTION_START_TIME_ERROR);
} }
//开始时间不能大于结束时间 //开始时间不能大于结束时间
if (startTime > endTime) { if (startTime > endTime) {
throw new ServiceException("活动起始时间不能大于活动结束时间"); throw new ServiceException(ResultCode.PROMOTION_TIME_ERROR);
} }
} }

View File

@ -1,5 +1,6 @@
package cn.lili.modules.search.serviceimpl; package cn.lili.modules.search.serviceimpl;
import cn.lili.common.enums.ResultCode;
import cn.lili.common.exception.ServiceException; import cn.lili.common.exception.ServiceException;
import cn.lili.common.utils.PageUtil; import cn.lili.common.utils.PageUtil;
import cn.lili.common.vo.PageVO; import cn.lili.common.vo.PageVO;
@ -63,7 +64,7 @@ public class CustomWordsServiceImpl extends ServiceImpl<CustomWordsMapper, Custo
@Override @Override
public boolean addCustomWords(CustomWordsVO customWordsVO) { public boolean addCustomWords(CustomWordsVO customWordsVO) {
if (this.existWords(customWordsVO.getName())) { if (this.existWords(customWordsVO.getName())) {
throw new ServiceException("当前自定义分词已存在!"); throw new ServiceException(ResultCode.CUSTOM_WORDS_EXIST_ERROR);
} }
return this.save(customWordsVO); return this.save(customWordsVO);
} }
@ -77,7 +78,7 @@ public class CustomWordsServiceImpl extends ServiceImpl<CustomWordsMapper, Custo
@Override @Override
public boolean deleteCustomWords(String id) { public boolean deleteCustomWords(String id) {
if (this.getById(id) == null) { if (this.getById(id) == null) {
throw new ServiceException("当前自定义分词不存在!"); throw new ServiceException(ResultCode.CUSTOM_WORDS_NOT_EXIST_ERROR);
} }
return this.removeById(id); return this.removeById(id);
} }
@ -91,7 +92,7 @@ public class CustomWordsServiceImpl extends ServiceImpl<CustomWordsMapper, Custo
@Override @Override
public boolean updateCustomWords(CustomWordsVO customWordsVO) { public boolean updateCustomWords(CustomWordsVO customWordsVO) {
if (this.getById(customWordsVO.getId()) == null) { if (this.getById(customWordsVO.getId()) == null) {
throw new ServiceException("当前自定义分词不存在!"); throw new ServiceException(ResultCode.CUSTOM_WORDS_NOT_EXIST_ERROR);
} }
return this.updateById(customWordsVO); return this.updateById(customWordsVO);
} }

View File

@ -1,5 +1,6 @@
package cn.lili.modules.statistics.serviceimpl; package cn.lili.modules.statistics.serviceimpl;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateTime;
import cn.lili.common.security.context.UserContext; import cn.lili.common.security.context.UserContext;
import cn.lili.common.security.enums.UserEnums; import cn.lili.common.security.enums.UserEnums;
@ -195,7 +196,7 @@ public class IndexStatisticsServiceImpl implements IndexStatisticsService {
storeIndexStatisticsVO.setGoodsNum(goodsService.goodsNum(GoodsStatusEnum.UPPER, null)); storeIndexStatisticsVO.setGoodsNum(goodsService.goodsNum(GoodsStatusEnum.UPPER, null));
//订单总数量订单总金额 //订单总数量订单总金额
Map<String, Object> map = orderStatisticsDataService.getStoreOrderStatisticsPrice(); Map<String, Object> map = orderStatisticsDataService.getStoreOrderStatisticsPrice();
storeIndexStatisticsVO.setOrderNum(Integer.parseInt(map.get("num").toString())); storeIndexStatisticsVO.setOrderNum(Convert.toInt(map.get("num").toString()));
storeIndexStatisticsVO.setOrderPrice(map.get("price") != null ? Double.parseDouble(map.get("price").toString()) : 0.0); storeIndexStatisticsVO.setOrderPrice(map.get("price") != null ? Double.parseDouble(map.get("price").toString()) : 0.0);
//访问量 //访问量

View File

@ -1,6 +1,7 @@
package cn.lili.modules.system.serviceimpl; package cn.lili.modules.system.serviceimpl;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.lili.common.enums.ResultCode;
import cn.lili.common.enums.SwitchEnum; import cn.lili.common.enums.SwitchEnum;
import cn.lili.common.exception.ServiceException; import cn.lili.common.exception.ServiceException;
import cn.lili.modules.system.entity.dos.Logistics; import cn.lili.modules.system.entity.dos.Logistics;
@ -72,7 +73,7 @@ public class LogisticsServiceImpl extends ServiceImpl<LogisticsMapper, Logistics
private Traces getOrderTracesByJson(String logisticsId, String expNo) throws Exception { private Traces getOrderTracesByJson(String logisticsId, String expNo) throws Exception {
Setting setting = settingService.get(SettingEnum.KUAIDI_SETTING.name()); Setting setting = settingService.get(SettingEnum.KUAIDI_SETTING.name());
if (StrUtil.isBlank(setting.getSettingValue())) { if (StrUtil.isBlank(setting.getSettingValue())) {
throw new ServiceException("您还未配置快递查询"); throw new ServiceException(ResultCode.LOGISTICS_NOT_SETTING);
} }
KuaidiSetting kuaidiSetting = new Gson().fromJson(setting.getSettingValue(), KuaidiSetting.class); KuaidiSetting kuaidiSetting = new Gson().fromJson(setting.getSettingValue(), KuaidiSetting.class);

View File

@ -8,14 +8,14 @@
<parent> <parent>
<groupId>cn.lili</groupId> <groupId>cn.lili</groupId>
<artifactId>lili-shop-parent</artifactId> <artifactId>lili-shop-parent</artifactId>
<version>1.0.1</version> <version>4.2.0</version>
</parent> </parent>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>cn.lili</groupId> <groupId>cn.lili</groupId>
<artifactId>framework</artifactId> <artifactId>framework</artifactId>
<version>1.0.1</version> <version>4.2.0</version>
</dependency> </dependency>
</dependencies> </dependencies>

View File

@ -47,7 +47,7 @@ public class MemberWithdrawApplyManagerController {
@ApiOperation(value = "提现申请审核") @ApiOperation(value = "提现申请审核")
@PostMapping @PostMapping
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(name = "apply_id", value = "审核记录id", required = true, paramType = "query"), @ApiImplicitParam(name = "applyId", value = "审核记录id", required = true, paramType = "query"),
@ApiImplicitParam(name = "result", value = "审核结果", required = true, paramType = "query", dataType = "boolean"), @ApiImplicitParam(name = "result", value = "审核结果", required = true, paramType = "query", dataType = "boolean"),
@ApiImplicitParam(name = "remark", value = "审核备注", paramType = "query") @ApiImplicitParam(name = "remark", value = "审核备注", paramType = "query")
}) })

View File

@ -1,5 +1,6 @@
package cn.lili.controller.other; package cn.lili.controller.other;
import cn.lili.common.enums.ResultCode;
import cn.lili.common.exception.ServiceException; import cn.lili.common.exception.ServiceException;
import cn.lili.common.utils.StringUtils; import cn.lili.common.utils.StringUtils;
import cn.lili.modules.permission.SettingKeys; import cn.lili.modules.permission.SettingKeys;
@ -49,7 +50,7 @@ public class CustomWordsController {
} }
if (!setting.getSettingValue().equals(secretKey)) { if (!setting.getSettingValue().equals(secretKey)) {
throw new ServiceException("秘钥验证失败!"); throw new ServiceException(ResultCode.CUSTOM_WORDS_SECRET_KEY_ERROR);
} }
String res = customWordsService.deploy(); String res = customWordsService.deploy();

View File

@ -112,7 +112,7 @@ public class CouponManagerController {
private void setStoreInfo(CouponVO couponVO) { private void setStoreInfo(CouponVO couponVO) {
AuthUser currentUser = UserContext.getCurrentUser(); AuthUser currentUser = UserContext.getCurrentUser();
if (currentUser == null) { if (currentUser == null) {
throw new ServiceException("获取当前用户信息不存在"); throw new ServiceException(ResultCode.USER_NOT_EXIST);
} }
couponVO.setStoreId("platform"); couponVO.setStoreId("platform");
couponVO.setStoreName("platform"); couponVO.setStoreName("platform");

View File

@ -12,11 +12,11 @@
<groupId>cn.lili</groupId> <groupId>cn.lili</groupId>
<artifactId>lili-shop-parent</artifactId> <artifactId>lili-shop-parent</artifactId>
<version>1.0.1</version> <version>4.2.0</version>
<properties> <properties>
<docker-registry>registry.cn-beijing.aliyuncs.com/lili-images</docker-registry> <docker-registry>registry.cn-beijing.aliyuncs.com/lili-images</docker-registry>
<images-version>0.0.5</images-version> <images-version>0.0.1</images-version>
</properties> </properties>
<modules> <modules>
<module>framework</module> <module>framework</module>

View File

@ -8,14 +8,14 @@
<parent> <parent>
<groupId>cn.lili</groupId> <groupId>cn.lili</groupId>
<artifactId>lili-shop-parent</artifactId> <artifactId>lili-shop-parent</artifactId>
<version>1.0.1</version> <version>4.2.0</version>
</parent> </parent>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>cn.lili</groupId> <groupId>cn.lili</groupId>
<artifactId>framework</artifactId> <artifactId>framework</artifactId>
<version>1.0.1</version> <version>4.2.0</version>
</dependency> </dependency>
</dependencies> </dependencies>

View File

@ -10,6 +10,7 @@ ALTER TABLE li_goods DROP COLUMN freight_payer;
/**添加商品类型**/ /**添加商品类型**/
ALTER TABLE li_goods ADD goods_type VARCHAR ( 32 ); ALTER TABLE li_goods ADD goods_type VARCHAR ( 32 );
ALTER TABLE li_goods_sku ADD goods_type VARCHAR ( 32 ); ALTER TABLE li_goods_sku ADD goods_type VARCHAR ( 32 );
ALTER TABLE li_specification ADD spec_value text;
UPDATE li_goods SET goods_type = "PHYSICAL_GOODS"; UPDATE li_goods SET goods_type = "PHYSICAL_GOODS";
UPDATE li_goods_sku SET goods_type = "PHYSICAL_GOODS"; UPDATE li_goods_sku SET goods_type = "PHYSICAL_GOODS";
/**增加优惠券有效期类型**/ /**增加优惠券有效期类型**/
@ -118,4 +119,6 @@ CREATE TABLE `li_coupon_activity_item` (
/** 修改商品模板详情字段类型**/ /** 修改商品模板详情字段类型**/
ALTER TABLE `li_draft_goods` MODIFY COLUMN `intro` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL; ALTER TABLE `li_draft_goods` MODIFY COLUMN `intro` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;
/** 添加秒杀设置**/ /** 添加秒杀设置**/
INSERT INTO `li_setting` ( `id`, `create_by`, `create_time`, `delete_flag`, `update_by`, `update_time`, `setting_value` ) VALUES ( 'SECKILL_SETTING', NULL, NULL, NULL, 'admin', '2021-06-04 09:58:39.384000', '{\"seckillRule\":\"秒杀规则\",\"hours\":\"9,10,11,12,13,14,15,21,22,23\"}' ); INSERT INTO `li_setting` ( `id`, `create_by`, `create_time`, `delete_flag`, `update_by`, `update_time`, `setting_value` ) VALUES ( 'SECKILL_SETTING', NULL, NULL, NULL, 'admin', '2021-06-04 09:58:39.384000', '{\"seckillRule\":\"秒杀规则\",\"hours\":\"9,10,11,12,13,14,15,21,22,23\"}' );
/** 添加直播间商品默认数量**/
alter table li_studio alter column room_goods_num set default 0;

View File

@ -0,0 +1,7 @@
/** 添加分销员结算信息**/
ALTER TABLE li_distribution ADD settlement_bank_account_name varchar ( 200 );
ALTER TABLE li_distribution ADD settlement_bank_account_num varchar ( 200 );
ALTER TABLE li_distribution ADD settlement_bank_branch_name varchar ( 200 );
/** 文章分类添加默认值**/
ALTER TABLE li_article_category alter column sort set default 0;