diff --git a/buyer-api/src/main/java/cn/lili/controller/passport/MemberBuyerController.java b/buyer-api/src/main/java/cn/lili/controller/passport/MemberBuyerController.java index d909135c..a9981b3d 100644 --- a/buyer-api/src/main/java/cn/lili/controller/passport/MemberBuyerController.java +++ b/buyer-api/src/main/java/cn/lili/controller/passport/MemberBuyerController.java @@ -63,9 +63,9 @@ public class MemberBuyerController { public ResultMessage smsLogin(@NotNull(message = "手机号为空") @RequestParam String mobile, @NotNull(message = "验证码为空") @RequestParam String code, @RequestHeader String uuid) { - if(smsUtil.verifyCode(mobile,VerificationEnums.LOGIN,uuid,code)){ - return ResultUtil.data(memberService.mobilePhoneLogin(mobile)); - }else { + if (smsUtil.verifyCode(mobile, VerificationEnums.LOGIN, uuid, code)) { + return ResultUtil.data(memberService.mobilePhoneLogin(mobile)); + } else { throw new ServiceException("验证码错误"); } } diff --git a/buyer-api/src/main/java/cn/lili/controller/payment/CashierController.java b/buyer-api/src/main/java/cn/lili/controller/payment/CashierController.java index 30117fee..0ba33e91 100644 --- a/buyer-api/src/main/java/cn/lili/controller/payment/CashierController.java +++ b/buyer-api/src/main/java/cn/lili/controller/payment/CashierController.java @@ -2,6 +2,7 @@ package cn.lili.controller.payment; import cn.lili.common.enums.ResultCode; import cn.lili.common.enums.ResultUtil; +import cn.lili.common.exception.ServiceException; import cn.lili.common.vo.ResultMessage; import cn.lili.modules.payment.kit.CashierSupport; import cn.lili.modules.payment.kit.dto.PayParam; @@ -64,8 +65,11 @@ public class CashierController { try { return cashierSupport.payment(paymentMethodEnum, paymentClientEnum, request, response, payParam); + } catch (ServiceException se) { + log.info("支付异常", se); + throw se; } catch (Exception e) { - log.error("收银台支付错误",e); + log.error("收银台支付错误", e); } return null; diff --git a/framework/src/main/java/cn/lili/common/enums/ResultCode.java b/framework/src/main/java/cn/lili/common/enums/ResultCode.java index bc0b33c2..395cf364 100644 --- a/framework/src/main/java/cn/lili/common/enums/ResultCode.java +++ b/framework/src/main/java/cn/lili/common/enums/ResultCode.java @@ -51,7 +51,7 @@ public enum ResultCode { /** * 商品 */ - GOODS_ERROR(11010, "读取商品异常"), + GOODS_ERROR(11001, "商品异常,请稍后重试"), GOODS_NOT_EXIST(11001, "商品已下架"), GOODS_NAME_ERROR(11002, "商品名称不正确,名称应为2-50字符"), GOODS_UNDER_ERROR(11003, "商品下架失败"), @@ -63,6 +63,7 @@ public enum ResultCode { GOODS_SKU_COST_ERROR(11009, "商品SKU成本价不能小于等于0"), GOODS_SKU_WEIGHT_ERROR(11010, "商品重量不能为负数"), GOODS_SKU_QUANTITY_ERROR(11011, "商品库存数量不能为负数"), + GOODS_SKU_QUANTITY_NOT_ENOUGH(11011, "商品库存不足"), /** * 参数 @@ -196,6 +197,10 @@ public enum ResultCode { ORDER_DELIVER_NUM_ERROR(31010, "没有待发货的订单"), + ORDER_NOT_SUPPORT_DISTRIBUTION(31011, "购物车中包含不支持配送的商品,请重新选择收货地址,或者重新选择商品"), + + ORDER_CAN_NOT_CANCEL(31012, "当前订单状态不可取消"), + /** * 支付 */ diff --git a/framework/src/main/java/cn/lili/common/verification/SliderImageUtil.java b/framework/src/main/java/cn/lili/common/verification/SliderImageUtil.java index a40cfc67..39b00968 100644 --- a/framework/src/main/java/cn/lili/common/verification/SliderImageUtil.java +++ b/framework/src/main/java/cn/lili/common/verification/SliderImageUtil.java @@ -78,7 +78,7 @@ public class SliderImageUtil { graphics.dispose(); //添加水印 - ImageUtil.addWatermark(originalImage, "请滑动拼图"); + ImageUtil.addWatermark(originalImage, "LILI-SHOP"); ByteArrayOutputStream newImageOs = new ByteArrayOutputStream();//新建流。 ImageIO.write(newImage, TEMP_IMG_FILE_TYPE, newImageOs);//利用ImageIO类提供的write方法,将bi以png图片的数据模式写入流。 byte[] newImagery = newImageOs.toByteArray(); diff --git a/framework/src/main/java/cn/lili/modules/goods/entity/dos/Goods.java b/framework/src/main/java/cn/lili/modules/goods/entity/dos/Goods.java index acf79d3d..e4f8eefa 100644 --- a/framework/src/main/java/cn/lili/modules/goods/entity/dos/Goods.java +++ b/framework/src/main/java/cn/lili/modules/goods/entity/dos/Goods.java @@ -221,8 +221,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(); diff --git a/framework/src/main/java/cn/lili/modules/goods/entity/dos/GoodsParams.java b/framework/src/main/java/cn/lili/modules/goods/entity/dos/GoodsParams.java deleted file mode 100644 index 16045221..00000000 --- a/framework/src/main/java/cn/lili/modules/goods/entity/dos/GoodsParams.java +++ /dev/null @@ -1,67 +0,0 @@ -package cn.lili.modules.goods.entity.dos; - -import cn.lili.base.BaseEntity; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableName; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import lombok.EqualsAndHashCode; -import org.hibernate.validator.constraints.Length; - -import javax.persistence.Entity; -import javax.persistence.Table; -import javax.validation.constraints.Max; -import javax.validation.constraints.Min; -import javax.validation.constraints.NotNull; - -/** - * 商品关联参数 - * - * @author pikachu - * @date 2020-02-23 9:14:33 - */ -@EqualsAndHashCode(callSuper = true) -@Data -@Entity -@Table(name = "li_goods_params") -@TableName("li_goods_params") -@ApiModel(value = "商品关联参数") -public class GoodsParams extends BaseEntity { - - private static final long serialVersionUID = 1L; - - /** - * 商品id - */ - @TableField(value = "goods_id") - @ApiModelProperty(value = "商品id", hidden = true) - private String goodsId; - /** - * 参数id - */ - @TableField(value = "param_id") - @ApiModelProperty(value = "参数id", required = true) - private String paramId; - /** - * 参数名字 - */ - @TableField(value = "param_name") - @ApiModelProperty(value = "参数名字", required = true) - private String paramName; - /** - * 参数值 - */ - @TableField(value = "param_value") - @ApiModelProperty(value = "参数值", required = true) - @Length(max = 100, message = "参数值字符不能大于120") - private String paramValue; - - @TableField(value = "is_index") - @ApiModelProperty(value = "是否可索引,0 不显示 1 显示", required = true) - @NotNull(message = "是否可索引必选") - @Min(value = 0, message = "是否可索引传值不正确") - @Max(value = 1, message = "是否可索引传值不正确") - private Integer isIndex = 0; - -} \ No newline at end of file diff --git a/framework/src/main/java/cn/lili/modules/goods/entity/dos/Parameters.java b/framework/src/main/java/cn/lili/modules/goods/entity/dos/Parameters.java index f9198944..96fcc1f8 100644 --- a/framework/src/main/java/cn/lili/modules/goods/entity/dos/Parameters.java +++ b/framework/src/main/java/cn/lili/modules/goods/entity/dos/Parameters.java @@ -1,13 +1,17 @@ package cn.lili.modules.goods.entity.dos; -import cn.lili.base.BaseEntity; +import cn.lili.base.IdEntity; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import org.hibernate.validator.constraints.Length; +import javax.persistence.Column; import javax.persistence.Entity; +import javax.persistence.Id; import javax.persistence.Table; import javax.validation.constraints.Max; import javax.validation.constraints.Min; @@ -25,7 +29,9 @@ import javax.validation.constraints.NotNull; @Table(name = "li_parameters") @TableName("li_parameters") @ApiModel(value = "商品参数") -public class Parameters extends BaseEntity { +public class Parameters extends IdEntity { + + private static final long serialVersionUID = -566510714456317006L; @@ -36,6 +42,7 @@ public class Parameters extends BaseEntity { @ApiModelProperty(value = "选择值") + @NotEmpty(message = "参数选项值必填") private String options; @ApiModelProperty(value = "是否可索引,0 不显示 1 显示", required = true) diff --git a/framework/src/main/java/cn/lili/modules/goods/entity/dos/Specification.java b/framework/src/main/java/cn/lili/modules/goods/entity/dos/Specification.java index 436d6ce3..b4e8a272 100644 --- a/framework/src/main/java/cn/lili/modules/goods/entity/dos/Specification.java +++ b/framework/src/main/java/cn/lili/modules/goods/entity/dos/Specification.java @@ -1,6 +1,6 @@ package cn.lili.modules.goods.entity.dos; -import cn.lili.base.BaseEntity; +import cn.lili.base.IdEntity; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; import io.swagger.annotations.ApiModel; @@ -23,7 +23,7 @@ import javax.validation.constraints.NotEmpty; @Table(name = "li_specification") @TableName("li_specification") @ApiModel(value = "规格项") -public class Specification extends BaseEntity { +public class Specification extends IdEntity { private static final long serialVersionUID = 147792597901239486L; diff --git a/framework/src/main/java/cn/lili/modules/goods/entity/dto/DraftGoodsDTO.java b/framework/src/main/java/cn/lili/modules/goods/entity/dto/DraftGoodsDTO.java index 607223b6..b1517e6b 100644 --- a/framework/src/main/java/cn/lili/modules/goods/entity/dto/DraftGoodsDTO.java +++ b/framework/src/main/java/cn/lili/modules/goods/entity/dto/DraftGoodsDTO.java @@ -1,7 +1,6 @@ package cn.lili.modules.goods.entity.dto; import cn.lili.modules.goods.entity.dos.DraftGoods; -import cn.lili.modules.goods.entity.dos.GoodsParams; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -22,7 +21,7 @@ public class DraftGoodsDTO extends DraftGoods { @ApiModelProperty(value = "商品参数") @Valid - private List goodsParamsList; + private List goodsParamsDTOList; @ApiModelProperty(value = "商品图片") private List goodsGalleryList; diff --git a/framework/src/main/java/cn/lili/modules/goods/entity/dto/GoodsOperationDTO.java b/framework/src/main/java/cn/lili/modules/goods/entity/dto/GoodsOperationDTO.java index 20cf8120..3decd397 100644 --- a/framework/src/main/java/cn/lili/modules/goods/entity/dto/GoodsOperationDTO.java +++ b/framework/src/main/java/cn/lili/modules/goods/entity/dto/GoodsOperationDTO.java @@ -1,6 +1,5 @@ package cn.lili.modules.goods.entity.dto; -import cn.lili.modules.goods.entity.dos.GoodsParams; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.ToString; @@ -83,8 +82,7 @@ public class GoodsOperationDTO implements Serializable { private boolean recommend; @ApiModelProperty(value = "商品参数") - @Valid - private List goodsParamsList; + private List goodsParamsDTOList; @ApiModelProperty(value = "商品图片") private List goodsGalleryList; @@ -121,4 +119,7 @@ public class GoodsOperationDTO implements Serializable { */ @ApiModelProperty(value = "商品类型") private String goodsType; + + + } diff --git a/framework/src/main/java/cn/lili/modules/goods/entity/dto/GoodsParamsDTO.java b/framework/src/main/java/cn/lili/modules/goods/entity/dto/GoodsParamsDTO.java new file mode 100644 index 00000000..09be40e0 --- /dev/null +++ b/framework/src/main/java/cn/lili/modules/goods/entity/dto/GoodsParamsDTO.java @@ -0,0 +1,31 @@ +package cn.lili.modules.goods.entity.dto; + +import com.baomidou.mybatisplus.annotation.TableField; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +/** + * 商品关联参数 + * + * @author pikachu + * @date 2020-02-23 9:14:33 + */ +@Data +@ApiModel(value = "商品参数分组") +public class GoodsParamsDTO { + + @TableField(value = "group_id") + @ApiModelProperty(value = "分组id") + private String groupId; + + @TableField(value = "group_name") + @ApiModelProperty(value = "分组名称") + private String groupName; + + @ApiModelProperty(value = "分组内的商品参数列表") + private List goodsParamsItemDTOList; + +} \ No newline at end of file diff --git a/framework/src/main/java/cn/lili/modules/goods/entity/dto/GoodsParamsItemDTO.java b/framework/src/main/java/cn/lili/modules/goods/entity/dto/GoodsParamsItemDTO.java new file mode 100644 index 00000000..84eb2113 --- /dev/null +++ b/framework/src/main/java/cn/lili/modules/goods/entity/dto/GoodsParamsItemDTO.java @@ -0,0 +1,35 @@ +package cn.lili.modules.goods.entity.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.Max; +import javax.validation.constraints.Min; + +/** + * 商品参数项 + * + * @author Chopper + * @version v1.0 + * 2021-06-24 15:41 + */ +@Data +@ApiModel(value = "商品参数列表") +public class GoodsParamsItemDTO { + + @ApiModelProperty(value = "参数ID") + private String paramId; + + @ApiModelProperty(value = "参数名字") + private String paramName; + + @ApiModelProperty(value = "参数值") + private String paramValue; + + @ApiModelProperty(value = "是否可索引,0 不索引 1 索引") + private Integer isIndex = 0; + + @ApiModelProperty(value = "是否必填,0 不显示 1 显示") + private Integer required = 0; +} diff --git a/framework/src/main/java/cn/lili/modules/goods/entity/vos/DraftGoodsVO.java b/framework/src/main/java/cn/lili/modules/goods/entity/vos/DraftGoodsVO.java index f6e67966..2bf39fad 100644 --- a/framework/src/main/java/cn/lili/modules/goods/entity/vos/DraftGoodsVO.java +++ b/framework/src/main/java/cn/lili/modules/goods/entity/vos/DraftGoodsVO.java @@ -1,10 +1,9 @@ package cn.lili.modules.goods.entity.vos; import cn.lili.modules.goods.entity.dos.DraftGoods; -import cn.lili.modules.goods.entity.dos.GoodsParams; +import cn.lili.modules.goods.entity.dto.GoodsParamsDTO; import io.swagger.annotations.ApiModelProperty; import lombok.Data; -import lombok.EqualsAndHashCode; import java.util.List; @@ -23,7 +22,7 @@ public class DraftGoodsVO extends DraftGoods { private List categoryName; @ApiModelProperty(value = "商品参数") - private List goodsParamsList; + private List goodsParamsDTOList; @ApiModelProperty(value = "商品图片") private List goodsGalleryList; diff --git a/framework/src/main/java/cn/lili/modules/goods/entity/vos/GoodsParamsVO.java b/framework/src/main/java/cn/lili/modules/goods/entity/vos/GoodsParamsDTOVO.java similarity index 90% rename from framework/src/main/java/cn/lili/modules/goods/entity/vos/GoodsParamsVO.java rename to framework/src/main/java/cn/lili/modules/goods/entity/vos/GoodsParamsDTOVO.java index 795a22c6..64deda4f 100644 --- a/framework/src/main/java/cn/lili/modules/goods/entity/vos/GoodsParamsVO.java +++ b/framework/src/main/java/cn/lili/modules/goods/entity/vos/GoodsParamsDTOVO.java @@ -1,7 +1,7 @@ package cn.lili.modules.goods.entity.vos; -import cn.lili.modules.goods.entity.dos.GoodsParams; +import cn.lili.modules.goods.entity.dto.GoodsParamsDTO; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -12,7 +12,7 @@ import lombok.Data; * @date 2020-02-26 23:24:13 */ @Data -public class GoodsParamsVO extends GoodsParams { +public class GoodsParamsDTOVO extends GoodsParamsDTO { private static final long serialVersionUID = -4904700751774005326L; @ApiModelProperty("1 输入项 2 选择项") diff --git a/framework/src/main/java/cn/lili/modules/goods/entity/vos/GoodsParamsGroupVO.java b/framework/src/main/java/cn/lili/modules/goods/entity/vos/GoodsParamsGroupVO.java index 18d0a9d5..9202f953 100644 --- a/framework/src/main/java/cn/lili/modules/goods/entity/vos/GoodsParamsGroupVO.java +++ b/framework/src/main/java/cn/lili/modules/goods/entity/vos/GoodsParamsGroupVO.java @@ -16,7 +16,7 @@ import java.util.List; public class GoodsParamsGroupVO implements Serializable { private static final long serialVersionUID = 1450550797436233753L; @ApiModelProperty("参数组关联的参数集合") - private List params; + private List params; @ApiModelProperty("参数组名称") private String groupName; @ApiModelProperty("参数组id") diff --git a/framework/src/main/java/cn/lili/modules/goods/entity/vos/GoodsVO.java b/framework/src/main/java/cn/lili/modules/goods/entity/vos/GoodsVO.java index 6207aac0..ebb31251 100644 --- a/framework/src/main/java/cn/lili/modules/goods/entity/vos/GoodsVO.java +++ b/framework/src/main/java/cn/lili/modules/goods/entity/vos/GoodsVO.java @@ -1,7 +1,7 @@ package cn.lili.modules.goods.entity.vos; import cn.lili.modules.goods.entity.dos.Goods; -import cn.lili.modules.goods.entity.dos.GoodsParams; +import cn.lili.modules.goods.entity.dto.GoodsParamsDTO; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -22,7 +22,7 @@ public class GoodsVO extends Goods { private List categoryName; @ApiModelProperty(value = "商品参数") - private List goodsParamsList; + private List goodsParamsDTOList; @ApiModelProperty(value = "商品图片") private List goodsGalleryList; diff --git a/framework/src/main/java/cn/lili/modules/goods/mapper/GoodsParamsMapper.java b/framework/src/main/java/cn/lili/modules/goods/mapper/GoodsParamsMapper.java index 37d136f4..471c649c 100644 --- a/framework/src/main/java/cn/lili/modules/goods/mapper/GoodsParamsMapper.java +++ b/framework/src/main/java/cn/lili/modules/goods/mapper/GoodsParamsMapper.java @@ -1,7 +1,7 @@ package cn.lili.modules.goods.mapper; -import cn.lili.modules.goods.entity.dos.GoodsParams; -import cn.lili.modules.goods.entity.vos.GoodsParamsVO; +import cn.lili.modules.goods.entity.dto.GoodsParamsDTO; +import cn.lili.modules.goods.entity.vos.GoodsParamsDTOVO; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Select; @@ -14,9 +14,9 @@ import java.util.List; * @author pikachu * @date 2020-02-18 15:18:56 */ -public interface GoodsParamsMapper extends BaseMapper { +public interface GoodsParamsMapper extends BaseMapper { @Select("select p.*,gp.param_value,p.group_id from li_parameters p left join li_goods_params gp on p.id=gp.param_id and gp.goods_id = #{goodsId} where p.category_id = #{categoryId} order by sort") - List paramList(String goodsId, String categoryId); + List paramList(String goodsId, String categoryId); } \ No newline at end of file diff --git a/framework/src/main/java/cn/lili/modules/goods/service/GoodsParamsService.java b/framework/src/main/java/cn/lili/modules/goods/service/GoodsParamsService.java deleted file mode 100644 index bd8195fc..00000000 --- a/framework/src/main/java/cn/lili/modules/goods/service/GoodsParamsService.java +++ /dev/null @@ -1,76 +0,0 @@ -package cn.lili.modules.goods.service; - -import cn.lili.modules.goods.entity.dos.GoodsParams; -import cn.lili.modules.goods.entity.vos.GoodsParamsGroupVO; -import cn.lili.modules.goods.entity.vos.GoodsParamsVO; -import com.baomidou.mybatisplus.extension.service.IService; - -import java.util.List; - - -/** - * 商品关联参数业务层 - * - * @author pikachu - * @date 2020-03-13 16:18:56 - */ -public interface GoodsParamsService extends IService { - - /** - * 添加商品参数 - * @param paramList 参数列表 - * @param goodsId 商品ID - */ - void addParams(List paramList, String goodsId); - - /** - * 更新商品参数是否索引 - * - * @param paramId 参数id - * @param isIndex 是否索引 - */ - void updateParametersIsIndex(String paramId, Integer isIndex); - - /** - * 根据参数id删除已经设置的商品参数 - * - * @param paramId 参数id - */ - void deleteByParamId(String paramId); - - /** - * 获取商品关联参数 - * - * @param goodsId 商品ID - * @return 商品关联参数 - */ - List getGoodsParamsByGoodsId(String goodsId); - - /** - * 添加商品参数 - * - * @param goodsParamsVO 商品参数 - * @return 添加是否成功 - */ - boolean addParams(GoodsParamsVO goodsParamsVO); - - /** - * 根据分类id查询绑定参数信息 - * - * @param categoryId 分类id - * @param goodsId 商品id - * @return 分类id - */ - List paramList(String categoryId, String goodsId); - - /** - * 查询商品参数信息 - * - * @param goodsId 商品id - * @param categoryId 分了id - * @return 商品参数信息 - */ - List queryGoodsParams(String goodsId, String categoryId); - - -} \ No newline at end of file diff --git a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/CategoryServiceImpl.java b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/CategoryServiceImpl.java index 3c46db2b..6f350d1c 100644 --- a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/CategoryServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/CategoryServiceImpl.java @@ -8,7 +8,7 @@ import cn.lili.modules.goods.entity.dos.Category; import cn.lili.modules.goods.entity.dos.CategoryParameterGroup; import cn.lili.modules.goods.entity.vos.CategoryVO; import cn.lili.modules.goods.entity.vos.GoodsParamsGroupVO; -import cn.lili.modules.goods.entity.vos.GoodsParamsVO; +import cn.lili.modules.goods.entity.vos.GoodsParamsDTOVO; import cn.lili.modules.goods.mapper.CategoryMapper; import cn.lili.modules.goods.service.CategoryService; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; @@ -255,13 +255,13 @@ public class CategoryServiceImpl extends ServiceImpl i * @param paramList 参数列表 * @return 拼装后的返回值 */ - private List convertParamList(List groupList, List paramList) { - Map> map = new HashMap<>(16); - for (GoodsParamsVO param : paramList) { + private List convertParamList(List groupList, List paramList) { + Map> map = new HashMap<>(16); + for (GoodsParamsDTOVO param : paramList) { if (map.get(param.getGroupId()) != null) { map.get(param.getGroupId()).add(param); } else { - List list = new ArrayList<>(); + List list = new ArrayList<>(); list.add(param); map.put(param.getGroupId(), list); } diff --git a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/DraftGoodsServiceImpl.java b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/DraftGoodsServiceImpl.java index ca55c272..25292b88 100644 --- a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/DraftGoodsServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/DraftGoodsServiceImpl.java @@ -8,6 +8,7 @@ import cn.lili.common.utils.StringUtils; import cn.lili.modules.goods.entity.dos.*; import cn.lili.modules.goods.entity.dto.DraftGoodsDTO; import cn.lili.modules.goods.entity.dto.DraftGoodsSearchParams; +import cn.lili.modules.goods.entity.dto.GoodsParamsDTO; import cn.lili.modules.goods.entity.vos.DraftGoodsVO; import cn.lili.modules.goods.mapper.DraftGoodsMapper; import cn.lili.modules.goods.service.CategoryService; @@ -45,7 +46,7 @@ public class DraftGoodsServiceImpl extends ServiceImpl list = JSONUtil.toList(jsonArray, GoodsSku.class); diff --git a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsParamsServiceImpl.java b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsParamsServiceImpl.java deleted file mode 100644 index 9c91b756..00000000 --- a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsParamsServiceImpl.java +++ /dev/null @@ -1,143 +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.vos.GoodsParamsGroupVO; -import cn.lili.modules.goods.entity.vos.GoodsParamsVO; -import cn.lili.modules.goods.mapper.GoodsParamsMapper; -import cn.lili.modules.goods.service.CategoryParameterGroupService; -import cn.lili.modules.goods.service.GoodsParamsService; -import cn.lili.modules.goods.service.ParametersService; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - - -/** - * 商品关联参数接口实现 - * - * @author pikachu - * @version v1.0 - * @since v1.0 - * 2020-02-23 15:18:56 - */ -@Service -@Transactional -public class GoodsParamsServiceImpl extends ServiceImpl implements GoodsParamsService { - //分类-参数绑定 - @Autowired - private CategoryParameterGroupService categoryParameterGroupService; - - - @Override - public void addParams(List paramList, String goodsId) { - //先删除现有商品参数 - this.remove(new UpdateWrapper().eq("goods_id", goodsId)); - //循环添加参数 - if (paramList != null) { - for (GoodsParams param : paramList) { - GoodsParams goodsParams = new GoodsParams(); - goodsParams.setGoodsId(goodsId); - goodsParams.setParamName(param.getParamName()); - goodsParams.setParamValue(param.getParamValue()); - goodsParams.setIsIndex(param.getIsIndex()); - goodsParams.setParamId(param.getId()); - this.save(goodsParams); - } - } - } - - /** - * 更新商品参数是否索引 - * - * @param paramId 参数id - * @param isIndex 是否索引 - */ - @Override - public void updateParametersIsIndex(String paramId, Integer isIndex) { - LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper<>(); - updateWrapper.eq(GoodsParams::getParamId, paramId); - updateWrapper.set(GoodsParams::getIsIndex, isIndex); - this.update(updateWrapper); - } - - /** - * 根据参数id删除已经设置的商品参数 - * - * @param paramId 参数id - */ - @Override - public void deleteByParamId(String paramId) { - this.remove(new QueryWrapper().eq("param_id", paramId)); - } - - @Override - public List getGoodsParamsByGoodsId(String goodsId) { - return this.list(new LambdaQueryWrapper().eq(GoodsParams::getGoodsId, goodsId)); - } - - /** - * 添加商品参数 - * - * @param goodsParamsVO 商品参数 - * @return 添加是否成功 - */ - @Override - public boolean addParams(GoodsParamsVO goodsParamsVO) { - return this.save(goodsParamsVO); - } - - @Override - public List paramList(String goodsId, String categoryId) { - return this.baseMapper.paramList(goodsId, categoryId); - } - - @Override - public List queryGoodsParams(String categoryId, String goodsId) { - //查询分类关联参数组 - List groupList = categoryParameterGroupService.getCategoryGroup(categoryId); - //查询商品参数 - List paramList = this.paramList(goodsId, categoryId); - //拼装数据返回 - return this.convertParamList(groupList, paramList); - } - - - /** - * 拼装返回值 - * - * @param paramList - * @return - */ - private List convertParamList(List groupList, List paramList) { - Map> map = new HashMap<>(16); - for (GoodsParamsVO param : paramList) { - if (map.get(param.getGroupId()) != null) { - map.get(param.getGroupId()).add(param); - } else { - List list = new ArrayList<>(); - list.add(param); - map.put(param.getGroupId(), list); - } - } - List resList = new ArrayList<>(); - for (CategoryParameterGroup group : groupList) { - GoodsParamsGroupVO list = new GoodsParamsGroupVO(); - list.setGroupName(group.getGroupName()); - list.setGroupId(group.getId()); - list.setParams(map.get(group.getId())); - resList.add(list); - } - return resList; - } -} \ No newline at end of file diff --git a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsServiceImpl.java b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsServiceImpl.java index 29593f34..b93dbeca 100644 --- a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsServiceImpl.java @@ -17,6 +17,7 @@ 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.dto.GoodsOperationDTO; +import cn.lili.modules.goods.entity.dto.GoodsParamsDTO; import cn.lili.modules.goods.entity.dto.GoodsSearchParams; import cn.lili.modules.goods.entity.enums.GoodsAuthEnum; import cn.lili.modules.goods.entity.enums.GoodsStatusEnum; @@ -59,9 +60,7 @@ import java.util.List; @Transactional public class GoodsServiceImpl extends ServiceImpl implements GoodsService { - //商品属性 - @Autowired - private GoodsParamsService goodsParamsService; + //分类 @Autowired private CategoryService categoryService; @@ -107,12 +106,12 @@ public class GoodsServiceImpl extends ServiceImpl implements this.checkGoods(goods); //向goods加入图片 this.setGoodsGalleryParam(goodsOperationDTO.getGoodsGalleryList().get(0), goods); + //添加商品参数 + if (goodsOperationDTO.getGoodsParamsDTOList() != null && !goodsOperationDTO.getGoodsParamsDTOList().isEmpty()) { + goods.setParams(JSONUtil.toJsonStr(goodsOperationDTO.getGoodsParamsDTOList())); + } //添加商品 this.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 +129,12 @@ public class GoodsServiceImpl extends ServiceImpl implements this.checkGoods(goods); //向goods加入图片 this.setGoodsGalleryParam(goodsOperationDTO.getGoodsGalleryList().get(0), goods); + //添加商品参数 + if (goodsOperationDTO.getGoodsParamsDTOList() != null && !goodsOperationDTO.getGoodsParamsDTOList().isEmpty()) { + goods.setParams(JSONUtil.toJsonStr(goodsOperationDTO.getGoodsParamsDTOList())); + } //修改商品 this.updateById(goods); - //添加商品参数 - if (goodsOperationDTO.getGoodsParamsList() != null && !goodsOperationDTO.getGoodsParamsList().isEmpty()) { - this.goodsParamsService.addParams(goodsOperationDTO.getGoodsParamsList(), goods.getId()); - } //修改商品sku信息 this.goodsSkuService.update(goodsOperationDTO.getSkuList(), goods, goodsOperationDTO.getRegeneratorSkuFlag()); //添加相册 @@ -180,7 +179,10 @@ public class GoodsServiceImpl extends ServiceImpl implements } goodsVO.setCategoryName(categoryName); - goodsVO.setGoodsParamsList(goodsParamsService.getGoodsParamsByGoodsId(goodsId)); + //参数非空则填写参数 + if (StringUtils.isNotEmpty(goods.getParams())) { + goodsVO.setGoodsParamsDTOList(JSONUtil.toList(goods.getParams(), GoodsParamsDTO.class)); + } return goodsVO; } diff --git a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsSkuServiceImpl.java b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsSkuServiceImpl.java index 3f7419b1..adfcb2c9 100644 --- a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsSkuServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsSkuServiceImpl.java @@ -14,7 +14,7 @@ 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; @@ -204,7 +204,7 @@ public class GoodsSkuServiceImpl extends ServiceImpl i //获取当前商品的索引信息 EsGoodsIndex goodsIndex = goodsIndexService.findById(skuId); if (goodsIndex == null) { - goodsIndex = goodsIndexService.resetEsGoodsIndex(goodsSku, goodsVO.getGoodsParamsList()); + goodsIndex = goodsIndexService.resetEsGoodsIndex(goodsSku, goodsVO.getGoodsParamsDTOList()); } //商品规格 GoodsSkuVO goodsSkuDetail = this.getGoodsSkuVO(goodsSku); @@ -458,8 +458,8 @@ public class GoodsSkuServiceImpl extends ServiceImpl i EsGoodsIndex esGoodsOld = goodsIndexService.findById(goodsSku.getId()); EsGoodsIndex goodsIndex = new EsGoodsIndex(goodsSku); if (goods.getParams() != null && !goods.getParams().isEmpty()) { - List goodsParams = JSONUtil.toList(goods.getParams(), GoodsParams.class); - goodsIndex = new EsGoodsIndex(goodsSku, goodsParams); + List goodsParamDTOS = JSONUtil.toList(goods.getParams(), GoodsParamsDTO.class); + goodsIndex = new EsGoodsIndex(goodsSku, goodsParamDTOS); } //如果商品库存不为0,并且es中有数据 if (goodsSku.getQuantity() > 0 && esGoodsOld == null) { diff --git a/framework/src/main/java/cn/lili/modules/order/cart/render/TradeBuilder.java b/framework/src/main/java/cn/lili/modules/order/cart/render/TradeBuilder.java index d51ddd1c..9a69a2a7 100644 --- a/framework/src/main/java/cn/lili/modules/order/cart/render/TradeBuilder.java +++ b/framework/src/main/java/cn/lili/modules/order/cart/render/TradeBuilder.java @@ -98,6 +98,8 @@ public class TradeBuilder { log.error("购物车{}渲染异常:", cartRenderSteps.get(index).getClass(), e); } } + + //购物车信息接受 List cartVOList = new ArrayList<>(); //循环购物车信息 @@ -113,7 +115,7 @@ public class TradeBuilder { /** * 创建一笔交易 * - * @param checkedWay 购物车类型 + * @param checkedWay 购物车类型 * @return 交易信息 */ public Trade createTrade(CartTypeEnum checkedWay) { diff --git a/framework/src/main/java/cn/lili/modules/order/cart/render/impl/SkuFreightRender.java b/framework/src/main/java/cn/lili/modules/order/cart/render/impl/SkuFreightRender.java index 776f797b..5f71e10f 100644 --- a/framework/src/main/java/cn/lili/modules/order/cart/render/impl/SkuFreightRender.java +++ b/framework/src/main/java/cn/lili/modules/order/cart/render/impl/SkuFreightRender.java @@ -40,7 +40,7 @@ public class SkuFreightRender implements CartRenderStep { MemberAddress memberAddress = tradeDTO.getMemberAddress(); //如果收货地址为空,则抛出异常 if (memberAddress == null) { - throw new ServiceException(ResultCode.MEMBER_ADDRESS_NOT_EXIST); + return; } //循环渲染购物车商品运费价格 forSku: diff --git a/framework/src/main/java/cn/lili/modules/order/cart/service/CartServiceImpl.java b/framework/src/main/java/cn/lili/modules/order/cart/service/CartServiceImpl.java index 4ccfd098..41fd0be2 100644 --- a/framework/src/main/java/cn/lili/modules/order/cart/service/CartServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/order/cart/service/CartServiceImpl.java @@ -360,17 +360,17 @@ public class CartServiceImpl implements CartService { private GoodsSku checkGoods(String skuId, Integer num) { GoodsSku dataSku = this.goodsSkuService.getGoodsSkuByIdFromCache(skuId); if (dataSku == null) { - throw new ServiceException("商品已失效,请重新选购!"); + throw new ServiceException(ResultCode.GOODS_NOT_EXIST); } if (!GoodsAuthEnum.PASS.name().equals(dataSku.getIsAuth()) || !GoodsStatusEnum.UPPER.name().equals(dataSku.getMarketEnable())) { - throw new ServiceException("商品已下架,请重新选购!"); + throw new ServiceException(ResultCode.GOODS_NOT_EXIST); } //读取sku的可用库存 Integer enableQuantity = goodsSkuService.getStock(skuId); //如果sku的可用库存小于等于0或者小于用户购买的数量,则不允许购买 if (enableQuantity <= 0 || enableQuantity < num) { - throw new ServiceException("商品库存已不足,请选购其他商品。"); + throw new ServiceException(ResultCode.GOODS_SKU_QUANTITY_NOT_ENOUGH); } return dataSku; } @@ -459,7 +459,7 @@ public class CartServiceImpl implements CartService { @Override public Long getCartNum(Boolean checked) { //构建购物车 - TradeDTO tradeDTO = this.getCheckedTradeDTO(CartTypeEnum.CART); + TradeDTO tradeDTO = this.getAllTradeDTO(); //过滤sku列表 List collect = tradeDTO.getSkuList().stream().filter(i -> Boolean.FALSE.equals(i.getInvalid())).collect(Collectors.toList()); long count = 0L; diff --git a/framework/src/main/java/cn/lili/modules/order/order/service/OrderComplaintService.java b/framework/src/main/java/cn/lili/modules/order/order/service/OrderComplaintService.java index 4d742153..37eee01b 100644 --- a/framework/src/main/java/cn/lili/modules/order/order/service/OrderComplaintService.java +++ b/framework/src/main/java/cn/lili/modules/order/order/service/OrderComplaintService.java @@ -68,11 +68,11 @@ public interface OrderComplaintService extends IService { OrderComplaint updateOrderComplainByStatus(OrderComplaintOperationParams operationParam); /** - * 获取新投诉数量 + * 待处理投诉数量 * - * @return 新投诉 + * @return 待处理投诉数量 */ - Integer newComplainNum(); + Integer waitComplainNum(); /** * 取消交易投诉 diff --git a/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/OrderComplaintServiceImpl.java b/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/OrderComplaintServiceImpl.java index ae260d65..b0a198aa 100644 --- a/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/OrderComplaintServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/OrderComplaintServiceImpl.java @@ -198,9 +198,9 @@ public class OrderComplaintServiceImpl extends ServiceImpl implements @OrderLogPoint(description = "'订单['+#orderSn+']取消,原因为:'+#reason", orderSn = "#orderSn") public Order cancel(String orderSn, String reason) { Order order = OperationalJudgment.judgment(this.getBySn(orderSn)); - if (order.getOrderPromotionType().equals(OrderPromotionTypeEnum.PINTUAN.name()) && !order.getOrderStatus().equals(OrderStatusEnum.UNDELIVERED.name())) { - throw new ServiceException("未成团订单不可取消"); + //如果订单促销类型不为空&&订单是拼团订单,并且订单未成团,则抛出异常 + if (StringUtils.isNotEmpty(order.getOrderPromotionType()) + && order.getOrderPromotionType().equals(OrderPromotionTypeEnum.PINTUAN.name()) + && !order.getOrderStatus().equals(OrderStatusEnum.UNDELIVERED.name())) { + throw new ServiceException(ResultCode.ORDER_CAN_NOT_CANCEL); } if (CharSequenceUtil.equalsAny(order.getOrderStatus(), OrderStatusEnum.UNDELIVERED.name(), @@ -217,7 +220,7 @@ public class OrderServiceImpl extends ServiceImpl implements orderStatusMessage(order); return order; } else { - throw new ServiceException("当前订单状态不可取消"); + throw new ServiceException(ResultCode.ORDER_CAN_NOT_CANCEL); } } diff --git a/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/TradeServiceImpl.java b/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/TradeServiceImpl.java index b4e49d35..ed5d50b3 100644 --- a/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/TradeServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/TradeServiceImpl.java @@ -8,6 +8,7 @@ import cn.lili.common.rocketmq.RocketmqSendCallbackBuilder; import cn.lili.common.rocketmq.tags.MqOrderTagsEnum; import cn.lili.config.rocketmq.RocketmqCustomProperties; import cn.lili.modules.member.entity.dos.Member; +import cn.lili.modules.member.entity.dos.MemberAddress; import cn.lili.modules.member.service.MemberService; import cn.lili.modules.order.cart.entity.dto.MemberCouponDTO; import cn.lili.modules.order.cart.entity.dto.TradeDTO; @@ -68,6 +69,11 @@ public class TradeServiceImpl extends ServiceImpl implements @Override @Transactional(rollbackFor = Exception.class) public Trade createTrade(TradeDTO tradeDTO) { + + //创建订单预校验 + createTradeCheck(tradeDTO); + + Trade trade = new Trade(tradeDTO); String key = CachePrefix.TRADE.getPrefix() + trade.getSn(); //积分预处理 @@ -87,6 +93,31 @@ public class TradeServiceImpl extends ServiceImpl implements return trade; } + /** + * 创建订单最后一步校验 + * + * @param tradeDTO + */ + private void createTradeCheck(TradeDTO tradeDTO) { + + //创建订单如果没有收获地址, + MemberAddress memberAddress = tradeDTO.getMemberAddress(); + if (memberAddress == null) { + throw new ServiceException(ResultCode.MEMBER_ADDRESS_NOT_EXIST); + } + + /** + * 订单配送区域校验 + */ + if (tradeDTO.getNotSupportFreight() != null && tradeDTO.getNotSupportFreight().size() > 0) { + StringBuilder stringBuilder = new StringBuilder("包含商品有-"); + tradeDTO.getNotSupportFreight().forEach(sku -> { + stringBuilder.append(sku.getGoodsSku().getGoodsName()); + }); + throw new ServiceException(ResultCode.ORDER_NOT_SUPPORT_DISTRIBUTION, stringBuilder.toString()); + } + } + @Override public Trade getBySn(String sn) { LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); diff --git a/framework/src/main/java/cn/lili/modules/payment/kit/params/impl/OrderCashier.java b/framework/src/main/java/cn/lili/modules/payment/kit/params/impl/OrderCashier.java index d99ef09b..dc0bbc56 100644 --- a/framework/src/main/java/cn/lili/modules/payment/kit/params/impl/OrderCashier.java +++ b/framework/src/main/java/cn/lili/modules/payment/kit/params/impl/OrderCashier.java @@ -9,15 +9,14 @@ import cn.lili.modules.order.order.entity.enums.OrderStatusEnum; import cn.lili.modules.order.order.entity.enums.PayStatusEnum; import cn.lili.modules.order.order.entity.vo.OrderDetailVO; import cn.lili.modules.order.order.service.OrderService; -import cn.lili.modules.payment.kit.dto.PaymentSuccessParams; import cn.lili.modules.payment.kit.dto.PayParam; +import cn.lili.modules.payment.kit.dto.PaymentSuccessParams; import cn.lili.modules.payment.kit.enums.CashierEnum; import cn.lili.modules.payment.kit.params.CashierExecute; import cn.lili.modules.payment.kit.params.dto.CashierParam; import cn.lili.modules.system.entity.dto.BaseSetting; import cn.lili.modules.system.entity.enums.SettingEnum; import cn.lili.modules.system.service.SettingService; -import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -106,7 +105,7 @@ public class OrderCashier implements CashierExecute { if (payParam.getOrderType().equals(CashierEnum.ORDER.name())) { Order order = orderService.getBySn(payParam.getSn()); if (order != null) { - return order.getPayStatus().equals(PayStatusEnum.PAID.name()); + return PayStatusEnum.PAID.name().equals(order.getPayStatus()); } else { throw new ServiceException(ResultCode.PAY_NOT_EXIST_ORDER); } diff --git a/framework/src/main/java/cn/lili/modules/payment/kit/params/impl/TradeCashier.java b/framework/src/main/java/cn/lili/modules/payment/kit/params/impl/TradeCashier.java index 7bd4e62e..6a488b0e 100644 --- a/framework/src/main/java/cn/lili/modules/payment/kit/params/impl/TradeCashier.java +++ b/framework/src/main/java/cn/lili/modules/payment/kit/params/impl/TradeCashier.java @@ -113,7 +113,7 @@ public class TradeCashier implements CashierExecute { if (payParam.getOrderType().equals(CashierEnum.TRADE.name())) { Trade trade = tradeService.getBySn(payParam.getSn()); if (trade != null) { - return trade.equals(PayStatusEnum.PAID.name()); + return PayStatusEnum.PAID.name().equals(trade.getPayStatus()); } else { throw new ServiceException(ResultCode.PAY_NOT_EXIST_ORDER); } diff --git a/framework/src/main/java/cn/lili/modules/payment/kit/plugin/wechat/WechatPlugin.java b/framework/src/main/java/cn/lili/modules/payment/kit/plugin/wechat/WechatPlugin.java index 9732ffe3..5dc658ec 100644 --- a/framework/src/main/java/cn/lili/modules/payment/kit/plugin/wechat/WechatPlugin.java +++ b/framework/src/main/java/cn/lili/modules/payment/kit/plugin/wechat/WechatPlugin.java @@ -555,7 +555,7 @@ public class WechatPlugin implements Payment { if (refundLog != null) { refundLog.setIsRefund(true); refundLog.setReceivableNo(refundId); - refundLogService.save(refundLog); + refundLogService.saveOrUpdate(refundLog); } } catch (Exception e) { log.error("微信退款失败",e); diff --git a/framework/src/main/java/cn/lili/modules/search/entity/dos/EsGoodsIndex.java b/framework/src/main/java/cn/lili/modules/search/entity/dos/EsGoodsIndex.java index e8388bd1..e3b72a27 100644 --- a/framework/src/main/java/cn/lili/modules/search/entity/dos/EsGoodsIndex.java +++ b/framework/src/main/java/cn/lili/modules/search/entity/dos/EsGoodsIndex.java @@ -1,8 +1,8 @@ package cn.lili.modules.search.entity.dos; import cn.lili.common.elasticsearch.EsSuffix; -import cn.lili.modules.goods.entity.dos.GoodsParams; import cn.lili.modules.goods.entity.dos.GoodsSku; +import cn.lili.modules.goods.entity.dto.GoodsParamsDTO; import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -273,36 +273,37 @@ public class EsGoodsIndex implements Serializable { this.intro = sku.getIntro(); this.grade = sku.getGrade(); this.releaseTime = new Date(); -// if (CharSequenceUtil.isNotEmpty(sku.getSpecs())) { -// List attributes = new ArrayList<>(); -// JSONObject jsonObject = JSONUtil.parseObj(sku.getSpecs()); -// for (Map.Entry entry : jsonObject.entrySet()) { -// if (!entry.getKey().equals("images")) { -// EsGoodsAttribute attribute = new EsGoodsAttribute(); -// attribute.setType(1); -// attribute.setName(entry.getKey()); -// attribute.setValue(entry.getValue().toString()); -// attributes.add(attribute); -// } -// } -// this.attrList = attributes; -// } } } - public EsGoodsIndex(GoodsSku sku, List goodsParams) { + /** + * 参数索引增加 + * + * @param sku + * @param goodsParamDTOS + */ + public EsGoodsIndex(GoodsSku sku, List goodsParamDTOS) { this(sku); - if (goodsParams != null && !goodsParams.isEmpty()) { + //如果参数不为空 + if (goodsParamDTOS != null && !goodsParamDTOS.isEmpty()) { + //接受不了参数索引 List attributes = new ArrayList<>(); - for (GoodsParams goodsParam : goodsParams) { - EsGoodsAttribute attribute = new EsGoodsAttribute(); - if (goodsParam.getIsIndex() != null && goodsParam.getIsIndex() == 1) { - attribute.setType(1); - attribute.setName(goodsParam.getParamName()); - attribute.setValue(goodsParam.getParamValue()); - attributes.add(attribute); - } - } + //循环参数分组 + goodsParamDTOS.forEach(goodsParamGroup -> { + //循环分组的内容 + goodsParamGroup.getGoodsParamsItemDTOList().forEach(goodsParam -> { + //如果字段需要索引,则增加索引字段 + if (goodsParam.getIsIndex() != null && goodsParam.getIsIndex() == 1) { + EsGoodsAttribute attribute = new EsGoodsAttribute(); + attribute.setType(1); + attribute.setName(goodsParam.getParamName()); + attribute.setValue(goodsParam.getParamValue()); + attributes.add(attribute); + } + } + ); + + }); this.attrList = attributes; } } diff --git a/framework/src/main/java/cn/lili/modules/search/service/EsGoodsIndexService.java b/framework/src/main/java/cn/lili/modules/search/service/EsGoodsIndexService.java index fbc7bc17..1d696cb2 100644 --- a/framework/src/main/java/cn/lili/modules/search/service/EsGoodsIndexService.java +++ b/framework/src/main/java/cn/lili/modules/search/service/EsGoodsIndexService.java @@ -1,6 +1,6 @@ package cn.lili.modules.search.service; -import cn.lili.modules.goods.entity.dos.GoodsParams; +import cn.lili.modules.goods.entity.dto.GoodsParamsDTO; import cn.lili.modules.goods.entity.dos.GoodsSku; import cn.lili.modules.promotion.entity.dos.PromotionGoods; import cn.lili.modules.promotion.entity.dto.BasePromotion; @@ -146,8 +146,8 @@ public interface EsGoodsIndexService { * 重置当前商品索引 * * @param goodsSku 商品sku信息 - * @param goodsParams 商品参数 + * @param goodsParamDTOS 商品参数 * @return 商品索引 */ - EsGoodsIndex resetEsGoodsIndex(GoodsSku goodsSku, List goodsParams); + EsGoodsIndex resetEsGoodsIndex(GoodsSku goodsSku, List goodsParamDTOS); } diff --git a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java index e1240279..8ac541e4 100644 --- a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java @@ -8,7 +8,7 @@ import cn.hutool.extra.pinyin.PinyinUtil; import cn.lili.common.elasticsearch.BaseElasticsearchService; import cn.lili.common.elasticsearch.EsSuffix; import cn.lili.config.elasticsearch.ElasticsearchProperties; -import cn.lili.modules.goods.entity.dos.GoodsParams; +import cn.lili.modules.goods.entity.dto.GoodsParamsDTO; import cn.lili.modules.goods.entity.dos.GoodsSku; import cn.lili.modules.goods.entity.dos.GoodsWords; import cn.lili.modules.goods.entity.enums.GoodsWordsTypeEnum; @@ -368,12 +368,12 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements * 重置当前商品索引 * * @param goodsSku 商品sku信息 - * @param goodsParams 商品参数 + * @param goodsParamDTOS 商品参数 * @return 商品索引 */ @Override - public EsGoodsIndex resetEsGoodsIndex(GoodsSku goodsSku, List goodsParams) { - EsGoodsIndex index = new EsGoodsIndex(goodsSku, goodsParams); + public EsGoodsIndex resetEsGoodsIndex(GoodsSku goodsSku, List goodsParamDTOS) { + EsGoodsIndex index = new EsGoodsIndex(goodsSku, goodsParamDTOS); //获取活动信息 Map goodsCurrentPromotionMap = promotionService.getGoodsCurrentPromotionMap(index); //写入促销信息 diff --git a/framework/src/main/java/cn/lili/modules/statistics/model/vo/OrderOverviewVO.java b/framework/src/main/java/cn/lili/modules/statistics/model/vo/OrderOverviewVO.java index 5cd79262..fbb3bd5d 100644 --- a/framework/src/main/java/cn/lili/modules/statistics/model/vo/OrderOverviewVO.java +++ b/framework/src/main/java/cn/lili/modules/statistics/model/vo/OrderOverviewVO.java @@ -13,35 +13,35 @@ import lombok.Data; public class OrderOverviewVO { @ApiModelProperty(value = "UV人次") - private Integer uvNum; + private Integer uvNum = 0; //下单统计 @ApiModelProperty(value = "下单数量") - private Long orderNum; + private Long orderNum = 0L; @ApiModelProperty(value = "下单人数") - private Long orderMemberNum; + private Long orderMemberNum = 0L; @ApiModelProperty(value = "下单金额") - private Double orderAmount; + private Double orderAmount = 0D; //付款统计 @ApiModelProperty(value = "付款订单数量") - private Long paymentOrderNum; + private Long paymentOrderNum = 0L; @ApiModelProperty(value = "付款人数") - private Long paymentsNum; + private Long paymentsNum = 0L; @ApiModelProperty(value = "付款金额") - private Double paymentAmount; + private Double paymentAmount = 0D; //退单统计 @ApiModelProperty(value = "退单笔数") - private Long refundOrderNum; + private Long refundOrderNum = 0L; @ApiModelProperty(value = "退单金额") - private Double refundOrderPrice; + private Double refundOrderPrice = 0D; //转换率 @ApiModelProperty(value = "下单转换率") diff --git a/framework/src/main/java/cn/lili/modules/statistics/serviceimpl/IndexStatisticsServiceImpl.java b/framework/src/main/java/cn/lili/modules/statistics/serviceimpl/IndexStatisticsServiceImpl.java index b191d75a..65a113a5 100644 --- a/framework/src/main/java/cn/lili/modules/statistics/serviceimpl/IndexStatisticsServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/statistics/serviceimpl/IndexStatisticsServiceImpl.java @@ -121,7 +121,7 @@ public class IndexStatisticsServiceImpl implements IndexStatisticsService { //售后申请 indexNoticeVO.setRefund(afterSaleService.applyNum(null)); //投诉审核 - indexNoticeVO.setComplain(orderComplaintService.newComplainNum()); + indexNoticeVO.setComplain(orderComplaintService.waitComplainNum()); //分销员提现审核 indexNoticeVO.setDistributionCash(distributionCashService.newDistributionCash()); //待处理商家结算 @@ -218,8 +218,8 @@ public class IndexStatisticsServiceImpl implements IndexStatisticsService { storeIndexStatisticsVO.setReturnMoney(afterSaleService.applyNum(AfterSaleTypeEnum.RETURN_MONEY.name())); //待回复评价数量 storeIndexStatisticsVO.setMemberEvaluation(memberEvaluationService.getWaitReplyNum()); - //待处理交易投诉数量 - storeIndexStatisticsVO.setComplaint(orderComplaintService.newComplainNum()); + //待处理投诉数量 + storeIndexStatisticsVO.setComplaint(orderComplaintService.waitComplainNum()); //待上架商品数量 storeIndexStatisticsVO.setWaitUpper(goodsService.goodsNum(GoodsStatusEnum.DOWN, null)); diff --git a/framework/src/main/java/cn/lili/modules/statistics/serviceimpl/OrderStatisticsDataServiceImpl.java b/framework/src/main/java/cn/lili/modules/statistics/serviceimpl/OrderStatisticsDataServiceImpl.java index 200dd483..e581d414 100644 --- a/framework/src/main/java/cn/lili/modules/statistics/serviceimpl/OrderStatisticsDataServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/statistics/serviceimpl/OrderStatisticsDataServiceImpl.java @@ -22,7 +22,6 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import lombok.RequiredArgsConstructor; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -50,18 +49,15 @@ public class OrderStatisticsDataServiceImpl extends ServiceImpl queryWrapper = new LambdaQueryWrapper(); //queryWrapper.eq("flow_type", FlowTypeEnum.PAY.name()); - queryWrapper.eq(StringUtils.isNotEmpty(orderStatus),Order::getOrderStatus,orderStatus); + queryWrapper.eq(StringUtils.isNotEmpty(orderStatus), Order::getOrderStatus, orderStatus); queryWrapper.eq(StringUtils.equals(UserContext.getCurrentUser().getRole().name(), UserEnums.STORE.name()), Order::getStoreId, UserContext.getCurrentUser().getStoreId()); return orderService.count(queryWrapper); diff --git a/manager-api/src/main/java/cn/lili/controller/goods/CategoryParameterGroupManagerController.java b/manager-api/src/main/java/cn/lili/controller/goods/CategoryParameterGroupManagerController.java index ca7b820e..4658ab88 100644 --- a/manager-api/src/main/java/cn/lili/controller/goods/CategoryParameterGroupManagerController.java +++ b/manager-api/src/main/java/cn/lili/controller/goods/CategoryParameterGroupManagerController.java @@ -1,8 +1,8 @@ package cn.lili.controller.goods; import cn.lili.common.enums.ResultCode; -import cn.lili.common.exception.ServiceException; import cn.lili.common.enums.ResultUtil; +import cn.lili.common.exception.ServiceException; import cn.lili.common.vo.ResultMessage; import cn.lili.modules.goods.entity.dos.CategoryParameterGroup; import cn.lili.modules.goods.entity.dos.Parameters; @@ -14,6 +14,7 @@ import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import java.util.List; @@ -50,7 +51,7 @@ public class CategoryParameterGroupManagerController { @ApiOperation(value = "保存数据") @PostMapping - public ResultMessage saveOrUpdate(CategoryParameterGroup categoryParameterGroup) { + public ResultMessage saveOrUpdate(@Validated CategoryParameterGroup categoryParameterGroup) { if (categoryParameterGroupService.save(categoryParameterGroup)) { return ResultUtil.data(categoryParameterGroup); @@ -60,7 +61,7 @@ public class CategoryParameterGroupManagerController { @ApiOperation(value = "更新数据") @PutMapping - public ResultMessage update(CategoryParameterGroup categoryParameterGroup) { + public ResultMessage update(@Validated CategoryParameterGroup categoryParameterGroup) { if (categoryParameterGroupService.updateById(categoryParameterGroup)) { return ResultUtil.data(categoryParameterGroup); diff --git a/manager-api/src/main/java/cn/lili/controller/goods/GoodsParameterManagerController.java b/manager-api/src/main/java/cn/lili/controller/goods/GoodsParameterManagerController.java deleted file mode 100644 index eb9ec22a..00000000 --- a/manager-api/src/main/java/cn/lili/controller/goods/GoodsParameterManagerController.java +++ /dev/null @@ -1,43 +0,0 @@ -package cn.lili.controller.goods; - -import cn.lili.common.enums.ResultUtil; -import cn.lili.common.vo.ResultMessage; -import cn.lili.modules.goods.entity.vos.GoodsParamsGroupVO; -import cn.lili.modules.goods.service.GoodsParamsService; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiImplicitParam; -import io.swagger.annotations.ApiImplicitParams; -import io.swagger.annotations.ApiOperation; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import java.util.List; - -/** - * 管理端,商品关联参数管理接口 - * - * @author pikachu - * @date 2020-02-18 15:18:56 - */ -@RestController -@Api(tags = "管理端,商品关联参数管理接口") -@RequestMapping("/manager/goods/parameters") -public class GoodsParameterManagerController { - - @Autowired - private GoodsParamsService goodsParamsService; - - @ApiImplicitParams({ - @ApiImplicitParam(name = "goodsId", value = "商品ID", required = true, paramType = "path", dataType = "String"), - @ApiImplicitParam(name = "categoryId", value = "分类ID", required = true, paramType = "path", dataType = "String") - }) - @ApiOperation(value = "通过商品id和分类id查询参数信息") - @GetMapping(value = "/{goodsId}/{categoryId}") - public ResultMessage> getGoodsParameters(@PathVariable String goodsId, @PathVariable String categoryId) { - return ResultUtil.data(this.goodsParamsService.queryGoodsParams(goodsId, categoryId)); - } - -} diff --git a/manager-api/src/main/java/cn/lili/controller/goods/ParameterManagerController.java b/manager-api/src/main/java/cn/lili/controller/goods/ParameterManagerController.java index 8555e5c9..78d7a0e5 100644 --- a/manager-api/src/main/java/cn/lili/controller/goods/ParameterManagerController.java +++ b/manager-api/src/main/java/cn/lili/controller/goods/ParameterManagerController.java @@ -5,7 +5,6 @@ import cn.lili.common.enums.ResultUtil; import cn.lili.common.exception.ServiceException; import cn.lili.common.vo.ResultMessage; import cn.lili.modules.goods.entity.dos.Parameters; -import cn.lili.modules.goods.service.GoodsParamsService; import cn.lili.modules.goods.service.ParametersService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; @@ -29,8 +28,6 @@ public class ParameterManagerController { @Autowired private ParametersService parametersService; - @Autowired - private GoodsParamsService goodsParamsService; @ApiOperation(value = "添加参数") @PostMapping @@ -48,9 +45,6 @@ public class ParameterManagerController { public ResultMessage update(@Valid Parameters parameters) { if (parametersService.updateById(parameters)) { - if (parameters.getIsIndex() != null) { - goodsParamsService.updateParametersIsIndex(parameters.getId(), parameters.getIsIndex()); - } return ResultUtil.data(parameters); } throw new ServiceException(ResultCode.PARAMETER_UPDATE_ERROR); @@ -61,7 +55,6 @@ public class ParameterManagerController { @DeleteMapping(value = "/{id}") public ResultMessage delById(@PathVariable String id) { parametersService.removeById(id); - goodsParamsService.deleteByParamId(id); return ResultUtil.success(); } diff --git a/manager-api/src/main/java/cn/lili/controller/goods/SpecificationManagerController.java b/manager-api/src/main/java/cn/lili/controller/goods/SpecificationManagerController.java index e5c2dd7e..41b114d5 100644 --- a/manager-api/src/main/java/cn/lili/controller/goods/SpecificationManagerController.java +++ b/manager-api/src/main/java/cn/lili/controller/goods/SpecificationManagerController.java @@ -46,7 +46,6 @@ public class SpecificationManagerController { public Page page(String specName, PageVO page) { LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); lambdaQueryWrapper.like(StringUtils.isNotEmpty(specName), Specification::getSpecName, specName); - lambdaQueryWrapper.orderByDesc(Specification::getCreateTime); return specificationService.page(PageUtil.initPage(page), lambdaQueryWrapper); } diff --git a/manager-api/src/main/java/cn/lili/controller/other/ElasticsearchController.java b/manager-api/src/main/java/cn/lili/controller/other/ElasticsearchController.java index 5ab07dbd..083e91f0 100644 --- a/manager-api/src/main/java/cn/lili/controller/other/ElasticsearchController.java +++ b/manager-api/src/main/java/cn/lili/controller/other/ElasticsearchController.java @@ -2,9 +2,8 @@ package cn.lili.controller.other; import cn.hutool.json.JSONUtil; 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.dos.Parameters; import cn.lili.modules.goods.entity.enums.GoodsAuthEnum; import cn.lili.modules.goods.entity.enums.GoodsStatusEnum; import cn.lili.modules.goods.service.GoodsService; @@ -15,7 +14,6 @@ import cn.lili.modules.search.entity.dos.EsGoodsIndex; import cn.lili.modules.search.service.EsGoodsIndexService; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import io.swagger.annotations.Api; -import org.junit.jupiter.api.Assertions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.web.bind.annotation.GetMapping; @@ -73,8 +71,8 @@ public class ElasticsearchController { Goods goods = goodsService.getById(goodsId); EsGoodsIndex index = new EsGoodsIndex(goodsSku); if (goods.getParams() != null && !goods.getParams().isEmpty()) { - List goodsParams = JSONUtil.toList(goods.getParams(), GoodsParams.class); - index = new EsGoodsIndex(goodsSku, goodsParams); + List goodsParamDTOS = JSONUtil.toList(goods.getParams(), GoodsParamsDTO.class); + index = new EsGoodsIndex(goodsSku, goodsParamDTOS); } Map goodsCurrentPromotionMap = promotionService.getGoodsCurrentPromotionMap(index); index.setPromotionMap(goodsCurrentPromotionMap);