Commit a8cca14d authored by 周健威's avatar 周健威

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

parents b648c373 a4919fdb
...@@ -4,8 +4,10 @@ import java.util.HashMap; ...@@ -4,8 +4,10 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
public enum CompanyWalletITypeEnum { public enum CompanyWalletITypeEnum {
COMPANY(1, "商家"), COMPANY(1, "订单收入"),
CATH(2, "提现"), REGULATION(2, "违章收入"),
CATH(3, "订单提现"),
REGULATION_CATH(4, "违章提现"),
; ;
/** /**
* 编码 * 编码
......
...@@ -25,5 +25,7 @@ public class BaseOrderAcceptDetailedDTO extends PageParam implements DataInter { ...@@ -25,5 +25,7 @@ public class BaseOrderAcceptDetailedDTO extends PageParam implements DataInter {
private Integer acceptId; private Integer acceptId;
private Integer iType;
} }
package com.github.wxiaoqi.security.admin.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.math.BigDecimal;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/7/12 9:20
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class CompanyAccountDTO {
@ApiModelProperty("店铺id")
private Integer companyId;
@ApiModelProperty(value = "银行账号")
private String bankAccount;
@ApiModelProperty(value = "开户名")
private String bankName;
@ApiModelProperty(value = "开户行")
private String bank;
}
package com.github.wxiaoqi.security.admin.dto;
import lombok.Data;
/**
* 店铺钱包设置密码
*/
@Data
public class CompanyWalletPwdDTO {
private Integer companyId;
private String phone;
private String mobilecod;
private String password;
private Integer type;
}
\ No newline at end of file
...@@ -25,8 +25,8 @@ public class WalletCathApplyDTO { ...@@ -25,8 +25,8 @@ public class WalletCathApplyDTO {
@ApiModelProperty("门店") @ApiModelProperty("营收Id")
private List<JSONObject> companyIds; private Integer revenueId;
@ApiModelProperty("提现金额") @ApiModelProperty("提现金额")
...@@ -40,6 +40,9 @@ public class WalletCathApplyDTO { ...@@ -40,6 +40,9 @@ public class WalletCathApplyDTO {
@ApiModelProperty("账号名称") @ApiModelProperty("账号名称")
private String accountName; private String accountName;
@ApiModelProperty("开户名")
private String bank;
......
...@@ -23,7 +23,8 @@ import java.util.List; ...@@ -23,7 +23,8 @@ import java.util.List;
public class WalletCathDTO extends PageParam implements DataInter { public class WalletCathDTO extends PageParam implements DataInter {
@ApiModelProperty("提现Id")
private Integer id;
@ApiModelProperty("门店") @ApiModelProperty("门店")
private Integer companyId; private Integer companyId;
......
...@@ -32,6 +32,8 @@ public class WalletCathSumDto { ...@@ -32,6 +32,8 @@ public class WalletCathSumDto {
//钱包版本 //钱包版本
private Integer version; private Integer version;
private Integer withdrawWay;
......
...@@ -3,9 +3,7 @@ package com.github.wxiaoqi.security.admin.entity; ...@@ -3,9 +3,7 @@ package com.github.wxiaoqi.security.admin.entity;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import org.apache.commons.lang3.StringUtils;
import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.GeneratedValue; import javax.persistence.GeneratedValue;
import javax.persistence.Id; import javax.persistence.Id;
...@@ -208,12 +206,4 @@ public class CompanyInfo { ...@@ -208,12 +206,4 @@ public class CompanyInfo {
@ApiModelProperty("公司地址-经度") @ApiModelProperty("公司地址-经度")
private BigDecimal longitude; private BigDecimal longitude;
public String getHeadLogo(){
if (StringUtils.isBlank(headLogo)){
headLogo="https://chwplatform.upyuns.com/image/app/shop_logo_default.png";
}
return headLogo;
}
} }
\ No newline at end of file
...@@ -42,6 +42,18 @@ public class CompanyWalletCath implements Serializable { ...@@ -42,6 +42,18 @@ public class CompanyWalletCath implements Serializable {
@ApiModelProperty(value = "门店ID") @ApiModelProperty(value = "门店ID")
private Integer companyId; private Integer companyId;
@Column(name = "wallet_detail_id")
@ApiModelProperty(value = "钱包明细id")
private Integer walletDetailId;
@Column(name = "revenue_id")
@ApiModelProperty(value = "营收id")
private Integer revenueId;
/** /**
* 提现类别,第三方提现类别(0-微信,1-支付宝,2-银行卡) * 提现类别,第三方提现类别(0-微信,1-支付宝,2-银行卡)
*/ */
...@@ -128,9 +140,15 @@ public class CompanyWalletCath implements Serializable { ...@@ -128,9 +140,15 @@ public class CompanyWalletCath implements Serializable {
private String updUser; private String updUser;
@Column(name = "order_no") @Column(name = "order_no")
@ApiModelProperty(value = "第三方订单号:如微信,支付宝,银行卡等") @ApiModelProperty(value = "订单号")
private String orderNo; private String orderNo;
@Column(name = "cath_no")
@ApiModelProperty(value = "提现单号")
private String cathNo;
@Column(name = "account_name") @Column(name = "account_name")
private String accountName; private String accountName;
......
...@@ -17,6 +17,14 @@ import java.math.BigDecimal; ...@@ -17,6 +17,14 @@ import java.math.BigDecimal;
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
public class ApplyCathVo { public class ApplyCathVo {
@ApiModelProperty("营收Id")
private Integer revenueId;
/** /**
* 用户ID * 用户ID
*/ */
...@@ -47,7 +55,17 @@ public class ApplyCathVo { ...@@ -47,7 +55,17 @@ public class ApplyCathVo {
@ApiModelProperty(value = "支付类型") @ApiModelProperty(value = "支付类型")
private Integer cathType; private Integer cathType;
@ApiModelProperty(value = "账号名称") @ApiModelProperty(value = "账号名称")
private String accountName; private String accountName;
@ApiModelProperty(value = "开户行")
private String bank;
@ApiModelProperty(value = "订单号")
private String orderNo;
} }
...@@ -2,6 +2,8 @@ package com.github.wxiaoqi.security.admin.biz; ...@@ -2,6 +2,8 @@ package com.github.wxiaoqi.security.admin.biz;
import com.github.wxiaoqi.security.admin.constant.enumerate.CompanyWalletITypeEnum;
import com.github.wxiaoqi.security.admin.constant.enumerate.CompanyWalletSourceEnum;
import com.github.wxiaoqi.security.admin.dto.BaseOrderRevenueFindDTO; import com.github.wxiaoqi.security.admin.dto.BaseOrderRevenueFindDTO;
import com.github.wxiaoqi.security.admin.dto.OrderWaterDTO; import com.github.wxiaoqi.security.admin.dto.OrderWaterDTO;
import com.github.wxiaoqi.security.admin.entity.*; import com.github.wxiaoqi.security.admin.entity.*;
...@@ -17,6 +19,7 @@ import tk.mybatis.mapper.entity.Example; ...@@ -17,6 +19,7 @@ import tk.mybatis.mapper.entity.Example;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
...@@ -82,6 +85,20 @@ public class BaseOrderRevenueBiz extends BaseBiz<BaseOrderRevenueMapper, BaseOrd ...@@ -82,6 +85,20 @@ public class BaseOrderRevenueBiz extends BaseBiz<BaseOrderRevenueMapper, BaseOrd
} }
public Integer getType(String type){
Integer itype = CompanyWalletITypeEnum.CATH.getCode();
if (StringUtils.isNotBlank(type)) {
String[] values = type.split(",");
List<String> list = Arrays.asList(values);
if (list.contains(CompanyWalletSourceEnum.REGULATION.getCode()+"")) {
itype = CompanyWalletITypeEnum.REGULATION_CATH.getCode();
}
}
return itype;
}
} }
...@@ -78,6 +78,7 @@ public class CompanyInfoBiz extends BaseBiz<CompanyInfoMapper, CompanyInfo>{ ...@@ -78,6 +78,7 @@ public class CompanyInfoBiz extends BaseBiz<CompanyInfoMapper, CompanyInfo>{
companyInfo.setId(id); companyInfo.setId(id);
updateSelectiveById(companyInfo); updateSelectiveById(companyInfo);
}else { }else {
setHeadLog(companyInfo);
insertSelective(companyInfo); insertSelective(companyInfo);
id=companyInfo.getId(); id=companyInfo.getId();
//初始化商家账号 //初始化商家账号
...@@ -100,6 +101,19 @@ public class CompanyInfoBiz extends BaseBiz<CompanyInfoMapper, CompanyInfo>{ ...@@ -100,6 +101,19 @@ public class CompanyInfoBiz extends BaseBiz<CompanyInfoMapper, CompanyInfo>{
return id; return id;
} }
public void setHeadLog(CompanyInfo companyInfo){
String headLog = companyInfo.getHeadLogo();
if (StringUtils.isBlank(headLog)){
Long id = companyInfo.getId() == null ? 0L : companyInfo.getId();
if ( id > 0){
CompanyInfo companyInfo1=selectById(id);
headLog=companyInfo1 == null ? null : companyInfo1.getHeadLogo();
}
headLog = StringUtils.isBlank(headLog) ? "https://chwplatform.upyuns.com/image/app/shop_logo_default.png" : headLog;
}
companyInfo.setHeadLogo(headLog);
}
//app上级用户为店铺推荐人 //app上级用户为店铺推荐人
public void setInviterAccount(CompanyInfoApply companyInfoApply){ public void setInviterAccount(CompanyInfoApply companyInfoApply){
Integer inviterAccount = companyInfoApply.getInviterAccount() == null ? 0 : companyInfoApply.getInviterAccount(); Integer inviterAccount = companyInfoApply.getInviterAccount() == null ? 0 : companyInfoApply.getInviterAccount();
...@@ -137,6 +151,7 @@ public class CompanyInfoBiz extends BaseBiz<CompanyInfoMapper, CompanyInfo>{ ...@@ -137,6 +151,7 @@ public class CompanyInfoBiz extends BaseBiz<CompanyInfoMapper, CompanyInfo>{
if (id > 0L ){ if (id > 0L ){
updateSelectiveById(companyInfo); updateSelectiveById(companyInfo);
}else { }else {
setHeadLog(companyInfo);
insertSelective(companyInfo); insertSelective(companyInfo);
} }
sendQueue(companyInfo); sendQueue(companyInfo);
...@@ -216,4 +231,8 @@ public class CompanyInfoBiz extends BaseBiz<CompanyInfoMapper, CompanyInfo>{ ...@@ -216,4 +231,8 @@ public class CompanyInfoBiz extends BaseBiz<CompanyInfoMapper, CompanyInfo>{
groupBiz.modifyUserGroups(user.getId(),members); groupBiz.modifyUserGroups(user.getId(),members);
} }
public CompanyInfo getInfoByCompanyId(Integer companyId){
return mapper.getInfoByCompanyId(companyId);
}
} }
package com.github.wxiaoqi.security.admin.biz; package com.github.wxiaoqi.security.admin.biz;
import com.github.wxiaoqi.security.admin.dto.BaseOrderRevenueFindDTO;
import com.github.wxiaoqi.security.admin.dto.CompanyWalletDTO; import com.github.wxiaoqi.security.admin.dto.CompanyWalletDTO;
import com.github.wxiaoqi.security.admin.dto.WalletDetailDTO; import com.github.wxiaoqi.security.admin.dto.WalletDetailDTO;
import com.github.wxiaoqi.security.admin.entity.CompanyWallet; import com.github.wxiaoqi.security.admin.entity.CompanyWallet;
...@@ -11,6 +12,7 @@ import com.github.wxiaoqi.security.common.exception.BaseException; ...@@ -11,6 +12,7 @@ import com.github.wxiaoqi.security.common.exception.BaseException;
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.github.wxiaoqi.security.common.vo.PageDataVO;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.math.BigDecimal; import java.math.BigDecimal;
...@@ -23,6 +25,11 @@ public class CompanyWalletBiz extends BaseBiz<CompanyWalletMapper, CompanyWallet ...@@ -23,6 +25,11 @@ public class CompanyWalletBiz extends BaseBiz<CompanyWalletMapper, CompanyWallet
@Autowired
BaseOrderRevenueBiz revenueBiz;
public void updCompanyWallet(CompanyWallet companyWallet){ public void updCompanyWallet(CompanyWallet companyWallet){
mapper.updMyWater(companyWallet); mapper.updMyWater(companyWallet);
} }
...@@ -65,7 +72,10 @@ public class CompanyWalletBiz extends BaseBiz<CompanyWalletMapper, CompanyWallet ...@@ -65,7 +72,10 @@ public class CompanyWalletBiz extends BaseBiz<CompanyWalletMapper, CompanyWallet
CompanyWalletVo companyWalletVo = list.get(0); CompanyWalletVo companyWalletVo = list.get(0);
companyWalletVo.setTodayAmount(mapper.todayAmount(companyWalletVo.getCompanyId())); companyWalletVo.setTodayAmount(mapper.todayAmount(companyWalletVo.getCompanyId()));
companyWalletVo.setNotDoAmount(mapper.notDoAmount(companyWalletVo.getCompanyId())); companyWalletVo.setNotDoAmount(mapper.notDoAmount(companyWalletVo.getCompanyId()));
companyWalletVo.setMonthAmount(mapper.monthAmount(companyWalletVo.getCompanyId(),walletDTO.getMonth())); BaseOrderRevenueFindDTO baseOrderRevenueFindDTO = new BaseOrderRevenueFindDTO();
baseOrderRevenueFindDTO.setCompanyId(companyWalletVo.getCompanyId());
baseOrderRevenueFindDTO.setMonth(walletDTO.getMonth());
companyWalletVo.setMonthAmount(revenueBiz.sumAmount(baseOrderRevenueFindDTO));
return companyWalletVo; return companyWalletVo;
} }
......
...@@ -2,34 +2,58 @@ package com.github.wxiaoqi.security.admin.biz; ...@@ -2,34 +2,58 @@ package com.github.wxiaoqi.security.admin.biz;
import cn.hutool.core.lang.Snowflake; import cn.hutool.core.lang.Snowflake;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.github.wxiaoqi.security.admin.constant.WithDrawStatusEnum; import com.github.wxiaoqi.security.admin.constant.WithDrawStatusEnum;
import com.github.wxiaoqi.security.admin.constant.enumerate.CompanyWalletITypeEnum; import com.github.wxiaoqi.security.admin.constant.enumerate.CompanyWalletSourceEnum;
import com.github.wxiaoqi.security.admin.dto.WalletCathApplyDTO; import com.github.wxiaoqi.security.admin.dto.CompanyAccountDTO;
import com.github.wxiaoqi.security.admin.dto.CompanyWalletPwdDTO;
import com.github.wxiaoqi.security.admin.dto.WalletCathDTO; import com.github.wxiaoqi.security.admin.dto.WalletCathDTO;
import com.github.wxiaoqi.security.admin.entity.CompanyWallet; import com.github.wxiaoqi.security.admin.dto.WalletCathSumDto;
import com.github.wxiaoqi.security.admin.entity.CompanyWalletCath; import com.github.wxiaoqi.security.admin.entity.*;
import com.github.wxiaoqi.security.admin.entity.CompanyWalletDetail;
import com.github.wxiaoqi.security.admin.mapper.CompanyWalletCathMapper; import com.github.wxiaoqi.security.admin.mapper.CompanyWalletCathMapper;
import com.github.wxiaoqi.security.admin.rpc.service.AppPermissionService;
import com.github.wxiaoqi.security.admin.vo.ApplyCathVo;
import com.github.wxiaoqi.security.admin.vo.CompanyWalletCathVo; import com.github.wxiaoqi.security.admin.vo.CompanyWalletCathVo;
import com.github.wxiaoqi.security.admin.vo.CompanyWalletDetailVo; import com.github.wxiaoqi.security.admin.vo.CompanyWalletDetailVo;
import com.github.wxiaoqi.security.common.biz.BaseBiz; import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.github.wxiaoqi.security.common.config.rabbit.RabbitConstant;
import com.github.wxiaoqi.security.common.constant.UserConstant;
import com.github.wxiaoqi.security.common.exception.BaseException; import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.ClientUtil;
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.github.wxiaoqi.security.common.vo.PageDataVO;
import com.xxfc.platform.app.entity.Cofig;
import com.xxfc.platform.app.entity.vo.WithDrawRuleVo;
import com.xxfc.platform.app.enumconstant.WithDrawWayEnum;
import com.xxfc.platform.app.feign.ConfigFeign;
import com.xxfc.platform.universal.vo.FundPayVo;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.core.MessageBuilder;
import org.springframework.amqp.core.MessageProperties;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.time.Instant; import java.time.Instant;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.List; import java.util.List;
import java.util.UUID;
@Service @Service
...@@ -52,6 +76,27 @@ public class CompanyWalletCathBiz extends BaseBiz<CompanyWalletCathMapper, Compa ...@@ -52,6 +76,27 @@ public class CompanyWalletCathBiz extends BaseBiz<CompanyWalletCathMapper, Compa
private DateTimeFormatter dateTimeFormatter; private DateTimeFormatter dateTimeFormatter;
@Autowired
private AppPermissionService permissionService;
@Autowired
private RedisTemplate userRedisTemplate;
@Autowired
ConfigFeign configFeign;
@Autowired
RabbitTemplate rabbitTemplate;
@Autowired
CompanyInfoBiz companyInfoBiz;
@Autowired
BaseOrderRevenueBiz revenueBiz;
private BCryptPasswordEncoder encoder = new BCryptPasswordEncoder(12);
...@@ -66,97 +111,347 @@ public class CompanyWalletCathBiz extends BaseBiz<CompanyWalletCathMapper, Compa ...@@ -66,97 +111,347 @@ public class CompanyWalletCathBiz extends BaseBiz<CompanyWalletCathMapper, Compa
@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED) @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
public void applyCathList(WalletCathApplyDTO walletCathApplyDTO){ public ObjectRestResponse applyCath(ApplyCathVo applyCathVo){
if (walletCathApplyDTO == null) { Integer companyId = applyCathVo.getUserId() == null ? 0 : applyCathVo.getUserId();
throw new BaseException("参数不能为空",ResultCode.NULL_CODE); Integer revenueId = applyCathVo.getRevenueId() == null ? 0 : applyCathVo.getRevenueId();
} if (revenueId == 0 || companyId == 0) {
List<JSONObject> companyIds = walletCathApplyDTO.getCompanyIds(); return ObjectRestResponse.createFailedResult(ResultCode.NULL_CODE, "参数不能为空");
for (JSONObject object:companyIds){ }
CompanyWalletCath walletCathDTO=new CompanyWalletCath(); JSONObject jsonObject = checkSetPwdOrAccount(companyId);
BeanUtils.copyProperties(walletCathApplyDTO,walletCathDTO); boolean flag = jsonObject.getBoolean("result");
walletCathDTO.setCompanyId(object.getInteger("companyId")); if (!flag){
walletCathDTO.setAmount(object.getBigDecimal("amount")); return ObjectRestResponse.createFailedResult(ResultCode.NULL_CODE, "密码或银行卡未设置");
applyCath(walletCathDTO);
} }
applyCathVo.setAccountNumber(jsonObject.getString("accountNumber"));
applyCathVo.setAccountName(jsonObject.getString("accountName"));
applyCathVo.setBank(jsonObject.getString("bank"));
return apply(applyCathVo);
} }
//提现申请 //提现申请
public void applyCath(CompanyWalletCath walletCathDTO) { public ObjectRestResponse apply(ApplyCathVo applyCathVo) {
if (walletCathDTO == null) { Integer companyId = applyCathVo.getUserId();
throw new BaseException("参数不能为空",ResultCode.NULL_CODE); String password = applyCathVo.getPassword();
String accountNumber = applyCathVo.getAccountNumber();
Integer cathType = applyCathVo.getCathType() == null ? 2 : applyCathVo.getCathType();
Integer revenueId = applyCathVo.getRevenueId() == null ? 0 : applyCathVo.getRevenueId();
BaseOrderRevenue baseOrderRevenue = revenueBiz.selectById(revenueId);
if (baseOrderRevenue == null ){
return ObjectRestResponse.createFailedResult(ResultCode.NULL_CODE, "营收记录不存在");
}
if (!companyId.equals(baseOrderRevenue.getCompanyId())){
return ObjectRestResponse.createFailedResult(ResultCode.NULL_CODE, "无权限操作");
}
if (baseOrderRevenue.getStatus() != 1 && baseOrderRevenue.getStatus() != 3){
return ObjectRestResponse.createFailedResult(ResultCode.NULL_CODE, "订单无法提现");
}
BigDecimal amount = baseOrderRevenue.getAmount();
if (StringUtils.isBlank(password) || amount.compareTo(BigDecimal.ZERO) < 1) {
return ObjectRestResponse.createFailedResult(ResultCode.NULL_CODE, "参数不能为空");
}
ObjectRestResponse restResponse = checkAmount(companyId, amount, password);
if (restResponse.getStatus() != ResultCode.SUCCESS_CODE) {
return restResponse;
}
String data = JSONObject.toJSONString(restResponse.getData());
WalletCathSumDto sumDto = JSONUtil.toBean(data, WalletCathSumDto.class);
if (sumDto == null) {
return ObjectRestResponse.createFailedResult(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(); CompanyWalletCath walletCath = new CompanyWalletCath();
BeanUtils.copyProperties(walletCathDTO,walletCath); Integer withdrawWay = sumDto.getWithdrawWay() == null ? 0 : sumDto.getWithdrawWay();
BigDecimal commission =BigDecimal.ZERO; BigDecimal commission = amount.multiply(sumDto.getProceduReates()).divide(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP);
BigDecimal balnece = companyWallet.getBalance(); BigDecimal balnece = sumDto.getBalance();
//到账金额 //到账金额
BigDecimal realAmount = amount.subtract(commission).setScale(2, RoundingMode.HALF_UP); BigDecimal realAmount = amount;
if ((realAmount.add(commission)).compareTo(balnece) > 0) {
realAmount = balnece.subtract(commission);
}
//提现单号 //提现单号
String orderNo = snowflake.nextIdStr(); String orderNo = snowflake.nextIdStr();
orderNo = String.format("%s%s", dateTimeFormatter.format(LocalDate.now()), orderNo); orderNo = String.format("%s%s", dateTimeFormatter.format(LocalDate.now()), orderNo);
log.info("-----提现申请-----orderNo===" + orderNo + "----companyId====" + companyId + "---realAmount===" + realAmount); log.info("-----提现申请-----proceduReates===" + sumDto.getProceduReates() + "----commission====" + commission + "---realAmount===" + realAmount);
walletCath.setCrtTime(Instant.now().toEpochMilli()); walletCath.setCrtTime(Instant.now().toEpochMilli());
walletCath.setOrderNo(orderNo); walletCath.setCathNo(orderNo);
walletCath.setStauts(WithDrawStatusEnum.AUDIT.getCode()); walletCath.setStauts(WithDrawStatusEnum.AUDIT.getCode());
walletCath.setCompanyId(companyId);
walletCath.setBalance(balnece); walletCath.setBalance(balnece);
walletCath.setRealAmount(realAmount); walletCath.setCathType(cathType);
walletCath.setAccountName(applyCathVo.getAccountName());
walletCath.setAccountNumber(accountNumber);
walletCath.setAmount(amount);
//手续费
walletCath.setCommission(commission); walletCath.setCommission(commission);
walletCath.setWithdrawWay(2); walletCath.setRealAmount(realAmount);
walletCath.setWithdrawWay(withdrawWay);
walletCath.setOrderNo(baseOrderRevenue.getOrderNo());
walletCath.setRevenueId(applyCathVo.getRevenueId());
insertSelective(walletCath); insertSelective(walletCath);
//提现金额
BigDecimal withdrawals = realAmount.add(commission);
balnece = balnece.subtract(withdrawals).setScale(2, RoundingMode.HALF_UP);
log.info("------钱包----withdrawals===" + withdrawals + "----balnece====" + balnece);
CompanyWallet companyWallet = new CompanyWallet();
companyWallet.setId(sumDto.getWalletId());
companyWallet.setCompanyId(companyId);
companyWallet.setBalance(balnece);
companyWallet.setWithdrawals(withdrawals);
companyWallet.setVersion(sumDto.getVersion());
companyWalletBiz.updCompanyWallet(companyWallet);
//线上自动提现
if (WithDrawWayEnum.WITHDRAW_ONLINE_WAY.getCode() == withdrawWay) {
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
String host = StringUtils.defaultIfBlank(request.getHeader("userHost"), ClientUtil.getClientIp(request));
FundPayVo fundPayVo = FundPayVo.builder()
.amount(applyCathVo.getCathType() == 0 ? String.format("%.0f",realAmount.multiply(new BigDecimal(100)).doubleValue()) : String.format("%.2f", realAmount.doubleValue()))
.orderNo(orderNo)
.payeeAccount(applyCathVo.getAccountNumber())
.payerShowName("广东升云信息科技有限公司")
.remark("提现转账")
.type(applyCathVo.getCathType())
.creatIp(host)
.build();
//发送提现申请
sendPayMessage(fundPayVo);
}
BaseOrderRevenue baseOrderRevenue1 = new BaseOrderRevenue();
baseOrderRevenue1.setId(baseOrderRevenue.getId());
baseOrderRevenue1.setStatus(4);
revenueBiz.updateSelectiveById(baseOrderRevenue1);
return ObjectRestResponse.succ(walletCath.getId());
}
private void sendPayMessage(FundPayVo fundPayVo) {
String json = JSON.toJSONString(fundPayVo);
Message message = MessageBuilder.withBody(json.getBytes())
.setContentType(MessageProperties.CONTENT_TYPE_JSON).setContentEncoding("utf-8")
.setMessageId(UUID.randomUUID() + "")
.setHeader("x-delay", 2000).build();
rabbitTemplate.convertAndSend(RabbitConstant.ADMIN_TOPIC, RabbitConstant.KEY_WALLET_WITH_DRAW, message);
} }
public void withDrawProcess(CompanyWalletCath companyWalletCath) { public void withDrawProcess(CompanyWalletCath companyWalletCath) {
WalletCathDTO walletCathDTO=new WalletCathDTO(); CompanyWalletCath companyWalletCath1 = selectById(companyWalletCath.getId());
walletCathDTO.setOrderNo(companyWalletCath.getOrderNo()); if (companyWalletCath1 == null) {
List<CompanyWalletCathVo> list = getList(walletCathDTO);
if (list == null || list.size() == 0) {
throw new BaseException("提现记录不存在",ResultCode.FAILED_CODE); throw new BaseException("提现记录不存在",ResultCode.FAILED_CODE);
} }
CompanyWalletCathVo walletCathVo=list.get(0); if (companyWalletCath1.getStauts().equals(WithDrawStatusEnum.SUCCESS.getCode()) || companyWalletCath1.getStauts().equals(WithDrawStatusEnum.FAIL.getCode())) {
if (walletCathVo.getStauts() == WithDrawStatusEnum.SUCCESS.getCode()) {
throw new BaseException("已审核",ResultCode.FAILED_CODE); throw new BaseException("已审核",ResultCode.FAILED_CODE);
} }
CompanyWallet companyWallet=companyWalletBiz.selectById(walletCathVo.getCompanyId()); CompanyWallet companyWallet=companyWalletBiz.selectById(companyWalletCath1.getCompanyId());
if (companyWallet == null) { if (companyWallet == null) {
throw new BaseException("钱包不存在", ResultCode.FAILED_CODE); throw new BaseException("钱包不存在", ResultCode.FAILED_CODE);
} }
companyWalletCath.setFinishTime(Instant.now().toEpochMilli()); BaseOrderRevenue baseOrderRevenue = revenueBiz.selectById(companyWalletCath1.getRevenueId());
companyWalletCath.setId(walletCathVo.getId()); if (baseOrderRevenue == null) {
updateSelectiveById(companyWalletCath); throw new BaseException("营收记录不存在", ResultCode.FAILED_CODE);
}
BaseOrderRevenue baseOrderRevenue1 = new BaseOrderRevenue();
baseOrderRevenue1.setId(baseOrderRevenue.getId());
baseOrderRevenue1.setReson(companyWalletCath.getReason());
if (companyWalletCath.getStauts() == WithDrawStatusEnum.SUCCESS.getCode()) { if (companyWalletCath.getStauts() == WithDrawStatusEnum.SUCCESS.getCode()) {
BigDecimal sAmount=companyWallet.getBalance().subtract(walletCathVo.getAmount()).setScale(2, RoundingMode.HALF_UP);
CompanyWalletDetail detail = new CompanyWalletDetail(); CompanyWalletDetail detail = new CompanyWalletDetail();
detail.setCono(walletCathVo.getOrderNo()); detail.setCono(companyWalletCath1.getCathNo());
detail.setSAmount(sAmount); detail.setSAmount(companyWalletCath1.getBalance());
detail.setAmount(walletCathVo.getAmount()); detail.setAmount(companyWalletCath1.getAmount());
detail.setItype(CompanyWalletITypeEnum.CATH.getCode()); detail.setItype(revenueBiz.getType(baseOrderRevenue.getType()));
detail.setSource(CompanyWalletSourceEnum.CATH.getCode());
//设置提现单号 //设置提现单号
detail.setCompanyId(walletCathVo.getCompanyId()); detail.setCompanyId(companyWalletCath1.getCompanyId());
detail.setBranchId(walletCathVo.getBranchId());
walletDetailBiz.insertSelective(detail); walletDetailBiz.insertSelective(detail);
companyWalletCath.setWalletDetailId(detail.getId());
baseOrderRevenue1.setStatus(2);
}else {
//更新钱包 //更新钱包
BigDecimal withdrawals = companyWallet.getWithdrawals().add(walletCathVo.getAmount()).setScale(2, RoundingMode.HALF_UP); BigDecimal withdrawals = companyWallet.getWithdrawals().subtract(companyWalletCath1.getAmount()).setScale(2, RoundingMode.HALF_UP);
companyWallet.setBalance(sAmount); BigDecimal balance = companyWallet.getBalance().add(companyWalletCath1.getAmount()).setScale(2, RoundingMode.HALF_UP);
companyWallet.setWithdrawals(withdrawals); CompanyWallet companyWallet1 =new CompanyWallet();
companyWalletBiz.updCompanyWallet(companyWallet); companyWallet1.setBalance(balance);
companyWallet1.setWithdrawals(withdrawals);
companyWallet1.setCompanyId(companyWallet.getCompanyId());
companyWalletBiz.updateSelectiveById(companyWallet1);
baseOrderRevenue1.setStatus(3);
} }
companyWalletCath.setFinishTime(Instant.now().toEpochMilli());
updateSelectiveById(companyWalletCath);
revenueBiz.updateSelectiveById(baseOrderRevenue1);
} }
//检查手机号码是否正确
public ObjectRestResponse checkCode(String phone, String mobilecod) {
boolean flag = false;
String key = permissionService.checkCodeByUsername(phone, mobilecod);
if (StringUtils.isNotBlank(key)) {
flag = true;
}
return ObjectRestResponse.succ(flag);
}
//发送验证码
public JSONObject sendSMS(String phone) {
return permissionService.sendSMS(phone,4,null);
}
//设置密码type 1-设置密码;2-修改密码
public ObjectRestResponse setPwd(CompanyWalletPwdDTO companyWalletPwdDTO) {
String phone = companyWalletPwdDTO.getPhone();
String mobilecod = companyWalletPwdDTO.getMobilecod();
String password = companyWalletPwdDTO.getPassword();
Integer type = companyWalletPwdDTO.getType() == null ? 0 : companyWalletPwdDTO.getType();
Integer companyId = companyWalletPwdDTO.getCompanyId() == null ? 0 : companyWalletPwdDTO.getCompanyId();
if (StringUtils.isBlank(phone) || StringUtils.isBlank(mobilecod) || StringUtils.isBlank(password) || companyId == 0 || type == 0) {
return ObjectRestResponse.createFailedResult(ResultCode.NULL_CODE, "参数为空");
}
String key = permissionService.checkCodeByUsername(phone, mobilecod);
if (StringUtils.isBlank(key)) {
return ObjectRestResponse.createFailedResult(ResultCode.NOTEXIST_CODE, "验证码错误");
}
userRedisTemplate.delete(key);
CompanyWallet companyWallet = companyWalletBiz.selectById(companyId);
if (companyWallet == null) {
return ObjectRestResponse.createFailedResult(ResultCode.NULL_CODE, "钱包不存在");
}
if (type == 1 && StringUtils.isNotBlank(companyWallet.getPayPassword())) {
return ObjectRestResponse.createFailedResult(ResultCode.EXIST_CODE, "密码已存在");
}
password = new BCryptPasswordEncoder(UserConstant.PW_ENCORDER_SALT).encode(password);
companyWallet.setPayPassword(password);
companyWalletBiz.updateSelectiveById(companyWallet);
return ObjectRestResponse.succ();
}
//检查用户是否设置过密码
public JSONObject checkSetPwdOrAccount(Integer companyId) {
CompanyInfo companyInfo = companyInfoBiz.getInfoByCompanyId(companyId);
if (companyInfo == null ){
throw new BaseException("商家不存在",ResultCode.NULL_CODE);
}
CompanyWallet companyWallet = companyWalletBiz.selectById(companyId);
if (companyWallet == null) {
throw new BaseException("钱包不存在",ResultCode.NULL_CODE);
}
JSONObject result = new JSONObject();
result.put("result",false);
Integer type = 0;
result.put("accountNumber","");
result.put("accountName","");
result.put("bank","");
if (StringUtils.isBlank(companyInfo.getBankAccount()) || StringUtils.isBlank(companyInfo.getBankName())){
if (StringUtils.isBlank(companyWallet.getPayPassword())) {
type=3;
}else {
type=2;
}
}else {
if (StringUtils.isBlank(companyWallet.getPayPassword())) {
type=1;
}else {
result.put("result",true);
result.put("accountNumber",companyInfo.getBankAccount());
result.put("accountName",companyInfo.getBankName());
result.put("bank",companyInfo.getBank());
}
}
result.put("type",type);
return result;
}
//检查提成下一步操作
public ObjectRestResponse checkAmount(Integer companyId, BigDecimal amount, String password) {
if (amount.compareTo(BigDecimal.ZERO) < 1) {
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE, "提现金额不能小于0");
}
CompanyWallet companyWallet = companyWalletBiz.selectById(companyId);
if (companyWallet == null) {
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE, "钱包不存在");
}
if (amount.compareTo(companyWallet.getBalance()) > 0) {
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE, "提现金额不能大于钱包金额");
}
if (StringUtils.isNotBlank(password) && !encoder.matches(password, companyWallet.getPayPassword())) {
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE, "支付密码错误");
}
WithDrawRuleVo ruleVo = getWithDrawRule();
BigDecimal proceduReates = BigDecimal.ZERO;
WalletCathSumDto sumDto = new WalletCathSumDto();
if (ruleVo != null) {
proceduReates = ruleVo.getProceduReates();
//提现次数
Integer number = 1;
//最小金额
BigDecimal mimAmount = ruleVo.getMinAmount();
if (mimAmount.compareTo(BigDecimal.ZERO) > 0 && amount.compareTo(mimAmount) < 0) {
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE, "提现金额不能小于" + mimAmount + "元");
}
//日额度
BigDecimal amountOfDay = ruleVo.getAmountOfDay();
//每日次数
Integer maxNumberOfDay = ruleVo.getMaxNumberOfDay() == null ? 0 : ruleVo.getMaxNumberOfDay();
//查询当日次数和金额
sumDto = mapper.sumCathAmount(companyId, 1);
BigDecimal ramount = amount.add(sumDto.getSumAmount());
if (amountOfDay.compareTo(BigDecimal.ZERO) > 0 && ramount.compareTo(amountOfDay) > 0) {
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE, "提现金额超过日额度" + amountOfDay + "元");
}
number += sumDto.getNumber();
if (maxNumberOfDay > 0 && number > maxNumberOfDay) {
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE, "提现当日次数超过" + maxNumberOfDay + "次");
}
number = 1;
//月额度
BigDecimal amountOfMonth = ruleVo.getAmountOfMonth();
//月次数
Integer maxNumberOfMonth = ruleVo.getMaxNumberOfMonth();
//查询当月次数和金额
sumDto = mapper.sumCathAmount(companyId, 2);
BigDecimal yamount = amount.add(sumDto.getSumAmount());
if (amountOfMonth.compareTo(BigDecimal.ZERO) > 0 && yamount.compareTo(amountOfMonth) > 0) {
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE, "提现金额超过月额度" + amountOfMonth + "元");
}
number += sumDto.getNumber();
if (maxNumberOfMonth > 0 && number > maxNumberOfMonth) {
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE, "提现当月次数超过" + maxNumberOfMonth + "次");
}
}
sumDto.setBalance(companyWallet.getBalance());
sumDto.setProceduReates(proceduReates);
sumDto.setWalletId(companyWallet.getId());
sumDto.setVersion(companyWallet.getVersion());
sumDto.setWithdrawWay(sumDto.getWithdrawWay());
return ObjectRestResponse.succ(sumDto);
}
//获取提现规则
public WithDrawRuleVo getWithDrawRule(){
try {
List<Cofig> list=configFeign.getAllByType(ConfigFeign.TYPE_COMPANY_CATH+"").getData();
if (list!=null && list.size()>0){
String params=list.get(0).getParams();
return JSONUtil.toBean(params, WithDrawRuleVo.class);
}
}catch (Exception e){
log.error(e.getMessage(), e);;
}
return null;
}
@Override @Override
public void afterPropertiesSet() throws Exception { public void afterPropertiesSet() throws Exception {
snowflake = new Snowflake(2, 2, false); snowflake = new Snowflake(2, 2, false);
...@@ -164,6 +459,18 @@ public class CompanyWalletCathBiz extends BaseBiz<CompanyWalletCathMapper, Compa ...@@ -164,6 +459,18 @@ public class CompanyWalletCathBiz extends BaseBiz<CompanyWalletCathMapper, Compa
} }
public void updAccount(CompanyAccountDTO companyAccountDTO){
CompanyInfo companyInfo = companyInfoBiz.getInfoByCompanyId(companyAccountDTO.getCompanyId());
if (companyInfo == null ){
throw new BaseException("商家不存在",ResultCode.NULL_CODE);
}
CompanyInfo companyInfo1 = new CompanyInfo();
BeanUtils.copyProperties(companyAccountDTO,companyInfo1);
companyInfo1.setId(companyInfo.getId());
companyInfoBiz.saveOrUpd(companyInfo1);
}
......
...@@ -65,6 +65,7 @@ public class CompanyWalletDetailBiz extends BaseBiz<CompanyWalletDetailMapper, C ...@@ -65,6 +65,7 @@ public class CompanyWalletDetailBiz extends BaseBiz<CompanyWalletDetailMapper, C
.builder() .builder()
.orderNo(orderWaterDTO.getOrderNo()) .orderNo(orderWaterDTO.getOrderNo())
.divisionTypes(divisionTypes) .divisionTypes(divisionTypes)
.iType(CompanyWalletITypeEnum.COMPANY.getCode())
.build(); .build();
updByIdOrOrderNo(acceptDetailedDTO); updByIdOrOrderNo(acceptDetailedDTO);
} }
...@@ -77,6 +78,7 @@ public class CompanyWalletDetailBiz extends BaseBiz<CompanyWalletDetailMapper, C ...@@ -77,6 +78,7 @@ public class CompanyWalletDetailBiz extends BaseBiz<CompanyWalletDetailMapper, C
BaseOrderAcceptDetailedDTO acceptDetailedDTO = BaseOrderAcceptDetailedDTO BaseOrderAcceptDetailedDTO acceptDetailedDTO = BaseOrderAcceptDetailedDTO
.builder() .builder()
.acceptId(acceptId) .acceptId(acceptId)
.iType(CompanyWalletITypeEnum.REGULATION.getCode())
.build(); .build();
updByIdOrOrderNo(acceptDetailedDTO); updByIdOrOrderNo(acceptDetailedDTO);
} }
...@@ -112,7 +114,7 @@ public class CompanyWalletDetailBiz extends BaseBiz<CompanyWalletDetailMapper, C ...@@ -112,7 +114,7 @@ public class CompanyWalletDetailBiz extends BaseBiz<CompanyWalletDetailMapper, C
companyWalletDetail.setCompanyId(acceptDetailedVO.getMchId()); companyWalletDetail.setCompanyId(acceptDetailedVO.getMchId());
companyWalletDetail.setSAmount(companyAmount); companyWalletDetail.setSAmount(companyAmount);
companyWalletDetail.setSource(source); companyWalletDetail.setSource(source);
companyWalletDetail.setItype(CompanyWalletITypeEnum.COMPANY.getCode()); companyWalletDetail.setItype(acceptDetailedDTO.getIType());
insertSelective(companyWalletDetail); insertSelective(companyWalletDetail);
walletDetails.add(companyWalletDetail); walletDetails.add(companyWalletDetail);
} }
......
...@@ -2,8 +2,14 @@ package com.github.wxiaoqi.security.admin.mapper; ...@@ -2,8 +2,14 @@ package com.github.wxiaoqi.security.admin.mapper;
import com.github.wxiaoqi.security.admin.entity.CompanyInfo; import com.github.wxiaoqi.security.admin.entity.CompanyInfo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.additional.idlist.SelectByIdListMapper; import tk.mybatis.mapper.additional.idlist.SelectByIdListMapper;
import tk.mybatis.mapper.common.Mapper; import tk.mybatis.mapper.common.Mapper;
public interface CompanyInfoMapper extends Mapper<CompanyInfo>, SelectByIdListMapper<CompanyInfo,Long> { public interface CompanyInfoMapper extends Mapper<CompanyInfo>, SelectByIdListMapper<CompanyInfo,Long> {
@Select("SELECT * FROM company_info WHERE id in (SELECT company_id FROM branch_company WHERE id=#{companyId} )")
CompanyInfo getInfoByCompanyId(@Param("companyId")Integer companyId);
} }
\ No newline at end of file
...@@ -3,6 +3,7 @@ package com.github.wxiaoqi.security.admin.mapper; ...@@ -3,6 +3,7 @@ package com.github.wxiaoqi.security.admin.mapper;
import com.github.wxiaoqi.security.admin.dto.WalletCathDTO; import com.github.wxiaoqi.security.admin.dto.WalletCathDTO;
import com.github.wxiaoqi.security.admin.dto.WalletCathSumDto;
import com.github.wxiaoqi.security.admin.entity.CompanyWalletCath; import com.github.wxiaoqi.security.admin.entity.CompanyWalletCath;
import com.github.wxiaoqi.security.admin.vo.CompanyWalletCathVo; import com.github.wxiaoqi.security.admin.vo.CompanyWalletCathVo;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
...@@ -27,4 +28,12 @@ public interface CompanyWalletCathMapper extends Mapper<CompanyWalletCath> { ...@@ -27,4 +28,12 @@ public interface CompanyWalletCathMapper extends Mapper<CompanyWalletCath> {
@Select("SELECT IFNULL(SUM(amount),0) FROM company_wallet_cath WHERE company_id =#{companyId} AND stauts=0") @Select("SELECT IFNULL(SUM(amount),0) FROM company_wallet_cath WHERE company_id =#{companyId} AND stauts=0")
BigDecimal sunAmountByStatus(@Param("companyId") Integer companyId); BigDecimal sunAmountByStatus(@Param("companyId") Integer companyId);
/**
* 计算提现的金额
* @param type 1-日;2-月
* @return
*/
WalletCathSumDto sumCathAmount(@Param("companyId") Integer companyId, @Param("type") int type);
} }
...@@ -45,6 +45,6 @@ public interface CompanyWalletMapper extends Mapper<CompanyWallet> { ...@@ -45,6 +45,6 @@ public interface CompanyWalletMapper extends Mapper<CompanyWallet> {
BigDecimal monthAmount(@Param("companyId") Integer companyId,@Param("month") String month); BigDecimal monthAmount(@Param("companyId") Integer companyId,@Param("month") String month);
@Select("SELECT IFNULL(SUM(division_amount-fee),0) FROM base_order_accept_detailed WHERE `status`=0 and mch_id=#{companyId} and division_type in (3,5,6,7,8)") @Select("SELECT IFNULL(SUM(amount),0) FROM base_order_revenue WHERE amount > 0 and is_del = 0 and company_id=#{companyId} and status = 0")
BigDecimal notDoAmount(@Param("companyId") Integer companyId); BigDecimal notDoAmount(@Param("companyId") Integer companyId);
} }
package com.github.wxiaoqi.security.admin.rest;
import com.github.wxiaoqi.security.admin.biz.CompanyWalletCathBiz;
import com.github.wxiaoqi.security.admin.dto.CompanyAccountDTO;
import com.github.wxiaoqi.security.admin.dto.CompanyWalletPwdDTO;
import com.github.wxiaoqi.security.admin.vo.ApplyCathVo;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* @author Administrator
*/
@Slf4j
@RestController
@RequestMapping("app/companyWalletCath")
@RequiredArgsConstructor(onConstructor_ = {@Autowired})
@Api(tags = {"店铺提现"})
public class AppCompanyCathController extends BaseController<CompanyWalletCathBiz> {
@GetMapping("sendSMS")
@ApiOperation("发送验证码")
public ObjectRestResponse sendSMS() throws Exception{
baseBiz.sendSMS(getUserName());
return ObjectRestResponse.succ();
}
@GetMapping("checkCode")
@ApiOperation("检查验证码")
public ObjectRestResponse checkCode(
@RequestParam(value = "mobilecode", defaultValue = "") String mobilecod) throws Exception{
return baseBiz.checkCode(getUserName(), mobilecod);
}
@PostMapping("setPwd")
@ApiOperation("设置密码")
public ObjectRestResponse setPwd(@RequestBody CompanyWalletPwdDTO companyWalletPwdDTO) throws Exception{
if (companyWalletPwdDTO.getCompanyId() == null || companyWalletPwdDTO.getCompanyId() == 0){
List<Integer> companyIds = getBusinessUserCompanyIds();
if (companyIds != null && companyIds.size() > 0){
companyWalletPwdDTO.setCompanyId(companyIds.get(0));
}
}
if (StringUtils.isBlank(companyWalletPwdDTO.getPhone())){
companyWalletPwdDTO.setPhone(getUserName());
}
return baseBiz.setPwd(companyWalletPwdDTO);
}
@GetMapping("checkSetPwdOrAccount")
@ApiOperation("检查用户是否设置过(支付密码或银行卡)")
public ObjectRestResponse checkSetPwdOrAccount(@RequestParam(value = "companyId", defaultValue = "0") Integer companyId) {
if (companyId == 0){
List<Integer> companyIds = getBusinessUserCompanyIds();
if (companyIds != null && companyIds.size() > 0){
companyId=companyIds.get(0);
}
}
return ObjectRestResponse.succ(baseBiz.checkSetPwdOrAccount(companyId));
}
@PostMapping("applyCath")
@ApiOperation("提现申请")
public ObjectRestResponse applyCath(@RequestBody ApplyCathVo applyCathVo) {
if (applyCathVo.getUserId() == null || applyCathVo.getUserId() == 0){
List<Integer> companyIds = getBusinessUserCompanyIds();
if (companyIds != null && companyIds.size() > 0){
applyCathVo.setUserId(companyIds.get(0));
}
}
return baseBiz.applyCath(applyCathVo);
}
@PostMapping("updAccount")
@ApiOperation("设置银行卡")
public ObjectRestResponse updAccount(@RequestBody CompanyAccountDTO companyAccountDTO) {
if (companyAccountDTO.getCompanyId() == null || companyAccountDTO.getCompanyId() == 0){
List<Integer> companyIds = getBusinessUserCompanyIds();
if (companyIds != null && companyIds.size() > 0){
companyAccountDTO.setCompanyId(companyIds.get(0));
}
}
baseBiz.updAccount(companyAccountDTO);
return ObjectRestResponse.succ();
}
}
...@@ -73,20 +73,6 @@ public class AdminCompanyWalletDetailController extends BaseController<CompanyWa ...@@ -73,20 +73,6 @@ public class AdminCompanyWalletDetailController extends BaseController<CompanyWa
} }
@RequestMapping(value = "applyCath", method = RequestMethod.POST)
@ApiModelProperty(value = "提现申请")
public ObjectRestResponse applyCath(@RequestBody CompanyWalletCath walletCathDTO) {
walletCathBiz.applyCath(walletCathDTO);
return ObjectRestResponse.succ();
}
@RequestMapping(value = "applyCathList", method = RequestMethod.POST)
@ApiModelProperty(value = "提现申请List")
public ObjectRestResponse applyCathList(@RequestBody WalletCathApplyDTO walletCathApplyDTO) {
walletCathBiz.applyCathList(walletCathApplyDTO);
return ObjectRestResponse.succ();
}
@RequestMapping(value = "withDrawProcess", method = RequestMethod.POST) @RequestMapping(value = "withDrawProcess", method = RequestMethod.POST)
@ApiModelProperty(value = "提现审核") @ApiModelProperty(value = "提现审核")
...@@ -96,4 +82,11 @@ public class AdminCompanyWalletDetailController extends BaseController<CompanyWa ...@@ -96,4 +82,11 @@ public class AdminCompanyWalletDetailController extends BaseController<CompanyWa
} }
@RequestMapping(value = "selectListByCath", method = RequestMethod.GET)
@ApiModelProperty(value = "提现记录")
public ObjectRestResponse<PageDataVO<CompanyWalletDetailVo>> selectListByCath(WalletCathDTO walletCathDTO) {
return ObjectRestResponse.succ(walletCathBiz.selectList(walletCathDTO));
}
} }
\ No newline at end of file
...@@ -24,6 +24,9 @@ ...@@ -24,6 +24,9 @@
<when test="status == 1"> <when test="status == 1">
and `status` in (1,3) and `status` in (1,3)
</when> </when>
<when test="status == 2">
and `status` in (2,4)
</when>
<otherwise> <otherwise>
and `status`=#{status} and `status`=#{status}
</otherwise> </otherwise>
......
<?xml version="1.0" encoding="UTF-8" ?> <?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" > <!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"> <mapper namespace="com.github.wxiaoqi.security.admin.mapper.CompanyWalletCathMapper">
<select id="selectList" resultType="com.xxfc.platform.order.pojo.vo.CompanyWalletCathVo" parameterType="com.xxfc.platform.order.pojo.dto.WalletCathDTO"> <select id="selectList" resultType="com.github.wxiaoqi.security.admin.vo.CompanyWalletCathVo" parameterType="com.github.wxiaoqi.security.admin.dto.WalletCathDTO">
SELECT SELECT
wc.*, wc.*,
c.`name` as companyName, c.`name` as companyName,
...@@ -20,6 +20,9 @@ ...@@ -20,6 +20,9 @@
<if test="branchId != null and branchId > 0"> <if test="branchId != null and branchId > 0">
and c.company_id=#{branchId} and c.company_id=#{branchId}
</if> </if>
<if test="id != null and id > 0">
and wc.id=#{id}
</if>
<if test="orderNo != null and orderNo != '' "> <if test="orderNo != null and orderNo != '' ">
and wc.order_no like concat('%',#{orderNo},'%') and wc.order_no like concat('%',#{orderNo},'%')
</if> </if>
...@@ -56,4 +59,22 @@ ...@@ -56,4 +59,22 @@
order by wc.crt_time desc order by wc.crt_time desc
</select> </select>
<select id="sumCathAmount" resultType="com.github.wxiaoqi.security.admin.dto.WalletCathSumDto">
select IFNULL(SUM(amount),0) as sumAmount,COUNT(*) as `number` from company_wallet_cath
<where>
company_id=#{companyId} and stauts in(0,1)
<choose>
<when test="type ==1 ">
AND date_format(from_unixtime(crt_time/1000),'%Y-%m-%d') = date_format(now(),'%Y-%m-%d')
</when>
<when test="type==2 ">
AND date_format(from_unixtime(crt_time/1000),'%Y-%m') = date_format(now(),'%Y-%m')
</when>
<otherwise>
</otherwise>
</choose>
</where>
</select>
</mapper> </mapper>
\ No newline at end of file
...@@ -27,6 +27,8 @@ public interface ConfigFeign { ...@@ -27,6 +27,8 @@ public interface ConfigFeign {
public static final int TYPE_BRANCH_COMPANY=111; public static final int TYPE_BRANCH_COMPANY=111;
public static final int TYPE_COMPANY_CATH=89;
@RequestMapping(value = "/cofig/app/unauth/types",method = RequestMethod.GET) @RequestMapping(value = "/cofig/app/unauth/types",method = RequestMethod.GET)
ObjectRestResponse<List<Cofig>> getAllByType(@RequestParam("types") String types); ObjectRestResponse<List<Cofig>> getAllByType(@RequestParam("types") String types);
......
...@@ -30,6 +30,10 @@ public class WalletCathDTO extends PageParam implements DataInter { ...@@ -30,6 +30,10 @@ public class WalletCathDTO extends PageParam implements DataInter {
private Integer companyId; private Integer companyId;
@ApiModelProperty("提现Id")
private Integer id;
@ApiModelProperty("企业") @ApiModelProperty("企业")
private Integer branchId; private Integer branchId;
......
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