直推和二级直推
This commit is contained in:
parent
3410ac9ea8
commit
589d37fd75
|
|
@ -3,23 +3,12 @@ package com.ruoyi.business.ajax;
|
||||||
import com.ruoyi.business.service.IBizMemberService;
|
import com.ruoyi.business.service.IBizMemberService;
|
||||||
import com.ruoyi.common.core.controller.BaseController;
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
import com.ruoyi.common.core.domain.AjaxResult;
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
import com.ruoyi.common.utils.security.Md5Utils;
|
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
import org.apache.shiro.crypto.hash.Md5Hash;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import sun.security.provider.MD5;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.crypto.Cipher;
|
|
||||||
import javax.crypto.NoSuchPaddingException;
|
|
||||||
import javax.crypto.SecretKey;
|
|
||||||
import javax.crypto.SecretKeyFactory;
|
|
||||||
import javax.crypto.spec.DESKeySpec;
|
|
||||||
import javax.crypto.spec.IvParameterSpec;
|
|
||||||
import java.security.NoSuchAlgorithmException;
|
|
||||||
import java.util.Base64;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 前端用户登录
|
* 前端用户登录
|
||||||
|
|
|
||||||
|
|
@ -1,28 +1,24 @@
|
||||||
package com.ruoyi.business.controller;
|
package com.ruoyi.business.controller;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import com.ruoyi.business.domain.BizMember;
|
||||||
import java.util.List;
|
import com.ruoyi.business.service.IBizMemberService;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import com.ruoyi.business.utils.Encrypt;
|
import com.ruoyi.business.utils.Encrypt;
|
||||||
|
import com.ruoyi.common.annotation.Log;
|
||||||
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
|
import com.ruoyi.common.enums.BusinessType;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.ModelMap;
|
import org.springframework.ui.ModelMap;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import java.util.HashMap;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import java.util.List;
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import java.util.Map;
|
||||||
import com.ruoyi.common.annotation.Log;
|
|
||||||
import com.ruoyi.common.enums.BusinessType;
|
|
||||||
import com.ruoyi.business.domain.BizMember;
|
|
||||||
import com.ruoyi.business.service.IBizMemberService;
|
|
||||||
import com.ruoyi.common.core.controller.BaseController;
|
|
||||||
import com.ruoyi.common.core.domain.AjaxResult;
|
|
||||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
|
||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 会员Controller
|
* 会员Controller
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,9 @@ public class BizAccount extends BaseEntity
|
||||||
public static final int DOU_SPECIAL = 3;
|
public static final int DOU_SPECIAL = 3;
|
||||||
public static final int DOU_FIELD = 4;
|
public static final int DOU_FIELD = 4;
|
||||||
|
|
||||||
|
//二级直推拥有有效下级用户数量条件
|
||||||
|
public static final int SECOND_AWARD_CHILD_LIMIT = 3;
|
||||||
|
|
||||||
/** 会员账户ID */
|
/** 会员账户ID */
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,9 @@ public class BizOrder extends BaseEntity
|
||||||
@Excel(name = "0-待支付,1-已支付,2-已取消, 3-待收货, 4-已完成")
|
@Excel(name = "0-待支付,1-已支付,2-已取消, 3-待收货, 4-已完成")
|
||||||
private Integer orderStatus;
|
private Integer orderStatus;
|
||||||
|
|
||||||
|
/** 是否团队福豆影响 */
|
||||||
|
private Integer isTeam;
|
||||||
|
|
||||||
/** 订单备注 */
|
/** 订单备注 */
|
||||||
@Excel(name = "订单备注")
|
@Excel(name = "订单备注")
|
||||||
private String remark;
|
private String remark;
|
||||||
|
|
@ -148,7 +151,16 @@ public class BizOrder extends BaseEntity
|
||||||
{
|
{
|
||||||
return orderStatus;
|
return orderStatus;
|
||||||
}
|
}
|
||||||
public void setAddressId(Long addressId)
|
|
||||||
|
public Integer getIsTeam() {
|
||||||
|
return isTeam;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsTeam(Integer isTeam) {
|
||||||
|
this.isTeam = isTeam;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAddressId(Long addressId)
|
||||||
{
|
{
|
||||||
this.addressId = addressId;
|
this.addressId = addressId;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -76,4 +76,13 @@ public interface BizMemberMapper
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public int deleteBizMemberByIds(String[] ids);
|
public int deleteBizMemberByIds(String[] ids);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 取出有效下级数量(有订单)
|
||||||
|
*
|
||||||
|
* @param memberID 上级用户ID
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int getValidChildCount(Long memberID);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ import com.ruoyi.common.core.text.Convert;
|
||||||
import com.ruoyi.common.utils.DateUtils;
|
import com.ruoyi.common.utils.DateUtils;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
import com.ruoyi.framework.util.ShiroUtils;
|
import com.ruoyi.framework.util.ShiroUtils;
|
||||||
|
import com.ruoyi.system.utils.DictUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
|
@ -187,6 +188,7 @@ public class BizOrderServiceImpl implements IBizOrderService
|
||||||
order.setMemberName(member.getMemberName());
|
order.setMemberName(member.getMemberName());
|
||||||
order.setOrderAmount(orderTotal);
|
order.setOrderAmount(orderTotal);
|
||||||
order.setOrderStatus(BizOrder.STATUS_PAYED); //已支付
|
order.setOrderStatus(BizOrder.STATUS_PAYED); //已支付
|
||||||
|
order.setIsTeam(cashbackAmount.longValue() > 0 ? 1 : 0); //是否团队福豆影响订单
|
||||||
order.setRemark(remark);
|
order.setRemark(remark);
|
||||||
order.setAddressDetail(address.getAddress());
|
order.setAddressDetail(address.getAddress());
|
||||||
order.setAddressId(addressID);
|
order.setAddressId(addressID);
|
||||||
|
|
@ -200,19 +202,43 @@ public class BizOrderServiceImpl implements IBizOrderService
|
||||||
orderDetail.setProductCount(productNum);
|
orderDetail.setProductCount(productNum);
|
||||||
orderDetail.setProductAmount(amount);
|
orderDetail.setProductAmount(amount);
|
||||||
bizOrderMapper.insertBizOrderDetail(orderDetail);
|
bizOrderMapper.insertBizOrderDetail(orderDetail);
|
||||||
|
|
||||||
|
String businessCode = String.valueOf(order.getOrderSn());
|
||||||
//减去福豆余额账户
|
//减去福豆余额账户
|
||||||
// TODO 类型不对,同步完数据后在修改
|
// TODO 类型不对,同步完数据后在修改
|
||||||
boolean result = bizAccountService.accountChange(memberID, BizAccount.DOU_BALANCE, BizAccountDetail.DOU_DETAIL_TYPE_ORDER, -orderTotal.longValue(), String.valueOf(order.getId()), BizAccountDetail.DOU_DESC_ORDER);
|
boolean result = bizAccountService.accountChange(memberID, BizAccount.DOU_BALANCE, BizAccountDetail.DOU_DETAIL_TYPE_ORDER, -orderTotal.longValue(), businessCode, BizAccountDetail.DOU_DESC_ORDER);
|
||||||
if (!result) {
|
if (!result) {
|
||||||
return AjaxResult.error("扣款失败,请联系管理员");
|
return AjaxResult.error("扣款失败,请联系管理员");
|
||||||
}
|
}
|
||||||
//增加专项账户
|
//增加专项账户
|
||||||
if(cashbackAmount.longValue() > 0) {
|
if(cashbackAmount.longValue() > 0) {
|
||||||
// TODO 类型不对,同步完数据后在修改
|
// TODO 类型不对,同步完数据后在修改
|
||||||
result = bizAccountService.accountChange(memberID, BizAccount.DOU_SPECIAL, BizAccountDetail.DOU_DETAIL_TYPE_CHARGE, cashbackAmount.longValue(), String.valueOf(order.getId()), BizAccountDetail.DOU_DESC_SPECIAL1);
|
result = bizAccountService.accountChange(memberID, BizAccount.DOU_SPECIAL, BizAccountDetail.DOU_DETAIL_TYPE_CHARGE, cashbackAmount.longValue(), businessCode, BizAccountDetail.DOU_DESC_SPECIAL1);
|
||||||
if (!result) {
|
if (!result) {
|
||||||
return AjaxResult.error("扣款失败,请联系管理员");
|
return AjaxResult.error("扣款失败,请联系管理员");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//增加直推奖励(团队福豆账户)
|
||||||
|
Long recMemberID = member.getRecommendId();
|
||||||
|
if (recMemberID != null && recMemberID != 0) {
|
||||||
|
//取出直推奖励金额
|
||||||
|
String award1 = DictUtils.getDictLabel("busi_recommend_award", "1");
|
||||||
|
result = bizAccountService.accountChange(memberID, BizAccount.DOU_TEAM, BizAccountDetail.DOU_DETAIL_TYPE_CHARGE, Long.parseLong(award1), businessCode, BizAccountDetail.DOU_DESC_RECOMM);
|
||||||
|
if (!result) {
|
||||||
|
return AjaxResult.error("扣款失败,请联系管理员");
|
||||||
|
}
|
||||||
|
//判断二级直推(需要3个下级)
|
||||||
|
BizMember recommendMember = bizMemberMapper.selectBizMemberSimple(recMemberID);
|
||||||
|
Long topMemberID = recommendMember.getRecommendId();
|
||||||
|
//判断有效下级数不少于三个
|
||||||
|
if (bizMemberMapper.getValidChildCount(topMemberID) >= BizAccount.SECOND_AWARD_CHILD_LIMIT) {
|
||||||
|
String award2 = DictUtils.getDictLabel("busi_recommend_award", "2");
|
||||||
|
result = bizAccountService.accountChange(memberID, BizAccount.DOU_TEAM, BizAccountDetail.DOU_DETAIL_TYPE_CHARGE, Long.parseLong(award2), businessCode, BizAccountDetail.DOU_DESC_SECOND);
|
||||||
|
if (!result) {
|
||||||
|
return AjaxResult.error("扣款失败,请联系管理员");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return AjaxResult.success();
|
return AjaxResult.success();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package com.ruoyi.business.utils;
|
||||||
|
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
import com.ruoyi.common.utils.security.Md5Utils;
|
import com.ruoyi.common.utils.security.Md5Utils;
|
||||||
|
import com.ruoyi.system.utils.DictUtils;
|
||||||
|
|
||||||
import javax.crypto.*;
|
import javax.crypto.*;
|
||||||
import javax.crypto.spec.DESKeySpec;
|
import javax.crypto.spec.DESKeySpec;
|
||||||
|
|
@ -72,7 +73,9 @@ public class Encrypt {
|
||||||
|
|
||||||
public static void main(String args[]) {
|
public static void main(String args[]) {
|
||||||
//System.out.println(encrypt("x123456"));
|
//System.out.println(encrypt("x123456"));
|
||||||
System.out.println(decrypt("248E135E28C103B4"));
|
//System.out.println(decrypt("248E135E28C103B4"));
|
||||||
|
|
||||||
|
//System.out.println(DictUtils.getDictLabel("busi_recommend_award", "1"));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String HEX_CHAR = "0123456789ABCDEF";
|
private static final String HEX_CHAR = "0123456789ABCDEF";
|
||||||
|
|
|
||||||
|
|
@ -122,4 +122,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
</foreach>
|
</foreach>
|
||||||
</delete>
|
</delete>
|
||||||
|
|
||||||
|
<select id="getValidChildCount" parameterType="Long" resultType="Integer">
|
||||||
|
select count(id) from biz_member a where recommend_id = #{memberID}
|
||||||
|
and exists(select id from biz_order b where b.member_id = a.id and is_team = 1)
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
@ -12,6 +12,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<result property="memberName" column="member_name" />
|
<result property="memberName" column="member_name" />
|
||||||
<result property="orderAmount" column="order_amount" />
|
<result property="orderAmount" column="order_amount" />
|
||||||
<result property="orderStatus" column="order_status" />
|
<result property="orderStatus" column="order_status" />
|
||||||
|
<result property="isTeam" column="is_team" />
|
||||||
<result property="remark" column="remark" />
|
<result property="remark" column="remark" />
|
||||||
<result property="addressDetail" column="address_detail" />
|
<result property="addressDetail" column="address_detail" />
|
||||||
<result property="addressId" column="address_id" />
|
<result property="addressId" column="address_id" />
|
||||||
|
|
@ -69,6 +70,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<if test="memberName != null and memberName != ''">member_name,</if>
|
<if test="memberName != null and memberName != ''">member_name,</if>
|
||||||
<if test="orderAmount != null">order_amount,</if>
|
<if test="orderAmount != null">order_amount,</if>
|
||||||
<if test="orderStatus != null">order_status,</if>
|
<if test="orderStatus != null">order_status,</if>
|
||||||
|
<if test="isTeam != null">is_team,</if>
|
||||||
<if test="addressDetail != null">address_detail,</if>
|
<if test="addressDetail != null">address_detail,</if>
|
||||||
<if test="remark != null">remark,</if>
|
<if test="remark != null">remark,</if>
|
||||||
<if test="addressId != null">address_id,</if>
|
<if test="addressId != null">address_id,</if>
|
||||||
|
|
@ -84,6 +86,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<if test="memberName != null and memberName != ''">#{memberName},</if>
|
<if test="memberName != null and memberName != ''">#{memberName},</if>
|
||||||
<if test="orderAmount != null">#{orderAmount},</if>
|
<if test="orderAmount != null">#{orderAmount},</if>
|
||||||
<if test="orderStatus != null">#{orderStatus},</if>
|
<if test="orderStatus != null">#{orderStatus},</if>
|
||||||
|
<if test="isTeam != null">#{isTeam},</if>
|
||||||
<if test="addressDetail != null">#{addressDetail},</if>
|
<if test="addressDetail != null">#{addressDetail},</if>
|
||||||
<if test="remark != null">#{remark},</if>
|
<if test="remark != null">#{remark},</if>
|
||||||
<if test="addressId != null">#{addressId},</if>
|
<if test="addressId != null">#{addressId},</if>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue