| | |
| | | import org.yeshi.utils.entity.DateInfo; |
| | | import org.yeshi.utils.taobao.TbImgUtil; |
| | | |
| | | import com.aliyun.openservices.ons.api.Message; |
| | | import com.aliyun.openservices.ons.api.Producer; |
| | | import com.yeshi.fanli.dao.mybatis.order.CommonOrderGoodsMapper; |
| | | import com.yeshi.fanli.dao.mybatis.order.CommonOrderMapper; |
| | | import com.yeshi.fanli.dao.mybatis.order.CommonOrderTradeIdMapMapper; |
| | | import com.yeshi.fanli.dao.mybatis.taobao.TaoBaoWeiQuanOrderMapper; |
| | | import com.yeshi.fanli.dto.mq.order.OrderTopicTagEnum; |
| | | import com.yeshi.fanli.dto.mq.order.body.OrderConfirmMQMsg; |
| | | import com.yeshi.fanli.dto.order.CommonOrderAddResultDTO; |
| | | import com.yeshi.fanli.dto.pdd.PDDGoodsDetail; |
| | | import com.yeshi.fanli.entity.accept.AcceptData; |
| | |
| | | import com.yeshi.fanli.service.inter.user.UserInfoService; |
| | | import com.yeshi.fanli.service.inter.user.UserSystemCouponRecordService; |
| | | import com.yeshi.fanli.service.inter.user.UserSystemCouponService; |
| | | import com.yeshi.fanli.service.inter.user.invite.UserInviteService; |
| | | import com.yeshi.fanli.service.inter.user.vip.UserVIPInfoService; |
| | | import com.yeshi.fanli.util.Constant; |
| | | import com.yeshi.fanli.util.MoneyBigDecimalUtil; |
| | |
| | | import com.yeshi.fanli.util.jd.JDApiUtil; |
| | | import com.yeshi.fanli.util.jd.JDUtil; |
| | | import com.yeshi.fanli.util.pinduoduo.PinDuoDuoApiUtil; |
| | | import com.yeshi.fanli.util.rocketmq.MQMsgBodyFactory; |
| | | import com.yeshi.fanli.util.rocketmq.MQTopicName; |
| | | import com.yeshi.fanli.util.taobao.TaoBaoUtil; |
| | | import com.yeshi.fanli.util.taobao.TaoKeApiUtil; |
| | | import com.yeshi.fanli.util.user.UserLevelUtil; |
| | |
| | | |
| | | @Resource |
| | | private UserInfoService userInfoService; |
| | | |
| | | @Resource |
| | | private UserInviteService userInviteService; |
| | | |
| | | @Resource(name = "producer") |
| | | private Producer orderProducer; |
| | | |
| | | // 奖励订单图片 |
| | | public final static String PIC_REWARD = "http://img.flqapp.com/resource/order/order_state_reward.png"; |
| | |
| | | for (TaoBaoOrder taoBaoOrder : taoBaoOrders) { |
| | | CommonOrder newCommonOrder = CommonOrderFactory.create(taoBaoOrder); |
| | | CommonOrderGoods cog = new CommonOrderGoods(); |
| | | cog.setGoodsId(taoBaoOrder.getAuctionId() + ""); |
| | | cog.setGoodsType(Constant.SOURCE_TYPE_TAOBAO); |
| | | newCommonOrder.setCommonOrderGoods(cog); |
| | | |
| | | if ("饿了么".equalsIgnoreCase(taoBaoOrder.getOrderType())) { |
| | | cog.setGoodsId(taoBaoOrder.getTradeId() + ""); |
| | | cog.setGoodsType(Constant.SOURCE_TYPE_ELME); |
| | | cog.setPicture("http://img.flqapp.com/resource/goods/elme_picture_demo.png"); |
| | | cog.setTitle(taoBaoOrder.getTitle()); |
| | | newCommonOrder.setCommonOrderGoods(cog); |
| | | } else { |
| | | cog.setGoodsId(taoBaoOrder.getAuctionId() + ""); |
| | | cog.setGoodsType(Constant.SOURCE_TYPE_TAOBAO); |
| | | newCommonOrder.setCommonOrderGoods(cog); |
| | | } |
| | | newCommonOrder.setStateWholeOrder(wholeOrderState); |
| | | // 订单商品插入 |
| | | List<CommonOrderGoods> commonGoodsList = commonOrderGoodsMapper.listByGoodsIdAndGoodsType(cog.getGoodsId(), |
| | |
| | | if (commonGoodsList.size() <= 0)// 不存在就插入商品 |
| | | { |
| | | TaoBaoGoodsBrief taoBaoGoods = null; |
| | | try { |
| | | taoBaoGoods = TaoKeApiUtil.getSimpleGoodsInfo(taoBaoOrder.getAuctionId()); |
| | | LogManager.getLogger(LogType.taobaoGoods).info(String.format("订单商品分类:%s#%s#%s", |
| | | taoBaoGoods.getAuctionId(), taoBaoGoods.getRootCategoryName(), taoBaoGoods.getLeafName())); |
| | | } catch (TaobaoGoodsDownException e) { |
| | | e.printStackTrace(); |
| | | LogHelper.errorDetailInfo(e, "AUCTIONID:" + taoBaoOrder.getAuctionId(), ""); |
| | | if (cog.getGoodsType() != Constant.SOURCE_TYPE_ELME) { |
| | | try { |
| | | taoBaoGoods = TaoBaoUtil.getSimpleGoodsBrief(taoBaoOrder.getAuctionId()); |
| | | // 记录商品分类 |
| | | taoBaoGoods = TaoKeApiUtil.getSimpleGoodsInfo(taoBaoOrder.getAuctionId()); |
| | | LogManager.getLogger(LogType.taobaoGoods) |
| | | .info(String.format("订单商品分类:%s#%s#%s", taoBaoGoods.getAuctionId(), |
| | | taoBaoGoods.getRootCategoryName(), taoBaoGoods.getLeafName())); |
| | | } catch (TaobaoGoodsDownException e) { |
| | | e.printStackTrace(); |
| | | LogHelper.errorDetailInfo(e, "AUCTIONID:" + taoBaoOrder.getAuctionId(), ""); |
| | | try { |
| | | taoBaoGoods = TaoBaoUtil.getSimpleGoodsBrief(taoBaoOrder.getAuctionId()); |
| | | // 记录商品分类 |
| | | |
| | | } catch (Exception e1) { |
| | | CommonGoods commonGoods = commonGoodsService.getCommonGoodsByGoodsIdAndGoodsType( |
| | | taoBaoOrder.getAuctionId(), Constant.SOURCE_TYPE_TAOBAO); |
| | | if (commonGoods != null) |
| | | taoBaoGoods = TaoBaoUtil.convert(commonGoods); |
| | | } catch (Exception e1) { |
| | | CommonGoods commonGoods = commonGoodsService.getCommonGoodsByGoodsIdAndGoodsType( |
| | | taoBaoOrder.getAuctionId(), Constant.SOURCE_TYPE_TAOBAO); |
| | | if (commonGoods != null) |
| | | taoBaoGoods = TaoBaoUtil.convert(commonGoods); |
| | | } |
| | | } |
| | | } |
| | | if (taoBaoGoods != null) { |
| | |
| | | newCommonOrder.setUserInfo(new UserInfo(uid)); |
| | | commonOrderList.add(addCommonOrder(newCommonOrder)); |
| | | } |
| | | addConfirmMQMsg(commonOrderList); |
| | | return commonOrderList; |
| | | } |
| | | |
| | |
| | | newCommonOrder.setUserInfo(new UserInfo(uid)); |
| | | commonOrderList.add(addCommonOrder(newCommonOrder)); |
| | | } |
| | | addConfirmMQMsg(commonOrderList); |
| | | return commonOrderList; |
| | | } |
| | | |
| | | private void addConfirmMQMsg(List<CommonOrderAddResultDTO> resultList) { |
| | | |
| | | // 订单是否新增或者更新过 |
| | | boolean isAddOrUpdate = false; |
| | | for (CommonOrderAddResultDTO dto : resultList) |
| | | if (dto.getType() == CommonOrderAddResultDTO.TYPE_ADD |
| | | || dto.getType() == CommonOrderAddResultDTO.TYPE_UPDATE) { |
| | | isAddOrUpdate = true; |
| | | break; |
| | | } |
| | | boolean hasSettleOrder = false; |
| | | // 查询是否有结算的订单 |
| | | if (isAddOrUpdate) { |
| | | for (CommonOrderAddResultDTO dto : resultList) { |
| | | if (dto.getCommonOrder().getSettleTime() != null && dto.getCommonOrder().getSettlement() != null) { |
| | | hasSettleOrder = true; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | // 有结算的订单 |
| | | if (hasSettleOrder) { |
| | | if (!Constant.IS_TEST) { |
| | | // 统计结算金额 |
| | | BigDecimal settlement = new BigDecimal("0"); |
| | | CommonOrder firstOrder = null; |
| | | for (CommonOrderAddResultDTO dto : resultList) |
| | | if (dto.getCommonOrder().getSettlement() != null) { |
| | | settlement = settlement.add(dto.getCommonOrder().getSettlement()); |
| | | if (firstOrder == null) |
| | | firstOrder = dto.getCommonOrder(); |
| | | } |
| | | if (firstOrder != null) { |
| | | Date placeDate = firstOrder.getThirdCreateTime(); |
| | | OrderConfirmMQMsg mqMsg = new OrderConfirmMQMsg(firstOrder.getOrderNo(), firstOrder.getSourceType(), |
| | | settlement, firstOrder.getUserInfo().getId(), placeDate, new Date()); |
| | | Message msg = MQMsgBodyFactory.create(MQTopicName.TOPIC_ORDER, OrderTopicTagEnum.orderConfirm, |
| | | mqMsg); |
| | | orderProducer.send(msg); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | |
| | | newCommonOrder.setUserInfo(new UserInfo(uid)); |
| | | commonOrderList.add(addCommonOrder(newCommonOrder)); |
| | | } |
| | | addConfirmMQMsg(commonOrderList); |
| | | return commonOrderList; |
| | | } |
| | | |
| | |
| | | return commonOrderMapper.countSearchOrderByUid(uid, list); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public List<CommonOrder> getMinSettleTimeAndUid() { |
| | | return commonOrderMapper.getMinSettleTimeAndUid(); |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public List<CommonOrderVO> searchOrderByUid(AcceptData acceptData, int page, int size, Long uid, List<ESOrder> list) |
| | | throws Exception { |
| | |
| | | // 2019.8.1开始返回维权信息 |
| | | Date august = TimeUtil.parse("2019-08-01"); |
| | | |
| | | // 当前用户是否VIP |
| | | boolean vip = userVIPInfoService.isVIP(uid); |
| | | // 当前用户是否可以使用奖励券 |
| | | boolean isvip = userInviteService.verifyVIP(uid); |
| | | // 是否存在奖励券 |
| | | boolean hasRewardCoupon = userSystemCouponService.getValidRebateCoupon(uid); |
| | | |
| | |
| | | if (sourceType.equals(commonOrder.getSourceType()) && orderNo.equals(commonOrder.getOrderNo())) { |
| | | CommonOrderGoodsVO commonGoodsVO = new CommonOrderGoodsVO(); |
| | | PropertyUtils.copyProperties(commonGoodsVO, goods); |
| | | commonGoodsVO.setGoodsType(sourceType); |
| | | if (commonGoodsVO.getGoodsType() == null) { |
| | | commonGoodsVO.setGoodsType(sourceType); |
| | | } |
| | | |
| | | // 淘宝商品图片处理 |
| | | String picture = commonGoodsVO.getPicture(); |
| | |
| | | } |
| | | |
| | | // 订单类型为空时 已商品类为准 |
| | | Integer orderType = order.getOrderType(); |
| | | if (orderType == null) { |
| | | String shopType = commonGoodsVO.getShopType(); |
| | | if (CommonOrderGoodsVO.TYPE_TAOBAO.equalsIgnoreCase(shopType)) { |
| | | order.setOrderType(1); |
| | | } else if (CommonOrderGoodsVO.TYPE_TMALL.equalsIgnoreCase(shopType)) { |
| | | order.setOrderType(2); |
| | | } |
| | | String shopType = commonGoodsVO.getShopType(); |
| | | if (CommonOrderGoodsVO.TYPE_TAOBAO.equalsIgnoreCase(shopType)) { |
| | | order.setOrderType(1); |
| | | } else if (CommonOrderGoodsVO.TYPE_TMALL.equalsIgnoreCase(shopType)) { |
| | | order.setOrderType(2); |
| | | } |
| | | |
| | | Integer goodsType = commonGoodsVO.getGoodsType(); |
| | | if (goodsType != null & goodsType == 6) { |
| | | order.setOrderType(5); // 饿了么订单 |
| | | if (goodsType != null & goodsType == Constant.SOURCE_TYPE_ELME) { |
| | | order.setOrderType(Constant.SOURCE_TYPE_ELME); // 饿了么订单 |
| | | } |
| | | |
| | | order.getListOrderGoods().add(commonGoodsVO); |
| | | } |
| | | } |
| | | |
| | | |
| | | // 订单类型 |
| | | if (sourceType == Constant.SOURCE_TYPE_TAOBAO) { |
| | | Integer orderType = order.getOrderType(); |
| | | if (orderType == null) { |
| | | order.setOrderType(1); |
| | | } |
| | | } else if (sourceType == Constant.SOURCE_TYPE_JD) { |
| | | order.setOrderType(3); |
| | | } else if (sourceType == Constant.SOURCE_TYPE_PDD) { |
| | | order.setOrderType(4); |
| | | } |
| | | |
| | | |
| | | Date thirdCreateTime = order.getThirdCreateTime(); |
| | | if (thirdCreateTime != null) { |
| | |
| | | order.setReceiveTime("收货时间:" + format.format(settleTime)); |
| | | } |
| | | |
| | | // 订单类型 |
| | | if (sourceType == Constant.SOURCE_TYPE_TAOBAO) { |
| | | Integer orderType = order.getOrderType(); |
| | | if (orderType == null) |
| | | order.setOrderType(1); |
| | | } else if (sourceType == Constant.SOURCE_TYPE_JD) { |
| | | order.setOrderType(3); |
| | | } else if (sourceType == Constant.SOURCE_TYPE_PDD) { |
| | | order.setOrderType(4); |
| | | } |
| | | |
| | | /* 订单状态 转换处理 */ |
| | | String orderStateContent = ""; |
| | |
| | | } |
| | | |
| | | |
| | | // 2.1显示返利说明连接> |
| | | // 2.1显示返利说明连接> 未失效-自购-分享 |
| | | if (VersionUtil.greaterThan_2_1(acceptData.getPlatform(), acceptData.getVersion())) { |
| | | if (CommonOrder.STATE_SX != orderState && thirdCreateTime.getTime() > TimeUtil.convertDateToTemp(Constant.ORDER_SHOW_BRACE_TIME)) { |
| | | if (CommonOrder.STATE_SX != orderState && thirdCreateTime.getTime() > TimeUtil.convertDateToTemp(Constant.ORDER_SHOW_BRACE_TIME) |
| | | && ((HongBaoV2.TYPE_ZIGOU == hongBaoType || 2 == hongBaoType) || HongBaoV2.TYPE_SHARE_GOODS == hongBaoType) ) { |
| | | String rebateLink = configService.get(ConfigKeyEnum.orderRebateDescLink.getKey()); |
| | | order.setRebateLink(rebateLink + "?orderNo=" + orderNo +"&sourceType=" + sourceType); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | BigDecimal hongBao = order.getHongBao(); |
| | | if (hongBao == null) { |
| | |
| | | List<TaoBaoWeiQuanOrder> listWQ = taoBaoWeiQuanOrderMapper |
| | | .selectListByOrderIdAndState(order.getOrderNo(), "维权成功"); |
| | | |
| | | boolean isPart = false;// 默认失效 |
| | | BigDecimal weiQuanMoney = getWeiQuanMoney(listWQ, sourceType, uid); |
| | | if (settleTime != null && august != null && settleTime.getTime() > august.getTime()) { |
| | | orderStateContent = "售后成功"; |
| | |
| | | if (HongBaoV2.TYPE_ZIGOU == hongBaoType) { |
| | | // 奖励订单、免单 使用记录 |
| | | if (sourceType == null) { |
| | | couponFactoryNew(order, hasRewardCoupon, hongBaoState, hongBaoType, null, uid, vip); |
| | | couponFactoryNew(order, hasRewardCoupon, hongBaoState, hongBaoType, null, uid, isvip); |
| | | } else if (sourceType == Constant.SOURCE_TYPE_TAOBAO) { |
| | | couponFactoryNew(order, hasRewardCoupon, hongBaoState, hongBaoType, listRecordTB, uid, vip); |
| | | couponFactoryNew(order, hasRewardCoupon, hongBaoState, hongBaoType, listRecordTB, uid, isvip); |
| | | } else if (sourceType == Constant.SOURCE_TYPE_JD) { |
| | | couponFactoryNew(order, hasRewardCoupon, hongBaoState, hongBaoType, listRecordJD, uid, vip); |
| | | couponFactoryNew(order, hasRewardCoupon, hongBaoState, hongBaoType, listRecordJD, uid, isvip); |
| | | } else if (sourceType == Constant.SOURCE_TYPE_PDD) { |
| | | couponFactoryNew(order, hasRewardCoupon, hongBaoState, hongBaoType, listRecordPDD, uid, vip); |
| | | couponFactoryNew(order, hasRewardCoupon, hongBaoState, hongBaoType, listRecordPDD, uid, isvip); |
| | | } |
| | | } |
| | | |