Audit.php 115 KB

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