__('Isrec 0'), '1' => __('Isrec 1')]; } public function getStatusList() { return ['-1' => __('Status -1'), '0' => __('Status 0'), '1' => __('Status 1'), '2' => __('Status 2'), '3' => __('Status 3'), '4' => __('Status 4')]; } public function getIsrecTextAttr($value, $data) { $value = $value ? $value : (isset($data['isrec']) ? $data['isrec'] : ''); $list = $this->getIsrecList(); return isset($list[$value]) ? $list[$value] : ''; } public function getStatusTextAttr($value, $data) { $value = $value ? $value : (isset($data['status']) ? $data['status'] : ''); $list = $this->getStatusList(); return isset($list[$value]) ? $list[$value] : ''; } public static function help_create($where) { self::beginTrans(); try { $res = self::create($where); $where['help_id'] = $res['id']; $res1 = HelpExt::create($where); foreach ($where['family'] as $v) { $v['cid'] = $where['cid']; $v['help_id'] = $res['id']; if(isset($v['full_name']) && isset($v['relation'])) { HelpFamily::create($v); } } self::commitTrans(); return $res; }catch (Exception $e) { self::setErrorInfo($e->getMessage(),true); } } public static function lst($where) { $model = new self; if(isset($where['cid']) && $where['cid']>0) $model->where('cid',$where['cid']); if(isset($where['user_id']) && $where['user_id']>0) $model->where('user_id',$where['user_id']); if(isset($where['category_id']) && $where['category_id']>0) $model->where('category_id',$where['category_id']); if(isset($where['status']) && $where['status']>-2) $model->where('status',$where['status']); if(isset($where['is_rec']) && $where['is_rec']==1) $model->where('is_rec',$where['is_rec']); $data = $model->order('id desc')->page($where['page'],$where['limit'])->select(); foreach ($data as &$v) { $v['is_apply'] = HelpApply::where('help_id',$v['id'])->where('user_id',$where['user_id_1'])->find(); $v['apply_sum'] = HelpApply::where('help_id',$v['id'])->value('count(id)')?:0; $v['category'] = Category::where('id',$v['category_id'])->value('name'); if($v['apply_user_id']>0) { $v['apply_user'] = HelpApply::where('help_id',$v['id'])->where('user_id',$v['apply_user_id'])->find(); } else { $v['apply_user'] = null; } } return $data; } public static function info($cid,$id,$user_id=0) { $info = self::where('cid',$cid)->where('id',$id)->find(); if(!$info)return self::setErrorInfo('非法数据'); $info['ext'] = HelpExt::where('help_id',$info['id'])->find(); $info['family'] = HelpFamily::where('help_id',$info['id'])->select(); $info['lave'] = Lave::lst(['cid'=>$cid,'paid'=>1,'help_id'=>$info['id'],'page'=>1,'limit'=>99999]); $info['sum_lave'] = Lave::where(['cid'=>$cid,'paid'=>1,'help_id'=>$id])->sum('amount'); $info['is_apply'] = HelpApply::where('help_id',$info['id'])->where('user_id',$user_id)->find(); $info['apply_sum'] = HelpApply::where('help_id',$info['id'])->value('count(id)')?:0; $info['category'] = Category::where('id',$info['category_id'])->value('name'); return $info; } }