diff --git a/agileboot-admin/src/main/java/com/agileboot/admin/controller/shop/WxUserInfoController.java b/agileboot-admin/src/main/java/com/agileboot/admin/controller/shop/WxUserInfoController.java index 004f960..01d53b9 100644 --- a/agileboot-admin/src/main/java/com/agileboot/admin/controller/shop/WxUserInfoController.java +++ b/agileboot-admin/src/main/java/com/agileboot/admin/controller/shop/WxUserInfoController.java @@ -1,10 +1,14 @@ package com.agileboot.admin.controller.shop; +import cn.hutool.json.JSONUtil; import com.agileboot.admin.customize.aop.accessLog.AccessLog; import com.agileboot.common.core.base.BaseController; import com.agileboot.common.core.dto.ResponseDTO; import com.agileboot.common.core.page.PageDTO; import com.agileboot.common.enums.common.BusinessTypeEnum; +import com.agileboot.common.exception.ApiException; +import com.agileboot.common.exception.error.ErrorCode; +import com.agileboot.domain.ab98.user.command.BindWxMpUserCommand; import com.agileboot.domain.common.command.BulkOperationCommand; import com.agileboot.domain.shop.wxuser.WxUserInfoApplicationService; import com.agileboot.domain.shop.wxuser.command.AddWxUserInfoCommand; @@ -12,10 +16,14 @@ import com.agileboot.domain.shop.wxuser.command.UpdateWxUserInfoCommand; import com.agileboot.domain.shop.wxuser.db.WxUserInfoEntity; import com.agileboot.domain.shop.wxuser.dto.WxUserInfoDTO; import com.agileboot.domain.shop.wxuser.query.SearchWxUserInfoQuery; +import com.agileboot.domain.wx.user.WxUserApplicationService; +import io.swagger.annotations.ApiOperation; import io.swagger.v3.oas.annotations.Operation; import java.util.List; import javax.validation.constraints.NotNull; import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; @@ -30,9 +38,11 @@ import org.springframework.web.bind.annotation.RestController; @RequestMapping("/shop/wxuser") @RequiredArgsConstructor @Validated +@Slf4j public class WxUserInfoController extends BaseController { private final WxUserInfoApplicationService applicationService; + private final WxUserApplicationService wxUserApplicationService; @Operation(summary = "微信用户列表") @GetMapping @@ -65,4 +75,26 @@ public class WxUserInfoController extends BaseController { applicationService.deleteWxUser(new BulkOperationCommand<>(ids)); return ResponseDTO.ok(); } + + + @PostMapping("/bindWxMpUser") + @ApiOperation(value = "绑定微信小程序用户到汇邦云", notes = "通过动态码、姓名、身份证绑定微信小程序用户到汇邦云") + public ResponseDTO bindWxMpUser(@RequestBody BindWxMpUserCommand command) { + if (command == null || StringUtils.isBlank(command.getDynamicCode()) || StringUtils.isBlank(command.getName()) || StringUtils.isBlank(command.getIdNum())) { + log.error("绑定微信小程序用户到汇邦云参数错误: {}", JSONUtil.toJsonStr(command)); + return ResponseDTO.fail(new ApiException(ErrorCode.Client.COMMON_REQUEST_PARAMETERS_INVALID, "参数错误")); + } + + try { + boolean success = wxUserApplicationService.bindWxMpUser(command); + if (success) { + return ResponseDTO.ok("绑定成功"); + } else { + return ResponseDTO.fail(new ApiException(ErrorCode.Internal.INTERNAL_ERROR, "绑定失败")); + } + } catch (Exception e) { + log.error("绑定微信小程序用户到汇邦云失败: ", e); + return ResponseDTO.fail(new ApiException(ErrorCode.Internal.INTERNAL_ERROR, "绑定失败: " + e.getMessage())); + } + } } \ No newline at end of file diff --git a/agileboot-domain/src/main/java/com/agileboot/domain/shop/order/OrderApplicationService.java b/agileboot-domain/src/main/java/com/agileboot/domain/shop/order/OrderApplicationService.java index 80b2a06..d269196 100644 --- a/agileboot-domain/src/main/java/com/agileboot/domain/shop/order/OrderApplicationService.java +++ b/agileboot-domain/src/main/java/com/agileboot/domain/shop/order/OrderApplicationService.java @@ -456,6 +456,7 @@ public class OrderApplicationService { } }); // 根据查询条件获取订单列表 + // 添加支付状态为已支付的查询条件,排除未支付订单 orderQueryWrapper.eq("pay_status", 2); List orderList = orderService.list(orderQueryWrapper); diff --git a/sql/20251124_user_balance.sql b/sql/20251124_user_balance.sql new file mode 100644 index 0000000..2baac4d --- /dev/null +++ b/sql/20251124_user_balance.sql @@ -0,0 +1,19 @@ +CREATE TABLE `user_balance` ( + `user_balance_id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID', + `corpid` varchar(50) NOT NULL COMMENT '企业微信id', + `openid` varchar(32) DEFAULT NULL COMMENT 'openid', + `ab98_user_id` bigint NOT NULL COMMENT '汇邦云用户ID', + `qy_user_id` bigint DEFAULT NULL COMMENT '企业用户id', + `balance` bigint NOT NULL DEFAULT 0 COMMENT '用户余额(单位:分)', + `use_balance` bigint NOT NULL DEFAULT 0 COMMENT '用户余额(单位:分)', + `balance_limit` bigint NOT NULL DEFAULT 0 COMMENT '用户余额(单位:分)', + `creator_id` bigint NULL DEFAULT 0 COMMENT '创建者ID', + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `updater_id` bigint NULL DEFAULT 0 COMMENT '更新者ID', + `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', + PRIMARY KEY (`user_balance_id`), + KEY `idx_openid` (`openid`), + KEY `idx_ab98_user_id` (`ab98_user_id`), + KEY `idx_corpid` (`corpid`), + UNIQUE KEY `uk_corpid_user` (`corpid`, `ab98_user_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='用户余额表';