From 27d2ae09aa2acb4bdafc471530466a7a4f45ade2 Mon Sep 17 00:00:00 2001 From: = <=> Date: Sat, 7 Aug 2021 08:33:52 +0800 Subject: [PATCH] =?UTF-8?q?'=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cweb/controller/HighTestController.java | 14 +++++++++++++ .../cweb/controller/pay/OrderController.java | 21 ++++++++++++++++++- .../com/hai/schedule/HighGasSchedule.java | 1 + .../java/com/hai/config/TuanYouConfig.java | 17 ++++++++++++++- 4 files changed, 51 insertions(+), 2 deletions(-) diff --git a/hai-cweb/src/main/java/com/cweb/controller/HighTestController.java b/hai-cweb/src/main/java/com/cweb/controller/HighTestController.java index e2456d69..7f59efa2 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/HighTestController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/HighTestController.java @@ -7,6 +7,7 @@ import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; import com.hai.common.pay.util.sdk.WXPayConstants; import com.hai.common.utils.*; +import com.hai.config.CommonSysConst; import com.hai.config.HuiLianTongConfig; import com.hai.config.QianZhuConfig; import com.hai.config.TuanYouConfig; @@ -82,6 +83,7 @@ public class HighTestController { store.setAddress(object.getString("gasAddress")); store.setLongitude(object.getString("gasAddressLongitude")); store.setLatitude(object.getString("gasAddressLatitude")); + store.setStatus(object.getInteger("gasStatus")); store.setOperatorId(0L); store.setOperatorName("系统创建"); store.setUpdateTime(new Date()); @@ -205,4 +207,16 @@ public class HighTestController { } } + @RequestMapping(value = "/queryOilCardAccount", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "测试") + public ResponseData queryOilCardAccount() { + try { + return ResponseMsgUtil.success(TuanYouConfig.queryCompanyAccountInfo2JD()); + } catch (Exception e) { + log.error("HighOrderController --> queryOilCardAccount() error!", e); + return ResponseMsgUtil.exception(e); + } + } + } diff --git a/hai-cweb/src/main/java/com/cweb/controller/pay/OrderController.java b/hai-cweb/src/main/java/com/cweb/controller/pay/OrderController.java index c4babf63..bd89c1d0 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/pay/OrderController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/pay/OrderController.java @@ -1,6 +1,7 @@ package com.cweb.controller.pay; import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.cweb.config.SysConst; import com.hai.common.exception.ErrorCode; @@ -17,6 +18,7 @@ import com.hai.common.utils.HttpsUtils; import com.hai.common.utils.MathUtils; import com.hai.common.utils.ResponseMsgUtil; import com.hai.config.QianZhuConfig; +import com.hai.config.TuanYouConfig; import com.hai.entity.HighChildOrder; import com.hai.entity.HighCoupon; import com.hai.entity.HighOrder; @@ -128,7 +130,7 @@ public class OrderController { throw ErrorHelp.genException(SysCode.System, ErrorCode.ORDER_NO_STAY_PAY, ""); } - // 商品类型 1:卡卷 2:金币充值 + // 商品类型 1:卡卷 2:金币充值 3:加油站 for (HighChildOrder childOrder : order.getHighChildOrderList()) { if (childOrder.getGiveawayType() == false && childOrder.getGoodsType() == 1) { HighCoupon coupon = highCouponService.getCouponById(childOrder.getGoodsId()); @@ -138,6 +140,23 @@ public class OrderController { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, coupon.getCouponName() + ",只支持微信支付"); } } + + if (childOrder.getGoodsType() == 3) { + // 查询账号余额 + JSONObject accountInfo2JD = TuanYouConfig.queryCompanyAccountInfo2JD(); + JSONArray result = accountInfo2JD.getJSONArray("result"); + for (Object accountObject : result) { + JSONObject account = (JSONObject)accountObject; + // 1:汽油:2:柴油;3:天然气 + if (account.getInteger("energyType") == childOrder.getGasOilType()) { + // 支付金额 大于 团油账号余额 + if(order.getPayPrice().compareTo(account.getBigDecimal("accountBalance")) == 1){ + log.error("OrderController --> orderToPay() ERROR", "无法进行支付,请联系平台客服"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法进行支付,请联系平台客服"); + } + } + } + } } Map map = new HashMap<>(); diff --git a/hai-schedule/src/main/java/com/hai/schedule/HighGasSchedule.java b/hai-schedule/src/main/java/com/hai/schedule/HighGasSchedule.java index ea47fff2..bae704b1 100644 --- a/hai-schedule/src/main/java/com/hai/schedule/HighGasSchedule.java +++ b/hai-schedule/src/main/java/com/hai/schedule/HighGasSchedule.java @@ -66,6 +66,7 @@ public class HighGasSchedule { store.setAddress(object.getString("gasAddress")); store.setLongitude(object.getString("gasAddressLongitude")); store.setLatitude(object.getString("gasAddressLatitude")); + store.setStatus(object.getInteger("gasStatus")); store.setOperatorId(0L); store.setOperatorName("系统创建"); store.setUpdateTime(new Date()); diff --git a/hai-service/src/main/java/com/hai/config/TuanYouConfig.java b/hai-service/src/main/java/com/hai/config/TuanYouConfig.java index 65b9e4db..aafda12a 100644 --- a/hai-service/src/main/java/com/hai/config/TuanYouConfig.java +++ b/hai-service/src/main/java/com/hai/config/TuanYouConfig.java @@ -103,6 +103,20 @@ public class TuanYouConfig { return HttpsUtils.doPost(CommonSysConst.getSysConfig().getTuanYouUrl()+"/services/vp/openapi/refuelingOrderRefund", JSON.toJSONString(paramMap)); } + /** + * queryCompanyAccountBalance + * @return 企业余额查询(多能源类型) + * @throws Exception + */ + public static JSONObject queryCompanyAccountInfo2JD() throws Exception { + Map paramMap = new HashMap<>(); + paramMap.put("app_key", CommonSysConst.getSysConfig().getTuanYouAppKey()); + paramMap.put("timestamp", new Date().getTime()); + paramMap.put("companyCode", CommonSysConst.getSysConfig().getTuanYouAppKey()); + paramMap.put("sign", MD5Util.encode(generateTuanYouSignature(paramMap,CommonSysConst.getSysConfig().getTuanYouAppSecret()).getBytes()).toLowerCase()); + return HttpsUtils.doPost(CommonSysConst.getSysConfig().getTuanYouUrl()+"/services/vp/openapi/queryCompanyAccountInfo2JD", JSON.toJSONString(paramMap)); + } + /** * 订单结果查询 * @param thirdSerialNo 三方订单号 @@ -113,9 +127,10 @@ public class TuanYouConfig { Map paramMap = new HashMap<>(); paramMap.put("app_key", CommonSysConst.getSysConfig().getTuanYouAppKey()); paramMap.put("timestamp", new Date().getTime()); + paramMap.put("companyCode", "new Date().getTime()"); paramMap.put("thirdSerialNo", thirdSerialNo); paramMap.put("sign", MD5Util.encode(generateTuanYouSignature(paramMap,CommonSysConst.getSysConfig().getTuanYouAppSecret()).getBytes()).toLowerCase()); - return HttpsUtils.doPost(CommonSysConst.getSysConfig().getTuanYouUrl()+"/services/vp/openapi/queryThirdOrderDetail", JSON.toJSONString(paramMap)); + return HttpsUtils.doPost(CommonSysConst.getSysConfig().getTuanYouUrl()+"/services/vp/openapi/queryCompanyAccountInfo2JD", JSON.toJSONString(paramMap)); } /**