|
|
@@ -11,6 +11,8 @@
|
|
|
|
|
|
namespace App\Services;
|
|
|
|
|
|
+use App\Models\MemberModel;
|
|
|
+use App\Models\SiyuanModel;
|
|
|
use App\Models\YigongModel;
|
|
|
|
|
|
/**
|
|
|
@@ -69,7 +71,7 @@ class YigongService extends BaseService
|
|
|
}
|
|
|
|
|
|
})
|
|
|
- ->select(['y.id', 'y.siyuan_id','y.user_id','s.title as siyuan', 'm.nickname', 'y.realname', 'y.on_siyuan', 'm.avatar', 'y.status', 'y.create_time', 'y.update_time', 'y.description', 'y.sort'])
|
|
|
+ ->select(['y.id', 'y.siyuan_id','y.user_id','s.title as siyuan', 'm.nickname', 'y.realname', 'y.on_siyuan', 'm.avatar', 'y.status', 'y.create_time', 'y.update_time','y.reason', 'y.description', 'y.sort'])
|
|
|
->orderBy('y.update_time', 'desc')
|
|
|
->paginate($pageSize);
|
|
|
|
|
|
@@ -101,21 +103,74 @@ class YigongService extends BaseService
|
|
|
{
|
|
|
$data = request()->all();
|
|
|
|
|
|
- // 图片处理
|
|
|
- $image = trim($data['thumb']);
|
|
|
- $id = isset($data['id']) ? $data['id'] : 0;
|
|
|
- if (!$id && !$image) {
|
|
|
- return message('请上传文章图片', false);
|
|
|
- }
|
|
|
- if (strpos($image, "temp")) {
|
|
|
- $data['thumb'] = save_image($image, 'item');
|
|
|
- } else {
|
|
|
- $data['thumb'] = str_replace(IMG_URL, "", $data['thumb']);
|
|
|
- }
|
|
|
-
|
|
|
$data['update_time'] = time();
|
|
|
$data['publish_at'] = isset($data['publish_at']) && $data['publish_at']? $data['publish_at'] : date('Y-m-d H:i:s');
|
|
|
return parent::edit($data); // TODO: Change the autogenerated stub
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 申请成为义工
|
|
|
+ * @param $userId
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public function apply($userId){
|
|
|
+ $params = request()->all();
|
|
|
+ $siyuanId = isset($params['siyuan_id'])? $params['siyuan_id'] : 0;
|
|
|
+ $siyuanInfo = SiyuanModel::where(['id'=> $siyuanId,'mark'=> 1,'status'=> 1])
|
|
|
+ ->select(['id','title','status'])
|
|
|
+ ->first();
|
|
|
+ if(!$siyuanInfo){
|
|
|
+ return message('所选寺院不存在', false);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 验证账户
|
|
|
+ $memberInfo = MemberModel::where(['id'=> $userId,'mark'=> 1,'status'=> 1])
|
|
|
+ ->select(['id','nickname','status'])
|
|
|
+ ->first();
|
|
|
+ if(!$memberInfo){
|
|
|
+ return message('当前账号无权操作或已冻结,请联系客服', false);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 验证是否已申请
|
|
|
+ $info = $this->model::where(['user_id'=> $userId,'siyuan_id'=> $siyuanId])
|
|
|
+ ->select(['id','user_id','mark','status'])
|
|
|
+ ->first();
|
|
|
+ if($info && $info->mark==1 && $info->status == 1){
|
|
|
+ return message('您已提交申请,请耐心等候审核', false);
|
|
|
+ }else if($info && $info->mark==1 && $info->status == 2){
|
|
|
+ return message('您的申请已通过,请不要重复提交', false);
|
|
|
+ }
|
|
|
+
|
|
|
+ if($info){
|
|
|
+ $info->realname = isset($params['realname'])? trim($params['realname']) : '';
|
|
|
+ $info->phone = isset($params['phone'])? trim($params['phone']) : '';
|
|
|
+ $info->idcard = isset($params['idcard'])? trim($params['idcard']) : '';
|
|
|
+ $info->description = isset($params['description'])? trim($params['description']) : '';
|
|
|
+ $info->reason = '';
|
|
|
+ $info->create_time = time();
|
|
|
+ $info->mark = 1;
|
|
|
+ $info->status = 1;
|
|
|
+
|
|
|
+ if($info->save()){
|
|
|
+ return message('您的申请已重新提交,请耐心等候审核', true);
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ $data = [
|
|
|
+ 'siyuan_id'=> $siyuanId,
|
|
|
+ 'user_id'=> $userId,
|
|
|
+ 'realname'=> isset($params['realname'])? trim($params['realname']) : '',
|
|
|
+ 'phone'=> isset($params['phone'])? trim($params['phone']) : '',
|
|
|
+ 'idcard'=> isset($params['idcard'])? trim($params['idcard']) : '',
|
|
|
+ 'description'=> isset($params['description'])? trim($params['description']) : '',
|
|
|
+ 'create_time'=> time(),
|
|
|
+ 'status'=> 1,
|
|
|
+ ];
|
|
|
+ if($this->model::insertGetId($data)){
|
|
|
+ return message('您的申请已提交,请耐心等候审核', true);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return message('操作失败,请刷新页面后重试', false);
|
|
|
+ }
|
|
|
+
|
|
|
}
|