Commit 711e0646 authored by hezhen's avatar hezhen

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

parents 8475c939 b4d39ecd
package com.xxfc.platform.order.contant.enumerate;
import java.util.HashMap;
import java.util.Map;
public enum CompanyWalletITypeEnum {
VEHICLE(1, "租车订单收入"),
VIOLATE(2, "违约金"),
REGULATION(3, "违章补偿"),
LOSS(4, "定损"),
PLATFORM(5, "平台抽成"),
CATH(6, "提现"),
TOUR(7, "旅游订单收入"),
;
/**
* 编码
*/
private Integer code;
/**
* 类型描述
*/
private String desc;
public static Map<Integer, CompanyWalletITypeEnum> codeAndDesc = new HashMap<Integer, CompanyWalletITypeEnum>();
//Maps.newHashMap();
static{
for(CompanyWalletITypeEnum enumE : CompanyWalletITypeEnum.values()){
codeAndDesc.put(enumE.getCode(), enumE);
}
}
CompanyWalletITypeEnum(Integer code, String desc){
this.code=code;
this.desc=desc;
}
public Integer getCode() {
return code;
}
public void setCode(Integer code) {
this.code = code;
}
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
public static Boolean exists(Integer code){
return codeAndDesc.containsKey(code);
}
public static CompanyWalletITypeEnum get(Integer code) {
for(CompanyWalletITypeEnum enumE : CompanyWalletITypeEnum.values()) {
if (enumE.getCode().equals(code)) {
return enumE;
}
}
return null;
}
}
\ No newline at end of file
...@@ -8,9 +8,10 @@ public enum CompanyWalletSourceEnum { ...@@ -8,9 +8,10 @@ public enum CompanyWalletSourceEnum {
DAMAGE_SAFE(2, "不计免赔费"), DAMAGE_SAFE(2, "不计免赔费"),
RENT_VEHICLE(3, "车辆租赁费"), RENT_VEHICLE(3, "车辆租赁费"),
ORDER_COMSSION(4, "订单抽成"), ORDER_COMSSION(4, "订单抽成"),
PLATFORM_COMSSION(4, "平台抽成"), PLATFORM_COMSSION(5, "平台抽成"),
LOSS_SPECIFIED(4, "定损费"), LOSS_SPECIFIED(6, "定损费"),
BREAK_RULES_REGULATION(4, "违章费"), BREAK_RULES_REGULATION(7, "违章费"),
VIOLATE_AMOUNT(8, "违约金"),
; ;
/** /**
* 编码 * 编码
......
...@@ -342,4 +342,8 @@ public class BaseOrder implements Serializable { ...@@ -342,4 +342,8 @@ public class BaseOrder implements Serializable {
*/ */
@Column(name = "invoice_id") @Column(name = "invoice_id")
private Integer invoiceId; private Integer invoiceId;
@Column(name = "revenue_json")
private String revenueJson;
} }
...@@ -37,7 +37,12 @@ public class CompanyWalletDetail implements Serializable { ...@@ -37,7 +37,12 @@ public class CompanyWalletDetail implements Serializable {
@Column(name = "cono") @Column(name = "cono")
@ApiModelProperty(value = "订单号或提现号") @ApiModelProperty(value = "订单号或提现号")
private Integer cono; private String cono;
@Column(name = "itype")
@ApiModelProperty(value = "收支分类")
private Integer itype;
@Column(name = "source") @Column(name = "source")
...@@ -60,7 +65,7 @@ public class CompanyWalletDetail implements Serializable { ...@@ -60,7 +65,7 @@ public class CompanyWalletDetail implements Serializable {
@Column(name = "branch_id") @Column(name = "branch_id")
@ApiModelProperty(value = "企业id") @ApiModelProperty(value = "企业id")
private Integer branchId; private Long branchId;
......
...@@ -27,7 +27,6 @@ public class CompanyWalletDetailDTO{ ...@@ -27,7 +27,6 @@ public class CompanyWalletDetailDTO{
private Integer startCompanyId; private Integer startCompanyId;
@ApiModelProperty("结束门店") @ApiModelProperty("结束门店")
private Integer endCompanyId; private Integer endCompanyId;
...@@ -40,6 +39,10 @@ public class CompanyWalletDetailDTO{ ...@@ -40,6 +39,10 @@ public class CompanyWalletDetailDTO{
private Integer platformCompanyId; private Integer platformCompanyId;
@ApiModelProperty("平台门店")
private Long platformBranchId;
@ApiModelProperty("订单总额") @ApiModelProperty("订单总额")
private BigDecimal orderAmount =BigDecimal.ZERO; private BigDecimal orderAmount =BigDecimal.ZERO;
...@@ -54,7 +57,7 @@ public class CompanyWalletDetailDTO{ ...@@ -54,7 +57,7 @@ public class CompanyWalletDetailDTO{
@ApiModelProperty("押金") @ApiModelProperty("押金")
private BigDecimal deposit =BigDecimal.ZERO; private BigDecimal deposit =BigDecimal.ZERO;
//算出来
@ApiModelProperty("分销金额") @ApiModelProperty("分销金额")
private BigDecimal comssion =BigDecimal.ZERO; private BigDecimal comssion =BigDecimal.ZERO;
...@@ -67,6 +70,10 @@ public class CompanyWalletDetailDTO{ ...@@ -67,6 +70,10 @@ public class CompanyWalletDetailDTO{
private BigDecimal breakRulesRegulation =BigDecimal.ZERO; private BigDecimal breakRulesRegulation =BigDecimal.ZERO;
@ApiModelProperty("违约金")
private BigDecimal violateAmount =BigDecimal.ZERO;
@ApiModelProperty("车辆收益比例") @ApiModelProperty("车辆收益比例")
private BigDecimal vehicleExtract = new BigDecimal(1); private BigDecimal vehicleExtract = new BigDecimal(1);
...@@ -79,7 +86,7 @@ public class CompanyWalletDetailDTO{ ...@@ -79,7 +86,7 @@ public class CompanyWalletDetailDTO{
private BigDecimal platformExtract = new BigDecimal(1); private BigDecimal platformExtract = new BigDecimal(1);
//算出来
@ApiModelProperty("车辆租赁费") @ApiModelProperty("车辆租赁费")
private BigDecimal rentVehicleAmount; private BigDecimal rentVehicleAmount;
......
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 WalletDetailDTO extends PageParam implements DataInter {
@ApiModelProperty("门店")
private Integer companyId;
@ApiModelProperty("企业")
private Integer branchId;
@ApiModelProperty("开始时间")
private Long startTime;
@ApiModelProperty("结束时间")
private Long endTime;
List<Integer> itypes;
List<Integer> dataCorporationIds;
List<Integer> dataCompanyIds;
}
package com.xxfc.platform.order.pojo.vo;
import com.xxfc.platform.order.contant.enumerate.CompanyWalletITypeEnum;
import com.xxfc.platform.order.contant.enumerate.CompanyWalletSourceEnum;
import com.xxfc.platform.order.entity.CompanyWalletDetail;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class CompanyWalletDetailVo extends CompanyWalletDetail {
@ApiModelProperty("门店名称")
private String companyName;
@ApiModelProperty("企业名称")
private String branchName;
@ApiModelProperty("类型说明")
private String sourceName;
@ApiModelProperty("类型")
private String typeName;
public String getSourceName(){
return CompanyWalletITypeEnum.get(getItype()).getDesc();
}
public String getTypeName(){
return getType() == 1 ? "收入":"支出";
}
}
package com.xxfc.platform.order.biz;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.xxfc.platform.order.entity.*;
import com.xxfc.platform.order.mapper.CompanyWalletMapper;
import com.xxfc.platform.order.pojo.dto.WalletDetailDTO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@Service
@Slf4j
public class CompanyWalletBiz extends BaseBiz<CompanyWalletMapper, CompanyWallet>{
public void updCompanyWallet(CompanyWallet companyWallet){
mapper.updMyWater(companyWallet);
}
public CompanyWallet sumAmount(WalletDetailDTO walletDetailDTO){
return mapper.sumAmount(walletDetailDTO);
}
}
...@@ -2,19 +2,31 @@ package com.xxfc.platform.order.biz; ...@@ -2,19 +2,31 @@ package com.xxfc.platform.order.biz;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.github.wxiaoqi.security.common.biz.BaseBiz; import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.github.wxiaoqi.security.common.exception.BaseException; import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.process.ResultCode; 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.contant.enumerate.CompanyWalletSourceEnum;
import com.xxfc.platform.order.contant.enumerate.OrderStatusEnum; import com.xxfc.platform.order.contant.enumerate.OrderStatusEnum;
import com.xxfc.platform.order.entity.BaseOrder; import com.xxfc.platform.order.entity.*;
import com.xxfc.platform.order.entity.CompanyWalletDetail;
import com.xxfc.platform.order.mapper.CompanyWalletDetailMapper; import com.xxfc.platform.order.mapper.CompanyWalletDetailMapper;
import com.xxfc.platform.order.pojo.dto.CompanyWalletDetailDTO; import com.xxfc.platform.order.pojo.dto.CompanyWalletDetailDTO;
import com.xxfc.platform.order.pojo.dto.WalletDetailDTO;
import com.xxfc.platform.order.pojo.vo.CompanyWalletDetailVo;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
@Service @Service
...@@ -25,24 +37,261 @@ public class CompanyWalletDetailBiz extends BaseBiz<CompanyWalletDetailMapper, C ...@@ -25,24 +37,261 @@ public class CompanyWalletDetailBiz extends BaseBiz<CompanyWalletDetailMapper, C
@Autowired @Autowired
BaseOrderBiz orderBiz; BaseOrderBiz orderBiz;
@Autowired
OrderRentVehicleBiz orderRentVehicleBiz;
@Autowired
OrderItemBiz orderItemBiz;
@Autowired
CompanyWalletBiz companyWalletBiz;
public void addOrUpd(CompanyWalletDetailDTO walletDetailDTO){
String orderNo=walletDetailDTO.getOrderNo();
@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
public void addOrUpd(CompanyWalletDetail companyWalletDetail){
String orderNo=companyWalletDetail.getCono();
if (StringUtils.isBlank(orderNo)){ if (StringUtils.isBlank(orderNo)){
throw new BaseException("订单号不存在",ResultCode.FAILED_CODE); throw new BaseException("订单号不存在",ResultCode.FAILED_CODE);
} }
log.info("---orderNo==="+orderNo); log.info("---orderNo==="+orderNo);
//获取订单相关信息
BaseOrder baseOrder=new BaseOrder(); BaseOrder baseOrder=new BaseOrder();
baseOrder.setNo(orderNo); baseOrder.setNo(orderNo);
baseOrder=orderBiz.selectOne(baseOrder); baseOrder=orderBiz.selectOne(baseOrder);
if (baseOrder == null || baseOrder.getStatus() >= OrderStatusEnum.ORDER_WAIT.getCode()){ if (baseOrder == null || baseOrder.getStatus() < OrderStatusEnum.ORDER_FINISH.getCode() || StringUtils.isBlank(baseOrder.getRevenueJson())){
throw new BaseException("订单不存在或状态不是已完成",ResultCode.FAILED_CODE); throw new BaseException("订单不存在或状态不是已完成",ResultCode.FAILED_CODE);
} }
List<OrderRentVehicleDetail> orderRentVehicleDetails = orderRentVehicleBiz.listByOrderId(baseOrder.getId());
if (orderRentVehicleDetails == null || orderRentVehicleDetails.size() == 0){
throw new BaseException("订单详情不存在",ResultCode.FAILED_CODE);
}
OrderItem orderItem=new OrderItem();
orderItem.setOrderId(baseOrder.getId());
List<OrderItem> orderItems = orderItemBiz.selectList(orderItem);
BigDecimal damageSafeAmount = orderItems.stream().filter(x->x.getType()==102).map(OrderItem::getRealAmount).reduce(BigDecimal.ZERO, (x, y) -> x.add(y));
OrderRentVehicleDetail vehicleDetail=orderRentVehicleDetails.get(0);
//获取营收明细dto
CompanyWalletDetailDTO walletDetailDTO=JSONUtil.toBean(baseOrder.getRevenueJson(), CompanyWalletDetailDTO.class);
walletDetailDTO.setDamageSafeAmount(damageSafeAmount);
walletDetailDTO.setOrderAmount(baseOrder.getRealAmount() ); walletDetailDTO.setOrderAmount(baseOrder.getRealAmount() );
walletDetailDTO.setDeposit(vehicleDetail.getDeposit());
walletDetailDTO.setViolateAmount(baseOrder.getViolateAmount());
walletDetailDTO.setBreakRulesRegulation(vehicleDetail.getViolateTrafficAmount());
walletDetailDTO.setLossSpecifiedAmount(baseOrder.getViolateAmount());
//获取门店钱包信息
CompanyWallet endCompany=companyWalletBiz.selectById(vehicleDetail.getActualEndCompanyId());
BigDecimal endCompanyAmount=BigDecimal.ZERO;
if (endCompany != null){
endCompanyAmount=endCompany.getBalance();
}
CompanyWallet vehicleCompany=companyWalletBiz.selectById(vehicleDetail.getVehicleCompanyId());
BigDecimal vehicleCompanyAmount=BigDecimal.ZERO;
if (vehicleCompany != null){
vehicleCompanyAmount=vehicleCompany.getBalance();
}
CompanyWallet startCompany=companyWalletBiz.selectById(vehicleDetail.getStartCompanyId());
BigDecimal startCompanyAmount=BigDecimal.ZERO;
if (startCompany != null){
startCompanyAmount=startCompany.getBalance();
}
CompanyWallet platformCompany=companyWalletBiz.selectById(walletDetailDTO.getPlatformCompanyId());
BigDecimal platformCompanyAmount=BigDecimal.ZERO;
if (platformCompany != null){
platformCompanyAmount=platformCompany.getBalance();
}
//插入营收明细
if (walletDetailDTO.getClosedVehicleAmout() != null && walletDetailDTO.getClosedVehicleAmout().compareTo(BigDecimal.ZERO)>0){
endCompanyAmount=endCompanyAmount.add(walletDetailDTO.getClosedVehicleAmout());
companyWalletDetail.setAmount(walletDetailDTO.getClosedVehicleAmout());
companyWalletDetail.setCompanyId(vehicleDetail.getActualEndCompanyId());
companyWalletDetail.setBranchId(vehicleDetail.getActualEndBranchId());
companyWalletDetail.setSAmount(endCompanyAmount);
companyWalletDetail.setSource(CompanyWalletSourceEnum.CLOSED_VEHICLE.getCode());
companyWalletDetail.setItype(CompanyWalletITypeEnum.VEHICLE.getCode());
companyWalletDetail.setId(null);
insertSelective(companyWalletDetail);
}if (walletDetailDTO.getDamageSafeAmount() != null && walletDetailDTO.getDamageSafeAmount().compareTo(BigDecimal.ZERO)>0){
BigDecimal amount=mapper.sumAmountByNo(orderNo,vehicleDetail.getVehicleCompanyId());
vehicleCompanyAmount=vehicleCompanyAmount.add(walletDetailDTO.getDamageSafeAmount());
companyWalletDetail.setAmount(walletDetailDTO.getDamageSafeAmount());
companyWalletDetail.setCompanyId(vehicleDetail.getVehicleCompanyId());
companyWalletDetail.setBranchId(vehicleDetail.getVehicleBranchId());
companyWalletDetail.setSAmount(walletDetailDTO.getDamageSafeAmount().add(amount));
companyWalletDetail.setSource(CompanyWalletSourceEnum.DAMAGE_SAFE.getCode());
companyWalletDetail.setItype(CompanyWalletITypeEnum.VEHICLE.getCode());
companyWalletDetail.setId(null);
insertSelective(companyWalletDetail);
}if (walletDetailDTO.getRentVehicleAmount() != null && walletDetailDTO.getRentVehicleAmount().compareTo(BigDecimal.ZERO)>0){
BigDecimal amount=mapper.sumAmountByNo(orderNo,vehicleDetail.getVehicleCompanyId());
vehicleCompanyAmount=vehicleCompanyAmount.add(walletDetailDTO.getRentVehicleAmount());
companyWalletDetail.setAmount(walletDetailDTO.getRentVehicleAmount());
companyWalletDetail.setCompanyId(vehicleDetail.getVehicleCompanyId());
companyWalletDetail.setBranchId(vehicleDetail.getVehicleBranchId());
companyWalletDetail.setSAmount(walletDetailDTO.getRentVehicleAmount().add(amount));
companyWalletDetail.setSource(CompanyWalletSourceEnum.RENT_VEHICLE.getCode());
companyWalletDetail.setItype(CompanyWalletITypeEnum.VEHICLE.getCode());
companyWalletDetail.setId(null);
insertSelective(companyWalletDetail);
}if (walletDetailDTO.getOrderAmount() != null && walletDetailDTO.getOrderAmount().compareTo(BigDecimal.ZERO)>0){
BigDecimal amount=mapper.sumAmountByNo(orderNo,vehicleDetail.getStartCompanyId());
startCompanyAmount=startCompanyAmount.add(walletDetailDTO.getOrderAmount());
companyWalletDetail.setAmount(walletDetailDTO.getOrderAmount());
companyWalletDetail.setCompanyId(vehicleDetail.getStartCompanyId());
companyWalletDetail.setBranchId(vehicleDetail.getStartBranchId());
companyWalletDetail.setSAmount(walletDetailDTO.getOrderAmount().add(amount));
companyWalletDetail.setSource(CompanyWalletSourceEnum.ORDER_COMSSION.getCode());
companyWalletDetail.setItype(CompanyWalletITypeEnum.VEHICLE.getCode());
companyWalletDetail.setId(null);
insertSelective(companyWalletDetail);
}if (walletDetailDTO.getPlatformComssion() != null && walletDetailDTO.getPlatformComssion().compareTo(BigDecimal.ZERO)>0){
BigDecimal amount=mapper.sumAmountByNo(orderNo,walletDetailDTO.getPlatformCompanyId());
platformCompanyAmount=platformCompanyAmount.add(walletDetailDTO.getPlatformComssion());
companyWalletDetail.setAmount(walletDetailDTO.getPlatformComssion());
companyWalletDetail.setCompanyId(walletDetailDTO.getPlatformCompanyId());
companyWalletDetail.setBranchId(walletDetailDTO.getPlatformBranchId());
companyWalletDetail.setSAmount(walletDetailDTO.getPlatformComssion().add(amount));
companyWalletDetail.setSource(CompanyWalletSourceEnum.PLATFORM_COMSSION.getCode());
companyWalletDetail.setItype(CompanyWalletITypeEnum.PLATFORM.getCode());
companyWalletDetail.setId(null);
insertSelective(companyWalletDetail);
}if (walletDetailDTO.getLossSpecifiedAmount() != null && walletDetailDTO.getLossSpecifiedAmount().compareTo(BigDecimal.ZERO)>0){
BigDecimal amount=mapper.sumAmountByNo(orderNo,vehicleDetail.getVehicleCompanyId());
vehicleCompanyAmount=vehicleCompanyAmount.add(walletDetailDTO.getLossSpecifiedAmount());
companyWalletDetail.setAmount(walletDetailDTO.getLossSpecifiedAmount());
companyWalletDetail.setCompanyId(vehicleDetail.getVehicleCompanyId());
companyWalletDetail.setBranchId(vehicleDetail.getVehicleBranchId());
companyWalletDetail.setSAmount(walletDetailDTO.getLossSpecifiedAmount().add(amount));
companyWalletDetail.setSource(CompanyWalletSourceEnum.LOSS_SPECIFIED.getCode());
companyWalletDetail.setItype(CompanyWalletITypeEnum.LOSS.getCode());
companyWalletDetail.setId(null);
insertSelective(companyWalletDetail);
}if (walletDetailDTO.getBreakRulesRegulation() != null && walletDetailDTO.getBreakRulesRegulation().compareTo(BigDecimal.ZERO)>0){
BigDecimal amount=mapper.sumAmountByNo(orderNo,vehicleDetail.getVehicleCompanyId());
vehicleCompanyAmount=vehicleCompanyAmount.add(walletDetailDTO.getBreakRulesRegulation());
companyWalletDetail.setAmount(walletDetailDTO.getBreakRulesRegulation());
companyWalletDetail.setCompanyId(vehicleDetail.getVehicleCompanyId());
companyWalletDetail.setBranchId(vehicleDetail.getVehicleBranchId());
companyWalletDetail.setSAmount(walletDetailDTO.getBreakRulesRegulation().add(amount));
companyWalletDetail.setSource(CompanyWalletSourceEnum.BREAK_RULES_REGULATION.getCode());
companyWalletDetail.setItype(CompanyWalletITypeEnum.REGULATION.getCode());
companyWalletDetail.setId(null);
insertSelective(companyWalletDetail);
}if (walletDetailDTO.getBreakRulesRegulation() != null && walletDetailDTO.getBreakRulesRegulation().compareTo(BigDecimal.ZERO)>0){
BigDecimal amount=mapper.sumAmountByNo(orderNo,vehicleDetail.getVehicleCompanyId());
vehicleCompanyAmount=vehicleCompanyAmount.add(walletDetailDTO.getViolateAmount());
companyWalletDetail.setAmount(walletDetailDTO.getViolateAmount());
companyWalletDetail.setCompanyId(vehicleDetail.getVehicleCompanyId());
companyWalletDetail.setBranchId(vehicleDetail.getVehicleBranchId());
companyWalletDetail.setSAmount(walletDetailDTO.getViolateAmount().add(amount));
companyWalletDetail.setSource(CompanyWalletSourceEnum.VIOLATE_AMOUNT.getCode());
companyWalletDetail.setItype(CompanyWalletITypeEnum.VIOLATE.getCode());
companyWalletDetail.setId(null);
insertSelective(companyWalletDetail);
}
//更新钱包
Long time=System.currentTimeMillis();
if (endCompany == null ){
endCompany=new CompanyWallet();
endCompany.setCompanyId(vehicleDetail.getActualEndCompanyId());
endCompany.setBalance(endCompanyAmount);
endCompany.setLastIntime(time);
endCompany.setTotalAmount(endCompanyAmount);
companyWalletBiz.insertSelective(endCompany);
}else {
endCompany.setTotalAmount(endCompany.getTotalAmount().add(endCompanyAmount));
endCompany.setBalance(endCompany.getBalance().add(endCompanyAmount));
endCompany.setLastIntime(time);
companyWalletBiz.updCompanyWallet(endCompany);
}
vehicleCompany=companyWalletBiz.selectById(vehicleDetail.getVehicleCompanyId());
if (vehicleCompany == null ){
vehicleCompany=new CompanyWallet();
vehicleCompany.setCompanyId(vehicleDetail.getVehicleCompanyId());
vehicleCompany.setBalance(vehicleCompanyAmount);
vehicleCompany.setLastIntime(time);
vehicleCompany.setTotalAmount(vehicleCompanyAmount);
companyWalletBiz.insertSelective(vehicleCompany);
}else {
vehicleCompany.setTotalAmount(vehicleCompany.getTotalAmount().add(vehicleCompanyAmount));
vehicleCompany.setBalance(vehicleCompany.getBalance().add(vehicleCompanyAmount));
vehicleCompany.setLastIntime(time);
companyWalletBiz.updCompanyWallet(vehicleCompany);
}
startCompany=companyWalletBiz.selectById(vehicleDetail.getStartCompanyId());
if (startCompany == null ){
startCompany=new CompanyWallet();
startCompany.setCompanyId(vehicleDetail.getStartCompanyId());
startCompany.setBalance(startCompanyAmount);
startCompany.setLastIntime(time);
startCompany.setTotalAmount(startCompanyAmount);
companyWalletBiz.insertSelective(startCompany);
}else {
startCompany.setTotalAmount(startCompany.getTotalAmount().add(startCompanyAmount));
startCompany.setBalance(startCompany.getBalance().add(startCompanyAmount));
startCompany.setLastIntime(time);
companyWalletBiz.updCompanyWallet(startCompany);
}
platformCompany=companyWalletBiz.selectById(walletDetailDTO.getPlatformCompanyId());
if (platformCompany == null ){
platformCompany=new CompanyWallet();
platformCompany.setCompanyId(walletDetailDTO.getPlatformCompanyId());
platformCompany.setBalance(platformCompanyAmount);
platformCompany.setLastIntime(time);
platformCompany.setTotalAmount(platformCompanyAmount);
companyWalletBiz.insertSelective(platformCompany);
}else {
platformCompany.setTotalAmount(platformCompany.getTotalAmount().add(platformCompanyAmount));
platformCompany.setBalance(platformCompany.getBalance().add(platformCompanyAmount));
platformCompany.setLastIntime(time);
companyWalletBiz.updCompanyWallet(platformCompany);
}
}
public PageDataVO<CompanyWalletDetailVo> selectList(WalletDetailDTO walletDetailDTO) {
PageHelper.startPage(walletDetailDTO.getPage(), walletDetailDTO.getLimit());
PageInfo<CompanyWalletDetailVo> branchCompanyPageInfo = new PageInfo<>(getList(walletDetailDTO));
return PageDataVO.pageInfo(branchCompanyPageInfo);
}
public List<CompanyWalletDetailVo> getList(WalletDetailDTO walletDetailDTO){
return mapper.selectList(walletDetailDTO);
}
public JSONObject getSumAmount(WalletDetailDTO walletDetailDTO){
List<Integer> itypes=new ArrayList<>();
itypes.add(1);
walletDetailDTO.setItypes(itypes);
BigDecimal amount = mapper.sumAmount(walletDetailDTO);
JSONObject jsonObject=new JSONObject();
jsonObject.put("orderAmount",amount);
itypes=new ArrayList<>();
itypes.add(2);
itypes.add(3);
itypes.add(4);
walletDetailDTO.setItypes(itypes);
amount = mapper.sumAmount(walletDetailDTO);
jsonObject.put("otherAmount",amount);
CompanyWallet companyWallet=companyWalletBiz.sumAmount(walletDetailDTO);
if (companyWallet != null ){
jsonObject.put("balance",companyWallet.getBalance());
jsonObject.put("withdrawals",companyWallet.getWithdrawals());
}
return jsonObject;
} }
} }
...@@ -2,8 +2,15 @@ package com.xxfc.platform.order.mapper; ...@@ -2,8 +2,15 @@ package com.xxfc.platform.order.mapper;
import com.xxfc.platform.order.entity.CompanyWalletDetail; import com.xxfc.platform.order.entity.CompanyWalletDetail;
import com.xxfc.platform.order.pojo.dto.WalletDetailDTO;
import com.xxfc.platform.order.pojo.vo.CompanyWalletDetailVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.common.Mapper; import tk.mybatis.mapper.common.Mapper;
import java.math.BigDecimal;
import java.util.List;
/** /**
* 收入/支持明细表,每笔的进账,出账的详细记录 * 收入/支持明细表,每笔的进账,出账的详细记录
* *
...@@ -14,4 +21,12 @@ import tk.mybatis.mapper.common.Mapper; ...@@ -14,4 +21,12 @@ import tk.mybatis.mapper.common.Mapper;
public interface CompanyWalletDetailMapper extends Mapper<CompanyWalletDetail> { public interface CompanyWalletDetailMapper extends Mapper<CompanyWalletDetail> {
@Select("SELECT IFNULL(SUM(amount),0)+IFNULL((SELECT balance FROM company_wallet WHERE company_id = #{companyId}),0) FROM company_wallet_detail WHERE cono=#{no} and company_id = #{companyId}")
BigDecimal sumAmountByNo(@Param("no")String no,@Param("companyId")Integer companyId);
List<CompanyWalletDetailVo> selectList(WalletDetailDTO walletDetailDTO);
BigDecimal sumAmount(WalletDetailDTO walletDetailDTO);
} }
...@@ -3,6 +3,7 @@ package com.xxfc.platform.order.mapper; ...@@ -3,6 +3,7 @@ package com.xxfc.platform.order.mapper;
import com.xxfc.platform.order.entity.CompanyWallet; import com.xxfc.platform.order.entity.CompanyWallet;
import com.xxfc.platform.order.pojo.dto.WalletDetailDTO;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update; import org.apache.ibatis.annotations.Update;
import tk.mybatis.mapper.common.Mapper; import tk.mybatis.mapper.common.Mapper;
...@@ -21,4 +22,7 @@ public interface CompanyWalletMapper extends Mapper<CompanyWallet> { ...@@ -21,4 +22,7 @@ public interface CompanyWalletMapper extends Mapper<CompanyWallet> {
@Update("UPDATE `company_wallet` SET `is_frozen`=#{state} WHERE `id`=#{id}" ) @Update("UPDATE `company_wallet` SET `is_frozen`=#{state} WHERE `id`=#{id}" )
void forbiddenWalletById(@Param("id") Integer id, @Param("state") Integer state); void forbiddenWalletById(@Param("id") Integer id, @Param("state") Integer state);
CompanyWallet sumAmount(WalletDetailDTO walletDetailDTO);
} }
package com.xxfc.platform.order.rest;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.rest.BaseController;
import com.xxfc.platform.order.biz.CompanyWalletDetailBiz;
import com.xxfc.platform.order.entity.CompanyWalletDetail;
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;
@RestController
@RequestMapping("wallet/detail")
public class CompanyWalletDetailController extends BaseController<CompanyWalletDetailBiz, CompanyWalletDetail> {
@RequestMapping(value = "upd", method = RequestMethod.POST)
public ObjectRestResponse refundAmount(@RequestBody CompanyWalletDetail companyWalletDetail) {
baseBiz.addOrUpd(companyWalletDetail);
return ObjectRestResponse.succ();
}
}
\ No newline at end of file
...@@ -26,6 +26,8 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -26,6 +26,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import static com.github.wxiaoqi.security.common.vo.PageDataVO.pageInfo; import static com.github.wxiaoqi.security.common.vo.PageDataVO.pageInfo;
import static com.xxfc.platform.order.entity.ShuntApply.STATUS_CNL;
import static com.xxfc.platform.order.entity.ShuntApply.STATUS_CRT;
@RestController @RestController
@RequestMapping("shuntApply") @RequestMapping("shuntApply")
...@@ -57,9 +59,32 @@ public class ShuntApplyController extends BaseController<ShuntApplyBiz, ShuntApp ...@@ -57,9 +59,32 @@ public class ShuntApplyController extends BaseController<ShuntApplyBiz, ShuntApp
throw new BaseException(ResultCode.AJAX_WECHAT_NOTEXIST_CODE); throw new BaseException(ResultCode.AJAX_WECHAT_NOTEXIST_CODE);
} }
shuntApply.setUserId(getCurrentUserIdInt()); shuntApply.setUserId(getCurrentUserIdInt());
shuntApply.setStatus(STATUS_CRT);
return add(shuntApply); return add(shuntApply);
} }
@RequestMapping(value = "/cancelApply", method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "取消申请")
public ObjectRestResponse addApply(@RequestBody CnlApplyDTO dto) {
//查询列表数据
if (StrUtil.isBlank(getCurrentUserId())) {
throw new BaseException(ResultCode.AJAX_WECHAT_NOTEXIST_CODE);
}
ShuntApply shuntApply = baseBiz.selectById(dto.getApplyId());
if(null == shuntApply) {
throw new BaseException(ResultCode.PARAM_ILLEGAL_CODE);
}
baseBiz.updateSelectiveById(new ShuntApply(){{
setId(shuntApply.getId());
setStatus(STATUS_CNL);
}});
return ObjectRestResponse.succ();
}
@RequestMapping(value = "/pageList", method = RequestMethod.GET) @RequestMapping(value = "/pageList", method = RequestMethod.GET)
@ResponseBody @ResponseBody
@ApiOperation(value = "申请列表") @ApiOperation(value = "申请列表")
...@@ -142,4 +167,9 @@ public class ShuntApplyController extends BaseController<ShuntApplyBiz, ShuntApp ...@@ -142,4 +167,9 @@ public class ShuntApplyController extends BaseController<ShuntApplyBiz, ShuntApp
public static class ApplyOrderDTO extends AddRentVehicleDTO { public static class ApplyOrderDTO extends AddRentVehicleDTO {
Integer applyId; Integer applyId;
} }
@Data
public static class CnlApplyDTO {
Integer applyId;
}
} }
\ No newline at end of file
package com.xxfc.platform.order.rest.background;
import com.github.wxiaoqi.security.admin.feign.UserFeign;
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.xxfc.platform.order.biz.CompanyWalletDetailBiz;
import com.xxfc.platform.order.entity.CompanyWalletDetail;
import com.xxfc.platform.order.pojo.dto.WalletDetailDTO;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("admin/wallet")
public class AdminCompanyWalletDetailController extends BaseController<CompanyWalletDetailBiz, CompanyWalletDetail> implements UserRestInterface {
@Autowired
UserFeign userFeign;
@Override
public UserFeign getUserFeign() {
return userFeign;
}
@RequestMapping(value = "selectList", method = RequestMethod.GET)
@ApiModelProperty(value = "营收明细列表")
public ObjectRestResponse refundAmount(WalletDetailDTO walletDetailDTO) {
return ObjectRestResponse.succ(baseBiz.selectList(walletDetailDTO));
}
@RequestMapping(value = "sumAmount", method = RequestMethod.GET)
@ApiModelProperty(value = "营收统计")
public ObjectRestResponse sumAmount(WalletDetailDTO walletDetailDTO) {
return ObjectRestResponse.succ(baseBiz.getSumAmount(walletDetailDTO));
}
}
\ No newline at end of file
...@@ -26,6 +26,7 @@ import com.xxfc.platform.order.contant.enumerate.OrderTypeEnum; ...@@ -26,6 +26,7 @@ import com.xxfc.platform.order.contant.enumerate.OrderTypeEnum;
import com.xxfc.platform.order.entity.OrderItem; import com.xxfc.platform.order.entity.OrderItem;
import com.xxfc.platform.order.entity.OrderTemplate; import com.xxfc.platform.order.entity.OrderTemplate;
import com.xxfc.platform.order.pojo.OrderAccompanyDTO; import com.xxfc.platform.order.pojo.OrderAccompanyDTO;
import com.xxfc.platform.order.pojo.dto.CompanyWalletDetailDTO;
import com.xxfc.platform.order.pojo.order.RentVehicleBO; import com.xxfc.platform.order.pojo.order.RentVehicleBO;
import com.xxfc.platform.order.pojo.order.VehicleItemDTO; import com.xxfc.platform.order.pojo.order.VehicleItemDTO;
import com.xxfc.platform.order.pojo.price.RentVehiclePriceVO; import com.xxfc.platform.order.pojo.price.RentVehiclePriceVO;
...@@ -101,6 +102,15 @@ public class OrderRentVehicleService extends AbstractOrderHandle<OrderRentVehicl ...@@ -101,6 +102,15 @@ public class OrderRentVehicleService extends AbstractOrderHandle<OrderRentVehicl
} }
public void initDetailSecond(RentVehicleBO bo) { public void initDetailSecond(RentVehicleBO bo) {
CompanyWalletDetailDTO companyWalletDetailDTO = new CompanyWalletDetailDTO();
//下单
companyWalletDetailDTO.setClosedVehicleAmout(BigDecimal.ZERO);//收车服务费
companyWalletDetailDTO.setPlatformCompanyId(0);//平台门店
companyWalletDetailDTO.setOrderExtract(BigDecimal.ZERO);//订单抽成比例
companyWalletDetailDTO.setPlatformExtract(BigDecimal.ZERO);//平台抽成比例
companyWalletDetailDTO.setVehicleExtract(BigDecimal.ZERO);//车辆收益比例
initDictionary(); initDictionary();
VehicleModel vehicleModel = vehicleFeign.get(bo.getModelId()).getData(); VehicleModel vehicleModel = vehicleFeign.get(bo.getModelId()).getData();
bo.setVehicleModel(vehicleModel); bo.setVehicleModel(vehicleModel);
......
<?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.CompanyWalletDetailMapper">
<select id="selectList" resultType="com.xxfc.platform.order.pojo.vo.CompanyWalletDetailVo" parameterType="com.xxfc.platform.order.pojo.dto.WalletDetailDTO">
SELECT
d.cono,
d.itype,
d.type,
c.`name` as companyName,
ci.`name` as branchName,
SUM(d.amount) as amount,
MAX(s_amount)as sAmount
FROM company_wallet_detail d
LEFT JOIN branch_company c ON d.company_id=c.id
LEFT JOIN company_info ci ON d.branch_id=ci.id
<where>
d.itype != 5
<if test="companyId != null and companyId > 0">
and d.company_id=#{companyId}
</if>
<if test="branchId != null and branchId > 0">
and d.branch_id=#{branchId}
</if>
<if test="startTime != null and startTime > 0">
and d.crt_time > = {startTime}
</if>
<if test="endTime != null and endTime > 0">
and d.crt_time &lt;= {endTime}
</if>
<if test="dataCompanyIds != null and dataCompanyIds.size() > 0">
and d.company_id= in
<foreach collection="dataCompanyIds" item="item" separator="," open="(" close=")">
#{item}
</foreach>
</if>
<if test="dataCorporationIds != null and dataCorporationIds.size() > 0">
and d.branch_id in
<foreach collection="dataCorporationIds" item="item" separator="," open="(" close=")">
#{item}
</foreach>
</if>
</where>
GROUP BY d.cono,d.itype
order by d.id desc
</select>
<select id="sumAmount" resultType="BigDecimal" parameterType="com.xxfc.platform.order.pojo.dto.WalletDetailDTO">
SELECT IFNULL(SUM(amount),0) as amount FROM company_wallet_detail
<where>
itype in
<foreach collection="itypes" item="item" separator="," open="(" close=")">
#{item}
</foreach>
<if test="companyId != null and companyId > 0">
and company_id=#{companyId}
</if>
<if test="branchId != null and branchId > 0">
and branch_id=#{branchId}
</if>0
<if test="dataCompanyIds != null and dataCompanyIds.size() > 0">
and company_id in
<foreach collection="dataCompanyIds" item="item" separator="," open="(" close=")">
#{item}
</foreach>
</if>
<if test="dataCorporationIds != null and dataCorporationIds.size() > 0">
and branch_id in
<foreach collection="dataCorporationIds" item="item" separator="," open="(" close=")">
#{item}
</foreach>
</if>
</where>
</select>
</mapper>
\ No newline at end of file
...@@ -45,4 +45,30 @@ ...@@ -45,4 +45,30 @@
</where> </where>
</update> </update>
<select id="sumAmount" resultType="com.xxfc.platform.order.entity.CompanyWallet" parameterType="com.xxfc.platform.order.pojo.dto.WalletDetailDTO">
SELECT IFNULL(SUM(w.balance),0) as balance,IFNULL(SUM(w.withdrawals),0) as withdrawals FROM company_wallet w
LEFT JOIN branch_company c ON w.company_id=c.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>
</select>
</mapper> </mapper>
\ No newline at end of file
...@@ -52,9 +52,14 @@ public interface VehicleFeign { ...@@ -52,9 +52,14 @@ public interface VehicleFeign {
@RequestMapping(value = "/vehicleModel/app/addScore", method = RequestMethod.GET) @RequestMapping(value = "/vehicleModel/app/addScore", method = RequestMethod.GET)
public RestResponse addScore(@RequestParam(value = "id") Integer id, @RequestParam(value = "score") Integer score); public RestResponse addScore(@RequestParam(value = "id") Integer id, @RequestParam(value = "score") Integer score);
//租车预约(无需审核)
@RequestMapping(value = "/vehicleInfo/rent/book/vehicle", method = RequestMethod.POST) @RequestMapping(value = "/vehicleInfo/rent/book/vehicle", method = RequestMethod.POST)
public ObjectRestResponse<VehicleBookRecord> rentApplyVehicle(@RequestBody RentVehicleBookDTO rentVehicleBookDTO); public ObjectRestResponse<VehicleBookRecord> rentApplyVehicle(@RequestBody RentVehicleBookDTO rentVehicleBookDTO);
//租车预约(需要审核)
@RequestMapping(value = "/vehicleInfo/apply/book/vehicle", method = RequestMethod.POST)
public ObjectRestResponse<VehicleBookRecord> applyBookVehicle(@RequestBody RentVehicleBookDTO rentVehicleBookDTO);
@RequestMapping(value = "/branchCompany/app/unauth/detail/{id}", method = RequestMethod.GET) @RequestMapping(value = "/branchCompany/app/unauth/detail/{id}", method = RequestMethod.GET)
public ObjectRestResponse<CompanyDetail> getCompanyDetail(@PathVariable(value = "id") Integer id); public ObjectRestResponse<CompanyDetail> getCompanyDetail(@PathVariable(value = "id") Integer id);
......
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