You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

81 lines
3.0 KiB

  1. package com.example.demo.serviceImpl.bean;
  2. import com.example.demo.domain.vo.bean.BeanAuditInfo;
  3. import com.example.demo.domain.vo.bean.BeanRechargeInfo;
  4. import com.example.demo.domain.vo.coin.Result;
  5. import com.example.demo.mapper.coin.BeanAuditMapper;
  6. import com.example.demo.service.bean.BeanAuditService;
  7. import com.github.pagehelper.PageHelper;
  8. import com.github.pagehelper.PageInfo;
  9. import lombok.RequiredArgsConstructor;
  10. import org.springframework.beans.factory.annotation.Autowired;
  11. import org.springframework.http.ResponseEntity;
  12. import org.springframework.stereotype.Service;
  13. import org.springframework.transaction.annotation.Transactional;
  14. import org.springframework.web.client.RestTemplate;
  15. import org.springframework.web.util.UriComponentsBuilder;
  16. import java.util.List;
  17. import java.util.UUID;
  18. /**
  19. * @program: gold-java
  20. * @ClassName BeanAuditServiceImpl
  21. * @description:
  22. * @author: Double
  23. * @create: 202508-01 11:37
  24. * @Version 1.0
  25. **/
  26. @Service
  27. @RequiredArgsConstructor
  28. public class BeanAuditServiceImpl implements BeanAuditService {
  29. @Autowired
  30. private BeanAuditMapper beanAuditMapper;
  31. @Autowired
  32. private RestTemplate restTemplate;
  33. //查找审核信息
  34. @Override
  35. public PageInfo<BeanAuditInfo> selectBy(Integer pageNum, Integer pageSize, BeanAuditInfo beanAuditInfo) {
  36. PageHelper.startPage(pageNum, pageSize);
  37. List<BeanAuditInfo> beanAuditInfos = beanAuditMapper.selectBy(beanAuditInfo);
  38. return new PageInfo<>(beanAuditInfos);
  39. }
  40. @Transactional
  41. @Override
  42. public Result updateStatus1(Long id) {
  43. BeanAuditInfo beanAuditInfo = beanAuditMapper.selectById(id);
  44. String jwcode = beanAuditInfo.getJwcode().toString();
  45. String op = "recharge"; // 操作类型(根据实际业务定义,例如"recharge"表示充值)
  46. String content = beanAuditInfo.getRemark(); // 备注作为content参数
  47. String orderNo = UUID.randomUUID().toString().replace("-", ""); // 生成唯一订单号(去除横线)
  48. // 2. 构建接口URL及参数
  49. String apiUrl = "http://47.92.148.30:3003/mock/61/hljw/api/user/gold";
  50. UriComponentsBuilder urlBuilder = UriComponentsBuilder.fromHttpUrl(apiUrl)
  51. .queryParam("jwcode", jwcode)
  52. .queryParam("op", op)
  53. .queryParam("gold", beanAuditInfo.getPermanentBean())
  54. .queryParam("content", content)
  55. .queryParam("order_no", orderNo);
  56. // 3. 发送GET请求
  57. ResponseEntity<String> response = restTemplate.getForEntity(urlBuilder.toUriString(), String.class);
  58. // 4. 处理响应结果
  59. if (!response.getStatusCode().is2xxSuccessful()) {
  60. return Result.error("远程接口调用失败,状态码:" + response.getStatusCodeValue());
  61. }
  62. beanAuditMapper.updateStatus1(id);
  63. return Result.success();
  64. }
  65. @Override
  66. public void updateStatus2(Long id) {
  67. beanAuditMapper.updateStatus2(id);
  68. }
  69. }