增加订单异常、退款申请超100元、未开票的自动生成工单

This commit is contained in:
yuyang 2022-06-06 17:48:41 +08:00
parent 644ca66080
commit 3a6968cd8c
26 changed files with 294 additions and 40 deletions

View File

@ -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);
}
}

View File

@ -11,8 +11,7 @@ public interface XhpcWorkOrderMapper {
List<Map<String, Object>> 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<XhpcWorkOrderUserDomain> 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);
}

View File

@ -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);
}

View File

@ -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<String, String> paramMap = new HashMap<>();

View File

@ -182,7 +182,7 @@
1,
</when>
<otherwise>
#{status}
#{status},
</otherwise>
</choose>
0,
@ -263,9 +263,12 @@
where work_order_id = #{workOrderId,jdbcType=BIGINT}
</update>
<delete id="deleteOrderUserByOrderId">
delete from xhpc_work_order_user where order_id=#{orderId}
</delete>
<select id="workOrderMessage" resultType="int">
select count(work_order_id) from xhpc_work_order where type=#{type} and create_time like concat('%', #{time}, '%') and status !=2
</select>
</mapper>

View File

@ -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);
}

View File

@ -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<WorkOrderYuService> {
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());
}
};
}
}

View File

@ -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);

View File

@ -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<XhpcChargeHistoryOrder> list = xhpcHistoryOrderService.getStatistisList(number,type);

View File

@ -213,6 +213,7 @@ public interface XhpcChargeOrderMapper {
*/
List<XhpcChargeOrder> getFourTimsStatus();
int getChargeOrderStatus();
/**
* 查询相同桩之后是否有订单结算
* @param serialNumber 订单号

View File

@ -160,6 +160,11 @@ public interface IXhpcChargeOrderService {
*/
void updateStatus();
/**
* 查询是否有异常订单
* @return
*/
int getChargeOrderStatus();
//获取桩信息
Map<String,Object> getXhpcChargingPileById(Long chargingPileId);

View File

@ -675,6 +675,16 @@ public class XhpcChargeOrderServiceImpl extends BaseService implements IXhpcChar
}
}
/**
* 查询是否有异常订单
*
* @return
*/
@Override
public int getChargeOrderStatus() {
return xhpcChargeOrderMapper.getChargeOrderStatus();
}
@Override
public Map<String, Object> getXhpcChargingPileById(Long chargingPileId) {
return xhpcChargeOrderMapper.getXhpcChargingPileById(chargingPileId,null);

View File

@ -350,8 +350,16 @@ public class XhpcRealTimeOrderServiceImpl extends BaseService implements IXhpcRe
}
xhpcChargeOrder.setStatus(3);
xhpcChargeOrder.setAmountCharged(money);
xhpcChargeOrder.setStopReasonEvcs(45);
try{
Map<String, Object> 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{

View File

@ -709,6 +709,9 @@
select * from xhpc_charge_order where now() >DATE_ADD(create_time,interval 4 hour) and status=0
</select>
<select id="getChargeOrderStatus" resultType="int">
select count(charge_order_id) from xhpc_charge_order where status =2
</select>
<select id="getSerialNumberLike" resultType="int">
select count(charge_order_id) from xhpc_charge_order where serial_number like concat('%', #{serialNumber}, '%') and charge_order_id &gt; #{chargeOrderId} and status=1
</select>

View File

@ -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 &lt;= #{startTime} AND replace(end_time, '00:00:00', '23:59:59') &gt;= #{startTime} AND del_flag=0
)
<if test="endTime !='' and endTime !=null and endTime !='00:00:00' ">
<if test="endTime !='24:00:00' ">
or rt.rate_time_id in (
SELECT rate_time_id FROM xhpc_rate_time WHERE rate_model_id = #{rateModelId} AND start_time &lt;= #{endTime} AND replace(end_time, '00:00:00', '23:59:59') &gt;= #{endTime} AND del_flag=0
)
</if>
</if>
and rt.rate_model_id = #{rateModelId}
</select>

View File

@ -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<Long> list = iXhpcRefundOrderService.moneyPage();
List<Long> list = iXhpcRefundOrderService.moneyPage(1);
if(list !=null && list.size()>0){
for (int i = 0; i <list.size() ; i++) {
Long aLong = list.get(i);
@ -745,5 +744,25 @@ public class XhpcRefundAuditController extends BaseController {
//后期可以增加短信通知
}
}
@Scheduled(cron = "0 0/1 * * * ?")
@GetMapping("/moneyPageTime")
public void moneyPageTime(){
logger.info("++++++++++++每1分钟扫描一次退款订单金额大于100自动生成工单++++++++++++++++");
try {
List<Long> 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();
//后期可以增加短信通知
}
}
}

View File

@ -111,7 +111,7 @@ public interface XhpcRefundOrderMapper {
/**
* 定时任务每1小时扫描一次退款订单金额小于100自动审核通过
*/
public List<Long> moneyPage();
public List<Long> moneyPage(@Param("type")Integer type);
/**

View File

@ -110,6 +110,7 @@ public interface IXhpcRefundOrderService {
/**
* 定时任务每5分钟扫描一次退款订单金额小于100自动审核通过
* type 1 小于101元 2大于100元
*/
public List<Long> moneyPage();
public List<Long> moneyPage(Integer type);
}

View File

@ -222,9 +222,9 @@ public class XhpcRefundOrderServiceImpl implements IXhpcRefundOrderService {
}
@Override
public List<Long> moneyPage() {
public List<Long> moneyPage(Integer type) {
return xhpcRefundOrderMapper.moneyPage();
return xhpcRefundOrderMapper.moneyPage(type);
}
}

View File

@ -346,7 +346,13 @@
<select id="moneyPage" resultType="long">
select xro.refund_order_id refundOrderId
from xhpc_refund_order xro
where xro.del_flag = 0 and xro.examine_status=0 and xro.status=0 and amount&lt;=100
where xro.del_flag = 0 and xro.examine_status=0 and xro.status=0
<if test="type==1">
and amount &lt;=100
</if>
<if test="type=2">
and amount &gt;100
</if>
</select>
<update id="updateRefundApplication">

View File

@ -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();
//后期可以增加短信通知
}
}
}

View File

@ -198,4 +198,6 @@ public interface XhpcInvoiceMapper {
*/
void updateElectricAndServiceById(XhpcInvoice xhpcInvoice);
int getInvoiceInfo();
}

View File

@ -149,4 +149,10 @@ public interface XhpcInvoiceService {
*/
void exportExcel(List<String> invoiceIds, HttpServletResponse response) throws IOException;
/**
* 查询是否有未开票的订单
* @return
*/
int getInvoiceInfo();
}

View File

@ -708,6 +708,16 @@ public class XhpcInvoiceServiceImpl implements XhpcInvoiceService {
writer.flush(response.getOutputStream(), true);
}
/**
* 查询是否有未开票的订单
*
* @return
*/
@Override
public int getInvoiceInfo() {
return xhpcInvoiceMapper.getInvoiceInfo();
}
/**
* 设置生成的Excel表格单元格标题
*

View File

@ -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="
#支付宝公钥

View File

@ -767,4 +767,7 @@
WHERE invoice_id = #{invoiceId};
</update>
<select id="getInvoiceInfo" resultType="int">
select count(invoice_id) from xhpc_invoice where status =0
</select>
</mapper>