mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-05-06 19:10:20 +08:00
update 添加会员接口
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user