提交 ec92b8f9 作者: xiaowang

功能:租赁商品详情

上级 067bb945
...@@ -14,10 +14,7 @@ import io.swagger.annotations.Api; ...@@ -14,10 +14,7 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses; import io.swagger.annotations.ApiResponses;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
...@@ -33,7 +30,7 @@ public class LeaseGoodsController extends BaseController { ...@@ -33,7 +30,7 @@ public class LeaseGoodsController extends BaseController {
@Resource @Resource
LeaseGoodsService leaseGoodsService; LeaseGoodsService leaseGoodsService;
@ApiOperation(value = "新增商城商品") @ApiOperation(value = "新增租赁商品")
@PostMapping("addLeaseGoods") @PostMapping("addLeaseGoods")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = ResultBody.class)}) @ApiResponses({@ApiResponse(code = 200, message = "OK", response = ResultBody.class)})
public ResultBody addLeaseGoods(@RequestBody LeaseGoodsVO leaseGoodsVO, HttpServletRequest request) { public ResultBody addLeaseGoods(@RequestBody LeaseGoodsVO leaseGoodsVO, HttpServletRequest request) {
...@@ -47,4 +44,11 @@ public class LeaseGoodsController extends BaseController { ...@@ -47,4 +44,11 @@ public class LeaseGoodsController extends BaseController {
public ResultBody getLeaseTermInfo() { public ResultBody getLeaseTermInfo() {
return leaseGoodsService.getLeaseTermInfo(); return leaseGoodsService.getLeaseTermInfo();
} }
@ApiOperation(value = "租赁商品详情")
@PostMapping("leaseGoodsDetails")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = ResultBody.class)})
public ResultBody leaseGoodsDetails(@RequestParam Integer id) {
return leaseGoodsService.leaseGoodsDetails(id);
}
} }
package com.mmc.pms.dao.lease; package com.mmc.pms.dao.lease;
import com.mmc.pms.entity.lease.LeaseGoodsDO; import com.mmc.pms.entity.lease.*;
import com.mmc.pms.entity.lease.LeasePartsListDO;
import com.mmc.pms.entity.lease.LeasePriceStockDO;
import com.mmc.pms.entity.lease.LeaseTermInfoDO;
import com.mmc.pms.entity.mall.MallGoodsResourcesDO; import com.mmc.pms.entity.mall.MallGoodsResourcesDO;
import com.mmc.pms.entity.mall.SpecAttrDO; import com.mmc.pms.entity.mall.SpecAttrDO;
import com.mmc.pms.entity.mall.SpecAttrValueDO; import com.mmc.pms.entity.mall.SpecAttrValueDO;
...@@ -37,4 +34,14 @@ public interface LeaseGoodsDao { ...@@ -37,4 +34,14 @@ public interface LeaseGoodsDao {
void batchInsertLeaseParts(List<LeasePartsListDO> list); void batchInsertLeaseParts(List<LeasePartsListDO> list);
List<LeaseTermInfoDO> getLeaseTermInfo(); List<LeaseTermInfoDO> getLeaseTermInfo();
LeaseGoodsDO getLeaseGoodsBaseInfo(Integer id);
List<LeaseGoodsResourcesDO> getLeaseGoodsResources(Integer id);
List<LeaseSpecAttrDO> listSpecAttr(Integer id);
List<LeasePriceStockDO> listPriceStock(Integer id);
List<LeasePartsListDO> listLeasePartsListDO(Integer id);
} }
...@@ -110,5 +110,15 @@ public class LeaseGoodsDO implements Serializable { ...@@ -110,5 +110,15 @@ public class LeaseGoodsDO implements Serializable {
this.logisticsCompany = leaseGoodsVO.getLogisticsCompany(); this.logisticsCompany = leaseGoodsVO.getLogisticsCompany();
this.modeOfDelivery = leaseGoodsVO.getModeOfDelivery(); this.modeOfDelivery = leaseGoodsVO.getModeOfDelivery();
} }
public LeaseGoodsVO buildLeaseGoodsVO() {
return LeaseGoodsVO.builder().id(id).tradeName(tradeName)
.sellingPoint(sellingPoint).level(level).shelfStatus(shelfStatus)
.productTypeId(productTypeId).brandInfoId(brandInfoId).deviceModeId(deviceModeId)
.productParam(productParam).productDetails(productDetails).minLeaseTerm(minLeaseTerm)
.maxLeaseTerm(maxLeaseTerm).shipAddress(shipAddress).returnAddress(returnAddress)
.logisticsCompany(logisticsCompany).modeOfDelivery(modeOfDelivery).createTime(createTime)
.userAccountId(userAccountId).build();
}
} }
package com.mmc.pms.entity.lease; package com.mmc.pms.entity.lease;
import com.mmc.pms.model.mall.GoodsResourcesVO;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
...@@ -34,6 +35,9 @@ public class LeaseGoodsResourcesDO implements Serializable { ...@@ -34,6 +35,9 @@ public class LeaseGoodsResourcesDO implements Serializable {
private Date createTime; private Date createTime;
private Date updateTime; private Date updateTime;
public GoodsResourcesVO buildGoodsResourcesVO() {
return GoodsResourcesVO.builder().id(id).url(url).type(type).build();
}
} }
...@@ -36,5 +36,9 @@ public class LeasePartsListDO implements Serializable { ...@@ -36,5 +36,9 @@ public class LeasePartsListDO implements Serializable {
this.name = param.getName(); this.name = param.getName();
this.price = param.getPrice(); this.price = param.getPrice();
} }
public LeasePartsListVO buildLeasePartsListVO() {
return LeasePartsListVO.builder().id(id).name(name).number(number).price(price).build();
}
} }
...@@ -90,5 +90,13 @@ public class LeasePriceStockDO implements Serializable { ...@@ -90,5 +90,13 @@ public class LeasePriceStockDO implements Serializable {
this.showPrice = param.getShowPrice(); this.showPrice = param.getShowPrice();
this.stockOut = param.getStockOut(); this.stockOut = param.getStockOut();
} }
public LeasePriceStockVO buildPriceStockVO() {
return LeasePriceStockVO.builder().id(id).productSpec(productSpec)
.cashPledge(cashPledge).threeDaysRental(threeDaysRental)
.sevenDaysRental(sevenDaysRental).thirtyDaysRental(thirtyDaysRental)
.ninetyDaysRental(ninetyDaysRental).maxDaysRental(maxDaysRental)
.showPrice(showPrice).skuImage(skuImage).stock(stock).stockOut(stockOut).build();
}
} }
package com.mmc.pms.entity.lease; package com.mmc.pms.entity.lease;
import com.mmc.pms.model.mall.SpecAttrVO;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import org.apache.commons.collections4.CollectionUtils;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date; import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
/** /**
* 规格属性表(LeaseSpecAttrDO)实体类 * 规格属性表(LeaseSpecAttrDO)实体类
...@@ -32,5 +36,13 @@ public class LeaseSpecAttrDO implements Serializable { ...@@ -32,5 +36,13 @@ public class LeaseSpecAttrDO implements Serializable {
private Date createTime; private Date createTime;
private Date updateTime; private Date updateTime;
private List<LeaseSpecAttrValueDO> leaseSpecAttrValues;
public SpecAttrVO buildSpecAttrVO() {
return SpecAttrVO.builder().id(id).specName(specName)
.specValuesList(CollectionUtils.isEmpty(leaseSpecAttrValues) ? null
: this.leaseSpecAttrValues.stream().map(LeaseSpecAttrValueDO::buildSpecAttr).collect(Collectors.toList())).build();
}
} }
package com.mmc.pms.entity.lease; package com.mmc.pms.entity.lease;
import com.mmc.pms.model.mall.SpecAttrVO;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
...@@ -28,5 +29,9 @@ public class LeaseSpecAttrValueDO implements Serializable { ...@@ -28,5 +29,9 @@ public class LeaseSpecAttrValueDO implements Serializable {
private String specValueName; private String specValueName;
private Date createTime; private Date createTime;
public SpecAttrVO buildSpecAttr() {
return SpecAttrVO.builder().id(id).specName(specValueName).build();
}
} }
...@@ -12,5 +12,6 @@ public interface LeaseGoodsService { ...@@ -12,5 +12,6 @@ public interface LeaseGoodsService {
ResultBody addLeaseGoods(LeaseGoodsVO leaseGoodsVO, Integer userAccountId); ResultBody addLeaseGoods(LeaseGoodsVO leaseGoodsVO, Integer userAccountId);
ResultBody getLeaseTermInfo(); ResultBody getLeaseTermInfo();
ResultBody leaseGoodsDetails(Integer id);
} }
...@@ -2,8 +2,7 @@ package com.mmc.pms.service.lease.impl; ...@@ -2,8 +2,7 @@ package com.mmc.pms.service.lease.impl;
import com.mmc.pms.common.ResultBody; import com.mmc.pms.common.ResultBody;
import com.mmc.pms.dao.lease.LeaseGoodsDao; import com.mmc.pms.dao.lease.LeaseGoodsDao;
import com.mmc.pms.entity.lease.LeaseGoodsDO; import com.mmc.pms.entity.lease.*;
import com.mmc.pms.entity.lease.LeasePartsListDO;
import com.mmc.pms.model.lease.vo.LeaseGoodsVO; import com.mmc.pms.model.lease.vo.LeaseGoodsVO;
import com.mmc.pms.model.lease.vo.LeasePartsListVO; import com.mmc.pms.model.lease.vo.LeasePartsListVO;
import com.mmc.pms.service.lease.LeaseGoodsService; import com.mmc.pms.service.lease.LeaseGoodsService;
...@@ -63,4 +62,28 @@ public class LeaseGoodsServiceImpl implements LeaseGoodsService { ...@@ -63,4 +62,28 @@ public class LeaseGoodsServiceImpl implements LeaseGoodsService {
public ResultBody getLeaseTermInfo() { public ResultBody getLeaseTermInfo() {
return ResultBody.success(leaseGoodsDao.getLeaseTermInfo()); return ResultBody.success(leaseGoodsDao.getLeaseTermInfo());
} }
@Override
public ResultBody leaseGoodsDetails(Integer id) {
LeaseGoodsDO leaseGoodsDO = leaseGoodsDao.getLeaseGoodsBaseInfo(id);
if (leaseGoodsDO == null) {
return ResultBody.error("商品不存在或已删除!");
}
LeaseGoodsVO leaseGoodsVO = leaseGoodsDO.buildLeaseGoodsVO();
// 获取图片及其他资源信息
List<LeaseGoodsResourcesDO> leaseGoodsResourcesList = leaseGoodsDao.getLeaseGoodsResources(id);
leaseGoodsVO.setResourcesList(leaseGoodsResourcesList.stream()
.map(LeaseGoodsResourcesDO::buildGoodsResourcesVO).collect(Collectors.toList()));
// 获取规格及规格值
List<LeaseSpecAttrDO> specAttrDOList = leaseGoodsDao.listSpecAttr(id);
leaseGoodsVO.setSpecAttrList(specAttrDOList.stream().map(LeaseSpecAttrDO::buildSpecAttrVO).collect(Collectors.toList()));
// 获取价格库存排列组合
List<LeasePriceStockDO> priceStockDOList = leaseGoodsDao.listPriceStock(id);
leaseGoodsVO.setPriceStock(priceStockDOList.stream().map(LeasePriceStockDO::buildPriceStockVO).collect(Collectors.toList()));
// 获取商品清单信息
List<LeasePartsListDO> leasePartsDOList = leaseGoodsDao.listLeasePartsListDO(id);
leaseGoodsVO.setLeasePartsList(CollectionUtils.isEmpty(leasePartsDOList) ? null :
leasePartsDOList.stream().map(LeasePartsListDO::buildLeasePartsListVO).collect(Collectors.toList()));
return ResultBody.success(leaseGoodsVO);
}
} }
...@@ -3,6 +3,17 @@ ...@@ -3,6 +3,17 @@
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.mmc.pms.dao.lease.LeaseGoodsDao"> <mapper namespace="com.mmc.pms.dao.lease.LeaseGoodsDao">
<resultMap id="leaseSpecAttr" type="com.mmc.pms.entity.lease.LeaseSpecAttrDO">
<id column="id" property="id"/>
<result column="lease_goods_id" property="mallGoodsId"/>
<result column="spec_name" property="specName"/>
<collection property="leaseSpecAttrValues" javaType="java.util.List"
ofType="com.mmc.pms.entity.lease.LeaseSpecAttrValueDO">
<id property="id" column="valueId"/>
<result property="specValueName" column="spec_value_name"/>
</collection>
</resultMap>
<insert id="insertLeaseGoodsBaseInfo" parameterType="com.mmc.pms.entity.lease.LeaseGoodsDO" <insert id="insertLeaseGoodsBaseInfo" parameterType="com.mmc.pms.entity.lease.LeaseGoodsDO"
keyProperty="id" useGeneratedKeys="true"> keyProperty="id" useGeneratedKeys="true">
insert into lease_goods (trade_name, insert into lease_goods (trade_name,
...@@ -102,4 +113,72 @@ ...@@ -102,4 +113,72 @@
select id, lease_date select id, lease_date
from lease_term_info from lease_term_info
</select> </select>
<select id="getLeaseGoodsBaseInfo" resultType="com.mmc.pms.entity.lease.LeaseGoodsDO">
select id,
trade_name,
selling_point,
`level`,
shelf_status,
product_type_id,
brand_info_id,
device_mode_id,
product_param,
product_details,
min_lease_term,
max_lease_term,
ship_address,
return_address,
logistics_company,
mode_of_delivery,
user_account_id,
create_time,
sort
from lease_goods
where id = #{id}
</select>
<select id="getLeaseGoodsResources" resultType="com.mmc.pms.entity.lease.LeaseGoodsResourcesDO">
SELECT id,
lease_goods_id,
url,
`type`
from lease_goods_resources
where lease_goods_id = #{id}
</select>
<select id="listSpecAttr" resultMap="leaseSpecAttr">
SELECT lsa.id,
lsa.lease_goods_id,
lsa.spec_name,
lsav.id as valueId,
lsav.spec_value_name
FROM lease_spec_attr lsa
LEFT JOIN lease_spec_attr_value lsav ON lsa.id = lsav.spec_attr_id
WHERE lsa.lease_goods_id = #{id}
</select>
<select id="listPriceStock" resultType="com.mmc.pms.entity.lease.LeasePriceStockDO">
select id,
lease_goods_id,
product_spec,
sku_image,
cash_pledge,
three_days_rental,
seven_days_rental,
thirty_days_rental,
ninety_days_rental,
max_days_rental,
show_price,
stock,
stock_out,
create_time
from lease_price_stock
where lease_goods_id = #{id}
</select>
<select id="listLeasePartsListDO" resultType="com.mmc.pms.entity.lease.LeasePartsListDO">
select id,
lease_goods_id,
`name`,
`number`,
price
from lease_parts_list
where lease_goods_id = #{id}
</select>
</mapper> </mapper>
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论