Compare commits

..

11 Commits

Author SHA1 Message Date
dzq 04fd224005 feat(订单): 添加订单模式字段并实现会员模式逻辑
添加订单模式字段(mode)用于区分不同业务场景
实现会员模式(模式3)的特殊处理逻辑,包括:
- 订单提交时设置商品价格为格口价格
- 订单完成时更新格口租赁状态
- 退货审批时自动审批会员模式订单
2025-06-28 14:50:40 +08:00
dzq bab1a171bf refactor(domain): 移除status字段的反引号转义
数据库字段status无需使用反引号转义,移除以保持代码简洁
2025-06-27 16:23:53 +08:00
dzq c83e7a7041 feat(订单): 添加订单运行模式字段
在订单表和订单商品表中添加mode字段,支持多种运行模式(支付/审批/借还/会员/耗材模式)
同时更新DTO和查询条件以支持新模式字段
2025-06-27 16:22:02 +08:00
dzq eacf28be6f fix(智能柜): 过滤掉价格为0或空的柜格
在获取柜体信息时,添加对柜格价格的过滤,确保只返回价格大于0的柜格
2025-06-27 15:25:24 +08:00
dzq 65a0ceeb2b feat(智能柜): 添加格口租赁功能及相关查询接口
添加格口租赁价格和租赁状态字段
新增获取租赁柜体详情接口
修改查询条件支持按租赁状态筛选
2025-06-26 11:39:40 +08:00
dzq 065912f2c7 fix(shop): 添加商店模式修改时的商品绑定检查逻辑
在更新商店模式时,新增检查逻辑确保商店下的柜子没有绑定商品时才允许修改模式为3
2025-06-25 16:19:06 +08:00
dzq 4a9e6d8d1c refactor(domain): 优化智能柜应用服务中店铺信息设置逻辑
将流式操作中的直接映射改为先获取店铺对象再设置属性,避免重复查找并增加mode字段的设置
2025-06-25 09:57:14 +08:00
dzq b1328b35ec feat(订单查询): 添加退货状态查询条件
在订单查询条件中增加退货状态字段,根据不同的退货状态值查询对应的支付状态和商品状态
2025-06-24 17:54:24 +08:00
dzq 76647e5b95 feat(查询): 添加退货审批查询的状态和搜索条件处理
添加handleStatus字段处理不同审批状态组合查询
添加searchStr字段支持订单名称和商品名称模糊搜索
2025-06-24 15:45:36 +08:00
dzq ff811ab6f6 fix(QywxScheduleJob): 添加suiteAccessToken为空时的错误处理
feat(ShopController): 新增获取商店列表接口并重命名分页接口

refactor(ShopApplicationService): 拆分获取商店列表和分页逻辑
2025-06-23 17:43:43 +08:00
dzq 2091d1e925 fix(ApprovalApiController): 添加订单商品状态检查防止重复退货
在提交退货审批前增加状态检查,避免状态为退货中或已退货的商品重复提交退货申请
2025-06-23 16:29:00 +08:00
21 changed files with 285 additions and 42 deletions

View File

@ -102,11 +102,18 @@ public class ShopController extends BaseController {
@Operation(summary = "商店列表")
@GetMapping
public ResponseDTO<PageDTO<ShopDTO>> list(SearchShopQuery<ShopEntity> query) {
PageDTO<ShopDTO> page = shopApplicationService.getShopList(query);
public ResponseDTO<PageDTO<ShopDTO>> page(SearchShopQuery<ShopEntity> query) {
PageDTO<ShopDTO> page = shopApplicationService.getShopPage(query);
return ResponseDTO.ok(page);
}
@Operation(summary = "商店列表")
@GetMapping("/list")
public ResponseDTO<List<ShopDTO>> list(SearchShopQuery<ShopEntity> query) {
List<ShopDTO> list = shopApplicationService.getShopList(query);
return ResponseDTO.ok(list);
}
@Operation(summary = "获取商店详情")
@GetMapping("/{id}")
public ResponseDTO<ShopDTO> getShopById(@PathVariable Long id) {

View File

@ -121,6 +121,10 @@ public class QywxScheduleJob {
String suiteAccessToken = templateApplicationService.getSuiteAccessToken(template.getSuiteId(), template.getSecret(),
template.getSuiteTicket());
if (StringUtils.isBlank(suiteAccessToken)) {
log.error("getSuiteAccessToken suiteAccessToken is null");
return;
}
UpdateTemplateCommand command = new UpdateTemplateCommand();
command.setId(template.getId());
command.setSuiteAccessToken(suiteAccessToken);

View File

@ -174,6 +174,9 @@ public class ApprovalApiController {
if (null == orderGoods) {
return ResponseDTO.fail(new ApiException(ErrorCode.Internal.INTERNAL_ERROR, "订单商品不存在"));
}
if (orderGoods.getStatus().equals(2) || orderGoods.getStatus().equals(5)) {
return ResponseDTO.fail(new ApiException(ErrorCode.Internal.INTERNAL_ERROR, "订单商品状态为退货中或已退货"));
}
// 执行业务逻辑
ReturnApprovalEntity returnApproval = approvalApplicationService.submitApproval(command, orderGoods);

View File

@ -16,6 +16,7 @@ import com.agileboot.domain.cabinet.operation.model.CabinetCellOperationModel;
import com.agileboot.domain.cabinet.operation.model.CabinetCellOperationModelFactory;
import com.agileboot.domain.cabinet.smartCabinet.SmartCabinetApplicationService;
import com.agileboot.domain.cabinet.smartCabinet.dto.CabinetDetailDTO;
import com.agileboot.domain.cabinet.smartCabinet.dto.RentingCabinetDetailDTO;
import com.agileboot.domain.cabinet.smartCabinet.model.SmartCabinetModel;
import com.agileboot.domain.cabinet.smartCabinet.model.SmartCabinetModelFactory;
import com.agileboot.domain.mqtt.MqttService;
@ -49,6 +50,11 @@ public class CabinetCellController {
return ResponseDTO.ok(smartCabinetApplicationService.getCabinetDetail(shopId));
}
@GetMapping("/detail/renting")
public ResponseDTO<List<RentingCabinetDetailDTO>> getRentingCabinetDetail(@RequestParam Long shopId) {
return ResponseDTO.ok(smartCabinetApplicationService.getRentingCabinetDetail(shopId));
}
@Operation(summary = "配置格口商品库存")
@PutMapping("/configureGoodsCellsStock/{cellId}/{goodsId}/{stock}")

View File

@ -6,6 +6,8 @@ import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.math.BigDecimal;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
@ -51,6 +53,14 @@ public class CabinetCellEntity extends BaseEntity<CabinetCellEntity> {
@TableField("stock")
private Integer stock;
@ApiModelProperty("格口租用价格")
@TableField("cell_price")
private BigDecimal cellPrice;
@ApiModelProperty("是否已租用0-未租用1-已租用")
@TableField("is_rented")
private Integer isRented;
@ApiModelProperty("格口类型1小格 2中格 3大格 4超大格")
@TableField("cell_type")
private Integer cellType;

View File

@ -49,6 +49,12 @@ public class CabinetCellDTO {
@ExcelColumn(name = "库存数量")
private Integer stock;
@ExcelColumn(name = "格口租用价格")
private BigDecimal cellPrice;
@ExcelColumn(name = "是否已租用")
private Integer isRented;
@ExcelColumn(name = "订单数量")
private Integer orderCount;

View File

@ -15,6 +15,9 @@ public class SearchCabinetCellQuery<T> extends AbstractPageQuery<T> {
private Long cabinetId;
private Integer cellNo;
private Integer cellType;
private Integer isRented;
private Integer usageStatus;
private Integer availableStatus;
private Date startTime;
@ -29,6 +32,7 @@ public class SearchCabinetCellQuery<T> extends AbstractPageQuery<T> {
.eq(cabinetId != null, "cabinet_id", cabinetId)
.eq(cellNo != null, "cell_no", cellNo)
.eq(cellType != null, "cell_type", cellType)
.eq(isRented != null, "is_rented", isRented)
.eq(usageStatus != null, "usage_status", usageStatus)
.eq(availableStatus != null, "available_status", availableStatus)
.eq("deleted", false)

View File

@ -15,6 +15,9 @@ public class SearchCabinetCellWithOrdersQuery<T> extends AbstractPageQuery<T> {
private Long cabinetId;
private Integer cellNo;
private Integer cellType;
private Integer isRented;
private Integer usageStatus;
private Integer availableStatus;
private Date startTime;
@ -30,7 +33,8 @@ public class SearchCabinetCellWithOrdersQuery<T> extends AbstractPageQuery<T> {
.eq(cabinetId != null, "cc.cabinet_id", cabinetId)
.eq(cellNo != null, "cc.cell_no", cellNo)
.eq(cellType != null, "cc.cell_type", cellType)
.eq(usageStatus != null, "cc.usage_status", usageStatus)
.eq(isRented != null, "cc.is_rented", isRented)
.eq(usageStatus != null, "cc.usage_status", usageStatus)
.eq(availableStatus != null, "cc.available_status", availableStatus)
.eq("cc.deleted", false)
.like(StringUtils.isNotBlank(goodsName), "sg.goods_name", goodsName)

View File

@ -12,6 +12,7 @@ import com.agileboot.domain.cabinet.mainboard.model.CabinetMainboardModel;
import com.agileboot.domain.cabinet.mainboard.model.CabinetMainboardModelFactory;
import com.agileboot.domain.cabinet.smartCabinet.db.SmartCabinetDO;
import com.agileboot.domain.cabinet.smartCabinet.dto.CabinetDetailDTO;
import com.agileboot.domain.cabinet.smartCabinet.dto.RentingCabinetDetailDTO;
import com.agileboot.domain.common.command.BulkOperationCommand;
import com.agileboot.domain.cabinet.smartCabinet.command.AddSmartCabinetCommand;
import com.agileboot.domain.cabinet.smartCabinet.command.UpdateSmartCabinetCommand;
@ -28,6 +29,7 @@ import com.agileboot.domain.shop.shop.db.ShopService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
@ -54,14 +56,15 @@ public class SmartCabinetApplicationService {
.map(SmartCabinetDTO::new)
.collect(Collectors.toList());
dtoList.forEach(dto ->
dto.setShopName(
shopEntities.stream()
.filter(shop -> shop.getShopId().equals(dto.getShopId()))
.findFirst()
.map(ShopEntity::getShopName)
.orElse(""))
);
dtoList.forEach(dto -> {
ShopEntity shopDo = shopEntities.stream()
.filter(shop -> shop.getShopId().equals(dto.getShopId()))
.findFirst().orElse(null);
if (shopDo != null) {
dto.setShopName(shopDo.getShopName());
dto.setMode(shopDo.getMode());
}
});
return new PageDTO<>(dtoList, page.getTotal());
}
@ -72,14 +75,15 @@ public class SmartCabinetApplicationService {
.map(SmartCabinetDTO::new)
.collect(Collectors.toList());
dtoList.forEach(dto ->
dto.setShopName(
shopEntities.stream()
.filter(shop -> shop.getShopId().equals(dto.getShopId()))
.findFirst()
.map(ShopEntity::getShopName)
.orElse(""))
);
dtoList.forEach(dto -> {
ShopEntity shopDo = shopEntities.stream()
.filter(shop -> shop.getShopId().equals(dto.getShopId()))
.findFirst().orElse(null);
if (shopDo != null) {
dto.setShopName(shopDo.getShopName());
dto.setMode(shopDo.getMode());
}
});
return dtoList;
}
@ -219,6 +223,48 @@ public class SmartCabinetApplicationService {
return result;
}
/**
* 获取所有智能柜的详细信息
* @return 包含柜体信息单元格信息和商品信息的列表
*/
public List<RentingCabinetDetailDTO> getRentingCabinetDetail(Long shopId) {
// 获取所有智能柜单元格和商品的基础数据
QueryWrapper<SmartCabinetEntity> smartCabinetEntityQueryWrapper = new QueryWrapper<>();
smartCabinetEntityQueryWrapper.eq("shop_id", shopId)
.eq("deleted", false);
List<SmartCabinetEntity> smartCabinets = smartCabinetService.list(smartCabinetEntityQueryWrapper);
QueryWrapper<CabinetCellEntity> cabinetCellEntityQueryWrapper = new QueryWrapper<>();
cabinetCellEntityQueryWrapper.in("cabinet_id",
smartCabinets.stream()
.map(SmartCabinetEntity::getCabinetId)
.filter(Objects::nonNull)
.distinct()
.collect(Collectors.toList()))
.eq("is_rented", 0)
.eq("deleted", false);
List<CabinetCellEntity> cabinetCells = cabinetCellService.list(cabinetCellEntityQueryWrapper);
List<RentingCabinetDetailDTO> result = new ArrayList<>();
// 遍历每个智能柜构建详细信息
for (SmartCabinetEntity cabinet : smartCabinets) {
RentingCabinetDetailDTO rentingCabinetDetailDTO = new RentingCabinetDetailDTO();
// 设置柜体基础信息
rentingCabinetDetailDTO.setCabinetId(cabinet.getCabinetId());
rentingCabinetDetailDTO.setCabinetName(cabinet.getCabinetName());
rentingCabinetDetailDTO.setLockControlNo(cabinet.getLockControlNo());
// 将单元格列表加入柜体信息
rentingCabinetDetailDTO.setCells(cabinetCells.stream()
.filter(cell -> cell.getCabinetId().equals(cabinet.getCabinetId()))
.filter(cell -> cell.getCellPrice() != null && cell.getCellPrice().compareTo(BigDecimal.ZERO) > 0)
.collect(Collectors.toList()));
result.add(rentingCabinetDetailDTO);
}
return result;
}
public List<CabinetMainboardModel> createCabinetMainboardByTemplate(SmartCabinetModel cabinetModel) {
CabinetTemplateEnum template = CabinetTemplateEnum.getByCode(Integer.parseInt(cabinetModel.getTemplateNo()));
if (template == null) {

View File

@ -0,0 +1,14 @@
package com.agileboot.domain.cabinet.smartCabinet.dto;
import com.agileboot.domain.cabinet.cell.db.CabinetCellEntity;
import lombok.Data;
import java.util.List;
@Data
public class RentingCabinetDetailDTO {
private Long cabinetId;
private String cabinetName;
private Integer lockControlNo;
private List<CabinetCellEntity> cells;
}

View File

@ -290,15 +290,22 @@ public class ReturnApprovalApplicationService {
orderGoodsModel.setStatus(2); // 6表示已完成退货
orderGoodsModel.updateById();
// 更新商品库存
GoodsModel goodsModel = goodsModelFactory.loadById(orderGoodsModel.getGoodsId());
goodsModel.setStock(goodsModel.getStock() + orderGoodsModel.getQuantity());
goodsModel.updateById();
if (orderGoodsModel.getMode()!= null && orderGoodsModel.getMode().equals(3)) {
// 模式为3需要更新柜子格口状态
CabinetCellEntity cell = cabinetCellService.getById(orderGoodsModel.getCellId());
cell.setIsRented(0);
cell.updateById();
} else {
// 更新商品库存
GoodsModel goodsModel = goodsModelFactory.loadById(orderGoodsModel.getGoodsId());
goodsModel.setStock(goodsModel.getStock() + orderGoodsModel.getQuantity());
goodsModel.updateById();
// 更新格口库存
CabinetCellModel cabinetCellModel = cabinetCellModelFactory.loadById(orderGoodsModel.getCellId());
cabinetCellModel.setStock(cabinetCellModel.getStock() + orderGoodsModel.getQuantity());
cabinetCellModel.updateById();
// 更新格口库存
CabinetCellModel cabinetCellModel = cabinetCellModelFactory.loadById(orderGoodsModel.getCellId());
cabinetCellModel.setStock(cabinetCellModel.getStock() + orderGoodsModel.getQuantity());
cabinetCellModel.updateById();
}
}
@ -729,9 +736,7 @@ public class ReturnApprovalApplicationService {
orderGoodsModel.setStatus(5);
orderGoodsModel.updateById();
GoodsModel goodsModel = goodsModelFactory.loadById(orderGoods.getGoodsId());
// 如果商品免审批则自动审批
if (goodsModel.getAutoApproval().equals(1)) {
if (orderGoods.getMode() != null && orderGoods.getMode().equals(3)) {
UpdateReturnApprovalCommand approveCommand = new UpdateReturnApprovalCommand();
approveCommand.setCorpid(command.getCorpid());
approveCommand.setApprovalId(returnApprovalModel.getApprovalId());
@ -739,6 +744,18 @@ public class ReturnApprovalApplicationService {
approveCommand.setAuditName("自动审批");
approveCommand.setAuditRemark("自动审批");
approveApproval(approveCommand);
} else {
GoodsModel goodsModel = goodsModelFactory.loadById(orderGoods.getGoodsId());
// 如果商品免审批则自动审批
if (goodsModel.getAutoApproval().equals(1)) {
UpdateReturnApprovalCommand approveCommand = new UpdateReturnApprovalCommand();
approveCommand.setCorpid(command.getCorpid());
approveCommand.setApprovalId(returnApprovalModel.getApprovalId());
approveCommand.setReturnAmount(orderGoods.getTotalAmount());
approveCommand.setAuditName("自动审批");
approveCommand.setAuditRemark("自动审批");
approveApproval(approveCommand);
}
}
// 发送审核消息

View File

@ -32,11 +32,35 @@ public class SearchReturnApprovalQuery<T> extends AbstractPageQuery<T> {
private Date endTime;
private String paymentMethod;
private Date approvalTime;
private Integer handleStatus;
private String searchStr;
@Override
public QueryWrapper<T> addQueryCondition() {
QueryWrapper<T> queryWrapper = new QueryWrapper<>();
if (status == null && handleStatus != null) {
if (handleStatus == 0) {
queryWrapper.and(wrapper ->
wrapper.eq("ra.status", 1)
.or()
.eq("ra.status", 4));
} else if (handleStatus == 1) {
queryWrapper.and(wrapper ->
wrapper.eq("ra.status", 2)
.or()
.eq("ra.status", 3));
}
}
if (StrUtil.isNotEmpty(searchStr)) {
queryWrapper.and(wrapper ->
wrapper.like("so.name", searchStr)
.or()
.like("sog.goods_name", searchStr));
}
queryWrapper
.eq(approvalId != null, "ra.approval_id", approvalId)
.eq(orderId != null, "ra.order_id", orderId)

View File

@ -182,6 +182,7 @@ public class OrderApplicationService {
orderModel.setUserid(command.getQyUserid());
orderModel.setName(command.getName());
orderModel.setIsDeductStock(0);
orderModel.setMode(command.getMode());
orderModel.insert();
goodsList.forEach(goods -> {
@ -326,12 +327,18 @@ public class OrderApplicationService {
goodsModel.setUpdateTime(new Date());
goodsModel.setDeleted(false);
// 计算商品金额并验证库存
goodsModel.calculateTotal();
goodsModel.validateQuantity();
CabinetCellEntity cabinetCellEntity = cabinetCellService.getById(goodsModel.getCellId());
if (cabinetCellEntity == null || cabinetCellEntity.getStock() < goodsModel.getQuantity()) {
throw new ApiException(ErrorCode.FAILED, "柜子库存不足");
if (orderModel.getMode() != null && orderModel.getMode().equals(3)) {
goodsModel.setPrice(cabinetCellEntity.getCellPrice());
goodsModel.setTotalAmount(cabinetCellEntity.getCellPrice());
} else {
// 计算商品金额并验证库存
goodsModel.calculateTotal();
goodsModel.validateQuantity();
if (cabinetCellEntity == null || cabinetCellEntity.getStock() < goodsModel.getQuantity()) {
throw new ApiException(ErrorCode.FAILED, "柜子库存不足");
}
}
// 保存订单商品

View File

@ -31,6 +31,9 @@ public class SubmitOrderCommand {
@ApiModelProperty("联系电话")
private String mobile;
@ApiModelProperty("运行模式0-支付模式 1-审批模式 2-借还模式 3-会员模式 4-耗材模式)")
private Integer mode;
@ApiModelProperty("企业微信用户ID或汇邦云用户ID")
private String qyUserid;

View File

@ -74,9 +74,13 @@ public class ShopOrderEntity extends BaseEntity<ShopOrderEntity> {
private BigDecimal totalAmount;
@ApiModelProperty("订单状态1待付款 2已付款 3已发货 4已完成 5已取消")
@TableField("`status`")
@TableField("status")
private Integer status;
@ApiModelProperty("运行模式0-支付模式 1-审批模式 2-借还模式 3-会员模式 4-耗材模式)")
@TableField("mode")
private Integer mode;
@ApiModelProperty("支付状态1未支付 2已支付 3退款中 4已退款")
@TableField("pay_status")
private Integer payStatus;

View File

@ -69,9 +69,13 @@ public class ShopOrderGoodsEntity extends BaseEntity<ShopOrderGoodsEntity> {
private String coverImg;
@ApiModelProperty("商品状态1正常 2已退货 3已换货 4已完成 5审核中 6退货未通过")
@TableField("`status`")
@TableField("status")
private Integer status;
@ApiModelProperty("运行模式0-支付模式 1-审批模式 2-借还模式 3-会员模式 4-耗材模式)")
@TableField("mode")
private Integer mode;
@ApiModelProperty("企业微信id")
@TableField("corpid")
private String corpid;

View File

@ -39,6 +39,10 @@ public class ShopOrderDTO {
private BigDecimal totalAmount;
@ApiModelProperty("订单状态1待付款 2已付款 3已发货 4已完成 5已取消")
private Integer status;
@ApiModelProperty("运行模式0-支付模式 1-审批模式 2-借还模式 3-会员模式 4-耗材模式)")
private Integer mode;
@ApiModelProperty("支付状态1未支付 2已支付 3退款中 4已退款")
private Integer payStatus;
@ApiModelProperty("已扣减库存0否 1是")

View File

@ -10,6 +10,7 @@ import com.agileboot.domain.cabinet.cell.db.CabinetCellService;
import com.agileboot.domain.shop.goods.db.ShopGoodsEntity;
import com.agileboot.domain.shop.goods.db.ShopGoodsService;
import com.agileboot.domain.shop.order.db.ShopOrderEntity;
import com.agileboot.domain.shop.order.db.ShopOrderGoodsEntity;
import com.agileboot.domain.shop.order.db.ShopOrderGoodsService;
import com.agileboot.domain.shop.order.db.ShopOrderService;
import java.math.BigDecimal;
@ -98,10 +99,19 @@ public class OrderModel extends ShopOrderEntity {
this.updateById();
if (!isDeductStock) {
orderGoodsService.selectByOrderId(this.getOrderId()).forEach(orderGoods -> {
// 扣减库存
deductGoodsStock(orderGoods.getGoodsId(), orderGoods.getQuantity(), orderGoods.getCellId());
});
List<ShopOrderGoodsEntity> orderGoodsList = orderGoodsService.selectByOrderId(this.getOrderId());
if (this.getMode() != null && this.getMode().equals(3)) {
for (ShopOrderGoodsEntity orderGoods : orderGoodsList) {
CabinetCellEntity cell = cabinetCellService.getById(orderGoods.getCellId());
cell.setIsRented(1);
cell.updateById();
}
} else {
orderGoodsList.forEach(orderGoods -> {
// 扣减库存
deductGoodsStock(orderGoods.getGoodsId(), orderGoods.getQuantity(), orderGoods.getCellId());
});
}
}
}

View File

@ -26,11 +26,22 @@ public class SearchShopOrderQuery<T> extends AbstractPageQuery<T> {
private Date payTime;
private String paymentMethod;
private String corpid;
private Integer returnStatus;
private Integer mode;
@Override
public QueryWrapper<T> addQueryCondition() {
QueryWrapper<T> queryWrapper = new QueryWrapper<>();
if (returnStatus != null) {
if (returnStatus.equals(1)) {
queryWrapper.eq("o.pay_status", 2)
.eq("og.status", 2);
} else {
queryWrapper.eq("o.pay_status", 2)
.eq("og.status", 1);
}
}
queryWrapper
.eq(orderId != null, "o.order_id", orderId)
.eq(cellId != null, "og.cell_id", cellId)
@ -43,6 +54,7 @@ public class SearchShopOrderQuery<T> extends AbstractPageQuery<T> {
.eq(cabinetId != null, "cc.cabinet_id", cabinetId)
.eq(goodsId!= null, "og.goods_id", goodsId)
.eq(status != null, "o.status", status)
.eq(mode != null, "o.mode", mode)
.eq(payStatus != null, "o.pay_status", payStatus)
.eq(StrUtil.isNotEmpty(paymentMethod), "o.payment_method", paymentMethod)
.eq(StrUtil.isNotBlank(corpid), "o.corpid", corpid)

View File

@ -1,6 +1,10 @@
package com.agileboot.domain.shop.shop;
import com.agileboot.common.core.page.PageDTO;
import com.agileboot.domain.cabinet.cell.db.CabinetCellEntity;
import com.agileboot.domain.cabinet.cell.db.CabinetCellService;
import com.agileboot.domain.cabinet.smartCabinet.db.SmartCabinetEntity;
import com.agileboot.domain.cabinet.smartCabinet.db.SmartCabinetService;
import com.agileboot.domain.common.command.BulkOperationCommand;
import com.agileboot.domain.shop.shop.command.AddShopCommand;
import com.agileboot.domain.shop.shop.command.UpdateShopCommand;
@ -10,6 +14,7 @@ import com.agileboot.domain.shop.shop.dto.ShopDTO;
import com.agileboot.domain.shop.shop.model.ShopModel;
import com.agileboot.domain.shop.shop.model.ShopModelFactory;
import com.agileboot.domain.shop.shop.query.SearchShopQuery;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.util.List;
import java.util.stream.Collectors;
@ -23,8 +28,10 @@ import org.springframework.stereotype.Service;
public class ShopApplicationService {
private final ShopService shopService;
private final ShopModelFactory shopModelFactory;
private final SmartCabinetService smartCabinetService;
private final CabinetCellService cabinetCellService;
public PageDTO<ShopDTO> getShopList(SearchShopQuery<ShopEntity> query) {
public PageDTO<ShopDTO> getShopPage(SearchShopQuery<ShopEntity> query) {
Page<ShopEntity> page = shopService.getShopList(query.toPage(), query.toQueryWrapper());
List<ShopDTO> dtoList = page.getRecords().stream()
.map(ShopDTO::new)
@ -32,6 +39,13 @@ public class ShopApplicationService {
return new PageDTO<>(dtoList, page.getTotal());
}
public List<ShopDTO> getShopList(SearchShopQuery<ShopEntity> query) {
List<ShopEntity> list = shopService.list();
return list.stream()
.map(ShopDTO::new)
.collect(Collectors.toList());
}
public ShopDTO getShopById(Long shopId) {
ShopEntity shopEntity = shopService.getById(shopId);
return new ShopDTO(shopEntity);
@ -49,6 +63,29 @@ public class ShopApplicationService {
public void updateShop(UpdateShopCommand command) {
ShopModel model = shopModelFactory.loadById(command.getShopId());
if (command.getMode() != null && !command.getMode().equals(model.getMode())) {
if (command.getMode().equals(3)) {
QueryWrapper<SmartCabinetEntity> smartCabinetQueryWrapper = new QueryWrapper<>();
smartCabinetQueryWrapper.eq("shop_id", command.getShopId())
.eq("deleted", false);
List<SmartCabinetEntity> cabinetEntities = smartCabinetService.list(smartCabinetQueryWrapper);
if (cabinetEntities != null && !cabinetEntities.isEmpty()) {
QueryWrapper<CabinetCellEntity> cabinetCellQueryWrapper = new QueryWrapper<>();
cabinetCellQueryWrapper.in("cabinet_id", cabinetEntities.stream()
.map(SmartCabinetEntity::getCabinetId)
.collect(Collectors.toList()))
.isNotNull("goods_id")
.eq("deleted", false);
List<CabinetCellEntity> cells = cabinetCellService.list(cabinetCellQueryWrapper);
if (cells!= null && !cells.isEmpty()) {
throw new RuntimeException("该商店下存在已绑定商品的柜子,请先解绑商品后再修改模式");
}
}
}
}
model.loadUpdateCommand(command);
model.updateById();
}

17
sql/20250625.sql Normal file
View File

@ -0,0 +1,17 @@
ALTER TABLE `cabinet_cell`
ADD COLUMN `cell_price` decimal(15,2) NOT NULL DEFAULT '0.00' COMMENT '格口租用价格'
AFTER `stock`;
ALTER TABLE `cabinet_cell`
ADD COLUMN `is_rented` tinyint(1) NOT NULL DEFAULT 0 COMMENT '是否已租用0-未租用1-已租用'
AFTER `cell_price`;
ALTER TABLE `shop_order`
ADD COLUMN `mode` tinyint NOT NULL DEFAULT '0' COMMENT '运行模式0-支付模式 1-审批模式 2-借还模式 3-会员模式 4-耗材模式)'
AFTER `status`;
ALTER TABLE `shop_order_goods`
ADD COLUMN `mode` tinyint NOT NULL DEFAULT '0' COMMENT '运行模式0-支付模式 1-审批模式 2-借还模式 3-会员模式 4-耗材模式)'
AFTER `status`;