|
|
@@ -647,6 +647,7 @@ public class UserLogic {
|
|
|
.setUserId(user.getUserId())
|
|
|
.setId(IdWorker.getIdStr())
|
|
|
.setCreditLimit(creditLimitBigDecimal)
|
|
|
+ .setAvailableCredit(creditLimitBigDecimal)
|
|
|
.setBillingDay(billingDayInt)
|
|
|
.setPaymentGracePeriod(paymentGracePeriodInt)
|
|
|
.setCreateTime(curDate);
|
|
|
@@ -657,6 +658,46 @@ public class UserLogic {
|
|
|
userCompanyCreditService.saveBatch(userCompanyCreditList);
|
|
|
}
|
|
|
|
|
|
+ public void companyCreditAdd(UserCompanyCredit userCompanyCredit) {
|
|
|
+ AdminUserCom adminUser = commonLogic.getAdminUser();
|
|
|
+ if (StringUtils.isBlank(adminUser.getCompanyWechatId())) {
|
|
|
+ throw new RemoteServiceException("管理员账号不可操作");
|
|
|
+ }
|
|
|
+
|
|
|
+ final User user = userService.getById(userCompanyCredit.getUserId());
|
|
|
+
|
|
|
+ if (Objects.isNull(user)) {
|
|
|
+ throw new RemoteServiceException("没有找到对应师傅信息");
|
|
|
+ }
|
|
|
+
|
|
|
+ final Integer count = userCompanyCreditService.lambdaQuery()
|
|
|
+ .eq(UserCompanyCredit::getUserId, user.getUserId())
|
|
|
+ .eq(UserCompanyCredit::getCompanyWechatId, adminUser.getCompanyWechatId())
|
|
|
+ .count();
|
|
|
+
|
|
|
+ if (count > 0) {
|
|
|
+ throw new RemoteServiceException("已配置授信记录");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (userCompanyCredit.getCreditLimit().compareTo(BigDecimal.ZERO) <= 0) {
|
|
|
+ throw new RemoteServiceException("请填写正确的授权额度");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (userCompanyCredit.getBillingDay() < 1 || userCompanyCredit.getBillingDay() > 29) {
|
|
|
+ throw new RemoteServiceException("请填写正确的账单日(1-29)");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (userCompanyCredit.getPaymentGracePeriod() < 1 || userCompanyCredit.getPaymentGracePeriod() > 29) {
|
|
|
+ throw new RemoteServiceException("请填写正确的账期天数(1-30)");
|
|
|
+ }
|
|
|
+
|
|
|
+ userCompanyCredit.setId(IdWorker.getIdStr())
|
|
|
+ .setCompanyWechatId(adminUser.getCompanyWechatId())
|
|
|
+ .setCompanyWechatName(adminUser.getCompanyName())
|
|
|
+ .setAvailableCredit(userCompanyCredit.getCreditLimit())
|
|
|
+ .insert();
|
|
|
+ }
|
|
|
+
|
|
|
public void companyCreditEnabled(List<String> userIds, Boolean status) {
|
|
|
AdminUserCom adminUser = commonLogic.getAdminUser();
|
|
|
|