| | |
| | | package com.yeshi.fanli.service.impl.order;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.text.ParseException;
|
| | | import java.text.SimpleDateFormat;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Date;
|
| | |
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.MoneyBigDecimalUtil;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | | import com.yeshi.fanli.util.VersionUtil;
|
| | | import com.yeshi.fanli.util.account.UserUtil;
|
| | | import com.yeshi.fanli.util.factory.CommonOrderGoodsFactory;
|
| | | import com.yeshi.fanli.util.factory.goods.CommonOrderFactory;
|
| | | 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.taobao.TaoBaoUtil;
|
| | |
| | | import com.yeshi.fanli.vo.msg.ClientTextStyleVO;
|
| | | import com.yeshi.fanli.vo.order.CommonOrderGoodsVO;
|
| | | import com.yeshi.fanli.vo.order.CommonOrderVO;
|
| | | import com.yeshi.fanli.vo.order.WeiQuanInfo;
|
| | |
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | |
| | | @Override
|
| | | public long countGroupOrderNoByUid(Long uid, Integer state, Integer type, Integer orderState, String orderNo,
|
| | | String startTime, String endTime, Integer dateType, Integer source) throws CommonOrderException {
|
| | | return commonOrderMapper.countUserOrder(uid, state, type, orderState, orderNo, startTime, endTime, dateType, source);
|
| | | return commonOrderMapper.countUserOrder(uid, state, type, orderState, orderNo, startTime, endTime, dateType,
|
| | | source);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<CommonOrderVO> getOrderByUid(AcceptData acceptData,Integer page, Long uid, Integer state, Integer type, Integer orderState,
|
| | | String orderNo, String startTime, String endTime, Integer dateType, Integer source) throws CommonOrderException {
|
| | | public List<CommonOrderVO> getOrderByUid(AcceptData acceptData, Integer page, Long uid, Integer state, Integer type,
|
| | | Integer orderState, String orderNo, String startTime, String endTime, Integer dateType, Integer source)
|
| | | throws CommonOrderException {
|
| | |
|
| | | int pageSize = Constant.PAGE_SIZE;
|
| | |
|
| | |
| | | }
|
| | |
|
| | | @Override
|
| | | public long countBonusOrderNumber(Long uid, Integer type, Integer day, String startTime, String endTime, Integer source) {
|
| | | public long countBonusOrderNumber(Long uid, Integer type, Integer day, String startTime, String endTime,
|
| | | Integer source) {
|
| | | return commonOrderMapper.countBonusOrderNumber(uid, type, day, startTime, endTime, source);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public BigDecimal countBonusOrderMoney(Long uid, Integer type, Integer day, String startTime, String endTime, Integer source) {
|
| | | public BigDecimal countBonusOrderMoney(Long uid, Integer type, Integer day, String startTime, String endTime,
|
| | | Integer source) {
|
| | | return commonOrderMapper.countBonusOrderMoney(uid, type, day, startTime, endTime, source);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public Map<String, Object> countBonusOrderMoneyAndNumber(Long uid, Integer type, Integer day, String startTime,
|
| | | String endTime) {
|
| | | return commonOrderMapper.countBonusOrderMoneyAndNumber(uid, type, day, startTime, endTime);
|
| | | String endTime, Integer source) {
|
| | | return commonOrderMapper.countBonusOrderMoneyAndNumber(uid, type, day, startTime, endTime, source);
|
| | | }
|
| | |
|
| | | @Override
|
| | |
| | | return commonOrderMapper.countByUidAndOrderState(uid, type, startTime, endTime, day, source);
|
| | | }
|
| | |
|
| | | public void listDataFactory(AcceptData acceptData, List<CommonOrderVO> listOrder, List<CommonOrderVO> listGoods, Long uid) {
|
| | | public void listDataFactory(AcceptData acceptData, List<CommonOrderVO> listOrder, List<CommonOrderVO> listGoods,
|
| | | Long uid) {
|
| | |
|
| | | List<String> listNo = new ArrayList<String>();
|
| | | List<String> listTB = new ArrayList<String>();
|
| | | List<String> listJD = new ArrayList<String>();
|
| | | List<String> listPDD = new ArrayList<String>();
|
| | | for (CommonOrderVO commonOrderVO : listOrder) {
|
| | | listNo.add(commonOrderVO.getOrderNo());
|
| | | Integer sourceType = commonOrderVO.getSourceType();
|
| | | if (sourceType == null) {
|
| | | continue;
|
| | | } else if (sourceType == Constant.SOURCE_TYPE_TAOBAO) {
|
| | | listTB.add(commonOrderVO.getOrderNo());
|
| | | } else if (sourceType == Constant.SOURCE_TYPE_JD) {
|
| | | listJD.add(commonOrderVO.getOrderNo());
|
| | | } else if (sourceType == Constant.SOURCE_TYPE_PDD) {
|
| | | listPDD.add(commonOrderVO.getOrderNo());
|
| | | }
|
| | | }
|
| | |
|
| | | // 已经使用券订单
|
| | | List<UserSystemCouponRecord> couponRecordList = userSystemCouponRecordService.getRecordByOrderNoList(listNo);
|
| | | List<UserSystemCouponRecord> listRecordTB = null;
|
| | | if (listTB.size() > 0) {
|
| | | listRecordTB = userSystemCouponRecordService.getRecordByOrderNoList(Constant.SOURCE_TYPE_TAOBAO, listTB);
|
| | | }
|
| | |
|
| | | List<UserSystemCouponRecord> listRecordJD = null;
|
| | | if (listJD.size() > 0) {
|
| | | listRecordJD = userSystemCouponRecordService.getRecordByOrderNoList(Constant.SOURCE_TYPE_JD, listJD);
|
| | | }
|
| | |
|
| | | List<UserSystemCouponRecord> listRecordPDD = null;
|
| | | if (listPDD.size() > 0) {
|
| | | listRecordPDD = userSystemCouponRecordService.getRecordByOrderNoList(Constant.SOURCE_TYPE_PDD, listPDD);
|
| | | }
|
| | |
|
| | | /* 组合商品信息 */
|
| | | for (CommonOrderVO commonOrder : listGoods) {
|
| | |
|
| | | CommonOrderGoods goods = commonOrder.getCommonOrderGoods();
|
| | | if (goods == null) {
|
| | | continue;
|
| | |
| | |
|
| | | String orderNo1 = commonOrder.getOrderNo();
|
| | | Integer sourceType = commonOrder.getSourceType();
|
| | |
|
| | | for (CommonOrderVO order : listOrder) {
|
| | | String orderNo2 = order.getOrderNo();
|
| | | Integer sourceType2 = order.getSourceType();
|
| | |
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | commonGoodsVO.setGoodsType(sourceType2);
|
| | |
|
| | | String picture = commonGoodsVO.getPicture();
|
| | | if (!StringUtil.isNullOrEmpty(picture) && !picture.contains("320x320")) {
|
| | |
| | | // 实付款
|
| | | commonGoodsVO.setActualPay("付款金额:¥" + totalSettlement);
|
| | |
|
| | | listOrderGoods.add(commonGoodsVO);
|
| | |
|
| | | Integer orderType = order.getOrderType();
|
| | | if (orderType == null) {
|
| | | String shopType = commonGoodsVO.getShopType();
|
| | |
| | | order.setOrderType(1);
|
| | | } else if (CommonOrderGoodsVO.TYPE_TMALL.equalsIgnoreCase(shopType)) {
|
| | | order.setOrderType(2);
|
| | | } |
| | | |
| | | if (Constant.SOURCE_TYPE_JD == sourceType2) {
|
| | | order.setOrderType(3);
|
| | | } else if (Constant.SOURCE_TYPE_PDD == sourceType2) {
|
| | | order.setOrderType(4);
|
| | | }
|
| | | }
|
| | |
|
| | | listOrderGoods.add(commonGoodsVO);
|
| | | break;
|
| | | }
|
| | | }
|
| | |
| | |
|
| | | // 是否存在奖励券
|
| | | boolean hasRewardCoupon = userSystemCouponService.hasRewardCoupon(uid);
|
| | |
|
| | | // 2019.8.1开始返回维权信息
|
| | | Date august = null;
|
| | | try {
|
| | | august = TimeUtil.parse("2019-08-01");
|
| | | } catch (ParseException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | /* 组织订单状态 等信息 */
|
| | | for (CommonOrderVO order : listOrder) {
|
| | |
| | | Date settleTime = order.getSettleTime();
|
| | | if (settleTime != null) {
|
| | | order.setReceiveTime("收货时间:" + format.format(settleTime));
|
| | | }
|
| | |
|
| | | Integer sourceType2 = order.getSourceType();
|
| | | if (sourceType2 == Constant.SOURCE_TYPE_TAOBAO) {
|
| | | Integer orderType = order.getOrderType();
|
| | | if (orderType == null) {
|
| | | order.setOrderType(1);
|
| | | }
|
| | | } else if (sourceType2 == Constant.SOURCE_TYPE_JD) {
|
| | | order.setOrderType(3);
|
| | | } else if (sourceType2 == Constant.SOURCE_TYPE_PDD) {
|
| | | order.setOrderType(4);
|
| | | }
|
| | |
|
| | | /* 订单状态 转换处理 */
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | BigDecimal hongBao = order.getHongBao();
|
| | | if (hongBao == null) {
|
| | | hongBao = new BigDecimal(0);
|
| | | }
|
| | |
|
| | | if (CommonOrder.STATE_FK == orderState) {
|
| | | orderStateContent = "已付款";
|
| | | } else if (CommonOrder.STATE_JS == orderState) {
|
| | |
| | | } else if (CommonOrder.STATE_WQ == orderState) {
|
| | | orderStateContent = "已维权";
|
| | |
|
| | | /* 订单维权 判断是否全部维权 */
|
| | | List<TaoBaoWeiQuanOrder> listWQ = taoBaoWeiQuanOrderMapper
|
| | | .selectListByOrderIdAndState(order.getOrderNo(), "维权成功");
|
| | | Integer sourceType = order.getSourceType();
|
| | | if (sourceType != null && sourceType == Constant.SOURCE_TYPE_TAOBAO) {
|
| | | /* 订单维权 判断是否全部维权 */
|
| | | List<TaoBaoWeiQuanOrder> listWQ = taoBaoWeiQuanOrderMapper
|
| | | .selectListByOrderIdAndState(order.getOrderNo(), "维权成功");
|
| | |
|
| | | boolean isPart = false;// 默认失效
|
| | | boolean isPart = false;// 默认失效
|
| | | BigDecimal weiQuanMoney = new BigDecimal(0);
|
| | | if (listWQ != null && listWQ.size() > 0) {
|
| | | BigDecimal fanTotalMoney = new BigDecimal(0);
|
| | | for (TaoBaoWeiQuanOrder weiQuanOrder : listWQ) {
|
| | | BigDecimal fanMoney = weiQuanOrder.getFanMoney();
|
| | | if (fanMoney != null) {
|
| | | fanTotalMoney = MoneyBigDecimalUtil.add(fanTotalMoney, fanMoney);
|
| | | }
|
| | | weiQuanMoney = MoneyBigDecimalUtil.add(weiQuanOrder.getMoney(), weiQuanMoney);
|
| | | }
|
| | |
|
| | | if (listWQ != null && listWQ.size() > 0) {
|
| | | BigDecimal fanTotalMoney = new BigDecimal(0);
|
| | | for (TaoBaoWeiQuanOrder weiQuanOrder : listWQ) {
|
| | | BigDecimal fanMoney = weiQuanOrder.getFanMoney();
|
| | | if (fanMoney != null) {
|
| | | fanTotalMoney = MoneyBigDecimalUtil.add(fanTotalMoney, fanMoney);
|
| | | if (fanTotalMoney.compareTo(hongBao) < 0) {
|
| | | isPart = true;
|
| | | }
|
| | | }
|
| | |
|
| | | if (fanTotalMoney.compareTo(order.getHongBao()) < 0) {
|
| | | isPart = true;
|
| | | if (!VersionUtil.greaterThan_1_6_0(acceptData.getPlatform(), acceptData.getVersion())) {
|
| | | if (isPart) {
|
| | | hongBaoState = HongBaoV2.STATE_BUFENSHIXIAO; // 部分失效
|
| | | } else {
|
| | | hongBaoState = HongBaoV2.STATE_SHIXIAO; // 全部失效
|
| | | }
|
| | | } else {
|
| | | // 2019.8.1 返回维权信息
|
| | | if (settleTime != null && august != null && settleTime.getTime() > august.getTime()) {
|
| | | orderStateContent = "维权成功";
|
| | | WeiQuanInfo weiQuanInfo = new WeiQuanInfo();
|
| | | weiQuanInfo.setOldHongBao("¥" + hongBao.setScale(2, BigDecimal.ROUND_DOWN).toString());
|
| | | if (isPart) {
|
| | | // 维权失效金额=维权的金额*获得的红包/结算金额
|
| | | BigDecimal settlement = order.getSettlement();
|
| | | BigDecimal wqHongbao = MoneyBigDecimalUtil
|
| | | .div(MoneyBigDecimalUtil.mul(hongBao, settlement), settlement);
|
| | | weiQuanInfo.setWqHongBao(
|
| | | "维权:-¥" + wqHongbao.setScale(2, BigDecimal.ROUND_DOWN).toString());
|
| | | hongBao = MoneyBigDecimalUtil.sub(hongBao, wqHongbao);
|
| | | } else {
|
| | | weiQuanInfo
|
| | | .setWqHongBao("维权:-¥" + hongBao.setScale(2, BigDecimal.ROUND_DOWN).toString());
|
| | | hongBao = new BigDecimal(0);
|
| | | }
|
| | | order.setWeiQuanInfo(weiQuanInfo);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | if (isPart) {
|
| | | hongBaoState = HongBaoV2.STATE_BUFENSHIXIAO; // 部分失效
|
| | | } else {
|
| | | hongBaoState = HongBaoV2.STATE_SHIXIAO; // 全部失效
|
| | | }
|
| | | }
|
| | | orderStateMap.put("content", orderStateContent);
|
| | |
| | |
|
| | | hongbaoInfo = hongBaoState_Str + hongbaoInfo;
|
| | |
|
| | | BigDecimal hongBao = order.getHongBao();
|
| | | if (hongBao == null) {
|
| | | hongBao = new BigDecimal(0);
|
| | | }
|
| | | Map<String, String> hongBaoMap = new HashMap<String, String>();
|
| | | hongBaoMap.put("content", hongbaoInfo + " ¥" + hongBao.setScale(2, BigDecimal.ROUND_DOWN).toString());
|
| | | hongBaoMap.put("fontColor", hongbaoInfoFontColor);
|
| | | order.setHongBaoInfo(hongBaoMap);
|
| | |
|
| | | Integer sourceType = order.getSourceType();
|
| | | // 非自购的订单 不显示返利、免单详情
|
| | | if (HongBaoV2.TYPE_ZIGOU != hongBaoType) {
|
| | | // 订单标识
|
| | | order.setSignList(signList);
|
| | |
|
| | | } else {
|
| | |
|
| | | // 是否免单商品
|
| | | boolean freeOrder = false;
|
| | | // 是否奖励成功
|
| | | boolean rewardSuccess = false;
|
| | |
|
| | | // 奖励订单、免单 使用记录
|
| | | if (couponRecordList != null && couponRecordList.size() > 0) {
|
| | |
|
| | | for (UserSystemCouponRecord couponRecord : couponRecordList) {
|
| | | // 订单号匹配
|
| | | if (order.getOrderNo().equals(couponRecord.getOrderNo())) {
|
| | |
|
| | | String systemCouponType = couponRecord.getCouponType();
|
| | | Integer state = couponRecord.getState();
|
| | |
|
| | | // 奖励订单: 且成功
|
| | | if (CouponTypeEnum.rebatePercentCoupon.name().equals(systemCouponType)
|
| | | && UserSystemCouponRecord.STATE_SUCCESS == state) {
|
| | | rewardSuccess = true;
|
| | | signList.add(PIC_REWARD); // 加入奖励成功图片
|
| | |
|
| | | } else if (CouponTypeEnum.freeCoupon.name().equals(systemCouponType)
|
| | | || CouponTypeEnum.welfareFreeCoupon.name().equals(systemCouponType)) {
|
| | |
|
| | | if (UserSystemCouponRecord.STATE_FREE_ON == state) {
|
| | | // 免单中
|
| | | freeOrder = true;
|
| | | signList.add(PIC_FREE_ON);
|
| | | } else if (UserSystemCouponRecord.STATE_SUCCESS == state) {
|
| | | // 免单成功
|
| | | freeOrder = true;
|
| | | signList.add(PIC_FREE_SUCCEED);
|
| | | } else if (UserSystemCouponRecord.STATE_FAIL_RULE == state
|
| | | || UserSystemCouponRecord.STATE_FAIL_DRAWBACK == state) {
|
| | | // 规则不匹配、退款
|
| | | freeOrder = true;
|
| | | signList.add(PIC_FREE_FAIL);
|
| | | }
|
| | | }
|
| | |
|
| | | break;
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | // 订单标识
|
| | | order.setSignList(signList);
|
| | |
|
| | | boolean rewardOrder = false;
|
| | |
|
| | | int type = 1; // 1 常规跳转页面 2弹出选项(奖励券)
|
| | | if (rewardSuccess) {
|
| | | // 奖励成功
|
| | | rewardOrder = true;
|
| | | } else if (hasRewardCoupon && !freeOrder && HongBaoV2.TYPE_ZIGOU == hongBaoType
|
| | | && HongBaoV2.STATE_YILINGQU == hongBaoState) {
|
| | | // 有可用的奖励券 、非免单订单 、且已到账的 、返利订单
|
| | | type = 2;
|
| | | rewardOrder = true;
|
| | | }
|
| | |
|
| | | if (rewardOrder) {
|
| | | ClientTextStyleVO rewardStyleVO = new ClientTextStyleVO();
|
| | | // 奖励券进度详情
|
| | | rewardStyleVO.setContent("返利奖励 >");
|
| | | rewardStyleVO.setColor("#E5005C");
|
| | | rewardStyleVO.setBottomColor("#FFDCEA");
|
| | |
|
| | | Map<String, Object> jumpLink = new HashMap<String, Object>();
|
| | | jumpLink.put("orderNo", order.getOrderNo());
|
| | |
|
| | | Map<String, Object> jump = new HashMap<String, Object>();
|
| | | jump.put("type", type);
|
| | | jump.put("params", jumpLink);
|
| | | jump.put("jumpDetail", jumpDetailV2Service.getByTypeCache("rewardCouponDetail"));
|
| | |
|
| | | Map<String, Object> rewardMap = new HashMap<String, Object>();
|
| | | rewardMap.put("text", rewardStyleVO);
|
| | | rewardMap.put("jump", jump);
|
| | |
|
| | | order.setRewardDetail(rewardMap);
|
| | | }
|
| | |
|
| | | if (freeOrder) {
|
| | | ClientTextStyleVO rewardStyleVO = new ClientTextStyleVO();
|
| | | // 返利、免单详情
|
| | | rewardStyleVO.setContent("免单详情 >");
|
| | | rewardStyleVO.setColor("#E5005C");
|
| | | rewardStyleVO.setBottomColor("#FFDCEA");
|
| | |
|
| | | Map<String, Object> jumpLink = new HashMap<String, Object>();
|
| | | jumpLink.put("orderNo", order.getOrderNo());
|
| | |
|
| | | Map<String, Object> jump = new HashMap<String, Object>();
|
| | | jump.put("type", 1); // 页面跳转
|
| | | jump.put("params", jumpLink);
|
| | | jump.put("jumpDetail", jumpDetailV2Service.getByTypeCache("freeCouponDetail"));
|
| | |
|
| | | Map<String, Object> rewardMap = new HashMap<String, Object>();
|
| | | rewardMap.put("text", rewardStyleVO);
|
| | | rewardMap.put("jump", jump);
|
| | |
|
| | | order.setRewardDetail(rewardMap);
|
| | | if (sourceType == null) {
|
| | | setSystemCouponRecord(order, hasRewardCoupon, hongBaoState, hongBaoType, null, signList);
|
| | | } else if (sourceType == Constant.SOURCE_TYPE_TAOBAO) {
|
| | | setSystemCouponRecord(order, hasRewardCoupon, hongBaoState, hongBaoType, listRecordTB, signList);
|
| | | } else if (sourceType == Constant.SOURCE_TYPE_JD) {
|
| | | setSystemCouponRecord(order, hasRewardCoupon, hongBaoState, hongBaoType, listRecordJD, signList);
|
| | | } else if (sourceType == Constant.SOURCE_TYPE_PDD) {
|
| | | setSystemCouponRecord(order, hasRewardCoupon, hongBaoState, hongBaoType, listRecordPDD, signList);
|
| | | }
|
| | | }
|
| | |
|
| | | // 分享、邀请 隐藏订单号
|
| | | if (HongBaoV2.TYPE_SHARE_GOODS == hongBaoType || 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 order
|
| | | * @param hasRewardCoupon
|
| | | * @param hongBaoState
|
| | | * @param list
|
| | | * @param signList
|
| | | */
|
| | | public void setSystemCouponRecord(CommonOrderVO order, boolean hasRewardCoupon, Integer hongBaoState,
|
| | | Integer hongBaoType, List<UserSystemCouponRecord> list, List<String> signList) {
|
| | |
|
| | | // 是否免单商品
|
| | | boolean freeOrder = false;
|
| | | // 是否奖励成功
|
| | | boolean rewardSuccess = false;
|
| | |
|
| | | if (list != null && list.size() > 0) {
|
| | | for (UserSystemCouponRecord couponRecord : list) {
|
| | | // 订单号匹配
|
| | | if (order.getOrderNo().equals(couponRecord.getOrderNo())) {
|
| | | Integer state = couponRecord.getState();
|
| | | String systemCouponType = couponRecord.getCouponType();
|
| | | // 奖励订单: 且成功
|
| | | if (CouponTypeEnum.rebatePercentCoupon.name().equals(systemCouponType)
|
| | | && UserSystemCouponRecord.STATE_SUCCESS == state) {
|
| | | rewardSuccess = true;
|
| | | signList.add(PIC_REWARD); // 加入奖励成功图片
|
| | |
|
| | | } else if (CouponTypeEnum.freeCoupon.name().equals(systemCouponType)
|
| | | || CouponTypeEnum.welfareFreeCoupon.name().equals(systemCouponType)) {
|
| | |
|
| | | if (UserSystemCouponRecord.STATE_FREE_ON == state) {
|
| | | // 免单中
|
| | | freeOrder = true;
|
| | | signList.add(PIC_FREE_ON);
|
| | | } else if (UserSystemCouponRecord.STATE_SUCCESS == state) {
|
| | | // 免单成功
|
| | | freeOrder = true;
|
| | | signList.add(PIC_FREE_SUCCEED);
|
| | | } else if (UserSystemCouponRecord.STATE_FAIL_RULE == state
|
| | | || UserSystemCouponRecord.STATE_FAIL_DRAWBACK == state) {
|
| | | // 规则不匹配、退款
|
| | | freeOrder = true;
|
| | | signList.add(PIC_FREE_FAIL);
|
| | | }
|
| | | }
|
| | |
|
| | | break;
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | // 订单标识
|
| | | order.setSignList(signList);
|
| | |
|
| | | boolean rewardOrder = false;
|
| | |
|
| | | int type = 1; // 1 常规跳转页面 2弹出选项(奖励券)
|
| | | if (rewardSuccess) {
|
| | | // 奖励成功
|
| | | rewardOrder = true;
|
| | | } else if (hasRewardCoupon && !freeOrder && HongBaoV2.TYPE_ZIGOU == hongBaoType
|
| | | && HongBaoV2.STATE_YILINGQU == hongBaoState) {
|
| | | // 有可用的奖励券 、非免单订单 、且已到账的 、返利订单
|
| | | type = 2;
|
| | | rewardOrder = true;
|
| | | }
|
| | |
|
| | | if (rewardOrder) {
|
| | | ClientTextStyleVO rewardStyleVO = new ClientTextStyleVO();
|
| | | // 奖励券进度详情
|
| | | rewardStyleVO.setContent("返利奖励 >");
|
| | | rewardStyleVO.setColor("#E5005C");
|
| | | rewardStyleVO.setBottomColor("#FFDCEA");
|
| | |
|
| | | Map<String, Object> jumpLink = new HashMap<String, Object>();
|
| | | jumpLink.put("orderNo", order.getOrderNo());
|
| | |
|
| | | Map<String, Object> jump = new HashMap<String, Object>();
|
| | | jump.put("type", type);
|
| | | jump.put("params", jumpLink);
|
| | | jump.put("jumpDetail", jumpDetailV2Service.getByTypeCache("rewardCouponDetail"));
|
| | |
|
| | | Map<String, Object> rewardMap = new HashMap<String, Object>();
|
| | | rewardMap.put("text", rewardStyleVO);
|
| | | rewardMap.put("jump", jump);
|
| | |
|
| | | order.setRewardDetail(rewardMap);
|
| | | }
|
| | |
|
| | | if (freeOrder) {
|
| | | ClientTextStyleVO rewardStyleVO = new ClientTextStyleVO();
|
| | | // 返利、免单详情
|
| | | rewardStyleVO.setContent("免单详情 >");
|
| | | rewardStyleVO.setColor("#E5005C");
|
| | | rewardStyleVO.setBottomColor("#FFDCEA");
|
| | |
|
| | | Map<String, Object> jumpLink = new HashMap<String, Object>();
|
| | | jumpLink.put("orderNo", order.getOrderNo());
|
| | |
|
| | | Map<String, Object> jump = new HashMap<String, Object>();
|
| | | jump.put("type", 1); // 页面跳转
|
| | | jump.put("params", jumpLink);
|
| | | jump.put("jumpDetail", jumpDetailV2Service.getByTypeCache("freeCouponDetail"));
|
| | |
|
| | | Map<String, Object> rewardMap = new HashMap<String, Object>();
|
| | | rewardMap.put("text", rewardStyleVO);
|
| | | rewardMap.put("jump", jump);
|
| | |
|
| | | order.setRewardDetail(rewardMap);
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | cog.setUpdateTime(new Date());
|
| | | commonOrderGoodsMapper.insertSelective(cog);
|
| | | newCommonOrder.setCommonOrderGoods(cog);
|
| | | } else {
|
| | | }
|
| | | newCommonOrder.setUserInfo(new UserInfo(uid));
|
| | | commonOrderList.add(addCommonOrder(newCommonOrder));
|
| | |
| | | if (commonGoodsList.size() <= 0)// 不存在就插入商品
|
| | | {
|
| | | JDGoods goods = JDApiUtil.getGoodsDetail(itemOrder.getSkuId());
|
| | | if (goods == null) {
|
| | | goods = JDUtil.getGoodsFromWeb(itemOrder.getSkuId());
|
| | | }
|
| | |
|
| | | if (goods == null) {
|
| | | goods = new JDGoods();
|
| | | goods.setSkuName(itemOrder.getSkuName());
|
| | | goods.setPrice(itemOrder.getPrice());
|
| | | goods.setSkuId(itemOrder.getSkuId());
|
| | | }
|
| | |
|
| | | if (goods != null) {
|
| | | cog = CommonOrderGoodsFactory.create(goods);
|
| | | }
|
| | |
|
| | | cog.setCreateTime(new Date());
|
| | | cog.setUpdateTime(new Date());
|
| | | commonOrderGoodsMapper.insertSelective(cog);
|
| | | } else {
|
| | |
|
| | | }
|
| | | newCommonOrder.setUserInfo(new UserInfo(uid));
|
| | | commonOrderList.add(addCommonOrder(newCommonOrder));
|
| | |
| | | commonOrder.setCommonOrderGoods(goods);
|
| | | }
|
| | |
|
| | | CommonOrder oldCommonOrder = commonOrderMapper.selectByOrderNoAndOrderTypeAndOrderBy(commonOrder.getOrderNo(),
|
| | | commonOrder.getSourceType(), commonOrder.getOrderBy());
|
| | | CommonOrder oldCommonOrder = null;
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(commonOrder.getTradeId()))
|
| | | oldCommonOrder = commonOrderMapper.selectBySourceTypeAndTradeId(commonOrder.getSourceType(),
|
| | | commonOrder.getTradeId());
|
| | | else {
|
| | | throw new CommonOrderException(10, "交易ID为空");
|
| | | }
|
| | | if (oldCommonOrder == null)// 新增
|
| | | {
|
| | | commonOrder.setCreateTime(new Date());
|
| | |
| | | commonOrder.getTradeId(), new Date(), commonOrder.getSourceType()));
|
| | | return commonOrder;
|
| | | } else {// 修改
|
| | | // 已经结算或者已经失效的订单不处理
|
| | | if (oldCommonOrder.getState() == CommonOrder.STATE_JS
|
| | | || oldCommonOrder.getState() == CommonOrder.STATE_SX) {
|
| | | // 已经结算,已经失效,状态未改变的订单不处理
|
| | | if (oldCommonOrder.getState() == CommonOrder.STATE_JS || oldCommonOrder.getState() == CommonOrder.STATE_SX
|
| | | || oldCommonOrder.getState() == CommonOrder.STATE_WQ
|
| | | || (oldCommonOrder.getState().intValue() == commonOrder.getState())) {
|
| | | return oldCommonOrder;
|
| | | }
|
| | | // 交易ID一致才修改
|
| | |
| | |
|
| | | @Override
|
| | | public List<CommonOrderVO> listQuery(long start, int count, Integer keyType, String key, Integer state,
|
| | | Integer type, Integer orderState, String startTime, String endTime) throws CommonOrderException {
|
| | | Integer type, Integer orderState, String startTime, String endTime, Integer source)
|
| | | throws CommonOrderException {
|
| | |
|
| | | List<CommonOrderVO> list = commonOrderMapper.listQuery(start, count, keyType, key, state, type, orderState,
|
| | | startTime, endTime);
|
| | | List<CommonOrderVO> list = null;
|
| | |
|
| | | if (StringUtil.isNullOrEmpty(key) || keyType == 1) {// 搜索框无值或者按订单号搜索时都只搜索主订单
|
| | | list = commonOrderMapper.listQueryWithNoChild(start, count, keyType, key, state, type, orderState,
|
| | | startTime, endTime, source);
|
| | | } else
|
| | | list = commonOrderMapper.listQuery(start, count, keyType, key, state, type, orderState, startTime, endTime,
|
| | | source);
|
| | |
|
| | | if (list == null) {
|
| | | list = new ArrayList<CommonOrderVO>();
|
| | |
| | | if (list.size() == 0) {
|
| | | return list;
|
| | | }
|
| | | |
| | | List<String> listNo = new ArrayList<String>();
|
| | | for (CommonOrderVO commonOrderVO : list) {
|
| | | listNo.add(commonOrderVO.getOrderNo());
|
| | | }
|
| | | // 已经使用券订单
|
| | | List<UserSystemCouponRecord> couponRecordList = userSystemCouponRecordService.getRecordByOrderNoList(listNo);
|
| | |
|
| | | List<String> listTB = new ArrayList<String>();
|
| | | List<String> listJD = new ArrayList<String>();
|
| | | List<String> listPDD = new ArrayList<String>();
|
| | | for (CommonOrderVO commonOrderVO : list) {
|
| | | Integer sourceType = commonOrderVO.getSourceType();
|
| | | if (sourceType == null) {
|
| | | continue;
|
| | | } else if (sourceType == Constant.SOURCE_TYPE_TAOBAO) {
|
| | | listTB.add(commonOrderVO.getOrderNo());
|
| | | } else if (sourceType == Constant.SOURCE_TYPE_JD) {
|
| | | listJD.add(commonOrderVO.getOrderNo());
|
| | | } else if (sourceType == Constant.SOURCE_TYPE_PDD) {
|
| | | listPDD.add(commonOrderVO.getOrderNo());
|
| | | }
|
| | | }
|
| | |
|
| | | List<UserSystemCouponRecord> listRecordTB = null;
|
| | | if (listTB.size() > 0) {
|
| | | listRecordTB = userSystemCouponRecordService.getRecordByOrderNoList(Constant.SOURCE_TYPE_TAOBAO, listTB);
|
| | | }
|
| | |
|
| | | List<UserSystemCouponRecord> listRecordJD = null;
|
| | | if (listJD.size() > 0) {
|
| | | listRecordJD = userSystemCouponRecordService.getRecordByOrderNoList(Constant.SOURCE_TYPE_JD, listJD);
|
| | | }
|
| | |
|
| | | List<UserSystemCouponRecord> listRecordPDD = null;
|
| | | if (listPDD.size() > 0) {
|
| | | listRecordPDD = userSystemCouponRecordService.getRecordByOrderNoList(Constant.SOURCE_TYPE_PDD, listPDD);
|
| | | }
|
| | |
|
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
|
| | | for (CommonOrderVO order : list) {
|
| | |
| | | }
|
| | | }
|
| | | }
|
| | | |
| | | // 奖励订单、免单 使用记录
|
| | | if (couponRecordList != null && couponRecordList.size() > 0) {
|
| | | for (UserSystemCouponRecord couponRecord : couponRecordList) {
|
| | | // 订单号匹配
|
| | | if (order.getOrderNo().equals(couponRecord.getOrderNo())) {
|
| | |
|
| | | Integer sourceType = order.getSourceType();
|
| | | // 奖励订单、免单 使用记录
|
| | | if (sourceType == null) {
|
| | |
|
| | | } else if (sourceType == Constant.SOURCE_TYPE_TAOBAO && listRecordTB != null && listRecordTB.size() > 0) {
|
| | | for (UserSystemCouponRecord couponRecord : listRecordTB) {
|
| | | if (order.getOrderNo().equals(couponRecord.getOrderNo())) {
|
| | | String systemCouponType = couponRecord.getCouponType();
|
| | | Integer couponState = couponRecord.getState();
|
| | | if (CouponTypeEnum.freeCoupon.name().equals(systemCouponType)
|
| | | || CouponTypeEnum.welfareFreeCoupon.name().equals(systemCouponType)) {
|
| | | if (UserSystemCouponRecord.STATE_SUCCESS == couponState) {
|
| | | if (UserSystemCouponRecord.STATE_SUCCESS == couponState) {
|
| | | // 免单成功
|
| | | order.setOtherState(1);
|
| | | } |
| | | order.setOtherState(2);
|
| | | } else if (UserSystemCouponRecord.STATE_FREE_ON == couponState) {
|
| | | order.setOtherState(1);
|
| | | }
|
| | | }
|
| | |
|
| | | break;
|
| | | }
|
| | | }
|
| | | } else if (sourceType == Constant.SOURCE_TYPE_JD && listRecordJD != null && listRecordJD.size() > 0) {
|
| | | for (UserSystemCouponRecord couponRecord : listRecordJD) {
|
| | | if (order.getOrderNo().equals(couponRecord.getOrderNo())) {
|
| | | String systemCouponType = couponRecord.getCouponType();
|
| | | Integer couponState = couponRecord.getState();
|
| | | if (CouponTypeEnum.freeCoupon.name().equals(systemCouponType)
|
| | | || CouponTypeEnum.welfareFreeCoupon.name().equals(systemCouponType)) {
|
| | | if (UserSystemCouponRecord.STATE_SUCCESS == couponState) {
|
| | | // 免单成功
|
| | | order.setOtherState(2);
|
| | | } else if (UserSystemCouponRecord.STATE_FREE_ON == couponState) {
|
| | | order.setOtherState(1);
|
| | | }
|
| | | }
|
| | | break;
|
| | | }
|
| | | }
|
| | | } else if (sourceType == Constant.SOURCE_TYPE_PDD && listRecordPDD != null && listRecordPDD.size() > 0) {
|
| | | for (UserSystemCouponRecord couponRecord : listRecordPDD) {
|
| | | if (order.getOrderNo().equals(couponRecord.getOrderNo())) {
|
| | | String systemCouponType = couponRecord.getCouponType();
|
| | | Integer couponState = couponRecord.getState();
|
| | | if (CouponTypeEnum.freeCoupon.name().equals(systemCouponType)
|
| | | || CouponTypeEnum.welfareFreeCoupon.name().equals(systemCouponType)) {
|
| | | if (UserSystemCouponRecord.STATE_SUCCESS == couponState) {
|
| | | // 免单成功
|
| | | order.setOtherState(2);
|
| | | } else if (UserSystemCouponRecord.STATE_FREE_ON == couponState) {
|
| | | order.setOtherState(1);
|
| | | }
|
| | | }
|
| | | break;
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | |
|
| | | }
|
| | |
|
| | | return list;
|
| | |
| | |
|
| | | @Override
|
| | | public long countQuery(Integer keyType, String key, Integer state, Integer type, Integer orderState,
|
| | | String startTime, String endTime) throws CommonOrderException {
|
| | | return commonOrderMapper.countQuery(keyType, key, state, type, orderState, startTime, endTime);
|
| | | String startTime, String endTime, Integer source) throws CommonOrderException {
|
| | | if (StringUtil.isNullOrEmpty(key) || keyType == 1) {// 搜索框无值或者按订单号搜索时都只搜索主订单
|
| | | return commonOrderMapper.countQueryWithNoChild(keyType, key, state, type, orderState, startTime, endTime,
|
| | | source);
|
| | | } else
|
| | | return commonOrderMapper.countQuery(keyType, key, state, type, orderState, startTime, endTime, source);
|
| | | }
|
| | |
|
| | |
|
| | | @Override
|
| | | public CommonOrderVO getCommonOrderByOrderNo(Long uid, String orderNo, Integer orderState)
|
| | | public CommonOrderVO getCommonOrderByOrderNo(Long uid, String orderNo, Integer orderState, Integer sourceType)
|
| | | throws CommonOrderException {
|
| | |
|
| | | CommonOrderVO commonOrderVO = commonOrderMapper.getCommonOrderByOrderNo(uid, orderNo, orderState);
|
| | | if (sourceType == null) {
|
| | | sourceType = Constant.SOURCE_TYPE_TAOBAO;
|
| | | }
|
| | |
|
| | | CommonOrderVO commonOrderVO = commonOrderMapper.getCommonOrderByOrderNo(uid, orderNo, orderState, sourceType);
|
| | | // 订单信息为空
|
| | | if (commonOrderVO == null) {
|
| | | return null;
|
| | |
| | | }
|
| | |
|
| | | String orderNo1 = commonOrder.getOrderNo();
|
| | | Integer sourceType = commonOrder.getSourceType();
|
| | | Integer sourceType1 = commonOrder.getSourceType();
|
| | |
|
| | | String orderNo2 = commonOrderVO.getOrderNo();
|
| | | Integer sourceType2 = commonOrderVO.getSourceType();
|
| | |
|
| | | // 来源、订单号相同
|
| | | if (sourceType.equals(sourceType2) && orderNo1.equals(orderNo2)) {
|
| | | if (sourceType1.equals(sourceType2) && orderNo1.equals(orderNo2)) {
|
| | | // 加入商品信息
|
| | | List<CommonOrderGoodsVO> listOrderGoods = commonOrderVO.getListOrderGoods();
|
| | |
|
| | |
| | | return commonOrderVO;
|
| | | }
|
| | |
|
| | |
|
| | | @Override
|
| | | public JSONObject getRewardJumpInfo(String orderNo) {
|
| | |
|
| | |
| | |
|
| | | @Override
|
| | | public CommonOrder selectBySourceTypeAndTradeId(int sourceType, String tradeId) {
|
| | |
|
| | | return commonOrderMapper.selectBySourceTypeAndTradeId(sourceType, tradeId);
|
| | | }
|
| | |
|
| | |
| | | return commonOrderMapper.listBySourceTypeAndTradeId(sourceType, tradeId);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<CommonOrder> listBySourceTypeAndStateAndThirdCrateTime(int sourceType, Integer state, Long minTime,
|
| | | Long maxTime, int page, int pageSize) {
|
| | | return commonOrderMapper.listBySourceTypeAndStateAndThirdCrateTime(sourceType, state, minTime, maxTime,
|
| | | (page - 1) * pageSize, pageSize);
|
| | | }
|
| | | }
|