|
@@ -4,12 +4,16 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.fuint.common.service.CommissionRelationService;
|
|
|
+import com.fuint.common.service.MemberService;
|
|
|
+import com.fuint.common.util.CommonUtil;
|
|
|
import com.fuint.framework.exception.BusinessCheckException;
|
|
|
import com.fuint.framework.pagination.PaginationRequest;
|
|
|
import com.fuint.framework.pagination.PaginationResponse;
|
|
|
import com.fuint.repository.mapper.MtCommissionRelationMapper;
|
|
|
import com.fuint.common.enums.StatusEnum;
|
|
|
import com.fuint.repository.model.MtCommissionRelation;
|
|
|
+import com.fuint.repository.model.MtUser;
|
|
|
+import com.fuint.utils.StringUtil;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
@@ -35,6 +39,11 @@ public class CommissionRelationServiceImpl extends ServiceImpl<MtCommissionRelat
|
|
|
|
|
|
private MtCommissionRelationMapper mtCommissionRelationMapper;
|
|
|
|
|
|
+ /**
|
|
|
+ * 会员服务接口
|
|
|
+ */
|
|
|
+ private MemberService memberService;
|
|
|
+
|
|
|
/**
|
|
|
* 分页查询关系列表
|
|
|
*
|
|
@@ -79,13 +88,58 @@ public class CommissionRelationServiceImpl extends ServiceImpl<MtCommissionRelat
|
|
|
/**
|
|
|
* 设置分销提成关系
|
|
|
*
|
|
|
- * @param userId 会员ID
|
|
|
+ * @param userInfo 会员信息
|
|
|
* @param shareId 分享者ID
|
|
|
* @throws BusinessCheckException
|
|
|
* @retrurn
|
|
|
*/
|
|
|
@Override
|
|
|
- public void setCommissionRelation(Integer userId, String shareId) {
|
|
|
+ public void setCommissionRelation(MtUser userInfo, String shareId) throws BusinessCheckException {
|
|
|
+ if (userInfo == null || StringUtil.isEmpty(shareId) || Integer.parseInt(shareId) <= 0) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ MtUser shareUserInfo = memberService.queryMemberById(Integer.parseInt(shareId));
|
|
|
+ if (shareUserInfo == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String, Object> param = new HashMap();
|
|
|
+ param.put("USER_ID", Integer.parseInt(shareId));
|
|
|
+ param.put("SUB_USER_ID", userInfo.getId());
|
|
|
+ param.put("STATUS", StatusEnum.ENABLED.getKey());
|
|
|
+ List<MtCommissionRelation> dataList = mtCommissionRelationMapper.selectByMap(param);
|
|
|
+ if (dataList == null || dataList.size() <= 0) {
|
|
|
+ MtCommissionRelation mtCommissionRelation = new MtCommissionRelation();
|
|
|
+ mtCommissionRelation.setCreateTime(new Date());
|
|
|
+ mtCommissionRelation.setUpdateTime(new Date());
|
|
|
+ mtCommissionRelation.setStatus(StatusEnum.ENABLED.getKey());
|
|
|
+ mtCommissionRelation.setUserId(Integer.parseInt(shareId));
|
|
|
+ mtCommissionRelation.setSubUserId(userInfo.getId());
|
|
|
+ mtCommissionRelation.setMerchantId(userInfo.getMerchantId());
|
|
|
+ mtCommissionRelation.setInviteCode(shareUserInfo.getUserNo());
|
|
|
+ mtCommissionRelation.setLevel(1);
|
|
|
+ mtCommissionRelationMapper.insert(mtCommissionRelation);
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String, Object> params = new HashMap();
|
|
|
+ params.put("SUB_USER_ID", Integer.parseInt(shareId));
|
|
|
+ params.put("LEVEL", 1);
|
|
|
+ params.put("STATUS", StatusEnum.ENABLED.getKey());
|
|
|
+ List<MtCommissionRelation> data = mtCommissionRelationMapper.selectByMap(params);
|
|
|
+ if (data != null && data.size() > 0) {
|
|
|
+ MtCommissionRelation mtCommissionRelation = new MtCommissionRelation();
|
|
|
+ mtCommissionRelation.setCreateTime(new Date());
|
|
|
+ mtCommissionRelation.setUpdateTime(new Date());
|
|
|
+ mtCommissionRelation.setStatus(StatusEnum.ENABLED.getKey());
|
|
|
+ mtCommissionRelation.setUserId(data.get(0).getUserId());
|
|
|
+ mtCommissionRelation.setSubUserId(userInfo.getId());
|
|
|
+ mtCommissionRelation.setMerchantId(userInfo.getMerchantId());
|
|
|
+ mtCommissionRelation.setInviteCode(data.get(0).getInviteCode());
|
|
|
+ mtCommissionRelation.setLevel(2);
|
|
|
+ mtCommissionRelationMapper.insert(mtCommissionRelation);
|
|
|
+ }
|
|
|
+
|
|
|
return;
|
|
|
}
|
|
|
}
|