提交 e441de02 作者: xiaowang

功能:租赁商品编辑

上级 ec92b8f9
...@@ -51,4 +51,11 @@ public class LeaseGoodsController extends BaseController { ...@@ -51,4 +51,11 @@ public class LeaseGoodsController extends BaseController {
public ResultBody leaseGoodsDetails(@RequestParam Integer id) { public ResultBody leaseGoodsDetails(@RequestParam Integer id) {
return leaseGoodsService.leaseGoodsDetails(id); return leaseGoodsService.leaseGoodsDetails(id);
} }
@ApiOperation(value = "编辑租赁商品")
@PostMapping("editLeaseGoods")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = ResultBody.class)})
public ResultBody editLeaseGoods(@RequestBody LeaseGoodsVO leaseGoodsVO, HttpServletRequest request) {
return leaseGoodsService.editLeaseGoods(leaseGoodsVO, this.getUserLoginInfoFromRedis(request).getUserAccountId());
}
} }
...@@ -5,6 +5,7 @@ import com.mmc.pms.entity.mall.MallGoodsResourcesDO; ...@@ -5,6 +5,7 @@ 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;
import com.mmc.pms.model.lease.vo.LeaseGoodsVO; import com.mmc.pms.model.lease.vo.LeaseGoodsVO;
import com.mmc.pms.model.mall.SpecAttrVO;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
...@@ -44,4 +45,20 @@ public interface LeaseGoodsDao { ...@@ -44,4 +45,20 @@ public interface LeaseGoodsDao {
List<LeasePriceStockDO> listPriceStock(Integer id); List<LeasePriceStockDO> listPriceStock(Integer id);
List<LeasePartsListDO> listLeasePartsListDO(Integer id); List<LeasePartsListDO> listLeasePartsListDO(Integer id);
void updateLeaseGoodsBaseInfo(LeaseGoodsDO leaseGoodsDO);
void deleteLeaseGoodsResources(Integer id);
void deleteLeasePartsList(Integer id);
void deleteSpecAttr(List<Integer> list);
void deleteLeasePriceStock(Integer id);
List<LeaseSpecAttrDO> getLeaseSpecAttr(List<Integer> ids);
void updateSpecAttr(SpecAttrVO specAttrVO);
void deleteSpecAttrValue(List<Integer> delValueIds);
} }
...@@ -14,4 +14,7 @@ public interface LeaseGoodsService { ...@@ -14,4 +14,7 @@ public interface LeaseGoodsService {
ResultBody getLeaseTermInfo(); ResultBody getLeaseTermInfo();
ResultBody leaseGoodsDetails(Integer id); ResultBody leaseGoodsDetails(Integer id);
ResultBody editLeaseGoods(LeaseGoodsVO leaseGoodsVO, Integer userAccountId);
} }
...@@ -86,4 +86,24 @@ public class LeaseGoodsServiceImpl implements LeaseGoodsService { ...@@ -86,4 +86,24 @@ public class LeaseGoodsServiceImpl implements LeaseGoodsService {
leasePartsDOList.stream().map(LeasePartsListDO::buildLeasePartsListVO).collect(Collectors.toList())); leasePartsDOList.stream().map(LeasePartsListDO::buildLeasePartsListVO).collect(Collectors.toList()));
return ResultBody.success(leaseGoodsVO); return ResultBody.success(leaseGoodsVO);
} }
@Override
public ResultBody editLeaseGoods(LeaseGoodsVO leaseGoodsVO, Integer userAccountId) {
ResultBody resultError = mallGoodsService.checkInformation(leaseGoodsVO, null, userAccountId);
if (resultError != null) return resultError;
LeaseGoodsDO leaseGoodsDO = new LeaseGoodsDO(leaseGoodsVO);
// 修改商品基本信息
leaseGoodsDao.updateLeaseGoodsBaseInfo(leaseGoodsDO);
// 修改商城商品的图片等资源信息,先删除后新增
leaseGoodsDao.deleteLeaseGoodsResources(leaseGoodsVO.getId());
mallGoodsService.insertMallGoodsResources(leaseGoodsVO, null, leaseGoodsVO.getId());
// 修改商品清单
leaseGoodsDao.deleteLeasePartsList(leaseGoodsVO.getId());
if (CollectionUtils.isNotEmpty(leaseGoodsVO.getLeasePartsList())) {
this.insertLeasePartsList(leaseGoodsVO.getLeasePartsList(), leaseGoodsVO.getId());
}
// 修改规格
mallGoodsService.updateSpecInfo(null, leaseGoodsVO);
return ResultBody.success();
}
} }
...@@ -40,4 +40,6 @@ public interface MallGoodsService { ...@@ -40,4 +40,6 @@ public interface MallGoodsService {
void insertMallGoodsResources(LeaseGoodsVO leaseGoodsVO, MallGoodsVO mallGoodsVO, Integer id); void insertMallGoodsResources(LeaseGoodsVO leaseGoodsVO, MallGoodsVO mallGoodsVO, Integer id);
void addMallGoodsSpec(List<SpecAttrVO> specAttrList, Integer id, List<PriceStockVO> priceStock, List<LeasePriceStockVO> leasePriceStockVO, Integer flag); void addMallGoodsSpec(List<SpecAttrVO> specAttrList, Integer id, List<PriceStockVO> priceStock, List<LeasePriceStockVO> leasePriceStockVO, Integer flag);
void updateSpecInfo(MallGoodsVO mallGoodsVO, LeaseGoodsVO leaseGoodsVO);
} }
...@@ -93,6 +93,95 @@ ...@@ -93,6 +93,95 @@
(#{item.leaseGoodsId},#{item.name},#{item.number},#{item.price}) (#{item.leaseGoodsId},#{item.name},#{item.number},#{item.price})
</foreach> </foreach>
</insert> </insert>
<update id="updateLeaseGoodsBaseInfo">
update lease_goods
<set>
<if test="tradeName != null and tradeName != ''">
trade_name = #{tradeName},
</if>
<if test="sellingPoint != null">
selling_point = #{sellingPoint},
</if>
<if test="level != null">
`level` = #{level},
</if>
<if test="shelfStatus != null">
shelf_status = #{shelfStatus},
</if>
<if test="productTypeId != null">
product_type_id = #{productTypeId},
</if>
<if test="brandInfoId != null">
brand_info_id = #{brandInfoId},
</if>
<if test="deviceModeId != null">
device_mode_id = #{deviceModeId},
</if>
<if test="productParam != null and productParam != ''">
product_param =#{productParam},
</if>
<if test="productDetails != null and productDetails != ''">
product_details = #{productDetails},
</if>
<if test="minLeaseTerm != null">
min_lease_term = #{minLeaseTerm},
</if>
<if test="maxLeaseTerm != null">
max_lease_term = #{maxLeaseTerm},
</if>
<if test="shipAddress != null">
ship_address =#{shipAddress},
</if>
<if test="returnAddress != null">
return_address = #{returnAddress},
</if>
<if test="logisticsCompany != null">
logistics_company = #{logisticsCompany},
</if>
<if test="modeOfDelivery != null">
mode_of_delivery = #{modeOfDelivery}
</if>
</set>
where id = #{id}
</update>
<update id="updateSpecAttr">
update lease_spec_attr
set spec_name = #{specName}
where id = #{id}
</update>
<delete id="deleteLeaseGoodsResources">
delete
from lease_goods_resources
where lease_goods_id = #{id}
</delete>
<delete id="deleteLeasePartsList">
delete
from lease_parts_list
where lease_goods_id = #{id}
</delete>
<delete id="deleteSpecAttr">
delete
from lease_spec_attr
<where>
<foreach collection="list" open="id in (" close=")" item="item" separator=",">
#{item}
</foreach>
</where>
</delete>
<delete id="deleteLeasePriceStock">
delete
from lease_price_stock
where lease_goods_id = #{id}
</delete>
<delete id="deleteSpecAttrValue">
delete
from lease_spec_attr_value
<where>
<foreach collection="list" open="id in (" close=")" item="item" separator=",">
#{item}
</foreach>
</where>
</delete>
<select id="countLeaseGoodsByName" resultType="java.lang.Integer"> <select id="countLeaseGoodsByName" resultType="java.lang.Integer">
select count(*) select count(*)
...@@ -181,4 +270,20 @@ ...@@ -181,4 +270,20 @@
from lease_parts_list from lease_parts_list
where lease_goods_id = #{id} where lease_goods_id = #{id}
</select> </select>
<select id="getLeaseSpecAttr" 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 in (
<foreach collection="list" item="item" separator=",">
#{item}
</foreach>
)
</where>
</select>
</mapper> </mapper>
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论