Authored by caoyan

Merge branch 'test6.10.0' of http://git.yoho.cn/ufo/ufo-platform into test6.10.0

... ... @@ -45,4 +45,8 @@ public interface BuyerOrderMapper {
int selectCountByStatusForFastDelivery(@Param("currentSecondMinus36Hours")Integer currentSecondMinus24Hours);
List<BuyerOrder> selectMinFalultList(@Param("buyerOrderReq") BuyerOrderReq req);
List<BuyerOrder> selectByStatusAndUpdateTimeLess(@Param("status")int status, @Param("updateTime")int updateTime);
}
... ...
... ... @@ -366,4 +366,11 @@
limit #{buyerOrderReq.start},#{buyerOrderReq.size}
</if>
</select>
<select id="selectByStatusAndUpdateTimeLess" resultMap="BaseResultMap">
select <include refid="Base_Column_List"></include>
from buyer_order
where status = #{status} and update_time < #{updateTime}
</select>
</mapper>
\ No newline at end of file
... ...
... ... @@ -23,7 +23,7 @@
<insert id="updateProductChain" parameterType="com.yoho.product.model.ProductChain" >
insert into product_chain (tag_id, chain_id, transaction_id, transaction_time)
values (#{tagId,jdbcType=VARCHAR}, #{chainId,jdbcType=BIGINT}, #{transactionId,jdbcType=VARCHAR}, #{transactionTime,jdbcType=INTEGER})
ON DUPLICATE KEY UPDATE transaction_time=#{transactionTime, jdbcType=INTEGER}
ON DUPLICATE KEY UPDATE transaction_time=#{transactionTime, jdbcType=INTEGER}, transaction_id = #{transactionId,jdbcType=VARCHAR}
</insert>
<insert id="insertSelective" parameterType="com.yoho.product.model.ProductChain" >
insert into product_chain
... ...
package com.yoho.ufo.order.controller;
import com.yoho.core.rabbitmq.YhProducer;
import com.yoho.order.dal.BuyerOrderMapper;
import com.yoho.ufo.util.DateUtil;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.Objects;
import java.util.Optional;
@RestController
@RequestMapping(value = "/help")
public class OrderHelpController {
@Autowired
private BuyerOrderMapper buyerOrderMapper;
@Resource(name = "yhProducer")
private YhProducer yhProducer;
@RequestMapping(value = "/fixTimeoutNonConfirmOrder")
public void fixTimeoutNonConfirmOrder(
@RequestParam(value = "updateTime", required = false) String updateTime
, @RequestParam(value = "orderCode", required = false) String orderCode) {
String topic = "buyerOrder.autoConfirm";
if (Objects.nonNull(orderCode)) {
Optional.ofNullable(buyerOrderMapper.selectByOrderCode(orderCode))
.ifPresent(order -> yhProducer.send(topic, order));
} else if (Objects.nonNull(updateTime)) {
int updateTimeSeconds = DateUtil.getTimeSecondsFromStr(updateTime, "yyyyMMddHHmmss");
int maxUpdateTimeSeconds = DateUtil.getCurrentTimeSeconds() - 7 * 24 * 3600;
if (updateTimeSeconds > maxUpdateTimeSeconds) {
return;
}
buyerOrderMapper.selectByStatusAndUpdateTimeLess(4, updateTimeSeconds)
.forEach(order -> yhProducer.send(topic, order));
}
}
}
... ...
... ... @@ -15,6 +15,7 @@ import com.yohobuy.ufo.model.request.nfc.ProductInfoReq;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.codec.binary.*;
import org.apache.commons.lang3.*;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -70,8 +71,10 @@ public class ProductChainService {
// curl http://40.73.0.117:8078/yoho/post/query POST -H "Content-Type:application/json" -d '"id":"156663177401529"' -v
public void postQuery(Long chainId, String tagid) {
try {
// (String serviceName, String url, Object request, Class<T> responseType, T fallback, int timeout)
Map<String, Object> request = new HashMap<>(); request.put("id", chainId);
Map<String, Object> request = new HashMap<>();
request.put("id", chainId);
HttpHeaders headers = getHttpHeaders("");
HttpEntity<String> formEntity = getStringHttpEntity(request, headers);
... ... @@ -89,10 +92,14 @@ public class ProductChainService {
if (0 >= size) {
return;
}
JSONObject item = (JSONObject)yohoInfos.get(0);
JSONObject item = (JSONObject) yohoInfos.get(0);
String transactionId = item.getString("transactionId");
Integer transactionTime = item.getInteger("transaction_time");
updateProductChain(ProductChain.builder().tagId(tagid).transactionId(transactionId).build());
updateProductChain(ProductChain.builder().tagId(tagid).transactionId(transactionId).transactionTime(transactionTime).build());
}
} catch (Exception e) {
logger.error("postQuery find wrong, chainId is " + chainId, e);
}
}
... ... @@ -145,7 +152,11 @@ public class ProductChainService {
public int updateProductChain(ProductChain chain) {
logger.info("updateProductChain in, chain is {}", chain);
ProductChain productChain = productChainMapper.selectByPrimaryKey(chain.getTagId());
if (null != productChain && StringUtils.isNotEmpty(productChain.getTransactionId())) {
productChain.setTransactionTime(chain.getTransactionTime());
productChainMapper.updateByPrimaryKeySelective(productChain); // 只更新时间
}
return productChainMapper.updateProductChain(chain);
}
... ...