余额相关改动

This commit is contained in:
liuyingfang
2023-08-25 09:26:14 +08:00
parent 25155ad6fc
commit 01e435f575
5 changed files with 23 additions and 15 deletions

View File

@@ -35,7 +35,7 @@ public interface UserAccountFlowMapper extends BaseMapper<UserAccountFlow> {
"\torder by id desc limit #{pageSize} offset #{offset} ")
List<UserMakerQuotaVO> selectByUserIdType(@Param("userId") Long userId, @Param("pageSize") Integer pageSize, @Param("offset") Integer offset);
@Select("SELECT\n" +
"\tSUM( amount ) \n" +
"\t IFNULL(SUM( amount ),0) \n" +
"FROM\n" +
"\ttb_pluss_user_account_flow \n" +
"WHERE\n" +

View File

@@ -14,10 +14,12 @@ import java.math.BigDecimal;
*/
public interface UserMakerQuotaMapper extends BaseMapper<UserMakerQuota> {
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);
@Select(value ="SELECT * FROM tb_pluss_user_maker_quota WHERE userId = #{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);
}

View File

@@ -38,7 +38,8 @@
where user_id = #{userId}
</select>
<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
<where>
user_id = #{userId}

View File

@@ -15,6 +15,7 @@ import cn.pluss.platform.vo.UserMakerQuotaVO;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.swagger.models.auth.In;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
@@ -64,22 +65,24 @@ public class UserMakerQuotaServiceImpl extends ServiceImpl<UserMakerQuotaMapper,
//商户码转userId
if (consumeFee.compareTo(new BigDecimal("0.01"))>0) {
MerchantBaseInfo merchantBaseInfoByMerchantCode = merchantBaseInfoService.getMerchantBaseInfoByMerchantCode(order.getMerchantCode());
if(merchantBaseInfoByMerchantCode == null)
return;
//找到上级增加额度
UserPromotion userInfo = userPromotionMapper.selectByPrimaryKey(Long.valueOf(merchantBaseInfoByMerchantCode.getUserId()));
if (userInfo != null) {
UserPromotion userParent = userPromotionMapper.selectByUserIdMC(Long.valueOf(userInfo.getParentUserId()));
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());
Integer integer = Integer.valueOf(s);
this.modMakerFunds(integer,"SD","免费额度",profit,"");
//给自己计算
if ("1".equals(userInfo.getIsExtend())){
profit(userInfo,consumeFee);
}
}
}
//自己如果是创客的话
assert userInfo != null;
if ("1".equals(userInfo.getIsExtend())){
profit(userInfo,consumeFee);
}
}
}
@@ -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());
if (userMakerQuota != null) {
BigDecimal sumbigDecimal = userMakerQuota.getAmount();
@@ -139,7 +143,7 @@ public class UserMakerQuotaServiceImpl extends ServiceImpl<UserMakerQuotaMapper,
//提现金额
userAccountService.modFunds(integer, "LD", "免提现额度", profit, "");
//额度改变
this.modMakerFunds(integer, "LD", "收款消耗", sumbigDecimal, "");
modMakerFunds(integer, "LD", "收款消耗", sumbigDecimal, "");
} else {
BigDecimal profit = sumbigDecimal.multiply(new BigDecimal("0.0038")).setScale(2, BigDecimal.ROUND_DOWN);
String s = String.valueOf(userInfo.getUserId());
@@ -147,7 +151,7 @@ public class UserMakerQuotaServiceImpl extends ServiceImpl<UserMakerQuotaMapper,
//提现金额
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 remark
*/
@Transactional(rollbackFor = Exception.class, propagation = Propagation.MANDATORY)
public void modMakerFunds(Integer userId, String bizCode, String bizName, BigDecimal difference, String remark) {
Assert.notNull(userId, "NOt Null");
Assert.notNull(bizCode, "Not Null");
@@ -189,7 +194,7 @@ public class UserMakerQuotaServiceImpl extends ServiceImpl<UserMakerQuotaMapper,
private UserMakerQuota initUserMaker(Integer userId){
Assert.notNull(userId, "NOt Null");
synchronized (this){
UserMakerQuota userMakerQuota = getUserAccountByUserId(userId);
UserMakerQuota userMakerQuota = userMakerQuotaMapper.selectByUserId(userId);
if(ObjectUtil.isEmpty(userMakerQuota)){
userMakerQuota=new UserMakerQuota();
userMakerQuota.setUserId(Long.valueOf(userId));

View File

@@ -284,8 +284,8 @@ public class CashServiceImpl extends ServiceImpl<CashMapper, Cash> implements Ca
cash.setMerchantName(tokenUa.getMerchantName());
cash.setMerchantCode(tokenUa.getMerchantCode());
cash.setRate(8);
cash.setBaseServiceCharge(BigDecimal.valueOf(3));
cash.setRatioCharge(cash.getCashAmt().multiply(BigDecimal.valueOf(0.08)));
cash.setBaseServiceCharge(BigDecimal.ZERO);
cash.setRatioCharge(cash.getCashAmt().multiply(new BigDecimal("0.01")).setScale(2,BigDecimal.ROUND_DOWN));
LambdaQueryWrapper<CashAccount> qWrapper2 = Wrappers.lambdaQuery();
qWrapper2.eq(CashAccount::getUserId, cash.getUserId())