This commit is contained in:
邱贞招 2024-05-27 21:14:49 +08:00
parent eaa2f4d6a4
commit 46740f14d8
7 changed files with 76 additions and 48 deletions

View File

@ -5,15 +5,15 @@ import com.ruoyi.system.domain.EtCapitalFlow;
/** /**
* 资金流水Mapper接口 * 资金流水Mapper接口
* *
* @author 邱贞招 * @author 邱贞招
* @date 2024-05-24 * @date 2024-05-24
*/ */
public interface EtCapitalFlowMapper public interface EtCapitalFlowMapper
{ {
/** /**
* 查询资金流水 * 查询资金流水
* *
* @param flowId 资金流水主键 * @param flowId 资金流水主键
* @return 资金流水 * @return 资金流水
*/ */
@ -21,7 +21,7 @@ public interface EtCapitalFlowMapper
/** /**
* 查询资金流水列表 * 查询资金流水列表
* *
* @param etCapitalFlow 资金流水 * @param etCapitalFlow 资金流水
* @return 资金流水集合 * @return 资金流水集合
*/ */
@ -29,7 +29,7 @@ public interface EtCapitalFlowMapper
/** /**
* 新增资金流水 * 新增资金流水
* *
* @param etCapitalFlow 资金流水 * @param etCapitalFlow 资金流水
* @return 结果 * @return 结果
*/ */
@ -37,7 +37,7 @@ public interface EtCapitalFlowMapper
/** /**
* 修改资金流水 * 修改资金流水
* *
* @param etCapitalFlow 资金流水 * @param etCapitalFlow 资金流水
* @return 结果 * @return 结果
*/ */
@ -45,7 +45,7 @@ public interface EtCapitalFlowMapper
/** /**
* 删除资金流水 * 删除资金流水
* *
* @param flowId 资金流水主键 * @param flowId 资金流水主键
* @return 结果 * @return 结果
*/ */
@ -53,9 +53,11 @@ public interface EtCapitalFlowMapper
/** /**
* 批量删除资金流水 * 批量删除资金流水
* *
* @param flowIds 需要删除的数据主键集合 * @param flowIds 需要删除的数据主键集合
* @return 结果 * @return 结果
*/ */
public int deleteEtCapitalFlowByFlowIds(Long[] flowIds); public int deleteEtCapitalFlowByFlowIds(Long[] flowIds);
EtCapitalFlow selectEtCapitalFlowByOutTradeNo(String outTradeNo);
} }

View File

@ -5,23 +5,31 @@ import com.ruoyi.system.domain.EtCapitalFlow;
/** /**
* 资金流水Service接口 * 资金流水Service接口
* *
* @author 邱贞招 * @author 邱贞招
* @date 2024-05-24 * @date 2024-05-24
*/ */
public interface IEtCapitalFlowService public interface IEtCapitalFlowService
{ {
/** /**
* 查询资金流水 * 查询资金流水
* *
* @param flowId 资金流水主键 * @param flowId 资金流水主键
* @return 资金流水 * @return 资金流水
*/ */
public EtCapitalFlow selectEtCapitalFlowByFlowId(Long flowId); public EtCapitalFlow selectEtCapitalFlowByFlowId(Long flowId);
/**
* 根据第三方交易单号查询资金流水
*
* @param outTradeNo 第三方交易单号
* @return 资金流水
*/
public EtCapitalFlow selectEtCapitalFlowByOutTradeNo(String outTradeNo);
/** /**
* 查询资金流水列表 * 查询资金流水列表
* *
* @param etCapitalFlow 资金流水 * @param etCapitalFlow 资金流水
* @return 资金流水集合 * @return 资金流水集合
*/ */
@ -29,7 +37,7 @@ public interface IEtCapitalFlowService
/** /**
* 新增资金流水 * 新增资金流水
* *
* @param etCapitalFlow 资金流水 * @param etCapitalFlow 资金流水
* @return 结果 * @return 结果
*/ */
@ -37,7 +45,7 @@ public interface IEtCapitalFlowService
/** /**
* 修改资金流水 * 修改资金流水
* *
* @param etCapitalFlow 资金流水 * @param etCapitalFlow 资金流水
* @return 结果 * @return 结果
*/ */
@ -45,7 +53,7 @@ public interface IEtCapitalFlowService
/** /**
* 批量删除资金流水 * 批量删除资金流水
* *
* @param flowIds 需要删除的资金流水主键集合 * @param flowIds 需要删除的资金流水主键集合
* @return 结果 * @return 结果
*/ */
@ -53,7 +61,7 @@ public interface IEtCapitalFlowService
/** /**
* 删除资金流水信息 * 删除资金流水信息
* *
* @param flowId 资金流水主键 * @param flowId 资金流水主键
* @return 结果 * @return 结果
*/ */

View File

@ -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);
} }

View File

@ -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_timepay_type默认是wxappointment_fee等于total_fee状态改为4 订单结束 // 如果是,更新订单状态pay_timepay_type默认是wxappointment_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);

View File

@ -10,19 +10,19 @@ import com.ruoyi.system.service.IEtCapitalFlowService;
/** /**
* 资金流水Service业务层处理 * 资金流水Service业务层处理
* *
* @author 邱贞招 * @author 邱贞招
* @date 2024-05-24 * @date 2024-05-24
*/ */
@Service @Service
public class EtCapitalFlowServiceImpl implements IEtCapitalFlowService public class EtCapitalFlowServiceImpl implements IEtCapitalFlowService
{ {
@Autowired @Autowired
private EtCapitalFlowMapper etCapitalFlowMapper; private EtCapitalFlowMapper etCapitalFlowMapper;
/** /**
* 查询资金流水 * 查询资金流水
* *
* @param flowId 资金流水主键 * @param flowId 资金流水主键
* @return 资金流水 * @return 资金流水
*/ */
@ -32,9 +32,20 @@ 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);
}
/** /**
* 查询资金流水列表 * 查询资金流水列表
* *
* @param etCapitalFlow 资金流水 * @param etCapitalFlow 资金流水
* @return 资金流水 * @return 资金流水
*/ */
@ -46,7 +57,7 @@ public class EtCapitalFlowServiceImpl implements IEtCapitalFlowService
/** /**
* 新增资金流水 * 新增资金流水
* *
* @param etCapitalFlow 资金流水 * @param etCapitalFlow 资金流水
* @return 结果 * @return 结果
*/ */
@ -59,7 +70,7 @@ public class EtCapitalFlowServiceImpl implements IEtCapitalFlowService
/** /**
* 修改资金流水 * 修改资金流水
* *
* @param etCapitalFlow 资金流水 * @param etCapitalFlow 资金流水
* @return 结果 * @return 结果
*/ */
@ -71,7 +82,7 @@ public class EtCapitalFlowServiceImpl implements IEtCapitalFlowService
/** /**
* 批量删除资金流水 * 批量删除资金流水
* *
* @param flowIds 需要删除的资金流水主键 * @param flowIds 需要删除的资金流水主键
* @return 结果 * @return 结果
*/ */
@ -83,7 +94,7 @@ public class EtCapitalFlowServiceImpl implements IEtCapitalFlowService
/** /**
* 删除资金流水信息 * 删除资金流水信息
* *
* @param flowId 资金流水主键 * @param flowId 资金流水主键
* @return 结果 * @return 结果
*/ */

View File

@ -141,8 +141,10 @@ 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();
for (Long ruleId:ruleIds){ if(ObjectUtil.isNotNull(ruleIds)){
etAreaRuleMapper.insert(EtAreaRule.builder().areaId(etOperatingArea.getAreaId()).ruleId(ruleId).build()); for (Long ruleId:ruleIds){
etAreaRuleMapper.insert(EtAreaRule.builder().areaId(etOperatingArea.getAreaId()).ruleId(ruleId).build());
}
} }
return i; return i;
} }

View File

@ -3,7 +3,7 @@
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.system.mapper.EtCapitalFlowMapper"> <mapper namespace="com.ruoyi.system.mapper.EtCapitalFlowMapper">
<resultMap type="EtCapitalFlow" id="EtCapitalFlowResult"> <resultMap type="EtCapitalFlow" id="EtCapitalFlowResult">
<result property="flowId" column="flow_id" /> <result property="flowId" column="flow_id" />
<result property="areaId" column="area_id" /> <result property="areaId" column="area_id" />
@ -26,7 +26,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectEtCapitalFlowList" parameterType="EtCapitalFlow" resultMap="EtCapitalFlowResult"> <select id="selectEtCapitalFlowList" parameterType="EtCapitalFlow" resultMap="EtCapitalFlowResult">
<include refid="selectEtCapitalFlowVo"/> <include refid="selectEtCapitalFlowVo"/>
<where> <where>
<if test="areaId != null "> and area_id = #{areaId}</if> <if test="areaId != null "> and area_id = #{areaId}</if>
<if test="orderNo != null and orderNo != ''"> and order_no = #{orderNo}</if> <if test="orderNo != null and orderNo != ''"> and order_no = #{orderNo}</if>
<if test="outTradeNo != null and outTradeNo != ''"> and out_trade_no = #{outTradeNo}</if> <if test="outTradeNo != null and outTradeNo != ''"> and out_trade_no = #{outTradeNo}</if>
@ -40,12 +40,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="payType != null and payType != ''"> and pay_type = #{payType}</if> <if test="payType != null and payType != ''"> and pay_type = #{payType}</if>
</where> </where>
</select> </select>
<select id="selectEtCapitalFlowByFlowId" parameterType="Long" resultMap="EtCapitalFlowResult"> <select id="selectEtCapitalFlowByFlowId" parameterType="Long" resultMap="EtCapitalFlowResult">
<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
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
@ -104,9 +108,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</delete> </delete>
<delete id="deleteEtCapitalFlowByFlowIds" parameterType="String"> <delete id="deleteEtCapitalFlowByFlowIds" parameterType="String">
delete from et_capital_flow where flow_id in delete from et_capital_flow where flow_id in
<foreach item="flowId" collection="array" open="(" separator="," close=")"> <foreach item="flowId" collection="array" open="(" separator="," close=")">
#{flowId} #{flowId}
</foreach> </foreach>
</delete> </delete>
</mapper> </mapper>