mirror of
https://gitee.com/dromara/dax-pay.git
synced 2025-09-02 18:46:29 +00:00
feat(cashier): 改进收银台功能并新增支付码牌配置
- 将 CashierTypeEnum 重命名为 CashierCodeTypeEnum,用于表示收银码牌类型 - 新增 CashierCodeResult 类用于收银码牌信息和配置的结果 - 添加 CashierCodeConfig 相关的控制器、服务、DAO 和实体类 -移除 ChannelCashierConfig 相关的代码,改为使用 CashierCodeTypeConfig - 更新支付订单状态,新增待支付状态 - 调整 MPJ 依赖版本
This commit is contained in:
10
_doc/Task.md
10
_doc/Task.md
@@ -9,6 +9,16 @@
|
||||
- [ ] 网关配套移动端开发
|
||||
- [ ] 同步回调页
|
||||
- [x] 微信通道添加单独的认证跳转地址, 处理它的特殊情况
|
||||
- [ ] 支付订单新增待支付状态, 此时不需要
|
||||
## 3.0.0.beta3
|
||||
- [ ] 收银台台功能
|
||||
- [ ] 支持通过订单信息生成收银台链接,
|
||||
- 进入是查询订单状态, 判断是否完成
|
||||
- 在PC时候为收银台,
|
||||
- 在H5时候为也是收银台,
|
||||
- 在微信支付宝时为结算页, 可以直接发起支付
|
||||
- [ ] PC收银台, PC收银台可以生成聚合收银码, 也可以通道特殊方式的支付(微信扫码/支付宝PC支付)
|
||||
- [ ] H5收银台只在浏览器中才会出现, 在软件中会直接跳转到结算页
|
||||
|
||||
## bugs
|
||||
- [x] 修复 BigDecimal 类型数据序列化和签名异常问题
|
||||
|
@@ -24,6 +24,11 @@
|
||||
<artifactId>mybatis-plus-spring-boot3-starter</artifactId>
|
||||
<version>${mybatis-plus.version}</version>
|
||||
</dependency>
|
||||
<!-- jdk 11+ 引入可选模块 -->
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-jsqlparser</artifactId>
|
||||
</dependency>
|
||||
<!-- MPJ -->
|
||||
<dependency>
|
||||
<groupId>com.github.yulichang</groupId>
|
||||
@@ -56,5 +61,16 @@
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-bom</artifactId>
|
||||
<version>${mybatis-plus.version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
</project>
|
||||
|
@@ -31,7 +31,7 @@
|
||||
<hutool.version>5.8.31</hutool.version>
|
||||
<bouncycastle.version>1.78.1</bouncycastle.version>
|
||||
<knife4j.version>4.5.0</knife4j.version>
|
||||
<mybatis-plus.version>3.5.8</mybatis-plus.version>
|
||||
<mybatis-plus.version>3.5.9</mybatis-plus.version>
|
||||
<mybatis-plus-join.version>1.4.13</mybatis-plus-join.version>
|
||||
<dynamic-datasource.version>4.3.1</dynamic-datasource.version>
|
||||
<lock4j.version>2.2.7</lock4j.version>
|
||||
|
@@ -4,17 +4,17 @@ import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 收银台类型
|
||||
* 字典: cashier_type
|
||||
* 收银码牌类型
|
||||
* 字典: cashier_code_type
|
||||
* @author xxm
|
||||
* @since 2024/9/28
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum CashierTypeEnum {
|
||||
public enum CashierCodeTypeEnum {
|
||||
|
||||
WECHAT_PAY("wechat_pay", "微信收银台"),
|
||||
ALIPAY("alipay", "支付宝收银台"),
|
||||
WECHAT_PAY("wechat_pay", "微信码牌"),
|
||||
ALIPAY("alipay", "支付宝码牌"),
|
||||
;
|
||||
|
||||
private final String code;
|
@@ -16,6 +16,7 @@ import java.util.Objects;
|
||||
@Getter
|
||||
@RequiredArgsConstructor
|
||||
public enum PayStatusEnum {
|
||||
WAIT("wait","待支付"),
|
||||
PROGRESS("progress","支付中"),
|
||||
SUCCESS("success","成功"),
|
||||
CLOSE("close","支付关闭"),
|
||||
|
@@ -0,0 +1,40 @@
|
||||
package org.dromara.daxpay.core.result.cashier;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.dromara.daxpay.core.enums.ChannelEnum;
|
||||
import org.dromara.daxpay.core.enums.PayMethodEnum;
|
||||
|
||||
/**
|
||||
* 收银码牌信息和配置
|
||||
* @author xxm
|
||||
* @since 2024/11/20
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@Schema(title = "收银码牌信息和配置")
|
||||
public class CashierCodeResult {
|
||||
|
||||
/** 码牌名称 */
|
||||
@Schema(description = "码牌名称")
|
||||
private String name;
|
||||
|
||||
/** 模板编号 */
|
||||
@Schema(description = "模板编号")
|
||||
private String templateCode;
|
||||
|
||||
/**
|
||||
* 支付通道
|
||||
* @see ChannelEnum
|
||||
*/
|
||||
@Schema(description = "支付通道")
|
||||
private String channel;
|
||||
|
||||
/**
|
||||
* 支付方式
|
||||
* @see PayMethodEnum
|
||||
*/
|
||||
@Schema(description = "支付方式")
|
||||
private String payMethod;
|
||||
}
|
@@ -0,0 +1,39 @@
|
||||
package org.dromara.daxpay.service.controller.cashier;
|
||||
|
||||
import cn.bootx.platform.core.annotation.IgnoreAuth;
|
||||
import cn.bootx.platform.core.rest.Res;
|
||||
import cn.bootx.platform.core.rest.result.Result;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.daxpay.core.result.cashier.CashierCodeResult;
|
||||
import org.dromara.daxpay.service.service.config.CashierCodeConfigService;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* 支付码牌配置
|
||||
* @author xxm
|
||||
* @since 2024/11/20
|
||||
*/
|
||||
@Validated
|
||||
@IgnoreAuth
|
||||
@Tag(name = "支付码牌配置")
|
||||
@RestController
|
||||
@RequestMapping("/cashier/code")
|
||||
@RequiredArgsConstructor
|
||||
public class CashierCodeController {
|
||||
private final CashierCodeConfigService cashierCodeConfigService;
|
||||
|
||||
@Operation(summary = "根据code和类型查询码牌信息和配置")
|
||||
@GetMapping("/findByCashierType")
|
||||
public Result<CashierCodeResult> findByCashierType(@NotBlank(message = "码牌code不可为空") String cashierCode,
|
||||
@NotBlank(message = "码牌类型不可为空") String cashierType){
|
||||
return Res.ok(cashierCodeConfigService.findByCashierType(cashierCode, cashierType));
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -0,0 +1,131 @@
|
||||
package org.dromara.daxpay.service.controller.config;
|
||||
|
||||
import cn.bootx.platform.core.annotation.RequestGroup;
|
||||
import cn.bootx.platform.core.annotation.RequestPath;
|
||||
import cn.bootx.platform.core.rest.Res;
|
||||
import cn.bootx.platform.core.rest.result.Result;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.daxpay.service.param.config.CashierCodeConfigParam;
|
||||
import org.dromara.daxpay.service.param.config.CashierCodeTypeConfigParam;
|
||||
import org.dromara.daxpay.service.result.config.CashierCodeConfigResult;
|
||||
import org.dromara.daxpay.service.result.config.CashierCodeTypeConfigResult;
|
||||
import org.dromara.daxpay.service.service.config.CashierCodeConfigService;
|
||||
import org.dromara.daxpay.service.service.config.CashierCodeTypeConfigService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 收银码牌配置
|
||||
* @author xxm
|
||||
* @since 2024/11/20
|
||||
*/
|
||||
@RequestGroup(groupCode = "CashierCodeConfig", groupName = "收银码牌配置", moduleCode = "PayConfig", moduleName = "支付配置")
|
||||
@Tag(name = "收银码牌配置")
|
||||
@RestController
|
||||
@RequestMapping("/cashier/code/config")
|
||||
@RequiredArgsConstructor
|
||||
public class CashierCodeConfigController {
|
||||
private final CashierCodeConfigService codeConfigService;
|
||||
private final CashierCodeTypeConfigService codeTypeConfigService;
|
||||
|
||||
@RequestPath("根据AppId查询码牌列表")
|
||||
@Operation(summary = "根据AppId查询码牌列表")
|
||||
@GetMapping("/findAllByAppId")
|
||||
public Result<List<CashierCodeConfigResult>> findAllByAppId(String appId){
|
||||
return Res.ok(codeConfigService.findAllByAppId(appId));
|
||||
}
|
||||
|
||||
@RequestPath("根据id查询码牌信息")
|
||||
@Operation(summary = "根据id查询码牌信息")
|
||||
@GetMapping("/findById")
|
||||
public Result<CashierCodeConfigResult> findById(Long id){
|
||||
return Res.ok(codeConfigService.findById(id));
|
||||
}
|
||||
|
||||
@RequestPath("码牌配置保存")
|
||||
@Operation(summary = "码牌配置保存")
|
||||
@PostMapping("/save")
|
||||
public Result<Void> save(@RequestBody CashierCodeConfigParam param) {
|
||||
codeConfigService.save(param);
|
||||
return Res.ok();
|
||||
}
|
||||
|
||||
@RequestPath("码牌配置更新")
|
||||
@Operation(summary = "码牌配置更新")
|
||||
@PostMapping("/update")
|
||||
public Result<Void> update(@RequestBody CashierCodeConfigParam param) {
|
||||
codeConfigService.update(param);
|
||||
return Res.ok();
|
||||
}
|
||||
|
||||
@RequestPath("码牌配置删除")
|
||||
@Operation(summary = "码牌配置删除")
|
||||
@PostMapping("/delete")
|
||||
public Result<Void> delete(Long id){
|
||||
codeConfigService.delete(id);
|
||||
return Res.ok();
|
||||
}
|
||||
|
||||
@RequestPath("获取码牌地址")
|
||||
@Operation(summary = "获取码牌地址")
|
||||
@GetMapping("/getCashierCodeUrl")
|
||||
public Result<String> getCashierCodeUrl(Long id){
|
||||
return Res.ok(codeConfigService.getCashierCodeUrl(id));
|
||||
}
|
||||
|
||||
@RequestPath("获取码牌各类型配置列表")
|
||||
@Operation(summary = "获取码牌各类型配置列表")
|
||||
@GetMapping("/type/findAll")
|
||||
public Result<List<CashierCodeTypeConfigResult>> findAllByCashierCodeId(Long cashierCodeId){
|
||||
return Res.ok(codeTypeConfigService.findByAppId(cashierCodeId));
|
||||
}
|
||||
|
||||
@RequestPath("获取码牌类型配置详情")
|
||||
@Operation(summary = "获取码牌各类型配置详情")
|
||||
@GetMapping("/type/findById")
|
||||
public Result<CashierCodeTypeConfigResult> findTypeById(Long id){
|
||||
return Res.ok(codeTypeConfigService.findById(id));
|
||||
}
|
||||
|
||||
@RequestPath("码牌类型配置保存")
|
||||
@Operation(summary = "码牌类型配置保存")
|
||||
@PostMapping("/type/save")
|
||||
public Result<Void> saveType(@RequestBody CashierCodeTypeConfigParam param){
|
||||
codeTypeConfigService.save(param);
|
||||
return Res.ok();
|
||||
}
|
||||
|
||||
@RequestPath("码牌类型配置更新")
|
||||
@Operation(summary = "码牌类型配置更新")
|
||||
@PostMapping("/type/update")
|
||||
public Result<Void> updateType(@RequestBody CashierCodeTypeConfigParam param){
|
||||
codeTypeConfigService.update(param);
|
||||
return Res.ok();
|
||||
}
|
||||
|
||||
@RequestPath("码牌类型配置删除")
|
||||
@Operation(summary = "码牌类型配置删除")
|
||||
@PostMapping("/type/delete")
|
||||
public Result<Void> deleteType(Long id){
|
||||
codeTypeConfigService.delete(id);
|
||||
return Res.ok();
|
||||
}
|
||||
|
||||
@RequestPath("码牌类型是否存在")
|
||||
@Operation(summary = "码牌类型是否存在")
|
||||
@GetMapping("/type/exists")
|
||||
public Result<Boolean> existsByType(String type, Long cashierCodeId){
|
||||
return Res.ok(codeTypeConfigService.existsByType(type, cashierCodeId));
|
||||
}
|
||||
|
||||
@RequestPath("码牌类型是否存在(不包括自身)")
|
||||
@Operation(summary = "码牌类型是否存在(不包括自身)")
|
||||
@GetMapping("/type/existsNotId")
|
||||
public Result<Boolean> existsByTypeNotId(String type, Long cashierCodeId, Long id){
|
||||
return Res.ok(codeTypeConfigService.existsByType(type, cashierCodeId, id));
|
||||
}
|
||||
|
||||
}
|
@@ -1,88 +0,0 @@
|
||||
package org.dromara.daxpay.service.controller.config;
|
||||
|
||||
import cn.bootx.platform.core.annotation.RequestGroup;
|
||||
import cn.bootx.platform.core.annotation.RequestPath;
|
||||
import cn.bootx.platform.core.rest.Res;
|
||||
import cn.bootx.platform.core.rest.result.Result;
|
||||
import org.dromara.daxpay.service.param.config.ChannelCashierConfigParam;
|
||||
import org.dromara.daxpay.service.result.config.ChannelCashierConfigResult;
|
||||
import org.dromara.daxpay.service.service.config.ChannelCashierConfigService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author xxm
|
||||
* @since 2024/9/28
|
||||
*/
|
||||
@Tag(name = "通道支付收银台配置")
|
||||
@RestController
|
||||
@RequestGroup(groupCode = "ChannelCashierConfig", groupName = "通道支付收银台配置", moduleCode = "PayConfig", moduleName = "支付配置")
|
||||
@RequestMapping("/channel/cashier/config")
|
||||
@RequiredArgsConstructor
|
||||
public class ChannelCashierConfigController {
|
||||
private final ChannelCashierConfigService channelCashierConfigService;
|
||||
|
||||
@RequestPath("配置列表")
|
||||
@Operation(summary = "配置列表")
|
||||
@GetMapping("/findByAppId")
|
||||
public Result<List<ChannelCashierConfigResult>> findByAppId(String appId) {
|
||||
return Res.ok(channelCashierConfigService.findByAppId(appId));
|
||||
}
|
||||
|
||||
@RequestPath("配置详情")
|
||||
@Operation(summary = "配置详情")
|
||||
@GetMapping("/findById")
|
||||
public Result<ChannelCashierConfigResult> findById(Long id) {
|
||||
return Res.ok(channelCashierConfigService.findById(id));
|
||||
}
|
||||
|
||||
@RequestPath("配置保存")
|
||||
@Operation(summary = "配置保存")
|
||||
@PostMapping("/save")
|
||||
public Result<Void> save(@RequestBody ChannelCashierConfigParam param) {
|
||||
channelCashierConfigService.save(param);
|
||||
return Res.ok();
|
||||
}
|
||||
|
||||
@RequestPath("配置更新")
|
||||
@Operation(summary = "配置更新")
|
||||
@PostMapping("/update")
|
||||
public Result<Void> update(@RequestBody ChannelCashierConfigParam param) {
|
||||
channelCashierConfigService.update(param);
|
||||
return Res.ok();
|
||||
}
|
||||
|
||||
@RequestPath("配置是否存在")
|
||||
@Operation(summary = "配置是否存在")
|
||||
@GetMapping("/existsByType")
|
||||
public Result<Boolean> existsByType(String type, String appId) {
|
||||
return Res.ok(channelCashierConfigService.existsByType(type, appId));
|
||||
}
|
||||
|
||||
@RequestPath("配置是否存在(不包括自身)")
|
||||
@Operation(summary = "配置是否存在(不包括自身)")
|
||||
@GetMapping("/existsByTypeNotId")
|
||||
public Result<Boolean> existsByTypeNotId(String type, String appId, Long id) {
|
||||
return Res.ok(channelCashierConfigService.existsByType(type, appId, id));
|
||||
}
|
||||
|
||||
@RequestPath("配置删除")
|
||||
@Operation(summary = "配置删除")
|
||||
@PostMapping("/delete")
|
||||
public Result<Void> delete(Long id) {
|
||||
channelCashierConfigService.delete(id);
|
||||
return Res.ok();
|
||||
}
|
||||
|
||||
@RequestPath("获取码牌地址")
|
||||
@Operation(summary = "获取码牌地址")
|
||||
@GetMapping("/qrCodeUrl")
|
||||
public Result<String> qrCodeUrl(String appId) {
|
||||
return Res.ok(channelCashierConfigService.qrCodeUrl(appId));
|
||||
}
|
||||
}
|
@@ -1,22 +1,11 @@
|
||||
package org.dromara.daxpay.service.controller.unipay;
|
||||
|
||||
import cn.bootx.platform.core.annotation.IgnoreAuth;
|
||||
import cn.bootx.platform.core.rest.Res;
|
||||
import cn.bootx.platform.core.rest.result.Result;
|
||||
import cn.bootx.platform.core.util.ValidationUtil;
|
||||
import org.dromara.daxpay.core.param.cashier.CashierAuthCodeParam;
|
||||
import org.dromara.daxpay.core.param.cashier.CashierAuthUrlParam;
|
||||
import org.dromara.daxpay.core.param.cashier.CashierPayParam;
|
||||
import org.dromara.daxpay.core.result.assist.AuthResult;
|
||||
import org.dromara.daxpay.core.result.trade.pay.PayResult;
|
||||
import org.dromara.daxpay.service.result.config.ChannelCashierConfigResult;
|
||||
import org.dromara.daxpay.service.service.assist.PaymentAssistService;
|
||||
import org.dromara.daxpay.service.service.cashier.ChannelCashierService;
|
||||
import org.dromara.daxpay.service.service.config.ChannelCashierConfigService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.dromara.daxpay.service.service.assist.PaymentAssistService;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* 通道收银台服务
|
||||
@@ -26,45 +15,41 @@ import org.springframework.web.bind.annotation.*;
|
||||
@IgnoreAuth
|
||||
@Tag(name = "通道收银台服务")
|
||||
@RestController
|
||||
@RequestMapping("/unipay/ext/channel/cashier")
|
||||
@RequestMapping("/unipay/cashier/code")
|
||||
@RequiredArgsConstructor
|
||||
public class ChannelCashierController {
|
||||
|
||||
private final ChannelCashierService channelCashierService;
|
||||
|
||||
private final PaymentAssistService paymentAssistService;
|
||||
|
||||
private final ChannelCashierConfigService cashierConfigService;
|
||||
|
||||
@Operation(summary = "获取收银台信息")
|
||||
@GetMapping("/getCashierInfo")
|
||||
public Result<ChannelCashierConfigResult> getCashierInfo(String cashierType,String appId){
|
||||
paymentAssistService.initMchApp(appId);
|
||||
return Res.ok(cashierConfigService.findByCashierType(cashierType));
|
||||
}
|
||||
|
||||
|
||||
@Operation(summary = "获取收银台所需授权链接, 用于获取OpenId一类的信息")
|
||||
@PostMapping("/generateAuthUrl")
|
||||
public Result<String> generateAuthUrl(@RequestBody CashierAuthUrlParam param){
|
||||
ValidationUtil.validateParam(param);
|
||||
paymentAssistService.initMchApp(param.getAppId());
|
||||
return Res.ok(channelCashierService.generateAuthUrl(param));
|
||||
}
|
||||
|
||||
@Operation(summary = "授权获取结果")
|
||||
@PostMapping("/auth")
|
||||
public Result<AuthResult> auth(@RequestBody CashierAuthCodeParam param){
|
||||
ValidationUtil.validateParam(param);
|
||||
paymentAssistService.initMchApp(param.getAppId());
|
||||
return Res.ok(channelCashierService.auth(param));
|
||||
}
|
||||
|
||||
@Operation(summary = "发起支付")
|
||||
@PostMapping("/pay")
|
||||
public Result<PayResult> cashierPay(@RequestBody CashierPayParam param){
|
||||
ValidationUtil.validateParam(param);
|
||||
paymentAssistService.initMchApp(param.getAppId());
|
||||
return Res.ok(channelCashierService.cashierPay(param));
|
||||
}
|
||||
// @Operation(summary = "获取收银台信息")
|
||||
// @GetMapping("/getCashierInfo")
|
||||
// public Result<ChannelCashierConfigResult> getCashierInfo(String cashierType,String appId){
|
||||
// paymentAssistService.initMchApp(appId);
|
||||
// return Res.ok(cashierConfigService.findByCashierType(cashierType));
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @Operation(summary = "获取收银台所需授权链接, 用于获取OpenId一类的信息")
|
||||
// @PostMapping("/generateAuthUrl")
|
||||
// public Result<String> generateAuthUrl(@RequestBody CashierAuthUrlParam param){
|
||||
// ValidationUtil.validateParam(param);
|
||||
// paymentAssistService.initMchApp(param.getAppId());
|
||||
// return Res.ok(channelCashierService.generateAuthUrl(param));
|
||||
// }
|
||||
//
|
||||
// @Operation(summary = "授权获取结果")
|
||||
// @PostMapping("/auth")
|
||||
// public Result<AuthResult> auth(@RequestBody CashierAuthCodeParam param){
|
||||
// ValidationUtil.validateParam(param);
|
||||
// paymentAssistService.initMchApp(param.getAppId());
|
||||
// return Res.ok(channelCashierService.auth(param));
|
||||
// }
|
||||
//
|
||||
// @Operation(summary = "发起支付")
|
||||
// @PostMapping("/pay")
|
||||
// public Result<PayResult> cashierPay(@RequestBody CashierPayParam param){
|
||||
// ValidationUtil.validateParam(param);
|
||||
// paymentAssistService.initMchApp(param.getAppId());
|
||||
// return Res.ok(channelCashierService.cashierPay(param));
|
||||
// }
|
||||
}
|
||||
|
@@ -0,0 +1,22 @@
|
||||
package org.dromara.daxpay.service.convert.config;
|
||||
|
||||
import org.dromara.daxpay.service.entity.config.CashierCodeConfig;
|
||||
import org.dromara.daxpay.service.param.config.CashierCodeConfigParam;
|
||||
import org.dromara.daxpay.service.result.config.CashierCodeConfigResult;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
* 收银台码牌配置
|
||||
* @author xxm
|
||||
* @since 2024/11/20
|
||||
*/
|
||||
@Mapper
|
||||
public interface CashierCodeConfigConvert {
|
||||
CashierCodeConfigConvert CONVERT = Mappers.getMapper(CashierCodeConfigConvert.class);
|
||||
|
||||
CashierCodeConfig toEntity(CashierCodeConfigParam in);
|
||||
|
||||
CashierCodeConfigResult toResult(CashierCodeConfig in);
|
||||
|
||||
}
|
@@ -0,0 +1,21 @@
|
||||
package org.dromara.daxpay.service.convert.config;
|
||||
|
||||
import org.dromara.daxpay.service.entity.config.CashierCodeTypeConfig;
|
||||
import org.dromara.daxpay.service.param.config.CashierCodeTypeConfigParam;
|
||||
import org.dromara.daxpay.service.result.config.CashierCodeTypeConfigResult;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
* 收银台码牌配置
|
||||
* @author xxm
|
||||
* @since 2024/11/20
|
||||
*/
|
||||
@Mapper
|
||||
public interface CashierCodeTypeConfigConvert {
|
||||
CashierCodeTypeConfigConvert CONVERT = Mappers.getMapper(CashierCodeTypeConfigConvert.class);
|
||||
|
||||
CashierCodeTypeConfigResult toResult(CashierCodeTypeConfig in);
|
||||
|
||||
CashierCodeTypeConfig toEntity(CashierCodeTypeConfigParam in);
|
||||
}
|
@@ -1,21 +0,0 @@
|
||||
package org.dromara.daxpay.service.convert.config;
|
||||
|
||||
import org.dromara.daxpay.service.entity.config.ChannelCashierConfig;
|
||||
import org.dromara.daxpay.service.param.config.ChannelCashierConfigParam;
|
||||
import org.dromara.daxpay.service.result.config.ChannelCashierConfigResult;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
* 通道收银台配置
|
||||
* @author xxm
|
||||
* @since 2024/9/28
|
||||
*/
|
||||
@Mapper
|
||||
public interface ChannelCashierConfigConvert {
|
||||
ChannelCashierConfigConvert CONVERT = Mappers.getMapper(ChannelCashierConfigConvert.class);
|
||||
|
||||
ChannelCashierConfig toEntity(ChannelCashierConfigParam param);
|
||||
|
||||
ChannelCashierConfigResult toResult(ChannelCashierConfig channelCashierConfig);
|
||||
}
|
@@ -0,0 +1,38 @@
|
||||
package org.dromara.daxpay.service.dao.config;
|
||||
|
||||
import cn.bootx.platform.common.mybatisplus.impl.BaseManager;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.daxpay.service.entity.config.CashierCodeConfig;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author xxm
|
||||
* @since 2024/11/20
|
||||
*/
|
||||
@Slf4j
|
||||
@Repository
|
||||
@RequiredArgsConstructor
|
||||
public class CashierCodeConfigManager extends BaseManager<CashierCodeConfigMapper, CashierCodeConfig> {
|
||||
|
||||
/**
|
||||
* 根据AppId查询列表
|
||||
*/
|
||||
public List<CashierCodeConfig> findAllByAppId(String appId) {
|
||||
return this.lambdaQuery()
|
||||
.eq(CashierCodeConfig::getAppId, appId)
|
||||
.list();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据Code查询码牌信息
|
||||
*/
|
||||
public Optional<CashierCodeConfig> findByCode(String code) {
|
||||
return findByField(CashierCodeConfig::getCode, code);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,14 @@
|
||||
package org.dromara.daxpay.service.dao.config;
|
||||
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.dromara.daxpay.service.entity.config.CashierCodeConfig;
|
||||
|
||||
/**
|
||||
* 收银台码牌配置
|
||||
* @author xxm
|
||||
* @since 2024/11/20
|
||||
*/
|
||||
@Mapper
|
||||
public interface CashierCodeConfigMapper extends MPJBaseMapper<CashierCodeConfig> {
|
||||
}
|
@@ -0,0 +1,73 @@
|
||||
package org.dromara.daxpay.service.dao.config;
|
||||
|
||||
import cn.bootx.platform.common.mybatisplus.impl.BaseManager;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.daxpay.service.common.context.MchAppLocal;
|
||||
import org.dromara.daxpay.service.common.local.PaymentContextLocal;
|
||||
import org.dromara.daxpay.service.entity.config.CashierCodeTypeConfig;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author xxm
|
||||
* @since 2024/11/20
|
||||
*/
|
||||
@Slf4j
|
||||
@Repository
|
||||
@RequiredArgsConstructor
|
||||
public class CashierCodeTypeConfigManager extends BaseManager<CashierCodeTypeConfigMapper, CashierCodeTypeConfig> {
|
||||
|
||||
/**
|
||||
* 根据码牌ID查询列表
|
||||
*/
|
||||
public List<CashierCodeTypeConfig> findAllByCashierCode(Long cashierCodeId) {
|
||||
return this.lambdaQuery()
|
||||
.eq(CashierCodeTypeConfig::getCashierCodeId, cashierCodeId)
|
||||
.list();
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断类型是否存在
|
||||
*/
|
||||
public boolean existsByType(String type, Long cashierCodeId) {
|
||||
return this.lambdaQuery()
|
||||
.eq(CashierCodeTypeConfig::getType, type)
|
||||
.eq(CashierCodeTypeConfig::getCashierCodeId,cashierCodeId)
|
||||
.exists();
|
||||
}
|
||||
/**
|
||||
* 判断类型是否存在
|
||||
*/
|
||||
public boolean existsByType(String type, Long cashierCodeId, Long id) {
|
||||
return this.lambdaQuery()
|
||||
.eq(CashierCodeTypeConfig::getType, type)
|
||||
.eq(CashierCodeTypeConfig::getCashierCodeId,cashierCodeId)
|
||||
.ne(CashierCodeTypeConfig::getId,id)
|
||||
.exists();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据类型查询
|
||||
*/
|
||||
public Optional<CashierCodeTypeConfig> findByCashierType(Long cashierCodeId, String cashierType) {
|
||||
MchAppLocal mchAppInfo = PaymentContextLocal.get().getMchAppInfo();
|
||||
return lambdaQuery()
|
||||
.eq(CashierCodeTypeConfig::getCashierCodeId, cashierCodeId)
|
||||
.eq(CashierCodeTypeConfig::getType, cashierType)
|
||||
.eq(CashierCodeTypeConfig::getAppId, mchAppInfo.getAppId())
|
||||
.oneOpt();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据码牌ID删除对应的类型配置
|
||||
*/
|
||||
public void deleteByCashierCode(Long cashierCodeId) {
|
||||
this.lambdaUpdate()
|
||||
.eq(CashierCodeTypeConfig::getCashierCodeId, cashierCodeId)
|
||||
.remove();
|
||||
}
|
||||
}
|
@@ -0,0 +1,14 @@
|
||||
package org.dromara.daxpay.service.dao.config;
|
||||
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.dromara.daxpay.service.entity.config.CashierCodeTypeConfig;
|
||||
|
||||
/**
|
||||
* 渠道码类型配置表 Mapper 接口
|
||||
* @author xxm
|
||||
* @since 2024/11/20
|
||||
*/
|
||||
@Mapper
|
||||
public interface CashierCodeTypeConfigMapper extends MPJBaseMapper<CashierCodeTypeConfig> {
|
||||
}
|
@@ -1,63 +0,0 @@
|
||||
package org.dromara.daxpay.service.dao.config;
|
||||
|
||||
import cn.bootx.platform.common.mybatisplus.impl.BaseManager;
|
||||
import org.dromara.daxpay.service.common.context.MchAppLocal;
|
||||
import org.dromara.daxpay.service.common.entity.MchAppBaseEntity;
|
||||
import org.dromara.daxpay.service.common.local.PaymentContextLocal;
|
||||
import org.dromara.daxpay.service.entity.config.ChannelCashierConfig;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* 通道收银台配置
|
||||
* @author xxm
|
||||
* @since 2024/9/28
|
||||
*/
|
||||
@Slf4j
|
||||
@Repository
|
||||
@RequiredArgsConstructor
|
||||
public class ChannelCashierConfigManage extends BaseManager<ChannelCashierConfigMapper, ChannelCashierConfig> {
|
||||
|
||||
/**
|
||||
* 根据AppId查询列表
|
||||
*/
|
||||
public List<ChannelCashierConfig> findAllByAppId(String appId) {
|
||||
return this.lambdaQuery()
|
||||
.eq(ChannelCashierConfig::getAppId, appId)
|
||||
.list();
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断类型是否存在
|
||||
*/
|
||||
public boolean existsByType(String type, String appId) {
|
||||
return this.lambdaQuery()
|
||||
.eq(ChannelCashierConfig::getCashierType, type)
|
||||
.eq(MchAppBaseEntity::getAppId,appId)
|
||||
.exists();
|
||||
}
|
||||
/**
|
||||
* 判断类型是否存在
|
||||
*/
|
||||
public boolean existsByType(String type, String appId, Long id) {
|
||||
return this.lambdaQuery()
|
||||
.eq(ChannelCashierConfig::getCashierType, type)
|
||||
.eq(MchAppBaseEntity::getAppId,appId)
|
||||
.ne(ChannelCashierConfig::getId,id)
|
||||
.exists();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据类型查询
|
||||
*/
|
||||
public Optional<ChannelCashierConfig> findByCashierType(String cashierType) {
|
||||
MchAppLocal mchAppInfo = PaymentContextLocal.get().getMchAppInfo();
|
||||
return lambdaQuery().eq(ChannelCashierConfig::getCashierType, cashierType)
|
||||
.eq(ChannelCashierConfig::getAppId, mchAppInfo.getAppId())
|
||||
.oneOpt();
|
||||
}
|
||||
}
|
@@ -1,14 +0,0 @@
|
||||
package org.dromara.daxpay.service.dao.config;
|
||||
|
||||
import org.dromara.daxpay.service.entity.config.ChannelCashierConfig;
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 通道收银台配置
|
||||
* @author xxm
|
||||
* @since 2024/9/28
|
||||
*/
|
||||
@Mapper
|
||||
public interface ChannelCashierConfigMapper extends MPJBaseMapper<ChannelCashierConfig> {
|
||||
}
|
@@ -0,0 +1,53 @@
|
||||
package org.dromara.daxpay.service.entity.config;
|
||||
|
||||
import cn.bootx.platform.common.mybatisplus.function.ToResult;
|
||||
import com.baomidou.mybatisplus.annotation.FieldStrategy;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.dromara.daxpay.service.common.entity.MchAppBaseEntity;
|
||||
import org.dromara.daxpay.service.convert.config.CashierCodeConfigConvert;
|
||||
import org.dromara.daxpay.service.param.config.CashierCodeConfigParam;
|
||||
import org.dromara.daxpay.service.result.config.CashierCodeConfigResult;
|
||||
|
||||
/**
|
||||
* 收银码牌配置
|
||||
* @author xxm
|
||||
* @since 2024/11/20
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@TableName("pay_cashier_code_config")
|
||||
public class CashierCodeConfig extends MchAppBaseEntity implements ToResult<CashierCodeConfigResult> {
|
||||
|
||||
/** 码牌名称 */
|
||||
private String name;
|
||||
|
||||
/** 码牌code */
|
||||
@TableField(updateStrategy = FieldStrategy.NEVER)
|
||||
private String code;
|
||||
|
||||
/** 模板编号 */
|
||||
private String templateCode;
|
||||
|
||||
/** 是否启用 */
|
||||
private boolean enable;
|
||||
|
||||
/** 备注 */
|
||||
private String remark;
|
||||
|
||||
public static CashierCodeConfig init(CashierCodeConfigParam param) {
|
||||
return CashierCodeConfigConvert.CONVERT.toEntity(param);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换
|
||||
*/
|
||||
@Override
|
||||
public CashierCodeConfigResult toResult() {
|
||||
return CashierCodeConfigConvert.CONVERT.toResult(this);
|
||||
}
|
||||
}
|
@@ -0,0 +1,65 @@
|
||||
package org.dromara.daxpay.service.entity.config;
|
||||
|
||||
import cn.bootx.platform.common.mybatisplus.function.ToResult;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.dromara.daxpay.core.enums.CashierCodeTypeEnum;
|
||||
import org.dromara.daxpay.core.enums.ChannelEnum;
|
||||
import org.dromara.daxpay.core.enums.PayMethodEnum;
|
||||
import org.dromara.daxpay.service.common.entity.MchAppBaseEntity;
|
||||
import org.dromara.daxpay.service.convert.config.CashierCodeTypeConfigConvert;
|
||||
import org.dromara.daxpay.service.param.config.CashierCodeTypeConfigParam;
|
||||
import org.dromara.daxpay.service.result.config.CashierCodeTypeConfigResult;
|
||||
|
||||
/**
|
||||
* 特定类型码牌配置
|
||||
* @author xxm
|
||||
* @since 2024/11/20
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@TableName("pay_cashier_code_type_config")
|
||||
public class CashierCodeTypeConfig extends MchAppBaseEntity implements ToResult<CashierCodeTypeConfigResult> {
|
||||
|
||||
/** 码牌ID */
|
||||
private Long cashierCodeId;
|
||||
|
||||
/**
|
||||
* 收银台类型
|
||||
* @see CashierCodeTypeEnum
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 支付通道
|
||||
* @see ChannelEnum
|
||||
*/
|
||||
private String channel;
|
||||
|
||||
/**
|
||||
* 支付方式
|
||||
* @see PayMethodEnum
|
||||
*/
|
||||
private String payMethod;
|
||||
|
||||
/** 是否开启分账 */
|
||||
private boolean allocation;
|
||||
|
||||
/** 自动分账 */
|
||||
private boolean autoAllocation;
|
||||
|
||||
public static CashierCodeTypeConfig init(CashierCodeTypeConfigParam param) {
|
||||
return CashierCodeTypeConfigConvert.CONVERT.toEntity(param);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换
|
||||
*/
|
||||
@Override
|
||||
public CashierCodeTypeConfigResult toResult() {
|
||||
return CashierCodeTypeConfigConvert.CONVERT.toResult(this);
|
||||
}
|
||||
}
|
@@ -1,67 +0,0 @@
|
||||
package org.dromara.daxpay.service.entity.config;
|
||||
|
||||
import cn.bootx.platform.common.mybatisplus.function.ToResult;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.dromara.daxpay.core.enums.CashierTypeEnum;
|
||||
import org.dromara.daxpay.core.enums.ChannelEnum;
|
||||
import org.dromara.daxpay.core.enums.PayMethodEnum;
|
||||
import org.dromara.daxpay.service.common.entity.MchAppBaseEntity;
|
||||
import org.dromara.daxpay.service.convert.config.ChannelCashierConfigConvert;
|
||||
import org.dromara.daxpay.service.param.config.ChannelCashierConfigParam;
|
||||
import org.dromara.daxpay.service.result.config.ChannelCashierConfigResult;
|
||||
|
||||
/**
|
||||
* 通道收银台配置
|
||||
* @author xxm
|
||||
* @since 2024/9/28
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@TableName("pay_channel_cashier_config")
|
||||
public class ChannelCashierConfig extends MchAppBaseEntity implements ToResult<ChannelCashierConfigResult> {
|
||||
|
||||
/**
|
||||
* 收银台类型
|
||||
* @see CashierTypeEnum
|
||||
*/
|
||||
private String cashierType;
|
||||
|
||||
/**
|
||||
* 收银台名称
|
||||
*/
|
||||
private String cashierName;
|
||||
|
||||
/**
|
||||
* 支付通道
|
||||
* @see ChannelEnum
|
||||
*/
|
||||
private String channel;
|
||||
|
||||
/**
|
||||
* 支付方式
|
||||
* @see PayMethodEnum
|
||||
*/
|
||||
private String payMethod;
|
||||
|
||||
/** 是否开启分账 */
|
||||
private Boolean allocation;
|
||||
|
||||
/** 自动分账 */
|
||||
private Boolean autoAllocation;
|
||||
|
||||
/** 备注 */
|
||||
private String remark;
|
||||
|
||||
public static ChannelCashierConfig init(ChannelCashierConfigParam param){
|
||||
return ChannelCashierConfigConvert.CONVERT.toEntity(param);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelCashierConfigResult toResult() {
|
||||
return ChannelCashierConfigConvert.CONVERT.toResult(this);
|
||||
}
|
||||
}
|
@@ -29,6 +29,9 @@ public class ChannelConst extends MpIdEntity implements ToResult<ChannelConstRes
|
||||
/** 是否启用 */
|
||||
private boolean enable;
|
||||
|
||||
/** 是否支持分账 */
|
||||
private boolean allocatable;
|
||||
|
||||
/** 备注 */
|
||||
private String remark;
|
||||
|
||||
|
@@ -0,0 +1,33 @@
|
||||
package org.dromara.daxpay.service.param.config;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 收款码牌配置
|
||||
* @author xxm
|
||||
* @since 2024/11/20
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@Schema(title = "收款码牌配置")
|
||||
public class CashierCodeConfigParam {
|
||||
|
||||
@Schema(description = "主健")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "模板编号")
|
||||
private String templateCode;
|
||||
@Schema(description = "码牌名称")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "备注")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "是否启用")
|
||||
private boolean enable;
|
||||
|
||||
@Schema(description = "应用ID")
|
||||
private String appId;
|
||||
}
|
@@ -0,0 +1,61 @@
|
||||
package org.dromara.daxpay.service.param.config;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.dromara.daxpay.core.enums.CashierCodeTypeEnum;
|
||||
import org.dromara.daxpay.core.enums.ChannelEnum;
|
||||
import org.dromara.daxpay.core.enums.PayMethodEnum;
|
||||
|
||||
/**
|
||||
* 特定类型码牌配置
|
||||
* @author xxm
|
||||
* @since 2024/11/20
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@Schema(title = "特定类型码牌配置")
|
||||
public class CashierCodeTypeConfigParam {
|
||||
|
||||
/** 主键 */
|
||||
@Schema(description = "主健")
|
||||
private Long id;
|
||||
|
||||
/** 码牌ID */
|
||||
@Schema(description = "主键ID")
|
||||
private Long cashierCodeId;
|
||||
|
||||
/**
|
||||
* 码牌类型
|
||||
* @see CashierCodeTypeEnum
|
||||
*/
|
||||
@Schema(description = "收银台类型")
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 支付通道
|
||||
* @see ChannelEnum
|
||||
*/
|
||||
@Schema(description = "支付通道")
|
||||
private String channel;
|
||||
|
||||
/**
|
||||
* 支付方式
|
||||
* @see PayMethodEnum
|
||||
*/
|
||||
@Schema(description = "支付方式")
|
||||
private String payMethod;
|
||||
|
||||
|
||||
/** 是否开启分账 */
|
||||
@Schema(description = "是否开启分账")
|
||||
private boolean allocation;
|
||||
|
||||
/** 自动分账 */
|
||||
@Schema(description = "自动分账")
|
||||
private boolean autoAllocation;
|
||||
|
||||
/** 备注 */
|
||||
@Schema(description = "备注")
|
||||
private String remark;
|
||||
}
|
@@ -1,76 +0,0 @@
|
||||
package org.dromara.daxpay.service.param.config;
|
||||
|
||||
import org.dromara.daxpay.core.enums.CashierTypeEnum;
|
||||
import org.dromara.daxpay.core.enums.ChannelEnum;
|
||||
import org.dromara.daxpay.core.enums.PayMethodEnum;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 通道收银台配置
|
||||
* @author xxm
|
||||
* @since 2024/9/28
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@Schema(title = "通道收银台配置")
|
||||
public class ChannelCashierConfigParam {
|
||||
|
||||
/** 主健 */
|
||||
@Schema(description = "主健")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 收银台类型
|
||||
* @see CashierTypeEnum
|
||||
*/
|
||||
@NotBlank(message = "收银台类型不可为空")
|
||||
@Schema(description = "收银台类型")
|
||||
private String cashierType;
|
||||
|
||||
/**
|
||||
* 收银台名称
|
||||
*/
|
||||
@NotBlank(message = "收银台名称不可为空")
|
||||
@Schema(description = "收银台名称")
|
||||
private String cashierName;
|
||||
|
||||
/**
|
||||
* 支付通道
|
||||
* @see ChannelEnum
|
||||
*/
|
||||
@NotBlank(message = "支付通道不可为空")
|
||||
@Schema(description = "支付通道")
|
||||
private String channel;
|
||||
|
||||
/**
|
||||
* 支付方式
|
||||
* @see PayMethodEnum
|
||||
*/
|
||||
@NotBlank(message = "支付方式不可为空")
|
||||
@Schema(description = "支付方式")
|
||||
private String payMethod;
|
||||
|
||||
|
||||
/** 是否开启分账 */
|
||||
@NotNull(message = "是否开启分账不可为空")
|
||||
@Schema(description = "是否开启分账")
|
||||
private Boolean allocation;
|
||||
|
||||
/** 自动分账 */
|
||||
@NotNull(message = "自动分账不可为空")
|
||||
@Schema(description = "自动分账")
|
||||
private Boolean autoAllocation;
|
||||
|
||||
/** 备注 */
|
||||
@Schema(description = "备注")
|
||||
private String remark;
|
||||
|
||||
/** 商户AppId */
|
||||
@Schema(description = "商户AppId")
|
||||
@NotBlank(message = "商户AppId不可为空")
|
||||
private String appId;
|
||||
}
|
@@ -0,0 +1,39 @@
|
||||
package org.dromara.daxpay.service.result.config;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.dromara.daxpay.core.result.MchAppResult;
|
||||
|
||||
/**
|
||||
* 收银台码牌配置
|
||||
* @author xxm
|
||||
* @since 2024/11/20
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@Schema(title = "收银台码牌配置")
|
||||
public class CashierCodeConfigResult extends MchAppResult {
|
||||
|
||||
/** 模板编号 */
|
||||
@Schema(description = "模板编号")
|
||||
private String templateCode;
|
||||
|
||||
/** 码牌名称 */
|
||||
@Schema(description = "码牌名称")
|
||||
private String name;
|
||||
|
||||
/** 码牌code */
|
||||
@Schema(description = "码牌code")
|
||||
private String code;
|
||||
|
||||
/** 是否启用 */
|
||||
@Schema(description = "是否启用")
|
||||
private boolean enable;
|
||||
|
||||
/** 备注 */
|
||||
@Schema(description = "备注")
|
||||
private String remark;
|
||||
}
|
@@ -1,37 +1,35 @@
|
||||
package org.dromara.daxpay.service.result.config;
|
||||
|
||||
import org.dromara.daxpay.core.enums.CashierTypeEnum;
|
||||
import org.dromara.daxpay.core.enums.ChannelEnum;
|
||||
import org.dromara.daxpay.core.enums.PayMethodEnum;
|
||||
import org.dromara.daxpay.core.result.MchAppResult;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.dromara.daxpay.core.enums.CashierCodeTypeEnum;
|
||||
import org.dromara.daxpay.core.enums.ChannelEnum;
|
||||
import org.dromara.daxpay.core.enums.PayMethodEnum;
|
||||
import org.dromara.daxpay.core.result.MchAppResult;
|
||||
|
||||
/**
|
||||
* 通道收银台配置
|
||||
* 特定类型码牌配置
|
||||
* @author xxm
|
||||
* @since 2024/9/28
|
||||
* @since 2024/11/20
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@Schema(title = "通道收银台配置")
|
||||
public class ChannelCashierConfigResult extends MchAppResult {
|
||||
@Schema(title = "特定类型码牌配置")
|
||||
public class CashierCodeTypeConfigResult extends MchAppResult {
|
||||
|
||||
/** 码牌ID */
|
||||
@Schema(description = "主键ID")
|
||||
private Long cashierCodeId;
|
||||
|
||||
/**
|
||||
* 收银台类型
|
||||
* @see CashierTypeEnum
|
||||
* 码牌类型
|
||||
* @see CashierCodeTypeEnum
|
||||
*/
|
||||
@Schema(description = "收银台类型")
|
||||
private String cashierType;
|
||||
|
||||
/**
|
||||
* 收银台名称
|
||||
*/
|
||||
@Schema(description = "收银台名称")
|
||||
private String cashierName;
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 支付通道
|
||||
@@ -50,11 +48,11 @@ public class ChannelCashierConfigResult extends MchAppResult {
|
||||
|
||||
/** 是否开启分账 */
|
||||
@Schema(description = "是否开启分账")
|
||||
private Boolean allocation;
|
||||
private boolean allocation;
|
||||
|
||||
/** 自动分账 */
|
||||
@Schema(description = "自动分账")
|
||||
private Boolean autoAllocation;
|
||||
private boolean autoAllocation;
|
||||
|
||||
/** 备注 */
|
||||
@Schema(description = "备注")
|
@@ -25,6 +25,10 @@ public class ChannelConstResult {
|
||||
@Schema(description = "是否启用")
|
||||
private boolean enable;
|
||||
|
||||
/** 是否支持分账 */
|
||||
@Schema(description = "是否支持分账")
|
||||
private boolean allocatable;
|
||||
|
||||
/** 备注 */
|
||||
@Schema(description = "备注")
|
||||
private String remark;
|
||||
|
@@ -0,0 +1,76 @@
|
||||
package org.dromara.daxpay.service.service.cashier;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 通知支付控制台服务
|
||||
* @author xxm
|
||||
* @since 2024/9/28
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class CashierCodeService {
|
||||
|
||||
//
|
||||
// private final PaymentAssistService paymentAssistService;
|
||||
//
|
||||
// private final PayService payService;
|
||||
//
|
||||
// /**
|
||||
// * 生成授权链接跳转链接, 主要是微信类通道使用, 用于获取OpenId
|
||||
// */
|
||||
// public String generateAuthUrl(CashierAuthUrlParam param){
|
||||
// // 查询配置
|
||||
// var cashierConfig = lCashierConfigService.findByCashierType(param.getCashierType());
|
||||
// // 获取策略
|
||||
// AbsChannelCashierStrategy cashierStrategy = PaymentStrategyFactory.create(cashierConfig.getChannel(), AbsChannelCashierStrategy.class);
|
||||
// return cashierStrategy.generateAuthUrl(param);
|
||||
// }
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * 授权结果
|
||||
// */
|
||||
// public AuthResult auth(CashierAuthCodeParam param) {
|
||||
// // 查询配置
|
||||
// var cashierConfig = lCashierConfigService.findByCashierType(param.getCashierType());
|
||||
// // 获取策略
|
||||
// AbsChannelCashierStrategy cashierStrategy = PaymentStrategyFactory.create(cashierConfig.getChannel(), AbsChannelCashierStrategy.class);
|
||||
// return cashierStrategy.doAuth(param);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 支付处理
|
||||
// */
|
||||
// public PayResult cashierPay(CashierPayParam param){
|
||||
// String clientIP = JakartaServletUtil.getClientIP(WebServletUtil.getRequest());
|
||||
// // 查询配置
|
||||
// var cashierConfig = lCashierConfigService.findByCashierType(param.getCashierType());
|
||||
// // 构建支付参数
|
||||
// PayParam payParam = new PayParam();
|
||||
// payParam.setBizOrderNo(TradeNoGenerateUtil.pay());
|
||||
// payParam.setTitle(StrUtil.format("手机收银金额: {}元", param.getAmount()));
|
||||
// payParam.setDescription(param.getDescription());
|
||||
// payParam.setChannel(cashierConfig.getChannel());
|
||||
// payParam.setMethod(cashierConfig.getPayMethod());
|
||||
// payParam.setAmount(param.getAmount());
|
||||
// payParam.setAppId(param.getAppId());
|
||||
// payParam.setClientIp(clientIP);
|
||||
// payParam.setReqTime(LocalDateTime.now());
|
||||
// String sign = paymentAssistService.genSign(payParam);
|
||||
// payParam.setSign(sign);
|
||||
//
|
||||
// // 获取策略
|
||||
// AbsChannelCashierStrategy cashierStrategy = PaymentStrategyFactory.create(cashierConfig.getChannel(), AbsChannelCashierStrategy.class);
|
||||
// // 进行参数预处理
|
||||
// cashierStrategy.handlePayParam(param, payParam);
|
||||
// // 参数校验
|
||||
// ValidationUtil.validateParam(payParam);
|
||||
// // 发起支付
|
||||
// return payService.pay(payParam);
|
||||
// }
|
||||
|
||||
}
|
@@ -1,95 +0,0 @@
|
||||
package org.dromara.daxpay.service.service.cashier;
|
||||
|
||||
import cn.bootx.platform.common.spring.util.WebServletUtil;
|
||||
import cn.bootx.platform.core.util.ValidationUtil;
|
||||
import org.dromara.daxpay.core.param.cashier.CashierAuthCodeParam;
|
||||
import org.dromara.daxpay.core.param.cashier.CashierAuthUrlParam;
|
||||
import org.dromara.daxpay.core.param.cashier.CashierPayParam;
|
||||
import org.dromara.daxpay.core.param.trade.pay.PayParam;
|
||||
import org.dromara.daxpay.core.result.assist.AuthResult;
|
||||
import org.dromara.daxpay.core.result.trade.pay.PayResult;
|
||||
import org.dromara.daxpay.core.util.TradeNoGenerateUtil;
|
||||
import org.dromara.daxpay.service.service.assist.PaymentAssistService;
|
||||
import org.dromara.daxpay.service.service.config.ChannelCashierConfigService;
|
||||
import org.dromara.daxpay.service.service.trade.pay.PayService;
|
||||
import org.dromara.daxpay.service.strategy.AbsChannelCashierStrategy;
|
||||
import org.dromara.daxpay.service.util.PaymentStrategyFactory;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.servlet.JakartaServletUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 通知支付控制台服务
|
||||
* @author xxm
|
||||
* @since 2024/9/28
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class ChannelCashierService {
|
||||
|
||||
private final ChannelCashierConfigService channelCashierConfigService;
|
||||
|
||||
private final PaymentAssistService paymentAssistService;
|
||||
|
||||
private final PayService payService;
|
||||
|
||||
/**
|
||||
* 生成授权链接跳转链接, 主要是微信类通道使用, 用于获取OpenId
|
||||
*/
|
||||
public String generateAuthUrl(CashierAuthUrlParam param){
|
||||
// 查询配置
|
||||
var cashierConfig = channelCashierConfigService.findByCashierType(param.getCashierType());
|
||||
// 获取策略
|
||||
AbsChannelCashierStrategy cashierStrategy = PaymentStrategyFactory.create(cashierConfig.getChannel(), AbsChannelCashierStrategy.class);
|
||||
return cashierStrategy.generateAuthUrl(param);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 授权结果
|
||||
*/
|
||||
public AuthResult auth(CashierAuthCodeParam param) {
|
||||
// 查询配置
|
||||
var cashierConfig = channelCashierConfigService.findByCashierType(param.getCashierType());
|
||||
// 获取策略
|
||||
AbsChannelCashierStrategy cashierStrategy = PaymentStrategyFactory.create(cashierConfig.getChannel(), AbsChannelCashierStrategy.class);
|
||||
return cashierStrategy.doAuth(param);
|
||||
}
|
||||
|
||||
/**
|
||||
* 支付处理
|
||||
*/
|
||||
public PayResult cashierPay(CashierPayParam param){
|
||||
String clientIP = JakartaServletUtil.getClientIP(WebServletUtil.getRequest());
|
||||
// 查询配置
|
||||
var cashierConfig = channelCashierConfigService.findByCashierType(param.getCashierType());
|
||||
// 构建支付参数
|
||||
PayParam payParam = new PayParam();
|
||||
payParam.setBizOrderNo(TradeNoGenerateUtil.pay());
|
||||
payParam.setTitle(StrUtil.format("手机收银金额: {}元", param.getAmount()));
|
||||
payParam.setDescription(param.getDescription());
|
||||
payParam.setChannel(cashierConfig.getChannel());
|
||||
payParam.setMethod(cashierConfig.getPayMethod());
|
||||
payParam.setAmount(param.getAmount());
|
||||
payParam.setAppId(param.getAppId());
|
||||
payParam.setClientIp(clientIP);
|
||||
payParam.setReqTime(LocalDateTime.now());
|
||||
String sign = paymentAssistService.genSign(payParam);
|
||||
payParam.setSign(sign);
|
||||
|
||||
// 获取策略
|
||||
AbsChannelCashierStrategy cashierStrategy = PaymentStrategyFactory.create(cashierConfig.getChannel(), AbsChannelCashierStrategy.class);
|
||||
// 进行参数预处理
|
||||
cashierStrategy.handlePayParam(param, payParam);
|
||||
// 参数校验
|
||||
ValidationUtil.validateParam(payParam);
|
||||
// 发起支付
|
||||
return payService.pay(payParam);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,119 @@
|
||||
package org.dromara.daxpay.service.service.config;
|
||||
|
||||
import cn.bootx.platform.common.mybatisplus.util.MpUtil;
|
||||
import cn.bootx.platform.core.exception.DataNotExistException;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.bean.copier.CopyOptions;
|
||||
import cn.hutool.core.lang.UUID;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.daxpay.core.exception.ConfigNotEnableException;
|
||||
import org.dromara.daxpay.core.result.cashier.CashierCodeResult;
|
||||
import org.dromara.daxpay.service.dao.config.CashierCodeConfigManager;
|
||||
import org.dromara.daxpay.service.dao.config.CashierCodeTypeConfigManager;
|
||||
import org.dromara.daxpay.service.entity.config.CashierCodeConfig;
|
||||
import org.dromara.daxpay.service.entity.config.CashierCodeTypeConfig;
|
||||
import org.dromara.daxpay.service.entity.config.PlatformConfig;
|
||||
import org.dromara.daxpay.service.param.config.CashierCodeConfigParam;
|
||||
import org.dromara.daxpay.service.result.config.CashierCodeConfigResult;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 收银码牌配置
|
||||
* @author xxm
|
||||
* @since 2024/11/20
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class CashierCodeConfigService {
|
||||
|
||||
private final CashierCodeConfigManager cashierCodeConfigManager;
|
||||
|
||||
private final CashierCodeTypeConfigManager cashierCodeTypeConfigManager;
|
||||
|
||||
private final PlatformConfigService platformConfigService;
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*/
|
||||
public void save(CashierCodeConfigParam param) {
|
||||
String uuid = UUID.fastUUID().toString(true);
|
||||
CashierCodeConfig config = CashierCodeConfig.init(param);
|
||||
config.setCode(uuid);
|
||||
cashierCodeConfigManager.save(config);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*/
|
||||
public void update(CashierCodeConfigParam param) {
|
||||
CashierCodeConfig channelCashierConfig = cashierCodeConfigManager.findById(param.getId())
|
||||
.orElseThrow(() -> new DataNotExistException("收银码牌配置不存在"));
|
||||
BeanUtil.copyProperties(param, channelCashierConfig, CopyOptions.create().ignoreNullValue());
|
||||
cashierCodeConfigManager.updateById(channelCashierConfig);
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
public List<CashierCodeConfigResult> findAllByAppId(String appId) {
|
||||
return MpUtil.toListResult(cashierCodeConfigManager.findAllByAppId(appId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询详情
|
||||
*/
|
||||
public CashierCodeConfigResult findById(Long id) {
|
||||
return cashierCodeConfigManager.findById(id).map(CashierCodeConfig::toResult).orElseThrow(() -> new DataNotExistException("收银码牌配置不存在"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void delete(Long id) {
|
||||
if (cashierCodeConfigManager.existedById(id)){
|
||||
throw new DataNotExistException("收银码牌配置不存在");
|
||||
}
|
||||
// 删除类型配置
|
||||
cashierCodeTypeConfigManager.deleteByCashierCode(id);
|
||||
cashierCodeConfigManager.deleteById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取码牌地址
|
||||
*/
|
||||
public String getCashierCodeUrl(Long id) {
|
||||
var codeConfig= cashierCodeConfigManager.findById(id)
|
||||
.orElseThrow(() -> new DataNotExistException("收银码牌配置不存在"));
|
||||
PlatformConfig platformConfig = platformConfigService.getConfig();
|
||||
String serverUrl = platformConfig.getGatewayMobileUrl();
|
||||
return StrUtil.format("{}/cashier/code/{}", serverUrl, codeConfig.getCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据码牌code和类型查询信息和配置
|
||||
*/
|
||||
public CashierCodeResult findByCashierType(String cashierCode, String cashierType) {
|
||||
CashierCodeConfig codeConfig = cashierCodeConfigManager.findByCode(cashierCode)
|
||||
.orElseThrow(() -> new DataNotExistException("支付码牌不存在"));
|
||||
// 是否启用
|
||||
if (!codeConfig.isEnable()) {
|
||||
throw new ConfigNotEnableException("支付码牌已禁用");
|
||||
}
|
||||
|
||||
CashierCodeTypeConfig codeTypeConfig = cashierCodeTypeConfigManager.findByCashierType(codeConfig.getId(), cashierType)
|
||||
.orElseThrow(() -> new DataNotExistException("收银码牌配置不存在"));
|
||||
return new CashierCodeResult()
|
||||
.setChannel(codeTypeConfig.getChannel())
|
||||
.setPayMethod(codeTypeConfig.getPayMethod())
|
||||
.setName(codeConfig.getName())
|
||||
.setTemplateCode(codeConfig.getTemplateCode());
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,100 @@
|
||||
package org.dromara.daxpay.service.service.config;
|
||||
|
||||
import cn.bootx.platform.common.mybatisplus.util.MpUtil;
|
||||
import cn.bootx.platform.core.exception.DataNotExistException;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.bean.copier.CopyOptions;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.daxpay.service.dao.config.CashierCodeConfigManager;
|
||||
import org.dromara.daxpay.service.dao.config.CashierCodeTypeConfigManager;
|
||||
import org.dromara.daxpay.service.entity.config.CashierCodeConfig;
|
||||
import org.dromara.daxpay.service.entity.config.CashierCodeTypeConfig;
|
||||
import org.dromara.daxpay.service.param.config.CashierCodeTypeConfigParam;
|
||||
import org.dromara.daxpay.service.result.config.CashierCodeTypeConfigResult;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 收银码牌码牌类型配置
|
||||
* @author xxm
|
||||
* @since 2024/11/20
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class CashierCodeTypeConfigService {
|
||||
private final CashierCodeTypeConfigManager codeTypeConfigManager;
|
||||
private final CashierCodeConfigManager codeConfigManager;
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
public List<CashierCodeTypeConfigResult> findByAppId(Long cashierCodeId) {
|
||||
return MpUtil.toListResult(codeTypeConfigManager.findAllByCashierCode(cashierCodeId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询详情
|
||||
*/
|
||||
public CashierCodeTypeConfigResult findById(Long id) {
|
||||
return codeTypeConfigManager.findById(id).map(CashierCodeTypeConfig::toResult).orElseThrow(() -> new DataNotExistException("收银码牌配置不存在"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断类型是否存在
|
||||
*/
|
||||
public boolean existsByType(String type, Long cashierCodeId) {
|
||||
return codeTypeConfigManager.existsByType(type, cashierCodeId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断类型是否存在
|
||||
*/
|
||||
public boolean existsByType(String type, Long cashierCodeId, Long id) {
|
||||
return codeTypeConfigManager.existsByType(type, cashierCodeId, id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*/
|
||||
public void save(CashierCodeTypeConfigParam param) {
|
||||
CashierCodeConfig codeConfig = codeConfigManager.findById(param.getCashierCodeId())
|
||||
.orElseThrow(() -> new DataNotExistException("收银码牌配置不存在"));
|
||||
// 收银码牌类型不能重复
|
||||
boolean existed = codeTypeConfigManager.existsByType(param.getType(), param.getId());
|
||||
if (existed){
|
||||
throw new DataNotExistException("收银码牌类型不可重复配置");
|
||||
}
|
||||
|
||||
CashierCodeTypeConfig entity = CashierCodeTypeConfig.init(param);
|
||||
entity.setAppId(codeConfig.getAppId());
|
||||
codeTypeConfigManager.save(entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*/
|
||||
public void update(CashierCodeTypeConfigParam param) {
|
||||
// 收银码牌类型不能重复
|
||||
boolean existed = codeTypeConfigManager.existsByType(param.getType(), param.getId(), param.getId());
|
||||
if (existed){
|
||||
throw new DataNotExistException("收银码牌类型不可重复配置");
|
||||
}
|
||||
var channelCashierConfig = codeTypeConfigManager.findById(param.getId())
|
||||
.orElseThrow(() -> new DataNotExistException("收银码牌配置不存在"));
|
||||
BeanUtil.copyProperties(param, channelCashierConfig, CopyOptions.create().ignoreNullValue());
|
||||
codeTypeConfigManager.updateById(channelCashierConfig);
|
||||
}
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
public void delete(Long id) {
|
||||
if (codeTypeConfigManager.existedById(id)){
|
||||
throw new DataNotExistException("该码牌类型配置不存在");
|
||||
}
|
||||
codeTypeConfigManager.deleteById(id);
|
||||
}
|
||||
}
|
||||
|
@@ -1,115 +0,0 @@
|
||||
package org.dromara.daxpay.service.service.config;
|
||||
|
||||
import cn.bootx.platform.common.mybatisplus.util.MpUtil;
|
||||
import cn.bootx.platform.core.exception.DataNotExistException;
|
||||
import org.dromara.daxpay.service.dao.config.ChannelCashierConfigManage;
|
||||
import org.dromara.daxpay.service.dao.merchant.MchAppManager;
|
||||
import org.dromara.daxpay.service.entity.config.ChannelCashierConfig;
|
||||
import org.dromara.daxpay.service.entity.config.PlatformConfig;
|
||||
import org.dromara.daxpay.service.entity.merchant.MchApp;
|
||||
import org.dromara.daxpay.service.param.config.ChannelCashierConfigParam;
|
||||
import org.dromara.daxpay.service.result.config.ChannelCashierConfigResult;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.bean.copier.CopyOptions;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 通道支付收银台配置
|
||||
* @author xxm
|
||||
* @since 2024/9/28
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class ChannelCashierConfigService {
|
||||
private final MchAppManager mchAppManager;
|
||||
|
||||
private final ChannelCashierConfigManage cashierConfigManage;
|
||||
|
||||
private final PlatformConfigService platformConfigService;
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
public List<ChannelCashierConfigResult> findByAppId(String appId) {
|
||||
return MpUtil.toListResult(cashierConfigManage.findAllByAppId(appId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询详情
|
||||
*/
|
||||
public ChannelCashierConfigResult findById(Long id) {
|
||||
return cashierConfigManage.findById(id).map(ChannelCashierConfig::toResult).orElseThrow(() -> new DataNotExistException("通道支付收银台配置不存在"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据类型查询
|
||||
*/
|
||||
public ChannelCashierConfigResult findByCashierType(String cashierType) {
|
||||
return cashierConfigManage.findByCashierType(cashierType)
|
||||
.map(ChannelCashierConfig::toResult)
|
||||
.orElseThrow(() -> new DataNotExistException("通道支付收银台配置不存在"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断类型是否存在
|
||||
*/
|
||||
public boolean existsByType(String type, String appId) {
|
||||
return cashierConfigManage.existsByType(type, appId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断类型是否存在
|
||||
*/
|
||||
public boolean existsByType(String type, String appId, Long id) {
|
||||
return cashierConfigManage.existsByType(type, appId, id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*/
|
||||
public void save(ChannelCashierConfigParam param) {
|
||||
// 收银台类型不能重复
|
||||
boolean existed = cashierConfigManage.existedByField(ChannelCashierConfig::getCashierType, param.getCashierType());
|
||||
if (existed){
|
||||
throw new DataNotExistException("收银台类型不可重复配置");
|
||||
}
|
||||
cashierConfigManage.save(ChannelCashierConfig.init(param));
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*/
|
||||
public void update(ChannelCashierConfigParam param) {
|
||||
// 收银台类型不能重复
|
||||
boolean existed = cashierConfigManage.existedByField(ChannelCashierConfig::getCashierType, param.getCashierType(), param.getId());
|
||||
if (existed){
|
||||
throw new DataNotExistException("收银台类型不可重复配置");
|
||||
}
|
||||
ChannelCashierConfig channelCashierConfig = cashierConfigManage.findById(param.getId())
|
||||
.orElseThrow(() -> new DataNotExistException("通道支付收银台配置不存在"));
|
||||
BeanUtil.copyProperties(param, channelCashierConfig, CopyOptions.create().ignoreNullValue());
|
||||
cashierConfigManage.updateById(channelCashierConfig);
|
||||
}
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
public void delete(Long id) {
|
||||
cashierConfigManage.deleteById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取码牌地址
|
||||
*/
|
||||
public String qrCodeUrl(String appId) {
|
||||
MchApp mchApp = mchAppManager.findByAppId(appId).orElseThrow(() -> new DataNotExistException("未找到指定的应用配置"));
|
||||
PlatformConfig platformConfig = platformConfigService.getConfig();
|
||||
String serverUrl = platformConfig.getGatewayMobileUrl();
|
||||
return StrUtil.format("{}/channel/cashier/{}", serverUrl, mchApp.getAppId());
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user