救援接口
This commit is contained in:
parent
26cc95e827
commit
a23cadaf6a
@ -1,12 +1,8 @@
|
||||
package cn.iocoder.yudao.module.custom.controller.admin;
|
||||
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import cn.hutool.http.HttpResponse;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.module.custom.entity.CustomerMain;
|
||||
import cn.iocoder.yudao.module.custom.service.CustomerCarService;
|
||||
import cn.iocoder.yudao.module.custom.service.CustomerMainService;
|
||||
import cn.iocoder.yudao.module.custom.vo.CustomerMainPageReqVO;
|
||||
import cn.iocoder.yudao.module.custom.vo.CustomerMainRespVO;
|
||||
@ -23,11 +19,7 @@ import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
import javax.validation.Valid;
|
||||
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.common.BaseConstants.*;
|
||||
@ -48,7 +40,8 @@ public class CustomerMainController {
|
||||
private CustomerMainService customerMainService;
|
||||
@Resource
|
||||
private BusiLabelService busiLabelService;
|
||||
|
||||
@Resource
|
||||
private CustomerCarService customerCarService;
|
||||
/**
|
||||
* 客户管理分页列表查询
|
||||
*
|
||||
@ -85,6 +78,14 @@ public class CustomerMainController {
|
||||
return success(true);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/saveCustomerAndCar")
|
||||
@Operation(summary = "保存客户及车辆信息")
|
||||
public CommonResult<Boolean> saveCustomerAndCar(@RequestBody CustomerMainSaveReqVO saveReqVO) throws Exception {
|
||||
customerCarService.saveCustomerAndCar(saveReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑客户
|
||||
*
|
||||
|
@ -1,6 +1,7 @@
|
||||
package cn.iocoder.yudao.module.custom.service;
|
||||
|
||||
import cn.iocoder.yudao.module.custom.entity.CustomerCar;
|
||||
import cn.iocoder.yudao.module.custom.vo.CustomerMainSaveReqVO;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
@ -23,4 +24,15 @@ public interface CustomerCarService extends IService<CustomerCar> {
|
||||
* @date 18:45 2024/8/3
|
||||
**/
|
||||
void bindCustomerCar(String mainId, String mainTable, List<CustomerCar> customerCars);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 保存客户及车辆信息
|
||||
* @author PQZ
|
||||
* @date 15:51 2024/11/12
|
||||
* @param saveReqVO CustomerMainSaveReqVO
|
||||
* @return void
|
||||
**/
|
||||
void saveCustomerAndCar(CustomerMainSaveReqVO saveReqVO) throws Exception;
|
||||
}
|
@ -1,19 +1,32 @@
|
||||
package cn.iocoder.yudao.module.custom.service.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
import cn.iocoder.yudao.module.custom.entity.CarMain;
|
||||
import cn.iocoder.yudao.module.custom.entity.CustomerCar;
|
||||
import cn.iocoder.yudao.module.custom.entity.CustomerMain;
|
||||
import cn.iocoder.yudao.module.custom.mapper.CustomerCarMapper;
|
||||
import cn.iocoder.yudao.module.custom.service.CarMainService;
|
||||
import cn.iocoder.yudao.module.custom.service.CustomerCarService;
|
||||
import cn.iocoder.yudao.module.custom.service.CustomerMainService;
|
||||
import cn.iocoder.yudao.module.custom.vo.CustomerMainSaveReqVO;
|
||||
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
||||
import cn.iocoder.yudao.module.system.api.user.dto.UserDTO;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.common.BaseConstants.CUS_SIGN_CAR;
|
||||
import static cn.iocoder.yudao.common.BaseConstants.CUS_SIGN_CUSTOMER;
|
||||
import static cn.iocoder.yudao.common.BaseConstants.*;
|
||||
import static cn.iocoder.yudao.framework.common.config.CommonStr.USER_TYPE_CUS;
|
||||
|
||||
/**
|
||||
* 客户车辆管理关联
|
||||
@ -24,6 +37,15 @@ import static cn.iocoder.yudao.common.BaseConstants.CUS_SIGN_CUSTOMER;
|
||||
@Validated
|
||||
public class CustomerCarServiceImpl extends ServiceImpl<CustomerCarMapper, CustomerCar> implements CustomerCarService {
|
||||
|
||||
@Resource
|
||||
@Lazy
|
||||
private CustomerMainService customerMainService;
|
||||
@Resource
|
||||
@Lazy
|
||||
private CarMainService carMainService;
|
||||
@Resource
|
||||
@Lazy
|
||||
private AdminUserApi adminUserApi;
|
||||
|
||||
/**
|
||||
* 保存客户与车辆的关联关系
|
||||
@ -60,4 +82,66 @@ public class CustomerCarServiceImpl extends ServiceImpl<CustomerCarMapper, Custo
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 保存客户及车辆信息
|
||||
*
|
||||
* @param saveReqVO CustomerMainSaveReqVO
|
||||
* @return void
|
||||
* @author PQZ
|
||||
* @date 15:51 2024/11/12
|
||||
**/
|
||||
@Override
|
||||
public void saveCustomerAndCar(CustomerMainSaveReqVO saveReqVO) throws Exception {
|
||||
chekData(saveReqVO);
|
||||
//用户信息
|
||||
AdminUserRespDTO userDTO = adminUserApi.getUserByUsername(saveReqVO.getPhoneNumber());
|
||||
UserDTO user = BeanUtils.toBean(userDTO, UserDTO.class);
|
||||
if (null == userDTO){
|
||||
user = new UserDTO();
|
||||
//如果不存在创建用户;
|
||||
user.setUsername(saveReqVO.getPhoneNumber());
|
||||
user.setNickname(saveReqVO.getCusName());
|
||||
//默认密码
|
||||
user.setPassword(PASSWORD_DEFAULT);
|
||||
user.setMobile(saveReqVO.getPhoneNumber());
|
||||
user.setUserType(USER_TYPE_CUS);
|
||||
//创建客户
|
||||
Long userId = adminUserApi.createUser(user);
|
||||
saveReqVO.setUserId(userId);
|
||||
} else {
|
||||
saveReqVO.setUserId(user.getId());
|
||||
}
|
||||
//客户信息
|
||||
CustomerMain customerMain = BeanUtils.toBean(saveReqVO,CustomerMain.class);
|
||||
customerMain.setDataFrom("02");
|
||||
//车辆信息
|
||||
CarMain carMain = saveReqVO.getCar();
|
||||
customerMainService.save(customerMain);
|
||||
carMainService.save(carMain);
|
||||
//关联关系
|
||||
CustomerCar customerCar = new CustomerCar();
|
||||
customerCar.setCusId(customerMain.getId());
|
||||
customerCar.setCarId(carMain.getId());
|
||||
save(customerCar);
|
||||
}
|
||||
|
||||
private void chekData(CustomerMainSaveReqVO saveReqVO) throws Exception {
|
||||
if (StringUtils.isEmpty(saveReqVO.getPhoneNumber())){
|
||||
throw new Exception("联系方式不能为空");
|
||||
}
|
||||
if (StringUtils.isEmpty(saveReqVO.getCusName())){
|
||||
throw new Exception("客户姓名不能为空");
|
||||
}
|
||||
if (saveReqVO.getCar() == null){
|
||||
throw new Exception("车辆信息不能为空");
|
||||
}
|
||||
if (StringUtils.isEmpty(saveReqVO.getCar().getLicenseNumber())){
|
||||
throw new Exception("车牌号不能为空");
|
||||
}
|
||||
if (StringUtils.isEmpty(saveReqVO.getCar().getCarBrand())){
|
||||
throw new Exception("车辆品牌不能为空");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package cn.iocoder.yudao.module.custom.vo;
|
||||
|
||||
import cn.iocoder.yudao.module.custom.entity.CarMain;
|
||||
import cn.iocoder.yudao.module.custom.entity.CustomerItem;
|
||||
import cn.iocoder.yudao.module.custom.entity.CustomerMain;
|
||||
import cn.iocoder.yudao.module.label.entity.BusiLabel;
|
||||
@ -18,9 +19,6 @@ public class CustomerMainSaveReqVO extends CustomerMain {
|
||||
private List<CarMainRespVO> carList;
|
||||
/**标签信息*/
|
||||
List<BusiLabel> labelList;
|
||||
|
||||
/**
|
||||
* 微信openId
|
||||
*/
|
||||
private String openId;
|
||||
/**客户车辆信息*/
|
||||
private CarMain car;
|
||||
}
|
Loading…
Reference in New Issue
Block a user