Compare commits

...

25 Commits

Author SHA1 Message Date
huan.xu 75cd1faf5e 修复第一次进入 ,系统自动注册失败的问题 4 years ago
huan.xu e490449c58 修复考试时间过长的问题,duration改为Long 4 years ago
huan.xu 2bff674480 修复提交报错的bug 4 years ago
huan.xu 5417d726d7 Merge branch 'master' of https://git.czcyedu.com/zhixinlian/client-server 4 years ago
fengyu.wang a8e11b590d feign update 4 years ago
fengyu.wang bfb1a0cc76 commit 4 years ago
huan.xu 332af212ff 修复历史成绩查看bug 4 years ago
huan.xu 23927365bc 修复bug 4 years ago
fengyu.wang 96691ea013 thread pool update 4 years ago
fengyu.wang 26f71afade 做市商 bug fix 4 years ago
fengyu.wang 3306fb2473 做市商 bug fix 4 years ago
huan.xu 9467cc4823 修复登陆后未将相关信息放入缓存的bug 4 years ago
fengyu.wang cb783c3040 做市商 出售 4 years ago
huan.xu a36cb7c7b5 修复资金密码设置问题 4 years ago
fengyu.wang e8824d8b65 Merge branch 'EP-Indicator' of zhixinlian/client-server into master 4 years ago
fengyu.wang 83e50a26a3 gateway support 4 years ago
fengyu.wang 07a37581ba bug fix 4 years ago
fengyu.wang 4f5b91fa82 Merge branch 'EP-Indicator' of zhixinlian/client-server into master 4 years ago
fengyu.wang 6e43b3feb8 bug fix 4 years ago
unclekh 4914c57520 修复产品提的bug(全景显示、返回、资金管理显示0) 4 years ago
unclekh 0961639ed1 处理线上登录报错 4 years ago
unclekh fcc3fdaa84 实现提币、充币、法币交易 4 years ago
unclekh aeec182834 充币、法币交易后台实现 4 years ago
unclekh 2298799078 更改注释 4 years ago
unclekh 7c0c2cacb8 更改注释 4 years ago
  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. 22
      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. 4
      blockchain-server/blockchain-server-currency/src/main/java/com/blockchain/server/currency/Scheduling/CurrencyMarketScheduling.java
  10. 13
      blockchain-server/blockchain-server-currency/src/main/java/com/blockchain/server/currency/Scheduling/HuobiMarketScheduling.java
  11. 9
      blockchain-server/blockchain-server-currency/src/main/java/com/blockchain/server/currency/inner/CurrencyMarketInnerController.java
  12. 6
      blockchain-server/blockchain-server-currency/src/main/java/com/blockchain/server/currency/inner/api/CurrencyMarketInnerApi.java
  13. 5
      blockchain-server/blockchain-server-currency/src/main/java/com/blockchain/server/currency/redis/MarketKCache.java
  14. 54
      blockchain-server/blockchain-server-currency/src/main/java/com/blockchain/server/currency/service/impl/CurrencyMarketServiceImpl.java
  15. 2
      blockchain-server/blockchain-server-eos/src/main/java/com/blockchain/server/eos/common/enums/EosWalletEnums.java
  16. 22
      blockchain-server/blockchain-server-eos/src/main/java/com/blockchain/server/eos/feign/YyyyfMoneyFeign.java
  17. 35
      blockchain-server/blockchain-server-eos/src/main/java/com/blockchain/server/eos/service/impl/EosWalletServiceImpl.java
  18. 1
      blockchain-server/blockchain-server-eth/src/main/java/com/blockchain/server/eth/common/enums/EthWalletEnums.java
  19. 16
      blockchain-server/blockchain-server-eth/src/main/java/com/blockchain/server/eth/controller/EthWalletController.java
  20. 22
      blockchain-server/blockchain-server-eth/src/main/java/com/blockchain/server/eth/feign/YyyyfMoneyFeign.java
  21. 33
      blockchain-server/blockchain-server-eth/src/main/java/com/blockchain/server/eth/service/impl/EthWalletServiceImpl.java
  22. 21
      blockchain-server/blockchain-server-otc/src/main/java/com/blockchain/server/otc/common/config/ApplicationConfig.java
  23. 2
      blockchain-server/blockchain-server-otc/src/main/java/com/blockchain/server/otc/common/enums/OtcEnums.java
  24. 1
      blockchain-server/blockchain-server-otc/src/main/java/com/blockchain/server/otc/dto/ad/PublishAdParamDTO.java
  25. 4
      blockchain-server/blockchain-server-otc/src/main/java/com/blockchain/server/otc/entity/Ad.java
  26. 22
      blockchain-server/blockchain-server-otc/src/main/java/com/blockchain/server/otc/feign/YyyyfMoneyFeign.java
  27. 40
      blockchain-server/blockchain-server-otc/src/main/java/com/blockchain/server/otc/service/impl/AdServiceImpl.java
  28. 119
      blockchain-server/blockchain-server-otc/src/main/java/com/blockchain/server/otc/service/impl/OrderServiceImpl.java
  29. 28
      blockchain-server/blockchain-server-otc/src/main/java/com/blockchain/server/otc/service/impl/UserPayInfoServiceImpl.java
  30. 4
      blockchain-server/blockchain-server-user/src/main/java/com/blockchain/server/user/controller/LoginController.java
  31. 2
      blockchain-server/blockchain-server-user/src/main/java/com/blockchain/server/user/entity/AssessUser.java
  32. 8
      blockchain-server/blockchain-server-user/src/main/java/com/blockchain/server/user/service/AssessUserService.java
  33. 2
      blockchain-server/blockchain-server-user/src/main/java/com/blockchain/server/user/service/impl/AssessUserServiceImpl.java
  34. 10
      blockchain-server/blockchain-server-user/src/main/java/com/blockchain/server/user/service/impl/UserMainServiceImpl.java
  35. 52
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/LoginController.java
  36. 12
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/TeachingGradeController.java
  37. 37
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/YyyfMoneyController.java
  38. 2
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/api/TeachingGradeApi.java
  39. 26
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/api/YyyfMoneyApi.java
  40. 2
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/dto/AssessUserDto.java
  41. 2
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/dto/ExamDetailsDto.java
  42. 2
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/dto/OverviewDto.java
  43. 2
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/dto/ReExamOverviewDto.java
  44. 2
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/dto/TransactResultDto.java
  45. 2
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/dto/UserTimeMoneyDto.java
  46. 4
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/dto/YyyfStudentAnswerDto.java
  47. 2
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/entity/AssessUser.java
  48. 4
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/entity/YyyfMoney.java
  49. 4
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/feign/BtcFeign.java
  50. 4
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/feign/CurrencyFeign.java
  51. 3
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/feign/EosFeign.java
  52. 2
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/indicators/IndicatorsUtils.java
  53. 2
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/indicators/dto/LastAndFirstAssetsDto.java
  54. 47
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/init/InitData.java
  55. 33
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/init/InitProject.java
  56. 59
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/init/SpringContextUtil.java
  57. 13
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/mapper/AssessUserMapper.java
  58. 4
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/mapper/AssessUserTargetMapper.java
  59. 27
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/mapper/TrainCaseManageMapper.java
  60. 2
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/mapper/YyyfMoneyMapper.java
  61. 34
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/AssessUserService.java
  62. 2
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/AssessUserTargetService.java
  63. 27
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/YyyfMoneyService.java
  64. 58
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/impl/AssessUserServiceImpl.java
  65. 76
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/impl/YyyfMoneyServiceImpl.java
  66. 6
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/task/ScheduleTask.java
  67. 2
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/utils/HttpClientUtil.java
  68. 2
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/utils/IdGenerator.java
  69. 8
      blockchain-server/blockchain-server-yyyf/src/main/resources/bootstrap.yml
  70. 6
      blockchain-server/blockchain-server-yyyf/src/main/resources/mapper/AssessUserMapper.xml
  71. 6
      blockchain-server/blockchain-server-yyyf/src/main/resources/mapper/AssetsReporterMapper.xml
  72. 36
      blockchain-server/blockchain-server-yyyf/src/main/resources/mapper/TrainCaseManageMapper.xml
  73. 7
      pom.xml
  74. 1
      spring-cloud/pom.xml
  75. 2
      spring-cloud/spring-cloud-config/src/main/resources/properties/dbconf-dev.yml
  76. 2
      spring-cloud/spring-cloud-config/src/main/resources/properties/txconf-dev.yml
  77. 41
      spring-cloud/spring-cloud-gateway/pom.xml
  78. 14
      spring-cloud/spring-cloud-gateway/src/main/java/com/blockchain/spring/cloud/gateway/GatewayApplication.java
  79. 82
      spring-cloud/spring-cloud-gateway/src/main/resources/application.yml

@ -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);
}
btcWalletMapper.updateWalletBalanceByUserOpenId(config.getBalance(), userOpenId, tokenId, walletType, new Date());
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}

@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
import com.blockchain.server.currency.common.constant.BaseCoinEnums;
import com.blockchain.server.currency.common.constant.RatesEnums;
import com.blockchain.server.currency.redis.MarketLegalCache;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.beans.factory.annotation.Value;
@ -15,6 +16,7 @@ import org.springframework.web.client.RestTemplate;
import java.util.List;
import java.util.Map;
@Slf4j
@Component
@Configurable
@EnableScheduling
@ -37,7 +39,7 @@ public class CurrencyMarketScheduling {
try {
setLegalMarket();
} catch (Exception e) {
// e.printStackTrace();
log.error("CurrencyMarketScheduling.getCurrencyMarket: get currency market error", e);
}
}

@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
import com.blockchain.common.base.util.HttpUtilManager;
import com.blockchain.server.currency.dto.CurrencyMarketDTO;
import com.blockchain.server.currency.service.CurrencyMarketService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.beans.factory.annotation.Value;
@ -19,6 +20,7 @@ import java.util.concurrent.Executors;
@Component
@Configurable
@EnableScheduling
@Slf4j
public class HuobiMarketScheduling {
@Autowired
@ -45,8 +47,12 @@ public class HuobiMarketScheduling {
private void setHuobiMarket() {
List<List> currencys = JSONObject.parseArray(huobiCurrencys,List.class);
for (List data : currencys){
saveMarket(getHuobiMarket(huobiUrl + data.get(0).toString()),
data.get(1).toString(),data.get(2).toString());
try {
saveMarket(getHuobiMarket(huobiUrl + data.get(0).toString()),
data.get(1).toString(),data.get(2).toString());
} catch (Exception e) {
log.error("HuobiMarketScheduling.setHuobiMarket: save market error, data={}", data, e);
}
}
}
@ -60,13 +66,14 @@ public class HuobiMarketScheduling {
CurrencyMarketDTO now = currencyMarketService.get(coinName + "-" + unitName);
for (JSONObject obj : list) {
Long timestamp = Long.parseLong(obj.get("ts").toString());
if(timestamp >= now.getTimestamp()) {
if(now == null || timestamp >= now.getTimestamp()) {
List<JSONObject> data = (List<JSONObject>)obj.get("data");
currencyMarketService.save(coinName, unitName,
new BigDecimal(data.get(0).get("price").toString()),
new BigDecimal(data.get(0).get("amount").toString()),
timestamp,data.get(0).get("direction").toString().toUpperCase());
} else {
log.warn("HuobiMarketScheduling.saveMarket: save market ignore");
break;
}
}

@ -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 = "数字货币对";
}
}

@ -51,8 +51,9 @@ public class MarketKCache {
}
public void setMarketKListCache(SortedMap<String,CurrencyMarketKDTO> map, String currencyPair, String timeType, int timeNumber){
redisTemplate.opsForValue().set(MARKET_LIST_CACHE + currencyPair + ":" + timeNumber + timeType
,map);
if (map != null && !map.isEmpty()) {
redisTemplate.opsForValue().set(MARKET_LIST_CACHE + currencyPair + ":" + timeNumber + timeType, map);
}
}
public SortedMap<String,CurrencyMarketKDTO> getMarketKListCache(String currencyPair, String timeType, int timeNumber){

@ -21,8 +21,10 @@ import com.blockchain.server.currency.redis.MarketLegalCache;
import com.blockchain.server.currency.service.CurrencyMarketService;
import com.blockchain.server.currency.service.CurrencyPairService;
import com.blockchain.server.currency.websocket.WebSocketSendMsgUtils;
import lombok.extern.slf4j.Slf4j;
import org.redisson.api.RedissonClient;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.simp.SimpMessagingTemplate;
import org.springframework.stereotype.Service;
@ -32,6 +34,7 @@ import java.util.*;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@Slf4j
@Service
public class CurrencyMarketServiceImpl implements CurrencyMarketService {
@ -95,24 +98,30 @@ public class CurrencyMarketServiceImpl implements CurrencyMarketService {
*/
@Override
public CurrencyMarketDTO save(String coinName, String unitName, BigDecimal amount, BigDecimal total, Long timestamp, String tradingType) {
String currencyPair = coinName + "-" + unitName;
//检测币对是否合法
checkCurrency(currencyPair);
CurrencyMarket currencyMarket = new CurrencyMarket();
currencyMarket.setCurrencyPair(currencyPair);
currencyMarket.setTotal(total);
currencyMarket.setAmount(amount);
currencyMarket.setTimestamp(timestamp);
//保存新数据
save(currencyMarket);
CurrencyMarketDTO dto = new CurrencyMarketDTO();
BeanUtils.copyProperties(currencyMarket, dto);
//发送历史成交记录信息
sendHistoryMsg(dto, tradingType);
//添加缓存数据,发送行情变动信息
setMarketCache(dto);
return dto;
try {
String currencyPair = coinName + "-" + unitName;
//检测币对是否合法
checkCurrency(currencyPair);
CurrencyMarket currencyMarket = new CurrencyMarket();
currencyMarket.setCurrencyPair(currencyPair);
currencyMarket.setTotal(total);
currencyMarket.setAmount(amount);
currencyMarket.setTimestamp(timestamp);
//保存新数据
save(currencyMarket);
CurrencyMarketDTO dto = new CurrencyMarketDTO();
BeanUtils.copyProperties(currencyMarket, dto);
//发送历史成交记录信息
sendHistoryMsg(dto, tradingType);
//添加缓存数据,发送行情变动信息
setMarketCache(dto);
return dto;
} catch (BeansException e) {
log.error("CurrencyMarketServiceImpl.save: save error, coinName={}, unitName={}, amount={}, total={}, timestamp={}, tradingType={}",
coinName, unitName, amount, total, timestamp, tradingType);
return null;
}
}
@Override
@ -122,6 +131,9 @@ public class CurrencyMarketServiceImpl implements CurrencyMarketService {
//获取一天的K线行情
SortedMap<String, CurrencyMarketKDTO> map = getOneDayMarketK(currencyPair,
MarketKTypeEnums.ONEDAY.getTimeType(), MarketKTypeEnums.ONEDAY.getTimeNumber());
if (map == null || map.isEmpty()) {
return null;
}
CurrencyMarketDTO dto = getMarketInfo(currencyPair, map);
return dto;
}
@ -432,9 +444,9 @@ public class CurrencyMarketServiceImpl implements CurrencyMarketService {
ktype.getTimeType(), ktype.getTimeNumber());
if (lock) {
SortedMap<String, CurrencyMarketKDTO> map = marketKCache.getMarketKListCache(dto.getCurrencyPair(), ktype.getTimeType(), ktype.getTimeNumber());
if (map == null)
if (map == null || map.isEmpty())
map = selectMarketK(dto.getCurrencyPair(), ktype.getTimeType(), ktype.getTimeNumber());
if (map == null) continue;
if (map == null || map.isEmpty()) continue;
Long timestamp = (dto.getTimestamp() / (ktype.getTimeNumber() * MarketKEnums.valueOf(ktype.getTimeType()).getSecond())) * ktype.getTimeNumber() * MarketKEnums.valueOf(ktype.getTimeType()).getSecond();
CurrencyMarketKDTO kdto = map.get(timestamp.toString());
if (kdto == null) {
@ -608,7 +620,7 @@ public class CurrencyMarketServiceImpl implements CurrencyMarketService {
*/
private SortedMap<String, CurrencyMarketKDTO> getOneDayMarketK(String currencyPair, String timeType, Integer timeNumber) {
SortedMap<String, CurrencyMarketKDTO> map = marketKCache.getMarketKListCache(currencyPair, timeType, timeNumber);
if (map == null) {
if (map == null || map.isEmpty()) {
boolean lock = marketKCache.tryFairLock(redissonClient, currencyPair,
timeType, timeNumber);
if (lock) {

@ -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);
}
// 修改钱包插入充值记录
walletMapper.updateWalletBalanceByUserOpenId(config.getBalance(), userOpenId, tokenId, walletType, new Date());
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", ""),

@ -1,23 +1,18 @@
package com.blockchain.server.eth.controller;
import com.blockchain.common.base.constant.BaseConstant;
import com.blockchain.common.base.dto.ResultDTO;
import com.blockchain.common.base.dto.SessionUserDTO;
import com.blockchain.common.base.exception.RPCException;
import com.blockchain.common.base.util.SSOHelper;
import com.blockchain.server.eth.common.enums.EthWalletEnums;
import com.blockchain.server.eth.common.exception.EthWalletException;
import com.blockchain.server.eth.controller.api.EthTokenApi;
import com.blockchain.server.eth.controller.api.EthWalletApi;
import com.blockchain.server.eth.entity.EthWalletTransfer;
import com.blockchain.server.eth.feign.UserFeign;
import com.blockchain.server.eth.service.IEthTokenService;
import com.blockchain.server.eth.service.IEthWalletKeyService;
import com.blockchain.server.eth.service.IEthWalletService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.tomcat.jni.User;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;
@ -43,6 +38,8 @@ public class EthWalletController {
private UserFeign userFeign;
private static final Logger LOG = LoggerFactory.getLogger(EthWalletController.class);
@ApiOperation(value = EthWalletApi.GetWallet.METHOD_API_NAME, notes = EthWalletApi.GetWallet.METHOD_API_NOTE)
@GetMapping("/getWallet")
public ResultDTO getWallet(
@ -95,13 +92,14 @@ public class EthWalletController {
@ApiParam(EthWalletApi.SaveWalletPass.METHOD_API_CODE) @RequestParam(name = "code", required = false) String code,
HttpServletRequest request) {
SessionUserDTO user = SSOHelper.getUser(redisTemplate, request);
ResultDTO resultDTO = userFeign.validateSmsg(code, user.getTel());
/* ResultDTO resultDTO = userFeign.validateSmsg(code, user.getTel());
if (resultDTO == null) {
throw new EthWalletException(EthWalletEnums.SERVER_IS_TOO_BUSY);
}
if (resultDTO.getCode() != BaseConstant.REQUEST_SUCCESS) {
throw new RPCException(resultDTO.getCode(), resultDTO.getMsg());
}
}*/
LOG.info(" user yyyfUserId : "+ user.getYyyfUserId());
ethWalletService.updatePassword(user.getId(), password);
return ResultDTO.requstSuccess();
}

@ -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,12 +16,15 @@ 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.*;
import com.blockchain.server.eth.web3j.IWalletWeb3j;
import com.codingapi.tx.annotation.ITxTransaction;
import com.codingapi.tx.annotation.TxTransaction;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
@ -62,6 +63,10 @@ public class EthWalletServiceImpl implements IEthWalletService, ITxTransaction {
IWalletWeb3j walletWeb3j;
@Autowired
RedisTemplate redisTemplate;
@Autowired
private YyyyfMoneyFeign yyyyfMoneyFeign;
@Autowired
private WalletInitConfigMapper walletInitConfigMapper;
@ -75,6 +80,7 @@ public class EthWalletServiceImpl implements IEthWalletService, ITxTransaction {
return ethWalletMapper.select(ethWallet);
}
private static Logger LOG= LoggerFactory.getLogger(EthWalletServiceImpl.class);
@Override
@Transactional
public EthWalletDTO insert(String userOpenId, String tokenAddr, String walletType, String pass) {
@ -331,6 +337,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 +447,18 @@ public class EthWalletServiceImpl implements IEthWalletService, ITxTransaction {
if(config==null || config.getBalance()==null){
throw new EthWalletException(EthWalletEnums.RESET_ERROR);
}
ethWalletMapper.updateWalletBalanceByUserOpenId(config.getBalance(),userOpenId,tokenId,walletType,new Date());
YyyfUserDto yyyfUserDto = YyyfUserDtoUtils.getYyyfUserDtoByUserId(userOpenId, redisTemplate);
LOG.info(yyyfUserDto.toString());
LOG.info("yyyfUserDtoID "+yyyfUserDto.getUserId());
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);
}
}

@ -0,0 +1,21 @@
package com.blockchain.server.otc.common.config;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Component;
import java.util.concurrent.ThreadPoolExecutor;
@Component
public class ApplicationConfig {
@Bean
public ThreadPoolTaskExecutor executor() {
ThreadPoolTaskExecutor threadPoolTaskExecutor = new ThreadPoolTaskExecutor();
threadPoolTaskExecutor.setCorePoolSize(5);
threadPoolTaskExecutor.setMaxPoolSize(10);
threadPoolTaskExecutor.setQueueCapacity(50);
threadPoolTaskExecutor.setRejectedExecutionHandler(new ThreadPoolExecutor.AbortPolicy());
threadPoolTaskExecutor.setThreadNamePrefix("executor-");
return threadPoolTaskExecutor;
}
}

@ -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!"),

@ -17,4 +17,5 @@ public class PublishAdParamDTO extends BaseDTO {
private BigDecimal minLimit;
private String[] payType;
private String remark;
private Boolean isTeacher;
}

@ -52,9 +52,11 @@ public class Ad extends BaseModel {
private String adStatus;
@Column(name = "ad_remark")
private String adRemark;
@Column(name = "built_in")
private Boolean builtIn;
@Column(name = "create_time")
private java.util.Date createTime;
@Column(name = "modify_time")
private java.util.Date modifyTime;
}
}

@ -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);
}

@ -15,6 +15,7 @@ import com.blockchain.server.otc.mapper.AdMapper;
import com.blockchain.server.otc.service.*;
import com.codingapi.tx.annotation.ITxTransaction;
import com.codingapi.tx.annotation.TxTransaction;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -62,7 +63,7 @@ public class AdServiceImpl implements AdService, ITxTransaction {
//广告手续费率
BigDecimal serviceCharge = checkAdServiceCharge(coin.getCoinServiceCharge(), param.getUserId());
//新建广告数据,返回广告流水号
String adNumber = insertAd(param, CommonConstans.BUY, serviceCharge);
String adNumber = insertAd(param, CommonConstans.BUY, serviceCharge, false);
//新增用户交易数据表
dealStatsService.insertIsNotExist(param.getUserId());
//记录用户操作
@ -75,16 +76,22 @@ public class AdServiceImpl implements AdService, ITxTransaction {
public void publishSellAd(PublishAdParamDTO param) {
//发布广告参数校验方法
Coin coin = publishAdVerify(param);
//检查市商否能发布更多广告
checkMarketAdCount(param.getUserId(), CommonConstans.SELL, coin.getCoinName(), coin.getUnitName());
//检查卖家是否绑定支付方式
checkPublishPaysIsBinging(param);
//判断是否开启广告手续费
BigDecimal chargeRatio = checkAdServiceCharge(coin.getCoinServiceCharge(), param.getUserId());
//新建广告数据,返回广告流水号
String adNumber = insertAd(param, CommonConstans.SELL, chargeRatio);
//更新钱包并记录资金变动
publishSellAdHandleWallet(param, adNumber, chargeRatio);
String adNumber;
if (BooleanUtils.isFalse(param.getIsTeacher())) {
//检查市商否能发布更多广告
checkMarketAdCount(param.getUserId(), CommonConstans.SELL, coin.getCoinName(), coin.getUnitName());
//检查卖家是否绑定支付方式
checkPublishPaysIsBinging(param);
//判断是否开启广告手续费
BigDecimal chargeRatio = checkAdServiceCharge(coin.getCoinServiceCharge(), param.getUserId());
//新建广告数据,返回广告流水号
adNumber = insertAd(param, CommonConstans.SELL, chargeRatio, false);
//更新钱包并记录资金变动
publishSellAdHandleWallet(param, adNumber, chargeRatio);
} else {
//新建广告数据,返回广告流水号
adNumber = insertAd(param, CommonConstans.SELL, BigDecimal.ZERO, true);
}
//新增用户交易数据表
dealStatsService.insertIsNotExist(param.getUserId());
//记录用户操作
@ -216,9 +223,11 @@ public class AdServiceImpl implements AdService, ITxTransaction {
//检查发布参数
checkPublishParam(param);
//判断用户是否可以发布广告
marketUserService.checkMarketUser(param.getUserId());
//检查密码
walletService.isPassword(param.getPass());
if (BooleanUtils.isFalse(param.getIsTeacher())) {
marketUserService.checkMarketUser(param.getUserId());
//检查密码
walletService.isPassword(param.getPass());
}
//检查币对
Coin coin = checkCoinIsNull(param.getCoinName(), param.getUnitName());
//检查发布数量、单价小数长度、单价下限是否合法
@ -452,7 +461,7 @@ public class AdServiceImpl implements AdService, ITxTransaction {
* @param coinChargeRaito
* @return adNumber
*/
private String insertAd(PublishAdParamDTO param, String adType, BigDecimal coinChargeRaito) {
private String insertAd(PublishAdParamDTO param, String adType, BigDecimal coinChargeRaito, boolean buildIn) {
//检查发布支付类型与枚举是否正确,并返回支付信息字符串
String pays = checkPaysTypeIsRealAndGeneratePayStr(param.getPayType());
@ -472,6 +481,7 @@ public class AdServiceImpl implements AdService, ITxTransaction {
ad.setUnitName(param.getUnitName());
ad.setCoinName(param.getCoinName());
ad.setAdPay(pays);
ad.setBuiltIn(buildIn);
ad.setAdStatus(AdConstants.DEFAULT);
ad.setAdType(adType);
ad.setAdRemark(param.getRemark());

@ -2,25 +2,36 @@ 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.enums.JgMsgEnums;
import com.blockchain.server.otc.common.enums.OtcEnums;
import com.blockchain.server.otc.common.exception.OtcException;
import com.blockchain.server.otc.common.util.CheckDecimalUtil;
import com.blockchain.server.otc.common.util.ImUtil;
import com.blockchain.server.otc.dto.order.OrderDTO;
import com.blockchain.server.otc.dto.user.UserBaseDTO;
import com.blockchain.server.otc.entity.*;
import com.blockchain.server.otc.entity.Ad;
import com.blockchain.server.otc.entity.Coin;
import com.blockchain.server.otc.entity.Order;
import com.blockchain.server.otc.entity.UserPayInfo;
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.*;
import com.codingapi.tx.annotation.ITxTransaction;
import com.codingapi.tx.annotation.TxTransaction;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -60,6 +71,14 @@ public class OrderServiceImpl implements OrderService, ITxTransaction {
private ImUtil imUtil;
@Autowired
private OrderCache orderCache;
@Autowired
private YyyyfMoneyFeign yyyyfMoneyFeign;
@Autowired
private RedisTemplate redisTemplate;
@Autowired
private ApplicationContext applicationContext;
@Autowired
private ThreadPoolTaskExecutor executor;
private static final BigDecimal DECIMAL_DISH = new BigDecimal("0.1"); //下单金额计算的偏差值
@ -256,7 +275,7 @@ public class OrderServiceImpl implements OrderService, ITxTransaction {
}
@Override
@Transactional
@Transactional(rollbackFor = Exception.class)
public void pay(String userId, String orderId, String payType) {
//订单id判空
checkOrderIdNull(orderId);
@ -278,15 +297,29 @@ public class OrderServiceImpl implements OrderService, ITxTransaction {
checkPayTypeIsAdPayType(payType, ad.getAdPay());
//确认支付时,设置订单支付信息
order.setOrderPayType(payType);
//更新订单状态
receiptOrPayUpdateOrder(order, UserHandleConstants.PAY);
//记录用户操作
insertUserHandleLog(userId, order.getOrderNumber(), UserHandleConstants.PAY);
//确认付款发送提示消息
sendNewOrderMsg(JgMsgEnums.CONFIRM_BUYER_SELL.getName(), JgMsgEnums.CONFIRM_BUYER_BUY.getName(),
order.getSellUserId(), order.getBuyUserId(), order.getId());
//发送手机消息通知
pushToSingle(order.getSellUserId(), order.getId(), PushEnums.OTC_ORDER_PAY.getPushType());
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()) {
//更新订单状态
receiptOrPayUpdateOrder(order, UserHandleConstants.PAY);
//记录用户操作
insertUserHandleLog(userId, order.getOrderNumber(), UserHandleConstants.PAY);
//确认付款发送提示消息
sendNewOrderMsg(JgMsgEnums.CONFIRM_BUYER_SELL.getName(), JgMsgEnums.CONFIRM_BUYER_BUY.getName(),
order.getSellUserId(), order.getBuyUserId(), order.getId());
//发送手机消息通知
pushToSingle(order.getSellUserId(), order.getId(), PushEnums.OTC_ORDER_PAY.getPushType());
} else {
throw new OtcException(OtcEnums.FREEBALANCE_NOT_ENOUGH);
}
if (BooleanUtils.isTrue(ad.getBuiltIn())) {
executor.execute(() -> applicationContext.getBean(OrderService.class).receipt(order.getSellUserId(), orderId, "123456"));
}
}
@Override
@ -295,29 +328,41 @@ public class OrderServiceImpl implements OrderService, ITxTransaction {
public void receipt(String userId, String orderId, String pass) {
//订单id判空
checkOrderIdNull(orderId);
//校验密码
walletService.isPassword(pass);
//排他锁查询订单
Order order = orderMapper.selectByIdForUpdate(orderId);
//订单是否存在
checkOrderNull(order);
//校验密码
Ad ad = adService.selectById(order.getAdId());
if (BooleanUtils.isFalse(ad.getBuiltIn())) {
walletService.isPassword(pass);
}
//检查订单能否确认收款
checkOrderCanHandle(order, userId, UserHandleConstants.RECEIPT);
//更新订单状态
receiptOrPayUpdateOrder(order, UserHandleConstants.RECEIPT);
//记录用户操作
insertUserHandleLog(userId, order.getOrderNumber(), UserHandleConstants.RECEIPT);
//更新广告发布方成交统计数据
updateAdUserDealStats(order);
//更新余额并记录资金变动
receiptUpdateBalance(order);
//判断广告是否可以结束
checkAdCanFinish(order.getAdId());
//确认收款发送提示消息
sendNewOrderMsg(JgMsgEnums.CONFIRM_SELLER_SELL.getName(), JgMsgEnums.CONFIRM_SELLER_BUY.getName(),
order.getSellUserId(), order.getBuyUserId(), order.getId());
//发送手机消息通知
pushToSingle(order.getBuyUserId(), order.getId(), PushEnums.OTC_ORDER_RECEIPT.getPushType());
YyyfUserDto yyyfUserDto = YyyfUserDtoUtils.getYyyfUserDtoByUserId(userId, redisTemplate);
ResultDTO<Boolean> resultDTO = yyyyfMoneyFeign.resetWallet(yyyfUserDto.getAssessUserId(), order.getOrderPayType(), order.getTurnover());
if (resultDTO.getCode() == 200 && resultDTO.getData()) {
//更新订单状态
receiptOrPayUpdateOrder(order, UserHandleConstants.RECEIPT);
//记录用户操作
insertUserHandleLog(userId, order.getOrderNumber(), UserHandleConstants.RECEIPT);
//更新广告发布方成交统计数据
updateAdUserDealStats(order);
//更新余额并记录资金变动
receiptUpdateBalance(order);
//判断广告是否可以结束
checkAdCanFinish(order.getAdId());
//确认收款发送提示消息
sendNewOrderMsg(JgMsgEnums.CONFIRM_SELLER_SELL.getName(), JgMsgEnums.CONFIRM_SELLER_BUY.getName(),
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
@ -377,7 +422,9 @@ public class OrderServiceImpl implements OrderService, ITxTransaction {
//判断广告类型是否正确
checkAdType(ad.getAdType(), adType);
//检查下单用户是不是广告发布用户
checkAdUserAndOrderUserEquals(ad.getUserId(), userId);
if (!ad.getBuiltIn()) {
checkAdUserAndOrderUserEquals(ad.getUserId(), userId);
}
//检查检查下单数量、单价是否合法
checkAmountAndPrice(ad, amount, price);
@ -1011,10 +1058,12 @@ public class OrderServiceImpl implements OrderService, ITxTransaction {
walletService.handleRealBalance(order.getBuyUserId(), order.getOrderNumber(), order.getCoinName(), order.getUnitName(), realAmount, BigDecimal.ZERO, serviceCharge);
//记录资金变动
billService.insertBill(order.getBuyUserId(), order.getOrderNumber(), realAmount, BigDecimal.ZERO, BillConstants.MARK, order.getCoinName());
//卖家解冻
walletService.handleRealBalance(order.getSellUserId(), order.getOrderNumber(), order.getCoinName(), order.getUnitName(), BigDecimal.ZERO, minusAmount, BigDecimal.ZERO);
//记录资金变动
billService.insertBill(order.getSellUserId(), order.getOrderNumber(), BigDecimal.ZERO, minusAmount, BillConstants.MARK, order.getCoinName());
if (BooleanUtils.isFalse(ad.getBuiltIn())) {
//卖家解冻
walletService.handleRealBalance(order.getSellUserId(), order.getOrderNumber(), order.getCoinName(), order.getUnitName(), BigDecimal.ZERO, minusAmount, BigDecimal.ZERO);
//记录资金变动
billService.insertBill(order.getSellUserId(), order.getOrderNumber(), BigDecimal.ZERO, minusAmount, BillConstants.MARK, order.getCoinName());
}
}
/***
@ -1037,7 +1086,7 @@ public class OrderServiceImpl implements OrderService, ITxTransaction {
//falge为卖
boolean flag = checkBuyOrSell(ad.getAdType());
//广告是卖出类型时 并且 有剩余数量时,解冻余额
if (!flag && ad.getLastNum().compareTo(BigDecimal.ZERO) > 0) {
if (!flag && BooleanUtils.isFalse(ad.getBuiltIn()) && ad.getLastNum().compareTo(BigDecimal.ZERO) > 0) {
//广告手续费
BigDecimal serviceCharge = ad.getLastNum().multiply(ad.getChargeRatio());
//增加可用

@ -17,10 +17,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.UUID;
import java.util.*;
@Service
public class UserPayInfoServiceImpl implements UserPayInfoService {
@ -55,14 +52,23 @@ public class UserPayInfoServiceImpl implements UserPayInfoService {
Ad ad = adService.selectById(order.getAdId());
//获取广告设置的支付信息
String[] pays = ad.getAdPay().split(",");
//遍历查询支付信息,添加到集合中
for (String pay : pays) {
UserPayInfo userPayInfo = selectByUserIdAndPayType(order.getSellUserId(), pay);
//防空
if (userPayInfo == null) {
continue;
if (ad.getBuiltIn()) {
Arrays.stream(pays).forEach(pay -> {
UserPayInfo userPayInfo = new UserPayInfo();
userPayInfo.setUserId(order.getSellUserId());
userPayInfo.setPayType(pay);
userPayInfos.add(userPayInfo);
});
} else {
//遍历查询支付信息,添加到集合中
for (String pay : pays) {
UserPayInfo userPayInfo = selectByUserIdAndPayType(order.getSellUserId(), pay);
//防空
if (userPayInfo == null) {
continue;
}
userPayInfos.add(userPayInfo);
}
userPayInfos.add(userPayInfo);
}
} else {
//其他状态时,查询确认付款后选择的支付方式

@ -168,8 +168,10 @@ public class LoginController {
@ApiOperation(value = LoginApi.PassWorldLoginPC.METHOD_NAME,
notes = LoginApi.PassWorldLoginPC.METHOD_NOTE)
public ResultDTO loginByPasswordPC(@ApiParam(LoginApi.PassWorldLoginPC.METHOD_API_TEL) @RequestParam(name = "tel") String tel,
@ApiParam(LoginApi.PassWorldLoginPC.METHOD_API_PASS) @RequestParam(name = "password") String password) {
@ApiParam(LoginApi.PassWorldLoginPC.METHOD_API_PASS) @RequestParam(name = "password") String password,
HttpServletRequest request) {
UserMain userMain = userLoginService.handleLoginByPassword(tel, password);
dealBindYyyfAccount(userMain.getId(),request);
return handleAfterLogin(userMain, TokenTypeEnums.PC.getValue());
}

@ -61,7 +61,7 @@ public class AssessUser implements Serializable {
* 时长
*/
@Column(name = "duration")
private Integer duration;
private Long duration;
/**
* 时长单位
*/

@ -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 学生用户考核信息表 服务实现类

@ -25,6 +25,8 @@ import com.blockchain.server.user.mapper.UserMainMapper;
import com.blockchain.server.user.service.*;
import com.codingapi.tx.annotation.TxTransaction;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -59,6 +61,7 @@ public class UserMainServiceImpl implements UserMainService {
@Autowired
private BtcFeign btcFeign;
private static final Logger LOG = LoggerFactory.getLogger(UserMainServiceImpl.class);
@Override
public UserMain selectByMobilePhone(String tel) {
@ -97,8 +100,8 @@ public class UserMainServiceImpl implements UserMainService {
userLoginService.insertEntity(userId, password);//插入密码信息
int insertRow = userRelationService.insertRelationChain(userId, invitationCode);//插入推荐关系
userInfoService.saveUser(userId,tel, insertRow > 0);//插入用户其他信息
/* ResultDTO ethResult = ethFeign.initWallets(userId);
LOG.info("生成钱包开始");
ResultDTO ethResult = ethFeign.initWallets(userId);
if (ethResult.getCode() != BaseConstant.REQUEST_SUCCESS) {
throw new RPCException(ethResult.getCode(), ethResult.getMsg());
}
@ -109,7 +112,8 @@ public class UserMainServiceImpl implements UserMainService {
ResultDTO btcResult = btcFeign.createWallet(userId);
if (btcResult.getCode() != BaseConstant.REQUEST_SUCCESS) {
throw new RPCException(btcResult.getCode(), btcResult.getMsg());
}*/
}
LOG.info("生成钱包结束");
return user;
}

@ -1,5 +1,6 @@
package com.blockchain.server.yyyf.controller;
import com.alibaba.fastjson.JSONObject;
import com.blockchain.common.base.constant.YyyfConstant;
import com.blockchain.common.base.dto.ResultDTO;
import com.blockchain.common.base.dto.TokenDTO;
@ -85,7 +86,9 @@ public class LoginController {
yyyfUserDto.setUserName(userName);
yyyfUserDto.setUserId(userId);
yyyfUserDto.setUserType(yyyfLoginRequestVo.getUserType());
boolean needInit = false;
AssessUser assessUser = null;
List<TrainCaseTargetDto> trainCaseTargeList = null;
//做考试和练习
if (0 == reqType || 1 == reqType) {
if (0 == reqType) {
@ -96,17 +99,17 @@ public class LoginController {
return handleAfterLogin(yyyfLoginDto, yyyfUserDto);
}
}
AssessUser assessUser = this.assessUserService.selectAssessUserByUserIdAndissueIdForNotEnd(userId, examId);
assessUser = this.assessUserService.selectAssessUserByUserIdAndissueIdForNotEnd(userId, examId);
if (assessUser == null) {
Date now = new Date();
String tel=new SimpleDateFormat("yyMMddHHmmss").format(now).concat(String.valueOf(userId));
String tel = new SimpleDateFormat("yyMMddHHmmss").format(now).concat(String.valueOf(userId));
//第一次进入进行注册
String code=String.format("%06d",new Random().nextInt(1000000));
redisTemplate.opsForValue().set(YyyfConstant.REGISTER_KEY.concat(tel),code,YyyfConstant.TIME_OUT, TimeUnit.MINUTES);
String code = String.format("%06d", new Random().nextInt(1000000));
redisTemplate.opsForValue().set(YyyfConstant.REGISTER_KEY.concat(tel), code, YyyfConstant.TIME_OUT, TimeUnit.MINUTES);
yyyfLoginDto.setCode(code);
String password=String.format("%08d",new Random().nextInt(10000000));
String password = String.format("%08d", new Random().nextInt(10000000));
String assessUserId = IdGenerator.uuid();
assessUser = new AssessUser();
assessUser.setId(assessUserId);
@ -126,16 +129,23 @@ public class LoginController {
//获取案例信息
HashOperations<String, String, ExamPaperDto> examPaperOpsForHash = redisTemplate.opsForHash();
ExamPaperDto examPaperDto = examPaperOpsForHash.get(YyyfConstant.EXAM_PAPER_KEY, examPaperId);
List<TrainCaseTargetDto> trainCaseTargeList = examPaperDto.getTrainCaseTargetList();
trainCaseTargeList = examPaperDto.getTrainCaseTargetList();
assessUser.setWechatInitMoney(examPaperDto.getWechatInitMoney());
assessUser.setAlipayInitMoney(examPaperDto.getAlipayInitMoney());
assessUser.setBankcardInitMoney(examPaperDto.getBankcardInitMoney());
assessUser.setDigitwalletInitMoney(examPaperDto.getDigitwalletInitMoney());
this.assessUserService.initAssessUser(assessUser, trainCaseTargeList);
needInit = true;
}else{
String tel=assessUser.getTel();
int count=assessUserService.countUserByTel(tel);
if(count==0){
String code = String.format("%06d", new Random().nextInt(1000000));
redisTemplate.opsForValue().set(YyyfConstant.REGISTER_KEY.concat(tel), code, YyyfConstant.TIME_OUT, TimeUnit.MINUTES);
yyyfLoginDto.setCode(code);
}
}
yyyfUserDto.setAssessUserId(assessUser.getId());
yyyfLoginDto.setTel(assessUser.getTel());
yyyfLoginDto.setPassword(assessUser.getPassword());
@ -163,7 +173,7 @@ public class LoginController {
examDto.setExamPaperId(examPaperId);
examDtoOpsForHash.put(YyyfConstant.EXAM_KEY, examId, examDto);
}
yyyfLoginDto.setRemainingTime((examDto.getEndTime().getTime() - new Date().getTime() )/ 1000);
yyyfLoginDto.setRemainingTime((examDto.getEndTime().getTime() - new Date().getTime()) / 1000);
joinStuIds = studentOpsForHash.get(YyyfConstant.JOIN_EXAM_STU_IDS_KEY, examId);
if (joinStuIds == null) {
joinStuIds = new ArrayList<Integer>();
@ -187,19 +197,27 @@ public class LoginController {
return handleAfterLogin(yyyfLoginDto, yyyfUserDto);
}
} else {
String jioinExamId=null;
String jioinExamId = null;
if (redisTemplate.hasKey(caseKey)) {
Map<String, String> examMsgMap = (Map<String, String>) redisTemplate.opsForValue().get(caseKey);
jioinExamId= examMsgMap.get("examId");
joinStuIds = studentOpsForHash.get(YyyfConstant.JOIN_EXAM_STU_IDS_KEY,jioinExamId);
jioinExamId = examMsgMap.get("examId");
joinStuIds = studentOpsForHash.get(YyyfConstant.JOIN_EXAM_STU_IDS_KEY, jioinExamId);
}
//缓存是考试,要进入练习,则不让进入
if (joinStuIds != null && joinStuIds.stream()
.filter(stuIds -> (stuIds.equals(userId))).count() != 0) {
yyyfLoginDto.setStatus(3);
yyyfLoginDto.setMsg(YyyfConstant.NO_ENTRY_INTO_PRACTICE);
ExamDto examDto = examDtoOpsForHash.get(YyyfConstant.EXAM_KEY, examId);
yyyfLoginDto.setRemainingTime((examDto.getEndTime().getTime() - new Date().getTime() )/ 1000);
ExamDto examDto = examDtoOpsForHash.get(YyyfConstant.EXAM_KEY, jioinExamId);
LOG.info("examId is " + examId + "examDto is " + JSONObject.toJSON(examDto) + "jioinExamId is " + jioinExamId);
yyyfLoginDto.setRemainingTime((examDto.getEndTime().getTime() - new Date().getTime()) / 1000);
assessUser = this.assessUserService.selectAssessUserByUserIdAndissueIdForNotEnd(userId, jioinExamId);
yyyfUserDto.setAssessUserId(assessUser.getId());
yyyfLoginDto.setTel(assessUser.getTel());
yyyfLoginDto.setPassword(assessUser.getPassword());
yyyfLoginDto.setNickName(userName);
Map<String, String> map = new HashMap<String, String>();
map.put("examPaperId", examDto.getExamPaperId());
@ -218,7 +236,9 @@ public class LoginController {
yyyfLoginDto.setStatus(1);
}
if (needInit && assessUser != null && trainCaseTargeList != null) {
this.assessUserService.initAssessUser(assessUser, trainCaseTargeList);
}
return handleAfterLogin(yyyfLoginDto, yyyfUserDto);
}

@ -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,12 +69,12 @@ public class TeachingGradeController {
/**
* @description 教师获取考核概况
* @author huan.xu
* @author zijie
* @date 2020-05-19 10:47:29
* @param [issueId, totalNum, caseId, response]
* @return void
**/
@GetMapping(value = "/getGradeData", produces = {"application/text;charset=UTF-8"})
@PostMapping(value = "/getGradeData", produces = {"application/text;charset=UTF-8"})
@ResponseBody
@SuppressWarnings("all")
@ApiOperation(value = TeachingGradeApi.GetGradeData.METHOD_NAME,
@ -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;
@ -11,15 +10,12 @@ 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 org.springframework.web.bind.annotation.*;
import java.math.BigDecimal;
/**
* @author Mr.Xu
* @author
* @version 1.0
* @className MoneyController
* @description
@ -46,4 +42,33 @@ public class YyyfMoneyController {
return ResultDTO.requstSuccess(transactResultDto);
}
@GetMapping("/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) {
LOG.info("assessUserId is "+assessUserId+" ,coinName is "+ coinName + " ,balance is "+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
@ -18,7 +18,7 @@ import java.util.Date;
public class YyyfStudentAnswerDto implements Serializable {
private static final long serialVersionUID = 505667820932379758L;
private String authorization="87DIVy348Oxzj3ha";
private String sysType="130";
private String sysType="148";
private Integer userId;
private Double totalScore;
private Date startTime;

@ -61,7 +61,7 @@ public class AssessUser implements Serializable {
* 时长
*/
@Column(name = "duration")
private Integer duration;
private Long duration;
/**
* 时长单位
*/

@ -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,7 +3,7 @@ package com.blockchain.server.yyyf.feign;
import com.blockchain.common.base.dto.ResultDTO;
import com.blockchain.server.yyyf.feign.dto.BtcWalletDTO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
@ -12,6 +12,6 @@ import java.util.List;
public interface BtcFeign {
String CONTENT_PATH = "/inner/wallet";
@PostMapping(CONTENT_PATH + "/getWallets")
@GetMapping(CONTENT_PATH + "/getWallets")
ResultDTO<List<BtcWalletDTO>> getWallets(@RequestParam("userId") String userId);
}

@ -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);
}

@ -4,11 +4,12 @@ import com.blockchain.common.base.dto.ResultDTO;
import com.blockchain.server.yyyf.feign.dto.EosWalletDTO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
@FeignClient("dapp-eos-server")
public interface EosFeign {
@GetMapping("/inner/walletTx/selectWalletByUserOpenId")
ResultDTO<List<EosWalletDTO>> selectWalletByWalletType(String userOpenId);
ResultDTO<List<EosWalletDTO>> selectWalletByWalletType(@RequestParam("userOpenId") String userOpenId);
}

@ -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
@ -52,4 +52,11 @@ public interface AssessUserMapper extends Mapper<AssessUser> {
UserTimeMoneyDto getUserTimeMoneyDtoByAssessUserId(@Param("assessUserId") String assessUserId);
UserTimeMoneyDto selectCurrentUserTimeMoneyDto(@Param("assessUserId") String assessUserId, @Param("qUserId")String qUserId);
/**
* @description 查询子系统是否有改电话号码注册成功
* @date 2020-12-29 17:18:29
* @param [tel]
* @return int
**/
int countUserByTel(@Param("tel")String tel);
}

@ -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,27 @@ 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();
/**
* @description 查询子系统是否有改电话号码注册成功
* @date 2020-12-29 17:18:29
* @param [tel]
* @return int
**/
int countUserByTel(String tel);
}

@ -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,9 @@
package com.blockchain.server.yyyf.service.impl;
import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
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;
@ -12,10 +15,13 @@ 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.indicators.IndicatorsManager;
import com.blockchain.server.yyyf.indicators.dto.AssetsReporter;
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.service.AssetsReporterService;
import com.blockchain.server.yyyf.utils.HttpClientUtil;
import com.blockchain.server.yyyf.utils.IdGenerator;
import lombok.SneakyThrows;
@ -36,7 +42,7 @@ import java.util.*;
import java.util.concurrent.TimeUnit;
/**
* @author huan.xu
* @author zijie
* @version 1.0
* @className AssessUserServiceImpl
* @description 学生用户考核信息表 服务实现类
@ -56,9 +62,13 @@ public class AssessUserServiceImpl implements AssessUserService {
private AssessUserTargetMapper assessUserTargetMapper;
@Autowired
private YyyfMoneyMapper yyyfMoneyMapper;
@Autowired
private TrainCaseManageMapper trainCaseManageMapper;
//@Autowired
@Autowired
private IndicatorsManager indicatorsManager;
@Autowired
private AssetsReporterService assetsReporterService;
@Value("${yyyf.url}")
@ -144,6 +154,19 @@ public class AssessUserServiceImpl implements AssessUserService {
if (assessUser.getEndTime() != null) {
throw new YyyfException(YyyfEnums.PROHIBIT_DUPLICATE_SUBMISSION);
}
//计算当前时间收益
BigDecimal assets = indicatorsManager.calculateCurrentTotalAssets(assessUser.getQUserId(), assessUserId);
Date now = new Date();
assetsReporterService.saveList(Collections.singletonList(AssetsReporter.builder()
.id(IdGenerator.uuid())
.assessUserId(assessUserId)
.assets(assets)
//不满一天按一天计算
.days(DateUtil.between(assessUser.getStartTime(), now, DateUnit.DAY) + 1)
.coinName("RMB")
.createTime(now)
.build()));
Double totalScore = 0d;
//获取指标信息
Example example = new Example(AssessUserTarget.class);
@ -168,13 +191,12 @@ public class AssessUserServiceImpl implements AssessUserService {
}
Date startTime = assessUser.getStartTime();
Date now = new Date();
assessUser.setTotalScore(totalScore);
assessUser.setEndTime(now);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//考试时长
long duration = sdf.parse(sdf.format(now)).getTime() - sdf.parse(sdf.format(startTime)).getTime();
assessUser.setDuration(Math.toIntExact(duration));
assessUser.setDuration(duration);
if (assessUser.getUserType() == 0 && assessUser.getAchieveMentType() == 0) {
YyyfStudentAnswerDto yyyfStudentAnswerDto = new YyyfStudentAnswerDto();
BeanUtils.copyProperties(assessUser, yyyfStudentAnswerDto);
@ -225,7 +247,7 @@ public class AssessUserServiceImpl implements AssessUserService {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//考试时长
long duration = sdf.parse(sdf.format(now)).getTime() - sdf.parse(sdf.format(startTime)).getTime();
assessUserDto.setDuration(Math.toIntExact(duration));
assessUserDto.setDuration(duration);
updateAssessUserDtoList.add(assessUserDto);
//指标库更新
@ -249,7 +271,7 @@ public class AssessUserServiceImpl implements AssessUserService {
this.assessUserTargetMapper.batchUpdateTargetAnswer(updateAssessUserTargetList);
}
HttpClientUtil.doPostWithJSON(new StringBuilder().append(yyyfUrl).append(assessmentList).toString(), yyyfStudentAnswerDtoList);
HttpClientUtil.doPostWithJSON(new StringBuilder().append(yyyfUrl).append(assessmentList).toString(), yyyfStudentAnswerDtoList);
}
@ -285,7 +307,8 @@ public class AssessUserServiceImpl implements AssessUserService {
Example example = new Example(AssessUser.class);
Example.Criteria criteria = example.createCriteria();
criteria.andCondition("issue_id = ", issueId)
.andCondition("user_id = ", userId);
.andCondition("user_id = ", userId)
.andCondition("end_time is not null ");
return this.assessUserMapper.selectByExample(example);
}
@ -304,11 +327,28 @@ 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);
}
}
@Override
public int countUserByTel(String tel) {
return this.assessUserMapper.countUserByTel(tel);
}
/**
* @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) {
@ -327,4 +367,4 @@ public class AssessUserServiceImpl implements AssessUserService {
}
}
}

@ -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

@ -22,11 +22,17 @@ spring:
name: dapp-yyyf-server
#以渔有方配置
yyyf:
url: http://10.1.129.60:9090/yyyf-server-app
#测试环境
#url: http://10.1.129.60:9090/yyyf-server-app
#线上环境
url: http://www.iyyyf.com
#在线同步
integral: /api/bd/v1.0/integral
#成绩同步(单个)
assessment: /api/db/v1.0/assessment
#成绩同步(整场考试)
assessmentList: /api/db/v1.0/assessmentList
rate:
riskFree: 0.04

@ -128,7 +128,11 @@
<select id="selectCurrentUserTimeMoneyDto" resultMap="UserTimeMoneyDtoMap">
SELECT au.id,au.user_id,au.q_user_id,au.alipay_init_money,au.wechat_init_money,au.bankcard_init_money,au.start_time,m.wx_pay,m.ali_pay,m.bank_card,m.btc,m.eth,m.usdt,m.eos
from yyyf_server_assess_user au,yyyf_money m
where au.id=m.assess_user_id and au.q_user_id=#{qUserId} and au.id={assessUserId}
where au.id=m.assess_user_id and au.q_user_id=#{qUserId} and au.id=#{assessUserId}
</select>
<select id="countUserByTel" resultType="java.lang.Integer">
select count(1) from dapp_u_user_main where mobile_phone = #{tel}
</select>
</mapper>

@ -20,11 +20,11 @@
<foreach collection="list" item="assetsReporter" index="index" separator=",">
(
#{assetsReporter.id},
#{assetsReporter.assess_user_id},
#{assetsReporter.coin_name},
#{assetsReporter.assessUserId},
#{assetsReporter.coinName},
#{assetsReporter.days},
#{assetsReporter.assets},
#{assetsReporter.create_time}
#{assetsReporter.createTime}
)
</foreach>
</insert>

@ -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>

@ -33,8 +33,9 @@
<custom-project-version>latest</custom-project-version>
<!-- 配置信息 -->
<eureka-host>zhixinlian:zhi123xin678lian@127.0.0.1</eureka-host>
<redis-host>127.0.0.1</redis-host>
<eureka-host>zhixinlian:zhi123xin678lian@spring-cloud-eureka</eureka-host>
<redis-host>redis</redis-host>
<tx-host>tx-manager</tx-host>
</properties>
<dependencies>
@ -117,4 +118,4 @@
</plugins>
</pluginManagement>
</build>
</project>
</project>

@ -16,6 +16,7 @@
<module>spring-cloud-eureka</module>
<module>spring-cloud-hystrix-dashboard</module>
<module>spring-cloud-config</module>
<module>spring-cloud-gateway</module>
</modules>

@ -1,6 +1,6 @@
spring:
datasource:
url: jdbc:mysql://127.0.0.1:3306/zhixinlian?useUnicode=true&characterEncoding=UTF-8&useSSL=false&allowMultiQueries=true
url: jdbc:mysql://mysql:3306/zhixinlian?useUnicode=true&characterEncoding=UTF-8&useSSL=false&allowMultiQueries=true
username: root
password: 123456
driver-class-name: com.mysql.jdbc.Driver

@ -1,4 +1,4 @@
#分布式事务配置
tm:
manager:
url: http://${redis-host}:7000/tx/manager/
url: http://${tx-host}:7000/tx/manager/

@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>spring-cloud</artifactId>
<groupId>com.blockchain</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>spring-cloud-gateway</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-gateway</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>

@ -0,0 +1,14 @@
package com.blockchain.spring.cloud.gateway;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
@SpringBootApplication
@EnableEurekaClient
public class GatewayApplication {
public static void main(String[] args) {
SpringApplication.run(GatewayApplication.class,args);
}
}

@ -0,0 +1,82 @@
server:
port: 8003
spring:
application:
name: dapp-gateway-server
cloud:
gateway:
routes:
- id: blockchain-server-btc
uri: lb://dapp-btc-server
predicates:
- Path=/btc/**
filters:
- StripPrefix=1
- id: blockchain-server-cct
uri: lb://dapp-cct-server
predicates:
- Path=/cct/**
filters:
- StripPrefix=1
- id: blockchain-server-currency
uri: lb://dapp-currency-server
predicates:
- Path=/currency/**
filters:
- StripPrefix=1
- id: blockchain-server-databot
uri: lb://dapp-databot-server
predicates:
- Path=/databot/**
filters:
- StripPrefix=1
- id: blockchain-server-eos
uri: lb://dapp-eos-server
predicates:
- Path=/eos/**
filters:
- StripPrefix=1
- id: blockchain-server-eth
uri: lb://dapp-eth-server
predicates:
- Path=/eth/**
filters:
- StripPrefix=1
- id: blockchain-server-imjg
uri: lb://dapp-imjg-server
predicates:
- Path=/imjg/**
filters:
- StripPrefix=1
- id: blockchain-server-otc
uri: lb://dapp-otc-server
predicates:
- Path=/otc/**
filters:
- StripPrefix=1
- id: blockchain-server-sysconf
uri: lb://dapp-sysconf-server
predicates:
- Path=/sysconf/**
filters:
- StripPrefix=1
- id: blockchain-server-user
uri: lb://dapp-user-server
predicates:
- Path=/user/**
filters:
- StripPrefix=1
- id: blockchain-server-yyyf
uri: lb://dapp-yyyf-server
predicates:
- Path=/yyyfuser/**
filters:
- StripPrefix=1
eureka:
client:
service-url:
defaultZone: http://${eureka-host}:8001/eureka/
instance:
prefer-ip-address: true
instance-id: ${spring.cloud.client.ip-address}:${server.port}
hostname: ${spring.cloud.client.ip-address}
Loading…
Cancel
Save