优化审核

master
chenzhi 3 years ago
parent c4602116f2
commit e9a8356c77

@ -1561,57 +1561,79 @@ class StatementMangementController extends ThinkController
public function verify() { public function verify() {
$id = $_REQUEST["id"]; $id = $_REQUEST["id"];
$status = $_REQUEST["status"]; $status = $_REQUEST["status"];
$rewardDetailModel = SM("reward_detail","tab_");
$rewardRecordModel = SM("reward_record","tab_");
if (!isset($id)||!isset($status)) { if (!isset($id)||!isset($status)) {
$this->ajaxReturn(["status"=>0,"msg"=>"参数错误"]); $this->ajaxReturn(["status"=>0,"msg"=>"参数错误"]);
} }
if($status != 2) { $dmap = [
$data = SM("reward_record","tab_") "record_id"=>['in',$id],
->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();
foreach ($data as $key => $value) { if($status != 2) {
if ($value['is_verify'] != 0) { $dmap['is_check']=0;
$this->ajaxReturn(["status"=>0,"msg"=>"含有已审核无需重新审核"]); $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"=>"操作成功"]); foreach ($data as $key => $value) {
} else { $value['is_check'] = $saveStatus;
$this->ajaxReturn(["status"=>1,"msg"=>"操作失败"]); $value['check_detail'] = $saveDetail;
}
} else {
$data = SM("reward_record","tab_") $rewardDetailModel->save($value);
->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();
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"=>'']); }else{
foreach ($recordIds as $key => $value) {
if ($is_success) { $rSave = [
$this->ajaxReturn(["status"=>1,"msg"=>"操作成功"]); 'id'=>$value,
} else { 'is_verify'=>$saveStatus
$this->ajaxReturn(["status"=>1,"msg"=>"操作失败"]); ];
$rewardRecordModel->save($rSave);
} }
} }
$this->ajaxReturn(["status"=>1,"msg"=>"操作成功"]);
} }

Loading…
Cancel
Save