feat[支付模块]:第三方支付集成
This commit is contained in:
+1
-1
@@ -9,7 +9,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients;
|
|||||||
* @author zlt
|
* @author zlt
|
||||||
*/
|
*/
|
||||||
@EnableDiscoveryClient
|
@EnableDiscoveryClient
|
||||||
@EnableFeignClients(basePackages = "com.central")
|
@EnableFeignClients(basePackages = "com.central.generator")
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
public class CodeGeneratorApp {
|
public class CodeGeneratorApp {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|||||||
+2
-1
@@ -2,6 +2,7 @@ package com.central.generator.mapper;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.central.db.mapper.SuperMapper;
|
import com.central.db.mapper.SuperMapper;
|
||||||
|
import com.central.generator.model.TableEntity;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
@@ -14,7 +15,7 @@ import java.util.Map;
|
|||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface SysGeneratorMapper extends SuperMapper {
|
public interface SysGeneratorMapper extends SuperMapper<TableEntity> {
|
||||||
List<Map<String, Object>> queryList(Page<Map<String, Object>> page, @Param("p") Map<String, Object> map);
|
List<Map<String, Object>> queryList(Page<Map<String, Object>> page, @Param("p") Map<String, Object> map);
|
||||||
|
|
||||||
int queryTotal(Map<String, Object> map);
|
int queryTotal(Map<String, Object> map);
|
||||||
|
|||||||
+5
-6
@@ -1,17 +1,16 @@
|
|||||||
package com.central.generator.service;
|
package com.central.generator.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.central.common.model.PageResult;
|
||||||
|
import com.central.generator.model.TableEntity;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
|
||||||
import com.central.common.model.PageResult;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author zlt
|
* @Author zlt
|
||||||
*/
|
*/
|
||||||
@Service
|
public interface SysGeneratorService extends IService<TableEntity> {
|
||||||
public interface SysGeneratorService extends IService {
|
|
||||||
PageResult queryList(Map<String, Object> map);
|
PageResult queryList(Map<String, Object> map);
|
||||||
|
|
||||||
Map<String, String> queryTable(String tableName);
|
Map<String, String> queryTable(String tableName);
|
||||||
|
|||||||
+9
-7
@@ -1,15 +1,10 @@
|
|||||||
package com.central.generator.service.impl;
|
package com.central.generator.service.impl;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.zip.ZipOutputStream;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.central.common.model.PageResult;
|
import com.central.common.model.PageResult;
|
||||||
import com.central.generator.mapper.SysGeneratorMapper;
|
import com.central.generator.mapper.SysGeneratorMapper;
|
||||||
|
import com.central.generator.model.TableEntity;
|
||||||
import com.central.generator.service.SysGeneratorService;
|
import com.central.generator.service.SysGeneratorService;
|
||||||
import com.central.generator.utils.GenUtils;
|
import com.central.generator.utils.GenUtils;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@@ -17,12 +12,18 @@ import org.apache.commons.collections4.MapUtils;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.zip.ZipOutputStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author zlt
|
* @Author zlt
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
public class SysGeneratorServiceImpl extends ServiceImpl implements SysGeneratorService {
|
public class SysGeneratorServiceImpl extends ServiceImpl<SysGeneratorMapper, TableEntity> implements SysGeneratorService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private SysGeneratorMapper sysGeneratorMapper;
|
private SysGeneratorMapper sysGeneratorMapper;
|
||||||
|
|
||||||
@@ -63,4 +64,5 @@ public class SysGeneratorServiceImpl extends ServiceImpl implements SysGenerator
|
|||||||
}
|
}
|
||||||
return outputStream.toByteArray();
|
return outputStream.toByteArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
spring:
|
spring:
|
||||||
datasource:
|
datasource:
|
||||||
url: jdbc:mysql://${zlt.datasource.ip}:3306/tourist-center?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false&zeroDateTimeBehavior=convertToNull&serverTimezone=Asia/Shanghai
|
url: jdbc:mysql://${zlt.datasource.ip}/order-center?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false&zeroDateTimeBehavior=convertToNull&serverTimezone=Asia/Shanghai
|
||||||
username: ${zlt.datasource.username}
|
username: ${zlt.datasource.username}
|
||||||
password: ${zlt.datasource.password}
|
password: ${zlt.datasource.password}
|
||||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||||
|
|||||||
-13
@@ -33,19 +33,6 @@ public class FileController {
|
|||||||
return fileService.upload(file);
|
return fileService.upload(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 文件上传
|
|
||||||
* 根据fileType选择上传方式
|
|
||||||
*
|
|
||||||
* @param id
|
|
||||||
* @return
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
|
||||||
/* @GetMapping("/files/{id}")
|
|
||||||
public Result upload(@PathVariable String id) throws Exception {
|
|
||||||
return "fileService.download(file)";
|
|
||||||
}*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 文件删除
|
* 文件删除
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -98,14 +98,27 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.binarywang</groupId>
|
<groupId>com.github.binarywang</groupId>
|
||||||
<artifactId>weixin-java-pay</artifactId>
|
<artifactId>weixin-java-pay</artifactId>
|
||||||
<version>4.6.0</version>
|
<version>4.1.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.egzosn</groupId>
|
||||||
|
<artifactId>pay-java-wx</artifactId>
|
||||||
|
<version>2.14.7</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.binarywang</groupId>
|
<groupId>com.github.binarywang</groupId>
|
||||||
<artifactId>weixin-java-miniapp</artifactId>
|
<artifactId>weixin-java-miniapp</artifactId>
|
||||||
<version>4.6.0</version>
|
<version>4.6.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>javax.servlet</groupId>
|
||||||
|
<artifactId>javax.servlet-api</artifactId>
|
||||||
|
<version>4.0.1</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|||||||
+54
-6
@@ -4,20 +4,30 @@ import com.central.common.context.LoginUserContextHolder;
|
|||||||
import com.central.common.model.LoginAppUser;
|
import com.central.common.model.LoginAppUser;
|
||||||
import com.central.common.model.PageResult;
|
import com.central.common.model.PageResult;
|
||||||
import com.central.common.model.Result;
|
import com.central.common.model.Result;
|
||||||
|
import com.central.common.model.SysUser;
|
||||||
|
import com.central.order.feign.UserCenterService;
|
||||||
import com.central.order.model.Order;
|
import com.central.order.model.Order;
|
||||||
import com.central.order.service.IOrderService;
|
import com.central.order.service.IOrderService;
|
||||||
|
import com.egzosn.pay.common.api.PayService;
|
||||||
|
import com.egzosn.pay.common.bean.PayOrder;
|
||||||
|
import com.egzosn.pay.wx.bean.WxTransactionType;
|
||||||
|
import com.egzosn.pay.wx.v3.api.WxPayConfigStorage;
|
||||||
|
import com.egzosn.pay.wx.v3.api.WxPayService;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
import io.swagger.v3.oas.annotations.Parameters;
|
import io.swagger.v3.oas.annotations.Parameters;
|
||||||
import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import jakarta.annotation.PostConstruct;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Order information
|
* Order information
|
||||||
@@ -34,6 +44,27 @@ public class OrderController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private IOrderService orderService;
|
private IOrderService orderService;
|
||||||
|
|
||||||
|
private PayService payService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private UserCenterService userCenterService;
|
||||||
|
/**
|
||||||
|
* 这里对 PayService 与 router进行构造
|
||||||
|
*/
|
||||||
|
@PostConstruct
|
||||||
|
public void init() {
|
||||||
|
|
||||||
|
WxPayConfigStorage wxPayConfigStorage = new WxPayConfigStorage();
|
||||||
|
wxPayConfigStorage.setMchId("1703796518");
|
||||||
|
wxPayConfigStorage.setAppId("wx30a3c8de94a85584");
|
||||||
|
// wxPayConfigStorage.setKeyPublic("转账公钥,转账时必填");
|
||||||
|
// wxPayConfigStorage.setApiKey("密钥");
|
||||||
|
wxPayConfigStorage.setNotifyUrl("https://img.goflytec.com/pay/unifiedorder");
|
||||||
|
wxPayConfigStorage.setReturnUrl("https://img.goflytec.com/pay/unifiedorder");
|
||||||
|
wxPayConfigStorage.setSignType("MD5");
|
||||||
|
wxPayConfigStorage.setInputCharset("utf-8");
|
||||||
|
payService = new WxPayService(wxPayConfigStorage);
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* 列表
|
* 列表
|
||||||
*/
|
*/
|
||||||
@@ -68,12 +99,29 @@ public class OrderController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 支付订单
|
|
||||||
// @PutMapping("/{orderId}/pay")
|
/**
|
||||||
// public Result<String> payOrder(@PathVariable Long orderId) {
|
* 公众号支付
|
||||||
// orderService.payOrder(orderId);
|
*
|
||||||
// return Result.succeed("支付订单操作已接收,正在处理");
|
* @param orderId 微信公众号对应微信付款用户的唯一标识
|
||||||
// }
|
* @return 返回jsapi所需参数
|
||||||
|
*/
|
||||||
|
@PutMapping("/{orderId}/pay")
|
||||||
|
public Result<Map> payOrder(@PathVariable("orderId") Long orderId) {
|
||||||
|
|
||||||
|
SysUser user = userCenterService.findUserById(LoginUserContextHolder.getUser().getId());
|
||||||
|
|
||||||
|
PayOrder order = new PayOrder("订单title", "摘要", new BigDecimal(0.01) , UUID.randomUUID().toString().replace("-", ""));
|
||||||
|
//公众号支付
|
||||||
|
order.setTransactionType(WxTransactionType.JSAPI);
|
||||||
|
//微信公众号对应微信付款用户的唯一标识
|
||||||
|
order.setOpenid(user.getOpenId());
|
||||||
|
|
||||||
|
Map orderInfo = payService.orderInfo(order);
|
||||||
|
orderInfo.put("code", 0);
|
||||||
|
|
||||||
|
return Result.succeed(orderInfo,"成功");
|
||||||
|
}
|
||||||
|
|
||||||
// 获取排队中的订单列表
|
// 获取排队中的订单列表
|
||||||
@GetMapping("/queue")
|
@GetMapping("/queue")
|
||||||
|
|||||||
+71
@@ -0,0 +1,71 @@
|
|||||||
|
package com.central.order.controller;
|
||||||
|
|
||||||
|
import com.central.common.context.LoginUserContextHolder;
|
||||||
|
import com.central.common.model.LoginAppUser;
|
||||||
|
import com.central.common.model.PageResult;
|
||||||
|
import com.central.common.model.Result;
|
||||||
|
import com.central.order.model.OrderFile;
|
||||||
|
import com.central.order.service.IOrderFileService;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
|
import io.swagger.v3.oas.annotations.Parameters;
|
||||||
|
import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Order Files information
|
||||||
|
*
|
||||||
|
* @author lsl
|
||||||
|
* @date 2024-12-19 17:51:47
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@RestController
|
||||||
|
@Tag(name = "Order Files information")
|
||||||
|
@RequestMapping("/files")
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class OrderFileController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IOrderFileService orderFileService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 列表
|
||||||
|
*/
|
||||||
|
@Operation(summary = "查询列表")
|
||||||
|
@Parameters({
|
||||||
|
@Parameter(name = "page",description = "分页起始位置",required = true,in=ParameterIn.QUERY),
|
||||||
|
@Parameter(name = "limit",description = "分页结束位置",required = true,in=ParameterIn.QUERY)
|
||||||
|
})
|
||||||
|
@GetMapping
|
||||||
|
public PageResult list(@RequestParam Map<String, Object> params) {
|
||||||
|
return orderFileService.findList(params);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping
|
||||||
|
public Result<OrderFile> createOrder(@RequestBody OrderFile orderFile) {
|
||||||
|
|
||||||
|
LoginAppUser user = LoginUserContextHolder.getUser();
|
||||||
|
orderFile.setUserId(user.getId());
|
||||||
|
boolean result = orderFileService.createOrderFile(orderFile);
|
||||||
|
if (result) {
|
||||||
|
return Result.succeed(orderFile,"文件资源创建成功");
|
||||||
|
} else {
|
||||||
|
return Result.failed("文件资源创建失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Result<OrderFile> getOrderFile(@PathVariable("fileId") String fileId) {
|
||||||
|
OrderFile orderFile = orderFileService.getOrderFileByFileId(fileId);
|
||||||
|
if (orderFile == null) {
|
||||||
|
return Result.failed("暂无数据");
|
||||||
|
}
|
||||||
|
return Result.succeed(orderFile,"获取成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+67
@@ -0,0 +1,67 @@
|
|||||||
|
package com.central.order.controller;
|
||||||
|
|
||||||
|
import com.central.common.model.PageResult;
|
||||||
|
import com.central.common.model.Result;
|
||||||
|
import com.central.order.model.Tourism;
|
||||||
|
import com.central.order.service.ITourismService;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
|
import io.swagger.v3.oas.annotations.Parameters;
|
||||||
|
import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tourism information
|
||||||
|
*
|
||||||
|
* @author lsl
|
||||||
|
* @date 2024-12-19 17:51:47
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@RestController
|
||||||
|
@Tag(name = "Tourism information")
|
||||||
|
@RequestMapping("/tourism")
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class TourismController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ITourismService tourismService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 列表
|
||||||
|
*/
|
||||||
|
@Operation(summary = "查询列表")
|
||||||
|
@Parameters({
|
||||||
|
@Parameter(name = "page",description = "分页起始位置",required = true,in=ParameterIn.QUERY),
|
||||||
|
@Parameter(name = "limit",description = "分页结束位置",required = true,in=ParameterIn.QUERY)
|
||||||
|
})
|
||||||
|
@GetMapping
|
||||||
|
public PageResult list(@RequestParam Map<String, Object> params) {
|
||||||
|
return tourismService.findList(params);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping
|
||||||
|
public Result<Tourism> createOrder(@RequestBody Tourism tourism) {
|
||||||
|
|
||||||
|
boolean result = tourismService.createTourism(tourism);
|
||||||
|
if (result) {
|
||||||
|
return Result.succeed(tourism,"jq创建成功");
|
||||||
|
} else {
|
||||||
|
return Result.failed("jq创建失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Result<Tourism> getOrderFile(@PathVariable("id") Long id) {
|
||||||
|
Tourism tourism = tourismService.getTourismById(id);
|
||||||
|
if (tourism == null) {
|
||||||
|
return Result.failed("暂无数据");
|
||||||
|
}
|
||||||
|
return Result.succeed(tourism,"获取成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
-66
@@ -1,66 +0,0 @@
|
|||||||
package com.central.order.controller;
|
|
||||||
|
|
||||||
import com.github.binarywang.wxpay.bean.notify.WxPayNotifyResponse;
|
|
||||||
import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult;
|
|
||||||
import com.github.binarywang.wxpay.config.WxPayConfig;
|
|
||||||
import com.github.binarywang.wxpay.service.WxPayService;
|
|
||||||
import com.github.binarywang.wxpay.service.impl.WxPayServiceImpl;
|
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* pay notify information
|
|
||||||
*
|
|
||||||
* @author lsl
|
|
||||||
* @date 2024-12-19 17:51:47
|
|
||||||
*/
|
|
||||||
@Slf4j
|
|
||||||
@RestController
|
|
||||||
@Tag(name = "Pay notify information")
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
public class WeixinPayNotifyController {
|
|
||||||
|
|
||||||
private static final WxPayService wxPayService = new WxPayServiceImpl();
|
|
||||||
|
|
||||||
static {
|
|
||||||
WxPayConfig payConfig = new WxPayConfig();
|
|
||||||
payConfig.setMchId("YOUR_MCH_ID");
|
|
||||||
payConfig.setMchKey("YOUR_MCH_KEY");
|
|
||||||
payConfig.setAppId("YOUR_APP_ID");
|
|
||||||
payConfig.setNotifyUrl("http://your_domain/weixin/pay/notify");
|
|
||||||
// 设置证书等其他配置信息(如果需要)
|
|
||||||
((WxPayServiceImpl) wxPayService).setConfig(payConfig);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 接收微信支付异步通知,验证并处理支付结果
|
|
||||||
@PostMapping("/pay/notify")
|
|
||||||
public String handleNotify(HttpServletRequest request) {
|
|
||||||
try {
|
|
||||||
// Map<String, String> notifyParams = WxPayUtil.xmlToMap(request.getInputStream());
|
|
||||||
// WxPayOrderNotifyResult result = wxPayService.parseOrderNotifyResult(notifyParams);
|
|
||||||
WxPayOrderNotifyResult result = wxPayService.parseOrderNotifyResult("notifyParams");
|
|
||||||
if ("SUCCESS".equals(result.getResultCode())) {
|
|
||||||
// 验证通知信息的合法性,如签名等,这里微信支付工具包已做了部分验证,可根据实际情况进一步确认
|
|
||||||
String orderNumber = result.getOutTradeNo();
|
|
||||||
// 根据业务逻辑处理订单,比如更新订单状态为已支付、记录支付信息等
|
|
||||||
handleOrderAfterPayment(orderNumber);
|
|
||||||
return WxPayNotifyResponse.success("OK");
|
|
||||||
} else {
|
|
||||||
return WxPayNotifyResponse.fail("支付失败");
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
return WxPayNotifyResponse.fail("通知处理异常");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 处理支付完成后的订单逻辑(这里简单示例,实际需根据业务详细拓展)
|
|
||||||
private void handleOrderAfterPayment(String orderNumber) {
|
|
||||||
// 此处可调用业务逻辑层方法,比如更新订单状态、记录支付记录等操作
|
|
||||||
System.out.println("订单 " + orderNumber + " 支付成功,正在处理订单后续逻辑");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+43
@@ -0,0 +1,43 @@
|
|||||||
|
//package com.central.order.controller;
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//import com.github.binarywang.wxpay.bean.notify.WxPayNotifyResponse;
|
||||||
|
//import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult;
|
||||||
|
//import com.github.binarywang.wxpay.service.WxPayService;
|
||||||
|
//import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
//import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
//import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
//import org.springframework.web.bind.annotation.RestController;
|
||||||
|
//
|
||||||
|
//import javax.servlet.http.HttpServletRequest;
|
||||||
|
//import java.util.HashMap;
|
||||||
|
//import java.util.Map;
|
||||||
|
//
|
||||||
|
//@RestController
|
||||||
|
//public class WxPayNotifyController {
|
||||||
|
//
|
||||||
|
//// @Autowired
|
||||||
|
// private WxPayService wxPayService;
|
||||||
|
////
|
||||||
|
// @PostMapping("/pay/notify")
|
||||||
|
// public String payNotify(HttpServletRequest request, @RequestBody String body) throws Exception {
|
||||||
|
// // 将XML格式的请求体转换为Map
|
||||||
|
// Map<String, String> params = new HashMap<>();
|
||||||
|
// // 这里需要你自己实现一个将XML转换为Map的工具方法
|
||||||
|
// // 例如使用Dom4j或JAXB等库来解析XML
|
||||||
|
//
|
||||||
|
// // 验证签名
|
||||||
|
// boolean signVerified = wxPayService.verifyNotify(params);
|
||||||
|
// if (!signVerified) {
|
||||||
|
// return WxPayNotifyResponse.fail("签名验证失败").toXml();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // 转换为WxPayOrderNotifyResult对象(可选,但推荐)
|
||||||
|
// WxPayOrderNotifyResult notifyResult = WxPayOrderNotifyResult.fromXml(body);
|
||||||
|
//
|
||||||
|
// // 处理支付结果
|
||||||
|
// // 根据notifyResult中的数据进行业务处理,如更新订单状态等
|
||||||
|
//
|
||||||
|
// return WxPayNotifyResponse.success("处理成功").toXml();
|
||||||
|
// }
|
||||||
|
//}
|
||||||
+49
-50
@@ -1,50 +1,49 @@
|
|||||||
package com.central.order.controller;
|
//package com.central.order.controller;
|
||||||
|
//
|
||||||
import com.github.binarywang.wx.miniprogram.api.WxMaService;
|
//import cn.binarywang.wx.miniapp.api.WxMaService;
|
||||||
import com.github.binarywang.wx.miniprogram.api.impl.WxMaServiceImpl;
|
//import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl;
|
||||||
import com.github.binarywang.wx.miniprogram.bean.template.WxMaSubscribeMessage;
|
//import cn.binarywang.wx.miniapp.bean.WxMaSubscribeMessage;
|
||||||
import com.github.binarywang.wx.miniprogram.bean.template.WxMaSubscribeTemplateData;
|
//import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
//import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
//import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
//import org.springframework.web.bind.annotation.RestController;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
//
|
||||||
|
//import java.util.ArrayList;
|
||||||
import java.util.ArrayList;
|
//import java.util.List;
|
||||||
import java.util.List;
|
//import java.util.Map;
|
||||||
import java.util.Map;
|
//
|
||||||
|
//@RestController
|
||||||
@RestController
|
//@RequestMapping("/wx/subscribe")
|
||||||
@RequestMapping("/wx/subscribe")
|
//public class WxSubscribeMessageController {
|
||||||
public class WxSubscribeMessageController {
|
// private final WxMaService wxMaService = new WxMaServiceImpl();
|
||||||
private final WxMaService wxMaService = new WxMaServiceImpl();
|
//
|
||||||
|
// static {
|
||||||
static {
|
// wxMaService.setWxMaConfig(new WxMaInMemoryConfig());
|
||||||
wxMaService.setWxMaConfig(new WxMaInMemoryConfig());
|
// wxMaService.getWxMaConfig().setAppId("YOUR_APPID");
|
||||||
wxMaService.getWxMaConfig().setAppId("YOUR_APPID");
|
// wxMaService.getWxMaConfig().setAppSecret("YOUR_APPSECRET");
|
||||||
wxMaService.getWxMaConfig().setAppSecret("YOUR_APPSECRET");
|
// }
|
||||||
}
|
//
|
||||||
|
// // 接收前端传来的订阅消息发送请求参数,发送订阅消息
|
||||||
// 接收前端传来的订阅消息发送请求参数,发送订阅消息
|
// @PostMapping("/send")
|
||||||
@PostMapping("/send")
|
// public boolean sendSubscribeMessage(@RequestBody Map<String, Object> requestData) {
|
||||||
public boolean sendSubscribeMessage(@RequestBody Map<String, Object> requestData) {
|
// try {
|
||||||
try {
|
// String openId = (String) requestData.get("openId");
|
||||||
String openId = (String) requestData.get("openId");
|
// String templateId = (String) requestData.get("templateId");
|
||||||
String templateId = (String) requestData.get("templateId");
|
//
|
||||||
|
// WxMaSubscribeMessage subscribeMessage = new WxMaSubscribeMessage();
|
||||||
WxMaSubscribeMessage subscribeMessage = new WxMaSubscribeMessage();
|
// subscribeMessage.setTemplateId(templateId);
|
||||||
subscribeMessage.setTemplateId(templateId);
|
// subscribeMessage.setToUser(openId);
|
||||||
subscribeMessage.setToUser(openId);
|
//
|
||||||
|
// List<WxMaSubscribeMessage> data = new ArrayList<>();
|
||||||
List<WxMaSubscribeTemplateData> data = new ArrayList<>();
|
// // 根据订阅消息模板的关键词设置对应的数据,示例如下(假设模板有两个关键词:keyword1和keyword2)
|
||||||
// 根据订阅消息模板的关键词设置对应的数据,示例如下(假设模板有两个关键词:keyword1和keyword2)
|
// data.add(new WxMaSubscribeTemplateData("keyword1", "具体内容1", "#FF0000"));
|
||||||
data.add(new WxMaSubscribeTemplateData("keyword1", "具体内容1", "#FF0000"));
|
// data.add(new WxMaSubscribeTemplateData("keyword2", "具体内容2", "#00FF00"));
|
||||||
data.add(new WxMaSubscribeTemplateData("keyword2", "具体内容2", "#00FF00"));
|
// subscribeMessage.setData(data);
|
||||||
subscribeMessage.setData(data);
|
//
|
||||||
|
// return wxMaService.getSubscribeMsgService().sendSubscribeMsg(subscribeMessage);
|
||||||
return wxMaService.getSubscribeMsgService().sendSubscribeMsg(subscribeMessage);
|
// } catch (Exception e) {
|
||||||
} catch (Exception e) {
|
// e.printStackTrace();
|
||||||
e.printStackTrace();
|
// return false;
|
||||||
return false;
|
// }
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
}
|
|
||||||
|
|||||||
+51
-48
@@ -1,48 +1,51 @@
|
|||||||
package com.central.order.controller;
|
//package com.central.order.controller;
|
||||||
|
//
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
//import cn.binarywang.wx.miniapp.api.WxMaService;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
//import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
//import cn.binarywang.wx.miniapp.bean.WxMaTemplateData;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
//import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
//import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import java.util.ArrayList;
|
//import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import java.util.List;
|
//import org.springframework.web.bind.annotation.RestController;
|
||||||
import java.util.Map;
|
//
|
||||||
|
//import java.util.ArrayList;
|
||||||
@RestController
|
//import java.util.List;
|
||||||
@RequestMapping("/wx/template")
|
//import java.util.Map;
|
||||||
public class WxTemplateMessageController {
|
//
|
||||||
private final WxMaS wxMaService = new WxMaServiceImpl();
|
//@RestController
|
||||||
|
//@RequestMapping("/wx/template")
|
||||||
static {
|
//public class WxTemplateMessageController {
|
||||||
wxMaService.setWxMaConfig(new WxMaInMemoryConfig());
|
// private final WxMaService wxMaService = new WxMaServiceImpl();
|
||||||
wxMaService.getWxMaConfig().setAppId("YOUR_APPID");
|
//
|
||||||
wxMaService.getWxMaConfig().setAppSecret("YOUR_APPSECRET");
|
// static {
|
||||||
}
|
// wxMaService.setWxMaConfig(new WxMaInMemoryConfig());
|
||||||
|
// wxMaService.getWxMaConfig().setAppId("YOUR_APPID");
|
||||||
// 接收前端传来的模板消息发送请求参数,发送模板消息
|
// wxMaService.getWxMaConfig().setAppSecret("YOUR_APPSECRET");
|
||||||
@PostMapping("/send")
|
// }
|
||||||
public boolean sendTemplateMessage(@RequestBody Map<String, Object> requestData) {
|
//
|
||||||
try {
|
// // 接收前端传来的模板消息发送请求参数,发送模板消息
|
||||||
String formId = (String) requestData.get("formId");
|
// @PostMapping("/send")
|
||||||
String templateId = (String) requestData.get("templateId");
|
// public boolean sendTemplateMessage(@RequestBody Map<String, Object> requestData) {
|
||||||
String openId = (String) requestData.get("openId");
|
// try {
|
||||||
|
// String formId = (String) requestData.get("formId");
|
||||||
WxMaTemplateMessage templateMessage = new WxMaTemplateMessage();
|
// String templateId = (String) requestData.get("templateId");
|
||||||
templateMessage.setTemplateId(templateId);
|
// String openId = (String) requestData.get("openId");
|
||||||
templateMessage.setToUser(openId);
|
//
|
||||||
templateMessage.setFormId(formId);
|
// WxMaTemplateMessage templateMessage = new WxMaTemplateMessage();
|
||||||
|
// templateMessage.setTemplateId(templateId);
|
||||||
List<WxMaTemplateData> data = new ArrayList<>();
|
// templateMessage.setToUser(openId);
|
||||||
// 根据模板的关键词设置对应的数据,示例如下(假设模板有两个关键词:keyword1和keyword2)
|
// templateMessage.setFormId(formId);
|
||||||
data.add(new WxMaTemplateData("keyword1", "具体内容1", "#FF0000"));
|
//
|
||||||
data.add(new WxMaTemplateData("keyword2", "具体内容2", "#00FF00"));
|
// List<WxMaTemplateData> data = new ArrayList<>();
|
||||||
templateMessage.setData(data);
|
// // 根据模板的关键词设置对应的数据,示例如下(假设模板有两个关键词:keyword1和keyword2)
|
||||||
|
// data.add(new WxMaTemplateData("keyword1", "具体内容1", "#FF0000"));
|
||||||
return wxMaService.getTemplateMsgService().sendTemplateMsg(templateMessage);
|
// data.add(new WxMaTemplateData("keyword2", "具体内容2", "#00FF00"));
|
||||||
} catch (Exception e) {
|
// templateMessage.setData(data);
|
||||||
e.printStackTrace();
|
//
|
||||||
return false;
|
// return wxMaService.getTemplateMsgService().sendTemplateMsg(templateMessage);
|
||||||
}
|
// } catch (Exception e) {
|
||||||
}
|
// e.printStackTrace();
|
||||||
}
|
// return false;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|||||||
+29
@@ -0,0 +1,29 @@
|
|||||||
|
package com.central.order.feign;
|
||||||
|
|
||||||
|
import com.central.common.constant.ServiceNameConstants;
|
||||||
|
import com.central.common.model.SysUser;
|
||||||
|
import com.central.order.feign.fallback.UserCenterServiceFallbackFactory;
|
||||||
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* user-center模块远程调用
|
||||||
|
*
|
||||||
|
* @author lsl
|
||||||
|
* @version 1.0
|
||||||
|
* @description user-center模块远程调用
|
||||||
|
* @create 2025/1/13
|
||||||
|
**/
|
||||||
|
@FeignClient(name = ServiceNameConstants.USER_SERVICE, fallbackFactory = UserCenterServiceFallbackFactory.class, dismiss404 = true)
|
||||||
|
public interface UserCenterService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过ID查询用户信息
|
||||||
|
*
|
||||||
|
* @param id 用户ID
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("/users/{id}")
|
||||||
|
SysUser findUserById(@PathVariable("id") Long id);
|
||||||
|
}
|
||||||
+31
@@ -0,0 +1,31 @@
|
|||||||
|
package com.central.order.feign.fallback;
|
||||||
|
|
||||||
|
import com.central.common.model.SysUser;
|
||||||
|
import com.central.order.feign.UserCenterService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户中心调用失败回调
|
||||||
|
*
|
||||||
|
* @author caiji
|
||||||
|
* @version 1.0
|
||||||
|
* @description 用户中心调用失败回调
|
||||||
|
* @create 2024/8/6 11:33
|
||||||
|
**/
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
public class UserCenterServiceFallbackFactory implements FallbackFactory<UserCenterService> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UserCenterService create(Throwable cause) {
|
||||||
|
return new UserCenterService() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SysUser findUserById(Long id) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
package com.central.order.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.central.db.mapper.SuperMapper;
|
||||||
|
import com.central.order.model.OrderFile;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Order File information
|
||||||
|
*
|
||||||
|
* @author lsl
|
||||||
|
* @date 2024-12-19 17:52:54
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface OrderFileMapper extends SuperMapper<OrderFile> {
|
||||||
|
/**
|
||||||
|
* 分页查询用户列表
|
||||||
|
*
|
||||||
|
* @param page
|
||||||
|
* @param params
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<OrderFile> findList(Page<OrderFile> page, @Param("p") Map<String, Object> params);
|
||||||
|
|
||||||
|
|
||||||
|
// 新增订单资源
|
||||||
|
int insertOrderFile(OrderFile orderFile);
|
||||||
|
// 根据订单编号查询文件资源信息
|
||||||
|
List<OrderFile> getOrderFileByOrderNo(@Param("orderNo") String orderNo);
|
||||||
|
// 文件ID查询文件
|
||||||
|
OrderFile getFileByFileId(@Param("fileId") String fileId);
|
||||||
|
// 查询所有处于排队状态的订单,用于后续按顺序处理(可根据业务需求添加排序等逻辑)
|
||||||
|
List<OrderFile> getOrderFilesByUserId(@Param("userId") Long userId);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
package com.central.order.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.central.db.mapper.SuperMapper;
|
||||||
|
import com.central.order.model.Tourism;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tourism information
|
||||||
|
*
|
||||||
|
* @author lsl
|
||||||
|
* @date 2024-12-19 17:52:54
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface TourismMapper extends SuperMapper<Tourism> {
|
||||||
|
/**
|
||||||
|
* 分页查询用户列表
|
||||||
|
*
|
||||||
|
* @param page
|
||||||
|
* @param params
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<Tourism> findList(Page<Tourism> page, @Param("p") Map<String, Object> params);
|
||||||
|
|
||||||
|
|
||||||
|
// 新增订单资源
|
||||||
|
int insertTourism(Tourism tourism);
|
||||||
|
// ID查询
|
||||||
|
Tourism getTourismById(@Param("id") Long id);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
package com.central.order.model;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.central.common.model.SuperEntity;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* order files information
|
||||||
|
*
|
||||||
|
* @author lsl
|
||||||
|
* @date 2024-12-19 17:51:47
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
@TableName("order_files")
|
||||||
|
public class OrderFile extends SuperEntity {
|
||||||
|
private static final long serialVersionUID=1L;
|
||||||
|
|
||||||
|
private String orderNo;
|
||||||
|
private String fileId;
|
||||||
|
|
||||||
|
private Long userId;
|
||||||
|
// 景区ID
|
||||||
|
private Long tourismId;
|
||||||
|
private String filePath;
|
||||||
|
@TableField(fill = FieldFill.INSERT)
|
||||||
|
private Date createTime;
|
||||||
|
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||||
|
private Date updateTime;
|
||||||
|
//租户ID
|
||||||
|
private Long tenantId;
|
||||||
|
private String company;
|
||||||
|
private Integer isDel;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -19,7 +19,7 @@ import java.util.Date;
|
|||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
@EqualsAndHashCode(callSuper = false)
|
@EqualsAndHashCode(callSuper = false)
|
||||||
@TableName("tourism")
|
@TableName("tourisms")
|
||||||
public class Tourism extends SuperEntity {
|
public class Tourism extends SuperEntity {
|
||||||
|
|
||||||
private static final long serialVersionUID=1L;
|
private static final long serialVersionUID=1L;
|
||||||
@@ -40,6 +40,8 @@ public class Tourism extends SuperEntity {
|
|||||||
private Date updateTime;
|
private Date updateTime;
|
||||||
|
|
||||||
private Long createId;
|
private Long createId;
|
||||||
|
//租户ID
|
||||||
|
private Long tenantId;
|
||||||
private String company;
|
private String company;
|
||||||
private Integer isDel;
|
private Integer isDel;
|
||||||
}
|
}
|
||||||
|
|||||||
+54
@@ -0,0 +1,54 @@
|
|||||||
|
package com.central.order.service;
|
||||||
|
|
||||||
|
import com.central.common.model.PageResult;
|
||||||
|
import com.central.common.service.ISuperService;
|
||||||
|
import com.central.order.model.OrderFile;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Firmware file information
|
||||||
|
*
|
||||||
|
* @author lsl
|
||||||
|
* @date 2024-12-19 17:52:54
|
||||||
|
*/
|
||||||
|
public interface IOrderFileService extends ISuperService<OrderFile> {
|
||||||
|
/**
|
||||||
|
* 列表
|
||||||
|
* @param params
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
PageResult<OrderFile> findList(Map<String, Object> params);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建订单文件资源
|
||||||
|
*
|
||||||
|
* @param orderFile
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
boolean createOrderFile(OrderFile orderFile) ;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单编号查询订单文件资源
|
||||||
|
* @param orderNo
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<OrderFile> getOrderFileByOrderNo(String orderNo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户ID查询订单文件资源
|
||||||
|
* @param userId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<OrderFile> getOrderFileByUserId(Long userId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件ID查询订单文件资源
|
||||||
|
* @param fileId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
OrderFile getOrderFileByFileId(String fileId);
|
||||||
|
}
|
||||||
|
|
||||||
+38
@@ -0,0 +1,38 @@
|
|||||||
|
package com.central.order.service;
|
||||||
|
|
||||||
|
import com.central.common.model.PageResult;
|
||||||
|
import com.central.common.service.ISuperService;
|
||||||
|
import com.central.order.model.Tourism;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Firmware file information
|
||||||
|
*
|
||||||
|
* @author lsl
|
||||||
|
* @date 2024-12-19 17:52:54
|
||||||
|
*/
|
||||||
|
public interface ITourismService extends ISuperService<Tourism> {
|
||||||
|
/**
|
||||||
|
* 列表
|
||||||
|
* @param params
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
PageResult<Tourism> findList(Map<String, Object> params);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建
|
||||||
|
*
|
||||||
|
* @param tourism
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
boolean createTourism(Tourism tourism) ;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* id查询
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
Tourism getTourismById(Long id);
|
||||||
|
}
|
||||||
|
|
||||||
+62
@@ -0,0 +1,62 @@
|
|||||||
|
package com.central.order.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.central.common.model.PageResult;
|
||||||
|
import com.central.common.service.impl.SuperServiceImpl;
|
||||||
|
import com.central.order.mapper.OrderFileMapper;
|
||||||
|
import com.central.order.model.OrderFile;
|
||||||
|
import com.central.order.service.IOrderFileService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.collections4.MapUtils;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Order information
|
||||||
|
*
|
||||||
|
* @author lsl
|
||||||
|
* @date 2024-12-19 17:52:54
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
public class OrderFileServiceImpl extends SuperServiceImpl<OrderFileMapper, OrderFile> implements IOrderFileService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 列表
|
||||||
|
* @param params
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public PageResult<OrderFile> findList(Map<String, Object> params){
|
||||||
|
Page<OrderFile> page = new Page<>(MapUtils.getInteger(params, "page"), MapUtils.getInteger(params, "limit"));
|
||||||
|
List<OrderFile> list = baseMapper.findList(page, params);
|
||||||
|
return PageResult.<OrderFile>builder().data(list).code(0).count(page.getTotal()).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean createOrderFile(OrderFile orderFile) {
|
||||||
|
int result = baseMapper.insert(orderFile);
|
||||||
|
if(result > 0){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<OrderFile> getOrderFileByOrderNo(String orderNo) {
|
||||||
|
return baseMapper.getOrderFileByOrderNo(orderNo);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<OrderFile> getOrderFileByUserId(Long userId) {
|
||||||
|
return baseMapper.getOrderFilesByUserId(userId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public OrderFile getOrderFileByFileId(String fileId) {
|
||||||
|
return baseMapper.getFileByFileId(fileId);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+52
@@ -0,0 +1,52 @@
|
|||||||
|
package com.central.order.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.central.common.model.PageResult;
|
||||||
|
import com.central.common.service.impl.SuperServiceImpl;
|
||||||
|
import com.central.order.mapper.TourismMapper;
|
||||||
|
import com.central.order.model.Tourism;
|
||||||
|
import com.central.order.service.ITourismService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.collections4.MapUtils;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Order information
|
||||||
|
*
|
||||||
|
* @author lsl
|
||||||
|
* @date 2024-12-19 17:52:54
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
public class TourismServiceImpl extends SuperServiceImpl<TourismMapper, Tourism> implements ITourismService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 列表
|
||||||
|
* @param params
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public PageResult<Tourism> findList(Map<String, Object> params){
|
||||||
|
Page<Tourism> page = new Page<>(MapUtils.getInteger(params, "page"), MapUtils.getInteger(params, "limit"));
|
||||||
|
List<Tourism> list = baseMapper.findList(page, params);
|
||||||
|
return PageResult.<Tourism>builder().data(list).code(0).count(page.getTotal()).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean createTourism(Tourism tourism) {
|
||||||
|
int result = baseMapper.insert(tourism);
|
||||||
|
if(result > 0){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Tourism getTourismById(Long id) {
|
||||||
|
return baseMapper.getTourismById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
<?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="com.central.order.mapper.OrderFileMapper">
|
||||||
|
<select id="findList" resultType="com.central.order.model.OrderFile">
|
||||||
|
select * from order_files t
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<insert id="insertOrderFile">
|
||||||
|
INSERT INTO order_files (user_id, order_no, file_id,tourism_id,file_path)
|
||||||
|
VALUES (#{userId}, #{order_no}, #{file_id}, #{tourism_id}, #{file_path})
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<select id="getOrderFileByOrderNo" resultType="com.central.order.model.OrderFile">
|
||||||
|
SELECT * FROM order_files WHERE order_no = #{orderNo}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="getFileByFileId" resultType="com.central.order.model.OrderFile">
|
||||||
|
SELECT * FROM order_files WHERE file_id = #{fileId}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="getOrderFilesByUserId" resultType="com.central.order.model.OrderFile">
|
||||||
|
SELECT * FROM order_files WHERE user_id = #{userId}
|
||||||
|
</select>
|
||||||
|
</mapper>
|
||||||
+1
-1
@@ -85,7 +85,7 @@ public class CosTemplate implements InitializingBean {
|
|||||||
objectMetadata.setContentLength(size);
|
objectMetadata.setContentLength(size);
|
||||||
objectMetadata.setContentType(contentType);
|
objectMetadata.setContentType(contentType);
|
||||||
PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, objectName, is, objectMetadata);
|
PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, objectName, is, objectMetadata);
|
||||||
// putObjectRequest.getRequestClientOptions().setReadLimit(size + 1);
|
putObjectRequest.getRequestClientOptions().setReadLimit(size + 1);
|
||||||
|
|
||||||
cosClient.putObject(putObjectRequest);
|
cosClient.putObject(putObjectRequest);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user