| | |
| | | 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;
|
| | |
| | | return commonOrderMapper.countByUidAndOrderState(uid, type, startTime, endTime, day, source);
|
| | | }
|
| | |
|
| | | 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,
|
| | | Long uid) {
|
| | |
|
| | |
| | | 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;
|
| | |
| | | .selectListByOrderIdAndState(order.getOrderNo(), "维权成功");
|
| | |
|
| | | 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 (fanTotalMoney.compareTo(hongBao) < 0) {
|
| | | isPart = true;
|
| | | }
|
| | | }
|
| | | BigDecimal weiQuanMoney = getWeiQuanMoney(listWQ, sourceType, uid);
|
| | |
|
| | | if (!VersionUtil.greaterThan_1_6_0(acceptData.getPlatform(), acceptData.getVersion())) {
|
| | | if (isPart) {
|
| | |
| | | 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);
|
| | | }
|
| | | // 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);
|
| | | }
|
| | | }
|
| | |
| | | } else {
|
| | | // 奖励订单、免单 使用记录
|
| | | if (sourceType == null) {
|
| | | setSystemCouponRecord(order, hasRewardCoupon, hongBaoState, hongBaoType, null, signList, acceptData);
|
| | | setSystemCouponRecord(order, hasRewardCoupon, exchangeCoupon, hongBaoState, hongBaoType, null,
|
| | | signList, acceptData);
|
| | | } else if (sourceType == Constant.SOURCE_TYPE_TAOBAO) {
|
| | | setSystemCouponRecord(order, hasRewardCoupon, hongBaoState, hongBaoType, listRecordTB, signList, acceptData);
|
| | | setSystemCouponRecord(order, hasRewardCoupon, exchangeCoupon, hongBaoState, hongBaoType,
|
| | | listRecordTB, signList, acceptData);
|
| | | } else if (sourceType == Constant.SOURCE_TYPE_JD) {
|
| | | setSystemCouponRecord(order, hasRewardCoupon, hongBaoState, hongBaoType, listRecordJD, signList, acceptData);
|
| | | setSystemCouponRecord(order, hasRewardCoupon, exchangeCoupon, hongBaoState, hongBaoType,
|
| | | listRecordJD, signList, acceptData);
|
| | | } else if (sourceType == Constant.SOURCE_TYPE_PDD) {
|
| | | setSystemCouponRecord(order, hasRewardCoupon, hongBaoState, hongBaoType, listRecordPDD, signList, acceptData);
|
| | | setSystemCouponRecord(order, hasRewardCoupon, exchangeCoupon, hongBaoState, hongBaoType,
|
| | | listRecordPDD, signList, acceptData);
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | * @param list
|
| | | * @param signList
|
| | | */
|
| | | public void setSystemCouponRecord(CommonOrderVO order, boolean hasRewardCoupon, Integer hongBaoState,
|
| | | Integer hongBaoType, List<UserSystemCouponRecord> list, List<String> signList, AcceptData acceptData) {
|
| | | public void setSystemCouponRecord(CommonOrderVO order, boolean hasRewardCoupon, boolean exchangeCoupon,
|
| | | Integer hongBaoState, Integer hongBaoType, List<UserSystemCouponRecord> list, List<String> signList,
|
| | | AcceptData acceptData) {
|
| | |
|
| | | // 是否免单商品
|
| | | boolean freeOrder = 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-05");
|
| | | if (downOrderTime > limitDate)
|
| | | hasRewardCoupon = true;
|
| | | }
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | boolean rewardOrder = false;
|
| | |
|
| | |
| | |
|
| | | @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) {
|
| | |
| | |
|
| | | @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()) {
|
| | |
| | | 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);
|
| | |
| | | * @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);
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | 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);
|
| | |
| | | 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);
|
| | |
| | | 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);
|
| | |
| | | return commonOrderMapper.listBySourceTypeAndStateAndThirdCrateTime(sourceType, state, minTime, maxTime,
|
| | | (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);
|
| | | }
|
| | |
|
| | | }
|