新版仿ok交易所-后端
1
zj
19 hours ago 640ccb9229224642515527daf87f308a7aa9bdf4
trading-order-admin/src/main/java/com/yami/trading/api/controller/ApiContractOrderController.java
@@ -3,25 +3,26 @@
import com.yami.trading.bean.contract.domain.ContractOrder;
import com.yami.trading.bean.data.domain.Realtime;
import com.yami.trading.bean.item.domain.Item;
import com.yami.trading.bean.model.Wallet;
import com.yami.trading.common.domain.Result;
import com.yami.trading.common.exception.YamiShopBindException;
import com.yami.trading.common.lang.LangUtils;
import com.yami.trading.common.util.StringUtils;
import com.yami.trading.common.util.ThreadUtils;
import com.yami.trading.security.common.util.SecurityUtils;
import com.yami.trading.service.WalletService;
import com.yami.trading.service.contract.ContractLockService;
import com.yami.trading.service.contract.ContractOrderService;
import com.yami.trading.service.data.DataService;
import com.yami.trading.service.item.ItemService;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
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 javax.servlet.http.HttpServletRequest;
import javax.validation.constraints.NotBlank;
import java.io.IOException;
import java.math.BigDecimal;
import java.math.RoundingMode;
@@ -44,6 +45,9 @@
    @Autowired
    private ContractLockService contractLockService;
    @Autowired
    WalletService walletService;
    private final String action = "/api/contractOrder!";
    /**
@@ -63,6 +67,39 @@
        }
        return Result.succeed("平仓成功");
    }
    @GetMapping(action + "addDepositOpen.action")
    @ApiOperation(value = "追加保证金")
    public Result<String> addDepositOpen(@RequestParam @NotBlank String orderNo, @RequestParam @NotBlank BigDecimal addDepositOpen) {
        try {
            ContractOrder order = this.contractOrderService.findByOrderNo(orderNo);
            if (order != null && order.getState().equals(ContractOrder.STATE_SUBMITTED) && order.getLocationType() == 0) {
                contractOrderService.addDepositOpen(order, addDepositOpen);
            }
        } catch (Exception e) {
            log.error("追加保证金异常", e);
            throw new YamiShopBindException("Failed to add margin");
        }
        return Result.succeed("success");
    }
    @GetMapping(action + "setStopPrice.action")
    @ApiOperation(value = "设置止盈止损")
    public Result<String> setStopPrice(@RequestParam @NotBlank String orderNo, @RequestParam @NotBlank BigDecimal stopPriceProfit,
                                       @RequestParam @NotBlank BigDecimal stopPriceLoss) {
        try {
            ContractOrder order = this.contractOrderService.findByOrderNo(orderNo);
            if (order != null && order.getState().equals(ContractOrder.STATE_SUBMITTED)) {
                order.setStopPriceProfit(stopPriceProfit);
                order.setStopPriceLoss(stopPriceLoss);
                contractOrderService.update(order);
            }
        } catch (Exception e) {
            log.error("追加保证金异常", e);
            throw new YamiShopBindException("Failed to add margin");
        }
        return Result.succeed("success");
    }
    /**
@@ -178,7 +215,7 @@
        if (null == order) {
            log.info("contractOrder!get order_no:" + order_no + ", order null");
            throw new YamiShopBindException("订单不存在");
            throw new YamiShopBindException("Order does not exist");
        }
        return Result.ok(this.contractOrderService.bulidOne(order));
@@ -219,10 +256,10 @@
        }
        if (!StringUtils.isInteger(page_no)) {
            throw new YamiShopBindException("页码不是整数");
            throw new YamiShopBindException("Page number must be an integer");
        }
        if (Integer.valueOf(page_no).intValue() <= 0) {
            throw new YamiShopBindException("页码不能小于等于0");
            throw new YamiShopBindException("Page number must be greater than 0");
        }
        String partyId = SecurityUtils.getCurrentUserId();