Commit b516df82 authored by lining's avatar lining

feat: 时间格式化

parent 6bff29c0
package com.onsiteservice.common.order.vo;
import com.alibaba.fastjson.annotation.JSONField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
......@@ -23,9 +24,11 @@ public class ServiceOrderLogVO {
private String remark;
@ApiModelProperty(value = "流程发生时间")
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
private Date createTime;
@ApiModelProperty(value = "估价员上门时间")
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
private Date expectArrivalTime;
}
\ No newline at end of file
package com.onsiteservice.common.order.vo;
import com.alibaba.fastjson.annotation.JSONField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
......@@ -17,6 +18,9 @@ public class ServiceOrderVO {
@ApiModelProperty(value = "订单号")
private String orderNo;
@ApiModelProperty(value = "服务名")
private String serviceName;
@ApiModelProperty(value = "客户名")
private String name;
@ApiModelProperty(value = "客户手机号")
......@@ -25,6 +29,7 @@ public class ServiceOrderVO {
private String address;
@ApiModelProperty(value = "期望上门时间")
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
private Date expectArrivalTime;
@ApiModelProperty(value = "服务数量")
......@@ -40,8 +45,12 @@ public class ServiceOrderVO {
private String remark;
@ApiModelProperty(value = "订单创建时间")
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
private Date createTime;
@ApiModelProperty(value = "订单付款剩余时间")
private Long leftTime;
@ApiModelProperty(value = "客户上传需求图片,最多8张")
private List<String> demandImgUrls;
......@@ -49,6 +58,6 @@ public class ServiceOrderVO {
private List<ServiceOrderLogVO> process;
@ApiModelProperty(value = "订单状态 1待受理,2 已拍估价员 3待支付,4待派单,5服务中,6已完成,7已取消 ")
private Integer orderStatus;
private String orderStatus;
}
\ No newline at end of file
......@@ -5,6 +5,7 @@ import com.onsiteservice.common.order.dto.FinishServiceOrderDTO;
import com.onsiteservice.common.order.dto.SendServiceOrderDTO;
import com.onsiteservice.common.order.dto.ValuationServiceOrderDTO;
import com.onsiteservice.constant.constant.BizConstants;
import com.onsiteservice.constant.constant.SysParamConstants;
import com.onsiteservice.constant.enums.BizCodeEnum;
import com.onsiteservice.constant.enums.ServiceOrderOpSourceEnum;
import com.onsiteservice.constant.enums.ServiceOrderStatusEnum;
......@@ -13,6 +14,7 @@ import com.onsiteservice.core.exception.ServiceException;
import com.onsiteservice.dao.common.AbstractMapper;
import com.onsiteservice.dao.component.RecordComponent;
import com.onsiteservice.dao.mapper.service.*;
import com.onsiteservice.dao.mapper.sys.SysParamMapper;
import com.onsiteservice.dao.mapper.sys.SysUserMapper;
import com.onsiteservice.dao.mapper.user.UserMapper;
import com.onsiteservice.entity.order.ServiceOrder;
......@@ -20,6 +22,7 @@ import com.onsiteservice.entity.service.ServiceValuator;
import com.onsiteservice.entity.service.ServiceValuatorAssign;
import com.onsiteservice.entity.service.ServiceWorker;
import com.onsiteservice.entity.service.ServiceWorkerAssign;
import com.onsiteservice.entity.sys.SysParam;
import com.onsiteservice.entity.sys.SysUser;
import com.onsiteservice.entity.user.User;
import com.onsiteservice.util.aliyun.SmsUtils;
......@@ -72,6 +75,9 @@ public class ServiceOrderService extends AbstractMapper<ServiceOrder> {
@Resource
private SysUserMapper sysUserMapper;
@Resource
private SysParamMapper sysParamMapper;
/**
* 指派估价员 管理员操作
......@@ -163,7 +169,11 @@ public class ServiceOrderService extends AbstractMapper<ServiceOrder> {
serviceOrder.setOrderStatus(ServiceOrderStatusEnum.SEND.getStatus());
serviceOrder.setModifyBy(userId);
// 超时时间
serviceOrder.setCancelTime(new Date());
Condition sysParamCondition = new Condition(SysParam.class);
sysParamCondition.createCriteria().andEqualTo("code", SysParamConstants.ORDER_PAY_TIMEOUT);
List<SysParam> sysParamList = sysParamMapper.selectByCondition(sysParamCondition);
long timeOut = CollectionUtils.isEmpty(sysParamList) ? BizConstants.OrderConstants.TIMEOUT_CANCEL_LIMIT : Long.parseLong(sysParamList.get(0).getValue());
serviceOrder.setCancelTime(new Date(System.currentTimeMillis() + timeOut));
int result = serviceOrderMapper.updateByPrimaryKeySelective(serviceOrder);
......
......@@ -53,6 +53,7 @@ public class ServiceOrderController {
private ServiceOrderService serviceOrderService;
@Dict(code = DictConstants.ORDER_STATUS, name = "orderStatus")
@ApiOperation(value = "根据id查询订单详情")
@GetMapping("get/{id}")
public Result<ServiceOrderVO> getDetail(@ApiParam(name = "id", value = "订单id") @PathVariable @Positive Long id, @CurrentUserId Long userId) {
......
......@@ -48,19 +48,13 @@ public class ServiceOrderCancelJob {
public void cancelServiceOrder() {
log.info("cancelServiceOrder start!");
// 超时时间
Condition sysParamCondition = new Condition(SysParam.class);
sysParamCondition.createCriteria().andEqualTo("code", SysParamConstants.ORDER_PAY_TIMEOUT);
List<SysParam> sysParamList = sysParamMapper.selectByCondition(sysParamCondition);
long timeOut = CollectionUtils.isEmpty(sysParamList) ? BizConstants.OrderConstants.TIMEOUT_CANCEL_LIMIT : Long.parseLong(sysParamList.get(0).getValue());
// 超时订单
Condition c = new Condition(ServiceOrder.class);
c.createCriteria().andEqualTo(BizConstants.OrderConstants.ORDER_STATUS, ServiceOrderStatusEnum.SEND.getStatus());
List<ServiceOrder> serviceOrderList = serviceOrderMapper.selectByCondition(c);
serviceOrderList.forEach(serviceOrder -> {
if ((System.currentTimeMillis() - serviceOrder.getCancelTime().getTime()) >= timeOut) {
if (System.currentTimeMillis() > serviceOrder.getCancelTime().getTime()) {
serviceOrder.setOrderStatus(ServiceOrderStatusEnum.CANCEL.getStatus());
serviceOrder.setRemark(MSG);
int result = serviceOrderMapper.updateByPrimaryKey(serviceOrder);
......
......@@ -37,6 +37,7 @@ import com.onsiteservice.miniapp.controller.order.vo.ServiceOrderDefDetailVO;
import com.onsiteservice.miniapp.service.weixin.pay.WechatNativePay;
import com.onsiteservice.service.order.ServiceOrderService;
import com.onsiteservice.util.AttrCopyUtils;
import com.onsiteservice.util.DateUtils;
import com.onsiteservice.util.RandomUtils;
import com.onsiteservice.util.aliyun.SmsUtils;
import lombok.extern.slf4j.Slf4j;
......@@ -223,20 +224,20 @@ public class ServiceOrderBizService extends AbstractMapper<ServiceOrder> {
logCondition.setProcessId(ServiceOrderStatusEnum.SEND.getStatus());
var orderLog = serviceOrderLogMapper.selectOne(logCondition);
if (orderLog != null) {
if(ServiceOrderOpSourceEnum.WEB.getId().equals(orderLog.getSource())) {
var sysUser = sysUserMapper.selectByPrimaryKey(orderLog.getHostId());
if(StringUtils.isNotEmpty(sysUser.getPhone())) {
try {
smsUtils.send("", "", "", sysUser.getPhone());
amqpTemplate.convertAndSend(SysConstants.Queue.ADMIN_ORDER, Pair.of(sysUser.getId(), 1));
} catch (Exception e) {
e.printStackTrace();
log.error("订单{} 支付成功短信发送失败", orderNo);
}
}
if (ServiceOrderOpSourceEnum.WEB.getId().equals(orderLog.getSource())) {
var sysUser = sysUserMapper.selectByPrimaryKey(orderLog.getHostId());
if (StringUtils.isNotEmpty(sysUser.getPhone())) {
try {
smsUtils.send("", "", "", sysUser.getPhone());
amqpTemplate.convertAndSend(SysConstants.Queue.ADMIN_ORDER, Pair.of(sysUser.getId(), 1));
} catch (Exception e) {
e.printStackTrace();
log.error("订单{} 支付成功短信发送失败", orderNo);
}
}
}
if(ServiceOrderOpSourceEnum.MINI_APP.getId().equals(orderLog.getSource())) {
var user = userMapper.selectByPrimaryKey(orderLog.getHostId());
if (ServiceOrderOpSourceEnum.MINI_APP.getId().equals(orderLog.getSource())) {
var user = userMapper.selectByPrimaryKey(orderLog.getHostId());
try {
smsUtils.send("", "", "", user.getPhone());
} catch (Exception e) {
......@@ -335,9 +336,27 @@ public class ServiceOrderBizService extends AbstractMapper<ServiceOrder> {
List<ServiceSubclass> serviceSubclassList = serviceSubclassMapper.selectByIdList(subclassIdList);
Map<Integer, ServiceSubclass> serviceSubclassMap = serviceSubclassList.parallelStream().collect(Collectors.toMap(ServiceSubclass::getId, Function.identity()));
return serviceOrderList.parallelStream().map(e -> {
ServiceOrderVO serviceOrderVO = AttrCopyUtils.copy(e, new ServiceOrderVO());
serviceOrderVO.setSubclassImg(serviceSubclassMap.getOrDefault(e.getSubclassId(), new ServiceSubclass()).getImg());
return serviceOrderList.parallelStream().map(serviceOrder -> {
ServiceOrderVO serviceOrderVO = new ServiceOrderVO();
serviceOrderVO.setId(serviceOrder.getId());
serviceOrderVO.setOrderNo(serviceOrder.getOrderNo());
serviceOrderVO.setServiceName(serviceOrder.getServiceName());
serviceOrderVO.setName(serviceOrder.getName());
serviceOrderVO.setPhone(serviceOrder.getPhone());
serviceOrderVO.setAddress(serviceOrder.getAddress());
serviceOrderVO.setExpectArrivalTime(serviceOrder.getExpectArrivalTime());
serviceOrderVO.setNum(serviceOrder.getNum());
serviceOrderVO.setDemandDesc(serviceOrder.getDemandDesc());
serviceOrderVO.setRemark(serviceOrder.getRemark());
serviceOrderVO.setCreateTime(serviceOrder.getCreateTime());
serviceOrderVO.setOrderStatus(String.valueOf(serviceOrder.getOrderStatus()));
// 剩余时间
if (serviceOrder.getOrderStatus().equals(ServiceOrderStatusEnum.SEND.getStatus())) {
long left = Math.max(serviceOrder.getCancelTime().getTime() - System.currentTimeMillis(), 0);
serviceOrderVO.setLeftTime(left);
}
serviceOrderVO.setSubclassImg(serviceSubclassMap.getOrDefault(serviceOrder.getSubclassId(), new ServiceSubclass()).getImg());
return serviceOrderVO;
}).collect(Collectors.toList());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment