技师忙时

This commit is contained in:
曹磊 2024-07-09 00:52:30 +08:00
parent 10bda25534
commit 75b37b259d
4 changed files with 2023 additions and 785 deletions

View File

@ -147,9 +147,363 @@ public class AliPayController {
private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
/**
* 获取总花费时间
* @param duration 服务时长
* @param serveTime 服务时间
* @param value1 是否开启忙时
* @param tripWay 出行方式
* @param artificerId 技师ID
* @return
*/
private Map<String,Object> getTaskTime(Integer duration,String serveTime,String value1,Integer tripWay,Long artificerId){
Map<String,Object> map = new HashMap<>();
String beforeTime = commonInfoService.findOne(457).getValue();
int beforeTimeInt = Integer.parseInt(beforeTime);
String afterTime = commonInfoService.findOne(458).getValue();
int afterTimeInt = Integer.parseInt(afterTime);
String jyValue = commonInfoService.findOne(392).getValue();
int jyMinuteInt = Integer.parseInt(jyValue);
int cxsjInt = 0;
if(Objects.nonNull(tripWay)){
if(tripWay.equals(1)){
String cxsj = commonInfoService.findOne(454).getValue();
cxsjInt = Integer.parseInt(cxsj);
}
if(tripWay.equals(2)){
String cxsj = commonInfoService.findOne(455).getValue();
cxsjInt = Integer.parseInt(cxsj);
}
if(tripWay.equals(3)){
String cxsj = commonInfoService.findOne(456).getValue();
cxsjInt = Integer.parseInt(cxsj);
}
}
beforeTimeInt = beforeTimeInt + cxsjInt; //服务时间前锁单时间
int minute=0;
int i = 0;
int f = 0;
int a = 0;
if ("".equals(value1)) {
minute = jyMinuteInt;
if (duration % minute == 0) {
i = duration / minute;
} else {
i = duration / minute;
i++;
}
if (beforeTimeInt % minute == 0) {
f = beforeTimeInt / minute;
} else {
f = beforeTimeInt / minute;
f++;
}
if (afterTimeInt % minute == 0) {
a = afterTimeInt / minute;
} else {
a = afterTimeInt / minute;
a++;
}
}
List<String> allTime = new ArrayList<>();
String date = serveTime.substring(0, 10);
String time = serveTime.substring(11, 16);
Date parse = DateUtils.stringToDate(serveTime,"yyyy-MM-dd HH:mm");
//服务时间前锁单时间判断
if (f > 0) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(parse);
for (int j = 0; j < f; j++) {
calendar.add(Calendar.MINUTE, -minute);
String format = DateUtils.format(calendar.getTime(),"yyyy-MM-dd HH:mm");
allTime.add(format);
date = format.substring(0, 10);
time = format.substring(11, 16);
ArtificerTime artificerTime = artificerTimeService.getOne(
new QueryWrapper<ArtificerTime>()
.eq("artificer_id", artificerId)
.eq("artificer_date", date)
.eq("artificer_time", time)
.last("limit 1"));
if (artificerTime != null) {
map.put("code","1");
}
}
}
//服务时间后锁单时间判断
if (i > 0) {
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(),"yyyy-MM-dd HH:mm");
allTime.add(format);
date = format.substring(0, 10);
time = format.substring(11, 16);
ArtificerTime artificerTime = artificerTimeService.getOne(
new QueryWrapper<ArtificerTime>()
.eq("artificer_id", artificerId)
.eq("artificer_date", date)
.eq("artificer_time", time)
.last("limit 1"));
if (artificerTime != null) {
map.put("code","1");
}
}
}
//服务中锁单时间判断
if (a > 0) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(parse);
calendar.add(Calendar.MINUTE, minute*i);
for (int j = 0; j < a; j++) {
calendar.add(Calendar.MINUTE, minute);
String format = DateUtils.format(calendar.getTime(),"yyyy-MM-dd HH:mm");
allTime.add(format);
date = format.substring(0, 10);
time = format.substring(11, 16);
ArtificerTime artificerTime = artificerTimeService.getOne(
new QueryWrapper<ArtificerTime>()
.eq("artificer_id", artificerId)
.eq("artificer_date", date)
.eq("artificer_time", time)
.last("limit 1"));
if (artificerTime != null) {
map.put("code","1");
}
}
}
allTime.sort(Comparator.naturalOrder());
map.put("timeList",allTime);
map.put("code","0");
return map;
}
/**
* 获取总花费时间包含当前订单中得时间
* @param duration 服务时长
* @param serveTime 服务时间
* @param value1 是否开启忙时
* @param tripWay 出行方式
* @param artificerId 技师ID
* @param ordersId 订单ID
* @return
*/
private Map<String,Object> getTaskTimeIncudeOrders(Integer duration,String serveTime,String value1,Integer tripWay,Long artificerId,Long ordersId){
Map<String,Object> map = new HashMap<>();
String beforeTime = commonInfoService.findOne(457).getValue();
int beforeTimeInt = Integer.parseInt(beforeTime);
String afterTime = commonInfoService.findOne(458).getValue();
int afterTimeInt = Integer.parseInt(afterTime);
String jyValue = commonInfoService.findOne(392).getValue();
int jyMinuteInt = Integer.parseInt(jyValue);
int cxsjInt = 0;
if(Objects.nonNull(tripWay)){
if(tripWay.equals(1)){
String cxsj = commonInfoService.findOne(454).getValue();
cxsjInt = Integer.parseInt(cxsj);
}
if(tripWay.equals(2)){
String cxsj = commonInfoService.findOne(455).getValue();
cxsjInt = Integer.parseInt(cxsj);
}
if(tripWay.equals(3)){
String cxsj = commonInfoService.findOne(456).getValue();
cxsjInt = Integer.parseInt(cxsj);
}
}
beforeTimeInt = beforeTimeInt + cxsjInt; //服务时间前锁单时间
int minute=0;
int i = 0;
int f = 0;
int a = 0;
if ("".equals(value1)) {
minute = jyMinuteInt;
if (duration % minute == 0) {
i = duration / minute;
} else {
i = duration / minute;
i++;
}
if (beforeTimeInt % minute == 0) {
f = beforeTimeInt / minute;
} else {
f = beforeTimeInt / minute;
f++;
}
if (afterTimeInt % minute == 0) {
a = afterTimeInt / minute;
} else {
a = afterTimeInt / minute;
a++;
}
}
List<String> allTime = new ArrayList<>();
String date = serveTime.substring(0, 10);
String time = serveTime.substring(11, 16);
Date parse = DateUtils.stringToDate(serveTime,"yyyy-MM-dd HH:mm");
//服务时间前锁单时间判断
if (f > 0) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(parse);
for (int j = 0; j < f; j++) {
calendar.add(Calendar.MINUTE, -minute);
String format = DateUtils.format(calendar.getTime(),"yyyy-MM-dd HH:mm");
allTime.add(format);
date = format.substring(0, 10);
time = format.substring(11, 16);
ArtificerTime artificerTime = artificerTimeService.getOne(
new QueryWrapper<ArtificerTime>()
.eq("artificer_id", artificerId)
.eq("artificer_date", date)
.eq("artificer_time", time)
.ne("orders_id", ordersId)
.last("limit 1"));
if (artificerTime != null) {
map.put("code","1");
}
}
}
//服务时间后锁单时间判断
if (i > 0) {
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(),"yyyy-MM-dd HH:mm");
allTime.add(format);
date = format.substring(0, 10);
time = format.substring(11, 16);
ArtificerTime artificerTime = artificerTimeService.getOne(
new QueryWrapper<ArtificerTime>()
.eq("artificer_id", artificerId)
.eq("artificer_date", date)
.eq("artificer_time", time)
.ne("orders_id", ordersId)
.last("limit 1"));
if (artificerTime != null) {
map.put("code","1");
}
}
}
//服务中锁单时间判断
if (a > 0) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(parse);
calendar.add(Calendar.MINUTE, minute*i);
for (int j = 0; j < a; j++) {
calendar.add(Calendar.MINUTE, minute);
String format = DateUtils.format(calendar.getTime(),"yyyy-MM-dd HH:mm");
allTime.add(format);
date = format.substring(0, 10);
time = format.substring(11, 16);
ArtificerTime artificerTime = artificerTimeService.getOne(
new QueryWrapper<ArtificerTime>()
.eq("artificer_id", artificerId)
.eq("artificer_date", date)
.eq("artificer_time", time)
.ne("orders_id", ordersId)
.last("limit 1"));
if (artificerTime != null) {
map.put("code","1");
}
}
}
allTime.sort(Comparator.naturalOrder());
map.put("timeList",allTime);
map.put("code","0");
return map;
}
/**
* 获取加钟总花费时间
* @param duration 服务时长
* @param serveTime 服务时间
* @param value1 是否开启忙时
* @param artificerId 技师ID
* @return
*/
private Map<String,Object> getAddTaskTime(Integer duration,String serveTime,String value1,Long artificerId){
Map<String,Object> map = new HashMap<>();
String jyValue = commonInfoService.findOne(392).getValue();
int jyMinuteInt = Integer.parseInt(jyValue);
int minute=0;
int i = 0;
if ("".equals(value1)) {
minute = jyMinuteInt;
if (duration % minute == 0) {
i = duration / minute;
} else {
i = duration / minute;
i++;
}
}
List<String> allTime = new ArrayList<>();
String date = serveTime.substring(0, 10);
String time = serveTime.substring(11, 16);
Date parse = DateUtils.stringToDate(serveTime,"yyyy-MM-dd HH:mm");
//服务时间后锁单时间判断
if (i > 0) {
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(),"yyyy-MM-dd HH:mm");
allTime.add(format);
date = format.substring(0, 10);
time = format.substring(11, 16);
ArtificerTime artificerTime = artificerTimeService.getOne(
new QueryWrapper<ArtificerTime>()
.eq("artificer_id", artificerId)
.eq("artificer_date", date)
.eq("artificer_time", time)
.last("limit 1"));
if (artificerTime != null) {
map.put("code","1");
}
}
}
allTime.sort(Comparator.naturalOrder());
map.put("timeList",allTime);
map.put("code","0");
return map;
}
/**
* 插入技师占用时间表
* @param allTime 时间集合
* @param artificerId 技师ID
* @param ordersId 订单ID
*/
private void insertArtificerTime(List<String> allTime,Long artificerId,Long ordersId){
if(allTime!=null && allTime.size()>0) {
for (int i=0; i<allTime.size(); i++) {
String serveTime2 = allTime.get(i);
String date2 = serveTime2.substring(0, 10);
String time2 = serveTime2.substring(11, 16);
ArtificerTime artificerTime2 = new ArtificerTime();
artificerTime2.setArtificerId(artificerId);
artificerTime2.setArtificerDate(date2);
artificerTime2.setArtificerTime(time2);
artificerTime2.setClassify(1);
artificerTime2.setOrdersId(ordersId);
artificerTime2.setCreateTime(DateUtils.format(new Date()));
artificerTimeService.save(artificerTime2);
}
}
}
@RequestMapping(value = "/notifyApp", method = RequestMethod.POST)
@Transactional(rollbackFor = Exception.class)
public void notifyApp(HttpServletRequest request, HttpServletResponse response) {
public String notifyApp(HttpServletRequest request, HttpServletResponse response) {
//获取支付宝POST过来反馈信息
Map<String, String> params = new HashMap<String, String>();
Map requestParams = request.getParameterMap();
@ -165,6 +519,7 @@ public class AliPayController {
//valueStr = new String(valueStr.getBytes("ISO-8859-1"), "utf-8");
params.put(name, valueStr);
}
String resultStr = "fail";
try {
log.info("回调成功!!!");
boolean flag = AlipaySignature.rsaCheckV1(params, commonInfoService.findOne(64).getValue(), AliPayConstants.CHARSET, "RSA2");
@ -326,49 +681,49 @@ public class AliPayController {
ordersService.updateById(orders);
if(orders.getParentId()!=null && orders.getParentId()!=0){
String value1 = commonInfoService.findOne(395).getValue();
OrdersMassage ordersMassage = ordersMassageService.getOne(new QueryWrapper<OrdersMassage>().eq("orders_id", orders.getOrdersId()));
MassageType massageType = massageTypeService.getById(ordersMassage.getMassageId());
Integer duration=massageType.getDuration();
Calendar calendar=Calendar.getInstance();
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 value = commonInfoService.findOne(392).getValue();
int minute = Integer.parseInt(value);
int i=1;
if(duration%minute==0){
i=duration/minute;
}else{
i=duration/minute;
i++;
}
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm");
Date parse = null;
try {
parse = sdf1.parse(serveTime);
} catch (ParseException e) {
e.printStackTrace();
}
calendar.setTime(parse);
for(int j=0;j<i;j++){
calendar.add(Calendar.MINUTE,minute);
String format = sdf1.format(calendar.getTime());
String date = format.substring(0, 10);
String time = format.substring(11, 16);
artificerTime=new ArtificerTime();
artificerTime.setArtificerId(orders.getArtificerId());
artificerTime.setArtificerDate(date);
artificerTime.setArtificerTime(time);
artificerTime.setClassify(1);
artificerTime.setOrdersId(orders.getParentId());
artificerTime.setCreateTime(DateUtils.format(new Date()));
artificerTimeService.save(artificerTime);
}
}
// String value1 = commonInfoService.findOne(395).getValue();
// OrdersMassage ordersMassage = ordersMassageService.getOne(new QueryWrapper<OrdersMassage>().eq("orders_id", orders.getOrdersId()));
// MassageType massageType = massageTypeService.getById(ordersMassage.getMassageId());
// Integer duration=massageType.getDuration();
// 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 value = commonInfoService.findOne(392).getValue();
// int minute = Integer.parseInt(value);
// int i=1;
// if(duration%minute==0){
// i=duration/minute;
// }else{
// i=duration/minute;
// i++;
// }
//
// SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm");
// Date parse = null;
// try {
// parse = sdf1.parse(serveTime);
// } catch (ParseException e) {
// e.printStackTrace();
// }
//
// calendar.setTime(parse);
// for(int j=0;j<i;j++){
// calendar.add(Calendar.MINUTE,minute);
// String format = sdf1.format(calendar.getTime());
// String date = format.substring(0, 10);
// String time = format.substring(11, 16);
// artificerTime=new ArtificerTime();
// artificerTime.setArtificerId(orders.getArtificerId());
// artificerTime.setArtificerDate(date);
// artificerTime.setArtificerTime(time);
// artificerTime.setClassify(1);
// artificerTime.setOrdersId(orders.getParentId());
// artificerTime.setCreateTime(DateUtils.format(new Date()));
// artificerTimeService.save(artificerTime);
// }
// }
Orders orders1 = ordersDao.selectById(orders.getParentId());
if(orders1.getAddNum()==null){
@ -407,16 +762,16 @@ public class AliPayController {
orders1.setPingMoney(orders1.getPingMoney().add(orders.getPingMoney()));
if(orders1.getStatus().equals(6)){
ordersMassage = ordersMassageService.getOne(new QueryWrapper<OrdersMassage>().eq("orders_id", orders1.getOrdersId()));
massageType = massageTypeService.getById(ordersMassage.getMassageId());
duration=massageType.getDuration();
// ordersMassage = ordersMassageService.getOne(new QueryWrapper<OrdersMassage>().eq("orders_id", orders1.getOrdersId()));
// massageType = massageTypeService.getById(ordersMassage.getMassageId());
// duration=massageType.getDuration();
String endTime = orders1.getEndTime();
Date date = DateUtils.stringToDate(endTime, "yyyy-MM-dd HH:mm:ss");
calendar=Calendar.getInstance();
if(date.getTime()>System.currentTimeMillis()){
calendar.setTime(date);
}
calendar.add(Calendar.MINUTE,duration);
calendar.add(Calendar.MINUTE,orders.getDuration());
orders1.setEndTime(endTime);
}
orders1.setAddPrice(orders.getPrice());
@ -775,13 +1130,24 @@ public class AliPayController {
}
}
}
} else {
String outTradeNo = params.get("out_trade_no");
PayDetails payDetails = payDetailsDao.selectByOrderId(outTradeNo);
if (payDetails.getState() == 0) {
if(payDetails.getType()==1){
artificerTimeService.remove(new QueryWrapper<ArtificerTime>().eq("orders_id", payDetails.getOrderId()));
payDetailsDao.deleteById(payDetails.getId());
}
}
}
resultStr = "success";
}
} catch (AlipayApiException e) {
resultStr = "fail";
e.printStackTrace();
log.info("回调验证失败!!!");
}
return resultStr;
}
@Login
@ -799,51 +1165,121 @@ public class AliPayController {
if(orders.getParentId()!=null && orders.getParentId()!=0){
Orders orders1 = ordersDao.selectById(orders.getParentId());
OrdersMassage ordersMassage = ordersMassageService.getOne(new QueryWrapper<OrdersMassage>().eq("orders_id", orders1.getOrdersId()));
MassageType massageType = massageTypeService.getById(ordersMassage.getMassageId());
if(massageType.getAddNum()==null || massageType.getAddNum()==0){
MassageType massageType = null;
if(orders1.getUserPackageDetailId() !=null){
UserPackageDetail userPackageDetail = userPackageDetailService.getById(ordersMassage.getMassageId());
massageType = massageTypeService.getById(userPackageDetail.getMassageTypeId());
}else{
massageType = massageTypeService.getById(ordersMassage.getMassageId());
}
if (massageType.getAddNum() == null || massageType.getAddNum() == 0) {
return Result.error("当前项目不允许加钟!");
}else if(massageType.getAddNum()>0){
if(orders1.getAddNum()!=null && orders1.getAddNum()>=massageType.getAddNum()){
} else if (massageType.getAddNum() > 0) {
if (orders1.getAddNum() != null && orders1.getAddNum().intValue() >= massageType.getAddNum().intValue()) {
return Result.error("当前项目已超过最大加钟次数!");
}
}
Integer duration=massageType.getDuration();
String value1 = commonInfoService.findOne(395).getValue();
if("".equals(value1)){
String value = commonInfoService.findOne(392).getValue();
int minute = Integer.parseInt(value);
int i=1;
if(duration%minute==0){
i=duration/minute;
}else{
i=duration/minute;
i++;
}
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;
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
Date parse = null;
try {
parse = sdf.parse(serveTime);
} catch (ParseException e) {
e.printStackTrace();
String serveTime = artificerTime.getArtificerDate() + " " + artificerTime.getArtificerTime();
Map<String,Object> map = getAddTaskTime(orders.getDuration(),serveTime,value1,orders.getArtificerId());
if(map.get("code").toString().equals("1")){
return Result.error("预约时间正忙,请更换其他时间!");
}
Calendar calendar=Calendar.getInstance();
calendar.setTime(parse);
for(int j=0;j<i;j++){
calendar.add(Calendar.MINUTE,minute);
String format = sdf.format(calendar.getTime());
date = format.substring(0, 10);
time = format.substring(11, 16);
artificerTime = artificerTimeService.getOne(
insertArtificerTime((ArrayList)map.get("timeList"),orders.getArtificerId(),orders.getOrdersId());
}
}else{
String value1 = commonInfoService.findOne(395).getValue();
if ("".equals(value1)) {
if(orders.getIsSupplement() != null){
if(orders.getIsSupplement() == 1){
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)
.last("limit 1"));
if (artificerTime != null) {
return Result.error("预约时间正忙,请更换其他时间!");
}
Map<String,Object> map = getTaskTime(orders.getDuration(),orders.getServeTime(),value1,orders.getTripWay(),orders.getArtificerId());
if(map.get("code").toString().equals("1")){
return Result.error("预约时间正忙,请更换其他时间!");
}
insertArtificerTime((ArrayList)map.get("timeList"),orders.getArtificerId(),orders.getOrdersId());
}else if(orders.getIsSupplement() == 2){
Orders oldOrders = ordersDao.selectById(orders.getOrdersId());
int timeDifference = orders.getDuration()-oldOrders.getDuration();
if(timeDifference>0){
ArtificerTime artificerTime = artificerTimeService.getOne(new QueryWrapper<ArtificerTime>().eq("orders_id", orders.getOrdersId()).last(" order by artificer_time_id desc limit 1 "));
String serveTime = artificerTime.getArtificerDate() + " " + artificerTime.getArtificerTime();
Map<String,Object> map = getAddTaskTime(timeDifference,serveTime,value1,oldOrders.getArtificerId());
if(map.get("code").toString().equals("1")){
return Result.error("预约时间正忙,请更换其他时间!");
}
//技师占用时间表插入新订单号的多出来的服务时间
insertArtificerTime((ArrayList)map.get("timeList"),orders.getArtificerId(),orders.getOrdersId());
}else{
//技师占用时间表插入新订单号的同时间
List<ArtificerTime> artificerTimeList = artificerTimeService.list(new QueryWrapper<ArtificerTime>().eq("orders_id", orders.getOrdersId()).last(" order by artificer_time_id"));
if(artificerTimeList!=null && artificerTimeList.size()>0){
for(int i=0; i<artificerTimeList.size(); i++){
ArtificerTime artificerTime = artificerTimeList.get(i);
artificerTime.setArtificerId(orders.getArtificerId());
artificerTime.setOrdersId(orders.getOrdersId());
artificerTime.setCreateTime(DateUtils.format(new Date()));
artificerTimeService.save(artificerTime);
}
}
}
}else{
//orders.getIsSupplement() == 3 || orders.getIsSupplement() == 4
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)
.ne("orders_id", orders.getOrdersId())
.last("limit 1"));
if (artificerTime != null) {
return Result.error("预约时间正忙,请更换其他时间!");
}
Map<String,Object> map = getTaskTimeIncudeOrders(orders.getDuration(),orders.getServeTime(),value1,orders.getTripWay(),orders.getArtificerId(),orders.getOldOrdersId());
if(map.get("code").toString().equals("1")){
return Result.error("预约时间正忙,请更换其他时间!");
}
//删除技师占用时间表数据
artificerTimeService.remove(new QueryWrapper<ArtificerTime>().eq("orders_id", orders.getOldOrdersId()));
//插入技师占用时间表新订单
insertArtificerTime((ArrayList)map.get("timeList"),orders.getArtificerId(),orders.getOrdersId());
//插入技师占用时间表原订单
insertArtificerTime((ArrayList)map.get("timeList"),orders.getArtificerId(),orders.getOldOrdersId());
}
}else{
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){
.eq("artificer_date", date)
.eq("artificer_time", time)
.last("limit 1"));
if (artificerTime != null) {
return Result.error("预约时间正忙,请更换其他时间!");
}
Map<String,Object> map = getTaskTime(orders.getDuration(),orders.getServeTime(),value1,orders.getTripWay(),orders.getArtificerId());
if(map.get("code").toString().equals("1")){
return Result.error("预约时间正忙,请更换其他时间!");
}
insertArtificerTime((ArrayList)map.get("timeList"),orders.getArtificerId(),orders.getOrdersId());
}
}
}
@ -1175,49 +1611,49 @@ public class AliPayController {
ordersService.updateById(orders);
if(orders.getParentId()!=null && orders.getParentId()!=0){
String value1 = commonInfoService.findOne(395).getValue();
OrdersMassage ordersMassage = ordersMassageService.getOne(new QueryWrapper<OrdersMassage>().eq("orders_id", orders.getOrdersId()));
MassageType massageType = massageTypeService.getById(ordersMassage.getMassageId());
Integer duration=massageType.getDuration();
Calendar calendar=Calendar.getInstance();
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 value = commonInfoService.findOne(392).getValue();
int minute = Integer.parseInt(value);
int i=1;
if(duration%minute==0){
i=duration/minute;
}else{
i=duration/minute;
i++;
}
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm");
Date parse = null;
try {
parse = sdf1.parse(serveTime);
} catch (ParseException e) {
e.printStackTrace();
}
calendar.setTime(parse);
for(int j=0;j<i;j++){
calendar.add(Calendar.MINUTE,minute);
String format = sdf1.format(calendar.getTime());
String date = format.substring(0, 10);
String time = format.substring(11, 16);
artificerTime=new ArtificerTime();
artificerTime.setArtificerId(orders.getArtificerId());
artificerTime.setArtificerDate(date);
artificerTime.setArtificerTime(time);
artificerTime.setClassify(1);
artificerTime.setOrdersId(orders.getParentId());
artificerTime.setCreateTime(DateUtils.format(new Date()));
artificerTimeService.save(artificerTime);
}
}
// String value1 = commonInfoService.findOne(395).getValue();
// OrdersMassage ordersMassage = ordersMassageService.getOne(new QueryWrapper<OrdersMassage>().eq("orders_id", orders.getOrdersId()));
// MassageType massageType = massageTypeService.getById(ordersMassage.getMassageId());
// Integer duration=massageType.getDuration();
// 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 value = commonInfoService.findOne(392).getValue();
// int minute = Integer.parseInt(value);
// int i=1;
// if(duration%minute==0){
// i=duration/minute;
// }else{
// i=duration/minute;
// i++;
// }
//
// SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm");
// Date parse = null;
// try {
// parse = sdf1.parse(serveTime);
// } catch (ParseException e) {
// e.printStackTrace();
// }
//
// calendar.setTime(parse);
// for(int j=0;j<i;j++){
// calendar.add(Calendar.MINUTE,minute);
// String format = sdf1.format(calendar.getTime());
// String date = format.substring(0, 10);
// String time = format.substring(11, 16);
// artificerTime=new ArtificerTime();
// artificerTime.setArtificerId(orders.getArtificerId());
// artificerTime.setArtificerDate(date);
// artificerTime.setArtificerTime(time);
// artificerTime.setClassify(1);
// artificerTime.setOrdersId(orders.getParentId());
// artificerTime.setCreateTime(DateUtils.format(new Date()));
// artificerTimeService.save(artificerTime);
// }
// }
Orders orders1 = ordersDao.selectById(orders.getParentId());
if(orders1.getAddNum()==null){
@ -1256,16 +1692,16 @@ public class AliPayController {
orders1.setPingMoney(orders1.getPingMoney().add(orders.getPingMoney()));
if(orders1.getStatus().equals(6)){
ordersMassage = ordersMassageService.getOne(new QueryWrapper<OrdersMassage>().eq("orders_id", orders1.getOrdersId()));
massageType = massageTypeService.getById(ordersMassage.getMassageId());
duration=massageType.getDuration();
// ordersMassage = ordersMassageService.getOne(new QueryWrapper<OrdersMassage>().eq("orders_id", orders1.getOrdersId()));
// massageType = massageTypeService.getById(ordersMassage.getMassageId());
// duration=massageType.getDuration();
String endTime = orders1.getEndTime();
Date date = DateUtils.stringToDate(endTime, "yyyy-MM-dd HH:mm:ss");
calendar=Calendar.getInstance();
if(date.getTime()>System.currentTimeMillis()){
calendar.setTime(date);
}
calendar.add(Calendar.MINUTE,duration);
calendar.add(Calendar.MINUTE,orders.getDuration());
orders1.setEndTime(endTime);
}
orders1.setAddPrice(orders.getPrice());

View File

@ -138,6 +138,360 @@ public class WxServiceImpl implements WxService {
private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
/**
* 获取总花费时间
* @param duration 服务时长
* @param serveTime 服务时间
* @param value1 是否开启忙时
* @param tripWay 出行方式
* @param artificerId 技师ID
* @return
*/
private Map<String,Object> getTaskTime(Integer duration,String serveTime,String value1,Integer tripWay,Long artificerId){
Map<String,Object> map = new HashMap<>();
String beforeTime = commonInfoService.findOne(457).getValue();
int beforeTimeInt = Integer.parseInt(beforeTime);
String afterTime = commonInfoService.findOne(458).getValue();
int afterTimeInt = Integer.parseInt(afterTime);
String jyValue = commonInfoService.findOne(392).getValue();
int jyMinuteInt = Integer.parseInt(jyValue);
int cxsjInt = 0;
if(Objects.nonNull(tripWay)){
if(tripWay.equals(1)){
String cxsj = commonInfoService.findOne(454).getValue();
cxsjInt = Integer.parseInt(cxsj);
}
if(tripWay.equals(2)){
String cxsj = commonInfoService.findOne(455).getValue();
cxsjInt = Integer.parseInt(cxsj);
}
if(tripWay.equals(3)){
String cxsj = commonInfoService.findOne(456).getValue();
cxsjInt = Integer.parseInt(cxsj);
}
}
beforeTimeInt = beforeTimeInt + cxsjInt; //服务时间前锁单时间
int minute=0;
int i = 0;
int f = 0;
int a = 0;
if ("".equals(value1)) {
minute = jyMinuteInt;
if (duration % minute == 0) {
i = duration / minute;
} else {
i = duration / minute;
i++;
}
if (beforeTimeInt % minute == 0) {
f = beforeTimeInt / minute;
} else {
f = beforeTimeInt / minute;
f++;
}
if (afterTimeInt % minute == 0) {
a = afterTimeInt / minute;
} else {
a = afterTimeInt / minute;
a++;
}
}
List<String> allTime = new ArrayList<>();
String date = serveTime.substring(0, 10);
String time = serveTime.substring(11, 16);
Date parse = DateUtils.stringToDate(serveTime,"yyyy-MM-dd HH:mm");
//服务时间前锁单时间判断
if (f > 0) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(parse);
for (int j = 0; j < f; j++) {
calendar.add(Calendar.MINUTE, -minute);
String format = DateUtils.format(calendar.getTime(),"yyyy-MM-dd HH:mm");
allTime.add(format);
date = format.substring(0, 10);
time = format.substring(11, 16);
ArtificerTime artificerTime = artificerTimeService.getOne(
new QueryWrapper<ArtificerTime>()
.eq("artificer_id", artificerId)
.eq("artificer_date", date)
.eq("artificer_time", time)
.last("limit 1"));
if (artificerTime != null) {
map.put("code","1");
}
}
}
//服务时间后锁单时间判断
if (i > 0) {
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(),"yyyy-MM-dd HH:mm");
allTime.add(format);
date = format.substring(0, 10);
time = format.substring(11, 16);
ArtificerTime artificerTime = artificerTimeService.getOne(
new QueryWrapper<ArtificerTime>()
.eq("artificer_id", artificerId)
.eq("artificer_date", date)
.eq("artificer_time", time)
.last("limit 1"));
if (artificerTime != null) {
map.put("code","1");
}
}
}
//服务中锁单时间判断
if (a > 0) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(parse);
calendar.add(Calendar.MINUTE, minute*i);
for (int j = 0; j < a; j++) {
calendar.add(Calendar.MINUTE, minute);
String format = DateUtils.format(calendar.getTime(),"yyyy-MM-dd HH:mm");
allTime.add(format);
date = format.substring(0, 10);
time = format.substring(11, 16);
ArtificerTime artificerTime = artificerTimeService.getOne(
new QueryWrapper<ArtificerTime>()
.eq("artificer_id", artificerId)
.eq("artificer_date", date)
.eq("artificer_time", time)
.last("limit 1"));
if (artificerTime != null) {
map.put("code","1");
}
}
}
allTime.sort(Comparator.naturalOrder());
map.put("timeList",allTime);
map.put("code","0");
return map;
}
/**
* 获取总花费时间包含当前订单中得时间
* @param duration 服务时长
* @param serveTime 服务时间
* @param value1 是否开启忙时
* @param tripWay 出行方式
* @param artificerId 技师ID
* @param ordersId 订单ID
* @return
*/
private Map<String,Object> getTaskTimeIncudeOrders(Integer duration,String serveTime,String value1,Integer tripWay,Long artificerId,Long ordersId){
Map<String,Object> map = new HashMap<>();
String beforeTime = commonInfoService.findOne(457).getValue();
int beforeTimeInt = Integer.parseInt(beforeTime);
String afterTime = commonInfoService.findOne(458).getValue();
int afterTimeInt = Integer.parseInt(afterTime);
String jyValue = commonInfoService.findOne(392).getValue();
int jyMinuteInt = Integer.parseInt(jyValue);
int cxsjInt = 0;
if(Objects.nonNull(tripWay)){
if(tripWay.equals(1)){
String cxsj = commonInfoService.findOne(454).getValue();
cxsjInt = Integer.parseInt(cxsj);
}
if(tripWay.equals(2)){
String cxsj = commonInfoService.findOne(455).getValue();
cxsjInt = Integer.parseInt(cxsj);
}
if(tripWay.equals(3)){
String cxsj = commonInfoService.findOne(456).getValue();
cxsjInt = Integer.parseInt(cxsj);
}
}
beforeTimeInt = beforeTimeInt + cxsjInt; //服务时间前锁单时间
int minute=0;
int i = 0;
int f = 0;
int a = 0;
if ("".equals(value1)) {
minute = jyMinuteInt;
if (duration % minute == 0) {
i = duration / minute;
} else {
i = duration / minute;
i++;
}
if (beforeTimeInt % minute == 0) {
f = beforeTimeInt / minute;
} else {
f = beforeTimeInt / minute;
f++;
}
if (afterTimeInt % minute == 0) {
a = afterTimeInt / minute;
} else {
a = afterTimeInt / minute;
a++;
}
}
List<String> allTime = new ArrayList<>();
String date = serveTime.substring(0, 10);
String time = serveTime.substring(11, 16);
Date parse = DateUtils.stringToDate(serveTime,"yyyy-MM-dd HH:mm");
//服务时间前锁单时间判断
if (f > 0) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(parse);
for (int j = 0; j < f; j++) {
calendar.add(Calendar.MINUTE, -minute);
String format = DateUtils.format(calendar.getTime(),"yyyy-MM-dd HH:mm");
allTime.add(format);
date = format.substring(0, 10);
time = format.substring(11, 16);
ArtificerTime artificerTime = artificerTimeService.getOne(
new QueryWrapper<ArtificerTime>()
.eq("artificer_id", artificerId)
.eq("artificer_date", date)
.eq("artificer_time", time)
.ne("orders_id", ordersId)
.last("limit 1"));
if (artificerTime != null) {
map.put("code","1");
}
}
}
//服务时间后锁单时间判断
if (i > 0) {
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(),"yyyy-MM-dd HH:mm");
allTime.add(format);
date = format.substring(0, 10);
time = format.substring(11, 16);
ArtificerTime artificerTime = artificerTimeService.getOne(
new QueryWrapper<ArtificerTime>()
.eq("artificer_id", artificerId)
.eq("artificer_date", date)
.eq("artificer_time", time)
.ne("orders_id", ordersId)
.last("limit 1"));
if (artificerTime != null) {
map.put("code","1");
}
}
}
//服务中锁单时间判断
if (a > 0) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(parse);
calendar.add(Calendar.MINUTE, minute*i);
for (int j = 0; j < a; j++) {
calendar.add(Calendar.MINUTE, minute);
String format = DateUtils.format(calendar.getTime(),"yyyy-MM-dd HH:mm");
allTime.add(format);
date = format.substring(0, 10);
time = format.substring(11, 16);
ArtificerTime artificerTime = artificerTimeService.getOne(
new QueryWrapper<ArtificerTime>()
.eq("artificer_id", artificerId)
.eq("artificer_date", date)
.eq("artificer_time", time)
.ne("orders_id", ordersId)
.last("limit 1"));
if (artificerTime != null) {
map.put("code","1");
}
}
}
allTime.sort(Comparator.naturalOrder());
map.put("timeList",allTime);
map.put("code","0");
return map;
}
/**
* 获取加钟总花费时间
* @param duration 服务时长
* @param serveTime 服务时间
* @param value1 是否开启忙时
* @param artificerId 技师ID
* @return
*/
private Map<String,Object> getAddTaskTime(Integer duration,String serveTime,String value1,Long artificerId){
Map<String,Object> map = new HashMap<>();
String jyValue = commonInfoService.findOne(392).getValue();
int jyMinuteInt = Integer.parseInt(jyValue);
int minute=0;
int i = 0;
if ("".equals(value1)) {
minute = jyMinuteInt;
if (duration % minute == 0) {
i = duration / minute;
} else {
i = duration / minute;
i++;
}
}
List<String> allTime = new ArrayList<>();
String date = serveTime.substring(0, 10);
String time = serveTime.substring(11, 16);
Date parse = DateUtils.stringToDate(serveTime,"yyyy-MM-dd HH:mm");
//服务时间后锁单时间判断
if (i > 0) {
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(),"yyyy-MM-dd HH:mm");
allTime.add(format);
date = format.substring(0, 10);
time = format.substring(11, 16);
ArtificerTime artificerTime = artificerTimeService.getOne(
new QueryWrapper<ArtificerTime>()
.eq("artificer_id", artificerId)
.eq("artificer_date", date)
.eq("artificer_time", time)
.last("limit 1"));
if (artificerTime != null) {
map.put("code","1");
}
}
}
allTime.sort(Comparator.naturalOrder());
map.put("timeList",allTime);
map.put("code","0");
return map;
}
/**
* 插入技师占用时间表
* @param allTime 时间集合
* @param artificerId 技师ID
* @param ordersId 订单ID
*/
private void insertArtificerTime(List<String> allTime,Long artificerId,Long ordersId){
if(allTime!=null && allTime.size()>0) {
for (int i=0; i<allTime.size(); i++) {
String serveTime2 = allTime.get(i);
String date2 = serveTime2.substring(0, 10);
String time2 = serveTime2.substring(11, 16);
ArtificerTime artificerTime2 = new ArtificerTime();
artificerTime2.setArtificerId(artificerId);
artificerTime2.setArtificerDate(date2);
artificerTime2.setArtificerTime(time2);
artificerTime2.setClassify(1);
artificerTime2.setOrdersId(ordersId);
artificerTime2.setCreateTime(DateUtils.format(new Date()));
artificerTimeService.save(artificerTime2);
}
}
}
@Override
public Result payMoney(Long userId,Long payClassifyId,Integer classify, Long artificerId, Long ordersId,HttpServletRequest request) throws Exception {
PayClassify payClassify = payClassifyService.getById(payClassifyId);
@ -171,49 +525,125 @@ public class WxServiceImpl implements WxService {
if(orders.getParentId()!=null && orders.getParentId()!=0){
Orders orders1 = ordersDao.selectById(orders.getParentId());
OrdersMassage ordersMassage = ordersMassageService.getOne(new QueryWrapper<OrdersMassage>().eq("orders_id", orders1.getOrdersId()));
MassageType massageType = massageTypeService.getById(ordersMassage.getMassageId());
if(massageType.getAddNum()==null || massageType.getAddNum()==0){
MassageType massageType = null;
if(orders1.getUserPackageDetailId() !=null){
UserPackageDetail userPackageDetail = userPackageDetailService.getById(ordersMassage.getMassageId());
massageType = massageTypeService.getById(userPackageDetail.getMassageTypeId());
}else{
massageType = massageTypeService.getById(ordersMassage.getMassageId());
}
if (massageType.getAddNum() == null || massageType.getAddNum() == 0) {
return Result.error("当前项目不允许加钟!");
}else if(massageType.getAddNum()>0){
if(orders1.getAddNum()!=null && orders1.getAddNum()>=massageType.getAddNum()){
} else if (massageType.getAddNum() > 0) {
if (orders1.getAddNum() != null && orders1.getAddNum().intValue() >= massageType.getAddNum().intValue()) {
return Result.error("当前项目已超过最大加钟次数!");
}
}
Integer duration=massageType.getDuration();
String value1 = commonInfoService.findOne(395).getValue();
if("".equals(value1)){
String value = commonInfoService.findOne(392).getValue();
int minute = Integer.parseInt(value);
int i=1;
if(duration%minute==0){
i=duration/minute;
}else{
i=duration/minute;
i++;
}
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;
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
Date parse = sdf.parse(serveTime);
Calendar calendar=Calendar.getInstance();
calendar.setTime(parse);
for(int j=0;j<i;j++){
calendar.add(Calendar.MINUTE,minute);
String format = sdf.format(calendar.getTime());
date = format.substring(0, 10);
time = format.substring(11, 16);
artificerTime = artificerTimeService.getOne(
String serveTime = artificerTime.getArtificerDate() + " " + artificerTime.getArtificerTime();
Map<String,Object> map = getAddTaskTime(orders.getDuration(),serveTime,value1,orders.getArtificerId());
if(map.get("code").toString().equals("1")){
return Result.error("预约时间正忙,请更换其他时间!");
}
insertArtificerTime((ArrayList)map.get("timeList"),orders.getArtificerId(),orders.getOrdersId());
}
}else{
String value1 = commonInfoService.findOne(395).getValue();
if ("".equals(value1)) {
if(orders.getIsSupplement() != null){
if(orders.getIsSupplement() == 1){
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)
.last("limit 1"));
if (artificerTime != null) {
return Result.error("预约时间正忙,请更换其他时间!");
}
Map<String,Object> map = getTaskTime(orders.getDuration(),orders.getServeTime(),value1,orders.getTripWay(),orders.getArtificerId());
if(map.get("code").toString().equals("1")){
return Result.error("预约时间正忙,请更换其他时间!");
}
insertArtificerTime((ArrayList)map.get("timeList"),orders.getArtificerId(),orders.getOrdersId());
}else if(orders.getIsSupplement() == 2){
Orders oldOrders = ordersDao.selectById(orders.getOrdersId());
int timeDifference = orders.getDuration()-oldOrders.getDuration();
if(timeDifference>0){
ArtificerTime artificerTime = artificerTimeService.getOne(new QueryWrapper<ArtificerTime>().eq("orders_id", orders.getOrdersId()).last(" order by artificer_time_id desc limit 1 "));
String serveTime = artificerTime.getArtificerDate() + " " + artificerTime.getArtificerTime();
Map<String,Object> map = getAddTaskTime(timeDifference,serveTime,value1,oldOrders.getArtificerId());
if(map.get("code").toString().equals("1")){
return Result.error("预约时间正忙,请更换其他时间!");
}
//技师占用时间表插入新订单号的多出来的服务时间
insertArtificerTime((ArrayList)map.get("timeList"),orders.getArtificerId(),orders.getOrdersId());
}else{
//技师占用时间表插入新订单号的同时间
List<ArtificerTime> artificerTimeList = artificerTimeService.list(new QueryWrapper<ArtificerTime>().eq("orders_id", orders.getOrdersId()).last(" order by artificer_time_id"));
if(artificerTimeList!=null && artificerTimeList.size()>0){
for(int i=0; i<artificerTimeList.size(); i++){
ArtificerTime artificerTime = artificerTimeList.get(i);
artificerTime.setArtificerId(orders.getArtificerId());
artificerTime.setOrdersId(orders.getOrdersId());
artificerTime.setCreateTime(DateUtils.format(new Date()));
artificerTimeService.save(artificerTime);
}
}
}
}else{
//orders.getIsSupplement() == 3 || orders.getIsSupplement() == 4
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)
.ne("orders_id", orders.getOrdersId())
.last("limit 1"));
if (artificerTime != null) {
return Result.error("预约时间正忙,请更换其他时间!");
}
Map<String,Object> map = getTaskTimeIncudeOrders(orders.getDuration(),orders.getServeTime(),value1,orders.getTripWay(),orders.getArtificerId(),orders.getOldOrdersId());
if(map.get("code").toString().equals("1")){
return Result.error("预约时间正忙,请更换其他时间!");
}
//删除技师占用时间表数据
artificerTimeService.remove(new QueryWrapper<ArtificerTime>().eq("orders_id", orders.getOldOrdersId()));
//插入技师占用时间表新订单
insertArtificerTime((ArrayList)map.get("timeList"),orders.getArtificerId(),orders.getOrdersId());
//插入技师占用时间表原订单
insertArtificerTime((ArrayList)map.get("timeList"),orders.getArtificerId(),orders.getOldOrdersId());
}
}else{
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){
.eq("artificer_date", date)
.eq("artificer_time", time)
.last("limit 1"));
if (artificerTime != null) {
return Result.error("预约时间正忙,请更换其他时间!");
}
Map<String,Object> map = getTaskTime(orders.getDuration(),orders.getServeTime(),value1,orders.getTripWay(),orders.getArtificerId());
if(map.get("code").toString().equals("1")){
return Result.error("预约时间正忙,请更换其他时间!");
}
insertArtificerTime((ArrayList)map.get("timeList"),orders.getArtificerId(),orders.getOrdersId());
}
}
}
PayDetails payDetails1 = payDetailsDao.selectByOrderId(orders.getOrdersNo());
if(payDetails1==null){
PayDetails payDetails = new PayDetails();
@ -781,43 +1211,43 @@ public class WxServiceImpl implements WxService {
ordersService.updateById(orders);
if(orders.getParentId()!=null && orders.getParentId()!=0){
String value1 = commonInfoService.findOne(395).getValue();
OrdersMassage ordersMassage = ordersMassageService.getOne(new QueryWrapper<OrdersMassage>().eq("orders_id", orders.getOrdersId()));
MassageType massageType = massageTypeService.getById(ordersMassage.getMassageId());
Integer duration=massageType.getDuration();
Calendar calendar=Calendar.getInstance();
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 value = commonInfoService.findOne(392).getValue();
int minute = Integer.parseInt(value);
int i=1;
if(duration%minute==0){
i=duration/minute;
}else{
i=duration/minute;
i++;
}
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm");
Date parse = sdf1.parse(serveTime);
calendar.setTime(parse);
for(int j=0;j<i;j++){
calendar.add(Calendar.MINUTE,minute);
String format = sdf1.format(calendar.getTime());
String date = format.substring(0, 10);
String time = format.substring(11, 16);
artificerTime=new ArtificerTime();
artificerTime.setArtificerId(orders.getArtificerId());
artificerTime.setArtificerDate(date);
artificerTime.setArtificerTime(time);
artificerTime.setClassify(1);
artificerTime.setOrdersId(orders.getParentId());
artificerTime.setCreateTime(DateUtils.format(new Date()));
artificerTimeService.save(artificerTime);
}
}
// String value1 = commonInfoService.findOne(395).getValue();
// OrdersMassage ordersMassage = ordersMassageService.getOne(new QueryWrapper<OrdersMassage>().eq("orders_id", orders.getOrdersId()));
// MassageType massageType = massageTypeService.getById(ordersMassage.getMassageId());
// Integer duration=massageType.getDuration();
// 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 value = commonInfoService.findOne(392).getValue();
// int minute = Integer.parseInt(value);
// int i=1;
// if(duration%minute==0){
// i=duration/minute;
// }else{
// i=duration/minute;
// i++;
// }
//
// SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm");
// Date parse = sdf1.parse(serveTime);
//
// calendar.setTime(parse);
// for(int j=0;j<i;j++){
// calendar.add(Calendar.MINUTE,minute);
// String format = sdf1.format(calendar.getTime());
// String date = format.substring(0, 10);
// String time = format.substring(11, 16);
// artificerTime=new ArtificerTime();
// artificerTime.setArtificerId(orders.getArtificerId());
// artificerTime.setArtificerDate(date);
// artificerTime.setArtificerTime(time);
// artificerTime.setClassify(1);
// artificerTime.setOrdersId(orders.getParentId());
// artificerTime.setCreateTime(DateUtils.format(new Date()));
// artificerTimeService.save(artificerTime);
// }
// }
Orders orders1 = ordersDao.selectById(orders.getParentId());
if(orders1.getAddNum()==null){
@ -856,16 +1286,16 @@ public class WxServiceImpl implements WxService {
orders1.setPingMoney(orders1.getPingMoney().add(orders.getPingMoney()));
if(orders1.getStatus().equals(6)){
ordersMassage = ordersMassageService.getOne(new QueryWrapper<OrdersMassage>().eq("orders_id", orders1.getOrdersId()));
massageType = massageTypeService.getById(ordersMassage.getMassageId());
duration=massageType.getDuration();
// ordersMassage = ordersMassageService.getOne(new QueryWrapper<OrdersMassage>().eq("orders_id", orders1.getOrdersId()));
// massageType = massageTypeService.getById(ordersMassage.getMassageId());
// duration=massageType.getDuration();
String endTime = orders1.getEndTime();
Date date = DateUtils.stringToDate(endTime, "yyyy-MM-dd HH:mm:ss");
calendar=Calendar.getInstance();
if(date.getTime()>System.currentTimeMillis()){
calendar.setTime(date);
}
calendar.add(Calendar.MINUTE,duration);
calendar.add(Calendar.MINUTE,orders.getDuration());
orders1.setEndTime(endTime);
}
orders1.setAddPrice(orders.getPrice());
@ -1419,43 +1849,43 @@ public class WxServiceImpl implements WxService {
ordersService.updateById(orders);
if(orders.getParentId()!=null && orders.getParentId()!=0){
String value1 = commonInfoService.findOne(395).getValue();
OrdersMassage ordersMassage = ordersMassageService.getOne(new QueryWrapper<OrdersMassage>().eq("orders_id", orders.getOrdersId()));
MassageType massageType = massageTypeService.getById(ordersMassage.getMassageId());
Integer duration=massageType.getDuration();
Calendar calendar=Calendar.getInstance();
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 value = commonInfoService.findOne(392).getValue();
int minute = Integer.parseInt(value);
int i=1;
if(duration%minute==0){
i=duration/minute;
}else{
i=duration/minute;
i++;
}
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm");
Date parse = sdf1.parse(serveTime);
calendar.setTime(parse);
for(int j=0;j<i;j++){
calendar.add(Calendar.MINUTE,minute);
String format = sdf1.format(calendar.getTime());
String date = format.substring(0, 10);
String time = format.substring(11, 16);
artificerTime=new ArtificerTime();
artificerTime.setArtificerId(orders.getArtificerId());
artificerTime.setArtificerDate(date);
artificerTime.setArtificerTime(time);
artificerTime.setClassify(1);
artificerTime.setOrdersId(orders.getParentId());
artificerTime.setCreateTime(DateUtils.format(new Date()));
artificerTimeService.save(artificerTime);
}
}
// String value1 = commonInfoService.findOne(395).getValue();
// OrdersMassage ordersMassage = ordersMassageService.getOne(new QueryWrapper<OrdersMassage>().eq("orders_id", orders.getOrdersId()));
// MassageType massageType = massageTypeService.getById(ordersMassage.getMassageId());
// Integer duration=massageType.getDuration();
// 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 value = commonInfoService.findOne(392).getValue();
// int minute = Integer.parseInt(value);
// int i=1;
// if(duration%minute==0){
// i=duration/minute;
// }else{
// i=duration/minute;
// i++;
// }
//
// SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm");
// Date parse = sdf1.parse(serveTime);
//
// calendar.setTime(parse);
// for(int j=0;j<i;j++){
// calendar.add(Calendar.MINUTE,minute);
// String format = sdf1.format(calendar.getTime());
// String date = format.substring(0, 10);
// String time = format.substring(11, 16);
// artificerTime=new ArtificerTime();
// artificerTime.setArtificerId(orders.getArtificerId());
// artificerTime.setArtificerDate(date);
// artificerTime.setArtificerTime(time);
// artificerTime.setClassify(1);
// artificerTime.setOrdersId(orders.getParentId());
// artificerTime.setCreateTime(DateUtils.format(new Date()));
// artificerTimeService.save(artificerTime);
// }
// }
Orders orders1 = ordersDao.selectById(orders.getParentId());
if(orders1.getAddNum()==null){
@ -1494,16 +1924,16 @@ public class WxServiceImpl implements WxService {
orders1.setPingMoney(orders1.getPingMoney().add(orders.getPingMoney()));
if(orders1.getStatus().equals(6)){
ordersMassage = ordersMassageService.getOne(new QueryWrapper<OrdersMassage>().eq("orders_id", orders1.getOrdersId()));
massageType = massageTypeService.getById(ordersMassage.getMassageId());
duration=massageType.getDuration();
// ordersMassage = ordersMassageService.getOne(new QueryWrapper<OrdersMassage>().eq("orders_id", orders1.getOrdersId()));
// massageType = massageTypeService.getById(ordersMassage.getMassageId());
// duration=massageType.getDuration();
String endTime = orders1.getEndTime();
Date date = DateUtils.stringToDate(endTime, "yyyy-MM-dd HH:mm:ss");
calendar=Calendar.getInstance();
if(date.getTime()>System.currentTimeMillis()){
calendar.setTime(date);
}
calendar.add(Calendar.MINUTE,duration);
calendar.add(Calendar.MINUTE,orders.getAddTime());
orders1.setEndTime(endTime);
}
orders1.setAddPrice(orders.getPrice());
@ -1870,6 +2300,21 @@ public class WxServiceImpl implements WxService {
xmlBack = "<xml>" + "<return_code><![CDATA[FAIL]]></return_code>" + "<return_msg><![CDATA[报文为空]]></return_msg>" + "</xml> ";
}
} else {
if (out_trade_no != null) {
//支付失败或者取消删除技师占用表数据
PayDetails payDetails = payDetailsDao.selectByOrderId(out_trade_no);
if (payDetails.getState() == 0){
if(payDetails.getType()==1){
artificerTimeService.remove(new QueryWrapper<ArtificerTime>().eq("orders_id", payDetails.getOrderId()));
payDetailsDao.deleteById(payDetails.getId());
System.err.println("微信手机支付回调成功订单号:" + out_trade_no + "");
xmlBack = "<xml>" + "<return_code><![CDATA[SUCCESS]]></return_code>" + "<return_msg><![CDATA[OK]]></return_msg>" + "</xml> ";
}
}
}else {
System.err.println("微信手机支付回调成功订单号:" + out_trade_no + "");
xmlBack = "<xml>" + "<return_code><![CDATA[FAIL]]></return_code>" + "<return_msg><![CDATA[报文为空]]></return_msg>" + "</xml> ";
}
}
return xmlBack;
} else {

View File

@ -1142,7 +1142,7 @@
where a.status in (3,5)
and a.artificer_id = ${userId}
and a.end_times BETWEEN #{startTime} and #{endTime} and a.parent_id = 0
order serve_time by desc
order by serve_time desc
</select>
<select id="getJiazhongList" resultType="com.sqx.modules.artificer.entity.Orders">