admin
2019-07-25 eee931dfb53af971d79329f294fe18958f15c0de
淘宝维权订单采用接口方式爬取
12个文件已修改
219 ■■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/controller/AuthCallBackController.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/admin/UserInfoAdminController.java 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/taobao/TaoBaoWeiQuanOrderMapper.java 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/taobao/TaoBaoWeiQuanOrderMapper.xml 64 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/count/CommonOrderCountServiceImpl.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/taobao/TaoBaoWeiQuanDrawBackServiceImpl.java 55 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/taobao/TaoBaoWeiQuanOrderServiceImpl.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/taobao/dataoke/DaTaoKeGoodsDetailServiceImpl.java 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/taobao/TaoBaoWeiQuanOrderService.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/dataoke/DaTaoKeApiUtil.java 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/factory/AccountDetailsFactory.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/taobao/TaoKeApiUtil.java 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/AuthCallBackController.java
@@ -114,7 +114,7 @@
                String relationId = null;
                try {
                    TaoKeApiUtil.getRelationId(accessToken, TaoBaoConstant.TAOBAO_AUTH_APPKEY,
                    relationId=    TaoKeApiUtil.getRelationId(accessToken, TaoBaoConstant.TAOBAO_AUTH_APPKEY,
                            TaoBaoConstant.TAOBAO_AUTH_APPSECRET);// 渠道ID
                } catch (TaoBaoAuthException e) {
                    if (e.getCode() == TaoBaoAuthException.CODE_NOT_REAL_NAME)
fanli/src/main/java/com/yeshi/fanli/controller/admin/UserInfoAdminController.java
@@ -80,12 +80,12 @@
    @Resource
    private UserMoneyDetailService userMoneyDetailService;
    @Resource
    private UserInfoDeleteRecordService userInfoDeleteRecordService;
    @Resource
    private UserAccountService  userAccountService;
    private UserAccountService userAccountService;
    /**
     * 查询用户信息列表 正常用户/异常用户
@@ -363,7 +363,7 @@
     * @param out
     */
    @RequestMapping(value = "forbiddenUser")
    public void forbiddenUser(String callback, Long uid, HttpServletRequest request,  PrintWriter out) {
    public void forbiddenUser(String callback, Long uid, HttpServletRequest request, PrintWriter out) {
        try {
            if (uid == null) {
@@ -381,12 +381,11 @@
            if (admin == null) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("登录失效,请登录"));
                return;
            }
            }
            String reason = "后台封禁,操作人:" + admin.getId() + "-" + admin.getName();
            userAccountService.forbiddenUserAll(uid, reason);
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("用户封禁成功"));
        } catch (Exception e) {
@@ -764,7 +763,6 @@
        }
        try {
            List<UserMoneyDetail> userMoneyDetailsList = userMoneyDetailService.listByUidWithState(uid, pageIndex,
                    pageSize);
            if (userMoneyDetailsList == null || userMoneyDetailsList.size() == 0) {
@@ -772,18 +770,15 @@
                return;
            }
            List<AccountDetails> detailList = new ArrayList<>();
            for (UserMoneyDetail detail : userMoneyDetailsList)
                detailList.add(AccountDetailsFactory.create(detail));
            long count = userMoneyDetailService.countByUidWithState(uid);
            int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1);
            PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage);
            Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd HH:mm:ss").create();
            JSONObject data = new JSONObject();
            data.put("pe", pe);
            data.put("result_list", GsonUtil.toJsonExpose(detailList));
            data.put("result_list", gson.toJson(userMoneyDetailsList));
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/taobao/TaoBaoWeiQuanOrderMapper.java
@@ -55,4 +55,15 @@
    List<Map<String, Object>> countWeiQaunOrderMoney(@Param("dateType") Integer dateType, @Param("year") String year,
            @Param("startTime") String startTime, @Param("endTime") String endTime);
    /**
     * 根据状态检索
     *
     * @param state
     * @param start
     * @param count
     * @return
     */
    List<TaoBaoWeiQuanOrder> listByState(@Param("state") String state, @Param("start") long start,
            @Param("count") int count);
}
fanli/src/main/java/com/yeshi/fanli/mapping/taobao/TaoBaoWeiQuanOrderMapper.xml
@@ -45,14 +45,26 @@
        from yeshi_ec_taobao_weiqaun_order where tmo_order_id =#{orderId} and
        tmo_state=#{state}
    </select>
    <select id="selectByOrderItemId" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List" />
        from yeshi_ec_taobao_weiqaun_order where tmo_order_item_id =#{0}
    </select>
    <select id="listByState" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List" />
        from yeshi_ec_taobao_weiqaun_order
        <if test="state!=null">
            where tmo_state like '${state}%'
        </if>
        order by tmo_createtime desc limit #{start},#{count}
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from
        yeshi_ec_taobao_weiqaun_order where tmo_id = #{id,jdbcType=BIGINT}
@@ -129,56 +141,62 @@
        </set>
        where tmo_id = #{id,jdbcType=BIGINT}
    </update>
    <sql id="Column_DateType">
        <if test="dateType == 1">
            DATE_FORMAT(t.`tmo_createtime`,'%Y-%m-%d') AS 'showDate'
            DATE_FORMAT(t.`tmo_weiquan_time`,'%Y-%m-%d') AS 'showDate'
        </if>
        <if test="dateType == 2">
            DATE_FORMAT(t.`tmo_createtime`,'%m') AS 'showDate'
            DATE_FORMAT(t.`tmo_weiquan_time`,'%m') AS 'showDate'
        </if>
        <if test="dateType == 3">
            DATE_FORMAT(t.`tmo_createtime`,'%Y') AS 'showDate'
            DATE_FORMAT(t.`tmo_weiquan_time`,'%Y') AS 'showDate'
        </if>
    </sql>
    <sql id="Count_Select_DateType">
        <if test="startTime != null and startTime != '' ">
            AND DATE_FORMAT(t.`tmo_createtime`,'%Y-%m-%d')<![CDATA[ >= ]]>'${startTime}'
            AND DATE_FORMAT(t.`tmo_weiquan_time`,'%Y-%m-%d')<![CDATA[ >= ]]>'${startTime}'
        </if>
        <if test="endTime != null and endTime != '' ">
            AND DATE_FORMAT(t.`tmo_createtime`,'%Y-%m-%d') <![CDATA[ <= ]]>'${endTime}'
            AND DATE_FORMAT(t.`tmo_weiquan_time`,'%Y-%m-%d') <![CDATA[ <= ]]>'${endTime}'
        </if>
        <if test="year != null and year != '' ">
            AND DATE_FORMAT(t.`tmo_createtime`,'%Y') = '${year}'
            AND DATE_FORMAT(t.`tmo_weiquan_time`,'%Y') = '${year}'
        </if>
    </sql>
    <sql id="Count_Group_DateType">
        <if test="dateType == 1">
            GROUP BY DATE_FORMAT(t.`tmo_createtime`,'%Y-%m-%d')
            GROUP BY DATE_FORMAT(t.`tmo_weiquan_time`,'%Y-%m-%d')
        </if>
        <if test="dateType == 2">
            GROUP BY DATE_FORMAT(t.`tmo_createtime`,'%Y-%m')
            GROUP BY DATE_FORMAT(t.`tmo_weiquan_time`,'%Y-%m')
        </if>
        <if test="dateType == 3">
            GROUP BY DATE_FORMAT(t.`tmo_createtime`,'%Y')
            GROUP BY DATE_FORMAT(t.`tmo_weiquan_time`,'%Y')
        </if>
    </sql>
    <select id="countWeiQaunOrderNumber" resultType="java.util.HashMap">
        SELECT  IFNULL(COUNT(t.`tmo_id`),0) AS showValue,<include refid="Column_DateType"/>
        SELECT IFNULL(COUNT(t.`tmo_id`),0) AS showValue,
        <include refid="Column_DateType" />
        FROM yeshi_ec_taobao_weiqaun_order t
        WHERE t.`tmo_createtime`IS NOT NULL  <include refid="Count_Select_DateType"/>
        <include refid="Count_Group_DateType"/>
        ORDER BY t.`tmo_createtime`
        WHERE t.`tmo_createtime`IS NOT
        NULL
        <include refid="Count_Select_DateType" />
        <include refid="Count_Group_DateType" />
        ORDER BY t.`tmo_weiquan_time`
    </select>
    <select id="countWeiQaunOrderMoney" resultType="java.util.HashMap">
        SELECT  CAST(SUM(t.`tmo_fan_money`)AS DECIMAL(19,2)) AS showValue,<include refid="Column_DateType"/>
        SELECT CAST(SUM(t.`tmo_fan_money`)AS DECIMAL(19,2)) AS showValue,
        <include refid="Column_DateType" />
        FROM yeshi_ec_taobao_weiqaun_order t
        WHERE  t.`tmo_createtime` IS NOT NULL  <include refid="Count_Select_DateType"/>
        <include refid="Count_Group_DateType"/>
        ORDER BY t.`tmo_createtime`
        WHERE t.`tmo_createtime` IS NOT
        NULL
        <include refid="Count_Select_DateType" />
        <include refid="Count_Group_DateType" />
        ORDER BY t.`tmo_weiquan_time`
    </select>
</mapper>
fanli/src/main/java/com/yeshi/fanli/service/impl/count/CommonOrderCountServiceImpl.java
@@ -221,7 +221,6 @@
    public List<Map<String, Object>> countWeiQaunOrderNumber(Integer dateType, String year, String startTime,
            String endTime) throws Exception{
        return taoBaoWeiQuanOrderMapper.countWeiQaunOrderNumber(dateType, year, startTime, endTime);
    }
    
    @Override
fanli/src/main/java/com/yeshi/fanli/service/impl/taobao/TaoBaoWeiQuanDrawBackServiceImpl.java
@@ -498,36 +498,41 @@
                    weiQuanDrawBack.setUser(child.getUserInfo());
                    taoBaoWeiQuanDrawBackMapper.insertSelective(weiQuanDrawBack);// 加入返还记录
                    // 判断资金是否足够扣款
                    UserInfo user = userInfoMapper.selectByPKey(uid);
                    if (user != null && user.getMyHongBao().compareTo(drawBackMoney) < 0)// 资金不足
                    {
                        try {
                            addDebt(uid, child.getId(), drawBackMoney);
                        } catch (UserMoneyDebtException e) {
                            throw new TaoBaoWeiQuanException(101, "资金借贷异常");
                    // 如果资金大于0才扣除
                    if (drawBackMoney != null && drawBackMoney.compareTo(new BigDecimal(0)) > 0) {
                        // 判断资金是否足够扣款
                        UserInfo user = userInfoMapper.selectByPKey(uid);
                        if (user != null && user.getMyHongBao().compareTo(drawBackMoney) < 0)// 资金不足
                        {
                            try {
                                addDebt(uid, child.getId(), drawBackMoney);
                            } catch (UserMoneyDebtException e) {
                                throw new TaoBaoWeiQuanException(101, "资金借贷异常");
                            }
                            continue;
                        }
                        continue;
                    }
                    UserMoneyDetail userMoneyDetail = null;
                    // 新版资金记录
                    try {
                        userMoneyDetail = UserMoneyDetailFactory.createInviteWeiQuan(uid, weiQuanDrawBack,
                                drawBackMoney);
                    } catch (UserMoneyDetailException e) {
                        UserMoneyDetail userMoneyDetail = null;
                        // 新版资金记录
                        try {
                            LogHelper.errorDetailInfo(e);
                        } catch (Exception e1) {
                            e1.printStackTrace();
                            userMoneyDetail = UserMoneyDetailFactory.createInviteWeiQuan(uid, weiQuanDrawBack,
                                    drawBackMoney);
                        } catch (UserMoneyDetailException e) {
                            try {
                                LogHelper.errorDetailInfo(e);
                            } catch (Exception e1) {
                                e1.printStackTrace();
                            }
                        }
                        userMoneyService.subUserMoney(uid, drawBackMoney, userMoneyDetail);
                        // 新版通知
                        userMoneyMsgNotificationService.inviteOrderWeiQuan(uid, orderId, drawBackMoney,
                                userInfoMapper.selectByPrimaryKey(uid).getMyHongBao());
                    }
                    userMoneyService.subUserMoney(uid, drawBackMoney, userMoneyDetail);
                    // 新版通知
                    userMoneyMsgNotificationService.inviteOrderWeiQuan(uid, orderId, drawBackMoney,
                            userInfoMapper.selectByPrimaryKey(uid).getMyHongBao());
                }
        }
    }
fanli/src/main/java/com/yeshi/fanli/service/impl/taobao/TaoBaoWeiQuanOrderServiceImpl.java
@@ -36,8 +36,7 @@
                .selectByOrderIdAndOrderItemId(order.getOrderId(), order.getOrderItemId());
        if (taoBaoWeiQuanOrder != null) {
            // 已经是最新的状态了
            if (taoBaoWeiQuanOrder.getState().contains("维权成功")
                    || taoBaoWeiQuanOrder.getState().contains("维权失败"))
            if (taoBaoWeiQuanOrder.getState().contains("维权成功") || taoBaoWeiQuanOrder.getState().contains("维权失败"))
                return;
            // 更新金额,状态与时间
            TaoBaoWeiQuanOrder update = new TaoBaoWeiQuanOrder();
@@ -86,4 +85,9 @@
        return taoBaoWeiQuanOrderMapper.selectByOrderItemId(tradeId);
    }
    @Override
    public List<TaoBaoWeiQuanOrder> listByState(String state, int page, int pageSize) {
        return taoBaoWeiQuanOrderMapper.listByState(state, (page - 1) * pageSize, pageSize);
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/taobao/dataoke/DaTaoKeGoodsDetailServiceImpl.java
@@ -167,6 +167,18 @@
        return list;
    }
    private void updateGoods(Long id) {
        DaTaoKeDetail detail = daTaoKeDetailMapper.selectByPrimaryKey(id);
        if (detail != null)
            return;
        detail = DaTaoKeApiUtil.getGoodsDetailV1(id);
        if (detail != null) {
            List<DaTaoKeDetail> list = new ArrayList<>();
            list.add(detail);
            addGoodsList(list);
        }
    }
    @Cacheable(value = "daTaoKeGoodsCache", key = "'getDingDongQiangData-'+#time")
    @Override
    public List<DaTaoKeDetail> getDingDongQiangData(String time) {
@@ -175,7 +187,6 @@
            return null;
        Map<String, DingDongQiangDTO> map = new HashMap<>();
        for (DingDongQiangDTO dto : list)
            map.put(dto.getTime(), dto);
        DingDongQiangDTO dto = map.get(time);
@@ -184,6 +195,12 @@
            for (DaTaoKeDetail td : dto.getGoodsList())
                idList.add(td.getId());
            List<DaTaoKeDetail> finalList = listByIds(idList);
            if (finalList.size() != idList.size()) {
                for (Long id : idList)
                    updateGoods(id);
                finalList = listByIds(idList);
            }
            for (DaTaoKeDetail detail : finalList) {
                detail.setQuanReceive(
                        detail.getQuanSurplus() + detail.getQuanReceive() - (int) (200 + Math.random() * 1000));
fanli/src/main/java/com/yeshi/fanli/service/inter/taobao/TaoBaoWeiQuanOrderService.java
@@ -28,5 +28,15 @@
     * @return
     */
    public TaoBaoWeiQuanOrder listByorderItemId(String tradeId);
    /**
     * 根据状态检索
     * @param state
     * @param page
     * @param pageSize
     * @return
     */
    public List<TaoBaoWeiQuanOrder> listByState(String state,int page,int pageSize);
}
fanli/src/main/java/com/yeshi/fanli/util/dataoke/DaTaoKeApiUtil.java
@@ -30,7 +30,6 @@
import com.yeshi.fanli.entity.taobao.TaoKeAppInfo;
import com.yeshi.fanli.entity.taobao.dataoke.DaTaoKeDetail;
import com.yeshi.fanli.entity.taobao.dataoke.DaTaoKeDetailV2;
import com.yeshi.fanli.log.LogHelper;
import com.yeshi.fanli.util.MoneyBigDecimalUtil;
import com.yeshi.fanli.util.StringUtil;
@@ -120,6 +119,14 @@
                resultJson.optJSONObject("data").optString("update_time"), list);
    }
    public static DaTaoKeDetail getGoodsDetailV1(Long id) {
        String url = String.format("http://api.dataoke.com/index.php?r=Port/index&type=total&appkey=%s&v=2&id=%s",
                Math.random() > 0.5 ? API_KEY : API_KEY_2, id + "");
        String result = request(url);
        JSONObject resultJson = JSONObject.fromObject(result);
        return gson.fromJson(resultJson.optJSONArray("result").optJSONObject(0).toString(), DaTaoKeDetail.class);
    }
    /**
     * 获取大淘客品牌优选 品牌id
     * 
fanli/src/main/java/com/yeshi/fanli/util/factory/AccountDetailsFactory.java
@@ -109,7 +109,7 @@
            accountDetails.setType(AccountDetailsFactory.TUIKUAN);
        else
            accountDetails.setType(AccountDetailsFactory.QITA);
        accountDetails.setTitle(map.get(accountDetails.getType()));
        accountDetails.setTitle(accountDetails.getTitle());
        accountDetails.setUserInfo(userMoneyDetail.getUserInfo());
        return accountDetails;
    }
fanli/src/main/java/com/yeshi/fanli/util/taobao/TaoKeApiUtil.java
@@ -2100,6 +2100,23 @@
        }
        return null;
    }
    public static void getCouponByAuctionId(Long auctionId) {
        Map<String, String> map = new HashMap<>();
        map.put("method", "taobao.tbk.itemid.coupon.get");
        map.put("platform", 2 + "");
        map.put("pid", TaoBaoConstant.TAOBAO_RELATION_AS_SPECIAL_PID);
        map.put("num_iids", auctionId + "");
        TaoKeAppInfo app = new TaoKeAppInfo();
        app.setAppKey(TaoBaoConstant.TAOBAO_AUTH_APPKEY);
        app.setAppSecret(TaoBaoConstant.TAOBAO_AUTH_APPSECRET);
        try {
            JSONObject json = TaoKeBaseUtil.baseRequest(map, app);
            System.out.print(json);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
class QuanInfo {