订单处理

This commit is contained in:
syruan 2025-10-14 17:22:50 +08:00
parent 1784825d15
commit aa8e5f5d6d
12 changed files with 182 additions and 106 deletions

View File

@ -27,8 +27,8 @@ public enum MaStatusEnum {
/**
* 根据code获取name
* @param code
* @return
* @param code 枚举编码
* @return 枚举值
*/
public static String getNameByCode(int code) {
MaStatusEnum[] maStatusEnums = values();

View File

@ -19,16 +19,17 @@ import javax.annotation.Resource;
import java.util.List;
/**
* @Authorliang.chao
* @Date2024/12/18 - 11:14
* @author liang.chao
* 综合查询
*/
@Api(tags = "综合查询")
@RestController
@RequestMapping("/comprehensive")
public class ComprehensiveController extends BaseController {
@Resource
private DevInfoService devInfoService;
@Resource
private OrderService orderService;
@ -43,9 +44,6 @@ public class ComprehensiveController extends BaseController {
/**
* 在租装备信息查询
*
* @param devInfo
* @return
*/
@ApiOperation(value = "综合查询-在租装备信息查询")
@GetMapping("/getLeaseDevList")
@ -74,10 +72,15 @@ public class ComprehensiveController extends BaseController {
return AjaxResult.success(ListPagingUtil.paging(pageIndex, pageSize, list));
}
@ApiOperation(value = "订单确认")
@ApiOperation(value = "订单确认--同意")
@PostMapping("/orderConfirm/{orderId}")
public AjaxResult orderConfirm(@PathVariable String orderId) {
return orderService.orderConfirm(orderId);
}
@ApiOperation(value = "订单确认--驳回")
@PostMapping("/orderReject/{orderId}")
public AjaxResult orderReject(@PathVariable String orderId) {
return orderService.orderReject(orderId);
}
}

View File

@ -12,28 +12,24 @@ import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;
import javax.annotation.Resource;
import java.io.UnsupportedEncodingException;
import java.util.List;
/**
* 设备台账-总览表
*
* @author xxxxx
* @author bonus
*/
@RestController
@RequestMapping("/device")
public class MaDevInfoController extends BaseController {
/**
* 服务对象
*/
@Autowired
@Resource
private MaDevInfoService service;
/**
* cha
*
* @param o
* @return
* 设备台账
*/
@ApiOperation(value = "设备台账")
@GetMapping("/list")
@ -48,34 +44,24 @@ public class MaDevInfoController extends BaseController {
}
}
@ApiOperation(value = "设备台账-上下架")
@PostMapping("/updateDeviceStatus")
public AjaxResult updateDeviceStatus(@RequestBody DevMergeVo o) {
try {
Integer i = service.updateDeviceStatus(o);
if (i > 0) {
return AjaxResult.success("修改成功");
} else {
return AjaxResult.error("修改失败");
}
return i > 0 ? AjaxResult.success("修改成功") : AjaxResult.error("修改失败");
} catch (Exception e) {
logger.error("报错啦", e);
return AjaxResult.error("调用异常,请联系管理员");
}
}
@ApiOperation(value = "设备台账-修改")
@PostMapping("/updateDeviceApi")
public AjaxResult updateDeviceApi(@RequestBody MaDevInfo o) {
try {
Integer i = service.updateDeviceApi(o);
if (i > 0) {
return AjaxResult.success("修改成功");
} else {
return AjaxResult.error("修改失败");
}
return i > 0 ? AjaxResult.success("修改成功") : AjaxResult.error("修改失败");
} catch (Exception e) {
logger.error("报错啦", e);
return AjaxResult.error("调用异常,请联系管理员");
@ -93,18 +79,13 @@ public class MaDevInfoController extends BaseController {
public AjaxResult delDevice(@PathVariable("ids") String[] ids) {
try {
Integer i = service.delDevice(ids);
if (i > 0) {
return AjaxResult.success("修改成功");
} else {
return AjaxResult.error("修改失败");
}
return i > 0 ? AjaxResult.success("修改成功"): AjaxResult.error("修改失败");
} catch (Exception e) {
logger.error("报错啦", e);
return AjaxResult.error("调用异常,请联系管理员");
}
}
@ApiOperation(value = "设备类型树")
@PostMapping("/deviceTree")
public AjaxResult deviceTree(String id) {

View File

@ -29,6 +29,7 @@ public interface BmFileInfoMapper {
* @return 附件集合
*/
List<BmFileInfo> selectBmFileInfoList(BmFileInfo bmFileInfo);
List<BmFileInfo> selectBmFileInfo(BmFileInfo bmFileInfo);
/**

View File

@ -94,8 +94,6 @@ public interface DevInfoService {
/**
* 查询企业列表
* @param obj
* @return
*/
List<BmCompanyInfo> selectCompanyList(BmCompanyInfo obj);
@ -113,28 +111,21 @@ public interface DevInfoService {
/**
* 在租装备信息查询
* @param devInfo
* @return
*/
List<DevInfoVo> getLeaseDevList(DevInfoVo devInfo);
/**
* 设备批量导入模版下载
* @param resp
*/
void downLoadDev(HttpServletResponse resp);
/**
* 设备信息导入
* @param file
* @return
*/
AjaxResult importTbPeople(MultipartFile file);
/**
* 设备信息审核列表
* @param devInfo
* @return
*/
List<DevInfoVo> selectCheckDevInfoList(DevInfoVo devInfo);

View File

@ -1,21 +1,17 @@
package com.bonus.material.device.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.BooleanUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.PhoneUtil;
import com.alibaba.druid.sql.visitor.functions.If;
import com.bonus.common.biz.constant.MaterialConstants;
import com.bonus.common.biz.domain.*;
import com.bonus.common.biz.enums.HttpCodeEnum;
import com.bonus.common.biz.enums.MaStatusEnum;
import com.bonus.common.biz.exception.BusinessException;
import com.bonus.material.utils.CacheHelper;
import com.bonus.common.core.exception.ServiceException;
import com.bonus.common.core.utils.DateUtils;
import com.bonus.common.core.utils.StringUtils;
import com.bonus.common.core.utils.bean.BeanUtils;
import com.bonus.common.core.utils.bean.BeanValidators;
import com.bonus.common.core.utils.encryption.Sm4Utils;
import com.bonus.common.core.utils.poi.ExcelUtil;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.common.security.utils.SecurityUtils;
@ -40,6 +36,8 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.IOUtils;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -49,11 +47,11 @@ import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Validator;
import javax.validation.constraints.NotEmpty;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.text.SimpleDateFormat;
import java.time.Duration;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeFormatterBuilder;
@ -100,6 +98,9 @@ public class DevInfoServiceImpl implements DevInfoService {
@Resource
private MaDevQcMapper maDevQcMapper;
@Autowired
private CacheHelper cacheHelper;
/**
* 查询设备信息
*
@ -253,10 +254,28 @@ public class DevInfoServiceImpl implements DevInfoService {
@Override
public List<DevInfoVo> selectDevInfoList(DevInfoVo devInfo) {
List<DevInfoVo> voList = devInfoMapper.selectDevInfoList(devInfo);
extractedFile(voList);
// 增加缓存处理
cacheHelper.putList("devListCache",
"user:" + SecurityUtils.getLoginUser().getSysUser().getUserId(), voList, Duration.ofMinutes(5L));
return voList;
}
@Override
public Map<String, Long> getCompanyCount(DevInfoVo devInfo) {
// 先从缓存获取
List<DevInfoVo> voList = cacheHelper.getList("devListCache", "user:" + SecurityUtils.getLoginUser().getSysUser().getUserId(), DevInfoVo.class);
if (CollectionUtils.isEmpty(voList)) {
System.out.println("缓存无此数据!");
// 缓存内没有此数据再执行Mapper查询
voList = devInfoMapper.selectDevInfoList(devInfo);
} else {
System.out.println("缓存已生效!");
}
Map<String, Long> map = voList.stream().collect(Collectors.groupingBy(DevInfoVo::getCompanyId, Collectors.counting()));
return map;
}
@Override
public List<DevInfoVo> selectZoneDevInfoList(DevInfoVo devInfo) {
if (Objects.isNull(devInfo)) {
@ -270,12 +289,6 @@ public class DevInfoServiceImpl implements DevInfoService {
return voList;
}
@Override
public Map<String, Long> getCompanyCount(DevInfoVo devInfo) {
List<DevInfoVo> voList = devInfoMapper.selectDevInfoList(devInfo);
Map<String, Long> map = voList.stream().collect(Collectors.groupingBy(DevInfoVo::getCompanyId, Collectors.counting()));
return map;
}
/**
* 查询设备收藏列表

View File

@ -1,6 +1,5 @@
package com.bonus.material.order.mapper;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.material.comprehensive.entity.RentDetailDto;
import com.bonus.material.device.domain.DevInfo;
import com.bonus.material.device.domain.vo.DevInfoVo;
@ -68,5 +67,13 @@ public interface OrderMapper {
List<OrderData> getBuyerAndSellerCouples();
/**
* 订单确认
*/
Integer orderConfirm(String orderId);
/**
* 订单驳回
*/
int orderReject(String orderId);
}

View File

@ -41,10 +41,10 @@ public interface OrderService {
/**
* 获取单个订单取件码
* @param dto
* @return
*/
int getOrderCode(OrderDetailDto dto);
AjaxResult orderConfirm(String orderId);
AjaxResult orderReject(String orderId);
}

View File

@ -223,7 +223,7 @@ public class OrderServiceImpl implements OrderService {
orderInfoDto.setReceivingUser(list.get(0).getReceivingUser());
orderInfoDto.setReceivingTime(list.get(0).getReceivingTime());
for (OrderDetailDto orderDetailDto : list) {
orderDetailDto.setTotalCost(orderDetailDto.getCosts());
// orderDetailDto.setTotalCost(orderDetailDto.getCosts());
// 出库时间设置为租赁开始时间
if (StringUtils.isNotBlank(orderDetailDto.getPreOutboundTime())) {
// 租赁天数为租期结束时间减去出库时间,计算天数差
@ -231,9 +231,9 @@ public class OrderServiceImpl implements OrderService {
Date dateStr2 = orderDetailDto.getRentEndTime();
long daysDifference = calculateDaysDifference(dateStr1, dateStr2);
// 计算累计租金
BigDecimal totalCost = orderDetailDto.getDayLeasePrice().multiply(new BigDecimal(daysDifference));
// BigDecimal totalCost = orderDetailDto.getDayLeasePrice().multiply(new BigDecimal(daysDifference));
orderDetailDto.setDays(String.valueOf(daysDifference));
orderDetailDto.setTotalCost(totalCost);
// orderDetailDto.setTotalCost(totalCost);
}
}
orderInfoDto.setDetailsList(list);
@ -272,7 +272,7 @@ public class OrderServiceImpl implements OrderService {
@Override
public List<OrderInfoDto> getOrderStatusCount(OrderDetailDto dto) throws Exception {
//true:出租方 false:承租方
// true:出租方 false:承租方
if (dto.isFlag()) {
dto.setSellerCompany(Optional.ofNullable(SecurityUtils.getLoginUser().getSysUser().getCompanyId()).orElse(SecurityUtils.getLoginUser().getSysUser().getDeptId()).intValue());
} else {
@ -378,7 +378,8 @@ public class OrderServiceImpl implements OrderService {
tmTask.setTaskStatus(minOrderStatus.getAsInt());
tmTask.setCode(dtos.get(0).getOrderCode());
if (orderInfoDto.getOrderStatus().equals(OrderStatusEnum.ORDER_PENDING_SHIPMENT.getStatus().toString()) ||
orderInfoDto.getOrderStatus().equals(OrderStatusEnum.ORDER_TERMINATED.getStatus().toString())) {
orderInfoDto.getOrderStatus().equals(OrderStatusEnum.ORDER_TERMINATED.getStatus().toString()))
{
tmTask.setNoticeCompanyId(tmTask.getBuyerCompanyId());
} else if (orderInfoDto.getOrderStatus().equals(OrderStatusEnum.ORDER_RECEIVE.getStatus().toString()) ||
@ -531,8 +532,6 @@ public class OrderServiceImpl implements OrderService {
OrderDetailDto orderDetailDto = orderMapper.selectOrderDetailsById(id);
list.add(orderDetailDto);
}
BigDecimal totalRentalPrice = BigDecimal.ZERO;
BigDecimal totalReliefPrice = BigDecimal.ZERO;
dto.setDetailsList(list);
Optional<OrderDetailDto> minOrderStatus = list.stream().min(Comparator.comparingInt(p -> Integer.parseInt(p.getOrderStatus())));
minOrderStatus.ifPresent(orderDetailDto -> dto.setOrderStatus(orderDetailDto.getOrderStatus()));
@ -587,4 +586,17 @@ public class OrderServiceImpl implements OrderService {
return AjaxResult.error("操作成功");
}
}
/**
* 订单驳回
*/
@Override
public AjaxResult orderReject(String orderId) {
try {
int dbCount = orderMapper.orderReject(orderId);
return dbCount > 0 ? AjaxResult.success("操作成功") : AjaxResult.error("操作失败");
} catch (Exception e) {
return AjaxResult.error("操作成功");
}
}
}

View File

@ -0,0 +1,60 @@
package com.bonus.material.utils;
import cn.hutool.json.JSONUtil;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.time.Duration;
import java.util.Collections;
import java.util.List;
@Component
public class CacheHelper {
@Resource
private RedisTemplate<String, Object> redisTemplate;
public <T> void putList(String cacheName, String key, List<T> data, Duration ttl) {
String fullKey = cacheName + "::" + key;
redisTemplate.opsForValue().set(fullKey, JSONUtil.toJsonStr(data), ttl);
}
public <T> List<T> getList(String cacheName, String key, Class<T> clazz) {
String fullKey = cacheName + "::" + key;
Object value = redisTemplate.opsForValue().get(fullKey);
if (value == null) return Collections.emptyList();
// 保证无论是字符串还是对象都能转回来
String json = (value instanceof String) ? (String) value : JSONUtil.toJsonStr(value);
return JSONUtil.toList(json, clazz);
}
/**
* 获取单对象
*/
public <T> T getBean(String cacheName, String key, Class<T> clazz) {
String fullKey = cacheName + "::" + key;
Object value = redisTemplate.opsForValue().get(fullKey);
if (value == null) {
return null;
}
String json = (value instanceof String) ? (String) value : JSONUtil.toJsonStr(value);
return JSONUtil.toBean(json, clazz);
}
/**
* 写入缓存
*/
public void put(String cacheName, String key, Object data, Duration ttl) {
String fullKey = cacheName + "::" + key;
redisTemplate.opsForValue().set(fullKey, JSONUtil.toJsonStr(data), ttl);
}
/**
* 删除缓存
*/
public void del(String cacheName, String key) {
redisTemplate.delete(cacheName + "::" + key);
}
}

View File

@ -50,41 +50,44 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectDevInfoList" parameterType="com.bonus.material.device.domain.vo.DevInfoVo" resultType="com.bonus.material.device.domain.vo.DevInfoVo">
SELECT
mtv.proType,
mtv.mainGx,
mtv.childGx,
mtv.devCategory,
mtv.devSubcategory,
mtv.devName,
d.ma_id as maId,
d.code as `code`,
d.identify_code as identifyCode,
d.device_name as deviceName,
d.device_count as deviceCount,
d.type_id as typeId,
d.ma_status as maStatus,
d.brand as brand,
d.production_date as productionDate,
d.working_hours as workingHours,
d.person as person,
d.person_phone as personPhone,
d.create_time as createTime,
d.update_time as updateTime,
d.on_company as companyId,
sd.dept_name as companyName,
c.operate_address as operateAddress
ifnull(mdf.file_url, bfi.url) as picUrl,
mtv.proType,
mtv.mainGx,
mtv.childGx,
mtv.devCategory,
mtv.devSubcategory,
mtv.devName,
d.ma_id as maId,
d.code as `code`,
d.identify_code as identifyCode,
d.device_name as deviceName,
d.device_count as deviceCount,
d.type_id as typeId,
d.ma_status as maStatus,
d.brand as brand,
d.production_date as productionDate,
d.working_hours as workingHours,
d.person as person,
d.person_phone as personPhone,
d.create_time as createTime,
d.update_time as updateTime,
d.on_company as companyId,
sd.dept_name as companyName,
c.operate_address as operateAddress
FROM
ma_dev_info d
ma_dev_info d
LEFT JOIN sys_dept sd ON d.on_company = sd.dept_id
LEFT JOIN bm_company_info c ON sd.dept_id = c.company_id
LEFT JOIN ma_type_view mtv ON mtv.typeId = d.type_id
LEFT JOIN bm_file_info bfi on d.ma_id = bfi.model_id and bfi.file_type = '0' and bfi.task_type = '17'
LEFT JOIN ma_dev_file mdf on d.ma_id = mdf.ma_id and mdf.file_type = '1' and mdf.is_active = '1'
<where>
<if test="maId != null "> and d.ma_id = #{maId}</if>
<if test="code != null and code != ''"> and d.code = #{code}</if>
<if test="deviceName != null and deviceName != ''">
and d.device_name like concat('%',#{deviceName},'%')
</if>
<if test="maStatus != null"> and d.ma_status = #{maStatus}</if>
<if test="maStatus != null"> and (d.ma_status = 1 or d.ma_status = 2 or d.ma_status = 3)</if>
<if test="leaseScope != null "> and d.lease_scope = #{leaseScope}</if>
<if test="location != null and location != ''"> and d.location = #{location}</if>
<if test="provinceId != null and provinceId != ''"> and d.province_id = #{provinceId}</if>
@ -109,12 +112,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="startTime != null and endTime != null">
and d.update_time between #{startTime} and #{endTime}
</if>
<if test="isZone != null">
and d.is_zone = 1
</if>
<if test="zoneId != null">
and d.zone_id = #{zoneId}
</if>
<if test="keyWord != null and keyWord != ''">
and (
locate(#{keyWord},mtv.mainGx) > 0

View File

@ -9,6 +9,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
values
(#{code}, now(), #{cost}, #{buyerId}, #{address}, #{creater}, now(), #{buyerCompany})
</insert>
<insert id="insertOrderDetail">
INSERT INTO `ma_order_details` (
`order_id`,
@ -33,23 +34,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
now(),
#{updateTime})
</insert>
<update id="updateDeviceStatus">
update ma_dev_info set ma_status = #{maStatus} where ma_id = #{maId} and is_active = 1
</update>
<update id="updateMaStatus">
update book_car_detail set order_status = 1 where id = #{id}
</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()
</if>
<if test="orderStatus == 4">
,pre_outbound_user = #{userName}
@ -84,9 +86,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</foreach>
</if>
</update>
<update id="updateDevCount">
update ma_dev_info set device_count = device_count - #{num} where ma_id = #{maId} and is_active = 1
</update>
<update id="updateAddDevCount">
update ma_dev_info set device_count = device_count + #{num} where ma_id = #{maId} and is_active = 1
</update>
@ -122,17 +126,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
update_time = now()
WHERE order_id = #{orderId} and ma_id = #{maId}
</update>
<update id="orderConfirm">
UPDATE
ma_order_details
set order_status = '2',
update_time = now()
WHERE order_id = #{orderId}
UPDATE ma_order_details set order_status = '2', update_time = now() WHERE order_id = #{orderId}
</update>
<update id="orderReject" >
UPDATE ma_order_details set order_status = '3', update_time = now() WHERE order_id = #{orderId}
</update>
<select id="getdeviceCount" resultType="com.bonus.material.device.domain.DevInfo">
select device_count,device_name from ma_dev_info where ma_id = #{maId} and is_active = 1
</select>
<select id="getOrderDetails" resultType="com.bonus.material.order.domain.OrderInfoDto">
SELECT
moi.code AS code,
@ -147,7 +153,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
su2.nick_name as sellerName,
moi.address,
moi.order_id,
sum(hh.costs) cost,
dept.dept_name as companyName
FROM
ma_order_details hh
@ -277,6 +282,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
WHERE
mt.del_flag = '0' and moi.order_id = #{orderId} limit 1
</select>
<select id="selectOrderDetailsByOrderId" resultType="com.bonus.material.order.domain.OrderDetailDto">
SELECT
mdi.ma_id as maId,
@ -319,6 +325,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
moi.order_id = #{orderId} and bfi.task_type = 17 and bfi.file_type = 0
GROUP BY hh.ma_id
</select>
<select id="getOrderDetailsByOrderId" resultType="com.bonus.material.order.domain.OrderDetailDto">
SELECT
su1.phonenumber as buyerPhoneNumber,
@ -401,6 +408,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
mt.del_flag = '0'
AND hh.order_id = #{orderId}
</select>
<select id="getRentDetails" resultType="com.bonus.material.comprehensive.entity.RentDetailDto">
SELECT
moi.`code` as orderCode,
@ -435,6 +443,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
ORDER BY
moi.order_time DESC
</select>
<select id="getOrderData" resultType="com.bonus.material.largeScreen.entity.OrderData">
SELECT
count( moi.order_id ) AS orderNum,
@ -442,6 +451,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
FROM
ma_order_info moi
</select>
<select id="getCompanysCost" resultType="com.bonus.material.largeScreen.entity.OrderData">
SELECT
mdi.on_company,
@ -456,6 +466,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
GROUP BY
mdi.on_company
</select>
<select id="getTodayOrderCount" resultType="com.bonus.material.largeScreen.entity.OrderDto">
SELECT
count( moi.order_id ) orderNum,