Commit 81a8b071 by 杨浩

系统完善需求

parent 12a42586
...@@ -30,6 +30,16 @@ public enum CheckTaskStatus implements ArrayValuable<String> { ...@@ -30,6 +30,16 @@ public enum CheckTaskStatus implements ArrayValuable<String> {
public static final String[] ARRAYS = Arrays.stream(values()).map(CheckTaskStatus::getKey).toArray(String[]::new); public static final String[] ARRAYS = Arrays.stream(values()).map(CheckTaskStatus::getKey).toArray(String[]::new);
public static String getNameByStatus(String key) {
for (CheckTaskStatus em : values()) {
if (em.getKey().equals(key)) {
return em.getLabel();
}
}
return "";
}
/** /**
* @return 数组 * @return 数组
*/ */
......
...@@ -2,6 +2,7 @@ package cn.iocoder.foodnexus.framework.common.util.number; ...@@ -2,6 +2,7 @@ package cn.iocoder.foodnexus.framework.common.util.number;
import cn.hutool.core.math.Money; import cn.hutool.core.math.Money;
import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.NumberUtil;
import cn.iocoder.foodnexus.framework.common.util.CommonUtil;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
...@@ -80,8 +81,15 @@ public class MoneyUtils { ...@@ -80,8 +81,15 @@ public class MoneyUtils {
* @param fen 分 * @param fen 分
* @return 元 * @return 元
*/ */
public static BigDecimal fenToYuan(int fen) { public static BigDecimal fenToYuan(Integer fen) {
return new Money(0, fen).getAmount(); try {
if (CommonUtil.isEmpty(fen)) {
return null;
}
return new Money(0, fen).getAmount();
} catch (Exception e) {
return null;
}
} }
/** /**
...@@ -92,8 +100,15 @@ public class MoneyUtils { ...@@ -92,8 +100,15 @@ public class MoneyUtils {
* @param fen 分 * @param fen 分
* @return 元 * @return 元
*/ */
public static String fenToYuanStr(int fen) { public static String fenToYuanStr(Integer fen) {
return new Money(0, fen).toString(); try {
if (CommonUtil.isEmpty(fen)) {
return null;
}
return new Money(0, fen).toString();
} catch (Exception e) {
return null;
}
} }
/** /**
...@@ -128,4 +143,25 @@ public class MoneyUtils { ...@@ -128,4 +143,25 @@ public class MoneyUtils {
return price.multiply(percent).divide(PERCENT_100, PRICE_SCALE, RoundingMode.HALF_UP); return price.multiply(percent).divide(PERCENT_100, PRICE_SCALE, RoundingMode.HALF_UP);
} }
/**
* BigDecimal与int相乘,四舍五入后转为int
* @param decimal 待相乘的BigDecimal(如金额、费率)
* @param integer 待相乘的int(如数量、倍数)
* @return 四舍五入后的int结果
* @throws ArithmeticException 结果超出int范围时抛出
*/
public static Integer multiplyAndRoundToInt(BigDecimal decimal, Integer integer) {
// 1. 空值校验(根据业务调整,也可默认decimal为0)
if (decimal == null) {
throw new IllegalArgumentException("BigDecimal参数不能为空");
}
// 2. 相乘运算 + 四舍五入(RoundingMode.HALF_UP = 标准四舍五入)
BigDecimal resultBigDecimal = decimal.multiply(BigDecimal.valueOf(integer))
.setScale(0, RoundingMode.HALF_UP);
// 3. 转换为int(超出int范围会抛ArithmeticException,需捕获或处理)
return resultBigDecimal.intValueExact();
}
} }
...@@ -21,16 +21,9 @@ public class BannerApplicationRunner implements ApplicationRunner { ...@@ -21,16 +21,9 @@ public class BannerApplicationRunner implements ApplicationRunner {
ThreadUtil.execute(() -> { ThreadUtil.execute(() -> {
ThreadUtil.sleep(1, TimeUnit.SECONDS); // 延迟 1 秒,保证输出到结尾 ThreadUtil.sleep(1, TimeUnit.SECONDS); // 延迟 1 秒,保证输出到结尾
log.info("\n----------------------------------------------------------\n\t" + log.info("\n----------------------------------------------------------\n\t" +
"项目启动成功!\n\t" + "项目启动成功!\n\t");
"接口文档: \t{} \n\t" +
"开发文档: \t{} \n\t" +
"视频教程: \t{} \n" +
"----------------------------------------------------------",
"https://doc.iocoder.cn/api-doc/",
"https://doc.iocoder.cn",
"https://t.zsxq.com/02Yf6M7Qn");
// 数据报表 /*// 数据报表
if (isNotPresent("cn.iocoder.foodnexus.module.report.framework.security.config.SecurityConfiguration")) { if (isNotPresent("cn.iocoder.foodnexus.module.report.framework.security.config.SecurityConfiguration")) {
System.out.println("[报表模块 foodnexus-module-report - 已禁用][参考 https://doc.iocoder.cn/report/ 开启]"); System.out.println("[报表模块 foodnexus-module-report - 已禁用][参考 https://doc.iocoder.cn/report/ 开启]");
} }
...@@ -65,7 +58,7 @@ public class BannerApplicationRunner implements ApplicationRunner { ...@@ -65,7 +58,7 @@ public class BannerApplicationRunner implements ApplicationRunner {
// IoT 物联网 // IoT 物联网
if (isNotPresent("cn.iocoder.foodnexus.module.iot.framework.web.config.IotWebConfiguration")) { if (isNotPresent("cn.iocoder.foodnexus.module.iot.framework.web.config.IotWebConfiguration")) {
System.out.println("[IoT 物联网 foodnexus-module-iot - 已禁用][参考 https://doc.iocoder.cn/iot/build/ 开启]"); System.out.println("[IoT 物联网 foodnexus-module-iot - 已禁用][参考 https://doc.iocoder.cn/iot/build/ 开启]");
} }*/
}); });
} }
......
...@@ -31,6 +31,15 @@ public enum ErpDeliveryStatus implements ArrayValuable<String> { ...@@ -31,6 +31,15 @@ public enum ErpDeliveryStatus implements ArrayValuable<String> {
*/ */
private final String name; private final String name;
public static String getNameByStatus(String deliveryStatus) {
for (ErpDeliveryStatus em : values()) {
if (em.getStatus().equals(deliveryStatus)) {
return em.getName();
}
}
return "";
}
@Override @Override
public String[] array() { public String[] array() {
return ARRAYS; return ARRAYS;
......
...@@ -123,4 +123,9 @@ public class CustomerAddReqVO { ...@@ -123,4 +123,9 @@ public class CustomerAddReqVO {
*/ */
private String address; private String address;
/**
* 客服信息
*/
private String serviceInfo;
} }
...@@ -2,18 +2,22 @@ package cn.iocoder.foodnexus.module.erp.controller.admin.purchase; ...@@ -2,18 +2,22 @@ package cn.iocoder.foodnexus.module.erp.controller.admin.purchase;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.iocoder.foodnexus.framework.apilog.core.annotation.ApiAccessLog; import cn.iocoder.foodnexus.framework.apilog.core.annotation.ApiAccessLog;
import cn.iocoder.foodnexus.framework.common.enums.CheckTaskStatus;
import cn.iocoder.foodnexus.framework.common.enums.UserSystemEnum; import cn.iocoder.foodnexus.framework.common.enums.UserSystemEnum;
import cn.iocoder.foodnexus.framework.common.pojo.CommonResult; import cn.iocoder.foodnexus.framework.common.pojo.CommonResult;
import cn.iocoder.foodnexus.framework.common.pojo.PageParam; import cn.iocoder.foodnexus.framework.common.pojo.PageParam;
import cn.iocoder.foodnexus.framework.common.pojo.PageResult; import cn.iocoder.foodnexus.framework.common.pojo.PageResult;
import cn.iocoder.foodnexus.framework.common.util.CommonUtil; import cn.iocoder.foodnexus.framework.common.util.CommonUtil;
import cn.iocoder.foodnexus.framework.common.util.collection.MapUtils; import cn.iocoder.foodnexus.framework.common.util.collection.MapUtils;
import cn.iocoder.foodnexus.framework.common.util.number.MoneyUtils;
import cn.iocoder.foodnexus.framework.common.util.object.BeanUtils; import cn.iocoder.foodnexus.framework.common.util.object.BeanUtils;
import cn.iocoder.foodnexus.framework.excel.core.util.ExcelUtils; import cn.iocoder.foodnexus.framework.excel.core.util.ExcelUtils;
import cn.iocoder.foodnexus.framework.security.core.util.SecurityFrameworkUtils; import cn.iocoder.foodnexus.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.foodnexus.module.erp.api.enums.ErpDeliveryStatus; import cn.iocoder.foodnexus.module.erp.api.enums.ErpDeliveryStatus;
import cn.iocoder.foodnexus.module.erp.api.service.ErpCustomerApi; import cn.iocoder.foodnexus.module.erp.api.service.ErpCustomerApi;
import cn.iocoder.foodnexus.module.erp.api.service.ErpSupplierApi; import cn.iocoder.foodnexus.module.erp.api.service.ErpSupplierApi;
import cn.iocoder.foodnexus.module.erp.api.vo.warehouse.WarehouseInfo;
import cn.iocoder.foodnexus.module.erp.controller.admin.purchase.vo.order.ErpPurchaseOrderExportVO;
import cn.iocoder.foodnexus.module.erp.controller.admin.purchase.vo.order.ErpPurchaseOrderPageReqVO; import cn.iocoder.foodnexus.module.erp.controller.admin.purchase.vo.order.ErpPurchaseOrderPageReqVO;
import cn.iocoder.foodnexus.module.erp.controller.admin.purchase.vo.order.ErpPurchaseOrderRespVO; import cn.iocoder.foodnexus.module.erp.controller.admin.purchase.vo.order.ErpPurchaseOrderRespVO;
import cn.iocoder.foodnexus.module.erp.dal.dataobject.purchase.ErpPurchaseOrderDO; import cn.iocoder.foodnexus.module.erp.dal.dataobject.purchase.ErpPurchaseOrderDO;
...@@ -23,6 +27,7 @@ import cn.iocoder.foodnexus.module.erp.service.purchase.ErpPurchaseOrderService; ...@@ -23,6 +27,7 @@ import cn.iocoder.foodnexus.module.erp.service.purchase.ErpPurchaseOrderService;
import cn.iocoder.foodnexus.module.erp.service.purchase.ErpSupplierService; import cn.iocoder.foodnexus.module.erp.service.purchase.ErpSupplierService;
import cn.iocoder.foodnexus.module.order.api.CheckTaskApi; import cn.iocoder.foodnexus.module.order.api.CheckTaskApi;
import cn.iocoder.foodnexus.module.order.api.CustomerOrderApi; import cn.iocoder.foodnexus.module.order.api.CustomerOrderApi;
import cn.iocoder.foodnexus.module.order.dto.CustomerAddressInfo;
import cn.iocoder.foodnexus.module.order.dto.CustomerOrderDTO; import cn.iocoder.foodnexus.module.order.dto.CustomerOrderDTO;
import cn.iocoder.foodnexus.module.order.dto.CustomerOrderItemDTO; import cn.iocoder.foodnexus.module.order.dto.CustomerOrderItemDTO;
import cn.iocoder.foodnexus.module.order.enums.CustomerOrderStatus; import cn.iocoder.foodnexus.module.order.enums.CustomerOrderStatus;
...@@ -33,6 +38,7 @@ import cn.iocoder.foodnexus.module.product.service.spu.ProductSpuService; ...@@ -33,6 +38,7 @@ import cn.iocoder.foodnexus.module.product.service.spu.ProductSpuService;
import cn.iocoder.foodnexus.module.system.annotations.AppSystemAuth; import cn.iocoder.foodnexus.module.system.annotations.AppSystemAuth;
import cn.iocoder.foodnexus.module.system.api.user.AdminUserApi; import cn.iocoder.foodnexus.module.system.api.user.AdminUserApi;
import cn.iocoder.foodnexus.module.system.api.user.dto.AdminUserRespDTO; import cn.iocoder.foodnexus.module.system.api.user.dto.AdminUserRespDTO;
import cn.iocoder.foodnexus.module.system.service.dept.DeptService;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
...@@ -45,6 +51,7 @@ import org.springframework.validation.annotation.Validated; ...@@ -45,6 +51,7 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.io.IOException; import java.io.IOException;
import java.math.BigDecimal;
import java.util.*; import java.util.*;
import static cn.iocoder.foodnexus.framework.apilog.core.enums.OperateTypeEnum.EXPORT; import static cn.iocoder.foodnexus.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
...@@ -75,7 +82,7 @@ public class ErpPurchaseOrderController { ...@@ -75,7 +82,7 @@ public class ErpPurchaseOrderController {
private ErpSupplierApi supplierApi; private ErpSupplierApi supplierApi;
@Autowired @Autowired
private CheckTaskApi checkTaskApi; private DeptService deptService;
@GetMapping("/erp/purchase-order/get") @GetMapping("/erp/purchase-order/get")
@Operation(summary = "获得采购订单") @Operation(summary = "获得采购订单")
...@@ -115,7 +122,33 @@ public class ErpPurchaseOrderController { ...@@ -115,7 +122,33 @@ public class ErpPurchaseOrderController {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<ErpPurchaseOrderRespVO> list = buildPurchaseOrderVOPageResult(purchaseOrderService.getPurchaseOrderPage(pageReqVO).getList(), false); List<ErpPurchaseOrderRespVO> list = buildPurchaseOrderVOPageResult(purchaseOrderService.getPurchaseOrderPage(pageReqVO).getList(), false);
// 导出 Excel // 导出 Excel
ExcelUtils.write(response, "采购订单.xls", "数据", ErpPurchaseOrderRespVO.class, list); ExcelUtils.write(response, "采购订单.xls", "数据", ErpPurchaseOrderExportVO.class,
BeanUtils.toBean(list, ErpPurchaseOrderExportVO.class, item -> {
item.setTotalPriceYuan(item.getTotalPrice().divide(BigDecimal.valueOf(100)));
item.setDepositPriceYuan(MoneyUtils.fenToYuan(item.getDepositPrice()));
item.setDeliveryStatusStr(ErpDeliveryStatus.getNameByStatus(item.getDeliveryStatus()));
item.setCheckTaskStatusStr(CheckTaskStatus.getNameByStatus(item.getCheckTaskStatus()));
if (CommonUtil.isNotEmpty(item.getAddressInfo())) {
CustomerAddressInfo addressInfo = item.getAddressInfo();
item.setAddressInfoStr(String.format("%s %s %s %s",
addressInfo.getProvinceName(),
addressInfo.getCityName(),
addressInfo.getRegionName(),
addressInfo.getAddress()));
}
if (CommonUtil.isNotEmpty(item.getWarehouseInfo())) {
WarehouseInfo warehouseInfo = item.getWarehouseInfo();
item.setWarehouseStr(String.format("%s %s %s %s",
warehouseInfo.getAddress(),
warehouseInfo.getName(),
warehouseInfo.getPrincipal(),
warehouseInfo.getTelephone()));
}
item.setDeliveryModeStr(item.getDeliveryMode().getLabel());
}));
} }
...@@ -190,6 +223,7 @@ public class ErpPurchaseOrderController { ...@@ -190,6 +223,7 @@ public class ErpPurchaseOrderController {
convertSet(list, purchaseOrder -> Long.parseLong(purchaseOrder.getCreator()))); convertSet(list, purchaseOrder -> Long.parseLong(purchaseOrder.getCreator())));
Map<Long, CustomerOrderDTO> customerOrderMap = customerOrderApi.getOrderMap( Map<Long, CustomerOrderDTO> customerOrderMap = customerOrderApi.getOrderMap(
convertSet(list, ErpPurchaseOrderDO::getCustomerOrderId)); convertSet(list, ErpPurchaseOrderDO::getCustomerOrderId));
Map<Long, String> deptNameMap = deptService.queryNameMapByIds(CommonUtil.listConvertSet(new ArrayList<>(customerOrderMap.values()), CustomerOrderDTO::getCustomerDeptId), Boolean.TRUE);
Map<Long, CustomerOrderItemDTO> customerOrderItemMap; Map<Long, CustomerOrderItemDTO> customerOrderItemMap;
/*Map<Long, String> checkResultMap;*/ /*Map<Long, String> checkResultMap;*/
List<CustomerOrderItemDTO> customerOrderItems = customerOrderApi.queryItemsByIds(CommonUtil.listConvert(purchaseOrderItemList, ErpPurchaseOrderItemDO::getCustomerOrderItemId)); List<CustomerOrderItemDTO> customerOrderItems = customerOrderApi.queryItemsByIds(CommonUtil.listConvert(purchaseOrderItemList, ErpPurchaseOrderItemDO::getCustomerOrderItemId));
...@@ -227,9 +261,10 @@ public class ErpPurchaseOrderController { ...@@ -227,9 +261,10 @@ public class ErpPurchaseOrderController {
purchaseOrder.setCustomerOrderCode(customerOrder.getCode()); purchaseOrder.setCustomerOrderCode(customerOrder.getCode());
purchaseOrder.setCustomerId(customerOrder.getCustomerId()); purchaseOrder.setCustomerId(customerOrder.getCustomerId());
purchaseOrder.setCustomerName(customerApi.queryNameStrById(customerOrder.getCustomerId())); purchaseOrder.setCustomerName(customerApi.queryNameStrById(customerOrder.getCustomerId()));
purchaseOrder.setCustomerDeptId(customerOrder.getCustomerDeptId());
purchaseOrder.setDeliveryMode(customerOrder.getDeliveryMode()); purchaseOrder.setDeliveryMode(customerOrder.getDeliveryMode());
}); });
MapUtils.findAndThen(deptNameMap, purchaseOrder.getCustomerDeptId(), purchaseOrder::setCustomerDeptName);
}); });
} }
......
package cn.iocoder.foodnexus.module.erp.controller.admin.purchase.vo.order;
import cn.idev.excel.annotation.ExcelIgnoreUnannotated;
import cn.idev.excel.annotation.ExcelProperty;
import cn.iocoder.foodnexus.framework.common.enums.CheckTaskStatus;
import cn.iocoder.foodnexus.module.erp.api.enums.ErpDeliveryStatus;
import cn.iocoder.foodnexus.module.erp.api.vo.warehouse.WarehouseInfo;
import cn.iocoder.foodnexus.module.order.dto.CustomerAddressInfo;
import cn.iocoder.foodnexus.module.order.enums.DeliveryMode;
import cn.iocoder.foodnexus.module.product.api.dto.ProductInfo;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;
@Schema(description = "管理后台 - ERP 采购订单 Response VO")
@Data
@ExcelIgnoreUnannotated
public class ErpPurchaseOrderExportVO {
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "17386")
@ExcelProperty("编号")
private Long id;
@Schema(description = "采购单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "XS001")
@ExcelProperty("采购单编号")
private String no;
@Schema(description = "采购状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
private Integer status;
@Schema(description = "产品信息", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("产品信息")
private String productNames;
@Schema(description = "供应商编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1724")
private Long supplierId;
@Schema(description = "供应商名称", example = "芋道")
@ExcelProperty("供应商名称")
private String supplierName;
@Schema(description = "采购时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("订单时间")
private LocalDateTime orderTime;
@Schema(description = "合计数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "15663")
@ExcelProperty("总数量")
private BigDecimal totalCount;
@Schema(description = "最终合计价格", requiredMode = Schema.RequiredMode.REQUIRED, example = "24906")
// @ExcelProperty("金额合计")
private BigDecimal totalPrice;
@Schema(description = "应收金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127")
// @ExcelProperty("应收金额")
private Integer depositPrice;
@Schema(description = "最终合计价格", requiredMode = Schema.RequiredMode.REQUIRED, example = "24906")
@ExcelProperty("金额合计,单位:元")
private BigDecimal totalPriceYuan;
@Schema(description = "应收金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127")
@ExcelProperty("应收金额,单位:元")
private BigDecimal depositPriceYuan;
@Schema(description = "采购入库数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00")
@ExcelProperty("入库数量")
private BigDecimal inCount;
@Schema(description = "采购退货数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00")
@ExcelProperty("退货数量")
private BigDecimal returnCount;
@Schema(description = "备注", example = "你猜")
@ExcelProperty("备注")
private String remark;
@Schema(description = "创建人名称", example = "芋道")
private String creatorName;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("创建时间")
private LocalDateTime createTime;
/**
* 发货状态
*
* 枚举 {@link ErpDeliveryStatus}
*/
@Schema(description = "发货状态")
private String deliveryStatus;
@ExcelProperty("状态")
private String deliveryStatusStr;
/**
* 质检状态
*
* 枚举 {@link CheckTaskStatus}
*/
@Schema(description = "质检状态")
private String checkTaskStatus;
@ExcelProperty("质检结果")
private String checkTaskStatusStr;
/* ------ 客户订单 ------ */
@Schema(description = "客户收货地址info")
private CustomerAddressInfo addressInfo;
@ExcelProperty("配送地址")
private String addressInfoStr;
@Schema(description = "配送仓库info")
private WarehouseInfo warehouseInfo;
@ExcelProperty("配送仓库")
private String warehouseStr;
@Schema(description = "预计配送开始时间")
@ExcelProperty("预计配送开始时间")
private LocalDateTime planDeliveryStartTime;
@Schema(description = "预计配送结束时间")
@ExcelProperty("预计配送结束时间")
private LocalDateTime planDeliveryEndTime;
@Schema(description = "客户订单编号", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("客户订单编号")
private String customerOrderCode;
@Schema(description = "客户id")
private Long customerId;
@Schema(description = "客户名称")
@ExcelProperty("客户名称")
private String customerName;
@Schema(description = "灶点id")
private Long customerDeptId;
@Schema(description = "灶点名称")
@ExcelProperty("灶点名称")
private String customerDeptName;
@Schema(description = "配送模式")
private DeliveryMode deliveryMode;
@ExcelProperty("配送模式")
private String deliveryModeStr;
}
...@@ -55,6 +55,9 @@ public class ErpPurchaseOrderPageReqVO extends PageParam { ...@@ -55,6 +55,9 @@ public class ErpPurchaseOrderPageReqVO extends PageParam {
@Schema(description = "供应商编号", example = "1724") @Schema(description = "供应商编号", example = "1724")
private Long supplierId; private Long supplierId;
@Schema(description = "供应商名称")
private String supplierName;
@Schema(description = "采购时间") @Schema(description = "采购时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] orderTime; private LocalDateTime[] orderTime;
......
...@@ -150,6 +150,12 @@ public class ErpPurchaseOrderRespVO { ...@@ -150,6 +150,12 @@ public class ErpPurchaseOrderRespVO {
@Schema(description = "客户名称") @Schema(description = "客户名称")
private String customerName; private String customerName;
@Schema(description = "灶点id")
private Long customerDeptId;
@Schema(description = "灶点名称")
private String customerDeptName;
@Schema(description = "配送模式") @Schema(description = "配送模式")
private DeliveryMode deliveryMode; private DeliveryMode deliveryMode;
...@@ -207,7 +213,7 @@ public class ErpPurchaseOrderRespVO { ...@@ -207,7 +213,7 @@ public class ErpPurchaseOrderRespVO {
private Long customerOrderItemId; private Long customerOrderItemId;
@Schema(description = "签收数量") @Schema(description = "签收数量")
private Integer signedQuantity; private BigDecimal signedQuantity;
@Schema(description = "签收总价,单位:分") @Schema(description = "签收总价,单位:分")
private Integer signedTotal; private Integer signedTotal;
...@@ -216,7 +222,7 @@ public class ErpPurchaseOrderRespVO { ...@@ -216,7 +222,7 @@ public class ErpPurchaseOrderRespVO {
private String checkResult;*/ private String checkResult;*/
@Schema(description = "退货数量") @Schema(description = "退货数量")
private Integer returnsCount; private BigDecimal returnsCount;
@Schema(description = "退货金额") @Schema(description = "退货金额")
private Integer returnsTotal; private Integer returnsTotal;
......
package cn.iocoder.foodnexus.module.erp.controller.admin.purchase.vo.order;
import cn.idev.excel.annotation.ExcelIgnoreUnannotated;
import cn.idev.excel.annotation.ExcelProperty;
import cn.iocoder.foodnexus.framework.excel.core.annotations.DictFormat;
import cn.iocoder.foodnexus.framework.excel.core.convert.DictConvert;
import cn.iocoder.foodnexus.module.order.enums.DeliveryMode;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.math.BigDecimal;
import java.time.LocalDateTime;
/**
* @author : yanghao
* create at: 2025/10/11 13:53
* @description: 月度账单明细
*/
@Data
@ExcelIgnoreUnannotated
public class SupplierMonthOrderDetailsExportVO {
@Schema(description = "采购单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "XS001")
@ExcelProperty("采购单编号")
private String no;
@Schema(description = "供应商名称", example = "芋道")
@ExcelProperty("供应商名称")
private String supplierName;
@Schema(description = "产品信息", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("产品信息")
private String productNames;
@Schema(description = "采购时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("订单时间")
private LocalDateTime orderTime;
@Schema(description = "配送模式", requiredMode = Schema.RequiredMode.REQUIRED)
// @DictFormat("order_delivery_mode") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中
private DeliveryMode deliveryMode;
@ExcelProperty(value = "配送模式")
private String deliveryModeStr;
@Schema(description = "预计配送开始时间")
@ExcelProperty("配送时间")
private LocalDateTime planDeliveryStartTime;
@Schema(description = "应对账总金额(分)")
private Integer payablePrice;
@Schema(description = "签收金额")
private Integer signedTotal;
@Schema(description = "退款金额")
private Integer returnsTotal;
@Schema(description = "最终合计价格", requiredMode = Schema.RequiredMode.REQUIRED, example = "24906")
@ExcelProperty("订单金额")
private BigDecimal totalPrice;
@ExcelProperty("应对账总金额(元)")
private BigDecimal payablePriceYuan;
@ExcelProperty("签收金额(元)")
private BigDecimal signedTotalYuan;
@ExcelProperty("退款金额(元)")
private BigDecimal returnsTotalYuan;
}
package cn.iocoder.foodnexus.module.erp.controller.admin.purchase.vo.order;
import cn.idev.excel.annotation.ExcelIgnoreUnannotated;
import cn.idev.excel.annotation.ExcelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.math.BigDecimal;
/**
* @author : yanghao
* create at: 2025/10/11 10:33
* @description: 供应商 月度账单
*/
@Data
@ExcelIgnoreUnannotated
public class SupplierMonthOrderExportVO {
@Schema(description = "供应商id")
private Long supplierId;
@Schema(description = "供应商名称")
@ExcelProperty("供应商名称")
private String supplierName;
@Schema(description = "月份")
@ExcelProperty("月份")
private String month;
@Schema(description = "订单总数")
@ExcelProperty("订单总数")
private Integer orderCount;
@Schema(description = "订单总金额(分)")
private Integer orderPrice;
@ExcelProperty("订单总金额(元)")
private BigDecimal orderPriceYuan;
@Schema(description = "应对账总金额(分)")
private Integer payablePrice;
@ExcelProperty("应对账总金额(元)")
private BigDecimal payablePriceYuan;
@Schema(description = "状态(是否对账)")
private Boolean status;
@ExcelProperty("状态(是否对账)")
private String statusStr;
}
...@@ -18,4 +18,7 @@ public class SupplierMonthOrderPageReqVO extends PageParam { ...@@ -18,4 +18,7 @@ public class SupplierMonthOrderPageReqVO extends PageParam {
@Schema(description = "供应商id") @Schema(description = "供应商id")
private Long supplierId; private Long supplierId;
@Schema(description = "供应商名称")
private String supplierName;
} }
...@@ -106,7 +106,7 @@ public class ErpPurchaseReturnSaveReqVO { ...@@ -106,7 +106,7 @@ public class ErpPurchaseReturnSaveReqVO {
@Schema(description = "产品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") @Schema(description = "产品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00")
@NotNull(message = "产品数量不能为空") @NotNull(message = "产品数量不能为空")
private Integer count; private BigDecimal count;
@Schema(description = "备注", example = "随便") @Schema(description = "备注", example = "随便")
private String remark; private String remark;
......
...@@ -107,4 +107,7 @@ public class ErpCustomerRespVO { ...@@ -107,4 +107,7 @@ public class ErpCustomerRespVO {
@Schema(description = "关联部门id") @Schema(description = "关联部门id")
private Long systemDeptId; private Long systemDeptId;
@Schema(description = "客服信息")
private String serviceInfo;
} }
...@@ -82,4 +82,7 @@ public class ErpCustomerSaveReqVO { ...@@ -82,4 +82,7 @@ public class ErpCustomerSaveReqVO {
@Schema(description = "关联系统部门id") @Schema(description = "关联系统部门id")
private Long systemDeptId; private Long systemDeptId;
@Schema(description = "客服信息")
private String serviceInfo;
} }
\ No newline at end of file
...@@ -57,7 +57,7 @@ public class ErpSaleOutRespVO { ...@@ -57,7 +57,7 @@ public class ErpSaleOutRespVO {
@Schema(description = "合计数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "15663") @Schema(description = "合计数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "15663")
@ExcelProperty("合计数量") @ExcelProperty("合计数量")
private Integer count; private BigDecimal count;
@Schema(description = "最终合计价格", requiredMode = Schema.RequiredMode.REQUIRED, example = "24906") @Schema(description = "最终合计价格", requiredMode = Schema.RequiredMode.REQUIRED, example = "24906")
@ExcelProperty("最终合计价格") @ExcelProperty("最终合计价格")
private Integer totalPrice; private Integer totalPrice;
...@@ -140,6 +140,9 @@ public class ErpSaleOutRespVO { ...@@ -140,6 +140,9 @@ public class ErpSaleOutRespVO {
@Schema(description = "拣货状态") @Schema(description = "拣货状态")
private SaleOrderPickUpStatus pickUpStatus; private SaleOrderPickUpStatus pickUpStatus;
@Schema(description = "签收单")
private String receiptFile;
@Data @Data
public static class Item { public static class Item {
......
...@@ -123,7 +123,7 @@ public class ErpSaleOutSaveReqVO { ...@@ -123,7 +123,7 @@ public class ErpSaleOutSaveReqVO {
@Schema(description = "产品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") @Schema(description = "产品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00")
@NotNull(message = "产品数量不能为空") @NotNull(message = "产品数量不能为空")
private Integer count; private BigDecimal count;
@Schema(description = "税率,百分比", example = "99.88") @Schema(description = "税率,百分比", example = "99.88")
private BigDecimal taxPercent; private BigDecimal taxPercent;
......
...@@ -64,7 +64,7 @@ public class ErpSaleReturnRespVO { ...@@ -64,7 +64,7 @@ public class ErpSaleReturnRespVO {
@Schema(description = "合计数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "15663") @Schema(description = "合计数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "15663")
@ExcelProperty("合计数量") @ExcelProperty("合计数量")
private Integer totalCount; private BigDecimal totalCount;
@Schema(description = "最终合计价格", requiredMode = Schema.RequiredMode.REQUIRED, example = "24906") @Schema(description = "最终合计价格", requiredMode = Schema.RequiredMode.REQUIRED, example = "24906")
@ExcelProperty("最终合计价格") @ExcelProperty("最终合计价格")
private Integer totalPrice; private Integer totalPrice;
...@@ -179,7 +179,7 @@ public class ErpSaleReturnRespVO { ...@@ -179,7 +179,7 @@ public class ErpSaleReturnRespVO {
@Schema(description = "产品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") @Schema(description = "产品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00")
@NotNull(message = "产品数量不能为空") @NotNull(message = "产品数量不能为空")
private Integer count; private BigDecimal count;
@Schema(description = "税率,百分比", example = "99.88") @Schema(description = "税率,百分比", example = "99.88")
private BigDecimal taxPercent; private BigDecimal taxPercent;
......
...@@ -107,7 +107,7 @@ public class ErpSaleReturnSaveReqVO { ...@@ -107,7 +107,7 @@ public class ErpSaleReturnSaveReqVO {
@Schema(description = "产品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") @Schema(description = "产品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00")
@NotNull(message = "产品数量不能为空") @NotNull(message = "产品数量不能为空")
private Integer count; private BigDecimal count;
@Schema(description = "税率,百分比", example = "99.88") @Schema(description = "税率,百分比", example = "99.88")
private BigDecimal taxPercent; private BigDecimal taxPercent;
......
...@@ -4,6 +4,7 @@ import cn.iocoder.foodnexus.framework.mybatis.core.dataobject.BaseDO; ...@@ -4,6 +4,7 @@ import cn.iocoder.foodnexus.framework.mybatis.core.dataobject.BaseDO;
import com.baomidou.mybatisplus.annotation.KeySequence; import com.baomidou.mybatisplus.annotation.KeySequence;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*; import lombok.*;
import java.math.BigDecimal; import java.math.BigDecimal;
...@@ -127,4 +128,9 @@ public class ErpCustomerDO extends BaseDO { ...@@ -127,4 +128,9 @@ public class ErpCustomerDO extends BaseDO {
*/ */
private Long systemDeptId; private Long systemDeptId;
/**
* 客服信息
*/
private String serviceInfo;
} }
\ No newline at end of file
...@@ -86,7 +86,7 @@ public class ErpSaleOutDO extends BaseDO { ...@@ -86,7 +86,7 @@ public class ErpSaleOutDO extends BaseDO {
/** /**
* 合计数量 * 合计数量
*/ */
private Integer totalCount; private BigDecimal totalCount;
/** /**
* 最终合计价格,单位:分 * 最终合计价格,单位:分
* *
...@@ -209,4 +209,9 @@ public class ErpSaleOutDO extends BaseDO { ...@@ -209,4 +209,9 @@ public class ErpSaleOutDO extends BaseDO {
* 拣货状态 * 拣货状态
*/ */
private SaleOrderPickUpStatus pickUpStatus; private SaleOrderPickUpStatus pickUpStatus;
/**
* 签收单
*/
private String receiptFile;
} }
\ No newline at end of file
...@@ -72,7 +72,7 @@ public class ErpSaleOutItemDO extends BaseDO { ...@@ -72,7 +72,7 @@ public class ErpSaleOutItemDO extends BaseDO {
/** /**
* 数量 * 数量
*/ */
private Integer count; private BigDecimal count;
/** /**
* 总价,单位:分 * 总价,单位:分
* *
......
...@@ -92,7 +92,7 @@ public class ErpSaleReturnDO extends BaseDO { ...@@ -92,7 +92,7 @@ public class ErpSaleReturnDO extends BaseDO {
/** /**
* 合计数量 * 合计数量
*/ */
private Integer totalCount; private BigDecimal totalCount;
/** /**
* 最终合计价格,单位:分 * 最终合计价格,单位:分
* *
......
...@@ -74,7 +74,7 @@ public class ErpSaleReturnItemDO extends BaseDO { ...@@ -74,7 +74,7 @@ public class ErpSaleReturnItemDO extends BaseDO {
/** /**
* 数量 * 数量
*/ */
private Integer count; private BigDecimal count;
/** /**
* 总价,单位:分 * 总价,单位:分
* *
......
...@@ -12,6 +12,7 @@ import cn.iocoder.foodnexus.module.erp.api.enums.ErpAuditStatus; ...@@ -12,6 +12,7 @@ import cn.iocoder.foodnexus.module.erp.api.enums.ErpAuditStatus;
import cn.iocoder.foodnexus.module.erp.controller.admin.purchase.vo.order.SupplierMonthOrderPageReqVO; import cn.iocoder.foodnexus.module.erp.controller.admin.purchase.vo.order.SupplierMonthOrderPageReqVO;
import cn.iocoder.foodnexus.module.erp.controller.admin.purchase.vo.order.SupplierMonthOrderRespVO; import cn.iocoder.foodnexus.module.erp.controller.admin.purchase.vo.order.SupplierMonthOrderRespVO;
import cn.iocoder.foodnexus.module.erp.dal.dataobject.purchase.ErpPurchaseReturnDO; import cn.iocoder.foodnexus.module.erp.dal.dataobject.purchase.ErpPurchaseReturnDO;
import cn.iocoder.foodnexus.module.erp.dal.dataobject.purchase.ErpSupplierDO;
import cn.iocoder.foodnexus.module.order.enums.CustomerOrderStatus; import cn.iocoder.foodnexus.module.order.enums.CustomerOrderStatus;
import cn.iocoder.foodnexus.module.product.dal.dataobject.spu.ProductSpuDO; import cn.iocoder.foodnexus.module.product.dal.dataobject.spu.ProductSpuDO;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
...@@ -138,6 +139,10 @@ public interface ErpPurchaseOrderMapper extends BaseMapperX<ErpPurchaseOrderDO> ...@@ -138,6 +139,10 @@ public interface ErpPurchaseOrderMapper extends BaseMapperX<ErpPurchaseOrderDO>
query.or().eq(ErpPurchaseReturnDO::getNo, reqVO.getCustomerOrderCode()); query.or().eq(ErpPurchaseReturnDO::getNo, reqVO.getCustomerOrderCode());
query.groupBy(ErpPurchaseReturnDO::getId); query.groupBy(ErpPurchaseReturnDO::getId);
} }
if (CommonUtil.isNotBlank(reqVO.getSupplierName())) {
query.leftJoin(ErpSupplierDO.class, ErpSupplierDO::getId, ErpPurchaseOrderDO::getSupplierId);
query.like(ErpSupplierDO::getName, reqVO.getSupplierName());
}
return query; return query;
} }
...@@ -167,6 +172,10 @@ public interface ErpPurchaseOrderMapper extends BaseMapperX<ErpPurchaseOrderDO> ...@@ -167,6 +172,10 @@ public interface ErpPurchaseOrderMapper extends BaseMapperX<ErpPurchaseOrderDO>
wrapper.in("t1.order_status", CommonUtil.asList(CustomerOrderStatus.SIGN_RECEIPT.getKey(), CustomerOrderStatus.FINISH.getKey(), CustomerOrderStatus.RETURN.getKey())); wrapper.in("t1.order_status", CommonUtil.asList(CustomerOrderStatus.SIGN_RECEIPT.getKey(), CustomerOrderStatus.FINISH.getKey(), CustomerOrderStatus.RETURN.getKey()));
wrapper.eq(CommonUtil.isNotBlank(pageReqVO.getMonth()), "DATE_FORMAT(t.create_time, '%Y-%m') ", pageReqVO.getMonth()); wrapper.eq(CommonUtil.isNotBlank(pageReqVO.getMonth()), "DATE_FORMAT(t.create_time, '%Y-%m') ", pageReqVO.getMonth());
wrapper.eq(CommonUtil.isNotEmpty(pageReqVO.getSupplierId()), "t.supplier_id", pageReqVO.getSupplierId());
if (CommonUtil.isNotBlank(pageReqVO.getSupplierName())) {
wrapper.like("es.name", pageReqVO.getSupplierName());
}
wrapper.orderByDesc("t.id"); wrapper.orderByDesc("t.id");
wrapper.groupBy("DATE_FORMAT( t.create_time, '%Y-%m' ), t.supplier_id"); wrapper.groupBy("DATE_FORMAT( t.create_time, '%Y-%m' ), t.supplier_id");
return this.selectJoinPage(pageReqVO, SupplierMonthOrderRespVO.class, wrapper); return this.selectJoinPage(pageReqVO, SupplierMonthOrderRespVO.class, wrapper);
......
...@@ -3,6 +3,7 @@ package cn.iocoder.foodnexus.module.erp.service.sale; ...@@ -3,6 +3,7 @@ package cn.iocoder.foodnexus.module.erp.service.sale;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.iocoder.foodnexus.framework.common.pojo.PageResult; import cn.iocoder.foodnexus.framework.common.pojo.PageResult;
import cn.iocoder.foodnexus.framework.common.util.CommonUtil; import cn.iocoder.foodnexus.framework.common.util.CommonUtil;
import cn.iocoder.foodnexus.framework.common.util.number.MoneyUtils;
import cn.iocoder.foodnexus.framework.common.util.object.BeanUtils; import cn.iocoder.foodnexus.framework.common.util.object.BeanUtils;
import cn.iocoder.foodnexus.framework.redis.utils.RedisUtils; import cn.iocoder.foodnexus.framework.redis.utils.RedisUtils;
import cn.iocoder.foodnexus.module.erp.api.vo.warehouse.WarehouseInfo; import cn.iocoder.foodnexus.module.erp.api.vo.warehouse.WarehouseInfo;
...@@ -458,7 +459,7 @@ public class ErpSaleOrderServiceImpl implements ErpSaleOrderService { ...@@ -458,7 +459,7 @@ public class ErpSaleOrderServiceImpl implements ErpSaleOrderService {
item.setProductId(saleOrderItem.getProductId()); item.setProductId(saleOrderItem.getProductId());
item.setProductUnit(saleOrderItem.getProductUnit()); item.setProductUnit(saleOrderItem.getProductUnit());
item.setProductPrice(saleOrderItem.getProductPrice()); item.setProductPrice(saleOrderItem.getProductPrice());
item.setCount(saleOrderItem.getCount()); item.setCount(BigDecimal.valueOf(saleOrderItem.getCount()));
item.setTaxPercent(saleOrderItem.getTaxPercent()); item.setTaxPercent(saleOrderItem.getTaxPercent());
item.setRemark(saleOrderItem.getRemark()); item.setRemark(saleOrderItem.getRemark());
item.setCustomerOrderItemId(saleOrderItem.getCustomerOrderItemId()); item.setCustomerOrderItemId(saleOrderItem.getCustomerOrderItemId());
...@@ -546,6 +547,7 @@ public class ErpSaleOrderServiceImpl implements ErpSaleOrderService { ...@@ -546,6 +547,7 @@ public class ErpSaleOrderServiceImpl implements ErpSaleOrderService {
.set(ErpSaleOutDO::getPickUpStatus, SaleOrderPickUpStatus.ARRIVAL.getType()) .set(ErpSaleOutDO::getPickUpStatus, SaleOrderPickUpStatus.ARRIVAL.getType())
.set(ErpSaleOutDO::getDeliveryStaffId, deliveryStaffId) .set(ErpSaleOutDO::getDeliveryStaffId, deliveryStaffId)
.set(ErpSaleOutDO::getArrivalTime, arrivalTime) .set(ErpSaleOutDO::getArrivalTime, arrivalTime)
.set(ErpSaleOutDO::getReceiptFile, reqVO.getReceiptFile())
.eq(ErpSaleOutDO::getId, saleOrder.getId())); .eq(ErpSaleOutDO::getId, saleOrder.getId()));
saleOutItemMapper.update(Wrappers.<ErpSaleOutItemDO>lambdaUpdate() saleOutItemMapper.update(Wrappers.<ErpSaleOutItemDO>lambdaUpdate()
.set(ErpSaleOutItemDO::getPickUpStatus, SaleOrderPickUpStatus.ARRIVAL.getType()) .set(ErpSaleOutItemDO::getPickUpStatus, SaleOrderPickUpStatus.ARRIVAL.getType())
...@@ -564,7 +566,7 @@ public class ErpSaleOrderServiceImpl implements ErpSaleOrderService { ...@@ -564,7 +566,7 @@ public class ErpSaleOrderServiceImpl implements ErpSaleOrderService {
updateItem.setCount(item.getSignedQuantity()); updateItem.setCount(item.getSignedQuantity());
updateItem.setRemark(item.getRemark()); updateItem.setRemark(item.getRemark());
updateItem.setRemarkFiles(item.getRemarkFiles()); updateItem.setRemarkFiles(item.getRemarkFiles());
updateItem.setTotalPrice(item.getSignedQuantity() * saleOutItem.getProductPrice()); updateItem.setTotalPrice(MoneyUtils.multiplyAndRoundToInt(item.getSignedQuantity(), saleOutItem.getProductPrice()));
updateBatch.add(updateItem); updateBatch.add(updateItem);
} }
}); });
......
...@@ -148,7 +148,7 @@ public class ErpSaleOutServiceImpl implements ErpSaleOutService { ...@@ -148,7 +148,7 @@ public class ErpSaleOutServiceImpl implements ErpSaleOutService {
} }
private void calculateTotalPrice(ErpSaleOutDO saleOut, List<ErpSaleOutItemDO> saleOutItems) { private void calculateTotalPrice(ErpSaleOutDO saleOut, List<ErpSaleOutItemDO> saleOutItems) {
saleOut.setTotalCount(getSumValue(saleOutItems, ErpSaleOutItemDO::getCount, Integer::sum)); saleOut.setTotalCount(getSumValue(saleOutItems, ErpSaleOutItemDO::getCount, BigDecimal::add));
saleOut.setTotalProductPrice(getSumValue(saleOutItems, ErpSaleOutItemDO::getTotalPrice, Integer::sum, 0)); saleOut.setTotalProductPrice(getSumValue(saleOutItems, ErpSaleOutItemDO::getTotalPrice, Integer::sum, 0));
saleOut.setTotalTaxPrice(getSumValue(saleOutItems, ErpSaleOutItemDO::getTaxPrice, BigDecimal::add, BigDecimal.ZERO)); saleOut.setTotalTaxPrice(getSumValue(saleOutItems, ErpSaleOutItemDO::getTaxPrice, BigDecimal::add, BigDecimal.ZERO));
saleOut.setTotalPrice(saleOut.getTotalProductPrice()); saleOut.setTotalPrice(saleOut.getTotalProductPrice());
...@@ -197,9 +197,9 @@ public class ErpSaleOutServiceImpl implements ErpSaleOutService { ...@@ -197,9 +197,9 @@ public class ErpSaleOutServiceImpl implements ErpSaleOutService {
Integer bizType = approve ? ErpStockRecordBizTypeEnum.SALE_OUT.getType() Integer bizType = approve ? ErpStockRecordBizTypeEnum.SALE_OUT.getType()
: ErpStockRecordBizTypeEnum.SALE_OUT_CANCEL.getType(); : ErpStockRecordBizTypeEnum.SALE_OUT_CANCEL.getType();
saleOutItems.forEach(saleOutItem -> { saleOutItems.forEach(saleOutItem -> {
Integer count = approve ? - saleOutItem.getCount() : saleOutItem.getCount(); BigDecimal count = approve ? saleOutItem.getCount().negate() : saleOutItem.getCount();
stockRecordService.createStockRecord(new ErpStockRecordCreateReqBO( stockRecordService.createStockRecord(new ErpStockRecordCreateReqBO(
saleOutItem.getProductId(), saleOutItem.getWarehouseId(), BigDecimal.valueOf(count), saleOutItem.getProductId(), saleOutItem.getWarehouseId(), count,
bizType, saleOutItem.getOutId(), saleOutItem.getId(), saleOut.getNo())); bizType, saleOutItem.getOutId(), saleOutItem.getId(), saleOut.getNo()));
}); });
} }
...@@ -223,7 +223,7 @@ public class ErpSaleOutServiceImpl implements ErpSaleOutService { ...@@ -223,7 +223,7 @@ public class ErpSaleOutServiceImpl implements ErpSaleOutService {
return convertList(list, o -> BeanUtils.toBean(o, ErpSaleOutItemDO.class, item -> { return convertList(list, o -> BeanUtils.toBean(o, ErpSaleOutItemDO.class, item -> {
// item.setProductUnit(productMap.get(item.getProductId()).getUnitName()); // item.setProductUnit(productMap.get(item.getProductId()).getUnitName());
/*MapUtils.findAndThen(productMap, item.getProductId(), product->item.setProductUnit(product.getUnitName()));*/ /*MapUtils.findAndThen(productMap, item.getProductId(), product->item.setProductUnit(product.getUnitName()));*/
item.setTotalPrice(item.getProductPrice() * item.getCount()); item.setTotalPrice(MoneyUtils.multiplyAndRoundToInt(item.getCount(), item.getProductPrice()));
if (item.getTotalPrice() == null) { if (item.getTotalPrice() == null) {
return; return;
} }
......
...@@ -5,6 +5,7 @@ import cn.hutool.core.util.ObjectUtil; ...@@ -5,6 +5,7 @@ import cn.hutool.core.util.ObjectUtil;
import cn.iocoder.foodnexus.framework.common.exception.ServiceException; import cn.iocoder.foodnexus.framework.common.exception.ServiceException;
import cn.iocoder.foodnexus.framework.common.pojo.PageResult; import cn.iocoder.foodnexus.framework.common.pojo.PageResult;
import cn.iocoder.foodnexus.framework.common.util.CommonUtil; import cn.iocoder.foodnexus.framework.common.util.CommonUtil;
import cn.iocoder.foodnexus.framework.common.util.number.MoneyUtils;
import cn.iocoder.foodnexus.framework.common.util.object.BeanUtils; import cn.iocoder.foodnexus.framework.common.util.object.BeanUtils;
import cn.iocoder.foodnexus.framework.redis.utils.RedisUtils; import cn.iocoder.foodnexus.framework.redis.utils.RedisUtils;
import cn.iocoder.foodnexus.module.erp.dal.dataobject.purchase.ErpPurchaseReturnDO; import cn.iocoder.foodnexus.module.erp.dal.dataobject.purchase.ErpPurchaseReturnDO;
...@@ -178,7 +179,7 @@ public class ErpSaleReturnServiceImpl implements ErpSaleReturnService { ...@@ -178,7 +179,7 @@ public class ErpSaleReturnServiceImpl implements ErpSaleReturnService {
} }
private void calculateTotalPrice(ErpSaleReturnDO saleReturn, List<ErpSaleReturnItemDO> saleReturnItems) { private void calculateTotalPrice(ErpSaleReturnDO saleReturn, List<ErpSaleReturnItemDO> saleReturnItems) {
saleReturn.setTotalCount(getSumValue(saleReturnItems, ErpSaleReturnItemDO::getCount, Integer::sum)); saleReturn.setTotalCount(getSumValue(saleReturnItems, ErpSaleReturnItemDO::getCount, BigDecimal::add));
saleReturn.setTotalProductPrice(getSumValue(saleReturnItems, ErpSaleReturnItemDO::getTotalPrice, Integer::sum, 0)); saleReturn.setTotalProductPrice(getSumValue(saleReturnItems, ErpSaleReturnItemDO::getTotalPrice, Integer::sum, 0));
saleReturn.setTotalTaxPrice(getSumValue(saleReturnItems, ErpSaleReturnItemDO::getTaxPrice, BigDecimal::add, BigDecimal.ZERO)); saleReturn.setTotalTaxPrice(getSumValue(saleReturnItems, ErpSaleReturnItemDO::getTaxPrice, BigDecimal::add, BigDecimal.ZERO));
saleReturn.setTotalPrice(saleReturn.getTotalProductPrice() /*+ (saleReturn.getTotalTaxPrice())*/); saleReturn.setTotalPrice(saleReturn.getTotalProductPrice() /*+ (saleReturn.getTotalTaxPrice())*/);
...@@ -235,7 +236,7 @@ public class ErpSaleReturnServiceImpl implements ErpSaleReturnService { ...@@ -235,7 +236,7 @@ public class ErpSaleReturnServiceImpl implements ErpSaleReturnService {
Integer returnsTotal = 0; Integer returnsTotal = 0;
for (ErpSaleReturnItemDO item : saleReturnItems) { for (ErpSaleReturnItemDO item : saleReturnItems) {
Long orderItemId = item.getCustomerOrderItemId(); Long orderItemId = item.getCustomerOrderItemId();
Integer returnsCount = item.getCount(); BigDecimal returnsCount = item.getCount();
if (!customerOrderItemMap.containsKey(orderItemId)) { if (!customerOrderItemMap.containsKey(orderItemId)) {
throw exception(SALERETURN_ERROR_ORDER_ITEM); throw exception(SALERETURN_ERROR_ORDER_ITEM);
} }
...@@ -243,8 +244,8 @@ public class ErpSaleReturnServiceImpl implements ErpSaleReturnService { ...@@ -243,8 +244,8 @@ public class ErpSaleReturnServiceImpl implements ErpSaleReturnService {
CustomerOrderItemDTO updateItem = new CustomerOrderItemDTO(); CustomerOrderItemDTO updateItem = new CustomerOrderItemDTO();
updateItem.setId(orderItem.getId()); updateItem.setId(orderItem.getId());
updateItem.setReturnsQuantity(returnsCount); updateItem.setReturnsQuantity(returnsCount);
updateItem.setReturnsTotal(returnsCount * orderItem.getOrderItemPrice()); updateItem.setReturnsTotal(MoneyUtils.multiplyAndRoundToInt(returnsCount, orderItem.getOrderItemPrice()));
if (orderItem.getSignedQuantity() < CommonUtil.getEls(updateItem.getReturnsQuantity(), 0)) { if (orderItem.getSignedQuantity().compareTo(CommonUtil.getEls(updateItem.getReturnsQuantity(), BigDecimal.ZERO)) < 0) {
throw exception(SALE_RETURN_COUNT_ERROR, orderItem.getProductName()); throw exception(SALE_RETURN_COUNT_ERROR, orderItem.getProductName());
} }
/*updateItem.setSignedQuantity(orderItem.getSignedQuantity() - returnsCount); /*updateItem.setSignedQuantity(orderItem.getSignedQuantity() - returnsCount);
...@@ -347,7 +348,7 @@ public class ErpSaleReturnServiceImpl implements ErpSaleReturnService { ...@@ -347,7 +348,7 @@ public class ErpSaleReturnServiceImpl implements ErpSaleReturnService {
// 2. 转化为 ErpSaleReturnItemDO 列表 // 2. 转化为 ErpSaleReturnItemDO 列表
return convertList(list, o -> BeanUtils.toBean(o, ErpSaleReturnItemDO.class, item -> { return convertList(list, o -> BeanUtils.toBean(o, ErpSaleReturnItemDO.class, item -> {
item.setProductUnit(productMap.get(item.getProductId()).getUnitName()); item.setProductUnit(productMap.get(item.getProductId()).getUnitName());
item.setTotalPrice((item.getProductPrice() * item.getCount())); item.setTotalPrice(MoneyUtils.multiplyAndRoundToInt(item.getCount(), item.getProductPrice()));
/*if (item.getTotalPrice() == null) { /*if (item.getTotalPrice() == null) {
return; return;
}*/ }*/
...@@ -582,7 +583,7 @@ public class ErpSaleReturnServiceImpl implements ErpSaleReturnService { ...@@ -582,7 +583,7 @@ public class ErpSaleReturnServiceImpl implements ErpSaleReturnService {
List<CustomerOrderItemDTO> updateItems = new ArrayList<>(); List<CustomerOrderItemDTO> updateItems = new ArrayList<>();
for (DeliveryOrderUpdateReqVO.DeliveryOrderUpdateItems item : reqVO.getOrderItems()) { for (DeliveryOrderUpdateReqVO.DeliveryOrderUpdateItems item : reqVO.getOrderItems()) {
Long orderItemId = item.getId(); Long orderItemId = item.getId();
Integer returnsCount = item.getSignedQuantity(); BigDecimal returnsCount = item.getSignedQuantity();
if (!customerOrderItemMap.containsKey(orderItemId)) { if (!customerOrderItemMap.containsKey(orderItemId)) {
throw exception(SALERETURN_ERROR_ORDER_ITEM); throw exception(SALERETURN_ERROR_ORDER_ITEM);
} }
...@@ -590,7 +591,7 @@ public class ErpSaleReturnServiceImpl implements ErpSaleReturnService { ...@@ -590,7 +591,7 @@ public class ErpSaleReturnServiceImpl implements ErpSaleReturnService {
CustomerOrderItemDTO updateItem = new CustomerOrderItemDTO(); CustomerOrderItemDTO updateItem = new CustomerOrderItemDTO();
updateItem.setId(orderItem.getId()); updateItem.setId(orderItem.getId());
updateItem.setReturnsQuantity(returnsCount); updateItem.setReturnsQuantity(returnsCount);
updateItem.setReturnsTotal(returnsCount * orderItem.getOrderItemPrice()); updateItem.setReturnsTotal(MoneyUtils.multiplyAndRoundToInt(returnsCount, orderItem.getOrderItemPrice()));
updateItems.add(updateItem); updateItems.add(updateItem);
} }
...@@ -600,9 +601,9 @@ public class ErpSaleReturnServiceImpl implements ErpSaleReturnService { ...@@ -600,9 +601,9 @@ public class ErpSaleReturnServiceImpl implements ErpSaleReturnService {
List<ErpSaleReturnItemDO> saleReturnItems = saleReturnItemMapper.selectListByReturnId(saleReturn.getId()); List<ErpSaleReturnItemDO> saleReturnItems = saleReturnItemMapper.selectListByReturnId(saleReturn.getId());
Integer bizType = ErpStockRecordBizTypeEnum.SALE_RETURN.getType(); Integer bizType = ErpStockRecordBizTypeEnum.SALE_RETURN.getType();
saleReturnItems.forEach(saleReturnItem -> { saleReturnItems.forEach(saleReturnItem -> {
Integer count = saleReturnItem.getCount(); BigDecimal count = saleReturnItem.getCount();
stockRecordService.createStockRecord(new ErpStockRecordCreateReqBO( stockRecordService.createStockRecord(new ErpStockRecordCreateReqBO(
saleReturnItem.getProductId(), saleReturnItem.getWarehouseId(), BigDecimal.valueOf(count), saleReturnItem.getProductId(), saleReturnItem.getWarehouseId(), count,
bizType, saleReturnItem.getReturnId(), saleReturnItem.getId(), saleReturn.getNo())); bizType, saleReturnItem.getReturnId(), saleReturnItem.getId(), saleReturn.getNo()));
}); });
......
...@@ -3,7 +3,9 @@ package cn.iocoder.foodnexus.module.operations.controller.admin.inquireprice; ...@@ -3,7 +3,9 @@ package cn.iocoder.foodnexus.module.operations.controller.admin.inquireprice;
import cn.iocoder.foodnexus.framework.common.pojo.ImportResult; import cn.iocoder.foodnexus.framework.common.pojo.ImportResult;
import cn.iocoder.foodnexus.framework.common.util.CommonUtil; import cn.iocoder.foodnexus.framework.common.util.CommonUtil;
import cn.iocoder.foodnexus.framework.common.util.collection.MapUtils; import cn.iocoder.foodnexus.framework.common.util.collection.MapUtils;
import cn.iocoder.foodnexus.framework.common.util.number.MoneyUtils;
import cn.iocoder.foodnexus.module.erp.controller.admin.sale.vo.customer.ErpCustomerSimpleRespVO; import cn.iocoder.foodnexus.module.erp.controller.admin.sale.vo.customer.ErpCustomerSimpleRespVO;
import cn.iocoder.foodnexus.module.operations.controller.admin.inquirepriceitem.vo.InquirePriceItemExportVO;
import cn.iocoder.foodnexus.module.operations.controller.admin.inquirepriceitem.vo.InquirePriceItemImportVO; import cn.iocoder.foodnexus.module.operations.controller.admin.inquirepriceitem.vo.InquirePriceItemImportVO;
import cn.iocoder.foodnexus.module.operations.controller.admin.inquirepriceitem.vo.InquirePriceItemRespVO; import cn.iocoder.foodnexus.module.operations.controller.admin.inquirepriceitem.vo.InquirePriceItemRespVO;
import cn.iocoder.foodnexus.module.operations.controller.admin.inquirepriceitem.vo.InquirePriceItemSaveReqVO; import cn.iocoder.foodnexus.module.operations.controller.admin.inquirepriceitem.vo.InquirePriceItemSaveReqVO;
...@@ -12,6 +14,7 @@ import cn.iocoder.foodnexus.module.operations.service.inquirepriceitem.InquirePr ...@@ -12,6 +14,7 @@ import cn.iocoder.foodnexus.module.operations.service.inquirepriceitem.InquirePr
import cn.iocoder.foodnexus.module.product.service.spu.ProductSpuService; import cn.iocoder.foodnexus.module.product.service.spu.ProductSpuService;
import cn.iocoder.foodnexus.module.system.controller.admin.user.vo.user.UserImportExcelVO; import cn.iocoder.foodnexus.module.system.controller.admin.user.vo.user.UserImportExcelVO;
import cn.iocoder.foodnexus.module.system.controller.admin.user.vo.user.UserImportRespVO; import cn.iocoder.foodnexus.module.system.controller.admin.user.vo.user.UserImportRespVO;
import cn.iocoder.foodnexus.module.system.service.user.AdminUserService;
import io.swagger.v3.oas.annotations.Parameters; import io.swagger.v3.oas.annotations.Parameters;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
...@@ -62,6 +65,9 @@ public class InquirePriceController { ...@@ -62,6 +65,9 @@ public class InquirePriceController {
@Autowired @Autowired
private InquireCustomerPushService inquireCustomerPushService; private InquireCustomerPushService inquireCustomerPushService;
@Autowired
private AdminUserService userService;
@PostMapping("/create") @PostMapping("/create")
@Operation(summary = "创建询价管理") @Operation(summary = "创建询价管理")
@PreAuthorize("@ss.hasPermission('operations:inquire-price:create')") @PreAuthorize("@ss.hasPermission('operations:inquire-price:create')")
...@@ -137,8 +143,28 @@ public class InquirePriceController { ...@@ -137,8 +143,28 @@ public class InquirePriceController {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<InquirePriceDO> list = inquirePriceService.getInquirePricePage(pageReqVO).getList(); List<InquirePriceDO> list = inquirePriceService.getInquirePricePage(pageReqVO).getList();
// 导出 Excel // 导出 Excel
ExcelUtils.write(response, "询价管理.xls", "数据", InquirePriceRespVO.class, Map<String, String> nameMap = userService.getUserNicknameMap(CommonUtil.listConvertSet(list, item -> Long.parseLong(item.getCreator())));
BeanUtils.toBean(list, InquirePriceRespVO.class)); ExcelUtils.write(response, "询价管理.xls", "数据", InquirePriceExportVO.class,
BeanUtils.toBean(list, InquirePriceExportVO.class, item -> {
item.setIsPushStr(CommonUtil.isNotEmpty(item.getIsPush()) && item.getIsPush() ? "已推送" : "未推送");
item.setPushCustomerStr(String.join(",", CommonUtil.listConvert(item.getPushCustomerInfo(), ErpCustomerSimpleRespVO::getName)));
MapUtils.findAndThen(nameMap, item.getCreator(), item::setCreatorName);
}));
}
@GetMapping("/export-excel/items")
@Operation(summary = "导出询价管理items Excel")
@PreAuthorize("@ss.hasPermission('operations:inquire-price:export')")
@ApiAccessLog(operateType = EXPORT)
public void exportInquirePriceItemsExcel(@RequestParam("id") Long id,
HttpServletResponse response) throws IOException {
List<InquirePriceItemRespVO> list = BeanUtils.toBean(inquirePriceItemService.queryByInquireId(id), InquirePriceItemRespVO.class, inquireItem -> {
inquireItem.setProductName(productService.queryName(inquireItem.getProductId()));
});
ExcelUtils.write(response, "询价记录表.xls", "数据", InquirePriceItemExportVO.class, BeanUtils.toBean(list ,InquirePriceItemExportVO.class, item -> {
item.setMarketPriceYuan(MoneyUtils.fenToYuan(item.getMarketPrice()));
}));
} }
......
package cn.iocoder.foodnexus.module.operations.controller.admin.inquireprice.vo;
import cn.idev.excel.annotation.ExcelIgnoreUnannotated;
import cn.idev.excel.annotation.ExcelProperty;
import cn.iocoder.foodnexus.module.erp.controller.admin.sale.vo.customer.ErpCustomerSimpleRespVO;
import cn.iocoder.foodnexus.module.operations.controller.admin.inquirepriceitem.vo.InquirePriceItemRespVO;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.time.LocalDateTime;
import java.util.List;
@Schema(description = "管理后台 - 询价管理 Response VO")
@Data
@ExcelIgnoreUnannotated
public class InquirePriceExportVO {
@Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "16631")
@ExcelProperty("id")
private Long id;
@Schema(description = "询价主题", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四")
@ExcelProperty("询价主题")
private String inquiryName;
@Schema(description = "询价年月")
@ExcelProperty("询价年月")
private String inquiryYearMonth;
@Schema(description = "是否推送")
private Boolean isPush;
@Schema(description = "是否推送")
@ExcelProperty("是否推送")
private String isPushStr;
@Schema(description = "推送客户明细")
// @ExcelProperty("推送客户明细")
private List<ErpCustomerSimpleRespVO> pushCustomerInfo;
@ExcelProperty("推送客户明细")
private String pushCustomerStr;
@Schema(description = "创建时间")
@ExcelProperty("创建时间")
private LocalDateTime createTime;
@Schema(description = "创建人")
// @ExcelProperty("创建人")
private String creator;
@Schema(description = "创建人")
@ExcelProperty("创建人")
private String creatorName;
}
\ No newline at end of file
...@@ -40,7 +40,7 @@ public class InquirePriceRespVO { ...@@ -40,7 +40,7 @@ public class InquirePriceRespVO {
private LocalDateTime createTime; private LocalDateTime createTime;
@Schema(description = "创建人") @Schema(description = "创建人")
@ExcelProperty("创建人") // @ExcelProperty("创建人")
private String creator; private String creator;
@Schema(description = "items") @Schema(description = "items")
......
package cn.iocoder.foodnexus.module.operations.controller.admin.inquirepriceitem.vo;
import cn.idev.excel.annotation.ExcelIgnoreUnannotated;
import cn.idev.excel.annotation.ExcelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.math.BigDecimal;
import java.time.LocalDateTime;
@Schema(description = "管理后台 - 询价管理子 Response VO")
@Data
@ExcelIgnoreUnannotated
public class InquirePriceItemExportVO {
@Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "7765")
private Long id;
@Schema(description = "询价id", requiredMode = Schema.RequiredMode.REQUIRED, example = "7342")
private Long inquireId;
@Schema(description = "商品id", requiredMode = Schema.RequiredMode.REQUIRED, example = "10941")
private Long productId;
@Schema(description = "商品名称")
@ExcelProperty("商品名称")
private String productName;
@Schema(description = "商品分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "13698")
private Long categoryId;
@Schema(description = "分类名称", example = "李四")
@ExcelProperty("商品类型")
private String categoryName;
@Schema(description = "市场价,单位使用:分", example = "22500")
private Integer marketPrice;
@Schema(description = "市场价,单位使用:分", example = "22500")
@ExcelProperty("市场均价")
private BigDecimal marketPriceYuan;
@Schema(description = "商品单位")
@ExcelProperty("商品单位")
private String productUnit;
@Schema(description = "商品规格")
@ExcelProperty("商品规格")
private String productStandard;
@Schema(description = "下浮率(%)")
@ExcelProperty("下浮率(%)")
private BigDecimal floatingRate;
@Schema(description = "下浮后价格(分)", example = "2164")
@ExcelProperty("下浮后价格(分)")
private Integer floatingPrice;
@Schema(description = "创建时间")
@ExcelProperty("创建时间")
private LocalDateTime createTime;
}
\ No newline at end of file
...@@ -4,6 +4,7 @@ import jakarta.validation.constraints.NotNull; ...@@ -4,6 +4,7 @@ import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size; import jakarta.validation.constraints.Size;
import lombok.Data; import lombok.Data;
import java.math.BigDecimal;
import java.util.List; import java.util.List;
/** /**
...@@ -58,7 +59,7 @@ public class AppCustomerReturnOrderReqVO { ...@@ -58,7 +59,7 @@ public class AppCustomerReturnOrderReqVO {
* 退货数量 * 退货数量
*/ */
@NotNull(message = "退货数量不能为空") @NotNull(message = "退货数量不能为空")
private Integer returnCount; private BigDecimal returnCount;
/** /**
* 备注 * 备注
......
...@@ -68,7 +68,7 @@ public class CustomerOrderItemDTO { ...@@ -68,7 +68,7 @@ public class CustomerOrderItemDTO {
/** /**
* 签收数量 * 签收数量
*/ */
private Integer signedQuantity; private BigDecimal signedQuantity;
/** /**
* 签收总价,单位:分 * 签收总价,单位:分
*/ */
...@@ -86,7 +86,7 @@ public class CustomerOrderItemDTO { ...@@ -86,7 +86,7 @@ public class CustomerOrderItemDTO {
/** /**
* 退货数量 * 退货数量
*/ */
private Integer returnsQuantity; private BigDecimal returnsQuantity;
/** /**
* 退货总价,单位:分 * 退货总价,单位:分
*/ */
......
...@@ -7,6 +7,7 @@ import jakarta.validation.constraints.NotNull; ...@@ -7,6 +7,7 @@ import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size; import jakarta.validation.constraints.Size;
import lombok.Data; import lombok.Data;
import java.math.BigDecimal;
import java.util.List; import java.util.List;
/** /**
...@@ -27,6 +28,9 @@ public class DeliveryOrderUpdateReqVO { ...@@ -27,6 +28,9 @@ public class DeliveryOrderUpdateReqVO {
@Size(min = 1, message = "子项不能为空") @Size(min = 1, message = "子项不能为空")
private List<DeliveryOrderUpdateItems> orderItems; private List<DeliveryOrderUpdateItems> orderItems;
@Schema(description = "签收单")
private String receiptFile;
@Data @Data
public static class DeliveryOrderUpdateItems { public static class DeliveryOrderUpdateItems {
...@@ -37,7 +41,7 @@ public class DeliveryOrderUpdateReqVO { ...@@ -37,7 +41,7 @@ public class DeliveryOrderUpdateReqVO {
@Schema(description = "实际签收数量") @Schema(description = "实际签收数量")
@NotNull(message = "实际签收数量不能为空") @NotNull(message = "实际签收数量不能为空")
@Min(value = 0, message = "实际签收数量最小为0") @Min(value = 0, message = "实际签收数量最小为0")
private Integer signedQuantity; private BigDecimal signedQuantity;
@Schema(description = "说明") @Schema(description = "说明")
private String remark; private String remark;
......
...@@ -2,11 +2,13 @@ package cn.iocoder.foodnexus.module.order.controller.admin.customerorder; ...@@ -2,11 +2,13 @@ package cn.iocoder.foodnexus.module.order.controller.admin.customerorder;
import cn.iocoder.foodnexus.framework.common.util.CommonUtil; import cn.iocoder.foodnexus.framework.common.util.CommonUtil;
import cn.iocoder.foodnexus.framework.common.util.collection.MapUtils; import cn.iocoder.foodnexus.framework.common.util.collection.MapUtils;
import cn.iocoder.foodnexus.framework.common.util.number.MoneyUtils;
import cn.iocoder.foodnexus.module.erp.api.service.ErpCustomerApi; import cn.iocoder.foodnexus.module.erp.api.service.ErpCustomerApi;
import cn.iocoder.foodnexus.module.order.api.CustomerOrderApi; import cn.iocoder.foodnexus.module.order.api.CustomerOrderApi;
import cn.iocoder.foodnexus.module.order.controller.admin.customerorderitem.vo.CustomerOrderItemRespVO; import cn.iocoder.foodnexus.module.order.controller.admin.customerorderitem.vo.CustomerOrderItemRespVO;
import cn.iocoder.foodnexus.module.order.service.customerorderitem.CustomerOrderItemService; import cn.iocoder.foodnexus.module.order.service.customerorderitem.CustomerOrderItemService;
import cn.iocoder.foodnexus.module.order.service.customerorderrecord.CustomerOrderRecordService; import cn.iocoder.foodnexus.module.order.service.customerorderrecord.CustomerOrderRecordService;
import cn.iocoder.foodnexus.module.system.service.dept.DeptService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy; import org.springframework.context.annotation.Lazy;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
...@@ -57,6 +59,9 @@ public class CustomerOrderController { ...@@ -57,6 +59,9 @@ public class CustomerOrderController {
@Lazy @Lazy
private ErpCustomerApi customerApi; private ErpCustomerApi customerApi;
@Autowired
private DeptService deptService;
/* @DeleteMapping("/delete") /* @DeleteMapping("/delete")
@Operation(summary = "删除客户总订单") @Operation(summary = "删除客户总订单")
...@@ -87,6 +92,7 @@ public class CustomerOrderController { ...@@ -87,6 +92,7 @@ public class CustomerOrderController {
item.setOrderItems( item.setOrderItems(
BeanUtils.toBean(customerOrderApi.queryItemsByOrderId(item.getId()), CustomerOrderItemRespVO.class)); BeanUtils.toBean(customerOrderApi.queryItemsByOrderId(item.getId()), CustomerOrderItemRespVO.class));
item.setCustomerName(customerApi.queryNameStrById(item.getCustomerId())); item.setCustomerName(customerApi.queryNameStrById(item.getCustomerId()));
item.setCustomerDeptName(deptService.queryNameById(item.getCustomerDeptId()));
})); }));
} }
...@@ -96,8 +102,11 @@ public class CustomerOrderController { ...@@ -96,8 +102,11 @@ public class CustomerOrderController {
public CommonResult<PageResult<CustomerOrderRespVO>> getCustomerOrderPage(@Valid CustomerOrderPageReqVO pageReqVO) { public CommonResult<PageResult<CustomerOrderRespVO>> getCustomerOrderPage(@Valid CustomerOrderPageReqVO pageReqVO) {
PageResult<CustomerOrderDO> pageResult = customerOrderService.getCustomerOrderPage(pageReqVO); PageResult<CustomerOrderDO> pageResult = customerOrderService.getCustomerOrderPage(pageReqVO);
Map<Long, String> nameMap = customerApi.queryNameMapByIds(CommonUtil.listConvertSet(pageResult.getList(), CustomerOrderDO::getCustomerId)); Map<Long, String> nameMap = customerApi.queryNameMapByIds(CommonUtil.listConvertSet(pageResult.getList(), CustomerOrderDO::getCustomerId));
return success(BeanUtils.toBean(pageResult, CustomerOrderRespVO.class, item -> Map<Long, String> deptNameMap = deptService.queryNameMapByIds(CommonUtil.listConvertSet(pageResult.getList(), CustomerOrderDO::getCustomerDeptId), Boolean.TRUE);
MapUtils.findAndThen(nameMap, item.getCustomerId(), item::setCustomerName))); return success(BeanUtils.toBean(pageResult, CustomerOrderRespVO.class, item -> {
MapUtils.findAndThen(nameMap, item.getCustomerId(), item::setCustomerName);
MapUtils.findAndThen(deptNameMap, item.getCustomerDeptId(), item::setCustomerDeptName);
}));
} }
@GetMapping("/record") @GetMapping("/record")
...@@ -115,9 +124,29 @@ public class CustomerOrderController { ...@@ -115,9 +124,29 @@ public class CustomerOrderController {
HttpServletResponse response) throws IOException { HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<CustomerOrderDO> list = customerOrderService.getCustomerOrderPage(pageReqVO).getList(); List<CustomerOrderDO> list = customerOrderService.getCustomerOrderPage(pageReqVO).getList();
Map<Long, String> nameMap = customerApi.queryNameMapByIds(CommonUtil.listConvertSet(list, CustomerOrderDO::getCustomerId));
Map<Long, String> deptNameMap = deptService.queryNameMapByIds(CommonUtil.listConvertSet(list, CustomerOrderDO::getCustomerDeptId));
// 导出 Excel // 导出 Excel
ExcelUtils.write(response, "客户总订单.xls", "数据", CustomerOrderRespVO.class, ExcelUtils.write(response, "客户总订单.xls", "数据", CustomerOrderExportVO.class,
BeanUtils.toBean(list, CustomerOrderRespVO.class)); BeanUtils.toBean(list, CustomerOrderExportVO.class, item -> {
MapUtils.findAndThen(nameMap, item.getCustomerId(), item::setCustomerName);
MapUtils.findAndThen(deptNameMap, item.getCustomerDeptId(), item::setCustomerDeptName);
if (CommonUtil.isNotEmpty(item.getWarehouseInfo())) {
item.setWarehouseStr(item.getWarehouseInfo().getName());
}
if (CommonUtil.isNotEmpty(item.getAddressInfo())) {
item.setAddressStr(
String.format("%s%s%s%s",
item.getAddressInfo().getProvinceName(),
item.getAddressInfo().getCityName(),
item.getAddressInfo().getRegionName(),
item.getAddressInfo().getAddress()));
item.setContactUser(item.getAddressInfo().getContactUser());
item.setContactPhone(item.getAddressInfo().getContactPhone());
}
item.setOrderAmountYuan(MoneyUtils.fenToYuan(item.getOrderAmount()));
item.setActualAmountYuan(MoneyUtils.fenToYuan(item.getActualAmount()));
}));
} }
} }
\ No newline at end of file
package cn.iocoder.foodnexus.module.order.controller.admin.customerorder; package cn.iocoder.foodnexus.module.order.controller.admin.customerorder;
import cn.iocoder.foodnexus.framework.apilog.core.annotation.ApiAccessLog;
import cn.iocoder.foodnexus.framework.common.pojo.CommonResult; import cn.iocoder.foodnexus.framework.common.pojo.CommonResult;
import cn.iocoder.foodnexus.framework.common.pojo.PageParam;
import cn.iocoder.foodnexus.framework.common.pojo.PageResult; import cn.iocoder.foodnexus.framework.common.pojo.PageResult;
import cn.iocoder.foodnexus.framework.common.util.CommonUtil;
import cn.iocoder.foodnexus.framework.common.util.number.MoneyUtils;
import cn.iocoder.foodnexus.framework.common.util.object.BeanUtils;
import cn.iocoder.foodnexus.framework.excel.core.util.ExcelUtils;
import cn.iocoder.foodnexus.module.erp.controller.admin.product.vo.unit.ErpProductUnitPageReqVO;
import cn.iocoder.foodnexus.module.erp.controller.admin.product.vo.unit.ErpProductUnitRespVO;
import cn.iocoder.foodnexus.module.erp.dal.dataobject.product.ErpProductUnitDO;
import cn.iocoder.foodnexus.module.order.controller.admin.customerorder.vo.CustomerOrderReconExportRespVO;
import cn.iocoder.foodnexus.module.order.controller.admin.customerorder.vo.CustomerOrderReconPageReqVO; import cn.iocoder.foodnexus.module.order.controller.admin.customerorder.vo.CustomerOrderReconPageReqVO;
import cn.iocoder.foodnexus.module.order.controller.admin.customerorder.vo.CustomerOrderReconPageRespVO; import cn.iocoder.foodnexus.module.order.controller.admin.customerorder.vo.CustomerOrderReconPageRespVO;
import cn.iocoder.foodnexus.module.order.service.customerorder.CustomerOrderService; import cn.iocoder.foodnexus.module.order.service.customerorder.CustomerOrderService;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.io.IOException;
import java.util.List;
import static cn.iocoder.foodnexus.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
import static cn.iocoder.foodnexus.framework.common.pojo.CommonResult.success; import static cn.iocoder.foodnexus.framework.common.pojo.CommonResult.success;
/** /**
...@@ -34,5 +50,24 @@ public class OperCustomerOrderReconciliationController { ...@@ -34,5 +50,24 @@ public class OperCustomerOrderReconciliationController {
return success(customerOrderService.pageReconciliation(pageReqVO)); return success(customerOrderService.pageReconciliation(pageReqVO));
} }
@GetMapping("/export-excel")
@Operation(summary = "导出客户对账 Excel")
@ApiAccessLog(operateType = EXPORT)
public void exportExcel(@Valid CustomerOrderReconPageReqVO pageReqVO,
HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<CustomerOrderReconPageRespVO> list = customerOrderService.pageReconciliation(pageReqVO).getList();
// 导出 Excel
ExcelUtils.write(response, "客户对账.xls", "数据", CustomerOrderReconExportRespVO.class,
BeanUtils.toBean(list, CustomerOrderReconExportRespVO.class, item -> {
if (CommonUtil.isNotEmpty(item.getIsFinish())) {
item.setIsFinishStr(item.getIsFinish() ? "已对账" : "未对账");
} else {
item.setIsFinishStr("未对账");
}
item.setOrderAmountYuan(MoneyUtils.fenToYuan(item.getOrderAmount()));
item.setActualAmountYuan(MoneyUtils.fenToYuan(item.getActualAmount()));
}));
}
} }
package cn.iocoder.foodnexus.module.order.controller.admin.customerorder.vo;
import cn.idev.excel.annotation.ExcelIgnoreUnannotated;
import cn.idev.excel.annotation.ExcelProperty;
import cn.iocoder.foodnexus.framework.excel.core.annotations.DictFormat;
import cn.iocoder.foodnexus.framework.excel.core.convert.DictConvert;
import cn.iocoder.foodnexus.module.erp.api.vo.warehouse.WarehouseInfo;
import cn.iocoder.foodnexus.module.order.controller.admin.customerorderitem.vo.CustomerOrderItemRespVO;
import cn.iocoder.foodnexus.module.order.controller.admin.customerorderrecord.vo.CustomerOrderRecordRespVO;
import cn.iocoder.foodnexus.module.order.dto.CustomerAddressInfo;
import cn.iocoder.foodnexus.module.order.dto.CustomerOrderRemark;
import cn.iocoder.foodnexus.module.order.enums.CustomerOrderStatus;
import cn.iocoder.foodnexus.module.order.enums.DeliveryMode;
import cn.iocoder.foodnexus.module.product.api.dto.ProductInfo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;
@Schema(description = "管理后台 - 客户总订单 Response VO")
@Data
@ExcelIgnoreUnannotated
public class CustomerOrderExportVO {
@Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "19291")
// @ExcelProperty("id")
private Long id;
@Schema(description = "订单编号", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("订单编号")
private String code;
@Schema(description = "订单状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
@ExcelProperty(value = "订单状态", converter = DictConvert.class)
@DictFormat("order_customer_order_status") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中
private CustomerOrderStatus orderStatus;
@Schema(description = "客户id", requiredMode = Schema.RequiredMode.REQUIRED, example = "20189")
// @ExcelProperty("客户id")
private Long customerId;
@ExcelProperty("客户")
private String customerName;
@Schema(description = "灶点id")
private Long customerDeptId;
@Schema(description = "灶点名称")
@ExcelProperty("灶点")
private String customerDeptName;
@Schema(description = "收获仓库id", requiredMode = Schema.RequiredMode.REQUIRED, example = "27065")
// @ExcelProperty("收获仓库id")
private Long warehouseId;
@Schema(description = "收获库区id", requiredMode = Schema.RequiredMode.REQUIRED, example = "26507")
// @ExcelProperty("收获库区id")
private Long warehouseAreaId;
@Schema(description = "仓库信息")
// @ExcelProperty("仓库信息")
private WarehouseInfo warehouseInfo;
@ExcelProperty("仓库")
private String warehouseStr;
@Schema(description = "客户收货地址id")
private Long addressId;
@Schema(description = "客户收货地址info")
private CustomerAddressInfo addressInfo;
@ExcelProperty("联系人")
private String contactUser;
@ExcelProperty("联系号码")
private String contactPhone;
@ExcelProperty("收货地址")
private String addressStr;
@Schema(description = "配送模式", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty(value = "配送模式", converter = DictConvert.class)
@DictFormat("order_delivery_mode") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中
private DeliveryMode deliveryMode;
@Schema(description = "采购订单数", requiredMode = Schema.RequiredMode.REQUIRED, example = "12099")
@ExcelProperty("采购订单数")
private Integer productCount;
@Schema(description = "供应商数", example = "8062")
@ExcelProperty("供应商数")
private Integer supplierCount;
@Schema(description = "预计配送开始时间")
@ExcelProperty("预计配送开始时间")
private LocalDateTime planDeliveryStartTime;
@Schema(description = "预计配送结束时间")
@ExcelProperty("预计配送结束时间")
private LocalDateTime planDeliveryEndTime;
@Schema(description = "订单总金额(分)", requiredMode = Schema.RequiredMode.REQUIRED)
// @ExcelProperty("订单总金额(分)")
private Integer orderAmount;
@ExcelProperty("订单总金额")
private BigDecimal orderAmountYuan;
@Schema(description = "实际支付总金额(分)")
// @ExcelProperty("实际支付总金额(分)")
private Integer actualAmount;
@ExcelProperty("实际支付总金额")
private BigDecimal actualAmountYuan;
@Schema(description = "配送公司")
@ExcelProperty("配送公司")
private String operCompany;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("创建时间")
private LocalDateTime createTime;
@Schema(description = "订单备注")
private CustomerOrderRemark orderRemark;
@Schema(description = "是否已评论")
private Boolean hasScore;
@Schema(description = "是否已确认")
private Boolean hasFinish;
@Schema(description = "当前订单进度")
private List<CustomerOrderRecordRespVO> currentRecords;
@Schema(description = "商品集合(page接口返回)")
private List<ProductInfo> productInfos;
@Schema(description = "订单子项(详情接口返回)")
private List<CustomerOrderItemRespVO> orderItems;
}
\ No newline at end of file
package cn.iocoder.foodnexus.module.order.controller.admin.customerorder.vo;
import cn.idev.excel.annotation.ExcelIgnore;
import cn.idev.excel.annotation.ExcelIgnoreUnannotated;
import cn.idev.excel.annotation.ExcelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.math.BigDecimal;
/**
* @author : yanghao
* create at: 2025/11/3 16:19
* @description:
*/
@Data
@ExcelIgnoreUnannotated
public class CustomerOrderReconExportRespVO {
@Schema(description = "对账月度")
@ExcelProperty("对账月度")
private String yearMonth;
@Schema(description = "客户id")
// @ExcelProperty("客户id")
private Long customerId;
@Schema(description = "客户名称")
@ExcelProperty("客户名称")
private String customerName;
@Schema(description = "灶点id")
private Long customerDeptId;
@Schema(description = "灶点名称")
@ExcelProperty("灶点名称")
private String customerDeptName;
@Schema(description = "订单总数")
@ExcelProperty("订单总数")
private Long orderCount;
@Schema(description = "订单总金额(单位:分)")
// @ExcelProperty("订单总金额(单位:分)")
private Integer orderAmount;
@Schema(description = "应对账总金额(单位:分)")
// @ExcelProperty("应对账总金额(单位:分)")
private Integer actualAmount;
@Schema(description = "订单总金额(单位:分)")
@ExcelProperty("订单总金额(单位:元)")
private BigDecimal orderAmountYuan;
@Schema(description = "应对账总金额(单位:分)")
@ExcelProperty("应对账总金额(单位:元)")
private BigDecimal actualAmountYuan;
@Schema(description = "对账状态")
private Boolean isFinish;
@Schema(description = "对账状态")
@ExcelProperty(value = "对账状态")
private String isFinishStr;
}
...@@ -4,6 +4,8 @@ import cn.iocoder.foodnexus.framework.common.pojo.PageParam; ...@@ -4,6 +4,8 @@ import cn.iocoder.foodnexus.framework.common.pojo.PageParam;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import java.util.List;
/** /**
* @author : yanghao * @author : yanghao
* create at: 2025/11/3 16:25 * create at: 2025/11/3 16:25
...@@ -18,4 +20,10 @@ public class CustomerOrderReconPageReqVO extends PageParam { ...@@ -18,4 +20,10 @@ public class CustomerOrderReconPageReqVO extends PageParam {
@Schema(description = "客户名称") @Schema(description = "客户名称")
private String customerName; private String customerName;
@Schema(description = "订单创建者")
private Long creator;
@Schema(description = "灶点id")
private Long deptId;
} }
...@@ -32,4 +32,10 @@ public class CustomerOrderReconPageRespVO { ...@@ -32,4 +32,10 @@ public class CustomerOrderReconPageRespVO {
@Schema(description = "对账状态") @Schema(description = "对账状态")
private Boolean isFinish; private Boolean isFinish;
@Schema(description = "灶点id")
private Long customerDeptId;
@Schema(description = "灶点名称")
private String customerDeptName;
} }
...@@ -45,6 +45,9 @@ public class CustomerOrderRespVO { ...@@ -45,6 +45,9 @@ public class CustomerOrderRespVO {
@Schema(description = "灶点id") @Schema(description = "灶点id")
private Long customerDeptId; private Long customerDeptId;
@Schema(description = "灶点名称")
private String customerDeptName;
@Schema(description = "收获仓库id", requiredMode = Schema.RequiredMode.REQUIRED, example = "27065") @Schema(description = "收获仓库id", requiredMode = Schema.RequiredMode.REQUIRED, example = "27065")
@ExcelProperty("收获仓库id") @ExcelProperty("收获仓库id")
private Long warehouseId; private Long warehouseId;
...@@ -109,6 +112,9 @@ public class CustomerOrderRespVO { ...@@ -109,6 +112,9 @@ public class CustomerOrderRespVO {
@Schema(description = "是否已确认") @Schema(description = "是否已确认")
private Boolean hasFinish; private Boolean hasFinish;
@Schema(description = "签收单")
private String receiptFile;
@Schema(description = "当前订单进度") @Schema(description = "当前订单进度")
private List<CustomerOrderRecordRespVO> currentRecords; private List<CustomerOrderRecordRespVO> currentRecords;
......
...@@ -2,6 +2,8 @@ package cn.iocoder.foodnexus.module.order.controller.admin.customerorderitem.vo; ...@@ -2,6 +2,8 @@ package cn.iocoder.foodnexus.module.order.controller.admin.customerorderitem.vo;
import cn.iocoder.foodnexus.module.product.api.dto.ProductInfo; import cn.iocoder.foodnexus.module.product.api.dto.ProductInfo;
import lombok.*; import lombok.*;
import java.math.BigDecimal;
import java.util.*; import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import cn.iocoder.foodnexus.framework.common.pojo.PageParam; import cn.iocoder.foodnexus.framework.common.pojo.PageParam;
...@@ -49,7 +51,7 @@ public class CustomerOrderItemPageReqVO extends PageParam { ...@@ -49,7 +51,7 @@ public class CustomerOrderItemPageReqVO extends PageParam {
private Integer orderItemQuantity; private Integer orderItemQuantity;
@Schema(description = "签收数量") @Schema(description = "签收数量")
private Integer signedQuantity; private BigDecimal signedQuantity;
@Schema(description = "签收总价,单位:分") @Schema(description = "签收总价,单位:分")
private Integer signedTotal; private Integer signedTotal;
......
...@@ -70,7 +70,7 @@ public class CustomerOrderItemRespVO { ...@@ -70,7 +70,7 @@ public class CustomerOrderItemRespVO {
@Schema(description = "签收数量", requiredMode = Schema.RequiredMode.REQUIRED) @Schema(description = "签收数量", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("签收数量") @ExcelProperty("签收数量")
private Integer signedQuantity; private BigDecimal signedQuantity;
@Schema(description = "签收总价,单位:分", requiredMode = Schema.RequiredMode.REQUIRED) @Schema(description = "签收总价,单位:分", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("签收总价,单位:分") @ExcelProperty("签收总价,单位:分")
...@@ -80,7 +80,7 @@ public class CustomerOrderItemRespVO { ...@@ -80,7 +80,7 @@ public class CustomerOrderItemRespVO {
private CustomerOrderRemark orderRemark; private CustomerOrderRemark orderRemark;
@Schema(description = "退货数量") @Schema(description = "退货数量")
private Integer returnsQuantity; private BigDecimal returnsQuantity;
@Schema(description = "退货总价,单位:分") @Schema(description = "退货总价,单位:分")
private Integer returnsTotal; private Integer returnsTotal;
......
...@@ -3,6 +3,8 @@ package cn.iocoder.foodnexus.module.order.controller.admin.customerorderitem.vo; ...@@ -3,6 +3,8 @@ package cn.iocoder.foodnexus.module.order.controller.admin.customerorderitem.vo;
import cn.iocoder.foodnexus.module.product.api.dto.ProductInfo; import cn.iocoder.foodnexus.module.product.api.dto.ProductInfo;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*; import lombok.*;
import java.math.BigDecimal;
import java.util.*; import java.util.*;
import jakarta.validation.constraints.*; import jakarta.validation.constraints.*;
...@@ -52,7 +54,7 @@ public class CustomerOrderItemSaveReqVO { ...@@ -52,7 +54,7 @@ public class CustomerOrderItemSaveReqVO {
@Schema(description = "签收数量", requiredMode = Schema.RequiredMode.REQUIRED) @Schema(description = "签收数量", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "签收数量不能为空") @NotNull(message = "签收数量不能为空")
private Integer signedQuantity; private BigDecimal signedQuantity;
@Schema(description = "签收总价,单位:分", requiredMode = Schema.RequiredMode.REQUIRED) @Schema(description = "签收总价,单位:分", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "签收总价,单位:分不能为空") @NotNull(message = "签收总价,单位:分不能为空")
......
package cn.iocoder.foodnexus.module.order.controller.admin.supplier; package cn.iocoder.foodnexus.module.order.controller.admin.supplier;
import cn.iocoder.foodnexus.framework.apilog.core.annotation.ApiAccessLog;
import cn.iocoder.foodnexus.framework.common.pojo.CommonResult; import cn.iocoder.foodnexus.framework.common.pojo.CommonResult;
import cn.iocoder.foodnexus.framework.common.pojo.PageParam;
import cn.iocoder.foodnexus.framework.common.pojo.PageResult; import cn.iocoder.foodnexus.framework.common.pojo.PageResult;
import cn.iocoder.foodnexus.framework.common.util.CommonUtil; import cn.iocoder.foodnexus.framework.common.util.CommonUtil;
import cn.iocoder.foodnexus.framework.common.util.number.MoneyUtils;
import cn.iocoder.foodnexus.framework.common.util.object.BeanUtils; import cn.iocoder.foodnexus.framework.common.util.object.BeanUtils;
import cn.iocoder.foodnexus.framework.excel.core.util.ExcelUtils;
import cn.iocoder.foodnexus.module.erp.api.enums.ErpDeliveryStatus; import cn.iocoder.foodnexus.module.erp.api.enums.ErpDeliveryStatus;
import cn.iocoder.foodnexus.module.erp.api.service.ErpSupplierApi; import cn.iocoder.foodnexus.module.erp.api.service.ErpSupplierApi;
import cn.iocoder.foodnexus.module.erp.controller.admin.purchase.vo.order.ErpPurchaseOrderPageReqVO; import cn.iocoder.foodnexus.module.erp.controller.admin.purchase.vo.order.*;
import cn.iocoder.foodnexus.module.erp.controller.admin.purchase.vo.order.SupplierMonthOrderDetailsRespVO;
import cn.iocoder.foodnexus.module.erp.controller.admin.purchase.vo.order.SupplierMonthOrderPageReqVO;
import cn.iocoder.foodnexus.module.erp.controller.admin.purchase.vo.order.SupplierMonthOrderRespVO;
import cn.iocoder.foodnexus.module.erp.dal.dataobject.purchase.ErpPurchaseOrderDO; import cn.iocoder.foodnexus.module.erp.dal.dataobject.purchase.ErpPurchaseOrderDO;
import cn.iocoder.foodnexus.module.erp.service.purchase.ErpPurchaseOrderService; import cn.iocoder.foodnexus.module.erp.service.purchase.ErpPurchaseOrderService;
import cn.iocoder.foodnexus.module.order.controller.admin.customerorder.vo.CustomerOrderReconExportRespVO;
import cn.iocoder.foodnexus.module.order.controller.admin.customerorder.vo.CustomerOrderReconPageRespVO;
import cn.iocoder.foodnexus.module.order.dal.dataobject.customerorder.CustomerOrderDO; import cn.iocoder.foodnexus.module.order.dal.dataobject.customerorder.CustomerOrderDO;
import cn.iocoder.foodnexus.module.order.dal.dataobject.customerorderitem.CustomerOrderItemDO; import cn.iocoder.foodnexus.module.order.dal.dataobject.customerorderitem.CustomerOrderItemDO;
import cn.iocoder.foodnexus.module.order.service.customerorder.CustomerOrderService; import cn.iocoder.foodnexus.module.order.service.customerorder.CustomerOrderService;
...@@ -20,12 +23,15 @@ import io.swagger.v3.oas.annotations.Operation; ...@@ -20,12 +23,15 @@ import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.io.IOException;
import java.util.List; import java.util.List;
import static cn.iocoder.foodnexus.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
import static cn.iocoder.foodnexus.framework.common.exception.util.ServiceExceptionUtil.exception; import static cn.iocoder.foodnexus.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.foodnexus.framework.common.pojo.CommonResult.success; import static cn.iocoder.foodnexus.framework.common.pojo.CommonResult.success;
import static cn.iocoder.foodnexus.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; import static cn.iocoder.foodnexus.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
...@@ -66,12 +72,56 @@ public class OperaSupplierPurchaseOrderController { ...@@ -66,12 +72,56 @@ public class OperaSupplierPurchaseOrderController {
orderPageReqVo.setPageSize(pageReqVO.getPageSize()); orderPageReqVo.setPageSize(pageReqVO.getPageSize());
orderPageReqVo.setPageNo(pageReqVO.getPageNo()); orderPageReqVo.setPageNo(pageReqVO.getPageNo());
orderPageReqVo.setSupplierId(pageReqVO.getSupplierId()); orderPageReqVo.setSupplierId(pageReqVO.getSupplierId());
orderPageReqVo.setSupplierName(pageReqVO.getSupplierName());
orderPageReqVo.setCreateMonth(pageReqVO.getMonth()); orderPageReqVo.setCreateMonth(pageReqVO.getMonth());
orderPageReqVo.setDeliveryStatusList(CommonUtil.asList(ErpDeliveryStatus.ARRIVAL.getStatus(), ErpDeliveryStatus.RECONCILIATION.getStatus())); orderPageReqVo.setDeliveryStatusList(CommonUtil.asList(ErpDeliveryStatus.ARRIVAL.getStatus(), ErpDeliveryStatus.RECONCILIATION.getStatus()));
PageResult<ErpPurchaseOrderDO> pageResult = purchaseOrderService.getPurchaseOrderPage(orderPageReqVo); PageResult<ErpPurchaseOrderDO> pageResult = purchaseOrderService.getPurchaseOrderPage(orderPageReqVo);
return success(BeanUtils.toBean(pageResult, SupplierMonthOrderDetailsRespVO.class, this::transform)); return success(BeanUtils.toBean(pageResult, SupplierMonthOrderDetailsRespVO.class, this::transform));
} }
@GetMapping("/page-month/export-excel")
@Operation(summary = "导出月度账单 Excel")
@ApiAccessLog(operateType = EXPORT)
public void pageMonthExportExcel(SupplierMonthOrderPageReqVO pageReqVO,
HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<SupplierMonthOrderRespVO> list = purchaseOrderService.pageMonth(pageReqVO, null).getList();
// 导出 Excel
ExcelUtils.write(response, "月度账单.xls", "数据", SupplierMonthOrderExportVO.class,
BeanUtils.toBean(list, SupplierMonthOrderExportVO.class, item -> {
item.setOrderPriceYuan(MoneyUtils.fenToYuan(item.getOrderPrice()));
item.setPayablePriceYuan(MoneyUtils.fenToYuan(item.getPayablePrice()));
item.setStatusStr(CommonUtil.isNotEmpty(item.getStatus()) && item.getStatus() ? "已对账" : "未对账");
}));
}
@GetMapping("/page-by-month/export-excel")
@Operation(summary = "导出月度账单明细 Excel")
@ApiAccessLog(operateType = EXPORT)
public void pageByMonthExportExcel(SupplierMonthOrderPageReqVO pageReqVO,
HttpServletResponse response) throws IOException {
if (CommonUtil.isEmpty(pageReqVO.getMonth())) {
throw exception("月份不能为空");
}
ErpPurchaseOrderPageReqVO orderPageReqVo = new ErpPurchaseOrderPageReqVO();
orderPageReqVo.setPageSize(pageReqVO.getPageSize());
orderPageReqVo.setPageNo(pageReqVO.getPageNo());
orderPageReqVo.setSupplierId(pageReqVO.getSupplierId());
orderPageReqVo.setSupplierName(pageReqVO.getSupplierName());
orderPageReqVo.setCreateMonth(pageReqVO.getMonth());
orderPageReqVo.setDeliveryStatusList(CommonUtil.asList(ErpDeliveryStatus.ARRIVAL.getStatus(), ErpDeliveryStatus.RECONCILIATION.getStatus()));
PageResult<ErpPurchaseOrderDO> pageResult = purchaseOrderService.getPurchaseOrderPage(orderPageReqVo);
List<SupplierMonthOrderDetailsRespVO> list = BeanUtils.toBean(pageResult, SupplierMonthOrderDetailsRespVO.class, this::transform).getList();
// 导出 Excel
ExcelUtils.write(response, "月度账单明细.xls", "数据", SupplierMonthOrderDetailsExportVO.class,
BeanUtils.toBean(list, SupplierMonthOrderDetailsExportVO.class, item -> {
item.setDeliveryModeStr(CommonUtil.isNotEmpty(item.getDeliveryMode()) ? item.getDeliveryMode().getLabel() : "");
item.setPayablePriceYuan(MoneyUtils.fenToYuan(item.getPayablePrice()));
item.setSignedTotalYuan(MoneyUtils.fenToYuan(item.getSignedTotal()));
item.setReturnsTotalYuan(MoneyUtils.fenToYuan(item.getReturnsTotal()));
}));
}
private void transform(SupplierMonthOrderDetailsRespVO purchaseOrder) { private void transform(SupplierMonthOrderDetailsRespVO purchaseOrder) {
CustomerOrderDO customerOrder = customerOrderService.getCustomerOrder(purchaseOrder.getCustomerOrderId()); CustomerOrderDO customerOrder = customerOrderService.getCustomerOrder(purchaseOrder.getCustomerOrderId());
List<CustomerOrderItemDO> customerOrderItemDOS = customerOrderItemService.queryByOrderId(purchaseOrder.getCustomerOrderId(), purchaseOrder.getSupplierId()); List<CustomerOrderItemDO> customerOrderItemDOS = customerOrderItemService.queryByOrderId(purchaseOrder.getCustomerOrderId(), purchaseOrder.getSupplierId());
......
package cn.iocoder.foodnexus.module.order.controller.admin.supplier; package cn.iocoder.foodnexus.module.order.controller.admin.supplier;
import cn.iocoder.foodnexus.framework.apilog.core.annotation.ApiAccessLog;
import cn.iocoder.foodnexus.framework.common.enums.UserSystemEnum; import cn.iocoder.foodnexus.framework.common.enums.UserSystemEnum;
import cn.iocoder.foodnexus.framework.common.pojo.CommonResult; import cn.iocoder.foodnexus.framework.common.pojo.CommonResult;
import cn.iocoder.foodnexus.framework.common.pojo.PageParam;
import cn.iocoder.foodnexus.framework.common.pojo.PageResult; import cn.iocoder.foodnexus.framework.common.pojo.PageResult;
import cn.iocoder.foodnexus.framework.common.util.CommonUtil; import cn.iocoder.foodnexus.framework.common.util.CommonUtil;
import cn.iocoder.foodnexus.framework.common.util.number.MoneyUtils;
import cn.iocoder.foodnexus.framework.common.util.object.BeanUtils; import cn.iocoder.foodnexus.framework.common.util.object.BeanUtils;
import cn.iocoder.foodnexus.framework.excel.core.util.ExcelUtils;
import cn.iocoder.foodnexus.module.erp.api.enums.ErpDeliveryStatus; import cn.iocoder.foodnexus.module.erp.api.enums.ErpDeliveryStatus;
import cn.iocoder.foodnexus.module.erp.api.service.ErpSupplierApi; import cn.iocoder.foodnexus.module.erp.api.service.ErpSupplierApi;
import cn.iocoder.foodnexus.module.erp.controller.admin.purchase.vo.order.*; import cn.iocoder.foodnexus.module.erp.controller.admin.purchase.vo.order.*;
...@@ -19,13 +23,16 @@ import io.swagger.v3.oas.annotations.Operation; ...@@ -19,13 +23,16 @@ import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.io.IOException;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import static cn.iocoder.foodnexus.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
import static cn.iocoder.foodnexus.framework.common.exception.util.ServiceExceptionUtil.exception; import static cn.iocoder.foodnexus.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.foodnexus.framework.common.pojo.CommonResult.success; import static cn.iocoder.foodnexus.framework.common.pojo.CommonResult.success;
import static cn.iocoder.foodnexus.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; import static cn.iocoder.foodnexus.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
...@@ -109,4 +116,48 @@ public class SupplierPurchaseOrderController { ...@@ -109,4 +116,48 @@ public class SupplierPurchaseOrderController {
} }
purchaseOrder.setProductNames(productNames.toString()); purchaseOrder.setProductNames(productNames.toString());
} }
@GetMapping("/page-month/export-excel")
@Operation(summary = "导出月度账单 Excel")
@ApiAccessLog(operateType = EXPORT)
public void pageMonthExportExcel(SupplierMonthOrderPageReqVO pageReqVO,
HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<SupplierMonthOrderRespVO> list = purchaseOrderService.pageMonth(pageReqVO, supplierApi.querySupplierIdByUserId(getLoginUserId())).getList();
// 导出 Excel
ExcelUtils.write(response, "月度账单.xls", "数据", SupplierMonthOrderExportVO.class,
BeanUtils.toBean(list, SupplierMonthOrderExportVO.class, item -> {
item.setOrderPriceYuan(MoneyUtils.fenToYuan(item.getOrderPrice()));
item.setPayablePriceYuan(MoneyUtils.fenToYuan(item.getPayablePrice()));
item.setStatusStr(CommonUtil.isNotEmpty(item.getStatus()) && item.getStatus() ? "已对账" : "未对账");
}));
}
@GetMapping("/page-by-month/export-excel")
@Operation(summary = "导出月度账单明细 Excel")
@ApiAccessLog(operateType = EXPORT)
public void pageByMonthExportExcel(SupplierMonthOrderPageReqVO pageReqVO,
HttpServletResponse response) throws IOException {
if (CommonUtil.isEmpty(pageReqVO.getMonth())) {
throw exception("月份不能为空");
}
ErpPurchaseOrderPageReqVO orderPageReqVo = new ErpPurchaseOrderPageReqVO();
orderPageReqVo.setPageSize(pageReqVO.getPageSize());
orderPageReqVo.setPageNo(pageReqVO.getPageNo());
orderPageReqVo.setSupplierId(supplierApi.querySupplierIdByUserId(getLoginUserId()));
orderPageReqVo.setCreateMonth(pageReqVO.getMonth());
orderPageReqVo.setDeliveryStatusList(CommonUtil.asList(ErpDeliveryStatus.ARRIVAL.getStatus(), ErpDeliveryStatus.RECONCILIATION.getStatus()));
PageResult<ErpPurchaseOrderDO> pageResult = purchaseOrderService.getPurchaseOrderPage(orderPageReqVo);
List<SupplierMonthOrderDetailsRespVO> list = BeanUtils.toBean(pageResult, SupplierMonthOrderDetailsRespVO.class, this::transform).getList();
// 导出 Excel
ExcelUtils.write(response, "月度账单明细.xls", "数据", SupplierMonthOrderDetailsExportVO.class,
BeanUtils.toBean(list, SupplierMonthOrderDetailsExportVO.class, item -> {
item.setDeliveryModeStr(CommonUtil.isNotEmpty(item.getDeliveryMode()) ? item.getDeliveryMode().getLabel() : "");
item.setPayablePriceYuan(MoneyUtils.fenToYuan(item.getPayablePrice()));
item.setSignedTotalYuan(MoneyUtils.fenToYuan(item.getSignedTotal()));
item.setReturnsTotalYuan(MoneyUtils.fenToYuan(item.getReturnsTotal()));
}));
}
} }
...@@ -6,6 +6,7 @@ import jakarta.validation.constraints.Min; ...@@ -6,6 +6,7 @@ import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.NotNull;
import lombok.Data; import lombok.Data;
import java.math.BigDecimal;
import java.util.List; import java.util.List;
/** /**
...@@ -20,7 +21,7 @@ public class AppCustomerOrderReceiptRespVO { ...@@ -20,7 +21,7 @@ public class AppCustomerOrderReceiptRespVO {
private Long productId; private Long productId;
@Schema(description = "实际签收数量") @Schema(description = "实际签收数量")
private Integer signedQuantity; private BigDecimal signedQuantity;
@Schema(description = "签收总价,单位:分") @Schema(description = "签收总价,单位:分")
private Integer signedTotal; private Integer signedTotal;
...@@ -31,4 +32,7 @@ public class AppCustomerOrderReceiptRespVO { ...@@ -31,4 +32,7 @@ public class AppCustomerOrderReceiptRespVO {
@Schema(description = "相关文件") @Schema(description = "相关文件")
private List<String> remarkFiles; private List<String> remarkFiles;
@Schema(description = "签收单")
private String receiptFile;
} }
...@@ -6,6 +6,7 @@ import io.swagger.v3.oas.annotations.media.Schema; ...@@ -6,6 +6,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.NotNull;
import lombok.Data; import lombok.Data;
import java.math.BigDecimal;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.List; import java.util.List;
...@@ -77,7 +78,7 @@ public class AppCustomerOrderReturnRespVO { ...@@ -77,7 +78,7 @@ public class AppCustomerOrderReturnRespVO {
private Integer orderItemPrice; private Integer orderItemPrice;
@Schema(description = "退货数量") @Schema(description = "退货数量")
private Integer returnCount; private BigDecimal returnCount;
@Schema(description = "退货金额,单位:分") @Schema(description = "退货金额,单位:分")
private Integer returnPrice; private Integer returnPrice;
......
...@@ -124,4 +124,8 @@ public class CustomerOrderDO extends BaseDO { ...@@ -124,4 +124,8 @@ public class CustomerOrderDO extends BaseDO {
*/ */
private Boolean hasFinish; private Boolean hasFinish;
/**
* 签收单
*/
private String receiptFile;
} }
\ No newline at end of file
...@@ -81,7 +81,7 @@ public class CustomerOrderItemDO extends BaseDO { ...@@ -81,7 +81,7 @@ public class CustomerOrderItemDO extends BaseDO {
/** /**
* 签收数量 * 签收数量
*/ */
private Integer signedQuantity; private BigDecimal signedQuantity;
/** /**
* 签收总价,单位:分 * 签收总价,单位:分
*/ */
...@@ -96,7 +96,7 @@ public class CustomerOrderItemDO extends BaseDO { ...@@ -96,7 +96,7 @@ public class CustomerOrderItemDO extends BaseDO {
/** /**
* 退货数量 * 退货数量
*/ */
private Integer returnsQuantity; private BigDecimal returnsQuantity;
/** /**
* 退货总价,单位:分 * 退货总价,单位:分
*/ */
......
...@@ -17,6 +17,7 @@ import cn.iocoder.foodnexus.module.order.controller.app.customerOrder.vo.AppCust ...@@ -17,6 +17,7 @@ import cn.iocoder.foodnexus.module.order.controller.app.customerOrder.vo.AppCust
import cn.iocoder.foodnexus.module.order.controller.app.customerOrder.vo.AppCustomerYearOrderPageReqVO; import cn.iocoder.foodnexus.module.order.controller.app.customerOrder.vo.AppCustomerYearOrderPageReqVO;
import cn.iocoder.foodnexus.module.order.dal.dataobject.customerorder.CustomerOrderDO; import cn.iocoder.foodnexus.module.order.dal.dataobject.customerorder.CustomerOrderDO;
import cn.iocoder.foodnexus.module.order.enums.CustomerOrderStatus; import cn.iocoder.foodnexus.module.order.enums.CustomerOrderStatus;
import cn.iocoder.foodnexus.module.system.dal.dataobject.dept.DeptDO;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.github.yulichang.query.MPJQueryWrapper; import com.github.yulichang.query.MPJQueryWrapper;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
...@@ -147,7 +148,10 @@ public interface CustomerOrderMapper extends BaseMapperX<CustomerOrderDO> { ...@@ -147,7 +148,10 @@ public interface CustomerOrderMapper extends BaseMapperX<CustomerOrderDO> {
default PageResult<CustomerOrderReconPageRespVO> pageReconciliation(CustomerOrderReconPageReqVO pageReqVO) { default PageResult<CustomerOrderReconPageRespVO> pageReconciliation(CustomerOrderReconPageReqVO pageReqVO) {
MPJLambdaWrapperX<CustomerOrderDO> wrapperX = new MPJLambdaWrapperX<>(); MPJLambdaWrapperX<CustomerOrderDO> wrapperX = new MPJLambdaWrapperX<>();
wrapperX.rightJoin(ErpCustomerDO.class, ErpCustomerDO::getId, CustomerOrderDO::getCustomerId); wrapperX.leftJoin(ErpCustomerDO.class, ErpCustomerDO::getId, CustomerOrderDO::getCustomerId);
wrapperX.leftJoin(DeptDO.class, DeptDO::getId, CustomerOrderDO::getCustomerDeptId);
wrapperX.select("t.customer_dept_id");
wrapperX.select("t2.name as 'customerDeptName'");
wrapperX.select("DATE_FORMAT( t.create_time, '%Y-%m' ) AS 'yearMonth'"); wrapperX.select("DATE_FORMAT( t.create_time, '%Y-%m' ) AS 'yearMonth'");
wrapperX.select("t1.id AS 'customerId'"); wrapperX.select("t1.id AS 'customerId'");
wrapperX.select("t1.NAME AS 'customerName'"); wrapperX.select("t1.NAME AS 'customerName'");
...@@ -159,6 +163,8 @@ public interface CustomerOrderMapper extends BaseMapperX<CustomerOrderDO> { ...@@ -159,6 +163,8 @@ public interface CustomerOrderMapper extends BaseMapperX<CustomerOrderDO> {
CustomerOrderStatus.FINISH.getKey(), CustomerOrderStatus.FINISH.getKey(),
CustomerOrderStatus.RETURN.getKey())); CustomerOrderStatus.RETURN.getKey()));
wrapperX.likeIfPresent(ErpCustomerDO::getName, pageReqVO.getCustomerName()); wrapperX.likeIfPresent(ErpCustomerDO::getName, pageReqVO.getCustomerName());
wrapperX.eqIfPresent(ErpCustomerDO::getCreator, pageReqVO.getCreator());
wrapperX.eqIfPresent(CustomerOrderDO::getCustomerDeptId, pageReqVO.getDeptId());
if (CommonUtil.isNotBlank(pageReqVO.getYearMonth())) { if (CommonUtil.isNotBlank(pageReqVO.getYearMonth())) {
String createMonth = pageReqVO.getYearMonth().trim(); String createMonth = pageReqVO.getYearMonth().trim();
String startOfMonth = createMonth + "-01 00:00:00"; String startOfMonth = createMonth + "-01 00:00:00";
...@@ -170,8 +176,8 @@ public interface CustomerOrderMapper extends BaseMapperX<CustomerOrderDO> { ...@@ -170,8 +176,8 @@ public interface CustomerOrderMapper extends BaseMapperX<CustomerOrderDO> {
year + "-" + (nextMonth < 10 ? "0" + nextMonth : nextMonth) + "-01 00:00:00"; year + "-" + (nextMonth < 10 ? "0" + nextMonth : nextMonth) + "-01 00:00:00";
wrapperX.between(CustomerOrderDO::getCreateTime, startOfMonth, endOfMonth); wrapperX.between(CustomerOrderDO::getCreateTime, startOfMonth, endOfMonth);
} }
wrapperX.groupBy("DATE_FORMAT( t.create_time, '%Y-%m' )", "t1.id"); wrapperX.groupBy("DATE_FORMAT( t.create_time, '%Y-%m' )", "t.customer_dept_id");
wrapperX.orderByDesc("DATE_FORMAT( t.create_time, '%Y-%m' )", "t1.id"); wrapperX.orderByDesc("DATE_FORMAT( t.create_time, '%Y-%m' )", "t.customer_dept_id");
return this.selectJoinPage(pageReqVO, CustomerOrderReconPageRespVO.class, wrapperX); return this.selectJoinPage(pageReqVO, CustomerOrderReconPageRespVO.class, wrapperX);
} }
......
...@@ -2,6 +2,7 @@ package cn.iocoder.foodnexus.module.order.service.customerorder; ...@@ -2,6 +2,7 @@ package cn.iocoder.foodnexus.module.order.service.customerorder;
import cn.iocoder.foodnexus.framework.common.enums.UserSystemEnum; import cn.iocoder.foodnexus.framework.common.enums.UserSystemEnum;
import cn.iocoder.foodnexus.framework.common.util.CommonUtil; import cn.iocoder.foodnexus.framework.common.util.CommonUtil;
import cn.iocoder.foodnexus.framework.common.util.number.MoneyUtils;
import cn.iocoder.foodnexus.framework.common.util.spring.SpringUtils; import cn.iocoder.foodnexus.framework.common.util.spring.SpringUtils;
import cn.iocoder.foodnexus.framework.redis.utils.RedisUtils; import cn.iocoder.foodnexus.framework.redis.utils.RedisUtils;
import cn.iocoder.foodnexus.framework.security.core.LoginUser; import cn.iocoder.foodnexus.framework.security.core.LoginUser;
...@@ -60,6 +61,7 @@ import jakarta.annotation.Resource; ...@@ -60,6 +61,7 @@ import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.ZoneId; import java.time.ZoneId;
import java.util.*; import java.util.*;
...@@ -275,7 +277,7 @@ public class CustomerOrderServiceImpl implements CustomerOrderService, CustomerO ...@@ -275,7 +277,7 @@ public class CustomerOrderServiceImpl implements CustomerOrderService, CustomerO
ProductInfo.class, product -> ProductInfo.class, product ->
product.setCategoryName(productCategoryService.queryNameById(product.getCategoryId())))); product.setCategoryName(productCategoryService.queryNameById(product.getCategoryId()))));
item.setProductName(item.getProductInfo().getName()); item.setProductName(item.getProductInfo().getName());
item.setSignedQuantity(0); item.setSignedQuantity(BigDecimal.ZERO);
item.setSignedTotal(0); item.setSignedTotal(0);
if (shoppingMap.containsKey(orderItem.getProductId())) { if (shoppingMap.containsKey(orderItem.getProductId())) {
item.setCustomerRemark(shoppingMap.get(orderItem.getProductId()).getRemark()); item.setCustomerRemark(shoppingMap.get(orderItem.getProductId()).getRemark());
...@@ -417,9 +419,9 @@ public class CustomerOrderServiceImpl implements CustomerOrderService, CustomerO ...@@ -417,9 +419,9 @@ public class CustomerOrderServiceImpl implements CustomerOrderService, CustomerO
remark.setRemark(saleOutItem.getRemark()); remark.setRemark(saleOutItem.getRemark());
updateItem.setOrderRemark(remark); updateItem.setOrderRemark(remark);
} else { } else {
updateItem.setSignedQuantity(customerOrderItem.getOrderItemQuantity()); updateItem.setSignedQuantity(BigDecimal.valueOf(customerOrderItem.getOrderItemQuantity()));
} }
updateItem.setSignedTotal(updateItem.getSignedQuantity() * customerOrderItem.getOrderItemPrice()); updateItem.setSignedTotal(MoneyUtils.multiplyAndRoundToInt(updateItem.getSignedQuantity(), customerOrderItem.getOrderItemPrice()));
actualAmount.updateAndGet(v -> v + updateItem.getSignedTotal()); actualAmount.updateAndGet(v -> v + updateItem.getSignedTotal());
updateBatch.add(updateItem); updateBatch.add(updateItem);
}); });
...@@ -429,6 +431,7 @@ public class CustomerOrderServiceImpl implements CustomerOrderService, CustomerO ...@@ -429,6 +431,7 @@ public class CustomerOrderServiceImpl implements CustomerOrderService, CustomerO
CustomerOrderDO updateOrder = new CustomerOrderDO(); CustomerOrderDO updateOrder = new CustomerOrderDO();
updateOrder.setId(customerOrder.getId()); updateOrder.setId(customerOrder.getId());
updateOrder.setActualAmount(actualAmount.get()); updateOrder.setActualAmount(actualAmount.get());
updateOrder.setReceiptFile(saleOut.getReceiptFile());
customerOrderMapper.updateById(updateOrder); customerOrderMapper.updateById(updateOrder);
// 更新销售单和销售出库单的状态 // 更新销售单和销售出库单的状态
...@@ -439,8 +442,7 @@ public class CustomerOrderServiceImpl implements CustomerOrderService, CustomerO ...@@ -439,8 +442,7 @@ public class CustomerOrderServiceImpl implements CustomerOrderService, CustomerO
CustomerOrderRecordEvent event = new CustomerOrderRecordEvent(); CustomerOrderRecordEvent event = new CustomerOrderRecordEvent();
event.setOrderStatus(CustomerOrderStatus.SIGN_RECEIPT); event.setOrderStatus(CustomerOrderStatus.SIGN_RECEIPT);
event.setCustomerOrderId(reqVO.getId()); event.setCustomerOrderId(reqVO.getId());
// TODO 签收单链接 event.setCopyWriter(CommonUtil.asList(saleOut.getReceiptFile()));
event.setCopyWriter(CommonUtil.asList("TODO 签收单链接"));
orderRecordApi.recordEvent(event); orderRecordApi.recordEvent(event);
} finally { } finally {
RedisUtils.unLockRds(lock); RedisUtils.unLockRds(lock);
...@@ -467,14 +469,15 @@ public class CustomerOrderServiceImpl implements CustomerOrderService, CustomerO ...@@ -467,14 +469,15 @@ public class CustomerOrderServiceImpl implements CustomerOrderService, CustomerO
return CommonUtil.listConvert(customerOrderItems, customerOrderItem -> { return CommonUtil.listConvert(customerOrderItems, customerOrderItem -> {
AppCustomerOrderReceiptRespVO result = new AppCustomerOrderReceiptRespVO(); AppCustomerOrderReceiptRespVO result = new AppCustomerOrderReceiptRespVO();
result.setProductId(customerOrderItem.getProductId()); result.setProductId(customerOrderItem.getProductId());
result.setReceiptFile(saleOut.getReceiptFile());
if (productMap.containsKey(customerOrderItem.getProductId())) { if (productMap.containsKey(customerOrderItem.getProductId())) {
ErpSaleOutItemDO saleOutItem = productMap.get(customerOrderItem.getProductId()); ErpSaleOutItemDO saleOutItem = productMap.get(customerOrderItem.getProductId());
result.setSignedQuantity(saleOutItem.getCount()); result.setSignedQuantity(saleOutItem.getCount());
result.setSignedTotal(saleOutItem.getCount() * saleOutItem.getProductPrice()); result.setSignedTotal(MoneyUtils.multiplyAndRoundToInt(saleOutItem.getCount(), saleOutItem.getProductPrice()));
result.setRemark(saleOutItem.getRemark()); result.setRemark(saleOutItem.getRemark());
result.setRemarkFiles(saleOutItem.getRemarkFiles()); result.setRemarkFiles(saleOutItem.getRemarkFiles());
} else { } else {
result.setSignedQuantity(customerOrderItem.getOrderItemQuantity()); result.setSignedQuantity(BigDecimal.valueOf(customerOrderItem.getOrderItemQuantity()));
result.setSignedTotal(customerOrderItem.getOrderItemQuantity() * customerOrderItem.getOrderItemPrice()); result.setSignedTotal(customerOrderItem.getOrderItemQuantity() * customerOrderItem.getOrderItemPrice());
} }
return result; return result;
...@@ -545,8 +548,13 @@ public class CustomerOrderServiceImpl implements CustomerOrderService, CustomerO ...@@ -545,8 +548,13 @@ public class CustomerOrderServiceImpl implements CustomerOrderService, CustomerO
ErpSaleOrderItemDO updateSaleOrderitem = new ErpSaleOrderItemDO(); ErpSaleOrderItemDO updateSaleOrderitem = new ErpSaleOrderItemDO();
updateSaleOrderitem.setId(saleOrderItemDO.getId()); updateSaleOrderitem.setId(saleOrderItemDO.getId());
updateSaleOrderitem.setPickUpStatus(SaleOrderPickUpStatus.RETURNS_PROCESS); updateSaleOrderitem.setPickUpStatus(SaleOrderPickUpStatus.RETURNS_PROCESS);
if (customerOrderItemDO.getSignedQuantity() - CommonUtil.getEls(customerOrderItemDO.getReturnsQuantity(), 0)
< item.getReturnCount()) { BigDecimal returnCount = item.getReturnCount(); // 待退数量(Integer转BigDecimal)
BigDecimal actualSigned = CommonUtil.getEls(customerOrderItemDO.getSignedQuantity(), BigDecimal.ZERO);
BigDecimal actualReturned = CommonUtil.getEls(customerOrderItemDO.getReturnsQuantity(), BigDecimal.ZERO);
// (已签 - 已退) < 待退
if (actualSigned.subtract(actualReturned).compareTo(returnCount) < 0) {
throw exception(CUSTOMER_ORDER_RETURN_COUNT_ERROR, customerOrderItemDO.getProductName()); throw exception(CUSTOMER_ORDER_RETURN_COUNT_ERROR, customerOrderItemDO.getProductName());
} }
returnItem.setOrderItemId(saleOrderItemDO.getId()); returnItem.setOrderItemId(saleOrderItemDO.getId());
......
...@@ -79,6 +79,14 @@ public class ProductSpuController { ...@@ -79,6 +79,14 @@ public class ProductSpuController {
return success(true); return success(true);
} }
@PutMapping("/pass-all")
@Operation(summary = "审核通过所有产品")
@PreAuthorize("@ss.hasPermission('product:spu:update')")
public CommonResult<Boolean> passAll() {
productSpuService.passAll();
return success(Boolean.TRUE);
}
@DeleteMapping("/delete") @DeleteMapping("/delete")
@Operation(summary = "删除商品 SPU") @Operation(summary = "删除商品 SPU")
@Parameter(name = "id", description = "编号", required = true, example = "1024") @Parameter(name = "id", description = "编号", required = true, example = "1024")
......
...@@ -155,6 +155,8 @@ public interface ProductSpuService { ...@@ -155,6 +155,8 @@ public interface ProductSpuService {
void audit(AuditCommonReqVO auditReqVO); void audit(AuditCommonReqVO auditReqVO);
void passAll();
default Map<Long, ProductSpuDO> getProductVOMap(Set<Long> longs) { default Map<Long, ProductSpuDO> getProductVOMap(Set<Long> longs) {
return this.getSpuMap(longs); return this.getSpuMap(longs);
} }
......
...@@ -144,6 +144,23 @@ public class ProductSpuServiceImpl implements ProductSpuService { ...@@ -144,6 +144,23 @@ public class ProductSpuServiceImpl implements ProductSpuService {
} }
@Override @Override
@Transactional(rollbackFor = Exception.class)
public void passAll() {
List<ProductSpuDO> productSpuDOS = productSpuMapper.selectList(Wrappers.<ProductSpuDO>lambdaQuery()
.eq(ProductSpuDO::getAuditStatus, ErpAuditStatus.PROCESS.getStatus()));
if (CommonUtil.isNotEmpty(productSpuDOS)) {
AuditCommonReqVO auditCommonReqVO = new AuditCommonReqVO();
auditCommonReqVO.setAuditReason("批量审核通过");
auditCommonReqVO.setAuditStatus(ErpAuditStatus.APPROVE.getStatus().toString());
for (ProductSpuDO item : productSpuDOS) {
auditCommonReqVO.setId(item.getId());
this.audit(auditCommonReqVO);
}
}
}
@Override
public List<ProductSpuDO> validProductList(Set<Long> ids) { public List<ProductSpuDO> validProductList(Set<Long> ids) {
if (CollUtil.isEmpty(ids)) { if (CollUtil.isEmpty(ids)) {
return Collections.emptyList(); return Collections.emptyList();
......
package cn.iocoder.foodnexus.module.system.service.dept; package cn.iocoder.foodnexus.module.system.service.dept;
import cn.iocoder.foodnexus.framework.common.util.CommonUtil;
import cn.iocoder.foodnexus.framework.common.util.collection.CollectionUtils; import cn.iocoder.foodnexus.framework.common.util.collection.CollectionUtils;
import cn.iocoder.foodnexus.framework.datapermission.core.annotation.DataPermission;
import cn.iocoder.foodnexus.module.system.controller.admin.dept.vo.dept.DeptListReqVO; import cn.iocoder.foodnexus.module.system.controller.admin.dept.vo.dept.DeptListReqVO;
import cn.iocoder.foodnexus.module.system.controller.admin.dept.vo.dept.DeptSaveReqVO; import cn.iocoder.foodnexus.module.system.controller.admin.dept.vo.dept.DeptSaveReqVO;
import cn.iocoder.foodnexus.module.system.controller.admin.dept.vo.dept.DeptSaveRespVO; import cn.iocoder.foodnexus.module.system.controller.admin.dept.vo.dept.DeptSaveRespVO;
...@@ -125,4 +127,13 @@ public interface DeptService { ...@@ -125,4 +127,13 @@ public interface DeptService {
DeptDO getTopDept(Long deptId); DeptDO getTopDept(Long deptId);
boolean isTop(Long deptId); boolean isTop(Long deptId);
String queryNameById(Long customerDeptId);
@DataPermission(enable = false)
default Map<Long, String> queryNameMapByIds(Collection<Long> ids) {
return queryNameMapByIds(ids, Boolean.FALSE);
}
Map<Long, String> queryNameMapByIds(Collection<Long> ids, boolean fullName);
} }
...@@ -297,4 +297,37 @@ public class DeptServiceImpl implements DeptService { ...@@ -297,4 +297,37 @@ public class DeptServiceImpl implements DeptService {
return DeptDO.PARENT_ID_ROOT.equals(deptDO.getParentId()); return DeptDO.PARENT_ID_ROOT.equals(deptDO.getParentId());
} }
@Override
public String queryNameById(Long customerDeptId) {
if (CommonUtil.isEmpty(customerDeptId)) {
return "";
}
return Optional.ofNullable(deptMapper.selectById(customerDeptId)).map(DeptDO::getName).orElse("");
}
@Override
@DataPermission(enable = false)
public Map<Long, String> queryNameMapByIds(Collection<Long> ids, boolean fullName) {
if (CommonUtil.isEmpty(ids)) {
return new HashMap<>();
}
return CommonUtil.listConvertMap(getDeptList(ids), DeptDO::getId, dept -> {
if (fullName) {
return recursion(dept.getName(), dept.getParentId());
} else {
return dept.getName();
}
});
}
private String recursion(String deptName, Long parentId) {
if (DeptDO.PARENT_ID_ROOT.equals(parentId) || CommonUtil.isEmpty(parentId)) {
return deptName;
}
DeptDO parentDept = deptMapper.selectById(parentId);
if (CommonUtil.isEmpty(parentDept)) {
return deptName;
}
return recursion(String.format("%s-%s", parentDept.getName(), deptName), parentDept.getParentId());
}
} }
...@@ -2,6 +2,7 @@ package cn.iocoder.foodnexus.module.system.service.user; ...@@ -2,6 +2,7 @@ package cn.iocoder.foodnexus.module.system.service.user;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.iocoder.foodnexus.framework.common.pojo.PageResult; import cn.iocoder.foodnexus.framework.common.pojo.PageResult;
import cn.iocoder.foodnexus.framework.common.util.CommonUtil;
import cn.iocoder.foodnexus.framework.common.util.collection.CollectionUtils; import cn.iocoder.foodnexus.framework.common.util.collection.CollectionUtils;
import cn.iocoder.foodnexus.module.system.controller.admin.auth.vo.AuthRegisterReqVO; import cn.iocoder.foodnexus.module.system.controller.admin.auth.vo.AuthRegisterReqVO;
import cn.iocoder.foodnexus.module.system.controller.admin.user.vo.profile.UserProfileUpdateAvatarReqVO; import cn.iocoder.foodnexus.module.system.controller.admin.user.vo.profile.UserProfileUpdateAvatarReqVO;
...@@ -183,6 +184,13 @@ public interface AdminUserService { ...@@ -183,6 +184,13 @@ public interface AdminUserService {
return CollectionUtils.convertMap(getUserList(ids), AdminUserDO::getId); return CollectionUtils.convertMap(getUserList(ids), AdminUserDO::getId);
} }
default Map<String, String> getUserNicknameMap(Collection<Long> ids) {
if (CollUtil.isEmpty(ids)) {
return new HashMap<>();
}
return CommonUtil.listConvertMap(getUserList(ids), item->String.valueOf(item.getId()), AdminUserDO::getNickname);
}
/** /**
* 获得用户列表,基于昵称模糊匹配 * 获得用户列表,基于昵称模糊匹配
* *
......
...@@ -62,7 +62,7 @@ spring: ...@@ -62,7 +62,7 @@ spring:
host: 127.0.0.1 # 地址 host: 127.0.0.1 # 地址
port: 6379 # 端口 port: 6379 # 端口
database: 9 # 数据库索引 database: 9 # 数据库索引
# password: 123456 # 密码,建议生产环境开启 password: '@#d43ed845$%' # 密码,建议生产环境开启
--- #################### 定时任务相关配置 #################### --- #################### 定时任务相关配置 ####################
......
...@@ -47,7 +47,7 @@ spring: ...@@ -47,7 +47,7 @@ spring:
primary: master primary: master
datasource: datasource:
master: master:
url: jdbc:mysql://113.125.34.25:3306/foodnexus?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true&rewriteBatchedStatements=true # MySQL Connector/J 8.X 连接的示例 url: jdbc:mysql://140.246.96.101:3306/foodnexus?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true&rewriteBatchedStatements=true # MySQL Connector/J 8.X 连接的示例
# url: jdbc:mysql://127.0.0.1:3306/foodnexus?useSSL=true&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=true # MySQL Connector/J 5.X 连接的示例 # url: jdbc:mysql://127.0.0.1:3306/foodnexus?useSSL=true&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=true # MySQL Connector/J 5.X 连接的示例
# url: jdbc:postgresql://127.0.0.1:5432/foodnexus # PostgreSQL 连接的示例 # url: jdbc:postgresql://127.0.0.1:5432/foodnexus # PostgreSQL 连接的示例
# url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例 # url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例
...@@ -65,7 +65,7 @@ spring: ...@@ -65,7 +65,7 @@ spring:
# password: Foodnexus@2024 # OpenGauss 连接的示例 # password: Foodnexus@2024 # OpenGauss 连接的示例
slave: # 模拟从库,可根据自己需要修改 slave: # 模拟从库,可根据自己需要修改
lazy: true # 开启懒加载,保证启动速度 lazy: true # 开启懒加载,保证启动速度
url: jdbc:mysql://113.125.34.25:3306/foodnexus?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&rewriteBatchedStatements=true&nullCatalogMeansCurrent=true url: jdbc:mysql://140.246.96.101:3306/foodnexus?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&rewriteBatchedStatements=true&nullCatalogMeansCurrent=true
username: foodnexus username: foodnexus
password: X6e3ztPiWTzJpwz3 password: X6e3ztPiWTzJpwz3
# tdengine: # IoT 数据库(需要 IoT 物联网再开启噢!) # tdengine: # IoT 数据库(需要 IoT 物联网再开启噢!)
......
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