| | |
| | | package com.nq.controller.backend; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.nq.common.ServerResponse; |
| | | |
| | | import com.nq.dao.UserPositionMapper; |
| | | import com.nq.enums.EConfigKey; |
| | | import com.nq.enums.EUserAssets; |
| | | import com.nq.pojo.UserAssets; |
| | | import com.nq.pojo.UserPosition; |
| | | import com.nq.service.IStockConfigServices; |
| | | import com.nq.service.IUserPositionService; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | |
| | | import com.nq.service.impl.UserAssetsServices; |
| | | import com.nq.utils.UserPointUtil; |
| | | import com.nq.utils.stock.GeneratePosition; |
| | | import com.nq.vo.position.PositionProfitVO; |
| | | import org.slf4j.Logger; |
| | | |
| | | import org.slf4j.LoggerFactory; |
| | |
| | | import org.springframework.web.bind.annotation.ResponseBody; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | |
| | | @Controller |
| | |
| | | @Autowired |
| | | IUserPositionService iUserPositionService; |
| | | |
| | | @Autowired |
| | | UserPositionMapper userPositionMapper; |
| | | |
| | | @Autowired |
| | | IStockConfigServices iStockConfigServices; |
| | | |
| | | @Autowired |
| | | UserAssetsServices userAssetsServices; |
| | | |
| | | |
| | | //分页查询持仓管理 融资持仓单信息/融资平仓单信息及模糊查询 |
| | | @RequestMapping({"list.do"}) |
| | | @ResponseBody |
| | | public ServerResponse list(@RequestParam(value = "agentId", required = false) |
| | | Integer agentId, @RequestParam(value = "positionType", required = false) Integer positionType, @RequestParam(value = "state", required = false) Integer state, @RequestParam(value = "userId", required = false) Integer userId, @RequestParam(value = "positionSn", required = false) String positionSn, @RequestParam(value = "beginTime", required = false) String beginTime, @RequestParam(value = "endTime", required = false) String endTime, @RequestParam(value = "pageNum", defaultValue = "1") |
| | | int pageNum, @RequestParam(value = "pageSize", defaultValue = "12") int pageSize, @RequestParam(value = "phone", required = false) String phone,HttpServletRequest request) { |
| | | return this.iUserPositionService.listByAdmin(agentId, positionType, state, userId, positionSn, beginTime, endTime, pageNum, pageSize,phone); |
| | | int pageNum, @RequestParam(value = "pageSize", defaultValue = "12") int pageSize, @RequestParam(value = "phone", required = false) String phone,@RequestParam(value = "productType", required = false) String productType,HttpServletRequest request) { |
| | | return this.iUserPositionService.listByAdmin(agentId, positionType, state, userId, positionSn, beginTime, endTime, pageNum, pageSize,phone,productType); |
| | | } |
| | | |
| | | //持仓管理 强制平仓操作 |
| | |
| | | return this.iUserPositionService.del(positionId); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * |
| | | * @param price 爆仓价格 |
| | | * @param name 产品名字 |
| | | * @param direction 方向 1 买涨 2 买跌 |
| | | * @return |
| | | */ |
| | | @RequestMapping({"blastingWarehouse.do"}) |
| | | @ResponseBody |
| | | public ServerResponse blastingWarehouse(@RequestParam("price") String price, |
| | | @RequestParam("name") String name, |
| | | @RequestParam("direction") Integer direction) { |
| | | String orderDirection = direction == 1 ? "买涨" : "买跌"; |
| | | List<UserPosition> userPositions = userPositionMapper.selectList(new LambdaQueryWrapper<>(UserPosition.class) |
| | | .eq(UserPosition::getStockName, name) |
| | | .eq(UserPosition::getOrderDirection, orderDirection) |
| | | .eq(UserPosition::getStockCode, "HJYY") |
| | | .isNull(UserPosition::getSellOrderId) |
| | | ); |
| | | // 手续费率 |
| | | BigDecimal siitteBuyFee = new BigDecimal(iStockConfigServices.queryByKey(EConfigKey.SELL_HANDLING_CHARGE.getCode()).getCValue()); |
| | | userPositions.forEach(f->{ |
| | | f.setSellOrderId(GeneratePosition.getPositionId()); |
| | | f.setSellOrderPrice(new BigDecimal(price)); |
| | | f.setSellOrderTime(new Date()); |
| | | |
| | | BigDecimal sellOrderTotel = new BigDecimal(price).multiply(new BigDecimal(f.getOrderNum())); |
| | | BigDecimal xsPrice = sellOrderTotel.multiply(siitteBuyFee); |
| | | f.setOrderFee(f.getOrderFee().add(xsPrice)); |
| | | userPositionMapper.updateById(f); |
| | | UserAssets userAssets = userAssetsServices.assetsByTypeAndUserId("USD", f.getUserId()); |
| | | userAssets.setFreezeMoney(userAssets.getFreezeMoney().subtract(f.getOrderTotalPrice())); |
| | | userAssetsServices.availablebalanceChange("USD", |
| | | f.getUserId(), |
| | | EUserAssets.CALL, |
| | | f.getOrderTotalPrice(), "", ""); |
| | | }); |
| | | return ServerResponse.createBySuccessMsg("执行成功!"); |
| | | } |
| | | |
| | | |
| | | |
| | | //创建持仓单 |
| | | @RequestMapping({"create.do"}) |
| | | @ResponseBody |