123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- <?php
- namespace app\common\model;
- use app\hander\HelpHander;
- use think\Db;
- use think\Model;
- use think\response\Json;
- class OfficialSealApply extends Model
- {
- public function advancedStartSealApply($id,$orgId,$userId,$formJson,$extra){
- $formJson = json_decode($formJson,true);
- $data = [
- 'org_id' => $orgId,
- 'user_id' => $userId,
- 'apply_id' => $id,
- 'dep_id' => $extra['depId'],
- 'create_time' => date('Y-m-d H:i:s'),
- 'status' => 0,
- ];
- $sealarr = [];
- $values = [];
- foreach ($formJson as $k=>$v){
- if($v['componentName'] == 'ddofficialsealfield'){
- foreach ($v['components'] as $key=>$val){
- switch ($val['idx']){
- case '0':
- $sealarr = isset($val['values'])?json_decode($val['values'],true):[];
- break;
- case '1':
- $data['nums'] = isset($val['values'])?$val['values']:0;
- break;
- case '2':
- $data['content'] = isset($val['values'])?$val['values']:0;
- break;
- case '3':
- $data['use_date'] = isset($val['values'])?$val['values']:null;
- break;
- }
- }
- break;
- }
- }
- $seals = [];
- foreach ($sealarr as $k=>$v){
- $seals[] = $v['id'];
- }
- $data['seals'] = implode(',',$seals);
- $ret = Db::name('official_seal_apply')->insert($data);
- return $ret?true:false;
- }
- public function advancedEndSealApply($id,$orgId,$userId,$formJson){
- $data = [
- 'update_time' => date('Y-m-d H:i:s'),
- 'status' => 1
- ];
- $ret = Db::name('official_seal_apply')->where('apply_id',$id)->update($data);
- return $ret?true:false;
- }
- public function advancedDisagreeSealApply($id){
- $data = [
- 'update_time' => date('Y-m-d H:i:s'),
- 'status' => 2
- ];
- $ret = Db::name('official_seal_apply')->where('apply_id',$id)->update($data);
- return $ret?true:false;
- }
- public function lists($page,$size,$orgId,$sealId,$dep){
- $map[] = ['status','=',1];
- $map[] = ['org_id','=',$orgId];
- if($dep){
- $depids = Db::name('dep')->where('name','like','%'.$dep.'%')->where('del',0)->column('id');
- if($depids){
- $map[] = ['dep_id','in',$depids];
- }
- }
- if($sealId > 0){
- $map[] = ['','exp',Db::raw("FIND_IN_SET(".$sealId.",seals)")];
- }
- $content = input('content','','trim');
- if($content){
- $map[] = ['content','like','%'.$content.'%'];
- }
- $lists = Db::name('official_seal_apply')
- ->where($map)
- ->page($page,$size)
- ->order('id desc')
- ->select();
- $lists = $lists?$lists:[];
- foreach ($lists as $k=>$v){
- $lists[$k]['userName'] = Db::name('user_info')->where('user_id',$v['user_id'])->value('name');
- $lists[$k]['depName'] = Db::name('dep')->where('id',$v['dep_id'])->value('name');
- $seals = Db::name('official_seal')->where('id','in',$v['seals'])->column('title');
- $lists[$k]['sealName'] = $seals?implode(',',$seals):'';
- }
- $total = Db::name('official_seal_apply')->where($map)->count();
- $data = [
- 'total' => $total,
- 'list' => $lists?$lists:[]
- ];
- return $data;
- }
- }
|