| | |
| | | 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 org.apache.commons.beanutils.PropertyUtils;
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | | import org.yeshi.utils.DateUtil;
|
| | | import org.yeshi.utils.entity.DateInfo;
|
| | | import org.yeshi.utils.taobao.TbImgUtil;
|
| | |
|
| | | 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.order.CommonOrderAddResultDTO;
|
| | | import com.yeshi.fanli.dto.pdd.PDDGoodsDetail;
|
| | | import com.yeshi.fanli.entity.accept.AcceptData;
|
| | | import com.yeshi.fanli.entity.bus.user.HongBaoV2;
|
| | |
| | | import com.yeshi.fanli.entity.order.CommonOrderGoods;
|
| | | import com.yeshi.fanli.entity.order.CommonOrderTradeIdMap;
|
| | | import com.yeshi.fanli.entity.order.HongBaoOrder;
|
| | | import com.yeshi.fanli.entity.order.OrderSubsidy;
|
| | | import com.yeshi.fanli.entity.pdd.PDDOrder;
|
| | | import com.yeshi.fanli.entity.system.SystemCoupon.CouponTypeEnum;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
|
| | |
| | | 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.hongbao.HongBaoV2Service;
|
| | | import com.yeshi.fanli.service.inter.order.CommonOrderService;
|
| | | import com.yeshi.fanli.service.inter.order.HongBaoOrderService;
|
| | | import com.yeshi.fanli.service.inter.order.HongBaoV2Service;
|
| | | import com.yeshi.fanli.service.inter.order.OrderSubsidyService;
|
| | | import com.yeshi.fanli.service.inter.user.UserSystemCouponRecordService;
|
| | | import com.yeshi.fanli.service.inter.user.UserSystemCouponService;
|
| | | 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.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;
|
| | |
|
| | |
| | |
|
| | | @Resource
|
| | | private HongBaoOrderService hongBaoOrderService;
|
| | | |
| | | @Resource
|
| | | private OrderSubsidyService orderSubsidyService;
|
| | | |
| | |
|
| | | // 奖励订单图片
|
| | | public final static String PIC_REWARD = "http://img.flqapp.com/resource/order/order_state_reward.png";
|
| | |
| | | }
|
| | |
|
| | | @Override
|
| | | public Map<String, BigDecimal> countByUidAndOrderState(Long uid, Integer type, String startTime, String endTime,
|
| | | Integer day, Integer source) {
|
| | | return commonOrderMapper.countByUidAndOrderState(uid, type, startTime, endTime, day, source);
|
| | | public Long countUserOrderToApp(Long uid, Integer type, String startTime, String endTime,
|
| | | Integer day, Integer source, Integer state, Integer stateOrder) {
|
| | | return commonOrderMapper.countUserOrderToApp(uid, type, startTime, endTime, day, source, state, stateOrder);
|
| | | }
|
| | |
|
| | | private BigDecimal getWeiQuanMoney(List<TaoBaoWeiQuanOrder> listWQ, int sourceType, Long uid) {
|
| | | BigDecimal weiQuanMoney = new BigDecimal(0);
|
| | | if (listWQ != null && listWQ.size() > 0) {
|
| | | for (TaoBaoWeiQuanOrder weiQuanOrder : listWQ) {
|
| | | String tradeId = weiQuanOrder.getOrderItemId();
|
| | | // 查询红包
|
| | | List<String> tradeList = new ArrayList<>();
|
| | | tradeList.add(tradeId);
|
| | | List<HongBaoV2> hongBaoList = hongBaoV2Service.listBySourceTypeAndTradeIdListAndUid(sourceType, uid,
|
| | | tradeList);
|
| | | if (hongBaoList != null && hongBaoList.size() > 0) {
|
| | | CommonOrder commonOrder = commonOrderMapper.selectBySourceTypeAndTradeId(sourceType, tradeId);
|
| | | if (commonOrder != null && commonOrder.getSettlement().compareTo(new BigDecimal(0)) > 0) {
|
| | | BigDecimal wqMoney = MoneyBigDecimalUtil
|
| | | .mul(hongBaoList.get(0).getMoney(), weiQuanOrder.getMoney())
|
| | | .divide(commonOrder.getSettlement(), 2, BigDecimal.ROUND_UP);
|
| | | if (wqMoney.compareTo(hongBaoList.get(0).getMoney()) > 0)
|
| | | wqMoney = hongBaoList.get(0).getMoney();
|
| | | weiQuanMoney = weiQuanMoney.add(wqMoney);
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | return weiQuanMoney;
|
| | | }
|
| | |
|
| | | public void listDataFactory(AcceptData acceptData, List<CommonOrderVO> listOrder, List<CommonOrderVO> listGoods,
|
| | |
| | | SimpleDateFormat formatday = new SimpleDateFormat("yyyy.MM.dd");
|
| | |
|
| | | // 是否存在奖励券
|
| | | boolean hasRewardCoupon = userSystemCouponService.hasRewardCoupon(uid);
|
| | | // boolean hasRewardCoupon =
|
| | | // userSystemCouponService.hasRewardCoupon(uid);
|
| | | boolean hasRewardCoupon = userSystemCouponService.getIncludeNotExchange(uid);
|
| | | boolean exchangeCoupon = userSystemCouponService.getIncludeExchange(uid);
|
| | |
|
| | | // 2019.8.1开始返回维权信息
|
| | | Date august = null;
|
| | | try {
|
| | | august = TimeUtil.parse("2019-08-01");
|
| | | } catch (ParseException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | /* 组织订单状态 等信息 */
|
| | | for (CommonOrderVO order : listOrder) {
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | BigDecimal hongBao = order.getHongBao();
|
| | | if (hongBao == null) {
|
| | | hongBao = new BigDecimal(0);
|
| | | }
|
| | |
|
| | | if (CommonOrder.STATE_FK == orderState) {
|
| | | orderStateContent = "已付款";
|
| | | } else if (CommonOrder.STATE_JS == orderState) {
|
| | |
| | | .selectListByOrderIdAndState(order.getOrderNo(), "维权成功");
|
| | |
|
| | | boolean isPart = false;// 默认失效
|
| | | BigDecimal weiQuanMoney = getWeiQuanMoney(listWQ, sourceType, uid);
|
| | |
|
| | | 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 (!VersionUtil.greaterThan_1_6_0(acceptData.getPlatform(), acceptData.getVersion())) {
|
| | | if (isPart) {
|
| | | hongBaoState = HongBaoV2.STATE_BUFENSHIXIAO; // 部分失效
|
| | | } else {
|
| | | hongBaoState = HongBaoV2.STATE_SHIXIAO; // 全部失效
|
| | | }
|
| | |
|
| | | if (fanTotalMoney.compareTo(order.getHongBao()) < 0) {
|
| | | isPart = true;
|
| | | }
|
| | | }
|
| | |
|
| | | if (isPart) {
|
| | | hongBaoState = HongBaoV2.STATE_BUFENSHIXIAO; // 部分失效
|
| | | } else {
|
| | | hongBaoState = HongBaoV2.STATE_SHIXIAO; // 全部失效
|
| | | // 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) {
|
| | | weiQuanInfo
|
| | | .setWqHongBao("维权:-¥" + weiQuanMoney.setScale(2, BigDecimal.ROUND_DOWN).toString());
|
| | | hongBao = MoneyBigDecimalUtil.sub(hongBao, weiQuanMoney);
|
| | | // } else {
|
| | | // weiQuanInfo
|
| | | // .setWqHongBao("维权:-¥" + weiQuanMoney.setScale(2,
|
| | | // BigDecimal.ROUND_DOWN).toString());
|
| | | // hongBao = MoneyBigDecimalUtil.sub(hongBao,
|
| | | // weiQuanMoney);
|
| | | // }
|
| | | order.setWeiQuanInfo(weiQuanInfo);
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | order.setHongBaoTypePic(CommonOrder.TYPE_SHARE);
|
| | | signList.add(CommonOrder.TYPE_SHARE);
|
| | |
|
| | | } else if (HongBaoV2.TYPE_YAOQING == hongBaoType || HongBaoV2.TYPE_YIJI == hongBaoType
|
| | | || HongBaoV2.TYPE_ERJI == hongBaoType || HongBaoV2.TYPE_SHARE_YIJI == hongBaoType
|
| | | || HongBaoV2.TYPE_SHARE_ERJI == hongBaoType) {
|
| | | // 邀请
|
| | | } else if (HongBaoV2.TYPE_SHARE_YIJI == hongBaoType || HongBaoV2.TYPE_SHARE_ERJI == hongBaoType) {
|
| | | // 下级的分享订单: 显示邀请
|
| | | hongbaoInfo = "奖金";
|
| | | order.setOrderOrigin("3");
|
| | | order.setHongBaoTypePic(CommonOrder.TYPE_INVITE);
|
| | | signList.add(CommonOrder.TYPE_INVITE);
|
| | | } else if (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);
|
| | | |
| | | // 版本区分:2-0-2
|
| | | if (VersionUtil.greaterThan_2_0_2(acceptData.getPlatform(), acceptData.getVersion())) {
|
| | | OrderSubsidy orderSubsidy = orderSubsidyService.getByOrderNoAndType(uid, order.getOrderNo(), sourceType2);
|
| | | if (orderSubsidy != null) {
|
| | | ClientTextStyleVO subsidyInfo = new ClientTextStyleVO();
|
| | | if (orderSubsidy.getState() == OrderSubsidy.STATE_SUBSIDIZED) {
|
| | | subsidyInfo.setColor("#E5005C");
|
| | | subsidyInfo.setContent("已补贴¥" + orderSubsidy.getMoney());
|
| | | } else {
|
| | | subsidyInfo.setColor("#888888");
|
| | | subsidyInfo.setContent("补贴¥" + orderSubsidy.getMoney());
|
| | | |
| | | // 解释信息(问号)
|
| | | List<String> subsidyList = new ArrayList<String>();
|
| | | subsidyList.add("额外补贴能否获得由系统算法自动判断,人为无法干涉;");
|
| | | subsidyList.add("额外补贴到账时间以及金额请以实际到账为准;");
|
| | | subsidyList.add("额外补贴产生后将会在消息-资金消息中提醒你。");
|
| | | order.setSubsidyList(subsidyList);
|
| | | }
|
| | | order.setSubsidy(subsidyInfo);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | String hongBaoDate = null;
|
| | |
| | | order.setHongBaoState(orderHongBaoState);
|
| | | order.setHongBaoDate(hongBaoDate);
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(order.getStateDesc())) {
|
| | | stateContent = stateContent + "-" + order.getStateDesc();
|
| | | }
|
| | | |
| | | Map<String, String> stateMap = new HashMap<String, String>();
|
| | | stateMap.put("content", stateContent);
|
| | | stateMap.put("fontColor", stateFontColor);
|
| | |
| | |
|
| | | 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);
|
| | |
| | | } else {
|
| | | // 奖励订单、免单 使用记录
|
| | | if (sourceType == null) {
|
| | | setSystemCouponRecord(order, hasRewardCoupon, hongBaoState, hongBaoType, null, signList);
|
| | | setSystemCouponRecord(order, hasRewardCoupon, exchangeCoupon, hongBaoState, hongBaoType, null,
|
| | | signList, acceptData);
|
| | | } else if (sourceType == Constant.SOURCE_TYPE_TAOBAO) {
|
| | | setSystemCouponRecord(order, hasRewardCoupon, hongBaoState, hongBaoType, listRecordTB, signList);
|
| | | setSystemCouponRecord(order, hasRewardCoupon, exchangeCoupon, hongBaoState, hongBaoType,
|
| | | listRecordTB, signList, acceptData);
|
| | | } else if (sourceType == Constant.SOURCE_TYPE_JD) {
|
| | | setSystemCouponRecord(order, hasRewardCoupon, hongBaoState, hongBaoType, listRecordJD, signList);
|
| | | setSystemCouponRecord(order, hasRewardCoupon, exchangeCoupon, hongBaoState, hongBaoType,
|
| | | listRecordJD, signList, acceptData);
|
| | | } else if (sourceType == Constant.SOURCE_TYPE_PDD) {
|
| | | setSystemCouponRecord(order, hasRewardCoupon, hongBaoState, hongBaoType, listRecordPDD, signList);
|
| | | setSystemCouponRecord(order, hasRewardCoupon, exchangeCoupon, hongBaoState, hongBaoType,
|
| | | listRecordPDD, signList, acceptData);
|
| | | }
|
| | | }
|
| | |
|
| | | // 分享、邀请 隐藏订单号
|
| | | 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) {
|
| | | 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 list
|
| | | * @param signList
|
| | | */
|
| | | public void setSystemCouponRecord(CommonOrderVO order, boolean hasRewardCoupon, Integer hongBaoState,
|
| | | Integer hongBaoType, List<UserSystemCouponRecord> list, List<String> signList) {
|
| | | public void setSystemCouponRecord(CommonOrderVO order, boolean hasRewardCoupon, boolean exchangeCoupon,
|
| | | Integer hongBaoState, Integer hongBaoType, List<UserSystemCouponRecord> list, List<String> signList,
|
| | | AcceptData acceptData) {
|
| | |
|
| | | // 是否免单商品
|
| | | boolean freeOrder = false;
|
| | | boolean freeOrder = false; |
| | | // 是否奖励成功
|
| | | boolean rewardSuccess = false;
|
| | |
|
| | |
| | | signList.add(PIC_REWARD); // 加入奖励成功图片
|
| | |
|
| | | } else if (CouponTypeEnum.freeCoupon.name().equals(systemCouponType)
|
| | | || CouponTypeEnum.welfareFreeCoupon.name().equals(systemCouponType)) {
|
| | | || CouponTypeEnum.welfareFreeCoupon.name().equals(systemCouponType)
|
| | | || CouponTypeEnum.freeCouponBuy.name().equals(systemCouponType)) {
|
| | |
|
| | | if (UserSystemCouponRecord.STATE_FREE_ON == state) {
|
| | | // 免单中
|
| | |
| | | // 订单标识
|
| | | order.setSignList(signList);
|
| | |
|
| | | // 1.6.5 是否存在新兑换的券
|
| | | if (!hasRewardCoupon && exchangeCoupon) {
|
| | | try {
|
| | | Date thirdCreateTime = order.getThirdCreateTime();
|
| | | if (thirdCreateTime != null) {
|
| | | long downOrderTime = thirdCreateTime.getTime();
|
| | | long limitDate = TimeUtil.convertDateToTemp("2019-09-10");
|
| | | if (downOrderTime > limitDate)
|
| | | hasRewardCoupon = true;
|
| | | }
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | boolean rewardOrder = false;
|
| | |
|
| | | int type = 1; // 1 常规跳转页面 2弹出选项(奖励券)
|
| | |
| | | }
|
| | |
|
| | | if (rewardOrder) {
|
| | | ClientTextStyleVO rewardStyleVO = new ClientTextStyleVO();
|
| | | // 奖励券进度详情
|
| | | rewardStyleVO.setContent("返利奖励 >");
|
| | | rewardStyleVO.setColor("#E5005C");
|
| | | rewardStyleVO.setBottomColor("#FFDCEA");
|
| | | try {
|
| | | boolean newEdition = false;
|
| | | String num = null;
|
| | | String unit = null;
|
| | | boolean canUse = false;
|
| | | |
| | | // 版本区分:2.0.2
|
| | | if (VersionUtil.greaterThan_2_0_2(acceptData.getPlatform(), acceptData.getVersion())) {
|
| | | Date thirdCreateTime = order.getThirdCreateTime();
|
| | | if (thirdCreateTime != null) {
|
| | | long downOrderTime = thirdCreateTime.getTime();
|
| | | long limitDate = Long.parseLong("1573315200000"); // TODO 日期待确定2019-11-10
|
| | | if (downOrderTime > limitDate) {
|
| | | newEdition = true;
|
| | | Date endDay = DateUtil.plusDayDate(4, thirdCreateTime);
|
| | | long currentTime = java.lang.System.currentTimeMillis();
|
| | | if (endDay.getTime() > currentTime) {
|
| | | DateInfo dateInfo = DateUtil.dateDiff3(currentTime, endDay.getTime());
|
| | | if (dateInfo != null) {
|
| | | if (dateInfo.getDay() > 0) {
|
| | | canUse = true;
|
| | | unit = "天";
|
| | | num = dateInfo.getDay().toString();
|
| | | }
|
| | |
|
| | | Map<String, Object> jumpLink = new HashMap<String, Object>();
|
| | | jumpLink.put("orderNo", order.getOrderNo());
|
| | | if (!canUse && dateInfo.getHour() > 0) {
|
| | | canUse = true;
|
| | | unit = "小时";
|
| | | num = dateInfo.getHour().toString();
|
| | | }
|
| | |
|
| | | Map<String, Object> jump = new HashMap<String, Object>();
|
| | | jump.put("type", type);
|
| | | jump.put("params", jumpLink);
|
| | | jump.put("jumpDetail", jumpDetailV2Service.getByTypeCache("rewardCouponDetail"));
|
| | | if (!canUse && dateInfo.getMinute() > 0) {
|
| | | canUse = true;
|
| | | unit = "分";
|
| | | num = dateInfo.getMinute().toString();
|
| | | }
|
| | |
|
| | | Map<String, Object> rewardMap = new HashMap<String, Object>();
|
| | | rewardMap.put("text", rewardStyleVO);
|
| | | rewardMap.put("jump", jump);
|
| | | if (!canUse && dateInfo.getSecond() > 0) {
|
| | | canUse = true;
|
| | | unit = "秒";
|
| | | num = dateInfo.getSecond().toString();
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | order.setRewardDetail(rewardMap);
|
| | | if (newEdition && !canUse) {
|
| | | // 新版不可使用
|
| | | } else {
|
| | | Map<String, Object> rewardMap = new HashMap<String, Object>();
|
| | | ClientTextStyleVO rewardStyleVO = new ClientTextStyleVO();
|
| | | rewardStyleVO.setColor("#E5005C");
|
| | | rewardStyleVO.setBottomColor("#FFDCEA");
|
| | | if (!newEdition) {
|
| | | rewardStyleVO.setContent("返利奖励 >");
|
| | | } else if (canUse) {
|
| | | rewardStyleVO.setContent("返利奖励 ");
|
| | | |
| | | ClientTextStyleVO txt1 = new ClientTextStyleVO();
|
| | | txt1.setContent("剩");
|
| | | txt1.setColor("#666666");
|
| | | txt1.setBottomColor("#FFDCEA");
|
| | | |
| | | ClientTextStyleVO txt2 = new ClientTextStyleVO();
|
| | | txt2.setContent(num);
|
| | | txt2.setColor("#E5005C");
|
| | | txt2.setBottomColor("#FFDCEA");
|
| | | |
| | | ClientTextStyleVO txt3 = new ClientTextStyleVO();
|
| | | txt3.setContent(unit + "关闭 >");
|
| | | txt3.setColor("#666666");
|
| | | txt3.setBottomColor("#FFDCEA");
|
| | | |
| | | List<ClientTextStyleVO> ticking = new ArrayList<ClientTextStyleVO>();
|
| | | ticking.add(txt1);
|
| | | ticking.add(txt2);
|
| | | ticking.add(txt3);
|
| | | rewardMap.put("ticking", ticking);
|
| | | }
|
| | | rewardMap.put("text", rewardStyleVO);
|
| | | |
| | | Map<String, Object> jumpLink = new HashMap<String, Object>();
|
| | | jumpLink.put("orderNo", order.getOrderNo());
|
| | | jumpLink.put("goodsType", order.getSourceType() + "");
|
| | | |
| | | Map<String, Object> jump = new HashMap<String, Object>();
|
| | | jump.put("type", type);
|
| | | jump.put("params", jumpLink);
|
| | | jump.put("jumpDetail", jumpDetailV2Service.getByTypeCache("rewardCouponDetail"));
|
| | | rewardMap.put("jump", jump);
|
| | | order.setRewardDetail(rewardMap);
|
| | | }
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | if (freeOrder) {
|
| | |
| | |
|
| | | Map<String, Object> jumpLink = new HashMap<String, Object>();
|
| | | jumpLink.put("orderNo", order.getOrderNo());
|
| | | if (VersionUtil.greaterThan_1_6_0(acceptData.getPlatform(), acceptData.getVersion())) {
|
| | | jumpLink.put("goodsType", order.getSourceType()+"");
|
| | | }
|
| | |
|
| | | Map<String, Object> jump = new HashMap<String, Object>();
|
| | | jump.put("type", 1); // 页面跳转
|
| | |
| | |
|
| | | @Transactional
|
| | | @Override
|
| | | public List<CommonOrder> addTaoBaoOrder(List<TaoBaoOrder> taoBaoOrders, Long uid) throws CommonOrderException {
|
| | | List<CommonOrder> commonOrderList = new ArrayList<>();
|
| | | public List<CommonOrderAddResultDTO> addTaoBaoOrder(List<TaoBaoOrder> taoBaoOrders, Long uid)
|
| | | throws CommonOrderException {
|
| | | List<CommonOrderAddResultDTO> commonOrderList = new ArrayList<>();
|
| | | // 判断所有的订单状态
|
| | | int invalidCount = 0;
|
| | | for (TaoBaoOrder tb : taoBaoOrders) {
|
| | |
| | |
|
| | | @Transactional
|
| | | @Override
|
| | | public List<CommonOrder> addPDDOrder(List<PDDOrder> pddOrderList, Long uid) throws CommonOrderException {
|
| | | List<CommonOrder> commonOrderList = new ArrayList<>();
|
| | | public List<CommonOrderAddResultDTO> addPDDOrder(List<PDDOrder> pddOrderList, Long uid)
|
| | | throws CommonOrderException {
|
| | | List<CommonOrderAddResultDTO> commonOrderList = new ArrayList<>();
|
| | | // 判断所有的订单状态
|
| | | int invalidCount = 0;
|
| | | for (PDDOrder order : pddOrderList) {
|
| | |
| | | commonOrderGoodsMapper.insertSelective(cog);
|
| | | newCommonOrder.setCommonOrderGoods(cog);
|
| | | } else {
|
| | | if (!Constant.IS_OUTNET) {
|
| | | PDDGoodsDetail pddGoods = null;
|
| | | pddGoods = PinDuoDuoApiUtil.getGoodsDetail(Long.parseLong(cog.getGoodsId()));
|
| | | if (pddGoods != null) {
|
| | | cog = CommonOrderGoodsFactory.create(pddGoods);
|
| | | commonGoodsList.get(0).setPicture(cog.getPicture());
|
| | | commonOrderGoodsMapper.updateByPrimaryKeySelective(commonGoodsList.get(0));
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | | newCommonOrder.setUserInfo(new UserInfo(uid));
|
| | | commonOrderList.add(addCommonOrder(newCommonOrder));
|
| | |
| | |
|
| | | @Transactional
|
| | | @Override
|
| | | public List<CommonOrder> addJDOrder(JDOrder jdOrder, Long uid) throws CommonOrderException {
|
| | | List<CommonOrder> commonOrderList = new ArrayList<>();
|
| | | public List<CommonOrderAddResultDTO> addJDOrder(JDOrder jdOrder, Long uid) throws CommonOrderException {
|
| | | List<CommonOrderAddResultDTO> commonOrderList = new ArrayList<>();
|
| | | // 判断所有的订单状态
|
| | | int invalidCount = 0;
|
| | | for (JDOrderItem tb : jdOrder.getOrderItemList()) {
|
| | |
| | | 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 {
|
| | | if (!Constant.IS_OUTNET) {
|
| | | JDGoods goods = JDApiUtil.getGoodsDetail(itemOrder.getSkuId());
|
| | | if(goods==null)
|
| | | goods=JDUtil.getGoodsFromWeb(itemOrder.getSkuId());
|
| | | commonGoodsList.get(0).setTitle(goods.getSkuName());
|
| | | commonGoodsList.get(0).setPicture(goods.getPicUrl());
|
| | | commonOrderGoodsMapper.updateByPrimaryKeySelective(commonGoodsList.get(0));
|
| | | }
|
| | |
|
| | | }
|
| | | newCommonOrder.setUserInfo(new UserInfo(uid));
|
| | | commonOrderList.add(addCommonOrder(newCommonOrder));
|
| | |
| | | * @param commonOrder
|
| | | */
|
| | | @Transactional
|
| | | private CommonOrder addCommonOrder(CommonOrder commonOrder) throws CommonOrderException {
|
| | | private CommonOrderAddResultDTO addCommonOrder(CommonOrder commonOrder) throws CommonOrderException {
|
| | | // 判断商品是否存在
|
| | | if (commonOrder == null)
|
| | | throw new CommonOrderException(1, "订单为空");
|
| | |
| | | if (!StringUtil.isNullOrEmpty(commonOrder.getTradeId()))
|
| | | oldCommonOrder = commonOrderMapper.selectBySourceTypeAndTradeId(commonOrder.getSourceType(),
|
| | | commonOrder.getTradeId());
|
| | | else
|
| | | oldCommonOrder = commonOrderMapper.selectByOrderNoAndOrderTypeAndOrderBy(commonOrder.getOrderNo(),
|
| | | commonOrder.getSourceType(), commonOrder.getOrderBy());
|
| | |
|
| | | else {
|
| | | throw new CommonOrderException(10, "交易ID为空");
|
| | | }
|
| | | if (oldCommonOrder == null)// 新增
|
| | | {
|
| | | commonOrder.setCreateTime(new Date());
|
| | |
| | | // 插入映射,保证交易ID的完整性
|
| | | commonOrderTradeIdMapMapper.insertSelective(new CommonOrderTradeIdMap(commonOrder.getId(),
|
| | | commonOrder.getTradeId(), new Date(), commonOrder.getSourceType()));
|
| | | return commonOrder;
|
| | | return new CommonOrderAddResultDTO(commonOrder, CommonOrderAddResultDTO.TYPE_ADD);
|
| | | } else {// 修改
|
| | | // 已经结算,已经失效,状态未改变的订单不处理
|
| | | if (oldCommonOrder.getState() == CommonOrder.STATE_JS || oldCommonOrder.getState() == CommonOrder.STATE_SX
|
| | | || oldCommonOrder.getState() == CommonOrder.STATE_WQ
|
| | | || (oldCommonOrder.getState().intValue() == commonOrder.getState())) {
|
| | | return oldCommonOrder;
|
| | | return new CommonOrderAddResultDTO(oldCommonOrder, CommonOrderAddResultDTO.TYPE_NOUPDATE);
|
| | | }
|
| | | // 交易ID一致才修改
|
| | | if (commonOrder.getTradeId() != null
|
| | |
| | | updateCommonOrder.setUpdateTime(new Date());
|
| | | updateCommonOrder.setTradeId(commonOrder.getTradeId());
|
| | | commonOrderMapper.updateByPrimaryKeySelective(updateCommonOrder);
|
| | | return commonOrderMapper.selectByPrimaryKey(updateCommonOrder.getId());
|
| | | return new CommonOrderAddResultDTO(commonOrderMapper.selectByPrimaryKey(updateCommonOrder.getId()),
|
| | | CommonOrderAddResultDTO.TYPE_UPDATE);
|
| | | } else
|
| | | return oldCommonOrder;
|
| | | return new CommonOrderAddResultDTO(oldCommonOrder, CommonOrderAddResultDTO.TYPE_NOUPDATE);
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | 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, source);
|
| | | 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>();
|
| | |
| | | String systemCouponType = couponRecord.getCouponType();
|
| | | Integer couponState = couponRecord.getState();
|
| | | if (CouponTypeEnum.freeCoupon.name().equals(systemCouponType)
|
| | | || CouponTypeEnum.welfareFreeCoupon.name().equals(systemCouponType)) {
|
| | | || CouponTypeEnum.welfareFreeCoupon.name().equals(systemCouponType)
|
| | | || CouponTypeEnum.freeCouponBuy.name().equals(systemCouponType)) {
|
| | | if (UserSystemCouponRecord.STATE_SUCCESS == couponState) {
|
| | | // 免单成功
|
| | | order.setOtherState(2);
|
| | | } else if (UserSystemCouponRecord.STATE_FREE_ON == couponState) {
|
| | | order.setOtherState(1);
|
| | | }
|
| | | }
|
| | |
| | | String systemCouponType = couponRecord.getCouponType();
|
| | | Integer couponState = couponRecord.getState();
|
| | | if (CouponTypeEnum.freeCoupon.name().equals(systemCouponType)
|
| | | || CouponTypeEnum.welfareFreeCoupon.name().equals(systemCouponType)) {
|
| | | || CouponTypeEnum.welfareFreeCoupon.name().equals(systemCouponType)
|
| | | || CouponTypeEnum.freeCouponBuy.name().equals(systemCouponType)) {
|
| | | if (UserSystemCouponRecord.STATE_SUCCESS == couponState) {
|
| | | // 免单成功
|
| | | order.setOtherState(2);
|
| | | } else if (UserSystemCouponRecord.STATE_FREE_ON == couponState) {
|
| | | order.setOtherState(1);
|
| | | }
|
| | | }
|
| | |
| | | String systemCouponType = couponRecord.getCouponType();
|
| | | Integer couponState = couponRecord.getState();
|
| | | if (CouponTypeEnum.freeCoupon.name().equals(systemCouponType)
|
| | | || CouponTypeEnum.welfareFreeCoupon.name().equals(systemCouponType)) {
|
| | | || CouponTypeEnum.welfareFreeCoupon.name().equals(systemCouponType)
|
| | | || CouponTypeEnum.freeCouponBuy.name().equals(systemCouponType)) {
|
| | | if (UserSystemCouponRecord.STATE_SUCCESS == couponState) {
|
| | | // 免单成功
|
| | | order.setOtherState(2);
|
| | | } else if (UserSystemCouponRecord.STATE_FREE_ON == couponState) {
|
| | | order.setOtherState(1);
|
| | | }
|
| | | }
|
| | |
| | | @Override
|
| | | public long countQuery(Integer keyType, String key, Integer state, Integer type, Integer orderState,
|
| | | String startTime, String endTime, Integer source) throws CommonOrderException {
|
| | | return commonOrderMapper.countQuery(keyType, key, state, type, orderState, startTime, endTime, source);
|
| | | 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
|
| | |
| | | }
|
| | |
|
| | | @Override
|
| | | public JSONObject getRewardJumpInfo(String orderNo) {
|
| | | public JSONObject getRewardJumpInfo(String orderNo, Integer goodsType) {
|
| | |
|
| | | JSONObject map = new JSONObject();
|
| | | // 订单标识
|
| | |
| | |
|
| | | Map<String, Object> jumpLink = new HashMap<String, Object>();
|
| | | jumpLink.put("orderNo", orderNo);
|
| | | jumpLink.put("goodsType", goodsType == null? goodsType: goodsType +"");
|
| | |
|
| | | Map<String, Object> jump = new HashMap<String, Object>();
|
| | | jump.put("type", 1);
|
| | |
| | | (page - 1) * pageSize, pageSize);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<CommonOrder> getByOrderNo(Long uid, String orderNO) {
|
| | | return commonOrderMapper.getByOrderNo(uid, orderNO);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public CommonOrder selectLatestValidByUid(Long uid) {
|
| | | List<Integer> stateList = new ArrayList<>();
|
| | | stateList.add(CommonOrder.STATE_FK);
|
| | | stateList.add(CommonOrder.STATE_JS);
|
| | | List<CommonOrder> commonOrderList = commonOrderMapper.listByUid(uid, stateList, 0, 1);
|
| | | if (commonOrderList == null || commonOrderList.size() == 0)
|
| | | return null;
|
| | | return commonOrderList.get(0);
|
| | | }
|
| | |
|
| | | }
|