Audit.php 114 KB

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