update 添加会员接口

This commit is contained in:
Guoqs
2025-04-22 14:11:05 +08:00
parent 144526338d
commit 66a5790d1e
2 changed files with 20 additions and 6 deletions

View File

@@ -1,6 +1,5 @@
package com.jsowell.web.controller.pile;
import com.alibaba.fastjson2.JSON;
import com.jsowell.common.annotation.Log;
import com.jsowell.common.core.controller.BaseController;
import com.jsowell.common.core.domain.AjaxResult;
@@ -12,7 +11,6 @@ import com.jsowell.pile.domain.MemberGroup;
import com.jsowell.pile.dto.MemberGroupDTO;
import com.jsowell.pile.service.MemberGroupService;
import com.jsowell.pile.util.UserUtils;
import com.jsowell.pile.vo.base.LoginUserDetailVO;
import com.jsowell.pile.vo.base.MerchantInfoVO;
import com.jsowell.pile.vo.web.MemberGroupVO;
import org.springframework.beans.factory.annotation.Autowired;
@@ -122,7 +120,20 @@ public class MemberGroupController extends BaseController {
*/
@PostMapping("/addMember")
public AjaxResult addMember(@RequestBody MemberGroupDTO dto) {
return toAjax(memberGroupService.addMember(dto));
AjaxResult ajaxResult;
try {
int i = memberGroupService.addMember(dto);
if (i > 0) {
ajaxResult = AjaxResult.success();
} else {
ajaxResult = AjaxResult.error();
}
} catch (BusinessException e) {
ajaxResult = AjaxResult.error(e.getMessage());
} catch (Exception e) {
ajaxResult = AjaxResult.error("添加会员失败");
}
return ajaxResult;
}
/**

View File

@@ -220,18 +220,21 @@ public class MemberGroupServiceImpl implements MemberGroupService {
public int addMember(MemberGroupDTO dto) {
String groupCode = dto.getGroupCode();
if (StringUtils.isBlank(groupCode)) {
return 0;
// return 0;
throw new BusinessException("", "集团编号不能为空");
}
// 校验会员组是否存在
MemberGroup memberGroup = selectByGroupCode(groupCode);
if (memberGroup == null) {
return 0;
// return 0;
throw new BusinessException("", "该集团不存在");
}
// 查询会员id
String firstLevelMerchantId = pileMerchantInfoService.getFirstLevelMerchantIdByMerchantId(memberGroup.getMerchantId());
MemberBasicInfo memberBasicInfo = memberBasicInfoService.selectInfoByMobileNumber(dto.getPhoneNumber(), firstLevelMerchantId);
if (memberBasicInfo == null) {
return 0;
// return 0;
throw new BusinessException("", "该手机号未注册会员");
}
// 查询是否保存过
MemberGroupVO groupVO = memberGroupMapper.queryByGroupCodeAndMemberId(groupCode, memberBasicInfo.getMemberId());