Audit.php 114 KB

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