|
@@ -2,29 +2,102 @@ package com.leromro.core.facade;
|
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
import com.leromro.common.core.domain.R;
|
|
import com.leromro.common.core.domain.R;
|
|
import com.leromro.common.core.domain.entity.SysUser;
|
|
import com.leromro.common.core.domain.entity.SysUser;
|
|
import com.leromro.common.core.redis.RedisCache;
|
|
import com.leromro.common.core.redis.RedisCache;
|
|
import com.leromro.common.enums.ConstantsKey;
|
|
import com.leromro.common.enums.ConstantsKey;
|
|
import com.leromro.common.exception.ServiceException;
|
|
import com.leromro.common.exception.ServiceException;
|
|
import com.leromro.common.utils.SecurityUtils;
|
|
import com.leromro.common.utils.SecurityUtils;
|
|
|
|
+import com.leromro.core.domain.VolunteerAccount;
|
|
|
|
+import com.leromro.core.domain.VolunteerAccountChange;
|
|
import com.leromro.core.domain.VolunteerPaymentRecords;
|
|
import com.leromro.core.domain.VolunteerPaymentRecords;
|
|
|
|
+import com.leromro.core.domain.VolunteerTakeRecord;
|
|
import com.leromro.core.domain.dto.WithdrawPaymentDTO;
|
|
import com.leromro.core.domain.dto.WithdrawPaymentDTO;
|
|
|
|
+import com.leromro.core.service.IVolunteerAccountChangeService;
|
|
|
|
+import com.leromro.core.service.IVolunteerAccountService;
|
|
import com.leromro.core.service.IVolunteerPaymentRecordsService;
|
|
import com.leromro.core.service.IVolunteerPaymentRecordsService;
|
|
|
|
+import com.leromro.core.service.IVolunteerTakeRecordService;
|
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
|
|
|
|
|
|
+/**
|
|
|
|
+ * 处理提现打款相关业务
|
|
|
|
+ */
|
|
@Service
|
|
@Service
|
|
public class VolunteerPaymentRecordsFacade {
|
|
public class VolunteerPaymentRecordsFacade {
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private IVolunteerAccountService volunteerAccountService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private IVolunteerAccountChangeService volunteerAccountChangeService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private IVolunteerTakeRecordService volunteerTakeRecordService;
|
|
|
|
+
|
|
@Autowired
|
|
@Autowired
|
|
private IVolunteerPaymentRecordsService volunteerPaymentRecordsService;
|
|
private IVolunteerPaymentRecordsService volunteerPaymentRecordsService;
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private RedisCache redisCache;
|
|
private RedisCache redisCache;
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 提现审批
|
|
|
|
+ */
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
+ public R<String> approval(@RequestBody VolunteerTakeRecord takeRecord){
|
|
|
|
+ String appStatus = takeRecord.getAppStatus();
|
|
|
|
+ if ("3".equals(appStatus)){
|
|
|
|
+ if (StrUtil.isBlank(takeRecord.getRejectReason())) {
|
|
|
|
+ return R.fail("请填写驳回原因");
|
|
|
|
+ }
|
|
|
|
+ //查询提现申请单
|
|
|
|
+ VolunteerTakeRecord oldTakeRecord = volunteerTakeRecordService.getById(takeRecord.getVolunteerTakeRecordId());
|
|
|
|
+ //修改志愿者账户表
|
|
|
|
+ VolunteerAccount volunteerAccount = volunteerAccountService.getById(oldTakeRecord.getVolunteerAccountId());
|
|
|
|
+ if (ObjectUtil.isNull(volunteerAccount)){
|
|
|
|
+ return R.fail("账户不存在");
|
|
|
|
+ }
|
|
|
|
+ volunteerAccountService.update(new LambdaUpdateWrapper<VolunteerAccount>()
|
|
|
|
+ .eq(VolunteerAccount::getVolunteerAccountId,volunteerAccount.getVolunteerAccountId())
|
|
|
|
+ .set(VolunteerAccount::getBalance,volunteerAccount.getBalance().add(oldTakeRecord.getTakeAmount()))
|
|
|
|
+ .set(VolunteerAccount::getBeBalance,volunteerAccount.getBeBalance().subtract(oldTakeRecord.getTakeAmount())));
|
|
|
|
+ //修改志愿者账户变动表
|
|
|
|
+ VolunteerAccountChange volunteerAccountChange = volunteerAccountChangeService.getOne(new LambdaQueryWrapper<VolunteerAccountChange>()
|
|
|
|
+ .eq(VolunteerAccountChange::getVolunteerId,volunteerAccount.getVolunteerId())
|
|
|
|
+ .orderByDesc(VolunteerAccountChange::getCreateTime)
|
|
|
|
+ .last("limit 1"));
|
|
|
|
+ VolunteerAccountChange changeBuilder = VolunteerAccountChange.builder()
|
|
|
|
+ .volunteerId(volunteerAccountChange.getVolunteerId())
|
|
|
|
+ .changeType("1")
|
|
|
|
+ .sourceType("11")
|
|
|
|
+ .changeMoney(oldTakeRecord.getTakeAmount())
|
|
|
|
+ .beforeBalance(volunteerAccountChange.getAfterBalance())
|
|
|
|
+ .afterBalance(volunteerAccountChange.getAfterBalance().add(oldTakeRecord.getTakeAmount()))
|
|
|
|
+ .sourceId(oldTakeRecord.getVolunteerTakeRecordId())
|
|
|
|
+ .build();
|
|
|
|
+ volunteerAccountChangeService.save(changeBuilder);
|
|
|
|
+ }
|
|
|
|
+ //修改提现申请单
|
|
|
|
+ volunteerTakeRecordService.update(new LambdaUpdateWrapper<VolunteerTakeRecord>()
|
|
|
|
+ .eq(VolunteerTakeRecord::getVolunteerTakeRecordId,takeRecord.getVolunteerTakeRecordId())
|
|
|
|
+ .set(VolunteerTakeRecord::getAppStatus,takeRecord.getAppStatus())
|
|
|
|
+ .set(StrUtil.isNotBlank(takeRecord.getRejectReason()),VolunteerTakeRecord::getRejectReason,takeRecord.getRejectReason())
|
|
|
|
+ .set(VolunteerTakeRecord::getAppUserId, SecurityUtils.getUserId())
|
|
|
|
+ .set(VolunteerTakeRecord::getAppUserName,SecurityUtils.getUsername()));
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ return R.ok();
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 打款单验证
|
|
* 打款单验证
|
|
*/
|
|
*/
|