Commit 68132d17 by 杨浩

配送端

parent 3f4e305f
......@@ -2,6 +2,9 @@ package cn.iocoder.foodnexus.module.operations.controller.admin.deliverystaff;
import cn.iocoder.foodnexus.module.operations.service.deliverystaffcustomer.DeliveryStaffCustomerService;
import cn.iocoder.foodnexus.module.operations.service.vehicleinfo.VehicleInfoService;
import cn.iocoder.foodnexus.module.system.dal.dataobject.user.AdminUserDO;
import cn.iocoder.foodnexus.module.system.service.user.AdminUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
......@@ -46,6 +49,9 @@ public class DeliveryStaffController {
@Resource
private VehicleInfoService vehicleInfoService;
@Autowired
private AdminUserService userService;
@PostMapping("/create")
@Operation(summary = "创建配送员信息")
@PreAuthorize("@ss.hasPermission('operation:delivery-staff:create')")
......@@ -122,6 +128,7 @@ public class DeliveryStaffController {
item.setCustomerList(deliveryStaffCustomerService.queryCustomerListByDeliveryStaffId(item.getId()));
item.setVehicleInfo(vehicleInfoService.queryByStaffId(item.getId()));
item.setCustomerDeptList(deliveryStaffCustomerService.queryDeptListByStaffId(item.getId()));
item.setUserName(Optional.ofNullable(userService.getUser(item.getUserId())).map(AdminUserDO::getUsername).orElse(""));
}));
}
......@@ -130,7 +137,9 @@ public class DeliveryStaffController {
@PreAuthorize("@ss.hasPermission('operation:delivery-staff:query')")
public CommonResult<PageResult<DeliveryStaffRespVO>> getDeliveryStaffPage(@Valid DeliveryStaffPageReqVO pageReqVO) {
PageResult<DeliveryStaffDO> pageResult = deliveryStaffService.getDeliveryStaffPage(pageReqVO);
return success(BeanUtils.toBean(pageResult, DeliveryStaffRespVO.class));
return success(BeanUtils.toBean(pageResult, DeliveryStaffRespVO.class, item -> {
item.setUserName(Optional.ofNullable(userService.getUser(item.getUserId())).map(AdminUserDO::getUsername).orElse(""));
}));
}
@GetMapping("/export-excel")
......
......@@ -80,6 +80,11 @@ public class DeliveryStaffRespVO {
@ExcelProperty("创建时间")
private LocalDateTime createTime;
@Schema(description = "关联系统用户id")
private Long userId;
@Schema(description = "关联系统用户名")
private String userName;
@Schema(description = "绑定车辆信息")
private VehicleInfoRespVO vehicleInfo;
......
......@@ -16,6 +16,7 @@ public interface ErrorCodeConstants {
// ========== 配送员信息 1_008_011_000 ==========
ErrorCode DELIVERY_STAFF_NOT_EXISTS = new ErrorCode(1_008_011_000, "配送员信息不存在");
ErrorCode DELIVERY_STAFF_ID_NUMBER_EXISTS = new ErrorCode(1_008_011_001, "身份证号已存在");
// ========== 配送员客户绑定 1_008_012_000 ==========
ErrorCode DELIVERY_STAFF_CUSTOMER_NOT_EXISTS = new ErrorCode(1_008_012_000, "配送员客户绑定不存在");
......
......@@ -56,6 +56,7 @@ public class DeliveryStaffServiceImpl implements DeliveryStaffService, DeliveryS
@Override
@Transactional(rollbackFor = Exception.class)
public Long createDeliveryStaff(DeliveryStaffSaveReqVO createReqVO) {
validStaff(createReqVO);
// 插入
DeliveryStaffDO deliveryStaff = BeanUtils.toBean(createReqVO, DeliveryStaffDO.class);
String userName = validStaffName(createReqVO.getName(), 1);
......@@ -82,6 +83,14 @@ public class DeliveryStaffServiceImpl implements DeliveryStaffService, DeliveryS
return deliveryStaff.getId();
}
private void validStaff(DeliveryStaffSaveReqVO createReqVO) {
if (deliveryStaffMapper.exists(Wrappers.<DeliveryStaffDO>lambdaQuery()
.eq(DeliveryStaffDO::getIdNumber, createReqVO.getIdNumber()))) {
throw exception(DELIVERY_STAFF_ID_NUMBER_EXISTS);
}
}
private String validStaffName(String name, int suffix) {
AdminUserDO user = userService.getUserByUsername(name);
if (CommonUtil.isNotEmpty(user)) {
......
......@@ -98,7 +98,6 @@ public class DeliverySaleOrderController {
@Operation(summary = "接单大厅 - 查询配送单")
@Parameter(name = "type", description = "0-待接单 1-待配送 2-配送中", required = true, example = "1024")
public CommonResult<PageResult<DeliverySaleOrderRespVO>> getSaleOrderPage(@Valid PageParam pageReq,
@InEnum(value = SaleOrderPickUpStatus.class)
@RequestParam("type")
Integer type) {
ErpSaleOrderPageReqVO pageReqVO = new ErpSaleOrderPageReqVO();
......
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