Commit 8b9d8fbe authored by zuoyh's avatar zuoyh

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

parents 318d7a63 fcc0acde
......@@ -15,9 +15,9 @@ import java.util.stream.Collectors;
* @data 2019/11/13 17:23
*/
public enum LevelEnum {
DIAMOND(3, "钻石"),
GOLD(2, "黄金"),
GENERAL(1, "普通");
DIAMOND(3, "钻石会员"),
GOLD(2, "黄金会员"),
GENERAL(1, "普通会员");
LevelEnum(Integer level, String desc) {
this.level = level;
......
......@@ -26,4 +26,8 @@ public class WalletCathFindDTO extends PageParam {
private Long startTime;
private Long endTime;
/**
* 提现方式 1:线下自动 2:线下手动 3:线上自动
*/
private Integer withdrawWay;
}
......@@ -56,6 +56,6 @@ public class WalletCathListDTO {
private String accountName;
@ApiModelProperty(value = "线下提现方式 1:自动 2:手动")
private Integer offlineWay;
@ApiModelProperty(value = "提现方式 1:线下自动 2:线下手动 3:线上自动")
private Integer withdrawWay;
}
......@@ -134,9 +134,9 @@ public class MyWalletCath implements Serializable {
@Column(name = "account_name")
private String accountName;
@Column(name = "offline_way")
@ApiModelProperty(value = "线下提现方式 1:自动 2:手动")
private Integer offlineWay;
@Column(name = "withdraw_way")
@ApiModelProperty(value = "提现方式 1:线下自动 2:线下手动 3:线上自动")
private Integer withdrawWay;
@Column(name = "real_reason")
private String realReason;
......
......@@ -164,11 +164,6 @@ public interface UserFeign {
@RequestParam(value = "isSuccess") Boolean isSuccess,
@RequestParam(value = "realReason",required = false) String realReason);
@GetMapping("/app/user/collect/exist")
boolean isCollectionByTypeAndTypeId(@RequestParam("userId") Integer userId,
@RequestParam(value = "type") int type,
@RequestParam("id") Integer typId);
/**
* 通过公司id,获取员工的下级用户id
* @param parentCompanyId
......@@ -193,4 +188,11 @@ public interface UserFeign {
@GetMapping("/public/getUsersByUserIdList")
ObjectRestResponse<List<AppUserVo>> getByUserIdList(@RequestParam("userIds") List<Integer> userIds);
@GetMapping("/app/user/collect/exist")
boolean isCollectionByTypeAndTypeId(@RequestParam("userId") Integer userId,
@RequestParam(value = "type") int type,
@RequestParam("id") Integer typId);
@GetMapping("/app/user/list_user_info")
List<UserBo> findUserDetailUserIds(@RequestParam(value = "userIds",required = false) List<Integer> userIds);
}
......@@ -52,6 +52,6 @@ public class WalletCathAdminVo {
private String accountName;
@ApiModelProperty(value = "线下提现方式 1:自动 2:手动")
private Integer offlineWay;
@ApiModelProperty(value = "提现方式 1:线下自动 2:线下手动 3:线上自动")
private Integer withdrawWay;
}
......@@ -241,4 +241,9 @@ public class AppUserDetailBiz extends BaseBiz<AppUserDetailMapper, AppUserDetail
List<AppUserDetail> appUserDetails = mapper.selectAllWithNoProviinceCode();
return CollectionUtils.isEmpty(appUserDetails)?Collections.EMPTY_LIST:appUserDetails;
}
public List<UserBo> findUserDetailByUserIds(List<Integer> userIds) {
List<UserBo> userBoList = mapper.selectUserByUserIds(userIds);
return CollectionUtils.isEmpty(userBoList)?Collections.EMPTY_LIST:userBoList;
}
}
......@@ -3,9 +3,8 @@ package com.github.wxiaoqi.security.admin.biz;
import com.ace.cache.annotation.Cache;
import com.ace.cache.annotation.CacheClear;
import com.alibaba.fastjson.JSONObject;
import com.github.wxiaoqi.security.admin.dto.AccountBindDTO;
import com.github.wxiaoqi.security.admin.bo.UserBo;
import com.github.wxiaoqi.security.admin.entity.AppUserDetail;
import com.github.wxiaoqi.security.admin.dto.AccountBindDTO;
import com.github.wxiaoqi.security.admin.entity.AppUserLogin;
import com.github.wxiaoqi.security.admin.entity.AppUserPositionTemp;
import com.github.wxiaoqi.security.admin.entity.AppUserRelation;
......@@ -13,9 +12,7 @@ import com.github.wxiaoqi.security.admin.mapper.AppUserLoginMapper;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.github.wxiaoqi.security.common.config.rabbit.RabbitConstant;
import com.github.wxiaoqi.security.common.constant.UserConstant;
import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.xxfc.platform.im.utils.StringUtil;
import com.xxfc.platform.universal.entity.IdInformation;
import com.xxfc.platform.universal.feign.MQSenderFeign;
import com.xxfc.platform.universal.feign.ThirdFeign;
......@@ -183,7 +180,7 @@ public class AppUserLoginBiz extends BaseBiz<AppUserLoginMapper, AppUserLogin> {
public AppUserLogin checkeUserLogin(String username) {
Example example = new Example(AppUserLogin.class);
example.createCriteria().andEqualTo("username", username).andEqualTo("isdel", 0).andEqualTo("status", 0);
example.createCriteria().andEqualTo("username", username).andEqualTo("isdel", 0);
List<AppUserLogin> userLoginList = mapper.selectByExample(example);
if (userLoginList != null && userLoginList.size() != 0) {
return userLoginList.get(0);
......
package com.github.wxiaoqi.security.admin.biz;
import com.github.wxiaoqi.security.admin.bo.UserIncomeBo;
import com.github.wxiaoqi.security.admin.bo.UserStaffBo;
import com.github.wxiaoqi.security.admin.dto.*;
import com.github.wxiaoqi.security.admin.entity.*;
import com.github.wxiaoqi.security.admin.entity.AppUserRelation;
import com.github.wxiaoqi.security.admin.vo.SellingWalletVo;
import com.github.wxiaoqi.security.admin.mapper.AppUserSellingWaterMapper;
import com.github.wxiaoqi.security.admin.vo.SellingWalletPagVo;
import com.github.wxiaoqi.security.admin.vo.SellingWalletVo;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.github.wxiaoqi.security.common.vo.PageDataVO;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.github.wxiaoqi.security.admin.mapper.AppUserSellingWaterMapper;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import tk.mybatis.mapper.entity.Example;
......@@ -352,7 +350,7 @@ public class AppUserSellingWaterBiz extends BaseBiz<AppUserSellingWaterMapper, A
sellingWaterVo = new SellingWalletVo();
BeanUtils.copyProperties(appUserSellingWater, sellingWaterVo);
sellingWaterVo.setUsername(userIdAndAppUserLoginMap.get(appUserSellingWater.getSourceId()).getUsername());
sellingWaterVo.setUsername(userIdAndAppUserLoginMap.get(appUserSellingWater.getSourceId())==null?"":userIdAndAppUserLoginMap.get(appUserSellingWater.getSourceId()).getUsername());
if (userIdAndAppUserDetailMap != null) {
AppUserDetail appUserDetail = userIdAndAppUserDetailMap.get(appUserSellingWater.getSourceId());
sellingWaterVo.setNickName(appUserDetail == null ? "" : appUserDetail.getNickname());
......
......@@ -21,6 +21,7 @@ import com.github.wxiaoqi.security.common.util.OrderUtil;
import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.xxfc.platform.app.entity.vo.WithDrawRuleVo;
import com.xxfc.platform.app.enumconstant.WithDrawWayEnum;
import com.xxfc.platform.app.feign.ConfigFeign;
import com.xxfc.platform.universal.feign.ThirdFeign;
import com.xxfc.platform.universal.vo.FundPayVo;
......@@ -100,9 +101,6 @@ public class MyWalletBiz extends BaseBiz<MyWalletMapper, MyWallet> implements In
private DateTimeFormatter dateTimeFormatter;
private static final Integer WITHDRAW_ONLINE_WAY = 1;
private static final Integer WITHDRAW_OFFLINE_WAY = 2;
private BCryptPasswordEncoder encoder = new BCryptPasswordEncoder(12);
......@@ -347,8 +345,10 @@ public class MyWalletBiz extends BaseBiz<MyWalletMapper, MyWallet> implements In
walletCath.setAccountName(applyCathVo.getAccountName());
walletCath.setAccountNumber(accountNumber);
walletCath.setAmount(amount);
//手续费
walletCath.setCommission(commission);
walletCath.setRealAmount(realAmount);
walletCath.setWithdrawWay(withdrawWay);
myWalletCathBiz.insertSelective(walletCath);
//提现金额
BigDecimal withdrawals = realAmount.add(commission);
......@@ -362,7 +362,7 @@ public class MyWalletBiz extends BaseBiz<MyWalletMapper, MyWallet> implements In
myWallet.setVersion(sumDto.getVersion());
mapper.updMyWater(myWallet);
//线上自动提现
if (WITHDRAW_ONLINE_WAY.equals(withdrawWay)) {
if (WithDrawWayEnum.WITHDRAW_ONLINE_WAY.getCode() == withdrawWay) {
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
String host = StringUtils.defaultIfBlank(request.getHeader("userHost"), ClientUtil.getClientIp(request));
FundPayVo fundPayVo = FundPayVo.builder()
......
......@@ -101,12 +101,7 @@ public class MyWalletCathBiz extends BaseBiz<MyWalletCathMapper, MyWalletCath> {
PageDataVO<WalletCathListDTO> walletCathListDTOPage = PageDataVO.pageInfo(walletCathFindDTO.getPage(),
walletCathFindDTO.getLimit(),
() -> mapper.selectByUserNameOrPhoneOrWithDrawSate(walletCathFindDTO.getUsername(),
walletCathFindDTO.getPhone(),
walletCathFindDTO.getState(),
walletCathFindDTO.getOrderNo(),
walletCathFindDTO.getStartTime(),
walletCathFindDTO.getEndTime()));
() -> mapper.selectWalletCatchAll(walletCathFindDTO));
List<WalletCathListDTO> walletCathListDTOList = walletCathListDTOPage.getData();
if (CollectionUtils.isEmpty(walletCathListDTOList)) {
......
......@@ -50,6 +50,11 @@ public class MyWalletDetailBiz extends BaseBiz<MyWalletDetailMapper, MyWalletDet
PageDataVO<MyWalletDetail> walletDetailPageVoPageDataVO = PageDataVO.pageInfo(pageNo, pageSize, () -> mapper.selectByExample(example));
List<MyWalletDetail> walletDetails = walletDetailPageVoPageDataVO.getData();
if (CollectionUtils.isEmpty(walletDetails)){
walletDetailPageVo.setPageNum(pageNo);
walletDetailPageVo.setPageSize(pageSize);
walletDetailPageVo.setData(Collections.EMPTY_LIST);
walletDetailPageVo.setTotalPage(0);
walletDetailPageVo.setTotalCount(0L);
return walletDetailPageVo;
}
List<WalletDetailPageVo> walletDetailPageVoList = new ArrayList<>();
......
......@@ -41,4 +41,5 @@ public interface AppUserDetailMapper extends Mapper<AppUserDetail> {
List<AppUserDetail> selectAllWithNoProviinceCode();
List<UserBo> selectUserByUserIds(@Param("userIds") List<Integer> userIds);
}
\ No newline at end of file
package com.github.wxiaoqi.security.admin.mapper;
import com.github.wxiaoqi.security.admin.dto.PersonalConsumptionDTO;
import com.github.wxiaoqi.security.admin.dto.WalletCathFindDTO;
import com.github.wxiaoqi.security.admin.dto.WalletCathListDTO;
import com.github.wxiaoqi.security.admin.dto.WalletCathSumDto;
import com.github.wxiaoqi.security.admin.entity.MyWalletCath;
......@@ -17,12 +18,7 @@ import java.util.List;
*/
public interface MyWalletCathMapper extends Mapper<MyWalletCath> {
List<WalletCathListDTO> selectByUserNameOrPhoneOrWithDrawSate(@Param("userName") String userName,
@Param("phone") String phone,
@Param("state") Integer state,
@Param("orderNo") String orderNo,
@Param("startTime") Long startTime,
@Param("endTime") Long endTime);
List<WalletCathListDTO> selectWalletCatchAll(WalletCathFindDTO walletCathFindDTO);
List<PersonalConsumptionDTO> findUserWithDrawingByUserIds(@Param("userIds") List<Integer> userIds);
......
......@@ -25,7 +25,6 @@ import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
......@@ -378,4 +377,9 @@ public class AppUserController extends CommonBaseController{
AppUserVo appUserVo = userDetailBiz.findByCode(code);
return ObjectRestResponse.succ(appUserVo);
}
@GetMapping("/list_user_info")
public List<UserBo> findUserDetailByUserIds(@RequestParam(value = "userIds",required = false) List<Integer> userIds){
return userDetailBiz.findUserDetailByUserIds(userIds);
}
}
......@@ -343,4 +343,16 @@ from `app_user_detail` as `aud` left join `app_user_login` as `aul` on aul.id=
resultType="com.github.wxiaoqi.security.admin.entity.AppUserDetail">
select `id`,`crt_host` from `app_user_detail` where crt_host is not null and ( province_code = 0 or province_code is null)
</select>
<select id="selectUserByUserIds" resultType="com.github.wxiaoqi.security.admin.bo.UserBo">
select aud.userid as `userId`,case when length(aud.realname)>0 then aud.realname else aud.nickname end as `name`,aul.username as `phone` from `app_user_detail` as aud left join `app_user_login` as aul on aul.id=aud.userid
<where>
<if test="userIds != null and userIds.size() != 0">
userid in
<foreach collection="userIds" item="userId" open="(" close=")" separator=",">
#{userId}
</foreach>
</if>
</where>
</select>
</mapper>
\ No newline at end of file
......@@ -3,7 +3,7 @@
<mapper namespace="com.github.wxiaoqi.security.admin.mapper.MyWalletCathMapper">
<select id="selectByUserNameOrPhoneOrWithDrawSate"
<select id="selectWalletCatchAll"
resultType="com.github.wxiaoqi.security.admin.dto.WalletCathListDTO">
SELECT
wc.id,
......@@ -19,12 +19,16 @@
wc.order_no AS `orderNo`,
wc.account_number AS `accountNumber`,
wc.account_name AS `accountName`,
wc.offline_way AS `offlineWay`
wc.withdraw_way AS `withdrawWay`
FROM
(SELECT * FROM `my_wallet_cath` WHERE 1 = 1
(SELECT * FROM `my_wallet_cath`
<where>
<if test="state != null">
AND `stauts`=#{state}
</if>
<if test="withdrawWay != null">
AND `withdraw_way`=#{withdrawWay}
</if>
<if test="orderNo !=null and orderNo !=''">
AND `order_no` = #{orderNo}
</if>
......@@ -41,13 +45,14 @@
`crt_time` <= #{endTime}
]]>
</if>
</where>
) AS `wc`
INNER JOIN ( SELECT `id`, `username` FROM `app_user_login` <if test="phone != null and phone != ''">
WHERE `username`=#{phone}
</if> ) AS `aul` ON aul.id = wc.user_id
INNER JOIN ( SELECT `userid`, `nickname`, `realname` FROM `app_user_detail` <if
test="userName != null and userName != ''">
WHERE nickname =#{userName} OR realname =#{userName}
test="username != null and username != ''">
WHERE nickname =#{username} OR realname =#{username}
</if> ) AS `aud` ON aud.userid = aul.id order by wc.crt_time DESC
</select>
......
......@@ -16,11 +16,11 @@
wd.crt_time AS `crtTime`,
aul.username AS `phone`,
aud.nickname,
aud.realname<!--,
aud.realname,
ausw.price,
ausw.extract,
ausw.waiting,
ausw.title-->
ausw.title
FROM
(select id,user_id,source,amount,`with_draw_order_no`,cono,itype,activity_id,activity_name,`crt_time` FROM
`my_wallet_detail` WHERE 1=1
......@@ -48,8 +48,8 @@
test="userName != null and userName != ''">
WHERE `nickname`=#{userName} OR `realname`=#{userName}
</if>) AS `aud` ON aud.userid = aul.id
<!-- LEFT JOIN (SELECT DISTINCT order_id,id,price,extract,waiting,title FROM `app_user_selling_water`) AS `ausw` ON
ausw.order_id = wd.cono-->
LEFT JOIN (SELECT DISTINCT order_id,id,price,extract,waiting,title FROM `app_user_selling_water`) AS `ausw` ON
ausw.order_id = wd.cono
ORDER BY `crtTime` DESC
</select>
......
......@@ -44,7 +44,7 @@ public class WithDrawRuleVo {
private Integer maxNumberOfDay;
/**
* 1. 线上 2.线下
* 1.线下:自动 2.线下:手动 3. 线上
*/
private Integer withdrawWay;
......
package com.xxfc.platform.app.enumconstant;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* @author libin
* @version 1.0
* @description 提现方式
* @data 2020/1/7 8:44
*/
@AllArgsConstructor
@Getter
public enum WithDrawWayEnum {
WITHDRAW_ONLINE_WAY(3, "线上"),
WITHDRAW_OFFLINE_AUTO_WAY(2, "线下手动"),
WITHDRAW_OFFLINE_WAY(1, "线下自动");
private int code;
private String desc;
}
......@@ -97,10 +97,22 @@
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
<exclusions>
<exclusion>
<artifactId>commons-io</artifactId>
<groupId>commons-io</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
<exclusions>
<exclusion>
<artifactId>commons-io</artifactId>
<groupId>commons-io</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>commons-beanutils</groupId>
......@@ -142,6 +154,11 @@
<version>3.11.0</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.5</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
package com.xxfc.platform.order.contant.enumerate;
/**
* @author libin
* @version 1.0
* @description
* @data 2020/1/6 12:48
*/
public enum MemberStatisticsBehaviorTypeEnum {
FIRST_TIME_BUY(0, "首次购买"),
RENEW(1, "续费"),
ACTIVATE(2, "激活"),
PAY(3, "付费(首次购买+续费)");
private int code;
private String desc;
MemberStatisticsBehaviorTypeEnum(int code, String desc) {
this.code = code;
this.desc = desc;
}
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
}
package com.xxfc.platform.order.entity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.*;
import java.math.BigDecimal;
/**
* @author libin
* @version 1.0
* @description
* @data 2020/1/6 12:38
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Table(name = "order_member_view")
@Entity
public class MemberStatistics {
@Id
@GeneratedValue(generator = "JDBC")
private Long id;
@Column(name = "user_id")
private Integer userId;
@Column(name = "real_amount")
private BigDecimal realAmount;
@Column(name = "pay_time")
private Long payTime;
@Column(name = "order_no")
private String orderNo;
/**
* 0:首次购买 1:续费 2:激活
*/
@Column(name = "behavior_type")
private Integer behaviorType;
@Column(name = "member_level")
private Integer memberLevel;
@Column(name = "parent_id")
private Integer parentId;
/**
* 是否是第一时时间成为会员
*/
@Column(name = "is_first_time_member")
private Integer isFirstTimeMember;
}
......@@ -114,4 +114,13 @@ public class OrderInvoice {
*/
private String extend;
/**
* 1、开票成功,2、开票中
*/
private Integer status;
/**
* 发票PDF路径
*/
private String invoiceUrl;
}
\ No newline at end of file
package com.xxfc.platform.order.pojo.bo;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* @author libin
* @version 1.0
* @description
* @data 2020/1/6 11:04
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class MemberStatisticsBo implements Serializable {
private static final long serialVersionUID = 1L;
@JsonIgnore
private Integer userId;
private String name;
private String phone;
private BigDecimal realAmount;
private Long payTime;
private String orderNo;
/**
* 0:首次购买 1:续费 2:激活
*/
private Integer behaviorType;
@JsonIgnore
private Integer memberLevel;
private String memberName;
@JsonIgnore
private Integer parentId;
private String parentName;
private String parentPhone;
}
package com.xxfc.platform.order.pojo.bo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.collections4.CollectionUtils;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Collections;
import java.util.List;
/**
* @author libin
* @version 1.0
* @description
* @data 2020/1/6 11:21
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class MemberStatisticsPageBo implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 会员订单数
*/
private long memberOrdersNum;
/**
* 新增会员人数
*/
private long newMembersNum;
/**
* 激活人数
*/
private long activateMembersNum;
/**
* 会员费
*/
private BigDecimal memberAmount = BigDecimal.ZERO;
/**
* 普通会员订单数
*/
private long commonMemberOrdersNum;
/**
* 普通会员订单金额
*/
private BigDecimal commonMemberOrderAmount = BigDecimal.ZERO;
/**
* 黄金会员订单数
*/
private long goldMemberOrdersNum;
/**
* 黄金会员订单金额
*/
private BigDecimal goldMemberOrderAmount = BigDecimal.ZERO;
/**
* 钻石会员订单数
*/
private long diamondMemberOrdersNum;
/**
* 钻石会员订单金额
*/
private BigDecimal diamondMemberOrderAmount = BigDecimal.ZERO;
/**
* 会员统计
*/
private List<MemberStatisticsBo> memberStatistics;
private Long totalCount;
private Integer totalPage;
private Integer pageNum;
private Integer pageSize;
public List<MemberStatisticsBo> getMemberStatistics() {
return CollectionUtils.isEmpty(memberStatistics)? Collections.EMPTY_LIST:memberStatistics;
}
}
package com.xxfc.platform.order.pojo.dto;
import com.github.wxiaoqi.security.common.vo.PageParam;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @author libin
* @version 1.0
* @description
* @data 2020/1/6 12:31
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class MemberStatisticsFindDTO extends PageParam {
private Long startTime;
private Long endTime;
private Integer behaviorType;
private Boolean isExport;
}
package com.xxfc.platform.order.biz;
import com.github.wxiaoqi.security.admin.bo.UserBo;
import com.github.wxiaoqi.security.admin.feign.UserFeign;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.github.wxiaoqi.security.common.enumconstant.LevelEnum;
import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.xxfc.platform.order.contant.enumerate.MemberStatisticsBehaviorTypeEnum;
import com.xxfc.platform.order.entity.MemberStatistics;
import com.xxfc.platform.order.mapper.MemberStatisticsMapper;
import com.xxfc.platform.order.pojo.bo.MemberStatisticsBo;
import com.xxfc.platform.order.pojo.bo.MemberStatisticsPageBo;
import com.xxfc.platform.order.pojo.dto.MemberStatisticsFindDTO;
import lombok.RequiredArgsConstructor;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import tk.mybatis.mapper.entity.Example;
import java.math.BigDecimal;
import java.util.*;
import java.util.function.Function;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* @author libin
* @version 1.0
* @description
* @data 2020/1/6 12:35
*/
@Transactional(rollbackFor = Exception.class)
@Service
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class MemberStatisticsBiz extends BaseBiz<MemberStatisticsMapper, MemberStatistics> {
private final UserFeign userFeign;
public MemberStatisticsPageBo findMemberStatisticsWithPage(MemberStatisticsFindDTO memberStatisticsFindDTO) {
Example example = getMemberStatisticsExample(memberStatisticsFindDTO);
PageDataVO<MemberStatistics> dataVO = PageDataVO.pageInfo(memberStatisticsFindDTO.getPage(), memberStatisticsFindDTO.getLimit(), () -> mapper.selectByExample(example));
List<MemberStatistics> data = dataVO.getData();
if (CollectionUtils.isEmpty(data)) {
return new MemberStatisticsPageBo();
}
MemberStatisticsPageBo memberStatisticsPageBo = createMemberStatistics(memberStatisticsFindDTO);
memberStatisticsPageBo = wrapToMemberStatisticsPageBo(data,memberStatisticsPageBo);
memberStatisticsPageBo.setPageNum(dataVO.getPageNum());
memberStatisticsPageBo.setPageSize(dataVO.getPageSize());
memberStatisticsPageBo.setTotalCount(dataVO.getTotalCount());
memberStatisticsPageBo.setTotalPage(dataVO.getTotalPage());
return memberStatisticsPageBo;
}
private Example getMemberStatisticsExample(MemberStatisticsFindDTO memberStatisticsFindDTO) {
Example example = new Example(MemberStatistics.class);
Example.Criteria criteria = example.createCriteria();
if (Objects.nonNull(memberStatisticsFindDTO.getBehaviorType())) {
if (memberStatisticsFindDTO.getBehaviorType() == MemberStatisticsBehaviorTypeEnum.PAY.getCode()) {
criteria.andIn("behaviorType", Arrays.asList(MemberStatisticsBehaviorTypeEnum.FIRST_TIME_BUY.getCode(), MemberStatisticsBehaviorTypeEnum.RENEW.getCode()));
} else {
criteria.andEqualTo("behaviorType", memberStatisticsFindDTO.getBehaviorType());
}
}
if (Objects.nonNull(memberStatisticsFindDTO.getStartTime()) && Objects.nonNull(memberStatisticsFindDTO.getEndTime())) {
criteria.andBetween("payTime", memberStatisticsFindDTO.getStartTime(), memberStatisticsFindDTO.getEndTime());
}
if (Objects.nonNull(memberStatisticsFindDTO.getStartTime()) && Objects.isNull(memberStatisticsFindDTO.getEndTime())) {
criteria.andGreaterThanOrEqualTo("payTime", memberStatisticsFindDTO.getStartTime());
}
if (Objects.nonNull(memberStatisticsFindDTO.getEndTime()) && Objects.isNull(memberStatisticsFindDTO.getStartTime())) {
criteria.andLessThanOrEqualTo("payTime", memberStatisticsFindDTO.getEndTime());
}
return example;
}
public MemberStatisticsPageBo wrapToMemberStatisticsPageBo(List<MemberStatistics> memberStatistics,MemberStatisticsPageBo memberStatisticsPageBo) {
if (CollectionUtils.isEmpty(memberStatistics)) {
return memberStatisticsPageBo;
}
//用户id
List<Integer> userIds = memberStatistics.stream().map(member ->
Arrays.asList(member.getUserId(), member.getParentId())
).flatMap(List::stream).filter(Objects::nonNull).distinct().collect(Collectors.toList());
List<UserBo> userBos = userFeign.findUserDetailUserIds(userIds);
Map<Integer, UserBo> userBoMap = userBos.stream().collect(Collectors.toMap(UserBo::getUserId, Function.identity()));
List<MemberStatisticsBo> memberStatisticsBos = new ArrayList<>();
MemberStatisticsBo memberStatisticsBo;
UserBo userBo = new UserBo();
boolean isNullOrEmpty = userBoMap == null || userBoMap.isEmpty();
for (MemberStatistics memberStatistic : memberStatistics) {
memberStatisticsBo = new MemberStatisticsBo();
BeanUtils.copyProperties(memberStatistic, memberStatisticsBo);
UserBo bo = isNullOrEmpty ? userBo : userBoMap.get(memberStatistic.getUserId()) == null ? userBo : userBoMap.get(memberStatistic.getUserId());
memberStatisticsBo.setName(bo.getName());
memberStatisticsBo.setPhone(bo.getPhone());
UserBo leaderUserBo = isNullOrEmpty ? userBo : userBoMap.get(memberStatistic.getParentId()) == null ? userBo : userBoMap.get(memberStatistic.getParentId());
memberStatisticsBo.setParentName(leaderUserBo.getName());
memberStatisticsBo.setParentPhone(leaderUserBo.getPhone());
memberStatisticsBo.setMemberName(LevelEnum.getLevelEnumByLevel(memberStatistic.getMemberLevel()).getDesc());
memberStatisticsBos.add(memberStatisticsBo);
}
memberStatisticsPageBo.setMemberStatistics(memberStatisticsBos);
return memberStatisticsPageBo;
}
public MemberStatisticsPageBo createMemberStatistics(MemberStatisticsFindDTO memberStatisticsFindDTO) {
MemberStatisticsPageBo memberStatisticsPageBo = new MemberStatisticsPageBo();
boolean isStatistics = memberStatisticsFindDTO.getPage() != null && (memberStatisticsFindDTO.getPage() == 1 || memberStatisticsFindDTO.getIsExport());
if (isStatistics) {
Example memberStatisticsExample = getMemberStatisticsExample(memberStatisticsFindDTO);
List<MemberStatistics> memberStatistics = mapper.selectByExample(memberStatisticsExample);
if (CollectionUtils.isEmpty(memberStatistics)) {
return memberStatisticsPageBo;
}
Supplier<Stream<MemberStatistics>> memberStatisticsSupplier = () -> memberStatistics.stream();
Map<Integer, Long> memberBehaviorMap = memberStatisticsSupplier.get().collect(Collectors.groupingBy(MemberStatistics::getBehaviorType, Collectors.counting()));
//激活人数
long activateNum = memberBehaviorMap.get(MemberStatisticsBehaviorTypeEnum.ACTIVATE.getCode()) == null ? 0 : memberBehaviorMap.get(MemberStatisticsBehaviorTypeEnum.ACTIVATE.getCode());
memberStatisticsPageBo.setActivateMembersNum(activateNum);
//会员订单数
long firstBuyNum = memberBehaviorMap.get(MemberStatisticsBehaviorTypeEnum.FIRST_TIME_BUY.getCode()) == null ? 0 : memberBehaviorMap.get(MemberStatisticsBehaviorTypeEnum.FIRST_TIME_BUY.getCode());
long renewNum = memberBehaviorMap.get(MemberStatisticsBehaviorTypeEnum.RENEW.getCode()) == null ? 0 : memberBehaviorMap.get(MemberStatisticsBehaviorTypeEnum.RENEW.getCode());
long orderNums = firstBuyNum + renewNum;
memberStatisticsPageBo.setMemberOrdersNum(orderNums);
//新增会员人数
long newMemberNum = memberStatisticsSupplier.get().filter(member -> Objects.equals(member.getIsFirstTimeMember(), 1)).count();
memberStatisticsPageBo.setNewMembersNum(newMemberNum);
//会员等级分类
Map<Integer, List<MemberStatistics>> memberLevelStatisticsMap = memberStatisticsSupplier.get()
.filter(member -> member.getBehaviorType() != MemberStatisticsBehaviorTypeEnum.ACTIVATE.getCode())
.collect(Collectors.groupingBy(MemberStatistics::getMemberLevel, Collectors.toList()));
if (memberLevelStatisticsMap == null || memberLevelStatisticsMap.isEmpty()) {
return memberStatisticsPageBo;
}
memberLevelStatisticsMap.forEach((K, V) -> {
LevelEnum levelEnum = LevelEnum.getLevelEnumByLevel(K);
wrapMemberStatisticsPageBo(levelEnum, V, memberStatisticsPageBo);
});
//会员订单金额
BigDecimal totalMemberAmount = memberStatisticsPageBo.getCommonMemberOrderAmount()
.add(memberStatisticsPageBo.getGoldMemberOrderAmount())
.add(memberStatisticsPageBo.getDiamondMemberOrderAmount()).setScale(2, BigDecimal.ROUND_HALF_UP);
memberStatisticsPageBo.setMemberAmount(totalMemberAmount);
}
return memberStatisticsPageBo;
}
private void wrapMemberStatisticsPageBo(LevelEnum levelEnum, List<MemberStatistics> memberStatistics, MemberStatisticsPageBo memberStatisticsPageBo) {
int orderNum = memberStatistics.size();
BigDecimal orderAmount = memberStatistics.stream().map(MemberStatistics::getRealAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
switch (levelEnum) {
case GENERAL:
memberStatisticsPageBo.setCommonMemberOrdersNum(orderNum);
memberStatisticsPageBo.setCommonMemberOrderAmount(orderAmount);
break;
case GOLD:
memberStatisticsPageBo.setGoldMemberOrdersNum(orderNum);
memberStatisticsPageBo.setGoldMemberOrderAmount(orderAmount);
break;
case DIAMOND:
memberStatisticsPageBo.setDiamondMemberOrdersNum(orderNum);
memberStatisticsPageBo.setDiamondMemberOrderAmount(orderAmount);
break;
default:
break;
}
}
}
package com.xxfc.platform.order.biz;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import com.github.wxiaoqi.security.admin.feign.UserFeign;
import com.github.wxiaoqi.security.admin.feign.dto.AppUserDTO;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
......@@ -144,4 +146,22 @@ public class OrderInvoiceBiz extends BaseBiz<OrderInvoiceMapper, OrderInvoice> {
return ObjectRestResponse.succ(pageDataVO);
}
public ObjectRestResponse update(OrderInvoice orderInvoice) {
AppUserDTO appUserDTO = userFeign.userDetailByToken(request.getHeader("Authorization")).getData();
if (appUserDTO == null) {
return ObjectRestResponse.createFailedResult(ResultCode.RSTOKEN_EXPIRED_CODE, ResultCode.getMsg(ResultCode.RSTOKEN_EXPIRED_CODE));
}
if (orderInvoice == null || orderInvoice.getId() == null) {
return ObjectRestResponse.paramIsEmpty();
}
OrderInvoice oldValue = mapper.selectByPrimaryKey(orderInvoice.getId());
if (oldValue != null) {
BeanUtil.copyProperties(orderInvoice, oldValue, CopyOptions.create().setIgnoreNullValue(true).setIgnoreError(true));
updateSelectiveByIdRe(oldValue);
return ObjectRestResponse.succ();
}
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE, "发票不存在!");
}
}
package com.xxfc.platform.order.mapper;
import com.xxfc.platform.order.entity.MemberStatistics;
import tk.mybatis.mapper.common.Mapper;
/**
* @author libin
* @version 1.0
* @description
* @data 2020/1/6 12:36
*/
public interface MemberStatisticsMapper extends Mapper<MemberStatistics> {
}
......@@ -382,9 +382,9 @@ public class BackStageOrderController extends CommonBaseController implements Us
return ObjectRestResponse.paramIsEmpty();
}
if(flag != null && flag == true) {
return baseOrderBiz.getOrderDetail(orderNo, userDTO);
} else {
return baseOrderBiz.orderDetail(orderNo, userDTO);
} else {
return baseOrderBiz.getOrderDetail(orderNo, userDTO);
}
}
......
......@@ -42,4 +42,9 @@ public class OrderInvoiceController extends BaseController<OrderInvoiceBiz, Orde
return baseBiz.getByParam(orderInvoiceDto);
}
@PostMapping(value = "/update")
public ObjectRestResponse update(@RequestBody OrderInvoice orderInvoice) {
return baseBiz.update(orderInvoice);
}
}
package com.xxfc.platform.order.rest;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.github.wxiaoqi.security.admin.feign.UserFeign;
import com.github.wxiaoqi.security.auth.client.annotation.IgnoreClientToken;
......@@ -15,13 +14,11 @@ import com.xxfc.platform.order.biz.OrderRentVehicleBiz;
import com.xxfc.platform.order.biz.inner.OrderCalculateBiz;
import com.xxfc.platform.order.entity.BaseOrder;
import com.xxfc.platform.order.entity.OrderRentVehicleDetail;
import com.xxfc.platform.order.pojo.order.add.AddRentVehicleDTO;
import com.xxfc.platform.order.pojo.order.RentVehicleBO;
import com.xxfc.platform.order.pojo.order.add.AddRentVehicleDTO;
import com.xxfc.platform.order.pojo.order.add.BgAddRentDTO;
import com.xxfc.platform.order.pojo.price.RentVehiclePriceVO;
import com.xxfc.platform.order.service.OrderRentVehicleService;
import com.xxfc.platform.universal.constant.DictionaryKey;
import com.xxfc.platform.universal.entity.Dictionary;
import com.xxfc.platform.universal.feign.ThirdFeign;
import com.xxfc.platform.vehicle.entity.BranchCompany;
import com.xxfc.platform.vehicle.feign.VehicleFeign;
......@@ -37,14 +34,10 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import static com.xxfc.platform.universal.constant.DictionaryKey.APP_ORDER;
@Controller
@RequestMapping("orderRentVehicle")
@Api(value="租车订单",tags={"租车订单"})
......@@ -81,6 +74,7 @@ public class OrderRentVehicleController extends CommonBaseController {
bo.setAppUserDTO(userFeign.userDetailByToken(BaseContextHandler.getToken()).getData());
orderRentVehicleService.createOrder(bo);
return ObjectRestResponse.succ(bo.getOrder());
// return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE, "系统维护,请联系客服线下租车: 4000-369-369!");
}
@RequestMapping(value = "back-stage/add",method = RequestMethod.POST)
......
package com.xxfc.platform.order.rest.background;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.xxfc.platform.order.biz.MemberStatisticsBiz;
import com.xxfc.platform.order.pojo.bo.MemberStatisticsPageBo;
import com.xxfc.platform.order.pojo.dto.MemberStatisticsFindDTO;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
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.ResponseBody;
/**
* @author libin
* @version 1.0
* @description
* @data 2020/1/6 12:34
*/
@Controller
@RequestMapping("/admin/member/statistics")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class MemberStatisticsAdminController {
private final MemberStatisticsBiz memberStatisticsBiz;
@PostMapping("/page")
@ResponseBody
public ObjectRestResponse<MemberStatisticsPageBo> findMemberStatisticsWithPage(@RequestBody MemberStatisticsFindDTO memberStatisticsFindDTO){
MemberStatisticsPageBo memberStatisticsPageBo = memberStatisticsBiz.findMemberStatisticsWithPage(memberStatisticsFindDTO);
return ObjectRestResponse.succ(memberStatisticsPageBo);
}
}
......@@ -20,7 +20,10 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
@Slf4j
......@@ -95,8 +98,8 @@ public class BranchCompanyVehicleCountBiz extends BaseBiz<BranchCompanyVehicleCo
branchCompanyVehicleCountDTO.setPage(page);
branchCompanyVehicleCountDTO.setLimit(limit);
if (StringUtils.isBlank(branchCompanyVehicleCountDTO.getStartTime()) || StringUtils.isBlank(branchCompanyVehicleCountDTO.getEndTime())) {
branchCompanyVehicleCountDTO.setStartTime(DateTime.now().minusDays(1).toString(DATE_TIME_FORMATTER));
branchCompanyVehicleCountDTO.setEndTime(DateTime.now().minusDays(1).toString(DATE_TIME_FORMATTER));
branchCompanyVehicleCountDTO.setStartTime(DateTime.now().toString(DATE_TIME_FORMATTER));
branchCompanyVehicleCountDTO.setEndTime(DateTime.now().toString(DATE_TIME_FORMATTER));
}
Query query = new Query(branchCompanyVehicleCountDTO);
if (type == 1) {//按天
......@@ -120,4 +123,32 @@ public class BranchCompanyVehicleCountBiz extends BaseBiz<BranchCompanyVehicleCo
return ObjectRestResponse.succ(new PageDataVO<>());
}
public List<BranchCompanyVehicleCountVo> exportAllDate(BranchCompanyVehicleCountDTO branchCompanyVehicleCountDTO) {
Integer type = branchCompanyVehicleCountDTO.getType() == null ? 1 : branchCompanyVehicleCountDTO.getType();
Map<String, Object> param = new HashMap<>();
if (branchCompanyVehicleCountDTO.getCompanyId() != null) {
param.put("companyId", branchCompanyVehicleCountDTO.getCompanyId());
}
if (type == 1) {//按天
return mapper.getAllCountInfo(param);
}
if (type == 2) {//按周
List<BranchCompanyVehicleCountVo> pageDataVO = mapper.countByWeek(param);
if (pageDataVO != null && pageDataVO.size() > 0) {
pageDataVO.parallelStream().forEach(result -> {
String weekStartDate = OrderDateUtils.getStartDayOfWeekNo(result.getCountYear(), result.getCountWeek());
String weekEndDate = OrderDateUtils.getEndDayOfWeekNo(result.getCountYear(), result.getCountWeek());
result.setWeekStartDate(weekStartDate);
result.setWeekEndDate(weekEndDate);
});
}
return pageDataVO;
}
if (type == 3) {//按月
return mapper.countByMonth(param);
}
return new ArrayList<>();
}
}
......@@ -123,7 +123,8 @@ public class VehicleCountRecordBiz extends BaseBiz<VehicleCountRecordMapper, Veh
DateTime startDay = DateTime.parse(startDate, DEFAULT_DATE_TIME_FORMATTER);
DateTime endDay = DateTime.parse(endDate, DEFAULT_DATE_TIME_FORMATTER);
int i = 0;
for (DateTime curDate = startDay; i < 30; curDate = curDate.minusDays(1)) {
int monthDay = endDay.getDayOfMonth() - startDay.getDayOfMonth() + 1;
for (DateTime curDate = startDay; i < monthDay; curDate = curDate.minusDays(1)) {
i++;
nowTime = curDate.getMillis();
lastTime = nowTime + 24 * 3600 * 1000 - 1;
......
......@@ -4,7 +4,6 @@ import cn.hutool.core.io.IoUtil;
import cn.hutool.poi.excel.ExcelUtil;
import cn.hutool.poi.excel.ExcelWriter;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.xxfc.platform.vehicle.biz.BranchCompanyVehicleCountBiz;
import com.xxfc.platform.vehicle.common.BaseController;
import com.xxfc.platform.vehicle.pojo.BranchCompanyVehicleCountVo;
......@@ -17,6 +16,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
@Controller
@RequestMapping(value = "/bg-vehicle/count")
......@@ -33,8 +33,8 @@ public class BranchCompanyVehicleCountController extends BaseController<BranchCo
}
@GetMapping("/app/unauth/export")
public void exportVehicleInfo(BranchCompanyVehicleCountDTO branchCompanyVehicleCountDTO) throws Exception {
PageDataVO<BranchCompanyVehicleCountVo> pageDataVO = baseBiz.getAllCountInfo(branchCompanyVehicleCountDTO).getData();
if (pageDataVO != null && pageDataVO.getData() != null) {
List<BranchCompanyVehicleCountVo> pageDataVO = baseBiz.exportAllDate(branchCompanyVehicleCountDTO);
if (pageDataVO != null && pageDataVO.size() > 0) {
ExcelWriter writer = ExcelUtil.getWriter(true);
writer.addHeaderAlias("companyId", "公司ID");
writer.addHeaderAlias("companyName", "公司名");
......@@ -50,7 +50,7 @@ public class BranchCompanyVehicleCountController extends BaseController<BranchCo
writer.setColumnWidth(6, 17);
writer.setColumnWidth(1, 17);
// 一次性写出内容,使用默认样式,强制输出标题
writer.write(pageDataVO.getData(), true);
writer.write(pageDataVO, true);
//response为HttpServletResponse对象
response.setContentType("application/vnd.ms-excel;charset=utf-8");
//test.xls是弹出下载对话框的文件名,不能为中文,中文请自行编码
......
......@@ -606,6 +606,7 @@
FROM
vehicle v
LEFT JOIN branch_company b ON b.id = v.park_branch_company_id
where v.is_del = 0
GROUP BY
b.id
</select>
......
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