From 37fc74869d32c46b12093c46237ec93d858e69e6 Mon Sep 17 00:00:00 2001 From: hurui <177768073@qq.com> Date: Tue, 22 Mar 2022 16:18:02 +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/HighOrderController.java | 9 +++- .../cweb/controller/pay/OrderController.java | 54 ++++++++++++++++--- .../controller/pay/UnionPayController.java | 2 +- .../java/com/hai/dao/HighOrderMapperExt.java | 4 ++ .../com/hai/service/HighOrderService.java | 7 +++ .../service/impl/HighOrderServiceImpl.java | 5 ++ 6 files changed, 70 insertions(+), 11 deletions(-) diff --git a/hai-cweb/src/main/java/com/cweb/controller/HighOrderController.java b/hai-cweb/src/main/java/com/cweb/controller/HighOrderController.java index 612ecd33..a3026978 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/HighOrderController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/HighOrderController.java @@ -206,9 +206,14 @@ public class HighOrderController { log.error("HighOrderController --> addOrder() error!", "参数错误"); throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); } - if (childOrder.getGoodsPrice().compareTo(new BigDecimal("500")) == 1){ - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "加油金额不能超过500元"); + if (childOrder.getGoodsPrice().compareTo(new BigDecimal("800")) == 1){ + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "加油金额不能超过800元"); } + + if (highOrderService.getGasTheDayOrderNum(userInfoModel.getHighUser().getId()) >= 1) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "已达到每日加油次数上限"); + } + // 查询门店 HighMerchantStoreModel store = highMerchantStoreService.getMerchantStoreById(childOrder.getGoodsId()); if (store == null) { 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 966e43c1..081deb3e 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 @@ -156,6 +156,9 @@ public class OrderController { } if (childOrder.getGoodsType() == 3) { + if (highOrderService.getGasTheDayOrderNum(order.getMemId()) >= 1) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "已达到每日加油次数上限"); + } // 查询账号余额 JSONObject accountInfo2JD = TuanYouConfig.queryCompanyAccountInfo2JD(); JSONArray result = accountInfo2JD.getJSONArray("result"); @@ -286,6 +289,27 @@ public class OrderController { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, coupon.getCouponName() + ",只支持积分支付"); } } + + if (childOrder.getGoodsType() == 3) { + if (highOrderService.getGasTheDayOrderNum(order.getMemId()) >= 1) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "已达到每日加油次数上限"); + } + // 查询账号余额 + 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, "无法进行支付,请联系平台客服"); + } + } + } + } + } highOrderService.goldPayOrder(order.getMemId(), order.getId()); @@ -369,17 +393,28 @@ public class OrderController { throw ErrorHelp.genException(SysCode.System, ErrorCode.ORDER_NO_STAY_PAY, ""); } -/* // 商品类型 1:卡卷 2:金币充值 + // 商品类型 1:卡卷 2:金币充值 for (HighChildOrder childOrder : order.getHighChildOrderList()) { - if (childOrder.getGoodsType() == 2) { - HighCoupon coupon = highCouponService.getCouponById(childOrder.getGoodsId()); - // 支付类型:1.微信支付 2.金币支付 - if (coupon.getPayType() != 2) { - log.error("OrderController --> orderToPay() ERROR", "只支持积分支付"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, coupon.getCouponName() + ",只支持积分支付"); + if (childOrder.getGoodsType() == 3) { + if (highOrderService.getGasTheDayOrderNum(order.getMemId()) >= 1) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "已达到每日加油次数上限"); + } + // 查询账号余额 + 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, "无法进行支付,请联系平台客服"); + } + } } } - }*/ + } highOrderService.hltUnionCardPay(userCard.getId(), order.getId()); @@ -445,6 +480,9 @@ public class OrderController { } if (childOrder.getGoodsType() == 3) { + if (highOrderService.getGasTheDayOrderNum(order.getMemId()) >= 1) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "已达到每日加油次数上限"); + } // 查询账号余额 JSONObject accountInfo2JD = TuanYouConfig.queryCompanyAccountInfo2JD(); JSONArray result = accountInfo2JD.getJSONArray("result"); diff --git a/hai-cweb/src/main/java/com/cweb/controller/pay/UnionPayController.java b/hai-cweb/src/main/java/com/cweb/controller/pay/UnionPayController.java index a5627887..f1f7e0cb 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/pay/UnionPayController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/pay/UnionPayController.java @@ -148,7 +148,7 @@ public class UnionPayController { order.setPayRealPrice(order.getPayPrice()); // 实付金额 order.setPayTime(new Date()); // 支付时间 order.setPayModel(2); // 支付模式:1 金币,2 第三方平台,3 混合 - order.setPayType(6); // 支付方式: 1:支付宝 2:微信 3:金币 4:工会卡 5:银联 6:银联分期 + order.setPayType(5); // 支付方式: 1:支付宝 2:微信 3:金币 4:工会卡 5:银联 6:银联分期 order.setOrderStatus(2); // 订单状态:1 待支付 2 已支付 3.已完成 4. 已退款 5.已取消 for (HighChildOrder highChildOrder : order.getHighChildOrderList()) { diff --git a/hai-service/src/main/java/com/hai/dao/HighOrderMapperExt.java b/hai-service/src/main/java/com/hai/dao/HighOrderMapperExt.java index b8043d5e..d394e54d 100644 --- a/hai-service/src/main/java/com/hai/dao/HighOrderMapperExt.java +++ b/hai-service/src/main/java/com/hai/dao/HighOrderMapperExt.java @@ -945,4 +945,8 @@ public interface HighOrderMapperExt { }) List getDateCountByUser(); + @Select({"select count(1) from high_order " + + "where id in (select b.order_id from high_child_order b where goods_type = 3 and mem_id = #{userId} and child_orde_status in (2,3)) " + + "and year(pay_time)=year(now()) and month(pay_time) = month(now()) and day(pay_time) = day(now())"}) + int selectGasTheDayOrderNum(@Param("userId") Long userId); } diff --git a/hai-service/src/main/java/com/hai/service/HighOrderService.java b/hai-service/src/main/java/com/hai/service/HighOrderService.java index 0e1c1c52..eb4a9200 100644 --- a/hai-service/src/main/java/com/hai/service/HighOrderService.java +++ b/hai-service/src/main/java/com/hai/service/HighOrderService.java @@ -372,4 +372,11 @@ public interface HighOrderService { */ List getDateCountByRecharge(); + /** + * 查询用户当天加油订单数据量 + * @param userId + * @return + */ + int getGasTheDayOrderNum(Long userId); + } diff --git a/hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java index 310121dc..3e0b386b 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java @@ -1238,4 +1238,9 @@ public class HighOrderServiceImpl implements HighOrderService { public List getDateCountByRecharge() { return highOrderMapper.getDateCountByRecharge(); } + + @Override + public int getGasTheDayOrderNum(Long userId) { + return highOrderMapper.selectGasTheDayOrderNum(userId); + } }