xiaoyong931011
2020-06-01 70667d9acc975f09d160d2b5fea28a3b1fc73287
20200601   代码提交
3 files added
4 files modified
220 ■■■■■ changed files
src/main/java/com/xcong/excoin/modules/member/controller/MemberController.java 13 ●●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/modules/member/dao/MemberCoinWithdrawDao.java 8 ●●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/modules/member/dao/MemberDao.java 1 ●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/modules/member/entity/MemberCoinWithdrawEntity.java 58 ●●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/modules/member/parameter/dto/MemberSubmitCoinApplyDto.java 48 ●●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/modules/member/service/MemberService.java 3 ●●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/modules/member/service/impl/MemberServiceImpl.java 89 ●●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/modules/member/controller/MemberController.java
@@ -18,6 +18,7 @@
import com.xcong.excoin.modules.member.parameter.dto.MemberDelPaymethodDto;
import com.xcong.excoin.modules.member.parameter.dto.MemberForgetPwdDto;
import com.xcong.excoin.modules.member.parameter.dto.MemberPaymethodDto;
import com.xcong.excoin.modules.member.parameter.dto.MemberSubmitCoinApplyDto;
import com.xcong.excoin.modules.member.parameter.dto.MemberUpdatePwdDto;
import com.xcong.excoin.modules.member.parameter.dto.MemberUpdateTradePwdDto;
import com.xcong.excoin.modules.member.parameter.dto.MemberUpdateTradersPwdTimeDto;
@@ -312,4 +313,16 @@
        return memberService.memberAvivableCoinInfo(symbol);
    }
    
    /**
     *     提币申请
     * @param token
     * @param coinVo
     * @return
     */
    @ApiOperation(value="提交提币申请", notes="提交提币申请")
    @PostMapping(value="/memberSubmitCoinApply")
    public Result memberSubmitCoinApply(@RequestBody @Valid MemberSubmitCoinApplyDto memberSubmitCoinApplyDto) {
        return memberService.memberSubmitCoinApply(memberSubmitCoinApplyDto);
    }
}
src/main/java/com/xcong/excoin/modules/member/dao/MemberCoinWithdrawDao.java
New file
@@ -0,0 +1,8 @@
package com.xcong.excoin.modules.member.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xcong.excoin.modules.member.entity.MemberCoinWithdrawEntity;
public interface MemberCoinWithdrawDao  extends BaseMapper<MemberCoinWithdrawEntity> {
}
src/main/java/com/xcong/excoin/modules/member/dao/MemberDao.java
@@ -2,6 +2,7 @@
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xcong.excoin.modules.member.entity.MemberEntity;
import com.xcong.excoin.modules.member.entity.MemberWalletCoinEntity;
import com.xcong.excoin.modules.member.parameter.vo.NeedMoneyMemberVo;
import org.apache.ibatis.annotations.Param;
src/main/java/com/xcong/excoin/modules/member/entity/MemberCoinWithdrawEntity.java
New file
@@ -0,0 +1,58 @@
package com.xcong.excoin.modules.member.entity;
import java.math.BigDecimal;
import com.baomidou.mybatisplus.annotation.TableName;
import com.xcong.excoin.common.system.base.BaseEntity;
import lombok.Data;
/**
 * 会员提币表
 */
@Data
@TableName("member_coin_withdraw")
public class MemberCoinWithdrawEntity extends BaseEntity{
    /**
     *
     */
    private static final long serialVersionUID = 1L;
     /**
     * 会员ID
     */
    private Long memberId;
    /**
     * 地址
     */
    private String address;
    /**
     * 提币数量
     */
    private BigDecimal amount;
    /**
     * 手续费
     */
    private BigDecimal feeAmount;
    /**
     * 币种
     */
    private String symbol;
    /**
     * 状态
     */
    private int status;
    public static final int STATUS_DOING = 1;
    /**
     * 是否内部转账 Y-是N-不是
     */
    private String isInside;
    public static final String ISINSIDE_YES = "Y";
    public static final String ISINSIDE_NO = "N";
    private String label;
    private String tag;
}
src/main/java/com/xcong/excoin/modules/member/parameter/dto/MemberSubmitCoinApplyDto.java
New file
@@ -0,0 +1,48 @@
package com.xcong.excoin.modules.member.parameter.dto;
import java.math.BigDecimal;
import javax.validation.constraints.NotNull;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel(value = "MemberSubmitCoinApplyDto", description = "提交提币申请参数接收类")
public class MemberSubmitCoinApplyDto {
    @NotNull(message = "地址不能为空")
    @ApiModelProperty(value = "地址", example = "asfdsdafsdafdsaf1231232sdfsa")
    private String address;
    @NotNull(message = "币数量不能为空")
    @ApiModelProperty(value = "币数量", example = "10")
    private BigDecimal coinNumber;
    @NotNull(message = "手续费不能为空")
    @ApiModelProperty(value = "手续费", example = "10")
    private BigDecimal feeAmount;
    @NotNull(message = "交易密码不能为空")
    @ApiModelProperty(value = "交易密码", example = "123456")
    private String tradePassword;
    @NotNull(message = "验证码不能为空")
    @ApiModelProperty(value = "验证码", example = "123456")
    private String code;
    @NotNull(message = "验证方式不能为空")
    @ApiModelProperty(value = "验证方式", example = "13412341234")
    private String account;
    @NotNull(message = "币种不能为空")
    @ApiModelProperty(value = "币种", example = "BTC")
    private String symbol;
    @ApiModelProperty(value = "姓名", example = "姓名")
    private String lable;
    @ApiModelProperty(value = "姓名", example = "姓名")
    private String tag;
}
src/main/java/com/xcong/excoin/modules/member/service/MemberService.java
@@ -14,6 +14,7 @@
import com.xcong.excoin.modules.member.parameter.dto.MemberDelPaymethodDto;
import com.xcong.excoin.modules.member.parameter.dto.MemberForgetPwdDto;
import com.xcong.excoin.modules.member.parameter.dto.MemberPaymethodDto;
import com.xcong.excoin.modules.member.parameter.dto.MemberSubmitCoinApplyDto;
import com.xcong.excoin.modules.member.parameter.dto.MemberUpdatePwdDto;
import com.xcong.excoin.modules.member.parameter.dto.MemberUpdateTradePwdDto;
import com.xcong.excoin.modules.member.parameter.dto.MemberUpdateTradersPwdTimeDto;
@@ -81,5 +82,7 @@
    public Result memberUpdateTradersPwdTime(@Valid MemberUpdateTradersPwdTimeDto memberUpdateTradersPwdTimeDto);
    public Result memberSubmitCoinApply(@Valid MemberSubmitCoinApplyDto memberSubmitCoinApplyDto);
}
src/main/java/com/xcong/excoin/modules/member/service/impl/MemberServiceImpl.java
@@ -13,6 +13,8 @@
import com.xcong.excoin.common.response.Result;
import com.xcong.excoin.common.system.dto.RegisterDto;
import com.xcong.excoin.common.system.service.CommonService;
import com.xcong.excoin.modules.coin.dao.MemberAccountMoneyChangeDao;
import com.xcong.excoin.modules.coin.entity.MemberAccountMoneyChange;
import com.xcong.excoin.modules.member.dao.*;
import com.xcong.excoin.modules.member.entity.*;
import com.xcong.excoin.modules.member.parameter.dto.MemberAddCoinAddressDto;
@@ -23,6 +25,7 @@
import com.xcong.excoin.modules.member.parameter.dto.MemberDelPaymethodDto;
import com.xcong.excoin.modules.member.parameter.dto.MemberForgetPwdDto;
import com.xcong.excoin.modules.member.parameter.dto.MemberPaymethodDto;
import com.xcong.excoin.modules.member.parameter.dto.MemberSubmitCoinApplyDto;
import com.xcong.excoin.modules.member.parameter.dto.MemberUpdatePwdDto;
import com.xcong.excoin.modules.member.parameter.dto.MemberUpdateTradePwdDto;
import com.xcong.excoin.modules.member.parameter.dto.MemberUpdateTradersPwdTimeDto;
@@ -75,6 +78,9 @@
    @Resource
    private MemberWalletAgentDao memberWalletAgentDao;
    @Resource
    MemberAccountMoneyChangeDao memberAccountMoneyChangeDao;
    @Resource
    private MemberWalletContractDao memberWalletContractDao;
@@ -105,6 +111,9 @@
    
    @Resource
    private CommonService commonservice;
    @Resource
    MemberCoinWithdrawDao memberCoinWithdrawDao;
    @Resource
    private MemberWalletContractSimulateDao memberWalletContractSimulateDao;
@@ -790,5 +799,83 @@
        return Result.ok("success");
    }
    @Override
    public Result memberSubmitCoinApply(@Valid MemberSubmitCoinApplyDto memberSubmitCoinApplyDto) {
        //获取用户ID
        Long memberId = LoginUserUtils.getAppLoginUser().getId();
        MemberEntity member = memberDao.selectById(memberId);
                    if (member.getCertifyStatus() != MemberEntity.CERTIFY_STATUS_Y) {
                        return Result.fail(MessageSourceUtils.getString("member_service_0077"));
                    }
                    if (StrUtil.isEmpty(member.getTradePassword())) {
                        return Result.fail(MessageSourceUtils.getString("member_service_0081"));
                    }
                    if(member.getTradePassword() == null) {
                        return Result.fail(MessageSourceUtils.getString("member_service_0082"));
                    }
                    if (!member.getTradePassword().equals(SecureUtil.md5(memberSubmitCoinApplyDto.getTradePassword()))) {
                        return Result.fail(MessageSourceUtils.getString("member_service_0082"));
                    }
                    boolean flag = commonservice.verifyCode(memberSubmitCoinApplyDto.getAccount(), memberSubmitCoinApplyDto.getCode());
                    if (flag) {
                        MemberWalletCoinEntity walletCoin = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId, memberSubmitCoinApplyDto.getSymbol());
                        BigDecimal availableBalance = walletCoin.getAvailableBalance();
                        BigDecimal coinNumber = memberSubmitCoinApplyDto.getCoinNumber().add(memberSubmitCoinApplyDto.getFeeAmount());
                        if(availableBalance.compareTo(BigDecimal.ZERO) > 0
                                && availableBalance.compareTo(coinNumber) > 0) {
                            //新增提币记录
                            MemberCoinWithdrawEntity memberCoinWithdrawEntity = new MemberCoinWithdrawEntity();
                            memberCoinWithdrawEntity.setAddress(memberSubmitCoinApplyDto.getAddress());
                            memberCoinWithdrawEntity.setAmount(coinNumber.setScale(4, BigDecimal.ROUND_DOWN));
                            memberCoinWithdrawEntity.setFeeAmount(memberSubmitCoinApplyDto.getFeeAmount().setScale(4, BigDecimal.ROUND_DOWN));
                            memberCoinWithdrawEntity.setSymbol(memberSubmitCoinApplyDto.getSymbol());
                            memberCoinWithdrawEntity.setMemberId(memberId);
                            memberCoinWithdrawEntity.setStatus(MemberCoinWithdrawEntity.STATUS_DOING);
                            Map<String,Object> columnMap = new HashMap<>();
                            columnMap.put("symbol", memberSubmitCoinApplyDto.getSymbol());
                            columnMap.put("address", memberSubmitCoinApplyDto.getAddress());
                            List<MemberCoinAddressEntity> selectByMap = memberCoinAddressDao.selectByMap(columnMap);
                            if(CollUtil.isEmpty(selectByMap)) {
                                memberCoinWithdrawEntity.setIsInside(MemberCoinWithdrawEntity.ISINSIDE_NO);
                            }else {
                                memberCoinWithdrawEntity.setIsInside(MemberCoinWithdrawEntity.ISINSIDE_YES);
                            }
                            memberCoinWithdrawDao.insert(memberCoinWithdrawEntity);
                            BigDecimal subtract = walletCoin.getAvailableBalance().subtract(coinNumber);
                            walletCoin.setAvailableBalance(subtract.setScale(4, BigDecimal.ROUND_DOWN));
                            BigDecimal add = walletCoin.getFrozenBalance().add(coinNumber);
                            walletCoin.setFrozenBalance(add.setScale(4, BigDecimal.ROUND_DOWN));
                            memberWalletCoinDao.updateById(walletCoin);
                            MemberAccountMoneyChange accountRecord = new MemberAccountMoneyChange();
                            accountRecord.setContent("提币");
                            accountRecord.setMemberId(memberId);
                            accountRecord.setAmount(memberSubmitCoinApplyDto.getCoinNumber());
                            accountRecord.setStatus(MemberAccountMoneyChange.STATUS_WAIT_INTEGER);
                            accountRecord.setSymbol(memberSubmitCoinApplyDto.getSymbol());
                            accountRecord.setType(MemberAccountMoneyChange.TYPE_WALLET_COIN);
                            memberAccountMoneyChangeDao.insert(accountRecord);
                         /**
                          *  TODO dingtalk
                            Constant.excutor.execute(new Runnable() {
                                @Override
                                public void run() {
                                    DingTalkUtils.sendActionCard(3);
                                }
                            });
                            */
                            return Result.ok(MessageSourceUtils.getString("member_service_0086"));
                        }else {
                            return Result.fail(MessageSourceUtils.getString("order_service_0040"));
                        }
                    }else {
                        return Result.fail(MessageSourceUtils.getString("member_service_0039"));
                    }
        }
}