修改订单
This commit is contained in:
parent
000d901f00
commit
a2c415c3d8
|
@ -76,6 +76,7 @@ import org.joda.time.format.DateTimeFormatter;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.scheduling.annotation.Scheduled;
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import weixin.popular.bean.message.templatemessage.TemplateMessageItem;
|
import weixin.popular.bean.message.templatemessage.TemplateMessageItem;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
@ -876,9 +877,623 @@ public class OrdersServiceImpl extends ServiceImpl<OrdersDao, Orders> implements
|
||||||
return Result.success().put("data", orders);
|
return Result.success().put("data", orders);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 入参与insertOrders一致,就是没有代金券
|
||||||
|
* 判断差额,如差额为0则修改原单据,如差额不为0则新增单据。
|
||||||
|
* @param orders
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional
|
||||||
public Result updateOrders(Orders orders) {
|
public Result updateOrders(Orders orders) {
|
||||||
Orders oldOrders = baseMapper.selectById(orders.getOrdersId());
|
Orders oldOrders = baseMapper.selectById(orders.getOrdersId());
|
||||||
|
|
||||||
|
if (oldOrders.getStatus() == 3 || oldOrders.getStatus() == 5) {
|
||||||
|
return Result.error("已完成的订单不可修改!");
|
||||||
|
}
|
||||||
|
if (oldOrders.getStatus() == 4) {
|
||||||
|
return Result.error("已取消的订单不可修改!");
|
||||||
|
}
|
||||||
|
if (oldOrders.getStatus() == 10) {
|
||||||
|
//只能修改,技师和时间 (技师等级大于等于原单据等级)
|
||||||
|
Long massageTypeId;
|
||||||
|
if(orders.getOrdersMassageList() != null){
|
||||||
|
List<OrdersMassage> ordersMassageList = orders.getOrdersMassageList();
|
||||||
|
massageTypeId = ordersMassageList.get(0).getMassageId();
|
||||||
|
}else {
|
||||||
|
massageTypeId = orders.getMassageTypeId();
|
||||||
|
}
|
||||||
|
if(massageTypeId == null){
|
||||||
|
return Result.error("当前订单没有选择服务项目!");
|
||||||
|
}
|
||||||
|
if (orders.getMassageTypeId()!=null && massageTypeId != oldOrders.getMassageTypeId()) {
|
||||||
|
return Result.error("当前订单无法修改服务项目!");
|
||||||
|
}
|
||||||
|
MassageType massageType = massageTypeService.getById(massageTypeId);
|
||||||
|
orders.setMassageTypeId(massageTypeId);
|
||||||
|
orders.setEntryName(massageType.getTitle());
|
||||||
|
orders.setPrice(BigDecimal.ZERO);
|
||||||
|
|
||||||
|
String value1 = commonInfoService.findOne(395).getValue();
|
||||||
|
int i = 0;
|
||||||
|
//1.锁定本单服务时间问题
|
||||||
|
//项目时间
|
||||||
|
Integer duration = massageType.getDuration();
|
||||||
|
//精油
|
||||||
|
String jyValue = commonInfoService.findOne(392).getValue();
|
||||||
|
|
||||||
|
int minute=0;
|
||||||
|
int jyMinuteInt = Integer.parseInt(jyValue);
|
||||||
|
//公交1h,出租30 , 免费 1h(加出行时间)
|
||||||
|
Integer tripWay = orders.getTripWay();
|
||||||
|
if(Objects.nonNull(tripWay)&&(tripWay==1 || tripWay==3)){
|
||||||
|
duration=duration+30;
|
||||||
|
}
|
||||||
|
if ("是".equals(value1)) {
|
||||||
|
if(orders.getClassifyId() == 91){
|
||||||
|
minute=jyMinuteInt;
|
||||||
|
if (duration % minute == 0) {
|
||||||
|
i = duration / minute;
|
||||||
|
} else {
|
||||||
|
i = duration / minute;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
minute=jyMinuteInt;
|
||||||
|
if (duration % minute == 0) {
|
||||||
|
i = duration / minute;
|
||||||
|
} else {
|
||||||
|
i = duration / minute;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String serveTime = orders.getServeTime();
|
||||||
|
String date = serveTime.substring(0, 10);
|
||||||
|
String time = serveTime.substring(11, 16);
|
||||||
|
ArtificerTime artificerTime = artificerTimeService.getOne(
|
||||||
|
new QueryWrapper<ArtificerTime>()
|
||||||
|
.eq("artificer_id", orders.getArtificerId())
|
||||||
|
.eq("artificer_date", date).eq("artificer_time", time));
|
||||||
|
if (artificerTime != null) {
|
||||||
|
return Result.error("预约时间正忙,请更换其他时间!");
|
||||||
|
}
|
||||||
|
if (i > 1) {
|
||||||
|
Date parse = DateUtils.stringToDate(serveTime,"yyyy-MM-dd HH:mm");;
|
||||||
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
calendar.setTime(parse);
|
||||||
|
for (int j = 1; j < i; j++) {
|
||||||
|
calendar.add(Calendar.MINUTE, minute);
|
||||||
|
String format = DateUtils.format(calendar.getTime());
|
||||||
|
date = format.substring(0, 10);
|
||||||
|
time = format.substring(11, 16);
|
||||||
|
artificerTime = artificerTimeService.getOne(
|
||||||
|
new QueryWrapper<ArtificerTime>()
|
||||||
|
.eq("artificer_id", orders.getArtificerId())
|
||||||
|
.eq("artificer_date", date).eq("artificer_time", time));
|
||||||
|
if (artificerTime != null) {
|
||||||
|
return Result.error("预约时间正忙,请更换其他时间!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TravelPriceVo travelPriceVo = travelConfService.calcTravelPrice(orders.getArtificerId(), orders.getLongitude(), orders.getLatitude());
|
||||||
|
if (travelPriceVo == null) {
|
||||||
|
return Result.error("暂不支持当前地址,请更换其他地址!");
|
||||||
|
}
|
||||||
|
BigDecimal taxiMoney = new BigDecimal(travelPriceVo.getTravelPrice());
|
||||||
|
orders.setTaxiMoney(taxiMoney);
|
||||||
|
orders.setKm(travelPriceVo.getKilometerNum());
|
||||||
|
orders.setPayMoney(taxiMoney);
|
||||||
|
orders.setStatus(1);
|
||||||
|
orders.setCreateTime(DateUtils.format(new Date()));
|
||||||
|
Artificer artificer = artificerService.getById(orders.getArtificerId());
|
||||||
|
orders.setArtificerRate(artificer.getRate());
|
||||||
|
orders.setSumMoney(orders.getPayMoney());
|
||||||
|
baseMapper.insert(orders);
|
||||||
|
|
||||||
|
if(orders.getOrdersMassageList() != null){
|
||||||
|
List<OrdersMassage> ordersMassageList = orders.getOrdersMassageList();
|
||||||
|
for (OrdersMassage ordersMassage : ordersMassageList) {
|
||||||
|
ordersMassage.setOrdersId(orders.getOrdersId());
|
||||||
|
ordersMassageService.save(ordersMassage);
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
OrdersMassage ordersMassage = new OrdersMassage();
|
||||||
|
ordersMassage.setOrdersId(orders.getOrdersId());
|
||||||
|
ordersMassage.setMassageId(massageTypeId);
|
||||||
|
ordersMassage.setNum(1);
|
||||||
|
ordersMassageService.save(ordersMassage);
|
||||||
|
}
|
||||||
|
Orders ordersOld = new Orders();
|
||||||
|
ordersOld.setOrdersId(orders.getOrdersId());
|
||||||
|
ordersOld.setStatus(11);
|
||||||
|
baseMapper.updateById(ordersOld);//原单暂变成挂单状态
|
||||||
|
return Result.success().put("data", orders);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (oldOrders.getStatus() == 6) {
|
||||||
|
//升级项目操作,只能修改,项目(金额大于等于当前项目金额)
|
||||||
|
if (StringUtils.isNotBlank(orders.getServeTime()) && !orders.getServeTime().equals(oldOrders.getServeTime())) {
|
||||||
|
return Result.error("当前订单无法修改时间!");
|
||||||
|
}
|
||||||
|
if (orders.getArtificerId() != null && orders.getArtificerId() != oldOrders.getArtificerId()) {
|
||||||
|
return Result.error("当前订单无法修改技师!");
|
||||||
|
}
|
||||||
|
//判断新price是否大于旧price
|
||||||
|
//如果是套餐使用原价计算差额
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
if (oldOrders.getStatus() == 1) {
|
||||||
|
//未支付随便改,更新原单据
|
||||||
|
Long massageTypeId;
|
||||||
|
if(orders.getOrdersMassageList() != null){
|
||||||
|
List<OrdersMassage> ordersMassageList = orders.getOrdersMassageList();
|
||||||
|
massageTypeId = ordersMassageList.get(0).getMassageId();
|
||||||
|
}else {
|
||||||
|
return Result.error("当前订单没有选择服务项目!");
|
||||||
|
}
|
||||||
|
if(orders.getUserPackageDetailId() !=null ){
|
||||||
|
if (massageTypeId != oldOrders.getUserPackageDetailId()) {
|
||||||
|
return Result.error("当前套餐类订单无法修改项目!");
|
||||||
|
}
|
||||||
|
UserPackageDetail userPackageDetail = userPackageDetailService.getById(massageTypeId);
|
||||||
|
//修改套餐类订单
|
||||||
|
String value1 = commonInfoService.findOne(395).getValue();
|
||||||
|
int i = 0;
|
||||||
|
//1.锁定本单服务时间问题
|
||||||
|
//项目时间
|
||||||
|
Integer duration = userPackageDetail.getDuration();
|
||||||
|
//精油
|
||||||
|
String jyValue = commonInfoService.findOne(392).getValue();
|
||||||
|
int minute=0;
|
||||||
|
int jyMinuteInt = Integer.parseInt(jyValue);
|
||||||
|
//公交1h,出租30 , 免费 1h(加出行时间)
|
||||||
|
Integer tripWay = orders.getTripWay();
|
||||||
|
if(Objects.nonNull(tripWay)&&(tripWay==1 || tripWay==3)){
|
||||||
|
duration=duration+30;
|
||||||
|
}
|
||||||
|
if ("是".equals(value1)) {
|
||||||
|
if(orders.getClassifyId() == 91){
|
||||||
|
minute=jyMinuteInt;
|
||||||
|
if (duration % minute == 0) {
|
||||||
|
i = duration / minute;
|
||||||
|
} else {
|
||||||
|
i = duration / minute;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
minute=jyMinuteInt;
|
||||||
|
if (duration % minute == 0) {
|
||||||
|
i = duration / minute;
|
||||||
|
} else {
|
||||||
|
i = duration / minute;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BigDecimal taxiMoney = BigDecimal.ZERO;
|
||||||
|
if (orders.getParentId() == null || orders.getParentId() == 0) {
|
||||||
|
String serveTime = orders.getServeTime();
|
||||||
|
String date = serveTime.substring(0, 10);
|
||||||
|
String time = serveTime.substring(11, 16);
|
||||||
|
ArtificerTime artificerTime = artificerTimeService.getOne(
|
||||||
|
new QueryWrapper<ArtificerTime>()
|
||||||
|
.eq("artificer_id", orders.getArtificerId())
|
||||||
|
.eq("artificer_date", date).eq("artificer_time", time));
|
||||||
|
if (artificerTime != null) {
|
||||||
|
return Result.error("预约时间正忙,请更换其他时间!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i > 1) {
|
||||||
|
Date parse = DateUtils.stringToDate(serveTime, "yyyy-MM-dd HH:mm");
|
||||||
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
calendar.setTime(parse);
|
||||||
|
for (int j = 1; j < i; j++) {
|
||||||
|
calendar.add(Calendar.MINUTE, minute);
|
||||||
|
String format = DateUtils.format(calendar.getTime());
|
||||||
|
date = format.substring(0, 10);
|
||||||
|
time = format.substring(11, 16);
|
||||||
|
artificerTime = artificerTimeService.getOne(
|
||||||
|
new QueryWrapper<ArtificerTime>()
|
||||||
|
.eq("artificer_id", orders.getArtificerId())
|
||||||
|
.eq("artificer_date", date).eq("artificer_time", time));
|
||||||
|
if (artificerTime != null) {
|
||||||
|
return Result.error("预约时间正忙,请更换其他时间!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TravelPriceVo travelPriceVo = travelConfService.calcTravelPrice(orders.getArtificerId(), orders.getLongitude(), orders.getLatitude());
|
||||||
|
if (travelPriceVo == null) {
|
||||||
|
return Result.error("暂不支持当前地址,请更换其他地址!");
|
||||||
|
}
|
||||||
|
taxiMoney = new BigDecimal(travelPriceVo.getTravelPrice());
|
||||||
|
orders.setTaxiMoney(taxiMoney);
|
||||||
|
orders.setKm(travelPriceVo.getKilometerNum());
|
||||||
|
|
||||||
|
} else {
|
||||||
|
if ("是".equals(value1)) {
|
||||||
|
ArtificerTime artificerTime = artificerTimeService.getOne(new QueryWrapper<ArtificerTime>().eq("orders_id", orders.getParentId()).last(" order by artificer_time_id desc limit 1 "));
|
||||||
|
String serveTime = artificerTime.getArtificerDate() + " " + artificerTime.getArtificerTime();
|
||||||
|
String date = null;
|
||||||
|
String time = null;
|
||||||
|
Date parse = DateUtils.stringToDate(serveTime, "yyyy-MM-dd HH:mm");
|
||||||
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
calendar.setTime(parse);
|
||||||
|
for (int j = 0; j < i; j++) {
|
||||||
|
calendar.add(Calendar.MINUTE, minute);
|
||||||
|
String format = DateUtils.format(calendar.getTime());
|
||||||
|
date = format.substring(0, 10);
|
||||||
|
time = format.substring(11, 16);
|
||||||
|
artificerTime = artificerTimeService.getOne(
|
||||||
|
new QueryWrapper<ArtificerTime>()
|
||||||
|
.eq("artificer_id", orders.getArtificerId())
|
||||||
|
.eq("artificer_date", date).eq("artificer_time", time));
|
||||||
|
if (artificerTime != null) {
|
||||||
|
return Result.error("预约时间正忙,请更换其他时间!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//加上车费
|
||||||
|
orders.setPayMoney(orders.getMassageMoney().add(taxiMoney));
|
||||||
|
BigDecimal artificerPrice = BigDecimal.ZERO;
|
||||||
|
Artificer artificer = artificerService.getById(orders.getArtificerId());
|
||||||
|
//查询是否计算出租车扣费
|
||||||
|
String taxi = commonInfoService.findOne(394).getValue();
|
||||||
|
//计算技师出租车收益(按照技师表收益计算)
|
||||||
|
if ("是".equals(taxi)) {
|
||||||
|
//计算技师应该收取的出租车费用
|
||||||
|
BigDecimal artificerTaxiMoney = taxiMoney.multiply(artificer.getRate());
|
||||||
|
//计算出租车扣款
|
||||||
|
BigDecimal pingTaxiMoney = taxiMoney.subtract(artificerTaxiMoney);
|
||||||
|
//赋值技师出租收款
|
||||||
|
orders.setArtificerTaxiMoney(artificerTaxiMoney);
|
||||||
|
//赋值出租车扣款
|
||||||
|
orders.setPingTaxiMoney(pingTaxiMoney);
|
||||||
|
//赋值技师收益
|
||||||
|
artificerPrice = orders.getPayMoney().multiply(artificer.getRate());
|
||||||
|
} else {
|
||||||
|
//平台不扣费 出租车收益全由技师收取
|
||||||
|
orders.setArtificerTaxiMoney(orders.getTaxiMoney());
|
||||||
|
//设置出租车扣款为0
|
||||||
|
orders.setPingTaxiMoney(BigDecimal.ZERO);
|
||||||
|
//用户支付减去通行费用
|
||||||
|
BigDecimal subtract = orders.getPayMoney().subtract(taxiMoney);
|
||||||
|
//计算用户收益 !计算前先减去通行费用再计算技师抽成
|
||||||
|
artificerPrice = subtract.multiply(artificer.getRate());
|
||||||
|
//用户收益加上通行费用
|
||||||
|
artificerPrice = artificerPrice.add(taxiMoney);
|
||||||
|
}
|
||||||
|
|
||||||
|
//计算项目收益
|
||||||
|
//获取项目应支付金额
|
||||||
|
BigDecimal projectBenefits = orders.getMassageMoney();
|
||||||
|
//计算技师项目提成金额
|
||||||
|
orders.setProjectBenefits(projectBenefits.multiply(artificer.getRate()).setScale(2,BigDecimal.ROUND_HALF_UP));
|
||||||
|
|
||||||
|
orders.setArtificerMoney(artificerPrice);
|
||||||
|
orders.setSumArtificerMoney(orders.getArtificerMoney());
|
||||||
|
orders.setOrdersNo(getGeneralOrder());
|
||||||
|
orders.setStatus(1);
|
||||||
|
|
||||||
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
|
orders.setCreateTime(sdf.format(new Date()));
|
||||||
|
//留存订单生成时的技师分成比例
|
||||||
|
orders.setArtificerRate(artificer.getRate());
|
||||||
|
orders.setSumMoney(orders.getPayMoney());
|
||||||
|
//修改订单
|
||||||
|
baseMapper.updateById(orders);
|
||||||
|
return Result.success().put("data", orders);
|
||||||
|
}else {
|
||||||
|
//修改一般订单
|
||||||
|
MassageType massageType = massageTypeService.getById(massageTypeId);
|
||||||
|
orders.setMassageTypeId(massageType.getMassageTypeId());
|
||||||
|
orders.setEntryName(massageType.getTitle());
|
||||||
|
|
||||||
|
//获取原优惠卷
|
||||||
|
List<String> oldCouponList = Lists.newArrayList();
|
||||||
|
String oldCouponId = oldOrders.getCouponId();
|
||||||
|
if (oldCouponId.length() > 0) {
|
||||||
|
String[] oldCouponArr = oldCouponId.trim().split(",");
|
||||||
|
for (int i = 0; i < oldCouponArr.length; i++) {
|
||||||
|
if (oldCouponArr[i] != null && !oldCouponArr[i].equals("")) {
|
||||||
|
oldCouponList.add(oldCouponArr[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//判断新优惠卷是否可用
|
||||||
|
BigDecimal couponMinMoney = BigDecimal.ZERO;//所有代金券的使用额度总和
|
||||||
|
//获取并判断代金券信息
|
||||||
|
List<CouponUser> CouponUserList = Lists.newArrayList();
|
||||||
|
String couponIds = orders.getCouponId();
|
||||||
|
if (couponIds.length() > 0) {
|
||||||
|
String[] couponArr = couponIds.trim().split(",");
|
||||||
|
BigDecimal couponMoney = new BigDecimal(0);
|
||||||
|
StringBuffer couponNameSb = new StringBuffer();
|
||||||
|
for (int i = 0; i < couponArr.length; i++) {
|
||||||
|
if (couponArr[i] != null && !couponArr[i].equals("")) {
|
||||||
|
String couponIdStr = couponArr[i];
|
||||||
|
Long couponId = Long.valueOf(couponIdStr);
|
||||||
|
CouponUser couponUser = couponUserService.getById(couponId);
|
||||||
|
boolean isGoon = false;
|
||||||
|
if (!couponUser.getStatus().equals(0)) {
|
||||||
|
isGoon = false;//被占用
|
||||||
|
}
|
||||||
|
if (!isGoon) {
|
||||||
|
if (oldCouponList.size() > 0) {
|
||||||
|
if (oldCouponList.contains(couponIdStr)) {
|
||||||
|
isGoon = true;//被占用的新优惠卷在原优惠卷中存在则继续
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!isGoon) {
|
||||||
|
return Result.error("优惠券已被使用!");
|
||||||
|
}
|
||||||
|
if (couponUser.getClassifyId() != 0) {
|
||||||
|
if (orders.getClassifyId() != couponUser.getClassifyId()) {
|
||||||
|
return Result.error("优惠券不满足使用条件!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
couponMinMoney = couponMinMoney.add(couponUser.getMinMoney());
|
||||||
|
CouponUserList.add(couponUser);
|
||||||
|
BigDecimal money = couponUser.getMoney();
|
||||||
|
couponMoney = couponMoney.add(money);
|
||||||
|
couponNameSb.append(couponUser.getCouponName());
|
||||||
|
couponNameSb.append(",");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
orders.setCouponName(couponNameSb.toString());
|
||||||
|
orders.setCouponMoney(couponMoney);
|
||||||
|
} else {
|
||||||
|
orders.setCouponName("");
|
||||||
|
orders.setCouponMoney(BigDecimal.ZERO);
|
||||||
|
}
|
||||||
|
//获取用户VIP的优惠信息
|
||||||
|
BigDecimal vipRate = new BigDecimal(100);
|
||||||
|
UserVip userVip = userVipService.selectUserVipByUserId(orders.getUserId());
|
||||||
|
if (userVip != null) {
|
||||||
|
if (userVip.getIsVip() == 1) {
|
||||||
|
//获取用户到期时间
|
||||||
|
Date date = null;
|
||||||
|
try {
|
||||||
|
date = DateUtils.stringToDate(userVip.getEndTime(), DateUtils.DATE_TIME_PATTERN);
|
||||||
|
if (date.getTime() >= System.currentTimeMillis()) {
|
||||||
|
VipDetails vipDetails = vipDetailsDao.selectOne(new QueryWrapper<VipDetails>().eq("vip_name_type", userVip.getVipNameType()));
|
||||||
|
if (vipDetails != null) {
|
||||||
|
vipRate = vipDetails.getRate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.getMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
orders.setVipRate(vipRate);
|
||||||
|
Artificer artificer = artificerService.getById(orders.getArtificerId());
|
||||||
|
orders.setTechnicianType(artificer.getTechnicianType());
|
||||||
|
BigDecimal artificerVipRate = BigDecimal.ZERO;
|
||||||
|
VipDetails artificerVipDetails = vipDetailsDao.selectOne(new QueryWrapper<VipDetails>().eq("vip_name_type", artificer.getTechnicianType()));
|
||||||
|
if (artificerVipDetails != null) {
|
||||||
|
artificerVipRate = artificerVipDetails.getRate();
|
||||||
|
}
|
||||||
|
orders.setTechnicianRate(artificerVipRate);
|
||||||
|
|
||||||
|
BigDecimal payMoney = BigDecimal.ZERO;
|
||||||
|
|
||||||
|
List<OrdersMassage> ordersMassageList = orders.getOrdersMassageList();
|
||||||
|
|
||||||
|
BigDecimal price = BigDecimal.ZERO;
|
||||||
|
String massageTypeName = "";
|
||||||
|
BigDecimal artificerPrice = new BigDecimal("0.00");
|
||||||
|
|
||||||
|
for (OrdersMassage ordersMassage : ordersMassageList) {
|
||||||
|
price = massageType.getPrice().multiply(BigDecimal.valueOf(ordersMassage.getNum()));
|
||||||
|
BigDecimal massagePrice = price.multiply(orders.getTechnicianRate()).divide(new BigDecimal(100)).add(price);//技师等级加成金额
|
||||||
|
massagePrice = massagePrice.multiply(orders.getVipRate()).divide(new BigDecimal(100));//会员优惠后金额
|
||||||
|
massageTypeName = massageType.getTitle();
|
||||||
|
payMoney = massagePrice.add(payMoney);
|
||||||
|
|
||||||
|
if (orders.getParentId() != null && orders.getParentId() != 0) {
|
||||||
|
orders.setAddTime(massageType.getDuration());
|
||||||
|
}
|
||||||
|
orders.setMassageTypeId(massageType.getMassageTypeId());
|
||||||
|
}
|
||||||
|
//保存现价
|
||||||
|
orders.setPrice(price);
|
||||||
|
orders.setEntryName(massageTypeName);
|
||||||
|
|
||||||
|
//判断金额是否满足代金券金额最少消费额度
|
||||||
|
if (payMoney.compareTo(couponMinMoney) < 0) {
|
||||||
|
return Result.error("当前应付总金额不满足优惠券使用的最小额度,请重新选择优惠卷!");
|
||||||
|
}
|
||||||
|
|
||||||
|
//减去代金券的金额
|
||||||
|
payMoney = payMoney.subtract(orders.getCouponMoney());
|
||||||
|
orders.setMassageMoney(payMoney);
|
||||||
|
|
||||||
|
String value1 = commonInfoService.findOne(395).getValue();
|
||||||
|
int i = 0;
|
||||||
|
//1.锁定本单服务时间问题
|
||||||
|
//项目时间
|
||||||
|
Integer duration = massageType.getDuration();
|
||||||
|
//精油
|
||||||
|
String jyValue = commonInfoService.findOne(392).getValue();
|
||||||
|
int minute = 0;
|
||||||
|
int jyMinuteInt = Integer.parseInt(jyValue);
|
||||||
|
//公交1h,出租30 , 免费 1h(加出行时间)
|
||||||
|
Integer tripWay = orders.getTripWay();
|
||||||
|
if (Objects.nonNull(tripWay) && (tripWay == 1 || tripWay == 3)) {
|
||||||
|
duration = duration + 30;
|
||||||
|
}
|
||||||
|
if ("是".equals(value1)) {
|
||||||
|
if (orders.getClassifyId() == 91) {
|
||||||
|
minute = jyMinuteInt;
|
||||||
|
if (duration % minute == 0) {
|
||||||
|
i = duration / minute;
|
||||||
|
} else {
|
||||||
|
i = duration / minute;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
minute = jyMinuteInt;
|
||||||
|
if (duration % minute == 0) {
|
||||||
|
i = duration / minute;
|
||||||
|
} else {
|
||||||
|
i = duration / minute;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BigDecimal taxiMoney = BigDecimal.ZERO;
|
||||||
|
if (orders.getParentId() == null || orders.getParentId() == 0) {
|
||||||
|
String serveTime = orders.getServeTime();
|
||||||
|
String date = serveTime.substring(0, 10);
|
||||||
|
String time = serveTime.substring(11, 16);
|
||||||
|
ArtificerTime artificerTime = artificerTimeService.getOne(
|
||||||
|
new QueryWrapper<ArtificerTime>()
|
||||||
|
.eq("artificer_id", orders.getArtificerId())
|
||||||
|
.eq("artificer_date", date).eq("artificer_time", time));
|
||||||
|
if (artificerTime != null) {
|
||||||
|
return Result.error("预约时间正忙,请更换其他时间!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i > 1) {
|
||||||
|
Date parse = DateUtils.stringToDate(serveTime, "yyyy-MM-dd HH:mm");
|
||||||
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
calendar.setTime(parse);
|
||||||
|
for (int j = 1; j < i; j++) {
|
||||||
|
calendar.add(Calendar.MINUTE, minute);
|
||||||
|
String format = DateUtils.format(calendar.getTime());
|
||||||
|
date = format.substring(0, 10);
|
||||||
|
time = format.substring(11, 16);
|
||||||
|
artificerTime = artificerTimeService.getOne(
|
||||||
|
new QueryWrapper<ArtificerTime>()
|
||||||
|
.eq("artificer_id", orders.getArtificerId())
|
||||||
|
.eq("artificer_date", date).eq("artificer_time", time));
|
||||||
|
if (artificerTime != null) {
|
||||||
|
return Result.error("预约时间正忙,请更换其他时间!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TravelPriceVo travelPriceVo = travelConfService.calcTravelPrice(orders.getArtificerId(), orders.getLongitude(), orders.getLatitude());
|
||||||
|
if (travelPriceVo == null) {
|
||||||
|
return Result.error("暂不支持当前地址,请更换其他地址!");
|
||||||
|
}
|
||||||
|
taxiMoney = new BigDecimal(travelPriceVo.getTravelPrice());
|
||||||
|
orders.setTaxiMoney(taxiMoney);
|
||||||
|
orders.setKm(travelPriceVo.getKilometerNum());
|
||||||
|
|
||||||
|
} else {
|
||||||
|
if ("是".equals(value1)) {
|
||||||
|
ArtificerTime artificerTime = artificerTimeService.getOne(new QueryWrapper<ArtificerTime>().eq("orders_id", orders.getParentId()).last(" order by artificer_time_id desc limit 1 "));
|
||||||
|
String serveTime = artificerTime.getArtificerDate() + " " + artificerTime.getArtificerTime();
|
||||||
|
String date = null;
|
||||||
|
String time = null;
|
||||||
|
Date parse = DateUtils.stringToDate(serveTime, "yyyy-MM-dd HH:mm");
|
||||||
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
calendar.setTime(parse);
|
||||||
|
for (int j = 0; j < i; j++) {
|
||||||
|
calendar.add(Calendar.MINUTE, minute);
|
||||||
|
String format = DateUtils.format(calendar.getTime());
|
||||||
|
date = format.substring(0, 10);
|
||||||
|
time = format.substring(11, 16);
|
||||||
|
artificerTime = artificerTimeService.getOne(
|
||||||
|
new QueryWrapper<ArtificerTime>()
|
||||||
|
.eq("artificer_id", orders.getArtificerId())
|
||||||
|
.eq("artificer_date", date).eq("artificer_time", time));
|
||||||
|
if (artificerTime != null) {
|
||||||
|
return Result.error("预约时间正忙,请更换其他时间!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//加上车费
|
||||||
|
orders.setPayMoney(payMoney.add(taxiMoney));
|
||||||
|
|
||||||
|
//查询是否计算出租车扣费
|
||||||
|
String taxi = commonInfoService.findOne(394).getValue();
|
||||||
|
//计算技师出租车收益(按照技师表收益计算)
|
||||||
|
if ("是".equals(taxi)) {
|
||||||
|
//计算技师应该收取的出租车费用
|
||||||
|
BigDecimal artificerTaxiMoney = taxiMoney.multiply(artificer.getRate());
|
||||||
|
//计算出租车扣款
|
||||||
|
BigDecimal pingTaxiMoney = taxiMoney.subtract(artificerTaxiMoney);
|
||||||
|
//赋值技师出租收款
|
||||||
|
orders.setArtificerTaxiMoney(artificerTaxiMoney);
|
||||||
|
//赋值出租车扣款
|
||||||
|
orders.setPingTaxiMoney(pingTaxiMoney);
|
||||||
|
//赋值技师收益
|
||||||
|
artificerPrice = orders.getPayMoney().multiply(artificer.getRate());
|
||||||
|
} else {
|
||||||
|
//平台不扣费 出租车收益全由技师收取
|
||||||
|
orders.setArtificerTaxiMoney(orders.getTaxiMoney());
|
||||||
|
//设置出租车扣款为0
|
||||||
|
orders.setPingTaxiMoney(BigDecimal.ZERO);
|
||||||
|
//用户支付减去通行费用
|
||||||
|
BigDecimal subtract = orders.getPayMoney().subtract(taxiMoney);
|
||||||
|
//计算用户收益 !计算前先减去通行费用再计算技师抽成
|
||||||
|
artificerPrice = subtract.multiply(artificer.getRate());
|
||||||
|
//用户收益加上通行费用
|
||||||
|
artificerPrice = artificerPrice.add(taxiMoney);
|
||||||
|
}
|
||||||
|
|
||||||
|
//计算项目收益
|
||||||
|
//获取项目应支付金额
|
||||||
|
BigDecimal projectBenefits = orders.getMassageMoney();
|
||||||
|
//计算技师项目提成金额
|
||||||
|
orders.setProjectBenefits(projectBenefits.multiply(artificer.getRate()).setScale(2, BigDecimal.ROUND_HALF_UP));
|
||||||
|
|
||||||
|
orders.setArtificerMoney(artificerPrice);
|
||||||
|
orders.setSumArtificerMoney(orders.getArtificerMoney());
|
||||||
|
// orders.setOrdersNo(getGeneralOrder());
|
||||||
|
orders.setStatus(1);
|
||||||
|
|
||||||
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
|
orders.setCreateTime(sdf.format(new Date()));
|
||||||
|
//留存订单生成时的技师分成比例
|
||||||
|
orders.setArtificerRate(artificer.getRate());
|
||||||
|
orders.setSumMoney(orders.getPayMoney());
|
||||||
|
//修改订单
|
||||||
|
baseMapper.updateById(orders);
|
||||||
|
|
||||||
|
//释放原优惠卷
|
||||||
|
if (oldCouponList.size() > 0) {
|
||||||
|
for (String couponIdStr : oldCouponList) {
|
||||||
|
CouponUser couponUser = new CouponUser();
|
||||||
|
couponUser.setId(Long.valueOf(couponIdStr));
|
||||||
|
couponUser.setStatus(0);
|
||||||
|
couponUserService.updateById(couponUser);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//占用新代金券
|
||||||
|
if (CouponUserList.size() > 0) {
|
||||||
|
for (CouponUser couponUser : CouponUserList) {
|
||||||
|
couponUser.setStatus(1);
|
||||||
|
couponUserService.updateById(couponUser);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Result.success().put("data", orders);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
//判断是否是可修改
|
||||||
|
boolean canUpdate = commonInfoService.isCheckEditOrder(DateUtils.stringToDate(orders.getServeTime(),"yyyy-MM-dd HH:mm") ,new Date());
|
||||||
|
if(!canUpdate){
|
||||||
|
return Result.error("当前订单无法修改!");
|
||||||
|
}
|
||||||
|
//判断是否是修改后的订单再继续修改
|
||||||
|
if(orders.getOrdersId() != null){
|
||||||
|
return Result.error("当前订单是修改后生成的新订单无法修改!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (StringUtils.isNotBlank(orders.getServeTime()) && !orders.getServeTime().equals(oldOrders.getServeTime())) {
|
if (StringUtils.isNotBlank(orders.getServeTime()) && !orders.getServeTime().equals(oldOrders.getServeTime())) {
|
||||||
//修改预约时间
|
//修改预约时间
|
||||||
//判断订单是否开始
|
//判断订单是否开始
|
||||||
|
@ -1641,7 +2256,7 @@ public class OrdersServiceImpl extends ServiceImpl<OrdersDao, Orders> implements
|
||||||
/***
|
/***
|
||||||
* 待补单处理及待补单全单退款
|
* 待补单处理及待补单全单退款
|
||||||
* @param userId
|
* @param userId
|
||||||
* @param isAuto 是否自动退款 1是 系统自动变成待补单,0否 用户点击操作变成待补单
|
* @param isAuto 是否自动退款 1是 技师操作变成待补单,0否 用户点击操作变成待补单
|
||||||
* @param type 是否全额退款,1车费 2项目费 3全部
|
* @param type 是否全额退款,1车费 2项目费 3全部
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@ -1804,6 +2419,8 @@ public class OrdersServiceImpl extends ServiceImpl<OrdersDao, Orders> implements
|
||||||
userMoneyDetails.setBlFlag(1);
|
userMoneyDetails.setBlFlag(1);
|
||||||
userMoneyDetailsService.save(userMoneyDetails);
|
userMoneyDetailsService.save(userMoneyDetails);
|
||||||
}
|
}
|
||||||
|
BigDecimal payMoney = orders.getPayMoney().subtract(orders.getTaxiMoney());
|
||||||
|
orders.setPayMoney(payMoney);
|
||||||
}
|
}
|
||||||
if(orders.getOldOrdersId() !=null){
|
if(orders.getOldOrdersId() !=null){
|
||||||
//此笔单子退车费,并改为取消,再将原单改成待补单
|
//此笔单子退车费,并改为取消,再将原单改成待补单
|
||||||
|
@ -2196,6 +2813,8 @@ public class OrdersServiceImpl extends ServiceImpl<OrdersDao, Orders> implements
|
||||||
userMoneyDetails.setBlFlag(1);
|
userMoneyDetails.setBlFlag(1);
|
||||||
userMoneyDetailsService.save(userMoneyDetails);
|
userMoneyDetailsService.save(userMoneyDetails);
|
||||||
}
|
}
|
||||||
|
BigDecimal payMoney = orders.getPayMoney().subtract(orders.getTaxiMoney());
|
||||||
|
orders.setPayMoney(payMoney);
|
||||||
}
|
}
|
||||||
if(orders.getOldOrdersId() !=null){
|
if(orders.getOldOrdersId() !=null){
|
||||||
//此笔单子退车费,并改为取消,再将原单改成待补单
|
//此笔单子退车费,并改为取消,再将原单改成待补单
|
||||||
|
|
|
@ -22,10 +22,10 @@ public enum CommonEnum {
|
||||||
/**服务开始n分钟后不可以取消订单*/
|
/**服务开始n分钟后不可以取消订单*/
|
||||||
V3_ORDER_FORM_CANCEL_START_02(440, "v3_order_form", "服务开始n分钟后不可以取消订单", "15"),
|
V3_ORDER_FORM_CANCEL_START_02(440, "v3_order_form", "服务开始n分钟后不可以取消订单", "15"),
|
||||||
|
|
||||||
/**距离服务开始前n个小时可修改*/
|
/**距离服务开始前n分钟可修改*/
|
||||||
V3_ORDER_FORM_EDIT_NOT_START_01(441, "v3_order_form", "距离服务开始前n个小时可修改", "2"),
|
V3_ORDER_FORM_EDIT_NOT_START_01(441, "v3_order_form", "距离服务开始前n分钟可修改", "120"),
|
||||||
/**距离服务开始n个小时内不可修改*/
|
/**距离服务开始n分钟内不可修改*/
|
||||||
V3_ORDER_FORM_EDIT_NOT_START_02(442, "v3_order_form", "距离服务开始n个小时内不可修改", "2"),
|
V3_ORDER_FORM_EDIT_NOT_START_02(442, "v3_order_form", "距离服务开始n分钟内不可修改", "120"),
|
||||||
|
|
||||||
/**夏令时开始时间~结束时间*/
|
/**夏令时开始时间~结束时间*/
|
||||||
V3_TRAVEL_CONF_DAYLIGHT_SAVING_TIME(443, "v3_travel_conf", "夏令时开始时间~结束时间", "0521,0823"),
|
V3_TRAVEL_CONF_DAYLIGHT_SAVING_TIME(443, "v3_travel_conf", "夏令时开始时间~结束时间", "0521,0823"),
|
||||||
|
|
|
@ -195,29 +195,21 @@ public class CommonInfoServiceImpl extends ServiceImpl<CommonInfoDao, CommonInfo
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCheckEditOrder(Date businessTime, Date nowTime) {
|
public boolean isCheckEditOrder(Date businessTime, Date nowTime) {
|
||||||
long bnDiffDay = DateUtil.between(businessTime, nowTime, DateUnit.DAY, false);
|
long bnDiffDay = DateUtil.between(nowTime, businessTime, DateUnit.MINUTE, false);
|
||||||
Map<Integer, CommonInfo> configMap = getMapByCondition(CommonEnum.GroupConditionEnum.V3_ORDER_FORM.getValue());
|
Map<Integer, CommonInfo> configMap = getMapByCondition(CommonEnum.GroupConditionEnum.V3_ORDER_FORM.getValue());
|
||||||
|
|
||||||
//距离服务开始前n个小时可修改 - 2
|
//距离服务开始前n分钟可修改 120
|
||||||
CommonInfo v3OrderFormEditNotStart01 = configMap.get(CommonEnum.V3_ORDER_FORM_EDIT_NOT_START_01.getKey());
|
CommonInfo v3OrderFormEditNotStart01 = configMap.get(CommonEnum.V3_ORDER_FORM_EDIT_NOT_START_01.getKey());
|
||||||
//距离服务开始n个小时内不可修改 - 2
|
|
||||||
CommonInfo v3OrderFormEditNotStart02 = configMap.get(CommonEnum.V3_ORDER_FORM_EDIT_NOT_START_02.getKey());
|
|
||||||
|
|
||||||
Double v3OrderFormEditNotStart01I = CommonConfigUtil.getDoubleValue(v3OrderFormEditNotStart01.getValue());
|
Long v3OrderFormEditNotStart01I = CommonConfigUtil.getLongValue(v3OrderFormEditNotStart01.getValue());
|
||||||
if(v3OrderFormEditNotStart01I == null) v3OrderFormEditNotStart01I = -1D;
|
if(v3OrderFormEditNotStart01I == null) v3OrderFormEditNotStart01I = 120L;
|
||||||
Double v3OrderFormEditNotStart02I = CommonConfigUtil.getDoubleValue(v3OrderFormEditNotStart02.getValue());
|
|
||||||
if(v3OrderFormEditNotStart02I == null) v3OrderFormEditNotStart02I = -1D;
|
|
||||||
|
|
||||||
if(bnDiffDay >= 0) {
|
if(bnDiffDay >= v3OrderFormEditNotStart01I) {
|
||||||
//正数,服务开始前
|
return true;
|
||||||
if(v3OrderFormEditNotStart01I == -1) return true;
|
}else{
|
||||||
return bnDiffDay >= v3OrderFormEditNotStart01I;
|
return false;
|
||||||
} else {
|
|
||||||
//负数,服务开始后
|
|
||||||
if(v3OrderFormEditNotStart02I == -1) return true;
|
|
||||||
double burdenV3OrderFormEditNotStart02I = - v3OrderFormEditNotStart02I;
|
|
||||||
return burdenV3OrderFormEditNotStart02I >= bnDiffDay;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue