diff --git a/agileboot-api/src/main/java/com/agileboot/api/controller/asset/AssetApiController.java b/agileboot-api/src/main/java/com/agileboot/api/controller/asset/AssetApiController.java index c18b2dc..75c08a2 100644 --- a/agileboot-api/src/main/java/com/agileboot/api/controller/asset/AssetApiController.java +++ b/agileboot-api/src/main/java/com/agileboot/api/controller/asset/AssetApiController.java @@ -1,25 +1,20 @@ package com.agileboot.api.controller.asset; -import cn.hutool.json.JSONUtil; import com.agileboot.common.constant.OpenApiConstants; import com.agileboot.common.core.dto.ResponseDTO; import com.agileboot.common.exception.ApiException; import com.agileboot.common.exception.error.ErrorCode; import com.agileboot.domain.asset.AssetApplicationService; -import com.agileboot.domain.asset.api.PostAssetGoodsBody; +import com.agileboot.domain.asset.command.PostAssetApprovalCommand; import com.agileboot.domain.asset.command.PostAssetGoodsCommand; import com.agileboot.domain.shop.payment.SignUtils; import com.agileboot.domain.shop.payment.dto.CommonRequest; -import com.fasterxml.jackson.core.type.TypeReference; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.web.bind.annotation.*; import java.io.UnsupportedEncodingException; -import java.net.URLDecoder; -import java.nio.charset.StandardCharsets; -import java.util.List; @Slf4j @RestController @@ -30,7 +25,7 @@ public class AssetApiController { private final AssetApplicationService assetApplicationService; @PostMapping("/pushExternalGoods") - public ResponseDTO pushExternalGoods(@RequestBody String body) throws UnsupportedEncodingException { + public ResponseDTO pushExternalGoods(@RequestBody String body) { CommonRequest notifyRequest = CommonRequest.build(body, PostAssetGoodsCommand.class); if (notifyRequest == null) { return ResponseDTO.fail(new ApiException(ErrorCode.Client.COMMON_REQUEST_PARAMETERS_INVALID, "请求参数无效")); @@ -42,4 +37,19 @@ public class AssetApiController { assetApplicationService.pushExternalGoods(notifyRequest.getBizContent()); return ResponseDTO.ok(); } + + + @PostMapping("/postAssetApproval") + public ResponseDTO postAssetApproval(@RequestBody String body) { + CommonRequest notifyRequest = CommonRequest.build(body, PostAssetApprovalCommand.class); + if (notifyRequest == null) { + return ResponseDTO.fail(new ApiException(ErrorCode.Client.COMMON_REQUEST_PARAMETERS_INVALID, "请求参数无效")); + } + log.info("pushExternalGoods sign:{}, body:{}", notifyRequest.getSign(), body); + if (!SignUtils.checkOpenSign(OpenApiConstants.appKey, notifyRequest.getSign(), body)) { + return ResponseDTO.fail(new ApiException(ErrorCode.Client.COMMON_REQUEST_PARAMETERS_INVALID, "sign校验失败")); + } + assetApplicationService.postAssetApprovalCommand(notifyRequest.getBizContent()); + return ResponseDTO.ok(); + } } diff --git a/agileboot-api/src/test/java/com/agileboot/api/controller/AssetApiControllerTest.java b/agileboot-api/src/test/java/com/agileboot/api/controller/AssetApiControllerTest.java index 391cfed..195be2f 100644 --- a/agileboot-api/src/test/java/com/agileboot/api/controller/AssetApiControllerTest.java +++ b/agileboot-api/src/test/java/com/agileboot/api/controller/AssetApiControllerTest.java @@ -3,8 +3,7 @@ package com.agileboot.api.controller; import cn.hutool.http.HttpUtil; import cn.hutool.json.JSONUtil; import com.agileboot.common.constant.OpenApiConstants; -import com.agileboot.common.core.dto.ResponseDTO; -import com.agileboot.domain.asset.api.PostAssetGoodsBody; +import com.agileboot.domain.asset.command.PostAssetApprovalCommand; import com.agileboot.domain.asset.command.PostAssetGoodsCommand; import com.agileboot.domain.shop.payment.SignUtils; import lombok.extern.slf4j.Slf4j; @@ -22,16 +21,21 @@ public class AssetApiControllerTest { @Test public void testPushExternalGoods() throws UnsupportedEncodingException { // 1.构建测试商品数据 + PostAssetGoodsCommand.GoodsInfo goodsInfo = new PostAssetGoodsCommand.GoodsInfo(); + goodsInfo.setExternalGoodsId(1003L); + goodsInfo.setGoodsName("测试笔记本电脑3"); + goodsInfo.setPrice(new BigDecimal("5999.00")); + goodsInfo.setStock(10); + goodsInfo.setAutoApproval(0); + goodsInfo.setCoverImg("https://example.com/laptop.jpg"); + goodsInfo.setGoodsDetail("商品详情内容,支持2000汉字和10张图片链接"); + goodsInfo.setUsageInstruction("1. 使用前请充电\n2. 避免液体接触\n3. 定期清理灰尘"); + goodsInfo.setBelongType(1); + PostAssetGoodsCommand goods = new PostAssetGoodsCommand(); - goods.setExternalGoodsId(1002L); - goods.setGoodsName("测试笔记本电脑"); - goods.setPrice(new BigDecimal("5999.00")); - goods.setStock(10); - goods.setAutoApproval(1); - goods.setCoverImg("https://example.com/laptop.jpg"); - goods.setGoodsDetail("商品详情内容,支持2000汉字和10张图片链接"); - goods.setUsageInstruction("1. 使用前请充电\n2. 避免液体接触\n3. 定期清理灰尘"); - goods.setBelongType(1); + goods.setCorpid("wpZ1ZrEgAA2QTxIRcB4cMtY7hQbTcPAw"); + goods.setGoodsInfoList(new ArrayList<>()); + goods.getGoodsInfoList().add(goodsInfo); // 2.构造请求体 Map params = new HashMap<>(); @@ -58,4 +62,46 @@ public class AssetApiControllerTest { log.info("接口响应: {}", res); } + + + @Test + public void testPostAssetApproval() throws UnsupportedEncodingException { + // 1.构建测试商品数据 + PostAssetApprovalCommand approvalCommand = new PostAssetApprovalCommand(); + approvalCommand.setCorpid("wpZ1ZrEgAA2QTxIRcB4cMtY7hQbTcPAw"); + approvalCommand.setExternalApprovalId(1L); + approvalCommand.setExternalGoodsId(1003L); + approvalCommand.setApplyQuantity(2); + approvalCommand.setApprovalType(1); + approvalCommand.setApplyRemark("申请说明"); + approvalCommand.setMobile("12345678901"); + approvalCommand.setUserid("123"); + approvalCommand.setName("姓名"); + approvalCommand.setIsInternal(2); + + // 2.构造请求体 + Map params = new HashMap<>(); + params.put("timestamp", String.valueOf(System.currentTimeMillis())); + params.put("biz_content", URLEncoder.encode(JSONUtil.toJsonStr(approvalCommand), StandardCharsets.UTF_8.toString())); + + // 3.生成签名参数 + + String appKey = OpenApiConstants.appKey; + String sign = SignUtils.openSign(appKey, params); + params.put("sign", sign); + + // 4.构造完整请求JSON + StringBuilder sb = new StringBuilder(); + for (String key : params.keySet()) { + if (sb.length() > 0) { + sb.append("&"); + } + sb.append(key).append("=").append(params.get(key)); + } + + // 5.发送POST请求 + String res = HttpUtil.post("http://localhost:8090/api/asset/postAssetApproval", sb.toString()); + + log.info("接口响应: {}", res); + } } \ No newline at end of file diff --git a/agileboot-domain/src/main/java/com/agileboot/domain/asset/AssetApplicationService.java b/agileboot-domain/src/main/java/com/agileboot/domain/asset/AssetApplicationService.java index 121d309..d803edb 100644 --- a/agileboot-domain/src/main/java/com/agileboot/domain/asset/AssetApplicationService.java +++ b/agileboot-domain/src/main/java/com/agileboot/domain/asset/AssetApplicationService.java @@ -1,16 +1,29 @@ package com.agileboot.domain.asset; -import cn.hutool.json.JSONUtil; -import com.agileboot.domain.asset.api.PostAssetGoodsBody; +import com.agileboot.common.constant.WeixinConstants; +import com.agileboot.domain.asset.command.PostAssetApprovalCommand; import com.agileboot.domain.asset.command.PostAssetGoodsCommand; +import com.agileboot.domain.qywx.accessToken.AccessTokenApplicationService; +import com.agileboot.domain.qywx.accessToken.db.QyAccessTokenEntity; +import com.agileboot.domain.qywx.api.QywxApiUtil; +import com.agileboot.domain.qywx.api.response.NewsArticle; +import com.agileboot.domain.qywx.authCorpInfo.AuthCorpInfoApplicationService; +import com.agileboot.domain.qywx.authCorpInfo.db.QyAuthCorpInfoEntity; +import com.agileboot.domain.qywx.user.db.QyUserService; +import com.agileboot.domain.shop.approval.command.AddReturnApprovalCommand; +import com.agileboot.domain.shop.approval.model.ReturnApprovalModel; +import com.agileboot.domain.shop.approval.model.ReturnApprovalModelFactory; import com.agileboot.domain.shop.goods.db.ShopGoodsEntity; import com.agileboot.domain.shop.goods.db.ShopGoodsService; import com.agileboot.domain.shop.goods.model.GoodsModel; import com.agileboot.domain.shop.goods.model.GoodsModelFactory; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; +import java.util.ArrayList; import java.util.List; @Slf4j @@ -19,55 +32,126 @@ import java.util.List; public class AssetApplicationService { private final ShopGoodsService shopGoodsService; private final GoodsModelFactory goodsModelFactory; + private final ReturnApprovalModelFactory returnApprovalModelFactory; + private final AuthCorpInfoApplicationService authCorpInfoApplicationService; + private final AccessTokenApplicationService accessTokenApplicationService; + private final QyUserService qyUserService; - public void pushExternalGoods(PostAssetGoodsCommand command) { - if (command == null || command.getExternalGoodsId() == null) { - throw new IllegalArgumentException("ExternalGoodsId cannot be null"); + public void pushExternalGoods(PostAssetGoodsCommand postAssetGoodsCommand) { + if (postAssetGoodsCommand == null || postAssetGoodsCommand.getGoodsInfoList() == null || postAssetGoodsCommand.getGoodsInfoList().isEmpty()) { + throw new IllegalArgumentException("GoodsInfoList cannot be null or empty"); } - ShopGoodsEntity shopGoodsEntity = shopGoodsService.getGoodsByExternalGoodsId(command.getExternalGoodsId()); - if (shopGoodsEntity != null) { - if (command.getGoodsName() != null) { - shopGoodsEntity.setGoodsName(command.getGoodsName()); + if (postAssetGoodsCommand.getCorpid() == null) { + throw new IllegalArgumentException("Corpid cannot be null"); + } + + for (PostAssetGoodsCommand.GoodsInfo command : postAssetGoodsCommand.getGoodsInfoList()) { + if (command == null || command.getExternalGoodsId() == null) { + throw new IllegalArgumentException("ExternalGoodsId cannot be null"); } - if (command.getPrice() != null) { - shopGoodsEntity.setPrice(command.getPrice()); + ShopGoodsEntity shopGoodsEntity = shopGoodsService.getGoodsByExternalGoodsId(postAssetGoodsCommand.getCorpid(), command.getExternalGoodsId()); + if (shopGoodsEntity != null) { + if (command.getGoodsName() != null) { + shopGoodsEntity.setGoodsName(command.getGoodsName()); + } + if (command.getPrice() != null) { + shopGoodsEntity.setPrice(command.getPrice()); + } + if (command.getStock() != null) { + shopGoodsEntity.setStock(command.getStock()); + } + if (command.getAutoApproval() != null) { + shopGoodsEntity.setAutoApproval(command.getAutoApproval()); + } + if (command.getCoverImg() != null) { + shopGoodsEntity.setCoverImg(command.getCoverImg()); + } + if (command.getGoodsDetail() != null) { + shopGoodsEntity.setGoodsDetail(command.getGoodsDetail()); + } + if (command.getUsageInstruction() != null) { + shopGoodsEntity.setUsageInstruction(command.getUsageInstruction()); + } + if (command.getBelongType() != null) { + shopGoodsEntity.setBelongType(command.getBelongType()); + } + shopGoodsEntity.updateById(); + } else { + GoodsModel goodsModel = goodsModelFactory.create(); + goodsModel.setCorpid(postAssetGoodsCommand.getCorpid()); + goodsModel.setExternalGoodsId(command.getExternalGoodsId()); + goodsModel.setGoodsName(command.getGoodsName()); + goodsModel.setPrice(command.getPrice()); + goodsModel.setStock(command.getStock()); + goodsModel.setAutoApproval(command.getAutoApproval()); + goodsModel.setCoverImg(command.getCoverImg()); + goodsModel.setGoodsDetail(command.getGoodsDetail()); + goodsModel.setUsageInstruction(command.getUsageInstruction()); + goodsModel.setBelongType(command.getBelongType()); + goodsModel.initBaseEntity(); + goodsModel.setCategoryId(0L); + goodsModel.setStatus(1); + goodsModel.insert(); } - if (command.getStock() != null) { - shopGoodsEntity.setStock(command.getStock()); - } - if (command.getAutoApproval() != null) { - shopGoodsEntity.setAutoApproval(command.getAutoApproval()); - } - if (command.getCoverImg() != null) { - shopGoodsEntity.setCoverImg(command.getCoverImg()); - } - if (command.getGoodsDetail() != null) { - shopGoodsEntity.setGoodsDetail(command.getGoodsDetail()); - } - if (command.getUsageInstruction() != null) { - shopGoodsEntity.setUsageInstruction(command.getUsageInstruction()); - } - if (command.getBelongType() != null) { - shopGoodsEntity.setBelongType(command.getBelongType()); - } - shopGoodsEntity.updateById(); - } else { - GoodsModel goodsModel = goodsModelFactory.create(); - goodsModel.setExternalGoodsId(command.getExternalGoodsId()); - goodsModel.setGoodsName(command.getGoodsName()); - goodsModel.setPrice(command.getPrice()); - goodsModel.setStock(command.getStock()); - goodsModel.setAutoApproval(command.getAutoApproval()); - goodsModel.setCoverImg(command.getCoverImg()); - goodsModel.setGoodsDetail(command.getGoodsDetail()); - goodsModel.setUsageInstruction(command.getUsageInstruction()); - goodsModel.setBelongType(command.getBelongType()); - goodsModel.initBaseEntity(); - goodsModel.setCategoryId(0L); - goodsModel.setStatus(1); - goodsModel.insert(); } } + public void postAssetApprovalCommand(PostAssetApprovalCommand command) { + if (command == null || command.getExternalGoodsId() == null || StringUtils.isBlank(command.getCorpid())) { + throw new IllegalArgumentException("ExternalGoodsId cannot be null"); + } + if (command.getApplyQuantity() == null || command.getApplyQuantity() <= 0) { + throw new IllegalArgumentException("ApplyQuantity must be greater than 0"); + } + + ShopGoodsEntity shopGoodsEntity = shopGoodsService.getGoodsByExternalGoodsId(command.getCorpid(), command.getExternalGoodsId()); + if (shopGoodsEntity == null) { + throw new IllegalArgumentException("ExternalGoodsId not found"); + } + if (shopGoodsEntity.getStock() == null || shopGoodsEntity.getStock() < command.getApplyQuantity()) { + throw new IllegalArgumentException("Insufficient stock"); + } + + AddReturnApprovalCommand returnApprovalCommand = new AddReturnApprovalCommand(); + BeanUtils.copyProperties(command, returnApprovalCommand); + returnApprovalCommand.setGoodsId(shopGoodsEntity.getGoodsId()); + returnApprovalCommand.setGoodsPrice(shopGoodsEntity.getPrice()); + if (returnApprovalCommand.getApprovalType() == null) { + returnApprovalCommand.setApprovalType(1); + } + + ReturnApprovalModel returnApprovalModel = returnApprovalModelFactory.create(); + returnApprovalModel.initBaseEntity(); + returnApprovalModel.loadAddCommand(returnApprovalCommand); + returnApprovalCommand.insert(); + + + // 发送审核消息 + try { + String appid = "QWTONG_YS_WXSHOP"; + List authCorpInfoList = authCorpInfoApplicationService.getByAppid(appid); + QyAuthCorpInfoEntity authCorpInfo = authCorpInfoList.stream() + .filter(a -> WeixinConstants.corpid.equals(a.getCorpid())) + .findFirst().orElse(null); + QyAccessTokenEntity accessToken = accessTokenApplicationService.getByAppid(appid, authCorpInfo.getCorpid()); + // 获取用户ID + List adminUserIds = qyUserService.selectAdminUserIds(); + String toUser = String.join("|", adminUserIds); + String toparty = ""; + String totag = ""; + List articles = new ArrayList<>(); + NewsArticle article = new NewsArticle(); + article.setTitle("耗材领用审核通知"); + article.setDescription("申请领用商品:" + shopGoodsEntity.getGoodsName()); + article.setPicurl(shopGoodsEntity.getCoverImg()); + article.setUrl("http://wxshop.ab98.cn/shop-api/api/shop/qy/wechatAuth"); + articles.add(article); + + QywxApiUtil.sendNewsMessage(accessToken.getAccessToken(), Integer.valueOf(authCorpInfo.getAgentid()), + toUser, toparty, totag, articles); + } catch (Exception e) { + log.error("发送退货审核通知失败", e); + } + } } diff --git a/agileboot-domain/src/main/java/com/agileboot/domain/asset/api/PostAssetGoodsBody.java b/agileboot-domain/src/main/java/com/agileboot/domain/asset/api/PostAssetGoodsBody.java deleted file mode 100644 index 10f6bd0..0000000 --- a/agileboot-domain/src/main/java/com/agileboot/domain/asset/api/PostAssetGoodsBody.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.agileboot.domain.asset.api; - -import com.agileboot.domain.asset.command.PostAssetGoodsCommand; -import lombok.Data; -import lombok.EqualsAndHashCode; - -import java.util.List; - -@EqualsAndHashCode -@Data -public class PostAssetGoodsBody { - - List goodsList; -} diff --git a/agileboot-domain/src/main/java/com/agileboot/domain/asset/command/PostAssetApprovalCommand.java b/agileboot-domain/src/main/java/com/agileboot/domain/asset/command/PostAssetApprovalCommand.java new file mode 100644 index 0000000..e306682 --- /dev/null +++ b/agileboot-domain/src/main/java/com/agileboot/domain/asset/command/PostAssetApprovalCommand.java @@ -0,0 +1,40 @@ +package com.agileboot.domain.asset.command; + +import com.baomidou.mybatisplus.annotation.TableField; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +@EqualsAndHashCode +@Data +public class PostAssetApprovalCommand { + @ApiModelProperty("企业微信id") + private String corpid; + + @ApiModelProperty("外部归属类型的商品ID") + private Long externalGoodsId; + + @ApiModelProperty("外部归属类型的审批ID") + private Long externalApprovalId; + + @ApiModelProperty("申请数量") + private Integer applyQuantity; + + @ApiModelProperty("审批类型(0为借还柜 1为固资通)") + private Integer approvalType; + + @ApiModelProperty("申请说明") + private String applyRemark; + + @ApiModelProperty("手机号码") + private String mobile; + + @ApiModelProperty("企业微信用户ID或汇邦云用户ID") + private String userid; + + @ApiModelProperty("用户姓名") + private String name; + + @ApiModelProperty("是否内部用户(0否 1汇邦云用户 2企业微信用户)") + private Integer isInternal; +} diff --git a/agileboot-domain/src/main/java/com/agileboot/domain/asset/command/PostAssetGoodsCommand.java b/agileboot-domain/src/main/java/com/agileboot/domain/asset/command/PostAssetGoodsCommand.java index 66a4076..a8257cc 100644 --- a/agileboot-domain/src/main/java/com/agileboot/domain/asset/command/PostAssetGoodsCommand.java +++ b/agileboot-domain/src/main/java/com/agileboot/domain/asset/command/PostAssetGoodsCommand.java @@ -8,34 +8,45 @@ import lombok.Data; import lombok.EqualsAndHashCode; import java.math.BigDecimal; +import java.util.List; @EqualsAndHashCode @Data public class PostAssetGoodsCommand { - @ApiModelProperty("外部归属类型的商品ID") - private Long externalGoodsId; + @ApiModelProperty("企业微信id") + private String corpid; - @ApiModelProperty("商品名称") - private String goodsName; + @ApiModelProperty("商品信息列表") + private List goodsInfoList; - @ApiModelProperty("销售价格") - private BigDecimal price; + @Data + public static class GoodsInfo { - @ApiModelProperty("库存数量") - private Integer stock; + @ApiModelProperty("外部归属类型的商品ID") + private Long externalGoodsId; - @ApiModelProperty("免审批(0否 1是)") - private Integer autoApproval; + @ApiModelProperty("商品名称") + private String goodsName; - @ApiModelProperty("封面图URL") - private String coverImg; + @ApiModelProperty("销售价格") + private BigDecimal price; - @ApiModelProperty("商品详情(支持2000汉字+10个图片链接)") - private String goodsDetail; + @ApiModelProperty("库存数量") + private Integer stock; - @ApiModelProperty("商品使用说明") - private String usageInstruction; + @ApiModelProperty("免审批(0否 1是)") + private Integer autoApproval; - @ApiModelProperty("归属类型(0-借还柜 1-固资通)") - private Integer belongType; + @ApiModelProperty("封面图URL") + private String coverImg; + + @ApiModelProperty("商品详情(支持2000汉字+10个图片链接)") + private String goodsDetail; + + @ApiModelProperty("商品使用说明") + private String usageInstruction; + + @ApiModelProperty("归属类型(0-借还柜 1-固资通)") + private Integer belongType; + } } diff --git a/agileboot-domain/src/main/java/com/agileboot/domain/qywx/user/QyUserApplicationService.java b/agileboot-domain/src/main/java/com/agileboot/domain/qywx/user/QyUserApplicationService.java index 1c87904..235d7f1 100644 --- a/agileboot-domain/src/main/java/com/agileboot/domain/qywx/user/QyUserApplicationService.java +++ b/agileboot-domain/src/main/java/com/agileboot/domain/qywx/user/QyUserApplicationService.java @@ -6,6 +6,7 @@ import com.agileboot.domain.ab98.api.Ab98ApiUtil; import com.agileboot.domain.ab98.api.SsoLoginUserinfo; import com.agileboot.domain.ab98.user.db.Ab98UserEntity; import com.agileboot.domain.ab98.user.db.Ab98UserService; +import com.agileboot.domain.common.cache.RedisCacheService; import com.agileboot.domain.common.command.BulkOperationCommand; import com.agileboot.domain.qywx.user.command.AddQyUserCommand; import com.agileboot.domain.qywx.user.command.UpdateQyUserCommand; @@ -43,6 +44,8 @@ public class QyUserApplicationService { private final SysRoleService sysRoleService; private final Ab98UserService ab98UserService; + private final RedisCacheService redisCache; + public PageDTO getUserList(SearchQyUserQuery query) { Page page = userService.getUserList(query); List dtoList = page.getRecords().stream() @@ -79,6 +82,7 @@ public class QyUserApplicationService { public void addUser(AddQyUserCommand command) { UserModel model = qyUserModelFactory.create(); model.loadAddCommand(command); + model.initBaseEntity(); model.insert(); } @@ -88,6 +92,7 @@ public class QyUserApplicationService { command.setBalance(command.getBalanceLimit().subtract(model.getUseBalance())); } model.loadUpdateCommand(command); + model.setUpdaterId(0L); model.updateById(); if (command.getRoleId() == null) { @@ -97,7 +102,9 @@ public class QyUserApplicationService { if (sysUserQyUser != null) { SysUserEntity sysUser = sysUserService.getById(sysUserQyUser.getSysUserId()); sysUser.setRoleId(command.getRoleId() > 0 ? command.getRoleId() : null); - sysUserService.updateById(sysUser); + sysUser.updateById(); + + redisCache.userCache.delete(sysUser.getUserId()); } } diff --git a/agileboot-domain/src/main/java/com/agileboot/domain/shop/approval/db/ReturnApprovalEntity.java b/agileboot-domain/src/main/java/com/agileboot/domain/shop/approval/db/ReturnApprovalEntity.java index d6257ed..b13c56f 100644 --- a/agileboot-domain/src/main/java/com/agileboot/domain/shop/approval/db/ReturnApprovalEntity.java +++ b/agileboot-domain/src/main/java/com/agileboot/domain/shop/approval/db/ReturnApprovalEntity.java @@ -46,6 +46,30 @@ public class ReturnApprovalEntity extends BaseEntity { @TableField("order_goods_id") private Long orderGoodsId; + @ApiModelProperty("外部归属类型的商品ID") + @TableField("external_goods_id") + private Long externalGoodsId; + + @ApiModelProperty("外部归属类型的审批ID") + @TableField("external_approval_id") + private Long externalApprovalId; + + @ApiModelProperty("企业微信id") + @TableField("corpid") + private String corpid; + + @ApiModelProperty("申请数量") + @TableField("apply_quantity") + private Integer applyQuantity; + + @ApiModelProperty("审批类型(0为借还柜 1为固资通)") + @TableField("approval_type") + private Integer approvalType; + + @ApiModelProperty("申请说明") + @TableField("apply_remark") + private String applyRemark; + @ApiModelProperty("归还数量") @TableField("return_quantity") private Integer returnQuantity; diff --git a/agileboot-domain/src/main/java/com/agileboot/domain/shop/approval/dto/ReturnApprovalDTO.java b/agileboot-domain/src/main/java/com/agileboot/domain/shop/approval/dto/ReturnApprovalDTO.java index b53ea81..eaf9530 100644 --- a/agileboot-domain/src/main/java/com/agileboot/domain/shop/approval/dto/ReturnApprovalDTO.java +++ b/agileboot-domain/src/main/java/com/agileboot/domain/shop/approval/dto/ReturnApprovalDTO.java @@ -44,6 +44,24 @@ public class ReturnApprovalDTO { @ExcelColumn(name = "关联订单商品ID") private Long orderGoodsId; + @ExcelColumn(name = "外部归属类型的商品ID") + private Long externalGoodsId; + + @ExcelColumn(name = "外部归属类型的审批ID") + private Long externalApprovalId; + + @ExcelColumn(name = "企业微信id") + private String corpid; + + @ExcelColumn(name = "申请数量") + private Integer applyQuantity; + + @ExcelColumn(name = "审批类型") + private Integer approvalType; + + @ExcelColumn(name = "申请说明") + private String applyRemark; + @ExcelColumn(name = "归还数量") private Integer returnQuantity; diff --git a/agileboot-domain/src/main/java/com/agileboot/domain/shop/approval/query/SearchApiReturnApprovalQuery.java b/agileboot-domain/src/main/java/com/agileboot/domain/shop/approval/query/SearchApiReturnApprovalQuery.java index 774cd56..240698f 100644 --- a/agileboot-domain/src/main/java/com/agileboot/domain/shop/approval/query/SearchApiReturnApprovalQuery.java +++ b/agileboot-domain/src/main/java/com/agileboot/domain/shop/approval/query/SearchApiReturnApprovalQuery.java @@ -16,6 +16,12 @@ public class SearchApiReturnApprovalQuery extends AbstractPageQuery { private Long goodsId; private String goodsName; private Integer status; + private Long externalGoodsId; + private Long externalApprovalId; + private String corpid; + private Integer applyQuantity; + private Integer approvalType; + private String applyRemark; private String returnRemark; private String auditRemark; private Date startTime; @@ -30,6 +36,10 @@ public class SearchApiReturnApprovalQuery extends AbstractPageQuery { .eq(orderId != null, "ra.order_id", orderId) .eq(goodsId != null, "ra.goods_id", goodsId) .eq(status != null, "ra.status", status) + .eq(externalGoodsId != null, "ra.external_goods_id", externalGoodsId) + .eq(externalApprovalId != null, "ra.external_approval_id", externalApprovalId) + .eq(approvalType != null, "ra.approval_type", approvalType) + .eq(StrUtil.isNotEmpty(corpid), "ra.corpid", corpid) .like(StrUtil.isNotEmpty(goodsName), "sog.goods_name", goodsName) .between(startTime != null && endTime != null, "ra.create_time", startTime, endTime) .orderByDesc("ra.approval_id"); diff --git a/agileboot-domain/src/main/java/com/agileboot/domain/shop/approval/query/SearchReturnApprovalQuery.java b/agileboot-domain/src/main/java/com/agileboot/domain/shop/approval/query/SearchReturnApprovalQuery.java index bb8fac3..1a581a2 100644 --- a/agileboot-domain/src/main/java/com/agileboot/domain/shop/approval/query/SearchReturnApprovalQuery.java +++ b/agileboot-domain/src/main/java/com/agileboot/domain/shop/approval/query/SearchReturnApprovalQuery.java @@ -16,6 +16,12 @@ public class SearchReturnApprovalQuery extends AbstractPageQuery { private Long orderId; private Long goodsId; private Integer status; + private Long externalGoodsId; + private Long externalApprovalId; + private String corpid; + private Integer applyQuantity; + private Integer approvalType; + private String applyRemark; private String returnRemark; private String auditRemark; private Date startTime; @@ -32,6 +38,10 @@ public class SearchReturnApprovalQuery extends AbstractPageQuery { .eq(orderId != null, "ra.order_id", orderId) .eq(goodsId != null, "ra.goods_id", goodsId) .eq(status != null, "ra.status", status) + .eq(externalGoodsId != null, "ra.external_goods_id", externalGoodsId) + .eq(externalApprovalId != null, "ra.external_approval_id", externalApprovalId) + .eq(approvalType != null, "ra.approval_type", approvalType) + .eq(StrUtil.isNotEmpty(corpid), "ra.corpid", corpid) .like(StrUtil.isNotEmpty(returnRemark), "ra.return_remark", returnRemark) .like(StrUtil.isNotEmpty(auditRemark), "ra.audit_remark", auditRemark) .like(StrUtil.isNotEmpty(paymentMethod), "so.payment_method", paymentMethod) diff --git a/agileboot-domain/src/main/java/com/agileboot/domain/shop/goods/db/ShopGoodsEntity.java b/agileboot-domain/src/main/java/com/agileboot/domain/shop/goods/db/ShopGoodsEntity.java index 7d94ec5..b958a49 100644 --- a/agileboot-domain/src/main/java/com/agileboot/domain/shop/goods/db/ShopGoodsEntity.java +++ b/agileboot-domain/src/main/java/com/agileboot/domain/shop/goods/db/ShopGoodsEntity.java @@ -44,6 +44,10 @@ public class ShopGoodsEntity extends BaseEntity { @TableField("external_goods_id") private Long externalGoodsId; + @ApiModelProperty("企业微信id") + @TableField("corpid") + private String corpid; + @ApiModelProperty("销售价格") @TableField("price") private BigDecimal price; diff --git a/agileboot-domain/src/main/java/com/agileboot/domain/shop/goods/db/ShopGoodsService.java b/agileboot-domain/src/main/java/com/agileboot/domain/shop/goods/db/ShopGoodsService.java index 403f5ca..0f6656f 100644 --- a/agileboot-domain/src/main/java/com/agileboot/domain/shop/goods/db/ShopGoodsService.java +++ b/agileboot-domain/src/main/java/com/agileboot/domain/shop/goods/db/ShopGoodsService.java @@ -28,5 +28,5 @@ public interface ShopGoodsService extends IService { BigDecimal calculateTotalAmount(); - ShopGoodsEntity getGoodsByExternalGoodsId(Long externalGoodsId); + ShopGoodsEntity getGoodsByExternalGoodsId(String corpid, Long externalGoodsId); } diff --git a/agileboot-domain/src/main/java/com/agileboot/domain/shop/goods/db/ShopGoodsServiceImpl.java b/agileboot-domain/src/main/java/com/agileboot/domain/shop/goods/db/ShopGoodsServiceImpl.java index eac1450..4f118fa 100644 --- a/agileboot-domain/src/main/java/com/agileboot/domain/shop/goods/db/ShopGoodsServiceImpl.java +++ b/agileboot-domain/src/main/java/com/agileboot/domain/shop/goods/db/ShopGoodsServiceImpl.java @@ -59,9 +59,10 @@ public class ShopGoodsServiceImpl extends ServiceImpl wrapper = new QueryWrapper<>(); wrapper.eq("external_goods_id", externalGoodsId) + .eq("corpid", corpid) .eq("deleted", 0) .last("LIMIT 1"); return baseMapper.selectOne(wrapper); diff --git a/agileboot-domain/src/main/java/com/agileboot/domain/shop/goods/dto/ShopGoodsDTO.java b/agileboot-domain/src/main/java/com/agileboot/domain/shop/goods/dto/ShopGoodsDTO.java index fa3763c..9a68d32 100644 --- a/agileboot-domain/src/main/java/com/agileboot/domain/shop/goods/dto/ShopGoodsDTO.java +++ b/agileboot-domain/src/main/java/com/agileboot/domain/shop/goods/dto/ShopGoodsDTO.java @@ -51,6 +51,9 @@ public class ShopGoodsDTO { @ExcelColumn(name = "外部商品ID") private Long externalGoodsId; + @ExcelColumn(name = "企业微信id") + private String corpid; + @ExcelColumn(name = "分类名称") private String categoryName; diff --git a/agileboot-domain/src/main/java/com/agileboot/domain/shop/goods/query/SearchShopGoodsQuery.java b/agileboot-domain/src/main/java/com/agileboot/domain/shop/goods/query/SearchShopGoodsQuery.java index 2651a9f..aaf99d2 100644 --- a/agileboot-domain/src/main/java/com/agileboot/domain/shop/goods/query/SearchShopGoodsQuery.java +++ b/agileboot-domain/src/main/java/com/agileboot/domain/shop/goods/query/SearchShopGoodsQuery.java @@ -14,6 +14,7 @@ public class SearchShopGoodsQuery extends AbstractPageQuery { protected String goodsName; protected Long categoryId; protected Long externalGoodsId; + protected String corpid; protected Integer status; protected Integer autoApproval; protected BigDecimal minPrice; @@ -33,6 +34,7 @@ public class SearchShopGoodsQuery extends AbstractPageQuery { .le(maxPrice != null, "g.price", maxPrice) .eq(belongType != null, "g.belong_type", belongType) .eq(externalGoodsId != null, "g.external_goods_id", externalGoodsId) + .eq(StrUtil.isNotEmpty(corpid), "g.corpid", corpid) .eq("g.deleted", 0) .groupBy("g.goods_id"); diff --git a/sql/20250605.sql b/sql/20250605.sql index 9f44dac..cd3acf0 100644 --- a/sql/20250605.sql +++ b/sql/20250605.sql @@ -4,4 +4,31 @@ AFTER `category_id`; ALTER TABLE `shop_goods` ADD COLUMN `external_goods_id` BIGINT NULL COMMENT '外部归属类型的商品ID' -AFTER `category_id`; \ No newline at end of file +AFTER `category_id`; + +-- 添加缺失字段 +ALTER TABLE `return_approval` +ADD COLUMN `external_goods_id` bigint DEFAULT NULL COMMENT '外部归属类型的商品ID' AFTER `order_goods_id`, +ADD COLUMN `apply_quantity` int DEFAULT NULL COMMENT '申请数量' AFTER `external_goods_id`, +ADD COLUMN `approval_type` TINYINT NOT NULL DEFAULT 0 COMMENT '审批类型(0为借还柜 1为固资通)' AFTER `order_goods_id`, +ADD COLUMN `apply_remark` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '申请说明' AFTER `return_remark`; + +-- 添加索引 +ALTER TABLE `return_approval` +ADD INDEX `idx_external_goods_id` (`external_goods_id`), +ADD INDEX `idx_approval_type` (`approval_type`); + +ALTER TABLE `shop_goods` +ADD COLUMN `corpid` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '企业微信id' +AFTER `external_goods_id`; + +ALTER TABLE `return_approval` +ADD COLUMN `corpid` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '企业微信id' +AFTER `external_goods_id`; + + +ALTER TABLE `return_approval` +ADD COLUMN `external_approval_id` bigint DEFAULT NULL COMMENT '外部归属类型的审批ID' +AFTER `external_goods_id`; +ALTER TABLE `return_approval` +ADD INDEX `idx_external_approval_id` (`external_approval_id`); \ No newline at end of file