Audit.php 113 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497
  1. <?php
  2. namespace app\admin\controller\project;
  3. use app\admin\BaseController;
  4. use app\admin\model\CostProject as CostProjectModel;
  5. use app\admin\model\ProjectAudit as AuditModel;
  6. use app\admin\model\ProjectMsg;
  7. use app\admin\model\ProjectReport;
  8. use app\admin\validate\project\CostProjectValidate;
  9. use think\db\exception\DbException;
  10. use think\db\Where;
  11. use think\exception\ValidateException;
  12. use think\facade\Db;
  13. use think\facade\Session;
  14. use think\facade\View;
  15. use think\App;
  16. use app\admin\controller\field\Field;
  17. use app\wechat\controller\Officialaccount;
  18. use app\admin\controller\Pushmessage;
  19. /*
  20. * 待审核项目
  21. */
  22. class Audit extends BaseController
  23. {
  24. public function __construct(App $app)
  25. {
  26. parent::__construct($app);
  27. $this->Field = new Field($this->app);
  28. $this->model = new CostProjectModel();
  29. $this->Auditmodel = new AuditModel();
  30. $this->ProjectMsg = new ProjectMsg();
  31. $this->uid = get_login_admin('id');
  32. $this->Officialaccount = new Officialaccount();
  33. $this->Pushmessage = new Pushmessage();
  34. }
  35. public function datalist()//财政局审核列表
  36. {
  37. //搜索
  38. if (request()->isAjax()) {
  39. $param = get_params();//获取内容
  40. $where = [
  41. ["cp_project_audit.approver", "=", $this->uid],//审批人的id
  42. ["cp_project_audit.audit_type", "<", 4]
  43. ];
  44. if(!empty($param["keywords"])){
  45. $where[] = ["c.review_unit_name|c.engineering_type|a.project_name","like","%".$param["keywords"]."%"];
  46. }
  47. $rows = empty($param['limit']) ? get_config('app . page_size') : $param['limit'];//分页数据条数
  48. $order = empty($param['order']) ? 'id desc' : $param['order'];//排序方式
  49. //将表a与表c通过a.project_id=c.id左关联,查a就能查到c中相关数据
  50. $list2 = $this->Auditmodel->alias('a')->join("cost_project c", "a.project_id=c.id", 'left')
  51. /*查询字段*/ ->field("a.*,c.project_status,c.sent_review_amount,c.engineering_type,c.review_unit_name")->where($where)->order($order)
  52. ->paginate($rows, false, ['query' => $param])
  53. ->each(function ($item) {
  54. if ($item->audit_type ==1){//一开始不显示二审
  55. if (isset($item->c['entrust_second_approver'])){
  56. $audit_status =Db::name(Auditmodel)->where("audit_name" ,"项目分配审核一审")->value("audit_status");
  57. if ($audit_status=1){
  58. $item->whereNotIn('audit_name', ['项目分配审核二审']);
  59. }
  60. }
  61. }
  62. if ($item->audit_type == 2) {//报告//else_id=>报告id
  63. $a = Db::name("project_report")->where("id", $item->else_id)->field("title,status")->find();
  64. $item->else_name = $a["title"];
  65. $item->else_status = $a["status"];
  66. } elseif ($item->audit_type == 3) {//联系函//else_id=>项目联系函id
  67. $a = Db::name("contact")->where("id", $item->else_id)->field("title,status")->find();
  68. $item->else_name = $a["title"];
  69. $item->else_status = $a["status"];
  70. }
  71. });
  72. return table_assign(0, '', $list2);
  73. } else {
  74. return view();
  75. }
  76. }
  77. /**
  78. *
  79. * 公司审核列表
  80. */
  81. public function datalist_company()
  82. {
  83. if (request()->isAjax()) {
  84. $param = get_params();
  85. //audit_type 1项目,2报告,3联系函,4公司一级审核,5公司二级审核,6公司三级审核
  86. //audit_status 审批状态 1.待审核,2已通过,3已拒绝,4作废,5待启用
  87. $where = [
  88. ["a.approver", "=", $this->uid],
  89. ["a.audit_type", ">", 3],
  90. ["a.audit_status", "<", 5]
  91. ];
  92. if(!empty($param["keywords"])){
  93. $where[] = ["c.entrust_unit_name|c.engineering_type|a.project_name","like","%".$param["keywords"]."%"];
  94. }
  95. $rows = empty($param['limit']) ? get_config('app . page_size') : $param['limit'];
  96. $order = empty($param['order']) ? 'id desc' : $param['order'];
  97. $list2 = $this->Auditmodel->alias('a')->join("cost_project c", "a.project_id=c.id", 'left')
  98. ->field("a.*,c.project_status,c.sent_review_amount,c.engineering_type,c.review_unit_name")->where($where)->order($order)
  99. ->paginate($rows, false, ['query' => $param])
  100. ->each(function ($item) {
  101. switch ($item["audit_type"]) {
  102. case 4:
  103. case 5:
  104. case 6:
  105. case 14:
  106. case 15:
  107. $item->else_name = Db::name("project_report")->where("id", $item["else_id"])->value("title");
  108. break;
  109. case 9:
  110. case 8:
  111. case 7:
  112. $item->else_name = Db::name("contact")->where("id", $item["else_id"])->value("title");
  113. break;
  114. case 10:
  115. $item->else_name = "请款一级审核";
  116. break;
  117. case 11:
  118. $item->else_name = "请款二级审核";
  119. break;
  120. case 12:
  121. $item->else_name = "请款三级审核";
  122. break;
  123. }
  124. });
  125. return table_assign(0, '', $list2);
  126. } else {
  127. return view();
  128. }
  129. }
  130. public function datalist_proprietor()//业主审核列表
  131. {
  132. if (request()->isAjax()) {
  133. $param = get_params();
  134. $where = [
  135. ["cp_project_audit.approver", "=", $this->uid],//审批人是登录的
  136. ["cp_project_audit.audit_type", "<", 4]//
  137. ];
  138. if(!empty($param["keywords"])){
  139. $where[] = ["c.review_unit_name|c.engineering_type|a.project_name","like","%".$param["keywords"]."%"];
  140. }
  141. $rows = empty($param['limit']) ? get_config('app . page_size') : $param['limit'];
  142. $order = empty($param['order']) ? 'id desc' : $param['order'];
  143. $list2 = $this->Auditmodel->alias('a')->join("cost_project c", "a.project_id=c.id", 'left')
  144. ->field("a.*,c.project_status,c.sent_review_amount,c.engineering_type,c.review_unit_name")->where($where)->order($order)
  145. ->paginate($rows, false, ['query' => $param])
  146. ->each(function ($item) {
  147. if ($item->audit_type == 2) {//报告
  148. $a = Db::name("project_report")->where("id", $item->else_id)->field("title,status")->find();
  149. $item->else_name = $a["title"];
  150. $item->else_status = $a["status"];
  151. } elseif ($item->audit_type == 3) {//联系函
  152. $a = Db::name("contact")->where("id", $item->else_id)->field("title,status")->find();
  153. $item->else_name = $a["title"];
  154. $item->else_status = $a["status"];
  155. }
  156. });
  157. return table_assign(0, '', $list2);
  158. } else {
  159. return view();
  160. }
  161. }
  162. /**
  163. * 首页待审核列表
  164. */
  165. public function list()
  166. {
  167. if (request()->isAjax()) {
  168. $param = get_params();
  169. $where = [
  170. ["cp_project_audit.approver", "=", $this->uid],
  171. ["cp_project_audit.audit_type", "<", 4],
  172. ["cp_project_audit.audit_status", "=", 1],
  173. ];
  174. if(!empty($param["keywords"])){
  175. $where[] = ["c.review_unit_name|c.engineering_type|a.project_name","like","%".$param["keywords"]."%"];
  176. }
  177. $rows = empty($param['limit']) ? get_config('app . page_size') : $param['limit'];
  178. $order = empty($param['order']) ? 'id desc' : $param['order'];
  179. $list2 = $this->Auditmodel->alias('a')->join("cost_project c", "a.project_id=c.id", 'left')
  180. ->field("a.*,c.project_status,c.sent_review_amount,c.engineering_type,c.review_unit_name")->where($where)->order($order)
  181. ->paginate($rows, false, ['query' => $param])
  182. ->each(function ($item) {
  183. if ($item->audit_type == 2) {
  184. $a = Db::name("project_report")->where("id", $item->else_id)->field("title,status")->find();
  185. $item->else_name = $a["title"];
  186. $item->else_status = $a["status"];
  187. } elseif ($item->audit_type == 3) {
  188. $a = Db::name("contact")->where("id", $item->else_id)->field("title,status")->find();
  189. $item->else_name = $a["title"];
  190. $item->else_status = $a["status"];
  191. }
  192. });
  193. return table_assign(0, '', $list2);
  194. } else {
  195. return view();
  196. }
  197. }
  198. /**
  199. * 项目日志
  200. */
  201. public function project_log($project_id)
  202. {
  203. // $project_id = 24;
  204. $login_admin = get_login_admin();
  205. $where = array();
  206. if ($login_admin['user_type'] == 2) {
  207. $where = [
  208. ['project_status', '>=', 3],
  209. ['unit_name', '=', $login_admin['unit_name']],
  210. ];
  211. } else {
  212. if ($login_admin['permission'] != 1) {
  213. $where = [
  214. ['unit_name', '=', $login_admin['unit_name']],
  215. ];
  216. }
  217. }
  218. // dump($where);
  219. $project_log = Db::name('ProjectLog')->where($where)->where('project_id', $project_id)->order('create_time', 'desc')->select()->toArray();
  220. foreach ($project_log as $key => $value) {
  221. $project_log[$key]['create_time'] = date("Y-m-d H:i:s", $value['create_time']);
  222. }
  223. // dump($project_log);
  224. // View::assign('project_log', $project_log);
  225. // return View();
  226. return $project_log;
  227. }
  228. /**
  229. * 查看信息
  230. */
  231. public function read()
  232. {
  233. $param = get_params();
  234. $id = isset($param['id']) ? $param['id'] : 0;
  235. $detail = $this->model->getCostProjectById($id);
  236. $comment = Db::name("project_comment")->where("project_id", $id)->order('create_time', 'desc')->select();
  237. $file_array = Db::name('ProjectFile')
  238. ->field('mf.id,mf.topic_id,mf.admin_id,f.name,f.filesize,f.filepath,f.fileext,f.create_time,f.admin_id,a.nickname as admin_name')
  239. ->alias('mf')
  240. ->join('File f', 'mf.file_id = f.id', 'LEFT')
  241. ->join('Admin a', 'mf.admin_id = a.id', 'LEFT')
  242. ->order('mf.create_time desc')
  243. ->where(array('mf.topic_id' => $id, 'mf.module' => 'project'))
  244. ->select()->toArray();
  245. $report = Db::name("project_report")->where([["project_id", "=", $id], ["r.status", "=", 1]])->alias("r")->join("admin a", "r.maker_id = a.id")->field("r.*,a.nickname")->select();
  246. // halt($comment);
  247. $project_log = self::project_log($id);
  248. View::assign('project_log', $project_log);
  249. // halt($project_log);
  250. // 根据用户id 查询其能显示的字段
  251. $field = $this->Field->get_field_rules_new(get_login_admin('id'));
  252. //剩余时间
  253. $c = $detail['project_end_time'] - time();
  254. if ($c > 0) {
  255. $advent_time = floor($c / 86400) . "天";
  256. } else {
  257. $c = -$c;
  258. $advent_time = floor($c / 86400) . "天";
  259. }
  260. if (!empty($detail)) {
  261. View::assign('advent_time', $advent_time);
  262. View::assign('project_id', $id);
  263. View::assign('comment', $comment);
  264. View::assign('field', $field);
  265. View::assign('detail', $detail);
  266. View::assign('file_array', $file_array);
  267. View::assign('report', $report);
  268. View::assign('project_five', self::getProjectFive());
  269. return view();
  270. } else {
  271. throw new \think\exception\HttpException(404, '找不到页面');
  272. }
  273. }
  274. /**
  275. * 公司查看信息
  276. */
  277. public function read_company()
  278. {
  279. $param = get_params();
  280. if (request()->isAjax()) {
  281. $a = time();
  282. $id = isset($param["project_id"]) ? $param["project_id"] : $a;
  283. if ($id == $a) {
  284. $datas = array();
  285. $datas["data"] = null;
  286. return table_assign(0, "无项目", $datas);
  287. }
  288. $project = Db::name("appropriation_project")->where("uid", $id)->select();
  289. $datas["data"] = $project;
  290. $datas["total"] = count($project);
  291. return table_assign(0, "", $datas);
  292. } else {
  293. if ($param["type"] > 9) {
  294. $a = time();
  295. $id = isset($param["project_id"]) ? $param["project_id"] : $a;
  296. $detail = Db::name("appropriation")->where("id", $id)->find();
  297. $file_array = Db::name('ProjectFile')
  298. ->field('mf.id,mf.topic_id,mf.admin_id,f.name,f.filesize,f.filepath,f.fileext,f.create_time,f.admin_id,a.nickname as admin_name')
  299. ->alias('mf')
  300. ->join('File f', 'mf.file_id = f.id', 'LEFT')
  301. ->join('Admin a', 'mf.admin_id = a.id', 'LEFT')
  302. ->order('mf.create_time desc')
  303. ->where(array('mf.topic_id' => $id, 'mf.module' => 'appropriation'))
  304. ->select()->toArray();
  305. View::assign('id', $id);
  306. View::assign('detail', $detail);
  307. View::assign('file_array', $file_array);
  308. return view('c_read');
  309. } else {
  310. $id = isset($param['id']) ? $param['id'] : 0;
  311. $detail = $this->model->getCostProjectById($id);
  312. $comment = Db::name("project_comment")->where("project_id", $id)->order('create_time', 'desc')->select();
  313. $file_array = Db::name('ProjectFile')
  314. ->field('mf.id,mf.topic_id,mf.admin_id,f.name,f.filesize,f.filepath,f.fileext,f.create_time,f.admin_id,a.nickname as admin_name')
  315. ->alias('mf')
  316. ->join('File f', 'mf.file_id = f.id', 'LEFT')
  317. ->join('Admin a', 'mf.admin_id = a.id', 'LEFT')
  318. ->order('mf.create_time desc')
  319. ->where(array('mf.topic_id' => $id, 'mf.module' => 'project'))
  320. ->select()->toArray();
  321. $report = Db::name("project_report")->where([["project_id", "=", $id], ["r.status", "=", 1]])->alias("r")->join("admin a", "r.maker_id = a.id")->field("r.*,a.nickname")->select();
  322. // halt($comment);
  323. $project_log = self::project_log($id);
  324. View::assign('project_log', $project_log);
  325. // halt($project_log);
  326. // 根据用户id 查询其能显示的字段
  327. $field = $this->Field->get_field_rules_new(get_login_admin('id'));
  328. $c = $detail['project_end_time'] - time();
  329. if ($c > 0) {
  330. $advent_time = floor($c / 86400) . "天";
  331. } else {
  332. $c = -$c;
  333. $advent_time = floor($c / 86400) . "天";
  334. }
  335. if (!empty($detail)) {
  336. View::assign('advent_time', $advent_time);
  337. View::assign('detail', $detail);
  338. View::assign('project_id', $id);
  339. View::assign('comment', $comment);
  340. View::assign('file_array', $file_array);
  341. View::assign('report', $report);
  342. View::assign('field', $field);
  343. View::assign('project_five', self::getProjectFive_company());
  344. return view();
  345. } else {
  346. throw new \think\exception\HttpException(404, '找不到页面');
  347. }
  348. }
  349. }
  350. }
  351. public function getProjectFive_company()
  352. {
  353. $where = [
  354. ['name', '=', '作业日志-公司'],
  355. ['name', '=', '工作记录-公司'],
  356. ['name', '=', '项目报告-公司'],
  357. ['name', '=', '项目人员-公司'],
  358. ['name', '=', '项目动态-公司'],
  359. ['name', '=', '项目附件-公司'],
  360. ['name', '=', '联系函-公司'],
  361. ];
  362. $list = Db::name('AdminRule')->whereOr($where)->field('id,name')->select()->toArray();
  363. $group_id = Db::name('AdminGroupAccess')->where('uid', get_login_admin('id'))->value('group_id');
  364. $login_rules = Db::name('AdminGroup')->where('id', $group_id)->value('rules');
  365. $login_rules = explode(',', $login_rules);
  366. $rules_id = array();
  367. foreach ($list as $key => $value) {
  368. if ($value['name'] == "作业日志-公司") {
  369. if (in_array($value['id'], $login_rules)) {
  370. $rules_id['project_comments'] = 1;
  371. } else {
  372. $rules_id['project_comments'] = 0;
  373. }
  374. } else if ($value['name'] == "工作记录-公司") {
  375. if (in_array($value['id'], $login_rules)) {
  376. $rules_id['project_record'] = 1;
  377. } else {
  378. $rules_id['project_record'] = 0;
  379. }
  380. } else if ($value['name'] == "项目报告-公司") {
  381. if (in_array($value['id'], $login_rules)) {
  382. $rules_id['project_report'] = 1;
  383. } else {
  384. $rules_id['project_report'] = 0;
  385. }
  386. } else if ($value['name'] == "项目人员-公司") {
  387. if (in_array($value['id'], $login_rules)) {
  388. $rules_id['project_user'] = 1;
  389. } else {
  390. $rules_id['project_user'] = 0;
  391. }
  392. } else if ($value['name'] == "项目动态-公司") {
  393. if (in_array($value['id'], $login_rules)) {
  394. $rules_id['project_log'] = 1;
  395. } else {
  396. $rules_id['project_log'] = 0;
  397. }
  398. } else if ($value['name'] == "项目附件-公司") {
  399. if (in_array($value['id'], $login_rules)) {
  400. $rules_id['project_file'] = 1;
  401. } else {
  402. $rules_id['project_file'] = 0;
  403. }
  404. } else if ($value['name'] == "联系函-公司") {
  405. if (in_array($value['id'], $login_rules)) {
  406. $rules_id['project_contact'] = 1;
  407. } else {
  408. $rules_id['project_contact'] = 0;
  409. }
  410. }
  411. }
  412. return $rules_id;
  413. }
  414. public function getProjectFive()
  415. {
  416. $where = [
  417. ['name', '=', '作业日志-财政局'],
  418. ['name', '=', '工作记录-财政局'],
  419. ['name', '=', '项目报告-财政局'],
  420. ['name', '=', '项目人员-财政局'],
  421. ['name', '=', '项目动态-财政局'],
  422. ['name', '=', '项目附件-财政局'],
  423. ['name', '=', '联系函-财政局'],
  424. ];
  425. $list = Db::name('AdminRule')->whereOr($where)->field('id,name')->select()->toArray();
  426. $group_id = Db::name('AdminGroupAccess')->where('uid', get_login_admin('id'))->value('group_id');
  427. $login_rules = Db::name('AdminGroup')->where('id', $group_id)->value('rules');
  428. $login_rules = explode(',', $login_rules);
  429. $rules_id = array();
  430. foreach ($list as $key => $value) {
  431. if ($value['name'] == "作业日志-财政局") {
  432. if (in_array($value['id'], $login_rules)) {
  433. $rules_id['project_comments'] = 1;
  434. } else {
  435. $rules_id['project_comments'] = 0;
  436. }
  437. } else if ($value['name'] == "工作记录-财政局") {
  438. if (in_array($value['id'], $login_rules)) {
  439. $rules_id['project_record'] = 1;
  440. } else {
  441. $rules_id['project_record'] = 0;
  442. }
  443. } else if ($value['name'] == "项目报告-财政局") {
  444. if (in_array($value['id'], $login_rules)) {
  445. $rules_id['project_report'] = 1;
  446. } else {
  447. $rules_id['project_report'] = 0;
  448. }
  449. } else if ($value['name'] == "项目人员-财政局") {
  450. if (in_array($value['id'], $login_rules)) {
  451. $rules_id['project_user'] = 1;
  452. } else {
  453. $rules_id['project_user'] = 0;
  454. }
  455. } else if ($value['name'] == "项目动态-财政局") {
  456. if (in_array($value['id'], $login_rules)) {
  457. $rules_id['project_log'] = 1;
  458. } else {
  459. $rules_id['project_log'] = 0;
  460. }
  461. } else if ($value['name'] == "项目附件-财政局") {
  462. if (in_array($value['id'], $login_rules)) {
  463. $rules_id['project_file'] = 1;
  464. } else {
  465. $rules_id['project_file'] = 0;
  466. }
  467. } else if ($value['name'] == "联系函-财政局") {
  468. if (in_array($value['id'], $login_rules)) {
  469. $rules_id['project_contact'] = 1;
  470. } else {
  471. $rules_id['project_contact'] = 0;
  472. }
  473. }
  474. }
  475. return $rules_id;
  476. }
  477. /**
  478. * 立项审核一拒绝
  479. */
  480. public function project_overrule_first()
  481. {
  482. if (request()->isAjax()) {
  483. $param = get_params();
  484. $handle = $this->Pushmessage->handleParam($param);
  485. $param = $handle['param'];
  486. //修改状态为原状态
  487. if ($param["project_status"] == 2) {
  488. $param["project_status"] = 1;//修改为立项
  489. } elseif ($param["project_status"] == 7) {
  490. $param["project_status"] = 5;
  491. } elseif ($param["project_status"] == 6) {
  492. $param["project_status"] = 5;
  493. }
  494. try {
  495. $where=[
  496. ["project_id", "=", $param["project_id"]],
  497. ["audit_status", "=", 0],
  498. ["audit_type", "=", 5]
  499. ];
  500. $second_approver=$this->Auditmodel->where($where)->value("approver");
  501. //新增发送给审批二拒绝消息
  502. if(!empty($second_approver)){
  503. $this->Auditmodel->where("approver","$second_approver")->update(["audit_remark" => "审核一未通过,已作废"]);
  504. $MsgData = [
  505. "uid" =>$second_approver,//显示的文本,传来的id
  506. "project_id" => $param['id'],
  507. "content" => "项目审核一:".get_login_admin("nickname") . "已拒绝这个项目审批" ,
  508. "create_time" => time()
  509. ];
  510. $MsgGetId = $this->ProjectMsg->insertGetId($MsgData);
  511. $unread = Db::name("admin")->where("id", $second_approver)->value("unread");
  512. if (!empty($unread)) {
  513. $unread = $unread . "," . $MsgGetId;
  514. } else {
  515. $unread = $MsgGetId;
  516. }
  517. Db::name("admin")->where("id", $second_approver)->update(["unread" => $unread]);
  518. }
  519. $param['audit_time'] = time();
  520. //更新所有审批人已拒绝状态,改为id与$param["id“]就可以只改当前审批人的状态
  521. $this->Auditmodel->where('id', $param["id"])->strict(false)->field(true)->update(["audit_status" => 3, "audit_remark" => $param["audit_remark"], "audit_time" => time()]);
  522. $id = $param['id'];
  523. unset($param["id"]);
  524. $param["approver_time"] = time();
  525. $this->model->where('id', $param['project_id'])->strict(false)->update($param);//更新项目状态
  526. unset($param["approver_time"]);
  527. add_project_log('审批一拒绝', $param['project_id'], "项目分配审核拒绝,原因:" . $param["audit_remark"]);
  528. //发送拒绝消息
  529. $maker = $this->model->where('id', $param['project_id'])->value("entrust_maker");
  530. if (empty($handle['financial'])) {
  531. $handle['financial'] = (array)$maker;
  532. } else {
  533. $handle['financial'] = array_merge($handle['financial'], (array)$maker);
  534. }
  535. $this->Pushmessage->pushMessage($param['project_id'], $handle['financial'], $handle['company'],);
  536. } catch (\Exception $e) {
  537. return to_assign(1, '操作失败,原因:' . $e->getMessage());
  538. }
  539. return to_assign(0, "操作成功");
  540. }
  541. }
  542. /**
  543. * 立项审核二拒绝
  544. */
  545. public function project_overrule_first2()
  546. {
  547. if (request()->isAjax()) {
  548. $param = get_params();
  549. $handle = $this->Pushmessage->handleParam($param);
  550. $param = $handle['param'];
  551. //修改状态为原状态
  552. if ($param["project_status"] == 2) {
  553. $param["project_status"] = 1;//修改为立项
  554. } elseif ($param["project_status"] == 7) {
  555. $param["project_status"] = 5;
  556. } elseif ($param["project_status"] == 6) {
  557. $param["project_status"] = 5;
  558. }
  559. try {
  560. $param['audit_time'] = time();
  561. //,改为id与$param["id“]就可以只改当前审批人的审批状态
  562. $this->Auditmodel->where('id', $param["id"])->strict(false)->field(true)->update(["audit_status" => 3, "audit_remark" => $param["audit_remark"], "audit_time" => time()]);
  563. $id = $param['id'];
  564. unset($param["id"]);
  565. $param["approver_time"] = time();
  566. $this->model->where('id', $param['project_id'])->strict(false)->update($param);//更新项目状态
  567. unset($param["approver_time"]);
  568. add_project_log('审批二拒绝', $param['project_id'], "项目分配审核拒绝,原因:" . $param["audit_remark"]);
  569. //发送拒绝消息
  570. $maker = $this->model->where('id', $param['project_id'])->value("entrust_maker");
  571. if (empty($handle['financial'])) {
  572. $handle['financial'] = (array)$maker;
  573. } else {
  574. $handle['financial'] = array_merge($handle['financial'], (array)$maker);
  575. }
  576. $this->Pushmessage->pushMessage($param['project_id'], $handle['financial'], $handle['company'],);
  577. } catch (\Exception $e) {
  578. return to_assign(1, '操作失败,原因:' . $e->getMessage());
  579. }
  580. return to_assign(0, "操作成功");
  581. }
  582. }
  583. /**
  584. * 拒绝
  585. */
  586. public function project_overrule_second()
  587. {
  588. if (request()->isAjax()) {
  589. $param = get_params();
  590. $handle = $this->Pushmessage->handleParam($param);
  591. $param = $handle['param'];
  592. //修改状态为原状态
  593. if ($param["project_status"] == 2) {
  594. $param["project_status"] = 1;
  595. } elseif ($param["project_status"] == 7) {
  596. $param["project_status"] = 5;
  597. } elseif ($param["project_status"] == 6) {
  598. $param["project_status"] = 5;
  599. }
  600. try {
  601. $param['audit_time'] = time();
  602. $this->Auditmodel->where('id', $param["id"])->strict(false)->field(true)->update(["audit_status" => 3, "audit_remark" => $param["audit_remark"], "audit_time" => time()]);
  603. $id = $param['id'];
  604. unset($param["id"]);
  605. $param["approver_time"] = time();
  606. $this->model->where('id', $param['project_id'])->strict(false)->update($param);
  607. unset($param["approver_time"]);
  608. add_project_log('审批拒绝', $param['project_id'], "申请归档审核拒绝,原因:" . $param["audit_remark"]);
  609. $people = $this->Auditmodel->where('id', $id)->value("sponsor_id");
  610. if (empty($handle['financial'])) {
  611. $handle['company'] = (array)$people;
  612. } else {
  613. $handle['company'] = array_merge($handle['company'], (array)$people);
  614. }
  615. $this->Pushmessage->pushMessage($param['project_id'], $handle['financial'], $handle['company'], []);
  616. } catch (\Exception $e) {
  617. return to_assign(1, '操作失败,原因:' . $e->getMessage());
  618. }
  619. return to_assign(0, "操作成功");
  620. }
  621. }
  622. /**
  623. * 拒绝
  624. */
  625. public function project_overrule_third()
  626. {
  627. if (request()->isAjax()) {
  628. $param = get_params();
  629. $handle = $this->Pushmessage->handleParam($param);
  630. $param = $handle['param'];
  631. //修改状态为原状态
  632. if ($param["project_status"] == 2) {
  633. $param["project_status"] = 1;
  634. } elseif ($param["project_status"] == 7) {
  635. $param["project_status"] = 5;
  636. } elseif ($param["project_status"] == 6) {
  637. $param["project_status"] = 5;
  638. }
  639. try {
  640. $param['audit_time'] = time();
  641. $this->Auditmodel->where('id', $param["id"])->strict(false)->field(true)->update(["audit_status" => 3, "audit_remark" => $param["audit_remark"], "audit_time" => time()]);
  642. $id = $param['id'];
  643. unset($param["id"]);
  644. $param["approver_time"] = time();
  645. $this->model->where('id', $param['project_id'])->strict(false)->update($param);
  646. unset($param["approver_time"]);
  647. add_project_log('审批拒绝', $param['project_id'], "申请退审审核拒绝,原因:" . $param["audit_remark"]);
  648. $people = $this->Auditmodel->where('id', $id)->value("sponsor_id");
  649. if (empty($handle['financial'])) {
  650. $handle['company'] = (array)$people;
  651. } else {
  652. $handle['company'] = array_merge($handle['company'], (array)$people);
  653. }
  654. $this->Pushmessage->pushMessage($param['project_id'], $handle['financial'], $handle['company'], []);
  655. } catch (\Exception $e) {
  656. return to_assign(1, '操作失败,原因:' . $e->getMessage());
  657. }
  658. return to_assign(0, "操作成功");
  659. }
  660. }
  661. /**
  662. * 财政项目立项审批通过
  663. */
  664. public function project_edit_first()
  665. {
  666. $param = get_params();
  667. $handle = $this->Pushmessage->handleParam($param);
  668. $param = $handle['param'];
  669. if (request()->isAjax()) {
  670. try {
  671. $param['audit_time'] = time();
  672. //改为已通过audit_status=2
  673. $this->Auditmodel->where('id', $param['id'])->strict(false)->field(true)->update(["audit_status" => 2, "audit_time" => time()]);
  674. $id = $param['id'];
  675. unset($param["id"]);
  676. $param["approver_time"] = time();
  677. $this->model->where('id', $param['project_id'])->strict(false)->update($param);
  678. unset($param["approver_time"]);
  679. } catch (\Exception $e) {
  680. return to_assign(1, '操作失败,原因:' . $e->getMessage());
  681. }
  682. $where=[
  683. ["project_id", "=", $param["project_id"]],
  684. ["audit_status", "=", 5],//待启用
  685. ["audit_type", "=", 0],
  686. ["audit_name","=","项目分配审核二审"]
  687. ];
  688. $maker = $this->model->where('id', $param['project_id'])->value("entrust_maker");
  689. //找第二审批人id
  690. $second_approver=$this->Auditmodel->where($where)->value("approver");
  691. if (empty($handle['financial'])) {
  692. $handle['financial'] = (array)$maker+(array)$second_approver;
  693. } else {
  694. $handle['financial'] = array_merge($handle['financial'],(array)$maker+(array)$second_approver);
  695. }
  696. if ($second_approver!=null) {
  697. // 发送消息给第二审批人
  698. //$this->Pushmessage->pushMessage($param['project_id'], $handle['financial']);
  699. add_project_log('审批通过', $param['project_id'], "项目分配审核一通过,等待审核二");
  700. $this->Auditmodel->where($where)->update(["audit_status" => 1]);//将其第二审批人转化为待审批
  701. } else {
  702. // 如果没有第二审批人配置或者查找不到相关信息,则按照原逻辑发送消息
  703. $this->Pushmessage->pushMessage($param['project_id'], $handle['financial'], $handle['company'], []);
  704. add_project_log('审批一通过', $param['project_id'], "项目分配审核通过");
  705. if ($param["audit_type"] == 1) {
  706. //修改状态为下一个状态
  707. if ($param["project_status"] == 2) {
  708. //立项
  709. $param["project_status"] = 3;
  710. } elseif ($param["project_status"] == 6) {
  711. //归档
  712. $param["project_status"] = 8;
  713. $param["project_dead_time"] = time();
  714. } elseif ($param["project_status"] == 7) {
  715. //退审
  716. $param["project_status"] = 9;
  717. $param["project_dead_time"] = time();
  718. }
  719. //更新状态
  720. $this->model->where('id', $param['project_id'])->strict(false)->update($param);
  721. }
  722. }
  723. return to_assign(0,"操作成功");
  724. }
  725. }
  726. public function project_edit_first2()
  727. {
  728. $param = get_params();
  729. $handle = $this->Pushmessage->handleParam($param);
  730. $param = $handle['param'];
  731. if (request()->isAjax()) {
  732. if ($param["audit_type"] == 0) {
  733. //修改状态为下一个状态
  734. if ($param["project_status"] == 2) {
  735. //立项
  736. $param["project_status"] = 3;
  737. } elseif ($param["project_status"] == 6) {
  738. //归档
  739. $param["project_status"] = 8;
  740. $param["project_dead_time"] = time();
  741. } elseif ($param["project_status"] == 7) {
  742. //退审
  743. $param["project_status"] = 9;
  744. $param["project_dead_time"] = time();
  745. }
  746. }
  747. try {
  748. $param['audit_time'] = time();
  749. $this->Auditmodel->where('id', $param['id'])->strict(false)->field(true)->update(["audit_status" => 2, "audit_time" => time()]);
  750. $id = $param['id'];
  751. unset($param["id"]);
  752. $param["approver_time"] = time();
  753. $this->model->where('id', $param['project_id'])->strict(false)->update($param);
  754. unset($param["approver_time"]);
  755. } catch (\Exception $e) {
  756. return to_assign(1, '操作失败,原因:' . $e->getMessage());
  757. }
  758. $maker = $this->model->where('id', $param['project_id'])->value("entrust_maker");
  759. if (empty($handle['financial'])) {
  760. $handle['financial'] = (array)$maker;
  761. } else {
  762. $handle['financial'] = array_merge($handle['financial'], (array)$maker);
  763. }
  764. //项目id,需要通知的财政人员/需要通知的公司人员
  765. $this->Pushmessage->pushMessage($param['project_id'], $handle['financial'], $handle['company'], []);
  766. add_project_log('审批通过', $param['project_id'], "项目分配审核二通过");
  767. return to_assign(0, "操作成功");
  768. }
  769. }
  770. /**
  771. * 财政项目归档审批
  772. */
  773. public function project_edit_second()
  774. {
  775. $param = get_params();
  776. $handle = $this->Pushmessage->handleParam($param);
  777. $param = $handle['param'];
  778. if (request()->isAjax()) {
  779. if ($param["audit_type"] == 1) {
  780. //修改状态为下一个状态
  781. if ($param["project_status"] == 2) {
  782. //立项
  783. $param["project_status"] = 3;
  784. } elseif ($param["project_status"] == 6) {
  785. //归档
  786. $param["project_status"] = 8;
  787. $param["project_dead_time"] = time();
  788. } elseif ($param["project_status"] == 7) {
  789. //退审
  790. $param["project_status"] = 9;
  791. $param["project_dead_time"] = time();
  792. }
  793. }
  794. try {
  795. $param['audit_time'] = time();
  796. $this->Auditmodel->where('id', $param['id'])->strict(false)->field(true)->update(["audit_status" => 2, "audit_time" => time()]);
  797. add_log('edit', $param['id'], $param);
  798. $id = $param['id'];
  799. unset($param["id"]);
  800. $param["approver_time"] = time();
  801. $this->model->where('id', $param['project_id'])->strict(false)->update($param);
  802. unset($param["approver_time"]);
  803. } catch (\Exception $e) {
  804. return to_assign(1, '操作失败,原因:' . $e->getMessage());
  805. }
  806. $people = $this->Auditmodel->where('id', $id)->value("sponsor_id");
  807. if (empty($handle['financial'])) {
  808. $handle['company'] = (array)$people;
  809. } else {
  810. $handle['company'] = array_merge($handle['company'], (array)$people);
  811. }
  812. $this->Pushmessage->pushMessage($param['project_id'], $handle['financial'], $handle['company'], []);
  813. add_project_log('审批通过', $param['project_id'], "申请归档审核通过");
  814. return to_assign(0, "操作成功");
  815. }
  816. }
  817. /**
  818. * 财政项目退审审批
  819. */
  820. public function project_edit_third()
  821. {
  822. $param = get_params();
  823. $handle = $this->Pushmessage->handleParam($param);
  824. $param = $handle['param'];
  825. if (request()->isAjax()) {
  826. if ($param["audit_type"] == 1) {
  827. //修改状态为下一个状态
  828. if ($param["project_status"] == 2) {
  829. //立项
  830. $param["project_status"] = 3;
  831. } elseif ($param["project_status"] == 6) {
  832. //归档
  833. $param["project_status"] = 8;
  834. $param["project_dead_time"] = time();
  835. } elseif ($param["project_status"] == 7) {
  836. //退审
  837. $param["project_status"] = 9;
  838. $param["project_dead_time"] = time();
  839. }
  840. }
  841. try {
  842. $param['audit_time'] = time();
  843. $this->Auditmodel->where('id', $param['id'])->strict(false)->field(true)->update(["audit_status" => 2, "audit_time" => time()]);
  844. add_log('edit', $param['id'], $param);
  845. $id = $param["id"];
  846. unset($param["id"]);
  847. $param["approver_time"] = time();
  848. $this->model->where('id', $param['project_id'])->strict(false)->update($param);
  849. unset($param["approver_time"]);
  850. } catch (\Exception $e) {
  851. return to_assign(1, '操作失败,原因:' . $e->getMessage());
  852. }
  853. $people = $this->Auditmodel->where('id', $id)->value("sponsor_id");
  854. if (empty($handle['financial'])) {
  855. $handle['company'] = (array)$people;
  856. } else {
  857. $handle['company'] = array_merge($handle['company'], (array)$people);
  858. }
  859. $this->Pushmessage->pushMessage($param['project_id'], $handle['financial'], $handle['company'], []);
  860. add_project_log('审批通过', $param['project_id'], "申请退审审核通过");
  861. return to_assign(0, "操作成功");
  862. }
  863. }
  864. /**
  865. * 公司同意报告
  866. */
  867. public function report_agree_first()
  868. {
  869. $param = get_params();
  870. $handle = $this->Pushmessage->handleParam($param);
  871. $param = $handle['param'];
  872. if (request()->isAjax()) {
  873. try {
  874. $param['audit_time'] = time();
  875. $this->Auditmodel->where('id', $param['id'])->strict(false)->field(true)->update(["audit_status" => 2, "audit_time" => time()]);
  876. } catch (\Exception $e) {
  877. return to_assign(1, '操作失败,原因:' . $e->getMessage());
  878. }
  879. //找有没有二审
  880. $where = [
  881. ["project_id", "=", $param["project_id"]],
  882. ["else_id", "=", $param["else_id"]],
  883. ["audit_status", "=", 5],
  884. ["audit_type", "=", 5]
  885. ];
  886. $next = $this->Auditmodel->where($where)->count();
  887. if ($next == 0) {//没有二审,给财评新增报告审核
  888. $where = [
  889. ["project_id", "=", $param["project_id"]],
  890. ["else_id", "=", $param["else_id"]],//项目报告id
  891. ["audit_type", "=", 4]
  892. ];
  893. $detail = Db::name("cost_project")->where("id", $param["project_id"])->field("entrust_maker,entrust_maker_name")->find();
  894. $auditData = $this->Auditmodel->where($where)->find()->toArray();
  895. $auditData["audit_name"] = "财评报告审核";
  896. $auditData["audit_status"] = 1;
  897. $auditData["audit_type"] = 2;
  898. $auditData["approver"] = $detail["entrust_maker"];
  899. $auditData["approver_name"] = $detail["entrust_maker_name"];
  900. $auditData["create_time"] = time();
  901. $auditData["audit_time"] = null;
  902. $auditData["remark"] = null;
  903. $auditData["audit_remark"] = null;
  904. unset($auditData["id"]);
  905. try {
  906. Db::name("project_report")->where("id", $param["else_id"])->update(["status" => 0]);
  907. $this->Auditmodel->save($auditData);
  908. } catch (\Exception $e) {
  909. return to_assign(1, '操作失败,原因:' . $e->getMessage());
  910. }
  911. //内部审核通过了,通知公司的发起人,通知财政局的审批人
  912. $detail = Db::name("cost_project")->where("id", $param["project_id"])->field("entrust_maker,entrust_maker_name")->find();
  913. if (empty($handle['company'])) {
  914. $handle['company'] = (array)$auditData["sponsor_id"];
  915. } else {
  916. $handle['company'] = array_merge($handle['company'], (array)$auditData["sponsor_id"]);
  917. }
  918. $this->Pushmessage->pushMessage($param['project_id'], (array)$detail["entrust_maker"], $handle['company'], []);
  919. $else_name = Db::name("project_report")->where("id", $auditData["else_id"])->value("title");
  920. add_project_log("新增项目报告", $param["project_id"], $else_name, 4);
  921. Db::name("cost_project")->where("id", $param["project_id"])->update(["report_time" => time()]);
  922. } else {//公司内部有第二审批
  923. $where = [
  924. ["project_id", "=", $param["project_id"]],
  925. ["else_id", "=", $param["else_id"]],
  926. ["audit_status", "=", 5],
  927. ["audit_type", "=", 5]
  928. ];
  929. $approver = $this->Auditmodel->where($where)->value("approver");
  930. $this->Auditmodel->where($where)->update(["audit_status" => 1]);
  931. //通过了一审,但是还有二审,通知公司的发起人审批通过了
  932. $sponsor_id = $this->Auditmodel->where($where)->value("sponsor_id");
  933. if (empty($handle['company'])) {
  934. $handle['company'] = (array)$sponsor_id;
  935. } else {
  936. $handle['company'] = array_merge($handle['company'], (array)$sponsor_id);
  937. }
  938. // 通知发起人审批通过了
  939. // $this->Pushmessage->pushMessage($param['project_id'], $handle['financial'], $handle['company']);
  940. $this->Pushmessage->pushMessage($param['project_id'], NULL, $handle['company'], []);
  941. // 通知下一级审批人,有待审核
  942. $this->Pushmessage->pushMessage($param['project_id'], NULL, (array)$approver, []);
  943. }
  944. return to_assign(0, "操作成功");
  945. }
  946. }
  947. public function report_agree_second()
  948. {
  949. $param = get_params();
  950. $handle = $this->Pushmessage->handleParam($param);
  951. $param = $handle['param'];
  952. if (request()->isAjax()) {
  953. try {
  954. $param['audit_time'] = time();
  955. $this->Auditmodel->where('id', $param['id'])->strict(false)->field(true)->update(["audit_status" => 2, "audit_time" => time()]);
  956. } catch (\Exception $e) {
  957. return to_assign(1, '操作失败,原因:' . $e->getMessage());
  958. }
  959. $where = [
  960. ["project_id", "=", $param["project_id"]],
  961. ["else_id", "=", $param["else_id"]],
  962. ["audit_status", "=", 5],
  963. ["audit_type", "=", 6]
  964. ];
  965. $next = $this->Auditmodel->where($where)->count();
  966. if ($next == 0) {
  967. $where = [
  968. ["project_id", "=", $param["project_id"]],
  969. ["else_id", "=", $param["else_id"]],
  970. ["audit_type", "=", 4]
  971. ];
  972. $detail = Db::name("cost_project")->where("id", $param["project_id"])->field("entrust_maker,entrust_maker_name")->find();
  973. $auditData = $this->Auditmodel->where($where)->find()->toArray();
  974. $auditData["audit_name"] = "报告审核";
  975. $auditData["audit_status"] = 1;
  976. $auditData["audit_type"] = 2;
  977. $auditData["approver"] = $detail["entrust_maker"];
  978. $auditData["approver_name"] = $detail["entrust_maker_name"];
  979. $auditData["create_time"] = time();
  980. $auditData["audit_time"] = null;
  981. $auditData["remark"] = null;
  982. $auditData["audit_remark"] = null;
  983. unset($auditData["id"]);
  984. try {
  985. Db::name("project_report")->where("id",$param["else_id"])->update(["status"=>0]);
  986. $this->Auditmodel->save($auditData);
  987. } catch (\Exception $e) {
  988. return to_assign(1, '操作失败,原因:' . $e->getMessage());
  989. }
  990. //内部审核通过了,通知公司的发起人,通知财政局的审批人
  991. if (empty($handle['company'])) {
  992. $handle['company'] = (array)$auditData["sponsor_id"];
  993. } else {
  994. $handle['company'] = array_merge($handle['company'], (array)$auditData["sponsor_id"]);
  995. }
  996. $this->Pushmessage->pushMessage($param['project_id'], (array)$detail["entrust_maker"], $handle['company'], []);
  997. $else_name = Db::name("project_report")->where("id",$auditData["else_id"])->value("title");
  998. add_project_log("新增项目报告", $param["project_id"], $else_name, 4);add_project_log("新增项目报告", $param["project_id"], $auditData["else_name"], 4);
  999. Db::name("cost_project")->where("id", $param["project_id"])->update(["report_time" => time()]);
  1000. } else {
  1001. $where = [
  1002. ["project_id", "=", $param["project_id"]],
  1003. ["else_id", "=", $param["else_id"]],
  1004. ["audit_status", "=", 5],
  1005. ["audit_type", "=", 6],
  1006. ];
  1007. $approver = $this->Auditmodel->where($where)->value("approver");
  1008. $this->Auditmodel->where($where)->update(["audit_status" => 1]);
  1009. Db::name("project_report")->where("id", $param["else_id"])->update(["status" => 0]);
  1010. //通过了二审,但是还有三审,通知公司的发起人审批通过了
  1011. $sponsor_id = $this->Auditmodel->where($where)->value("sponsor_id");
  1012. if (empty($handle['company'])) {
  1013. $handle['company'] = (array)$sponsor_id;
  1014. } else {
  1015. $handle['company'] = array_merge($handle['company'], (array)$sponsor_id);
  1016. }
  1017. // 通知发起人审批通过了
  1018. // $this->Pushmessage->pushMessage($param['project_id'], $handle['financial'], $handle['company']);
  1019. $this->Pushmessage->pushMessage($param['project_id'], NULL, $handle['company'], []);
  1020. // 通知下一级审批人,有待审核
  1021. $this->Pushmessage->pushMessage($param['project_id'], NULL, (array)$approver, []);
  1022. }
  1023. return to_assign(0, "操作成功");
  1024. }
  1025. }
  1026. public function report_agree_third()
  1027. {
  1028. $param = get_params();
  1029. $handle = $this->Pushmessage->handleParam($param);
  1030. $param = $handle['param'];
  1031. if (request()->isAjax()) {
  1032. try {
  1033. $param['audit_time'] = time();
  1034. $this->Auditmodel->where('id', $param['id'])->strict(false)->field(true)->update(["audit_status" => 2, "audit_time" => time()]);
  1035. } catch (\Exception $e) {
  1036. return to_assign(1, '操作失败,原因:' . $e->getMessage());
  1037. }
  1038. $where = [
  1039. ["project_id", "=", $param["project_id"]],
  1040. ["else_id", "=", $param["else_id"]],
  1041. ["audit_status", "=", 5],
  1042. ["audit_type", "=", 14]
  1043. ];
  1044. $next = $this->Auditmodel->where($where)->count();
  1045. if ($next == 0) {
  1046. $where = [
  1047. ["project_id", "=", $param["project_id"]],
  1048. ["else_id", "=", $param["else_id"]],
  1049. ["audit_type", "=", 4]
  1050. ];
  1051. $detail = Db::name("cost_project")->where("id", $param["project_id"])->field("entrust_maker,entrust_maker_name")->find();
  1052. $auditData = $this->Auditmodel->where($where)->find()->toArray();
  1053. $auditData["audit_name"] = "报告审核";
  1054. $auditData["audit_status"] = 1;
  1055. $auditData["audit_type"] = 2;
  1056. $auditData["approver"] = $detail["entrust_maker"];
  1057. $auditData["approver_name"] = $detail["entrust_maker_name"];
  1058. $auditData["create_time"] = time();
  1059. $auditData["audit_time"] = null;
  1060. $auditData["remark"] = null;
  1061. $auditData["audit_remark"] = null;
  1062. unset($auditData["id"]);
  1063. try {
  1064. Db::name("project_report")->where("id",$param["else_id"])->update(["status"=>0]);
  1065. $this->Auditmodel->save($auditData);
  1066. } catch (\Exception $e) {
  1067. return to_assign(1, '操作失败,原因:' . $e->getMessage());
  1068. }
  1069. //内部审核通过了,通知公司的发起人,通知财政局的审批人
  1070. if (empty($handle['company'])) {
  1071. $handle['company'] = (array)$auditData["sponsor_id"];
  1072. } else {
  1073. $handle['company'] = array_merge($handle['company'], (array)$auditData["sponsor_id"]);
  1074. }
  1075. $this->Pushmessage->pushMessage($param['project_id'], (array)$detail["entrust_maker"], $handle['company'], []);
  1076. add_project_log("新增项目报告", $param["project_id"], $auditData["else_name"], 4);
  1077. Db::name("cost_project")->where("id", $param["project_id"])->update(["report_time" => time()]);
  1078. } else {
  1079. $where = [
  1080. ["project_id", "=", $param["project_id"]],
  1081. ["else_id", "=", $param["else_id"]],
  1082. ["audit_status", "=", 5],
  1083. ["audit_type", "=", 14]
  1084. ];
  1085. $approver = $this->Auditmodel->where($where)->value("approver");
  1086. $this->Auditmodel->where($where)->update(["audit_status" => 1]);
  1087. //通过了三审,但是还有四审,通知公司的发起人审批通过了
  1088. $sponsor_id = $this->Auditmodel->where($where)->value("sponsor_id");
  1089. if (empty($handle['company'])) {
  1090. $handle['company'] = (array)$sponsor_id;
  1091. } else {
  1092. $handle['company'] = array_merge($handle['company'], (array)$sponsor_id);
  1093. }
  1094. // 通知发起人审批通过了
  1095. // $this->Pushmessage->pushMessage($param['project_id'], $handle['financial'], $handle['company']);
  1096. $this->Pushmessage->pushMessage($param['project_id'], NULL, $handle['company'], []);
  1097. // 通知下一级审批人,有待审核
  1098. $this->Pushmessage->pushMessage($param['project_id'], NULL, (array)$approver, []);
  1099. }
  1100. return to_assign(0, "操作成功");
  1101. }
  1102. }
  1103. public function report_agree_fourth()
  1104. {
  1105. $param = get_params();
  1106. $handle = $this->Pushmessage->handleParam($param);
  1107. $param = $handle['param'];
  1108. if (request()->isAjax()) {
  1109. try {
  1110. $param['audit_time'] = time();
  1111. $this->Auditmodel->where('id', $param['id'])->strict(false)->field(true)->update(["audit_status" => 2, "audit_time" => time()]);
  1112. } catch (\Exception $e) {
  1113. return to_assign(1, '操作失败,原因:' . $e->getMessage());
  1114. }
  1115. $where = [
  1116. ["project_id", "=", $param["project_id"]],
  1117. ["else_id", "=", $param["else_id"]],
  1118. ["audit_status", "=", 5],
  1119. ["audit_type", "=", 15]
  1120. ];
  1121. $next = $this->Auditmodel->where($where)->count();
  1122. if ($next == 0) {
  1123. $where = [
  1124. ["project_id", "=", $param["project_id"]],
  1125. ["else_id", "=", $param["else_id"]],
  1126. ["audit_type", "=", 4]
  1127. ];
  1128. $detail = Db::name("cost_project")->where("id", $param["project_id"])->field("entrust_maker,entrust_maker_name")->find();
  1129. $auditData = $this->Auditmodel->where($where)->find()->toArray();
  1130. $auditData["audit_name"] = "报告审核";
  1131. $auditData["audit_status"] = 1;
  1132. $auditData["audit_type"] = 2;
  1133. $auditData["approver"] = $detail["entrust_maker"];
  1134. $auditData["approver_name"] = $detail["entrust_maker_name"];
  1135. $auditData["create_time"] = time();
  1136. $auditData["audit_time"] = null;
  1137. $auditData["remark"] = null;
  1138. $auditData["audit_remark"] = null;
  1139. unset($auditData["id"]);
  1140. try {
  1141. Db::name("project_report")->where("id",$param["else_id"])->update(["status"=>0]);
  1142. $this->Auditmodel->save($auditData);
  1143. } catch (\Exception $e) {
  1144. return to_assign(1, '操作失败,原因:' . $e->getMessage());
  1145. }
  1146. Db::name("project_report")->where("id", $param["else_id"])->update(["status" => 0]);
  1147. //内部审核通过了,通知公司的发起人,通知财政局的审批人
  1148. if (empty($handle['company'])) {
  1149. $handle['company'] = (array)$auditData["sponsor_id"];
  1150. } else {
  1151. $handle['company'] = array_merge($handle['company'], (array)$auditData["sponsor_id"]);
  1152. }
  1153. $this->Pushmessage->pushMessage($param['project_id'], (array)$detail["entrust_maker"], $handle['company'], []);
  1154. $else_name = Db::name("project_report")->where("id",$auditData["else_id"])->value("title");
  1155. add_project_log("新增项目报告", $param["project_id"], $else_name, 4);
  1156. Db::name("cost_project")->where("id", $param["project_id"])->update(["report_time" => time()]);
  1157. } else {
  1158. $where = [
  1159. ["project_id", "=", $param["project_id"]],
  1160. ["else_id", "=", $param["else_id"]],
  1161. ["audit_status", "=", 5],
  1162. ["audit_type", "=", 15]
  1163. ];
  1164. $approver = $this->Auditmodel->where($where)->value("approver");
  1165. $this->Auditmodel->where($where)->update(["audit_status" => 1]);
  1166. //通过了四审,但是还有五审,通知公司的发起人审批通过了
  1167. $sponsor_id = $this->Auditmodel->where($where)->value("sponsor_id");
  1168. if (empty($handle['company'])) {
  1169. $handle['company'] = (array)$sponsor_id;
  1170. } else {
  1171. $handle['company'] = array_merge($handle['company'], (array)$sponsor_id);
  1172. }
  1173. // 通知发起人审批通过了
  1174. // $this->Pushmessage->pushMessage($param['project_id'], $handle['financial'], $handle['company']);
  1175. $this->Pushmessage->pushMessage($param['project_id'], NULL, $handle['company'], []);
  1176. // 通知下一级审批人,有待审核
  1177. $this->Pushmessage->pushMessage($param['project_id'], NULL, (array)$approver, []);
  1178. }
  1179. return to_assign(0, "操作成功");
  1180. }
  1181. }
  1182. public function report_agree_fifth()
  1183. {
  1184. $param = get_params();
  1185. $handle = $this->Pushmessage->handleParam($param);
  1186. $param = $handle['param'];
  1187. if (request()->isAjax()) {
  1188. try {
  1189. $param['audit_time'] = time();
  1190. $this->Auditmodel->where('id', $param['id'])->strict(false)->field(true)->update(["audit_status" => 2, "audit_time" => time()]);
  1191. } catch (\Exception $e) {
  1192. return to_assign(1, '操作失败,原因:' . $e->getMessage());
  1193. }
  1194. $where = [
  1195. ["project_id", "=", $param["project_id"]],
  1196. ["else_id", "=", $param["else_id"]],
  1197. ["audit_type", "=", 4]
  1198. ];
  1199. $detail = Db::name("cost_project")->where("id", $param["project_id"])->field("entrust_maker,entrust_maker_name")->find();
  1200. $auditData = $this->Auditmodel->where($where)->find()->toArray();
  1201. $auditData["audit_name"] = "报告审核";
  1202. $auditData["audit_status"] = 1;
  1203. $auditData["audit_type"] = 2;
  1204. $auditData["approver"] = $detail["entrust_maker"];
  1205. $auditData["approver_name"] = $detail["entrust_maker_name"];
  1206. $auditData["create_time"] = time();
  1207. $auditData["audit_time"] = null;
  1208. $auditData["remark"] = null;
  1209. $auditData["audit_remark"] = null;
  1210. unset($auditData["id"]);
  1211. try {
  1212. Db::name("project_report")->where("id",$param["else_id"])->update(["status"=>0]);
  1213. $this->Auditmodel->save($auditData);
  1214. } catch (\Exception $e) {
  1215. return to_assign(1, '操作失败,原因:' . $e->getMessage());
  1216. }
  1217. Db::name("project_report")->where("id", $param["else_id"])->update(["status" => 0]);
  1218. //内部审核通过了,通知公司的发起人,通知财政局的审批人
  1219. if (empty($handle['company'])) {
  1220. $handle['company'] = (array)$auditData["sponsor_id"];
  1221. } else {
  1222. $handle['company'] = array_merge($handle['company'], (array)$auditData["sponsor_id"]);
  1223. }
  1224. $this->Pushmessage->pushMessage($param['project_id'], (array)$detail['entrust_maker'], $handle['company'], []);
  1225. $else_name = Db::name("project_report")->where("id",$auditData["else_id"])->value("title");
  1226. add_project_log("新增项目报告", $param["project_id"], $else_name, 4);
  1227. try {
  1228. Db::name("cost_project")->where("id", $param["project_id"])->update(["report_time" => time()]);
  1229. } catch (\Exception $e) {
  1230. return to_assign(1, '操作失败,原因:' . $e->getMessage());
  1231. }
  1232. return to_assign(0, "操作成功");
  1233. }
  1234. }
  1235. /**
  1236. * 公司同意联系函
  1237. */
  1238. public function contact_agree_first()
  1239. {
  1240. $param = get_params();
  1241. $handle = $this->Pushmessage->handleParam($param);
  1242. $param = $handle['param'];
  1243. if (request()->isAjax()) {
  1244. try {
  1245. $param['audit_time'] = time();
  1246. $this->Auditmodel->where('id', $param['id'])->strict(false)->field(true)->update(["audit_status" => 2, "audit_time" => time()]);
  1247. } catch (\Exception $e) {
  1248. return to_assign(1, '操作失败,原因:' . $e->getMessage());
  1249. }
  1250. $where = [
  1251. ["project_id", "=", $param["project_id"]],
  1252. ["else_id", "=", $param["else_id"]],
  1253. ["audit_status", "=", 5],
  1254. ["audit_type", "=", 8]
  1255. ];
  1256. $next = $this->Auditmodel->where($where)->count();
  1257. if ($next == 0) {
  1258. $where = [
  1259. ["project_id", "=", $param["project_id"]],
  1260. ["else_id", "=", $param["else_id"]],
  1261. ["audit_type", "=", 7]
  1262. ];
  1263. $detail = Db::name("cost_project")->where("id", $param["project_id"])->field("entrust_maker,entrust_maker_name")->find();
  1264. $auditData = $this->Auditmodel->where($where)->find()->toArray();
  1265. $auditData["audit_name"] = "联系函审核";
  1266. $auditData["audit_status"] = 1;
  1267. $auditData["audit_type"] = 3;
  1268. $auditData["approver"] = $detail["entrust_maker"];
  1269. $auditData["approver_name"] = $detail["entrust_maker_name"];
  1270. $auditData["create_time"] = time();
  1271. $auditData["audit_time"] = null;
  1272. $auditData["remark"] = null;
  1273. $auditData["audit_remark"] = null;
  1274. unset($auditData["id"]);
  1275. try {
  1276. $this->Auditmodel->save($auditData);
  1277. } catch (\Exception $e) {
  1278. return to_assign(1, '操作失败,原因:' . $e->getMessage());
  1279. }
  1280. //内部审核通过了,通知公司的发起人,通知财政局的审批人
  1281. if (empty($handle['company'])) {
  1282. $handle['company'] = (array)$auditData["sponsor_id"];
  1283. } else {
  1284. $handle['company'] = array_merge($handle['company'], (array)$auditData["sponsor_id"]);
  1285. }
  1286. $this->Pushmessage->pushMessage($param['project_id'], (array)$detail["entrust_maker"], $handle['company'], []);
  1287. add_project_log("新增项目联系函", $param["project_id"], $auditData["else_name"], 4);
  1288. Db::name("cost_project")->where("id", $param["project_id"])->update(["report_time" => time()]);
  1289. } else {
  1290. $where = [
  1291. ["project_id", "=", $param["project_id"]],
  1292. ["else_id", "=", $param["else_id"]],
  1293. ['audit_status', '=', 5],
  1294. ["audit_type", "=", 8]
  1295. ];
  1296. $approver = $this->Auditmodel->where($where)->value("approver");
  1297. $this->Auditmodel->where($where)->update(["audit_status" => 1]);
  1298. //通过了一审,但是还有二审,通知公司的发起人审批通过了
  1299. $sponsor_id = $this->Auditmodel->where($where)->value("sponsor_id");
  1300. if (empty($handle['company'])) {
  1301. $handle['company'] = (array)$sponsor_id;
  1302. } else {
  1303. $handle['company'] = array_merge($handle['company'], (array)$sponsor_id);
  1304. }
  1305. // 通知发起人审批通过了
  1306. $this->Pushmessage->pushMessage($param['project_id'], [], $handle['company'], []);
  1307. // 通知下一级审批人,有待审核
  1308. $this->Pushmessage->pushMessage($param['project_id'], [], (array)$approver, []);
  1309. }
  1310. return to_assign(0, "操作成功");
  1311. }
  1312. }
  1313. /**
  1314. * 公司同意联系函
  1315. */
  1316. public function contact_agree_second()
  1317. {
  1318. $param = get_params();
  1319. $handle = $this->Pushmessage->handleParam($param);
  1320. $param = $handle['param'];
  1321. if (request()->isAjax()) {
  1322. try {
  1323. $param['audit_time'] = time();
  1324. $this->Auditmodel->where('id', $param['id'])->strict(false)->field(true)->update(["audit_status" => 2, "audit_time" => time()]);
  1325. } catch (\Exception $e) {
  1326. return to_assign(1, '操作失败,原因:' . $e->getMessage());
  1327. }
  1328. $where = [
  1329. ["project_id", "=", $param["project_id"]],
  1330. ["else_id", "=", $param["else_id"]],
  1331. ["audit_status", "=", 5],
  1332. ["audit_type", "=", 9]
  1333. ];
  1334. $next = $this->Auditmodel->where($where)->count();
  1335. if ($next == 0) {
  1336. $where = [
  1337. ["project_id", "=", $param["project_id"]],
  1338. ["else_id", "=", $param["else_id"]],
  1339. ["audit_type", "=", 7]
  1340. ];
  1341. $detail = Db::name("cost_project")->where("id", $param["project_id"])->field("entrust_maker,entrust_maker_name")->find();
  1342. $auditData = $this->Auditmodel->where($where)->find()->toArray();
  1343. $auditData["audit_name"] = "联系函审核";
  1344. $auditData["audit_status"] = 1;
  1345. $auditData["audit_type"] = 3;
  1346. $auditData["approver"] = $detail["entrust_maker"];
  1347. $auditData["approver_name"] = $detail["entrust_maker_name"];
  1348. $auditData["create_time"] = time();
  1349. $auditData["audit_time"] = null;
  1350. $auditData["remark"] = null;
  1351. $auditData["audit_remark"] = null;
  1352. unset($auditData["id"]);
  1353. try {
  1354. $this->Auditmodel->save($auditData);
  1355. } catch (\Exception $e) {
  1356. return to_assign(1, '操作失败,原因:' . $e->getMessage());
  1357. }
  1358. //内部审核通过了,通知公司的发起人,通知财政局的审批人
  1359. if (empty($handle['company'])) {
  1360. $handle['company'] = (array)$auditData["sponsor_id"];
  1361. } else {
  1362. $handle['company'] = array_merge($handle['company'], (array)$auditData["sponsor_id"]);
  1363. }
  1364. $this->Pushmessage->pushMessage($param['project_id'], (array)$detail["entrust_maker"], $handle['company'], []);
  1365. add_project_log("新增项目联系函", $param["project_id"], $auditData["else_name"], 4);
  1366. Db::name("cost_project")->where("id", $param["project_id"])->update(["report_time" => time()]);
  1367. } else {
  1368. $where = [
  1369. ["project_id", "=", $param["project_id"]],
  1370. ["else_id", "=", $param["else_id"]],
  1371. ['audit_status', '=', '5'],
  1372. ["audit_type", "=", 9],
  1373. ];
  1374. $approver = $this->Auditmodel->where($where)->value('approver');
  1375. $this->Auditmodel->where($where)->update(["audit_status" => 1]);
  1376. //通过了二审,但是还有三审,通知公司的发起人审批通过了
  1377. $sponsor_id = $this->Auditmodel->where($where)->value("sponsor_id");
  1378. if (empty($handle['company'])) {
  1379. $handle['company'] = (array)$sponsor_id;
  1380. } else {
  1381. $handle['company'] = array_merge($handle['company'], (array)$sponsor_id);
  1382. }
  1383. $this->Pushmessage->pushMessage($param['project_id'], [], $handle['company'], []);
  1384. $this->Pushmessage->pushMessage($param['project_id'], [], (array)$approver, []);
  1385. }
  1386. return to_assign(0, "操作成功");
  1387. }
  1388. }
  1389. /**
  1390. * 公司同意联系函
  1391. */
  1392. public function contact_agree_third()
  1393. {
  1394. $param = get_params();
  1395. $handle = $this->Pushmessage->handleParam($param);
  1396. $param = $handle['param'];
  1397. if (request()->isAjax()) {
  1398. try {
  1399. $param['audit_time'] = time();
  1400. $this->Auditmodel->where('id', $param['id'])->strict(false)->field(true)->update(["audit_status" => 2, "audit_time" => time()]);
  1401. } catch (\Exception $e) {
  1402. return to_assign(1, '操作失败,原因:' . $e->getMessage());
  1403. }
  1404. $where = [
  1405. ["project_id", "=", $param["project_id"]],
  1406. ["else_id", "=", $param["else_id"]],
  1407. ["audit_type", "=", 7]
  1408. ];
  1409. $detail = Db::name("cost_project")->where("id", $param["project_id"])->field("entrust_maker,entrust_maker_name")->find();
  1410. $auditData = $this->Auditmodel->where($where)->find()->toArray();
  1411. $auditData["audit_name"] = "联系函审核";
  1412. $auditData["audit_status"] = 1;
  1413. $auditData["audit_type"] = 3;
  1414. $auditData["approver"] = $detail["entrust_maker"];
  1415. $auditData["approver_name"] = $detail["entrust_maker_name"];
  1416. $auditData["create_time"] = time();
  1417. $auditData["audit_time"] = null;
  1418. $auditData["remark"] = null;
  1419. $auditData["audit_remark"] = null;
  1420. unset($auditData["id"]);
  1421. try {
  1422. $this->Auditmodel->save($auditData);
  1423. } catch (\Exception $e) {
  1424. return to_assign(1, '操作失败,原因:' . $e->getMessage());
  1425. }
  1426. //内部审核通过了,通知公司的发起人,通知财政局的审批人
  1427. if (empty($handle['company'])) {
  1428. $handle['company'] = (array)$auditData["sponsor_id"];
  1429. } else {
  1430. $handle['company'] = array_merge($handle['company'], (array)$auditData["sponsor_id"]);
  1431. }
  1432. $this->Pushmessage->pushMessage($param['project_id'], (array)$detail['entrust_maker'], $handle['company'], []);
  1433. add_project_log("新增项目联系函", $param["project_id"], $auditData["else_name"], 4);
  1434. Db::name("cost_project")->where("id", $param["project_id"])->update(["report_time" => time()]);
  1435. return to_assign(0, "操作成功");
  1436. }
  1437. }
  1438. /**
  1439. * 公司同意请款
  1440. */
  1441. public function appropriation_agree_first()
  1442. {
  1443. $param = get_params();
  1444. $handle = $this->Pushmessage->handleParam($param);
  1445. $param = $handle['param'];
  1446. if (request()->isAjax()) {
  1447. try {
  1448. $param['audit_time'] = time();
  1449. $this->Auditmodel->where('id', $param['id'])
  1450. ->strict(false)->field(true)
  1451. ->update(["audit_status" => 2, "audit_time" => time()]);
  1452. } catch (\Exception $e) {
  1453. return to_assign(1, '操作失败,原因:' . $e->getMessage());
  1454. }
  1455. $where = [
  1456. ["project_id", "=", $param["project_id"]],
  1457. ["else_id", "=", 0],
  1458. ["audit_status", "=", 5],
  1459. ["audit_type", "in", 11]
  1460. ];
  1461. $next = $this->Auditmodel->where($where)->count();
  1462. if ($next == 0) {
  1463. try {
  1464. Db::name("appropriation")->where("id", $param["project_id"])->update(["status" => 1]);
  1465. } catch (\Exception $e) {
  1466. return to_assign(1, '操作失败,原因:' . $e->getMessage());
  1467. }
  1468. //$param["project_id"]为关联id,非项目id
  1469. $project = Db::name("appropriation_project")->where("uid", $param["project_id"])->select();
  1470. $financial = [];
  1471. $company = [];
  1472. $project_ids = [];
  1473. foreach ($project as $item => $value) {
  1474. $id = Db::name("cost_project")->where("id", $value['project_id'])->value("entrust_maker");
  1475. if (empty($handle['financial'])) {
  1476. $financial = (array)$id;
  1477. } else {
  1478. $financial = array_merge($handle['financial'], (array)$id);
  1479. }
  1480. $sponsor_id = $this->Auditmodel->where('id', $param['id'])->value("sponsor_id");
  1481. if (empty($handle['company'])) {
  1482. $company = (array)$sponsor_id;
  1483. } else {
  1484. $company = array_merge($handle['company'], (array)$sponsor_id);
  1485. }
  1486. $project_ids = array_merge($project_ids, (array)$value['project_id']);
  1487. }
  1488. $this->Pushmessage->pushMessage($project_ids, $financial, $company, []);
  1489. } else {
  1490. $where = [
  1491. ["project_id", "=", $param["project_id"]],
  1492. ["else_id", "=", 0],
  1493. ['audit_status', '=', 5],
  1494. ["audit_type", "in", 11],
  1495. ];
  1496. $approver = $this->Auditmodel->where($where)->value('approver');
  1497. $this->Auditmodel->where($where)->update(["audit_status" => 1]);
  1498. $sponsor_id = $this->Auditmodel->where('id', $param['id'])->value("sponsor_id");
  1499. if (empty($handle['company'])) {
  1500. $handle['company'] = (array)$sponsor_id;
  1501. } else {
  1502. $handle['company'] = array_merge($handle['company'], (array)$sponsor_id);
  1503. }
  1504. //$param["project_id"]为关联id,非项目id
  1505. $project = Db::name("appropriation_project")->where("uid", $param["project_id"])->select();
  1506. $project_ids = [];
  1507. foreach ($project as $item => $value) {
  1508. $project_ids = array_merge($project_ids, (array)$value['project_id']);
  1509. }
  1510. // 通知发起人审批通过了
  1511. $this->Pushmessage->pushMessage($project_ids, [], $handle['company'], []);
  1512. //通知下一级审批人,有待审核
  1513. $this->Pushmessage->pushMessage($project_ids, [], (array)$approver, []);
  1514. }
  1515. return to_assign(0, "操作成功");
  1516. }
  1517. }
  1518. /**
  1519. * 公司同意请款
  1520. */
  1521. public function appropriation_agree_second()
  1522. {
  1523. $param = get_params();
  1524. $handle = $this->Pushmessage->handleParam($param);
  1525. $param = $handle['param'];
  1526. if (request()->isAjax()) {
  1527. try {
  1528. $param['audit_time'] = time();
  1529. $this->Auditmodel->where('id', $param['id'])->strict(false)->field(true)->update(["audit_status" => 2, "audit_time" => time()]);
  1530. } catch (\Exception $e) {
  1531. return to_assign(1, '操作失败,原因:' . $e->getMessage());
  1532. }
  1533. $where = [
  1534. ["project_id", "=", $param["project_id"]],
  1535. ["else_id", "=", 0],
  1536. ["audit_status", "=", 5],
  1537. ["audit_type", "in", 12]
  1538. ];
  1539. $next = $this->Auditmodel->where($where)->count();
  1540. if ($next == 0) {
  1541. try {
  1542. Db::name("appropriation")->where("id", $param["project_id"])->update(["status" => 1]);
  1543. } catch (\Exception $e) {
  1544. return to_assign(1, '操作失败,原因:' . $e->getMessage());
  1545. }
  1546. //$param["project_id"]为关联id,非项目id
  1547. $project = Db::name("appropriation_project")->where("uid", $param["project_id"])->select();
  1548. $project_ids = [];
  1549. $financial = [];
  1550. $company = [];
  1551. foreach ($project as $item => $value) {
  1552. $id = Db::name("cost_project")->where("id", $value['project_id'])->value("entrust_maker");
  1553. if (empty($handle['financial'])) {
  1554. $financial = (array)$id;
  1555. } else {
  1556. $financial = array_merge($handle['financial'], (array)$id);
  1557. }
  1558. $sponsor_id = $this->Auditmodel->where('id', $param['id'])->value("sponsor_id");
  1559. if (empty($handle['company'])) {
  1560. $company = (array)$sponsor_id;
  1561. } else {
  1562. $company = array_merge($handle['company'], (array)$sponsor_id);
  1563. }
  1564. $project_ids = array_merge($project_ids, (array)$value['project_id']);
  1565. }
  1566. $this->Pushmessage->pushMessage($project_ids, $financial, $company, []);
  1567. } else {
  1568. $where = [
  1569. ["project_id", "=", $param["project_id"]],
  1570. ["else_id", "=", 0],
  1571. ['audit_status', '=', 5],
  1572. ["audit_type", "in", 12],
  1573. ];
  1574. $approver = $this->Auditmodel->where('id', $param['id'])->value("approver");
  1575. $this->Auditmodel->where($where)->update(["audit_status" => 1]);
  1576. //$param["project_id"]为关联id,非项目id
  1577. $project = Db::name("appropriation_project")->where("uid", $param["project_id"])->select();
  1578. $sponsor_id = $this->Auditmodel->where('id', $param['id'])->value("sponsor_id");
  1579. if (empty($handle['company'])) {
  1580. $handle['company'] = (array)$sponsor_id;
  1581. } else {
  1582. $handle['company'] = array_merge($handle['company'], (array)$sponsor_id);
  1583. }
  1584. $project_ids = [];
  1585. foreach ($project as $item => $value) {
  1586. $project_ids = array_merge($project_ids, (array)$value['project_id']);
  1587. }
  1588. // 通知发起人审批通过了
  1589. $this->Pushmessage->pushMessage($project_ids, [], $handle['company'], []);
  1590. //通知下一级审批人,有待审核
  1591. $this->Pushmessage->pushMessage($project_ids, [], (array)$approver, []);
  1592. }
  1593. return to_assign(0, "操作成功");
  1594. }
  1595. }
  1596. /**
  1597. * 公司同意请款
  1598. */
  1599. public function appropriation_agree_third()
  1600. {
  1601. $param = get_params();
  1602. $handle = $this->Pushmessage->handleParam($param);
  1603. $param = $handle['param'];
  1604. if (request()->isAjax()) {
  1605. try {
  1606. $param['audit_time'] = time();
  1607. $this->Auditmodel->where('id', $param['id'])->strict(false)->field(true)->update(["audit_status" => 2, "audit_time" => time()]);
  1608. } catch (\Exception $e) {
  1609. return to_assign(1, '操作失败,原因:' . $e->getMessage());
  1610. }
  1611. try {
  1612. Db::name("appropriation")->where("id", $param["project_id"])->update(["status" => 1]);
  1613. } catch (\Exception $e) {
  1614. return to_assign(1, '操作失败,原因:' . $e->getMessage());
  1615. }
  1616. //$param["project_id"]为关联id,非项目id
  1617. $project = Db::name("appropriation_project")->where("uid", $param["project_id"])->select();
  1618. $project_ids = [];
  1619. $financial = [];
  1620. $company = [];
  1621. foreach ($project as $item => $value) {
  1622. $id = Db::name("cost_project")->where("id", $value['project_id'])->value("entrust_maker");
  1623. if (empty($handle['financial'])) {
  1624. $financial = (array)$id;
  1625. } else {
  1626. $financial = array_merge($handle['financial'], (array)$id);
  1627. }
  1628. $sponsor_id = $this->Auditmodel->where('id', $param['id'])->value("sponsor_id");
  1629. if (empty($handle['company'])) {
  1630. $company = (array)$sponsor_id;
  1631. } else {
  1632. $company = array_merge($handle['company'], (array)$sponsor_id);
  1633. }
  1634. $project_ids = array_merge($project_ids, (array)$value['project_id']);
  1635. }
  1636. $this->Pushmessage->pushMessage($project_ids, $financial, $company, []);
  1637. return to_assign(0, "操作成功");
  1638. }
  1639. }
  1640. /**
  1641. * 公司拒绝报告
  1642. */
  1643. public function report_disagree_first()
  1644. {
  1645. $param = get_params();
  1646. $handle = $this->Pushmessage->handleParam($param);
  1647. $param = $handle['param'];
  1648. if (request()->isAjax()) {
  1649. try {
  1650. $param['audit_time'] = time();
  1651. $this->Auditmodel->where('id', $param['id'])->strict(false)->field(true)->update(["audit_status" => 3, "audit_remark" => $param["audit_remark"], "audit_time" => time()]);
  1652. Db::name("project_report")->where("id", $param["else_id"])->update(["status" => 7]);
  1653. } catch (\Exception $e) {
  1654. return to_assign(1, '操作失败,原因:' . $e->getMessage());
  1655. }
  1656. $where = [
  1657. ["project_id", "=", $param["project_id"]],
  1658. ["else_id", "=", $param["else_id"]],
  1659. ["audit_status", "=", 5],
  1660. ["audit_type", "=", 5]
  1661. ];
  1662. $next = $this->Auditmodel->where($where)->column("id");
  1663. if (!empty($next)) {
  1664. $this->Auditmodel->whereIn("id", $next)->update(["audit_remark" => "审核未全部通过,已作废"]);
  1665. }
  1666. $id = $param['id'];
  1667. $detail = Db::name("cost_project")->where("id", $param["project_id"])->field("entrust_maker,entrust_maker_name")->find();
  1668. $sponsor_id = $this->Auditmodel->where('id', $param['id'])->value("sponsor_id");
  1669. if (empty($handle['company'])) {
  1670. $handle['company'] = (array)$sponsor_id;
  1671. } else {
  1672. $handle['company'] = array_merge($handle['company'], (array)$sponsor_id);
  1673. }
  1674. // $this->Pushmessage->pushMessage($param['project_id'], (array)$detail['entrust_maker'], $handle['company']);
  1675. $this->Pushmessage->pushMessage($param['project_id'], [], $handle['company'], []);
  1676. $content = get_login_admin("nickname") . "拒绝了" . $this->Auditmodel->where('id', $id)->value("audit_name") . "《" . $param["else_name"] . "》,原因:".$param["audit_remark"];
  1677. add_project_log('审批拒绝', $param['project_id'], $content);
  1678. return to_assign(0, "操作成功");
  1679. }
  1680. }
  1681. public function report_disagree_second()
  1682. {
  1683. $param = get_params();
  1684. $handle = $this->Pushmessage->handleParam($param);
  1685. $param = $handle['param'];
  1686. if (request()->isAjax()) {
  1687. try {
  1688. $param['audit_time'] = time();
  1689. $this->Auditmodel->where('id', $param['id'])->strict(false)->field(true)->update(["audit_status" => 3, "audit_remark" => $param["audit_remark"], "audit_time" => time()]);
  1690. Db::name("project_report")->where("id", $param["else_id"])->update(["status" => 7]);
  1691. } catch (\Exception $e) {
  1692. return to_assign(1, '操作失败,原因:' . $e->getMessage());
  1693. }
  1694. $where = [
  1695. ["project_id", "=", $param["project_id"]],
  1696. ["else_id", "=", $param["else_id"]],
  1697. ["audit_status", "=", 5],
  1698. ["audit_type", "=", 6]
  1699. ];
  1700. $next = $this->Auditmodel->where($where)->column("id");
  1701. if (!empty($next)) {
  1702. $this->Auditmodel->whereIn("id", $next)->update(["audit_remark" => "审核未全部通过,已作废"]);
  1703. }
  1704. $id = $param['id'];
  1705. $MsgData = ["content" => get_login_admin("nickname") . "拒绝了您发起的" . $this->Auditmodel->where('id', $id)->value("audit_name") . "《" . $param["else_name"] . "》",];
  1706. $detail = Db::name("cost_project")->where("id", $param["project_id"])->field("entrust_maker,entrust_maker_name")->find();
  1707. $sponsor_id = $this->Auditmodel->where('id', $param['id'])->value("sponsor_id");
  1708. if (empty($handle['company'])) {
  1709. $handle['company'] = (array)$sponsor_id;
  1710. } else {
  1711. $handle['company'] = array_merge($handle['company'], (array)$sponsor_id);
  1712. }
  1713. // $this->Pushmessage->pushMessage($param['project_id'], (array)$detail['entrust_maker'], $handle['company']);
  1714. $content = get_login_admin("nickname") . "拒绝了" . $this->Auditmodel->where('id', $id)->value("audit_name") . "《" . $param["else_name"] . "》,原因:".$param["audit_remark"];
  1715. add_project_log('审批拒绝', $param['project_id'], $content);
  1716. return to_assign(0, "操作成功");
  1717. }
  1718. }
  1719. public function report_disagree_third()
  1720. {
  1721. $param = get_params();
  1722. $handle = $this->Pushmessage->handleParam($param);
  1723. $param = $handle['param'];
  1724. if (request()->isAjax()) {
  1725. try {
  1726. $param['audit_time'] = time();
  1727. $this->Auditmodel->where('id', $param['id'])->strict(false)->field(true)->update(["audit_status" => 3, "audit_remark" => $param["audit_remark"], "audit_time" => time()]);
  1728. Db::name("project_report")->where("id", $param["else_id"])->update(["status" => 7]);
  1729. } catch (\Exception $e) {
  1730. return to_assign(1, '操作失败,原因:' . $e->getMessage());
  1731. }
  1732. $where = [
  1733. ["project_id", "=", $param["project_id"]],
  1734. ["else_id", "=", $param["else_id"]],
  1735. ["audit_status", "=", 5],
  1736. ["audit_type", "=", 14]
  1737. ];
  1738. $next = $this->Auditmodel->where($where)->column("id");
  1739. if (!empty($next)) {
  1740. $this->Auditmodel->whereIn("id", $next)->update(["audit_remark" => "审核未全部通过,已作废"]);
  1741. }
  1742. $id = $param['id'];
  1743. $detail = Db::name("cost_project")->where("id", $param["project_id"])->field("entrust_maker,entrust_maker_name")->find();
  1744. $sponsor_id = $this->Auditmodel->where('id', $param['id'])->value("sponsor_id");
  1745. if (empty($handle['company'])) {
  1746. $handle['company'] = (array)$sponsor_id;
  1747. } else {
  1748. $handle['company'] = array_merge($handle['company'], (array)$sponsor_id);
  1749. }
  1750. // $this->Pushmessage->pushMessage($param['project_id'], (array)$detail['entrust_maker'], $handle['company']);
  1751. $content = get_login_admin("nickname") . "拒绝了" . $this->Auditmodel->where('id', $id)->value("audit_name") . "《" . $param["else_name"] . "》,原因:".$param["audit_remark"];
  1752. add_project_log('审批拒绝', $param['project_id'], $content);
  1753. return to_assign(0, "操作成功");
  1754. }
  1755. }
  1756. public function report_disagree_fourth()
  1757. {
  1758. $param = get_params();
  1759. $handle = $this->Pushmessage->handleParam($param);
  1760. $param = $handle['param'];
  1761. if (request()->isAjax()) {
  1762. try {
  1763. $param['audit_time'] = time();
  1764. $this->Auditmodel->where('id', $param['id'])->strict(false)->field(true)->update(["audit_status" => 3, "audit_remark" => $param["audit_remark"], "audit_time" => time()]);
  1765. Db::name("project_report")->where("id", $param["else_id"])->update(["status" => 7]);
  1766. } catch (\Exception $e) {
  1767. return to_assign(1, '操作失败,原因:' . $e->getMessage());
  1768. }
  1769. $where = [
  1770. ["project_id", "=", $param["project_id"]],
  1771. ["else_id", "=", $param["else_id"]],
  1772. ["audit_status", "=", 5],
  1773. ["audit_type", "=", 15]
  1774. ];
  1775. $next = $this->Auditmodel->where($where)->column("id");
  1776. if (!empty($next)) {
  1777. $this->Auditmodel->whereIn("id", $next)->update(["audit_remark" => "审核未全部通过,已作废"]);
  1778. }
  1779. $id = $param['id'];
  1780. $MsgData = ["content" => get_login_admin("nickname") . "拒绝了您发起的" . $this->Auditmodel->where('id', $id)->value("audit_name") . "《" . $param["else_name"] . "》",];
  1781. $detail = Db::name("cost_project")->where("id", $param["project_id"])->field("entrust_maker,entrust_maker_name")->find();
  1782. $sponsor_id = $this->Auditmodel->where('id', $param['id'])->value("sponsor_id");
  1783. if (empty($handle['company'])) {
  1784. $handle['company'] = (array)$sponsor_id;
  1785. } else {
  1786. $handle['company'] = array_merge($handle['company'], (array)$sponsor_id);
  1787. }
  1788. // $this->Pushmessage->pushMessage($param['project_id'], (array)$detail['entrust_maker'], $handle['company']);
  1789. $this->Pushmessage->pushMessage($param['project_id'], [], $handle['company'], []);
  1790. $content = get_login_admin("nickname") . "拒绝了" . $this->Auditmodel->where('id', $id)->value("audit_name") . "《" . $param["else_name"] . "》,原因:".$param["audit_remark"];
  1791. add_project_log('审批拒绝', $param['project_id'], $content);
  1792. return to_assign(0, "操作成功");
  1793. }
  1794. }
  1795. public function report_disagree_fifth()
  1796. {
  1797. $param = get_params();
  1798. $handle = $this->Pushmessage->handleParam($param);
  1799. $param = $handle['param'];
  1800. if (request()->isAjax()) {
  1801. try {
  1802. $param['audit_time'] = time();
  1803. $this->Auditmodel->where('id', $param['id'])->strict(false)->field(true)->update(["audit_status" => 3, "audit_remark" => $param["audit_remark"], "audit_time" => time()]);
  1804. Db::name("project_report")->where("id", $param["else_id"])->update(["status" => 7]);
  1805. } catch (\Exception $e) {
  1806. return to_assign(1, '操作失败,原因:' . $e->getMessage());
  1807. }
  1808. $else_name = Db::name('project_audit')->where('else_id',$param['else_id'])->value('else_name');
  1809. $id = $param['id'];
  1810. $MsgData = ["content" => get_login_admin("nickname") . "拒绝了您发起的" . $this->Auditmodel->where('id', $id)->value("audit_name") . "《" . $else_name . "》"];
  1811. $detail = Db::name("cost_project")->where("id", $param["project_id"])->field("entrust_maker,entrust_maker_name")->find();
  1812. $sponsor_id = $this->Auditmodel->where('id', $param['id'])->value("sponsor_id");
  1813. if (empty($handle['company'])) {
  1814. $handle['company'] = (array)$sponsor_id;
  1815. } else {
  1816. $handle['company'] = array_merge($handle['company'], (array)$sponsor_id);
  1817. }
  1818. // $this->Pushmessage->pushMessage($param['project_id'], (array)$detail['entrust_maker'], $handle['company']);
  1819. $this->Pushmessage->pushMessage($param['project_id'], [], $handle['company'], []);
  1820. $content = get_login_admin("nickname") . "拒绝了" . $this->Auditmodel->where('id', $id)->value("audit_name") . "《" . $else_name . "》,原因:".$param["audit_remark"];
  1821. add_project_log('审批拒绝', $param['project_id'], $content);
  1822. return to_assign(0, "操作成功");
  1823. }
  1824. }
  1825. /**
  1826. * 公司拒绝联系函
  1827. */
  1828. public function contact_disagree_first()
  1829. {
  1830. $param = get_params();
  1831. $handle = $this->Pushmessage->handleParam($param);
  1832. $param = $handle['param'];
  1833. if (request()->isAjax()) {
  1834. try {
  1835. $param['audit_time'] = time();
  1836. $this->Auditmodel->where('id', $param['id'])->strict(false)->field(true)->update(["audit_status" => 3, "audit_remark" => $param["audit_remark"], "audit_time" => time()]);
  1837. Db::name("project_report")->where("id", $param["else_id"])->update(["status" => 7]);
  1838. } catch (\Exception $e) {
  1839. return to_assign(1, '操作失败,原因:' . $e->getMessage());
  1840. }
  1841. $where = [
  1842. ["project_id", "=", $param["project_id"]],
  1843. ["else_id", "=", $param["else_id"]],
  1844. ["audit_status", "=", 5],
  1845. ["audit_type", "=", 8]
  1846. ];
  1847. $next = $this->Auditmodel->where($where)->column("id");
  1848. if (!empty($next)) {
  1849. $this->Auditmodel->whereIn("id", $next)->update(["audit_remark" => "审核未全部通过,已作废"]);
  1850. }
  1851. $id = $param['id'];
  1852. $MsgData = ["content" => get_login_admin("nickname") . "拒绝了您发起的" . $this->Auditmodel->where('id', $id)->value("audit_name") . "《" . $param["else_name"] . "》",];
  1853. $detail = Db::name("cost_project")->where("id", $param["project_id"])->field("entrust_maker,entrust_maker_name")->find();
  1854. $sponsor_id = $this->Auditmodel->where('id', $param['id'])->value("sponsor_id");
  1855. if (empty($handle['company'])) {
  1856. $handle['company'] = (array)$sponsor_id;
  1857. } else {
  1858. $handle['company'] = array_merge($handle['company'], (array)$sponsor_id);
  1859. }
  1860. // $this->Pushmessage->pushMessage($param['project_id'], (array)$detail['entrust_maker'], $handle['company']);
  1861. $this->Pushmessage->pushMessage($param['project_id'], [], $handle['company'], []);
  1862. $content = get_login_admin("nickname") . "拒绝了" . $this->Auditmodel->where('id', $id)->value("audit_name") . "《" . $param["else_name"] . "》,原因:".$param["audit_remark"];
  1863. add_project_log('审批拒绝', $param['project_id'], $content);
  1864. return to_assign(0, "操作成功");
  1865. }
  1866. }
  1867. /**
  1868. * 公司拒绝联系函
  1869. */
  1870. public function contact_disagree_second()
  1871. {
  1872. $param = get_params();
  1873. $handle = $this->Pushmessage->handleParam($param);
  1874. $param = $handle['param'];
  1875. if (request()->isAjax()) {
  1876. try {
  1877. $param['audit_time'] = time();
  1878. $this->Auditmodel->where('id', $param['id'])->strict(false)->field(true)->update(["audit_status" => 3, "audit_remark" => $param["audit_remark"], "audit_time" => time()]);
  1879. Db::name("project_report")->where("id", $param["else_id"])->update(["status" => 7]);
  1880. } catch (\Exception $e) {
  1881. return to_assign(1, '操作失败,原因:' . $e->getMessage());
  1882. }
  1883. $where = [
  1884. ["project_id", "=", $param["project_id"]],
  1885. ["else_id", "=", $param["else_id"]],
  1886. ["audit_status", "=", 5],
  1887. ["audit_type", "=", 9]
  1888. ];
  1889. $next = $this->Auditmodel->where($where)->column("id");
  1890. if (!empty($next)) {
  1891. $this->Auditmodel->whereIn("id", $next)->update(["audit_remark" => "审核未全部通过,已作废"]);
  1892. }
  1893. $id = $param['id'];
  1894. $MsgData = ["content" => get_login_admin("nickname") . "拒绝了您发起的" . $this->Auditmodel->where('id', $id)->value("audit_name") . "《" . $param["else_name"] . "》",];
  1895. $detail = Db::name("cost_project")->where("id", $param["project_id"])->field("entrust_maker,entrust_maker_name")->find();
  1896. $sponsor_id = $this->Auditmodel->where('id', $param['id'])->value("sponsor_id");
  1897. if (empty($handle['company'])) {
  1898. $handle['company'] = (array)$sponsor_id;
  1899. } else {
  1900. $handle['company'] = array_merge($handle['company'], (array)$sponsor_id);
  1901. }
  1902. // $this->Pushmessage->pushMessage($param['project_id'], (array)$detail['entrust_maker'], $handle['company']);
  1903. $this->Pushmessage->pushMessage($param['project_id'], [], $handle['company'], []);
  1904. $content = get_login_admin("nickname") . "拒绝了" . $this->Auditmodel->where('id', $id)->value("audit_name") . "《" . $param["else_name"] . "》,原因:".$param["audit_remark"];
  1905. add_project_log('审批拒绝', $param['project_id'], $content);
  1906. return to_assign(0, "操作成功");
  1907. }
  1908. }
  1909. /**
  1910. * 公司拒绝联系函
  1911. */
  1912. public function contact_disagree_third()
  1913. {
  1914. $param = get_params();
  1915. $handle = $this->Pushmessage->handleParam($param);
  1916. $param = $handle['param'];
  1917. if (request()->isAjax()) {
  1918. try {
  1919. $param['audit_time'] = time();
  1920. $this->Auditmodel->where('id', $param['id'])->strict(false)->field(true)->update(["audit_status" => 3, "audit_remark" => $param["audit_remark"], "audit_time" => time()]);
  1921. Db::name("project_report")->where("id", $param["else_id"])->update(["status" => 7]);
  1922. } catch (\Exception $e) {
  1923. return to_assign(1, '操作失败,原因:' . $e->getMessage());
  1924. }
  1925. $id = $param['id'];
  1926. $MsgData = ["content" => get_login_admin("nickname") . "拒绝了您发起的" . $this->Auditmodel->where('id', $id)->value("audit_name") . "《" . $param["else_name"] . "》",];
  1927. $detail = Db::name("cost_project")->where("id", $param["project_id"])->field("entrust_maker,entrust_maker_name")->find();
  1928. $sponsor_id = $this->Auditmodel->where('id', $param['id'])->value("sponsor_id");
  1929. if (empty($handle['company'])) {
  1930. $handle['company'] = (array)$sponsor_id;
  1931. } else {
  1932. $handle['company'] = array_merge($handle['company'], (array)$sponsor_id);
  1933. }
  1934. // $this->Pushmessage->pushMessage($param['project_id'], (array)$detail['entrust_maker'], $handle['company']);
  1935. $this->Pushmessage->pushMessage($param['project_id'], [], $handle['company'], []);
  1936. $content = get_login_admin("nickname") . "拒绝了" . $this->Auditmodel->where('id', $id)->value("audit_name") . "《" . $param["else_name"] . "》,原因:".$param["audit_remark"];
  1937. add_project_log('审批拒绝', $param['project_id'], $content);
  1938. return to_assign(0, "操作成功");
  1939. }
  1940. }
  1941. /**
  1942. * 公司拒绝请款
  1943. */
  1944. public function appropriation_disagree_first()
  1945. {
  1946. $param = get_params();;
  1947. $handle = $this->Pushmessage->handleParam($param);
  1948. $param = $handle['param'];
  1949. if (request()->isAjax()) {
  1950. try {
  1951. $param['audit_time'] = time();
  1952. $this->Auditmodel->where('id', $param['id'])->strict(false)->field(true)->update(["audit_status" => 3, "audit_remark" => $param["audit_remark"], "audit_time" => time()]);
  1953. Db::name("project_report")->where("id", $param["else_id"])->update(["status" => 7]);
  1954. } catch (\Exception $e) {
  1955. return to_assign(1, '操作失败,原因:' . $e->getMessage());
  1956. }
  1957. try {
  1958. Db::name("appropriation")->where("id", $param["project_id"])->update(["status" => -2]);
  1959. } catch (\Exception $e) {
  1960. return to_assign(1, '操作失败,原因:' . $e->getMessage());
  1961. }
  1962. $where = [
  1963. ["project_id", "=", $param["project_id"]],
  1964. ["else_id", "=", 0],
  1965. ["audit_status", "=", 5],
  1966. ["audit_type", ">", 10],
  1967. ["audit_type", "<", 13]
  1968. ];
  1969. $next = $this->Auditmodel->where($where)->column("id");
  1970. if (!empty($next)) {
  1971. $this->Auditmodel->whereIn("id", $next)->update(["audit_status"=>4,"audit_remark" => "审核未全部通过,已作废"]);
  1972. }
  1973. //$param["project_id"]为关联id,非项目id
  1974. $project = Db::name("appropriation_project")->where("uid", $param["project_id"])->select();
  1975. $sponsor_id = $this->Auditmodel->where('id', $param['id'])->value("sponsor_id");
  1976. $project_ids = [];
  1977. foreach ($project as $item => $value) {
  1978. $company = [];
  1979. if (empty($handle['company'])) {
  1980. $company = (array)$sponsor_id;
  1981. } else {
  1982. $company = array_merge($handle['company'], (array)$sponsor_id);
  1983. }
  1984. $project_ids = array_merge($project_ids, (array)$value['project_id']);
  1985. }
  1986. // $this->Pushmessage->pushMessage($project_ids, $handle['financial'],$company);
  1987. $this->Pushmessage->pushMessage($param['project_id'], [], $company, []);
  1988. return to_assign(0, "操作成功");
  1989. }
  1990. }
  1991. /**
  1992. * 公司拒绝请款
  1993. */
  1994. public function appropriation_disagree_second()
  1995. {
  1996. $param = get_params();
  1997. $handle = $this->Pushmessage->handleParam($param);
  1998. $param = $handle['param'];
  1999. if (request()->isAjax()) {
  2000. try {
  2001. $param['audit_time'] = time();
  2002. $this->Auditmodel->where('id', $param['id'])->strict(false)->field(true)->update(["audit_status" => 3, "audit_remark" => $param["audit_remark"], "audit_time" => time()]);
  2003. Db::name("project_report")->where("id", $param["else_id"])->update(["status" => 7]);
  2004. } catch (\Exception $e) {
  2005. return to_assign(1, '操作失败,原因:' . $e->getMessage());
  2006. }
  2007. try {
  2008. Db::name("appropriation")->where("id", $param["project_id"])->update(["status" => -2]);
  2009. } catch (\Exception $e) {
  2010. return to_assign(1, '操作失败,原因:' . $e->getMessage());
  2011. }
  2012. $where = [
  2013. ["project_id", "=", $param["project_id"]],
  2014. ["else_id", "=", 0],
  2015. ["audit_status", "=", 5],
  2016. ["audit_type", ">", 11],
  2017. ["audit_type", "<", 13]
  2018. ];
  2019. $next = $this->Auditmodel->where($where)->column("id");
  2020. if (!empty($next)) {
  2021. $this->Auditmodel->whereIn("id", $next)->update(["audit_status"=>4,"audit_remark" => "审核未全部通过,已作废"]);
  2022. }
  2023. //$param["project_id"]为关联id,非项目id
  2024. $project = Db::name("appropriation_project")->where("uid", $param["project_id"])->select();
  2025. $sponsor_id = $this->Auditmodel->where('id', $param['id'])->value("sponsor_id");
  2026. $project_ids = [];
  2027. $company = [];
  2028. foreach ($project as $item => $value) {
  2029. if (empty($handle['company'])) {
  2030. $company = (array)$sponsor_id;
  2031. } else {
  2032. $company = array_merge($handle['company'], (array)$sponsor_id);
  2033. }
  2034. $project_ids = array_merge($project_ids, (array)$value['project_id']);
  2035. }
  2036. // $this->Pushmessage->pushMessage($project_ids, $handle['financial'],$company);
  2037. $this->Pushmessage->pushMessage($param['project_id'], [], $company, []);
  2038. return to_assign(0, "操作成功");
  2039. }
  2040. }
  2041. /**
  2042. * 公司拒绝请款
  2043. */
  2044. public function appropriation_disagree_third()
  2045. {
  2046. $param = get_params();
  2047. $handle = $this->Pushmessage->handleParam($param);
  2048. $param = $handle['param'];
  2049. if (request()->isAjax()) {
  2050. try {
  2051. $param['audit_time'] = time();
  2052. $this->Auditmodel->where('id', $param['id'])->strict(false)->field(true)->update(["audit_status" => 3, "audit_remark" => $param["audit_remark"], "audit_time" => time()]);
  2053. Db::name("project_report")->where("id", $param["else_id"])->update(["status" => 7]);
  2054. } catch (\Exception $e) {
  2055. return to_assign(1, '操作失败,原因:' . $e->getMessage());
  2056. }
  2057. try {
  2058. Db::name("appropriation")->where("id", $param["project_id"])->update(["status" => -2]);
  2059. } catch (\Exception $e) {
  2060. return to_assign(1, '操作失败,原因:' . $e->getMessage());
  2061. }
  2062. //$param["project_id"]为关联id,非项目id
  2063. $project = Db::name("appropriation_project")->where("uid", $param["project_id"])->select();
  2064. $sponsor_id = $this->Auditmodel->where('id', $param['id'])->value("sponsor_id");
  2065. $project_ids = [];
  2066. foreach ($project as $item => $value) {
  2067. $company = [];
  2068. if (empty($handle['company'])) {
  2069. $company = (array)$sponsor_id;
  2070. } else {
  2071. $company = array_merge($handle['company'], (array)$sponsor_id);
  2072. }
  2073. $project_ids = array_merge($project_ids, (array)$value['project_id']);
  2074. }
  2075. // $this->Pushmessage->pushMessage($project_ids, $handle['financial'],$company);
  2076. $this->Pushmessage->pushMessage($param['project_id'], [], $company, []);
  2077. return to_assign(0, "操作成功");
  2078. }
  2079. }
  2080. /**
  2081. * 业主项目审核一同意
  2082. */
  2083. public function proprietor_agree()
  2084. {
  2085. if (request()->isAjax()) {
  2086. $param = get_params();
  2087. $id = isset($param['id']) ? $param["id"] : 0;
  2088. $project_id = isset($param["project_id"]) ? $param["project_id"] : 0;
  2089. $this->Auditmodel->update(["id" => $id, "audit_status" => 2, "audit_time" => time()]);
  2090. $where=[
  2091. ["project_id", "=", $param["project_id"]],
  2092. ["audit_status", "=", 5],//待启用
  2093. ["audit_type", "=", 0],
  2094. ["audit_name", "=","业主项目审核二审"]
  2095. ];
  2096. //找第二审批人id
  2097. $second_approver=$this->Auditmodel->where($where)->value("approver");
  2098. if( $second_approver!=null){
  2099. add_project_log('审批通过', $param['project_id'], "业主项目审核一通过,等待审核二");
  2100. $this->Auditmodel->where($where)->update(["audit_status" => 1]);//将其第二审批人转化为待审批
  2101. }
  2102. else{
  2103. add_project_log('审批一通过', $param['project_id'], "项目分配审核通过");
  2104. $this->model->update(["id" => $project_id, "proprietor_status" => 2]);//改为待接收
  2105. }
  2106. $this->model->update(["id" => $project_id, "proprietor_status" => 2]);
  2107. $sponsor_id = $this->Auditmodel->where('id', $id)->value('sponsor_id');
  2108. // $fiscal_nature = Db::name('CostProject')->where('project_id', $project_id)->value('fiscal_nature');
  2109. // if($fiscal_nature == '财政资金'){
  2110. // $this->Pushmessage->pushMessage($project_id, [], [], (array)$sponsor_id);
  2111. // }else if($fiscal_nature == '非财政资金'){
  2112. $this->Pushmessage->pushMessage($project_id, [], [], (array)$sponsor_id);
  2113. // }
  2114. return to_assign("0", "操作成功");
  2115. }
  2116. }
  2117. //业主项目审核二同意
  2118. public function proprietor_agree2()
  2119. {
  2120. if (request()->isAjax()) {
  2121. $param = get_params();
  2122. $id = isset($param['id']) ? $param["id"] : 0;
  2123. $project_id = isset($param["project_id"]) ? $param["project_id"] : 0;
  2124. $this->Auditmodel->update(["id" => $id, "audit_status" => 2, "audit_time" => time()]);//改为已通过
  2125. $this->model->update(["id" => $project_id, "proprietor_status" => 2]);//改为待接收
  2126. $sponsor_id = $this->Auditmodel->where('id', $id)->value('sponsor_id');
  2127. $this->Pushmessage->pushMessage($project_id, [], [], (array)$sponsor_id);
  2128. add_project_log('审批通过', $param['project_id'], "业主项目审核二通过,项目审核通过");
  2129. return to_assign("0", "操作成功");
  2130. }
  2131. }
  2132. /**
  2133. * 业主项目审核一拒绝
  2134. */
  2135. public function proprietor_disagree()
  2136. {
  2137. if (request()->isAjax()) {
  2138. $param = get_params();
  2139. $id = isset($param['id']) ? $param["id"] : 0;
  2140. $project_id = isset($param["project_id"]) ? $param["project_id"] : 0;
  2141. $this->Auditmodel->update(["id" => $id, "audit_status" => 3, "audit_remark" => $param["audit_remark"], "audit_time" => time()]);
  2142. $where=[
  2143. ["project_id", "=", $param["project_id"]],
  2144. ["audit_status", "=", 5],//待启用
  2145. ["audit_type", "=", 0],
  2146. ["audit_name", "=","业主项目审核二审"]
  2147. ];
  2148. //找第二审批人id
  2149. $second_approver=$this->Auditmodel->where($where)->value("approver");
  2150. if($second_approver!=null){
  2151. add_project_log('业主端审批一拒绝', $param['project_id'], "项目审核拒绝,原因:" . $param["audit_remark"]);
  2152. }
  2153. else{
  2154. $this->model->update(["id" => $project_id, "proprietor_status" => 0]);//改为业主立项中
  2155. }
  2156. $sponsor_id = $this->Auditmodel->where('id', $id)->value('sponsor_id');
  2157. $this->Pushmessage->pushMessage($project_id, [], [], (array)$sponsor_id);
  2158. return to_assign("0", "操作成功");
  2159. }
  2160. }
  2161. //业主项目审核二拒绝
  2162. public function proprietor_disagre2()
  2163. {
  2164. if (request()->isAjax()) {
  2165. $param = get_params();
  2166. $id = isset($param['id']) ? $param["id"] : 0;
  2167. $project_id = isset($param["project_id"]) ? $param["project_id"] : 0;
  2168. $this->Auditmodel->update(["id" => $id, "audit_status" => 3, "audit_remark" => $param["audit_remark"], "audit_time" => time()]);
  2169. $this->model->update(["id" => $project_id, "proprietor_status" => 0]);
  2170. add_project_log('业主端审批二拒绝', $param['project_id'], "项目审核拒绝,原因:" . $param["audit_remark"]);
  2171. $sponsor_id = $this->Auditmodel->where('id', $id)->value('sponsor_id');
  2172. $this->Pushmessage->pushMessage($project_id, [], [], (array)$sponsor_id);
  2173. return to_assign("0", "操作成功");
  2174. }
  2175. }
  2176. /*
  2177. * **************************************************************************
  2178. * **************************************************************************
  2179. * *
  2180. * _oo8oo_ *
  2181. * o8888888o *
  2182. * 88" . "88 *
  2183. * (| -_- |) *
  2184. * 0\ = /0 *
  2185. * ___/'==='\___ *
  2186. * .' \\| |// '. *
  2187. * / \\||| : |||// \ *
  2188. * / _||||| -:- |||||_ \ *
  2189. * | | \\\ - /// | | *
  2190. * | \_| ''\---/'' |_/ | *
  2191. * \ .-\__ '-' __/-. / *
  2192. * ___'. .' /--.--\ '. .'___ *
  2193. * ."" '< '.___\_<|>_/___.' >' "". *
  2194. * | | : `- \`.:`\ _ /`:.`/ -` : | | *
  2195. * \ \ `-. \_ __\ /__ _/ .-` / / *
  2196. * =====`-.____`.___ \_____/ ___.`____.-`===== *
  2197. * `=---=` *
  2198. * **************************************************************************
  2199. * ******************** ********************
  2200. * ******************** ********************
  2201. * ******************** 佛祖保佑 永远无BUG ********************
  2202. * ******************** ********************
  2203. * **************************************************************************
  2204. */
  2205. }