admin
2019-10-21 ac1e3863197a4a72784cd02335cb9b1f89026369
双11红包修改
3个文件已修改
1个文件已添加
235 ■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/SearchControllerV2.java 69 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/h5/H5S11Controller.java 145 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/job/order/jd/UpdateJDOrderJob.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/taobao/TaoBaoUtil.java 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/SearchControllerV2.java
@@ -182,6 +182,8 @@
            if (analysisTaoToken(acceptData, text, out)) {
                return;
            }
            if (!StringUtil.isNullOrEmpty(TaoBaoUtil.parseSystemTaoToken(text)))
                return;
            JSONObject root = new JSONObject();
            root.put("type", 2);
@@ -238,17 +240,16 @@
            return;
        } else {
            tb = TaoBaoUtil.parsePhoneShareUrlByTB(text);
            if (tb == null) {
                String goodsId = TaoBaoUtil.getGoodsIdByPhoneShareUrl(text);
                if (!StringUtil.isNullOrEmpty(goodsId)) {
                    tb = TaoBaoUtil.getTmallGoodsInfo(goodsId);
                    if (tb != null)
                    if (tb != null)
                        type = 4;
                }
            }
            if (tb == null)// 淘宝是空值
            {
                String jdId = JDUtil.getJDGoodsId(text);
@@ -256,7 +257,7 @@
                    JDGoods goods = JDApiUtil.getGoodsDetail(Long.parseLong(jdId));
                    if (goods != null) {
                        // 高级接口 -- 信息更完整
                        JDGoods jdGoods = JDApiUtil.queryGoodsDetail(Long.parseLong(jdId));
                        JDGoods jdGoods = JDApiUtil.queryGoodsDetail(Long.parseLong(jdId));
                        if (jdGoods != null) {
                            commonGoods = CommonGoodsFactory.create(jdGoods);
                        } else {
@@ -280,7 +281,7 @@
                        } else {
                            type = 4;
                            goods = PinDuoDuoUtil.getPDDGoodsInfo(pddId);
                            if(goods != null) {
                            if (goods != null) {
                                commonGoods = new CommonGoods();
                                commonGoods.setTitle(goods.getGoodsName());
                                commonGoods.setPicture(goods.getGoodsThumbnailUrl());
@@ -290,42 +291,42 @@
                }
            }
        }
        if (tb == null && commonGoods == null) {
            out.println(JsonUtil.loadFalseResult("暂未找到该商品,请稍后再试!"));
            return;
        }
        if (type == 4) {
            if (!VersionUtil.greaterThan_2_0_1(acceptData.getPlatform(), acceptData.getVersion())) {
                out.println(JsonUtil.loadFalseResult("暂未找到该商品,请稍后再试!"));
                return;
            }
            }
            JSONObject data = new JSONObject();
            if (tb != null) {
                commonGoods = new CommonGoods();
                commonGoods.setTitle(tb.getTitle());
                commonGoods.setPicture(tb.getPictUrl());
            }
            if (StringUtil.isNullOrEmpty(commonGoods.getTitle()) || StringUtil.isNullOrEmpty(commonGoods.getPicture())) {
            if (StringUtil.isNullOrEmpty(commonGoods.getTitle())
                    || StringUtil.isNullOrEmpty(commonGoods.getPicture())) {
                out.println(JsonUtil.loadFalseResult("暂未找到该商品,请稍后再试!"));
                return;
            }
            JSONObject goodsJSON = new JSONObject();
            goodsJSON.put("title", commonGoods.getTitle());
            goodsJSON.put("pictUrl", commonGoods.getPicture());
            data.put("type", type);
            data.put("desc", "该商品无推广信息");
            data.put("goods", goodsJSON);
            out.print(JsonUtil.loadTrueResult(data));
            return;
        }
        }
        JSONObject data = new JSONObject();
        if (VersionUtil.greaterThan_1_6_5(acceptData.getPlatform(), acceptData.getVersion())) {
            if (tb != null) {
@@ -341,7 +342,7 @@
                }
                commonGoods = CommonGoodsFactory.create(goodsBrief);
            }
            BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
            BigDecimal shareRate = hongBaoManageService.getShareRate();
            Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
@@ -383,9 +384,10 @@
        root.put("data", data);
        out.print(JsonUtil.loadTrueResult(root));
    }
    /**
     * 解析抖音链接
     *
     * @param acceptData
     * @param text
     * @param out
@@ -405,7 +407,7 @@
                JSONObject goodsJSON = new JSONObject();
                goodsJSON.put("title", goods.getName());
                goodsJSON.put("pictUrl", goods.getImg());
                JSONObject data = new JSONObject();
                data.put("type", 4);
                data.put("desc", "该商品无推广信息");
@@ -418,10 +420,9 @@
        return;
    }
    /**
     * 解析淘口令
     *
     * @param acceptData
     * @param text
     * @param out
@@ -447,25 +448,25 @@
                        } catch (TaobaoGoodsDownException e) {
                            e.printStackTrace();
                        }
                        if (goodsBrief == null) {
                            out.println(JsonUtil.loadFalseResult("暂未找到该商品,请稍后再试!"));
                            return false;
                        }
                        BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
                        BigDecimal shareRate = hongBaoManageService.getShareRate();
                        Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
                                .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
                        JSONObject data = new JSONObject();
                        data.put("type", 3);
                        data.put("goods", gson.toJson(GoodsDetailVOFactory.convertTaoBao(goodsBrief, null, fanLiRate, shareRate)));
                        data.put("goods", gson
                                .toJson(GoodsDetailVOFactory.convertTaoBao(goodsBrief, null, fanLiRate, shareRate)));
                        out.print(JsonUtil.loadTrueResult(data));
                        return true;
                    }
                    JSONObject data = new JSONObject();
                    JSONObject taoBaoGoodsJSON = new JSONObject();
                    taoBaoGoodsJSON.put("title", tb.getTitle());
@@ -649,7 +650,8 @@
     * @param endprice
     * @return
     */
    private void searchTaoBaoGoods(AcceptData acceptData, String key, Integer page, String filter, Integer order, PrintWriter out) {
    private void searchTaoBaoGoods(AcceptData acceptData, String key, Integer page, String filter, Integer order,
            PrintWriter out) {
        SearchFilter sf = new SearchFilter();
        sf.setKey(SearchFilterUtil.filterSearchContent(key));
        sf.setPage(page);
@@ -750,7 +752,8 @@
                String platform = acceptData.getPlatform();
                TaoBaoShopVO taoBaoShop = listShop.get(0);
                if (("ios".equalsIgnoreCase(platform) && VersionUtil.greaterThan_2_0(platform, acceptData.getVersion()))
                    || ("android".equalsIgnoreCase(platform) && VersionUtil.greaterThan_2_0_1(platform, acceptData.getVersion()))) {
                        || ("android".equalsIgnoreCase(platform)
                                && VersionUtil.greaterThan_2_0_1(platform, acceptData.getVersion()))) {
                    BrandInfoVO brandInfoVO = new BrandInfoVO();
                    brandInfoVO.setId(taoBaoShop.getId());
                    brandInfoVO.setName(taoBaoShop.getShopName());
@@ -776,7 +779,8 @@
     * @param endprice
     * @return
     */
    private void searchJDGoods(AcceptData acceptData, String key, Integer page, String filter, Integer order, PrintWriter out) {
    private void searchJDGoods(AcceptData acceptData, String key, Integer page, String filter, Integer order,
            PrintWriter out) {
        JDSearchResult result = null;
        boolean hasCoupon = false;
@@ -951,7 +955,8 @@
     * @param endprice
     * @return
     */
    private void searchPDDGoods(AcceptData acceptData, String key, Integer page, String filter, Integer order, PrintWriter out) {
    private void searchPDDGoods(AcceptData acceptData, String key, Integer page, String filter, Integer order,
            PrintWriter out) {
        PDDSearchFilter pddfilter = new PDDSearchFilter();
        pddfilter.setKw(SearchFilterUtil.filterSearchContent(key));
        pddfilter.setPage(page);
fanli/src/main/java/com/yeshi/fanli/controller/h5/H5S11Controller.java
New file
@@ -0,0 +1,145 @@
package com.yeshi.fanli.controller.h5;
import java.io.PrintWriter;
import javax.annotation.Resource;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.yeshi.utils.JsonUtil;
import com.yeshi.fanli.entity.bus.user.UserExtraTaoBaoInfo;
import com.yeshi.fanli.log.LogHelper;
import com.yeshi.fanli.service.inter.config.ConfigService;
import com.yeshi.fanli.service.inter.user.tb.UserExtraTaoBaoInfoService;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.RedisManager;
import com.yeshi.fanli.util.StringUtil;
import com.yeshi.fanli.util.taobao.TaoBaoUtil;
import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
@Controller
@RequestMapping("api/apph5/v1/s11")
public class H5S11Controller {
    @Resource
    private UserExtraTaoBaoInfoService userExtraTaoBaoInfoService;
    @Resource
    private RedisManager redisManager;
    @Resource
    private ConfigService configService;
    /**
     * 获取超级红包分享口令
     *
     * @param acceptData
     * @param uid
     * @param out
     */
    @RequestMapping(value = "getSuperHongBaoToken")
    public void getSuperHongBaoToken(String sign, Long uid, String callback, PrintWriter out) {
        if (!StringUtil.Md5(uid + "@?,223Hbb88lll").equalsIgnoreCase(sign)) {
            out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult(1001, "签名错误")));
            return;
        }
        if (uid == null || uid <= 0) {
            out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult(1, "请登录")));
            return;
        }
        UserExtraTaoBaoInfo info = userExtraTaoBaoInfoService.getByUid(uid);
        if (info == null || StringUtil.isNullOrEmpty(info.getRelationId()) || info.getRelationValid() == false) {
            out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult(2, "您尚未绑定淘宝,请前往我的->个人信息 绑定淘宝账号")));
            return;
        }
        String key = "s11-superhongbao-" + info.getRelationId();
        String token = null;
        token = redisManager.getCommonString(key);
        if (StringUtil.isNullOrEmpty(token)) {
            try {
                String link = TaoKeApiUtil.officialActivityConvert("19507100253", "1539329391766",
                        info.getRelationId());
                if (!StringUtil.isNullOrEmpty(link)) {
                    token = TaoKeApiUtil.getTKToken("http://img.flqapp.com/resource/s11/banner.jpg",
                            "【天猫双11】上亿红包等你来拆!", link);
                    if (!StringUtil.isNullOrEmpty(token))
                        redisManager.cacheCommonString(key, token, 60 * 60 * 24);// 缓存1天
                }
            } catch (Exception e) {
                LogHelper.errorDetailInfo(e);
            }
        }
        if (StringUtil.isNullOrEmpty(token)) {
            if (!StringUtil.isNullOrEmpty(callback))
                out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult(1, "口令生成失败,请稍后重试")));
            return;
        }
        String desc = configService.get("super-hongbao-share-desc");
        desc = desc.replace("[淘口令]", TaoBaoUtil.filterTaoToken(token));
        try {
            out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(StringUtil.getBase64String(desc))));
        } catch (Exception e) {
            out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult(1002, "未知错误")));
        }
    }
    @RequestMapping(value = "getYuShouToken")
    public void getYuShouToken(String sign, Long uid, String callback, PrintWriter out) {
        if (!StringUtil.Md5(uid + "@?,223Hbb88lll").equalsIgnoreCase(sign)) {
            out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult(1001, "签名错误")));
            return;
        }
        if (uid == null || uid <= 0) {
            out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult(1, "请登录")));
            return;
        }
        UserExtraTaoBaoInfo info = userExtraTaoBaoInfoService.getByUid(uid);
        if (info == null || StringUtil.isNullOrEmpty(info.getRelationId()) || info.getRelationValid() == false) {
            out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult(2, "您尚未绑定淘宝,请前往我的->个人信息 绑定淘宝账号")));
            return;
        }
        String key = "s11-yushou-" + info.getRelationId();
        String token = null;
        if (Constant.IS_OUTNET)
            token = redisManager.getCommonString(key);
        if (StringUtil.isNullOrEmpty(token)) {
            try {
                String link = TaoKeApiUtil.officialActivityConvert("19507100253", "1539329391766",
                        info.getRelationId());
                if (!StringUtil.isNullOrEmpty(link)) {
                    token = TaoKeApiUtil.getTKToken("http://img.flqapp.com/resource/s11/banner.jpg",
                            "预售商品付定金,得奖金!", link);
                    if (Constant.IS_OUTNET)
                        if (!StringUtil.isNullOrEmpty(token))
                            redisManager.cacheCommonString(key, token, 60 * 60 * 24);// 缓存1天
                }
            } catch (Exception e) {
                LogHelper.errorDetailInfo(e);
            }
        }
        if (StringUtil.isNullOrEmpty(token)) {
            if (!StringUtil.isNullOrEmpty(callback))
                out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult(1, "口令生成失败,请稍后重试")));
            return;
        }
        String desc = configService.get("super-yushou-share-desc");
        desc = desc.replace("[淘口令]", TaoBaoUtil.filterTaoToken(token));
        try {
            out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(StringUtil.getBase64String(desc))));
        } catch (Exception e) {
            out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult(1002, "未知错误")));
        }
    }
}
fanli/src/main/java/com/yeshi/fanli/job/order/jd/UpdateJDOrderJob.java
@@ -64,7 +64,7 @@
        if (!Constant.IS_TASK)
            return;
        LogHelper.orderInfo("开始爬取京东订单");
        LogHelper.job("开始爬取京东订单");
        long now = System.currentTimeMillis();
        JDOrderResult result = JDApiUtil.getOrderList(1, 200, new Date(now), JDApiUtil.ORDER_TYPE_CREATETIME);
fanli/src/main/java/com/yeshi/fanli/util/taobao/TaoBaoUtil.java
@@ -1442,7 +1442,7 @@
            if (goodsBrief.getYsylCommissionRate() != null)
                money = MoneyBigDecimalUtil.mul(
                        MoneyBigDecimalUtil.mul(MoneyBigDecimalUtil.mul(new BigDecimal(goodsBrief.getPresaleDeposit()),
                                goodsBrief.getYsylCommissionRate()), new BigDecimal("0.01")),
                                goodsBrief.getYsylCommissionRate()), new BigDecimal("0.0001")),
                        MoneyBigDecimalUtil.div(rate, new BigDecimal(100)));
            else
                money = MoneyBigDecimalUtil.mul(MoneyBigDecimalUtil.mul(
@@ -2118,6 +2118,23 @@
        return token;
    }
    /**
     * 提取自有格式的淘口令
     * @param str
     * @return
     */
    public static String parseSystemTaoToken(String str) {
        String pattern = "(\\({1}[A-Za-z0-9]+\\){1})";
        Pattern r = Pattern.compile(pattern);
        Matcher m = r.matcher(str);
        while (m.find()) {
            String group = m.group(0);
            if (!StringUtil.isNullOrEmpty(group))
                return group;
        }
        return null;
    }
    public static boolean isSpecialGoods(Integer materialLibType) {
        if (materialLibType != null && materialLibType == 1)
            return true;