package com.stylefeng.guns.modular.code.controller; import com.baomidou.mybatisplus.mapper.EntityWrapper; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.stylefeng.guns.modular.system.model.*; import com.stylefeng.guns.modular.system.service.*; import com.stylefeng.guns.modular.system.util.ResultUtil; import com.stylefeng.guns.modular.system.vo.MoneyDetailVO; import com.stylefeng.guns.modular.system.vo.RechargeListVO; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.util.StringUtils; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.RestController; import java.math.BigDecimal; import java.text.SimpleDateFormat; import java.util.Date; import java.util.List; /** * @author 无关风月 * @Date 2024/2/6 18:25 */ /** * 财务管理 */ @Slf4j @RestController @RequestMapping("") public class MoneyController { @Autowired private IFitnessTypeService fitnessTypeService; @Autowired private IFitnessPositionService fitnessPositionService; @Autowired private IAppUserService appUserService; @Autowired private ICourseService courseService; @Autowired private ICourseVideoService courseVideoService; @Autowired private IOrderService orderService; @Autowired private IOrderCourseService orderCourseService; @Autowired private ICouponService couponService; @Autowired private IPackageService packageService; @Autowired private IProtocolService protocolService; @Autowired private IWithdrawalService withdrawalService; @Autowired private IBannerService bannerService; @Autowired private IMessageService messageService; @ResponseBody @PostMapping("/base/money/list") @ApiOperation(value = "提现申请列表", tags = {"财务管理"}) @ApiImplicitParams({ @ApiImplicitParam(value = "申请用户", name = "userName"), @ApiImplicitParam(value = "联系电话", name = "phone"), @ApiImplicitParam(value = "状态状态1待审核 2 已通过 3已拒绝", name = "state"), @ApiImplicitParam(value = "开始时间", name = "startTime"), @ApiImplicitParam(value = "结束时间", name = "endTime"), @ApiImplicitParam(value = "打款状态", name = "payment"), @ApiImplicitParam(value = "页码,首页1", name = "pageNum", dataType = "int"), @ApiImplicitParam(value = "页条数", name = "pageSize", dataType = "int"), }) public ResultUtil> list(String userName, String phone,Integer state,Integer payment , Date startTime, Date endTime, Integer pageNum, Integer pageSize) { String startTime1 = ""; String endTime1 = ""; if (endTime!=null){ endTime.setHours(23); endTime.setMinutes(59); endTime.setSeconds(59); SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); startTime1 = format.format(startTime); endTime1 = format.format(endTime); } List res = withdrawalService.list(userName,phone,state,payment,startTime,endTime,startTime1,endTime1); // PageHelper.startPage(pageNum,pageSize); PageInfo info=new PageInfo<>(res); return ResultUtil.success(info); } @Autowired private ITurnService turnService; @ResponseBody @PostMapping("/base/money/detail") @ApiOperation(value = "提现详情", tags = {"财务管理"}) public ResultUtil getModel(Integer id) { Withdrawal withdrawal = withdrawalService.selectById(id); MoneyDetailVO moneyDetailVO = new MoneyDetailVO(); AppUser appUser = appUserService.selectById(withdrawal.getUserId()); moneyDetailVO.setUserName(appUser.getName()); moneyDetailVO.setPhone(appUser.getPhone()); SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); moneyDetailVO.setInsertTime(format.format(withdrawal.getInsertTime())); moneyDetailVO.setAmount(withdrawal.getAmount()); moneyDetailVO.setApplyAmount(withdrawal.getApplyAmount()); moneyDetailVO.setAccountName(appUser.getAccountName()); moneyDetailVO.setBankCard(appUser.getBankCard()); moneyDetailVO.setBankName(appUser.getBankName()); moneyDetailVO.setBankPhone(appUser.getBankPhone()); moneyDetailVO.setBankCardImg(appUser.getBankCardImg()); moneyDetailVO.setState(withdrawal.getState()); moneyDetailVO.setPayment(withdrawal.getPayment()); return ResultUtil.success(moneyDetailVO); } @ResponseBody @PostMapping("/base/money/rechargeList") @ApiOperation(value = "充值记录", tags = {"财务管理"}) @ApiImplicitParams({ @ApiImplicitParam(value = "申请用户", name = "userName"), @ApiImplicitParam(value = "联系电话", name = "phone"), @ApiImplicitParam(value = "开始时间", name = "startTime"), @ApiImplicitParam(value = "结束时间", name = "endTime"), @ApiImplicitParam(value = "页码,首页1", name = "pageNum", dataType = "int"), @ApiImplicitParam(value = "页条数", name = "pageSize", dataType = "int"), }) public ResultUtil> list(String userName, String phone,Date startTime, Date endTime, Integer pageNum, Integer pageSize) { if (endTime!=null){ endTime.setHours(23); endTime.setMinutes(59); endTime.setSeconds(59); } List res = withdrawalService.rechargeList(userName,phone,startTime,endTime); // PageHelper.startPage(pageNum,pageSize); PageInfo info=new PageInfo<>(res); return ResultUtil.success(info); } @ResponseBody @PostMapping("/base/money/changeState") @ApiOperation(value = "审核", tags = {"财务管理"}) @ApiImplicitParams({ @ApiImplicitParam(value = "主键", name = "id"), @ApiImplicitParam(value = "状态 2=通过 3=拒绝", name = "state"), @ApiImplicitParam(value = "拒绝理由", name = "reason"), }) public ResultUtil getModel(Integer id,Integer state,String reason) { Withdrawal withdrawal = withdrawalService.selectById(id); if (state==2){ // /// 还需要发送一条消息给用户 // Message message = new Message(); // message.setUserId(withdrawal.getUserId()); // message.setType(1); // message.setContent("您的提现申请已通过"); // message.setInsertTime(new Date()); // message.setIsRead(0); // messageService.insert(message); }else{ // 把钱退回用户余额 AppUser appUser = appUserService.selectById(withdrawal.getUserId()); BigDecimal subtract = appUser.getBalance().add(withdrawal.getAmount()); appUser.setBalance(subtract); // 扣钱 appUserService.updateById(appUser); withdrawal.setReason(reason); withdrawal.setRefuseTime(new Date()); Message message = new Message(); message.setUserId(withdrawal.getUserId()); message.setType(1); message.setContent("您的提现申请被驳回,原因:"+reason); message.setInsertTime(new Date()); message.setIsRead(0); messageService.insert(message); } withdrawal.setState(state); withdrawalService.updateById(withdrawal); return ResultUtil.success(); } @ResponseBody @PostMapping("/base/money/payment") @ApiOperation(value = "打款", tags = {"财务管理"}) @ApiImplicitParams({ @ApiImplicitParam(value = "主键", name = "id"), }) public ResultUtil payment(Integer id) { Withdrawal withdrawal = withdrawalService.selectById(id); /// 还需要发送一条消息给用户 Message message = new Message(); message.setUserId(withdrawal.getUserId()); message.setType(1); message.setContent("您的提现申请已通过"); message.setInsertTime(new Date()); message.setIsRead(0); messageService.insert(message); withdrawal.setPayment(2); withdrawal.setComplete(new Date()); withdrawalService.updateById(withdrawal); return ResultUtil.success(); } }