下单校验
用户余额
This commit is contained in:
parent
1585e00184
commit
fc0d19d7f9
|
@ -110,10 +110,54 @@ public class AppVerifyController extends BaseController
|
||||||
public AjaxResult createOrder(@RequestBody RlOrderQuery order)
|
public AjaxResult createOrder(@RequestBody RlOrderQuery order)
|
||||||
{
|
{
|
||||||
logger.info("【下单】请求参数:order={}", JSON.toJSON(order));
|
logger.info("【下单】请求参数:order={}", JSON.toJSON(order));
|
||||||
|
// 下单校验
|
||||||
|
orderCheck(order);
|
||||||
PrepayResponseVO orderServiceOrder = orderService.createOrder(order,getUserId());
|
PrepayResponseVO orderServiceOrder = orderService.createOrder(order,getUserId());
|
||||||
return success(orderServiceOrder);
|
return success(orderServiceOrder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void orderCheck(RlOrderQuery order) {
|
||||||
|
if(StringUtils.isEmpty(order.getOrderNo())){
|
||||||
|
throw new ServiceException("订单号不能为空");
|
||||||
|
}
|
||||||
|
// 车型id不能为空
|
||||||
|
if(order.getModelId() != null){
|
||||||
|
throw new ServiceException("车型id不能为空");
|
||||||
|
}
|
||||||
|
// 配送方式不能为空
|
||||||
|
if(order.getDeliveryMethod() != null){
|
||||||
|
throw new ServiceException("配送方式不能为空");
|
||||||
|
}
|
||||||
|
// 取车时间不能为空
|
||||||
|
if(ObjectUtil.isNotNull(order.getPickupTime())){
|
||||||
|
throw new ServiceException("取车时间不能为空");
|
||||||
|
}
|
||||||
|
// 取车经纬度不能为空
|
||||||
|
if(StringUtils.isEmpty(order.getPickupLon()) && StringUtils.isEmpty(order.getPickupLat())){
|
||||||
|
throw new ServiceException("取车经度不能为空");
|
||||||
|
}
|
||||||
|
// ruleId不能为空
|
||||||
|
if(order.getRuleId() != null){
|
||||||
|
throw new ServiceException("计费规则id不能为空");
|
||||||
|
}
|
||||||
|
// agentId不能为空
|
||||||
|
if(order.getAgentId() != null){
|
||||||
|
throw new ServiceException("代理商id不能为空");
|
||||||
|
}
|
||||||
|
// storeId不能为空
|
||||||
|
if(order.getStoreId() != null){
|
||||||
|
throw new ServiceException("门店id不能为空");
|
||||||
|
}
|
||||||
|
// 数量num不能为空
|
||||||
|
if(order.getNum() != null){
|
||||||
|
throw new ServiceException("数量不能为空");
|
||||||
|
}
|
||||||
|
// 订单类型type不能为空
|
||||||
|
if(order.getType() != null){
|
||||||
|
throw new ServiceException("订单类型不能为空");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 确认支付
|
* 确认支付
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -673,4 +673,33 @@ public class ServiceConstants {
|
||||||
public static final String RETURN_METHOD_PICKUP = "2";
|
public static final String RETURN_METHOD_PICKUP = "2";
|
||||||
|
|
||||||
/**----------------------------还车方式end----------------------------*/
|
/**----------------------------还车方式end----------------------------*/
|
||||||
|
|
||||||
|
/**----------------------------业务类型start----------------------------*/
|
||||||
|
/** 业务类型:1-骑行订单;2-押金订单;3-押金订单退款;4-骑行订单退款(包含调度费、停车点外调度费)5-提现;6-提现失败;7-车损收入;8-短信扣费 */
|
||||||
|
/** 业务类型:1-骑行订单 */
|
||||||
|
public static final String RIDE_ORDER = "1";
|
||||||
|
|
||||||
|
/** 业务类型:2-押金订单 */
|
||||||
|
public static final String DEPOSIT_ORDER = "2";
|
||||||
|
|
||||||
|
/** 业务类型:3-押金订单退款 */
|
||||||
|
public static final String DEPOSIT_REFUND_ORDER = "3";
|
||||||
|
|
||||||
|
/** 业务类型:4-骑行订单退款(包含调度费、停车点外调度费) */
|
||||||
|
public static final String RIDE_REFUND_ORDER = "4";
|
||||||
|
|
||||||
|
/** 业务类型:5-提现 */
|
||||||
|
public static final String WITHDRAWAL = "5";
|
||||||
|
|
||||||
|
/** 业务类型:6-提现失败 */
|
||||||
|
public static final String WITHDRAWAL_FAILURE = "6";
|
||||||
|
|
||||||
|
/** 业务类型:7-车损收入 */
|
||||||
|
public static final String CAR_DAMAGE_INCOME = "7";
|
||||||
|
|
||||||
|
/** 业务类型:8-短信扣费 */
|
||||||
|
public static final String SMS_FEE_DEDUCTION = "8";
|
||||||
|
|
||||||
|
/**----------------------------业务类型end----------------------------*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,14 @@ public class RlOrder extends BaseEntity
|
||||||
@Excel(name = "用户ID")
|
@Excel(name = "用户ID")
|
||||||
private Long userId;
|
private Long userId;
|
||||||
|
|
||||||
|
/** 用户名 */
|
||||||
|
@Excel(name = "用户名")
|
||||||
|
private String userName;
|
||||||
|
|
||||||
|
/** 手机号 */
|
||||||
|
@Excel(name = "手机号")
|
||||||
|
private String phone;
|
||||||
|
|
||||||
/** 计费规则id */
|
/** 计费规则id */
|
||||||
@Excel(name = "计费规则id")
|
@Excel(name = "计费规则id")
|
||||||
private Long ruleId;
|
private Long ruleId;
|
||||||
|
@ -235,4 +243,7 @@ public class RlOrder extends BaseEntity
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
@Excel(name = "支付时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
|
@Excel(name = "支付时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
|
||||||
private Date autoCancelTime;
|
private Date autoCancelTime;
|
||||||
|
|
||||||
|
/** 成本 */
|
||||||
|
private BigDecimal cost;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import com.ruoyi.common.core.domain.entity.RlUserVO;
|
||||||
import com.ruoyi.common.core.domain.vo.LabelVo;
|
import com.ruoyi.common.core.domain.vo.LabelVo;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -184,4 +185,12 @@ public interface RlUserMapper
|
||||||
* 更新用户密码
|
* 更新用户密码
|
||||||
*/
|
*/
|
||||||
int updateUserPwd(@Param("userId") Long userId, @Param("password") String password);
|
int updateUserPwd(@Param("userId") Long userId, @Param("password") String password);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取用户余额
|
||||||
|
*
|
||||||
|
* @param userId 用户id
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
BigDecimal selectUserBalanceById(Long userId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ public interface CallbackService {
|
||||||
* @param outTradeNo
|
* @param outTradeNo
|
||||||
* @return String
|
* @return String
|
||||||
*/
|
*/
|
||||||
public void businessHandle(String outTradeNo,AttachVo attachVo,String payType);
|
public void businessHandle(String outTradeNo,String payType);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 微信退款回调
|
* 微信退款回调
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.ruoyi.system.service;
|
||||||
import com.ruoyi.common.core.domain.entity.RlUser;
|
import com.ruoyi.common.core.domain.entity.RlUser;
|
||||||
import com.ruoyi.system.domain.query.AuthenticationQuery;
|
import com.ruoyi.system.domain.query.AuthenticationQuery;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -365,4 +366,12 @@ public interface IRlUserService
|
||||||
* @param roleIds 角色组
|
* @param roleIds 角色组
|
||||||
*/
|
*/
|
||||||
public void insertUserAuth(Long userId, Long[] roleIds);
|
public void insertUserAuth(Long userId, Long[] roleIds);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取用户余额
|
||||||
|
*
|
||||||
|
* @param userId 用户id
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
BigDecimal selectUserBalanceById(Long userId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,19 +2,18 @@ package com.ruoyi.system.service.impl;
|
||||||
|
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.alibaba.fastjson2.JSON;
|
import com.alibaba.fastjson2.JSON;
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
|
||||||
import com.ruoyi.common.constant.Constants;
|
import com.ruoyi.common.constant.Constants;
|
||||||
import com.ruoyi.common.constant.ServiceConstants;
|
import com.ruoyi.common.constant.ServiceConstants;
|
||||||
import com.ruoyi.common.core.redis.RedisCache;
|
|
||||||
import com.ruoyi.common.exception.ServiceException;
|
import com.ruoyi.common.exception.ServiceException;
|
||||||
import com.ruoyi.common.pay.wx.domain.NotifyEventType;
|
import com.ruoyi.common.pay.wx.domain.NotifyEventType;
|
||||||
import com.ruoyi.common.utils.DateUtils;
|
import com.ruoyi.common.utils.DateUtils;
|
||||||
import com.ruoyi.common.utils.http.HttpUtils;
|
import com.ruoyi.common.utils.http.HttpUtils;
|
||||||
import com.ruoyi.system.domain.EtCallbackLog;
|
import com.ruoyi.system.domain.EtCallbackLog;
|
||||||
|
import com.ruoyi.system.domain.changeBalance.RlChangeBalance;
|
||||||
import com.ruoyi.system.domain.channel.ChannelVO;
|
import com.ruoyi.system.domain.channel.ChannelVO;
|
||||||
import com.ruoyi.system.domain.order.RlOrder;
|
import com.ruoyi.system.domain.order.RlOrder;
|
||||||
import com.ruoyi.system.domain.refund.RlRefund;
|
import com.ruoyi.system.domain.refund.RlRefund;
|
||||||
import com.ruoyi.system.domain.vo.AttachVo;
|
import com.ruoyi.system.domain.rule.RlFeeRule;
|
||||||
import com.ruoyi.system.mapper.EtCallbackLogMapper;
|
import com.ruoyi.system.mapper.EtCallbackLogMapper;
|
||||||
import com.ruoyi.system.service.*;
|
import com.ruoyi.system.service.*;
|
||||||
import com.wechat.pay.java.core.RSAAutoCertificateConfig;
|
import com.wechat.pay.java.core.RSAAutoCertificateConfig;
|
||||||
|
@ -28,7 +27,6 @@ import com.wechat.pay.java.service.refund.model.Status;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.transaction.support.TransactionTemplate;
|
import org.springframework.transaction.support.TransactionTemplate;
|
||||||
|
@ -36,6 +34,7 @@ import org.springframework.transaction.support.TransactionTemplate;
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
@ -52,7 +51,7 @@ public class CallbackServiceImpl implements CallbackService {
|
||||||
private IRlOrderService orderService;
|
private IRlOrderService orderService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private RedisCache redisCache;
|
private IRlFeeRuleService feeRuleService;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private IRlRefundService etRefundService;
|
private IRlRefundService etRefundService;
|
||||||
|
@ -69,23 +68,11 @@ public class CallbackServiceImpl implements CallbackService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private RlChannelService rlChannelService;
|
private RlChannelService rlChannelService;
|
||||||
|
|
||||||
@Value("${aliyun.accessKeyId}")
|
@Autowired
|
||||||
private String accessKeyId;
|
private IRlUserService userService;
|
||||||
|
|
||||||
@Value("${aliyun.accessKeySecret}")
|
@Autowired
|
||||||
private String accessKeySecret;
|
private IRlChangeBalanceService changeBalanceService;
|
||||||
|
|
||||||
@Value("${aliyun.signName}")
|
|
||||||
private String signName;
|
|
||||||
|
|
||||||
@Value("${aliyun.templateCode}")
|
|
||||||
private String templateCode;
|
|
||||||
|
|
||||||
@Value("${aliyun.templateCode2}")
|
|
||||||
private String templateCode2;
|
|
||||||
|
|
||||||
// @Resource
|
|
||||||
// private EtMsgLogMapper etMsgLogMapper;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -112,144 +99,85 @@ public class CallbackServiceImpl implements CallbackService {
|
||||||
if (Transaction.TradeStateEnum.SUCCESS.equals(transaction.getTradeState())) {
|
if (Transaction.TradeStateEnum.SUCCESS.equals(transaction.getTradeState())) {
|
||||||
// 充值成功后的业务处理
|
// 充值成功后的业务处理
|
||||||
etCallbackLog.setBody(JSON.toJSONString(transaction));
|
etCallbackLog.setBody(JSON.toJSONString(transaction));
|
||||||
AttachVo attachVo = JSONObject.parseObject(transaction.getAttach(),AttachVo.class);
|
businessHandle(transaction.getOutTradeNo(), ServiceConstants.PAY_TYPE_WX);//业务处理
|
||||||
businessHandle(transaction.getOutTradeNo(), attachVo, ServiceConstants.PAY_TYPE_WX);//业务处理
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 支付成功后的业务处理
|
* 支付成功后的业务处理
|
||||||
|
* 1. 更改订单状态,订单到期时间修改,账变记录保存至订单
|
||||||
|
* 2. 生成配送工单
|
||||||
|
* 3. 生成账变记录
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void businessHandle(String outTradeNo,AttachVo attachVo,String payType) {
|
public void businessHandle(String outTradeNo,String payType) {
|
||||||
// 充值成功后的业务处理
|
// 充值成功后的业务处理
|
||||||
RlOrder order = orderService.selectRlOrderByOutTradeNo(outTradeNo);
|
RlOrder order = orderService.selectRlOrderByOutTradeNo(outTradeNo);
|
||||||
RlOrder order1 = new RlOrder();
|
RlOrder order1 = new RlOrder();
|
||||||
order1.setOrderId(order.getOrderId());
|
order1.setOrderId(order.getOrderId());
|
||||||
logger.info("【微信支付回调】订单信息 : " + JSON.toJSONString(order));
|
logger.info("【微信支付回调】订单信息 : " + JSON.toJSONString(order));
|
||||||
logger.info("【微信支付回调】========== orderId : " + order.getOrderId());
|
|
||||||
|
|
||||||
Long payChannel = order.getPayChannel();
|
Long payChannel = order.getPayChannel();
|
||||||
ChannelVO channelVO = rlChannelService.selectSmChannelByChannelId(payChannel);
|
ChannelVO channelVO = rlChannelService.selectSmChannelByChannelId(payChannel);
|
||||||
|
|
||||||
// AsUser asUser = asUserMapper.selectUserById(order.getUserId());
|
logger.info("【微信支付回调】租赁订单支付");
|
||||||
// /** 支付回调逻辑 1. 处理预约还是开锁 电压 */
|
|
||||||
// AsDevice asDevice = null;
|
/** 计算到期时间*/
|
||||||
// if(StrUtil.isNotBlank(order.getSn())){
|
calculateExpiryTime(order);
|
||||||
// asDevice = asDeviceMapper.selectAsDeviceBySn(order.getSn());
|
|
||||||
// }
|
Boolean execute = transactionTemplate.execute(e -> {
|
||||||
// if(attachVo.getType().equals(ServiceConstants.BUSINESS_TYPE_RIDING)){
|
/** 生成账变记录*/
|
||||||
// logger.info("【微信支付回调】骑行支付");
|
generateChanggeBalance(order);
|
||||||
// // 1-骑行支付 关锁
|
order1.setPaid("1");
|
||||||
// EtOperatingArea area = etOperatingAreaService.selectEtOperatingAreaByAreaId(order.getAreaId());
|
order1.setPayTime(DateUtils.getNowDate());
|
||||||
// order1.setMark("骑行支付");
|
order1.setPayType(payType);
|
||||||
// logger.info("=================【微信支付回调】11111111==================");
|
order1.setCost(getCost(channelVO,order.getPayFee()));
|
||||||
// if(ServiceConstants.RETURN_VERIFY_YES.equals(area.getReturnVerify())){
|
logger.info("=================【微信支付回调】开始更新订单信息=================={}",JSON.toJSON(order1));
|
||||||
// logger.info("【微信支付回调】还车-----需要-----拍照审核");
|
int updateEtOrder = orderService.updateRlOrder(order1);
|
||||||
// order1.setStatus(ServiceConstants.ORDER_STATUS_TO_BE_AUDIT);//如果还车需要拍照审核,状态为待审核
|
if(updateEtOrder==0){
|
||||||
// BigDecimal amount = order.getPayFee();
|
logger.error("【微信支付回调】更新订单信息失败");
|
||||||
//
|
throw new ServiceException("【微信支付回调】更新订单信息失败");
|
||||||
// // 异步处理短信
|
}
|
||||||
// if("1".equals(area.getMsgSwitch())){
|
logger.info("=================【微信支付回调】全部结束!!!!!==================");
|
||||||
// asynchronousMsg(order, amount);
|
return Boolean.TRUE;
|
||||||
// }
|
});
|
||||||
// }else{
|
if(!execute)throw new ServiceException("微信支付回调失败");
|
||||||
// logger.info("【微信支付回调】还车-----不需要-----拍照审核");
|
}
|
||||||
// order1.setStatus(ServiceConstants.ORDER_STATUS_ORDER_END);
|
|
||||||
// // 还车结算___小时后自动退押金---创建一个定时器TimerTask,计算出退还时间后,执行退款操作
|
|
||||||
// logger.info("=================【微信支付回调】22222222==================");
|
private void generateChanggeBalance(RlOrder order) {
|
||||||
// // 退还押金处理
|
RlChangeBalance rlChangeBalance = new RlChangeBalance();
|
||||||
// refundDeposit(area.getDeposit(), order, asUser);
|
rlChangeBalance.setOrderNo(order.getOrderNo());
|
||||||
// logger.info("=================【微信支付回调】33333333==================");
|
rlChangeBalance.setOutTradeNo(order.getOutTradeNo());
|
||||||
// // 用户付款通知
|
rlChangeBalance.setType("1");
|
||||||
// if("1".equals(area.getMsgSwitch())){
|
rlChangeBalance.setBusType(ServiceConstants.RIDE_ORDER);
|
||||||
// asynchronousMsg2(order);
|
BigDecimal balance = userService.selectUserBalanceById(order.getUserId());
|
||||||
// }
|
rlChangeBalance.setBeforeBalance(balance);
|
||||||
// }
|
rlChangeBalance.setAfterBalance(balance.add(order.getPayFee()));
|
||||||
// asDevice.setStatus(ServiceConstants.VEHICLE_STATUS_NORMAL);//还车后车辆正常运营
|
rlChangeBalance.setAmount(order.getPayFee());
|
||||||
// asDevice.setLockStatus(ServiceConstants.LOCK_STATUS_CLOSE);
|
rlChangeBalance.setOwnerId(order.getUserId());
|
||||||
// // 新增资金流水记录
|
rlChangeBalance.setOwnerName(order.getUserName());
|
||||||
// EtCapitalFlow capitalFlow = capitalFlowRecords(order, ServiceConstants.FLOW_TYPE_INCOME, ServiceConstants.ORDER_TYPE_RIDING, ServiceConstants.OWNER_TYPE_OPERATOR, null, ServiceConstants.PAY_TYPE_WX);
|
rlChangeBalance.setOwnerPhone(order.getPhone());
|
||||||
// logger.info("=================【微信支付回调-新增资金流水记录后】=================={}",JSON.toJSON(capitalFlow));
|
rlChangeBalance.setCreateTime(DateUtils.getNowDate());
|
||||||
// order1.setHandlingCharge(capitalFlow.getHandlingCharge());
|
rlChangeBalance.setReason("租赁订单:"+ order.getOrderNo());
|
||||||
// order1.setPlatformServiceFee(capitalFlow.getPlatformServiceFee());
|
int i = changeBalanceService.insertRlChangeBalance(rlChangeBalance);
|
||||||
// order1.setOperatorDividend(capitalFlow.getOperatorDividend());
|
if(i>0){
|
||||||
// order1.setCost(getCost(channelVO,order.getPayFee()));
|
logger.info("【微信支付回调】账变记录插入成功");
|
||||||
// logger.info("=================【微信支付回调】4444444==================");
|
}
|
||||||
// }else if(attachVo.getType().equals(ServiceConstants.BUSINESS_TYPE_APPOINTMENT)){
|
}
|
||||||
// logger.info("【微信支付回调】取消预约支付");
|
|
||||||
// // 2-取消预约支付
|
private void calculateExpiryTime(RlOrder order) {
|
||||||
// order1.setStatus(ServiceConstants.ORDER_STATUS_ORDER_END);
|
/** 如果是租赁订单,根据取车时间计算到期时间
|
||||||
// order1.setMark("取消预约支付");
|
* 如果是续费订单,根据到期时间计算续费订单的到期时间 */
|
||||||
// asDevice.setStatus(ServiceConstants.VEHICLE_STATUS_NORMAL);//取消预约支付后车辆正常运营
|
RlFeeRule feeRule = feeRuleService.selectRlFeeRuleByRuleId(order.getRuleId());
|
||||||
// asDevice.setLockStatus(ServiceConstants.LOCK_STATUS_CLOSE);
|
Date startTime = null;
|
||||||
// }else if(attachVo.getType().equals(ServiceConstants.ORDER_TYPE_COUPON)){
|
if(order.getType().equals(ServiceConstants.ORDER_TYPE_LEASE)){
|
||||||
// /** 优惠券订单 */
|
startTime = order.getPickupTime();
|
||||||
// logger.info("【微信支付回调】优惠券支付");
|
}else{
|
||||||
// // 3-优惠券支付
|
startTime = order.getExpiryTime();
|
||||||
// order1.setStatus(ServiceConstants.ORDER_STATUS_ORDER_END);
|
}
|
||||||
// order1.setMark("优惠券支付");
|
Date expiryTime = DateUtils.getTimeAfterXUnit(startTime, order.getNum(), feeRule.getRentalUnit());
|
||||||
// // 优惠券成功处理逻辑
|
order.setExpiryTime(expiryTime);
|
||||||
// couponSuccessHandle(order);
|
|
||||||
// }else if(attachVo.getType().equals(ServiceConstants.BUSINESS_TYPE_DEPOSIT)){
|
|
||||||
// logger.info("【微信支付回调】押金支付");
|
|
||||||
// // 4-押金支付
|
|
||||||
// order1.setStatus(ServiceConstants.ORDER_STATUS_ORDER_END);
|
|
||||||
// asUser.setBalance(order.getTotalFee());
|
|
||||||
// order1.setMark("押金支付");
|
|
||||||
// // 删除用户缓存
|
|
||||||
// String token = attachVo.getToken();
|
|
||||||
// logger.info("【微信支付回调】删除用户缓存:"+token);
|
|
||||||
// if (StringUtils.isNotNull(token))
|
|
||||||
// {
|
|
||||||
// redisCache.deleteObject(CacheConstants.LOGIN_TOKEN_KEY + token);
|
|
||||||
// }
|
|
||||||
// }else{
|
|
||||||
// logger.error("【微信支付回调】 : 支付场景不存在");
|
|
||||||
// throw new ServiceException("【微信支付回调】支付场景不存在");
|
|
||||||
// }
|
|
||||||
// if(ObjectUtil.isNotNull(asDevice)){
|
|
||||||
// int device = asDeviceService.updateAsDevice(asDevice);
|
|
||||||
// if(device==0){
|
|
||||||
// logger.error("【微信支付回调】更新车辆状态失败");
|
|
||||||
// throw new ServiceException("【微信支付回调】更新车辆状态失败");
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// Boolean execute = transactionTemplate.execute(e -> {
|
|
||||||
// order1.setPaid("1");
|
|
||||||
// order1.setPayTime(DateUtils.getNowDate());
|
|
||||||
// order1.setPayType(payType);
|
|
||||||
// order1.setLocking("0");
|
|
||||||
// // 如果使用了优惠券则扣除一次使用次数
|
|
||||||
// if(ObjectUtil.isNotNull(order.getLogId())){
|
|
||||||
// EtCouponUserLog couponUserLog = etCouponClaimLogMapper.selectEtCouponClaimLogByLogId(order.getLogId());
|
|
||||||
// EtCoupon etCoupon = etCouponMapper.selectEtCouponByCouponId(couponUserLog.getCouponId());
|
|
||||||
// logger.info("【微信支付回调】优惠券信息 : " + JSON.toJSONString(etCoupon));
|
|
||||||
// if(ObjectUtil.isNotNull(etCoupon) && (etCoupon.getType().equals(ServiceConstants.COUPON_TYPE_DISCOUNT_CARD) || etCoupon.getType().equals(ServiceConstants.COUPON_TYPE_VOUCHER)) && couponUserLog.getLimitNum() > 0){
|
|
||||||
// etCouponClaimLogMapper.deductLimitNum(couponUserLog.getLogId());
|
|
||||||
// logger.info("【微信支付回调】优惠券使用次数-1");
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// logger.info("=================【微信支付回调】开始更新订单信息=================={}",JSON.toJSON(order1));
|
|
||||||
// int updateEtOrder = orderService.updateEtOrder(order1);
|
|
||||||
// if(updateEtOrder==0){
|
|
||||||
// logger.error("【微信支付回调】更新订单信息失败");
|
|
||||||
// throw new ServiceException("【微信支付回调】更新订单信息失败");
|
|
||||||
// }
|
|
||||||
// if(attachVo.getType().equals(ServiceConstants.BUSINESS_TYPE_DEPOSIT)){
|
|
||||||
// logger.info("=================【微信支付回调】开始更新用户信息==================");
|
|
||||||
// int updateUser = userService.updateUser(asUser);
|
|
||||||
// if(updateUser==0){
|
|
||||||
// logger.error("【微信支付回调】更新用户押金失败");
|
|
||||||
// throw new ServiceException("【微信支付回调】更新用户押金失败");
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// logger.info("=================【微信支付回调】全部结束!!!!!==================");
|
|
||||||
// return Boolean.TRUE;
|
|
||||||
// });
|
|
||||||
// if(!execute)throw new ServiceException("管理员开锁失败");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private BigDecimal getCost(ChannelVO channel,BigDecimal payFee) {
|
private BigDecimal getCost(ChannelVO channel,BigDecimal payFee) {
|
||||||
|
|
|
@ -312,16 +312,6 @@ public class RlOrderServiceImpl implements IRlOrderService
|
||||||
order.setOutUnit(feeRule.getOutUnit());
|
order.setOutUnit(feeRule.getOutUnit());
|
||||||
order.setOutPrice(feeRule.getOutPrice());
|
order.setOutPrice(feeRule.getOutPrice());
|
||||||
order.setRentalUnit(feeRule.getRentalUnit());
|
order.setRentalUnit(feeRule.getRentalUnit());
|
||||||
/** 如果是租赁订单,根据取车时间计算到期时间
|
|
||||||
* 如果是续费订单,根据到期时间计算续费订单的到期时间 */
|
|
||||||
Date startTime = null;
|
|
||||||
if(order.getType().equals(ServiceConstants.ORDER_TYPE_LEASE)){
|
|
||||||
startTime = order.getPickupTime();
|
|
||||||
}else{
|
|
||||||
startTime = order.getExpiryTime();
|
|
||||||
}
|
|
||||||
Date expiryTime = DateUtils.getTimeAfterXUnit(startTime, order.getNum(), feeRule.getRentalUnit());
|
|
||||||
order.setExpiryTime(expiryTime);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -662,6 +662,17 @@ public class RlUserServiceImpl implements IRlUserService{
|
||||||
insertUserRole(userId, roleIds);
|
insertUserRole(userId, roleIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取用户余额
|
||||||
|
*
|
||||||
|
* @param userId 用户id
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public BigDecimal selectUserBalanceById(Long userId) {
|
||||||
|
return rlUserMapper.selectUserBalanceById(userId);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增用户岗位信息
|
* 新增用户岗位信息
|
||||||
*
|
*
|
||||||
|
|
|
@ -7,11 +7,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<resultMap type="RlOrderVO" id="RlOrderResult" autoMapping="true"/>
|
<resultMap type="RlOrderVO" id="RlOrderResult" autoMapping="true"/>
|
||||||
|
|
||||||
<sql id="selectRlOrderVo">
|
<sql id="selectRlOrderVo">
|
||||||
select order_id, order_no, out_trade_no, user_id, rule_id, device_mac, sn, pay_time, pay_type, paid, type, total_fee, pay_fee, deposit, overdue_fee, dispatch_fee,delivery_fee,
|
select order_id, order_no, out_trade_no, user_id, user_name, phone, rule_id, device_mac, sn, pay_time, pay_type, paid, type, total_fee, pay_fee, deposit, overdue_fee, dispatch_fee,delivery_fee,
|
||||||
lease_fee, mark, duration, status, create_time, return_time, deposit_deduction, deposit_order_no, deduction_amount, used_sn, change_reason,
|
lease_fee, mark, duration, status, create_time, return_time, deposit_deduction, deposit_order_no, deduction_amount, used_sn, change_reason,
|
||||||
auto_refund_deposit, rental_unit, handling_charge, platform_service_fee, operator_dividend, pay_channel, delivery_method, pickup_time,
|
auto_refund_deposit, rental_unit, handling_charge, platform_service_fee, operator_dividend, pay_channel, delivery_method, pickup_time,
|
||||||
agent_id, store_id, merchant_id, pickup_city, pickup_loc, pickup_lon, pickup_lat, model_id, expiry_time, original_order_no, num, price, `explain`,
|
agent_id, store_id, merchant_id, pickup_city, pickup_loc, pickup_lon, pickup_lat, model_id, expiry_time, original_order_no, num, price, `explain`,
|
||||||
instructions, out_unit, out_price,return_type,return_method,address,auto_cancel_time from rl_order
|
instructions, out_unit, out_price,return_type,return_method,address,auto_cancel_time,cost from rl_order
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<sql id="selectRlOrderDetail">
|
<sql id="selectRlOrderDetail">
|
||||||
|
@ -20,6 +20,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
o.order_no,
|
o.order_no,
|
||||||
o.out_trade_no,
|
o.out_trade_no,
|
||||||
o.user_id,
|
o.user_id,
|
||||||
|
o.user_name,
|
||||||
|
o.phone,
|
||||||
o.rule_id,
|
o.rule_id,
|
||||||
o.device_mac,
|
o.device_mac,
|
||||||
o.sn,
|
o.sn,
|
||||||
|
@ -79,6 +81,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
o.address,
|
o.address,
|
||||||
o.auto_cancel_time,
|
o.auto_cancel_time,
|
||||||
o.merchant_id,
|
o.merchant_id,
|
||||||
|
o.cost,
|
||||||
CONCAT(
|
CONCAT(
|
||||||
CASE
|
CASE
|
||||||
WHEN r.rental_unit = 'hours' THEN '时租'
|
WHEN r.rental_unit = 'hours' THEN '时租'
|
||||||
|
@ -115,6 +118,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<if test="orderNo != null and orderNo != ''"> and o.order_no = #{orderNo}</if>
|
<if test="orderNo != null and orderNo != ''"> and o.order_no = #{orderNo}</if>
|
||||||
<if test="outTradeNo != null and outTradeNo != ''"> and o.out_trade_no = #{outTradeNo}</if>
|
<if test="outTradeNo != null and outTradeNo != ''"> and o.out_trade_no = #{outTradeNo}</if>
|
||||||
<if test="userId != null"> and o.user_id = #{userId}</if>
|
<if test="userId != null"> and o.user_id = #{userId}</if>
|
||||||
|
<if test="userName != null and userName != ''"> and u.user_name like concat('%', #{userName}, '%')</if>
|
||||||
|
<if test="phone != null and phone != ''"> and u.phone like concat('%', #{phone}, '%')</if>
|
||||||
<if test="ruleId != null"> and o.rule_id = #{ruleId}</if>
|
<if test="ruleId != null"> and o.rule_id = #{ruleId}</if>
|
||||||
<if test="deviceMac != null and deviceMac != ''"> and o.device_mac = #{deviceMac}</if>
|
<if test="deviceMac != null and deviceMac != ''"> and o.device_mac = #{deviceMac}</if>
|
||||||
<if test="sn != null and sn != ''"> and o.sn = #{sn}</if>
|
<if test="sn != null and sn != ''"> and o.sn = #{sn}</if>
|
||||||
|
@ -167,6 +172,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<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>
|
||||||
<if test="userId != null"> and user_id = #{userId}</if>
|
<if test="userId != null"> and user_id = #{userId}</if>
|
||||||
|
<if test="userName != null and userName != ''"> and u.user_name like concat('%', #{userName}, '%')</if>
|
||||||
|
<if test="phone != null and phone != ''"> and u.phone like concat('%', #{phone}, '%')</if>
|
||||||
<if test="status != null and status != ''"> and status = #{status}</if>
|
<if test="status != null and status != ''"> and status = #{status}</if>
|
||||||
<if test="paid != null and paid != ''"> and paid = #{paid}</if>
|
<if test="paid != null and paid != ''"> and paid = #{paid}</if>
|
||||||
</where>
|
</where>
|
||||||
|
@ -192,6 +199,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<if test="orderNo != null and orderNo != ''">order_no,</if>
|
<if test="orderNo != null and orderNo != ''">order_no,</if>
|
||||||
<if test="outTradeNo != null">out_trade_no,</if>
|
<if test="outTradeNo != null">out_trade_no,</if>
|
||||||
<if test="userId != null">user_id,</if>
|
<if test="userId != null">user_id,</if>
|
||||||
|
<if test="userName != null and userName != ''">user_name,</if>
|
||||||
|
<if test="phone != null and phone != ''">phone,</if>
|
||||||
<if test="ruleId != null">rule_id,</if>
|
<if test="ruleId != null">rule_id,</if>
|
||||||
<if test="deviceMac != null">device_mac,</if>
|
<if test="deviceMac != null">device_mac,</if>
|
||||||
<if test="sn != null">sn,</if>
|
<if test="sn != null">sn,</if>
|
||||||
|
@ -243,11 +252,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<if test="returnMethod != null">return_method,</if>
|
<if test="returnMethod != null">return_method,</if>
|
||||||
<if test="address != null">address,</if>
|
<if test="address != null">address,</if>
|
||||||
<if test="autoCancelTime != null">auto_cancel_time,</if>
|
<if test="autoCancelTime != null">auto_cancel_time,</if>
|
||||||
|
<if test="cost != null">cost,</if>
|
||||||
</trim>
|
</trim>
|
||||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
<if test="orderNo != null and orderNo != ''">#{orderNo},</if>
|
<if test="orderNo != null and orderNo != ''">#{orderNo},</if>
|
||||||
<if test="outTradeNo != null">#{outTradeNo},</if>
|
<if test="outTradeNo != null">#{outTradeNo},</if>
|
||||||
<if test="userId != null">#{userId},</if>
|
<if test="userId != null">#{userId},</if>
|
||||||
|
<if test="userName != null and userName != ''">#{userName},</if>
|
||||||
|
<if test="phone != null and phone != ''">#{phone},</if>
|
||||||
<if test="ruleId != null">#{ruleId},</if>
|
<if test="ruleId != null">#{ruleId},</if>
|
||||||
<if test="deviceMac != null">#{deviceMac},</if>
|
<if test="deviceMac != null">#{deviceMac},</if>
|
||||||
<if test="sn != null">#{sn},</if>
|
<if test="sn != null">#{sn},</if>
|
||||||
|
@ -299,6 +311,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<if test="returnMethod != null">#{returnMethod},</if>
|
<if test="returnMethod != null">#{returnMethod},</if>
|
||||||
<if test="address != null">#{address},</if>
|
<if test="address != null">#{address},</if>
|
||||||
<if test="autoCancelTime != null">#{autoCancelTime},</if>
|
<if test="autoCancelTime != null">#{autoCancelTime},</if>
|
||||||
|
<if test="cost != null">#{cost},</if>
|
||||||
</trim>
|
</trim>
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
|
@ -308,6 +321,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<if test="orderNo != null and orderNo != ''">order_no = #{orderNo},</if>
|
<if test="orderNo != null and orderNo != ''">order_no = #{orderNo},</if>
|
||||||
<if test="outTradeNo != null">out_trade_no = #{outTradeNo},</if>
|
<if test="outTradeNo != null">out_trade_no = #{outTradeNo},</if>
|
||||||
<if test="userId != null">user_id = #{userId},</if>
|
<if test="userId != null">user_id = #{userId},</if>
|
||||||
|
<if test="userName != null and userName != ''">user_name = #{userName},</if>
|
||||||
|
<if test="phone != null and phone != ''">phone = #{phone},</if>
|
||||||
<if test="ruleId != null">rule_id = #{ruleId},</if>
|
<if test="ruleId != null">rule_id = #{ruleId},</if>
|
||||||
<if test="deviceMac != null">device_mac = #{deviceMac},</if>
|
<if test="deviceMac != null">device_mac = #{deviceMac},</if>
|
||||||
<if test="sn != null">sn = #{sn},</if>
|
<if test="sn != null">sn = #{sn},</if>
|
||||||
|
@ -359,6 +374,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<if test="returnMethod != null">return_method = #{returnMethod},</if>
|
<if test="returnMethod != null">return_method = #{returnMethod},</if>
|
||||||
<if test="address != null">address = #{address},</if>
|
<if test="address != null">address = #{address},</if>
|
||||||
<if test="autoCancelTime != null">auto_cancel_time = #{autoCancelTime},</if>
|
<if test="autoCancelTime != null">auto_cancel_time = #{autoCancelTime},</if>
|
||||||
|
|
||||||
</trim>
|
</trim>
|
||||||
where order_id = #{orderId}
|
where order_id = #{orderId}
|
||||||
</update>
|
</update>
|
||||||
|
@ -369,6 +385,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<if test="orderNo != null and orderNo != ''">order_no = #{orderNo},</if>
|
<if test="orderNo != null and orderNo != ''">order_no = #{orderNo},</if>
|
||||||
<if test="outTradeNo != null">out_trade_no = #{outTradeNo},</if>
|
<if test="outTradeNo != null">out_trade_no = #{outTradeNo},</if>
|
||||||
<if test="userId != null">user_id = #{userId},</if>
|
<if test="userId != null">user_id = #{userId},</if>
|
||||||
|
<if test="userName != null and userName != ''">user_name = #{userName},</if>
|
||||||
|
<if test="phone != null and phone != ''">phone = #{phone},</if>
|
||||||
<if test="ruleId != null">rule_id = #{ruleId},</if>
|
<if test="ruleId != null">rule_id = #{ruleId},</if>
|
||||||
<if test="deviceMac != null">device_mac = #{deviceMac},</if>
|
<if test="deviceMac != null">device_mac = #{deviceMac},</if>
|
||||||
<if test="sn != null">sn = #{sn},</if>
|
<if test="sn != null">sn = #{sn},</if>
|
||||||
|
@ -417,6 +435,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<if test="outUnit != null">out_unit = #{outUnit},</if>
|
<if test="outUnit != null">out_unit = #{outUnit},</if>
|
||||||
<if test="outPrice != null">out_price = #{outPrice},</if>
|
<if test="outPrice != null">out_price = #{outPrice},</if>
|
||||||
<if test="returnType != null">return_type = #{returnType},</if>
|
<if test="returnType != null">return_type = #{returnType},</if>
|
||||||
|
<if test="cost != null">cost = #{cost},</if>
|
||||||
</trim>
|
</trim>
|
||||||
where order_no = #{orderNo}
|
where order_no = #{orderNo}
|
||||||
</update>
|
</update>
|
||||||
|
|
|
@ -152,7 +152,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
</if>
|
</if>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<insert id="insertUser" parameterType="RlUser" useGeneratedKeys="true" keyProperty="userId">
|
<select id="selectUserBalanceById" resultType="java.math.BigDecimal">
|
||||||
|
select balance from rl_user_ext
|
||||||
|
where user_id = #{userId}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<insert id="insertUser" parameterType="RlUser" useGeneratedKeys="true" keyProperty="userId">
|
||||||
insert into rl_user(
|
insert into rl_user(
|
||||||
<if test="userId != null and userId != 0">user_id,</if>
|
<if test="userId != null and userId != 0">user_id,</if>
|
||||||
<if test="userName != null and userName != ''">user_name,</if>
|
<if test="userName != null and userName != ''">user_name,</if>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user