4 changed files with 134 additions and 0 deletions
-
24src/main/java/com/example/demo/mapper/coin/WalletMapper.java
-
23src/main/java/com/example/demo/service/Wallet/WalletService.java
-
60src/main/java/com/example/demo/serviceImpl/Wallet/WalletServiceImpl.java
-
27src/main/resources/mapper/WalletMapper.xml
@ -0,0 +1,24 @@ |
|||||
|
package com.example.demo.mapper.coin; |
||||
|
|
||||
|
import com.example.demo.domain.entity.UserRegionWallet; |
||||
|
import com.example.demo.domain.entity.UserWalletRecord; |
||||
|
import com.example.demo.domain.entity.Wallet; |
||||
|
import org.apache.ibatis.annotations.Mapper; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @program: GOLD |
||||
|
* @ClassName WalletMapper |
||||
|
* @description: |
||||
|
* @author: huangqizhen |
||||
|
* @create: 2026−03-06 13:56 |
||||
|
* @Version 1.0 |
||||
|
**/ |
||||
|
@Mapper |
||||
|
public interface WalletMapper { |
||||
|
void updateWallet(UserRegionWallet userRegionWallet); |
||||
|
UserRegionWallet selectWallet(Integer jwcode, Integer walletId); |
||||
|
List<UserWalletRecord> selectWalletRecord(Integer jwcode, String orderCode); |
||||
|
void updateWalletRecord(Integer id); |
||||
|
} |
||||
@ -0,0 +1,23 @@ |
|||||
|
package com.example.demo.service.Wallet; |
||||
|
|
||||
|
import com.example.demo.domain.entity.UserGoldRecord; |
||||
|
import com.example.demo.domain.entity.UserRegionWallet; |
||||
|
import com.example.demo.domain.entity.UserWalletRecord; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @program: GOLD |
||||
|
* @ClassName WalletService |
||||
|
* @description: |
||||
|
* @author: huangqizhen |
||||
|
* @create: 2026−03-05 14:00 |
||||
|
* @Version 1.0 |
||||
|
**/ |
||||
|
public interface WalletService { |
||||
|
void updateUserGoldRecord(UserRegionWallet userRegionWallet); |
||||
|
List<UserWalletRecord> selectUserWalletRecord(Integer jwcode, String orderCode); |
||||
|
void updateUserWalletRecord(Integer id); |
||||
|
// void MysqlConnection(); |
||||
|
} |
||||
@ -0,0 +1,60 @@ |
|||||
|
package com.example.demo.serviceImpl.Wallet; |
||||
|
|
||||
|
import com.example.demo.Util.BusinessException; |
||||
|
import com.example.demo.domain.entity.UserGoldRecord; |
||||
|
import com.example.demo.domain.entity.UserRegionWallet; |
||||
|
import com.example.demo.domain.entity.UserWalletRecord; |
||||
|
import com.example.demo.exception.SystemException; |
||||
|
import com.example.demo.mapper.coin.WalletMapper; |
||||
|
import com.example.demo.service.Wallet.WalletService; |
||||
|
import lombok.RequiredArgsConstructor; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
import java.math.BigDecimal; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @program: GOLD |
||||
|
* @ClassName WalletServiceImpl |
||||
|
* @description: |
||||
|
* @author: huangqizhen |
||||
|
* @create: 2026−03-06 13:53 |
||||
|
* @Version 1.0 |
||||
|
**/ |
||||
|
@Service |
||||
|
@RequiredArgsConstructor |
||||
|
public class WalletServiceImpl implements WalletService { |
||||
|
@Autowired |
||||
|
private WalletMapper walletMapper; |
||||
|
|
||||
|
@Override |
||||
|
public void updateUserGoldRecord(UserRegionWallet userRegionWallet) { |
||||
|
BigDecimal currentPermanentGold = userRegionWallet.getCurrentPermanentGold(); |
||||
|
if (currentPermanentGold == null|| currentPermanentGold.compareTo(BigDecimal.ZERO) <= 0) |
||||
|
throw new SystemException("钱包金币传参错误"); |
||||
|
if (userRegionWallet.getJwcode()!= null|| userRegionWallet.getWalletId() != null){ |
||||
|
UserRegionWallet wallet = walletMapper.selectWallet(userRegionWallet.getJwcode(), userRegionWallet.getWalletId()); |
||||
|
if (wallet == null){ |
||||
|
throw new BusinessException("该用户钱包不存在"); |
||||
|
} |
||||
|
else { |
||||
|
userRegionWallet.setCurrentPermanentGold(wallet.getCurrentPermanentGold().add(currentPermanentGold)); |
||||
|
walletMapper.updateWallet(userRegionWallet); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public List<UserWalletRecord> selectUserWalletRecord(Integer jwcode, String orderCode) { |
||||
|
if (jwcode == null){ |
||||
|
throw new SystemException("精网号传参错误"); |
||||
|
} |
||||
|
return walletMapper.selectWalletRecord(jwcode, orderCode); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void updateUserWalletRecord(Integer id) { |
||||
|
walletMapper.updateWalletRecord(id); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,27 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
|
<mapper namespace="com.example.demo.mapper.coin.WalletMapper"> |
||||
|
<update id="updateWallet"> |
||||
|
update user_region_wallet set current_permanent_gold = {currentPermanentGold} where jwcode = {jwcode} and wallet_id = {walletId}} |
||||
|
</update> |
||||
|
<update id="updateWalletRecord"> |
||||
|
update user_wallet_record set status = 1 where id = {id} |
||||
|
</update> |
||||
|
<select id="selectWallet" resultType="com.example.demo.domain.entity.UserRegionWallet"> |
||||
|
select jwcode, |
||||
|
wallet_id, |
||||
|
current_permanent_gold |
||||
|
from user_region_wallet where jwcode = {jwcode} and wallet_id = {walletId} |
||||
|
</select> |
||||
|
<select id="selectWalletRecord" resultType="com.example.demo.domain.entity.UserWalletRecord"> |
||||
|
select jwcode, |
||||
|
wallet_id, |
||||
|
type, |
||||
|
amount, |
||||
|
order_code, |
||||
|
description, |
||||
|
status, |
||||
|
id |
||||
|
from user_wallet_record where jwcode = {jwcode} and oreder_code = {orderCode} |
||||
|
</select> |
||||
|
</mapper> |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue