Commit 696eab8c authored by alex yao's avatar alex yao

fix: 【【POE】分享应用时数据统计更改】 --bug=1009877

parent a2b08039
...@@ -31,8 +31,9 @@ public interface DataAnalyzeReportService { ...@@ -31,8 +31,9 @@ public interface DataAnalyzeReportService {
* @param type * @param type
* @param relationId * @param relationId
* @param channel * @param channel
* @param pointDeductionNum 当前对话积分扣除数量-单位分
*/ */
void dataReportByDialogue(Long memberId, DataAnalyzeTypeEnum type, String relationId, DataAnalyzeChannelEnum channel); void dataReportByDialogue(Long memberId, DataAnalyzeTypeEnum type, String relationId, Long pointDeductionNum, DataAnalyzeChannelEnum channel);
/** /**
* 数据上报-聚合上报【对话次数+积分使用情况】 * 数据上报-聚合上报【对话次数+积分使用情况】
......
...@@ -47,14 +47,16 @@ public class DataAnalyzeReportServiceImpl implements DataAnalyzeReportService { ...@@ -47,14 +47,16 @@ public class DataAnalyzeReportServiceImpl implements DataAnalyzeReportService {
} }
@Override @Override
public void dataReportByDialogue(Long memberId, DataAnalyzeTypeEnum type, String relationId, DataAnalyzeChannelEnum channel) { public void dataReportByDialogue(Long memberId, DataAnalyzeTypeEnum type, String relationId, Long pointDeductionNum, DataAnalyzeChannelEnum channel) {
try { try {
BigDecimal points = new BigDecimal(pointDeductionNum).divide(new BigDecimal(100), 2, RoundingMode.HALF_UP);
BizDataAnalyzeDialogueRecordEntity bizDataAnalyzeDialogueRecordEntity = new BizDataAnalyzeDialogueRecordEntity(); BizDataAnalyzeDialogueRecordEntity bizDataAnalyzeDialogueRecordEntity = new BizDataAnalyzeDialogueRecordEntity();
bizDataAnalyzeDialogueRecordEntity.setRelationId(relationId); bizDataAnalyzeDialogueRecordEntity.setRelationId(relationId);
bizDataAnalyzeDialogueRecordEntity.setType(type.getType()); bizDataAnalyzeDialogueRecordEntity.setType(type.getType());
bizDataAnalyzeDialogueRecordEntity.setMemberId(memberId); bizDataAnalyzeDialogueRecordEntity.setMemberId(memberId);
bizDataAnalyzeDialogueRecordEntity.setChannel(channel.getChannel()); bizDataAnalyzeDialogueRecordEntity.setChannel(channel.getChannel());
bizDataAnalyzeDialogueRecordEntity.setDatetime(DateUtils.getCurrDateTime()); bizDataAnalyzeDialogueRecordEntity.setDatetime(DateUtils.getCurrDateTime());
bizDataAnalyzeDialogueRecordEntity.setPointNum(points.doubleValue());
bizDataAnalyzeDialogueRecordService.save(bizDataAnalyzeDialogueRecordEntity); bizDataAnalyzeDialogueRecordService.save(bizDataAnalyzeDialogueRecordEntity);
} catch (Exception e) { } catch (Exception e) {
logger.error("对话次数统计情况-数据统计异常", e); logger.error("对话次数统计情况-数据统计异常", e);
...@@ -64,7 +66,7 @@ public class DataAnalyzeReportServiceImpl implements DataAnalyzeReportService { ...@@ -64,7 +66,7 @@ public class DataAnalyzeReportServiceImpl implements DataAnalyzeReportService {
@Override @Override
public boolean dataReport(String agentId, DataAnalyzeChannelEnum channel, Long userId, Long deducted, Long pointDeductionNum) { public boolean dataReport(String agentId, DataAnalyzeChannelEnum channel, Long userId, Long deducted, Long pointDeductionNum) {
BigDecimal points = new BigDecimal(pointDeductionNum).divide(new BigDecimal(100), 2, RoundingMode.HALF_UP); BigDecimal points = new BigDecimal(pointDeductionNum).divide(new BigDecimal(100), 2, RoundingMode.HALF_UP);
this.dataReportByDialogue(userId, DataAnalyzeTypeEnum.AGENT, agentId, channel); this.dataReportByDialogue(userId, DataAnalyzeTypeEnum.AGENT, agentId, userId.equals(deducted) ? pointDeductionNum : 0, channel);
this.dataReportByPoint(deducted, points, DataAnalyzeTypeEnum.AGENT, agentId, channel); this.dataReportByPoint(deducted, points, DataAnalyzeTypeEnum.AGENT, agentId, channel);
return true; return true;
} }
......
package cn.com.poc.data_analyze.convert; package cn.com.poc.data_analyze.convert;
import cn.com.poc.data_analyze.model.BizDataAnalyzeDialogueRecordModel; import cn.com.poc.data_analyze.model.BizDataAnalyzeDialogueRecordModel;
import cn.com.poc.data_analyze.entity.BizDataAnalyzeDialogueRecordEntity; import cn.com.poc.data_analyze.entity.BizDataAnalyzeDialogueRecordEntity;
...@@ -7,7 +7,7 @@ import cn.com.poc.data_analyze.dto.BizDataAnalyzeDialogueRecordDto; ...@@ -7,7 +7,7 @@ import cn.com.poc.data_analyze.dto.BizDataAnalyzeDialogueRecordDto;
public class BizDataAnalyzeDialogueRecordConvert { public class BizDataAnalyzeDialogueRecordConvert {
public static BizDataAnalyzeDialogueRecordEntity modelToEntity(BizDataAnalyzeDialogueRecordModel model){ public static BizDataAnalyzeDialogueRecordEntity modelToEntity(BizDataAnalyzeDialogueRecordModel model) {
BizDataAnalyzeDialogueRecordEntity entity = new BizDataAnalyzeDialogueRecordEntity(); BizDataAnalyzeDialogueRecordEntity entity = new BizDataAnalyzeDialogueRecordEntity();
entity.setId(model.getId()); entity.setId(model.getId());
entity.setRelationId(model.getRelationId()); entity.setRelationId(model.getRelationId());
...@@ -15,10 +15,11 @@ public class BizDataAnalyzeDialogueRecordConvert { ...@@ -15,10 +15,11 @@ public class BizDataAnalyzeDialogueRecordConvert {
entity.setMemberId(model.getMemberId()); entity.setMemberId(model.getMemberId());
entity.setChannel(model.getChannel()); entity.setChannel(model.getChannel());
entity.setDatetime(model.getDatetime()); entity.setDatetime(model.getDatetime());
entity.setPointNum(model.getPointNum());
return entity; return entity;
} }
public static BizDataAnalyzeDialogueRecordModel entityToModel(BizDataAnalyzeDialogueRecordEntity entity){ public static BizDataAnalyzeDialogueRecordModel entityToModel(BizDataAnalyzeDialogueRecordEntity entity) {
BizDataAnalyzeDialogueRecordModel model = new BizDataAnalyzeDialogueRecordModel(); BizDataAnalyzeDialogueRecordModel model = new BizDataAnalyzeDialogueRecordModel();
model.setId(entity.getId()); model.setId(entity.getId());
model.setRelationId(entity.getRelationId()); model.setRelationId(entity.getRelationId());
...@@ -26,10 +27,11 @@ public class BizDataAnalyzeDialogueRecordConvert { ...@@ -26,10 +27,11 @@ public class BizDataAnalyzeDialogueRecordConvert {
model.setMemberId(entity.getMemberId()); model.setMemberId(entity.getMemberId());
model.setChannel(entity.getChannel()); model.setChannel(entity.getChannel());
model.setDatetime(entity.getDatetime()); model.setDatetime(entity.getDatetime());
model.setPointNum(entity.getPointNum());
return model; return model;
} }
public static BizDataAnalyzeDialogueRecordDto entityToDto(BizDataAnalyzeDialogueRecordEntity entity){ public static BizDataAnalyzeDialogueRecordDto entityToDto(BizDataAnalyzeDialogueRecordEntity entity) {
BizDataAnalyzeDialogueRecordDto dto = new BizDataAnalyzeDialogueRecordDto(); BizDataAnalyzeDialogueRecordDto dto = new BizDataAnalyzeDialogueRecordDto();
dto.setId(entity.getId()); dto.setId(entity.getId());
dto.setRelationId(entity.getRelationId()); dto.setRelationId(entity.getRelationId());
...@@ -40,7 +42,7 @@ public class BizDataAnalyzeDialogueRecordConvert { ...@@ -40,7 +42,7 @@ public class BizDataAnalyzeDialogueRecordConvert {
return dto; return dto;
} }
public static BizDataAnalyzeDialogueRecordEntity dtoToEntity(BizDataAnalyzeDialogueRecordDto dto){ public static BizDataAnalyzeDialogueRecordEntity dtoToEntity(BizDataAnalyzeDialogueRecordDto dto) {
BizDataAnalyzeDialogueRecordEntity entity = new BizDataAnalyzeDialogueRecordEntity(); BizDataAnalyzeDialogueRecordEntity entity = new BizDataAnalyzeDialogueRecordEntity();
entity.setId(dto.getId()); entity.setId(dto.getId());
entity.setRelationId(dto.getRelationId()); entity.setRelationId(dto.getRelationId());
......
...@@ -78,4 +78,17 @@ public class BizDataAnalyzeDialogueRecordEntity { ...@@ -78,4 +78,17 @@ public class BizDataAnalyzeDialogueRecordEntity {
public void setDatetime(java.util.Date datetime){ public void setDatetime(java.util.Date datetime){
this.datetime = datetime; this.datetime = datetime;
} }
/**
* 积分使用情况 00.00
*/
private Double pointNum;
public Double getPointNum() {
return pointNum;
}
public void setPointNum(Double pointNum) {
this.pointNum = pointNum;
}
} }
\ No newline at end of file
package cn.com.poc.data_analyze.model; package cn.com.poc.data_analyze.model;
import java.io.Serializable; import java.io.Serializable;
import cn.com.yict.framemax.data.model.BaseModelClass; import cn.com.yict.framemax.data.model.BaseModelClass;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.Table; import javax.persistence.Table;
import javax.persistence.Id; import javax.persistence.Id;
import org.hibernate.annotations.DynamicInsert; import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate; import org.hibernate.annotations.DynamicUpdate;
import javax.persistence.GeneratedValue; import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType; import javax.persistence.GenerationType;
...@@ -22,105 +26,126 @@ import javax.persistence.GenerationType; ...@@ -22,105 +26,126 @@ import javax.persistence.GenerationType;
public class BizDataAnalyzeDialogueRecordModel extends BaseModelClass implements Serializable { public class BizDataAnalyzeDialogueRecordModel extends BaseModelClass implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** id /**
* * id
*/ */
private java.lang.Long id; private java.lang.Long id;
@Column(name = "id",length = 19) @Column(name = "id", length = 19)
@Id @GeneratedValue(strategy = GenerationType.AUTO) @Id
public java.lang.Long getId(){ @GeneratedValue(strategy = GenerationType.AUTO)
public java.lang.Long getId() {
return this.id; return this.id;
} }
public void setId(java.lang.Long id){ public void setId(java.lang.Long id) {
this.id = id; this.id = id;
super.addValidField("id"); super.addValidField("id");
} }
/** relation_id /**
*主体关联id * relation_id
*/ * 主体关联id
*/
private java.lang.String relationId; private java.lang.String relationId;
@Column(name = "relation_id",length = 120) @Column(name = "relation_id", length = 120)
public java.lang.String getRelationId(){ public java.lang.String getRelationId() {
return this.relationId; return this.relationId;
} }
public void setRelationId(java.lang.String relationId){ public void setRelationId(java.lang.String relationId) {
this.relationId = relationId; this.relationId = relationId;
super.addValidField("relationId"); super.addValidField("relationId");
} }
/** type /**
*应用类型 agent-agent应用 * type
*/ * 应用类型 agent-agent应用
*/
private java.lang.String type; private java.lang.String type;
@Column(name = "type",length = 15) @Column(name = "type", length = 15)
public java.lang.String getType(){ public java.lang.String getType() {
return this.type; return this.type;
} }
public void setType(java.lang.String type){ public void setType(java.lang.String type) {
this.type = type; this.type = type;
super.addValidField("type"); super.addValidField("type");
} }
/** member_id /**
*用户id * member_id
*/ * 用户id
*/
private java.lang.Long memberId; private java.lang.Long memberId;
@Column(name = "member_id",length = 19) @Column(name = "member_id", length = 19)
public java.lang.Long getMemberId(){ public java.lang.Long getMemberId() {
return this.memberId; return this.memberId;
} }
public void setMemberId(java.lang.Long memberId){ public void setMemberId(java.lang.Long memberId) {
this.memberId = memberId; this.memberId = memberId;
super.addValidField("memberId"); super.addValidField("memberId");
} }
/** channel /**
*使用渠道 * channel
应用调式: 调试、多模型调试 * 使用渠道
使用渠道: 首页、应用广场、链接分享、API调用 * 应用调式: 调试、多模型调试
*/ * 使用渠道: 首页、应用广场、链接分享、API调用
*/
private java.lang.String channel; private java.lang.String channel;
@Column(name = "channel",length = 20) @Column(name = "channel", length = 20)
public java.lang.String getChannel(){ public java.lang.String getChannel() {
return this.channel; return this.channel;
} }
public void setChannel(java.lang.String channel){ public void setChannel(java.lang.String channel) {
this.channel = channel; this.channel = channel;
super.addValidField("channel"); super.addValidField("channel");
} }
/** datetime /**
*对话上报时间 * datetime
*/ * 对话上报时间
*/
private java.util.Date datetime; private java.util.Date datetime;
@Column(name = "datetime",length = 19) @Column(name = "datetime", length = 19)
public java.util.Date getDatetime(){ public java.util.Date getDatetime() {
return this.datetime; return this.datetime;
} }
public void setDatetime(java.util.Date datetime){ public void setDatetime(java.util.Date datetime) {
this.datetime = datetime; this.datetime = datetime;
super.addValidField("datetime"); super.addValidField("datetime");
} }
/**
* 积分使用情况 00.00
*/
private Double pointNum;
@Column(name = "point_num", length = 19)
public Double getPointNum() {
return pointNum;
}
public void setPointNum(Double pointNum) {
this.pointNum = pointNum;
super.addValidField("pointNum");
}
} }
\ No newline at end of file
...@@ -2,17 +2,15 @@ select * ...@@ -2,17 +2,15 @@ select *
from (select bmi.nick_name as owner, from (select bmi.nick_name as owner,
baai.agent_title, baai.agent_title,
count(bdadr.relation_id) as usage_count, count(bdadr.relation_id) as usage_count,
ifnull(total_points, 0) as total_points, ifnull(sum(bdadr.point_num), 0) as total_points,
max(bdadr.datetime) as last_usage_time, max(bdadr.datetime) as last_usage_time,
(case when baai.agent_publish_status = "publish" then "Y" else "N" end) as publish_status (case when baai.agent_publish_status = "publish" then "Y" else "N" end) as publish_status
from biz_data_analyze_dialogue_record bdadr from biz_data_analyze_dialogue_record bdadr
left join biz_agent_application_info baai on baai.agent_id = bdadr.relation_id left join biz_agent_application_info baai on baai.agent_id = bdadr.relation_id
left join biz_member_info bmi on bmi.member_id = baai.member_id left join biz_member_info bmi on bmi.member_id = baai.member_id on bdap.relation_id = bdadr.relation_id
left join (select ifnull(sum(bdapr.point_num),0) as total_points,bdapr.relation_id from biz_data_analyze_point_record bdapr where 1=1 <<and bdapr.member_id = :memberId>> group by bdapr.relation_id) bdap
on bdap.relation_id = bdadr.relation_id
where 1=1 where 1=1
<< <<
and bdadr.member_id = :memberId>> and bdadr.member_id = :memberId>>
group by bdadr.relation_id,bdadr.member_id) as t1 group by bdadr.relation_id, bdadr.member_id) as t1
where 1 = 1 << and t1.last_usage_time >= :startDate and t1.last_usage_time <= :endDate >> where 1 = 1 << and t1.last_usage_time >= :startDate and t1.last_usage_time <= :endDate >>
order by t1.last_usage_time desc order by t1.last_usage_time desc
\ No newline at end of file
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