Commit bb67c29e by 范富荣

添加推送轻改客户录音到群聊功能

1 parent 9e3d4f8a
Showing 17 changed files with 1348 additions and 6 deletions
...@@ -24,4 +24,9 @@ public interface ConfigCenterConstants { ...@@ -24,4 +24,9 @@ public interface ConfigCenterConstants {
*/ */
String CURRENT_SYSTEM_TIME_FOR_TEST = "current.system.time.for.test"; String CURRENT_SYSTEM_TIME_FOR_TEST = "current.system.time.for.test";
/**
* 客户档案录音对应的URL
*/
String RECEPTION_CUSTOMER_FILE_URL = "reception.customer.file.url";
} }
package cn.com.glsx.dj.mindworkplate.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
@Data
public class ReceptionCustomerFileDetailDTO implements Serializable {
private static final long serialVersionUID = 1L;
// --- Recording Info (Top Module) ---
@ApiModelProperty(notes = "车主姓名")
private String customerName;
@ApiModelProperty(notes = "电话")
private String phoneNumber;
@ApiModelProperty(notes = "接待开始时间")
private Date receptionStartTime;
@ApiModelProperty(notes = "车品牌")
private String carBrand;
// --- Customer File Info (Bottom Module) ---
@ApiModelProperty(notes = "主键ID")
private Long id;
@ApiModelProperty(notes = "提交状态, 0-未提交, 1-已提交")
private Integer submitStatus;
@ApiModelProperty(notes = "录音接待id")
private Integer receptionId;
@ApiModelProperty(notes = "接待结果, 0-成交, 1-战败")
private Integer receptionResult;
@ApiModelProperty(notes = "成交归因(接待结果=0时填写), 0-自然成交, 1-活动成交, 2-对比成交, 3-引导成交, 4-口碑成交, 5-培育成交")
private Integer dealAttribution;
@ApiModelProperty(notes = "战败归因(接待结果=1时填写), 0-价格战败, 1-竞品战败, 2-产品战败, 3-需求战败, 4-决策战败, 5-服务战败, 6-其他战败")
private Integer loseReason;
@ApiModelProperty(notes = "用车人, 0-主人本人, 1-公司户, 2-代办, 3-决策者")
private Integer carUserType;
@ApiModelProperty(notes = "客户背景, 0-企业老板, 1-老师, 2-医生, 3-建筑, 4-个体, 5-自由职业, 6-其他")
private Integer customerBackground;
@ApiModelProperty(notes = "是否好沟通, 0-是, 1-否")
private Integer easyCommunication;
@ApiModelProperty(notes = "是否按揭, 0-是, 1-否")
private Integer isMortgage;
@ApiModelProperty(notes = "首付比例, 0-全款, 1-50%, 2-零首付")
private Integer downPaymentRatio;
@ApiModelProperty(notes = "购车背景, 0-首购, 1-增购")
private Integer purchaseBackground;
@ApiModelProperty(notes = "是否本地用车, 0-本地, 1-外地")
private Integer isLocalUse;
@ApiModelProperty(notes = "购车用途, 0-公司车, 1-家庭用车")
private Integer purchasePurpose;
@ApiModelProperty(notes = "购车时加装项目(多选,英文逗号分隔保存int编码), 0-零重力座椅, 1-轮毂, 2-内饰, 3-玻璃")
private String installItems;
@ApiModelProperty(notes = "赠送精品项目(多选,英文逗号分隔保存int编码), 0-脚垫, 1-车衣, 2-底盘护板, 3-电动踏板, 4-小桌板")
private String giftItems;
@ApiModelProperty(notes = "贴膜品牌(手填文本)")
private String filmBrand;
@ApiModelProperty(notes = "是否了解其它品牌精品, 0-是, 1-否")
private Integer knowOtherBrandGoods;
}
package cn.com.glsx.dj.mindworkplate.dto;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import lombok.Data;
import java.io.Serializable;
@Data
public class ReceptionCustomerFileExportDTO implements Serializable {
private static final long serialVersionUID = 1L;
@ExcelProperty(value = "驻店人员")
private String salesName;
@ExcelProperty(value = "门店名称")
private String merchantName;
@ExcelProperty(value = "接待日期")
@ColumnWidth(20)
private String receptionStartTimeStr;
@ExcelProperty(value = "客户姓名")
@ColumnWidth(15)
private String customerName;
@ExcelProperty(value = "接待录音链接")
@ColumnWidth(40)
private String fileUrl;
@ExcelProperty(value = "客户手机号")
@ColumnWidth(15)
private String phoneNumber;
@ExcelProperty(value = "车型")
@ColumnWidth(20)
private String carModel;
@ExcelProperty(value = "接待结果")
@ColumnWidth(12)
private String receptionResultStr;
@ExcelProperty(value = "结果归因(新增)")
@ColumnWidth(20)
private String resultAttributionStr;
@ExcelProperty(value = "用车人")
@ColumnWidth(12)
private String carUserTypeStr;
@ExcelProperty(value = "客户背景")
@ColumnWidth(15)
private String customerBackgroundStr;
@ExcelProperty(value = "是否好沟通")
@ColumnWidth(12)
private String easyCommunicationStr;
@ExcelProperty(value = "是否按揭")
@ColumnWidth(12)
private String isMortgageStr;
@ExcelProperty(value = "首付比例")
@ColumnWidth(12)
private String downPaymentRatioStr;
@ExcelProperty(value = "购车背景")
@ColumnWidth(12)
private String purchaseBackgroundStr;
@ExcelProperty(value = "是否本地用车")
@ColumnWidth(15)
private String isLocalUseStr;
@ExcelProperty(value = "购车用途")
@ColumnWidth(15)
private String purchasePurposeStr;
@ExcelProperty(value = "加装项目(多选)")
@ColumnWidth(30)
private String installItemsStr;
@ExcelProperty(value = "赠送精品项目(多选)")
@ColumnWidth(30)
private String giftItemsStr;
@ExcelProperty(value = "窗膜品牌")
@ColumnWidth(15)
private String filmBrand;
@ExcelProperty(value = "是否了解其它品牌精品")
@ColumnWidth(20)
private String knowOtherBrandGoodsStr;
}
package cn.com.glsx.dj.mindworkplate.dto;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
@Data
public class ReceptionCustomerFileSummaryDTO implements Serializable {
private static final long serialVersionUID = 1L;
// From reception_customer_info
private String salesName;
private String merchantName;
private Date receptionStartTime;
private String customerName;
private String phoneNumber;
private String carModel;
// From inspection_conversation_batch
private String fileUrl;
// From reception_customer_file
private Integer receptionResult;
private Integer dealAttribution;
private Integer loseReason;
private Integer carUserType;
private Integer customerBackground;
private Integer easyCommunication;
private Integer isMortgage;
private Integer downPaymentRatio;
private Integer purchaseBackground;
private Integer isLocalUse;
private Integer purchasePurpose;
private String installItems;
private String giftItems;
private String filmBrand;
private Integer knowOtherBrandGoods;
}
package cn.com.glsx.dj.mindworkplate.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
@Data
public class ReceptionCustomerFileUpdateRequestDTO implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(notes = "录音接待id", required = true)
private Integer receptionId;
@ApiModelProperty(notes = "接待结果, 0-成交, 1-战败")
private Integer receptionResult;
@ApiModelProperty(notes = "成交归因(接待结果=0时填写), 0-自然成交, 1-活动成交, 2-对比成交, 3-引导成交, 4-口碑成交, 5-培育成交")
private Integer dealAttribution;
@ApiModelProperty(notes = "战败归因(接待结果=1时填写), 0-价格战败, 1-竞品战败, 2-产品战败, 3-需求战败, 4-决策战败, 5-服务战败, 6-其他战败")
private Integer loseReason;
@ApiModelProperty(notes = "用车人, 0-主人本人, 1-公司户, 2-代办, 3-决策者")
private Integer carUserType;
@ApiModelProperty(notes = "客户背景, 0-企业老板, 1-老师, 2-医生, 3-建筑, 4-个体, 5-自由职业, 6-其他")
private Integer customerBackground;
@ApiModelProperty(notes = "是否好沟通, 0-是, 1-否")
private Integer easyCommunication;
@ApiModelProperty(notes = "是否按揭, 0-是, 1-否")
private Integer isMortgage;
@ApiModelProperty(notes = "首付比例, 0-全款, 1-50%, 2-零首付")
private Integer downPaymentRatio;
@ApiModelProperty(notes = "购车背景, 0-首购, 1-增购")
private Integer purchaseBackground;
@ApiModelProperty(notes = "是否本地用车, 0-本地, 1-外地")
private Integer isLocalUse;
@ApiModelProperty(notes = "购车用途, 0-公司车, 1-家庭用车")
private Integer purchasePurpose;
@ApiModelProperty(notes = "购车时加装项目(多选,英文逗号分隔保存int编码), 0-零重力座椅, 1-轮毂, 2-内饰, 3-玻璃")
private String installItems;
@ApiModelProperty(notes = "赠送精品项目(多选,英文逗号分隔保存int编码), 0-脚垫, 1-车衣, 2-底盘护板, 3-电动踏板, 4-小桌板")
private String giftItems;
@ApiModelProperty(notes = "贴膜品牌(手填文本)")
private String filmBrand;
@ApiModelProperty(notes = "是否了解其它品牌精品, 0-是, 1-否")
private Integer knowOtherBrandGoods;
@ApiModelProperty(notes = "修改人")
private String updatedBy;
}
package cn.com.glsx.dj.mindworkplate.model;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import lombok.Data;
@Data
@Table(name = "reception_customer_file")
public class ReceptionCustomerFile implements Serializable {
private static final long serialVersionUID = -1L;
/**
* 主键ID
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
/**
* 提交状态, 0-未提交, 1-已提交
*/
@Column(name = "submit_status")
private Integer submitStatus;
/**
* 录音接待id
*/
@Column(name = "reception_id")
private Integer receptionId;
/**
* 接待结果, 0-成交, 1-战败
*/
@Column(name = "reception_result")
private Integer receptionResult;
/**
* 成交归因(接待结果=0时填写), 0-自然成交, 1-活动成交, 2-对比成交, 3-引导成交, 4-口碑成交, 5-培育成交
*/
@Column(name = "deal_attribution")
private Integer dealAttribution;
/**
* 战败归因(接待结果=1时填写), 0-价格战败, 1-竞品战败, 2-产品战败, 3-需求战败, 4-决策战败, 5-服务战败, 6-其他战败
*/
@Column(name = "lose_reason")
private Integer loseReason;
/**
* 用车人, 0-主人本人, 1-公司户, 2-代办, 3-决策者
*/
@Column(name = "car_user_type")
private Integer carUserType;
/**
* 客户背景, 0-企业老板, 1-老师, 2-医生, 3-建筑, 4-个体, 5-自由职业, 6-其他
*/
@Column(name = "customer_background")
private Integer customerBackground;
/**
* 是否好沟通, 0-是, 1-否
*/
@Column(name = "easy_communication")
private Integer easyCommunication;
/**
* 是否按揭, 0-是, 1-否
*/
@Column(name = "is_mortgage")
private Integer isMortgage;
/**
* 首付比例, 0-全款, 1-50%, 2-零首付
*/
@Column(name = "down_payment_ratio")
private Integer downPaymentRatio;
/**
* 购车背景, 0-首购, 1-增购
*/
@Column(name = "purchase_background")
private Integer purchaseBackground;
/**
* 是否本地用车, 0-本地, 1-外地
*/
@Column(name = "is_local_use")
private Integer isLocalUse;
/**
* 购车用途, 0-公司车, 1-家庭用车
*/
@Column(name = "purchase_purpose")
private Integer purchasePurpose;
/**
* 购车时加装项目(多选,英文逗号分隔保存int编码), 0-零重力座椅, 1-轮毂, 2-内饰, 3-玻璃
*/
@Column(name = "install_items")
private String installItems;
/**
* 赠送精品项目(多选,英文逗号分隔保存int编码), 0-脚垫, 1-车衣, 2-底盘护板, 3-电动踏板, 4-小桌板
*/
@Column(name = "gift_items")
private String giftItems;
/**
* 贴膜品牌(手填文本)
*/
@Column(name = "film_brand")
private String filmBrand;
/**
* 是否了解其它品牌精品, 0-是, 1-否
*/
@Column(name = "know_other_brand_goods")
private Integer knowOtherBrandGoods;
/**
* 创建人
*/
@Column(name = "created_by")
private String createdBy;
/**
* 创建时间
*/
@Column(name = "created_date")
private Date createdDate;
/**
* 修改人
*/
@Column(name = "updated_by")
private String updatedBy;
/**
* 修改时间
*/
@Column(name = "updated_date")
private Date updatedDate;
/**
* 删除标识(D:已删除;N:未删除)
*/
@Column(name = "deleted_flag")
private String deletedFlag;
}
...@@ -165,5 +165,10 @@ public class ReceptionCustomerInfo implements Serializable { ...@@ -165,5 +165,10 @@ public class ReceptionCustomerInfo implements Serializable {
@Column(name = "car_purchase_method") @Column(name = "car_purchase_method")
private Integer carPurchaseMethod; private Integer carPurchaseMethod;
@Transient
private String staffName;
@Transient
private String staffPhone;
} }
\ No newline at end of file \ No newline at end of file
...@@ -165,11 +165,16 @@ ...@@ -165,11 +165,16 @@
<artifactId>spring-boot-starter-test</artifactId> <artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>cn.com.glsx.merchants</groupId> <groupId>cn.com.glsx.merchants</groupId>
<artifactId>platform-merchants-api</artifactId> <artifactId>platform-merchants-api</artifactId>
<version>5.6.1-SNAPSHOT</version> <version>5.6.1-SNAPSHOT</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency>
<groupId>org.oreframework.boot</groupId>
<artifactId>ore-boot-starter-alioss</artifactId>
<version>2.2.0-SNAPSHOT</version>
</dependency>
</dependencies> </dependencies>
</project> </project>
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.dj.mindworkplate.job.customer;
import cn.com.glsx.dj.mindworkplate.service.customer.ReceptionCustomerFileGenerateService;
import com.dangdang.ddframe.job.api.ShardingContext;
import com.dangdang.ddframe.job.api.simple.SimpleJob;
import java.time.LocalDate;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.oreframework.boot.autoconfigure.elasticjob.annotation.ElasticJobConf;
import org.springframework.beans.factory.annotation.Autowired;
@Slf4j
//@ElasticJobConf(name = "ReceptionCustomerFileGenerateJob", cron = "0 0/5 * * * ?", description = "生成接待录音对应的客户档案", overwrite = true)
public class ReceptionCustomerFileGenerateJob implements SimpleJob {
//@Autowired
private ReceptionCustomerFileGenerateService receptionCustomerFileGenerateService;
@Override
public void execute(ShardingContext shardingContext) {
try {
log.info("生成接待录音对应的客户档案任务开始执行");
LocalDate date = getJobDate(shardingContext);
receptionCustomerFileGenerateService.generateLightModCustomerFilesByDate(date);
log.info("生成接待录音对应的客户档案任务结束执行, 日期:{}", date);
} catch (Exception e) {
log.error("生成接待录音对应的客户档案任务执行异常", e);
}
}
private LocalDate getJobDate(ShardingContext shardingContext) {
String param = shardingContext.getJobParameter();
if (StringUtils.isBlank(param)) {
return LocalDate.now(ZoneId.systemDefault());
}
try {
return LocalDate.parse(param.trim(), DateTimeFormatter.ISO_LOCAL_DATE);
} catch (DateTimeParseException e) {
log.warn("生成接待录音对应的客户档案任务日期参数解析失败, param:{}", param);
return LocalDate.now(ZoneId.systemDefault());
}
}
}
package cn.com.glsx.dj.mindworkplate.job.customer;
import cn.com.glsx.dj.mindworkplate.service.customer.ReceptionCustomerFileGenerateService;
import com.dangdang.ddframe.job.api.ShardingContext;
import com.dangdang.ddframe.job.api.simple.SimpleJob;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.oreframework.boot.autoconfigure.elasticjob.annotation.ElasticJobConf;
import org.springframework.beans.factory.annotation.Autowired;
@Slf4j
@ElasticJobConf(name = "ReceptionCustomerFileSummaryJob", cron = "0 0 8 ? * MON", description = "每周一汇总轻改业务客户档案信息并推送到埋点群", overwrite = true)
public class ReceptionCustomerFileSummaryJob implements SimpleJob {
@Autowired
private ReceptionCustomerFileGenerateService receptionCustomerFileGenerateService;
@Override
public void execute(ShardingContext shardingContext) {
try {
log.info("每周汇总轻改业务客户档案信息任务开始执行");
String jobParam = shardingContext.getJobParameter();
if (StringUtils.isNotBlank(jobParam)) {
String[] dates = jobParam.split(",");
if (dates.length == 2) {
receptionCustomerFileGenerateService.exportAndPushSummary(dates[0], dates[1]);
} else {
log.warn("定时任务参数格式不正确,期望格式:'yyyy-MM-dd,yyyy-MM-dd',实际:{}", jobParam);
receptionCustomerFileGenerateService.exportAndPushSummary(null, null); // 使用默认日期范围
}
} else {
receptionCustomerFileGenerateService.exportAndPushSummary(null, null); // 使用默认日期范围
}
log.info("每周汇总轻改业务客户档案信息任务结束执行");
} catch (Exception e) {
log.error("每周汇总轻改业务客户档案信息任务执行异常", e);
}
}
}
package cn.com.glsx.dj.mindworkplate.mapper;
import cn.com.glsx.dj.mindworkplate.dto.ReceptionCustomerFileDetailDTO;
import cn.com.glsx.dj.mindworkplate.dto.ReceptionCustomerFileSummaryDTO;
import cn.com.glsx.dj.mindworkplate.dto.ReceptionCustomerFileUpdateRequestDTO;
import cn.com.glsx.dj.mindworkplate.model.ReceptionCustomerFile;
import cn.com.glsx.dj.mindworkplate.model.ReceptionCustomerInfo;
import java.util.Date;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.oreframework.datasource.mybatis.mapper.OreMapper;
@Mapper
public interface ReceptionCustomerFileMapper extends OreMapper<ReceptionCustomerFile> {
List<ReceptionCustomerInfo> listNeedGenerateTodayLightModReception(
@Param("startTime") Date startTime,
@Param("endTime") Date endTime);
Integer batchInsertInit(@Param("list") List<ReceptionCustomerFile> list);
Integer updateCustomerFileFlag(@Param("ids") List<Integer> ids);
Integer updatePushStatusByReceptionIds(@Param("receptionIds") List<Integer> receptionIds);
ReceptionCustomerFileDetailDTO findDetailByReceptionId(@Param("receptionId") Integer receptionId);
Integer updateByReceptionId(ReceptionCustomerFileUpdateRequestDTO request);
ReceptionCustomerFile selectByReceptionId(@Param("receptionId") Integer receptionId);
List<ReceptionCustomerFileSummaryDTO> listSummaryBetweenDates(
@Param("startTime") Date startTime,
@Param("endTime") Date endTime);
}
package cn.com.glsx.dj.mindworkplate.service.customer;
import cn.com.glsx.dj.mindworkplate.util.HttpUtil;
import cn.com.glsx.entmicro.model.request.EntmicroStaffRequest;
import cn.com.glsx.entmicro.model.response.EntmicroStaffResponse;
import cn.com.glsx.entmicro.remote.EntmicroStaffRemote;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
import cn.com.glsx.scrm.wechat.dto.workwechat.message.request.SendWorkWechatMessageRequestDTO;
import cn.com.glsx.scrm.wechat.dto.workwechat.message.response.SendWorkWechatMessageResponseDTO;
import cn.com.glsx.scrm.wechat.remote.WorkWechatMessageRemote;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.oreframework.boot.env.OrePropertyConfigurer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Service
@Slf4j
public class QWManager {
@Autowired
private Environment environment;
@Resource
private EntmicroStaffRemote entmicroStaffRemote;
@Autowired
private WorkWechatMessageRemote workWechatMessageRemote;
/**
* 通过http请求发送企微应用消息
*
* @param sendWorkWechatMessageRequestDTO
* @return
*/
public SendWorkWechatMessageResponseDTO sendMessage(SendWorkWechatMessageRequestDTO sendWorkWechatMessageRequestDTO) {
log.info("发送企微应用消息:{}", JSON.toJSONString(sendWorkWechatMessageRequestDTO));
SendWorkWechatMessageResponseDTO responseDTO=null;
try {
String baseurl = environment.getProperty("wechat.base.path")+"/wechat/message/sendMessage";
responseDTO = HttpUtil.post(baseurl,JSONObject.parseObject(JSONObject.toJSONString(sendWorkWechatMessageRequestDTO)), SendWorkWechatMessageResponseDTO.class);
log.info("发送企微应用消息 ropResponse:{}", JSON.toJSONString(responseDTO));
} catch (Exception e) {
e.printStackTrace();
log.info("发送企微应用消息异常:", e);
}
return responseDTO;
}
public boolean sendSingleWechatMessage(SendWorkWechatMessageRequestDTO sendWorkWechatMessageRequestDTO) {
log.info("sendMessage request:{}", JSON.toJSONString(sendWorkWechatMessageRequestDTO));
RpcResponse<SendWorkWechatMessageResponseDTO> sendWorkWechatMessageResponseDTORpcResponse = workWechatMessageRemote
.sendMessage(sendWorkWechatMessageRequestDTO);
log.info("sendMessage resp:{}", JSON.toJSONString(sendWorkWechatMessageResponseDTORpcResponse));
if (!sendWorkWechatMessageResponseDTORpcResponse.isSuccess()) {
log.info("发送企微消息,参数为:{},异常:{}", sendWorkWechatMessageRequestDTO,
sendWorkWechatMessageResponseDTORpcResponse.getException());
return false;
}
return true;
}
/**
* 通过商户号+手机号查询企微员工标识
*
* @param merchantId 商户号
* @param mobile 手机号
* @return 企微userId
*/
public String getUserId(Integer merchantId, String mobile) {
log.info("查询企微员工标识, 商户号:{}, 手机号:{}", merchantId, mobile);
String userId = null;
try {
String baseurl = environment.getProperty("wechat.base.path") + "/wechat/oa/getuserid";
JSONObject requestBody = new JSONObject();
requestBody.put("merchantId", merchantId);
requestBody.put("mobile", mobile);
JSONObject responseDTO = HttpUtil.post(baseurl, requestBody, JSONObject.class);
log.info("查询企微员工标识 response:{}", JSON.toJSONString(responseDTO));
if (responseDTO != null && responseDTO.getBoolean("success")) {
userId = responseDTO.getString("userid");
}
} catch (Exception e) {
e.printStackTrace();
log.error("查询企微员工标识异常:", e);
}
return userId;
}
/**
* 获取全量广联数科员工企微
*/
public Map<String, String> getSendUserIds() {
EntmicroStaffRequest entmicroStaffRequest = new EntmicroStaffRequest();
// dev = 44211227 test = 44209813 线上 = 44202977
Integer merchantId = OrePropertyConfigurer.getProperty("dj.send.work.wechat.merchant.id",Integer.class,44202977);
entmicroStaffRequest.setMerchantId(merchantId);
RpcResponse<List<EntmicroStaffResponse>> staffResponse = entmicroStaffRemote.findStaffByMerchantId(entmicroStaffRequest);
if (staffResponse.hasResult()) {
List<EntmicroStaffResponse> result = staffResponse.getResult();
return result.stream().filter(item ->
StringUtils.isNotBlank(item.getStaffPhone()) && StringUtils.isNotBlank(item.getUserId()))
.collect(Collectors.toMap(EntmicroStaffResponse::getStaffPhone, EntmicroStaffResponse::getUserId, (a, b) -> a));
}
if (staffResponse.isFailed()) {
log.warn("获取发送员工失败,失败原因:{}", staffResponse.getException().getMessage());
}
return null;
}
public String getJoinedUserIds(Map<String, String> phoneToUserIdMap, List<String> phoneNumbers) {
StringBuilder userIds = new StringBuilder();
for (String phoneNumber : phoneNumbers) {
String userId = phoneToUserIdMap.get(phoneNumber);
if (userId != null) {
if (userIds.length() > 0) {
userIds.append("|");
}
userIds.append(userId);
}
}
return userIds.toString();
}
}
package cn.com.glsx.dj.mindworkplate.service.customer;
import cn.com.glsx.dj.mindworkplate.consts.ConfigCenterConstants;
import cn.com.glsx.dj.mindworkplate.dto.ReceptionCustomerFileDetailDTO;
import cn.com.glsx.dj.mindworkplate.dto.ReceptionCustomerFileExportDTO;
import cn.com.glsx.dj.mindworkplate.dto.ReceptionCustomerFileSummaryDTO;
import cn.com.glsx.dj.mindworkplate.dto.ReceptionCustomerFileUpdateRequestDTO;
import cn.com.glsx.dj.mindworkplate.enums.MindWorkplateServiceErrorEnum;
import cn.com.glsx.dj.mindworkplate.mapper.ReceptionCustomerFileMapper;
import cn.com.glsx.dj.mindworkplate.model.ReceptionCustomerFile;
import cn.com.glsx.dj.mindworkplate.model.ReceptionCustomerInfo;
import cn.com.glsx.dj.mindworkplate.service.MerchantService;
import cn.com.glsx.dj.mindworkplate.service.customer.QWManager;
import cn.com.glsx.dj.mindworkplate.util.ExcelExportUtils;
import cn.com.glsx.framework.core.exception.RpcServiceException;
import cn.com.glsx.scrm.proxy.dto.merchant.ListMerchantRequest;
import cn.com.glsx.scrm.proxy.model.merchant.MerchantRopResponse;
import cn.com.glsx.scrm.wechat.dto.workwechat.message.WorkWechatTextCardMessageDTO;
import cn.com.glsx.scrm.wechat.dto.workwechat.message.request.SendWorkWechatMessageRequestDTO;
import cn.com.glsx.scrm.wechat.enums.WorkWechatAppMessageTypeEnum;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.ZoneId;
import java.time.temporal.TemporalAdjusters;
import java.util.*;
import java.util.stream.Collectors;
import cn.hutool.core.date.DateUtil;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.oreframework.boot.autoconfigure.alioss.entity.AliOssUploadClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Slf4j
@Service
public class ReceptionCustomerFileGenerateService {
@Autowired
private ReceptionCustomerFileMapper receptionCustomerFileMapper;
@Autowired
private Environment env;
@Autowired
private QWManager qwManager;
@Autowired
private AliOssUploadClient aliOssUploadClient;
@Autowired
private MerchantService merchantService;
@Transactional
public void generateLightModCustomerFilesByDate(LocalDate date) {
ZoneId zoneId = ZoneId.systemDefault();
LocalDateTime startOfDay = date.atStartOfDay();
LocalDateTime startOfTomorrow = date.plusDays(1).atStartOfDay();
Date startTime = Date.from(startOfDay.atZone(zoneId).toInstant());
Date endTime = Date.from(startOfTomorrow.atZone(zoneId).toInstant());
log.info("开始查询需要生成的客户接待录音,startTime{},endTime{}", startTime, endTime);
List<ReceptionCustomerInfo> receptionList = receptionCustomerFileMapper.listNeedGenerateTodayLightModReception(
startTime, endTime);
if (CollectionUtils.isEmpty(receptionList)) {
//用中文
log.info("未查询到需要生成的客户接待录音,日期: {}", date);
return;
}
// 发送企微消息通知
sendWeChatPushMessages(receptionList);
}
private void sendWeChatPushMessages(List<ReceptionCustomerInfo> receptionList) {
Integer merchantId = env.getProperty(ConfigCenterConstants.DATA_AI_SPARRING_STAFF_WORK_WECHAT_MERCHANT_ID, Integer.class, 44211227);
String baseUrl = env.getProperty("reception.customer.file.url", "http://localhost:8080");
String agentId = env.getProperty("reception.customer.file.wechat.agent.id");
String title = env.getProperty("reception.customer.file.title", "%s辛苦啦!🎉");
String description = env.getProperty("reception.customer.file.description", "检测到你刚才在平板上完成了对 %s(手机尾号%s)的轻改业务接待录音。\n为了确保后续跟进更精准,请点击 这里 👉 补充%s的轻改档案,完善一下意向信息哦,耗时约1分钟。");
List<Integer> successIds = new ArrayList<>();
List<ReceptionCustomerInfo> sucessList = new ArrayList<>();
for (ReceptionCustomerInfo reception : receptionList) {
try {
String staffName = reception.getStaffName() != null ? reception.getStaffName() : "小张";
String customerName = reception.getCustomerName() != null ? reception.getCustomerName() : "客户";
String phone = reception.getPhoneNumber();
String phoneSuffix = (phone != null && phone.length() >= 4) ? phone.substring(phone.length() - 4) : "";
title = String.format(title, staffName);
description = String.format(description, customerName, phoneSuffix, customerName);
String url = (baseUrl != null ? baseUrl : "") + "?id=" + reception.getId();
SendWorkWechatMessageRequestDTO requestDTO = new SendWorkWechatMessageRequestDTO();
requestDTO.setMerchantId(merchantId);
//requestDTO.setAgentId(agentId);
String userId = qwManager.getUserId(merchantId, reception.getStaffPhone());
//判断是否为空
if (StringUtils.isBlank(userId)) {
log.warn("未查询到员工企微用户ID,receptionId: {}", reception.getId());
continue;
}
requestDTO.setToUser(userId);
requestDTO.setMsgType(WorkWechatAppMessageTypeEnum.TEXTCARD.getValue());
WorkWechatTextCardMessageDTO textCard = new WorkWechatTextCardMessageDTO();
textCard.setTitle(title);
textCard.setDescription(description);
textCard.setUrl(url);
requestDTO.setTextCard(textCard);
boolean response = qwManager.sendSingleWechatMessage(requestDTO);
//对接大模型
if (response) {
sucessList.add(reception);
successIds.add(reception.getId());
}
} catch (Exception e) {
log.error("发送企微消息失败,receptionId: {}", reception.getId(), e);
}
}
if (CollectionUtils.isNotEmpty(sucessList)) {
//批量更新发送企微状态
Date now = new Date();
List<ReceptionCustomerFile> insertList = receptionList.stream()
.map(x -> buildInitCustomerFile(x, now))
.collect(Collectors.toList());
receptionCustomerFileMapper.batchInsertInit(insertList);
}
}
private ReceptionCustomerFile buildInitCustomerFile(ReceptionCustomerInfo receptionCustomerInfo, Date createdDate) {
ReceptionCustomerFile file = new ReceptionCustomerFile();
file.setSubmitStatus(0);
file.setReceptionId(receptionCustomerInfo.getId());
file.setCreatedBy("system");
file.setCreatedDate(createdDate);
file.setDeletedFlag("N");
return file;
}
public ReceptionCustomerFileDetailDTO findDetailByReceptionId(Integer receptionId) {
return receptionCustomerFileMapper.findDetailByReceptionId(receptionId);
}
@Transactional
public boolean updateCustomerFile(ReceptionCustomerFileUpdateRequestDTO request) {
if (request == null || request.getReceptionId() == null) {
throw new RpcServiceException(MindWorkplateServiceErrorEnum.DATA_NOT_FULL_ERROR);
}
ReceptionCustomerFile existingFile = receptionCustomerFileMapper.selectByReceptionId(request.getReceptionId());
if (existingFile != null) {
// 记录存在,执行更新
if (existingFile.getSubmitStatus() != null && existingFile.getSubmitStatus() == 1) {
throw new RpcServiceException(MindWorkplateServiceErrorEnum.COMMON_ERROR, "该客户档案已提交,不可重复提交");
}
receptionCustomerFileMapper.updateByReceptionId(request);
} else {
// 记录不存在,执行插入
ReceptionCustomerFile newFile = new ReceptionCustomerFile();
newFile.setReceptionId(request.getReceptionId());
newFile.setReceptionResult(request.getReceptionResult());
newFile.setDealAttribution(request.getDealAttribution());
newFile.setLoseReason(request.getLoseReason());
newFile.setCarUserType(request.getCarUserType());
newFile.setCustomerBackground(request.getCustomerBackground());
newFile.setEasyCommunication(request.getEasyCommunication());
newFile.setIsMortgage(request.getIsMortgage());
newFile.setDownPaymentRatio(request.getDownPaymentRatio());
newFile.setPurchaseBackground(request.getPurchaseBackground());
newFile.setIsLocalUse(request.getIsLocalUse());
newFile.setPurchasePurpose(request.getPurchasePurpose());
newFile.setInstallItems(request.getInstallItems());
newFile.setGiftItems(request.getGiftItems());
newFile.setFilmBrand(request.getFilmBrand());
newFile.setKnowOtherBrandGoods(request.getKnowOtherBrandGoods());
newFile.setSubmitStatus(1); // 插入时直接设置为已提交
newFile.setCreatedBy(request.getUpdatedBy() != null ? request.getUpdatedBy() : "system");
newFile.setCreatedDate(new Date());
newFile.setDeletedFlag("N");
receptionCustomerFileMapper.insert(newFile);
}
return true;
}
public void exportAndPushSummary(String startDateStr, String endDateStr) {
LocalDate prevMonday;
LocalDate prevSunday;
if (StringUtils.isNotBlank(startDateStr) && StringUtils.isNotBlank(endDateStr)) {
prevMonday = LocalDate.parse(startDateStr);
prevSunday = LocalDate.parse(endDateStr);
} else {
// 计算上周时间范围:上周一 00:00:00 到 上周日 23:59:59
LocalDate today = LocalDate.now();
LocalDate thisMonday = today.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY));
prevMonday = thisMonday.minusWeeks(1);
prevSunday = thisMonday.minusDays(1);
}
Date startTime = Date.from(prevMonday.atStartOfDay(ZoneId.systemDefault()).toInstant());
Date endTime = Date.from(prevSunday.atTime(LocalTime.MAX).atZone(ZoneId.systemDefault()).toInstant());
log.info("汇总导出客户档案数据,范围: {} 至 {}", prevMonday, prevSunday);
List<ReceptionCustomerFileSummaryDTO> summaryList = receptionCustomerFileMapper.listSummaryBetweenDates(startTime, endTime);
if (CollectionUtils.isEmpty(summaryList)) {
log.info("上周无提交的客户档案数据,跳过导出");
return;
}
// 获取所有门店名称
Set<String> merchantIds = summaryList.stream().map(ReceptionCustomerFileSummaryDTO::getMerchantName).collect(Collectors.toSet());
Map<String, String> merchantNameMap = new HashMap<>();
if (CollectionUtils.isNotEmpty(merchantIds)) {
try {
// 假设 merchantService 有通过 IDs 获取详情的方法,根据之前的 SearchCodebase 结果
// 这里我们简化处理,如果 merchantService 比较复杂,我们直接在循环中转换或批量转换
// 参考 SearchCodebase 结果 L1647,使用了 findMerchantListByCondition
ListMerchantRequest merchantRequest = new ListMerchantRequest();
merchantRequest.setMerchantNoStrSet(String.join(",", merchantIds));
List<MerchantRopResponse> merchantList = merchantService.findMerchantListByCondition(merchantRequest);
if (CollectionUtils.isNotEmpty(merchantList)) {
merchantNameMap = merchantList.stream().collect(Collectors.toMap(MerchantRopResponse::getMerchantNo, MerchantRopResponse::getMerchantName, (k1, k2) -> k1));
}
} catch (Exception e) {
log.error("获取门店名称失败", e);
}
}
Map<String, String> finalMerchantNameMap = merchantNameMap;
List<ReceptionCustomerFileExportDTO> exportList = summaryList.stream().map(s -> {
ReceptionCustomerFileExportDTO e = new ReceptionCustomerFileExportDTO();
e.setSalesName(s.getSalesName());
e.setMerchantName(finalMerchantNameMap.getOrDefault(s.getMerchantName(), s.getMerchantName()));
e.setReceptionStartTimeStr(DateUtil.formatDateTime(s.getReceptionStartTime()));
e.setCustomerName(s.getCustomerName());
e.setFileUrl(s.getFileUrl());
e.setPhoneNumber(s.getPhoneNumber());
e.setCarModel(s.getCarModel());
e.setReceptionResultStr(s.getReceptionResult() == 0 ? "成交" : "战败");
// 结果归因
if (s.getReceptionResult() == 0) {
e.setResultAttributionStr(mapDealAttribution(s.getDealAttribution()));
} else {
e.setResultAttributionStr(mapLoseReason(s.getLoseReason()));
}
e.setCarUserTypeStr(mapCarUserType(s.getCarUserType()));
e.setCustomerBackgroundStr(mapCustomerBackground(s.getCustomerBackground()));
e.setEasyCommunicationStr(s.getEasyCommunication() == 0 ? "是" : "否");
e.setIsMortgageStr(s.getIsMortgage() == 0 ? "是" : "否");
e.setDownPaymentRatioStr(mapDownPaymentRatio(s.getDownPaymentRatio()));
e.setPurchaseBackgroundStr(s.getPurchaseBackground() == 0 ? "首购" : "增购");
e.setIsLocalUseStr(s.getIsLocalUse() == 0 ? "本地" : "外地");
e.setPurchasePurposeStr(s.getPurchasePurpose() == 0 ? "公司车" : "家庭用车");
e.setInstallItemsStr(mapMultiSelectItems(s.getInstallItems(), new String[]{"零重力座椅", "轮毂", "内饰", "玻璃"}));
e.setGiftItemsStr(mapMultiSelectItems(s.getGiftItems(), new String[]{"脚垫", "车衣", "底盘护板", "电动踏板", "小桌板"}));
e.setFilmBrand(s.getFilmBrand());
e.setKnowOtherBrandGoodsStr(s.getKnowOtherBrandGoods() == 0 ? "是" : "否");
return e;
}).collect(Collectors.toList());
String fileName = "轻改业务客户档案汇总_" + prevMonday + "_" + prevSunday;
exportBurialPointRecord(fileName, exportList, ReceptionCustomerFileExportDTO.class);
}
private String mapDealAttribution(Integer val) {
if (val == null) return "";
switch (val) {
case 0: return "自然成交";
case 1: return "活动成交";
case 2: return "对比成交";
case 3: return "引导成交";
case 4: return "口碑成交";
case 5: return "培育成交";
default: return "";
}
}
private String mapLoseReason(Integer val) {
if (val == null) return "";
switch (val) {
case 0: return "价格战败";
case 1: return "竞品战败";
case 2: return "产品战败";
case 3: return "需求战败";
case 4: return "决策战败";
case 5: return "服务战败";
case 6: return "其他战败";
default: return "";
}
}
private String mapCarUserType(Integer val) {
if (val == null) return "";
switch (val) {
case 0: return "主人本人";
case 1: return "公司户";
case 2: return "代办";
case 3: return "决策者";
default: return "";
}
}
private String mapCustomerBackground(Integer val) {
if (val == null) return "";
switch (val) {
case 0: return "企业老板";
case 1: return "老师";
case 2: return "医生";
case 3: return "建筑";
case 4: return "个体";
case 5: return "自由职业";
case 6: return "其他";
default: return "";
}
}
private String mapDownPaymentRatio(Integer val) {
if (val == null) return "";
switch (val) {
case 0: return "全款";
case 1: return "50%";
case 2: return "零首付";
default: return "";
}
}
private String mapMultiSelectItems(String val, String[] names) {
if (StringUtils.isBlank(val)) return "";
try {
return Arrays.stream(val.split(","))
.map(String::trim)
.filter(StringUtils::isNotBlank)
.map(Integer::parseInt)
.filter(i -> i >= 0 && i < names.length)
.map(i -> names[i])
.collect(Collectors.joining("、"));
} catch (Exception e) {
return val;
}
}
/**
* 导出表格数据,并发送机器人
* @param fileName
* @param list
* @param classType
*/
public void exportBurialPointRecord(String fileName, List<? extends Object> list, Class classType) {
byte[] bytes = ExcelExportUtils.excelExportWithoutUpload(fileName + new Date().getTime(), list, classType, null);
InputStream inputStream = new ByteArrayInputStream(bytes);
String bucketName = env.getProperty("ore.alioss.bucketName");
String fileUrl = aliOssUploadClient.uploadFileSimple4InputStream(bucketName, fileName + ".xlsx", inputStream, null);
log.info("埋点文件[{}]返回地址[{}]", fileName, fileUrl);
//发送机器人
String content = fileName + "文件下载地址: " + fileUrl;
String key = env.getProperty("burial.point.excel.qw.robot.key");
if (StringUtils.isEmpty(key)) {
log.info("推送企微机器人消息通知失败,机器人key配置为空");
return;
}
Map<String, Object> body = new HashMap<>();
body.put("msgtype", "markdown");
Map<String, String> markdown = new HashMap<>();
markdown.put("content", content);
body.put("markdown", markdown);
String textMessageUrl = "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=" + key;
String post = HttpUtil.post(textMessageUrl, JSON.toJSONString(body));
log.info("推送企微机器人埋点消息通知结果[{}]", post);
}
}
...@@ -78,6 +78,34 @@ public class EasyExcelUtils { ...@@ -78,6 +78,34 @@ public class EasyExcelUtils {
head.excelType(ExcelTypeEnum.XLSX).sheet(sheetName).registerWriteHandler(horizontalCellStyleStrategy).doWrite(data); head.excelType(ExcelTypeEnum.XLSX).sheet(sheetName).registerWriteHandler(horizontalCellStyleStrategy).doWrite(data);
} }
/**
* 导出
*
* @param os
* @param data
* @param sheetName
* @param clazz
*/
public static void writeExcelWithOutWraypped(OutputStream os, List<? extends Object> data, String sheetName, Class clazz, String serviceProviderType) {
//表头样式
WriteCellStyle headWriteCellStyle = new WriteCellStyle();
// 允许自动换行
headWriteCellStyle.setWrapped(true);
//设置表头居中对齐
headWriteCellStyle.setHorizontalAlignment(HorizontalAlignment.CENTER);
WriteFont writeFont = new WriteFont();
writeFont.setFontHeightInPoints((short) 12);
headWriteCellStyle.setWriteFont(writeFont);
//内容样式
WriteCellStyle contentWriteCellStyle = new WriteCellStyle();
//设置内容靠左对齐
contentWriteCellStyle.setHorizontalAlignment(HorizontalAlignment.LEFT);
contentWriteCellStyle.setWrapped(false);
HorizontalCellStyleStrategy horizontalCellStyleStrategy = new HorizontalCellStyleStrategy(headWriteCellStyle, contentWriteCellStyle);
ExcelWriterBuilder head = EasyExcel.write(os).head(clazz);
head.excelType(ExcelTypeEnum.XLSX).sheet(sheetName).registerWriteHandler(horizontalCellStyleStrategy).doWrite(data);
}
/** /**
* 导出 * 导出
* *
......
...@@ -50,4 +50,11 @@ public class ExcelExportUtils { ...@@ -50,4 +50,11 @@ public class ExcelExportUtils {
} }
} }
} }
public static byte[] excelExportWithoutUpload(String filename, List<? extends Object> list, Class clazz, String serviceProviderType) {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
EasyExcelUtils.writeExcelWithOutWraypped(outputStream, list, filename, clazz, serviceProviderType);
byte[] bytes = outputStream.toByteArray();
return bytes;
}
} }
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="cn.com.glsx.dj.mindworkplate.mapper.ReceptionCustomerFileMapper">
<select id="listNeedGenerateTodayLightModReception" resultType="cn.com.glsx.dj.mindworkplate.model.ReceptionCustomerInfo">
select distinct
rci.id as id,
rci.reception_status as receptionStatus,
ieb.employee_name as staffName,
ieb.phone_number as staffPhone,
rci.customer_name as customerName,
rci.phone_number as phoneNumber
from reception_customer_info rci
inner join inspection_badge_recordings ibr on ibr.reception_id = rci.id and ibr.deleted_flag = 'N'
inner join inspection_conversation_batch cb on cb.task_id = rci.id and cb.deleted_flag = 'N'
inner join inspection_conversation_date t2 on cb.conversation_id = t2.id and t2.deleted_flag = 'N'
inner join inspection_employee_badge ieb on ieb.badge_id = t2.badge_id and ieb.deleted_flag = 'N'
where rci.deleted_flag = 'N'
and rci.bussiness_type = 2
and rci.reception_start_time &gt;= #{startTime}
and rci.reception_start_time &lt; #{endTime}
and ibr.recording_id is not null and ibr.recording_id != ''
and not exists (
select 1 from reception_customer_file rcf
where rcf.reception_id = rci.id and rcf.deleted_flag = 'N'
)
order by rci.id asc
</select>
<insert id="batchInsertInit">
insert into reception_customer_file
(submit_status, push_status, reception_id, reception_result, created_by, created_date, deleted_flag)
values
<foreach collection="list" item="item" separator=",">
(#{item.submitStatus}, #{item.pushStatus}, #{item.receptionId}, #{item.receptionResult}, #{item.createdBy}, #{item.createdDate}, #{item.deletedFlag})
</foreach>
</insert>
<update id="updateCustomerFileFlag">
update reception_customer_info
set customer_file_flag = 1, updated_by = 'system', updated_date = now()
where id in
<foreach collection="ids" item="item" separator="," open="(" close=")">
#{item}
</foreach>
</update>
<update id="updatePushStatusByReceptionIds">
update reception_customer_file
set push_status = 1, updated_by = 'system', updated_date = now()
where reception_id in
<foreach collection="receptionIds" item="item" separator="," open="(" close=")">
#{item}
</foreach>
</update>
<select id="findDetailByReceptionId" resultType="cn.com.glsx.dj.mindworkplate.dto.ReceptionCustomerFileDetailDTO">
select
rci.customer_name as customerName,
rci.phone_number as phoneNumber,
rci.reception_start_time as receptionStartTime,
rci.car_brand as carBrand,
rcf.id as id,
rcf.submit_status as submitStatus,
rcf.reception_id as receptionId,
rcf.reception_result as receptionResult,
rcf.deal_attribution as dealAttribution,
rcf.lose_reason as loseReason,
rcf.car_user_type as carUserType,
rcf.customer_background as customerBackground,
rcf.easy_communication as easyCommunication,
rcf.is_mortgage as isMortgage,
rcf.down_payment_ratio as downPaymentRatio,
rcf.purchase_background as purchaseBackground,
rcf.is_local_use as isLocalUse,
rcf.purchase_purpose as purchasePurpose,
rcf.install_items as installItems,
rcf.gift_items as giftItems,
rcf.film_brand as filmBrand,
rcf.know_other_brand_goods as knowOtherBrandGoods
from inspection_conversation_batch t2
LEFT JOIN reception_customer_file rcf on rcf.reception_id = t2.record_id and rcf.deleted_flag = 'N'
left join reception_customer_info rci on t2.task_id = rci.id and rci.deleted_flag = 'N'
where t2.record_id = #{receptionId}
limit 1
</select>
<update id="updateByReceptionId">
update reception_customer_file
<set>
<if test="receptionResult != null">reception_result = #{receptionResult},</if>
<if test="dealAttribution != null">deal_attribution = #{dealAttribution},</if>
<if test="loseReason != null">lose_reason = #{loseReason},</if>
<if test="carUserType != null">car_user_type = #{carUserType},</if>
<if test="customerBackground != null">customer_background = #{customerBackground},</if>
<if test="easyCommunication != null">easy_communication = #{easyCommunication},</if>
<if test="isMortgage != null">is_mortgage = #{isMortgage},</if>
<if test="downPaymentRatio != null">down_payment_ratio = #{downPaymentRatio},</if>
<if test="purchaseBackground != null">purchase_background = #{purchaseBackground},</if>
<if test="isLocalUse != null">is_local_use = #{isLocalUse},</if>
<if test="purchasePurpose != null">purchase_purpose = #{purchasePurpose},</if>
<if test="installItems != null">install_items = #{installItems},</if>
<if test="giftItems != null">gift_items = #{giftItems},</if>
<if test="filmBrand != null">film_brand = #{filmBrand},</if>
<if test="knowOtherBrandGoods != null">know_other_brand_goods = #{knowOtherBrandGoods},</if>
<if test="updatedBy != null">updated_by = #{updatedBy},</if>
submit_status = 1,
updated_date = now()
</set>
where reception_id = #{receptionId}
and deleted_flag = 'N'
</update>
<select id="listSummaryBetweenDates" resultType="cn.com.glsx.dj.mindworkplate.dto.ReceptionCustomerFileSummaryDTO">
select
ieb.employee_name as salesName,
rci.merchant_id as merchantName,
rci.reception_start_time as receptionStartTime,
rci.customer_name as customerName,
rci.phone_number as phoneNumber,
rci.car_model as carModel,
icb.file_url as fileUrl,
rcf.reception_result as receptionResult,
rcf.deal_attribution as dealAttribution,
rcf.lose_reason as loseReason,
rcf.car_user_type as carUserType,
rcf.customer_background as customerBackground,
rcf.easy_communication as easyCommunication,
rcf.is_mortgage as isMortgage,
rcf.down_payment_ratio as downPaymentRatio,
rcf.purchase_background as purchaseBackground,
rcf.is_local_use as isLocalUse,
rcf.purchase_purpose as purchasePurpose,
rcf.install_items as installItems,
rcf.gift_items as giftItems,
rcf.film_brand as filmBrand,
rcf.know_other_brand_goods as knowOtherBrandGoods
from reception_customer_file rcf
left join inspection_conversation_batch icb on rcf.reception_id = icb.record_id and icb.deleted_flag = 'N'
left join reception_customer_info rci on icb.task_id = rci.id and rci.deleted_flag = 'N'
LEFT JOIN inspection_badge_recordings t3 ON icb.record_id = t3.id and t3.deleted_flag = 'N'
LEFT JOIN inspection_employee_badge ieb ON t3.badge_id = ieb.badge_id and ieb.deleted_flag = 'N'
where rcf.submit_status = 1
and rcf.created_date &gt;= #{startTime}
and rcf.created_date &lt; #{endTime}
and rcf.deleted_flag = 'N'
order by rcf.created_date desc
</select>
<select id="selectByReceptionId" resultType="cn.com.glsx.dj.mindworkplate.model.ReceptionCustomerFile">
select
id, submit_status, reception_id, reception_result, deal_attribution,
lose_reason, car_user_type, customer_background, easy_communication, is_mortgage,
down_payment_ratio, purchase_background, is_local_use, purchase_purpose,
install_items, gift_items, film_brand, know_other_brand_goods,
created_by, created_date, updated_by, updated_date, deleted_flag
from reception_customer_file
where reception_id = #{receptionId}
and deleted_flag = 'N'
limit 1
</select>
</mapper>
package cn.com.glsx.dj.mindworkplate.service.customer;
import cn.com.glsx.dj.mindworkplate.dto.ReceptionCustomerFileDetailDTO;
import cn.com.glsx.dj.mindworkplate.dto.ReceptionCustomerFileUpdateRequestDTO;
import cn.com.glsx.dj.mindworkplate.service.BaseServiceTest;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import java.time.LocalDate;
public class ReceptionCustomerFileGenerateServiceTest extends BaseServiceTest {
@Autowired
private ReceptionCustomerFileGenerateService receptionCustomerFileGenerateService;
@Test
public void testGenerateLightModCustomerFilesByDate() {
//指定日期:2024-05-10
LocalDate date = LocalDate.of(2024, 5, 10);
receptionCustomerFileGenerateService.generateLightModCustomerFilesByDate(date);
}
@Test
public void testUpdateCustomerFile() {
ReceptionCustomerFileUpdateRequestDTO request = new ReceptionCustomerFileUpdateRequestDTO();
request.setReceptionId(823);
request.setReceptionResult(0);
request.setDealAttribution(0);
//request.setLoseReason(0);
request.setCarUserType(0);
request.setCustomerBackground(0);
request.setEasyCommunication(0);
request.setIsMortgage(0);
request.setDownPaymentRatio(0);
request.setPurchaseBackground(0);
request.setIsLocalUse(0);
request.setPurchasePurpose(0);
request.setInstallItems("0");
request.setGiftItems("0");
request.setFilmBrand("");
request.setKnowOtherBrandGoods(0);
request.setUpdatedBy("ffr");
receptionCustomerFileGenerateService.updateCustomerFile(request);
ReceptionCustomerFileDetailDTO detailByReceptionId = receptionCustomerFileGenerateService.findDetailByReceptionId(823);
System.out.println(detailByReceptionId);
}
@Test
public void testExportAndPushSummary() {
receptionCustomerFileGenerateService.exportAndPushSummary("2026-04-06", "2026-04-12");
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!