Merge remote-tracking branch 'origin/main'
This commit is contained in:
commit
82fd154968
@ -1,55 +0,0 @@
|
|||||||
package com.cdzy.payment.component;
|
|
||||||
|
|
||||||
import cn.dev33.satoken.stp.StpUtil;
|
|
||||||
import com.cdzy.common.model.response.CommonEbikeRole;
|
|
||||||
import com.cdzy.common.model.response.CommonStaffInfo;
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
|
||||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
|
||||||
import com.mybatisflex.core.tenant.TenantFactory;
|
|
||||||
import org.springframework.web.context.request.RequestAttributes;
|
|
||||||
import org.springframework.web.context.request.RequestContextHolder;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.TimeZone;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author: yanglei
|
|
||||||
* @since: 2025-10-15 09:41
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class EbikeTenantFactory implements TenantFactory {
|
|
||||||
|
|
||||||
public Object[] getTenantIds() {
|
|
||||||
if (StpUtil.isLogin()) {
|
|
||||||
RequestAttributes attributes = RequestContextHolder.getRequestAttributes();
|
|
||||||
Object attribute = attributes.getAttribute("tenantId", RequestAttributes.SCOPE_REQUEST);
|
|
||||||
if (attribute != null) {
|
|
||||||
String id = (String) StpUtil.getLoginId();
|
|
||||||
Object object = StpUtil.getSessionByLoginId(id).get(id);
|
|
||||||
ObjectMapper objectMapper = new ObjectMapper()
|
|
||||||
.registerModule(new JavaTimeModule())
|
|
||||||
.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
|
|
||||||
.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai"));
|
|
||||||
CommonStaffInfo staffInfo = objectMapper.convertValue(object, CommonStaffInfo.class);
|
|
||||||
List<CommonEbikeRole> roles = staffInfo.getRoles();
|
|
||||||
boolean isSysAdmin = false;
|
|
||||||
for (CommonEbikeRole role : roles) {
|
|
||||||
if (role.getSysAdmin()) {
|
|
||||||
isSysAdmin = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
long tenantId = Long.parseLong(attribute.toString());
|
|
||||||
//系统管理员
|
|
||||||
if (isSysAdmin) {
|
|
||||||
return null;
|
|
||||||
} else {
|
|
||||||
return new Object[]{tenantId};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,17 +1,13 @@
|
|||||||
package com.cdzy.payment.config;
|
package com.cdzy.payment.config;
|
||||||
|
|
||||||
import com.cdzy.common.enums.EbikeContents;
|
import com.cdzy.common.enums.EbikeContents;
|
||||||
import com.cdzy.payment.component.EbikeTenantFactory;
|
|
||||||
import com.mybatisflex.annotation.KeyType;
|
import com.mybatisflex.annotation.KeyType;
|
||||||
import com.mybatisflex.core.FlexGlobalConfig;
|
import com.mybatisflex.core.FlexGlobalConfig;
|
||||||
import com.mybatisflex.core.audit.AuditManager;
|
import com.mybatisflex.core.audit.AuditManager;
|
||||||
import com.mybatisflex.core.dialect.DbType;
|
import com.mybatisflex.core.dialect.DbType;
|
||||||
import com.mybatisflex.core.keygen.KeyGenerators;
|
import com.mybatisflex.core.keygen.KeyGenerators;
|
||||||
import com.mybatisflex.core.tenant.TenantFactory;
|
|
||||||
import com.mybatisflex.core.tenant.TenantManager;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -54,15 +50,4 @@ public class MyBatisFlexConfiguration {
|
|||||||
//设置数据已被删除时的值
|
//设置数据已被删除时的值
|
||||||
globalConfig.setDeletedValueOfLogicDelete(Boolean.TRUE);
|
globalConfig.setDeletedValueOfLogicDelete(Boolean.TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 详细的租户工厂配置
|
|
||||||
*/
|
|
||||||
@Bean
|
|
||||||
public static TenantFactory tenantFactory() {
|
|
||||||
logger.info("开始初始化租户工厂...");
|
|
||||||
EbikeTenantFactory factory = new EbikeTenantFactory();
|
|
||||||
TenantManager.setTenantFactory(factory);
|
|
||||||
return new EbikeTenantFactory();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@ -0,0 +1,37 @@
|
|||||||
|
package com.cdzy.user.controller;
|
||||||
|
|
||||||
|
import com.cdzy.common.model.response.JsonResult;
|
||||||
|
import com.cdzy.user.model.entity.EbikePayment;
|
||||||
|
import com.cdzy.user.service.EbikePaymentService;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户支付 控制层
|
||||||
|
*
|
||||||
|
* @author yanglei
|
||||||
|
* @since 2025-11-13 13:49
|
||||||
|
*/
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/ebikePayment")
|
||||||
|
public class EbikePaymentController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private EbikePaymentService ebikePaymentService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据订单号获取支付订单
|
||||||
|
*
|
||||||
|
* @param orderId 用户订单号
|
||||||
|
* @return 支付订单信息
|
||||||
|
*/
|
||||||
|
@GetMapping("/queryPaymentInfo")
|
||||||
|
public JsonResult<?> queryPaymentInfo(@RequestParam(name = "orderId") Long orderId) {
|
||||||
|
EbikePayment ebikePayment = ebikePaymentService.queryPaymentInfo(orderId);
|
||||||
|
return JsonResult.success(ebikePayment);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -11,4 +11,12 @@ import com.mybatisflex.core.service.IService;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
public interface EbikePaymentService extends IService<EbikePayment> {
|
public interface EbikePaymentService extends IService<EbikePayment> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询用户支付订单
|
||||||
|
*
|
||||||
|
* @param orderId 订单id
|
||||||
|
* @return 用户支付订单
|
||||||
|
*/
|
||||||
|
EbikePayment queryPaymentInfo(Long orderId);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -95,7 +95,7 @@ public class EbikeOrderImpl extends ServiceImpl<EbikeOrderMapper, EbikeOrder> im
|
|||||||
.updateTime(LocalDateTime.now())
|
.updateTime(LocalDateTime.now())
|
||||||
.build();
|
.build();
|
||||||
updateById(orders);
|
updateById(orders);
|
||||||
return orders;
|
return getById(order.getOrderId());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("开锁失败, userId={}, bikeCode={}", userId, bikeCode, e);
|
log.error("开锁失败, userId={}, bikeCode={}", userId, bikeCode, e);
|
||||||
throw new RuntimeException("开锁失败", e);
|
throw new RuntimeException("开锁失败", e);
|
||||||
|
|||||||
@ -3,10 +3,13 @@ package com.cdzy.user.service.impl;
|
|||||||
import com.cdzy.user.mapper.EbikePaymentMapper;
|
import com.cdzy.user.mapper.EbikePaymentMapper;
|
||||||
import com.cdzy.user.model.entity.EbikePayment;
|
import com.cdzy.user.model.entity.EbikePayment;
|
||||||
import com.cdzy.user.service.EbikePaymentService;
|
import com.cdzy.user.service.EbikePaymentService;
|
||||||
|
import com.mybatisflex.core.query.QueryWrapper;
|
||||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import static com.cdzy.user.model.entity.table.EbikePaymentTableDef.EBIKE_PAYMENT;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户支付服务层
|
* 用户支付服务层
|
||||||
*
|
*
|
||||||
@ -16,4 +19,16 @@ import org.springframework.stereotype.Service;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
public class EbikePaymentServiceImpl extends ServiceImpl<EbikePaymentMapper, EbikePayment> implements EbikePaymentService {
|
public class EbikePaymentServiceImpl extends ServiceImpl<EbikePaymentMapper, EbikePayment> implements EbikePaymentService {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EbikePayment queryPaymentInfo(Long orderId) {
|
||||||
|
QueryWrapper queryWrapper = QueryWrapper.create()
|
||||||
|
.where(EBIKE_PAYMENT.ORDER_ID.eq(orderId));
|
||||||
|
EbikePayment ebikePayment = this.mapper.selectOneByQuery(queryWrapper);
|
||||||
|
if (ebikePayment == null) {
|
||||||
|
log.error("{}支付订单不存在!", orderId);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return ebikePayment;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -298,7 +298,7 @@ CREATE TABLE "public"."ebike_payment" (
|
|||||||
"user_id" int8 NOT NULL,
|
"user_id" int8 NOT NULL,
|
||||||
"order_id" int8 NOT NULL,
|
"order_id" int8 NOT NULL,
|
||||||
"operator_id" int8 NOT NULL,
|
"operator_id" int8 NOT NULL,
|
||||||
"trade_id" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
|
"trade_id" varchar(64) COLLATE "pg_catalog"."default",
|
||||||
"transaction_id" varchar(64) COLLATE "pg_catalog"."default",
|
"transaction_id" varchar(64) COLLATE "pg_catalog"."default",
|
||||||
"payment_time" timestamp(6),
|
"payment_time" timestamp(6),
|
||||||
"payment_method" int2 NOT NULL,
|
"payment_method" int2 NOT NULL,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user