Merge remote-tracking branch 'origin/master' into dev
# Conflicts: # smart-switch-ruoyi/smart-switch-common/src/main/java/com/ruoyi/common/core/domain/entity/SmUser.java # smart-switch-service/src/main/java/com/ruoyi/ss/user/mapper/SmUserMapper.xml
This commit is contained in:
commit
9e154620cd
|
@ -179,6 +179,14 @@ public class SmUser extends BaseEntity
|
|||
@Size(max = 200, message = "限制提现原因长度不能超过200个字符")
|
||||
private String limitWithdrawReason;
|
||||
|
||||
@Excel(name = "是否限制退款")
|
||||
@ApiModelProperty("是否限制退款")
|
||||
private Boolean limitRefund;
|
||||
|
||||
@Excel(name = "限制退款原因")
|
||||
@ApiModelProperty("限制退款原因")
|
||||
private String limitRefundReason;
|
||||
|
||||
@ApiModelProperty("用户类型")
|
||||
private String type;
|
||||
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
package com.ruoyi.common.pay.syb.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 交易结果
|
||||
* @author wjh
|
||||
|
@ -27,6 +28,10 @@ public enum SybTrxStatus {
|
|||
return SUCCESS.getCode().equals(code);
|
||||
}
|
||||
|
||||
public static boolean isSuccess(Map<String, String> result) {
|
||||
return result != null && isSuccess(result.get("trxstatus"));
|
||||
}
|
||||
|
||||
public static SybTrxStatus getByCode(String code) {
|
||||
for (SybTrxStatus value : SybTrxStatus.values()) {
|
||||
if (value.getCode().equals(code)) {
|
||||
|
|
|
@ -1,12 +1,9 @@
|
|||
package com.ruoyi.common.pay.syb.service;
|
||||
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Map;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
|
||||
@RestController
|
||||
|
@ -16,39 +13,44 @@ public class ApiTestV2 extends BaseController {
|
|||
@Autowired
|
||||
private SybPayClient service;
|
||||
|
||||
@GetMapping("/scanPay")
|
||||
public AjaxResult testScanPay() throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
String reqsn = String.valueOf(System.currentTimeMillis());
|
||||
Map<String, String> map = service.scanPay(1, reqsn, "标题", "备注", "134775931316089668", "", "", "", "");
|
||||
return success(map);
|
||||
}
|
||||
|
||||
@GetMapping("/query")
|
||||
public AjaxResult testQuery(@RequestParam String trxid) throws Exception {
|
||||
Map<String, String> map = service.query("", trxid);
|
||||
return success(map);
|
||||
}
|
||||
|
||||
@PostMapping("/refund")
|
||||
public AjaxResult testRefund() throws Exception {
|
||||
String reqsn = String.valueOf(System.currentTimeMillis());
|
||||
Map<String, String> map = service.refund(1, reqsn, "", "20160712167578.2547");
|
||||
return success(map);
|
||||
}
|
||||
|
||||
@PostMapping("/cancel")
|
||||
public AjaxResult testCancel() throws Exception {
|
||||
String reqsn = String.valueOf(System.currentTimeMillis());
|
||||
Map<String, String> map = service.cancel(1, reqsn, "112094120001088316", "");
|
||||
return success(map);
|
||||
}
|
||||
|
||||
@PostMapping("/pay")
|
||||
public AjaxResult testPay() throws Exception {
|
||||
|
||||
String reqsn = String.valueOf(System.currentTimeMillis());
|
||||
Map<String, String> map = service.pay(1L, reqsn, "W06", "标题", "备注", "ol5kD7eeXNGeYE5z7uIhk12K-rBA", "123", "https://test.allinpaygd.com/JWeb/NotifyServlet", "", "", "", "", "", "", "", "", "", "", "", "");
|
||||
return success(map);
|
||||
}
|
||||
// @GetMapping("/scanPay")
|
||||
// public AjaxResult testScanPay() throws Exception {
|
||||
// // TODO Auto-generated method stub
|
||||
// String reqsn = String.valueOf(System.currentTimeMillis());
|
||||
// Map<String, String> map = service.scanPay(1, reqsn, "标题", "备注", "134775931316089668", "", "", "", "");
|
||||
// return success(map);
|
||||
// }
|
||||
//
|
||||
// @GetMapping("/query")
|
||||
// public AjaxResult testQuery(@RequestParam String trxid) throws Exception {
|
||||
// Map<String, String> map = service.query("", trxid);
|
||||
// return success(map);
|
||||
// }
|
||||
//
|
||||
// @PostMapping("/refund")
|
||||
// public AjaxResult testRefund(@RequestParam String sn,@RequestParam Integer amount) throws Exception {
|
||||
// Map<String, String> map = service.refund(amount, null, "", sn);
|
||||
// return success(map);
|
||||
// }
|
||||
//
|
||||
// @PostMapping("/cancel")
|
||||
// public AjaxResult testCancel() throws Exception {
|
||||
// String reqsn = String.valueOf(System.currentTimeMillis());
|
||||
// Map<String, String> map = service.cancel(1, reqsn, "112094120001088316", "");
|
||||
// return success(map);
|
||||
// }
|
||||
//
|
||||
// @PostMapping("/close")
|
||||
// public AjaxResult close(@RequestParam String id, @RequestParam String sn) throws Exception {
|
||||
// Map<String, String> map = service.close(id, sn);
|
||||
// return success(map);
|
||||
// }
|
||||
//
|
||||
// @PostMapping("/pay")
|
||||
// public AjaxResult testPay() throws Exception {
|
||||
//
|
||||
// String reqsn = String.valueOf(System.currentTimeMillis());
|
||||
// Map<String, String> map = service.pay(1L, reqsn, "W06", "标题", "备注", "ol5kD7eeXNGeYE5z7uIhk12K-rBA", "123", "https://test.allinpaygd.com/JWeb/NotifyServlet", "", "", "", "", "", "", "", "", "", "", "", "");
|
||||
// return success(map);
|
||||
// }
|
||||
}
|
||||
|
|
|
@ -730,6 +730,8 @@ public class DeviceServiceImpl implements DeviceService
|
|||
if (CollectionUtils.isEmptyElement(list)) {
|
||||
return;
|
||||
}
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
|
||||
for (DeviceVO device : list) {
|
||||
try {
|
||||
if (StringUtils.isAnyBlank(device.getMac(), device.getModelProductId())) {
|
||||
|
@ -750,6 +752,19 @@ public class DeviceServiceImpl implements DeviceService
|
|||
data.setSurplusEle(deviceInfo.getM());
|
||||
}
|
||||
|
||||
// 判断设备是否正在使用
|
||||
// 时长优先级最高,若当前设备过期时间 > 当前时间,则正在使用
|
||||
boolean hasTime = device.getExpireTime().isAfter(now);
|
||||
// 若当前设备有电量,则正在使用
|
||||
boolean hasEle = device.getSurplusEle().compareTo(BigDecimal.ZERO) > 0;
|
||||
// 若开关开启,则正在使用
|
||||
boolean hasOpen = DevicePowerStatus.ON.getStatus().equals(device.getPowerStatus());
|
||||
if (hasTime || hasEle || hasOpen) {
|
||||
data.setStatus(DeviceStatus.USING.getStatus());
|
||||
} else {
|
||||
data.setStatus(DeviceStatus.NORMAL.getStatus());
|
||||
}
|
||||
|
||||
// 是否在线
|
||||
data.setOnlineStatus(iotService.getOnlineStatus(device.getMac(), device.getModelProductId()).getStatus());
|
||||
|
||||
|
|
|
@ -1,24 +1,20 @@
|
|||
package com.ruoyi.ss.payBill.service.impl;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.ruoyi.common.core.redis.RedisLock;
|
||||
import com.ruoyi.common.core.redis.enums.RedisLockKey;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.pay.syb.enums.SybTrxStatus;
|
||||
import com.ruoyi.common.pay.syb.service.SybPayService;
|
||||
import com.ruoyi.common.pay.wx.service.WxPayService;
|
||||
import com.ruoyi.common.pay.wx.util.WxPayUtil;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.common.utils.ServiceUtil;
|
||||
import com.ruoyi.common.utils.SnowFlakeUtil;
|
||||
import com.ruoyi.common.utils.collection.CollectionUtils;
|
||||
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||
import com.ruoyi.ss.payBill.domain.PayBill;
|
||||
import com.ruoyi.ss.payBill.domain.PayBillQuery;
|
||||
import com.ruoyi.ss.payBill.domain.PayBillVO;
|
||||
import com.ruoyi.ss.payBill.domain.bo.PayBillRefundBO;
|
||||
import com.ruoyi.ss.payBill.domain.bo.RefundSuccessBO;
|
||||
import com.ruoyi.ss.payBill.domain.dto.PayBillRefundDTO;
|
||||
|
@ -28,23 +24,27 @@ import com.ruoyi.ss.payBill.domain.vo.DoPayVO;
|
|||
import com.ruoyi.ss.payBill.domain.vo.PayResultVO;
|
||||
import com.ruoyi.ss.payBill.interfaces.AfterPay;
|
||||
import com.ruoyi.ss.payBill.interfaces.AfterRefund;
|
||||
import com.ruoyi.ss.payBill.mapper.PayBillMapper;
|
||||
import com.ruoyi.ss.payBill.service.PayBillConverter;
|
||||
import com.ruoyi.ss.payBill.service.PayBillService;
|
||||
import com.ruoyi.ss.refund.domain.RefundVO;
|
||||
import com.ruoyi.ss.refund.service.RefundConverter;
|
||||
import com.ruoyi.ss.refund.service.RefundService;
|
||||
import com.ruoyi.ss.transactionBill.domain.enums.TransactionBillPayType;
|
||||
import com.ruoyi.common.pay.wx.service.WxPayService;
|
||||
import com.wechat.pay.java.service.payments.model.Transaction;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.ss.payBill.mapper.PayBillMapper;
|
||||
import com.ruoyi.ss.payBill.domain.PayBill;
|
||||
import com.ruoyi.ss.payBill.domain.PayBillVO;
|
||||
import com.ruoyi.ss.payBill.domain.PayBillQuery;
|
||||
import com.ruoyi.ss.payBill.service.PayBillService;
|
||||
import org.springframework.transaction.support.TransactionTemplate;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* 支付订单Service业务层处理
|
||||
*
|
||||
|
@ -165,11 +165,11 @@ public class PayBillServiceImpl implements PayBillService
|
|||
return null;
|
||||
};
|
||||
try {
|
||||
return transactionTemplate.execute(status -> {
|
||||
// 关闭旧的支付订单
|
||||
boolean close = this.closeByBstId(bill.getBstId(), bill.getBstType());
|
||||
ServiceUtil.assertion(!close, "关闭旧支付订单失败");
|
||||
// 尝试关闭旧的支付订单
|
||||
boolean close = this.closeByBstId(bill.getBstId(), bill.getBstType());
|
||||
ServiceUtil.assertion(!close, "关闭旧支付订单失败");
|
||||
|
||||
return transactionTemplate.execute(status -> {
|
||||
// 插入订单
|
||||
bill.setStatus(PayBillStatus.PAYING.getStatus());
|
||||
int insert = this.insertPayBill(bill);
|
||||
|
@ -218,7 +218,16 @@ public class PayBillServiceImpl implements PayBillService
|
|||
}
|
||||
// 通联微信
|
||||
else if (TransactionBillPayType.TL_WX.getType().equals(bill.getChannelId())) {
|
||||
sybPayService.closeOrderWx(bill.getPayNo());
|
||||
try {
|
||||
sybPayService.closeOrderWx(bill.getPayNo());
|
||||
} catch (Exception e) {
|
||||
Map<String, String> result = sybPayService.queryOrderByOutTradeNo(bill.getPayNo());
|
||||
if (SybTrxStatus.isSuccess(result)) {
|
||||
throw new ServiceException("交易已成功,无法关闭");
|
||||
} else {
|
||||
log.error("关闭通联支付订单出错:{}", e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -473,7 +482,7 @@ public class PayBillServiceImpl implements PayBillService
|
|||
} else if (TransactionBillPayType.TL_WX.getType().equals(bill.getChannelId())) {
|
||||
// 通联微信支付
|
||||
Map<String, String> result = sybPayService.queryOrderByOutTradeNo(bill.getPayNo());
|
||||
if (SybTrxStatus.isSuccess(result.get("trxstatus"))) {
|
||||
if (SybTrxStatus.isSuccess(result)) {
|
||||
return PayResultVO.success(DateUtils.toLocalDate(result.get("fintime"), "yyyyMMddHHmmss"));
|
||||
} else {
|
||||
return PayResultVO.fail("暂未支付成功");
|
||||
|
|
|
@ -47,6 +47,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
su.is_real,
|
||||
su.limit_withdraw,
|
||||
su.limit_withdraw_reason,
|
||||
su.limit_refund,
|
||||
su.limit_refund_reason,
|
||||
su.agent_service_rate,
|
||||
su.arrival_delay,
|
||||
if(su.is_real, su.real_name, su.user_name) as real_or_user_name,
|
||||
|
@ -72,6 +74,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="withdrawServiceType != null and withdrawServiceType != ''"> and withdraw_service_type = #{withdrawServiceType}</if>
|
||||
<if test="serviceType != null and serviceType != ''"> and service_type = #{serviceType}</if>
|
||||
<if test="limitWithdraw != null "> and limit_withdraw = #{limitWithdraw}</if>
|
||||
<if test="limitRefund != null "> and limit_refund = #{limitRefund}</if>
|
||||
<if test="tenantDeviceId != null">
|
||||
and su.user_id in (
|
||||
select sdt.tenant_id
|
||||
|
@ -167,6 +170,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="isReal != null">is_real,</if>
|
||||
<if test="limitWithdraw != null">limit_withdraw,</if>
|
||||
<if test="limitWithdrawReason != null">limit_withdraw_reason,</if>
|
||||
<if test="limitRefund != null">limit_refund,</if>
|
||||
<if test="limitRefundReason != null">limit_refund_reason,</if>
|
||||
<if test="arrivalDelay != null">arrival_delay,</if>
|
||||
<if test="agentServiceRate != null">agent_service_rate,</if>
|
||||
</trim>
|
||||
|
@ -204,6 +209,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="isReal != null">#{isReal},</if>
|
||||
<if test="limitWithdraw != null">#{limitWithdraw},</if>
|
||||
<if test="limitWithdrawReason != null">#{limitWithdrawReason},</if>
|
||||
<if test="limitRefund != null">#{limitRefund},</if>
|
||||
<if test="limitRefundReason != null">#{limitRefundReason},</if>
|
||||
<if test="arrivalDelay != null">arrival_delay,</if>
|
||||
<if test="agentServiceRate != null">#{agentServiceRate},</if>
|
||||
</trim>
|
||||
|
@ -251,6 +258,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="isReal != null">is_real = #{isReal},</if>
|
||||
<if test="limitWithdraw != null">limit_withdraw = #{limitWithdraw},</if>
|
||||
<if test="limitWithdrawReason != null">limit_withdraw_reason = #{limitWithdrawReason},</if>
|
||||
<if test="limitRefund != null">limit_refund = #{limitRefund},</if>
|
||||
<if test="limitRefundReason != null">limit_refund_reason = #{limitRefundReason},</if>
|
||||
<if test="arrivalDelay != null">arrival_delay = #{arrivalDelay},</if>
|
||||
<if test="agentServiceRate != null">agent_service_rate = #{agentServiceRate},</if>
|
||||
</trim>
|
||||
|
|
|
@ -22,6 +22,8 @@ import com.ruoyi.ss.transactionBill.service.TransactionAssembler;
|
|||
import com.ruoyi.ss.transactionBill.service.TransactionBillConverter;
|
||||
import com.ruoyi.ss.transactionBill.service.TransactionBillService;
|
||||
import com.ruoyi.ss.transactionBill.service.TransactionBillValidator;
|
||||
import com.ruoyi.ss.user.domain.SmUserVo;
|
||||
import com.ruoyi.ss.user.service.ISmUserService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
|
@ -64,6 +66,9 @@ public class AppTransactionBillController extends BaseController
|
|||
@Autowired
|
||||
private TransactionBillConverter transactionBillConverter;
|
||||
|
||||
@Autowired
|
||||
private ISmUserService userService;
|
||||
|
||||
/**
|
||||
* 查询充值记录列表
|
||||
*/
|
||||
|
@ -236,9 +241,14 @@ public class AppTransactionBillController extends BaseController
|
|||
if (bill == null) {
|
||||
return error("订单不存在");
|
||||
}
|
||||
if (!Objects.equals(bill.getMchId(), getUserId())) {
|
||||
Long userId = getUserId();
|
||||
if (!Objects.equals(bill.getMchId(), userId )) {
|
||||
return error("您无权操作退款");
|
||||
}
|
||||
SmUserVo user = userService.selectSmUserByUserId(userId);
|
||||
if (user.getLimitRefund() != null && user.getLimitRefund()) {
|
||||
return error("退款失败:" + user.getLimitRefundReason());
|
||||
}
|
||||
LoginUser loginUser = getLoginUser();
|
||||
dto.setUserName(loginUser.getUsername());
|
||||
dto.setUserType(loginUser.getLoginType().getType());
|
||||
|
|
|
@ -26,7 +26,7 @@ wx:
|
|||
# 转账回调地址
|
||||
transferNotifyUrl: https://kg-dev.chuangtewl.com/dev-api/app/pay/notify/wx/transfer
|
||||
# 密钥所在位置
|
||||
privateKeyPath: D:/project/证书/wxpay-kg/apiclient_key.pem
|
||||
privateKeyPath: H:/project/创特/证书/wxpay-kg/apiclient_key.pem
|
||||
# 证书序列号
|
||||
merchantSerialNumber: 6AD69237C0F22A9AE51A64F1927E3A0962AC1FB0
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user