hotfix: 优化用户数查询

master
Yixian 3 years ago
parent b1c04352b6
commit ed58aae8ec

@ -64,7 +64,6 @@ public class DashboardServiceImpl implements DashboardService,DashboardAnalysisT
private MerchantInfoProvider merchantInfoProvider;
@Override
public JSONObject getCommonAnalysis1(JSONObject params) {
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);
return res;
}
private JSONObject getYesOrLasMonth(JSONObject params) {
JSONObject res = new JSONObject();
res.put("traded_partners", customerAndOrdersStatisticsMapper.countTradedClients(params));
@ -277,6 +277,7 @@ public class DashboardServiceImpl implements DashboardService,DashboardAnalysisT
analysis.add(wechatHtml5);
return analysis;
}
@Override
public List<JSONObject> getPartnerTradeAnalysisInDays(JSONObject params) {
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 partnerAnalysisBean
* @return
@ -383,6 +385,7 @@ public class DashboardServiceImpl implements DashboardService,DashboardAnalysisT
res.put(key, new BigDecimal(transactionAnalysisMapper.analysisNotSettled(params)));
return res;
}
private JSONObject getTransJSONO(JSONObject params) {
JSONObject res = new JSONObject();
JSONObject object = transactionAnalysisMapper.getClientTransaction(params);
@ -391,6 +394,7 @@ public class DashboardServiceImpl implements DashboardService,DashboardAnalysisT
res.put("customers", transactionAnalysisMapper.countCustomers(params));
return res;
}
@Override
public List<JSONObject> getTradeAnalysisInHours(JSONObject partner, AnalysisBean partnerAnalysisBean) {
String timezone = partner.getJSONObject("client").getString("timezone");
@ -533,10 +537,12 @@ public class DashboardServiceImpl implements DashboardService,DashboardAnalysisT
JSONObject totalObject = new JSONObject();
totalObject.put("client_id", 0);
generateData(format, date, totalObject);
logger.info("generate customer and orders statistics on {} done", date);
}
/**
*
*
* @param analysisDate
* @param clientId
*/
@ -599,6 +605,7 @@ public class DashboardServiceImpl implements DashboardService,DashboardAnalysisT
}
}
}
@Override
public JSONObject getPlatformAmount(JSONObject params) {
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;
}
}
private JSONObject getTodayChannelCount(JSONObject params) {
String[] channels = new String[]{"Wechat", "Alipay", "AlipayOnline", "Rpay", "rpaypmt_card", "rpaypmt_dd"};
JSONObject resp = new JSONObject();
@ -630,6 +638,7 @@ public class DashboardServiceImpl implements DashboardService,DashboardAnalysisT
}
return resp;
}
@Override
public JSONObject getOrderAndCustomerPerDay(JSONObject partner, AnalysisBean partnerAnalysisBean) {
String timezone = partner.getJSONObject("client").getString("timezone");

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

Loading…
Cancel
Save