瀏覽代碼

志愿者信息修改

LiRong 3 月之前
父節點
當前提交
80d8ca303c

+ 50 - 31
leromro-core/src/main/java/com/leromro/core/controller/VolunteerInfoController.java

@@ -10,6 +10,7 @@ import com.leromro.common.core.domain.R;
 import com.leromro.common.core.domain.entity.SysUser;
 import com.leromro.common.core.page.TableDataInfo;
 import com.leromro.common.utils.SecurityUtils;
+import com.leromro.core.domain.MainOrders;
 import com.leromro.core.domain.VolunteerFaceRecord;
 import com.leromro.core.domain.VolunteerInfo;
 import com.leromro.core.domain.dto.ConversationMsgDTO;
@@ -20,6 +21,7 @@ import com.leromro.core.domain.vo.VolunteerInfoVO;
 import com.leromro.core.service.IConversationRecordService;
 import com.leromro.core.service.IVolunteerFaceRecordService;
 import com.leromro.core.service.IVolunteerInfoService;
+import com.leromro.core.service.impl.MainOrderServiceImpl;
 import com.leromro.core.utils.SendSmsUtil;
 import com.leromro.framework.config.ConstantsConfig;
 import com.leromro.system.mapper.SysUserMapper;
@@ -37,6 +39,7 @@ import java.util.Objects;
 
 /**
  * 志愿者信息
+ *
  * @author lr
  * @since 2025-04-07
  */
@@ -52,51 +55,68 @@ public class VolunteerInfoController extends BaseController {
     @Autowired
     private IVolunteerFaceRecordService volunteerFaceRecordService;
 
+    @Autowired
+    private MainOrderServiceImpl mainOrderService;
+
     /**
      * 新增志愿者信息
      * 已测试
      */
-    @ApiOperation( value = "新增志愿者信息",notes = "传入路径参数 大分类,传入对象参数志愿者信息")
+    @ApiOperation(value = "新增志愿者信息", notes = "传入路径参数 大分类,传入对象参数志愿者信息")
     @PostMapping("/newVolunteerInfo/{serviceCategory}")
-    public AjaxResult newVolunteerInfoByuserId(@Valid  @RequestBody VolunteerInfoDTO dto, @PathVariable Long serviceCategory){
-        volunteerInfoService.newVolunteerInfoByuserId(dto,serviceCategory);
+    public AjaxResult newVolunteerInfoByuserId(@Valid @RequestBody VolunteerInfoDTO dto, @PathVariable Long serviceCategory) {
+        volunteerInfoService.newVolunteerInfoByuserId(dto, serviceCategory);
         return AjaxResult.success();
     }
+
     /**
      * 修改志愿者信息
      * 未测试
      */
-//    @ApiOperation(value = "修改志愿者信息" , notes = "传入志愿者修改后的对象")
-//    @PutMapping("/updateInfo")
-//    public AjaxResult updateVolunteerInfo(@RequestBody VolunteerInfoVO volunteerInfoVO){
-//        boolean b = volunteerInfoService.updateById(volunteerInfoVO);
-//        return AjaxResult.success();
-//    }
+    @ApiOperation(value = "修改志愿者信息", notes = "传入志愿者修改后的对象,记得也把volunteerInfoId也传过来")
+    @PutMapping("/updateInfo")
+    public R updateVolunteerInfo(@RequestBody VolunteerInfoDTO volunteerInfoDTO) {
+
+        return volunteerInfoService.updateVolunteerInfoById(volunteerInfoDTO);
+    }
+    /**
+     * 志愿者信息回显
+     * 已测试
+     */
+    @ApiOperation(value = "查看志愿者是否有订单", notes = "什么都不传,有订单会报错")
+    @GetMapping("/hadOrder")
+    public R selectVolunteerhasOrder(Long volunteerInfoId) {
+        List<MainOrders> list = mainOrderService.list(new LambdaQueryWrapper<MainOrders>().eq(MainOrders::getVolunteerInfoId, volunteerInfoId));
+        if (!list.isEmpty()){
+            return R.fail("该志愿者不可修改,志愿者已有订单");
+        }
+        return R.ok();
+    }
+
     /**
      * 志愿者信息回显
      * 已测试
      */
-    @ApiOperation(value = "志愿者信息回显" , notes = "传入大分类,返回大分类中志愿者已有信息")
+    @ApiOperation(value = "志愿者信息回显", notes = "传入大分类,返回大分类中志愿者已有信息")
     @GetMapping("/volunteerInfo")
-    public R<VolunteerInfo> selectVolunteerInfo(Long serviceCategory){
+    public R<VolunteerInfo> selectVolunteerInfo(Long serviceCategory) {
         Long userId = SecurityUtils.getUserId();
-        VolunteerInfo info = volunteerInfoService.selectByUserID(serviceCategory,userId);
-        return R.ok(info);
+        return volunteerInfoService.selectByUserID(serviceCategory, userId);
     }
+
     /**
      * 查询志愿者信息列表
      * 已测试
      */
-    @ApiOperation(value = "(后台)查询志愿者信息列表",notes = "传入进行分类的字段,根据分类字段查询,返回List 集合")
+    @ApiOperation(value = "(后台)查询志愿者信息列表", notes = "传入进行分类的字段,根据分类字段查询,返回List 集合")
     @ApiImplicitParams(value = {
             @ApiImplicitParam(name = "appStatus", value = "审批传1,管理传2", required = true)
     })
     @GetMapping("/web/list")
-    public TableDataInfo<VolunteerInfo> webList(VolunteerInfoDTO dto)
-    {
+    public TableDataInfo<VolunteerInfo> webList(VolunteerInfoDTO dto) {
         startPage();
         SysUser sysUser = sysUserMapper.selectUserById(SecurityUtils.getUserId());
-        if (Objects.equals(sysUser.getAreaType(), "4")){
+        if (Objects.equals(sysUser.getAreaType(), "4")) {
             //如果是服务中心,那就把服务中心id传进去,查的时候联查
             dto.setServiceCenterId(SecurityUtils.getDeptId());
         }
@@ -108,10 +128,9 @@ public class VolunteerInfoController extends BaseController {
      * 获取志愿者信息列表
      * 已测试
      */
-    @ApiOperation(value = "(小程序)查询志愿者信息列表",notes = "传入进行分类的字段,根据分类字段查询,返回List 集合")
-    @GetMapping ("/list")
-    public TableDataInfo<VolunteerInfoVO> list( VolunteerListDTO volunteerInfo)
-    {
+    @ApiOperation(value = "(小程序)查询志愿者信息列表", notes = "传入进行分类的字段,根据分类字段查询,返回List 集合")
+    @GetMapping("/list")
+    public TableDataInfo<VolunteerInfoVO> list(VolunteerListDTO volunteerInfo) {
         startPage();
         List<VolunteerInfoVO> list = volunteerInfoService.selectVolunteerInfoList(volunteerInfo);
         return getDataTable(list);
@@ -121,10 +140,9 @@ public class VolunteerInfoController extends BaseController {
      * 获取志愿者信息详细信息
      * 已测试
      */
-    @ApiOperation( value = "获取志愿者信息详细信息",notes = "传入志愿者id,以及分类的id, 返回志愿者的信息")
+    @ApiOperation(value = "获取志愿者信息详细信息", notes = "传入志愿者id,以及分类的id, 返回志愿者的信息")
     @PostMapping(value = "/getDetails")
-    public R<VolunteerInfoDetailVO> getInfo(@RequestBody VolunteerInfo volunteerInfo)
-    {
+    public R<VolunteerInfoDetailVO> getInfo(@RequestBody VolunteerInfo volunteerInfo) {
 
         return R.ok(volunteerInfoService.selectLVolunteerInfoByVolunteerId(volunteerInfo));
     }
@@ -132,28 +150,29 @@ public class VolunteerInfoController extends BaseController {
     /**
      * 志愿者审批
      */
-    @ApiOperation(value = "志愿者审批",notes = "传入当前行主键volunteerInfoId,审批状态appStatus:2通过,3拒绝,驳回原因rejectReason,状态为3则必填")
+    @ApiOperation(value = "志愿者审批", notes = "传入当前行主键volunteerInfoId,审批状态appStatus:2通过,3拒绝,驳回原因rejectReason,状态为3则必填")
     @PostMapping("/web/approval")
-    public AjaxResult approval(@RequestBody VolunteerInfo volunteerInfo){
-        if ("3".equals(volunteerInfo.getAppStatus()) && StrUtil.isBlank(volunteerInfo.getRejectReason())){
+    public AjaxResult approval(@RequestBody VolunteerInfo volunteerInfo) {
+        if ("3".equals(volunteerInfo.getAppStatus()) && StrUtil.isBlank(volunteerInfo.getRejectReason())) {
             return AjaxResult.warn("请填写驳回原因");
         }
         // 志愿者审批
         volunteerInfoService.approval(volunteerInfo);
         return AjaxResult.success();
     }
+
     @ApiOperation("小程序志愿者首页获取自己的头像(用于排班管理)")
     @GetMapping("/volunteerPicture")
-    public List<String> getVolunteerPicture(){
+    public List<String> getVolunteerPicture() {
         return volunteerInfoService.getVolunteerPicture(SecurityUtils.getUserId());
     }
 
     /**
      * 获取志愿者人脸核身状态
      */
-    @ApiOperation(value = "获取志愿者人脸核身状态",notes = "传入志愿者id,返回核身状态,如果为false,则提示志愿者先去人脸核身")
+    @ApiOperation(value = "获取志愿者人脸核身状态", notes = "传入志愿者id,返回核身状态,如果为false,则提示志愿者先去人脸核身")
     @GetMapping("/getFaceStatus")
-    public R<Boolean> getFaceStatus(Long volunteerInfoId){
+    public R<Boolean> getFaceStatus(Long volunteerInfoId) {
         return volunteerFaceRecordService.getFaceStatus(volunteerInfoId);
     }
 
@@ -162,7 +181,7 @@ public class VolunteerInfoController extends BaseController {
      */
     @ApiOperation(value = "新增志愿者人脸核身记录")
     @PostMapping("/addFaceRecord")
-    public R<Boolean> addFaceRecord(@RequestBody VolunteerFaceRecord volunteerFaceRecord){
+    public R<Boolean> addFaceRecord(@RequestBody VolunteerFaceRecord volunteerFaceRecord) {
         return volunteerFaceRecordService.addFaceRecord(volunteerFaceRecord);
     }
 

+ 4 - 1
leromro-core/src/main/java/com/leromro/core/service/IVolunteerInfoService.java

@@ -1,5 +1,6 @@
 package com.leromro.core.service;
 
+import com.leromro.common.core.domain.R;
 import com.leromro.common.core.domain.entity.SysUser;
 import com.leromro.core.domain.VolunteerInfo;
 import com.baomidou.mybatisplus.extension.service.IService;
@@ -23,7 +24,7 @@ public interface IVolunteerInfoService extends IService<VolunteerInfo> {
 
     void newVolunteerInfoByuserId(VolunteerInfoDTO dto,Long serviceCategory);
 
-    VolunteerInfo selectByUserID(Long serviceCategory, Long userId);
+    R<VolunteerInfo> selectByUserID(Long serviceCategory, Long userId);
 
     List<VolunteerInfo> webList(VolunteerInfoDTO dto);
 
@@ -43,4 +44,6 @@ public interface IVolunteerInfoService extends IService<VolunteerInfo> {
     List<VolunteerInfo> selectVolunteerGroupByUserId(SysUser sysUser);
 
     List<String> getVolunteerPicture(Long userId);
+
+    R updateVolunteerInfoById(VolunteerInfoDTO volunteerInfoDTO);
 }

+ 64 - 17
leromro-core/src/main/java/com/leromro/core/service/impl/VolunteerInfoServiceImpl.java

@@ -11,16 +11,14 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.leromro.common.constant.CommonConstants;
 import com.leromro.common.constant.SysConfigConstants;
 import com.leromro.common.core.domain.ListPermission;
+import com.leromro.common.core.domain.R;
 import com.leromro.common.core.domain.entity.SysUser;
 import com.leromro.common.core.redis.RedisCache;
 import com.leromro.common.enums.ConstantsKey;
 import com.leromro.common.enums.UserPointChangeTypeEnum;
 import com.leromro.common.exception.ServiceException;
 import com.leromro.common.utils.SecurityUtils;
-import com.leromro.core.domain.BusinessManagement;
-import com.leromro.core.domain.SecondOrder;
-import com.leromro.core.domain.UserPointChange;
-import com.leromro.core.domain.VolunteerInfo;
+import com.leromro.core.domain.*;
 import com.leromro.core.domain.dto.ConversationMsgDTO;
 import com.leromro.core.domain.dto.HomePageDTO;
 import com.leromro.core.domain.dto.VolunteerInfoDTO;
@@ -82,6 +80,9 @@ public class VolunteerInfoServiceImpl extends ServiceImpl<VolunteerInfoMapper, V
     @Autowired
     private IConversationRecordService conversationRecordService;
 
+    @Autowired
+    private MainOrderServiceImpl mainOrderService;
+
     /**
      * 新增志愿者信息
      * @param dto
@@ -107,18 +108,7 @@ public class VolunteerInfoServiceImpl extends ServiceImpl<VolunteerInfoMapper, V
         String[] businessTierName = businessManagement.getBusinessTierName().split("-");
         volunteerInfo.setProjectName(businessTierName[0]);
         String s = businessTierName[1];
-
         volunteerInfo.setProjectTypeName(s);
-      /*  switch(Integer.parseInt(String.valueOf(serviceCategory))) {
-            case 1:
-                break;
-            case 2:
-                volunteerInfo.setServiceSubjectName(businessTierName[2]);
-                break;
-            default:
-                throw new RuntimeException("当前服务项目层级名称错误");
-        }*/
-
         volunteerInfo.setVolunteerId(userId);
         volunteerInfo.setServiceCategory(serviceCategory);
         volunteerInfo.setCreateTime(DateTimeUtil.getNowTime());
@@ -158,10 +148,10 @@ public class VolunteerInfoServiceImpl extends ServiceImpl<VolunteerInfoMapper, V
      * @return
      */
     @Override
-    public VolunteerInfo selectByUserID(Long serviceCategory, Long userId) {
+    public R<VolunteerInfo> selectByUserID(Long serviceCategory, Long userId) {
         QueryWrapper<VolunteerInfo> wrapper = new QueryWrapper<>();
         wrapper.eq("volunteer_id",userId).eq("service_category",serviceCategory);
-        return volunteerInfoMapper.selectOne(wrapper);
+        return R.ok(volunteerInfoMapper.selectOne(wrapper));
     }
 
     /**     后台web页面志愿者列表
@@ -240,6 +230,63 @@ public class VolunteerInfoServiceImpl extends ServiceImpl<VolunteerInfoMapper, V
     public List<String> getVolunteerPicture(Long userId) {
         return volunteerInfoMapper.selectVolunteerPictureList(userId);
     }
+
+    /**
+     * @param volunteerInfoDTO
+     * @return
+     */
+    @Override
+    public R updateVolunteerInfoById(VolunteerInfoDTO volunteerInfoDTO) {
+        if (volunteerInfoDTO.getBusinessDuration()==null||volunteerInfoDTO.getBusinessDuration()<=0){
+            throw new RuntimeException("服务时长不能为空或者为“0”!");
+        }
+        if (volunteerInfoDTO.getMinQuantity()==null||volunteerInfoDTO.getMinQuantity()==0){
+            throw new RuntimeException("设置的最少购买数量不能小于0!");
+        }
+        VolunteerInfo volunteerInfo = BeanUtil.copyProperties(volunteerInfoDTO, VolunteerInfo.class);
+        Long userId = SecurityUtils.getUserId();
+        //查询业务管理信息
+        BusinessManagement businessManagement = businessManagementService.getOne(new LambdaQueryWrapper<BusinessManagement>()
+                .eq(BusinessManagement::getBusinessManagementId, volunteerInfo.getBusinessManagementId()));
+        if (StrUtil.isBlank(businessManagement.getBusinessTierName()) || businessManagement.getBusinessTierName().length() < 2){
+            throw new RuntimeException("当前服务项目层级名称错误");
+        }
+        //把BusinessTierName按照-分割 (后面再改)
+        String[] businessTierName = businessManagement.getBusinessTierName().split("-");
+        volunteerInfo.setProjectName(businessTierName[0]);
+        String s = businessTierName[1];
+        volunteerInfo.setProjectTypeName(s);
+        volunteerInfo.setVolunteerId(userId);
+        volunteerInfo.setServiceCategory(volunteerInfoDTO.getServiceCategory());
+        volunteerInfo.setCreateTime(DateTimeUtil.getNowTime());
+        volunteerInfo.setBusinessTierName(businessManagement.getBusinessTierName());
+        QueryWrapper<VolunteerInfo> wrapper = new QueryWrapper<>();
+        wrapper.eq("volunteer_id",userId).eq("service_category",volunteerInfoDTO.getServiceCategory()) .ne("volunteer_info_id", volunteerInfo.getVolunteerInfoId());;
+
+        Integer i = volunteerInfoMapper.selectCount(wrapper);
+        if(i>0){
+           return R.fail("此用户已有志愿者信息,不可重复创建,请前往修改");
+        }
+        if (ObjectUtil.isNull(volunteerInfo.getVolunteerInfoId())) {
+            //新增,则校验手机号
+            String redisCode = this.redisCache.getCacheObject(ConstantsKey.REDIS_PHONE_CODE.getKey() + "_" + volunteerInfo.getPhonenumber());
+            if (StrUtil.isBlank(redisCode)) {
+                throw new ServiceException("验证码已过期");
+            }
+            if (StrUtil.isBlank(volunteerInfoDTO.getCode())){
+                throw new ServiceException("验证码不能为空");
+            }
+            if (!redisCode.equals(volunteerInfoDTO.getCode())) {
+                throw new ServiceException("验证码错误");
+            }
+            this.save(volunteerInfo);
+        }else {
+            volunteerInfo.setAppStatus("1");
+            volunteerInfoMapper.updateById(volunteerInfo);
+        }        volunteerInfo.setAppStatus("1");
+        return R.ok();
+    }
+
     /**
      * 用户成为志愿者积分处理
      */