From 926ee1cbb623e9c6c39984acca83c2fa14580e59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=B9=E7=A3=8A?= <45566618@qq.com> Date: Tue, 10 Sep 2024 10:13:00 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=AE=A2=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/OrdersServiceImpl.java | 1384 ++++++++++------- .../mapper/bl/massage/MassagePackageDao.xml | 4 +- 2 files changed, 807 insertions(+), 581 deletions(-) diff --git a/src/main/java/com/sqx/modules/artificer/service/impl/OrdersServiceImpl.java b/src/main/java/com/sqx/modules/artificer/service/impl/OrdersServiceImpl.java index e416e81..c66af06 100644 --- a/src/main/java/com/sqx/modules/artificer/service/impl/OrdersServiceImpl.java +++ b/src/main/java/com/sqx/modules/artificer/service/impl/OrdersServiceImpl.java @@ -1716,10 +1716,10 @@ public class OrdersServiceImpl extends ServiceImpl implements orders.setPriceMarkup(priceMarkup); //会员优惠后金额,及会员减免金额 - BigDecimal vipMoney = priceMarkup.multiply(orders.getVipRate()).divide(new BigDecimal(100)); - vipMoney = vipMoney.setScale(2,BigDecimal.ROUND_HALF_UP); - BigDecimal vipReductionMoney = priceMarkup.subtract(vipMoney); - orders.setVipReductionMoney(vipReductionMoney); +// BigDecimal vipMoney = priceMarkup.multiply(orders.getVipRate()).divide(new BigDecimal(100)); +// vipMoney = vipMoney.setScale(2,BigDecimal.ROUND_HALF_UP); +// BigDecimal vipReductionMoney = priceMarkup.subtract(vipMoney); +// orders.setVipReductionMoney(vipReductionMoney); BigDecimal chajia = orders.getPriceMarkup().subtract(oldOrders.getPriceMarkup()); @@ -1729,12 +1729,12 @@ public class OrdersServiceImpl extends ServiceImpl implements // BigDecimal chajiaPriceMarkup = chajiaTechnicianMoney.add(chajia); - BigDecimal chajiaVipMoney = chajia.subtract(vipReductionMoney); +// BigDecimal chajiaVipMoney = chajia.subtract(vipReductionMoney); -// BigDecimal chajiaVipMoney = chajia.multiply(orders.getVipRate()).divide(new BigDecimal(100)); -// chajiaVipMoney = chajiaVipMoney.setScale(2,BigDecimal.ROUND_HALF_UP); -// BigDecimal chajiaVipReductionMoney = chajia.subtract(chajiaVipMoney); -// orders.setVipReductionMoney(chajiaVipReductionMoney); + BigDecimal chajiaVipMoney = chajia.multiply(orders.getVipRate()).divide(new BigDecimal(100)); + chajiaVipMoney = chajiaVipMoney.setScale(2,BigDecimal.ROUND_HALF_UP); + BigDecimal chajiaVipReductionMoney = chajia.subtract(chajiaVipMoney); + orders.setVipReductionMoney(chajiaVipReductionMoney); //项目价格 = 会员金额 BigDecimal massagePrice = chajiaVipMoney; @@ -1767,8 +1767,786 @@ public class OrdersServiceImpl extends ServiceImpl implements baseMapper.updateById(ordersOld);//原单暂变成挂单状态 return Result.success().put("data", orders); } +// if (oldOrders.getStatus() == 2 || oldOrders.getStatus() == 9 || xgd == 1) { +// //只能修改,技师和时间 (技师等级大于等于原单据等级) +// //判断是否是可修改,状态2 9 +// boolean canUpdate = commonInfoService.isCheckEditOrder(DateUtils.stringToDate(oldOrders.getServeTime(), "yyyy-MM-dd HH:mm"), new Date()); +// if (!canUpdate) { +// return Result.error("当前订单已过修改时限无法修改!"); +// } +// //判断是否是修改后的订单再继续修改 +// +// if (oldOrders.getOldOrdersId() != null && oldOrders.getOldOrdersId() != 0) { +// return Result.error("当前订单是修改后生成的新订单无法修改!"); +// } +// Long massageTypeId; +// BigDecimal price = BigDecimal.ZERO; +// MassageType massageType = null; +// if (orders.getOrdersMassageList() != null) { +// List ordersMassageList = orders.getOrdersMassageList(); +// if(orders.getUserPackageDetailId() != null) { +// UserPackageDetail userPackageDetail = userPackageDetailService.getById(ordersMassageList.get(0).getMassageId()); +// massageTypeId = userPackageDetail.getMassageTypeId(); +// orders.setUserPackageId(userPackageDetail.getMainId()); +// }else{ +// massageTypeId = ordersMassageList.get(0).getMassageId(); +// } +// +// massageType = massageTypeService.getById(massageTypeId); +// orders.setMassageTypeId(massageTypeId); +// orders.setEntryName(massageType.getTitle()); +// orders.setDuration(massageType.getDuration()); +// +// for (OrdersMassage ordersMassage : ordersMassageList) { +// orders.setMassageNum(ordersMassage.getNum()); +// price = massageType.getPrice().multiply(BigDecimal.valueOf(ordersMassage.getNum())).setScale(2,BigDecimal.ROUND_HALF_UP); +// } +// orders.setMassagePrice(price); +// orders.setPrice(price); +// } else { +// return Result.error("当前订单没有选择服务项目!"); +// } +// +// Date serveTimeDate = DateUtils.stringToDate(orders.getServeTime(), "yyyy-MM-dd HH:mm"); +// if(serveTimeDate.getTime() < (new Date()).getTime()){ +// return Result.error("服务时间不能晚于当前时间!"); +// } +// +// //判断新price是否大于旧price +// if (price.compareTo(oldOrders.getPrice()) < 0) { +// return Result.error("当前订单的服务项目金额不能小于原服务项目金额!"); +// } +// +// String value1 = commonInfoService.findOne(395).getValue(); +// Integer tripWay = orders.getTripWay(); +// BigDecimal taxiMoney = BigDecimal.ZERO; +// if(orders.getUserPackageDetailId() != null) { +// String isTravelFree = commonInfoService.findOne(460).getValue(); +// if(isTravelFree.equals("是")){ +// taxiMoney = BigDecimal.ZERO; +// tripWay = 3; +// orders.setTripWay(3); +// } +// } +// +// String serveTime = orders.getServeTime(); +// String date = serveTime.substring(0, 10); +// String time = serveTime.substring(11, 16); +// ArtificerTime artificerTime = artificerTimeService.getOne( +// new QueryWrapper() +// .eq("artificer_id", orders.getArtificerId()) +// .eq("artificer_date", date) +// .eq("artificer_time", time) +// .ne("orders_id", orders.getOrdersId()) +// .last("limit 1")); +// if (artificerTime != null) { +// return Result.error("预约时间正忙,请更换其他时间!"); +// } +// +// Map map = getTaskTimeIncudeOrders(massageType.getDuration(),serveTime,value1,tripWay,orders.getArtificerId(),orders.getOrdersId()); +// if(map.get("code").toString().equals("1")){ +// return Result.error("预约时间正忙,请更换其他时间!"); +// } +// +// Artificer artificer = artificerService.getById(orders.getArtificerId()); +// Artificer oldArtificer = artificerService.getById(oldOrders.getArtificerId()); +// if (artificer.getTechnicianType() < oldArtificer.getTechnicianType()) { +// return Result.error("当前订单技师等级不能低于原订单技师等级!"); +// } +// +// orders.setArtificerId(artificer.getArtificerId()); +// orders.setTechnicianType(artificer.getTechnicianType()); +// orders.setArtificerRate(artificer.getRate()); +// BigDecimal artificerVipRate = BigDecimal.ZERO; +// VipDetails artificerVipDetails = vipDetailsDao.selectOne(new QueryWrapper().eq("vip_name_type", artificer.getTechnicianType())); +// if (artificerVipDetails != null) { +// artificerVipRate = artificerVipDetails.getRate(); +// } +// orders.setTechnicianRate(artificerVipRate); +// //获取用户VIP的优惠信息 +// BigDecimal vipRate = new BigDecimal(100); +// UserVip userVip = userVipService.selectUserVipByUserId(oldOrders.getUserId()); +// if (userVip != null) { +// if (userVip.getIsVip() == 1) { +// //获取用户到期时间 +// Date date2 = null; +// try { +// date2 = DateUtils.stringToDate(userVip.getEndTime(), DateUtils.DATE_TIME_PATTERN); +// if (date2.getTime() >= System.currentTimeMillis()) { +// VipDetails vipDetails = vipDetailsDao.selectOne(new QueryWrapper().eq("vip_name_type", userVip.getVipNameType())); +// if (vipDetails != null) { +// vipRate = vipDetails.getRate(); +// } +// } +// } catch (Exception e) { +// e.getMessage(); +// } +// } +// } +// orders.setVipRate(vipRate); +// +// if(orders.getUserPackageDetailId() != null) { +// //技师加成金额 +// orders.setTechnicianMoney(BigDecimal.ZERO); +// //技师加成后总额 +// orders.setPriceMarkup(price); +// //会员优惠后金额,及会员减免金额 +// orders.setVipReductionMoney(BigDecimal.ZERO); +// //项目价格 = 会员金额 +// orders.setMassageMoney(price); +// }else{ +// //技师加成金额 +// BigDecimal technicianMoney = price.multiply(orders.getTechnicianRate()).divide(new BigDecimal(100)); +// technicianMoney = technicianMoney.setScale(2,BigDecimal.ROUND_HALF_UP); +// orders.setTechnicianMoney(technicianMoney); +// +// //技师加成后总额 +// BigDecimal priceMarkup = technicianMoney.add(price); +// priceMarkup = priceMarkup.setScale(2,BigDecimal.ROUND_HALF_UP); +// orders.setPriceMarkup(priceMarkup); +// +// //会员优惠后金额,及会员减免金额 +// BigDecimal vipMoney = priceMarkup.multiply(orders.getVipRate()).divide(new BigDecimal(100)); +// vipMoney = vipMoney.setScale(2,BigDecimal.ROUND_HALF_UP); +// BigDecimal vipReductionMoney = priceMarkup.subtract(vipMoney); +// orders.setVipReductionMoney(vipReductionMoney); +// +// //项目价格 = 会员金额 +// BigDecimal payMoney = vipMoney; +// orders.setMassageMoney(payMoney); +// } +// +// +// //项目差价 +// BigDecimal xmchajia = orders.getMassageMoney().subtract(oldOrders.getMassageMoney()); +// TravelPriceVo travelPriceVo = null; +// if(orders.getUserPackageDetailId() != null) { +// travelPriceVo = travelConfService.calcTravelPrice(orders.getArtificerId(), orders.getLongitude(), orders.getLatitude(),orders.getServeTime(),tripWay); +// }else{ +// travelPriceVo = travelConfService.calcTravelPrice(orders.getArtificerId(), orders.getLongitude(), orders.getLatitude(),orders.getServeTime()); +// } +// if (travelPriceVo == null) { +// return Result.error("暂不支持当前地址,请更换其他地址!"); +// } +// //删除未支付,无用的升级新单据 +// List newList = baseMapper.getNewOrdersByOld(oldOrders.getOrdersId()); +// if(newList.size()>0){ +// for(Orders newOrder : newList){ +// if(newOrder.getStatus()==1 || newOrder.getStatus()==4){ +// baseMapper.deleteById(newOrder.getOrdersId()); +// ordersMassageService.removeByOrdersId(newOrder.getOrdersId()); +// } +// } +// } +// taxiMoney = new BigDecimal(travelPriceVo.getTravelPrice()); +// BigDecimal usualTravelMoney = travelPriceVo.getUsualTravelMoney(); +// BigDecimal nightTravelMoney = travelPriceVo.getNightTravelMoney(); +// taxiMoney = taxiMoney.setScale(2,BigDecimal.ROUND_HALF_UP); +// BigDecimal oldTaxiMoney = oldOrders.getTaxiMoney(); +// BigDecimal oldUsualTravelMoney = oldOrders.getUsualTravelMoney(); +// BigDecimal oldNightTravelMoney = oldOrders.getNightTravelMoney(); +// if (taxiMoney.compareTo(oldTaxiMoney) < 0) { +// taxiMoney = oldTaxiMoney; +// usualTravelMoney = oldUsualTravelMoney; +// nightTravelMoney = oldNightTravelMoney; +// } +// orders.setTaxiMoney(taxiMoney); +// orders.setKm(travelPriceVo.getKilometerNum()); +// orders.setUsualTravelMoney(usualTravelMoney); +// orders.setNightTravelMoney(nightTravelMoney); +// //出行交通费差价 +//// BigDecimal cxchajia = taxiMoney.subtract(oldTaxiMoney); +// BigDecimal pccxchajia = usualTravelMoney.subtract(oldUsualTravelMoney); +// BigDecimal yjcxchajia = nightTravelMoney.subtract(oldNightTravelMoney); +// BigDecimal cxchajia = pccxchajia.subtract(yjcxchajia); +// if(cxchajia.compareTo(BigDecimal.ZERO)<0){ +// cxchajia = BigDecimal.ZERO; +// } +// //总差价 +// BigDecimal chajia = xmchajia.add(cxchajia); +// +// if (chajia.compareTo(BigDecimal.ZERO) == 0) { +// orders.setPayMoney(oldOrders.getPayMoney()); +// BigDecimal subtract = orders.getPayMoney().subtract(taxiMoney); +// BigDecimal artificerPrice = subtract.multiply(artificer.getRate()); +// artificerPrice = artificerPrice.setScale(2, BigDecimal.ROUND_HALF_UP); +// +// if(oldOrders.getPayWay().equals(5)){ +// BigDecimal valueStorageDeduction = artificerPrice; +// BigDecimal rate = new BigDecimal(commonInfoService.findOne(449).getValue()); +// orders.setWalletRate(rate); +// rate = rate.divide(new BigDecimal(100)); +// artificerPrice = artificerPrice.multiply(rate); +// artificerPrice = artificerPrice.setScale(2, BigDecimal.ROUND_HALF_UP); +// valueStorageDeduction = valueStorageDeduction.subtract(artificerPrice); +// orders.setValueStorageDeduction(valueStorageDeduction); +// orders.setProjectBenefits(artificerPrice); +// }else{ +// orders.setValueStorageDeduction(BigDecimal.ZERO); +// //计算技师项目提成金额 +// orders.setProjectBenefits(artificerPrice); +// } +// +// UserEntity artificerUser = userService.selectUserById(artificer.getUserId()); +// //经纪人分佣 +// orders.setJjrMoney(BigDecimal.ZERO); +// orders.setJjrArtificerDeductMoney(BigDecimal.ZERO); +// JjrConfig jc = jjrConfigService.getOne(new QueryWrapper()); +// if(jc!=null && jc.getIsOpen().equals(1)){ +// UserEntity jjrUser = userService.queryByInvitationCode(artificerUser.getBlJjrCode()); +// if(jjrUser!=null){ +// JjrApply jjrApply = jjrApplyService.findByUserId(jjrUser.getUserId()); +// if(jjrApply!=null && jjrApply.getStatus().equals(1)){ +// if(jjrUser.getBlIsJjr() !=null && jjrUser.getBlIsJjr() ==1){ +// orders.setJjrUserId(jjrUser.getUserId()); +// orders.setJjrUserName(jjrUser.getUserName()); +// BigDecimal artificerRate = jc.getArtificerRate(); +// BigDecimal agentRate = jc.getAgentRate(); +// BigDecimal rate = BigDecimal.ZERO; +// if(jc.getType().equals(1)){ +// rate = jc.getRate(); +// }else{ +// int invitationCn = jjrApplyService.getInvitationCn(artificerUser.getBlJjrCode()); +// List list = jjrConfigServiceLevel.findList(null); +// for(int i=0;ijjrcl.getMinNumber() && invitationCn<=jjrcl.getMaxNumber()){ +// rate = jjrcl.getRate(); +// break; +// } +// } +// } +// BigDecimal jjrMoney = subtract.multiply(rate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); +// orders.setJjrMoney(jjrMoney); +// BigDecimal jjrOneArtificerDeductMoney = jjrMoney.multiply(artificerRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); +// orders.setJjrArtificerDeductMoney(jjrOneArtificerDeductMoney); +// } +// } +// } +// } +// +// BigDecimal shopMoney = BigDecimal.ZERO; +// if (artificerUser.getConsortiaId() != null) { +// Consortia consortia = consortiaService.getById(artificerUser.getConsortiaId()); +// if (consortia != null && consortia.getUserId() != null) { +// UserEntity consortiaUser = userService.getById(consortia.getUserId()); +// if (consortiaUser != null) { +// orders.setConsortiaId(consortia.getConsortiaId()); +// orders.setShopUserId(consortiaUser.getUserId()); +// orders.setShopUserName(consortiaUser.getUserName()); +// shopMoney = artificerPrice.multiply(consortia.getRate()); +// shopMoney = shopMoney.setScale(2, BigDecimal.ROUND_HALF_UP); +// } +// } +// } +// orders.setShopMoney(shopMoney); +//// UserEntity user = userService.selectUserById(orders.getUserId()); +//// UserEntity oneUser = userService.queryByInvitationCode(user.getInviterCode()); +//// BigDecimal oneUserMoney = BigDecimal.ZERO; +//// if (oneUser != null && oneUser.getIsAgency() != null && oneUser.getIsAgency() == 1) { +//// orders.setOneUserId(oneUser.getUserId()); +//// orders.setOneUserName(oneUser.getUserName()); +//// oneUserMoney = artificerPrice.multiply(oneUser.getUserRate()); +//// oneUserMoney = oneUserMoney.setScale(2, BigDecimal.ROUND_HALF_UP); +//// } +//// orders.setOneUserMoney(oneUserMoney); +// +// //分销商分佣 +// orders.setFxyOneMoney(BigDecimal.ZERO); +// orders.setFxyOneArtificerDeductMoney(BigDecimal.ZERO); +// orders.setFxyTwoMoney(BigDecimal.ZERO); +// orders.setFxyTwoArtificerDeductMoney(BigDecimal.ZERO); +// FxyConfig fc = fxyConfigService.getOne(new QueryWrapper()); +// if(fc!=null && fc.getIsOpen().equals(1)){ +// UserEntity user = userService.selectUserById(orders.getUserId()); +// UserEntity fxyOneUser = userService.queryByInvitationCode(user.getBlFxyCode()); +// if(fxyOneUser!=null){ +// FxyApply faOne = fxyApplyService.findByUserId(fxyOneUser.getUserId()); +// if(faOne!=null && faOne.getStatus().equals(1)){ +// if(fxyOneUser.getBlIsFxy() !=null && fxyOneUser.getBlIsFxy() ==1){ +// boolean isCanFxyFy = false; +// if(fc.getFxmLimit().equals(2)){ +// int fxmLimitDays = fc.getFxmLimitDays(); +// String approveTime = faOne.getApproveTime(); +// Date approveDate = DateUtils.stringToDate(approveTime,DateUtils.DATE_TIME_PATTERN); +// Calendar calendar = Calendar.getInstance(); +// calendar.setTime(approveDate); +// calendar.add(Calendar.DAY_OF_MONTH, fxmLimitDays); +// approveDate = calendar.getTime(); +// Date current = new Date(); +// if(approveDate.getTime() > current.getTime()){ +// isCanFxyFy = true; +// } +// }else{ +// isCanFxyFy = true; +// } +// if(isCanFxyFy){ +// orders.setFxyOneUserId(fxyOneUser.getUserId()); +// orders.setFxyOneUserName(fxyOneUser.getUserName()); +// BigDecimal fxyMoney = BigDecimal.ZERO; +// if(fc.getType().equals(1)){ +// fxyMoney = artificerPrice; +// } +// if(fc.getType().equals(2)){ +// fxyMoney = subtract; +// } +// BigDecimal artificerRate = fc.getArtificerRate(); +// BigDecimal mostRate = fc.getMostRate(); +// BigDecimal oneRate = fc.getOneRate(); +// BigDecimal oneRecommendRate = fc.getOneRecommendRate(); +// BigDecimal fxyRate = BigDecimal.ZERO; +// if(oneRate == null || oneRate.compareTo(BigDecimal.ZERO) == 0){ +// fxyRate = oneRecommendRate; +// if(oneRecommendRate.compareTo(mostRate)> 0){ +// fxyRate = mostRate; +// } +// }else{ +// fxyRate = oneRate; +// if(oneRate.compareTo(mostRate)> 0){ +// fxyRate = mostRate; +// } +// } +// BigDecimal fxyOneMoney = fxyMoney.multiply(fxyRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); +// orders.setFxyOneMoney(fxyOneMoney); +// BigDecimal fxyOneArtificerDeductMoney = fxyOneMoney.multiply(artificerRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); +// orders.setFxyOneArtificerDeductMoney(fxyOneArtificerDeductMoney); +// if(fxyOneUser.getBlFxyLevel().equals(1)){ +// UserEntity fxyTwoUser = userService.queryByInvitationCode(fxyOneUser.getBlFxyCode()); +// if(fxyTwoUser!=null){ +// FxyApply faTwo = fxyApplyService.findByUserId(fxyTwoUser.getUserId()); +// if(faTwo!=null && faTwo.getStatus().equals(1)){ +// if(fxyTwoUser.getBlIsFxy() !=null && fxyTwoUser.getBlIsFxy() ==1){ +// isCanFxyFy = false; +// if(fc.getFxmLimit().equals(2)){ +// int fxmLimitDays = fc.getFxmLimitDays(); +// String approveTime = faTwo.getApproveTime(); +// Date approveDate = DateUtils.stringToDate(approveTime,DateUtils.DATE_TIME_PATTERN); +// Calendar calendar = Calendar.getInstance(); +// calendar.setTime(approveDate); +// calendar.add(Calendar.DAY_OF_MONTH, fxmLimitDays); +// approveDate = calendar.getTime(); +// Date current = new Date(); +// if(approveDate.getTime() > current.getTime()){ +// isCanFxyFy = true; +// } +// }else{ +// isCanFxyFy = true; +// } +// if(isCanFxyFy) { +// orders.setFxyTwoUserId(fxyTwoUser.getUserId()); +// orders.setFxyTwoUserName(fxyTwoUser.getUserName()); +// BigDecimal twoRate = fc.getTwoRate(); +// BigDecimal twoRecommendRate = fc.getTwoRecommendRate(); +// fxyRate = BigDecimal.ZERO; +// if (twoRate == null || twoRate.compareTo(BigDecimal.ZERO) == 0) { +// fxyRate = twoRecommendRate; +// if (twoRecommendRate.compareTo(mostRate) > 0) { +// fxyRate = mostRate; +// } +// } else { +// fxyRate = twoRate; +// if (twoRate.compareTo(mostRate) > 0) { +// fxyRate = mostRate; +// } +// } +// BigDecimal fxyTwoMoney = fxyMoney.multiply(fxyRate).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP); +// orders.setFxyTwoMoney(fxyTwoMoney); +// BigDecimal fxyTwoArtificerDeductMoney = fxyTwoMoney.multiply(artificerRate).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP); +// orders.setFxyTwoArtificerDeductMoney(fxyTwoArtificerDeductMoney); +// } +// } +// } +// } +// } +// } +// } +// } +// } +// } +// +//// artificerPrice = artificerPrice.subtract(oneArtificerMoney); +// artificerPrice = artificerPrice.subtract(orders.getJjrArtificerDeductMoney()); +// artificerPrice = artificerPrice.subtract(shopMoney); +//// artificerPrice = artificerPrice.subtract(oneUserMoney); +// artificerPrice = artificerPrice.subtract(orders.getFxyOneArtificerDeductMoney());//减掉一级分销商分佣技师承担 +// artificerPrice = artificerPrice.subtract(orders.getFxyTwoArtificerDeductMoney());//减掉二级分销商分佣技师承担 +// orders.setArtificerMoney(artificerPrice); +// orders.setSumArtificerMoney(artificerPrice); +// +// //平台扣款 +// BigDecimal pingMoney = orders.getPayMoney(); +// pingMoney = pingMoney.subtract(artificerPrice); +//// pingMoney = pingMoney.subtract(oneArtificerMoney); +// pingMoney = pingMoney.subtract(orders.getJjrMoney()); +// pingMoney = pingMoney.subtract(shopMoney); +//// pingMoney = pingMoney.subtract(oneUserMoney); +// pingMoney = pingMoney.subtract(orders.getFxyOneMoney());//减掉一级分销商分佣 +// pingMoney = pingMoney.subtract(orders.getFxyTwoMoney());//减掉二级分销商分佣 +// orders.setPingMoney(pingMoney); +// orders.setStatus(9); +// //总差价不变,则修改原单据 +// baseMapper.updateById(orders); +// ordersMassageService.removeByOrdersId(orders.getOrdersId()); +// List ordersMassageList = orders.getOrdersMassageList(); +// for (OrdersMassage ordersMassage : ordersMassageList) { +// ordersMassage.setOrdersId(orders.getOrdersId()); +// ordersMassageService.save(ordersMassage); +// } +// +// //删除技师占用时间表数据 +// artificerTimeService.remove(new QueryWrapper().eq("orders_id", orders.getOrdersId())); +// //插入技师占用时间表时间差数据 +// List allTime = (ArrayList)map.get("timeList"); +// if(allTime!=null && allTime.size()>0) { +// for (int x=0;x ordersMassageList = orders.getOrdersMassageList(); +// for (OrdersMassage ordersMassage : ordersMassageList) { +// ordersMassage.setOrdersId(orders.getOrdersId()); +// ordersMassageService.save(ordersMassage); +// } +// +//// //删除技师占用时间表旧数据 +//// artificerTimeService.remove(new QueryWrapper().eq("orders_id", oldOrders.getOrdersId())); +//// //插入技师占用时间表新数据 +//// List allTime = (ArrayList)map.get("timeList"); +//// if(allTime!=null && allTime.size()>0) { +//// for (int x=0;x()); +// if(jc!=null && jc.getIsOpen().equals(1)){ +// UserEntity jjrUser = userService.queryByInvitationCode(artificerUser.getBlJjrCode()); +// if(jjrUser!=null){ +// JjrApply jjrApply = jjrApplyService.findByUserId(jjrUser.getUserId()); +// if(jjrApply!=null && jjrApply.getStatus().equals(1)){ +// if(jjrUser.getBlIsJjr() !=null && jjrUser.getBlIsJjr() ==1){ +// ordersOld.setJjrUserId(jjrUser.getUserId()); +// ordersOld.setJjrUserName(jjrUser.getUserName()); +// BigDecimal artificerRate = jc.getArtificerRate(); +// BigDecimal agentRate = jc.getAgentRate(); +// BigDecimal rate = BigDecimal.ZERO; +// if(jc.getType().equals(1)){ +// rate = jc.getRate(); +// }else{ +// int invitationCn = jjrApplyService.getInvitationCn(artificerUser.getBlJjrCode()); +// List list = jjrConfigServiceLevel.findList(null); +// for(int i=0;ijjrcl.getMinNumber() && invitationCn<=jjrcl.getMaxNumber()){ +// rate = jjrcl.getRate(); +// break; +// } +// } +// } +// BigDecimal jjrMoney = subtract.multiply(rate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); +// ordersOld.setJjrMoney(jjrMoney); +// BigDecimal jjrOneArtificerDeductMoney = jjrMoney.multiply(artificerRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); +// ordersOld.setJjrArtificerDeductMoney(jjrOneArtificerDeductMoney); +// } +// } +// } +// } +// +// BigDecimal shopMoney = BigDecimal.ZERO; +// if (artificerUser.getConsortiaId() != null) { +// Consortia consortia = consortiaService.getById(artificerUser.getConsortiaId()); +// if (consortia != null && consortia.getUserId() != null) { +// UserEntity consortiaUser = userService.getById(consortia.getUserId()); +// if (consortiaUser != null) { +// ordersOld.setConsortiaId(consortia.getConsortiaId()); +// ordersOld.setShopUserId(consortiaUser.getUserId()); +// ordersOld.setShopUserName(consortiaUser.getUserName()); +// shopMoney = oldArtificerPrice.multiply(consortia.getRate()); +// shopMoney = shopMoney.setScale(2, BigDecimal.ROUND_HALF_UP); +// } +// } +// } +// ordersOld.setShopMoney(shopMoney); +//// UserEntity user = userService.selectUserById(orders.getUserId()); +//// UserEntity oneUser = userService.queryByInvitationCode(user.getInviterCode()); +//// BigDecimal oneUserMoney = BigDecimal.ZERO; +//// if (oneUser != null && oneUser.getIsAgency() != null && oneUser.getIsAgency() == 1) { +//// ordersOld.setOneUserId(oneUser.getUserId()); +//// ordersOld.setOneUserName(oneUser.getUserName()); +//// oneUserMoney = oldArtificerPrice.multiply(oneUser.getUserRate()); +//// oneUserMoney = oneUserMoney.setScale(2, BigDecimal.ROUND_HALF_UP); +//// } +//// ordersOld.setOneUserMoney(oneUserMoney); +// +// //分销商分佣 +// ordersOld.setFxyOneMoney(BigDecimal.ZERO); +// ordersOld.setFxyOneArtificerDeductMoney(BigDecimal.ZERO); +// ordersOld.setFxyTwoMoney(BigDecimal.ZERO); +// ordersOld.setFxyTwoArtificerDeductMoney(BigDecimal.ZERO); +// FxyConfig fc = fxyConfigService.getOne(new QueryWrapper()); +// if(fc!=null && fc.getIsOpen().equals(1)){ +// UserEntity user = userService.selectUserById(orders.getUserId()); +// UserEntity fxyOneUser = userService.queryByInvitationCode(user.getBlFxyCode()); +// if(fxyOneUser!=null){ +// FxyApply faOne = fxyApplyService.findByUserId(fxyOneUser.getUserId()); +// if(faOne!=null && faOne.getStatus().equals(1)){ +// if(fxyOneUser.getBlIsFxy() !=null && fxyOneUser.getBlIsFxy() ==1){ +// boolean isCanFxyFy = false; +// if(fc.getFxmLimit().equals(2)){ +// int fxmLimitDays = fc.getFxmLimitDays(); +// String approveTime = faOne.getApproveTime(); +// Date approveDate = DateUtils.stringToDate(approveTime,DateUtils.DATE_TIME_PATTERN); +// Calendar calendar = Calendar.getInstance(); +// calendar.setTime(approveDate); +// calendar.add(Calendar.DAY_OF_MONTH, fxmLimitDays); +// approveDate = calendar.getTime(); +// Date current = new Date(); +// if(approveDate.getTime() > current.getTime()){ +// isCanFxyFy = true; +// } +// }else{ +// isCanFxyFy = true; +// } +// if(isCanFxyFy){ +// ordersOld.setFxyOneUserId(fxyOneUser.getUserId()); +// ordersOld.setFxyOneUserName(fxyOneUser.getUserName()); +// BigDecimal fxyMoney = BigDecimal.ZERO; +// if(fc.getType().equals(1)){ +// fxyMoney = artificerPrice; +// } +// if(fc.getType().equals(2)){ +// fxyMoney = subtract; +// } +// BigDecimal artificerRate = fc.getArtificerRate(); +// BigDecimal mostRate = fc.getMostRate(); +// BigDecimal oneRate = fc.getOneRate(); +// BigDecimal oneRecommendRate = fc.getOneRecommendRate(); +// BigDecimal fxyRate = BigDecimal.ZERO; +// if(oneRate == null || oneRate.compareTo(BigDecimal.ZERO) == 0){ +// fxyRate = oneRecommendRate; +// if(oneRecommendRate.compareTo(mostRate)> 0){ +// fxyRate = mostRate; +// } +// }else{ +// fxyRate = oneRate; +// if(oneRate.compareTo(mostRate)> 0){ +// fxyRate = mostRate; +// } +// } +// BigDecimal fxyOneMoney = fxyMoney.multiply(fxyRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); +// ordersOld.setFxyOneMoney(fxyOneMoney); +// BigDecimal fxyOneArtificerDeductMoney = fxyOneMoney.multiply(artificerRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); +// ordersOld.setFxyOneArtificerDeductMoney(fxyOneArtificerDeductMoney); +// if(fxyOneUser.getBlFxyLevel().equals(1)){ +// UserEntity fxyTwoUser = userService.queryByInvitationCode(fxyOneUser.getBlFxyCode()); +// if(fxyTwoUser!=null){ +// FxyApply faTwo = fxyApplyService.findByUserId(fxyTwoUser.getUserId()); +// if(faTwo!=null && faTwo.getStatus().equals(1)){ +// if(fxyTwoUser.getBlIsFxy() !=null && fxyTwoUser.getBlIsFxy() ==1){ +// isCanFxyFy = false; +// if(fc.getFxmLimit().equals(2)){ +// int fxmLimitDays = fc.getFxmLimitDays(); +// String approveTime = faTwo.getApproveTime(); +// Date approveDate = DateUtils.stringToDate(approveTime,DateUtils.DATE_TIME_PATTERN); +// Calendar calendar = Calendar.getInstance(); +// calendar.setTime(approveDate); +// calendar.add(Calendar.DAY_OF_MONTH, fxmLimitDays); +// approveDate = calendar.getTime(); +// Date current = new Date(); +// if(approveDate.getTime() > current.getTime()){ +// isCanFxyFy = true; +// } +// }else{ +// isCanFxyFy = true; +// } +// if(isCanFxyFy) { +// ordersOld.setFxyTwoUserId(fxyTwoUser.getUserId()); +// ordersOld.setFxyTwoUserName(fxyTwoUser.getUserName()); +// BigDecimal twoRate = fc.getTwoRate(); +// BigDecimal twoRecommendRate = fc.getTwoRecommendRate(); +// fxyRate = BigDecimal.ZERO; +// if (twoRate == null || twoRate.compareTo(BigDecimal.ZERO) == 0) { +// fxyRate = twoRecommendRate; +// if (twoRecommendRate.compareTo(mostRate) > 0) { +// fxyRate = mostRate; +// } +// } else { +// fxyRate = twoRate; +// if (twoRate.compareTo(mostRate) > 0) { +// fxyRate = mostRate; +// } +// } +// BigDecimal fxyTwoMoney = fxyMoney.multiply(fxyRate).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP); +// ordersOld.setFxyTwoMoney(fxyTwoMoney); +// BigDecimal fxyTwoArtificerDeductMoney = fxyTwoMoney.multiply(artificerRate).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP); +// ordersOld.setFxyTwoArtificerDeductMoney(fxyTwoArtificerDeductMoney); +// } +// } +// } +// } +// } +// } +// } +// } +// } +// } +// +//// oldArtificerPrice = oldArtificerPrice.subtract(oneArtificerMoney); +// oldArtificerPrice = oldArtificerPrice.subtract(ordersOld.getJjrArtificerDeductMoney()); +// oldArtificerPrice = oldArtificerPrice.subtract(shopMoney); +//// oldArtificerPrice = oldArtificerPrice.subtract(oneUserMoney); +// oldArtificerPrice = oldArtificerPrice.subtract(ordersOld.getFxyOneArtificerDeductMoney());//减掉一级分销商分佣技师承担 +// oldArtificerPrice = oldArtificerPrice.subtract(ordersOld.getFxyTwoArtificerDeductMoney());//减掉二级分销商分佣技师承担 +// ordersOld.setArtificerMoney(oldArtificerPrice); +// ordersOld.setSumArtificerMoney(oldArtificerPrice); +// +// //平台扣款 +// BigDecimal pingMoney = oldOrders.getPayMoney(); +// pingMoney = pingMoney.subtract(oldArtificerPrice); +//// pingMoney = pingMoney.subtract(oneArtificerMoney); +// pingMoney = pingMoney.subtract(oldOrders.getJjrMoney()); +// pingMoney = pingMoney.subtract(shopMoney); +//// pingMoney = pingMoney.subtract(oneUserMoney); +// pingMoney = pingMoney.subtract(oldOrders.getFxyOneMoney());//减掉一级分销商分佣 +// pingMoney = pingMoney.subtract(oldOrders.getFxyTwoMoney());//减掉二级分销商分佣 +// ordersOld.setPingMoney(pingMoney); +// baseMapper.updateById(ordersOld);//原单暂变成挂单状态 +// return Result.success().put("data", orders); +// } +// } if (oldOrders.getStatus() == 2 || oldOrders.getStatus() == 9 || xgd == 1) { - //只能修改,技师和时间 (技师等级大于等于原单据等级) + //只能时间 (如还需修改技师则将上边注释打开并做调整) //判断是否是可修改,状态2 9 boolean canUpdate = commonInfoService.isCheckEditOrder(DateUtils.stringToDate(oldOrders.getServeTime(), "yyyy-MM-dd HH:mm"), new Date()); if (!canUpdate) { @@ -1854,71 +2632,6 @@ public class OrdersServiceImpl extends ServiceImpl implements return Result.error("当前订单技师等级不能低于原订单技师等级!"); } - orders.setArtificerId(artificer.getArtificerId()); - orders.setTechnicianType(artificer.getTechnicianType()); - orders.setArtificerRate(artificer.getRate()); - BigDecimal artificerVipRate = BigDecimal.ZERO; - VipDetails artificerVipDetails = vipDetailsDao.selectOne(new QueryWrapper().eq("vip_name_type", artificer.getTechnicianType())); - if (artificerVipDetails != null) { - artificerVipRate = artificerVipDetails.getRate(); - } - orders.setTechnicianRate(artificerVipRate); - //获取用户VIP的优惠信息 - BigDecimal vipRate = new BigDecimal(100); - UserVip userVip = userVipService.selectUserVipByUserId(oldOrders.getUserId()); - if (userVip != null) { - if (userVip.getIsVip() == 1) { - //获取用户到期时间 - Date date2 = null; - try { - date2 = DateUtils.stringToDate(userVip.getEndTime(), DateUtils.DATE_TIME_PATTERN); - if (date2.getTime() >= System.currentTimeMillis()) { - VipDetails vipDetails = vipDetailsDao.selectOne(new QueryWrapper().eq("vip_name_type", userVip.getVipNameType())); - if (vipDetails != null) { - vipRate = vipDetails.getRate(); - } - } - } catch (Exception e) { - e.getMessage(); - } - } - } - orders.setVipRate(vipRate); - - if(orders.getUserPackageDetailId() != null) { - //技师加成金额 - orders.setTechnicianMoney(BigDecimal.ZERO); - //技师加成后总额 - orders.setPriceMarkup(price); - //会员优惠后金额,及会员减免金额 - orders.setVipReductionMoney(BigDecimal.ZERO); - //项目价格 = 会员金额 - orders.setMassageMoney(price); - }else{ - //技师加成金额 - BigDecimal technicianMoney = price.multiply(orders.getTechnicianRate()).divide(new BigDecimal(100)); - technicianMoney = technicianMoney.setScale(2,BigDecimal.ROUND_HALF_UP); - orders.setTechnicianMoney(technicianMoney); - - //技师加成后总额 - BigDecimal priceMarkup = technicianMoney.add(price); - priceMarkup = priceMarkup.setScale(2,BigDecimal.ROUND_HALF_UP); - orders.setPriceMarkup(priceMarkup); - - //会员优惠后金额,及会员减免金额 - BigDecimal vipMoney = priceMarkup.multiply(orders.getVipRate()).divide(new BigDecimal(100)); - vipMoney = vipMoney.setScale(2,BigDecimal.ROUND_HALF_UP); - BigDecimal vipReductionMoney = priceMarkup.subtract(vipMoney); - orders.setVipReductionMoney(vipReductionMoney); - - //项目价格 = 会员金额 - BigDecimal payMoney = vipMoney; - orders.setMassageMoney(payMoney); - } - - - //项目差价 - BigDecimal xmchajia = orders.getMassageMoney().subtract(oldOrders.getMassageMoney()); TravelPriceVo travelPriceVo = null; if(orders.getUserPackageDetailId() != null) { travelPriceVo = travelConfService.calcTravelPrice(orders.getArtificerId(), orders.getLongitude(), orders.getLatitude(),orders.getServeTime(),tripWay); @@ -1954,267 +2667,22 @@ public class OrdersServiceImpl extends ServiceImpl implements orders.setKm(travelPriceVo.getKilometerNum()); orders.setUsualTravelMoney(usualTravelMoney); orders.setNightTravelMoney(nightTravelMoney); - //出行交通费差价 -// BigDecimal cxchajia = taxiMoney.subtract(oldTaxiMoney); BigDecimal pccxchajia = usualTravelMoney.subtract(oldUsualTravelMoney); BigDecimal yjcxchajia = nightTravelMoney.subtract(oldNightTravelMoney); - BigDecimal cxchajia = pccxchajia.subtract(yjcxchajia); + //出行交通费差价 + BigDecimal cxchajia = taxiMoney.subtract(oldTaxiMoney); if(cxchajia.compareTo(BigDecimal.ZERO)<0){ cxchajia = BigDecimal.ZERO; } //总差价 - BigDecimal chajia = xmchajia.add(cxchajia); - + BigDecimal chajia =cxchajia; if (chajia.compareTo(BigDecimal.ZERO) == 0) { - orders.setPayMoney(oldOrders.getPayMoney()); - BigDecimal subtract = orders.getPayMoney().subtract(taxiMoney); - BigDecimal artificerPrice = subtract.multiply(artificer.getRate()); - artificerPrice = artificerPrice.setScale(2, BigDecimal.ROUND_HALF_UP); - - if(oldOrders.getPayWay().equals(5)){ - BigDecimal valueStorageDeduction = artificerPrice; - BigDecimal rate = new BigDecimal(commonInfoService.findOne(449).getValue()); - orders.setWalletRate(rate); - rate = rate.divide(new BigDecimal(100)); - artificerPrice = artificerPrice.multiply(rate); - artificerPrice = artificerPrice.setScale(2, BigDecimal.ROUND_HALF_UP); - valueStorageDeduction = valueStorageDeduction.subtract(artificerPrice); - orders.setValueStorageDeduction(valueStorageDeduction); - orders.setProjectBenefits(artificerPrice); - }else{ - orders.setValueStorageDeduction(BigDecimal.ZERO); - //计算技师项目提成金额 - orders.setProjectBenefits(artificerPrice); - } - - UserEntity artificerUser = userService.selectUserById(artificer.getUserId()); - //经纪人分佣 - orders.setJjrMoney(BigDecimal.ZERO); - orders.setJjrArtificerDeductMoney(BigDecimal.ZERO); - JjrConfig jc = jjrConfigService.getOne(new QueryWrapper()); - if(jc!=null && jc.getIsOpen().equals(1)){ - UserEntity jjrUser = userService.queryByInvitationCode(artificerUser.getBlJjrCode()); - if(jjrUser!=null){ - JjrApply jjrApply = jjrApplyService.findByUserId(jjrUser.getUserId()); - if(jjrApply!=null && jjrApply.getStatus().equals(1)){ - if(jjrUser.getBlIsJjr() !=null && jjrUser.getBlIsJjr() ==1){ - orders.setJjrUserId(jjrUser.getUserId()); - orders.setJjrUserName(jjrUser.getUserName()); - BigDecimal artificerRate = jc.getArtificerRate(); - BigDecimal agentRate = jc.getAgentRate(); - BigDecimal rate = BigDecimal.ZERO; - if(jc.getType().equals(1)){ - rate = jc.getRate(); - }else{ - int invitationCn = jjrApplyService.getInvitationCn(artificerUser.getBlJjrCode()); - List list = jjrConfigServiceLevel.findList(null); - for(int i=0;ijjrcl.getMinNumber() && invitationCn<=jjrcl.getMaxNumber()){ - rate = jjrcl.getRate(); - break; - } - } - } - BigDecimal jjrMoney = subtract.multiply(rate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); - orders.setJjrMoney(jjrMoney); - BigDecimal jjrOneArtificerDeductMoney = jjrMoney.multiply(artificerRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); - orders.setJjrArtificerDeductMoney(jjrOneArtificerDeductMoney); - } - } - } - } - - BigDecimal shopMoney = BigDecimal.ZERO; - if (artificerUser.getConsortiaId() != null) { - Consortia consortia = consortiaService.getById(artificerUser.getConsortiaId()); - if (consortia != null && consortia.getUserId() != null) { - UserEntity consortiaUser = userService.getById(consortia.getUserId()); - if (consortiaUser != null) { - orders.setConsortiaId(consortia.getConsortiaId()); - orders.setShopUserId(consortiaUser.getUserId()); - orders.setShopUserName(consortiaUser.getUserName()); - shopMoney = artificerPrice.multiply(consortia.getRate()); - shopMoney = shopMoney.setScale(2, BigDecimal.ROUND_HALF_UP); - } - } - } - orders.setShopMoney(shopMoney); -// UserEntity user = userService.selectUserById(orders.getUserId()); -// UserEntity oneUser = userService.queryByInvitationCode(user.getInviterCode()); -// BigDecimal oneUserMoney = BigDecimal.ZERO; -// if (oneUser != null && oneUser.getIsAgency() != null && oneUser.getIsAgency() == 1) { -// orders.setOneUserId(oneUser.getUserId()); -// orders.setOneUserName(oneUser.getUserName()); -// oneUserMoney = artificerPrice.multiply(oneUser.getUserRate()); -// oneUserMoney = oneUserMoney.setScale(2, BigDecimal.ROUND_HALF_UP); -// } -// orders.setOneUserMoney(oneUserMoney); - - //分销商分佣 - orders.setFxyOneMoney(BigDecimal.ZERO); - orders.setFxyOneArtificerDeductMoney(BigDecimal.ZERO); - orders.setFxyTwoMoney(BigDecimal.ZERO); - orders.setFxyTwoArtificerDeductMoney(BigDecimal.ZERO); - FxyConfig fc = fxyConfigService.getOne(new QueryWrapper()); - if(fc!=null && fc.getIsOpen().equals(1)){ - UserEntity user = userService.selectUserById(orders.getUserId()); - UserEntity fxyOneUser = userService.queryByInvitationCode(user.getBlFxyCode()); - if(fxyOneUser!=null){ - FxyApply faOne = fxyApplyService.findByUserId(fxyOneUser.getUserId()); - if(faOne!=null && faOne.getStatus().equals(1)){ - if(fxyOneUser.getBlIsFxy() !=null && fxyOneUser.getBlIsFxy() ==1){ - boolean isCanFxyFy = false; - if(fc.getFxmLimit().equals(2)){ - int fxmLimitDays = fc.getFxmLimitDays(); - String approveTime = faOne.getApproveTime(); - Date approveDate = DateUtils.stringToDate(approveTime,DateUtils.DATE_TIME_PATTERN); - Calendar calendar = Calendar.getInstance(); - calendar.setTime(approveDate); - calendar.add(Calendar.DAY_OF_MONTH, fxmLimitDays); - approveDate = calendar.getTime(); - Date current = new Date(); - if(approveDate.getTime() > current.getTime()){ - isCanFxyFy = true; - } - }else{ - isCanFxyFy = true; - } - if(isCanFxyFy){ - orders.setFxyOneUserId(fxyOneUser.getUserId()); - orders.setFxyOneUserName(fxyOneUser.getUserName()); - BigDecimal fxyMoney = BigDecimal.ZERO; - if(fc.getType().equals(1)){ - fxyMoney = artificerPrice; - } - if(fc.getType().equals(2)){ - fxyMoney = subtract; - } - BigDecimal artificerRate = fc.getArtificerRate(); - BigDecimal mostRate = fc.getMostRate(); - BigDecimal oneRate = fc.getOneRate(); - BigDecimal oneRecommendRate = fc.getOneRecommendRate(); - BigDecimal fxyRate = BigDecimal.ZERO; - if(oneRate == null || oneRate.compareTo(BigDecimal.ZERO) == 0){ - fxyRate = oneRecommendRate; - if(oneRecommendRate.compareTo(mostRate)> 0){ - fxyRate = mostRate; - } - }else{ - fxyRate = oneRate; - if(oneRate.compareTo(mostRate)> 0){ - fxyRate = mostRate; - } - } - BigDecimal fxyOneMoney = fxyMoney.multiply(fxyRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); - orders.setFxyOneMoney(fxyOneMoney); - BigDecimal fxyOneArtificerDeductMoney = fxyOneMoney.multiply(artificerRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); - orders.setFxyOneArtificerDeductMoney(fxyOneArtificerDeductMoney); - if(fxyOneUser.getBlFxyLevel().equals(1)){ - UserEntity fxyTwoUser = userService.queryByInvitationCode(fxyOneUser.getBlFxyCode()); - if(fxyTwoUser!=null){ - FxyApply faTwo = fxyApplyService.findByUserId(fxyTwoUser.getUserId()); - if(faTwo!=null && faTwo.getStatus().equals(1)){ - if(fxyTwoUser.getBlIsFxy() !=null && fxyTwoUser.getBlIsFxy() ==1){ - isCanFxyFy = false; - if(fc.getFxmLimit().equals(2)){ - int fxmLimitDays = fc.getFxmLimitDays(); - String approveTime = faTwo.getApproveTime(); - Date approveDate = DateUtils.stringToDate(approveTime,DateUtils.DATE_TIME_PATTERN); - Calendar calendar = Calendar.getInstance(); - calendar.setTime(approveDate); - calendar.add(Calendar.DAY_OF_MONTH, fxmLimitDays); - approveDate = calendar.getTime(); - Date current = new Date(); - if(approveDate.getTime() > current.getTime()){ - isCanFxyFy = true; - } - }else{ - isCanFxyFy = true; - } - if(isCanFxyFy) { - orders.setFxyTwoUserId(fxyTwoUser.getUserId()); - orders.setFxyTwoUserName(fxyTwoUser.getUserName()); - BigDecimal twoRate = fc.getTwoRate(); - BigDecimal twoRecommendRate = fc.getTwoRecommendRate(); - fxyRate = BigDecimal.ZERO; - if (twoRate == null || twoRate.compareTo(BigDecimal.ZERO) == 0) { - fxyRate = twoRecommendRate; - if (twoRecommendRate.compareTo(mostRate) > 0) { - fxyRate = mostRate; - } - } else { - fxyRate = twoRate; - if (twoRate.compareTo(mostRate) > 0) { - fxyRate = mostRate; - } - } - BigDecimal fxyTwoMoney = fxyMoney.multiply(fxyRate).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP); - orders.setFxyTwoMoney(fxyTwoMoney); - BigDecimal fxyTwoArtificerDeductMoney = fxyTwoMoney.multiply(artificerRate).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP); - orders.setFxyTwoArtificerDeductMoney(fxyTwoArtificerDeductMoney); - } - } - } - } - } - } - } - } - } - } - -// artificerPrice = artificerPrice.subtract(oneArtificerMoney); - artificerPrice = artificerPrice.subtract(orders.getJjrArtificerDeductMoney()); - artificerPrice = artificerPrice.subtract(shopMoney); -// artificerPrice = artificerPrice.subtract(oneUserMoney); - artificerPrice = artificerPrice.subtract(orders.getFxyOneArtificerDeductMoney());//减掉一级分销商分佣技师承担 - artificerPrice = artificerPrice.subtract(orders.getFxyTwoArtificerDeductMoney());//减掉二级分销商分佣技师承担 - orders.setArtificerMoney(artificerPrice); - orders.setSumArtificerMoney(artificerPrice); - - //平台扣款 - BigDecimal pingMoney = orders.getPayMoney(); - pingMoney = pingMoney.subtract(artificerPrice); -// pingMoney = pingMoney.subtract(oneArtificerMoney); - pingMoney = pingMoney.subtract(orders.getJjrMoney()); - pingMoney = pingMoney.subtract(shopMoney); -// pingMoney = pingMoney.subtract(oneUserMoney); - pingMoney = pingMoney.subtract(orders.getFxyOneMoney());//减掉一级分销商分佣 - pingMoney = pingMoney.subtract(orders.getFxyTwoMoney());//减掉二级分销商分佣 - orders.setPingMoney(pingMoney); orders.setStatus(9); //总差价不变,则修改原单据 baseMapper.updateById(orders); - ordersMassageService.removeByOrdersId(orders.getOrdersId()); - List ordersMassageList = orders.getOrdersMassageList(); - for (OrdersMassage ordersMassage : ordersMassageList) { - ordersMassage.setOrdersId(orders.getOrdersId()); - ordersMassageService.save(ordersMassage); - } - - //删除技师占用时间表数据 - artificerTimeService.remove(new QueryWrapper().eq("orders_id", orders.getOrdersId())); - //插入技师占用时间表时间差数据 - List allTime = (ArrayList)map.get("timeList"); - if(allTime!=null && allTime.size()>0) { - for (int x=0;x implements //计算项目收益 //计算技师项目提成金额 + BigDecimal xmchajia = BigDecimal.ZERO; BigDecimal subtract = xmchajia; artificerPrice = xmchajia.multiply(artificer.getRate()).setScale(2, BigDecimal.ROUND_HALF_UP); orders.setProjectBenefits(artificerPrice); @@ -2273,6 +2742,18 @@ public class OrdersServiceImpl extends ServiceImpl implements orders.setOldPriceMarkup(oldOrders.getPriceMarkup()); orders.setOldTechnicianMoney(oldOrders.getTechnicianMoney()); orders.setOldVipReductionMoney(oldOrders.getVipReductionMoney()); + + orders.setArtificerRate(oldOrders.getArtificerRate()); + orders.setVipRate(oldOrders.getVipRate()); + orders.setTechnicianRate(oldOrders.getTechnicianRate()); + orders.setTechnicianRate(oldOrders.getTechnicianRate()); + orders.setTechnicianType(oldOrders.getTechnicianType()); + + orders.setMassageMoney(oldOrders.getMassageMoney()); + orders.setPriceMarkup(oldOrders.getPriceMarkup()); + orders.setTechnicianMoney(oldOrders.getTechnicianMoney()); + orders.setVipReductionMoney(oldOrders.getVipReductionMoney()); + //保存订单 baseMapper.insert(orders); @@ -2283,264 +2764,9 @@ public class OrdersServiceImpl extends ServiceImpl implements ordersMassageService.save(ordersMassage); } -// //删除技师占用时间表旧数据 -// artificerTimeService.remove(new QueryWrapper().eq("orders_id", oldOrders.getOrdersId())); -// //插入技师占用时间表新数据 -// List allTime = (ArrayList)map.get("timeList"); -// if(allTime!=null && allTime.size()>0) { -// for (int x=0;x()); - if(jc!=null && jc.getIsOpen().equals(1)){ - UserEntity jjrUser = userService.queryByInvitationCode(artificerUser.getBlJjrCode()); - if(jjrUser!=null){ - JjrApply jjrApply = jjrApplyService.findByUserId(jjrUser.getUserId()); - if(jjrApply!=null && jjrApply.getStatus().equals(1)){ - if(jjrUser.getBlIsJjr() !=null && jjrUser.getBlIsJjr() ==1){ - ordersOld.setJjrUserId(jjrUser.getUserId()); - ordersOld.setJjrUserName(jjrUser.getUserName()); - BigDecimal artificerRate = jc.getArtificerRate(); - BigDecimal agentRate = jc.getAgentRate(); - BigDecimal rate = BigDecimal.ZERO; - if(jc.getType().equals(1)){ - rate = jc.getRate(); - }else{ - int invitationCn = jjrApplyService.getInvitationCn(artificerUser.getBlJjrCode()); - List list = jjrConfigServiceLevel.findList(null); - for(int i=0;ijjrcl.getMinNumber() && invitationCn<=jjrcl.getMaxNumber()){ - rate = jjrcl.getRate(); - break; - } - } - } - BigDecimal jjrMoney = subtract.multiply(rate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); - ordersOld.setJjrMoney(jjrMoney); - BigDecimal jjrOneArtificerDeductMoney = jjrMoney.multiply(artificerRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); - ordersOld.setJjrArtificerDeductMoney(jjrOneArtificerDeductMoney); - } - } - } - } - - BigDecimal shopMoney = BigDecimal.ZERO; - if (artificerUser.getConsortiaId() != null) { - Consortia consortia = consortiaService.getById(artificerUser.getConsortiaId()); - if (consortia != null && consortia.getUserId() != null) { - UserEntity consortiaUser = userService.getById(consortia.getUserId()); - if (consortiaUser != null) { - ordersOld.setConsortiaId(consortia.getConsortiaId()); - ordersOld.setShopUserId(consortiaUser.getUserId()); - ordersOld.setShopUserName(consortiaUser.getUserName()); - shopMoney = oldArtificerPrice.multiply(consortia.getRate()); - shopMoney = shopMoney.setScale(2, BigDecimal.ROUND_HALF_UP); - } - } - } - ordersOld.setShopMoney(shopMoney); -// UserEntity user = userService.selectUserById(orders.getUserId()); -// UserEntity oneUser = userService.queryByInvitationCode(user.getInviterCode()); -// BigDecimal oneUserMoney = BigDecimal.ZERO; -// if (oneUser != null && oneUser.getIsAgency() != null && oneUser.getIsAgency() == 1) { -// ordersOld.setOneUserId(oneUser.getUserId()); -// ordersOld.setOneUserName(oneUser.getUserName()); -// oneUserMoney = oldArtificerPrice.multiply(oneUser.getUserRate()); -// oneUserMoney = oneUserMoney.setScale(2, BigDecimal.ROUND_HALF_UP); -// } -// ordersOld.setOneUserMoney(oneUserMoney); - - //分销商分佣 - ordersOld.setFxyOneMoney(BigDecimal.ZERO); - ordersOld.setFxyOneArtificerDeductMoney(BigDecimal.ZERO); - ordersOld.setFxyTwoMoney(BigDecimal.ZERO); - ordersOld.setFxyTwoArtificerDeductMoney(BigDecimal.ZERO); - FxyConfig fc = fxyConfigService.getOne(new QueryWrapper()); - if(fc!=null && fc.getIsOpen().equals(1)){ - UserEntity user = userService.selectUserById(orders.getUserId()); - UserEntity fxyOneUser = userService.queryByInvitationCode(user.getBlFxyCode()); - if(fxyOneUser!=null){ - FxyApply faOne = fxyApplyService.findByUserId(fxyOneUser.getUserId()); - if(faOne!=null && faOne.getStatus().equals(1)){ - if(fxyOneUser.getBlIsFxy() !=null && fxyOneUser.getBlIsFxy() ==1){ - boolean isCanFxyFy = false; - if(fc.getFxmLimit().equals(2)){ - int fxmLimitDays = fc.getFxmLimitDays(); - String approveTime = faOne.getApproveTime(); - Date approveDate = DateUtils.stringToDate(approveTime,DateUtils.DATE_TIME_PATTERN); - Calendar calendar = Calendar.getInstance(); - calendar.setTime(approveDate); - calendar.add(Calendar.DAY_OF_MONTH, fxmLimitDays); - approveDate = calendar.getTime(); - Date current = new Date(); - if(approveDate.getTime() > current.getTime()){ - isCanFxyFy = true; - } - }else{ - isCanFxyFy = true; - } - if(isCanFxyFy){ - ordersOld.setFxyOneUserId(fxyOneUser.getUserId()); - ordersOld.setFxyOneUserName(fxyOneUser.getUserName()); - BigDecimal fxyMoney = BigDecimal.ZERO; - if(fc.getType().equals(1)){ - fxyMoney = artificerPrice; - } - if(fc.getType().equals(2)){ - fxyMoney = subtract; - } - BigDecimal artificerRate = fc.getArtificerRate(); - BigDecimal mostRate = fc.getMostRate(); - BigDecimal oneRate = fc.getOneRate(); - BigDecimal oneRecommendRate = fc.getOneRecommendRate(); - BigDecimal fxyRate = BigDecimal.ZERO; - if(oneRate == null || oneRate.compareTo(BigDecimal.ZERO) == 0){ - fxyRate = oneRecommendRate; - if(oneRecommendRate.compareTo(mostRate)> 0){ - fxyRate = mostRate; - } - }else{ - fxyRate = oneRate; - if(oneRate.compareTo(mostRate)> 0){ - fxyRate = mostRate; - } - } - BigDecimal fxyOneMoney = fxyMoney.multiply(fxyRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); - ordersOld.setFxyOneMoney(fxyOneMoney); - BigDecimal fxyOneArtificerDeductMoney = fxyOneMoney.multiply(artificerRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); - ordersOld.setFxyOneArtificerDeductMoney(fxyOneArtificerDeductMoney); - if(fxyOneUser.getBlFxyLevel().equals(1)){ - UserEntity fxyTwoUser = userService.queryByInvitationCode(fxyOneUser.getBlFxyCode()); - if(fxyTwoUser!=null){ - FxyApply faTwo = fxyApplyService.findByUserId(fxyTwoUser.getUserId()); - if(faTwo!=null && faTwo.getStatus().equals(1)){ - if(fxyTwoUser.getBlIsFxy() !=null && fxyTwoUser.getBlIsFxy() ==1){ - isCanFxyFy = false; - if(fc.getFxmLimit().equals(2)){ - int fxmLimitDays = fc.getFxmLimitDays(); - String approveTime = faTwo.getApproveTime(); - Date approveDate = DateUtils.stringToDate(approveTime,DateUtils.DATE_TIME_PATTERN); - Calendar calendar = Calendar.getInstance(); - calendar.setTime(approveDate); - calendar.add(Calendar.DAY_OF_MONTH, fxmLimitDays); - approveDate = calendar.getTime(); - Date current = new Date(); - if(approveDate.getTime() > current.getTime()){ - isCanFxyFy = true; - } - }else{ - isCanFxyFy = true; - } - if(isCanFxyFy) { - ordersOld.setFxyTwoUserId(fxyTwoUser.getUserId()); - ordersOld.setFxyTwoUserName(fxyTwoUser.getUserName()); - BigDecimal twoRate = fc.getTwoRate(); - BigDecimal twoRecommendRate = fc.getTwoRecommendRate(); - fxyRate = BigDecimal.ZERO; - if (twoRate == null || twoRate.compareTo(BigDecimal.ZERO) == 0) { - fxyRate = twoRecommendRate; - if (twoRecommendRate.compareTo(mostRate) > 0) { - fxyRate = mostRate; - } - } else { - fxyRate = twoRate; - if (twoRate.compareTo(mostRate) > 0) { - fxyRate = mostRate; - } - } - BigDecimal fxyTwoMoney = fxyMoney.multiply(fxyRate).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP); - ordersOld.setFxyTwoMoney(fxyTwoMoney); - BigDecimal fxyTwoArtificerDeductMoney = fxyTwoMoney.multiply(artificerRate).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP); - ordersOld.setFxyTwoArtificerDeductMoney(fxyTwoArtificerDeductMoney); - } - } - } - } - } - } - } - } - } - } - -// oldArtificerPrice = oldArtificerPrice.subtract(oneArtificerMoney); - oldArtificerPrice = oldArtificerPrice.subtract(ordersOld.getJjrArtificerDeductMoney()); - oldArtificerPrice = oldArtificerPrice.subtract(shopMoney); -// oldArtificerPrice = oldArtificerPrice.subtract(oneUserMoney); - oldArtificerPrice = oldArtificerPrice.subtract(ordersOld.getFxyOneArtificerDeductMoney());//减掉一级分销商分佣技师承担 - oldArtificerPrice = oldArtificerPrice.subtract(ordersOld.getFxyTwoArtificerDeductMoney());//减掉二级分销商分佣技师承担 - ordersOld.setArtificerMoney(oldArtificerPrice); - ordersOld.setSumArtificerMoney(oldArtificerPrice); - - //平台扣款 - BigDecimal pingMoney = oldOrders.getPayMoney(); - pingMoney = pingMoney.subtract(oldArtificerPrice); -// pingMoney = pingMoney.subtract(oneArtificerMoney); - pingMoney = pingMoney.subtract(oldOrders.getJjrMoney()); - pingMoney = pingMoney.subtract(shopMoney); -// pingMoney = pingMoney.subtract(oneUserMoney); - pingMoney = pingMoney.subtract(oldOrders.getFxyOneMoney());//减掉一级分销商分佣 - pingMoney = pingMoney.subtract(oldOrders.getFxyTwoMoney());//减掉二级分销商分佣 - ordersOld.setPingMoney(pingMoney); baseMapper.updateById(ordersOld);//原单暂变成挂单状态 return Result.success().put("data", orders); } diff --git a/src/main/resources/mapper/bl/massage/MassagePackageDao.xml b/src/main/resources/mapper/bl/massage/MassagePackageDao.xml index 23fcc7b..460c895 100644 --- a/src/main/resources/mapper/bl/massage/MassagePackageDao.xml +++ b/src/main/resources/mapper/bl/massage/MassagePackageDao.xml @@ -73,7 +73,7 @@ inner join massage_type t on t.massage_type_id = d.massage_type_id and t.status = 1 where d.main_id = a.id ) else 1 end - ) as service_count + ) as service_count,a.level from bl_massage_package a left join sys_dict b on a.type = b.id where a.status = 1 @@ -92,7 +92,7 @@ union all select massage_type_id as id,title,classify_id as type,b.value as type_name,old_price,price,massage_img,jianjie,content_img,add_num,sales,labels,'项目' as flag,1 as is_can_coupon,1 as is_can_vip, - 1 as service_count + 1 as service_count, 0 as level from massage_type a left join sys_dict b on a.classify_id = b.id where a.status = 1