Compare commits
11 Commits
de166f62d1
...
04fd224005
Author | SHA1 | Date |
---|---|---|
|
04fd224005 | |
|
bab1a171bf | |
|
c83e7a7041 | |
|
eacf28be6f | |
|
65a0ceeb2b | |
|
065912f2c7 | |
|
4a9e6d8d1c | |
|
b1328b35ec | |
|
76647e5b95 | |
|
ff811ab6f6 | |
|
2091d1e925 |
|
@ -102,11 +102,18 @@ public class ShopController extends BaseController {
|
||||||
|
|
||||||
@Operation(summary = "商店列表")
|
@Operation(summary = "商店列表")
|
||||||
@GetMapping
|
@GetMapping
|
||||||
public ResponseDTO<PageDTO<ShopDTO>> list(SearchShopQuery<ShopEntity> query) {
|
public ResponseDTO<PageDTO<ShopDTO>> page(SearchShopQuery<ShopEntity> query) {
|
||||||
PageDTO<ShopDTO> page = shopApplicationService.getShopList(query);
|
PageDTO<ShopDTO> page = shopApplicationService.getShopPage(query);
|
||||||
return ResponseDTO.ok(page);
|
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 = "获取商店详情")
|
@Operation(summary = "获取商店详情")
|
||||||
@GetMapping("/{id}")
|
@GetMapping("/{id}")
|
||||||
public ResponseDTO<ShopDTO> getShopById(@PathVariable Long id) {
|
public ResponseDTO<ShopDTO> getShopById(@PathVariable Long id) {
|
||||||
|
|
|
@ -121,6 +121,10 @@ public class QywxScheduleJob {
|
||||||
String suiteAccessToken = templateApplicationService.getSuiteAccessToken(template.getSuiteId(), template.getSecret(),
|
String suiteAccessToken = templateApplicationService.getSuiteAccessToken(template.getSuiteId(), template.getSecret(),
|
||||||
template.getSuiteTicket());
|
template.getSuiteTicket());
|
||||||
|
|
||||||
|
if (StringUtils.isBlank(suiteAccessToken)) {
|
||||||
|
log.error("getSuiteAccessToken suiteAccessToken is null");
|
||||||
|
return;
|
||||||
|
}
|
||||||
UpdateTemplateCommand command = new UpdateTemplateCommand();
|
UpdateTemplateCommand command = new UpdateTemplateCommand();
|
||||||
command.setId(template.getId());
|
command.setId(template.getId());
|
||||||
command.setSuiteAccessToken(suiteAccessToken);
|
command.setSuiteAccessToken(suiteAccessToken);
|
||||||
|
|
|
@ -174,6 +174,9 @@ public class ApprovalApiController {
|
||||||
if (null == orderGoods) {
|
if (null == orderGoods) {
|
||||||
return ResponseDTO.fail(new ApiException(ErrorCode.Internal.INTERNAL_ERROR, "订单商品不存在"));
|
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);
|
ReturnApprovalEntity returnApproval = approvalApplicationService.submitApproval(command, orderGoods);
|
||||||
|
|
|
@ -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.operation.model.CabinetCellOperationModelFactory;
|
||||||
import com.agileboot.domain.cabinet.smartCabinet.SmartCabinetApplicationService;
|
import com.agileboot.domain.cabinet.smartCabinet.SmartCabinetApplicationService;
|
||||||
import com.agileboot.domain.cabinet.smartCabinet.dto.CabinetDetailDTO;
|
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.SmartCabinetModel;
|
||||||
import com.agileboot.domain.cabinet.smartCabinet.model.SmartCabinetModelFactory;
|
import com.agileboot.domain.cabinet.smartCabinet.model.SmartCabinetModelFactory;
|
||||||
import com.agileboot.domain.mqtt.MqttService;
|
import com.agileboot.domain.mqtt.MqttService;
|
||||||
|
@ -49,6 +50,11 @@ public class CabinetCellController {
|
||||||
return ResponseDTO.ok(smartCabinetApplicationService.getCabinetDetail(shopId));
|
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 = "配置格口商品库存")
|
@Operation(summary = "配置格口商品库存")
|
||||||
@PutMapping("/configureGoodsCellsStock/{cellId}/{goodsId}/{stock}")
|
@PutMapping("/configureGoodsCellsStock/{cellId}/{goodsId}/{stock}")
|
||||||
|
|
|
@ -6,6 +6,8 @@ import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
@ -51,6 +53,14 @@ public class CabinetCellEntity extends BaseEntity<CabinetCellEntity> {
|
||||||
@TableField("stock")
|
@TableField("stock")
|
||||||
private Integer 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超大格)")
|
@ApiModelProperty("格口类型(1小格 2中格 3大格 4超大格)")
|
||||||
@TableField("cell_type")
|
@TableField("cell_type")
|
||||||
private Integer cellType;
|
private Integer cellType;
|
||||||
|
|
|
@ -49,6 +49,12 @@ public class CabinetCellDTO {
|
||||||
@ExcelColumn(name = "库存数量")
|
@ExcelColumn(name = "库存数量")
|
||||||
private Integer stock;
|
private Integer stock;
|
||||||
|
|
||||||
|
@ExcelColumn(name = "格口租用价格")
|
||||||
|
private BigDecimal cellPrice;
|
||||||
|
|
||||||
|
@ExcelColumn(name = "是否已租用")
|
||||||
|
private Integer isRented;
|
||||||
|
|
||||||
@ExcelColumn(name = "订单数量")
|
@ExcelColumn(name = "订单数量")
|
||||||
private Integer orderCount;
|
private Integer orderCount;
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,9 @@ public class SearchCabinetCellQuery<T> extends AbstractPageQuery<T> {
|
||||||
private Long cabinetId;
|
private Long cabinetId;
|
||||||
private Integer cellNo;
|
private Integer cellNo;
|
||||||
private Integer cellType;
|
private Integer cellType;
|
||||||
|
|
||||||
|
private Integer isRented;
|
||||||
|
|
||||||
private Integer usageStatus;
|
private Integer usageStatus;
|
||||||
private Integer availableStatus;
|
private Integer availableStatus;
|
||||||
private Date startTime;
|
private Date startTime;
|
||||||
|
@ -29,6 +32,7 @@ public class SearchCabinetCellQuery<T> extends AbstractPageQuery<T> {
|
||||||
.eq(cabinetId != null, "cabinet_id", cabinetId)
|
.eq(cabinetId != null, "cabinet_id", cabinetId)
|
||||||
.eq(cellNo != null, "cell_no", cellNo)
|
.eq(cellNo != null, "cell_no", cellNo)
|
||||||
.eq(cellType != null, "cell_type", cellType)
|
.eq(cellType != null, "cell_type", cellType)
|
||||||
|
.eq(isRented != null, "is_rented", isRented)
|
||||||
.eq(usageStatus != null, "usage_status", usageStatus)
|
.eq(usageStatus != null, "usage_status", usageStatus)
|
||||||
.eq(availableStatus != null, "available_status", availableStatus)
|
.eq(availableStatus != null, "available_status", availableStatus)
|
||||||
.eq("deleted", false)
|
.eq("deleted", false)
|
||||||
|
|
|
@ -15,6 +15,9 @@ public class SearchCabinetCellWithOrdersQuery<T> extends AbstractPageQuery<T> {
|
||||||
private Long cabinetId;
|
private Long cabinetId;
|
||||||
private Integer cellNo;
|
private Integer cellNo;
|
||||||
private Integer cellType;
|
private Integer cellType;
|
||||||
|
|
||||||
|
private Integer isRented;
|
||||||
|
|
||||||
private Integer usageStatus;
|
private Integer usageStatus;
|
||||||
private Integer availableStatus;
|
private Integer availableStatus;
|
||||||
private Date startTime;
|
private Date startTime;
|
||||||
|
@ -30,6 +33,7 @@ public class SearchCabinetCellWithOrdersQuery<T> extends AbstractPageQuery<T> {
|
||||||
.eq(cabinetId != null, "cc.cabinet_id", cabinetId)
|
.eq(cabinetId != null, "cc.cabinet_id", cabinetId)
|
||||||
.eq(cellNo != null, "cc.cell_no", cellNo)
|
.eq(cellNo != null, "cc.cell_no", cellNo)
|
||||||
.eq(cellType != null, "cc.cell_type", cellType)
|
.eq(cellType != null, "cc.cell_type", cellType)
|
||||||
|
.eq(isRented != null, "cc.is_rented", isRented)
|
||||||
.eq(usageStatus != null, "cc.usage_status", usageStatus)
|
.eq(usageStatus != null, "cc.usage_status", usageStatus)
|
||||||
.eq(availableStatus != null, "cc.available_status", availableStatus)
|
.eq(availableStatus != null, "cc.available_status", availableStatus)
|
||||||
.eq("cc.deleted", false)
|
.eq("cc.deleted", false)
|
||||||
|
|
|
@ -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.mainboard.model.CabinetMainboardModelFactory;
|
||||||
import com.agileboot.domain.cabinet.smartCabinet.db.SmartCabinetDO;
|
import com.agileboot.domain.cabinet.smartCabinet.db.SmartCabinetDO;
|
||||||
import com.agileboot.domain.cabinet.smartCabinet.dto.CabinetDetailDTO;
|
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.common.command.BulkOperationCommand;
|
||||||
import com.agileboot.domain.cabinet.smartCabinet.command.AddSmartCabinetCommand;
|
import com.agileboot.domain.cabinet.smartCabinet.command.AddSmartCabinetCommand;
|
||||||
import com.agileboot.domain.cabinet.smartCabinet.command.UpdateSmartCabinetCommand;
|
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.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
@ -54,14 +56,15 @@ public class SmartCabinetApplicationService {
|
||||||
.map(SmartCabinetDTO::new)
|
.map(SmartCabinetDTO::new)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
dtoList.forEach(dto ->
|
dtoList.forEach(dto -> {
|
||||||
dto.setShopName(
|
ShopEntity shopDo = shopEntities.stream()
|
||||||
shopEntities.stream()
|
|
||||||
.filter(shop -> shop.getShopId().equals(dto.getShopId()))
|
.filter(shop -> shop.getShopId().equals(dto.getShopId()))
|
||||||
.findFirst()
|
.findFirst().orElse(null);
|
||||||
.map(ShopEntity::getShopName)
|
if (shopDo != null) {
|
||||||
.orElse(""))
|
dto.setShopName(shopDo.getShopName());
|
||||||
);
|
dto.setMode(shopDo.getMode());
|
||||||
|
}
|
||||||
|
});
|
||||||
return new PageDTO<>(dtoList, page.getTotal());
|
return new PageDTO<>(dtoList, page.getTotal());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,14 +75,15 @@ public class SmartCabinetApplicationService {
|
||||||
.map(SmartCabinetDTO::new)
|
.map(SmartCabinetDTO::new)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
dtoList.forEach(dto ->
|
dtoList.forEach(dto -> {
|
||||||
dto.setShopName(
|
ShopEntity shopDo = shopEntities.stream()
|
||||||
shopEntities.stream()
|
|
||||||
.filter(shop -> shop.getShopId().equals(dto.getShopId()))
|
.filter(shop -> shop.getShopId().equals(dto.getShopId()))
|
||||||
.findFirst()
|
.findFirst().orElse(null);
|
||||||
.map(ShopEntity::getShopName)
|
if (shopDo != null) {
|
||||||
.orElse(""))
|
dto.setShopName(shopDo.getShopName());
|
||||||
);
|
dto.setMode(shopDo.getMode());
|
||||||
|
}
|
||||||
|
});
|
||||||
return dtoList;
|
return dtoList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -219,6 +223,48 @@ public class SmartCabinetApplicationService {
|
||||||
return result;
|
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) {
|
public List<CabinetMainboardModel> createCabinetMainboardByTemplate(SmartCabinetModel cabinetModel) {
|
||||||
CabinetTemplateEnum template = CabinetTemplateEnum.getByCode(Integer.parseInt(cabinetModel.getTemplateNo()));
|
CabinetTemplateEnum template = CabinetTemplateEnum.getByCode(Integer.parseInt(cabinetModel.getTemplateNo()));
|
||||||
if (template == null) {
|
if (template == null) {
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
|
@ -290,6 +290,12 @@ public class ReturnApprovalApplicationService {
|
||||||
orderGoodsModel.setStatus(2); // 6表示已完成退货
|
orderGoodsModel.setStatus(2); // 6表示已完成退货
|
||||||
orderGoodsModel.updateById();
|
orderGoodsModel.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 goodsModel = goodsModelFactory.loadById(orderGoodsModel.getGoodsId());
|
||||||
goodsModel.setStock(goodsModel.getStock() + orderGoodsModel.getQuantity());
|
goodsModel.setStock(goodsModel.getStock() + orderGoodsModel.getQuantity());
|
||||||
|
@ -300,6 +306,7 @@ public class ReturnApprovalApplicationService {
|
||||||
cabinetCellModel.setStock(cabinetCellModel.getStock() + orderGoodsModel.getQuantity());
|
cabinetCellModel.setStock(cabinetCellModel.getStock() + orderGoodsModel.getQuantity());
|
||||||
cabinetCellModel.updateById();
|
cabinetCellModel.updateById();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -729,6 +736,15 @@ public class ReturnApprovalApplicationService {
|
||||||
orderGoodsModel.setStatus(5);
|
orderGoodsModel.setStatus(5);
|
||||||
orderGoodsModel.updateById();
|
orderGoodsModel.updateById();
|
||||||
|
|
||||||
|
if (orderGoods.getMode() != null && orderGoods.getMode().equals(3)) {
|
||||||
|
UpdateReturnApprovalCommand approveCommand = new UpdateReturnApprovalCommand();
|
||||||
|
approveCommand.setCorpid(command.getCorpid());
|
||||||
|
approveCommand.setApprovalId(returnApprovalModel.getApprovalId());
|
||||||
|
approveCommand.setReturnAmount(orderGoods.getTotalAmount());
|
||||||
|
approveCommand.setAuditName("自动审批");
|
||||||
|
approveCommand.setAuditRemark("自动审批");
|
||||||
|
approveApproval(approveCommand);
|
||||||
|
} else {
|
||||||
GoodsModel goodsModel = goodsModelFactory.loadById(orderGoods.getGoodsId());
|
GoodsModel goodsModel = goodsModelFactory.loadById(orderGoods.getGoodsId());
|
||||||
// 如果商品免审批,则自动审批
|
// 如果商品免审批,则自动审批
|
||||||
if (goodsModel.getAutoApproval().equals(1)) {
|
if (goodsModel.getAutoApproval().equals(1)) {
|
||||||
|
@ -740,6 +756,7 @@ public class ReturnApprovalApplicationService {
|
||||||
approveCommand.setAuditRemark("自动审批");
|
approveCommand.setAuditRemark("自动审批");
|
||||||
approveApproval(approveCommand);
|
approveApproval(approveCommand);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 发送审核消息
|
// 发送审核消息
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -32,11 +32,35 @@ public class SearchReturnApprovalQuery<T> extends AbstractPageQuery<T> {
|
||||||
private Date endTime;
|
private Date endTime;
|
||||||
private String paymentMethod;
|
private String paymentMethod;
|
||||||
private Date approvalTime;
|
private Date approvalTime;
|
||||||
|
private Integer handleStatus;
|
||||||
|
private String searchStr;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public QueryWrapper<T> addQueryCondition() {
|
public QueryWrapper<T> addQueryCondition() {
|
||||||
QueryWrapper<T> queryWrapper = new QueryWrapper<>();
|
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
|
queryWrapper
|
||||||
.eq(approvalId != null, "ra.approval_id", approvalId)
|
.eq(approvalId != null, "ra.approval_id", approvalId)
|
||||||
.eq(orderId != null, "ra.order_id", orderId)
|
.eq(orderId != null, "ra.order_id", orderId)
|
||||||
|
|
|
@ -182,6 +182,7 @@ public class OrderApplicationService {
|
||||||
orderModel.setUserid(command.getQyUserid());
|
orderModel.setUserid(command.getQyUserid());
|
||||||
orderModel.setName(command.getName());
|
orderModel.setName(command.getName());
|
||||||
orderModel.setIsDeductStock(0);
|
orderModel.setIsDeductStock(0);
|
||||||
|
orderModel.setMode(command.getMode());
|
||||||
orderModel.insert();
|
orderModel.insert();
|
||||||
|
|
||||||
goodsList.forEach(goods -> {
|
goodsList.forEach(goods -> {
|
||||||
|
@ -326,13 +327,19 @@ public class OrderApplicationService {
|
||||||
goodsModel.setUpdateTime(new Date());
|
goodsModel.setUpdateTime(new Date());
|
||||||
goodsModel.setDeleted(false);
|
goodsModel.setDeleted(false);
|
||||||
|
|
||||||
|
CabinetCellEntity cabinetCellEntity = cabinetCellService.getById(goodsModel.getCellId());
|
||||||
|
|
||||||
|
if (orderModel.getMode() != null && orderModel.getMode().equals(3)) {
|
||||||
|
goodsModel.setPrice(cabinetCellEntity.getCellPrice());
|
||||||
|
goodsModel.setTotalAmount(cabinetCellEntity.getCellPrice());
|
||||||
|
} else {
|
||||||
// 计算商品金额并验证库存
|
// 计算商品金额并验证库存
|
||||||
goodsModel.calculateTotal();
|
goodsModel.calculateTotal();
|
||||||
goodsModel.validateQuantity();
|
goodsModel.validateQuantity();
|
||||||
CabinetCellEntity cabinetCellEntity = cabinetCellService.getById(goodsModel.getCellId());
|
|
||||||
if (cabinetCellEntity == null || cabinetCellEntity.getStock() < goodsModel.getQuantity()) {
|
if (cabinetCellEntity == null || cabinetCellEntity.getStock() < goodsModel.getQuantity()) {
|
||||||
throw new ApiException(ErrorCode.FAILED, "柜子库存不足");
|
throw new ApiException(ErrorCode.FAILED, "柜子库存不足");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 保存订单商品
|
// 保存订单商品
|
||||||
goodsModel.insert();
|
goodsModel.insert();
|
||||||
|
|
|
@ -31,6 +31,9 @@ public class SubmitOrderCommand {
|
||||||
@ApiModelProperty("联系电话")
|
@ApiModelProperty("联系电话")
|
||||||
private String mobile;
|
private String mobile;
|
||||||
|
|
||||||
|
@ApiModelProperty("运行模式(0-支付模式 1-审批模式 2-借还模式 3-会员模式 4-耗材模式)")
|
||||||
|
private Integer mode;
|
||||||
|
|
||||||
@ApiModelProperty("企业微信用户ID或汇邦云用户ID")
|
@ApiModelProperty("企业微信用户ID或汇邦云用户ID")
|
||||||
private String qyUserid;
|
private String qyUserid;
|
||||||
|
|
||||||
|
|
|
@ -74,9 +74,13 @@ public class ShopOrderEntity extends BaseEntity<ShopOrderEntity> {
|
||||||
private BigDecimal totalAmount;
|
private BigDecimal totalAmount;
|
||||||
|
|
||||||
@ApiModelProperty("订单状态(1待付款 2已付款 3已发货 4已完成 5已取消)")
|
@ApiModelProperty("订单状态(1待付款 2已付款 3已发货 4已完成 5已取消)")
|
||||||
@TableField("`status`")
|
@TableField("status")
|
||||||
private Integer status;
|
private Integer status;
|
||||||
|
|
||||||
|
@ApiModelProperty("运行模式(0-支付模式 1-审批模式 2-借还模式 3-会员模式 4-耗材模式)")
|
||||||
|
@TableField("mode")
|
||||||
|
private Integer mode;
|
||||||
|
|
||||||
@ApiModelProperty("支付状态(1未支付 2已支付 3退款中 4已退款)")
|
@ApiModelProperty("支付状态(1未支付 2已支付 3退款中 4已退款)")
|
||||||
@TableField("pay_status")
|
@TableField("pay_status")
|
||||||
private Integer payStatus;
|
private Integer payStatus;
|
||||||
|
|
|
@ -69,9 +69,13 @@ public class ShopOrderGoodsEntity extends BaseEntity<ShopOrderGoodsEntity> {
|
||||||
private String coverImg;
|
private String coverImg;
|
||||||
|
|
||||||
@ApiModelProperty("商品状态(1正常 2已退货 3已换货 4已完成 5审核中 6退货未通过)")
|
@ApiModelProperty("商品状态(1正常 2已退货 3已换货 4已完成 5审核中 6退货未通过)")
|
||||||
@TableField("`status`")
|
@TableField("status")
|
||||||
private Integer status;
|
private Integer status;
|
||||||
|
|
||||||
|
@ApiModelProperty("运行模式(0-支付模式 1-审批模式 2-借还模式 3-会员模式 4-耗材模式)")
|
||||||
|
@TableField("mode")
|
||||||
|
private Integer mode;
|
||||||
|
|
||||||
@ApiModelProperty("企业微信id")
|
@ApiModelProperty("企业微信id")
|
||||||
@TableField("corpid")
|
@TableField("corpid")
|
||||||
private String corpid;
|
private String corpid;
|
||||||
|
|
|
@ -39,6 +39,10 @@ public class ShopOrderDTO {
|
||||||
private BigDecimal totalAmount;
|
private BigDecimal totalAmount;
|
||||||
@ApiModelProperty("订单状态(1待付款 2已付款 3已发货 4已完成 5已取消)")
|
@ApiModelProperty("订单状态(1待付款 2已付款 3已发货 4已完成 5已取消)")
|
||||||
private Integer status;
|
private Integer status;
|
||||||
|
|
||||||
|
@ApiModelProperty("运行模式(0-支付模式 1-审批模式 2-借还模式 3-会员模式 4-耗材模式)")
|
||||||
|
private Integer mode;
|
||||||
|
|
||||||
@ApiModelProperty("支付状态(1未支付 2已支付 3退款中 4已退款)")
|
@ApiModelProperty("支付状态(1未支付 2已支付 3退款中 4已退款)")
|
||||||
private Integer payStatus;
|
private Integer payStatus;
|
||||||
@ApiModelProperty("已扣减库存(0否 1是)")
|
@ApiModelProperty("已扣减库存(0否 1是)")
|
||||||
|
|
|
@ -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.ShopGoodsEntity;
|
||||||
import com.agileboot.domain.shop.goods.db.ShopGoodsService;
|
import com.agileboot.domain.shop.goods.db.ShopGoodsService;
|
||||||
import com.agileboot.domain.shop.order.db.ShopOrderEntity;
|
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.ShopOrderGoodsService;
|
||||||
import com.agileboot.domain.shop.order.db.ShopOrderService;
|
import com.agileboot.domain.shop.order.db.ShopOrderService;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
@ -98,12 +99,21 @@ public class OrderModel extends ShopOrderEntity {
|
||||||
this.updateById();
|
this.updateById();
|
||||||
|
|
||||||
if (!isDeductStock) {
|
if (!isDeductStock) {
|
||||||
orderGoodsService.selectByOrderId(this.getOrderId()).forEach(orderGoods -> {
|
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());
|
deductGoodsStock(orderGoods.getGoodsId(), orderGoods.getQuantity(), orderGoods.getCellId());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void handleRefundSuccess() {
|
public void handleRefundSuccess() {
|
||||||
// 更新订单状态
|
// 更新订单状态
|
||||||
|
|
|
@ -26,11 +26,22 @@ public class SearchShopOrderQuery<T> extends AbstractPageQuery<T> {
|
||||||
private Date payTime;
|
private Date payTime;
|
||||||
private String paymentMethod;
|
private String paymentMethod;
|
||||||
private String corpid;
|
private String corpid;
|
||||||
|
private Integer returnStatus;
|
||||||
|
private Integer mode;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public QueryWrapper<T> addQueryCondition() {
|
public QueryWrapper<T> addQueryCondition() {
|
||||||
QueryWrapper<T> queryWrapper = new QueryWrapper<>();
|
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
|
queryWrapper
|
||||||
.eq(orderId != null, "o.order_id", orderId)
|
.eq(orderId != null, "o.order_id", orderId)
|
||||||
.eq(cellId != null, "og.cell_id", cellId)
|
.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(cabinetId != null, "cc.cabinet_id", cabinetId)
|
||||||
.eq(goodsId!= null, "og.goods_id", goodsId)
|
.eq(goodsId!= null, "og.goods_id", goodsId)
|
||||||
.eq(status != null, "o.status", status)
|
.eq(status != null, "o.status", status)
|
||||||
|
.eq(mode != null, "o.mode", mode)
|
||||||
.eq(payStatus != null, "o.pay_status", payStatus)
|
.eq(payStatus != null, "o.pay_status", payStatus)
|
||||||
.eq(StrUtil.isNotEmpty(paymentMethod), "o.payment_method", paymentMethod)
|
.eq(StrUtil.isNotEmpty(paymentMethod), "o.payment_method", paymentMethod)
|
||||||
.eq(StrUtil.isNotBlank(corpid), "o.corpid", corpid)
|
.eq(StrUtil.isNotBlank(corpid), "o.corpid", corpid)
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
package com.agileboot.domain.shop.shop;
|
package com.agileboot.domain.shop.shop;
|
||||||
|
|
||||||
import com.agileboot.common.core.page.PageDTO;
|
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.common.command.BulkOperationCommand;
|
||||||
import com.agileboot.domain.shop.shop.command.AddShopCommand;
|
import com.agileboot.domain.shop.shop.command.AddShopCommand;
|
||||||
import com.agileboot.domain.shop.shop.command.UpdateShopCommand;
|
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.ShopModel;
|
||||||
import com.agileboot.domain.shop.shop.model.ShopModelFactory;
|
import com.agileboot.domain.shop.shop.model.ShopModelFactory;
|
||||||
import com.agileboot.domain.shop.shop.query.SearchShopQuery;
|
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 com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
@ -23,8 +28,10 @@ import org.springframework.stereotype.Service;
|
||||||
public class ShopApplicationService {
|
public class ShopApplicationService {
|
||||||
private final ShopService shopService;
|
private final ShopService shopService;
|
||||||
private final ShopModelFactory shopModelFactory;
|
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());
|
Page<ShopEntity> page = shopService.getShopList(query.toPage(), query.toQueryWrapper());
|
||||||
List<ShopDTO> dtoList = page.getRecords().stream()
|
List<ShopDTO> dtoList = page.getRecords().stream()
|
||||||
.map(ShopDTO::new)
|
.map(ShopDTO::new)
|
||||||
|
@ -32,6 +39,13 @@ public class ShopApplicationService {
|
||||||
return new PageDTO<>(dtoList, page.getTotal());
|
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) {
|
public ShopDTO getShopById(Long shopId) {
|
||||||
ShopEntity shopEntity = shopService.getById(shopId);
|
ShopEntity shopEntity = shopService.getById(shopId);
|
||||||
return new ShopDTO(shopEntity);
|
return new ShopDTO(shopEntity);
|
||||||
|
@ -49,6 +63,29 @@ public class ShopApplicationService {
|
||||||
|
|
||||||
public void updateShop(UpdateShopCommand command) {
|
public void updateShop(UpdateShopCommand command) {
|
||||||
ShopModel model = shopModelFactory.loadById(command.getShopId());
|
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.loadUpdateCommand(command);
|
||||||
model.updateById();
|
model.updateById();
|
||||||
}
|
}
|
||||||
|
|
|
@ -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`;
|
Loading…
Reference in New Issue