分销金额
This commit is contained in:
parent
c027336989
commit
3820d86c8a
|
|
@ -6,6 +6,7 @@ import com.czg.market.vo.InviteUserVO;
|
|||
import com.mybatisflex.core.paginate.Page;
|
||||
import com.mybatisflex.core.service.IService;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -34,4 +35,6 @@ public interface ShopUserService extends IService<ShopUser> {
|
|||
boolean updateInfo(ShopUser shopUser);
|
||||
|
||||
List<ShopUser> selectBirthdayUser(LocalDate current, Long mainShopId, String userType);
|
||||
|
||||
void updateOneOrTwoAmount(Long userId, Long mainShopId, BigDecimal bigDecimal, Integer isOne);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,6 +25,6 @@ public interface UserInfoService extends IService<UserInfo> {
|
|||
|
||||
Boolean getCode(Long userId, String type);
|
||||
|
||||
void updateDistributionAmount(long userId, BigDecimal amount, Integer isOne);
|
||||
void updateDistributionAmount(long userId, BigDecimal amount);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ public interface MkDistributionUserService extends IService<MkDistributionUser>
|
|||
*/
|
||||
void distribute(Long sourceId, String orderNo, BigDecimal amount, Long userId, Long shopId, String type);
|
||||
|
||||
void updateIncome(BigDecimal pendingIncome, BigDecimal receivedIncome, BigDecimal withdrawIncome, Long id, Long userId, Integer isOne);
|
||||
void updateIncome(BigDecimal pendingIncome, BigDecimal receivedIncome, BigDecimal withdrawIncome, Long id, Long userId, Long shopId, Integer isOne);
|
||||
|
||||
|
||||
Boolean withdraw(long userId, MkDistributionWithdrawFlowDTO withdrawFlowDTO);
|
||||
|
|
|
|||
|
|
@ -71,4 +71,7 @@ public interface ShopUserMapper extends BaseMapper<ShopUser> {
|
|||
* @return 分页结果
|
||||
*/
|
||||
List<InviteUserVO> getInviteUser(Long distributionUserId, Long shopUserId);
|
||||
|
||||
void updateOneOrTwoAmount(Long userId, Long mainShopId, BigDecimal bigDecimal, Integer isOne);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,5 +14,5 @@ import java.math.BigDecimal;
|
|||
*/
|
||||
public interface UserInfoMapper extends BaseMapper<UserInfo> {
|
||||
|
||||
int updateAmount(long userId, BigDecimal amount, Integer isOne);
|
||||
int updateAmount(long userId, BigDecimal amount);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -169,4 +169,9 @@ public class ShopUserServiceImpl extends ServiceImpl<ShopUserMapper, ShopUser> i
|
|||
|
||||
return list(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateOneOrTwoAmount(Long userId, Long mainShopId, BigDecimal bigDecimal, Integer isOne) {
|
||||
mapper.updateOneOrTwoAmount(userId, mainShopId, bigDecimal, isOne);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -101,8 +101,8 @@ public class UserInfoServiceImpl extends ServiceImpl<UserInfoMapper, UserInfo> i
|
|||
}
|
||||
|
||||
@Override
|
||||
public void updateDistributionAmount(long userId, BigDecimal amount, Integer isOne) {
|
||||
int b = mapper.updateAmount(userId, amount, isOne);
|
||||
public void updateDistributionAmount(long userId, BigDecimal amount) {
|
||||
int b = mapper.updateAmount(userId, amount);
|
||||
if (b <= 0) {
|
||||
throw new CzgException("更新分销金额失败");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,20 @@
|
|||
where id = #{id}
|
||||
and amount - #{money} >= 0
|
||||
</update>
|
||||
<update id="updateOneOrTwoAmount">
|
||||
update tb_shop_user
|
||||
<set>
|
||||
<if test="isOne != null and isOne == 1">
|
||||
one_income = one_income + #{amount}
|
||||
</if>
|
||||
<if test="isOne != null and isOne == 2">
|
||||
two_income = two_income + #{amount}
|
||||
</if>
|
||||
</set>
|
||||
where user_id = #{userId}
|
||||
and shop_id = #{shopId}
|
||||
</update>
|
||||
|
||||
|
||||
|
||||
<select id="selectUserSummary" resultType="com.czg.account.dto.shopuser.ShopUserSummaryDTO">
|
||||
|
|
|
|||
|
|
@ -8,12 +8,6 @@
|
|||
update tb_user_info
|
||||
<set>
|
||||
distribution_amount = distribution_amount + #{amount}
|
||||
<if test="isOne != null and isOne == 1">
|
||||
, one_income = one_income + #{amount}
|
||||
</if>
|
||||
<if test="isOne != null and isOne == 2">
|
||||
, two_income = two_income + #{amount}
|
||||
</if>
|
||||
</set>
|
||||
where id = #{userId}
|
||||
and distribution_amount + #{amount} >= 0
|
||||
|
|
|
|||
|
|
@ -618,7 +618,7 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
|
|||
distributionFlowService.save(mkDistributionFlow);
|
||||
|
||||
updateIncome(!flag ? rewardAmount : BigDecimal.ZERO,
|
||||
flag ? rewardAmount : BigDecimal.ZERO, BigDecimal.ZERO, distributionUser.getId(), shopUser.getUserId(), currentLevel == 1 ? 1 : 2);
|
||||
flag ? rewardAmount : BigDecimal.ZERO, BigDecimal.ZERO, distributionUser.getId(), shopUser.getUserId(), shopUser.getMainShopId(), currentLevel == 1 ? 1 : 2);
|
||||
|
||||
if (flag) {
|
||||
distributionAmountFlowService.save(new MkDistributionAmountFlow()
|
||||
|
|
@ -649,8 +649,9 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
|
|||
}
|
||||
|
||||
@Override
|
||||
public void updateIncome(BigDecimal pendingIncome, BigDecimal receivedIncome, BigDecimal withdrawIncome, Long id, Long userId, Integer isOne) {
|
||||
userInfoService.updateDistributionAmount(userId, receivedIncome, isOne);
|
||||
public void updateIncome(BigDecimal pendingIncome, BigDecimal receivedIncome, BigDecimal withdrawIncome, Long id, Long userId, Long mainShopId, Integer isOne) {
|
||||
shopUserService.updateOneOrTwoAmount(userId, mainShopId, receivedIncome == null ? pendingIncome : receivedIncome, isOne);
|
||||
userInfoService.updateDistributionAmount(userId, receivedIncome);
|
||||
boolean flag = mapper.updateIncome(pendingIncome, receivedIncome, withdrawIncome, id);
|
||||
if (!flag) {
|
||||
throw new CzgException("操作失败");
|
||||
|
|
@ -676,7 +677,7 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
|
|||
JSONObject jsonObject = appWxService.transferBalance(userInfo.getWechatOpenId(), userInfo.getRealName(), finalAmount, "提现", withdrawFlow.getBillNo());
|
||||
withdrawFlow.setPackageInfo(jsonObject.getString("package_info"));
|
||||
// 扣减余额
|
||||
userInfoService.updateDistributionAmount(userId, withdrawFlowDTO.getAmount().negate(), null);
|
||||
userInfoService.updateDistributionAmount(userId, withdrawFlowDTO.getAmount().negate());
|
||||
return withdrawFlowService.save(withdrawFlow);
|
||||
}
|
||||
|
||||
|
|
@ -707,7 +708,7 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
|
|||
case "CANCELLED":
|
||||
flow.setStatus(TableValueConstant.DistributionWithdrawFlow.Status.FAIL.getCode());
|
||||
// 扣减余额
|
||||
userInfoService.updateDistributionAmount(flow.getUserId(), flow.getAmount().add(flow.getServiceFee()), null);
|
||||
userInfoService.updateDistributionAmount(flow.getUserId(), flow.getAmount().add(flow.getServiceFee()));
|
||||
break;
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue