Showing
8 changed files
with
69 additions
and
4 deletions
@@ -16,4 +16,6 @@ public interface ChannelSkuCompareMapper { | @@ -16,4 +16,6 @@ public interface ChannelSkuCompareMapper { | ||
16 | 16 | ||
17 | List<ChannelSkuCompare> selectByCondition(@Param("channelSkuCompareReq") ChannelSkuCompareReq req); | 17 | List<ChannelSkuCompare> selectByCondition(@Param("channelSkuCompareReq") ChannelSkuCompareReq req); |
18 | 18 | ||
19 | + ChannelSkuCompare selectById(@Param("id") Integer id); | ||
20 | + | ||
19 | } | 21 | } |
1 | package com.yoho.ufo.dal; | 1 | package com.yoho.ufo.dal; |
2 | 2 | ||
3 | -import com.yoho.ufo.dal.model.Storage; | 3 | +import java.math.BigDecimal; |
4 | import java.util.List; | 4 | import java.util.List; |
5 | 5 | ||
6 | import org.apache.ibatis.annotations.Param; | 6 | import org.apache.ibatis.annotations.Param; |
7 | 7 | ||
8 | +import com.yoho.ufo.dal.model.Storage; | ||
9 | + | ||
8 | public interface StorageMapper { | 10 | public interface StorageMapper { |
9 | int deleteByPrimaryKey(Integer id); | 11 | int deleteByPrimaryKey(Integer id); |
10 | 12 | ||
@@ -23,4 +25,7 @@ public interface StorageMapper { | @@ -23,4 +25,7 @@ public interface StorageMapper { | ||
23 | int updateStorageNum(@Param("storageId")Integer storageId, @Param("storageNum")Integer storageNum, @Param("oldStorageNum")Integer oldStorageNum); | 25 | int updateStorageNum(@Param("storageId")Integer storageId, @Param("storageNum")Integer storageNum, @Param("oldStorageNum")Integer oldStorageNum); |
24 | 26 | ||
25 | List<Storage> selectByIds(@Param("storageIdList")List<Integer> storageIdList); | 27 | List<Storage> selectByIds(@Param("storageIdList")List<Integer> storageIdList); |
28 | + | ||
29 | + int updateSuggestPriceById(@Param("id") Integer id, @Param("suggestLowPrice") BigDecimal suggestLowPrice, | ||
30 | + @Param("suggestHighPrice") BigDecimal suggestHighPrice); | ||
26 | } | 31 | } |
@@ -11,6 +11,8 @@ public class ChannelSkuCompareReq extends PageRequestBO { | @@ -11,6 +11,8 @@ public class ChannelSkuCompareReq extends PageRequestBO { | ||
11 | * | 11 | * |
12 | */ | 12 | */ |
13 | private static final long serialVersionUID = 1L; | 13 | private static final long serialVersionUID = 1L; |
14 | + | ||
15 | + private Integer id; | ||
14 | 16 | ||
15 | private Integer sku; | 17 | private Integer sku; |
16 | 18 | ||
@@ -25,8 +27,16 @@ public class ChannelSkuCompareReq extends PageRequestBO { | @@ -25,8 +27,16 @@ public class ChannelSkuCompareReq extends PageRequestBO { | ||
25 | private List<Integer> productIdList; | 27 | private List<Integer> productIdList; |
26 | 28 | ||
27 | private List<Integer> sizeIdList; | 29 | private List<Integer> sizeIdList; |
30 | + | ||
31 | + public Integer getId() { | ||
32 | + return id; | ||
33 | + } | ||
34 | + | ||
35 | + public void setId(Integer id) { | ||
36 | + this.id = id; | ||
37 | + } | ||
28 | 38 | ||
29 | - public Integer getSku() { | 39 | + public Integer getSku() { |
30 | return sku; | 40 | return sku; |
31 | } | 41 | } |
32 | 42 |
@@ -16,6 +16,12 @@ | @@ -16,6 +16,12 @@ | ||
16 | <sql id="Base_Column_List"> | 16 | <sql id="Base_Column_List"> |
17 | id, product_id, sku, size_id, channel_price, low_rate, high_rate, update_time, channel_url | 17 | id, product_id, sku, size_id, channel_price, low_rate, high_rate, update_time, channel_url |
18 | </sql> | 18 | </sql> |
19 | + | ||
20 | + <select id="selectById" resultMap="BaseResultMap"> | ||
21 | + select <include refid="Base_Column_List" /> | ||
22 | + from channel_sku_compare | ||
23 | + where id=#{id} | ||
24 | + </select> | ||
19 | 25 | ||
20 | <sql id="Query_Sql" > | 26 | <sql id="Query_Sql" > |
21 | <if test="channelSkuCompareReq.sku != null and channelSkuCompareReq.sku != 0 "> | 27 | <if test="channelSkuCompareReq.sku != null and channelSkuCompareReq.sku != 0 "> |
@@ -66,4 +66,7 @@ | @@ -66,4 +66,7 @@ | ||
66 | #{item} | 66 | #{item} |
67 | </foreach> | 67 | </foreach> |
68 | </select> | 68 | </select> |
69 | + <update id="updateSuggestPriceById"> | ||
70 | + update storage set suggest_low_price=#{suggestLowPrice}, suggest_high_price=#{suggestHighPrice} where id=#{id} | ||
71 | + </update> | ||
69 | </mapper> | 72 | </mapper> |
@@ -23,9 +23,21 @@ public class ChannelSkuCompareController { | @@ -23,9 +23,21 @@ public class ChannelSkuCompareController { | ||
23 | private IChannelSkuCompareService channelSkuCompareService; | 23 | private IChannelSkuCompareService channelSkuCompareService; |
24 | 24 | ||
25 | @RequestMapping(value = "/queryList") | 25 | @RequestMapping(value = "/queryList") |
26 | - public ApiResponse queryList(@RequestBody ChannelSkuCompareReq req) { | 26 | + public ApiResponse queryList(ChannelSkuCompareReq req) { |
27 | LOGGER.info("queryOrderList in. req is {}", req); | 27 | LOGGER.info("queryOrderList in. req is {}", req); |
28 | PageResponseBO<ChannelSkuCompareRspBo> result = channelSkuCompareService.queryList(req); | 28 | PageResponseBO<ChannelSkuCompareRspBo> result = channelSkuCompareService.queryList(req); |
29 | return new ApiResponse.ApiResponseBuilder().code(200).message("查询成功").data(result).build(); | 29 | return new ApiResponse.ApiResponseBuilder().code(200).message("查询成功").data(result).build(); |
30 | } | 30 | } |
31 | + | ||
32 | + @RequestMapping(value = "/updateSuggestPrice") | ||
33 | + public ApiResponse updateSuggestPrice(ChannelSkuCompareReq req) { | ||
34 | + LOGGER.info("updateSuggestPrice in. req is {}", req); | ||
35 | + int result = channelSkuCompareService.updateSuggestPrice(req); | ||
36 | + if(result > 0) { | ||
37 | + return new ApiResponse.ApiResponseBuilder().code(200).message("更新成功").data(result).build(); | ||
38 | + }else { | ||
39 | + return new ApiResponse.ApiResponseBuilder().code(500).message("更新失败").data(result).build(); | ||
40 | + } | ||
41 | + | ||
42 | + } | ||
31 | } | 43 | } |
@@ -10,4 +10,5 @@ import com.yohobuy.ufo.model.resp.product.ChannelSkuCompareRspBo; | @@ -10,4 +10,5 @@ import com.yohobuy.ufo.model.resp.product.ChannelSkuCompareRspBo; | ||
10 | public interface IChannelSkuCompareService { | 10 | public interface IChannelSkuCompareService { |
11 | PageResponseBO<ChannelSkuCompareRspBo> queryList(ChannelSkuCompareReq req); | 11 | PageResponseBO<ChannelSkuCompareRspBo> queryList(ChannelSkuCompareReq req); |
12 | 12 | ||
13 | + int updateSuggestPrice(ChannelSkuCompareReq req); | ||
13 | } | 14 | } |
@@ -100,11 +100,37 @@ public class ChannelSkuCompareServiceImpl implements IChannelSkuCompareService { | @@ -100,11 +100,37 @@ public class ChannelSkuCompareServiceImpl implements IChannelSkuCompareService { | ||
100 | return result; | 100 | return result; |
101 | } | 101 | } |
102 | 102 | ||
103 | + @Override | ||
104 | + public int updateSuggestPrice(ChannelSkuCompareReq req) { | ||
105 | + if(null == req.getStatus() || req.getStatus().intValue() != 0 || null == req.getId()) { | ||
106 | + return 0; | ||
107 | + } | ||
108 | + | ||
109 | + ChannelSkuCompare csc = channelSkuCompareMapper.selectById(req.getId()); | ||
110 | + if(null == csc) { | ||
111 | + LOGGER.error("id not exist! id is {}", req.getId()); | ||
112 | + return 0; | ||
113 | + } | ||
114 | + | ||
115 | + Storage storage = storageMapper.selectByPrimaryKey(csc.getSku()); | ||
116 | + if(null == storage) { | ||
117 | + LOGGER.error("storageId not exist! storageId is {}", csc.getSku()); | ||
118 | + return 0; | ||
119 | + } | ||
120 | + | ||
121 | + //更新 | ||
122 | + BigDecimal suggestLowPrice = csc.getChannelPrice().multiply(BigDecimal.valueOf(1).subtract(csc.getLowRate())); | ||
123 | + BigDecimal suggestHighPrice = csc.getChannelPrice().multiply(BigDecimal.valueOf(1).add(csc.getHighRate())); | ||
124 | + return storageMapper.updateSuggestPriceById(csc.getSku(), suggestLowPrice, suggestHighPrice); | ||
125 | + | ||
126 | + } | ||
127 | + | ||
103 | private List<ChannelSkuCompareRspBo> convertToResp(List<ChannelSkuCompare> cscList, Map<Integer, Product> productMap, | 128 | private List<ChannelSkuCompareRspBo> convertToResp(List<ChannelSkuCompare> cscList, Map<Integer, Product> productMap, |
104 | Map<Integer, String> sizeIdNameMap, Map<Integer, Storage> storageMap, Map<Integer, BigDecimal> storageMinPriceMap){ | 129 | Map<Integer, String> sizeIdNameMap, Map<Integer, Storage> storageMap, Map<Integer, BigDecimal> storageMinPriceMap){ |
105 | List<ChannelSkuCompareRspBo> boList = Lists.newArrayList(); | 130 | List<ChannelSkuCompareRspBo> boList = Lists.newArrayList(); |
106 | for(ChannelSkuCompare csc : cscList) { | 131 | for(ChannelSkuCompare csc : cscList) { |
107 | ChannelSkuCompareRspBo bo = new ChannelSkuCompareRspBo(); | 132 | ChannelSkuCompareRspBo bo = new ChannelSkuCompareRspBo(); |
133 | + bo.setId(csc.getId()); | ||
108 | bo.setProductId(csc.getProductId()); | 134 | bo.setProductId(csc.getProductId()); |
109 | bo.setSku(csc.getSku()); | 135 | bo.setSku(csc.getSku()); |
110 | bo.setProductName(productMap.get(csc.getProductId()).getProductName()); | 136 | bo.setProductName(productMap.get(csc.getProductId()).getProductName()); |
@@ -137,7 +163,7 @@ public class ChannelSkuCompareServiceImpl implements IChannelSkuCompareService { | @@ -137,7 +163,7 @@ public class ChannelSkuCompareServiceImpl implements IChannelSkuCompareService { | ||
137 | } | 163 | } |
138 | 164 | ||
139 | private static String getFormatPrice(BigDecimal price) { | 165 | private static String getFormatPrice(BigDecimal price) { |
140 | - return String.format("%d", price.intValue()); | 166 | + return String.format("%.2f", price.doubleValue()); |
141 | } | 167 | } |
142 | 168 | ||
143 | private boolean checkAndBuildParam(ChannelSkuCompareReq req) { | 169 | private boolean checkAndBuildParam(ChannelSkuCompareReq req) { |
-
Please register or login to post a comment