Commit 5c6c7ab5 authored by jiaorz's avatar jiaorz

Merge remote-tracking branch 'origin/dev' into dev

# Conflicts:
#	xx-order/xx-order-server/src/main/java/com/xxfc/platform/order/biz/BaseOrderBiz.java
parents db5593d3 bf5dcdd5
......@@ -5,6 +5,10 @@ import lombok.Data;
import java.util.ArrayList;
import java.util.List;
/**
* 手动给集合分页
* @author Administrator
*/
@Data
public class PageResult<M> {
/** 页码 */
......
......@@ -168,6 +168,16 @@ public interface UserFeign {
boolean isCollectionByTypeAndTypeId(@RequestParam("userId") Integer userId,
@RequestParam(value = "type") int type,
@RequestParam("id") Integer typId);
/**
* 通过公司id,获取员工的下级用户id
* @param parentCompanyId
* @return
*/
@GetMapping("/postion/admin/userid")
List<Integer> getUserIdByParentCompany(@RequestParam("parentCompanyId") List<Integer> parentCompanyId);
@GetMapping("/app/user/list_staff")
List<UserStaffBo> findAllStaffs();
......
......@@ -345,4 +345,7 @@ public class AppUserPositionTempBiz extends BaseBiz<AppUserPositionTempMapper, A
}
public List<Integer> getUserIdByParentCompany(List<Integer> parentCompanyId) {
return mapper.getUserIdByParentCompany(parentCompanyId);
}
}
......@@ -10,6 +10,7 @@ import com.github.wxiaoqi.security.admin.dto.StaffStatisticsFindDTO;
import com.github.wxiaoqi.security.admin.vo.WalletPostionVo;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.google.common.collect.Lists;
import com.xxfc.platform.order.contant.enumerate.StatisticsStatusEnum;
import com.xxfc.platform.order.feign.OrderFeign;
import com.xxfc.platform.order.pojo.dto.OrderDTO;
......@@ -86,7 +87,7 @@ public class StaffStatisticsBiz {
Row ctpRow = sheet.createRow(1);
Cell ctpCell = ctpRow.createCell(0);
//缺少判断 公司 身份 时间
//
String companyName = StringUtils.hasText(staffStatisticsFindDTO.getCompanyName()) ? staffStatisticsFindDTO.getCompanyName() : "全集团";
String postionName = StringUtils.hasText(staffStatisticsFindDTO.getPostionName()) ? staffStatisticsFindDTO.getPostionName() : "全部员工";
String startTimeStr = staffStatisticsFindDTO.getStartDate()==null?"":DateUtil.format(staffStatisticsFindDTO.getStartDate(), "yyyy-MM-dd HH:mm:ss");
......@@ -250,7 +251,7 @@ public class StaffStatisticsBiz {
//2.根据员工id范围和其他条件分页查询
List<Integer> userIds = allStaffs.stream().map(UserStaffBo::getUserId).collect(Collectors.toList());
List<AppUserSellingWaterDTO> appUserSellingWaterDTOS = appUserSellingWaterBiz.findStatffSellerWaterByUserIdsAndTime(userIds, staffStatisticsFindDTO.getStartDate(), staffStatisticsFindDTO.getEndDate());
Map<Integer, Map<String, Map<Integer, Map<Integer, List<AppUserSellingWaterDTO>>>>> sellingWaterMap = new HashMap<>();
Map<Integer, Map<String, Map<Integer, List<AppUserSellingWaterDTO>>>> sellingWaterMap = new HashMap<>();
if (CollectionUtils.isNotEmpty(appUserSellingWaterDTOS)) {
//3.根据订单id查询订单相关信息
......@@ -265,7 +266,7 @@ public class StaffStatisticsBiz {
sellingWaterMap = appUserSellingWaterDTOS.stream().collect(Collectors.groupingBy(AppUserSellingWaterDTO::getUserId,
Collectors.groupingBy(AppUserSellingWaterDTO::getStateGroup, Collectors.groupingBy(AppUserSellingWaterDTO::getOrderType, Collectors.groupingBy(AppUserSellingWaterDTO::getStatus, Collectors.toList())))));
Collectors.groupingBy(AppUserSellingWaterDTO::getStateGroup, Collectors.groupingBy(AppUserSellingWaterDTO::getOrderType,Collectors.toList()))));
}
Map<Integer, String> companyMap = vehicleFeign.findCompanyMap();
......@@ -275,13 +276,13 @@ public class StaffStatisticsBiz {
String stateGroup = String.format("%d-%d-%d", userStaffBo.getUserId(), userStaffBo.getPostionId(), userStaffBo.getCompanyId() == null ? NO_COMPANY_STATE : userStaffBo.getCompanyId());
StaffStatisticsBo staffStatisticsBo = creatDefaultStaffStatistics(userStaffBo);
if (!sellingWaterMap.isEmpty()) {
Map<String, Map<Integer, Map<Integer, List<AppUserSellingWaterDTO>>>> userSellingWaterMap = sellingWaterMap.get(userStaffBo.getUserId());
Map<String, Map<Integer, List<AppUserSellingWaterDTO>>> userSellingWaterMap = sellingWaterMap.get(userStaffBo.getUserId());
if (userSellingWaterMap != null && !userSellingWaterMap.isEmpty()) {
AtomicReference<BigDecimal> royaltyAmountAtomicReference = new AtomicReference<>(BigDecimal.ZERO);
List<String> postionNames = new ArrayList<>(staffStatisticsBo.getPostionNames());
List<Integer> postionIds = new ArrayList<>(staffStatisticsBo.getPostionIds());
List<String> companyNames = new ArrayList<>(staffStatisticsBo.getCompanyNames());
List<Integer> compnayIds = new ArrayList<>(staffStatisticsBo.getCompnayIds());
List<String> postionNames = Lists.newArrayList(staffStatisticsBo.getPostionNames());
List<Integer> postionIds = Lists.newArrayList(staffStatisticsBo.getPostionIds());
List<String> companyNames = Lists.newArrayList(staffStatisticsBo.getCompanyNames());
List<Integer> compnayIds = Lists.newArrayList(staffStatisticsBo.getCompnayIds());
userSellingWaterMap.forEach((K, V) -> {
if (!K.equals(stateGroup)) {
String[] sates = K.split("-");
......@@ -319,7 +320,7 @@ public class StaffStatisticsBiz {
return staffStatisticsBos;
}
private StaffStatisticsBo wrapStaffStatistics(Map<Integer, Map<Integer, List<AppUserSellingWaterDTO>>> waterDTOSMap, AtomicReference<BigDecimal> royaltyAmountAtomicReference, StaffStatisticsBo staffStatisticsBo) {
private StaffStatisticsBo wrapStaffStatistics(Map<Integer, List<AppUserSellingWaterDTO>> waterDTOSMap, AtomicReference<BigDecimal> royaltyAmountAtomicReference, StaffStatisticsBo staffStatisticsBo) {
waterDTOSMap.forEach((K, V) -> {
Map<String, Object> orderRentResultMap = wrapStaffStatisticsMap(V);
BigDecimal royaltyAmount = royaltyAmountAtomicReference.get();
......@@ -345,34 +346,45 @@ public class StaffStatisticsBiz {
return staffStatisticsBo;
}
private Map<String, Object> wrapStaffStatisticsMap(Map<Integer, List<AppUserSellingWaterDTO>> sellingWaters) {
private Map<String, Object> wrapStaffStatisticsMap(List<AppUserSellingWaterDTO> sellingWaters) {
Map<String, Object> staffStatisticsResultMap = new HashMap<>(2);
AtomicInteger orderCounter = new AtomicInteger(0);
if (sellingWaters == null || sellingWaters.isEmpty()) {
if (CollectionUtils.isEmpty(sellingWaters)) {
staffStatisticsResultMap.put(TOTAL_AMOUNT_VAL, BigDecimal.ZERO);
staffStatisticsResultMap.put(TOTAL_NUM_VAL, orderCounter.get());
}
BigDecimal totalAmount = BigDecimal.ZERO;
BigDecimal royaltyAmount = BigDecimal.ZERO;
Set<Map.Entry<Integer, List<AppUserSellingWaterDTO>>> sellingWaterSet = sellingWaters.entrySet();
for (Map.Entry<Integer, List<AppUserSellingWaterDTO>> sellingWaterEntry : sellingWaterSet) {
List<AppUserSellingWaterDTO> waterDTOS = sellingWaterEntry.getValue();
for (AppUserSellingWaterDTO waterDTO : waterDTOS) {
if (sellingWaterEntry.getKey() == 0) {
Map<Integer, List<AppUserSellingWaterDTO>> orderSellingMap = sellingWaters.stream().collect(Collectors.groupingBy(AppUserSellingWaterDTO::getOrderId, Collectors.toList()));
Set<Map.Entry<Integer, List<AppUserSellingWaterDTO>>> orderSellingSet = orderSellingMap.entrySet();
for (Map.Entry<Integer, List<AppUserSellingWaterDTO>> orderSellingEntry : orderSellingSet) {
BigDecimal inAmount = BigDecimal.ZERO;
BigDecimal outAmount = BigDecimal.ZERO;
boolean isCommissionZero=false;
List<AppUserSellingWaterDTO> appUserSellingWaterDTOS = orderSellingEntry.getValue();
for (AppUserSellingWaterDTO waterDTO : appUserSellingWaterDTOS) {
if (waterDTO.getStatus() == 0) {
royaltyAmount = royaltyAmount.add(waterDTO.getCommission());
totalAmount = totalAmount.add(waterDTO.getPrice());
orderCounter.incrementAndGet();
totalAmount = totalAmount.add(waterDTO.getCommission().divide(new BigDecimal(String.valueOf(waterDTO.getExtract()/100.00)),2,BigDecimal.ROUND_HALF_UP));
inAmount = inAmount.add(waterDTO.getCommission());
isCommissionZero = waterDTO.getCommission().intValue()==0;
}
if (sellingWaterEntry.getKey() == 1) {
if (waterDTO.getStatus() == 1) {
royaltyAmount = royaltyAmount.subtract(waterDTO.getCommission());
totalAmount = totalAmount.subtract(waterDTO.getPrice());
totalAmount = totalAmount.subtract(waterDTO.getCommission().divide(new BigDecimal(String.valueOf(waterDTO.getExtract()/100.00)),2,BigDecimal.ROUND_HALF_UP));
outAmount = outAmount.add(waterDTO.getCommission());
isCommissionZero=!isCommissionZero;
}
}
if(appUserSellingWaterDTOS.size()==1 || inAmount.subtract(outAmount).doubleValue()>0 || isCommissionZero){
orderCounter.incrementAndGet();
}
}
staffStatisticsResultMap.put(TOTAL_AMOUNT_VAL, totalAmount);
staffStatisticsResultMap.put(TOTAL_NUM_VAL, orderCounter.get());
staffStatisticsResultMap.put(TOTAL_COMMISSION_VAL, royaltyAmount);
}
return staffStatisticsResultMap;
}
......
......@@ -3,8 +3,12 @@ package com.github.wxiaoqi.security.admin.mapper;
import com.github.wxiaoqi.security.admin.entity.AppUserPositionTemp;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.common.Mapper;
import java.util.List;
/**
* 用户身份职位表
*
......@@ -17,4 +21,6 @@ public interface AppUserPositionTempMapper extends Mapper<AppUserPositionTemp> {
@Insert("INSERT IGNORE INTO `app_user_position_temp`(`user_id`,`phone`,`name`,`position_id`,`crt_time`)VALUES(#{userId},#{phone},#{name},#{positionId},#{crtTime})")
void insertWithIgnoreRepeat(AppUserPositionTemp appUserPositionTemp);
List<Integer> getUserIdByParentCompany(@Param("parentCompanyId") List<Integer> parentCompanyId);
}
......@@ -107,4 +107,10 @@ public class AppUserPositionController {
return ObjectRestResponse.succ(dataVO);
}
@GetMapping("/userid")
public List<Integer> getUserIdByParentCompany(@RequestParam("parentCompanyId") List<Integer> parentCompanyId){
return appUserPositionTempBiz.getUserIdByParentCompany(parentCompanyId);
}
}
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.github.wxiaoqi.security.admin.mapper.AppUserPositionTempMapper">
<select id="getUserIdByParentCompany" resultType="Integer">
SELECT
r.uid
FROM
app_user_position_temp pt
LEFT JOIN app_user_detail d ON pt.user_id = d.userid
LEFT JOIN (
SELECT
parent_id AS pid,
user_id AS uid
FROM
app_user_relation
WHERE
is_del = 0
) r ON d.userid = r.pid
WHERE
pt.is_del = 0
<if test="parentCompanyId != null and parentCompanyId.size() !=0">
AND pt.company_id IN
<foreach collection="parentCompanyId" index="index" item="pid" open="(" separator="," close=")">
#{pid}
</foreach>
</if>
</select>
</mapper>
\ No newline at end of file
package com.xxfc.platform.order.contant.enumerate;
/**
* 账目类型
* @author Administrator
*/
public enum BookkeepingTypeEnum {
ENTER(0,"入账"),OUT(1,"出账");
private Integer code;
private String msg;
BookkeepingTypeEnum(int code, String msg) {
this.code=code;
this.msg=msg;
}
public Integer getCode() {
return code;
}
public String getMsg() {
return msg;
}
}
package com.xxfc.platform.order.pojo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.persistence.Column;
import java.io.Serializable;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
@Data
@ApiModel("订单业绩明细表")
public class Achievement implements Serializable {
private static final Map<Integer, String> orderTypeMap = new HashMap<>();
private static final Map<Integer, String> payWayMap = new HashMap<>();
static {
orderTypeMap.put(1, "租车");
orderTypeMap.put(2, "旅游");
orderTypeMap.put(3, "会员");
payWayMap.put(null, "微信");
payWayMap.put(1, "微信支付");
payWayMap.put(2, "支付宝支付");
payWayMap.put(3, "银联支付");
}
@ApiModelProperty(value = "下单用户真实姓名")
private String realname;
@ApiModelProperty(value = "用户手机号")
private String username;
@ApiModelProperty(value = "上级姓名")
private String parentRealname;
@ApiModelProperty(value = "上级职位")
private String positionName;
@ApiModelProperty(value = "上级手机号")
private String parentUsername;
@ApiModelProperty(value = "订单所属公司id")
private Integer companyId;
@ApiModelProperty(value = "订单所属公司名")
private String companyName;
@ApiModelProperty(value = "优惠价格")
private BigDecimal favorablePrice = BigDecimal.ZERO;
@ApiModelProperty(value = "创建时间", hidden = true)
@Column(name = "crt_time")
private String crtTime;
@ApiModelProperty(value = "订单号")
private String no;
@ApiModelProperty(value = "订单类型")
private Integer type;
@Column(name = "order_amount")
@ApiModelProperty("订单总额")
private BigDecimal orderAmount = BigDecimal.ZERO;
@ApiModelProperty(value = "实际订单额")
@Column(name = "real_amount")
private BigDecimal realAmount = BigDecimal.ZERO;
@Column(name = "pay_way")
@ApiModelProperty(value = "支付方式")
private Integer payWay;
public void setCrtTime(Date crtTime) {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
this.crtTime = dateFormat.format(crtTime);
}
public String getType() {
return orderTypeMap.get(type);
}
public String getPayWay() {
return payWayMap.get(payWay);
}
}
package com.xxfc.platform.order.pojo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
import java.util.List;
/**
* 总业绩查询条件
* @author Administrator
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@ApiModel
public class QueryCriteria {
@ApiModelProperty(value ="开始时间" )
private Date startDate;
@ApiModelProperty(value = "结束时间")
private Date endDate;
@ApiModelProperty(value = "订单类型:1-租车 2-旅游 3-会员 null-全部")
private Integer orderType;
@ApiModelProperty(value = "业绩所属公司")
private Integer companyId;
@ApiModelProperty(value = "支付方式: 1-微信支付 2-支付宝支付 3-银联支付 null-全部")
private Integer paymentMethod;
@ApiModelProperty(value = "账目类型: 0-入账 1-出账")
private Integer type = 0;
@ApiModelProperty("权限公司id")
private List<Integer> jurisdiction;
@ApiModelProperty(value = "当前页数")
private Integer page=1;
@ApiModelProperty(value = "每页条数")
private Integer limit=10;
}
package com.xxfc.platform.order.pojo;
import com.alibaba.fastjson.JSON;
import com.xxfc.platform.order.pojo.account.OrderAccountDetail;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.util.StringUtils;
import javax.persistence.Column;
import java.io.Serializable;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
@Data
public class ReturnOrderAmount implements Serializable {
private static final long serialVersionUID = -8445943548965154778L;
private static final Map<Integer, String> orderTypeMap = new HashMap<>();
static {
orderTypeMap.put(1, "租车");
orderTypeMap.put(2, "旅游");
orderTypeMap.put(3, "会员");
}
@ApiModelProperty(value = "时间")
private Long time;
@ApiModelProperty(value = "订单号")
private String no;
@ApiModelProperty(value = "订单类型")
private Integer type;
@ApiModelProperty(value = "订单明细")
private String accountDetail;
@ApiModelProperty(value = "用户姓名")
private String realname;
@ApiModelProperty(value = "手机号")
private String username;
@ApiModelProperty(value = "退款说明")
private String refundInstruction;
@ApiModelProperty(value = "退款明细")
private BigDecimal refundAmount = BigDecimal.ZERO;
@ApiModelProperty("退还类型")
@Column(name = "account_type")
private Integer accountType;
public OrderAccountDetail getAccountDetail() {
return StringUtils.hasText(accountDetail) ? JSON.parseObject(accountDetail, OrderAccountDetail.class) : new OrderAccountDetail();
}
public String getType() {
return orderTypeMap.get(type);
}
public String getTime() {
Date date = new Date(this.time);
return new SimpleDateFormat("yyyy-MM-dd").format(date);
}
}
package com.xxfc.platform.order.pojo;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.math.BigDecimal;
import java.util.List;
/**
* 总业绩报表类
*
* @author Administrator
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class TotalOrderRevenue {
@ApiModelProperty(value = "总订单数")
private Integer orderSum;
@ApiModelProperty(value = "应收总额")
private BigDecimal totalReceivables=BigDecimal.ZERO;
@ApiModelProperty(value = "优惠金额")
private BigDecimal discount=BigDecimal.ZERO;
@ApiModelProperty(value = "实收金额")
private BigDecimal actual=BigDecimal.ZERO;
@ApiModelProperty(value = "数据明细")
private PageInfo<Achievement> achievements;
}
......@@ -5,6 +5,8 @@ import cn.hutool.core.bean.copier.CopyOptions;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSONArray;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.github.wxiaoqi.security.admin.dto.UserMemberDTO;
import com.github.wxiaoqi.security.admin.feign.UserFeign;
import com.github.wxiaoqi.security.admin.feign.dto.AppUserDTO;
......@@ -135,8 +137,8 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper, BaseOrder> implements
}
public List<OrderListVo> listOrder(Map<String, Object> paramMap) {
List<OrderListVo> orderListVos = mapper.listOrder(paramMap);
return orderListVos;
return mapper.listOrder(paramMap);
}
public List<OrderPageVO> getRentVehicle(Map<String, Object> paramMap) {
......@@ -929,4 +931,18 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper, BaseOrder> implements
return mapper.selectAllRentVehicleOrder(paramMap);
}
public List<Achievement> entryStatisticalData(QueryCriteria queryCriteria) {
return mapper.selectTotalStatistical(queryCriteria);
}
public PageInfo<Achievement> getAchievementPageInfo(QueryCriteria queryCriteria) {
PageHelper.startPage(queryCriteria.getPage(),queryCriteria.getLimit());
List<Achievement> achievements = mapper.selectTotalStatistical(queryCriteria);
return PageInfo.of(achievements);
}
}
\ No newline at end of file
......@@ -4,6 +4,8 @@ import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.github.wxiaoqi.security.admin.feign.UserFeign;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.github.wxiaoqi.security.common.exception.BaseException;
......@@ -17,6 +19,8 @@ import com.xxfc.platform.order.contant.enumerate.*;
import com.xxfc.platform.order.entity.*;
import com.xxfc.platform.order.mapper.OrderAccountMapper;
import com.xxfc.platform.order.pojo.DedDetailDTO;
import com.xxfc.platform.order.pojo.QueryCriteria;
import com.xxfc.platform.order.pojo.ReturnOrderAmount;
import com.xxfc.platform.order.pojo.Term;
import com.xxfc.platform.order.pojo.account.OrderAccountBo;
import com.xxfc.platform.order.pojo.account.OrderAccountDTO;
......@@ -671,4 +675,17 @@ public class OrderAccountBiz extends BaseBiz<OrderAccountMapper,OrderAccount> {
List<OrderAccountBo> orderAccountBos = mapper.selectByDateAndStatffIds(startDate,endDate,staffUserIds);
return CollectionUtils.isNotEmpty(orderAccountBos)?Collections.EMPTY_LIST:orderAccountBos;
}
public List<ReturnOrderAmount> outStatisticalData(QueryCriteria queryCriteria) {
Long startTime=null;
Long endTime= null;
if (queryCriteria.getStartDate()!=null) {
startTime=queryCriteria.getStartDate().getTime();
}
if (queryCriteria.getEndDate()!=null) {
endTime= queryCriteria.getEndDate().getTime();
}
return mapper.outStatisticalData(queryCriteria,startTime,endTime);
}
}
\ No newline at end of file
......@@ -229,13 +229,14 @@ public class StaffStatisticsBiz extends BaseBiz<StaffStatisticsMapper, StaffStat
for (AppUserSellingWaterDTO waterDTO : waterDTOS) {
if (sellingWaterEntry.getKey() == 0){
royaltyAmount = royaltyAmount.add(waterDTO.getCommission());
totalAmount = totalAmount.add(waterDTO.getPrice());
totalAmount = totalAmount.add(waterDTO.getCommission().divide(new BigDecimal(String.valueOf(waterDTO.getExtract()))));
orderCounter.incrementAndGet();
}
if (sellingWaterEntry.getKey()==1){
royaltyAmount = royaltyAmount.subtract(waterDTO.getCommission());
totalAmount = totalAmount.subtract(waterDTO.getPrice());
totalAmount = totalAmount.subtract(waterDTO.getCommission().divide(new BigDecimal(String.valueOf(waterDTO.getExtract()/100.00))));
}
}
staffStatisticsResultMap.put(TOTAL_AMOUNT_VAL,totalAmount);
......
package com.xxfc.platform.order.mapper;
import com.xxfc.platform.order.entity.BaseOrder;
import com.xxfc.platform.order.pojo.Achievement;
import com.xxfc.platform.order.pojo.QueryCriteria;
import com.xxfc.platform.order.pojo.bg.BgOrderListVo;
import com.xxfc.platform.order.pojo.dto.MemberOrderBo;
import com.xxfc.platform.order.pojo.dto.MemberOrderFindDTO;
......@@ -46,5 +48,7 @@ public interface BaseOrderMapper extends Mapper<BaseOrder> {
@Param("startDate") Date startDate,
@Param("endDate") Date endDate);
List<Achievement> selectTotalStatistical(QueryCriteria queryCriteria);
List<OrderDTO> selectBaeOrderByOrderIds(@Param("orderIds") List<Integer> orderIds);
}
package com.xxfc.platform.order.mapper;
import com.xxfc.platform.order.entity.OrderAccount;
import com.xxfc.platform.order.pojo.QueryCriteria;
import com.xxfc.platform.order.pojo.ReturnOrderAmount;
import com.xxfc.platform.order.pojo.Term;
import com.xxfc.platform.order.pojo.account.OrderAccountBo;
import com.xxfc.platform.order.pojo.account.OrderAccountDTO;
......@@ -9,6 +11,7 @@ import tk.mybatis.mapper.common.Mapper;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
......@@ -22,6 +25,8 @@ public interface OrderAccountMapper extends Mapper<OrderAccount> {
List<OrderAccountDTO> getOrderAccountByOrderType(Term term);
List<ReturnOrderAmount> outStatisticalData(@Param("queryCriteria")QueryCriteria queryCriteria,@Param("startTime") Long startTime,@Param("endTime")Long endTime);
List<OrderAccountBo> selectOrderAccountByOrderTypeAndStartTimeAndEndTime(@Param("orderType") Integer orderType,
@Param("startTime") long startTime,
@Param("endTime") long endTime);
......
package com.xxfc.platform.order.rest.background;
import com.github.wxiaoqi.security.admin.feign.UserFeign;
import com.github.wxiaoqi.security.admin.feign.dto.UserDTO;
import com.github.wxiaoqi.security.auth.client.annotation.IgnoreClientToken;
import com.github.wxiaoqi.security.auth.client.annotation.IgnoreUserToken;
import com.github.wxiaoqi.security.auth.client.config.UserAuthConfig;
import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.msg.auth.PageResult;
import com.github.wxiaoqi.security.common.rest.CommonBaseController;
import com.xxfc.platform.order.biz.TotalPerformanceBiz;
import com.xxfc.platform.order.pojo.QueryCriteria;
import com.xxfc.platform.order.contant.enumerate.BookkeepingTypeEnum;
import com.xxfc.platform.order.pojo.ReturnOrderAmount;
import com.xxfc.platform.order.pojo.TotalOrderRevenue;
import com.xxfc.platform.vehicle.entity.BranchCompany;
import com.xxfc.platform.vehicle.feign.VehicleFeign;
import io.swagger.annotations.Api;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;
import java.util.stream.Collectors;
/**
* 总业绩报表
*
* @author Administrator
*/
@RestController()
@RequestMapping("/report/form")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
@Api(tags = "总业绩统计")
@IgnoreClientToken
@IgnoreUserToken
public class TotalPerformanceStatementController extends CommonBaseController {
private final TotalPerformanceBiz totalPerformanceBiz;
private final HttpServletRequest request;
private final UserAuthConfig userAuthConfig;
private final UserFeign userFeign;
private final VehicleFeign vehicleFeign;
private final Integer HIGHEST_AUTHORITY = 1;
@PostMapping("/list")
public ObjectRestResponse statisticalData(@RequestBody QueryCriteria queryCriteria) throws Exception {
UserDTO userDTO = userFeign.userinfoByToken(userAuthConfig.getToken(request)).getData();
//获取用户权限
List<Integer> Jurisdiction = null;
//是否有查询所有数据的权限
if (!HIGHEST_AUTHORITY.equals(userDTO.getDataAll())) {
List<BranchCompany> branchCompanies = vehicleFeign.companyAll(userDTO.getDataAll(), userDTO.getDataCompany(), userDTO.getDataZone());
Jurisdiction = branchCompanies.parallelStream().map(BranchCompany::getId).collect(Collectors.toList());
}
queryCriteria.setJurisdiction(Jurisdiction);
if (BookkeepingTypeEnum.ENTER.getCode().equals(queryCriteria.getType())) {
TotalOrderRevenue totalOrderRevenue = totalPerformanceBiz.entryStatisticalData(queryCriteria);
return ObjectRestResponse.succ(totalOrderRevenue);
}else if (BookkeepingTypeEnum.OUT.getCode().equals(queryCriteria.getType())){
List<ReturnOrderAmount> returnOrderAmounts = totalPerformanceBiz.outStatisticalData(queryCriteria);
return ObjectRestResponse.succ(PageResult.nowPageResult(queryCriteria.getPage(),queryCriteria.getLimit(),returnOrderAmounts));
}
return ObjectRestResponse.succ();
}
@PostMapping("/excel")
public void exportTotalPerformance(@RequestBody QueryCriteria queryCriteria, HttpServletResponse response) throws Exception {
try {
String name = DateTimeFormatter.ofPattern("YYYYMMddHHmmss").format(LocalDateTime.now());
response.setContentType("application/vnd.ms-excel;charset=utf-8");
if (BookkeepingTypeEnum.ENTER.getCode().equals(queryCriteria.getType())) {
String filename = String.format("%s-总业绩-入账表.xlsx",name);
response.setHeader("Content-Disposition","attachment;filename="+ new String(filename.getBytes(), "iso8859-1"));
ServletOutputStream outputStream = response.getOutputStream();
totalPerformanceBiz.exportEntry(queryCriteria, name, outputStream);
}else if (BookkeepingTypeEnum.OUT.getCode().equals(queryCriteria.getType())){
String filename = String.format("%s-总业绩-出账表.xlsx",name);
response.setHeader("Content-Disposition","attachment;filename="+ new String(filename.getBytes(), "iso8859-1"));
ServletOutputStream outputStream = response.getOutputStream();
totalPerformanceBiz.exportAccount(queryCriteria, name, outputStream);
}else {
throw new BaseException("无相关数据");
}
response.setCharacterEncoding("UTF-8");
} catch (IOException e) {
throw new BaseException("导入数据失败");
}
}
}
......@@ -439,4 +439,37 @@
#{orderId}
</foreach>
</select>
<select id="selectTotalStatistical" parameterType="com.xxfc.platform.order.pojo.QueryCriteria"
resultType="com.xxfc.platform.order.pojo.Achievement">
select
crt_time,no,type,order_amount,real_amount,realname,username,parentRealname,positionName,parentUsername,companyName,pay_way,company_id
from order_user_position_company
<where>
<if test="startDate != null">
and crt_time <![CDATA[>=]]> #{startDate}
</if>
<if test="endDate != null">
and crt_time <![CDATA[<=]]> #{endDate}
</if>
<if test="paymentMethod !=null">
and pay_way = #{paymentMethod}
</if>
<if test="jurisdiction != null and jurisdiction.size() !=0 ">
and company_id in
<foreach collection="jurisdiction" index="index" item="companyId" open="(" separator="," close=")">
#{companyId}
</foreach>
</if>
<if test="companyId != null ">
and company_id =#{companyId}
</if>
<if test="orderType != null">
and type = #{orderType}
</if>
</where>
order by crt_time DESC
</select>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.xxfc.platform.order.mapper.OrderAccountMapper">
<select id="getOrderAccountByOrderType" parameterType="com.xxfc.platform.order.pojo.Term" resultType="com.xxfc.platform.order.pojo.account.OrderAccountDTO">
<select id="getOrderAccountByOrderType" parameterType="com.xxfc.platform.order.pojo.Term"
resultType="com.xxfc.platform.order.pojo.account.OrderAccountDTO">
SELECT
<if test="subdivide !=null and subdivide ==1">
date( FROM_UNIXTIME( a.crt_time / 1000 ) ) as oneDay,
......@@ -49,7 +50,28 @@
<if test="subdivide !=null and subdivide ==1">
AND date( FROM_UNIXTIME( a.crt_time / 1000 ) ) = date( DATE_SUB( now( ), INTERVAL #{day} DAY ) )
</if>
</select>
<select id="outStatisticalData" resultType="com.xxfc.platform.order.pojo.ReturnOrderAmount">
select oa.crt_time as time ,oupc.no,oupc.type,oa.account_detail as accountDetail ,oupc.realname,oupc.username,oa.account_type
from order_account oa
left join order_user_position_company oupc ON oa.order_id=oupc.id
WHERE oa.account_type!=101
<if test="startTime != null">
and oa.crt_time <![CDATA[>=]]> #{startTime}
</if>
<if test="endTime != null">
and oa.crt_time <![CDATA[<=]]> #{endTime}
</if>
<if test="queryCriteria.jurisdiction != null and queryCriteria.jurisdiction.size() !=0 ">
and oupc.company_id in
<foreach collection="jurisdiction" index="index" item="companyId" open="(" separator="," close=")">
#{companyId}
</foreach>
</if>
<if test="queryCriteria.orderType != null">
and oupc.type = #{orderType}
</if>
order by oa.crt_time DESC
</select>
<select id="selectOrderAccountByOrderTypeAndStartTimeAndEndTime"
......
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