Compare commits
No commits in common. "71cc995aae20ef82f37e48a67f404de8b71a3c8f" and "bb70fcb97fb7e4601420aee2b72fca345d64fb11" have entirely different histories.
71cc995aae
...
bb70fcb97f
@ -1,8 +1,12 @@
|
|||||||
package cn.iocoder.yudao.module.custom.controller.admin;
|
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.framework.common.pojo.CommonResult;
|
||||||
import cn.iocoder.yudao.module.custom.entity.CustomerMain;
|
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.service.CustomerMainService;
|
||||||
import cn.iocoder.yudao.module.custom.vo.CustomerMainPageReqVO;
|
import cn.iocoder.yudao.module.custom.vo.CustomerMainPageReqVO;
|
||||||
import cn.iocoder.yudao.module.custom.vo.CustomerMainRespVO;
|
import cn.iocoder.yudao.module.custom.vo.CustomerMainRespVO;
|
||||||
@ -19,7 +23,11 @@ import org.springframework.validation.annotation.Validated;
|
|||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import javax.net.ssl.HttpsURLConnection;
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
|
|
||||||
|
import java.net.HttpURLConnection;
|
||||||
|
import java.net.URL;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.common.BaseConstants.*;
|
import static cn.iocoder.yudao.common.BaseConstants.*;
|
||||||
@ -40,8 +48,7 @@ public class CustomerMainController {
|
|||||||
private CustomerMainService customerMainService;
|
private CustomerMainService customerMainService;
|
||||||
@Resource
|
@Resource
|
||||||
private BusiLabelService busiLabelService;
|
private BusiLabelService busiLabelService;
|
||||||
@Resource
|
|
||||||
private CustomerCarService customerCarService;
|
|
||||||
/**
|
/**
|
||||||
* 客户管理分页列表查询
|
* 客户管理分页列表查询
|
||||||
*
|
*
|
||||||
@ -78,14 +85,6 @@ public class CustomerMainController {
|
|||||||
return success(true);
|
return success(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@PostMapping("/saveCustomerAndCar")
|
|
||||||
@Operation(summary = "保存客户及车辆信息")
|
|
||||||
public CommonResult<Boolean> saveCustomerAndCar(@RequestBody CustomerMainSaveReqVO saveReqVO) throws Exception {
|
|
||||||
customerCarService.saveCustomerAndCar(saveReqVO);
|
|
||||||
return success(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 编辑客户
|
* 编辑客户
|
||||||
*
|
*
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
package cn.iocoder.yudao.module.custom.service;
|
package cn.iocoder.yudao.module.custom.service;
|
||||||
|
|
||||||
import cn.iocoder.yudao.module.custom.entity.CustomerCar;
|
import cn.iocoder.yudao.module.custom.entity.CustomerCar;
|
||||||
import cn.iocoder.yudao.module.custom.vo.CustomerMainSaveReqVO;
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -24,15 +23,4 @@ public interface CustomerCarService extends IService<CustomerCar> {
|
|||||||
* @date 18:45 2024/8/3
|
* @date 18:45 2024/8/3
|
||||||
**/
|
**/
|
||||||
void bindCustomerCar(String mainId, String mainTable, List<CustomerCar> customerCars);
|
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,32 +1,19 @@
|
|||||||
package cn.iocoder.yudao.module.custom.service.impl;
|
package cn.iocoder.yudao.module.custom.service.impl;
|
||||||
|
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
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.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.CustomerCar;
|
||||||
import cn.iocoder.yudao.module.custom.entity.CustomerMain;
|
|
||||||
import cn.iocoder.yudao.module.custom.mapper.CustomerCarMapper;
|
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.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.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
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.stereotype.Service;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.common.BaseConstants.*;
|
import static cn.iocoder.yudao.common.BaseConstants.CUS_SIGN_CAR;
|
||||||
import static cn.iocoder.yudao.framework.common.config.CommonStr.USER_TYPE_CUS;
|
import static cn.iocoder.yudao.common.BaseConstants.CUS_SIGN_CUSTOMER;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 客户车辆管理关联
|
* 客户车辆管理关联
|
||||||
@ -37,15 +24,6 @@ import static cn.iocoder.yudao.framework.common.config.CommonStr.USER_TYPE_CUS;
|
|||||||
@Validated
|
@Validated
|
||||||
public class CustomerCarServiceImpl extends ServiceImpl<CustomerCarMapper, CustomerCar> implements CustomerCarService {
|
public class CustomerCarServiceImpl extends ServiceImpl<CustomerCarMapper, CustomerCar> implements CustomerCarService {
|
||||||
|
|
||||||
@Resource
|
|
||||||
@Lazy
|
|
||||||
private CustomerMainService customerMainService;
|
|
||||||
@Resource
|
|
||||||
@Lazy
|
|
||||||
private CarMainService carMainService;
|
|
||||||
@Resource
|
|
||||||
@Lazy
|
|
||||||
private AdminUserApi adminUserApi;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 保存客户与车辆的关联关系
|
* 保存客户与车辆的关联关系
|
||||||
@ -82,66 +60,4 @@ 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,6 +1,5 @@
|
|||||||
package cn.iocoder.yudao.module.custom.vo;
|
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.CustomerItem;
|
||||||
import cn.iocoder.yudao.module.custom.entity.CustomerMain;
|
import cn.iocoder.yudao.module.custom.entity.CustomerMain;
|
||||||
import cn.iocoder.yudao.module.label.entity.BusiLabel;
|
import cn.iocoder.yudao.module.label.entity.BusiLabel;
|
||||||
@ -19,6 +18,9 @@ public class CustomerMainSaveReqVO extends CustomerMain {
|
|||||||
private List<CarMainRespVO> carList;
|
private List<CarMainRespVO> carList;
|
||||||
/**标签信息*/
|
/**标签信息*/
|
||||||
List<BusiLabel> labelList;
|
List<BusiLabel> labelList;
|
||||||
/**客户车辆信息*/
|
|
||||||
private CarMain car;
|
/**
|
||||||
|
* 微信openId
|
||||||
|
*/
|
||||||
|
private String openId;
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user