| | |
| | | DecimalFormat df = new DecimalFormat("#.########"); |
| | | C2cAdvert c2cAdvert = this.c2cAdvertService.getById(c2cOrder.getC2cAdvertId()); |
| | | if (null == c2cAdvert) { |
| | | throw new YamiShopBindException("广告不存在"); |
| | | throw new YamiShopBindException("Advertisement does not exist"); |
| | | } |
| | | // double symbolClose = symbolClose(c2cOrder.getSymbol()); |
| | | double symbolClose = c2cAdvert.getSymbolClose(); |
| | |
| | | this.updateNofinishOrderCount(c2cOrder); |
| | | C2cUser c2cUser = this.c2cUserService.getById(c2cOrder.getC2cUserId()); |
| | | if (null == c2cUser) { |
| | | throw new YamiShopBindException("承兑商不存在"); |
| | | throw new YamiShopBindException("Merchant does not exist"); |
| | | } |
| | | if (C2cOrder.DIRECTION_BUY.equals(c2cOrder.getDirection())) { |
| | | // 买币 |
| | |
| | | public void savePass(C2cOrder c2cOrder, String safeword, String operator_username) { |
| | | |
| | | if ("3".equals(c2cOrder.getState())) { |
| | | throw new YamiShopBindException("订单已完成,无法放行"); |
| | | throw new YamiShopBindException("Order completed, cannot release"); |
| | | } |
| | | if ("4".equals(c2cOrder.getState())) { |
| | | throw new YamiShopBindException("订单已取消,无法放行"); |
| | | throw new YamiShopBindException("Order cancelled, cannot release"); |
| | | } |
| | | saveOrderPass(c2cOrder); |
| | | User order_user = userService.getById(c2cOrder.getPartyId()); |
| | |
| | | |
| | | DecimalFormat df = new DecimalFormat("#.########"); |
| | | if ("4".equals(c2cOrder.getState())) { |
| | | throw new YamiShopBindException("该订单已取消"); |
| | | throw new YamiShopBindException("Order has been cancelled"); |
| | | } |
| | | if ("3".equals(c2cOrder.getState())) { |
| | | throw new YamiShopBindException("该订单已完成"); |
| | | throw new YamiShopBindException("Order has been completed"); |
| | | } |
| | | if ("recharge".equals(c2cOrder.getDirection())) { |
| | | // 充值 |
| | |
| | | @Transactional |
| | | public void manualRelease(C2cOrder c2cOrder, String operator_username) { |
| | | if ("3".equals(c2cOrder.getState())) { |
| | | throw new YamiShopBindException("订单已完成,无法放行"); |
| | | throw new YamiShopBindException("Order completed, cannot release"); |
| | | } |
| | | if ("4".equals(c2cOrder.getState())) { |
| | | throw new YamiShopBindException("订单已取消,无法放行"); |
| | | throw new YamiShopBindException("Order cancelled, cannot release"); |
| | | } |
| | | |
| | | DecimalFormat df = new DecimalFormat("#.########"); |
| | |
| | | public void orderCancel(String id, String reason) { |
| | | // C2cOrder c2cOrder= getById(id); |
| | | // if (c2cOrder==null){ |
| | | // throw new YamiShopBindException("参数错误!"); |
| | | // throw new YamiShopBindException("Invalid parameters!"); |
| | | // } |
| | | // if (c2cOrder.getStatus()!=0){ |
| | | // throw new YamiShopBindException("订单已操作过了!"); |
| | | // throw new YamiShopBindException("Order already processed!"); |
| | | // } |
| | | // Date now=new Date(); |
| | | // c2cOrder.setStatus(4); |
| | |
| | | log.error("saveOpen start:"+remark); |
| | | C2cAdvert c2cAdvert = this.c2cAdvertService.getById(c2cOrder.getC2cAdvertId()); |
| | | if (null == c2cAdvert) { |
| | | throw new YamiShopBindException("广告不存在"); |
| | | throw new YamiShopBindException("Advertisement does not exist"); |
| | | } |
| | | |
| | | if (1 != c2cAdvert.getOnSale()) { |
| | | throw new YamiShopBindException("广告已下架"); |
| | | throw new YamiShopBindException("Advertisement has been delisted"); |
| | | } |
| | | |
| | | User party =userService.getById(c2cOrder.getPartyId()); |
| | | if (null == party) { |
| | | throw new YamiShopBindException("用户信息不存在"); |
| | | throw new YamiShopBindException("User info does not exist"); |
| | | } |
| | | |
| | | C2cUser c2cUser = this.c2cUserService.getById(c2cAdvert.getC2cUserId()); |
| | | if (null == c2cUser) { |
| | | throw new YamiShopBindException("承兑商不存在"); |
| | | throw new YamiShopBindException("Merchant does not exist"); |
| | | } |
| | | User c2cParty =userService.getById(c2cUser.getC2cUserPartyId()); |
| | | |
| | | if (null == c2cParty) { |
| | | throw new YamiShopBindException("承兑商的用户信息不存在"); |
| | | throw new YamiShopBindException("Merchant user info does not exist"); |
| | | } |
| | | |
| | | C2cPaymentMethod method = this.c2cPaymentMethodService.get(c2cOrder.getPaymentMethodId()); |
| | | if (null == method) { |
| | | throw new YamiShopBindException("支付方式不存在"); |
| | | throw new YamiShopBindException("Payment method does not exist"); |
| | | } |
| | | |
| | | if (C2cAdvert.DIRECTION_SELL.equals(c2cAdvert.getDirection())) { |
| | | |
| | | if (!party.isWithdrawAuthority()) { |
| | | throw new YamiShopBindException( "无权限"); |
| | | throw new YamiShopBindException( "Permission denied"); |
| | | } |
| | | |
| | | this.checkSellAuth(c2cOrder.getPartyId()); |
| | | this.checkSellNum(c2cOrder.getPartyId()); |
| | | |
| | | if (!method.getPartyId().equals(c2cOrder.getPartyId())) { |
| | | throw new YamiShopBindException("支付方式不匹配该用户"); |
| | | throw new YamiShopBindException("Payment method does not match this user"); |
| | | } |
| | | } else { |
| | | |
| | | if (!method.getPartyId().equals(c2cUser.getC2cUserPartyId())) { |
| | | throw new YamiShopBindException("支付方式不匹配该承兑商"); |
| | | throw new YamiShopBindException("Payment method does not match this merchant"); |
| | | } |
| | | } |
| | | |
| | |
| | | // 卖币 |
| | | this.saveSell(c2cOrder, c2cAdvert, symbolValue,remark); |
| | | } else { |
| | | throw new YamiShopBindException("买卖方式不正确"); |
| | | throw new YamiShopBindException("Invalid buy/sell method"); |
| | | } |
| | | |
| | | this.tipService.saveNewTip(c2cOrder.getUuid().toString(), TipConstants.C2C_ORDER,remark); |
| | |
| | | log.error("save save end::"+remark); |
| | | // 买入金额需要在区间内 |
| | | if (c2cOrder.getAmount() > c2cAdvert.getInvestmentMax() || c2cOrder.getAmount() < c2cAdvert.getInvestmentMin()) { |
| | | throw new YamiShopBindException("金额不在购买区间"); |
| | | throw new YamiShopBindException("Amount is outside purchase range"); |
| | | } |
| | | |
| | | double amountBefore = 0d; |
| | |
| | | |
| | | Wallet wallet = this.walletService.saveWalletByPartyId(c2cOrder.getPartyId()); |
| | | if (c2cOrder.getCoinAmount() > wallet.getMoney().doubleValue()) { |
| | | throw new YamiShopBindException("用户剩余数量不足"); |
| | | throw new YamiShopBindException("Insufficient user remaining quantity"); |
| | | } |
| | | |
| | | amountBefore = wallet.getMoney().doubleValue(); |
| | |
| | | WalletExtend walletExtend = this.walletService.saveExtendByPara(c2cOrder.getPartyId(), c2cOrder.getSymbol()); |
| | | |
| | | if (c2cOrder.getCoinAmount() > walletExtend.getAmount()) { |
| | | throw new YamiShopBindException("用户剩余数量不足"); |
| | | throw new YamiShopBindException("Insufficient user remaining quantity"); |
| | | } |
| | | |
| | | amountBefore = walletExtend.getAmount(); |
| | |
| | | double coin_amount = Double.valueOf(df.format(Arith.div(c2cOrder.getAmount(), symbol_value))).doubleValue(); |
| | | |
| | | if (coin_amount > c2cAdvert.getCoinAmount()) { |
| | | throw new YamiShopBindException("该广告剩余数量不足"); |
| | | throw new YamiShopBindException("Insufficient advertisement remaining quantity"); |
| | | } |
| | | |
| | | c2cOrder.setCoinAmount(coin_amount); |
| | |
| | | // 按币种数量支付 |
| | | |
| | | if (c2cOrder.getCoinAmount() > c2cAdvert.getCoinAmount()) { |
| | | throw new YamiShopBindException("该广告剩余数量不足"); |
| | | throw new YamiShopBindException("Insufficient advertisement remaining quantity"); |
| | | } |
| | | |
| | | c2cOrder.setAmount(Double.valueOf(df.format(Arith.mul(c2cOrder.getCoinAmount(), symbol_value))).doubleValue()); |
| | |
| | | log.error("buy save end:"+remark); |
| | | // 买入金额需要在区间内 |
| | | if (c2cOrder.getAmount() > c2cAdvert.getInvestmentMax() || c2cOrder.getAmount() < c2cAdvert.getInvestmentMin()) { |
| | | throw new YamiShopBindException("金额不在购买区间"); |
| | | throw new YamiShopBindException("Amount is outside purchase range"); |
| | | } |
| | | |
| | | c2cAdvert.setSortIndex(0); |
| | |
| | | |
| | | C2cOrder c2cOrder = get(order_no); |
| | | if (null == c2cOrder) { |
| | | throw new YamiShopBindException("订单不存在"); |
| | | throw new YamiShopBindException("Order does not exist"); |
| | | } |
| | | List<String> typeList=new ArrayList<>(); |
| | | if (c2cOrderFlag){ |
| | | C2cAdvert c2cAdvert = c2cAdvertService.getById(c2cOrder.getC2cAdvertId()); |
| | | if (null == c2cAdvert) { |
| | | throw new YamiShopBindException("广告不存在"); |
| | | throw new YamiShopBindException("Advertisement does not exist"); |
| | | } |
| | | String [] types = c2cAdvert.getPayType().split(","); |
| | | typeList = Arrays.asList(types); |
| | |
| | | |
| | | C2cOrder c2cOrder = get(order_no); |
| | | if (null == c2cOrder) { |
| | | throw new YamiShopBindException("订单不存在"); |
| | | throw new YamiShopBindException("Order does not exist"); |
| | | } |
| | | if (!Arrays.asList("0", "2").contains(c2cOrder.getState())) { |
| | | throw new YamiShopBindException("订单不处于待支付或申诉中状态,无法转账"); |
| | | throw new YamiShopBindException("Order is not pending payment or appeal, cannot transfer"); |
| | | } |
| | | C2cPaymentMethod method = this.c2cPaymentMethodService.get(payment_method_id_order_pay); |
| | | // 更新最终的支付方式 |
| | |
| | | |
| | | C2cPaymentMethod method = c2cPaymentMethodService.get(c2cOrder.getPaymentMethodId()); |
| | | if (null == method) { |
| | | throw new YamiShopBindException("支付方式不存在"); |
| | | throw new YamiShopBindException("Payment method does not exist"); |
| | | } |
| | | if ("withdraw".equals(c2cOrder.getDirection())) { |
| | | String partyId = party.getUserId(); |
| | | if (!method.getPartyId().equals(partyId)) { |
| | | throw new YamiShopBindException("支付方式不匹配该用户"); |
| | | throw new YamiShopBindException("Payment method does not match this user"); |
| | | } |
| | | } else { |
| | | // if (!method.getPartyId().equals("2c948a8282920a9f01829270bcac0000")) { |
| | | // throw new YamiShopBindException("支付方式不匹配官方"); |
| | | // throw new YamiShopBindException("Payment method does not match official account"); |
| | | // } |
| | | } |
| | | int expireTime = 45; |
| | |
| | | // 提现 |
| | | this.saveWithdraw(c2cOrder); |
| | | } else { |
| | | throw new YamiShopBindException("充值或提现不正确"); |
| | | throw new YamiShopBindException("Invalid deposit or withdrawal type"); |
| | | } |
| | | } |
| | | |
| | |
| | | DecimalFormat df = new DecimalFormat("#.########"); |
| | | Wallet wallet = this.walletService.saveWalletByPartyId(c2cOrder.getPartyId()); |
| | | if (c2cOrder.getCoinAmount() > wallet.getMoney().doubleValue()) { |
| | | throw new YamiShopBindException("余额不足"); |
| | | throw new YamiShopBindException("Insufficient balance"); |
| | | } |
| | | double amountBefore = wallet.getMoney().doubleValue(); |
| | | double amountAfter = Double.valueOf(df.format(Arith.sub(wallet.getMoney().doubleValue(), c2cOrder.getCoinAmount()))).doubleValue(); |
| | |
| | | // 用户未完成USDT订单 |
| | | List<RechargeBlockchainOrder> orders = rechargeBlockchainOrderService.findByPartyIdAndSucceeded(party.getUserId(), 0); |
| | | if (null != orders && 1 == recharge_only_one) { |
| | | throw new YamiShopBindException("提交失败,当前有未处理USDT订单"); |
| | | throw new YamiShopBindException("Submission failed, pending USDT order exists"); |
| | | } |
| | | // 用户未结束银行卡订单数量 |
| | | Long nofinishOrderCount = this.getNofinishOrderCount(c2cOrder.getPartyId()); |
| | | if (null != nofinishOrderCount && 0 != nofinishOrderCount.longValue() && 1 == recharge_only_one) { |
| | | throw new YamiShopBindException("提交失败,当前有未处理银行卡订单"); |
| | | throw new YamiShopBindException("Submission failed, pending bank card order exists"); |
| | | } |
| | | double recharge_limit_min = Double.valueOf(this.sysparaService.find("recharge_limit_min").getSvalue()); |
| | | double recharge_limit_max = Double.valueOf(this.sysparaService.find("recharge_limit_max").getSvalue()); |
| | | if (c2cOrder.getCoinAmount() < recharge_limit_min) { |
| | | log.info(c2cOrder.getCoinAmount() + "====================================" + recharge_limit_min); |
| | | throw new YamiShopBindException("充值数量不得小于最小限额"); |
| | | throw new YamiShopBindException("Recharge amount must not be less than the minimum limit"); |
| | | } |
| | | if (c2cOrder.getCoinAmount() > recharge_limit_max) { |
| | | throw new YamiShopBindException("充值数量不得大于最大限额"); |
| | | throw new YamiShopBindException("Recharge amount must not exceed the maximum limit"); |
| | | } |
| | | this.save(c2cOrder); |
| | | this.tipService.saveTip(c2cOrder.getUuid().toString(), TipConstants.BANK_CARD_ORDER); |