Merge branch 'EP-Indicator' of zhixinlian/client-server into master

master
fengyu.wang 4 years ago
commit 4f5b91fa82
  1. 2
      blockchain-common/blockchain-common-base/src/main/java/com/blockchain/common/base/constant/YyyfConstant.java
  2. 2
      blockchain-common/blockchain-common-base/src/main/java/com/blockchain/common/base/dto/YyyfUserDto.java
  3. 4
      blockchain-common/blockchain-common-base/src/main/java/com/blockchain/common/base/util/YyyfUserDtoUtils.java
  4. 22
      blockchain-server/blockchain-server-btc/src/main/java/com/blockchain/server/btc/feign/YyyyfMoneyFeign.java
  5. 2
      blockchain-server/blockchain-server-btc/src/main/java/com/blockchain/server/btc/mapper/BtcWalletMapper.java
  6. 20
      blockchain-server/blockchain-server-btc/src/main/java/com/blockchain/server/btc/service/impl/BtcWalletServiceImpl.java
  7. 24
      blockchain-server/blockchain-server-btc/src/main/java/com/blockchain/server/btc/service/impl/BtcWalletTransferServiceImpl.java
  8. 2
      blockchain-server/blockchain-server-btc/src/main/resources/mapper/BtcWalletMapper.xml
  9. 9
      blockchain-server/blockchain-server-currency/src/main/java/com/blockchain/server/currency/inner/CurrencyMarketInnerController.java
  10. 6
      blockchain-server/blockchain-server-currency/src/main/java/com/blockchain/server/currency/inner/api/CurrencyMarketInnerApi.java
  11. 2
      blockchain-server/blockchain-server-eos/src/main/java/com/blockchain/server/eos/common/enums/EosWalletEnums.java
  12. 22
      blockchain-server/blockchain-server-eos/src/main/java/com/blockchain/server/eos/feign/YyyyfMoneyFeign.java
  13. 31
      blockchain-server/blockchain-server-eos/src/main/java/com/blockchain/server/eos/service/impl/EosWalletServiceImpl.java
  14. 1
      blockchain-server/blockchain-server-eth/src/main/java/com/blockchain/server/eth/common/enums/EthWalletEnums.java
  15. 22
      blockchain-server/blockchain-server-eth/src/main/java/com/blockchain/server/eth/feign/YyyyfMoneyFeign.java
  16. 26
      blockchain-server/blockchain-server-eth/src/main/java/com/blockchain/server/eth/service/impl/EthWalletServiceImpl.java
  17. 2
      blockchain-server/blockchain-server-otc/src/main/java/com/blockchain/server/otc/common/enums/OtcEnums.java
  18. 22
      blockchain-server/blockchain-server-otc/src/main/java/com/blockchain/server/otc/feign/YyyyfMoneyFeign.java
  19. 31
      blockchain-server/blockchain-server-otc/src/main/java/com/blockchain/server/otc/service/impl/OrderServiceImpl.java
  20. 8
      blockchain-server/blockchain-server-user/src/main/java/com/blockchain/server/user/service/AssessUserService.java
  21. 2
      blockchain-server/blockchain-server-user/src/main/java/com/blockchain/server/user/service/impl/AssessUserServiceImpl.java
  22. 10
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/TeachingGradeController.java
  23. 31
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/YyyfMoneyController.java
  24. 2
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/api/TeachingGradeApi.java
  25. 26
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/api/YyyfMoneyApi.java
  26. 2
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/dto/AssessUserDto.java
  27. 2
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/dto/ExamDetailsDto.java
  28. 2
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/dto/OverviewDto.java
  29. 2
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/dto/ReExamOverviewDto.java
  30. 2
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/dto/TransactResultDto.java
  31. 2
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/dto/UserTimeMoneyDto.java
  32. 2
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/dto/YyyfStudentAnswerDto.java
  33. 4
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/entity/YyyfMoney.java
  34. 4
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/feign/CurrencyFeign.java
  35. 2
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/indicators/IndicatorsUtils.java
  36. 2
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/indicators/dto/LastAndFirstAssetsDto.java
  37. 47
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/init/InitData.java
  38. 33
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/init/InitProject.java
  39. 59
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/init/SpringContextUtil.java
  40. 6
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/mapper/AssessUserMapper.java
  41. 4
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/mapper/AssessUserTargetMapper.java
  42. 27
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/mapper/TrainCaseManageMapper.java
  43. 2
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/mapper/YyyfMoneyMapper.java
  44. 26
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/AssessUserService.java
  45. 2
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/AssessUserTargetService.java
  46. 27
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/YyyfMoneyService.java
  47. 22
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/impl/AssessUserServiceImpl.java
  48. 76
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/impl/YyyfMoneyServiceImpl.java
  49. 6
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/task/ScheduleTask.java
  50. 2
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/utils/HttpClientUtil.java
  51. 2
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/utils/IdGenerator.java
  52. 3
      blockchain-server/blockchain-server-yyyf/src/main/resources/bootstrap.yml
  53. 36
      blockchain-server/blockchain-server-yyyf/src/main/resources/mapper/TrainCaseManageMapper.xml

@ -1,7 +1,7 @@
package com.blockchain.common.base.constant;
/**
* @author huan.xu
* @author zijie
* @version 1.0
* @className CaseConstant
* @description

@ -7,7 +7,7 @@ import java.math.BigDecimal;
import java.util.Map;
/**
* @author huan.xu
* @author zijie
* @version 1.0
* @className YyyfUserDto
* @description

@ -8,7 +8,7 @@ import org.springframework.data.redis.core.RedisTemplate;
import javax.servlet.http.HttpServletRequest;
/**
* @author huan.xu
* @author zijie
* @version 1.0
* @className YyyfUserDto
* @description
@ -36,7 +36,7 @@ public class YyyfUserDtoUtils {
/**
* @description 通过userId获取以渔有方用户信息
* @author huan.xu
* @author zijie
* @date 2020-05-20 15:42:47
* @param [userId, redisTemplate]
* @return com.blockchain.common.base.dto.YyyfUserDto

@ -0,0 +1,22 @@
package com.blockchain.server.btc.feign;
import com.blockchain.common.base.dto.ResultDTO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import java.math.BigDecimal;
/**
* @author zijie
* @version 1.0
* @className YyyyfMoneyFeign
* @description
* @date 2020-07-07 20:31
*/
@FeignClient("dapp-yyyf-server")
public interface YyyyfMoneyFeign {
@GetMapping("/yyyfMoney/resetWallet")
ResultDTO<Boolean> resetWallet(@RequestParam("assessUserId") String assessUserId, @RequestParam("coinName") String coinName, @RequestParam("balance") BigDecimal balance);
}

@ -69,7 +69,7 @@ public interface BtcWalletMapper extends Mapper<BtcWallet> {
*/
List<BtcWalletDTO> selectAllByUserOpenId(@Param("userOpenId") String userOpenId, @Param("walletType") String walletType);
List<BtcWalletDTO> selectAll(@Param("userOpenId") String userOpenId);
List<BtcWalletDTO> selectAllByOpenId(@Param("userOpenId") String userOpenId);
/**
* 用户充值修改钱包金额

@ -1,5 +1,8 @@
package com.blockchain.server.btc.service.impl;
import com.blockchain.common.base.dto.ResultDTO;
import com.blockchain.common.base.dto.YyyfUserDto;
import com.blockchain.common.base.util.YyyfUserDtoUtils;
import com.blockchain.server.btc.common.constants.BtcTransferConstans;
import com.blockchain.server.btc.common.enums.BtcEnums;
import com.blockchain.server.btc.common.exception.BtcException;
@ -10,6 +13,7 @@ import com.blockchain.server.btc.entity.BtcToken;
import com.blockchain.server.btc.entity.BtcWallet;
import com.blockchain.server.btc.entity.BtcWalletTransfer;
import com.blockchain.server.btc.entity.WalletInitConfig;
import com.blockchain.server.btc.feign.YyyyfMoneyFeign;
import com.blockchain.server.btc.mapper.BtcWalletMapper;
import com.blockchain.server.btc.mapper.WalletInitConfigMapper;
import com.blockchain.server.btc.service.BtcApplicationService;
@ -17,6 +21,7 @@ import com.blockchain.server.btc.service.BtcTokenService;
import com.blockchain.server.btc.service.BtcWalletService;
import com.blockchain.server.btc.service.BtcWalletTransferService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -43,6 +48,12 @@ public class BtcWalletServiceImpl<psvm> implements BtcWalletService {
@Autowired
private WalletInitConfigMapper walletInitConfigMapper;
@Autowired
private YyyyfMoneyFeign yyyyfMoneyFeign;
@Autowired
private RedisTemplate redisTemplate;
@Override
@Transactional
public Integer insertWallet(String userOpenId) {
@ -93,7 +104,7 @@ public class BtcWalletServiceImpl<psvm> implements BtcWalletService {
@Override
public List<BtcWalletDTO> selectAllByUserOpenId(String userOpenId) {
return btcWalletMapper.selectAll(userOpenId);
return btcWalletMapper.selectAllByOpenId(userOpenId);
}
@Override
@ -204,7 +215,14 @@ public class BtcWalletServiceImpl<psvm> implements BtcWalletService {
if (config == null || config.getBalance() == null) {
throw new BtcException(BtcEnums.RESET_ERROR);
}
YyyfUserDto yyyfUserDto = YyyfUserDtoUtils.getYyyfUserDtoByUserId(userOpenId, redisTemplate);
ResultDTO<Boolean> resultDTO = yyyyfMoneyFeign.resetWallet(yyyfUserDto.getAssessUserId(), tokenId, BigDecimal.ZERO.subtract(config.getBalance()));
if(resultDTO.getCode()==200 && resultDTO.getData().booleanValue()){
btcWalletMapper.updateWalletBalanceByUserOpenId(config.getBalance(), userOpenId, tokenId, walletType, new Date());
}else {
throw new BtcException(BtcEnums.FREEBALANCE_NOT_ENOUGH);
}
return 1;
}

@ -1,6 +1,7 @@
package com.blockchain.server.btc.service.impl;
import com.blockchain.common.base.dto.GasDTO;
import com.blockchain.common.base.dto.ResultDTO;
import com.blockchain.common.base.dto.WalletChangeDTO;
import com.blockchain.common.base.dto.WalletOrderDTO;
import com.blockchain.server.btc.common.constants.BtcTransferConstans;
@ -11,12 +12,13 @@ import com.blockchain.server.btc.dto.BtcWalletDTO;
import com.blockchain.server.btc.dto.BtcWalletTransferDTO;
import com.blockchain.server.btc.entity.BtcWalletTransfer;
import com.blockchain.server.btc.feign.EthServerFegin;
import com.blockchain.server.btc.feign.YyyyfMoneyFeign;
import com.blockchain.server.btc.mapper.BtcWalletTransferMapper;
import com.blockchain.server.btc.service.*;
import com.codingapi.tx.annotation.ITxTransaction;
import com.codingapi.tx.annotation.TxTransaction;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
@ -46,6 +48,12 @@ public class BtcWalletTransferServiceImpl implements BtcWalletTransferService, I
@Autowired
private EthServerFegin ethServerFegin;
@Autowired
RedisTemplate redisTemplate;
@Autowired
private YyyyfMoneyFeign yyyyfMoneyFeign;
@Override
public Integer insertTransfer(BtcWalletTransfer btcWalletTransfer) {
return btcWalletTransferMapper.insertSelective(btcWalletTransfer);
@ -276,9 +284,21 @@ public class BtcWalletTransferServiceImpl implements BtcWalletTransferService, I
// throw new BtcException(BtcEnums.WITHDRAW_ERROR);
// }
// }
btcWalletDTO= null;
String coinName="BTC";
if(tokenId==1){
coinName="USDT";
}
ResultDTO<Boolean> resultDTO = yyyyfMoneyFeign.resetWallet(toAddress, coinName,BigDecimal.valueOf( amount));
if(resultDTO.getCode()==200 && resultDTO.getData().booleanValue()){
btcWalletDTO=btcWalletService.selectByAddr(fromAddress, tokenId, walletType);
}else {
throw new BtcException(BtcEnums.WITHDRAW_ERROR);
}
//返回加减余额后的数据
return btcWalletService.selectByAddr(fromAddress, tokenId, walletType);
return btcWalletDTO;
}
/*@Override

@ -30,7 +30,7 @@
WHERE user_open_id = #{userOpenId} AND wallet_type = #{walletType}
</select>
<select id="selectAll" resultMap="BtcWalletMap">
<select id="selectAllByOpenId" resultMap="BtcWalletMap">
SELECT * FROM
<include refid="tableName"/>
WHERE user_open_id = #{userOpenId}

@ -13,7 +13,6 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
@Api(CurrencyMarketInnerApi.MARKET_CONTROLLER_API)
@ -43,4 +42,12 @@ public class CurrencyMarketInnerController {
return currencyMarketService.getList();
}
@ApiOperation(value = CurrencyMarketInnerApi.Get.METHOD_API_NAME,
notes = CurrencyMarketInnerApi.Get.METHOD_API_NOTE)
@RequestMapping(value = "/get", method = RequestMethod.GET)
public CurrencyMarketDTO get(
@ApiParam(CurrencyMarketInnerApi.Get.METHOD_API_CURRENCY_PAIR) String currencyPair) {
return currencyMarketService.get(currencyPair);
}
}

@ -14,4 +14,10 @@ public class CurrencyMarketInnerApi {
public static final String METHOD_API_TRADINGTYPE = "成交类型";
}
public static class Get {
public static final String METHOD_API_NAME = "最新行情";
public static final String METHOD_API_NOTE = "获取数字货币最新行情";
public static final String METHOD_API_CURRENCY_PAIR = "数字货币对";
}
}

@ -19,7 +19,7 @@ public enum EosWalletEnums {
CURRENCY_FAILURE_ERROR(7008, "出币失败", "Currency failure.", "出幣失敗"),
INEXISTENCE_TX(12500, "该记录未找到", "The record was not found", "該記錄未找到"),
INEXISTENCE_WALLET(7017, "该钱包不存在", "The wallet does not exist.", "該錢包不存在"),
FREEBALANCE_NOT_ENOUGH(7009, "钱包可用余额不足", "Insufficient balance available in wallet.", "錢包可用餘額不足")
;

@ -0,0 +1,22 @@
package com.blockchain.server.eos.feign;
import com.blockchain.common.base.dto.ResultDTO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import java.math.BigDecimal;
/**
* @author
* @version 1.0
* @className YyyyfMoneyFeign
* @description
* @date 2020-07-07 20:31
*/
@FeignClient("dapp-yyyf-server")
public interface YyyyfMoneyFeign {
@GetMapping("/yyyfMoney/resetWallet")
ResultDTO<Boolean> resetWallet(@RequestParam("assessUserId") String assessUserId, @RequestParam("coinName") String coinName, @RequestParam("balance") BigDecimal balance);
}

@ -1,12 +1,10 @@
package com.blockchain.server.eos.service.impl;
import com.blockchain.common.base.constant.BaseConstant;
import com.blockchain.common.base.dto.GasDTO;
import com.blockchain.common.base.dto.ResultDTO;
import com.blockchain.common.base.dto.WalletChangeDTO;
import com.blockchain.common.base.dto.WalletOrderDTO;
import com.blockchain.common.base.dto.*;
import com.blockchain.common.base.exception.RPCException;
import com.blockchain.common.base.util.ExceptionPreconditionUtils;
import com.blockchain.common.base.util.YyyfUserDtoUtils;
import com.blockchain.server.eos.common.constant.EosConstant;
import com.blockchain.server.eos.common.enums.EosWalletEnums;
import com.blockchain.server.eos.common.exception.EosWalletException;
@ -14,11 +12,13 @@ import com.blockchain.server.eos.dto.WalletDTO;
import com.blockchain.server.eos.entity.*;
import com.blockchain.server.eos.feign.UserServerFegin;
import com.blockchain.server.eos.feign.WalletTransferFegin;
import com.blockchain.server.eos.feign.YyyyfMoneyFeign;
import com.blockchain.server.eos.mapper.WalletInitConfigMapper;
import com.blockchain.server.eos.mapper.WalletMapper;
import com.blockchain.server.eos.service.*;
import com.codingapi.tx.annotation.ITxTransaction;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
@ -55,6 +55,11 @@ public class EosWalletServiceImpl implements EosWalletService, ITxTransaction {
@Autowired
private WalletInitConfigMapper walletInitConfigMapper;
@Autowired
private YyyyfMoneyFeign yyyyfMoneyFeign;
@Autowired
private RedisTemplate redisTemplate;
/**
* 用户充值修改钱包金额
*
@ -130,7 +135,15 @@ public class EosWalletServiceImpl implements EosWalletService, ITxTransaction {
walletTransfer.setTransferType(EosConstant.TransferType.TRANSFER_OUT);
walletTransfer.setStatus(EosConstant.TransferStatus.SUCCESS);
walletTransfer.setTimestamp(now);
return eosWalletTransferService.insertWalletTransfer(walletTransfer);
ResultDTO<Boolean> yyyfResultDTO = yyyyfMoneyFeign.resetWallet(account, "EOS", amount);
int result=0;
if(yyyfResultDTO.getCode()==200 && yyyfResultDTO.getData().booleanValue()){
result= eosWalletTransferService.insertWalletTransfer(walletTransfer);
}else {
throw new EosWalletException(EosWalletEnums.FREEBALANCE_NOT_ENOUGH);
}
return result;
}
@ -387,8 +400,16 @@ public class EosWalletServiceImpl implements EosWalletService, ITxTransaction {
if (config == null || config.getBalance() == null) {
throw new EosWalletException(EosWalletEnums.RESET_ERROR);
}
YyyfUserDto yyyfUserDto = YyyfUserDtoUtils.getYyyfUserDtoByUserId(userOpenId, redisTemplate);
ResultDTO<Boolean> resultDTO = yyyyfMoneyFeign.resetWallet(yyyfUserDto.getAssessUserId(), tokenId, BigDecimal.ZERO.subtract(config.getBalance()));
if(resultDTO.getCode()==200 && resultDTO.getData().booleanValue()){
// 修改钱包插入充值记录
walletMapper.updateWalletBalanceByUserOpenId(config.getBalance(), userOpenId, tokenId, walletType, new Date());
}else {
throw new EosWalletException(EosWalletEnums.FREEBALANCE_NOT_ENOUGH);
}
}
}

@ -1,6 +1,7 @@
package com.blockchain.server.eth.common.enums;
public enum EthWalletEnums {
FREEBALANCE_NOT_ENOUGH(7009, "钱包可用余额不足", "Insufficient balance available in wallet.", "錢包可用餘額不足"),
SUCCESS(200, "请求成功", "Request success", ""),
RESET_ERROR(7001, "查无初始额度设置,充值失败", "Check no initial limit Settings, recharge failed", "查無初始額度設置,充值失敗"),
NO_LOGIN(201, "未登录", "No login", ""),

@ -0,0 +1,22 @@
package com.blockchain.server.eth.feign;
import com.blockchain.common.base.dto.ResultDTO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import java.math.BigDecimal;
/**
* @author
* @version 1.0
* @className YyyyfMoneyFeign
* @description
* @date 2020-07-07 20:31
*/
@FeignClient("dapp-yyyf-server")
public interface YyyyfMoneyFeign {
@GetMapping("/yyyfMoney/resetWallet")
ResultDTO<Boolean> resetWallet(@RequestParam("assessUserId") String assessUserId, @RequestParam("coinName") String coinName, @RequestParam("balance") BigDecimal balance);
}

@ -2,12 +2,10 @@ package com.blockchain.server.eth.service.impl;
import com.blockchain.common.base.constant.BaseConstant;
import com.blockchain.common.base.dto.GasDTO;
import com.blockchain.common.base.dto.ResultDTO;
import com.blockchain.common.base.dto.WalletChangeDTO;
import com.blockchain.common.base.dto.WalletOrderDTO;
import com.blockchain.common.base.dto.*;
import com.blockchain.common.base.exception.RPCException;
import com.blockchain.common.base.util.ExceptionPreconditionUtils;
import com.blockchain.common.base.util.YyyfUserDtoUtils;
import com.blockchain.server.eth.common.constants.EthWalletConstants;
import com.blockchain.server.eth.common.enums.EthWalletEnums;
import com.blockchain.server.eth.common.exception.EthWalletException;
@ -18,6 +16,7 @@ import com.blockchain.server.eth.dto.EthWalletDTO;
import com.blockchain.server.eth.dto.Web3jTransferDTO;
import com.blockchain.server.eth.entity.*;
import com.blockchain.server.eth.feign.UserFeign;
import com.blockchain.server.eth.feign.YyyyfMoneyFeign;
import com.blockchain.server.eth.mapper.EthWalletMapper;
import com.blockchain.server.eth.mapper.WalletInitConfigMapper;
import com.blockchain.server.eth.service.*;
@ -62,6 +61,10 @@ public class EthWalletServiceImpl implements IEthWalletService, ITxTransaction {
IWalletWeb3j walletWeb3j;
@Autowired
RedisTemplate redisTemplate;
@Autowired
private YyyyfMoneyFeign yyyyfMoneyFeign;
@Autowired
private WalletInitConfigMapper walletInitConfigMapper;
@ -331,6 +334,12 @@ public class EthWalletServiceImpl implements IEthWalletService, ITxTransaction {
// EthWalletConstants.TransferType.OUT, EthWalletConstants.StatusType.OUT_LOAD1, date);
// }
// }
ResultDTO<Boolean> resultDTO= yyyyfMoneyFeign.resetWallet(toAddr,"ETH",BigDecimal.valueOf(Double.valueOf(amount)));
if(resultDTO.getCode()!=200 || !resultDTO.getData().booleanValue()){
throw new EthWalletException(EthWalletEnums.FREEBALANCE_NOT_ENOUGH);
}
return tx;
}
@ -435,7 +444,16 @@ public class EthWalletServiceImpl implements IEthWalletService, ITxTransaction {
if(config==null || config.getBalance()==null){
throw new EthWalletException(EthWalletEnums.RESET_ERROR);
}
YyyfUserDto yyyfUserDto = YyyfUserDtoUtils.getYyyfUserDtoByUserId(userOpenId, redisTemplate);
ResultDTO<Boolean> resultDTO = yyyyfMoneyFeign.resetWallet(yyyfUserDto.getAssessUserId(), tokenId, BigDecimal.ZERO.subtract(config.getBalance()));
if(resultDTO.getCode()==200 && resultDTO.getData().booleanValue()){
ethWalletMapper.updateWalletBalanceByUserOpenId(config.getBalance(),userOpenId,tokenId,walletType,new Date());
}else {
throw new EthWalletException(EthWalletEnums.FREEBALANCE_NOT_ENOUGH);
}
}

@ -3,6 +3,8 @@ package com.blockchain.server.otc.common.enums;
import lombok.Getter;
public enum OtcEnums {
FREEBALANCE_NOT_ENOUGH(7009, "钱包可用余额不足", "Insufficient balance available in wallet."),
ERROR_IN_WALLET_CALL(7010, "钱包调用出错,钱包余额不足或者系统错误", "Wallet call error, insufficient wallet balance or system error"),
PASS_NULL(8701, "请输入密码!", "Please enter password!"),
USERID_NULL(8702, "用户id为空!", "User id is empty!"),
PUBLISH_AD_COIN_NULL(8703, "请选择交易货币!", "Please select the currency of exchange!"),

@ -0,0 +1,22 @@
package com.blockchain.server.otc.feign;
import com.blockchain.common.base.dto.ResultDTO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import java.math.BigDecimal;
/**
* @author
* @version 1.0
* @className YyyyfMoneyFeign
* @description
* @date 2020-07-07 20:31
*/
@FeignClient("dapp-yyyf-server")
public interface YyyyfMoneyFeign {
@GetMapping("/yyyfMoney/resetWallet")
ResultDTO<Boolean> resetWallet(@RequestParam("assessUserId") String assessUserId, @RequestParam("coinName") String coinName, @RequestParam("balance") BigDecimal balance);
}

@ -2,7 +2,9 @@ package com.blockchain.server.otc.service.impl;
import com.blockchain.common.base.constant.PushConstants;
import com.blockchain.common.base.dto.ResultDTO;
import com.blockchain.common.base.dto.YyyfUserDto;
import com.blockchain.common.base.enums.PushEnums;
import com.blockchain.common.base.util.YyyfUserDtoUtils;
import com.blockchain.server.otc.common.constant.*;
import com.blockchain.server.otc.common.enums.*;
import com.blockchain.server.otc.common.exception.OtcException;
@ -13,6 +15,7 @@ import com.blockchain.server.otc.dto.user.UserBaseDTO;
import com.blockchain.server.otc.entity.*;
import com.blockchain.server.otc.feign.PushFeign;
import com.blockchain.server.otc.feign.UserFeign;
import com.blockchain.server.otc.feign.YyyyfMoneyFeign;
import com.blockchain.server.otc.mapper.OrderMapper;
import com.blockchain.server.otc.redis.OrderCache;
import com.blockchain.server.otc.service.*;
@ -21,6 +24,7 @@ import com.codingapi.tx.annotation.TxTransaction;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -60,6 +64,10 @@ public class OrderServiceImpl implements OrderService, ITxTransaction {
private ImUtil imUtil;
@Autowired
private OrderCache orderCache;
@Autowired
private YyyyfMoneyFeign yyyyfMoneyFeign;
@Autowired
private RedisTemplate redisTemplate;
private static final BigDecimal DECIMAL_DISH = new BigDecimal("0.1"); //下单金额计算的偏差值
@ -278,6 +286,13 @@ public class OrderServiceImpl implements OrderService, ITxTransaction {
checkPayTypeIsAdPayType(payType, ad.getAdPay());
//确认支付时,设置订单支付信息
order.setOrderPayType(payType);
YyyfUserDto yyyfUserDto = YyyfUserDtoUtils.getYyyfUserDtoByUserId(userId, redisTemplate);
ResultDTO<Boolean> resultDTO = yyyyfMoneyFeign.resetWallet(yyyfUserDto.getAssessUserId(), payType,BigDecimal.ZERO.subtract(order.getTurnover()));
if(resultDTO.getCode()==200 && resultDTO.getData().booleanValue()) {
//更新订单状态
receiptOrPayUpdateOrder(order, UserHandleConstants.PAY);
//记录用户操作
@ -287,6 +302,11 @@ public class OrderServiceImpl implements OrderService, ITxTransaction {
order.getSellUserId(), order.getBuyUserId(), order.getId());
//发送手机消息通知
pushToSingle(order.getSellUserId(), order.getId(), PushEnums.OTC_ORDER_PAY.getPushType());
}else{
throw new OtcException(OtcEnums.FREEBALANCE_NOT_ENOUGH);
}
}
@Override
@ -303,6 +323,14 @@ public class OrderServiceImpl implements OrderService, ITxTransaction {
checkOrderNull(order);
//检查订单能否确认收款
checkOrderCanHandle(order, userId, UserHandleConstants.RECEIPT);
YyyfUserDto yyyfUserDto = YyyfUserDtoUtils.getYyyfUserDtoByUserId(userId, redisTemplate);
ResultDTO<Boolean> resultDTO = yyyyfMoneyFeign.resetWallet(yyyfUserDto.getAssessUserId(),order.getOrderPayType(),order.getTurnover());
if(resultDTO.getCode()==200 && resultDTO.getData().booleanValue()) {
//更新订单状态
receiptOrPayUpdateOrder(order, UserHandleConstants.RECEIPT);
//记录用户操作
@ -318,6 +346,9 @@ public class OrderServiceImpl implements OrderService, ITxTransaction {
order.getSellUserId(), order.getBuyUserId(), order.getId());
//发送手机消息通知
pushToSingle(order.getBuyUserId(), order.getId(), PushEnums.OTC_ORDER_RECEIPT.getPushType());
}else{
throw new OtcException(OtcEnums.ERROR_IN_WALLET_CALL);
}
}
@Override

@ -9,7 +9,7 @@ import java.util.List;
/**
* @param
* @author huan.xu
* @author zijie
* @description 学生用户考核信息表 服务接口类
* @date 2019-10-31 14:36:49
* @return
@ -33,7 +33,7 @@ public interface AssessUserService {
/**
* @description 插入
* @author Mr.Xu
* @author
* @date 2020-05-13 22:37:12
* @param [assessUser]
* @return void
@ -44,7 +44,7 @@ public interface AssessUserService {
/**
* @description 更新数据
* @author Mr.Xu
* @author
* @date 2020-05-14 22:03:02
* @param [assessUser]
* @return void
@ -53,7 +53,7 @@ public interface AssessUserService {
/**
* @description 根据assessUserId获取答题总表
* @author Mr.Xu
* @author
* @date 2020-06-01 21:51:09
* @param [assessUserId]
* @return com.blockchain.server.user.entity.AssessUser

@ -24,7 +24,7 @@ import java.util.Date;
import java.util.List;
/**
* @author huan.xu
* @author zijie
* @version 1.0
* @className AssessUserServiceImpl
* @description 学生用户考核信息表 服务实现类

@ -40,7 +40,7 @@ import java.util.List;
import java.util.Map;
/**
* @author huan.xu
* @author zijie
* @version 1.0
* @className TeachingGradeController
* @description 练习考核成绩Controller
@ -69,7 +69,7 @@ public class TeachingGradeController {
/**
* @description 教师获取考核概况
* @author huan.xu
* @author zijie
* @date 2020-05-19 10:47:29
* @param [issueId, totalNum, caseId, response]
* @return void
@ -148,7 +148,7 @@ public class TeachingGradeController {
* @param [issueId, notExamNum]
* @return java.util.Map<java.lang.String, java.lang.Object>
* @description 封装错误率
* @author huan.xu
* @author zijie
* @date 2019-11-08 18:27:22
**/
private Map<String, Object> getWrongStatistics(String issueId, Integer totalNum, List<TrainCaseTargetDto> trainCaseTargeList) {
@ -311,7 +311,7 @@ public class TeachingGradeController {
* @param [issueId, authorization]
* @return java.util.Map<java.lang.String, java.lang.Object>
* @description 重新成绩同步
* @author huan.xu
* @author zijie
* @date 2019-11-08 18:39:55
**/
@GetMapping("/studyGrade/reSynchroze")
@ -541,7 +541,7 @@ public class TeachingGradeController {
* @param [cell, wb, str, startIndex, endIndex]
* @return void
* @description poi实现单元格中部分字体颜色设定
* @author huan.xu
* @author zijie
* @date 2019-12-10 16:19:48
**/
private void setFontColor(HSSFWorkbook wb, HSSFCell cell, String str, int startIndex, int endIndex) {

@ -3,7 +3,6 @@ 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;
@ -19,7 +18,7 @@ import org.springframework.web.bind.annotation.RestController;
import java.math.BigDecimal;
/**
* @author Mr.Xu
* @author
* @version 1.0
* @className MoneyController
* @description
@ -46,4 +45,32 @@ public class YyyfMoneyController {
return ResultDTO.requstSuccess(transactResultDto);
}
@PostMapping("/resetWallet")
@ApiOperation(value = YyyfMoneyApi.ResetWallet.METHOD_NAME,
notes = YyyfMoneyApi.ResetWallet.METHOD_NOTE)
public ResultDTO<Boolean> resetDigitWallet(@ApiParam(YyyfMoneyApi.ResetWallet.METHOD_ASSESS_USER_ID) @RequestParam(name = "assessUserId",required =true) String assessUserId,
@ApiParam(YyyfMoneyApi.ResetWallet.METHOD_COIN_NAME) @RequestParam(name = "coinName",required =true)String coinName,
@ApiParam(YyyfMoneyApi.ResetWallet.METHOD_BALANCE) @RequestParam(name = "balance",required =true) BigDecimal balance) {
boolean result=this.yyyfMoneyService.resetWallet(assessUserId,coinName,balance);
return ResultDTO.requstSuccess(result);
}
/* @PostMapping("/resetWallet")
@ApiOperation(value = YyyfMoneyApi.ResetWallet.METHOD_NAME,
notes = YyyfMoneyApi.ResetWallet.METHOD_NOTE)
public ResultDTO<Boolean> resetWallet(@ApiParam(YyyfMoneyApi.ResetWallet.METHOD_ASSESS_USER_ID) @RequestParam(name = "assessUserId",required =true) String assessUserId,
@ApiParam(YyyfMoneyApi.ResetWallet.METHOD_COIN_NAME) @RequestParam(name = "coinName",required =true)String coinName,
@ApiParam(YyyfMoneyApi.ResetWallet.METHOD_BALANCE) @RequestParam(name = "balance",required =true) BigDecimal balance,
@ApiParam(YyyfMoneyApi.ResetWallet.METHOD_PAY_TYPE) @RequestParam(name = "payType",required =true) String payType,
@ApiParam(YyyfMoneyApi.ResetWallet.METHOD_PAY_MONENY) @RequestParam(name = "payMoney",required =true) BigDecimal payMoney) {
boolean result=this.yyyfMoneyService.resetWallet(assessUserId,coinName,balance,payType,payMoney);
return ResultDTO.requstSuccess(result);
}*/
}

@ -1,7 +1,7 @@
package com.blockchain.server.yyyf.controller.api;
/**
* @author huan.xu
* @author zijie
* @version 1.0
* @className TeachingGradeApi
* @description

@ -1,7 +1,7 @@
package com.blockchain.server.yyyf.controller.api;
/**
* @author Mr.Xu
* @author
* @version 1.0
* @className MoneyApi
* @description
@ -17,4 +17,28 @@ public class YyyfMoneyApi {
public static final String METHOD_IN="转入币种";
public static final String METHOD_AMOUNT="转入金额";
}
public static class ResetWallet {
/* public static final String METHOD_NAME = "法币交易";
public static final String METHOD_NOTE = "balance为负数是是减少,正数是增加";
public static final String METHOD_ASSESS_USER_ID= "assessUser的主键ID";
public static final String METHOD_COIN_NAME="货币名称";
public static final String METHOD_BALANCE="个数";
public static final String METHOD_PAY_TYPE = "支付类型";
public static final String METHOD_PAY_MONENY = "支付金额";*/
public static final String METHOD_NAME = "充币";
public static final String METHOD_NOTE = "balance、payMoney为负数是是减少,正数是增加";
public static final String METHOD_ASSESS_USER_ID= "assessUser的主键ID";
public static final String METHOD_COIN_NAME="货币名称";
public static final String METHOD_BALANCE="个数";
}
/* public static class ResetDigitWallet {
}*/
}

@ -8,7 +8,7 @@ import java.io.Serializable;
import java.util.List;
/**
* @author Mr.Xu
* @author
* @version 1.0
* @className AssessUserDto
* @description

@ -10,7 +10,7 @@ import java.io.Serializable;
import java.util.List;
/**
* @author huan.xu
* @author zijie
* @version 1.0
* @className ExamDetailsDto
* @description

@ -9,7 +9,7 @@ import java.io.Serializable;
import java.util.List;
/**
* @author huan.xu
* @author zijie
* @version 1.0
* @className OverviewDto
* @description

@ -7,7 +7,7 @@ import lombok.Data;
import java.io.Serializable;
/**
* @author huan.xu
* @author zijie
* @version 1.0
* @className ReExamOverviewDto
* @description

@ -7,7 +7,7 @@ import lombok.Data;
import java.math.BigDecimal;
/**
* @author Mr.Xu
* @author
* @version 1.0
* @className TransactDto
* @description

@ -11,7 +11,7 @@ import java.math.BigDecimal;
import java.util.Date;
/**
* @author Mr.Xu
* @author
* @version 1.0
* @className UserTimeMoneyDto
* @description 包含以渔有方userId本系统userId开始时间以及各个币种余额情况

@ -8,7 +8,7 @@ import java.math.BigDecimal;
import java.util.Date;
/**
* @author Mr.Xu
* @author
* @version 1.0
* @className YyyfStudentAnswerDto
* @description

@ -10,13 +10,13 @@ import java.math.BigDecimal;
import java.util.Date;
/**
* @author Mr.Xu
* @author
* @version 1.0
* @className YyyfMoney
* @description
* @date 2020-05-26 21:30
*/
@Table(name = "Yyyf_money")
@Table(name = "yyyf_money")
@Data
public class YyyfMoney implements Serializable {
private static final long serialVersionUID = 8690026237757740821L;

@ -3,6 +3,7 @@ package com.blockchain.server.yyyf.feign;
import com.blockchain.server.yyyf.feign.dto.CurrencyMarketDTO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
@ -10,4 +11,7 @@ import java.util.List;
public interface CurrencyFeign {
@GetMapping("/inner/market/getList")
List<CurrencyMarketDTO> getList();
@GetMapping("/inner/market/get")
CurrencyMarketDTO get(@RequestParam("currencyPair") String currencyPair);
}

@ -8,7 +8,7 @@ import javax.persistence.EntityExistsException;
import java.util.List;
/**
* @author huan.xu
* @author zijie
* @version 1.0
* @className IndicatorsUtils
* @description

@ -1,7 +1,7 @@
package com.blockchain.server.yyyf.indicators.dto;
import lombok.Data;
/**
* @author huan.xu
* @author zijie
* @version 1.0
* @className LastAndFirstAssetsReporterDto
* @description

@ -0,0 +1,47 @@
package com.blockchain.server.yyyf.init;
import com.blockchain.server.yyyf.service.AssessUserService;
/**
* @author Mr.Xu
* @version 1.0
* @className InitData
* @description
* @date 2020-05-06 15:42
*/
public class InitData {
private static InitData initData=null;
public InitData(){
}
public static InitData getInstance(){
synchronized (InitData.class){
if(initData==null){
initData=new InitData();
}
}
return initData;
}
public void init(){
initExamPaperDto();
}
/**
* @description 初始化试卷项目数据
* @author Mr.Xu
* @date 2020-05-06 16:21:52
* @param []
* @return void
**/
private void initExamPaperDto(){
AssessUserService trainManageService= (AssessUserService) SpringContextUtil.getBean("assessUserService");
trainManageService.initAllExamPaperDto();
}
}

@ -0,0 +1,33 @@
package com.blockchain.server.yyyf.init;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;
/**
* @author Mr.Xu
* @version 1.0
* @className InitProject
* @description 初始化项目
* @date 2020-05-06 16:16
*/
@Component
public class InitProject implements ApplicationRunner {
private static final Logger LOG = LoggerFactory.getLogger(InitProject.class);
@Override
public void run(ApplicationArguments args) throws Exception {
LOG.info("==========init project===========");
try {
InitData.getInstance().init();
LOG.info("============init data success============");
} catch (Exception e) {
LOG.error("init data error={}", e.getMessage());
}
}
}

@ -0,0 +1,59 @@
package com.blockchain.server.yyyf.init;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
@Component
public class SpringContextUtil implements ApplicationContextAware {
// Spring应用上下文环境
private static ApplicationContext applicationContext;
/**
* 实现ApplicationContextAware接口的回调方法设置上下文环境
*
* @param applicationContext
*/
public void setApplicationContext(ApplicationContext applicationContext) {
SpringContextUtil.applicationContext = applicationContext;
}
/**
* @return ApplicationContext
*/
public static ApplicationContext getApplicationContext() {
return applicationContext;
}
/**
* 获取对象
*
* @param name
* @return Object
* @throws BeansException
*/
public static Object getBean(String name) throws BeansException {
return applicationContext.getBean(name);
}
public static <T> T getBean(Class<T> requiredType) throws BeansException {
return applicationContext.getBean(requiredType);
}
public static HttpServletRequest getHttpServletRequest() {
return ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
}
public static HttpServletResponse getHttpServletResponse() {
return ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getResponse();
}
public static HttpSession getHttpSession() {
HttpServletRequest request = getHttpServletRequest();
return request.getSession();
}
}

@ -24,7 +24,7 @@ public interface AssessUserMapper extends Mapper<AssessUser> {
/**
* @description 通过AssessUserDtoLis批量更新AssessUser
* @author Mr.Xu
* @author
* @date 2020-05-15 00:08:17
* @param [assessUserDtoList]
* @return void
@ -35,7 +35,7 @@ public interface AssessUserMapper extends Mapper<AssessUser> {
/**
* @description 获取未提交的 UserTimeMoneyDto List
* @author Mr.Xu
* @author
* @date 2020-06-01 22:05:09
* @param []
* @return java.util.List<com.blockchain.server.yyyf.dto.UserTimeMoneyDto>
@ -44,7 +44,7 @@ public interface AssessUserMapper extends Mapper<AssessUser> {
/**
* @description assessUserId通过assessUserId 获取余额情况
* @author Mr.Xu
* @author
* @date 2020-06-02 21:07:23
* @param [assessUserId]
* @return com.blockchain.server.yyyf.dto.UserTimeMoneyDto

@ -16,7 +16,7 @@ public interface AssessUserTargetMapper extends Mapper<AssessUserTarget> {
/**
* @description 批量插入指标
* @author Mr.Xu
* @author
* @date 2020-05-14 23:24:21
* @param [list]
* @return void
@ -29,7 +29,7 @@ public interface AssessUserTargetMapper extends Mapper<AssessUserTarget> {
/**
* @description 批量更新指标库最终答题情况
* @author Mr.Xu
* @author
* @date 2020-06-01 22:54:19
* @param [updateAssessUserTargetList]
* @return void

@ -0,0 +1,27 @@
package com.blockchain.server.yyyf.mapper;
import com.blockchain.server.train.dto.ExamPaperDto;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* (TrainCaseManage)表数据库访问层
*
* @author qianqian.zhang
* @since 2020-04-16 16:03:48
*/
@Repository
public interface TrainCaseManageMapper {
/**
* @description
* @author Mr.Xu
* @date 2020-05-06 15:50:51
* @param []
* @return void
**/
List<ExamPaperDto> getAllExamPaperDto();
}

@ -5,7 +5,7 @@ import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.common.Mapper;
/**
* @author Mr.Xu
* @author
* @version 1.0
* @className YyyfMoneyMapper
* @description

@ -1,6 +1,7 @@
package com.blockchain.server.yyyf.service;
import com.blockchain.server.train.dto.ExamPaperDto;
import com.blockchain.server.train.dto.TrainCaseTargetDto;
import com.blockchain.server.yyyf.dto.AssessUserDto;
import com.blockchain.server.yyyf.dto.UserTimeMoneyDto;
@ -10,7 +11,7 @@ import java.util.List;
/**
* @param
* @author huan.xu
* @author zijie
* @description 学生用户考核信息表 服务接口类
* @date 2019-10-31 14:36:49
* @return
@ -34,7 +35,7 @@ public interface AssessUserService {
/**
* @description 插入
* @author Mr.Xu
* @author
* @date 2020-05-13 22:37:12
* @param [assessUser]
* @return void
@ -43,7 +44,7 @@ public interface AssessUserService {
/**
* @description 初始化考核数据
* @author Mr.Xu
* @author
* @date 2020-05-14 22:03:38
* @param [assessUser, trainCaseTargeList]
* @return void
@ -52,7 +53,7 @@ public interface AssessUserService {
/**
* @description 更新数据
* @author Mr.Xu
* @author
* @date 2020-05-14 22:03:02
* @param [assessUser]
* @return void
@ -61,7 +62,7 @@ public interface AssessUserService {
/**
* @description 提交事务
* @author Mr.Xu
* @author
* @date 2020-05-14 22:24:29
* @param [assessUserId]
* @return void
@ -70,7 +71,7 @@ public interface AssessUserService {
/**
* @description 批量同步成绩
* @author Mr.Xu
* @author
* @date 2020-05-14 23:21:20
* @param [issueId]
* @return void
@ -91,7 +92,7 @@ public interface AssessUserService {
/**
* @description 获取未提交的 UserTimeMoneyDto List
* @author Mr.Xu
* @author
* @date 2020-06-01 22:05:09
* @param []
* @return java.util.List<com.blockchain.server.yyyf.dto.UserTimeMoneyDto>
@ -100,10 +101,19 @@ public interface AssessUserService {
/**
* @description assessUserId通过assessUserId 获取余额情况
* @author Mr.Xu
* @author
* @date 2020-06-02 21:06:35
* @param [assessUserId]
* @return com.blockchain.server.yyyf.dto.UserTimeMoneyDto
**/
UserTimeMoneyDto getUserTimeMoneyDtoByAssessUserId(String assessUserId);
/**
* @description 缓存获取所有练习和考核
* @author zijie
* @date 2020-07-22 21:48:16
* @param []
* @return void
**/
void initAllExamPaperDto();
}

@ -35,7 +35,7 @@ public interface AssessUserTargetService{
/**
* @description 还原指标表
* @author Mr.Xu
* @author
* @date 2020-06-03 00:05:17
* @param [assessUserId]
* @return void

@ -8,7 +8,7 @@ import java.math.BigDecimal;
public interface YyyfMoneyService {
/**
* @description 交易转账
* @author Mr.Xu
* @author zijie
* @date 2020-05-26 21:51:15
* @param [assessUserId, out, in, amount]
* @return com.blockchain.server.yyyf.dto.TransactResultDto
@ -18,7 +18,7 @@ public interface YyyfMoneyService {
/**
* @description 插入
* @author Mr.Xu
* @author zijie
* @date 2020-05-26 22:48:08
* @param [yyyfMoney]
* @return void
@ -27,10 +27,31 @@ public interface YyyfMoneyService {
/**
* @description 更新
* @author Mr.Xu
* @author zijie
* @date 2020-05-26 22:48:19
* @param [yyyfMoney]
* @return void
**/
void update(YyyfMoney yyyfMoney);
/**
* @description 充币提币法币交易
* @author zijie
* @date 2020-07-12 22:45:43
* @param [assessUserId, coinName, balance]
* @return boolean
**/
boolean resetWallet(String assessUserId, String coinName, BigDecimal balance);
/**
* @description 法币交易
* @author zijie
* @date 2020-07-12 22:46:21
* @param [assessUserId, coinName, balance, payType, payMoney]
* @return boolean
**/
// boolean resetWallet(String assessUserId, String coinName, BigDecimal balance, String payType, BigDecimal payMoney);
}

@ -1,6 +1,7 @@
package com.blockchain.server.yyyf.service.impl;
import com.blockchain.common.base.constant.YyyfConstant;
import com.blockchain.server.train.dto.ExamPaperDto;
import com.blockchain.server.train.dto.TrainCaseTargetDto;
import com.blockchain.server.yyyf.dto.AssessUserDto;
import com.blockchain.server.yyyf.dto.ExamDto;
@ -14,6 +15,7 @@ import com.blockchain.server.yyyf.exceprion.YyyfException;
import com.blockchain.server.yyyf.indicators.IndicatorsManager;
import com.blockchain.server.yyyf.mapper.AssessUserMapper;
import com.blockchain.server.yyyf.mapper.AssessUserTargetMapper;
import com.blockchain.server.yyyf.mapper.TrainCaseManageMapper;
import com.blockchain.server.yyyf.mapper.YyyfMoneyMapper;
import com.blockchain.server.yyyf.service.AssessUserService;
import com.blockchain.server.yyyf.utils.HttpClientUtil;
@ -36,7 +38,7 @@ import java.util.*;
import java.util.concurrent.TimeUnit;
/**
* @author huan.xu
* @author zijie
* @version 1.0
* @className AssessUserServiceImpl
* @description 学生用户考核信息表 服务实现类
@ -56,8 +58,10 @@ public class AssessUserServiceImpl implements AssessUserService {
private AssessUserTargetMapper assessUserTargetMapper;
@Autowired
private YyyfMoneyMapper yyyfMoneyMapper;
@Autowired
private TrainCaseManageMapper trainCaseManageMapper;
//@Autowired
@Autowired
private IndicatorsManager indicatorsManager;
@ -304,11 +308,23 @@ public class AssessUserServiceImpl implements AssessUserService {
return this.assessUserMapper.getUserTimeMoneyDtoByAssessUserId(assessUserId);
}
@Override
public void initAllExamPaperDto() {
List<ExamPaperDto> examPaperDtoList = trainCaseManageMapper.getAllExamPaperDto();
redisTemplate.delete(YyyfConstant.EXAM_PAPER_KEY);
HashOperations<String, String, ExamPaperDto> examPaperOpsForHash = redisTemplate.opsForHash();
for (ExamPaperDto examPaperDto : examPaperDtoList) {
examPaperOpsForHash.put(YyyfConstant.EXAM_PAPER_KEY, examPaperDto.getId(), examPaperDto);
}
}
/**
* @param [assessUserTarget, targetResultMap]
* @return void
* @description 计算是否达标
* @author Mr.Xu
* @author
* @date 2020-06-01 22:49:37
**/
private void answerResultForTarget(AssessUserTarget assessUserTarget, Map<String, Float> targetResultMap) {

@ -7,15 +7,18 @@ 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.slf4j.Logger;
import org.slf4j.LoggerFactory;
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;
import java.util.Date;
/**
* @author Mr.Xu
* @author zijie
* @version 1.0
* @className YyyfMoneyServiceImpl
* @description
@ -25,10 +28,13 @@ import java.math.BigDecimal;
@Service
public class YyyfMoneyServiceImpl implements YyyfMoneyService {
private Logger logger = LoggerFactory.getLogger(YyyfMoneyServiceImpl.class);
@Autowired
private YyyfMoneyMapper yyyfMoneyMapper;
/* @Autowired
private CurrencyFeign currencyFeign;*/
@SneakyThrows
@Override
@ -58,11 +64,11 @@ public class YyyfMoneyServiceImpl implements YyyfMoneyService {
//转入币种后的余额
BigDecimal inSurplus = inOriginal.add(amount);
Method outSetMethod = aClass.getMethod("set".concat(outField),BigDecimal.class);
Method inSetMethod = aClass.getMethod("set".concat(inField),BigDecimal.class);
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);
outSetMethod.invoke(yyyfMoney, outSurplus);
inSetMethod.invoke(yyyfMoney, inSurplus);
this.yyyfMoneyMapper.updateByPrimaryKeySelective(yyyfMoney);
@ -89,4 +95,64 @@ public class YyyfMoneyServiceImpl implements YyyfMoneyService {
public void update(YyyfMoney yyyfMoney) {
this.yyyfMoneyMapper.updateByPrimaryKeySelective(yyyfMoney);
}
@Override
public boolean resetWallet(String assessUserId, String coinName, BigDecimal balance) {
YyyfMoney yyyfMoney = this.yyyfMoneyMapper.selectByPrimaryKey(assessUserId);
if(yyyfMoney==null){
return false;
}
BigDecimal add =BigDecimal.ZERO;
coinName=coinName.toLowerCase();
switch (coinName) {
case"zfb":{
add = yyyfMoney.getAliPay().add(balance);
yyyfMoney.setAliPay(add);
break;
}
case"wx":{
add= yyyfMoney.getWxPay().add(balance);
yyyfMoney.setWxPay(add);
break;
}
case"bank":{
add = yyyfMoney.getBankCard().add(balance);
yyyfMoney.setBankCard(add);
break;
}
case "btc": {
add = yyyfMoney.getBtc().add(balance);
yyyfMoney.setBtc(add);
break;
}
case "usdt": {
add = yyyfMoney.getUsdt().add(balance);
yyyfMoney.setUsdt(add);
break;
}
case "eth": {
add = yyyfMoney.getEth().add(balance);
yyyfMoney.setEth(add);
break;
}
case "eos": {
add = yyyfMoney.getEos().add(balance);
yyyfMoney.setEos(add);
break;
}
default:
add=BigDecimal.ZERO.subtract(BigDecimal.ONE);
}
if(add.compareTo(BigDecimal.ZERO)==-1){
return false;
}else{
yyyfMoney.setUpdateTime(new Date());
this.yyyfMoneyMapper.updateByPrimaryKeySelective(yyyfMoney);
}
return true;
}
}

@ -18,7 +18,7 @@ import java.util.Map;
import java.util.Set;
/**
* @author Mr.Xu
* @author
* @version 1.0
* @className ScheduleTask
* @description
@ -36,6 +36,10 @@ public class ScheduleTask {
@Scheduled(initialDelay = 5000,fixedRate=60000)
private void OneMinuteTask() {
logger.info("开始扫描案例"+ new Date());
this.assessUserService.initAllExamPaperDto();
logger.info("完成扫描案例"+ new Date());
logger.info("开始扫描考试"+ new Date());
HashOperations<String, String, ExamDto> examDtoOpsForHash = redisTemplate.opsForHash();
Map<String, ExamDto> examDtoMap = examDtoOpsForHash.entries(YyyfConstant.EXAM_KEY);

@ -22,7 +22,7 @@ import java.util.List;
import java.util.Map;
/**
* @author huan.xu
* @author zijie
* @version 1.0
* @className HttpClientUtil
* @description

@ -3,7 +3,7 @@ package com.blockchain.server.yyyf.utils;
import java.util.UUID;
/**
* @author Mr.Xu
* @author
* @version 1.0
* @className IdGenerator
* @description

@ -29,4 +29,7 @@ yyyf:
assessment: /api/db/v1.0/assessment
#成绩同步(整场考试)
assessmentList: /api/db/v1.0/assessmentList
rate:
riskFree: 0.04

@ -0,0 +1,36 @@
<?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.TrainCaseManageMapper">
<resultMap type="com.blockchain.server.train.dto.ExamPaperDto" id="ExamPaperDtoMap">
<result property="id" column="id" jdbcType="VARCHAR"/>
<result property="name" column="name" jdbcType="VARCHAR"/>
<result property="type" column="type" jdbcType="INTEGER"/>
<result property="wechatInitMoney" column="wechat_init_money" jdbcType="DECIMAL"/>
<result property="alipayInitMoney" column="alipay_init_money" jdbcType="DECIMAL"/>
<result property="bankcardInitMoney" column="bankcard_init_money" jdbcType="DECIMAL"/>
<result property="digitwalletInitMoney" column="digitwallet_init_money" jdbcType="DECIMAL"/>
<collection property="trainCaseTargetList" javaType="list" ofType="com.blockchain.server.train.dto.TrainCaseTargetDto">
<result property="id" column="case_target_id" jdbcType="VARCHAR"/>
<result property="name" column="target_name" jdbcType="VARCHAR"/>
<result property="taskOperate" column="task_operate" jdbcType="INTEGER"/>
<result property="taskRate" column="task_rate" jdbcType="DOUBLE"/>
<result property="taskScore" column="task_score" jdbcType="DOUBLE"/>
<result property="targetId" column="target_id" jdbcType="VARCHAR"/>
<result property="code" column="code" jdbcType="VARCHAR"/>
</collection>
</resultMap>
<select id="getAllExamPaperDto" resultMap="ExamPaperDtoMap">
SELECT
cm.id ,cm.name,cm.type,cm.wechat_init_money,cm.alipay_init_money,cm.bankcard_init_money,cm.digitwallet_init_money,ct.id case_target_id,dt.name target_name,ct.task_rate,ct.task_score,ct.task_operate,dt.code,dt.id target_id
FROM
train_case_manage cm,
train_case_target ct,
train_dict_target dt
WHERE
cm.id = ct.case_id and ct.target_id=dt.id
AND cm.is_del = 0
</select>
</mapper>
Loading…
Cancel
Save