浏览代码

Merge remote-tracking branch 'origin/stock2coin' into stock2coin

qlm 4 年之前
父节点
当前提交
01a3c8a506

+ 8 - 0
src/main/java/com/xc/controller/RiskController.java

@@ -103,6 +103,14 @@ public class RiskController {
         } catch (Exception e) {
             e.printStackTrace();
         }
+        if("0".equals(status)){  // 启动
+            //如果有数据那就不管
+            Record data1 = Db.use("data").findFirst("select code,status,tocode from risk_control_formula_history where code = ? and ( endTime is null or endTime = '' ) ", code);
+            if(data1==null){
+                Db.use("data").update("INSERT INTO  risk_control_formula_history( `code`, `minimumFluctuation`, `riskControl`, `status`, `startTime`, `endTime`, `tocode`, `multiples`)                         " +
+                        " VALUES ( '" + code + "', '"+minimumFluctuation+"', '"+riskControl+"', "+status+", '"+ System.currentTimeMillis() +"', '', '"+tocode+"', "+multiples+")  " );
+            }
+        }
         if("1".equals(status)){  // 如果关闭了
             Db.use("data").update("UPDATE risk_control_formula_history SET `endTime` = ?   WHERE `tocode` = ?  and (endTime is null or endTime ='' ) ", System.currentTimeMillis(), tocode);
         }

+ 19 - 4
src/main/java/com/xc/service/impl/DbStockServiceImpl.java

@@ -3,11 +3,13 @@ package com.xc.service.impl;
 
 import com.xc.dao2.KLinkStockMapper;
 import com.xc.dao2.StockRestDataMapper;
+import com.xc.pub.redismessage.util.RedisUtil;
 import com.xc.service.DbStockService;
 import com.xc.vo.stock.StockListVO;
 import com.xc.vo.stock.StockVO;
 import com.xc.vo2.StockDbVO;
 import org.apache.commons.lang.ObjectUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -25,13 +27,26 @@ public class DbStockServiceImpl implements DbStockService {
     @Autowired
     private KLinkStockMapper kLinkStockMapper;
 
+    @Autowired
+    private RedisUtil redisUtil;
+
     private StockDbVO getStockDb(String stockGid) {
         String dbTableName = String.format("data_rt_%s",stockGid);
-        StockDbVO stockDbVO;
-        if(kLinkStockMapper.selectDateOneCount(dbTableName) <= 0) {
-            stockDbVO = stockRestDataMapper.selectRestDataByGidDateOne(dbTableName);
+        StockDbVO stockDbVO = null;
+        String redisData = redisUtil.getItem(stockGid);
+        StockVO stockVO = null;
+        if (StringUtils.isNotEmpty(redisData) && !("[]".equals(redisData))) {
+            stockVO = com.alibaba.fastjson.JSONArray.parseObject(redisData, StockVO.class);
+        }
+        if(stockVO == null){
+            if(kLinkStockMapper.selectDateOneCount(dbTableName) <= 0) {
+                stockDbVO = stockRestDataMapper.selectRestDataByGidDateOne(dbTableName);
+            }else{
+                stockDbVO = stockRestDataMapper.selectRestDataByGid(dbTableName);
+            }
         }else{
-            stockDbVO = stockRestDataMapper.selectRestDataByGid(dbTableName);
+            stockDbVO = new StockDbVO();
+            BeanUtils.copyProperties(stockVO, stockDbVO);
         }
 //        StockDbVO stockDbVO = stockRestDataMapper.selectRestDataByGid(dbTableName);
         if(null == stockDbVO){

+ 16 - 14
src/main/java/com/xc/service/impl/UserPositionServiceImpl.java

@@ -1106,24 +1106,26 @@ public class UserPositionServiceImpl implements IUserPositionService {
     }
 
     public PositionVO findUserPositionAllProfitAndLose(Integer userId) {
-        // 获取货币当前价格
-        List<IndexInfo> indexInfoList = stockMapper.selectStockList();
+        List<UserPosition> userPositionAll = this.userPositionMapper.findMyPositionByCodeAndSpell(userId, null, null, 0);
         Map<String, IndexInfo> indexMap = new HashMap<>();
-        BigDecimal nowPrice;
-        for (IndexInfo indexInfo : indexInfoList) {
-            if (StringUtils.isNotEmpty(indexInfo.getDataDbName())) {
-                try {
-                    StockListVO stockListVO = dbStockService.getStockListVO(indexInfo.getCode());
-                    nowPrice = new BigDecimal(stockListVO.getNowPrice());
-                    indexInfo.setNowPrice(nowPrice);
-                } catch (Exception e) {
-                    // 数据库不存在
-                    log.info("数据库不存在");
+        if(userPositionAll.size() > 0){
+            // 获取货币当前价格
+            List<IndexInfo> indexInfoList = stockMapper.selectStockList();
+            BigDecimal nowPrice;
+            for (IndexInfo indexInfo : indexInfoList) {
+                if (StringUtils.isNotEmpty(indexInfo.getDataDbName())) {
+                    try {
+                        StockListVO stockListVO = dbStockService.getStockListVO(indexInfo.getCode());
+                        nowPrice = new BigDecimal(stockListVO.getNowPrice());
+                        indexInfo.setNowPrice(nowPrice);
+                    } catch (Exception e) {
+                        // 数据库不存在
+                        log.info("数据库不存在");
+                    }
                 }
+                indexMap.put(indexInfo.getCnName(), indexInfo);
             }
-            indexMap.put(indexInfo.getCnName(), indexInfo);
         }
-        List<UserPosition> userPositionAll = this.userPositionMapper.findMyPositionByCodeAndSpell(userId, null, null, 0);
         BigDecimal depositFreezeAmt = new BigDecimal(0);
         BigDecimal ykSum = new BigDecimal(0);
         for (UserPosition position : userPositionAll) {

+ 19 - 21
src/main/java/com/xc/service/impl/UserServiceImpl.java

@@ -124,7 +124,7 @@ public class UserServiceImpl implements IUserService {
         if (agentUser == null) {
             return ServerResponse.createByErrorMsg("注册失败, 代理不存在");
         }
-        if (agentUser.getIsLock().intValue() == 1) {
+        if (agentUser.getIsLock() == 1) {
             return ServerResponse.createByErrorMsg("注册失败, 代理已被锁定");
         }
         User dbuser = this.userMapper.findByPhone(phone);
@@ -137,7 +137,7 @@ public class UserServiceImpl implements IUserService {
         user.setPhone(phone);
         user.setUserPwd(userPwd);
         user.setAccountType(0);
-        user.setIsLock(1);
+        user.setIsLock(0);
         user.setIsActive(0);
         user.setRegTime(new Date());
         String uip = IpUtils.getIp(request);
@@ -296,9 +296,6 @@ public class UserServiceImpl implements IUserService {
 
 
     public ServerResponse getUserInfo(HttpServletRequest request) {
-//        String loginToken = CookieUtils.readLoginToken(request, PropertiesUtil.getProperty("user.cookie.name"));
-//        String userJson = RedisShardedPoolUtils.get(loginToken);
-//        User user = (User)JsonUtil.string2Obj(userJson, User.class);
         User user = getCurrentUser(request);
         User dbuser = this.userMapper.selectByPrimaryKey(user.getId());
         UserInfoVO userInfoVO = assembleUserInfoVO(dbuser);
@@ -1161,22 +1158,23 @@ public class UserServiceImpl implements IUserService {
         BigDecimal userAllAmt = user.getUserAmt();
         userAllAmt = userAllAmt.add(allProfitAndLose);
         userInfoVO.setUserAmt(userAllAmt);
-        userInfoVO.setEnableIndexAmt(user.getEnableIndexAmt());
-        IndexPositionVO indexPositionVO = this.iUserIndexPositionService.findUserIndexPositionAllProfitAndLose(user.getId());
-        BigDecimal allIndexProfitAndLose = indexPositionVO.getAllIndexProfitAndLose();
-        userInfoVO.setAllIndexProfitAndLose(allIndexProfitAndLose);
-        userInfoVO.setAllIndexFreezAmt(indexPositionVO.getAllIndexFreezAmt());
-        BigDecimal userAllIndexAmt = user.getUserIndexAmt();
-        userAllIndexAmt = userAllIndexAmt.add(allIndexProfitAndLose);
-        userInfoVO.setUserIndexAmt(userAllIndexAmt);
-        userInfoVO.setEnableFuturesAmt(user.getEnableFutAmt());
-        FuturesPositionVO futuresPositionVO = this.iUserFuturesPositionService.findUserFuturesPositionAllProfitAndLose(user.getId());
-        userInfoVO.setAllFuturesFreezAmt(futuresPositionVO.getAllFuturesDepositAmt());
-        BigDecimal allFuturesProfitAndLose = futuresPositionVO.getAllFuturesProfitAndLose();
-        userInfoVO.setAllFuturesProfitAndLose(allFuturesProfitAndLose);
-        BigDecimal userAllFuturesAmt = user.getUserFutAmt();
-        userAllFuturesAmt = userAllFuturesAmt.add(allFuturesProfitAndLose);
-        userInfoVO.setUserFuturesAmt(userAllFuturesAmt);
+
+//        userInfoVO.setEnableIndexAmt(user.getEnableIndexAmt());
+//        IndexPositionVO indexPositionVO = this.iUserIndexPositionService.findUserIndexPositionAllProfitAndLose(user.getId());
+//        BigDecimal allIndexProfitAndLose = indexPositionVO.getAllIndexProfitAndLose();
+//        userInfoVO.setAllIndexProfitAndLose(allIndexProfitAndLose);
+//        userInfoVO.setAllIndexFreezAmt(indexPositionVO.getAllIndexFreezAmt());
+//        BigDecimal userAllIndexAmt = user.getUserIndexAmt();
+//        userAllIndexAmt = userAllIndexAmt.add(allIndexProfitAndLose);
+//        userInfoVO.setUserIndexAmt(userAllIndexAmt);
+//        userInfoVO.setEnableFuturesAmt(user.getEnableFutAmt());
+//        FuturesPositionVO futuresPositionVO = this.iUserFuturesPositionService.findUserFuturesPositionAllProfitAndLose(user.getId());
+//        userInfoVO.setAllFuturesFreezAmt(futuresPositionVO.getAllFuturesDepositAmt());
+//        BigDecimal allFuturesProfitAndLose = futuresPositionVO.getAllFuturesProfitAndLose();
+//        userInfoVO.setAllFuturesProfitAndLose(allFuturesProfitAndLose);
+//        BigDecimal userAllFuturesAmt = user.getUserFutAmt();
+//        userAllFuturesAmt = userAllFuturesAmt.add(allFuturesProfitAndLose);
+//        userInfoVO.setUserFuturesAmt(userAllFuturesAmt);
         // 获取用户是否有绑定银行卡
         if(0 == userMapper.selectHaveBankCardByUserId(userInfoVO.getId())){
             userInfoVO.setHaveBankCard(false);

+ 7 - 14
src/main/java/com/xc/service/impl/UserWithdrawServiceImpl.java

@@ -108,26 +108,19 @@ public class UserWithdrawServiceImpl implements IUserWithdrawService {
             if (userBank == null) {
                 return ServerResponse.createByErrorMsg("未添加银行卡");
             }
-            if (user.getAccountType().intValue() == 1) {
+            if (user.getAccountType() == 1) {
                 return ServerResponse.createByErrorMsg("模拟用户不能出币");
             }
             SiteSetting siteSetting = this.iSiteSettingService.getSiteSetting();
             if ((new BigDecimal(amt)).compareTo(new BigDecimal(siteSetting.getWithMinAmt().intValue())) == -1) {
                 return ServerResponse.createByErrorMsg("出币金额不得低于" + siteSetting.getWithMinAmt() + "元");
             }
-            int with_time_begin = siteSetting.getWithTimeBegin().intValue();
-            int with_time_end = siteSetting.getWithTimeEnd().intValue();
-            if (!WithDrawUtils.checkIsWithTime(with_time_begin, with_time_end)) {
-                return ServerResponse.createByErrorMsg("出币失败,出币时间在" + with_time_begin + "点 - " + with_time_end + "点 之间");
-            }
-            BigDecimal index_user_amt = user.getUserIndexAmt();
-            if (index_user_amt.compareTo(new BigDecimal("0")) == -1) {
-                return ServerResponse.createByErrorMsg("货币资金不能小于0");
-            }
-            BigDecimal futures_user_amt = user.getUserFutAmt();
-            if (futures_user_amt.compareTo(new BigDecimal("0")) == -1) {
-                return ServerResponse.createByErrorMsg("期货资金不能小于0");
-            }
+//            int with_time_begin = siteSetting.getWithTimeBegin().intValue();
+//            int with_time_end = siteSetting.getWithTimeEnd().intValue();
+//            if (!WithDrawUtils.checkIsWithTime(with_time_begin, with_time_end)) {
+//                return ServerResponse.createByErrorMsg("出币失败,出币时间在" + with_time_begin + "点 - " + with_time_end + "点 之间");
+//            }
+
             BigDecimal enable_amt = user.getEnableAmt();
             int compareAmt = enable_amt.compareTo(new BigDecimal(amt));
             if (compareAmt == -1) {

+ 0 - 13
src/main/java/com/xc/vo/stock/StockVO.java

@@ -16,30 +16,17 @@ public class StockVO {
     private BigDecimal hcrate;
     private String today_max;
     private String today_min;
-
     private String business_balance;
-
     private String business_amount;
-
     private String preclose_px;
-
     private String open_px;
-
     private String buy1;
-
     private String buy2;
-
     private String buy3;
-
     private String buy4;
-
     private String buy5;
-
     private Integer transState;//交易状态:0 不可交易 1 可交易
-
     private Integer depositAmt;
-
-
     private String sell1;
     private String sell2;
     private String sell3;