@ -5,19 +5,22 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.greenorange.promotion.annotation.RequiresPermission ;
import com.greenorange.promotion.annotation.SysLog ;
import com.greenorange.promotion.common.BaseResponse ;
import com.greenorange.promotion.common.ErrorCode ;
import com.greenorange.promotion.common.ResultUtils ;
import com.greenorange.promotion.constant.UserConstant ;
import com.greenorange.promotion.exception.ThrowUtils ;
import com.greenorange.promotion.model.dto.withdrawalApply.WithdrawalApplyAddRequest ;
import com.greenorange.promotion.model.dto.withdrawalApply.WithdrawalApplyQueryRequest ;
import com.greenorange.promotion.model.entity.FundsChange ;
import com.greenorange.promotion.model.entity.UserMainInfo ;
import com.greenorange.promotion.model.entity.WithdrawalApply ;
import com.greenorange.promotion.model.entity.* ;
import com.greenorange.promotion.model.vo.fundsChange.FundsChangeVO ;
import com.greenorange.promotion.model.vo.fundsChange.FundsItemVO ;
import com.greenorange.promotion.model.vo.userAccount.UserAccountConditionVO ;
import com.greenorange.promotion.model.vo.withdrawalApply.WithdrawalApplyVO ;
import com.greenorange.promotion.service.common.CommonService ;
import com.greenorange.promotion.service.settle.FundsChangeService ;
import com.greenorange.promotion.service.settle.UserAccountService ;
import com.greenorange.promotion.service.settle.WithdrawalApplyService ;
import com.greenorange.promotion.service.userInfo.UserInfoService ;
import com.greenorange.promotion.service.userInfo.UserMainInfoService ;
import io.swagger.v3.oas.annotations.Operation ;
import io.swagger.v3.oas.annotations.tags.Tag ;
@ -56,6 +59,36 @@ public class WithdrawalApplyController {
@Resource
private UserMainInfoService userMainInfoService ;
@Resource
private UserInfoService userInfoService ;
@Resource
private UserAccountService userAccountService ;
/**
* 小程序端用户查询账户提现状况
* @return 提现申请记录id
*/
@PostMapping ( " query/condition " )
@Operation ( summary = " 小程序端用户查询账户提现状况 " , description = " 参数: 无, 权限: 管理员, 方法名: queryWithdrawalCondition " )
@RequiresPermission ( mustRole = UserConstant . DEFAULT_ROLE )
public BaseResponse < UserAccountConditionVO > queryWithdrawalCondition ( HttpServletRequest request ) {
Long userId = ( Long ) request . getAttribute ( " userId " ) ;
LambdaQueryWrapper < UserMainInfo > userMainInfoLambdaQueryWrapper = new LambdaQueryWrapper < > ( ) ;
userMainInfoLambdaQueryWrapper . eq ( UserMainInfo : : getUserId , userId ) ;
UserMainInfo userMainInfo = userMainInfoService . getOne ( userMainInfoLambdaQueryWrapper ) ;
LambdaQueryWrapper < UserAccount > userAccountLambdaQueryWrapper = new LambdaQueryWrapper < > ( ) ;
userAccountLambdaQueryWrapper . eq ( UserAccount : : getUserId , userId ) ;
UserAccount userAccount = userAccountService . getOne ( userAccountLambdaQueryWrapper ) ;
String bankCardNumber = userAccount = = null ? " " : userAccount . getBankCardNumber ( ) ;
UserAccountConditionVO userAccountConditionVO = UserAccountConditionVO . builder ( )
. currentBalance ( userMainInfo . getCurrentBalance ( ) )
. bankCardNumber ( bankCardNumber )
. build ( ) ;
return ResultUtils . success ( userAccountConditionVO ) ;
}
/**
* 小程序端用户申请提现
@ -68,9 +101,17 @@ public class WithdrawalApplyController {
// @SysLog(title = "提现申请记录管理", content = "小程序端用户申请提现")
public BaseResponse < Long > addWithdrawalApply ( @Valid @RequestBody WithdrawalApplyAddRequest withdrawalApplyAddRequest , HttpServletRequest request ) {
Long userId = ( Long ) request . getAttribute ( " userId " ) ;
LambdaQueryWrapper < UserAccount > userAccountLambdaQueryWrapper = commonService . buildQueryWrapperByField ( UserAccount : : getUserId , userId , userAccountService ) ;
UserAccount userAccount = userAccountService . getOne ( userAccountLambdaQueryWrapper ) ;
ThrowUtils . throwIf ( userAccount = = null , ErrorCode . OPERATION_ERROR , " 请先绑定银行卡 " ) ;
BigDecimal withdrawnAmount = withdrawalApplyAddRequest . getWithdrawnAmount ( ) ;
WithdrawalApply withdrawalApply = WithdrawalApply . builder ( )
. withdrawnAmount ( withdrawnAmount )
. cardHolder ( userAccount . getCardHolder ( ) )
. idCardNumber ( userAccount . getIdCardNumber ( ) )
. phoneNumber ( userAccount . getPhoneNumber ( ) )
. bankCardNumber ( userAccount . getBankCardNumber ( ) )
. openBank ( userAccount . getOpenBank ( ) )
. userId ( userId )
. build ( ) ;
withdrawalApplyService . save ( withdrawalApply ) ;
@ -104,7 +145,7 @@ public class WithdrawalApplyController {
// @SysLog(title = "提现申请记录管理", content = "小程序端用户查询资金变动记录")
public BaseResponse < FundsItemVO > queryFundsChangeByUserId ( HttpServletRequest request ) {
Long userId = ( Long ) request . getAttribute ( " userId " ) ;
LambdaQueryWrapper < UserMainInfo > lambdaQueryWrapper = new LambdaQueryWrapper < > ( ) ;
LambdaQueryWrapper < UserMainInfo > lambdaQueryWrapper = new LambdaQueryWrapper < > ( ) ;
lambdaQueryWrapper . eq ( UserMainInfo : : getUserId , userId ) ;
UserMainInfo userMainInfo = userMainInfoService . getOne ( lambdaQueryWrapper ) ;
FundsItemVO fundsItemVO = commonService . copyProperties ( userMainInfo , FundsItemVO . class ) ;