src/main/java/com/xcong/excoin/modules/fish/controller/MemberCannonController.java
@@ -1,21 +1,22 @@ package com.xcong.excoin.modules.fish.controller; import com.xcong.excoin.common.response.Result; import com.xcong.excoin.modules.coin.parameter.vo.MemberWalletAgentInfoVo; import com.xcong.excoin.modules.coin.parameter.vo.OrderWalletCoinDealVo; import com.xcong.excoin.modules.fish.dto.CannonExchangeDto; import com.xcong.excoin.modules.fish.dto.CoinGoldExchangeDto; import com.xcong.excoin.modules.fish.dto.GetCannonsDto; import com.xcong.excoin.modules.fish.dto.GoldExchangeDto; import com.xcong.excoin.modules.fish.service.MemberCannonService; import com.xcong.excoin.modules.fish.vo.CannonSettingVo; import com.xcong.excoin.modules.fish.vo.GoldAccountVo; import com.xcong.excoin.modules.fish.vo.OwnCannonVo; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponses; import lombok.extern.slf4j.Slf4j; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; @@ -29,6 +30,16 @@ private MemberCannonService memberCannonService; /** * 获取金币账户 */ @ApiOperation(value="获取金币账户", notes="获取金币账户") @ApiResponses({@ApiResponse( code = 200, message = "success", response = GoldAccountVo.class)}) @GetMapping(value="/getGoldAccount") public Result getGoldAccount() { return memberCannonService.getGoldAccount(); } /** * 代币金币互转 */ @ApiOperation(value = "代币金币互转") @@ -40,17 +51,17 @@ /** * USDT购买金币 */ @ApiOperation(value = "USDT购买金币") @PostMapping(value = "/goldExchange") public Result goldExchange(@RequestBody GoldExchangeDto goldExchangeDto) { return memberCannonService.goldExchange(goldExchangeDto); } // @ApiOperation(value = "USDT购买金币") // @PostMapping(value = "/goldExchange") // public Result goldExchange(@RequestBody GoldExchangeDto goldExchangeDto) { // return memberCannonService.goldExchange(goldExchangeDto); // } /** * 获取大炮列表 */ @ApiOperation(value = "获取大炮列表") @ApiResponses({@ApiResponse( code = 200, message = "success", response = OrderWalletCoinDealVo.class)}) @ApiResponses({@ApiResponse( code = 200, message = "success", response = CannonSettingVo.class)}) @PostMapping(value = "/getCannons") public Result getCannons(@RequestBody GetCannonsDto getCannonsDto) { return memberCannonService.getCannons(getCannonsDto); @@ -65,5 +76,15 @@ return memberCannonService.cannonExchange(cannonExchangeDto); } /** * 获取用户拥有的炮台 */ @ApiOperation(value="获取用户拥有的炮台", notes="获取用户拥有的炮台") @ApiResponses({@ApiResponse( code = 200, message = "success", response = OwnCannonVo.class)}) @GetMapping(value="/getOwnCannon") public Result getOwnCannon() { return memberCannonService.getOwnCannon(); } } src/main/java/com/xcong/excoin/modules/fish/dao/CannonOwnRecordDao.java
@@ -2,6 +2,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.xcong.excoin.modules.fish.entity.CannonOwnRecord; import com.xcong.excoin.modules.fish.vo.OwnCannonVo; import org.apache.ibatis.annotations.Param; import java.util.List; @@ -10,4 +11,5 @@ List<CannonOwnRecord> selectCannonOwnRecordsByMemberIdAndCannonCode(@Param("memberId")Long memberId, @Param("code")String code); List<OwnCannonVo> selectCannonOwnRecordsByMemberId(@Param("memberId")Long memberId); } src/main/java/com/xcong/excoin/modules/fish/dao/MemberAccountGoldDao.java
@@ -2,6 +2,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.xcong.excoin.modules.fish.entity.MemberAccountGold; import com.xcong.excoin.modules.fish.vo.GoldAccountVo; import org.apache.ibatis.annotations.Param; import java.math.BigDecimal; @@ -11,4 +12,6 @@ MemberAccountGold selectAccountGoldByMemberId(@Param("memberId")Long memberId); int updateTotalBalanceAndAvailableBalance(@Param("id") Long id, @Param("availableBalance") BigDecimal availableBalance, @Param("totalBalance") BigDecimal totalBalance, @Param("frozenBalance") BigDecimal frozenBalance); GoldAccountVo selectAccountGoldVoByMemberId(Long memberId); } src/main/java/com/xcong/excoin/modules/fish/service/MemberCannonService.java
@@ -22,4 +22,8 @@ Result cannonExchange(CannonExchangeDto cannonExchangeDto); Result goldExchange(GoldExchangeDto goldExchangeDto); Result getGoldAccount(); Result getOwnCannon(); } src/main/java/com/xcong/excoin/modules/fish/service/impl/MemberCannonServiceImpl.java
@@ -21,6 +21,8 @@ import com.xcong.excoin.modules.fish.entity.*; import com.xcong.excoin.modules.fish.service.MemberCannonService; import com.xcong.excoin.modules.fish.vo.CannonSettingVo; import com.xcong.excoin.modules.fish.vo.GoldAccountVo; import com.xcong.excoin.modules.fish.vo.OwnCannonVo; import com.xcong.excoin.modules.member.dao.MemberWalletCoinDao; import com.xcong.excoin.modules.member.entity.MemberWalletCoinEntity; import com.xcong.excoin.utils.RedisUtils; @@ -191,6 +193,29 @@ return Result.ok("兑换成功"); } @Override public Result getGoldAccount() { Long memberId = LoginUserUtils.getAppLoginUser().getId(); MemberAccountGold memberAccountGold = memberAccountGoldDao.selectAccountGoldByMemberId(memberId); if(ObjectUtil.isEmpty(memberAccountGold)){ MemberAccountGold memberAccountGoldNew = new MemberAccountGold(); memberAccountGoldNew.setMemberId(memberId); memberAccountGoldNew.setTotalBalance(BigDecimal.ZERO); memberAccountGoldNew.setAvailableBalance(BigDecimal.ZERO); memberAccountGoldNew.setFrozenBalance(BigDecimal.ZERO); memberAccountGoldDao.insert(memberAccountGoldNew); } GoldAccountVo goldAccountVo = memberAccountGoldDao.selectAccountGoldVoByMemberId(memberId); return Result.ok(goldAccountVo); } @Override public Result getOwnCannon() { Long memberId = LoginUserUtils.getAppLoginUser().getId(); List<OwnCannonVo> cannonOwnRecords = cannonOwnRecordDao.selectCannonOwnRecordsByMemberId(memberId); return Result.ok(cannonOwnRecords); } public static void main(String[] args) { System.out.println(UUID.randomUUID().toString()); } src/main/java/com/xcong/excoin/modules/fish/vo/CannonSettingVo.java
@@ -18,7 +18,7 @@ private String code; @ApiModelProperty(value = "兑换价格")//兑换价格 private BigDecimal exchangePrice; @ApiModelProperty(value = "1发炮弹消耗金币数")//消耗金币 @ApiModelProperty(value = "每发炮弹消耗金币数")//消耗金币 private BigDecimal goldConsume; } src/main/java/com/xcong/excoin/modules/fish/vo/GoldAccountVo.java
New file @@ -0,0 +1,20 @@ package com.xcong.excoin.modules.fish.vo; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.math.BigDecimal; @Data @ApiModel(value = "GoldAccountVo", description = "金币账户") public class GoldAccountVo { private Long memberId; @ApiModelProperty(value = "金币可用余额")//金币可用余额 private BigDecimal availableBalance; @ApiModelProperty(value = "金币总金额")//金币总金额 private BigDecimal totalBalance; @ApiModelProperty(value = "金币冻结余额")//金币冻结余额 private BigDecimal frozenBalance; } src/main/java/com/xcong/excoin/modules/fish/vo/OwnCannonVo.java
New file @@ -0,0 +1,25 @@ package com.xcong.excoin.modules.fish.vo; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.math.BigDecimal; @Data @ApiModel(value = "OwnCannonVo", description = "金币账户") public class OwnCannonVo { private Long memberId; @ApiModelProperty(value = "炮台UUID")//炮台UUID private String cannonUuid; @ApiModelProperty(value = "炮台名称")//炮台名称 private String cannonName; @ApiModelProperty(value = "炮台编码")//炮台编码 private String cannonCode; @ApiModelProperty(value = "炮台兑换价格")//炮台兑换价格 private BigDecimal cannonPrice; @ApiModelProperty(value = "每发炮弹消耗金币数")//消耗金币 private BigDecimal goldConsume; @ApiModelProperty(value = "1:主动购买 2:系统赠送")//1:主动购买 2:系统赠送 private Integer type; } src/main/resources/mapper/fish/CannonOwnRecordDao.xml
@@ -6,4 +6,11 @@ select a.* from cannon_own_record a where a.member_id = #{memberId} and a.cannon_code = #{code} </select> <select id="selectCannonOwnRecordsByMemberId" resultType="com.xcong.excoin.modules.fish.vo.OwnCannonVo"> select a.*,b.gold_consume goldConsume from cannon_own_record a left join cannon_setting b on a.cannon_code = b.code where a.member_id = #{memberId} </select> </mapper> src/main/resources/mapper/fish/MemberAccountGoldDao.xml
@@ -28,4 +28,8 @@ where id=#{id} </update> <select id="selectAccountGoldVoByMemberId" resultType="com.xcong.excoin.modules.fish.vo.GoldAccountVo"> select a.* from member_account_gold a where a.member_id = #{memberId} </select> </mapper>