3 文件已重命名
15个文件已修改
4个文件已添加
| | |
| | | import com.google.gson.JsonSerializationContext;
|
| | | import com.google.gson.JsonSerializer;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoOrder;
|
| | | import com.yeshi.fanli.job.UpdateOrderJob;
|
| | | import com.yeshi.fanli.job.UpdateRelationAndSpecialOrderJob;
|
| | | import com.yeshi.fanli.job.order.taobao.UpdateOrderJob;
|
| | | import com.yeshi.fanli.job.order.taobao.UpdateTBRelationAndSpecialOrderJob;
|
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoOrderService;
|
| | | import com.yeshi.fanli.tag.PageEntity;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | |
| | | private TaoBaoOrderService taoBaoOrderService;
|
| | |
|
| | | @Resource
|
| | | private UpdateRelationAndSpecialOrderJob updateRelationAndSpecialOrderJob;
|
| | | private UpdateTBRelationAndSpecialOrderJob updateRelationAndSpecialOrderJob;
|
| | |
|
| | | @Resource
|
| | | private UpdateOrderJob updateOrderJob;
|
| | |
| | | if (end > 2)
|
| | | text = text.substring(1, end);
|
| | | }
|
| | |
|
| | | if (NumberUtil.isNumeric(text)) {
|
| | | out.println(JsonUtil.loadFalseResult("不支持纯数字"));
|
| | | |
| | | String pattern = "^[A-Za-z0-9]+$";
|
| | | if (Pattern.matches(pattern, text)) {
|
| | | out.println(JsonUtil.loadFalseResult("不支持推荐"));
|
| | | return;
|
| | | }
|
| | |
|
| | |
| | | package com.yeshi.fanli.dao.mybatis.jd; |
| | | |
| | | import java.util.List; |
| | | |
| | | import com.yeshi.fanli.dao.BaseMapper; |
| | | import com.yeshi.fanli.entity.jd.JDOrderItem; |
| | | |
| | |
| | | */ |
| | | JDOrderItem selectByTradeId(String tradeId); |
| | | |
| | | /** |
| | | * 根据订单号查询 |
| | | * @param orderId |
| | | * @return |
| | | */ |
| | | List<JDOrderItem> listByOrderId(Long orderId); |
| | | |
| | | } |
New file |
| | |
| | | package com.yeshi.fanli.job.order.jd;
|
| | |
|
| | | import java.util.ArrayList;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.scheduling.annotation.Scheduled;
|
| | | import org.springframework.stereotype.Component;
|
| | |
|
| | | import com.yeshi.fanli.dto.jd.JDOrderResult;
|
| | | import com.yeshi.fanli.entity.jd.JDOrder;
|
| | | import com.yeshi.fanli.exception.jd.JDOrderException;
|
| | | import com.yeshi.fanli.service.inter.jd.JDOrderService;
|
| | | import com.yeshi.fanli.util.RedisManager;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.cmq.JDOrderCMQManager;
|
| | | import com.yeshi.fanli.util.jd.JDApiUtil;
|
| | |
|
| | | //从淘宝爬去订单更新
|
| | | @Component
|
| | | public class UpdateJDOrderJob {
|
| | |
|
| | | @Resource
|
| | | private JDOrderService jdOrderService;
|
| | |
|
| | | @Resource
|
| | | private RedisManager redisManager;
|
| | |
|
| | | /**
|
| | | * 保存订单
|
| | | * |
| | | * @param jdOrderList
|
| | | */
|
| | | public void saveJDOrders(List<JDOrder> jdOrderList) {
|
| | | for (JDOrder order : jdOrderList)
|
| | | try {
|
| | | jdOrderService.addJDOrder(order);
|
| | | /**
|
| | | * 做频率限制
|
| | | */
|
| | | String key = "jd-order-" + order.getOrderId();
|
| | | String result = redisManager.getCommonString(key);
|
| | | if (!StringUtil.isNullOrEmpty(result))
|
| | | continue;
|
| | | JDOrderCMQManager.getInstance().addJDOrder(order.getOrderId() + "");
|
| | | redisManager.cacheCommonString(key, "1", 60 * 60 * 2);// 2小时内不再更新
|
| | | } catch (JDOrderException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 快速订单更新(爬取本小时内的单,每分钟一次)
|
| | | */
|
| | | @Scheduled(cron = "0 0/1 * * * ? ")
|
| | | public void updateSoonOrder() {
|
| | | JDOrderResult result = JDApiUtil.getOrderList(1, 200, new Date(), JDApiUtil.ORDER_TYPE_CREATETIME);
|
| | | if (result != null && result.getOrderList() != null)
|
| | | saveJDOrders(result.getOrderList());
|
| | | }
|
| | |
|
| | | /**
|
| | | * 爬取最近一小时内的状态更新了的单(10分钟一次)
|
| | | */
|
| | | @Scheduled(cron = "0 0/10 * * * ? ")
|
| | | public void updateUpdateOrder() {
|
| | | List<JDOrder> jdOrderList = new ArrayList<>();
|
| | | int pageSize = 200;
|
| | | int page = 1;
|
| | | JDOrderResult result = JDApiUtil.getOrderList(page++, pageSize, new Date(), JDApiUtil.ORDER_TYPE_UPDATETIME);
|
| | | jdOrderList.addAll(result.getOrderList());
|
| | | while (result.isHasMore()) {
|
| | | result = JDApiUtil.getOrderList(page++, pageSize, new Date(), JDApiUtil.ORDER_TYPE_UPDATETIME);
|
| | | jdOrderList.addAll(result.getOrderList());
|
| | | }
|
| | | saveJDOrders(jdOrderList);
|
| | | }
|
| | |
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.job.order.jd;
|
| | |
|
| | | import java.util.ArrayList;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.scheduling.annotation.Scheduled;
|
| | | import org.springframework.stereotype.Component;
|
| | |
|
| | | import com.yeshi.fanli.dto.pdd.PDDOrderResult;
|
| | | import com.yeshi.fanli.entity.pdd.PDDOrder;
|
| | | import com.yeshi.fanli.exception.pdd.PDDOrderException;
|
| | | import com.yeshi.fanli.service.inter.pdd.PDDOrderService;
|
| | | import com.yeshi.fanli.util.RedisManager;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.cmq.JDOrderCMQManager;
|
| | | import com.yeshi.fanli.util.pinduoduo.PinDuoDuoApiUtil;
|
| | |
|
| | | //从淘宝爬去订单更新
|
| | | @Component
|
| | | public class UpdatePDDOrderJob {
|
| | |
|
| | | @Resource
|
| | | private PDDOrderService pddOrderService;
|
| | |
|
| | | @Resource
|
| | | private RedisManager redisManager;
|
| | |
|
| | | /**
|
| | | * 保存订单
|
| | | * |
| | | * @param jdOrderList
|
| | | */
|
| | | public void savePDDOrders(List<PDDOrder> orderList) {
|
| | | for (PDDOrder order : orderList)
|
| | | try {
|
| | | pddOrderService.addOrder(order);
|
| | | /**
|
| | | * 做频率限制
|
| | | */
|
| | | String key = "pdd-order-" + order.getOrderSn();
|
| | | String result = redisManager.getCommonString(key);
|
| | | if (!StringUtil.isNullOrEmpty(result))
|
| | | continue;
|
| | | JDOrderCMQManager.getInstance().addJDOrder(order.getOrderSn() + "");
|
| | | redisManager.cacheCommonString(key, "1", 60 * 60 * 2);// 2小时内不再更新
|
| | | } catch (PDDOrderException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 快速订单更新(爬取本小时内的单,每分钟一次)
|
| | | */
|
| | | @Scheduled(cron = "0 0/1 * * * ? ")
|
| | | public void updateSoonOrder() {
|
| | | Date now = null;
|
| | | now = PinDuoDuoApiUtil.getSystemTime();
|
| | | if (now == null)
|
| | | now = new Date();
|
| | | long endTime = now.getTime();
|
| | | long startTime = endTime - 1000 * 60 * 60;// 最近一个小时
|
| | | PDDOrderResult result = PinDuoDuoApiUtil.getOrdersList(1, 50, startTime, endTime);
|
| | | if (result != null && result.getOrderList() != null)
|
| | | savePDDOrders(result.getOrderList());
|
| | | }
|
| | |
|
| | | /**
|
| | | * 爬取最近1天的订单(30分钟一次)
|
| | | */
|
| | | @Scheduled(cron = "0 0/30 * * * ? ")
|
| | | public void updateUpdateOrder() {
|
| | | long endTime = System.currentTimeMillis() - 1000 * 60 * 60L;
|
| | | long startTime = System.currentTimeMillis() - 1000 * 60 * 60 * 24L;
|
| | | int page = 1;
|
| | | List<PDDOrder> pddOrderList = new ArrayList<>();
|
| | | PDDOrderResult result = PinDuoDuoApiUtil.getOrdersList(page++, 50, startTime, endTime);
|
| | | pddOrderList.addAll(result.getOrderList());
|
| | | while (result != null && pddOrderList.size() < result.getTotalCount()) {
|
| | | result = PinDuoDuoApiUtil.getOrdersList(page++, 50, startTime, endTime);
|
| | | if (result != null)
|
| | | pddOrderList.addAll(result.getOrderList());
|
| | | }
|
| | | savePDDOrders(pddOrderList);
|
| | | }
|
| | |
|
| | | }
|
File was renamed from fanli/src/main/java/com/yeshi/fanli/job/UpdateCommonOrderJob.java |
| | |
| | | package com.yeshi.fanli.job;
|
| | | package com.yeshi.fanli.job.order.taobao;
|
| | |
|
| | | import java.util.ArrayList;
|
| | | import java.util.Date;
|
File was renamed from fanli/src/main/java/com/yeshi/fanli/job/UpdateOrderJob.java |
| | |
| | | package com.yeshi.fanli.job;
|
| | | package com.yeshi.fanli.job.order.taobao;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.util.ArrayList;
|
File was renamed from fanli/src/main/java/com/yeshi/fanli/job/UpdateRelationAndSpecialOrderJob.java |
| | |
| | | package com.yeshi.fanli.job;
|
| | | package com.yeshi.fanli.job.order.taobao;
|
| | |
|
| | | import java.util.Iterator;
|
| | | import java.util.List;
|
| | |
| | | *
|
| | | */
|
| | | @Component
|
| | | public class UpdateRelationAndSpecialOrderJob {
|
| | | public class UpdateTBRelationAndSpecialOrderJob {
|
| | |
|
| | | @Resource
|
| | | private TaoBaoOrderService taoBaoOrderService;
|
| | |
| | | from yeshi_ec_jd_order_item where joi_trade_id = #{0} |
| | | </select> |
| | | |
| | | <select id="listByOrderId" resultMap="BaseResultMap" |
| | | parameterType="java.lang.Long"> |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | | from yeshi_ec_jd_order_item where joi_order_id = #{0} |
| | | </select> |
| | | |
| | | <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from |
| | | yeshi_ec_jd_order_item where joi_id = #{id,jdbcType=BIGINT} |
| | |
| | | // 查询是否有免单计划
|
| | | BigDecimal mianDanMoney = null;
|
| | | if (commonOrder.getState() == CommonOrder.STATE_JS || commonOrder.getState() == CommonOrder.STATE_FK) {
|
| | | List<CommonOrder> orderList = commonOrderService.listBySourceTypeAndOrderId(Constant.SOURCE_TYPE_TAOBAO,
|
| | | List<CommonOrder> orderList = commonOrderService.listBySourceTypeAndOrderId(commonOrder.getSourceType(),
|
| | | commonOrder.getOrderNo());
|
| | | if (orderList != null && orderList.size() == 1) {// 只有1个订单才参与免单
|
| | | BigDecimal payMent = commonOrder.getPayment();
|
| | |
| | | package com.yeshi.fanli.service.impl.jd;
|
| | |
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | public JDOrder selectByOrderId(Long orderId) {
|
| | | return jdOrderMapper.selectByOrderId(orderId);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public JDOrder selectDetailByOrderId(Long orderId) {
|
| | | JDOrder order = selectByOrderId(orderId);
|
| | | if (order == null)
|
| | | return null;
|
| | | List<JDOrderItem> orderItemList = jdOrderItemMapper.listByOrderId(order.getOrderId());
|
| | | order.setOrderItemList(orderItemList);
|
| | | return order;
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | 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.jd.JDOrder;
|
| | | import com.yeshi.fanli.entity.jd.JDOrderItem;
|
| | | import com.yeshi.fanli.entity.money.UserMoneyDetail;
|
| | | import com.yeshi.fanli.entity.order.CommonOrder;
|
| | | import com.yeshi.fanli.entity.order.HongBaoOrder;
|
| | | import com.yeshi.fanli.entity.pdd.PDDOrder;
|
| | | import com.yeshi.fanli.entity.taobao.PidUser;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoOrder;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoUnionConfig;
|
| | |
| | | import com.yeshi.fanli.service.inter.user.UserSystemCouponService;
|
| | | import com.yeshi.fanli.util.CMQManager;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.MoneyBigDecimalUtil;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.TaoBaoConstant;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | | import com.yeshi.fanli.util.factory.UserMoneyDetailFactory;
|
| | | import com.yeshi.fanli.util.jd.JDApiUtil;
|
| | | import com.yeshi.fanli.util.pinduoduo.PinDuoDuoApiUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoKeOrderApiUtil;
|
| | |
|
| | | @Service
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void processJDOrder(JDOrder order) {
|
| | | if (order == null || order.getOrderItemList() == null || order.getOrderItemList().size() == 0)
|
| | | return;
|
| | | String uidStr = order.getExt1();
|
| | | Long uid = null;
|
| | | if (!StringUtil.isNullOrEmpty(uidStr))
|
| | | uid = Long.parseLong(uidStr);
|
| | | Long positionId = order.getOrderItemList().get(0).getPositionId();
|
| | | if (positionId == JDApiUtil.POSITION_FANLI)// 返利订单
|
| | | {
|
| | | processFanLiJDOrder(order, uid);
|
| | | lostOrderService.processSuceess(order.getOrderId() + "", Constant.SOURCE_TYPE_JD);
|
| | | } else if (positionId == JDApiUtil.POSITION_SHARE) {// 分享订单
|
| | | if (uid == null)// 分享订单不允许找回
|
| | | return;
|
| | | processShareJDOrder(order, uid);
|
| | | } else {// 处理是否有订单找回的状态
|
| | | processFanLiJDOrder(order, null);
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 处理京东返利订单
|
| | | * @param jdOrder
|
| | | * @param uid
|
| | | */
|
| | | @Transactional
|
| | | private void processFanLiJDOrder(JDOrder jdOrder, Long uid) {
|
| | | int invalidCount = 0;
|
| | | BigDecimal totalMoney = new BigDecimal(0);
|
| | | // 订单状态判断
|
| | | for (JDOrderItem item : jdOrder.getOrderItemList()) {
|
| | | if (item.getEstimateCosPrice() != null)
|
| | | totalMoney = totalMoney.add(item.getEstimateCosPrice());
|
| | |
|
| | | if (item.getValidCode() == 16 || item.getValidCode() == 17 || item.getValidCode() == 18) {// 已付款
|
| | |
|
| | | } else if (item.getValidCode() == 15) {// 未支付
|
| | |
|
| | | } else {
|
| | | invalidCount++;
|
| | | }
|
| | | }
|
| | |
|
| | | // 加入订单
|
| | | Order oldOrder = orderMapper.selectOrderByOrderIdAndOrderType(jdOrder.getOrderId() + "",
|
| | | Constant.SOURCE_TYPE_JD);
|
| | | if (uid == null && oldOrder.getBeizhu().contains("补单"))
|
| | | uid = oldOrder.getUserInfo().getId();
|
| | |
|
| | | if (uid == null)
|
| | | return;
|
| | |
|
| | | if (oldOrder == null)// 新增
|
| | | {
|
| | | Order order = new Order();
|
| | | order.setBeizhu("京东返利订单");
|
| | | order.setCreatetime(System.currentTimeMillis());
|
| | | order.setOrderId(jdOrder.getOrderId() + "");
|
| | | order.setOrderType(Constant.SOURCE_TYPE_JD);
|
| | | order.setState(
|
| | | invalidCount == jdOrder.getOrderItemList().size() ? Order.STATE_SHIXIAO : Order.STATE_YIZHIFU);
|
| | | order.setUserInfo(new UserInfo(uid));
|
| | | order.setVersion(2);
|
| | | order.setThirdCreateTime(new Date(jdOrder.getOrderTime()));
|
| | | order.setMoney(totalMoney);
|
| | | // 加入到订单表
|
| | | orderMapper.insertSelective(order);
|
| | | } else {
|
| | | Order updateOrder = new Order();
|
| | | updateOrder.setId(oldOrder.getId());
|
| | | updateOrder.setMoney(totalMoney);
|
| | | orderMapper.updateByPrimaryKeySelective(updateOrder);
|
| | | }
|
| | |
|
| | | try {
|
| | | List<CommonOrder> commonOrderList = commonOrderService.addJDOrder(jdOrder, uid);
|
| | | hongBaoV2Service.addHongBao(commonOrderList, HongBaoV2.TYPE_ZIGOU);
|
| | | } catch (CommonOrderException e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e, "addJDOrder或addHongBao出错", "订单号:" + jdOrder.getOrderId());
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | } catch (HongBaoException e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e, "addJDOrder或addHongBao出错", "订单号:" + jdOrder.getOrderId());
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 处理京东分享订单
|
| | | * @param order
|
| | | * @param uid
|
| | | */
|
| | | @Transactional
|
| | | private void processShareJDOrder(JDOrder order, Long uid) {
|
| | | try {
|
| | | List<CommonOrder> commonOrderList = commonOrderService.addJDOrder(order, uid);
|
| | | hongBaoV2Service.addHongBao(commonOrderList, HongBaoV2.TYPE_SHARE_GOODS);
|
| | | } catch (CommonOrderException e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e, "addJDOrder或addHongBao出错", "订单号:" + order.getOrderId());
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | } catch (HongBaoException e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e, "addJDOrder或addHongBao出错", "订单号:" + order.getOrderId());
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 处理拼多多订单
|
| | | */
|
| | | @Override
|
| | | public void processPDDOrder(PDDOrder pddOrder) {
|
| | | if (pddOrder == null)
|
| | | return;
|
| | | String uidStr = pddOrder.getCustomParameters();
|
| | | Long uid = null;
|
| | | if (!StringUtil.isNullOrEmpty(uidStr))
|
| | | uid = Long.parseLong(uidStr);
|
| | | String positionId = pddOrder.getpId();
|
| | | if (PinDuoDuoApiUtil.PID_FANLI.equalsIgnoreCase(positionId))// 返利订单
|
| | | {
|
| | | processFanLiPDDOrder(pddOrder, uid);
|
| | | lostOrderService.processSuceess(pddOrder.getOrderSn(), Constant.SOURCE_TYPE_PDD);
|
| | | } else if (PinDuoDuoApiUtil.PID_SHARE.equalsIgnoreCase(positionId)) {// 分享订单
|
| | | if (uid == null)// 分享订单不允许找回
|
| | | return;
|
| | | processSharePDDOrder(pddOrder, uid);
|
| | | } else {// 处理是否有订单找回的状态
|
| | | processFanLiPDDOrder(pddOrder, null);
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 处理拼多多自购返利订单
|
| | | * @param pddOrder
|
| | | * @param uid
|
| | | */
|
| | | @Transactional
|
| | | private void processFanLiPDDOrder(PDDOrder pddOrder, Long uid) {
|
| | | int orderState = 0;
|
| | | if (pddOrder.getOrderStatus() == -1 || pddOrder.getOrderStatus() == 8)
|
| | | orderState = Order.STATE_SHIXIAO;
|
| | | else
|
| | | orderState = Order.STATE_YIZHIFU;
|
| | |
|
| | | BigDecimal totalMoney = MoneyBigDecimalUtil.div(new BigDecimal(pddOrder.getOrderAmount()), new BigDecimal(100));
|
| | |
|
| | | // 加入订单
|
| | | Order oldOrder = orderMapper.selectOrderByOrderIdAndOrderType(pddOrder.getOrderSn(), Constant.SOURCE_TYPE_PDD);
|
| | | if (uid == null && oldOrder.getBeizhu().contains("补单"))
|
| | | uid = oldOrder.getUserInfo().getId();
|
| | |
|
| | | if (uid == null)
|
| | | return;
|
| | |
|
| | | if (oldOrder == null)// 新增
|
| | | {
|
| | | Order order = new Order();
|
| | | order.setBeizhu("拼多多返利订单");
|
| | | order.setCreatetime(System.currentTimeMillis());
|
| | | order.setOrderId(pddOrder.getOrderSn());
|
| | | order.setOrderType(Constant.SOURCE_TYPE_PDD);
|
| | | order.setState(orderState);
|
| | | order.setUserInfo(new UserInfo(uid));
|
| | | order.setVersion(2);
|
| | | order.setThirdCreateTime(new Date(pddOrder.getOrderCreateTime() * 1000));
|
| | | order.setMoney(totalMoney);
|
| | | // 加入到订单表
|
| | | orderMapper.insertSelective(order);
|
| | | } else {
|
| | | Order updateOrder = new Order();
|
| | | updateOrder.setId(oldOrder.getId());
|
| | | updateOrder.setMoney(totalMoney);
|
| | | orderMapper.updateByPrimaryKeySelective(updateOrder);
|
| | | }
|
| | |
|
| | | try {
|
| | | List<PDDOrder> pddOrderList = new ArrayList<>();
|
| | | pddOrderList.add(pddOrder);
|
| | | List<CommonOrder> commonOrderList = commonOrderService.addPDDOrder(pddOrderList, uid);
|
| | | hongBaoV2Service.addHongBao(commonOrderList, HongBaoV2.TYPE_ZIGOU);
|
| | | } catch (CommonOrderException e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e, "addPDDOrder或addHongBao出错", "订单号:" + pddOrder.getOrderSn());
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | } catch (HongBaoException e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e, "addPDDOrder或addHongBao出错", "订单号:" + pddOrder.getOrderSn());
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | |
| | | /**
|
| | | * 处理拼多多分享订单
|
| | | * @param order
|
| | | * @param uid
|
| | | */
|
| | | @Transactional
|
| | | private void processSharePDDOrder(PDDOrder order, Long uid) {
|
| | | try {
|
| | | List<PDDOrder> pddOrderList = new ArrayList<>();
|
| | | pddOrderList.add(order);
|
| | | List<CommonOrder> commonOrderList = commonOrderService.addPDDOrder(pddOrderList, uid);
|
| | | hongBaoV2Service.addHongBao(commonOrderList, HongBaoV2.TYPE_SHARE_GOODS);
|
| | | } catch (CommonOrderException e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e, "addJDOrder或addHongBao出错", "订单号:" + order.getOrderId());
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | } catch (HongBaoException e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e, "addJDOrder或addHongBao出错", "订单号:" + order.getOrderId());
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | package com.yeshi.fanli.service.impl.pdd;
|
| | |
|
| | | import java.util.ArrayList;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | |
| | | return order;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<PDDOrder> selectByOrderSn(String orderSn) {
|
| | | List<PDDOrder> pddList = new ArrayList<>();
|
| | | PDDOrder pddOrder = pddOrderMapper.selectByOrderSN(orderSn);
|
| | | if (pddOrder != null)
|
| | | pddList.add(pddOrder);
|
| | | return pddList;
|
| | | }
|
| | |
|
| | | }
|
| | |
| | |
|
| | | public interface JDOrderService {
|
| | |
|
| | | /**
|
| | | * 添加订单
|
| | | * |
| | | * @param order
|
| | | * @throws JDOrderException
|
| | | */
|
| | | public void addJDOrder(JDOrder order) throws JDOrderException;
|
| | |
|
| | | /**
|
| | | * 根据订单号查询
|
| | | * |
| | | * @param orderId
|
| | | * @return
|
| | | */
|
| | | public JDOrder selectByOrderId(Long orderId);
|
| | | |
| | | /**
|
| | | * 根据订单号查询(包含子订单)
|
| | | * @param orderId
|
| | | * @return
|
| | | */
|
| | | public JDOrder selectDetailByOrderId(Long orderId);
|
| | |
|
| | | }
|
| | |
| | | import java.util.Map;
|
| | |
|
| | | import com.yeshi.fanli.entity.bus.user.HongBaoV2;
|
| | | import com.yeshi.fanli.entity.jd.JDOrder;
|
| | | import com.yeshi.fanli.entity.pdd.PDDOrder;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoOrder;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoWeiQuanOrder;
|
| | | import com.yeshi.fanli.exception.HongBaoException;
|
| | |
| | | */
|
| | | public void processShopingFanliOrder(Map<String, List<TaoBaoOrder>> orders);
|
| | |
|
| | |
|
| | | /**
|
| | | * 处理分享商品订单
|
| | | */
|
| | | public void processShareGoodsOrder(Map<String, List<TaoBaoOrder>> orders);
|
| | | |
| | | |
| | | |
| | | |
| | |
|
| | | public void processShopingFanliOrderNew(String orderId, List<TaoBaoOrder> orderList)
|
| | | throws HongBaoException, OrderItemException;
|
| | |
|
| | |
| | | */
|
| | | public void processShareGoodsOrderNew(String orderId, List<TaoBaoOrder> orderList);
|
| | |
|
| | | |
| | |
|
| | | /**
|
| | | * 处理返利
|
| | | */
|
| | | public void fanli();
|
| | |
|
| | |
|
| | | |
| | | /**
|
| | | * 购物返利
|
| | | * @param hongBao type=1的主红包
|
| | | * |
| | | * @param hongBao
|
| | | * type=1的主红包
|
| | | * @throws TaoBaoWeiQuanException
|
| | | */
|
| | | public void fanli(HongBaoV2 hongBao) throws TaoBaoWeiQuanException;
|
| | |
| | | *
|
| | | * @param hongBao
|
| | | * type=1且有子红包的主红包
|
| | |
|
| | | * |
| | | */
|
| | | public void fanliInvaiteAndShare();
|
| | |
|
| | | /**
|
| | | * 分享赚与邀请赚返利
|
| | | */
|
| | | public void fanliInvaiteAndShare(Long uid) throws TaoBaoWeiQuanException;
|
| | | public void fanliInvaiteAndShare(Long uid) throws TaoBaoWeiQuanException;
|
| | |
|
| | | /**
|
| | | * 订单维权
|
| | |
| | | *
|
| | | * @param order
|
| | | */
|
| | | public void weiQuanOrder(TaoBaoWeiQuanOrder order) ;
|
| | | |
| | | public void weiQuanOrder(TaoBaoWeiQuanOrder order);
|
| | |
|
| | | /**
|
| | | * 处理京东订单
|
| | | * |
| | | * @param order
|
| | | */
|
| | | public void processJDOrder(JDOrder order);
|
| | |
|
| | | /**
|
| | | * 处理拼多多订单
|
| | | * @param pddOrder
|
| | | */
|
| | | public void processPDDOrder(PDDOrder pddOrder);
|
| | |
|
| | | }
|
| | |
| | | package com.yeshi.fanli.service.inter.pdd;
|
| | |
|
| | | import java.util.List;
|
| | |
|
| | | import com.yeshi.fanli.entity.pdd.PDDOrder;
|
| | | import com.yeshi.fanli.exception.pdd.PDDOrderException;
|
| | |
|
| | |
| | | */
|
| | | public PDDOrder addOrder(PDDOrder order) throws PDDOrderException;
|
| | |
|
| | | /**
|
| | | * 根据订单号查询
|
| | | * |
| | | * @param orderSn
|
| | | * @return
|
| | | */
|
| | | public List<PDDOrder> selectByOrderSn(String orderSn);
|
| | |
|
| | | }
|
| | |
| | | import com.yeshi.fanli.entity.bus.user.AlipayTransferResultInfo;
|
| | | import com.yeshi.fanli.entity.bus.user.HongBaoV2;
|
| | | import com.yeshi.fanli.entity.bus.user.ThreeSale;
|
| | | import com.yeshi.fanli.entity.jd.JDOrder;
|
| | | import com.yeshi.fanli.entity.pdd.PDDOrder;
|
| | | import com.yeshi.fanli.entity.push.PushQueueRecord;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoOrder;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoWeiQuanOrder;
|
| | | import com.yeshi.fanli.exception.TaoBaoWeiQuanException;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.hongbao.ThreeSaleSerivce;
|
| | | import com.yeshi.fanli.service.inter.jd.JDOrderService;
|
| | | import com.yeshi.fanli.service.inter.lable.BoutiqueAutoRuleService;
|
| | | import com.yeshi.fanli.service.inter.lable.LabelService;
|
| | | import com.yeshi.fanli.service.inter.money.UserMoneyDebtService;
|
| | | import com.yeshi.fanli.service.inter.order.OrderProcessService;
|
| | | import com.yeshi.fanli.service.inter.pdd.PDDOrderService;
|
| | | import com.yeshi.fanli.service.inter.push.IOSPushService;
|
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoGoodsUpdateService;
|
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoOrderService;
|
| | | import com.yeshi.fanli.service.inter.user.ExtractService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoService;
|
| | | import com.yeshi.fanli.service.inter.user.UserSystemCouponService;
|
| | | import com.yeshi.fanli.util.cmq.JDOrderCMQManager;
|
| | | import com.yeshi.fanli.util.cmq.PDDOrderCMQManager;
|
| | | import com.yeshi.fanli.util.cmq.ThreeSaleCMQManager;
|
| | | import com.yeshi.fanli.util.cmq.UserMoneyChangeCMQManager;
|
| | |
|
| | |
| | | @Resource
|
| | | private UserMoneyDebtService userMoneyDebtService;
|
| | |
|
| | | @Resource
|
| | | private JDOrderService jdOrderService;
|
| | |
|
| | | @Resource
|
| | | private PDDOrderService pddOrderService;
|
| | |
|
| | | private static boolean isInited = false;
|
| | |
|
| | | public void onApplicationEvent(ContextRefreshedEvent arg0) {
|
| | |
| | | initScheduler();// 启动商品更新定时任务
|
| | | doUpdateGoodsJob(); // 更新商品队列
|
| | | }
|
| | |
|
| | | doJDOrderJob();// 京东订单处理
|
| | | doPDDOrderJob();// 拼多多订单处理
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | }
|
| | | });
|
| | | }
|
| | |
|
| | | public void doJDOrderJob() {
|
| | | executor.execute(new Runnable() {
|
| | | @Override
|
| | | public void run() {
|
| | | while (true) {
|
| | | try {
|
| | | Map<String, String> map = JDOrderCMQManager.getInstance().consumeJDOrder(16);
|
| | | if (map != null) {
|
| | | Iterator<String> its = map.keySet().iterator();
|
| | | while (its.hasNext()) {
|
| | | String key = its.next();
|
| | | try {
|
| | | String orderId = map.get(key);
|
| | | if (!StringUtil.isNullOrEmpty(orderId)) {
|
| | | JDOrder order = jdOrderService.selectDetailByOrderId(Long.parseLong(orderId));
|
| | | orderProcessService.processJDOrder(order);
|
| | | }
|
| | | JDOrderCMQManager.getInstance().deleteJDOrder(key);
|
| | | } catch (Exception e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | } catch (Exception e) {
|
| | | LogHelper.error("拼多多订单出错:" + e.getMessage());
|
| | |
|
| | | }
|
| | | }
|
| | | }
|
| | | });
|
| | |
|
| | | }
|
| | |
|
| | | public void doPDDOrderJob() {
|
| | | executor.execute(new Runnable() {
|
| | | @Override
|
| | | public void run() {
|
| | | while (true) {
|
| | | try {
|
| | | Map<String, String> map = PDDOrderCMQManager.getInstance().consumePDDOrder(16);
|
| | | if (map != null) {
|
| | | Iterator<String> its = map.keySet().iterator();
|
| | | while (its.hasNext()) {
|
| | | String key = its.next();
|
| | | try {
|
| | | String orderId = map.get(key);
|
| | | if (!StringUtil.isNullOrEmpty(orderId)) {
|
| | | List<PDDOrder> orderList = pddOrderService.selectByOrderSn(orderId);
|
| | | if (orderList != null)
|
| | | for (PDDOrder order : orderList)
|
| | | orderProcessService.processPDDOrder(order);
|
| | | }
|
| | | PDDOrderCMQManager.getInstance().deletePDDOrder(key);
|
| | | } catch (Exception e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | } catch (Exception e) {
|
| | | LogHelper.error("拼多多订单:" + e.getMessage());
|
| | |
|
| | | }
|
| | | }
|
| | | }
|
| | | });
|
| | |
|
| | | }
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.util.cmq;
|
| | |
|
| | | import java.util.HashMap;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | |
|
| | | import org.yeshi.utils.CMQUtil;
|
| | |
|
| | | import com.qcloud.cmq.Message;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | |
|
| | | public class JDOrderCMQManager {
|
| | |
|
| | | private static String secretId = "AKIDTlpgJhLjOozvd6QI2XnpfGbgV4NQJk25";
|
| | | private static String secretKey = "xhCSUHo55oHUQ6XicFcmfIgspX0EEzWo";
|
| | | private static JDOrderCMQManager jdOrderCMQManager;
|
| | | private static CMQUtil cmqUtil;
|
| | |
|
| | | public static String JD_ORDER = "order-jd";
|
| | |
|
| | | static {
|
| | | cmqUtil = CMQUtil.getInstance(secretId, secretKey);
|
| | | cmqUtil.createQueue(JD_ORDER);
|
| | | JD_ORDER += "-" + Constant.systemCommonConfig.getProjectName();
|
| | | }
|
| | |
|
| | | public static JDOrderCMQManager getInstance() {
|
| | | if (jdOrderCMQManager == null)
|
| | | jdOrderCMQManager = new JDOrderCMQManager();
|
| | | return jdOrderCMQManager;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 添加京东订单到队列
|
| | | * |
| | | * @param orderId
|
| | | */
|
| | | public void addJDOrder(String orderId) {
|
| | | if (StringUtil.isNullOrEmpty(orderId))
|
| | | return;
|
| | | cmqUtil.sendMsg(JD_ORDER, orderId);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 消费队列消息
|
| | | * |
| | | * @param count
|
| | | * @return
|
| | | */
|
| | | public Map<String, String> consumeJDOrder(int count) {
|
| | | List<Message> list = cmqUtil.recieveMsg(count, JD_ORDER);
|
| | | Map<String, String> map = new HashMap<>();
|
| | | if (list != null)
|
| | | for (Message msg : list) {
|
| | | String result = msg.msgBody;
|
| | | map.put(msg.receiptHandle, result);
|
| | | }
|
| | | return map;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 删除京东队列
|
| | | * |
| | | * @param receiptHandle
|
| | | */
|
| | | public void deleteJDOrder(String receiptHandle) {
|
| | | cmqUtil.deleteMsg(JD_ORDER, receiptHandle);
|
| | | }
|
| | |
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.util.cmq;
|
| | |
|
| | | import java.util.HashMap;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | |
|
| | | import org.yeshi.utils.CMQUtil;
|
| | |
|
| | | import com.qcloud.cmq.Message;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | |
|
| | | public class PDDOrderCMQManager {
|
| | |
|
| | | private static String secretId = "AKIDTlpgJhLjOozvd6QI2XnpfGbgV4NQJk25";
|
| | | private static String secretKey = "xhCSUHo55oHUQ6XicFcmfIgspX0EEzWo";
|
| | | private static PDDOrderCMQManager pddOrderCMQManager;
|
| | | private static CMQUtil cmqUtil;
|
| | |
|
| | | public static String PDD_ORDER = "order-pdd";
|
| | |
|
| | | static {
|
| | | cmqUtil = CMQUtil.getInstance(secretId, secretKey);
|
| | | cmqUtil.createQueue(PDD_ORDER);
|
| | | PDD_ORDER += "-" + Constant.systemCommonConfig.getProjectName();
|
| | | }
|
| | |
|
| | | public static PDDOrderCMQManager getInstance() {
|
| | | if (pddOrderCMQManager == null)
|
| | | pddOrderCMQManager = new PDDOrderCMQManager();
|
| | | return pddOrderCMQManager;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 添加京东订单到队列
|
| | | * |
| | | * @param orderId
|
| | | */
|
| | | public void addPDDOrder(String orderId) {
|
| | | if (StringUtil.isNullOrEmpty(orderId))
|
| | | return;
|
| | | cmqUtil.sendMsg(PDD_ORDER, orderId);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 消费队列消息
|
| | | * |
| | | * @param count
|
| | | * @return
|
| | | */
|
| | | public Map<String, String> consumePDDOrder(int count) {
|
| | | List<Message> list = cmqUtil.recieveMsg(count, PDD_ORDER);
|
| | | Map<String, String> map = new HashMap<>();
|
| | | if (list != null)
|
| | | for (Message msg : list) {
|
| | | String result = msg.msgBody;
|
| | | map.put(msg.receiptHandle, result);
|
| | | }
|
| | | return map;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 删除京东队列
|
| | | * |
| | | * @param receiptHandle
|
| | | */
|
| | | public void deletePDDOrder(String receiptHandle) {
|
| | | cmqUtil.deleteMsg(PDD_ORDER, receiptHandle);
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | import java.net.URLEncoder;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Collections;
|
| | | import java.util.Date;
|
| | | import java.util.HashMap;
|
| | | import java.util.Iterator;
|
| | | import java.util.List;
|
| | |
| | | public static String SECRET_KEY = "fb49bc6ecac5458ba5394fc2969d7c56";
|
| | | private static String SERVER_URL = "https://router.jd.com/api";
|
| | |
|
| | | public static Long POSITION_FANLI = 1834339426L;
|
| | | public static Long POSITION_SHARE = 1834289924L;
|
| | | public static Long POSITION_COUPON = 1859510742L;
|
| | | public static long POSITION_FANLI = 1834339426L;
|
| | | public static long POSITION_SHARE = 1834289924L;
|
| | | public static long POSITION_COUPON = 1859510742L;
|
| | |
|
| | | // 订单查询类型
|
| | | public static int ORDER_TYPE_CREATETIME = 1;// 下单时间
|
| | |
| | | }
|
| | | return null;
|
| | | }
|
| | | |
| | |
|
| | | private static String post2(String url, Map<String, String> params) {
|
| | | String baseUrl = url;
|
| | | List<String> paramsList = new ArrayList<>();
|
| | |
| | | return result;
|
| | | }
|
| | |
|
| | | |
| | | private static String baseRequest2(String method, String accessToken, JSONObject params) {
|
| | | Map<String, String> baseMap = new HashMap<String, String>();
|
| | | baseMap.put("param_json", params.toString());
|
| | |
| | | String result = post2(SERVER_URL, baseMap);
|
| | | return result;
|
| | | }
|
| | | |
| | |
|
| | | /**
|
| | | * 转链
|
| | | *
|
| | |
| | | json.put("materialId", materialId);
|
| | | json.put("siteId", APP_ID);
|
| | | json.put("positionId", positionId);
|
| | | |
| | |
|
| | | if (!StringUtil.isNullOrEmpty(couponUrl))
|
| | | json.put("couponUrl", couponUrl);
|
| | | |
| | |
|
| | | if (!StringUtil.isNullOrEmpty(ext1))
|
| | | json.put("ext1", ext1);
|
| | | json.put("ext1", ext1);
|
| | |
|
| | | JSONObject root = new JSONObject();
|
| | | root.put("promotionCodeReq", json);
|
| | |
|
| | | String result = baseRequest("jd.union.open.promotion.common.get", null, root);
|
| | | |
| | |
|
| | | JSONObject resultJson = JSONObject.fromObject(result);
|
| | | result = resultJson.optJSONObject("jd_union_open_promotion_common_get_response").optString("result");
|
| | | if (result == null) {
|
| | | return null;
|
| | | }
|
| | | |
| | |
|
| | | resultJson = JSONObject.fromObject(result);
|
| | | return resultJson.optJSONObject("data").optString("clickURL");
|
| | | }
|
| | | |
| | |
|
| | | /**
|
| | | * 转链接-短连接
|
| | | * |
| | | * @param materialId
|
| | | * @param couponUrl
|
| | | * @param positionId
|
| | |
| | | }
|
| | | return url;
|
| | | }
|
| | | |
| | | |
| | |
|
| | | public static JDGoods queryGoodsDetail(Long skuId) {
|
| | | List<Long> skuIdList = new ArrayList<>();
|
| | | skuIdList.add(skuId);
|
| | |
| | | }
|
| | | return null;
|
| | | }
|
| | | |
| | |
|
| | | /**
|
| | | * 关键词商品查询接口【申请】
|
| | | * |
| | | * @param skuIdList
|
| | | * @return
|
| | | */
|
| | | public static JDSearchResult queryByKey(JDFilter filter) {
|
| | | JDSearchResult searchResult = new JDSearchResult();
|
| | | |
| | |
|
| | | List<JDGoods> list = new ArrayList<>();
|
| | | JSONObject json = new JSONObject();
|
| | | json.put("pageIndex", filter.getPageIndex());
|
| | |
| | |
|
| | | if (filter.getShopId() != null)
|
| | | json.put("shopId", filter.getShopId());
|
| | | |
| | |
|
| | | if (filter.getOwner() != null)
|
| | | json.put("owner", filter.getOwner());
|
| | | |
| | |
|
| | | System.out.println(json.toString());
|
| | | |
| | |
|
| | | JSONObject jsonDTO = new JSONObject();
|
| | | jsonDTO.put("goodsReqDTO", json);
|
| | | |
| | | |
| | |
|
| | | String result = baseRequest2("jd.union.open.goods.query", null, jsonDTO);
|
| | | System.out.println(result);
|
| | | JSONObject resultJson = JSONObject.fromObject(result);
|
| | |
| | | }
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | long totalCount = resultJson.optLong("totalCount");
|
| | | PageEntity pageEntity = new PageEntity();
|
| | | pageEntity.setTotalCount(totalCount);
|
| | | |
| | |
|
| | | searchResult.setPageEntity(pageEntity);
|
| | | }
|
| | | searchResult.setGoodsList(list);
|
| | | return searchResult;
|
| | | }
|
| | | |
| | | |
| | | |
| | | |
| | |
|
| | | private static JDGoods parseJDGoods(JSONObject json) {
|
| | | JDGoods goods = new JDGoods();
|
| | | |
| | |
|
| | | // 佣金信息
|
| | | Object commission = json.get("commissionInfo");
|
| | | JSONObject commissionJson = JSONObject.fromObject(commission);
|
| | |
| | | } else {
|
| | | return null;
|
| | | }
|
| | | |
| | |
|
| | | goods.setComments(json.optLong("comments"));
|
| | | goods.setBrandCode(json.optString("brandCode"));
|
| | | goods.setBrandName(json.optString("brandName"));
|
| | |
| | | goods.setSkuId(json.optLong("skuId"));
|
| | | goods.setSkuName(json.optString("skuName"));
|
| | | goods.setIsHot(json.optInt("isHot"));
|
| | | |
| | | |
| | |
|
| | | // 价格信息
|
| | | Object priceInfo = json.get("priceInfo");
|
| | | JSONObject priceInfoJson = JSONObject.fromObject(priceInfo);
|
| | | goods.setPrice(new BigDecimal(priceInfoJson.optString("price")));
|
| | | |
| | |
|
| | | // 店铺信息
|
| | | Object shopInfo = json.get("shopInfo");
|
| | | JSONObject shopInfoJson = JSONObject.fromObject(shopInfo);
|
| | |
| | | jdshopInfo.setShopId(shopInfoJson.optInt("shopId"));
|
| | | jdshopInfo.setShopName(shopInfoJson.optString("shopName"));
|
| | | goods.setShopInfo(jdshopInfo);
|
| | | |
| | | |
| | |
|
| | | // 分类信息
|
| | | Object category = json.get("categoryInfo");
|
| | | JSONObject categoryJson = JSONObject.fromObject(category);
|
| | |
| | | categoryInfo.setCid3(categoryJson.optLong("cid3"));
|
| | | categoryInfo.setCid3Name(categoryJson.optString("cid3Name"));
|
| | | goods.setCategoryInfo(categoryInfo);
|
| | | |
| | | |
| | |
|
| | | // 图片信息
|
| | | List<String> imageList = new ArrayList<String>();
|
| | | Object images = json.get("imageInfo");
|
| | |
| | | imageList.add(imagesArray.optJSONObject(i).optString("url"));
|
| | | }
|
| | | goods.setImageList(imageList);
|
| | | |
| | |
|
| | | if (imageList.size() > 0) {
|
| | | goods.setPicUrl(imageList.get(0));
|
| | | }
|
| | | |
| | |
|
| | | BigDecimal price = new BigDecimal(priceInfoJson.optString("price"));
|
| | | // 拼购信息
|
| | | Object pinGouInfo = json.get("pinGouInfo");
|
| | |
| | | goods.setPinGouInfo(jdPinGouInfo);
|
| | | }
|
| | | }
|
| | | |
| | | |
| | | |
| | |
|
| | | // 券信息
|
| | | Object coupon = json.get("couponInfo");
|
| | | if (coupon != null) {
|
| | |
| | | for (int i = 0; i < couponArray.size(); i++) {
|
| | | boolean add = false;
|
| | | JSONObject jdcoupon = couponArray.optJSONObject(i);
|
| | | |
| | |
|
| | | BigDecimal quota = new BigDecimal(jdcoupon.optString("quota"));
|
| | | BigDecimal sub = MoneyBigDecimalUtil.sub(price, quota);
|
| | | if (sub.compareTo(new BigDecimal(0)) < 0) {
|
| | | continue; // 商品价格小于优惠券价格限制
|
| | | }
|
| | | |
| | |
|
| | | // 券面额
|
| | | BigDecimal discount = new BigDecimal(jdcoupon.optString("discount"));
|
| | | if (discount_temp == null) {
|
| | |
| | | } else if (discount_temp.compareTo(discount) > 0) { // 券面额大
|
| | | add = true;
|
| | | }
|
| | | |
| | |
|
| | | if (add) {
|
| | | if (couponInfo == null) {
|
| | | couponInfo = new JDCouponInfo();
|
| | | }
|
| | | |
| | |
|
| | | couponInfo.setBindType(jdcoupon.optInt("bindType"));
|
| | | couponInfo.setDiscount(new BigDecimal(jdcoupon.optString("discount")));
|
| | | couponInfo.setQuota(new BigDecimal(jdcoupon.optString("quota")));
|
| | |
| | | couponInfo.setLink(jdcoupon.optString("link"));
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | goods.setCouponInfo(couponInfo);
|
| | | }
|
| | | }
|
| | |
|
| | | |
| | | |
| | | return goods;
|
| | | }
|
| | |
|
| | |
|
| | | /**
|
| | | * 获取推广商品信息接口
|
| | | * |
| | | * @param skuIdList
|
| | | * @return
|
| | | */
|
| | |
| | | goods.setPrice(StringUtil.isNullOrEmpty(json.optString("wlUnitPrice"))
|
| | | ? new BigDecimal(json.optString("unitPrice")) : new BigDecimal(json.optString("wlUnitPrice")));
|
| | |
|
| | | |
| | | BigDecimal commisionRatioWl = new BigDecimal(json.optString("commisionRatioWl"));
|
| | | if (commisionRatioWl.compareTo(new BigDecimal(0)) > 0) {
|
| | | JDCommissionInfo commissionInfo = new JDCommissionInfo();
|
| | |
| | | } else {
|
| | | return null;
|
| | | }
|
| | | |
| | |
|
| | | JDCategoryInfo categoryInfo = new JDCategoryInfo();
|
| | | categoryInfo.setCid1(json.optLong("cid1"));
|
| | | categoryInfo.setCid1Name(json.optString("cid1Name"));
|
| | |
| | | if (!StringUtil.isNullOrEmpty(isFreeShipping)) {
|
| | | goods.setIsFreeShipping(Integer.parseInt(isFreeShipping));
|
| | | }
|
| | | |
| | |
|
| | | goods.setCouponInfo(null);
|
| | | goods.setGoodCommentsShare(null);
|
| | | List<String> imageList = new ArrayList<>();
|
| | |
| | |
|
| | | return goods;
|
| | | }
|
| | | |
| | | |
| | |
|
| | | public static JDSearchResult getJingFenGoods(int pageIndex, int eliteId) {
|
| | | JDSearchResult searchResult = new JDSearchResult();
|
| | | List<JDGoods> list = new ArrayList<>();
|
| | |
| | | json.put("sortName", "inOrderCount30DaysSku");
|
| | | json.put("sort", "desc");
|
| | | json.put("eliteId", eliteId);
|
| | | |
| | |
|
| | | JSONObject jsonDTO = new JSONObject();
|
| | | jsonDTO.put("goodsReq", json);
|
| | | |
| | | |
| | |
|
| | | String result = baseRequest2("jd.union.open.goods.jingfen.query", null, jsonDTO);
|
| | | System.out.println(result);
|
| | | JSONObject resultJson = JSONObject.fromObject(result);
|
| | |
| | | }
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | long totalCount = resultJson.optLong("totalCount");
|
| | | PageEntity pageEntity = new PageEntity();
|
| | | pageEntity.setTotalCount(totalCount);
|
| | | |
| | |
|
| | | searchResult.setPageEntity(pageEntity);
|
| | | }
|
| | | searchResult.setGoodsList(list);
|
| | | return searchResult;
|
| | | }
|
| | | |
| | | |
| | |
|
| | | public static JDSearchResult getGoodsClass() {
|
| | | JDSearchResult searchResult = new JDSearchResult();
|
| | | List<JDGoods> list = new ArrayList<>();
|
| | | JSONObject json = new JSONObject();
|
| | | json.put("parentId", 0);
|
| | | json.put("grade", 0);
|
| | | |
| | |
|
| | | JSONObject jsonDTO = new JSONObject();
|
| | | jsonDTO.put("req", json);
|
| | | |
| | | |
| | |
|
| | | String result = baseRequest2("jd.union.open.category.goods.get", null, jsonDTO);
|
| | | System.out.println(result);
|
| | | JSONObject resultJson = JSONObject.fromObject(result);
|
| | |
| | | }
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | long totalCount = resultJson.optLong("totalCount");
|
| | | PageEntity pageEntity = new PageEntity();
|
| | | pageEntity.setTotalCount(totalCount);
|
| | | |
| | |
|
| | | searchResult.setPageEntity(pageEntity);
|
| | | }
|
| | | searchResult.setGoodsList(list);
|
| | | return searchResult;
|
| | | }
|
| | | |
| | |
|
| | | public static JDGoods getGoodsDetail(Long skuId) {
|
| | | List<Long> skuIdList = new ArrayList<>();
|
| | |
| | | return null;
|
| | | }
|
| | |
|
| | | public static JDOrderResult getOrder(int page, int pageSize, String time, int type) {
|
| | | /**
|
| | | * 获取订单列表
|
| | | * |
| | | * @param page
|
| | | * @param pageSize
|
| | | * @param time
|
| | | * @param type
|
| | | * 时间类型 1-下单时间 2-完成时间 3-更新时间
|
| | | * @return
|
| | | */
|
| | | public static JDOrderResult getOrderList(int page, int pageSize, Date time, int type) {
|
| | | JSONObject json = new JSONObject();
|
| | | JSONObject orderReq = new JSONObject();
|
| | | orderReq.put("pageNo", page);
|
| | | orderReq.put("pageSize", pageSize);
|
| | | orderReq.put("type", type);
|
| | | orderReq.put("time", time);
|
| | | orderReq.put("time", TimeUtil.getGernalTime(time.getTime(), "yyyyMMddHH"));
|
| | |
|
| | | json.put("orderReq", orderReq);
|
| | | String result = baseRequest("jd.union.open.order.query", null, json);
|
| | | String result = baseRequest2("jd.union.open.order.query", null, json);
|
| | | try {
|
| | | System.out.println(new String(result.getBytes("GBK"), "UTF-8"));
|
| | | System.out.println(new String(result.getBytes("ISO-8859-1"), "UTF-8"));
|
| | | } catch (UnsupportedEncodingException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | JSONObject root = JSONObject.fromObject(result).optJSONObject("jd_union_open_order_query_response");
|
| | | if (root.optInt("code") == 0) {
|
| | | boolean hasMore = root.optBoolean("hasMore");
|
| | |
| | | System.out.println(result);
|
| | | }
|
| | |
|
| | | |
| | | /**
|
| | | * 搜索网页
|
| | | * |
| | | * @param searchFilter
|
| | | * @return
|
| | | */
|
| | |
| | | params.put("pageNo", searchFilter.getPageNo());
|
| | | params.put("pageSize", searchFilter.getPageSize());
|
| | | params.put("searchUUID", StringUtil.Md5(System.currentTimeMillis() + ""));
|
| | | |
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("lock", "0");
|
| | | data.put("deliveryType", searchFilter.getDeliveryType());
|
| | |
| | | data.put("isPinGou", searchFilter.getIsPinGou());
|
| | | data.put("isZY", searchFilter.getIsZY());
|
| | | data.put("orientationFlag", searchFilter.getOrientationFlag());
|
| | | |
| | |
|
| | | // 分类
|
| | | data.put("categoryId", searchFilter.getCategoryId());
|
| | | data.put("cat2Id", searchFilter.getCat2Id());
|
| | | data.put("cat3Id", searchFilter.getCat3Id());
|
| | | |
| | |
|
| | | data.put("fromCommissionRatio", searchFilter.getFromCommissionRatio());
|
| | | data.put("toCommissionRatio", searchFilter.getToCommissionRatio());
|
| | | data.put("fromPrice", searchFilter.getFromPrice());
|
| | | data.put("toPrice", searchFilter.getToPrice());
|
| | | |
| | |
|
| | | String key = searchFilter.getKey();
|
| | | if (StringUtil.isNullOrEmpty(key)) {
|
| | | data.put("key", "");
|
| | |
| | | data.put("keywordType", "kt1");
|
| | | data.put("searchType", "st3");
|
| | | }
|
| | | |
| | |
|
| | | String sortName = searchFilter.getSortName();
|
| | | if (StringUtil.isNullOrEmpty(sortName)) {
|
| | | data.put("sort", null);
|
| | |
| | | String sort = searchFilter.getSort();
|
| | | if (StringUtil.isNullOrEmpty(sort)) {
|
| | | sort = JDSearchFilter.SORT_DESC;
|
| | | } |
| | | }
|
| | | data.put("sort", sort);
|
| | | }
|
| | | params.put("data", data);
|
| | | |
| | |
|
| | | System.out.println(params.toString());
|
| | | |
| | |
|
| | | HttpClient client = new HttpClient();
|
| | | PostMethod pm = new PostMethod("https://union.jd.com/api/goods/search");
|
| | | pm.setRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; rv:11.0) like Gecko");
|
| | |
| | | searchResult.setGoodsList(goodsList);
|
| | | return searchResult;
|
| | | }
|
| | | |
| | | |
| | |
|
| | | /**
|
| | | * 搜索网页
|
| | | * |
| | | * @param searchFilter
|
| | | * @return
|
| | | */
|
| | |
| | | params.put("pageNo", 1);
|
| | | params.put("pageSize", 60);
|
| | | params.put("searchUUID", StringUtil.Md5(System.currentTimeMillis() + ""));
|
| | | |
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("lock", "0");
|
| | | data.put("deliveryType", 0);
|
| | | data.put("hasCoupon",0);
|
| | | data.put("hasCoupon", 0);
|
| | | data.put("isCare", 0);
|
| | | data.put("isPinGou", 0);
|
| | | data.put("isZY", 0);
|
| | | data.put("orientationFlag", 0);
|
| | | |
| | |
|
| | | data.put("key", skuId);
|
| | | data.put("keywordType", "kt0");
|
| | | data.put("searchType", "st2");
|
| | | params.put("data", data);
|
| | | |
| | |
|
| | | HttpClient client = new HttpClient();
|
| | | PostMethod pm = new PostMethod("https://union.jd.com/api/goods/search");
|
| | | pm.setRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; rv:11.0) like Gecko");
|
| | |
| | | return null;
|
| | | }
|
| | |
|
| | | |
| | | private static JDGoods parseGoods(String data) {
|
| | | JDGoods goods = new JDGoods();
|
| | | JSONObject json = JSONObject.fromObject(data);
|
| | | |
| | |
|
| | | BigDecimal wlCommissionRatio = new BigDecimal(json.optString("wlCommissionRatio"));
|
| | | if (wlCommissionRatio.compareTo(new BigDecimal(0)) > 0) {
|
| | | JDCommissionInfo commission = new JDCommissionInfo();
|
| | |
| | | } else {
|
| | | return null; // 过滤无返利商品
|
| | | }
|
| | | |
| | |
|
| | | goods.setSkuId(json.optLong("skuId"));
|
| | | goods.setSkuName(json.optString("skuName"));
|
| | | |
| | |
|
| | | JDShopInfo shopInfo = new JDShopInfo();
|
| | | shopInfo.setShopId(json.optInt("shopId"));
|
| | | shopInfo.setShopName(json.optString("shopName"));
|
| | | goods.setShopInfo(shopInfo);
|
| | | goods.setPrice(new BigDecimal(json.optString("wlPrice")));
|
| | | |
| | |
|
| | | goods.setInOrderCount30Days(json.optLong("inOrderCount30Days"));
|
| | | |
| | |
|
| | | if (json.optInt("isZY") == 1)
|
| | | goods.setOwner("g");
|
| | | else
|
| | | goods.setOwner("p");
|
| | | |
| | | goods.setMaterialUrl("https://item.jd.com/"+ json.optLong("skuId") +".html");
|
| | |
|
| | | goods.setMaterialUrl("https://item.jd.com/" + json.optLong("skuId") + ".html");
|
| | | goods.setPicUrl("http://img14.360buyimg.com/n1/" + json.optString("materialUrl"));
|
| | | |
| | |
|
| | | goods.setGoodCommentsShare(new BigDecimal(json.optString("goodCommentsShare")));
|
| | |
|
| | | // 团购信息
|
| | |
| | | jdPinGouInfo.setPingouPrice(new BigDecimal(json.optString("pingouPrice")));
|
| | | jdPinGouInfo.setPingouTmCount(json.optLong("pingouTmCount"));
|
| | | goods.setPinGouInfo(jdPinGouInfo);
|
| | | } |
| | | |
| | | |
| | | }
|
| | |
|
| | | String finalPrice = json.optString("finalPrice");
|
| | | if (!StringUtil.isNullOrEmpty(finalPrice)) {
|
| | | // 券信息
|
| | |
| | | coupon.setQuota(new BigDecimal(json.optString("couponQuota")));
|
| | | coupon.setLink("https:" + json.optString("couponLink"));
|
| | | goods.setCouponInfo(coupon);
|
| | | } |
| | | }
|
| | | }
|
| | | |
| | | |
| | |
|
| | | return goods;
|
| | | }
|
| | | |
| | | |
| | |
|
| | | /**
|
| | | * 商品佣金计算
|
| | | * |
| | | * @param goods
|
| | | * @param rate
|
| | | * @return
|
| | | */
|
| | | public static BigDecimal getGoodsFanLiMoney(JDGoods goods, BigDecimal rate) {
|
| | | BigDecimal money = null;
|
| | | |
| | |
|
| | | JDCommissionInfo commissionInfo = goods.getCommissionInfo();
|
| | | if (commissionInfo == null) {
|
| | | return money;
|
| | | }
|
| | | |
| | |
|
| | | BigDecimal price = null;
|
| | | JDPingouInfo pinGouInfo = goods.getPinGouInfo();
|
| | | if (pinGouInfo == null) {
|
| | | price = goods.getPrice();
|
| | | price = goods.getPrice();
|
| | | } else {
|
| | | price = pinGouInfo.getPingouPrice();
|
| | | price = pinGouInfo.getPingouPrice();
|
| | | }
|
| | | |
| | |
|
| | | JDCouponInfo couponInfo = goods.getCouponInfo();
|
| | | if (couponInfo == null) {
|
| | | money = MoneyBigDecimalUtil.mul(MoneyBigDecimalUtil.mul(
|
| | | MoneyBigDecimalUtil.mul(price,commissionInfo.getCommissionShare()),
|
| | | new BigDecimal("0.01")), MoneyBigDecimalUtil.div(rate, new BigDecimal(100)));
|
| | | money = MoneyBigDecimalUtil.mul(MoneyBigDecimalUtil
|
| | | .mul(MoneyBigDecimalUtil.mul(price, commissionInfo.getCommissionShare()), new BigDecimal("0.01")),
|
| | | MoneyBigDecimalUtil.div(rate, new BigDecimal(100)));
|
| | | } else {
|
| | | BigDecimal quota = couponInfo.getQuota();
|
| | | BigDecimal discount = couponInfo.getDiscount();
|
| | | if (quota.compareTo(price) <= 0 && price.compareTo(discount) > 0) {
|
| | | |
| | |
|
| | | BigDecimal finalPrice = price.subtract(discount);
|
| | | money = MoneyBigDecimalUtil.mul(MoneyBigDecimalUtil
|
| | | .mul(MoneyBigDecimalUtil.mul(finalPrice, commissionInfo.getCommissionShare()), new BigDecimal("0.01")),
|
| | | MoneyBigDecimalUtil.div(rate, new BigDecimal(100)));
|
| | | money = MoneyBigDecimalUtil.mul(MoneyBigDecimalUtil.mul(
|
| | | MoneyBigDecimalUtil.mul(finalPrice, commissionInfo.getCommissionShare()),
|
| | | new BigDecimal("0.01")), MoneyBigDecimalUtil.div(rate, new BigDecimal(100)));
|
| | |
|
| | | } else {// 不能用券
|
| | | money = MoneyBigDecimalUtil.mul(MoneyBigDecimalUtil.mul(
|
| | | MoneyBigDecimalUtil.mul(price,commissionInfo.getCommissionShare()),
|
| | | new BigDecimal("0.01")), MoneyBigDecimalUtil.div(rate, new BigDecimal(100)));
|
| | | money = MoneyBigDecimalUtil.mul(
|
| | | MoneyBigDecimalUtil.mul(MoneyBigDecimalUtil.mul(price, commissionInfo.getCommissionShare()),
|
| | | new BigDecimal("0.01")),
|
| | | MoneyBigDecimalUtil.div(rate, new BigDecimal(100)));
|
| | | }
|
| | | |
| | |
|
| | | }
|
| | | return BigDecimalUtil.getWithNoZera(money);
|
| | | }
|
| | | |
| | | |
| | |
|
| | | /**
|
| | | * 计算商品券后价,没有券则返回原价
|
| | | *
|
| | |
| | | JDCouponInfo couponInfo = jdGoods.getCouponInfo();
|
| | | if (couponInfo == null) {
|
| | | return jdGoods.getPrice();
|
| | | } |
| | | |
| | | }
|
| | |
|
| | | BigDecimal discount = couponInfo.getDiscount();
|
| | | BigDecimal price = null;
|
| | | JDPingouInfo pinGouInfo = jdGoods.getPinGouInfo();
|
| | | if (pinGouInfo == null) {
|
| | | price = jdGoods.getPrice();
|
| | | price = jdGoods.getPrice();
|
| | | } else {
|
| | | price = pinGouInfo.getPingouPrice();
|
| | | price = pinGouInfo.getPingouPrice();
|
| | | }
|
| | | // 计算券后价
|
| | | BigDecimal sub = price.subtract(couponInfo.getQuota());
|
| | |
| | | return jdGoods.getPrice();
|
| | | }
|
| | | }
|
| | | |
| | | |
| | |
|
| | | /**
|
| | | * 销量处理
|
| | | * |
| | | * @param count
|
| | | * @return
|
| | | */
|
| | |
| | | }
|
| | | return salesCountMidea;
|
| | | }
|
| | | |
| | | /** |
| | |
|
| | | /**
|
| | | * 搜索候选词
|
| | | * |
| | | * @param key
|
| | | * @return
|
| | | */
|
| | |
| | | return list;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 根据链接提取商品ID
|
| | | * @param url
|
| | | * @return
|
| | | */
|
| | | public static String parseJDSkuIdByUrl(String url) {
|
| | | try {
|
| | | if (url.startsWith("https://item.m.jd.com/product/") || url.startsWith("http://item.m.jd.com/product/")
|
| | | || url.startsWith("https://item.jd.com/") || url.startsWith("http://item.jd.com/")) {
|
| | | String preUrl = url.split("\\?")[0];
|
| | | String index = preUrl.split("/")[preUrl.split("/").length - 1];
|
| | | index = index.split("\\.")[0];
|
| | | return index.trim();
|
| | | }
|
| | | } catch (Exception e) {
|
| | | }
|
| | | return null;
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | import java.net.URLEncoder;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Collections;
|
| | | import java.util.Date;
|
| | | import java.util.HashMap;
|
| | | import java.util.Iterator;
|
| | | import java.util.List;
|
| | |
| | | import com.yeshi.fanli.entity.pdd.PDDOrder;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | |
|
| | | import net.sf.json.JSONArray;
|
| | | import net.sf.json.JSONObject;
|
| | |
| | |
|
| | | /**
|
| | | * 多多进宝商品查询
|
| | | * |
| | | * @param sf
|
| | | * @return
|
| | | */
|
| | |
| | | map.put("keyword", sf.getKw());
|
| | | if (sf.getGoodsIdList() != null)
|
| | | map.put("goods_id_list", "[" + StringUtil.concat(sf.getGoodsIdList(), ",") + "]");
|
| | | |
| | | |
| | |
|
| | | map.put("pid", PID_FANLI);
|
| | | String result = baseRequest(map);
|
| | | JSONObject json = JSONObject.fromObject(result);
|
| | | JSONObject root = json.optJSONObject("goods_search_response");
|
| | | if (root == null) {
|
| | | return null;
|
| | | } |
| | | |
| | | }
|
| | |
|
| | | JSONArray array = root.optJSONArray("goods_list");
|
| | | if (array == null) {
|
| | | return null;
|
| | | }
|
| | | |
| | |
|
| | | Type type = new TypeToken<List<PDDGoodsDetail>>() {
|
| | | }.getType();
|
| | | |
| | |
|
| | | Gson gson = new GsonBuilder().disableHtmlEscaping().create();
|
| | | List<PDDGoodsDetail> goodsList = gson.fromJson(array.toString(), type);
|
| | | int totalCount = root.optInt("total_count");
|
| | | return new PDDGoodsResult(totalCount, goodsList);
|
| | | }
|
| | | |
| | | |
| | |
|
| | | /**
|
| | | * 运营频道商品查询API
|
| | | * 运营频道商品查询API
|
| | | * |
| | | * @param page
|
| | | * @param pageSize
|
| | | * @param channelType 频道类型;0, "1.9包邮", 1, "今日爆款", 2, "品牌清仓", 非必填 ,默认是1
|
| | | * @param channelType
|
| | | * 频道类型;0, "1.9包邮", 1, "今日爆款", 2, "品牌清仓", 非必填 ,默认是1
|
| | | * @return
|
| | | */
|
| | | public static PDDGoodsResult searchByChannelType(Integer page, Integer pageSize, String channelType) {
|
| | | Map<String, String> map = new HashMap<>();
|
| | | map.put("type", "pdd.ddk.goods.recommend.get");
|
| | | map.put("offset", (page == null?0:page) + "");
|
| | | map.put("offset", (pageSize == null?Constant.PAGE_SIZE:pageSize) + "");
|
| | | |
| | | map.put("offset", (page == null ? 0 : page) + "");
|
| | | map.put("offset", (pageSize == null ? Constant.PAGE_SIZE : pageSize) + "");
|
| | |
|
| | | if (channelType != null)
|
| | | map.put("channel_type", channelType);
|
| | | |
| | |
|
| | | map.put("pid", PID_FANLI);
|
| | | String result = baseRequest(map);
|
| | | |
| | |
|
| | | JSONObject json = JSONObject.fromObject(result);
|
| | | JSONObject root = json.optJSONObject("goods_basic_detail_response");
|
| | | if (root == null) {
|
| | |
| | | if (array == null) {
|
| | | return null;
|
| | | }
|
| | | |
| | |
|
| | | Type type = new TypeToken<List<PDDGoodsDetail>>() {
|
| | | }.getType();
|
| | | |
| | |
|
| | | Gson gson = new GsonBuilder().disableHtmlEscaping().create();
|
| | | List<PDDGoodsDetail> goodsList = gson.fromJson(array.toString(), type);
|
| | | int totalCount = root.optInt("total");
|
| | | return new PDDGoodsResult(totalCount, goodsList);
|
| | | }
|
| | | |
| | |
|
| | | public static void getGoodsClass() {
|
| | | Map<String, String> map = new HashMap<>();
|
| | | map.put("type", "pdd.goods.cats.get");
|
| | | map.put("parent_cat_id", "0");
|
| | | String result = baseRequest(map);
|
| | | |
| | |
|
| | | JSONObject json = JSONObject.fromObject(result);
|
| | | JSONObject root = json.optJSONObject("goods_cats_get_response");
|
| | | JSONArray array = root.optJSONArray("goods_cats_list");
|
| | | }
|
| | | |
| | | |
| | |
|
| | | public static void getThemes(Integer page, Integer pageSize) {
|
| | | Map<String, String> map = new HashMap<>();
|
| | | map.put("type", "pdd.ddk.theme.list.get");
|
| | | map.put("page", page + "");
|
| | | map.put("page_size", pageSize + "");
|
| | | map.put("page_size", pageSize + "");
|
| | | String result = baseRequest(map);
|
| | | |
| | |
|
| | | JSONObject json = JSONObject.fromObject(result);
|
| | | JSONObject root = json.optJSONObject("theme_list_get_response");
|
| | | JSONArray array = root.optJSONArray("theme_list");
|
| | |
| | | System.out.println(array.optJSONObject(i).optString("goods_num"));
|
| | | System.out.println("-------------------------------------------");
|
| | | }
|
| | | |
| | |
|
| | | System.out.println(root.optLong("total"));
|
| | | }
|
| | | |
| | | |
| | |
|
| | | public static void getGoodsOpt() {
|
| | | Map<String, String> map = new HashMap<>();
|
| | | map.put("type", "pdd.goods.opt.get");
|
| | | map.put("parent_opt_id", "0");
|
| | | String result = baseRequest(map);
|
| | | |
| | |
|
| | | JSONObject json = JSONObject.fromObject(result);
|
| | | JSONObject root = json.optJSONObject("goods_opt_get_response");
|
| | | JSONArray array = root.optJSONArray("goods_opt_list");
|
| | | }
|
| | | |
| | | |
| | |
|
| | | /**
|
| | | * 多多客获取爆款排行商品接口
|
| | | * @param pid 推广位id (非必填)
|
| | | * @param page 从多少位置开始请求;默认值 : 0 (非必填)
|
| | | * @param pageSize 请求数量;默认值 :20 (非必填)
|
| | | * @param sortType 1-实时热销榜;2-实时收益榜 (非必填)
|
| | | * |
| | | * @param pid
|
| | | * 推广位id (非必填)
|
| | | * @param page
|
| | | * 从多少位置开始请求;默认值 : 0 (非必填)
|
| | | * @param pageSize
|
| | | * 请求数量;默认值 :20 (非必填)
|
| | | * @param sortType
|
| | | * 1-实时热销榜;2-实时收益榜 (非必填)
|
| | | * @return
|
| | | */
|
| | | public static PDDGoodsResult getTopList(String pid, Integer page, Integer pageSize, Integer sortType) {
|
| | | Map<String, String> map = new HashMap<>();
|
| | | map.put("type", "pdd.ddk.top.goods.list.query");
|
| | | map.put("offset", (page == null? 0: (page-1) * Constant.PAGE_SIZE) +"");
|
| | | map.put("limit", (pageSize == null? Constant.PAGE_SIZE : pageSize) +"");
|
| | | |
| | | map.put("offset", (page == null ? 0 : (page - 1) * Constant.PAGE_SIZE) + "");
|
| | | map.put("limit", (pageSize == null ? Constant.PAGE_SIZE : pageSize) + "");
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(pid))
|
| | | map.put("p_id", pid + "");
|
| | | |
| | |
|
| | | if (sortType != null)
|
| | | map.put("sort_type", sortType + "");
|
| | | |
| | |
|
| | | String result = baseRequest(map);
|
| | | JSONObject json = JSONObject.fromObject(result);
|
| | | JSONObject root = json.optJSONObject("top_goods_list_get_response");
|
| | |
| | | if (array == null) {
|
| | | return null;
|
| | | }
|
| | | |
| | | Type type = new TypeToken<List<PDDGoodsDetail>>() {}.getType();
|
| | | |
| | |
|
| | | Type type = new TypeToken<List<PDDGoodsDetail>>() {
|
| | | }.getType();
|
| | |
|
| | | Gson gson = new GsonBuilder().disableHtmlEscaping().create();
|
| | | List<PDDGoodsDetail> goodsList = gson.fromJson(array.toString(), type);
|
| | | //int totalCount = root.optInt("total");
|
| | | // int totalCount = root.optInt("total");
|
| | | int totalCount = 400; // 默认设置成400
|
| | | return new PDDGoodsResult(totalCount, goodsList);
|
| | | }
|
| | |
|
| | |
|
| | | /**
|
| | | * 商品转链
|
| | |
| | | map.put("p_id", pid);
|
| | | map.put("multi_group", "true");
|
| | | map.put("generate_weapp_webview", "true");
|
| | | // map.put("generate_weiboapp_webview", "true");
|
| | | // map.put("generate_weiboapp_webview", "true");
|
| | | JSONArray array = new JSONArray();
|
| | | array.add(goodsId);
|
| | | map.put("goods_id_list", array.toString());
|
| | |
| | | * 与开始时间不得大于24小时
|
| | | * @return
|
| | | */
|
| | | public static PDDOrderResult getOrders(int page, int pageSize, long startTime, long endTime) {
|
| | | public static PDDOrderResult getOrdersList(int page, int pageSize, long startTime, long endTime) {
|
| | | Map<String, String> map = new HashMap<>();
|
| | | map.put("type", "pdd.ddk.order.list.increment.get");
|
| | | map.put("start_update_time", startTime / 1000 + "");
|
| | |
| | | if (root == null) {
|
| | | return null;
|
| | | }
|
| | | |
| | |
|
| | | JSONArray resultArray = root.optJSONArray("goods_details");
|
| | | if (resultArray == null) {
|
| | | return null;
|
| | | }
|
| | | |
| | |
|
| | | Type type = new TypeToken<List<PDDGoodsDetail>>() {
|
| | | }.getType();
|
| | | List<PDDGoodsDetail> goodsList = new Gson().fromJson(resultArray.toString(), type);
|
| | |
| | | return goodsList.get(0);
|
| | | return null;
|
| | | }
|
| | | |
| | | |
| | |
|
| | | /**
|
| | | * 获取商品详情
|
| | | *
|
| | |
| | | JSONObject root = resultJson.optJSONObject("ddk_phrase_generate_response");
|
| | | if (root != null) {
|
| | | array = root.optJSONArray("promotion_phrase_list");
|
| | | JSONObject phraseObject = JSONObject.fromObject( array.get(0));
|
| | | JSONObject phraseObject = JSONObject.fromObject(array.get(0));
|
| | | return phraseObject.optString("phrase");
|
| | | }
|
| | | |
| | |
|
| | | return null;
|
| | | }
|
| | |
|
| | | public static Date getSystemTime() {
|
| | | try {
|
| | | Map<String, String> map = new HashMap<>();
|
| | | map.put("type", "pdd.time.get");
|
| | | String result = baseRequest(map);
|
| | | String time = JSONObject.fromObject(result).optJSONObject("time_get_response").optString("time");
|
| | | return new Date(TimeUtil.convertToTimeTemp(time, "yyyy-MM-dd HH:mm:ss"));
|
| | | } catch (Exception e) {
|
| | | }
|
| | | return null;
|
| | | }
|
| | |
|