This commit is contained in:
lifenlong 2021-06-25 16:03:18 +08:00
commit 7dfbb164ae
44 changed files with 284 additions and 481 deletions

View File

@ -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)){
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("验证码错误");
}
}

View File

@ -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;

View File

@ -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, "当前订单状态不可取消"),
/**
* 支付
*/

View File

@ -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();

View File

@ -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();

View File

@ -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;
}

View File

@ -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)

View File

@ -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;

View File

@ -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;

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;

View File

@ -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 选择项")

View File

@ -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")

View File

@ -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;

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);

View File

@ -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<GoodsParamsMapper, GoodsParams> implements GoodsParamsService {
//分类-参数绑定
@Autowired
private CategoryParameterGroupService categoryParameterGroupService;
@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) {
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<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;
}
}

View File

@ -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<GoodsMapper, Goods> implements GoodsService {
//商品属性
@Autowired
private GoodsParamsService goodsParamsService;
//分类
@Autowired
private CategoryService categoryService;
@ -107,12 +106,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.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<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 +179,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;
}

View File

@ -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<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);
@ -458,8 +458,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) {

View File

@ -98,6 +98,8 @@ public class TradeBuilder {
log.error("购物车{}渲染异常:", cartRenderSteps.get(index).getClass(), e);
}
}
//购物车信息接受
List<CartVO> cartVOList = new ArrayList<>();
//循环购物车信息
@ -113,7 +115,7 @@ public class TradeBuilder {
/**
* 创建一笔交易
*
* @param checkedWay 购物车类型
* @param checkedWay 购物车类型
* @return 交易信息
*/
public Trade createTrade(CartTypeEnum checkedWay) {

View File

@ -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:

View File

@ -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;

View File

@ -68,11 +68,11 @@ public interface OrderComplaintService extends IService<OrderComplaint> {
OrderComplaint updateOrderComplainByStatus(OrderComplaintOperationParams operationParam);
/**
* 获取新投诉数量
* 待处理投诉数量
*
* @return 新投诉
* @return 待处理投诉数量
*/
Integer newComplainNum();
Integer waitComplainNum();
/**
* 取消交易投诉

View File

@ -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);

View File

@ -202,8 +202,11 @@ 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 (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<OrderMapper, Order> implements
orderStatusMessage(order);
return order;
} else {
throw new ServiceException("当前订单状态不可取消");
throw new ServiceException(ResultCode.ORDER_CAN_NOT_CANCEL);
}
}

View File

@ -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<TradeMapper, Trade> 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<TradeMapper, Trade> 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<Trade> queryWrapper = new LambdaQueryWrapper<>();

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);

View File

@ -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();
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;
}
}

View File

@ -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);
}

View File

@ -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);
//写入促销信息

View File

@ -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 = "下单转换率")

View File

@ -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));

View File

@ -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);

View File

@ -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<CategoryParameterGroup> saveOrUpdate(CategoryParameterGroup categoryParameterGroup) {
public ResultMessage<CategoryParameterGroup> saveOrUpdate(@Validated CategoryParameterGroup categoryParameterGroup) {
if (categoryParameterGroupService.save(categoryParameterGroup)) {
return ResultUtil.data(categoryParameterGroup);
@ -60,7 +61,7 @@ public class CategoryParameterGroupManagerController {
@ApiOperation(value = "更新数据")
@PutMapping
public ResultMessage<CategoryParameterGroup> update(CategoryParameterGroup categoryParameterGroup) {
public ResultMessage<CategoryParameterGroup> update(@Validated CategoryParameterGroup categoryParameterGroup) {
if (categoryParameterGroupService.updateById(categoryParameterGroup)) {
return ResultUtil.data(categoryParameterGroup);

View File

@ -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<List<GoodsParamsGroupVO>> getGoodsParameters(@PathVariable String goodsId, @PathVariable String categoryId) {
return ResultUtil.data(this.goodsParamsService.queryGoodsParams(goodsId, categoryId));
}
}

View File

@ -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<Parameters> 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<Object> delById(@PathVariable String id) {
parametersService.removeById(id);
goodsParamsService.deleteByParamId(id);
return ResultUtil.success();
}

View File

@ -46,7 +46,6 @@ public class SpecificationManagerController {
public Page<Specification> page(String specName, PageVO page) {
LambdaQueryWrapper<Specification> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.like(StringUtils.isNotEmpty(specName), Specification::getSpecName, specName);
lambdaQueryWrapper.orderByDesc(Specification::getCreateTime);
return specificationService.page(PageUtil.initPage(page), lambdaQueryWrapper);
}

View File

@ -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> goodsParams = JSONUtil.toList(goods.getParams(), GoodsParams.class);
index = new EsGoodsIndex(goodsSku, goodsParams);
List<GoodsParamsDTO> goodsParamDTOS = JSONUtil.toList(goods.getParams(), GoodsParamsDTO.class);
index = new EsGoodsIndex(goodsSku, goodsParamDTOS);
}
Map<String, Object> goodsCurrentPromotionMap = promotionService.getGoodsCurrentPromotionMap(index);
index.setPromotionMap(goodsCurrentPromotionMap);