Commit 5d5c3614 by Jony.L

订单相关提交

parent 955b441b
package com.luhu.computility.framework.common.enums;
/**
* @Author: jony
* @Date : 2025/8/10 14:40
* @VERSION v1.0
*/
import lombok.Getter;
/**
* 交易订单类型
*/
@Getter
public enum TradeOrderTypeEnum {
TICKET_TRADE_ORDER("TO", "交易订单");
/**
* 类型
*/
private final String code;
/**
* 类型名
*/
private final String info;
TradeOrderTypeEnum(String code, String info)
{
this.code = code;
this.info = info;
}
}
package com.luhu.computility.framework.common.util.order;
import cn.hutool.core.date.DateUtil;
import com.luhu.computility.framework.common.enums.TradeOrderTypeEnum;
/**
* @Author: jony
* @Date : 2025/8/10 14:39
* @VERSION v1.0
*/
public class OrderNoUtil {
public static String generateOrderNo(TradeOrderTypeEnum orderType) {
return orderType.getCode() + DateUtil.format(DateUtil.date(), "yyyyMMddHHmmssSSS");
}
}
......@@ -10,13 +10,18 @@ import com.luhu.computility.framework.common.util.object.BeanUtils;
import com.luhu.computility.module.biz.controller.admin.bannerinfo.vo.BannerInfoPageReqVO;
import com.luhu.computility.module.biz.controller.admin.bannerinfo.vo.BannerInfoRespVO;
import com.luhu.computility.module.biz.controller.admin.computilityinformation.vo.ComputilityInformationRespVO;
import com.luhu.computility.module.biz.controller.app.index.vo.ComputeRespVO;
import com.luhu.computility.module.biz.controller.app.index.vo.BizOrderCreateReqVO;
import com.luhu.computility.module.biz.controller.app.index.vo.ResourcesDetailRespVO;
import com.luhu.computility.module.biz.controller.client.dto.MenuDTO;
import com.luhu.computility.module.biz.dal.dataobject.bannerinfo.BannerInfoDO;
import com.luhu.computility.module.biz.service.bannerinfo.BannerInfoService;
import com.luhu.computility.module.biz.service.order.OrderService;
import com.luhu.computility.module.biz.service.resources.ResourcesDetailService;
import com.luhu.computility.module.product.dal.dataobject.category.ProductCategoryDO;
import com.luhu.computility.module.product.dal.dataobject.sku.ProductSkuDO;
import com.luhu.computility.module.product.dal.dataobject.spu.ProductSpuDO;
import com.luhu.computility.module.product.enums.spu.ProductSpuStatusEnum;
import com.luhu.computility.module.product.service.category.ProductCategoryService;
import com.luhu.computility.module.product.service.sku.ProductSkuService;
import com.luhu.computility.module.product.service.spu.ProductSpuService;
import com.luhu.computility.module.system.dal.dataobject.dict.DictDataDO;
......@@ -72,6 +77,12 @@ public class ApiController {
private ProductSpuService productSpuService;
@Resource
private ProductSkuService productSkuService;
@Resource
private ProductCategoryService productCategoryService;
@Resource
private OrderService orderService;
@Resource
private ResourcesDetailService resourcesDetailService;
/*
protected final Logger logger = LoggerFactory.getLogger(this.getClass());
......@@ -142,7 +153,7 @@ public class ApiController {
@GetMapping(value = "/computilityMenu")
@ResponseBody
public CommonResult<List<MenuDTO>> computilityMenu() {
List<MenuDTO> menuDTOList = getMenus("application_category");
List<MenuDTO> menuDTOList = getMenus("computility_category");
return success(menuDTOList);
}
......@@ -163,7 +174,7 @@ public class ApiController {
*/
@GetMapping(value = "/getRListByCategory")
@ResponseBody
public CommonResult<List<ComputeRespVO>> getResourceListByCategory(@NotNull(message = "计算机资源编号不能为空") Integer categoryId) {
public CommonResult<List<ResourcesDetailRespVO>> getResourceListByCategory(@NotNull(message = "计算机资源编号不能为空") Integer categoryId) {
/**
* 根据前段传的categoryId,去product_spu表查对应的多个spu
* 每个spu会有多个对应的sku,目前都要展示出来
......@@ -179,13 +190,13 @@ public class ApiController {
.map(ProductSpuDO::getId)
.collect(Collectors.toList());
List<ProductSkuDO> skuDOList = productSkuService.getSkuListBySpuId(spuIdList);
List<ComputeRespVO> computeRespVOS = new ArrayList<ComputeRespVO>();
List<ResourcesDetailRespVO> computeRespVOS = new ArrayList<>();
for (ProductSkuDO productSkuDO : skuDOList) { //处理每个sku对应的cpu、gpu、内存、存储、时长等需要展示的字段
List<ProductSkuDO.Property> properties = productSkuDO.getProperties();
String spuName = productSpuService.getSpu(productSkuDO.getSpuId()).getName();//spuName实际上是每个服务器的名字
ComputeRespVO computeRespVO = new ComputeRespVO();
ResourcesDetailRespVO computeRespVO = new ResourcesDetailRespVO();
for (ProductSkuDO.Property property : properties) {
switch (Convert.toInt(property.getPropertyId())) {
......@@ -205,25 +216,31 @@ public class ApiController {
computeRespVO.setTerm(property.getValueName());
break;
}
computeRespVO.setId(productSkuDO.getId());
computeRespVO.setModel(spuName);
}
computeRespVO.setPublicPrice(String.format("%.2f",productSkuDO.getPrice()/100.0));
computeRespVOS.add(computeRespVO);
}
return success(computeRespVOS);
// startPage();
// BizComputility bizComputility = new BizComputility();
// bizComputility.setCategory(nav);
// Integer groundingStatus = Integer.valueOf(DictUtils.getDictValue("grounding_status", "已上架"));
// bizComputility.setGroundingStatus(groundingStatus);
//
// List<BizComputility> bizComputilities = bizComputilityService.selectBizComputilityDetailList(bizComputility);
// List<BizResourceDetail> bizResourceDetails = new ArrayList<>();
// bizComputilities.forEach(item -> {
// BizResourceDetail bizResourceDetail = bizComputilityService.bizResourceDetail(item);
// bizResourceDetails.add(bizResourceDetail);
// });
// return getDataTable(bizResourceDetails,bizComputilities);
}
/**
* 订单 - 计算机资源详情
*/
// @ApiOperation(value = "计算机资源 - 详情2",notes = "计算机资源详情2")
@GetMapping(value = "/getRDetail")
@ResponseBody
public CommonResult<ResourcesDetailRespVO> getResourceDetail(@Param(value = "id") @NotNull(message = "计算机资源编号不能为空") Long id){
ProductSkuDO skuDO = productSkuService.getSku(id);
ResourcesDetailRespVO resourcesDetailBySkuDO = resourcesDetailService.getResourcesDetailBySkuDO(skuDO);
return success(resourcesDetailBySkuDO);
}
@PostMapping(value = "/bizOrderSubmit")
public CommonResult<Long> bizOrderSubmit(BizOrderCreateReqVO bizOrderCreateReqVO){
Long skuId = bizOrderCreateReqVO.getSkuId();
orderService.bizOrderSubmit(skuId);
return null;
}
// *//**
// *行业应用二级菜单
......@@ -311,6 +328,7 @@ public class ApiController {
// return R.ok(detail);
// }else {
// return R.fail("无法获取详情,请重试!");
// }
// }
//
......@@ -364,19 +382,9 @@ public class ApiController {
// List<BizPartner> bizPartners = bizPartnerService.selectBizPartnerList(bizPartner);
// return R.ok(bizPartners);
// }
//
//
// *//**
// * 订单 - 计算机资源详情
// *//*
// @ApiOperation(value = "计算机资源 - 详情2",notes = "计算机资源详情2")
// @GetMapping(value = "/getRDetail")
// @ResponseBody
// public R<BizResourceDetailRespVO> getResourceDetail(@Param(value = "id") @NotNull(message = "计算机资源编号不能为空") Long id){
// BizResourceDetailRespVO getResourceDetail = bizComputilityService.getResourceDetail(id);
// return R.ok(getResourceDetail);
// }
//
// *//**
// * 订单-我的订单列表
......
package com.luhu.computility.module.biz.controller.app.index.vo;
import lombok.Data;
/**
* @Author: jony
* @Date : 2025/8/11 14:13
* @VERSION v1.0
*/
@Data
public class BizOrderCreateReqVO {
private Long skuId;
}
package com.luhu.computility.module.biz.controller.app.index.vo;
import lombok.Data;
/**
* @Author: jony
* @Date : 2025/8/10 15:35
* @VERSION v1.0
*/
@Data
public class ResourcesDetailBackRespVO {
private Long id;
private Long category;
private String model;
private Long cpu;
private Long gpu;
private Long memory;
private Long storage;
private Long term;
private String publicPrice;
}
......@@ -10,18 +10,36 @@ import lombok.Data;
* @VERSION v1.0
*/
@Data
public class ComputeRespVO {
public class ResourcesDetailRespVO {
private Long id;//skuId
private Integer categoryId;
private String category;
private Integer modelId;
private String model;
private Integer cpuId;
private String cpu;
private Integer gpuId;
private String gpu;
private Integer memoryId;
private String memory;
private Integer storageId;
private String storage;
private Integer termId;
private String term;
private String publicPrice;
......
package com.luhu.computility.module.biz.controller.app.order;
import com.luhu.computility.module.biz.controller.app.order.vo.OrderPageReqVO;
import com.luhu.computility.module.biz.controller.app.order.vo.OrderRespVO;
import com.luhu.computility.module.biz.controller.app.order.vo.OrderSaveReqVO;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;
import javax.validation.*;
import javax.servlet.http.*;
import java.util.*;
import java.io.IOException;
import com.luhu.computility.framework.common.pojo.PageParam;
import com.luhu.computility.framework.common.pojo.PageResult;
import com.luhu.computility.framework.common.pojo.CommonResult;
import com.luhu.computility.framework.common.util.object.BeanUtils;
import static com.luhu.computility.framework.common.pojo.CommonResult.success;
import com.luhu.computility.framework.excel.core.util.ExcelUtils;
import com.luhu.computility.framework.apilog.core.annotation.ApiAccessLog;
import static com.luhu.computility.framework.apilog.core.enums.OperateTypeEnum.*;
import com.luhu.computility.module.biz.controller.app.order.vo.*;
import com.luhu.computility.module.biz.dal.dataobject.order.OrderDO;
import com.luhu.computility.module.biz.service.order.OrderService;
@Tag(name = "管理后台 - 订单管理-需求单管理")
@RestController
@RequestMapping("/biz/order")
@Validated
public class OrderController {
@Resource
private OrderService orderService;
@PostMapping("/create")
@Operation(summary = "创建订单管理-需求单管理")
@PreAuthorize("@ss.hasPermission('biz:order:create')")
public CommonResult<Long> createOrder(@Valid @RequestBody OrderSaveReqVO createReqVO) {
return success(orderService.createOrder(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新订单管理-需求单管理")
@PreAuthorize("@ss.hasPermission('biz:order:update')")
public CommonResult<Boolean> updateOrder(@Valid @RequestBody OrderSaveReqVO updateReqVO) {
orderService.updateOrder(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除订单管理-需求单管理")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('biz:order:delete')")
public CommonResult<Boolean> deleteOrder(@RequestParam("id") Long id) {
orderService.deleteOrder(id);
return success(true);
}
@DeleteMapping("/delete-list")
@Parameter(name = "ids", description = "编号", required = true)
@Operation(summary = "批量删除订单管理-需求单管理")
@PreAuthorize("@ss.hasPermission('biz:order:delete')")
public CommonResult<Boolean> deleteOrderList(@RequestParam("ids") List<Long> ids) {
orderService.deleteOrderListByIds(ids);
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得订单管理-需求单管理")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('biz:order:query')")
public CommonResult<OrderRespVO> getOrder(@RequestParam("id") Long id) {
OrderDO order = orderService.getOrder(id);
return success(BeanUtils.toBean(order, OrderRespVO.class));
}
@GetMapping("/page")
@Operation(summary = "获得订单管理-需求单管理分页")
@PreAuthorize("@ss.hasPermission('biz:order:query')")
public CommonResult<PageResult<OrderRespVO>> getOrderPage(@Valid OrderPageReqVO pageReqVO) {
PageResult<OrderDO> pageResult = orderService.getOrderPage(pageReqVO);
return success(BeanUtils.toBean(pageResult, OrderRespVO.class));
}
@GetMapping("/export-excel")
@Operation(summary = "导出订单管理-需求单管理 Excel")
@PreAuthorize("@ss.hasPermission('biz:order:export')")
@ApiAccessLog(operateType = EXPORT)
public void exportOrderExcel(@Valid OrderPageReqVO pageReqVO,
HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<OrderDO> list = orderService.getOrderPage(pageReqVO).getList();
// 导出 Excel
ExcelUtils.write(response, "订单管理-需求单管理.xls", "数据", OrderRespVO.class,
BeanUtils.toBean(list, OrderRespVO.class));
}
}
\ No newline at end of file
package com.luhu.computility.module.biz.controller.app.order.vo;
import lombok.*;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
import com.luhu.computility.framework.common.pojo.PageParam;
import java.math.BigDecimal;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import static com.luhu.computility.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "管理后台 - 订单管理-需求单管理分页 Request VO")
@Data
public class OrderPageReqVO extends PageParam {
@Schema(description = "订单编号")
private String orderNo;
@Schema(description = "商品类别")
private Boolean category;
@Schema(description = "型号")
private Boolean model;
@Schema(description = "CPU")
private Boolean cpu;
@Schema(description = "GPU")
private Boolean gpu;
@Schema(description = "内存")
private Boolean memory;
@Schema(description = "存储硬盘")
private Boolean storage;
@Schema(description = "算力金额", example = "26427")
private BigDecimal price;
@Schema(description = "状态:0-已确认,1-审核中,2-已驳回,3-已取消", example = "2")
private Boolean orderStatus;
@Schema(description = "网络带宽(M)", example = "183")
private Long networkId;
@Schema(description = "额外IP数量(个)")
private Integer ipNum;
@Schema(description = "虚拟机存储(TB)")
private Integer vmStorage;
@Schema(description = "申请时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] submitTime;
@Schema(description = "应用人(购买人)")
private Long applyUser;
@Schema(description = "支付状态 0 已支付 1未支付", example = "2")
private Boolean payStatus;
@Schema(description = "使用数量")
private Integer useNum;
@Schema(description = "使用期限(年)")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private String[] useTime;
@Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
@Schema(description = "备注", example = "你说的对")
private String remark;
@Schema(description = "对外总金额", example = "18381")
private BigDecimal publicTotalPrice;
@Schema(description = "对内总金额", example = "1454")
private BigDecimal innerTotalPrice;
@Schema(description = "参数字符串")
private String param;
@Schema(description = "销售价格", example = "11011")
private BigDecimal salesPrice;
}
\ No newline at end of file
package com.luhu.computility.module.biz.controller.app.order.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import java.math.BigDecimal;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import com.alibaba.excel.annotation.*;
@Schema(description = "管理后台 - 订单管理-需求单管理 Response VO")
@Data
@ExcelIgnoreUnannotated
public class OrderRespVO {
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "31971")
@ExcelProperty("主键")
private Long id;
@Schema(description = "订单编号")
@ExcelProperty("订单编号")
private String orderNo;
@Schema(description = "商品类别", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("商品类别")
private Boolean category;
@Schema(description = "型号", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("型号")
private Boolean model;
@Schema(description = "CPU")
@ExcelProperty("CPU")
private Boolean cpu;
@Schema(description = "GPU")
@ExcelProperty("GPU")
private Boolean gpu;
@Schema(description = "内存")
@ExcelProperty("内存")
private Boolean memory;
@Schema(description = "存储硬盘")
@ExcelProperty("存储硬盘")
private Boolean storage;
@Schema(description = "算力金额", example = "26427")
@ExcelProperty("算力金额")
private BigDecimal price;
@Schema(description = "状态:0-已确认,1-审核中,2-已驳回,3-已取消", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
@ExcelProperty("状态:0-已确认,1-审核中,2-已驳回,3-已取消")
private Boolean orderStatus;
@Schema(description = "网络带宽(M)", example = "183")
@ExcelProperty("网络带宽(M)")
private Long networkId;
@Schema(description = "额外IP数量(个)")
@ExcelProperty("额外IP数量(个)")
private Integer ipNum;
@Schema(description = "虚拟机存储(TB)")
@ExcelProperty("虚拟机存储(TB)")
private Integer vmStorage;
@Schema(description = "申请时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("申请时间")
private LocalDateTime submitTime;
@Schema(description = "应用人(购买人)", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("应用人(购买人)")
private Long applyUser;
@Schema(description = "支付状态 0 已支付 1未支付", example = "2")
@ExcelProperty("支付状态 0 已支付 1未支付")
private Boolean payStatus;
@Schema(description = "使用数量")
@ExcelProperty("使用数量")
private Integer useNum;
@Schema(description = "使用期限(年)", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("使用期限(年)")
private String useTime;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("创建时间")
private LocalDateTime createTime;
@Schema(description = "备注", example = "你说的对")
@ExcelProperty("备注")
private String remark;
@Schema(description = "对外总金额", example = "18381")
@ExcelProperty("对外总金额")
private BigDecimal publicTotalPrice;
@Schema(description = "对内总金额", example = "1454")
@ExcelProperty("对内总金额")
private BigDecimal innerTotalPrice;
@Schema(description = "参数字符串")
@ExcelProperty("参数字符串")
private String param;
@Schema(description = "销售价格", example = "11011")
@ExcelProperty("销售价格")
private BigDecimal salesPrice;
}
\ No newline at end of file
package com.luhu.computility.module.biz.controller.app.order.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import javax.validation.constraints.*;
import java.math.BigDecimal;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
@Schema(description = "管理后台 - 订单管理-需求单管理新增/修改 Request VO")
@Data
public class OrderSaveReqVO {
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "31971")
private Long id;
@Schema(description = "订单编号")
private String orderNo;
@Schema(description = "商品类别", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "商品类别不能为空")
private Integer category;
@Schema(description = "型号", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "型号不能为空")
private Long model;
@Schema(description = "CPU")
private Integer cpu;
@Schema(description = "GPU")
private Integer gpu;
@Schema(description = "内存")
private Integer memory;
@Schema(description = "存储硬盘")
private Integer storage;
@Schema(description = "算力金额", example = "26427")
private BigDecimal price;
@Schema(description = "状态:0-已确认,1-审核中,2-已驳回,3-已取消", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
@NotNull(message = "状态:0-已确认,1-审核中,2-已驳回,3-已取消不能为空")
private Boolean orderStatus;
@Schema(description = "网络带宽(M)", example = "183")
private Long networkId;
@Schema(description = "额外IP数量(个)")
private Integer ipNum;
@Schema(description = "虚拟机存储(TB)")
private Integer vmStorage;
@Schema(description = "申请时间", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "申请时间不能为空")
private LocalDateTime submitTime;
@Schema(description = "应用人(购买人)", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "应用人(购买人)不能为空")
private Long applyUser;
@Schema(description = "支付状态 0 已支付 1未支付", example = "2")
private Boolean payStatus;
@Schema(description = "使用数量")
private Integer useNum;
@Schema(description = "使用期限(年)", requiredMode = Schema.RequiredMode.REQUIRED)
@NotEmpty(message = "使用期限(年)不能为空")
private String useTime;
@Schema(description = "备注", example = "你说的对")
private String remark;
@Schema(description = "对外总金额", example = "18381")
private BigDecimal publicTotalPrice;
@Schema(description = "对内总金额", example = "1454")
private BigDecimal innerTotalPrice;
@Schema(description = "参数字符串")
private String param;
@Schema(description = "销售价格", example = "11011")
private BigDecimal salesPrice;
}
\ No newline at end of file
package com.luhu.computility.module.biz.dal.dataobject.order;
import lombok.*;
import java.util.*;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import java.math.BigDecimal;
import java.math.BigDecimal;
import java.math.BigDecimal;
import com.baomidou.mybatisplus.annotation.*;
import com.luhu.computility.framework.mybatis.core.dataobject.BaseDO;
/**
* 订单管理-需求单管理 DO
*
* @author 测试号02
*/
@TableName("biz_order")
@KeySequence("biz_order_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class OrderDO extends BaseDO {
/**
* 主键
*/
@TableId
private Long id;
/**
* 订单编号
*/
private String orderNo;
/**
* 商品类别
*/
private Integer category;
/**
* 型号
*/
private Boolean model;
/**
* CPU
*/
private Integer cpu;
/**
* GPU
*/
private Boolean gpu;
/**
* 内存
*/
private Boolean memory;
/**
* 存储硬盘
*/
private Boolean storage;
/**
* 算力金额
*/
private BigDecimal price;
/**
* 状态:0-已确认,1-审核中,2-已驳回,3-已取消
*/
private Boolean orderStatus;
/**
* 网络带宽(M)
*/
private Long networkId;
/**
* 额外IP数量(个)
*/
private Integer ipNum;
/**
* 虚拟机存储(TB)
*/
private Integer vmStorage;
/**
* 申请时间
*/
private LocalDateTime submitTime;
/**
* 应用人(购买人)
*/
private Long applyUser;
/**
* 支付状态 0 已支付 1未支付
*/
private Boolean payStatus;
/**
* 使用数量
*/
private Integer useNum;
/**
* 使用期限(年)
*/
private String useTime;
/**
* 备注
*/
private String remark;
/**
* 对外总金额
*/
private BigDecimal publicTotalPrice;
/**
* 对内总金额
*/
private BigDecimal innerTotalPrice;
/**
* 参数字符串
*/
private String param;
/**
* 销售价格
*/
private BigDecimal salesPrice;
}
\ No newline at end of file
package com.luhu.computility.module.biz.dal.mysql.order;
import com.luhu.computility.framework.common.pojo.PageResult;
import com.luhu.computility.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.luhu.computility.framework.mybatis.core.mapper.BaseMapperX;
import com.luhu.computility.module.biz.controller.app.order.vo.OrderPageReqVO;
import com.luhu.computility.module.biz.dal.dataobject.order.OrderDO;
import org.apache.ibatis.annotations.Mapper;
/**
* 订单管理-需求单管理 Mapper
*
* @author 测试号02
*/
@Mapper
public interface OrderMapper extends BaseMapperX<OrderDO> {
default PageResult<OrderDO> selectPage(OrderPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<OrderDO>()
.eqIfPresent(OrderDO::getOrderNo, reqVO.getOrderNo())
.eqIfPresent(OrderDO::getCategory, reqVO.getCategory())
.eqIfPresent(OrderDO::getModel, reqVO.getModel())
.eqIfPresent(OrderDO::getCpu, reqVO.getCpu())
.eqIfPresent(OrderDO::getGpu, reqVO.getGpu())
.eqIfPresent(OrderDO::getMemory, reqVO.getMemory())
.eqIfPresent(OrderDO::getStorage, reqVO.getStorage())
.eqIfPresent(OrderDO::getPrice, reqVO.getPrice())
.eqIfPresent(OrderDO::getOrderStatus, reqVO.getOrderStatus())
.eqIfPresent(OrderDO::getNetworkId, reqVO.getNetworkId())
.eqIfPresent(OrderDO::getIpNum, reqVO.getIpNum())
.eqIfPresent(OrderDO::getVmStorage, reqVO.getVmStorage())
.betweenIfPresent(OrderDO::getSubmitTime, reqVO.getSubmitTime())
.eqIfPresent(OrderDO::getApplyUser, reqVO.getApplyUser())
.eqIfPresent(OrderDO::getPayStatus, reqVO.getPayStatus())
.eqIfPresent(OrderDO::getUseNum, reqVO.getUseNum())
.betweenIfPresent(OrderDO::getUseTime, reqVO.getUseTime())
.betweenIfPresent(OrderDO::getCreateTime, reqVO.getCreateTime())
.eqIfPresent(OrderDO::getRemark, reqVO.getRemark())
.eqIfPresent(OrderDO::getPublicTotalPrice, reqVO.getPublicTotalPrice())
.eqIfPresent(OrderDO::getInnerTotalPrice, reqVO.getInnerTotalPrice())
.eqIfPresent(OrderDO::getParam, reqVO.getParam())
.eqIfPresent(OrderDO::getSalesPrice, reqVO.getSalesPrice())
.orderByDesc(OrderDO::getId));
}
}
\ No newline at end of file
......@@ -18,5 +18,6 @@ public interface ErrorCodeConstants {
ErrorCode INFORMATION_NOT_EXISTS = new ErrorCode(1_040_014_000, "活动资讯管理不存在");
ErrorCode ORDER_NOT_EXISTS = new ErrorCode(1_040_015_000, "订单管理-需求单管理不存在");
}
package com.luhu.computility.module.biz.service.order;
import java.util.*;
import javax.validation.*;
import com.luhu.computility.module.biz.controller.app.order.vo.OrderPageReqVO;
import com.luhu.computility.module.biz.controller.app.order.vo.OrderSaveReqVO;
import com.luhu.computility.module.biz.dal.dataobject.order.OrderDO;
import com.luhu.computility.framework.common.pojo.PageResult;
/**
* 订单管理-需求单管理 Service 接口
*
* @author 测试号02
*/
public interface OrderService {
void bizOrderSubmit(Long skuId);
/**
* 创建订单管理-需求单管理
*
* @param createReqVO 创建信息
* @return 编号
*/
Long createOrder(@Valid OrderSaveReqVO createReqVO);
/**
* 更新订单管理-需求单管理
*
* @param updateReqVO 更新信息
*/
void updateOrder(@Valid OrderSaveReqVO updateReqVO);
/**
* 删除订单管理-需求单管理
*
* @param id 编号
*/
void deleteOrder(Long id);
/**
* 批量删除订单管理-需求单管理
*
* @param ids 编号
*/
void deleteOrderListByIds(List<Long> ids);
/**
* 获得订单管理-需求单管理
*
* @param id 编号
* @return 订单管理-需求单管理
*/
OrderDO getOrder(Long id);
/**
* 获得订单管理-需求单管理分页
*
* @param pageReqVO 分页查询
* @return 订单管理-需求单管理分页
*/
PageResult<OrderDO> getOrderPage(OrderPageReqVO pageReqVO);
}
\ No newline at end of file
package com.luhu.computility.module.biz.service.order;
import com.luhu.computility.framework.common.enums.TradeOrderTypeEnum;
import com.luhu.computility.framework.common.util.order.OrderNoUtil;
import com.luhu.computility.module.biz.controller.app.index.vo.ResourcesDetailRespVO;
import com.luhu.computility.module.biz.controller.app.order.vo.OrderPageReqVO;
import com.luhu.computility.module.biz.controller.app.order.vo.OrderSaveReqVO;
import com.luhu.computility.module.biz.service.resources.ResourcesDetailService;
import com.luhu.computility.module.product.dal.dataobject.sku.ProductSkuDO;
import com.luhu.computility.module.product.dal.mysql.sku.ProductSkuMapper;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import java.util.*;
import com.luhu.computility.module.biz.dal.dataobject.order.OrderDO;
import com.luhu.computility.framework.common.pojo.PageResult;
import com.luhu.computility.framework.common.util.object.BeanUtils;
import com.luhu.computility.module.biz.dal.mysql.order.OrderMapper;
import static com.luhu.computility.framework.common.exception.util.ServiceExceptionUtil.exception;
import static com.luhu.computility.framework.common.util.collection.CollectionUtils.convertList;
import static com.luhu.computility.module.biz.enums.ErrorCodeConstants.*;
/**
* 订单管理-需求单管理 Service 实现类
*
* @author 测试号02
*/
@Service
@Validated
public class OrderServiceImpl implements OrderService {
@Resource
private OrderMapper orderMapper;
@Resource
private ProductSkuMapper productSkuMapper;
@Resource
private ResourcesDetailService resourcesDetailService;
@Override
public void bizOrderSubmit(Long skuId) {
ProductSkuDO skuDo = productSkuMapper.selectById(skuId);
ResourcesDetailRespVO resourcesDetailRespVO = resourcesDetailService.getResourcesDetailBySkuDO(skuDo);
OrderSaveReqVO orderSaveReqVO = new OrderSaveReqVO();
orderSaveReqVO.setOrderNo(OrderNoUtil.generateOrderNo(TradeOrderTypeEnum.TICKET_TRADE_ORDER));
orderSaveReqVO.setGpu(resourcesDetailRespVO.getGpuId());
orderSaveReqVO.setCpu(resourcesDetailRespVO.getCpuId());
orderSaveReqVO.setMemory(resourcesDetailRespVO.getMemoryId());
orderSaveReqVO.setStorage(resourcesDetailRespVO.getStorageId());
}
@Override
public Long createOrder(OrderSaveReqVO createReqVO) {
// 插入
OrderDO order = BeanUtils.toBean(createReqVO, OrderDO.class);
orderMapper.insert(order);
// 返回
return order.getId();
}
@Override
public void updateOrder(OrderSaveReqVO updateReqVO) {
// 校验存在
validateOrderExists(updateReqVO.getId());
// 更新
OrderDO updateObj = BeanUtils.toBean(updateReqVO, OrderDO.class);
orderMapper.updateById(updateObj);
}
@Override
public void deleteOrder(Long id) {
// 校验存在
validateOrderExists(id);
// 删除
orderMapper.deleteById(id);
}
@Override
public void deleteOrderListByIds(List<Long> ids) {
// 删除
orderMapper.deleteByIds(ids);
}
private void validateOrderExists(Long id) {
if (orderMapper.selectById(id) == null) {
throw exception(ORDER_NOT_EXISTS);
}
}
@Override
public OrderDO getOrder(Long id) {
return orderMapper.selectById(id);
}
@Override
public PageResult<OrderDO> getOrderPage(OrderPageReqVO pageReqVO) {
return orderMapper.selectPage(pageReqVO);
}
}
\ No newline at end of file
package com.luhu.computility.module.biz.service.resources;
import com.luhu.computility.module.biz.controller.app.index.vo.ResourcesDetailRespVO;
import com.luhu.computility.module.product.dal.dataobject.sku.ProductSkuDO;
/**
* @Author: jony
* @Date : 2025/8/11 15:09
* @VERSION v1.0
*/
public interface ResourcesDetailService {
ResourcesDetailRespVO getResourcesDetailBySkuDO(ProductSkuDO skuDO);
}
package com.luhu.computility.module.biz.service.resources;
import cn.hutool.core.convert.Convert;
import com.luhu.computility.module.biz.controller.app.index.vo.ResourcesDetailRespVO;
import com.luhu.computility.module.product.dal.dataobject.sku.ProductSkuDO;
import com.luhu.computility.module.product.dal.dataobject.spu.ProductSpuDO;
import com.luhu.computility.module.product.dal.mysql.category.ProductCategoryMapper;
import com.luhu.computility.module.product.dal.mysql.spu.ProductSpuMapper;
import com.luhu.computility.module.product.service.category.ProductCategoryService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
/**
* @Author: jony
* @Date : 2025/8/11 15:09
* @VERSION v1.0
*/
@Service
public class ResourcesDetailServiceImpl implements ResourcesDetailService{
@Resource
ProductSpuMapper productSpuMapper;
@Resource
ProductCategoryMapper productCategoryMapper;
@Override
public ResourcesDetailRespVO getResourcesDetailBySkuDO(ProductSkuDO skuDO) {
ResourcesDetailRespVO resourcesDetailRespVO = new ResourcesDetailRespVO();
List<ProductSkuDO.Property> properties = skuDO.getProperties();
ProductSpuDO spuDo = productSpuMapper.selectById(skuDO.getSpuId());
resourcesDetailRespVO.setCategory(productCategoryMapper.selectById(spuDo.getCategoryId()).getName());
resourcesDetailRespVO.setModel(spuDo.getName());//spuName实际上是每个服务器的名字
resourcesDetailRespVO.setPublicPrice(String.format("%.2f",skuDO.getPrice()/100.0));
for (ProductSkuDO.Property property : properties) {
switch (Convert.toInt(property.getPropertyId())) {
case 18:
resourcesDetailRespVO.setCpuId(property.getValueId());
resourcesDetailRespVO.setCpu(property.getValueName());
break;
case 19:
resourcesDetailRespVO.setGpuId(property.getValueId());
resourcesDetailRespVO.setGpu(property.getValueName());
break;
case 20:
resourcesDetailRespVO.setMemoryId(property.getValueId());
resourcesDetailRespVO.setMemory(property.getValueName());
break;
case 21:
resourcesDetailRespVO.setStorageId(property.getValueId());
resourcesDetailRespVO.setStorage(property.getValueName());
break;
case 22:
resourcesDetailRespVO.setTermId(property.getValueId());
resourcesDetailRespVO.setTerm(property.getValueName());
break;
}
resourcesDetailRespVO.setId(skuDO.getId());
}
return resourcesDetailRespVO;
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.luhu.computility.module.biz.dal.mysql.order.OrderMapper">
<!--
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
-->
</mapper>
\ No newline at end of file
......@@ -106,7 +106,7 @@ public class ProductSkuDO extends BaseDO {
* 属性编号
* 关联 {@link ProductPropertyDO#getId()}
*/
private Long propertyId;
private Integer propertyId;
/**
* 属性名字
* 冗余 {@link ProductPropertyDO#getName()}
......@@ -119,7 +119,7 @@ public class ProductSkuDO extends BaseDO {
* 属性值编号
* 关联 {@link ProductPropertyValueDO#getId()}
*/
private Long valueId;
private Integer valueId;
/**
* 属性值名字
* 冗余 {@link ProductPropertyValueDO#getName()}
......
......@@ -61,7 +61,7 @@ public class PayOrderServiceImpl implements PayOrderService {
private PayProperties payProperties;
@Resource
private PayOrderMapper orderMapper;
private PayOrderMapper payOrderMapper;
@Resource
private PayOrderExtensionMapper orderExtensionMapper;
@Resource
......@@ -76,12 +76,12 @@ public class PayOrderServiceImpl implements PayOrderService {
@Override
public PayOrderDO getOrder(Long id) {
return orderMapper.selectById(id);
return payOrderMapper.selectById(id);
}
@Override
public PayOrderDO getOrder(Long appId, String merchantOrderId) {
return orderMapper.selectByAppIdAndMerchantOrderId(appId, merchantOrderId);
return payOrderMapper.selectByAppIdAndMerchantOrderId(appId, merchantOrderId);
}
@Override
......@@ -89,22 +89,22 @@ public class PayOrderServiceImpl implements PayOrderService {
if (CollUtil.isEmpty(ids)) {
return Collections.emptyList();
}
return orderMapper.selectByIds(ids);
return payOrderMapper.selectByIds(ids);
}
@Override
public Long getOrderCountByAppId(Long appId) {
return orderMapper.selectCountByAppId(appId);
return payOrderMapper.selectCountByAppId(appId);
}
@Override
public PageResult<PayOrderDO> getOrderPage(PayOrderPageReqVO pageReqVO) {
return orderMapper.selectPage(pageReqVO);
return payOrderMapper.selectPage(pageReqVO);
}
@Override
public List<PayOrderDO> getOrderList(PayOrderExportReqVO exportReqVO) {
return orderMapper.selectList(exportReqVO);
return payOrderMapper.selectList(exportReqVO);
}
@Override
......@@ -113,7 +113,7 @@ public class PayOrderServiceImpl implements PayOrderService {
PayAppDO app = appService.validPayApp(reqDTO.getAppKey());
// 查询对应的支付交易单是否已经存在。如果是,则直接返回
PayOrderDO order = orderMapper.selectByAppIdAndMerchantOrderId(
PayOrderDO order = payOrderMapper.selectByAppIdAndMerchantOrderId(
app.getId(), reqDTO.getMerchantOrderId());
if (order != null) {
log.warn("[createOrder][appId({}) merchantOrderId({}) 已经存在对应的支付单({})]", order.getAppId(),
......@@ -129,7 +129,7 @@ public class PayOrderServiceImpl implements PayOrderService {
.setStatus(PayOrderStatusEnum.WAITING.getStatus())
// 退款相关字段
.setRefundPrice(0);
orderMapper.insert(order);
payOrderMapper.insert(order);
return order.getId();
}
......@@ -176,13 +176,13 @@ public class PayOrderServiceImpl implements PayOrderService {
unifiedOrderResp.getChannelErrorMsg());
}
// 此处需要读取最新的状态
order = orderMapper.selectById(order.getId());
order = payOrderMapper.selectById(order.getId());
}
return PayOrderConvert.INSTANCE.convert(order, unifiedOrderResp);
}
private PayOrderDO validateOrderCanSubmit(Long id) {
PayOrderDO order = orderMapper.selectById(id);
PayOrderDO order = payOrderMapper.selectById(id);
if (order == null) { // 是否存在
throw exception(PAY_ORDER_NOT_FOUND);
}
......@@ -339,7 +339,7 @@ public class PayOrderServiceImpl implements PayOrderService {
private Boolean updateOrderSuccess(PayChannelDO channel, PayOrderExtensionDO orderExtension,
PayOrderRespDTO notify) {
// 1. 判断 PayOrderDO 是否处于待支付
PayOrderDO order = orderMapper.selectById(orderExtension.getOrderId());
PayOrderDO order = payOrderMapper.selectById(orderExtension.getOrderId());
if (order == null) {
throw exception(PAY_ORDER_NOT_FOUND);
}
......@@ -353,7 +353,7 @@ public class PayOrderServiceImpl implements PayOrderService {
}
// 2. 更新 PayOrderDO
int updateCounts = orderMapper.updateByIdAndStatus(order.getId(), PayOrderStatusEnum.WAITING.getStatus(),
int updateCounts = payOrderMapper.updateByIdAndStatus(order.getId(), PayOrderStatusEnum.WAITING.getStatus(),
PayOrderDO.builder().status(PayOrderStatusEnum.SUCCESS.getStatus())
.channelId(channel.getId()).channelCode(channel.getCode())
.successTime(notify.getSuccessTime()).extensionId(orderExtension.getId()).no(orderExtension.getNo())
......@@ -404,7 +404,7 @@ public class PayOrderServiceImpl implements PayOrderService {
@Override
public void updateOrderRefundPrice(Long id, Integer incrRefundPrice) {
PayOrderDO order = orderMapper.selectById(id);
PayOrderDO order = payOrderMapper.selectById(id);
if (order == null) {
throw exception(PAY_ORDER_NOT_FOUND);
}
......@@ -419,7 +419,7 @@ public class PayOrderServiceImpl implements PayOrderService {
PayOrderDO updateObj = new PayOrderDO()
.setRefundPrice(order.getRefundPrice() + incrRefundPrice)
.setStatus(PayOrderStatusEnum.REFUND.getStatus());
int updateCount = orderMapper.updateByIdAndStatus(id, order.getStatus(), updateObj);
int updateCount = payOrderMapper.updateByIdAndStatus(id, order.getStatus(), updateObj);
if (updateCount == 0) {
throw exception(PAY_ORDER_REFUND_FAIL_STATUS_ERROR);
}
......@@ -427,7 +427,7 @@ public class PayOrderServiceImpl implements PayOrderService {
@Override
public void updatePayOrderPrice(Long id, Integer payPrice) {
PayOrderDO order = orderMapper.selectById(id);
PayOrderDO order = payOrderMapper.selectById(id);
if (order == null) {
throw exception(PAY_ORDER_NOT_FOUND);
}
......@@ -438,7 +438,7 @@ public class PayOrderServiceImpl implements PayOrderService {
return;
}
orderMapper.updateById(new PayOrderDO().setId(order.getId()).setPrice(payPrice));
payOrderMapper.updateById(new PayOrderDO().setId(order.getId()).setPrice(payPrice));
}
@Override
......@@ -516,7 +516,7 @@ public class PayOrderServiceImpl implements PayOrderService {
@Override
public int expireOrder() {
// 1. 查询过期的待支付订单
List<PayOrderDO> orders = orderMapper.selectListByStatusAndExpireTimeLt(
List<PayOrderDO> orders = payOrderMapper.selectListByStatusAndExpireTimeLt(
PayOrderStatusEnum.WAITING.getStatus(), LocalDateTime.now());
if (CollUtil.isEmpty(orders)) {
return 0;
......@@ -581,7 +581,7 @@ public class PayOrderServiceImpl implements PayOrderService {
// 2. 都没有上述情况,可以安心更新为已关闭
PayOrderDO updateObj = new PayOrderDO().setStatus(PayOrderStatusEnum.CLOSED.getStatus());
if (orderMapper.updateByIdAndStatus(order.getId(), order.getStatus(), updateObj) == 0) {
if (payOrderMapper.updateByIdAndStatus(order.getId(), order.getStatus(), updateObj) == 0) {
log.error("[expireOrder][order({}) 更新为支付关闭失败]", order.getId());
return false;
}
......
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 sign in to comment