OfficialSealApply.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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 OfficialSealApply extends Model
  8. {
  9. public function advancedStartSealApply($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. ];
  19. $sealarr = [];
  20. $values = [];
  21. foreach ($formJson as $k=>$v){
  22. if($v['componentName'] == 'ddofficialsealfield'){
  23. foreach ($v['components'] as $key=>$val){
  24. switch ($val['idx']){
  25. case '0':
  26. $sealarr = isset($val['values'])?json_decode($val['values'],true):[];
  27. break;
  28. case '1':
  29. $data['nums'] = isset($val['values'])?$val['values']:0;
  30. break;
  31. case '2':
  32. $data['content'] = isset($val['values'])?$val['values']:0;
  33. break;
  34. case '3':
  35. $data['use_date'] = isset($val['values'])?$val['values']:null;
  36. break;
  37. }
  38. }
  39. break;
  40. }
  41. }
  42. $seals = [];
  43. foreach ($sealarr as $k=>$v){
  44. $seals[] = $v['id'];
  45. }
  46. $data['seals'] = implode(',',$seals);
  47. $ret = Db::name('official_seal_apply')->insert($data);
  48. return $ret?true:false;
  49. }
  50. public function advancedEndSealApply($id,$orgId,$userId,$formJson){
  51. $data = [
  52. 'update_time' => date('Y-m-d H:i:s'),
  53. 'status' => 1
  54. ];
  55. $ret = Db::name('official_seal_apply')->where('apply_id',$id)->update($data);
  56. return $ret?true:false;
  57. }
  58. public function advancedDisagreeSealApply($id){
  59. $data = [
  60. 'update_time' => date('Y-m-d H:i:s'),
  61. 'status' => 2
  62. ];
  63. $ret = Db::name('official_seal_apply')->where('apply_id',$id)->update($data);
  64. return $ret?true:false;
  65. }
  66. public function lists($page,$size,$orgId,$sealId,$dep){
  67. $map[] = ['status','=',1];
  68. $map[] = ['org_id','=',$orgId];
  69. if($dep){
  70. $depids = Db::name('dep')->where('name','like','%'.$dep.'%')->where('del',0)->column('id');
  71. if($depids){
  72. $map[] = ['dep_id','in',$depids];
  73. }
  74. }
  75. if($sealId > 0){
  76. $map[] = ['','exp',Db::raw("FIND_IN_SET(".$sealId.",seals)")];
  77. }
  78. $content = input('content','','trim');
  79. if($content){
  80. $map[] = ['content','like','%'.$content.'%'];
  81. }
  82. $lists = Db::name('official_seal_apply')
  83. ->where($map)
  84. ->page($page,$size)
  85. ->order('id desc')
  86. ->select();
  87. $lists = $lists?$lists:[];
  88. foreach ($lists as $k=>$v){
  89. $lists[$k]['userName'] = Db::name('user_info')->where('user_id',$v['user_id'])->value('name');
  90. $lists[$k]['depName'] = Db::name('dep')->where('id',$v['dep_id'])->value('name');
  91. $seals = Db::name('official_seal')->where('id','in',$v['seals'])->column('title');
  92. $lists[$k]['sealName'] = $seals?implode(',',$seals):'';
  93. }
  94. $total = Db::name('official_seal_apply')->where($map)->count();
  95. $data = [
  96. 'total' => $total,
  97. 'list' => $lists?$lists:[]
  98. ];
  99. return $data;
  100. }
  101. }