From 3a6968cd8c0f9ca09e409e7a220fd087b5bfa3cd Mon Sep 17 00:00:00 2001 From: yuyang Date: Mon, 6 Jun 2022 17:48:41 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=AE=A2=E5=8D=95=E5=BC=82?= =?UTF-8?q?=E5=B8=B8=E3=80=81=E9=80=80=E6=AC=BE=E7=94=B3=E8=AF=B7=E8=B6=85?= =?UTF-8?q?100=E5=85=83=E3=80=81=E6=9C=AA=E5=BC=80=E7=A5=A8=E7=9A=84?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E7=94=9F=E6=88=90=E5=B7=A5=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/WorkOrderController.java | 11 ++++++ .../activity/mapper/XhpcWorkOrderMapper.java | 6 ++-- .../activity/service/WorkOrderService.java | 7 ++++ .../service/impl/WorkOrderServiceImpl.java | 36 ++++++++++++++++--- .../resources/mapper/XhpcWorkOrderMapper.xml | 9 +++-- .../xhpc/common/api/WorkOrderYuService.java | 36 +++++++++++++++++++ .../api/factory/WorkOrderFallbackFactory.java | 36 +++++++++++++++++++ .../order/api/XhpcPileOrderController.java | 14 ++++---- .../XhpcHistoryOrderController.java | 25 +++++++++++++ .../order/mapper/XhpcChargeOrderMapper.java | 1 + .../service/IXhpcChargeOrderService.java | 5 +++ .../impl/XhpcChargeOrderServiceImpl.java | 10 ++++++ .../impl/XhpcRealTimeOrderServiceImpl.java | 14 ++++++-- .../mapper/XhpcChargeOrderMapper.xml | 3 ++ .../mapper/XhpcHistoryOrderMapper.xml | 10 ++++-- .../controller/XhpcRefundAuditController.java | 33 +++++++++++++---- .../payment/mapper/XhpcRefundOrderMapper.java | 2 +- .../service/IXhpcRefundOrderService.java | 3 +- .../impl/XhpcRefundOrderServiceImpl.java | 4 +-- .../mapper/XhpcRefundOrderMapper.xml | 8 ++++- .../controller/XhpcInvoiceController.java | 30 ++++++++++++++++ .../xhpc/user/mapper/XhpcInvoiceMapper.java | 2 ++ .../xhpc/user/service/XhpcInvoiceService.java | 6 ++++ .../service/impl/XhpcInvoiceServiceImpl.java | 10 ++++++ .../src/main/resources/bootstrap.yml | 10 +++--- .../resources/mapper/XhpcInvoiceMapper.xml | 3 ++ 26 files changed, 294 insertions(+), 40 deletions(-) create mode 100644 xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/api/WorkOrderYuService.java create mode 100644 xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/api/factory/WorkOrderFallbackFactory.java diff --git a/xhpc-modules/xhpc-activity/src/main/java/com/xhpc/activity/controller/WorkOrderController.java b/xhpc-modules/xhpc-activity/src/main/java/com/xhpc/activity/controller/WorkOrderController.java index bd61fce6..cf8e150d 100644 --- a/xhpc-modules/xhpc-activity/src/main/java/com/xhpc/activity/controller/WorkOrderController.java +++ b/xhpc-modules/xhpc-activity/src/main/java/com/xhpc/activity/controller/WorkOrderController.java @@ -14,6 +14,7 @@ import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; +import java.util.Date; import java.util.HashMap; import java.util.Map; @@ -75,4 +76,14 @@ public class WorkOrderController extends BaseController { return R.ok(workOrderService.deleteOrder(orderId)); } + + @GetMapping("/addNewOrder") + public R addNewOrder(@RequestParam(value = "type") String type, @RequestParam(value = "title") String title, @RequestParam(value = "content")String content, @RequestParam(value = "faultTime") Date faultTime, @RequestParam(value = "reason")String reason){ + return R.ok(workOrderService.addNewOrder(type, title, content, faultTime, reason)); + } + + @GetMapping("/workOrderMessage") + public R workOrderMessage(@RequestParam(value = "type") Integer type, @RequestParam(value = "time") String time){ + return workOrderService.workOrderMessage(type, time); + } } diff --git a/xhpc-modules/xhpc-activity/src/main/java/com/xhpc/activity/mapper/XhpcWorkOrderMapper.java b/xhpc-modules/xhpc-activity/src/main/java/com/xhpc/activity/mapper/XhpcWorkOrderMapper.java index 115efca5..09c1249f 100644 --- a/xhpc-modules/xhpc-activity/src/main/java/com/xhpc/activity/mapper/XhpcWorkOrderMapper.java +++ b/xhpc-modules/xhpc-activity/src/main/java/com/xhpc/activity/mapper/XhpcWorkOrderMapper.java @@ -11,8 +11,7 @@ public interface XhpcWorkOrderMapper { List> findOrderListByParams(@Param("params") Map params); - XhpcWorkOrderDomain selectByTypeAndTitle(@Param("type")Integer type, - @Param("title")String title); + XhpcWorkOrderDomain selectByTypeAndTitle(@Param("type")Integer type,@Param("title")String title); int insertOrderUser(@Param("domainList") List domainList); @@ -28,6 +27,7 @@ public interface XhpcWorkOrderMapper { int updateByPrimaryKey(XhpcWorkOrderDomain record); - int deleteOrderUserByOrderId(Long orderId); + + int workOrderMessage(@Param("type")Integer type, @Param("time")String time); } \ No newline at end of file diff --git a/xhpc-modules/xhpc-activity/src/main/java/com/xhpc/activity/service/WorkOrderService.java b/xhpc-modules/xhpc-activity/src/main/java/com/xhpc/activity/service/WorkOrderService.java index f869d557..42432c58 100644 --- a/xhpc-modules/xhpc-activity/src/main/java/com/xhpc/activity/service/WorkOrderService.java +++ b/xhpc-modules/xhpc-activity/src/main/java/com/xhpc/activity/service/WorkOrderService.java @@ -2,7 +2,10 @@ package com.xhpc.activity.service; import com.xhpc.activity.domain.XhpcWorkOrderDomain; +import com.xhpc.common.core.domain.R; +import org.springframework.web.bind.annotation.RequestParam; +import java.util.Date; import java.util.List; import java.util.Map; @@ -19,4 +22,8 @@ public interface WorkOrderService { Boolean insertOrder(XhpcWorkOrderDomain domain); Boolean deleteOrder(Long orderId) throws Exception; + + Boolean addNewOrder(String type, String title, String content, Date faultTime, String reason); + + R workOrderMessage(Integer type, String time); } diff --git a/xhpc-modules/xhpc-activity/src/main/java/com/xhpc/activity/service/impl/WorkOrderServiceImpl.java b/xhpc-modules/xhpc-activity/src/main/java/com/xhpc/activity/service/impl/WorkOrderServiceImpl.java index ade09418..380f33af 100644 --- a/xhpc-modules/xhpc-activity/src/main/java/com/xhpc/activity/service/impl/WorkOrderServiceImpl.java +++ b/xhpc-modules/xhpc-activity/src/main/java/com/xhpc/activity/service/impl/WorkOrderServiceImpl.java @@ -12,10 +12,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; @Slf4j @Service @@ -185,6 +182,37 @@ public class WorkOrderServiceImpl implements WorkOrderService { return true; } + @Override + public Boolean addNewOrder(String type, String title, String content, Date faultTime, String reason) { + try{ + XhpcWorkOrderDomain domain =new XhpcWorkOrderDomain(); + domain.setType(Short.parseShort(type)); + domain.setTitle(title); + domain.setContent(content); + domain.setFaultTime(faultTime); + domain.setContent(content); + domain.setCreateTime(faultTime); + Short s =0; + domain.setStatus(s); + orderMapper.insertSelective(domain); + + }catch (Exception e){ + e.printStackTrace(); + } + + return true; + } + + @Override + public R workOrderMessage(Integer type, String time) { + int i = orderMapper.workOrderMessage(type, time); + System.out.println("------------iiiiii--------"+i); + if(i>0){ + return R.fail(); + } + return R.ok(); + } + private void sendSms(String phoneList, String orderId){ HashMap paramMap = new HashMap<>(); diff --git a/xhpc-modules/xhpc-activity/src/main/resources/mapper/XhpcWorkOrderMapper.xml b/xhpc-modules/xhpc-activity/src/main/resources/mapper/XhpcWorkOrderMapper.xml index a11d6a26..e8d30240 100644 --- a/xhpc-modules/xhpc-activity/src/main/resources/mapper/XhpcWorkOrderMapper.xml +++ b/xhpc-modules/xhpc-activity/src/main/resources/mapper/XhpcWorkOrderMapper.xml @@ -182,7 +182,7 @@ 1, - #{status} + #{status}, 0, @@ -263,9 +263,12 @@ where work_order_id = #{workOrderId,jdbcType=BIGINT} - - delete from xhpc_work_order_user where order_id=#{orderId} + + + \ No newline at end of file diff --git a/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/api/WorkOrderYuService.java b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/api/WorkOrderYuService.java new file mode 100644 index 00000000..222413b1 --- /dev/null +++ b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/api/WorkOrderYuService.java @@ -0,0 +1,36 @@ +package com.xhpc.common.api; + +import com.xhpc.common.api.factory.WorkOrderFallbackFactory; +import com.xhpc.common.core.constant.ServiceNameConstants; +import com.xhpc.common.core.domain.R; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestParam; + +import java.util.Date; + +/** + * @author yuyang + * @date 2022/6/6 11:38 + */ +@FeignClient(contextId = "workOrderYuService" ,value = ServiceNameConstants.XHPC_ACTIVITY,fallbackFactory = WorkOrderFallbackFactory.class) +public interface WorkOrderYuService { + + /** + * 添加工单 + * @return + */ + @GetMapping("/order/addNewOrder") + R addNewOrder(@RequestParam(value = "type") String type, @RequestParam(value = "title") String title, @RequestParam(value = "content")String content, @RequestParam(value = "faultTime") Date faultTime, @RequestParam(value = "reason")String reason); + + /** + * 查询工单今日是否生成 + * @return + */ + @GetMapping("/order/workOrderMessage") + R workOrderMessage(@RequestParam(value = "type") Integer type,@RequestParam(value = "time")String time); + + + + +} diff --git a/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/api/factory/WorkOrderFallbackFactory.java b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/api/factory/WorkOrderFallbackFactory.java new file mode 100644 index 00000000..5827d924 --- /dev/null +++ b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/api/factory/WorkOrderFallbackFactory.java @@ -0,0 +1,36 @@ +package com.xhpc.common.api.factory; + +import com.xhpc.common.api.WorkOrderYuService; +import com.xhpc.common.core.domain.R; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.cloud.openfeign.FallbackFactory; +import org.springframework.stereotype.Component; + +import java.util.Date; + +/** + * @author yuyang + * @date 2022/6/6 11:39 + */ +@Component +public class WorkOrderFallbackFactory implements FallbackFactory { + + private static final Logger logger = LoggerFactory.getLogger(WorkOrderFallbackFactory.class); + + @Override + public WorkOrderYuService create(Throwable cause) { + logger.error("工单调用失败:{}//fallback",cause.getMessage()); + return new WorkOrderYuService() { + @Override + public R addNewOrder(String type, String title, String content, Date faultTime, String reason) { + return R.fail("工单生成失败调用失败:" + cause.getMessage()); + } + + @Override + public R workOrderMessage(Integer type, String time) { + return R.fail("工单查询调用失败:" + cause.getMessage()); + } + }; + } +} diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/api/XhpcPileOrderController.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/api/XhpcPileOrderController.java index 4d46da64..94a31ed1 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/api/XhpcPileOrderController.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/api/XhpcPileOrderController.java @@ -327,7 +327,12 @@ public class XhpcPileOrderController extends BaseController { } CacheOrderData cacheOrderData = (CacheOrderData)cacheMap.get("orderData"); - + //停止原因 + try{ + if(cacheOrderData.getStopReason() !=null && !"".equals(cacheOrderData.getStopReason())){ + xhpcChargeOrder.setType(cacheOrderData.getStopReason()); + } + }catch (Exception e){} if(xhpcChargeOrder == null ){ logger.info("无效订单号>>>>>orderNo:" + orderNo); return R.fail(500,"无效订单号:"+orderNo); @@ -486,12 +491,7 @@ public class XhpcPileOrderController extends BaseController { xhpcChargeOrder.setUpdateTime(date); xhpcChargeOrder.setStatus(status); XhpcHistoryOrder xhpcHistoryOrder = new XhpcHistoryOrder(); - //停止原因 - try{ - if(cacheOrderData.getStopReason() !=null && !"".equals(cacheOrderData.getStopReason())){ - xhpcChargeOrder.setType(cacheOrderData.getStopReason()); - } - }catch (Exception e){} + //生成一条历史订单 xhpcHistoryOrder.setStartTime(startTime); diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/controller/XhpcHistoryOrderController.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/controller/XhpcHistoryOrderController.java index e305ae78..55b23157 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/controller/XhpcHistoryOrderController.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/controller/XhpcHistoryOrderController.java @@ -3,6 +3,8 @@ package com.xhpc.order.controller; import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateUnit; import cn.hutool.core.date.DateUtil; +import com.xhpc.common.api.WorkOrderYuService; +import com.xhpc.common.core.domain.R; import com.xhpc.common.core.web.controller.BaseController; import com.xhpc.common.core.web.domain.AjaxResult; import com.xhpc.common.core.web.page.TableDataInfo; @@ -44,6 +46,8 @@ public class XhpcHistoryOrderController extends BaseController { @Autowired private IXhpcChargeOrderService chargeOrderService; + @Autowired + private WorkOrderYuService workOrderYuService; private static final Logger logger = LoggerFactory.getLogger(XhpcHistoryOrderController.class); @@ -915,6 +919,27 @@ public class XhpcHistoryOrderController extends BaseController { chargeOrderService.updateStatus(); } + @Scheduled(cron = "0 0/1 * * * ?") + @GetMapping("/getInvoiceInfo") + public void getInvoiceInfo(){ + logger.info("++++++++++++每1分钟,扫描一次,异常订单,自动生成工单++++++++++++++++"); + try { + int invoiceInfo = chargeOrderService.getChargeOrderStatus(); + if(invoiceInfo>0){ + Date date = DateUtil.date(); + String format = DateUtil.format(date, "yyyy-MM-dd"); + R r = workOrderYuService.workOrderMessage(2, format); + if(r.getCode()==200){ + workOrderYuService.addNewOrder("2","有异常订单订单待处理","定时任务自动扫描申请异常订单",date,""); + } + } + }catch (Exception e){ + logger.info("++++++++++++每1分钟,扫描一次,异常订单,自动生成工单异常++++++++++++++++"); + e.printStackTrace(); + //后期可以增加短信通知 + } + } + public void add(int number,int type){ //获取500条待统计历史订单 List list = xhpcHistoryOrderService.getStatistisList(number,type); diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/XhpcChargeOrderMapper.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/XhpcChargeOrderMapper.java index 93eb28f7..30f9c007 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/XhpcChargeOrderMapper.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/XhpcChargeOrderMapper.java @@ -213,6 +213,7 @@ public interface XhpcChargeOrderMapper { */ List getFourTimsStatus(); + int getChargeOrderStatus(); /** * 查询相同桩之后是否有订单结算 * @param serialNumber 订单号 diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IXhpcChargeOrderService.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IXhpcChargeOrderService.java index ff910b34..7a704e9e 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IXhpcChargeOrderService.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IXhpcChargeOrderService.java @@ -160,6 +160,11 @@ public interface IXhpcChargeOrderService { */ void updateStatus(); + /** + * 查询是否有异常订单 + * @return + */ + int getChargeOrderStatus(); //获取桩信息 Map getXhpcChargingPileById(Long chargingPileId); diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcChargeOrderServiceImpl.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcChargeOrderServiceImpl.java index 5f3023a5..a04dc56d 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcChargeOrderServiceImpl.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcChargeOrderServiceImpl.java @@ -675,6 +675,16 @@ public class XhpcChargeOrderServiceImpl extends BaseService implements IXhpcChar } } + /** + * 查询是否有异常订单 + * + * @return + */ + @Override + public int getChargeOrderStatus() { + return xhpcChargeOrderMapper.getChargeOrderStatus(); + } + @Override public Map getXhpcChargingPileById(Long chargingPileId) { return xhpcChargeOrderMapper.getXhpcChargingPileById(chargingPileId,null); diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcRealTimeOrderServiceImpl.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcRealTimeOrderServiceImpl.java index 065134dd..b56add96 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcRealTimeOrderServiceImpl.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcRealTimeOrderServiceImpl.java @@ -350,8 +350,16 @@ public class XhpcRealTimeOrderServiceImpl extends BaseService implements IXhpcRe } xhpcChargeOrder.setStatus(3); xhpcChargeOrder.setAmountCharged(money); - xhpcChargeOrder.setStopReasonEvcs(45); - xhpcChargeOrder.setType("91"); + + try{ + Map cacheMap = redisService.getCacheMap("order:"+xhpcChargeOrder.getSerialNumber()); + if(cacheMap.get("stopReason") !=null && !"".equals(cacheMap.get("stopReason").toString())){ + xhpcChargeOrder.setType(cacheMap.get("stopReason").toString()); + }else{ + xhpcChargeOrder.setType("91"); + xhpcChargeOrder.setStopReasonEvcs(45); + } + }catch (Exception e){} Long userId = xhpcChargeOrder.getUserId(); Integer source = xhpcChargeOrder.getSource(); String tenantId = xhpcChargeOrder.getTenantId(); @@ -1450,8 +1458,8 @@ public class XhpcRealTimeOrderServiceImpl extends BaseService implements IXhpcRe xhpcHistoryOrder.setStartTime(xhpcChargeOrder.getStartTime()); xhpcHistoryOrder.setEndTime(xhpcChargeOrder.getStartTime()); } + xhpcHistoryOrder.setStopReasonEvcs(xhpcChargeOrder.getType()); - xhpcHistoryOrder.setStopReasonEvcs("91"); if(UserTypeUtil.COMMUNIT_TYPE.equals(xhpcChargeOrder.getSource()) || UserTypeUtil.CUSTOMERS_TYPE.equals(xhpcChargeOrder.getSource())){ xhpcHistoryOrder.setChargeModelEvcs(2); }else{ diff --git a/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcChargeOrderMapper.xml b/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcChargeOrderMapper.xml index 17ed3b59..179de833 100644 --- a/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcChargeOrderMapper.xml +++ b/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcChargeOrderMapper.xml @@ -709,6 +709,9 @@ select * from xhpc_charge_order where now() >DATE_ADD(create_time,interval 4 hour) and status=0 + diff --git a/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcHistoryOrderMapper.xml b/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcHistoryOrderMapper.xml index d3457fcb..9d15631d 100644 --- a/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcHistoryOrderMapper.xml +++ b/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcHistoryOrderMapper.xml @@ -837,9 +837,13 @@ rt.rate_time_id in ( SELECT rate_time_id FROM xhpc_rate_time WHERE rate_model_id = #{rateModelId} AND start_time <= #{startTime} AND replace(end_time, '00:00:00', '23:59:59') >= #{startTime} AND del_flag=0 ) - or rt.rate_time_id in ( - SELECT rate_time_id FROM xhpc_rate_time WHERE rate_model_id = #{rateModelId} AND start_time <= #{endTime} AND replace(end_time, '00:00:00', '23:59:59') >= #{endTime} AND del_flag=0 - ) + + + or rt.rate_time_id in ( + SELECT rate_time_id FROM xhpc_rate_time WHERE rate_model_id = #{rateModelId} AND start_time <= #{endTime} AND replace(end_time, '00:00:00', '23:59:59') >= #{endTime} AND del_flag=0 + ) + + and rt.rate_model_id = #{rateModelId} diff --git a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/controller/XhpcRefundAuditController.java b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/controller/XhpcRefundAuditController.java index b0e05bde..e6622767 100644 --- a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/controller/XhpcRefundAuditController.java +++ b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/controller/XhpcRefundAuditController.java @@ -1,5 +1,6 @@ package com.xhpc.payment.controller; +import cn.hutool.core.date.DateUtil; import com.alipay.api.AlipayClient; import com.alipay.api.CertAlipayRequest; import com.alipay.api.DefaultAlipayClient; @@ -8,9 +9,10 @@ import com.alipay.api.domain.Participant; import com.alipay.api.request.AlipayFundTransUniTransferRequest; import com.alipay.api.response.AlipayFundTransUniTransferResponse; import com.xhpc.common.api.SmsService; -import com.xhpc.common.api.UserTypeService; +import com.xhpc.common.api.WorkOrderYuService; import com.xhpc.common.core.constant.HttpStatus; import com.xhpc.common.core.constant.StatusConstants; +import com.xhpc.common.core.domain.R; import com.xhpc.common.core.utils.DateUtils; import com.xhpc.common.core.utils.StringUtils; import com.xhpc.common.core.utils.WXPayUtil; @@ -45,7 +47,6 @@ import org.apache.http.util.EntityUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.core.env.Environment; import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.transaction.annotation.Transactional; @@ -59,6 +60,7 @@ import java.io.FileInputStream; import java.io.IOException; import java.math.BigDecimal; import java.security.KeyStore; +import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -81,9 +83,6 @@ public class XhpcRefundAuditController extends BaseController { @Autowired private XhpcUserAccountStatementServiceImpl xhpcUserAccountStatementService; - @Autowired - private Environment environment; - @Autowired private SmsService smsService; @Autowired @@ -91,7 +90,7 @@ public class XhpcRefundAuditController extends BaseController { @Autowired private IXhpcCommonPayment xhpcCommonPayment; @Autowired - private UserTypeService userTypeService; + private WorkOrderYuService workOrderService; private static final Logger logger = LoggerFactory.getLogger(XhpcRefundAuditController.class); /** @@ -728,7 +727,7 @@ public class XhpcRefundAuditController extends BaseController { public void moneyPage(){ logger.info("++++++++++++每20秒,扫描一次,退款订单金额小于100,自动审核通过++++++++++++++++"); try { - List list = iXhpcRefundOrderService.moneyPage(); + List list = iXhpcRefundOrderService.moneyPage(1); if(list !=null && list.size()>0){ for (int i = 0; i list = iXhpcRefundOrderService.moneyPage(2); + if(list !=null && list.size()>0){ + Date date = DateUtil.date(); + String format = DateUtil.format(date, "yyyy-MM-dd"); + R r = workOrderService.workOrderMessage(3, format); + if(r.getCode()==200){ + workOrderService.addNewOrder("3","有退款订单待处理","定时任务自动扫描退款订单",date,""); + } + } + }catch (Exception e){ + logger.info("++++++++++++每1分钟,扫描一次,退款订单金额大于100,自动生成工单异常++++++++++++++++"); + e.printStackTrace(); + //后期可以增加短信通知 + } + } } diff --git a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/mapper/XhpcRefundOrderMapper.java b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/mapper/XhpcRefundOrderMapper.java index fac4877d..6e30aa8b 100644 --- a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/mapper/XhpcRefundOrderMapper.java +++ b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/mapper/XhpcRefundOrderMapper.java @@ -111,7 +111,7 @@ public interface XhpcRefundOrderMapper { /** * 定时任务,每1小时,扫描一次,退款订单金额小于100,自动审核通过 */ - public List moneyPage(); + public List moneyPage(@Param("type")Integer type); /** diff --git a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/IXhpcRefundOrderService.java b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/IXhpcRefundOrderService.java index 251b0afc..a38cf1b7 100644 --- a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/IXhpcRefundOrderService.java +++ b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/IXhpcRefundOrderService.java @@ -110,6 +110,7 @@ public interface IXhpcRefundOrderService { /** * 定时任务,每5分钟,扫描一次,退款订单金额小于100,自动审核通过 + * type 1 小于101元 2大于100元 */ - public List moneyPage(); + public List moneyPage(Integer type); } \ No newline at end of file diff --git a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/impl/XhpcRefundOrderServiceImpl.java b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/impl/XhpcRefundOrderServiceImpl.java index 7180f191..03709918 100644 --- a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/impl/XhpcRefundOrderServiceImpl.java +++ b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/impl/XhpcRefundOrderServiceImpl.java @@ -222,9 +222,9 @@ public class XhpcRefundOrderServiceImpl implements IXhpcRefundOrderService { } @Override - public List moneyPage() { + public List moneyPage(Integer type) { - return xhpcRefundOrderMapper.moneyPage(); + return xhpcRefundOrderMapper.moneyPage(type); } } \ No newline at end of file diff --git a/xhpc-modules/xhpc-payment/src/main/resources/mapper/XhpcRefundOrderMapper.xml b/xhpc-modules/xhpc-payment/src/main/resources/mapper/XhpcRefundOrderMapper.xml index 99229ece..5b4da244 100644 --- a/xhpc-modules/xhpc-payment/src/main/resources/mapper/XhpcRefundOrderMapper.xml +++ b/xhpc-modules/xhpc-payment/src/main/resources/mapper/XhpcRefundOrderMapper.xml @@ -346,7 +346,13 @@ diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/controller/XhpcInvoiceController.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/controller/XhpcInvoiceController.java index 21634255..10887c17 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/controller/XhpcInvoiceController.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/controller/XhpcInvoiceController.java @@ -1,6 +1,9 @@ package com.xhpc.user.controller; +import cn.hutool.core.date.DateUtil; import com.aliyun.oss.OSSClient; +import com.xhpc.common.api.WorkOrderYuService; +import com.xhpc.common.core.domain.R; import com.xhpc.common.core.utils.DateUtils; import com.xhpc.common.core.web.controller.BaseController; import com.xhpc.common.core.web.domain.AjaxResult; @@ -11,6 +14,7 @@ import com.xhpc.user.domain.InvoiceToUserRequest; import com.xhpc.user.domain.SpecificInvoiceWrap; import com.xhpc.user.service.XhpcInvoiceService; import org.springframework.core.env.Environment; +import org.springframework.scheduling.annotation.Scheduled; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; @@ -18,6 +22,7 @@ import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.util.Arrays; +import java.util.Date; import java.util.List; import java.util.Map; @@ -36,6 +41,8 @@ public class XhpcInvoiceController extends BaseController { XhpcInvoiceService xhpcInvoiceService; @Resource Environment environment; + @Resource + WorkOrderYuService workOrderMessage; /** * 导出发票Excel接口 @@ -197,4 +204,27 @@ public class XhpcInvoiceController extends BaseController { return AjaxResult.success(specificInvoiceWrap); } + + + + @Scheduled(cron = "0 0/1 * * * ?") + @GetMapping("/getInvoiceInfo") + public void getInvoiceInfo(){ + logger.info("++++++++++++每1分钟,扫描一次,申请发票订单,自动生成工单++++++++++++++++"); + try { + int invoiceInfo = xhpcInvoiceService.getInvoiceInfo(); + if(invoiceInfo>0){ + Date date = DateUtil.date(); + String format = DateUtil.format(date, "yyyy-MM-dd"); + R r = workOrderMessage.workOrderMessage(5, format); + if(r.getCode()==200){ + workOrderMessage.addNewOrder("5","有申请发票订单待处理","定时任务自动扫描申请发票订单",date,""); + } + } + }catch (Exception e){ + logger.info("++++++++++++每1分钟,扫描一次,申请发票订单金额,自动生成工单异常++++++++++++++++"); + e.printStackTrace(); + //后期可以增加短信通知 + } + } } diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/mapper/XhpcInvoiceMapper.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/mapper/XhpcInvoiceMapper.java index 49a72f02..14b8cc3b 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/mapper/XhpcInvoiceMapper.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/mapper/XhpcInvoiceMapper.java @@ -198,4 +198,6 @@ public interface XhpcInvoiceMapper { */ void updateElectricAndServiceById(XhpcInvoice xhpcInvoice); + int getInvoiceInfo(); + } \ No newline at end of file diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/XhpcInvoiceService.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/XhpcInvoiceService.java index 80aff9a4..036fddb8 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/XhpcInvoiceService.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/XhpcInvoiceService.java @@ -149,4 +149,10 @@ public interface XhpcInvoiceService { */ void exportExcel(List invoiceIds, HttpServletResponse response) throws IOException; + /** + * 查询是否有未开票的订单 + * @return + */ + int getInvoiceInfo(); + } diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcInvoiceServiceImpl.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcInvoiceServiceImpl.java index 029eb3d6..ff8caaee 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcInvoiceServiceImpl.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcInvoiceServiceImpl.java @@ -708,6 +708,16 @@ public class XhpcInvoiceServiceImpl implements XhpcInvoiceService { writer.flush(response.getOutputStream(), true); } + /** + * 查询是否有未开票的订单 + * + * @return + */ + @Override + public int getInvoiceInfo() { + return xhpcInvoiceMapper.getInvoiceInfo(); + } + /** * 设置生成的Excel表格单元格标题 * diff --git a/xhpc-modules/xhpc-user/src/main/resources/bootstrap.yml b/xhpc-modules/xhpc-user/src/main/resources/bootstrap.yml index e5970990..b6890645 100644 --- a/xhpc-modules/xhpc-user/src/main/resources/bootstrap.yml +++ b/xhpc-modules/xhpc-user/src/main/resources/bootstrap.yml @@ -14,18 +14,18 @@ spring: nacos: discovery: # 服务注册地址 - server-addr: 127.0.0.1:8848 + server-addr: 172.31.183.135:8858 config: # 配置中心地址 - server-addr: 127.0.0.1:8848 + server-addr: 172.31.183.135:8858 # 配置文件格式 file-extension: yml # 共享配置 shared-configs: - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} -logging: - level: - com.xhpc.user.mapper: debug +#logging: +# level: +# com.xhpc.user.mapper: debug #获取微信openid地址 WXGETJSCODE: "https://api.weixin.qq.com/sns/jscode2session?appid=wxd0a48e00319ef8a7&secret=e26d9088b58e24af69411d5933cece47&js_code=" #支付宝公钥 diff --git a/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcInvoiceMapper.xml b/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcInvoiceMapper.xml index 18524555..f1460d69 100644 --- a/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcInvoiceMapper.xml +++ b/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcInvoiceMapper.xml @@ -767,4 +767,7 @@ WHERE invoice_id = #{invoiceId}; +