Authored by htoooth

fix

... ... @@ -39,6 +39,8 @@ public class ChannelSkuCompare implements Serializable {
private Integer updateUid;
private BigDecimal channelAveragePrice;
public Integer getId() {
return id;
}
... ... @@ -127,6 +129,14 @@ public class ChannelSkuCompare implements Serializable {
this.updateUid = updateUid;
}
public BigDecimal getChannelAveragePrice() {
return channelAveragePrice;
}
public void setChannelAveragePrice(BigDecimal channelAveragePrice) {
this.channelAveragePrice = channelAveragePrice;
}
@Override
public String toString() {
return "ProductPool{" +
... ... @@ -141,6 +151,7 @@ public class ChannelSkuCompare implements Serializable {
", channelUrl=" + channelUrl +
", status=" + status +
", updateUid=" + updateUid +
", channelAveragePrice=" + channelAveragePrice +
'}';
}
}
... ...
... ... @@ -57,4 +57,6 @@ public class ChannelSkuCompareRspBo {
private String channelUrl;
private String imageUrl;
private String channelAveragePrice;
}
... ...
... ... @@ -13,11 +13,12 @@
<result column="status" property="status" jdbcType="INTEGER" />
<result column="update_time" property="updateTime" jdbcType="INTEGER" />
<result column="update_uid" property="updateUid" jdbcType="INTEGER" />
<result column="channel_average_price" property="channelAveragePrice" jdbcType="DECIMAL" />
</resultMap>
<sql id="Base_Column_List">
id, product_id, sku, size_id, channel_price, low_rate, high_rate, channel_url,
status, update_time, update_uid
status, update_time, update_uid, channel_average_price
</sql>
<select id="selectById" resultMap="BaseResultMap">
... ... @@ -53,14 +54,14 @@
<select id="selectTotalByCondition" resultType="java.lang.Integer" parameterType="com.yoho.ufo.model.ChannelSkuCompareReq">
select count(a.id)
from channel_sku_compare a
where 1=1
where a.channel_price != 0
<include refid="Query_Sql" />
</select>
<select id="selectByCondition" resultMap="BaseResultMap" parameterType="com.yoho.ufo.model.ChannelSkuCompareReq">
select a.*
from channel_sku_compare a
where 1=1
where a.channel_price != 0
<include refid="Query_Sql" />
order by a.product_id desc, a.sku asc
<if test="channelSkuCompareReq.start!=null and channelSkuCompareReq.size != null">
... ...
... ... @@ -114,7 +114,7 @@
<dependency>
<groupId>com.yoho.quartz</groupId>
<artifactId>yoho-quartz-client</artifactId>
<version>1.3.8-SNAPSHOT</version>
<version>1.4.5-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.yoho.common</groupId>
... ...
... ... @@ -204,9 +204,11 @@ public class ChannelSkuCompareServiceImpl implements IChannelSkuCompareService,
List<Product> productList = productMapper.selectProductListByIds(productIdList);
Map<Integer, BigDecimal> productIdMinPriceMap = productList.stream().collect(Collectors.toMap(Product::getId, Product::getMinPrice));
List<Integer> abnormalIdList = Lists.newArrayList();
List<Integer> normalIdList = Lists.newArrayList();
List<Storage> storageList = Lists.newArrayList();
for(ChannelSkuCompare csc : cscList) {
if(csc.getChannelPrice().compareTo(productIdMinPriceMap.get(csc.getProductId())) < 0) {//毒价小于平台最低价为异常
if((null != productIdMinPriceMap.get(csc.getProductId()) && csc.getChannelPrice().compareTo(productIdMinPriceMap.get(csc.getProductId()))< 0)
|| (csc.getChannelAveragePrice().compareTo(BigDecimal.valueOf(0)) != 0 && csc.getChannelPrice().compareTo(csc.getChannelAveragePrice()) < 0)) {//毒价小于平台最低价或毒价小于毒前24小时平均价为异常
abnormalIdList.add(csc.getId());
continue;
}
... ... @@ -217,14 +219,18 @@ public class ChannelSkuCompareServiceImpl implements IChannelSkuCompareService,
BigDecimal suggestHighPrice = csc.getChannelPrice().multiply(BigDecimal.valueOf(1).add(csc.getHighRate())).setScale(0, BigDecimal.ROUND_DOWN);
storage.setSuggestLowPrice(suggestLowPrice);
storage.setSuggestHighPrice(suggestHighPrice);
normalIdList.add(csc.getId());
storageList.add(storage);
}
//更新异常数据状态
channelSkuCompareMapper.updateStatusByIds(abnormalIdList, CHANNEL_SKU_COMPARE_ABNORMAL, 0);//uid=0表示系统操作
if(CollectionUtils.isNotEmpty(abnormalIdList)) {
channelSkuCompareMapper.updateStatusByIds(abnormalIdList, CHANNEL_SKU_COMPARE_ABNORMAL, 0);//uid=0表示系统操作
}
//更新正常数据的建议价到storage表
if(CollectionUtils.isEmpty(storageList)){
if(CollectionUtils.isNotEmpty(storageList)){
channelSkuCompareMapper.updateStatusByIds(normalIdList, CHANNEL_SKU_COMPARE_NORMAL, 0);//uid=0表示系统操作
storageMapper.updateBatchSuggestPrice(storageList);
}
... ... @@ -280,6 +286,7 @@ public class ChannelSkuCompareServiceImpl implements IChannelSkuCompareService,
bo.setUfoCurrentPrice(getFormatPrice(storageMinPriceMap.get(csc.getSku())));
BigDecimal ufoMinPrice = null == productMap.get(csc.getProductId()) ? null : productMap.get(csc.getProductId()).getMinPrice();
bo.setUfoMinPrice(getFormatPrice(ufoMinPrice));
bo.setChannelAveragePrice(null == csc.getChannelAveragePrice() ? "" : getIntFormatPrice(csc.getChannelAveragePrice()));
//毒当前价低于UFO价格红线则为异常,那么显示上回的建议价
BigDecimal suggestLowPrice = null == storageMap.get(csc.getSku()) ? null : storageMap.get(csc.getSku()).getSuggestLowPrice();
BigDecimal suggestHighPrice = null == storageMap.get(csc.getSku()) ? null : storageMap.get(csc.getSku()).getSuggestHighPrice();
... ...
... ... @@ -19,8 +19,8 @@ import com.yoho.ufo.service.IChannelSkuCompareService;
*
*/
@Service(value="scheduledUpdateSuggestPrice")
@YhJobDef(desc = "定时变参考价", jobName = "scheduledUpdateSuggestPrice", cron = "*/30 * * * * ?", misfiredPolicy = MisfiredPolicy.CRON_DO_NOTHING,
jobType = JobType.CRON, jobGroup = "ufoPlatform")
@YhJobDef(desc = "定时变参考价", jobName = "scheduledUpdateSuggestPrice", cron = "0 0/30 * * * ?", misfiredPolicy = MisfiredPolicy.CRON_DO_NOTHING,
jobType = JobType.CRON, jobGroup = "ufoPlatform", needUpdate=true)
public class ScheduledUpdateSuggestPrice implements YhJob{
private static final Logger LOGGER = LoggerFactory.getLogger("scheduledLog");
... ...
... ... @@ -82,6 +82,21 @@
</encoder>
</appender>
<!-- 定时任务日志 appender -->
<appender name="SCHEDULED_LOG" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 按天回滚 daily -->
<fileNamePattern>${catalina.home}/logs/%d{yyyy-MM-dd}/scheduled-log.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>${maxHistory}</maxHistory>
</rollingPolicy>
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<maxFileSize>${maxFileSize}</maxFileSize>
</triggeringPolicy>
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger:%line - %msg%n</pattern>
</encoder>
</appender>
<!-- MQ日志 appender -->
<appender name="MQ_LOG" class="ch.qos.logback.core.rolling.RollingFileAppender">
... ... @@ -146,6 +161,11 @@
<appender-ref ref="OPERATE_LOG"/>
</logger>
<!-- 定时日志,记录关键操作 -->
<logger name="scheduledLog" additivity="true">
<level value="INFO"/>
<appender-ref ref="SCHEDULED_LOG"/>
</logger>
<!-- MQ日志 -->
<logger name="mqLog" additivity="false">
... ...