| | |
| | | * @return |
| | | */ |
| | | UserExtraTaoBaoInfo selectByUid(Long uid); |
| | | |
| | | |
| | | /** |
| | | * 根据淘宝UID查询 |
| | | * |
| | | * @param taoBaoUid |
| | | * @return |
| | | */ |
| | | UserExtraTaoBaoInfo selectByTaoBaoUid(String taoBaoUid); |
| | | |
| | | |
| | | /** |
| | | * 清除用户ID |
| | | * |
| | | * @param uid |
| | | * @return |
| | | */ |
| | | int clearUid(Long uid); |
| | | |
| | | /** |
| | | * 通过渠道ID查询 |
| | | * |
| | | * @param relationId |
| | | * @return |
| | | */ |
| | | UserExtraTaoBaoInfo selectByRelationIdWithUidNotNull(String relationId); |
| | | |
| | | /** |
| | | * 通过会员运营ID查询 |
| | | * |
| | | * @param specialId |
| | | * @return |
| | | */ |
| | | UserExtraTaoBaoInfo selectBySpecialIdWithUidNotNull(String specialId); |
| | | |
| | | } |
| | |
| | |
|
| | | }
|
| | |
|
| | | private void addRelationAndSpecialOrder(List<TaoBaoOrder> orderList) {
|
| | | try {
|
| | | taoBaoOrderService.addTaoBaoOrderList(orderList);
|
| | | } catch (Exception e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | try {
|
| | | Map<String, List<TaoBaoOrder>> map = TaoBaoOrderUtil.classifyTaoBaoOrderByOrderId(orderList);
|
| | | if (map != null) {
|
| | | Iterator<String> its = map.keySet().iterator();
|
| | | while (its.hasNext()) {
|
| | | String key = its.next();
|
| | | List<TaoBaoOrder> orders = map.get(key);
|
| | | String redisKey = "addorderqueue-" + key;
|
| | | // redis做频率限制
|
| | | try {
|
| | | if (!StringUtil.isNullOrEmpty(redisManager.getCommonString(redisKey))) {
|
| | | continue;
|
| | | }
|
| | |
|
| | | } catch (Exception e) {
|
| | |
|
| | | }
|
| | |
|
| | | CMQManager.getInstance().addTaoBaoOrderMsg(key, orders);
|
| | |
|
| | | try {
|
| | | // 6小时内不再处理
|
| | | redisManager.cacheCommonString(redisKey, "1", 60 * 60 * 6);
|
| | | } catch (Exception e) {
|
| | |
|
| | | }
|
| | | }
|
| | | }
|
| | | } catch (Exception e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | private void addOrder(List<TaoBaoOrder> orderList) {
|
| | |
|
| | | if (orderList != null)
|
| | | for (int i = 0; i < orderList.size(); i++) {
|
| | | // 移除会员运营ID与渠道专属订单
|
| | | if (orderList.get(i).getAdPositionName().contains("会员运营")
|
| | | || orderList.get(i).getAdPositionName().contains("渠道专属")) {
|
| | | orderList.remove(i);
|
| | | i--;
|
| | | }
|
| | | }
|
| | |
|
| | | try {
|
| | | taoBaoOrderService.addTaoBaoOrderList(orderList);
|
| | | } catch (Exception e) {
|
New file |
| | |
| | | package com.yeshi.fanli.job;
|
| | |
|
| | | import java.util.Iterator;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.scheduling.annotation.Scheduled;
|
| | | import org.springframework.stereotype.Component;
|
| | |
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoOrder;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoOrderService;
|
| | | import com.yeshi.fanli.util.CMQManager;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.RedisManager;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoBaoOrderUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
|
| | |
|
| | | /**
|
| | | * 淘宝渠道订单更新
|
| | | * |
| | | * @author hexiaohui
|
| | | *
|
| | | */
|
| | | @Component
|
| | | public class UpdateRelationAndSpecialOrderJob {
|
| | |
|
| | | @Resource
|
| | | private TaoBaoOrderService taoBaoOrderService;
|
| | |
|
| | | @Resource
|
| | | private RedisManager redisManager;
|
| | |
|
| | | private void updateRelationOrder(long startTime) {
|
| | | String startTimeStr = TimeUtil.getGernalTime(startTime, "yyyy-MM-dd HH:mm:ss");
|
| | | List<TaoBaoOrder> orderList = TaoKeApiUtil.getTaoBaoRelationOrder(startTimeStr, Constant.TAOBAO_AUTH_APPKEY,
|
| | | Constant.TAOBAO_AUTH_APPSECRET);
|
| | | addRelationAndSpecialOrder(orderList);
|
| | | }
|
| | |
|
| | | private void updateSpecialOrder(long startTime) {
|
| | | String startTimeStr = TimeUtil.getGernalTime(startTime, "yyyy-MM-dd HH:mm:ss");
|
| | | List<TaoBaoOrder> orderList = TaoKeApiUtil.getTaoBaoSpecialOrder(startTimeStr, Constant.TAOBAO_AUTH_APPKEY,
|
| | | Constant.TAOBAO_AUTH_APPSECRET);
|
| | | addRelationAndSpecialOrder(orderList);
|
| | | }
|
| | |
|
| | | private void addRelationAndSpecialOrder(List<TaoBaoOrder> orderList) {
|
| | | try {
|
| | | taoBaoOrderService.addTaoBaoOrderList(orderList);
|
| | | } catch (Exception e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | try {
|
| | | Map<String, List<TaoBaoOrder>> map = TaoBaoOrderUtil.classifyTaoBaoOrderByOrderId(orderList);
|
| | | if (map != null) {
|
| | | Iterator<String> its = map.keySet().iterator();
|
| | | while (its.hasNext()) {
|
| | | String key = its.next();
|
| | | List<TaoBaoOrder> orders = map.get(key);
|
| | | String redisKey = "addorderqueue-" + key;
|
| | | // redis做频率限制
|
| | | try {
|
| | | if (!StringUtil.isNullOrEmpty(redisManager.getCommonString(redisKey))) {
|
| | | continue;
|
| | | }
|
| | |
|
| | | } catch (Exception e) {
|
| | |
|
| | | }
|
| | |
|
| | | CMQManager.getInstance().addTaoBaoOrderMsg(key, orders);
|
| | |
|
| | | try {
|
| | | // 20分钟内不再处理
|
| | | redisManager.cacheCommonString(redisKey, "1", 60 * 20);
|
| | | } catch (Exception e) {
|
| | |
|
| | | }
|
| | | }
|
| | | }
|
| | | } catch (Exception e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | // 每30s爬取一次
|
| | | @Scheduled(cron = "0/30 * * * * ? ")
|
| | | public void doJob1() {
|
| | | if (!Constant.IS_TASK)
|
| | | return;
|
| | | long currentTime = System.currentTimeMillis();
|
| | | updateRelationOrder(currentTime);
|
| | | updateSpecialOrder(currentTime);
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | </select> |
| | | |
| | | |
| | | <select id="selectByCommonOrderId" resultMap="BaseResultMap" |
| | | <select id="selectByCommonOrderId" resultMap="BaseDetailResultMap" |
| | | parameterType="java.lang.Long"> |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | |
| | | jdbcType="VARCHAR" /> |
| | | <result column="to_latest_updatetime" property="latestUpdateTime" |
| | | jdbcType="TIMESTAMP" /> |
| | | |
| | | <result column="to_orderby" property="orderBy" jdbcType="INTEGER" /> |
| | | <result column="to_relation_id" property="relationId" jdbcType="VARCHAR" /> |
| | | <result column="to_special_id" property="specialId" jdbcType="VARCHAR" /> |
| | | </resultMap> |
| | | |
| | | |
| | | |
| | | <sql id="Base_Column_List">to_id,to_create_time,to_click_time,to_title,to_auction_id,to_manager_wangwang,to_shop,to_count,to_price,to_order_state,to_order_type,to_iratio,to_sratio,to_payment,to_estimate,to_settlement,to_eIncome,to_settlement_time,to_tk_rate,to_tk_money,to_technology_support_percent,to_subsidy_ratio,to_subsidy,to_subsidy_type,to_transaction_platform,to_third_service,to_order_id,to_class_name,to_source_media_id,to_source_media_name,to_ad_position_id,to_ad_position_name,to_latest_updatetime,to_orderby |
| | | |
| | | |
| | | <sql id="Base_Column_List">to_id,to_create_time,to_click_time,to_title,to_auction_id,to_manager_wangwang,to_shop,to_count,to_price,to_order_state,to_order_type,to_iratio,to_sratio,to_payment,to_estimate,to_settlement,to_eIncome,to_settlement_time,to_tk_rate,to_tk_money,to_technology_support_percent,to_subsidy_ratio,to_subsidy,to_subsidy_type,to_transaction_platform,to_third_service,to_order_id,to_class_name,to_source_media_id,to_source_media_name,to_ad_position_id,to_ad_position_name,to_latest_updatetime,to_orderby,to_relation_id,to_special_id |
| | | </sql> |
| | | |
| | | <select id="selectByPrimaryKey" resultMap="BaseResultMap" |
| | |
| | | <include refid="Base_Column_List" /> |
| | | from yeshi_ec_taobao_order where to_order_id = #{0} |
| | | </select> |
| | | |
| | | |
| | | |
| | | |
| | | <select id="selectLatestByAuctionId" resultMap="BaseResultMap" |
| | | parameterType="java.lang.Long"> |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | | from yeshi_ec_taobao_order where to_auction_id = #{0} order by to_id desc limit 1 |
| | | from yeshi_ec_taobao_order where to_auction_id = #{0} order by to_id |
| | | desc limit 1 |
| | | </select> |
| | | |
| | | |
| | | |
| | | |
| | | <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from |
| | |
| | | |
| | | <insert id="insert" parameterType="com.yeshi.fanli.entity.taobao.TaoBaoOrder" |
| | | useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_taobao_order |
| | | (to_id,to_create_time,to_click_time,to_title,to_auction_id,to_manager_wangwang,to_shop,to_count,to_price,to_order_state,to_order_type,to_iratio,to_sratio,to_payment,to_estimate,to_settlement,to_eIncome,to_settlement_time,to_tk_rate,to_tk_money,to_technology_support_percent,to_subsidy_ratio,to_subsidy,to_subsidy_type,to_transaction_platform,to_third_service,to_order_id,to_class_name,to_source_media_id,to_source_media_name,to_ad_position_id,to_ad_position_name,to_latest_updatetime,to_orderby) |
| | | (to_id,to_create_time,to_click_time,to_title,to_auction_id,to_manager_wangwang,to_shop,to_count,to_price,to_order_state,to_order_type,to_iratio,to_sratio,to_payment,to_estimate,to_settlement,to_eIncome,to_settlement_time,to_tk_rate,to_tk_money,to_technology_support_percent,to_subsidy_ratio,to_subsidy,to_subsidy_type,to_transaction_platform,to_third_service,to_order_id,to_class_name,to_source_media_id,to_source_media_name,to_ad_position_id,to_ad_position_name,to_latest_updatetime,to_orderby,to_relation_id,to_special_id) |
| | | values |
| | | (#{id,jdbcType=BIGINT},#{createTime,jdbcType=VARCHAR},#{clickTime,jdbcType=VARCHAR},#{title,jdbcType=VARCHAR},#{auctionId,jdbcType=BIGINT},#{managerWangWang,jdbcType=VARCHAR},#{shop,jdbcType=VARCHAR},#{count,jdbcType=INTEGER},#{price,jdbcType=DECIMAL},#{orderState,jdbcType=VARCHAR},#{orderType,jdbcType=VARCHAR},#{iRatio,jdbcType=DECIMAL},#{sRatio,jdbcType=DECIMAL},#{payment,jdbcType=DECIMAL},#{estimate,jdbcType=DECIMAL},#{settlement,jdbcType=DECIMAL},#{eIncome,jdbcType=DECIMAL},#{settlementTime,jdbcType=VARCHAR},#{tkRate,jdbcType=DECIMAL},#{tkMoney,jdbcType=DECIMAL},#{technologySupportPercent,jdbcType=DECIMAL},#{subsidyRatio,jdbcType=DECIMAL},#{subsidy,jdbcType=DECIMAL},#{subsidyType,jdbcType=VARCHAR},#{transactionPlatform,jdbcType=VARCHAR},#{thirdService,jdbcType=VARCHAR},#{orderId,jdbcType=VARCHAR},#{className,jdbcType=VARCHAR},#{sourceMediaId,jdbcType=VARCHAR},#{sourceMediaName,jdbcType=VARCHAR},#{adPositionId,jdbcType=VARCHAR},#{adPositionName,jdbcType=VARCHAR},#{latestUpdateTime,jdbcType=TIMESTAMP},#{orderBy,jdbcType=INTEGER}) |
| | | (#{id,jdbcType=BIGINT},#{createTime,jdbcType=VARCHAR},#{clickTime,jdbcType=VARCHAR},#{title,jdbcType=VARCHAR},#{auctionId,jdbcType=BIGINT},#{managerWangWang,jdbcType=VARCHAR},#{shop,jdbcType=VARCHAR},#{count,jdbcType=INTEGER},#{price,jdbcType=DECIMAL},#{orderState,jdbcType=VARCHAR},#{orderType,jdbcType=VARCHAR},#{iRatio,jdbcType=DECIMAL},#{sRatio,jdbcType=DECIMAL},#{payment,jdbcType=DECIMAL},#{estimate,jdbcType=DECIMAL},#{settlement,jdbcType=DECIMAL},#{eIncome,jdbcType=DECIMAL},#{settlementTime,jdbcType=VARCHAR},#{tkRate,jdbcType=DECIMAL},#{tkMoney,jdbcType=DECIMAL},#{technologySupportPercent,jdbcType=DECIMAL},#{subsidyRatio,jdbcType=DECIMAL},#{subsidy,jdbcType=DECIMAL},#{subsidyType,jdbcType=VARCHAR},#{transactionPlatform,jdbcType=VARCHAR},#{thirdService,jdbcType=VARCHAR},#{orderId,jdbcType=VARCHAR},#{className,jdbcType=VARCHAR},#{sourceMediaId,jdbcType=VARCHAR},#{sourceMediaName,jdbcType=VARCHAR},#{adPositionId,jdbcType=VARCHAR},#{adPositionName,jdbcType=VARCHAR}, |
| | | #{latestUpdateTime,jdbcType=TIMESTAMP},#{orderBy,jdbcType=INTEGER}, |
| | | #{relationId,jdbcType=VARCHAR},#{specialId,jdbcType=VARCHAR} |
| | | ) |
| | | </insert> |
| | | <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.taobao.TaoBaoOrder" |
| | | useGeneratedKeys="true" keyProperty="id"> |
| | |
| | | <if test="adPositionName != null">to_ad_position_name,</if> |
| | | <if test="latestUpdateTime != null">to_latest_updatetime,</if> |
| | | <if test="orderBy != null">to_orderby,</if> |
| | | <if test="relationId != null">to_relation_id,</if> |
| | | <if test="specialId != null">to_special_id,</if> |
| | | </trim> |
| | | values |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | |
| | | <if test="adPositionName != null">#{adPositionName,jdbcType=VARCHAR},</if> |
| | | <if test="latestUpdateTime != null">#{latestUpdateTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="orderBy != null">#{orderBy,jdbcType=INTEGER},</if> |
| | | |
| | | |
| | | <if test="relationId != null">#{relationId,jdbcType=VARCHAR},</if> |
| | | <if test="specialId != null">#{specialId,jdbcType=VARCHAR},</if> |
| | | |
| | | |
| | | |
| | | </trim> |
| | | </insert> |
| | | <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.taobao.TaoBaoOrder">update |
| | |
| | | #{adPositionId,jdbcType=VARCHAR},to_ad_position_name = |
| | | #{adPositionName,jdbcType=VARCHAR},to_latest_updatetime = |
| | | #{latestUpdateTime,jdbcType=TIMESTAMP},to_orderby= |
| | | #{orderBy,jdbcType=INTEGER} |
| | | where to_id = |
| | | #{orderBy,jdbcType=INTEGER},to_relation_id = |
| | | #{relationId,jdbcType=VARCHAR},to_special_id= |
| | | #{specialId,jdbcType=VARCHAR} |
| | | where to_id = |
| | | #{id,jdbcType=BIGINT} |
| | | </update> |
| | | <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.taobao.TaoBaoOrder"> |
| | |
| | | <if test="latestUpdateTime != null">to_latest_updatetime=#{latestUpdateTime,jdbcType=TIMESTAMP}, |
| | | </if> |
| | | <if test="orderBy != null">to_orderby=#{orderBy,jdbcType=INTEGER}, |
| | | </if> |
| | | <if test="relationId != null">to_relation_id=#{relationId,jdbcType=VARCHAR}, |
| | | </if> |
| | | <if test="specialId != null">to_special_id=#{specialId,jdbcType=VARCHAR}, |
| | | </if> |
| | | </set> |
| | | where to_id = #{id,jdbcType=BIGINT} |
| | |
| | | where to_order_id = #{orderId} and |
| | | to_payment = #{payment} |
| | | </select> |
| | | |
| | | |
| | | <sql id="Column_DateType"> |
| | | |
| | | |
| | | <sql id="Column_DateType"> |
| | | <if test="dateType == 1"> |
| | | DATE_FORMAT(t.`to_create_time`,'%Y-%m-%d') AS 'showDate' |
| | | </if> |
| | |
| | | </sql> |
| | | |
| | | <select id="countOrderNumber" resultType="java.util.HashMap"> |
| | | SELECT IFNULL(COUNT(t.`to_id`),0) AS showValue,<include refid="Column_DateType"/> |
| | | FROM `yeshi_ec_taobao_order` t |
| | | WHERE t.`to_create_time` IS NOT NULL <include refid="Count_Select_DateType"/> |
| | | <include refid="Count_Group_DateType"/> |
| | | SELECT IFNULL(COUNT(t.`to_id`),0) AS showValue, |
| | | <include refid="Column_DateType" /> |
| | | FROM `yeshi_ec_taobao_order` t |
| | | WHERE t.`to_create_time` IS NOT NULL |
| | | <include refid="Count_Select_DateType" /> |
| | | <include refid="Count_Group_DateType" /> |
| | | ORDER BY t.`to_create_time` |
| | | </select> |
| | | |
| | | |
| | | |
| | | |
| | | </mapper> |
| | |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | | from yeshi_ec_user_info_extra_taobao where uiet_taobao_uid = |
| | | #{0} limit 1 |
| | | #{0} limit |
| | | 1 |
| | | </select> |
| | | |
| | | |
| | | <select id="selectByRelationIdWithUidNotNull" resultMap="BaseResultMap" |
| | | parameterType="java.lang.String"> |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | | from yeshi_ec_user_info_extra_taobao where uiet_relation_id = |
| | | #{0} and |
| | | uiet_uid is not null limit 1 |
| | | </select> |
| | | |
| | | |
| | | |
| | | <select id="selectBySpecialIdWithUidNotNull" resultMap="BaseResultMap" |
| | | parameterType="java.lang.String"> |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | | from yeshi_ec_user_info_extra_taobao where uiet_special_id = |
| | | #{0} and |
| | | uiet_uid is not null limit 1 |
| | | </select> |
| | | |
| | | <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from |
| | | yeshi_ec_user_info_extra_taobao where uiet_id = #{id,jdbcType=BIGINT} |
| | | </delete> |
| | |
| | | taoBaoLink.setCouponLink(goods.getCouponLink());
|
| | | taoBaoLink.setGoods(goods);
|
| | |
|
| | | TaoBaoGoodsBrief taoBaoGoods = null;
|
| | | try {
|
| | | taoBaoGoods = TaoKeApiUtil.getSimpleGoodsInfo(auctionId);
|
| | | } catch (TaobaoGoodsDownException e) {
|
| | | throw new ShareGoodsException(2, "商品为空");
|
| | | }
|
| | |
|
| | | String url = goods.getAuctionUrl();
|
| | | if (!StringUtil.isNullOrEmpty(goods.getCouponLink()))
|
| | | url = goods.getCouponLink();
|
| | | String token = TaoKeApiUtil.getTKToken(taoBaoGoods.getPictUrl(), taoBaoGoods.getTitle(), url);
|
| | | taoBaoLink.setTaoToken(token);
|
| | | return taoBaoLink;
|
| | | }
|
| | |
|
| | |
| | | import com.yeshi.fanli.entity.bus.user.HongBao;
|
| | | import com.yeshi.fanli.entity.bus.user.HongBaoV2;
|
| | | import com.yeshi.fanli.entity.bus.user.Order;
|
| | | import com.yeshi.fanli.entity.bus.user.UserExtraTaoBaoInfo;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | | import com.yeshi.fanli.entity.money.UserMoneyDetail;
|
| | | import com.yeshi.fanli.entity.order.CommonOrder;
|
| | |
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoOrderService;
|
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoUnionConfigService;
|
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoWeiQuanDrawBackService;
|
| | | import com.yeshi.fanli.service.inter.user.UserExtraTaoBaoInfoService;
|
| | | import com.yeshi.fanli.service.inter.user.UserNotificationService;
|
| | | import com.yeshi.fanli.util.CMQManager;
|
| | | import com.yeshi.fanli.util.RedisManager;
|
| | |
| | | @Resource
|
| | | private UserMoneyMsgNotificationService userMoneyMsgNotificationService;
|
| | |
|
| | | @Resource
|
| | | private UserExtraTaoBaoInfoService userExtraTaoBaoInfoService;
|
| | |
|
| | | @Override
|
| | | public void processOrder(Map<String, List<TaoBaoOrder>> orders) {
|
| | | List<TaoBaoUnionConfig> configList = taoBaoUnionConfigService.getConfigByTypeCache(PidUser.TYPE_FANLI_ANDROID);
|
| | |
| | | String orderId = its.next();
|
| | | if (orders.get(orderId) != null && orders.get(orderId).size() > 0) {
|
| | | List<TaoBaoOrder> list = orders.get(orderId);
|
| | | String pid = String.format("mm_%s_%s_%s", configList.get(0).getAccountId(),
|
| | | list.get(0).getSourceMediaId(), list.get(0).getAdPositionId());
|
| | | PidUser pidUser = pidUserMapper.selectByPid(pid);
|
| | | if (pidUser != null && pidUser.getType() == PidUser.TYPE_SHARE_GOODS) {// 商品分享订单
|
| | | // List<PidOrder> pidOrderList = new ArrayList<>();
|
| | | // for (TaoBaoOrder order : list) {
|
| | | // pidOrderList.add(TaoBaoOrderUtil.convertToPidOrder(order));
|
| | | // }
|
| | | // sharePidOrderMap.put(orderId, pidOrderList);
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(list.get(0).getRelationId())) {
|
| | | shareOrderMap.put(orderId, list);
|
| | | } else {// 普通返利订单
|
| | | } else if (!StringUtil.isNullOrEmpty(list.get(0).getSpecialId())) {
|
| | | fanliOrderMap.put(orderId, list);
|
| | | } else {
|
| | | String pid = String.format("mm_%s_%s_%s", configList.get(0).getAccountId(),
|
| | | list.get(0).getSourceMediaId(), list.get(0).getAdPositionId());
|
| | | PidUser pidUser = pidUserMapper.selectByPid(pid);
|
| | | if (pidUser != null && pidUser.getType() == PidUser.TYPE_SHARE_GOODS) {// 商品分享订单
|
| | | // List<PidOrder> pidOrderList = new ArrayList<>();
|
| | | // for (TaoBaoOrder order : list) {
|
| | | // pidOrderList.add(TaoBaoOrderUtil.convertToPidOrder(order));
|
| | | // }
|
| | | // sharePidOrderMap.put(orderId, pidOrderList);
|
| | | shareOrderMap.put(orderId, list);
|
| | | } else {// 普通返利订单
|
| | | fanliOrderMap.put(orderId, list);
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | // 加入到订单表
|
| | | orderMapper.insertSelective(order);
|
| | | oldOrder = order;
|
| | | } else {
|
| | | UserExtraTaoBaoInfo info = userExtraTaoBaoInfoService
|
| | | .getBySpecialId(orderList.get(0).getSpecialId());
|
| | | if (info != null && info.getUser() != null) {
|
| | | uid = info.getUser().getId();
|
| | | // 插入到Order中
|
| | | // 添加到订单中去
|
| | | Order order = new Order();
|
| | | order.setBeizhu("PID返利订单");
|
| | | order.setCreatetime(System.currentTimeMillis());
|
| | | order.setOrderId(orderId);
|
| | | order.setOrderType(1);
|
| | | order.setState(Order.STATE_YIZHIFU);
|
| | | order.setUserInfo(new UserInfo(uid));
|
| | | order.setVersion(2);
|
| | | // 加入到订单表
|
| | | orderMapper.insertSelective(order);
|
| | | oldOrder = order;
|
| | | }
|
| | | }
|
| | | } else {
|
| | | uid = oldOrder.getUserInfo().getId();
|
| | |
| | | PidUser pidUser = pidUserMapper.selectByPid(pid);
|
| | | if (pidUser != null)
|
| | | uid = pidUser.getUid();
|
| | | else {
|
| | | UserExtraTaoBaoInfo info = userExtraTaoBaoInfoService.getByRelationId(orderList.get(0).getRelationId());
|
| | | if (info != null && info.getUser() != null)
|
| | | uid = info.getUser().getId();
|
| | | }
|
| | |
|
| | | // 尚未找到和PID对应的用户
|
| | | if (uid == null)
|
| | |
| | |
|
| | | }
|
| | |
|
| | | @Override
|
| | | public UserExtraTaoBaoInfo getByRelationId(String relationId) {
|
| | | return userExtraTaoBaoInfoMapper.selectByRelationIdWithUidNotNull(relationId);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public UserExtraTaoBaoInfo getBySpecialId(String specialId) {
|
| | | return userExtraTaoBaoInfoMapper.selectBySpecialIdWithUidNotNull(specialId);
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | */
|
| | | public void bindTaoBaoOrderEnd6Num(String taoBaoUid, String orderId);
|
| | |
|
| | | /**
|
| | | * 通过渠道ID查询用户(用户信息不为空)
|
| | | * @param relationId
|
| | | * @return
|
| | | */
|
| | | public UserExtraTaoBaoInfo getByRelationId(String relationId);
|
| | |
|
| | | /**
|
| | | * 通过会员运营ID查询用户(用户信息不为空)
|
| | | * @param specialId
|
| | | * @return
|
| | | */
|
| | | public UserExtraTaoBaoInfo getBySpecialId(String specialId);
|
| | | }
|
| | |
| | | return null;
|
| | | }
|
| | |
|
| | | public static void getTaoBaoSpecialOrder(String startTime, String appKey, String appSecret) {
|
| | | /**
|
| | | * 获取会员订单
|
| | | * |
| | | * @param startTime
|
| | | * @param appKey
|
| | | * @param appSecret
|
| | | * @return
|
| | | */
|
| | | public static List<TaoBaoOrder> getTaoBaoSpecialOrder(String startTime, String appKey, String appSecret) {
|
| | | Map<String, String> map = new HashMap<>();
|
| | | map.put("method", "taobao.tbk.order.get");
|
| | | map.put("fields",
|
| | |
| | | app.setAppSecret(appSecret);
|
| | | try {
|
| | | JSONObject json = TaoKeBaseUtil.baseRequest(map, app);
|
| | | System.out.println(json.toString());
|
| | | return parseTaoBaoOrder(json.toString());
|
| | | } catch (TaoKeApiException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | return null;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 获取渠道订单
|
| | | * |
| | | * @param startTime
|
| | | * @param appKey
|
| | | * @param appSecret
|
| | | * @return
|
| | | */
|
| | | public static List<TaoBaoOrder> getTaoBaoRelationOrder(String startTime, String appKey, String appSecret) {
|
| | | Map<String, String> map = new HashMap<>();
|
| | | map.put("method", "taobao.tbk.order.get");
|
| | | map.put("fields",
|
| | | "tb_trade_parent_id,tb_trade_id,num_iid,item_title,item_num,price,pay_price,seller_nick,seller_shop_title,commission,commission_rate,unid,create_time,earning_time,tk_status,tk3rd_pub_id,tk3rd_site_id,tk3rd_adzone_id,relation_id,tb_trade_parent_id,tb_trade_id,num_iid,item_title,item_num,price,pay_price,seller_nick,seller_shop_title,commission,commission_rate,unid,create_time,earning_time,tk3rd_pub_id,tk3rd_site_id,tk3rd_adzone_id,special_id,click_time,relation_id,special_id");
|
| | | map.put("start_time", "2019-01-28 18:39:00");
|
| | | map.put("start_time", startTime);
|
| | | map.put("span", "1200");
|
| | | map.put("tk_status", "1");
|
| | | map.put("order_query_type", "create_time");
|
| | | map.put("order_scene", "3");
|
| | | map.put("order_scene", "2");
|
| | | map.put("page_no", 1 + "");
|
| | | map.put("page_size", 100 + "");
|
| | |
|
| | |
| | | List<TaoBaoOrder> orderList = new ArrayList<>();
|
| | |
|
| | | JSONObject data = JSONObject.fromObject(response);
|
| | | if (data.optJSONObject("tbk_order_get_response") == null)
|
| | | return null;
|
| | | if (data.optJSONObject("tbk_order_get_response").optJSONObject("results") == null)
|
| | | return null;
|
| | | if (data.optJSONObject("tbk_order_get_response").optJSONObject("results").optJSONArray("n_tbk_order") == null)
|
| | | return null;
|
| | |
|
| | | JSONArray array = data.optJSONObject("tbk_order_get_response").optJSONObject("results")
|
| | | .optJSONArray("n_tbk_order");
|
| | | for (int i = 0; i < array.size(); i++) {
|
| | |
| | | taoBaoOrder.setCreateTime(item.optString("create_time"));
|
| | | if (!StringUtil.isNullOrEmpty(item.optString("commission")))
|
| | | taoBaoOrder.seteIncome(new BigDecimal(item.optString("commission")));
|
| | | else
|
| | | taoBaoOrder.seteIncome(new BigDecimal(0));
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(item.optString("pub_share_pre_fee")))
|
| | | taoBaoOrder.setEstimate(new BigDecimal(item.optString("pub_share_pre_fee")));
|
| | | else
|
| | | taoBaoOrder.setEstimate(new BigDecimal(0));
|
| | | taoBaoOrder.setiRatio(new BigDecimal(item.optString("income_rate")).multiply(new BigDecimal(100)));
|
| | | taoBaoOrder.setLatestUpdateTime(null);
|
| | | taoBaoOrder.setManagerWangWang(null);
|
| | |
| | | taoBaoOrder.setOrderType(item.optString("order_type"));
|
| | | if (!StringUtil.isNullOrEmpty(item.optString("pay_price")))
|
| | | taoBaoOrder.setPayment(new BigDecimal(item.optString("pay_price")));
|
| | | else
|
| | | taoBaoOrder.setPayment(new BigDecimal(0));
|
| | | taoBaoOrder.setPrice(new BigDecimal(item.optString("price")));
|
| | | if (!StringUtil.isNullOrEmpty(item.optString("alipay_total_price")))
|
| | | taoBaoOrder.setSettlement(new BigDecimal(item.optString("alipay_total_price")));
|
| | | else
|
| | | taoBaoOrder.setSettlement(new BigDecimal(0));
|
| | | taoBaoOrder.setSettlementTime(item.optString("earning_time"));
|
| | | taoBaoOrder.setShop(item.optString("seller_shop_title"));
|
| | | taoBaoOrder.setSourceMediaId(item.optString("site_id"));
|
| | |
| | | taoBaoOrder.setsRatio(null);
|
| | | taoBaoOrder.setSubsidy(null);
|
| | | if (!StringUtil.isNullOrEmpty(item.optString("subsidy_rate")))
|
| | | taoBaoOrder.setSubsidyRatio(new BigDecimal(item.optString("subsidy_rate")).multiply(new BigDecimal(100)));
|
| | | taoBaoOrder
|
| | | .setSubsidyRatio(new BigDecimal(item.optString("subsidy_rate")).multiply(new BigDecimal(100)));
|
| | | taoBaoOrder.setSubsidyType(item.optString("subsidy_type"));
|
| | | taoBaoOrder.setTechnologySupportPercent(null);
|
| | | taoBaoOrder.setThirdService(null);
|
| | | taoBaoOrder.setTitle(item.optString("item_title"));
|
| | | if (!StringUtil.isNullOrEmpty(item.optString("total_commission_fee")))
|
| | | taoBaoOrder.setTkMoney(new BigDecimal(item.optString("total_commission_fee")));
|
| | | else
|
| | | taoBaoOrder.setTkMoney(new BigDecimal(0));
|
| | | taoBaoOrder.setTkRate(new BigDecimal(item.optString("commission_rate")));
|
| | | taoBaoOrder.setTransactionPlatform(item.optString("terminal_type"));
|
| | | taoBaoOrder.setRelationId(item.optString("relation_id"));
|