feat(订单): 添加corpid字段支持企业微信相关功能

在订单创建和退货审批流程中添加corpid字段,用于支持企业微信相关的用户查询和余额操作
This commit is contained in:
dzq 2025-06-10 10:12:07 +08:00
parent 6313299722
commit a4f79e3e28
2 changed files with 10 additions and 6 deletions

View File

@ -188,9 +188,9 @@ public class ReturnApprovalApplicationService {
} else if (Objects.equals(orderModel.getPaymentMethod(), "balance")) {
// 余额退款
try {
QyAccessTokenEntity accessToken = accessTokenApplicationService.getByAppid("QWTONG_YS_WXSHOP", command.getCorpid());
QyAccessTokenEntity accessToken = accessTokenApplicationService.getByAppid("QWTONG_YS_WXSHOP", model.getCorpid());
String userid = QywxApiUtil.convertToUserid(accessToken.getAccessToken(), orderModel.getOpenid()).getUserid();
QyUserEntity qyUser = userService.getUserByUserIdAndCorpid(userid, command.getCorpid());
QyUserEntity qyUser = userService.getUserByUserIdAndCorpid(userid, model.getCorpid());
if (null != qyUser) {
qyUser.setBalance(qyUser.getBalance().add(command.getReturnAmount()));
qyUser.setUseBalance(qyUser.getUseBalance().subtract(command.getReturnAmount()));
@ -205,7 +205,7 @@ public class ReturnApprovalApplicationService {
if (StringUtils.isNotBlank(command.getAuditName())) {
model.setAuditName(command.getAuditName());
} else if (StringUtils.isNotBlank(command.getUserid())) {
QyUserEntity qyUserEntity = qyUserService.getUserByUserIdAndCorpid(command.getUserid(), command.getCorpid());
QyUserEntity qyUserEntity = qyUserService.getUserByUserIdAndCorpid(command.getUserid(), model.getCorpid());
if (null != qyUserEntity) {
model.setAuditName(qyUserEntity.getName());
}
@ -256,7 +256,7 @@ public class ReturnApprovalApplicationService {
if (StringUtils.isNotBlank(command.getAuditName())) {
model.setAuditName(command.getAuditName());
} else if (StringUtils.isNotBlank(command.getUserid())) {
QyUserEntity qyUserEntity = qyUserService.getUserByUserIdAndCorpid(command.getUserid(), command.getCorpid());
QyUserEntity qyUserEntity = qyUserService.getUserByUserIdAndCorpid(command.getUserid(), model.getCorpid());
if (null != qyUserEntity) {
model.setAuditName(qyUserEntity.getName());
}
@ -337,8 +337,6 @@ public class ReturnApprovalApplicationService {
command.setGoodsId(orderGoods.getGoodsId());
command.setOrderId(orderGoods.getOrderId());
command.setGoodsPrice(orderGoods.getTotalAmount());
command.setReturnImages(command.getReturnImages());
command.setReturnRemark(command.getReturnRemark());
command.setStatus(1);
command.setCreatorId(0L);
command.setCreateTime(new Date());
@ -358,6 +356,7 @@ public class ReturnApprovalApplicationService {
// 如果商品免审批则自动审批
if (goodsModel.getAutoApproval().equals(1)) {
UpdateReturnApprovalCommand approveCommand = new UpdateReturnApprovalCommand();
approveCommand.setCorpid(command.getCorpid());
approveCommand.setApprovalId(returnApprovalModel.getApprovalId());
approveCommand.setReturnAmount(orderGoods.getTotalAmount());
approveCommand.setAuditName("自动审批");

View File

@ -163,6 +163,7 @@ public class OrderApplicationService {
OrderModel orderModel = orderModelFactory.create();
orderModel.setOpenid(command.getOpenid());
orderModel.setCorpid(command.getCorpid());
orderModel.setCreatorId(1L);
orderModel.setCreateTime(new Date());
orderModel.setUpdaterId(1L);
@ -179,6 +180,9 @@ public class OrderApplicationService {
orderModel.setIsDeductStock(0);
orderModel.insert();
goodsList.forEach(goods -> {
goods.setCorpid(command.getCorpid());
});
processOrderGoods(orderModel, goodsList);
if (Objects.equals(command.getPaymentType(), "wechat")) {
@ -225,6 +229,7 @@ public class OrderApplicationService {
// 设置商品价格并初始化审批状态
AddReturnApprovalCommand command = new AddReturnApprovalCommand();
command.initBaseEntity();
command.setCorpid(submitOrderCommand.getCorpid());
command.setGoodsId(firstOrderGoods.getGoodsId());
command.setOrderId(orderModel.getOrderId());
command.setApplyRemark(submitOrderCommand.getApplyRemark());