Api.php 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <?php
  2. namespace app\enterprise\controller;
  3. use app\admin\model\Enterprise;
  4. use app\common\api\DictApi;
  5. use app\common\model\TalentChecklog;
  6. use app\enterprise\model\EnterpriseRecord;
  7. use app\enterprise\common\EnterpriseController;
  8. use app\Request;
  9. use think\exception\ValidateException;
  10. class Api extends EnterpriseController {
  11. public function findEnterpriseChangeByPage()
  12. {
  13. $order = trim($this->request->param("order")) ?: "desc";
  14. $offset = trim($this->request->param("offset")) ?: 0;
  15. $limit = trim($this->request->param("limit")) ?: 10;
  16. $list = EnterpriseRecord::where('mainId',session("user")["uid"])->limit($offset, $limit)->order('createTime ' . $order)->select()->toArray();
  17. $count = count($list);
  18. return json(["total" => $count, "rows" => $list]);
  19. }
  20. public function findUnfinishedChangeRecord(){
  21. return EnterpriseRecord::where('mainId',session("user")["uid"])->where('checkState',4)->select()->toArray();
  22. }
  23. public function toAdd()
  24. {
  25. $ep = Enterprise::where('id',session("user")["uid"])->find();
  26. $ecr = [
  27. 'enterprise_id' => $ep['id'],
  28. 'newName' => $ep['name'],
  29. 'newIdCard' => $ep['idCard'],
  30. 'newStreet' => $ep['street'],
  31. 'newAddress' => $ep['address'],
  32. 'newLegal' => $ep['legal'],
  33. 'newEphone' => $ep['ephone'],
  34. 'newAgentName' => $ep['agentName'],
  35. 'newAgentEmail' => $ep['agentEmail'],
  36. 'newAgentPhone' => $ep['agentPhone'],
  37. 'type' => $ep['type'],
  38. 'newEnterpriseTag' => $ep['enterpriseTag'],
  39. 'newIndustryFieldNew' => $ep['industryFieldNew'],
  40. 'newIndustryFieldOld' => $ep['industryFieldOld']
  41. ];
  42. switch ($ep['checkState']){
  43. case 1:
  44. $ecr['checkStateName'] = '保存未提交审核';
  45. break;
  46. case 2:
  47. $ecr['checkStateName'] = '待审核';
  48. break;
  49. case 3:
  50. $ecr['checkStateName'] = '审核驳回';
  51. break;
  52. case 4:
  53. $ecr['checkStateName'] = '审核通过';
  54. break;
  55. case 5:
  56. $ecr['checkStateName'] = '重新提交';
  57. break;
  58. default:
  59. $ecr['checkStateName'] = '';
  60. }
  61. return view("", ['ecr' => $ecr]);
  62. }
  63. public function upsert(){
  64. $data = [
  65. 'id' => \StrUtil::getRequestDecodeParam($this->request,'enterprise_id'),
  66. 'name' => \StrUtil::getRequestDecodeParam($this->request,'newName'),//单位名称
  67. 'idCard' => \StrUtil::getRequestDecodeParam($this->request,'newIdCard'),//社会信用代码
  68. 'agentName' => \StrUtil::getRequestDecodeParam($this->request,'newAgentName'),//经办人
  69. 'agentPhone' => \StrUtil::getRequestDecodeParam($this->request,'newAgentPhone'),//经办人电话
  70. 'legal' => \StrUtil::getRequestDecodeParam($this->request,'newLegal'),//法人
  71. 'street' => \StrUtil::getRequestDecodeParam($this->request,'newStreet'),//镇街
  72. 'address' => \StrUtil::getRequestDecodeParam($this->request,'newAddress'),//地址
  73. 'type' => intval($this->request['type']),
  74. 'enterpriseTag' => \StrUtil::getRequestDecodeParam($this->request,'newEnterpriseTag'),//单位标签
  75. 'agentEmail' => \StrUtil::getRequestDecodeParam($this->request,'newAgentEmail'),//邮箱
  76. 'ephone' => \StrUtil::getRequestDecodeParam($this->request,'newEphone'),//单位电话
  77. 'industryFieldNew' => \StrUtil::getRequestDecodeParam($this->request,'newIndustryFieldNew'),//产业领域
  78. 'industryFieldOld' => \StrUtil::getRequestDecodeParam($this->request,'newIndustryFieldOld'),//行业领域
  79. 'bankCard' => \StrUtil::getRequestDecodeParam($this->request,'newBankCard'),//银行
  80. 'bank' => \StrUtil::getRequestDecodeParam($this->request,'newBank'),//开户行
  81. 'bankNetwork' => \StrUtil::getRequestDecodeParam($this->request,'newBankNetwork')//网点
  82. ];
  83. try {
  84. validate(\app\common\validate\Enterprise::class)->batch(true)->scene('change')->check($data);
  85. $ep = Enterprise::where('id',session("user")["uid"])->find();
  86. $record_id = \StrUtil::getRequestDecodeParam($this->request,'id');
  87. if($record_id){
  88. $record_data = [
  89. 'mainId' => $data['id'],
  90. 'type' => $data['type'],
  91. 'oldName' => $ep['name'],
  92. 'oldIdCard' => $ep['idCard'],
  93. 'oldIndustryFieldNew' => $ep['industryFieldNew'],
  94. 'oldIndustryFieldOld' => $ep['industryFieldOld'],
  95. 'oldStreet' => $ep['street'],
  96. 'oldAddress' => $ep['address'],
  97. 'oldLegal' => $ep['legal'],
  98. 'oldEphone' => $ep['ephone'],
  99. 'oldAgentName' => $ep['agentName'],
  100. 'oldAgentEmail' => $ep['agentEmail'],
  101. 'oldAgentPhone' => $ep['agentPhone'],
  102. 'oldEnterpriseTag' => $ep['enterpriseTag'],
  103. 'oldBankCard' => $ep['bankCard'],
  104. 'oldBank' => $ep['bank'],
  105. 'oldBankNetwork' => $ep['bankNetwork'],
  106. 'newName' => htmlspecialchars($data['name']),
  107. 'newIdCard' => htmlspecialchars($data['idCard']),
  108. 'newIndustryFieldNew' => $data['industryFieldNew'],
  109. 'newIndustryFieldOld' => $data['industryFieldOld'],
  110. 'newStreet' => $data['street'],
  111. 'newAddress' => $data['address'],
  112. 'newLegal' => $data['legal'],
  113. 'newEphone' => $data['ephone'],
  114. 'newAgentName' => $data['agentName'],
  115. 'newAgentEmail' => $data['agentEmail'],
  116. 'newAgentPhone' => $data['agentPhone'],
  117. 'newEnterpriseTag' => $data['enterpriseTag'],
  118. 'newBankCard' => $data['bankCard'],
  119. 'newBank' => $data['bank'],
  120. 'newBankNetwork' => $data['bankNetwork'],
  121. 'checkState' => 1,
  122. 'createTime' => date("y-m-d H:i:s",time()),
  123. 'createUser' => session("user")["uid"]
  124. ];
  125. EnterpriseRecord::create($record_data);
  126. }
  127. $log = [
  128. 'type' => 10,
  129. 'active' => 1,
  130. 'state' => 1,
  131. 'step' => 100,
  132. 'stateChange' => '保存未提交',
  133. 'createTime' => date("y-m-d H:i:s",time()),
  134. 'createUser' => '用户'
  135. ];
  136. } catch (ValidateException $e){
  137. $error = $e->getError();
  138. return json(["msg" => array_pop($error)],500);
  139. }
  140. dd($this->request->post());
  141. }
  142. }