xuhy
2025-08-05 74aaaab01e109d3f408cf586ea2c4661872190f1
DriverZYTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/DriverAlipayServiceImpl.java
@@ -1,38 +1,21 @@
package com.stylefeng.guns.modular.system.service.impl;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.stylefeng.guns.core.common.constant.JwtConstants;
import com.stylefeng.guns.core.shiro.ShiroKit;
import com.stylefeng.guns.core.shiro.ShiroUser;
import com.stylefeng.guns.core.util.JwtTokenUtil;
import com.stylefeng.guns.core.util.ToolUtil;
import com.stylefeng.guns.modular.smallLogistics.server.IOrderLogisticsService;
import com.stylefeng.guns.modular.system.dao.*;
import com.stylefeng.guns.modular.system.model.*;
import com.stylefeng.guns.modular.system.service.*;
import com.stylefeng.guns.modular.system.util.*;
import com.stylefeng.guns.modular.system.warpper.ActivityWarpper;
import com.stylefeng.guns.modular.system.warpper.BaseWarpper;
import com.stylefeng.guns.modular.system.warpper.LoginWarpper;
import com.stylefeng.guns.modular.system.warpper.RegisteredWarpper;
import com.stylefeng.guns.modular.taxi.service.IOrderTaxiService;
import org.apache.shiro.authc.SimpleAuthenticationInfo;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.authc.credential.HashedCredentialsMatcher;
import org.apache.shiro.crypto.hash.Md5Hash;
import org.apache.shiro.util.ByteSource;
import com.stylefeng.guns.core.util.DateUtil;
import com.stylefeng.guns.modular.system.dao.DriverAlipayMapper;
import com.stylefeng.guns.modular.system.dao.DriverMapper;
import com.stylefeng.guns.modular.system.dao.WithdrawalMapper;
import com.stylefeng.guns.modular.system.model.Driver;
import com.stylefeng.guns.modular.system.model.DriverAlipay;
import com.stylefeng.guns.modular.system.model.Withdrawal;
import com.stylefeng.guns.modular.system.service.IDriverAlipayService;
import com.stylefeng.guns.modular.system.util.ResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.Date;
import java.util.List;
@Service
@@ -40,6 +23,10 @@
    @Autowired
    private DriverAlipayMapper driverAlipayMapper;
    @Autowired
    private DriverMapper driverMapper;
    @Autowired
    private WithdrawalMapper withdrawalMapper;
    @Override
    public ResultUtil saveAlipay(String userName, String account, Integer driverId) {
@@ -74,7 +61,7 @@
    public ResultUtil delAlipay(Integer id, Integer driverId) {
        DriverAlipay driverAlipay = this.selectById(id);
        if(driverAlipay.getDriverId().compareTo(driverId) != 0){
            return ResultUtil.error("你无权删除此卡号");
            return ResultUtil.error("你无权删除此账号");
        }
        this.deleteById(id);
        return ResultUtil.success();
@@ -85,4 +72,86 @@
        pageNum = (pageNum - 1) * size;
        return driverAlipayMapper.queryAlipay(pageNum, size, driverId);
    }
    @Override
    public ResultUtil aliWithdrawal(Double money, Integer id, Integer uid, Integer type) {
        if(money.compareTo(0D) <= 0){
            return ResultUtil.error("提现金额必须大于0");
        }
        Driver driver = driverMapper.selectById(uid);
        Integer withdrawalRule = driverMapper.getWithdrawalRule();
        if(withdrawalRule==null){
            return ResultUtil.error("暂未设置提现时间,请联系平台");
        }
        String week =withdrawalRule==1?"星期一":
                withdrawalRule==2?"星期二":
                        withdrawalRule==3?"星期三":
                                withdrawalRule==4?"星期四":
                                        withdrawalRule==5?"星期五":
                                                withdrawalRule==6?"星期六":"星期日";
        String weeks = DateUtil.getAfterDayWeek("0");
        if(!weeks.equals(week)){
            return ResultUtil.error(" 每周"+(withdrawalRule==1?"一":
                    withdrawalRule==2?"二":
                            withdrawalRule==3?"三":
                                    withdrawalRule==4?"四":
                                            withdrawalRule==5?"五":
                                                    withdrawalRule==6?"六":"日")+"统一申请提现,平台统一处理。");
        }
        if(null == type){
            type = 1;
        }
        Withdrawal withdrawal = new Withdrawal();
        if(type == 1){
            if(null == driver.getLaveActivityMoney()){
                return ResultUtil.error("账户没有余额,不能提现");
            }
            if(driver.getLaveActivityMoney().compareTo(money) < 0){
                return ResultUtil.error("提现金额必须小于账户余额");
            }
            withdrawal.setBalance(driver.getLaveActivityMoney());
        }
        if(type == 2){
            if(null == driver.getLaveBusinessMoney()){
                return ResultUtil.error("账户没有余额,不能提现");
            }
            Double money1 = driverMapper.getThisWeekMoney(uid);
            Double laveBusinessMoney =driver.getLaveBusinessMoney()-(money1==null?0d:money1);
            if(laveBusinessMoney.compareTo(money) < 0){
                return ResultUtil.error("提现金额必须小于账户余额");
            }
            withdrawal.setBalance(driver.getLaveBusinessMoney()-(money1==null?0d:money1));
        }
        DriverAlipay driverAlipay = this.selectById(id);
        if(null == driverAlipay){
            return ResultUtil.error("请选择提现账号");
        }
        withdrawal.setCode(driverAlipay.getAccount());
        withdrawal.setFlag(1);
        withdrawal.setInsertTime(new Date());
        withdrawal.setMoney(money);
        withdrawal.setName(driverAlipay.getUserName());
        withdrawal.setState(1);
        withdrawal.setUserId(uid);
        withdrawal.setUserType(2);
        withdrawal.setBankName("支付宝");
        withdrawal.setType(type);
        withdrawal.setWithdrawalType(1);//线上
        if(type == 1){
            double v = new BigDecimal(driver.getLaveActivityMoney()).subtract(new BigDecimal(money)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue();
            driver.setLaveActivityMoney(v);
            v = new BigDecimal(driver.getBalance()).subtract(new BigDecimal(money)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue();
            driver.setBalance(v);
        }
        if(type == 2){
            double v = new BigDecimal(driver.getLaveBusinessMoney()).subtract(new BigDecimal(money)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue();
            driver.setLaveBusinessMoney(v);
        }
        withdrawalMapper.insert(withdrawal);
        driverMapper.updateById(driver);
        return ResultUtil.success();
    }
}