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.

60 lines
2.2 KiB

  1. package com.example.demo.serviceImpl.Wallet;
  2. import com.example.demo.Util.BusinessException;
  3. import com.example.demo.domain.entity.UserGoldRecord;
  4. import com.example.demo.domain.entity.UserRegionWallet;
  5. import com.example.demo.domain.entity.UserWalletRecord;
  6. import com.example.demo.exception.SystemException;
  7. import com.example.demo.mapper.coin.WalletMapper;
  8. import com.example.demo.service.Wallet.WalletService;
  9. import lombok.RequiredArgsConstructor;
  10. import org.springframework.beans.factory.annotation.Autowired;
  11. import org.springframework.stereotype.Service;
  12. import java.math.BigDecimal;
  13. import java.util.List;
  14. /**
  15. * @program: GOLD
  16. * @ClassName WalletServiceImpl
  17. * @description:
  18. * @author: huangqizhen
  19. * @create: 202603-06 13:53
  20. * @Version 1.0
  21. **/
  22. @Service
  23. @RequiredArgsConstructor
  24. public class WalletServiceImpl implements WalletService {
  25. @Autowired
  26. private WalletMapper walletMapper;
  27. @Override
  28. public void updateUserGoldRecord(UserRegionWallet userRegionWallet) {
  29. BigDecimal currentPermanentGold = userRegionWallet.getCurrentPermanentGold();
  30. if (currentPermanentGold == null|| currentPermanentGold.compareTo(BigDecimal.ZERO) <= 0)
  31. throw new SystemException("钱包金币传参错误");
  32. if (userRegionWallet.getJwcode()!= null|| userRegionWallet.getWalletId() != null){
  33. UserRegionWallet wallet = walletMapper.selectWallet(userRegionWallet.getJwcode(), userRegionWallet.getWalletId());
  34. if (wallet == null){
  35. throw new BusinessException("该用户钱包不存在");
  36. }
  37. else {
  38. userRegionWallet.setCurrentPermanentGold(wallet.getCurrentPermanentGold().add(currentPermanentGold));
  39. walletMapper.updateWallet(userRegionWallet);
  40. }
  41. }
  42. }
  43. @Override
  44. public List<UserWalletRecord> selectUserWalletRecord(Integer jwcode, String orderCode) {
  45. if (jwcode == null){
  46. throw new SystemException("精网号传参错误");
  47. }
  48. return walletMapper.selectWalletRecord(jwcode, orderCode);
  49. }
  50. @Override
  51. public void updateUserWalletRecord(Integer id) {
  52. walletMapper.updateWalletRecord(id);
  53. }
  54. }