mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-26 14:05:04 +08:00
update会员计费模板
This commit is contained in:
@@ -2,6 +2,7 @@ package com.jsowell.pile.service.impl;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.jsowell.common.enums.DelFlagEnum;
|
||||
import com.jsowell.common.exception.BusinessException;
|
||||
import com.jsowell.common.util.DateUtils;
|
||||
import com.jsowell.common.util.SecurityUtils;
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
@@ -90,6 +91,11 @@ public class MemberGroupServiceImpl implements MemberGroupService {
|
||||
*/
|
||||
@Override
|
||||
public int insertMemberGroup(MemberGroup memberGroup) {
|
||||
String merchantId = memberGroup.getMerchantId();
|
||||
MemberGroupVO memberGroupVO = queryByMerchantId(merchantId);
|
||||
if (memberGroupVO != null) {
|
||||
throw new BusinessException("", "该运营商已经创建过集团");
|
||||
}
|
||||
// 生成编号
|
||||
memberGroup.setGroupCode(generateGroupCode());
|
||||
memberGroup.setCreateTime(DateUtils.getNowDate());
|
||||
@@ -107,14 +113,14 @@ public class MemberGroupServiceImpl implements MemberGroupService {
|
||||
return memberGroupMapper.insertMemberGroup(memberGroup);
|
||||
}
|
||||
|
||||
private boolean isBetween(BigDecimal price){
|
||||
private boolean isBetween(BigDecimal price) {
|
||||
BigDecimal start = BigDecimal.ZERO;
|
||||
BigDecimal end = BigDecimal.TEN;
|
||||
return isBetween(price, start, end);
|
||||
}
|
||||
|
||||
private boolean isBetween(BigDecimal price, BigDecimal start, BigDecimal end){
|
||||
return price.compareTo(start) > 0 && price.compareTo(end) < 0;
|
||||
private boolean isBetween(BigDecimal source, BigDecimal start, BigDecimal end) {
|
||||
return source.compareTo(start) > 0 && source.compareTo(end) < 0;
|
||||
}
|
||||
|
||||
// 生成编号
|
||||
@@ -131,6 +137,7 @@ public class MemberGroupServiceImpl implements MemberGroupService {
|
||||
|
||||
/**
|
||||
* 根据会员组编号查询
|
||||
*
|
||||
* @param groupCode
|
||||
* @return
|
||||
*/
|
||||
@@ -181,6 +188,11 @@ public class MemberGroupServiceImpl implements MemberGroupService {
|
||||
return MemberDiscountVO;
|
||||
}
|
||||
|
||||
/**
|
||||
* 后管保存集团会员关系
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public int addMember(MemberGroupDTO dto) {
|
||||
String groupCode = dto.getGroupCode();
|
||||
@@ -193,15 +205,51 @@ public class MemberGroupServiceImpl implements MemberGroupService {
|
||||
return 0;
|
||||
}
|
||||
// 查询会员id
|
||||
String phoneNumber = dto.getPhoneNumber();
|
||||
String firstLevelMerchantId = pileMerchantInfoService.getFirstLevelMerchantIdByMerchantId(memberGroup.getMerchantId());
|
||||
MemberBasicInfo memberBasicInfo = memberBasicInfoService.selectInfoByMobileNumber(phoneNumber, firstLevelMerchantId);
|
||||
MemberBasicInfo memberBasicInfo = memberBasicInfoService.selectInfoByMobileNumber(dto.getPhoneNumber(), firstLevelMerchantId);
|
||||
if (memberBasicInfo == null) {
|
||||
return 0;
|
||||
}
|
||||
// 校验通过,关系存入数据库
|
||||
return saveMemberGroupRelation(memberBasicInfo.getMemberId(), groupCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单保存集团会员关系
|
||||
* @param memberId 会员id
|
||||
* @param merchantId 运营商id
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public int addMember2MemberGroup(String memberId, String merchantId) {
|
||||
log.info("添加会员id:{}, 到运营商:{}的集团中", memberId, merchantId);
|
||||
// 查询该站点有没有集团信息
|
||||
MemberGroupVO memberGroupVO = queryByMerchantId(merchantId);
|
||||
if (memberGroupVO == null) {
|
||||
return 0;
|
||||
}
|
||||
// 检查memberId是否在集团中
|
||||
MemberDiscountVO vo = memberGroupMapper.queryMemberDiscountV2(memberGroupVO.getGroupCode(), memberId);
|
||||
if (vo == null) {
|
||||
// 校验通过,关系存入数据库 加入到集团
|
||||
return saveMemberGroupRelation(memberId, memberGroupVO.getGroupCode());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 会员与集团的关系保存到数据库
|
||||
* @param memberId 会员id
|
||||
* @param groupCode 集团编号
|
||||
* @return
|
||||
*/
|
||||
private int saveMemberGroupRelation(String memberId, String groupCode) {
|
||||
if (StringUtils.isBlank(memberId) || StringUtils.isBlank(groupCode)) {
|
||||
return 0;
|
||||
}
|
||||
// 校验通过,关系存入数据库 加入到集团
|
||||
MemberGroupRelation relation = new MemberGroupRelation();
|
||||
relation.setMemberId(memberBasicInfo.getMemberId());
|
||||
relation.setMemberId(memberId);
|
||||
relation.setGroupCode(groupCode);
|
||||
relation.setCreateTime(DateUtils.getNowDate());
|
||||
relation.setDelFlag(DelFlagEnum.NORMAL.getValue());
|
||||
@@ -214,4 +262,14 @@ public class MemberGroupServiceImpl implements MemberGroupService {
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MemberGroupVO queryByMerchantId(String merchantId) {
|
||||
return memberGroupMapper.queryByMerchantId(merchantId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MemberGroupVO queryByStationId(String stationId) {
|
||||
return memberGroupMapper.queryByStationId(stationId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user