| | |
| | | import com.nq.pojo.*; |
| | | import com.nq.service.*; |
| | | import com.nq.utils.timeutil.DateTimeUtil; |
| | | import com.nq.utils.KeyUtils; |
| | | import com.nq.utils.stock.BuyAndSellUtils; |
| | | import com.nq.utils.stock.GeneratePosition; |
| | | import com.nq.utils.stock.sina.StockApi; |
| | | import com.nq.vo.position.PositionProfitVO; |
| | | import com.nq.vo.position.UserPositionVO; |
| | | import com.nq.vo.stock.StockListVO; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.math.BigDecimal; |
| | | import java.util.Calendar; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | |
| | | IUserService iUserService; |
| | | @Autowired |
| | | ISiteSettingService iSiteSettingService; |
| | | @Autowired |
| | | IStockService iStockService; |
| | | @Autowired |
| | | ISiteSpreadService iSiteSpreadService; |
| | | @Autowired |
| | | IAgentAgencyFeeService iAgentAgencyFeeService; |
| | | |
| | | |
| | | @Override |
| | | public ServerResponse insert(UserFundsPosition model, HttpServletRequest request) { |
| | |
| | | /** |
| | | * 分仓交易-入仓 |
| | | */ |
| | | @Transactional |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public ServerResponse buyFunds(Integer stockId, Integer buyNum, Integer buyType, Integer lever, Integer subaccountNumber, HttpServletRequest request) throws Exception { |
| | | return ServerResponse.createBySuccess("Order successful"); |
| | | } |
| | |
| | | /* |
| | | * 分仓交易-用户平仓操作 |
| | | * */ |
| | | @Transactional |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public ServerResponse sellFunds(String positionSn, int doType) throws Exception { |
| | | log.info("【用户交易平仓】 positionSn = {} , dotype = {}", positionSn, Integer.valueOf(doType)); |
| | | |
| | |
| | | return ServerResponse.createByErrorMsg("报价0,平仓失败,请稍后再试"); |
| | | } |
| | | |
| | | double stock_crease = stockListVO.getHcrate().doubleValue(); |
| | | |
| | | BigDecimal zsPrice = new BigDecimal(stockListVO.getPreclose_px()); |
| | | |
| | |
| | | |
| | | BigDecimal ztRate = chaPrice.multiply(new BigDecimal("100")).divide(zsPrice, 2, 4); |
| | | |
| | | ztRate = ztRate.negate(); |
| | | log.info("股票当前涨跌幅 = {} 跌停幅度 = {}", Double.valueOf(stock_crease), ztRate); |
| | | if ((new BigDecimal(String.valueOf(stock_crease))).compareTo(ztRate) == 0 && "买涨" |
| | | .equals(userPosition.getOrderDirection())) { |
| | | return ServerResponse.createByErrorMsg("当前股票已跌停不能卖出"); |
| | | } |
| | | |
| | | Integer buy_num = userPosition.getOrderNum(); |
| | | |