Commit 17b6155f authored by hezhen's avatar hezhen

Merge branch 'master-vehicle-price' into dev-tiande

parents 159886cc db4e66d6
package com.xxfc.platform.order.pojo.dto;
import com.github.wxiaoqi.security.common.vo.DataInter;
import com.github.wxiaoqi.security.common.vo.PageParam;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.math.BigDecimal;
import java.util.List;
/**
* 门店收支明细DTO
* @author libin
* @version 1.0
* @description
* @data 2019/12/25 14:53
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class WalletCathDTO extends PageParam implements DataInter {
@ApiModelProperty("门店")
private Integer companyId;
@ApiModelProperty("企业")
private Integer branchId;
@ApiModelProperty("开始时间")
private Long startTime;
@ApiModelProperty("结束时间")
private Long endTime;
@ApiModelProperty("提现单号")
private String orderNo;
List<Integer> dataCorporationIds;
List<Integer> dataCompanyIds;
}
package com.xxfc.platform.order.pojo.dto;
import com.github.wxiaoqi.security.common.vo.DataInter;
import com.github.wxiaoqi.security.common.vo.PageParam;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.math.BigDecimal;
import java.util.List;
/**
* 门店收支明细DTO
* @author libin
* @version 1.0
* @description
* @data 2019/12/25 14:53
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class WalletDTO extends PageParam implements DataInter {
@ApiModelProperty("门店")
private Integer companyId;
@ApiModelProperty("企业")
private Integer branchId;
List<Integer> dataCorporationIds;
List<Integer> dataCompanyIds;
}
package com.xxfc.platform.order.pojo.vo;
import com.xxfc.platform.order.entity.CompanyWalletCath;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class CompanyWalletCathVo extends CompanyWalletCath {
@ApiModelProperty("门店名称")
private String companyName;
@ApiModelProperty("企业名称")
private String branchName;
@ApiModelProperty("企业名称")
private Long branchId;
}
package com.xxfc.platform.order.pojo.vo;
import com.xxfc.platform.order.entity.CompanyWallet;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class CompanyWalletVo extends CompanyWallet {
@ApiModelProperty("门店名称")
private String companyName;
@ApiModelProperty("企业名称")
private String branchName;
@ApiModelProperty("企业名称")
private Long branchId;
}
......@@ -3,12 +3,20 @@ package com.xxfc.platform.order.biz;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.xxfc.platform.order.entity.*;
import com.xxfc.platform.order.mapper.CompanyWalletMapper;
import com.xxfc.platform.order.pojo.dto.WalletDTO;
import com.xxfc.platform.order.pojo.dto.WalletDetailDTO;
import com.xxfc.platform.order.pojo.vo.CompanyWalletVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.List;
@Service
@Slf4j
......@@ -25,6 +33,34 @@ public class CompanyWalletBiz extends BaseBiz<CompanyWalletMapper, CompanyWallet
}
//检查提现下一步操作
public CompanyWallet checkAmount(Integer companyId, BigDecimal amount) {
if (amount.compareTo(BigDecimal.ZERO) < 1) {
throw new BaseException("提现金额不能小于0", ResultCode.FAILED_CODE);
}
CompanyWallet companyWallet =selectById(companyId);
if (companyWallet == null) {
throw new BaseException( "钱包不存在",ResultCode.FAILED_CODE);
}
if (amount.compareTo(companyWallet.getBalance()) > 0) {
throw new BaseException("提现金额不能大于钱包金额和未审核提现金额",ResultCode.FAILED_CODE);
}
return companyWallet;
}
public List<CompanyWalletVo> getList(WalletDTO walletDTO){
return mapper.selectList(walletDTO);
}
public PageDataVO<CompanyWalletVo> selectList(WalletDTO walletDTO) {
return PageDataVO.pageInfo(walletDTO.getPage(), walletDTO.getLimit(), () -> getList(walletDTO));
}
......
package com.xxfc.platform.order.biz;
import cn.hutool.core.lang.Snowflake;
import com.github.wxiaoqi.security.admin.constant.WithDrawStatusEnum;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.xxfc.platform.order.contant.enumerate.CompanyWalletITypeEnum;
import com.xxfc.platform.order.entity.*;
import com.xxfc.platform.order.mapper.CompanyWalletCathMapper;
import com.xxfc.platform.order.pojo.dto.WalletCathDTO;
import com.xxfc.platform.order.pojo.vo.CompanyWalletCathVo;
import com.xxfc.platform.order.pojo.vo.CompanyWalletDetailVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.Instant;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.List;
@Service
@Slf4j
public class CompanyWalletCathBiz extends BaseBiz<CompanyWalletCathMapper, CompanyWalletCath> implements InitializingBean {
@Autowired
CompanyWalletBiz companyWalletBiz;
@Autowired
CompanyWalletDetailBiz walletDetailBiz;
@Autowired
BranchCompanyBiz branchCompanyBiz;
private Snowflake snowflake;
private DateTimeFormatter dateTimeFormatter;
public List<CompanyWalletCathVo> getList(WalletCathDTO walletCathDTO){
return mapper.selectList(walletCathDTO);
}
public PageDataVO<CompanyWalletDetailVo> selectList(WalletCathDTO walletCathDTO) {
return PageDataVO.pageInfo(walletCathDTO.getPage(), walletCathDTO.getLimit(), () -> getList(walletCathDTO));
}
//提现申请
public void applyCath(CompanyWalletCath walletCathDTO) {
if (walletCathDTO == null) {
throw new BaseException("参数不能为空",ResultCode.NULL_CODE);
}
Integer companyId = walletCathDTO.getCompanyId();
BigDecimal amount = walletCathDTO.getAmount();
//检查是否可以提现
BigDecimal cathAmount=mapper.sunAmountByStatus(companyId);
cathAmount=cathAmount.add(amount);
CompanyWallet companyWallet=companyWalletBiz.checkAmount(companyId, cathAmount);
CompanyWalletCath walletCath = new CompanyWalletCath();
BeanUtils.copyProperties(walletCathDTO,walletCath);
BigDecimal commission =BigDecimal.ZERO;
BigDecimal balnece = companyWallet.getBalance();
//到账金额
BigDecimal realAmount = amount.subtract(commission).setScale(2, RoundingMode.HALF_UP);
//提现单号
String orderNo = snowflake.nextIdStr();
orderNo = String.format("%s%s", dateTimeFormatter.format(LocalDate.now()), orderNo);
log.info("-----提现申请-----orderNo===" + orderNo + "----companyId====" + companyId + "---realAmount===" + realAmount);
walletCath.setCrtTime(Instant.now().toEpochMilli());
walletCath.setOrderNo(orderNo);
walletCath.setStauts(WithDrawStatusEnum.AUDIT.getCode());
walletCath.setBalance(balnece);
walletCath.setRealAmount(realAmount);
walletCath.setCommission(commission);
walletCath.setWithdrawWay(2);
insertSelective(walletCath);
}
public void withDrawProcess(CompanyWalletCath companyWalletCath) {
WalletCathDTO walletCathDTO=new WalletCathDTO();
walletCathDTO.setOrderNo(companyWalletCath.getOrderNo());
List<CompanyWalletCathVo> list = getList(walletCathDTO);
if (list == null || list.size() == 0) {
throw new BaseException("提现记录不存在",ResultCode.FAILED_CODE);
}
CompanyWalletCathVo walletCathVo=list.get(0);
if (walletCathVo.getStauts() == WithDrawStatusEnum.SUCCESS.getCode()) {
throw new BaseException("已审核",ResultCode.FAILED_CODE);
}
CompanyWallet companyWallet=companyWalletBiz.selectById(walletCathVo.getCompanyId());
if (companyWallet == null) {
throw new BaseException("钱包不存在", ResultCode.FAILED_CODE);
}
companyWalletCath.setFinishTime(Instant.now().toEpochMilli());
companyWalletCath.setId(walletCathVo.getId());
updateSelectiveById(companyWalletCath);
if (companyWalletCath.getStauts() == WithDrawStatusEnum.SUCCESS.getCode()) {
BigDecimal sAmount=companyWallet.getBalance().subtract(walletCathVo.getAmount()).setScale(2, RoundingMode.HALF_UP);
CompanyWalletDetail detail = new CompanyWalletDetail();
detail.setCono(walletCathVo.getOrderNo());
detail.setSAmount(sAmount);
detail.setAmount(walletCathVo.getAmount());
detail.setItype(CompanyWalletITypeEnum.CATH.getCode());
//设置提现单号
detail.setCompanyId(walletCathVo.getCompanyId());
detail.setBranchId(walletCathVo.getBranchId());
walletDetailBiz.insertSelective(detail);
//更新钱包
BigDecimal withdrawals = companyWallet.getWithdrawals().add(walletCathVo.getAmount()).setScale(2, RoundingMode.HALF_UP);
companyWallet.setBalance(sAmount);
companyWallet.setWithdrawals(withdrawals);
companyWalletBiz.updCompanyWallet(companyWallet);
}
}
@Override
public void afterPropertiesSet() throws Exception {
snowflake = new Snowflake(2, 2, false);
dateTimeFormatter = DateTimeFormatter.ofPattern("YYYYMMdd");
}
}
......@@ -60,7 +60,8 @@ public class WebConfiguration implements WebMvcConfigurer {
"/orderMember/**",
"/orderRefund/**",
"/orderVehicle/**",
"/shuntApply/**"
"/shuntApply/**",
"/admin/**",
};
Collections.addAll(list, urls);
return list;
......
......@@ -2,8 +2,15 @@ package com.xxfc.platform.order.mapper;
import com.xxfc.platform.order.entity.CompanyWalletCath;
import com.xxfc.platform.order.pojo.dto.WalletCathDTO;
import com.xxfc.platform.order.pojo.vo.CompanyWalletCathVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.common.Mapper;
import java.math.BigDecimal;
import java.util.List;
/**
* 钱包提现表
......@@ -14,4 +21,9 @@ import tk.mybatis.mapper.common.Mapper;
*/
public interface CompanyWalletCathMapper extends Mapper<CompanyWalletCath> {
List<CompanyWalletCathVo> selectList(WalletCathDTO walletCathDTO);
@Select("SELECT IFNULL(SUM(amount),0) FROM company_wallet_cath WHERE company_id =#{companyId} AND stauts=0")
BigDecimal sunAmountByStatus(@Param("companyId")Integer companyId);
}
......@@ -3,11 +3,15 @@ package com.xxfc.platform.order.mapper;
import com.xxfc.platform.order.entity.CompanyWallet;
import com.xxfc.platform.order.pojo.dto.WalletDTO;
import com.xxfc.platform.order.pojo.dto.WalletDetailDTO;
import com.xxfc.platform.order.pojo.vo.CompanyWalletVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import tk.mybatis.mapper.common.Mapper;
import java.util.List;
/**
* 我的钱包
*
......@@ -25,4 +29,7 @@ public interface CompanyWalletMapper extends Mapper<CompanyWallet> {
CompanyWallet sumAmount(WalletDetailDTO walletDetailDTO);
List<CompanyWalletVo> selectList(WalletDTO walletDTO);
}
......@@ -6,12 +6,18 @@ import com.github.wxiaoqi.security.admin.feign.rest.UserRestInterface;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.rest.BaseController;
import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.xxfc.platform.order.biz.CompanyWalletBiz;
import com.xxfc.platform.order.biz.CompanyWalletCathBiz;
import com.xxfc.platform.order.biz.CompanyWalletDetailBiz;
import com.xxfc.platform.order.entity.CompanyWalletCath;
import com.xxfc.platform.order.entity.CompanyWalletDetail;
import com.xxfc.platform.order.pojo.dto.WalletCathDTO;
import com.xxfc.platform.order.pojo.dto.WalletDTO;
import com.xxfc.platform.order.pojo.dto.WalletDetailDTO;
import com.xxfc.platform.order.pojo.vo.CompanyWalletDetailVo;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
......@@ -29,9 +35,16 @@ public class AdminCompanyWalletDetailController extends BaseController<CompanyWa
}
@Autowired
CompanyWalletCathBiz walletCathBiz;
@Autowired
CompanyWalletBiz walletBiz;
@RequestMapping(value = "selectList", method = RequestMethod.GET)
@ApiModelProperty(value = "营收明细列表")
public ObjectRestResponse<PageDataVO<CompanyWalletDetailVo>> refundAmount(WalletDetailDTO walletDetailDTO) {
public ObjectRestResponse<PageDataVO<CompanyWalletDetailVo>> selectList(WalletDetailDTO walletDetailDTO) {
setPowerData(walletDetailDTO,true);
return ObjectRestResponse.succ(baseBiz.selectList(walletDetailDTO));
}
......@@ -44,4 +57,37 @@ public class AdminCompanyWalletDetailController extends BaseController<CompanyWa
return ObjectRestResponse.succ(baseBiz.getSumAmount(walletDetailDTO));
}
@RequestMapping(value = "cath/selectList", method = RequestMethod.GET)
@ApiModelProperty(value = "提现明细列表")
public ObjectRestResponse<PageDataVO<CompanyWalletDetailVo>> cathSelectList(WalletCathDTO walletCathDTO) {
setPowerData(walletCathDTO,true);
return ObjectRestResponse.succ(walletCathBiz.selectList(walletCathDTO));
}
@RequestMapping(value = "amount/selectList", method = RequestMethod.GET)
@ApiModelProperty(value = "钱包列表")
public ObjectRestResponse<PageDataVO<CompanyWalletDetailVo>> amountSelectList(WalletDTO walletDTO) {
setPowerData(walletDTO,true);
return ObjectRestResponse.succ(walletBiz.selectList(walletDTO));
}
@RequestMapping(value = "applyCath", method = RequestMethod.POST)
@ApiModelProperty(value = "提现申请")
public ObjectRestResponse applyCath(@RequestBody CompanyWalletCath walletCathDTO) {
walletCathBiz.applyCath(walletCathDTO);
return ObjectRestResponse.succ();
}
@RequestMapping(value = "withDrawProcess", method = RequestMethod.POST)
@ApiModelProperty(value = "提现审核")
public ObjectRestResponse withDrawProcess(@RequestBody CompanyWalletCath companyWalletCath) {
walletCathBiz.withDrawProcess(companyWalletCath);
return ObjectRestResponse.succ();
}
}
\ No newline at end of file
......@@ -46,10 +46,11 @@ public class BgStatisticsController extends BaseController<OrderStatisticsBiz, O
@ApiOperation(value = "首页订单统计")
public ObjectRestResponse<IndexOrderVO> indexOrder() {
IndexOrderVO indexOrderVO = new IndexOrderVO();
indexOrderVO.setCurrDayOrderAmount(new BigDecimal("1"));
indexOrderVO.setCurrDayOrderAmount(new BigDecimal("1000000000.00"));
indexOrderVO.setCurrDayOrderNum(2L);
indexOrderVO.setCurrDayToLiftVehicleNum(3L);
indexOrderVO.setCurrDayToReturnVehicleNum(4L);
indexOrderVO.setToDealTrafficPay(5L);
//获取会员订单统计信息
return ObjectRestResponse.succ(indexOrderVO);
}
......@@ -60,5 +61,6 @@ public class BgStatisticsController extends BaseController<OrderStatisticsBiz, O
private Long currDayOrderNum;
private Long currDayToLiftVehicleNum;
private Long currDayToReturnVehicleNum;
private Long toDealTrafficPay;
}
}
<?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.CompanyWalletCathMapper">
<select id="selectList" resultType="com.xxfc.platform.order.pojo.vo.CompanyWalletCathVo" parameterType="com.xxfc.platform.order.pojo.dto.WalletCathDTO">
SELECT
wc.*,
c.`name` as companyName,
ci.`name` as branchName,
ci.id as branchId
FROM company_wallet_cath wc
LEFT JOIN branch_company c ON wc.company_id =c.id
LEFT JOIN company_info ci ON c.company_id=ci.id
<where>
<if test="companyId != null and companyId > 0">
and wc.company_id=#{companyId}
</if>
<if test="branchId != null and branchId > 0">
and c.company_id=#{branchId}
</if>
<if test="orderNo != null and orderNo != '' ">
and wc.order_no like concat('%',#{orderNo},'%')
</if>
<if test="startTime != null and startTime > 0">
and wc.crt_time > = {startTime}
</if>
<if test="endTime != null and endTime > 0">
and wc.crt_time &lt;= {endTime}
</if>
<if test="dataCompanyIds != null and dataCompanyIds.size() > 0">
and wc.company_id= in
<foreach collection="dataCompanyIds" item="item" separator="," open="(" close=")">
#{item}
</foreach>
</if>
<if test="dataCorporationIds != null and dataCorporationIds.size() > 0">
and c.company_id in
<foreach collection="dataCorporationIds" item="item" separator="," open="(" close=")">
#{item}
</foreach>
</if>
</where>
order by wc.crt_time desc
</select>
</mapper>
\ No newline at end of file
......@@ -71,4 +71,38 @@
</where>
</select>
<select id="selectList" resultType="com.xxfc.platform.order.pojo.vo.CompanyWalletVo" parameterType="com.xxfc.platform.order.pojo.dto.WalletDTO">
SELECT
w.*,
c.`name` as companyName,
ci.`name` as branchName,
ci.id as branchId
FROM company_wallet w
LEFT JOIN branch_company c ON w.company_id =c.id
LEFT JOIN company_info ci ON c.company_id=ci.id
<where>
<if test="companyId != null and companyId > 0">
and w.company_id=#{companyId}
</if>
<if test="branchId != null and branchId > 0">
and c.company_id=#{branchId}
</if>
<if test="dataCompanyIds != null and dataCompanyIds.size() > 0">
and w.company_id= in
<foreach collection="dataCompanyIds" item="item" separator="," open="(" close=")">
#{item}
</foreach>
</if>
<if test="dataCorporationIds != null and dataCorporationIds.size() > 0">
and c.company_id in
<foreach collection="dataCorporationIds" item="item" separator="," open="(" close=")">
#{item}
</foreach>
</if>
</where>
order by w.id desc
</select>
</mapper>
\ No newline at end of file
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