Commit 01a72da0 authored by hanfeng's avatar hanfeng

修改统计

parent bc2b8858
package com.xxfc.platform.order.entity; package com.xxfc.platform.order.entity;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import java.math.BigDecimal; import java.math.BigDecimal;
...@@ -9,39 +12,52 @@ import java.math.BigDecimal; ...@@ -9,39 +12,52 @@ import java.math.BigDecimal;
*/ */
@Data @Data
@ApiModel(value = "月订单统计实体")
public class OrderStatistics { public class OrderStatistics {
/**
* 公司id
*/
@ApiModelProperty(value = "公司id")
private Integer branchCompanyId;
/** /**
* 月成交总金额 * 月成交总金额
*/ */
@ApiModelProperty(value = "月成交总金额")
private BigDecimal totalGmv; private BigDecimal totalGmv;
/** /**
* 月押金总额 * 月押金总额
*/ */
@ApiModelProperty(value = "月押金总额")
private BigDecimal totalSecurityDeposit; private BigDecimal totalSecurityDeposit;
/** /**
* 月退还押金总额 * 月退还押金总额
*/ */
@ApiModelProperty(value = "月退还押金总额")
private BigDecimal totalRefundSecurityDeposit; private BigDecimal totalRefundSecurityDeposit;
/** /**
* 月赔偿总额 * 月赔偿总额
*/ */
@ApiModelProperty(value = "月赔偿总额")
private BigDecimal totalCompensation; private BigDecimal totalCompensation;
/** /**
* 月违章总额 * 月违章总额
*/ */
@ApiModelProperty(value = "月违章总额")
private BigDecimal totalForfeit; private BigDecimal totalForfeit;
/** /**
* 月取消订单扣款总额 * 月取消订单扣款总额
*/ */
@ApiModelProperty(value = "月取消订单扣款总额")
private BigDecimal totalPenalSum; private BigDecimal totalPenalSum;
/** /**
* 月延期扣款总额 * 月延期扣款总额
*/ */
@ApiModelProperty(value = "月延期扣款总额")
private BigDecimal totalPostpone; private BigDecimal totalPostpone;
} }
...@@ -12,12 +12,11 @@ import org.springframework.web.bind.annotation.*; ...@@ -12,12 +12,11 @@ import org.springframework.web.bind.annotation.*;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set;
/** /**
* Created by ace on 2017/9/15. * Created by ace on 2017/9/15.
*/ */
@FeignClient(name = "vehicle") @FeignClient(name = "xx-order")
public interface OrderFeign { public interface OrderFeign {
@GetMapping("/baseOrder/entityList") @GetMapping("/baseOrder/entityList")
public ObjectRestResponse<List<BaseOrder>> baseOrderEntityList(@RequestParam("entity") Map<String, Object> entity); public ObjectRestResponse<List<BaseOrder>> baseOrderEntityList(@RequestParam("entity") Map<String, Object> entity);
......
...@@ -8,12 +8,14 @@ import com.xxfc.platform.order.mapper.DailyMembersOrderStatisticsMapper; ...@@ -8,12 +8,14 @@ import com.xxfc.platform.order.mapper.DailyMembersOrderStatisticsMapper;
import com.xxfc.platform.order.mapper.DailyTravelOrderStatisticsMapper; import com.xxfc.platform.order.mapper.DailyTravelOrderStatisticsMapper;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.beanutils.BeanUtils; import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
...@@ -30,12 +32,15 @@ public class DailyMembersOrderStatisticsBiz extends BaseBiz<DailyMembersOrderSta ...@@ -30,12 +32,15 @@ public class DailyMembersOrderStatisticsBiz extends BaseBiz<DailyMembersOrderSta
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public boolean memberOrderStatistics() { public boolean memberOrderStatistics() {
try { try {
HashMap<String, Object> resultMap = new HashMap<>(); List<Map<String, Object>> travelGmv = mapper.getTravelGmv();
Map<String, Object> travelGmv = mapper.getTravelGmv(); if (CollectionUtils.isEmpty(travelGmv)) {
resultMap.putAll(travelGmv); return true;
}
for (Map<String, Object> stringObjectMap : travelGmv) {
DailyMembersOrderStatistics MembersStatistics = new DailyMembersOrderStatistics(); DailyMembersOrderStatistics MembersStatistics = new DailyMembersOrderStatistics();
BeanUtils.copyProperties(MembersStatistics, resultMap); BeanUtils.copyProperties(MembersStatistics, stringObjectMap);
insertSelective(MembersStatistics); insertSelective(MembersStatistics);
}
return true; return true;
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
......
...@@ -6,6 +6,7 @@ import com.github.wxiaoqi.security.common.biz.BaseBiz; ...@@ -6,6 +6,7 @@ import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.xxfc.platform.order.entity.DailyTravelOrderStatistics; import com.xxfc.platform.order.entity.DailyTravelOrderStatistics;
import com.xxfc.platform.order.entity.OrderStatistics; import com.xxfc.platform.order.entity.OrderStatistics;
import com.xxfc.platform.order.mapper.DailyTravelOrderStatisticsMapper; import com.xxfc.platform.order.mapper.DailyTravelOrderStatisticsMapper;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport; import org.springframework.transaction.interceptor.TransactionAspectSupport;
...@@ -41,22 +42,23 @@ public class DailyTravelOrderStatisticsBiz extends BaseBiz<DailyTravelOrderStati ...@@ -41,22 +42,23 @@ public class DailyTravelOrderStatisticsBiz extends BaseBiz<DailyTravelOrderStati
private void insertByList(ArrayList<DailyTravelOrderStatistics> objects) throws Exception { private void insertByList(ArrayList<DailyTravelOrderStatistics> objects) throws Exception {
if (CollectionUtils.isNotEmpty(objects)) {
HashMap<Integer, DailyTravelOrderStatistics> map = new HashMap<>(); HashMap<Integer, DailyTravelOrderStatistics> map = new HashMap<>();
for (DailyTravelOrderStatistics object : objects) { for (DailyTravelOrderStatistics object : objects) {
DailyTravelOrderStatistics statistics = map.get(object.getBranchCompanyId()); DailyTravelOrderStatistics statistics = map.get(object.getBranchCompanyId());
if (statistics==null) { if (statistics == null) {
statistics= new DailyTravelOrderStatistics(); statistics = new DailyTravelOrderStatistics();
map.put(object.getBranchCompanyId(),statistics); map.put(object.getBranchCompanyId(), statistics);
} }
BeanUtil.copyProperties(object,statistics, CopyOptions.create().setIgnoreNullValue(true).setIgnoreError(true)); BeanUtil.copyProperties(object, statistics, CopyOptions.create().setIgnoreNullValue(true).setIgnoreError(true));
} }
for (Map.Entry<Integer, DailyTravelOrderStatistics> e : map.entrySet()) { for (Map.Entry<Integer, DailyTravelOrderStatistics> e : map.entrySet()) {
insertSelectiveRe(e.getValue()); insertSelectiveRe(e.getValue());
} }
}
} }
......
...@@ -70,8 +70,9 @@ public class DailyVehicleOrderStatisticsBiz extends BaseBiz<DailyVehicleOrderSta ...@@ -70,8 +70,9 @@ public class DailyVehicleOrderStatisticsBiz extends BaseBiz<DailyVehicleOrderSta
} }
private void InsertByList(ArrayList<DailyVehicleOrderStatistics> result)throws Exception { private void InsertByList(ArrayList<DailyVehicleOrderStatistics> result) throws Exception {
if(CollectionUtils.isNotEmpty(result)) {
Map<Integer, DailyVehicleOrderStatistics> map = new HashMap<>(); Map<Integer, DailyVehicleOrderStatistics> map = new HashMap<>();
for (DailyVehicleOrderStatistics value : result) { for (DailyVehicleOrderStatistics value : result) {
...@@ -92,6 +93,7 @@ public class DailyVehicleOrderStatisticsBiz extends BaseBiz<DailyVehicleOrderSta ...@@ -92,6 +93,7 @@ public class DailyVehicleOrderStatisticsBiz extends BaseBiz<DailyVehicleOrderSta
} }
} }
}
} }
......
...@@ -4,6 +4,7 @@ import com.xxfc.platform.order.entity.DailyMembersOrderStatistics; ...@@ -4,6 +4,7 @@ import com.xxfc.platform.order.entity.DailyMembersOrderStatistics;
import com.xxfc.platform.order.entity.OrderStatistics; import com.xxfc.platform.order.entity.OrderStatistics;
import tk.mybatis.mapper.common.Mapper; import tk.mybatis.mapper.common.Mapper;
import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
...@@ -12,7 +13,7 @@ import java.util.Map; ...@@ -12,7 +13,7 @@ import java.util.Map;
*/ */
public interface DailyMembersOrderStatisticsMapper extends Mapper<DailyMembersOrderStatistics> { public interface DailyMembersOrderStatisticsMapper extends Mapper<DailyMembersOrderStatistics> {
Map<String, Object> getTravelGmv(); List<Map<String, Object>> getTravelGmv();
OrderStatistics monthOrderTotal(Integer companyId); OrderStatistics monthOrderTotal(Integer companyId);
......
...@@ -12,6 +12,7 @@ import com.xxfc.platform.order.biz.DailyTravelOrderStatisticsBiz; ...@@ -12,6 +12,7 @@ import com.xxfc.platform.order.biz.DailyTravelOrderStatisticsBiz;
import com.xxfc.platform.order.biz.DailyVehicleOrderStatisticsBiz; import com.xxfc.platform.order.biz.DailyVehicleOrderStatisticsBiz;
import com.xxfc.platform.order.biz.OrderStatisticsBiz; import com.xxfc.platform.order.biz.OrderStatisticsBiz;
import com.xxfc.platform.order.entity.OrderStatistics; import com.xxfc.platform.order.entity.OrderStatistics;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
...@@ -23,7 +24,8 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -23,7 +24,8 @@ import org.springframework.web.bind.annotation.RestController;
* @author Administrator * @author Administrator
*/ */
@RestController @RestController
@RequestMapping("orderStatisticsA") @RequestMapping("orderStatistics")
@Api(description = "每月总的订单统计")
public class OrderStatisticsController extends BaseController<OrderStatisticsBiz, OrderStatistics> { public class OrderStatisticsController extends BaseController<OrderStatisticsBiz, OrderStatistics> {
@Autowired @Autowired
private UserFeign userFeign; private UserFeign userFeign;
...@@ -45,6 +47,11 @@ public class OrderStatisticsController extends BaseController<OrderStatisticsBiz ...@@ -45,6 +47,11 @@ public class OrderStatisticsController extends BaseController<OrderStatisticsBiz
*/ */
private final Integer TYEP_MEMBER = 3; private final Integer TYEP_MEMBER = 3;
/**
* 月总数据
*/
private final Integer TYEP_TOTAL = 4;
@Autowired @Autowired
private DailyVehicleOrderStatisticsBiz vehicleBiz; private DailyVehicleOrderStatisticsBiz vehicleBiz;
...@@ -58,7 +65,6 @@ public class OrderStatisticsController extends BaseController<OrderStatisticsBiz ...@@ -58,7 +65,6 @@ public class OrderStatisticsController extends BaseController<OrderStatisticsBiz
@ApiOperation("获取订单统计数据") @ApiOperation("获取订单统计数据")
@GetMapping("/findAll/{type}") @GetMapping("/findAll/{type}")
public ObjectRestResponse findAll(@PathVariable Integer type) { public ObjectRestResponse findAll(@PathVariable Integer type) {
ObjectRestResponse<UserDTO> userDTOObjectRestResponse = userFeign.userinfoByToken(userAuthConfig.getToken(getRequest())); ObjectRestResponse<UserDTO> userDTOObjectRestResponse = userFeign.userinfoByToken(userAuthConfig.getToken(getRequest()));
if (userDTOObjectRestResponse==null||userDTOObjectRestResponse.getData()==null) { if (userDTOObjectRestResponse==null||userDTOObjectRestResponse.getData()==null) {
throw new BaseException("请登录!"); throw new BaseException("请登录!");
...@@ -66,14 +72,19 @@ public class OrderStatisticsController extends BaseController<OrderStatisticsBiz ...@@ -66,14 +72,19 @@ public class OrderStatisticsController extends BaseController<OrderStatisticsBiz
UserDTO user = userDTOObjectRestResponse.getData(); UserDTO user = userDTOObjectRestResponse.getData();
Integer companyId = user.getCompanyId(); Integer companyId = user.getCompanyId();
if (TYEP_VEHICLE.equals(type)) { if (TYEP_VEHICLE.equals(type)) {
return ObjectRestResponse.succ(vehicleBiz.findAll(companyId)); OrderStatistics vehicle = vehicleBiz.findAll(companyId);
return ObjectRestResponse.succ(vehicle);
} }
if (TYEP_TOUR.equals(type)) { if (TYEP_TOUR.equals(type)) {
return ObjectRestResponse.succ(TravelBiz.findAll(companyId)); OrderStatistics tour = TravelBiz.findAll(companyId);
return ObjectRestResponse.succ(tour);
} }
if (TYEP_MEMBER.equals(type)) { if (TYEP_MEMBER.equals(type)) {
return ObjectRestResponse.succ(membersBiz.findAll(companyId)); OrderStatistics member = membersBiz.findAll(companyId);
return ObjectRestResponse.succ(member);
} }
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE,"参数为空!"); return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE,"参数为空!");
} }
} }
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<mapper namespace="com.xxfc.platform.order.mapper.DailyTravelOrderStatisticsMapper"> <mapper namespace="com.xxfc.platform.order.mapper.DailyTravelOrderStatisticsMapper">
<!-- 获取旅游订单成交金--> <!-- 获取旅游订单成交金-->
<select id="getTravelGmv" resultType="list"> <select id="getTravelGmv" resultType="com.xxfc.platform.order.entity.DailyTravelOrderStatistics">
select select
t.start_company_id as branchCompanyId, t.start_company_id as branchCompanyId,
COALESCE(date_format(FROM_UNIXTIME(o.pay_time/1000),'%Y-%c-%d'),date(DATE_SUB(now(),interval 1 day))) as oneDay, COALESCE(date_format(FROM_UNIXTIME(o.pay_time/1000),'%Y-%c-%d'),date(DATE_SUB(now(),interval 1 day))) as oneDay,
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
</select> </select>
<!-- 取消订单扣除款项总和--> <!-- 取消订单扣除款项总和-->
<select id="getTravelPenalSum" resultType="list"> <select id="getTravelPenalSum" resultType="com.xxfc.platform.order.entity.DailyTravelOrderStatistics">
SELECT SELECT
t.start_company_id as branchCompanyId, t.start_company_id as branchCompanyId,
IFNULL(SUM(r.deduct_amount),0) as penalSum IFNULL(SUM(r.deduct_amount),0) as penalSum
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<mapper namespace="com.xxfc.platform.order.mapper.DailyVehicleOrderStatisticsMapper"> <mapper namespace="com.xxfc.platform.order.mapper.DailyVehicleOrderStatisticsMapper">
<!-- 获取每日租车订单成交金和押金总额--> <!-- 获取每日租车订单成交金和押金总额-->
<select id="getGmvAndMarginTotal" resultType="List"> <select id="getGmvAndMarginTotal" resultType="com.xxfc.platform.order.entity.DailyVehicleOrderStatistics">
SELECT SELECT
v.start_company_id AS branchCompanyId, v.start_company_id AS branchCompanyId,
COALESCE(date_format(FROM_UNIXTIME(b.pay_time/1000),'%Y-%c-%d'),date(DATE_SUB(now(),interval 1 day))) as oneDay, COALESCE(date_format(FROM_UNIXTIME(b.pay_time/1000),'%Y-%c-%d'),date(DATE_SUB(now(),interval 1 day))) as oneDay,
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
<!-- 退还押金总额--> <!-- 退还押金总额-->
<select id="getRefundSecurityDeposit" resultType="List"> <select id="getRefundSecurityDeposit" resultType="com.xxfc.platform.order.entity.DailyVehicleOrderStatistics">
SELECT SELECT
v.start_company_id AS branchCompanyId, v.start_company_id AS branchCompanyId,
IFNULL(SUM(r.refund_amount),0) AS refundSecurityDeposit IFNULL(SUM(r.refund_amount),0) AS refundSecurityDeposit
...@@ -53,7 +53,7 @@ ...@@ -53,7 +53,7 @@
<!-- 取消订单扣除款项总和--> <!-- 取消订单扣除款项总和-->
<select id="getPenalSum" resultType="List"> <select id="getPenalSum" resultType="com.xxfc.platform.order.entity.DailyVehicleOrderStatistics">
SELECT SELECT
v.start_company_id as branchCompanyId, v.start_company_id as branchCompanyId,
IFNULL(SUM(r.deduct_amount),0) as penalSum IFNULL(SUM(r.deduct_amount),0) as penalSum
...@@ -80,7 +80,7 @@ ...@@ -80,7 +80,7 @@
</select> </select>
<!-- 获取赔偿和延期JSON字符串--> <!-- 获取赔偿和延期JSON字符串-->
<select id="getCompensationAndPostpone" resultType="List"> <select id="getCompensationAndPostpone" resultType="HashMap">
SELECT SELECT
v.start_company_id AS branchCompanyId, v.start_company_id AS branchCompanyId,
c.ded_detail AS dedDetail c.ded_detail AS dedDetail
...@@ -106,7 +106,7 @@ ...@@ -106,7 +106,7 @@
</select> </select>
<!--违章--> <!--违章-->
<select id="getViolationMoney" resultType="List"> <select id="getViolationMoney" resultType="com.xxfc.platform.order.entity.DailyVehicleOrderStatistics">
SELECT SELECT
d.start_company_id AS branchCompanyId, d.start_company_id AS branchCompanyId,
v.price as violationMoney v.price as violationMoney
......
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