Commit 4e6b6271 authored by libin's avatar libin

员工统计

parent 49dd5ee5
package com.github.wxiaoqi.security.common.enumconstant;
import org.assertj.core.util.Lists;
import java.util.EnumSet;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/11/13 17:23
*/
public enum LevelEnum {
DIAMOND(3, "钻石"),
GOLD(2, "黄金"),
GENERAL(1, "普通");
LevelEnum(Integer level, String desc) {
this.level = level;
this.desc = desc;
}
public static LevelEnum getLevelEnumByLevel(Integer level) {
return levelMap.get(level);
}
private Integer level;
private String desc;
private static Map<Integer, LevelEnum> levelMap;
public static List<Integer> levels;
static {
levelMap = EnumSet.allOf(LevelEnum.class).stream().collect(Collectors.toMap(LevelEnum::getLevel, Function.identity()));
levels = Lists.newArrayList(levelMap.keySet());
}
public Integer getLevel() {
return level;
}
public void setLevel(Integer level) {
this.level = level;
}
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
}
......@@ -14,6 +14,7 @@ import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;
import java.util.Date;
import java.util.List;
import java.util.Map;
......@@ -163,6 +164,8 @@ public interface UserFeign {
List<UserStaffBo> findAllStaffs();
@GetMapping("/sellingwater/list_staff_sellerwater")
List<UserStaffBo> findStaffSellerWater(@RequestParam("userIds") List<Integer> userIds);
public List<UserStaffBo> findStaffSellerWater(@RequestParam(value = "userIds",required = false) List<Integer> userIds,
@RequestParam(value = "startDate") Date startDate,
@RequestParam(value = "endDate") Date endDate);
}
......@@ -463,8 +463,8 @@ public class AppUserSellingWaterBiz extends BaseBiz<AppUserSellingWaterMapper, A
return pageDataVO;
}
public List<UserStaffBo> findStatffSellerWaterByUserIds(List<Integer> userIds) {
List<UserStaffBo> userStaffBos = mapper.statisticsStatffSellerWaterByUserIds(userIds);
public List<UserStaffBo> findStatffSellerWaterByUserIdsAndTime(List<Integer> userIds,Date startDate,Date endDate) {
List<UserStaffBo> userStaffBos = mapper.statisticsStatffSellerWaterByUserIdsAndTime(userIds,startDate.getTime(),endDate.getTime());
return CollectionUtils.isEmpty(userStaffBos)?Collections.EMPTY_LIST:userStaffBos;
}
......
......@@ -7,7 +7,6 @@ import com.github.wxiaoqi.security.admin.dto.UserSellingWaterFindDTO;
import com.github.wxiaoqi.security.admin.entity.AppUserSellingWater;
import com.github.wxiaoqi.security.admin.vo.SellingWalletVo;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.bind.annotation.RequestParam;
import tk.mybatis.mapper.common.Mapper;
import java.math.BigDecimal;
......@@ -30,5 +29,7 @@ public interface AppUserSellingWaterMapper extends Mapper<AppUserSellingWater> {
List<UserSellingWaterAdminDTO> selectSellingWaterPage(UserSellingWaterFindDTO userSellingWaterFindDTO);
List<UserStaffBo> statisticsStatffSellerWaterByUserIds(@RequestParam("userIds") List<Integer> userIds);
List<UserStaffBo> statisticsStatffSellerWaterByUserIdsAndTime(@Param("userIds") List<Integer> userIds,
@Param("startTime") Long startTime,
@Param("endTime") Long endTime);
}
......@@ -14,6 +14,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.Date;
import java.util.List;
/**
......@@ -78,8 +79,10 @@ public class UserSellingWaterController {
@ApiOperation("员工佣金")
@GetMapping("/list_staff_sellerwater")
public List<UserStaffBo> findStaffSellerWater(@RequestParam("userIds") List<Integer> userIds){
return appUserSellingWaterBiz.findStatffSellerWaterByUserIds(userIds);
public List<UserStaffBo> findStaffSellerWater(@RequestParam(value = "userIds",required = false) List<Integer> userIds,
@RequestParam(value = "startDate") Date startDate,
@RequestParam(value = "endDate") Date endDate){
return appUserSellingWaterBiz.findStatffSellerWaterByUserIdsAndTime(userIds,startDate,endDate);
}
}
......@@ -151,18 +151,22 @@ FROM
ORDER BY ausw.crt_time DESC
</select>
<select id="statisticsStatffSellerWaterByUserIds"
<select id="statisticsStatffSellerWaterByUserIdsAndTime"
resultType="com.github.wxiaoqi.security.admin.bo.UserStaffBo">
SELECT
`auswu`.user_id, ( IFNULL(auswu.upIncome,0) - IFNULL(auswd.dowIncome,0) ) AS `commission`
FROM
( SELECT `user_id` as `userId`, IFNULL(SUM( commission ),0) AS upIncome FROM `app_user_selling_water` where STATUS = 0 and waiting=1 <if test="userIds!=null and userIds.size!=0">
( SELECT `user_id` as `userId`, IFNULL(SUM( commission ),0) AS upIncome FROM `app_user_selling_water` where STATUS = 0 and waiting=1
AND `crt_time` between #{startTime} and #{endTime}
<if test="userIds!=null and userIds.size!=0">
AND `user_id` IN <foreach collection="userIds" item="userId" open="(" close=")" separator=",">
#{userId}
</foreach>
</if> group by user_id) AS `auswu`
left join
( SELECT `user_id`,IFNULL(SUM( commission ),0) AS `dowIncome` FROM `app_user_selling_water` where STATUS = 1 and waiting=1 <if test="userIds!=null and userIds.size!=0">
( SELECT `user_id`,IFNULL(SUM( commission ),0) AS `dowIncome` FROM `app_user_selling_water` where STATUS = 1 and waiting=1
and `crt_time` between #{startTime} and #{endTime}
<if test="userIds!=null and userIds.size!=0">
AND `user_id` IN <foreach collection="userIds" item="userId" open="(" close=")" separator=",">
#{userId}
</foreach>
......
package com.xxfc.platform.order.contant.enumerate;
import org.assertj.core.util.Lists;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public enum DeductionTypeEnum {
......@@ -22,19 +26,48 @@ public enum DeductionTypeEnum {
* 类型描述
*/
private String desc;
/**
* 违约相关code
*/
public static List<Integer> lateFeeCode;
/**
* 定损相关code
*/
public static List<Integer> lossSpecifiedCode;
/**
* 违章相关code
*/
public static List<Integer> breakRulesRegulationCode;
/**
*消费金额相关code
*/
public static List<Integer> consumerCode;
private static Map<Integer,String> codeAndDesc = new HashMap<Integer, String>();
//Maps.newHashMap();
private static Map<Integer, String> codeAndDesc = new HashMap<Integer, String>();
static{
for(DeductionTypeEnum enumE : DeductionTypeEnum.values()){
codeAndDesc.put(enumE.getCode(),enumE.getDesc());
static {
for (DeductionTypeEnum enumE : DeductionTypeEnum.values()) {
codeAndDesc.put(enumE.getCode(), enumE.getDesc());
}
lateFeeCode = Lists.newArrayList(VIOLATE_CANCEL.getCode(),
VIOLATE_ADVANCE.getCode(),
VIOLATE_DELAY.getCode(),
VIOLATE_CHANGE_C.getCode());
lossSpecifiedCode = Lists.newArrayList(DAMAGES.getCode());
breakRulesRegulationCode = Lists.newArrayList(
VIOLATE_TRAFFIC_DEDUCT.getCode()
);
consumerCode = Lists.newArrayList(CONSUME.getCode());
}
DeductionTypeEnum(Integer code, String desc){
this.code=code;
this.desc=desc;
DeductionTypeEnum(Integer code, String desc) {
this.code = code;
this.desc = desc;
}
public Integer getCode() {
......@@ -53,7 +86,7 @@ public enum DeductionTypeEnum {
this.desc = desc;
}
public static Boolean exists(Integer code){
public static Boolean exists(Integer code) {
return codeAndDesc.containsKey(code);
}
}
\ No newline at end of file
package com.xxfc.platform.order.contant.enumerate;
import cn.hutool.core.date.DateField;
import cn.hutool.core.date.DateTime;
import com.xxfc.platform.order.entity.OrderReceivedStatisticsBase;
import org.apache.commons.collections4.CollectionUtils;
import org.assertj.core.util.Lists;
import org.springframework.util.StringUtils;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.ZoneId;
import java.time.temporal.WeekFields;
import java.util.*;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/11/14 14:28
*/
public enum StatisticsStatusEnum {
;
public static final int DEFAULT_COMPANY=1;
public static final int ORDER_MEMBER_TYPE=3;
public static final int ORDER_RENT_VEHICLE_TYPE=1;
public static final int ORDER_TOUR_TYPE=2;
public static final int NO_PAY_WAY=0;
public static final Integer DEFAULT_SQL_SIZE=1000;
public static final String ORDER_AMOUNT="order_amount";
public static final String LATEFEE_AMOUNT="late_fee";
public static final String ORDER_REFUND_AMOUNT="order_refund_amount";
public static final String ORDER_DEPOSIT_AMOUNT="order_deposit_amount";
public static final String COMPANY_DEFAULT="欣新房车控股集团";
public static final String NO_DEDUCTIBLE_AMOUNT="damageSafeAmount";
public static final String PARMAM_JSON="paramJson";
public static final int DAMAGE_SAFE=1;
public static List<String> orderStates;
public static List<String> orderOrigins;
public static List<String> orderPayWays;
static {
// 0 未支付 1 已支付
orderStates = Lists.newArrayList("0","1");
// 1 app 2 小程序 3 其他
orderOrigins = Lists.newArrayList("1","2","3");
// 1 微信 2 支付宝 0不需要支付(使用了优惠券之类的)或未支付
orderPayWays = Lists.newArrayList("1","2","0");
}
public static List<String> statisticsSateGroupWithCompanys(List<Integer> companyIdList){
List<String> orderStatisticsStateGroups = new ArrayList<>();
List<String> stateGroup = statisticsStateGroup();
for (String stgp : stateGroup) {
for (Integer companyId : companyIdList) {
// 公司id-订单来源-支付方式-订单状态
orderStatisticsStateGroups.add(String.format("%d-%s",companyId,stgp));
}
}
return orderStatisticsStateGroups;
}
public static List<String> statisticsStateGroup(){
List<String> orderStatisticsStateGroups = new ArrayList<>();
for (String orderOrigin : orderOrigins) {
for (String orderPayWay : orderPayWays) {
for (String orderState : orderStates) {
//订单来源-支付方式-订单状态
orderStatisticsStateGroups.add(String.format("%s-%s-%s",orderOrigin,orderPayWay,orderState));
}
}
}
return orderStatisticsStateGroups;
}
public static List<String> getOtherStatisticsStateGroup(List<Integer> companyIdList,List<String> statisticsStates){
List<String> stateGroupList = CollectionUtils.isEmpty(companyIdList)?statisticsStateGroup():statisticsSateGroupWithCompanys(companyIdList);
stateGroupList.removeAll(statisticsStates);
return stateGroupList;
}
public static<T extends OrderReceivedStatisticsBase> T wrapStatisticsObject(Date date, String stateGroup, Map<Integer,String> companyMap, T targetObj){
LocalDate localDate = LocalDate.from(new Date().toInstant().atZone(ZoneId.systemDefault()));
String year = String.valueOf(localDate.getYear());
String month = String.format("%s%d", year, localDate.getMonthValue());
String weekOfYear = String.format("%s%d", year,localDate.get(WeekFields.of(Locale.CHINESE).weekOfYear()));
String[] status = stateGroup.split("-");
targetObj.setCrtTime(new Date());
targetObj.setCompanyId(Integer.valueOf(status[0]));
String companyName = Objects.isNull(companyMap)?COMPANY_DEFAULT: StringUtils.hasText(companyMap.get(targetObj.getCompanyId()))?companyMap.get(targetObj.getCompanyId()):COMPANY_DEFAULT;
targetObj.setCompanyName(companyName);
targetObj.setHasPay(Integer.valueOf(status[3]));
targetObj.setOrderOrigin(Integer.valueOf(status[1]));
targetObj.setPayWay(Integer.valueOf(status[2]));
targetObj.setDate(date);
targetObj.setYear(year);
targetObj.setMonth(month);
targetObj.setWeekOfYear(weekOfYear);
targetObj.setExtraAmount(BigDecimal.ZERO);
targetObj.setLateFeeAmount(BigDecimal.ZERO);
targetObj.setTotalAmount(BigDecimal.ZERO);
targetObj.setTotalQuantity(0);
targetObj.setOrderRefundAmount(BigDecimal.ZERO);
targetObj.setStateGroup(stateGroup);
return targetObj;
}
}
package com.xxfc.platform.order.entity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.persistence.*;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/11/11 15:49
*/
@Data
public class OrderReceivedStatisticsBase implements Serializable {
private static final long serialVersionUID = 1L;
/**
*
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY,generator = "JDBC")
@ApiModelProperty("")
protected Long id;
/**
* 年份
*/
@Column(name = "year")
@ApiModelProperty(value = "年份")
protected String year;
/**
* 月份
*/
@Column(name = "month")
@ApiModelProperty(value = "月份----->201908")
protected String month;
/**
* 年月日
*/
@Column(name = "date")
@ApiModelProperty(value = "年月日")
protected Date date;
/**
* 1周年的第几周
*/
@Column(name = "week_of_year")
@ApiModelProperty(value = "1周年的第几周--->201922")
protected String weekOfYear;
/**
* 订单总额
*/
@Column(name = "total_amount")
@ApiModelProperty(value = "订单总额(不包含押金)")
protected BigDecimal totalAmount;
/**
* 订单总量
*/
@Column(name = "total_quantity")
@ApiModelProperty(value = "订单总量")
protected Integer totalQuantity;
@Column(name = "has_pay")
@ApiModelProperty(value = "是否支付 1已经支付 0未支付")
protected Integer hasPay;
/**
* '支付来源 1--app;2--小程序',
*/
@Column(name = "order_origin")
@ApiModelProperty(value = " '支付来源 1--app;2--小程序',")
protected Integer orderOrigin;
/**
* 支付方式 '1:微信公众号支付 2.支付宝即时到账,3,银联'
*/
@Column(name = "pay_way")
@ApiModelProperty(value = "支付方式 '1:微信公众号支付 2.支付宝即时到账,3,银联'")
protected Integer payWay;
@Column(name = "company_id")
@ApiModelProperty(value = "分公司id")
protected Integer companyId;
@Column(name = "company_name")
@ApiModelProperty("分公司名称")
protected String companyName;
@ApiModelProperty("违约金")
@Column(name = "late_fee_amount")
protected BigDecimal lateFeeAmount;
@ApiModelProperty("订单退款")
@Column(name = "order_refund_amount")
protected BigDecimal orderRefundAmount;
@ApiModelProperty("额外费用")
@Column(name = "extra_amount")
protected BigDecimal extraAmount;
/**
* 创建时间
*/
@Column(name = "crt_time")
@ApiModelProperty(value = "创建时间", hidden = true)
protected Date crtTime;
@Transient
protected Integer divisor;
@Transient
private String stateGroup;
}
......@@ -96,4 +96,8 @@ public class StaffStatistics implements Serializable {
@ApiModelProperty("提成")
@Column(name = "royalty_amount")
private BigDecimal royaltyAmount;
@ApiModelProperty("创建时间")
@Column(name = "crt_time")
private Date crtTime;
}
package com.xxfc.platform.order.pojo.account;
import com.alibaba.fastjson.JSON;
import com.xxfc.platform.order.pojo.dto.OrderDTO;
import lombok.Data;
import org.springframework.util.StringUtils;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/11/14 19:16
*/
@Data
public class OrderAccountBo extends OrderDTO {
private Integer accountType;
private String accountDetail;
private OrderAccountDetail accountDetailEntity;
public OrderAccountDetail getAccountDetailEntity() {
return StringUtils.hasText(accountDetail)? JSON.parseObject(accountDetail,OrderAccountDetail.class):new OrderAccountDetail();
}
}
package com.xxfc.platform.order.pojo.dto;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.github.wxiaoqi.security.common.enumconstant.LevelEnum;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.util.StringUtils;
import java.math.BigDecimal;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/11/13 15:58
*/
@Data
@Builder(toBuilder = true)
@AllArgsConstructor
@NoArgsConstructor
public class OrderDTO {
protected Integer id;
protected Integer type;
protected Integer status;
protected BigDecimal orderAmount;
protected BigDecimal realAmount;
protected Integer orderOrigin;
protected Integer payWay;
protected Integer companyId;
protected String stateGroup;
protected Integer hasPay;
private JSONObject data;
private Integer damageSafe;
private BigDecimal deposit;
private Integer userId;
private Integer postionId;
/**
* 费用其他明细 租车使用
*/
protected String costDetailExtend;
/**
* 会员相关
*/
protected Integer memberLevel;
protected LevelEnum levelEnum;
public LevelEnum getLevelEnum(){
return LevelEnum.getLevelEnumByLevel(this.memberLevel);
}
public JSONObject getData() {
return StringUtils.hasText(costDetailExtend)?JSONUtil.parseObj(costDetailExtend):new JSONObject();
}
}
......@@ -30,6 +30,7 @@ import com.xxfc.platform.order.pojo.account.OrderAccountDetail;
import com.xxfc.platform.order.pojo.calculate.InProgressVO;
import com.xxfc.platform.order.pojo.dto.MemberOrderBo;
import com.xxfc.platform.order.pojo.dto.MemberOrderFindDTO;
import com.xxfc.platform.order.pojo.dto.OrderDTO;
import com.xxfc.platform.order.pojo.mq.OrderMQDTO;
import com.xxfc.platform.order.pojo.order.OrderListVo;
import com.xxfc.platform.order.pojo.order.OrderPageVO;
......@@ -53,6 +54,7 @@ import com.xxfc.platform.vehicle.pojo.CompanyDetail;
import com.xxfc.platform.vehicle.util.DistanceUtil;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
......@@ -908,4 +910,13 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper, BaseOrder> implements
return Lists.newArrayList();
}
public List<OrderDTO> selectOrdersByTypeAndTime(List<Integer> types,Integer hasPay, Date startDate, Date endDate) {
List<OrderDTO> orderDTOS = mapper.selectOrdersByTypeAndTime(types,hasPay,startDate,endDate);
return CollectionUtils.isEmpty(orderDTOS)?Collections.EMPTY_LIST:orderDTOS;
}
public List<OrderPageVO> selectAllRentVehicleOrder(Map<String, Object> paramMap) {
return mapper.selectAllRentVehicleOrder(paramMap);
}
}
\ No newline at end of file
......@@ -18,6 +18,7 @@ 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.Term;
import com.xxfc.platform.order.pojo.account.OrderAccountBo;
import com.xxfc.platform.order.pojo.account.OrderAccountDTO;
import com.xxfc.platform.order.pojo.account.OrderAccountDeduction;
import com.xxfc.platform.order.pojo.account.OrderAccountDetail;
......@@ -31,6 +32,7 @@ import com.xxfc.platform.universal.entity.Dictionary;
import com.xxfc.platform.universal.feign.ThirdFeign;
import com.xxfc.platform.universal.vo.OrderRefundVo;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.jexl2.MapContext;
import org.mockito.internal.util.collections.Sets;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -38,9 +40,7 @@ import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.*;
import static com.github.wxiaoqi.security.common.constant.CommonConstants.SYS_FALSE;
import static com.github.wxiaoqi.security.common.constant.CommonConstants.SYS_TRUE;
......@@ -649,4 +649,26 @@ public class OrderAccountBiz extends BaseBiz<OrderAccountMapper,OrderAccount> {
orderMsgBiz.handelMsgDeposit(orvd, baseOrder, userFeign.userDetailById(baseOrder.getUserId()).getData());
}
/**
*根据开始与结束时间查询账目
* @param startDate
* @param endDate
* @return
*/
public List<OrderAccountBo> selectByTypeAndDate(Integer orderType, Date startDate, Date endDate) {
List<OrderAccountBo> accountBos = mapper.selectOrderAccountByOrderTypeAndStartTimeAndEndTime(orderType,startDate.getTime(),endDate.getTime());
return CollectionUtils.isEmpty(accountBos)? Collections.EMPTY_LIST:accountBos;
}
/**
* 根据创建时间与员工id查询
* @param startDate
* @param endDate
* @param staffUserIds
* @return
*/
public List<OrderAccountBo> selectByDateAndStatffIds(Date startDate, Date endDate,List<Integer> staffUserIds) {
List<OrderAccountBo> orderAccountBos = mapper.selectByDateAndStatffIds(startDate,endDate,staffUserIds);
return CollectionUtils.isNotEmpty(orderAccountBos)?Collections.EMPTY_LIST:orderAccountBos;
}
}
\ No newline at end of file
package com.xxfc.platform.order.biz;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.github.wxiaoqi.security.admin.bo.UserStaffBo;
import com.github.wxiaoqi.security.admin.feign.UserFeign;
import com.github.wxiaoqi.security.admin.vo.AppUserVo;
......@@ -8,9 +10,15 @@ import com.github.wxiaoqi.security.common.biz.BaseBiz;
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.AccountTypeEnum;
import com.xxfc.platform.order.contant.enumerate.DeductionTypeEnum;
import com.xxfc.platform.order.contant.enumerate.StatisticsStatusEnum;
import com.xxfc.platform.order.entity.StaffStatistics;
import com.xxfc.platform.order.mapper.StaffStatisticsMapper;
import com.xxfc.platform.order.pojo.account.OrderAccountBo;
import com.xxfc.platform.order.pojo.account.OrderAccountDeduction;
import com.xxfc.platform.order.pojo.bo.StaffStatisticsTotalBo;
import com.xxfc.platform.order.pojo.dto.OrderDTO;
import com.xxfc.platform.order.pojo.dto.StaffStatisticsFindDTO;
import com.xxfc.platform.order.pojo.vo.StaffStatisticsVo;
import lombok.RequiredArgsConstructor;
......@@ -21,7 +29,11 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.ZoneId;
import java.time.temporal.WeekFields;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Function;
import java.util.stream.Collectors;
......@@ -33,43 +45,45 @@ import java.util.stream.Collectors;
*/
@Transactional(rollbackFor = Exception.class)
@Service
@RequiredArgsConstructor(onConstructor =@__(@Autowired))
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class StaffStatisticsBiz extends BaseBiz<StaffStatisticsMapper, StaffStatistics> {
private final UserFeign userFeign;
private static final String TOTAL_AMOUNT_VAL="totalAmount";
private static final String TOTAL_NUM_VAL="totalNum";
private final BaseOrderBiz baseOrderBiz;
private final UserFeign userFeign;
private final OrderAccountBiz orderAccountBiz;
private final OrderAccountBiz orderAccountBiz;
public StaffStatisticsTotalBo staffStatisticsWithTotal(StaffStatisticsFindDTO staffStatisticsFindDTO) {
return mapper.statistics(staffStatisticsFindDTO);
}
public PageDataVO<StaffStatisticsVo> staffStatisticsWithPage(StaffStatisticsFindDTO staffStatisticsFindDTO) {
PageDataVO<StaffStatisticsVo> pageDataVO = new PageDataVO<>();
PageDataVO<StaffStatistics> statisticsVoPageDataVO = PageDataVO.pageInfo(staffStatisticsFindDTO.getPage(),staffStatisticsFindDTO.getLimit(),()->mapper.selectStaffStatistics(staffStatisticsFindDTO));
List<StaffStatistics> data = statisticsVoPageDataVO.getData();
if (CollectionUtils.isEmpty(data)){
pageDataVO.setTotalCount(0L);
pageDataVO.setTotalPage(0);
pageDataVO.setPageNum(staffStatisticsFindDTO.getPage());
pageDataVO.setPageSize(staffStatisticsFindDTO.getLimit());
pageDataVO.setData(Collections.EMPTY_LIST);
return pageDataVO;
}
PageDataVO<StaffStatisticsVo> pageDataVO = new PageDataVO<>();
PageDataVO<StaffStatistics> statisticsVoPageDataVO = PageDataVO.pageInfo(staffStatisticsFindDTO.getPage(), staffStatisticsFindDTO.getLimit(), () -> mapper.selectStaffStatistics(staffStatisticsFindDTO));
List<StaffStatistics> data = statisticsVoPageDataVO.getData();
if (CollectionUtils.isEmpty(data)) {
pageDataVO.setTotalCount(0L);
pageDataVO.setTotalPage(0);
pageDataVO.setPageNum(staffStatisticsFindDTO.getPage());
pageDataVO.setPageSize(staffStatisticsFindDTO.getLimit());
pageDataVO.setData(Collections.EMPTY_LIST);
return pageDataVO;
}
List<Integer> userIds = data.stream().map(StaffStatistics::getUserId).collect(Collectors.toList());
//根据员工id查询员工信息
//根据员工id查询员工信息
ObjectRestResponse<List<AppUserVo>> result = userFeign.getByUserIds(userIds);
List<AppUserVo> users = result.getData();
Map<Integer,AppUserVo> userVoMap = CollectionUtils.isEmpty(users) ? Collections.EMPTY_MAP : users.stream().filter(x->Objects.nonNull(x.getUserid())).collect(Collectors.toMap(AppUserVo::getUserid, Function.identity()));
Map<Integer, AppUserVo> userVoMap = CollectionUtils.isEmpty(users) ? Collections.EMPTY_MAP : users.stream().filter(x -> Objects.nonNull(x.getUserid())).collect(Collectors.toMap(AppUserVo::getUserid, Function.identity()));
Map<Integer, List<StaffStatistics>> statisticsMap = data.stream().collect(Collectors.groupingBy(StaffStatistics::getUserId, Collectors.toList()));
List<StaffStatisticsVo> staffStatisticsVos = new ArrayList<>(data.size());
StaffStatisticsVo staffStatisticsVo = new StaffStatisticsVo();
statisticsMap.forEach((K,V)->{
statisticsMap.forEach((K, V) -> {
List<String> compnayNames = new ArrayList<>(V.size());
List<String> postionNames = new ArrayList<>(V.size());
StaffStatisticsVo staffStatisticsClone = ObjectUtil.cloneByStream(staffStatisticsVo);
......@@ -77,16 +91,16 @@ public class StaffStatisticsBiz extends BaseBiz<StaffStatisticsMapper, StaffStat
staffStatisticsClone.setSellAmount(staffStatistics.getSellAmount().add(staffStatisticsClone.getSellAmount()));
staffStatisticsClone.setRoyaltyAmount(staffStatistics.getRoyaltyAmount().add(staffStatisticsClone.getRoyaltyAmount()));
staffStatisticsClone.setRentVehicleAmount(staffStatistics.getRentVehicleAmount().add(staffStatisticsClone.getRentVehicleAmount()));
staffStatisticsClone.setRentVehicleOrderNum(staffStatistics.getRentVehicleOrderNum()+staffStatisticsClone.getRentVehicleOrderNum());
staffStatisticsClone.setRentVehicleOrderNum(staffStatistics.getRentVehicleOrderNum() + staffStatisticsClone.getRentVehicleOrderNum());
staffStatisticsClone.setTravelAmount(staffStatistics.getTravelAmount().add(staffStatisticsClone.getTravelAmount()));
staffStatisticsClone.setTravelOrderNum(staffStatistics.getTravelOrderNum()+staffStatisticsClone.getTravelOrderNum());
staffStatisticsClone.setTravelOrderNum(staffStatistics.getTravelOrderNum() + staffStatisticsClone.getTravelOrderNum());
staffStatisticsClone.setMemberAmount(staffStatistics.getMemberAmount().add(staffStatisticsClone.getMemberAmount()));
staffStatisticsClone.setMemberOrderNum(staffStatistics.getMemberOrderNum()+staffStatisticsClone.getMemberOrderNum());
staffStatisticsClone.setMemberOrderNum(staffStatistics.getMemberOrderNum() + staffStatisticsClone.getMemberOrderNum());
compnayNames.add(staffStatistics.getCompanyName());
postionNames.add(staffStatistics.getPostionName());
}
AppUserVo appUserVo = userVoMap ==null?new AppUserVo():userVoMap.get(K)==null?new AppUserVo():userVoMap.get(K);
String name = StringUtils.hasText(appUserVo.getRealname())?appUserVo.getRealname():StringUtils.hasText(appUserVo.getNickname())?appUserVo.getNickname():"";
AppUserVo appUserVo = userVoMap == null ? new AppUserVo() : userVoMap.get(K) == null ? new AppUserVo() : userVoMap.get(K);
String name = StringUtils.hasText(appUserVo.getRealname()) ? appUserVo.getRealname() : StringUtils.hasText(appUserVo.getNickname()) ? appUserVo.getNickname() : "";
staffStatisticsClone.setName(name);
staffStatisticsClone.setPhone(appUserVo.getUsername());
staffStatisticsClone.setCompanyNames(compnayNames);
......@@ -103,18 +117,134 @@ public class StaffStatisticsBiz extends BaseBiz<StaffStatisticsMapper, StaffStat
return pageDataVO;
}
public void staffStatisticsJob(Date startDate,Date endDate,Map<Integer,String> companyMap){
//1.查询全部员工信息
List<UserStaffBo> userStaffBos = userFeign.findAllStaffs();
//2.根据员工id调用用户服务查询员工的佣金
if (CollectionUtils.isEmpty(userStaffBos)){
return;
}
public void staffStatisticsJob(Date startDate, Date endDate, Map<Integer, String> companyMap) {
List<StaffStatistics> staffStatisticsList = new ArrayList<>();
//1.查询全部员工信息
List<UserStaffBo> userStaffBos = userFeign.findAllStaffs();
//2.根据员工id调用用户服务查询员工的佣金
if (CollectionUtils.isEmpty(userStaffBos)) {
return;
}
Map<Integer, UserStaffBo> staffMap = userStaffBos.stream().collect(Collectors.toMap(UserStaffBo::getUserId, Function.identity()));
List<UserStaffBo> staffCommisstions = userFeign.findStaffSellerWater(Lists.newArrayList(staffMap.keySet()));
Map<Integer, BigDecimal> staffCommissionMap = CollectionUtils.isEmpty(staffCommisstions)?Collections.EMPTY_MAP:staffCommisstions.stream().collect(Collectors.toMap(UserStaffBo::getUserId, UserStaffBo::getCommission));
//2.根据员工id去订单基础表查询
//2.根据员工id去订单账目表查询
List<UserStaffBo> staffCommisstions = userFeign.findStaffSellerWater(Lists.newArrayList(staffMap.keySet()), startDate, endDate);
Map<Integer, BigDecimal> staffCommissionMap = CollectionUtils.isEmpty(staffCommisstions) ? Collections.EMPTY_MAP : staffCommisstions.stream().collect(Collectors.toMap(UserStaffBo::getUserId, UserStaffBo::getCommission));
//4.根据员工id去订单账目表查询
List<OrderAccountBo> orderAccountBos = orderAccountBiz.selectByDateAndStatffIds(startDate, endDate, Lists.newArrayList(staffMap.keySet()));
Map<Integer, Map<Integer, List<OrderAccountBo>>> accountMap = CollectionUtils.isEmpty(orderAccountBos) ? Collections.EMPTY_MAP : orderAccountBos.stream().collect(Collectors.groupingBy(OrderDTO::getUserId, Collectors.groupingBy(OrderDTO::getType, Collectors.toList())));
//遍历员工
for (UserStaffBo userStaffBo : userStaffBos) {
StaffStatistics staffStatistics = creatDefaultStaffStatistics(startDate, userStaffBo);
//1.设置佣金
if (staffCommissionMap!=null && staffCommissionMap.get(staffStatistics.getUserId())!=null){
staffStatistics.setRoyaltyAmount(staffCommissionMap.get(staffStatistics.getUserId()));
}
//2.设置
if(accountMap!=null && accountMap.get(staffStatistics.getUserId())!=null){
Map<Integer, List<OrderAccountBo>> orderAccountMap = accountMap.get(staffStatistics.getUserId());
//K:订单类型 V:对应的订单集合
orderAccountMap.forEach((K,V)->{
Map<String, Object> orderRentResultMap = wrapStaffStatisticsMap(V);
switch (K){
case StatisticsStatusEnum.ORDER_RENT_VEHICLE_TYPE:
staffStatistics.setRentVehicleOrderNum((Integer) orderRentResultMap.get(TOTAL_NUM_VAL));
staffStatistics.setRentVehicleAmount((BigDecimal) orderRentResultMap.get(TOTAL_AMOUNT_VAL));
break;
case StatisticsStatusEnum.ORDER_TOUR_TYPE:
staffStatistics.setTravelOrderNum((Integer) orderRentResultMap.get(TOTAL_NUM_VAL));
staffStatistics.setTravelAmount((BigDecimal) orderRentResultMap.get(TOTAL_AMOUNT_VAL));
break;
case StatisticsStatusEnum.ORDER_MEMBER_TYPE:
staffStatistics.setMemberOrderNum((Integer) orderRentResultMap.get(TOTAL_NUM_VAL));
staffStatistics.setMemberAmount((BigDecimal) orderRentResultMap.get(TOTAL_AMOUNT_VAL));
break;
default:
break;
}
});
}
//添加员工统计对象
staffStatisticsList.add(staffStatistics);
}
//批量插入
inserBatchStaffStatistics(staffStatisticsList);
}
public void inserBatchStaffStatistics(List<StaffStatistics> staffStatistics){
mapper.insertList(staffStatistics);
}
private Map<String,Object> wrapStaffStatisticsMap(List<OrderAccountBo> orderAccountBos){
Map<String,Object> staffStatisticsResultMap = new HashMap<>(2);
AtomicInteger orderCounter = new AtomicInteger(0);
BigDecimal totalAmount = BigDecimal.ZERO;
BigDecimal totalRefundAmount = BigDecimal.ZERO;
for (OrderAccountBo orderAccountBo : orderAccountBos) {
if (Objects.equals(orderAccountBo.getType(),AccountTypeEnum.IN_ORDER_PAY.getCode())){
orderCounter.incrementAndGet();
if (Objects.nonNull(orderAccountBo.getDamageSafe()) && (orderAccountBo.getDamageSafe() == StatisticsStatusEnum.DAMAGE_SAFE)){
BigDecimal safeAmount = getSafeAmount(orderAccountBo);
totalAmount = totalAmount.subtract(safeAmount);
}
totalAmount = totalAmount.add(orderAccountBo.getAccountDetailEntity().getOrderAmount());
}else{
if (Objects.nonNull(orderAccountBo.getDamageSafe()) && (orderAccountBo.getDamageSafe() == StatisticsStatusEnum.DAMAGE_SAFE)){
List<OrderAccountDeduction> deductions = orderAccountBo.getAccountDetailEntity().getDeductions();
boolean isCancelAll = Objects.equals(orderAccountBo.getType(), AccountTypeEnum.OUT_ORDER_FUND.getCode()) && CollectionUtils.isEmpty(deductions);
boolean isViolateCancel = CollectionUtils.isNotEmpty(deductions) && deductions.stream()
.map(OrderAccountDeduction::getType).collect(Collectors.toList()).contains(DeductionTypeEnum.VIOLATE_CANCEL.getCode());
if (isCancelAll || isViolateCancel){
BigDecimal safeAmount = getSafeAmount(orderAccountBo);
totalRefundAmount = totalRefundAmount.subtract(safeAmount);
}
}
totalRefundAmount = totalRefundAmount.add(orderAccountBo.getAccountDetailEntity().getOrderAmount());
}
}
staffStatisticsResultMap.put(TOTAL_AMOUNT_VAL,totalAmount.subtract(totalRefundAmount));
staffStatisticsResultMap.put(TOTAL_NUM_VAL,orderCounter.get());
return staffStatisticsResultMap;
}
private BigDecimal getSafeAmount(OrderAccountBo orderAccountBo){
JSONObject data = orderAccountBo.getData();
if(!data.isEmpty()) {
Object paramJson = data.get(StatisticsStatusEnum.PARMAM_JSON);
JSONObject jsonObject = JSONUtil.parseObj(paramJson);
BigDecimal safeAmount = jsonObject.get(StatisticsStatusEnum.NO_DEDUCTIBLE_AMOUNT, BigDecimal.class);
return safeAmount==null?BigDecimal.ZERO:safeAmount;
}
return BigDecimal.ZERO;
}
private StaffStatistics creatDefaultStaffStatistics(Date startDate, UserStaffBo userStaffBo) {
StaffStatistics staffStatistics = new StaffStatistics();
LocalDate localDate = LocalDate.from(new Date().toInstant().atZone(ZoneId.systemDefault()));
String year = String.valueOf(localDate.getYear());
String month = String.format("%s%d", year, localDate.getMonthValue());
String weekOfYear = String.format("%s%d", year, localDate.get(WeekFields.of(Locale.CHINESE).weekOfYear()));
staffStatistics.setUserId(userStaffBo.getUserId());
staffStatistics.setCompanyId(userStaffBo.getCompanyId());
staffStatistics.setCompanyName(userStaffBo.getCompanyName());
staffStatistics.setUserPostionId(userStaffBo.getPostionId());
staffStatistics.setPostionName(userStaffBo.getPostionName());
staffStatistics.setMemberAmount(BigDecimal.ZERO);
staffStatistics.setMemberOrderNum(0);
staffStatistics.setTravelAmount(BigDecimal.ZERO);
staffStatistics.setTravelOrderNum(0);
staffStatistics.setRentVehicleAmount(BigDecimal.ZERO);
staffStatistics.setRentVehicleOrderNum(0);
staffStatistics.setSellAmount(BigDecimal.ZERO);
staffStatistics.setRoyaltyAmount(BigDecimal.ZERO);
staffStatistics.setDate(startDate);
staffStatistics.setYear(year);
staffStatistics.setMonth(month);
staffStatistics.setWeekOfYear(weekOfYear);
staffStatistics.setCrtTime(new Date());
return staffStatistics;
}
}
package com.xxfc.platform.order.jobhandler;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import com.xxfc.platform.order.biz.StaffStatisticsBiz;
import com.xxfc.platform.vehicle.feign.VehicleFeign;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.IJobHandler;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import java.util.Date;
import java.util.Map;
/**
* @author libin
* @version 1.0
* @description 员工业绩统计job
* @data 2019/11/26 10:12
*/
@Component
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
@Slf4j
public class SaffStatisticsJobHandler extends IJobHandler {
private final StaffStatisticsBiz staffStatisticsBiz;
private final VehicleFeign vehicleFeign;
@Override
public ReturnT<String> execute(String arg) throws Exception {
//1.查询公司
Map<Integer, String> companyMap = vehicleFeign.findCompanyMap();
Date date= null;
if (StringUtils.hasText(arg)){
date = DateUtil.parse(arg,"yyyy-MM-dd");
}else {
date = DateUtil.yesterday().toJdkDate();
}
Date startDate = DateUtil.beginOfDay(date).toJdkDate();
Date endDate = DateUtil.endOfDay(date).toJdkDate();
staffStatisticsBiz.staffStatisticsJob(startDate,endDate,companyMap);
return ReturnT.SUCCESS;
}
}
......@@ -4,10 +4,13 @@ import com.xxfc.platform.order.entity.BaseOrder;
import com.xxfc.platform.order.pojo.bg.BgOrderListVo;
import com.xxfc.platform.order.pojo.dto.MemberOrderBo;
import com.xxfc.platform.order.pojo.dto.MemberOrderFindDTO;
import com.xxfc.platform.order.pojo.dto.OrderDTO;
import com.xxfc.platform.order.pojo.order.OrderListVo;
import com.xxfc.platform.order.pojo.order.OrderPageVO;
import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.common.Mapper;
import java.util.Date;
import java.util.List;
import java.util.Map;
......@@ -36,7 +39,8 @@ public interface BaseOrderMapper extends Mapper<BaseOrder> {
List<MemberOrderBo> findMemberOrders(MemberOrderFindDTO memberOrderFindDTO);
public List<BgOrderListVo> getAllOrderList(Map<String, Object> paramMap);
List<OrderDTO> selectOrdersByTypeAndTime(@Param("types") List<Integer> types,
@Param("hasPay") Integer hasPay,
@Param("startDate") Date startDate,
@Param("endDate") Date endDate);
}
......@@ -2,10 +2,12 @@ package com.xxfc.platform.order.mapper;
import com.xxfc.platform.order.entity.OrderAccount;
import com.xxfc.platform.order.pojo.Term;
import com.xxfc.platform.order.pojo.account.OrderAccountBo;
import com.xxfc.platform.order.pojo.account.OrderAccountDTO;
import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.common.Mapper;
import java.util.Date;
import java.util.List;
......@@ -19,4 +21,12 @@ import java.util.List;
public interface OrderAccountMapper extends Mapper<OrderAccount> {
List<OrderAccountDTO> getOrderAccountByOrderType(Term term);
List<OrderAccountBo> selectOrderAccountByOrderTypeAndStartTimeAndEndTime(@Param("orderType") Integer orderType,
@Param("startTime") long startTime,
@Param("endTime") long endTime);
List<OrderAccountBo> selectByDateAndStatffIds(@Param("startDate") Date startDate,
@Param("endDate") Date endDate,
@Param("staffUserIds") List<Integer> staffUserIds);
}
......@@ -410,4 +410,26 @@
) AS `omd` ON omd.order_id=bo.id
ORDER BY bo.`creatTime` DESC
</select>
<select id="selectOrdersByTypeAndTime" resultType="com.xxfc.platform.order.pojo.dto.OrderDTO">
select bo.id,bo.type,bo.status,bo.order_amount,bo.real_amount,bo.order_origin,bo.parent_user_id as `userId`,bo.parent_postion_id as `postionId`,
bo.has_pay,bo.pay_way,omd.memberLevel,IFNULL(IFNULL(orvd.start_company_id,otd.start_company_id),`parent_user_company_id`) AS `companyId`,orvd.deposit,orvd.cost_detail_extend AS `costDetailExtend` from (select `id`,`type`,`status`,`order_amount` AS `orderAmount`, `real_amount`AS
`realAmount`,`order_origin` AS `orderOrigin`, `has_pay` AS `hasPay`,
`pay_way` AS `payWay`
from `base_order` where 1=1
<if test="hasPay!=null">
and `has_pay`=#{hasPay}
</if>
and (`crt_time` between #{startDate} and #{endDate} or `pay_time` between #{startDate} and #{endDate} ) and `type` IN <foreach collection="types"
item="type"
open="(" close=")"
separator=",">
#{type}
</foreach> ) AS `bo`
LEFT JOIN (select `order_id`,`start_company_id`,`deposit`,`cost_detail_extend` from `order_rent_vehicle_detail`) AS `orvd` ON
orvd.order_id=bo.id
LEFT JOIN (select `order_id`,`start_company_id` from `order_tour_detail`) AS `otd` ON otd.order_id=bo.id
LEFT JOIN (select `order_id`,`member_level` AS `memberLevel` from `order_member_detail`) AS `omd` ON
omd.order_id=bo.id;
</select>
</mapper>
\ No newline at end of file
......@@ -51,4 +51,57 @@
</if>
</select>
<select id="selectOrderAccountByOrderTypeAndStartTimeAndEndTime"
resultType="com.xxfc.platform.order.pojo.account.OrderAccountBo">
SELECT
oa.*,
bo.id,
bo.`status`,
bo.order_origin,
bo.pay_way,
bo.has_pay,
IFNULL(brvd.start_company_id,IFNULL(otd.start_company_id,bo.parent_user_company_id)) AS `companyId`,
brvd.cost_detail_extend AS `costDetailExtend`,
brvd.damage_safe AS `damageSafe`,
omd.member_level AS `memberLevel`
FROM
`order_account` AS `oa`
LEFT JOIN `base_order` AS `bo` ON bo.id = oa.order_id
LEFT JOIN `order_rent_vehicle_detail` AS `brvd` ON brvd.order_id=oa.order_id
LEFT JOIN `order_tour_detail` as `otd` ON otd.order_id=oa.order_id
LEFT JOIN `order_member_detail` AS `omd` ON omd.order_id=oa.order_id
WHERE bo.type=#{orderType} AND `oa`.account_status=1 AND oa.`crt_time` BETWEEN #{startTime} AND #{endTime}
</select>
<select id="selectByDateAndStatffIds" resultType="com.xxfc.platform.order.pojo.account.OrderAccountBo">
oa.*,
bo.id,
bo.`status`,
bo.order_origin,
bo.pay_way,
bo.has_pay,
bo.parent_user_id as `userId`,
bo.parent_position_id as `postionId`,
IFNULL(brvd.start_company_id,IFNULL(otd.start_company_id,bo.parent_user_company_id)) AS `companyId`,
brvd.cost_detail_extend AS `costDetailExtend`,
brvd.damage_safe AS `damageSafe`,
omd.member_level AS `memberLevel`
FROM
`order_account` AS `oa`
LEFT JOIN `base_order` AS `bo` ON bo.id = oa.order_id
LEFT JOIN `order_rent_vehicle_detail` AS `brvd` ON brvd.order_id=oa.order_id
LEFT JOIN `order_tour_detail` as `otd` ON otd.order_id=oa.order_id
LEFT JOIN `order_member_detail` AS `omd` ON omd.order_id=oa.order_id
WHERE `oa`.account_status=1
AND oa.`crt_time` BETWEEN #{startDate} AND #{endDate}
<if test="staffUserIds!=null and staffUserIds.size>0">
and bo.id IN <foreach collection="staffUserIds" item="staffId" open="(" close=")" separator=",">
#{staffId}
</foreach>
</if>
</select>
</mapper>
\ No newline at end of file
......@@ -2,7 +2,9 @@ import com.xxfc.platform.order.OrderApplication;
import com.xxfc.platform.order.biz.DailyOrderStatisticsBiz;
import com.xxfc.platform.order.biz.OrderStatisticsBiz;
import com.xxfc.platform.order.jobhandler.BaseOrderStatisticsJobHandler;
import com.xxfc.platform.order.jobhandler.SaffStatisticsJobHandler;
import com.xxfc.platform.order.pojo.HomePageOrderData;
import lombok.SneakyThrows;
import org.joda.time.DateTime;
import org.junit.Test;
import org.junit.runner.RunWith;
......@@ -33,6 +35,9 @@ public class ServiceTest {
@Autowired
private BaseOrderStatisticsJobHandler handler;
@Autowired
private SaffStatisticsJobHandler statisticsJobHandler;
@Test
public void testSchedu(){
......@@ -77,5 +82,10 @@ public class ServiceTest {
handler.execute("2019-09-29");
}
@Test
@SneakyThrows
public void testStaffStatisticsJob(){
statisticsJobHandler.execute("");
}
}
......@@ -200,4 +200,7 @@ public interface VehicleFeign {
@RequestParam(value = "endDate") Long endDate,
@RequestParam(value = "vehicleModelId") Integer vehicleModelId,
@RequestParam(value = "userId") Integer userId);
@GetMapping("/branchCompany/company_info")
Map<Integer, String> findCompanyMap();
}
......@@ -432,4 +432,13 @@ public class BranchCompanyBiz extends BaseBiz<BranchCompanyMapper, BranchCompany
return ObjectRestResponse.succ();
}
public Map<Integer, String> selectCompanyMap() {
Example example = new Example(BranchCompany.class);
example.createCriteria().andEqualTo("isDel", 0);
List<BranchCompany> branchCompanies = mapper.selectByExample(example);
if (CollectionUtils.isEmpty(branchCompanies)){
return Collections.EMPTY_MAP;
}
return branchCompanies.stream().collect(Collectors.toMap(BranchCompany::getId,BranchCompany::getName));
}
}
......@@ -227,4 +227,9 @@ public class BranchCompanyController extends BaseController<BranchCompanyBiz> {
return RestResponse.suc(baseBiz.getCompanyIds(dataZone,dataCompany));
}
@GetMapping("/company_info")
public Map<Integer, String> findCompanyMap(){
return baseBiz.selectCompanyMap();
}
}
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