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; ...@@ -14,6 +14,7 @@ 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;
...@@ -163,6 +164,8 @@ public interface UserFeign { ...@@ -163,6 +164,8 @@ public interface UserFeign {
List<UserStaffBo> findAllStaffs(); List<UserStaffBo> findAllStaffs();
@GetMapping("/sellingwater/list_staff_sellerwater") @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 ...@@ -463,8 +463,8 @@ public class AppUserSellingWaterBiz extends BaseBiz<AppUserSellingWaterMapper, A
return pageDataVO; return pageDataVO;
} }
public List<UserStaffBo> findStatffSellerWaterByUserIds(List<Integer> userIds) { public List<UserStaffBo> findStatffSellerWaterByUserIdsAndTime(List<Integer> userIds,Date startDate,Date endDate) {
List<UserStaffBo> userStaffBos = mapper.statisticsStatffSellerWaterByUserIds(userIds); List<UserStaffBo> userStaffBos = mapper.statisticsStatffSellerWaterByUserIdsAndTime(userIds,startDate.getTime(),endDate.getTime());
return CollectionUtils.isEmpty(userStaffBos)?Collections.EMPTY_LIST:userStaffBos; return CollectionUtils.isEmpty(userStaffBos)?Collections.EMPTY_LIST:userStaffBos;
} }
......
...@@ -7,7 +7,6 @@ import com.github.wxiaoqi.security.admin.dto.UserSellingWaterFindDTO; ...@@ -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.entity.AppUserSellingWater;
import com.github.wxiaoqi.security.admin.vo.SellingWalletVo; import com.github.wxiaoqi.security.admin.vo.SellingWalletVo;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.springframework.web.bind.annotation.RequestParam;
import tk.mybatis.mapper.common.Mapper; import tk.mybatis.mapper.common.Mapper;
import java.math.BigDecimal; import java.math.BigDecimal;
...@@ -30,5 +29,7 @@ public interface AppUserSellingWaterMapper extends Mapper<AppUserSellingWater> { ...@@ -30,5 +29,7 @@ public interface AppUserSellingWaterMapper extends Mapper<AppUserSellingWater> {
List<UserSellingWaterAdminDTO> selectSellingWaterPage(UserSellingWaterFindDTO userSellingWaterFindDTO); 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; ...@@ -14,6 +14,7 @@ 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; import java.util.List;
/** /**
...@@ -78,8 +79,10 @@ public class UserSellingWaterController { ...@@ -78,8 +79,10 @@ public class UserSellingWaterController {
@ApiOperation("员工佣金") @ApiOperation("员工佣金")
@GetMapping("/list_staff_sellerwater") @GetMapping("/list_staff_sellerwater")
public List<UserStaffBo> findStaffSellerWater(@RequestParam("userIds") List<Integer> userIds){ public List<UserStaffBo> findStaffSellerWater(@RequestParam(value = "userIds",required = false) List<Integer> userIds,
return appUserSellingWaterBiz.findStatffSellerWaterByUserIds(userIds); @RequestParam(value = "startDate") Date startDate,
@RequestParam(value = "endDate") Date endDate){
return appUserSellingWaterBiz.findStatffSellerWaterByUserIdsAndTime(userIds,startDate,endDate);
} }
} }
...@@ -151,18 +151,22 @@ FROM ...@@ -151,18 +151,22 @@ FROM
ORDER BY ausw.crt_time DESC ORDER BY ausw.crt_time DESC
</select> </select>
<select id="statisticsStatffSellerWaterByUserIds" <select id="statisticsStatffSellerWaterByUserIdsAndTime"
resultType="com.github.wxiaoqi.security.admin.bo.UserStaffBo"> resultType="com.github.wxiaoqi.security.admin.bo.UserStaffBo">
SELECT SELECT
`auswu`.user_id, ( IFNULL(auswu.upIncome,0) - IFNULL(auswd.dowIncome,0) ) AS `commission` `auswu`.user_id, ( IFNULL(auswu.upIncome,0) - IFNULL(auswd.dowIncome,0) ) AS `commission`
FROM 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=","> AND `user_id` IN <foreach collection="userIds" item="userId" open="(" close=")" separator=",">
#{userId} #{userId}
</foreach> </foreach>
</if> group by user_id) AS `auswu` </if> group by user_id) AS `auswu`
left join 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=","> AND `user_id` IN <foreach collection="userIds" item="userId" open="(" close=")" separator=",">
#{userId} #{userId}
</foreach> </foreach>
......
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;
}
...@@ -96,4 +96,8 @@ public class StaffStatistics implements Serializable { ...@@ -96,4 +96,8 @@ public class StaffStatistics implements Serializable {
@ApiModelProperty("提成") @ApiModelProperty("提成")
@Column(name = "royalty_amount") @Column(name = "royalty_amount")
private BigDecimal royaltyAmount; 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; ...@@ -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;
...@@ -908,4 +910,13 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper, BaseOrder> implements ...@@ -908,4 +910,13 @@ 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<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
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; ...@@ -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;
...@@ -36,7 +39,8 @@ public interface BaseOrderMapper extends Mapper<BaseOrder> { ...@@ -36,7 +39,8 @@ public interface BaseOrderMapper extends Mapper<BaseOrder> {
List<MemberOrderBo> findMemberOrders(MemberOrderFindDTO memberOrderFindDTO); 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; ...@@ -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);
} }
...@@ -410,4 +410,26 @@ ...@@ -410,4 +410,26 @@
) 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>
</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
...@@ -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(){
...@@ -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