| | |
| | | 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.TaoBaoOrderGoodsMapper; |
| | | 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.entity.jd.JDGoods; |
| | | import com.yeshi.fanli.entity.jd.JDOrder; |
| | | import com.yeshi.fanli.entity.jd.JDOrderItem; |
| | | import com.yeshi.fanli.entity.money.InviteOrderSubsidyDebt; |
| | | import com.yeshi.fanli.entity.order.CommonOrder; |
| | | import com.yeshi.fanli.entity.order.CommonOrderGoods; |
| | | import com.yeshi.fanli.entity.order.CommonOrderTradeIdMap; |
| | |
| | | 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.entity.taobao.TaoBaoOrderGoods; |
| | | import com.yeshi.fanli.entity.taobao.TaoBaoWeiQuanOrder; |
| | | import com.yeshi.fanli.exception.order.CommonOrderException; |
| | | import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException; |
| | |
| | | import com.yeshi.fanli.service.inter.config.ConfigService; |
| | | import com.yeshi.fanli.service.inter.config.SystemCouponService; |
| | | import com.yeshi.fanli.service.inter.goods.CommonGoodsService; |
| | | import com.yeshi.fanli.service.inter.money.InviteOrderSubsidyDebtService; |
| | | import com.yeshi.fanli.service.inter.order.CommonOrderService; |
| | | import com.yeshi.fanli.service.inter.order.HongBaoOrderService; |
| | | import com.yeshi.fanli.service.inter.order.HongBaoV2Service; |
| | |
| | | |
| | | @Resource |
| | | private InviteOrderSubsidyService inviteOrderSubsidyService; |
| | | |
| | | @Resource |
| | | private InviteOrderSubsidyDebtService inviteOrderSubsidyDebtService; |
| | | |
| | | @Resource |
| | | private UserVIPInfoService userVIPInfoService; |
| | |
| | | |
| | | @Resource |
| | | private UserLevelManager userLevelManager; |
| | | |
| | | @Resource |
| | | private TaoBaoOrderGoodsMapper taoBaoOrderGoodsMapper; |
| | | |
| | | @Resource(name = "producer") |
| | | private Producer orderProducer; |
| | |
| | | |
| | | // 当前用户是否VIP |
| | | boolean vip = userInviteService.verifyVIP(uid); |
| | | |
| | | |
| | | // 是否存在奖励券 |
| | | boolean hasRewardCoupon = userSystemCouponService.getValidRebateCoupon(uid); |
| | | for (CommonOrderVO order : listOrder) { |
| | |
| | | if (HongBaoV2.TYPE_ZIGOU == hongBaoType) { |
| | | // 奖励订单、免单 使用记录 |
| | | if (sourceType == null) { |
| | | couponFactory(order, hasRewardCoupon, hongBaoState, hongBaoType, null, uid, vip, acceptData, hongBao); |
| | | couponFactory(order, hasRewardCoupon, hongBaoState, hongBaoType, null, uid, vip, acceptData, |
| | | hongBao); |
| | | } else if (sourceType == Constant.SOURCE_TYPE_TAOBAO) { |
| | | couponFactory(order, hasRewardCoupon, hongBaoState, hongBaoType, listRecordTB, uid, vip, |
| | | acceptData, hongBao); |
| | | couponFactory(order, hasRewardCoupon, hongBaoState, hongBaoType, listRecordTB, uid, vip, acceptData, |
| | | hongBao); |
| | | } else if (sourceType == Constant.SOURCE_TYPE_JD) { |
| | | couponFactory(order, hasRewardCoupon, hongBaoState, hongBaoType, listRecordJD, uid, vip, |
| | | acceptData, hongBao); |
| | | couponFactory(order, hasRewardCoupon, hongBaoState, hongBaoType, listRecordJD, uid, vip, acceptData, |
| | | hongBao); |
| | | } else if (sourceType == Constant.SOURCE_TYPE_PDD) { |
| | | couponFactory(order, hasRewardCoupon, hongBaoState, hongBaoType, listRecordPDD, uid, vip, |
| | | acceptData, hongBao); |
| | | } |
| | | } |
| | | |
| | | // 分享、邀请 隐藏订单号 |
| | | if (HongBaoV2.TYPE_SHARE_GOODS == hongBaoType || HongBaoV2.TYPE_YAOQING == hongBaoType |
| | | || HongBaoV2.TYPE_YIJI == hongBaoType || HongBaoV2.TYPE_ERJI == hongBaoType |
| | | // 邀请 隐藏订单号 |
| | | if (HongBaoV2.TYPE_YAOQING == hongBaoType || HongBaoV2.TYPE_YIJI == hongBaoType || HongBaoV2.TYPE_ERJI == hongBaoType |
| | | || HongBaoV2.TYPE_SHARE_YIJI == hongBaoType || HongBaoV2.TYPE_SHARE_ERJI == hongBaoType) { |
| | | order.setOrderNo(UserUtil.filterOrderId(order.getOrderNo())); |
| | | } |
| | |
| | | * @param signList |
| | | */ |
| | | private void couponFactory(CommonOrderVO order, boolean hasRewardCoupon, Integer hongBaoState, Integer hongBaoType, |
| | | List<UserSystemCouponRecord> list, Long uid, boolean vip, AcceptData acceptData, BigDecimal hongBao) throws Exception { |
| | | List<UserSystemCouponRecord> list, Long uid, boolean vip, AcceptData acceptData, BigDecimal hongBao) |
| | | throws Exception { |
| | | |
| | | // 是否免单商品 |
| | | boolean freeOrder = false; |
| | |
| | | } |
| | | |
| | | // 使用奖励券 金额额限制 |
| | | if (hongBao.compareTo(Constant.REWARD_COUPON_LIMIT_MONEY) > 0){ |
| | | if (hongBao.compareTo(Constant.REWARD_COUPON_LIMIT_MONEY) > 0) { |
| | | return; |
| | | } |
| | | |
| | | |
| | | // 是否可使用奖励券 |
| | | if (!rewardSuccess && !freeOrder && HongBaoV2.TYPE_ZIGOU == hongBaoType |
| | | && HongBaoV2.STATE_YILINGQU == hongBaoState && !vip && CommonOrder.STATE_WQ != order.getState()) { |
| | |
| | | return commonOrderMapper.countUserOrderToApp(uid, type, startTime, endTime, day, source, state, stateOrder); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public BigDecimal getWeiQuanMoney(List<TaoBaoWeiQuanOrder> listWQ, int sourceType, Long uid) { |
| | | BigDecimal weiQuanMoney = new BigDecimal(0); |
| | |
| | | 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()); |
| | | TaoBaoOrderGoods goods = taoBaoOrderGoodsMapper.selectByTradeId(taoBaoOrder.getTradeId()); |
| | | if (goods == null) { |
| | | cog.setPicture("http://img.flqapp.com/resource/goods/elme_picture_demo.png"); |
| | | cog.setTitle(taoBaoOrder.getTitle()); |
| | | } else { |
| | | cog.setPicture(goods.getImg()); |
| | | cog.setTitle(goods.getTitle()); |
| | | } |
| | | newCommonOrder.setCommonOrderGoods(cog); |
| | | } else { |
| | | cog.setGoodsId(taoBaoOrder.getAuctionId() + ""); |
| | |
| | | return listVO; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public Date getThirdCreateTime(String orderId, int sourceType) { |
| | | List<CommonOrder> list = listBySourceTypeAndOrderId(sourceType, orderId); |
| | |
| | | return list.get(0).getThirdCreateTime(); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public List<CommonOrderVO> getOrderList(AcceptData acceptData, Integer page, Long uid, Integer state, Integer type, |
| | | Integer orderState, String orderNo, String startTime, String endTime, Integer dateType, |
| | |
| | | return commonOrderMapper.countOrderList(uid, state, type, orderState, orderNo, startTime, endTime, dateType, |
| | | listSource); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 订单信息加工 |
| | | * |
| | |
| | | || order.getHongBaoType() == HongBaoV2.TYPE_SHARE_ERJI) { |
| | | Integer urank = order.getUrank(); |
| | | if (urank != null) { |
| | | String levelName = UserLevelUtil.getLevelName(urank); |
| | | if (!StringUtil.isNullOrEmpty(levelName)) { |
| | | order.setOrderDesc("订单来源:" + levelName); |
| | | UserLevelEnum levelEnum = UserLevelUtil.getByOrderRank(urank); |
| | | if (levelEnum != null) { |
| | | levelEnum = UserLevelUtil.getShowLevel(levelEnum); |
| | | order.setOrderDesc("订单来源:" + levelEnum.getName()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | Integer sourceType = order.getSourceType(); |
| | | if (sourceType == null) { |
| | | continue; |
| | |
| | | if (listPDD.size() > 0) { |
| | | listRecordPDD = userSystemCouponRecordService.getRecordByOrderNoList(Constant.SOURCE_TYPE_PDD, listPDD); |
| | | } |
| | | |
| | | |
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy.MM.dd HH:mm"); |
| | | SimpleDateFormat formatday = new SimpleDateFormat("yyyy.MM.dd"); |
| | |
| | | order.setReceiveTime("收货时间:" + format.format(settleTime)); |
| | | } |
| | | |
| | | |
| | | Map<String, String> orderStateMap = new HashMap<String, String>(); |
| | | // 订单状态 |
| | | Integer orderState = order.getState(); |
| | |
| | | orderState = buFenOrder.getState(); |
| | | } |
| | | } |
| | | |
| | | |
| | | // 显示返利说明连接> 未失效 |
| | | 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); |
| | | } |
| | | |
| | | |
| | | // 红包信息 |
| | | List<HongBaoOrder> hongBaoOrderList = hongBaoOrderService.listDetailByOrderIdAndSourceTypeAndUid(orderNo, sourceType, uid); |
| | | List<HongBaoOrder> hongBaoOrderList = hongBaoOrderService.listDetailByOrderIdAndSourceTypeAndUid(orderNo, |
| | | sourceType, uid); |
| | | HongBaoCountVO hongBaoCountVO = hongBaoOrderService.getHongBaoCountVO(hongBaoOrderList); |
| | | BigDecimal hongBao = hongBaoCountVO.getValidMoney(); |
| | | Integer hongBaoState = hongBaoCountVO.getCurrentState(); |
| | | |
| | | |
| | | |
| | | /* 订单状态 转换处理 */ |
| | | String orderStateContent = ""; |
| | | if (CommonOrder.STATE_FK == orderState) { |
| | |
| | | orderStateContent = "已售后"; |
| | | if (sourceType == Constant.SOURCE_TYPE_TAOBAO) { |
| | | /* 订单维权 判断是否全部维权 */ |
| | | List<TaoBaoWeiQuanOrder> listWQ = taoBaoWeiQuanOrderMapper.selectListByOrderIdAndState(order.getOrderNo(), "维权成功"); |
| | | List<TaoBaoWeiQuanOrder> listWQ = taoBaoWeiQuanOrderMapper |
| | | .selectListByOrderIdAndState(order.getOrderNo(), "维权成功"); |
| | | BigDecimal weiQuanMoney = getWeiQuanMoney(listWQ, sourceType, uid); |
| | | hongBao = MoneyBigDecimalUtil.sub(hongBao, weiQuanMoney); |
| | | } |
| | |
| | | orderStateMap.put("fontColor", "#666666"); |
| | | order.setOrderState(orderStateMap); |
| | | |
| | | String hongbaoInfo = ""; |
| | | // 订单标识 |
| | | List<String> signList = new ArrayList<String>(); |
| | | /* 订单返利类型 转换 */ |
| | | if (HongBaoV2.TYPE_ZIGOU == hongBaoType || 2 == hongBaoType) { |
| | | // 自购 |
| | | hongbaoInfo = "返利"; |
| | | order.setOrderOrigin("1"); |
| | | order.setHongBaoTypePic(CommonOrder.TYPE_FANLI); |
| | | signList.add(CommonOrder.TYPE_FANLI); |
| | | |
| | | |
| | | // 是否已使用奖励券、免单券情况 |
| | | if (sourceType == Constant.SOURCE_TYPE_TAOBAO) { |
| | | if (sourceType == Constant.SOURCE_TYPE_TAOBAO) { |
| | | couponUseFactory(order, listRecordTB); |
| | | } else if (sourceType == Constant.SOURCE_TYPE_JD) { |
| | | couponUseFactory(order, listRecordJD); |
| | |
| | | } |
| | | } else if (HongBaoV2.TYPE_SHARE_GOODS == hongBaoType) { |
| | | // 分享 |
| | | hongbaoInfo = "奖金"; |
| | | order.setOrderOrigin("2"); |
| | | order.setHongBaoTypePic(CommonOrder.TYPE_SHARE); |
| | | signList.add(CommonOrder.TYPE_SHARE); |
| | |
| | | || HongBaoV2.TYPE_YAOQING == hongBaoType || HongBaoV2.TYPE_YIJI == hongBaoType |
| | | || HongBaoV2.TYPE_ERJI == hongBaoType) { |
| | | // 邀请订单 |
| | | hongbaoInfo = "收益"; |
| | | order.setOrderOrigin("3"); |
| | | order.setHongBaoTypePic(CommonOrder.TYPE_INVITE); |
| | | signList.add(CommonOrder.TYPE_INVITE); |
| | | |
| | | // 红包加上补贴金额 |
| | | InviteOrderSubsidy orderSubsidy = inviteOrderSubsidyService.getByOrderNoAndType(uid, orderNo, sourceType); |
| | | if (orderSubsidy != null && orderSubsidy.getMoney() != null) { |
| | | BigDecimal subsidyMoney = orderSubsidy.getMoney(); |
| | | // 维权金额 |
| | | InviteOrderSubsidyDebt subsidyDebt = inviteOrderSubsidyDebtService.getBySourceId(orderSubsidy.getId()); |
| | | if (subsidyDebt != null && subsidyDebt.getOriginMoney() != null) { |
| | | subsidyMoney = subsidyMoney.subtract(subsidyDebt.getOriginMoney()); |
| | | } |
| | | // 最终补贴 |
| | | if (subsidyMoney.compareTo(new BigDecimal(0)) > 0) { |
| | | hongBao = hongBao.add(subsidyMoney); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | order.setSignList(signList); |
| | | |
| | | String hongBaoDate = null; |
| | |
| | | stateMap.put("content", stateContent); |
| | | stateMap.put("fontColor", stateFontColor); |
| | | order.setAccountState(stateMap); |
| | | hongbaoInfo = hongBaoState_Str + hongbaoInfo; |
| | | |
| | | |
| | | Map<String, String> hongBaoMap = new HashMap<String, String>(); |
| | | hongBaoMap.put("content", hongbaoInfo + " ¥" + hongBao.setScale(2, BigDecimal.ROUND_DOWN).toString()); |
| | | hongBaoMap.put("content", |
| | | hongBaoState_Str + "收益 ¥" + hongBao.setScale(2, BigDecimal.ROUND_DOWN).toString()); |
| | | hongBaoMap.put("fontColor", hongbaoInfoFontColor); |
| | | order.setHongBaoInfo(hongBaoMap); |
| | | |
| | | // 分享、邀请 隐藏订单号 |
| | | if (HongBaoV2.TYPE_YAOQING == hongBaoType || HongBaoV2.TYPE_YIJI == hongBaoType || HongBaoV2.TYPE_ERJI == hongBaoType |
| | | || HongBaoV2.TYPE_SHARE_YIJI == hongBaoType || HongBaoV2.TYPE_SHARE_ERJI == hongBaoType) { |
| | | if (HongBaoV2.TYPE_YAOQING == hongBaoType || HongBaoV2.TYPE_YIJI == hongBaoType |
| | | || HongBaoV2.TYPE_ERJI == hongBaoType || HongBaoV2.TYPE_SHARE_YIJI == hongBaoType |
| | | || HongBaoV2.TYPE_SHARE_ERJI == hongBaoType) { |
| | | order.setOrderNo(UserUtil.filterOrderId(order.getOrderNo())); |
| | | } |
| | | } |
| | |
| | | if (UserSystemCouponRecord.STATE_FREE_ON == state) { |
| | | text = "免单中"; |
| | | } else if (UserSystemCouponRecord.STATE_SUCCESS == state) { |
| | | text = "免单成功"; |
| | | } |
| | | text = "已免单"; |
| | | } |
| | | } |
| | | break; |
| | | } |
| | |
| | | order.setRewardDetail(rewardMap); |
| | | } |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public long countOrderByUidAndSettled(Long uid, BigDecimal payment) { |
| | | Long count = commonOrderMapper.countOrderByUidAndSettled(uid, payment); |
| | | if (count == null) { |
| | | count = 0L; |
| | | } |
| | | return count; |
| | | } |
| | | |
| | | } |