@Override public OrderTrade createOrderTrade(String mobile, String orderNo, String orderTime, String notifyUrl, Item item, MerchantInfo merchantInfo) { OrderTrade orderTrade = new OrderTrade(); orderTrade.setOrderStatus(OrderStatusEnum.CREATE.getCode()); orderTrade.setUserInfoId(merchantInfo.getUserInfoId()); orderTrade.setAcctInfoId(merchantInfo.getAcctInfoId()); orderTrade.setItemId(item.getId()); orderTrade.setItemNo(item.getItemNo()); orderTrade.setItemName(item.getItemName()); orderTrade.setItemCategory(item.getItemCategory()); orderTrade.setItemType(item.getItemType()); if (merchantInfo.getPriceLevel().equals(PriceLevelEnum.ONE.getCode())) { orderTrade.setSalesPrice(item.getSalesPrice1()); } else if (merchantInfo.getPriceLevel().equals(PriceLevelEnum.TWO.getCode())) { orderTrade.setSalesPrice(item.getSalesPrice2()); } else if (merchantInfo.getPriceLevel().equals(PriceLevelEnum.THREE.getCode())) { orderTrade.setSalesPrice(item.getSalesPrice3()); } else { orderTrade.setSalesPrice(item.getSalesPrice1()); orderTrade.setFacePrice(item.getFacePrice()); orderTrade.setCostPrice(item.getCostPrice()); orderTrade.setActualCost(orderTrade.getSalesPrice()); orderTrade.setMobile(mobile); orderTrade.setChannel(ChannelEnum.API.getCode()); orderTrade.setTradeNo(NOUtil.getTradeNo()); // 平台订单号 orderTrade.setOrderNo(orderNo); orderTrade.setOrderTime(DateUtil.parse(orderTime)); orderTrade.setCarrierType(item.getCarrierType()); orderTrade.setSupplyDesc("");
@Override public void notifyMsg(OrderTrade orderTrade) { TreeMap<String, Object> map = new TreeMap<>(); map.put("tradeNo", orderTrade.getTradeNo()); map.put("orderNo", orderTrade.getOrderNo()); map.put("orderStatus", orderTrade.getOrderStatus()); map.put("amont", orderTrade.getFacePrice()); if (ItemCategoryEnum.EXCHANGE.getCode().equals(orderTrade.getItemCategory())) { // 兑换通知 map.put("cardNo", orderTrade.getCardNo()); } else if (ItemCategoryEnum.RECHARGE.getCode().equals(orderTrade.getItemCategory())) { // 充值通知 map.put("mobile", orderTrade.getMobile()); } else { logger.warn("未知商品类型={}", orderTrade.getItemCategory()); return; } /*String result = HttpRestUtil.postForObject(orderTrade.getNotifyUrl(), map, String.class); logger.warn("通知下游:url={},参数={},返回={}", orderTrade.getNotifyUrl(), map, result); if (!"success".equalsIgnoreCase(result)) { // 失败,继续重复通知 try { Thread.sleep(10000L); } catch (InterruptedException e) { logger.error("线程出错", e.getMessage()); } result = HttpRestUtil.postForObject(orderTrade.getNotifyUrl(), map, String.class); }*/ }
private Result<ExchangeOrderResponse> completeExchangeOrderResponse(OrderTrade orderTrade) { ExchangeOrderResponse resp = new ExchangeOrderResponse(); resp.setTradeNo(orderTrade.getTradeNo()); resp.setOrderNo(orderTrade.getOrderNo()); resp.setProductNo(orderTrade.getItemNo()); resp.setProductType(orderTrade.getItemType()); resp.setMoblie(orderTrade.getMobile()); resp.setFacePrice(orderTrade.getFacePrice()); resp.setSalesPrice(orderTrade.getSalesPrice()); return Result.success(resp); }
private Result<ExchangeResponse> completeExchangeResponse(OrderTrade orderTrade) { ExchangeResponse resp = new ExchangeResponse(); resp.setAmount(orderTrade.getMobile()); resp.setCardNo(orderTrade.getCardNo()); resp.setOrderNo(orderTrade.getOrderNo()); resp.setTradeNo(orderTrade.getTradeNo().toString()); return Result.success(resp); }
@Override public OrderSupply createOrderSupply(OrderTrade orderTrade, SupplyInfo supplyInfo) { OrderSupply orderSupply = new OrderSupply(); orderSupply.setOrderStatus(OrderStatusEnum.CREATE.getCode()); orderSupply.setOrderTradeNo(orderTrade.getTradeNo()); orderSupply.setItemSupplyId(orderTrade.getItemSupplyId()); orderSupply.setUserInfoId(orderTrade.getUserInfoId()); orderSupply.setItemId(orderTrade.getItemId()); orderSupply.setItemCategory(orderTrade.getItemCategory()); orderSupply.setItemType(orderTrade.getItemType()); orderSupply.setItemNo(orderTrade.getItemNo()); orderSupply.setItemName(orderTrade.getItemName()); orderSupply.setMobile(orderTrade.getMobile()); orderSupply.setSupplyInfoId(supplyInfo.getId()); orderSupply.setSupplyCode(supplyInfo.getSupplyCode()); orderSupply.setSupplyName(supplyInfo.getSupplyName()); orderSupply.setSupplySerialNo(IdWorker.getId()); orderSupply.setSupplyFacePrice(orderTrade.getFacePrice()); orderSupply.setSupplyCostPrice(orderTrade.getCostPrice()); orderSupply.setSupplyActualCost(orderTrade.getActualCost()); Long id = orderSupplyDao.save(orderSupply); orderSupply.setId(id); orderTrade.setSupplySerialNo(orderSupply.getSupplySerialNo()); return orderSupply; }
private OrderTradePay createOrderTradePay(OrderTrade orderTrade) { OrderTradePay orderTradePay = new OrderTradePay(); orderTradePay.setPayStatus(PayStatusEnum.CREATE.getCode()); orderTradePay.setPaySerialNo(IdWorker.getId()); orderTradePay.setOrderTradeNo(orderTrade.getTradeNo()); orderTradePay.setUserInfoId(orderTrade.getUserInfoId()); orderTradePay.setAcctInfoId(orderTrade.getAcctInfoId()); orderTradePay.setItemId(orderTrade.getItemId()); orderTradePay.setItemNo(orderTrade.getItemNo()); // 兑换类型为:加款 orderTradePay.setTradeType(TradeTypeEnum.ADD.getCode()); orderTradePay.setSalesPrice(orderTrade.getSalesPrice()); orderTradePay.setPayType(PayTypeEnum.BALANCE.getCode()); Long id = orderTradePayDao.save(orderTradePay); orderTradePay.setId(id); orderTrade.setPaySerialNo(orderTradePay.getPaySerialNo()); return orderTradePay; }
/** * 补兑换接口 */ public Result<OrderTrade> repairExchange(Long tradeNo) { OrderTrade orderTrade = exchangeManager.getOrderTradeByTradeNo(tradeNo); if (!OrderStatusEnum.FAIL.getCode().equals(orderTrade.getOrderStatus())) { // 不是失败的交易订单,不允许补充 return Result.error("不是失败的交易订单,不允许补充"); } orderTrade.setRepeatType(RepeatTypeEnum.YES.getCode()); orderTrade.setSupplyIndex(0); Result<OrderSupply> resultorderSupply = exchangeService.supplyExchange(orderTrade); if (!resultorderSupply.getCode().equals(ResultEnum.SUCCESS.getCode())) { // 失败 orderTrade.setSupplyDesc(resultorderSupply.getMsg()); orderTrade.setOrderStatus(OrderStatusEnum.FAIL.getCode()); exchangeManager.updateOrderTrade(orderTrade); return Result.error(resultorderSupply.getCode(), resultorderSupply.getMsg()); } return Result.success(orderTrade); }
private Result<RechargeResponse> completeRechargeResponse(OrderTrade orderTrade) { RechargeResponse resp = new RechargeResponse(); resp.setMoblie(orderTrade.getMobile()); resp.setOrderNo(orderTrade.getOrderNo()); resp.setTradeNo(orderTrade.getTradeNo().toString()); return Result.success(resp); }
private ExchangeBO createExchangeBO(OrderTrade orderTrade, SupplyInfo supplyInfo) { ExchangeBO exchangeBO = new ExchangeBO(); BeanUtils.copyProperties(supplyInfo, exchangeBO); exchangeBO.setNotifyUrl(NOTIFY_URL.replace("{supplyCode}", supplyInfo.getSupplyCode())); // 回调地址的设置 exchangeBO.setAmount(orderTrade.getFacePrice()); exchangeBO.setCardNo(orderTrade.getCardNo()); exchangeBO.setCardPwd(orderTrade.getCardPwd()); exchangeBO.setSupplySerialNo(orderTrade.getSupplySerialNo().toString());// 交易号 return exchangeBO; }
private RechargeBO createRechargeBO(OrderTrade orderTrade, SupplyInfo supplyInfo) { RechargeBO rechargeBO = new RechargeBO(); BeanUtils.copyProperties(supplyInfo, rechargeBO); rechargeBO.setNotifyUrl(NOTIFY_URL.replace("{supplyCode}", supplyInfo.getSupplyCode())); // 回调地址的设置 rechargeBO.setMobile(orderTrade.getMobile()); rechargeBO.setAmount(orderTrade.getFacePrice()); rechargeBO.setSupplySerialNo(orderTrade.getSupplySerialNo().toString());// 交易号 return rechargeBO; }
final Thread currentThread = Thread.currentThread(); final String threadName = currentThread.getName(); currentThread.setName(String.format(currentThread.getName() + "-供货线程(订单号:%d-供货单:%d-供货商品ID:%d-供货商ID:%s)", orderTrade.getTradeNo(), orderSupply.getSupplySerialNo(), orderSupply.getItemSupplyId(), orderSupply.getSupplyName())); final long time2 = System.currentTimeMillis();
public int updateById(OrderTradeQO qo) { OrderTrade record = new OrderTrade(); BeanUtils.copyProperties(qo, record); return dao.updateById(record); }
@Override public OrderSupply createOrderSupply(OrderTrade orderTrade, SupplyInfo supplyInfo) { OrderSupply orderSupply = new OrderSupply(); orderSupply.setOrderStatus(OrderStatusEnum.CREATE.getCode()); orderSupply.setOrderTradeNo(orderTrade.getTradeNo()); orderSupply.setItemSupplyId(orderTrade.getItemSupplyId()); orderSupply.setUserInfoId(orderTrade.getUserInfoId()); orderSupply.setItemId(orderTrade.getItemId()); orderSupply.setItemCategory(orderTrade.getItemCategory()); orderSupply.setItemType(orderTrade.getItemType()); orderSupply.setItemNo(orderTrade.getItemNo()); orderSupply.setItemName(orderTrade.getItemName()); orderSupply.setMobile(orderTrade.getMobile()); orderSupply.setSupplyInfoId(supplyInfo.getId()); orderSupply.setSupplyCode(supplyInfo.getSupplyCode()); orderSupply.setSupplyName(supplyInfo.getSupplyName()); orderSupply.setSupplySerialNo(IdWorker.getId()); orderSupply.setSupplyFacePrice(orderTrade.getFacePrice()); orderSupply.setSupplyCostPrice(orderTrade.getCostPrice()); orderSupply.setSupplyActualCost(orderTrade.getActualCost()); Long id = orderSupplyDao.save(orderSupply); orderSupply.setId(id); orderTrade.setSupplySerialNo(orderSupply.getSupplySerialNo()); return orderSupply; }
private Result<ExchangeOrderResponse> completeExchangeOrderResponse(OrderTrade orderTrade) { ExchangeOrderResponse resp = new ExchangeOrderResponse(); resp.setTradeNo(orderTrade.getTradeNo()); resp.setOrderNo(orderTrade.getOrderNo()); resp.setProductNo(orderTrade.getItemNo()); resp.setProductType(orderTrade.getItemType()); resp.setMoblie(orderTrade.getMobile()); resp.setFacePrice(orderTrade.getFacePrice()); resp.setSalesPrice(orderTrade.getSalesPrice()); return Result.success(resp); }
/** * 支付订单 */ private OrderTradePay createOrderTradePay(OrderTrade orderTrade) { OrderTradePay orderTradePay = new OrderTradePay(); orderTradePay.setPayStatus(PayStatusEnum.CREATE.getCode()); orderTradePay.setPaySerialNo(IdWorker.getId()); orderTradePay.setOrderTradeNo(orderTrade.getTradeNo()); orderTradePay.setUserInfoId(orderTrade.getUserInfoId()); orderTradePay.setAcctInfoId(orderTrade.getAcctInfoId()); orderTradePay.setItemId(orderTrade.getItemId()); orderTradePay.setItemNo(orderTrade.getItemNo()); orderTradePay.setTradeType(TradeTypeEnum.SUBTRACT.getCode()); orderTradePay.setSalesPrice(orderTrade.getSalesPrice()); orderTradePay.setPayType(PayTypeEnum.BALANCE.getCode()); Long id = orderTradePayDao.save(orderTradePay); orderTradePay.setId(id); orderTrade.setPaySerialNo(orderTradePay.getPaySerialNo()); return orderTradePay; }
OrderTrade orderTrade = rechargeManager.getOrderTradeByTradeNo(tradeNo); if (!OrderStatusEnum.FAIL.getCode().equals(orderTrade.getOrderStatus())) { orderTrade.setOrderStatus(OrderStatusEnum.FAIL.getCode()); orderTrade.setSupplyDesc(resultPay.getMsg()); rechargeManager.updateOrderTrade(orderTrade); logger.warn("充值业务-补充供货失败:失败原因={}", resultPay.getMsg()); orderTrade.setRepeatType(RepeatTypeEnum.YES.getCode()); orderTrade.setSupplyIndex(0); Result<OrderSupply> resultOrderSupply = rechargeService.supplyRecharge(orderTrade); if (!resultOrderSupply.getCode().equals(ResultEnum.SUCCESS.getCode())) { orderTrade.setSupplyDesc(resultOrderSupply.getMsg()); orderTrade.setOrderStatus(OrderStatusEnum.FAIL.getCode()); rechargeManager.updateOrderTrade(orderTrade); return Result.error(resultOrderSupply.getCode(), resultOrderSupply.getMsg());
final Thread currentThread = Thread.currentThread(); final String threadName = currentThread.getName(); currentThread.setName(String.format(currentThread.getName() + "-供货线程:(订单号:%d-供货单:%d-供货商品ID:%d-供货商ID:%s)", orderTrade.getTradeNo(), orderSupply.getSupplySerialNo(), orderSupply.getItemSupplyId(), orderSupply.getSupplyName())); final long time2 = System.currentTimeMillis();
@Override public OrderTrade createOrderTrade(ExchangeRequest exchangeRequest, Item item, MerchantInfo merchantInfo) { OrderTrade orderTrade = new OrderTrade(); orderTrade.setOrderStatus(OrderStatusEnum.CREATE.getCode()); orderTrade.setUserInfoId(merchantInfo.getUserInfoId()); orderTrade.setAcctInfoId(merchantInfo.getAcctInfoId()); orderTrade.setItemId(item.getId()); orderTrade.setItemNo(item.getItemNo()); orderTrade.setItemCategory(item.getItemCategory()); orderTrade.setItemName(item.getItemName()); orderTrade.setItemType(item.getItemType()); if (merchantInfo.getPriceLevel().equals(PriceLevelEnum.ONE.getCode())) { orderTrade.setSalesPrice(item.getSalesPrice1()); } else if (merchantInfo.getPriceLevel().equals(PriceLevelEnum.TWO.getCode())) { orderTrade.setSalesPrice(item.getSalesPrice2()); } else if (merchantInfo.getPriceLevel().equals(PriceLevelEnum.THREE.getCode())) { orderTrade.setSalesPrice(item.getSalesPrice3()); } else { orderTrade.setSalesPrice(item.getSalesPrice1()); orderTrade.setFacePrice(item.getFacePrice()); orderTrade.setCostPrice(item.getCostPrice()); orderTrade.setActualCost(orderTrade.getSalesPrice()); orderTrade.setMobile(""); orderTrade.setChannel(ChannelEnum.API.getCode()); orderTrade.setTradeNo(NOUtil.getTradeNo()); // 平台订单号 orderTrade.setOrderNo(exchangeRequest.getOrderNo()); orderTrade.setOrderTime(DateUtil.parse(exchangeRequest.getOrderTime())); orderTrade.setCarrierType(exchangeRequest.getCarrierType()); orderTrade.setSupplyDesc("");
@Override public void notifyMsg(OrderTrade orderTrade) { TreeMap<String, Object> map = new TreeMap<>(); map.put("tradeNo", orderTrade.getTradeNo()); map.put("orderNo", orderTrade.getOrderNo()); map.put("orderStatus", orderTrade.getOrderStatus()); map.put("amont", orderTrade.getFacePrice()); if (ItemCategoryEnum.EXCHANGE.getCode().equals(orderTrade.getItemCategory())) { // 兑换通知 map.put("cardNo", orderTrade.getCardNo()); } else if (ItemCategoryEnum.RECHARGE.getCode().equals(orderTrade.getItemCategory())) { // 充值通知 map.put("mobile", orderTrade.getMobile()); } else { logger.warn("未知商品类型={}", orderTrade.getItemCategory()); return; } /*String result = HttpRestUtil.postForObject(orderTrade.getNotifyUrl(), map, String.class); logger.warn("通知下游:url={},参数={},返回={}", orderTrade.getNotifyUrl(), map, result); if (!"success".equalsIgnoreCase(result)) { // 失败,继续重复通知 try { Thread.sleep(10000L); } catch (InterruptedException e) { logger.error("线程出错", e.getMessage()); } result = HttpRestUtil.postForObject(orderTrade.getNotifyUrl(), map, String.class); }*/ }
/** * 退款订单 */ private OrderTradePay createOrderTradePayForRefund(OrderTrade orderTrade) { OrderTradePay orderTradePay = new OrderTradePay(); orderTradePay.setPayStatus(PayStatusEnum.CREATE.getCode()); orderTradePay.setPaySerialNo(IdWorker.getId()); orderTradePay.setOrderTradeNo(orderTrade.getTradeNo()); orderTradePay.setUserInfoId(orderTrade.getUserInfoId()); orderTradePay.setAcctInfoId(orderTrade.getAcctInfoId()); orderTradePay.setItemId(orderTrade.getItemId()); orderTradePay.setItemNo(orderTrade.getItemNo()); orderTradePay.setTradeType(TradeTypeEnum.ADD.getCode()); orderTradePay.setSalesPrice(orderTrade.getSalesPrice()); orderTradePay.setPayType(PayTypeEnum.BALANCE.getCode()); Long id = orderTradePayDao.save(orderTradePay); orderTradePay.setId(id); orderTrade.setPaySerialNo(orderTradePay.getPaySerialNo()); return orderTradePay; }