订单状态修改,批量新增修改
This commit is contained in:
		
							parent
							
								
									a5d0b758c7
								
							
						
					
					
						commit
						1e0f75f42b
					
				| 
						 | 
				
			
			@ -7,6 +7,8 @@ import lombok.Data;
 | 
			
		|||
import lombok.ToString;
 | 
			
		||||
import lombok.experimental.Accessors;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 附件
 | 
			
		||||
对象 bm_file_info
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -12,11 +12,16 @@ public enum OrderStatusEnum {
 | 
			
		|||
 | 
			
		||||
    NO_ORDER_PLACED(0, "未下单"),
 | 
			
		||||
    TO_ORDER_PLACED(1, "已下单"),
 | 
			
		||||
    ORDER_PENDING_SHIPMENT(2, "待出库"),
 | 
			
		||||
    ORDER_AWAITING_RECEIPT(3, "待收货"),
 | 
			
		||||
    ORDER_UNDER_LEASE(4, "租赁中"),
 | 
			
		||||
    ORDER_TERMINATED(5, "已退租"),
 | 
			
		||||
    ORDER_FINISHED(6, "已完成");
 | 
			
		||||
    ORDER_RECEIVE(2, "已接单"),
 | 
			
		||||
    ORDER_PENDING_SHIPMENT(3, "待出库"),
 | 
			
		||||
    ORDER_AWAITING_RECEIPT(4, "待收货"),
 | 
			
		||||
    ORDER_UNDER_LEASE(5, "租赁中"),
 | 
			
		||||
    ORDER_TERMINATED(6, "已退租"),
 | 
			
		||||
    ORDER_SETTLEMENT(7, "已结算"),
 | 
			
		||||
    ORDER_FINISHED(8, "已完成"),
 | 
			
		||||
    ORDER_CANCEL(9, "已取消");
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    private final Integer status;
 | 
			
		||||
    private final String statusName;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -55,8 +55,6 @@ public class DevInfo extends BaseEntity {
 | 
			
		|||
 | 
			
		||||
    @Excel(name = "设备数量")
 | 
			
		||||
    @ApiModelProperty(value = "设备数量")
 | 
			
		||||
    @NotNull(message = "设备数量不能为空")
 | 
			
		||||
    @Min(value = 1, message = "设备数量不能小于1")
 | 
			
		||||
    private Integer deviceCount;
 | 
			
		||||
 | 
			
		||||
    @ApiModelProperty(value = "单位")
 | 
			
		||||
| 
						 | 
				
			
			@ -216,10 +214,16 @@ public class DevInfo extends BaseEntity {
 | 
			
		|||
 | 
			
		||||
    @ApiModelProperty(value = "检测证明、检验pdf")
 | 
			
		||||
    @NotEmpty(message = "检测证明、检验pdf不能为空")
 | 
			
		||||
    private List<List<BmFileInfo>> examinationPdfs = new ArrayList<>();
 | 
			
		||||
 | 
			
		||||
    @ApiModelProperty(value = "检测证明、检验pdf")
 | 
			
		||||
    private List<BmFileInfo> examinationPdf = new ArrayList<>();
 | 
			
		||||
 | 
			
		||||
    @ApiModelProperty(value = "合格证、保险pdf")
 | 
			
		||||
    @NotEmpty(message = "合格证、保险pdf不能为空")
 | 
			
		||||
    private List<List<BmFileInfo>> insurancePdfs = new ArrayList<>();
 | 
			
		||||
 | 
			
		||||
    @ApiModelProperty(value = "合格证、保险pdf")
 | 
			
		||||
    private List<BmFileInfo> insurancePdf = new ArrayList<>();
 | 
			
		||||
 | 
			
		||||
    /**文件附件*/
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -319,24 +319,27 @@ public class DevInfoServiceImpl implements DevInfoService {
 | 
			
		|||
        if (deviceNameCount != null && deviceNameCount.getMaId() > 0) {
 | 
			
		||||
            return AjaxResult.error("设备名称已存在,请修改后重试!");
 | 
			
		||||
        }*/
 | 
			
		||||
 | 
			
		||||
        //获取用户信息
 | 
			
		||||
        Long userId = SecurityUtils.getLoginUser().getUserid();
 | 
			
		||||
        //保存用户信息
 | 
			
		||||
        devInfo.setCreator(userId).setMaStatus(ON_HIRE.getCode()).setOwnId(userId);
 | 
			
		||||
        if (org.apache.commons.lang3.StringUtils.isBlank(code)) {
 | 
			
		||||
            code = getString();
 | 
			
		||||
        }
 | 
			
		||||
        devInfo.setCode(code);
 | 
			
		||||
        devInfo.setCompanyId(SecurityUtils.getLoginUser().getSysUser().getCompanyId().toString());
 | 
			
		||||
        int saveSuccessNum = devInfoMapper.insertDevInfo(devInfo);
 | 
			
		||||
        if (saveSuccessNum == 0) {
 | 
			
		||||
            return AjaxResult.error("设备信息SQL保存失败,请修改后重试");
 | 
			
		||||
        }
 | 
			
		||||
        //把文件保存到附件中
 | 
			
		||||
        AjaxResult error = uploadFiles(devInfo, userId);
 | 
			
		||||
        if (error != null) {
 | 
			
		||||
            return error;
 | 
			
		||||
        for (int i = 0; i < devInfo.getExaminationPdfs().size(); i++) {
 | 
			
		||||
            //获取用户信息
 | 
			
		||||
            Long userId = SecurityUtils.getLoginUser().getUserid();
 | 
			
		||||
            //保存用户信息
 | 
			
		||||
            devInfo.setCreator(userId).setMaStatus(ON_HIRE.getCode()).setOwnId(userId);
 | 
			
		||||
            if (org.apache.commons.lang3.StringUtils.isBlank(code)) {
 | 
			
		||||
                code = getString();
 | 
			
		||||
            }
 | 
			
		||||
            devInfo.setCode(code);
 | 
			
		||||
            devInfo.setCompanyId(SecurityUtils.getLoginUser().getSysUser().getCompanyId().toString());
 | 
			
		||||
            devInfo.setDeviceCount(1);
 | 
			
		||||
            int saveSuccessNum = devInfoMapper.insertDevInfo(devInfo);
 | 
			
		||||
            code = "";
 | 
			
		||||
            if (saveSuccessNum == 0) {
 | 
			
		||||
                return AjaxResult.error("设备信息SQL保存失败,请修改后重试");
 | 
			
		||||
            }
 | 
			
		||||
            //把文件保存到附件中
 | 
			
		||||
            AjaxResult error = uploadFiles(devInfo, userId, i);
 | 
			
		||||
            if (error != null) {
 | 
			
		||||
                return error;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        return AjaxResult.success("保存成功");
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			@ -357,15 +360,18 @@ public class DevInfoServiceImpl implements DevInfoService {
 | 
			
		|||
            if (devInfo.getMaId() != null) {
 | 
			
		||||
                devInfoMapper.deleteDevInfoByMaId(devInfo.getMaId(), MaStatusEnum.UNDER_RENT.getCode());
 | 
			
		||||
            }
 | 
			
		||||
            String code = getString();
 | 
			
		||||
            devInfo.setCode(code);
 | 
			
		||||
            int insertedDraft = devInfoMapper.insertDraft(devInfo);
 | 
			
		||||
            if (insertedDraft == 0) {
 | 
			
		||||
                return AjaxResult.error("装备草稿保存失败,请修改后重试");
 | 
			
		||||
            }
 | 
			
		||||
            AjaxResult error = uploadFiles(devInfo, userId);
 | 
			
		||||
            if (error != null) {
 | 
			
		||||
                return error;
 | 
			
		||||
            for (int i = 0; i < devInfo.getExaminationPdfs().size(); i++) {
 | 
			
		||||
                String code = getString();
 | 
			
		||||
                devInfo.setCode(code);
 | 
			
		||||
                devInfo.setDeviceCount(1);
 | 
			
		||||
                int insertedDraft = devInfoMapper.insertDraft(devInfo);
 | 
			
		||||
                if (insertedDraft == 0) {
 | 
			
		||||
                    return AjaxResult.error("装备草稿保存失败,请修改后重试");
 | 
			
		||||
                }
 | 
			
		||||
                AjaxResult error = uploadFiles(devInfo, userId, i);
 | 
			
		||||
                if (error != null) {
 | 
			
		||||
                    return error;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        } catch (Exception e) {
 | 
			
		||||
            return AjaxResult.error("装备草稿保存失败,执行异常:" + e.getMessage());
 | 
			
		||||
| 
						 | 
				
			
			@ -380,7 +386,7 @@ public class DevInfoServiceImpl implements DevInfoService {
 | 
			
		|||
     * @param userId  用户ID
 | 
			
		||||
     * @return 无异常返回null ,报错返回AjaxResult
 | 
			
		||||
     */
 | 
			
		||||
    private AjaxResult uploadFiles(DevInfo devInfo, Long userId) {
 | 
			
		||||
    private AjaxResult uploadFiles(DevInfo devInfo, Long userId, Integer i) {
 | 
			
		||||
        if (userId == null) {
 | 
			
		||||
            return AjaxResult.error("用户信息获取失败,请刷新后重试");
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			@ -406,21 +412,21 @@ public class DevInfoServiceImpl implements DevInfoService {
 | 
			
		|||
            });
 | 
			
		||||
            fileInfoList.addAll(devInfo.getDetailsFileList());
 | 
			
		||||
        }
 | 
			
		||||
        if (CollectionUtil.isNotEmpty(devInfo.getInsurancePdf())) {
 | 
			
		||||
            devInfo.getInsurancePdf().removeIf(Objects::isNull);
 | 
			
		||||
            devInfo.getInsurancePdf().forEach(item -> {
 | 
			
		||||
        if (CollectionUtil.isNotEmpty(devInfo.getInsurancePdfs().get(i))) {
 | 
			
		||||
            devInfo.getInsurancePdfs().get(i).removeIf(Objects::isNull);
 | 
			
		||||
            devInfo.getInsurancePdfs().get(i).forEach(item -> {
 | 
			
		||||
                item.setTaskType(MaterialConstants.MATERIAL_FILE_TYPE_CODE);
 | 
			
		||||
                item.setFileType(Long.valueOf(INSURANCE_PDF));
 | 
			
		||||
            });
 | 
			
		||||
            fileInfoList.addAll(devInfo.getInsurancePdf());
 | 
			
		||||
            fileInfoList.addAll(devInfo.getInsurancePdfs().get(i));
 | 
			
		||||
        }
 | 
			
		||||
        if (CollectionUtil.isNotEmpty(devInfo.getExaminationPdf())) {
 | 
			
		||||
            devInfo.getExaminationPdf().removeIf(Objects::isNull);
 | 
			
		||||
            devInfo.getExaminationPdf().forEach(item -> {
 | 
			
		||||
        if (CollectionUtil.isNotEmpty(devInfo.getExaminationPdfs().get(i))) {
 | 
			
		||||
            devInfo.getExaminationPdfs().get(i).removeIf(Objects::isNull);
 | 
			
		||||
            devInfo.getExaminationPdfs().get(i).forEach(item -> {
 | 
			
		||||
                item.setTaskType(MaterialConstants.MATERIAL_FILE_TYPE_CODE);
 | 
			
		||||
                item.setFileType(Long.valueOf(EXAMINATION_PDF));
 | 
			
		||||
            });
 | 
			
		||||
            fileInfoList.addAll(devInfo.getExaminationPdf());
 | 
			
		||||
            fileInfoList.addAll(devInfo.getExaminationPdfs().get(i));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // 上传处理后的附件列表
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,6 @@
 | 
			
		|||
package com.bonus.material.order.controller;
 | 
			
		||||
 | 
			
		||||
import com.bonus.common.biz.enums.OrderStatusEnum;
 | 
			
		||||
import com.bonus.common.core.web.controller.BaseController;
 | 
			
		||||
import com.bonus.common.core.web.domain.AjaxResult;
 | 
			
		||||
import com.bonus.common.core.web.page.TableDataInfo;
 | 
			
		||||
| 
						 | 
				
			
			@ -98,18 +99,18 @@ public class OrderController extends BaseController {
 | 
			
		|||
            }
 | 
			
		||||
        }*/
 | 
			
		||||
        // 取消
 | 
			
		||||
        if (orderInfoDto.getOrderStatus().equals("7")) {
 | 
			
		||||
        if (orderInfoDto.getOrderStatus().equals(OrderStatusEnum.ORDER_CANCEL.getStatus())) {
 | 
			
		||||
            List<OrderDetailDto> dtos = orderMapper.getOrderDetailsByOrderId(orderInfoDto.getOrderId());
 | 
			
		||||
            if (dtos.size() > 0) {
 | 
			
		||||
                for (OrderDetailDto dto : dtos) {
 | 
			
		||||
                    if ("0".equals(dto.getManageType())) {
 | 
			
		||||
//                    if ("0".equals(dto.getManageType())) {
 | 
			
		||||
                        // 编码设备已取消的继续上架
 | 
			
		||||
                        dto.setMaStatus("2");
 | 
			
		||||
                        orderMapper.updateDeviceStatus(dto);
 | 
			
		||||
                    } else {
 | 
			
		||||
                   /* } else {
 | 
			
		||||
                        // 数量设备已退租的增加库存
 | 
			
		||||
                        orderMapper.updateAddDevCount(dto);
 | 
			
		||||
                    }
 | 
			
		||||
                    }*/
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -38,7 +38,7 @@ public class OrderServiceImpl implements OrderService {
 | 
			
		|||
            List<OrderDetailDto> orderDetailDtos = orderInfoDto.getDetailsList();
 | 
			
		||||
            for (OrderDetailDto orderDetailDto : orderDetailDtos) {
 | 
			
		||||
                // 如果是数量设备 ,改库存
 | 
			
		||||
                if ("1".equals(orderDetailDto.getManageType())) {
 | 
			
		||||
             /*   if ("1".equals(orderDetailDto.getManageType())) {
 | 
			
		||||
                    // 再查询库存是否足够
 | 
			
		||||
                    DevInfo devInfo = orderMapper.getdeviceCount(orderDetailDto);
 | 
			
		||||
                    if (devInfo.getDeviceCount() == 0) {
 | 
			
		||||
| 
						 | 
				
			
			@ -52,11 +52,11 @@ public class OrderServiceImpl implements OrderService {
 | 
			
		|||
                        // 改库存
 | 
			
		||||
                        orderMapper.updateDevCount(orderDetailDto);
 | 
			
		||||
                    }
 | 
			
		||||
                } else {
 | 
			
		||||
                } else {*/
 | 
			
		||||
                    //如果是编码设备,改设备状态为在租
 | 
			
		||||
                    orderDetailDto.setMaStatus(MaStatusEnum.UNDER_RENT.getCode().toString());
 | 
			
		||||
                    orderMapper.updateDeviceStatus(orderDetailDto);
 | 
			
		||||
                }
 | 
			
		||||
//                }
 | 
			
		||||
                // 更改购物车状态为已下单
 | 
			
		||||
                orderMapper.updateMaStatus(orderDetailDto);
 | 
			
		||||
            }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -29,7 +29,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 | 
			
		|||
             #{days},
 | 
			
		||||
             #{num},
 | 
			
		||||
             #{costs},
 | 
			
		||||
             2,
 | 
			
		||||
             1,
 | 
			
		||||
             now(),
 | 
			
		||||
             #{updateTime})
 | 
			
		||||
    </insert>
 | 
			
		||||
| 
						 | 
				
			
			@ -41,6 +41,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 | 
			
		|||
    </update>
 | 
			
		||||
    <update id="updateOrderStatus">
 | 
			
		||||
        update ma_order_details set order_status = #{orderStatus}
 | 
			
		||||
        <if test="orderStatus == 2">
 | 
			
		||||
            ,receiving_user = #{userName}
 | 
			
		||||
            ,receiving_time = now()
 | 
			
		||||
        </if>
 | 
			
		||||
        <if test="orderStatus == 3">
 | 
			
		||||
            ,pre_outbound_user = #{userName}
 | 
			
		||||
            ,pre_outbound_time = now()
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue