Commit eaedad02 authored by Smile's avatar Smile

feat:控货收货人自动创建客户

parent 7381d240
INSERT INTO jiedao.system_dict_data (sort, label, value, dict_type, status, color_type, css_class, remark, creator, create_time, updater, update_time, deleted, label_en, label_fr) VALUES(101, '客户放货推荐', '101', 'customer_source', 0, 'default', '', NULL, '1', '2024-11-19 10:34:42', '1', '2024-11-19 14:48:21', 0, 'Shipper Release', 'Libération Expéditeur');
INSERT INTO jiedao.system_dict_data (sort, label, value, dict_type, status, color_type, css_class, remark, creator, create_time, updater, update_time, deleted, label_en, label_fr) VALUES(5, '后台放货信息获得', '5', 'customer_from', 0, 'default', '', NULL, '1', '2024-11-25 18:20:55', '1', '2024-11-25 18:21:25', 0, 'Cargo', NULL);
......@@ -32,7 +32,7 @@ public class CustomerApiImpl implements CustomerApi {
@Resource
private CountryService countryService;
public void associateCustomerAuto(String areaCode, String phone, Long memberUserId, String newName ,String memberCode) {
public void associateCustomerAuto(String areaCode, String phone, Long memberUserId, String newName, String memberCode) {
//先查询此用户是否有关联老客户
CustomerContactsDO customerContactsDO = customerContactsService.getUniqueOneAndValidate(areaCode, phone, null);
......@@ -95,6 +95,59 @@ public class CustomerApiImpl implements CustomerApi {
}
public void associateCargoCustomerAuto(String areaCode, String phone, String newName, String email) {
//先查询此用户是否有关联老客户
CustomerContactsDO customerContactsDO = customerContactsService.getUniqueOneAndValidate(areaCode, phone, null);
if (customerContactsDO == null) {
CustomerCreateReqVO customerCreateReqVO = new CustomerCreateReqVO();
//初始化名字为手机号
customerCreateReqVO.setName(newName);
customerCreateReqVO.setNameEn(newName);
//普通
customerCreateReqVO.setLevel(1);
//会员注册
customerCreateReqVO.setSource(101);
//注册会员是公司资源
customerCreateReqVO.setResourceType(2);
//线索客户
customerCreateReqVO.setStatus(CustomerStatusEnum.CLUE.getValue());
//更新 状态更新时间
customerCreateReqVO.setStatusUpdateTime(new Date());
//注册时自动创建
customerCreateReqVO.setIsAuto(1);
//客户类型 默认为收货人
customerCreateReqVO.setType("1");
//国家
CountryDO countryDO = countryService.getCountry(areaCode);
if (countryDO != null) {
customerCreateReqVO.setCountry(countryDO.getId());
}
//添加联系人
CustomerContactsCreateReqVO customerContactsCreateReqVO = new CustomerContactsCreateReqVO();
customerContactsCreateReqVO.setName(newName);
customerContactsCreateReqVO.setNameEn(newName);
//默认联系人
customerContactsCreateReqVO.setIsDefault(1);
customerContactsCreateReqVO.setAreaCode(areaCode);
customerContactsCreateReqVO.setPhoneNew(phone);
customerContactsCreateReqVO.setEmail(email);
customerCreateReqVO.setCustomerContacts(Arrays.asList(customerContactsCreateReqVO));
customerCreateReqVO.setCustomerOperateLogRemark("控货收货人创建. 会员名称:" + newName + "; 电话:" + phone);
// 控货收货人创建
customerCreateReqVO.setCreateFrom(CustomerCreateFromEnum.CARGO_CONSIGNOR.getValue());
customerService.createCustomer(customerCreateReqVO);
}
}
@Override
public void approvalCustomerDelay(String approveId, Integer result) {
customerService.approvalCustomerDelay(approveId, result);
......
......@@ -17,7 +17,8 @@ public enum CustomerCreateFromEnum {
IMPORT(1, "导入"),
BACKEND(2, "后台用户创建"),
APP_REGISTER(3, "APP注册"),
APP_CONSIGNOR(4, "APP发货人创建");
APP_CONSIGNOR(4, "APP发货人创建"),
CARGO_CONSIGNOR(5, "控货收货人创建");
;
/**
......
......@@ -15,6 +15,7 @@ import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.yudao.module.bpm.api.BpmCreateServiceFactory;
import cn.iocoder.yudao.module.bpm.enums.WorkFlowEmus;
import cn.iocoder.yudao.module.bpm.resp.TaskResp;
import cn.iocoder.yudao.module.customer.service.api.CustomerApiImpl;
import cn.iocoder.yudao.module.ecw.api.internalMessage.ClientInternalMessageApi;
import cn.iocoder.yudao.module.ecw.api.internalMessage.dto.InternalMessageCreateDto;
import cn.iocoder.yudao.module.ecw.api.paramValid.ParamValidatorApi;
......@@ -27,6 +28,7 @@ import cn.iocoder.yudao.module.order.dal.dataobject.approval.OrderApprovalDO;
import cn.iocoder.yudao.module.order.dal.dataobject.order.OrderDO;
import cn.iocoder.yudao.module.order.dal.dataobject.orderCargoControl.OrderCargoControlDO;
import cn.iocoder.yudao.module.order.dal.dataobject.orderCargoControlPick.OrderCargoControlPickDO;
import cn.iocoder.yudao.module.order.dal.dataobject.orderObjective.OrderObjectiveDO;
import cn.iocoder.yudao.module.order.dal.mysql.approval.OrderApprovalMapper;
import cn.iocoder.yudao.module.order.dal.mysql.orderCargoControl.OrderCargoControlMapper;
import cn.iocoder.yudao.module.order.dal.mysql.orderCargoControlPick.OrderCargoControlPickMapper;
......@@ -34,6 +36,7 @@ import cn.iocoder.yudao.module.order.dal.mysql.orderPickup.OrderPickupMapper;
import cn.iocoder.yudao.module.order.dto.OrderCargoControlReleaseInfoDto;
import cn.iocoder.yudao.module.order.param.OrderControlLogParam;
import cn.iocoder.yudao.module.order.service.order.OrderBusinessService;
import cn.iocoder.yudao.module.order.service.order.OrderObjectiveService;
import cn.iocoder.yudao.module.order.service.order.OrderQueryService;
import cn.iocoder.yudao.module.order.service.order.OrderService;
import cn.iocoder.yudao.module.order.service.orderCargoControl.OrderCargoControlService;
......@@ -120,7 +123,10 @@ public class OrderCargoControlPickServiceImpl extends AbstractService<OrderCargo
private DictDataApi dictDataApi;
@Resource
private ParamValidatorApi paramValidatorApi;
@Resource
private CustomerApiImpl customerApiImpl;
@Resource
private OrderObjectiveService objectiveService;
@Override
public Long createOrderCargoControlPick(
OrderCargoControlPickCreateReqVO createReqVO) {
......@@ -335,6 +341,8 @@ public class OrderCargoControlPickServiceImpl extends AbstractService<OrderCargo
orderService.updateById(orderDO);
// 订单控货信息日志补充
orderBusinessService.createOrderControlLog(orderCargoControlPick.getOrderId(), 4, "订单放货", msg, 0L);
//控货收货人自动创建客户
customerApiImpl.associateCargoCustomerAuto(orderCargoControlPick.getConsigneeCountryCode(), orderCargoControlPick.getConsigneePhone(), orderCargoControlPick.getConsigneeName(), orderCargoControlPick.getConsigneeEmail());
// 返回
return orderCargoControlPick.getId();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment