优化审核

master
chenzhi 3 years ago
parent c4602116f2
commit e9a8356c77

@ -1561,57 +1561,79 @@ class StatementMangementController extends ThinkController
public function verify() {
$id = $_REQUEST["id"];
$status = $_REQUEST["status"];
$rewardDetailModel = SM("reward_detail","tab_");
$rewardRecordModel = SM("reward_record","tab_");
if (!isset($id)||!isset($status)) {
$this->ajaxReturn(["status"=>0,"msg"=>"参数错误"]);
}
if($status != 2) {
$data = SM("reward_record","tab_")
->field("is_verify,company_id,company_belong")
->join("left join tab_reward_detail on record_id=tab_reward_record.id")
->join("left join tab_promote_company on tab_promote_company.id=tab_reward_detail.company_id")
->where(["tab_reward_record.id"=>['in',$id]])
->select();
$dmap = [
"record_id"=>['in',$id],
];
foreach ($data as $key => $value) {
if ($value['is_verify'] != 0) {
$this->ajaxReturn(["status"=>0,"msg"=>"含有已审核无需重新审核"]);
}
if($status != 2) {
$dmap['is_check']=0;
$saveStatus = $status;
$saveDetail = json_encode(["user"=>$_SESSION['onethink_admin']['user_auth']['username'],"time"=>date("Y-m-d H:i:s",time())]);
}else{
$dmap['is_check']=['neq',0];
$saveStatus = 0;
$saveDetail = '';
}
}
$marketCompanyIds = A("Market","Event")->getAdminCompanyId();
if($marketCompanyIds != 'all'){
$dmap['company_id']=['in',$marketCompanyIds];
}
$detail = json_encode(["user"=>$_SESSION['onethink_admin']['user_auth']['username'],"time"=>date("Y-m-d H:i:s",time())]);
$is_success = SM("reward_record","tab_")->where(["id"=>['in',$id]])->save(["is_verify"=>$status,"verify_detail"=>$detail]);
//获取需要审核的细则表
$data = $rewardDetailModel
->field("id,record_id,is_check,company_id,check_detail")
->where($dmap)
->select();
if(empty($data)){
$this->ajaxReturn(["status"=>1,"msg"=>"操作失败"]);
}
//改母单
$recordIds = array_unique( array_column($data,"record_id") );
$rdIds = array_unique( array_column($data,"id") );
if ($is_success) {
$this->ajaxReturn(["status"=>1,"msg"=>"操作成功"]);
} else {
$this->ajaxReturn(["status"=>1,"msg"=>"操作失败"]);
}
} else {
foreach ($data as $key => $value) {
$value['is_check'] = $saveStatus;
$value['check_detail'] = $saveDetail;
$data = SM("reward_record","tab_")
->field("is_verify,company_id,company_belong")
->join("left join tab_reward_detail on record_id=tab_reward_record.id")
->join("left join tab_promote_company on tab_promote_company.id=tab_reward_detail.company_id")
->where(["tab_reward_record.id"=>['in',$id]])
->select();
$rewardDetailModel->save($value);
}
foreach ($data as $key => $value) {
if ($value['is_verify'] == 0) {
$this->ajaxReturn(["status"=>0,"msg"=>"含有未审核无需撤回审核"]);
}
if($status == 1){
//同意
$map = [
'record_id'=>['in',$recordIds],
'is_check'=>['neq',1],
'id'=>['NOT IN',$rdIds]
];
$record = $rewardDetailModel->where($map)->group("record_id")->getField("record_id,count(*) count",TRUE);
foreach ($recordIds as $key => $value) {
if(isset($record[$value])) continue;
$rSave = [
'id'=>$value,
'is_verify'=>$status
];
$rewardRecordModel->save($rSave);
}
$is_success = SM("reward_record","tab_")->where(["id"=>['in',$id]])->save(["is_verify"=>0,"verify_detail"=>'']);
if ($is_success) {
$this->ajaxReturn(["status"=>1,"msg"=>"操作成功"]);
} else {
$this->ajaxReturn(["status"=>1,"msg"=>"操作失败"]);
}else{
foreach ($recordIds as $key => $value) {
$rSave = [
'id'=>$value,
'is_verify'=>$saveStatus
];
$rewardRecordModel->save($rSave);
}
}
$this->ajaxReturn(["status"=>1,"msg"=>"操作成功"]);
}

Loading…
Cancel
Save