diff --git a/src/main/java/au/com/royalpay/payment/manage/actchairty/core/impls/ActChairtyServiceImp.java b/src/main/java/au/com/royalpay/payment/manage/actchairty/core/impls/ActChairtyServiceImp.java index 5ba7e36fd..b7d86ffbf 100644 --- a/src/main/java/au/com/royalpay/payment/manage/actchairty/core/impls/ActChairtyServiceImp.java +++ b/src/main/java/au/com/royalpay/payment/manage/actchairty/core/impls/ActChairtyServiceImp.java @@ -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 getWeekendAnalysis(JSONObject params) { List result = new ArrayList<>(); - List 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 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 weekStart = new ArrayList(); + 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= 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; } diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/act/ActChairtyMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/act/ActChairtyMapper.java index 21de95ebf..de5793c77 100644 --- a/src/main/java/au/com/royalpay/payment/manage/mappers/act/ActChairtyMapper.java +++ b/src/main/java/au/com/royalpay/payment/manage/mappers/act/ActChairtyMapper.java @@ -25,9 +25,7 @@ public interface ActChairtyMapper { PageList chairtyClientNum(PageBounds pageBounds); - List getChairtyWeekstartAnalysis(@Param("begin") Date begin, @Param("end") Date end); - - JSONObject getChairtyWeekAnalysis(@Param("begin") Date begin, @Param("end") Date end); + List getChairtyWeekAnalysis(@Param("begin") Date begin, @Param("end") Date end); PageList getChairtyWeekRaking(@Param("begin") Date begin, @Param("end") Date end,PageBounds pageBounds); diff --git a/src/main/resources/au/com/royalpay/payment/manage/mappers/act/ActChairtyMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/mappers/act/ActChairtyMapper.xml index edc40b062..dcf7d88f4 100644 --- a/src/main/resources/au/com/royalpay/payment/manage/mappers/act/ActChairtyMapper.xml +++ b/src/main/resources/au/com/royalpay/payment/manage/mappers/act/ActChairtyMapper.xml @@ -2,7 +2,7 @@ - - diff --git a/src/main/ui/static/actchairty/act_chairty.js b/src/main/ui/static/actchairty/act_chairty.js index 7d6af2eb7..4cd8fc7ef 100644 --- a/src/main/ui/static/actchairty/act_chairty.js +++ b/src/main/ui/static/actchairty/act_chairty.js @@ -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")