| | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | |
| | | import com.yeshi.fanli.entity.accept.AdminAcceptData; |
| | | import com.yeshi.fanli.util.OrderConstant; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | |
| | | public class OrderAdminController { |
| | | |
| | | |
| | | @Resource |
| | | private HongBaoV2CountService hongBaoV2CountService; |
| | | @Resource |
| | | private HongBaoV2CountService hongBaoV2CountService; |
| | | |
| | | @Resource |
| | | private CommonOrderCountService commonOrderCountService; |
| | | @Resource |
| | | private CommonOrderCountService commonOrderCountService; |
| | | |
| | | @Resource |
| | | private CommonOrderService commonOrderService; |
| | | @Resource |
| | | private CommonOrderService commonOrderService; |
| | | |
| | | |
| | | @Resource |
| | | private TaoBaoOrderCountService taoBaoOrderCountService; |
| | | @Resource |
| | | private TaoBaoOrderCountService taoBaoOrderCountService; |
| | | |
| | | @Resource |
| | | private TaoBaoWeiQuanDrawBackService taoBaoWeiQuanDrawBackService; |
| | | @Resource |
| | | private TaoBaoWeiQuanDrawBackService taoBaoWeiQuanDrawBackService; |
| | | |
| | | @Resource |
| | | private TaoBaoWeiQuanOrderService taoBaoWeiQuanOrderService; |
| | | @Resource |
| | | private TaoBaoWeiQuanOrderService taoBaoWeiQuanOrderService; |
| | | |
| | | @Resource |
| | | private UserMoneyDetailService userMoneyDetailService; |
| | | @Resource |
| | | private UserMoneyDetailService userMoneyDetailService; |
| | | |
| | | @Resource |
| | | private OrderProcessService orderProcessService; |
| | | @Resource |
| | | private OrderProcessService orderProcessService; |
| | | |
| | | @Resource |
| | | private HongBaoOrderService hongBaoOrderService; |
| | | @Resource |
| | | private HongBaoOrderService hongBaoOrderService; |
| | | |
| | | @Resource |
| | | private UserMoneyDebtService userMoneyDebtService; |
| | | @Resource |
| | | private UserMoneyDebtService userMoneyDebtService; |
| | | |
| | | @Resource |
| | | private ConfigService configService; |
| | | @Resource |
| | | private ConfigService configService; |
| | | |
| | | @Resource |
| | | private UserOrderWeiQuanRecordService userOrderWeiQuanRecordService; |
| | | |
| | | @Resource |
| | | private CommonGoodsService commonGoodsService; |
| | | @Resource |
| | | private UserOrderWeiQuanRecordService userOrderWeiQuanRecordService; |
| | | |
| | | /** |
| | | * 统计历史订单-淘宝订单 |
| | | * |
| | | * @param callback |
| | | * @param request |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "countTaoBaoOrder") |
| | | public void countTaoBaoOrder(AdminAcceptData acceptData,String callback, HttpServletRequest request, PrintWriter out) { |
| | | @Resource |
| | | private CommonGoodsService commonGoodsService; |
| | | |
| | | try { |
| | | Map<String, Object> countByOdrerType = taoBaoOrderCountService.countByOdrerType(); |
| | | /** |
| | | * 统计历史订单-淘宝订单 |
| | | * |
| | | * @param callback |
| | | * @param request |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "countTaoBaoOrder") |
| | | public void countTaoBaoOrder(AdminAcceptData acceptData, String callback, HttpServletRequest request, PrintWriter out) { |
| | | |
| | | JSONObject data = new JSONObject(); |
| | | data.put("typeOrder", countByOdrerType); |
| | | try { |
| | | Map<String, Object> countByOdrerType = taoBaoOrderCountService.countByOdrerType(); |
| | | |
| | | // 统计今日 未失效订单数量 相同订单号合并为一单 |
| | | int todayOrder = taoBaoOrderCountService.countToday(); |
| | | // 统计昨日 未失效订单数量 相同订单号合并为一单 |
| | | int yesterdayOrder = taoBaoOrderCountService.countYesterday(); |
| | | JSONObject data = new JSONObject(); |
| | | data.put("typeOrder", countByOdrerType); |
| | | |
| | | data.put("todayOrder", todayOrder); |
| | | data.put("yesterdayOrder", yesterdayOrder); |
| | | data.put("genzong", yesterdayOrder); |
| | | data.put("yesterdayOrder", yesterdayOrder); |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); |
| | | } catch (Exception e) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("统计失败")); |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | // 统计今日 未失效订单数量 相同订单号合并为一单 |
| | | int todayOrder = taoBaoOrderCountService.countToday(); |
| | | // 统计昨日 未失效订单数量 相同订单号合并为一单 |
| | | int yesterdayOrder = taoBaoOrderCountService.countYesterday(); |
| | | |
| | | /** |
| | | * 查询所有用户订单列表 |
| | | * |
| | | * @param callback |
| | | * @param pageIndex |
| | | * @param pageSize |
| | | * @param state |
| | | * @param type |
| | | * @param orderState |
| | | * @param startTime |
| | | * @param endTime |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "getUserOrderList") |
| | | public void getUserOrderList(AdminAcceptData acceptData, String callback, Integer pageIndex, Integer pageSize, Integer keyType, String key, |
| | | Integer state, Integer type, Integer orderState, String startTime, String endTime, Integer sourceType, |
| | | Integer riskType, BigDecimal payment, PrintWriter out) { |
| | | data.put("todayOrder", todayOrder); |
| | | data.put("yesterdayOrder", yesterdayOrder); |
| | | data.put("genzong", yesterdayOrder); |
| | | data.put("yesterdayOrder", yesterdayOrder); |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); |
| | | } catch (Exception e) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("统计失败")); |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | if (pageIndex == null || pageIndex < 1) { |
| | | pageIndex = 1; |
| | | } |
| | | /** |
| | | * 查询所有用户订单列表 |
| | | * |
| | | * @param callback |
| | | * @param pageIndex |
| | | * @param pageSize |
| | | * @param state |
| | | * @param type |
| | | * @param orderState |
| | | * @param startTime |
| | | * @param endTime |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "getUserOrderList") |
| | | public void getUserOrderList(AdminAcceptData acceptData, String callback, Integer pageIndex, Integer pageSize, Integer keyType, String key, |
| | | Integer state, Integer type, Integer orderState, String startTime, String endTime, Integer sourceType, |
| | | Integer riskType, BigDecimal payment, PrintWriter out) { |
| | | |
| | | if (pageSize == null) |
| | | pageSize = Constant.PAGE_SIZE; |
| | | if (pageIndex == null || pageIndex < 1) { |
| | | pageIndex = 1; |
| | | } |
| | | |
| | | if (state != null && state == 0) { |
| | | state = null;// 所有状态 |
| | | } |
| | | if (pageSize == null) |
| | | pageSize = Constant.PAGE_SIZE; |
| | | |
| | | if (type != null && type == 0) { |
| | | type = null; // 所有类型订单 |
| | | } |
| | | if (state != null && state == 0) { |
| | | state = null;// 所有状态 |
| | | } |
| | | |
| | | if (endTime != null && endTime.trim().length() > 0) { |
| | | endTime += " 23:59:59"; |
| | | } |
| | | if (type != null && type == 0) { |
| | | type = null; // 所有类型订单 |
| | | } |
| | | |
| | | try { |
| | | Date minTime = null; |
| | | BigDecimal money = null; |
| | | List<Long> listShopId = null; |
| | | List<Long> listGoodsId = null; |
| | | // 风险 |
| | | if (riskType != null && !StringUtil.isNullOrEmpty(key) && keyType != null && keyType == 2) { |
| | | long uid = Long.parseLong(key); |
| | | // 查询同店铺商品,同商品订单超过一定数量的 |
| | | List<Integer> typeList = new ArrayList<>(); |
| | | typeList.add(HongBaoV2.TYPE_ZIGOU); |
| | | if (endTime != null && endTime.trim().length() > 0) { |
| | | endTime += " 23:59:59"; |
| | | } |
| | | |
| | | if (riskType == 1) { |
| | | listGoodsId = commonOrderCountService.getSameGoodsOrderByUidAndHongBaoType(typeList, uid, |
| | | Integer.parseInt(configService.getValue(ConfigKeyEnum.adminMinSameGoodsOrderCount.getKey(),acceptData.getSystem()))); |
| | | if (listGoodsId == null || listGoodsId.isEmpty()) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无同商品订单")); |
| | | return; |
| | | } |
| | | } else if (riskType == 2) { |
| | | listShopId = commonOrderCountService.getSameShopOrderByUidAndHongBaoType(typeList, uid, |
| | | Integer.parseInt(configService.getValue(ConfigKeyEnum.adminMinSameShopOrderCount.getKey(),acceptData.getSystem()))); |
| | | if (listShopId == null || listShopId.isEmpty()) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无同店铺订单")); |
| | | return; |
| | | } |
| | | } else if (riskType == 3) { |
| | | money = new BigDecimal(100); |
| | | minTime = new Date(System.currentTimeMillis() - 1000 * 60 * 60 * 24 * 180L); |
| | | } |
| | | } |
| | | try { |
| | | Date minTime = null; |
| | | BigDecimal money = null; |
| | | List<Long> listShopId = null; |
| | | List<Long> listGoodsId = null; |
| | | // 风险 |
| | | if (riskType != null && !StringUtil.isNullOrEmpty(key) && keyType != null && keyType == 2) { |
| | | long uid = Long.parseLong(key); |
| | | // 查询同店铺商品,同商品订单超过一定数量的 |
| | | List<Integer> typeList = new ArrayList<>(); |
| | | typeList.add(HongBaoV2.TYPE_ZIGOU); |
| | | |
| | | // 查询列表 |
| | | List<CommonOrderVO> list = commonOrderService.listQuery((pageIndex - 1) * pageSize, pageSize, keyType, key, |
| | | state, type, orderState, startTime, endTime, sourceType, listShopId, listGoodsId, minTime, money, payment,acceptData.getSystem()); |
| | | if (riskType == 1) { |
| | | listGoodsId = commonOrderCountService.getSameGoodsOrderByUidAndHongBaoType(typeList, uid, |
| | | Integer.parseInt(configService.getValue(ConfigKeyEnum.adminMinSameGoodsOrderCount.getKey(), acceptData.getSystem()))); |
| | | if (listGoodsId == null || listGoodsId.isEmpty()) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无同商品订单")); |
| | | return; |
| | | } |
| | | } else if (riskType == 2) { |
| | | listShopId = commonOrderCountService.getSameShopOrderByUidAndHongBaoType(typeList, uid, |
| | | Integer.parseInt(configService.getValue(ConfigKeyEnum.adminMinSameShopOrderCount.getKey(), acceptData.getSystem()))); |
| | | if (listShopId == null || listShopId.isEmpty()) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无同店铺订单")); |
| | | return; |
| | | } |
| | | } else if (riskType == 3) { |
| | | money = OrderConstant.BIG_ORDER_MONEY; |
| | | minTime = new Date(System.currentTimeMillis() - 1000 * 60 * 60 * 24 * 180L); |
| | | } |
| | | } |
| | | |
| | | // 统计总数 |
| | | long count = commonOrderService.countQuery(keyType, key, state, type, orderState, startTime, endTime, |
| | | sourceType, listShopId, listGoodsId, minTime, money, payment,acceptData.getSystem()); |
| | | // 查询列表 |
| | | List<CommonOrderVO> list = commonOrderService.listQuery((pageIndex - 1) * pageSize, pageSize, keyType, key, |
| | | state, type, orderState, startTime, endTime, sourceType, listShopId, listGoodsId, minTime, money, payment, acceptData.getSystem()); |
| | | |
| | | for (CommonOrderVO order : list) { |
| | | |
| | | CommonOrderGoods goods = order.getCommonOrderGoods(); |
| | | if (goods != null) { |
| | | CommonGoods commonGoods = commonGoodsService.getCommonGoodsByGoodsIdAndGoodsType(Long.parseLong(goods.getGoodsId()), |
| | | goods.getGoodsType()); |
| | | if (commonGoods != null) { |
| | | String categoryInfo = commonGoods.getCategoryInfo(); |
| | | if (!StringUtil.isNullOrEmpty(categoryInfo)) { |
| | | JSONObject json = JSONObject.fromObject(categoryInfo); |
| | | CategoryInfoDTO otherDTO = (CategoryInfoDTO) JSONObject.toBean(json, CategoryInfoDTO.class); |
| | | if (otherDTO != null) { |
| | | goods.setCategory1(otherDTO.getCid1Name()); |
| | | goods.setCategory2(otherDTO.getCid2Name()); |
| | | goods.setCategory3(otherDTO.getCid3Name()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | if (order.getUserId() == null) |
| | | continue; |
| | | // 统计总数 |
| | | long count = commonOrderService.countQuery(keyType, key, state, type, orderState, startTime, endTime, |
| | | sourceType, listShopId, listGoodsId, minTime, money, payment, acceptData.getSystem()); |
| | | |
| | | // 查询是否维权 |
| | | TaoBaoWeiQuanOrder weiQuanOrder = taoBaoWeiQuanOrderService.listByorderItemId(order.getTradeId()); |
| | | if (weiQuanOrder != null)// 有维权 |
| | | { |
| | | order.setWeiQuanState(weiQuanOrder.getState()); |
| | | order.setState(CommonOrder.STATE_WQ); |
| | | TaoBaoWeiQuanDrawBack drawBack = taoBaoWeiQuanDrawBackService.selectByOrderItemIdAndUid( |
| | | weiQuanOrder.getOrderItemId(), Long.parseLong(order.getUserId())); |
| | | if (drawBack != null) {// 已经退款 |
| | | for (CommonOrderVO order : list) { |
| | | |
| | | // 计算退款资金 |
| | | UserMoneyDetail detail = null; |
| | | switch (order.getHongBaoType()) { |
| | | case 1: |
| | | detail = userMoneyDetailService.selectByTypeAndUidAndIdentifyCode( |
| | | UserMoneyDetailTypeEnum.fanliWeiQuan, Long.parseLong(order.getUserId()), |
| | | drawBack.getId()); |
| | | if (detail == null) |
| | | detail = userMoneyDetailService.selectByTypeAndUidAndIdentifyCode( |
| | | UserMoneyDetailTypeEnum.weiQuan, Long.parseLong(order.getUserId()), |
| | | drawBack.getId()); |
| | | break; |
| | | case 3: |
| | | detail = userMoneyDetailService.selectByTypeAndUidAndIdentifyCode( |
| | | UserMoneyDetailTypeEnum.inviteWeiQuan, Long.parseLong(order.getUserId()), |
| | | drawBack.getId()); |
| | | break; |
| | | case 2: |
| | | detail = userMoneyDetailService.selectByTypeAndUidAndIdentifyCode( |
| | | UserMoneyDetailTypeEnum.shareWeiQuan, Long.parseLong(order.getUserId()), |
| | | drawBack.getId()); |
| | | break; |
| | | } |
| | | if (detail != null) { |
| | | // 退款成功 |
| | | order.setWeiQuanBackMoney(detail.getMoney().abs().toString()); |
| | | } else {// 尚未退款 |
| | | order.setWeiQuanBackMoney(drawBack.getDrawBackMoney().toString()); |
| | | // 查询出对应的hongBaoId |
| | | CommonOrder commonOrder = commonOrderService.selectBySourceTypeAndTradeId( |
| | | Constant.SOURCE_TYPE_TAOBAO, drawBack.getOrderItemId()); |
| | | if (commonOrder != null) { |
| | | HongBaoOrder hongBaoOrder = hongBaoOrderService |
| | | .selectDetailByCommonOrderId(commonOrder.getId()); |
| | | if (hongBaoOrder != null) { |
| | | UserMoneyDebt debt = userMoneyDebtService.selectByTypeAndSourceId( |
| | | UserMoneyDebtTypeEnum.order, hongBaoOrder.getHongBaoV2().getId()); |
| | | if (debt != null && debt.getLeftMoney().compareTo(new BigDecimal(0)) > 0) { |
| | | order.setWeiQuanBackMoney( |
| | | new BigDecimal(0).subtract(debt.getLeftMoney()).toString());// 未扣除 |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | } else {// 尚未退款 |
| | | UserOrderWeiQuanRecord record = userOrderWeiQuanRecordService.selectByOrderInfoAndUid( |
| | | Long.parseLong(order.getUserId()), weiQuanOrder.getOrderItemId(), |
| | | Constant.SOURCE_TYPE_TAOBAO); |
| | | if (record != null) |
| | | order.setWeiQuanBackMoney("-" + record.getMoney()); |
| | | else { |
| | | order.setWeiQuanBackMoney("-" + order.getHongBao()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1); |
| | | PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage); |
| | | |
| | | JSONObject data = new JSONObject(); |
| | | data.put("pe", pe); |
| | | data.put("result_list", list); |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); |
| | | } catch (CommonOrderException e) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg())); |
| | | } catch (Exception e) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("查询失败")); |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 查询订单列表用户uid |
| | | * |
| | | * @param callback |
| | | * @param pageIndex |
| | | * @param pageSize |
| | | * @param uid |
| | | * @param state |
| | | * @param type |
| | | * @param orderState |
| | | * @param orderNo |
| | | * @param startTime |
| | | * @param endTime |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "getHistoryOrder") |
| | | public void getHistoryOrder(AdminAcceptData acceptData,String callback, Integer pageIndex, Integer pageSize, Long uid, Integer state, |
| | | Integer type, Integer orderState, String orderNo, String startTime, String endTime, PrintWriter out) { |
| | | |
| | | if (uid == null) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("uid不能为空")); |
| | | return; |
| | | } |
| | | |
| | | if (pageIndex == null || pageIndex < 1) { |
| | | pageIndex = 1; |
| | | } |
| | | |
| | | if (pageSize == null) |
| | | pageSize = Constant.PAGE_SIZE; |
| | | |
| | | if (state != null && state == 0) { |
| | | state = null;// 所有状态 |
| | | } |
| | | |
| | | if (type != null && type == 0) { |
| | | type = null; // 所有类型订单 |
| | | } |
| | | |
| | | if (endTime != null && endTime.trim().length() > 0) { |
| | | endTime += " 23:59:59"; |
| | | } |
| | | |
| | | try { |
| | | long count = 0; |
| | | |
| | | // 查询列表 |
| | | List<CommonOrderVO> list = commonOrderService.listQueryByUid((pageIndex - 1) * pageSize, pageSize, uid, |
| | | state, type, orderState, orderNo, startTime, endTime, null); |
| | | |
| | | if (list != null && list.size() > 0) { |
| | | // 统计总数 |
| | | count = commonOrderService.countQueryByUid(uid, state, type, orderState, orderNo, startTime, endTime, |
| | | null); |
| | | } |
| | | |
| | | int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1); |
| | | PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage); |
| | | |
| | | JSONObject data = new JSONObject(); |
| | | data.put("pe", pe); |
| | | data.put("result_list", list); |
| | | |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); |
| | | |
| | | } catch (CommonOrderException e) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg())); |
| | | } catch (Exception e) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("查询失败")); |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | CommonOrderGoods goods = order.getCommonOrderGoods(); |
| | | if (goods != null) { |
| | | CommonGoods commonGoods = commonGoodsService.getCommonGoodsByGoodsIdAndGoodsType(Long.parseLong(goods.getGoodsId()), |
| | | goods.getGoodsType()); |
| | | if (commonGoods != null) { |
| | | String categoryInfo = commonGoods.getCategoryInfo(); |
| | | if (!StringUtil.isNullOrEmpty(categoryInfo)) { |
| | | JSONObject json = JSONObject.fromObject(categoryInfo); |
| | | CategoryInfoDTO otherDTO = (CategoryInfoDTO) JSONObject.toBean(json, CategoryInfoDTO.class); |
| | | if (otherDTO != null) { |
| | | goods.setCategory1(otherDTO.getCid1Name()); |
| | | goods.setCategory2(otherDTO.getCid2Name()); |
| | | goods.setCategory3(otherDTO.getCid3Name()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 当前未收货订单数 |
| | | * |
| | | * @param callback |
| | | * @param type |
| | | * 订单状态-暂未使用 |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "getHistoryUnreceived") |
| | | public void getHistoryUnreceived(AdminAcceptData acceptData,String callback, Integer type, PrintWriter out) { |
| | | try { |
| | | if (order.getUserId() == null) |
| | | continue; |
| | | |
| | | Long total = commonOrderCountService.countByState(1); |
| | | if (total == null) { |
| | | total = 0L; |
| | | } |
| | | JSONObject data = new JSONObject(); |
| | | data.put("total", total); |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); |
| | | } catch (Exception e) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作异常")); |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | // 查询是否维权 |
| | | TaoBaoWeiQuanOrder weiQuanOrder = taoBaoWeiQuanOrderService.listByorderItemId(order.getTradeId()); |
| | | if (weiQuanOrder != null)// 有维权 |
| | | { |
| | | order.setWeiQuanState(weiQuanOrder.getState()); |
| | | order.setState(CommonOrder.STATE_WQ); |
| | | TaoBaoWeiQuanDrawBack drawBack = taoBaoWeiQuanDrawBackService.selectByOrderItemIdAndUid( |
| | | weiQuanOrder.getOrderItemId(), Long.parseLong(order.getUserId())); |
| | | if (drawBack != null) {// 已经退款 |
| | | |
| | | @RequestMapping(value = "uploadTaoBaoWeiQuanOrder") |
| | | public void uploadWeiQuanOrder(AdminAcceptData acceptData,String callback, HttpServletRequest request, PrintWriter out) { |
| | | try { |
| | | // 1. 先判断httpRequest 是否含有文件类型 |
| | | if (request instanceof MultipartHttpServletRequest) { |
| | | MultipartHttpServletRequest fileRequest = (MultipartHttpServletRequest) request; |
| | | MultipartFile file = fileRequest.getFile("file"); |
| | | List<TaoBaoWeiQuanOrder> orderList = TaoBaoOrderUtil.getWeiQuanOrders(file.getInputStream()); |
| | | for (TaoBaoWeiQuanOrder order : orderList) |
| | | taoBaoWeiQuanOrderService.addWeiQuanOrder(order);// 添加维权订单到数据库 |
| | | // 处理维权订单 |
| | | orderProcessService.weiQuanOrder(orderList); |
| | | } |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("更新成功")); |
| | | } catch (Exception e) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("更新失败")); |
| | | } |
| | | } |
| | | |
| | | |
| | | @RequestMapping(value = "countOrderInfo") |
| | | public void countOrderInfo(AdminAcceptData acceptData,String callback, Long uid, PrintWriter out) { |
| | | JSONObject data = new JSONObject(); |
| | | |
| | | /* --------- 本月累计 ------------*/ |
| | | JSONObject month = new JSONObject(); |
| | | // 自购已到账 |
| | | month.put("selfNumEnd", hongBaoV2CountService.countOrderByCashArrival(uid, null, 1, 1)); |
| | | // 分享已到账 |
| | | month.put("shareNumEnd", hongBaoV2CountService.countOrderByCashArrival(uid, null, 2, 1)); |
| | | // 邀请已到账 |
| | | month.put("inviteNumEnd", hongBaoV2CountService.countOrderByCashArrival(uid, null, 3, 1)); |
| | | // 自购未到账 |
| | | month.put("selfNum", hongBaoV2CountService.countOrderByCashNotArrival(uid, null, 1, 1)); |
| | | // 分享未到账 |
| | | month.put("shareNum", hongBaoV2CountService.countOrderByCashNotArrival(uid, null, 2, 1)); |
| | | // 邀请未到账 |
| | | month.put("inviteNum", hongBaoV2CountService.countOrderByCashNotArrival(uid, null, 3, 1)); |
| | | data.put("month", month); |
| | | |
| | | |
| | | /* --------- 历史累计 ------------*/ |
| | | JSONObject history = new JSONObject(); |
| | | // 自购已到账 |
| | | history.put("selfNumEnd", hongBaoV2CountService.countOrderByCashArrival(uid, null, 1, null)); |
| | | // 分享已到账 |
| | | history.put("shareNumEnd", hongBaoV2CountService.countOrderByCashArrival(uid, null, 2, null)); |
| | | // 邀请已到账 |
| | | history.put("inviteNumEnd", hongBaoV2CountService.countOrderByCashArrival(uid, null, 3, null)); |
| | | // 自购未到账 |
| | | history.put("selfNum", hongBaoV2CountService.countOrderByCashNotArrival(uid, null, 1, null)); |
| | | // 分享未到账 |
| | | history.put("shareNum", hongBaoV2CountService.countOrderByCashNotArrival(uid, null, 2, null)); |
| | | // 邀请未到账 |
| | | history.put("inviteNum", hongBaoV2CountService.countOrderByCashNotArrival(uid, null, 3, null)); |
| | | data.put("history", history); |
| | | |
| | | |
| | | /* --------- 付款金额大于1 ------------*/ |
| | | // 自购已到账 |
| | | long selfAccountEnd = hongBaoV2CountService.countMyDirectOrderByCashArrival(uid, Constant.VIP_ORDER_PAY, 1); |
| | | // 分享已到账 |
| | | long shareAccountEnd = hongBaoV2CountService.countMyDirectOrderByCashArrival(uid, Constant.VIP_ORDER_PAY, 2); |
| | | // 自购未到账 |
| | | long selfAccount = hongBaoV2CountService.countOrderByCashNotArrival(uid, Constant.VIP_ORDER_PAY, 1, null); |
| | | // 分享未到账 |
| | | long shareAccount = hongBaoV2CountService.countOrderByCashNotArrival(uid, Constant.VIP_ORDER_PAY, 2, null); |
| | | data.put("selfAccountEnd", selfAccountEnd); |
| | | data.put("shareAccountEnd", shareAccountEnd); |
| | | data.put("selfAccount", selfAccount); |
| | | data.put("shareAccount", shareAccount); |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); |
| | | } |
| | | |
| | | // 计算退款资金 |
| | | UserMoneyDetail detail = null; |
| | | switch (order.getHongBaoType()) { |
| | | case 1: |
| | | detail = userMoneyDetailService.selectByTypeAndUidAndIdentifyCode( |
| | | UserMoneyDetailTypeEnum.fanliWeiQuan, Long.parseLong(order.getUserId()), |
| | | drawBack.getId()); |
| | | if (detail == null) |
| | | detail = userMoneyDetailService.selectByTypeAndUidAndIdentifyCode( |
| | | UserMoneyDetailTypeEnum.weiQuan, Long.parseLong(order.getUserId()), |
| | | drawBack.getId()); |
| | | break; |
| | | case 3: |
| | | detail = userMoneyDetailService.selectByTypeAndUidAndIdentifyCode( |
| | | UserMoneyDetailTypeEnum.inviteWeiQuan, Long.parseLong(order.getUserId()), |
| | | drawBack.getId()); |
| | | break; |
| | | case 2: |
| | | detail = userMoneyDetailService.selectByTypeAndUidAndIdentifyCode( |
| | | UserMoneyDetailTypeEnum.shareWeiQuan, Long.parseLong(order.getUserId()), |
| | | drawBack.getId()); |
| | | break; |
| | | } |
| | | if (detail != null) { |
| | | // 退款成功 |
| | | order.setWeiQuanBackMoney(detail.getMoney().abs().toString()); |
| | | } else {// 尚未退款 |
| | | order.setWeiQuanBackMoney(drawBack.getDrawBackMoney().toString()); |
| | | // 查询出对应的hongBaoId |
| | | CommonOrder commonOrder = commonOrderService.selectBySourceTypeAndTradeId( |
| | | Constant.SOURCE_TYPE_TAOBAO, drawBack.getOrderItemId()); |
| | | if (commonOrder != null) { |
| | | HongBaoOrder hongBaoOrder = hongBaoOrderService |
| | | .selectDetailByCommonOrderId(commonOrder.getId()); |
| | | if (hongBaoOrder != null) { |
| | | UserMoneyDebt debt = userMoneyDebtService.selectByTypeAndSourceId( |
| | | UserMoneyDebtTypeEnum.order, hongBaoOrder.getHongBaoV2().getId()); |
| | | if (debt != null && debt.getLeftMoney().compareTo(new BigDecimal(0)) > 0) { |
| | | order.setWeiQuanBackMoney( |
| | | new BigDecimal(0).subtract(debt.getLeftMoney()).toString());// 未扣除 |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | } else {// 尚未退款 |
| | | UserOrderWeiQuanRecord record = userOrderWeiQuanRecordService.selectByOrderInfoAndUid( |
| | | Long.parseLong(order.getUserId()), weiQuanOrder.getOrderItemId(), |
| | | Constant.SOURCE_TYPE_TAOBAO); |
| | | if (record != null) |
| | | order.setWeiQuanBackMoney("-" + record.getMoney()); |
| | | else { |
| | | order.setWeiQuanBackMoney("-" + order.getHongBao()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1); |
| | | PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage); |
| | | |
| | | JSONObject data = new JSONObject(); |
| | | data.put("pe", pe); |
| | | data.put("result_list", list); |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); |
| | | } catch (CommonOrderException e) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg())); |
| | | } catch (Exception e) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("查询失败")); |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 查询订单列表用户uid |
| | | * |
| | | * @param callback |
| | | * @param pageIndex |
| | | * @param pageSize |
| | | * @param uid |
| | | * @param state |
| | | * @param type |
| | | * @param orderState |
| | | * @param orderNo |
| | | * @param startTime |
| | | * @param endTime |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "getHistoryOrder") |
| | | public void getHistoryOrder(AdminAcceptData acceptData, String callback, Integer pageIndex, Integer pageSize, Long uid, Integer state, |
| | | Integer type, Integer orderState, String orderNo, String startTime, String endTime, PrintWriter out) { |
| | | |
| | | if (uid == null) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("uid不能为空")); |
| | | return; |
| | | } |
| | | |
| | | if (pageIndex == null || pageIndex < 1) { |
| | | pageIndex = 1; |
| | | } |
| | | |
| | | if (pageSize == null) |
| | | pageSize = Constant.PAGE_SIZE; |
| | | |
| | | if (state != null && state == 0) { |
| | | state = null;// 所有状态 |
| | | } |
| | | |
| | | if (type != null && type == 0) { |
| | | type = null; // 所有类型订单 |
| | | } |
| | | |
| | | if (endTime != null && endTime.trim().length() > 0) { |
| | | endTime += " 23:59:59"; |
| | | } |
| | | |
| | | try { |
| | | long count = 0; |
| | | |
| | | // 查询列表 |
| | | List<CommonOrderVO> list = commonOrderService.listQueryByUid((pageIndex - 1) * pageSize, pageSize, uid, |
| | | state, type, orderState, orderNo, startTime, endTime, null); |
| | | |
| | | if (list != null && list.size() > 0) { |
| | | // 统计总数 |
| | | count = commonOrderService.countQueryByUid(uid, state, type, orderState, orderNo, startTime, endTime, |
| | | null); |
| | | } |
| | | |
| | | int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1); |
| | | PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage); |
| | | |
| | | JSONObject data = new JSONObject(); |
| | | data.put("pe", pe); |
| | | data.put("result_list", list); |
| | | |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); |
| | | |
| | | } catch (CommonOrderException e) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg())); |
| | | } catch (Exception e) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("查询失败")); |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 当前未收货订单数 |
| | | * |
| | | * @param callback |
| | | * @param type 订单状态-暂未使用 |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "getHistoryUnreceived") |
| | | public void getHistoryUnreceived(AdminAcceptData acceptData, String callback, Integer type, PrintWriter out) { |
| | | try { |
| | | |
| | | Long total = commonOrderCountService.countByState(1); |
| | | if (total == null) { |
| | | total = 0L; |
| | | } |
| | | JSONObject data = new JSONObject(); |
| | | data.put("total", total); |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); |
| | | } catch (Exception e) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作异常")); |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | @RequestMapping(value = "uploadTaoBaoWeiQuanOrder") |
| | | public void uploadWeiQuanOrder(AdminAcceptData acceptData, String callback, HttpServletRequest request, PrintWriter out) { |
| | | try { |
| | | // 1. 先判断httpRequest 是否含有文件类型 |
| | | if (request instanceof MultipartHttpServletRequest) { |
| | | MultipartHttpServletRequest fileRequest = (MultipartHttpServletRequest) request; |
| | | MultipartFile file = fileRequest.getFile("file"); |
| | | List<TaoBaoWeiQuanOrder> orderList = TaoBaoOrderUtil.getWeiQuanOrders(file.getInputStream()); |
| | | for (TaoBaoWeiQuanOrder order : orderList) |
| | | taoBaoWeiQuanOrderService.addWeiQuanOrder(order);// 添加维权订单到数据库 |
| | | // 处理维权订单 |
| | | orderProcessService.weiQuanOrder(orderList); |
| | | } |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("更新成功")); |
| | | } catch (Exception e) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("更新失败")); |
| | | } |
| | | } |
| | | |
| | | |
| | | @RequestMapping(value = "countOrderInfo") |
| | | public void countOrderInfo(AdminAcceptData acceptData, String callback, Long uid, PrintWriter out) { |
| | | JSONObject data = new JSONObject(); |
| | | |
| | | /* --------- 本月累计 ------------*/ |
| | | JSONObject month = new JSONObject(); |
| | | // 自购已到账 |
| | | month.put("selfNumEnd", hongBaoV2CountService.countOrderByCashArrival(uid, null, 1, 1)); |
| | | // 分享已到账 |
| | | month.put("shareNumEnd", hongBaoV2CountService.countOrderByCashArrival(uid, null, 2, 1)); |
| | | // 邀请已到账 |
| | | month.put("inviteNumEnd", hongBaoV2CountService.countOrderByCashArrival(uid, null, 3, 1)); |
| | | // 自购未到账 |
| | | month.put("selfNum", hongBaoV2CountService.countOrderByCashNotArrival(uid, null, 1, 1)); |
| | | // 分享未到账 |
| | | month.put("shareNum", hongBaoV2CountService.countOrderByCashNotArrival(uid, null, 2, 1)); |
| | | // 邀请未到账 |
| | | month.put("inviteNum", hongBaoV2CountService.countOrderByCashNotArrival(uid, null, 3, 1)); |
| | | data.put("month", month); |
| | | |
| | | |
| | | /* --------- 历史累计 ------------*/ |
| | | JSONObject history = new JSONObject(); |
| | | // 自购已到账 |
| | | history.put("selfNumEnd", hongBaoV2CountService.countOrderByCashArrival(uid, null, 1, null)); |
| | | // 分享已到账 |
| | | history.put("shareNumEnd", hongBaoV2CountService.countOrderByCashArrival(uid, null, 2, null)); |
| | | // 邀请已到账 |
| | | history.put("inviteNumEnd", hongBaoV2CountService.countOrderByCashArrival(uid, null, 3, null)); |
| | | // 自购未到账 |
| | | history.put("selfNum", hongBaoV2CountService.countOrderByCashNotArrival(uid, null, 1, null)); |
| | | // 分享未到账 |
| | | history.put("shareNum", hongBaoV2CountService.countOrderByCashNotArrival(uid, null, 2, null)); |
| | | // 邀请未到账 |
| | | history.put("inviteNum", hongBaoV2CountService.countOrderByCashNotArrival(uid, null, 3, null)); |
| | | data.put("history", history); |
| | | |
| | | |
| | | /* --------- 付款金额大于1 ------------*/ |
| | | // 自购已到账 |
| | | long selfAccountEnd = hongBaoV2CountService.countMyDirectOrderByCashArrival(uid, Constant.VIP_ORDER_PAY, 1); |
| | | // 分享已到账 |
| | | long shareAccountEnd = hongBaoV2CountService.countMyDirectOrderByCashArrival(uid, Constant.VIP_ORDER_PAY, 2); |
| | | // 自购未到账 |
| | | long selfAccount = hongBaoV2CountService.countOrderByCashNotArrival(uid, Constant.VIP_ORDER_PAY, 1, null); |
| | | // 分享未到账 |
| | | long shareAccount = hongBaoV2CountService.countOrderByCashNotArrival(uid, Constant.VIP_ORDER_PAY, 2, null); |
| | | data.put("selfAccountEnd", selfAccountEnd); |
| | | data.put("shareAccountEnd", shareAccountEnd); |
| | | data.put("selfAccount", selfAccount); |
| | | data.put("shareAccount", shareAccount); |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | couponUrl = couponInfo.getLink(); |
| | | } |
| | | String materialId = "https://item.jd.com/" + goodsVO.getGoodsId() + ".html"; |
| | | jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, JDApiUtil.POSITION_SHARE + "", |
| | | jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, null,JDApiUtil.POSITION_SHARE + "", |
| | | user.getId() + ""); |
| | | } else if (goodsVO.getGoodsType() == Constant.SOURCE_TYPE_PDD) { |
| | | jumpLink = PinDuoDuoApiUtil.getPromotionUrl(Long.parseLong(goodsVO.getGoodsId()), |
| | |
| | | if (couponInfo != null) {
|
| | | // 券链接处理
|
| | | String materialId = "https://item.jd.com/" + id + ".html";
|
| | | String url = JDApiUtil.convertLinkWithSubUnionId(materialId, couponInfo.getLink(),
|
| | | String url = JDApiUtil.convertLinkWithSubUnionId(materialId, couponInfo.getLink(),null,
|
| | | JDApiUtil.POSITION_COUPON + "", null);
|
| | | couponInfo.setLink(url);
|
| | | }
|
| | |
| | | if (couponInfo != null) {
|
| | | couponUrl = couponInfo.getLink();
|
| | | }
|
| | | jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, JDApiUtil.POSITION_COUPON + "",
|
| | | jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, null,JDApiUtil.POSITION_COUPON + "",
|
| | | "");
|
| | | if (jumpLink == null) {
|
| | | jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, null, JDApiUtil.POSITION_COUPON + "",
|
| | | jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, null, null,JDApiUtil.POSITION_COUPON + "",
|
| | | "");
|
| | | }
|
| | | } else {
|
| | | jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, JDApiUtil.POSITION_COUPON + "",
|
| | | jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, null,JDApiUtil.POSITION_COUPON + "",
|
| | | "");
|
| | | if (StringUtil.isNullOrEmpty(jumpLink)) {
|
| | | jumpLink = couponUrl;
|
| | |
| | | if (couponInfo != null) {
|
| | | couponUrl = couponInfo.getLink();
|
| | | }
|
| | | jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, JDApiUtil.POSITION_FANLI + "",
|
| | | jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, null,JDApiUtil.POSITION_FANLI + "",
|
| | | uid + "");
|
| | | if (jumpLink == null) {
|
| | | jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, null, JDApiUtil.POSITION_FANLI + "",
|
| | | jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, null, null,JDApiUtil.POSITION_FANLI + "",
|
| | | uid + "");
|
| | | }
|
| | | } else {
|
| | | jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, JDApiUtil.POSITION_FANLI + "",
|
| | | jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, null,JDApiUtil.POSITION_FANLI + "",
|
| | | uid + "");
|
| | | if (StringUtil.isNullOrEmpty(jumpLink)) {
|
| | | jumpLink = couponUrl;
|
| | |
| | | String jumpLink = null;
|
| | | String materialId = "https://item.jd.com/" + id + ".html";
|
| | |
|
| | | jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, JDApiUtil.POSITION_FANLI + "", null);
|
| | | jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, null,JDApiUtil.POSITION_FANLI + "", null);
|
| | | if (StringUtil.isNullOrEmpty(jumpLink)) {
|
| | | jumpLink = couponUrl;
|
| | | }
|
| | |
| | | return;
|
| | | }
|
| | |
|
| | | link = JDApiUtil.convertLinkWithSubUnionId(link, null, JDApiUtil.POSITION_FANLI + "", uid + "");
|
| | | link = JDApiUtil.convertLinkWithSubUnionId(link, null, null,JDApiUtil.POSITION_FANLI + "", uid + "");
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("link", link);
|
| | |
| | | couponUrl = couponInfo.getLink(); |
| | | } |
| | | String materialId = "https://item.jd.com/" + goodsId + ".html"; |
| | | String jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, JDApiUtil.POSITION_SHARE + "", uid + ""); |
| | | String jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, null,JDApiUtil.POSITION_SHARE + "", uid + ""); |
| | | if (StringUtil.isNullOrEmpty(jumpLink)) { |
| | | jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, null, JDApiUtil.POSITION_SHARE + "", uid + ""); |
| | | jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, null, null,JDApiUtil.POSITION_SHARE + "", uid + ""); |
| | | } |
| | | |
| | | ShareInfoVO shareInfo = new ShareInfoVO(); |
| | |
| | | couponUrl = couponInfo.getLink(); |
| | | } |
| | | String materialId = "https://item.jd.com/" + goodsId + ".html"; |
| | | String shortLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, JDApiUtil.POSITION_SHARE + "", |
| | | String shortLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, null,JDApiUtil.POSITION_SHARE + "", |
| | | uid + ""); |
| | | |
| | | String content = shareGoodsTextTemplateService.createContentJD(template, goods, shortLink, hasCoupon); |
| | |
| | | }
|
| | |
|
| | | String materialId = "https://item.jd.com/" + id + ".html";
|
| | | String jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, JDApiUtil.POSITION_SHARE + "",
|
| | | String jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, null,JDApiUtil.POSITION_SHARE + "",
|
| | | uid);
|
| | |
|
| | | int priceType = 1;
|
| | |
| | | JSONObject paramsJson = JSONObject.fromObject(params);
|
| | | // 京东转链
|
| | | String url = paramsJson.optString("url");
|
| | | String link = JDApiUtil.convertLinkWithSubUnionId(url, null, JDApiUtil.POSITION_FANLI + "", uid + "");
|
| | | String link = JDApiUtil.convertLinkWithSubUnionId(url, null, null,JDApiUtil.POSITION_FANLI + "", uid + "");
|
| | |
|
| | | if (StringUtil.isNullOrEmpty(link)) {
|
| | | out.print(JsonUtil.loadFalseResult("转链失败"));
|
| | |
| | | // 券链接处理
|
| | | String materialId = "https://item.jd.com/" + id + ".html";
|
| | | String url = JDApiUtil.convertLinkWithSubUnionId(materialId, couponInfo.getLink(),
|
| | | JDApiUtil.POSITION_COUPON + "", null);
|
| | | null,JDApiUtil.POSITION_COUPON + "", null);
|
| | | couponInfo.setLink(url);
|
| | | }
|
| | |
|
| | |
| | | if (share) {
|
| | | position = JDApiUtil.POSITION_SHARE;
|
| | | }
|
| | | String jdLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, position + "", subUnionId);
|
| | | String jdLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, null,position + "", subUnionId);
|
| | | try {
|
| | | jumpLink = "/pages/union/proxy/proxy?spreadUrl=" + URLEncoder.encode(jdLink, "UTF-8");
|
| | | } catch (Exception e) {
|
| | |
| | |
|
| | | public interface UserMoneyDebtMapper extends BaseMapper<UserMoneyDebt> {
|
| | |
|
| | | /**
|
| | | * 根据用户ID与sourceId查询记录
|
| | | * |
| | | * @param uid
|
| | | * @param sourceId
|
| | | * @return
|
| | | */
|
| | | UserMoneyDebt selectByUidAndTypeAndSourceId(@Param("uid") Long uid, @Param("type") UserMoneyDebtTypeEnum type,
|
| | | @Param("sourceId") Long sourceId);
|
| | | /**
|
| | | * 根据用户ID与sourceId查询记录
|
| | | *
|
| | | * @param uid
|
| | | * @param sourceId
|
| | | * @return
|
| | | */
|
| | | UserMoneyDebt selectByUidAndTypeAndSourceId(@Param("uid") Long uid, @Param("type") UserMoneyDebtTypeEnum type,
|
| | | @Param("sourceId") Long sourceId);
|
| | |
|
| | | UserMoneyDebt selectByTypeAndSourceId(@Param("type") UserMoneyDebtTypeEnum type, @Param("sourceId") Long sourceId);
|
| | | UserMoneyDebt selectByTypeAndSourceId(@Param("type") UserMoneyDebtTypeEnum type, @Param("sourceId") Long sourceId);
|
| | |
|
| | | /**
|
| | | * 查询欠债
|
| | | * |
| | | * @param uid
|
| | | * @param start
|
| | | * @param count
|
| | | * @return
|
| | | */
|
| | | List<UserMoneyDebt> listByUidWithHasLeftMoney(@Param("uid") Long uid, @Param("start") long start,
|
| | | @Param("count") int count);
|
| | | /**
|
| | | * 查询欠债
|
| | | *
|
| | | * @param uid
|
| | | * @param start
|
| | | * @param count
|
| | | * @return
|
| | | */
|
| | | List<UserMoneyDebt> listByUidWithHasLeftMoney(@Param("uid") Long uid, @Param("start") long start,
|
| | | @Param("count") int count);
|
| | |
|
| | | /**
|
| | | * 查询需要还欠款的用户ID
|
| | | * @param start
|
| | | * @param count
|
| | | * @return
|
| | | */
|
| | | List<Long> listUidWithHasDebtToRepay(@Param("start") long start,
|
| | | @Param("count") int count);
|
| | |
|
| | |
|
| | | long countUidWithHasDebtToRepay();
|
| | |
|
| | | } |
New file |
| | |
| | | package com.yeshi.fanli.dao.taobao; |
| | | |
| | | import com.yeshi.common.MongodbBaseDao; |
| | | import com.yeshi.fanli.entity.taobao.TaoBaoOrderBackUp; |
| | | import com.yeshi.fanli.entity.taobao.UserTLJBuyHistory; |
| | | import org.springframework.data.mongodb.core.query.Criteria; |
| | | import org.springframework.data.mongodb.core.query.Query; |
| | | import org.springframework.stereotype.Repository; |
| | | |
| | | import java.util.List; |
| | | |
| | | |
| | | @Repository |
| | | public class TaoBaoOrderBackUpDao extends MongodbBaseDao<TaoBaoOrderBackUp> { |
| | | |
| | | |
| | | } |
| | |
| | | package com.yeshi.fanli.dto.taobao;
|
| | |
|
| | | import java.io.Serializable;
|
| | | import java.util.List;
|
| | |
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoOrder;
|
| | |
| | | private boolean hasNext;
|
| | | private boolean hasPre;
|
| | | private String positionIndex;
|
| | | private List<TaoBaoOrder> orderList;
|
| | | private List<Serializable> orderList;
|
| | |
|
| | | public TaoBaoOrderResultDTO(boolean hasNext, boolean hasPre, String positionIndex, List<TaoBaoOrder> orderList) {
|
| | | public TaoBaoOrderResultDTO(boolean hasNext, boolean hasPre, String positionIndex, List<Serializable> orderList) {
|
| | | this.hasNext = hasNext;
|
| | | this.hasPre = hasPre;
|
| | | this.positionIndex = positionIndex;
|
| | |
| | | this.positionIndex = positionIndex;
|
| | | }
|
| | |
|
| | | public List<TaoBaoOrder> getOrderList() {
|
| | | public List<Serializable> getOrderList() {
|
| | | return orderList;
|
| | | }
|
| | |
|
| | | public void setOrderList(List<TaoBaoOrder> orderList) {
|
| | | public void setOrderList(List<Serializable> orderList) {
|
| | | this.orderList = orderList;
|
| | | }
|
| | | }
|
| | |
| | | import java.util.List;
|
| | |
|
| | | public class VipShopOrderQueryModel {
|
| | | public final static int STATUS_NOT_VALID = 0;
|
| | | public final static int STATUS_UNKOWN = 1;
|
| | | public final static int STATUS_FINISH = 2;
|
| | | public final static int STATUS_NOT_VALID = 0;
|
| | | public final static int STATUS_UNKOWN = 1;
|
| | | public final static int STATUS_FINISH = 2;
|
| | |
|
| | | private Integer status;// 订单状态:0-不合格,1-待定,2-已完结,该参数不设置默认代表全部状态
|
| | | private Long orderTimeStart;// 订单时间起始 时间戳 单位毫秒
|
| | | private Long orderTimeEnd;// 订单时间结束 时间戳 单位毫秒
|
| | | private Integer page;// 页码:从1开始
|
| | | private Integer pageSize;// 页面大小:默认20
|
| | | private Long updateTimeStart;// 更新时间-起始 时间戳 单位毫秒
|
| | | private Long updateTimeEnd;// 更新时间-结束 时间戳 单位毫秒
|
| | | private List<String> orderSnList;// 订单号列表:当传入订单号列表时,订单时间和更新时间区间可不传入
|
| | | private String chanTag;// 筛选订单,渠道商方式下表示自定义渠道标识,工具商方式下表示用户pid
|
| | | private Integer status;// 订单状态:0-不合格,1-待定,2-已完结,该参数不设置默认代表全部状态
|
| | | private Long orderTimeStart;// 订单时间起始 时间戳 单位毫秒
|
| | | private Long orderTimeEnd;// 订单时间结束 时间戳 单位毫秒
|
| | | private Integer page;// 页码:从1开始
|
| | | private Integer pageSize;// 页面大小:默认20
|
| | | private Long updateTimeStart;// 更新时间-起始 时间戳 单位毫秒
|
| | | private Long updateTimeEnd;// 更新时间-结束 时间戳 单位毫秒
|
| | | private List<String> orderSnList;// 订单号列表:当传入订单号列表时,订单时间和更新时间区间可不传入
|
| | | private String chanTag;// 筛选订单,渠道商方式下表示自定义渠道标识,工具商方式下表示用户pid
|
| | |
|
| | | public Integer getStatus() {
|
| | | return status;
|
| | | }
|
| | | public Integer getStatus() {
|
| | | return status;
|
| | | }
|
| | |
|
| | | public void setStatus(Integer status) {
|
| | | this.status = status;
|
| | | }
|
| | | public void setStatus(Integer status) {
|
| | | this.status = status;
|
| | | }
|
| | |
|
| | | public Long getOrderTimeStart() {
|
| | | return orderTimeStart;
|
| | | }
|
| | | public Long getOrderTimeStart() {
|
| | | return orderTimeStart;
|
| | | }
|
| | |
|
| | | public void setOrderTimeStart(Long orderTimeStart) {
|
| | | this.orderTimeStart = orderTimeStart;
|
| | | }
|
| | | public void setOrderTimeStart(Long orderTimeStart) {
|
| | | this.orderTimeStart = orderTimeStart;
|
| | | }
|
| | |
|
| | | public Long getOrderTimeEnd() {
|
| | | return orderTimeEnd;
|
| | | }
|
| | | public Long getOrderTimeEnd() {
|
| | | return orderTimeEnd;
|
| | | }
|
| | |
|
| | | public void setOrderTimeEnd(Long orderTimeEnd) {
|
| | | this.orderTimeEnd = orderTimeEnd;
|
| | | }
|
| | | public void setOrderTimeEnd(Long orderTimeEnd) {
|
| | | this.orderTimeEnd = orderTimeEnd;
|
| | | }
|
| | |
|
| | | public Integer getPage() {
|
| | | return page;
|
| | | }
|
| | | public Integer getPage() {
|
| | | return page;
|
| | | }
|
| | |
|
| | | public void setPage(Integer page) {
|
| | | this.page = page;
|
| | | }
|
| | | public void setPage(Integer page) {
|
| | | this.page = page;
|
| | | }
|
| | |
|
| | | public Integer getPageSize() {
|
| | | return pageSize;
|
| | | }
|
| | | public Integer getPageSize() {
|
| | | return pageSize;
|
| | | }
|
| | |
|
| | | public void setPageSize(Integer pageSize) {
|
| | | this.pageSize = pageSize;
|
| | | }
|
| | | public void setPageSize(Integer pageSize) {
|
| | | this.pageSize = pageSize;
|
| | | }
|
| | |
|
| | | public Long getUpdateTimeStart() {
|
| | | return updateTimeStart;
|
| | | }
|
| | | public Long getUpdateTimeStart() {
|
| | | return updateTimeStart;
|
| | | }
|
| | |
|
| | | public void setUpdateTimeStart(Long updateTimeStart) {
|
| | | this.updateTimeStart = updateTimeStart;
|
| | | }
|
| | | public void setUpdateTimeStart(Long updateTimeStart) {
|
| | | this.updateTimeStart = updateTimeStart;
|
| | | }
|
| | |
|
| | | public Long getUpdateTimeEnd() {
|
| | | return updateTimeEnd;
|
| | | }
|
| | | public Long getUpdateTimeEnd() {
|
| | | return updateTimeEnd;
|
| | | }
|
| | |
|
| | | public void setUpdateTimeEnd(Long updateTimeEnd) {
|
| | | this.updateTimeEnd = updateTimeEnd;
|
| | | }
|
| | | public void setUpdateTimeEnd(Long updateTimeEnd) {
|
| | | this.updateTimeEnd = updateTimeEnd;
|
| | | }
|
| | |
|
| | | public List<String> getOrderSnList() {
|
| | | return orderSnList;
|
| | | }
|
| | | public List<String> getOrderSnList() {
|
| | | return orderSnList;
|
| | | }
|
| | |
|
| | | public void setOrderSnList(List<String> orderSnList) {
|
| | | this.orderSnList = orderSnList;
|
| | | }
|
| | | public void setOrderSnList(List<String> orderSnList) {
|
| | | this.orderSnList = orderSnList;
|
| | | }
|
| | |
|
| | | public String getChanTag() {
|
| | | return chanTag;
|
| | | }
|
| | | public String getChanTag() {
|
| | | return chanTag;
|
| | | }
|
| | |
|
| | | public void setChanTag(String chanTag) {
|
| | | this.chanTag = chanTag;
|
| | | }
|
| | | public void setChanTag(String chanTag) {
|
| | | this.chanTag = chanTag;
|
| | | }
|
| | |
|
| | | public static VipShopOrderQueryModel createOrderTime(Long orderTimeStart, Long orderTimeEnd, Integer status,
|
| | | int page) {
|
| | | VipShopOrderQueryModel model = new VipShopOrderQueryModel();
|
| | | model.setOrderTimeStart(orderTimeStart);
|
| | | model.setOrderTimeEnd(orderTimeEnd);
|
| | | model.setStatus(status);
|
| | | model.setPage(page);
|
| | | return model;
|
| | | }
|
| | | public static VipShopOrderQueryModel createOrderTime(Long orderTimeStart, Long orderTimeEnd, Integer status,
|
| | | int page) {
|
| | | VipShopOrderQueryModel model = new VipShopOrderQueryModel();
|
| | | model.setOrderTimeStart(orderTimeStart);
|
| | | model.setOrderTimeEnd(orderTimeEnd);
|
| | | if (status != null)
|
| | | model.setStatus(status);
|
| | | model.setPage(page);
|
| | | return model;
|
| | | }
|
| | |
|
| | | public static VipShopOrderQueryModel createUpdateTime(Long updateTimeStart, Long updateTimeEnd, Integer status,
|
| | | int page) {
|
| | | VipShopOrderQueryModel model = new VipShopOrderQueryModel();
|
| | | model.setUpdateTimeStart(updateTimeStart);
|
| | | model.setUpdateTimeEnd(updateTimeEnd);
|
| | | model.setStatus(status);
|
| | | model.setPage(page);
|
| | | return model;
|
| | | }
|
| | | public static VipShopOrderQueryModel createUpdateTime(Long updateTimeStart, Long updateTimeEnd, Integer status,
|
| | | int page) {
|
| | | VipShopOrderQueryModel model = new VipShopOrderQueryModel();
|
| | | model.setUpdateTimeStart(updateTimeStart);
|
| | | model.setUpdateTimeEnd(updateTimeEnd);
|
| | | model.setStatus(status);
|
| | | model.setPage(page);
|
| | | return model;
|
| | | }
|
| | |
|
| | | public static VipShopOrderQueryModel createOrderSn(List<String> orderSnList, int page) {
|
| | | VipShopOrderQueryModel model = new VipShopOrderQueryModel();
|
| | | model.setOrderSnList(orderSnList);
|
| | | model.setPage(page);
|
| | | return model;
|
| | | }
|
| | | public static VipShopOrderQueryModel createOrderSn(List<String> orderSnList, int page) {
|
| | | VipShopOrderQueryModel model = new VipShopOrderQueryModel();
|
| | | model.setOrderSnList(orderSnList);
|
| | | model.setPage(page);
|
| | | return model;
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | package com.yeshi.fanli.entity.taobao;
|
| | |
|
| | | import java.io.Serializable;
|
| | | import java.math.BigDecimal;
|
| | | import java.util.Date;
|
| | |
|
| | |
| | | import org.yeshi.utils.mybatis.Table;
|
| | |
|
| | | @Table("yeshi_ec_taobao_order")
|
| | | public class TaoBaoOrder {
|
| | | public class TaoBaoOrder implements Serializable {
|
| | | @Column(name = "to_id")
|
| | | private Long id;
|
| | |
|
New file |
| | |
| | | package com.yeshi.fanli.entity.taobao; |
| | | |
| | | |
| | | import org.springframework.data.annotation.Id; |
| | | import org.springframework.data.mongodb.core.mapping.Document; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | @Document(collection = "taoBaoOrderBackUp") |
| | | public class TaoBaoOrderBackUp implements Serializable { |
| | | @Id |
| | | private String tradeId; |
| | | private String orderId; |
| | | private String content;//订单内容 |
| | | |
| | | |
| | | public String getOrderId() { |
| | | return orderId; |
| | | } |
| | | |
| | | public void setOrderId(String orderId) { |
| | | this.orderId = orderId; |
| | | } |
| | | |
| | | public String getTradeId() { |
| | | return tradeId; |
| | | } |
| | | |
| | | public void setTradeId(String tradeId) { |
| | | this.tradeId = tradeId; |
| | | } |
| | | |
| | | public String getContent() { |
| | | return content; |
| | | } |
| | | |
| | | public void setContent(String content) { |
| | | this.content = content; |
| | | } |
| | | } |
New file |
| | |
| | | package com.yeshi.fanli.job.money; |
| | | |
| | | import com.xxl.job.core.biz.model.ReturnT; |
| | | import com.xxl.job.core.handler.annotation.XxlJob; |
| | | import com.yeshi.fanli.service.inter.money.UserMoneyDebtService; |
| | | import com.yeshi.fanli.util.StringUtil; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.List; |
| | | |
| | | @Component |
| | | public class UserMoneyJob { |
| | | |
| | | @Resource |
| | | private UserMoneyDebtService userMoneyDebtService; |
| | | |
| | | /** |
| | | * 还账 |
| | | * |
| | | * @param param 用户ID |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | @XxlJob("usermoney-repayDebt") |
| | | public ReturnT<String> repayDebt(String param) throws Exception { |
| | | if (!StringUtil.isNullOrEmpty(param)) { |
| | | userMoneyDebtService.repayDebt(Long.parseLong(param)); |
| | | } else { |
| | | long count = userMoneyDebtService.countNeedRepayDebtUser(); |
| | | int page = (int) (count % 100 == 0 ? count / 100 : count / 100 + 1); |
| | | for (int i = 0; i < page; i++) { |
| | | List<Long> uids = userMoneyDebtService.listNeedRepayDebtUser(i + 1, 100); |
| | | for (long uid : uids) { |
| | | userMoneyDebtService.repayDebt(uid); |
| | | } |
| | | } |
| | | } |
| | | return ReturnT.SUCCESS; |
| | | } |
| | | } |
New file |
| | |
| | | package com.yeshi.fanli.job.order.taobao; |
| | | |
| | | import com.xxl.job.core.biz.model.ReturnT; |
| | | import com.xxl.job.core.handler.annotation.XxlJob; |
| | | import com.yeshi.fanli.dao.taobao.TaoBaoOrderBackUpDao; |
| | | import com.yeshi.fanli.dto.taobao.WeiQuanOrderResult; |
| | | import com.yeshi.fanli.entity.bus.user.LostOrder; |
| | | import com.yeshi.fanli.entity.bus.user.Order; |
| | | import com.yeshi.fanli.entity.order.CommonOrder; |
| | | import com.yeshi.fanli.entity.taobao.TaoBaoOrder; |
| | | import com.yeshi.fanli.entity.taobao.TaoBaoOrderBackUp; |
| | | import com.yeshi.fanli.entity.taobao.TaoBaoWeiQuanOrder; |
| | | import com.yeshi.fanli.log.LogHelper; |
| | | import com.yeshi.fanli.service.inter.common.DataMonitorService; |
| | | import com.yeshi.fanli.service.inter.order.*; |
| | | import com.yeshi.fanli.service.inter.order.tb.TaoBaoOrderService; |
| | | import com.yeshi.fanli.service.inter.order.tb.TaoBaoWeiQuanOrderService; |
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoUnionConfigService; |
| | | import com.yeshi.fanli.util.*; |
| | | import com.yeshi.fanli.util.taobao.TaoBaoOrderUtil; |
| | | import com.yeshi.fanli.util.taobao.TaoKeApiUtil; |
| | | import com.yeshi.fanli.util.taobao.TaoKeOrderApiUtil; |
| | | import org.springframework.stereotype.Component; |
| | | import org.yeshi.utils.TimeUtil; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.util.*; |
| | | |
| | | //从淘宝爬去订单更新 |
| | | @Component |
| | | public class TaoBaoOrderBackUpJob { |
| | | @Resource |
| | | private TaoBaoOrderBackUpDao taoBaoOrderBackUpDao; |
| | | |
| | | //同步某一天的订单 |
| | | private void syncOrder(Date day, int queryType, int status, int orderSence) { |
| | | long startTime = TimeUtil.convertToTimeTemp(TimeUtil.getGernalTime(day.getTime(), "yyyy-MM-dd"), "yyyy-MM-dd"); |
| | | long endTime = startTime + 1000 * 60 * 60 * 24L; |
| | | List<TaoBaoOrderBackUp> backUpList = TaoKeOrderApiUtil.getTaoBaoOrderBackUpList(startTime, endTime, status, queryType, orderSence); |
| | | for (TaoBaoOrderBackUp backUp : backUpList) { |
| | | taoBaoOrderBackUpDao.save(backUp); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 同步订单 |
| | | * |
| | | * @param day |
| | | */ |
| | | public void syncOrder(Date day) { |
| | | syncOrder(day, 1, 12, 1); |
| | | syncOrder(day, 1, 13, 1); |
| | | syncOrder(day, 1, 3, 1); |
| | | |
| | | syncOrder(day, 3, 12, 1); |
| | | syncOrder(day, 3, 13, 1); |
| | | syncOrder(day, 3, 3, 1); |
| | | } |
| | | |
| | | |
| | | //同步90天到88天的订单 |
| | | @XxlJob("order-taobao-backUpOrderHandler") |
| | | public ReturnT<String> syncOrder(String param) throws Exception { |
| | | long now = TimeUtil.convertToTimeTemp(TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy-MM-dd"), "yyyy-MM-dd"); |
| | | for (int i = 90; i > 87; i--) { |
| | | syncOrder(new Date(now - 1000 * 60 * 60L * 24 * i)); |
| | | } |
| | | return ReturnT.SUCCESS; |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | return ReturnT.SUCCESS;
|
| | | }
|
| | |
|
| | |
|
| | | @XxlJob("order-updateTaoBaoOrderByOrderId")
|
| | | public ReturnT<String> updateTaoBaoOrderByOrderId(String param) throws Exception {
|
| | | List<TaoBaoOrder> orderList = taoBaoOrderService.getTaoBaoOrderByOrderId(param);
|
| | | Map<String, List<TaoBaoOrder>> orders = new HashMap<>();
|
| | | orders.put(param, orderList);
|
| | | orderProcessService.processOrder(orders);
|
| | | return ReturnT.SUCCESS;
|
| | | }
|
| | |
|
| | |
|
| | |
|
| | |
|
| | | /**
|
| | | * 更新最近的本地单(30分钟更新一次)
|
| | | */
|
| | |
| | | @Component
|
| | | public class UpdateVipShopOrderJob {
|
| | |
|
| | | @Resource
|
| | | private VipShopOrderService vipShopOrderService;
|
| | | @Resource
|
| | | private VipShopOrderService vipShopOrderService;
|
| | |
|
| | | @Resource
|
| | | private RedisManager redisManager;
|
| | | @Resource
|
| | | private RedisManager redisManager;
|
| | |
|
| | | /**
|
| | | * 保存订单
|
| | | * |
| | | * @param VipShopOrderList
|
| | | */
|
| | | public void saveVipShopOrders(List<VipShopOrder> vipShopOrderList) {
|
| | | //5分钟不更新就报警
|
| | | try {
|
| | | redisManager.cacheCommonString(RedisKeyEnum.monitor.getKey() + Constant.SOURCE_TYPE_VIP, "1", 60 * 5);
|
| | | } catch (Exception e) {
|
| | | }
|
| | | for (VipShopOrder order : vipShopOrderList) {
|
| | | try {
|
| | | vipShopOrderService.addOrder(order);
|
| | | /**
|
| | | * 做频率限制
|
| | | */
|
| | | String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.VIPShopOrder, order.getOrderSn() + "");
|
| | | String result = redisManager.getCommonString(key);
|
| | | // 判断
|
| | | /**
|
| | | * 保存订单
|
| | | *
|
| | | * @param vipShopOrderList
|
| | | */
|
| | | public void saveVipShopOrders(List<VipShopOrder> vipShopOrderList) {
|
| | | //5分钟不更新就报警
|
| | | try {
|
| | | redisManager.cacheCommonString(RedisKeyEnum.monitor.getKey() + Constant.SOURCE_TYPE_VIP, "1", 60 * 5);
|
| | | } catch (Exception e) {
|
| | | }
|
| | | for (VipShopOrder order : vipShopOrderList) {
|
| | | try {
|
| | | vipShopOrderService.addOrder(order);
|
| | | /**
|
| | | * 做频率限制
|
| | | */
|
| | | String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.VIPShopOrder, order.getOrderSn() + "");
|
| | | String result = redisManager.getCommonString(key);
|
| | | // 判断
|
| | | // if (StringUtil.isNullOrEmpty(result)) {
|
| | | VipShopOrderCMQManager.getInstance().addVipShopOrder(order.getOrderSn() + "");
|
| | | redisManager.cacheCommonString(key, "1", 60 * 60 * 2);// 2小时内不再更新
|
| | | LogHelper.test("唯品会订单消息发送成功");
|
| | | VipShopOrderCMQManager.getInstance().addVipShopOrder(order.getOrderSn() + "");
|
| | | redisManager.cacheCommonString(key, "1", 60 * 60 * 2);// 2小时内不再更新
|
| | | LogHelper.test("唯品会订单消息发送成功");
|
| | | // }else{
|
| | | // LogHelper.test("唯品会订单频率限制");
|
| | | // }
|
| | | } catch (VipShopOrderException e) {
|
| | | e.printStackTrace();
|
| | | LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | }
|
| | | }
|
| | | } catch (VipShopOrderException e) {
|
| | | e.printStackTrace();
|
| | | LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 快速订单更新(爬取本小时内的单,每分钟一次)
|
| | | */
|
| | | @XxlJob("updateVipShopOrderHandler")
|
| | | public ReturnT<String> updateVipShopSoonOrder(String param) throws Exception {
|
| | | LogHelper.test("updateVipShopOrderHandler:"+param);
|
| | | long endTime = System.currentTimeMillis();
|
| | | if ("1hour".equalsIgnoreCase(param)) {// 更新1小时内的订单
|
| | | updateByOrderTime(endTime - 1000 * 60 * 60 * 1L, endTime);
|
| | | updateByUpdateTime(endTime - 1000 * 60 * 60 * 1L, endTime);
|
| | | } else if ("1day".equalsIgnoreCase(param)) {// 更新最近1天更新的数据
|
| | | updateByOrderTime(endTime - 1000 * 60 * 60 * 24L, endTime);
|
| | | updateByUpdateTime(endTime - 1000 * 60 * 60 * 24L, endTime);
|
| | | }
|
| | | /*
|
| | | * else if ("3day".equalsIgnoreCase(param)) {// 更新最近3天更新的数据
|
| | | * updateByOrderTime(endTime - 1000 * 60 * 60 * 24 * 3L, endTime);
|
| | | * updateByUpdateTime(endTime - 1000 * 60 * 60 * 24 * 3L, endTime); }
|
| | | */
|
| | | return ReturnT.SUCCESS;
|
| | | }
|
| | | /**
|
| | | * 快速订单更新(爬取本小时内的单,每分钟一次)
|
| | | */
|
| | | @XxlJob("updateVipShopOrderHandler")
|
| | | public ReturnT<String> updateVipShopSoonOrder(String param) throws Exception {
|
| | | LogHelper.test("updateVipShopOrderHandler:" + param);
|
| | | long endTime = System.currentTimeMillis();
|
| | | if ("1hour".equalsIgnoreCase(param)) {// 更新1小时内的订单
|
| | | updateByOrderTime(endTime - 1000 * 60 * 60 * 1L, endTime);
|
| | | updateByUpdateTime(endTime - 1000 * 60 * 60 * 1L, endTime);
|
| | | } else if ("1day".equalsIgnoreCase(param)) {// 更新最近1天更新的数据
|
| | | updateByOrderTime(endTime - 1000 * 60 * 60 * 24L, endTime);
|
| | | updateByUpdateTime(endTime - 1000 * 60 * 60 * 24L, endTime);
|
| | | }
|
| | | /*
|
| | | * else if ("3day".equalsIgnoreCase(param)) {// 更新最近3天更新的数据
|
| | | * updateByOrderTime(endTime - 1000 * 60 * 60 * 24 * 3L, endTime);
|
| | | * updateByUpdateTime(endTime - 1000 * 60 * 60 * 24 * 3L, endTime); }
|
| | | */
|
| | | return ReturnT.SUCCESS;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 按下单时间更新
|
| | | * @Title: updateByOrderTime
|
| | | * @Description: |
| | | * @param startTime
|
| | | * @param endTime |
| | | * void 返回类型
|
| | | * @throws
|
| | | */
|
| | |
|
| | | public void updateByOrderTime(long startTime, long endTime) {
|
| | | List<VipShopOrder> vipShopOrderList = new ArrayList<>();
|
| | | int page = 1;
|
| | | VipShopQueryOrderResultDTO result = VipShopApiUtil
|
| | | .getOrderList(VipShopOrderQueryModel.createOrderTime(startTime, endTime, null, page));
|
| | |
|
| | | while (result != null && result.getOrderList().size() > 0) {
|
| | | page++;
|
| | | vipShopOrderList.addAll(result.getOrderList());
|
| | | result = VipShopApiUtil
|
| | | .getOrderList(VipShopOrderQueryModel.createOrderTime(startTime, endTime, null, page));
|
| | | }
|
| | | //根据订单号更新
|
| | | @XxlJob("order-vip-updateByOrderSn")
|
| | | public ReturnT<String> updateByOrderSn(String param) throws Exception {
|
| | | List<VipShopOrder> orders = vipShopOrderService.listByOrderSn(param);
|
| | | if (orders == null || orders.size() == 0)
|
| | | throw new Exception("订单不存在");
|
| | |
|
| | | saveVipShopOrders(vipShopOrderList);
|
| | | }
|
| | | VipShopQueryOrderResultDTO result = VipShopApiUtil
|
| | | .getOrderList(VipShopOrderQueryModel.createOrderTime(orders.get(0).getOrderTime(), orders.get(0).getOrderTime() + 1000, null, 1));
|
| | | saveVipShopOrders(result.getOrderList());
|
| | | return ReturnT.SUCCESS;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 按更新时间更新
|
| | | * @Title: updateByOrderTime
|
| | | * @Description: |
| | | * @param startTime
|
| | | * @param endTime |
| | | * void 返回类型
|
| | | * @throws
|
| | | */
|
| | | /**
|
| | | * 按下单时间更新
|
| | | *
|
| | | * @param startTime
|
| | | * @param endTime void 返回类型
|
| | | * @throws
|
| | | * @Title: updateByOrderTime
|
| | | * @Description:
|
| | | */
|
| | |
|
| | | public void updateByUpdateTime(long startTime, long endTime) {
|
| | | List<VipShopOrder> vipShopOrderList = new ArrayList<>();
|
| | | int page = 1;
|
| | | VipShopQueryOrderResultDTO result = VipShopApiUtil
|
| | | .getOrderList(VipShopOrderQueryModel.createUpdateTime(startTime, endTime, null, page));
|
| | | public void updateByOrderTime(long startTime, long endTime) {
|
| | | List<VipShopOrder> vipShopOrderList = new ArrayList<>();
|
| | | int page = 1;
|
| | | VipShopQueryOrderResultDTO result = VipShopApiUtil
|
| | | .getOrderList(VipShopOrderQueryModel.createOrderTime(startTime, endTime, null, page));
|
| | |
|
| | | while (result != null && result.getOrderList().size() > 0) {
|
| | | page++;
|
| | | vipShopOrderList.addAll(result.getOrderList());
|
| | | result = VipShopApiUtil
|
| | | .getOrderList(VipShopOrderQueryModel.createUpdateTime(startTime, endTime, null, page));
|
| | | }
|
| | | saveVipShopOrders(vipShopOrderList);
|
| | | }
|
| | | while (result != null && result.getOrderList().size() > 0) {
|
| | | page++;
|
| | | vipShopOrderList.addAll(result.getOrderList());
|
| | | result = VipShopApiUtil
|
| | | .getOrderList(VipShopOrderQueryModel.createOrderTime(startTime, endTime, null, page));
|
| | | }
|
| | |
|
| | | saveVipShopOrders(vipShopOrderList);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 按更新时间更新
|
| | | *
|
| | | * @param startTime
|
| | | * @param endTime void 返回类型
|
| | | * @throws
|
| | | * @Title: updateByOrderTime
|
| | | * @Description:
|
| | | */
|
| | |
|
| | | public void updateByUpdateTime(long startTime, long endTime) {
|
| | | List<VipShopOrder> vipShopOrderList = new ArrayList<>();
|
| | | int page = 1;
|
| | | VipShopQueryOrderResultDTO result = VipShopApiUtil
|
| | | .getOrderList(VipShopOrderQueryModel.createUpdateTime(startTime, endTime, null, page));
|
| | |
|
| | | while (result != null && result.getOrderList().size() > 0) {
|
| | | page++;
|
| | | vipShopOrderList.addAll(result.getOrderList());
|
| | | result = VipShopApiUtil
|
| | | .getOrderList(VipShopOrderQueryModel.createUpdateTime(startTime, endTime, null, page));
|
| | | }
|
| | | saveVipShopOrders(vipShopOrderList);
|
| | | }
|
| | |
|
| | |
|
| | | }
|
| | |
| | | couponUrl = couponInfo.getLink(); |
| | | } |
| | | String materialId = "https://item.jd.com/" + goodsId + ".html"; |
| | | String jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, |
| | | String jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl,null, |
| | | JDApiUtil.POSITION_SHARE + "", "1"); |
| | | String template = configService.getValue(ConfigKeyEnum.quickShareJDCommentText.getKey(), system); |
| | | if (jumpLink == null) { |
| | |
| | | couponUrl = couponInfo.getLink(); |
| | | } |
| | | String materialId = "https://item.jd.com/" + goodsDetailVO.getGoodsId() + ".html"; |
| | | String jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, JDApiUtil.POSITION_SHARE + "", |
| | | String jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, null,JDApiUtil.POSITION_SHARE + "", |
| | | "1"); |
| | | String template = configService.getValue(ConfigKeyEnum.quickShareJDCommentText.getKey(), system); |
| | | commentText = template.replace("[链接]", jumpLink); |
| | |
| | | @Service
|
| | | public class UserMoneyDebtServiceImpl implements UserMoneyDebtService {
|
| | |
|
| | | @Resource
|
| | | private UserMoneyDebtMapper userMoneyDebtMapper;
|
| | | @Resource
|
| | | private UserMoneyDebtMapper userMoneyDebtMapper;
|
| | |
|
| | | @Resource
|
| | | private UserMoneyDebtReturnHistoryMapper userMoneyDebtReturnHistoryMapper;
|
| | | @Resource
|
| | | private UserMoneyDebtReturnHistoryMapper userMoneyDebtReturnHistoryMapper;
|
| | |
|
| | | @Resource
|
| | | private TaoBaoWeiQuanDrawBackService taoBaoWeiQuanDrawBackService;
|
| | | @Resource
|
| | | private TaoBaoWeiQuanDrawBackService taoBaoWeiQuanDrawBackService;
|
| | |
|
| | | @Resource
|
| | | private TaoBaoOrderService taoBaoOrderService;
|
| | | @Resource
|
| | | private TaoBaoOrderService taoBaoOrderService;
|
| | |
|
| | | @Resource
|
| | | private HongBaoV2Service hongBaoV2Service;
|
| | | @Resource
|
| | | private HongBaoV2Service hongBaoV2Service;
|
| | |
|
| | | @Resource
|
| | | private HongBaoOrderService hongBaoOrderService;
|
| | | @Resource
|
| | | private HongBaoOrderService hongBaoOrderService;
|
| | |
|
| | | @Resource
|
| | | private UserMoneyService userMoneyService;
|
| | | @Resource
|
| | | private UserMoneyService userMoneyService;
|
| | |
|
| | | @Resource
|
| | | private UserMoneyMsgNotificationService userMoneyMsgNotificationService;
|
| | | @Resource
|
| | | private UserMoneyMsgNotificationService userMoneyMsgNotificationService;
|
| | |
|
| | | @Resource
|
| | | private UserInfoService userInfoService;
|
| | | @Resource
|
| | | private UserInfoService userInfoService;
|
| | |
|
| | | @Resource
|
| | | private AlipayAccountValidNormalHistoryMapper alipayAccountValidNormalHistoryMapper;
|
| | | @Resource
|
| | | private AlipayAccountValidNormalHistoryMapper alipayAccountValidNormalHistoryMapper;
|
| | |
|
| | | @Resource
|
| | | private CommonOrderService commonOrderService;
|
| | | @Resource
|
| | | private CommonOrderService commonOrderService;
|
| | |
|
| | | @Override
|
| | | public void addUserMoneyDebt(UserMoneyDebt debt) throws UserMoneyDebtException {
|
| | | if (debt == null)
|
| | | return;
|
| | | @Override
|
| | | public void addUserMoneyDebt(UserMoneyDebt debt) throws UserMoneyDebtException {
|
| | | if (debt == null)
|
| | | return;
|
| | |
|
| | | if (debt.getType() == UserMoneyDebtTypeEnum.order) {
|
| | | if (debt.getSourceId() == null)
|
| | | throw new UserMoneyDebtException(1, "sourceId为空");
|
| | | if (debt.getUid() == null || debt.getOriginMoney() == null)
|
| | | throw new UserMoneyDebtException(2, "信息不完整");
|
| | | if (debt.getType() == UserMoneyDebtTypeEnum.order) {
|
| | | if (debt.getSourceId() == null)
|
| | | throw new UserMoneyDebtException(1, "sourceId为空");
|
| | | if (debt.getUid() == null || debt.getOriginMoney() == null)
|
| | | throw new UserMoneyDebtException(2, "信息不完整");
|
| | |
|
| | | if (debt.getLeftMoney() == null)
|
| | | debt.setLeftMoney(debt.getOriginMoney());
|
| | | if (debt.getLeftMoney() == null)
|
| | | debt.setLeftMoney(debt.getOriginMoney());
|
| | |
|
| | | if (debt.getCreateTime() == null)
|
| | | debt.setCreateTime(new Date());
|
| | | if (debt.getCreateTime() == null)
|
| | | debt.setCreateTime(new Date());
|
| | |
|
| | | UserMoneyDebt old = userMoneyDebtMapper.selectByUidAndTypeAndSourceId(debt.getUid(), debt.getType(),
|
| | | debt.getSourceId());
|
| | | if (old != null) {
|
| | | throw new UserMoneyDebtException(3, "对应售后已经存在");
|
| | | }
|
| | | userMoneyDebtMapper.insertSelective(debt);
|
| | | }
|
| | | }
|
| | | UserMoneyDebt old = userMoneyDebtMapper.selectByUidAndTypeAndSourceId(debt.getUid(), debt.getType(),
|
| | | debt.getSourceId());
|
| | | if (old != null) {
|
| | | throw new UserMoneyDebtException(3, "对应售后已经存在");
|
| | | }
|
| | | userMoneyDebtMapper.insertSelective(debt);
|
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | public UserMoneyDebt selectByTypeAndSourceId(UserMoneyDebtTypeEnum type, Long sourceId) {
|
| | | @Override
|
| | | public UserMoneyDebt selectByTypeAndSourceId(UserMoneyDebtTypeEnum type, Long sourceId) {
|
| | |
|
| | | return userMoneyDebtMapper.selectByTypeAndSourceId(type, sourceId);
|
| | | }
|
| | | return userMoneyDebtMapper.selectByTypeAndSourceId(type, sourceId);
|
| | | }
|
| | |
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | @Override
|
| | | public void repayDebt(UserMoneyDebt debt, BigDecimal money) throws UserMoneyDebtException {
|
| | | if (debt == null || debt.getId() == null)
|
| | | throw new UserMoneyDebtException(1, "参数不完整");
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | @Override
|
| | | public void repayDebt(UserMoneyDebt debt, BigDecimal money) throws UserMoneyDebtException {
|
| | | if (debt == null || debt.getId() == null)
|
| | | throw new UserMoneyDebtException(1, "参数不完整");
|
| | |
|
| | | if (money == null || money.compareTo(new BigDecimal(0)) <= 0)
|
| | | throw new UserMoneyDebtException(2, "偿还资金需大于0");
|
| | | if (money == null || money.compareTo(new BigDecimal(0)) <= 0)
|
| | | throw new UserMoneyDebtException(2, "偿还资金需大于0");
|
| | |
|
| | | UserMoneyDebt old = userMoneyDebtMapper.selectByPrimaryKey(debt.getId());
|
| | | if (old == null)
|
| | | throw new UserMoneyDebtException(3, "借贷关系不存在");
|
| | | UserMoneyDebt old = userMoneyDebtMapper.selectByPrimaryKey(debt.getId());
|
| | | if (old == null)
|
| | | throw new UserMoneyDebtException(3, "借贷关系不存在");
|
| | |
|
| | | if (old.getUid().longValue() != debt.getUid())
|
| | | throw new UserMoneyDebtException(4, "只能本人还钱");
|
| | | if (old.getUid().longValue() != debt.getUid())
|
| | | throw new UserMoneyDebtException(4, "只能本人还钱");
|
| | |
|
| | | if (money.compareTo(old.getLeftMoney()) < 0)
|
| | | throw new UserMoneyDebtException(5, "不够还");
|
| | | if (money.compareTo(old.getLeftMoney()) < 0)
|
| | | throw new UserMoneyDebtException(5, "不够还");
|
| | |
|
| | | UserMoneyDebt update = new UserMoneyDebt();
|
| | | update.setId(old.getId());
|
| | | update.setUpdateTime(new Date());
|
| | | update.setLeftMoney(old.getLeftMoney().subtract(money));
|
| | | userMoneyDebtMapper.updateByPrimaryKeySelective(update);
|
| | | UserMoneyDebt update = new UserMoneyDebt();
|
| | | update.setId(old.getId());
|
| | | update.setUpdateTime(new Date());
|
| | | update.setLeftMoney(old.getLeftMoney().subtract(money));
|
| | | userMoneyDebtMapper.updateByPrimaryKeySelective(update);
|
| | |
|
| | | UserMoneyDebtReturnHistory history = new UserMoneyDebtReturnHistory();
|
| | | history.setBeiZhu(null);
|
| | | history.setCreateTime(new Date());
|
| | | history.setDebt(old);
|
| | | history.setMoney(money);
|
| | | history.setUid(old.getUid());
|
| | | userMoneyDebtReturnHistoryMapper.insertSelective(history);
|
| | | UserMoneyDebtReturnHistory history = new UserMoneyDebtReturnHistory();
|
| | | history.setBeiZhu(null);
|
| | | history.setCreateTime(new Date());
|
| | | history.setDebt(old);
|
| | | history.setMoney(money);
|
| | | history.setUid(old.getUid());
|
| | | userMoneyDebtReturnHistoryMapper.insertSelective(history);
|
| | |
|
| | | if (debt.getType() == UserMoneyDebtTypeEnum.order) {
|
| | | HongBaoV2 hb = hongBaoV2Service.selectByPrimaryKey(debt.getSourceId());
|
| | | if (hb == null) {
|
| | | throw new UserMoneyDebtException(6, "偿还的订单ID不存在");
|
| | | }
|
| | | if (debt.getType() == UserMoneyDebtTypeEnum.order) {
|
| | | HongBaoV2 hb = hongBaoV2Service.selectByPrimaryKey(debt.getSourceId());
|
| | | if (hb == null) {
|
| | | throw new UserMoneyDebtException(6, "偿还的订单ID不存在");
|
| | | }
|
| | |
|
| | | TaoBaoWeiQuanDrawBack weiQuanDrawBack = taoBaoWeiQuanDrawBackService.selectByHongBaoId(hb.getId());
|
| | | if (weiQuanDrawBack == null)
|
| | | throw new UserMoneyDebtException(7, "尚未找到退款信息");
|
| | | TaoBaoWeiQuanDrawBack weiQuanDrawBack = taoBaoWeiQuanDrawBackService.selectByHongBaoId(hb.getId());
|
| | | if (weiQuanDrawBack == null)
|
| | | throw new UserMoneyDebtException(7, "尚未找到退款信息");
|
| | |
|
| | | // 资金变化,添加用户资金记录,添加相关通知
|
| | | Long uid = debt.getUid();
|
| | | switch (hb.getType()) {
|
| | | case HongBaoV2.TYPE_ZIGOU:
|
| | | // 新版资金记录
|
| | | try {
|
| | | UserMoneyDetail userMoneyDetail = UserMoneyDetailFactory.createFanLiWeiQuan(uid, weiQuanDrawBack,
|
| | | money);
|
| | | userMoneyService.subUserMoney(uid, money, userMoneyDetail);
|
| | | } catch (UserMoneyDetailException e) {
|
| | | throw new UserMoneyDebtException(12, "插入资金详情出错");
|
| | | }
|
| | | // 资金变化,添加用户资金记录,添加相关通知
|
| | | Long uid = debt.getUid();
|
| | | switch (hb.getType()) {
|
| | | case HongBaoV2.TYPE_ZIGOU:
|
| | | // 新版资金记录
|
| | | try {
|
| | | UserMoneyDetail userMoneyDetail = UserMoneyDetailFactory.createFanLiWeiQuan(uid, weiQuanDrawBack,
|
| | | money);
|
| | | userMoneyService.subUserMoney(uid, money, userMoneyDetail);
|
| | | } catch (UserMoneyDetailException e) {
|
| | | throw new UserMoneyDebtException(12, "插入资金详情出错");
|
| | | }
|
| | |
|
| | | // 新版通知
|
| | | List<CommonOrder> orderList = commonOrderService.listBySourceTypeAndOrderId(Constant.SOURCE_TYPE_TAOBAO,
|
| | | weiQuanDrawBack.getOrderId());
|
| | | int goodsCount = 0;
|
| | | for (CommonOrder co : orderList) {
|
| | | if (co.getState() != CommonOrder.STATE_SX)
|
| | | goodsCount += co.getCount();
|
| | | }
|
| | | // 新版通知
|
| | | List<CommonOrder> orderList = commonOrderService.listBySourceTypeAndOrderId(Constant.SOURCE_TYPE_TAOBAO,
|
| | | weiQuanDrawBack.getOrderId());
|
| | | int goodsCount = 0;
|
| | | for (CommonOrder co : orderList) {
|
| | | if (co.getState() != CommonOrder.STATE_SX)
|
| | | goodsCount += co.getCount();
|
| | | }
|
| | |
|
| | | BigDecimal fanliMoney = new BigDecimal(0);
|
| | | List<HongBaoOrder> hongBaoOrderList = hongBaoOrderService
|
| | | .listDetailByOrderIdAndSourceType(weiQuanDrawBack.getOrderId(), Constant.SOURCE_TYPE_TAOBAO);
|
| | | BigDecimal fanliMoney = new BigDecimal(0);
|
| | | List<HongBaoOrder> hongBaoOrderList = hongBaoOrderService
|
| | | .listDetailByOrderIdAndSourceType(weiQuanDrawBack.getOrderId(), Constant.SOURCE_TYPE_TAOBAO);
|
| | |
|
| | | for (HongBaoOrder hongBaoOrder : hongBaoOrderList) {
|
| | | fanliMoney = fanliMoney.add(hongBaoOrder.getHongBaoV2().getMoney());
|
| | | }
|
| | | for (HongBaoOrder hongBaoOrder : hongBaoOrderList) {
|
| | | fanliMoney = fanliMoney.add(hongBaoOrder.getHongBaoV2().getMoney());
|
| | | }
|
| | |
|
| | | userMoneyMsgNotificationService.fanliOrderWeiQuan(uid, weiQuanDrawBack.getOrderId(),
|
| | | Constant.SOURCE_TYPE_TAOBAO, money, fanliMoney, goodsCount,
|
| | | orderList.get(0).getThirdCreateTime());
|
| | | userMoneyMsgNotificationService.fanliOrderWeiQuan(uid, weiQuanDrawBack.getOrderId(),
|
| | | Constant.SOURCE_TYPE_TAOBAO, money, fanliMoney, goodsCount,
|
| | | orderList.get(0).getThirdCreateTime());
|
| | |
|
| | | break;
|
| | | case HongBaoV2.TYPE_SHARE_GOODS:
|
| | | break;
|
| | | case HongBaoV2.TYPE_SHARE_GOODS:
|
| | |
|
| | | // 新版资金记录
|
| | | try {
|
| | | UserMoneyDetail userMoneyDetail = UserMoneyDetailFactory.createShareWeiQuan(debt.getUid(),
|
| | | weiQuanDrawBack, money);
|
| | | userMoneyService.subUserMoney(uid, money, userMoneyDetail);
|
| | | // 新版资金记录
|
| | | try {
|
| | | UserMoneyDetail userMoneyDetail = UserMoneyDetailFactory.createShareWeiQuan(debt.getUid(),
|
| | | weiQuanDrawBack, money);
|
| | | userMoneyService.subUserMoney(uid, money, userMoneyDetail);
|
| | |
|
| | | // 新版通知
|
| | | List<CommonOrder> orderList1 = commonOrderService
|
| | | .listBySourceTypeAndOrderId(Constant.SOURCE_TYPE_TAOBAO, weiQuanDrawBack.getOrderId());
|
| | | int goodsCount1 = 0;
|
| | | for (CommonOrder co : orderList1) {
|
| | | if (co.getState() != CommonOrder.STATE_SX)
|
| | | goodsCount1 += co.getCount();
|
| | | }
|
| | | // 新版通知
|
| | | List<CommonOrder> orderList1 = commonOrderService
|
| | | .listBySourceTypeAndOrderId(Constant.SOURCE_TYPE_TAOBAO, weiQuanDrawBack.getOrderId());
|
| | | int goodsCount1 = 0;
|
| | | for (CommonOrder co : orderList1) {
|
| | | if (co.getState() != CommonOrder.STATE_SX)
|
| | | goodsCount1 += co.getCount();
|
| | | }
|
| | |
|
| | | BigDecimal fanliMoney1 = new BigDecimal(0);
|
| | | List<HongBaoOrder> hongBaoOrderList1 = hongBaoOrderService.listDetailByOrderIdAndSourceType(
|
| | | weiQuanDrawBack.getOrderId(), Constant.SOURCE_TYPE_TAOBAO);
|
| | | BigDecimal fanliMoney1 = new BigDecimal(0);
|
| | | List<HongBaoOrder> hongBaoOrderList1 = hongBaoOrderService.listDetailByOrderIdAndSourceType(
|
| | | weiQuanDrawBack.getOrderId(), Constant.SOURCE_TYPE_TAOBAO);
|
| | |
|
| | | for (HongBaoOrder hongBaoOrder : hongBaoOrderList1) {
|
| | | fanliMoney1 = fanliMoney1.add(hongBaoOrder.getHongBaoV2().getMoney());
|
| | | }
|
| | | for (HongBaoOrder hongBaoOrder : hongBaoOrderList1) {
|
| | | fanliMoney1 = fanliMoney1.add(hongBaoOrder.getHongBaoV2().getMoney());
|
| | | }
|
| | |
|
| | | userMoneyMsgNotificationService.shareOrderWeiQuan(uid, weiQuanDrawBack.getOrderId(),
|
| | | Constant.SOURCE_TYPE_TAOBAO, money, fanliMoney1, goodsCount1,
|
| | | orderList1.get(0).getThirdCreateTime());
|
| | | userMoneyMsgNotificationService.shareOrderWeiQuan(uid, weiQuanDrawBack.getOrderId(),
|
| | | Constant.SOURCE_TYPE_TAOBAO, money, fanliMoney1, goodsCount1,
|
| | | orderList1.get(0).getThirdCreateTime());
|
| | |
|
| | | } catch (UserMoneyDetailException e) {
|
| | | throw new UserMoneyDebtException(12, "插入资金详情出错");
|
| | | }
|
| | | break;
|
| | | case HongBaoV2.TYPE_SHARE_ERJI:
|
| | | case HongBaoV2.TYPE_SHARE_YIJI:
|
| | | case HongBaoV2.TYPE_ERJI:
|
| | | case HongBaoV2.TYPE_YIJI:
|
| | | } catch (UserMoneyDetailException e) {
|
| | | throw new UserMoneyDebtException(12, "插入资金详情出错");
|
| | | }
|
| | | break;
|
| | | case HongBaoV2.TYPE_SHARE_ERJI:
|
| | | case HongBaoV2.TYPE_SHARE_YIJI:
|
| | | case HongBaoV2.TYPE_ERJI:
|
| | | case HongBaoV2.TYPE_YIJI:
|
| | |
|
| | | // 新版资金记录
|
| | | try {
|
| | | UserMoneyDetail userMoneyDetail = UserMoneyDetailFactory.createInviteWeiQuan(uid, weiQuanDrawBack,
|
| | | money);
|
| | | userMoneyService.subUserMoney(uid, money, userMoneyDetail);
|
| | | } catch (UserMoneyDetailException e) {
|
| | | throw new UserMoneyDebtException(12, "插入资金详情出错");
|
| | | }
|
| | | // 新版资金记录
|
| | | try {
|
| | | UserMoneyDetail userMoneyDetail = UserMoneyDetailFactory.createInviteWeiQuan(uid, weiQuanDrawBack,
|
| | | money);
|
| | | userMoneyService.subUserMoney(uid, money, userMoneyDetail);
|
| | | } catch (UserMoneyDetailException e) {
|
| | | throw new UserMoneyDebtException(12, "插入资金详情出错");
|
| | | }
|
| | |
|
| | | break;
|
| | | }
|
| | | } else if (debt.getType() == UserMoneyDebtTypeEnum.extractVerify) {// 提现验证
|
| | | // 新版资金记录
|
| | | AlipayAccountValidNormalHistory aliPayAccountHistory = alipayAccountValidNormalHistoryMapper
|
| | | .selectByPrimaryKey(debt.getSourceId());
|
| | | break;
|
| | | }
|
| | | } else if (debt.getType() == UserMoneyDebtTypeEnum.extractVerify) {// 提现验证
|
| | | // 新版资金记录
|
| | | AlipayAccountValidNormalHistory aliPayAccountHistory = alipayAccountValidNormalHistoryMapper
|
| | | .selectByPrimaryKey(debt.getSourceId());
|
| | |
|
| | | AlipayAccountValidNormalHistory first = alipayAccountValidNormalHistoryMapper
|
| | | .selectLatestByUid(aliPayAccountHistory.getUid());
|
| | | AlipayAccountValidNormalHistory first = alipayAccountValidNormalHistoryMapper
|
| | | .selectLatestByUid(aliPayAccountHistory.getUid());
|
| | |
|
| | | if (aliPayAccountHistory == null)
|
| | | return;
|
| | | try {
|
| | | UserMoneyDetail userMoneyDetail = UserMoneyDetailFactory.createExtractAccountValid(aliPayAccountHistory,
|
| | | money);
|
| | | userMoneyService.subUserMoney(aliPayAccountHistory.getUid(), money, userMoneyDetail);
|
| | | } catch (UserMoneyDetailException e) {
|
| | | throw new UserMoneyDebtException(12, "插入资金详情出错");
|
| | | }
|
| | | userMoneyMsgNotificationService.alipayAccountValid(aliPayAccountHistory, "1个月",
|
| | | first.getId().longValue() != aliPayAccountHistory.getId());
|
| | | }
|
| | | }
|
| | | if (aliPayAccountHistory == null)
|
| | | return;
|
| | | try {
|
| | | UserMoneyDetail userMoneyDetail = UserMoneyDetailFactory.createExtractAccountValid(aliPayAccountHistory,
|
| | | money);
|
| | | userMoneyService.subUserMoney(aliPayAccountHistory.getUid(), money, userMoneyDetail);
|
| | | } catch (UserMoneyDetailException e) {
|
| | | throw new UserMoneyDebtException(12, "插入资金详情出错");
|
| | | }
|
| | | userMoneyMsgNotificationService.alipayAccountValid(aliPayAccountHistory, "1个月",
|
| | | first.getId().longValue() != aliPayAccountHistory.getId());
|
| | | }
|
| | | }
|
| | |
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | @Override
|
| | | public void repayDebt(Long uid) {
|
| | | // 查询是否有欠债
|
| | | List<UserMoneyDebt> list = userMoneyDebtMapper.listByUidWithHasLeftMoney(uid, 0, 50);
|
| | | if (list != null && list.size() > 0) {// 有欠债
|
| | | for (UserMoneyDebt debt : list) {
|
| | | BigDecimal leftMoney = userInfoService.getBalance(uid);
|
| | | if (leftMoney.compareTo(debt.getLeftMoney()) >= 0) {// 有足够的资金偿还债务
|
| | | try {
|
| | | repayDebt(debt, debt.getLeftMoney());
|
| | | } catch (UserMoneyDebtException e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e, "uid:" + uid + " debtId:" + debt.getId(), null);
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | @Override
|
| | | public void repayDebt(Long uid) {
|
| | | // 查询是否有欠债
|
| | | List<UserMoneyDebt> list = userMoneyDebtMapper.listByUidWithHasLeftMoney(uid, 0, 50);
|
| | | if (list != null && list.size() > 0) {// 有欠债
|
| | | for (UserMoneyDebt debt : list) {
|
| | | BigDecimal leftMoney = userInfoService.getBalance(uid);
|
| | | if (leftMoney.compareTo(debt.getLeftMoney()) >= 0) {// 有足够的资金偿还债务
|
| | | try {
|
| | | repayDebt(debt, debt.getLeftMoney());
|
| | | } catch (UserMoneyDebtException e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e, "uid:" + uid + " debtId:" + debt.getId(), null);
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | public boolean isHaveDebtToRepay(Long uid) {
|
| | | List<UserMoneyDebt> debtList = userMoneyDebtMapper.listByUidWithHasLeftMoney(uid, 0, 1);
|
| | | if (debtList != null && debtList.size() > 0)
|
| | | return true;
|
| | | return false;
|
| | | }
|
| | | @Override
|
| | | public boolean isHaveDebtToRepay(Long uid) {
|
| | | List<UserMoneyDebt> debtList = userMoneyDebtMapper.listByUidWithHasLeftMoney(uid, 0, 1);
|
| | | if (debtList != null && debtList.size() > 0)
|
| | | return true;
|
| | | return false;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<Long> listNeedRepayDebtUser(int page, int pageSize) {
|
| | | return userMoneyDebtMapper.listUidWithHasDebtToRepay((page - 1) * pageSize, pageSize);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public long countNeedRepayDebtUser() {
|
| | | return userMoneyDebtMapper.countUidWithHasDebtToRepay();
|
| | | }
|
| | |
|
| | | }
|
| | |
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import com.yeshi.fanli.util.*;
|
| | | import org.dom4j.Document;
|
| | | import org.dom4j.DocumentException;
|
| | | import org.dom4j.DocumentHelper;
|
| | |
| | | import com.yeshi.fanli.service.inter.push.PushService;
|
| | | import com.yeshi.fanli.service.inter.user.UserAccountBindingHistoryService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoService;
|
| | | import com.yeshi.fanli.util.AlipayUtil;
|
| | | import com.yeshi.fanli.util.CMQManager;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.GsonUtil;
|
| | | import org.yeshi.utils.MoneyBigDecimalUtil;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.ThreadUtil;
|
| | | import org.yeshi.utils.TimeUtil;
|
| | | import com.yeshi.fanli.util.factory.UserMoneyDetailFactory;
|
| | |
|
| | |
| | | int less10Count = commonOrderCountService.countOderByUidAndLess10(user.getId());
|
| | | ExtractAuditRecord update = new ExtractAuditRecord();
|
| | | update.setId(auditRecord.getId());
|
| | | int orderCount50More = orderUserStatisticService.countOrderCount100MoreByUidAndMinTime(user.getId(),
|
| | | minTime);
|
| | | int orderCountBigMoneyOrder = orderUserStatisticService.countOrderMoneyMoreByUidAndMinTime(user.getId(),
|
| | | minTime, OrderConstant.BIG_ORDER_MONEY);
|
| | | BigDecimal weiQuanOrderFanAmount = orderUserStatisticService.sumWeiQuanOrderFanAmountByUid(user.getId(),
|
| | | minTime);
|
| | | int weiQuanOrderCount = orderUserStatisticService.countWeiQuanOrderByUid(user.getId(), minTime);
|
| | | update.setExtraInfoStr(new Gson().toJson(new ExtractOrderStatisticDTO(orderCount50More,
|
| | | update.setExtraInfoStr(new Gson().toJson(new ExtractOrderStatisticDTO(orderCountBigMoneyOrder,
|
| | | weiQuanOrderCount, weiQuanOrderFanAmount, 0, less10Count)));
|
| | | extractAuditRecordMapper.updateByPrimaryKeySelective(update);
|
| | | }
|
| | |
| | | private HongBaoOrderMapper hongBaoOrderMapper;
|
| | |
|
| | | @Override
|
| | | public int countOrderCount100MoreByUidAndMinTime(Long uid, Date minTime) {
|
| | | return hongBaoOrderMapper.countOrderCountMoneyMoreByUidAndMinTime(uid, minTime, new BigDecimal(100));
|
| | | public int countOrderMoneyMoreByUidAndMinTime(Long uid, Date minTime,BigDecimal money) {
|
| | | return hongBaoOrderMapper.countOrderCountMoneyMoreByUidAndMinTime(uid, minTime,money);
|
| | | }
|
| | |
|
| | | @Override
|
| | |
| | | couponUrl = couponInfo.getLink();
|
| | | }
|
| | | String materialId = "https://item.jd.com/" + goodsId + ".html";
|
| | | String jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, JDApiUtil.POSITION_SHARE + "",
|
| | | String jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, null,JDApiUtil.POSITION_SHARE + "",
|
| | | user.getId() + "");
|
| | |
|
| | | boolean coupon = false;
|
| | |
| | | package com.yeshi.fanli.service.inter.money;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.util.List;
|
| | |
|
| | | import com.yeshi.fanli.entity.money.UserMoneyDebt;
|
| | | import com.yeshi.fanli.entity.money.UserMoneyDebt.UserMoneyDebtTypeEnum;
|
| | | import com.yeshi.fanli.exception.money.UserMoneyDebtException;
|
| | |
|
| | | public interface UserMoneyDebtService {
|
| | | /**
|
| | | * 添加用户借钱记录
|
| | | * |
| | | * @param debt
|
| | | * @throws UserMoneyDebtException
|
| | | */
|
| | | public void addUserMoneyDebt(UserMoneyDebt debt) throws UserMoneyDebtException;
|
| | | /**
|
| | | * 添加用户借钱记录
|
| | | *
|
| | | * @param debt
|
| | | * @throws UserMoneyDebtException
|
| | | */
|
| | | public void addUserMoneyDebt(UserMoneyDebt debt) throws UserMoneyDebtException;
|
| | |
|
| | | /**
|
| | | * 根据类型与源ID获取
|
| | | * |
| | | * @param type
|
| | | * @param sourceId
|
| | | * @return
|
| | | */
|
| | | public UserMoneyDebt selectByTypeAndSourceId(UserMoneyDebtTypeEnum type, Long sourceId);
|
| | | /**
|
| | | * 根据类型与源ID获取
|
| | | *
|
| | | * @param type
|
| | | * @param sourceId
|
| | | * @return
|
| | | */
|
| | | public UserMoneyDebt selectByTypeAndSourceId(UserMoneyDebtTypeEnum type, Long sourceId);
|
| | |
|
| | | /**
|
| | | * 偿还
|
| | | * |
| | | * @param debt
|
| | | * @throws UserMoneyDebtException
|
| | | */
|
| | | public void repayDebt(UserMoneyDebt debt, BigDecimal money) throws UserMoneyDebtException;
|
| | | /**
|
| | | * 偿还
|
| | | *
|
| | | * @param debt
|
| | | * @throws UserMoneyDebtException
|
| | | */
|
| | | public void repayDebt(UserMoneyDebt debt, BigDecimal money) throws UserMoneyDebtException;
|
| | |
|
| | | /**
|
| | | * 偿还
|
| | | * |
| | | * @param uid
|
| | | */
|
| | | public void repayDebt(Long uid);
|
| | | /**
|
| | | * 偿还
|
| | | *
|
| | | * @param uid
|
| | | */
|
| | | public void repayDebt(Long uid);
|
| | |
|
| | | /**
|
| | | * 是否有账务待还
|
| | | * |
| | | * @param uid
|
| | | * @return
|
| | | */
|
| | | public boolean isHaveDebtToRepay(Long uid);
|
| | | /**
|
| | | * 是否有账务待还
|
| | | *
|
| | | * @param uid
|
| | | * @return
|
| | | */
|
| | | public boolean isHaveDebtToRepay(Long uid);
|
| | |
|
| | |
|
| | | /**
|
| | | * 查询需要偿还的用户列表
|
| | | *
|
| | | * @param page
|
| | | * @param pageSize
|
| | | * @return
|
| | | */
|
| | | public List<Long> listNeedRepayDebtUser(int page, int pageSize);
|
| | |
|
| | | /**
|
| | | * @return
|
| | | */
|
| | | public long countNeedRepayDebtUser();
|
| | | }
|
| | |
| | | * @param minTime
|
| | | * @return
|
| | | */
|
| | | public int countOrderCount100MoreByUidAndMinTime(Long uid, Date minTime);
|
| | | public int countOrderMoneyMoreByUidAndMinTime(Long uid, Date minTime,BigDecimal money);
|
| | |
|
| | | /**
|
| | | * 维权订单数量(包含邀请赚)
|
| | |
| | | for (String shortLink : linkSet) {
|
| | | String link = null;
|
| | | if (share)
|
| | | link = JDApiUtil.convertLinkWithSubUnionId(shortLink, null, JDApiUtil.POSITION_SHARE + "",
|
| | | link = JDApiUtil.convertLinkWithSubUnionId(shortLink, null, null,JDApiUtil.POSITION_SHARE + "",
|
| | | uid + "");
|
| | | else
|
| | | link = JDApiUtil.convertLinkWithSubUnionId(shortLink, null, JDApiUtil.POSITION_FANLI + "",
|
| | | link = JDApiUtil.convertLinkWithSubUnionId(shortLink, null, null,JDApiUtil.POSITION_FANLI + "",
|
| | | uid + "");
|
| | | if (!StringUtil.isNullOrEmpty(link)) {
|
| | | linkMap.put(shortLink, link);
|
New file |
| | |
| | | package com.yeshi.fanli.util; |
| | | |
| | | import java.math.BigDecimal; |
| | | |
| | | public class OrderConstant { |
| | | |
| | | //大额订单阈值 |
| | | public final static BigDecimal BIG_ORDER_MONEY = new BigDecimal(50); |
| | | } |
| | |
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | |
|
| | | import com.sun.istack.NotNull;
|
| | | import org.apache.commons.httpclient.HttpClient;
|
| | | import org.apache.commons.httpclient.methods.PostMethod;
|
| | |
|
| | |
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | public class JDApiUtil {
|
| | | public static String APP_ID = "1864778416";
|
| | | public static String APP_KEY = "388f5133d13a5ea290aa5c44f3ebcc00";
|
| | | public static String SECRET_KEY = "e22367fc866746d98b50d47b4c521781";
|
| | | private static String SERVER_URL = "https://router.jd.com/api";
|
| | | public static String APP_ID = "1864778416";
|
| | | public static String APP_KEY = "388f5133d13a5ea290aa5c44f3ebcc00";
|
| | | public static String SECRET_KEY = "e22367fc866746d98b50d47b4c521781";
|
| | | private static String SERVER_URL = "https://router.jd.com/api";
|
| | |
|
| | | public static long POSITION_FANLI = 1869704794L;
|
| | | public static long POSITION_SHARE = 1869542990L;
|
| | | public static long POSITION_COUPON = 1869704796L;
|
| | | public static long POSITION_FANLI = 1869704794L;
|
| | | public static long POSITION_SHARE = 1869542990L;
|
| | | public static long POSITION_COUPON = 1869704796L;
|
| | |
|
| | | // 订单查询类型
|
| | | public static int ORDER_TYPE_CREATETIME = 1;// 下单时间
|
| | | public static int ORDER_TYPE_FINISHTIME = 2;// 完成时间
|
| | | public static int ORDER_TYPE_UPDATETIME = 3;// 更新时间
|
| | | // 订单查询类型
|
| | | public static int ORDER_TYPE_CREATETIME = 1;// 下单时间
|
| | | public static int ORDER_TYPE_FINISHTIME = 2;// 完成时间
|
| | | public static int ORDER_TYPE_UPDATETIME = 3;// 更新时间
|
| | |
|
| | | private static String post2(String url, Map<String, String> params) {
|
| | | String baseUrl = url;
|
| | | List<String> paramsList = new ArrayList<>();
|
| | | if (params != null)
|
| | | for (Iterator<String> its = params.keySet().iterator(); its.hasNext();) {
|
| | | String key = its.next();
|
| | | try {
|
| | | paramsList.add(key + "=" + URLEncoder.encode(params.get(key), "UTF-8"));
|
| | | } catch (UnsupportedEncodingException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | baseUrl += "?" + StringUtil.concat(paramsList, "&");
|
| | | HttpClient client = new HttpClient();
|
| | | PostMethod pm = new PostMethod(baseUrl);
|
| | | try {
|
| | | client.executeMethod(pm);
|
| | | String result = pm.getResponseBodyAsString();
|
| | | return result;
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | return null;
|
| | | }
|
| | | private static String post2(String url, Map<String, String> params) {
|
| | | String baseUrl = url;
|
| | | List<String> paramsList = new ArrayList<>();
|
| | | if (params != null)
|
| | | for (Iterator<String> its = params.keySet().iterator(); its.hasNext(); ) {
|
| | | String key = its.next();
|
| | | try {
|
| | | paramsList.add(key + "=" + URLEncoder.encode(params.get(key), "UTF-8"));
|
| | | } catch (UnsupportedEncodingException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | baseUrl += "?" + StringUtil.concat(paramsList, "&");
|
| | | HttpClient client = new HttpClient();
|
| | | PostMethod pm = new PostMethod(baseUrl);
|
| | | try {
|
| | | client.executeMethod(pm);
|
| | | String result = pm.getResponseBodyAsString();
|
| | | return result;
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | return null;
|
| | | }
|
| | |
|
| | | private static String getSign(Map<String, String> params) {
|
| | | List<String> list = new ArrayList<>();
|
| | | Iterator<String> its = params.keySet().iterator();
|
| | | while (its.hasNext()) {
|
| | | String key = its.next();
|
| | | list.add(key + params.get(key));
|
| | | }
|
| | | String str = "";
|
| | | Collections.sort(list);
|
| | | for (String st : list) {
|
| | | str += st;
|
| | | }
|
| | | return StringUtil.Md5(SECRET_KEY + str + SECRET_KEY).toUpperCase();
|
| | | }
|
| | | private static String getSign(Map<String, String> params) {
|
| | | List<String> list = new ArrayList<>();
|
| | | Iterator<String> its = params.keySet().iterator();
|
| | | while (its.hasNext()) {
|
| | | String key = its.next();
|
| | | list.add(key + params.get(key));
|
| | | }
|
| | | String str = "";
|
| | | Collections.sort(list);
|
| | | for (String st : list) {
|
| | | str += st;
|
| | | }
|
| | | return StringUtil.Md5(SECRET_KEY + str + SECRET_KEY).toUpperCase();
|
| | | }
|
| | |
|
| | | private static String baseRequest2(String method, String accessToken, JSONObject params) {
|
| | | Map<String, String> baseMap = new HashMap<String, String>();
|
| | | baseMap.put("param_json", params.toString());
|
| | | baseMap.put("app_key", APP_KEY);
|
| | | baseMap.put("method", method);
|
| | | if (accessToken != null)
|
| | | baseMap.put("access_token", accessToken);
|
| | | baseMap.put("timestamp", TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy-MM-dd HH:mm:ss"));
|
| | | baseMap.put("format", "json");
|
| | | baseMap.put("v", "1.0");
|
| | | baseMap.put("sign_method", "md5");
|
| | | baseMap.put("sign", getSign(baseMap));
|
| | | String result = post2(SERVER_URL, baseMap);
|
| | | 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());
|
| | | baseMap.put("app_key", APP_KEY);
|
| | | baseMap.put("method", method);
|
| | | if (accessToken != null)
|
| | | baseMap.put("access_token", accessToken);
|
| | | baseMap.put("timestamp", TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy-MM-dd HH:mm:ss"));
|
| | | baseMap.put("format", "json");
|
| | | baseMap.put("v", "1.0");
|
| | | baseMap.put("sign_method", "md5");
|
| | | baseMap.put("sign", getSign(baseMap));
|
| | | String result = post2(SERVER_URL, baseMap);
|
| | | return result;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 转链
|
| | | * |
| | | * @return
|
| | | */
|
| | | public static String convertLink1(String materialId, String couponUrl, String positionId, String ext1) {
|
| | | JSONObject json = new JSONObject();
|
| | | json.put("materialId", materialId);
|
| | | json.put("siteId", APP_ID);
|
| | | json.put("positionId", positionId);
|
| | | /**
|
| | | * 转链
|
| | | *
|
| | | * @return
|
| | | */
|
| | | public static String convertLink1(String materialId, String couponUrl, String positionId, String ext1) {
|
| | | JSONObject json = new JSONObject();
|
| | | json.put("materialId", materialId);
|
| | | json.put("siteId", APP_ID);
|
| | | json.put("positionId", positionId);
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(couponUrl))
|
| | | json.put("couponUrl", couponUrl);
|
| | | if (!StringUtil.isNullOrEmpty(couponUrl))
|
| | | json.put("couponUrl", couponUrl);
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(ext1))
|
| | | json.put("ext1", ext1);
|
| | | if (!StringUtil.isNullOrEmpty(ext1))
|
| | | json.put("ext1", ext1);
|
| | |
|
| | | JSONObject root = new JSONObject();
|
| | | root.put("promotionCodeReq", json);
|
| | | JSONObject root = new JSONObject();
|
| | | root.put("promotionCodeReq", json);
|
| | |
|
| | | String result = baseRequest2("jd.union.open.promotion.common.get", null, root);
|
| | | String result = baseRequest2("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");
|
| | | System.out.println(result);
|
| | | if (result == null) {
|
| | | return null;
|
| | | }
|
| | | JSONObject resultJson = JSONObject.fromObject(result);
|
| | | result = resultJson.optJSONObject("jd_union_open_promotion_common_get_response").optString("result");
|
| | | System.out.println(result);
|
| | | if (result == null) {
|
| | | return null;
|
| | | }
|
| | |
|
| | | resultJson = JSONObject.fromObject(result);
|
| | | return resultJson.optJSONObject("data").optString("clickURL");
|
| | | }
|
| | | resultJson = JSONObject.fromObject(result);
|
| | | return resultJson.optJSONObject("data").optString("clickURL");
|
| | | }
|
| | |
|
| | | public static String convertLinkWithSubUnionId(String materialId, String couponUrl, String positionId,
|
| | | String subUnionId) {
|
| | | String log = "京东转链出错:";
|
| | | try {
|
| | | JSONObject json = new JSONObject();
|
| | | json.put("materialId", materialId);
|
| | | json.put("siteId", APP_ID);
|
| | | json.put("positionId", positionId);
|
| | | public static String convertLinkWithSubUnionId(@NotNull String materialId, String couponUrl, String giftCouponKey, @NotNull String positionId,
|
| | | String subUnionId) {
|
| | | String log = "京东转链出错:";
|
| | | try {
|
| | | JSONObject json = new JSONObject();
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(couponUrl))
|
| | | json.put("couponUrl", couponUrl);
|
| | | json.put("siteId", APP_ID);
|
| | | json.put("positionId", positionId);
|
| | | json.put("materialId", materialId);
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(subUnionId))
|
| | | json.put("subUnionId", subUnionId);
|
| | | if (!StringUtil.isNullOrEmpty(giftCouponKey)) {
|
| | | json.put("giftCouponKey", giftCouponKey);
|
| | | }
|
| | | if (!StringUtil.isNullOrEmpty(couponUrl))
|
| | | json.put("couponUrl", couponUrl);
|
| | |
|
| | | // 1:长链, 2 :短链 ,3: 长链+短链
|
| | | json.put("chainType", 3);
|
| | | JSONObject root = new JSONObject();
|
| | | root.put("promotionCodeReq", json);
|
| | | if (!StringUtil.isNullOrEmpty(subUnionId))
|
| | | json.put("subUnionId", subUnionId);
|
| | |
|
| | | String result = baseRequest2("jd.union.open.promotion.bysubunionid.get", null, root);
|
| | | // 1:长链, 2 :短链 ,3: 长链+短链
|
| | | json.put("chainType", 3);
|
| | | JSONObject root = new JSONObject();
|
| | | root.put("promotionCodeReq", json);
|
| | |
|
| | | log += json.toString() + "####" + result;
|
| | | JSONObject resultJson = JSONObject.fromObject(result);
|
| | | result = resultJson.optJSONObject("jd_union_open_promotion_bysubunionid_get_response").optString("result");
|
| | | System.out.println(result);
|
| | | if (result == null) {
|
| | | return null;
|
| | | }
|
| | | String result = baseRequest2("jd.union.open.promotion.bysubunionid.get", null, root);
|
| | |
|
| | | resultJson = JSONObject.fromObject(result);
|
| | | return resultJson.optJSONObject("data").optString("shortURL");
|
| | | } catch (Exception e) {
|
| | | LogHelper.error(log);
|
| | | }
|
| | | log += json.toString() + "####" + result;
|
| | | JSONObject resultJson = JSONObject.fromObject(result);
|
| | | result = resultJson.optJSONObject("jd_union_open_promotion_bysubunionid_get_response").optString("result");
|
| | | System.out.println(result);
|
| | | if (result == null) {
|
| | | return null;
|
| | | }
|
| | |
|
| | | return null;
|
| | | }
|
| | | resultJson = JSONObject.fromObject(result);
|
| | | return resultJson.optJSONObject("data").optString("shortURL");
|
| | | } catch (Exception e) {
|
| | | LogHelper.error(log);
|
| | | }
|
| | |
|
| | | public static JDGoods queryGoodsDetail(Long skuId) {
|
| | | List<Long> skuIdList = new ArrayList<>();
|
| | | skuIdList.add(skuId);
|
| | | JDFilter filter = new JDFilter();
|
| | | filter.setPageIndex(1);
|
| | | filter.setPageSize(20);
|
| | | filter.setListId(skuIdList);
|
| | | JDSearchResult searchResult = queryByKey(filter);
|
| | | if (searchResult != null) {
|
| | | List<JDGoods> list = searchResult.getGoodsList();
|
| | | if (list != null && list.size() > 0)
|
| | | return list.get(0);
|
| | | }
|
| | | return null;
|
| | | }
|
| | | return null;
|
| | | }
|
| | |
|
| | | public static List<JDGoods> queryGoodsDetail(List<Long> skuIdList) {
|
| | | JDFilter filter = new JDFilter();
|
| | | filter.setPageIndex(1);
|
| | | filter.setPageSize(20);
|
| | | filter.setListId(skuIdList);
|
| | | JDSearchResult searchResult = queryByKey(filter);
|
| | | if (searchResult != null) {
|
| | | List<JDGoods> list = searchResult.getGoodsList();
|
| | | if (list != null && list.size() > 0)
|
| | | return list;
|
| | | }
|
| | | return null;
|
| | | }
|
| | | public static JDGoods queryGoodsDetail(Long skuId) {
|
| | | List<Long> skuIdList = new ArrayList<>();
|
| | | skuIdList.add(skuId);
|
| | | JDFilter filter = new JDFilter();
|
| | | filter.setPageIndex(1);
|
| | | filter.setPageSize(20);
|
| | | filter.setListId(skuIdList);
|
| | | JDSearchResult searchResult = queryByKey(filter);
|
| | | if (searchResult != null) {
|
| | | List<JDGoods> list = searchResult.getGoodsList();
|
| | | if (list != null && list.size() > 0)
|
| | | return list.get(0);
|
| | | }
|
| | | return null;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 通过商品搜索接口批量获取详情
|
| | | * |
| | | * @param skuIds
|
| | | * @return
|
| | | */
|
| | | public static List<JDGoods> listGoodsDetail(List<Long> skuIds) {
|
| | | JDFilter filter = new JDFilter();
|
| | | filter.setListId(skuIds);
|
| | | JDSearchResult result = queryByKey(filter);
|
| | | return result.getGoodsList();
|
| | | }
|
| | | public static List<JDGoods> queryGoodsDetail(List<Long> skuIdList) {
|
| | | JDFilter filter = new JDFilter();
|
| | | filter.setPageIndex(1);
|
| | | filter.setPageSize(20);
|
| | | filter.setListId(skuIdList);
|
| | | JDSearchResult searchResult = queryByKey(filter);
|
| | | if (searchResult != null) {
|
| | | List<JDGoods> list = searchResult.getGoodsList();
|
| | | if (list != null && list.size() > 0)
|
| | | return list;
|
| | | }
|
| | | return null;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 关键词商品查询接口【申请】
|
| | | * |
| | | * @param skuIdList
|
| | | * @return
|
| | | */
|
| | | public static JDSearchResult queryByKey(JDFilter filter) {
|
| | | JDSearchResult searchResult = new JDSearchResult();
|
| | | /**
|
| | | * 通过商品搜索接口批量获取详情
|
| | | *
|
| | | * @param skuIds
|
| | | * @return
|
| | | */
|
| | | public static List<JDGoods> listGoodsDetail(List<Long> skuIds) {
|
| | | JDFilter filter = new JDFilter();
|
| | | filter.setListId(skuIds);
|
| | | JDSearchResult result = queryByKey(filter);
|
| | | return result.getGoodsList();
|
| | | }
|
| | |
|
| | | List<JDGoods> list = new ArrayList<>();
|
| | | JSONObject json = new JSONObject();
|
| | | json.put("pageIndex", filter.getPageIndex());
|
| | | json.put("pageSize", filter.getPageSize());
|
| | | /**
|
| | | * 关键词商品查询接口【申请】
|
| | | *
|
| | | * @param filter
|
| | | * @return
|
| | | */
|
| | | public static JDSearchResult queryByKey(JDFilter filter) {
|
| | | JDSearchResult searchResult = new JDSearchResult();
|
| | |
|
| | | if (filter.getCid1() != null)
|
| | | json.put("cid1", filter.getCid1());
|
| | | List<JDGoods> list = new ArrayList<>();
|
| | | JSONObject json = new JSONObject();
|
| | | json.put("pageIndex", filter.getPageIndex());
|
| | | json.put("pageSize", filter.getPageSize());
|
| | |
|
| | | if (filter.getCid2() != null)
|
| | | json.put("cid2", filter.getCid2());
|
| | | if (filter.getCid1() != null)
|
| | | json.put("cid1", filter.getCid1());
|
| | |
|
| | | if (filter.getCid3() != null)
|
| | | json.put("cid3", filter.getCid3());
|
| | | if (filter.getCid2() != null)
|
| | | json.put("cid2", filter.getCid2());
|
| | |
|
| | | if (filter.getKeyword() != null)
|
| | | json.put("keyword", filter.getKeyword());
|
| | | if (filter.getCid3() != null)
|
| | | json.put("cid3", filter.getCid3());
|
| | |
|
| | | if (filter.getPricefrom() != null)
|
| | | json.put("pricefrom", filter.getPricefrom());
|
| | | if (filter.getKeyword() != null)
|
| | | json.put("keyword", filter.getKeyword());
|
| | |
|
| | | if (filter.getPriceto() != null)
|
| | | json.put("priceto", filter.getPriceto());
|
| | | if (filter.getPricefrom() != null)
|
| | | json.put("pricefrom", filter.getPricefrom());
|
| | |
|
| | | if (filter.getCommissionShareStart() != null)
|
| | | json.put("commissionShareStart", filter.getCommissionShareStart());
|
| | | if (filter.getPriceto() != null)
|
| | | json.put("priceto", filter.getPriceto());
|
| | |
|
| | | if (filter.getCommissionShareEnd() != null)
|
| | | json.put("commissionShareEnd", filter.getCommissionShareEnd());
|
| | | if (filter.getCommissionShareStart() != null)
|
| | | json.put("commissionShareStart", filter.getCommissionShareStart());
|
| | |
|
| | | if (filter.getSortName() != null)
|
| | | json.put("sortName", filter.getSortName());
|
| | | if (filter.getCommissionShareEnd() != null)
|
| | | json.put("commissionShareEnd", filter.getCommissionShareEnd());
|
| | |
|
| | | if (filter.getSort() != null)
|
| | | json.put("sort", filter.getSort());
|
| | | if (filter.getSortName() != null)
|
| | | json.put("sortName", filter.getSortName());
|
| | |
|
| | | if (filter.getIsCoupon() != null)
|
| | | json.put("isCoupon", filter.getIsCoupon());
|
| | | if (filter.getSort() != null)
|
| | | json.put("sort", filter.getSort());
|
| | |
|
| | | if (filter.getListId() != null)
|
| | | json.put("skuIds", "[" + StringUtil.concat(filter.getListId(), ",") + "]");
|
| | | if (filter.getIsCoupon() != null)
|
| | | json.put("isCoupon", filter.getIsCoupon());
|
| | |
|
| | | if (filter.getIsPG() != null)
|
| | | json.put("isPG", filter.getIsPG());
|
| | | if (filter.getListId() != null)
|
| | | json.put("skuIds", "[" + StringUtil.concat(filter.getListId(), ",") + "]");
|
| | |
|
| | | if (filter.getPingouPriceStart() != null)
|
| | | json.put("pingouPriceStart", filter.getPingouPriceStart());
|
| | | if (filter.getIsPG() != null)
|
| | | json.put("isPG", filter.getIsPG());
|
| | |
|
| | | if (filter.getPingouPriceEnd() != null)
|
| | | json.put("pingouPriceEnd", filter.getPingouPriceEnd());
|
| | | if (filter.getPingouPriceStart() != null)
|
| | | json.put("pingouPriceStart", filter.getPingouPriceStart());
|
| | |
|
| | | if (filter.getIsHot() != null)
|
| | | json.put("isHot", filter.getIsHot());
|
| | | if (filter.getPingouPriceEnd() != null)
|
| | | json.put("pingouPriceEnd", filter.getPingouPriceEnd());
|
| | |
|
| | | if (filter.getBrandCode() != null)
|
| | | json.put("brandCode", filter.getBrandCode());
|
| | | if (filter.getIsHot() != null)
|
| | | json.put("isHot", filter.getIsHot());
|
| | |
|
| | | if (filter.getShopId() != null)
|
| | | json.put("shopId", filter.getShopId());
|
| | | if (filter.getBrandCode() != null)
|
| | | json.put("brandCode", filter.getBrandCode());
|
| | |
|
| | | if (filter.getOwner() != null)
|
| | | json.put("owner", filter.getOwner());
|
| | | if (filter.getShopId() != null)
|
| | | json.put("shopId", filter.getShopId());
|
| | |
|
| | | System.out.println(json.toString());
|
| | | if (filter.getOwner() != null)
|
| | | json.put("owner", filter.getOwner());
|
| | |
|
| | | JSONObject jsonDTO = new JSONObject();
|
| | | jsonDTO.put("goodsReqDTO", json);
|
| | | System.out.println(json.toString());
|
| | |
|
| | | String result = baseRequest2("jd.union.open.goods.query", null, jsonDTO);
|
| | | System.out.println(result);
|
| | | JSONObject resultJson = JSONObject.fromObject(result);
|
| | | resultJson = resultJson.optJSONObject("jd_union_open_goods_query_response");
|
| | | if (resultJson.optInt("code") == 0) {
|
| | | result = resultJson.optString("result");
|
| | | resultJson = JSONObject.fromObject(result);
|
| | | String message = resultJson.optString("message");
|
| | | if ("SUCCESS".equalsIgnoreCase(message)) {
|
| | | JSONArray array = resultJson.optJSONArray("data");
|
| | | if (array != null) {
|
| | | for (int i = 0; i < array.size(); i++) {
|
| | | JDGoods goods = parseJDGoods(array.optJSONObject(i));
|
| | | if (goods != null)
|
| | | list.add(goods);
|
| | | }
|
| | | }
|
| | | }
|
| | | JSONObject jsonDTO = new JSONObject();
|
| | | jsonDTO.put("goodsReqDTO", json);
|
| | |
|
| | | long totalCount = resultJson.optLong("totalCount");
|
| | | PageEntity pageEntity = new PageEntity();
|
| | | pageEntity.setTotalCount(totalCount);
|
| | | String result = baseRequest2("jd.union.open.goods.query", null, jsonDTO);
|
| | | System.out.println(result);
|
| | | JSONObject resultJson = JSONObject.fromObject(result);
|
| | | resultJson = resultJson.optJSONObject("jd_union_open_goods_query_response");
|
| | | if (resultJson.optInt("code") == 0) {
|
| | | result = resultJson.optString("result");
|
| | | resultJson = JSONObject.fromObject(result);
|
| | | String message = resultJson.optString("message");
|
| | | if ("SUCCESS".equalsIgnoreCase(message)) {
|
| | | JSONArray array = resultJson.optJSONArray("data");
|
| | | if (array != null) {
|
| | | for (int i = 0; i < array.size(); i++) {
|
| | | JDGoods goods = parseJDGoods(array.optJSONObject(i));
|
| | | if (goods != null)
|
| | | list.add(goods);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | searchResult.setPageEntity(pageEntity);
|
| | | }
|
| | | searchResult.setGoodsList(list);
|
| | | return searchResult;
|
| | | }
|
| | | long totalCount = resultJson.optLong("totalCount");
|
| | | PageEntity pageEntity = new PageEntity();
|
| | | pageEntity.setTotalCount(totalCount);
|
| | |
|
| | | /**
|
| | | * 解析京东的券信息
|
| | | * |
| | | * @param json
|
| | | * @return
|
| | | */
|
| | | private static JDCouponInfo parseJDCouponInfo(JSONObject json) {
|
| | | JDCouponInfo couponInfo = new Gson().fromJson(json.toString(), JDCouponInfo.class);
|
| | | return couponInfo;
|
| | | }
|
| | | searchResult.setPageEntity(pageEntity);
|
| | | }
|
| | | searchResult.setGoodsList(list);
|
| | | return searchResult;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 解析京东商品信息
|
| | | * |
| | | * @param json
|
| | | * @return
|
| | | */
|
| | | /**
|
| | | * 解析京东的券信息
|
| | | *
|
| | | * @param json
|
| | | * @return
|
| | | */
|
| | | private static JDCouponInfo parseJDCouponInfo(JSONObject json) {
|
| | | JDCouponInfo couponInfo = new Gson().fromJson(json.toString(), JDCouponInfo.class);
|
| | | return couponInfo;
|
| | | }
|
| | |
|
| | | private static JDGoods parseJDGoods(JSONObject json) {
|
| | | JDGoods goods = new JDGoods();
|
| | | /**
|
| | | * 解析京东商品信息
|
| | | *
|
| | | * @param json
|
| | | * @return
|
| | | */
|
| | |
|
| | | // 佣金信息
|
| | | Object commission = json.get("commissionInfo");
|
| | | JSONObject commissionJson = JSONObject.fromObject(commission);
|
| | | BigDecimal commissionShare = new BigDecimal(commissionJson.optString("commissionShare"));
|
| | | if (commissionShare.compareTo(new BigDecimal(0)) > 0) {
|
| | | JDCommissionInfo commissionInfo = new JDCommissionInfo();
|
| | | commissionInfo.setCommission(new BigDecimal(commissionJson.optString("commission")));
|
| | | commissionInfo.setCommissionShare(commissionShare);
|
| | | goods.setCommissionInfo(commissionInfo);
|
| | | } else {
|
| | | return null;
|
| | | }
|
| | | private static JDGoods parseJDGoods(JSONObject json) {
|
| | | JDGoods goods = new JDGoods();
|
| | |
|
| | | // 佣金信息
|
| | | Object commission = json.get("commissionInfo");
|
| | | JSONObject commissionJson = JSONObject.fromObject(commission);
|
| | | BigDecimal commissionShare = new BigDecimal(commissionJson.optString("commissionShare"));
|
| | | if (commissionShare.compareTo(new BigDecimal(0)) > 0) {
|
| | | JDCommissionInfo commissionInfo = new JDCommissionInfo();
|
| | | commissionInfo.setCommission(new BigDecimal(commissionJson.optString("commission")));
|
| | | commissionInfo.setCommissionShare(commissionShare);
|
| | | goods.setCommissionInfo(commissionInfo);
|
| | | } else {
|
| | | return null;
|
| | | }
|
| | |
|
| | | goods.setComments(json.optLong("comments"));
|
| | | goods.setBrandCode(json.optString("brandCode"));
|
| | | goods.setBrandName(json.optString("brandName"));
|
| | | goods.setGoodCommentsShare(new BigDecimal(json.optString("goodCommentsShare")));
|
| | | goods.setInOrderCount30Days(json.optLong("inOrderCount30Days"));
|
| | | goods.setOwner(json.optString("owner"));
|
| | | goods.setMaterialUrl(json.optString("materialUrl"));
|
| | | 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 jdshopInfo = new JDShopInfo();
|
| | | jdshopInfo.setShopId(shopInfoJson.optInt("shopId"));
|
| | | jdshopInfo.setShopName(shopInfoJson.optString("shopName"));
|
| | | goods.setShopInfo(jdshopInfo);
|
| | |
|
| | | // 分类信息
|
| | | Object category = json.get("categoryInfo");
|
| | | JSONObject categoryJson = JSONObject.fromObject(category);
|
| | | JDCategoryInfo categoryInfo = new JDCategoryInfo();
|
| | | categoryInfo.setCid1(categoryJson.optLong("cid1"));
|
| | | categoryInfo.setCid1Name(categoryJson.optString("cid1Name"));
|
| | | categoryInfo.setCid2(categoryJson.optLong("cid2"));
|
| | | categoryInfo.setCid2Name(categoryJson.optString("cid2Name"));
|
| | | categoryInfo.setCid3(categoryJson.optLong("cid3"));
|
| | | categoryInfo.setCid3Name(categoryJson.optString("cid3Name"));
|
| | | goods.setCategoryInfo(categoryInfo);
|
| | |
|
| | | // 图片信息
|
| | | List<String> imageList = new ArrayList<String>();
|
| | | Object images = json.get("imageInfo");
|
| | | JSONObject imagesJson = JSONObject.fromObject(images);
|
| | | JSONArray imagesArray = imagesJson.optJSONArray("imageList");
|
| | | for (int i = 0; i < imagesArray.size(); i++) {
|
| | | 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");
|
| | | if (pinGouInfo != null) {
|
| | | JSONObject pinGouInfoJson = JSONObject.fromObject(pinGouInfo);
|
| | | if (!pinGouInfoJson.isEmpty()) {
|
| | | JDPingouInfo jdPinGouInfo = new JDPingouInfo();
|
| | | price = new BigDecimal(pinGouInfoJson.optString("pingouPrice"));
|
| | | jdPinGouInfo.setPingouPrice(price);
|
| | | jdPinGouInfo.setPingouTmCount(pinGouInfoJson.optLong("pingouTmCount"));
|
| | | jdPinGouInfo.setPingouUrl(pinGouInfoJson.optString("pingouUrl"));
|
| | | jdPinGouInfo.setTotalCount(pinGouInfoJson.optLong("totalCount"));
|
| | | jdPinGouInfo.setPingouEndTime(pinGouInfoJson.optLong("pingouEndTime"));
|
| | | jdPinGouInfo.setPingouStartTime(pinGouInfoJson.optLong("pingouStartTime"));
|
| | | goods.setPinGouInfo(jdPinGouInfo);
|
| | | }
|
| | | }
|
| | |
|
| | | // 券信息
|
| | | Object coupon = json.get("couponInfo");
|
| | | if (coupon != null) {
|
| | | JSONObject couponJson = JSONObject.fromObject(coupon);
|
| | | JSONArray couponArray = couponJson.optJSONArray("couponList");
|
| | | if (couponArray != null) {
|
| | | List<JDCouponInfo> couponInfoList = new ArrayList<>();
|
| | | for (int i = 0; i < couponArray.size(); i++) {
|
| | | JDCouponInfo couponInfo = parseJDCouponInfo(couponArray.optJSONObject(i));
|
| | | if (couponInfo != null)
|
| | | couponInfoList.add(couponInfo);
|
| | | }
|
| | |
|
| | | // 根据消费条件排序
|
| | | Comparator<JDCouponInfo> cm = new Comparator<JDCouponInfo>() {
|
| | | @Override
|
| | | public int compare(JDCouponInfo o1, JDCouponInfo o2) {
|
| | | return o1.getQuota().compareTo(o2.getQuota());
|
| | | }
|
| | | };
|
| | | Collections.sort(couponInfoList, cm);
|
| | | // if (couponInfoList.size() > 0) {
|
| | | // // 设置券信息为最接近的一个
|
| | | // for (int i = couponInfoList.size() - 1; i >= 0; i--) {
|
| | | // if
|
| | | // (couponInfoList.get(i).getQuota().compareTo(goods.getPrice())
|
| | | // <= 0) {
|
| | | // goods.setCouponInfo(couponInfoList.get(i));
|
| | | // break;
|
| | | // }
|
| | | // }
|
| | | // if (goods.getCouponInfo() == null)
|
| | | // goods.setCouponInfo(couponInfoList.get(0));
|
| | | // }
|
| | | //
|
| | | goods.setCouponInfoList(couponInfoList);
|
| | |
|
| | | goods.setComments(json.optLong("comments"));
|
| | | goods.setBrandCode(json.optString("brandCode"));
|
| | | goods.setBrandName(json.optString("brandName"));
|
| | | goods.setGoodCommentsShare(new BigDecimal(json.optString("goodCommentsShare")));
|
| | | goods.setInOrderCount30Days(json.optLong("inOrderCount30Days"));
|
| | | goods.setOwner(json.optString("owner"));
|
| | | goods.setMaterialUrl(json.optString("materialUrl"));
|
| | | 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")));
|
| | | return goods;
|
| | | }
|
| | |
|
| | | // 店铺信息
|
| | | Object shopInfo = json.get("shopInfo");
|
| | | JSONObject shopInfoJson = JSONObject.fromObject(shopInfo);
|
| | | JDShopInfo jdshopInfo = new JDShopInfo();
|
| | | jdshopInfo.setShopId(shopInfoJson.optInt("shopId"));
|
| | | jdshopInfo.setShopName(shopInfoJson.optString("shopName"));
|
| | | goods.setShopInfo(jdshopInfo);
|
| | | /**
|
| | | * 获取推广商品信息接口
|
| | | *
|
| | | * @param skuIdList
|
| | | * @return
|
| | | */
|
| | | public static List<JDGoods> getGoodsDetail(List<Long> skuIdList) {
|
| | | List<JDGoods> list = new ArrayList<>();
|
| | | JSONObject json = new JSONObject();
|
| | | json.put("skuIds", StringUtil.concat(skuIdList, ","));
|
| | | String result = baseRequest2("jd.union.open.goods.promotiongoodsinfo.query", null, json);
|
| | | JSONObject resultJson = JSONObject.fromObject(result);
|
| | | resultJson = resultJson.optJSONObject("jd_union_open_goods_promotiongoodsinfo_query_response");
|
| | | if (resultJson.optInt("code") == 0) {
|
| | | result = resultJson.optString("result");
|
| | | resultJson = JSONObject.fromObject(result);
|
| | | JSONArray array = resultJson.optJSONArray("data");
|
| | | if (array != null)
|
| | | for (int i = 0; i < array.size(); i++) {
|
| | | JDGoods goods = parseSimpleJDGoods(array.optJSONObject(i));
|
| | | if (goods != null)
|
| | | list.add(goods);
|
| | | }
|
| | | }
|
| | | return list;
|
| | | }
|
| | |
|
| | | // 分类信息
|
| | | Object category = json.get("categoryInfo");
|
| | | JSONObject categoryJson = JSONObject.fromObject(category);
|
| | | JDCategoryInfo categoryInfo = new JDCategoryInfo();
|
| | | categoryInfo.setCid1(categoryJson.optLong("cid1"));
|
| | | categoryInfo.setCid1Name(categoryJson.optString("cid1Name"));
|
| | | categoryInfo.setCid2(categoryJson.optLong("cid2"));
|
| | | categoryInfo.setCid2Name(categoryJson.optString("cid2Name"));
|
| | | categoryInfo.setCid3(categoryJson.optLong("cid3"));
|
| | | categoryInfo.setCid3Name(categoryJson.optString("cid3Name"));
|
| | | goods.setCategoryInfo(categoryInfo);
|
| | | private static JDGoods parseSimpleJDGoods(JSONObject json) {
|
| | | JDGoods goods = new JDGoods();
|
| | | goods.setPrice(StringUtil.isNullOrEmpty(json.optString("wlUnitPrice"))
|
| | | ? new BigDecimal(json.optString("unitPrice")) : new BigDecimal(json.optString("wlUnitPrice")));
|
| | |
|
| | | // 图片信息
|
| | | List<String> imageList = new ArrayList<String>();
|
| | | Object images = json.get("imageInfo");
|
| | | JSONObject imagesJson = JSONObject.fromObject(images);
|
| | | JSONArray imagesArray = imagesJson.optJSONArray("imageList");
|
| | | for (int i = 0; i < imagesArray.size(); i++) {
|
| | | imageList.add(imagesArray.optJSONObject(i).optString("url"));
|
| | | }
|
| | | goods.setImageList(imageList);
|
| | | BigDecimal commisionRatioWl = new BigDecimal(json.optString("commisionRatioWl"));
|
| | | if (commisionRatioWl.compareTo(new BigDecimal(0)) > 0) {
|
| | | JDCommissionInfo commissionInfo = new JDCommissionInfo();
|
| | | commissionInfo.setCommissionShare(new BigDecimal(json.optString("commisionRatioWl")));
|
| | | commissionInfo.setCommission(MoneyBigDecimalUtil
|
| | | .div(goods.getPrice().multiply(commissionInfo.getCommissionShare()), new BigDecimal(100)));
|
| | | goods.setCommissionInfo(commissionInfo);
|
| | | } else {
|
| | | return null;
|
| | | }
|
| | |
|
| | | if (imageList.size() > 0) {
|
| | | goods.setPicUrl(imageList.get(0));
|
| | | }
|
| | | JDCategoryInfo categoryInfo = new JDCategoryInfo();
|
| | | categoryInfo.setCid1(json.optLong("cid1"));
|
| | | categoryInfo.setCid1Name(json.optString("cid1Name"));
|
| | | categoryInfo.setCid2(json.optLong("cid2"));
|
| | | categoryInfo.setCid2Name(json.optString("cid2Name"));
|
| | | categoryInfo.setCid3(json.optLong("cid3"));
|
| | | categoryInfo.setCid3Name(json.optString("cid3Name"));
|
| | |
|
| | | BigDecimal price = new BigDecimal(priceInfoJson.optString("price"));
|
| | | // 拼购信息
|
| | | Object pinGouInfo = json.get("pinGouInfo");
|
| | | if (pinGouInfo != null) {
|
| | | JSONObject pinGouInfoJson = JSONObject.fromObject(pinGouInfo);
|
| | | if (!pinGouInfoJson.isEmpty()) {
|
| | | JDPingouInfo jdPinGouInfo = new JDPingouInfo();
|
| | | price = new BigDecimal(pinGouInfoJson.optString("pingouPrice"));
|
| | | jdPinGouInfo.setPingouPrice(price);
|
| | | jdPinGouInfo.setPingouTmCount(pinGouInfoJson.optLong("pingouTmCount"));
|
| | | jdPinGouInfo.setPingouUrl(pinGouInfoJson.optString("pingouUrl"));
|
| | | jdPinGouInfo.setTotalCount(pinGouInfoJson.optLong("totalCount"));
|
| | | jdPinGouInfo.setPingouEndTime(pinGouInfoJson.optLong("pingouEndTime"));
|
| | | jdPinGouInfo.setPingouStartTime(pinGouInfoJson.optLong("pingouStartTime"));
|
| | | goods.setPinGouInfo(jdPinGouInfo);
|
| | | }
|
| | | }
|
| | | goods.setCategoryInfo(categoryInfo);
|
| | | goods.setComments(null);
|
| | |
|
| | | // 券信息
|
| | | Object coupon = json.get("couponInfo");
|
| | | if (coupon != null) {
|
| | | JSONObject couponJson = JSONObject.fromObject(coupon);
|
| | | JSONArray couponArray = couponJson.optJSONArray("couponList");
|
| | | if (couponArray != null) {
|
| | | List<JDCouponInfo> couponInfoList = new ArrayList<>();
|
| | | for (int i = 0; i < couponArray.size(); i++) {
|
| | | JDCouponInfo couponInfo = parseJDCouponInfo(couponArray.optJSONObject(i));
|
| | | if (couponInfo != null)
|
| | | couponInfoList.add(couponInfo);
|
| | | }
|
| | | String isFreeShipping = json.optString("isFreeShipping");
|
| | | if (!StringUtil.isNullOrEmpty(isFreeShipping)) {
|
| | | goods.setIsFreeShipping(Integer.parseInt(isFreeShipping));
|
| | | }
|
| | | String inOrderCount = json.optString("inOrderCount");
|
| | | if (!StringUtil.isNullOrEmpty(isFreeShipping)) {
|
| | | goods.setInOrderCount30Days(Long.parseLong(inOrderCount));
|
| | | }
|
| | |
|
| | | // 根据消费条件排序
|
| | | Comparator<JDCouponInfo> cm = new Comparator<JDCouponInfo>() {
|
| | | @Override
|
| | | public int compare(JDCouponInfo o1, JDCouponInfo o2) {
|
| | | return o1.getQuota().compareTo(o2.getQuota());
|
| | | }
|
| | | };
|
| | | Collections.sort(couponInfoList, cm);
|
| | | // if (couponInfoList.size() > 0) {
|
| | | // // 设置券信息为最接近的一个
|
| | | // for (int i = couponInfoList.size() - 1; i >= 0; i--) {
|
| | | // if
|
| | | // (couponInfoList.get(i).getQuota().compareTo(goods.getPrice())
|
| | | // <= 0) {
|
| | | // goods.setCouponInfo(couponInfoList.get(i));
|
| | | // break;
|
| | | // }
|
| | | // }
|
| | | // if (goods.getCouponInfo() == null)
|
| | | // goods.setCouponInfo(couponInfoList.get(0));
|
| | | // }
|
| | | //
|
| | | goods.setCouponInfoList(couponInfoList);
|
| | | goods.setGoodCommentsShare(null);
|
| | | List<String> imageList = new ArrayList<>();
|
| | | imageList.add(json.optString("imgUrl"));
|
| | | goods.setPicUrl(json.optString("imgUrl"));
|
| | | goods.setImageList(imageList);
|
| | | goods.setIsHot(null);
|
| | | goods.setMaterialUrl(json.optString("materialUrl"));
|
| | | goods.setOwner(null);
|
| | | goods.setPinGouInfo(null);
|
| | |
|
| | | }
|
| | | }
|
| | | JDShopInfo shopInfo = new JDShopInfo();
|
| | | shopInfo.setShopId(json.optInt("shopId"));
|
| | | shopInfo.setShopName(null);
|
| | | goods.setShopInfo(shopInfo);
|
| | | goods.setSkuId(json.optLong("skuId"));
|
| | | goods.setSkuName(json.optString("goodsName"));
|
| | | goods.setTotalCount(null);
|
| | |
|
| | | return goods;
|
| | | }
|
| | | return goods;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 获取推广商品信息接口
|
| | | * |
| | | * @param skuIdList
|
| | | * @return
|
| | | */
|
| | | public static List<JDGoods> getGoodsDetail(List<Long> skuIdList) {
|
| | | List<JDGoods> list = new ArrayList<>();
|
| | | JSONObject json = new JSONObject();
|
| | | json.put("skuIds", StringUtil.concat(skuIdList, ","));
|
| | | String result = baseRequest2("jd.union.open.goods.promotiongoodsinfo.query", null, json);
|
| | | JSONObject resultJson = JSONObject.fromObject(result);
|
| | | resultJson = resultJson.optJSONObject("jd_union_open_goods_promotiongoodsinfo_query_response");
|
| | | if (resultJson.optInt("code") == 0) {
|
| | | result = resultJson.optString("result");
|
| | | resultJson = JSONObject.fromObject(result);
|
| | | JSONArray array = resultJson.optJSONArray("data");
|
| | | if (array != null)
|
| | | for (int i = 0; i < array.size(); i++) {
|
| | | JDGoods goods = parseSimpleJDGoods(array.optJSONObject(i));
|
| | | if (goods != null)
|
| | | list.add(goods);
|
| | | }
|
| | | }
|
| | | return list;
|
| | | }
|
| | | public static JDSearchResult getJingFenGoods(int pageIndex, int eliteId) {
|
| | | JDSearchResult searchResult = new JDSearchResult();
|
| | | List<JDGoods> list = new ArrayList<>();
|
| | | JSONObject json = new JSONObject();
|
| | | json.put("pageIndex", pageIndex);
|
| | | json.put("pageSize", 20);
|
| | | json.put("sortName", "inOrderCount30DaysSku");
|
| | | json.put("sort", "desc");
|
| | | json.put("eliteId", eliteId);
|
| | |
|
| | | private static JDGoods parseSimpleJDGoods(JSONObject json) {
|
| | | JDGoods goods = new JDGoods();
|
| | | goods.setPrice(StringUtil.isNullOrEmpty(json.optString("wlUnitPrice"))
|
| | | ? new BigDecimal(json.optString("unitPrice")) : new BigDecimal(json.optString("wlUnitPrice")));
|
| | | JSONObject jsonDTO = new JSONObject();
|
| | | jsonDTO.put("goodsReq", json);
|
| | |
|
| | | BigDecimal commisionRatioWl = new BigDecimal(json.optString("commisionRatioWl"));
|
| | | if (commisionRatioWl.compareTo(new BigDecimal(0)) > 0) {
|
| | | JDCommissionInfo commissionInfo = new JDCommissionInfo();
|
| | | commissionInfo.setCommissionShare(new BigDecimal(json.optString("commisionRatioWl")));
|
| | | commissionInfo.setCommission(MoneyBigDecimalUtil
|
| | | .div(goods.getPrice().multiply(commissionInfo.getCommissionShare()), new BigDecimal(100)));
|
| | | goods.setCommissionInfo(commissionInfo);
|
| | | } else {
|
| | | return null;
|
| | | }
|
| | | String result = baseRequest2("jd.union.open.goods.jingfen.query", null, jsonDTO);
|
| | | LogHelper.test(result);
|
| | | System.out.println(result);
|
| | | JSONObject resultJson = JSONObject.fromObject(result);
|
| | | resultJson = resultJson.optJSONObject("jd_union_open_goods_jingfen_query_response");
|
| | | if (resultJson.optInt("code") == 0) {
|
| | | result = resultJson.optString("result");
|
| | | resultJson = JSONObject.fromObject(result);
|
| | | String message = resultJson.optString("message");
|
| | | if ("SUCCESS".equalsIgnoreCase(message)) {
|
| | | JSONArray array = resultJson.optJSONArray("data");
|
| | | if (array != null) {
|
| | | for (int i = 0; i < array.size(); i++) {
|
| | | JDGoods goods = parseJDGoods(array.optJSONObject(i));
|
| | | if (goods != null)
|
| | | list.add(goods);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | JDCategoryInfo categoryInfo = new JDCategoryInfo();
|
| | | categoryInfo.setCid1(json.optLong("cid1"));
|
| | | categoryInfo.setCid1Name(json.optString("cid1Name"));
|
| | | categoryInfo.setCid2(json.optLong("cid2"));
|
| | | categoryInfo.setCid2Name(json.optString("cid2Name"));
|
| | | categoryInfo.setCid3(json.optLong("cid3"));
|
| | | categoryInfo.setCid3Name(json.optString("cid3Name"));
|
| | | long totalCount = resultJson.optLong("totalCount");
|
| | | PageEntity pageEntity = new PageEntity();
|
| | | pageEntity.setTotalCount(totalCount);
|
| | |
|
| | | goods.setCategoryInfo(categoryInfo);
|
| | | goods.setComments(null);
|
| | | searchResult.setPageEntity(pageEntity);
|
| | | }
|
| | | searchResult.setGoodsList(list);
|
| | | return searchResult;
|
| | | }
|
| | |
|
| | | String isFreeShipping = json.optString("isFreeShipping");
|
| | | if (!StringUtil.isNullOrEmpty(isFreeShipping)) {
|
| | | goods.setIsFreeShipping(Integer.parseInt(isFreeShipping));
|
| | | }
|
| | | String inOrderCount = json.optString("inOrderCount");
|
| | | if (!StringUtil.isNullOrEmpty(isFreeShipping)) {
|
| | | goods.setInOrderCount30Days(Long.parseLong(inOrderCount));
|
| | | }
|
| | | public static List<GoodsClass> getGoodsClass(int parentId, int grade) {
|
| | | JDSearchResult searchResult = new JDSearchResult();
|
| | | List<GoodsClass> list = new ArrayList<>();
|
| | | JSONObject json = new JSONObject();
|
| | | json.put("parentId", parentId);
|
| | | json.put("grade", grade);
|
| | |
|
| | | goods.setGoodCommentsShare(null);
|
| | | List<String> imageList = new ArrayList<>();
|
| | | imageList.add(json.optString("imgUrl"));
|
| | | goods.setPicUrl(json.optString("imgUrl"));
|
| | | goods.setImageList(imageList);
|
| | | goods.setIsHot(null);
|
| | | goods.setMaterialUrl(json.optString("materialUrl"));
|
| | | goods.setOwner(null);
|
| | | goods.setPinGouInfo(null);
|
| | | JSONObject jsonDTO = new JSONObject();
|
| | | jsonDTO.put("req", json);
|
| | |
|
| | | JDShopInfo shopInfo = new JDShopInfo();
|
| | | shopInfo.setShopId(json.optInt("shopId"));
|
| | | shopInfo.setShopName(null);
|
| | | goods.setShopInfo(shopInfo);
|
| | | goods.setSkuId(json.optLong("skuId"));
|
| | | goods.setSkuName(json.optString("goodsName"));
|
| | | goods.setTotalCount(null);
|
| | | String result = baseRequest2("jd.union.open.category.goods.get", null, jsonDTO);
|
| | | System.out.println(result);
|
| | | JSONObject resultJson = JSONObject.fromObject(result);
|
| | | resultJson = resultJson.optJSONObject("jd_union_open_category_goods_get_response");
|
| | | if (resultJson.optInt("code") == 0) {
|
| | | result = resultJson.optString("result");
|
| | | resultJson = JSONObject.fromObject(result);
|
| | | String message = resultJson.optString("message");
|
| | | if ("SUCCESS".equalsIgnoreCase(message)) {
|
| | | JSONArray array = resultJson.optJSONArray("data");
|
| | | if (array != null) {
|
| | | for (int i = 0; i < array.size(); i++) {
|
| | | GoodsClass gc = new GoodsClass();
|
| | | JSONObject item = array.optJSONObject(i);
|
| | | gc.setName(item.optString("name"));
|
| | | gc.setId(item.optLong("id"));
|
| | | list.add(gc);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | return goods;
|
| | | }
|
| | | long totalCount = resultJson.optLong("totalCount");
|
| | | PageEntity pageEntity = new PageEntity();
|
| | | pageEntity.setTotalCount(totalCount);
|
| | | searchResult.setPageEntity(pageEntity);
|
| | | }
|
| | | return list;
|
| | | }
|
| | |
|
| | | public static JDSearchResult getJingFenGoods(int pageIndex, int eliteId) {
|
| | | JDSearchResult searchResult = new JDSearchResult();
|
| | | List<JDGoods> list = new ArrayList<>();
|
| | | JSONObject json = new JSONObject();
|
| | | json.put("pageIndex", pageIndex);
|
| | | json.put("pageSize", 20);
|
| | | json.put("sortName", "inOrderCount30DaysSku");
|
| | | json.put("sort", "desc");
|
| | | json.put("eliteId", eliteId);
|
| | | public static JDGoods getGoodsDetail(Long skuId) {
|
| | | List<Long> skuIdList = new ArrayList<>();
|
| | | skuIdList.add(skuId);
|
| | | List<JDGoods> list = getGoodsDetail(skuIdList);
|
| | | if (list != null && list.size() > 0)
|
| | | return list.get(0);
|
| | | return null;
|
| | | }
|
| | |
|
| | | JSONObject jsonDTO = new JSONObject();
|
| | | jsonDTO.put("goodsReq", json);
|
| | | /**
|
| | | * 获取订单列表
|
| | | *
|
| | | * @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", TimeUtil.getGernalTime(time.getTime(), "yyyyMMddHH"));
|
| | |
|
| | | String result = baseRequest2("jd.union.open.goods.jingfen.query", null, jsonDTO);
|
| | | LogHelper.test(result);
|
| | | System.out.println(result);
|
| | | JSONObject resultJson = JSONObject.fromObject(result);
|
| | | resultJson = resultJson.optJSONObject("jd_union_open_goods_jingfen_query_response");
|
| | | if (resultJson.optInt("code") == 0) {
|
| | | result = resultJson.optString("result");
|
| | | resultJson = JSONObject.fromObject(result);
|
| | | String message = resultJson.optString("message");
|
| | | if ("SUCCESS".equalsIgnoreCase(message)) {
|
| | | JSONArray array = resultJson.optJSONArray("data");
|
| | | if (array != null) {
|
| | | for (int i = 0; i < array.size(); i++) {
|
| | | JDGoods goods = parseJDGoods(array.optJSONObject(i));
|
| | | if (goods != null)
|
| | | list.add(goods);
|
| | | }
|
| | | }
|
| | | }
|
| | | json.put("orderReq", orderReq);
|
| | | String result = baseRequest2("jd.union.open.order.query", null, json);
|
| | | System.out.println(result);
|
| | | JSONObject root = JSONObject.fromObject(result).optJSONObject("jd_union_open_order_query_response");
|
| | | if (root.optInt("code") == 0) {
|
| | | boolean hasMore = root.optBoolean("hasMore");
|
| | | root = JSONObject.fromObject(root.optString("result"));
|
| | | if (root.optInt("code") == 200 && root.optJSONArray("data") != null) {
|
| | |
|
| | | long totalCount = resultJson.optLong("totalCount");
|
| | | PageEntity pageEntity = new PageEntity();
|
| | | pageEntity.setTotalCount(totalCount);
|
| | | String date = root.optJSONArray("data").toString();
|
| | | Type typeToken = new TypeToken<List<JDOrder>>() {
|
| | | }.getType();
|
| | | List<JDOrder> orderList = new Gson().fromJson(date, typeToken);
|
| | | if (orderList != null)
|
| | | for (JDOrder order : orderList) {
|
| | | Map<Long, List<JDOrderItem>> map = new HashMap<>();
|
| | | for (int i = 0; i < order.getOrderItemList().size(); i++) {
|
| | | JDOrderItem orderItem = order.getOrderItemList().get(i);
|
| | | if (map.get(orderItem.getSkuId()) == null)
|
| | | map.put(orderItem.getSkuId(), new ArrayList<>());
|
| | | map.get(orderItem.getSkuId()).add(orderItem);
|
| | |
|
| | | searchResult.setPageEntity(pageEntity);
|
| | | }
|
| | | searchResult.setGoodsList(list);
|
| | | return searchResult;
|
| | | }
|
| | | order.getOrderItemList().get(i)
|
| | | .setTradeId(order.getOrderId() + "-" + order.getOrderItemList().get(i).getSkuId());
|
| | | order.getOrderItemList().get(i).setOrderId(order.getOrderId());
|
| | | order.getOrderItemList().get(i).setOrderBy(i + 1);
|
| | | }
|
| | | // 查询商品ID相同的子订单
|
| | | for (Iterator<Long> its = map.keySet().iterator(); its.hasNext(); ) {
|
| | | Long skuId = its.next();
|
| | | if (map.get(skuId).size() > 1) {
|
| | | int skuOrderBy = 1;
|
| | | for (int i = 0; i < order.getOrderItemList().size(); i++) {
|
| | | JDOrderItem orderItem = order.getOrderItemList().get(i);
|
| | | if (orderItem.getSkuId().longValue() == skuId) {
|
| | | order.getOrderItemList().get(i).setTradeId(order.getOrderId() + "-"
|
| | | + order.getOrderItemList().get(i).getSkuId() + "-" + skuOrderBy++);
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | public static List<GoodsClass> getGoodsClass(int parentId, int grade) {
|
| | | JDSearchResult searchResult = new JDSearchResult();
|
| | | List<GoodsClass> list = new ArrayList<>();
|
| | | JSONObject json = new JSONObject();
|
| | | json.put("parentId", parentId);
|
| | | json.put("grade", grade);
|
| | | }
|
| | | return new JDOrderResult(hasMore, orderList);
|
| | | }
|
| | | }
|
| | | return null;
|
| | | }
|
| | |
|
| | | 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);
|
| | | resultJson = resultJson.optJSONObject("jd_union_open_category_goods_get_response");
|
| | | if (resultJson.optInt("code") == 0) {
|
| | | result = resultJson.optString("result");
|
| | | resultJson = JSONObject.fromObject(result);
|
| | | String message = resultJson.optString("message");
|
| | | if ("SUCCESS".equalsIgnoreCase(message)) {
|
| | | JSONArray array = resultJson.optJSONArray("data");
|
| | | if (array != null) {
|
| | | for (int i = 0; i < array.size(); i++) {
|
| | | GoodsClass gc = new GoodsClass();
|
| | | JSONObject item = array.optJSONObject(i);
|
| | | gc.setName(item.optString("name"));
|
| | | gc.setId(item.optLong("id"));
|
| | | list.add(gc);
|
| | | }
|
| | | }
|
| | | }
|
| | | public static String createLiJin(String sku) {
|
| | | JSONObject json = new JSONObject();
|
| | | JSONObject couponReq = new JSONObject();
|
| | | couponReq.put("skuMaterialId", sku);
|
| | | couponReq.put("discount", 10);
|
| | | couponReq.put("amount", 5);
|
| | | couponReq.put("receiveStartTime", TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy-MM-dd HH"));
|
| | | couponReq.put("receiveEndTime", TimeUtil.getGernalTime(System.currentTimeMillis() + 1000 * 60 * 2, "yyyy-MM-dd HH"));
|
| | | couponReq.put("isSpu", 0);
|
| | | couponReq.put("expireType", 2);
|
| | | couponReq.put("useStartTime", TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy-MM-dd"));
|
| | | couponReq.put("useEndTime", TimeUtil.getGernalTime(System.currentTimeMillis() + 1000 * 60 * 60L * 24, "yyyy-MM-dd"));
|
| | | couponReq.put("share", 1);
|
| | | couponReq.put("contentMatch", 0);
|
| | |
|
| | | long totalCount = resultJson.optLong("totalCount");
|
| | | PageEntity pageEntity = new PageEntity();
|
| | | pageEntity.setTotalCount(totalCount);
|
| | | searchResult.setPageEntity(pageEntity);
|
| | | }
|
| | | return list;
|
| | | }
|
| | | json.put("couponReq", couponReq);
|
| | | String result = baseRequest2("jd.union.open.coupon.gift.get", null, json);
|
| | | System.out.println(result);
|
| | | JSONObject root = JSONObject.fromObject(result).optJSONObject("jd_union_open_coupon_gift_get_response");
|
| | | if (root.optInt("code") == 0) {
|
| | | boolean hasMore = root.optBoolean("hasMore");
|
| | | root = JSONObject.fromObject(root.optString("result"));
|
| | | if (root.optInt("code") == 200 && root.optJSONObject("data") != null) {
|
| | | JSONObject data = root.optJSONObject("data");
|
| | | String giftCouponKey = data.optString("giftCouponKey");
|
| | | return giftCouponKey;
|
| | | }
|
| | | }
|
| | | return null;
|
| | | }
|
| | |
|
| | | public static JDGoods getGoodsDetail(Long skuId) {
|
| | | List<Long> skuIdList = new ArrayList<>();
|
| | | skuIdList.add(skuId);
|
| | | List<JDGoods> list = getGoodsDetail(skuIdList);
|
| | | if (list != null && list.size() > 0)
|
| | | return list.get(0);
|
| | | return null;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 获取订单列表
|
| | | * |
| | | * @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", TimeUtil.getGernalTime(time.getTime(), "yyyyMMddHH"));
|
| | | public static void toolConvert() {
|
| | | JSONObject json = new JSONObject();
|
| | | JSONObject couponReq = new JSONObject();
|
| | | couponReq.put("materialId", "https://item.jd.com/71751967284.html");
|
| | | couponReq.put("unionId", "2011217145");
|
| | | // couponReq.put("pid", "2011217145_4100059717_3003005722");
|
| | | couponReq.put("subUnionId", "123_437032");
|
| | | couponReq.put("giftCouponKey","123123123123");
|
| | | json.put("promotionCodeReq", couponReq);
|
| | | String result = baseRequest2("jd.union.open.promotion.byunionid.get", null, json);
|
| | | System.out.println(result);
|
| | | }
|
| | |
|
| | | json.put("orderReq", orderReq);
|
| | | String result = baseRequest2("jd.union.open.order.query", null, json);
|
| | | System.out.println(result);
|
| | | JSONObject root = JSONObject.fromObject(result).optJSONObject("jd_union_open_order_query_response");
|
| | | if (root.optInt("code") == 0) {
|
| | | boolean hasMore = root.optBoolean("hasMore");
|
| | | root = JSONObject.fromObject(root.optString("result"));
|
| | | if (root.optInt("code") == 200 && root.optJSONArray("data") != null) {
|
| | | public static void toolOrder() {
|
| | | JSONObject json = new JSONObject();
|
| | | JSONObject couponReq = new JSONObject();
|
| | | couponReq.put("pageIndex", 1);
|
| | | couponReq.put("pageSize", 20);
|
| | | couponReq.put("type", 3);
|
| | | couponReq.put("startTime", "2020-10-31 16:00:00");
|
| | | couponReq.put("endTime", "2020-10-31 16:55:00");
|
| | | // couponReq.put("key", "026eea846250e0dcbcacd750faf07de0");
|
| | |
|
| | | String date = root.optJSONArray("data").toString();
|
| | | Type typeToken = new TypeToken<List<JDOrder>>() {
|
| | | }.getType();
|
| | | List<JDOrder> orderList = new Gson().fromJson(date, typeToken);
|
| | | if (orderList != null)
|
| | | for (JDOrder order : orderList) {
|
| | | Map<Long, List<JDOrderItem>> map = new HashMap<>();
|
| | | for (int i = 0; i < order.getOrderItemList().size(); i++) {
|
| | | JDOrderItem orderItem = order.getOrderItemList().get(i);
|
| | | if (map.get(orderItem.getSkuId()) == null)
|
| | | map.put(orderItem.getSkuId(), new ArrayList<>());
|
| | | map.get(orderItem.getSkuId()).add(orderItem);
|
| | |
|
| | | order.getOrderItemList().get(i)
|
| | | .setTradeId(order.getOrderId() + "-" + order.getOrderItemList().get(i).getSkuId());
|
| | | order.getOrderItemList().get(i).setOrderId(order.getOrderId());
|
| | | order.getOrderItemList().get(i).setOrderBy(i + 1);
|
| | | }
|
| | | // 查询商品ID相同的子订单
|
| | | for (Iterator<Long> its = map.keySet().iterator(); its.hasNext();) {
|
| | | Long skuId = its.next();
|
| | | if (map.get(skuId).size() > 1) {
|
| | | int skuOrderBy = 1;
|
| | | for (int i = 0; i < order.getOrderItemList().size(); i++) {
|
| | | JDOrderItem orderItem = order.getOrderItemList().get(i);
|
| | | if (orderItem.getSkuId().longValue() == skuId) {
|
| | | order.getOrderItemList().get(i).setTradeId(order.getOrderId() + "-"
|
| | | + order.getOrderItemList().get(i).getSkuId() + "-" + skuOrderBy++);
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | // couponReq.put("pid", "2011217145_4100059717_3003005722");
|
| | | couponReq.put("childUnionId", "2011217145");
|
| | | json.put("orderReq", couponReq);
|
| | | String result = baseRequest2("jd.union.open.order.row.query", null, json);
|
| | | System.out.println(result);
|
| | | }
|
| | |
|
| | | }
|
| | | return new JDOrderResult(hasMore, orderList);
|
| | | }
|
| | | }
|
| | | return null;
|
| | | }
|
| | |
|
| | | public static void test() {
|
| | | JSONObject json = new JSONObject();
|
| | | json.put("materialId", "https://item.jd.com/32376790478.html");
|
| | | json.put("ext1", "437032");
|
| | | JSONObject root = new JSONObject();
|
| | | root.put("promotionCodeReq", json);
|
| | | String result = baseRequest2("jd.union.open.promotion.bysubunionid.get", null, root);
|
| | | System.out.println(result);
|
| | | }
|
| | | public static void test() {
|
| | | JSONObject json = new JSONObject();
|
| | | json.put("materialId", "https://item.jd.com/32376790478.html");
|
| | | json.put("ext1", "437032");
|
| | | JSONObject root = new JSONObject();
|
| | | root.put("promotionCodeReq", json);
|
| | | String result = baseRequest2("jd.union.open.promotion.bysubunionid.get", null, root);
|
| | | System.out.println(result);
|
| | | }
|
| | |
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.util.rocketmq.consumer.user; |
| | | |
| | | import com.aliyun.openservices.ons.api.Action; |
| | | import com.aliyun.openservices.ons.api.ConsumeContext; |
| | | import com.aliyun.openservices.ons.api.Message; |
| | | import com.aliyun.openservices.ons.api.MessageListener; |
| | | import com.google.gson.Gson; |
| | | import com.yeshi.fanli.dto.mq.order.OrderTopicTagEnum; |
| | | import com.yeshi.fanli.dto.mq.order.body.OrderConfirmMQMsg; |
| | | import com.yeshi.fanli.dto.mq.order.body.OrderMoneyRecievedMQMsg; |
| | | import com.yeshi.fanli.dto.mq.user.UserTopicTagEnum; |
| | | import com.yeshi.fanli.dto.mq.user.body.UserLevelChangedMQMsg; |
| | | import com.yeshi.fanli.dto.mq.user.body.UserMoneyChangeMQMsg; |
| | | import com.yeshi.fanli.entity.SystemEnum; |
| | | import com.yeshi.fanli.entity.SystemFunction; |
| | | import com.yeshi.fanli.entity.bus.user.UserActiveLog; |
| | | import com.yeshi.fanli.entity.bus.user.UserInfo; |
| | | import com.yeshi.fanli.log.LogHelper; |
| | | import com.yeshi.fanli.service.inter.money.UserMoneyDebtService; |
| | | import com.yeshi.fanli.service.inter.user.UserActiveLogService; |
| | | import com.yeshi.fanli.service.inter.user.UserInfoService; |
| | | import com.yeshi.fanli.service.inter.user.invite.ThreeSaleSerivce; |
| | | import com.yeshi.fanli.service.inter.user.invite.UserInviteValidNumService; |
| | | import com.yeshi.fanli.service.inter.user.vip.TeamUserLevelStatisticService; |
| | | import com.yeshi.fanli.service.inter.user.vip.UserVIPPreInfoService; |
| | | import com.yeshi.fanli.util.Constant; |
| | | import com.yeshi.fanli.util.SystemInfoUtil; |
| | | import com.yeshi.fanli.util.VersionUtil; |
| | | import com.yeshi.fanli.util.rocketmq.MQTopicName; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | /** |
| | | * 用户超级会员 |
| | | * |
| | | * @author Administrator |
| | | */ |
| | | @Component |
| | | public class UserMoneyDebtMessageListener implements MessageListener { |
| | | @Resource |
| | | private UserMoneyDebtService userMoneyDebtService; |
| | | |
| | | |
| | | @Override |
| | | public Action consume(Message message, ConsumeContext context) { |
| | | |
| | | LogHelper.mqInfo("consumer-UserMoneyMessageListener", message.getMsgID(), message.getTopic(), message.getTag(), |
| | | new String(message.getBody())); |
| | | String tag = message.getTag(); |
| | | if (tag == null) |
| | | tag = ""; |
| | | |
| | | // 资金偿还 |
| | | if (MQTopicName.TOPIC_USER.name().equalsIgnoreCase(message.getTopic())) { |
| | | if (tag.equalsIgnoreCase(UserTopicTagEnum.userMoneyAdd.name())) {//用户资金增加 |
| | | UserMoneyChangeMQMsg msg = new Gson().fromJson(new String(message.getBody()), |
| | | UserMoneyChangeMQMsg.class); |
| | | userMoneyDebtService.repayDebt(msg.getUid()); |
| | | return Action.CommitMessage; |
| | | } |
| | | } |
| | | return Action.CommitMessage; |
| | | } |
| | | } |
| | |
| | | package com.yeshi.fanli.util.taobao;
|
| | |
|
| | | import java.io.Serializable;
|
| | | import java.math.BigDecimal;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Date;
|
| | |
| | | import com.yeshi.fanli.dto.order.OrderQuery;
|
| | | import com.yeshi.fanli.dto.taobao.TaoBaoOrderResultDTO;
|
| | | import com.yeshi.fanli.dto.taobao.WeiQuanOrderResult;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoOrder;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoOrderGoods;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoPunishOrder;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoWeiQuanOrder;
|
| | | import com.yeshi.fanli.entity.taobao.*;
|
| | | import com.yeshi.common.entity.taobao.TaoKeAppInfo;
|
| | | import com.yeshi.fanli.exception.taobao.TaoKeApiException;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | |
| | | //淘宝客API接口
|
| | | public class TaoKeOrderApiUtil {
|
| | |
|
| | | public static int TK_STATUS_ALL = 1;
|
| | | public static int TK_STATUS_SETTLEMENT = 3;
|
| | | public static int TK_STATUS_PAY = 12;
|
| | | public static int TK_STATUS_SUCCESS = 14;
|
| | | public static int TK_STATUS_INVALID = 13;
|
| | | public static int TK_STATUS_ALL = 1;
|
| | | public static int TK_STATUS_SETTLEMENT = 3;
|
| | | public static int TK_STATUS_PAY = 12;
|
| | | public static int TK_STATUS_SUCCESS = 14;
|
| | | public static int TK_STATUS_INVALID = 13;
|
| | |
|
| | | private static TaoBaoPunishOrder parsePunishOrder(JSONObject data) {
|
| | | TaoBaoPunishOrder order = new TaoBaoPunishOrder();
|
| | | order.setPunishStatus(data.optString("punish_status"));
|
| | | order.setRelationId(data.optString("relation_id"));
|
| | | order.setSettleMonth(data.optString("settle_month"));
|
| | | order.setSpecialId(data.optString("special_id"));
|
| | | order.setTbTradeId(data.optString("tb_trade_id"));
|
| | | order.setTbTradeParentId(data.optString("tb_trade_parent_id"));
|
| | | order.setTkAdzoneId(data.optString("tk_adzone_id"));
|
| | | order.setTkPubId(data.optString("tk_pub_id"));
|
| | | order.setTkSiteId(data.optString("tk_site_id"));
|
| | | order.setTkTradeCreateTime(data.optString("tk_trade_create_time"));
|
| | | order.setViolationType(data.optString("violation_type"));
|
| | | return order;
|
| | | }
|
| | | private static TaoBaoPunishOrder parsePunishOrder(JSONObject data) {
|
| | | TaoBaoPunishOrder order = new TaoBaoPunishOrder();
|
| | | order.setPunishStatus(data.optString("punish_status"));
|
| | | order.setRelationId(data.optString("relation_id"));
|
| | | order.setSettleMonth(data.optString("settle_month"));
|
| | | order.setSpecialId(data.optString("special_id"));
|
| | | order.setTbTradeId(data.optString("tb_trade_id"));
|
| | | order.setTbTradeParentId(data.optString("tb_trade_parent_id"));
|
| | | order.setTkAdzoneId(data.optString("tk_adzone_id"));
|
| | | order.setTkPubId(data.optString("tk_pub_id"));
|
| | | order.setTkSiteId(data.optString("tk_site_id"));
|
| | | order.setTkTradeCreateTime(data.optString("tk_trade_create_time"));
|
| | | order.setViolationType(data.optString("violation_type"));
|
| | | return order;
|
| | | }
|
| | |
|
| | | public static List<TaoBaoPunishOrder> getPunishOrderList(Long startTime, Long endTime) {
|
| | | List<TaoBaoPunishOrder> resultList = new ArrayList<>();
|
| | | TaoKeAppInfo app = new TaoKeAppInfo();
|
| | | app.setAppKey(TaoBaoConstant.TAOBAO_AUTH_APPKEY);
|
| | | app.setAppSecret(TaoBaoConstant.TAOBAO_AUTH_APPSECRET);
|
| | | Map<String, String> map = new HashMap<>();
|
| | | map.put("method", "taobao.tbk.dg.punish.order.get");
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("page_no", 1);
|
| | | data.put("page_size", 100);
|
| | | int sub = (int) ((endTime - startTime) / 1000);
|
| | | int span = 1800;
|
| | | int count = sub % span == 0 ? sub / span : sub / span + 1;
|
| | | for (int i = 0; i < count; i++) {
|
| | | int totalSpanOrderCount = 0;
|
| | | List<TaoBaoPunishOrder> spanOrderList = new ArrayList<>();
|
| | | long startT = startTime + i * span * 1000;
|
| | | data.put("start_time", TimeUtil.getGernalTime(startT, "yyyy-MM-dd HH:mm:ss"));
|
| | | data.put("span", 1800 + "");
|
| | | map.put("af_order_option", data.toString());
|
| | | try {
|
| | | JSONObject json = TaoKeBaseUtil.baseRequest(map, app);
|
| | | JSONObject dataJson = json.optJSONObject("tbk_dg_punish_order_get_response").optJSONObject("result")
|
| | | .optJSONObject("data");
|
| | | JSONArray array = dataJson.optJSONObject("results").optJSONArray("result");
|
| | | if (array != null)
|
| | | for (int n = 0; n < array.size(); n++) {
|
| | | spanOrderList.add(parsePunishOrder(array.optJSONObject(n)));
|
| | | }
|
| | | totalSpanOrderCount = dataJson.optInt("total_count");
|
| | | int page = 2;
|
| | | while (totalSpanOrderCount > spanOrderList.size())// 存在下一页
|
| | | {
|
| | | data.put("page_no", page++);
|
| | | map.put("af_order_option", data.toString());
|
| | | json = TaoKeBaseUtil.baseRequest(map, app);
|
| | | dataJson = json.optJSONObject("tbk_dg_punish_order_get_response").optJSONObject("data");
|
| | | array = dataJson.optJSONArray("results");
|
| | | if (array != null)
|
| | | for (int n = 0; n < array.size(); n++) {
|
| | | spanOrderList.add(parsePunishOrder(array.optJSONObject(n)));
|
| | | }
|
| | | totalSpanOrderCount = dataJson.optInt("total_count");
|
| | | }
|
| | | resultList.addAll(spanOrderList);
|
| | | System.out.println(json);
|
| | | } catch (TaoKeApiException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | return resultList;
|
| | | }
|
| | | public static List<TaoBaoPunishOrder> getPunishOrderList(Long startTime, Long endTime) {
|
| | | List<TaoBaoPunishOrder> resultList = new ArrayList<>();
|
| | | TaoKeAppInfo app = new TaoKeAppInfo();
|
| | | app.setAppKey(TaoBaoConstant.TAOBAO_AUTH_APPKEY);
|
| | | app.setAppSecret(TaoBaoConstant.TAOBAO_AUTH_APPSECRET);
|
| | | Map<String, String> map = new HashMap<>();
|
| | | map.put("method", "taobao.tbk.dg.punish.order.get");
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("page_no", 1);
|
| | | data.put("page_size", 100);
|
| | | int sub = (int) ((endTime - startTime) / 1000);
|
| | | int span = 1800;
|
| | | int count = sub % span == 0 ? sub / span : sub / span + 1;
|
| | | for (int i = 0; i < count; i++) {
|
| | | int totalSpanOrderCount = 0;
|
| | | List<TaoBaoPunishOrder> spanOrderList = new ArrayList<>();
|
| | | long startT = startTime + i * span * 1000;
|
| | | data.put("start_time", TimeUtil.getGernalTime(startT, "yyyy-MM-dd HH:mm:ss"));
|
| | | data.put("span", 1800 + "");
|
| | | map.put("af_order_option", data.toString());
|
| | | try {
|
| | | JSONObject json = TaoKeBaseUtil.baseRequest(map, app);
|
| | | JSONObject dataJson = json.optJSONObject("tbk_dg_punish_order_get_response").optJSONObject("result")
|
| | | .optJSONObject("data");
|
| | | JSONArray array = dataJson.optJSONObject("results").optJSONArray("result");
|
| | | if (array != null)
|
| | | for (int n = 0; n < array.size(); n++) {
|
| | | spanOrderList.add(parsePunishOrder(array.optJSONObject(n)));
|
| | | }
|
| | | totalSpanOrderCount = dataJson.optInt("total_count");
|
| | | int page = 2;
|
| | | while (totalSpanOrderCount > spanOrderList.size())// 存在下一页
|
| | | {
|
| | | data.put("page_no", page++);
|
| | | map.put("af_order_option", data.toString());
|
| | | json = TaoKeBaseUtil.baseRequest(map, app);
|
| | | dataJson = json.optJSONObject("tbk_dg_punish_order_get_response").optJSONObject("data");
|
| | | array = dataJson.optJSONArray("results");
|
| | | if (array != null)
|
| | | for (int n = 0; n < array.size(); n++) {
|
| | | spanOrderList.add(parsePunishOrder(array.optJSONObject(n)));
|
| | | }
|
| | | totalSpanOrderCount = dataJson.optInt("total_count");
|
| | | }
|
| | | resultList.addAll(spanOrderList);
|
| | | System.out.println(json);
|
| | | } catch (TaoKeApiException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | return resultList;
|
| | | }
|
| | |
|
| | | private static TaoBaoOrderResultDTO parseTaoBaoOrderNew(String response) {
|
| | | private static TaoBaoOrderResultDTO parseTaoBaoOrderNew(String response) {
|
| | |
|
| | | TaoBaoOrderResultDTO dto = new TaoBaoOrderResultDTO(false, false, null, new ArrayList<>());
|
| | | TaoBaoOrderResultDTO dto = new TaoBaoOrderResultDTO(false, false, null, new ArrayList<>());
|
| | |
|
| | | List<TaoBaoOrder> orderList = new ArrayList<>();
|
| | | JSONArray array = null;
|
| | | JSONObject data = JSONObject.fromObject(response);
|
| | | try {
|
| | | JSONObject rootData = data.optJSONObject("tbk_order_details_get_response").optJSONObject("data");
|
| | | array = rootData.optJSONObject("results").optJSONArray("publisher_order_dto");
|
| | | dto.setHasPre(rootData.optBoolean("has_pre"));
|
| | | dto.setPositionIndex(rootData.optString("position_index"));
|
| | | dto.setHasNext(rootData.optBoolean("has_next"));
|
| | | } catch (Exception e) {
|
| | | return dto;
|
| | | }
|
| | | List<Serializable> orderList = new ArrayList<>();
|
| | | JSONArray array = null;
|
| | | JSONObject data = JSONObject.fromObject(response);
|
| | | try {
|
| | | JSONObject rootData = data.optJSONObject("tbk_order_details_get_response").optJSONObject("data");
|
| | | array = rootData.optJSONObject("results").optJSONArray("publisher_order_dto");
|
| | | dto.setHasPre(rootData.optBoolean("has_pre"));
|
| | | dto.setPositionIndex(rootData.optString("position_index"));
|
| | | dto.setHasNext(rootData.optBoolean("has_next"));
|
| | | } catch (Exception e) {
|
| | | return dto;
|
| | | }
|
| | |
|
| | | if (array != null)
|
| | | for (int i = 0; i < array.size(); i++) {
|
| | | if (array != null)
|
| | | for (int i = 0; i < array.size(); i++) {
|
| | |
|
| | | JSONObject item = array.optJSONObject(i);
|
| | | try {
|
| | | TaoBaoOrder taoBaoOrder = new TaoBaoOrder();
|
| | | taoBaoOrder.setAdPositionId(item.optString("adzone_id"));
|
| | | taoBaoOrder.setAdPositionName(item.optString("adzone_name"));
|
| | | taoBaoOrder.setAuctionId(item.optLong("item_id"));
|
| | | taoBaoOrder.setClassName(item.optString("item_category_name"));
|
| | | taoBaoOrder.setClickTime(item.optString("click_time"));
|
| | | taoBaoOrder.setPayTime(item.optString("tb_paid_time"));
|
| | | taoBaoOrder.setCount(item.optInt("item_num"));
|
| | | taoBaoOrder.setCreateTime(item.optString("tk_create_time"));
|
| | | if (!StringUtil.isNullOrEmpty(item.optString("total_commission_fee")))
|
| | | taoBaoOrder.seteIncome(new BigDecimal(item.optString("total_commission_fee")));
|
| | | else
|
| | | taoBaoOrder.seteIncome(new BigDecimal(0));
|
| | | JSONObject item = array.optJSONObject(i);
|
| | | try {
|
| | | TaoBaoOrder taoBaoOrder = new TaoBaoOrder();
|
| | | taoBaoOrder.setAdPositionId(item.optString("adzone_id"));
|
| | | taoBaoOrder.setAdPositionName(item.optString("adzone_name"));
|
| | | taoBaoOrder.setAuctionId(item.optLong("item_id"));
|
| | | taoBaoOrder.setClassName(item.optString("item_category_name"));
|
| | | taoBaoOrder.setClickTime(item.optString("click_time"));
|
| | | taoBaoOrder.setPayTime(item.optString("tb_paid_time"));
|
| | | taoBaoOrder.setCount(item.optInt("item_num"));
|
| | | taoBaoOrder.setCreateTime(item.optString("tk_create_time"));
|
| | | if (!StringUtil.isNullOrEmpty(item.optString("total_commission_fee")))
|
| | | taoBaoOrder.seteIncome(new BigDecimal(item.optString("total_commission_fee")));
|
| | | else
|
| | | taoBaoOrder.seteIncome(new BigDecimal(0));
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(item.optString("pub_share_pre_fee")))
|
| | | taoBaoOrder.setEstimate(new BigDecimal(item.optString("pub_share_pre_fee")));
|
| | | else
|
| | | taoBaoOrder.setEstimate(new BigDecimal(0));
|
| | | taoBaoOrder.setiRatio(new BigDecimal(item.optString("income_rate")));
|
| | | taoBaoOrder.setLatestUpdateTime(null);
|
| | | taoBaoOrder.setManagerWangWang(null);
|
| | | taoBaoOrder.setOrderBy(null);
|
| | | taoBaoOrder.setOrderId(item.optString("trade_parent_id"));
|
| | | if (item.optInt("tk_status") == 12)
|
| | | taoBaoOrder.setOrderState("订单付款");
|
| | | else if (item.optInt("tk_status") == 3)
|
| | | taoBaoOrder.setOrderState("订单结算");
|
| | | else if (item.optInt("tk_status") == 13)
|
| | | taoBaoOrder.setOrderState("订单失效");
|
| | | else if (item.optInt("tk_status") == 14)
|
| | | taoBaoOrder.setOrderState("订单成功");
|
| | | if (!StringUtil.isNullOrEmpty(item.optString("pub_share_pre_fee")))
|
| | | taoBaoOrder.setEstimate(new BigDecimal(item.optString("pub_share_pre_fee")));
|
| | | else
|
| | | taoBaoOrder.setEstimate(new BigDecimal(0));
|
| | | taoBaoOrder.setiRatio(new BigDecimal(item.optString("income_rate")));
|
| | | taoBaoOrder.setLatestUpdateTime(null);
|
| | | taoBaoOrder.setManagerWangWang(null);
|
| | | taoBaoOrder.setOrderBy(null);
|
| | | taoBaoOrder.setOrderId(item.optString("trade_parent_id"));
|
| | | if (item.optInt("tk_status") == 12)
|
| | | taoBaoOrder.setOrderState("订单付款");
|
| | | else if (item.optInt("tk_status") == 3)
|
| | | taoBaoOrder.setOrderState("订单结算");
|
| | | else if (item.optInt("tk_status") == 13)
|
| | | taoBaoOrder.setOrderState("订单失效");
|
| | | else if (item.optInt("tk_status") == 14)
|
| | | taoBaoOrder.setOrderState("订单成功");
|
| | |
|
| | | taoBaoOrder.setOrderType(item.optString("order_type"));
|
| | | if (!StringUtil.isNullOrEmpty(item.optString("alipay_total_price")))
|
| | | taoBaoOrder.setPayment(new BigDecimal(item.optString("alipay_total_price")));
|
| | | else
|
| | | taoBaoOrder.setPayment(new BigDecimal(0));
|
| | | if (StringUtil.isNullOrEmpty(item.optString("item_price")))
|
| | | taoBaoOrder.setPrice(new BigDecimal(0));
|
| | | else
|
| | | taoBaoOrder.setPrice(new BigDecimal(item.optString("item_price")));
|
| | | if (!StringUtil.isNullOrEmpty(item.optString("pay_price")))
|
| | | taoBaoOrder.setSettlement(new BigDecimal(item.optString("pay_price")));
|
| | | else
|
| | | taoBaoOrder.setSettlement(taoBaoOrder.getPayment());
|
| | | taoBaoOrder.setSettlementTime(item.optString("tk_earning_time"));
|
| | | taoBaoOrder.setShop(item.optString("seller_shop_title"));
|
| | | taoBaoOrder.setSourceMediaId(item.optString("site_id"));
|
| | | taoBaoOrder.setSourceMediaName(item.optString("site_name"));
|
| | | taoBaoOrder.setsRatio(null);
|
| | | if (!StringUtil.isNullOrEmpty(item.optString("subsidy_fee")))// 补贴金额
|
| | | taoBaoOrder.setSubsidy(new BigDecimal(item.optString("subsidy_fee")));
|
| | | if (!StringUtil.isNullOrEmpty(item.optString("subsidy_rate")))
|
| | | taoBaoOrder.setSubsidyRatio(new BigDecimal(item.optString("subsidy_rate")));
|
| | | taoBaoOrder.setSubsidyType(item.optString("subsidy_type"));
|
| | | taoBaoOrder.setTechnologySupportPercent(null);
|
| | | taoBaoOrder.setThirdService(null);
|
| | | taoBaoOrder.setTitle(item.optString("item_title"));
|
| | | if (!StringUtil.isNullOrEmpty(item.optString("total_commission_fee")))
|
| | | taoBaoOrder.setTkMoney(new BigDecimal(item.optString("total_commission_fee")));
|
| | | else
|
| | | taoBaoOrder.setTkMoney(new BigDecimal(0));
|
| | | if (!StringUtil.isNullOrEmpty(item.optString("commission_rate")))
|
| | | taoBaoOrder.setTkRate(new BigDecimal(item.optString("commission_rate")));
|
| | | else if (!StringUtil.isNullOrEmpty(item.optString("total_commission_rate")))
|
| | | taoBaoOrder.setTkRate(new BigDecimal(item.optString("total_commission_rate")));
|
| | | taoBaoOrder.setTransactionPlatform(item.optString("terminal_type"));
|
| | | taoBaoOrder.setRelationId(item.optString("relation_id"));
|
| | | taoBaoOrder.setSpecialId(item.optString("special_id"));
|
| | | taoBaoOrder.setTradeId(item.optString("trade_id"));
|
| | | // 解析商品信息
|
| | | TaoBaoOrderGoods goods = new TaoBaoOrderGoods();
|
| | | goods.setCategoryName(item.optString("item_category_name"));
|
| | | goods.setCreateTime(new Date());
|
| | | goods.setGoodsId(item.optLong("item_id"));
|
| | | goods.setImg(item.optString("item_img"));
|
| | | goods.setLink(item.optString("item_link"));
|
| | | goods.setPrice(item.optString("item_price"));
|
| | | goods.setTitle(item.optString("item_title"));
|
| | | goods.setTradeId(item.optString("trade_id"));
|
| | | if (goods.getImg() != null && !goods.getImg().startsWith("http")) {
|
| | | goods.setImg("http:" + goods.getImg());
|
| | | }
|
| | | taoBaoOrder.setOrderType(item.optString("order_type"));
|
| | | if (!StringUtil.isNullOrEmpty(item.optString("alipay_total_price")))
|
| | | taoBaoOrder.setPayment(new BigDecimal(item.optString("alipay_total_price")));
|
| | | else
|
| | | taoBaoOrder.setPayment(new BigDecimal(0));
|
| | | if (StringUtil.isNullOrEmpty(item.optString("item_price")))
|
| | | taoBaoOrder.setPrice(new BigDecimal(0));
|
| | | else
|
| | | taoBaoOrder.setPrice(new BigDecimal(item.optString("item_price")));
|
| | | if (!StringUtil.isNullOrEmpty(item.optString("pay_price")))
|
| | | taoBaoOrder.setSettlement(new BigDecimal(item.optString("pay_price")));
|
| | | else
|
| | | taoBaoOrder.setSettlement(taoBaoOrder.getPayment());
|
| | | taoBaoOrder.setSettlementTime(item.optString("tk_earning_time"));
|
| | | taoBaoOrder.setShop(item.optString("seller_shop_title"));
|
| | | taoBaoOrder.setSourceMediaId(item.optString("site_id"));
|
| | | taoBaoOrder.setSourceMediaName(item.optString("site_name"));
|
| | | taoBaoOrder.setsRatio(null);
|
| | | if (!StringUtil.isNullOrEmpty(item.optString("subsidy_fee")))// 补贴金额
|
| | | taoBaoOrder.setSubsidy(new BigDecimal(item.optString("subsidy_fee")));
|
| | | if (!StringUtil.isNullOrEmpty(item.optString("subsidy_rate")))
|
| | | taoBaoOrder.setSubsidyRatio(new BigDecimal(item.optString("subsidy_rate")));
|
| | | taoBaoOrder.setSubsidyType(item.optString("subsidy_type"));
|
| | | taoBaoOrder.setTechnologySupportPercent(null);
|
| | | taoBaoOrder.setThirdService(null);
|
| | | taoBaoOrder.setTitle(item.optString("item_title"));
|
| | | if (!StringUtil.isNullOrEmpty(item.optString("total_commission_fee")))
|
| | | taoBaoOrder.setTkMoney(new BigDecimal(item.optString("total_commission_fee")));
|
| | | else
|
| | | taoBaoOrder.setTkMoney(new BigDecimal(0));
|
| | | if (!StringUtil.isNullOrEmpty(item.optString("commission_rate")))
|
| | | taoBaoOrder.setTkRate(new BigDecimal(item.optString("commission_rate")));
|
| | | else if (!StringUtil.isNullOrEmpty(item.optString("total_commission_rate")))
|
| | | taoBaoOrder.setTkRate(new BigDecimal(item.optString("total_commission_rate")));
|
| | | taoBaoOrder.setTransactionPlatform(item.optString("terminal_type"));
|
| | | taoBaoOrder.setRelationId(item.optString("relation_id"));
|
| | | taoBaoOrder.setSpecialId(item.optString("special_id"));
|
| | | taoBaoOrder.setTradeId(item.optString("trade_id"));
|
| | | // 解析商品信息
|
| | | TaoBaoOrderGoods goods = new TaoBaoOrderGoods();
|
| | | goods.setCategoryName(item.optString("item_category_name"));
|
| | | goods.setCreateTime(new Date());
|
| | | goods.setGoodsId(item.optLong("item_id"));
|
| | | goods.setImg(item.optString("item_img"));
|
| | | goods.setLink(item.optString("item_link"));
|
| | | goods.setPrice(item.optString("item_price"));
|
| | | goods.setTitle(item.optString("item_title"));
|
| | | goods.setTradeId(item.optString("trade_id"));
|
| | | if (goods.getImg() != null && !goods.getImg().startsWith("http")) {
|
| | | goods.setImg("http:" + goods.getImg());
|
| | | }
|
| | |
|
| | | taoBaoOrder.setGoods(goods);
|
| | | orderList.add(taoBaoOrder);
|
| | | } catch (Exception e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e, "订单号信息:" + item.toString(), "订单解析出错");
|
| | | } catch (Exception e1) {
|
| | | }
|
| | | }
|
| | | }
|
| | | dto.setOrderList(orderList);
|
| | | return dto;
|
| | | }
|
| | |
|
| | | public static WeiQuanOrderResult getTaoBaoRelationWeiQuanOrderList(Date startTime, int searchType, int page,
|
| | | boolean third) {
|
| | |
|
| | | return getRelationAndSpecialWeiQuanOrderList(startTime, searchType, page, third, 1);
|
| | | }
|
| | |
|
| | | public static WeiQuanOrderResult getTaoBaoSpecialWeiQuanOrderList(Date startTime, int searchType, int page,
|
| | | boolean third) {
|
| | |
|
| | | return getRelationAndSpecialWeiQuanOrderList(startTime, searchType, page, third, 2);
|
| | | }
|
| | |
|
| | | private static WeiQuanOrderResult getRelationAndSpecialWeiQuanOrderList(Date startTime, int searchType, int page,
|
| | | boolean third, int bizType) {
|
| | | WeiQuanOrderResult finalResult = new WeiQuanOrderResult();
|
| | |
|
| | | List<TaoBaoWeiQuanOrder> list = new ArrayList<>();
|
| | | finalResult.orderList = list;
|
| | | Map<String, String> map = new HashMap<>();
|
| | | map.put("method", "taobao.tbk.relation.refund");
|
| | |
|
| | | JSONObject option = new JSONObject();
|
| | | option.put("search_type", searchType);
|
| | | option.put("refund_type", third ? 2 : 1);
|
| | | option.put("start_time", TimeUtil.getGernalTime(startTime.getTime(), "yyyy-MM-dd HH:mm:ss"));
|
| | | option.put("page_no", page);
|
| | | option.put("page_size", 100);
|
| | | option.put("biz_type", bizType);
|
| | | map.put("search_option", option.toString());
|
| | |
|
| | | TaoKeAppInfo app = new TaoKeAppInfo();
|
| | | app.setAppKey(TaoBaoConstant.TAOBAO_AUTH_APPKEY);
|
| | | app.setAppSecret(TaoBaoConstant.TAOBAO_AUTH_APPSECRET);
|
| | | try {
|
| | | JSONObject json = TaoKeBaseUtil.baseRequest(map, app);
|
| | | JSONObject results = json.optJSONObject("tbk_relation_refund_response").optJSONObject("result")
|
| | | .optJSONObject("data").optJSONObject("results");
|
| | | if (results == null)
|
| | | return finalResult;
|
| | |
|
| | | int count = results.optInt("total_count");
|
| | | finalResult.totalCount = count;
|
| | | JSONArray array = results.optJSONArray("result");
|
| | | if (array != null)
|
| | | for (int i = 0; i < array.size(); i++) {
|
| | | JSONObject item = array.optJSONObject(i);
|
| | | TaoBaoWeiQuanOrder order = new TaoBaoWeiQuanOrder();
|
| | | order.setGoodsName(item.optString("tb_auction_title"));
|
| | | BigDecimal fanMoney = new BigDecimal(0);
|
| | | if (!StringUtil.isNullOrEmpty(item.optString("tk_subsidy_fee_refund3rd_pub"))) {
|
| | | fanMoney = fanMoney.add(new BigDecimal(item.optString("tk_subsidy_fee_refund3rd_pub")));
|
| | | }
|
| | | if (!StringUtil.isNullOrEmpty(item.optString("tk_commission_fee_refund3rd_pub"))) {
|
| | | fanMoney = fanMoney.add(new BigDecimal(item.optString("tk_commission_fee_refund3rd_pub")));
|
| | | }
|
| | | if (!StringUtil.isNullOrEmpty(item.optString("tk_subsidy_fee_refund_pub"))) {
|
| | | fanMoney = fanMoney.add(new BigDecimal(item.optString("tk_subsidy_fee_refund_pub")));
|
| | | }
|
| | | if (!StringUtil.isNullOrEmpty(item.optString("tk_commission_fee_refund_pub"))) {
|
| | | fanMoney = fanMoney.add(new BigDecimal(item.optString("tk_commission_fee_refund_pub")));
|
| | | }
|
| | |
|
| | | if (fanMoney.compareTo(new BigDecimal(0)) == 0)
|
| | | fanMoney = null;
|
| | |
|
| | | order.setFanMoney(fanMoney);
|
| | | order.setJieSuanTime(new Date(
|
| | | TimeUtil.convertToTimeTemp(item.optString("earning_time"), "yyyy-MM-dd HH:mm:ss")));
|
| | | if (!StringUtil.isNullOrEmpty(item.optString("refund_fee")))
|
| | | order.setMoney(new BigDecimal(item.optString("refund_fee")));
|
| | | order.setOrderId(item.optString("tb_trade_parent_id"));
|
| | | order.setOrderItemId(item.optString("tb_trade_id"));
|
| | | int state = item.optInt("refund_status");
|
| | | if (state == 4)
|
| | | order.setState("维权创建");
|
| | | else if (state == 2)
|
| | | order.setState("维权成功");
|
| | | else if (state == 3)
|
| | | order.setState("维权失败");
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(item.optString("tk_refund_suit_time")))
|
| | | order.setWeiQuanFinishTime(new Date(TimeUtil
|
| | | .convertToTimeTemp(item.optString("tk_refund_suit_time"), "yyyy-MM-dd HH:mm:ss")));
|
| | | order.setWeiQuanTime(new Date(
|
| | | TimeUtil.convertToTimeTemp(item.optString("tk_refund_time"), "yyyy-MM-dd HH:mm:ss")));
|
| | | list.add(order);
|
| | | }
|
| | |
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | return finalResult;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 新版本淘宝订单
|
| | | */
|
| | |
|
| | | /**
|
| | | * 获取淘宝会员运营订单
|
| | | * |
| | | * @param startTime
|
| | | * @param endTime
|
| | | * @return
|
| | | */
|
| | | public static List<TaoBaoOrder> getTaoBaoSpecialOrderList(long startTime, long endTime, int queryType) {
|
| | | return getTaoBaoOrderList(startTime, endTime, queryType, 3);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 淘宝渠道订单
|
| | | * |
| | | * @param startTime
|
| | | * @param endTime
|
| | | * @param queryType
|
| | | * @return
|
| | | */
|
| | | public static List<TaoBaoOrder> getTaoBaoRelationOrderList(long startTime, long endTime, int queryType) {
|
| | | return getTaoBaoOrderList(startTime, endTime, queryType, 2);
|
| | | }
|
| | |
|
| | | public static List<TaoBaoOrder> getTaoBaoCommonOrderList(long startTime, long endTime, int queryType) {
|
| | | return getTaoBaoOrderList(startTime, endTime, queryType, 1);
|
| | | }
|
| | |
|
| | | public static List<TaoBaoOrder> getTaoBaoOrderList(long startTime, long endTime, int queryType, int orderScene) {
|
| | | List<TaoBaoOrder> orderList = new ArrayList<>();
|
| | | // 跨度20分钟
|
| | | long span = (1000 * 60 * 20L);
|
| | | long jianGe = endTime - startTime;
|
| | | long page = jianGe % span == 0 ? jianGe / span : jianGe / span + 1;
|
| | | if (page == 0)
|
| | | page = 1;
|
| | | for (int i = 1; i <= page; i++) {
|
| | | long start = startTime + (i - 1) * span;
|
| | | long end = start + span;
|
| | | if (end > endTime)
|
| | | end = endTime;
|
| | | TaoBaoOrderResultDTO dto = queryNewOrder(TimeUtil.getGernalTime(start, "yyyy-MM-dd HH:mm:ss"),
|
| | | TimeUtil.getGernalTime(end, "yyyy-MM-dd HH:mm:ss"), null, queryType, orderScene);
|
| | | if (dto != null)
|
| | | orderList.addAll(dto.getOrderList());
|
| | | while (dto!=null&&dto.isHasNext()) {
|
| | | dto = queryNewOrder(TimeUtil.getGernalTime(start, "yyyy-MM-dd HH:mm:ss"),
|
| | | TimeUtil.getGernalTime(end, "yyyy-MM-dd HH:mm:ss"), dto.getPositionIndex(), queryType,
|
| | | orderScene);
|
| | | if (dto != null)
|
| | | orderList.addAll(dto.getOrderList());
|
| | | }
|
| | | }
|
| | | return orderList;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 淘宝订单查询
|
| | | * |
| | | * @param startTime
|
| | | * @param endTime
|
| | | * @param positionIndex
|
| | | * @param queryType
|
| | | * 1:按照订单淘客创建时间查询,2:按照订单淘客付款时间查询,3:按照订单淘客结算时间查询
|
| | | * @param orderScene
|
| | | * @return
|
| | | */
|
| | | private static TaoBaoOrderResultDTO queryNewOrder(String startTime, String endTime, String positionIndex,
|
| | | int queryType, int orderScene) {
|
| | | Map<String, String> params = new HashMap<>();
|
| | | params.put("query_type", queryType + "");
|
| | | params.put("page_size", "100");
|
| | | params.put("start_time", startTime);
|
| | | params.put("end_time", endTime);
|
| | | params.put("page_no", "1");
|
| | | params.put("order_scene", orderScene + "");
|
| | | if (!StringUtil.isNullOrEmpty(positionIndex))
|
| | | params.put("position_index", positionIndex + "");
|
| | | params.put("method", "taobao.tbk.order.details.get");
|
| | | TaoKeAppInfo app = new TaoKeAppInfo();
|
| | | app.setAppKey(TaoBaoConstant.TAOBAO_AUTH_APPKEY);
|
| | | app.setAppSecret(TaoBaoConstant.TAOBAO_AUTH_APPSECRET);
|
| | | try {
|
| | | JSONObject json = TaoKeBaseUtil.baseRequest(params, app);
|
| | | if (Constant.IS_TEST)
|
| | | System.out.println(json);
|
| | | return parseTaoBaoOrderNew(json.toString());
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | return null;
|
| | | }
|
| | | taoBaoOrder.setGoods(goods);
|
| | | orderList.add(taoBaoOrder);
|
| | | } catch (Exception e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e, "订单号信息:" + item.toString(), "订单解析出错");
|
| | | } catch (Exception e1) {
|
| | | }
|
| | | }
|
| | | }
|
| | | dto.setOrderList(orderList);
|
| | | return dto;
|
| | | }
|
| | |
|
| | |
|
| | | @Deprecated
|
| | | public static List<TaoBaoOrder> queryTaoBaoOrder(OrderQuery orderQuery, String appKey, String appSecret) {
|
| | | private static TaoBaoOrderResultDTO parseTaoBaoOrderForBackUp(String response) {
|
| | |
|
| | | Map<String, String> map = new HashMap<>();
|
| | | map.put("method", "taobao.tbk.order.get");
|
| | | map.put("fields",
|
| | | "tb_trade_parent_id,tb_trade_id,num_iid,item_title,item_num,price,pay_price,seller_nick,seller_shop_title,commission,commission_rate,unid,create_time,earning_time,tk_status,tk3rd_pub_id,tk3rd_site_id,tk3rd_adzone_id,relation_id,tb_trade_parent_id,tb_trade_id,num_iid,item_title,item_num,price,pay_price,seller_nick,seller_shop_title,commission,commission_rate,unid,create_time,earning_time,tk3rd_pub_id,tk3rd_site_id,tk3rd_adzone_id,special_id,click_time,relation_id,special_id");
|
| | | if (orderQuery.startTime != null)
|
| | | map.put("start_time", orderQuery.startTime);
|
| | | if (orderQuery.span != null)
|
| | | map.put("span", orderQuery.span + "");
|
| | | map.put("page_no", orderQuery.pageNo + "");
|
| | | map.put("page_size", orderQuery.pageSize + "");
|
| | | TaoBaoOrderResultDTO dto = new TaoBaoOrderResultDTO(false, false, null, new ArrayList<>());
|
| | |
|
| | | if (orderQuery.tkStatus != null)
|
| | | map.put("tk_status", orderQuery.tkStatus + "");
|
| | | if (orderQuery.orderQueryType != null)
|
| | | map.put("order_query_type", orderQuery.orderQueryType);
|
| | | if (orderQuery.orderScene != null)
|
| | | map.put("order_scene", orderQuery.orderScene + "");
|
| | | List<Serializable> orderList = new ArrayList<>();
|
| | | JSONArray array = null;
|
| | | JSONObject data = JSONObject.fromObject(response);
|
| | | try {
|
| | | JSONObject rootData = data.optJSONObject("tbk_order_details_get_response").optJSONObject("data");
|
| | | array = rootData.optJSONObject("results").optJSONArray("publisher_order_dto");
|
| | | dto.setHasPre(rootData.optBoolean("has_pre"));
|
| | | dto.setPositionIndex(rootData.optString("position_index"));
|
| | | dto.setHasNext(rootData.optBoolean("has_next"));
|
| | | } catch (Exception e) {
|
| | | return dto;
|
| | | }
|
| | |
|
| | | if (orderQuery.orderCountType != null)
|
| | | map.put("order_count_type", orderQuery.orderCountType + "");
|
| | | if (array != null)
|
| | | for (int i = 0; i < array.size(); i++) {
|
| | | JSONObject item = array.optJSONObject(i);
|
| | | try {
|
| | | String tradeId = item.optString("trade_id");
|
| | | String orderId = item.optString("trade_parent_id");
|
| | | TaoBaoOrderBackUp orderBackUp = new TaoBaoOrderBackUp();
|
| | | orderBackUp.setContent(item.toString());
|
| | | orderBackUp.setTradeId(tradeId);
|
| | | orderBackUp.setOrderId(orderId);
|
| | | orderList.add(orderBackUp);
|
| | | } catch (Exception e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e, "订单号信息:" + item.toString(), "订单解析出错");
|
| | | } catch (Exception e1) {
|
| | | }
|
| | | }
|
| | | }
|
| | | dto.setOrderList(orderList);
|
| | | return dto;
|
| | | }
|
| | |
|
| | | TaoKeAppInfo app = new TaoKeAppInfo();
|
| | | app.setAppKey(appKey);
|
| | | app.setAppSecret(appSecret);
|
| | | try {
|
| | | JSONObject json = TaoKeBaseUtil.baseRequest(map, app);
|
| | | System.out.println(json);
|
| | | } catch (TaoKeApiException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | try {
|
| | | Thread.sleep(1000);
|
| | | } catch (InterruptedException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | public static WeiQuanOrderResult getTaoBaoRelationWeiQuanOrderList(Date startTime, int searchType, int page,
|
| | | boolean third) {
|
| | |
|
| | | return null;
|
| | | }
|
| | | return getRelationAndSpecialWeiQuanOrderList(startTime, searchType, page, third, 1);
|
| | | }
|
| | |
|
| | | public static WeiQuanOrderResult getTaoBaoSpecialWeiQuanOrderList(Date startTime, int searchType, int page,
|
| | | boolean third) {
|
| | |
|
| | | return getRelationAndSpecialWeiQuanOrderList(startTime, searchType, page, third, 2);
|
| | | }
|
| | |
|
| | | private static WeiQuanOrderResult getRelationAndSpecialWeiQuanOrderList(Date startTime, int searchType, int page,
|
| | | boolean third, int bizType) {
|
| | | WeiQuanOrderResult finalResult = new WeiQuanOrderResult();
|
| | |
|
| | | List<TaoBaoWeiQuanOrder> list = new ArrayList<>();
|
| | | finalResult.orderList = list;
|
| | | Map<String, String> map = new HashMap<>();
|
| | | map.put("method", "taobao.tbk.relation.refund");
|
| | |
|
| | | JSONObject option = new JSONObject();
|
| | | option.put("search_type", searchType);
|
| | | option.put("refund_type", third ? 2 : 1);
|
| | | option.put("start_time", TimeUtil.getGernalTime(startTime.getTime(), "yyyy-MM-dd HH:mm:ss"));
|
| | | option.put("page_no", page);
|
| | | option.put("page_size", 100);
|
| | | option.put("biz_type", bizType);
|
| | | map.put("search_option", option.toString());
|
| | |
|
| | | TaoKeAppInfo app = new TaoKeAppInfo();
|
| | | app.setAppKey(TaoBaoConstant.TAOBAO_AUTH_APPKEY);
|
| | | app.setAppSecret(TaoBaoConstant.TAOBAO_AUTH_APPSECRET);
|
| | | try {
|
| | | JSONObject json = TaoKeBaseUtil.baseRequest(map, app);
|
| | | JSONObject results = json.optJSONObject("tbk_relation_refund_response").optJSONObject("result")
|
| | | .optJSONObject("data").optJSONObject("results");
|
| | | if (results == null)
|
| | | return finalResult;
|
| | |
|
| | | int count = results.optInt("total_count");
|
| | | finalResult.totalCount = count;
|
| | | JSONArray array = results.optJSONArray("result");
|
| | | if (array != null)
|
| | | for (int i = 0; i < array.size(); i++) {
|
| | | JSONObject item = array.optJSONObject(i);
|
| | | TaoBaoWeiQuanOrder order = new TaoBaoWeiQuanOrder();
|
| | | order.setGoodsName(item.optString("tb_auction_title"));
|
| | | BigDecimal fanMoney = new BigDecimal(0);
|
| | | if (!StringUtil.isNullOrEmpty(item.optString("tk_subsidy_fee_refund3rd_pub"))) {
|
| | | fanMoney = fanMoney.add(new BigDecimal(item.optString("tk_subsidy_fee_refund3rd_pub")));
|
| | | }
|
| | | if (!StringUtil.isNullOrEmpty(item.optString("tk_commission_fee_refund3rd_pub"))) {
|
| | | fanMoney = fanMoney.add(new BigDecimal(item.optString("tk_commission_fee_refund3rd_pub")));
|
| | | }
|
| | | if (!StringUtil.isNullOrEmpty(item.optString("tk_subsidy_fee_refund_pub"))) {
|
| | | fanMoney = fanMoney.add(new BigDecimal(item.optString("tk_subsidy_fee_refund_pub")));
|
| | | }
|
| | | if (!StringUtil.isNullOrEmpty(item.optString("tk_commission_fee_refund_pub"))) {
|
| | | fanMoney = fanMoney.add(new BigDecimal(item.optString("tk_commission_fee_refund_pub")));
|
| | | }
|
| | |
|
| | | if (fanMoney.compareTo(new BigDecimal(0)) == 0)
|
| | | fanMoney = null;
|
| | |
|
| | | order.setFanMoney(fanMoney);
|
| | | order.setJieSuanTime(new Date(
|
| | | TimeUtil.convertToTimeTemp(item.optString("earning_time"), "yyyy-MM-dd HH:mm:ss")));
|
| | | if (!StringUtil.isNullOrEmpty(item.optString("refund_fee")))
|
| | | order.setMoney(new BigDecimal(item.optString("refund_fee")));
|
| | | order.setOrderId(item.optString("tb_trade_parent_id"));
|
| | | order.setOrderItemId(item.optString("tb_trade_id"));
|
| | | int state = item.optInt("refund_status");
|
| | | if (state == 4)
|
| | | order.setState("维权创建");
|
| | | else if (state == 2)
|
| | | order.setState("维权成功");
|
| | | else if (state == 3)
|
| | | order.setState("维权失败");
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(item.optString("tk_refund_suit_time")))
|
| | | order.setWeiQuanFinishTime(new Date(TimeUtil
|
| | | .convertToTimeTemp(item.optString("tk_refund_suit_time"), "yyyy-MM-dd HH:mm:ss")));
|
| | | order.setWeiQuanTime(new Date(
|
| | | TimeUtil.convertToTimeTemp(item.optString("tk_refund_time"), "yyyy-MM-dd HH:mm:ss")));
|
| | | list.add(order);
|
| | | }
|
| | |
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | return finalResult;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 新版本淘宝订单
|
| | | */
|
| | |
|
| | | /**
|
| | | * 获取淘宝会员运营订单
|
| | | *
|
| | | * @param startTime
|
| | | * @param endTime
|
| | | * @return
|
| | | */
|
| | | public static List<TaoBaoOrder> getTaoBaoSpecialOrderList(long startTime, long endTime, int queryType) {
|
| | | return getTaoBaoOrderList(startTime, endTime, queryType, 3);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 淘宝渠道订单
|
| | | *
|
| | | * @param startTime
|
| | | * @param endTime
|
| | | * @param queryType
|
| | | * @return
|
| | | */
|
| | | public static List<TaoBaoOrder> getTaoBaoRelationOrderList(long startTime, long endTime, int queryType) {
|
| | | return getTaoBaoOrderList(startTime, endTime, queryType, 2);
|
| | | }
|
| | |
|
| | | public static List<TaoBaoOrder> getTaoBaoCommonOrderList(long startTime, long endTime, int queryType) {
|
| | | return getTaoBaoOrderList(startTime, endTime, queryType, 1);
|
| | | }
|
| | |
|
| | | public static List<TaoBaoOrder> getTaoBaoOrderList(long startTime, long endTime, int queryType, int orderScene) {
|
| | | List<Serializable> orderList = new ArrayList<>();
|
| | | // 跨度20分钟
|
| | | long span = (1000 * 60 * 20L);
|
| | | long jianGe = endTime - startTime;
|
| | | long page = jianGe % span == 0 ? jianGe / span : jianGe / span + 1;
|
| | | if (page == 0)
|
| | | page = 1;
|
| | | for (int i = 1; i <= page; i++) {
|
| | | long start = startTime + (i - 1) * span;
|
| | | long end = start + span;
|
| | | if (end > endTime)
|
| | | end = endTime;
|
| | | TaoBaoOrderResultDTO dto = queryNewOrder(TimeUtil.getGernalTime(start, "yyyy-MM-dd HH:mm:ss"),
|
| | | TimeUtil.getGernalTime(end, "yyyy-MM-dd HH:mm:ss"), null, null, queryType, orderScene, new TaoBaoOrder());
|
| | | if (dto != null)
|
| | | orderList.addAll(dto.getOrderList());
|
| | | while (dto != null && dto.isHasNext()) {
|
| | | dto = queryNewOrder(TimeUtil.getGernalTime(start, "yyyy-MM-dd HH:mm:ss"),
|
| | | TimeUtil.getGernalTime(end, "yyyy-MM-dd HH:mm:ss"), dto.getPositionIndex(), null, queryType,
|
| | | orderScene, new TaoBaoOrder());
|
| | | if (dto != null)
|
| | | orderList.addAll(dto.getOrderList());
|
| | | }
|
| | | }
|
| | | List<TaoBaoOrder> orders = new ArrayList<>();
|
| | | for (Serializable s : orderList)
|
| | | orders.add((TaoBaoOrder) s);
|
| | |
|
| | | return orders;
|
| | | }
|
| | |
|
| | |
|
| | | /**
|
| | | * 获取淘宝订单备份数据
|
| | | *
|
| | | * @param startTime
|
| | | * @param endTime
|
| | | * @param status 12-付款,13-关闭,14-确认收货,3-结算成功;不传
|
| | | * @param queryType 1:按照订单淘客创建时间查询,2:按照订单淘客付款时间查询,3:按照订单淘客结算时间查询
|
| | | * @param orderScene 1:常规订单,2:渠道订单,3:会员运营订单
|
| | | * @return
|
| | | */
|
| | | public static List<TaoBaoOrderBackUp> getTaoBaoOrderBackUpList(long startTime, long endTime, Integer status, int queryType, int orderScene) {
|
| | | List<Serializable> orderList = new ArrayList<>();
|
| | | // 跨度20分钟
|
| | | long span = (1000 * 60 * 20L);
|
| | | long jianGe = endTime - startTime;
|
| | | long page = jianGe % span == 0 ? jianGe / span : jianGe / span + 1;
|
| | | if (page == 0)
|
| | | page = 1;
|
| | | for (int i = 1; i <= page; i++) {
|
| | | long start = startTime + (i - 1) * span;
|
| | | long end = start + span;
|
| | | if (end > endTime)
|
| | | end = endTime;
|
| | | TaoBaoOrderResultDTO dto = queryNewOrder(TimeUtil.getGernalTime(start, "yyyy-MM-dd HH:mm:ss"),
|
| | | TimeUtil.getGernalTime(end, "yyyy-MM-dd HH:mm:ss"), null, status, queryType, orderScene, new TaoBaoOrderBackUp());
|
| | | if (dto != null)
|
| | | orderList.addAll(dto.getOrderList());
|
| | | while (dto != null && dto.isHasNext()) {
|
| | | dto = queryNewOrder(TimeUtil.getGernalTime(start, "yyyy-MM-dd HH:mm:ss"),
|
| | | TimeUtil.getGernalTime(end, "yyyy-MM-dd HH:mm:ss"), dto.getPositionIndex(), status, queryType,
|
| | | orderScene, new TaoBaoOrderBackUp());
|
| | | if (dto != null)
|
| | | orderList.addAll(dto.getOrderList());
|
| | |
|
| | | try {
|
| | | Thread.sleep(1000);
|
| | | } catch (InterruptedException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | try {
|
| | | Thread.sleep(1000);
|
| | | } catch (InterruptedException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | List<TaoBaoOrderBackUp> orders = new ArrayList<>();
|
| | | for (Serializable s : orderList)
|
| | | orders.add((TaoBaoOrderBackUp) s);
|
| | |
|
| | | return orders;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 淘宝订单查询
|
| | | *
|
| | | * @param startTime
|
| | | * @param endTime
|
| | | * @param positionIndex
|
| | | * @param queryType 1:按照订单淘客创建时间查询,2:按照订单淘客付款时间查询,3:按照订单淘客结算时间查询
|
| | | * @param orderScene
|
| | | * @return
|
| | | */
|
| | | private static TaoBaoOrderResultDTO queryNewOrder(String startTime, String endTime, String positionIndex, Integer status,
|
| | | int queryType, int orderScene, Serializable clazz) {
|
| | | Map<String, String> params = new HashMap<>();
|
| | | params.put("query_type", queryType + "");
|
| | | if (status != null)
|
| | | params.put("tk_status", status + "");
|
| | | params.put("page_size", "100");
|
| | | params.put("start_time", startTime);
|
| | | params.put("end_time", endTime);
|
| | | params.put("page_no", "1");
|
| | | params.put("order_scene", orderScene + "");
|
| | | if (!StringUtil.isNullOrEmpty(positionIndex))
|
| | | params.put("position_index", positionIndex + "");
|
| | | params.put("method", "taobao.tbk.order.details.get");
|
| | | TaoKeAppInfo app = new TaoKeAppInfo();
|
| | | app.setAppKey(TaoBaoConstant.TAOBAO_AUTH_APPKEY);
|
| | | app.setAppSecret(TaoBaoConstant.TAOBAO_AUTH_APPSECRET);
|
| | | try {
|
| | | JSONObject json = TaoKeBaseUtil.baseRequest(params, app);
|
| | | if (Constant.IS_TEST)
|
| | | System.out.println(json);
|
| | | if (clazz instanceof TaoBaoOrder)
|
| | | return parseTaoBaoOrderNew(json.toString());
|
| | | else
|
| | | return parseTaoBaoOrderForBackUp(json.toString());
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | return null;
|
| | | }
|
| | |
|
| | |
|
| | | @Deprecated
|
| | | public static List<TaoBaoOrder> queryTaoBaoOrder(OrderQuery orderQuery, String appKey, String appSecret) {
|
| | |
|
| | | Map<String, String> map = new HashMap<>();
|
| | | map.put("method", "taobao.tbk.order.get");
|
| | | map.put("fields",
|
| | | "tb_trade_parent_id,tb_trade_id,num_iid,item_title,item_num,price,pay_price,seller_nick,seller_shop_title,commission,commission_rate,unid,create_time,earning_time,tk_status,tk3rd_pub_id,tk3rd_site_id,tk3rd_adzone_id,relation_id,tb_trade_parent_id,tb_trade_id,num_iid,item_title,item_num,price,pay_price,seller_nick,seller_shop_title,commission,commission_rate,unid,create_time,earning_time,tk3rd_pub_id,tk3rd_site_id,tk3rd_adzone_id,special_id,click_time,relation_id,special_id");
|
| | | if (orderQuery.startTime != null)
|
| | | map.put("start_time", orderQuery.startTime);
|
| | | if (orderQuery.span != null)
|
| | | map.put("span", orderQuery.span + "");
|
| | | map.put("page_no", orderQuery.pageNo + "");
|
| | | map.put("page_size", orderQuery.pageSize + "");
|
| | |
|
| | | if (orderQuery.tkStatus != null)
|
| | | map.put("tk_status", orderQuery.tkStatus + "");
|
| | | if (orderQuery.orderQueryType != null)
|
| | | map.put("order_query_type", orderQuery.orderQueryType);
|
| | | if (orderQuery.orderScene != null)
|
| | | map.put("order_scene", orderQuery.orderScene + "");
|
| | |
|
| | | if (orderQuery.orderCountType != null)
|
| | | map.put("order_count_type", orderQuery.orderCountType + "");
|
| | |
|
| | | TaoKeAppInfo app = new TaoKeAppInfo();
|
| | | app.setAppKey(appKey);
|
| | | app.setAppSecret(appSecret);
|
| | | try {
|
| | | JSONObject json = TaoKeBaseUtil.baseRequest(map, app);
|
| | | System.out.println(json);
|
| | | } catch (TaoKeApiException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | try {
|
| | | Thread.sleep(1000);
|
| | | } catch (InterruptedException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | return null;
|
| | | }
|
| | | }
|
| | |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | |
| | | <mapper namespace="com.yeshi.fanli.dao.mybatis.money.UserMoneyDebtMapper"> |
| | | <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.money.UserMoneyDebt"> |
| | | <id column="ud_id" property="id" jdbcType="BIGINT" /> |
| | | <result column="ud_uid" property="uid" jdbcType="BIGINT" /> |
| | | <result column="ud_origin_money" property="originMoney" |
| | | jdbcType="DECIMAL" /> |
| | | <result column="ud_left_money" property="leftMoney" jdbcType="DECIMAL" /> |
| | | <result column="ud_type" property="type" jdbcType="VARCHAR" |
| | | typeHandler="com.yeshi.fanli.util.mybatishandler.money.UserMoneyDebtTypeEnumHandler" /> |
| | | <result column="ud_source_id" property="sourceId" jdbcType="BIGINT" /> |
| | | <result column="ud_beizhu" property="beiZhu" jdbcType="VARCHAR" /> |
| | | <result column="ud_create_time" property="createTime" jdbcType="TIMESTAMP" /> |
| | | <result column="ud_update_time" property="updateTime" jdbcType="TIMESTAMP" /> |
| | | </resultMap> |
| | | <sql id="Base_Column_List">ud_id,ud_uid,ud_origin_money,ud_left_money,ud_type,ud_source_id,ud_beizhu,ud_create_time,ud_update_time |
| | | <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.money.UserMoneyDebt"> |
| | | <id column="ud_id" property="id" jdbcType="BIGINT"/> |
| | | <result column="ud_uid" property="uid" jdbcType="BIGINT"/> |
| | | <result column="ud_origin_money" property="originMoney" |
| | | jdbcType="DECIMAL"/> |
| | | <result column="ud_left_money" property="leftMoney" jdbcType="DECIMAL"/> |
| | | <result column="ud_type" property="type" jdbcType="VARCHAR" |
| | | typeHandler="com.yeshi.fanli.util.mybatishandler.money.UserMoneyDebtTypeEnumHandler"/> |
| | | <result column="ud_source_id" property="sourceId" jdbcType="BIGINT"/> |
| | | <result column="ud_beizhu" property="beiZhu" jdbcType="VARCHAR"/> |
| | | <result column="ud_create_time" property="createTime" jdbcType="TIMESTAMP"/> |
| | | <result column="ud_update_time" property="updateTime" jdbcType="TIMESTAMP"/> |
| | | </resultMap> |
| | | <sql id="Base_Column_List">ud_id,ud_uid,ud_origin_money,ud_left_money,ud_type,ud_source_id,ud_beizhu,ud_create_time,ud_update_time |
| | | </sql> |
| | | <select id="selectByPrimaryKey" resultMap="BaseResultMap" |
| | | parameterType="java.lang.Long"> |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | | from yeshi_ec_user_debt where ud_id = #{id,jdbcType=BIGINT} |
| | | </select> |
| | | <select id="selectByPrimaryKey" resultMap="BaseResultMap" |
| | | parameterType="java.lang.Long"> |
| | | select |
| | | <include refid="Base_Column_List"/> |
| | | from yeshi_ec_user_debt where ud_id = #{id,jdbcType=BIGINT} |
| | | </select> |
| | | |
| | | <select id="selectByUidAndTypeAndSourceId" resultMap="BaseResultMap"> |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | | from yeshi_ec_user_debt where ud_uid = #{uid} and ud_type=#{type} and |
| | | ud_source_id=#{sourceId} limit 1 for update |
| | | <select id="selectByUidAndTypeAndSourceId" resultMap="BaseResultMap"> |
| | | select |
| | | <include refid="Base_Column_List"/> |
| | | from yeshi_ec_user_debt where ud_uid = #{uid} and ud_type=#{type} and |
| | | ud_source_id=#{sourceId} limit 1 for update |
| | | </select> |
| | | |
| | | |
| | | <select id="selectByTypeAndSourceId" resultMap="BaseResultMap"> |
| | | select |
| | | <include refid="Base_Column_List"/> |
| | | from yeshi_ec_user_debt where ud_type=#{type} and |
| | | ud_source_id=#{sourceId} limit 1 for update |
| | | </select> |
| | | |
| | | <select id="listByUidWithHasLeftMoney" resultMap="BaseResultMap"> |
| | | select |
| | | <include refid="Base_Column_List"/> |
| | | from yeshi_ec_user_debt where ud_uid=#{uid} and ud_left_money>0 limit #{start},#{count} |
| | | </select> |
| | | |
| | | |
| | | <select id="listUidWithHasDebtToRepay" resultType="java.lang.Long"> |
| | | SELECT DISTINCT( d.`ud_uid`) FROM `yeshi_ec_user_debt` d WHERE d.`ud_left_money`>0 limit #{start},#{count} |
| | | </select> |
| | | |
| | | |
| | | <select id="selectByTypeAndSourceId" resultMap="BaseResultMap"> |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | | from yeshi_ec_user_debt where ud_type=#{type} and |
| | | ud_source_id=#{sourceId} limit 1 for update |
| | | </select> |
| | | |
| | | <select id="listByUidWithHasLeftMoney" resultMap="BaseResultMap"> |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | | from yeshi_ec_user_debt where ud_uid=#{uid} and ud_left_money>0 limit #{start},#{count} |
| | | <select id="countUidWithHasDebtToRepay" resultType="java.lang.Long"> |
| | | SELECT COUNT( DISTINCT( d.`ud_uid`)) FROM `yeshi_ec_user_debt` d WHERE d.`ud_left_money`>0 |
| | | </select> |
| | | |
| | | <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from |
| | | |
| | | <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from |
| | | yeshi_ec_user_debt where ud_id = #{id,jdbcType=BIGINT} |
| | | </delete> |
| | | <insert id="insert" parameterType="com.yeshi.fanli.entity.money.UserMoneyDebt" |
| | | useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_user_debt |
| | | <insert id="insert" parameterType="com.yeshi.fanli.entity.money.UserMoneyDebt" |
| | | useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_user_debt |
| | | (ud_id,ud_uid,ud_origin_money,ud_left_money,ud_type,ud_source_id,ud_beizhu,ud_create_time,ud_update_time) |
| | | values |
| | | (#{id,jdbcType=BIGINT},#{uid,jdbcType=BIGINT},#{originMoney,jdbcType=DECIMAL},#{leftMoney,jdbcType=DECIMAL},#{type,jdbcType=VARCHAR},#{sourceId,jdbcType=BIGINT},#{beiZhu,jdbcType=VARCHAR},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP}) |
| | | </insert> |
| | | <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.money.UserMoneyDebt" |
| | | useGeneratedKeys="true" keyProperty="id"> |
| | | insert into yeshi_ec_user_debt |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null">ud_id,</if> |
| | | <if test="uid != null">ud_uid,</if> |
| | | <if test="originMoney != null">ud_origin_money,</if> |
| | | <if test="leftMoney != null">ud_left_money,</if> |
| | | <if test="type != null">ud_type,</if> |
| | | <if test="sourceId != null">ud_source_id,</if> |
| | | <if test="beiZhu != null">ud_beizhu,</if> |
| | | <if test="createTime != null">ud_create_time,</if> |
| | | <if test="updateTime != null">ud_update_time,</if> |
| | | </trim> |
| | | values |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null">#{id,jdbcType=BIGINT},</if> |
| | | <if test="uid != null">#{uid,jdbcType=BIGINT},</if> |
| | | <if test="originMoney != null">#{originMoney,jdbcType=DECIMAL},</if> |
| | | <if test="leftMoney != null">#{leftMoney,jdbcType=DECIMAL},</if> |
| | | <if test="type != null">#{type,jdbcType=VARCHAR},</if> |
| | | <if test="sourceId != null">#{sourceId,jdbcType=BIGINT},</if> |
| | | <if test="beiZhu != null">#{beiZhu,jdbcType=VARCHAR},</if> |
| | | <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if> |
| | | </trim> |
| | | </insert> |
| | | <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.money.UserMoneyDebt">update |
| | | <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.money.UserMoneyDebt" |
| | | useGeneratedKeys="true" keyProperty="id"> |
| | | insert into yeshi_ec_user_debt |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null">ud_id,</if> |
| | | <if test="uid != null">ud_uid,</if> |
| | | <if test="originMoney != null">ud_origin_money,</if> |
| | | <if test="leftMoney != null">ud_left_money,</if> |
| | | <if test="type != null">ud_type,</if> |
| | | <if test="sourceId != null">ud_source_id,</if> |
| | | <if test="beiZhu != null">ud_beizhu,</if> |
| | | <if test="createTime != null">ud_create_time,</if> |
| | | <if test="updateTime != null">ud_update_time,</if> |
| | | </trim> |
| | | values |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null">#{id,jdbcType=BIGINT},</if> |
| | | <if test="uid != null">#{uid,jdbcType=BIGINT},</if> |
| | | <if test="originMoney != null">#{originMoney,jdbcType=DECIMAL},</if> |
| | | <if test="leftMoney != null">#{leftMoney,jdbcType=DECIMAL},</if> |
| | | <if test="type != null">#{type,jdbcType=VARCHAR},</if> |
| | | <if test="sourceId != null">#{sourceId,jdbcType=BIGINT},</if> |
| | | <if test="beiZhu != null">#{beiZhu,jdbcType=VARCHAR},</if> |
| | | <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if> |
| | | </trim> |
| | | </insert> |
| | | <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.money.UserMoneyDebt">update |
| | | yeshi_ec_user_debt set ud_uid = #{uid,jdbcType=BIGINT},ud_origin_money |
| | | = #{originMoney,jdbcType=DECIMAL},ud_left_money = |
| | | #{leftMoney,jdbcType=DECIMAL},ud_type = |
| | |
| | | #{createTime,jdbcType=TIMESTAMP},ud_update_time = |
| | | #{updateTime,jdbcType=TIMESTAMP} where ud_id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.money.UserMoneyDebt"> |
| | | update yeshi_ec_user_debt |
| | | <set> |
| | | <if test="uid != null">ud_uid=#{uid,jdbcType=BIGINT},</if> |
| | | <if test="originMoney != null">ud_origin_money=#{originMoney,jdbcType=DECIMAL},</if> |
| | | <if test="leftMoney != null">ud_left_money=#{leftMoney,jdbcType=DECIMAL},</if> |
| | | <if test="type != null">ud_type=#{type,jdbcType=VARCHAR},</if> |
| | | <if test="sourceId != null">ud_source_id=#{sourceId,jdbcType=BIGINT},</if> |
| | | <if test="beiZhu != null">ud_beizhu=#{beiZhu,jdbcType=VARCHAR},</if> |
| | | <if test="createTime != null">ud_create_time=#{createTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="updateTime != null">ud_update_time=#{updateTime,jdbcType=TIMESTAMP},</if> |
| | | </set> |
| | | where ud_id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.money.UserMoneyDebt"> |
| | | update yeshi_ec_user_debt |
| | | <set> |
| | | <if test="uid != null">ud_uid=#{uid,jdbcType=BIGINT},</if> |
| | | <if test="originMoney != null">ud_origin_money=#{originMoney,jdbcType=DECIMAL},</if> |
| | | <if test="leftMoney != null">ud_left_money=#{leftMoney,jdbcType=DECIMAL},</if> |
| | | <if test="type != null">ud_type=#{type,jdbcType=VARCHAR},</if> |
| | | <if test="sourceId != null">ud_source_id=#{sourceId,jdbcType=BIGINT},</if> |
| | | <if test="beiZhu != null">ud_beizhu=#{beiZhu,jdbcType=VARCHAR},</if> |
| | | <if test="createTime != null">ud_create_time=#{createTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="updateTime != null">ud_update_time=#{updateTime,jdbcType=TIMESTAMP},</if> |
| | | </set> |
| | | where ud_id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | </mapper> |
| | |
| | | </property>
|
| | | </bean>
|
| | |
|
| | | <!--用户贷款资金订阅 -->
|
| | |
|
| | | <bean id="userMoneyDebtMessageListener"
|
| | | class="com.yeshi.fanli.util.rocketmq.consumer.user.UserMoneyDebtMessageListener"></bean>
|
| | | <bean id="userMoneyDebtConsumer" class="com.aliyun.openservices.ons.api.bean.ConsumerBean"
|
| | | init-method="start" destroy-method="shutdown">
|
| | | <property name="properties"> <!--消费者配置信息 -->
|
| | | <props>
|
| | | <prop key="AccessKey">${rocketmq.AccessKey}</prop>
|
| | | <prop key="SecretKey">${rocketmq.SecretKey}</prop>
|
| | | <prop key="GROUP_ID">GID_USER_MONEY_DEBT</prop>
|
| | | <prop key="NAMESRV_ADDR">${rocketmq.NAMESRV_ADDR}</prop>
|
| | | <prop key="ConsumeThreadNums">50</prop>
|
| | | </props>
|
| | | </property>
|
| | | <property name="subscriptionTable">
|
| | | <map>
|
| | | <entry value-ref="userMoneyDebtMessageListener">
|
| | | <key>
|
| | | <bean class="com.aliyun.openservices.ons.api.bean.Subscription">
|
| | | <property name="topic" value="TOPIC_USER" />
|
| | | <property name="expression" value="userMoneyAdd" />
|
| | | </bean>
|
| | | </key>
|
| | | </entry>
|
| | | </map>
|
| | | </property>
|
| | | </bean>
|
| | |
|
| | |
|
| | |
|
| | |
|
| | | <!-- 测试消息订阅 -->
|
| | | <bean id="testRocketMQCosumerListener"
|
| | |
| | | </bean>
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | | </beans> |