| | |
| | | List<ContractApplyOrder> list = this.contractApplyOrderService.findSubmitted(); |
| | | for (int i = 0; i < list.size(); i++) { |
| | | ContractApplyOrder order = list.get(i); |
| | | ContractApplyOrder latest = this.contractApplyOrderService.findByOrderNo(order.getOrderNo()); |
| | | if (latest == null || !ContractApplyOrder.STATE_SUBMITTED.equals(latest.getState())) { |
| | | continue; |
| | | } |
| | | order = latest; |
| | | List<Realtime> realtime_list = this.dataService.realtime(order.getSymbol()); |
| | | Realtime realtime = null; |
| | | if (realtime_list.size() > 0) { |
| | |
| | | public void handle(ContractApplyOrder applyOrder, Realtime realtime) { |
| | | boolean lock = false; |
| | | try { |
| | | applyOrder = this.contractApplyOrderService.findByOrderNo(applyOrder.getOrderNo()); |
| | | if (applyOrder == null || !ContractApplyOrder.STATE_SUBMITTED.equals(applyOrder.getState())) { |
| | | return; |
| | | } |
| | | if (!ContractLock.add(applyOrder.getOrderNo())) { |
| | | return; |
| | | } |
| | |
| | | |
| | | } |
| | | |
| | | } catch (YamiShopBindException e) { |
| | | log.error("委托单处理失败 orderNo={}, msg={}", applyOrder.getOrderNo(), e.getMessage()); |
| | | if (isInsufficientFunds(e)) { |
| | | this.contractApplyOrderService.saveCancel(applyOrder.getPartyId(), applyOrder.getOrderNo()); |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("error:", e); |
| | | } finally { |
| | |
| | | } |
| | | |
| | | } |
| | | |
| | | private boolean isInsufficientFunds(YamiShopBindException e) { |
| | | if (e.getMessage() == null) { |
| | | return false; |
| | | } |
| | | String msg = e.getMessage().toLowerCase(); |
| | | return msg.contains("not sufficient funds") || msg.contains("余额不足"); |
| | | } |
| | | |
| | | public void start(){ |
| | | new Thread(this, "ContractApplyOrderHandleJob").start(); |
| | | if (log.isInfoEnabled()) |