1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- <?php
- namespace app\common\model;
- use app\hander\HelpHander;
- use think\Db;
- use think\Model;
- use think\response\Json;
- class PostApply extends Model
- {
- public function advancedStartPostApply($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,
- 'year' => date('Y')
- ];
- foreach ($formJson as $k=>$v){
- if($v['componentName'] == 'ddpostfield'){
- foreach ($v['components'] as $key=>$val){
- switch ($val['idx']){
- case '0':
- $values = isset($val['values'])?$val['values']:'';
- if($values == '发改基建' || $values == '发改基人'){
- $data['name'] = $values;
- $data['type'] = $values;
- }else{
- $val = explode('[',$values);
- $val2 = explode(']',$val[1]);
- $data['name'] = $values;
- $data['type'] = $val[0];
- $data['sn'] = $val2[0];
- }
- break;
- case '1':
- $data['send_date'] = isset($val['values'])?$val['values']:null;
- break;
- }
- }
- break;
- }
- }
- $ret = Db::name('post_apply')->insert($data);
- return $ret?true:false;
- }
- public function advancedEndPostApply($id,$orgId,$userId,$formJson){
- $data = [
- 'update_time' => date('Y-m-d H:i:s'),
- 'status' => 1
- ];
- $ret = Db::name('post_apply')->where('apply_id',$id)->update($data);
- return $ret?true:false;
- }
- public function advancedDisagreePostApply($id){
- $data = [
- 'update_time' => date('Y-m-d H:i:s'),
- 'status' => 2
- ];
- $ret = Db::name('post_apply')->where('apply_id',$id)->update($data);
- return $ret?true:false;
- }
- public function lists($page,$size,$type,$orgId){
- $map[] = ['status','=',1];
- $map[] = ['org_id','=',$orgId];
- if($type != ''){
- $map[] = ['type','=',$type];
- }
- $lists = Db::name('post_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');
- }
- $total = Db::name('post_apply')->where($map)->count();
- $data = [
- 'total' => $total,
- 'list' => $lists?$lists:[]
- ];
- return $data;
- }
- }
|