Commit 727e682f authored by hezhen's avatar hezhen

123

parent ac623f80
package com.github.wxiaoqi.security.admin.constant.enumerate;
import java.util.HashMap;
import java.util.Map;
public enum CompanyWalletITypeEnum {
COMPANY(1, "商家"),
CATH(2, "提现"),
;
/**
* 编码
*/
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
package com.github.wxiaoqi.security.admin.dto;
import com.github.wxiaoqi.security.common.vo.DataInter;
import com.github.wxiaoqi.security.common.vo.PageParam;
import lombok.*;
import java.util.List;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class BaseOrderAcceptDetailedDTO extends PageParam implements DataInter {
String orderNo;
List<Integer> companyIds;
List<Integer> dataCorporationIds;
List<Integer> dataCompanyIds;
Integer bizType;
List<Integer> divisionTypes;
}
package com.github.wxiaoqi.security.admin.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.util.List;
/**
* 门店收支明细DTO
* @author libin
* @version 1.0
* @description
* @data 2019/12/25 14:53
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class CompanyWalletDTO extends PageParam implements DataInter {
@ApiModelProperty("门店")
private Integer companyId;
@ApiModelProperty("企业")
private Integer branchId;
List<Integer> dataCorporationIds;
List<Integer> dataCompanyIds;
Integer bizType;
}
package com.github.wxiaoqi.security.admin.dto;
import com.alibaba.fastjson.JSONObject;
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 WalletCathApplyDTO {
@ApiModelProperty("门店")
private List<JSONObject> companyIds;
@ApiModelProperty("提现金额")
private BigDecimal amount;
@ApiModelProperty("提现账号")
private String accountNumber;
@ApiModelProperty("账号名称")
private String accountName;
}
package com.github.wxiaoqi.security.admin.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.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("提现状态:0-未提现;1-已提现")
private Integer status;
@ApiModelProperty("开始时间")
private Long startTime;
@ApiModelProperty("结束时间")
private Long endTime;
@ApiModelProperty("提现单号")
private String orderNo;
List<Integer> dataCorporationIds;
List<Integer> dataCompanyIds;
Integer bizType;
}
package com.github.wxiaoqi.security.admin.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.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;
Integer bizType;
}
package com.github.wxiaoqi.security.admin.entity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* 门店钱包
*
* @author zjw
* @email 18178966185@163.com
* @date 2019-07-11 14:14:54
*/
@Data
@Table(name = "company_wallet")
public class CompanyWallet implements Serializable {
private static final long serialVersionUID = 1L;
/**
* id
*/
@Column(name = "id")
@ApiModelProperty(value = "id")
private Integer id;
/**
* 用户ID
*/
@Id
@GeneratedValue(generator = "JDBC")
@ApiModelProperty("门店ID")
private Integer companyId;
/**
* 余额(分)
*/
@Column(name = "balance")
@ApiModelProperty(value = "余额(元)")
private BigDecimal balance;
/**
* 支付密码
*/
@Column(name = "pay_password")
@ApiModelProperty(value = "支付密码")
private String payPassword;
/**
* 已提现金额
*/
@Column(name = "withdrawals")
@ApiModelProperty(value = "已提现金额")
private BigDecimal withdrawals;
/**
* 进账总额(分)
*/
@Column(name = "total_amount")
@ApiModelProperty(value = "进账总额(元)")
private BigDecimal totalAmount;
/**
* 今日收益
*/
@Column(name = "today_amount")
@ApiModelProperty(value = "今日收益")
private BigDecimal todayAmount;
/**
* 未入账金额
*/
@Column(name = "unbooked")
@ApiModelProperty(value = "未入账金额")
private BigDecimal unbooked;
/**
* 是否冻结:0-正常,1-冻结
*/
@Column(name = "is_frozen")
@ApiModelProperty(value = "是否冻结:0-正常,1-冻结")
private Integer isFrozen;
/**
* 最后进账时间
*/
@Column(name = "last_intime")
@ApiModelProperty(value = "最后进账时间")
private Long lastIntime;
/**
* 创建时间
*/
@Column(name = "crt_time")
@ApiModelProperty(value = "创建时间", hidden = true )
private Long crtTime;
/**
* 更新时间
*/
@Column(name = "upd_time")
@ApiModelProperty(value = "更新时间", hidden = true )
private Long updTime;
/**
* 版本
*/
@Column(name = "version")
@ApiModelProperty(value = "版本")
private Integer version;
}
package com.github.wxiaoqi.security.admin.entity;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* 门店钱包提现表
*
* @author zjw
* @email 18178966185@163.com
* @date 2019-07-11 14:14:54
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Table(name = "company_wallet_cath")
public class CompanyWalletCath implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键ID
*/
@Id
@GeneratedValue(generator = "JDBC")
@ApiModelProperty("主键ID")
private Long id;
/**
* 用户iD
*/
@Column(name = "company_id")
@ApiModelProperty(value = "门店ID")
private Integer companyId;
/**
* 提现类别,第三方提现类别(0-微信,1-支付宝,2-银行卡)
*/
@Column(name = "cath_type")
@ApiModelProperty(value = "提现类别,第三方提现类别(0-微信,1-支付宝,2-银行卡)")
private Integer cathType;
@Column(name = "account_number")
@ApiModelProperty(value = "用户账号")
private String accountNumber;
@Column(name = "cono")
@ApiModelProperty(value = "提现单号")
private String cono;
/**
* 提现金额
*/
@Column(name = "balance")
@ApiModelProperty(value = "当前钱包余额")
private BigDecimal balance;
/**
* 提现金额
*/
@Column(name = "amount")
@ApiModelProperty(value = "提现金额")
private BigDecimal amount;
/**
* 到账金额
*/
@Column(name = "real_amount")
@ApiModelProperty(value = "到账金额")
private BigDecimal realAmount;
/**
* 手续费
*/
@Column(name = "commission")
@ApiModelProperty(value = "手续费")
private BigDecimal commission;
/**
* 订单状态:0-未提现,待审核,1-已审核
*/
@Column(name = "stauts")
@ApiModelProperty(value = "订单状态:0-未提现,待审核,1-已审核")
private Integer stauts;
/**
* 失败原因
*/
@Column(name = "reason")
@ApiModelProperty(value = "失败原因")
private String reason;
/**
* 提现日期
*/
@Column(name = "crt_time")
@ApiModelProperty(value = "提现日期", hidden = true)
private Long crtTime;
/**
* 审核日期
*/
@Column(name = "finish_time")
@ApiModelProperty(value = "审核日期")
private Long finishTime;
/**
* 操作者ID
*/
@Column(name = "upd_user")
@ApiModelProperty(value = "操作者ID")
private String updUser;
@Column(name = "order_no")
@ApiModelProperty(value = "第三方订单号:如微信,支付宝,银行卡等")
private String orderNo;
@Column(name = "account_name")
private String accountName;
@Column(name = "withdraw_way")
@ApiModelProperty(value = "提现方式 1:线下自动 2:线下手动 3:线上自动")
private Integer withdrawWay;
@Column(name = "real_reason")
private String realReason;
}
package com.github.wxiaoqi.security.admin.entity;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* 门店收支明细
*
* @author zjw
* @email 18178966185@163.com
* @date 2019-07-11 14:14:54
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Table(name = "company_wallet_detail")
public class CompanyWalletDetail implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(generator = "JDBC")
@ApiModelProperty("主键ID")
private Integer id;
@Column(name = "cono")
@ApiModelProperty(value = "订单号或提现号")
private String cono;
@Column(name = "itype")
@ApiModelProperty(value = "收支分类")
private Integer itype;
@Column(name = "source")
@ApiModelProperty(value = "收支类型:见枚举")
private Integer source;
@Column(name = "type")
@ApiModelProperty(value = "类型:1-收入;2-支出")
private Integer type;
@Column(name = "amount")
@ApiModelProperty(value = "收入/支出的金额(分)")
private BigDecimal amount;
@Column(name = "branch_id")
@ApiModelProperty(value = "企业id")
private Long branchId;
@Column(name = "company_id")
@ApiModelProperty(value = "门店id")
private Integer companyId;
@Column(name = "s_amount")
@ApiModelProperty(value = "门店剩余金额")
private BigDecimal sAmount;
@Column(name = "crt_time")
@ApiModelProperty(value = "操作时间", hidden = true )
private Long crtTime;
@Column(name = "is_del")
@ApiModelProperty(value = "是否删除:0-正常;1-删除")
private Integer isDel;
}
package com.github.wxiaoqi.security.admin.vo;
import com.github.wxiaoqi.security.admin.entity.BaseOrderAcceptDetailed;
import lombok.Data;
@Data
public class BaseOrderAcceptDetailedVO extends BaseOrderAcceptDetailed {
}
package com.github.wxiaoqi.security.admin.vo;
import com.github.wxiaoqi.security.admin.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.github.wxiaoqi.security.admin.vo;
import com.github.wxiaoqi.security.admin.constant.enumerate.CompanyWalletITypeEnum;
import com.github.wxiaoqi.security.admin.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.github.wxiaoqi.security.admin.vo;
import com.github.wxiaoqi.security.admin.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;
}
......@@ -4,6 +4,7 @@ import com.github.wxiaoqi.security.admin.bo.UserIncomeBo;
import com.github.wxiaoqi.security.admin.dto.*;
import com.github.wxiaoqi.security.admin.entity.*;
import com.github.wxiaoqi.security.admin.mapper.BaseOrderAcceptDetailedMapper;
import com.github.wxiaoqi.security.admin.vo.BaseOrderAcceptDetailedVO;
import com.github.wxiaoqi.security.admin.vo.SellingWalletPagVo;
import com.github.wxiaoqi.security.admin.vo.SellingWalletVo;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
......@@ -65,6 +66,9 @@ public class BaseOrderAcceptDetailedBiz extends BaseBiz<BaseOrderAcceptDetailedM
@Autowired
OrderFeign orderFeign;
@Autowired
CompanyWalletDetailBiz companyWalletDetailBiz;
//计算用户拥金
@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
......@@ -92,9 +96,11 @@ public class BaseOrderAcceptDetailedBiz extends BaseBiz<BaseOrderAcceptDetailedM
orderWaterDTO.setOrderAmount(acceptAmount);
finishOrderAccept(orderWaterDTO,orderDetailDTO);
sellingWaterBiz.updWalletByOrderId(orderWaterDTO);
companyWalletDetailBiz.addOrUpd(orderWaterDTO);
} else {
refundOrderAccept(orderWaterDTO);
sellingWaterBiz.updWalletByOrderId(orderWaterDTO);
companyWalletDetailBiz.addOrUpd(orderWaterDTO);
}
}
......@@ -277,9 +283,7 @@ public class BaseOrderAcceptDetailedBiz extends BaseBiz<BaseOrderAcceptDetailedM
Integer orderType = orderDetailDTO.getOrderType() == null ? 0 : orderDetailDTO.getOrderType();
BigDecimal unbooked = amount;
log.info("订单完成分账----finishOrderWater----orderId====" + orderId + "---amount==" + amount + "---unbooked==" + unbooked);
if (orderType == 1) {
payOrderFAccept(orderWaterDTO,orderDetailDTO);
}
log.info("订单完成分账----finishOrderWater--------orderId===" + orderId + "----amount====" + amount + "--orderType===" + orderType);
}
......@@ -318,22 +322,40 @@ public class BaseOrderAcceptDetailedBiz extends BaseBiz<BaseOrderAcceptDetailedM
}
public void othderAccept(OrderDetailDTO orderDetailDTO){
BaseOrderAcceptDetailed acceptDetailed = new BaseOrderAcceptDetailed();
acceptDetailed.setOrderNo(orderDetailDTO.getOrderNo());
acceptDetailed.setDivisionType(5);
acceptDetailed=selectOne(acceptDetailed);
OrderRentVehicleDetail rentVehicleDetail = orderDetailDTO.getRentVehicleDetail();
BaseOrderAcceptDetailed acceptDetailed=new BaseOrderAcceptDetailed();
BeanUtils.copyProperties(orderDetailDTO,acceptDetailed);
acceptDetailed.setMchId(rentVehicleDetail.getVehicleManageCompanyId());
acceptDetailed.setOrderAmount(orderDetailDTO.getAcceptAmount());
acceptDetailed.setAddTime(System.currentTimeMillis());
acceptDetailed.setStatusTime(System.currentTimeMillis());
acceptDetailed.setStatus(1);
if (acceptDetailed != null ){
if (orderDetailDTO.getOrderStatus().equals(OrderDetailDTO.DELAY)){
BigDecimal violateAmount = orderDetailDTO.getViolateAmount() == null ? BigDecimal.ZERO :orderDetailDTO.getViolateAmount() ; //违约金
if (violateAmount.compareTo(BigDecimal.ZERO) > 0 && orderDetailDTO.getOrderStatus().equals(OrderDetailDTO.DELAY)){
acceptDetailed.setDivisionAmount(orderDetailDTO.getViolateAmount());
acceptDetailed.setDivisionType(8);
insertSelective(acceptDetailed);
}
BigDecimal lossSpecifiedAmount = orderDetailDTO.getLossSpecifiedAmount() == null ? BigDecimal.ZERO :orderDetailDTO.getLossSpecifiedAmount() ; //定损
if (lossSpecifiedAmount.compareTo(BigDecimal.ZERO) > 0 ){
acceptDetailed.setDivisionAmount(lossSpecifiedAmount);
acceptDetailed.setDivisionType(6);
acceptDetailed.setId(null);
acceptDetailed.setStatus(1);
acceptDetailed.setStatusTime(System.currentTimeMillis());
insertSelective(acceptDetailed);
}
BigDecimal breakRulesRegulation = orderDetailDTO.getLossSpecifiedAmount() == null ? BigDecimal.ZERO :orderDetailDTO.getBreakRulesRegulation() ; //违章
if (breakRulesRegulation.compareTo(BigDecimal.ZERO) > 0 ){
acceptDetailed.setDivisionAmount(breakRulesRegulation);
acceptDetailed.setDivisionType(7);
insertSelective(acceptDetailed);
}
}
}
public List<BaseOrderAcceptDetailedVO> getList(BaseOrderAcceptDetailedDTO acceptDetailedDTO){
return mapper.selectList(acceptDetailedDTO);
}
}
\ No newline at end of file
package com.github.wxiaoqi.security.admin.biz;
import com.github.wxiaoqi.security.admin.dto.CompanyWalletDTO;
import com.github.wxiaoqi.security.admin.dto.WalletDetailDTO;
import com.github.wxiaoqi.security.admin.entity.CompanyWallet;
import com.github.wxiaoqi.security.admin.mapper.CompanyWalletMapper;
import com.github.wxiaoqi.security.admin.vo.CompanyWalletVo;
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 lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.List;
@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);
}
//检查提现下一步操作
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(CompanyWalletDTO walletDTO){
return mapper.selectList(walletDTO);
}
public PageDataVO<CompanyWalletVo> selectList(CompanyWalletDTO walletDTO) {
return PageDataVO.pageInfo(walletDTO.getPage(), walletDTO.getLimit(), () -> getList(walletDTO));
}
}
package com.github.wxiaoqi.security.admin.biz;
import cn.hutool.core.lang.Snowflake;
import com.alibaba.fastjson.JSONObject;
import com.github.wxiaoqi.security.admin.constant.WithDrawStatusEnum;
import com.github.wxiaoqi.security.admin.constant.enumerate.CompanyWalletITypeEnum;
import com.github.wxiaoqi.security.admin.dto.WalletCathApplyDTO;
import com.github.wxiaoqi.security.admin.dto.WalletCathDTO;
import com.github.wxiaoqi.security.admin.entity.CompanyWallet;
import com.github.wxiaoqi.security.admin.entity.CompanyWalletCath;
import com.github.wxiaoqi.security.admin.entity.CompanyWalletDetail;
import com.github.wxiaoqi.security.admin.mapper.CompanyWalletCathMapper;
import com.github.wxiaoqi.security.admin.vo.CompanyWalletCathVo;
import com.github.wxiaoqi.security.admin.vo.CompanyWalletDetailVo;
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 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 org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
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));
}
@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
public void applyCathList(WalletCathApplyDTO walletCathApplyDTO){
if (walletCathApplyDTO == null) {
throw new BaseException("参数不能为空",ResultCode.NULL_CODE);
}
List<JSONObject> companyIds = walletCathApplyDTO.getCompanyIds();
for (JSONObject object:companyIds){
CompanyWalletCath walletCathDTO=new CompanyWalletCath();
BeanUtils.copyProperties(walletCathApplyDTO,walletCathDTO);
walletCathDTO.setCompanyId(object.getInteger("companyId"));
walletCathDTO.setAmount(object.getBigDecimal("amount"));
applyCath(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");
}
}
package com.github.wxiaoqi.security.admin.biz;
import cn.hutool.json.JSONObject;
import com.github.wxiaoqi.security.admin.constant.enumerate.CompanyWalletITypeEnum;
import com.github.wxiaoqi.security.admin.dto.BaseOrderAcceptDetailedDTO;
import com.github.wxiaoqi.security.admin.dto.OrderWaterDTO;
import com.github.wxiaoqi.security.admin.dto.WalletDetailDTO;
import com.github.wxiaoqi.security.admin.entity.CompanyWalletDetail;
import com.github.wxiaoqi.security.admin.mapper.CompanyWalletDetailMapper;
import com.github.wxiaoqi.security.admin.vo.BaseOrderAcceptDetailedVO;
import com.github.wxiaoqi.security.admin.vo.CompanyWalletDetailVo;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.util.CollectorsUtil;
import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.github.wxiaoqi.security.admin.entity.CompanyWallet;
import com.xxfc.platform.order.contant.enumerate.CompanyWalletSourceEnum;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
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;
import java.util.Map;
import java.util.stream.Collectors;
@Service
@Slf4j
public class CompanyWalletDetailBiz extends BaseBiz<CompanyWalletDetailMapper, CompanyWalletDetail> {
@Autowired
BaseOrderAcceptDetailedBiz acceptDetailedBiz;
@Autowired
CompanyWalletBiz companyWalletBiz;
@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
public void addOrUpd(OrderWaterDTO orderWaterDTO){
if (StringUtils.isBlank(orderWaterDTO.getOrderNo())){
throw new BaseException("订单号不存在",ResultCode.FAILED_CODE);
}
List<Integer> divisionTypes=new ArrayList<>();
divisionTypes.add(3);
divisionTypes.add(5);
divisionTypes.add(6);
divisionTypes.add(7);
divisionTypes.add(8);
BaseOrderAcceptDetailedDTO acceptDetailedDTO = BaseOrderAcceptDetailedDTO
.builder()
.orderNo(orderWaterDTO.getOrderNo())
.divisionTypes(divisionTypes)
.build();
acceptDetailedDTO.setOrderNo(orderWaterDTO.getOrderNo());
List<BaseOrderAcceptDetailedVO> list = acceptDetailedBiz.getList(acceptDetailedDTO);
List<CompanyWalletDetail> walletDetails = new ArrayList<>();
if (list.size() > 0){
for (BaseOrderAcceptDetailedVO acceptDetailedVO : list){
BigDecimal divisionAmount = acceptDetailedVO.getDivisionAmount() == null ? BigDecimal.ZERO : acceptDetailedVO.getDivisionAmount();
if (divisionAmount .compareTo(BigDecimal.ZERO) > 0 ){
Integer entryType = acceptDetailedVO.getEntryType() == null ? 0 : acceptDetailedVO.getEntryType();
if (entryType != 1){
log.info("----线下分账不入店铺明细----orderNo==="+acceptDetailedVO.getOrderNo()+"-----店铺id==="+acceptDetailedVO.getMchId());
continue;
}
CompanyWallet companyWallet=companyWalletBiz.selectById(acceptDetailedVO.getMchId());
BigDecimal companyAmount=BigDecimal.ZERO;
if (companyWallet != null){
companyAmount=companyWallet.getBalance();
}
CompanyWalletDetail companyWalletDetail = new CompanyWalletDetail();
companyWalletDetail.setCono(acceptDetailedVO.getOrderNo());
companyWalletDetail.setAmount(divisionAmount);
companyWalletDetail.setCompanyId(acceptDetailedVO.getMchId());
companyWalletDetail.setSAmount(companyAmount);
companyWalletDetail.setSource(setItype(acceptDetailedVO.getDivisionType()));
companyWalletDetail.setItype(CompanyWalletITypeEnum.COMPANY.getCode());
insertSelective(companyWalletDetail);
walletDetails.add(companyWalletDetail);
}
}
}
if (walletDetails.size() > 0){
Map<Integer, BigDecimal> amountSum = walletDetails.stream().filter(t -> t.getAmount() != null)
.collect(Collectors.groupingBy(CompanyWalletDetail::getCompanyId, CollectorsUtil.summingBigDecimal(CompanyWalletDetail::getAmount)));
amountSum.forEach((k,v) -> updCompanyWallet(k,v));
}
}
public PageDataVO<CompanyWalletDetailVo> selectList(WalletDetailDTO walletDetailDTO) {
return PageDataVO.pageInfo(walletDetailDTO.getPage(), walletDetailDTO.getLimit(), () -> getList(walletDetailDTO));
}
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;
}
//更新钱包
public void updCompanyWallet(Integer companyId,BigDecimal amount){
CompanyWallet companyWallet = companyWalletBiz.selectById(companyId);
Long time=System.currentTimeMillis();
if (companyWallet == null ){
companyWallet=new CompanyWallet();
companyWallet.setCompanyId(companyId);
companyWallet.setBalance(amount);
companyWallet.setLastIntime(time);
companyWallet.setTotalAmount(amount);
companyWalletBiz.insertSelective(companyWallet);
}else {
companyWallet.setTotalAmount(companyWallet.getTotalAmount().add(amount));
companyWallet.setBalance(companyWallet.getBalance().add(amount));
companyWallet.setLastIntime(time);
companyWalletBiz.updCompanyWallet(companyWallet);
}
}
public Integer setItype(Integer divisionType){
Integer source = 0;
switch (divisionType){
case 3 :
source = CompanyWalletSourceEnum.WATER.getCode();
break;
case 5 :
source = CompanyWalletSourceEnum.VEHICLE.getCode();
break;
case 6 :
source = CompanyWalletSourceEnum.LOSS.getCode();
break;
case 7 :
source = CompanyWalletSourceEnum.REGULATION.getCode();
break;
case 8 :
source = CompanyWalletSourceEnum.VIOLATE.getCode();
break;
}
return source;
}
}
package com.github.wxiaoqi.security.admin.mapper;
import com.github.wxiaoqi.security.admin.dto.BaseOrderAcceptDetailedDTO;
import com.github.wxiaoqi.security.admin.entity.BaseOrderAcceptDetailed;
import com.github.wxiaoqi.security.admin.vo.BaseOrderAcceptDetailedVO;
import tk.mybatis.mapper.common.Mapper;
import java.util.List;
/**
* 订单分账表
*
......@@ -12,4 +16,7 @@ import tk.mybatis.mapper.common.Mapper;
*/
public interface BaseOrderAcceptDetailedMapper extends Mapper<BaseOrderAcceptDetailed> {
List<BaseOrderAcceptDetailedVO> selectList(BaseOrderAcceptDetailedDTO acceptDetailedDTO);
}
package com.github.wxiaoqi.security.admin.mapper;
import com.github.wxiaoqi.security.admin.dto.WalletCathDTO;
import com.github.wxiaoqi.security.admin.entity.CompanyWalletCath;
import com.github.wxiaoqi.security.admin.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;
/**
* 钱包提现表
*
* @author zjw
* @email 18178966185@163.com
* @date 2019-07-11 14:14:54
*/
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);
}
package com.github.wxiaoqi.security.admin.mapper;
import com.github.wxiaoqi.security.admin.dto.WalletDetailDTO;
import com.github.wxiaoqi.security.admin.entity.CompanyWalletDetail;
import com.github.wxiaoqi.security.admin.vo.CompanyWalletDetailVo;
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;
/**
* 收入/支持明细表,每笔的进账,出账的详细记录
*
* @author zjw
* @email 18178966185@163.com
* @date 2019-07-11 14:14:54
*/
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);
}
package com.github.wxiaoqi.security.admin.mapper;
import com.github.wxiaoqi.security.admin.dto.CompanyWalletDTO;
import com.github.wxiaoqi.security.admin.dto.WalletDetailDTO;
import com.github.wxiaoqi.security.admin.entity.CompanyWallet;
import com.github.wxiaoqi.security.admin.vo.CompanyWalletVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import tk.mybatis.mapper.common.Mapper;
import java.util.List;
/**
* 我的钱包
*
* @author zjw
* @email 18178966185@163.com
* @date 2019-07-11 14:14:54
*/
public interface CompanyWalletMapper extends Mapper<CompanyWallet> {
void updMyWater(CompanyWallet companyWallet);
@Update("UPDATE `company_wallet` SET `is_frozen`=#{state} WHERE `id`=#{id}" )
void forbiddenWalletById(@Param("id") Integer id, @Param("state") Integer state);
CompanyWallet sumAmount(WalletDetailDTO walletDetailDTO);
List<CompanyWalletVo> selectList(CompanyWalletDTO walletDTO);
}
<?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.github.wxiaoqi.security.admin.mapper.BaseOrderAcceptDetailedMapper">
<select id="selectList" parameterType="com.github.wxiaoqi.security.admin.entity.BaseOrderAcceptDetailed" resultType="com.github.wxiaoqi.security.admin.vo.BaseOrderAcceptDetailedVO">
SELECT
r.*,
SUM(r.zDivisionAmount)-SUM(r.fDivisionAmount) as divisionAmount
FROM
(
SELECT mch_id,order_no,order_id,user_id,division_type,entry_type,order_amount,(division_amount-fee) as zDivisionAmount, 0 as fDivisionAmount,fee,status_time FROM base_order_accept_detailed
WHERE type=1 AND order_no=#{orderNo} AND `status`=1
<if test="divisionTypes != null and divisionTypes.size() > 0">
and division_type in
<foreach collection="divisionTypes" item="divisionType" open="(" separator="," close=")">
#{divisionType}
</foreach>
</if>
UNION ALL
SELECT mch_id,order_no,order_id,user_id,division_type,entry_type,order_amount,0 as zDivisionAmount, (division_amount-fee) as fDivisionAmount,fee,status_time FROM base_order_accept_detailed
WHERE type=2 AND order_no=#{orderNo} AND `status`=1
<if test="divisionTypes != null and divisionTypes.size() > 0">
and division_type in
<foreach collection="divisionTypes" item="divisionType" open="(" separator="," close=")">
#{divisionType}
</foreach>
</if>
) r
GROUP BY r.division_type
</select>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.xxfc.platform.order.mapper.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="status != null ">
and
<choose>
<when test="status == 0">
wc.stauts in (0 ,2)
</when>
<otherwise>
wc.stauts =#{status}
</otherwise>
</choose>
</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
<?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>
<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
<?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.github.wxiaoqi.security.admin.mapper.CompanyWalletMapper">
<update id="updMyWater" parameterType="com.github.wxiaoqi.security.admin.entity.CompanyWallet">
update company_wallet
<set>
<if test=" companyId != null and companyId != '' ">
company_id=#{companyId},
</if>
<if test="balance!=null ">
balance=#{balance},
</if>
<if test="withdrawals!=null and withdrawals!='' ">
withdrawals=#{withdrawals},
</if>
<if test="totalAmount!=null and totalAmount!='' ">
total_amount=#{totalAmount},
</if>
<if test="todayAmount!=null and todayAmount!='' ">
today_amount=#{todayAmount},
</if>
<if test="unbooked!=null and unbooked!='' ">
unbooked=#{unbooked},
</if>
<if test="isFrozen!=null and isFrozen!='' ">
is_frozen=#{isFrozen},
</if>
<if test="lastIntime!=null and lastIntime!='' ">
last_intime=#{lastIntime},
</if>
<if test="crtTime!=null and crtTime!='' ">
crt_time=#{crtTime},
</if>
<if test="updTime!=null and updTime!='' ">
upd_time=#{updTime},
</if>
<if test="version!=null and version!='' ">
version=version+1,
</if>
</set>
<where>
id=#{id} and version=#{version}
</where>
</update>
<select id="sumAmount" resultType="com.github.wxiaoqi.security.admin.entity.CompanyWallet" parameterType="com.github.wxiaoqi.security.admin.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>
<select id="selectList" resultType="com.github.wxiaoqi.security.admin.vo.CompanyWalletVo" parameterType="com.github.wxiaoqi.security.admin.dto.CompanyWalletDTO">
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
......@@ -4,14 +4,13 @@ import java.util.HashMap;
import java.util.Map;
public enum CompanyWalletSourceEnum {
CLOSED_VEHICLE(1, "收车服务费"),
DAMAGE_SAFE(2, "不计免赔费"),
RENT_VEHICLE(3, "车辆租赁费"),
ORDER_COMSSION(4, "订单抽成"),
PLATFORM_COMSSION(5, "平台抽成"),
LOSS_SPECIFIED(6, "定损费"),
BREAK_RULES_REGULATION(7, "违章费"),
VIOLATE_AMOUNT(8, "违约金"),
VEHICLE(1, "商家订单"),
WATER(2, "上级商家拥金"),
VIOLATE(3, "违约金"),
REGULATION(4, "违章补偿"),
LOSS(5, "定损"),
CATH(6, "提现"),
;
/**
* 编码
......
......@@ -53,6 +53,12 @@ public class OrderDetailDTO {
private Integer orderId;
@ApiModelProperty("订单id")
private Integer goodsDepositType;
@ApiModelProperty("订单状态")
private Integer orderStatus = PAY;
......
......@@ -3,7 +3,7 @@
<mapper namespace="com.xxfc.platform.order.mapper.CompanyWalletMapper">
<update id="updMyWater" parameterType="com.xxfc.platform.order.entity.CompanyWallet">
<update id="updMyWater" parameterType="com.github.wxiaoqi.security.admin.entity.CompanyWallet">
update company_wallet
<set>
<if test=" companyId != null and companyId != '' ">
......@@ -46,7 +46,7 @@
</update>
<select id="sumAmount" resultType="com.xxfc.platform.order.entity.CompanyWallet" parameterType="com.xxfc.platform.order.pojo.dto.WalletDetailDTO">
<select id="sumAmount" resultType="com.github.wxiaoqi.security.admin.entity.CompanyWallet" parameterType="com.github.wxiaoqi.security.admin.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>
......@@ -73,7 +73,7 @@
<select id="selectList" resultType="com.xxfc.platform.order.pojo.vo.CompanyWalletVo" parameterType="com.xxfc.platform.order.pojo.dto.WalletDTO">
<select id="selectList" resultType="com.github.wxiaoqi.security.admin.vo.CompanyWalletVo" parameterType="com.github.wxiaoqi.security.admin.dto.WalletDTO">
SELECT
w.*,
c.`name` as companyName,
......
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