Authored by caoyan

Merge branch 'dev_suggestPrice_20181119' into test6.8.2

package com.yoho.ufo.dal;
import java.math.BigDecimal;
import java.util.List;
import org.apache.ibatis.annotations.Param;
... ... @@ -21,4 +22,5 @@ public interface ChannelSkuCompareMapper {
int updateChangeStatusById(@Param("id")Integer id, @Param("status")Integer status, @Param("changeStatusTime") Integer changeStatusTime,
@Param("changeStatusUid")Integer changeStatusUid);
int updateRateById(@Param("id")Integer id, @Param("lowRate")BigDecimal lowRate, @Param("highRate")BigDecimal highRate);
}
... ...
package com.yoho.ufo.model;
import java.math.BigDecimal;
import java.util.List;
import com.alibaba.fastjson.JSONObject;
... ... @@ -28,6 +29,10 @@ public class ChannelSkuCompareReq extends PageRequestBO {
private List<Integer> sizeIdList;
private BigDecimal suggestLowRate;
private BigDecimal suggestHighRate;
public Integer getId() {
return id;
}
... ... @@ -92,6 +97,22 @@ public class ChannelSkuCompareReq extends PageRequestBO {
this.sizeIdList = sizeIdList;
}
public BigDecimal getSuggestLowRate() {
return suggestLowRate;
}
public void setSuggestLowRate(BigDecimal suggestLowRate) {
this.suggestLowRate = suggestLowRate;
}
public BigDecimal getSuggestHighRate() {
return suggestHighRate;
}
public void setSuggestHighRate(BigDecimal suggestHighRate) {
this.suggestHighRate = suggestHighRate;
}
public String toString() {
return JSONObject.toJSONString(this);
}
... ...
package com.yoho.ufo.model;
import java.math.BigDecimal;
import com.yoho.ufo.annotation.BatchExportField;
import lombok.Data;
... ... @@ -30,10 +32,10 @@ public class ChannelSkuCompareRspBo {
private String channelPrice;
@BatchExportField(name = "价格低于(a%)")
private String lowRate;
private BigDecimal lowRate;
@BatchExportField(name = "价格高于(b%)")
private String highRate;
private BigDecimal highRate;
@BatchExportField(name = "对标毒的价格区间A(1-a%)~A(1+b%)")
private String channelPriceRange;
... ...
... ... @@ -72,5 +72,10 @@
<update id="updateChangeStatusById">
update channel_sku_compare set status=#{status}, change_status_time=#{changeStatusTime}, change_status_uid=#{changeStatusUid}
where id=#{id}
</update>
<update id="updateRateById">
update channel_sku_compare set low_rate=#{lowRate}, high_rate=#{highRate}
where id=#{id}
</update>
</mapper>
\ No newline at end of file
... ...
... ... @@ -40,4 +40,16 @@ public class ChannelSkuCompareController {
}
}
@RequestMapping(value = "/updateSuggestRate")
public ApiResponse updateSuggestRate(ChannelSkuCompareReq req) {
LOGGER.info("updateSuggestPrice in. req is {}", req);
int result = channelSkuCompareService.updateSuggestRate(req);
if(result > 0) {
return new ApiResponse.ApiResponseBuilder().code(200).message("更新成功").data(result).build();
}else {
return new ApiResponse.ApiResponseBuilder().code(500).message("更新失败").data(result).build();
}
}
}
... ...
... ... @@ -11,4 +11,6 @@ public interface IChannelSkuCompareService {
PageResponseBO<ChannelSkuCompareRspBo> queryList(ChannelSkuCompareReq req);
int updateSuggestPrice(ChannelSkuCompareReq req);
int updateSuggestRate(ChannelSkuCompareReq req);
}
... ...
... ... @@ -134,6 +134,26 @@ public class ChannelSkuCompareServiceImpl implements IChannelSkuCompareService,
}
@Override
public int updateSuggestRate(ChannelSkuCompareReq req) {
if(null == req.getId()) {
return 0;
}
ChannelSkuCompare csc = channelSkuCompareMapper.selectById(req.getId());
if(null == csc) {
LOGGER.error("id not exist! id is {}", req.getId());
return 0;
}
BigDecimal lowRate = null == req.getSuggestLowRate() ? csc.getLowRate() : req.getSuggestLowRate();
BigDecimal highRate = null == req.getSuggestHighRate() ? csc.getHighRate() : req.getSuggestHighRate();
//更新比例
return channelSkuCompareMapper.updateRateById(req.getId(), lowRate, highRate);
}
@Override
public Class getDataClass() {
return ChannelSkuCompareRspBo.class;
}
... ... @@ -174,8 +194,8 @@ public class ChannelSkuCompareServiceImpl implements IChannelSkuCompareService,
bo.setSizeName(sizeIdNameMap.get(csc.getSizeId()));
bo.setChannelPrice(getFormatPrice(csc.getChannelPrice()));
bo.setChannelUrl(csc.getChannelUrl());
bo.setLowRate(csc.getLowRate().multiply(BigDecimal.valueOf(100)) + "%");
bo.setHighRate(csc.getHighRate().multiply(BigDecimal.valueOf(100)) + "%");
bo.setLowRate(csc.getLowRate());
bo.setHighRate(csc.getHighRate());
BigDecimal channelLowPrice = csc.getChannelPrice().multiply(BigDecimal.valueOf(1).subtract(csc.getLowRate()));
BigDecimal channelHighPrice = csc.getChannelPrice().multiply(BigDecimal.valueOf(1).add(csc.getHighRate()));
bo.setChannelPriceRange(getFormatPrice(channelLowPrice) + "~" + getFormatPrice(channelHighPrice));
... ...