Commit e4d8720d authored by libin's avatar libin

Merge branch 'staff-statistics'

parents 644170b3 df220352
package com.github.wxiaoqi.security.common.enumconstant;
import java.util.ArrayList;
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 = new ArrayList<>(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;
}
}
package com.github.wxiaoqi.security.admin.bo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.collections4.CollectionUtils;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/11/26 17:09
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class StaffStatisticsBo {
private static final long serialVersionUID = 1L;
private String name ;
private Integer userId;
private List<String> companyNames;
private List<Integer> compnayIds;
private List<String> postionNames;
private List<Integer> postionIds;
private String phone;
private BigDecimal sellAmount = BigDecimal.ZERO;
private BigDecimal royaltyAmount = BigDecimal.ZERO;
private Integer memberOrderNum = 0;
private BigDecimal memberAmount = BigDecimal.ZERO;
private Integer rentVehicleOrderNum = 0;
private BigDecimal rentVehicleAmount = BigDecimal.ZERO;
private Integer travelOrderNum = 0;
private BigDecimal travelAmount = BigDecimal.ZERO;
public List<String> getCompanyNames() {
return CollectionUtils.isEmpty(companyNames)? new ArrayList<>():companyNames;
}
public List<Integer> getCompnayIds() {
return CollectionUtils.isEmpty(compnayIds)?new ArrayList<>():compnayIds;
}
public List<String> getPostionNames() {
return CollectionUtils.isEmpty(postionNames)?new ArrayList<>() :postionNames;
}
public List<Integer> getPostionIds() {
return CollectionUtils.isEmpty(postionIds)?new ArrayList<>():postionIds;
}
public BigDecimal getSellAmount() {
return rentVehicleAmount.add(travelAmount).add(memberAmount);
}
}
package com.github.wxiaoqi.security.admin.bo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.math.BigDecimal;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/11/26 17:09
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class StaffStatisticsTotalBo {
private Integer staffNum;
private BigDecimal totalSellAmount;
private BigDecimal totalRoyaltyAmount;
public Integer getStaffNum() {
return this.staffNum==null?0:staffNum;
}
public BigDecimal getTotalSellAmount() {
return this.totalSellAmount==null?BigDecimal.ZERO:totalSellAmount;
}
public BigDecimal getTotalRoyaltyAmount() {
return this.totalRoyaltyAmount==null?BigDecimal.ZERO:totalRoyaltyAmount;
}
}
package com.github.wxiaoqi.security.admin.bo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/11/25 14:33
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class UserStaffBo implements Serializable {
private static final long serialVersionUID = 1L;
private Integer userId;
private String realName;
private String nickName;
private String phone;
private Integer postionId;
private String postionName;
private Integer companyId;
private String companyName;
/**
* 佣金
*/
private BigDecimal commission;
}
...@@ -3,6 +3,9 @@ package com.github.wxiaoqi.security.admin.dto; ...@@ -3,6 +3,9 @@ package com.github.wxiaoqi.security.admin.dto;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
/** /**
* @author libin * @author libin
* @version 1.0 * @version 1.0
...@@ -10,7 +13,8 @@ import lombok.Data; ...@@ -10,7 +13,8 @@ import lombok.Data;
* @data 2019/7/11 15:14 * @data 2019/7/11 15:14
*/ */
@Data @Data
public class AppUserSellingWaterDTO { public class AppUserSellingWaterDTO implements Serializable {
private static final long serialVersionUID = 1L;
/** /**
* 用户id * 用户id
*/ */
...@@ -35,6 +39,8 @@ public class AppUserSellingWaterDTO { ...@@ -35,6 +39,8 @@ public class AppUserSellingWaterDTO {
@ApiModelProperty(value = "订单id") @ApiModelProperty(value = "订单id")
private Integer orderId; private Integer orderId;
private Integer orderType;
/** /**
* 商品id * 商品id
*/ */
...@@ -75,7 +81,7 @@ public class AppUserSellingWaterDTO { ...@@ -75,7 +81,7 @@ public class AppUserSellingWaterDTO {
* 售价 * 售价
*/ */
@ApiModelProperty(value = "售价") @ApiModelProperty(value = "售价")
private Long price; private BigDecimal price;
/** /**
* 提成百分比 * 提成百分比
...@@ -89,4 +95,12 @@ public class AppUserSellingWaterDTO { ...@@ -89,4 +95,12 @@ public class AppUserSellingWaterDTO {
@ApiModelProperty(value = "是否入账:0-未入账;1-已入账") @ApiModelProperty(value = "是否入账:0-未入账;1-已入账")
private Integer waiting; private Integer waiting;
private BigDecimal commission;
private Integer companyId;
private String companyName;
private String stateGroup;
} }
package com.github.wxiaoqi.security.admin.dto;
import com.github.wxiaoqi.security.common.vo.PageParam;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
import java.util.List;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/11/26 17:04
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class StaffStatisticsFindDTO extends PageParam {
private Date startDate;
private Date endDate;
private String companyName;
private String postionName;
private Integer userPostionId;
private Integer companyId;
private List<Integer> userIds;
}
package com.github.wxiaoqi.security.admin.feign; package com.github.wxiaoqi.security.admin.feign;
import com.github.wxiaoqi.security.admin.bo.UserBo; import com.github.wxiaoqi.security.admin.bo.UserBo;
import com.github.wxiaoqi.security.admin.bo.UserStaffBo;
import com.github.wxiaoqi.security.admin.dto.AppUserSellingWaterDTO;
import com.github.wxiaoqi.security.admin.dto.UserMemberDTO; import com.github.wxiaoqi.security.admin.dto.UserMemberDTO;
import com.github.wxiaoqi.security.admin.entity.AppUserLogin; import com.github.wxiaoqi.security.admin.entity.AppUserLogin;
import com.github.wxiaoqi.security.admin.entity.AppUserPosition;
import com.github.wxiaoqi.security.admin.entity.BaseUserMember; import com.github.wxiaoqi.security.admin.entity.BaseUserMember;
import com.github.wxiaoqi.security.admin.entity.BaseUserMemberLevel; import com.github.wxiaoqi.security.admin.entity.BaseUserMemberLevel;
import com.github.wxiaoqi.security.admin.feign.dto.AppUserDTO; import com.github.wxiaoqi.security.admin.feign.dto.AppUserDTO;
import com.github.wxiaoqi.security.admin.feign.dto.UserDTO; import com.github.wxiaoqi.security.admin.feign.dto.UserDTO;
import com.github.wxiaoqi.security.admin.vo.AppUserVo; import com.github.wxiaoqi.security.admin.vo.AppUserVo;
import com.github.wxiaoqi.security.admin.vo.ImiVo; import com.github.wxiaoqi.security.admin.vo.ImiVo;
import com.github.wxiaoqi.security.admin.vo.WalletPostionVo;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse; import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -158,4 +163,17 @@ public interface UserFeign { ...@@ -158,4 +163,17 @@ public interface UserFeign {
@RequestParam(value = "cono",required = false) String cono, @RequestParam(value = "cono",required = false) String cono,
@RequestParam(value = "reason",required = false) String reason, @RequestParam(value = "reason",required = false) String reason,
@RequestParam(value = "isSuccess") Boolean isSuccess); @RequestParam(value = "isSuccess") Boolean isSuccess);
@GetMapping("/app/user/list_staff")
List<UserStaffBo> findAllStaffs();
@GetMapping("/sellingwater/list_staff_sellerwater")
List<AppUserSellingWaterDTO> findStaffSellerWater(@RequestParam(value = "userIds",required = false) List<Integer> userIds,
@RequestParam(value = "startDate") Date startDate,
@RequestParam(value = "endDate") Date endDate);
@GetMapping("/postion/admin/postions")
ObjectRestResponse<List<WalletPostionVo>> findAllPostions();
@GetMapping("/public/getUsersByUserIdList")
ObjectRestResponse<List<AppUserVo>> getByUserIdList(@RequestParam("userIds") List<Integer> userIds);
} }
...@@ -3,6 +3,8 @@ package com.github.wxiaoqi.security.admin.vo; ...@@ -3,6 +3,8 @@ package com.github.wxiaoqi.security.admin.vo;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import java.io.Serializable;
/** /**
* @author libin * @author libin
* @version 1.0 * @version 1.0
...@@ -10,8 +12,8 @@ import lombok.Data; ...@@ -10,8 +12,8 @@ import lombok.Data;
* @data 2019/7/17 16:17 * @data 2019/7/17 16:17
*/ */
@Data @Data
public class WalletPostionVo { public class WalletPostionVo implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty("主键id") @ApiModelProperty("主键id")
private Integer id; private Integer id;
......
...@@ -2,13 +2,16 @@ package com.github.wxiaoqi.security.admin.biz; ...@@ -2,13 +2,16 @@ package com.github.wxiaoqi.security.admin.biz;
import com.ace.cache.annotation.Cache; import com.ace.cache.annotation.Cache;
import com.ace.cache.annotation.CacheClear; import com.ace.cache.annotation.CacheClear;
import com.github.wxiaoqi.security.admin.bo.UserStaffBo;
import com.github.wxiaoqi.security.admin.dto.AccountBindDTO; import com.github.wxiaoqi.security.admin.dto.AccountBindDTO;
import com.github.wxiaoqi.security.admin.dto.StaffStatisticsFindDTO;
import com.github.wxiaoqi.security.admin.entity.AppUserDetail; import com.github.wxiaoqi.security.admin.entity.AppUserDetail;
import com.github.wxiaoqi.security.admin.mapper.AppUserDetailMapper; import com.github.wxiaoqi.security.admin.mapper.AppUserDetailMapper;
import com.github.wxiaoqi.security.admin.rpc.service.AppPermissionService; import com.github.wxiaoqi.security.admin.rpc.service.AppPermissionService;
import com.github.wxiaoqi.security.admin.vo.AppUserInfoVo; import com.github.wxiaoqi.security.admin.vo.AppUserInfoVo;
import com.github.wxiaoqi.security.admin.vo.AppUserVo; import com.github.wxiaoqi.security.admin.vo.AppUserVo;
import com.github.wxiaoqi.security.common.biz.BaseBiz; import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.github.wxiaoqi.security.common.vo.PageDataVO;
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.apache.commons.collections.CollectionUtils;
...@@ -17,10 +20,7 @@ import org.springframework.transaction.annotation.Transactional; ...@@ -17,10 +20,7 @@ import org.springframework.transaction.annotation.Transactional;
import tk.mybatis.mapper.entity.Example; import tk.mybatis.mapper.entity.Example;
import java.time.Instant; import java.time.Instant;
import java.util.Collection; import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -173,4 +173,23 @@ public class AppUserDetailBiz extends BaseBiz<AppUserDetailMapper, AppUserDetail ...@@ -173,4 +173,23 @@ public class AppUserDetailBiz extends BaseBiz<AppUserDetailMapper, AppUserDetail
public List<AppUserVo> getUserByUserIds(List<Integer> ids) { public List<AppUserVo> getUserByUserIds(List<Integer> ids) {
return mapper.getUserVo(ids); return mapper.getUserVo(ids);
} }
public List<UserStaffBo> findAllStaffs() {
List<UserStaffBo> userStaffBos = mapper.selectAllStaffs();
return CollectionUtils.isEmpty(userStaffBos)? Collections.EMPTY_LIST:userStaffBos;
}
public List<AppUserVo> getUserByUserIdList(List<Integer> userIds) {
List<AppUserVo> appUserVos = mapper.getUserByUserIdList(userIds);
return CollectionUtils.isEmpty(appUserVos)?Collections.EMPTY_LIST:appUserVos;
}
public PageDataVO<UserStaffBo> findAllStaffsByCompanyIdAndPostionIdWithPage(StaffStatisticsFindDTO staffStatisticsFindDTO) {
return PageDataVO.pageInfo(staffStatisticsFindDTO.getPage(),staffStatisticsFindDTO.getLimit(),()->mapper.findAllStaffsByCompanyIdAndPostionId(staffStatisticsFindDTO));
}
public List<UserStaffBo> findStaffsByIdsAndCompanyAndPostion(StaffStatisticsFindDTO staffStatisticsFindDTO) {
List<UserStaffBo> staffBos = mapper.findAllStaffsByCompanyIdAndPostionId(staffStatisticsFindDTO);
return CollectionUtils.isEmpty(staffBos)?Collections.EMPTY_LIST:staffBos;
}
} }
package com.github.wxiaoqi.security.admin.biz; package com.github.wxiaoqi.security.admin.biz;
import com.github.wxiaoqi.security.admin.bo.UserIncomeBo; import com.github.wxiaoqi.security.admin.bo.UserIncomeBo;
import com.github.wxiaoqi.security.admin.dto.OrderGoodsDTO; import com.github.wxiaoqi.security.admin.bo.UserStaffBo;
import com.github.wxiaoqi.security.admin.dto.OrderWaterDTO; import com.github.wxiaoqi.security.admin.dto.*;
import com.github.wxiaoqi.security.admin.dto.UserSellingWaterAdminDTO;
import com.github.wxiaoqi.security.admin.dto.UserSellingWaterFindDTO;
import com.github.wxiaoqi.security.admin.entity.*; import com.github.wxiaoqi.security.admin.entity.*;
import com.github.wxiaoqi.security.admin.entity.AppUserRelation; import com.github.wxiaoqi.security.admin.entity.AppUserRelation;
import com.github.wxiaoqi.security.admin.vo.SellingWalletVo; import com.github.wxiaoqi.security.admin.vo.SellingWalletVo;
...@@ -20,6 +18,7 @@ import com.github.wxiaoqi.security.common.biz.BaseBiz; ...@@ -20,6 +18,7 @@ import com.github.wxiaoqi.security.common.biz.BaseBiz;
import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import tk.mybatis.mapper.entity.Example; import tk.mybatis.mapper.entity.Example;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.*; import java.util.*;
import java.util.function.Supplier; import java.util.function.Supplier;
...@@ -199,12 +198,12 @@ public class AppUserSellingWaterBiz extends BaseBiz<AppUserSellingWaterMapper, A ...@@ -199,12 +198,12 @@ public class AppUserSellingWaterBiz extends BaseBiz<AppUserSellingWaterMapper, A
amount = amount.add(commission); amount = amount.add(commission);
} }
BigDecimal unbooked=amount; BigDecimal unbooked = amount;
log.info("订单完成计算用户拥金----finishOrderWater----orderId====" + orderId + "---amount==" + amount+"---unbooked=="+unbooked); log.info("订单完成计算用户拥金----finishOrderWater----orderId====" + orderId + "---amount==" + amount + "---unbooked==" + unbooked);
if(orderType==1){ if (orderType == 1) {
List<OrderGoodsDTO> goodsDTOList =orderWaterDTO.getGoodsDTOList(); List<OrderGoodsDTO> goodsDTOList = orderWaterDTO.getGoodsDTOList();
log.info("租车订单完成-----goodsDTOList==="+goodsDTOList); log.info("租车订单完成-----goodsDTOList===" + goodsDTOList);
if (CollectionUtils.isNotEmpty(goodsDTOList)){ if (CollectionUtils.isNotEmpty(goodsDTOList)) {
for (OrderGoodsDTO goodsDto : goodsDTOList) { for (OrderGoodsDTO goodsDto : goodsDTOList) {
//商品id //商品id
Integer goodId = goodsDto.getGoodId(); Integer goodId = goodsDto.getGoodId();
...@@ -214,17 +213,17 @@ public class AppUserSellingWaterBiz extends BaseBiz<AppUserSellingWaterMapper, A ...@@ -214,17 +213,17 @@ public class AppUserSellingWaterBiz extends BaseBiz<AppUserSellingWaterMapper, A
sellingWater.setOrderId(orderId); sellingWater.setOrderId(orderId);
sellingWater.setGoodId(goodId); sellingWater.setGoodId(goodId);
sellingWater = selectOne(sellingWater); sellingWater = selectOne(sellingWater);
if (sellingWater == null||sellingWater.getExtract()==null||sellingWater.getExtract()==0) { if (sellingWater == null || sellingWater.getExtract() == null || sellingWater.getExtract() == 0) {
log.info("租车订单完成-----sellingWater---不存在或extract---为空"); log.info("租车订单完成-----sellingWater---不存在或extract---为空");
continue; continue;
} }
if (price.compareTo(sellingWater.getPrice())>=0){ if (price.compareTo(sellingWater.getPrice()) >= 0) {
log.info("租车订单完成-----完成价格大于支付价格"); log.info("租车订单完成-----完成价格大于支付价格");
continue; continue;
} }
price=sellingWater.getPrice().subtract(price); price = sellingWater.getPrice().subtract(price);
Integer extract=sellingWater.getExtract(); Integer extract = sellingWater.getExtract();
log.info("租车订单完成-----price====="+price+"---extract===="+extract); log.info("租车订单完成-----price=====" + price + "---extract====" + extract);
BigDecimal commission = price.multiply(new BigDecimal(extract + "")).divide(new BigDecimal("100"), 2, BigDecimal.ROUND_HALF_UP); BigDecimal commission = price.multiply(new BigDecimal(extract + "")).divide(new BigDecimal("100"), 2, BigDecimal.ROUND_HALF_UP);
log.info("租车订单完成--------userId===" + userId + "---commission===" + commission); log.info("租车订单完成--------userId===" + userId + "---commission===" + commission);
sellingWater.setWaiting(1); sellingWater.setWaiting(1);
...@@ -234,8 +233,8 @@ public class AppUserSellingWaterBiz extends BaseBiz<AppUserSellingWaterMapper, A ...@@ -234,8 +233,8 @@ public class AppUserSellingWaterBiz extends BaseBiz<AppUserSellingWaterMapper, A
insertSelective(sellingWater); insertSelective(sellingWater);
log.info("租车订单完成计算用户拥成功----payOrderWater--------userId===" + userId); log.info("租车订单完成计算用户拥成功----payOrderWater--------userId===" + userId);
amount = amount.subtract(commission); amount = amount.subtract(commission);
}
} }
}
} }
log.info("订单完成计算用户拥金----finishOrderWater--------orderId===" + orderId + "----amount====" + amount + "--orderType===" + orderType); log.info("订单完成计算用户拥金----finishOrderWater--------orderId===" + orderId + "----amount====" + amount + "--orderType===" + orderType);
int r = amount.compareTo(BigDecimal.ZERO); int r = amount.compareTo(BigDecimal.ZERO);
...@@ -249,7 +248,7 @@ public class AppUserSellingWaterBiz extends BaseBiz<AppUserSellingWaterMapper, A ...@@ -249,7 +248,7 @@ public class AppUserSellingWaterBiz extends BaseBiz<AppUserSellingWaterMapper, A
detail.setSource(1); detail.setSource(1);
myWaterBiz.updMyWater(detail); myWaterBiz.updMyWater(detail);
} }
if ((orderType == 1 || orderType == 2)&&unbooked.compareTo(BigDecimal.ZERO)==1 ){ if ((orderType == 1 || orderType == 2) && unbooked.compareTo(BigDecimal.ZERO) == 1) {
myWaterBiz.updMyWalletUnbooked(userId, unbooked, 2); myWaterBiz.updMyWalletUnbooked(userId, unbooked, 2);
} }
} }
...@@ -449,7 +448,7 @@ public class AppUserSellingWaterBiz extends BaseBiz<AppUserSellingWaterMapper, A ...@@ -449,7 +448,7 @@ public class AppUserSellingWaterBiz extends BaseBiz<AppUserSellingWaterMapper, A
criteria.andEqualTo("userId", leaderId); criteria.andEqualTo("userId", leaderId);
criteria.andEqualTo("orderType", orderType); criteria.andEqualTo("orderType", orderType);
List<AppUserSellingWater> appUserSellingWaters = mapper.selectByExample(example); List<AppUserSellingWater> appUserSellingWaters = mapper.selectByExample(example);
if (CollectionUtils.isEmpty(appUserSellingWaters)){ if (CollectionUtils.isEmpty(appUserSellingWaters)) {
return Collections.EMPTY_LIST; return Collections.EMPTY_LIST;
} }
return appUserSellingWaters.stream().map(AppUserSellingWater::getSourceId).collect(Collectors.toList()); return appUserSellingWaters.stream().map(AppUserSellingWater::getSourceId).collect(Collectors.toList());
...@@ -462,6 +461,37 @@ public class AppUserSellingWaterBiz extends BaseBiz<AppUserSellingWaterMapper, A ...@@ -462,6 +461,37 @@ public class AppUserSellingWaterBiz extends BaseBiz<AppUserSellingWaterMapper, A
return pageDataVO; return pageDataVO;
} }
public List<AppUserSellingWaterDTO> 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;*/
List<AppUserSellingWaterDTO> appUserSellingWaterDTOS = new ArrayList<>();
Example example = new Example(AppUserSellingWater.class);
Example.Criteria criteria = example.createCriteria();
criteria.andIn("userId", userIds);
if(startDate!=null && endDate!=null){
criteria.andBetween("crtTime", startDate.getTime(), endDate.getTime());
}
if (startDate!=null && endDate==null){
criteria.andGreaterThanOrEqualTo("crtTime",startDate.getTime());
}
if(startDate==null && endDate!=null){
criteria.andLessThanOrEqualTo("crtTime",endDate.getTime());
}
criteria.andNotEqualTo("positionId", 6);
List<AppUserSellingWater> appUserSellingWaters = mapper.selectByExample(example);
if (CollectionUtils.isEmpty(appUserSellingWaters)) {
return appUserSellingWaterDTOS;
}
AppUserSellingWaterDTO appUserSellingWaterDTO = null;
for (AppUserSellingWater appUserSellingWater : appUserSellingWaters) {
appUserSellingWaterDTO = new AppUserSellingWaterDTO();
BeanUtils.copyProperties(appUserSellingWater, appUserSellingWaterDTO);
appUserSellingWaterDTOS.add(appUserSellingWaterDTO);
}
return appUserSellingWaterDTOS;
}
private enum SellerWallterStatus { private enum SellerWallterStatus {
CANCEL(2, "取消订单"), CANCEL(2, "取消订单"),
POST(1, "已入账"), POST(1, "已入账"),
......
package com.github.wxiaoqi.security.admin.mapper; package com.github.wxiaoqi.security.admin.mapper;
import com.github.wxiaoqi.security.admin.bo.UserStaffBo;
import com.github.wxiaoqi.security.admin.dto.AppUserManageDTO; import com.github.wxiaoqi.security.admin.dto.AppUserManageDTO;
import com.github.wxiaoqi.security.admin.dto.StaffStatisticsFindDTO;
import com.github.wxiaoqi.security.admin.entity.AppUserDetail; import com.github.wxiaoqi.security.admin.entity.AppUserDetail;
import com.github.wxiaoqi.security.admin.vo.AppUserManageVo; import com.github.wxiaoqi.security.admin.vo.AppUserManageVo;
import com.github.wxiaoqi.security.admin.vo.AppUserVo; import com.github.wxiaoqi.security.admin.vo.AppUserVo;
...@@ -26,4 +28,9 @@ public interface AppUserDetailMapper extends Mapper<AppUserDetail> { ...@@ -26,4 +28,9 @@ public interface AppUserDetailMapper extends Mapper<AppUserDetail> {
List<AppUserManageVo> selectAppUser(AppUserManageDTO appUserManageDTO); List<AppUserManageVo> selectAppUser(AppUserManageDTO appUserManageDTO);
List<UserStaffBo> selectAllStaffs();
List<AppUserVo> getUserByUserIdList(@Param("userIds") List<Integer> userIds);
List<UserStaffBo> findAllStaffsByCompanyIdAndPostionId(StaffStatisticsFindDTO staffStatisticsFindDTO);
} }
\ No newline at end of file
package com.github.wxiaoqi.security.admin.mapper; package com.github.wxiaoqi.security.admin.mapper;
import com.github.wxiaoqi.security.admin.bo.UserIncomeBo; import com.github.wxiaoqi.security.admin.bo.UserIncomeBo;
import com.github.wxiaoqi.security.admin.bo.UserStaffBo;
import com.github.wxiaoqi.security.admin.dto.AppUserSellingWaterDTO;
import com.github.wxiaoqi.security.admin.dto.UserSellingWaterAdminDTO; import com.github.wxiaoqi.security.admin.dto.UserSellingWaterAdminDTO;
import com.github.wxiaoqi.security.admin.dto.UserSellingWaterFindDTO; import com.github.wxiaoqi.security.admin.dto.UserSellingWaterFindDTO;
import com.github.wxiaoqi.security.admin.entity.AppUserSellingWater; import com.github.wxiaoqi.security.admin.entity.AppUserSellingWater;
...@@ -27,4 +29,8 @@ public interface AppUserSellingWaterMapper extends Mapper<AppUserSellingWater> { ...@@ -27,4 +29,8 @@ public interface AppUserSellingWaterMapper extends Mapper<AppUserSellingWater> {
List<SellingWalletVo> selectSellerWalterByUserIdAndWating(@Param("userId") Integer userId, @Param("wating") Integer wating); List<SellingWalletVo> selectSellerWalterByUserIdAndWating(@Param("userId") Integer userId, @Param("wating") Integer wating);
List<UserSellingWaterAdminDTO> selectSellingWaterPage(UserSellingWaterFindDTO userSellingWaterFindDTO); List<UserSellingWaterAdminDTO> selectSellingWaterPage(UserSellingWaterFindDTO userSellingWaterFindDTO);
List<AppUserSellingWaterDTO> statisticsStatffSellerWaterByUserIdsAndTime(@Param("userIds") List<Integer> userIds,
@Param("startTime") Long startTime,
@Param("endTime") Long endTime);
} }
...@@ -2,6 +2,7 @@ package com.github.wxiaoqi.security.admin.rest; ...@@ -2,6 +2,7 @@ package com.github.wxiaoqi.security.admin.rest;
import com.github.wxiaoqi.security.admin.biz.*; import com.github.wxiaoqi.security.admin.biz.*;
import com.github.wxiaoqi.security.admin.bo.UserBo; import com.github.wxiaoqi.security.admin.bo.UserBo;
import com.github.wxiaoqi.security.admin.bo.UserStaffBo;
import com.github.wxiaoqi.security.admin.dto.AccountBindDTO; import com.github.wxiaoqi.security.admin.dto.AccountBindDTO;
import com.github.wxiaoqi.security.admin.entity.*; import com.github.wxiaoqi.security.admin.entity.*;
import com.github.wxiaoqi.security.admin.feign.dto.AppUserDTO; import com.github.wxiaoqi.security.admin.feign.dto.AppUserDTO;
...@@ -366,4 +367,9 @@ public class AppUserController extends CommonBaseController{ ...@@ -366,4 +367,9 @@ public class AppUserController extends CommonBaseController{
return appUserLoginBiz.findUserDetailInfo(userBos); return appUserLoginBiz.findUserDetailInfo(userBos);
} }
@ApiOperation("查询全部员工")
@GetMapping("/list_staff")
public List<UserStaffBo> findAllStaffs(){
return userDetailBiz.findAllStaffs();
}
} }
...@@ -13,11 +13,13 @@ import com.github.wxiaoqi.security.auth.client.jwt.UserAuthUtil; ...@@ -13,11 +13,13 @@ import com.github.wxiaoqi.security.auth.client.jwt.UserAuthUtil;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse; import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.process.ResultCode; import com.github.wxiaoqi.security.common.util.process.ResultCode;
import org.apache.commons.beanutils.BeanUtils; import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.List; import java.util.List;
/** /**
...@@ -169,4 +171,9 @@ public class PublicController { ...@@ -169,4 +171,9 @@ public class PublicController {
return ObjectRestResponse.succ(appUserVos); return ObjectRestResponse.succ(appUserVos);
} }
@GetMapping("/getUsersByUserIdList")
ObjectRestResponse<List<AppUserVo>> getByUserIdList(@RequestParam("userIds") List<Integer> userIds){
List<AppUserVo> appUserVos = detailBiz.getUserByUserIdList(userIds);
return ObjectRestResponse.succ(appUserVos);
}
} }
package com.github.wxiaoqi.security.admin.rest; package com.github.wxiaoqi.security.admin.rest;
import com.github.wxiaoqi.security.admin.biz.AppUserSellingWaterBiz; import com.github.wxiaoqi.security.admin.biz.AppUserSellingWaterBiz;
import com.github.wxiaoqi.security.admin.bo.UserStaffBo;
import com.github.wxiaoqi.security.admin.dto.AppUserSellingWaterDTO;
import com.github.wxiaoqi.security.admin.dto.OrderWaterDTO; import com.github.wxiaoqi.security.admin.dto.OrderWaterDTO;
import com.github.wxiaoqi.security.admin.vo.SellingWalletPagVo; import com.github.wxiaoqi.security.admin.vo.SellingWalletPagVo;
import com.github.wxiaoqi.security.auth.client.config.UserAuthConfig; import com.github.wxiaoqi.security.auth.client.config.UserAuthConfig;
...@@ -8,10 +10,13 @@ import com.github.wxiaoqi.security.auth.client.jwt.UserAuthUtil; ...@@ -8,10 +10,13 @@ import com.github.wxiaoqi.security.auth.client.jwt.UserAuthUtil;
import com.github.wxiaoqi.security.auth.common.util.jwt.IJWTInfo; import com.github.wxiaoqi.security.auth.common.util.jwt.IJWTInfo;
import com.github.wxiaoqi.security.common.exception.BaseException; import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse; import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
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.*; import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.util.Date;
import java.util.List;
/** /**
* @author libin * @author libin
...@@ -72,4 +77,13 @@ public class UserSellingWaterController { ...@@ -72,4 +77,13 @@ public class UserSellingWaterController {
throw new BaseException(e); throw new BaseException(e);
} }
} }
@ApiOperation("员工佣金")
@GetMapping("/list_staff_sellerwater")
public List<AppUserSellingWaterDTO> 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);
}
} }
package com.github.wxiaoqi.security.admin.rest.admin;
import com.github.wxiaoqi.security.admin.biz.StaffStatisticsBiz;
import com.github.wxiaoqi.security.admin.dto.StaffStatisticsFindDTO;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
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 com.github.wxiaoqi.security.common.exception.BaseException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Map;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/11/26 16:59
*/
@RestController
@RequestMapping("/staff_statistics")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class StaffStatisticsAdminController {
private final StaffStatisticsBiz staffStatisticsBiz;
@PostMapping("/page")
public ObjectRestResponse<Map<String,Object>> lisetStaffStatisticsWithPage(@RequestBody StaffStatisticsFindDTO staffStatisticsFindDTO){
Map<String,Object> result = staffStatisticsBiz.listStaffStatisticsWithPage(staffStatisticsFindDTO);
return ObjectRestResponse.succ(result);
}
@PostMapping("/export")
public void exportStaffStatistics(@RequestBody StaffStatisticsFindDTO staffStatisticsFindDTO, HttpServletResponse response){
try {
String name = DateTimeFormatter.ofPattern("YYYYMMddHHmmss").format(LocalDateTime.now());
response.setContentType("application/vnd.ms-excel;charset=utf-8");
String filename = String.format("%s-staff-statistics.xlsx",name);
response.setHeader("Content-Disposition","attachment;filename="+ new String(filename.getBytes(), "iso8859-1"));
ServletOutputStream outputStream = response.getOutputStream();
staffStatisticsBiz.exportStaffStistics(staffStatisticsFindDTO, outputStream);
response.setCharacterEncoding("UTF-8");
}catch (Exception ex){
throw new BaseException("导出数据失败");
}
}
}
...@@ -234,5 +234,81 @@ ...@@ -234,5 +234,81 @@
order by l.id ASC order by l.id ASC
</select> </select>
<!--查询非普通用户-->
<select id="selectAllStaffs" resultType="com.github.wxiaoqi.security.admin.bo.UserStaffBo">
select aud.userid as `userId`,aud.realname as `realName`,aud.nickname as `nickName`,aul.username as `phone`,aud.position_id as `postionId`,aup.name as `postionName`,aupt.company_id as `companyId`,aupt.company_name as `companyName`
from `app_user_detail` as `aud` left join `app_user_login` as `aul` on aul.id=aud.userid
left join `app_user_position_temp` as `aupt` on aupt.user_id=aul.id
left join `app_user_position` as `aup` on aup.id=aud.position_id
where <![CDATA[aud.position_id<>6]]> and aud.isdel=0
</select>
<select id="getUserByUserIdList" resultMap="AppUserVoMap">
select
l.im_userid,l.username,l.wx_openid,l.unionid,l.openid,l.status,l.id_number,l.certification_status,d.*,p.name as
jobTitle,buml.name as memberName from app_user_login l
left join app_user_detail d
on d.userid = l.id
left join base_user_member bum
on bum.user_id=l.id
left join (select level, name from base_user_member_level level where isdel = 0) buml
on bum.member_level = buml.level
left join (select id, name from app_user_position where is_del=0) p
on d.position_id=p.id
where l.isdel=0 and
d.userid in
<foreach collection="userIds" item="userId" index="index" open="(" separator="," close=")">
#{userId}
</foreach>
</select>
<select id="findAllStaffsByCompanyIdAndPostionId"
resultType="com.github.wxiaoqi.security.admin.bo.UserStaffBo">
select * from (select aud.userid as `userId`,aud.realname as `realName`,aud.nickname as `nickName`,aul.username as `phone`,aud.position_id
as `postionId`,aup.name as `postionName`,aupt.company_id as `companyId`,aupt.company_name as `companyName` from `app_user_detail` as `aud`
left join `app_user_login` as `aul` on aul.id=aud.userid
left join (select * from `app_user_position_temp` where is_del=0) as `aupt` on aupt.user_id=aul.id
left join `app_user_position` as `aup` on aup.id=aud.position_id where <![CDATA[aud.position_id<>6]]> and aud.isdel=0
<if test="userPostionId!=null">
and aud.`position_id`=#{userPostionId}
</if>
<if test="companyId!=null">
and aupt.`company_id`=#{companyId}
</if>
<if test="userIds!=null and userIds.size>0">
and aud.userid in
<foreach collection="userIds" item="userId" open="(" close=")" separator=",">
#{userId}
</foreach>
</if>) as `saff`
left join (
select auswp.user_id, IFNULL(auswp.upIncome, 0) - IFNULL(auswd.dowIncome, 0) as `sellAmount`
from (select `user_id`, sum(price) as `upIncome`
from `app_user_selling_water`
where <![CDATA[position_id<>6]]>
and status = 0
<if test="startDate!=null and endDate!=null">
and `crt_time` between #{startDate} and #{endDate}
</if>
<if test="startDate!=null and endDate==null">
and <![CDATA[
`crt_time` >=#{startDate}
]]>
</if>
<if test="startDate==null and endDate!=null">
and <![CDATA[
`crt_time` <=#{endDate}
]]>
</if>
group by user_id) as auswp
left join (select `user_id`, sum(price) as `dowIncome`
from `app_user_selling_water`
where <![CDATA[position_id<>6]]>
and status = 1
group by user_id) as auswd
on auswd.user_id = auswp.user_id
) as `sell` on sell.user_id=saff.userId
order by sell.sellAmount desc
</select>
</mapper> </mapper>
\ No newline at end of file
...@@ -26,10 +26,10 @@ FROM ...@@ -26,10 +26,10 @@ FROM
<select id="selectTotalIncomeByUserId" resultType="java.math.BigDecimal"> <select id="selectTotalIncomeByUserId" resultType="java.math.BigDecimal">
SELECT SELECT
( auswu.upIncome - auswd.dowIncome ) AS `income` ( IFNULL(auswu.upIncome,0) - IFNULL(auswd.dowIncome,0) ) AS `income`
FROM FROM
( SELECT IFNULL(SUM( commission ),0) AS upIncome FROM `app_user_selling_water` WHERE STATUS = 0 AND `user_id` = #{userId} ) AS `auswu`, ( SELECT IFNULL(SUM( commission ),0) AS upIncome FROM `app_user_selling_water` WHERE STATUS = 0 AND waiting=1 AND `user_id` = #{userId} ) AS `auswu`,
( SELECT IFNULL(SUM( commission ),0) AS `dowIncome` FROM `app_user_selling_water` WHERE STATUS = 1 AND `user_id` = #{userId} ) AS `auswd`; ( SELECT IFNULL(SUM( commission ),0) AS `dowIncome` FROM `app_user_selling_water` WHERE STATUS = 1 AND waiting=1 AND `user_id` = #{userId} ) AS `auswd`;
</select> </select>
<select id="selectSellerWalterByUserIdAndWating" resultType="com.github.wxiaoqi.security.admin.vo.SellingWalletVo"> <select id="selectSellerWalterByUserIdAndWating" resultType="com.github.wxiaoqi.security.admin.vo.SellingWalletVo">
...@@ -150,4 +150,27 @@ FROM ...@@ -150,4 +150,27 @@ FROM
</if>) AS audd ON audd.userid = ausw.user_id </if>) AS audd ON audd.userid = ausw.user_id
ORDER BY ausw.crt_time DESC ORDER BY ausw.crt_time DESC
</select> </select>
<select id="statisticsStatffSellerWaterByUserIdsAndTime"
resultType="com.github.wxiaoqi.security.admin.dto.AppUserSellingWaterDTO">
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
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
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 `auswd`
on auswd.user_id=auswu.user_id
</select>
</mapper> </mapper>
\ No newline at end of file
package com.xxfc.platform.order.contant.enumerate; package com.xxfc.platform.order.contant.enumerate;
import org.assertj.core.util.Lists;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
public enum DeductionTypeEnum { public enum DeductionTypeEnum {
...@@ -22,19 +26,48 @@ public enum DeductionTypeEnum { ...@@ -22,19 +26,48 @@ public enum DeductionTypeEnum {
* 类型描述 * 类型描述
*/ */
private String desc; 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>(); private static Map<Integer, String> codeAndDesc = new HashMap<Integer, String>();
//Maps.newHashMap();
static{ static {
for(DeductionTypeEnum enumE : DeductionTypeEnum.values()){ for (DeductionTypeEnum enumE : DeductionTypeEnum.values()) {
codeAndDesc.put(enumE.getCode(),enumE.getDesc()); 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){ DeductionTypeEnum(Integer code, String desc) {
this.code=code; this.code = code;
this.desc=desc; this.desc = desc;
} }
public Integer getCode() { public Integer getCode() {
...@@ -53,7 +86,7 @@ public enum DeductionTypeEnum { ...@@ -53,7 +86,7 @@ public enum DeductionTypeEnum {
this.desc = desc; this.desc = desc;
} }
public static Boolean exists(Integer code){ public static Boolean exists(Integer code) {
return codeAndDesc.containsKey(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;
}
package com.xxfc.platform.order.entity;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.*;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/11/25 12:19
*/
@Table(name = "staff_statistics")
@Entity
@Data
@AllArgsConstructor
@NoArgsConstructor
@Api("员工业绩统计")
public class StaffStatistics implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(generator = "JDBC")
private 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;
@Column(name = "week_of_year")
@ApiModelProperty(value = "1周年的第几周--->201922")
protected String weekOfYear;
@ApiModelProperty("员工所属公司id")
@Column(name = "company_id")
private Integer companyId;
@ApiModelProperty("公司名称")
@Column(name = "company_name")
private String companyName;
@ApiModelProperty("员工id")
@Column(name = "user_id")
private Integer userId;
@ApiModelProperty("员工身份id")
@Column(name = "user_postion_id")
private Integer userPostionId;
@ApiModelProperty("员工身份")
@Column(name = "postion_name")
private String postionName;
@ApiModelProperty("租车订单量")
@Column(name = "rent_vehicle_order_num")
private Integer rentVehicleOrderNum;
@ApiModelProperty("租车订单总额(不包含押金,不计免赔金额)")
@Column(name = "rent_vehicle_amount")
private BigDecimal rentVehicleAmount;
@ApiModelProperty("会员订单量")
@Column(name = "member_order_num")
private Integer memberOrderNum;
@ApiModelProperty("会员订单总额")
@Column(name = "member_amount")
private BigDecimal memberAmount;
@ApiModelProperty("旅游订单量")
@Column(name = "travel_order_num")
private Integer travelOrderNum;
@ApiModelProperty("旅游订单总额")
@Column(name = "travel_amount")
private BigDecimal travelAmount;
@ApiModelProperty("销售总额")
@Column(name = "sell_amount")
private BigDecimal sellAmount;
@ApiModelProperty("提成")
@Column(name = "royalty_amount")
private BigDecimal royaltyAmount;
@ApiModelProperty("创建时间")
@Column(name = "crt_time")
private Date crtTime;
}
package com.xxfc.platform.order.feign; package com.xxfc.platform.order.feign;
import com.github.wxiaoqi.security.auth.client.annotation.IgnoreClientToken;
import com.github.wxiaoqi.security.auth.client.annotation.IgnoreUserToken;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse; import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.vo.GoodDataVO; import com.xxfc.platform.order.pojo.dto.OrderDTO;
import com.xxfc.platform.order.entity.BaseOrder;
import com.xxfc.platform.order.pojo.order.OrderPageVO; import com.xxfc.platform.order.pojo.order.OrderPageVO;
import com.xxfc.platform.vehicle.common.RestResponse;
import com.xxfc.platform.vehicle.entity.*;
import com.xxfc.platform.vehicle.pojo.*;
import com.xxfc.platform.vehicle.pojo.vo.AccompanyingItemVo;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Set;
/** /**
* Created by ace on 2017/9/15. * Created by ace on 2017/9/15.
...@@ -25,4 +23,8 @@ public interface OrderFeign { ...@@ -25,4 +23,8 @@ public interface OrderFeign {
@GetMapping("/count/list") @GetMapping("/count/list")
public ObjectRestResponse<List<OrderPageVO>> getOrderList(@RequestParam("dateTime")Long dateTime, @RequestParam("type")Integer type, @RequestParam("status")Integer status); public ObjectRestResponse<List<OrderPageVO>> getOrderList(@RequestParam("dateTime")Long dateTime, @RequestParam("type")Integer type, @RequestParam("status")Integer status);
@GetMapping(value = "/count/basebase/findByOrderIds")
public ObjectRestResponse<List<OrderDTO>> findOrdersByorderId(@RequestParam(value = "orderIds") List<Integer> orderIds);
} }
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.bo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.math.BigDecimal;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/11/25 12:44
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class StaffStatisticsTotalBo {
private Integer staffNum;
private BigDecimal totalSellAmount;
private BigDecimal totalRoyaltyAmount;
public Integer getStaffNum() {
return this.staffNum==null?0:staffNum;
}
public BigDecimal getTotalSellAmount() {
return this.totalSellAmount==null?BigDecimal.ZERO:totalSellAmount;
}
public BigDecimal getTotalRoyaltyAmount() {
return this.totalRoyaltyAmount==null?BigDecimal.ZERO:totalRoyaltyAmount;
}
}
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();
}
}
package com.xxfc.platform.order.pojo.dto;
import com.github.wxiaoqi.security.common.vo.PageParam;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
import java.util.List;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/11/25 12:43
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class StaffStatisticsFindDTO extends PageParam {
private Date startDate;
private Date endDate;
private String companyName;
private Integer userPostionId;
private List<Integer> companyIds;
}
package com.xxfc.platform.order.pojo.vo;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/11/25 12:44
*/
@Data
@Builder(toBuilder = true)
@AllArgsConstructor
@NoArgsConstructor
public class StaffStatisticsVo implements Serializable {
private static final long serialVersionUID = 1L;
private String name ;
private List<String> companyNames;
private List<String> postionNames;
private String phone;
private BigDecimal sellAmount = BigDecimal.ZERO;
private BigDecimal royaltyAmount = BigDecimal.ZERO;
private Integer memberOrderNum = 0;
private BigDecimal memberAmount = BigDecimal.ZERO;
private Integer rentVehicleOrderNum = 0;
private BigDecimal rentVehicleAmount = BigDecimal.ZERO;
private Integer travelOrderNum = 0;
private BigDecimal travelAmount = BigDecimal.ZERO;
}
...@@ -30,6 +30,7 @@ import com.xxfc.platform.order.pojo.account.OrderAccountDetail; ...@@ -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.calculate.InProgressVO;
import com.xxfc.platform.order.pojo.dto.MemberOrderBo; import com.xxfc.platform.order.pojo.dto.MemberOrderBo;
import com.xxfc.platform.order.pojo.dto.MemberOrderFindDTO; 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.mq.OrderMQDTO;
import com.xxfc.platform.order.pojo.order.OrderListVo; import com.xxfc.platform.order.pojo.order.OrderListVo;
import com.xxfc.platform.order.pojo.order.OrderPageVO; import com.xxfc.platform.order.pojo.order.OrderPageVO;
...@@ -53,6 +54,7 @@ import com.xxfc.platform.vehicle.pojo.CompanyDetail; ...@@ -53,6 +54,7 @@ import com.xxfc.platform.vehicle.pojo.CompanyDetail;
import com.xxfc.platform.vehicle.util.DistanceUtil; import com.xxfc.platform.vehicle.util.DistanceUtil;
import lombok.Data; import lombok.Data;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.joda.time.DateTime; import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat; import org.joda.time.format.DateTimeFormat;
...@@ -887,6 +889,7 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper, BaseOrder> implements ...@@ -887,6 +889,7 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper, BaseOrder> implements
return userFeign; return userFeign;
} }
/** /**
* 订单查询类 * 订单查询类
*/ */
...@@ -909,4 +912,18 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper, BaseOrder> implements ...@@ -909,4 +912,18 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper, BaseOrder> implements
return Lists.newArrayList(); 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<OrderDTO> selectBaeOrderByOrderIds(List<Integer> orderIds) {
List<OrderDTO> orderDTOList = mapper.selectBaeOrderByOrderIds(orderIds);
return CollectionUtils.isNotEmpty(orderDTOList)?Collections.EMPTY_LIST:orderDTOList;
}
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.*; ...@@ -18,6 +18,7 @@ import com.xxfc.platform.order.entity.*;
import com.xxfc.platform.order.mapper.OrderAccountMapper; import com.xxfc.platform.order.mapper.OrderAccountMapper;
import com.xxfc.platform.order.pojo.DedDetailDTO; import com.xxfc.platform.order.pojo.DedDetailDTO;
import com.xxfc.platform.order.pojo.Term; 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.OrderAccountDTO;
import com.xxfc.platform.order.pojo.account.OrderAccountDeduction; import com.xxfc.platform.order.pojo.account.OrderAccountDeduction;
import com.xxfc.platform.order.pojo.account.OrderAccountDetail; import com.xxfc.platform.order.pojo.account.OrderAccountDetail;
...@@ -31,6 +32,7 @@ import com.xxfc.platform.universal.entity.Dictionary; ...@@ -31,6 +32,7 @@ import com.xxfc.platform.universal.entity.Dictionary;
import com.xxfc.platform.universal.feign.ThirdFeign; import com.xxfc.platform.universal.feign.ThirdFeign;
import com.xxfc.platform.universal.vo.OrderRefundVo; import com.xxfc.platform.universal.vo.OrderRefundVo;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.jexl2.MapContext; import org.apache.commons.jexl2.MapContext;
import org.mockito.internal.util.collections.Sets; import org.mockito.internal.util.collections.Sets;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -38,9 +40,7 @@ import org.springframework.stereotype.Service; ...@@ -38,9 +40,7 @@ import org.springframework.stereotype.Service;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.util.List; import java.util.*;
import java.util.Map;
import java.util.Set;
import static com.github.wxiaoqi.security.common.constant.CommonConstants.SYS_FALSE; import static com.github.wxiaoqi.security.common.constant.CommonConstants.SYS_FALSE;
import static com.github.wxiaoqi.security.common.constant.CommonConstants.SYS_TRUE; import static com.github.wxiaoqi.security.common.constant.CommonConstants.SYS_TRUE;
...@@ -649,4 +649,26 @@ public class OrderAccountBiz extends BaseBiz<OrderAccountMapper,OrderAccount> { ...@@ -649,4 +649,26 @@ public class OrderAccountBiz extends BaseBiz<OrderAccountMapper,OrderAccount> {
orderMsgBiz.handelMsgDeposit(orvd, baseOrder, userFeign.userDetailById(baseOrder.getUserId()).getData()); 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
...@@ -22,7 +22,7 @@ import java.util.Enumeration; ...@@ -22,7 +22,7 @@ import java.util.Enumeration;
* @see FeignHeadConfiguration * @see FeignHeadConfiguration
* @since JDK1.8 * @since JDK1.8
*/ */
@Configuration //@Configuration
@Slf4j @Slf4j
public class FeignHeadConfiguration { public class FeignHeadConfiguration {
......
package com.xxfc.platform.order.jobhandler;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import com.github.wxiaoqi.security.admin.entity.AppUserPosition;
import com.github.wxiaoqi.security.admin.feign.UserFeign;
import com.github.wxiaoqi.security.admin.vo.WalletPostionVo;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
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.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @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;
private final UserFeign userFeign;
@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();
ObjectRestResponse<List<WalletPostionVo>> response = userFeign.findAllPostions();
Map<Integer, String> postionMap = response.getData().stream().collect(Collectors.toMap(WalletPostionVo::getId, WalletPostionVo::getName));
staffStatisticsBiz.staffStatisticsJob(startDate,endDate,companyMap,postionMap);
return ReturnT.SUCCESS;
}
}
...@@ -4,10 +4,13 @@ import com.xxfc.platform.order.entity.BaseOrder; ...@@ -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.bg.BgOrderListVo;
import com.xxfc.platform.order.pojo.dto.MemberOrderBo; import com.xxfc.platform.order.pojo.dto.MemberOrderBo;
import com.xxfc.platform.order.pojo.dto.MemberOrderFindDTO; 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.OrderListVo;
import com.xxfc.platform.order.pojo.order.OrderPageVO; import com.xxfc.platform.order.pojo.order.OrderPageVO;
import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.common.Mapper; import tk.mybatis.mapper.common.Mapper;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -38,5 +41,10 @@ public interface BaseOrderMapper extends Mapper<BaseOrder> { ...@@ -38,5 +41,10 @@ public interface BaseOrderMapper extends Mapper<BaseOrder> {
public List<BgOrderListVo> getAllOrderList(Map<String, Object> paramMap); 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);
List<OrderDTO> selectBaeOrderByOrderIds(@Param("orderIds") List<Integer> orderIds);
} }
...@@ -2,10 +2,12 @@ package com.xxfc.platform.order.mapper; ...@@ -2,10 +2,12 @@ package com.xxfc.platform.order.mapper;
import com.xxfc.platform.order.entity.OrderAccount; import com.xxfc.platform.order.entity.OrderAccount;
import com.xxfc.platform.order.pojo.Term; 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.OrderAccountDTO;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.common.Mapper; import tk.mybatis.mapper.common.Mapper;
import java.util.Date;
import java.util.List; import java.util.List;
...@@ -19,4 +21,12 @@ import java.util.List; ...@@ -19,4 +21,12 @@ import java.util.List;
public interface OrderAccountMapper extends Mapper<OrderAccount> { public interface OrderAccountMapper extends Mapper<OrderAccount> {
List<OrderAccountDTO> getOrderAccountByOrderType(Term term); 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);
} }
package com.xxfc.platform.order.mapper;
import com.xxfc.platform.order.entity.StaffStatistics;
import com.xxfc.platform.order.pojo.bo.StaffStatisticsTotalBo;
import com.xxfc.platform.order.pojo.dto.StaffStatisticsFindDTO;
import tk.mybatis.mapper.additional.insert.InsertListMapper;
import tk.mybatis.mapper.common.Mapper;
import java.util.List;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/11/25 12:37
*/
public interface StaffStatisticsMapper extends Mapper<StaffStatistics>, InsertListMapper<StaffStatistics> {
StaffStatisticsTotalBo statistics(StaffStatisticsFindDTO staffStatisticsFindDTO);
List<StaffStatistics> selectStaffStatistics(StaffStatisticsFindDTO staffStatisticsFindDTO);
}
...@@ -24,6 +24,7 @@ import com.xxfc.platform.order.entity.*; ...@@ -24,6 +24,7 @@ import com.xxfc.platform.order.entity.*;
import com.xxfc.platform.order.mqhandler.RabbitProduct; import com.xxfc.platform.order.mqhandler.RabbitProduct;
import com.xxfc.platform.order.pojo.account.OrderAccountDeduction; import com.xxfc.platform.order.pojo.account.OrderAccountDeduction;
import com.xxfc.platform.order.pojo.account.OrderAccountDetail; import com.xxfc.platform.order.pojo.account.OrderAccountDetail;
import com.xxfc.platform.order.pojo.dto.OrderDTO;
import com.xxfc.platform.order.pojo.mq.OrderMQDTO; import com.xxfc.platform.order.pojo.mq.OrderMQDTO;
import com.xxfc.platform.order.pojo.order.CancelOrderDTO; import com.xxfc.platform.order.pojo.order.CancelOrderDTO;
import com.xxfc.platform.order.pojo.order.OrderAboutParamDTO; import com.xxfc.platform.order.pojo.order.OrderAboutParamDTO;
...@@ -473,4 +474,12 @@ public class BaseOrderController extends CommonBaseController implements UserRes ...@@ -473,4 +474,12 @@ public class BaseOrderController extends CommonBaseController implements UserRes
return ObjectRestResponse.succ(); return ObjectRestResponse.succ();
} }
@RequestMapping(value = "/basebase/aaa", method = RequestMethod.GET)
@IgnoreClientToken
@IgnoreUserToken
public ObjectRestResponse<List<OrderDTO>> findOrdersByorderId(@RequestParam(value = "orderIds") String orderIds){
return ObjectRestResponse.succ();
//ObjectRestResponse.succ(baseOrderBiz.selectBaeOrderByOrderIds(orderIds));
}
} }
package com.xxfc.platform.order.rest.background; package com.xxfc.platform.order.rest.background;
import com.github.wxiaoqi.security.auth.client.annotation.IgnoreClientToken;
import com.github.wxiaoqi.security.auth.client.annotation.IgnoreUserToken;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse; import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.xxfc.platform.order.biz.BaseOrderBiz;
import com.xxfc.platform.order.biz.rpc.OrderListBiz; import com.xxfc.platform.order.biz.rpc.OrderListBiz;
import com.xxfc.platform.order.pojo.dto.OrderDTO;
import com.xxfc.platform.order.pojo.order.OrderPageVO; import com.xxfc.platform.order.pojo.order.OrderPageVO;
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.*;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List; import java.util.List;
...@@ -18,9 +19,18 @@ public class OrderListController { ...@@ -18,9 +19,18 @@ public class OrderListController {
@Autowired @Autowired
OrderListBiz orderListBiz; OrderListBiz orderListBiz;
@Autowired
private BaseOrderBiz baseOrderBiz;
@GetMapping("/list") @GetMapping("/list")
public ObjectRestResponse<List<OrderPageVO>> getOrderList(@RequestParam("dateTime")Long dateTime, @RequestParam("type")Integer type, @RequestParam("status")Integer status) { public ObjectRestResponse<List<OrderPageVO>> getOrderList(@RequestParam("dateTime")Long dateTime, @RequestParam("type")Integer type, @RequestParam("status")Integer status) {
return orderListBiz.getOrderList(dateTime, type, status); return orderListBiz.getOrderList(dateTime, type, status);
} }
@GetMapping(value = "/basebase/findByOrderIds")
@IgnoreClientToken
@IgnoreUserToken
public ObjectRestResponse<List<OrderDTO>> findOrdersByorderId(@RequestParam(value = "orderIds") List<Integer> orderIds){
return ObjectRestResponse.succ(baseOrderBiz.selectBaeOrderByOrderIds(orderIds));
}
} }
package com.xxfc.platform.order.rest.background;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.xxfc.platform.order.biz.StaffStatisticsBiz;
import com.xxfc.platform.order.pojo.dto.StaffStatisticsFindDTO;
import com.xxfc.platform.order.pojo.bo.StaffStatisticsTotalBo;
import com.xxfc.platform.order.pojo.vo.StaffStatisticsVo;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/11/25 12:39
*/
@RestController
@RequestMapping("/admin/staff_statistics")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class StaffStatisticsAdminController {
private final StaffStatisticsBiz staffStatisticsBiz;
@PostMapping("/total_statistics")
public ObjectRestResponse<StaffStatisticsTotalBo> staffStatisticsWithTotal(@RequestBody StaffStatisticsFindDTO staffStatisticsFindDTO) {
StaffStatisticsTotalBo staffStatisticsTotalVo = staffStatisticsBiz.staffStatisticsWithTotal(staffStatisticsFindDTO);
return ObjectRestResponse.succ(staffStatisticsTotalVo);
}
@PostMapping("/page")
public ObjectRestResponse<PageDataVO<StaffStatisticsVo>> staffStatisticsWithPage(@RequestBody StaffStatisticsFindDTO staffStatisticsFindDTO) {
PageDataVO<StaffStatisticsVo> pageDataVO = staffStatisticsBiz.staffStatisticsWithPage(staffStatisticsFindDTO);
return ObjectRestResponse.succ(pageDataVO);
}
}
...@@ -410,4 +410,33 @@ ...@@ -410,4 +410,33 @@
) AS `omd` ON omd.order_id=bo.id ) AS `omd` ON omd.order_id=bo.id
ORDER BY bo.`creatTime` DESC ORDER BY bo.`creatTime` DESC
</select> </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>
<select id="selectBaeOrderByOrderIds" resultType="com.xxfc.platform.order.pojo.dto.OrderDTO">
select `id`,`parent_user_company_id` as `companyId` from `base_order` where id in
<foreach collection="orderIds" item="orderId" open="(" close=")" separator=",">
#{orderId}
</foreach>
</select>
</mapper> </mapper>
\ No newline at end of file
...@@ -51,4 +51,57 @@ ...@@ -51,4 +51,57 @@
</if> </if>
</select> </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> </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.StaffStatisticsMapper">
<!-- 可根据自己的需求,是否要使用 -->
<resultMap type="com.xxfc.platform.order.entity.StaffStatistics" id="staffstatisticsMap">
<result property="id" column="id"/>
<result property="year" column="year"/>
<result property="month" column="month"/>
<result property="date" column="date"/>
<result property="weekOfYear" column="week_of_year"/>
<result property="companyId" column="company_id"/>
<result property="companyName" column="company_name"/>
<result property="userId" column="user_id"/>
<result property="userPostionId" column="user_postion_id"/>
<result property="postionName" column="postion_name"/>
<result property="rentVehicleOrderNum" column="rent_vehicle_order_num"/>
<result property="rentVehicleAmount" column="rent_vehicle_amount"/>
<result property="travelOrderNum" column="travel_order_num"/>
<result property="travelAmount" column="travel_amount"/>
<result property="memberOrderNum" column="member_order_num"/>
<result property="memberAmount" column="member_amount"/>
<result property="sellAmount" column="sell_amount"/>
<result property="royaltyAmount" column="royalty_amount"/>
</resultMap>
<select id="statistics" resultType="com.xxfc.platform.order.pojo.bo.StaffStatisticsTotalBo">
select count(`user_id`) as `staffNum`,sum(`sell_amount`) as `totalSellAmount`,sum(`royalty_amount`) as `totalRoyaltyAmount` from `staff_statistics`
</select>
<select id="selectStaffStatistics" resultMap="staffstatisticsMap">
select * from `staff_statistics` where 1=1
<if test="userPostionId!=null">
and `user_postion_id`=#{userPostionId}
</if>
<if test="companyName!=null and companyName!=''">
and `company_name` like CONCAT('%',#{companyName},'%')
</if>
<if test="companyIds!=null and companyIds.size!=0">
and `company_id` IN
<foreach collection="companyIds" item="compnayId" separator="," open="(" close=")">
#{compnayId}
</foreach>
</if>
<if test="startDate!=null and endDate!=null">
and `date` between #{startDate} and #{endDate}
</if>
<if test="startDate!=null and endDate==null">
and <![CDATA[
`date` >=#{startDate}
]]>
</if>
<if test="startDate==null and endDate!=null">
and <![CDATA[
`date` <=#{endDate}
]]>
</if>
</select>
</mapper>
\ No newline at end of file
...@@ -2,7 +2,9 @@ import com.xxfc.platform.order.OrderApplication; ...@@ -2,7 +2,9 @@ import com.xxfc.platform.order.OrderApplication;
import com.xxfc.platform.order.biz.DailyOrderStatisticsBiz; import com.xxfc.platform.order.biz.DailyOrderStatisticsBiz;
import com.xxfc.platform.order.biz.OrderStatisticsBiz; import com.xxfc.platform.order.biz.OrderStatisticsBiz;
import com.xxfc.platform.order.jobhandler.BaseOrderStatisticsJobHandler; import com.xxfc.platform.order.jobhandler.BaseOrderStatisticsJobHandler;
import com.xxfc.platform.order.jobhandler.SaffStatisticsJobHandler;
import com.xxfc.platform.order.pojo.HomePageOrderData; import com.xxfc.platform.order.pojo.HomePageOrderData;
import lombok.SneakyThrows;
import org.joda.time.DateTime; import org.joda.time.DateTime;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
...@@ -33,6 +35,9 @@ public class ServiceTest { ...@@ -33,6 +35,9 @@ public class ServiceTest {
@Autowired @Autowired
private BaseOrderStatisticsJobHandler handler; private BaseOrderStatisticsJobHandler handler;
@Autowired
private SaffStatisticsJobHandler statisticsJobHandler;
@Test @Test
public void testSchedu(){ public void testSchedu(){
...@@ -67,8 +72,8 @@ public class ServiceTest { ...@@ -67,8 +72,8 @@ public class ServiceTest {
@Test @Test
public void test4(){ public void test4(){
HomePageOrderData totalOrder = statisticsBiz.getTotalOrder(null,null); // HomePageOrderData totalOrder = statisticsBiz.getTotalOrder(null);
System.out.println(totalOrder); // System.out.println(totalOrder);
} }
...@@ -77,5 +82,10 @@ public class ServiceTest { ...@@ -77,5 +82,10 @@ public class ServiceTest {
handler.execute("2019-09-29"); handler.execute("2019-09-29");
} }
@Test
@SneakyThrows
public void testStaffStatisticsJob(){
statisticsJobHandler.execute("");
}
} }
...@@ -200,4 +200,7 @@ public interface VehicleFeign { ...@@ -200,4 +200,7 @@ public interface VehicleFeign {
@RequestParam(value = "endDate") Long endDate, @RequestParam(value = "endDate") Long endDate,
@RequestParam(value = "vehicleModelId") Integer vehicleModelId, @RequestParam(value = "vehicleModelId") Integer vehicleModelId,
@RequestParam(value = "userId") Integer userId); @RequestParam(value = "userId") Integer userId);
@GetMapping("/branchCompany/company_info")
Map<Integer, String> findCompanyMap();
} }
...@@ -432,4 +432,13 @@ public class BranchCompanyBiz extends BaseBiz<BranchCompanyMapper, BranchCompany ...@@ -432,4 +432,13 @@ public class BranchCompanyBiz extends BaseBiz<BranchCompanyMapper, BranchCompany
return ObjectRestResponse.succ(); 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> { ...@@ -227,4 +227,9 @@ public class BranchCompanyController extends BaseController<BranchCompanyBiz> {
return RestResponse.suc(baseBiz.getCompanyIds(dataZone,dataCompany)); 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