fix : ActChairty

master
luoyang14z7 6 years ago
parent 125b1eda8d
commit d5a2bfcb6f

@ -14,6 +14,8 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
@ -61,20 +63,56 @@ public class ActChairtyServiceImp implements ActChairtyService {
@Override
public List<JSONObject> getWeekendAnalysis(JSONObject params) {
List<JSONObject> result = new ArrayList<>();
List<JSONObject> getWeekstartanalysis = actChairtyMapper.getChairtyWeekstartAnalysis(params.getDate("begin"), params.getDate("end"));
for (JSONObject getWeekendAnalysis : getWeekstartanalysis) {
Calendar rightNow = Calendar.getInstance();
rightNow.setTime(getWeekendAnalysis.getDate("weekstart"));
rightNow.add(Calendar.DAY_OF_YEAR,7);
Date dt1=rightNow.getTime();
JSONObject getAnalysis = actChairtyMapper.getChairtyWeekAnalysis(getWeekendAnalysis.getDate("weekstart"), dt1);
getWeekendAnalysis.put("count_ordernum", getAnalysis.getIntValue("count_ordernum"));
getWeekendAnalysis.put("sum_ordernum", getAnalysis.getBigDecimal("sum_ordernum"));
BigDecimal bg = new BigDecimal(getAnalysis.getIntValue("count_ordernum") * 0.01);
double f1 = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
getWeekendAnalysis.put("chairty_amount", f1);
result.add(getWeekendAnalysis);
}
List<JSONObject> getAnalysis = actChairtyMapper.getChairtyWeekAnalysis(params.getDate("begin"), params.getDate("end"));
SimpleDateFormat df=new SimpleDateFormat("yyyy-MM-dd");
Calendar cal = Calendar.getInstance();
cal.setTime(params.getDate("begin"));
cal.add(cal.DAY_OF_MONTH, -1);
long beginTime = params.getDate("begin").getTime();
long endTime = params.getDate("end").getTime();
long betweenDays = (long)((endTime - beginTime) / (1000 * 60 * 60 *24));
List<String> weekStart = new ArrayList<String>();
for(int i=0;i<=betweenDays;i++){
cal.add(cal.DAY_OF_MONTH, 1);//DATE=日
if ((cal.get(Calendar.DAY_OF_WEEK)) == 2) {
weekStart.add(df.format(cal.getTime()));
}
}
for(int i=0;i<weekStart.size();i++){
JSONObject weekDay = new JSONObject();
BigDecimal count_ordernum = new BigDecimal(0);
BigDecimal sum_ordernum = new BigDecimal(0);
String weekS = weekStart.get(i);
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
try {
Date dateStar = dateFormat.parse(weekS);
Calendar d1 = Calendar.getInstance();
d1.setTime(dateStar);
d1.add(Calendar.DAY_OF_YEAR,7);
Date dateEnd = d1.getTime();
for (int b = 0; b < getAnalysis.size(); b++) {
long orderDate = getAnalysis.get(b).getDate("orderdate").getTime();
if (orderDate >= dateStar.getTime() && orderDate < dateEnd.getTime()) {
count_ordernum = count_ordernum.add(getAnalysis.get(b).getBigDecimal("count_ordernum"));
sum_ordernum = sum_ordernum.add(getAnalysis.get(b).getBigDecimal("sum_ordernum"));
}
}
BigDecimal chairty = new BigDecimal(0.01);
BigDecimal chairty_amount = count_ordernum.multiply(chairty);
double f1 = sum_ordernum.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
double f2 = chairty_amount.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
weekDay.put("weekstart", weekStart.get(i));
weekDay.put("count_ordernum", count_ordernum);
weekDay.put("sum_ordernum", f1);
weekDay.put("chairty_amount",f2 );
result.add(weekDay);
} catch (Exception e) {
e.printStackTrace();
}
}
return result;
}

@ -25,9 +25,7 @@ public interface ActChairtyMapper {
PageList<JSONObject> chairtyClientNum(PageBounds pageBounds);
List<JSONObject> getChairtyWeekstartAnalysis(@Param("begin") Date begin, @Param("end") Date end);
JSONObject getChairtyWeekAnalysis(@Param("begin") Date begin, @Param("end") Date end);
List<JSONObject> getChairtyWeekAnalysis(@Param("begin") Date begin, @Param("end") Date end);
PageList<JSONObject> getChairtyWeekRaking(@Param("begin") Date begin, @Param("end") Date end,PageBounds pageBounds);

@ -2,7 +2,7 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="au.com.royalpay.payment.manage.mappers.act.ActChairtyMapper">
<select id="chairtyClientNum" resultType="com.alibaba.fastjson.JSONObject">
select DISTINCT (count(order_id)) as count_ordernum ,client_moniker,active_time,ifnull(sum(pmt_transactions.transaction_amount),0) as sum_ordernum
select DISTINCT (count(order_id)) as count_ordernum ,client_moniker,active_time,ifnull(sum(pmt_transactions.clearing_amount),0) as sum_ordernum
from act_charity
left JOIN pmt_transactions on act_charity.client_id = pmt_transactions.client_id
and pmt_transactions.transaction_type='Credit' and pmt_transactions.transaction_time>=act_charity.active_time
@ -10,23 +10,16 @@
and pmt_transactions.channel != 'Settlement'
GROUP BY act_charity.client_id order by sum_ordernum desc
</select>
<select id="getChairtyWeekstartAnalysis" resultType="com.alibaba.fastjson.JSONObject">
select DATE_FORMAT(pmt_transactions.transaction_time,'%Y-%m-%d') as weekstart from act_charity
inner JOIN pmt_transactions on act_charity.client_id = pmt_transactions.client_id
where dayofweek(pmt_transactions.transaction_time)=2 and pmt_transactions.transaction_time&gt;=#{begin} and pmt_transactions.transaction_time&lt;=#{end}
and pmt_transactions.refund_id is null and pmt_transactions.channel != 'Settlement'
group by weekstart order by weekstart asc;
</select>
<select id="getChairtyWeekAnalysis" resultType="com.alibaba.fastjson.JSONObject">
select DISTINCT (count(order_id)) as count_ordernum,ifnull(sum(pmt_transactions.transaction_amount),0) as sum_ordernum from act_charity left JOIN pmt_transactions ON act_charity.client_id = pmt_transactions.client_id
and pmt_transactions.transaction_type='Credit' and pmt_transactions.transaction_time&gt;=#{begin} and pmt_transactions.transaction_time&lt;=#{end} and pmt_transactions.transaction_time>=act_charity.active_time
and pmt_transactions.refund_id is null and pmt_transactions.channel != 'Settlement'
select DISTINCT (count(order_id)) as count_ordernum,date_format(pmt_transactions.transaction_time,'%Y-%m-%d') as orderdate,client_moniker,ifnull(sum(pmt_transactions.clearing_amount),0) as sum_ordernum from act_charity inner JOIN pmt_transactions ON act_charity.client_id = pmt_transactions.client_id
and pmt_transactions.transaction_type='Credit' and pmt_transactions.transaction_time>=#{begin} and pmt_transactions.transaction_time&lt;=#{end} and pmt_transactions.transaction_time>=act_charity.active_time
and pmt_transactions.channel != 'Settlement'
group by date_format(pmt_transactions.transaction_time,'%Y-%m-%d')
</select>
<select id="getChairtyWeekRaking" resultType="com.alibaba.fastjson.JSONObject">
select DISTINCT (count(pmt_transactions.order_id)) *0.01 as chair_ordernum,act_charity.client_moniker,ifnull(sum(pmt_transactions.transaction_amount),0) as sum_ordernum from act_charity left JOIN pmt_transactions ON act_charity.client_id = pmt_transactions.client_id
select DISTINCT (count(pmt_transactions.order_id)) *0.01 as chair_ordernum,act_charity.client_moniker,ifnull(sum(pmt_transactions.clearing_amount),0) as sum_ordernum from act_charity left JOIN pmt_transactions ON act_charity.client_id = pmt_transactions.client_id
and pmt_transactions.transaction_type='Credit' and pmt_transactions.transaction_time&gt;=#{begin} and pmt_transactions.transaction_time&lt;=#{end} and pmt_transactions.transaction_time>=act_charity.active_time
GROUP BY act_charity.client_moniker order by sum_ordernum desc
</select>

@ -84,13 +84,21 @@ define(['angular', 'uiBootstrap', 'uiRouter', 'angularEcharts'], function (angul
};
};
$scope.getClientsCashbackRankingByDate = function (date,page) {
var dateend = angular.copy($scope.params);
$scope.event_date = date;
var params = {};
params.begin = date;
var event_date_format=date.replace(/^(\d{4})(\d{2})(\d{2})$/, "$1-$2-$3")
var endDate = new Date(event_date_format);
endDate.setDate(endDate.getDate()+6);
params.end =$filter('date')(endDate,'yyyyMMdd');
var end1 = $filter('date')(endDate, 'yyyyMMdd');
var end2 = $filter('date')(dateend.end, 'yyyyMMdd');
if (end1 > end2) {
params.end =$filter('date')(dateend.end,'yyyyMMdd');
}
else {
params.end =$filter('date')(endDate,'yyyyMMdd');
}
params.page = page||$scope.day_ranking_pagination.page || 1;
params.limit = 10;
if ($scope.params.cashback_type){
@ -182,6 +190,7 @@ define(['angular', 'uiBootstrap', 'uiRouter', 'angularEcharts'], function (angul
$scope.cashBack_total_daily = $scope.cashbackDaily[params.dataIndex].chairty_amount;
var event_date = $scope.cashbackDaily[params.dataIndex].weekstart;
if (event_date) {
event_date+="";
var event_date_format=event_date.replace(/^(\d{4})(\d{2})(\d{2})$/, "$1-$2-$3")

Loading…
Cancel
Save