KKSU
2024-08-27 a29ec2e752a0735cfe9d4574a22f95bcf2618a14
src/main/java/cc/mrbird/febs/mall/controller/AdminMallMemberController.java
@@ -4,6 +4,7 @@
import cc.mrbird.febs.common.controller.BaseController;
import cc.mrbird.febs.common.entity.FebsResponse;
import cc.mrbird.febs.common.entity.QueryRequest;
import cc.mrbird.febs.common.enumerates.DataDictionaryEnum;
import cc.mrbird.febs.common.enumerates.FlowTypeNewEnum;
import cc.mrbird.febs.common.enumerates.MoneyFlowTypeNewEnum;
import cc.mrbird.febs.common.enumerates.ProductEnum;
@@ -15,10 +16,7 @@
import cc.mrbird.febs.common.utils.excl.ResponseHeadUtil;
import cc.mrbird.febs.mall.dto.*;
import cc.mrbird.febs.mall.entity.*;
import cc.mrbird.febs.mall.mapper.MallMemberAmountMapper;
import cc.mrbird.febs.mall.mapper.MallMemberChargeMapper;
import cc.mrbird.febs.mall.mapper.MallMemberMapper;
import cc.mrbird.febs.mall.mapper.MallMemberWalletMapper;
import cc.mrbird.febs.mall.mapper.*;
import cc.mrbird.febs.mall.service.IAdminMallMemberService;
import cc.mrbird.febs.mall.service.IApiMallMemberService;
import cc.mrbird.febs.mall.service.IMallMoneyFlowService;
@@ -39,6 +37,7 @@
import javax.validation.constraints.NotNull;
import java.io.IOException;
import java.io.OutputStream;
import java.math.BigDecimal;
import java.net.URLEncoder;
import java.text.DecimalFormat;
import java.util.ArrayList;
@@ -60,6 +59,8 @@
    private final IApiMallMemberService apiMallMemberService;
    private final MallMemberChargeMapper mallMemberChargeMapper;
    private final IMallMoneyFlowService mallMoneyFlowService;
    private final MallMemberWithdrawMapper mallMemberWithdrawMapper;
    private final DataDictionaryCustomMapper dataDictionaryCustomMapper;
    @GetMapping("confirmOrder")
@@ -73,8 +74,15 @@
            if(1 != mallMemberCharge.getState()){
                continue;
            }
            DataDictionaryCustom fcmPriceDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                    DataDictionaryEnum.FCM_PRICE.getType(),
                    DataDictionaryEnum.FCM_PRICE.getCode());
            BigDecimal price = ObjectUtil.isEmpty(fcmPriceDic) ? new BigDecimal(8) : new BigDecimal(fcmPriceDic.getValue());
            BigDecimal divide = mallMemberCharge.getAmount().divide(price, 2, BigDecimal.ROUND_DOWN);
            MallMemberAmount mallMemberAmount = mallMemberAmountMapper.selectByMemberId(mallMemberCharge.getMemberId());
            mallMemberAmount.setFcmCntAva(mallMemberAmount.getFcmCntAva().add(mallMemberCharge.getAmount()));
            mallMemberAmount.setFcmCntAva(mallMemberAmount.getFcmCntAva().add(divide));
            mallMemberAmountMapper.updateFcmCntAvaById(mallMemberAmount);
            mallMemberCharge.setState(2);
@@ -83,7 +91,7 @@
            String orderNo = MallUtils.getOrderNum("BF");
            mallMoneyFlowService.addMoneyFlow(
                    mallMemberCharge.getMemberId(),
                    mallMemberCharge.getAmount(),
                    divide,
                    MoneyFlowTypeNewEnum.FCM_INSIDE_IN.getValue(),
                    orderNo,
                    mallMemberCharge.getMemberId(),
@@ -111,6 +119,55 @@
        return new FebsResponse().success();
    }
    @GetMapping("confirmCancelWithdraw")
    @ControllerEndpoint(operation = "批量提现取消", exceptionMessage = "操作失败")
    public FebsResponse confirmCancelWithdraw(MemberChargrDto memberChargrDto){
        String orderIds = memberChargrDto.getOrderIds();
        List<String> ids = StrUtil.splitTrim(orderIds, ",");
        for(String id : ids){
            long orderId = Long.parseLong(id);
            MallMemberWithdraw mallMemberWithdraw = mallMemberWithdrawMapper.selectById(orderId);
            if(1 != mallMemberWithdraw.getStatus()){
                continue;
            }
            mallMemberWithdraw.setStatus(3);
            mallMemberWithdrawMapper.updateById(mallMemberWithdraw);
            MallMemberAmount mallMemberAmount = mallMemberAmountMapper.selectByMemberId(mallMemberWithdraw.getMemberId());
            mallMemberAmount.setFcmCntAva(mallMemberAmount.getFcmCntAva().subtract(mallMemberWithdraw.getAmount()));
            mallMemberAmountMapper.updateFcmCntAvaById(mallMemberAmount);
        }
        return new FebsResponse().success();
    }
    @GetMapping("confirmWithdraw")
    @ControllerEndpoint(operation = "批量同意", exceptionMessage = "操作失败")
    public FebsResponse confirmWithdraw(MemberChargrDto memberChargrDto){
        String orderIds = memberChargrDto.getOrderIds();
        List<String> ids = StrUtil.splitTrim(orderIds, ",");
        for(String id : ids){
            long orderId = Long.parseLong(id);
            MallMemberWithdraw mallMemberWithdraw = mallMemberWithdrawMapper.selectById(orderId);
            if(1 != mallMemberWithdraw.getStatus()){
                continue;
            }
            mallMemberWithdraw.setStatus(2);
            mallMemberWithdrawMapper.updateById(mallMemberWithdraw);
            String orderNo = MallUtils.getOrderNum("BF");
            mallMoneyFlowService.addMoneyFlow(
                    mallMemberWithdraw.getMemberId(),
                    mallMemberWithdraw.getAmount(),
                    MoneyFlowTypeNewEnum.FCM_INSIDE_OUT.getValue(),
                    orderNo,
                    mallMemberWithdraw.getId(),
                    FlowTypeNewEnum.FCM_COIN.getValue(),
                    MoneyFlowTypeNewEnum.FCM_INSIDE_OUT.getDescrition());
        }
        return new FebsResponse().success();
    }
    /**
     * 充值列表
@@ -121,6 +178,16 @@
        return new FebsResponse().success().data(data);
    }
    /**
     * 提现列表
     */
    @GetMapping("memberWithDrawList")
    public FebsResponse memberWithDrawList(MoneyChargeListDto moneyChargeListDto, QueryRequest request) {
        Map<String, Object> data = getDataTable(mallMemberService.memberWithDrawList(moneyChargeListDto, request));
        return new FebsResponse().success().data(data);
    }
    /**
     * 平台账单
     *