|
@@ -2977,23 +2977,33 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport |
|
@@ -2977,23 +2977,33 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport |
2977
|
}
|
2977
|
}
|
2978
|
|
2978
|
|
2979
|
/**
|
2979
|
/**
|
2980
|
- * 提现
|
2980
|
+ * 提现确认
|
2981
|
*/
|
2981
|
*/
|
2982
|
@Override
|
2982
|
@Override
|
2983
|
- @Database(ForceMaster = true)
|
|
|
2984
|
- public BigDecimal addSettlement(Integer uid) {
|
|
|
2985
|
- settlementLog.info("addSettlement enter,uid is {}",uid);
|
2983
|
+ public ShareSettlementRspBo checkSettlement(Integer uid){
|
|
|
2984
|
+ //提现条件判断,不可提现时会throw错误码
|
|
|
2985
|
+ JSONObject jsonObject=canSettlement(uid);
|
|
|
2986
|
+ BigDecimal preamount=(BigDecimal) jsonObject.get("preamount");
|
|
|
2987
|
+ ShareSettlementRspBo rspBo = new ShareSettlementRspBo();
|
|
|
2988
|
+ rspBo.setSettlementAmount(preamount);
|
|
|
2989
|
+ rspBo.setTaxAmount(getTaxAmount(preamount));
|
|
|
2990
|
+ rspBo.setAfterTaxAmount(preamount.subtract(rspBo.getTaxAmount()));
|
|
|
2991
|
+ return rspBo;
|
|
|
2992
|
+ }
|
|
|
2993
|
+
|
|
|
2994
|
+ /**
|
|
|
2995
|
+ * 提现条件判断,可提现返回银行卡
|
|
|
2996
|
+ */
|
|
|
2997
|
+ public JSONObject canSettlement(Integer uid){
|
|
|
2998
|
+ logger.info("canSettlement enter,uid is {}",uid);
|
2986
|
if (uid == null ) {
|
2999
|
if (uid == null ) {
|
2987
|
throw new ServiceException(ServiceError.USER_ID_ERROR);
|
3000
|
throw new ServiceException(ServiceError.USER_ID_ERROR);
|
2988
|
}
|
3001
|
}
|
2989
|
- //提现开关是否关闭
|
|
|
2990
|
-// boolean settlementSwitch=configReader.getBoolean(settlementSwitch,)
|
|
|
2991
|
-
|
|
|
2992
|
//查询该用户是否为特邀用户
|
3002
|
//查询该用户是否为特邀用户
|
2993
|
int count = unionShareUserMapper.selectCountByUid(uid);
|
3003
|
int count = unionShareUserMapper.selectCountByUid(uid);
|
2994
|
if (count == 0) {
|
3004
|
if (count == 0) {
|
2995
|
//不是特邀用户
|
3005
|
//不是特邀用户
|
2996
|
- settlementLog.info("addSettlement end,can not find unionType,uid is {}",uid);
|
3006
|
+ settlementLog.info("canSettlement end,can not find unionType,uid is {}",uid);
|
2997
|
throw new ServiceException(ServiceError.USER_ID_ERROR);
|
3007
|
throw new ServiceException(ServiceError.USER_ID_ERROR);
|
2998
|
}
|
3008
|
}
|
2999
|
|
3009
|
|
|
@@ -3003,14 +3013,14 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport |
|
@@ -3003,14 +3013,14 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport |
3003
|
req.setStatus((byte)1);
|
3013
|
req.setStatus((byte)1);
|
3004
|
List<UnionShareUserBank> bankCardList = unionShareUserBankMapper.selectByUid(req);
|
3014
|
List<UnionShareUserBank> bankCardList = unionShareUserBankMapper.selectByUid(req);
|
3005
|
if (CollectionUtils.isEmpty(bankCardList) || null == bankCardList.get(0)) {
|
3015
|
if (CollectionUtils.isEmpty(bankCardList) || null == bankCardList.get(0)) {
|
3006
|
- settlementLog.info("addSettlement end,can not find available bank card,uid is {}",uid);
|
3016
|
+ settlementLog.info("canSettlement end,can not find available bank card,uid is {}",uid);
|
3007
|
throw new ServiceException(ServiceError.UNION_HASNOT_AVAILABLE_CARD);
|
3017
|
throw new ServiceException(ServiceError.UNION_HASNOT_AVAILABLE_CARD);
|
3008
|
}
|
3018
|
}
|
3009
|
|
3019
|
|
3010
|
//查询是否有处理中的提现
|
3020
|
//查询是否有处理中的提现
|
3011
|
if (hasSettlement(uid)) {
|
3021
|
if (hasSettlement(uid)) {
|
3012
|
//有处理中的提现单,不可提现
|
3022
|
//有处理中的提现单,不可提现
|
3013
|
- settlementLog.info("addSettlement end,hasSettlement,uid is {}",uid);
|
3023
|
+ settlementLog.info("canSettlement end,hasSettlement,uid is {}",uid);
|
3014
|
throw new ServiceException(ServiceError.UNION_HASSETTLEMENT_ERROR);
|
3024
|
throw new ServiceException(ServiceError.UNION_HASSETTLEMENT_ERROR);
|
3015
|
}
|
3025
|
}
|
3016
|
|
3026
|
|
|
@@ -3018,7 +3028,7 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport |
|
@@ -3018,7 +3028,7 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport |
3018
|
int orderCount = unionShareOrdersMapper.selectCountByCondition(uid,ShareOrdersStatusEnum.CAN_SETTLE.getCode());
|
3028
|
int orderCount = unionShareOrdersMapper.selectCountByCondition(uid,ShareOrdersStatusEnum.CAN_SETTLE.getCode());
|
3019
|
if (orderCount == 0 ) {
|
3029
|
if (orderCount == 0 ) {
|
3020
|
//没有可以提现的订单
|
3030
|
//没有可以提现的订单
|
3021
|
- settlementLog.info("addSettlement end,has not remaining settlement,uid is {}",uid);
|
3031
|
+ settlementLog.info("canSettlement end,has not remaining settlement,uid is {}",uid);
|
3022
|
throw new ServiceException(ServiceError.UNION_HASNOT_REMAINING_SETTLEMENT);
|
3032
|
throw new ServiceException(ServiceError.UNION_HASNOT_REMAINING_SETTLEMENT);
|
3023
|
}
|
3033
|
}
|
3024
|
//查询当前可提现金额是否不小于50
|
3034
|
//查询当前可提现金额是否不小于50
|
|
@@ -3026,13 +3036,28 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport |
|
@@ -3026,13 +3036,28 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport |
3026
|
Integer minimumAmount=configReader.getInt(UNION_CPS_SETTLEMENT_AMOUNT_MIN, 50);
|
3036
|
Integer minimumAmount=configReader.getInt(UNION_CPS_SETTLEMENT_AMOUNT_MIN, 50);
|
3027
|
if (preamount.compareTo(new BigDecimal(minimumAmount))<0 ) {
|
3037
|
if (preamount.compareTo(new BigDecimal(minimumAmount))<0 ) {
|
3028
|
//没有可以提现的订单
|
3038
|
//没有可以提现的订单
|
3029
|
- settlementLog.info("addSettlement end,settlement lower than {},uid is {},preamount is {}",minimumAmount,uid,preamount);
|
3039
|
+ settlementLog.info("canSettlement end,settlement lower than {},uid is {},preamount is {}",minimumAmount,uid,preamount);
|
3030
|
ServiceException serviceException = new ServiceException(ServiceError.UNION_HASNOT_ENOUGH_SETTLEMENT,false,minimumAmount);
|
3040
|
ServiceException serviceException = new ServiceException(ServiceError.UNION_HASNOT_ENOUGH_SETTLEMENT,false,minimumAmount);
|
3031
|
serviceException.setParams(minimumAmount.toString());
|
3041
|
serviceException.setParams(minimumAmount.toString());
|
3032
|
throw serviceException;
|
3042
|
throw serviceException;
|
3033
|
}
|
3043
|
}
|
|
|
3044
|
+ JSONObject result = new JSONObject();
|
|
|
3045
|
+ result.put("bankcard", bankCardList.get(0));
|
|
|
3046
|
+ result.put("preamount", preamount);
|
|
|
3047
|
+ return result;
|
|
|
3048
|
+ }
|
|
|
3049
|
+ /**
|
|
|
3050
|
+ * 提现
|
|
|
3051
|
+ */
|
|
|
3052
|
+ @Override
|
|
|
3053
|
+ @Database(ForceMaster = true)
|
|
|
3054
|
+ public BigDecimal addSettlement(Integer uid) {
|
|
|
3055
|
+ settlementLog.info("addSettlement enter,uid is {}",uid);
|
|
|
3056
|
+ //提现条件判断,可提现返回银行卡
|
|
|
3057
|
+ JSONObject jsonObject=canSettlement(uid);
|
|
|
3058
|
+ UnionShareUserBank bankCard=(UnionShareUserBank) jsonObject.get("bankcard");
|
3034
|
// 生成取现单,绑定订单
|
3059
|
// 生成取现单,绑定订单
|
3035
|
- BigDecimal amount = relateSettlementAndOrder(uid,bankCardList.get(0));
|
3060
|
+ BigDecimal amount = relateSettlementAndOrder(uid,bankCard);
|
3036
|
settlementLog.info("addSettlement end,remaining settlement is {},uid is {}",amount,uid);
|
3061
|
settlementLog.info("addSettlement end,remaining settlement is {},uid is {}",amount,uid);
|
3037
|
return amount;
|
3062
|
return amount;
|
3038
|
}
|
3063
|
}
|
|
@@ -3206,7 +3231,7 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport |
|
@@ -3206,7 +3231,7 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport |
3206
|
return totalAmount;
|
3231
|
return totalAmount;
|
3207
|
}
|
3232
|
}
|
3208
|
|
3233
|
|
3209
|
- //扣税金额计算
|
3234
|
+ //扣税金额计算,保留两位小数,多余位舍弃
|
3210
|
private BigDecimal getTaxAmount(BigDecimal amount) {
|
3235
|
private BigDecimal getTaxAmount(BigDecimal amount) {
|
3211
|
// 假设佣金为X
|
3236
|
// 假设佣金为X
|
3212
|
// 增值税(B) 城建税 教育费 地方教育 个人所得税 到手佣金
|
3237
|
// 增值税(B) 城建税 教育费 地方教育 个人所得税 到手佣金
|
|
@@ -3222,18 +3247,18 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport |
|
@@ -3222,18 +3247,18 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport |
3222
|
return new BigDecimal(0);
|
3247
|
return new BigDecimal(0);
|
3223
|
}
|
3248
|
}
|
3224
|
if (amount.compareTo(new BigDecimal(824))<1) {
|
3249
|
if (amount.compareTo(new BigDecimal(824))<1) {
|
3225
|
- return amount.multiply(new BigDecimal("336")).divide(new BigDecimal("10300")).setScale(2,BigDecimal.ROUND_DOWN);
|
3250
|
+ return amount.multiply(new BigDecimal("336")).divide(new BigDecimal("10300"),2,BigDecimal.ROUND_DOWN);
|
3226
|
}
|
3251
|
}
|
3227
|
if (amount.compareTo(new BigDecimal(4120))<1) {
|
3252
|
if (amount.compareTo(new BigDecimal(4120))<1) {
|
3228
|
- return amount.multiply(new BigDecimal("2336")).divide(new BigDecimal("10300")).setScale(2,BigDecimal.ROUND_DOWN).subtract(new BigDecimal("160"));
|
3253
|
+ return amount.multiply(new BigDecimal("2336")).divide(new BigDecimal("10300"),2,BigDecimal.ROUND_DOWN).subtract(new BigDecimal("160"));
|
3229
|
}
|
3254
|
}
|
3230
|
if (amount.compareTo(new BigDecimal(20600))<1) {
|
3255
|
if (amount.compareTo(new BigDecimal(20600))<1) {
|
3231
|
- return amount.multiply(new BigDecimal("1936")).divide(new BigDecimal("10300")).setScale(2,BigDecimal.ROUND_DOWN);
|
3256
|
+ return amount.multiply(new BigDecimal("1936")).divide(new BigDecimal("10300"),2,BigDecimal.ROUND_DOWN);
|
3232
|
}
|
3257
|
}
|
3233
|
if (amount.compareTo(new BigDecimal(51500))<1) {
|
3258
|
if (amount.compareTo(new BigDecimal(51500))<1) {
|
3234
|
- return amount.multiply(new BigDecimal("2736")).divide(new BigDecimal("10300")).setScale(2,BigDecimal.ROUND_DOWN).subtract(new BigDecimal("2000"));
|
3259
|
+ return amount.multiply(new BigDecimal("2736")).divide(new BigDecimal("10300"),2,BigDecimal.ROUND_DOWN).subtract(new BigDecimal("2000"));
|
3235
|
}
|
3260
|
}
|
3236
|
- return amount.multiply(new BigDecimal("3536")).divide(new BigDecimal("10300")).setScale(2,BigDecimal.ROUND_DOWN).subtract(new BigDecimal("7000"));
|
3261
|
+ return amount.multiply(new BigDecimal("3536")).divide(new BigDecimal("10300"),2,BigDecimal.ROUND_DOWN).subtract(new BigDecimal("7000"));
|
3237
|
}
|
3262
|
}
|
3238
|
|
3263
|
|
3239
|
/**
|
3264
|
/**
|