Merge branch 'master' of gitee.com:beijing_hongye_huicheng/lilishop into feature/pg
This commit is contained in:
commit
696e075fcd
@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>cn.lili</groupId>
|
||||
<artifactId>lili-shop-parent</artifactId>
|
||||
<version>1.0.1</version>
|
||||
<version>4.2.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>admin</artifactId>
|
||||
|
@ -10,14 +10,14 @@
|
||||
<parent>
|
||||
<groupId>cn.lili</groupId>
|
||||
<artifactId>lili-shop-parent</artifactId>
|
||||
<version>1.0.1</version>
|
||||
<version>4.2.0</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>cn.lili</groupId>
|
||||
<artifactId>framework</artifactId>
|
||||
<version>1.0.1</version>
|
||||
<version>4.2.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
@ -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<IPage<MemberMessage>> 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<Boolean> read(@PathVariable String messageId) {
|
||||
@PutMapping("/{message_id}")
|
||||
public ResultMessage<Boolean> 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<Boolean> deleteMessage(@PathVariable String messageId) {
|
||||
return ResultUtil.data(memberMessageService.deleteMessage(messageId));
|
||||
@DeleteMapping("/{message_id}")
|
||||
public ResultMessage<Boolean> deleteMessage(@PathVariable("message_id") String messageId) {
|
||||
return ResultUtil.data(memberMessageService.editStatus(MessageStatusEnum.ALREADY_REMOVE.name(), messageId));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -53,7 +53,7 @@ public class DistributionBuyerController {
|
||||
@ApiOperation(value = "获取分销员分页订单列表")
|
||||
@GetMapping("/distributionOrder")
|
||||
public ResultMessage<IPage<DistributionOrder>> distributionOrderPage(DistributionOrderSearchParams distributionOrderSearchParams) {
|
||||
distributionOrderSearchParams.setDistributionId(UserContext.getCurrentUser().getId());
|
||||
distributionOrderSearchParams.setDistributionId(distributionService.getDistribution().getId());
|
||||
return ResultUtil.data(distributionOrderService.getDistributionOrderPage(distributionOrderSearchParams));
|
||||
}
|
||||
|
||||
|
@ -63,9 +63,9 @@ public class MemberBuyerController {
|
||||
public ResultMessage<Object> smsLogin(@NotNull(message = "手机号为空") @RequestParam String mobile,
|
||||
@NotNull(message = "验证码为空") @RequestParam String code,
|
||||
@RequestHeader String uuid) {
|
||||
if(smsUtil.verifyCode(mobile,VerificationEnums.LOGIN,uuid,code)){
|
||||
if (smsUtil.verifyCode(mobile, VerificationEnums.LOGIN, uuid, code)) {
|
||||
return ResultUtil.data(memberService.mobilePhoneLogin(mobile));
|
||||
}else {
|
||||
} else {
|
||||
throw new ServiceException("验证码错误");
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
|
@ -37,7 +37,8 @@ public class WalletLogBuyerController {
|
||||
//获取当前登录用户
|
||||
AuthUser authUser = UserContext.getCurrentUser();
|
||||
//构建查询 返回数据
|
||||
IPage<WalletLog> depositLogPage = walletLogService.page(PageUtil.initPage(page), new QueryWrapper<WalletLog>().eq("member_id", authUser.getId()));
|
||||
IPage<WalletLog> depositLogPage = walletLogService.page(PageUtil.initPage(page),
|
||||
new QueryWrapper<WalletLog>().eq("member_id", authUser.getId()).orderByDesc("create_time"));
|
||||
return ResultUtil.data(depositLogPage);
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>cn.lili</groupId>
|
||||
<artifactId>lili-shop-parent</artifactId>
|
||||
<version>1.0.1</version>
|
||||
<version>4.2.0</version>
|
||||
</parent>
|
||||
|
||||
<groupId>cn.lili</groupId>
|
||||
@ -17,7 +17,7 @@
|
||||
<dependency>
|
||||
<groupId>cn.lili</groupId>
|
||||
<artifactId>framework</artifactId>
|
||||
<version>1.0.1</version>
|
||||
<version>4.2.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
@ -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
|
||||
|
@ -8,14 +8,14 @@
|
||||
<parent>
|
||||
<groupId>cn.lili</groupId>
|
||||
<artifactId>lili-shop-parent</artifactId>
|
||||
<version>1.0.1</version>
|
||||
<version>4.2.0</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>cn.lili</groupId>
|
||||
<artifactId>framework</artifactId>
|
||||
<version>1.0.1</version>
|
||||
<version>4.2.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
@ -59,7 +59,7 @@ public class NoticeMessageExecute implements TradeEvent, OrderStatusChangeEvent,
|
||||
//如果订单状态不为空
|
||||
if (orderDetailVO != null) {
|
||||
Map<String, String> 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<String, String> params = new HashMap<>();
|
||||
if (memberPointMessage.getType().equals(1)) {
|
||||
if (memberPointMessage.getType()) {
|
||||
params.put("expenditure_points", "0");
|
||||
params.put("income_points", memberPointMessage.getPoint().toString());
|
||||
} else {
|
||||
|
@ -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<Order>()
|
||||
.set(Order::getVerificationCode, code)
|
||||
.eq(Order::getSn, orderMessage.getOrderSn()));
|
||||
//修改虚拟订单货物可以进行售后、投诉
|
||||
orderItemService.update(new LambdaUpdateWrapper<OrderItem>().eq(OrderItem::getOrderSn, orderMessage.getOrderSn())
|
||||
.set(OrderItem::getAfterSaleStatus, OrderItemAfterSaleStatusEnum.NOT_APPLIED)
|
||||
.set(OrderItem::getCommentStatus, OrderComplaintStatusEnum.NO_APPLY));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -148,7 +148,7 @@ public class NoticeSendMessageListener implements RocketMQListener<MessageExt> {
|
||||
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;
|
||||
|
@ -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<CouponActivity> couponActivities=couponActivityService.list(new LambdaQueryWrapper<CouponActivity>()
|
||||
.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<CouponActivity>()
|
||||
.eq(CouponActivity::getId,couponActivity.getId())
|
||||
.set(CouponActivity::getPromotionStatus,PromotionStatusEnum.END.name()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* 注册赠券活动状态监测
|
||||
*/
|
||||
private void registered(){
|
||||
//开启注册赠券优惠券活动
|
||||
LambdaUpdateWrapper<CouponActivity> 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<CouponActivity> 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);
|
||||
}
|
||||
}
|
@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>cn.lili</groupId>
|
||||
<artifactId>lili-shop-parent</artifactId>
|
||||
<version>1.0.1</version>
|
||||
<version>4.2.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>framework</artifactId>
|
||||
|
@ -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,"直播商品已存在"),
|
||||
|
||||
/**
|
||||
* 店铺
|
||||
*/
|
||||
|
@ -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);
|
||||
|
@ -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 {};
|
||||
|
||||
|
32
framework/src/main/java/cn/lili/common/validation/Phone.java
Normal file
32
framework/src/main/java/cn/lili/common/validation/Phone.java
Normal file
@ -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<? extends Payload>[] payload() default {};
|
||||
}
|
@ -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<Mobile, String> {
|
||||
|
||||
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
|
||||
|
@ -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<Phone, String> {
|
||||
|
||||
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) {
|
||||
|
||||
}
|
||||
}
|
@ -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();
|
||||
|
@ -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<StudioMapper, Studio> 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<StudioMapper, Studio> 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<StudioMapper, Studio> 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<StudioMapper, Studio> impleme
|
||||
|
||||
@Override
|
||||
public Boolean push(Integer roomId, Integer goodsId) {
|
||||
|
||||
//判断直播间是否已添加商品
|
||||
if (studioCommodityService.getOne(
|
||||
new LambdaQueryWrapper<StudioCommodity>().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<StudioMapper, Studio> impleme
|
||||
|
||||
@Override
|
||||
public IPage<Studio> studioList(PageVO pageVO, Integer recommend, String status) {
|
||||
return this.page(PageUtil.initPage(pageVO), new QueryWrapper<Studio>()
|
||||
QueryWrapper queryWrapper = new QueryWrapper<Studio>()
|
||||
.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);
|
||||
|
||||
}
|
||||
|
||||
|
@ -38,18 +38,11 @@ public class WechatLivePlayerUtil {
|
||||
* @return 房间ID
|
||||
*/
|
||||
public Map<String, String> 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<String, String> 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<String, String> map = this.mockRoom(studio);
|
||||
JSONObject json = this.doPostWithJson(url, map);
|
||||
Map<String, String> 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<String, String> map = this.mockRoom(token, studio);
|
||||
Map<String, String> 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<String, Object> 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<String, Object> 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<String, Integer> 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")){
|
||||
this.doPostWithJson(url, map);
|
||||
return true;
|
||||
}
|
||||
throw new ServiceException(json.getStr("errmsg"));
|
||||
|
||||
}
|
||||
|
||||
@ -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<String, GoodsInfo> 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<String, Object> 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<String> 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<String, Object> 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<String, String> 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<String, String> mockRoom(Studio studio) {
|
||||
Map<String, String> 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());
|
||||
//直播计划开始时间
|
||||
|
@ -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,7 +95,7 @@ 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();
|
||||
@ -95,19 +103,31 @@ public class WechatMediaUtil {
|
||||
resultIn.close();
|
||||
urlConn.disconnect();
|
||||
} catch (Exception e) {
|
||||
log.error("微信媒体上传失败",e);
|
||||
log.error("微信媒体上传失败", e);
|
||||
}
|
||||
JSONObject jsonObject=new JSONObject(resultStr.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;
|
||||
|
@ -184,6 +184,8 @@ public class ConnectUtil {
|
||||
.clientId(qqConnectSettingItem.getAppId())
|
||||
.clientSecret(qqConnectSettingItem.getAppKey())
|
||||
.redirectUri(getRedirectUri(authInterface))
|
||||
//这里qq获取unionid 需要配置为true,详情可以查阅属性说明,内部有帮助文档
|
||||
.unionId(true)
|
||||
.build(), cache);
|
||||
}
|
||||
}
|
||||
|
@ -39,6 +39,9 @@ public class DistributionGoodsVO {
|
||||
@ApiModelProperty(value = "商品编号")
|
||||
private String sn;
|
||||
|
||||
@ApiModelProperty(value = "商品ID")
|
||||
private String goodsId;
|
||||
|
||||
@ApiModelProperty(value = "规格ID")
|
||||
private String skuId;
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -16,6 +16,6 @@ public interface DistributionMapper extends BaseMapper<Distribution> {
|
||||
@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);
|
||||
}
|
@ -41,7 +41,7 @@ public class CategoryParameterGroup extends BaseEntity {
|
||||
@NotNull(message = "关联的分类不能为空")
|
||||
private String categoryId;
|
||||
/**
|
||||
*
|
||||
* 排序
|
||||
*/
|
||||
@ApiModelProperty(value = "排序", hidden = true)
|
||||
private Integer sort;
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
||||
}
|
@ -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)
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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<GoodsParams> goodsParamsList;
|
||||
private List<GoodsParamsDTO> goodsParamsDTOList;
|
||||
|
||||
@ApiModelProperty(value = "商品图片")
|
||||
private List<String> goodsGalleryList;
|
||||
|
@ -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<GoodsParams> goodsParamsList;
|
||||
private List<GoodsParamsDTO> goodsParamsDTOList;
|
||||
|
||||
@ApiModelProperty(value = "商品图片")
|
||||
private List<String> goodsGalleryList;
|
||||
@ -121,4 +119,7 @@ public class GoodsOperationDTO implements Serializable {
|
||||
*/
|
||||
@ApiModelProperty(value = "商品类型")
|
||||
private String goodsType;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -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<GoodsParamsItemDTO> goodsParamsItemDTOList;
|
||||
|
||||
}
|
@ -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;
|
||||
}
|
@ -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<String> categoryName;
|
||||
|
||||
@ApiModelProperty(value = "商品参数")
|
||||
private List<GoodsParams> goodsParamsList;
|
||||
private List<GoodsParamsDTO> goodsParamsDTOList;
|
||||
|
||||
@ApiModelProperty(value = "商品图片")
|
||||
private List<String> goodsGalleryList;
|
||||
|
@ -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 选择项")
|
@ -16,7 +16,7 @@ import java.util.List;
|
||||
public class GoodsParamsGroupVO implements Serializable {
|
||||
private static final long serialVersionUID = 1450550797436233753L;
|
||||
@ApiModelProperty("参数组关联的参数集合")
|
||||
private List<GoodsParamsVO> params;
|
||||
private List<GoodsParamsDTOVO> params;
|
||||
@ApiModelProperty("参数组名称")
|
||||
private String groupName;
|
||||
@ApiModelProperty("参数组id")
|
||||
|
@ -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<String> categoryName;
|
||||
|
||||
@ApiModelProperty(value = "商品参数")
|
||||
private List<GoodsParams> goodsParamsList;
|
||||
private List<GoodsParamsDTO> goodsParamsDTOList;
|
||||
|
||||
@ApiModelProperty(value = "商品图片")
|
||||
private List<String> goodsGalleryList;
|
||||
|
@ -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<String> specImage;
|
||||
private List<SpecImages> specImage;
|
||||
|
||||
@Data
|
||||
public static class SpecImages implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1816357809660916086L;
|
||||
|
||||
private String url;
|
||||
|
||||
private String name;
|
||||
|
||||
private String status;
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -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<Goods> {
|
||||
|
||||
/**
|
||||
* 下架所有商家商品
|
||||
* 根据店铺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<String> getGoodsIdByStoreId(String storeId);
|
||||
|
||||
@Update("UPDATE li_goods SET comment_num = comment_num + #{commentNum} WHERE id = #{goodsId}")
|
||||
void addGoodsCommentNum(Integer commentNum, String goodsId);
|
||||
|
@ -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<GoodsParams> {
|
||||
public interface GoodsParamsMapper extends BaseMapper<GoodsParamsDTO> {
|
||||
|
||||
@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<GoodsParamsVO> paramList(String goodsId, String categoryId);
|
||||
List<GoodsParamsDTOVO> paramList(String goodsId, String categoryId);
|
||||
|
||||
}
|
@ -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<GoodsParams> {
|
||||
|
||||
/**
|
||||
* 添加商品参数
|
||||
* @param paramList 参数列表
|
||||
* @param goodsId 商品ID
|
||||
*/
|
||||
void addParams(List<GoodsParams> 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<GoodsParams> getGoodsParamsByGoodsId(String goodsId);
|
||||
|
||||
/**
|
||||
* 添加商品参数
|
||||
*
|
||||
* @param goodsParamsVO 商品参数
|
||||
* @return 添加是否成功
|
||||
*/
|
||||
boolean addParams(GoodsParamsVO goodsParamsVO);
|
||||
|
||||
/**
|
||||
* 根据分类id查询绑定参数信息
|
||||
*
|
||||
* @param categoryId 分类id
|
||||
* @param goodsId 商品id
|
||||
* @return 分类id
|
||||
*/
|
||||
List<GoodsParamsVO> paramList(String categoryId, String goodsId);
|
||||
|
||||
/**
|
||||
* 查询商品参数信息
|
||||
*
|
||||
* @param goodsId 商品id
|
||||
* @param categoryId 分了id
|
||||
* @return 商品参数信息
|
||||
*/
|
||||
List<GoodsParamsGroupVO> queryGoodsParams(String goodsId, String categoryId);
|
||||
|
||||
|
||||
}
|
@ -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<CategoryMapper, Category> i
|
||||
* @param paramList 参数列表
|
||||
* @return 拼装后的返回值
|
||||
*/
|
||||
private List<GoodsParamsGroupVO> convertParamList(List<CategoryParameterGroup> groupList, List<GoodsParamsVO> paramList) {
|
||||
Map<String, List<GoodsParamsVO>> map = new HashMap<>(16);
|
||||
for (GoodsParamsVO param : paramList) {
|
||||
private List<GoodsParamsGroupVO> convertParamList(List<CategoryParameterGroup> groupList, List<GoodsParamsDTOVO> paramList) {
|
||||
Map<String, List<GoodsParamsDTOVO>> map = new HashMap<>(16);
|
||||
for (GoodsParamsDTOVO param : paramList) {
|
||||
if (map.get(param.getGroupId()) != null) {
|
||||
map.get(param.getGroupId()).add(param);
|
||||
} else {
|
||||
List<GoodsParamsVO> list = new ArrayList<>();
|
||||
List<GoodsParamsDTOVO> list = new ArrayList<>();
|
||||
list.add(param);
|
||||
map.put(param.getGroupId(), list);
|
||||
}
|
||||
|
@ -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<DraftGoodsMapper, DraftGo
|
||||
public boolean addGoodsDraft(DraftGoodsDTO draftGoods) {
|
||||
draftGoods.setGoodsGalleryListJson(JSONUtil.toJsonStr(draftGoods.getGoodsGalleryList()));
|
||||
draftGoods.setSkuListJson(JSONUtil.toJsonStr(draftGoods.getSkuList()));
|
||||
draftGoods.setGoodsParamsListJson(JSONUtil.toJsonStr(draftGoods.getGoodsParamsList()));
|
||||
draftGoods.setGoodsParamsListJson(JSONUtil.toJsonStr(draftGoods.getGoodsParamsDTOList()));
|
||||
return this.save(draftGoods);
|
||||
}
|
||||
|
||||
@ -53,7 +54,7 @@ public class DraftGoodsServiceImpl extends ServiceImpl<DraftGoodsMapper, DraftGo
|
||||
public boolean updateGoodsDraft(DraftGoodsDTO draftGoods) {
|
||||
draftGoods.setGoodsGalleryListJson(JSONUtil.toJsonStr(draftGoods.getGoodsGalleryList()));
|
||||
draftGoods.setSkuListJson(JSONUtil.toJsonStr(draftGoods.getSkuList()));
|
||||
draftGoods.setGoodsParamsListJson(JSONUtil.toJsonStr(draftGoods.getGoodsParamsList()));
|
||||
draftGoods.setGoodsParamsListJson(JSONUtil.toJsonStr(draftGoods.getGoodsParamsDTOList()));
|
||||
return this.updateById(draftGoods);
|
||||
}
|
||||
|
||||
@ -68,7 +69,7 @@ public class DraftGoodsServiceImpl extends ServiceImpl<DraftGoodsMapper, DraftGo
|
||||
}
|
||||
draftGoods.setGoodsGalleryListJson(JSONUtil.toJsonStr(draftGoods.getGoodsGalleryList()));
|
||||
draftGoods.setSkuListJson(JSONUtil.toJsonStr(this.getGoodsSkuList(draftGoods.getSkuList())));
|
||||
draftGoods.setGoodsParamsListJson(JSONUtil.toJsonStr(draftGoods.getGoodsParamsList()));
|
||||
draftGoods.setGoodsParamsListJson(JSONUtil.toJsonStr(draftGoods.getGoodsParamsDTOList()));
|
||||
this.saveOrUpdate(draftGoods);
|
||||
}
|
||||
|
||||
@ -91,7 +92,7 @@ public class DraftGoodsServiceImpl extends ServiceImpl<DraftGoodsMapper, DraftGo
|
||||
categoryName.add(category.getName());
|
||||
}
|
||||
draftGoodsVO.setCategoryName(categoryName);
|
||||
draftGoodsVO.setGoodsParamsList(JSONUtil.toList(JSONUtil.parseArray(draftGoods.getGoodsParamsListJson()), GoodsParams.class));
|
||||
draftGoodsVO.setGoodsParamsDTOList(JSONUtil.toList(JSONUtil.parseArray(draftGoods.getGoodsParamsListJson()), GoodsParamsDTO.class));
|
||||
draftGoodsVO.setGoodsGalleryList(JSONUtil.toList(JSONUtil.parseArray(draftGoods.getGoodsGalleryListJson()), String.class));
|
||||
JSONArray jsonArray = JSONUtil.parseArray(draftGoods.getSkuListJson());
|
||||
List<GoodsSku> list = JSONUtil.toList(jsonArray, GoodsSku.class);
|
||||
|
@ -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<GoodsParamsMapper, GoodsParams> implements GoodsParamsService {
|
||||
//分类-参数绑定
|
||||
@Autowired
|
||||
private CategoryParameterGroupService categoryParameterGroupService;
|
||||
|
||||
@Autowired
|
||||
private ParametersService parametersService;
|
||||
|
||||
@Override
|
||||
public void addParams(List<GoodsParams> paramList, String goodsId) {
|
||||
//先删除现有商品参数
|
||||
this.remove(new UpdateWrapper<GoodsParams>().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<GoodsParams> 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<GoodsParams>().eq("param_id", paramId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GoodsParams> getGoodsParamsByGoodsId(String goodsId) {
|
||||
return this.list(new LambdaQueryWrapper<GoodsParams>().eq(GoodsParams::getGoodsId, goodsId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加商品参数
|
||||
*
|
||||
* @param goodsParamsVO 商品参数
|
||||
* @return 添加是否成功
|
||||
*/
|
||||
@Override
|
||||
public boolean addParams(GoodsParamsVO goodsParamsVO) {
|
||||
return this.save(goodsParamsVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GoodsParamsVO> paramList(String goodsId, String categoryId) {
|
||||
return this.baseMapper.paramList(goodsId, categoryId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GoodsParamsGroupVO> queryGoodsParams(String categoryId, String goodsId) {
|
||||
//查询分类关联参数组
|
||||
List<CategoryParameterGroup> groupList = categoryParameterGroupService.getCategoryGroup(categoryId);
|
||||
//查询商品参数
|
||||
List<GoodsParamsVO> paramList = this.paramList(goodsId, categoryId);
|
||||
//拼装数据返回
|
||||
return this.convertParamList(groupList, paramList);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 拼装返回值
|
||||
*
|
||||
* @param paramList
|
||||
* @return
|
||||
*/
|
||||
private List<GoodsParamsGroupVO> convertParamList(List<CategoryParameterGroup> groupList, List<GoodsParamsVO> paramList) {
|
||||
Map<String, List<GoodsParamsVO>> map = new HashMap<>(16);
|
||||
for (GoodsParamsVO param : paramList) {
|
||||
if (map.get(param.getGroupId()) != null) {
|
||||
map.get(param.getGroupId()).add(param);
|
||||
} else {
|
||||
List<GoodsParamsVO> list = new ArrayList<>();
|
||||
list.add(param);
|
||||
map.put(param.getGroupId(), list);
|
||||
}
|
||||
}
|
||||
List<GoodsParamsGroupVO> 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;
|
||||
}
|
||||
}
|
@ -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<GoodsMapper, Goods> implements GoodsService {
|
||||
|
||||
//商品属性
|
||||
@Autowired
|
||||
private GoodsParamsService goodsParamsService;
|
||||
|
||||
//分类
|
||||
@Autowired
|
||||
private CategoryService categoryService;
|
||||
@ -85,11 +87,16 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
||||
//rocketMq配置
|
||||
@Autowired
|
||||
private RocketmqCustomProperties rocketmqCustomProperties;
|
||||
@Autowired
|
||||
private CategoryParameterGroupService categoryParameterGroupService;
|
||||
|
||||
|
||||
@Override
|
||||
public void underStoreGoods(String storeId) {
|
||||
this.baseMapper.underStoreGoods(storeId);
|
||||
//获取商品ID列表
|
||||
List<String> list= this.baseMapper.getGoodsIdByStoreId(storeId);
|
||||
//下架店铺下的商品
|
||||
updateGoodsMarketAble(list,GoodsStatusEnum.DOWN,"店铺关闭");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -107,12 +114,15 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> 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<GoodsMapper, Goods> 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<GoodsMapper, Goods> 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<GoodsMapper, Goods> implements
|
||||
goods.setThumbnail(goodsGallery.getThumbnail());
|
||||
}
|
||||
|
||||
/**
|
||||
* 检测商品参数是否非法传递
|
||||
*
|
||||
* @param goodsParamsDTOS 商品参数
|
||||
* @param categoryId 分类id
|
||||
*/
|
||||
private void checkGoodsParams(List<GoodsParamsDTO> goodsParamsDTOS, String categoryId) {
|
||||
//根据绑定的分了id查询出参数信息
|
||||
List<ParameterGroupVO> parameterGroupVOS = categoryParameterGroupService.getCategoryParams(categoryId);
|
||||
if (parameterGroupVOS.size() > 0) {
|
||||
//绑定分类的参数集合
|
||||
List<Parameters> parametersList = new ArrayList<>();
|
||||
//循环分类绑定的参数信息 把它整理到新的分类参数集合中 用于最后的参数信息对比
|
||||
for (ParameterGroupVO parameterGroupVO : parameterGroupVOS) {
|
||||
List<Parameters> parameters = parameterGroupVO.getParams();
|
||||
for (Parameters param : parameters) {
|
||||
parametersList.add(param);
|
||||
}
|
||||
}
|
||||
List<GoodsParamsItemDTO> goodsOperationParamList = new ArrayList<>();
|
||||
//循环添加商品传递的参数信息 把它整理到新的分类参数集合中 用于最后的参数信息对比
|
||||
for (GoodsParamsDTO goodsParamsDTO : goodsParamsDTOS) {
|
||||
List<GoodsParamsItemDTO> 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("商品参数错误,刷新后重试");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查商品信息
|
||||
* 如果商品是虚拟商品则无需配置配送模板
|
||||
|
@ -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<GoodsSkuMapper, GoodsSku> i
|
||||
//商品相册
|
||||
@Autowired
|
||||
private GoodsGalleryService goodsGalleryService;
|
||||
//规格
|
||||
@Autowired
|
||||
private SpecificationService specificationService;
|
||||
//缓存
|
||||
@Autowired
|
||||
private StringRedisTemplate stringRedisTemplate;
|
||||
@ -208,7 +207,7 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> 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<GoodsSkuMapper, GoodsSku> i
|
||||
|
||||
@Override
|
||||
public GoodsSkuVO getGoodsSkuVO(GoodsSku goodsSku) {
|
||||
//厨师还商品
|
||||
GoodsSkuVO goodsSkuVO = new GoodsSkuVO(goodsSku);
|
||||
//获取sku信息
|
||||
JSONObject jsonObject = JSONUtil.parseObj(goodsSku.getSpecs());
|
||||
//用于接受sku信息
|
||||
List<SpecValueVO> specValueVOS = new ArrayList<>();
|
||||
//用于接受sku相册
|
||||
List<String> goodsGalleryList = new ArrayList<>();
|
||||
// for (Map.Entry<String, Object> entry : jsonObject.entrySet()) {
|
||||
// SpecValueVO s = new SpecValueVO();
|
||||
// if (entry.getKey().equals("images")) {
|
||||
// s.setSpecName(entry.getKey());
|
||||
// if (entry.getValue().toString().contains("url")) {
|
||||
// List<SpecValueVO.SpecImages> 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<String, Object> entry : jsonObject.entrySet()) {
|
||||
SpecValueVO specValueVO = new SpecValueVO();
|
||||
if (entry.getKey().equals("images")) {
|
||||
specValueVO.setSpecName(entry.getKey());
|
||||
if (entry.getValue().toString().contains("url")) {
|
||||
List<SpecValueVO.SpecImages> 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<GoodsSkuMapper, GoodsSku> i
|
||||
EsGoodsIndex esGoodsOld = goodsIndexService.findById(goodsSku.getId());
|
||||
EsGoodsIndex goodsIndex = new EsGoodsIndex(goodsSku);
|
||||
if (goods.getParams() != null && !goods.getParams().isEmpty()) {
|
||||
List<GoodsParams> goodsParams = JSONUtil.toList(goods.getParams(), GoodsParams.class);
|
||||
goodsIndex = new EsGoodsIndex(goodsSku, goodsParams);
|
||||
List<GoodsParamsDTO> 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<GoodsSkuMapper, GoodsSku> i
|
||||
List<EsGoodsAttribute> attributes = new ArrayList<>();
|
||||
|
||||
//获取规格信息
|
||||
for (Map.Entry<String, Object> m : map.entrySet()) {
|
||||
for (Map.Entry<String, Object> 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<Map<String, String>> images = (List<Map<String, String>>) m.getValue();
|
||||
List<Map<String, String>> images = (List<Map<String, String>>) 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(m.getValue());
|
||||
goodsName.append(" ").append(spec.getValue());
|
||||
//规格简短信息
|
||||
simpleSpecs.append(" ").append(m.getValue());
|
||||
simpleSpecs.append(" ").append(spec.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//设置规格信息
|
||||
sku.setGoodsName(goodsName.toString());
|
||||
sku.setThumbnail(thumbnail);
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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();
|
||||
|
||||
}
|
@ -31,13 +31,15 @@ public class MemberMessageServiceImpl extends ServiceImpl<MemberMessageMapper, M
|
||||
public IPage<MemberMessage> getPage(MemberMessageQueryVO memberMessageQueryVO, PageVO pageVO) {
|
||||
QueryWrapper<MemberMessage> 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);
|
||||
}
|
||||
|
@ -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());
|
||||
}
|
||||
|
||||
}
|
@ -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<CartVO> cartVOList = new ArrayList<>();
|
||||
//循环购物车信息
|
||||
@ -112,6 +118,8 @@ public class TradeBuilder {
|
||||
|
||||
/**
|
||||
* 创建一笔交易
|
||||
* 1.构造交易
|
||||
* 2.创建交易
|
||||
*
|
||||
* @param checkedWay 购物车类型
|
||||
* @return 交易信息
|
||||
|
@ -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:
|
||||
|
@ -162,6 +162,13 @@ public interface CartService {
|
||||
|
||||
/**
|
||||
* 创建交易
|
||||
* 1.获取购物车类型,不同的购物车类型有不同的订单逻辑
|
||||
* 购物车类型:购物车、立即购买、虚拟商品、拼团、积分
|
||||
* 2.校验用户的收件人信息
|
||||
* 3.设置交易的基础参数
|
||||
* 4.交易信息存储到缓存中
|
||||
* 5.创建交易
|
||||
* 6.清除购物车选择数据
|
||||
*
|
||||
* @param tradeParams 创建交易参数
|
||||
* @return 交易信息
|
||||
|
@ -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<CartSkuVO> collect = tradeDTO.getSkuList().stream().filter(i -> Boolean.FALSE.equals(i.getInvalid())).collect(Collectors.toList());
|
||||
long count = 0L;
|
||||
|
@ -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<String> 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<String> 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());
|
||||
|
@ -13,17 +13,8 @@ public enum OrderTypeEnum {
|
||||
*/
|
||||
NORMAL,
|
||||
|
||||
/**
|
||||
* 赠品订单
|
||||
*/
|
||||
GIFT,
|
||||
|
||||
/**
|
||||
* 虚拟订单
|
||||
*/
|
||||
VIRTUAL,
|
||||
/**
|
||||
* 拼团订单
|
||||
*/
|
||||
PINTUAN
|
||||
VIRTUAL
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
|
||||
}
|
||||
|
@ -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());
|
||||
|
@ -68,11 +68,11 @@ public interface OrderComplaintService extends IService<OrderComplaint> {
|
||||
OrderComplaint updateOrderComplainByStatus(OrderComplaintOperationParams operationParam);
|
||||
|
||||
/**
|
||||
* 获取新投诉数量
|
||||
* 待处理投诉数量
|
||||
*
|
||||
* @return 新投诉
|
||||
* @return 待处理投诉数量
|
||||
*/
|
||||
Integer newComplainNum();
|
||||
Integer waitComplainNum();
|
||||
|
||||
/**
|
||||
* 取消交易投诉
|
||||
|
@ -70,7 +70,9 @@ public interface OrderService extends IService<Order> {
|
||||
OrderDetailVO queryDetail(String orderSn);
|
||||
|
||||
/**
|
||||
* 创建交易
|
||||
* 创建订单
|
||||
* 1.检查交易信息
|
||||
* 2.循环交易购物车列表,创建订单以及相关信息
|
||||
*
|
||||
* @param tradeDTO 交易DTO
|
||||
*/
|
||||
|
@ -14,6 +14,13 @@ public interface TradeService extends IService<Trade> {
|
||||
|
||||
/**
|
||||
* 创建交易
|
||||
* 1.订单数据校验
|
||||
* 2.积分预处理
|
||||
* 3.优惠券预处理
|
||||
* 4.添加交易
|
||||
* 5.添加订单
|
||||
* 6.将交易写入缓存供消费者调用
|
||||
* 7.发送交易创建消息
|
||||
*
|
||||
* @param tradeDTO 购物车视图
|
||||
* @return 交易
|
||||
|
@ -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<AfterSaleMapper, AfterSale
|
||||
} else {
|
||||
afterSaleApplyVO.setRefundWay(AfterSaleRefundWayEnum.ORIGINAL.name());
|
||||
}
|
||||
//判断订单类型,虚拟订单只支持退款
|
||||
if(order.getOrderType().equals(OrderTypeEnum.VIRTUAL.name())){
|
||||
afterSaleApplyVO.setReturnMoney(true);
|
||||
afterSaleApplyVO.setReturnGoods(false);
|
||||
}else{
|
||||
afterSaleApplyVO.setReturnMoney(true);
|
||||
afterSaleApplyVO.setReturnGoods(true);
|
||||
}
|
||||
|
||||
afterSaleApplyVO.setAccountType(order.getPaymentMethod());
|
||||
afterSaleApplyVO.setApplyRefundPrice(CurrencyUtil.sub(orderItem.getFlowPrice(), orderItem.getNum()));
|
||||
|
@ -198,9 +198,9 @@ public class OrderComplaintServiceImpl extends ServiceImpl<OrderComplaintMapper,
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer newComplainNum() {
|
||||
public Integer waitComplainNum() {
|
||||
QueryWrapper queryWrapper = Wrappers.query();
|
||||
queryWrapper.eq("complain_status", ComplaintStatusEnum.NEW.name());
|
||||
queryWrapper.ne("complain_status", ComplaintStatusEnum.COMPLETE.name());
|
||||
queryWrapper.eq(StringUtils.equals(UserContext.getCurrentUser().getRole().name(), UserEnums.STORE.name()),
|
||||
"store_id", UserContext.getCurrentUser().getStoreId());
|
||||
return this.count(queryWrapper);
|
||||
|
@ -202,8 +202,10 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> 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<OrderMapper, Order> 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<OrderMapper, Order> 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<OrderMapper, Order> 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;
|
||||
}
|
||||
|
||||
|
File diff suppressed because one or more lines are too long
@ -37,8 +37,9 @@ public interface RechargeService extends IService<Recharge> {
|
||||
*
|
||||
* @param sn 充值订单编号
|
||||
* @param receivableNo 流水no
|
||||
* @param paymentMethod 支付方式
|
||||
*/
|
||||
void paySuccess(String sn, String receivableNo);
|
||||
void paySuccess(String sn, String receivableNo,String paymentMethod);
|
||||
|
||||
/**
|
||||
* 根据充值订单号查询充值信息
|
||||
|
@ -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<RechargeMapper, Recharge> 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<Recharge>().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);
|
||||
//增加预存款余额
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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<Object> 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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -199,13 +199,12 @@ public class AdminUserServiceImpl extends ServiceImpl<AdminUserMapper, AdminUser
|
||||
if (roles.size() > 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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -66,7 +66,7 @@ public class Coupon extends BasePromotion {
|
||||
@ApiModelProperty(value = "活动描述")
|
||||
private String description;
|
||||
|
||||
@ApiModelProperty(value = "发行数量")
|
||||
@ApiModelProperty(value = "发行数量,如果是0则是不限制")
|
||||
private Integer publishNum;
|
||||
|
||||
@ApiModelProperty(value = "领取限制")
|
||||
|
@ -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<CouponActivityMapper,
|
||||
private CouponActivityItemService couponActivityItemService;
|
||||
@Autowired
|
||||
private MemberService memberService;
|
||||
//Rocketmq
|
||||
@Autowired
|
||||
private RocketmqCustomProperties rocketmqCustomProperties;
|
||||
//延时任务
|
||||
@Autowired
|
||||
private TimeTrigger timeTrigger;
|
||||
|
||||
@Override
|
||||
public CouponActivityDTO addCouponActivity(CouponActivityDTO couponActivityDTO) {
|
||||
@ -60,6 +71,17 @@ public class CouponActivityServiceImpl extends ServiceImpl<CouponActivityMapper,
|
||||
this.save(couponActivityDTO);
|
||||
//添加优惠券活动优惠券
|
||||
this.addCouponActivityItems(couponActivityDTO);
|
||||
|
||||
//创建优惠券活动延时任务
|
||||
PromotionMessage promotionMessage = new PromotionMessage(couponActivityDTO.getId(), PromotionTypeEnum.COUPON_ACTIVITY.name(), PromotionStatusEnum.START.name(), couponActivityDTO.getStartTime(), couponActivityDTO.getEndTime());
|
||||
TimeTriggerMsg timeTriggerMsg = new TimeTriggerMsg(TimeExecuteConstant.PROMOTION_EXECUTOR,
|
||||
couponActivityDTO.getStartTime().getTime(),
|
||||
promotionMessage,
|
||||
DelayQueueTools.wrapperUniqueKey(DelayTypeEnums.PROMOTION, (promotionMessage.getPromotionType() + promotionMessage.getPromotionId())),
|
||||
rocketmqCustomProperties.getPromotionTopic());
|
||||
//发送促销活动开始的延时任务
|
||||
this.timeTrigger.addDelay(timeTriggerMsg);
|
||||
|
||||
return couponActivityDTO;
|
||||
}
|
||||
|
||||
|
@ -15,18 +15,12 @@ import cn.lili.common.vo.PageVO;
|
||||
import cn.lili.config.rocketmq.RocketmqCustomProperties;
|
||||
import cn.lili.modules.goods.entity.dos.GoodsSku;
|
||||
import cn.lili.modules.goods.service.GoodsSkuService;
|
||||
import cn.lili.modules.promotion.entity.dos.Coupon;
|
||||
import cn.lili.modules.promotion.entity.dos.FullDiscount;
|
||||
import cn.lili.modules.promotion.entity.dos.MemberCoupon;
|
||||
import cn.lili.modules.promotion.entity.dos.PromotionGoods;
|
||||
import cn.lili.modules.promotion.entity.dos.*;
|
||||
import cn.lili.modules.promotion.entity.enums.*;
|
||||
import cn.lili.modules.promotion.entity.vos.CouponSearchParams;
|
||||
import cn.lili.modules.promotion.entity.vos.CouponVO;
|
||||
import cn.lili.modules.promotion.mapper.CouponMapper;
|
||||
import cn.lili.modules.promotion.service.CouponService;
|
||||
import cn.lili.modules.promotion.service.FullDiscountService;
|
||||
import cn.lili.modules.promotion.service.MemberCouponService;
|
||||
import cn.lili.modules.promotion.service.PromotionGoodsService;
|
||||
import cn.lili.modules.promotion.service.*;
|
||||
import cn.lili.modules.promotion.tools.PromotionTools;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
@ -76,6 +70,9 @@ public class CouponServiceImpl extends ServiceImpl<CouponMapper, Coupon> impleme
|
||||
//满额活动
|
||||
@Autowired
|
||||
private FullDiscountService fullDiscountService;
|
||||
//优惠券活动-优惠券关联
|
||||
@Autowired
|
||||
private CouponActivityItemService couponActivityItemService;
|
||||
|
||||
@Override
|
||||
public CouponVO add(CouponVO coupon) {
|
||||
@ -159,15 +156,31 @@ public class CouponServiceImpl extends ServiceImpl<CouponMapper, Coupon> impleme
|
||||
@Override
|
||||
public boolean deleteCoupon(String id) {
|
||||
CouponVO couponVO = checkStatus(id);
|
||||
LambdaUpdateWrapper<Coupon> couponUpdateWrapper = new LambdaUpdateWrapper<Coupon>().eq(Coupon::getId, id).set(Coupon::getPromotionStatus, PromotionStatusEnum.CLOSE.name()).set(Coupon::getDeleteFlag, true);
|
||||
|
||||
//更新优惠券状态为关闭,标示删除标志
|
||||
LambdaUpdateWrapper<Coupon> couponUpdateWrapper = new LambdaUpdateWrapper<Coupon>().eq(Coupon::getId, id)
|
||||
.set(Coupon::getPromotionStatus, PromotionStatusEnum.CLOSE.name()).set(Coupon::getDeleteFlag, true);
|
||||
boolean result = this.update(couponUpdateWrapper);
|
||||
LambdaUpdateWrapper<PromotionGoods> updateWrapper = new LambdaUpdateWrapper<PromotionGoods>().eq(PromotionGoods::getPromotionId, id).set(PromotionGoods::getPromotionStatus, PromotionStatusEnum.CLOSE.name()).set(PromotionGoods::getDeleteFlag, true);
|
||||
|
||||
//更新促销商品记录信息为删除
|
||||
LambdaUpdateWrapper<PromotionGoods> updateWrapper = new LambdaUpdateWrapper<PromotionGoods>()
|
||||
.eq(PromotionGoods::getPromotionId, id)
|
||||
.set(PromotionGoods::getPromotionStatus, PromotionStatusEnum.CLOSE.name())
|
||||
.set(PromotionGoods::getDeleteFlag, true);
|
||||
this.promotionGoodsService.update(updateWrapper);
|
||||
LambdaUpdateWrapper<MemberCoupon> memberCouponLambdaUpdateWrapper = new LambdaUpdateWrapper<MemberCoupon>().eq(MemberCoupon::getCouponId, id).set(MemberCoupon::getMemberCouponStatus, MemberCouponStatusEnum.CLOSED.name());
|
||||
|
||||
//删除mongo优惠券信息
|
||||
LambdaUpdateWrapper<MemberCoupon> memberCouponLambdaUpdateWrapper = new LambdaUpdateWrapper<MemberCoupon>()
|
||||
.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<CouponActivityItem>()
|
||||
.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<CouponMapper, Coupon> 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<CouponMapper, Coupon> 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("活动时间小于当前时间,不能进行编辑删除操作");
|
||||
|
@ -55,7 +55,7 @@ public class MemberCouponServiceImpl extends ServiceImpl<MemberCouponMapper, Mem
|
||||
if (!PromotionStatusEnum.START.name().equals(coupon.getPromotionStatus())) {
|
||||
throw new ServiceException("当前优惠券状态不可领取");
|
||||
}
|
||||
if (coupon.getReceivedNum() >= coupon.getPublishNum()) {
|
||||
if (coupon.getPublishNum() != 0 && coupon.getReceivedNum() >= coupon.getPublishNum()) {
|
||||
throw new ServiceException("优惠券剩余领取数量不足");
|
||||
}
|
||||
if (haveCoupons >= coupon.getCouponLimitNum()) {
|
||||
|
@ -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<CouponActivity>()
|
||||
.eq(CouponActivity::getId,promotionMessage.getPromotionId())
|
||||
.set(CouponActivity::getPromotionStatus,promotionMessage.getPromotionStatus()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -185,7 +185,7 @@ public class SeckillApplyServiceImpl extends ServiceImpl<SeckillApplyMapper, Sec
|
||||
promotionGoodsService.saveBatch(promotionGoodsList);
|
||||
}
|
||||
//设置秒杀活动的商品数量、店铺数量
|
||||
seckillService.updateSeckillGoodsNum(seckill.getId());
|
||||
seckillService.updateSeckillGoodsNum(seckillId);
|
||||
}
|
||||
|
||||
|
||||
|
@ -126,7 +126,7 @@ public class SeckillServiceImpl extends ServiceImpl<SeckillMapper, Seckill> 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<SeckillMapper, Seckill> impl
|
||||
public Integer getApplyNum() {
|
||||
LambdaQueryWrapper<Seckill> 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<SeckillMapper, Seckill> impl
|
||||
int sameNum = this.count(queryWrapper);
|
||||
//当前时间段是否存在同类活动
|
||||
if (sameNum > 0) {
|
||||
throw new ServiceException("当前时间内已存在同类活动");
|
||||
throw new ServiceException("当前时间内已存在同类活动:"+seckill.getStartTime());
|
||||
}
|
||||
}
|
||||
}
|
@ -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<EsGoodsAttribute> attributes = new ArrayList<>();
|
||||
// JSONObject jsonObject = JSONUtil.parseObj(sku.getSpecs());
|
||||
// for (Map.Entry<String, Object> 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> goodsParams) {
|
||||
/**
|
||||
* 参数索引增加
|
||||
*
|
||||
* @param sku
|
||||
* @param goodsParamDTOS
|
||||
*/
|
||||
public EsGoodsIndex(GoodsSku sku, List<GoodsParamsDTO> goodsParamDTOS) {
|
||||
this(sku);
|
||||
if (goodsParams != null && !goodsParams.isEmpty()) {
|
||||
//如果参数不为空
|
||||
if (goodsParamDTOS != null && !goodsParamDTOS.isEmpty()) {
|
||||
//接受不了参数索引
|
||||
List<EsGoodsAttribute> attributes = new ArrayList<>();
|
||||
for (GoodsParams goodsParam : goodsParams) {
|
||||
EsGoodsAttribute attribute = new EsGoodsAttribute();
|
||||
//循环参数分组
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -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> goodsParams);
|
||||
EsGoodsIndex resetEsGoodsIndex(GoodsSku goodsSku, List<GoodsParamsDTO> goodsParamDTOS);
|
||||
}
|
||||
|
@ -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> goodsParams) {
|
||||
EsGoodsIndex index = new EsGoodsIndex(goodsSku, goodsParams);
|
||||
public EsGoodsIndex resetEsGoodsIndex(GoodsSku goodsSku, List<GoodsParamsDTO> goodsParamDTOS) {
|
||||
EsGoodsIndex index = new EsGoodsIndex(goodsSku, goodsParamDTOS);
|
||||
//获取活动信息
|
||||
Map<String, Object> goodsCurrentPromotionMap = promotionService.getGoodsCurrentPromotionMap(index);
|
||||
//写入促销信息
|
||||
|
@ -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 = "下单转换率")
|
||||
|
@ -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));
|
||||
|
@ -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<OrderStatisticsD
|
||||
OrderOverviewVO orderOverviewVO = new OrderOverviewVO();
|
||||
//访客数
|
||||
orderOverviewVO.setUvNum(platformViewDataService.countUv(statisticsQueryParam));
|
||||
if (orderOverviewVO.getUvNum() == null) {
|
||||
orderOverviewVO.setUvNum(0);
|
||||
}
|
||||
|
||||
//下单统计
|
||||
initOrder(dates, orderOverviewVO);
|
||||
initOrder(dates, orderOverviewVO, statisticsQueryParam);
|
||||
|
||||
//付款统计
|
||||
initPayment(dates, orderOverviewVO);
|
||||
initPayment(dates, orderOverviewVO, statisticsQueryParam);
|
||||
|
||||
//退单统计
|
||||
initAfterSale(dates, orderOverviewVO);
|
||||
initAfterSale(dates, orderOverviewVO, statisticsQueryParam);
|
||||
|
||||
//数据运算(转换率,比例相关)
|
||||
conversionRateOperation(orderOverviewVO);
|
||||
@ -97,24 +93,37 @@ public class OrderStatisticsDataServiceImpl extends ServiceImpl<OrderStatisticsD
|
||||
* @param dates
|
||||
* @param orderOverviewVO
|
||||
*/
|
||||
private void initOrder(Date[] dates, OrderOverviewVO orderOverviewVO) {
|
||||
private void initOrder(Date[] dates, OrderOverviewVO orderOverviewVO, StatisticsQueryParam statisticsQueryParam) {
|
||||
//构建查询条件
|
||||
QueryWrapper queryWrapper = Wrappers.query();
|
||||
//时间区间
|
||||
queryWrapper.between("create_time", dates[0], dates[1]);
|
||||
//如果有店铺id传入,则查询店铺
|
||||
if (StringUtils.isNotEmpty(statisticsQueryParam.getStoreId())) {
|
||||
queryWrapper.eq("store_id", statisticsQueryParam.getStoreId());
|
||||
}
|
||||
//查询流水金额和订单数量
|
||||
queryWrapper.select("SUM(flow_price) AS price , COUNT(0) AS num");
|
||||
//获取查询结果
|
||||
Map order = orderService.getMap(queryWrapper);
|
||||
//赋予订单数和流水金额
|
||||
orderOverviewVO.setOrderNum(order != null && order.containsKey("num") ? (Long) order.get("num") : 0L);
|
||||
orderOverviewVO.setOrderAmount(order != null && order.containsKey("price") ? (double) order.get("price") : 0L);
|
||||
|
||||
//查询下单人数
|
||||
queryWrapper = Wrappers.query();
|
||||
//时间区间
|
||||
queryWrapper.between("create_time", dates[0], dates[1]);
|
||||
queryWrapper.select("count(DISTINCT member_id) AS num");
|
||||
Map memberNum = orderService.getMap(queryWrapper);
|
||||
|
||||
orderOverviewVO.setOrderMemberNum(memberNum != null && memberNum.containsKey("num") ? (Long) memberNum.get("num") : 0L);
|
||||
|
||||
if (orderOverviewVO.getOrderAmount() == null) {
|
||||
orderOverviewVO.setOrderAmount(0D);
|
||||
//如果有店铺id传入,则查询店铺
|
||||
if (StringUtils.isNotEmpty(statisticsQueryParam.getStoreId())) {
|
||||
queryWrapper.eq("store_id", statisticsQueryParam.getStoreId());
|
||||
}
|
||||
//查询下单人数的sql
|
||||
queryWrapper.select("count(DISTINCT member_id) AS num");
|
||||
//获取查询结果
|
||||
Map memberNum = orderService.getMap(queryWrapper);
|
||||
//写入下单人数
|
||||
orderOverviewVO.setOrderMemberNum(memberNum != null && memberNum.containsKey("num") ? (Long) memberNum.get("num") : 0L);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -123,10 +132,14 @@ public class OrderStatisticsDataServiceImpl extends ServiceImpl<OrderStatisticsD
|
||||
* @param dates
|
||||
* @param orderOverviewVO
|
||||
*/
|
||||
private void initPayment(Date[] dates, OrderOverviewVO orderOverviewVO) {
|
||||
private void initPayment(Date[] dates, OrderOverviewVO orderOverviewVO, StatisticsQueryParam statisticsQueryParam) {
|
||||
//付款订单数,付款金额
|
||||
QueryWrapper queryWrapper = Wrappers.query();
|
||||
queryWrapper.between("create_time", dates[0], dates[1]);
|
||||
//如果有店铺id传入,则查询店铺
|
||||
if (StringUtils.isNotEmpty(statisticsQueryParam.getStoreId())) {
|
||||
queryWrapper.eq("store_id", statisticsQueryParam.getStoreId());
|
||||
}
|
||||
queryWrapper.select("SUM(final_price) AS price , COUNT(0) AS num");
|
||||
queryWrapper.eq("flow_type", FlowTypeEnum.PAY.name());
|
||||
Map payment = this.getMap(queryWrapper);
|
||||
@ -137,6 +150,10 @@ public class OrderStatisticsDataServiceImpl extends ServiceImpl<OrderStatisticsD
|
||||
//付款人数
|
||||
queryWrapper = Wrappers.query();
|
||||
queryWrapper.between("create_time", dates[0], dates[1]);
|
||||
//如果有店铺id传入,则查询店铺
|
||||
if (StringUtils.isNotEmpty(statisticsQueryParam.getStoreId())) {
|
||||
queryWrapper.eq("store_id", statisticsQueryParam.getStoreId());
|
||||
}
|
||||
queryWrapper.select("COUNT(0) AS num");
|
||||
queryWrapper.groupBy("member_id");
|
||||
Map paymentMemberNum = this.getMap(queryWrapper);
|
||||
@ -150,11 +167,15 @@ public class OrderStatisticsDataServiceImpl extends ServiceImpl<OrderStatisticsD
|
||||
* @param dates
|
||||
* @param orderOverviewVO
|
||||
*/
|
||||
private void initAfterSale(Date[] dates, OrderOverviewVO orderOverviewVO) {
|
||||
private void initAfterSale(Date[] dates, OrderOverviewVO orderOverviewVO, StatisticsQueryParam statisticsQueryParam) {
|
||||
//付款订单数,付款金额
|
||||
QueryWrapper queryWrapper = Wrappers.query();
|
||||
queryWrapper.between("create_time", dates[0], dates[1]);
|
||||
queryWrapper.select("SUM(final_price) AS price , COUNT(0) AS num");
|
||||
//如果有店铺id传入,则查询店铺
|
||||
if (StringUtils.isNotEmpty(statisticsQueryParam.getStoreId())) {
|
||||
queryWrapper.eq("store_id", statisticsQueryParam.getStoreId());
|
||||
}
|
||||
queryWrapper.eq("flow_type", FlowTypeEnum.REFUND.name());
|
||||
Map payment = this.getMap(queryWrapper);
|
||||
orderOverviewVO.setRefundOrderNum(payment != null && payment.containsKey("num") ? (Long) payment.get("num") : 0L);
|
||||
@ -193,7 +214,7 @@ public class OrderStatisticsDataServiceImpl extends ServiceImpl<OrderStatisticsD
|
||||
public Integer orderNum(String orderStatus) {
|
||||
LambdaQueryWrapper<Order> 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);
|
||||
|
@ -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<PlatformViewDataMap
|
||||
@Autowired
|
||||
private Cache cache;
|
||||
|
||||
//平台流量统计
|
||||
@Autowired
|
||||
private PlatformViewDataMapper platformViewDataMapper;
|
||||
|
||||
@Override
|
||||
public Long online() {
|
||||
@ -221,8 +223,6 @@ public class PlatformViewDataServiceImpl extends ServiceImpl<PlatformViewDataMap
|
||||
|
||||
calendar.set(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH), 0, 0, 0);
|
||||
calendar.set(Calendar.MILLISECOND, 0);
|
||||
|
||||
System.out.println(DateUtil.toString(calendar.getTime().getTime(), DateUtil.STANDARD_FORMAT));
|
||||
//如果是今天的统计,则从redis 中拿,否则从数据库中拿
|
||||
if (dates[0].equals(calendar.getTime())) {
|
||||
if (StringUtils.isNotEmpty(queryParam.getStoreId())) {
|
||||
@ -238,7 +238,7 @@ public class PlatformViewDataServiceImpl extends ServiceImpl<PlatformViewDataMap
|
||||
} else {
|
||||
queryWrapper.eq("store_id", -1);
|
||||
}
|
||||
return this.count(queryWrapper);
|
||||
return platformViewDataMapper.count(queryWrapper);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ package cn.lili.modules.store.entity.dos;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.lili.common.validation.Mobile;
|
||||
import cn.lili.common.validation.Phone;
|
||||
import cn.lili.modules.store.entity.dto.AdminStoreApplyDTO;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
@ -93,7 +94,7 @@ public class StoreDetail {
|
||||
private String linkName;
|
||||
|
||||
@NotBlank(message = "手机号不能为空")
|
||||
@Pattern(regexp = "^[1][3,4,5,6,7,8,9][0-9]{9}$", message = "手机号格式有误")
|
||||
@Phone
|
||||
@ApiModelProperty(value = "联系人电话")
|
||||
private String linkPhone;
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
package cn.lili.modules.store.entity.dto;
|
||||
|
||||
import cn.lili.common.validation.Mobile;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
@ -57,6 +58,7 @@ public class AdminStoreApplyDTO {
|
||||
@ApiModelProperty(value = "公司名称")
|
||||
private String companyName;
|
||||
|
||||
@Mobile
|
||||
@ApiModelProperty(value = "公司电话")
|
||||
private String companyPhone;
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
package cn.lili.modules.store.entity.dto;
|
||||
|
||||
import cn.lili.common.validation.Mobile;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
@ -38,6 +39,10 @@ public class StoreCompanyDTO {
|
||||
@ApiModelProperty(value = "公司地址")
|
||||
private String companyAddress;
|
||||
|
||||
@Mobile
|
||||
@ApiModelProperty(value = "公司电话")
|
||||
private String companyPhone;
|
||||
|
||||
@Email
|
||||
@ApiModelProperty(value = "电子邮箱")
|
||||
private String companyEmail;
|
||||
|
@ -1,11 +1,23 @@
|
||||
package cn.lili.modules.store.entity.dto;
|
||||
|
||||
import cn.lili.common.validation.Mobile;
|
||||
import cn.lili.common.validation.Phone;
|
||||
import cn.lili.modules.store.entity.dos.StoreDetail;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Id;
|
||||
import javax.validation.constraints.Email;
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 店铺修改DTO
|
||||
@ -14,7 +26,147 @@ import javax.validation.constraints.Size;
|
||||
* @date 2020-08-22 15:10:51
|
||||
*/
|
||||
@Data
|
||||
public class StoreEditDTO extends StoreDetail {
|
||||
public class StoreEditDTO {
|
||||
|
||||
|
||||
@Id
|
||||
@TableId
|
||||
@TableField
|
||||
@Column(columnDefinition = "bigint(20)")
|
||||
@ApiModelProperty(value = "唯一标识", hidden = true)
|
||||
private String id;
|
||||
|
||||
@NotBlank(message = "店铺不能为空")
|
||||
@ApiModelProperty(value = "店铺id")
|
||||
private String storeId;
|
||||
|
||||
@Size(min = 2, max = 200, message = "店铺名称长度为2-200位")
|
||||
@NotBlank(message = "店铺名称不能为空")
|
||||
@ApiModelProperty(value = "店铺名称")
|
||||
private String storeName;
|
||||
|
||||
@NotBlank(message = "公司名称不能为空")
|
||||
@Size(min = 2, max = 100, message = "公司名称错误")
|
||||
@ApiModelProperty(value = "公司名称")
|
||||
private String companyName;
|
||||
|
||||
@NotBlank(message = "公司地址不能为空")
|
||||
@Size(min = 1, max = 200, message = "公司地址,长度为1-200字符")
|
||||
@ApiModelProperty(value = "公司地址")
|
||||
private String companyAddress;
|
||||
|
||||
@ApiModelProperty(value = "公司地址地区Id")
|
||||
private String companyAddressIdPath;
|
||||
|
||||
@ApiModelProperty(value = "公司地址地区")
|
||||
private String companyAddressPath;
|
||||
|
||||
@Mobile
|
||||
@ApiModelProperty(value = "公司电话")
|
||||
private String companyPhone;
|
||||
|
||||
@Email
|
||||
@ApiModelProperty(value = "电子邮箱")
|
||||
private String companyEmail;
|
||||
|
||||
@Min(value = 1, message = "员工总数,至少一位")
|
||||
@ApiModelProperty(value = "员工总数")
|
||||
private Integer employeeNum;
|
||||
|
||||
@Min(value = 1, message = "注册资金,至少一位")
|
||||
@ApiModelProperty(value = "注册资金")
|
||||
private Double registeredCapital;
|
||||
|
||||
@NotBlank(message = "联系人姓名为空")
|
||||
@Length(min = 2, max = 20, message = "联系人长度为:2-20位字符")
|
||||
@ApiModelProperty(value = "联系人姓名")
|
||||
private String linkName;
|
||||
|
||||
@NotBlank(message = "手机号不能为空")
|
||||
@Phone
|
||||
@ApiModelProperty(value = "联系人电话")
|
||||
private String linkPhone;
|
||||
|
||||
@Size(min = 18, max = 18, message = "营业执照长度为18位字符")
|
||||
@ApiModelProperty(value = "营业执照号")
|
||||
private String licenseNum;
|
||||
|
||||
@Size(min = 1, max = 200, message = "法定经营范围长度为1-200位字符")
|
||||
@ApiModelProperty(value = "法定经营范围")
|
||||
private String scope;
|
||||
|
||||
@NotBlank(message = "营业执照电子版不能为空")
|
||||
@ApiModelProperty(value = "营业执照电子版")
|
||||
private String licencePhoto;
|
||||
|
||||
@NotBlank(message = "法人姓名不能为空")
|
||||
@Size(min = 2, max = 20, message = "法人姓名长度为2-20位字符")
|
||||
@ApiModelProperty(value = "法人姓名")
|
||||
private String legalName;
|
||||
|
||||
@NotBlank(message = "法人身份证不能为空")
|
||||
@Size(min = 18, max = 18, message = "法人身份证号长度为18位")
|
||||
@ApiModelProperty(value = "法人身份证")
|
||||
private String legalId;
|
||||
|
||||
@NotBlank(message = "法人身份证不能为空")
|
||||
@ApiModelProperty(value = "法人身份证照片")
|
||||
private String legalPhoto;
|
||||
|
||||
@Size(min = 1, max = 200, message = "结算银行开户行名称长度为1-200位")
|
||||
@NotBlank(message = "结算银行开户行名称不能为空")
|
||||
@ApiModelProperty(value = "结算银行开户行名称")
|
||||
private String settlementBankAccountName;
|
||||
|
||||
@Size(min = 1, max = 200, message = "结算银行开户账号长度为1-200位")
|
||||
@NotBlank(message = "结算银行开户账号不能为空")
|
||||
@ApiModelProperty(value = "结算银行开户账号")
|
||||
private String settlementBankAccountNum;
|
||||
|
||||
@Size(min = 1, max = 200, message = "结算银行开户支行名称长度为1-200位")
|
||||
@NotBlank(message = "结算银行开户支行名称不能为空")
|
||||
@ApiModelProperty(value = "结算银行开户支行名称")
|
||||
private String settlementBankBranchName;
|
||||
|
||||
@Size(min = 1, max = 50, message = "结算银行支行联行号长度为1-200位")
|
||||
@NotBlank(message = "结算银行支行联行号不能为空")
|
||||
@ApiModelProperty(value = "结算银行支行联行号")
|
||||
private String settlementBankJointName;
|
||||
|
||||
@NotBlank(message = "店铺经营类目不能为空")
|
||||
@ApiModelProperty(value = "店铺经营类目")
|
||||
@Column(columnDefinition = "TEXT")
|
||||
private String goodsManagementCategory;
|
||||
|
||||
@ApiModelProperty(value = "结算周期")
|
||||
private String settlementCycle;
|
||||
|
||||
|
||||
@ApiModelProperty(value = "库存预警数量")
|
||||
private Integer stockWarning;
|
||||
|
||||
/**
|
||||
* 同城配送达达店铺编码
|
||||
*/
|
||||
@ApiModelProperty(value = "同城配送达达店铺编码")
|
||||
@TableField(value = "dd_code")
|
||||
private String ddCode;
|
||||
|
||||
//店铺退货收件地址
|
||||
@ApiModelProperty(value = "收货人姓名")
|
||||
private String salesConsigneeName;
|
||||
|
||||
@ApiModelProperty(value = "收件人手机")
|
||||
private String salesConsigneeMobile;
|
||||
|
||||
@ApiModelProperty(value = "地址Id, ','分割")
|
||||
private String salesConsigneeAddressId;
|
||||
|
||||
@ApiModelProperty(value = "地址名称, ','分割")
|
||||
private String salesConsigneeAddressPath;
|
||||
|
||||
@ApiModelProperty(value = "详细地址")
|
||||
private String salesConsigneeDetail;
|
||||
|
||||
@ApiModelProperty(value = "店铺状态")
|
||||
private String storeDisable;
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user