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;
|
| | |
| | | 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 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 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());
|
| | |
| | |
|
| | | /**
|
| | | * 转链接-短连接
|
| | | * |
| | | * @param materialId
|
| | | * @param couponUrl
|
| | | * @param positionId
|
| | |
| | | }
|
| | | return url;
|
| | | }
|
| | | |
| | |
|
| | | public static JDGoods queryGoodsDetail(Long skuId) {
|
| | | List<Long> skuIdList = new ArrayList<>();
|
| | |
| | |
|
| | | /**
|
| | | * 关键词商品查询接口【申请】
|
| | | * |
| | | * @param skuIdList
|
| | | * @return
|
| | | */
|
| | |
| | | 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);
|
| | |
| | | return searchResult;
|
| | | }
|
| | |
|
| | | |
| | | |
| | | |
| | | private static JDGoods parseJDGoods(JSONObject json) {
|
| | | JDGoods goods = new JDGoods();
|
| | |
|
| | |
| | | goods.setSkuName(json.optString("skuName"));
|
| | | goods.setIsHot(json.optInt("isHot"));
|
| | |
|
| | | |
| | | // 价格信息
|
| | | Object priceInfo = json.get("priceInfo");
|
| | | JSONObject priceInfoJson = JSONObject.fromObject(priceInfo);
|
| | |
| | | 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>();
|
| | |
| | | goods.setPinGouInfo(jdPinGouInfo);
|
| | | }
|
| | | }
|
| | | |
| | | |
| | |
|
| | | // 券信息
|
| | | Object coupon = json.get("couponInfo");
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | |
| | | |
| | | return goods;
|
| | | }
|
| | |
|
| | |
|
| | | /**
|
| | | * 获取推广商品信息接口
|
| | | * |
| | | * @param skuIdList
|
| | | * @return
|
| | | */
|
| | |
| | | JDGoods goods = new JDGoods();
|
| | | 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) {
|
| | |
| | | return goods;
|
| | | }
|
| | |
|
| | | |
| | | public static JDSearchResult getJingFenGoods(int pageIndex, int eliteId) {
|
| | | JDSearchResult searchResult = new JDSearchResult();
|
| | | List<JDGoods> list = new ArrayList<>();
|
| | |
| | |
|
| | | JSONObject jsonDTO = new JSONObject();
|
| | | jsonDTO.put("goodsReq", json);
|
| | | |
| | |
|
| | | String result = baseRequest2("jd.union.open.goods.jingfen.query", null, jsonDTO);
|
| | | System.out.println(result);
|
| | |
| | | return searchResult;
|
| | | }
|
| | |
|
| | | |
| | | public static JDSearchResult getGoodsClass() {
|
| | | JDSearchResult searchResult = new JDSearchResult();
|
| | | List<JDGoods> list = new ArrayList<>();
|
| | |
| | |
|
| | | JSONObject jsonDTO = new JSONObject();
|
| | | jsonDTO.put("req", json);
|
| | | |
| | |
|
| | | String result = baseRequest2("jd.union.open.category.goods.get", null, jsonDTO);
|
| | | System.out.println(result);
|
| | |
| | | return searchResult;
|
| | | }
|
| | |
|
| | |
|
| | | public static JDGoods getGoodsDetail(Long skuId) {
|
| | | List<Long> skuIdList = new ArrayList<>();
|
| | | skuIdList.add(skuId);
|
| | |
| | | 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
|
| | | */
|
| | |
| | | return searchResult;
|
| | | }
|
| | |
|
| | | |
| | | /**
|
| | | * 搜索网页
|
| | | * |
| | | * @param searchFilter
|
| | | * @return
|
| | | */
|
| | |
| | | return null;
|
| | | }
|
| | |
|
| | | |
| | | private static JDGoods parseGoods(String data) {
|
| | | JDGoods goods = new JDGoods();
|
| | | JSONObject json = JSONObject.fromObject(data);
|
| | |
| | | goods.setPinGouInfo(jdPinGouInfo);
|
| | | }
|
| | |
|
| | | |
| | | String finalPrice = json.optString("finalPrice");
|
| | | if (!StringUtil.isNullOrEmpty(finalPrice)) {
|
| | | // 券信息
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | |
| | | return goods;
|
| | | }
|
| | |
|
| | | |
| | | /**
|
| | | * 商品佣金计算
|
| | | * |
| | | * @param goods
|
| | | * @param rate
|
| | | * @return
|
| | |
| | |
|
| | | 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);
|
| | | }
|
| | | |
| | |
|
| | | /**
|
| | | * 计算商品券后价,没有券则返回原价
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | |
| | | /**
|
| | | * 销量处理
|
| | | * |
| | | * @param count
|
| | | * @return
|
| | | */
|
| | |
| | |
|
| | | /**
|
| | | * 搜索候选词
|
| | | * |
| | | * @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
|
| | | */
|
| | |
| | | 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);
|
| | |
| | | return new PDDGoodsResult(totalCount, goodsList);
|
| | | }
|
| | |
|
| | | |
| | | /**
|
| | | * 运营频道商品查询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) {
|
| | |
| | | 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");
|
| | |
| | | System.out.println(root.optLong("total"));
|
| | | }
|
| | |
|
| | | |
| | | public static void getGoodsOpt() {
|
| | | Map<String, String> map = new HashMap<>();
|
| | | map.put("type", "pdd.goods.opt.get");
|
| | |
| | | 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) {
|
| | |
| | | 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 = 400; // 默认设置成400
|
| | | return new PDDGoodsResult(totalCount, goodsList);
|
| | | }
|
| | |
|
| | |
|
| | | /**
|
| | | * 商品转链
|
| | |
| | | * 与开始时间不得大于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 + "");
|
| | |
| | | return null;
|
| | | }
|
| | |
|
| | | |
| | | /**
|
| | | * 获取商品详情
|
| | | *
|
| | |
| | | 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;
|
| | | }
|
| | |
|
| | | }
|