1. 调整
This commit is contained in:
		
							parent
							
								
									127dd794d0
								
							
						
					
					
						commit
						0a22b587fc
					
				| 
						 | 
					@ -22,6 +22,7 @@ import com.ruoyi.system.domain.*;
 | 
				
			||||||
import com.ruoyi.system.domain.response.FaultResponse;
 | 
					import com.ruoyi.system.domain.response.FaultResponse;
 | 
				
			||||||
import com.ruoyi.system.domain.response.OrderResponse;
 | 
					import com.ruoyi.system.domain.response.OrderResponse;
 | 
				
			||||||
import com.ruoyi.system.domain.vo.*;
 | 
					import com.ruoyi.system.domain.vo.*;
 | 
				
			||||||
 | 
					import com.ruoyi.system.mapper.AsDeviceMapper;
 | 
				
			||||||
import com.ruoyi.system.service.*;
 | 
					import com.ruoyi.system.service.*;
 | 
				
			||||||
import com.wechat.pay.java.service.payments.jsapi.model.PrepayWithRequestPaymentResponse;
 | 
					import com.wechat.pay.java.service.payments.jsapi.model.PrepayWithRequestPaymentResponse;
 | 
				
			||||||
import org.jetbrains.annotations.NotNull;
 | 
					import org.jetbrains.annotations.NotNull;
 | 
				
			||||||
| 
						 | 
					@ -29,6 +30,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 | 
				
			||||||
import org.springframework.transaction.annotation.Transactional;
 | 
					import org.springframework.transaction.annotation.Transactional;
 | 
				
			||||||
import org.springframework.web.bind.annotation.*;
 | 
					import org.springframework.web.bind.annotation.*;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import javax.annotation.Resource;
 | 
				
			||||||
import java.math.BigDecimal;
 | 
					import java.math.BigDecimal;
 | 
				
			||||||
import java.util.ArrayList;
 | 
					import java.util.ArrayList;
 | 
				
			||||||
import java.util.Comparator;
 | 
					import java.util.Comparator;
 | 
				
			||||||
| 
						 | 
					@ -74,6 +76,9 @@ public class AppVerifyController extends BaseController
 | 
				
			||||||
    @Autowired
 | 
					    @Autowired
 | 
				
			||||||
    private IEtOperatingAreaService etOperatingAreaService;
 | 
					    private IEtOperatingAreaService etOperatingAreaService;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Resource
 | 
				
			||||||
 | 
					    private AsDeviceMapper asDeviceMapper;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * 故障上报
 | 
					     * 故障上报
 | 
				
			||||||
| 
						 | 
					@ -154,7 +159,7 @@ public class AppVerifyController extends BaseController
 | 
				
			||||||
                return error("订单已结束,请重新扫码");
 | 
					                return error("订单已结束,请重新扫码");
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        AsDevice asDevice = asDeviceService.selectAsDeviceBySn(order.getSn());
 | 
					        AsDevice asDevice = asDeviceMapper.selectAsDeviceBySn(order.getSn());
 | 
				
			||||||
        EtOperatingArea area = etOperatingAreaService.selectEtOperatingAreaByAreaId(asDevice.getAreaId());
 | 
					        EtOperatingArea area = etOperatingAreaService.selectEtOperatingAreaByAreaId(asDevice.getAreaId());
 | 
				
			||||||
        //实名判断
 | 
					        //实名判断
 | 
				
			||||||
        if(area.getAuthentication().equals(ServiceConstants.IS_AUTHENTICATION_YES) && !asUserService.checkIsAuthentication(order.getUserId())){
 | 
					        if(area.getAuthentication().equals(ServiceConstants.IS_AUTHENTICATION_YES) && !asUserService.checkIsAuthentication(order.getUserId())){
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,5 +1,6 @@
 | 
				
			||||||
package com.ruoyi.common.core.domain.entity;
 | 
					package com.ruoyi.common.core.domain.entity;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.math.BigDecimal;
 | 
				
			||||||
import java.util.ArrayList;
 | 
					import java.util.ArrayList;
 | 
				
			||||||
import java.util.List;
 | 
					import java.util.List;
 | 
				
			||||||
import javax.validation.constraints.Email;
 | 
					import javax.validation.constraints.Email;
 | 
				
			||||||
| 
						 | 
					@ -75,6 +76,9 @@ public class SysDept extends BaseEntity
 | 
				
			||||||
    /** 小程序名称 */
 | 
					    /** 小程序名称 */
 | 
				
			||||||
    private String appName;
 | 
					    private String appName;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /** 余额 */
 | 
				
			||||||
 | 
					    private BigDecimal balance;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /** appSecret */
 | 
					    /** appSecret */
 | 
				
			||||||
    private String appSecret;
 | 
					    private String appSecret;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -96,6 +100,14 @@ public class SysDept extends BaseEntity
 | 
				
			||||||
    /** 退款回调地址 */
 | 
					    /** 退款回调地址 */
 | 
				
			||||||
    private String refundNotifyUrl;
 | 
					    private String refundNotifyUrl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public BigDecimal getBalance() {
 | 
				
			||||||
 | 
					        return balance;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void setBalance(BigDecimal balance) {
 | 
				
			||||||
 | 
					        this.balance = balance;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public String getPlatformServiceFee() {
 | 
					    public String getPlatformServiceFee() {
 | 
				
			||||||
        return platformServiceFee;
 | 
					        return platformServiceFee;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -243,6 +243,7 @@ public class SysLoginService
 | 
				
			||||||
            asUser.setWxopenid(openId);
 | 
					            asUser.setWxopenid(openId);
 | 
				
			||||||
            asUser.setAreaId(Long.parseLong(areaId));
 | 
					            asUser.setAreaId(Long.parseLong(areaId));
 | 
				
			||||||
            asUser.setAppName(dept.getAppName());
 | 
					            asUser.setAppName(dept.getAppName());
 | 
				
			||||||
 | 
					            asUser.setRemark(dept.getAppName());
 | 
				
			||||||
            int i = asUserService.insertUser(asUser);
 | 
					            int i = asUserService.insertUser(asUser);
 | 
				
			||||||
            user = asUser;
 | 
					            user = asUser;
 | 
				
			||||||
        }else{
 | 
					        }else{
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -144,14 +144,14 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
 | 
				
			||||||
        if (ObjectUtil.isNull(asDevice)) {
 | 
					        if (ObjectUtil.isNull(asDevice)) {
 | 
				
			||||||
            throw new ServiceException("设备不存在:"+ sn);
 | 
					            throw new ServiceException("设备不存在:"+ sn);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        // 查询车辆上下线
 | 
					//        // 查询车辆上下线
 | 
				
			||||||
        if(!isOnline(sn)){
 | 
					//        if(!isOnline(sn)){
 | 
				
			||||||
            asDevice.setOnlineStatus(ServiceConstants.VEHICLE_STATUS_OFFLINE);
 | 
					//            asDevice.setOnlineStatus(ServiceConstants.VEHICLE_STATUS_OFFLINE);
 | 
				
			||||||
            log.info("设备不在线:"+ sn);
 | 
					//            log.info("设备不在线:"+ sn);
 | 
				
			||||||
        }else{
 | 
					//        }else{
 | 
				
			||||||
            asDevice.setOnlineStatus(ServiceConstants.VEHICLE_STATUS_ONLINE);
 | 
					//            asDevice.setOnlineStatus(ServiceConstants.VEHICLE_STATUS_ONLINE);
 | 
				
			||||||
        }
 | 
					//        }
 | 
				
			||||||
        int i = asDeviceMapper.updateAsDevice(asDevice);
 | 
					//        int i = asDeviceMapper.updateAsDevice(asDevice);
 | 
				
			||||||
        Long areaId = asDevice.getAreaId();
 | 
					        Long areaId = asDevice.getAreaId();
 | 
				
			||||||
        EtOperatingArea etOperatingArea;
 | 
					        EtOperatingArea etOperatingArea;
 | 
				
			||||||
        if (ObjectUtil.isNotNull(areaId)) {
 | 
					        if (ObjectUtil.isNotNull(areaId)) {
 | 
				
			||||||
| 
						 | 
					@ -472,7 +472,7 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
 | 
				
			||||||
        ResponseVo responseVo = sendCommandWithResp(asDevice.getMac(), token, IotConstants.COMMAND_OPEN+IotConstants.COMMAND_FREQUENCY_5, "编号开锁");
 | 
					        ResponseVo responseVo = sendCommandWithResp(asDevice.getMac(), token, IotConstants.COMMAND_OPEN+IotConstants.COMMAND_FREQUENCY_5, "编号开锁");
 | 
				
			||||||
        if(responseVo.getCode() != 0){
 | 
					        if(responseVo.getCode() != 0){
 | 
				
			||||||
            asynchronousUpdateOnlineStatus(asDevice.getMac());
 | 
					            asynchronousUpdateOnlineStatus(asDevice.getMac());
 | 
				
			||||||
            throw new ServiceException("【扫码/编号开锁骑行】更新车辆状态失败");
 | 
					            throw new ServiceException("【扫码/编号开锁骑行】发送开锁命令失败");
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        /** 3.更新车辆状态*/
 | 
					        /** 3.更新车辆状态*/
 | 
				
			||||||
        asDevice.setLockStatus(ServiceConstants.LOCK_STATUS_OPEN);
 | 
					        asDevice.setLockStatus(ServiceConstants.LOCK_STATUS_OPEN);
 | 
				
			||||||
| 
						 | 
					@ -498,6 +498,7 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
 | 
				
			||||||
            //计算预约费
 | 
					            //计算预约费
 | 
				
			||||||
            calculateAppointmentFee(order);
 | 
					            calculateAppointmentFee(order);
 | 
				
			||||||
            order.setTotalFee(order.getAppointmentFee());
 | 
					            order.setTotalFee(order.getAppointmentFee());
 | 
				
			||||||
 | 
					            order.setPayFee(order.getAppointmentFee());
 | 
				
			||||||
            int update = etOrderService.updateEtOrder(order);
 | 
					            int update = etOrderService.updateEtOrder(order);
 | 
				
			||||||
            if(update==0){
 | 
					            if(update==0){
 | 
				
			||||||
                log.info("【扫码/编号开锁骑行】更新订单失败");
 | 
					                log.info("【扫码/编号开锁骑行】更新订单失败");
 | 
				
			||||||
| 
						 | 
					@ -881,6 +882,7 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
 | 
				
			||||||
            BigDecimal fee = appointmentServiceFee.multiply(new BigDecimal(area.getTimeoutMinutes()).divide(new BigDecimal(10)));
 | 
					            BigDecimal fee = appointmentServiceFee.multiply(new BigDecimal(area.getTimeoutMinutes()).divide(new BigDecimal(10)));
 | 
				
			||||||
            order.setAppointmentFee(fee);
 | 
					            order.setAppointmentFee(fee);
 | 
				
			||||||
            order.setTotalFee(fee);
 | 
					            order.setTotalFee(fee);
 | 
				
			||||||
 | 
					            order.setPayFee(fee);
 | 
				
			||||||
            int update = etOrderService.updateEtOrder(order);
 | 
					            int update = etOrderService.updateEtOrder(order);
 | 
				
			||||||
            if(update==0){
 | 
					            if(update==0){
 | 
				
			||||||
                throw new ServiceException("【车辆超时预约】:更新订单状态失败");
 | 
					                throw new ServiceException("【车辆超时预约】:更新订单状态失败");
 | 
				
			||||||
| 
						 | 
					@ -921,6 +923,7 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
 | 
				
			||||||
        //计算预约费
 | 
					        //计算预约费
 | 
				
			||||||
        calculateAppointmentFee(order);
 | 
					        calculateAppointmentFee(order);
 | 
				
			||||||
        order.setTotalFee(order.getAppointmentFee());
 | 
					        order.setTotalFee(order.getAppointmentFee());
 | 
				
			||||||
 | 
					        order.setPayFee(order.getAppointmentFee());
 | 
				
			||||||
        order.setStatus(ServiceConstants.ORDER_STATUS_CANCEL_APPOINTMENT);
 | 
					        order.setStatus(ServiceConstants.ORDER_STATUS_CANCEL_APPOINTMENT);
 | 
				
			||||||
        int i = etOrderService.updateEtOrder(order);
 | 
					        int i = etOrderService.updateEtOrder(order);
 | 
				
			||||||
        if(i==0){
 | 
					        if(i==0){
 | 
				
			||||||
| 
						 | 
					@ -1117,6 +1120,7 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            log.info("【计算订单费用】骑行费:" + order.getRidingFee() + ",车辆管理费:" + order.getManageFee() + ",调度费:" + order.getDispatchFee() + ",预约费:" + order.getAppointmentFee() + ",总计:" + totalFee);
 | 
					            log.info("【计算订单费用】骑行费:" + order.getRidingFee() + ",车辆管理费:" + order.getManageFee() + ",调度费:" + order.getDispatchFee() + ",预约费:" + order.getAppointmentFee() + ",总计:" + totalFee);
 | 
				
			||||||
            order.setTotalFee(totalFee);
 | 
					            order.setTotalFee(totalFee);
 | 
				
			||||||
 | 
					            order.setPayFee(totalFee);
 | 
				
			||||||
        }else {
 | 
					        }else {
 | 
				
			||||||
            throw new ServiceException("订单类型错误");
 | 
					            throw new ServiceException("订单类型错误");
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
| 
						 | 
					@ -1148,11 +1152,6 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
 | 
				
			||||||
            String timeoutPrice = startingRule.getTimeoutPrice();//超时价格
 | 
					            String timeoutPrice = startingRule.getTimeoutPrice();//超时价格
 | 
				
			||||||
            Integer timeoutTime = Integer.parseInt(startingRule.getTimeoutTime());//超时时间
 | 
					            Integer timeoutTime = Integer.parseInt(startingRule.getTimeoutTime());//超时时间
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            //判断免费骑行时间不得大于起步时间
 | 
					 | 
				
			||||||
            if(freeRideTime>startingTime){
 | 
					 | 
				
			||||||
                throw new ServiceException("免费骑行时长不得大于起步分钟!");
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            if(rentalUnit.equals(ServiceConstants.RENTAL_UNIT_HOURS)){//租赁单位:hours-小时
 | 
					            if(rentalUnit.equals(ServiceConstants.RENTAL_UNIT_HOURS)){//租赁单位:hours-小时
 | 
				
			||||||
                startingTime = startingTime*60;
 | 
					                startingTime = startingTime*60;
 | 
				
			||||||
                timeoutTime = timeoutTime*60;
 | 
					                timeoutTime = timeoutTime*60;
 | 
				
			||||||
| 
						 | 
					@ -1161,6 +1160,11 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
 | 
				
			||||||
                timeoutTime = timeoutTime*60*24;
 | 
					                timeoutTime = timeoutTime*60*24;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            //判断免费骑行时间不得大于起步时间
 | 
				
			||||||
 | 
					            if(freeRideTime>startingTime){
 | 
				
			||||||
 | 
					                throw new ServiceException("免费骑行时长不得大于起步分钟!");
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if(ObjectUtils.isNotEmpty(returnTime) && ObjectUtils.isNotEmpty(unlockTime)){
 | 
					            if(ObjectUtils.isNotEmpty(returnTime) && ObjectUtils.isNotEmpty(unlockTime)){
 | 
				
			||||||
                if(minutes<startingTime){
 | 
					                if(minutes<startingTime){
 | 
				
			||||||
                    //小于起步分钟,按照起步价计算费用
 | 
					                    //小于起步分钟,按照起步价计算费用
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -175,18 +175,19 @@ public class CallbackServiceImpl implements CallbackService {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    // 新增资金流水记录
 | 
					                    // 新增资金流水记录
 | 
				
			||||||
                    capitalFlowRecords(order,ServiceConstants.FLOW_TYPE_INCOME,ServiceConstants.ORDER_TYPE_RIDING);
 | 
					                    capitalFlowRecords(order,ServiceConstants.FLOW_TYPE_INCOME,ServiceConstants.ORDER_TYPE_RIDING);
 | 
				
			||||||
 | 
					                    logger.info("=================【微信支付回调】11111111==================");
 | 
				
			||||||
                    // 还车结算___小时后自动退押金---创建一个定时器TimerTask,计算出退还时间后,执行退款操作
 | 
					                    // 还车结算___小时后自动退押金---创建一个定时器TimerTask,计算出退还时间后,执行退款操作
 | 
				
			||||||
                    EtOperatingArea area = etOperatingAreaService.selectEtOperatingAreaByAreaId(order.getAreaId());
 | 
					                    EtOperatingArea area = etOperatingAreaService.selectEtOperatingAreaByAreaId(order.getAreaId());
 | 
				
			||||||
 | 
					                    logger.info("=================【微信支付回调】22222222==================");
 | 
				
			||||||
                    // 退还押金处理
 | 
					                    // 退还押金处理
 | 
				
			||||||
                    refundDeposit(area.getDeposit(), order, asUser);
 | 
					                    refundDeposit(area.getDeposit(), order, asUser);
 | 
				
			||||||
 | 
					                    logger.info("=================【微信支付回调】33333333==================");
 | 
				
			||||||
                    // 24小时后发起分账
 | 
					                    // 24小时后发起分账
 | 
				
			||||||
                    scheduledExecutorService.schedule(() -> {
 | 
					                    scheduledExecutorService.schedule(() -> {
 | 
				
			||||||
                        // 请求分账处理
 | 
					                        // 请求分账处理
 | 
				
			||||||
                        if (dividendHandle(transactionId, order, area)) return;
 | 
					                        if (dividendHandle(transactionId, order, area)) return;
 | 
				
			||||||
                    }, 24 , TimeUnit.HOURS);
 | 
					                    }, 24 , TimeUnit.HOURS);
 | 
				
			||||||
 | 
					                    logger.info("=================【微信支付回调】4444444==================");
 | 
				
			||||||
                }else if(attachVo.getType().equals(ServiceConstants.BUSINESS_TYPE_APPOINTMENT)){
 | 
					                }else if(attachVo.getType().equals(ServiceConstants.BUSINESS_TYPE_APPOINTMENT)){
 | 
				
			||||||
                    logger.info("【微信支付回调】取消预约支付");
 | 
					                    logger.info("【微信支付回调】取消预约支付");
 | 
				
			||||||
                    // 2-取消预约支付
 | 
					                    // 2-取消预约支付
 | 
				
			||||||
| 
						 | 
					@ -390,7 +391,8 @@ public class CallbackServiceImpl implements CallbackService {
 | 
				
			||||||
        EtFeeRule rule = etFeeRuleService.selectEtFeeRuleByRuleId(order.getRuleId());
 | 
					        EtFeeRule rule = etFeeRuleService.selectEtFeeRuleByRuleId(order.getRuleId());
 | 
				
			||||||
        Integer autoRefundDeposit = rule.getAutoRefundDeposit();
 | 
					        Integer autoRefundDeposit = rule.getAutoRefundDeposit();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if(autoRefundDeposit!=null && autoRefundDeposit>0){
 | 
					        logger.info("【微信支付回调】进入退还押金");
 | 
				
			||||||
 | 
					        if(autoRefundDeposit!=null){
 | 
				
			||||||
            //创建一个定时器,计算出退还时间后,执行退款操作
 | 
					            //创建一个定时器,计算出退还时间后,执行退款操作
 | 
				
			||||||
            // 往后推autoRefundDeposit小时执行
 | 
					            // 往后推autoRefundDeposit小时执行
 | 
				
			||||||
            scheduledExecutorService.schedule(() -> {
 | 
					            scheduledExecutorService.schedule(() -> {
 | 
				
			||||||
| 
						 | 
					@ -399,7 +401,7 @@ public class CallbackServiceImpl implements CallbackService {
 | 
				
			||||||
                if(ObjectUtil.isNotNull(refund2) && refund2.getRefundResult().equals(Constants.SUCCESS2)){
 | 
					                if(ObjectUtil.isNotNull(refund2) && refund2.getRefundResult().equals(Constants.SUCCESS2)){
 | 
				
			||||||
                    return;
 | 
					                    return;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                logger.info("【微信支付回调】退还押金定时任务开始");
 | 
					                logger.info("【微信支付回调】退还押金定时任务开始执行!!!!!!!!");
 | 
				
			||||||
                // 退款
 | 
					                // 退款
 | 
				
			||||||
                Long userId = order.getUserId();
 | 
					                Long userId = order.getUserId();
 | 
				
			||||||
                EtOrder etOrder = new EtOrder();
 | 
					                EtOrder etOrder = new EtOrder();
 | 
				
			||||||
| 
						 | 
					@ -444,6 +446,9 @@ public class CallbackServiceImpl implements CallbackService {
 | 
				
			||||||
                    throw new ServiceException("没有找到押金充值记录");
 | 
					                    throw new ServiceException("没有找到押金充值记录");
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }, autoRefundDeposit , TimeUnit.HOURS);
 | 
					            }, autoRefundDeposit , TimeUnit.HOURS);
 | 
				
			||||||
 | 
					        }else{
 | 
				
			||||||
 | 
					            logger.info("【微信支付回调】还车结算___小时后自动退押金参数为空");
 | 
				
			||||||
 | 
					            throw new ServiceException("还车结算___小时后自动退押金参数为空");
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -462,38 +467,49 @@ public class CallbackServiceImpl implements CallbackService {
 | 
				
			||||||
        capitalFlow.setOutTradeNo(order.getOutTradeNo());
 | 
					        capitalFlow.setOutTradeNo(order.getOutTradeNo());
 | 
				
			||||||
        capitalFlow.setType(type);
 | 
					        capitalFlow.setType(type);
 | 
				
			||||||
        capitalFlow.setBusType(busType);
 | 
					        capitalFlow.setBusType(busType);
 | 
				
			||||||
        capitalFlow.setAmount(order.getTotalFee());
 | 
					        capitalFlow.setAmount(order.getPayFee());
 | 
				
			||||||
        if(busType.equals(ServiceConstants.ORDER_TYPE_DEPOSIT) || busType.equals(ServiceConstants.ORDER_TYPE_DEPOSIT_REFUND)){
 | 
					        if(busType.equals(ServiceConstants.ORDER_TYPE_DEPOSIT) || busType.equals(ServiceConstants.ORDER_TYPE_DEPOSIT_REFUND)){
 | 
				
			||||||
            capitalFlow.setOperatorDividend(BigDecimal.ZERO);
 | 
					            capitalFlow.setOperatorDividend(BigDecimal.ZERO);
 | 
				
			||||||
            capitalFlow.setPartnerDividend(BigDecimal.ZERO);
 | 
					            capitalFlow.setPartnerDividend(BigDecimal.ZERO);
 | 
				
			||||||
        }else{
 | 
					        }else{
 | 
				
			||||||
            //获取所有合伙人列表
 | 
					            logger.info("【微信支付回调--保存资金流水记录】 ==============业务类型=====================:"+busType);
 | 
				
			||||||
            SysUser sysUser = new SysUser();
 | 
					            BigDecimal partnerDividend = BigDecimal.ZERO;
 | 
				
			||||||
            sysUser.setUserType("03");
 | 
					            BigDecimal operatorDividend = order.getPayFee();
 | 
				
			||||||
            List<SysUser> sysUsers = userMapper.selectUserList(sysUser);
 | 
					            if(sysDept.getIsProfitSharing().equals("true")){//需要分账
 | 
				
			||||||
            double totalDividendProportion = sysUsers.stream()
 | 
					                logger.info("【微信支付回调--保存资金流水记录】 ==============需要分账====================="+sysDept.getIsProfitSharing());
 | 
				
			||||||
                    .mapToDouble(SysUser::getDividendProportion)
 | 
					                //获取所有合伙人列表
 | 
				
			||||||
                    .sum();//算出总的分成比例
 | 
					                SysUser sysUser = new SysUser();
 | 
				
			||||||
            BigDecimal decimal = new BigDecimal(totalDividendProportion).divide(new BigDecimal(100), 2, BigDecimal.ROUND_HALF_UP);
 | 
					                sysUser.setUserType("03");
 | 
				
			||||||
            BigDecimal partnerDividend = order.getTotalFee().multiply(decimal);
 | 
					                sysUser.setAreaId(order.getAreaId());
 | 
				
			||||||
            BigDecimal operatorDividend = order.getTotalFee().subtract(partnerDividend);
 | 
					                List<SysUser> sysUsers = userMapper.selectUserList(sysUser);
 | 
				
			||||||
 | 
					                double totalDividendProportion = sysUsers.stream()
 | 
				
			||||||
 | 
					                        .mapToDouble(SysUser::getDividendProportion)
 | 
				
			||||||
 | 
					                        .sum();//算出总的分成比例
 | 
				
			||||||
 | 
					                BigDecimal decimal = new BigDecimal(totalDividendProportion).divide(new BigDecimal(100), 2, BigDecimal.ROUND_HALF_UP);
 | 
				
			||||||
 | 
					                partnerDividend = order.getTotalFee().multiply(decimal);
 | 
				
			||||||
 | 
					                operatorDividend = order.getTotalFee().subtract(partnerDividend);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            logger.info("【微信支付回调--保存资金流水记录】 ==============partnerDividend=====================:"+partnerDividend);
 | 
				
			||||||
 | 
					            logger.info("【微信支付回调--保存资金流水记录】 ==============operatorDividend=====================:"+operatorDividend);
 | 
				
			||||||
            if(type.equals(ServiceConstants.FLOW_TYPE_INCOME)){
 | 
					            if(type.equals(ServiceConstants.FLOW_TYPE_INCOME)){
 | 
				
			||||||
                capitalFlow.setPartnerDividend(partnerDividend);
 | 
					                capitalFlow.setPartnerDividend(partnerDividend);
 | 
				
			||||||
                capitalFlow.setOperatorDividend(operatorDividend);
 | 
					                capitalFlow.setOperatorDividend(operatorDividend);
 | 
				
			||||||
                capitalFlow.setOperatorBalance(capitalFlow.getOperatorBalance().add(operatorDividend));
 | 
					                capitalFlow.setOperatorBalance(sysDept.getBalance().add(operatorDividend));
 | 
				
			||||||
                deptService.changeDeptBalance(operatorDividend,sysDept.getDeptId());
 | 
					                deptService.changeDeptBalance(operatorDividend,sysDept.getDeptId());
 | 
				
			||||||
 | 
					                logger.info("【微信支付回调--保存资金流水记录】 ==============收入=====================:");
 | 
				
			||||||
            }else{
 | 
					            }else{
 | 
				
			||||||
                capitalFlow.setPartnerDividend(partnerDividend.negate());
 | 
					                capitalFlow.setPartnerDividend(partnerDividend.negate());
 | 
				
			||||||
                capitalFlow.setOperatorDividend(operatorDividend.negate());
 | 
					                capitalFlow.setOperatorDividend(operatorDividend.negate());
 | 
				
			||||||
                capitalFlow.setOperatorBalance(capitalFlow.getOperatorBalance().subtract(operatorDividend));
 | 
					                capitalFlow.setOperatorBalance(sysDept.getBalance().subtract(operatorDividend));
 | 
				
			||||||
                deptService.changeDeptBalance(operatorDividend.negate(),sysDept.getDeptId());
 | 
					                deptService.changeDeptBalance(operatorDividend.negate(),sysDept.getDeptId());
 | 
				
			||||||
 | 
					                logger.info("【微信支付回调--保存资金流水记录】 ==============支出=====================:");
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        BigDecimal bigDecimal = new BigDecimal(handlingCharge).divide(new BigDecimal(1000), 2, BigDecimal.ROUND_HALF_UP);
 | 
					        BigDecimal bigDecimal = new BigDecimal(handlingCharge).divide(new BigDecimal(1000), 2, BigDecimal.ROUND_HALF_UP);
 | 
				
			||||||
        capitalFlow.setHandlingCharge(bigDecimal.multiply(order.getTotalFee()));//手续费
 | 
					        capitalFlow.setHandlingCharge(bigDecimal.multiply(order.getTotalFee()));//手续费
 | 
				
			||||||
        capitalFlow.setPayType(ServiceConstants.PAY_TYPE_WX);
 | 
					        capitalFlow.setPayType(ServiceConstants.PAY_TYPE_WX);
 | 
				
			||||||
        capitalFlow.setCreateTime(DateUtils.getNowDate());
 | 
					        capitalFlow.setCreateTime(DateUtils.getNowDate());
 | 
				
			||||||
 | 
					        logger.info("【微信支付回调】保存资金流水记录对象 : " + JSON.toJSONString(capitalFlow));
 | 
				
			||||||
        int i = etCapitalFlowService.insertEtCapitalFlow(capitalFlow);
 | 
					        int i = etCapitalFlowService.insertEtCapitalFlow(capitalFlow);
 | 
				
			||||||
        if(i==0){
 | 
					        if(i==0){
 | 
				
			||||||
            throw new ServiceException("保存资金流水记录失败");
 | 
					            throw new ServiceException("保存资金流水记录失败");
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -100,7 +100,11 @@ public class EtOrderServiceImpl implements IEtOrderService
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public EtOrder selectEtOrderByOrderId(Long orderId)
 | 
					    public EtOrder selectEtOrderByOrderId(Long orderId)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        return etOrderMapper.selectEtOrderByOrderId(orderId);
 | 
					        // todo 订单详情获取行程记录、费用明细、退款明细、收费方式、终点起点、
 | 
				
			||||||
 | 
					        EtOrder order = etOrderMapper.selectEtOrderByOrderId(orderId);
 | 
				
			||||||
 | 
					        AsDevice device = asDeviceMapper.selectAsDeviceBySn(order.getSn());
 | 
				
			||||||
 | 
					        order.setDevice(device);
 | 
				
			||||||
 | 
					        return order;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
| 
						 | 
					@ -414,6 +418,7 @@ public class EtOrderServiceImpl implements IEtOrderService
 | 
				
			||||||
            log.info("【预下单】支付场景为:取消预约支付");
 | 
					            log.info("【预下单】支付场景为:取消预约支付");
 | 
				
			||||||
            etOrder = etOrderMapper.selectEtOrderByOrderNo(order.getOrderNo());
 | 
					            etOrder = etOrderMapper.selectEtOrderByOrderNo(order.getOrderNo());
 | 
				
			||||||
            etOrder.setTotalFee(etOrder.getAppointmentFee());
 | 
					            etOrder.setTotalFee(etOrder.getAppointmentFee());
 | 
				
			||||||
 | 
					            etOrder.setPayFee(etOrder.getAppointmentFee());
 | 
				
			||||||
            int updateEtOrder = etOrderService.updateEtOrder(etOrder);
 | 
					            int updateEtOrder = etOrderService.updateEtOrder(etOrder);
 | 
				
			||||||
            if(updateEtOrder==0){
 | 
					            if(updateEtOrder==0){
 | 
				
			||||||
                throw new ServiceException("【预下单】订单信息更新失败");
 | 
					                throw new ServiceException("【预下单】订单信息更新失败");
 | 
				
			||||||
| 
						 | 
					@ -480,6 +485,7 @@ public class EtOrderServiceImpl implements IEtOrderService
 | 
				
			||||||
            EtOperatingArea area = etOperatingAreaService.selectEtOperatingAreaByAreaId(user.getAreaId());
 | 
					            EtOperatingArea area = etOperatingAreaService.selectEtOperatingAreaByAreaId(user.getAreaId());
 | 
				
			||||||
            BigDecimal deposit = new BigDecimal(area.getDeposit());
 | 
					            BigDecimal deposit = new BigDecimal(area.getDeposit());
 | 
				
			||||||
            etOrder.setTotalFee(deposit);
 | 
					            etOrder.setTotalFee(deposit);
 | 
				
			||||||
 | 
					            etOrder.setPayFee(deposit);
 | 
				
			||||||
        }else {
 | 
					        }else {
 | 
				
			||||||
            throw new ServiceException("订单类型错误");
 | 
					            throw new ServiceException("订单类型错误");
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -101,7 +101,7 @@ public class WxPayService implements IWxPayService {
 | 
				
			||||||
                String isProfitSharing = sysDept.getIsProfitSharing();
 | 
					                String isProfitSharing = sysDept.getIsProfitSharing();
 | 
				
			||||||
                // 获取JSAPI所需参数
 | 
					                // 获取JSAPI所需参数
 | 
				
			||||||
                PrepayRequest request = new PrepayRequest();
 | 
					                PrepayRequest request = new PrepayRequest();
 | 
				
			||||||
                request.setAmount(getAmount(order.getTotalFee()));
 | 
					                request.setAmount(getAmount(order.getPayFee()));
 | 
				
			||||||
                String outTradeNo = IdUtils.getOrderNo("wx");
 | 
					                String outTradeNo = IdUtils.getOrderNo("wx");
 | 
				
			||||||
                order.setOutTradeNo(outTradeNo);
 | 
					                order.setOutTradeNo(outTradeNo);
 | 
				
			||||||
                int updateEtOrder = etOrderService.updateEtOrder(order);
 | 
					                int updateEtOrder = etOrderService.updateEtOrder(order);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -264,6 +264,7 @@ public class EtTask {
 | 
				
			||||||
                BigDecimal fee = appointmentServiceFee.multiply(new BigDecimal(area.getTimeoutMinutes()).divide(new BigDecimal(10)));
 | 
					                BigDecimal fee = appointmentServiceFee.multiply(new BigDecimal(area.getTimeoutMinutes()).divide(new BigDecimal(10)));
 | 
				
			||||||
                order.setAppointmentFee(fee);
 | 
					                order.setAppointmentFee(fee);
 | 
				
			||||||
                order.setTotalFee(fee);
 | 
					                order.setTotalFee(fee);
 | 
				
			||||||
 | 
					                order.setPayFee(fee);
 | 
				
			||||||
                int update = etOrderService.updateEtOrder(order);
 | 
					                int update = etOrderService.updateEtOrder(order);
 | 
				
			||||||
                if(update==0){
 | 
					                if(update==0){
 | 
				
			||||||
                    throw new ServiceException("【车辆超时预约】:更新订单状态失败");
 | 
					                    throw new ServiceException("【车辆超时预约】:更新订单状态失败");
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -126,7 +126,41 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 | 
				
			||||||
    </select>
 | 
					    </select>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    <select id="selectEtOrderByOrderId" parameterType="Long" resultMap="EtOrderResult">
 | 
					    <select id="selectEtOrderByOrderId" parameterType="Long" resultMap="EtOrderResult">
 | 
				
			||||||
        <include refid="selectEtOrderVo"/>
 | 
					        select o.order_id,
 | 
				
			||||||
 | 
					               o.area_id,
 | 
				
			||||||
 | 
					               o.order_no,
 | 
				
			||||||
 | 
					               o.out_trade_no,
 | 
				
			||||||
 | 
					               oa.area_name AS area,
 | 
				
			||||||
 | 
					               u.user_name AS userName,
 | 
				
			||||||
 | 
					               u.phonenumber AS phonenumber,
 | 
				
			||||||
 | 
					               o.rule_id,
 | 
				
			||||||
 | 
					               o.device_mac,
 | 
				
			||||||
 | 
					               o.sn,
 | 
				
			||||||
 | 
					               o.pay_time,
 | 
				
			||||||
 | 
					               o.paid,
 | 
				
			||||||
 | 
					               o.pay_type,
 | 
				
			||||||
 | 
					               o.type, COALESCE(o.total_fee, 0) AS total_fee,
 | 
				
			||||||
 | 
					               COALESCE(o.pay_fee, 0) AS pay_fee,
 | 
				
			||||||
 | 
					               COALESCE(o.dispatch_fee, 0) AS dispatch_fee,
 | 
				
			||||||
 | 
					               COALESCE(o.manage_fee, 0) AS manage_fee,
 | 
				
			||||||
 | 
					               COALESCE(o.riding_fee, 0) AS riding_fee,
 | 
				
			||||||
 | 
					               COALESCE(o.appointment_fee, 0) AS appointment_fee,
 | 
				
			||||||
 | 
					               o.mark,
 | 
				
			||||||
 | 
					               o.duration,
 | 
				
			||||||
 | 
					               o.distance,
 | 
				
			||||||
 | 
					               o.status,
 | 
				
			||||||
 | 
					               o.create_time,
 | 
				
			||||||
 | 
					               o.appointment_start_time,
 | 
				
			||||||
 | 
					               o.appointment_end_time,
 | 
				
			||||||
 | 
					               o.appointment_timeout,
 | 
				
			||||||
 | 
					               o.unlock_time,
 | 
				
			||||||
 | 
					               o.return_time,
 | 
				
			||||||
 | 
					               o.rule_end_time,
 | 
				
			||||||
 | 
					               o.return_type,
 | 
				
			||||||
 | 
					               AsText(o.trip_route) trip_route,
 | 
				
			||||||
 | 
					               o.trip_route_str from et_order o
 | 
				
			||||||
 | 
					        LEFT JOIN et_user u ON u.user_id = o.user_id
 | 
				
			||||||
 | 
					        LEFT JOIN et_operating_area oa ON o.area_id = oa.area_id
 | 
				
			||||||
        where order_id = #{orderId}
 | 
					        where order_id = #{orderId}
 | 
				
			||||||
    </select>
 | 
					    </select>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -353,7 +387,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    <select id="selectUserListFinishOrder" resultMap="EtOrderResult">
 | 
					    <select id="selectUserListFinishOrder" resultMap="EtOrderResult">
 | 
				
			||||||
        select * from   et_order o
 | 
					        select * from   et_order o
 | 
				
			||||||
        where o.status ='4' and o.paid = '1' and o.type = 1
 | 
					        where o.status ='4' and o.paid = '1' and o.type = 1 and o.is_test = '0'
 | 
				
			||||||
        GROUP BY o.user_id
 | 
					        GROUP BY o.user_id
 | 
				
			||||||
    </select>
 | 
					    </select>
 | 
				
			||||||
    <select id="selectNeedDividendOrder" resultType="com.ruoyi.system.domain.EtOrder">
 | 
					    <select id="selectNeedDividendOrder" resultType="com.ruoyi.system.domain.EtOrder">
 | 
				
			||||||
| 
						 | 
					@ -367,6 +401,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 | 
				
			||||||
          AND o.type = 1
 | 
					          AND o.type = 1
 | 
				
			||||||
          AND o.pay_type != 'sys'
 | 
					          AND o.pay_type != 'sys'
 | 
				
			||||||
	      AND o.total_fee != 0
 | 
						      AND o.total_fee != 0
 | 
				
			||||||
 | 
					          AND o.is_test = '0'
 | 
				
			||||||
    </select>
 | 
					    </select>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    <insert id="insertEtOrder" parameterType="EtOrder" useGeneratedKeys="true" keyProperty="orderId">
 | 
					    <insert id="insertEtOrder" parameterType="EtOrder" useGeneratedKeys="true" keyProperty="orderId">
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -22,6 +22,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 | 
				
			||||||
		<result property="domain" column="domain" />
 | 
							<result property="domain" column="domain" />
 | 
				
			||||||
		<result property="appid"     column="appid"       />
 | 
							<result property="appid"     column="appid"       />
 | 
				
			||||||
		<result property="appName"     column="app_name"       />
 | 
							<result property="appName"     column="app_name"       />
 | 
				
			||||||
 | 
							<result property="balance"     column="balance"       />
 | 
				
			||||||
		<result property="appSecret" column="app_secret" />
 | 
							<result property="appSecret" column="app_secret" />
 | 
				
			||||||
		<result property="merchantId" column="merchant_id" />
 | 
							<result property="merchantId" column="merchant_id" />
 | 
				
			||||||
		<result property="apiV3Key" column="api_v3_key" />
 | 
							<result property="apiV3Key" column="api_v3_key" />
 | 
				
			||||||
| 
						 | 
					@ -38,7 +39,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 | 
				
			||||||
	<sql id="selectDeptVo">
 | 
						<sql id="selectDeptVo">
 | 
				
			||||||
        select d.dept_id, d.parent_id, d.ancestors, d.dept_name,
 | 
					        select d.dept_id, d.parent_id, d.ancestors, d.dept_name,
 | 
				
			||||||
               d.order_num, d.leader, d.phone, d.email, d.status,
 | 
					               d.order_num, d.leader, d.phone, d.email, d.status,
 | 
				
			||||||
               d.del_flag,d.platform_service_fee, d.is_profit_sharing, d.domain, d.is_use_platform_app, d.appid, d.app_name, d.app_secret,
 | 
					               d.del_flag,d.platform_service_fee, d.is_profit_sharing, d.domain, d.is_use_platform_app, d.appid, d.app_name, d.balance, d.app_secret,
 | 
				
			||||||
               d.merchant_id, d.api_v3_key, d.notify_url, d.private_key_path,d.merchant_serial_number,d.refund_notify_url,
 | 
					               d.merchant_id, d.api_v3_key, d.notify_url, d.private_key_path,d.merchant_serial_number,d.refund_notify_url,
 | 
				
			||||||
               d.create_by, d.create_time
 | 
					               d.create_by, d.create_time
 | 
				
			||||||
        from sys_dept d
 | 
					        from sys_dept d
 | 
				
			||||||
| 
						 | 
					@ -76,7 +77,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 | 
				
			||||||
	</select>
 | 
						</select>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    <select id="selectDeptById" parameterType="Long" resultMap="SysDeptResult">
 | 
					    <select id="selectDeptById" parameterType="Long" resultMap="SysDeptResult">
 | 
				
			||||||
		select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status,d.platform_service_fee, d.is_profit_sharing,d.domain,d.is_use_platform_app, d.appid, d.app_name,d.app_secret,
 | 
							select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status,d.platform_service_fee, d.is_profit_sharing,d.domain,d.is_use_platform_app, d.appid, d.app_name, d.balance, d.app_secret,
 | 
				
			||||||
			   d.merchant_id, d.api_v3_key, d.notify_url, d.private_key_path,d.merchant_serial_number,d.refund_notify_url,
 | 
								   d.merchant_id, d.api_v3_key, d.notify_url, d.private_key_path,d.merchant_serial_number,d.refund_notify_url,
 | 
				
			||||||
			(select dept_name from sys_dept where dept_id = d.parent_id) parent_name
 | 
								(select dept_name from sys_dept where dept_id = d.parent_id) parent_name
 | 
				
			||||||
		from sys_dept d
 | 
							from sys_dept d
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user