退款,量表套餐
This commit is contained in:
parent
e7974b6455
commit
f18b3023af
|
@ -53,24 +53,6 @@ spring:
|
||||||
url: jdbc:mysql://39.101.193.239:3306/mental_tenant?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true&allowMultiQueries=true
|
url: jdbc:mysql://39.101.193.239:3306/mental_tenant?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true&allowMultiQueries=true
|
||||||
username:
|
username:
|
||||||
password:
|
password:
|
||||||
# oracle:
|
|
||||||
# type: ${spring.datasource.type}
|
|
||||||
# driverClassName: oracle.jdbc.OracleDriver
|
|
||||||
# url: jdbc:oracle:thin:@//localhost:1521/XE
|
|
||||||
# username: ROOT
|
|
||||||
# password: root
|
|
||||||
# postgres:
|
|
||||||
# type: ${spring.datasource.type}
|
|
||||||
# driverClassName: org.postgresql.Driver
|
|
||||||
# url: jdbc:postgresql://localhost:5432/postgres?useUnicode=true&characterEncoding=utf8&useSSL=true&autoReconnect=true&reWriteBatchedInserts=true
|
|
||||||
# username: root
|
|
||||||
# password: root
|
|
||||||
# sqlserver:
|
|
||||||
# type: ${spring.datasource.type}
|
|
||||||
# driverClassName: com.microsoft.sqlserver.jdbc.SQLServerDriver
|
|
||||||
# url: jdbc:sqlserver://localhost:1433;DatabaseName=tempdb;SelectMethod=cursor;encrypt=false;rewriteBatchedStatements=true
|
|
||||||
# username: SA
|
|
||||||
# password: root
|
|
||||||
hikari:
|
hikari:
|
||||||
# 最大连接池数量
|
# 最大连接池数量
|
||||||
maxPoolSize: 20
|
maxPoolSize: 20
|
||||||
|
@ -199,7 +181,7 @@ justauth:
|
||||||
client-id: 449c4*********937************759
|
client-id: 449c4*********937************759
|
||||||
client-secret: ac7***********1e0************28d
|
client-secret: ac7***********1e0************28d
|
||||||
redirect-uri: ${justauth.address}/social-callback?source=topiam
|
redirect-uri: ${justauth.address}/social-callback?source=topiam
|
||||||
scopes: [openid, email, phone, profile]
|
scopes: [ openid, email, phone, profile ]
|
||||||
qq:
|
qq:
|
||||||
client-id: 10**********6
|
client-id: 10**********6
|
||||||
client-secret: 1f7d08**********5b7**********29e
|
client-secret: 1f7d08**********5b7**********29e
|
||||||
|
@ -262,7 +244,7 @@ wx:
|
||||||
appId: wx2e09db4124332242
|
appId: wx2e09db4124332242
|
||||||
mchId: 1646701170
|
mchId: 1646701170
|
||||||
mchKey: Mozhekejiyouxiangongsi6296296296
|
mchKey: Mozhekejiyouxiangongsi6296296296
|
||||||
keyPath: /usr/local/tenant/certs
|
keyPath: /usr/local/tenant/certs/apiclient_cert.p12
|
||||||
miniapp:
|
miniapp:
|
||||||
configs:
|
configs:
|
||||||
- appid: wx2e09db4124332242
|
- appid: wx2e09db4124332242
|
||||||
|
|
|
@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.github.binarywang.wxpay.bean.notify.WxPayRefundNotifyResult;
|
import com.github.binarywang.wxpay.bean.notify.WxPayRefundNotifyResult;
|
||||||
import com.github.binarywang.wxpay.bean.request.WxPayRefundRequest;
|
import com.github.binarywang.wxpay.bean.request.WxPayRefundRequest;
|
||||||
|
import com.github.binarywang.wxpay.bean.result.WxPayRefundResult;
|
||||||
import com.github.binarywang.wxpay.service.WxPayService;
|
import com.github.binarywang.wxpay.service.WxPayService;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
@ -41,7 +42,7 @@ public class ReservationRefundServiceImpl implements IReservationRefundService {
|
||||||
|
|
||||||
private final ReservationRefundMapper baseMapper;
|
private final ReservationRefundMapper baseMapper;
|
||||||
private final ReservationOrderMapper orderMapper;
|
private final ReservationOrderMapper orderMapper;
|
||||||
private final WxPayService wxService;
|
private final WxPayService payService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询预约退款
|
* 查询预约退款
|
||||||
|
@ -99,9 +100,9 @@ public class ReservationRefundServiceImpl implements IReservationRefundService {
|
||||||
@Override
|
@Override
|
||||||
public Boolean insertByBo(ReservationRefundBo bo) {
|
public Boolean insertByBo(ReservationRefundBo bo) {
|
||||||
Long userId = LoginHelper.getUserId();
|
Long userId = LoginHelper.getUserId();
|
||||||
|
bo.setUserId(userId);
|
||||||
ReservationRefund add = MapstructUtils.convert(bo, ReservationRefund.class);
|
ReservationRefund add = MapstructUtils.convert(bo, ReservationRefund.class);
|
||||||
ReservationOrder order = validEntityBeforeSave(add);
|
ReservationOrder order = validEntityBeforeSave(add);
|
||||||
add.setUserId(userId);
|
|
||||||
add.setOrderPrice(order.getOrderPrice());
|
add.setOrderPrice(order.getOrderPrice());
|
||||||
add.setActualPrice(order.getActualPrice());
|
add.setActualPrice(order.getActualPrice());
|
||||||
add.setStatus(0);
|
add.setStatus(0);
|
||||||
|
@ -138,8 +139,30 @@ public class ReservationRefundServiceImpl implements IReservationRefundService {
|
||||||
request.setTotalFee(totalFee);
|
request.setTotalFee(totalFee);
|
||||||
request.setRefundFee(totalFee);
|
request.setRefundFee(totalFee);
|
||||||
request.setNotifyUrl("https://api.ysmental.com/tenant/wx/pay/notify/refund/reservation");
|
request.setNotifyUrl("https://api.ysmental.com/tenant/wx/pay/notify/refund/reservation");
|
||||||
this.wxService.refund(request);
|
WxPayRefundResult refund = payService.refund(request);
|
||||||
return null;
|
String returnCode = refund.getReturnCode();
|
||||||
|
if ("FAIL".equals(returnCode)) {
|
||||||
|
log.error("同意退款:{},通信异常。异常原因:{}", refundId, refund.getReturnMsg());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
String resultCode = refund.getResultCode();
|
||||||
|
if ("FAIL".equals(resultCode)) {
|
||||||
|
String errCode = refund.getErrCode();
|
||||||
|
String errCodeDes = refund.getErrCodeDes();
|
||||||
|
log.error("同意退款:{},支付异常。异常代码:{}。异常原因:{}", refundId, errCode, errCodeDes);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// WxPayRefundV3Request request = new WxPayRefundV3Request();
|
||||||
|
// request.setOutTradeNo(orderId.toString());
|
||||||
|
// request.setOutRefundNo(refundId.toString());
|
||||||
|
// WxPayRefundV3Request.Amount amont = new WxPayRefundV3Request.Amount();
|
||||||
|
// amont.setRefund(totalFee);
|
||||||
|
// amont.setTotal(totalFee);
|
||||||
|
// amont.setCurrency("CNY");
|
||||||
|
// request.setAmount(amont);
|
||||||
|
// request.setNotifyUrl("https://api.ysmental.com/tenant/wx/pay/notify/refund/reservation");
|
||||||
|
// payService.refundV3(request);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -0,0 +1,121 @@
|
||||||
|
package org.dromara.system.controller.system;
|
||||||
|
|
||||||
|
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||||
|
import cn.dev33.satoken.annotation.SaCheckRole;
|
||||||
|
import jakarta.validation.constraints.NotEmpty;
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.dromara.common.core.constant.TenantConstants;
|
||||||
|
import org.dromara.common.core.domain.R;
|
||||||
|
import org.dromara.common.core.validate.AddGroup;
|
||||||
|
import org.dromara.common.core.validate.EditGroup;
|
||||||
|
import org.dromara.common.idempotent.annotation.RepeatSubmit;
|
||||||
|
import org.dromara.common.log.annotation.Log;
|
||||||
|
import org.dromara.common.log.enums.BusinessType;
|
||||||
|
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||||
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||||
|
import org.dromara.common.web.core.BaseController;
|
||||||
|
import org.dromara.system.domain.bo.SysScalePackageBo;
|
||||||
|
import org.dromara.system.domain.vo.SysScalePackageVo;
|
||||||
|
import org.dromara.system.service.ISysScalePackageService;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 量表套餐
|
||||||
|
*
|
||||||
|
* @author cjw
|
||||||
|
* @date 2024-10-23
|
||||||
|
*/
|
||||||
|
@Validated
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/system/scale/package")
|
||||||
|
public class SysScalePackageController extends BaseController {
|
||||||
|
|
||||||
|
private final ISysScalePackageService sysScalePackageService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询量表套餐列表
|
||||||
|
*/
|
||||||
|
@SaCheckRole(TenantConstants.SUPER_ADMIN_ROLE_KEY)
|
||||||
|
@SaCheckPermission("system:scalePackage:list")
|
||||||
|
@GetMapping("/list")
|
||||||
|
public TableDataInfo<SysScalePackageVo> list(SysScalePackageBo bo, PageQuery pageQuery) {
|
||||||
|
return sysScalePackageService.queryPageList(bo, pageQuery);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询租户套餐下拉选列表
|
||||||
|
*/
|
||||||
|
@SaCheckRole(TenantConstants.SUPER_ADMIN_ROLE_KEY)
|
||||||
|
@SaCheckPermission("system:scalePackage:list")
|
||||||
|
@GetMapping("/selectList")
|
||||||
|
public R<List<SysScalePackageVo>> selectList() {
|
||||||
|
return R.ok(sysScalePackageService.selectList());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取量表套餐详细信息
|
||||||
|
*
|
||||||
|
* @param packageId 主键
|
||||||
|
*/
|
||||||
|
@SaCheckRole(TenantConstants.SUPER_ADMIN_ROLE_KEY)
|
||||||
|
@SaCheckPermission("system:scalePackage:query")
|
||||||
|
@GetMapping("/{packageId}")
|
||||||
|
public R<SysScalePackageVo> getInfo(@NotNull(message = "主键不能为空")
|
||||||
|
@PathVariable Long packageId) {
|
||||||
|
return R.ok(sysScalePackageService.queryById(packageId));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增量表套餐
|
||||||
|
*/
|
||||||
|
@SaCheckRole(TenantConstants.SUPER_ADMIN_ROLE_KEY)
|
||||||
|
@SaCheckPermission("system:scalePackage:add")
|
||||||
|
@Log(title = "量表套餐", businessType = BusinessType.INSERT)
|
||||||
|
@RepeatSubmit()
|
||||||
|
@PostMapping()
|
||||||
|
public R<Void> add(@Validated(AddGroup.class) @RequestBody SysScalePackageBo bo) {
|
||||||
|
return toAjax(sysScalePackageService.insertByBo(bo));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改量表套餐
|
||||||
|
*/
|
||||||
|
@SaCheckRole(TenantConstants.SUPER_ADMIN_ROLE_KEY)
|
||||||
|
@SaCheckPermission("system:scalePackage:edit")
|
||||||
|
@Log(title = "量表套餐", businessType = BusinessType.UPDATE)
|
||||||
|
@RepeatSubmit()
|
||||||
|
@PutMapping()
|
||||||
|
public R<Void> edit(@Validated(EditGroup.class) @RequestBody SysScalePackageBo bo) {
|
||||||
|
return toAjax(sysScalePackageService.updateByBo(bo));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 状态修改
|
||||||
|
*/
|
||||||
|
@SaCheckRole(TenantConstants.SUPER_ADMIN_ROLE_KEY)
|
||||||
|
@SaCheckPermission("system:tenantPackage:edit")
|
||||||
|
@Log(title = "租户套餐", businessType = BusinessType.UPDATE)
|
||||||
|
@PutMapping("/changeStatus")
|
||||||
|
public R<Void> changeStatus(@RequestBody SysScalePackageBo bo) {
|
||||||
|
return toAjax(sysScalePackageService.updatePackageStatus(bo));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除量表套餐
|
||||||
|
*
|
||||||
|
* @param packageIds 主键串
|
||||||
|
*/
|
||||||
|
@SaCheckRole(TenantConstants.SUPER_ADMIN_ROLE_KEY)
|
||||||
|
@SaCheckPermission("system:scalePackage:remove")
|
||||||
|
@Log(title = "量表套餐", businessType = BusinessType.DELETE)
|
||||||
|
@DeleteMapping("/{packageIds}")
|
||||||
|
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||||
|
@PathVariable Long[] packageIds) {
|
||||||
|
return toAjax(sysScalePackageService.deleteWithValidByIds(List.of(packageIds), true));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,57 @@
|
||||||
|
package org.dromara.system.domain;
|
||||||
|
|
||||||
|
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
||||||
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 量表套餐对象 sys_scale_package
|
||||||
|
*
|
||||||
|
* @author cjw
|
||||||
|
* @date 2024-10-23
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@TableName("sys_scale_package")
|
||||||
|
public class SysScalePackage extends BaseEntity {
|
||||||
|
|
||||||
|
@Serial
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 量表套餐id
|
||||||
|
*/
|
||||||
|
@TableId(value = "package_id")
|
||||||
|
private Long packageId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 套餐名称
|
||||||
|
*/
|
||||||
|
private String packageName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 关联量表id
|
||||||
|
*/
|
||||||
|
private String scaleIds;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 备注
|
||||||
|
*/
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 状态(0正常 1停用)
|
||||||
|
*/
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除标志(0代表存在 2代表删除)
|
||||||
|
*/
|
||||||
|
@TableLogic
|
||||||
|
private String delFlag;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -77,7 +77,12 @@ public class SysTenant extends BaseEntity {
|
||||||
/**
|
/**
|
||||||
* 租户套餐编号
|
* 租户套餐编号
|
||||||
*/
|
*/
|
||||||
private Long packageId;
|
private Long tenantPackageId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 量表套餐编号
|
||||||
|
*/
|
||||||
|
private Long scalePackageId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 过期时间
|
* 过期时间
|
||||||
|
|
|
@ -0,0 +1,53 @@
|
||||||
|
package org.dromara.system.domain.bo;
|
||||||
|
|
||||||
|
import io.github.linpeilie.annotations.AutoMapping;
|
||||||
|
import org.dromara.system.domain.SysScalePackage;
|
||||||
|
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
||||||
|
import org.dromara.common.core.validate.AddGroup;
|
||||||
|
import org.dromara.common.core.validate.EditGroup;
|
||||||
|
import io.github.linpeilie.annotations.AutoMapper;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import jakarta.validation.constraints.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 量表套餐业务对象 sys_scale_package
|
||||||
|
*
|
||||||
|
* @author cjw
|
||||||
|
* @date 2024-10-23
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@AutoMapper(target = SysScalePackage.class, reverseConvertGenerate = false)
|
||||||
|
public class SysScalePackageBo extends BaseEntity {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 量表套餐id
|
||||||
|
*/
|
||||||
|
@NotNull(message = "量表套餐id不能为空", groups = { EditGroup.class })
|
||||||
|
private Long packageId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 套餐名称
|
||||||
|
*/
|
||||||
|
@NotBlank(message = "套餐名称不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||||
|
private String packageName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 关联量表id
|
||||||
|
*/
|
||||||
|
@AutoMapping(target = "scaleIds", expression = "java(org.dromara.common.core.utils.StringUtils.join(source.getScaleIds(), \",\"))")
|
||||||
|
private Long[] scaleIds;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 备注
|
||||||
|
*/
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 状态(0正常 1停用)
|
||||||
|
*/
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -1,17 +1,17 @@
|
||||||
package org.dromara.system.domain.bo;
|
package org.dromara.system.domain.bo;
|
||||||
|
|
||||||
import org.dromara.common.core.validate.AddGroup;
|
|
||||||
import org.dromara.common.core.validate.EditGroup;
|
|
||||||
import org.dromara.system.domain.SysTenant;
|
|
||||||
import io.github.linpeilie.annotations.AutoMapper;
|
import io.github.linpeilie.annotations.AutoMapper;
|
||||||
|
import jakarta.validation.constraints.NotBlank;
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import jakarta.validation.constraints.*;
|
import org.dromara.common.core.validate.AddGroup;
|
||||||
|
import org.dromara.common.core.validate.EditGroup;
|
||||||
|
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
||||||
|
import org.dromara.system.domain.SysTenant;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 租户业务对象 sys_tenant
|
* 租户业务对象 sys_tenant
|
||||||
*
|
*
|
||||||
|
@ -93,7 +93,13 @@ public class SysTenantBo extends BaseEntity {
|
||||||
* 租户套餐编号
|
* 租户套餐编号
|
||||||
*/
|
*/
|
||||||
@NotNull(message = "租户套餐不能为空", groups = { AddGroup.class })
|
@NotNull(message = "租户套餐不能为空", groups = { AddGroup.class })
|
||||||
private Long packageId;
|
private Long tenantPackageId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 量表套餐编号
|
||||||
|
*/
|
||||||
|
@NotNull(message = "量表套餐不能为空", groups = { AddGroup.class })
|
||||||
|
private Long scalePackageId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 过期时间
|
* 过期时间
|
||||||
|
|
|
@ -0,0 +1,63 @@
|
||||||
|
package org.dromara.system.domain.vo;
|
||||||
|
|
||||||
|
import org.dromara.system.domain.SysScalePackage;
|
||||||
|
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||||
|
import com.alibaba.excel.annotation.ExcelProperty;
|
||||||
|
import org.dromara.common.excel.annotation.ExcelDictFormat;
|
||||||
|
import org.dromara.common.excel.convert.ExcelDictConvert;
|
||||||
|
import io.github.linpeilie.annotations.AutoMapper;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 量表套餐视图对象 sys_scale_package
|
||||||
|
*
|
||||||
|
* @author cjw
|
||||||
|
* @date 2024-10-23
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@ExcelIgnoreUnannotated
|
||||||
|
@AutoMapper(target = SysScalePackage.class)
|
||||||
|
public class SysScalePackageVo implements Serializable {
|
||||||
|
|
||||||
|
@Serial
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 量表套餐id
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "量表套餐id")
|
||||||
|
private Long packageId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 套餐名称
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "套餐名称")
|
||||||
|
private String packageName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 关联量表id
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "关联量表id")
|
||||||
|
private String scaleIds;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 备注
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "备注")
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 状态(0正常 1停用)
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "状态", converter = ExcelDictConvert.class)
|
||||||
|
@ExcelDictFormat(readConverterExp = "0=正常,1=停用")
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -1,16 +1,16 @@
|
||||||
package org.dromara.system.domain.vo;
|
package org.dromara.system.domain.vo;
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||||
import com.alibaba.excel.annotation.ExcelProperty;
|
import com.alibaba.excel.annotation.ExcelProperty;
|
||||||
|
import io.github.linpeilie.annotations.AutoMapper;
|
||||||
|
import lombok.Data;
|
||||||
import org.dromara.common.excel.annotation.ExcelDictFormat;
|
import org.dromara.common.excel.annotation.ExcelDictFormat;
|
||||||
import org.dromara.common.excel.convert.ExcelDictConvert;
|
import org.dromara.common.excel.convert.ExcelDictConvert;
|
||||||
import org.dromara.system.domain.SysTenant;
|
import org.dromara.system.domain.SysTenant;
|
||||||
import io.github.linpeilie.annotations.AutoMapper;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.io.Serial;
|
import java.io.Serial;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -90,7 +90,13 @@ public class SysTenantVo implements Serializable {
|
||||||
* 租户套餐编号
|
* 租户套餐编号
|
||||||
*/
|
*/
|
||||||
@ExcelProperty(value = "租户套餐编号")
|
@ExcelProperty(value = "租户套餐编号")
|
||||||
private Long packageId;
|
private Long tenantPackageId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 量表套餐编号
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "量表套餐编号")
|
||||||
|
private Long scalePackageId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 过期时间
|
* 过期时间
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
package org.dromara.system.mapper;
|
||||||
|
|
||||||
|
import org.dromara.system.domain.SysScalePackage;
|
||||||
|
import org.dromara.system.domain.vo.SysScalePackageVo;
|
||||||
|
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 量表套餐Mapper接口
|
||||||
|
*
|
||||||
|
* @author cjw
|
||||||
|
* @date 2024-10-23
|
||||||
|
*/
|
||||||
|
public interface SysScalePackageMapper extends BaseMapperPlus<SysScalePackage, SysScalePackageVo> {
|
||||||
|
|
||||||
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
package org.dromara.system.mapper;
|
package org.dromara.system.mapper;
|
||||||
|
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
|
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
|
||||||
import org.dromara.system.domain.SysTenantPackage;
|
import org.dromara.system.domain.SysTenantPackage;
|
||||||
import org.dromara.system.domain.vo.SysTenantPackageVo;
|
import org.dromara.system.domain.vo.SysTenantPackageVo;
|
||||||
|
@ -9,6 +10,7 @@ import org.dromara.system.domain.vo.SysTenantPackageVo;
|
||||||
*
|
*
|
||||||
* @author Michelle.Chung
|
* @author Michelle.Chung
|
||||||
*/
|
*/
|
||||||
|
@Mapper
|
||||||
public interface SysTenantPackageMapper extends BaseMapperPlus<SysTenantPackage, SysTenantPackageVo> {
|
public interface SysTenantPackageMapper extends BaseMapperPlus<SysTenantPackage, SysTenantPackageVo> {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,78 @@
|
||||||
|
package org.dromara.system.service;
|
||||||
|
|
||||||
|
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||||
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||||
|
import org.dromara.system.domain.bo.SysScalePackageBo;
|
||||||
|
import org.dromara.system.domain.vo.SysScalePackageVo;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 量表套餐Service接口
|
||||||
|
*
|
||||||
|
* @author cjw
|
||||||
|
* @date 2024-10-23
|
||||||
|
*/
|
||||||
|
public interface ISysScalePackageService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询量表套餐
|
||||||
|
*
|
||||||
|
* @param packageId 主键
|
||||||
|
* @return 量表套餐
|
||||||
|
*/
|
||||||
|
SysScalePackageVo queryById(Long packageId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询量表套餐列表
|
||||||
|
*
|
||||||
|
* @param bo 查询条件
|
||||||
|
* @param pageQuery 分页参数
|
||||||
|
* @return 量表套餐分页列表
|
||||||
|
*/
|
||||||
|
TableDataInfo<SysScalePackageVo> queryPageList(SysScalePackageBo bo, PageQuery pageQuery);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询租户套餐已启用列表
|
||||||
|
*/
|
||||||
|
List<SysScalePackageVo> selectList();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询符合条件的量表套餐列表
|
||||||
|
*
|
||||||
|
* @param bo 查询条件
|
||||||
|
* @return 量表套餐列表
|
||||||
|
*/
|
||||||
|
List<SysScalePackageVo> queryList(SysScalePackageBo bo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增量表套餐
|
||||||
|
*
|
||||||
|
* @param bo 量表套餐
|
||||||
|
* @return 是否新增成功
|
||||||
|
*/
|
||||||
|
Boolean insertByBo(SysScalePackageBo bo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改量表套餐
|
||||||
|
*
|
||||||
|
* @param bo 量表套餐
|
||||||
|
* @return 是否修改成功
|
||||||
|
*/
|
||||||
|
Boolean updateByBo(SysScalePackageBo bo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改套餐状态
|
||||||
|
*/
|
||||||
|
int updatePackageStatus(SysScalePackageBo bo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验并批量删除量表套餐信息
|
||||||
|
*
|
||||||
|
* @param ids 待删除的主键集合
|
||||||
|
* @param isValid 是否进行有效性校验
|
||||||
|
* @return 是否删除成功
|
||||||
|
*/
|
||||||
|
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||||
|
}
|
|
@ -0,0 +1,159 @@
|
||||||
|
package org.dromara.system.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.dromara.common.core.constant.TenantConstants;
|
||||||
|
import org.dromara.common.core.exception.ServiceException;
|
||||||
|
import org.dromara.common.core.utils.MapstructUtils;
|
||||||
|
import org.dromara.common.core.utils.StringUtils;
|
||||||
|
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||||
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||||
|
import org.dromara.system.domain.SysScalePackage;
|
||||||
|
import org.dromara.system.domain.SysTenant;
|
||||||
|
import org.dromara.system.domain.bo.SysScalePackageBo;
|
||||||
|
import org.dromara.system.domain.vo.SysScalePackageVo;
|
||||||
|
import org.dromara.system.mapper.SysScalePackageMapper;
|
||||||
|
import org.dromara.system.mapper.SysTenantMapper;
|
||||||
|
import org.dromara.system.service.ISysScalePackageService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 量表套餐Service业务层处理
|
||||||
|
*
|
||||||
|
* @author cjw
|
||||||
|
* @date 2024-10-23
|
||||||
|
*/
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@Service
|
||||||
|
public class SysScalePackageServiceImpl implements ISysScalePackageService {
|
||||||
|
|
||||||
|
private final SysScalePackageMapper baseMapper;
|
||||||
|
private final SysTenantMapper tenantMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询量表套餐
|
||||||
|
*
|
||||||
|
* @param packageId 主键
|
||||||
|
* @return 量表套餐
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public SysScalePackageVo queryById(Long packageId) {
|
||||||
|
return baseMapper.selectVoById(packageId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询量表套餐列表
|
||||||
|
*
|
||||||
|
* @param bo 查询条件
|
||||||
|
* @param pageQuery 分页参数
|
||||||
|
* @return 量表套餐分页列表
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public TableDataInfo<SysScalePackageVo> queryPageList(SysScalePackageBo bo, PageQuery pageQuery) {
|
||||||
|
LambdaQueryWrapper<SysScalePackage> lqw = buildQueryWrapper(bo);
|
||||||
|
Page<SysScalePackageVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||||||
|
return TableDataInfo.build(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<SysScalePackageVo> selectList() {
|
||||||
|
return baseMapper.selectVoList(new LambdaQueryWrapper<SysScalePackage>()
|
||||||
|
.eq(SysScalePackage::getStatus, TenantConstants.NORMAL));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询符合条件的量表套餐列表
|
||||||
|
*
|
||||||
|
* @param bo 查询条件
|
||||||
|
* @return 量表套餐列表
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<SysScalePackageVo> queryList(SysScalePackageBo bo) {
|
||||||
|
LambdaQueryWrapper<SysScalePackage> lqw = buildQueryWrapper(bo);
|
||||||
|
return baseMapper.selectVoList(lqw);
|
||||||
|
}
|
||||||
|
|
||||||
|
private LambdaQueryWrapper<SysScalePackage> buildQueryWrapper(SysScalePackageBo bo) {
|
||||||
|
Map<String, Object> params = bo.getParams();
|
||||||
|
LambdaQueryWrapper<SysScalePackage> lqw = Wrappers.lambdaQuery();
|
||||||
|
lqw.like(StringUtils.isNotBlank(bo.getPackageName()), SysScalePackage::getPackageName, bo.getPackageName());
|
||||||
|
lqw.eq(StringUtils.isNotBlank(bo.getStatus()), SysScalePackage::getStatus, bo.getStatus());
|
||||||
|
lqw.orderByAsc(SysScalePackage::getPackageId);
|
||||||
|
return lqw;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增量表套餐
|
||||||
|
*
|
||||||
|
* @param bo 量表套餐
|
||||||
|
* @return 是否新增成功
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Boolean insertByBo(SysScalePackageBo bo) {
|
||||||
|
SysScalePackage add = MapstructUtils.convert(bo, SysScalePackage.class);
|
||||||
|
// 保存菜单id
|
||||||
|
List<Long> scaleIds = Arrays.asList(bo.getScaleIds());
|
||||||
|
if (CollUtil.isNotEmpty(scaleIds)) {
|
||||||
|
add.setScaleIds(StringUtils.join(scaleIds, ", "));
|
||||||
|
} else {
|
||||||
|
add.setScaleIds("");
|
||||||
|
}
|
||||||
|
boolean flag = baseMapper.insert(add) > 0;
|
||||||
|
if (flag) {
|
||||||
|
bo.setPackageId(add.getPackageId());
|
||||||
|
}
|
||||||
|
return flag;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改量表套餐
|
||||||
|
*
|
||||||
|
* @param bo 量表套餐
|
||||||
|
* @return 是否修改成功
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Boolean updateByBo(SysScalePackageBo bo) {
|
||||||
|
SysScalePackage update = MapstructUtils.convert(bo, SysScalePackage.class);
|
||||||
|
// 保存菜单id
|
||||||
|
List<Long> scaleIds = Arrays.asList(bo.getScaleIds());
|
||||||
|
if (CollUtil.isNotEmpty(scaleIds)) {
|
||||||
|
update.setScaleIds(StringUtils.join(scaleIds, ", "));
|
||||||
|
} else {
|
||||||
|
update.setScaleIds("");
|
||||||
|
}
|
||||||
|
return baseMapper.updateById(update) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int updatePackageStatus(SysScalePackageBo bo) {
|
||||||
|
SysScalePackage tenantPackage = MapstructUtils.convert(bo, SysScalePackage.class);
|
||||||
|
return baseMapper.updateById(tenantPackage);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验并批量删除量表套餐信息
|
||||||
|
*
|
||||||
|
* @param ids 待删除的主键集合
|
||||||
|
* @param isValid 是否进行有效性校验
|
||||||
|
* @return 是否删除成功
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||||
|
if (isValid) {
|
||||||
|
boolean exists = tenantMapper.exists(new LambdaQueryWrapper<SysTenant>().in(SysTenant::getScalePackageId, ids));
|
||||||
|
if (exists) {
|
||||||
|
throw new ServiceException("租户套餐已被使用");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return baseMapper.deleteByIds(ids) > 0;
|
||||||
|
}
|
||||||
|
}
|
|
@ -135,7 +135,7 @@ public class SysTenantPackageServiceImpl implements ISysTenantPackageService {
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||||
if(isValid){
|
if(isValid){
|
||||||
boolean exists = tenantMapper.exists(new LambdaQueryWrapper<SysTenant>().in(SysTenant::getPackageId, ids));
|
boolean exists = tenantMapper.exists(new LambdaQueryWrapper<SysTenant>().in(SysTenant::getTenantPackageId, ids));
|
||||||
if (exists) {
|
if (exists) {
|
||||||
throw new ServiceException("租户套餐已被使用");
|
throw new ServiceException("租户套餐已被使用");
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,7 +99,8 @@ public class SysTenantServiceImpl implements ISysTenantService {
|
||||||
lqw.eq(StringUtils.isNotBlank(bo.getAddress()), SysTenant::getAddress, bo.getAddress());
|
lqw.eq(StringUtils.isNotBlank(bo.getAddress()), SysTenant::getAddress, bo.getAddress());
|
||||||
lqw.eq(StringUtils.isNotBlank(bo.getIntro()), SysTenant::getIntro, bo.getIntro());
|
lqw.eq(StringUtils.isNotBlank(bo.getIntro()), SysTenant::getIntro, bo.getIntro());
|
||||||
lqw.like(StringUtils.isNotBlank(bo.getDomain()), SysTenant::getDomain, bo.getDomain());
|
lqw.like(StringUtils.isNotBlank(bo.getDomain()), SysTenant::getDomain, bo.getDomain());
|
||||||
lqw.eq(bo.getPackageId() != null, SysTenant::getPackageId, bo.getPackageId());
|
lqw.eq(bo.getTenantPackageId() != null, SysTenant::getTenantPackageId, bo.getTenantPackageId());
|
||||||
|
lqw.eq(bo.getScalePackageId() != null, SysTenant::getScalePackageId, bo.getScalePackageId());
|
||||||
lqw.eq(bo.getExpireTime() != null, SysTenant::getExpireTime, bo.getExpireTime());
|
lqw.eq(bo.getExpireTime() != null, SysTenant::getExpireTime, bo.getExpireTime());
|
||||||
lqw.eq(bo.getAccountCount() != null, SysTenant::getAccountCount, bo.getAccountCount());
|
lqw.eq(bo.getAccountCount() != null, SysTenant::getAccountCount, bo.getAccountCount());
|
||||||
lqw.eq(StringUtils.isNotBlank(bo.getStatus()), SysTenant::getStatus, bo.getStatus());
|
lqw.eq(StringUtils.isNotBlank(bo.getStatus()), SysTenant::getStatus, bo.getStatus());
|
||||||
|
@ -117,7 +118,9 @@ public class SysTenantServiceImpl implements ISysTenantService {
|
||||||
|
|
||||||
// 获取所有租户编号
|
// 获取所有租户编号
|
||||||
List<String> tenantIds = baseMapper.selectObjs(
|
List<String> tenantIds = baseMapper.selectObjs(
|
||||||
new LambdaQueryWrapper<SysTenant>().select(SysTenant::getTenantId), x -> {return Convert.toStr(x);});
|
new LambdaQueryWrapper<SysTenant>().select(SysTenant::getTenantId), x -> {
|
||||||
|
return Convert.toStr(x);
|
||||||
|
});
|
||||||
String tenantId = generateTenantId(tenantIds);
|
String tenantId = generateTenantId(tenantIds);
|
||||||
add.setTenantId(tenantId);
|
add.setTenantId(tenantId);
|
||||||
boolean flag = baseMapper.insert(add) > 0;
|
boolean flag = baseMapper.insert(add) > 0;
|
||||||
|
@ -127,7 +130,7 @@ public class SysTenantServiceImpl implements ISysTenantService {
|
||||||
bo.setId(add.getId());
|
bo.setId(add.getId());
|
||||||
|
|
||||||
// 根据套餐创建角色
|
// 根据套餐创建角色
|
||||||
Long roleId = createTenantRole(tenantId, bo.getPackageId());
|
Long roleId = createTenantRole(tenantId, bo.getTenantPackageId());
|
||||||
|
|
||||||
// 创建部门: 公司名是部门名称
|
// 创建部门: 公司名是部门名称
|
||||||
SysDept dept = new SysDept();
|
SysDept dept = new SysDept();
|
||||||
|
@ -253,7 +256,8 @@ public class SysTenantServiceImpl implements ISysTenantService {
|
||||||
public Boolean updateByBo(SysTenantBo bo) {
|
public Boolean updateByBo(SysTenantBo bo) {
|
||||||
SysTenant tenant = MapstructUtils.convert(bo, SysTenant.class);
|
SysTenant tenant = MapstructUtils.convert(bo, SysTenant.class);
|
||||||
tenant.setTenantId(null);
|
tenant.setTenantId(null);
|
||||||
tenant.setPackageId(null);
|
tenant.setTenantPackageId(null);
|
||||||
|
tenant.setScalePackageId(null);
|
||||||
return baseMapper.updateById(tenant) > 0;
|
return baseMapper.updateById(tenant) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper
|
||||||
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="org.dromara.system.mapper.SysScalePackageMapper">
|
||||||
|
|
||||||
|
</mapper>
|
Loading…
Reference in New Issue