feat(商品): 添加belongType字段并优化审批流程

在SearchGoodsWithCabinetDO中添加belongType字段以支持商品分类
优化ReturnApprovalApplicationService中的审批流程,添加订单商品校验和状态更新
简化ShopGoodsMapper中的SQL查询语句
重构OrderApplicationService中的submitAssetApproval方法,使用完整命令对象
This commit is contained in:
dzq 2025-06-09 17:38:54 +08:00
parent 4da0d35be4
commit 848f9d9606
4 changed files with 23 additions and 13 deletions

View File

@ -1,5 +1,6 @@
package com.agileboot.domain.shop.approval;
import cn.hutool.core.date.DateUtil;
import cn.hutool.json.JSONUtil;
import com.agileboot.common.constant.PayApiConstants;
import com.agileboot.common.constant.WeixinConstants;
@ -247,6 +248,10 @@ public class ReturnApprovalApplicationService {
// 获取关联的订单商品列表
List<ShopOrderGoodsEntity> shopOrderGoodsList = shopOrderGoodsService.selectOrderGoodsByApprovalId(model.getApprovalId());
if (shopOrderGoodsList == null || shopOrderGoodsList.isEmpty()) {
throw new RuntimeException("未找到关联的订单商品");
}
// 设置审批人信息
if (StringUtils.isNotBlank(command.getAuditName())) {
model.setAuditName(command.getAuditName());
@ -311,6 +316,14 @@ public class ReturnApprovalApplicationService {
// 批量更新格口库存
cabinetCellModelList.forEach(CabinetCellModel::updateById);
OrderModel orderModel = orderModelFactory.loadById(shopOrderGoodsList.get(0).getOrderId());
orderModel.setStatus(2);
orderModel.setPayStatus(2);
orderModel.setPayTime(new Date());
orderModel.setIsDeductStock(1);
orderModel.updateById();
}
/**

View File

@ -22,6 +22,7 @@ public class SearchGoodsWithCabinetDO extends BaseEntity<SearchGoodsWithCabinetD
private String goodsDetail;
private String usageInstruction;
private String remark;
private Integer belongType;
@TableField("sc.cabinet_id")
private Long cabinetId;

View File

@ -64,9 +64,7 @@ public interface ShopGoodsMapper extends BaseMapper<ShopGoodsEntity> {
* 查询商品及其关联的柜机格口信息
* @return 商品列表
*/
@Select("SELECT g.goods_id, g.goods_name, g.category_id, g.price, " +
"g.status, g.cover_img, g.goods_detail, g.usage_instruction, " +
"g.creator_id, g.create_time, g.updater_id, g.update_time, g.remark, g.deleted, " +
@Select("SELECT g.*, " +
"sc.cabinet_id, sc.cabinet_name, cc.stock, cc.cell_id " +
"FROM shop_goods g " +
"LEFT JOIN cabinet_cell cc ON g.goods_id = cc.goods_id " +
@ -74,9 +72,7 @@ public interface ShopGoodsMapper extends BaseMapper<ShopGoodsEntity> {
"WHERE g.deleted = 0 AND g.belong_type = 0 AND sc.deleted = 0 AND cc.deleted = 0 AND cc.goods_id IS NOT NULL ")
List<SearchGoodsWithCabinetDO> getGoodsWithCabinetList();
@Select("SELECT g.goods_id, g.goods_name, g.category_id, g.price, " +
"g.status, g.cover_img, g.goods_detail, g.usage_instruction, " +
"g.creator_id, g.create_time, g.updater_id, g.update_time, g.remark, g.deleted, " +
@Select("SELECT g.*, " +
"sc.cabinet_id, sc.cabinet_name, sc.shop_id, cc.stock, cc.cell_id " +
"FROM shop_goods g " +
"LEFT JOIN cabinet_cell cc ON g.goods_id = cc.goods_id " +

View File

@ -213,22 +213,22 @@ public class OrderApplicationService {
"balance-" + orderModel.getOrderId(), DateUtil.formatDateTime(new Date()));
return new CreateOrderResult(orderModel.getOrderId(), orderModel.getTotalAmount(), null, qyUser.getBalance());
} else if (Objects.equals(command.getPaymentType(), "approval")) {
submitAssetApproval(orderModel, goodsList, command.getCorpid(), command.getName());
submitAssetApproval(orderModel, goodsList, command);
return new CreateOrderResult(orderModel.getOrderId(), orderModel.getTotalAmount(), null, BigDecimal.valueOf(0));
}else {
throw new ApiException(ErrorCode.Client.COMMON_REQUEST_PARAMETERS_INVALID, "无效的支付类型");
}
}
private void submitAssetApproval(OrderModel orderModel, List<ShopOrderGoodsEntity> orderGoodsList, String corpid, String name) {
private void submitAssetApproval(OrderModel orderModel, List<ShopOrderGoodsEntity> orderGoodsList, SubmitOrderCommand submitOrderCommand) {
ShopOrderGoodsEntity firstOrderGoods = orderGoodsList.get(0);
// 设置商品价格并初始化审批状态
AddReturnApprovalCommand command = new AddReturnApprovalCommand();
command.initBaseEntity();
command.setGoodsId(firstOrderGoods.getGoodsId());
command.setOrderId(orderModel.getOrderId());
command.setReturnImages(command.getReturnImages());
command.setReturnRemark(command.getReturnRemark());
command.setApplyRemark(submitOrderCommand.getApplyRemark());
command.setApprovalType(1);
command.setStatus(1);
command.setCreatorId(0L);
command.setCreateTime(new Date());
@ -259,7 +259,7 @@ public class OrderApplicationService {
.findFirst().orElse(null);
QyAccessTokenEntity accessToken = accessTokenApplicationService.getByAppid(appid, authCorpInfo.getCorpid());
// 获取用户ID
List<String> adminUserIds = qyUserService.selectAdminUserIds(corpid);
List<String> adminUserIds = qyUserService.selectAdminUserIds(submitOrderCommand.getCorpid());
String toUser = String.join("|", adminUserIds);
String toparty = "";
String totag = "";
@ -268,9 +268,9 @@ public class OrderApplicationService {
article.setTitle("耗材领用申请通知");
article.setDescription("领用商品:" + firstOrderGoods.getGoodsName());
if (orderGoodsList.size() > 1) {
article.setDescription(name + " 申请领用" + firstOrderGoods.getGoodsName() + "" + orderGoodsList.size() + "件商品");
article.setDescription(submitOrderCommand.getName() + " 申请领用" + firstOrderGoods.getGoodsName() + "" + orderGoodsList.size() + "件商品");
} else {
article.setDescription(name + " 申请领用" + firstOrderGoods.getGoodsName());
article.setDescription(submitOrderCommand.getName() + " 申请领用" + firstOrderGoods.getGoodsName());
}
article.setPicurl(firstOrderGoods.getCoverImg());
article.setUrl("http://wxshop.ab98.cn/shop-api/api/shop/qy/wechatAuth");