|
|
|
@ -1,252 +0,0 @@
|
|
|
|
|
package com.dsideal.baseService.Verification.model;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.date.DateTime;
|
|
|
|
|
import com.jfinal.kit.Kv;
|
|
|
|
|
import com.jfinal.plugin.activerecord.Db;
|
|
|
|
|
import com.jfinal.plugin.activerecord.Page;
|
|
|
|
|
import com.jfinal.plugin.activerecord.Record;
|
|
|
|
|
import com.jfinal.plugin.activerecord.SqlPara;
|
|
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
public class VerificationModel {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 功能:获取指定接入模块的开始第一步序号
|
|
|
|
|
* 作者:黄海
|
|
|
|
|
* 时间:2020-08-18
|
|
|
|
|
*/
|
|
|
|
|
public int getFirstStepId(int module_id) {
|
|
|
|
|
String sql = "select min(step_id) as step_id from t_verification_step where module_id=? and b_use=0";
|
|
|
|
|
List<Record> list = Db.find(sql, module_id);
|
|
|
|
|
if (list.size() > 0) {
|
|
|
|
|
return list.get(0).getInt("step_id");
|
|
|
|
|
} else {
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 功能:获取指定接入模块的结束最后一步序号
|
|
|
|
|
* 作者:黄海
|
|
|
|
|
* 时间:2020-08-18
|
|
|
|
|
*/
|
|
|
|
|
public int getLastStepId(int module_id) {
|
|
|
|
|
String sql = "select max(step_id) as step_id from t_verification_step where module_id=? and b_use=0";
|
|
|
|
|
List<Record> list = Db.find(sql, module_id);
|
|
|
|
|
if (list.size() > 0) {
|
|
|
|
|
return list.get(0).getInt("step_id");
|
|
|
|
|
} else {
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 功能:在操作的记录表中,找到指定接入模块+指定业务ID的最后一条记录,就是最新的记录
|
|
|
|
|
* 作者:黄海
|
|
|
|
|
* 时间:2020-08-18
|
|
|
|
|
*
|
|
|
|
|
* @param module_id
|
|
|
|
|
* @param business_id
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
private int getLastRecordId(int module_id, int business_id) {
|
|
|
|
|
String sql = "select max(record_id) as record_id from t_verification_record where module_id=? and business_id=?";
|
|
|
|
|
List<Record> list = Db.find(sql, module_id, business_id);
|
|
|
|
|
if (list.size() > 0) {
|
|
|
|
|
return list.get(0).getInt("record_id");
|
|
|
|
|
} else {
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 功能:获取审核通过后下一步的步骤ID
|
|
|
|
|
* 作者:黄海
|
|
|
|
|
* 时间:2020-08-18
|
|
|
|
|
*
|
|
|
|
|
* @param step_id
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public int getNextStepId(int step_id) {
|
|
|
|
|
String sql = "select step_id from t_verification_step where parent_id=? and b_use=0";
|
|
|
|
|
List<Record> list = Db.find(sql, step_id);
|
|
|
|
|
if (list.size() > 0) {
|
|
|
|
|
return list.get(0).getInt("step_id");
|
|
|
|
|
} else {
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 功能:传入一个步骤ID,获取这个步骤对应的实体记录
|
|
|
|
|
* 作者:黄海
|
|
|
|
|
* 时间:2020-08-15
|
|
|
|
|
*
|
|
|
|
|
* @param step_id
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
private Record getStepRecord(int step_id) {
|
|
|
|
|
Record record = Db.findById("t_verification_step", "step_id", step_id);
|
|
|
|
|
return record;
|
|
|
|
|
}
|
|
|
|
|
/*****************************************************************************************************/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 功能:添加一条审核记录,在两个地方有用,1:全新创建一条审核记录时,2:在被拒绝后,重新创建一条审核记录时。
|
|
|
|
|
* 作者:黄海
|
|
|
|
|
* 时间:2020-08-18
|
|
|
|
|
*/
|
|
|
|
|
public int insertVerificationRecord(int module_id, int business_id) {
|
|
|
|
|
//(1)检查这个模块中的此业务ID是否存在,如果不存在,则全新创建,如果存在,则添加下一条
|
|
|
|
|
String sql = "select ifnull(max(step_id),0) as step_id,ifnull(verification_status,0) as verificationStatus from t_verification_record where module_id=? and business_id=? order by record_id desc";
|
|
|
|
|
List<Record> list = Db.find(sql, module_id, business_id);
|
|
|
|
|
|
|
|
|
|
//如果存在旧的,表示是被拒绝后,重新创建一条审核记录
|
|
|
|
|
int step_id = list.get(0).getInt("step_id");
|
|
|
|
|
int verification_status = list.get(0).getInt("verification_status");
|
|
|
|
|
|
|
|
|
|
//TODO
|
|
|
|
|
//0 表示没有找到数据,是全新的
|
|
|
|
|
if (verification_status > 0 && verification_status != 4) {
|
|
|
|
|
//4:退回修改
|
|
|
|
|
//没有找到的话,就是全新的!
|
|
|
|
|
if (step_id == 0) {
|
|
|
|
|
//开始第一步的step_id
|
|
|
|
|
step_id = getFirstStepId(module_id);
|
|
|
|
|
} else {
|
|
|
|
|
//获取下一步的step_id
|
|
|
|
|
step_id = getNextStepId(module_id);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (step_id == 0) {
|
|
|
|
|
//开始第一步的step_id
|
|
|
|
|
step_id = getFirstStepId(module_id);
|
|
|
|
|
} else {
|
|
|
|
|
//获取下一步的step_id
|
|
|
|
|
step_id = getNextStepId(module_id);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//(2)构建实体,准备增加
|
|
|
|
|
Record record = new Record();
|
|
|
|
|
record.set("step_id", step_id);
|
|
|
|
|
record.set("module_id", module_id);
|
|
|
|
|
record.set("business_id", business_id);
|
|
|
|
|
record.set("create_time", DateTime.now());
|
|
|
|
|
record.set("verification_status", 2);//待审核
|
|
|
|
|
//(3)增加记录
|
|
|
|
|
Db.save("t_verification_record", "record_id", record);
|
|
|
|
|
//返回新生成的ID
|
|
|
|
|
return record.getInt("record_id");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 功能:通过当前的审核
|
|
|
|
|
* 作者:黄海
|
|
|
|
|
* 时间:2020-08-18
|
|
|
|
|
*/
|
|
|
|
|
public void passCurrentVerification(int record_id, String person_id, String verification_judgement) {
|
|
|
|
|
//(1)修改当前审核通过记录
|
|
|
|
|
Record record = Db.findById("t_verification_record", "record_id", record_id);
|
|
|
|
|
record.set("verification_status", 1);//审核通过
|
|
|
|
|
record.set("verification_person_id", person_id);//审核人
|
|
|
|
|
record.set("verification_time", DateTime.now());//审核时间
|
|
|
|
|
record.set("verification_judgement", verification_judgement);//审核意见
|
|
|
|
|
Db.update("t_verification_record", "record_id", record);
|
|
|
|
|
//(2)生成下一步的审核记录
|
|
|
|
|
int step_id = record.getInt("step_id");
|
|
|
|
|
int module_id = record.getInt("module_id");
|
|
|
|
|
int business_id = record.getInt("business_id");
|
|
|
|
|
//(3)是不是已经到了终结时刻?
|
|
|
|
|
int max_step_id = getLastStepId(module_id);
|
|
|
|
|
if (max_step_id != step_id) {
|
|
|
|
|
//(4)如果还没有到终结时刻,那么生成下一步数据记录
|
|
|
|
|
insertVerificationRecord(module_id, business_id);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 功能:拒绝当前的审核
|
|
|
|
|
* 作者:黄海
|
|
|
|
|
* 时间:2020-08-18
|
|
|
|
|
*/
|
|
|
|
|
public void refuseCurrentVerification(int record_id, String person_id, String verification_judgement) {
|
|
|
|
|
//修改当前审核通过记录
|
|
|
|
|
Record record = Db.findById("t_verification_record", "record_id", record_id);
|
|
|
|
|
record.set("verification_status", -1);//审核拒绝
|
|
|
|
|
record.set("verification_person_id", person_id);//审核人
|
|
|
|
|
record.set("verification_time", DateTime.now());//审核时间
|
|
|
|
|
record.set("verification_judgement", verification_judgement);//审核意见
|
|
|
|
|
Db.update("t_verification_record", "record_id", record);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 功能:获取审核列表
|
|
|
|
|
* 作者:黄海
|
|
|
|
|
* 时间:2020-08-18
|
|
|
|
|
*
|
|
|
|
|
* @param module_id
|
|
|
|
|
* @param verification_status
|
|
|
|
|
* @param page
|
|
|
|
|
* @param limit
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public Page<Record> getVerificationList(int module_id, int verification_status, String identity_id, int page, int limit) {
|
|
|
|
|
Kv kv = Kv.create();
|
|
|
|
|
kv = kv.set("module_id", module_id).set("identity_id", identity_id);
|
|
|
|
|
|
|
|
|
|
if (verification_status > 0) {
|
|
|
|
|
kv = kv.set("verification_status", verification_status);
|
|
|
|
|
}
|
|
|
|
|
SqlPara sp = Db.getSqlPara("Verification.getVerifcationList", kv);
|
|
|
|
|
return Db.paginate(page, limit, sp);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 功能:检查业务模块中某条业务记录,是不是处于审核状态中,用来判断是不是可以重新发起申请审核
|
|
|
|
|
* 作者:黄海
|
|
|
|
|
* 时间:2020-08-18
|
|
|
|
|
*/
|
|
|
|
|
public boolean canApplyVerification(int module_id, int business_id) {
|
|
|
|
|
//(1)可以发起审核的状态包括: 1:待提交,4:退回修改
|
|
|
|
|
//(2)不可以发起审核的状态包括 :2:已提交,待审批,3:已通过,5:已拒绝
|
|
|
|
|
String sql = "select * from t_verification_record where module_id=? and business_id=? order by record_id limit 1";
|
|
|
|
|
List<Record> list = Db.find(sql, module_id, business_id);
|
|
|
|
|
if (list.size() > 0) {
|
|
|
|
|
int verification_status = list.get(0).getInt("verification_status");
|
|
|
|
|
if (verification_status == 4) {
|
|
|
|
|
return true;
|
|
|
|
|
} else {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 功能:获取单条业务数据的审核状态
|
|
|
|
|
* 作者:黄海
|
|
|
|
|
* 时间:2020-08-18
|
|
|
|
|
*/
|
|
|
|
|
public int getVerificationStatus(int module_id, int business_id) {
|
|
|
|
|
String sql = "select * from t_verification_record where module_id=? and business_id=? order by record_id limit 1";
|
|
|
|
|
List<Record> list = Db.find(sql, module_id, business_id);
|
|
|
|
|
if (list.size() > 0) {
|
|
|
|
|
int verification_status = list.get(0).getInt("verification_status");
|
|
|
|
|
return verification_status;
|
|
|
|
|
} else {
|
|
|
|
|
return -99999;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 功能:获取当前审核的信息
|
|
|
|
|
* 作者:黄海
|
|
|
|
|
* 时间:2020-8-19
|
|
|
|
|
*/
|
|
|
|
|
public Record getModuleInfoById(int record_id) {
|
|
|
|
|
Record record = Db.findById("t_verification_record", "record_id", record_id);
|
|
|
|
|
return record;
|
|
|
|
|
}
|
|
|
|
|
}
|