parent
fac6ec1336
commit
e59c2f3c1e
16 changed files with 439 additions and 129 deletions
@ -0,0 +1,49 @@ |
|||||||
|
package com.blockchain.server.yyyf.controller; |
||||||
|
|
||||||
|
import com.blockchain.common.base.dto.ResultDTO; |
||||||
|
import com.blockchain.server.yyyf.controller.api.YyyfMoneyApi; |
||||||
|
import com.blockchain.server.yyyf.dto.TransactResultDto; |
||||||
|
import com.blockchain.server.yyyf.entity.YyyfMoney; |
||||||
|
import com.blockchain.server.yyyf.service.YyyfMoneyService; |
||||||
|
import io.swagger.annotations.Api; |
||||||
|
import io.swagger.annotations.ApiOperation; |
||||||
|
import io.swagger.annotations.ApiParam; |
||||||
|
import org.slf4j.Logger; |
||||||
|
import org.slf4j.LoggerFactory; |
||||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||||
|
import org.springframework.web.bind.annotation.PostMapping; |
||||||
|
import org.springframework.web.bind.annotation.RequestMapping; |
||||||
|
import org.springframework.web.bind.annotation.RequestParam; |
||||||
|
import org.springframework.web.bind.annotation.RestController; |
||||||
|
|
||||||
|
import java.math.BigDecimal; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author Mr.Xu |
||||||
|
* @version 1.0 |
||||||
|
* @className MoneyController |
||||||
|
* @description |
||||||
|
* @date 2020-05-26 20:50 |
||||||
|
*/ |
||||||
|
@RestController |
||||||
|
@Api(YyyfMoneyApi.CONTROLLER_API) |
||||||
|
@RequestMapping("/yyyfMoney") |
||||||
|
public class YyyfMoneyController { |
||||||
|
|
||||||
|
@Autowired |
||||||
|
private YyyfMoneyService yyyfMoneyService; |
||||||
|
|
||||||
|
private static Logger LOG = LoggerFactory.getLogger(YyyfMoneyController.class); |
||||||
|
@PostMapping("/transact") |
||||||
|
@ApiOperation(value = YyyfMoneyApi.Transact.METHOD_NAME, |
||||||
|
notes = YyyfMoneyApi.Transact.METHOD_NOTE) |
||||||
|
public ResultDTO<TransactResultDto> transact(@ApiParam(YyyfMoneyApi.Transact.METHOD_ASSESS_USER_ID) @RequestParam(name = "assessUserId",required =true) String assessUserId, |
||||||
|
@ApiParam(YyyfMoneyApi.Transact.METHOD_OUT) @RequestParam(name = "out",required =true) String out, |
||||||
|
@ApiParam(YyyfMoneyApi.Transact.METHOD_IN) @RequestParam(name = "in",required =true) String in, |
||||||
|
@ApiParam(YyyfMoneyApi.Transact.METHOD_AMOUNT) @RequestParam(name = "amount",required =true) BigDecimal amount) { |
||||||
|
|
||||||
|
TransactResultDto transactResultDto=this.yyyfMoneyService.transact(assessUserId,out,in,amount); |
||||||
|
|
||||||
|
return ResultDTO.requstSuccess(transactResultDto); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,20 @@ |
|||||||
|
package com.blockchain.server.yyyf.controller.api; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author Mr.Xu |
||||||
|
* @version 1.0 |
||||||
|
* @className MoneyApi |
||||||
|
* @description |
||||||
|
* @date 2020-05-26 20:59 |
||||||
|
*/ |
||||||
|
public class YyyfMoneyApi { |
||||||
|
public static final String CONTROLLER_API = "金钱变化交易器"; |
||||||
|
public static class Transact { |
||||||
|
public static final String METHOD_NAME = "交易转账"; |
||||||
|
public static final String METHOD_NOTE = "out为转出币种,in为转入币种"; |
||||||
|
public static final String METHOD_ASSESS_USER_ID= "assessUser的主键ID"; |
||||||
|
public static final String METHOD_OUT="转出币种"; |
||||||
|
public static final String METHOD_IN="转入币种"; |
||||||
|
public static final String METHOD_AMOUNT="转入金额"; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,37 @@ |
|||||||
|
package com.blockchain.server.yyyf.dto; |
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel; |
||||||
|
import io.swagger.annotations.ApiModelProperty; |
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
import java.math.BigDecimal; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author Mr.Xu |
||||||
|
* @version 1.0 |
||||||
|
* @className TransactDto |
||||||
|
* @description |
||||||
|
* @date 2020-05-26 21:41 |
||||||
|
*/ |
||||||
|
@ApiModel(description = "交易转账结果") |
||||||
|
@Data |
||||||
|
public class TransactResultDto { |
||||||
|
|
||||||
|
@ApiModelProperty("转出币种") |
||||||
|
private String out; |
||||||
|
@ApiModelProperty("转入币种") |
||||||
|
private String in; |
||||||
|
@ApiModelProperty("转出币种剩余金额") |
||||||
|
private BigDecimal outSurplus; |
||||||
|
@ApiModelProperty("转入剩余金额") |
||||||
|
private BigDecimal inSurplus; |
||||||
|
|
||||||
|
@ApiModelProperty("转出币种原金额") |
||||||
|
private BigDecimal outOriginal; |
||||||
|
@ApiModelProperty("转入原金额") |
||||||
|
private BigDecimal inOriginal; |
||||||
|
|
||||||
|
@ApiModelProperty("交易金额") |
||||||
|
private BigDecimal amount; |
||||||
|
|
||||||
|
} |
@ -0,0 +1,41 @@ |
|||||||
|
package com.blockchain.server.yyyf.entity; |
||||||
|
|
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
import javax.persistence.Column; |
||||||
|
import javax.persistence.Id; |
||||||
|
import javax.persistence.Table; |
||||||
|
import java.io.Serializable; |
||||||
|
import java.math.BigDecimal; |
||||||
|
import java.util.Date; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author Mr.Xu |
||||||
|
* @version 1.0 |
||||||
|
* @className YyyfMoney |
||||||
|
* @description |
||||||
|
* @date 2020-05-26 21:30 |
||||||
|
*/ |
||||||
|
@Table(name = "Yyyf_money") |
||||||
|
@Data |
||||||
|
public class YyyfMoney implements Serializable { |
||||||
|
private static final long serialVersionUID = 8690026237757740821L; |
||||||
|
@Id |
||||||
|
@Column(name = "assess_user_id") |
||||||
|
private String assessUserId; |
||||||
|
@Column(name = "ali_pay") |
||||||
|
private BigDecimal aliPay; |
||||||
|
@Column(name = "wx_pay") |
||||||
|
private BigDecimal wxPay; |
||||||
|
@Column(name = "bank_card") |
||||||
|
private BigDecimal bankCard; |
||||||
|
@Column(name = "btc") |
||||||
|
private BigDecimal btc; |
||||||
|
@Column(name = "usdt") |
||||||
|
private BigDecimal usdt; |
||||||
|
@Column(name = "eth") |
||||||
|
private BigDecimal eth; |
||||||
|
|
||||||
|
@Column(name = "update_time") |
||||||
|
private Date updateTime; |
||||||
|
} |
@ -1,97 +0,0 @@ |
|||||||
package com.blockchain.server.yyyf.enums; |
|
||||||
|
|
||||||
/** |
|
||||||
* @author huangxl |
|
||||||
* @data 2019/2/21 20:53 |
|
||||||
*/ |
|
||||||
public enum UserEnums { |
|
||||||
NO_INDICATORS_FOUND(1096,"查不到指标","No indicators found","查不到指標"), |
|
||||||
PROHIBIT_DUPLICATE_SUBMISSION(1097,"禁止重复提交","Prohibit duplicate submission","禁止重複提交"), |
|
||||||
USER_NOT_FORBID_OTHER_USER(1098, "禁止登录他人账号", "The user does not allow login other user's accout", "禁止登錄他人賬號"), |
|
||||||
USER_NOT_BIND_YYYF(1099, "该用户未绑定以渔有方或者以渔有方登录已失效", "The user does not bind yyyf", "該用戶未綁定以漁有方或者以漁有方登錄已失效"), |
|
||||||
USER_EXISTS(1100, "该用户已存在", "The user already exists", "該用戶已存在"), |
|
||||||
USER_NOT_EXISTS(1101, "不存在该用户", "The user does not exist", "不存在該用戶"), |
|
||||||
LOGIN_PASSWORD_ERROR(1102, "用户名密码错误", "Wrong username and password", "用戶名密碼錯誤"), |
|
||||||
LOGIN_FORBIDDEN(1103, "你被列入黑名单,禁止登录", "You are blacklisted from logging in", "你被列入黑名單,禁止登錄"), |
|
||||||
SMS_VERIFY_FAIL(1104, "手机号验证码错误", "Wrong verification code for mobile phone number", "手機號驗證碼錯誤"), |
|
||||||
SMS_CODE_NOT_EXIST(1105, "请先获取验证码信息", "Please get the captcha information first", "請先獲取驗證碼資訊"), |
|
||||||
PHONE_FORMAT_ERROR(1106, "手机号格式不正确", "The phone number format is not correct", "手機號格式不正確"), |
|
||||||
FORMAT_ERROR(1106, "手机号或邮箱格式不正确", "The phone number or email format is not correct", "手機號或郵箱格式不正確"), |
|
||||||
VERIFY_CODE_TYPE_ERROR(1107, "没有此类型短信", "There is no text message of this type", "沒有此類型短信"), |
|
||||||
VERIFY_CODE_OVER_COUNT(1108, "今日获取验证码到达上限", "The upper limit of the captcha is reached today", "今日獲取驗證碼到達上限"), |
|
||||||
USER_PHONE_EXISTS(1109, "该手机号或邮箱已存在", "The phone number or email address already exists", "該手機號或郵箱已存在"), |
|
||||||
USER_PASSWORD_ERROR_FORMAT(1110, "密码只能是6-16位数字、字母和特殊字符的组合", "Passwords can only be 6-16 digit combinations of Numbers, letters, and special characters", "密碼只能是6-16位數字、字母和特殊字元的組合"), |
|
||||||
INVALID_INVITATION_CODE(1111, "无效的邀请码信息", "Invalid invitation code information", "無效的邀請碼資訊"), |
|
||||||
INVALID_NICK_NAME(1112, "昵称不能包含特殊字符", "Nicknames cannot contain special characters", "昵稱不能包含特殊字元"), |
|
||||||
PHONE_NOT_CHANGE(1113, "手机号码与当前用户一致", "The phone number is the same as the current user", "手機號碼與當前用戶一致"), |
|
||||||
GOOGLE_SECRET_KEY_FAIL(1114, "获取谷歌安全码失败", "Failed to get Google security code", "獲取穀歌安全碼失敗"), |
|
||||||
GOOGLE_SECRET_KEY_EXIST(1115, "你已绑定谷歌验证器,请勿重复绑定", "You have bound the Google validator. Do not repeat the binding", "你已綁定穀歌驗證器,請勿重複綁定"), |
|
||||||
GOOGLE_AUTH_FAIL(1116, "谷歌验证器验证失败", "Google verifier validation failed", "穀歌驗證器驗證失敗"), |
|
||||||
FILE_UPLOAD_ERROR(1117, "文件上传失败", "File upload failed", "文檔上傳失敗"), |
|
||||||
FILE_UPLOAD_LIMIT(1118, "文件上传失败,上传文件次数过多!", "File upload failed, too many times!", "文檔上傳失敗,上傳檔次數過多!"), |
|
||||||
FILE_UPLOAD_FORMAT_ERROR(1119, "文件地址错误", "File address error", "文檔地址錯誤"), |
|
||||||
FILE_UPLOAD_DEFICIENCY(1120, "请先上传文件", "Please upload the file first", "請先上傳文檔"), |
|
||||||
AUTH_WAIT(1121, "认证审核中,请勿重复申请!", "Please do not repeat the application during the certification audit!", "認證審核中,請勿重複申請!"), |
|
||||||
AUTH_YES(1122, "你已完成认证!", "You have completed the certification!", "你已完成認證!"), |
|
||||||
AUTH_BASIC_BEFORE(1123, "请先完成初级认证!", "Please complete the primary certification first!", "請先完成初級認證!"), |
|
||||||
EMAIL_FORMAT_ERROR(1124, "无效的邮箱格式!", "Invalid mailbox format!", "無效的郵箱格式!"), |
|
||||||
EMAIL_VERIFY_FAIL(1125, "邮箱验证失败!", "Mailbox authentication failed!", "郵箱驗證失敗!"), |
|
||||||
EMAIL_BIND_REPEAT(1126, "绑定失败,你已绑定邮箱", "Failed to bind. You have bound your mailbox", "綁定失敗,你已綁定郵箱"), |
|
||||||
PASSWORD_EXIST(1127, "设置失败,你已经设置过密码了", "Setup failed. You have already set the password", "設置失敗,你已經設置過密碼了"), |
|
||||||
EMAIL_EXIST(1128, "绑定失败,该邮箱已被绑定!", "The mailbox has been bound!", "綁定失敗,該郵箱已被綁定!"), |
|
||||||
PASSWORD_NOT_MATCH(1129, "密码不匹配", "Password mismatch", "密碼不匹配"), |
|
||||||
TRANSACTION_FORBIDDEN(1130, "你被列入黑名单,禁止交易!", "You're blacklisted! No trading!", "你被列入黑名單,禁止交易!"), |
|
||||||
CANNOT_FOUND_INTERNATIONAL(1131, "找不到该国家信息", "Country information not available", "找不到該國家信息"), |
|
||||||
VERIFY_CODE_DID_NOT_FIND(1034, "验证码已过期或没有获取", "The captcha is expired or not available", "驗證碼已過期或沒有獲取"), |
|
||||||
VERIFY_CODE_DID_NOT_MATCH(1035, "您输入的验证码不匹配", "The verification code you entered does not match", "您輸入的驗證碼不匹配"), |
|
||||||
WITHDRAW_FORBIDDEN(1136, "你被列入黑名单,禁止提现!", "You are blacklisted and no withdrawal is allowed!", "你被列入黑名單,禁止提現!"), |
|
||||||
TRANSACTION_NOT_PASS_HIGH_AUTH(1137, "操作失败,您未通过高级认证!", "Operation failed. You did not pass advanced certification!", "操作失敗,您未通過高級認證!"), |
|
||||||
TRANSACTION_NOT_PASS_LOW_AUTH(1137, "操作失败,您未通过初级认证!", "Operation failed. You did not pass primary certification!", "操作失敗,您未通過初級認證!"), |
|
||||||
SEND_CODE_ERROR(1138, "验证码发送失败!", "Verification code failed to send!", "驗證碼發送失敗!"), |
|
||||||
; |
|
||||||
|
|
||||||
|
|
||||||
private int code; |
|
||||||
private String hkmsg; |
|
||||||
private String enMsg; |
|
||||||
private String cnmsg; |
|
||||||
|
|
||||||
UserEnums(int code, String cnmsg, String enMsg, String hkmsg) { |
|
||||||
this.code = code; |
|
||||||
this.cnmsg = cnmsg; |
|
||||||
this.enMsg = enMsg; |
|
||||||
this.hkmsg = hkmsg; |
|
||||||
} |
|
||||||
|
|
||||||
public int getCode() { |
|
||||||
return code; |
|
||||||
} |
|
||||||
|
|
||||||
public void setCode(int code) { |
|
||||||
this.code = code; |
|
||||||
} |
|
||||||
|
|
||||||
public String getHkmsg() { |
|
||||||
return hkmsg; |
|
||||||
} |
|
||||||
|
|
||||||
public void setHkmsg(String hkmsg) { |
|
||||||
this.hkmsg = hkmsg; |
|
||||||
} |
|
||||||
|
|
||||||
public String getEnMsg() { |
|
||||||
return enMsg; |
|
||||||
} |
|
||||||
|
|
||||||
public void setEnMsg(String enMsg) { |
|
||||||
this.enMsg = enMsg; |
|
||||||
} |
|
||||||
|
|
||||||
public String getCnmsg() { |
|
||||||
return cnmsg; |
|
||||||
} |
|
||||||
|
|
||||||
public void setCnmsg(String cnmsg) { |
|
||||||
this.cnmsg = cnmsg; |
|
||||||
} |
|
||||||
} |
|
@ -0,0 +1,59 @@ |
|||||||
|
package com.blockchain.server.yyyf.enums; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author huangxl |
||||||
|
* @data 2019/2/21 20:53 |
||||||
|
*/ |
||||||
|
public enum YyyfEnums { |
||||||
|
MONEY_LOW(1094,"转出币种余额不足","Insufficient transfer out currency balance","轉出幣種餘額不足"), |
||||||
|
FODBID_EXAM_RESTART(1095,"考试禁止重新开始","The exam is not allowed to restart","考試禁止重新開始"), |
||||||
|
NO_INDICATORS_FOUND(1096,"查不到指标","No indicators found","查不到指標"), |
||||||
|
PROHIBIT_DUPLICATE_SUBMISSION(1097,"禁止重复提交","Prohibit duplicate submission","禁止重複提交"), |
||||||
|
|
||||||
|
; |
||||||
|
|
||||||
|
|
||||||
|
private int code; |
||||||
|
private String hkmsg; |
||||||
|
private String enMsg; |
||||||
|
private String cnmsg; |
||||||
|
|
||||||
|
YyyfEnums(int code, String cnmsg, String enMsg, String hkmsg) { |
||||||
|
this.code = code; |
||||||
|
this.cnmsg = cnmsg; |
||||||
|
this.enMsg = enMsg; |
||||||
|
this.hkmsg = hkmsg; |
||||||
|
} |
||||||
|
|
||||||
|
public int getCode() { |
||||||
|
return code; |
||||||
|
} |
||||||
|
|
||||||
|
public void setCode(int code) { |
||||||
|
this.code = code; |
||||||
|
} |
||||||
|
|
||||||
|
public String getHkmsg() { |
||||||
|
return hkmsg; |
||||||
|
} |
||||||
|
|
||||||
|
public void setHkmsg(String hkmsg) { |
||||||
|
this.hkmsg = hkmsg; |
||||||
|
} |
||||||
|
|
||||||
|
public String getEnMsg() { |
||||||
|
return enMsg; |
||||||
|
} |
||||||
|
|
||||||
|
public void setEnMsg(String enMsg) { |
||||||
|
this.enMsg = enMsg; |
||||||
|
} |
||||||
|
|
||||||
|
public String getCnmsg() { |
||||||
|
return cnmsg; |
||||||
|
} |
||||||
|
|
||||||
|
public void setCnmsg(String cnmsg) { |
||||||
|
this.cnmsg = cnmsg; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,16 @@ |
|||||||
|
package com.blockchain.server.yyyf.mapper; |
||||||
|
|
||||||
|
import com.blockchain.server.yyyf.entity.YyyfMoney; |
||||||
|
import org.springframework.stereotype.Repository; |
||||||
|
import tk.mybatis.mapper.common.Mapper; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author Mr.Xu |
||||||
|
* @version 1.0 |
||||||
|
* @className YyyfMoneyMapper |
||||||
|
* @description |
||||||
|
* @date 2020-05-26 21:34 |
||||||
|
*/ |
||||||
|
@Repository |
||||||
|
public interface YyyfMoneyMapper extends Mapper<YyyfMoney> { |
||||||
|
} |
@ -0,0 +1,36 @@ |
|||||||
|
package com.blockchain.server.yyyf.service; |
||||||
|
|
||||||
|
import com.blockchain.server.yyyf.dto.TransactResultDto; |
||||||
|
import com.blockchain.server.yyyf.entity.YyyfMoney; |
||||||
|
|
||||||
|
import java.math.BigDecimal; |
||||||
|
|
||||||
|
public interface YyyfMoneyService { |
||||||
|
/** |
||||||
|
* @description 交易转账 |
||||||
|
* @author Mr.Xu |
||||||
|
* @date 2020-05-26 21:51:15 |
||||||
|
* @param [assessUserId, out, in, amount] |
||||||
|
* @return com.blockchain.server.yyyf.dto.TransactResultDto |
||||||
|
**/ |
||||||
|
TransactResultDto transact(String assessUserId, String out, String in, BigDecimal amount); |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* @description 插入 |
||||||
|
* @author Mr.Xu |
||||||
|
* @date 2020-05-26 22:48:08 |
||||||
|
* @param [yyyfMoney] |
||||||
|
* @return void |
||||||
|
**/ |
||||||
|
void insert(YyyfMoney yyyfMoney); |
||||||
|
|
||||||
|
/** |
||||||
|
* @description 更新 |
||||||
|
* @author Mr.Xu |
||||||
|
* @date 2020-05-26 22:48:19 |
||||||
|
* @param [yyyfMoney] |
||||||
|
* @return void |
||||||
|
**/ |
||||||
|
void update(YyyfMoney yyyfMoney); |
||||||
|
} |
@ -0,0 +1,92 @@ |
|||||||
|
package com.blockchain.server.yyyf.service.impl; |
||||||
|
|
||||||
|
import com.blockchain.server.yyyf.dto.TransactResultDto; |
||||||
|
import com.blockchain.server.yyyf.entity.YyyfMoney; |
||||||
|
import com.blockchain.server.yyyf.enums.YyyfEnums; |
||||||
|
import com.blockchain.server.yyyf.exceprion.YyyfException; |
||||||
|
import com.blockchain.server.yyyf.mapper.YyyfMoneyMapper; |
||||||
|
import com.blockchain.server.yyyf.service.YyyfMoneyService; |
||||||
|
import lombok.SneakyThrows; |
||||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||||
|
import org.springframework.stereotype.Service; |
||||||
|
import org.springframework.transaction.annotation.Transactional; |
||||||
|
|
||||||
|
import java.lang.reflect.Method; |
||||||
|
import java.math.BigDecimal; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author Mr.Xu |
||||||
|
* @version 1.0 |
||||||
|
* @className YyyfMoneyServiceImpl |
||||||
|
* @description |
||||||
|
* @date 2020-05-26 21:36 |
||||||
|
*/ |
||||||
|
@Transactional(rollbackFor = Exception.class) |
||||||
|
@Service |
||||||
|
public class YyyfMoneyServiceImpl implements YyyfMoneyService { |
||||||
|
|
||||||
|
|
||||||
|
@Autowired |
||||||
|
private YyyfMoneyMapper yyyfMoneyMapper; |
||||||
|
|
||||||
|
|
||||||
|
@SneakyThrows |
||||||
|
@Override |
||||||
|
public TransactResultDto transact(String assessUserId, String out, String in, BigDecimal amount) { |
||||||
|
|
||||||
|
YyyfMoney yyyfMoney = this.yyyfMoneyMapper.selectByPrimaryKey(assessUserId); |
||||||
|
BigDecimal outOriginal = null; |
||||||
|
BigDecimal inOriginal = null; |
||||||
|
Class<? extends YyyfMoney> aClass = yyyfMoney.getClass(); |
||||||
|
|
||||||
|
String outField = out.substring(0, 1).toUpperCase().concat(out.substring(1)); |
||||||
|
String inField = in.substring(0, 1).toUpperCase().concat(in.substring(1)); |
||||||
|
|
||||||
|
Method outGetMethod = aClass.getMethod("get".concat(outField)); |
||||||
|
//转出的原始金额
|
||||||
|
outOriginal = (BigDecimal) outGetMethod.invoke(yyyfMoney); |
||||||
|
|
||||||
|
Method inGetMethod = aClass.getMethod("get".concat(inField)); |
||||||
|
//转入的原始金额
|
||||||
|
inOriginal = (BigDecimal) inGetMethod.invoke(yyyfMoney); |
||||||
|
|
||||||
|
if (outOriginal.compareTo(amount) == -1) { |
||||||
|
throw new YyyfException(YyyfEnums.MONEY_LOW); |
||||||
|
} |
||||||
|
//转出币种后的余额
|
||||||
|
BigDecimal outSurplus = outOriginal.subtract(amount); |
||||||
|
//转入币种后的余额
|
||||||
|
BigDecimal inSurplus = inOriginal.add(amount); |
||||||
|
|
||||||
|
Method outSetMethod = aClass.getMethod("set".concat(outField),BigDecimal.class); |
||||||
|
Method inSetMethod = aClass.getMethod("set".concat(inField),BigDecimal.class); |
||||||
|
|
||||||
|
outSetMethod.invoke(yyyfMoney,outSurplus); |
||||||
|
inSetMethod.invoke(yyyfMoney,inSurplus); |
||||||
|
|
||||||
|
this.yyyfMoneyMapper.updateByPrimaryKeySelective(yyyfMoney); |
||||||
|
|
||||||
|
TransactResultDto transactResultDto = new TransactResultDto(); |
||||||
|
|
||||||
|
transactResultDto.setAmount(amount); |
||||||
|
transactResultDto.setOut(out); |
||||||
|
transactResultDto.setOutOriginal(outOriginal); |
||||||
|
transactResultDto.setOutSurplus(outSurplus); |
||||||
|
transactResultDto.setIn(in); |
||||||
|
transactResultDto.setInOriginal(inOriginal); |
||||||
|
transactResultDto.setInSurplus(inSurplus); |
||||||
|
|
||||||
|
|
||||||
|
return transactResultDto; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void insert(YyyfMoney yyyfMoney) { |
||||||
|
this.yyyfMoneyMapper.insert(yyyfMoney); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void update(YyyfMoney yyyfMoney) { |
||||||
|
this.yyyfMoneyMapper.updateByPrimaryKeySelective(yyyfMoney); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,5 @@ |
|||||||
|
<?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.blockchain.server.yyyf.mapper.YyyfMoneyMapper"> |
||||||
|
|
||||||
|
</mapper> |
Loading…
Reference in new issue