|
@@ -0,0 +1,231 @@
|
|
|
+package com.huyi.task.taskMan.schedule;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.huyi.task.base.entity.PayAccDetail;
|
|
|
+import com.huyi.task.base.entity.SysCompany;
|
|
|
+import com.huyi.task.base.entity.SysUserCompanyRel;
|
|
|
+import com.huyi.task.base.entity.ZcChargeInf;
|
|
|
+import com.huyi.task.base.service.IPayAccDetailService;
|
|
|
+import com.huyi.task.base.service.ISysCompanyService;
|
|
|
+import com.huyi.task.base.service.ISysUserCompanyRelService;
|
|
|
+import com.huyi.task.base.service.IZcChargeInfService;
|
|
|
+import com.huyi.task.taskMan.service.BankTaskService;
|
|
|
+import com.tianhu.common.core.domain.R;
|
|
|
+import com.tianhu.common.core.utils.AmtUtil;
|
|
|
+import com.tianhu.common.core.utils.CommonUtil;
|
|
|
+import com.tianhu.system.api.RemoteSystemService;
|
|
|
+import com.tianhu.system.api.RemoteZxBankService;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.context.annotation.Configuration;
|
|
|
+import org.springframework.scheduling.annotation.EnableScheduling;
|
|
|
+import org.springframework.scheduling.annotation.Scheduled;
|
|
|
+
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+@Configuration //1.主要用于标记配置类,兼备Component的效果。
|
|
|
+@EnableScheduling // 2.开启定时任务
|
|
|
+public class BankTask {
|
|
|
+ private static final Logger log = LoggerFactory.getLogger(BankTask.class);
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private RemoteZxBankService remoteZxBankService;
|
|
|
+ @Autowired
|
|
|
+ private IPayAccDetailService iPayAccDetailService;
|
|
|
+ @Autowired
|
|
|
+ private IZcChargeInfService iZcChargeInfService;
|
|
|
+ @Autowired
|
|
|
+ private RemoteSystemService remoteSystemService;
|
|
|
+ @Autowired
|
|
|
+ private ISysUserCompanyRelService iSysUserCompanyRelService;
|
|
|
+ @Autowired
|
|
|
+ private BankTaskService bankTaskService;
|
|
|
+ @Autowired
|
|
|
+ private ISysCompanyService iSysCompanyService;
|
|
|
+ /**
|
|
|
+ * 交易中的流水查证
|
|
|
+ */
|
|
|
+ //每30分钟
|
|
|
+ @Scheduled(cron = "0 */30 * * * ?")
|
|
|
+ //每天凌晨一点
|
|
|
+// @Scheduled(cron = "0 0 1 * * ?")
|
|
|
+ private void changeCreditStates() throws Exception{
|
|
|
+ //查询交易明细表
|
|
|
+ LambdaQueryWrapper<PayAccDetail> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.eq(PayAccDetail::getPadState,"00");
|
|
|
+ List<PayAccDetail> detailList = iPayAccDetailService.list(queryWrapper);
|
|
|
+
|
|
|
+ for(PayAccDetail detail : detailList){
|
|
|
+ //查询费用列表交易中的数据
|
|
|
+ LambdaQueryWrapper<ZcChargeInf> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.in(ZcChargeInf::getZciStatus,"01","04");
|
|
|
+ wrapper.eq(ZcChargeInf::getZciId,detail.getPadBusinessId());
|
|
|
+ List<ZcChargeInf> zcChargeInfList =iZcChargeInfService.list(wrapper);
|
|
|
+ //查询次数
|
|
|
+ String count = detail.getPadTarCount();
|
|
|
+ if (CommonUtil.isNotEmpty(count)) {
|
|
|
+ count = AmtUtil.add(count, "1", 0);
|
|
|
+ } else {
|
|
|
+ count = AmtUtil.add("0", "1", 0);
|
|
|
+ }
|
|
|
+ //若次数大于三次 则不再查询
|
|
|
+ if (CommonUtil.compare(count, "3") != 1) {
|
|
|
+ //根据交易状态查询接口处理费用列表接口。
|
|
|
+ R payStatus = remoteZxBankService.stateQuery(detail.getPadPayflowno());
|
|
|
+ System.out.println("交易查询接口========》"+payStatus.getData());
|
|
|
+ Map map = (Map) payStatus.getData();
|
|
|
+ PayAccDetail payAccDetail = new PayAccDetail();
|
|
|
+ payAccDetail.setPadNo(detail.getPadNo());
|
|
|
+
|
|
|
+ //有无费用列表数据
|
|
|
+ if(zcChargeInfList.size()>0) {
|
|
|
+ ZcChargeInf zcChargeInf = zcChargeInfList.get(0);
|
|
|
+ //费用列表状态 (00:待缴费;01:缴费中;02:已缴费;03:已退款 04:退款中05:缴费失败 06 退款失败)
|
|
|
+ String status = zcChargeInf.getZciStatus();
|
|
|
+ ZcChargeInf inf = new ZcChargeInf();
|
|
|
+ inf.setZciId(zcChargeInf.getZciId());
|
|
|
+ //根据查询结果处理
|
|
|
+ if (map.containsKey("status")) {
|
|
|
+ //stt 状态 0:未知 1成功 2 失败
|
|
|
+ String stt = map.get("status").toString();
|
|
|
+ if ("1".equals(stt)) {
|
|
|
+ payAccDetail.setPadState("01");
|
|
|
+ if ("01".equals(status)) {
|
|
|
+ inf.setZciStatus("02");
|
|
|
+ } else {
|
|
|
+ inf.setZciStatus("03");
|
|
|
+ }
|
|
|
+ } else if ("0".equals(stt)) {
|
|
|
+ payAccDetail.setPadState("00");
|
|
|
+ } else {
|
|
|
+ payAccDetail.setPadState("02");
|
|
|
+ if ("01".equals(status)) {
|
|
|
+ inf.setZciStatus("05");
|
|
|
+ } else {
|
|
|
+ inf.setZciStatus("06");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ iZcChargeInfService.updateZcChargeInf(inf);
|
|
|
+ //无费用列表时,只更改流水状态
|
|
|
+ }else{
|
|
|
+ if (map.containsKey("status")) {
|
|
|
+ //stt 状态 0:未知 1成功 2 失败
|
|
|
+ String stt = map.get("status").toString();
|
|
|
+ if ("1".equals(stt)) {
|
|
|
+ payAccDetail.setPadState("01");
|
|
|
+ } else if ("0".equals(stt)) {
|
|
|
+ payAccDetail.setPadState("00");
|
|
|
+ } else {
|
|
|
+ payAccDetail.setPadState("02");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ payAccDetail.setPadTarCount(count);
|
|
|
+ iPayAccDetailService.updatePayAccDetail(payAccDetail);
|
|
|
+ //若达到三次则生成待办
|
|
|
+ if ("3".equals(count)) {
|
|
|
+ LambdaQueryWrapper<SysUserCompanyRel> userLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ userLambdaQueryWrapper.eq(SysUserCompanyRel::getSucrCompanyId, "000000");
|
|
|
+ List<SysUserCompanyRel> userCompany = iSysUserCompanyRelService.list(userLambdaQueryWrapper);
|
|
|
+ String userList = "";
|
|
|
+ for (SysUserCompanyRel rel : userCompany) {
|
|
|
+ userList = userList + rel.getSucrUserId() + ",";
|
|
|
+ }
|
|
|
+ SysCompany company = iSysCompanyService.getById(detail.getPadCstno());
|
|
|
+ String title = "【交易失败】"+company.getScyName()+"向中信银行交易请求连续失败,请及时线下核实处理";
|
|
|
+ remoteSystemService.sendNotice("000000", "", title, "00", null, "10", "0", userList, null, "00", null);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 转账 调账跑批
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ //每30分钟
|
|
|
+ @Scheduled(cron = "0 */2 * * * ?")
|
|
|
+ //每天凌晨一点
|
|
|
+// @Scheduled(cron = "0 0 1 * * ?")
|
|
|
+ private void transferAmtHandle() throws Exception{
|
|
|
+ Map map = new HashMap();
|
|
|
+ //查询 退款 及平台调账 失败的数据进行再次转账
|
|
|
+ List<Map> tranList = bankTaskService.selectTranList(map);
|
|
|
+ for(Map detail : tranList){
|
|
|
+ //业务表id
|
|
|
+ String businessId = detail.get("businessId").toString();
|
|
|
+ //查询费用列表交易中的数据
|
|
|
+ LambdaQueryWrapper<ZcChargeInf> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.eq(ZcChargeInf::getZciId,businessId);
|
|
|
+ List<ZcChargeInf> zcChargeInfList =iZcChargeInfService.list(wrapper);
|
|
|
+ if(zcChargeInfList.size()>0){
|
|
|
+ ZcChargeInf inf = zcChargeInfList.get(0);
|
|
|
+ //备注
|
|
|
+ String remrk = detail.get("remrk").toString();
|
|
|
+ //付款账户
|
|
|
+ String accNo = detail.get("accNo").toString();
|
|
|
+ //交易金额
|
|
|
+ String tranAmt = detail.get("trxamout").toString();
|
|
|
+ //企业id
|
|
|
+ String companyId = detail.get("companyId").toString();
|
|
|
+ //类型 30 退款 94:平台调账
|
|
|
+ String type = detail.get("tranType").toString();
|
|
|
+ if(CommonUtil.isNotEmpty(remrk)){
|
|
|
+ String[] remrks = remrk.split(",");
|
|
|
+ String[] recvAccNo = remrks[1].split(":");
|
|
|
+ String[] recvAccNm = remrks[2].split(":");
|
|
|
+ R mess = remoteZxBankService.transfer(accNo,recvAccNo[1],recvAccNm[1],tranAmt,businessId,companyId,type);
|
|
|
+ System.out.println("交易查询接口========》"+mess.getData());
|
|
|
+ //数据信息
|
|
|
+ Map maps = (Map) mess.getData();
|
|
|
+ //状态是否存在
|
|
|
+ if(maps.containsKey("status")){
|
|
|
+ //状态 0 交易中 1 成功 2 失败
|
|
|
+ String status = maps.get("status").toString();
|
|
|
+ //退款
|
|
|
+ String title = "";
|
|
|
+ if ("30".equals(type)){
|
|
|
+ //退款时,只要不成功就给待办
|
|
|
+ if("0".equals(status)){
|
|
|
+ inf.setZciStatus("04");
|
|
|
+ title = "【转账受阻】中信银行业务流水号:" + maps.get("flow") + "转账受阻,请及时线下核实处理;";
|
|
|
+ }else if("1".equals(status)){
|
|
|
+ inf.setZciStatus("03");
|
|
|
+ }else {
|
|
|
+ inf.setZciStatus("06");
|
|
|
+ title = "【转账受阻】中信银行业务流水号:" + maps.get("flow") + "转账受阻,请及时线下核实处理;";
|
|
|
+
|
|
|
+ }
|
|
|
+ iZcChargeInfService.updateZcChargeInf(inf);
|
|
|
+ //平台调账时,只要不成功就给待办处理
|
|
|
+ }else{
|
|
|
+ if(!"1".equals(status)){
|
|
|
+ title = "【转账受阻】中信银行业务流水号:" + maps.get("flow") + "转账受阻,请及时线下核实处理;";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //若标题不为空,则进行添加待办
|
|
|
+ if(CommonUtil.isNotEmpty(title)){
|
|
|
+ LambdaQueryWrapper<SysUserCompanyRel> userLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ userLambdaQueryWrapper.eq(SysUserCompanyRel::getSucrCompanyId, "000000");
|
|
|
+ List<SysUserCompanyRel> userCompany = iSysUserCompanyRelService.list(userLambdaQueryWrapper);
|
|
|
+ String userList = "";
|
|
|
+ for (SysUserCompanyRel rel : userCompany) {
|
|
|
+ userList = userList + rel.getSucrUserId() + ",";
|
|
|
+ }
|
|
|
+ remoteSystemService.sendNotice("000000", "", title, "00", null, "10", "0", userList, null, "00", null);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+}
|
|
|
+
|