hotfix: 优化用户数查询

master
Yixian 3 years ago
parent b1c04352b6
commit ed58aae8ec

@ -64,7 +64,6 @@ public class DashboardServiceImpl implements DashboardService,DashboardAnalysisT
private MerchantInfoProvider merchantInfoProvider; private MerchantInfoProvider merchantInfoProvider;
@Override @Override
public JSONObject getCommonAnalysis1(JSONObject params) { public JSONObject getCommonAnalysis1(JSONObject params) {
String jsonStr = stringRedisTemplate.boundValueOps("org_commonAnalysis1" + params.getString("org_id") + params.getString("begin")).get(); String jsonStr = stringRedisTemplate.boundValueOps("org_commonAnalysis1" + params.getString("org_id") + params.getString("begin")).get();
@ -126,6 +125,7 @@ public class DashboardServiceImpl implements DashboardService,DashboardAnalysisT
stringRedisTemplate.boundValueOps("org_commonAnalysis2" + params.getString("org_id") + params.getString("begin")).set(res.toJSONString(), 5, TimeUnit.MINUTES); stringRedisTemplate.boundValueOps("org_commonAnalysis2" + params.getString("org_id") + params.getString("begin")).set(res.toJSONString(), 5, TimeUnit.MINUTES);
return res; return res;
} }
private JSONObject getYesOrLasMonth(JSONObject params) { private JSONObject getYesOrLasMonth(JSONObject params) {
JSONObject res = new JSONObject(); JSONObject res = new JSONObject();
res.put("traded_partners", customerAndOrdersStatisticsMapper.countTradedClients(params)); res.put("traded_partners", customerAndOrdersStatisticsMapper.countTradedClients(params));
@ -277,6 +277,7 @@ public class DashboardServiceImpl implements DashboardService,DashboardAnalysisT
analysis.add(wechatHtml5); analysis.add(wechatHtml5);
return analysis; return analysis;
} }
@Override @Override
public List<JSONObject> getPartnerTradeAnalysisInDays(JSONObject params) { public List<JSONObject> getPartnerTradeAnalysisInDays(JSONObject params) {
int date_range = Integer.parseInt(DurationFormatUtils.formatPeriod(params.getDate("begin").getTime(), params.getDate("end").getTime(), "dd")); int date_range = Integer.parseInt(DurationFormatUtils.formatPeriod(params.getDate("begin").getTime(), params.getDate("end").getTime(), "dd"));
@ -354,6 +355,7 @@ public class DashboardServiceImpl implements DashboardService,DashboardAnalysisT
/** /**
* *
*
* @param partner * @param partner
* @param partnerAnalysisBean * @param partnerAnalysisBean
* @return * @return
@ -383,6 +385,7 @@ public class DashboardServiceImpl implements DashboardService,DashboardAnalysisT
res.put(key, new BigDecimal(transactionAnalysisMapper.analysisNotSettled(params))); res.put(key, new BigDecimal(transactionAnalysisMapper.analysisNotSettled(params)));
return res; return res;
} }
private JSONObject getTransJSONO(JSONObject params) { private JSONObject getTransJSONO(JSONObject params) {
JSONObject res = new JSONObject(); JSONObject res = new JSONObject();
JSONObject object = transactionAnalysisMapper.getClientTransaction(params); JSONObject object = transactionAnalysisMapper.getClientTransaction(params);
@ -391,6 +394,7 @@ public class DashboardServiceImpl implements DashboardService,DashboardAnalysisT
res.put("customers", transactionAnalysisMapper.countCustomers(params)); res.put("customers", transactionAnalysisMapper.countCustomers(params));
return res; return res;
} }
@Override @Override
public List<JSONObject> getTradeAnalysisInHours(JSONObject partner, AnalysisBean partnerAnalysisBean) { public List<JSONObject> getTradeAnalysisInHours(JSONObject partner, AnalysisBean partnerAnalysisBean) {
String timezone = partner.getJSONObject("client").getString("timezone"); String timezone = partner.getJSONObject("client").getString("timezone");
@ -533,10 +537,12 @@ public class DashboardServiceImpl implements DashboardService,DashboardAnalysisT
JSONObject totalObject = new JSONObject(); JSONObject totalObject = new JSONObject();
totalObject.put("client_id", 0); totalObject.put("client_id", 0);
generateData(format, date, totalObject); generateData(format, date, totalObject);
logger.info("generate customer and orders statistics on {} done", date);
} }
/** /**
* *
*
* @param analysisDate * @param analysisDate
* @param clientId * @param clientId
*/ */
@ -599,6 +605,7 @@ public class DashboardServiceImpl implements DashboardService,DashboardAnalysisT
} }
} }
} }
@Override @Override
public JSONObject getPlatformAmount(JSONObject params) { public JSONObject getPlatformAmount(JSONObject params) {
String jsonStr = stringRedisTemplate.boundValueOps("org_ChannelAnalysis" + params.getString("org_id") + params.getString("begin")).get(); String jsonStr = stringRedisTemplate.boundValueOps("org_ChannelAnalysis" + params.getString("org_id") + params.getString("begin")).get();
@ -620,6 +627,7 @@ public class DashboardServiceImpl implements DashboardService,DashboardAnalysisT
return resp; return resp;
} }
} }
private JSONObject getTodayChannelCount(JSONObject params) { private JSONObject getTodayChannelCount(JSONObject params) {
String[] channels = new String[]{"Wechat", "Alipay", "AlipayOnline", "Rpay", "rpaypmt_card", "rpaypmt_dd"}; String[] channels = new String[]{"Wechat", "Alipay", "AlipayOnline", "Rpay", "rpaypmt_card", "rpaypmt_dd"};
JSONObject resp = new JSONObject(); JSONObject resp = new JSONObject();
@ -630,6 +638,7 @@ public class DashboardServiceImpl implements DashboardService,DashboardAnalysisT
} }
return resp; return resp;
} }
@Override @Override
public JSONObject getOrderAndCustomerPerDay(JSONObject partner, AnalysisBean partnerAnalysisBean) { public JSONObject getOrderAndCustomerPerDay(JSONObject partner, AnalysisBean partnerAnalysisBean) {
String timezone = partner.getJSONObject("client").getString("timezone"); String timezone = partner.getJSONObject("client").getString("timezone");

@ -441,11 +441,9 @@
</select> </select>
<select id="countOldCustomers" resultType="java.lang.Integer"> <select id="countOldCustomers" resultType="java.lang.Integer">
<![CDATA[ <![CDATA[
SELECT COUNT(DISTINCT customer_id) FROM (SELECT o.customer_id FROM pmt_transactions t SELECT COUNT(customer_id) FROM (
INNER JOIN pmt_orders o ON o.order_id = t.order_id SELECT o.customer_id,min(o.create_time) first_pay,max(o.create_time) last_pay FROM pmt_orders o
]]> WHERE o.create_time < #{end} and o.status>4
<![CDATA[
WHERE o.create_time >= #{begin} AND o.create_time < #{end}
]]> ]]>
<if test="client_ids!=null"> <if test="client_ids!=null">
AND o.client_id IN AND o.client_id IN
@ -456,29 +454,15 @@
<if test="client_ids==null and client_id != null"> <if test="client_ids==null and client_id != null">
and o.client_id=#{client_id} and o.client_id=#{client_id}
</if> </if>
<if test="org_id!=null and org_ids==null">and t.org_id=#{org_id}</if> <if test="org_id!=null and org_ids==null">and o.org_id=#{org_id}</if>
<if test="org_ids!=null">and t.org_id in <if test="org_ids!=null">and o.org_id in
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach> <foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach>
</if> </if>
<if test="channel !=null">and o.channel = #{channel}</if> <if test="channel !=null">and o.channel = #{channel}</if>
<![CDATA[ <![CDATA[
GROUP BY o.customer_id) p GROUP BY o.customer_id
where p.customer_id IN (SELECT o.customer_id FROM pmt_transactions t INNER JOIN pmt_orders o ON o.order_id = t.order_id having first_pay<#{begin} and last_pay>=#{begin}
]]> ) p
<![CDATA[
WHERE o.create_time < #{begin}
]]>
<if test="client_ids!=null">
AND o.client_id IN
<foreach collection="client_ids" open="(" close=")" separator="," item="client_id">
#{client_id}
</foreach>
</if>
<if test="client_ids==null and client_id != null">
and o.client_id=#{client_id}
</if>
<![CDATA[
)
]]> ]]>
</select> </select>

Loading…
Cancel
Save