feat(支付和智能柜): 新增余额相关字段和格口统计功能
- 在GetBalanceResponse中添加useBalance和balanceLimit字段 - 在SmartCabinet相关类中添加usedCells和availableCells字段用于统计格口使用情况 - 修改智能柜查询SQL以计算已用和可用格口数 - 新增商品管理控制器ManageGoodsController
This commit is contained in:
parent
0ea23e7309
commit
cae2822a5d
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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<PageDTO<ShopGoodsDTO>> goodsList(SearchShopGoodsQuery<SearchGoodsDO> query) {
|
||||
PageDTO<ShopGoodsDTO> page = goodsApplicationService.getGoodsList(query);
|
||||
return ResponseDTO.ok(page);
|
||||
}
|
||||
|
||||
@Operation(summary = "新增商品")
|
||||
@PostMapping
|
||||
public ResponseDTO<Void> add(@Validated @RequestBody AddGoodsCommand command) {
|
||||
goodsApplicationService.addGoods(command);
|
||||
return ResponseDTO.ok();
|
||||
}
|
||||
|
||||
@Operation(summary = "删除商品")
|
||||
@DeleteMapping("/{goodsIds}")
|
||||
public ResponseDTO<Void> remove(@PathVariable @NotNull List<Long> goodsIds) {
|
||||
BulkOperationCommand<Long> bulkDeleteCommand = new BulkOperationCommand<>(goodsIds);
|
||||
goodsApplicationService.deleteGoods(bulkDeleteCommand);
|
||||
return ResponseDTO.ok();
|
||||
}
|
||||
|
||||
@Operation(summary = "修改商品")
|
||||
@PutMapping("/{goodsId}")
|
||||
public ResponseDTO<Void> edit(@PathVariable Long goodsId, @Validated @RequestBody UpdateGoodsCommand command) {
|
||||
command.setGoodsId(goodsId);
|
||||
goodsApplicationService.updateGoods(command);
|
||||
return ResponseDTO.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取单个商品信息
|
||||
*/
|
||||
@Operation(summary = "商品列表")
|
||||
@GetMapping("/getGoodsInfo")
|
||||
public ResponseDTO<ShopGoodsDTO> getGoodsInfo(@RequestParam Long goodsId) {
|
||||
ShopGoodsDTO goodsInfo = goodsApplicationService.getGoodsInfo(goodsId);
|
||||
return ResponseDTO.ok(goodsInfo);
|
||||
}
|
||||
}
|
|
@ -11,4 +11,6 @@ public class GetBalanceResponse {
|
|||
private String userid;
|
||||
private String corpid;
|
||||
private BigDecimal balance;
|
||||
private BigDecimal useBalance;
|
||||
private BigDecimal balanceLimit;
|
||||
}
|
||||
|
|
|
@ -71,6 +71,11 @@ public class SmartCabinetEntity extends BaseEntity<SmartCabinetEntity> {
|
|||
@TableField("location")
|
||||
private Integer location;
|
||||
|
||||
@ApiModelProperty("已用格口数")
|
||||
private Integer usedCells;
|
||||
|
||||
@ApiModelProperty("未用格口数")
|
||||
private Integer availableCells;
|
||||
|
||||
@Override
|
||||
public Serializable pkVal() {
|
||||
|
|
|
@ -17,9 +17,12 @@ import java.util.List;
|
|||
* @since 2025-03-17
|
||||
*/
|
||||
public interface SmartCabinetMapper extends BaseMapper<SmartCabinetEntity> {
|
||||
@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<SmartCabinetEntity> getCabinetList(
|
||||
Page<SmartCabinetEntity> page,
|
||||
|
|
|
@ -55,4 +55,10 @@ public class SmartCabinetDTO {
|
|||
|
||||
@ExcelColumn(name = "柜机位置")
|
||||
private Integer location;
|
||||
|
||||
@ExcelColumn(name = "已用格口数")
|
||||
private Integer usedCells;
|
||||
|
||||
@ExcelColumn(name = "未用格口数")
|
||||
private Integer availableCells;
|
||||
}
|
|
@ -33,7 +33,8 @@ public class SearchSmartCabinetQuery<T> extends AbstractPageQuery<T> {
|
|||
.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";
|
||||
|
||||
|
|
Loading…
Reference in New Issue