|
@@ -18,6 +18,8 @@ import com.gree.mall.manager.plus.service.AdminWebsitService;
|
|
|
import com.gree.mall.manager.plus.service.SettleDailyBankAccountService;
|
|
|
import com.gree.mall.manager.plus.service.UserService;
|
|
|
import com.gree.mall.manager.plus.service.WebsitUserService;
|
|
|
+import com.gree.mall.manager.utils.CommonUtils;
|
|
|
+import com.gree.mall.manager.utils.excel.ExcelUtils;
|
|
|
import com.gree.mall.manager.zfire.bean.ZfireParamBean;
|
|
|
import com.gree.mall.manager.zfire.util.FieldUtils;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
@@ -25,6 +27,7 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
@@ -125,8 +128,127 @@ public class RepairSettleAccountLogic {
|
|
|
}
|
|
|
|
|
|
public void update(SettleDailyBankAccount dailyBankAccount) {
|
|
|
+// AdminUserCom adminUser = commonLogic.getAdminUser();
|
|
|
+
|
|
|
+ final SettleDailyBankAccount oldAccount = settleDailyBankAccountService.getById(dailyBankAccount.getId());
|
|
|
+ dailyBankAccount.setIdcard(oldAccount.getIdcard());
|
|
|
+
|
|
|
+ List<SettleDailyBankAccount> oldList = settleDailyBankAccountService.lambdaQuery()
|
|
|
+ .eq(SettleDailyBankAccount::getIdcard, dailyBankAccount.getIdcard())
|
|
|
+ .list();
|
|
|
+
|
|
|
+ for (SettleDailyBankAccount bean : oldList) {
|
|
|
+ bean.setId(dailyBankAccount.getId())
|
|
|
+ .setWorkerName(dailyBankAccount.getWorkerName())
|
|
|
+ .setMobile(dailyBankAccount.getMobile())
|
|
|
+ .setBankAccount(dailyBankAccount.getBankAccount())
|
|
|
+ .setBankAccountName(dailyBankAccount.getBankAccountName())
|
|
|
+ .setDepositBank(dailyBankAccount.getDepositBank())
|
|
|
+ .setBankAddr(dailyBankAccount.getBankAddr())
|
|
|
+ .setRemark(dailyBankAccount.getRemark());
|
|
|
+ }
|
|
|
+ settleDailyBankAccountService.updateBatchById(oldList);
|
|
|
}
|
|
|
|
|
|
public void delete(Integer id) {
|
|
|
+ settleDailyBankAccountService.removeById(id);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void importData(MultipartFile file) throws Exception {
|
|
|
+ AdminUserCom adminUser = commonLogic.getAdminUser();
|
|
|
+
|
|
|
+ if (adminUser.getType() == 2) {
|
|
|
+ throw new RemoteServiceException("平台账号禁止操作");
|
|
|
+ }
|
|
|
+ List<Object> objects = ExcelUtils.importExcel(file);
|
|
|
+ List<SettleDailyBankAccount> importList = new ArrayList<>();
|
|
|
+
|
|
|
+ List<String> distinctIdcard = new ArrayList<>();
|
|
|
+ for (Object o : objects) {
|
|
|
+ List<Object> row = (List<Object>) o;
|
|
|
+ CommonUtils.initList2(row, row.size() + 1);
|
|
|
+ String workerName = (String) row.get(0);//服务人员名称
|
|
|
+ String idcard = (String) row.get(1);//身份证号码
|
|
|
+ String mobile = (String) row.get(2);//手机号
|
|
|
+ String bankAccount = (String) row.get(3);//银行卡号
|
|
|
+ String bankAccountName = (String) row.get(4);//户名
|
|
|
+ String depositBank = (String) row.get(5);//开户行名称
|
|
|
+ String bankAddr = (String) row.get(6);//开户行地址
|
|
|
+ String remark = (String) row.get(7);//备注
|
|
|
+ if (StringUtils.isEmpty(workerName)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (StringUtils.isEmpty(workerName) || StringUtils.isEmpty(idcard) || StringUtils.isEmpty(bankAccount) ||
|
|
|
+ StringUtils.isEmpty(depositBank) || StringUtils.isEmpty(mobile) || StringUtils.isEmpty(bankAccountName)) {
|
|
|
+ throw new RemoteServiceException("师傅【" + workerName + "】服务人员名称/身份证号码/银行卡号/开户行名称/手机号/户名都为必填项");
|
|
|
+ }
|
|
|
+ if (!depositBank.contains("招商银行") && StringUtils.isEmpty(bankAddr)) {
|
|
|
+ throw new RemoteServiceException("师傅【" + workerName + "】非招行开户行必填");
|
|
|
+ }
|
|
|
+ if (distinctIdcard.contains(idcard)) {
|
|
|
+ throw new RemoteServiceException("师傅【" + workerName + "】身份证:" + idcard + "重复");
|
|
|
+ }
|
|
|
+ distinctIdcard.add(idcard);
|
|
|
+
|
|
|
+ List<User> userList = userService.lambdaQuery()
|
|
|
+ .eq(User::getCompanyWechatId, adminUser.getAdminCompanyWechat().getCompanyWechatId())
|
|
|
+ .eq(User::getIdCard, idcard)
|
|
|
+ .eq(User::getType, UserTypeEnum.WORKER.getKey())
|
|
|
+ .list();
|
|
|
+ if (CollectionUtil.isEmpty(userList)) {
|
|
|
+ throw new RemoteServiceException("身份证在系统不存在:" + idcard);
|
|
|
+ }
|
|
|
+ //删除
|
|
|
+ settleDailyBankAccountService.lambdaUpdate().eq(SettleDailyBankAccount::getIdcard, idcard).remove();
|
|
|
+
|
|
|
+ SettleDailyBankAccount dailyBankAccount = new SettleDailyBankAccount();
|
|
|
+ dailyBankAccount.setCompanyWechatId(adminUser.getAdminCompanyWechat().getCompanyWechatId());
|
|
|
+ dailyBankAccount.setCompanyName(adminUser.getAdminCompanyWechat().getCompanyName());
|
|
|
+ dailyBankAccount.setWorkerName(workerName);
|
|
|
+ dailyBankAccount.setIdcard(idcard);
|
|
|
+ dailyBankAccount.setMobile(mobile);
|
|
|
+ dailyBankAccount.setBankAccount(bankAccount);
|
|
|
+ dailyBankAccount.setBankAccountName(bankAccountName);
|
|
|
+ dailyBankAccount.setDepositBank(depositBank);
|
|
|
+ dailyBankAccount.setBankAddr(bankAddr);
|
|
|
+ dailyBankAccount.setRemark(remark);
|
|
|
+ dailyBankAccount.setBankAccount(dailyBankAccount.getBankAccount().replaceAll(" ", ""));
|
|
|
+
|
|
|
+ // 检查师傅已入驻网点并创建相应网点记录
|
|
|
+ final List<WebsitUser> websitUserList = websitUserService.lambdaQuery()
|
|
|
+ .eq(WebsitUser::getCompanyWechatId, adminUser.getAdminCompanyWechat().getCompanyWechatId())
|
|
|
+ .eq(WebsitUser::getExamineStatus, ExamineStatusEnum.OK.getKey())
|
|
|
+ .in(WebsitUser::getUserId, userList.stream().map(User::getUserId).distinct().collect(Collectors.toList()))
|
|
|
+ .list();
|
|
|
+
|
|
|
+ final List<String> websits = websitUserList.stream().map(WebsitUser::getWebsitId).distinct().collect(Collectors.toList());
|
|
|
+
|
|
|
+ final Map<String, WebsitUser> websitUserMap = websitUserList.stream()
|
|
|
+ .collect(Collectors.toMap(WebsitUser::getWebsitId, Function.identity(), (key1, key2) -> key2));
|
|
|
+
|
|
|
+ final List<AdminWebsit> adminWebsits = adminWebsitService.lambdaQuery()
|
|
|
+ .eq(AdminWebsit::getCompanyWechatId, adminUser.getAdminCompanyWechat().getCompanyWechatId())
|
|
|
+ .in(AdminWebsit::getWebsitId, websits)
|
|
|
+ .list();
|
|
|
+
|
|
|
+ final Map<String, String> websitMap = adminWebsits.stream()
|
|
|
+ .collect(Collectors.toMap(AdminWebsit::getWebsitId, AdminWebsit::getName));
|
|
|
+
|
|
|
+ for (String websit : websits) {
|
|
|
+ final String websitName = websitMap.get(websit);
|
|
|
+ final WebsitUser websitUser = websitUserMap.get(websit);
|
|
|
+ SettleDailyBankAccount account = new SettleDailyBankAccount();
|
|
|
+ BeanUtils.copyProperties(dailyBankAccount, account);
|
|
|
+ account.setCompanyWechatId(adminUser.getAdminCompanyWechat().getCompanyWechatId())
|
|
|
+ .setCompanyName(adminUser.getAdminCompanyWechat().getCompanyName())
|
|
|
+ .setWebsitId(websit)
|
|
|
+ .setWebsitName(websitName)
|
|
|
+ .setWorkerNumber(websitUser.getWorkerNumber());
|
|
|
+ importList.add(account);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (CollectionUtil.isNotEmpty(importList))
|
|
|
+ settleDailyBankAccountService.saveBatch(importList);
|
|
|
}
|
|
|
}
|