From 11fd8fa493f22c2c018a1d1ff1d087caa640a709 Mon Sep 17 00:00:00 2001 From: 18650502300 <18650502300@163.com> Date: Mon, 3 Jun 2024 12:23:23 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E5=AE=9E=E5=90=8D=E5=88=A4=E6=96=AD=202.?= =?UTF-8?q?=20=E9=AA=91=E8=A1=8C=E8=B4=B9=E7=94=A8=E4=B8=BA0=E5=88=99?= =?UTF-8?q?=E7=9B=B4=E6=8E=A5=E6=94=B9=E5=B7=B2=E6=94=AF=E4=BB=98=203.=20?= =?UTF-8?q?=E6=8A=BC=E9=87=91=E5=85=85=E5=80=BC=E4=B9=9F=E8=A6=81=E5=8A=A0?= =?UTF-8?q?=E8=BF=90=E8=90=A5=E5=8C=BAid=204.=20=E6=94=B9=E6=88=90?= =?UTF-8?q?=E7=AB=8B=E5=8D=B3=E5=88=86=E8=B4=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/app/AppVerifyController.java | 5 + .../common/constant/ServiceConstants.java | 14 +++ .../common/core/domain/entity/AsUser.java | 11 ++ .../com/ruoyi/system/domain/vo/EtOrderVo.java | 3 + .../ruoyi/system/service/IAsUserService.java | 7 ++ .../service/impl/AsDeviceServiceImpl.java | 7 -- .../service/impl/AsUserServiceImpl.java | 11 ++ .../service/impl/CallbackServiceImpl.java | 114 ++++++++++-------- .../service/impl/EtOrderServiceImpl.java | 14 +++ .../resources/mapper/system/AsUserMapper.xml | 8 +- .../resources/mapper/system/EtOrderMapper.xml | 68 +++++------ 11 files changed, 169 insertions(+), 93 deletions(-) diff --git a/electripper-admin/src/main/java/com/ruoyi/web/controller/app/AppVerifyController.java b/electripper-admin/src/main/java/com/ruoyi/web/controller/app/AppVerifyController.java index 3283c60..d32a004 100644 --- a/electripper-admin/src/main/java/com/ruoyi/web/controller/app/AppVerifyController.java +++ b/electripper-admin/src/main/java/com/ruoyi/web/controller/app/AppVerifyController.java @@ -144,6 +144,10 @@ public class AppVerifyController extends BaseController if(order.getRuleId()==null){ return error("=============================================ruleId未传!!!============================================="); } + //实名判断 + if(!asUserService.checkIsAuthentication(order.getUserId())){ + return error("您还未实名,请先实名"); + } //运营时间判断 if(!asDeviceService.isOperatingTime(order.getSn())){ return error("不在营业时间内,不得骑行"); @@ -643,6 +647,7 @@ public class AppVerifyController extends BaseController asUser.setUserId(authenticationVo.getUserId()); asUser.setRealName(authenticationVo.getRealName()); asUser.setIdCard(authenticationVo.getIdCard()); + asUser.setIsAuthentication(ServiceConstants.IS_AUTHENTICATION_YES); int updateUser = asUserService.updateUser(asUser); if(updateUser==0){ throw new ServiceException("【实名认证】保存身份信息失败"); diff --git a/electripper-common/src/main/java/com/ruoyi/common/constant/ServiceConstants.java b/electripper-common/src/main/java/com/ruoyi/common/constant/ServiceConstants.java index d959b31..01a6b02 100644 --- a/electripper-common/src/main/java/com/ruoyi/common/constant/ServiceConstants.java +++ b/electripper-common/src/main/java/com/ruoyi/common/constant/ServiceConstants.java @@ -105,6 +105,11 @@ public class ServiceConstants { */ public static final String PAY_TYPE_WX = "wx"; + /** + * 支付方式: sys-系统 免费骑行时,订单金额为0 + */ + public static final String PAY_TYPE_SYS = "sys"; + /** * 支付方式: alipay-支付宝 */ @@ -454,4 +459,13 @@ public class ServiceConstants { public static final String AREA_TIME_CUSTOM= "2"; /**----------------------------运营时间end----------------------------*/ + + /**----------------------------是否已实名start----------------------------*/ + + /** 是否认证:0-未认证;1-已认证 */ + public static final String IS_AUTHENTICATION_NO = "0"; + + public static final String IS_AUTHENTICATION_YES = "1"; + /**----------------------------是否已实名start----------------------------*/ + } diff --git a/electripper-common/src/main/java/com/ruoyi/common/core/domain/entity/AsUser.java b/electripper-common/src/main/java/com/ruoyi/common/core/domain/entity/AsUser.java index cc3e3fb..5aa9b9f 100644 --- a/electripper-common/src/main/java/com/ruoyi/common/core/domain/entity/AsUser.java +++ b/electripper-common/src/main/java/com/ruoyi/common/core/domain/entity/AsUser.java @@ -106,6 +106,17 @@ public class AsUser extends BaseEntity /** 运营区id */ private Long areaId; + /** 是否认证:0-未认证;1-已认证 */ + public String isAuthentication; + + public String getIsAuthentication() { + return isAuthentication; + } + + public void setIsAuthentication(String isAuthentication) { + this.isAuthentication = isAuthentication; + } + public Long getAreaId() { return areaId; } diff --git a/electripper-system/src/main/java/com/ruoyi/system/domain/vo/EtOrderVo.java b/electripper-system/src/main/java/com/ruoyi/system/domain/vo/EtOrderVo.java index 214266e..4525d5e 100644 --- a/electripper-system/src/main/java/com/ruoyi/system/domain/vo/EtOrderVo.java +++ b/electripper-system/src/main/java/com/ruoyi/system/domain/vo/EtOrderVo.java @@ -31,6 +31,9 @@ public class EtOrderVo { /** 备注 */ private String mark; + /** 区域id */ + private Long areaId; + // /** 是否预约 */ // private Boolean isAppointment; } diff --git a/electripper-system/src/main/java/com/ruoyi/system/service/IAsUserService.java b/electripper-system/src/main/java/com/ruoyi/system/service/IAsUserService.java index da82ee2..952620d 100644 --- a/electripper-system/src/main/java/com/ruoyi/system/service/IAsUserService.java +++ b/electripper-system/src/main/java/com/ruoyi/system/service/IAsUserService.java @@ -217,4 +217,11 @@ public interface IAsUserService * */ Object authentication(AuthenticationVo authenticationVo); + + /** + * 检测用户是否实名认证 + * @param userId + * @return + */ + boolean checkIsAuthentication(Long userId); } diff --git a/electripper-system/src/main/java/com/ruoyi/system/service/impl/AsDeviceServiceImpl.java b/electripper-system/src/main/java/com/ruoyi/system/service/impl/AsDeviceServiceImpl.java index e9e1076..6f00264 100644 --- a/electripper-system/src/main/java/com/ruoyi/system/service/impl/AsDeviceServiceImpl.java +++ b/electripper-system/src/main/java/com/ruoyi/system/service/impl/AsDeviceServiceImpl.java @@ -931,13 +931,6 @@ public class AsDeviceServiceImpl extends ServiceImpl i AsDevice device = asDeviceMapper.selectAsDeviceBySn(order.getSn()); /** 2. 车辆远程关锁*/ sendCommand(device.getMac(), token,IotConstants.COMMAND_CLOSE,"还车关锁"); - //间隔1秒 -// try { -// Thread.sleep(500); -// } catch (InterruptedException ex) { -// ex.printStackTrace(); -// } -// sendCommand(device.getMac(), token,IotConstants.COMMAND_PLAY8,"还车关锁播报"); /** 4. 更新车辆状态*/ device.setStatus(ServiceConstants.VEHICLE_STATUS_NORMAL); device.setLockStatus(ServiceConstants.LOCK_STATUS_CLOSE); diff --git a/electripper-system/src/main/java/com/ruoyi/system/service/impl/AsUserServiceImpl.java b/electripper-system/src/main/java/com/ruoyi/system/service/impl/AsUserServiceImpl.java index 26b99a3..496b098 100644 --- a/electripper-system/src/main/java/com/ruoyi/system/service/impl/AsUserServiceImpl.java +++ b/electripper-system/src/main/java/com/ruoyi/system/service/impl/AsUserServiceImpl.java @@ -520,4 +520,15 @@ public class AsUserServiceImpl implements IAsUserService return o; } + /** + * 检测是否实名认证 + */ + @Override + public boolean checkIsAuthentication(Long userId) { + if(asUserMapper.selectUserById(userId).getIsAuthentication().equals("1")){ + return true; + } + return false; + } + } diff --git a/electripper-system/src/main/java/com/ruoyi/system/service/impl/CallbackServiceImpl.java b/electripper-system/src/main/java/com/ruoyi/system/service/impl/CallbackServiceImpl.java index b29e528..e386016 100644 --- a/electripper-system/src/main/java/com/ruoyi/system/service/impl/CallbackServiceImpl.java +++ b/electripper-system/src/main/java/com/ruoyi/system/service/impl/CallbackServiceImpl.java @@ -88,9 +88,6 @@ public class CallbackServiceImpl implements CallbackService { @Autowired private IEtCapitalFlowService etCapitalFlowService; - @Value("${et.handlingCharge}") - private String handlingCharge; - @Resource private SysUserMapper userMapper; @@ -103,6 +100,12 @@ public class CallbackServiceImpl implements CallbackService { @Autowired private ScheduledExecutorService scheduledExecutorService; + @Autowired + private IEtDividendDetailService dividendDetailService; + + @Value("${et.handlingCharge}") + private String handlingCharge; + /** * 微信支付回调 @@ -196,56 +199,67 @@ public class CallbackServiceImpl implements CallbackService { } }, autoRefundDeposit, TimeUnit.HOURS); } - logger.info("=================【微信支付回调】10秒后开始请求分账=================="); - // 30秒后请求分账 - scheduledExecutorService.schedule(() -> { - logger.info("=================【微信支付回调】开始请求分账=================="); - logger.info("区域对象====="+JSON.toJSONString(area)); - logger.info("订单对象====="+JSON.toJSONString(order)); - // 请求分账 - List receivers = new ArrayList<>(); - // 获取到合伙人的openid - SysUser sysUser = new SysUser(); - sysUser.setUserType("03"); - sysUser.setAreaId(area.getAreaId()); - List sysUsers = userMapper.selectUserList(sysUser); + logger.info("=================【微信支付回调】开始请求分账=================="); + logger.info("区域对象====="+JSON.toJSONString(area)); + logger.info("订单对象====="+JSON.toJSONString(order)); + // 请求分账 + List receivers = new ArrayList<>(); + // 获取到合伙人的openid + SysUser sysUser = new SysUser(); + sysUser.setUserType("03"); + sysUser.setAreaId(area.getAreaId()); + List sysUsers = userMapper.selectUserList(sysUser); - for (SysUser sysUser1 : sysUsers){ - AsUser asUser1 = asUserMapper.selectUserById(sysUser1.getAppUserId()); - if(asUser1!=null && asUser1.getWxopenid()!=null){ - BigDecimal dividendAmount = BigDecimal.ZERO; - logger.info("=============系统用户:sysUser1============"+JSON.toJSONString(sysUser1)); - CreateOrderReceiver receiver = new CreateOrderReceiver(); - receiver.setType(ReceiverType.PERSONAL_OPENID.name()); - receiver.setAccount(asUser1.getWxopenid()); - String dividendItem = sysUser1.getDividendItem(); - logger.info("=================分账项目:dividendItem=================="+dividendItem); - if(dividendItem.contains("1")){ - logger.info("=================骑行费(骑行费+预约费)=================="); - dividendAmount = dividendAmount.add(order.getRidingFee().add(order.getAppointmentFee()));//1-骑行费(骑行费+预约费) - } - if(dividendItem.contains("2")){ - logger.info("=================调度费(调度费+管理费)=================="); - dividendAmount = dividendAmount.add(order.getManageFee().add(order.getDispatchFee()));//2-调度费(调度费+管理费) - } - logger.info("=================分账金额:dividendAmount=================="+dividendAmount); - BigDecimal divide = new BigDecimal(sysUser1.getDividendProportion()).divide(new BigDecimal(100), 2, BigDecimal.ROUND_HALF_UP); - logger.info("=================分账比例%=================="+divide); - BigDecimal multiply = dividendAmount.multiply(divide); - logger.info(sysUser1.getUserName()+"分账比例:"+sysUser1.getDividendProportion()+"%,分账金额:"+multiply); - receiver.setAmount(multiply.multiply(new BigDecimal(100)).longValue()); - receiver.setDescription("系统自动分账"); - receivers.add(receiver); + for (SysUser sysUser1 : sysUsers){ + EtDividendDetail etDividendDetail = new EtDividendDetail(); + AsUser asUser1 = asUserMapper.selectUserById(sysUser1.getAppUserId()); + if(asUser1!=null && asUser1.getWxopenid()!=null){ + BigDecimal dividendAmount = BigDecimal.ZERO; + logger.info("=============系统用户:sysUser1============"+JSON.toJSONString(sysUser1)); + CreateOrderReceiver receiver = new CreateOrderReceiver(); + receiver.setType(ReceiverType.PERSONAL_OPENID.name()); + receiver.setAccount(asUser1.getWxopenid()); + String dividendItem = sysUser1.getDividendItem(); + logger.info("=================分账项目:dividendItem=================="+dividendItem); + if(dividendItem.contains("1")){ + logger.info("=================骑行费(骑行费+预约费)=================="); + dividendAmount = dividendAmount.add(order.getRidingFee().add(order.getAppointmentFee()));//1-骑行费(骑行费+预约费) + } + if(dividendItem.contains("2")){ + logger.info("=================调度费(调度费+管理费)=================="); + dividendAmount = dividendAmount.add(order.getManageFee().add(order.getDispatchFee()));//2-调度费(调度费+管理费) + } + logger.info("=================分账金额:dividendAmount=================="+dividendAmount); + BigDecimal divide = new BigDecimal(sysUser1.getDividendProportion()).divide(new BigDecimal(100), 2, BigDecimal.ROUND_HALF_UP); + logger.info("=================分账比例%=================="+divide); + BigDecimal multiply = dividendAmount.multiply(divide); + logger.info(sysUser1.getUserName()+"分账比例:"+sysUser1.getDividendProportion()+"%,分账金额:"+multiply); + receiver.setAmount(multiply.multiply(new BigDecimal(100)).longValue()); + receiver.setDescription(area.getAreaName()+"共享电动车自动分账"); + receivers.add(receiver); + + etDividendDetail.setAreaId(area.getAreaId()); + etDividendDetail.setPartnerId(sysUser1.getUserId()); + etDividendDetail.setOrderNo(order.getOrderNo()); + etDividendDetail.setTotalAmount(order.getTotalFee()); + etDividendDetail.setCreateTime(DateUtils.getNowDate()); + etDividendDetail.setDividendProportion(sysUser1.getDividendProportion()); + etDividendDetail.setDividendAmount(multiply); + etDividendDetail.setDividendItem(dividendItem); + logger.info("【微信支付回调】保存分账明细 === " + JSON.toJSONString(etDividendDetail)); + int i = dividendDetailService.insertEtDividendDetail(etDividendDetail); + if(i==0){ + throw new ServiceException("保存分账明细失败"); } } - OrdersEntity ordersEntity = wxPayService.createOrder(transactionId,receivers); - if(ordersEntity!=null){ - logger.info("【微信支付回调】发起分账响应:【{}】",JSON.toJSON(ordersEntity)); - }else{ - logger.info("【微信支付回调】发起分账失败"); - throw new ServiceException("发起分账失败"); - } - }, 10, TimeUnit.SECONDS); + } + OrdersEntity ordersEntity = wxPayService.createOrder(transactionId,receivers); + if(ordersEntity!=null){ + logger.info("【微信支付回调】发起分账响应:【{}】",JSON.toJSON(ordersEntity)); + }else{ + logger.info("【微信支付回调】发起分账失败"); + throw new ServiceException("发起分账失败"); + } }else if(attachVo.getType().equals(ServiceConstants.BUSINESS_TYPE_APPOINTMENT)){ logger.info("【微信支付回调】取消预约支付"); // 2-取消预约支付 diff --git a/electripper-system/src/main/java/com/ruoyi/system/service/impl/EtOrderServiceImpl.java b/electripper-system/src/main/java/com/ruoyi/system/service/impl/EtOrderServiceImpl.java index 5313596..2a6f9d5 100644 --- a/electripper-system/src/main/java/com/ruoyi/system/service/impl/EtOrderServiceImpl.java +++ b/electripper-system/src/main/java/com/ruoyi/system/service/impl/EtOrderServiceImpl.java @@ -453,6 +453,7 @@ public class EtOrderServiceImpl implements IEtOrderService etOrder.setMark(order.getMark()); etOrder.setCreateTime(DateUtils.getNowDate()); etOrder.setRuleId(order.getRuleId()); + etOrder.setAreaId(order.getAreaId()); /** 订单类型 1骑行 2预约 3套餐 4押金 根据类型不同下单的参数也不同,不同的参数有: 金额、类型、rule_id(套餐id)*/ String type = order.getType(); if(type.equals("1")){//骑行订单,正常骑行(包含预约费),计时收费,根据开锁时间、起步价和起步时长、时长费和时长分钟等参数,如果有预约,还要加上预约费计算费用 @@ -784,6 +785,19 @@ public class EtOrderServiceImpl implements IEtOrderService if(ObjectUtil.isNotNull(etFeeRule)){ order.setRule(etFeeRule); } + // 骑行结束并且订单金额等于0,并且未支付 + if(ServiceConstants.ORDER_STATUS_RIDING_END.equals(order.getStatus()) && order.getTotalFee().compareTo(BigDecimal.ZERO) == 0 && order.getPaid().equals(ServiceConstants.ORDER_PAY_STATUS_NON_PAYMENT)){ + order.setPaid(ServiceConstants.ORDER_PAY_STATUS_PAID); + order.setPayTime(new Date()); + order.setPayType(ServiceConstants.PAY_TYPE_SYS); + order.setStatus(ServiceConstants.ORDER_STATUS_ORDER_END); + int updateEtOrder = etOrderMapper.updateEtOrder(order); + if(updateEtOrder == 0){ + throw new ServiceException("更新订单outTradeNo失败"); + }else { + log.info("【isInOrder接口】更新订单outTradeNo成功"); + } + } } return inOrder; } diff --git a/electripper-system/src/main/resources/mapper/system/AsUserMapper.xml b/electripper-system/src/main/resources/mapper/system/AsUserMapper.xml index 8532057..f9eacae 100644 --- a/electripper-system/src/main/resources/mapper/system/AsUserMapper.xml +++ b/electripper-system/src/main/resources/mapper/system/AsUserMapper.xml @@ -32,20 +32,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + select u.user_id, u.user_name, u.real_name, u.id_card, u.nick_name, u.email, u.avatar, u.phonenumber, u.balance, u.birthday, u.password, u.pay_password, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark,u.wxopenid, - u.is_sign,u.role,u.sys_user_id,u.area_id + u.is_sign,u.role,u.sys_user_id,u.area_id,u.is_authentication from et_user u SELECT - o.order_id, - o.area_id, - oa.area_name AS area, - u.user_name AS userName, - u.phonenumber AS phonenumber, - o.order_no, - o.out_trade_no, - o.user_id, - 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.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), - o.trip_route_str + o.order_id, + o.area_id, + oa.area_name AS area, + u.user_name AS userName, + u.phonenumber AS phonenumber, + o.order_no, + o.out_trade_no, + o.user_id, + 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.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), + o.trip_route_str FROM et_order o LEFT JOIN