Contact.php 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870
  1. <?php
  2. // 联系函
  3. namespace app\admin\controller\project;
  4. use app\admin\BaseController;
  5. use app\admin\controller\Pushmessage;
  6. use app\admin\model\Admin;
  7. use app\admin\model\ProjectAudit;
  8. use app\admin\model\ProjectAudit as AuditModel;
  9. use app\admin\model\ProjectMsg;
  10. use app\wechat\controller\Officialaccount;
  11. use think\db\exception\DbException;
  12. use think\exception\ValidateException;
  13. use HTMLPurifier;
  14. use HTMLPurifier_Config;
  15. use think\facade\Db;
  16. use think\facade\Session;
  17. use think\facade\View;
  18. use think\App;
  19. use app\admin\model\Contact as ContactModel;
  20. class Contact extends BaseController
  21. {
  22. /**
  23. * 构造函数
  24. */
  25. public function __construct(App $app)
  26. {
  27. parent::__construct($app);
  28. $this->uid = get_login_admin('id');
  29. $this->Adminmodel = new Admin();
  30. $this->ProjectMsg = new ProjectMsg();
  31. $this->ContactModel = new ContactModel();
  32. $this->Officialaccount = new Officialaccount();
  33. $this->Pushmessage = new Pushmessage();
  34. $this->Auditmodel = new AuditModel();
  35. }
  36. public function conList()
  37. {
  38. $param = get_params();
  39. // halt($param);
  40. // $param = [
  41. // 'project_id' => 290,
  42. // ];
  43. $where = [
  44. ['project_id', '=', $param['project_id']],
  45. ];
  46. $rows = empty($param['limit']) ? get_config('app.page_size') : $param['limit'];
  47. $order = empty($param['order']) ? 'a.id desc' : $param['order'];
  48. $list = $this->ContactModel->where($where)
  49. ->field('a.*,u.nickname as admin_name,f.name,f.filesize,f.filepath,f.fileext,f.admin_id')
  50. ->alias('a')
  51. ->join('file f', "a.file = f.id", "left")
  52. ->join('Admin u', 'a.maker_id = u.id', "left")
  53. ->order($order)
  54. ->paginate($rows, false, ['query' => $param])
  55. ->each(function ($item, $key) {
  56. })->toArray();
  57. // halt($list);
  58. // dump($list);
  59. return table_assign(0, '', $list);
  60. }
  61. public function conList_company()
  62. {
  63. $param = get_params();
  64. // halt($param);
  65. // $param = [
  66. // 'project_id' => 290,
  67. // ];
  68. $where = [
  69. ['project_id', '=', $param['project_id']],
  70. ];
  71. $rows = empty($param['limit']) ? get_config('app.page_size') : $param['limit'];
  72. $order = empty($param['order']) ? 'a.id desc' : $param['order'];
  73. $list = $this->ContactModel->where($where)
  74. ->field('a.*,u.nickname as admin_name,f.name,f.filesize,f.filepath,f.fileext,f.admin_id')
  75. ->alias('a')
  76. ->join('file f', "a.file = f.id", "left")
  77. ->join('Admin u', 'a.maker_id = u.id', "left")
  78. ->order($order)
  79. ->paginate($rows, false, ['query' => $param])
  80. ->each(function ($item, $key) {
  81. })->toArray();
  82. // halt($list);
  83. // dump($list);
  84. return table_assign(0, '', $list);
  85. }
  86. public function conList_proprietor()
  87. {
  88. $param = get_params();
  89. // halt($param);
  90. // $param = [
  91. // 'project_id' => 290,
  92. // ];
  93. $where = [
  94. ['project_id', '=', $param['project_id']],
  95. ];
  96. $rows = empty($param['limit']) ? get_config('app.page_size') : $param['limit'];
  97. $order = empty($param['order']) ? 'a.id desc' : $param['order'];
  98. $list = $this->ContactModel->where($where)
  99. ->field('a.*,u.nickname as admin_name,f.name,f.filesize,f.filepath,f.fileext,f.admin_id')
  100. ->alias('a')
  101. ->join('file f', "a.file = f.id", "left")
  102. ->join('Admin u', 'a.maker_id = u.id', "left")
  103. ->order($order)
  104. ->paginate($rows, false, ['query' => $param])
  105. ->each(function ($item, $key) {
  106. })->toArray();
  107. // halt($list);
  108. // dump($list);
  109. return table_assign(0, '', $list);
  110. }
  111. /**
  112. * 添加-财政局
  113. */
  114. public function add()
  115. {
  116. $param = get_params();
  117. if (request()->isAjax()) {
  118. if (isset($param['table-align'])) {
  119. unset($param['table-align']);
  120. }
  121. if (isset($param['content'])) {
  122. $param['md_content'] = '';
  123. }
  124. if (isset($param['docContent-html-code'])) {
  125. $param['content'] = $param['docContent-html-code'];
  126. $param['md_content'] = $param['docContent-markdown-doc'];
  127. unset($param['docContent-html-code']);
  128. unset($param['docContent-markdown-doc']);
  129. }
  130. // 创建HTMLPurifier配置对象
  131. $config = HTMLPurifier_Config::createDefault();
  132. $config->set('HTML.DefinitionID', 'html5-definitions');
  133. $config->set('HTML.DefinitionRev', 1);
  134. $config->set('HTML.ForbiddenAttributes', ['width', 'height']);
  135. //$config->set('HTML.Allowed', 'p,b,a[href],pre[class],code,blockquote,img[src],table,tr,th,td,ul,li,ol,dl,dt,dd');
  136. $config->set('HTML.ForbiddenElements', array('script'), true);//设置拒绝使用的tagname
  137. if ($def = $config->maybeGetRawHTMLDefinition()) {
  138. $def->addElement('video', 'Block', 'Optional: (source, Flow) | (Flow, source) | Flow', 'Common', [
  139. 'src' => 'URI',
  140. 'type' => 'Text',
  141. 'poster' => 'URI',
  142. 'preload' => 'Enum#auto,metadata,none',
  143. 'controls' => 'Bool',
  144. ]);
  145. $def->addElement('source', 'Block', 'Flow', 'Common', [
  146. 'src' => 'URI',
  147. 'type' => 'Text',
  148. ]);
  149. }
  150. // 创建HTMLPurifier对象
  151. $purifier = new HTMLPurifier($config);
  152. //防止xss,过滤输入并输出结果
  153. //$param['content'] = '测试<script>alert(0);</script>';
  154. $param['content'] = $purifier->purify($param['content']);
  155. $project_id = isset($param['project_id']) ? $param['project_id'] : 0;
  156. $param['project_id'] = $project_id;
  157. $param['maker_id'] = $this->uid;
  158. $param['admin_name'] = get_login_admin('nickname');
  159. $param['status'] = 8;
  160. $content = $param["title"];
  161. add_project_log("新增联系函", $project_id, $content);
  162. try {
  163. $param['create_time'] = time();
  164. $insertId = $this->ContactModel->strict(false)->field(true)->insertGetId($param);
  165. } catch(\Exception $e) {
  166. return to_assign(1, '操作失败,原因:'.$e->getMessage());
  167. }
  168. return to_assign(0,'操作成功');
  169. } else {
  170. $project_id = isset($param['project_id']) ? $param['project_id'] : 0;
  171. //富文本类型
  172. View::assign('editor', get_system_config('other', 'editor'));
  173. //关联项目id
  174. View::assign('project_id', $project_id);
  175. return view();
  176. }
  177. }
  178. /**
  179. * 添加-公司
  180. */
  181. public function add_company()
  182. {
  183. $param = get_params();
  184. if (request()->isAjax()) {
  185. if (isset($param['table-align'])) {
  186. unset($param['table-align']);
  187. }
  188. if (isset($param['content'])) {
  189. $param['md_content'] = '';
  190. }
  191. if (isset($param['docContent-html-code'])) {
  192. $param['content'] = $param['docContent-html-code'];
  193. $param['md_content'] = $param['docContent-markdown-doc'];
  194. unset($param['docContent-html-code']);
  195. unset($param['docContent-markdown-doc']);
  196. }
  197. // 创建HTMLPurifier配置对象
  198. $config = HTMLPurifier_Config::createDefault();
  199. $config->set('HTML.DefinitionID', 'html5-definitions');
  200. $config->set('HTML.DefinitionRev', 1);
  201. $config->set('HTML.ForbiddenAttributes', ['width', 'height']);
  202. //$config->set('HTML.Allowed', 'p,b,a[href],pre[class],code,blockquote,img[src],table,tr,th,td,ul,li,ol,dl,dt,dd');
  203. $config->set('HTML.ForbiddenElements', array('script'), true);//设置拒绝使用的tagname
  204. if ($def = $config->maybeGetRawHTMLDefinition()) {
  205. $def->addElement('video', 'Block', 'Optional: (source, Flow) | (Flow, source) | Flow', 'Common', [
  206. 'src' => 'URI',
  207. 'type' => 'Text',
  208. 'poster' => 'URI',
  209. 'preload' => 'Enum#auto,metadata,none',
  210. 'controls' => 'Bool',
  211. ]);
  212. $def->addElement('source', 'Block', 'Flow', 'Common', [
  213. 'src' => 'URI',
  214. 'type' => 'Text',
  215. ]);
  216. }
  217. // 创建HTMLPurifier对象
  218. $purifier = new HTMLPurifier($config);
  219. //防止xss,过滤输入并输出结果
  220. //$param['content'] = '测试<script>alert(0);</script>';
  221. $param['content'] = $purifier->purify($param['content']);
  222. $project_id = isset($param['project_id']) ? $param['project_id'] : 0;
  223. $param['project_id'] = $project_id;
  224. $param['maker_id'] = $this->uid;
  225. $param['admin_name'] = get_login_admin('nickname');
  226. try {
  227. $param['create_time'] = time();
  228. $insertId = $this->ContactModel->strict(false)->field(true)->insertGetId($param);
  229. } catch(\Exception $e) {
  230. return to_assign(1, '操作失败,原因:'.$e->getMessage());
  231. }
  232. $detail = Db::name("cost_project")->where("id",$project_id)->field("project_name,project_status,entrust_maker,entrust_maker_name")->find();
  233. $auditDataArr = [];
  234. //1项目,2报告,3公司一级审核,4公司二级审核,5公司三级审核
  235. if (!empty($param["first"])) {
  236. $auditData = [
  237. "project_id" => $project_id,
  238. "project_name" => $detail["project_name"],
  239. "project_type" => "造价项目",
  240. "audit_name" => "联系函一审",
  241. "audit_type" => 7,
  242. "else_id" => $insertId,
  243. "sponsor" => get_login_admin("nickname"),
  244. "sponsor_id" => $this->uid,
  245. "sponsor_unit" => Db::name("department")->where("id", get_login_admin('unit_name'))->value("title"),
  246. "approver" => $param["first"],
  247. "approver_name" => get_admin($param["first"])["nickname"],
  248. "create_time" => time()
  249. ];
  250. $auditDataArr[] = $auditData;
  251. } else {
  252. return to_assign(1, "请选择审批人");
  253. }
  254. if (!empty($param["second"])) {
  255. $auditData = [
  256. "project_id" => $project_id,
  257. "project_name" => $detail["project_name"],
  258. "project_type" => "造价项目",
  259. "audit_name" => "联系函二审",
  260. "audit_type" => 8,
  261. "audit_status" => 5,
  262. "else_id" => $insertId,
  263. "sponsor" => get_login_admin("nickname"),
  264. "sponsor_id" => $this->uid,
  265. "sponsor_unit" => Db::name("department")->where("id", get_login_admin('unit_name'))->value("title"),
  266. "approver" => $param["second"],
  267. "approver_name" => get_admin($param["second"])["nickname"],
  268. "create_time" => time()
  269. ];
  270. $auditDataArr[] = $auditData;
  271. }
  272. if (!empty($param["third"])) {
  273. $auditData = [
  274. "project_id" => $project_id,
  275. "project_name" => $detail["project_name"],
  276. "project_type" => "造价项目",
  277. "audit_name" => "联系函三审",
  278. "audit_type" => 9,
  279. "audit_status" => 5,
  280. "else_id" => $insertId,
  281. "sponsor" => get_login_admin("nickname"),
  282. "sponsor_id" => $this->uid,
  283. "sponsor_unit" => Db::name("department")->where("id", get_login_admin('unit_name'))->value("title"),
  284. "approver" => $param["third"],
  285. "approver_name" => get_admin($param["third"])["nickname"],
  286. "create_time" => time()
  287. ];
  288. $auditDataArr[] = $auditData;
  289. }
  290. // halt($auditDataArr);
  291. if (!empty($auditDataArr)) {
  292. $ProjectAudit = new ProjectAudit();
  293. try {
  294. $ProjectAudit->saveAll($auditDataArr);
  295. } catch (\Exception $e) {
  296. return to_assign(1, '操作失败,原因:' . $e->getMessage());
  297. }
  298. }
  299. return to_assign(0,'操作成功');
  300. } else {
  301. $project_id = isset($param['project_id']) ? $param['project_id'] : 0;
  302. //富文本类型
  303. View::assign('editor', get_system_config('other', 'editor'));
  304. //关联项目id
  305. View::assign('project_id', $project_id);
  306. $ids = Db::name('CostProject')->where("id", $project_id)->field("entrust_maker,review_head,operate_head,operate_team")->find();
  307. $idarr = $ids["operate_team"] . ',' . $ids["operate_head"] . ',' . $ids["review_head"];
  308. $idarr = explode(",", $idarr);
  309. $people = Db::name("admin")->whereIn('id', $idarr)->field('id,nickname')->select();
  310. View::assign('people', $people);
  311. return view();
  312. }
  313. }
  314. /**
  315. *
  316. * 编辑-公司
  317. */
  318. public function edit_company()
  319. {
  320. $param = get_params();
  321. if (request()->isAjax()) {
  322. // halt($param);
  323. if (isset($param['table-align'])) {
  324. unset($param['table-align']);
  325. }
  326. if (isset($param['content'])) {
  327. $param['md_content'] = '';
  328. }
  329. if (isset($param['docContent-html-code'])) {
  330. $param['content'] = $param['docContent-html-code'];
  331. $param['md_content'] = $param['docContent-markdown-doc'];
  332. unset($param['docContent-html-code']);
  333. unset($param['docContent-markdown-doc']);
  334. }
  335. // 创建HTMLPurifier配置对象
  336. $config = HTMLPurifier_Config::createDefault();
  337. $config->set('HTML.DefinitionID', 'html5-definitions');
  338. $config->set('HTML.DefinitionRev', 1);
  339. $config->set('HTML.ForbiddenAttributes', ['width', 'height']);
  340. //$config->set('HTML.Allowed', 'p,b,a[href],pre[class],code,blockquote,img[src],table,tr,th,td,ul,li,ol,dl,dt,dd');
  341. $config->set('HTML.ForbiddenElements', array('script'), true);//设置拒绝使用的tagname
  342. if ($def = $config->maybeGetRawHTMLDefinition()) {
  343. $def->addElement('video', 'Block', 'Optional: (source, Flow) | (Flow, source) | Flow', 'Common', [
  344. 'src' => 'URI',
  345. 'type' => 'Text',
  346. 'poster' => 'URI',
  347. 'preload' => 'Enum#auto,metadata,none',
  348. 'controls' => 'Bool',
  349. ]);
  350. $def->addElement('source', 'Block', 'Flow', 'Common', [
  351. 'src' => 'URI',
  352. 'type' => 'Text',
  353. ]);
  354. }
  355. // 创建HTMLPurifier对象
  356. $purifier = new HTMLPurifier($config);
  357. //防止xss,过滤输入并输出结果
  358. //$param['content'] = '测试<script>alert(0);</script>';
  359. $param['content'] = $purifier->purify($param['content']);
  360. $contact_id = isset($param['id']) ? $param['id'] : 0;
  361. $param['project_id'] = Db::name('Contact')->where('id', $contact_id)->value('project_id');
  362. $param['maker_id'] = $this->uid;
  363. $param['audit_status'] = 0;
  364. $content = $param["title"];
  365. add_project_log("编辑联系函", $param['project_id'], $content);
  366. // $this->ContactModel->addContact($param);
  367. $this->ContactModel->where('id', $contact_id)->save($param);
  368. return to_assign(0, '修改成功');
  369. } else {
  370. $contact_id = isset($param['id']) ? $param['id'] : 0;
  371. $detail = Db::name('Contact')->where('id', $contact_id)->find();
  372. $file_array = Db::name('Contact')
  373. ->field("r.*,a.nickname as admin_name,f.name,f.filesize,f.filepath,f.fileext,f.admin_id")
  374. ->alias('r')
  375. ->join('File f', 'r.file = f.id')
  376. ->join('Admin a', 'r.maker_id = a.id', 'LEFT')
  377. ->order('r.create_time desc')
  378. ->where(array('r.id' => $contact_id))
  379. ->select()->toArray();
  380. View::assign('file_array', $file_array);
  381. //富文本类型
  382. View::assign('editor', get_system_config('other', 'editor'));
  383. View::assign('detail', $detail);
  384. // dump($detail);
  385. //关联项目id
  386. // View::assign('project_id', $project_id);
  387. return view('edit');
  388. }
  389. }
  390. /**
  391. * 查看信息-财政局
  392. */
  393. public function view()
  394. {
  395. $param = get_params();
  396. $id = isset($param['id']) ? $param['id'] : 0;
  397. $detail = $this->ContactModel->detail($id);
  398. // dump($param);
  399. // dump($detail);
  400. if (empty($detail)) {
  401. if (empty($detail)) {
  402. echo '<div style="text-align:center;color:red;margin-top:20%;">该文档不存在</div>';
  403. exit;
  404. }
  405. } else {
  406. $maker_name = Db::name('admin')->where(['id' => $detail["maker_id"]])->value("nickname");
  407. $detail["maker_name"] = $maker_name;
  408. $file_array = Db::name('Contact')
  409. ->field("r.*,a.nickname as admin_name,f.name,f.filesize,f.filepath,f.fileext,f.admin_id")
  410. ->alias('r')
  411. ->join('File f', 'r.file = f.id')
  412. ->join('Admin a', 'r.maker_id = a.id', 'LEFT')
  413. ->order('r.create_time desc')
  414. ->where(array('r.id' => $id))
  415. ->select()->toArray();
  416. View::assign('file_array', $file_array);
  417. View::assign('detail', $detail);
  418. View::assign('user', get_login_admin('user_type'));
  419. // dump($detail);
  420. return view();
  421. }
  422. }
  423. /**
  424. * 查看信息-公司
  425. */
  426. public function view_company()
  427. {
  428. $param = get_params();
  429. $id = isset($param['id']) ? $param['id'] : 0;
  430. $detail = $this->ContactModel->detail($id);
  431. // dump($param);
  432. // dump($detail);
  433. if (empty($detail)) {
  434. if (empty($detail)) {
  435. echo '<div style="text-align:center;color:red;margin-top:20%;">该文档不存在</div>';
  436. exit;
  437. }
  438. } else {
  439. $maker_name = Db::name('admin')->where(['id' => $detail["maker_id"]])->value("nickname");
  440. $detail["maker_name"] = $maker_name;
  441. $file_array = Db::name('Contact')
  442. ->field("r.*,a.nickname as admin_name,f.name,f.filesize,f.filepath,f.fileext,f.admin_id")
  443. ->alias('r')
  444. ->join('File f', 'r.file = f.id')
  445. ->join('Admin a', 'r.maker_id = a.id', 'LEFT')
  446. ->order('r.create_time desc')
  447. ->where(array('r.id' => $id))
  448. ->select()->toArray();
  449. View::assign('file_array', $file_array);
  450. View::assign('detail', $detail);
  451. View::assign('user', get_login_admin('user_type'));
  452. // dump($detail);
  453. return view('view');
  454. }
  455. }
  456. /**
  457. * 查看信息-业主
  458. */
  459. public function view_proprietor()
  460. {
  461. $param = get_params();
  462. $id = isset($param['id']) ? $param['id'] : 0;
  463. $detail = $this->ContactModel->detail($id);
  464. // dump($param);
  465. // dump($detail);
  466. if (empty($detail)) {
  467. if (empty($detail)) {
  468. echo '<div style="text-align:center;color:red;margin-top:20%;">该文档不存在</div>';
  469. exit;
  470. }
  471. } else {
  472. $maker_name = Db::name('admin')->where(['id' => $detail["maker_id"]])->value("nickname");
  473. $detail["maker_name"] = $maker_name;
  474. $file_array = Db::name('Contact')
  475. ->field("r.*,a.nickname as admin_name,f.name,f.filesize,f.filepath,f.fileext,f.admin_id")
  476. ->alias('r')
  477. ->join('File f', 'r.file = f.id')
  478. ->join('Admin a', 'r.maker_id = a.id', 'LEFT')
  479. ->order('r.create_time desc')
  480. ->where(array('r.id' => $id))
  481. ->select()->toArray();
  482. View::assign('file_array', $file_array);
  483. View::assign('detail', $detail);
  484. View::assign('user', get_login_admin('user_type'));
  485. // dump($detail);
  486. return view('view');
  487. }
  488. }
  489. public function add_file()
  490. {
  491. $param = get_params();
  492. // $param['create_time'] = time();
  493. $param['maker_id'] = $this->uid;
  494. $file_array = Db::name('file')
  495. ->field("f.id,f.name,f.filesize,f.filepath,f.fileext,f.admin_id,f.create_time,a.nickname as admin_name")
  496. ->alias("f")
  497. // ->field("r.*,a.nickname as admin_name,f.name,f.filesize,f.filepath,f.fileext,f.admin_id")
  498. ->join('Admin a', 'f.admin_id = a.id', 'LEFT')
  499. ->order('f.create_time desc')
  500. ->where(array('f.id' => $param["file"]))
  501. ->select()->toArray();
  502. // ->find();
  503. View::assign("file_array", $file_array);
  504. return json($file_array);
  505. }
  506. //删除
  507. public function delete_file()
  508. {
  509. if (request()->isDelete()) {
  510. if (true) {
  511. return to_assign(0, "删除成功");
  512. }
  513. } else {
  514. return to_assign(1, "错误的请求");
  515. }
  516. }
  517. /**
  518. * 删除-公司
  519. * 跟财评申请删除
  520. */
  521. public function delete_company()
  522. {
  523. $param = get_params();
  524. $handle = $this->Pushmessage->handleParam($param);
  525. $param = $handle['param'];
  526. $id = isset($param['id']) ? $param['id'] : 0;
  527. $detail = $this->ContactModel->where("id", $id)->find();
  528. $approver = Db::name("cost_project")->where("id", $detail["project_id"])->value("entrust_maker");
  529. $details = Db::name("cost_project")->where("id",$detail["project_id"])->field("project_name,project_status,entrust_maker,entrust_maker_name")->find();
  530. $auditData = [
  531. "project_id" => $detail["project_id"],
  532. "project_name" => $details["project_name"],
  533. "project_type" => "造价项目",
  534. "audit_name" => "删除联系函申请",
  535. "audit_type" => 3,
  536. "else_id" => $id,
  537. "sponsor" => get_login_admin("nickname"),
  538. "sponsor_id" => $this->uid,
  539. "sponsor_unit" => Db::name("department")->where("id",get_login_admin('unit_name'))->value("title"),
  540. "approver" => $details["entrust_maker"],
  541. "approver_name" => $details["entrust_maker_name"],
  542. "remark" =>$param["remark"],
  543. "create_time" => time()
  544. ];
  545. ProjectAudit::create($auditData);
  546. if (empty($handle['financial'])) {
  547. $handle['financial'] = (array)$details["entrust_maker"];
  548. } else {
  549. $handle['financial'] = array_merge($handle['company'], (array)$details["entrust_maker"]);
  550. }
  551. $this->Pushmessage->pushMessage($detail['project_id'], $handle['financial'], $handle['company']);
  552. $this->ContactModel->where("id", $id)->update(["status" => 3]);
  553. add_project_log("发起删除项目联系函审批", $detail["project_id"], $detail["title"]);
  554. return to_assign(0, "操作成功");
  555. }
  556. /**
  557. * 财评
  558. * 同意-联系函
  559. */
  560. public function agree_contact()
  561. {
  562. $param = get_params();
  563. $handle = $this->Pushmessage->handleParam($param);
  564. $param = $handle['param'];
  565. if(!isset($param["type"])){
  566. $id = isset($param['id']) ? $param['id'] : 0;
  567. $this->ContactModel->where("id", $id)->update(["status" => 1]);
  568. try {
  569. Db::name("project_audit")->where([["else_id", "=", $id]])->update(["audit_status"=>2]);
  570. } catch (DbException $e) {
  571. return to_assign(1, '操作失败,原因:'.$e->getMessage());
  572. }
  573. $people = $this->ContactModel->where('id', $id)->value("maker_id");
  574. if (empty($handle['company'])) {
  575. $handle['company'] = (array)$people;
  576. } else {
  577. $handle['company'] = array_merge($handle['company'], (array)$people);
  578. }
  579. $project_id = $this->ContactModel->where("id", $id)->value("project_id");
  580. $this->Pushmessage->pushMessage($project_id, $handle['financial'], $handle['company']);
  581. add_project_log('审批通过', $project_id, "联系函新建审批通过");
  582. }else{
  583. $param['audit_time'] = time();
  584. $this->Auditmodel->where('id', $param['id'])->strict(false)->field(true)->update(["audit_status" => 2, "audit_time" => time()]);
  585. $id = $param['id'];
  586. unset($param["id"]);
  587. $type_status = Db::name("contact")->where("id", $param["else_id"])->value("status");
  588. if ($type_status == 0) {
  589. Db::name("contact")->where("id", $param["else_id"])->update(["status" => 1, "update_time" => time()]);
  590. } elseif ($type_status == 3) {
  591. Db::name("contact")->where("id", $param["else_id"])->update(["status" => 4, "update_time" => time()]);
  592. }
  593. $people = $this->Auditmodel->where('id', $id)->value("sponsor_id");
  594. if (empty($handle['company'])) {
  595. $handle['company'] = (array)$people;
  596. } else {
  597. $handle['company'] = array_merge($handle['company'], (array)$people);
  598. }
  599. $this->Pushmessage->pushMessage($param['project_id'], $handle['financial'], $handle['company']);
  600. add_project_log('审批通过', $param['project_id'], "联系函新建审批通过");
  601. }
  602. return to_assign(0, "操作成功");
  603. }
  604. /**
  605. * 财评
  606. * 不同意-联系函
  607. */
  608. public function un_contact()
  609. {
  610. $param = get_params();
  611. $handle = $this->Pushmessage->handleParam($param);
  612. $param = $handle['param'];
  613. if(!isset($param["type"])){
  614. $id = isset($param['id']) ? $param['id'] : 0;
  615. $this->ContactModel->where("id", $id)->update(["status" => 2]);
  616. try {
  617. Db::name("project_audit")->where([["else_id", "=", $id]])->update(["audit_status"=> 3,"audit_remark" => $param["audit_remark"]]);
  618. } catch (DbException $e) {
  619. return to_assign(1, '操作失败,原因:'.$e->getMessage());
  620. }
  621. $people = $this->ContactModel->where('id', $id)->value("maker_id");
  622. if (empty($handle['company'])) {
  623. $handle['company'] = (array)$people;
  624. } else {
  625. $handle['company'] = array_merge($handle['company'], (array)$people);
  626. }
  627. $project_id = $this->ContactModel->where("id", $id)->value("project_id");
  628. $this->Pushmessage->pushMessage($project_id, $handle['financial'], $handle['company']);
  629. add_project_log('审批通过', $project_id, "联系新建审批拒绝");
  630. }else{
  631. $param = get_params();
  632. $handle = $this->Pushmessage->handleParam($param);
  633. $param = $handle['param'];
  634. try {
  635. $param['audit_time'] = time();
  636. $this->Auditmodel->where('id', $param["id"])->strict(false)->field(true)->update(["audit_status" => 3, "audit_remark" => $param["audit_remark"], "audit_time" => time()]);
  637. $id = $param['id'];
  638. unset($param["id"]);
  639. $type_status = Db::name("contact")->where("id", $param["else_id"])->value("status");
  640. if ($type_status == 0) {
  641. //新建
  642. Db::name("contact")->where("id", $param["else_id"])->update(["status" => 2, "update_time" => time()]);
  643. } elseif ($type_status == 3) {
  644. //删除
  645. Db::name("contact")->where("id", $param["else_id"])->update(["status" => 5, "update_time" => time()]);
  646. }
  647. $people = $this->Auditmodel->where('id', $id)->value("sponsor_id");
  648. if (empty($handle['company'])) {
  649. $handle['company'] = (array)$people;
  650. } else {
  651. $handle['company'] = array_merge($handle['company'], (array)$people);
  652. }
  653. $this->Pushmessage->pushMessage($param['project_id'], $handle['financial'], $handle['company']);
  654. add_project_log('审批通过', $param['project_id'], "联系新建审批拒绝");
  655. } catch (\Exception $e) {
  656. return to_assign(1, '操作失败,原因:' . $e->getMessage());
  657. }
  658. }
  659. return to_assign(0, "操作成功");
  660. }
  661. /**
  662. * 财评
  663. * 同意-删除
  664. */
  665. public function agree_delete()
  666. {
  667. $param = get_params();
  668. $handle = $this->Pushmessage->handleParam($param);
  669. $param = $handle['param'];
  670. if(!isset($param["type"])){
  671. $id = isset($param['id']) ? $param['id'] : 0;
  672. $this->ContactModel->where("id", $id)->update(["status" => 4]);
  673. try {
  674. Db::name("project_audit")->where([["else_id", "=", $id]])->update(["audit_status"=> 2]);
  675. } catch (DbException $e) {
  676. return to_assign(1, '操作失败,原因:'.$e->getMessage());
  677. }
  678. $people = $this->ContactModel->where('id', $id)->value("maker_id");
  679. if (empty($handle['company'])) {
  680. $handle['company'] = (array)$people;
  681. } else {
  682. $handle['company'] = array_merge($handle['company'], (array)$people);
  683. }
  684. $project_id = $this->ContactModel->where("id", $id)->value("project_id");
  685. $this->Pushmessage->pushMessage($project_id, $handle['financial'], $handle['company']);
  686. add_project_log('审批通过', $project_id, "联系函删除审批通过");
  687. }else{
  688. $param['audit_time'] = time();
  689. $this->Auditmodel->where('id', $param['id'])->strict(false)->field(true)->update(["audit_status" => 2, "audit_time" => time()]);
  690. add_log('edit', $param['id'], $param);
  691. $id = $param['id'];
  692. unset($param["id"]);
  693. $type_status = Db::name("contact")->where("id", $param["else_id"])->value("status");
  694. if ($type_status == 0) {
  695. Db::name("contact")->where("id", $param["else_id"])->update(["status" => 1, "update_time" => time()]);
  696. } elseif ($type_status == 3) {
  697. Db::name("contact")->where("id", $param["else_id"])->update(["status" => 4, "update_time" => time()]);
  698. }
  699. $people = $this->Auditmodel->where('id', $id)->value("sponsor_id");
  700. if (empty($handle['company'])) {
  701. $handle['company'] = (array)$people;
  702. } else {
  703. $handle['company'] = array_merge($handle['company'], (array)$people);
  704. }
  705. $this->Pushmessage->pushMessage($param['project_id'], $handle['financial'], $handle['company']);
  706. add_project_log('审批通过', $param['project_id'], "联系函删除审批通过");
  707. }
  708. return to_assign(0, "操作成功");
  709. }
  710. /**
  711. * 财评
  712. * 不同意-删除
  713. */
  714. public function un_delete()
  715. {
  716. $param = get_params();
  717. $handle = $this->Pushmessage->handleParam($param);
  718. $param = $handle['param'];
  719. if(!isset($param["type"])){
  720. $id = isset($param['id']) ? $param['id'] : 0;
  721. $this->ContactModel->where("id", $id)->update(["status" => 5]);
  722. try {
  723. Db::name("project_audit")->where([["else_id", "=", $id]])->update(["audit_status"=>3,"audit_remark" => $param["audit_remark"]]);
  724. } catch (DbException $e) {
  725. return to_assign(1, '操作失败,原因:'.$e->getMessage());
  726. }
  727. $people = $this->ContactModel->where('id', $id)->value("maker_id");
  728. if (empty($handle['company'])) {
  729. $handle['company'] = (array)$people;
  730. } else {
  731. $handle['company'] = array_merge($handle['company'], (array)$people);
  732. }
  733. $project_id = $this->ContactModel->where("id", $id)->value("project_id");
  734. $this->Pushmessage->pushMessage($project_id, $handle['financial'], $handle['company']);
  735. add_project_log('审批通过', $project_id, "联系函删除审批拒绝");
  736. }else{
  737. $param = get_params();
  738. $handle = $this->Pushmessage->handleParam($param);
  739. $param = $handle['param'];
  740. try {
  741. $param['audit_time'] = time();
  742. $this->Auditmodel->where('id', $param["id"])->strict(false)->field(true)->update(["audit_status" => 3, "audit_remark" => $param["audit_remark"], "audit_time" => time()]);
  743. $id = $param['id'];
  744. unset($param["id"]);
  745. $type_status = Db::name("contact")->where("id", $param["else_id"])->value("status");
  746. if ($type_status == 0) {
  747. //新建
  748. Db::name("contact")->where("id", $param["else_id"])->update(["status" => 2, "update_time" => time()]);
  749. } elseif ($type_status == 3) {
  750. //删除
  751. Db::name("contact")->where("id", $param["else_id"])->update(["status" => 5, "update_time" => time()]);
  752. }
  753. $people = $this->Auditmodel->where('id', $id)->value("sponsor_id");
  754. if (empty($handle['company'])) {
  755. $handle['company'] = (array)$people;
  756. } else {
  757. $handle['company'] = array_merge($handle['company'], (array)$people);
  758. }
  759. $this->Pushmessage->pushMessage($param['project_id'], $handle['financial'], $handle['company']);
  760. add_project_log('审批通过', $param['project_id'], "联系函删除审批拒绝");
  761. } catch (\Exception $e) {
  762. return to_assign(1, '操作失败,原因:' . $e->getMessage());
  763. }
  764. }
  765. return to_assign(0, "操作成功");
  766. }
  767. }