提交 a59ef846 作者: xiaowang

新增:商品列表、排序、上下架、删除

上级 b4127ace
package com.mmc.pms.auth.dto;
import com.mmc.pms.model.other.dto.RoleInfoDTO;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
......@@ -17,15 +18,16 @@ import java.io.Serializable;
@AllArgsConstructor
@NoArgsConstructor
public class LoginSuccessDTO implements Serializable {
private static final long serialVersionUID = -1200834589953161925L;
private String token;
private Integer userAccountId;
private String accountNo;
private Integer portType;
private String uid;
private String phoneNum;
private String userName;
private String nickName;
private CompanyInfoVO companyInfoVO;
// private RoleInfoDTO roleInfo;
private static final long serialVersionUID = -1200834589953161925L;
private String token;
private Integer userAccountId;
private String accountNo;
private Integer portType;
private String uid;
private String phoneNum;
private String userName;
private String nickName;
private CompanyInfoVO companyInfoVO;
private RoleInfoDTO roleInfo;
private Integer appUserAccountId;
}
......@@ -3,11 +3,10 @@ package com.mmc.pms.controller.mall;
import com.mmc.pms.common.ResultBody;
import com.mmc.pms.controller.BaseController;
import com.mmc.pms.model.mall.MallGoodsVO;
import com.mmc.pms.model.sale.dto.SkuUnitDTO;
import com.mmc.pms.model.sale.qo.MallGoodsQO;
import com.mmc.pms.service.mall.MallGoodsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import io.swagger.annotations.*;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
......@@ -44,4 +43,41 @@ public class MallGoodsController extends BaseController {
public ResultBody editMallGoods(@RequestBody MallGoodsVO mallGoodsVO, HttpServletRequest request) {
return mallGoodsService.editMallGoods(mallGoodsVO, this.getUserLoginInfoFromRedis(request).getUserAccountId());
}
@ApiOperation(value = "单位信息")
@GetMapping("getSkuUnit")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = SkuUnitDTO.class)})
public ResultBody getSkuUnit() {
return mallGoodsService.getSkuUnit();
}
@ApiOperation(value = "商品列表-分页")
@PostMapping("listPageGoodsInfo")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = MallGoodsVO.class)})
public ResultBody<MallGoodsVO> listPageGoodsInfo(@ApiParam("商品查询条件QO") @RequestBody MallGoodsQO param, HttpServletRequest request) {
return ResultBody.success(mallGoodsService.listPageGoodsInfo(param, this.getUserLoginInfoFromRedis(request)));
}
@ApiOperation(value = "商品列表-排序")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = ResultBody.class)})
@GetMapping("exchange")
public ResultBody exchange(@ApiParam(value = "第一个商品id", required = true) @RequestParam(value = "firstId") Long firstId,
@ApiParam(value = "第二个商品id", required = true) @RequestParam(value = "secondId") Long secondId) {
return mallGoodsService.exchange(firstId, secondId);
}
@ApiOperation(value = "商品列表-上架或下架")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = ResultBody.class)})
@GetMapping("upOrDownShelf")
public ResultBody upOrDownShelf(@ApiParam(value = "商品id", required = true) @RequestParam(value = "id") Long id,
@ApiParam(value = "状态 0:下架 1: 上架", required = true) @RequestParam(value = "status") Integer status) {
return mallGoodsService.upOrDownShelf(id, status);
}
@ApiOperation(value = "商品列表-删除")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = ResultBody.class)})
@GetMapping("removeMallGoods")
public ResultBody removeMallGoods(@ApiParam(value = "商品id", required = true) @RequestParam(value = "id") Long id) {
return mallGoodsService.removeMallGoods(id);
}
}
package com.mmc.pms.dao.mall;
import com.mmc.pms.entity.SkuUnitDO;
import com.mmc.pms.entity.mall.GoodsSpecDO;
import com.mmc.pms.entity.mall.GoodsSpecValuesDO;
import com.mmc.pms.entity.mall.MallGoodsDO;
import com.mmc.pms.entity.mall.MallGoodsResourcesDO;
import com.mmc.pms.model.mall.MallGoodsVO;
import com.mmc.pms.model.sale.qo.MallGoodsQO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
......@@ -48,4 +50,15 @@ public interface MallGoodsDao {
void updateGoodsSpecValue(GoodsSpecValuesDO goodsSpecValuesDO);
List<SkuUnitDO> getSkuUnit();
int countListMallGoods(MallGoodsQO param);
List<MallGoodsDO> listMallGoods(MallGoodsQO param);
int updateMallGoodsSort(Long id, Integer sort);
void updateMallGoodsByShelf(Long id, Integer status);
void removeMallGoods(Long id);
}
package com.mmc.pms.entity.mall;
import com.mmc.pms.model.mall.GoodsResourcesVO;
import com.mmc.pms.model.mall.MallGoodsVO;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* 商品基本信息(MallGoodsDO)实体类
......@@ -72,6 +75,10 @@ public class MallGoodsDO implements Serializable {
private Integer deleted;
private String url;
private Integer type;
private Integer imgId;
public MallGoodsDO(MallGoodsVO mallGoodsVO) {
this.id = mallGoodsVO.getId();
this.tradeName = mallGoodsVO.getTradeName();
......@@ -90,5 +97,16 @@ public class MallGoodsDO implements Serializable {
.goodsLabel(goodsLabel).labelShow(labelShow).goodsDetails(goodsDetails).build();
}
public MallGoodsVO buildListMallGoodsVO() {
List<GoodsResourcesVO> resourcesList = new ArrayList<>();
GoodsResourcesVO goodsResourcesVO = new GoodsResourcesVO();
goodsResourcesVO.setId(imgId);
goodsResourcesVO.setUrl(url);
goodsResourcesVO.setType(type);
resourcesList.add(goodsResourcesVO);
return MallGoodsVO.builder().id(id).tradeName(tradeName).resourcesList(resourcesList)
.categoryPrimaryId(categoryPrimaryId).categorySubId(categorySubId)
.shelfStatus(shelfStatus).createTime(createTime).build();
}
}
......@@ -11,6 +11,7 @@ import lombok.NoArgsConstructor;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.Date;
import java.util.List;
/**
......@@ -63,4 +64,7 @@ public class MallGoodsVO {
@ApiModelProperty(value = "商品详情 富文本")
private String goodsDetails;
@ApiModelProperty(value = "创建时间 用作列表回显")
private Date createTime;
}
package com.mmc.pms.model.other.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
......@@ -10,40 +9,27 @@ import lombok.NoArgsConstructor;
import java.io.Serializable;
/**
* @Author small @Date 2023/5/25 9:57 @Version 1.0
* @Author small
* @Date 2023/7/10 16:03
* @Version 1.0
*/
@Builder
@Data
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(description = "角色信息DTO")
public class RoleInfoDTO implements Serializable {
private static final long serialVersionUID = -4791023169682602298L;
private static final long serialVersionUID = -4791023169682602298L;
@ApiModelProperty(value = "角色ID")
private Integer id;
@ApiModelProperty(value = "角色编号")
private String roleNo;
@ApiModelProperty(value = "角色名称/权限角色")
private String roleName;
@ApiModelProperty(value = "备注")
private String remark;
@ApiModelProperty(value = "账号名称/创建人")
private String userName;
@ApiModelProperty(value = "0不是超级管理员 1是超级管理员")
private Integer superAdmin;
@ApiModelProperty(value = "角色ID")
private Integer id;
@ApiModelProperty(value = "角色编号")
private String roleNo;
@ApiModelProperty(value = "角色名称")
private String roleName;
@ApiModelProperty(value = "是否为管理角色:0否 1是")
private Integer admin; // 是否为管理角色
@ApiModelProperty(value = "是否为运营角色:0否 1是")
private Integer operate;
@ApiModelProperty(value = "是否为系统角色:0否 1是")
private Integer system;
@ApiModelProperty(value = "是否为PMC发货角色:0否 1是")
private Integer pmc; // PMC发货角色
@ApiModelProperty(value = "是否可用:0否 1是")
private Integer roleStatus;
@ApiModelProperty(value = "备注")
private String remark;
}
......@@ -13,7 +13,6 @@ import javax.validation.constraints.NotNull;
/**
* @Author LW
*
* @date 2022/3/22 9:44 概要:商品列表查询QO
*/
@Builder
......@@ -21,39 +20,30 @@ import javax.validation.constraints.NotNull;
@AllArgsConstructor
@NoArgsConstructor
public class MallGoodsQO {
@ApiModelProperty(value = "商品名称", example = "商品名称")
private String goodsName;
@ApiModelProperty(value = "商品类型 0:销售 1:租赁", example = "0")
private Integer goodsType;
@ApiModelProperty(value = "开始时间", example = "2023-06-09 00:00:00")
private String startTime;
@ApiModelProperty(value = "结束时间", example = "2023-06-11 23:59:59")
private String endTime;
@ApiModelProperty(value = "状态 0:下架(仓库中)1:上架", example = "1")
private Integer status;
@ApiModelProperty(value = "目录id", example = "1")
private Integer directoryId;
@ApiModelProperty(value = "页码", required = true, example = "1")
@NotNull(
message = "页码不能为空",
groups = {Page.class, Freeze.class})
@Min(value = 1, groups = Page.class)
private Integer pageNo;
@ApiModelProperty(value = "每页显示数", required = true, example = "10")
@NotNull(
message = "每页显示数不能为空",
groups = {Page.class, Freeze.class})
@Min(value = 1, groups = Page.class)
private Integer pageSize;
public void buildCurrentPage() {
this.pageNo = (pageNo - 1) * pageSize;
}
@ApiModelProperty(value = "商品名称", example = "商品名称")
private String tradeName;
@ApiModelProperty(value = "商品一级分类", example = "1")
private Integer categoryPrimaryId;
@ApiModelProperty(value = "用户id", hidden = true)
private Integer userAccountId;
@ApiModelProperty(value = "页码", required = true, example = "1")
@NotNull(
message = "页码不能为空",
groups = {Page.class, Freeze.class})
@Min(value = 1, groups = Page.class)
private Integer pageNo;
@ApiModelProperty(value = "每页显示数", required = true, example = "10")
@NotNull(
message = "每页显示数不能为空",
groups = {Page.class, Freeze.class})
@Min(value = 1, groups = Page.class)
private Integer pageSize;
public void buildCurrentPage() {
this.pageNo = (pageNo - 1) * pageSize;
}
}
package com.mmc.pms.service.mall;
import com.mmc.pms.auth.dto.LoginSuccessDTO;
import com.mmc.pms.common.ResultBody;
import com.mmc.pms.model.mall.MallGoodsVO;
import com.mmc.pms.model.sale.qo.MallGoodsQO;
import com.mmc.pms.page.PageResult;
/**
* @Author LW
......@@ -13,4 +16,14 @@ public interface MallGoodsService {
ResultBody<MallGoodsVO> mallGoodsDetails(Long id);
ResultBody editMallGoods(MallGoodsVO mallGoodsVO, Integer userAccountId);
ResultBody getSkuUnit();
PageResult listPageGoodsInfo(MallGoodsQO param, LoginSuccessDTO loginSuccessDTO);
ResultBody exchange(Long firstId, Long secondId);
ResultBody upOrDownShelf(Long id, Integer status);
ResultBody removeMallGoods(Long id);
}
package com.mmc.pms.service.mall.impl;
import com.mmc.pms.auth.dto.LoginSuccessDTO;
import com.mmc.pms.common.ResultBody;
import com.mmc.pms.common.ResultEnum;
import com.mmc.pms.dao.mall.MallGoodsDao;
import com.mmc.pms.entity.SkuUnitDO;
import com.mmc.pms.entity.mall.GoodsSpecDO;
import com.mmc.pms.entity.mall.GoodsSpecValuesDO;
import com.mmc.pms.entity.mall.MallGoodsDO;
......@@ -11,6 +13,9 @@ import com.mmc.pms.model.mall.GoodsResourcesVO;
import com.mmc.pms.model.mall.GoodsSpecVO;
import com.mmc.pms.model.mall.GoodsSpecValuesVO;
import com.mmc.pms.model.mall.MallGoodsVO;
import com.mmc.pms.model.sale.dto.SkuUnitDTO;
import com.mmc.pms.model.sale.qo.MallGoodsQO;
import com.mmc.pms.page.PageResult;
import com.mmc.pms.service.mall.MallGoodsService;
import com.mmc.pms.util.CodeUtil;
import com.mmc.pms.util.SnowFlake;
......@@ -18,6 +23,7 @@ import com.mmc.pms.util.TDateUtil;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import javax.annotation.Resource;
import java.util.Date;
......@@ -186,4 +192,66 @@ public class MallGoodsServiceImpl implements MallGoodsService {
}
return ResultBody.success();
}
@Override
public ResultBody getSkuUnit() {
List<SkuUnitDO> skuUnitList = mallGoodsDao.getSkuUnit();
List<SkuUnitDTO> list =
skuUnitList.stream().map(SkuUnitDO::buildSkuUnitDTO).collect(Collectors.toList());
return ResultBody.success(list);
}
@Override
public PageResult listPageGoodsInfo(MallGoodsQO param, LoginSuccessDTO loginSuccessDTO) {
if (loginSuccessDTO.getRoleInfo().getSuperAdmin().equals(1)) {
// 超级管理员获取所有商品信息
return getMallGoodsInfo(param);
} else {
// 非超级管理员获取自家的商品信息
param.setUserAccountId(loginSuccessDTO.getUserAccountId());
return getMallGoodsInfo(param);
}
}
private PageResult getMallGoodsInfo(MallGoodsQO param) {
int count;
List<MallGoodsDO> mallGoodsList;
count = mallGoodsDao.countListMallGoods(param);
if (count == 0) {
return PageResult.buildPage(param.getPageNo(), param.getPageSize(), count);
}
Integer pageNo = param.getPageNo();
param.buildCurrentPage();
mallGoodsList = mallGoodsDao.listMallGoods(param);
List<MallGoodsVO> pageList = mallGoodsList.stream().map(MallGoodsDO::buildListMallGoodsVO).collect(Collectors.toList());
return PageResult.buildPage(pageNo, param.getPageSize(), count, pageList);
}
@Override
@Transactional(rollbackFor = Exception.class)
public ResultBody exchange(Long firstId, Long secondId) {
MallGoodsDO firstMallGoodsBaseInfo = mallGoodsDao.getMallGoodsBaseInfo(firstId);
MallGoodsDO secondMallGoodsBaseInfo = mallGoodsDao.getMallGoodsBaseInfo(secondId);
int updateCount1 = mallGoodsDao.updateMallGoodsSort(firstId, firstMallGoodsBaseInfo.getSort());
int updateCount2 = mallGoodsDao.updateMallGoodsSort(secondId, secondMallGoodsBaseInfo.getSort());
if (updateCount1 == updateCount2) {
return ResultBody.success();
} else {
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return ResultBody.error("排序失败");
}
}
@Override
public ResultBody upOrDownShelf(Long id, Integer status) {
mallGoodsDao.updateMallGoodsByShelf(id, status);
return ResultBody.success();
}
@Override
public ResultBody removeMallGoods(Long id) {
mallGoodsDao.removeMallGoods(id);
return ResultBody.success();
}
}
......@@ -85,6 +85,21 @@
channel_price =#{channelPrice}
where id = #{id}
</update>
<update id="updateMallGoodsSort">
update mall_goods
set sort = #{sort}
where id = #{id}
</update>
<update id="updateMallGoodsByShelf">
update mall_goods
set shelf_status = #{status}
where id = #{id}
</update>
<update id="removeMallGoods">
update mall_goods
set is_deleted = 1
where id = #{id}
</update>
<delete id="deleteMallGoodsResources">
delete
from mall_goods_resources
......@@ -174,4 +189,60 @@
</foreach>
</where>
</select>
<select id="getSkuUnit" resultType="com.mmc.pms.entity.SkuUnitDO">
SELECT id,
unit_name unitName,
create_time createTime
FROM sku_unit
WHERE is_deleted = 0
</select>
<select id="countListMallGoods" resultType="java.lang.Integer">
SELECT
count(*)
FROM
mall_goods
<where>
is_deleted = 0
<if test="tradeName != null and tradeName !=''">
AND (trade_name LIKE CONCAT('%',#{tradeName},'%'))
</if>
<if test="categoryPrimaryId != null">
and category_primary_id = #{categoryPrimaryId}
</if>
<if test="userAccountId != null">
and user_account_id = #{userAccountId}
</if>
</where>
</select>
<select id="listMallGoods" resultType="com.mmc.pms.entity.mall.MallGoodsDO">
SELECT
mg.id,
mg.trade_name,
mg.shelf_status,
mg.create_time,
mg.category_primary_id,
mg.category_sub_id,
img.id as imgId,
img.url,
img.type
FROM
mall_goods mg
INNER JOIN mall_goods_resources img ON mg.id = img.mall_goods_id
AND img.type = 0
<where>
mg.is_deleted = 0
<if test="tradeName != null and tradeName !=''">
AND (mg.trade_name LIKE CONCAT('%',#{tradeName},'%'))
</if>
<if test="categoryPrimaryId != null">
and mg.category_primary_id = #{categoryPrimaryId}
</if>
<if test="userAccountId != null">
and user_account_id = #{userAccountId}
</if>
</where>
ORDER BY
mg.shelf_status DESC , mg.sort DESC,mg.create_time DESC
limit #{pageNo},#{pageSize}
</select>
</mapper>
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论