diff --git a/agileboot-api/src/main/java/com/agileboot/api/controller/PaymentController.java b/agileboot-api/src/main/java/com/agileboot/api/controller/PaymentController.java index ed2bee2..ccbfd31 100644 --- a/agileboot-api/src/main/java/com/agileboot/api/controller/PaymentController.java +++ b/agileboot-api/src/main/java/com/agileboot/api/controller/PaymentController.java @@ -24,6 +24,8 @@ import com.agileboot.domain.qywx.userQySys.SysUserQyUserApplicationService; import com.agileboot.domain.shop.order.OrderApplicationService; import com.agileboot.domain.shop.payment.PaymentApplicationService; import com.agileboot.domain.shop.payment.dto.PaymentCallbackRequest; + +import java.math.BigDecimal; import java.nio.charset.StandardCharsets; import java.util.*; import javax.servlet.http.HttpServletRequest; @@ -264,7 +266,12 @@ public class PaymentController { } // 创建响应对象(假设GetBalanceResponse包含balance字段) - GetBalanceResponse response = new GetBalanceResponse(maxBalanceUser.getUserid(), maxBalanceUser.getCorpid(), maxBalanceUser.getBalance()); + GetBalanceResponse response = new GetBalanceResponse( + maxBalanceUser.getUserid(), + maxBalanceUser.getCorpid(), + BigDecimal.ZERO, + BigDecimal.ZERO, + BigDecimal.ZERO); return ResponseDTO.ok(response); } @@ -279,7 +286,12 @@ public class PaymentController { QyUserEntity qyUser = qyUserApplicationService.getUserByUserId(userid, corpid); // 创建响应对象(假设GetBalanceResponse包含balance字段) - GetBalanceResponse response = new GetBalanceResponse(qyUser.getUserid(), qyUser.getCorpid(), qyUser.getBalance()); + GetBalanceResponse response = new GetBalanceResponse( + qyUser.getUserid(), + qyUser.getCorpid(), + qyUser.getBalance(), + qyUser.getUseBalance(), + qyUser.getBalanceLimit()); return ResponseDTO.ok(response); } diff --git a/agileboot-api/src/main/java/com/agileboot/api/controller/manage/ManageGoodsController.java b/agileboot-api/src/main/java/com/agileboot/api/controller/manage/ManageGoodsController.java new file mode 100644 index 0000000..94516bb --- /dev/null +++ b/agileboot-api/src/main/java/com/agileboot/api/controller/manage/ManageGoodsController.java @@ -0,0 +1,71 @@ +package com.agileboot.api.controller.manage; + +import com.agileboot.common.core.dto.ResponseDTO; +import com.agileboot.common.core.page.PageDTO; +import com.agileboot.common.enums.common.BusinessTypeEnum; +import com.agileboot.domain.common.command.BulkOperationCommand; +import com.agileboot.domain.shop.goods.GoodsApplicationService; +import com.agileboot.domain.shop.goods.command.AddGoodsCommand; +import com.agileboot.domain.shop.goods.command.UpdateGoodsCommand; +import com.agileboot.domain.shop.goods.db.SearchGoodsDO; +import com.agileboot.domain.shop.goods.dto.ShopGoodsDTO; +import com.agileboot.domain.shop.goods.query.SearchShopGoodsQuery; +import io.swagger.v3.oas.annotations.Operation; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import javax.validation.constraints.NotNull; +import java.util.List; + +@Slf4j +@RestController +@CrossOrigin(origins = "*", allowedHeaders = "*") +@RequiredArgsConstructor +@RequestMapping("/api/manage/goods") +public class ManageGoodsController { + private final GoodsApplicationService goodsApplicationService; + /** + * 获取商品列表 + */ + @Operation(summary = "商品列表") + @GetMapping("/list") + public ResponseDTO> goodsList(SearchShopGoodsQuery query) { + PageDTO page = goodsApplicationService.getGoodsList(query); + return ResponseDTO.ok(page); + } + + @Operation(summary = "新增商品") + @PostMapping + public ResponseDTO add(@Validated @RequestBody AddGoodsCommand command) { + goodsApplicationService.addGoods(command); + return ResponseDTO.ok(); + } + + @Operation(summary = "删除商品") + @DeleteMapping("/{goodsIds}") + public ResponseDTO remove(@PathVariable @NotNull List goodsIds) { + BulkOperationCommand bulkDeleteCommand = new BulkOperationCommand<>(goodsIds); + goodsApplicationService.deleteGoods(bulkDeleteCommand); + return ResponseDTO.ok(); + } + + @Operation(summary = "修改商品") + @PutMapping("/{goodsId}") + public ResponseDTO edit(@PathVariable Long goodsId, @Validated @RequestBody UpdateGoodsCommand command) { + command.setGoodsId(goodsId); + goodsApplicationService.updateGoods(command); + return ResponseDTO.ok(); + } + + /** + * 获取单个商品信息 + */ + @Operation(summary = "商品列表") + @GetMapping("/getGoodsInfo") + public ResponseDTO getGoodsInfo(@RequestParam Long goodsId) { + ShopGoodsDTO goodsInfo = goodsApplicationService.getGoodsInfo(goodsId); + return ResponseDTO.ok(goodsInfo); + } +} diff --git a/agileboot-api/src/main/java/com/agileboot/api/response/GetBalanceResponse.java b/agileboot-api/src/main/java/com/agileboot/api/response/GetBalanceResponse.java index 059d108..ea7296a 100644 --- a/agileboot-api/src/main/java/com/agileboot/api/response/GetBalanceResponse.java +++ b/agileboot-api/src/main/java/com/agileboot/api/response/GetBalanceResponse.java @@ -11,4 +11,6 @@ public class GetBalanceResponse { private String userid; private String corpid; private BigDecimal balance; + private BigDecimal useBalance; + private BigDecimal balanceLimit; } diff --git a/agileboot-domain/src/main/java/com/agileboot/domain/cabinet/smartCabinet/db/SmartCabinetEntity.java b/agileboot-domain/src/main/java/com/agileboot/domain/cabinet/smartCabinet/db/SmartCabinetEntity.java index 010859e..042a6e9 100644 --- a/agileboot-domain/src/main/java/com/agileboot/domain/cabinet/smartCabinet/db/SmartCabinetEntity.java +++ b/agileboot-domain/src/main/java/com/agileboot/domain/cabinet/smartCabinet/db/SmartCabinetEntity.java @@ -71,6 +71,11 @@ public class SmartCabinetEntity extends BaseEntity { @TableField("location") private Integer location; + @ApiModelProperty("已用格口数") + private Integer usedCells; + + @ApiModelProperty("未用格口数") + private Integer availableCells; @Override public Serializable pkVal() { diff --git a/agileboot-domain/src/main/java/com/agileboot/domain/cabinet/smartCabinet/db/SmartCabinetMapper.java b/agileboot-domain/src/main/java/com/agileboot/domain/cabinet/smartCabinet/db/SmartCabinetMapper.java index 73f1edb..ea60b9d 100644 --- a/agileboot-domain/src/main/java/com/agileboot/domain/cabinet/smartCabinet/db/SmartCabinetMapper.java +++ b/agileboot-domain/src/main/java/com/agileboot/domain/cabinet/smartCabinet/db/SmartCabinetMapper.java @@ -17,9 +17,12 @@ import java.util.List; * @since 2025-03-17 */ public interface SmartCabinetMapper extends BaseMapper { - @Select("SELECT sc.*, scl.cabinet_name AS mainCabinetName " + + @Select("SELECT sc.*, scl.cabinet_name AS mainCabinetName, " + + "SUM(CASE WHEN cc.usage_status = 2 AND cc.deleted = 0 THEN 1 ELSE 0 END) AS usedCells, " + + "SUM(CASE WHEN cc.usage_status = 1 AND cc.deleted = 0 THEN 1 ELSE 0 END) AS availableCells " + "FROM smart_cabinet sc " + "LEFT JOIN smart_cabinet scl ON scl.cabinet_id = sc.main_cabinet " + + "LEFT JOIN cabinet_cell cc ON cc.cabinet_id = sc.cabinet_id " + "${ew.customSqlSegment}") Page getCabinetList( Page page, diff --git a/agileboot-domain/src/main/java/com/agileboot/domain/cabinet/smartCabinet/dto/SmartCabinetDTO.java b/agileboot-domain/src/main/java/com/agileboot/domain/cabinet/smartCabinet/dto/SmartCabinetDTO.java index 4ef867c..727092f 100644 --- a/agileboot-domain/src/main/java/com/agileboot/domain/cabinet/smartCabinet/dto/SmartCabinetDTO.java +++ b/agileboot-domain/src/main/java/com/agileboot/domain/cabinet/smartCabinet/dto/SmartCabinetDTO.java @@ -55,4 +55,10 @@ public class SmartCabinetDTO { @ExcelColumn(name = "柜机位置") private Integer location; + + @ExcelColumn(name = "已用格口数") + private Integer usedCells; + + @ExcelColumn(name = "未用格口数") + private Integer availableCells; } \ No newline at end of file diff --git a/agileboot-domain/src/main/java/com/agileboot/domain/cabinet/smartCabinet/query/SearchSmartCabinetQuery.java b/agileboot-domain/src/main/java/com/agileboot/domain/cabinet/smartCabinet/query/SearchSmartCabinetQuery.java index aa78b14..31109a0 100644 --- a/agileboot-domain/src/main/java/com/agileboot/domain/cabinet/smartCabinet/query/SearchSmartCabinetQuery.java +++ b/agileboot-domain/src/main/java/com/agileboot/domain/cabinet/smartCabinet/query/SearchSmartCabinetQuery.java @@ -33,7 +33,8 @@ public class SearchSmartCabinetQuery extends AbstractPageQuery { .eq(belongType!= null, "sc.belong_type", belongType) .eq(StrUtil.isNotEmpty(templateNo), "sc.template_no", templateNo) .eq("sc.deleted", false) - .between(startTime != null && endTime != null, "sc.create_time", startTime, endTime); + .between(startTime != null && endTime != null, "sc.create_time", startTime, endTime) + .groupBy("sc.cabinet_id"); this.timeRangeColumn = "create_time";