| | |
| | | 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.entity.order.HongBaoOrder; |
| | | import com.yeshi.fanli.entity.order.InviteOrderSubsidy; |
| | | import com.yeshi.fanli.entity.pdd.PDDOrder; |
| | | import com.yeshi.fanli.entity.system.ConfigKeyEnum; |
| | | import com.yeshi.fanli.entity.system.SystemCoupon.CouponTypeEnum; |
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief; |
| | | import com.yeshi.fanli.entity.taobao.TaoBaoOrder; |
| | |
| | | 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.taobao.TaoBaoOrderUtil; |
| | | 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; |
| | | import com.yeshi.fanli.vo.msg.ClientTextStyleVO; |
| | | import com.yeshi.fanli.vo.order.CommonOrderGoodsVO; |
| | | import com.yeshi.fanli.vo.order.CommonOrderVO; |
| | |
| | | |
| | | @Resource |
| | | private UserInfoService userInfoService; |
| | | |
| | | @Resource(name = "producer") |
| | | private Producer orderProducer; |
| | | |
| | | // 奖励订单图片 |
| | | public final static String PIC_REWARD = "http://img.flqapp.com/resource/order/order_state_reward.png"; |
| | |
| | | } |
| | | |
| | | // 数据加工重新组织 |
| | | orderVOFactory(acceptData, listOrder, listGoods, uid); |
| | | if (VersionUtil.greaterThan_2_1(acceptData.getPlatform(), acceptData.getVersion())) { |
| | | orderVOFactoryNew(acceptData, listOrder, listGoods, uid); |
| | | } else { |
| | | orderVOFactory(acceptData, listOrder, listGoods, uid); |
| | | } |
| | | |
| | | return listOrder; |
| | | } |
| | |
| | | } |
| | | Map<Long, Boolean> vipUserMap = userVIPInfoService.listByUids(needSelectVIPUidList); |
| | | |
| | | |
| | | // 设置是否为vip订单 |
| | | for (CommonOrderVO order : listOrder) { |
| | | if (order.getHongBaoType() == HongBaoV2.TYPE_YIJI || order.getHongBaoType() == HongBaoV2.TYPE_ERJI |
| | |
| | | boolean vip = userVIPInfoService.isVIP(uid); |
| | | // 是否存在奖励券 |
| | | boolean hasRewardCoupon = userSystemCouponService.getValidRebateCoupon(uid); |
| | | |
| | | for (CommonOrderVO order : listOrder) { |
| | | String orderNo = order.getOrderNo(); |
| | | Integer sourceType = order.getSourceType(); |
| | | Integer hongBaoType = order.getHongBaoType(); |
| | | |
| | | // 商品信息组合 |
| | | for (CommonOrderVO commonOrder : listGoods) { |
| | |
| | | } |
| | | commonGoodsVO.setActualPay("付款金额:¥" + totalSettlement); |
| | | |
| | | Integer hongBaoType = order.getHongBaoType(); |
| | | |
| | | // 邀请订单信息保护 |
| | | if (HongBaoV2.TYPE_YAOQING == hongBaoType || HongBaoV2.TYPE_YIJI == hongBaoType |
| | | || HongBaoV2.TYPE_ERJI == hongBaoType || HongBaoV2.TYPE_SHARE_YIJI == hongBaoType |
| | |
| | | } |
| | | |
| | | Date thirdCreateTime = order.getThirdCreateTime(); |
| | | if (thirdCreateTime != null) { |
| | | order.setDownTime("下单时间:" + format.format(thirdCreateTime)); |
| | | order.setObtainTime(thirdCreateTime.getTime()); |
| | | } |
| | | order.setDownTime("下单时间:" + format.format(thirdCreateTime)); |
| | | order.setObtainTime(thirdCreateTime.getTime()); |
| | | |
| | | Date settleTime = order.getSettleTime(); |
| | | if (settleTime != null) { |
| | |
| | | // 订单标识 |
| | | List<String> signList = new ArrayList<String>(); |
| | | /* 订单返利类型 转换 */ |
| | | Integer hongBaoType = order.getHongBaoType(); |
| | | if (HongBaoV2.TYPE_ZIGOU == hongBaoType || 2 == hongBaoType) { |
| | | // 自购 |
| | | hongbaoInfo = "返利"; |
| | |
| | | wholeOrderState = CommonOrder.STATE_WHOLE_ORDER_BUFENYOUXIAO; |
| | | |
| | | for (TaoBaoOrder taoBaoOrder : taoBaoOrders) { |
| | | CommonOrder newCommonOrder = TaoBaoOrderUtil.convert(taoBaoOrder); |
| | | CommonOrder newCommonOrder = CommonOrderFactory.create(taoBaoOrder); |
| | | CommonOrderGoods cog = new CommonOrderGoods(); |
| | | cog.setGoodsId(taoBaoOrder.getAuctionId() + ""); |
| | | cog.setGoodsType(Constant.SOURCE_TYPE_TAOBAO); |
| | |
| | | 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) |
| | |
| | | @Override |
| | | public List<CommonOrderVO> listQuery(long start, int count, Integer keyType, String key, Integer state, |
| | | Integer type, Integer orderState, String startTime, String endTime, Integer source, List<Long> listShopId, |
| | | List<Long> listGoodsId, Date minTime, BigDecimal money,BigDecimal payment) throws CommonOrderException { |
| | | List<Long> listGoodsId, Date minTime, BigDecimal money, BigDecimal payment) throws CommonOrderException { |
| | | |
| | | List<CommonOrderVO> list = null; |
| | | |
| | |
| | | startTime, endTime, source, payment); |
| | | } else { |
| | | list = commonOrderMapper.listQuery(start, count, keyType, key, state, type, orderState, startTime, endTime, |
| | | source, listShopId, listGoodsId, minTime, money,payment); |
| | | source, listShopId, listGoodsId, minTime, money, payment); |
| | | } |
| | | |
| | | if (list == null) { |
| | |
| | | @Override |
| | | public long countQuery(Integer keyType, String key, Integer state, Integer type, Integer orderState, |
| | | String startTime, String endTime, Integer source, List<Long> listShopId, List<Long> listGoodsId, |
| | | Date minTime, BigDecimal money,BigDecimal payment) throws CommonOrderException { |
| | | Date minTime, BigDecimal money, BigDecimal payment) throws CommonOrderException { |
| | | if (StringUtil.isNullOrEmpty(key) || keyType == 1) {// 搜索框无值或者按订单号搜索时都只搜索主订单 |
| | | return commonOrderMapper.countQueryWithNoChild(keyType, key, state, type, orderState, startTime, endTime, |
| | | source, payment); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<CommonOrderVO> searchOrderByUid(int page, int size, Long uid, List<ESOrder> list) throws Exception { |
| | | public List<CommonOrderVO> searchOrderByUid(AcceptData acceptData, int page, int size, Long uid, List<ESOrder> list) |
| | | throws Exception { |
| | | List<CommonOrderVO> listVO = commonOrderMapper.searchOrderByUid((page - 1) * size, size, uid, list); |
| | | |
| | | // 订单信息为空 |
| | |
| | | } |
| | | |
| | | // 数据加工重新组织 |
| | | orderVOFactoryNew(listVO, listGoods, uid); |
| | | orderVOFactoryNew(acceptData, listVO, listGoods, uid); |
| | | |
| | | return listVO; |
| | | } |
| | |
| | | * @param listGoods |
| | | * @param uid |
| | | */ |
| | | private void orderVOFactoryNew(List<CommonOrderVO> listOrder, List<CommonOrderVO> listGoods, Long uid) |
| | | throws Exception { |
| | | private void orderVOFactoryNew(AcceptData acceptData, List<CommonOrderVO> listOrder, List<CommonOrderVO> listGoods, |
| | | Long uid) throws Exception { |
| | | List<String> listTB = new ArrayList<String>(); |
| | | List<String> listJD = new ArrayList<String>(); |
| | | List<String> listPDD = new ArrayList<String>(); |
| | |
| | | || order.getHongBaoType() == HongBaoV2.TYPE_SHARE_ERJI) |
| | | needSelectVIPUidList.add(Long.parseLong(order.getUserId())); |
| | | } |
| | | Map<Long, Boolean> vipUserMap = userVIPInfoService.listByUids(needSelectVIPUidList); |
| | | |
| | | // 设置是否为vip订单 |
| | | for (CommonOrderVO order : listOrder) { |
| | | if (order.getHongBaoType() == HongBaoV2.TYPE_YIJI || order.getHongBaoType() == HongBaoV2.TYPE_ERJI |
| | | || order.getHongBaoType() == HongBaoV2.TYPE_SHARE_ERJI |
| | | || order.getHongBaoType() == HongBaoV2.TYPE_SHARE_ERJI) { |
| | | if (vipUserMap.get(Long.parseLong(order.getUserId())) != null |
| | | && vipUserMap.get(Long.parseLong(order.getUserId())) == true) |
| | | order.setVipOrder(true); |
| | | else |
| | | order.setVipOrder(false); |
| | | } else |
| | | order.setVipOrder(false); |
| | | |
| | | if (order.isVipOrder()) |
| | | order.setVipOrderDesc("订单来源:由超级会员的粉丝产生"); |
| | | Integer urank = order.getUrank(); |
| | | if (urank != null) { |
| | | String levelName = UserLevelUtil.getLevelName(urank); |
| | | if (!StringUtil.isNullOrEmpty(levelName)) { |
| | | order.setOrderDesc("订单来源:" + levelName); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy.MM.dd HH:mm"); |
| | |
| | | for (CommonOrderVO order : listOrder) { |
| | | String orderNo = order.getOrderNo(); |
| | | Integer sourceType = order.getSourceType(); |
| | | Integer hongBaoType = order.getHongBaoType(); |
| | | |
| | | // 商品信息组合 |
| | | for (CommonOrderVO commonOrder : listGoods) { |
| | |
| | | } |
| | | commonGoodsVO.setActualPay("付款金额:¥" + totalSettlement); |
| | | |
| | | Integer hongBaoType = order.getHongBaoType(); |
| | | // 邀请订单信息保护 |
| | | if (HongBaoV2.TYPE_YAOQING == hongBaoType || HongBaoV2.TYPE_YIJI == hongBaoType |
| | | || HongBaoV2.TYPE_ERJI == hongBaoType || HongBaoV2.TYPE_SHARE_YIJI == hongBaoType |
| | |
| | | } else if (CommonOrderGoodsVO.TYPE_TMALL.equalsIgnoreCase(shopType)) { |
| | | order.setOrderType(2); |
| | | } |
| | | } |
| | | |
| | | Integer goodsType = commonGoodsVO.getGoodsType(); |
| | | if (goodsType != null & goodsType == 6) { |
| | | order.setOrderType(5); // 饿了么订单 |
| | | } |
| | | |
| | | order.getListOrderGoods().add(commonGoodsVO); |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | // 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)) { |
| | | String rebateLink = configService.get(ConfigKeyEnum.orderRebateDescLink.getKey()); |
| | | order.setRebateLink(rebateLink + "?orderNo=" + orderNo +"&sourceType=" + sourceType); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | BigDecimal hongBao = order.getHongBao(); |
| | | if (hongBao == null) { |
| | | hongBao = new BigDecimal(0); |
| | |
| | | // 订单标识 |
| | | List<String> signList = new ArrayList<String>(); |
| | | /* 订单返利类型 转换 */ |
| | | Integer hongBaoType = order.getHongBaoType(); |
| | | if (HongBaoV2.TYPE_ZIGOU == hongBaoType || 2 == hongBaoType) { |
| | | // 自购 |
| | | hongbaoInfo = "返利"; |
| | |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public Date getThirdCreateTime(String orderId, int sourceType) { |
| | | List<CommonOrder> list = listBySourceTypeAndOrderId(sourceType, orderId); |
| | | if (list == null || list.size() == 0) |
| | | return null; |
| | | return list.get(0).getThirdCreateTime(); |
| | | } |
| | | |
| | | } |