|
@@ -1,10 +1,26 @@
|
|
|
package com.yh.saas.plugin.yiliangyiyun.service.impl;
|
|
|
|
|
|
-import com.yh.saas.plugin.yiliangyiyun.entity.DriverInfo;
|
|
|
+import com.baomidou.mybatisplus.mapper.EntityWrapper;
|
|
|
+import com.winsea.svc.base.security.util.AuthSecurityUtils;
|
|
|
+import com.yh.saas.common.support.util.IdGenerator;
|
|
|
+import com.yh.saas.common.support.util.StringUtils;
|
|
|
+import com.yh.saas.plugin.yiliangyiyun.constant.NumberConstant;
|
|
|
+import com.yh.saas.plugin.yiliangyiyun.constant.StatusEnum;
|
|
|
+import com.yh.saas.plugin.yiliangyiyun.entity.*;
|
|
|
+import com.yh.saas.plugin.yiliangyiyun.exception.YException;
|
|
|
+import com.yh.saas.plugin.yiliangyiyun.exception.YExceptionEnum;
|
|
|
import com.yh.saas.plugin.yiliangyiyun.mapper.DriverInfoMapper;
|
|
|
+import com.yh.saas.plugin.yiliangyiyun.service.IDriverCarInfoService;
|
|
|
import com.yh.saas.plugin.yiliangyiyun.service.IDriverInfoService;
|
|
|
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
|
|
|
+import com.yh.saas.plugin.yiliangyiyun.service.IDriverPayeeInfoService;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
+
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -17,4 +33,170 @@ import org.springframework.stereotype.Service;
|
|
|
@Service
|
|
|
public class DriverInfoServiceImpl extends ServiceImpl<DriverInfoMapper, DriverInfo> implements IDriverInfoService {
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IDriverCarInfoService driverCarInfoService;
|
|
|
+ @Autowired
|
|
|
+ private IDriverPayeeInfoService driverPayeeInfoService;
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 添加信息
|
|
|
+ *
|
|
|
+ * @param
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public String addInfo(DriverInfo driverViewInfo) {
|
|
|
+ //新增主键id
|
|
|
+ driverViewInfo.setId(IdGenerator.generateUUID());
|
|
|
+ //判断司机电话是否唯一
|
|
|
+ List<DriverInfo> driverViewInfos =
|
|
|
+ this.selectList(new EntityWrapper<DriverInfo>()
|
|
|
+ .eq("driver_phone", driverViewInfo.getDriverPhone())
|
|
|
+ .eq("delete_flag", NumberConstant.CONSTANT0));
|
|
|
+ if (driverViewInfos.size() > 0) {
|
|
|
+ throw new YException(YExceptionEnum.DRIVER_PHONE_ERROR);
|
|
|
+ }
|
|
|
+ driverViewInfo.setAuthenticationStatus(StatusEnum.IDENTITY_COMPLETED.getName());
|
|
|
+ driverViewInfo.setAuthenticationStatusKey(StatusEnum.IDENTITY_COMPLETED.getFlag());
|
|
|
+ //判断司机身份证号是否唯一
|
|
|
+ List<DriverInfo> driverViewInfoList =
|
|
|
+ this.selectList(new EntityWrapper<DriverInfo>()
|
|
|
+ .eq("number_card", driverViewInfo.getNumberCard())
|
|
|
+ .eq("delete_flag", NumberConstant.CONSTANT0));
|
|
|
+ if (driverViewInfoList.size() > 0) {
|
|
|
+ throw new YException(YExceptionEnum.DRIVER_NUMBER_ERROR);
|
|
|
+ }
|
|
|
+ //货车信息新增
|
|
|
+ List<DriverCarInfo> driverCarInfoList = driverViewInfo.getDriverCarInfoList();
|
|
|
+ if (!CollectionUtils.isEmpty(driverCarInfoList)) {
|
|
|
+ for (DriverCarInfo driverCarInfo : driverCarInfoList) {
|
|
|
+ driverCarInfo.setId(IdGenerator.generateUUID());
|
|
|
+ driverCarInfo.setDriverId(driverViewInfo.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //收款人账户信息新增
|
|
|
+ List<DriverPayeeInfo> driverPayeeInfoList = driverViewInfo.getDriverPayeeInfoList();
|
|
|
+ if (!CollectionUtils.isEmpty(driverPayeeInfoList)) {
|
|
|
+ for (DriverPayeeInfo driverPayeeInfo : driverPayeeInfoList) {
|
|
|
+ driverPayeeInfo.setId(IdGenerator.generateUUID());
|
|
|
+ driverPayeeInfo.setDriverId(driverViewInfo.getId());
|
|
|
+ //判断收款人身份证号是否唯一
|
|
|
+// List<DriverPayeeInfo> driverPayeeInfos =
|
|
|
+// driverPayeeInfoService.selectList(new EntityWrapper<DriverPayeeInfo>()
|
|
|
+// .eq(DriverPayeeInfo.QueryFiles.PAYEE_NUMBER_CARD, driverPayeeInfo.getPayeeNumberCard())
|
|
|
+// .eq(DriverPayeeInfo.QueryFiles.DELETE_FLAG, NumberConstant.CONSTANT0));
|
|
|
+// if (driverPayeeInfos.size() > 0) {
|
|
|
+// throw new YException(YExceptionEnum.PAYEE_NUMBER_ERROR);
|
|
|
+// }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ boolean one = this.insert(driverViewInfo);
|
|
|
+ boolean two = driverCarInfoService.insertBatch(driverCarInfoList);
|
|
|
+ boolean three = driverPayeeInfoService.insertBatch(driverPayeeInfoList);
|
|
|
+ // 假如 都成功返回ok
|
|
|
+ if (one && two && three) {
|
|
|
+ return "OK";
|
|
|
+ } else {
|
|
|
+ return "NG";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 编辑信息
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public String editInfo(DriverInfo driverViewInfo) {
|
|
|
+ //主表信息编辑
|
|
|
+ this.updateById(driverViewInfo);
|
|
|
+ //货车信息编辑
|
|
|
+ List<DriverCarInfo> driverCarInfoList = driverViewInfo.getDriverCarInfoList();
|
|
|
+ if (!CollectionUtils.isEmpty(driverCarInfoList)) {
|
|
|
+ for (DriverCarInfo driverCarInfo : driverCarInfoList) {
|
|
|
+ if (StringUtils.isEmpty(driverCarInfo.getId())) {
|
|
|
+ driverCarInfo.setId(IdGenerator.generateUUID());
|
|
|
+ driverCarInfo.setDriverId(driverViewInfo.getId());
|
|
|
+ driverCarInfoService.insert(driverCarInfo);
|
|
|
+ } else {
|
|
|
+ driverCarInfoService.updateById(driverCarInfo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //收款人账户信息编辑
|
|
|
+ List<DriverPayeeInfo> driverPayeeInfoList = driverViewInfo.getDriverPayeeInfoList();
|
|
|
+ if (!CollectionUtils.isEmpty(driverPayeeInfoList)) {
|
|
|
+ for (DriverPayeeInfo driverPayeeInfo : driverPayeeInfoList) {
|
|
|
+ if (StringUtils.isEmpty(driverPayeeInfo.getId())) {
|
|
|
+ driverPayeeInfo.setId(IdGenerator.generateUUID());
|
|
|
+ driverPayeeInfo.setDriverId(driverViewInfo.getId());
|
|
|
+ driverPayeeInfoService.insert(driverPayeeInfo);
|
|
|
+ } else {
|
|
|
+ driverPayeeInfoService.updateById(driverPayeeInfo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return "OK";
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 审核
|
|
|
+ *
|
|
|
+ * @param driverViewInfo
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public String examine(DriverInfo driverViewInfo) {
|
|
|
+ //查询司机列表
|
|
|
+ DriverInfo driverViewInfo1 = this.selectById(driverViewInfo.getId());
|
|
|
+
|
|
|
+ if (driverViewInfo1 != null) {
|
|
|
+ //通过
|
|
|
+// if (driverViewInfo.getFlag() == 1) {
|
|
|
+// driverViewInfo1.setAuthenticationStatusKey(StatusEnum.IDENTITY_COMPLETED.getFlag());
|
|
|
+// driverViewInfo1.setAuthenticationStatus(StatusEnum.IDENTITY_COMPLETED.getName());
|
|
|
+// geTuiUtils.pushByCid("审核通知", "您的司机认证申请已审核通过", commonUser.getId());
|
|
|
+// UnimallMessage messageDO = new UnimallMessage();
|
|
|
+// messageDO.setAdminId(commonUser.getId());
|
|
|
+// messageDO.setCustomer(commonUser.getUserName());
|
|
|
+// messageDO.setOperation("审核通知");
|
|
|
+// messageDO.setResult("您的司机认证申请已审核通过");
|
|
|
+// messageDO.setGmtUpdate(new java.util.Date());
|
|
|
+// messageDO.setGmtCreate(new Date());
|
|
|
+// messageDO.setTaskId(IdGenerator.generateUUID());
|
|
|
+// messageDO.setCompanyId(AuthSecurityUtils.getCurrentUserInfo().getCompId());
|
|
|
+// messageDO.setPath("XXXXX");
|
|
|
+// webSocket.sendOneMessage(messageDO);
|
|
|
+// }
|
|
|
+ //驳回
|
|
|
+// else {
|
|
|
+// driverViewInfo1.setAuthenticationStatusKey(StatusEnum.IDENTITY_FAILED.getFlag());
|
|
|
+// driverViewInfo1.setAuthenticationStatus(StatusEnum.IDENTITY_FAILED.getName());
|
|
|
+// geTuiUtils.pushByCid("驳回通知", "您的司机认证申请已被驳回", commonUser.getId());
|
|
|
+// UnimallMessage messageDO = new UnimallMessage();
|
|
|
+// messageDO.setAdminId(commonUser.getId());
|
|
|
+// messageDO.setCustomer(commonUser.getUserName());
|
|
|
+// messageDO.setOperation("驳回通知");
|
|
|
+// messageDO.setResult("您的司机认证申请已被驳回");
|
|
|
+// messageDO.setGmtUpdate(new java.util.Date());
|
|
|
+// messageDO.setGmtCreate(new Date());
|
|
|
+// messageDO.setTaskId(IdGenerator.generateUUID());
|
|
|
+// messageDO.setCompanyId(AuthSecurityUtils.getCurrentUserInfo().getCompId());
|
|
|
+// messageDO.setPath("XXXXX");
|
|
|
+// webSocket.sendOneMessage(messageDO);
|
|
|
+// }
|
|
|
+ //更改司机信息
|
|
|
+ this.updateById(driverViewInfo1);
|
|
|
+ return "OK";
|
|
|
+ }
|
|
|
+ return "NG";
|
|
|
+ }
|
|
|
+
|
|
|
}
|