feat(cloud): 添加修改资金账户名称功能并优化相关服务

- 在 BatteryStation 实体类中添加 EqualsAndHashCode 注解
- 在 CloudService 接口中添加 updateName 方法
- 修改 GZHMessageTemplateService 中的模板 ID 引用- 在 PageListWalletRequest 中添加 uname 字段
- 在 WalletAccountController 中添加 updateName 接口
- 在 WalletAccountService 接口中添加 updateName 方法
- 实现 WalletAccountServiceImpl 中的 updateName 方法
- 在 WechatUserService 实现类中调用 updateName 方法更新微信用户信息
This commit is contained in:
tzy 2025-04-19 13:57:24 +08:00
parent 1a68ba3e9e
commit aa096bb997
8 changed files with 46 additions and 7 deletions

View File

@ -11,6 +11,7 @@ import java.io.Serializable;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import lombok.EqualsAndHashCode;
import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat;
import io.swagger.v3.oas.annotations.Hidden; import io.swagger.v3.oas.annotations.Hidden;
@ -23,6 +24,7 @@ import lombok.Data;
* @author zrb * @author zrb
* @since 2024-10-15 * @since 2024-10-15
*/ */
@EqualsAndHashCode(callSuper = true)
@Data @Data
@TableName("hd_cloud_manage.yt_t_battery_station") @TableName("hd_cloud_manage.yt_t_battery_station")
@Schema(name = "BatteryStation", description = "换电站") @Schema(name = "BatteryStation", description = "换电站")

View File

@ -19,6 +19,9 @@ public class PageListWalletRequest extends BasePageRequest {
@Schema(description = "户主ID") @Schema(description = "户主ID")
private String ownerId; private String ownerId;
@Schema(description = "用户名")
private String uname;
@Schema(description = "编码") @Schema(description = "编码")
private String code; private String code;

View File

@ -54,6 +54,7 @@ public class WalletAccountController {
public Result<Integer> update(@ParameterObject WalletAccount wa) { public Result<Integer> update(@ParameterObject WalletAccount wa) {
return walletAccountService.update(wa); return walletAccountService.update(wa);
} }
@Operation(summary = "查询") @Operation(summary = "查询")
@GetMapping("/list") @GetMapping("/list")
@ -92,15 +93,19 @@ public class WalletAccountController {
} }
@Operation(summary = "获取WalleCode") @Operation(summary = "获取WalleCode")
@PostMapping("/getWalleCode") @PostMapping("/getWalleCode")
@ApiOperationSupport(order = 8) @ApiOperationSupport(order = 9)
public Result<String> getWalleCode(String wuid) { public Result<String> getWalleCode(String wuid) {
return walletAccountService.getWalleCode(wuid); return walletAccountService.getWalleCode(wuid);
} }
@Operation(summary = "获取附加信息") @Operation(summary = "获取附加信息")
@PostMapping("/getPayAttach") @PostMapping("/getPayAttach")
@ApiOperationSupport(order = 8) @ApiOperationSupport(order = 10)
public Result<WechatPayAttach> getPayAttach(String wuid) { public Result<WechatPayAttach> getPayAttach(String wuid) {
return walletAccountService.getPayAttach(wuid); return walletAccountService.getPayAttach(wuid);
} }
@PostMapping({"/updateName"})
@ApiOperationSupport(order = 11)
public Result<Integer> updateName(@ParameterObject WalletAccount wa) {
return walletAccountService.updateName(wa);
}
} }

View File

@ -30,4 +30,6 @@ public interface WalletAccountService {
public Result<String> getWalleCode(String wuid); public Result<String> getWalleCode(String wuid);
public Result<WechatPayAttach> getPayAttach(String wuid); public Result<WechatPayAttach> getPayAttach(String wuid);
public Result<Integer> updateName(WalletAccount wa);
} }

View File

@ -125,23 +125,26 @@ public class WalletAccountServiceImpl implements WalletAccountService {
if (n == 1) { if (n == 1) {
return new Result<Integer>().success(n); return new Result<Integer>().success(n);
} }
return new Result<Integer>().error("更新资金账户失败!"); return new Result<Integer>().error("更新资金账户失败!");
} }
@Override @Override
public Result<List<WalletAccountVO>> list(PageListWalletRequest plwr) { public Result<List<WalletAccountVO>> list(PageListWalletRequest plwr) {
Page<WalletAccount> page = new Page<WalletAccount>(plwr.getPageNo(), plwr.getPageSize()); Page<WalletAccount> page = new Page<WalletAccount>(plwr.getPageNo(), plwr.getPageSize());
QueryWrapper<WalletAccount> queryWrapper = new QueryWrapper<WalletAccount>()
page = walletAccountDao.selectPage(page, new QueryWrapper<WalletAccount>()
.eq(StringUtils.hasText(plwr.getCode()), "code", plwr.getCode()) .eq(StringUtils.hasText(plwr.getCode()), "code", plwr.getCode())
.like(StringUtils.hasText(plwr.getUname()), "acc_name", plwr.getUname())
.eq(StringUtils.hasText(plwr.getStationCode()), "station_code", plwr.getStationCode()) .eq(StringUtils.hasText(plwr.getStationCode()), "station_code", plwr.getStationCode())
.eq(plwr.getOwnerType() != null, "owner_type", plwr.getOwnerType()) .eq(plwr.getOwnerType() != null, "owner_type", plwr.getOwnerType())
.eq(StringUtils.hasText(plwr.getOwnerId()), "owner_id", plwr.getOwnerId()) .eq(StringUtils.hasText(plwr.getOwnerId()), "owner_id", plwr.getOwnerId())
.orderByDesc("pk_id")); .orderByDesc("pk_id");
page = walletAccountDao.selectPage(page, queryWrapper);
if (page.getRecords().isEmpty()) { if (page.getRecords().isEmpty()) {
return new Result<List<WalletAccountVO>>().error(CodeMsg.DATABASE_RESULT_NULL); return new Result<List<WalletAccountVO>>().error(CodeMsg.DATABASE_RESULT_NULL);
} }
// 2. 转换为VO并查询用户信息 // 2. 转换为VO并查询用户信息
List<WalletAccountVO> voList = page.getRecords().stream().map(account -> { List<WalletAccountVO> voList = page.getRecords().stream().map(account -> {
WalletAccountVO vo = new WalletAccountVO(); WalletAccountVO vo = new WalletAccountVO();
@ -276,6 +279,22 @@ public class WalletAccountServiceImpl implements WalletAccountService {
} }
} }
@Override
public Result<Integer> updateName(WalletAccount wa) {
if (wa == null) {
return new Result<Integer>().error("参数不能为空");
}
LambdaQueryWrapper<WalletAccount> walletAccountLambdaQueryWrapper = new LambdaQueryWrapper<>();
walletAccountLambdaQueryWrapper.eq(WalletAccount::getOwnerId, wa.getOwnerId());
WalletAccount walletAccount = walletAccountDao.selectOne(walletAccountLambdaQueryWrapper);
if (walletAccount != null) {
walletAccount.setAccName(wa.getAccName());
walletAccountDao.updateById(walletAccount);
return new Result<Integer>().success(1);
}
return new Result<Integer>().error("未找到对应的账户");
}
// 查询 WechatUser 的封装方法 // 查询 WechatUser 的封装方法
private WechatUser queryWechatUserByWuid(String wuid) { private WechatUser queryWechatUserByWuid(String wuid) {
LambdaQueryWrapper<WechatUser> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<WechatUser> queryWrapper = new LambdaQueryWrapper<>();

View File

@ -157,7 +157,7 @@ public class GZHMessageTemplateService {
break; break;
// 付款完成 // 付款完成
case 3: case 3:
templateId = gzhProperties.getOrderSwapEndTemplateId(); templateId = gzhProperties.getOrderEndTemplateId();
miniprogram.setPath(orderDetailPage); miniprogram.setPath(orderDetailPage);
PayTemplateData payData = new PayTemplateData(); PayTemplateData payData = new PayTemplateData();
payData.setThing2(osb.getStationName()); payData.setThing2(osb.getStationName());
@ -170,6 +170,7 @@ public class GZHMessageTemplateService {
break; break;
//预约即将失效 //预约即将失效
case 4: case 4:
break; break;
default: default:
break; break;

View File

@ -45,6 +45,10 @@ public class WechatUserServiceImpl implements WechatUserService {
if (n == 1) { if (n == 1) {
return new Result<String>().success(1); return new Result<String>().success(1);
} }
WalletAccount walletAccount = new WalletAccount();
walletAccount.setOwnerId(wuser.getWuid());
walletAccount.setAccName(wuser.getName());
cloudService.updateName(walletAccount);
return new Result<String>().error("修改微信用户信息出错!"); return new Result<String>().error("修改微信用户信息出错!");
} }

View File

@ -93,4 +93,7 @@ public interface CloudService {
@PostMapping(value = "/wallet/getPayAttach", consumes = {MediaType.APPLICATION_FORM_URLENCODED_VALUE}) @PostMapping(value = "/wallet/getPayAttach", consumes = {MediaType.APPLICATION_FORM_URLENCODED_VALUE})
public Result<WechatPayAttach> getPayAttach(@NotBlank String wuid); public Result<WechatPayAttach> getPayAttach(@NotBlank String wuid);
@PostMapping(value = "/wallet/updateName", consumes = {MediaType.APPLICATION_FORM_URLENCODED_VALUE})
public Result<WechatPayAttach> updateName(@NotBlank WalletAccount wa);
} }