diff --git a/hai-cweb/src/main/java/com/cweb/controller/pay/TuanYouController.java b/hai-cweb/src/main/java/com/cweb/controller/pay/TuanYouController.java index c6defe97..1350577e 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/pay/TuanYouController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/pay/TuanYouController.java @@ -84,6 +84,7 @@ public class TuanYouController { if(orderRefundModel.getResult_code().equals("SUCCESS")) { order.setOrderStatus(4); order.setRefundTime(new Date()); + order.setRefundPrice(order.getPayRealPrice()); highOrderService.updateOrderDetail(order); } } else if (!object.getBoolean("refundResult") == true && order != null) { 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 88bdd7ec..32b48835 100644 --- a/hai-schedule/src/main/java/com/hai/schedule/HighOrderSchedule.java +++ b/hai-schedule/src/main/java/com/hai/schedule/HighOrderSchedule.java @@ -4,6 +4,7 @@ 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.HighChildOrder; import com.hai.entity.HighOrder; import com.hai.model.OrderRefundModel; import com.hai.service.HighOrderService; @@ -70,21 +71,146 @@ public class HighOrderSchedule { // 订单状态 0:待付款 5:已支付 10:充值中 15:交易成功 -5:已取消 -10:充值失败 if (data.getInteger("status") == 15) { - highOrder.getHighChildOrderList().get(0).setChildOrdeStatus(3); - highOrder.setOrderStatus(3); - highOrder.setFinishTime(new Date()); + for (HighChildOrder childOrder : highOrder.getHighChildOrderList()) { + childOrder.setChildOrdeStatus(3); + } + highOrder.setOrderStatus(3); + highOrder.setFinishTime(new Date()); + highOrderService.updateOrder(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")) { + for (HighChildOrder childOrder : highOrder.getHighChildOrderList()) { + childOrder.setChildOrdeStatus(4); + } + highOrder.setOrderStatus(4); + highOrder.setRefundTime(new Date()); + highOrder.setRefundPrice(highOrder.getPayRealPrice()); + highOrderService.updateOrder(highOrder); + } + } else { + for (HighChildOrder childOrder : highOrder.getHighChildOrderList()) { + childOrder.setChildOrdeStatus(5); + } + highOrder.setCancelTime(new Date()); + highOrder.setOrderStatus(5); + highOrderService.updateOrder(highOrder); + } + } + } + } + } catch (Exception e) { + log.error("HighCouponSchedule --> handleMobileOrder() error!", e); + } + } + } + } + + /** + * @Author 胡锐 + * @Description 处理话KFC订单 + * @Date 2021/4/4 22:45 + **/ + @Scheduled(cron="0 0/1 * * * ?") //每1分钟执行一次 + public void handleKfcOrder() { + List orderList = highOrderService.getAlreadyPaidKfcOrder(); + if (orderList != null && orderList.size() > 0) { + for (HighOrder order : orderList) { + try { + HighOrder highOrder = highOrderService.getOrderById(order.getId()); + if (highOrder != null) { + JSONObject mobileOrderJson = QianZhuConfig.getKfcOrderByOrderNo(highOrder.getOrderNo()); + if (mobileOrderJson != null && mobileOrderJson.getBoolean("success") == true) { + JSONObject data = mobileOrderJson.getJSONObject("data"); + + // 订单状态 0:待付款 5:排队中 15:TRAN_SUCCESS:交易成功 -5:已取消 + if (data.getInteger("status") == 15) { + for (HighChildOrder childOrder : highOrder.getHighChildOrderList()) { + childOrder.setChildOrdeStatus(3); + } + highOrder.setOrderStatus(3); + highOrder.setFinishTime(new Date()); + highOrderService.updateOrder(highOrder); + } + + if (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")) { + for (HighChildOrder childOrder : highOrder.getHighChildOrderList()) { + childOrder.setChildOrdeStatus(4); + } + highOrder.setOrderStatus(4); + highOrder.setRefundTime(new Date()); + highOrder.setRefundPrice(highOrder.getPayRealPrice()); + highOrderService.updateOrder(highOrder); + } + } else { + for (HighChildOrder childOrder : highOrder.getHighChildOrderList()) { + childOrder.setChildOrdeStatus(5); + } + highOrder.setCancelTime(new Date()); + highOrder.setOrderStatus(5); highOrderService.updateOrder(highOrder); + } + } + } + } + } catch (Exception e) { + log.error("HighCouponSchedule --> handleMobileOrder() error!", e); + } + } + } + } + + /** + * @Author 胡锐 + * @Description 处理电影票订单 + * @Date 2021/4/4 22:45 + **/ + @Scheduled(cron="0 0/1 * * * ?") //每1分钟执行一次 + public void handleCinemaOrder() { + List orderList = highOrderService.getAlreadyPaidCinemaOrder(); + if (orderList != null && orderList.size() > 0) { + for (HighOrder order : orderList) { + try { + HighOrder highOrder = highOrderService.getOrderById(order.getId()); + if (highOrder != null) { + JSONObject mobileOrderJson = QianZhuConfig.getCinemaOrderByOrderNo(highOrder.getOrderNo()); + if (mobileOrderJson != null && mobileOrderJson.getBoolean("success") == true) { + JSONObject data = mobileOrderJson.getJSONObject("data"); + + // 订单状态 0:待付款 5:待出票 10:已出票 15:交易成功 -5:已取消 + if (data.getInteger("status") == 10 || data.getInteger("status") == 15) { + for (HighChildOrder childOrder : highOrder.getHighChildOrderList()) { + childOrder.setChildOrdeStatus(3); + } + highOrder.setOrderStatus(3); + highOrder.setFinishTime(new Date()); + highOrderService.updateOrder(highOrder); } - if (data.getInteger("status") == -10 || data.getInteger("status") == -5) { + + if (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); + for (HighChildOrder childOrder : highOrder.getHighChildOrderList()) { + childOrder.setChildOrdeStatus(4); + } highOrder.setOrderStatus(4); highOrder.setRefundTime(new Date()); highOrder.setRefundPrice(highOrder.getPayRealPrice()); highOrderService.updateOrder(highOrder); } + } else { + for (HighChildOrder childOrder : highOrder.getHighChildOrderList()) { + childOrder.setChildOrdeStatus(5); + } + highOrder.setCancelTime(new Date()); + highOrder.setOrderStatus(5); + highOrderService.updateOrder(highOrder); } } } 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 42e960ca..e8a85490 100644 --- a/hai-service/src/main/java/com/hai/dao/HighOrderMapperExt.java +++ b/hai-service/src/main/java/com/hai/dao/HighOrderMapperExt.java @@ -340,7 +340,7 @@ public interface HighOrderMapperExt { List getMobileOrderList(@Param("map") Map map); /** - * 查询处于已经支付的话费订单 + * 查询处于已经支付和待支付的话费订单 */ @Select({"SELECT" + " b.*" + @@ -350,9 +350,9 @@ public interface HighOrderMapperExt { " WHERE" + " a.order_id = b.id" + " and a.goods_type = 6" + - " and b.order_status = 2" + + " and b.order_status in (1,2) " + " and a.giveaway_type = 0" + - " GROUP BY a.id ORDER BY b.create_time desc"}) + " GROUP BY b.id"}) @Results({ @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true), @Result(column="order_no", property="orderNo", jdbcType=JdbcType.VARCHAR), @@ -385,6 +385,102 @@ public interface HighOrderMapperExt { @Result(column="ext_3", property="ext3", jdbcType=JdbcType.VARCHAR) }) List selectAlreadyPaidMobileOrder(); + + + /** + * 查询处于已经支付和待支付的KFC订单 + */ + @Select({"SELECT " + + " b.*" + + " FROM" + + " high_child_order a," + + " high_order b" + + " WHERE" + + " a.order_id = b.id" + + " and a.goods_type = 4" + + " and b.order_status in (1,2) " + + " and a.giveaway_type = 0" + + " GROUP BY b.id"}) + @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 selectAlreadyPaidKfcOrder(); + + + /** + * 查询处于已经支付和待支付的电影票订单 + */ + @Select({"SELECT" + + " b.*" + + " FROM" + + " high_child_order a," + + " high_order b" + + " WHERE" + + " a.order_id = b.id" + + " and a.goods_type = 5" + + " and b.order_status in (1,2)" + + " and a.giveaway_type = 0" + + " GROUP BY b.id"}) + @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 selectAlreadyPaidCinemaOrder(); @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 7ceba2a1..681f8029 100644 --- a/hai-service/src/main/java/com/hai/service/HighOrderService.java +++ b/hai-service/src/main/java/com/hai/service/HighOrderService.java @@ -193,11 +193,23 @@ public interface HighOrderService { Integer countUnusedDiscountByUserId(Long userId , Integer status); /** - * 查询处于已经支付的话费订单 + * 查询处于已经支付和待支付的话费订单 * @return */ List getAlreadyPaidMobileOrder(); + /** + * 查询处于已经支付和待支付的KFC订单 + * @return + */ + List getAlreadyPaidKfcOrder(); + + /** + * 查询处于已经支付和待支付的话费订单 + * @return + */ + List getAlreadyPaidCinemaOrder(); + /** * 查询团油超过支付时间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 3e030003..40ba8323 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 @@ -124,6 +124,7 @@ public class HighOrderServiceImpl implements HighOrderService { highChildOrder.setGoodsImg(coupon.getCouponImg()); highChildOrder.setGoodsSpecName("默认"); highChildOrder.setGoodsPrice(new BigDecimal(0)); + highChildOrder.setGoodsActualPrice(new BigDecimal("0")); highChildOrder.setSaleCount(1); highChildOrder.setTotalPrice(new BigDecimal(0)); highChildOrder.setGiveawayType(true); // 是否是赠品 0:否 1:是 @@ -543,6 +544,17 @@ public class HighOrderServiceImpl implements HighOrderService { return highOrderMapperExt.selectAlreadyPaidMobileOrder(); } + @Override + public List getAlreadyPaidKfcOrder() { + return highOrderMapperExt.selectAlreadyPaidKfcOrder(); + } + + @Override + public List getAlreadyPaidCinemaOrder() { + return highOrderMapperExt.selectAlreadyPaidCinemaOrder(); + } + + @Override public List> getFinishGasOrder() { return highOrderMapper.selectFinishGasOrder();