| | |
| | | import com.google.common.collect.Lists; |
| | | import com.nq.common.ServerResponse; |
| | | import com.nq.config.StockPoll; |
| | | import com.nq.config.StockType; |
| | | import com.nq.dao.*; |
| | | import com.nq.pojo.*; |
| | | import com.nq.service.*; |
| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | |
| | | @Service("iUserService") |
| | | public class UserServiceImpl implements IUserService { |
| | |
| | | } |
| | | } |
| | | |
| | | public ServerResponse addOption(String code, HttpServletRequest request) { |
| | | public ServerResponse addOption(String stockType, String code, HttpServletRequest request) { |
| | | User user = getCurrentUser(request); |
| | | if (user == null) { |
| | | return ServerResponse.createBySuccessMsg("請先登錄"); |
| | | } |
| | | |
| | | String stockcode = code; |
| | | if(code.contains("hf")){ |
| | | stockcode = code.split("_")[1]; |
| | | } |
| | | stockcode = stockcode.replace("sh","").replace("sz","").replace("bj",""); |
| | | StockOption dboption = this.stockOptionMapper.findMyOptionIsExistByCode(user.getId(), stockcode); |
| | | |
| | |
| | | // stock.setIsLock(0); |
| | | // } |
| | | } else { |
| | | if(StockType.HK.getCode().equals(stockType)) { |
| | | stock = stockMapper.findStockByCodeAndType(stockType,code); |
| | | }else { |
| | | stock = this.stockMapper.findStockByCode(code); |
| | | } |
| | | } |
| | | if (stock == null) { |
| | | return ServerResponse.createByErrorMsg("添加失败,股票不存在"); |
| | |
| | | stockOption.setUserId(user.getId()); |
| | | stockOption.setStockId(stock.getId()); |
| | | stockOption.setAddTime(new Date()); |
| | | |
| | | if(StockType.HK.getCode().equals(stockType)) { |
| | | stockOption.setStockCode(stock.getStockGid()); |
| | | stockOption.setStockType(StockType.HK.getCode()); |
| | | }else { |
| | | stockOption.setStockCode(stock.getStockCode()); |
| | | stockOption.setStockType(StockType.A.getCode()); |
| | | } |
| | | stockOption.setStockName(stock.getStockName()); |
| | | stockOption.setStockGid(stock.getStockGid()); |
| | | stockOption.setIsLock(stock.getIsLock()); |
| | |
| | | } |
| | | } |
| | | userInfoVO.setHistoryProfitLoss(historyProfitLoss); |
| | | |
| | | // 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.setDjzj(user.getDjzj()); |
| | | return userInfoVO; |
| | | } |
| | |
| | | StockCoin stockCoin = new StockCoin(); |
| | | stockListVO = SinaStockApi.assembleLideStockListVO(LiDeDataUtils.getStock(position.getStockCode())); |
| | | if (org.springframework.util.ObjectUtils.isEmpty(stockListVO)) { |
| | | if(StockType.HK.getCode().equals(position.getStockType())){ |
| | | stockListVO = SinaStockApi.assembleStockListVOHk(SinaStockApi.getSinaStock(position.getStockType()+position.getStockGid())); |
| | | }else { |
| | | stockListVO = SinaStockApi.assembleStockListVO(SinaStockApi.getSinaStock(position.getStockGid())); |
| | | } |
| | | // stockListVO = SinaStockApi.assembleStockListVO(SinaStockApi.getSinaStock(position.getStockGid())); |
| | | |
| | | } |
| | | nowPrice = stockListVO.getNowPrice(); |
| | | if (nowPrice == null) { |
| | | nowPrice = String.valueOf(0); |
| | | } |
| | | |
| | | BigDecimal subPrice = (new BigDecimal(nowPrice)).subtract(position.getBuyOrderPrice()); |
| | | // profitAndLose = subPrice.multiply(new BigDecimal(position.getOrderNum().intValue())).multiply(new BigDecimal(position.getOrderLever())).setScale(2,4); |
| | | profitAndLose = subPrice.multiply(new BigDecimal(position.getOrderNum().intValue())).setScale(2,4); |
| | | if ("买跌".equals(position.getOrderDirection())) { |
| | | profitAndLose = profitAndLose.negate(); |