Commit 0de5834e authored by kretee's avatar kretee

feat: 估价接口

parent 6dc3b020
...@@ -27,7 +27,13 @@ public enum BizCodeEnum { ...@@ -27,7 +27,13 @@ public enum BizCodeEnum {
/** /**
* 服务地址模块 * 服务地址模块
*/ */
SERVICE_ADDRESS_NOT_EXIST("服务地址不存在"); SERVICE_ADDRESS_NOT_EXIST("服务地址不存在"),
/**
*
*/
SERVICE_SUBCLASS_NOT_EXIST("服务项目不存在");
@Getter @Getter
......
package com.onsiteservice.constant.enums;
import lombok.Getter;
/**
* <P>服务地址枚举</P>
*
* @author 李宁
* @version v1.0
* @since 2022/7/8 10:16
*/
public enum ServiceAddressStatusEnum {
/**
* 是默认收货地址
*/
DEFAULT_STATUS(1),
/**
* 非默认收货地址
*/
COMMON_STATUS(0);
@Getter
private int status;
private ServiceAddressStatusEnum(int status) {
this.status = status;
}
}
package com.onsiteservice.constant.enums;
import lombok.Getter;
/**
* <P>订单状态枚举</P>
*
* @author jack
* @version v1.0
* @since 2022/4/11 15:42
*/
public enum ServiceOrderStatusEnum {
/**
* 已提交
*/
SUBMIT(1, "已提交"),
/**
* 已受理:估价+发送客户
*/
ACCEPT(2, "已受理"),
/**
* 已支付
*/
PAY(3, "已支付"),
/**
* 已派单
*/
DISPATCH(4, "已派单"),
/**
* 已确认
*/
CONFIRM(5, "已确认"),
/**
*
*/
CANCEL(6, "已取消"),
/**
* 退款状态
*/
REFUND_APPLY(4,"申请退款"),
REFUND_HANDLING(4,"退款处理中"),
REFUND_FAIL(4,"退款失败"),
REFUND_FINISH(4,"退款完成");
@Getter
private Integer status;
@Getter
private String msg;
private ServiceOrderStatusEnum(Integer status, String msg) {
this.status = status;
this.msg = msg;
}
}
...@@ -64,7 +64,7 @@ public class ServiceAddress implements Serializable { ...@@ -64,7 +64,7 @@ public class ServiceAddress implements Serializable {
* 是否默认:1默认地址,0非默认地址 * 是否默认:1默认地址,0非默认地址
*/ */
@ApiModelProperty("是否默认:1默认地址,0非默认地址") @ApiModelProperty("是否默认:1默认地址,0非默认地址")
private Integer def; private Boolean def;
/** /**
* 创建时间 * 创建时间
......
...@@ -38,6 +38,13 @@ public class ServiceOrder implements Serializable { ...@@ -38,6 +38,13 @@ public class ServiceOrder implements Serializable {
@ApiModelProperty("账号") @ApiModelProperty("账号")
private Long accountNo; private Long accountNo;
/**
* 服务类型id
*/
@Column(name = "subclass_id")
@ApiModelProperty("服务类型id")
private Integer subclassId;
/** /**
* 服务地址id * 服务地址id
*/ */
...@@ -77,7 +84,7 @@ public class ServiceOrder implements Serializable { ...@@ -77,7 +84,7 @@ public class ServiceOrder implements Serializable {
*/ */
@Column(name = "read_agreement") @Column(name = "read_agreement")
@ApiModelProperty("是否阅读协议:1已阅读,0未阅读") @ApiModelProperty("是否阅读协议:1已阅读,0未阅读")
private Integer readAgreement; private Boolean readAgreement;
/** /**
* 订单状态:1已预约,2已派单,3进行中,4完成,5取消,6已评价 * 订单状态:1已预约,2已派单,3进行中,4完成,5取消,6已评价
......
...@@ -102,6 +102,10 @@ public class User implements Serializable { ...@@ -102,6 +102,10 @@ public class User implements Serializable {
@ApiModelProperty("即时通讯id") @ApiModelProperty("即时通讯id")
private String imUserId; private String imUserId;
@Column(name = "admin")
@ApiModelProperty("管理员")
private Boolean admin;
/** /**
* 是否启用 0: 禁用 1: 启用 * 是否启用 0: 禁用 1: 启用
*/ */
......
...@@ -31,6 +31,7 @@ public class SaveServiceAddressDTO { ...@@ -31,6 +31,7 @@ public class SaveServiceAddressDTO {
* 区域id * 区域id
*/ */
@ApiModelProperty(value = "区域id", required = true) @ApiModelProperty(value = "区域id", required = true)
@NotNull(message = "请输入区域ID")
private Long areaId; private Long areaId;
/** /**
...@@ -48,6 +49,7 @@ public class SaveServiceAddressDTO { ...@@ -48,6 +49,7 @@ public class SaveServiceAddressDTO {
private String address; private String address;
@ApiModelProperty(value = "是否默认收货地址", required = true) @ApiModelProperty(value = "是否默认收货地址", required = true)
private Integer def; @NotNull(message = "请确认地址是否默认")
private Boolean def;
} }
\ No newline at end of file
...@@ -13,6 +13,7 @@ import javax.validation.constraints.Pattern; ...@@ -13,6 +13,7 @@ import javax.validation.constraints.Pattern;
public class UpdateServiceAddressDTO { public class UpdateServiceAddressDTO {
@ApiModelProperty(value = "服务地址id", required = true) @ApiModelProperty(value = "服务地址id", required = true)
@NotNull(message = "请选择地址ID")
private Long id; private Long id;
/** /**
...@@ -34,6 +35,7 @@ public class UpdateServiceAddressDTO { ...@@ -34,6 +35,7 @@ public class UpdateServiceAddressDTO {
* 区域id * 区域id
*/ */
@ApiModelProperty(value = "区域id", required = true) @ApiModelProperty(value = "区域id", required = true)
@NotNull(message = "请选择区域ID")
private Long areaId; private Long areaId;
/** /**
...@@ -51,6 +53,7 @@ public class UpdateServiceAddressDTO { ...@@ -51,6 +53,7 @@ public class UpdateServiceAddressDTO {
private String address; private String address;
@ApiModelProperty(value = "是否默认收货地址", required = true) @ApiModelProperty(value = "是否默认收货地址", required = true)
private Integer def; @NotNull(message = "请确认地址是否默认")
private Boolean def;
} }
\ No newline at end of file
...@@ -38,6 +38,6 @@ public class ServiceAddressVO { ...@@ -38,6 +38,6 @@ public class ServiceAddressVO {
/** /**
* 是否默认:1默认地址,0非默认地址 * 是否默认:1默认地址,0非默认地址
*/ */
private Integer def; private Boolean def;
} }
\ No newline at end of file
...@@ -6,6 +6,7 @@ import com.onsiteservice.dao.common.page.PageInfoVO; ...@@ -6,6 +6,7 @@ import com.onsiteservice.dao.common.page.PageInfoVO;
import com.onsiteservice.entity.order.ServiceOrder; import com.onsiteservice.entity.order.ServiceOrder;
import com.onsiteservice.miniapp.controller.order.dto.PageServiceOrderDTO; import com.onsiteservice.miniapp.controller.order.dto.PageServiceOrderDTO;
import com.onsiteservice.miniapp.controller.order.dto.SaveServiceOrderDTO; import com.onsiteservice.miniapp.controller.order.dto.SaveServiceOrderDTO;
import com.onsiteservice.miniapp.controller.order.dto.SendServiceOrderDTO;
import com.onsiteservice.miniapp.controller.order.dto.ValuationServiceOrderDTO; import com.onsiteservice.miniapp.controller.order.dto.ValuationServiceOrderDTO;
import com.onsiteservice.miniapp.controller.order.vo.ServiceOrderVO; import com.onsiteservice.miniapp.controller.order.vo.ServiceOrderVO;
import com.onsiteservice.miniapp.service.order.ServiceOrderService; import com.onsiteservice.miniapp.service.order.ServiceOrderService;
...@@ -63,8 +64,14 @@ public class ServiceOrderController { ...@@ -63,8 +64,14 @@ public class ServiceOrderController {
@ApiOperation(value = "订单估计") @ApiOperation(value = "订单估计")
@PutMapping("valuation") @PutMapping("valuation")
public Result valuation(@RequestBody @NonNull @Validated ValuationServiceOrderDTO dto) { public Result valuation(@RequestBody @NonNull @Validated ValuationServiceOrderDTO dto, @CurrentUserId Long userId) {
return serviceOrderService.valuation(dto) == 1 ? success() : fail("估价失败"); return serviceOrderService.valuation(dto, userId) == 1 ? success() : fail("估价失败");
}
@ApiOperation(value = "发送订单")
@PutMapping("send")
public Result valuation(@RequestBody @NonNull @Validated SendServiceOrderDTO dto, @CurrentUserId Long userId) {
return serviceOrderService.sendOrder(dto, userId) == 1 ? success() : fail("估价失败");
} }
......
...@@ -4,38 +4,40 @@ import io.swagger.annotations.ApiModel; ...@@ -4,38 +4,40 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import javax.persistence.Column; import javax.validation.constraints.Min;
import javax.persistence.GeneratedValue; import javax.validation.constraints.NotBlank;
import javax.persistence.GenerationType; import javax.validation.constraints.NotNull;
import javax.persistence.Id;
import java.util.Date; import java.util.Date;
@Data @Data
@ApiModel("订单预约请求模型") @ApiModel("订单预约请求模型")
public class SaveServiceOrderDTO { public class SaveServiceOrderDTO {
/**
* 账号 @ApiModelProperty(value = "服务子类id", required = true)
*/ @NotNull(message = "请选择服务类型")
@ApiModelProperty("账号") private Integer subclassId;
private Long accountNo;
/** /**
* 服务地址id * 服务地址id
*/ */
@ApiModelProperty(value = "服务地址id", required = true) @ApiModelProperty(value = "服务地址id", required = true)
@NotNull(message = "请选择服务地址")
private Long addressId; private Long addressId;
/** /**
* 期望上门时间 * 期望上门时间
*/ */
@ApiModelProperty(value = "期望上门时间", required = true) @ApiModelProperty(value = "期望上门时间", required = true)
@NotNull(message = "请选择上门时间")
private Date expectArrivalTime; private Date expectArrivalTime;
/** /**
* 服务数量 * 服务数量
*/ */
@ApiModelProperty(value = "服务数量", required = true) @ApiModelProperty(value = "服务数量", required = true)
@NotNull(message = "请选择服务数量")
@Min(value = 1, message = "服务数量最低为1")
private Integer num; private Integer num;
/** /**
...@@ -54,6 +56,7 @@ public class SaveServiceOrderDTO { ...@@ -54,6 +56,7 @@ public class SaveServiceOrderDTO {
* 是否阅读协议:1已阅读,0未阅读 * 是否阅读协议:1已阅读,0未阅读
*/ */
@ApiModelProperty("是否阅读协议:1已阅读,0未阅读") @ApiModelProperty("是否阅读协议:1已阅读,0未阅读")
private Integer readAgreement; @NotNull(message = "请确认是否阅读协议")
private Boolean readAgreement;
} }
\ No newline at end of file
package com.onsiteservice.miniapp.controller.order.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
/**
* <P></P>
*
* @author 李宁
* @version v1.0
* @since 2022/7/7 15:20
*/
@Data
@ApiModel("发送订单请求模型")
public class SendServiceOrderDTO {
@ApiModelProperty(value = "订单id", required = true)
@NotNull(message = "请选择订单")
private Long id;
}
...@@ -7,6 +7,7 @@ import lombok.extern.log4j.Log4j2; ...@@ -7,6 +7,7 @@ import lombok.extern.log4j.Log4j2;
import org.checkerframework.checker.units.qual.A; import org.checkerframework.checker.units.qual.A;
import javax.validation.constraints.Min; import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal; import java.math.BigDecimal;
/** /**
...@@ -21,10 +22,12 @@ import java.math.BigDecimal; ...@@ -21,10 +22,12 @@ import java.math.BigDecimal;
public class ValuationServiceOrderDTO { public class ValuationServiceOrderDTO {
@ApiModelProperty(value = "订单id", required = true) @ApiModelProperty(value = "订单id", required = true)
@NotNull(message = "请输入订单ID")
private Long id; private Long id;
@ApiModelProperty(value = "订单价格,维修价格不能低于1元", required = true) @ApiModelProperty(value = "订单价格,维修价格不能低于1元", required = true)
@Min(value = 1, message = "维修价格不能低于1元") @Min(value = 1, message = "维修价格不能低于1元")
@NotNull(message = "请输入维修价格")
private BigDecimal price; private BigDecimal price;
} }
...@@ -3,7 +3,6 @@ package com.onsiteservice.miniapp.service.address; ...@@ -3,7 +3,6 @@ package com.onsiteservice.miniapp.service.address;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.onsiteservice.constant.constant.BizConstants; import com.onsiteservice.constant.constant.BizConstants;
import com.onsiteservice.constant.enums.BizCodeEnum; import com.onsiteservice.constant.enums.BizCodeEnum;
import com.onsiteservice.constant.enums.ServiceAddressStatusEnum;
import com.onsiteservice.core.exception.ServiceException; import com.onsiteservice.core.exception.ServiceException;
import com.onsiteservice.core.result.Result; import com.onsiteservice.core.result.Result;
import com.onsiteservice.core.result.ResultGenerator; import com.onsiteservice.core.result.ResultGenerator;
...@@ -18,6 +17,7 @@ import com.onsiteservice.miniapp.controller.address.dto.UpdateServiceAddressDTO; ...@@ -18,6 +17,7 @@ import com.onsiteservice.miniapp.controller.address.dto.UpdateServiceAddressDTO;
import com.onsiteservice.miniapp.controller.address.vo.ServiceAddressVO; import com.onsiteservice.miniapp.controller.address.vo.ServiceAddressVO;
import com.onsiteservice.miniapp.mapper.address.ServiceAddressBizMapper; import com.onsiteservice.miniapp.mapper.address.ServiceAddressBizMapper;
import com.onsiteservice.util.AttrCopyUtils; import com.onsiteservice.util.AttrCopyUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
...@@ -29,6 +29,7 @@ import java.util.Objects; ...@@ -29,6 +29,7 @@ import java.util.Objects;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Service @Service
@Slf4j
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public class ServiceAddressService extends AbstractMapper<ServiceAddress> { public class ServiceAddressService extends AbstractMapper<ServiceAddress> {
...@@ -43,15 +44,19 @@ public class ServiceAddressService extends AbstractMapper<ServiceAddress> { ...@@ -43,15 +44,19 @@ public class ServiceAddressService extends AbstractMapper<ServiceAddress> {
/** /**
* 分页查询列表 * 分页查询列表
*/ */
public Result<PageInfoVO<ServiceAddressVO>> getPage(PageServiceAddressDTO dto, Long uid) { public Result<PageInfoVO<ServiceAddressVO>> getPage(PageServiceAddressDTO dto, Long userId) {
log.info("address getPage dto: {}, uid: {}", dto, userId);
PageHelper.startPage(dto.getPage(), dto.getSize()); PageHelper.startPage(dto.getPage(), dto.getSize());
List<ServiceAddress> serviceAddressList = serviceAddressBizMapper.selectServiceAddressPage(dto, uid); List<ServiceAddress> serviceAddressList = serviceAddressBizMapper.selectServiceAddressPage(dto, userId);
List<ServiceAddressVO> serviceAddressVOList = serviceAddressList.parallelStream().map(e -> AttrCopyUtils.copy(e, new ServiceAddressVO())).collect(Collectors.toList()); List<ServiceAddressVO> serviceAddressVOList = serviceAddressList.parallelStream().map(e -> AttrCopyUtils.copy(e, new ServiceAddressVO())).collect(Collectors.toList());
return ResultGenerator.success(new PageInfoVO<>(serviceAddressVOList)); return ResultGenerator.success(new PageInfoVO<>(serviceAddressVOList));
} }
public ServiceAddressVO selectById(Long id, Long userId) { public ServiceAddressVO selectById(Long id, Long userId) {
log.info("address selectById id: {}, userId: {}", id, userId);
Condition c = new Condition(ServiceAddress.class); Condition c = new Condition(ServiceAddress.class);
c.createCriteria().andEqualTo("id", id).andEqualTo(BizConstants.UserConstants.ACCOUNT_NO, userId); c.createCriteria().andEqualTo("id", id).andEqualTo(BizConstants.UserConstants.ACCOUNT_NO, userId);
...@@ -76,6 +81,8 @@ public class ServiceAddressService extends AbstractMapper<ServiceAddress> { ...@@ -76,6 +81,8 @@ public class ServiceAddressService extends AbstractMapper<ServiceAddress> {
public int save(SaveServiceAddressDTO dto, Long userId) { public int save(SaveServiceAddressDTO dto, Long userId) {
log.info("address save dto: {}, userId: {}", dto, userId);
checkServiceArea(dto.getAreaId()); checkServiceArea(dto.getAreaId());
ServiceAddress serviceAddress = AttrCopyUtils.copy(dto, new ServiceAddress()); ServiceAddress serviceAddress = AttrCopyUtils.copy(dto, new ServiceAddress());
...@@ -88,6 +95,8 @@ public class ServiceAddressService extends AbstractMapper<ServiceAddress> { ...@@ -88,6 +95,8 @@ public class ServiceAddressService extends AbstractMapper<ServiceAddress> {
public int update(UpdateServiceAddressDTO dto, Long userId) { public int update(UpdateServiceAddressDTO dto, Long userId) {
log.info("address update dto: {}, userId: {}", dto, userId);
checkServiceArea(dto.getAreaId()); checkServiceArea(dto.getAreaId());
ServiceAddress serviceAddress = AttrCopyUtils.copy(dto, new ServiceAddress()); ServiceAddress serviceAddress = AttrCopyUtils.copy(dto, new ServiceAddress());
...@@ -101,6 +110,8 @@ public class ServiceAddressService extends AbstractMapper<ServiceAddress> { ...@@ -101,6 +110,8 @@ public class ServiceAddressService extends AbstractMapper<ServiceAddress> {
public int delete(Long id, Long userId) { public int delete(Long id, Long userId) {
log.info("address delete id: {}, userId: {}", id, userId);
Condition c = new Condition(ServiceAddress.class); Condition c = new Condition(ServiceAddress.class);
// 删除条件里加上账户号防越权攻击 // 删除条件里加上账户号防越权攻击
c.createCriteria().andEqualTo("id", id).andEqualTo(BizConstants.UserConstants.ACCOUNT_NO, userId); c.createCriteria().andEqualTo("id", id).andEqualTo(BizConstants.UserConstants.ACCOUNT_NO, userId);
...@@ -128,14 +139,14 @@ public class ServiceAddressService extends AbstractMapper<ServiceAddress> { ...@@ -128,14 +139,14 @@ public class ServiceAddressService extends AbstractMapper<ServiceAddress> {
* @param userId 用户id * @param userId 用户id
*/ */
private void checkAndCancelDefaultServiceAddress(ServiceAddress serviceAddress, Long userId) { private void checkAndCancelDefaultServiceAddress(ServiceAddress serviceAddress, Long userId) {
if (serviceAddress.getDef() == ServiceAddressStatusEnum.DEFAULT_STATUS.getStatus()) { if (serviceAddress.getDef()) {
Condition c = new Condition(ServiceAddress.class); Condition c = new Condition(ServiceAddress.class);
c.createCriteria().andEqualTo(BizConstants.UserConstants.ACCOUNT_NO, userId) c.createCriteria().andEqualTo(BizConstants.UserConstants.ACCOUNT_NO, userId)
.andEqualTo("def", ServiceAddressStatusEnum.DEFAULT_STATUS.getStatus()); .andEqualTo("def", true);
List<ServiceAddress> defaultServiceAddressList = this.selectByCondition(c); List<ServiceAddress> defaultServiceAddressList = this.selectByCondition(c);
if (!CollectionUtils.isEmpty(defaultServiceAddressList)) { if (!CollectionUtils.isEmpty(defaultServiceAddressList)) {
defaultServiceAddressList.forEach(defaultServiceAddress -> { defaultServiceAddressList.forEach(defaultServiceAddress -> {
defaultServiceAddress.setDef(ServiceAddressStatusEnum.COMMON_STATUS.getStatus()); defaultServiceAddress.setDef(false);
this.updateByPrimaryKeySelective(defaultServiceAddress); this.updateByPrimaryKeySelective(defaultServiceAddress);
}); });
} }
......
...@@ -3,15 +3,23 @@ package com.onsiteservice.miniapp.service.order; ...@@ -3,15 +3,23 @@ package com.onsiteservice.miniapp.service.order;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.onsiteservice.constant.constant.BizConstants; import com.onsiteservice.constant.constant.BizConstants;
import com.onsiteservice.constant.enums.BizCodeEnum; import com.onsiteservice.constant.enums.BizCodeEnum;
import com.onsiteservice.constant.enums.ServiceOrderStatusEnum;
import com.onsiteservice.core.exception.ServiceException; import com.onsiteservice.core.exception.ServiceException;
import com.onsiteservice.core.result.Result; import com.onsiteservice.core.result.Result;
import com.onsiteservice.core.result.ResultGenerator; import com.onsiteservice.core.result.ResultGenerator;
import com.onsiteservice.dao.common.AbstractMapper; import com.onsiteservice.dao.common.AbstractMapper;
import com.onsiteservice.dao.common.page.PageInfoVO; import com.onsiteservice.dao.common.page.PageInfoVO;
import com.onsiteservice.dao.mapper.service.ServiceAddressMapper;
import com.onsiteservice.dao.mapper.service.ServiceSubclassMapper;
import com.onsiteservice.dao.mapper.user.UserMapper;
import com.onsiteservice.entity.address.ServiceAddress;
import com.onsiteservice.entity.category.ServiceSubclass;
import com.onsiteservice.entity.order.ServiceOrder; import com.onsiteservice.entity.order.ServiceOrder;
import com.onsiteservice.entity.user.User;
import com.onsiteservice.miniapp.controller.address.vo.ServiceAddressVO; import com.onsiteservice.miniapp.controller.address.vo.ServiceAddressVO;
import com.onsiteservice.miniapp.controller.order.dto.PageServiceOrderDTO; import com.onsiteservice.miniapp.controller.order.dto.PageServiceOrderDTO;
import com.onsiteservice.miniapp.controller.order.dto.SaveServiceOrderDTO; import com.onsiteservice.miniapp.controller.order.dto.SaveServiceOrderDTO;
import com.onsiteservice.miniapp.controller.order.dto.SendServiceOrderDTO;
import com.onsiteservice.miniapp.controller.order.dto.ValuationServiceOrderDTO; import com.onsiteservice.miniapp.controller.order.dto.ValuationServiceOrderDTO;
import com.onsiteservice.miniapp.controller.order.vo.ServiceOrderVO; import com.onsiteservice.miniapp.controller.order.vo.ServiceOrderVO;
import com.onsiteservice.miniapp.mapper.order.ServiceOrderBizMapper; import com.onsiteservice.miniapp.mapper.order.ServiceOrderBizMapper;
...@@ -40,6 +48,15 @@ public class ServiceOrderService extends AbstractMapper<ServiceOrder> { ...@@ -40,6 +48,15 @@ public class ServiceOrderService extends AbstractMapper<ServiceOrder> {
@Resource @Resource
private ServiceAddressService serviceAddressService; private ServiceAddressService serviceAddressService;
@Resource
private ServiceAddressMapper serviceAddressMapper;
@Resource
private ServiceSubclassMapper serviceSubclassMapper;
@Resource
private UserMapper userMapper;
public ServiceOrderVO selectById(Long id, Long userId) { public ServiceOrderVO selectById(Long id, Long userId) {
// 订单信息 // 订单信息
...@@ -77,29 +94,64 @@ public class ServiceOrderService extends AbstractMapper<ServiceOrder> { ...@@ -77,29 +94,64 @@ public class ServiceOrderService extends AbstractMapper<ServiceOrder> {
} }
public int save(SaveServiceOrderDTO dto, Long uid) { public int save(SaveServiceOrderDTO dto, Long userId) {
log.info("order save dto: {}, userId: {}", dto, userId);
ServiceSubclass serviceSubclass = serviceSubclassMapper.selectByPrimaryKey(dto.getSubclassId());
if (Objects.isNull(serviceSubclass)) {
throw new ServiceException(BizCodeEnum.SERVICE_SUBCLASS_NOT_EXIST);
}
ServiceAddress serviceAddress = serviceAddressMapper.selectByPrimaryKey(dto.getAddressId());
if (Objects.isNull(serviceAddress)) {
throw new ServiceException(BizCodeEnum.SERVICE_ADDRESS_NOT_EXIST);
}
ServiceOrder serviceOrder = AttrCopyUtils.copy(dto, new ServiceOrder()); ServiceOrder serviceOrder = AttrCopyUtils.copy(dto, new ServiceOrder());
// 账户号 // 账户号
serviceOrder.setAccountNo(uid); serviceOrder.setAccountNo(userId);
// 订单号 // 订单号
serviceOrder.setOrderNo(RandomUtils.orderNum()); serviceOrder.setOrderNo(RandomUtils.orderNum());
return this.insertSelective(serviceOrder); return this.insertSelective(serviceOrder);
} }
public int valuation(ValuationServiceOrderDTO dto) { public int valuation(ValuationServiceOrderDTO dto, Long userId) {
ServiceOrder serviceOrder = this.selectByPrimaryKey(dto.getId()); log.info("order valuation dto: {}, userId: {}", dto, userId);
Condition c = new Condition(ServiceOrder.class);
c.createCriteria().andEqualTo("id", dto.getId()).andEqualTo(BizConstants.UserConstants.ACCOUNT_NO, userId);
List<ServiceOrder> serviceOrderList = this.selectByCondition(c);
// 找不到订单 // 找不到订单
if (Objects.isNull(serviceOrder)) { if (CollectionUtils.isEmpty(serviceOrderList)) {
throw new ServiceException(BizCodeEnum.SERVICE_ORDER_NOT_EXIST); throw new ServiceException(BizCodeEnum.SERVICE_ORDER_NOT_EXIST);
} }
ServiceOrder serviceOrder = serviceOrderList.get(0);
// 估价价格 // 估价价格
serviceOrder.setPrice(dto.getPrice()); serviceOrder.setPrice(dto.getPrice());
// TODO 置为以估价状态 serviceOrder.setOrderStatus(ServiceOrderStatusEnum.ACCEPT.getStatus());
// serviceOrder.setOrderStatus();
return this.updateByPrimaryKeySelective(serviceOrder);
}
public int sendOrder(SendServiceOrderDTO dto, Long userId) {
User user = userMapper.selectByPrimaryKey(userId);
return this.updateByPrimaryKey(serviceOrder); /**
* 判断发送者权限
* 判断能发送的状态
* 发短信
* 小程序通知
*
*/
return 1;
} }
......
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