|
|
@@ -51,6 +51,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.io.IOException;
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.util.*;
|
|
|
import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
|
@@ -76,7 +77,7 @@ public class UserLogic {
|
|
|
private final PgOrderBaseService pgOrderBaseService;
|
|
|
private final PgOrderWorkerService pgOrderWorkerService;
|
|
|
private final UserCompanyDeliveryService userCompanyDeliveryService;
|
|
|
-
|
|
|
+ private final UserCompanyAttrService userCompanyAttrService;
|
|
|
|
|
|
/**
|
|
|
* 客户列表-v2
|
|
|
@@ -532,4 +533,113 @@ public class UserLogic {
|
|
|
AdminUserCom adminUser = commonLogic.getAdminUser();
|
|
|
return commonMapper.companyCredit(new Page<>(pageNum, pageSize), adminUser.getCompanyWechatId(), nickName, mobile);
|
|
|
}
|
|
|
+
|
|
|
+ public void companyCreditImport(List<Object> datas) {
|
|
|
+ AdminUserCom adminUser = commonLogic.getAdminUser();
|
|
|
+ if (StringUtils.isBlank(adminUser.getCompanyWechatId())) {
|
|
|
+ throw new RemoteServiceException("管理员账号不可操作");
|
|
|
+ }
|
|
|
+ int index = 1;
|
|
|
+
|
|
|
+ final DateTime curDate = DateUtil.date();
|
|
|
+
|
|
|
+ List<UserCompanyAttr> userCompanyAttrList = new ArrayList<>();
|
|
|
+ for (Object o : datas) {
|
|
|
+ index++;
|
|
|
+ String errPrefix = "第" + index + "行";
|
|
|
+ List<Object> row = (List<Object>) o;
|
|
|
+ CommonUtils.initList2(row, 10);
|
|
|
+ String mobile = (String) row.get(0);
|
|
|
+ // 授权额度
|
|
|
+ String creditLimit = (String) row.get(0);
|
|
|
+ // 账单日(1-28),如果是29表示月末
|
|
|
+ String billingDay = (String) row.get(0);
|
|
|
+ // 账期天数(1-30天)
|
|
|
+ String paymentGracePeriod = (String) row.get(0);
|
|
|
+
|
|
|
+ if (StringUtils.isAnyBlank(mobile, creditLimit, billingDay, paymentGracePeriod)) {
|
|
|
+ throw new RemoteServiceException(errPrefix + "橙色区域为必填项");
|
|
|
+ }
|
|
|
+
|
|
|
+ final User user = userService.lambdaQuery()
|
|
|
+ .eq(User::getMobile, mobile)
|
|
|
+ .one();
|
|
|
+
|
|
|
+ if (Objects.isNull(user)) {
|
|
|
+ throw new RemoteServiceException(errPrefix + " 没有找到对应师傅信息");
|
|
|
+ }
|
|
|
+
|
|
|
+ final Integer count = userCompanyAttrService.lambdaQuery()
|
|
|
+ .eq(UserCompanyAttr::getUserId, user.getUserId())
|
|
|
+ .eq(UserCompanyAttr::getCompanyWechatId, adminUser.getCompanyWechatId())
|
|
|
+ .count();
|
|
|
+
|
|
|
+ if (count > 0) {
|
|
|
+ throw new RemoteServiceException(errPrefix + " " + mobile + "已配置授信记录");
|
|
|
+ }
|
|
|
+
|
|
|
+ BigDecimal creditLimitBigDecimal;
|
|
|
+ try {
|
|
|
+ creditLimitBigDecimal = new BigDecimal(creditLimit);
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new RemoteServiceException(errPrefix + " 请填写正确的授权额度");
|
|
|
+ }
|
|
|
+
|
|
|
+ Integer billingDayInt;
|
|
|
+ try {
|
|
|
+ billingDayInt = new Integer(billingDay);
|
|
|
+ if (billingDayInt < 1 || billingDayInt > 29) {
|
|
|
+ throw new RuntimeException();
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new RemoteServiceException(errPrefix + " 请填写正确的账单日(1-29)");
|
|
|
+ }
|
|
|
+
|
|
|
+ Integer paymentGracePeriodInt;
|
|
|
+ try {
|
|
|
+ paymentGracePeriodInt = new Integer(paymentGracePeriod);
|
|
|
+ if (paymentGracePeriodInt < 1 || paymentGracePeriodInt > 30) {
|
|
|
+ throw new RuntimeException();
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new RemoteServiceException(errPrefix + " 请填写正确的账期天数(1-30)");
|
|
|
+ }
|
|
|
+
|
|
|
+ UserCompanyAttr attr = new UserCompanyAttr();
|
|
|
+ attr.setCompanyWechatId(adminUser.getCompanyWechatId())
|
|
|
+ .setCompanyWechatName(adminUser.getCompanyName())
|
|
|
+ .setUserId(user.getUserId())
|
|
|
+ .setId(IdWorker.getIdStr())
|
|
|
+ .setCreditLimit(creditLimitBigDecimal)
|
|
|
+ .setBillingDay(billingDayInt)
|
|
|
+ .setPaymentGracePeriod(paymentGracePeriodInt)
|
|
|
+ .setCreateTime(curDate);
|
|
|
+
|
|
|
+ userCompanyAttrList.add(attr);
|
|
|
+ }
|
|
|
+
|
|
|
+ userCompanyAttrService.saveBatch(userCompanyAttrList);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void companyCreditEnabled(List<String> userIds, Boolean status) {
|
|
|
+ AdminUserCom adminUser = commonLogic.getAdminUser();
|
|
|
+
|
|
|
+ userCompanyAttrService.lambdaUpdate()
|
|
|
+ .set(UserCompanyAttr::getIsCreditEnabled, status)
|
|
|
+ .set(UserCompanyAttr::getUpdateTime, DateUtil.date())
|
|
|
+ .eq(UserCompanyAttr::getCompanyWechatId, adminUser.getCompanyWechatId())
|
|
|
+ .in(UserCompanyAttr::getUserId, userIds)
|
|
|
+ .update();
|
|
|
+ }
|
|
|
+
|
|
|
+ public void companyCreditDel(String userId) {
|
|
|
+ AdminUserCom adminUser = commonLogic.getAdminUser();
|
|
|
+
|
|
|
+ // TODO 需要检查是否已产生授信数据或未还款账单
|
|
|
+
|
|
|
+// userCompanyDeliveryService.lambdaUpdate()
|
|
|
+// .eq(UserCompanyDelivery::getUserId, userId)
|
|
|
+// .eq(UserCompanyDelivery::getCompanyWechatId, adminUser.getCompanyWechatId())
|
|
|
+// .remove();
|
|
|
+ }
|
|
|
}
|