福豆分成显示修改 专项划拨任务

This commit is contained in:
Administrator 2020-09-22 17:57:34 +08:00
parent 6790bf68c6
commit fd35edd27d
10 changed files with 172 additions and 31 deletions

View File

@ -148,14 +148,17 @@ public class BizMemberController extends BaseController
//取出团队盒数等级配置
List<SysDictData> levels = DictUtils.getDictCache("busi_teamaward_level");
int numLimit = Integer.parseInt(DictUtils.getDictLabel("busi_award_set", "1"));
long teamDou = getTeamDou(teamNum, levels, numLimit);
//归总直属下级盒数
List<Map> list = (List<Map>) temp.get(memberID);
for (Map item : list) {
Long id = (Long) item.get("id");
long num = ((BigDecimal) item.get("num")).longValue();
item.put("totalNum", num);
long totalNum = getTeamNum((List<Map>) temp.get(id), item);
item.put("desc", getTeamDesc(totalNum, levels, numLimit));
if (list != null) {
for (Map item : list) {
Long id = (Long) item.get("id");
long num = ((BigDecimal) item.get("num")).longValue();
item.put("totalNum", num);
getTeamNum((List<Map>) temp.get(id), item);
item.put("desc", getTeamDesc((Long) item.get("totalNum"), levels, numLimit, teamDou));
}
}
Map resultMap = new HashMap();
resultMap.put("teamNum", teamNum);
@ -164,9 +167,9 @@ public class BizMemberController extends BaseController
}
//取出子级团队盒数
private long getTeamNum(List<Map> chList, Map parent)
private void getTeamNum(List<Map> chList, Map parent)
{
if (chList == null) return 0;
if (chList == null) return;
for (Map item : chList) {
long num = ((BigDecimal) item.get("num")).longValue();
long totalNum = (Long) parent.get("totalNum");
@ -176,13 +179,12 @@ public class BizMemberController extends BaseController
getTeamNum(children, parent);
}
}
return (Long) parent.get("totalNum");
}
//出团队盒数说明
private String getTeamDesc(long totalNum, List<SysDictData> levels, int numLimit)
//得当前团队盒数对应分成
private long getTeamDou(long totalNum, List<SysDictData> levels, int numLimit)
{
if (totalNum <= numLimit) return "[团队盒数" + totalNum + " 无分成]";
if (totalNum <= numLimit) return 0L;
for (SysDictData data : levels) {
String label = data.getDictLabel();
long dou = Long.parseLong(data.getDictValue());
@ -190,10 +192,20 @@ public class BizMemberController extends BaseController
long begin = Long.parseLong(split[0]);
long end = Long.parseLong(split[1]);
if (totalNum >= begin && totalNum <= end) {
return "[团队盒数" + totalNum + " 分成" + dou + "福豆]";
return dou;
}
}
return "";
return 0L;
}
//取出团队盒数说明
private String getTeamDesc(long totalNum, List<SysDictData> levels, int numLimit, long teamDou)
{
long dou = getTeamDou(totalNum, levels, numLimit);
if (teamDou == 0) {
return "[团队盒数" + totalNum + " 无分成]";
}
return "[团队盒数" + totalNum + " 分成" + teamDou + "-" + dou + "=" + (teamDou - dou) + "福豆]";
}
/**

View File

@ -46,6 +46,9 @@ public class BizMember extends BaseEntity
@Excel(name = "会员类型")
private Integer memberType;
/** 专项返还等级0-出局1-第一次 */
private Integer specialLevel;
/** 是否删除0-否1-是 */
private Integer isDelete;
@ -150,7 +153,16 @@ public class BizMember extends BaseEntity
{
return memberType;
}
public void setIsDelete(Integer isDelete)
public Integer getSpecialLevel() {
return specialLevel;
}
public void setSpecialLevel(Integer specialLevel) {
this.specialLevel = specialLevel;
}
public void setIsDelete(Integer isDelete)
{
this.isDelete = isDelete;
}

View File

@ -100,4 +100,28 @@ public interface BizMemberMapper
* @return 结果
*/
public List<Map> selectTeamData(Map paramMap);
/**
* 查询专项划拨任务会员列表
*
* @param minValue 专项划拨每日金额
* @return 会员集合
*/
public List<BizMember> selectSpecialMember(int minValue);
/**
* 取出某用户团队盒数
*
* @param memberID 上级用户ID
* @return 结果
*/
public long getMemberTeamCount(Long memberID);
/**
* 修改会员出局等级
*
* @param bizMember 会员
* @return 结果
*/
public int updateMemberLevel(BizMember bizMember);
}

View File

@ -99,4 +99,12 @@ public interface IBizMemberService
* @return 结果
*/
public List<Map> selectTeamData(Map paramMap);
/**
* 执行专项划拨每日任务
*
* @param
* @return 结果
*/
public int doSpecialTask();
}

View File

@ -11,12 +11,14 @@ import com.ruoyi.business.domain.BizAccountDetail;
import com.ruoyi.business.mapper.BizAccountMapper;
import com.ruoyi.business.service.IBizAccountService;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.system.utils.DictUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.business.mapper.BizMemberMapper;
import com.ruoyi.business.domain.BizMember;
import com.ruoyi.business.service.IBizMemberService;
import com.ruoyi.common.core.text.Convert;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
@ -205,4 +207,50 @@ public class BizMemberServiceImpl implements IBizMemberService
{
return bizMemberMapper.selectTeamData(paramMap);
}
/**
* 执行专项划拨每日任务
*
* @param
* @return 结果
*/
@Override
@Transactional
public int doSpecialTask()
{
//划拨金额
int dailyAmount = Integer.parseInt(DictUtils.getDictLabel("busi_award_set", "2"));
//出局次数
int maxLevel = Integer.parseInt(DictUtils.getDictLabel("busi_award_set", "5"));
//团队盒数标准
int teamCountLimit = Integer.parseInt(DictUtils.getDictLabel("busi_award_set", "3"));
List<BizMember> memberList = bizMemberMapper.selectSpecialMember(dailyAmount);
int accessCount = 0;
for (BizMember member : memberList) {
Long memberID = member.getId();
Long douSpecial = member.getDouSpecial();
//先扣款
boolean result = bizAccountService.accountChange(memberID, BizAccount.DOU_SPECIAL, BizAccountDetail.DOU_DETAIL_TYPE_EXCHANGE, (long) -dailyAmount, "", BizAccountDetail.DOU_DESC_SPECIAL2);
if (result) {
//加入个人账户
result = bizAccountService.accountChange(memberID, BizAccount.DOU_PERSON, BizAccountDetail.DOU_DETAIL_TYPE_CHARGE, (long) dailyAmount, "", BizAccountDetail.DOU_DESC_SPECIAL2);
if (result) {
accessCount ++;
if (douSpecial <= dailyAmount) {
//已经划拨完余额为0,更新用户出局情况
long teamCount = bizMemberMapper.getMemberTeamCount(memberID);
int specialLevel = member.getSpecialLevel();
if (teamCount < teamCountLimit) { //团队盒数不足设定值盒则更新level
//达到最大等级则出局
specialLevel = specialLevel == maxLevel ? 0 : (specialLevel + 1);
member.setSpecialLevel(specialLevel);
bizMemberMapper.updateMemberLevel(member);
}
}
}
}
}
return accessCount;
}
}

View File

@ -171,8 +171,17 @@ public class BizOrderServiceImpl implements IBizOrderService
if (douBalance < orderTotal.longValue()) {
return AjaxResult.error("福豆余额不足");
}
BigDecimal cashbackAmount = product.getCashbackAmount().multiply(new BigDecimal(productNum));
//TODO cashbackAmount 专项划拨金额等级判断
//判断专项划拨相关金额
int decreaseAmount = Integer.parseInt(DictUtils.getDictLabel("busi_award_set", "4"));
BigDecimal cashbackAmount = product.getCashbackAmount();
boolean isTeam = cashbackAmount.longValue() > 0;
Integer specialLevel = member.getSpecialLevel();
BigDecimal cashbackTotalAmount = new BigDecimal(0);
if (specialLevel != null && specialLevel > 0) { //未出局
//重新计算专项金额
cashbackAmount = cashbackAmount.add(new BigDecimal((specialLevel - 1) * decreaseAmount));
cashbackTotalAmount = cashbackAmount.multiply(new BigDecimal(productNum));
}
//判断地址
BizMemberAddress address = bizMemberAddressMapper.selectBizMemberAddressById(addressID);
@ -188,7 +197,7 @@ public class BizOrderServiceImpl implements IBizOrderService
order.setMemberName(member.getMemberName());
order.setOrderAmount(orderTotal);
order.setOrderStatus(BizOrder.STATUS_PAYED); //已支付
order.setIsTeam(cashbackAmount.longValue() > 0 ? 1 : 0); //是否团队福豆影响订单
order.setIsTeam(isTeam ? 1 : 0); //是否团队福豆影响订单
order.setRemark(remark);
order.setAddressDetail(address.getAddress());
order.setAddressId(addressID);
@ -205,17 +214,17 @@ public class BizOrderServiceImpl implements IBizOrderService
String businessCode = String.valueOf(order.getOrderSn());
//减去福豆余额账户
// TODO 类型不对同步完数据后在修改
boolean result = bizAccountService.accountChange(memberID, BizAccount.DOU_BALANCE, BizAccountDetail.DOU_DETAIL_TYPE_ORDER, -orderTotal.longValue(), businessCode, BizAccountDetail.DOU_DESC_ORDER);
if (!result) {
return AjaxResult.error("扣款失败,请联系管理员");
}
//增加专项账户
if(cashbackAmount.longValue() > 0) {
// TODO 类型不对同步完数据后在修改
result = bizAccountService.accountChange(memberID, BizAccount.DOU_SPECIAL, BizAccountDetail.DOU_DETAIL_TYPE_CHARGE, cashbackAmount.longValue(), businessCode, BizAccountDetail.DOU_DESC_SPECIAL1);
if (!result) {
return AjaxResult.error("扣款失败,请联系管理员");
if(isTeam) {
if (cashbackTotalAmount.longValue() > 0) {
result = bizAccountService.accountChange(memberID, BizAccount.DOU_SPECIAL, BizAccountDetail.DOU_DETAIL_TYPE_CHARGE, cashbackTotalAmount.longValue(), businessCode, BizAccountDetail.DOU_DESC_SPECIAL1);
if (!result) {
return AjaxResult.error("扣款失败,请联系管理员");
}
}
//增加直推奖励(团队福豆账户)

View File

@ -67,10 +67,9 @@ public class BusinessTask {
private void doSpecialTask()
{
try {
int dailyAmount = Integer.parseInt(DictUtils.getDictLabel("busi_award_set", "2"));
int accessCount = bizMemberService.doSpecialTask();
LogUtils.getAccessLog().info("======执行专项划拨任务完成======");
LogUtils.getAccessLog().info("======执行专项划拨任务完成,处理会员" + accessCount + "条======");
} catch (Exception ex) {
ex.printStackTrace();
LogUtils.getAccessLog().error("======执行专项划拨任务出错======" + ex.getMessage());

View File

@ -13,6 +13,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="recommendMobile" column="recommend_mobile" />
<result property="recommendName" column="recommend_name" />
<result property="memberType" column="member_type" />
<result property="specialLevel" column="special_level" />
<result property="isDelete" column="is_delete" />
<result property="isEnable" column="is_enable" />
<result property="createBy" column="create_by" />
@ -22,7 +23,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectBizMemberVo">
select a.id, mobile, member_name, password, recommend_id, recommend_mobile, recommend_name, member_type, is_delete, is_enable, create_by, create_time, update_by, update_time,
select a.id, mobile, member_name, password, recommend_id, recommend_mobile, recommend_name, member_type, special_level, is_delete, is_enable, create_by, create_time, update_by, update_time,
(select amount from biz_account where member_id = a.id and account_type = 0) douBalance,
(select amount from biz_account where member_id = a.id and account_type = 1) douPerson,
(select amount from biz_account where member_id = a.id and account_type = 2) douTeam,
@ -50,7 +51,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<select id="selectBizMemberSimple" parameterType="Long" resultMap="BizMemberResult">
select id, mobile, member_name, password, recommend_id, recommend_mobile, recommend_name, member_type, is_delete, is_enable, create_by, create_time, update_by, update_time
select id, mobile, member_name, password, recommend_id, recommend_mobile, recommend_name, member_type, special_level, is_delete, is_enable, create_by, create_time, update_by, update_time
from biz_member where id = #{id}
</select>
@ -141,4 +142,25 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
group by a.id,a.member_name,a.recommend_id
</select>
<select id="selectSpecialMember" parameterType="Integer" resultMap="BizMemberResult">
select a.id, special_level, b.amount douSpecial from biz_member a
left join biz_account b on a.id = b.member_id and b.account_type = 3
where is_delete = 0 and b.amount >= #{minValue}
</select>
<select id="getMemberTeamCount" parameterType="Long" resultType="Long">
select IF(sum(num) IS NULL,0,sum(num)) totalNum from (
select a.id, sum(IF(c.product_count IS NULL,0,c.product_count)) as num from biz_member a
left join biz_order b on a.id = b.member_id and b.order_status > 0 and b.is_team = 1
left join biz_order_detail c on c.order_id = b.id
where concat(',', recommend_all_id, ',') like concat('%,', #{memberID}, ',%')
group by a.id
) t
</select>
<update id="updateMemberLevel" parameterType="BizMember">
update biz_member
set special_level = #{specialLevel}
where id = #{id}
</update>
</mapper>

View File

@ -30,6 +30,7 @@
.childDiv .cont{padding-left: 20px}
.childDiv span{display:block;font-size: 14px;line-height: 24px;padding:0 0 4px 4px;cursor:pointer;border-radius: 5px;border:1px solid #AAAAAA}
.childDiv span.noneChild{padding-left: 29px;padding-top: 2px;padding-bottom: 2px}
.childDiv span ss{font-family: 宋体}
</style>
<script th:inline="javascript">
var prefix = ctx + "business/member";
@ -44,7 +45,12 @@
$.post(prefix + "/accountTeamDetail", "memberID=" + $("#memberID").val() + "&productID=" + productID, function(resp){
if(resp.code != 0) return;
$("#numSpan").text(resp.data.teamNum);
showChildren($("#container"), resp.data.memberList, true);
let members = resp.data.memberList;
if(!members){
$("#container").html("&nbsp;该用户没有子级");
return;
}
showChildren($("#container"), members, true);
$("#container .cont").hide();
});
}
@ -55,7 +61,7 @@
let item = list[i];
let children = item.children;
let child = clone.clone().show();
child.html("<span class='" + (children ? "glyphicon glyphicon-chevron-right" : "noneChild") + "'>&nbsp;" + item.member_name + item.mobile + "(" + item.num + "盒)&nbsp;<b style='color:#0000FF'>" + (flag ? item.desc : "") + "</b></span>");
child.html("<span class='" + (children ? "glyphicon glyphicon-chevron-right" : "noneChild") + "'><ss>&nbsp;" + item.member_name + item.mobile + "(" + item.num + "盒)&nbsp;<b style='color:#0000FF'>" + (flag ? item.desc : "") + "</b></ss></span>");
div.append(child);
if(children){
child.append("<div class='cont'></div>");

View File

@ -8,6 +8,7 @@ CREATE TABLE `biz_member` (
`recommend_mobile` varchar(32) NOT NULL DEFAULT '' COMMENT '推荐人手机',
`recommend_name` varchar(32) NOT NULL DEFAULT '' COMMENT '推荐人姓名',
`member_type` tinyint(4) NOT NULL DEFAULT 0 COMMENT '会员类型',
`special_level` tinyint(1) NOT NULL DEFAULT 1 COMMENT '专项返还次数(默认1, 若出局为0)',
`is_delete` tinyint(4) NOT NULL DEFAULT 0 COMMENT '是否删除0-否1-是',
`is_enable` tinyint(4) NOT NULL DEFAULT 0 COMMENT '是否禁用0-否1-是',
`create_by` varchar(64) DEFAULT '' COMMENT '创建者',