Commit 742fd4e0 authored by hezhen's avatar hezhen

修改会员分红

parent 251a2f56
......@@ -116,9 +116,4 @@ public class BaseUserMemberLevel implements Serializable {
@Transient
private BigDecimal showShareAmount;
public BigDecimal getShowShareAmount(){
return price.multiply(shareAmount).divide(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP);
}
}
......@@ -2,16 +2,23 @@ package com.github.wxiaoqi.security.admin.biz;
import com.ace.cache.annotation.Cache;
import com.ace.cache.annotation.CacheClear;
import com.alibaba.fastjson.JSONObject;
import com.github.wxiaoqi.security.admin.entity.BaseUserMemberLevel;
import com.github.wxiaoqi.security.admin.mapper.BaseUserMemberLevelMapper;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.xxfc.platform.app.entity.Cofig;
import com.xxfc.platform.app.feign.ConfigFeign;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import tk.mybatis.mapper.entity.Example;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
......@@ -24,6 +31,10 @@ import java.util.stream.Collectors;
public class UserMemberLevelBiz extends BaseBiz<BaseUserMemberLevelMapper,BaseUserMemberLevel> {
@Autowired
ConfigFeign configFeign;
@Transactional
@Cache(key="member")
public List<BaseUserMemberLevel> getLevesls() {
......@@ -42,7 +53,9 @@ public class UserMemberLevelBiz extends BaseBiz<BaseUserMemberLevelMapper,BaseUs
criteria.andEqualTo("isShow",baseUserMemberLevel.getIsShow());
}
example.setOrderByClause(" level asc ");
return mapper.selectByExample(example);
List<BaseUserMemberLevel> list = mapper.selectByExample(example);
setShowShareAmount(list);
return list;
}
public BaseUserMemberLevel getLevel(Integer level) {
......@@ -55,6 +68,28 @@ public class UserMemberLevelBiz extends BaseBiz<BaseUserMemberLevelMapper,BaseUs
return null;
}
public void setShowShareAmount(List<BaseUserMemberLevel> list){
if (list.size() > 0){
BigDecimal price = getConfigParam();
for (BaseUserMemberLevel memberLevel : list){
BigDecimal showShareAmount = price.multiply(memberLevel.getShareAmount()).divide(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP);
memberLevel.setShowShareAmount(showShareAmount);
}
}
}
public BigDecimal getConfigParam(){
ObjectRestResponse<List<Cofig>> restResponse = configFeign.getAllByType("77");
BigDecimal price = BigDecimal.ZERO;
if (restResponse.getData() != null ){
List<Cofig> cofigList = restResponse.getData();
JSONObject jsonObject = JSONObject.parseObject(cofigList.get(0).getParams());
price = jsonObject.getBigDecimal("price");
}
return price;
}
@Transactional(rollbackFor = Exception.class,propagation = Propagation.REQUIRED)
public Map<Integer, BaseUserMemberLevel> getUserMemberLevelAndUserMemberMapByLevels(List<Integer> levels){
List<BaseUserMemberLevel> baseUserMemberLevels = mapper.selectUserMembersLevelByLevels(levels);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment