| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- package com.ydtech.modules.ttqf;
- import cn.hutool.extra.spring.SpringUtil;
- import com.alibaba.fastjson.JSONObject;
- import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
- import com.ipaynow.jiaxin.domain.OrderQueryResultModel;
- import com.ipaynow.jiaxin.response.OrderQueryResponse;
- import com.ydtech.modules.ttqf.dao.PaymentNoticeMapper;
- import com.ydtech.modules.ttqf.entity.PaymentNoticeEntity;
- import com.ydtech.utils.StringUtils;
- import lombok.extern.slf4j.Slf4j;
- import org.quartz.*;
- import java.util.Arrays;
- import java.util.Date;
- import java.util.Objects;
- @Slf4j
- public class RegularlyUpdateStatus implements Job {
- @Override
- public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
- try {
- if ((boolean) QuartzManager.getInstance().getContext().get("flag")){
- JobDataMap mergedJobDataMap = jobExecutionContext.getMergedJobDataMap();
- String orderNo = String.valueOf(mergedJobDataMap.get("orderNo"));
- log.info("打款状态定时任务入参:{}",orderNo);
- OrderQueryResponse response = SpringUtil.getBean(RetrieveTTQFApi.class).orderQuery(orderNo);
- log.info("打款状态定时返回执行数据:{}", JSONObject.toJSONString(response.getResultModel()));
- if (response == null || !StringUtils.equals(response.getBizCode(),"0000")) {
- log.info("获取打款状态任务退出{}");
- QuartzManager.getInstance().removeJob(jobExecutionContext);
- }
- if (response.isSuccess()) {
- if (Arrays.stream(PayConstantStatus.ORDER_ARRAY).anyMatch(i -> Objects.equals(i,response.getResultModel().getStatus()))){
- updatePayLog(orderNo,response.getResultModel());
- log.info("获取打款状态任务退出");
- }
- QuartzManager.getInstance().removeJob(jobExecutionContext);
- }
- log.info("当前线程+++++++++++++{}",Thread.currentThread().getId());
- }else {
- log.info("获取天天企赋状态退出",jobExecutionContext.getJobDetail().getKey().getName());
- QuartzManager.getInstance().removeJob(jobExecutionContext);
- }
- } catch (SchedulerException e) {
- throw new RuntimeException(e);
- }
- }
- public void updatePayLog(String orderNo, OrderQueryResultModel resultModel){
- QueryWrapper<PaymentNoticeEntity> wrapper = new QueryWrapper<>();
- wrapper.eq("order_no",orderNo);
- PaymentNoticeEntity notice = SpringUtil.getBean(PaymentNoticeMapper.class).selectOne(wrapper);
- if (null == notice){
- PaymentNoticeEntity noticeEntity = JSONObject.parseObject(JSONObject.toJSONString(resultModel), PaymentNoticeEntity.class);
- if (null == noticeEntity.getPayTime()){
- noticeEntity.setPayTime(new Date());
- }
- noticeEntity.setCreateTime(new Date());
- int update = SpringUtil.getBean(PaymentNoticeMapper.class).insert(noticeEntity);
- log.info("获取打款状态成功正在保存===========:{}",orderNo ,"+++++", update > 0 ? "保存成功" : "保存失败");
- }
- }
- }
|