diff --git a/admin/pom.xml b/admin/pom.xml index e188f455..e2b538db 100644 --- a/admin/pom.xml +++ b/admin/pom.xml @@ -6,7 +6,7 @@ cn.lili lili-shop-parent - 1.0.1 + 4.2.0 admin diff --git a/buyer-api/pom.xml b/buyer-api/pom.xml index 7499e497..22afda90 100644 --- a/buyer-api/pom.xml +++ b/buyer-api/pom.xml @@ -10,14 +10,14 @@ cn.lili lili-shop-parent - 1.0.1 + 4.2.0 cn.lili framework - 1.0.1 + 4.2.0 diff --git a/buyer-api/src/main/java/cn/lili/controller/member/MemberMessageBuyerController.java b/buyer-api/src/main/java/cn/lili/controller/member/MemberMessageBuyerController.java index 1dae47d7..0ca41606 100644 --- a/buyer-api/src/main/java/cn/lili/controller/member/MemberMessageBuyerController.java +++ b/buyer-api/src/main/java/cn/lili/controller/member/MemberMessageBuyerController.java @@ -1,6 +1,7 @@ package cn.lili.controller.member; import cn.lili.common.enums.ResultUtil; +import cn.lili.common.security.context.UserContext; import cn.lili.common.vo.PageVO; import cn.lili.common.vo.ResultMessage; import cn.lili.modules.message.entity.enums.MessageStatusEnum; @@ -34,21 +35,23 @@ public class MemberMessageBuyerController { @ApiOperation(value = "分页获取会员站内消息") @GetMapping public ResultMessage> page(MemberMessageQueryVO memberMessageQueryVO, PageVO page) { + memberMessageQueryVO.setMemberId(UserContext.getCurrentUser().getId()); return ResultUtil.data(memberMessageService.getPage(memberMessageQueryVO, page)); } @ApiOperation(value = "消息已读") @ApiImplicitParam(name = "messageId", value = "会员消息id", required = true, paramType = "path") - @PutMapping - public ResultMessage read(@PathVariable String messageId) { + @PutMapping("/{message_id}") + public ResultMessage read(@PathVariable("message_id") String messageId) { return ResultUtil.data(memberMessageService.editStatus(MessageStatusEnum.ALREADY_READY.name(), messageId)); } - @ApiOperation(value = "消息删除") + @ApiOperation(value = "消息放入回收站") @ApiImplicitParam(name = "messageId", value = "会员消息id", required = true, paramType = "path") - @DeleteMapping - public ResultMessage deleteMessage(@PathVariable String messageId) { - return ResultUtil.data(memberMessageService.deleteMessage(messageId)); + @DeleteMapping("/{message_id}") + public ResultMessage deleteMessage(@PathVariable("message_id") String messageId) { + return ResultUtil.data(memberMessageService.editStatus(MessageStatusEnum.ALREADY_REMOVE.name(), messageId)); + } diff --git a/buyer-api/src/main/java/cn/lili/controller/other/distribution/DistributionBuyerController.java b/buyer-api/src/main/java/cn/lili/controller/other/distribution/DistributionBuyerController.java index 410601c2..fd9bbe3a 100644 --- a/buyer-api/src/main/java/cn/lili/controller/other/distribution/DistributionBuyerController.java +++ b/buyer-api/src/main/java/cn/lili/controller/other/distribution/DistributionBuyerController.java @@ -53,7 +53,7 @@ public class DistributionBuyerController { @ApiOperation(value = "获取分销员分页订单列表") @GetMapping("/distributionOrder") public ResultMessage> distributionOrderPage(DistributionOrderSearchParams distributionOrderSearchParams) { - distributionOrderSearchParams.setDistributionId(UserContext.getCurrentUser().getId()); + distributionOrderSearchParams.setDistributionId(distributionService.getDistribution().getId()); return ResultUtil.data(distributionOrderService.getDistributionOrderPage(distributionOrderSearchParams)); } diff --git a/buyer-api/src/main/java/cn/lili/controller/passport/MemberBuyerController.java b/buyer-api/src/main/java/cn/lili/controller/passport/MemberBuyerController.java index d909135c..a9981b3d 100644 --- a/buyer-api/src/main/java/cn/lili/controller/passport/MemberBuyerController.java +++ b/buyer-api/src/main/java/cn/lili/controller/passport/MemberBuyerController.java @@ -63,9 +63,9 @@ public class MemberBuyerController { public ResultMessage smsLogin(@NotNull(message = "手机号为空") @RequestParam String mobile, @NotNull(message = "验证码为空") @RequestParam String code, @RequestHeader String uuid) { - if(smsUtil.verifyCode(mobile,VerificationEnums.LOGIN,uuid,code)){ - return ResultUtil.data(memberService.mobilePhoneLogin(mobile)); - }else { + if (smsUtil.verifyCode(mobile, VerificationEnums.LOGIN, uuid, code)) { + return ResultUtil.data(memberService.mobilePhoneLogin(mobile)); + } else { throw new ServiceException("验证码错误"); } } diff --git a/buyer-api/src/main/java/cn/lili/controller/payment/CashierController.java b/buyer-api/src/main/java/cn/lili/controller/payment/CashierController.java index 30117fee..0ba33e91 100644 --- a/buyer-api/src/main/java/cn/lili/controller/payment/CashierController.java +++ b/buyer-api/src/main/java/cn/lili/controller/payment/CashierController.java @@ -2,6 +2,7 @@ package cn.lili.controller.payment; import cn.lili.common.enums.ResultCode; import cn.lili.common.enums.ResultUtil; +import cn.lili.common.exception.ServiceException; import cn.lili.common.vo.ResultMessage; import cn.lili.modules.payment.kit.CashierSupport; import cn.lili.modules.payment.kit.dto.PayParam; @@ -64,8 +65,11 @@ public class CashierController { try { return cashierSupport.payment(paymentMethodEnum, paymentClientEnum, request, response, payParam); + } catch (ServiceException se) { + log.info("支付异常", se); + throw se; } catch (Exception e) { - log.error("收银台支付错误",e); + log.error("收银台支付错误", e); } return null; diff --git a/buyer-api/src/main/java/cn/lili/controller/trade/WalletLogBuyerController.java b/buyer-api/src/main/java/cn/lili/controller/trade/WalletLogBuyerController.java index 3da33ba4..aabb6b58 100644 --- a/buyer-api/src/main/java/cn/lili/controller/trade/WalletLogBuyerController.java +++ b/buyer-api/src/main/java/cn/lili/controller/trade/WalletLogBuyerController.java @@ -37,7 +37,8 @@ public class WalletLogBuyerController { //获取当前登录用户 AuthUser authUser = UserContext.getCurrentUser(); //构建查询 返回数据 - IPage depositLogPage = walletLogService.page(PageUtil.initPage(page), new QueryWrapper().eq("member_id", authUser.getId())); + IPage depositLogPage = walletLogService.page(PageUtil.initPage(page), + new QueryWrapper().eq("member_id", authUser.getId()).orderByDesc("create_time")); return ResultUtil.data(depositLogPage); } } diff --git a/common-api/pom.xml b/common-api/pom.xml index 4e5c7d8d..fe5a4ae7 100644 --- a/common-api/pom.xml +++ b/common-api/pom.xml @@ -7,7 +7,7 @@ cn.lili lili-shop-parent - 1.0.1 + 4.2.0 cn.lili @@ -17,7 +17,7 @@ cn.lili framework - 1.0.1 + 4.2.0 diff --git a/config/application.yml b/config/application.yml index 5a9316c8..0e645d6b 100644 --- a/config/application.yml +++ b/config/application.yml @@ -77,7 +77,7 @@ spring: default-datasource: type: com.alibaba.druid.pool.DruidDataSource 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 password: lilishop maxActive: 20 @@ -194,9 +194,9 @@ logging: # 输出级别 level: cn.lili: info - # org.hibernate: debug - # org.springframework: debug - # org.springframework.data.mongodb.core: debug + org.hibernate: debug + org.springframework: debug + org.springframework.data.mongodb.core: debug file: # 指定路径 path: lili-logs diff --git a/consumer/pom.xml b/consumer/pom.xml index dd25a81b..b9b34c24 100644 --- a/consumer/pom.xml +++ b/consumer/pom.xml @@ -8,14 +8,14 @@ cn.lili lili-shop-parent - 1.0.1 + 4.2.0 cn.lili framework - 1.0.1 + 4.2.0 diff --git a/consumer/src/main/java/cn/lili/event/impl/NoticeMessageExecute.java b/consumer/src/main/java/cn/lili/event/impl/NoticeMessageExecute.java index 3b63bdd8..e3346136 100644 --- a/consumer/src/main/java/cn/lili/event/impl/NoticeMessageExecute.java +++ b/consumer/src/main/java/cn/lili/event/impl/NoticeMessageExecute.java @@ -59,7 +59,7 @@ public class NoticeMessageExecute implements TradeEvent, OrderStatusChangeEvent, //如果订单状态不为空 if (orderDetailVO != null) { Map params = new HashMap<>(); - switch (orderMessage.getNewStatus()){ + switch (orderMessage.getNewStatus()) { //如果订单新的状态为已取消 则发送取消订单站内信 case CANCELLED: params.put(NoticeMessageParameterEnum.CANCEL_REASON.getType(), orderDetailVO.getOrder().getCancelReason()); @@ -82,7 +82,7 @@ public class NoticeMessageExecute implements TradeEvent, OrderStatusChangeEvent, break; //如果是拼团订单,发送拼团成功消息 case UNDELIVERED: - if(orderDetailVO.getOrder().getOrderPromotionType().equals(OrderPromotionTypeEnum.PINTUAN.name())){ + if (OrderPromotionTypeEnum.PINTUAN.name().equals(orderDetailVO.getOrder().getOrderPromotionType())) { //拼团成功消息 noticeMessageDTO.setNoticeMessageNodeEnum(NoticeMessageNodeEnum.PINTUAN_SUCCESS); } @@ -148,11 +148,14 @@ public class NoticeMessageExecute implements TradeEvent, OrderStatusChangeEvent, @Override public void memberPointChange(MemberPointMessage memberPointMessage) { + if (memberPointMessage == null) { + return; + } //组织站内信参数 NoticeMessageDTO noticeMessageDTO = new NoticeMessageDTO(); noticeMessageDTO.setMemberId(memberPointMessage.getMemberId()); Map params = new HashMap<>(); - if (memberPointMessage.getType().equals(1)) { + if (memberPointMessage.getType()) { params.put("expenditure_points", "0"); params.put("income_points", memberPointMessage.getPoint().toString()); } else { diff --git a/consumer/src/main/java/cn/lili/event/impl/VerificationOrderExecute.java b/consumer/src/main/java/cn/lili/event/impl/VerificationOrderExecute.java index 95e2e3a8..0b696158 100644 --- a/consumer/src/main/java/cn/lili/event/impl/VerificationOrderExecute.java +++ b/consumer/src/main/java/cn/lili/event/impl/VerificationOrderExecute.java @@ -4,11 +4,16 @@ import cn.hutool.core.util.RandomUtil; import cn.lili.common.utils.CommonUtil; import cn.lili.event.OrderStatusChangeEvent; import cn.lili.modules.order.order.entity.dos.Order; +import cn.lili.modules.order.order.entity.dos.OrderItem; import cn.lili.modules.order.order.entity.dto.OrderMessage; +import cn.lili.modules.order.order.entity.enums.OrderComplaintStatusEnum; +import cn.lili.modules.order.order.entity.enums.OrderItemAfterSaleStatusEnum; import cn.lili.modules.order.order.entity.enums.OrderStatusEnum; +import cn.lili.modules.order.order.service.OrderItemService; import cn.lili.modules.order.order.service.OrderService; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; +import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -23,7 +28,8 @@ public class VerificationOrderExecute implements OrderStatusChangeEvent { @Autowired private OrderService orderService; - + @Autowired + private OrderItemService orderItemService; @Override public void orderChange(OrderMessage orderMessage) { //订单状态为待核验,添加订单添加核验码 @@ -36,6 +42,10 @@ public class VerificationOrderExecute implements OrderStatusChangeEvent { orderService.update(new LambdaUpdateWrapper() .set(Order::getVerificationCode, code) .eq(Order::getSn, orderMessage.getOrderSn())); + //修改虚拟订单货物可以进行售后、投诉 + orderItemService.update(new LambdaUpdateWrapper().eq(OrderItem::getOrderSn, orderMessage.getOrderSn()) + .set(OrderItem::getAfterSaleStatus, OrderItemAfterSaleStatusEnum.NOT_APPLIED) + .set(OrderItem::getCommentStatus, OrderComplaintStatusEnum.NO_APPLY)); } } diff --git a/consumer/src/main/java/cn/lili/listener/NoticeSendMessageListener.java b/consumer/src/main/java/cn/lili/listener/NoticeSendMessageListener.java index 01433f64..659c1c53 100644 --- a/consumer/src/main/java/cn/lili/listener/NoticeSendMessageListener.java +++ b/consumer/src/main/java/cn/lili/listener/NoticeSendMessageListener.java @@ -148,7 +148,7 @@ public class NoticeSendMessageListener implements RocketMQListener { Integer memberNum = memberService.getMemberNum(memberSearchVO); //构建分页查询参数 //100条查一次 - Integer pageSize = 200; + Integer pageSize = 100; Integer pageCount = 0; pageCount = memberNum / pageSize; pageCount = memberNum % pageSize > 0 ? pageCount + 1 : pageCount; diff --git a/consumer/src/main/java/cn/lili/timetask/handler/impl/coupon/CouponActivityExecute.java b/consumer/src/main/java/cn/lili/timetask/handler/impl/coupon/CouponActivityExecute.java deleted file mode 100644 index f960098f..00000000 --- a/consumer/src/main/java/cn/lili/timetask/handler/impl/coupon/CouponActivityExecute.java +++ /dev/null @@ -1,80 +0,0 @@ -package cn.lili.timetask.handler.impl.coupon; - -import cn.hutool.core.date.DateTime; -import cn.hutool.core.date.DateUtil; -import cn.lili.modules.promotion.entity.dos.CouponActivity; -import cn.lili.modules.promotion.entity.enums.CouponActivityTypeEnum; -import cn.lili.modules.promotion.entity.enums.PromotionStatusEnum; -import cn.lili.modules.promotion.service.CouponActivityService; -import cn.lili.timetask.handler.EveryMinuteExecute; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import java.util.List; - -/** - * 优惠券活动状态监测 - * - * @author Bulbasaur - * @date: 2021/5/24 10:08 上午 - */ -@Component -public class CouponActivityExecute implements EveryMinuteExecute { - - @Autowired - private CouponActivityService couponActivityService; - - @Override - public void execute() { - //精确发券活动 - specify(); - //注册赠券的活动 - registered(); - } - - /** - * 监测精确发券活动 - * 达到活动时间发送优惠券 - */ - private void specify(){ - DateTime dateTime=DateUtil.date(); - List couponActivities=couponActivityService.list(new LambdaQueryWrapper() - .eq(CouponActivity::getCouponActivityType, CouponActivityTypeEnum.SPECIFY.name()) - .le(CouponActivity::getStartTime, dateTime) - .eq(CouponActivity::getPromotionStatus,PromotionStatusEnum.NEW.name())); - //如果有符合要求的优惠券活动,发送优惠券 - if(couponActivities.size()>0){ - for (CouponActivity couponActivity:couponActivities) { - couponActivityService.specify(couponActivity.getId()); - - //修改精准发券优惠券活动状态 - couponActivityService.update(new LambdaUpdateWrapper() - .eq(CouponActivity::getId,couponActivity.getId()) - .set(CouponActivity::getPromotionStatus,PromotionStatusEnum.END.name())); - } - } - - } - /** - * 注册赠券活动状态监测 - */ - private void registered(){ - //开启注册赠券优惠券活动 - LambdaUpdateWrapper lambdaUpdateWrapper = new LambdaUpdateWrapper<>(); - lambdaUpdateWrapper.eq(CouponActivity::getCouponActivityType, CouponActivityTypeEnum.REGISTERED.name()) - .eq(CouponActivity::getPromotionStatus, PromotionStatusEnum.NEW.name()) - .le(CouponActivity::getStartTime, DateUtil.date()) - .set(CouponActivity::getPromotionStatus,PromotionStatusEnum.START.name()); - couponActivityService.update(lambdaUpdateWrapper); - - //关闭注册赠券优惠券活动 - LambdaUpdateWrapper endWrapper = new LambdaUpdateWrapper<>(); - endWrapper.eq(CouponActivity::getCouponActivityType, CouponActivityTypeEnum.REGISTERED.name()) - .eq(CouponActivity::getPromotionStatus, PromotionStatusEnum.START.name()) - .le(CouponActivity::getEndTime, DateUtil.date()) - .set(CouponActivity::getPromotionStatus,PromotionStatusEnum.END.name()); - couponActivityService.update(endWrapper); - } -} diff --git a/framework/pom.xml b/framework/pom.xml index 4873ab05..ba3991db 100644 --- a/framework/pom.xml +++ b/framework/pom.xml @@ -7,7 +7,7 @@ cn.lili lili-shop-parent - 1.0.1 + 4.2.0 framework diff --git a/framework/src/main/java/cn/lili/common/enums/ResultCode.java b/framework/src/main/java/cn/lili/common/enums/ResultCode.java index bc0b33c2..26490d88 100644 --- a/framework/src/main/java/cn/lili/common/enums/ResultCode.java +++ b/framework/src/main/java/cn/lili/common/enums/ResultCode.java @@ -51,7 +51,7 @@ public enum ResultCode { /** * 商品 */ - GOODS_ERROR(11010, "读取商品异常"), + GOODS_ERROR(11001, "商品异常,请稍后重试"), GOODS_NOT_EXIST(11001, "商品已下架"), GOODS_NAME_ERROR(11002, "商品名称不正确,名称应为2-50字符"), GOODS_UNDER_ERROR(11003, "商品下架失败"), @@ -63,6 +63,7 @@ public enum ResultCode { GOODS_SKU_COST_ERROR(11009, "商品SKU成本价不能小于等于0"), GOODS_SKU_WEIGHT_ERROR(11010, "商品重量不能为负数"), GOODS_SKU_QUANTITY_ERROR(11011, "商品库存数量不能为负数"), + GOODS_SKU_QUANTITY_NOT_ENOUGH(11011, "商品库存不足"), /** * 参数 @@ -196,6 +197,10 @@ public enum ResultCode { ORDER_DELIVER_NUM_ERROR(31010, "没有待发货的订单"), + ORDER_NOT_SUPPORT_DISTRIBUTION(31011, "购物车中包含不支持配送的商品,请重新选择收货地址,或者重新选择商品"), + + ORDER_CAN_NOT_CANCEL(31012, "当前订单状态不可取消"), + /** * 支付 */ @@ -223,6 +228,8 @@ public enum ResultCode { PAY_NOT_EXIST_ORDER(32011, "支付订单不存在"), + CAN_NOT_RECHARGE_WALLET(32012, "不能使用余额进行充值"), + /** * 售后 */ @@ -313,6 +320,11 @@ public enum ResultCode { FULL_DISCOUNT_EDIT_DELETE(43002, "删除满优惠活动成功"), + /** + * 直播 + */ + STODIO_GOODS_EXIST_ERROR(44001,"直播商品已存在"), + /** * 店铺 */ diff --git a/framework/src/main/java/cn/lili/common/token/base/generate/ManagerTokenGenerate.java b/framework/src/main/java/cn/lili/common/token/base/generate/ManagerTokenGenerate.java index a58d1aa6..5b4d6e70 100644 --- a/framework/src/main/java/cn/lili/common/token/base/generate/ManagerTokenGenerate.java +++ b/framework/src/main/java/cn/lili/common/token/base/generate/ManagerTokenGenerate.java @@ -84,7 +84,7 @@ public class ManagerTokenGenerate extends AbstractTokenGenerate { //for循环路径集合 for (String path : paths) { //如果是超级权限 则计入超级权限 - if (menu.getIsSupper()) { + if (menu.getIsSupper() != null && menu.getIsSupper()) { //如果已有超级权限,则这里就不做权限的累加 if (!superPermissions.contains(path)) { superPermissions.add(path); diff --git a/framework/src/main/java/cn/lili/common/validation/Mobile.java b/framework/src/main/java/cn/lili/common/validation/Mobile.java index 374b37f0..578888bc 100644 --- a/framework/src/main/java/cn/lili/common/validation/Mobile.java +++ b/framework/src/main/java/cn/lili/common/validation/Mobile.java @@ -1,6 +1,7 @@ package cn.lili.common.validation; import cn.lili.common.validation.impl.MobileValidator; +import cn.lili.common.validation.impl.PhoneValidator; import javax.validation.Constraint; import javax.validation.Payload; @@ -12,7 +13,7 @@ import static java.lang.annotation.ElementType.*; import static java.lang.annotation.RetentionPolicy.RUNTIME; /** - * 手机号码校验注解 + * 电话号码校验注解 * * @author Bulbasaur */ @@ -22,9 +23,9 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME; @Constraint(validatedBy = {MobileValidator.class}) public @interface Mobile { - String regexp() default "1[3|4|5|7|8]\\d{9}"; + String regexp() default ""; - String message() default "手机号码格式不正确"; + String message() default "电话号码格式不正确"; Class[] groups() default {}; diff --git a/framework/src/main/java/cn/lili/common/validation/Phone.java b/framework/src/main/java/cn/lili/common/validation/Phone.java new file mode 100644 index 00000000..9acdd3b9 --- /dev/null +++ b/framework/src/main/java/cn/lili/common/validation/Phone.java @@ -0,0 +1,32 @@ +package cn.lili.common.validation; + +import cn.lili.common.validation.impl.PhoneValidator; + +import javax.validation.Constraint; +import javax.validation.Payload; +import java.lang.annotation.Documented; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +import static java.lang.annotation.ElementType.*; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +/** + * 手机号码校验注解 + * + * @author Bulbasaur + */ +@Target({METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER}) +@Retention(RUNTIME) +@Documented +@Constraint(validatedBy = {PhoneValidator.class}) +public @interface Phone { + + String regexp() default "1[3|4|5|7|8]\\d{9}"; + + String message() default "手机号码格式不正确"; + + Class[] groups() default {}; + + Class[] payload() default {}; +} diff --git a/framework/src/main/java/cn/lili/common/validation/impl/MobileValidator.java b/framework/src/main/java/cn/lili/common/validation/impl/MobileValidator.java index add99847..2b21b32c 100644 --- a/framework/src/main/java/cn/lili/common/validation/impl/MobileValidator.java +++ b/framework/src/main/java/cn/lili/common/validation/impl/MobileValidator.java @@ -1,6 +1,7 @@ package cn.lili.common.validation.impl; import cn.lili.common.validation.Mobile; +import cn.lili.common.validation.Phone; import javax.validation.ConstraintValidator; import javax.validation.ConstraintValidatorContext; @@ -10,12 +11,21 @@ import java.util.regex.Pattern; public class MobileValidator implements ConstraintValidator { - private static Pattern pattern = 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}$"); - @Override public boolean isValid(String value, ConstraintValidatorContext constraintValidatorContext) { - Matcher m = pattern.matcher(value); - return m.matches(); + Pattern p1 = null,p2 = null; + Matcher m = null; + boolean b = false; + p1 = Pattern.compile("^[0][1-9]{2,3}-[0-9]{5,10}$"); // 验证带区号的 + p2 = Pattern.compile("^[1-9]{1}[0-9]{5,8}$"); // 验证没有区号的 + if(value.length() >9) + { m = p1.matcher(value); + b = m.matches(); + }else{ + m = p2.matcher(value); + b = m.matches(); + } + return b; } @Override diff --git a/framework/src/main/java/cn/lili/common/validation/impl/PhoneValidator.java b/framework/src/main/java/cn/lili/common/validation/impl/PhoneValidator.java new file mode 100644 index 00000000..731e9fe2 --- /dev/null +++ b/framework/src/main/java/cn/lili/common/validation/impl/PhoneValidator.java @@ -0,0 +1,25 @@ +package cn.lili.common.validation.impl; + +import cn.lili.common.validation.Phone; + +import javax.validation.ConstraintValidator; +import javax.validation.ConstraintValidatorContext; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + + +public class PhoneValidator implements ConstraintValidator { + + private static Pattern pattern = 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}$"); + + @Override + public boolean isValid(String value, ConstraintValidatorContext constraintValidatorContext) { + Matcher m = pattern.matcher(value); + return m.matches(); + } + + @Override + public void initialize(Phone constraintAnnotation) { + + } +} diff --git a/framework/src/main/java/cn/lili/common/verification/SliderImageUtil.java b/framework/src/main/java/cn/lili/common/verification/SliderImageUtil.java index a40cfc67..39b00968 100644 --- a/framework/src/main/java/cn/lili/common/verification/SliderImageUtil.java +++ b/framework/src/main/java/cn/lili/common/verification/SliderImageUtil.java @@ -78,7 +78,7 @@ public class SliderImageUtil { graphics.dispose(); //添加水印 - ImageUtil.addWatermark(originalImage, "请滑动拼图"); + ImageUtil.addWatermark(originalImage, "LILI-SHOP"); ByteArrayOutputStream newImageOs = new ByteArrayOutputStream();//新建流。 ImageIO.write(newImage, TEMP_IMG_FILE_TYPE, newImageOs);//利用ImageIO类提供的write方法,将bi以png图片的数据模式写入流。 byte[] newImagery = newImageOs.toByteArray(); diff --git a/framework/src/main/java/cn/lili/modules/broadcast/serviceimpl/StudioServiceImpl.java b/framework/src/main/java/cn/lili/modules/broadcast/serviceimpl/StudioServiceImpl.java index 18f9d74c..f3750381 100644 --- a/framework/src/main/java/cn/lili/modules/broadcast/serviceimpl/StudioServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/broadcast/serviceimpl/StudioServiceImpl.java @@ -5,6 +5,7 @@ import cn.lili.common.delayqueue.BroadcastMessage; import cn.lili.common.enums.ResultCode; import cn.lili.common.exception.ServiceException; import cn.lili.common.security.context.UserContext; +import cn.lili.common.security.enums.UserEnums; import cn.lili.common.trigger.enums.DelayTypeEnums; import cn.lili.common.trigger.interfaces.TimeTrigger; import cn.lili.common.trigger.model.TimeExecuteConstant; @@ -71,7 +72,8 @@ public class StudioServiceImpl extends ServiceImpl impleme //直播开启延时任务 BroadcastMessage broadcastMessage = new BroadcastMessage(studio.getId(), StudioStatusEnum.START.name()); TimeTriggerMsg timeTriggerMsg = new TimeTriggerMsg(TimeExecuteConstant.BROADCAST_EXECUTOR, - Long.parseLong(studio.getStartTime()) * 1000L, broadcastMessage, + Long.parseLong(studio.getStartTime()) * 1000L, + broadcastMessage, DelayQueueTools.wrapperUniqueKey(DelayTypeEnums.BROADCAST, studio.getId()), rocketmqCustomProperties.getPromotionTopic()); @@ -106,8 +108,8 @@ public class StudioServiceImpl extends ServiceImpl impleme this.timeTrigger.edit( TimeExecuteConstant.BROADCAST_EXECUTOR, broadcastMessage, - Long.parseLong(oldStudio.getStartTime()), - Long.parseLong(studio.getStartTime()), + Long.parseLong(oldStudio.getStartTime()) * 1000L, + Long.parseLong(studio.getStartTime()) * 1000L, DelayQueueTools.wrapperUniqueKey(DelayTypeEnums.BROADCAST, studio.getId()), DateUtil.getDelayTime(Long.parseLong(studio.getStartTime())), rocketmqCustomProperties.getPromotionTopic()); @@ -117,8 +119,8 @@ public class StudioServiceImpl extends ServiceImpl impleme this.timeTrigger.edit( TimeExecuteConstant.BROADCAST_EXECUTOR, broadcastMessage, - Long.parseLong(oldStudio.getEndTime()), - Long.parseLong(studio.getEndTime()), + Long.parseLong(oldStudio.getEndTime()) * 1000L, + Long.parseLong(studio.getEndTime()) * 1000L, DelayQueueTools.wrapperUniqueKey(DelayTypeEnums.BROADCAST, studio.getId()), DateUtil.getDelayTime(Long.parseLong(studio.getEndTime())), rocketmqCustomProperties.getPromotionTopic()); @@ -152,6 +154,14 @@ public class StudioServiceImpl extends ServiceImpl impleme @Override public Boolean push(Integer roomId, Integer goodsId) { + + //判断直播间是否已添加商品 + if (studioCommodityService.getOne( + new LambdaQueryWrapper().eq(StudioCommodity::getRoomId, roomId) + .eq(StudioCommodity::getGoodsId, goodsId)) != null) { + throw new ServiceException(ResultCode.STODIO_GOODS_EXIST_ERROR); + } + //调用微信接口添加直播间商品并进行记录 if (wechatLivePlayerUtil.pushGoods(roomId, goodsId)) { studioCommodityService.save(new StudioCommodity(roomId, goodsId)); @@ -186,10 +196,14 @@ public class StudioServiceImpl extends ServiceImpl impleme @Override public IPage studioList(PageVO pageVO, Integer recommend, String status) { - return this.page(PageUtil.initPage(pageVO), new QueryWrapper() + QueryWrapper queryWrapper = new QueryWrapper() .eq(recommend != null, "recommend", true) .eq(status != null, "status", status) - .orderByDesc("create_time")); + .orderByDesc("create_time"); + if (UserContext.getCurrentUser() != null && UserContext.getCurrentUser().getRole().equals(UserEnums.STORE)) { + queryWrapper.eq("store_id", UserContext.getCurrentUser().getStoreId()); + } + return this.page(PageUtil.initPage(pageVO), queryWrapper); } diff --git a/framework/src/main/java/cn/lili/modules/broadcast/util/WechatLivePlayerUtil.java b/framework/src/main/java/cn/lili/modules/broadcast/util/WechatLivePlayerUtil.java index 32f80ed6..776f85a9 100644 --- a/framework/src/main/java/cn/lili/modules/broadcast/util/WechatLivePlayerUtil.java +++ b/framework/src/main/java/cn/lili/modules/broadcast/util/WechatLivePlayerUtil.java @@ -38,18 +38,11 @@ public class WechatLivePlayerUtil { * @return 房间ID */ public Map create(Studio studio) throws Exception { - //获取token - String token = wechatAccessTokenUtil.cgiAccessToken(ClientTypeEnum.WECHAT_MP); //发送url - String url = "https://api.weixin.qq.com/wxaapi/broadcast/room/create?access_token=" + token; + String url = "https://api.weixin.qq.com/wxaapi/broadcast/room/create?access_token="; //添加直播间 - Map map = this.mockRoom(token, studio); - String content = HttpUtils.doPostWithJson(url, map); - JSONObject json = new JSONObject(content); - log.info("微信小程序直播间创建结果:" + content); - if (!json.getStr("errcode").equals("0")) { - throw new ServiceException(json.getStr("errmsg")); - } + Map map = this.mockRoom(studio); + JSONObject json = this.doPostWithJson(url, map); Map roomMap = new HashMap<>(); roomMap.put("roomId", json.getStr("roomId")); roomMap.put("qrcodeUrl", json.getStr("qrcode_url")); @@ -63,20 +56,13 @@ public class WechatLivePlayerUtil { * @return 房间ID */ public boolean editRoom(Studio studio) { - //获取token - String token = wechatAccessTokenUtil.cgiAccessToken(ClientTypeEnum.WECHAT_MP); //发送url - String url = "https://api.weixin.qq.com/wxaapi/broadcast/room/editroom?access_token=" + token; + String url = "https://api.weixin.qq.com/wxaapi/broadcast/room/editroom?access_token="; //修改直播间 - Map map = this.mockRoom(token, studio); + Map map = this.mockRoom(studio); map.put("id", studio.getRoomId().toString()); - String content = HttpUtils.doPostWithJson(url, map); - JSONObject json = new JSONObject(content); - log.info("微信小程序直播间修改结果:" + content); - if (!json.getStr("errcode").equals("0")) { - throw new ServiceException(json.getStr("errmsg")); - } + this.doPostWithJson(url, map); return true; } @@ -88,10 +74,8 @@ public class WechatLivePlayerUtil { * @return 回放地址 */ public String getLiveInfo(Integer roomId) { - //获取token - String token = wechatAccessTokenUtil.cgiAccessToken(ClientTypeEnum.WECHAT_MP); //发送url - String url = "https://api.weixin.qq.com/wxa/business/getliveinfo?access_token=" + token; + String url = "https://api.weixin.qq.com/wxa/business/getliveinfo?access_token="; Map map = new HashMap<>(); //获取回放 map.put("action", "get_replay"); @@ -101,10 +85,7 @@ public class WechatLivePlayerUtil { map.put("start", "0"); //每次拉取的数量,建议100以内 map.put("limit", "1"); - - String content = HttpUtils.doPostWithJson(url, map); - JSONObject json = new JSONObject(content); - log.info("微信小程序获取信息:" + content); + JSONObject json = this.doPostWithJson(url, map); //TODO get media_url return json.getStr("live_replay"); } @@ -117,22 +98,15 @@ public class WechatLivePlayerUtil { * @return 操作结果 */ public Boolean pushGoods(Integer roomId, Integer goodsId) { - //获取token - String token = wechatAccessTokenUtil.cgiAccessToken(ClientTypeEnum.WECHAT_MP); //发送url - String url = "https://api.weixin.qq.com/wxaapi/broadcast/room/addgoods?access_token=" + token; + String url = "https://api.weixin.qq.com/wxaapi/broadcast/room/addgoods?access_token="; Map map = new HashMap<>(); //直播间回放 Integer[] ids = {goodsId}; map.put("ids", ids); //商品ID map.put("roomId", roomId); - String content = HttpUtils.doPostWithJson(url, map); - JSONObject json = new JSONObject(content); - log.info("直播间导入商品:" + content); - if (!json.getStr("errcode").equals("0")) { - throw new ServiceException(json.getStr("errmsg")); - } + this.doPostWithJson(url, map); return true; } @@ -144,22 +118,15 @@ public class WechatLivePlayerUtil { * @return 操作结果 */ public Boolean goodsDeleteInRoom(Integer roomId, Integer goodsId) { - //获取token - String token = wechatAccessTokenUtil.cgiAccessToken(ClientTypeEnum.WECHAT_MP); //发送url - String url = "https://api.weixin.qq.com/wxaapi/broadcast/goods/deleteInRoom?access_token=" + token; + String url = "https://api.weixin.qq.com/wxaapi/broadcast/goods/deleteInRoom?access_token="; Map map = new HashMap<>(); //直播间回放 map.put("goodsId", goodsId); //商品ID map.put("roomId", roomId); - String content = HttpUtils.doPostWithJson(url, map); - JSONObject json = new JSONObject(content); - log.info("微信小程序直播间删除商品:" + content); - if(json.getStr("errcode").equals("0")){ - return true; - } - throw new ServiceException(json.getStr("errmsg")); + this.doPostWithJson(url, map); + return true; } @@ -170,10 +137,8 @@ public class WechatLivePlayerUtil { * @return 添加结果 */ public JSONObject addGoods(Commodity commodity) { - //获取token - String token = wechatAccessTokenUtil.cgiAccessToken(ClientTypeEnum.WECHAT_MP); //发送url - String url = "https://api.weixin.qq.com/wxaapi/broadcast/goods/add?access_token=" + token; + String url = "https://api.weixin.qq.com/wxaapi/broadcast/goods/add?access_token="; //商品名称,最长14个汉字 if (commodity.getName().length() > 14) { @@ -183,14 +148,11 @@ public class WechatLivePlayerUtil { //新建微信商品DTO GoodsInfo goodsInfo = new GoodsInfo(commodity); //上传微信临时图片 - goodsInfo.setCoverImgUrl(wechatMediaUtil.uploadMedia(token, "image", commodity.getGoodsImage())); + goodsInfo.setCoverImgUrl(wechatMediaUtil.uploadMedia("image", commodity.getGoodsImage())); Map map = new HashMap<>(); //调用新增直播商品接口 map.put("goodsInfo", goodsInfo); - String content = HttpUtils.doPostWithJson(url, map); - JSONObject json = new JSONObject(content); - log.info("微信小程序添加直播商品结果:" + content); - return json; + return this.doPostWithJson(url, map); } /** @@ -200,16 +162,11 @@ public class WechatLivePlayerUtil { * @return 删除结果 */ public JSONObject deleteGoods(String goodsId) { - //获取token - String token = wechatAccessTokenUtil.cgiAccessToken(ClientTypeEnum.WECHAT_MP); //发送url - String url = "https://api.weixin.qq.com/wxaapi/broadcast/goods/delete?access_token=" + token; + String url = "https://api.weixin.qq.com/wxaapi/broadcast/goods/delete?access_token="; Map map = new HashMap<>(); map.put("goodsId", goodsId); - String content = HttpUtils.doPostWithJson(url, map); - JSONObject json = new JSONObject(content); - log.info("微信小程序删除直播商品结果:" + content); - return json; + return this.doPostWithJson(url, map); } /** @@ -219,26 +176,49 @@ public class WechatLivePlayerUtil { * @return 删除结果 */ public JSONObject getGoodsWareHouse(List goodsIdList) { - //获取token - String token = wechatAccessTokenUtil.cgiAccessToken(ClientTypeEnum.WECHAT_MP); //发送url - String url = "https://api.weixin.qq.com/wxa/business/getgoodswarehouse?access_token=" + token; + String url = "https://api.weixin.qq.com/wxa/business/getgoodswarehouse?access_token="; Map map = new HashMap<>(); map.put("goods_ids", goodsIdList); - String content = HttpUtils.doPostWithJson(url, map); - JSONObject json = new JSONObject(content); - log.info("微信小程序查询直播商品结果:" + content); - return json; + return this.doPostWithJson(url, map); } - private Map mockRoom(String token, Studio studio) { + /** + * 请求微信接口 + * + * @param url 链接 + * @param map 参数 + * @return 返回内容 + */ + private JSONObject doPostWithJson(String url, Map map) { + //获取token + String token = wechatAccessTokenUtil.cgiAccessToken(ClientTypeEnum.WECHAT_MP); + //请求链接添加token + url += token; + //发起请求 + String content = HttpUtils.doPostWithJson(url, map); + //记录请求结果 + log.info("微信小程序请求结果:" + content); + //获取请求内容,如果token过期则重新获取,如果出错则抛出错误 + JSONObject jsonObject = new JSONObject(content); + if (jsonObject.get("errcode").toString().equals("0")) { + return jsonObject; + } else if (jsonObject.get("errcode").equals("40001")) { + wechatAccessTokenUtil.removeAccessToken(ClientTypeEnum.WECHAT_MP); + return this.doPostWithJson(url, map); + } else { + throw new ServiceException(jsonObject.get("errmsg").toString()); + } + } + + private Map mockRoom(Studio studio) { Map map = new HashMap<>(); //背景图 - map.put("coverImg", wechatMediaUtil.uploadMedia(token, "image", studio.getCoverImg())); + map.put("coverImg", wechatMediaUtil.uploadMedia("image", studio.getCoverImg())); //分享图 - map.put("shareImg", wechatMediaUtil.uploadMedia(token, "image", studio.getShareImg())); + map.put("shareImg", wechatMediaUtil.uploadMedia("image", studio.getShareImg())); //购物直播频道封面图 - map.put("feedsImg", wechatMediaUtil.uploadMedia(token, "image", studio.getFeedsImg())); + map.put("feedsImg", wechatMediaUtil.uploadMedia("image", studio.getFeedsImg())); //直播间名字 map.put("name", studio.getName()); //直播计划开始时间 diff --git a/framework/src/main/java/cn/lili/modules/broadcast/util/WechatMediaUtil.java b/framework/src/main/java/cn/lili/modules/broadcast/util/WechatMediaUtil.java index ad6cef2b..eb885cb1 100644 --- a/framework/src/main/java/cn/lili/modules/broadcast/util/WechatMediaUtil.java +++ b/framework/src/main/java/cn/lili/modules/broadcast/util/WechatMediaUtil.java @@ -1,7 +1,11 @@ package cn.lili.modules.broadcast.util; import cn.hutool.json.JSONObject; +import cn.lili.common.exception.ServiceException; +import cn.lili.modules.base.entity.enums.ClientTypeEnum; +import cn.lili.modules.message.util.WechatAccessTokenUtil; import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import java.io.*; @@ -18,14 +22,18 @@ import java.util.Date; @Slf4j @Component public class WechatMediaUtil { + @Autowired + private WechatAccessTokenUtil wechatAccessTokenUtil; /** * 上传多媒体数据到微信服务器 - * @param accessToken 从微信获取到的access_token + * * @param mediaFileUrl 来自网络上面的媒体文件地址 * @return */ - public String uploadMedia(String accessToken, String type, String mediaFileUrl) { + public String uploadMedia(String type, String mediaFileUrl) { + //获取token + String accessToken = wechatAccessTokenUtil.cgiAccessToken(ClientTypeEnum.WECHAT_MP); /* * 上传媒体文件到微信服务器需要请求的地址 */ @@ -38,21 +46,21 @@ public class WechatMediaUtil { try { String boundary = "----WebKitFormBoundaryOYXo8heIv9pgpGjT"; URL url = new URL(mediaStr); - HttpURLConnection urlConn = (HttpURLConnection)url.openConnection(); + HttpURLConnection urlConn = (HttpURLConnection) url.openConnection(); //让输入输出流开启 urlConn.setDoInput(true); urlConn.setDoOutput(true); //使用post方式请求的时候必须关闭缓存 urlConn.setUseCaches(false); //设置请求头的Content-Type属性 - urlConn.setRequestProperty("Content-Type", "multipart/form-data; boundary="+boundary); + urlConn.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + boundary); urlConn.setRequestMethod("POST"); //获取输出流,使用输出流拼接请求体 OutputStream out = urlConn.getOutputStream(); //读取文件的数据,构建一个GET请求,然后读取指定地址中的数据 mediaUrl = new URL(mediaFileUrl); - HttpURLConnection mediaConn = (HttpURLConnection)mediaUrl.openConnection(); + HttpURLConnection mediaConn = (HttpURLConnection) mediaUrl.openConnection(); //设置请求方式 mediaConn.setRequestMethod("GET"); //设置可以打开输入流 @@ -68,15 +76,15 @@ public class WechatMediaUtil { byte[] bytes = new byte[1024]; int size = 0; //使用outputStream流输出信息到请求体当中去 - out.write(("--"+boundary+"\r\n").getBytes()); + out.write(("--" + boundary + "\r\n").getBytes()); out.write(("Content-Disposition: form-data; name=\"media\";\r\n" - + "filename=\""+(new Date().getTime())+fileExt+"\"\r\n" - + "Content-Type: "+contentType+"\r\n\r\n").getBytes()); - while( (size = bufferedIn.read(bytes)) != -1) { + + "filename=\"" + (new Date().getTime()) + fileExt + "\"\r\n" + + "Content-Type: " + contentType + "\r\n\r\n").getBytes()); + while ((size = bufferedIn.read(bytes)) != -1) { out.write(bytes, 0, size); } //切记,这里的换行符不能少,否则将会报41005错误 - out.write(("\r\n--"+boundary+"--\r\n").getBytes()); + out.write(("\r\n--" + boundary + "--\r\n").getBytes()); bufferedIn.close(); in.close(); @@ -87,27 +95,39 @@ public class WechatMediaUtil { BufferedReader bufferedReader = new BufferedReader(reader); String tempStr = null; resultStr = new StringBuffer(); - while((tempStr = bufferedReader.readLine()) != null) { + while ((tempStr = bufferedReader.readLine()) != null) { resultStr.append(tempStr); } bufferedReader.close(); reader.close(); resultIn.close(); urlConn.disconnect(); - } catch (Exception e) { - log.error("微信媒体上传失败",e); + } catch (Exception e) { + log.error("微信媒体上传失败", e); } - JSONObject jsonObject=new JSONObject(resultStr.toString()); - return jsonObject.get("media_id").toString(); + JSONObject jsonObject = new JSONObject(resultStr.toString()); + log.info("微信媒体上传:" + jsonObject.toString()); + //判断是否传递成功,如果token过期则重新获取 + if (jsonObject.get("errcode") != null && jsonObject.get("errcode").equals("40001")) { + wechatAccessTokenUtil.removeAccessToken(ClientTypeEnum.WECHAT_MP); + return this.uploadMedia(type, mediaFileUrl); + } else if (jsonObject.get("errcode") != null) { + throw new ServiceException(jsonObject.get("errmsg").toString()); + } else { + return jsonObject.get("media_id").toString(); + } + } + /** * 通过传过来的contentType判断是哪一种类型 + * * @param contentType 获取来自连接的contentType * @return */ public String judgeType(String contentType) { String fileExt = ""; - switch (contentType){ + switch (contentType) { case "image/png": fileExt = ".png"; break; diff --git a/framework/src/main/java/cn/lili/modules/connect/util/ConnectUtil.java b/framework/src/main/java/cn/lili/modules/connect/util/ConnectUtil.java index cf28840a..acf388a3 100644 --- a/framework/src/main/java/cn/lili/modules/connect/util/ConnectUtil.java +++ b/framework/src/main/java/cn/lili/modules/connect/util/ConnectUtil.java @@ -184,6 +184,8 @@ public class ConnectUtil { .clientId(qqConnectSettingItem.getAppId()) .clientSecret(qqConnectSettingItem.getAppKey()) .redirectUri(getRedirectUri(authInterface)) + //这里qq获取unionid 需要配置为true,详情可以查阅属性说明,内部有帮助文档 + .unionId(true) .build(), cache); } } diff --git a/framework/src/main/java/cn/lili/modules/distribution/entity/vos/DistributionGoodsVO.java b/framework/src/main/java/cn/lili/modules/distribution/entity/vos/DistributionGoodsVO.java index 73a075d9..07d266d1 100644 --- a/framework/src/main/java/cn/lili/modules/distribution/entity/vos/DistributionGoodsVO.java +++ b/framework/src/main/java/cn/lili/modules/distribution/entity/vos/DistributionGoodsVO.java @@ -39,6 +39,9 @@ public class DistributionGoodsVO { @ApiModelProperty(value = "商品编号") private String sn; + @ApiModelProperty(value = "商品ID") + private String goodsId; + @ApiModelProperty(value = "规格ID") private String skuId; diff --git a/framework/src/main/java/cn/lili/modules/distribution/entity/vos/DistributionOrderSearchParams.java b/framework/src/main/java/cn/lili/modules/distribution/entity/vos/DistributionOrderSearchParams.java index 9a4512e6..befe4480 100644 --- a/framework/src/main/java/cn/lili/modules/distribution/entity/vos/DistributionOrderSearchParams.java +++ b/framework/src/main/java/cn/lili/modules/distribution/entity/vos/DistributionOrderSearchParams.java @@ -55,8 +55,8 @@ public class DistributionOrderSearchParams extends PageVO { queryWrapper.like(StringUtils.isNotBlank(distributionName), "distribution_name", distributionName); queryWrapper.eq(StringUtils.isNotBlank(distributionOrderStatus), "distribution_order_status", distributionOrderStatus); queryWrapper.eq(StringUtils.isNotBlank(orderSn), "order_sn", orderSn); - queryWrapper.eq(StringUtils.isNotBlank(StringUtils.toString(distributionId)), "distribution_id", distributionId); - queryWrapper.eq(StringUtils.isNotBlank(StringUtils.toString(storeId)), "store_id", storeId); + queryWrapper.eq(StringUtils.isNotBlank(distributionId), "distribution_id", distributionId); + queryWrapper.eq(StringUtils.isNotBlank(storeId), "store_id", storeId); if (endTime != null && startTime != null) { queryWrapper.between("create_time", startTime, endTime); } diff --git a/framework/src/main/java/cn/lili/modules/distribution/mapper/DistributionMapper.java b/framework/src/main/java/cn/lili/modules/distribution/mapper/DistributionMapper.java index 4a43c512..cd32c80b 100644 --- a/framework/src/main/java/cn/lili/modules/distribution/mapper/DistributionMapper.java +++ b/framework/src/main/java/cn/lili/modules/distribution/mapper/DistributionMapper.java @@ -16,6 +16,6 @@ public interface DistributionMapper extends BaseMapper { @Update("UPDATE li_distribution set can_rebate = can_rebate+#{canRebate} WHERE id = #{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); } \ No newline at end of file diff --git a/framework/src/main/java/cn/lili/modules/goods/entity/dos/CategoryParameterGroup.java b/framework/src/main/java/cn/lili/modules/goods/entity/dos/CategoryParameterGroup.java index 5c97992d..3737862d 100644 --- a/framework/src/main/java/cn/lili/modules/goods/entity/dos/CategoryParameterGroup.java +++ b/framework/src/main/java/cn/lili/modules/goods/entity/dos/CategoryParameterGroup.java @@ -41,7 +41,7 @@ public class CategoryParameterGroup extends BaseEntity { @NotNull(message = "关联的分类不能为空") private String categoryId; /** - * + * 排序 */ @ApiModelProperty(value = "排序", hidden = true) private Integer sort; diff --git a/framework/src/main/java/cn/lili/modules/goods/entity/dos/DraftGoods.java b/framework/src/main/java/cn/lili/modules/goods/entity/dos/DraftGoods.java index 23e0a4a3..df07486c 100644 --- a/framework/src/main/java/cn/lili/modules/goods/entity/dos/DraftGoods.java +++ b/framework/src/main/java/cn/lili/modules/goods/entity/dos/DraftGoods.java @@ -64,6 +64,10 @@ public class DraftGoods extends BaseEntity { @ApiModelProperty(value = "详情") private String intro; + + @ApiModelProperty(value = "商品移动端详情") + private String mobileIntro; + @Max(value = 99999999, message = "价格不能超过99999999") @ApiModelProperty(value = "商品价格") private Double price; @@ -114,11 +118,6 @@ public class DraftGoods extends BaseEntity { @ApiModelProperty(value = "是否自营") private Boolean selfOperated; - /** - * 商品移动端详情 - */ - @ApiModelProperty(value = "商品移动端详情") - private String mobileIntro; @ApiModelProperty(value = "商品视频") private String goodsVideo; diff --git a/framework/src/main/java/cn/lili/modules/goods/entity/dos/Goods.java b/framework/src/main/java/cn/lili/modules/goods/entity/dos/Goods.java index acf79d3d..142c2298 100644 --- a/framework/src/main/java/cn/lili/modules/goods/entity/dos/Goods.java +++ b/framework/src/main/java/cn/lili/modules/goods/entity/dos/Goods.java @@ -1,5 +1,6 @@ package cn.lili.modules.goods.entity.dos; +import cn.hutool.core.convert.Convert; import cn.hutool.json.JSONUtil; import cn.lili.base.BaseEntity; import cn.lili.common.enums.ResultCode; @@ -221,8 +222,8 @@ public class Goods extends BaseEntity { this.intro = goodsOperationDTO.getIntro(); this.mobileIntro = goodsOperationDTO.getMobileIntro(); this.cost = goodsOperationDTO.getCost(); - if (goodsOperationDTO.getGoodsParamsList() != null && goodsOperationDTO.getGoodsParamsList().isEmpty()) { - this.params = JSONUtil.toJsonStr(goodsOperationDTO.getGoodsParamsList()); + if (goodsOperationDTO.getGoodsParamsDTOList() != null && goodsOperationDTO.getGoodsParamsDTOList().isEmpty()) { + this.params = JSONUtil.toJsonStr(goodsOperationDTO.getGoodsParamsDTOList()); } //如果立即上架则 this.marketEnable = goodsOperationDTO.isRelease() ? GoodsStatusEnum.UPPER.name() : GoodsStatusEnum.DOWN.name(); @@ -234,19 +235,19 @@ public class Goods extends BaseEntity { if (sku.get("sn") == null) { 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); } - 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); } //虚拟商品没有重量字段 - if(sku.containsKey("weight")) { - if (StringUtil.isEmpty(sku.get("weight").toString()) || Integer.parseInt(sku.get("weight").toString()) < 0) { + if (sku.containsKey("weight")) { + if (StringUtil.isEmpty(sku.get("weight").toString()) || Convert.toDouble(sku.get("weight").toString()) < 0) { throw new ServiceException(ResultCode.GOODS_SKU_WEIGHT_ERROR); } } - if (StringUtil.isEmpty(sku.get("quantity").toString()) || 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); } diff --git a/framework/src/main/java/cn/lili/modules/goods/entity/dos/GoodsParams.java b/framework/src/main/java/cn/lili/modules/goods/entity/dos/GoodsParams.java deleted file mode 100644 index 16045221..00000000 --- a/framework/src/main/java/cn/lili/modules/goods/entity/dos/GoodsParams.java +++ /dev/null @@ -1,67 +0,0 @@ -package cn.lili.modules.goods.entity.dos; - -import cn.lili.base.BaseEntity; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableName; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import lombok.EqualsAndHashCode; -import org.hibernate.validator.constraints.Length; - -import javax.persistence.Entity; -import javax.persistence.Table; -import javax.validation.constraints.Max; -import javax.validation.constraints.Min; -import javax.validation.constraints.NotNull; - -/** - * 商品关联参数 - * - * @author pikachu - * @date 2020-02-23 9:14:33 - */ -@EqualsAndHashCode(callSuper = true) -@Data -@Entity -@Table(name = "li_goods_params") -@TableName("li_goods_params") -@ApiModel(value = "商品关联参数") -public class GoodsParams extends BaseEntity { - - private static final long serialVersionUID = 1L; - - /** - * 商品id - */ - @TableField(value = "goods_id") - @ApiModelProperty(value = "商品id", hidden = true) - private String goodsId; - /** - * 参数id - */ - @TableField(value = "param_id") - @ApiModelProperty(value = "参数id", required = true) - private String paramId; - /** - * 参数名字 - */ - @TableField(value = "param_name") - @ApiModelProperty(value = "参数名字", required = true) - private String paramName; - /** - * 参数值 - */ - @TableField(value = "param_value") - @ApiModelProperty(value = "参数值", required = true) - @Length(max = 100, message = "参数值字符不能大于120") - private String paramValue; - - @TableField(value = "is_index") - @ApiModelProperty(value = "是否可索引,0 不显示 1 显示", required = true) - @NotNull(message = "是否可索引必选") - @Min(value = 0, message = "是否可索引传值不正确") - @Max(value = 1, message = "是否可索引传值不正确") - private Integer isIndex = 0; - -} \ No newline at end of file diff --git a/framework/src/main/java/cn/lili/modules/goods/entity/dos/Parameters.java b/framework/src/main/java/cn/lili/modules/goods/entity/dos/Parameters.java index f9198944..96fcc1f8 100644 --- a/framework/src/main/java/cn/lili/modules/goods/entity/dos/Parameters.java +++ b/framework/src/main/java/cn/lili/modules/goods/entity/dos/Parameters.java @@ -1,13 +1,17 @@ package cn.lili.modules.goods.entity.dos; -import cn.lili.base.BaseEntity; +import cn.lili.base.IdEntity; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import org.hibernate.validator.constraints.Length; +import javax.persistence.Column; import javax.persistence.Entity; +import javax.persistence.Id; import javax.persistence.Table; import javax.validation.constraints.Max; import javax.validation.constraints.Min; @@ -25,7 +29,9 @@ import javax.validation.constraints.NotNull; @Table(name = "li_parameters") @TableName("li_parameters") @ApiModel(value = "商品参数") -public class Parameters extends BaseEntity { +public class Parameters extends IdEntity { + + private static final long serialVersionUID = -566510714456317006L; @@ -36,6 +42,7 @@ public class Parameters extends BaseEntity { @ApiModelProperty(value = "选择值") + @NotEmpty(message = "参数选项值必填") private String options; @ApiModelProperty(value = "是否可索引,0 不显示 1 显示", required = true) diff --git a/framework/src/main/java/cn/lili/modules/goods/entity/dos/Specification.java b/framework/src/main/java/cn/lili/modules/goods/entity/dos/Specification.java index 436d6ce3..b4e8a272 100644 --- a/framework/src/main/java/cn/lili/modules/goods/entity/dos/Specification.java +++ b/framework/src/main/java/cn/lili/modules/goods/entity/dos/Specification.java @@ -1,6 +1,6 @@ package cn.lili.modules.goods.entity.dos; -import cn.lili.base.BaseEntity; +import cn.lili.base.IdEntity; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; import io.swagger.annotations.ApiModel; @@ -23,7 +23,7 @@ import javax.validation.constraints.NotEmpty; @Table(name = "li_specification") @TableName("li_specification") @ApiModel(value = "规格项") -public class Specification extends BaseEntity { +public class Specification extends IdEntity { private static final long serialVersionUID = 147792597901239486L; diff --git a/framework/src/main/java/cn/lili/modules/goods/entity/dto/DraftGoodsDTO.java b/framework/src/main/java/cn/lili/modules/goods/entity/dto/DraftGoodsDTO.java index 607223b6..b1517e6b 100644 --- a/framework/src/main/java/cn/lili/modules/goods/entity/dto/DraftGoodsDTO.java +++ b/framework/src/main/java/cn/lili/modules/goods/entity/dto/DraftGoodsDTO.java @@ -1,7 +1,6 @@ package cn.lili.modules.goods.entity.dto; import cn.lili.modules.goods.entity.dos.DraftGoods; -import cn.lili.modules.goods.entity.dos.GoodsParams; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -22,7 +21,7 @@ public class DraftGoodsDTO extends DraftGoods { @ApiModelProperty(value = "商品参数") @Valid - private List goodsParamsList; + private List goodsParamsDTOList; @ApiModelProperty(value = "商品图片") private List goodsGalleryList; diff --git a/framework/src/main/java/cn/lili/modules/goods/entity/dto/GoodsOperationDTO.java b/framework/src/main/java/cn/lili/modules/goods/entity/dto/GoodsOperationDTO.java index 20cf8120..3decd397 100644 --- a/framework/src/main/java/cn/lili/modules/goods/entity/dto/GoodsOperationDTO.java +++ b/framework/src/main/java/cn/lili/modules/goods/entity/dto/GoodsOperationDTO.java @@ -1,6 +1,5 @@ package cn.lili.modules.goods.entity.dto; -import cn.lili.modules.goods.entity.dos.GoodsParams; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.ToString; @@ -83,8 +82,7 @@ public class GoodsOperationDTO implements Serializable { private boolean recommend; @ApiModelProperty(value = "商品参数") - @Valid - private List goodsParamsList; + private List goodsParamsDTOList; @ApiModelProperty(value = "商品图片") private List goodsGalleryList; @@ -121,4 +119,7 @@ public class GoodsOperationDTO implements Serializable { */ @ApiModelProperty(value = "商品类型") private String goodsType; + + + } diff --git a/framework/src/main/java/cn/lili/modules/goods/entity/dto/GoodsParamsDTO.java b/framework/src/main/java/cn/lili/modules/goods/entity/dto/GoodsParamsDTO.java new file mode 100644 index 00000000..09be40e0 --- /dev/null +++ b/framework/src/main/java/cn/lili/modules/goods/entity/dto/GoodsParamsDTO.java @@ -0,0 +1,31 @@ +package cn.lili.modules.goods.entity.dto; + +import com.baomidou.mybatisplus.annotation.TableField; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +/** + * 商品关联参数 + * + * @author pikachu + * @date 2020-02-23 9:14:33 + */ +@Data +@ApiModel(value = "商品参数分组") +public class GoodsParamsDTO { + + @TableField(value = "group_id") + @ApiModelProperty(value = "分组id") + private String groupId; + + @TableField(value = "group_name") + @ApiModelProperty(value = "分组名称") + private String groupName; + + @ApiModelProperty(value = "分组内的商品参数列表") + private List goodsParamsItemDTOList; + +} \ No newline at end of file diff --git a/framework/src/main/java/cn/lili/modules/goods/entity/dto/GoodsParamsItemDTO.java b/framework/src/main/java/cn/lili/modules/goods/entity/dto/GoodsParamsItemDTO.java new file mode 100644 index 00000000..84eb2113 --- /dev/null +++ b/framework/src/main/java/cn/lili/modules/goods/entity/dto/GoodsParamsItemDTO.java @@ -0,0 +1,35 @@ +package cn.lili.modules.goods.entity.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.Max; +import javax.validation.constraints.Min; + +/** + * 商品参数项 + * + * @author Chopper + * @version v1.0 + * 2021-06-24 15:41 + */ +@Data +@ApiModel(value = "商品参数列表") +public class GoodsParamsItemDTO { + + @ApiModelProperty(value = "参数ID") + private String paramId; + + @ApiModelProperty(value = "参数名字") + private String paramName; + + @ApiModelProperty(value = "参数值") + private String paramValue; + + @ApiModelProperty(value = "是否可索引,0 不索引 1 索引") + private Integer isIndex = 0; + + @ApiModelProperty(value = "是否必填,0 不显示 1 显示") + private Integer required = 0; +} diff --git a/framework/src/main/java/cn/lili/modules/goods/entity/vos/DraftGoodsVO.java b/framework/src/main/java/cn/lili/modules/goods/entity/vos/DraftGoodsVO.java index f6e67966..2bf39fad 100644 --- a/framework/src/main/java/cn/lili/modules/goods/entity/vos/DraftGoodsVO.java +++ b/framework/src/main/java/cn/lili/modules/goods/entity/vos/DraftGoodsVO.java @@ -1,10 +1,9 @@ package cn.lili.modules.goods.entity.vos; import cn.lili.modules.goods.entity.dos.DraftGoods; -import cn.lili.modules.goods.entity.dos.GoodsParams; +import cn.lili.modules.goods.entity.dto.GoodsParamsDTO; import io.swagger.annotations.ApiModelProperty; import lombok.Data; -import lombok.EqualsAndHashCode; import java.util.List; @@ -23,7 +22,7 @@ public class DraftGoodsVO extends DraftGoods { private List categoryName; @ApiModelProperty(value = "商品参数") - private List goodsParamsList; + private List goodsParamsDTOList; @ApiModelProperty(value = "商品图片") private List goodsGalleryList; diff --git a/framework/src/main/java/cn/lili/modules/goods/entity/vos/GoodsParamsVO.java b/framework/src/main/java/cn/lili/modules/goods/entity/vos/GoodsParamsDTOVO.java similarity index 90% rename from framework/src/main/java/cn/lili/modules/goods/entity/vos/GoodsParamsVO.java rename to framework/src/main/java/cn/lili/modules/goods/entity/vos/GoodsParamsDTOVO.java index 795a22c6..64deda4f 100644 --- a/framework/src/main/java/cn/lili/modules/goods/entity/vos/GoodsParamsVO.java +++ b/framework/src/main/java/cn/lili/modules/goods/entity/vos/GoodsParamsDTOVO.java @@ -1,7 +1,7 @@ package cn.lili.modules.goods.entity.vos; -import cn.lili.modules.goods.entity.dos.GoodsParams; +import cn.lili.modules.goods.entity.dto.GoodsParamsDTO; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -12,7 +12,7 @@ import lombok.Data; * @date 2020-02-26 23:24:13 */ @Data -public class GoodsParamsVO extends GoodsParams { +public class GoodsParamsDTOVO extends GoodsParamsDTO { private static final long serialVersionUID = -4904700751774005326L; @ApiModelProperty("1 输入项 2 选择项") diff --git a/framework/src/main/java/cn/lili/modules/goods/entity/vos/GoodsParamsGroupVO.java b/framework/src/main/java/cn/lili/modules/goods/entity/vos/GoodsParamsGroupVO.java index 18d0a9d5..9202f953 100644 --- a/framework/src/main/java/cn/lili/modules/goods/entity/vos/GoodsParamsGroupVO.java +++ b/framework/src/main/java/cn/lili/modules/goods/entity/vos/GoodsParamsGroupVO.java @@ -16,7 +16,7 @@ import java.util.List; public class GoodsParamsGroupVO implements Serializable { private static final long serialVersionUID = 1450550797436233753L; @ApiModelProperty("参数组关联的参数集合") - private List params; + private List params; @ApiModelProperty("参数组名称") private String groupName; @ApiModelProperty("参数组id") diff --git a/framework/src/main/java/cn/lili/modules/goods/entity/vos/GoodsVO.java b/framework/src/main/java/cn/lili/modules/goods/entity/vos/GoodsVO.java index 6207aac0..ebb31251 100644 --- a/framework/src/main/java/cn/lili/modules/goods/entity/vos/GoodsVO.java +++ b/framework/src/main/java/cn/lili/modules/goods/entity/vos/GoodsVO.java @@ -1,7 +1,7 @@ package cn.lili.modules.goods.entity.vos; import cn.lili.modules.goods.entity.dos.Goods; -import cn.lili.modules.goods.entity.dos.GoodsParams; +import cn.lili.modules.goods.entity.dto.GoodsParamsDTO; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -22,7 +22,7 @@ public class GoodsVO extends Goods { private List categoryName; @ApiModelProperty(value = "商品参数") - private List goodsParamsList; + private List goodsParamsDTOList; @ApiModelProperty(value = "商品图片") private List goodsGalleryList; diff --git a/framework/src/main/java/cn/lili/modules/goods/entity/vos/SpecValueVO.java b/framework/src/main/java/cn/lili/modules/goods/entity/vos/SpecValueVO.java index 79ee16af..81bbc39b 100644 --- a/framework/src/main/java/cn/lili/modules/goods/entity/vos/SpecValueVO.java +++ b/framework/src/main/java/cn/lili/modules/goods/entity/vos/SpecValueVO.java @@ -26,14 +26,24 @@ public class SpecValueVO implements Serializable { @ApiModelProperty(value = "规格值") private String specValue; - /** - * 规格类型,1图片 0 非图片 - */ @ApiModelProperty(value = "该规格是否有图片,1 有 0 没有") private Integer specType; /** * 规格图片 */ @ApiModelProperty(value = "规格的图片") - private List specImage; + private List specImage; + + @Data + public static class SpecImages implements Serializable { + + private static final long serialVersionUID = 1816357809660916086L; + + private String url; + + private String name; + + private String status; + + } } diff --git a/framework/src/main/java/cn/lili/modules/goods/mapper/GoodsMapper.java b/framework/src/main/java/cn/lili/modules/goods/mapper/GoodsMapper.java index 928248c7..cea5e6a8 100644 --- a/framework/src/main/java/cn/lili/modules/goods/mapper/GoodsMapper.java +++ b/framework/src/main/java/cn/lili/modules/goods/mapper/GoodsMapper.java @@ -10,6 +10,8 @@ import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Select; 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 { /** - * 下架所有商家商品 + * 根据店铺ID获取商品ID列表 * - * @param storeId + * @param storeId 店铺ID */ - @Update("update li_goods set market_enable = 0 WHERE store_id = #{storeId}") - void underStoreGoods(String storeId); + @Select("SELECT id FROM li_goods WHERE store_id = #{storeId}") + List getGoodsIdByStoreId(String storeId); @Update("UPDATE li_goods SET comment_num = comment_num + #{commentNum} WHERE id = #{goodsId}") void addGoodsCommentNum(Integer commentNum, String goodsId); diff --git a/framework/src/main/java/cn/lili/modules/goods/mapper/GoodsParamsMapper.java b/framework/src/main/java/cn/lili/modules/goods/mapper/GoodsParamsMapper.java index 37d136f4..471c649c 100644 --- a/framework/src/main/java/cn/lili/modules/goods/mapper/GoodsParamsMapper.java +++ b/framework/src/main/java/cn/lili/modules/goods/mapper/GoodsParamsMapper.java @@ -1,7 +1,7 @@ package cn.lili.modules.goods.mapper; -import cn.lili.modules.goods.entity.dos.GoodsParams; -import cn.lili.modules.goods.entity.vos.GoodsParamsVO; +import cn.lili.modules.goods.entity.dto.GoodsParamsDTO; +import cn.lili.modules.goods.entity.vos.GoodsParamsDTOVO; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Select; @@ -14,9 +14,9 @@ import java.util.List; * @author pikachu * @date 2020-02-18 15:18:56 */ -public interface GoodsParamsMapper extends BaseMapper { +public interface GoodsParamsMapper extends BaseMapper { @Select("select p.*,gp.param_value,p.group_id from li_parameters p left join li_goods_params gp on p.id=gp.param_id and gp.goods_id = #{goodsId} where p.category_id = #{categoryId} order by sort") - List paramList(String goodsId, String categoryId); + List paramList(String goodsId, String categoryId); } \ No newline at end of file diff --git a/framework/src/main/java/cn/lili/modules/goods/service/GoodsParamsService.java b/framework/src/main/java/cn/lili/modules/goods/service/GoodsParamsService.java deleted file mode 100644 index bd8195fc..00000000 --- a/framework/src/main/java/cn/lili/modules/goods/service/GoodsParamsService.java +++ /dev/null @@ -1,76 +0,0 @@ -package cn.lili.modules.goods.service; - -import cn.lili.modules.goods.entity.dos.GoodsParams; -import cn.lili.modules.goods.entity.vos.GoodsParamsGroupVO; -import cn.lili.modules.goods.entity.vos.GoodsParamsVO; -import com.baomidou.mybatisplus.extension.service.IService; - -import java.util.List; - - -/** - * 商品关联参数业务层 - * - * @author pikachu - * @date 2020-03-13 16:18:56 - */ -public interface GoodsParamsService extends IService { - - /** - * 添加商品参数 - * @param paramList 参数列表 - * @param goodsId 商品ID - */ - void addParams(List paramList, String goodsId); - - /** - * 更新商品参数是否索引 - * - * @param paramId 参数id - * @param isIndex 是否索引 - */ - void updateParametersIsIndex(String paramId, Integer isIndex); - - /** - * 根据参数id删除已经设置的商品参数 - * - * @param paramId 参数id - */ - void deleteByParamId(String paramId); - - /** - * 获取商品关联参数 - * - * @param goodsId 商品ID - * @return 商品关联参数 - */ - List getGoodsParamsByGoodsId(String goodsId); - - /** - * 添加商品参数 - * - * @param goodsParamsVO 商品参数 - * @return 添加是否成功 - */ - boolean addParams(GoodsParamsVO goodsParamsVO); - - /** - * 根据分类id查询绑定参数信息 - * - * @param categoryId 分类id - * @param goodsId 商品id - * @return 分类id - */ - List paramList(String categoryId, String goodsId); - - /** - * 查询商品参数信息 - * - * @param goodsId 商品id - * @param categoryId 分了id - * @return 商品参数信息 - */ - List queryGoodsParams(String goodsId, String categoryId); - - -} \ No newline at end of file diff --git a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/CategoryServiceImpl.java b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/CategoryServiceImpl.java index 3c46db2b..6f350d1c 100644 --- a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/CategoryServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/CategoryServiceImpl.java @@ -8,7 +8,7 @@ import cn.lili.modules.goods.entity.dos.Category; import cn.lili.modules.goods.entity.dos.CategoryParameterGroup; import cn.lili.modules.goods.entity.vos.CategoryVO; import cn.lili.modules.goods.entity.vos.GoodsParamsGroupVO; -import cn.lili.modules.goods.entity.vos.GoodsParamsVO; +import cn.lili.modules.goods.entity.vos.GoodsParamsDTOVO; import cn.lili.modules.goods.mapper.CategoryMapper; import cn.lili.modules.goods.service.CategoryService; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; @@ -255,13 +255,13 @@ public class CategoryServiceImpl extends ServiceImpl i * @param paramList 参数列表 * @return 拼装后的返回值 */ - private List convertParamList(List groupList, List paramList) { - Map> map = new HashMap<>(16); - for (GoodsParamsVO param : paramList) { + private List convertParamList(List groupList, List paramList) { + Map> map = new HashMap<>(16); + for (GoodsParamsDTOVO param : paramList) { if (map.get(param.getGroupId()) != null) { map.get(param.getGroupId()).add(param); } else { - List list = new ArrayList<>(); + List list = new ArrayList<>(); list.add(param); map.put(param.getGroupId(), list); } diff --git a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/DraftGoodsServiceImpl.java b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/DraftGoodsServiceImpl.java index ca55c272..25292b88 100644 --- a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/DraftGoodsServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/DraftGoodsServiceImpl.java @@ -8,6 +8,7 @@ import cn.lili.common.utils.StringUtils; import cn.lili.modules.goods.entity.dos.*; import cn.lili.modules.goods.entity.dto.DraftGoodsDTO; import cn.lili.modules.goods.entity.dto.DraftGoodsSearchParams; +import cn.lili.modules.goods.entity.dto.GoodsParamsDTO; import cn.lili.modules.goods.entity.vos.DraftGoodsVO; import cn.lili.modules.goods.mapper.DraftGoodsMapper; import cn.lili.modules.goods.service.CategoryService; @@ -45,7 +46,7 @@ public class DraftGoodsServiceImpl extends ServiceImpl list = JSONUtil.toList(jsonArray, GoodsSku.class); diff --git a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsParamsServiceImpl.java b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsParamsServiceImpl.java deleted file mode 100644 index fc3d10ca..00000000 --- a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsParamsServiceImpl.java +++ /dev/null @@ -1,147 +0,0 @@ -package cn.lili.modules.goods.serviceimpl; - -import cn.lili.modules.goods.entity.dos.CategoryParameterGroup; -import cn.lili.modules.goods.entity.dos.GoodsParams; -import cn.lili.modules.goods.entity.dos.Parameters; -import cn.lili.modules.goods.entity.vos.GoodsParamsGroupVO; -import cn.lili.modules.goods.entity.vos.GoodsParamsVO; -import cn.lili.modules.goods.mapper.GoodsParamsMapper; -import cn.lili.modules.goods.service.CategoryParameterGroupService; -import cn.lili.modules.goods.service.GoodsParamsService; -import cn.lili.modules.goods.service.ParametersService; -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.UpdateWrapper; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - - -/** - * 商品关联参数接口实现 - * - * @author pikachu - * @version v1.0 - * @since v1.0 - * 2020-02-23 15:18:56 - */ -@Service -@Transactional -public class GoodsParamsServiceImpl extends ServiceImpl implements GoodsParamsService { - //分类-参数绑定 - @Autowired - private CategoryParameterGroupService categoryParameterGroupService; - - @Autowired - private ParametersService parametersService; - - @Override - public void addParams(List paramList, String goodsId) { - //先删除现有商品参数 - this.remove(new UpdateWrapper().eq("goods_id", goodsId)); - //循环添加参数 - if (paramList != null) { - for (GoodsParams param : paramList) { - Parameters parameters = parametersService.getById(param.getParamId()); - GoodsParams goodsParams = new GoodsParams(); - goodsParams.setGoodsId(goodsId); - goodsParams.setParamName(param.getParamName()); - goodsParams.setParamValue(param.getParamValue()); - goodsParams.setIsIndex(parameters.getIsIndex()); - goodsParams.setParamId(param.getId()); - this.save(goodsParams); - } - } - } - - /** - * 更新商品参数是否索引 - * - * @param paramId 参数id - * @param isIndex 是否索引 - */ - @Override - public void updateParametersIsIndex(String paramId, Integer isIndex) { - LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper<>(); - updateWrapper.eq(GoodsParams::getParamId, paramId); - updateWrapper.set(GoodsParams::getIsIndex, isIndex); - this.update(updateWrapper); - } - - /** - * 根据参数id删除已经设置的商品参数 - * - * @param paramId 参数id - */ - @Override - public void deleteByParamId(String paramId) { - this.remove(new QueryWrapper().eq("param_id", paramId)); - } - - @Override - public List getGoodsParamsByGoodsId(String goodsId) { - return this.list(new LambdaQueryWrapper().eq(GoodsParams::getGoodsId, goodsId)); - } - - /** - * 添加商品参数 - * - * @param goodsParamsVO 商品参数 - * @return 添加是否成功 - */ - @Override - public boolean addParams(GoodsParamsVO goodsParamsVO) { - return this.save(goodsParamsVO); - } - - @Override - public List paramList(String goodsId, String categoryId) { - return this.baseMapper.paramList(goodsId, categoryId); - } - - @Override - public List queryGoodsParams(String categoryId, String goodsId) { - //查询分类关联参数组 - List groupList = categoryParameterGroupService.getCategoryGroup(categoryId); - //查询商品参数 - List paramList = this.paramList(goodsId, categoryId); - //拼装数据返回 - return this.convertParamList(groupList, paramList); - } - - - /** - * 拼装返回值 - * - * @param paramList - * @return - */ - private List convertParamList(List groupList, List paramList) { - Map> map = new HashMap<>(16); - for (GoodsParamsVO param : paramList) { - if (map.get(param.getGroupId()) != null) { - map.get(param.getGroupId()).add(param); - } else { - List list = new ArrayList<>(); - list.add(param); - map.put(param.getGroupId(), list); - } - } - List resList = new ArrayList<>(); - for (CategoryParameterGroup group : groupList) { - GoodsParamsGroupVO list = new GoodsParamsGroupVO(); - list.setGroupName(group.getGroupName()); - list.setGroupId(group.getId()); - list.setParams(map.get(group.getId())); - resList.add(list); - } - return resList; - } -} \ No newline at end of file diff --git a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsServiceImpl.java b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsServiceImpl.java index 29593f34..b9167c90 100644 --- a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsServiceImpl.java @@ -16,12 +16,16 @@ import cn.lili.config.rocketmq.RocketmqCustomProperties; import cn.lili.modules.goods.entity.dos.Category; import cn.lili.modules.goods.entity.dos.Goods; import cn.lili.modules.goods.entity.dos.GoodsGallery; +import cn.lili.modules.goods.entity.dos.Parameters; import cn.lili.modules.goods.entity.dto.GoodsOperationDTO; +import cn.lili.modules.goods.entity.dto.GoodsParamsDTO; +import cn.lili.modules.goods.entity.dto.GoodsParamsItemDTO; import cn.lili.modules.goods.entity.dto.GoodsSearchParams; import cn.lili.modules.goods.entity.enums.GoodsAuthEnum; import cn.lili.modules.goods.entity.enums.GoodsStatusEnum; import cn.lili.modules.goods.entity.vos.GoodsSkuVO; import cn.lili.modules.goods.entity.vos.GoodsVO; +import cn.lili.modules.goods.entity.vos.ParameterGroupVO; import cn.lili.modules.goods.mapper.GoodsMapper; import cn.lili.modules.goods.service.*; import cn.lili.modules.member.entity.dos.MemberEvaluation; @@ -59,9 +63,7 @@ import java.util.List; @Transactional public class GoodsServiceImpl extends ServiceImpl implements GoodsService { - //商品属性 - @Autowired - private GoodsParamsService goodsParamsService; + //分类 @Autowired private CategoryService categoryService; @@ -85,11 +87,16 @@ public class GoodsServiceImpl extends ServiceImpl implements //rocketMq配置 @Autowired private RocketmqCustomProperties rocketmqCustomProperties; + @Autowired + private CategoryParameterGroupService categoryParameterGroupService; @Override public void underStoreGoods(String storeId) { - this.baseMapper.underStoreGoods(storeId); + //获取商品ID列表 + List list= this.baseMapper.getGoodsIdByStoreId(storeId); + //下架店铺下的商品 + updateGoodsMarketAble(list,GoodsStatusEnum.DOWN,"店铺关闭"); } @Override @@ -107,12 +114,15 @@ public class GoodsServiceImpl extends ServiceImpl implements this.checkGoods(goods); //向goods加入图片 this.setGoodsGalleryParam(goodsOperationDTO.getGoodsGalleryList().get(0), goods); + //添加商品参数 + if (goodsOperationDTO.getGoodsParamsDTOList() != null && !goodsOperationDTO.getGoodsParamsDTOList().isEmpty()) { + //检测商品参数是否合法 + //this.checkGoodsParams(goodsOperationDTO.getGoodsParamsDTOList(), goodsOperationDTO.getCategoryPath().substring(goodsOperationDTO.getCategoryPath().lastIndexOf(",") + 1)); + //给商品参数填充值 + goods.setParams(JSONUtil.toJsonStr(goodsOperationDTO.getGoodsParamsDTOList())); + } //添加商品 this.save(goods); - //添加商品参数 - if (goodsOperationDTO.getGoodsParamsList() != null && !goodsOperationDTO.getGoodsParamsList().isEmpty()) { - this.goodsParamsService.addParams(goodsOperationDTO.getGoodsParamsList(), goods.getId()); - } //添加商品sku信息 this.goodsSkuService.add(goodsOperationDTO.getSkuList(), goods); //添加相册 @@ -130,12 +140,12 @@ public class GoodsServiceImpl extends ServiceImpl implements this.checkGoods(goods); //向goods加入图片 this.setGoodsGalleryParam(goodsOperationDTO.getGoodsGalleryList().get(0), goods); + //添加商品参数 + if (goodsOperationDTO.getGoodsParamsDTOList() != null && !goodsOperationDTO.getGoodsParamsDTOList().isEmpty()) { + goods.setParams(JSONUtil.toJsonStr(goodsOperationDTO.getGoodsParamsDTOList())); + } //修改商品 this.updateById(goods); - //添加商品参数 - if (goodsOperationDTO.getGoodsParamsList() != null && !goodsOperationDTO.getGoodsParamsList().isEmpty()) { - this.goodsParamsService.addParams(goodsOperationDTO.getGoodsParamsList(), goods.getId()); - } //修改商品sku信息 this.goodsSkuService.update(goodsOperationDTO.getSkuList(), goods, goodsOperationDTO.getRegeneratorSkuFlag()); //添加相册 @@ -180,7 +190,10 @@ public class GoodsServiceImpl extends ServiceImpl implements } goodsVO.setCategoryName(categoryName); - goodsVO.setGoodsParamsList(goodsParamsService.getGoodsParamsByGoodsId(goodsId)); + //参数非空则填写参数 + if (StringUtils.isNotEmpty(goods.getParams())) { + goodsVO.setGoodsParamsDTOList(JSONUtil.toList(goods.getParams(), GoodsParamsDTO.class)); + } return goodsVO; } @@ -321,6 +334,52 @@ public class GoodsServiceImpl extends ServiceImpl implements goods.setThumbnail(goodsGallery.getThumbnail()); } + /** + * 检测商品参数是否非法传递 + * + * @param goodsParamsDTOS 商品参数 + * @param categoryId 分类id + */ + private void checkGoodsParams(List goodsParamsDTOS, String categoryId) { + //根据绑定的分了id查询出参数信息 + List parameterGroupVOS = categoryParameterGroupService.getCategoryParams(categoryId); + if (parameterGroupVOS.size() > 0) { + //绑定分类的参数集合 + List parametersList = new ArrayList<>(); + //循环分类绑定的参数信息 把它整理到新的分类参数集合中 用于最后的参数信息对比 + for (ParameterGroupVO parameterGroupVO : parameterGroupVOS) { + List parameters = parameterGroupVO.getParams(); + for (Parameters param : parameters) { + parametersList.add(param); + } + } + List goodsOperationParamList = new ArrayList<>(); + //循环添加商品传递的参数信息 把它整理到新的分类参数集合中 用于最后的参数信息对比 + for (GoodsParamsDTO goodsParamsDTO : goodsParamsDTOS) { + List goodsParamsItemDTOS = goodsParamsDTO.getGoodsParamsItemDTOList(); + for (GoodsParamsItemDTO goodsParamsItemDTO : goodsParamsItemDTOS) { + goodsOperationParamList.add(goodsParamsItemDTO); + } + } + //两个参数集合进行对比 + for (Parameters parameters :parametersList){ + for (GoodsParamsItemDTO goodsParamsItemDTO :goodsOperationParamList){ + if(parameters.getId().equals(goodsParamsItemDTO.getParamId())){ + //校验是否可以索引参数是否正确 + if(!parameters.getIsIndex().equals(goodsParamsItemDTO.getIsIndex())){ + throw new ServiceException("商品参数错误,刷新后重试"); + } + //校验是否必填参数是否正确 + if(!parameters.getRequired().equals(goodsParamsItemDTO.getRequired())){ + throw new ServiceException("商品参数错误,刷新后重试"); + } + } + } + } + + } + } + /** * 检查商品信息 * 如果商品是虚拟商品则无需配置配送模板 diff --git a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsSkuServiceImpl.java b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsSkuServiceImpl.java index 9f8e0f68..8f28f806 100644 --- a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsSkuServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsSkuServiceImpl.java @@ -11,9 +11,10 @@ import cn.lili.common.rocketmq.RocketmqSendCallbackBuilder; import cn.lili.common.rocketmq.tags.GoodsTagsEnum; import cn.lili.common.security.context.UserContext; import cn.lili.common.utils.PageUtil; +import cn.lili.common.utils.StringUtils; import cn.lili.config.rocketmq.RocketmqCustomProperties; import cn.lili.modules.goods.entity.dos.Goods; -import cn.lili.modules.goods.entity.dos.GoodsParams; +import cn.lili.modules.goods.entity.dto.GoodsParamsDTO; import cn.lili.modules.goods.entity.dos.GoodsSku; import cn.lili.modules.goods.entity.dto.GoodsSearchParams; import cn.lili.modules.goods.entity.dto.GoodsSkuStockDTO; @@ -44,6 +45,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.*; +import java.util.stream.Collectors; /** * 商品sku业务层实现 @@ -64,9 +66,6 @@ public class GoodsSkuServiceImpl extends ServiceImpl i //商品相册 @Autowired private GoodsGalleryService goodsGalleryService; - //规格 - @Autowired - private SpecificationService specificationService; //缓存 @Autowired private StringRedisTemplate stringRedisTemplate; @@ -208,7 +207,7 @@ public class GoodsSkuServiceImpl extends ServiceImpl i //获取当前商品的索引信息 EsGoodsIndex goodsIndex = goodsIndexService.findById(skuId); if (goodsIndex == null) { - goodsIndex = goodsIndexService.resetEsGoodsIndex(goodsSku, goodsVO.getGoodsParamsList()); + goodsIndex = goodsIndexService.resetEsGoodsIndex(goodsSku, goodsVO.getGoodsParamsDTOList()); } //商品规格 GoodsSkuVO goodsSkuDetail = this.getGoodsSkuVO(goodsSku); @@ -320,33 +319,30 @@ public class GoodsSkuServiceImpl extends ServiceImpl i @Override public GoodsSkuVO getGoodsSkuVO(GoodsSku goodsSku) { + //厨师还商品 GoodsSkuVO goodsSkuVO = new GoodsSkuVO(goodsSku); + //获取sku信息 JSONObject jsonObject = JSONUtil.parseObj(goodsSku.getSpecs()); + //用于接受sku信息 List specValueVOS = new ArrayList<>(); + //用于接受sku相册 List goodsGalleryList = new ArrayList<>(); -// for (Map.Entry entry : jsonObject.entrySet()) { -// SpecValueVO s = new SpecValueVO(); -// if (entry.getKey().equals("images")) { -// s.setSpecName(entry.getKey()); -// if (entry.getValue().toString().contains("url")) { -// List specImages = JSONUtil.toList(JSONUtil.parseArray(entry.getValue()), SpecValueVO.SpecImages.class); -// s.setSpecImage(specImages); -// goodsGalleryList = specImages.stream().map(SpecValueVO.SpecImages::getUrl).collect(Collectors.toList()); -// } -// } else { -// SpecificationVO specificationVO = new SpecificationVO(); -// specificationVO.setSpecName(entry.getKey()); -// specificationVO.setStoreId(goodsSku.getStoreId()); -// specificationVO.setCategoryPath(goodsSku.getCategoryPath()); -// Specification specification = specificationService.addSpecification(specificationVO); -// s.setSpecNameId(specification.getId()); -// SpecValues specValues = specValuesService.getSpecValues(entry.getValue().toString(), specification.getId()); -// s.setSpecValueId(specValues.getId()); -// s.setSpecName(entry.getKey()); -// s.setSpecValue(entry.getValue().toString()); -// } -// specValueVOS.add(s); -// } + //循环提交的sku表单 + for (Map.Entry entry : jsonObject.entrySet()) { + SpecValueVO specValueVO = new SpecValueVO(); + if (entry.getKey().equals("images")) { + specValueVO.setSpecName(entry.getKey()); + if (entry.getValue().toString().contains("url")) { + List specImages = JSONUtil.toList(JSONUtil.parseArray(entry.getValue()), SpecValueVO.SpecImages.class); + specValueVO.setSpecImage(specImages); + goodsGalleryList = specImages.stream().map(SpecValueVO.SpecImages::getUrl).collect(Collectors.toList()); + } + } else { + specValueVO.setSpecName(entry.getKey()); + specValueVO.setSpecValue(entry.getValue().toString()); + } + specValueVOS.add(specValueVO); + } goodsSkuVO.setGoodsGalleryList(goodsGalleryList); goodsSkuVO.setSpecList(specValueVOS); return goodsSkuVO; @@ -465,8 +461,8 @@ public class GoodsSkuServiceImpl extends ServiceImpl i EsGoodsIndex esGoodsOld = goodsIndexService.findById(goodsSku.getId()); EsGoodsIndex goodsIndex = new EsGoodsIndex(goodsSku); if (goods.getParams() != null && !goods.getParams().isEmpty()) { - List goodsParams = JSONUtil.toList(goods.getParams(), GoodsParams.class); - goodsIndex = new EsGoodsIndex(goodsSku, goodsParams); + List goodsParamDTOS = JSONUtil.toList(goods.getParams(), GoodsParamsDTO.class); + goodsIndex = new EsGoodsIndex(goodsSku, goodsParamDTOS); } //如果商品库存不为0,并且es中有数据 if (goodsSku.getQuantity() > 0 && esGoodsOld == null) { @@ -606,29 +602,34 @@ public class GoodsSkuServiceImpl extends ServiceImpl i List attributes = new ArrayList<>(); //获取规格信息 - for (Map.Entry m : map.entrySet()) { + for (Map.Entry spec : map.entrySet()) { //保存规格信息 - if (m.getKey().equals("id") || m.getKey().equals("sn") || m.getKey().equals("cost") || m.getKey().equals("price") || m.getKey().equals("quantity") || m.getKey().equals("weight")) { + if (spec.getKey().equals("id") || spec.getKey().equals("sn") || spec.getKey().equals("cost") + || spec.getKey().equals("price") || spec.getKey().equals("quantity") + || spec.getKey().equals("weight")) { continue; } else { - specMap.put(m.getKey(), m.getValue()); - if (m.getKey().equals("images")) { + specMap.put(spec.getKey(), spec.getValue()); + if (spec.getKey().equals("images")) { //设置规格商品缩略图 - List> images = (List>) m.getValue(); + List> images = (List>) spec.getValue(); if (images == null || images.isEmpty()) { - throw new ServiceException("sku图片至少为一个"); + continue; + } + //设置规格商品缩略图 + //如果规格没有图片,则用商品图片复盖。有则增加规格图片,放在商品图片集合之前 + if (spec.getValue() != null && StringUtils.isNotEmpty(spec.getValue().toString())) { + thumbnail = goodsGalleryService.getGoodsGallery(images.get(0).get("url")).getThumbnail(); + small = goodsGalleryService.getGoodsGallery(images.get(0).get("url")).getSmall(); + } else { + //设置商品名称 + goodsName.append(" ").append(spec.getValue()); + //规格简短信息 + simpleSpecs.append(" ").append(spec.getValue()); } - thumbnail = goodsGalleryService.getGoodsGallery(images.get(0).get("url")).getThumbnail(); - small = goodsGalleryService.getGoodsGallery(images.get(0).get("url")).getSmall(); - } else { - //设置商品名称 - goodsName.append(" ").append(m.getValue()); - //规格简短信息 - simpleSpecs.append(" ").append(m.getValue()); } } } - //设置规格信息 sku.setGoodsName(goodsName.toString()); sku.setThumbnail(thumbnail); @@ -659,4 +660,4 @@ public class GoodsSkuServiceImpl extends ServiceImpl i public void setGoodsIndexService(EsGoodsIndexService goodsIndexService) { this.goodsIndexService = goodsIndexService; } -} \ No newline at end of file +} diff --git a/framework/src/main/java/cn/lili/modules/member/entity/aop/interceptor/PointLogInterceptor.java b/framework/src/main/java/cn/lili/modules/member/entity/aop/interceptor/PointLogInterceptor.java index 7d6708ab..425fcb72 100644 --- a/framework/src/main/java/cn/lili/modules/member/entity/aop/interceptor/PointLogInterceptor.java +++ b/framework/src/main/java/cn/lili/modules/member/entity/aop/interceptor/PointLogInterceptor.java @@ -40,9 +40,9 @@ public class PointLogInterceptor { point = Long.valueOf(obj[0].toString()); } //变动类型 - Integer type = 0; + Boolean type = false; if (obj[1] != null) { - type = Integer.valueOf(obj[1].toString()); + type = Boolean.valueOf(obj[1].toString()); } //会员ID String memberId = ""; @@ -55,7 +55,7 @@ public class PointLogInterceptor { MemberPointsHistory memberPointsHistory = new MemberPointsHistory(); memberPointsHistory.setMemberId(member.getId()); memberPointsHistory.setMemberName(member.getUsername()); - memberPointsHistory.setPointType(type); + memberPointsHistory.setPointType(type ? 1 : 0); memberPointsHistory.setVariablePoint(point); memberPointsHistory.setBeforePoint(new Double(CurrencyUtil.sub(member.getPoint(), point)).longValue()); memberPointsHistory.setPoint(member.getPoint()); @@ -64,7 +64,7 @@ public class PointLogInterceptor { memberPointsHistoryService.save(memberPointsHistory); } } catch (Exception e) { - log.error("积分操作错误",e); + log.error("积分操作错误", e); } diff --git a/framework/src/main/java/cn/lili/modules/member/entity/dos/MemberAddress.java b/framework/src/main/java/cn/lili/modules/member/entity/dos/MemberAddress.java index 84d436d4..ad78c35b 100644 --- a/framework/src/main/java/cn/lili/modules/member/entity/dos/MemberAddress.java +++ b/framework/src/main/java/cn/lili/modules/member/entity/dos/MemberAddress.java @@ -1,7 +1,7 @@ package cn.lili.modules.member.entity.dos; import cn.lili.base.BaseEntity; -import cn.lili.common.validation.Mobile; +import cn.lili.common.validation.Phone; import com.baomidou.mybatisplus.annotation.TableName; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -34,7 +34,7 @@ public class MemberAddress extends BaseEntity { @ApiModelProperty(value = "收货人姓名") private String name; - @Mobile + @Phone @ApiModelProperty(value = "手机号码") private String mobile; diff --git a/framework/src/main/java/cn/lili/modules/member/entity/dto/EvaluationQueryParams.java b/framework/src/main/java/cn/lili/modules/member/entity/dto/EvaluationQueryParams.java index 63881cd3..5ff36340 100644 --- a/framework/src/main/java/cn/lili/modules/member/entity/dto/EvaluationQueryParams.java +++ b/framework/src/main/java/cn/lili/modules/member/entity/dto/EvaluationQueryParams.java @@ -1,5 +1,7 @@ package cn.lili.modules.member.entity.dto; +import cn.lili.common.security.context.UserContext; +import cn.lili.common.security.enums.UserEnums; import cn.lili.common.utils.StringUtils; import cn.lili.common.vo.PageVO; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; diff --git a/framework/src/main/java/cn/lili/modules/member/entity/dto/MemberAddressDTO.java b/framework/src/main/java/cn/lili/modules/member/entity/dto/MemberAddressDTO.java index 3fe583f9..ad07b84b 100644 --- a/framework/src/main/java/cn/lili/modules/member/entity/dto/MemberAddressDTO.java +++ b/framework/src/main/java/cn/lili/modules/member/entity/dto/MemberAddressDTO.java @@ -1,6 +1,6 @@ package cn.lili.modules.member.entity.dto; -import cn.lili.common.validation.Mobile; +import cn.lili.common.validation.Phone; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -20,7 +20,7 @@ public class MemberAddressDTO { @ApiModelProperty(value = "收货人姓名") private String consigneeName; - @Mobile + @Phone @ApiModelProperty(value = "手机号码") private String consigneeMobile; diff --git a/framework/src/main/java/cn/lili/modules/message/entity/dos/MemberMessage.java b/framework/src/main/java/cn/lili/modules/message/entity/dos/MemberMessage.java index 378e35b6..4ccb3fdd 100644 --- a/framework/src/main/java/cn/lili/modules/message/entity/dos/MemberMessage.java +++ b/framework/src/main/java/cn/lili/modules/message/entity/dos/MemberMessage.java @@ -43,7 +43,7 @@ public class MemberMessage extends BaseEntity { /** * @see MessageStatusEnum */ - @ApiModelProperty(value = "状态 0默认未读 1已读 2回收站") + @ApiModelProperty(value = "状态") private String status = MessageStatusEnum.UN_READY.name(); } \ No newline at end of file diff --git a/framework/src/main/java/cn/lili/modules/message/serviceimpl/MemberMessageServiceImpl.java b/framework/src/main/java/cn/lili/modules/message/serviceimpl/MemberMessageServiceImpl.java index 7b9a78ae..e5dfed67 100644 --- a/framework/src/main/java/cn/lili/modules/message/serviceimpl/MemberMessageServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/message/serviceimpl/MemberMessageServiceImpl.java @@ -31,13 +31,15 @@ public class MemberMessageServiceImpl extends ServiceImpl getPage(MemberMessageQueryVO memberMessageQueryVO, PageVO pageVO) { QueryWrapper queryWrapper = new QueryWrapper<>(); //消息id - queryWrapper.like(StringUtils.isNotEmpty(memberMessageQueryVO.getMessageId()), "message_id", memberMessageQueryVO.getMessageId()); + queryWrapper.eq(StringUtils.isNotEmpty(memberMessageQueryVO.getMessageId()), "message_id", memberMessageQueryVO.getMessageId()); //消息标题 queryWrapper.like(StringUtils.isNotEmpty(memberMessageQueryVO.getTitle()), "title", memberMessageQueryVO.getTitle()); //会员id - queryWrapper.like(StringUtils.isNotEmpty(memberMessageQueryVO.getMemberId()), "member_id", memberMessageQueryVO.getMemberId()); + queryWrapper.eq(StringUtils.isNotEmpty(memberMessageQueryVO.getMemberId()), "member_id", memberMessageQueryVO.getMemberId()); //消息状态 - queryWrapper.like(StringUtils.isNotEmpty(memberMessageQueryVO.getStatus()), "status", memberMessageQueryVO.getStatus()); + queryWrapper.eq(StringUtils.isNotEmpty(memberMessageQueryVO.getStatus()), "status", memberMessageQueryVO.getStatus()); + //倒序 + queryWrapper.orderByDesc("create_time"); //构建查询 return this.page(PageUtil.initPage(pageVO), queryWrapper); } diff --git a/framework/src/main/java/cn/lili/modules/message/util/WechatAccessTokenUtil.java b/framework/src/main/java/cn/lili/modules/message/util/WechatAccessTokenUtil.java index 26ca19e2..0ec1b8e5 100644 --- a/framework/src/main/java/cn/lili/modules/message/util/WechatAccessTokenUtil.java +++ b/framework/src/main/java/cn/lili/modules/message/util/WechatAccessTokenUtil.java @@ -110,5 +110,12 @@ public class WechatAccessTokenUtil { } + /** + * 清除 token + * @param clientTypeEnum + */ + public void removeAccessToken(ClientTypeEnum clientTypeEnum) { + cache.remove(CachePrefix.WECHAT_CGI_ACCESS_TOKEN.getPrefix() + clientTypeEnum.name()); + } } \ No newline at end of file diff --git a/framework/src/main/java/cn/lili/modules/order/cart/render/TradeBuilder.java b/framework/src/main/java/cn/lili/modules/order/cart/render/TradeBuilder.java index d51ddd1c..4454c8f9 100644 --- a/framework/src/main/java/cn/lili/modules/order/cart/render/TradeBuilder.java +++ b/framework/src/main/java/cn/lili/modules/order/cart/render/TradeBuilder.java @@ -80,6 +80,10 @@ public class TradeBuilder { /** * 构造一笔交易 + * 1.从缓存中读取交易数据 + * 2.从购物车列表中筛选出已选择的SKU列表存入交易中 + * 3.渲染整个交易(0-> 校验商品 1-》 满优惠渲染 2->渲染优惠 3->优惠券渲染 4->计算运费 5->计算价格 6->分销渲染 7->其他渲染) + * 4.将已选择的购物车列表存入交易中 * * @param checkedWay 购物车类型 * @return 购物车展示信息 @@ -98,6 +102,8 @@ public class TradeBuilder { log.error("购物车{}渲染异常:", cartRenderSteps.get(index).getClass(), e); } } + + //购物车信息接受 List cartVOList = new ArrayList<>(); //循环购物车信息 @@ -112,8 +118,10 @@ public class TradeBuilder { /** * 创建一笔交易 + * 1.构造交易 + * 2.创建交易 * - * @param checkedWay 购物车类型 + * @param checkedWay 购物车类型 * @return 交易信息 */ public Trade createTrade(CartTypeEnum checkedWay) { diff --git a/framework/src/main/java/cn/lili/modules/order/cart/render/impl/SkuFreightRender.java b/framework/src/main/java/cn/lili/modules/order/cart/render/impl/SkuFreightRender.java index 776f797b..5f71e10f 100644 --- a/framework/src/main/java/cn/lili/modules/order/cart/render/impl/SkuFreightRender.java +++ b/framework/src/main/java/cn/lili/modules/order/cart/render/impl/SkuFreightRender.java @@ -40,7 +40,7 @@ public class SkuFreightRender implements CartRenderStep { MemberAddress memberAddress = tradeDTO.getMemberAddress(); //如果收货地址为空,则抛出异常 if (memberAddress == null) { - throw new ServiceException(ResultCode.MEMBER_ADDRESS_NOT_EXIST); + return; } //循环渲染购物车商品运费价格 forSku: diff --git a/framework/src/main/java/cn/lili/modules/order/cart/service/CartService.java b/framework/src/main/java/cn/lili/modules/order/cart/service/CartService.java index 2d997b3f..c47b37e9 100644 --- a/framework/src/main/java/cn/lili/modules/order/cart/service/CartService.java +++ b/framework/src/main/java/cn/lili/modules/order/cart/service/CartService.java @@ -162,6 +162,13 @@ public interface CartService { /** * 创建交易 + * 1.获取购物车类型,不同的购物车类型有不同的订单逻辑 + * 购物车类型:购物车、立即购买、虚拟商品、拼团、积分 + * 2.校验用户的收件人信息 + * 3.设置交易的基础参数 + * 4.交易信息存储到缓存中 + * 5.创建交易 + * 6.清除购物车选择数据 * * @param tradeParams 创建交易参数 * @return 交易信息 diff --git a/framework/src/main/java/cn/lili/modules/order/cart/service/CartServiceImpl.java b/framework/src/main/java/cn/lili/modules/order/cart/service/CartServiceImpl.java index 4ccfd098..41fd0be2 100644 --- a/framework/src/main/java/cn/lili/modules/order/cart/service/CartServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/order/cart/service/CartServiceImpl.java @@ -360,17 +360,17 @@ public class CartServiceImpl implements CartService { private GoodsSku checkGoods(String skuId, Integer num) { GoodsSku dataSku = this.goodsSkuService.getGoodsSkuByIdFromCache(skuId); if (dataSku == null) { - throw new ServiceException("商品已失效,请重新选购!"); + throw new ServiceException(ResultCode.GOODS_NOT_EXIST); } if (!GoodsAuthEnum.PASS.name().equals(dataSku.getIsAuth()) || !GoodsStatusEnum.UPPER.name().equals(dataSku.getMarketEnable())) { - throw new ServiceException("商品已下架,请重新选购!"); + throw new ServiceException(ResultCode.GOODS_NOT_EXIST); } //读取sku的可用库存 Integer enableQuantity = goodsSkuService.getStock(skuId); //如果sku的可用库存小于等于0或者小于用户购买的数量,则不允许购买 if (enableQuantity <= 0 || enableQuantity < num) { - throw new ServiceException("商品库存已不足,请选购其他商品。"); + throw new ServiceException(ResultCode.GOODS_SKU_QUANTITY_NOT_ENOUGH); } return dataSku; } @@ -459,7 +459,7 @@ public class CartServiceImpl implements CartService { @Override public Long getCartNum(Boolean checked) { //构建购物车 - TradeDTO tradeDTO = this.getCheckedTradeDTO(CartTypeEnum.CART); + TradeDTO tradeDTO = this.getAllTradeDTO(); //过滤sku列表 List collect = tradeDTO.getSkuList().stream().filter(i -> Boolean.FALSE.equals(i.getInvalid())).collect(Collectors.toList()); long count = 0L; diff --git a/framework/src/main/java/cn/lili/modules/order/order/entity/dos/Order.java b/framework/src/main/java/cn/lili/modules/order/order/entity/dos/Order.java index 09903e68..daafdca9 100644 --- a/framework/src/main/java/cn/lili/modules/order/order/entity/dos/Order.java +++ b/framework/src/main/java/cn/lili/modules/order/order/entity/dos/Order.java @@ -219,27 +219,25 @@ public class Order extends BaseEntity { BeanUtil.copyProperties(tradeDTO, this); BeanUtil.copyProperties(cartVO.getPriceDetailDTO(), this); BeanUtil.copyProperties(cartVO, this); - //订单类型判断--普通订单,活动订单。 + //订单类型判断--普通订单,虚拟订单。 if (tradeDTO.getCartTypeEnum().equals(CartTypeEnum.CART) || tradeDTO.getCartTypeEnum().equals(CartTypeEnum.BUY_NOW)) { this.setOrderType(OrderTypeEnum.NORMAL.name()); } else if (tradeDTO.getCartTypeEnum().equals(CartTypeEnum.VIRTUAL)) { this.setOrderType(tradeDTO.getCartTypeEnum().name()); - } else { - this.setOrderType(OrderTypeEnum.NORMAL.name()); } this.setId(oldId); //促销信息填充 - if (cartVO.getSkuList().get(0).getPromotions() != null && tradeDTO.getCartTypeEnum().equals(CartTypeEnum.PINTUAN)) { - Optional pintuanId = cartVO.getSkuList().get(0).getPromotions().stream().filter(i -> i.getPromotionType().equals(PromotionTypeEnum.PINTUAN.name())).map(PromotionGoods::getPromotionId).findFirst(); - if (pintuanId.isPresent()) { - promotionId = pintuanId.get(); - this.setOrderType(OrderTypeEnum.PINTUAN.name()); - if (tradeDTO.getParentOrderSn() == null) { - this.setParentOrderSn(""); - } - } - } +// if (cartVO.getSkuList().get(0).getPromotions() != null && tradeDTO.getCartTypeEnum().equals(CartTypeEnum.PINTUAN)) { +// Optional pintuanId = cartVO.getSkuList().get(0).getPromotions().stream().filter(i -> i.getPromotionType().equals(PromotionTypeEnum.PINTUAN.name())).map(PromotionGoods::getPromotionId).findFirst(); +// if (pintuanId.isPresent()) { +// promotionId = pintuanId.get(); +// this.setOrderType(OrderTypeEnum.PINTUAN.name()); +// if (tradeDTO.getParentOrderSn() == null) { +// this.setParentOrderSn(""); +// } +// } +// } //设置默认支付状态 this.setOrderStatus(OrderStatusEnum.UNPAID.name()); diff --git a/framework/src/main/java/cn/lili/modules/order/order/entity/enums/OrderTypeEnum.java b/framework/src/main/java/cn/lili/modules/order/order/entity/enums/OrderTypeEnum.java index e670e523..8fba1a49 100644 --- a/framework/src/main/java/cn/lili/modules/order/order/entity/enums/OrderTypeEnum.java +++ b/framework/src/main/java/cn/lili/modules/order/order/entity/enums/OrderTypeEnum.java @@ -13,17 +13,8 @@ public enum OrderTypeEnum { */ NORMAL, - /** - * 赠品订单 - */ - GIFT, - /** * 虚拟订单 */ - VIRTUAL, - /** - * 拼团订单 - */ - PINTUAN + VIRTUAL } diff --git a/framework/src/main/java/cn/lili/modules/order/order/entity/vo/AfterSaleApplyVO.java b/framework/src/main/java/cn/lili/modules/order/order/entity/vo/AfterSaleApplyVO.java index 5259e528..847e2ca0 100644 --- a/framework/src/main/java/cn/lili/modules/order/order/entity/vo/AfterSaleApplyVO.java +++ b/framework/src/main/java/cn/lili/modules/order/order/entity/vo/AfterSaleApplyVO.java @@ -47,4 +47,12 @@ public class AfterSaleApplyVO { */ @ApiModelProperty(value = "账号类型", allowableValues = "ALIPAY,WECHATPAY,MEMBERWALLET,BANKTRANSFER") private String accountType; + + @ApiModelProperty(value = "是否支持退货") + private boolean returnGoods; + + @ApiModelProperty(value = "是否支持退款") + private boolean returnMoney; + + } diff --git a/framework/src/main/java/cn/lili/modules/order/order/entity/vo/AllowOperation.java b/framework/src/main/java/cn/lili/modules/order/order/entity/vo/AllowOperation.java index dd8a1e9a..2e39d768 100644 --- a/framework/src/main/java/cn/lili/modules/order/order/entity/vo/AllowOperation.java +++ b/framework/src/main/java/cn/lili/modules/order/order/entity/vo/AllowOperation.java @@ -69,8 +69,10 @@ public class AllowOperation implements Serializable { //新订单,允许支付 this.pay = status.equals(OrderStatusEnum.UNPAID.name()) && payStatus.equals(PayStatusEnum.UNPAID.name()); - //订单未发货,就可以编辑收货人信息 - this.editConsignee = order.getDeliverStatus().equals(DeliverStatusEnum.UNDELIVERED.name()) && !status.equals(OrderStatusEnum.CANCELLED.name()); + //可编辑订单收件人信息=实物订单 && 订单未发货 && 订单未取消 + this.editConsignee = order.getOrderType().equals(OrderTypeEnum.NORMAL.name()) + && order.getDeliverStatus().equals(DeliverStatusEnum.UNDELIVERED.name()) + && !status.equals(OrderStatusEnum.CANCELLED.name()); //是否允许被发货 this.ship = editConsignee && status.equals(OrderStatusEnum.UNDELIVERED.name()); diff --git a/framework/src/main/java/cn/lili/modules/order/order/service/OrderComplaintService.java b/framework/src/main/java/cn/lili/modules/order/order/service/OrderComplaintService.java index 4d742153..37eee01b 100644 --- a/framework/src/main/java/cn/lili/modules/order/order/service/OrderComplaintService.java +++ b/framework/src/main/java/cn/lili/modules/order/order/service/OrderComplaintService.java @@ -68,11 +68,11 @@ public interface OrderComplaintService extends IService { OrderComplaint updateOrderComplainByStatus(OrderComplaintOperationParams operationParam); /** - * 获取新投诉数量 + * 待处理投诉数量 * - * @return 新投诉 + * @return 待处理投诉数量 */ - Integer newComplainNum(); + Integer waitComplainNum(); /** * 取消交易投诉 diff --git a/framework/src/main/java/cn/lili/modules/order/order/service/OrderService.java b/framework/src/main/java/cn/lili/modules/order/order/service/OrderService.java index a44078ff..fbc45510 100644 --- a/framework/src/main/java/cn/lili/modules/order/order/service/OrderService.java +++ b/framework/src/main/java/cn/lili/modules/order/order/service/OrderService.java @@ -70,7 +70,9 @@ public interface OrderService extends IService { OrderDetailVO queryDetail(String orderSn); /** - * 创建交易 + * 创建订单 + * 1.检查交易信息 + * 2.循环交易购物车列表,创建订单以及相关信息 * * @param tradeDTO 交易DTO */ diff --git a/framework/src/main/java/cn/lili/modules/order/order/service/TradeService.java b/framework/src/main/java/cn/lili/modules/order/order/service/TradeService.java index 91457521..21fcfe5b 100644 --- a/framework/src/main/java/cn/lili/modules/order/order/service/TradeService.java +++ b/framework/src/main/java/cn/lili/modules/order/order/service/TradeService.java @@ -14,6 +14,13 @@ public interface TradeService extends IService { /** * 创建交易 + * 1.订单数据校验 + * 2.积分预处理 + * 3.优惠券预处理 + * 4.添加交易 + * 5.添加订单 + * 6.将交易写入缓存供消费者调用 + * 7.发送交易创建消息 * * @param tradeDTO 购物车视图 * @return 交易 diff --git a/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/AfterSaleServiceImpl.java b/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/AfterSaleServiceImpl.java index 2df123ac..4c4e44a5 100644 --- a/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/AfterSaleServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/AfterSaleServiceImpl.java @@ -20,6 +20,7 @@ import cn.lili.modules.order.order.entity.dos.OrderItem; import cn.lili.modules.order.order.entity.dto.AfterSaleDTO; import cn.lili.modules.order.order.entity.enums.OrderItemAfterSaleStatusEnum; import cn.lili.modules.order.order.entity.enums.OrderStatusEnum; +import cn.lili.modules.order.order.entity.enums.OrderTypeEnum; import cn.lili.modules.order.order.entity.enums.PayStatusEnum; import cn.lili.modules.order.order.entity.vo.AfterSaleApplyVO; import cn.lili.modules.order.order.entity.vo.AfterSaleSearchParams; @@ -128,6 +129,14 @@ public class AfterSaleServiceImpl extends ServiceImpl implements @OrderLogPoint(description = "'订单['+#orderSn+']取消,原因为:'+#reason", orderSn = "#orderSn") public Order cancel(String orderSn, String reason) { Order order = OperationalJudgment.judgment(this.getBySn(orderSn)); - if (order.getOrderPromotionType().equals(OrderPromotionTypeEnum.PINTUAN.name()) && !order.getOrderStatus().equals(OrderStatusEnum.UNDELIVERED.name())) { - throw new ServiceException("未成团订单不可取消"); + //如果订单促销类型不为空&&订单是拼团订单,并且订单未成团,则抛出异常 + if (OrderPromotionTypeEnum.PINTUAN.name().equals(order.getOrderPromotionType()) + && !order.getOrderStatus().equals(OrderStatusEnum.UNDELIVERED.name())) { + throw new ServiceException(ResultCode.ORDER_CAN_NOT_CANCEL); } if (CharSequenceUtil.equalsAny(order.getOrderStatus(), OrderStatusEnum.UNDELIVERED.name(), @@ -217,7 +219,7 @@ public class OrderServiceImpl extends ServiceImpl implements orderStatusMessage(order); return order; } else { - throw new ServiceException("当前订单状态不可取消"); + throw new ServiceException(ResultCode.ORDER_CAN_NOT_CANCEL); } } @@ -283,7 +285,7 @@ public class OrderServiceImpl extends ServiceImpl implements 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()); } else { //判断订单类型 @@ -365,13 +367,8 @@ public class OrderServiceImpl extends ServiceImpl implements //检测虚拟订单信息 checkVerificationOrder(order, verificationCode); order.setOrderStatus(OrderStatusEnum.COMPLETED.name()); - //修改订单信息 - this.updateById(order); - //发送订单完成消息 - OrderMessage orderMessage = new OrderMessage(); - orderMessage.setNewStatus(OrderStatusEnum.COMPLETED); - orderMessage.setOrderSn(order.getSn()); - this.sendUpdateStatusMessage(orderMessage); + //订单完成 + this.complete(orderSn); return order; } diff --git a/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/TradeServiceImpl.java b/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/TradeServiceImpl.java index b4e49d35..f1b66b6e 100644 --- a/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/TradeServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/TradeServiceImpl.java @@ -1,160 +1 @@ -package cn.lili.modules.order.order.serviceimpl; - -import cn.lili.common.cache.Cache; -import cn.lili.common.cache.CachePrefix; -import cn.lili.common.enums.ResultCode; -import cn.lili.common.exception.ServiceException; -import cn.lili.common.rocketmq.RocketmqSendCallbackBuilder; -import cn.lili.common.rocketmq.tags.MqOrderTagsEnum; -import cn.lili.config.rocketmq.RocketmqCustomProperties; -import cn.lili.modules.member.entity.dos.Member; -import cn.lili.modules.member.service.MemberService; -import cn.lili.modules.order.cart.entity.dto.MemberCouponDTO; -import cn.lili.modules.order.cart.entity.dto.TradeDTO; -import cn.lili.modules.order.cart.entity.vo.CartVO; -import cn.lili.modules.order.order.entity.dos.Order; -import cn.lili.modules.order.order.entity.dos.Trade; -import cn.lili.modules.order.order.entity.enums.PayStatusEnum; -import cn.lili.modules.order.order.mapper.TradeMapper; -import cn.lili.modules.order.order.service.OrderService; -import cn.lili.modules.order.order.service.TradeService; -import cn.lili.modules.promotion.service.CouponService; -import cn.lili.modules.promotion.service.MemberCouponService; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import org.apache.rocketmq.spring.core.RocketMQTemplate; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.stream.Collectors; - -/** - * 交易业务层实现 - * - * @author Chopper - * @date 2020/11/17 7:39 下午 - */ -@Service -@Transactional -public class TradeServiceImpl extends ServiceImpl implements TradeService { - - //缓存 - @Autowired - private Cache cache; - //订单 - @Autowired - private OrderService orderService; - //会员 - @Autowired - private MemberService memberService; - //优惠券 - @Autowired - private CouponService couponService; - //会员优惠券 - @Autowired - private MemberCouponService memberCouponService; - //RocketMQ - @Autowired - private RocketMQTemplate rocketMQTemplate; - //RocketMQ 配置 - @Autowired - private RocketmqCustomProperties rocketmqCustomProperties; - - - @Override - @Transactional(rollbackFor = Exception.class) - public Trade createTrade(TradeDTO tradeDTO) { - Trade trade = new Trade(tradeDTO); - String key = CachePrefix.TRADE.getPrefix() + trade.getSn(); - //积分预处理 - pointPretreatment(tradeDTO); - //优惠券预处理 - couponPretreatment(tradeDTO); - //添加交易 - this.save(trade); - //添加订单 - orderService.intoDB(tradeDTO); - //写入缓存,给消费者调用 - cache.put(key, tradeDTO); - //构建订单创建消息 - String destination = rocketmqCustomProperties.getOrderTopic() + ":" + MqOrderTagsEnum.ORDER_CREATE.name(); - //发送订单创建消息 - rocketMQTemplate.asyncSend(destination, key, RocketmqSendCallbackBuilder.commonCallback()); - return trade; - } - - @Override - public Trade getBySn(String sn) { - LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); - queryWrapper.eq(Trade::getSn, sn); - return this.getOne(queryWrapper); - } - - - @Override - public void payTrade(String tradeSn, String paymentName, String receivableNo) { - LambdaQueryWrapper orderQueryWrapper = new LambdaQueryWrapper<>(); - orderQueryWrapper.eq(Order::getTradeSn, tradeSn); - List orders = orderService.list(orderQueryWrapper); - for (Order order : orders) { - orderService.payOrder(order.getSn(), paymentName, receivableNo); - } - Trade trade = this.getBySn(tradeSn); - trade.setPayStatus(PayStatusEnum.PAID.name()); - this.saveOrUpdate(trade); - } - - /** - * 积分预处理 - * 下单同时,使用积分 - * - * @param tradeDTO - */ - private void pointPretreatment(TradeDTO tradeDTO) { - StringBuilder orderSns = new StringBuilder(); - for (CartVO item : tradeDTO.getCartList()) { - orderSns.append(item.getSn()).append(","); - } - if (tradeDTO.getPriceDetailDTO() != null && tradeDTO.getPriceDetailDTO().getPayPoint() != null && tradeDTO.getPriceDetailDTO().getPayPoint() > 0) { - Member userInfo = memberService.getUserInfo(); - if (userInfo.getPoint() < tradeDTO.getPriceDetailDTO().getPayPoint()) { - throw new ServiceException(ResultCode.PAY_POINT_ENOUGH); - } - boolean result = memberService.updateMemberPoint(tradeDTO.getPriceDetailDTO(). - getPayPoint().longValue(), false, tradeDTO.getMemberId(), - "订单【" + orderSns + "】创建,积分扣减"); - - if (!result) { - throw new ServiceException(ResultCode.PAY_POINT_ENOUGH); - } - } - } - - - /** - * 优惠券预处理 - * 下单同时,扣除优惠券 - * - * @param tradeDTO - */ - private void couponPretreatment(TradeDTO tradeDTO) { - List memberCouponDTOList = new ArrayList<>(); - if (null != tradeDTO.getPlatformCoupon()) { - memberCouponDTOList.add(tradeDTO.getPlatformCoupon()); - } - Collection storeCoupons = tradeDTO.getStoreCoupons().values(); - if (!storeCoupons.isEmpty()) { - memberCouponDTOList.addAll(storeCoupons); - } - List ids = memberCouponDTOList.stream().map(e -> e.getMemberCoupon().getId()).collect(Collectors.toList()); - memberCouponService.used(ids); - memberCouponDTOList.forEach(e -> couponService.usedCoupon(e.getMemberCoupon().getCouponId(), 1)); - - } - - -} \ No newline at end of file +package cn.lili.modules.order.order.serviceimpl; import cn.lili.common.cache.Cache; import cn.lili.common.cache.CachePrefix; import cn.lili.common.enums.ResultCode; import cn.lili.common.exception.ServiceException; import cn.lili.common.rocketmq.RocketmqSendCallbackBuilder; import cn.lili.common.rocketmq.tags.MqOrderTagsEnum; import cn.lili.config.rocketmq.RocketmqCustomProperties; import cn.lili.modules.member.entity.dos.Member; import cn.lili.modules.member.entity.dos.MemberAddress; import cn.lili.modules.member.service.MemberService; import cn.lili.modules.order.cart.entity.dto.MemberCouponDTO; import cn.lili.modules.order.cart.entity.dto.TradeDTO; import cn.lili.modules.order.cart.entity.vo.CartVO; import cn.lili.modules.order.order.entity.dos.Order; import cn.lili.modules.order.order.entity.dos.Trade; import cn.lili.modules.order.order.entity.enums.PayStatusEnum; import cn.lili.modules.order.order.mapper.TradeMapper; import cn.lili.modules.order.order.service.OrderService; import cn.lili.modules.order.order.service.TradeService; import cn.lili.modules.promotion.service.CouponService; import cn.lili.modules.promotion.service.MemberCouponService; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.apache.rocketmq.spring.core.RocketMQTemplate; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.stream.Collectors; /** * 交易业务层实现 * * @author Chopper * @date 2020/11/17 7:39 下午 */ @Service @Transactional public class TradeServiceImpl extends ServiceImpl implements TradeService { //缓存 @Autowired private Cache cache; //订单 @Autowired private OrderService orderService; //会员 @Autowired private MemberService memberService; //优惠券 @Autowired private CouponService couponService; //会员优惠券 @Autowired private MemberCouponService memberCouponService; //RocketMQ @Autowired private RocketMQTemplate rocketMQTemplate; //RocketMQ 配置 @Autowired private RocketmqCustomProperties rocketmqCustomProperties; @Override @Transactional(rollbackFor = Exception.class) public Trade createTrade(TradeDTO tradeDTO) { //创建订单预校验 createTradeCheck(tradeDTO); Trade trade = new Trade(tradeDTO); String key = CachePrefix.TRADE.getPrefix() + trade.getSn(); //积分预处理 pointPretreatment(tradeDTO); //优惠券预处理 couponPretreatment(tradeDTO); //添加交易 this.save(trade); //添加订单 orderService.intoDB(tradeDTO); //写入缓存,给消费者调用 cache.put(key, tradeDTO); //构建订单创建消息 String destination = rocketmqCustomProperties.getOrderTopic() + ":" + MqOrderTagsEnum.ORDER_CREATE.name(); //发送订单创建消息 rocketMQTemplate.asyncSend(destination, key, RocketmqSendCallbackBuilder.commonCallback()); return trade; } /** * 创建订单最后一步校验 * * @param tradeDTO */ private void createTradeCheck(TradeDTO tradeDTO) { //创建订单如果没有收获地址, MemberAddress memberAddress = tradeDTO.getMemberAddress(); if (memberAddress == null) { throw new ServiceException(ResultCode.MEMBER_ADDRESS_NOT_EXIST); } /** * 订单配送区域校验 */ if (tradeDTO.getNotSupportFreight() != null && tradeDTO.getNotSupportFreight().size() > 0) { StringBuilder stringBuilder = new StringBuilder("包含商品有-"); tradeDTO.getNotSupportFreight().forEach(sku -> { stringBuilder.append(sku.getGoodsSku().getGoodsName()); }); throw new ServiceException(ResultCode.ORDER_NOT_SUPPORT_DISTRIBUTION, stringBuilder.toString()); } } @Override public Trade getBySn(String sn) { LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.eq(Trade::getSn, sn); return this.getOne(queryWrapper); } @Override public void payTrade(String tradeSn, String paymentName, String receivableNo) { LambdaQueryWrapper orderQueryWrapper = new LambdaQueryWrapper<>(); orderQueryWrapper.eq(Order::getTradeSn, tradeSn); List orders = orderService.list(orderQueryWrapper); for (Order order : orders) { orderService.payOrder(order.getSn(), paymentName, receivableNo); } Trade trade = this.getBySn(tradeSn); trade.setPayStatus(PayStatusEnum.PAID.name()); this.saveOrUpdate(trade); } /** * 积分预处理 * 下单同时,使用积分 * * @param tradeDTO */ private void pointPretreatment(TradeDTO tradeDTO) { StringBuilder orderSns = new StringBuilder(); for (CartVO item : tradeDTO.getCartList()) { orderSns.append(item.getSn()).append(","); } if (tradeDTO.getPriceDetailDTO() != null && tradeDTO.getPriceDetailDTO().getPayPoint() != null && tradeDTO.getPriceDetailDTO().getPayPoint() > 0) { Member userInfo = memberService.getUserInfo(); if (userInfo.getPoint() < tradeDTO.getPriceDetailDTO().getPayPoint()) { throw new ServiceException(ResultCode.PAY_POINT_ENOUGH); } boolean result = memberService.updateMemberPoint(tradeDTO.getPriceDetailDTO(). getPayPoint().longValue(), false, tradeDTO.getMemberId(), "订单【" + orderSns + "】创建,积分扣减"); if (!result) { throw new ServiceException(ResultCode.PAY_POINT_ENOUGH); } } } /** * 优惠券预处理 * 下单同时,扣除优惠券 * * @param tradeDTO */ private void couponPretreatment(TradeDTO tradeDTO) { List memberCouponDTOList = new ArrayList<>(); if (null != tradeDTO.getPlatformCoupon()) { memberCouponDTOList.add(tradeDTO.getPlatformCoupon()); } Collection storeCoupons = tradeDTO.getStoreCoupons().values(); if (!storeCoupons.isEmpty()) { memberCouponDTOList.addAll(storeCoupons); } List ids = memberCouponDTOList.stream().map(e -> e.getMemberCoupon().getId()).collect(Collectors.toList()); memberCouponService.used(ids); memberCouponDTOList.forEach(e -> couponService.usedCoupon(e.getMemberCoupon().getCouponId(), 1)); } } \ No newline at end of file diff --git a/framework/src/main/java/cn/lili/modules/order/trade/service/RechargeService.java b/framework/src/main/java/cn/lili/modules/order/trade/service/RechargeService.java index c8919ded..a4b51e39 100644 --- a/framework/src/main/java/cn/lili/modules/order/trade/service/RechargeService.java +++ b/framework/src/main/java/cn/lili/modules/order/trade/service/RechargeService.java @@ -37,8 +37,9 @@ public interface RechargeService extends IService { * * @param sn 充值订单编号 * @param receivableNo 流水no + * @param paymentMethod 支付方式 */ - void paySuccess(String sn, String receivableNo); + void paySuccess(String sn, String receivableNo,String paymentMethod); /** * 根据充值订单号查询充值信息 diff --git a/framework/src/main/java/cn/lili/modules/order/trade/serviceimpl/RechargeServiceImpl.java b/framework/src/main/java/cn/lili/modules/order/trade/serviceimpl/RechargeServiceImpl.java index c0b8684a..8504ac30 100644 --- a/framework/src/main/java/cn/lili/modules/order/trade/serviceimpl/RechargeServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/order/trade/serviceimpl/RechargeServiceImpl.java @@ -1,9 +1,11 @@ package cn.lili.modules.order.trade.serviceimpl; +import cn.hutool.core.date.DateTime; import cn.lili.common.enums.ResultCode; import cn.lili.common.exception.ServiceException; import cn.lili.common.security.AuthUser; import cn.lili.common.security.context.UserContext; +import cn.lili.common.utils.DateUtil; import cn.lili.common.utils.PageUtil; import cn.lili.common.utils.SnowFlake; import cn.lili.common.utils.StringUtils; @@ -62,27 +64,28 @@ public class RechargeServiceImpl extends ServiceImpl i queryWrapper.eq(!StringUtils.isEmpty(rechargeQueryVO.getRechargeSn()), "recharge_sn", rechargeQueryVO.getRechargeSn()); //会员id queryWrapper.eq(!StringUtils.isEmpty(rechargeQueryVO.getMemberId()), "member_id", rechargeQueryVO.getMemberId()); - //已付款的充值订单 - queryWrapper.eq("pay_status", PayStatusEnum.PAID.name()); //支付时间 开始时间和结束时间 if (!StringUtils.isEmpty(rechargeQueryVO.getStartDate()) && !StringUtils.isEmpty(rechargeQueryVO.getEndDate())) { Date start = cn.hutool.core.date.DateUtil.parse(rechargeQueryVO.getStartDate()); Date end = cn.hutool.core.date.DateUtil.parse(rechargeQueryVO.getEndDate()); queryWrapper.between("pay_time", start, end); } + queryWrapper.orderByDesc("create_time"); //查询返回数据 return this.page(PageUtil.initPage(page), queryWrapper); } @Override - public void paySuccess(String sn, String receivableNo) { + public void paySuccess(String sn, String receivableNo,String paymentMethod) { //根据sn获取支付账单 Recharge recharge = this.getOne(new QueryWrapper().eq("recharge_sn", sn)); //如果支付账单不为空则进行一下逻辑 - if (recharge != null) { + if (recharge != null && !recharge.getPayStatus().equals(PayStatusEnum.PAID.name())) { //将此账单支付状态更改为已支付 recharge.setPayStatus(PayStatusEnum.PAID.name()); recharge.setReceivableNo(receivableNo); + recharge.setPayTime(new DateTime()); + recharge.setRechargeWay(paymentMethod); //执行保存操作 this.updateById(recharge); //增加预存款余额 diff --git a/framework/src/main/java/cn/lili/modules/payment/kit/params/impl/OrderCashier.java b/framework/src/main/java/cn/lili/modules/payment/kit/params/impl/OrderCashier.java index d99ef09b..dc0bbc56 100644 --- a/framework/src/main/java/cn/lili/modules/payment/kit/params/impl/OrderCashier.java +++ b/framework/src/main/java/cn/lili/modules/payment/kit/params/impl/OrderCashier.java @@ -9,15 +9,14 @@ import cn.lili.modules.order.order.entity.enums.OrderStatusEnum; import cn.lili.modules.order.order.entity.enums.PayStatusEnum; import cn.lili.modules.order.order.entity.vo.OrderDetailVO; import cn.lili.modules.order.order.service.OrderService; -import cn.lili.modules.payment.kit.dto.PaymentSuccessParams; import cn.lili.modules.payment.kit.dto.PayParam; +import cn.lili.modules.payment.kit.dto.PaymentSuccessParams; import cn.lili.modules.payment.kit.enums.CashierEnum; import cn.lili.modules.payment.kit.params.CashierExecute; import cn.lili.modules.payment.kit.params.dto.CashierParam; import cn.lili.modules.system.entity.dto.BaseSetting; import cn.lili.modules.system.entity.enums.SettingEnum; import cn.lili.modules.system.service.SettingService; -import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -106,7 +105,7 @@ public class OrderCashier implements CashierExecute { if (payParam.getOrderType().equals(CashierEnum.ORDER.name())) { Order order = orderService.getBySn(payParam.getSn()); if (order != null) { - return order.getPayStatus().equals(PayStatusEnum.PAID.name()); + return PayStatusEnum.PAID.name().equals(order.getPayStatus()); } else { throw new ServiceException(ResultCode.PAY_NOT_EXIST_ORDER); } diff --git a/framework/src/main/java/cn/lili/modules/payment/kit/params/impl/RechargeCashier.java b/framework/src/main/java/cn/lili/modules/payment/kit/params/impl/RechargeCashier.java index f60bd762..75fc952e 100644 --- a/framework/src/main/java/cn/lili/modules/payment/kit/params/impl/RechargeCashier.java +++ b/framework/src/main/java/cn/lili/modules/payment/kit/params/impl/RechargeCashier.java @@ -45,7 +45,7 @@ public class RechargeCashier implements CashierExecute { public void paymentSuccess(PaymentSuccessParams paymentSuccessParams) { PayParam payParam = paymentSuccessParams.getPayParam(); if (payParam.getOrderType().equals(CashierEnum.RECHARGE.name())) { - rechargeService.paySuccess(payParam.getSn(), paymentSuccessParams.getReceivableNo()); + rechargeService.paySuccess(payParam.getSn(), paymentSuccessParams.getReceivableNo(),paymentSuccessParams.getPaymentMethod()); log.info("会员充值-订单号{},第三方流水:{}", payParam.getSn(), paymentSuccessParams.getReceivableNo()); } } diff --git a/framework/src/main/java/cn/lili/modules/payment/kit/params/impl/TradeCashier.java b/framework/src/main/java/cn/lili/modules/payment/kit/params/impl/TradeCashier.java index 7bd4e62e..6a488b0e 100644 --- a/framework/src/main/java/cn/lili/modules/payment/kit/params/impl/TradeCashier.java +++ b/framework/src/main/java/cn/lili/modules/payment/kit/params/impl/TradeCashier.java @@ -113,7 +113,7 @@ public class TradeCashier implements CashierExecute { if (payParam.getOrderType().equals(CashierEnum.TRADE.name())) { Trade trade = tradeService.getBySn(payParam.getSn()); if (trade != null) { - return trade.equals(PayStatusEnum.PAID.name()); + return PayStatusEnum.PAID.name().equals(trade.getPayStatus()); } else { throw new ServiceException(ResultCode.PAY_NOT_EXIST_ORDER); } diff --git a/framework/src/main/java/cn/lili/modules/payment/kit/plugin/wallet/WalletPlugin.java b/framework/src/main/java/cn/lili/modules/payment/kit/plugin/wallet/WalletPlugin.java index 6caca9ef..2f3a2749 100644 --- a/framework/src/main/java/cn/lili/modules/payment/kit/plugin/wallet/WalletPlugin.java +++ b/framework/src/main/java/cn/lili/modules/payment/kit/plugin/wallet/WalletPlugin.java @@ -1,9 +1,9 @@ package cn.lili.modules.payment.kit.plugin.wallet; import cn.lili.common.enums.ResultCode; +import cn.lili.common.enums.ResultUtil; import cn.lili.common.exception.ServiceException; import cn.lili.common.security.context.UserContext; -import cn.lili.common.enums.ResultUtil; import cn.lili.common.vo.ResultMessage; import cn.lili.modules.member.service.MemberWalletService; import cn.lili.modules.order.trade.entity.enums.DepositServiceTypeEnum; @@ -12,6 +12,7 @@ import cn.lili.modules.payment.kit.CashierSupport; import cn.lili.modules.payment.kit.Payment; import cn.lili.modules.payment.kit.dto.PayParam; import cn.lili.modules.payment.kit.dto.PaymentSuccessParams; +import cn.lili.modules.payment.kit.enums.CashierEnum; import cn.lili.modules.payment.kit.enums.PaymentMethodEnum; import cn.lili.modules.payment.kit.params.dto.CashierParam; import cn.lili.modules.payment.service.PaymentService; @@ -68,6 +69,9 @@ public class WalletPlugin implements Payment { @Override public ResultMessage nativePay(HttpServletRequest request, PayParam payParam) { + if(payParam.getOrderType().equals(CashierEnum.RECHARGE.name())){ + throw new ServiceException(ResultCode.CAN_NOT_RECHARGE_WALLET); + } savePaymentLog(payParam); return ResultUtil.success(ResultCode.PAY_SUCCESS); } diff --git a/framework/src/main/java/cn/lili/modules/payment/kit/plugin/wechat/WechatPlugin.java b/framework/src/main/java/cn/lili/modules/payment/kit/plugin/wechat/WechatPlugin.java index 9732ffe3..5dc658ec 100644 --- a/framework/src/main/java/cn/lili/modules/payment/kit/plugin/wechat/WechatPlugin.java +++ b/framework/src/main/java/cn/lili/modules/payment/kit/plugin/wechat/WechatPlugin.java @@ -555,7 +555,7 @@ public class WechatPlugin implements Payment { if (refundLog != null) { refundLog.setIsRefund(true); refundLog.setReceivableNo(refundId); - refundLogService.save(refundLog); + refundLogService.saveOrUpdate(refundLog); } } catch (Exception e) { log.error("微信退款失败",e); diff --git a/framework/src/main/java/cn/lili/modules/permission/serviceimpl/AdminUserServiceImpl.java b/framework/src/main/java/cn/lili/modules/permission/serviceimpl/AdminUserServiceImpl.java index d28b664e..831aec4b 100644 --- a/framework/src/main/java/cn/lili/modules/permission/serviceimpl/AdminUserServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/permission/serviceimpl/AdminUserServiceImpl.java @@ -199,13 +199,12 @@ public class AdminUserServiceImpl extends ServiceImpl 10) { throw new ServiceException(ResultCode.PERMISSION_BEYOND_TEN); } - if (roles != null && roles.size() > 0) { + if (roles.size() > 0) { dbUser.setRoleIds(StringUtils.join(",", roles)); } - - this.save(dbUser); - updateRole(adminUser.getId(), roles); + dbUser = this.findByUsername(dbUser.getUsername()); + updateRole(dbUser.getId(), roles); } diff --git a/framework/src/main/java/cn/lili/modules/promotion/entity/dos/Coupon.java b/framework/src/main/java/cn/lili/modules/promotion/entity/dos/Coupon.java index 9c9739e0..1188a79a 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/entity/dos/Coupon.java +++ b/framework/src/main/java/cn/lili/modules/promotion/entity/dos/Coupon.java @@ -66,7 +66,7 @@ public class Coupon extends BasePromotion { @ApiModelProperty(value = "活动描述") private String description; - @ApiModelProperty(value = "发行数量") + @ApiModelProperty(value = "发行数量,如果是0则是不限制") private Integer publishNum; @ApiModelProperty(value = "领取限制") diff --git a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/CouponActivityServiceImpl.java b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/CouponActivityServiceImpl.java index 03f56f14..9fbd6e88 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/CouponActivityServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/CouponActivityServiceImpl.java @@ -2,7 +2,14 @@ package cn.lili.modules.promotion.serviceimpl; import cn.hutool.json.JSONUtil; import cn.lili.common.exception.ServiceException; +import cn.lili.common.trigger.enums.DelayTypeEnums; +import cn.lili.common.trigger.interfaces.TimeTrigger; +import cn.lili.common.trigger.message.PromotionMessage; +import cn.lili.common.trigger.model.TimeExecuteConstant; +import cn.lili.common.trigger.model.TimeTriggerMsg; +import cn.lili.common.trigger.util.DelayQueueTools; import cn.lili.common.utils.DateUtil; +import cn.lili.config.rocketmq.RocketmqCustomProperties; import cn.lili.modules.member.entity.dos.Member; import cn.lili.modules.member.service.MemberService; import cn.lili.modules.promotion.entity.dos.Coupon; @@ -10,9 +17,7 @@ import cn.lili.modules.promotion.entity.dos.CouponActivity; import cn.lili.modules.promotion.entity.dos.CouponActivityItem; import cn.lili.modules.promotion.entity.dos.MemberCoupon; import cn.lili.modules.promotion.entity.dto.CouponActivityDTO; -import cn.lili.modules.promotion.entity.enums.CouponActivitySendTypeEnum; -import cn.lili.modules.promotion.entity.enums.MemberCouponStatusEnum; -import cn.lili.modules.promotion.entity.enums.PromotionStatusEnum; +import cn.lili.modules.promotion.entity.enums.*; import cn.lili.modules.promotion.entity.vos.CouponActivityVO; import cn.lili.modules.promotion.mapper.CouponActivityMapper; import cn.lili.modules.promotion.service.CouponActivityItemService; @@ -47,6 +52,12 @@ public class CouponActivityServiceImpl extends ServiceImpl impleme //满额活动 @Autowired private FullDiscountService fullDiscountService; + //优惠券活动-优惠券关联 + @Autowired + private CouponActivityItemService couponActivityItemService; @Override public CouponVO add(CouponVO coupon) { @@ -159,15 +156,31 @@ public class CouponServiceImpl extends ServiceImpl impleme @Override public boolean deleteCoupon(String id) { CouponVO couponVO = checkStatus(id); - LambdaUpdateWrapper couponUpdateWrapper = new LambdaUpdateWrapper().eq(Coupon::getId, id).set(Coupon::getPromotionStatus, PromotionStatusEnum.CLOSE.name()).set(Coupon::getDeleteFlag, true); + //更新优惠券状态为关闭,标示删除标志 + LambdaUpdateWrapper couponUpdateWrapper = new LambdaUpdateWrapper().eq(Coupon::getId, id) + .set(Coupon::getPromotionStatus, PromotionStatusEnum.CLOSE.name()).set(Coupon::getDeleteFlag, true); boolean result = this.update(couponUpdateWrapper); - LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper().eq(PromotionGoods::getPromotionId, id).set(PromotionGoods::getPromotionStatus, PromotionStatusEnum.CLOSE.name()).set(PromotionGoods::getDeleteFlag, true); + //更新促销商品记录信息为删除 + LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper() + .eq(PromotionGoods::getPromotionId, id) + .set(PromotionGoods::getPromotionStatus, PromotionStatusEnum.CLOSE.name()) + .set(PromotionGoods::getDeleteFlag, true); this.promotionGoodsService.update(updateWrapper); - LambdaUpdateWrapper memberCouponLambdaUpdateWrapper = new LambdaUpdateWrapper().eq(MemberCoupon::getCouponId, id).set(MemberCoupon::getMemberCouponStatus, MemberCouponStatusEnum.CLOSED.name()); + + //删除mongo优惠券信息 + LambdaUpdateWrapper memberCouponLambdaUpdateWrapper = new LambdaUpdateWrapper() + .eq(MemberCoupon::getCouponId, id) + .set(MemberCoupon::getMemberCouponStatus, MemberCouponStatusEnum.CLOSED.name()); memberCouponService.update(memberCouponLambdaUpdateWrapper); this.mongoTemplate.remove(new Query().addCriteria(Criteria.where("id").is(id)), CouponVO.class); + + //删除优惠券活动关联优惠券 + couponActivityItemService.remove(new LambdaQueryWrapper() + .eq(CouponActivityItem::getCouponId,id)); + + //删除延时任务 this.timeTrigger.delete(TimeExecuteConstant.PROMOTION_EXECUTOR, couponVO.getStartTime().getTime(), DelayQueueTools.wrapperUniqueKey(DelayTypeEnums.PROMOTION, (PromotionTypeEnum.COUPON.name() + couponVO.getId())), @@ -271,8 +284,8 @@ public class CouponServiceImpl extends ServiceImpl impleme if (coupon.getCouponLimitNum() < 0) { throw new ServiceException("领取限制数量不能为负数"); } - - if (coupon.getCouponLimitNum() > coupon.getPublishNum()) { + //如果发行数量是0则判断领取限制数量 + if (coupon.getPublishNum() != 0 && coupon.getCouponLimitNum() > coupon.getPublishNum()) { throw new ServiceException("领取限制数量超出发行数量"); } @@ -282,7 +295,7 @@ public class CouponServiceImpl extends ServiceImpl impleme throw new ServiceException("优惠券折扣必须小于10且大于0"); } - if (coupon.getRangeDayType().equals(CouponRangeDayEnum.FIXEDTIME.name())) { + if (coupon.getRangeDayType() != null && coupon.getRangeDayType().equals(CouponRangeDayEnum.FIXEDTIME.name())) { long nowTime = DateUtil.getDateline() * 1000; if (coupon.getStartTime().getTime() < nowTime && coupon.getEndTime().getTime() > nowTime) { throw new ServiceException("活动时间小于当前时间,不能进行编辑删除操作"); diff --git a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/MemberCouponServiceImpl.java b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/MemberCouponServiceImpl.java index 7ac348ca..b5177a18 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/MemberCouponServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/MemberCouponServiceImpl.java @@ -55,7 +55,7 @@ public class MemberCouponServiceImpl extends ServiceImpl= coupon.getPublishNum()) { + if (coupon.getPublishNum() != 0 && coupon.getReceivedNum() >= coupon.getPublishNum()) { throw new ServiceException("优惠券剩余领取数量不足"); } if (haveCoupons >= coupon.getCouponLimitNum()) { diff --git a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/PromotionServiceImpl.java b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/PromotionServiceImpl.java index bf1ced2b..4335286d 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/PromotionServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/PromotionServiceImpl.java @@ -16,6 +16,7 @@ import cn.lili.modules.search.service.EsGoodsIndexService; 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.UpdateWrapper; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.mongodb.core.MongoTemplate; @@ -416,16 +417,17 @@ public class PromotionServiceImpl implements PromotionService { * @return 修改结果 */ private boolean updateCouponActivity(PromotionMessage promotionMessage, PromotionTypeEnum promotionTypeEnum){ - boolean result; - CouponActivityVO couponActivityVO = this.mongoTemplate.findById(promotionMessage.getPromotionId(), CouponActivityVO.class); - if (couponActivityVO == null) { - this.throwPromotionException(promotionTypeEnum, promotionMessage.getPromotionId(), promotionMessage.getPromotionStatus()); - return false; + + //如果是精准发券,进行发送优惠券 + CouponActivity couponActivity=couponActivityService.getById(promotionMessage.getPromotionId()); + if(couponActivity.getCouponActivityType().equals(CouponActivityTypeEnum.SPECIFY.name())){ + couponActivityService.specify(couponActivity.getId()); } - couponActivityVO.setPromotionStatus(promotionMessage.getPromotionStatus()); - result = this.couponActivityService.update(promotionMessage.updateWrapper()); - this.mongoTemplate.save(couponActivityVO); - return result; + + //修改活动状态 + return couponActivityService.update(new LambdaUpdateWrapper() + .eq(CouponActivity::getId,promotionMessage.getPromotionId()) + .set(CouponActivity::getPromotionStatus,promotionMessage.getPromotionStatus())); } /** diff --git a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/SeckillApplyServiceImpl.java b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/SeckillApplyServiceImpl.java index 7cec4571..64aa1db9 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/SeckillApplyServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/SeckillApplyServiceImpl.java @@ -185,7 +185,7 @@ public class SeckillApplyServiceImpl extends ServiceImpl impl //检查秒杀活动参数 checkSeckillParam(seckillVO, seckill.getStoreId()); //保存到MYSQL中 - boolean result = this.save(seckill); + boolean result = this.save(seckillVO); //保存到MONGO中 this.mongoTemplate.save(seckillVO); //添加秒杀延时任务 @@ -245,7 +245,7 @@ public class SeckillServiceImpl extends ServiceImpl impl public Integer getApplyNum() { LambdaQueryWrapper queryWrapper = Wrappers.lambdaQuery(); //秒杀申请时间未超过当前时间 - queryWrapper.le(Seckill::getApplyEndTime, cn.hutool.core.date.DateUtil.date()); + queryWrapper.ge(Seckill::getApplyEndTime, cn.hutool.core.date.DateUtil.date()); queryWrapper.eq(Seckill::getPromotionStatus, PromotionStatusEnum.NEW.name()); return this.count(queryWrapper); } @@ -296,7 +296,7 @@ public class SeckillServiceImpl extends ServiceImpl impl int sameNum = this.count(queryWrapper); //当前时间段是否存在同类活动 if (sameNum > 0) { - throw new ServiceException("当前时间内已存在同类活动"); + throw new ServiceException("当前时间内已存在同类活动:"+seckill.getStartTime()); } } } \ No newline at end of file diff --git a/framework/src/main/java/cn/lili/modules/search/entity/dos/EsGoodsIndex.java b/framework/src/main/java/cn/lili/modules/search/entity/dos/EsGoodsIndex.java index e8388bd1..e3b72a27 100644 --- a/framework/src/main/java/cn/lili/modules/search/entity/dos/EsGoodsIndex.java +++ b/framework/src/main/java/cn/lili/modules/search/entity/dos/EsGoodsIndex.java @@ -1,8 +1,8 @@ package cn.lili.modules.search.entity.dos; import cn.lili.common.elasticsearch.EsSuffix; -import cn.lili.modules.goods.entity.dos.GoodsParams; import cn.lili.modules.goods.entity.dos.GoodsSku; +import cn.lili.modules.goods.entity.dto.GoodsParamsDTO; import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -273,36 +273,37 @@ public class EsGoodsIndex implements Serializable { this.intro = sku.getIntro(); this.grade = sku.getGrade(); this.releaseTime = new Date(); -// if (CharSequenceUtil.isNotEmpty(sku.getSpecs())) { -// List attributes = new ArrayList<>(); -// JSONObject jsonObject = JSONUtil.parseObj(sku.getSpecs()); -// for (Map.Entry entry : jsonObject.entrySet()) { -// if (!entry.getKey().equals("images")) { -// EsGoodsAttribute attribute = new EsGoodsAttribute(); -// attribute.setType(1); -// attribute.setName(entry.getKey()); -// attribute.setValue(entry.getValue().toString()); -// attributes.add(attribute); -// } -// } -// this.attrList = attributes; -// } } } - public EsGoodsIndex(GoodsSku sku, List goodsParams) { + /** + * 参数索引增加 + * + * @param sku + * @param goodsParamDTOS + */ + public EsGoodsIndex(GoodsSku sku, List goodsParamDTOS) { this(sku); - if (goodsParams != null && !goodsParams.isEmpty()) { + //如果参数不为空 + if (goodsParamDTOS != null && !goodsParamDTOS.isEmpty()) { + //接受不了参数索引 List attributes = new ArrayList<>(); - for (GoodsParams goodsParam : goodsParams) { - EsGoodsAttribute attribute = new EsGoodsAttribute(); - if (goodsParam.getIsIndex() != null && goodsParam.getIsIndex() == 1) { - attribute.setType(1); - attribute.setName(goodsParam.getParamName()); - attribute.setValue(goodsParam.getParamValue()); - attributes.add(attribute); - } - } + //循环参数分组 + goodsParamDTOS.forEach(goodsParamGroup -> { + //循环分组的内容 + goodsParamGroup.getGoodsParamsItemDTOList().forEach(goodsParam -> { + //如果字段需要索引,则增加索引字段 + if (goodsParam.getIsIndex() != null && goodsParam.getIsIndex() == 1) { + EsGoodsAttribute attribute = new EsGoodsAttribute(); + attribute.setType(1); + attribute.setName(goodsParam.getParamName()); + attribute.setValue(goodsParam.getParamValue()); + attributes.add(attribute); + } + } + ); + + }); this.attrList = attributes; } } diff --git a/framework/src/main/java/cn/lili/modules/search/service/EsGoodsIndexService.java b/framework/src/main/java/cn/lili/modules/search/service/EsGoodsIndexService.java index fbc7bc17..1d696cb2 100644 --- a/framework/src/main/java/cn/lili/modules/search/service/EsGoodsIndexService.java +++ b/framework/src/main/java/cn/lili/modules/search/service/EsGoodsIndexService.java @@ -1,6 +1,6 @@ package cn.lili.modules.search.service; -import cn.lili.modules.goods.entity.dos.GoodsParams; +import cn.lili.modules.goods.entity.dto.GoodsParamsDTO; import cn.lili.modules.goods.entity.dos.GoodsSku; import cn.lili.modules.promotion.entity.dos.PromotionGoods; import cn.lili.modules.promotion.entity.dto.BasePromotion; @@ -146,8 +146,8 @@ public interface EsGoodsIndexService { * 重置当前商品索引 * * @param goodsSku 商品sku信息 - * @param goodsParams 商品参数 + * @param goodsParamDTOS 商品参数 * @return 商品索引 */ - EsGoodsIndex resetEsGoodsIndex(GoodsSku goodsSku, List goodsParams); + EsGoodsIndex resetEsGoodsIndex(GoodsSku goodsSku, List goodsParamDTOS); } diff --git a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java index e1240279..8ac541e4 100644 --- a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java @@ -8,7 +8,7 @@ import cn.hutool.extra.pinyin.PinyinUtil; import cn.lili.common.elasticsearch.BaseElasticsearchService; import cn.lili.common.elasticsearch.EsSuffix; import cn.lili.config.elasticsearch.ElasticsearchProperties; -import cn.lili.modules.goods.entity.dos.GoodsParams; +import cn.lili.modules.goods.entity.dto.GoodsParamsDTO; import cn.lili.modules.goods.entity.dos.GoodsSku; import cn.lili.modules.goods.entity.dos.GoodsWords; import cn.lili.modules.goods.entity.enums.GoodsWordsTypeEnum; @@ -368,12 +368,12 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements * 重置当前商品索引 * * @param goodsSku 商品sku信息 - * @param goodsParams 商品参数 + * @param goodsParamDTOS 商品参数 * @return 商品索引 */ @Override - public EsGoodsIndex resetEsGoodsIndex(GoodsSku goodsSku, List goodsParams) { - EsGoodsIndex index = new EsGoodsIndex(goodsSku, goodsParams); + public EsGoodsIndex resetEsGoodsIndex(GoodsSku goodsSku, List goodsParamDTOS) { + EsGoodsIndex index = new EsGoodsIndex(goodsSku, goodsParamDTOS); //获取活动信息 Map goodsCurrentPromotionMap = promotionService.getGoodsCurrentPromotionMap(index); //写入促销信息 diff --git a/framework/src/main/java/cn/lili/modules/statistics/model/vo/OrderOverviewVO.java b/framework/src/main/java/cn/lili/modules/statistics/model/vo/OrderOverviewVO.java index 5cd79262..fbb3bd5d 100644 --- a/framework/src/main/java/cn/lili/modules/statistics/model/vo/OrderOverviewVO.java +++ b/framework/src/main/java/cn/lili/modules/statistics/model/vo/OrderOverviewVO.java @@ -13,35 +13,35 @@ import lombok.Data; public class OrderOverviewVO { @ApiModelProperty(value = "UV人次") - private Integer uvNum; + private Integer uvNum = 0; //下单统计 @ApiModelProperty(value = "下单数量") - private Long orderNum; + private Long orderNum = 0L; @ApiModelProperty(value = "下单人数") - private Long orderMemberNum; + private Long orderMemberNum = 0L; @ApiModelProperty(value = "下单金额") - private Double orderAmount; + private Double orderAmount = 0D; //付款统计 @ApiModelProperty(value = "付款订单数量") - private Long paymentOrderNum; + private Long paymentOrderNum = 0L; @ApiModelProperty(value = "付款人数") - private Long paymentsNum; + private Long paymentsNum = 0L; @ApiModelProperty(value = "付款金额") - private Double paymentAmount; + private Double paymentAmount = 0D; //退单统计 @ApiModelProperty(value = "退单笔数") - private Long refundOrderNum; + private Long refundOrderNum = 0L; @ApiModelProperty(value = "退单金额") - private Double refundOrderPrice; + private Double refundOrderPrice = 0D; //转换率 @ApiModelProperty(value = "下单转换率") diff --git a/framework/src/main/java/cn/lili/modules/statistics/serviceimpl/IndexStatisticsServiceImpl.java b/framework/src/main/java/cn/lili/modules/statistics/serviceimpl/IndexStatisticsServiceImpl.java index b191d75a..65a113a5 100644 --- a/framework/src/main/java/cn/lili/modules/statistics/serviceimpl/IndexStatisticsServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/statistics/serviceimpl/IndexStatisticsServiceImpl.java @@ -121,7 +121,7 @@ public class IndexStatisticsServiceImpl implements IndexStatisticsService { //售后申请 indexNoticeVO.setRefund(afterSaleService.applyNum(null)); //投诉审核 - indexNoticeVO.setComplain(orderComplaintService.newComplainNum()); + indexNoticeVO.setComplain(orderComplaintService.waitComplainNum()); //分销员提现审核 indexNoticeVO.setDistributionCash(distributionCashService.newDistributionCash()); //待处理商家结算 @@ -218,8 +218,8 @@ public class IndexStatisticsServiceImpl implements IndexStatisticsService { storeIndexStatisticsVO.setReturnMoney(afterSaleService.applyNum(AfterSaleTypeEnum.RETURN_MONEY.name())); //待回复评价数量 storeIndexStatisticsVO.setMemberEvaluation(memberEvaluationService.getWaitReplyNum()); - //待处理交易投诉数量 - storeIndexStatisticsVO.setComplaint(orderComplaintService.newComplainNum()); + //待处理投诉数量 + storeIndexStatisticsVO.setComplaint(orderComplaintService.waitComplainNum()); //待上架商品数量 storeIndexStatisticsVO.setWaitUpper(goodsService.goodsNum(GoodsStatusEnum.DOWN, null)); diff --git a/framework/src/main/java/cn/lili/modules/statistics/serviceimpl/OrderStatisticsDataServiceImpl.java b/framework/src/main/java/cn/lili/modules/statistics/serviceimpl/OrderStatisticsDataServiceImpl.java index 200dd483..e581d414 100644 --- a/framework/src/main/java/cn/lili/modules/statistics/serviceimpl/OrderStatisticsDataServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/statistics/serviceimpl/OrderStatisticsDataServiceImpl.java @@ -22,7 +22,6 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import lombok.RequiredArgsConstructor; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -50,18 +49,15 @@ public class OrderStatisticsDataServiceImpl extends ServiceImpl queryWrapper = new LambdaQueryWrapper(); //queryWrapper.eq("flow_type", FlowTypeEnum.PAY.name()); - queryWrapper.eq(StringUtils.isNotEmpty(orderStatus),Order::getOrderStatus,orderStatus); + queryWrapper.eq(StringUtils.isNotEmpty(orderStatus), Order::getOrderStatus, orderStatus); queryWrapper.eq(StringUtils.equals(UserContext.getCurrentUser().getRole().name(), UserEnums.STORE.name()), Order::getStoreId, UserContext.getCurrentUser().getStoreId()); return orderService.count(queryWrapper); diff --git a/framework/src/main/java/cn/lili/modules/statistics/serviceimpl/PlatformViewDataServiceImpl.java b/framework/src/main/java/cn/lili/modules/statistics/serviceimpl/PlatformViewDataServiceImpl.java index 8d69e54f..c39cf71e 100644 --- a/framework/src/main/java/cn/lili/modules/statistics/serviceimpl/PlatformViewDataServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/statistics/serviceimpl/PlatformViewDataServiceImpl.java @@ -4,7 +4,6 @@ import cn.lili.common.cache.Cache; import cn.lili.common.cache.CachePrefix; import cn.lili.common.security.enums.UserEnums; import cn.lili.common.utils.CurrencyUtil; -import cn.lili.common.utils.DateUtil; import cn.lili.config.properties.StatisticsProperties; import cn.lili.modules.base.entity.enums.ClientTypeEnum; import cn.lili.modules.member.entity.vo.MemberDistributionVO; @@ -52,6 +51,9 @@ public class PlatformViewDataServiceImpl extends ServiceImpl