Commit 8174429d by zhiwj

添加评价率

parent 90aa3680
package com.gic.evaluate.dao.mapper;
import com.gic.evaluate.entity.TabEvaluateMsgLog;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Param;
import java.util.Date;
import java.util.List;
import java.util.Map;
public interface TabEvaluateMsgLogMapper {
/**
......@@ -63,4 +65,6 @@ public interface TabEvaluateMsgLogMapper {
List<TabEvaluateMsgLog> listReviewMsgLogs(@Param("enterpriseId") Integer enterpriseId, @Param("startTimeOfDay") Date startTimeOfDay, @Param("endTimeOfDay") Date endTimeOfDay);
@MapKey("storeId")
Map<Integer,Map<String,Object>> orderCountByStoreId(@Param("enterpriseId") Integer enterpriseId, @Param("ids") List<Integer> storeIdList);
}
\ No newline at end of file
......@@ -3,6 +3,7 @@ package com.gic.evaluate.service;
import com.gic.evaluate.entity.TabEvaluateMsgLog;
import java.util.List;
import java.util.Map;
/**
*
......@@ -22,4 +23,6 @@ public interface EvaluateMsgLogService {
List<TabEvaluateMsgLog> listReviewMsgLogs(Integer enterpriseId);
void update(TabEvaluateMsgLog log);
Map<Integer,Map<String,Object>> orderCountByStoreId(Integer enterpriseId, List<Integer> storeIdList);
}
......@@ -8,6 +8,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
/**
*
......@@ -50,4 +51,9 @@ public class EvaluateMsgLogServiceImpl implements EvaluateMsgLogService {
public void update(TabEvaluateMsgLog log) {
tabEvaluateMsgLogMapper.updateByPrimaryKeySelective(log);
}
@Override
public Map<Integer, Map<String, Object>> orderCountByStoreId(Integer enterpriseId, List<Integer> storeIdList) {
return tabEvaluateMsgLogMapper.orderCountByStoreId(enterpriseId, storeIdList);
}
}
\ No newline at end of file
......@@ -9,6 +9,7 @@ import com.gic.enterprise.response.EnterpriseServiceResponse;
import com.gic.evaluate.constant.QuickReplyTypeEnum;
import com.gic.evaluate.qo.StoreScoreQO;
import com.gic.evaluate.qo.StoreTrendQO;
import com.gic.evaluate.service.EvaluateMsgLogService;
import com.gic.evaluate.service.EvaluateOverviewApiService;
import com.gic.evaluate.service.EvaluateService;
import org.apache.commons.collections.CollectionUtils;
......@@ -35,6 +36,8 @@ public class EvaluateOverviewApiServiceImpl implements EvaluateOverviewApiServic
@Autowired
private EvaluateService evaluateService;
@Autowired
private EvaluateMsgLogService evaluateMsgLogService;
@Override
public ServiceResponse<Map<String, Long>> chart1(Integer enterpriseId, String startTime, String endTime, List<Integer> storeIdList) {
......@@ -118,12 +121,31 @@ public class EvaluateOverviewApiServiceImpl implements EvaluateOverviewApiServic
if (CollectionUtils.isNotEmpty(trendList)) {
List<Integer> storeIdList = trendList.stream().map(
e -> {
e.put("evaluateRate", 0);
// e.put("evaluateRate", 0);
Object storeId = e.get("storeId");
return storeId == null ? null : Integer.valueOf(storeId.toString());
}
).collect(Collectors.toList());
// todo order 通过storeIdList拿到order总数
Map<Integer, Map<String, Object>> orderCountMap = evaluateMsgLogService.orderCountByStoreId(storeTrendQO.getEnterpriseId(), storeIdList);
for (Map<String, Object> e : trendList) {
// e.put("evaluateRate", 0);
Object storeId = e.get("storeId");
if (storeId != null) {
Map<String, Object> map = orderCountMap.get(Integer.valueOf(storeId.toString()));
if (map != null) {
Long totalCount = (Long) e.get("totalCount");
Long orderCount = (Long) map.get("orderCount");
if (orderCount != null && orderCount != 0) {
e.put("evaluateRate", totalCount.doubleValue() / orderCount.doubleValue());
} else {
e.put("evaluateRate", 0);
}
} else {
e.put("evaluateRate", 0);
}
}
}
}
return EnterpriseServiceResponse.success(PageHelperUtils.changePageHelperToCurrentPage(trendList));
}
......
......@@ -302,4 +302,18 @@
<include refid="Base_Column_List" />
from tab_evaluate_msg_log where enterprise_id = #{enterpriseId} and review_send_time &gt;= #{startTimeOfDay} and review_send_time &lt;= #{endTimeOfDay} and review_status = 1
</select>
<select id="orderCountByStoreId" resultType="map">
select
store_id storeId,
count(*) orderCount
from tab_evaluate_msg_log
where enterprise_id = #{enterpriseId}
<if test="null != ids">
and store_id in
<foreach collection="ids" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
group by store_id
</select>
</mapper>
\ 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