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. $aduit_status=Db::name(Auditmodel)->where("audit_name" ,"项目分配审核一审")->value(aduit_status);
  57. if ( $aduit_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. $where = [
  880. ["project_id", "=", $param["project_id"]],
  881. ["else_id", "=", $param["else_id"]],
  882. ["audit_status", "=", 5],
  883. ["audit_type", "=", 5]
  884. ];
  885. $next = $this->Auditmodel->where($where)->count();
  886. if ($next == 0) {
  887. $where = [
  888. ["project_id", "=", $param["project_id"]],
  889. ["else_id", "=", $param["else_id"]],
  890. ["audit_type", "=", 4]
  891. ];
  892. $detail = Db::name("cost_project")->where("id", $param["project_id"])->field("entrust_maker,entrust_maker_name")->find();
  893. $auditData = $this->Auditmodel->where($where)->find()->toArray();
  894. $auditData["audit_name"] = "报告审核";
  895. $auditData["audit_status"] = 1;
  896. $auditData["audit_type"] = 2;
  897. $auditData["approver"] = $detail["entrust_maker"];
  898. $auditData["approver_name"] = $detail["entrust_maker_name"];
  899. $auditData["create_time"] = time();
  900. $auditData["audit_time"] = null;
  901. $auditData["remark"] = null;
  902. $auditData["audit_remark"] = null;
  903. unset($auditData["id"]);
  904. try {
  905. Db::name("project_report")->where("id", $param["else_id"])->update(["status" => 0]);
  906. $this->Auditmodel->save($auditData);
  907. } catch (\Exception $e) {
  908. return to_assign(1, '操作失败,原因:' . $e->getMessage());
  909. }
  910. //内部审核通过了,通知公司的发起人,通知财政局的审批人
  911. $detail = Db::name("cost_project")->where("id", $param["project_id"])->field("entrust_maker,entrust_maker_name")->find();
  912. if (empty($handle['company'])) {
  913. $handle['company'] = (array)$auditData["sponsor_id"];
  914. } else {
  915. $handle['company'] = array_merge($handle['company'], (array)$auditData["sponsor_id"]);
  916. }
  917. $this->Pushmessage->pushMessage($param['project_id'], (array)$detail["entrust_maker"], $handle['company'], []);
  918. $else_name = Db::name("project_report")->where("id", $auditData["else_id"])->value("title");
  919. add_project_log("新增项目报告", $param["project_id"], $else_name, 4);
  920. Db::name("cost_project")->where("id", $param["project_id"])->update(["report_time" => time()]);
  921. } else {
  922. $where = [
  923. ["project_id", "=", $param["project_id"]],
  924. ["else_id", "=", $param["else_id"]],
  925. ["audit_status", "=", 5],
  926. ["audit_type", "=", 5]
  927. ];
  928. $approver = $this->Auditmodel->where($where)->value("approver");
  929. $this->Auditmodel->where($where)->update(["audit_status" => 1]);
  930. //通过了一审,但是还有二审,通知公司的发起人审批通过了
  931. $sponsor_id = $this->Auditmodel->where($where)->value("sponsor_id");
  932. if (empty($handle['company'])) {
  933. $handle['company'] = (array)$sponsor_id;
  934. } else {
  935. $handle['company'] = array_merge($handle['company'], (array)$sponsor_id);
  936. }
  937. // 通知发起人审批通过了
  938. // $this->Pushmessage->pushMessage($param['project_id'], $handle['financial'], $handle['company']);
  939. $this->Pushmessage->pushMessage($param['project_id'], NULL, $handle['company'], []);
  940. // 通知下一级审批人,有待审核
  941. $this->Pushmessage->pushMessage($param['project_id'], NULL, (array)$approver, []);
  942. }
  943. return to_assign(0, "操作成功");
  944. }
  945. }
  946. public function report_agree_second()
  947. {
  948. $param = get_params();
  949. $handle = $this->Pushmessage->handleParam($param);
  950. $param = $handle['param'];
  951. if (request()->isAjax()) {
  952. try {
  953. $param['audit_time'] = time();
  954. $this->Auditmodel->where('id', $param['id'])->strict(false)->field(true)->update(["audit_status" => 2, "audit_time" => time()]);
  955. } catch (\Exception $e) {
  956. return to_assign(1, '操作失败,原因:' . $e->getMessage());
  957. }
  958. $where = [
  959. ["project_id", "=", $param["project_id"]],
  960. ["else_id", "=", $param["else_id"]],
  961. ["audit_status", "=", 5],
  962. ["audit_type", "=", 6]
  963. ];
  964. $next = $this->Auditmodel->where($where)->count();
  965. if ($next == 0) {
  966. $where = [
  967. ["project_id", "=", $param["project_id"]],
  968. ["else_id", "=", $param["else_id"]],
  969. ["audit_type", "=", 4]
  970. ];
  971. $detail = Db::name("cost_project")->where("id", $param["project_id"])->field("entrust_maker,entrust_maker_name")->find();
  972. $auditData = $this->Auditmodel->where($where)->find()->toArray();
  973. $auditData["audit_name"] = "报告审核";
  974. $auditData["audit_status"] = 1;
  975. $auditData["audit_type"] = 2;
  976. $auditData["approver"] = $detail["entrust_maker"];
  977. $auditData["approver_name"] = $detail["entrust_maker_name"];
  978. $auditData["create_time"] = time();
  979. $auditData["audit_time"] = null;
  980. $auditData["remark"] = null;
  981. $auditData["audit_remark"] = null;
  982. unset($auditData["id"]);
  983. try {
  984. Db::name("project_report")->where("id",$param["else_id"])->update(["status"=>0]);
  985. $this->Auditmodel->save($auditData);
  986. } catch (\Exception $e) {
  987. return to_assign(1, '操作失败,原因:' . $e->getMessage());
  988. }
  989. //内部审核通过了,通知公司的发起人,通知财政局的审批人
  990. if (empty($handle['company'])) {
  991. $handle['company'] = (array)$auditData["sponsor_id"];
  992. } else {
  993. $handle['company'] = array_merge($handle['company'], (array)$auditData["sponsor_id"]);
  994. }
  995. $this->Pushmessage->pushMessage($param['project_id'], (array)$detail["entrust_maker"], $handle['company'], []);
  996. $else_name = Db::name("project_report")->where("id",$auditData["else_id"])->value("title");
  997. add_project_log("新增项目报告", $param["project_id"], $else_name, 4);add_project_log("新增项目报告", $param["project_id"], $auditData["else_name"], 4);
  998. Db::name("cost_project")->where("id", $param["project_id"])->update(["report_time" => time()]);
  999. } else {
  1000. $where = [
  1001. ["project_id", "=", $param["project_id"]],
  1002. ["else_id", "=", $param["else_id"]],
  1003. ["audit_status", "=", 5],
  1004. ["audit_type", "=", 6],
  1005. ];
  1006. $approver = $this->Auditmodel->where($where)->value("approver");
  1007. $this->Auditmodel->where($where)->update(["audit_status" => 1]);
  1008. Db::name("project_report")->where("id", $param["else_id"])->update(["status" => 0]);
  1009. //通过了二审,但是还有三审,通知公司的发起人审批通过了
  1010. $sponsor_id = $this->Auditmodel->where($where)->value("sponsor_id");
  1011. if (empty($handle['company'])) {
  1012. $handle['company'] = (array)$sponsor_id;
  1013. } else {
  1014. $handle['company'] = array_merge($handle['company'], (array)$sponsor_id);
  1015. }
  1016. // 通知发起人审批通过了
  1017. // $this->Pushmessage->pushMessage($param['project_id'], $handle['financial'], $handle['company']);
  1018. $this->Pushmessage->pushMessage($param['project_id'], NULL, $handle['company'], []);
  1019. // 通知下一级审批人,有待审核
  1020. $this->Pushmessage->pushMessage($param['project_id'], NULL, (array)$approver, []);
  1021. }
  1022. return to_assign(0, "操作成功");
  1023. }
  1024. }
  1025. public function report_agree_third()
  1026. {
  1027. $param = get_params();
  1028. $handle = $this->Pushmessage->handleParam($param);
  1029. $param = $handle['param'];
  1030. if (request()->isAjax()) {
  1031. try {
  1032. $param['audit_time'] = time();
  1033. $this->Auditmodel->where('id', $param['id'])->strict(false)->field(true)->update(["audit_status" => 2, "audit_time" => time()]);
  1034. } catch (\Exception $e) {
  1035. return to_assign(1, '操作失败,原因:' . $e->getMessage());
  1036. }
  1037. $where = [
  1038. ["project_id", "=", $param["project_id"]],
  1039. ["else_id", "=", $param["else_id"]],
  1040. ["audit_status", "=", 5],
  1041. ["audit_type", "=", 14]
  1042. ];
  1043. $next = $this->Auditmodel->where($where)->count();
  1044. if ($next == 0) {
  1045. $where = [
  1046. ["project_id", "=", $param["project_id"]],
  1047. ["else_id", "=", $param["else_id"]],
  1048. ["audit_type", "=", 4]
  1049. ];
  1050. $detail = Db::name("cost_project")->where("id", $param["project_id"])->field("entrust_maker,entrust_maker_name")->find();
  1051. $auditData = $this->Auditmodel->where($where)->find()->toArray();
  1052. $auditData["audit_name"] = "报告审核";
  1053. $auditData["audit_status"] = 1;
  1054. $auditData["audit_type"] = 2;
  1055. $auditData["approver"] = $detail["entrust_maker"];
  1056. $auditData["approver_name"] = $detail["entrust_maker_name"];
  1057. $auditData["create_time"] = time();
  1058. $auditData["audit_time"] = null;
  1059. $auditData["remark"] = null;
  1060. $auditData["audit_remark"] = null;
  1061. unset($auditData["id"]);
  1062. try {
  1063. Db::name("project_report")->where("id",$param["else_id"])->update(["status"=>0]);
  1064. $this->Auditmodel->save($auditData);
  1065. } catch (\Exception $e) {
  1066. return to_assign(1, '操作失败,原因:' . $e->getMessage());
  1067. }
  1068. //内部审核通过了,通知公司的发起人,通知财政局的审批人
  1069. if (empty($handle['company'])) {
  1070. $handle['company'] = (array)$auditData["sponsor_id"];
  1071. } else {
  1072. $handle['company'] = array_merge($handle['company'], (array)$auditData["sponsor_id"]);
  1073. }
  1074. $this->Pushmessage->pushMessage($param['project_id'], (array)$detail["entrust_maker"], $handle['company'], []);
  1075. add_project_log("新增项目报告", $param["project_id"], $auditData["else_name"], 4);
  1076. Db::name("cost_project")->where("id", $param["project_id"])->update(["report_time" => time()]);
  1077. } else {
  1078. $where = [
  1079. ["project_id", "=", $param["project_id"]],
  1080. ["else_id", "=", $param["else_id"]],
  1081. ["audit_status", "=", 5],
  1082. ["audit_type", "=", 14]
  1083. ];
  1084. $approver = $this->Auditmodel->where($where)->value("approver");
  1085. $this->Auditmodel->where($where)->update(["audit_status" => 1]);
  1086. //通过了三审,但是还有四审,通知公司的发起人审批通过了
  1087. $sponsor_id = $this->Auditmodel->where($where)->value("sponsor_id");
  1088. if (empty($handle['company'])) {
  1089. $handle['company'] = (array)$sponsor_id;
  1090. } else {
  1091. $handle['company'] = array_merge($handle['company'], (array)$sponsor_id);
  1092. }
  1093. // 通知发起人审批通过了
  1094. // $this->Pushmessage->pushMessage($param['project_id'], $handle['financial'], $handle['company']);
  1095. $this->Pushmessage->pushMessage($param['project_id'], NULL, $handle['company'], []);
  1096. // 通知下一级审批人,有待审核
  1097. $this->Pushmessage->pushMessage($param['project_id'], NULL, (array)$approver, []);
  1098. }
  1099. return to_assign(0, "操作成功");
  1100. }
  1101. }
  1102. public function report_agree_fourth()
  1103. {
  1104. $param = get_params();
  1105. $handle = $this->Pushmessage->handleParam($param);
  1106. $param = $handle['param'];
  1107. if (request()->isAjax()) {
  1108. try {
  1109. $param['audit_time'] = time();
  1110. $this->Auditmodel->where('id', $param['id'])->strict(false)->field(true)->update(["audit_status" => 2, "audit_time" => time()]);
  1111. } catch (\Exception $e) {
  1112. return to_assign(1, '操作失败,原因:' . $e->getMessage());
  1113. }
  1114. $where = [
  1115. ["project_id", "=", $param["project_id"]],
  1116. ["else_id", "=", $param["else_id"]],
  1117. ["audit_status", "=", 5],
  1118. ["audit_type", "=", 15]
  1119. ];
  1120. $next = $this->Auditmodel->where($where)->count();
  1121. if ($next == 0) {
  1122. $where = [
  1123. ["project_id", "=", $param["project_id"]],
  1124. ["else_id", "=", $param["else_id"]],
  1125. ["audit_type", "=", 4]
  1126. ];
  1127. $detail = Db::name("cost_project")->where("id", $param["project_id"])->field("entrust_maker,entrust_maker_name")->find();
  1128. $auditData = $this->Auditmodel->where($where)->find()->toArray();
  1129. $auditData["audit_name"] = "报告审核";
  1130. $auditData["audit_status"] = 1;
  1131. $auditData["audit_type"] = 2;
  1132. $auditData["approver"] = $detail["entrust_maker"];
  1133. $auditData["approver_name"] = $detail["entrust_maker_name"];
  1134. $auditData["create_time"] = time();
  1135. $auditData["audit_time"] = null;
  1136. $auditData["remark"] = null;
  1137. $auditData["audit_remark"] = null;
  1138. unset($auditData["id"]);
  1139. try {
  1140. Db::name("project_report")->where("id",$param["else_id"])->update(["status"=>0]);
  1141. $this->Auditmodel->save($auditData);
  1142. } catch (\Exception $e) {
  1143. return to_assign(1, '操作失败,原因:' . $e->getMessage());
  1144. }
  1145. Db::name("project_report")->where("id", $param["else_id"])->update(["status" => 0]);
  1146. //内部审核通过了,通知公司的发起人,通知财政局的审批人
  1147. if (empty($handle['company'])) {
  1148. $handle['company'] = (array)$auditData["sponsor_id"];
  1149. } else {
  1150. $handle['company'] = array_merge($handle['company'], (array)$auditData["sponsor_id"]);
  1151. }
  1152. $this->Pushmessage->pushMessage($param['project_id'], (array)$detail["entrust_maker"], $handle['company'], []);
  1153. $else_name = Db::name("project_report")->where("id",$auditData["else_id"])->value("title");
  1154. add_project_log("新增项目报告", $param["project_id"], $else_name, 4);
  1155. Db::name("cost_project")->where("id", $param["project_id"])->update(["report_time" => time()]);
  1156. } else {
  1157. $where = [
  1158. ["project_id", "=", $param["project_id"]],
  1159. ["else_id", "=", $param["else_id"]],
  1160. ["audit_status", "=", 5],
  1161. ["audit_type", "=", 15]
  1162. ];
  1163. $approver = $this->Auditmodel->where($where)->value("approver");
  1164. $this->Auditmodel->where($where)->update(["audit_status" => 1]);
  1165. //通过了四审,但是还有五审,通知公司的发起人审批通过了
  1166. $sponsor_id = $this->Auditmodel->where($where)->value("sponsor_id");
  1167. if (empty($handle['company'])) {
  1168. $handle['company'] = (array)$sponsor_id;
  1169. } else {
  1170. $handle['company'] = array_merge($handle['company'], (array)$sponsor_id);
  1171. }
  1172. // 通知发起人审批通过了
  1173. // $this->Pushmessage->pushMessage($param['project_id'], $handle['financial'], $handle['company']);
  1174. $this->Pushmessage->pushMessage($param['project_id'], NULL, $handle['company'], []);
  1175. // 通知下一级审批人,有待审核
  1176. $this->Pushmessage->pushMessage($param['project_id'], NULL, (array)$approver, []);
  1177. }
  1178. return to_assign(0, "操作成功");
  1179. }
  1180. }
  1181. public function report_agree_fifth()
  1182. {
  1183. $param = get_params();
  1184. $handle = $this->Pushmessage->handleParam($param);
  1185. $param = $handle['param'];
  1186. if (request()->isAjax()) {
  1187. try {
  1188. $param['audit_time'] = time();
  1189. $this->Auditmodel->where('id', $param['id'])->strict(false)->field(true)->update(["audit_status" => 2, "audit_time" => time()]);
  1190. } catch (\Exception $e) {
  1191. return to_assign(1, '操作失败,原因:' . $e->getMessage());
  1192. }
  1193. $where = [
  1194. ["project_id", "=", $param["project_id"]],
  1195. ["else_id", "=", $param["else_id"]],
  1196. ["audit_type", "=", 4]
  1197. ];
  1198. $detail = Db::name("cost_project")->where("id", $param["project_id"])->field("entrust_maker,entrust_maker_name")->find();
  1199. $auditData = $this->Auditmodel->where($where)->find()->toArray();
  1200. $auditData["audit_name"] = "报告审核";
  1201. $auditData["audit_status"] = 1;
  1202. $auditData["audit_type"] = 2;
  1203. $auditData["approver"] = $detail["entrust_maker"];
  1204. $auditData["approver_name"] = $detail["entrust_maker_name"];
  1205. $auditData["create_time"] = time();
  1206. $auditData["audit_time"] = null;
  1207. $auditData["remark"] = null;
  1208. $auditData["audit_remark"] = null;
  1209. unset($auditData["id"]);
  1210. try {
  1211. Db::name("project_report")->where("id",$param["else_id"])->update(["status"=>0]);
  1212. $this->Auditmodel->save($auditData);
  1213. } catch (\Exception $e) {
  1214. return to_assign(1, '操作失败,原因:' . $e->getMessage());
  1215. }
  1216. Db::name("project_report")->where("id", $param["else_id"])->update(["status" => 0]);
  1217. //内部审核通过了,通知公司的发起人,通知财政局的审批人
  1218. if (empty($handle['company'])) {
  1219. $handle['company'] = (array)$auditData["sponsor_id"];
  1220. } else {
  1221. $handle['company'] = array_merge($handle['company'], (array)$auditData["sponsor_id"]);
  1222. }
  1223. $this->Pushmessage->pushMessage($param['project_id'], (array)$detail['entrust_maker'], $handle['company'], []);
  1224. $else_name = Db::name("project_report")->where("id",$auditData["else_id"])->value("title");
  1225. add_project_log("新增项目报告", $param["project_id"], $else_name, 4);
  1226. try {
  1227. Db::name("cost_project")->where("id", $param["project_id"])->update(["report_time" => time()]);
  1228. } catch (\Exception $e) {
  1229. return to_assign(1, '操作失败,原因:' . $e->getMessage());
  1230. }
  1231. return to_assign(0, "操作成功");
  1232. }
  1233. }
  1234. /**
  1235. * 公司同意联系函
  1236. */
  1237. public function contact_agree_first()
  1238. {
  1239. $param = get_params();
  1240. $handle = $this->Pushmessage->handleParam($param);
  1241. $param = $handle['param'];
  1242. if (request()->isAjax()) {
  1243. try {
  1244. $param['audit_time'] = time();
  1245. $this->Auditmodel->where('id', $param['id'])->strict(false)->field(true)->update(["audit_status" => 2, "audit_time" => time()]);
  1246. } catch (\Exception $e) {
  1247. return to_assign(1, '操作失败,原因:' . $e->getMessage());
  1248. }
  1249. $where = [
  1250. ["project_id", "=", $param["project_id"]],
  1251. ["else_id", "=", $param["else_id"]],
  1252. ["audit_status", "=", 5],
  1253. ["audit_type", "=", 8]
  1254. ];
  1255. $next = $this->Auditmodel->where($where)->count();
  1256. if ($next == 0) {
  1257. $where = [
  1258. ["project_id", "=", $param["project_id"]],
  1259. ["else_id", "=", $param["else_id"]],
  1260. ["audit_type", "=", 7]
  1261. ];
  1262. $detail = Db::name("cost_project")->where("id", $param["project_id"])->field("entrust_maker,entrust_maker_name")->find();
  1263. $auditData = $this->Auditmodel->where($where)->find()->toArray();
  1264. $auditData["audit_name"] = "联系函审核";
  1265. $auditData["audit_status"] = 1;
  1266. $auditData["audit_type"] = 3;
  1267. $auditData["approver"] = $detail["entrust_maker"];
  1268. $auditData["approver_name"] = $detail["entrust_maker_name"];
  1269. $auditData["create_time"] = time();
  1270. $auditData["audit_time"] = null;
  1271. $auditData["remark"] = null;
  1272. $auditData["audit_remark"] = null;
  1273. unset($auditData["id"]);
  1274. try {
  1275. $this->Auditmodel->save($auditData);
  1276. } catch (\Exception $e) {
  1277. return to_assign(1, '操作失败,原因:' . $e->getMessage());
  1278. }
  1279. //内部审核通过了,通知公司的发起人,通知财政局的审批人
  1280. if (empty($handle['company'])) {
  1281. $handle['company'] = (array)$auditData["sponsor_id"];
  1282. } else {
  1283. $handle['company'] = array_merge($handle['company'], (array)$auditData["sponsor_id"]);
  1284. }
  1285. $this->Pushmessage->pushMessage($param['project_id'], (array)$detail["entrust_maker"], $handle['company'], []);
  1286. add_project_log("新增项目联系函", $param["project_id"], $auditData["else_name"], 4);
  1287. Db::name("cost_project")->where("id", $param["project_id"])->update(["report_time" => time()]);
  1288. } else {
  1289. $where = [
  1290. ["project_id", "=", $param["project_id"]],
  1291. ["else_id", "=", $param["else_id"]],
  1292. ['audit_status', '=', 5],
  1293. ["audit_type", "=", 8]
  1294. ];
  1295. $approver = $this->Auditmodel->where($where)->value("approver");
  1296. $this->Auditmodel->where($where)->update(["audit_status" => 1]);
  1297. //通过了一审,但是还有二审,通知公司的发起人审批通过了
  1298. $sponsor_id = $this->Auditmodel->where($where)->value("sponsor_id");
  1299. if (empty($handle['company'])) {
  1300. $handle['company'] = (array)$sponsor_id;
  1301. } else {
  1302. $handle['company'] = array_merge($handle['company'], (array)$sponsor_id);
  1303. }
  1304. // 通知发起人审批通过了
  1305. $this->Pushmessage->pushMessage($param['project_id'], [], $handle['company'], []);
  1306. // 通知下一级审批人,有待审核
  1307. $this->Pushmessage->pushMessage($param['project_id'], [], (array)$approver, []);
  1308. }
  1309. return to_assign(0, "操作成功");
  1310. }
  1311. }
  1312. /**
  1313. * 公司同意联系函
  1314. */
  1315. public function contact_agree_second()
  1316. {
  1317. $param = get_params();
  1318. $handle = $this->Pushmessage->handleParam($param);
  1319. $param = $handle['param'];
  1320. if (request()->isAjax()) {
  1321. try {
  1322. $param['audit_time'] = time();
  1323. $this->Auditmodel->where('id', $param['id'])->strict(false)->field(true)->update(["audit_status" => 2, "audit_time" => time()]);
  1324. } catch (\Exception $e) {
  1325. return to_assign(1, '操作失败,原因:' . $e->getMessage());
  1326. }
  1327. $where = [
  1328. ["project_id", "=", $param["project_id"]],
  1329. ["else_id", "=", $param["else_id"]],
  1330. ["audit_status", "=", 5],
  1331. ["audit_type", "=", 9]
  1332. ];
  1333. $next = $this->Auditmodel->where($where)->count();
  1334. if ($next == 0) {
  1335. $where = [
  1336. ["project_id", "=", $param["project_id"]],
  1337. ["else_id", "=", $param["else_id"]],
  1338. ["audit_type", "=", 7]
  1339. ];
  1340. $detail = Db::name("cost_project")->where("id", $param["project_id"])->field("entrust_maker,entrust_maker_name")->find();
  1341. $auditData = $this->Auditmodel->where($where)->find()->toArray();
  1342. $auditData["audit_name"] = "联系函审核";
  1343. $auditData["audit_status"] = 1;
  1344. $auditData["audit_type"] = 3;
  1345. $auditData["approver"] = $detail["entrust_maker"];
  1346. $auditData["approver_name"] = $detail["entrust_maker_name"];
  1347. $auditData["create_time"] = time();
  1348. $auditData["audit_time"] = null;
  1349. $auditData["remark"] = null;
  1350. $auditData["audit_remark"] = null;
  1351. unset($auditData["id"]);
  1352. try {
  1353. $this->Auditmodel->save($auditData);
  1354. } catch (\Exception $e) {
  1355. return to_assign(1, '操作失败,原因:' . $e->getMessage());
  1356. }
  1357. //内部审核通过了,通知公司的发起人,通知财政局的审批人
  1358. if (empty($handle['company'])) {
  1359. $handle['company'] = (array)$auditData["sponsor_id"];
  1360. } else {
  1361. $handle['company'] = array_merge($handle['company'], (array)$auditData["sponsor_id"]);
  1362. }
  1363. $this->Pushmessage->pushMessage($param['project_id'], (array)$detail["entrust_maker"], $handle['company'], []);
  1364. add_project_log("新增项目联系函", $param["project_id"], $auditData["else_name"], 4);
  1365. Db::name("cost_project")->where("id", $param["project_id"])->update(["report_time" => time()]);
  1366. } else {
  1367. $where = [
  1368. ["project_id", "=", $param["project_id"]],
  1369. ["else_id", "=", $param["else_id"]],
  1370. ['audit_status', '=', '5'],
  1371. ["audit_type", "=", 9],
  1372. ];
  1373. $approver = $this->Auditmodel->where($where)->value('approver');
  1374. $this->Auditmodel->where($where)->update(["audit_status" => 1]);
  1375. //通过了二审,但是还有三审,通知公司的发起人审批通过了
  1376. $sponsor_id = $this->Auditmodel->where($where)->value("sponsor_id");
  1377. if (empty($handle['company'])) {
  1378. $handle['company'] = (array)$sponsor_id;
  1379. } else {
  1380. $handle['company'] = array_merge($handle['company'], (array)$sponsor_id);
  1381. }
  1382. $this->Pushmessage->pushMessage($param['project_id'], [], $handle['company'], []);
  1383. $this->Pushmessage->pushMessage($param['project_id'], [], (array)$approver, []);
  1384. }
  1385. return to_assign(0, "操作成功");
  1386. }
  1387. }
  1388. /**
  1389. * 公司同意联系函
  1390. */
  1391. public function contact_agree_third()
  1392. {
  1393. $param = get_params();
  1394. $handle = $this->Pushmessage->handleParam($param);
  1395. $param = $handle['param'];
  1396. if (request()->isAjax()) {
  1397. try {
  1398. $param['audit_time'] = time();
  1399. $this->Auditmodel->where('id', $param['id'])->strict(false)->field(true)->update(["audit_status" => 2, "audit_time" => time()]);
  1400. } catch (\Exception $e) {
  1401. return to_assign(1, '操作失败,原因:' . $e->getMessage());
  1402. }
  1403. $where = [
  1404. ["project_id", "=", $param["project_id"]],
  1405. ["else_id", "=", $param["else_id"]],
  1406. ["audit_type", "=", 7]
  1407. ];
  1408. $detail = Db::name("cost_project")->where("id", $param["project_id"])->field("entrust_maker,entrust_maker_name")->find();
  1409. $auditData = $this->Auditmodel->where($where)->find()->toArray();
  1410. $auditData["audit_name"] = "联系函审核";
  1411. $auditData["audit_status"] = 1;
  1412. $auditData["audit_type"] = 3;
  1413. $auditData["approver"] = $detail["entrust_maker"];
  1414. $auditData["approver_name"] = $detail["entrust_maker_name"];
  1415. $auditData["create_time"] = time();
  1416. $auditData["audit_time"] = null;
  1417. $auditData["remark"] = null;
  1418. $auditData["audit_remark"] = null;
  1419. unset($auditData["id"]);
  1420. try {
  1421. $this->Auditmodel->save($auditData);
  1422. } catch (\Exception $e) {
  1423. return to_assign(1, '操作失败,原因:' . $e->getMessage());
  1424. }
  1425. //内部审核通过了,通知公司的发起人,通知财政局的审批人
  1426. if (empty($handle['company'])) {
  1427. $handle['company'] = (array)$auditData["sponsor_id"];
  1428. } else {
  1429. $handle['company'] = array_merge($handle['company'], (array)$auditData["sponsor_id"]);
  1430. }
  1431. $this->Pushmessage->pushMessage($param['project_id'], (array)$detail['entrust_maker'], $handle['company'], []);
  1432. add_project_log("新增项目联系函", $param["project_id"], $auditData["else_name"], 4);
  1433. Db::name("cost_project")->where("id", $param["project_id"])->update(["report_time" => time()]);
  1434. return to_assign(0, "操作成功");
  1435. }
  1436. }
  1437. /**
  1438. * 公司同意请款
  1439. */
  1440. public function appropriation_agree_first()
  1441. {
  1442. $param = get_params();
  1443. $handle = $this->Pushmessage->handleParam($param);
  1444. $param = $handle['param'];
  1445. if (request()->isAjax()) {
  1446. try {
  1447. $param['audit_time'] = time();
  1448. $this->Auditmodel->where('id', $param['id'])
  1449. ->strict(false)->field(true)
  1450. ->update(["audit_status" => 2, "audit_time" => time()]);
  1451. } catch (\Exception $e) {
  1452. return to_assign(1, '操作失败,原因:' . $e->getMessage());
  1453. }
  1454. $where = [
  1455. ["project_id", "=", $param["project_id"]],
  1456. ["else_id", "=", 0],
  1457. ["audit_status", "=", 5],
  1458. ["audit_type", "in", 11]
  1459. ];
  1460. $next = $this->Auditmodel->where($where)->count();
  1461. if ($next == 0) {
  1462. try {
  1463. Db::name("appropriation")->where("id", $param["project_id"])->update(["status" => 1]);
  1464. } catch (\Exception $e) {
  1465. return to_assign(1, '操作失败,原因:' . $e->getMessage());
  1466. }
  1467. //$param["project_id"]为关联id,非项目id
  1468. $project = Db::name("appropriation_project")->where("uid", $param["project_id"])->select();
  1469. $financial = [];
  1470. $company = [];
  1471. $project_ids = [];
  1472. foreach ($project as $item => $value) {
  1473. $id = Db::name("cost_project")->where("id", $value['project_id'])->value("entrust_maker");
  1474. if (empty($handle['financial'])) {
  1475. $financial = (array)$id;
  1476. } else {
  1477. $financial = array_merge($handle['financial'], (array)$id);
  1478. }
  1479. $sponsor_id = $this->Auditmodel->where('id', $param['id'])->value("sponsor_id");
  1480. if (empty($handle['company'])) {
  1481. $company = (array)$sponsor_id;
  1482. } else {
  1483. $company = array_merge($handle['company'], (array)$sponsor_id);
  1484. }
  1485. $project_ids = array_merge($project_ids, (array)$value['project_id']);
  1486. }
  1487. $this->Pushmessage->pushMessage($project_ids, $financial, $company, []);
  1488. } else {
  1489. $where = [
  1490. ["project_id", "=", $param["project_id"]],
  1491. ["else_id", "=", 0],
  1492. ['audit_status', '=', 5],
  1493. ["audit_type", "in", 11],
  1494. ];
  1495. $approver = $this->Auditmodel->where($where)->value('approver');
  1496. $this->Auditmodel->where($where)->update(["audit_status" => 1]);
  1497. $sponsor_id = $this->Auditmodel->where('id', $param['id'])->value("sponsor_id");
  1498. if (empty($handle['company'])) {
  1499. $handle['company'] = (array)$sponsor_id;
  1500. } else {
  1501. $handle['company'] = array_merge($handle['company'], (array)$sponsor_id);
  1502. }
  1503. //$param["project_id"]为关联id,非项目id
  1504. $project = Db::name("appropriation_project")->where("uid", $param["project_id"])->select();
  1505. $project_ids = [];
  1506. foreach ($project as $item => $value) {
  1507. $project_ids = array_merge($project_ids, (array)$value['project_id']);
  1508. }
  1509. // 通知发起人审批通过了
  1510. $this->Pushmessage->pushMessage($project_ids, [], $handle['company'], []);
  1511. //通知下一级审批人,有待审核
  1512. $this->Pushmessage->pushMessage($project_ids, [], (array)$approver, []);
  1513. }
  1514. return to_assign(0, "操作成功");
  1515. }
  1516. }
  1517. /**
  1518. * 公司同意请款
  1519. */
  1520. public function appropriation_agree_second()
  1521. {
  1522. $param = get_params();
  1523. $handle = $this->Pushmessage->handleParam($param);
  1524. $param = $handle['param'];
  1525. if (request()->isAjax()) {
  1526. try {
  1527. $param['audit_time'] = time();
  1528. $this->Auditmodel->where('id', $param['id'])->strict(false)->field(true)->update(["audit_status" => 2, "audit_time" => time()]);
  1529. } catch (\Exception $e) {
  1530. return to_assign(1, '操作失败,原因:' . $e->getMessage());
  1531. }
  1532. $where = [
  1533. ["project_id", "=", $param["project_id"]],
  1534. ["else_id", "=", 0],
  1535. ["audit_status", "=", 5],
  1536. ["audit_type", "in", 12]
  1537. ];
  1538. $next = $this->Auditmodel->where($where)->count();
  1539. if ($next == 0) {
  1540. try {
  1541. Db::name("appropriation")->where("id", $param["project_id"])->update(["status" => 1]);
  1542. } catch (\Exception $e) {
  1543. return to_assign(1, '操作失败,原因:' . $e->getMessage());
  1544. }
  1545. //$param["project_id"]为关联id,非项目id
  1546. $project = Db::name("appropriation_project")->where("uid", $param["project_id"])->select();
  1547. $project_ids = [];
  1548. $financial = [];
  1549. $company = [];
  1550. foreach ($project as $item => $value) {
  1551. $id = Db::name("cost_project")->where("id", $value['project_id'])->value("entrust_maker");
  1552. if (empty($handle['financial'])) {
  1553. $financial = (array)$id;
  1554. } else {
  1555. $financial = array_merge($handle['financial'], (array)$id);
  1556. }
  1557. $sponsor_id = $this->Auditmodel->where('id', $param['id'])->value("sponsor_id");
  1558. if (empty($handle['company'])) {
  1559. $company = (array)$sponsor_id;
  1560. } else {
  1561. $company = array_merge($handle['company'], (array)$sponsor_id);
  1562. }
  1563. $project_ids = array_merge($project_ids, (array)$value['project_id']);
  1564. }
  1565. $this->Pushmessage->pushMessage($project_ids, $financial, $company, []);
  1566. } else {
  1567. $where = [
  1568. ["project_id", "=", $param["project_id"]],
  1569. ["else_id", "=", 0],
  1570. ['audit_status', '=', 5],
  1571. ["audit_type", "in", 12],
  1572. ];
  1573. $approver = $this->Auditmodel->where('id', $param['id'])->value("approver");
  1574. $this->Auditmodel->where($where)->update(["audit_status" => 1]);
  1575. //$param["project_id"]为关联id,非项目id
  1576. $project = Db::name("appropriation_project")->where("uid", $param["project_id"])->select();
  1577. $sponsor_id = $this->Auditmodel->where('id', $param['id'])->value("sponsor_id");
  1578. if (empty($handle['company'])) {
  1579. $handle['company'] = (array)$sponsor_id;
  1580. } else {
  1581. $handle['company'] = array_merge($handle['company'], (array)$sponsor_id);
  1582. }
  1583. $project_ids = [];
  1584. foreach ($project as $item => $value) {
  1585. $project_ids = array_merge($project_ids, (array)$value['project_id']);
  1586. }
  1587. // 通知发起人审批通过了
  1588. $this->Pushmessage->pushMessage($project_ids, [], $handle['company'], []);
  1589. //通知下一级审批人,有待审核
  1590. $this->Pushmessage->pushMessage($project_ids, [], (array)$approver, []);
  1591. }
  1592. return to_assign(0, "操作成功");
  1593. }
  1594. }
  1595. /**
  1596. * 公司同意请款
  1597. */
  1598. public function appropriation_agree_third()
  1599. {
  1600. $param = get_params();
  1601. $handle = $this->Pushmessage->handleParam($param);
  1602. $param = $handle['param'];
  1603. if (request()->isAjax()) {
  1604. try {
  1605. $param['audit_time'] = time();
  1606. $this->Auditmodel->where('id', $param['id'])->strict(false)->field(true)->update(["audit_status" => 2, "audit_time" => time()]);
  1607. } catch (\Exception $e) {
  1608. return to_assign(1, '操作失败,原因:' . $e->getMessage());
  1609. }
  1610. try {
  1611. Db::name("appropriation")->where("id", $param["project_id"])->update(["status" => 1]);
  1612. } catch (\Exception $e) {
  1613. return to_assign(1, '操作失败,原因:' . $e->getMessage());
  1614. }
  1615. //$param["project_id"]为关联id,非项目id
  1616. $project = Db::name("appropriation_project")->where("uid", $param["project_id"])->select();
  1617. $project_ids = [];
  1618. $financial = [];
  1619. $company = [];
  1620. foreach ($project as $item => $value) {
  1621. $id = Db::name("cost_project")->where("id", $value['project_id'])->value("entrust_maker");
  1622. if (empty($handle['financial'])) {
  1623. $financial = (array)$id;
  1624. } else {
  1625. $financial = array_merge($handle['financial'], (array)$id);
  1626. }
  1627. $sponsor_id = $this->Auditmodel->where('id', $param['id'])->value("sponsor_id");
  1628. if (empty($handle['company'])) {
  1629. $company = (array)$sponsor_id;
  1630. } else {
  1631. $company = array_merge($handle['company'], (array)$sponsor_id);
  1632. }
  1633. $project_ids = array_merge($project_ids, (array)$value['project_id']);
  1634. }
  1635. $this->Pushmessage->pushMessage($project_ids, $financial, $company, []);
  1636. return to_assign(0, "操作成功");
  1637. }
  1638. }
  1639. /**
  1640. * 公司拒绝报告
  1641. */
  1642. public function report_disagree_first()
  1643. {
  1644. $param = get_params();
  1645. $handle = $this->Pushmessage->handleParam($param);
  1646. $param = $handle['param'];
  1647. if (request()->isAjax()) {
  1648. try {
  1649. $param['audit_time'] = time();
  1650. $this->Auditmodel->where('id', $param['id'])->strict(false)->field(true)->update(["audit_status" => 3, "audit_remark" => $param["audit_remark"], "audit_time" => time()]);
  1651. Db::name("project_report")->where("id", $param["else_id"])->update(["status" => 7]);
  1652. } catch (\Exception $e) {
  1653. return to_assign(1, '操作失败,原因:' . $e->getMessage());
  1654. }
  1655. $where = [
  1656. ["project_id", "=", $param["project_id"]],
  1657. ["else_id", "=", $param["else_id"]],
  1658. ["audit_status", "=", 5],
  1659. ["audit_type", "=", 5]
  1660. ];
  1661. $next = $this->Auditmodel->where($where)->column("id");
  1662. if (!empty($next)) {
  1663. $this->Auditmodel->whereIn("id", $next)->update(["audit_remark" => "审核未全部通过,已作废"]);
  1664. }
  1665. $id = $param['id'];
  1666. $detail = Db::name("cost_project")->where("id", $param["project_id"])->field("entrust_maker,entrust_maker_name")->find();
  1667. $sponsor_id = $this->Auditmodel->where('id', $param['id'])->value("sponsor_id");
  1668. if (empty($handle['company'])) {
  1669. $handle['company'] = (array)$sponsor_id;
  1670. } else {
  1671. $handle['company'] = array_merge($handle['company'], (array)$sponsor_id);
  1672. }
  1673. // $this->Pushmessage->pushMessage($param['project_id'], (array)$detail['entrust_maker'], $handle['company']);
  1674. $this->Pushmessage->pushMessage($param['project_id'], [], $handle['company'], []);
  1675. $content = get_login_admin("nickname") . "拒绝了" . $this->Auditmodel->where('id', $id)->value("audit_name") . "《" . $param["else_name"] . "》,原因:".$param["audit_remark"];
  1676. add_project_log('审批拒绝', $param['project_id'], $content);
  1677. return to_assign(0, "操作成功");
  1678. }
  1679. }
  1680. public function report_disagree_second()
  1681. {
  1682. $param = get_params();
  1683. $handle = $this->Pushmessage->handleParam($param);
  1684. $param = $handle['param'];
  1685. if (request()->isAjax()) {
  1686. try {
  1687. $param['audit_time'] = time();
  1688. $this->Auditmodel->where('id', $param['id'])->strict(false)->field(true)->update(["audit_status" => 3, "audit_remark" => $param["audit_remark"], "audit_time" => time()]);
  1689. Db::name("project_report")->where("id", $param["else_id"])->update(["status" => 7]);
  1690. } catch (\Exception $e) {
  1691. return to_assign(1, '操作失败,原因:' . $e->getMessage());
  1692. }
  1693. $where = [
  1694. ["project_id", "=", $param["project_id"]],
  1695. ["else_id", "=", $param["else_id"]],
  1696. ["audit_status", "=", 5],
  1697. ["audit_type", "=", 6]
  1698. ];
  1699. $next = $this->Auditmodel->where($where)->column("id");
  1700. if (!empty($next)) {
  1701. $this->Auditmodel->whereIn("id", $next)->update(["audit_remark" => "审核未全部通过,已作废"]);
  1702. }
  1703. $id = $param['id'];
  1704. $MsgData = ["content" => get_login_admin("nickname") . "拒绝了您发起的" . $this->Auditmodel->where('id', $id)->value("audit_name") . "《" . $param["else_name"] . "》",];
  1705. $detail = Db::name("cost_project")->where("id", $param["project_id"])->field("entrust_maker,entrust_maker_name")->find();
  1706. $sponsor_id = $this->Auditmodel->where('id', $param['id'])->value("sponsor_id");
  1707. if (empty($handle['company'])) {
  1708. $handle['company'] = (array)$sponsor_id;
  1709. } else {
  1710. $handle['company'] = array_merge($handle['company'], (array)$sponsor_id);
  1711. }
  1712. // $this->Pushmessage->pushMessage($param['project_id'], (array)$detail['entrust_maker'], $handle['company']);
  1713. $content = get_login_admin("nickname") . "拒绝了" . $this->Auditmodel->where('id', $id)->value("audit_name") . "《" . $param["else_name"] . "》,原因:".$param["audit_remark"];
  1714. add_project_log('审批拒绝', $param['project_id'], $content);
  1715. return to_assign(0, "操作成功");
  1716. }
  1717. }
  1718. public function report_disagree_third()
  1719. {
  1720. $param = get_params();
  1721. $handle = $this->Pushmessage->handleParam($param);
  1722. $param = $handle['param'];
  1723. if (request()->isAjax()) {
  1724. try {
  1725. $param['audit_time'] = time();
  1726. $this->Auditmodel->where('id', $param['id'])->strict(false)->field(true)->update(["audit_status" => 3, "audit_remark" => $param["audit_remark"], "audit_time" => time()]);
  1727. Db::name("project_report")->where("id", $param["else_id"])->update(["status" => 7]);
  1728. } catch (\Exception $e) {
  1729. return to_assign(1, '操作失败,原因:' . $e->getMessage());
  1730. }
  1731. $where = [
  1732. ["project_id", "=", $param["project_id"]],
  1733. ["else_id", "=", $param["else_id"]],
  1734. ["audit_status", "=", 5],
  1735. ["audit_type", "=", 14]
  1736. ];
  1737. $next = $this->Auditmodel->where($where)->column("id");
  1738. if (!empty($next)) {
  1739. $this->Auditmodel->whereIn("id", $next)->update(["audit_remark" => "审核未全部通过,已作废"]);
  1740. }
  1741. $id = $param['id'];
  1742. $detail = Db::name("cost_project")->where("id", $param["project_id"])->field("entrust_maker,entrust_maker_name")->find();
  1743. $sponsor_id = $this->Auditmodel->where('id', $param['id'])->value("sponsor_id");
  1744. if (empty($handle['company'])) {
  1745. $handle['company'] = (array)$sponsor_id;
  1746. } else {
  1747. $handle['company'] = array_merge($handle['company'], (array)$sponsor_id);
  1748. }
  1749. // $this->Pushmessage->pushMessage($param['project_id'], (array)$detail['entrust_maker'], $handle['company']);
  1750. $content = get_login_admin("nickname") . "拒绝了" . $this->Auditmodel->where('id', $id)->value("audit_name") . "《" . $param["else_name"] . "》,原因:".$param["audit_remark"];
  1751. add_project_log('审批拒绝', $param['project_id'], $content);
  1752. return to_assign(0, "操作成功");
  1753. }
  1754. }
  1755. public function report_disagree_fourth()
  1756. {
  1757. $param = get_params();
  1758. $handle = $this->Pushmessage->handleParam($param);
  1759. $param = $handle['param'];
  1760. if (request()->isAjax()) {
  1761. try {
  1762. $param['audit_time'] = time();
  1763. $this->Auditmodel->where('id', $param['id'])->strict(false)->field(true)->update(["audit_status" => 3, "audit_remark" => $param["audit_remark"], "audit_time" => time()]);
  1764. Db::name("project_report")->where("id", $param["else_id"])->update(["status" => 7]);
  1765. } catch (\Exception $e) {
  1766. return to_assign(1, '操作失败,原因:' . $e->getMessage());
  1767. }
  1768. $where = [
  1769. ["project_id", "=", $param["project_id"]],
  1770. ["else_id", "=", $param["else_id"]],
  1771. ["audit_status", "=", 5],
  1772. ["audit_type", "=", 15]
  1773. ];
  1774. $next = $this->Auditmodel->where($where)->column("id");
  1775. if (!empty($next)) {
  1776. $this->Auditmodel->whereIn("id", $next)->update(["audit_remark" => "审核未全部通过,已作废"]);
  1777. }
  1778. $id = $param['id'];
  1779. $MsgData = ["content" => get_login_admin("nickname") . "拒绝了您发起的" . $this->Auditmodel->where('id', $id)->value("audit_name") . "《" . $param["else_name"] . "》",];
  1780. $detail = Db::name("cost_project")->where("id", $param["project_id"])->field("entrust_maker,entrust_maker_name")->find();
  1781. $sponsor_id = $this->Auditmodel->where('id', $param['id'])->value("sponsor_id");
  1782. if (empty($handle['company'])) {
  1783. $handle['company'] = (array)$sponsor_id;
  1784. } else {
  1785. $handle['company'] = array_merge($handle['company'], (array)$sponsor_id);
  1786. }
  1787. // $this->Pushmessage->pushMessage($param['project_id'], (array)$detail['entrust_maker'], $handle['company']);
  1788. $this->Pushmessage->pushMessage($param['project_id'], [], $handle['company'], []);
  1789. $content = get_login_admin("nickname") . "拒绝了" . $this->Auditmodel->where('id', $id)->value("audit_name") . "《" . $param["else_name"] . "》,原因:".$param["audit_remark"];
  1790. add_project_log('审批拒绝', $param['project_id'], $content);
  1791. return to_assign(0, "操作成功");
  1792. }
  1793. }
  1794. public function report_disagree_fifth()
  1795. {
  1796. $param = get_params();
  1797. $handle = $this->Pushmessage->handleParam($param);
  1798. $param = $handle['param'];
  1799. if (request()->isAjax()) {
  1800. try {
  1801. $param['audit_time'] = time();
  1802. $this->Auditmodel->where('id', $param['id'])->strict(false)->field(true)->update(["audit_status" => 3, "audit_remark" => $param["audit_remark"], "audit_time" => time()]);
  1803. Db::name("project_report")->where("id", $param["else_id"])->update(["status" => 7]);
  1804. } catch (\Exception $e) {
  1805. return to_assign(1, '操作失败,原因:' . $e->getMessage());
  1806. }
  1807. $else_name = Db::name('project_audit')->where('else_id',$param['else_id'])->value('else_name');
  1808. $id = $param['id'];
  1809. $MsgData = ["content" => get_login_admin("nickname") . "拒绝了您发起的" . $this->Auditmodel->where('id', $id)->value("audit_name") . "《" . $else_name . "》"];
  1810. $detail = Db::name("cost_project")->where("id", $param["project_id"])->field("entrust_maker,entrust_maker_name")->find();
  1811. $sponsor_id = $this->Auditmodel->where('id', $param['id'])->value("sponsor_id");
  1812. if (empty($handle['company'])) {
  1813. $handle['company'] = (array)$sponsor_id;
  1814. } else {
  1815. $handle['company'] = array_merge($handle['company'], (array)$sponsor_id);
  1816. }
  1817. // $this->Pushmessage->pushMessage($param['project_id'], (array)$detail['entrust_maker'], $handle['company']);
  1818. $this->Pushmessage->pushMessage($param['project_id'], [], $handle['company'], []);
  1819. $content = get_login_admin("nickname") . "拒绝了" . $this->Auditmodel->where('id', $id)->value("audit_name") . "《" . $else_name . "》,原因:".$param["audit_remark"];
  1820. add_project_log('审批拒绝', $param['project_id'], $content);
  1821. return to_assign(0, "操作成功");
  1822. }
  1823. }
  1824. /**
  1825. * 公司拒绝联系函
  1826. */
  1827. public function contact_disagree_first()
  1828. {
  1829. $param = get_params();
  1830. $handle = $this->Pushmessage->handleParam($param);
  1831. $param = $handle['param'];
  1832. if (request()->isAjax()) {
  1833. try {
  1834. $param['audit_time'] = time();
  1835. $this->Auditmodel->where('id', $param['id'])->strict(false)->field(true)->update(["audit_status" => 3, "audit_remark" => $param["audit_remark"], "audit_time" => time()]);
  1836. Db::name("project_report")->where("id", $param["else_id"])->update(["status" => 7]);
  1837. } catch (\Exception $e) {
  1838. return to_assign(1, '操作失败,原因:' . $e->getMessage());
  1839. }
  1840. $where = [
  1841. ["project_id", "=", $param["project_id"]],
  1842. ["else_id", "=", $param["else_id"]],
  1843. ["audit_status", "=", 5],
  1844. ["audit_type", "=", 8]
  1845. ];
  1846. $next = $this->Auditmodel->where($where)->column("id");
  1847. if (!empty($next)) {
  1848. $this->Auditmodel->whereIn("id", $next)->update(["audit_remark" => "审核未全部通过,已作废"]);
  1849. }
  1850. $id = $param['id'];
  1851. $MsgData = ["content" => get_login_admin("nickname") . "拒绝了您发起的" . $this->Auditmodel->where('id', $id)->value("audit_name") . "《" . $param["else_name"] . "》",];
  1852. $detail = Db::name("cost_project")->where("id", $param["project_id"])->field("entrust_maker,entrust_maker_name")->find();
  1853. $sponsor_id = $this->Auditmodel->where('id', $param['id'])->value("sponsor_id");
  1854. if (empty($handle['company'])) {
  1855. $handle['company'] = (array)$sponsor_id;
  1856. } else {
  1857. $handle['company'] = array_merge($handle['company'], (array)$sponsor_id);
  1858. }
  1859. // $this->Pushmessage->pushMessage($param['project_id'], (array)$detail['entrust_maker'], $handle['company']);
  1860. $this->Pushmessage->pushMessage($param['project_id'], [], $handle['company'], []);
  1861. $content = get_login_admin("nickname") . "拒绝了" . $this->Auditmodel->where('id', $id)->value("audit_name") . "《" . $param["else_name"] . "》,原因:".$param["audit_remark"];
  1862. add_project_log('审批拒绝', $param['project_id'], $content);
  1863. return to_assign(0, "操作成功");
  1864. }
  1865. }
  1866. /**
  1867. * 公司拒绝联系函
  1868. */
  1869. public function contact_disagree_second()
  1870. {
  1871. $param = get_params();
  1872. $handle = $this->Pushmessage->handleParam($param);
  1873. $param = $handle['param'];
  1874. if (request()->isAjax()) {
  1875. try {
  1876. $param['audit_time'] = time();
  1877. $this->Auditmodel->where('id', $param['id'])->strict(false)->field(true)->update(["audit_status" => 3, "audit_remark" => $param["audit_remark"], "audit_time" => time()]);
  1878. Db::name("project_report")->where("id", $param["else_id"])->update(["status" => 7]);
  1879. } catch (\Exception $e) {
  1880. return to_assign(1, '操作失败,原因:' . $e->getMessage());
  1881. }
  1882. $where = [
  1883. ["project_id", "=", $param["project_id"]],
  1884. ["else_id", "=", $param["else_id"]],
  1885. ["audit_status", "=", 5],
  1886. ["audit_type", "=", 9]
  1887. ];
  1888. $next = $this->Auditmodel->where($where)->column("id");
  1889. if (!empty($next)) {
  1890. $this->Auditmodel->whereIn("id", $next)->update(["audit_remark" => "审核未全部通过,已作废"]);
  1891. }
  1892. $id = $param['id'];
  1893. $MsgData = ["content" => get_login_admin("nickname") . "拒绝了您发起的" . $this->Auditmodel->where('id', $id)->value("audit_name") . "《" . $param["else_name"] . "》",];
  1894. $detail = Db::name("cost_project")->where("id", $param["project_id"])->field("entrust_maker,entrust_maker_name")->find();
  1895. $sponsor_id = $this->Auditmodel->where('id', $param['id'])->value("sponsor_id");
  1896. if (empty($handle['company'])) {
  1897. $handle['company'] = (array)$sponsor_id;
  1898. } else {
  1899. $handle['company'] = array_merge($handle['company'], (array)$sponsor_id);
  1900. }
  1901. // $this->Pushmessage->pushMessage($param['project_id'], (array)$detail['entrust_maker'], $handle['company']);
  1902. $this->Pushmessage->pushMessage($param['project_id'], [], $handle['company'], []);
  1903. $content = get_login_admin("nickname") . "拒绝了" . $this->Auditmodel->where('id', $id)->value("audit_name") . "《" . $param["else_name"] . "》,原因:".$param["audit_remark"];
  1904. add_project_log('审批拒绝', $param['project_id'], $content);
  1905. return to_assign(0, "操作成功");
  1906. }
  1907. }
  1908. /**
  1909. * 公司拒绝联系函
  1910. */
  1911. public function contact_disagree_third()
  1912. {
  1913. $param = get_params();
  1914. $handle = $this->Pushmessage->handleParam($param);
  1915. $param = $handle['param'];
  1916. if (request()->isAjax()) {
  1917. try {
  1918. $param['audit_time'] = time();
  1919. $this->Auditmodel->where('id', $param['id'])->strict(false)->field(true)->update(["audit_status" => 3, "audit_remark" => $param["audit_remark"], "audit_time" => time()]);
  1920. Db::name("project_report")->where("id", $param["else_id"])->update(["status" => 7]);
  1921. } catch (\Exception $e) {
  1922. return to_assign(1, '操作失败,原因:' . $e->getMessage());
  1923. }
  1924. $id = $param['id'];
  1925. $MsgData = ["content" => get_login_admin("nickname") . "拒绝了您发起的" . $this->Auditmodel->where('id', $id)->value("audit_name") . "《" . $param["else_name"] . "》",];
  1926. $detail = Db::name("cost_project")->where("id", $param["project_id"])->field("entrust_maker,entrust_maker_name")->find();
  1927. $sponsor_id = $this->Auditmodel->where('id', $param['id'])->value("sponsor_id");
  1928. if (empty($handle['company'])) {
  1929. $handle['company'] = (array)$sponsor_id;
  1930. } else {
  1931. $handle['company'] = array_merge($handle['company'], (array)$sponsor_id);
  1932. }
  1933. // $this->Pushmessage->pushMessage($param['project_id'], (array)$detail['entrust_maker'], $handle['company']);
  1934. $this->Pushmessage->pushMessage($param['project_id'], [], $handle['company'], []);
  1935. $content = get_login_admin("nickname") . "拒绝了" . $this->Auditmodel->where('id', $id)->value("audit_name") . "《" . $param["else_name"] . "》,原因:".$param["audit_remark"];
  1936. add_project_log('审批拒绝', $param['project_id'], $content);
  1937. return to_assign(0, "操作成功");
  1938. }
  1939. }
  1940. /**
  1941. * 公司拒绝请款
  1942. */
  1943. public function appropriation_disagree_first()
  1944. {
  1945. $param = get_params();;
  1946. $handle = $this->Pushmessage->handleParam($param);
  1947. $param = $handle['param'];
  1948. if (request()->isAjax()) {
  1949. try {
  1950. $param['audit_time'] = time();
  1951. $this->Auditmodel->where('id', $param['id'])->strict(false)->field(true)->update(["audit_status" => 3, "audit_remark" => $param["audit_remark"], "audit_time" => time()]);
  1952. Db::name("project_report")->where("id", $param["else_id"])->update(["status" => 7]);
  1953. } catch (\Exception $e) {
  1954. return to_assign(1, '操作失败,原因:' . $e->getMessage());
  1955. }
  1956. try {
  1957. Db::name("appropriation")->where("id", $param["project_id"])->update(["status" => -2]);
  1958. } catch (\Exception $e) {
  1959. return to_assign(1, '操作失败,原因:' . $e->getMessage());
  1960. }
  1961. $where = [
  1962. ["project_id", "=", $param["project_id"]],
  1963. ["else_id", "=", 0],
  1964. ["audit_status", "=", 5],
  1965. ["audit_type", ">", 10],
  1966. ["audit_type", "<", 13]
  1967. ];
  1968. $next = $this->Auditmodel->where($where)->column("id");
  1969. if (!empty($next)) {
  1970. $this->Auditmodel->whereIn("id", $next)->update(["audit_status"=>4,"audit_remark" => "审核未全部通过,已作废"]);
  1971. }
  1972. //$param["project_id"]为关联id,非项目id
  1973. $project = Db::name("appropriation_project")->where("uid", $param["project_id"])->select();
  1974. $sponsor_id = $this->Auditmodel->where('id', $param['id'])->value("sponsor_id");
  1975. $project_ids = [];
  1976. foreach ($project as $item => $value) {
  1977. $company = [];
  1978. if (empty($handle['company'])) {
  1979. $company = (array)$sponsor_id;
  1980. } else {
  1981. $company = array_merge($handle['company'], (array)$sponsor_id);
  1982. }
  1983. $project_ids = array_merge($project_ids, (array)$value['project_id']);
  1984. }
  1985. // $this->Pushmessage->pushMessage($project_ids, $handle['financial'],$company);
  1986. $this->Pushmessage->pushMessage($param['project_id'], [], $company, []);
  1987. return to_assign(0, "操作成功");
  1988. }
  1989. }
  1990. /**
  1991. * 公司拒绝请款
  1992. */
  1993. public function appropriation_disagree_second()
  1994. {
  1995. $param = get_params();
  1996. $handle = $this->Pushmessage->handleParam($param);
  1997. $param = $handle['param'];
  1998. if (request()->isAjax()) {
  1999. try {
  2000. $param['audit_time'] = time();
  2001. $this->Auditmodel->where('id', $param['id'])->strict(false)->field(true)->update(["audit_status" => 3, "audit_remark" => $param["audit_remark"], "audit_time" => time()]);
  2002. Db::name("project_report")->where("id", $param["else_id"])->update(["status" => 7]);
  2003. } catch (\Exception $e) {
  2004. return to_assign(1, '操作失败,原因:' . $e->getMessage());
  2005. }
  2006. try {
  2007. Db::name("appropriation")->where("id", $param["project_id"])->update(["status" => -2]);
  2008. } catch (\Exception $e) {
  2009. return to_assign(1, '操作失败,原因:' . $e->getMessage());
  2010. }
  2011. $where = [
  2012. ["project_id", "=", $param["project_id"]],
  2013. ["else_id", "=", 0],
  2014. ["audit_status", "=", 5],
  2015. ["audit_type", ">", 11],
  2016. ["audit_type", "<", 13]
  2017. ];
  2018. $next = $this->Auditmodel->where($where)->column("id");
  2019. if (!empty($next)) {
  2020. $this->Auditmodel->whereIn("id", $next)->update(["audit_status"=>4,"audit_remark" => "审核未全部通过,已作废"]);
  2021. }
  2022. //$param["project_id"]为关联id,非项目id
  2023. $project = Db::name("appropriation_project")->where("uid", $param["project_id"])->select();
  2024. $sponsor_id = $this->Auditmodel->where('id', $param['id'])->value("sponsor_id");
  2025. $project_ids = [];
  2026. $company = [];
  2027. foreach ($project as $item => $value) {
  2028. if (empty($handle['company'])) {
  2029. $company = (array)$sponsor_id;
  2030. } else {
  2031. $company = array_merge($handle['company'], (array)$sponsor_id);
  2032. }
  2033. $project_ids = array_merge($project_ids, (array)$value['project_id']);
  2034. }
  2035. // $this->Pushmessage->pushMessage($project_ids, $handle['financial'],$company);
  2036. $this->Pushmessage->pushMessage($param['project_id'], [], $company, []);
  2037. return to_assign(0, "操作成功");
  2038. }
  2039. }
  2040. /**
  2041. * 公司拒绝请款
  2042. */
  2043. public function appropriation_disagree_third()
  2044. {
  2045. $param = get_params();
  2046. $handle = $this->Pushmessage->handleParam($param);
  2047. $param = $handle['param'];
  2048. if (request()->isAjax()) {
  2049. try {
  2050. $param['audit_time'] = time();
  2051. $this->Auditmodel->where('id', $param['id'])->strict(false)->field(true)->update(["audit_status" => 3, "audit_remark" => $param["audit_remark"], "audit_time" => time()]);
  2052. Db::name("project_report")->where("id", $param["else_id"])->update(["status" => 7]);
  2053. } catch (\Exception $e) {
  2054. return to_assign(1, '操作失败,原因:' . $e->getMessage());
  2055. }
  2056. try {
  2057. Db::name("appropriation")->where("id", $param["project_id"])->update(["status" => -2]);
  2058. } catch (\Exception $e) {
  2059. return to_assign(1, '操作失败,原因:' . $e->getMessage());
  2060. }
  2061. //$param["project_id"]为关联id,非项目id
  2062. $project = Db::name("appropriation_project")->where("uid", $param["project_id"])->select();
  2063. $sponsor_id = $this->Auditmodel->where('id', $param['id'])->value("sponsor_id");
  2064. $project_ids = [];
  2065. foreach ($project as $item => $value) {
  2066. $company = [];
  2067. if (empty($handle['company'])) {
  2068. $company = (array)$sponsor_id;
  2069. } else {
  2070. $company = array_merge($handle['company'], (array)$sponsor_id);
  2071. }
  2072. $project_ids = array_merge($project_ids, (array)$value['project_id']);
  2073. }
  2074. // $this->Pushmessage->pushMessage($project_ids, $handle['financial'],$company);
  2075. $this->Pushmessage->pushMessage($param['project_id'], [], $company, []);
  2076. return to_assign(0, "操作成功");
  2077. }
  2078. }
  2079. /**
  2080. * 业主项目审核一同意
  2081. */
  2082. public function proprietor_agree()
  2083. {
  2084. if (request()->isAjax()) {
  2085. $param = get_params();
  2086. $id = isset($param['id']) ? $param["id"] : 0;
  2087. $project_id = isset($param["project_id"]) ? $param["project_id"] : 0;
  2088. $this->Auditmodel->update(["id" => $id, "audit_status" => 2, "audit_time" => time()]);
  2089. $where=[
  2090. ["project_id", "=", $param["project_id"]],
  2091. ["audit_status", "=", 5],//待启用
  2092. ["audit_type", "=", 0],
  2093. ["audit_name", "=","业主项目审核二审"]
  2094. ];
  2095. //找第二审批人id
  2096. $second_approver=$this->Auditmodel->where($where)->value("approver");
  2097. if( $second_approver!=null){
  2098. add_project_log('审批通过', $param['project_id'], "业主项目审核一通过,等待审核二");
  2099. $this->Auditmodel->where($where)->update(["audit_status" => 1]);//将其第二审批人转化为待审批
  2100. }
  2101. else{
  2102. add_project_log('审批一通过', $param['project_id'], "项目分配审核通过");
  2103. $this->model->update(["id" => $project_id, "proprietor_status" => 2]);//改为待接收
  2104. }
  2105. $this->model->update(["id" => $project_id, "proprietor_status" => 2]);
  2106. $sponsor_id = $this->Auditmodel->where('id', $id)->value('sponsor_id');
  2107. // $fiscal_nature = Db::name('CostProject')->where('project_id', $project_id)->value('fiscal_nature');
  2108. // if($fiscal_nature == '财政资金'){
  2109. // $this->Pushmessage->pushMessage($project_id, [], [], (array)$sponsor_id);
  2110. // }else if($fiscal_nature == '非财政资金'){
  2111. $this->Pushmessage->pushMessage($project_id, [], [], (array)$sponsor_id);
  2112. // }
  2113. return to_assign("0", "操作成功");
  2114. }
  2115. }
  2116. //业主项目审核二同意
  2117. public function proprietor_agree2()
  2118. {
  2119. if (request()->isAjax()) {
  2120. $param = get_params();
  2121. $id = isset($param['id']) ? $param["id"] : 0;
  2122. $project_id = isset($param["project_id"]) ? $param["project_id"] : 0;
  2123. $this->Auditmodel->update(["id" => $id, "audit_status" => 2, "audit_time" => time()]);//改为已通过
  2124. $this->model->update(["id" => $project_id, "proprietor_status" => 2]);//改为待接收
  2125. $sponsor_id = $this->Auditmodel->where('id', $id)->value('sponsor_id');
  2126. $this->Pushmessage->pushMessage($project_id, [], [], (array)$sponsor_id);
  2127. return to_assign("0", "操作成功");
  2128. }
  2129. }
  2130. /**
  2131. * 业主项目审核一拒绝
  2132. */
  2133. public function proprietor_disagree()
  2134. {
  2135. if (request()->isAjax()) {
  2136. $param = get_params();
  2137. $id = isset($param['id']) ? $param["id"] : 0;
  2138. $project_id = isset($param["project_id"]) ? $param["project_id"] : 0;
  2139. $this->Auditmodel->update(["id" => $id, "audit_status" => 3, "audit_remark" => $param["audit_remark"], "audit_time" => time()]);
  2140. $where=[
  2141. ["project_id", "=", $param["project_id"]],
  2142. ["audit_status", "=", 5],//待启用
  2143. ["audit_type", "=", 0],
  2144. ["audit_name", "=","业主项目审核二审"]
  2145. ];
  2146. //找第二审批人id
  2147. $second_approver=$this->Auditmodel->where($where)->value("approver");
  2148. if($second_approver!=null){
  2149. add_project_log('业主端审批一拒绝', $param['project_id'], "项目审核拒绝,原因:" . $param["audit_remark"]);
  2150. }
  2151. else{
  2152. $this->model->update(["id" => $project_id, "proprietor_status" => 0]);//改为业主立项中
  2153. }
  2154. $sponsor_id = $this->Auditmodel->where('id', $id)->value('sponsor_id');
  2155. $this->Pushmessage->pushMessage($project_id, [], [], (array)$sponsor_id);
  2156. return to_assign("0", "操作成功");
  2157. }
  2158. }
  2159. //业主项目审核二拒绝
  2160. public function proprietor_disagre2()
  2161. {
  2162. if (request()->isAjax()) {
  2163. $param = get_params();
  2164. $id = isset($param['id']) ? $param["id"] : 0;
  2165. $project_id = isset($param["project_id"]) ? $param["project_id"] : 0;
  2166. $this->Auditmodel->update(["id" => $id, "audit_status" => 3, "audit_remark" => $param["audit_remark"], "audit_time" => time()]);
  2167. $this->model->update(["id" => $project_id, "proprietor_status" => 0]);
  2168. add_project_log('业主端审批二拒绝', $param['project_id'], "项目审核拒绝,原因:" . $param["audit_remark"]);
  2169. $sponsor_id = $this->Auditmodel->where('id', $id)->value('sponsor_id');
  2170. $this->Pushmessage->pushMessage($project_id, [], [], (array)$sponsor_id);
  2171. return to_assign("0", "操作成功");
  2172. }
  2173. }
  2174. /*
  2175. * **************************************************************************
  2176. * **************************************************************************
  2177. * *
  2178. * _oo8oo_ *
  2179. * o8888888o *
  2180. * 88" . "88 *
  2181. * (| -_- |) *
  2182. * 0\ = /0 *
  2183. * ___/'==='\___ *
  2184. * .' \\| |// '. *
  2185. * / \\||| : |||// \ *
  2186. * / _||||| -:- |||||_ \ *
  2187. * | | \\\ - /// | | *
  2188. * | \_| ''\---/'' |_/ | *
  2189. * \ .-\__ '-' __/-. / *
  2190. * ___'. .' /--.--\ '. .'___ *
  2191. * ."" '< '.___\_<|>_/___.' >' "". *
  2192. * | | : `- \`.:`\ _ /`:.`/ -` : | | *
  2193. * \ \ `-. \_ __\ /__ _/ .-` / / *
  2194. * =====`-.____`.___ \_____/ ___.`____.-`===== *
  2195. * `=---=` *
  2196. * **************************************************************************
  2197. * ******************** ********************
  2198. * ******************** ********************
  2199. * ******************** 佛祖保佑 永远无BUG ********************
  2200. * ******************** ********************
  2201. * **************************************************************************
  2202. */
  2203. }