PostApply.php 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <?php
  2. namespace app\common\model;
  3. use app\hander\HelpHander;
  4. use think\Db;
  5. use think\Model;
  6. use think\response\Json;
  7. class PostApply extends Model
  8. {
  9. public function advancedStartPostApply($id,$orgId,$userId,$formJson,$extra){
  10. $formJson = json_decode($formJson,true);
  11. $data = [
  12. 'org_id' => $orgId,
  13. 'user_id' => $userId,
  14. 'apply_id' => $id,
  15. 'dep_id' => $extra['depId'],
  16. 'create_time' => date('Y-m-d H:i:s'),
  17. 'status' => 0,
  18. 'year' => date('Y')
  19. ];
  20. foreach ($formJson as $k=>$v){
  21. if($v['componentName'] == 'ddpostfield'){
  22. foreach ($v['components'] as $key=>$val){
  23. switch ($val['idx']){
  24. case '0':
  25. $values = isset($val['values'])?$val['values']:'';
  26. if($values == '发改基建' || $values == '发改基人'){
  27. $data['name'] = $values;
  28. $data['type'] = $values;
  29. }else{
  30. $val = explode('[',$values);
  31. $val2 = explode(']',$val[1]);
  32. $data['name'] = $values;
  33. $data['type'] = $val[0];
  34. $data['sn'] = $val2[0];
  35. }
  36. break;
  37. case '1':
  38. $data['send_date'] = isset($val['values'])?$val['values']:null;
  39. break;
  40. }
  41. }
  42. break;
  43. }
  44. }
  45. $ret = Db::name('post_apply')->insert($data);
  46. return $ret?true:false;
  47. }
  48. public function advancedEndPostApply($id,$orgId,$userId,$formJson){
  49. $data = [
  50. 'update_time' => date('Y-m-d H:i:s'),
  51. 'status' => 1
  52. ];
  53. $ret = Db::name('post_apply')->where('apply_id',$id)->update($data);
  54. return $ret?true:false;
  55. }
  56. public function advancedDisagreePostApply($id){
  57. $data = [
  58. 'update_time' => date('Y-m-d H:i:s'),
  59. 'status' => 2
  60. ];
  61. $ret = Db::name('post_apply')->where('apply_id',$id)->update($data);
  62. return $ret?true:false;
  63. }
  64. public function lists($page,$size,$type,$orgId){
  65. $map[] = ['status','=',1];
  66. $map[] = ['org_id','=',$orgId];
  67. if($type != ''){
  68. $map[] = ['type','=',$type];
  69. }
  70. $lists = Db::name('post_apply')
  71. ->where($map)
  72. ->page($page,$size)
  73. ->order('id desc')
  74. ->select();
  75. $lists = $lists?$lists:[];
  76. foreach ($lists as $k=>$v){
  77. $lists[$k]['userName'] = Db::name('user_info')->where('user_id',$v['user_id'])->value('name');
  78. $lists[$k]['depName'] = Db::name('dep')->where('id',$v['dep_id'])->value('name');
  79. }
  80. $total = Db::name('post_apply')->where($map)->count();
  81. $data = [
  82. 'total' => $total,
  83. 'list' => $lists?$lists:[]
  84. ];
  85. return $data;
  86. }
  87. }