Audit.php 101 KB

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