Compare commits
2 Commits
3d64b4eaac
...
3bca52f8a1
| Author | SHA1 | Date |
|---|---|---|
|
|
3bca52f8a1 | |
|
|
268b577851 |
|
|
@ -9,7 +9,7 @@ public interface ErrorCodeConstants extends cn.hangtag.module.system.enums.Erro
|
|||
ErrorCode CUSTOMER_NOT_EXISTS = new ErrorCode(3300, "客户不存在");
|
||||
ErrorCode SHAPE_TEMPLATE_NOT_EXISTS = new ErrorCode(3400, "图形模板管理 不存在");
|
||||
ErrorCode DRAFT_DESIGN_DATA_NOT_EXISTS = new ErrorCode(3500, "稿件模板数据 不存在");
|
||||
ErrorCode SALE_ORDER_NOT_EXISTS = new ErrorCode(3600, "OMS销售订单主表不存在");
|
||||
ErrorCode SALE_ORDER_NOT_EXISTS = new ErrorCode(3600, "OMS销售订单不存在");
|
||||
ErrorCode SALE_ORDER_ENTRY_NOT_EXISTS = new ErrorCode(3700, "OMS销售订单明细不存在");
|
||||
ErrorCode SALE_ORDER_ENTRY_PRICE_NOT_NULL= new ErrorCode(3701, "单价不允许为空");
|
||||
ErrorCode CUSTOMER_BRAND_NOT_EXISTS = new ErrorCode(3800, "客户和品牌关联不存在");
|
||||
|
|
|
|||
|
|
@ -17,4 +17,10 @@ public class DataComparisonRespVO<T> {
|
|||
@Schema(description = "参照数据", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
private T reference;
|
||||
|
||||
@Schema(description = "当前数据", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
private T value2;
|
||||
|
||||
@Schema(description = "参照数据", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
private T reference2;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,11 @@
|
|||
package cn.hangtag.module.oms.controller.admin.saleorder;
|
||||
|
||||
import cn.hangtag.framework.common.util.number.NumberUtils;
|
||||
import cn.hangtag.module.oms.convert.saleorder.SaleOrderConvert;
|
||||
import cn.hangtag.module.oms.dal.dataobject.customer.CustomerDO;
|
||||
import cn.hangtag.module.oms.service.customer.CustomerService;
|
||||
import cn.hangtag.module.system.api.user.AdminUserApi;
|
||||
import cn.hangtag.module.system.api.user.dto.AdminUserRespDTO;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.springframework.ui.Model;
|
||||
|
|
@ -17,6 +23,7 @@ import javax.validation.*;
|
|||
import javax.servlet.http.*;
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import cn.hangtag.framework.common.pojo.PageParam;
|
||||
import cn.hangtag.framework.common.pojo.PageResult;
|
||||
|
|
@ -42,6 +49,10 @@ public class SaleOrderController {
|
|||
|
||||
@Resource
|
||||
private SaleOrderService saleOrderService;
|
||||
@Resource
|
||||
private CustomerService customerService;
|
||||
@Resource
|
||||
private AdminUserApi adminUserApi;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建销售订单")
|
||||
|
|
@ -73,7 +84,20 @@ public class SaleOrderController {
|
|||
@PreAuthorize("@ss.hasPermission('oms:sale-order:query')")
|
||||
public CommonResult<SaleOrderRespVO> getSaleOrder(@RequestParam("id") Long id) {
|
||||
SaleOrderDO saleOrder = saleOrderService.getSaleOrder(id);
|
||||
return success(BeanUtils.toBean(saleOrder, SaleOrderRespVO.class));
|
||||
if(saleOrder == null){
|
||||
return success(null);
|
||||
}
|
||||
// 拼接数据
|
||||
List<SaleOrderEntryDO> entrys = saleOrderService.getSaleOrderEntryListByParentId(id);
|
||||
|
||||
CustomerDO customer = customerService.getCustomer(saleOrder.getCustomerId());
|
||||
// 1.2 获取修改人
|
||||
AdminUserRespDTO updater = adminUserApi.getUser(NumberUtils.parseLong(saleOrder.getUpdater()));
|
||||
AdminUserRespDTO auditor = adminUserApi.getUser(NumberUtils.parseLong(saleOrder.getAuditor()));
|
||||
|
||||
return success(SaleOrderConvert.INSTANCE.convert(saleOrder,entrys,customer,updater,auditor));
|
||||
|
||||
//return success(BeanUtils.toBean(saleOrder, SaleOrderRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
|
|
@ -153,5 +177,21 @@ public class SaleOrderController {
|
|||
public void downloadPdf(HttpServletResponse response) throws Exception{
|
||||
saleOrderService.generatePdf(response);
|
||||
}
|
||||
@PutMapping("/update-remark")
|
||||
@Operation(summary = "订单备注")
|
||||
@PreAuthorize("@ss.hasPermission('oms:sale-order:update')")
|
||||
public CommonResult<Boolean> updateOrderRemark(@RequestBody SaleOrderRemarkReqVO reqVO) {
|
||||
saleOrderService.updateOrderRemark(reqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
|
||||
@PutMapping("/update-entrys")
|
||||
@Operation(summary = "更新销售订单")
|
||||
@PreAuthorize("@ss.hasPermission('oms:sale-order:update')")
|
||||
public CommonResult<Boolean> updateSaleOrderEntry(@Valid @RequestBody SaleOrderSaveReqVO updateReqVO) {
|
||||
saleOrderService.updateSaleOrder(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -2,6 +2,8 @@ package cn.hangtag.module.oms.controller.admin.saleorder.vo;
|
|||
|
||||
import cn.hangtag.framework.excel.core.annotations.DictFormat;
|
||||
import cn.hangtag.framework.excel.core.convert.DictConvert;
|
||||
import cn.hangtag.module.oms.controller.admin.customer.vo.CustomerRespVO;
|
||||
import cn.hangtag.module.oms.dal.dataobject.customer.CustomerDO;
|
||||
import cn.hangtag.module.oms.enums.DictTypeConstants;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
|
|
@ -70,8 +72,43 @@ public class SaleOrderRespVO {
|
|||
@ExcelProperty("备注")
|
||||
private String remarks;
|
||||
|
||||
@Schema(description = "发票抬头")
|
||||
@ExcelProperty("发票抬头")
|
||||
private String invoiceCode;
|
||||
|
||||
@Schema(description = "发票名称")
|
||||
@ExcelProperty("发票名称")
|
||||
private String invoiceName;
|
||||
|
||||
@Schema(description = "发票地址")
|
||||
@ExcelProperty("发票地址")
|
||||
private String address;
|
||||
|
||||
@Schema(description = "货币")
|
||||
@ExcelProperty("货币")
|
||||
private String currency;
|
||||
|
||||
@Schema(description = "发票备注")
|
||||
@ExcelProperty("发票备注")
|
||||
private String invoiceRemarks;
|
||||
|
||||
@Schema(description = "驳回原因")
|
||||
@ExcelProperty("驳回原因")
|
||||
private String rejectReason;
|
||||
|
||||
@Schema(description = "修改人")
|
||||
private String updaterName;
|
||||
|
||||
@Schema(description = "审核人")
|
||||
|
||||
private String auditorName;
|
||||
@Schema(description = "审核时间")
|
||||
private LocalDateTime auditorTime;
|
||||
|
||||
@Schema(description = "客户")
|
||||
private CustomerRespVO customer;
|
||||
|
||||
@Schema(description = "产品明细")
|
||||
private List<cn.hangtag.module.oms.dal.dataobject.saleorderentry.SaleOrderEntryDO> entrys;
|
||||
|
||||
}
|
||||
|
|
@ -66,6 +66,6 @@ public class SaleOrderSaveReqVO {
|
|||
private String rejectReason;
|
||||
|
||||
@Schema(description = "销售订单明细列表")
|
||||
private List<SaleOrderEntryDO> saleOrderEntrys;
|
||||
private List<SaleOrderEntryDO> entrys;
|
||||
|
||||
}
|
||||
|
|
@ -2,7 +2,11 @@ package cn.hangtag.module.oms.controller.admin.trade;
|
|||
|
||||
import cn.hangtag.framework.common.pojo.CommonResult;
|
||||
import cn.hangtag.module.oms.controller.admin.common.vo.DataComparisonRespVO;
|
||||
import cn.hangtag.module.oms.controller.admin.trade.vo.TradeOrderCountRespVO;
|
||||
import cn.hangtag.module.oms.controller.admin.trade.vo.TradeOrderSummaryRespVO;
|
||||
import cn.hangtag.module.oms.controller.admin.trade.vo.TradeOrderTrendReqVO;
|
||||
import cn.hangtag.module.oms.controller.admin.trade.vo.TradeOrderTrendRespVO;
|
||||
import cn.hangtag.module.oms.enums.common.BillStatusEnum;
|
||||
import cn.hangtag.module.oms.service.saleorder.SaleOrderService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
|
|
@ -14,6 +18,9 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static cn.hangtag.framework.common.pojo.CommonResult.success;
|
||||
|
||||
|
|
@ -34,4 +41,32 @@ public class TradeStatisticsController {
|
|||
public CommonResult<DataComparisonRespVO<TradeOrderSummaryRespVO>> getOrderComparison() {
|
||||
return success(saleOrderService.getOrderComparison());
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/order-count")
|
||||
@Operation(summary = "获得交易订单数量")
|
||||
@PreAuthorize("@ss.hasPermission('statistics:trade:query')")
|
||||
public CommonResult<TradeOrderCountRespVO> getOrderCount() {
|
||||
TradeOrderCountRespVO tradeOrderCountRespVO = new TradeOrderCountRespVO();
|
||||
// 订单统计
|
||||
Long rejectCount = saleOrderService.getCountByBillStatus(BillStatusEnum.REJECT.getValue());
|
||||
Long saveCount = saleOrderService.getCountByBillStatus(BillStatusEnum.SAVE.getValue());
|
||||
Long submitCount = saleOrderService.getCountByBillStatus(BillStatusEnum.SUBMIT.getValue());
|
||||
Long auditCount = saleOrderService.getCountByBillStatus(BillStatusEnum.AUDIT.getValue());
|
||||
tradeOrderCountRespVO.setOrderCountAA(rejectCount);
|
||||
tradeOrderCountRespVO.setOrderCountA(saveCount);
|
||||
tradeOrderCountRespVO.setOrderCountB(submitCount);
|
||||
tradeOrderCountRespVO.setOrderCountC(auditCount);
|
||||
// 拼接返回
|
||||
return success(tradeOrderCountRespVO);
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/order-count-trend")
|
||||
@Operation(summary = "获得订单量趋势统计")
|
||||
@PreAuthorize("@ss.hasPermission('statistics:trade:query')")
|
||||
public CommonResult<List<DataComparisonRespVO<TradeOrderTrendRespVO>>> getOrderCountTrendComparison(@Valid TradeOrderTrendReqVO reqVO) {
|
||||
return success(saleOrderService.getOrderCountTrendComparison(reqVO));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,16 +7,16 @@ import lombok.Data;
|
|||
@Data
|
||||
public class TradeOrderCountRespVO {
|
||||
|
||||
@Schema(description = "待发货", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
private Long undelivered;
|
||||
@Schema(description = "已驳回", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
private Long orderCountAA;
|
||||
|
||||
@Schema(description = "待核销", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
private Long pickUp;
|
||||
@Schema(description = "待提交", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
private Long orderCountA;
|
||||
|
||||
@Schema(description = "退款中", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
private Long afterSaleApply;
|
||||
@Schema(description = "待审核", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
private Long orderCountB;
|
||||
|
||||
@Schema(description = "提现待审核", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
private Long auditingWithdraw;
|
||||
@Schema(description = "已完成", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
private Long orderCountC;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,14 +3,16 @@ package cn.hangtag.module.oms.controller.admin.trade.vo;
|
|||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Schema(description = "管理后台 - 交易订单统计 Response VO")
|
||||
@Data
|
||||
public class TradeOrderSummaryRespVO {
|
||||
|
||||
@Schema(description = "支付订单商品数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
private Integer orderPayCount;
|
||||
@Schema(description = "销售订单数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
private Integer orderCount;
|
||||
|
||||
@Schema(description = "总支付金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
private Integer orderPayPrice;
|
||||
@Schema(description = "销售订单额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
private BigDecimal orderAmount;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,9 +11,9 @@ public class TradeOrderTrendRespVO {
|
|||
private String date;
|
||||
|
||||
@Schema(description = "订单数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
private Integer orderPayCount;
|
||||
private Integer orderCount;
|
||||
|
||||
@Schema(description = "订单支付金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
private Integer orderPayPrice;
|
||||
@Schema(description = "订单金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
private Integer orderAmount;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,54 @@
|
|||
package cn.hangtag.module.oms.convert.saleorder;
|
||||
|
||||
|
||||
import cn.hangtag.module.oms.controller.admin.customer.vo.CustomerRespVO;
|
||||
import cn.hangtag.module.oms.controller.admin.saleorder.vo.SaleOrderRemarkReqVO;
|
||||
import cn.hangtag.module.oms.controller.admin.saleorder.vo.SaleOrderRespVO;
|
||||
import cn.hangtag.module.oms.dal.dataobject.customer.CustomerDO;
|
||||
import cn.hangtag.module.oms.dal.dataobject.saleorder.SaleOrderDO;
|
||||
import cn.hangtag.module.system.api.user.dto.AdminUserRespDTO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.Mappings;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface SaleOrderConvert {
|
||||
|
||||
SaleOrderConvert INSTANCE = Mappers.getMapper(SaleOrderConvert.class);
|
||||
@Mappings({
|
||||
// @Mapping(target = "id", ignore = true),
|
||||
@Mapping(source = "invoiceCode", target = "invoiceCode"),
|
||||
@Mapping(source = "invoiceName", target = "invoiceName"),
|
||||
@Mapping(source = "address", target = "address")
|
||||
})
|
||||
SaleOrderRespVO convert(SaleOrderDO bean);
|
||||
|
||||
|
||||
CustomerRespVO convert(CustomerDO bean);
|
||||
|
||||
|
||||
SaleOrderDO convert(SaleOrderRemarkReqVO reqVO);
|
||||
|
||||
|
||||
|
||||
default SaleOrderRespVO convert(SaleOrderDO saleOrder, List<cn.hangtag.module.oms.dal.dataobject.saleorderentry.SaleOrderEntryDO> entrys, CustomerDO customer, AdminUserRespDTO updater, AdminUserRespDTO auditor){
|
||||
|
||||
SaleOrderRespVO orderVO = convert(saleOrder);
|
||||
// 处理客户信息
|
||||
orderVO.setCustomer(convert(customer));
|
||||
if(updater!=null){
|
||||
orderVO.setUpdaterName(updater.getNickname());
|
||||
}
|
||||
if(auditor!=null){
|
||||
orderVO.setAuditorName(auditor.getNickname());
|
||||
}
|
||||
orderVO.setEntrys(entrys);
|
||||
return orderVO;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
package cn.hangtag.module.oms.dal.dataobject.saleorder;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDateTime;
|
||||
|
|
@ -74,6 +76,10 @@ public class SaleOrderDO extends BaseDO {
|
|||
* 传真
|
||||
*/
|
||||
private String fax;
|
||||
/**
|
||||
* 订单总金额
|
||||
*/
|
||||
private BigDecimal orderAmount;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
|
|
@ -106,5 +112,13 @@ public class SaleOrderDO extends BaseDO {
|
|||
* 驳回原因
|
||||
*/
|
||||
private String rejectReason;
|
||||
/**
|
||||
* 审核人
|
||||
*/
|
||||
private String auditor;
|
||||
/**
|
||||
* 审核时间
|
||||
*/
|
||||
private LocalDateTime auditorTime;
|
||||
|
||||
}
|
||||
|
|
@ -46,9 +46,17 @@ public class SaleOrderEntryDO extends BaseDO {
|
|||
* 单价
|
||||
*/
|
||||
private BigDecimal price;
|
||||
/**
|
||||
* 折扣率
|
||||
*/
|
||||
private BigDecimal discount;
|
||||
/**
|
||||
* 数量
|
||||
*/
|
||||
private Integer qty;
|
||||
/**
|
||||
* 金额
|
||||
*/
|
||||
private BigDecimal amount;
|
||||
|
||||
}
|
||||
|
|
@ -5,6 +5,7 @@ import cn.hangtag.framework.mybatis.core.mapper.BaseMapperX;
|
|||
import cn.hangtag.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.hangtag.module.oms.controller.admin.saleorder.vo.SaleOrderPageReqVO;
|
||||
import cn.hangtag.module.oms.controller.admin.trade.vo.TradeOrderSummaryRespVO;
|
||||
import cn.hangtag.module.oms.controller.admin.trade.vo.TradeOrderTrendRespVO;
|
||||
import cn.hangtag.module.oms.dal.dataobject.saleorder.SaleOrderDO;
|
||||
import cn.hangtag.module.oms.enums.saleorder.SaleOrderStatusEnum;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
|
|
@ -12,6 +13,7 @@ import org.apache.ibatis.annotations.Mapper;
|
|||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 销售订单 Mapper
|
||||
|
|
@ -68,4 +70,23 @@ public interface SaleOrderMapper extends BaseMapperX<SaleOrderDO> {
|
|||
@Param("endTime") LocalDateTime endTime);
|
||||
|
||||
|
||||
/**
|
||||
* 按照支付时间统计订单(按天分组)
|
||||
*
|
||||
* @param beginTime 支付起始时间
|
||||
* @param endTime 支付截止时间
|
||||
* @return 订单统计列表
|
||||
*/
|
||||
List<TradeOrderTrendRespVO> selectListByPayTimeBetweenAndGroupByDay(@Param("beginTime") LocalDateTime beginTime,
|
||||
@Param("endTime") LocalDateTime endTime);
|
||||
|
||||
/**
|
||||
* 按照支付时间统计订单(按月分组)
|
||||
*
|
||||
* @param beginTime 支付起始时间
|
||||
* @param endTime 支付截止时间
|
||||
* @return 订单统计列表
|
||||
*/
|
||||
List<TradeOrderTrendRespVO> selectListByPayTimeBetweenAndGroupByMonth(@Param("beginTime") LocalDateTime beginTime,
|
||||
@Param("endTime") LocalDateTime endTime);
|
||||
}
|
||||
|
|
@ -8,6 +8,8 @@ import javax.validation.*;
|
|||
import cn.hangtag.module.oms.controller.admin.common.vo.DataComparisonRespVO;
|
||||
import cn.hangtag.module.oms.controller.admin.saleorder.vo.*;
|
||||
import cn.hangtag.module.oms.controller.admin.trade.vo.TradeOrderSummaryRespVO;
|
||||
import cn.hangtag.module.oms.controller.admin.trade.vo.TradeOrderTrendReqVO;
|
||||
import cn.hangtag.module.oms.controller.admin.trade.vo.TradeOrderTrendRespVO;
|
||||
import cn.hangtag.module.oms.dal.dataobject.saleorder.SaleOrderDO;
|
||||
import cn.hangtag.module.oms.dal.dataobject.saleorderentry.SaleOrderEntryDO;
|
||||
import cn.hangtag.framework.common.pojo.PageResult;
|
||||
|
|
@ -85,4 +87,10 @@ public interface SaleOrderService {
|
|||
* @return 销售额对照
|
||||
*/
|
||||
DataComparisonRespVO<TradeOrderSummaryRespVO> getOrderComparison();
|
||||
|
||||
void updateOrderRemark(SaleOrderRemarkReqVO reqVO);
|
||||
|
||||
Long getCountByBillStatus(String value);
|
||||
|
||||
List<DataComparisonRespVO<TradeOrderTrendRespVO>> getOrderCountTrendComparison(TradeOrderTrendReqVO reqVO);
|
||||
}
|
||||
|
|
@ -4,6 +4,9 @@ import cn.hangtag.framework.common.exception.ServiceException;
|
|||
import cn.hangtag.framework.common.exception.enums.GlobalErrorCodeConstants;
|
||||
import cn.hangtag.framework.common.pojo.PageResult;
|
||||
import cn.hangtag.framework.common.util.object.BeanUtils;
|
||||
import cn.hangtag.framework.security.core.LoginUser;
|
||||
import cn.hangtag.framework.security.core.util.SecurityFrameworkUtils;
|
||||
import cn.hangtag.framework.web.core.util.WebFrameworkUtils;
|
||||
import cn.hangtag.module.oms.common.utils.NumberChineseFormatterUtils;
|
||||
import cn.hangtag.module.oms.common.utils.WKHtmlToPdfUtil;
|
||||
import cn.hangtag.module.oms.controller.admin.common.vo.DataComparisonRespVO;
|
||||
|
|
@ -11,8 +14,12 @@ import cn.hangtag.module.oms.controller.admin.produceorder.vo.ProduceOrderSaveRe
|
|||
import cn.hangtag.module.oms.controller.admin.product.vo.ProductPriceSaveReqVO;
|
||||
import cn.hangtag.module.oms.controller.admin.salecontract.vo.SaleContractSaveReqVO;
|
||||
import cn.hangtag.module.oms.controller.admin.saleorder.vo.SaleOrderPageReqVO;
|
||||
import cn.hangtag.module.oms.controller.admin.saleorder.vo.SaleOrderRemarkReqVO;
|
||||
import cn.hangtag.module.oms.controller.admin.saleorder.vo.SaleOrderSaveReqVO;
|
||||
import cn.hangtag.module.oms.controller.admin.trade.vo.TradeOrderSummaryRespVO;
|
||||
import cn.hangtag.module.oms.controller.admin.trade.vo.TradeOrderTrendReqVO;
|
||||
import cn.hangtag.module.oms.controller.admin.trade.vo.TradeOrderTrendRespVO;
|
||||
import cn.hangtag.module.oms.convert.saleorder.SaleOrderConvert;
|
||||
import cn.hangtag.module.oms.dal.dataobject.customer.CustomerDO;
|
||||
import cn.hangtag.module.oms.dal.dataobject.product.ProductPriceDO;
|
||||
import cn.hangtag.module.oms.dal.dataobject.productinfo.ProductInfoDO;
|
||||
|
|
@ -23,6 +30,7 @@ import cn.hangtag.module.oms.dal.dataobject.saleorderentry.SaleOrderEntryDO;
|
|||
import cn.hangtag.module.oms.dal.mysql.saleorder.SaleOrderMapper;
|
||||
import cn.hangtag.module.oms.dal.mysql.saleorderentry.SaleOrderEntryMapper;
|
||||
import cn.hangtag.module.oms.enums.ErrorCodeConstants;
|
||||
import cn.hangtag.module.oms.enums.TimeRangeTypeEnum;
|
||||
import cn.hangtag.module.oms.enums.common.BillStatusEnum;
|
||||
import cn.hangtag.module.oms.enums.saleorder.SaleOrderStatusEnum;
|
||||
import cn.hangtag.module.oms.service.customer.CustomerService;
|
||||
|
|
@ -30,6 +38,8 @@ import cn.hangtag.module.oms.service.produceorder.ProduceOrderService;
|
|||
import cn.hangtag.module.oms.service.product.ProductPriceService;
|
||||
import cn.hangtag.module.oms.service.productinfo.ProductInfoService;
|
||||
import cn.hangtag.module.oms.service.salecontract.SaleContractService;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
|
|
@ -46,15 +56,19 @@ import org.thymeleaf.context.Context;
|
|||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.Duration;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
import static cn.hangtag.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.hangtag.module.oms.enums.ErrorCodeConstants.SALE_ORDER_NOT_EXISTS;
|
||||
|
|
@ -94,7 +108,7 @@ public class SaleOrderServiceImpl implements SaleOrderService {
|
|||
saleOrder.setOrderStatus(SaleOrderStatusEnum.YXD.getValue());
|
||||
saleOrderMapper.insert(saleOrder);
|
||||
// 插入子表
|
||||
createSaleOrderEntryList(saleOrder.getId(), createReqVO.getSaleOrderEntrys());
|
||||
createSaleOrderEntryList(saleOrder.getId(), createReqVO.getEntrys());
|
||||
// 返回
|
||||
return saleOrder.getId();
|
||||
}
|
||||
|
|
@ -109,7 +123,7 @@ public class SaleOrderServiceImpl implements SaleOrderService {
|
|||
saleOrderMapper.updateById(updateObj);
|
||||
|
||||
// 更新子表
|
||||
updateSaleOrderEntryList(updateReqVO.getId(), updateReqVO.getSaleOrderEntrys());
|
||||
updateSaleOrderEntryList(updateReqVO.getId(), updateReqVO.getEntrys());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -208,10 +222,11 @@ public class SaleOrderServiceImpl implements SaleOrderService {
|
|||
case "audit":
|
||||
for (SaleOrderDO saleOrder : saleOrders) {
|
||||
if(BillStatusEnum.SUBMIT.getValue().equals(saleOrder.getBillStatus())){
|
||||
saleOrder.setBillStatus(BillStatusEnum.AUDIT.getValue());
|
||||
saleOrder.setOrderStatus(SaleOrderStatusEnum.YWC.getValue());
|
||||
saleOrderMapper.updateById(saleOrder);
|
||||
|
||||
List<SaleOrderEntryDO> entrys = getSaleOrderEntryListByParentId(saleOrder.getId());
|
||||
if(entrys==null||entrys.isEmpty()){
|
||||
throw new ServiceException(001,"产品明细为空");
|
||||
}
|
||||
for (cn.hangtag.module.oms.dal.dataobject.saleorderentry.SaleOrderEntryDO entry : entrys) {
|
||||
BigDecimal price = entry.getPrice();
|
||||
if(price==null){
|
||||
|
|
@ -219,6 +234,14 @@ public class SaleOrderServiceImpl implements SaleOrderService {
|
|||
}
|
||||
}
|
||||
|
||||
saleOrder.setBillStatus(BillStatusEnum.AUDIT.getValue());
|
||||
saleOrder.setOrderStatus(SaleOrderStatusEnum.YWC.getValue());
|
||||
Long userId = SecurityFrameworkUtils.getLoginUserId();
|
||||
saleOrder.setAuditor(userId.toString());
|
||||
saleOrder.setAuditorTime(LocalDateTime.now());
|
||||
saleOrderMapper.updateById(saleOrder);
|
||||
|
||||
|
||||
//生成产品单价记录
|
||||
for (cn.hangtag.module.oms.dal.dataobject.saleorderentry.SaleOrderEntryDO entry : entrys) {
|
||||
Long parentId = entry.getParentId();
|
||||
|
|
@ -354,19 +377,78 @@ public class SaleOrderServiceImpl implements SaleOrderService {
|
|||
|
||||
@Override
|
||||
public DataComparisonRespVO<TradeOrderSummaryRespVO> getOrderComparison() {
|
||||
LocalDateTime dayDate = LocalDateTime.now();
|
||||
LocalDateTime lastDayDate = LocalDateTime.now().minusDays(1);
|
||||
LocalDateTime beginWeekDate = DateUtil.beginOfWeek(DateUtil.date()).toLocalDateTime();
|
||||
LocalDateTime endWeekDate = DateUtil.endOfWeek(DateUtil.date()).toLocalDateTime();
|
||||
LocalDateTime lastBeginWeekDate = DateUtil.beginOfWeek(DateUtil.lastWeek()).toLocalDateTime();
|
||||
LocalDateTime lastEndWeekDate = DateUtil.endOfWeek(DateUtil.lastWeek()).toLocalDateTime();
|
||||
|
||||
return new DataComparisonRespVO<TradeOrderSummaryRespVO>()
|
||||
.setValue(getOrderQtySummary(LocalDateTime.now()))
|
||||
.setReference(getOrderQtySummary(LocalDateTime.now().minusDays(1)));
|
||||
.setValue(getOrderQtySummary(dayDate,dayDate))//今日
|
||||
.setReference(getOrderQtySummary(lastDayDate,lastDayDate))//昨日
|
||||
.setValue2(getOrderQtySummary(beginWeekDate,endWeekDate))//本周
|
||||
.setReference2(getOrderQtySummary(lastBeginWeekDate,lastEndWeekDate));//上周
|
||||
}
|
||||
|
||||
private TradeOrderSummaryRespVO getOrderQtySummary(LocalDateTime date) {
|
||||
LocalDateTime beginTime = LocalDateTimeUtil.beginOfDay(date);
|
||||
LocalDateTime endTime = LocalDateTimeUtil.endOfDay(date);
|
||||
@Override
|
||||
public void updateOrderRemark(SaleOrderRemarkReqVO reqVO) {
|
||||
// 校验并获得交易订单
|
||||
validateOrderExists(reqVO.getId());
|
||||
|
||||
// 更新
|
||||
SaleOrderDO order = SaleOrderConvert.INSTANCE.convert(reqVO);
|
||||
saleOrderMapper.updateById(order);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getCountByBillStatus(String billstatus) {
|
||||
return saleOrderMapper.selectCount(SaleOrderDO::getBillStatus,billstatus);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DataComparisonRespVO<TradeOrderTrendRespVO>> getOrderCountTrendComparison(TradeOrderTrendReqVO reqVO) {
|
||||
// 查询当前数据
|
||||
List<TradeOrderTrendRespVO> value = getOrderCountTrend(reqVO.getType(), reqVO.getBeginTime(), reqVO.getEndTime());
|
||||
// 查询对照数据
|
||||
LocalDateTime referenceEndTime = reqVO.getBeginTime().minusDays(1);
|
||||
LocalDateTime referenceBeginTime = referenceEndTime.minus(Duration.between(reqVO.getBeginTime(), reqVO.getEndTime()));
|
||||
List<TradeOrderTrendRespVO> reference = getOrderCountTrend(reqVO.getType(), referenceBeginTime, referenceEndTime);
|
||||
// 顺序对比返回
|
||||
return IntStream.range(0, value.size())
|
||||
.mapToObj(index -> new DataComparisonRespVO<TradeOrderTrendRespVO>()
|
||||
.setValue(CollUtil.get(value, index))
|
||||
.setReference(CollUtil.get(reference, index)))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private List<TradeOrderTrendRespVO> getOrderCountTrend(Integer timeRangeType, LocalDateTime beginTime, LocalDateTime endTime) {
|
||||
// 情况一:按年统计时,以月份分组
|
||||
if (TimeRangeTypeEnum.YEAR.getType().equals(timeRangeType)) {
|
||||
return saleOrderMapper.selectListByPayTimeBetweenAndGroupByMonth(beginTime, endTime);
|
||||
}
|
||||
// 情况二:其它以天分组(天、周、月)
|
||||
return saleOrderMapper.selectListByPayTimeBetweenAndGroupByDay(beginTime, endTime);
|
||||
}
|
||||
|
||||
private TradeOrderSummaryRespVO getOrderQtySummary(LocalDateTime beginDate,LocalDateTime endDate) {
|
||||
LocalDateTime beginTime = LocalDateTimeUtil.beginOfDay(beginDate);
|
||||
LocalDateTime endTime = LocalDateTimeUtil.endOfDay(endDate);
|
||||
return saleOrderMapper.selectOrderQtySummaryByOrderStatusAndCreateTimeBetween(
|
||||
null, beginTime, endTime);
|
||||
}
|
||||
|
||||
|
||||
@NotNull
|
||||
private SaleOrderDO validateOrderExists(Long id) {
|
||||
// 校验订单是否存在
|
||||
SaleOrderDO order = saleOrderMapper.selectById(id);
|
||||
if (order == null) {
|
||||
throw exception(SALE_ORDER_NOT_EXISTS);
|
||||
}
|
||||
return order;
|
||||
}
|
||||
|
||||
private void createSaleOrderEntryList(Long parentId, List<SaleOrderEntryDO> list) {
|
||||
list.forEach(o -> o.setParentId(parentId));
|
||||
saleOrderEntryMapper.insertBatch(list);
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@
|
|||
<select id="selectOrderQtySummaryByOrderStatusAndCreateTimeBetween"
|
||||
resultType="cn.hangtag.module.oms.controller.admin.trade.vo.TradeOrderSummaryRespVO">
|
||||
|
||||
SELECT IFNULL(SUM(0), 0) AS orderPayPrice,
|
||||
COUNT(1) AS orderPayCount
|
||||
SELECT IFNULL(SUM(0), 0) AS orderCount,
|
||||
COUNT(1) AS orderAmount
|
||||
FROM oms_saleorder
|
||||
WHERE deleted = FALSE
|
||||
<if test="orderStatus != null">
|
||||
|
|
@ -17,5 +17,32 @@
|
|||
</select>
|
||||
|
||||
|
||||
<select id="selectListByPayTimeBetweenAndGroupByDay"
|
||||
resultType="cn.hangtag.module.oms.controller.admin.trade.vo.TradeOrderTrendRespVO">
|
||||
SELECT DATE_FORMAT(create_time, '%Y-%m-%d') AS date,
|
||||
COUNT(1) AS orderCount,
|
||||
SUM(order_amount) AS orderAmount
|
||||
FROM oms_saleorder
|
||||
WHERE bill_status = 'C'
|
||||
AND create_time BETWEEN #{beginTime} AND #{endTime}
|
||||
AND deleted = FALSE
|
||||
GROUP BY date
|
||||
</select>
|
||||
|
||||
|
||||
<select id="selectListByPayTimeBetweenAndGroupByMonth"
|
||||
resultType="cn.hangtag.module.oms.controller.admin.trade.vo.TradeOrderTrendRespVO">
|
||||
|
||||
SELECT DATE_FORMAT(create_time, '%Y-%m') AS date,
|
||||
COUNT(1) AS orderCount,
|
||||
SUM(order_amount) AS orderAmount
|
||||
FROM oms_saleorder
|
||||
WHERE bill_status = 'C'
|
||||
AND create_time BETWEEN #{beginTime} AND #{endTime}
|
||||
AND deleted = FALSE
|
||||
GROUP BY date
|
||||
</select>
|
||||
|
||||
|
||||
|
||||
</mapper>
|
||||
|
|
@ -1,138 +0,0 @@
|
|||
package cn.hangtag.module.oms.service.product;
|
||||
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import cn.hangtag.framework.test.core.ut.BaseDbUnitTest;
|
||||
|
||||
import cn.hangtag.module.oms.controller.admin.product.vo.*;
|
||||
import cn.hangtag.module.oms.dal.dataobject.product.ProductPriceDO;
|
||||
import cn.hangtag.module.oms.dal.mysql.product.ProductPriceMapper;
|
||||
import cn.hangtag.framework.common.pojo.PageResult;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import java.util.*;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.hutool.core.util.RandomUtil.*;
|
||||
import static cn.hangtag.module.oms.enums.ErrorCodeConstants.*;
|
||||
import static cn.hangtag.framework.test.core.util.AssertUtils.*;
|
||||
import static cn.hangtag.framework.test.core.util.RandomUtils.*;
|
||||
import static cn.hangtag.framework.common.util.date.LocalDateTimeUtils.*;
|
||||
import static cn.hangtag.framework.common.util.object.ObjectUtils.*;
|
||||
import static cn.hangtag.framework.common.util.date.DateUtils.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
/**
|
||||
* {@link ProductPriceServiceImpl} 的单元测试类
|
||||
*
|
||||
* @author wwb
|
||||
*/
|
||||
@Import(ProductPriceServiceImpl.class)
|
||||
public class ProductPriceServiceImplTest extends BaseDbUnitTest {
|
||||
|
||||
@Resource
|
||||
private ProductPriceServiceImpl productPriceService;
|
||||
|
||||
@Resource
|
||||
private ProductPriceMapper productPriceMapper;
|
||||
|
||||
@Test
|
||||
public void testCreateProductPrice_success() {
|
||||
// 准备参数
|
||||
ProductPriceSaveReqVO createReqVO = randomPojo(ProductPriceSaveReqVO.class).setId(null);
|
||||
|
||||
// 调用
|
||||
Integer productPriceId = productPriceService.createProductPrice(createReqVO);
|
||||
// 断言
|
||||
assertNotNull(productPriceId);
|
||||
// 校验记录的属性是否正确
|
||||
ProductPriceDO productPrice = productPriceMapper.selectById(productPriceId);
|
||||
assertPojoEquals(createReqVO, productPrice, "id");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateProductPrice_success() {
|
||||
// mock 数据
|
||||
ProductPriceDO dbProductPrice = randomPojo(ProductPriceDO.class);
|
||||
productPriceMapper.insert(dbProductPrice);// @Sql: 先插入出一条存在的数据
|
||||
// 准备参数
|
||||
ProductPriceSaveReqVO updateReqVO = randomPojo(ProductPriceSaveReqVO.class, o -> {
|
||||
o.setId(dbProductPrice.getId()); // 设置更新的 ID
|
||||
});
|
||||
|
||||
// 调用
|
||||
productPriceService.updateProductPrice(updateReqVO);
|
||||
// 校验是否更新正确
|
||||
ProductPriceDO productPrice = productPriceMapper.selectById(updateReqVO.getId()); // 获取最新的
|
||||
assertPojoEquals(updateReqVO, productPrice);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateProductPrice_notExists() {
|
||||
// 准备参数
|
||||
ProductPriceSaveReqVO updateReqVO = randomPojo(ProductPriceSaveReqVO.class);
|
||||
|
||||
// 调用, 并断言异常
|
||||
assertServiceException(() -> productPriceService.updateProductPrice(updateReqVO), PRODUCT_PRICE_NOT_EXISTS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteProductPrice_success() {
|
||||
// mock 数据
|
||||
ProductPriceDO dbProductPrice = randomPojo(ProductPriceDO.class);
|
||||
productPriceMapper.insert(dbProductPrice);// @Sql: 先插入出一条存在的数据
|
||||
// 准备参数
|
||||
Integer id = dbProductPrice.getId();
|
||||
|
||||
// 调用
|
||||
productPriceService.deleteProductPrice(id);
|
||||
// 校验数据不存在了
|
||||
assertNull(productPriceMapper.selectById(id));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteProductPrice_notExists() {
|
||||
// 准备参数
|
||||
Integer id = randomIntegerId();
|
||||
|
||||
// 调用, 并断言异常
|
||||
assertServiceException(() -> productPriceService.deleteProductPrice(id), PRODUCT_PRICE_NOT_EXISTS);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
|
||||
public void testGetProductPricePage() {
|
||||
// mock 数据
|
||||
ProductPriceDO dbProductPrice = randomPojo(ProductPriceDO.class, o -> { // 等会查询到
|
||||
o.setProductId(null);
|
||||
o.setPrice(null);
|
||||
o.setCreateTime(null);
|
||||
});
|
||||
productPriceMapper.insert(dbProductPrice);
|
||||
// 测试 productId 不匹配
|
||||
productPriceMapper.insert(cloneIgnoreId(dbProductPrice, o -> o.setProductId(null)));
|
||||
// 测试 price 不匹配
|
||||
productPriceMapper.insert(cloneIgnoreId(dbProductPrice, o -> o.setPrice(null)));
|
||||
// 测试 createTime 不匹配
|
||||
productPriceMapper.insert(cloneIgnoreId(dbProductPrice, o -> o.setCreateTime(null)));
|
||||
// 准备参数
|
||||
ProductPricePageReqVO reqVO = new ProductPricePageReqVO();
|
||||
reqVO.setProductId(null);
|
||||
reqVO.setPrice(null);
|
||||
reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
|
||||
|
||||
// 调用
|
||||
PageResult<ProductPriceDO> pageResult = productPriceService.getProductPricePage(reqVO);
|
||||
// 断言
|
||||
assertEquals(1, pageResult.getTotal());
|
||||
assertEquals(1, pageResult.getList().size());
|
||||
assertPojoEquals(dbProductPrice, pageResult.getList().get(0));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -4,7 +4,7 @@ import javax.annotation.Generated;
|
|||
|
||||
@Generated(
|
||||
value = "org.mapstruct.ap.MappingProcessor",
|
||||
date = "2024-09-15T11:57:57+0800",
|
||||
date = "2024-09-22T21:13:45+0800",
|
||||
comments = "version: 1.5.5.Final, compiler: javac, environment: Java 1.8.0_401 (Oracle Corporation)"
|
||||
)
|
||||
public class OAuth2OpenConvertImpl implements OAuth2OpenConvert {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import javax.annotation.Generated;
|
|||
|
||||
@Generated(
|
||||
value = "org.mapstruct.ap.MappingProcessor",
|
||||
date = "2024-09-15T11:57:57+0800",
|
||||
date = "2024-09-22T21:13:46+0800",
|
||||
comments = "version: 1.5.5.Final, compiler: javac, environment: Java 1.8.0_401 (Oracle Corporation)"
|
||||
)
|
||||
public class SocialUserConvertImpl implements SocialUserConvert {
|
||||
|
|
|
|||
Loading…
Reference in New Issue