admin
2023-10-08 850a524cced18e275ae89aea5ffdeaa30ddd687f
唯品会接口修改增加必要的3个字段
4个文件已修改
129 ■■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/GoodsControllerV2.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/job/order/vipshop/UpdateVipShopOrderJob.java 90 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/vipshop/VipShopApiUtil.java 34 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/resource/dubbo/consumer.xml 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/GoodsControllerV2.java
@@ -677,7 +677,6 @@
            if ("ios".equalsIgnoreCase(acceptData.getPlatform())
                    && configService.iosOnLining(Integer.parseInt(acceptData.getVersion()), acceptData.getSystem()))
                otherInfo.setRewardCoupon(null);
            goodsDetail.setOtherInfo(otherInfo);
        }
        extraVO.setFanliValid(fanliValid);
fanli/src/main/java/com/yeshi/fanli/job/order/vipshop/UpdateVipShopOrderJob.java
@@ -11,6 +11,8 @@
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.mq.cmq.order.OrdersCMQManager;
import com.yeshi.fanli.util.vipshop.DingDanXiaApiUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import com.xxl.job.core.biz.model.ReturnT;
@@ -27,6 +29,8 @@
//从淘宝爬去订单更新
@Component
public class UpdateVipShopOrderJob {
    private  Logger logger = LoggerFactory.getLogger("debugLog");
    @Resource
    private VipShopOrderService vipShopOrderService;
@@ -76,30 +80,38 @@
    @XxlJob("updateVipShopOrderHandler")
    public ReturnT<String> updateVipShopSoonOrder(String param) throws Exception {
        LogHelper.test("updateVipShopOrderHandler:" + param);
        long endTime = System.currentTimeMillis();
        if ("1hour".equalsIgnoreCase(param)) {// 更新1小时内的订单
            updateByOrderTime(endTime - 1000 * 60 * 60 * 1L, endTime);
            updateByUpdateTime(endTime - 1000 * 60 * 60 * 1L, endTime);
        } else if ("1day".equalsIgnoreCase(param)) {// 更新最近1天更新的数据
            Long startT = endTime - 1000 * 60 * 60 * 24L;
            for(long start= startT;start<startT +1000 * 60 * 60 * 24L;start+=1000 * 60 * 60 ) {
                updateByOrderTime(start, start + 1000 * 60 * 60 );
                updateByUpdateTime(start, start + 1000 * 60 * 60 );
        logger.info("唯品会订单更新开始:updateVipShopSoonOrder 参数:"+param);
        try {
            long endTime = System.currentTimeMillis();
            if ("1hour".equalsIgnoreCase(param)) {// 更新1小时内的订单
                updateByOrderTime(endTime - 1000 * 60 * 60 * 1L, endTime);
                updateByUpdateTime(endTime - 1000 * 60 * 60 * 1L, endTime);
            } else if ("1day".equalsIgnoreCase(param)) {// 更新最近1天更新的数据
                Long startT = endTime - 1000 * 60 * 60 * 24L;
                for (long start = startT; start < startT + 1000 * 60 * 60 * 24L; start += 1000 * 60 * 60) {
                    updateByOrderTime(start, start + 1000 * 60 * 60);
                    updateByUpdateTime(start, start + 1000 * 60 * 60);
                }
            } else if ("1month".equalsIgnoreCase(param)) {// 更新最近1个月的数据
                for (int i = 0; i < 30; i++) {
                    Long startT = endTime - 1000 * 60 * 60 * 24L * (i + 1);
                    for (long start = startT; start < startT + 1000 * 60 * 60 * 24L; start += 1000 * 60 * 60) {
                        updateByOrderTime(start, start + 1000 * 60 * 60);
                        updateByUpdateTime(start, start + 1000 * 60 * 60);
                    }
                }
            }
        } else if ("1month".equalsIgnoreCase(param)) {// 更新最近1个月的数据
            for (int i = 0; i < 30; i++) {
                Long startT = endTime - 1000 * 60 * 60 * 24L*(i+1);
               for(long start= startT;start<startT +1000 * 60 * 60 * 24L;start+=1000 * 60 * 60 ) {
                   updateByOrderTime(start, start + 1000 * 60 * 60 );
                   updateByUpdateTime(start, start + 1000 * 60 * 60 );
               }
            }
            /*
             * else if ("3day".equalsIgnoreCase(param)) {// 更新最近3天更新的数据
             * updateByOrderTime(endTime - 1000 * 60 * 60 * 24 * 3L, endTime);
             * updateByUpdateTime(endTime - 1000 * 60 * 60 * 24 * 3L, endTime); }
             */
        }catch(Exception e){
            logger.error("唯品会订单更新异常:",e);
        }finally {
            logger.info("唯品会订单更新结束:updateVipShopSoonOrder 参数:"+ param);
        }
        /*
         * else if ("3day".equalsIgnoreCase(param)) {// 更新最近3天更新的数据
         * updateByOrderTime(endTime - 1000 * 60 * 60 * 24 * 3L, endTime);
         * updateByUpdateTime(endTime - 1000 * 60 * 60 * 24 * 3L, endTime); }
         */
        return ReturnT.SUCCESS;
    }
@@ -107,23 +119,27 @@
    //根据订单号更新
    @XxlJob("order-vip-updateByOrderSn")
    public ReturnT<String> updateByOrderSn(String param) throws Exception {
        String[] ps = param.split(",");
        for (String p : ps) {
            List<VipShopOrder> orders = vipShopOrderService.listByOrderSn(p);
            if (orders == null || orders.size() == 0)
            {
                // 请求订单详情
                saveVipShopOrders( Arrays.asList(new VipShopOrder[]{ DingDanXiaApiUtil.getOrderDetail(p)}));
            }
            else {
                Thread.sleep(1000);
                VipShopOrder vipShopOrder = DingDanXiaApiUtil.getOrderDetail(p);
                if (vipShopOrder != null) {
                    List<VipShopOrder> vipShopOrderList = new ArrayList<>();
                    vipShopOrderList.add(vipShopOrder);
                    saveVipShopOrders(vipShopOrderList);
        logger.info(String.format("唯品会订单更新:%s", param));
        try {
            String[] ps = param.split(",");
            for (String p : ps) {
                List<VipShopOrder> orders = vipShopOrderService.listByOrderSn(p);
                if (orders == null || orders.size() == 0) {
                    // 请求订单详情
                    saveVipShopOrders(Arrays.asList(new VipShopOrder[]{DingDanXiaApiUtil.getOrderDetail(p)}));
                } else {
                    Thread.sleep(1000);
                    VipShopOrder vipShopOrder = DingDanXiaApiUtil.getOrderDetail(p);
                    if (vipShopOrder != null) {
                        List<VipShopOrder> vipShopOrderList = new ArrayList<>();
                        vipShopOrderList.add(vipShopOrder);
                        saveVipShopOrders(vipShopOrderList);
                    }
                }
            }
            logger.info("唯品会订单更新成功");
        }catch(Exception e){
            logger.info(String.format("唯品会订单更新失败:%s", e.getMessage()));
        }
        return ReturnT.SUCCESS;
    }
fanli/src/main/java/com/yeshi/fanli/util/vipshop/VipShopApiUtil.java
@@ -6,6 +6,7 @@
import java.net.URLEncoder;
import java.util.*;
import com.yeshi.fanli.util.Constant;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.methods.PostMethod;
@@ -40,7 +41,8 @@
    /**
     * 获取签名
     *
     * @param params
     * @param systemParams
     * @param taskParams
     * @return
     */
    private static String getSign(Map<String, String> systemParams, JSONObject taskParams) {
@@ -141,6 +143,14 @@
        if (searchFilter.getFieldName() != null)
            taskParams.put("fieldName", searchFilter.getFieldName() + "");
        //新增参数
        taskParams.put("chanTag", "default_pid");
        taskParams.put("openId", "default_open_id");
        taskParams.put("realCall", "true");
        JSONObject root = new JSONObject();
        root.put("request", JSONObject.fromObject(taskParams));
        String result = baseRequest("com.vip.adp.api.open.service.UnionGoodsService", "query", root);
@@ -177,6 +187,11 @@
        taskParams.put("page", page + "");
        taskParams.put("pageSize", 20 + "");
        taskParams.put("requestId", System.currentTimeMillis() + "_" + UUID.randomUUID());
        //新增参数
        taskParams.put("chanTag", "default_pid");
        taskParams.put("openId", "default_open_id");
        taskParams.put("realCall", "true");
        JSONObject root = new JSONObject();
@@ -263,6 +278,13 @@
        JSONObject params = new JSONObject();
        params.put("goodsIdList", goodsIdList);
        params.put("requestId", UUID.randomUUID());
        //新增参数
        params.put("chanTag", "default_pid");
        JSONObject request = new JSONObject();
        request.put("openId", "default_open_id");
        request.put("realCall", "true");
        params.put("request", request);
        String result = baseRequest("com.vip.adp.api.open.service.UnionGoodsService", "getByGoodsIds",
                JSONObject.fromObject(params));
        System.out.println(result);
@@ -319,9 +341,17 @@
    }
    public static void main(String[] args) {
//        VIPSearchFilter sf=new VIPSearchFilter();
//        sf.setKeyword("花卉");
//        sf.setPage(1);
//        sf.setPageSize(Constant.PAGE_SIZE);
//        search(sf);
        getGoodsDetail("6919981305334511260");
//        convertLinkByUrl("https://t.vip.com/T7RyKKCJLj9", "437032");
//        convertLink("560392904","437032");
        getOrderList(VipShopOrderQueryModel.createOrderSn(Arrays.asList(new String[]{"23090254293903"}),1));
//        getOrderList(VipShopOrderQueryModel.createOrderSn(Arrays.asList(new String[]{"23090254293903"}),1));
    }
}
fanli/src/main/resource/dubbo/consumer.xml
@@ -11,8 +11,8 @@
    <dubbo:annotation package="com.yeshi.fanli"></dubbo:annotation>
    <!--<dubbo:registry  address="zookeeper://172.16.16.46:2181"/>-->
    <dubbo:registry  address="zookeeper://193.112.35.168:2182"/>
    <dubbo:registry  address="zookeeper://172.16.16.46:2181"/>
    <!--<dubbo:registry  address="zookeeper://193.112.35.168:2182"/>-->
    <!-- url=dubbo://192.168.3.122:20882/com.yeshi.goods.facade.service.TaoBaoCouponCacheService -->