From 1ff1fa6a21821167760e47a1426e8431af85aa06 Mon Sep 17 00:00:00 2001 From: = <=> Date: Tue, 27 Jul 2021 21:55:48 +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 --- .../bweb/controller/HighOrderController.java | 52 +++++++++ .../cweb/controller/pay/OrderController.java | 4 +- .../com/hai/schedule/HighOrderSchedule.java | 49 +++++++++ .../java/com/hai/config/QianZhuConfig.java | 17 ++- .../java/com/hai/dao/HighOrderMapperExt.java | 104 +++++++++++++++++- .../com/hai/service/HighOrderService.java | 14 +++ .../service/impl/HighOrderServiceImpl.java | 21 ++++ 7 files changed, 254 insertions(+), 7 deletions(-) diff --git a/hai-bweb/src/main/java/com/bweb/controller/HighOrderController.java b/hai-bweb/src/main/java/com/bweb/controller/HighOrderController.java index 80c69658..88ef83c0 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/HighOrderController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/HighOrderController.java @@ -393,5 +393,57 @@ public class HighOrderController { return ResponseMsgUtil.exception(e); } } + + @RequestMapping(value = "/getMobileOrderList", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "查询话费充值订单列表") + public ResponseData getMobileOrderList(@RequestParam(name = "companyId", required = false) Long companyId, + @RequestParam(name = "merchantId", required = false) Long merchantId, + @RequestParam(name = "orderNo", required = false) String orderNo, + @RequestParam(name = "paySerialNo", required = false) String paySerialNo, + @RequestParam(name = "payModel", required = false) Integer payModel, + @RequestParam(name = "payType", required = false) Integer payType, + @RequestParam(name = "orderStatus", required = false) Integer orderStatus, + @RequestParam(name = "payTimeS", required = false) Long payTimeS, + @RequestParam(name = "payTimeE", required = false) Long payTimeE, + @RequestParam(name = "pageNum", required = true) Integer pageNum, + @RequestParam(name = "pageSize", required = true) Integer pageSize, + HttpServletRequest request) { + try { + + SessionObject sessionObject = userCenter.getSessionObject(request); + UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); + + Map map = new HashMap<>(); + // 用户来源 0:超级管理员 1:公司 2:商户 3:门店 4. 代理商 + if(userInfoModel.getSecUser().getObjectType() == 0) { + map.put("companyId", companyId); + + } else if (userInfoModel.getSecUser().getObjectType() == 1) { + map.put("companyId", userInfoModel.getBsCompany().getId()); + map.put("merchantId", merchantId); + + } else if (userInfoModel.getSecUser().getObjectType() == 2) { + map.put("merchantId", userInfoModel.getMerchant().getId()); + } + + map.put("orderNo", orderNo); + map.put("paySerialNo", paySerialNo); + map.put("payModel", payModel); + map.put("payType", payType); + map.put("orderStatus", orderStatus); + map.put("payTimeS", payTimeS); + map.put("payTimeE", payTimeE); + + PageHelper.startPage(pageNum,pageSize); + return ResponseMsgUtil.success(new PageInfo<>(highOrderService.getMobileOrderList(map))); + + } catch (Exception e) { + log.error("HighOrderController --> getGasOrderList() 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 1fe6dc2d..c4babf63 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 @@ -262,8 +262,8 @@ public class OrderController { //微信支付 String nonce_str = MD5Util.MD5Encode(String.valueOf(ThreadLocalRandom.current().nextInt(10000)), "UTF-8"); - // int total_fee = MathUtils.objectConvertBigDecimal(map.get("payPrice")).multiply(new BigDecimal("100")).intValue(); - int total_fee = 1; + int total_fee = MathUtils.objectConvertBigDecimal(map.get("payPrice")).multiply(new BigDecimal("100")).intValue(); + // int total_fee = 1; WeChatPayReqInfo weChatPayReqInfo = new WeChatPayReqInfo(); weChatPayReqInfo.setAppid(SysConst.getSysConfig().getWxMchAppId()); //公众号id weChatPayReqInfo.setMch_id(SysConst.getSysConfig().getWxMchId()); //商户号 diff --git a/hai-schedule/src/main/java/com/hai/schedule/HighOrderSchedule.java b/hai-schedule/src/main/java/com/hai/schedule/HighOrderSchedule.java index 50819c66..0c768f7f 100644 --- a/hai-schedule/src/main/java/com/hai/schedule/HighOrderSchedule.java +++ b/hai-schedule/src/main/java/com/hai/schedule/HighOrderSchedule.java @@ -2,7 +2,10 @@ package com.hai.schedule; import com.alibaba.fastjson.JSONObject; import com.hai.common.utils.HttpsUtils; +import com.hai.config.QianZhuConfig; +import com.hai.config.WxOrderConfig; import com.hai.entity.HighOrder; +import com.hai.model.OrderRefundModel; import com.hai.service.HighOrderService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -48,6 +51,52 @@ public class HighOrderSchedule { } } + /** + * @Author 胡锐 + * @Description 处理话费充值订单 + * @Date 2021/4/4 22:45 + **/ + @Scheduled(cron="0 0/1 * * * ?") //每1分钟执行一次 + public void handleMobileOrder() { + List orderList = highOrderService.getAlreadyPaidMobileOrder(); + if (orderList != null && orderList.size() > 0) { + for (HighOrder order : orderList) { + try { + HighOrder highOrder = highOrderService.getOrderById(order.getId()); + if (highOrder != null) { + JSONObject mobileOrderJson = QianZhuConfig.getMobileOrderByOrderNo(highOrder.getOrderNo()); + if (mobileOrderJson != null && mobileOrderJson.getBoolean("success") == true) { + JSONObject data = mobileOrderJson.getJSONObject("data"); + + // 订单状态 0:待付款 5:已支付 10:充值中 15:交易成功 -5:已取消 -10:充值失败 + if (data.getInteger("status") == 15) { + highOrder.getHighChildOrderList().get(0).setChildOrdeStatus(3); + highOrder.setOrderStatus(3); + highOrder.setRefundTime(new Date()); + highOrder.setRefundPrice(data.getBigDecimal("refundAmount")); + highOrderService.updateOrderDetail(highOrder); + } + if (data.getInteger("status") == -10 || data.getInteger("status") == -5) { + if(highOrder.getPaySerialNo() != null && highOrder.getPayRealPrice() != null) { + OrderRefundModel orderRefundModel = WxOrderConfig.orderToRefund(highOrder.getPaySerialNo(), highOrder.getPayRealPrice(), highOrder.getPayRealPrice()); + if(orderRefundModel.getResult_code().equals("SUCCESS")) { + highOrder.getHighChildOrderList().get(0).setChildOrdeStatus(4); + highOrder.setOrderStatus(4); + highOrder.setRefundTime(new Date()); + highOrder.setRefundPrice(highOrder.getPayRealPrice()); + highOrderService.updateOrderDetail(highOrder); + } + } + } + } + } + } catch (Exception e) { + log.error("HighCouponSchedule --> handleMobileOrder() error!", e); + } + } + } + } + /** * @Author 胡锐 * @Description 完成团油订单 超过支付时间24小时订单自动完成 diff --git a/hai-service/src/main/java/com/hai/config/QianZhuConfig.java b/hai-service/src/main/java/com/hai/config/QianZhuConfig.java index 9c943301..7d13f415 100644 --- a/hai-service/src/main/java/com/hai/config/QianZhuConfig.java +++ b/hai-service/src/main/java/com/hai/config/QianZhuConfig.java @@ -111,7 +111,8 @@ public class QianZhuConfig { /** - * 获取话费充值Token + * 话费充值 + * 获取Token * @param platformUniqueId 用户唯一id * @param nickname 昵称 * @param mobile 电话号码 @@ -134,6 +135,13 @@ public class QianZhuConfig { return HttpsUtils.doPost("https://live.qianzhu8.com/gateway", JSON.toJSONString(map)); } + /** + * 话费订单 + * 根据订单号查询 + * @param orderNo 订单号 + * @return + * @throws Exception + */ public static JSONObject getMobileOrderByOrderNo(String orderNo) throws Exception { Map contentMap = new LinkedHashMap<>(); contentMap.put("orderNo", orderNo); @@ -148,6 +156,13 @@ public class QianZhuConfig { return HttpsUtils.doPost("https://nf.qianzhu8.com/gateway", JSON.toJSONString(map)); } + /** + * 话费订单 + * 支付订单 + * @param orderNo + * @return + * @throws Exception + */ public static JSONObject payMobileOrder(String orderNo) throws Exception { Map contentMap = new LinkedHashMap<>(); contentMap.put("orderNo", orderNo); 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 83b62b8b..42e960ca 100644 --- a/hai-service/src/main/java/com/hai/dao/HighOrderMapperExt.java +++ b/hai-service/src/main/java/com/hai/dao/HighOrderMapperExt.java @@ -226,9 +226,9 @@ public interface HighOrderMapperExt { " a.order_id = b.id" + " and a.goods_type = 4" + " and a.giveaway_type = 0" + - " and EXISTS (select 1 from high_merchant_store c where c.id = a.goods_id " + +/* " and EXISTS (select 1 from high_merchant_store c where c.id = a.goods_id " + " and c.company_id = #{map.companyId} " + - " and c.merchant_id = #{map.merchantId} )" + + " and c.merchant_id = #{map.merchantId} )" +*/ " and b.order_no = #{map.orderNo}", " and b.pay_serial_no = #{map.paySerialNo} ", " and b.pay_model = #{map.payModel} ", @@ -276,9 +276,9 @@ public interface HighOrderMapperExt { " a.order_id = b.id" + " and a.goods_type = 5" + " and a.giveaway_type = 0" + - " and EXISTS (select 1 from high_merchant_store c where c.id = a.goods_id " + +/* " and EXISTS (select 1 from high_merchant_store c where c.id = a.goods_id " + " and c.company_id = #{map.companyId} " + - " and c.merchant_id = #{map.merchantId} )" + + " and c.merchant_id = #{map.merchantId} )" +*/ " and b.order_no = #{map.orderNo}", " and b.pay_serial_no = #{map.paySerialNo} ", " and b.pay_model = #{map.payModel} ", @@ -290,6 +290,102 @@ public interface HighOrderMapperExt { ""}) List selectCinemaOrderList(@Param("map") Map map); + @Select({""}) + List getMobileOrderList(@Param("map") Map map); + + /** + * 查询处于已经支付的话费订单 + */ + @Select({"SELECT" + + " b.*" + + " FROM" + + " high_child_order a," + + " high_order b" + + " WHERE" + + " a.order_id = b.id" + + " and a.goods_type = 6" + + " and b.order_status = 2" + + " and a.giveaway_type = 0" + + " GROUP BY a.id ORDER BY b.create_time desc"}) + @Results({ + @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true), + @Result(column="order_no", property="orderNo", jdbcType=JdbcType.VARCHAR), + @Result(column="mem_discount_id", property="memDiscountId", jdbcType=JdbcType.BIGINT), + @Result(column="mem_discount_name", property="memDiscountName", jdbcType=JdbcType.VARCHAR), + @Result(column="mem_id", property="memId", jdbcType=JdbcType.BIGINT), + @Result(column="mem_name", property="memName", jdbcType=JdbcType.VARCHAR), + @Result(column="mem_phone", property="memPhone", jdbcType=JdbcType.VARCHAR), + @Result(column="pay_model", property="payModel", jdbcType=JdbcType.INTEGER), + @Result(column="pay_type", property="payType", jdbcType=JdbcType.INTEGER), + @Result(column="pay_gold", property="payGold", jdbcType=JdbcType.INTEGER), + @Result(column="pay_price", property="payPrice", jdbcType=JdbcType.DECIMAL), + @Result(column="pay_real_price", property="payRealPrice", jdbcType=JdbcType.DECIMAL), + @Result(column="pay_serial_no", property="paySerialNo", jdbcType=JdbcType.VARCHAR), + @Result(column="deduction_price", property="deductionPrice", jdbcType=JdbcType.DECIMAL), + @Result(column="order_status", property="orderStatus", jdbcType=JdbcType.INTEGER), + @Result(column="total_price", property="totalPrice", jdbcType=JdbcType.DECIMAL), + @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP), + @Result(column="pay_time", property="payTime", jdbcType=JdbcType.TIMESTAMP), + @Result(column="cancel_time", property="cancelTime", jdbcType=JdbcType.TIMESTAMP), + @Result(column="cancel_remarks", property="cancelRemarks", jdbcType=JdbcType.VARCHAR), + @Result(column="finish_time", property="finishTime", jdbcType=JdbcType.TIMESTAMP), + @Result(column="remarks", property="remarks", jdbcType=JdbcType.VARCHAR), + @Result(column="refund_time", property="refundTime", jdbcType=JdbcType.TIMESTAMP), + @Result(column="refund_price", property="refundPrice", jdbcType=JdbcType.DECIMAL), + @Result(column="refund_content", property="refundContent", jdbcType=JdbcType.VARCHAR), + @Result(column="refusal_refund_content", property="refusalRefundContent", jdbcType=JdbcType.VARCHAR), + @Result(column="ext_1", property="ext1", jdbcType=JdbcType.VARCHAR), + @Result(column="ext_2", property="ext2", jdbcType=JdbcType.VARCHAR), + @Result(column="ext_3", property="ext3", jdbcType=JdbcType.VARCHAR) + }) + List selectAlreadyPaidMobileOrder(); + @Select({"select a.id orderId,b.id childOrderId from high_order a,high_child_order b where a.id = b.order_id and b.goods_type = 3 and a.order_status = 2 and TIMESTAMPDIFF(MINUTE,a.pay_time,SYSDATE()) > 60*24 GROUP BY b.id"}) List> selectFinishGasOrder(); 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 494e26af..7ceba2a1 100644 --- a/hai-service/src/main/java/com/hai/service/HighOrderService.java +++ b/hai-service/src/main/java/com/hai/service/HighOrderService.java @@ -142,6 +142,14 @@ public interface HighOrderService { */ List getCinemaOrderList(Map map) throws Exception; + /** + * 查询话费充值订单 + * @param map + * @return + * @throws Exception + */ + List getMobileOrderList(Map map) throws Exception; + /** * @Author 胡锐 * @Description 查询需要关闭的订单列表 @@ -184,6 +192,12 @@ public interface HighOrderService { **/ Integer countUnusedDiscountByUserId(Long userId , Integer status); + /** + * 查询处于已经支付的话费订单 + * @return + */ + List getAlreadyPaidMobileOrder(); + /** * 查询团油超过支付时间24小时订单 * @return 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 f4ab6a01..3e030003 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 @@ -409,6 +409,19 @@ public class HighOrderServiceImpl implements HighOrderService { return highOrderMapper.selectCinemaOrderList(map); } + @Override + public List getMobileOrderList(Map map) throws Exception { + if(MapUtils.getLong(map, "payTimeS") != null) { + map.put("payTimeS", DateUtil.date2String(new Date(MapUtils.getLong(map, "payTimeS")), "yyyy-MM-dd HH:mm:ss")); + } + + if(MapUtils.getLong(map, "payTimeE") != null) { + map.put("payTimeE", DateUtil.date2String(new Date(MapUtils.getLong(map, "payTimeE")), "yyyy-MM-dd HH:mm:ss")); + } + + return highOrderMapper.getMobileOrderList(map); + } + @Override public List getCloseOrder() { return highOrderMapperExt.getCloseOrder(); @@ -460,6 +473,9 @@ public class HighOrderServiceImpl implements HighOrderService { public void cancelOrder(Long orderId) { HighOrder order = getOrderById(orderId); if (order != null) { + if (order.getOrderStatus() != 1) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.STATUS_ERROR, ""); + } order.setOrderStatus(5); // 订单状态:1 待支付 2 已支付 3.已完成 4. 已退款 5.已取消 order.setCancelTime(new Date()); @@ -522,6 +538,11 @@ public class HighOrderServiceImpl implements HighOrderService { return highDiscountUserRelMapper.selectByExample(example).size(); } + @Override + public List getAlreadyPaidMobileOrder() { + return highOrderMapperExt.selectAlreadyPaidMobileOrder(); + } + @Override public List> getFinishGasOrder() { return highOrderMapper.selectFinishGasOrder();