余额相关改动
This commit is contained in:
@@ -35,7 +35,7 @@ public interface UserAccountFlowMapper extends BaseMapper<UserAccountFlow> {
|
|||||||
"\torder by id desc limit #{pageSize} offset #{offset} ")
|
"\torder by id desc limit #{pageSize} offset #{offset} ")
|
||||||
List<UserMakerQuotaVO> selectByUserIdType(@Param("userId") Long userId, @Param("pageSize") Integer pageSize, @Param("offset") Integer offset);
|
List<UserMakerQuotaVO> selectByUserIdType(@Param("userId") Long userId, @Param("pageSize") Integer pageSize, @Param("offset") Integer offset);
|
||||||
@Select("SELECT\n" +
|
@Select("SELECT\n" +
|
||||||
"\tSUM( amount ) \n" +
|
"\t IFNULL(SUM( amount ),0) \n" +
|
||||||
"FROM\n" +
|
"FROM\n" +
|
||||||
"\ttb_pluss_user_account_flow \n" +
|
"\ttb_pluss_user_account_flow \n" +
|
||||||
"WHERE\n" +
|
"WHERE\n" +
|
||||||
|
|||||||
@@ -14,10 +14,12 @@ import java.math.BigDecimal;
|
|||||||
*/
|
*/
|
||||||
public interface UserMakerQuotaMapper extends BaseMapper<UserMakerQuota> {
|
public interface UserMakerQuotaMapper extends BaseMapper<UserMakerQuota> {
|
||||||
BigDecimal sumQuota(@Param("userId") Long userId);
|
BigDecimal sumQuota(@Param("userId") Long userId);
|
||||||
@Update(value = "update tb_pluss_user_account set amount=amount+#{amount} where userId=#{userId}")
|
@Update(value = "update tb_pluss_user_maker_quota set amount=#{amount} where userId=#{userId}")
|
||||||
Integer updateMakerFreeze(@Param("userId") Integer userId, @Param("amount") BigDecimal amount);
|
Integer updateMakerFreeze(@Param("userId") Integer userId, @Param("amount") BigDecimal amount);
|
||||||
|
|
||||||
@Select(value ="SELECT * FROM tb_pluss_user_maker_quota WHERE userId = #{userId}")
|
@Select(value ="SELECT * FROM tb_pluss_user_maker_quota WHERE userId = #{userId}")
|
||||||
UserMakerQuota selectByUserId(@Param("userId") Long userId);
|
UserMakerQuota selectByUserId(@Param("userId") Long userId);
|
||||||
|
@Select(value ="SELECT * FROM tb_pluss_user_maker_quota WHERE userId = #{userId}")
|
||||||
|
UserMakerQuota selectByUserId(@Param("userId") Integer userId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,8 @@
|
|||||||
where user_id = #{userId}
|
where user_id = #{userId}
|
||||||
</select>
|
</select>
|
||||||
<select id="selectByUserIdMC" resultType="cn.pluss.platform.entity.UserPromotion">
|
<select id="selectByUserIdMC" resultType="cn.pluss.platform.entity.UserPromotion">
|
||||||
select *
|
select user_id AS userId,type_code AS typeCode,current_fee AS currentFee,parent_user_id AS parentUserId,
|
||||||
|
is_extend AS isExtend,create_time AS createTime,update_time AS updateTime
|
||||||
from tb_pluss_user_promotion
|
from tb_pluss_user_promotion
|
||||||
<where>
|
<where>
|
||||||
user_id = #{userId}
|
user_id = #{userId}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import cn.pluss.platform.vo.UserMakerQuotaVO;
|
|||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import io.swagger.models.auth.In;
|
import io.swagger.models.auth.In;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Propagation;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
@@ -64,25 +65,27 @@ public class UserMakerQuotaServiceImpl extends ServiceImpl<UserMakerQuotaMapper,
|
|||||||
//商户码转userId
|
//商户码转userId
|
||||||
if (consumeFee.compareTo(new BigDecimal("0.01"))>0) {
|
if (consumeFee.compareTo(new BigDecimal("0.01"))>0) {
|
||||||
MerchantBaseInfo merchantBaseInfoByMerchantCode = merchantBaseInfoService.getMerchantBaseInfoByMerchantCode(order.getMerchantCode());
|
MerchantBaseInfo merchantBaseInfoByMerchantCode = merchantBaseInfoService.getMerchantBaseInfoByMerchantCode(order.getMerchantCode());
|
||||||
|
if(merchantBaseInfoByMerchantCode == null)
|
||||||
|
return;
|
||||||
//找到上级增加额度
|
//找到上级增加额度
|
||||||
UserPromotion userInfo = userPromotionMapper.selectByPrimaryKey(Long.valueOf(merchantBaseInfoByMerchantCode.getUserId()));
|
UserPromotion userInfo = userPromotionMapper.selectByPrimaryKey(Long.valueOf(merchantBaseInfoByMerchantCode.getUserId()));
|
||||||
if (userInfo != null) {
|
if (userInfo != null) {
|
||||||
UserPromotion userParent = userPromotionMapper.selectByUserIdMC(Long.valueOf(userInfo.getParentUserId()));
|
UserPromotion userParent = userPromotionMapper.selectByUserIdMC(Long.valueOf(userInfo.getParentUserId()));
|
||||||
if (userParent != null && "1".equals(userParent.getIsExtend())){
|
if (userParent != null && "1".equals(userParent.getIsExtend())){
|
||||||
BigDecimal profit = consumeFee.multiply(new BigDecimal("0.0038")).setScale(2,BigDecimal.ROUND_DOWN);
|
BigDecimal profit = consumeFee.multiply(new BigDecimal("0.5")).setScale(2,BigDecimal.ROUND_DOWN);
|
||||||
String s = String.valueOf(userParent.getUserId());
|
String s = String.valueOf(userParent.getUserId());
|
||||||
Integer integer = Integer.valueOf(s);
|
Integer integer = Integer.valueOf(s);
|
||||||
this.modMakerFunds(integer,"SD","免费额度",profit,"");
|
this.modMakerFunds(integer,"SD","免费额度",profit,"");
|
||||||
}
|
//给自己计算
|
||||||
}
|
|
||||||
//自己如果是创客的话
|
|
||||||
assert userInfo != null;
|
|
||||||
if ("1".equals(userInfo.getIsExtend())){
|
if ("1".equals(userInfo.getIsExtend())){
|
||||||
profit(userInfo,consumeFee);
|
profit(userInfo,consumeFee);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<UserMakerQuotaVO> quotaList(Integer page, Integer size, Integer type) {
|
public List<UserMakerQuotaVO> quotaList(Integer page, Integer size, Integer type) {
|
||||||
Integer pageSize = size;
|
Integer pageSize = size;
|
||||||
@@ -127,7 +130,8 @@ public class UserMakerQuotaServiceImpl extends ServiceImpl<UserMakerQuotaMapper,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//增加提现金额
|
//增加提现金额
|
||||||
private void profit(UserPromotion userInfo,BigDecimal consumeFee){
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void profit(UserPromotion userInfo,BigDecimal consumeFee){
|
||||||
UserMakerQuota userMakerQuota = userMakerQuotaMapper.selectByUserId(userInfo.getUserId());
|
UserMakerQuota userMakerQuota = userMakerQuotaMapper.selectByUserId(userInfo.getUserId());
|
||||||
if (userMakerQuota != null) {
|
if (userMakerQuota != null) {
|
||||||
BigDecimal sumbigDecimal = userMakerQuota.getAmount();
|
BigDecimal sumbigDecimal = userMakerQuota.getAmount();
|
||||||
@@ -139,7 +143,7 @@ public class UserMakerQuotaServiceImpl extends ServiceImpl<UserMakerQuotaMapper,
|
|||||||
//提现金额
|
//提现金额
|
||||||
userAccountService.modFunds(integer, "LD", "免提现额度", profit, "");
|
userAccountService.modFunds(integer, "LD", "免提现额度", profit, "");
|
||||||
//额度改变
|
//额度改变
|
||||||
this.modMakerFunds(integer, "LD", "收款消耗", sumbigDecimal, "");
|
modMakerFunds(integer, "LD", "收款消耗", sumbigDecimal, "");
|
||||||
} else {
|
} else {
|
||||||
BigDecimal profit = sumbigDecimal.multiply(new BigDecimal("0.0038")).setScale(2, BigDecimal.ROUND_DOWN);
|
BigDecimal profit = sumbigDecimal.multiply(new BigDecimal("0.0038")).setScale(2, BigDecimal.ROUND_DOWN);
|
||||||
String s = String.valueOf(userInfo.getUserId());
|
String s = String.valueOf(userInfo.getUserId());
|
||||||
@@ -147,7 +151,7 @@ public class UserMakerQuotaServiceImpl extends ServiceImpl<UserMakerQuotaMapper,
|
|||||||
//提现金额
|
//提现金额
|
||||||
userAccountService.modFunds(integer, "LD", "收款消耗", profit, "");
|
userAccountService.modFunds(integer, "LD", "收款消耗", profit, "");
|
||||||
//额度改变
|
//额度改变
|
||||||
this.modMakerFunds(integer, "LD", "收款消耗", BigDecimal.ZERO, "");
|
modMakerFunds(integer, "LD", "收款消耗", BigDecimal.ZERO, "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -161,6 +165,7 @@ public class UserMakerQuotaServiceImpl extends ServiceImpl<UserMakerQuotaMapper,
|
|||||||
* @param difference
|
* @param difference
|
||||||
* @param remark
|
* @param remark
|
||||||
*/
|
*/
|
||||||
|
@Transactional(rollbackFor = Exception.class, propagation = Propagation.MANDATORY)
|
||||||
public void modMakerFunds(Integer userId, String bizCode, String bizName, BigDecimal difference, String remark) {
|
public void modMakerFunds(Integer userId, String bizCode, String bizName, BigDecimal difference, String remark) {
|
||||||
Assert.notNull(userId, "NOt Null");
|
Assert.notNull(userId, "NOt Null");
|
||||||
Assert.notNull(bizCode, "Not Null");
|
Assert.notNull(bizCode, "Not Null");
|
||||||
@@ -189,7 +194,7 @@ public class UserMakerQuotaServiceImpl extends ServiceImpl<UserMakerQuotaMapper,
|
|||||||
private UserMakerQuota initUserMaker(Integer userId){
|
private UserMakerQuota initUserMaker(Integer userId){
|
||||||
Assert.notNull(userId, "NOt Null");
|
Assert.notNull(userId, "NOt Null");
|
||||||
synchronized (this){
|
synchronized (this){
|
||||||
UserMakerQuota userMakerQuota = getUserAccountByUserId(userId);
|
UserMakerQuota userMakerQuota = userMakerQuotaMapper.selectByUserId(userId);
|
||||||
if(ObjectUtil.isEmpty(userMakerQuota)){
|
if(ObjectUtil.isEmpty(userMakerQuota)){
|
||||||
userMakerQuota=new UserMakerQuota();
|
userMakerQuota=new UserMakerQuota();
|
||||||
userMakerQuota.setUserId(Long.valueOf(userId));
|
userMakerQuota.setUserId(Long.valueOf(userId));
|
||||||
|
|||||||
@@ -284,8 +284,8 @@ public class CashServiceImpl extends ServiceImpl<CashMapper, Cash> implements Ca
|
|||||||
cash.setMerchantName(tokenUa.getMerchantName());
|
cash.setMerchantName(tokenUa.getMerchantName());
|
||||||
cash.setMerchantCode(tokenUa.getMerchantCode());
|
cash.setMerchantCode(tokenUa.getMerchantCode());
|
||||||
cash.setRate(8);
|
cash.setRate(8);
|
||||||
cash.setBaseServiceCharge(BigDecimal.valueOf(3));
|
cash.setBaseServiceCharge(BigDecimal.ZERO);
|
||||||
cash.setRatioCharge(cash.getCashAmt().multiply(BigDecimal.valueOf(0.08)));
|
cash.setRatioCharge(cash.getCashAmt().multiply(new BigDecimal("0.01")).setScale(2,BigDecimal.ROUND_DOWN));
|
||||||
|
|
||||||
LambdaQueryWrapper<CashAccount> qWrapper2 = Wrappers.lambdaQuery();
|
LambdaQueryWrapper<CashAccount> qWrapper2 = Wrappers.lambdaQuery();
|
||||||
qWrapper2.eq(CashAccount::getUserId, cash.getUserId())
|
qWrapper2.eq(CashAccount::getUserId, cash.getUserId())
|
||||||
|
|||||||
Reference in New Issue
Block a user