1.联调
This commit is contained in:
		
							parent
							
								
									eaa2f4d6a4
								
							
						
					
					
						commit
						46740f14d8
					
				| 
						 | 
					@ -58,4 +58,6 @@ public interface EtCapitalFlowMapper
 | 
				
			||||||
     * @return 结果
 | 
					     * @return 结果
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public int deleteEtCapitalFlowByFlowIds(Long[] flowIds);
 | 
					    public int deleteEtCapitalFlowByFlowIds(Long[] flowIds);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    EtCapitalFlow selectEtCapitalFlowByOutTradeNo(String outTradeNo);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -19,6 +19,14 @@ public interface IEtCapitalFlowService
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public EtCapitalFlow selectEtCapitalFlowByFlowId(Long flowId);
 | 
					    public EtCapitalFlow selectEtCapitalFlowByFlowId(Long flowId);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 根据第三方交易单号查询资金流水
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param outTradeNo 第三方交易单号
 | 
				
			||||||
 | 
					     * @return 资金流水
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public EtCapitalFlow selectEtCapitalFlowByOutTradeNo(String outTradeNo);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * 查询资金流水列表
 | 
					     * 查询资金流水列表
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -453,7 +453,7 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
 | 
				
			||||||
        String finalOrderNo = orderNo;
 | 
					        String finalOrderNo = orderNo;
 | 
				
			||||||
        Boolean execute = transactionTemplate.execute(e -> {
 | 
					        Boolean execute = transactionTemplate.execute(e -> {
 | 
				
			||||||
            /** 2.发送命令*/
 | 
					            /** 2.发送命令*/
 | 
				
			||||||
            sendCommand(asDevice.getMac(), token,IotConstants.COMMAND_OPEN,"编号开锁");
 | 
					//            sendCommand(asDevice.getMac(), token,IotConstants.COMMAND_OPEN,"编号开锁");
 | 
				
			||||||
            /** 3.更新车辆状态*/
 | 
					            /** 3.更新车辆状态*/
 | 
				
			||||||
            asDevice.setLockStatus(ServiceConstants.LOCK_STATUS_OPEN);
 | 
					            asDevice.setLockStatus(ServiceConstants.LOCK_STATUS_OPEN);
 | 
				
			||||||
            asDevice.setStatus(ServiceConstants.VEHICLE_STATUS_IN_USING);
 | 
					            asDevice.setStatus(ServiceConstants.VEHICLE_STATUS_IN_USING);
 | 
				
			||||||
| 
						 | 
					@ -942,13 +942,8 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            //根据订单的开始时间和还车时间计算出在第几个计费周期,在第一个计费周期内,并没有超过封顶费用,则根据规则算出骑行费,
 | 
					            //根据订单的开始时间和还车时间计算出在第几个计费周期,在第一个计费周期内,并没有超过封顶费用,则根据规则算出骑行费,
 | 
				
			||||||
            Integer cycle = null;
 | 
					            Integer cycle = null;
 | 
				
			||||||
            Date startTime;
 | 
					            Date startTime = order.getUnlockTime();
 | 
				
			||||||
            Date endTime = order.getReturnTime();
 | 
					            Date endTime = order.getReturnTime();
 | 
				
			||||||
            if(ObjectUtil.isNull(order.getAppointmentFee()) || order.getAppointmentFee().compareTo(BigDecimal.ZERO) == 0){//没有预约
 | 
					 | 
				
			||||||
                startTime = order.getUnlockTime();
 | 
					 | 
				
			||||||
            }else{//有预约
 | 
					 | 
				
			||||||
                startTime = order.getAppointmentStartTime();
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            String chargingCycle = rule.getChargingCycle();
 | 
					            String chargingCycle = rule.getChargingCycle();
 | 
				
			||||||
            String chargingCycleValue = rule.getChargingCycleValue();
 | 
					            String chargingCycleValue = rule.getChargingCycleValue();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1060,12 +1055,13 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
 | 
				
			||||||
            if(ObjectUtils.isNotEmpty(returnTime) && ObjectUtils.isNotEmpty(unlockTime)){
 | 
					            if(ObjectUtils.isNotEmpty(returnTime) && ObjectUtils.isNotEmpty(unlockTime)){
 | 
				
			||||||
                if(minutes<startingTime){
 | 
					                if(minutes<startingTime){
 | 
				
			||||||
                    //小于起步分钟,按照起步价计算费用
 | 
					                    //小于起步分钟,按照起步价计算费用
 | 
				
			||||||
                    order.setRidingFee(new BigDecimal(startingPrice));
 | 
					                    ridingFee = new BigDecimal(startingPrice);
 | 
				
			||||||
                }else{
 | 
					                }else{
 | 
				
			||||||
                    //大于起步分钟,按照时长费计算费用
 | 
					                    //大于起步分钟,按照时长费计算费用
 | 
				
			||||||
                    //minutes除以startingMinutes得到的结构四舍五入
 | 
					                    //minutes除以startingMinutes得到的结构四舍五入
 | 
				
			||||||
                    minutes = minutes - timeoutTime;//扣掉起步分钟数后
 | 
					                    minutes = minutes - timeoutTime;//扣掉起步分钟数后
 | 
				
			||||||
                    ridingFee = new BigDecimal(Math.ceil(minutes / timeoutTime) * Integer.parseInt(timeoutPrice));
 | 
					                    double ceil = Math.ceil(minutes / timeoutTime) +1 ;
 | 
				
			||||||
 | 
					                    ridingFee = new BigDecimal(ceil * Integer.parseInt(timeoutPrice));
 | 
				
			||||||
                    BigDecimal startingPriceB = new BigDecimal(startingPrice);
 | 
					                    BigDecimal startingPriceB = new BigDecimal(startingPrice);
 | 
				
			||||||
                    ridingFee = ridingFee.add(startingPriceB);
 | 
					                    ridingFee = ridingFee.add(startingPriceB);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -19,6 +19,7 @@ import com.ruoyi.common.utils.http.HttpUtils;
 | 
				
			||||||
import com.ruoyi.common.utils.onenet.Token;
 | 
					import com.ruoyi.common.utils.onenet.Token;
 | 
				
			||||||
import com.ruoyi.system.domain.*;
 | 
					import com.ruoyi.system.domain.*;
 | 
				
			||||||
import com.ruoyi.system.domain.vo.AttachVo;
 | 
					import com.ruoyi.system.domain.vo.AttachVo;
 | 
				
			||||||
 | 
					import com.ruoyi.system.mapper.SysUserMapper;
 | 
				
			||||||
import com.ruoyi.system.service.*;
 | 
					import com.ruoyi.system.service.*;
 | 
				
			||||||
import com.wechat.pay.java.core.notification.Notification;
 | 
					import com.wechat.pay.java.core.notification.Notification;
 | 
				
			||||||
import com.wechat.pay.java.core.notification.NotificationParser;
 | 
					import com.wechat.pay.java.core.notification.NotificationParser;
 | 
				
			||||||
| 
						 | 
					@ -82,8 +83,11 @@ public class CallbackServiceImpl implements CallbackService {
 | 
				
			||||||
    @Value("${et.handlingCharge}")
 | 
					    @Value("${et.handlingCharge}")
 | 
				
			||||||
    private String handlingCharge;
 | 
					    private String handlingCharge;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//    @Autowired
 | 
				
			||||||
 | 
					//    private ISysUserService sysUserService;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Autowired
 | 
					    @Autowired
 | 
				
			||||||
    private ISysUserService sysUserService;
 | 
					    private SysUserMapper userMapper;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
| 
						 | 
					@ -116,7 +120,6 @@ public class CallbackServiceImpl implements CallbackService {
 | 
				
			||||||
                if(StrUtil.isNotBlank(order.getSn())){
 | 
					                if(StrUtil.isNotBlank(order.getSn())){
 | 
				
			||||||
                    asDevice = asDeviceService.selectAsDeviceBySn(order.getSn());
 | 
					                    asDevice = asDeviceService.selectAsDeviceBySn(order.getSn());
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                String iotToken = Token.getToken();
 | 
					 | 
				
			||||||
                //先判断是骑行订单还是押金,如果是骑行订单
 | 
					                //先判断是骑行订单还是押金,如果是骑行订单
 | 
				
			||||||
                // 还要区分是取消预约支付
 | 
					                // 还要区分是取消预约支付
 | 
				
			||||||
                //      如果是,更新订单状态,pay_time、pay_type(默认是wx)、appointment_fee等于total_fee,状态改为4 订单结束
 | 
					                //      如果是,更新订单状态,pay_time、pay_type(默认是wx)、appointment_fee等于total_fee,状态改为4 订单结束
 | 
				
			||||||
| 
						 | 
					@ -130,7 +133,6 @@ public class CallbackServiceImpl implements CallbackService {
 | 
				
			||||||
                    // 1-骑行支付  关锁
 | 
					                    // 1-骑行支付  关锁
 | 
				
			||||||
                    order.setStatus(ServiceConstants.ORDER_STATUS_ORDER_END);
 | 
					                    order.setStatus(ServiceConstants.ORDER_STATUS_ORDER_END);
 | 
				
			||||||
                    order.setMark("骑行支付");
 | 
					                    order.setMark("骑行支付");
 | 
				
			||||||
                    asDeviceService.sendCommand(asDevice.getMac(), iotToken, IotConstants.COMMAND_OPEN,"套餐开锁");
 | 
					 | 
				
			||||||
                    asDevice.setStatus(ServiceConstants.VEHICLE_STATUS_NORMAL);//还车后车辆正常运营
 | 
					                    asDevice.setStatus(ServiceConstants.VEHICLE_STATUS_NORMAL);//还车后车辆正常运营
 | 
				
			||||||
                    asDevice.setLockStatus(ServiceConstants.LOCK_STATUS_CLOSE);
 | 
					                    asDevice.setLockStatus(ServiceConstants.LOCK_STATUS_CLOSE);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -200,7 +202,7 @@ public class CallbackServiceImpl implements CallbackService {
 | 
				
			||||||
                        order.setAppointmentStartTime(DateUtils.getNowDate());
 | 
					                        order.setAppointmentStartTime(DateUtils.getNowDate());
 | 
				
			||||||
                        order.setMark("套餐预约支付");
 | 
					                        order.setMark("套餐预约支付");
 | 
				
			||||||
                        /** 2.发送命令*/
 | 
					                        /** 2.发送命令*/
 | 
				
			||||||
                        asDeviceService.sendCommand(asDevice.getMac(), iotToken,IotConstants.COMMAND_CLOSE,"套餐预约");
 | 
					//                        asDeviceService.sendCommand(asDevice.getMac(), iotToken,IotConstants.COMMAND_CLOSE,"套餐预约");
 | 
				
			||||||
                        /** 3.更新车辆状态*/
 | 
					                        /** 3.更新车辆状态*/
 | 
				
			||||||
                        asDevice.setStatus(ServiceConstants.VEHICLE_STATUS_IN_APPOINTMENT);//预约中
 | 
					                        asDevice.setStatus(ServiceConstants.VEHICLE_STATUS_IN_APPOINTMENT);//预约中
 | 
				
			||||||
                        asDevice.setLockStatus(ServiceConstants.LOCK_STATUS_CLOSE);
 | 
					                        asDevice.setLockStatus(ServiceConstants.LOCK_STATUS_CLOSE);
 | 
				
			||||||
| 
						 | 
					@ -209,7 +211,7 @@ public class CallbackServiceImpl implements CallbackService {
 | 
				
			||||||
                        order.setMark("套餐骑行支付");
 | 
					                        order.setMark("套餐骑行支付");
 | 
				
			||||||
                        order.setStatus(ServiceConstants.ORDER_STATUS_RIDING);//骑行中
 | 
					                        order.setStatus(ServiceConstants.ORDER_STATUS_RIDING);//骑行中
 | 
				
			||||||
                        /** 2.发送命令*/
 | 
					                        /** 2.发送命令*/
 | 
				
			||||||
                        asDeviceService.sendCommand(asDevice.getMac(), iotToken,IotConstants.COMMAND_OPEN,"套餐开锁");
 | 
					//                        asDeviceService.sendCommand(asDevice.getMac(), iotToken,IotConstants.COMMAND_OPEN,"套餐开锁");
 | 
				
			||||||
                        /** 3.更新车辆状态*/
 | 
					                        /** 3.更新车辆状态*/
 | 
				
			||||||
                        asDevice.setLockStatus(ServiceConstants.LOCK_STATUS_OPEN);
 | 
					                        asDevice.setLockStatus(ServiceConstants.LOCK_STATUS_OPEN);
 | 
				
			||||||
                        asDevice.setStatus(ServiceConstants.VEHICLE_STATUS_IN_USING);
 | 
					                        asDevice.setStatus(ServiceConstants.VEHICLE_STATUS_IN_USING);
 | 
				
			||||||
| 
						 | 
					@ -266,6 +268,9 @@ public class CallbackServiceImpl implements CallbackService {
 | 
				
			||||||
     * 资金流水记录
 | 
					     * 资金流水记录
 | 
				
			||||||
     * */
 | 
					     * */
 | 
				
			||||||
    private void capitalFlowRecords(EtOrder order,String type,String busType) {
 | 
					    private void capitalFlowRecords(EtOrder order,String type,String busType) {
 | 
				
			||||||
 | 
					        if(ObjectUtil.isNotNull(etCapitalFlowService.selectEtCapitalFlowByOutTradeNo(order.getOutTradeNo()))){
 | 
				
			||||||
 | 
					            return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        EtCapitalFlow capitalFlow = new EtCapitalFlow();
 | 
					        EtCapitalFlow capitalFlow = new EtCapitalFlow();
 | 
				
			||||||
        capitalFlow.setAreaId(order.getAreaId());
 | 
					        capitalFlow.setAreaId(order.getAreaId());
 | 
				
			||||||
        capitalFlow.setOrderNo(order.getOrderNo());
 | 
					        capitalFlow.setOrderNo(order.getOrderNo());
 | 
				
			||||||
| 
						 | 
					@ -281,13 +286,13 @@ public class CallbackServiceImpl implements CallbackService {
 | 
				
			||||||
            //获取所有合伙人列表
 | 
					            //获取所有合伙人列表
 | 
				
			||||||
            SysUser sysUser = new SysUser();
 | 
					            SysUser sysUser = new SysUser();
 | 
				
			||||||
            sysUser.setUserType("03");
 | 
					            sysUser.setUserType("03");
 | 
				
			||||||
            List<SysUser> sysUsers = sysUserService.selectUserList(sysUser);
 | 
					            List<SysUser> sysUsers = userMapper.selectUserList(sysUser);
 | 
				
			||||||
            double totalDividendProportion = sysUsers.stream()
 | 
					            double totalDividendProportion = sysUsers.stream()
 | 
				
			||||||
                    .mapToDouble(SysUser::getDividendProportion)
 | 
					                    .mapToDouble(SysUser::getDividendProportion)
 | 
				
			||||||
                    .sum();//算出总的分成比例
 | 
					                    .sum();//算出总的分成比例
 | 
				
			||||||
            BigDecimal decimal = new BigDecimal(totalDividendProportion).divide(new BigDecimal(100), 2, BigDecimal.ROUND_HALF_UP);
 | 
					            BigDecimal decimal = new BigDecimal(totalDividendProportion).divide(new BigDecimal(100), 2, BigDecimal.ROUND_HALF_UP);
 | 
				
			||||||
            BigDecimal partnerDividend = order.getTotalFee().multiply(decimal);
 | 
					            BigDecimal partnerDividend = order.getTotalFee().multiply(decimal);
 | 
				
			||||||
            BigDecimal operatorDividend = order.getTotalFee().subtract(capitalFlow.getPartnerDividend());
 | 
					            BigDecimal operatorDividend = order.getTotalFee().subtract(partnerDividend);
 | 
				
			||||||
            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);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -32,6 +32,17 @@ public class EtCapitalFlowServiceImpl implements IEtCapitalFlowService
 | 
				
			||||||
        return etCapitalFlowMapper.selectEtCapitalFlowByFlowId(flowId);
 | 
					        return etCapitalFlowMapper.selectEtCapitalFlowByFlowId(flowId);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 根据第三方交易单号查询资金流水
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param outTradeNo 第三方交易单号
 | 
				
			||||||
 | 
					     * @return 资金流水
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public EtCapitalFlow selectEtCapitalFlowByOutTradeNo(String outTradeNo) {
 | 
				
			||||||
 | 
					        return etCapitalFlowMapper.selectEtCapitalFlowByOutTradeNo(outTradeNo);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * 查询资金流水列表
 | 
					     * 查询资金流水列表
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -141,9 +141,11 @@ public class EtOperatingAreaServiceImpl extends ServiceImpl<EtOperatingAreaMappe
 | 
				
			||||||
        etAreaRuleMapper.deleteAreaRuleByAreaId(etOperatingArea.getAreaId());
 | 
					        etAreaRuleMapper.deleteAreaRuleByAreaId(etOperatingArea.getAreaId());
 | 
				
			||||||
        int i = dao.updateById(etOperatingArea);
 | 
					        int i = dao.updateById(etOperatingArea);
 | 
				
			||||||
        Long[] ruleIds = etOperatingArea.getRuleIds();
 | 
					        Long[] ruleIds = etOperatingArea.getRuleIds();
 | 
				
			||||||
 | 
					        if(ObjectUtil.isNotNull(ruleIds)){
 | 
				
			||||||
            for (Long ruleId:ruleIds){
 | 
					            for (Long ruleId:ruleIds){
 | 
				
			||||||
                etAreaRuleMapper.insert(EtAreaRule.builder().areaId(etOperatingArea.getAreaId()).ruleId(ruleId).build());
 | 
					                etAreaRuleMapper.insert(EtAreaRule.builder().areaId(etOperatingArea.getAreaId()).ruleId(ruleId).build());
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        return i;
 | 
					        return i;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -45,6 +45,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 | 
				
			||||||
        <include refid="selectEtCapitalFlowVo"/>
 | 
					        <include refid="selectEtCapitalFlowVo"/>
 | 
				
			||||||
        where flow_id = #{flowId}
 | 
					        where flow_id = #{flowId}
 | 
				
			||||||
    </select>
 | 
					    </select>
 | 
				
			||||||
 | 
					    <select id="selectEtCapitalFlowByOutTradeNo" resultType="com.ruoyi.system.domain.EtCapitalFlow">
 | 
				
			||||||
 | 
					        <include refid="selectEtCapitalFlowVo"/>
 | 
				
			||||||
 | 
					        where out_trade_no = #{outTradeNo}
 | 
				
			||||||
 | 
					    </select>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    <insert id="insertEtCapitalFlow" parameterType="EtCapitalFlow">
 | 
					    <insert id="insertEtCapitalFlow" parameterType="EtCapitalFlow">
 | 
				
			||||||
        insert into et_capital_flow
 | 
					        insert into et_capital_flow
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user