Browse Source

20260306充值钱包金额查询

huangqizheng/feature-20260309142559-钱包退款
wangguorui 1 month ago
parent
commit
1c9599550b
  1. 106
      src/main/java/com/example/demo/controller/cash/CashCollectionController.java
  2. 21
      src/main/java/com/example/demo/domain/vo/cash/UserWalletVO.java
  3. 17
      src/main/java/com/example/demo/domain/vo/cash/WalletItem.java
  4. 6
      src/main/java/com/example/demo/mapper/cash/CashCollectionMapper.java
  5. 4
      src/main/java/com/example/demo/service/cash/CashCollectionService.java
  6. 13
      src/main/java/com/example/demo/serviceImpl/cash/CashCollectionServiceImpl.java
  7. 37
      src/main/resources/cashMapper/CashCollectionMapper.xml

106
src/main/java/com/example/demo/controller/cash/CashCollectionController.java

@ -4,9 +4,7 @@ import com.example.demo.Util.JWTUtil;
import com.example.demo.Util.LanguageTranslationUtil; import com.example.demo.Util.LanguageTranslationUtil;
import com.example.demo.domain.DTO.PerformanceDTO; import com.example.demo.domain.DTO.PerformanceDTO;
import com.example.demo.domain.entity.*; import com.example.demo.domain.entity.*;
import com.example.demo.domain.vo.cash.CashCollection;
import com.example.demo.domain.vo.cash.PerformanceVO;
import com.example.demo.domain.vo.cash.UserWalletRecordVO;
import com.example.demo.domain.vo.cash.*;
import com.example.demo.domain.vo.coin.Page; import com.example.demo.domain.vo.coin.Page;
import com.example.demo.domain.vo.coin.Result; import com.example.demo.domain.vo.coin.Result;
import com.example.demo.service.cash.CashCollectionService; import com.example.demo.service.cash.CashCollectionService;
@ -23,6 +21,7 @@ import org.springframework.web.context.request.ServletRequestAttributes;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* @program: gold-java * @program: gold-java
@ -359,6 +358,107 @@ public class CashCollectionController {
} }
} }
// 根据精网号和地区查询用户的所有钱包 ID 和金币数量
@PostMapping("/selectUserWallets")
public Result selectUserWallets(@RequestBody Map<String, Object> params, @RequestHeader(defaultValue = "zh_CN") String lang) {
try {
Integer jwcode = null;
String market = null;
Integer pageNum = null;
Integer pageSize = null;
// 处理 jwcode 参数兼容 null 和空字符串
if (params.containsKey("jwcode")) {
Object jwcodeObj = params.get("jwcode");
// 判断是否为 null 或空字符串
if (jwcodeObj != null) {
String jwcodeStr = jwcodeObj.toString();
if (!jwcodeStr.isEmpty()) {
try {
jwcode = ((Number) jwcodeObj).intValue();
} catch (Exception e) {
// 如果转换失败保持为 null
}
}
}
}
// 处理 market 参数
if (params.containsKey("market")) {
Object marketObj = params.get("market");
if (marketObj != null && !marketObj.toString().isEmpty()) {
market = marketObj.toString();
}
}
// 处理分页参数
if (params.containsKey("pageNum")) {
Object pageNumObj = params.get("pageNum");
if (pageNumObj != null && !pageNumObj.toString().isEmpty()) {
try {
pageNum = ((Number) pageNumObj).intValue();
} catch (Exception e) {
pageNum = 1; // 默认第一页
}
}
}
if (params.containsKey("pageSize")) {
Object pageSizeObj = params.get("pageSize");
if (pageSizeObj != null && !pageSizeObj.toString().isEmpty()) {
try {
pageSize = ((Number) pageSizeObj).intValue();
} catch (Exception e) {
pageSize = 10; // 默认每页 10
}
}
}
// 如果没有传分页参数设置默认值
if (pageNum == null) {
pageNum = 1;
}
if (pageSize == null) {
pageSize = 10;
}
PageInfo<UserWalletVO> result = cashCollectionService.selectUserWallets(jwcode, market, pageNum, pageSize);
// 对返回结果进行多语言转换
if (result != null && result.getList() != null) {
for (UserWalletVO vo : result.getList()) {
translateUserWalletVO(vo, lang);
}
}
return Result.success(result);
} catch (Exception e) {
String errorMsg = languageTranslationUtil.translate("查询失败", lang);
return Result.error(errorMsg + ": " + e.getMessage());
}
}
/**
* 转换用户钱包 VO 的多语言字段
*/
private void translateUserWalletVO(UserWalletVO vo, String lang) {
if (vo != null) {
// 翻译地区名称
if (vo.getMarketName() != null) {
vo.setMarketName(languageTranslationUtil.translate(vo.getMarketName(), lang));
}
// 翻译钱包名称
if (vo.getWalletList() != null) {
for (WalletItem wallet : vo.getWalletList()) {
if (wallet.getWalletName() != null) {
wallet.setWalletName(languageTranslationUtil.translate(wallet.getWalletName(), lang));
}
}
}
}
}
/** /**
* 转换现金收款订单的多语言字段 * 转换现金收款订单的多语言字段
*/ */

21
src/main/java/com/example/demo/domain/vo/cash/UserWalletVO.java

@ -0,0 +1,21 @@
package com.example.demo.domain.vo.cash;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.math.BigDecimal;
import java.util.List;
// 用户钱包 VO包含用户名地区和所有钱包列表
@Data
@NoArgsConstructor
@AllArgsConstructor
public class UserWalletVO {
private Integer jwcode; // 精网号
private String userName; // 用户名
private String market; // 地区代码
private String marketName; // 地区名称
private List<WalletItem> walletList; // 钱包列表
}

17
src/main/java/com/example/demo/domain/vo/cash/WalletItem.java

@ -0,0 +1,17 @@
package com.example.demo.domain.vo.cash;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.math.BigDecimal;
// 钱包项单个钱包信息
@Data
@NoArgsConstructor
@AllArgsConstructor
public class WalletItem {
private Integer walletId; // 钱包 ID
private String walletName; // 钱包名称
private BigDecimal currentPermanentGold; // 当前永久金币数量
}

6
src/main/java/com/example/demo/mapper/cash/CashCollectionMapper.java

@ -6,6 +6,7 @@ import com.example.demo.domain.entity.*;
import com.example.demo.domain.vo.cash.CashCollection; import com.example.demo.domain.vo.cash.CashCollection;
import com.example.demo.domain.vo.cash.PerformanceVO; import com.example.demo.domain.vo.cash.PerformanceVO;
import com.example.demo.domain.vo.cash.UserWalletRecordVO; import com.example.demo.domain.vo.cash.UserWalletRecordVO;
import com.example.demo.domain.vo.cash.UserWalletVO;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
@ -116,4 +117,9 @@ public interface CashCollectionMapper {
List<UserWalletRecordVO> selectWalletRecordsByJwcodeAndWalletId( List<UserWalletRecordVO> selectWalletRecordsByJwcodeAndWalletId(
@Param("jwcode") Integer jwcode, @Param("jwcode") Integer jwcode,
@Param("walletId") Integer walletId); @Param("walletId") Integer walletId);
// 根据精网号和地区查询用户的所有钱包 ID 和金币数量包含用户名和地区
// 如果 jwcode null则查询所有用户如果 market 不为 null则按地区筛选
List<UserWalletVO> selectUserWallets(@Param("jwcode") Integer jwcode,
@Param("market") String market);
} }

4
src/main/java/com/example/demo/service/cash/CashCollectionService.java

@ -7,6 +7,7 @@ import com.example.demo.domain.entity.RechargeActivity;
import com.example.demo.domain.vo.cash.CashCollection; import com.example.demo.domain.vo.cash.CashCollection;
import com.example.demo.domain.vo.cash.PerformanceVO; import com.example.demo.domain.vo.cash.PerformanceVO;
import com.example.demo.domain.vo.cash.UserWalletRecordVO; import com.example.demo.domain.vo.cash.UserWalletRecordVO;
import com.example.demo.domain.vo.cash.UserWalletVO;
import com.example.demo.domain.vo.coin.Result; import com.example.demo.domain.vo.coin.Result;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
@ -52,4 +53,7 @@ public interface CashCollectionService {
// 根据精网号和钱包 ID 查询用户钱包明细列表分页 // 根据精网号和钱包 ID 查询用户钱包明细列表分页
PageInfo<UserWalletRecordVO> selectWalletRecordsByJwcodeAndWalletId( PageInfo<UserWalletRecordVO> selectWalletRecordsByJwcodeAndWalletId(
Integer pageNum, Integer pageSize, Integer jwcode, Integer walletId); Integer pageNum, Integer pageSize, Integer jwcode, Integer walletId);
// 根据精网号和地区查询用户的所有钱包 ID 和金币数量包含用户名和地区分页
PageInfo<UserWalletVO> selectUserWallets(Integer jwcode, String market, Integer pageNum, Integer pageSize);
} }

13
src/main/java/com/example/demo/serviceImpl/cash/CashCollectionServiceImpl.java

@ -5,10 +5,7 @@ import com.example.demo.Util.LanguageTranslationUtil;
import com.example.demo.config.RabbitMQConfig; import com.example.demo.config.RabbitMQConfig;
import com.example.demo.domain.DTO.PerformanceDTO; import com.example.demo.domain.DTO.PerformanceDTO;
import com.example.demo.domain.entity.*; import com.example.demo.domain.entity.*;
import com.example.demo.domain.vo.cash.CashCollection;
import com.example.demo.domain.vo.cash.CashCollectionMessage;
import com.example.demo.domain.vo.cash.PerformanceVO;
import com.example.demo.domain.vo.cash.UserWalletRecordVO;
import com.example.demo.domain.vo.cash.*;
import com.example.demo.domain.vo.coin.GoldUser; import com.example.demo.domain.vo.coin.GoldUser;
import com.example.demo.domain.vo.coin.Messages; import com.example.demo.domain.vo.coin.Messages;
import com.example.demo.domain.vo.coin.Result; import com.example.demo.domain.vo.coin.Result;
@ -610,4 +607,12 @@ public class CashCollectionServiceImpl implements CashCollectionService {
List<UserWalletRecordVO> records = cashCollectionMapper.selectWalletRecordsByJwcodeAndWalletId(jwcode, walletId); List<UserWalletRecordVO> records = cashCollectionMapper.selectWalletRecordsByJwcodeAndWalletId(jwcode, walletId);
return new PageInfo<>(records); return new PageInfo<>(records);
} }
// 根据精网号和地区查询用户的所有钱包 ID 和金币数量包含用户名和地区分页
@Override
public PageInfo<UserWalletVO> selectUserWallets(Integer jwcode, String market, Integer pageNum, Integer pageSize) {
PageHelper.startPage(pageNum, pageSize);
List<UserWalletVO> wallets = cashCollectionMapper.selectUserWallets(jwcode, market);
return new PageInfo<>(wallets);
}
} }

37
src/main/resources/cashMapper/CashCollectionMapper.xml

@ -447,6 +447,43 @@
ORDER BY uwr.create_time DESC ORDER BY uwr.create_time DESC
</select> </select>
<!-- 根据精网号和地区查询用户的所有钱包 ID 和金币数量(包含用户名和地区) -->
<resultMap id="UserWalletVOResultMap" type="com.example.demo.domain.vo.cash.UserWalletVO">
<id property="jwcode" column="jwcode"/>
<result property="userName" column="userName"/>
<result property="market" column="market"/>
<result property="marketName" column="marketName"/>
<collection property="walletList" ofType="com.example.demo.domain.vo.cash.WalletItem">
<id property="walletId" column="walletId"/>
<result property="walletName" column="walletName"/>
<result property="currentPermanentGold" column="currentPermanentGold"/>
</collection>
</resultMap>
<select id="selectUserWallets" resultMap="UserWalletVOResultMap">
SELECT
u.jwcode,
u.name as userName,
u.market,
m.name as marketName,
wr.wallet_id as walletId,
w.wallet_name as walletName,
COALESCE(wr.current_permanent_gold, 0) as currentPermanentGold
FROM user u
LEFT JOIN market m ON u.market = m.id
LEFT JOIN user_region_wallet wr ON u.jwcode = wr.jwcode
LEFT JOIN wallet w ON wr.wallet_id = w.id
<where>
<if test="jwcode != null">
AND u.jwcode = #{jwcode}
</if>
<if test="market != null and market != ''">
AND u.market = #{market}
</if>
</where>
ORDER BY u.jwcode, wr.wallet_id
</select>
<!--根据OrderCode订单号更新收款订单--> <!--根据OrderCode订单号更新收款订单-->
<update id="updateByGoldCoinOrderCodeByPayment"> <update id="updateByGoldCoinOrderCodeByPayment">
update cash_record_collection update cash_record_collection

Loading…
Cancel
Save