Compare commits
No commits in common. "3b4ff9f774c51332d920769b2bc90a48a5ef53a3" and "79bfa1a981bc189364ecd7bf6d831cf7c9361e2a" have entirely different histories.
3b4ff9f774
...
79bfa1a981
|
@ -16,11 +16,7 @@
|
||||||
</description>
|
</description>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
|
||||||
<groupId>com.alipay.sdk</groupId>
|
|
||||||
<artifactId>alipay-easysdk</artifactId>
|
|
||||||
<version>2.2.0</version>
|
|
||||||
</dependency>
|
|
||||||
<!-- spring-boot-devtools -->
|
<!-- spring-boot-devtools -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
@ -77,12 +73,6 @@
|
||||||
<artifactId>mcwl-common</artifactId>
|
<artifactId>mcwl-common</artifactId>
|
||||||
<version>3.8.8</version>
|
<version>3.8.8</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- 支付模块-->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.mcwl</groupId>
|
|
||||||
<artifactId>mcwl-pay</artifactId>
|
|
||||||
<version>3.8.8</version>
|
|
||||||
</dependency>
|
|
||||||
<!-- 资源中心模块-->
|
<!-- 资源中心模块-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.mcwl</groupId>
|
<groupId>com.mcwl</groupId>
|
||||||
|
|
|
@ -1,40 +0,0 @@
|
||||||
package com.mcwl.web.controller.pay;
|
|
||||||
|
|
||||||
import com.alipay.easysdk.payment.facetoface.models.AlipayTradePrecreateResponse;
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
import com.alipay.easysdk.factory.Factory;
|
|
||||||
import com.mcwl.pay.domain.OrderTrade;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
import com.alipay.easysdk.kernel.Config;
|
|
||||||
/**
|
|
||||||
* 支付宝支付
|
|
||||||
|
|
||||||
*/
|
|
||||||
@Component
|
|
||||||
public class AliPayIntegration {
|
|
||||||
@Autowired
|
|
||||||
private Config config;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 调用支付宝预下订单接口
|
|
||||||
*
|
|
||||||
* @param tradeEntity 订单实体
|
|
||||||
* @return 二维码url
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
|
||||||
public String pay(OrderTrade tradeEntity) throws Exception {
|
|
||||||
Factory.setOptions(config);
|
|
||||||
//调用支付宝的接口
|
|
||||||
AlipayTradePrecreateResponse payResponse = Factory.Payment.FaceToFace()
|
|
||||||
.preCreate("商城",
|
|
||||||
tradeEntity.getCode(),
|
|
||||||
tradeEntity.getPaymentAmount().toString());
|
|
||||||
//参照官方文档响应示例,解析返回结果
|
|
||||||
String httpBodyStr = payResponse.getHttpBody();
|
|
||||||
JSONObject jsonObject = JSONObject.parseObject(httpBodyStr);
|
|
||||||
return jsonObject.getJSONObject("alipay_trade_precreate_response").get("qr_code").toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,113 +0,0 @@
|
||||||
package com.mcwl.web.controller.pay;
|
|
||||||
|
|
||||||
import cn.hutool.extra.qrcode.QrCodeUtil;
|
|
||||||
import com.mcwl.common.core.controller.BaseController;
|
|
||||||
import com.mcwl.common.core.domain.AjaxResult;
|
|
||||||
import com.mcwl.common.core.page.TableDataInfo;
|
|
||||||
import com.mcwl.common.domain.IdsParam;
|
|
||||||
import com.mcwl.common.interfaces.NoLogin;
|
|
||||||
import com.mcwl.common.utils.SecurityUtils;
|
|
||||||
import com.mcwl.pay.domain.OrderTrade;
|
|
||||||
import com.mcwl.pay.service.OrderTradeService;
|
|
||||||
import com.mcwl.resource.domain.MallProduct;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.util.CollectionUtils;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
import static com.mcwl.common.utils.PageUtils.startPage;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Author:ChenYan
|
|
||||||
* @Project:McWl
|
|
||||||
* @Package:com.mcwl.web.controller.pay
|
|
||||||
* @Filename:OrderTradeController
|
|
||||||
* @Description 支付模块
|
|
||||||
* @Date:2025/1/3 14:46
|
|
||||||
*/
|
|
||||||
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/web/pay")
|
|
||||||
@Validated
|
|
||||||
public class OrderTradeController extends BaseController {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private OrderTradeService orderTradeService;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private AliPayIntegration aliPayIntegration;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询列表
|
|
||||||
*/
|
|
||||||
@GetMapping("/list")
|
|
||||||
public TableDataInfo list(OrderTrade orderTrade)
|
|
||||||
{
|
|
||||||
startPage();
|
|
||||||
List<OrderTrade> list = orderTradeService.selectMallProductList(orderTrade);
|
|
||||||
return getDataTable(list);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增
|
|
||||||
*/
|
|
||||||
@PostMapping("/add")
|
|
||||||
public AjaxResult add(@RequestBody OrderTrade orderTrade)
|
|
||||||
{
|
|
||||||
// 获取当前用户
|
|
||||||
Long userId = SecurityUtils.getUserId();
|
|
||||||
if (userId == null) {
|
|
||||||
return AjaxResult.warn("用户未登录");
|
|
||||||
}
|
|
||||||
orderTrade.setUserId(userId);
|
|
||||||
orderTrade.setCreateBy(getUsername());
|
|
||||||
return toAjax(orderTradeService.insertMallProduct(orderTrade));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改
|
|
||||||
*/
|
|
||||||
@PostMapping("/upda")
|
|
||||||
public AjaxResult upda(@RequestBody OrderTrade orderTrade)
|
|
||||||
{
|
|
||||||
// 获取当前用户
|
|
||||||
Long userId = SecurityUtils.getUserId();
|
|
||||||
if (userId == null) {
|
|
||||||
return AjaxResult.warn("用户未登录");
|
|
||||||
}
|
|
||||||
orderTrade.setUserId(userId);
|
|
||||||
orderTrade.setUpdateBy(getUsername());
|
|
||||||
return toAjax(orderTradeService.updateMallProduct(orderTrade));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除
|
|
||||||
*/
|
|
||||||
@PostMapping
|
|
||||||
public AjaxResult remove(@RequestBody IdsParam ids)
|
|
||||||
{
|
|
||||||
orderTradeService.deleteMallProductByIds(ids);
|
|
||||||
return success();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 支付接口
|
|
||||||
*
|
|
||||||
* @param tradeEntity 订单实体
|
|
||||||
* @param response 响应
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
|
||||||
@NoLogin
|
|
||||||
@PostMapping("/doPay")
|
|
||||||
public void doPay(@RequestBody OrderTrade tradeEntity, HttpServletResponse response) throws Exception {
|
|
||||||
String qrUrl = aliPayIntegration.pay(tradeEntity);
|
|
||||||
QrCodeUtil.generate(qrUrl, 300, 300, "png", response.getOutputStream());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,37 +0,0 @@
|
||||||
package com.mcwl.web.controller.rabbitmq.config;
|
|
||||||
|
|
||||||
import com.alipay.easysdk.kernel.Config;
|
|
||||||
import com.mcwl.common.config.BusinessConfig;
|
|
||||||
import com.mcwl.common.domain.AliPayProperties;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Author:ChenYan
|
|
||||||
* @Project:McWl
|
|
||||||
* @Package:com.mcwl.common.config
|
|
||||||
* @Filename:AliPayConfig
|
|
||||||
* @Description 支付宝配置
|
|
||||||
* @Date:2025/1/3 18:45
|
|
||||||
*/
|
|
||||||
@Configuration
|
|
||||||
public class AliPayConfig {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private BusinessConfig businessConfig;
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public Config config() {
|
|
||||||
AliPayProperties aliPayConfig = businessConfig.getAliPayConfig();
|
|
||||||
Config config = new Config();
|
|
||||||
config.protocol = aliPayConfig.getProtocol();
|
|
||||||
config.gatewayHost = aliPayConfig.getGatewayHost();
|
|
||||||
config.signType = aliPayConfig.getSignType();
|
|
||||||
config.appId = aliPayConfig.getAppId();
|
|
||||||
config.merchantPrivateKey = aliPayConfig.getPrivateKey();
|
|
||||||
config.alipayPublicKey = aliPayConfig.getPublicKey();
|
|
||||||
config.notifyUrl = aliPayConfig.getNotifyUrl();
|
|
||||||
return config;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -6,11 +6,9 @@ import com.mcwl.common.core.domain.AjaxResult;
|
||||||
import com.mcwl.common.core.page.TableDataInfo;
|
import com.mcwl.common.core.page.TableDataInfo;
|
||||||
import com.mcwl.common.domain.IdsParam;
|
import com.mcwl.common.domain.IdsParam;
|
||||||
import com.mcwl.resource.domain.MallProduct;
|
import com.mcwl.resource.domain.MallProduct;
|
||||||
import com.mcwl.resource.domain.vo.MallProductVo;
|
|
||||||
import com.mcwl.resource.service.MallProductService;
|
import com.mcwl.resource.service.MallProductService;
|
||||||
import com.mcwl.web.controller.common.OssUtil;
|
import com.mcwl.resource.domain.vo.MallProductVo;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -37,51 +35,6 @@ public class MallProductController extends BaseController {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/***
|
|
||||||
*
|
|
||||||
* 图片
|
|
||||||
* @param file
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@PostMapping("/file")
|
|
||||||
public AjaxResult Malifile(@RequestParam MultipartFile file){
|
|
||||||
|
|
||||||
String s = OssUtil.uploadMultipartFile(file);
|
|
||||||
return AjaxResult.success(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/***
|
|
||||||
*
|
|
||||||
* zip
|
|
||||||
* @param file
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@PostMapping("/zipUrlFile")
|
|
||||||
public AjaxResult zipUrlFile(@RequestParam MultipartFile file){
|
|
||||||
String s = OssUtil.uploadMultipartFile(file);
|
|
||||||
return AjaxResult.success(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/***
|
|
||||||
*
|
|
||||||
* 下载zip
|
|
||||||
* @param file
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@PostMapping("/zipUrl")
|
|
||||||
public AjaxResult zipUrl(@RequestParam MultipartFile file){
|
|
||||||
String s = OssUtil.uploadMultipartFile(file);
|
|
||||||
return AjaxResult.success(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询商品列表
|
* 查询商品列表
|
||||||
*/
|
*/
|
||||||
|
@ -97,14 +50,12 @@ public class MallProductController extends BaseController {
|
||||||
/**
|
/**
|
||||||
* 获取详细信息
|
* 获取详细信息
|
||||||
*/
|
*/
|
||||||
@GetMapping(value = "/{id}")
|
@GetMapping(value = "/{jobId}")
|
||||||
public AjaxResult getInfo(@PathVariable("id") Long jobId)
|
public AjaxResult getInfo(@PathVariable("jobId") Long jobId)
|
||||||
{
|
{
|
||||||
return success(mallProductRuleInfoService.selectMallProductById(jobId));
|
return success(mallProductRuleInfoService.selectMallProductById(jobId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增
|
* 新增
|
||||||
*/
|
*/
|
||||||
|
@ -127,7 +78,7 @@ public class MallProductController extends BaseController {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除
|
* 删除定
|
||||||
*/
|
*/
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public AjaxResult remove(@RequestBody IdsParam ids)
|
public AjaxResult remove(@RequestBody IdsParam ids)
|
||||||
|
|
|
@ -1,25 +0,0 @@
|
||||||
package com.mcwl.web.core.config;
|
|
||||||
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import org.springframework.web.cors.CorsConfiguration;
|
|
||||||
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
|
|
||||||
import org.springframework.web.filter.CorsFilter;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 跨域配置
|
|
||||||
*/
|
|
||||||
@Configuration
|
|
||||||
public class CorsConfig {
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public CorsFilter corsFilter() {
|
|
||||||
UrlBasedCorsConfigurationSource urlBasedCorsConfigurationSource = new UrlBasedCorsConfigurationSource();
|
|
||||||
CorsConfiguration corsConfiguration = new CorsConfiguration();
|
|
||||||
corsConfiguration.addAllowedOrigin("*");
|
|
||||||
corsConfiguration.addAllowedHeader("*");
|
|
||||||
corsConfiguration.addAllowedMethod("*");
|
|
||||||
urlBasedCorsConfigurationSource.registerCorsConfiguration("/**", corsConfiguration);
|
|
||||||
return new CorsFilter(urlBasedCorsConfigurationSource);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -164,23 +164,14 @@ xss:
|
||||||
# 匹配链接
|
# 匹配链接
|
||||||
urlPatterns: /system/*,/monitor/*,/tool/*
|
urlPatterns: /system/*,/monitor/*,/tool/*
|
||||||
|
|
||||||
# yml版(application.yml)
|
|
||||||
aliyun:
|
|
||||||
oss:
|
|
||||||
bucketName: ybl2112
|
|
||||||
endpoint: oss-cn-beijing.aliyuncs.com
|
|
||||||
accessKeyId: LTAI5tSHZZ8wHJRP8X4r9TXT
|
|
||||||
accessKeySecret: F82IVNx0IGJ3AnP6gSIfcyql1HCXIH
|
|
||||||
policy : https://ybl2112.oss-cn-beijing.aliyuncs.com/
|
|
||||||
|
|
||||||
|
#aliyun-oss
|
||||||
|
# aliyun:
|
||||||
|
# oss:
|
||||||
|
# file:
|
||||||
|
# endPoint: "http://oss-cn-beijing.aliyuncs.com" // 一般不用改,选择自己的地址即可
|
||||||
|
# keyid: "保存的key"
|
||||||
|
# keyecrets: "保存的secret"
|
||||||
|
# #bucket可以在控制台创建,也可以使用java代码创建
|
||||||
|
# bucketname: "实例名称"
|
||||||
|
|
||||||
mall:
|
|
||||||
mgt:
|
|
||||||
aliPayConfig:
|
|
||||||
protocol: https
|
|
||||||
gatewayHost: openapi-sandbox.dl.alipaydev.com
|
|
||||||
signType: RSA2
|
|
||||||
appId: 9021000138607290
|
|
||||||
privateKey: MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCarcUREqQVHIYq4FBuqvcYxOxsuUI3gOphRXcN0k/hIUV7fcfO9ivui99pJihbou9MmC22FM7hzFMHHl4GvZQJuw/GgJlnh9T/SlfS9Awlr0nbzVtXYOd7Os1EM4Jry2PW3zkvaWMvO3DfcYU47bqN8aw+vVBhSVeVhq41zKkH9k8UPw6Ny4WmVUHje84ykf1uBR8AqPxEeDIYD79CGGLtGLECuHoeRsVpGrNmZxwmcen1Bwf8oWiM68+Ein3S/pV69ED6x74+/WDJO71IHUJN+1DclLVXWVGriUenUzTVrAhh8RHgtF5J+t4K24qrGpbsryXzuYJ/p872ieI2oFnLAgMBAAECggEAVfbziiyJAq6qplOqgAcGcz6mgzpm4cAFAvB/XTAgcudx3VMnZA+OlPIpxR+O2Hbydegxp3tjCzzqfA9VhHuCNfI/rzuzhkWIjCV+L+Cwi5UjAETeWe6iV+tzP089UbllEHtZJc91bz+i2JwXxW7h+pdw+iFu9dK0GYcTdRT8cE6FVkBtRikUMA/bAQ4f5umF/vv5yx2XsyfCJddyI2eKIOQQ3FZ27/EEvj+hkWFGj+hcTO0zchCzYudaUyhVanJfPOTMeQrh5J9d13HXQYH0qPT4NYrLSXPjl04zAhWyZQw50kFMpkYnog0i9E9XWESSBXilALd2hITmRAj8MPqi8QKBgQDmJ4P5Fa88nvBoPvpjkevcoOP7EzokvsJuw9QHwr7mKwY5/uTrDkHmgy0iIQJ7BQmYOTW+CcwAcaquQwZrdauxsto5sG+Vle62e9FIGxqsCqrzqRS3bKY2NHUS33Ep43lA9Uz07wYchFHs17e4rTidotaWd+ONhGu2zi44vXZOMwKBgQCsDHr1fDoKplRnJ9Na+YkkpG86lGvHW8R/69dn4ur89mCGhFyexLrSA1NggAMYT9pADg4G2jYvsPa+0ynV4rg8fmvfgpO9dvv3UoOGBxxdzaxNlIdb5LsuyQMN6wcWNSQFH9qDt9nyZ5BLCQXd/DJLMtgLSBpAYi+HZD1E4Zv+CQKBgQCaDZslr+ES56QtcvIwkazZigvvtCf4DoOglo2nADC9adEKItZhi7KKtAUS0huR8oZAkRKq+G3HYk4HxK9YYHQjRn8RnEqkSq51ER29cP8CZ0WUQPmv6Ra8M5KlplBd5Hf2BfuT+yYREnSv3piIEdJSmXufTfJPeHKM8yc3LYIxxwKBgFnjK1qWTLzDqdU7OXGObdh3EKXKZYUCrOcokKH2LE99aXDeNoW8wt52XllMiFFrZtuQfEOYPjcsfb21FWZpzVfNtQ5Ral7Si1HsCks769YWXq8pqo6YMjN/UdkzscAog2kp+0BWDchX00tgq3APEze2mKlMQmrg4XQbKueR964BAoGBAMA5mWyKVfphQ2SsOrYSF5hQ7PBaTT/gLLU2CWBcCXge4oO7dd3MIsd2+7cJG9uYPiSgJdLGqmVfet4pBXNd4znYjHunRr6BukTZzQSNujn0j2fr3SDN46vuqVjYsPF05hGWy3XH5NflrTHq7RO6qkqcqxdaSCRZO7a9G+ckzvx/
|
|
||||||
publicKey: MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAjehzFgsbjUfksMRBGsYGi/ycg5/SMP8jmGMbRWbiVmDVKO8GdVI0StLZvfLi8ozUPcGrJzQL3HaXx+b88JXQPJ2ftUiBvQnoAf+qzWKqsqXo40uuy6DZc+0LAGoxup2WyFp4YcIf+XFMJBSGmQaGSqYs3Lx49/aWI1uFTzBL4YF4X7ckXm6Cl2xr5gD1Gl1twbKIyeDnAZal2Eego4pLwFkcP6jZFaAY0V3YqTfhZLAl5NK+K4BCB2iQPOiK6Qr5XMRhnUVQVeZr5T9PmYf1GyncBIWgUaZlmGNq6Yup2trQW/mEqDqzeek4N3NuoORdZ2JBAnLdqAjQyRBrQAnkbQIDAQAA
|
|
||||||
notifyUrl: http://susan.net.cn/notify
|
|
||||||
|
|
|
@ -17,17 +17,11 @@
|
||||||
</description>
|
</description>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
<!--OSS-->
|
<!--OSS-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.aliyun.oss</groupId>
|
<groupId>com.aliyun.oss</groupId>
|
||||||
<artifactId>aliyun-sdk-oss</artifactId>
|
<artifactId>aliyun-sdk-oss</artifactId>
|
||||||
<version>3.17.4</version>
|
<version>3.17.1</version>
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.google.zxing</groupId>
|
|
||||||
<artifactId>core</artifactId>
|
|
||||||
<version>3.4.1</version>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>commons-fileupload</groupId>
|
<groupId>commons-fileupload</groupId>
|
||||||
|
@ -50,32 +44,13 @@
|
||||||
<artifactId>fastdfs-client</artifactId>
|
<artifactId>fastdfs-client</artifactId>
|
||||||
<version>1.26.5</version>
|
<version>1.26.5</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>javax.xml.bind</groupId>
|
|
||||||
<artifactId>jaxb-api</artifactId>
|
|
||||||
<version>2.3.1</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>javax.activation</groupId>
|
|
||||||
<artifactId>activation</artifactId>
|
|
||||||
<version>1.1.1</version>
|
|
||||||
</dependency>
|
|
||||||
<!-- no more than 2.3.3-->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.glassfish.jaxb</groupId>
|
|
||||||
<artifactId>jaxb-runtime</artifactId>
|
|
||||||
<version>2.3.3</version>
|
|
||||||
</dependency>
|
|
||||||
<!-- quartz定时任务-->
|
<!-- quartz定时任务-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-quartz</artifactId>
|
<artifactId>spring-boot-starter-quartz</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>com.aliyun.oss</groupId>
|
|
||||||
<artifactId>aliyun-sdk-oss</artifactId>
|
|
||||||
<version>3.17.4</version>
|
|
||||||
</dependency>
|
|
||||||
<!-- SpringWeb模块 -->
|
<!-- SpringWeb模块 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework</groupId>
|
<groupId>org.springframework</groupId>
|
||||||
|
|
|
@ -1,38 +0,0 @@
|
||||||
package com.mcwl.common.config;
|
|
||||||
|
|
||||||
import com.mcwl.common.config.properties.QuartzThreadPoolProperties;
|
|
||||||
import com.mcwl.common.domain.AliPayProperties;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Author:ChenYan
|
|
||||||
* @Project:McWl
|
|
||||||
* @Package:com.mcwl.common.config
|
|
||||||
* @Filename:BusinessConfig
|
|
||||||
* @Description TODO
|
|
||||||
* @Date:2025/1/3 18:46
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@Component
|
|
||||||
@Slf4j
|
|
||||||
@ConfigurationProperties(prefix = "mall.mgt")
|
|
||||||
public class BusinessConfig {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 动态定时任务线程池配置
|
|
||||||
*/
|
|
||||||
private QuartzThreadPoolProperties QuartzThreadPoolConfig = new QuartzThreadPoolProperties();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 商品搜索index名称
|
|
||||||
*/
|
|
||||||
private String productEsIndexName = "product-es-index-v1";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 支付宝支付相关配置
|
|
||||||
*/
|
|
||||||
private AliPayProperties aliPayConfig = new AliPayProperties();
|
|
||||||
}
|
|
|
@ -1,34 +0,0 @@
|
||||||
package com.mcwl.common.config.properties;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public class QuartzThreadPoolProperties {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 核心线程数
|
|
||||||
*/
|
|
||||||
private int corePoolSize = 8;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 最大线程数
|
|
||||||
*/
|
|
||||||
private int maxPoolSize = 10;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 队列大小
|
|
||||||
*/
|
|
||||||
private int queueSize = 200;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 空闲线程回收时间,多少秒
|
|
||||||
*/
|
|
||||||
private int keepAliveSeconds = 30;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 线程前缀
|
|
||||||
*/
|
|
||||||
private String threadNamePrefix = "QuartzThread";
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,23 +0,0 @@
|
||||||
package com.mcwl.common.domain;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Author:ChenYan
|
|
||||||
* @Project:McWl
|
|
||||||
* @Package:com.mcwl.common.domain
|
|
||||||
* @Filename:AliPayProperties
|
|
||||||
* @Description 支付宝支付配置
|
|
||||||
* @Date:2025/1/3 18:45
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public class AliPayProperties {
|
|
||||||
|
|
||||||
private String protocol;
|
|
||||||
private String gatewayHost;
|
|
||||||
private String signType;
|
|
||||||
private String appId;
|
|
||||||
private String privateKey;
|
|
||||||
private String publicKey;
|
|
||||||
private String notifyUrl;
|
|
||||||
}
|
|
|
@ -1,16 +0,0 @@
|
||||||
package com.mcwl.common.interfaces;
|
|
||||||
|
|
||||||
import java.lang.annotation.ElementType;
|
|
||||||
import java.lang.annotation.Retention;
|
|
||||||
import java.lang.annotation.RetentionPolicy;
|
|
||||||
import java.lang.annotation.Target;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 无需登录注解
|
|
||||||
*
|
|
||||||
* @author 陈妍
|
|
||||||
*/
|
|
||||||
@Target(ElementType.METHOD)
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
|
||||||
public @interface NoLogin {
|
|
||||||
}
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2018-2999 广州市蓝海创新科技有限公司 All rights reserved.
|
||||||
|
*
|
||||||
|
* https://www.mall4j.com/
|
||||||
|
*
|
||||||
|
* 未经允许,不可做商业用途!
|
||||||
|
*
|
||||||
|
* 版权所有,侵权必究!
|
||||||
|
*/
|
||||||
|
package com.mcwl.common.utils;
|
||||||
|
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 对象转换工具类
|
||||||
|
*/
|
||||||
|
public class BeanUtil {
|
||||||
|
public static <S, D> List<D> mapAsList(final Iterable<S> sourceObject, Class<D> clazz) {
|
||||||
|
return JSONObject.parseArray(JSONObject.toJSONString(sourceObject), clazz);
|
||||||
|
}
|
||||||
|
public static <S, D> D map(final S sourceObject, Class<D> clazz) {
|
||||||
|
return JSONObject.parseObject(JSONObject.toJSONString(sourceObject), clazz);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,153 +0,0 @@
|
||||||
package com.mcwl.common.utils.oss;
|
|
||||||
|
|
||||||
import com.aliyun.oss.OSS;
|
|
||||||
import com.aliyun.oss.OSSClientBuilder;
|
|
||||||
import com.aliyun.oss.model.GetObjectRequest;
|
|
||||||
import com.aliyun.oss.model.PutObjectRequest;
|
|
||||||
import lombok.extern.log4j.Log4j2;
|
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
|
||||||
|
|
||||||
import java.io.*;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Oss服务调用
|
|
||||||
*/
|
|
||||||
@Log4j2
|
|
||||||
public class OssUtil {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Endpoint 存储对象概述 阿里云主账号AccessKey,accessKeySecret拥有所有API的访问权限 访问路径前缀 存储对象概述
|
|
||||||
*/
|
|
||||||
private static String endPoint = "oss-cn-beijing.aliyuncs.com";
|
|
||||||
private static String accessKeyId = "LTAI5tSHZZ8wHJRP8X4r9TXT";
|
|
||||||
private static String accessKeySecret = "F82IVNx0IGJ3AnP6gSIfcyql1HCXIH";
|
|
||||||
private static String accessPre = "https://ybl2112.oss-cn-beijing.aliyuncs.com/";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* bucket名称
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private static String bucketName = "ylb2112";
|
|
||||||
|
|
||||||
private static OSS ossClient ;
|
|
||||||
|
|
||||||
static {
|
|
||||||
ossClient = new OSSClientBuilder().build(
|
|
||||||
endPoint,
|
|
||||||
accessKeyId,
|
|
||||||
accessKeySecret);
|
|
||||||
log.info("oss服务连接成功!");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 默认路径上传本地文件
|
|
||||||
* @param filePath
|
|
||||||
*/
|
|
||||||
public static String uploadFile(String filePath){
|
|
||||||
return uploadFileForBucket(bucketName,getOssFilePath(filePath) ,filePath);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 默认路径上传multipartFile文件
|
|
||||||
* @param multipartFile
|
|
||||||
*/
|
|
||||||
public static String uploadMultipartFile(MultipartFile multipartFile) {
|
|
||||||
return uploadMultipartFile(bucketName,getOssFilePath(multipartFile.getOriginalFilename()),multipartFile);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* 上传 multipartFile 类型文件
|
|
||||||
* @param bucketName
|
|
||||||
* @param ossPath
|
|
||||||
* @param multipartFile
|
|
||||||
*/
|
|
||||||
public static String uploadMultipartFile(String bucketName , String ossPath , MultipartFile multipartFile){
|
|
||||||
InputStream inputStream = null;
|
|
||||||
try {
|
|
||||||
inputStream = multipartFile.getInputStream();
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
uploadFileInputStreamForBucket(bucketName, ossPath, inputStream);
|
|
||||||
return accessPre+ossPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 使用File上传PutObject上传文件 ** 程序默认使用次方法上传
|
|
||||||
* @param bucketName 实例名称
|
|
||||||
* @param ossPath oss存储路径
|
|
||||||
* @param filePath 本地文件路径
|
|
||||||
*/
|
|
||||||
public static String uploadFileForBucket(String bucketName , String ossPath , String filePath) {
|
|
||||||
// 创建PutObjectRequest对象。
|
|
||||||
PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, ossPath, new File(filePath));
|
|
||||||
|
|
||||||
// 上传
|
|
||||||
ossClient.putObject(putObjectRequest);
|
|
||||||
return accessPre+ossPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 使用文件流上传到指定的bucket实例
|
|
||||||
* @param bucketName 实例名称
|
|
||||||
* @param ossPath oss存储路径
|
|
||||||
* @param filePath 本地文件路径
|
|
||||||
*/
|
|
||||||
public static String uploadFileInputStreamForBucket(String bucketName , String ossPath , String filePath){
|
|
||||||
|
|
||||||
// 填写本地文件的完整路径。如果未指定本地路径,则默认从示例程序所属项目对应本地路径中上传文件流。
|
|
||||||
InputStream inputStream = null;
|
|
||||||
try {
|
|
||||||
inputStream = new FileInputStream(filePath);
|
|
||||||
} catch (FileNotFoundException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
// 填写Bucket名称和Object完整路径。Object完整路径中不能包含Bucket名称。
|
|
||||||
uploadFileInputStreamForBucket(bucketName, ossPath, inputStream);
|
|
||||||
return accessPre+ossPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void uploadFileInputStreamForBucket(String bucketName , String ossPath , InputStream inputStream ){
|
|
||||||
ossClient.putObject(bucketName, ossPath, inputStream);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 下载
|
|
||||||
* @param ossFilePath
|
|
||||||
* @param filePath
|
|
||||||
*/
|
|
||||||
public static void downloadFile(String ossFilePath , String filePath ){
|
|
||||||
downloadFileForBucket(bucketName , ossFilePath , filePath);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* 下载
|
|
||||||
* @param bucketName 实例名称
|
|
||||||
* @param ossFilePath oss存储路径
|
|
||||||
* @param filePath 本地文件路径
|
|
||||||
*/
|
|
||||||
public static void downloadFileForBucket(String bucketName , String ossFilePath , String filePath ){
|
|
||||||
ossClient.getObject(new GetObjectRequest(bucketName, ossFilePath), new File(filePath));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static String getOssDefaultPath(){
|
|
||||||
LocalDateTime now = LocalDateTime.now();
|
|
||||||
String url =
|
|
||||||
now.getYear()+"/"+
|
|
||||||
now.getMonth()+"/"+
|
|
||||||
now.getDayOfMonth()+"/"+
|
|
||||||
now.getHour()+"/"+
|
|
||||||
now.getMinute()+"/";
|
|
||||||
return url;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getOssFilePath(String filePath){
|
|
||||||
String fileSuf = filePath.substring(filePath.indexOf(".") + 1);
|
|
||||||
return getOssDefaultPath() + UUID.randomUUID().toString() + "." + fileSuf;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,37 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
<parent>
|
|
||||||
<groupId>com.mcwl</groupId>
|
|
||||||
<artifactId>mcwl</artifactId>
|
|
||||||
<version>3.8.8</version>
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
<artifactId>mcwl-pay</artifactId>
|
|
||||||
|
|
||||||
<properties>
|
|
||||||
<maven.compiler.source>8</maven.compiler.source>
|
|
||||||
<maven.compiler.target>8</maven.compiler.target>
|
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
|
||||||
</properties>
|
|
||||||
<description>
|
|
||||||
pay支付模块
|
|
||||||
</description>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<!-- 通用工具-->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.mcwl</groupId>
|
|
||||||
<artifactId>mcwl-common</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.baomidou</groupId>
|
|
||||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
|
||||||
<version>${mybatis-plus.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
</dependencies>
|
|
||||||
</project>
|
|
|
@ -1,94 +0,0 @@
|
||||||
package com.mcwl.pay.domain;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
|
||||||
import com.mcwl.common.core.domain.BaseEntity;
|
|
||||||
import com.mcwl.common.interfaces.MaxMoney;
|
|
||||||
import com.mcwl.common.interfaces.MinMoney;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import org.springframework.format.annotation.DateTimeFormat;
|
|
||||||
|
|
||||||
import javax.validation.constraints.NotNull;
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Author:ChenYan
|
|
||||||
* @Project:McWl
|
|
||||||
* @Package:com.mcwl.pay.domain
|
|
||||||
* @Filename:OrderTrade
|
|
||||||
* @Description TODO
|
|
||||||
* @Date:2025/1/3 14:15
|
|
||||||
*/
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
@Data
|
|
||||||
@TableName("order_trade")
|
|
||||||
public class OrderTrade extends BaseEntity {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ID
|
|
||||||
*/
|
|
||||||
@TableId
|
|
||||||
private Long id;
|
|
||||||
/**
|
|
||||||
* 订单编码
|
|
||||||
*/
|
|
||||||
private String code;
|
|
||||||
/**
|
|
||||||
* 用户ID
|
|
||||||
*/
|
|
||||||
private Long userId;
|
|
||||||
/**
|
|
||||||
* 商品ID
|
|
||||||
*/
|
|
||||||
private Integer productId;
|
|
||||||
/**
|
|
||||||
* 商品名称
|
|
||||||
*/
|
|
||||||
private String productName;
|
|
||||||
/**
|
|
||||||
* 用户名称
|
|
||||||
*/
|
|
||||||
private String userName;
|
|
||||||
/**
|
|
||||||
* 支付方式第三方支付平台返回的交易流水号
|
|
||||||
*/
|
|
||||||
private String paymentMethod;
|
|
||||||
/**
|
|
||||||
* 支付方式
|
|
||||||
*/
|
|
||||||
private Integer transactionId;
|
|
||||||
/**
|
|
||||||
* 下单时间
|
|
||||||
*/
|
|
||||||
@JsonFormat(pattern = "yyyy-mm-dd")
|
|
||||||
@DateTimeFormat(pattern = "yyyy-mm-dd")
|
|
||||||
private Date orderTime;
|
|
||||||
/**
|
|
||||||
* 订单状态 1:下单 2:支付 3:完成 4:取消
|
|
||||||
*/
|
|
||||||
@NotNull(message = "状态不能为空")
|
|
||||||
private Integer orderStatus;
|
|
||||||
/**
|
|
||||||
* 支付状态 1:待支付 2:已支付 3:退款
|
|
||||||
*/
|
|
||||||
@NotNull(message = "状态不能为空")
|
|
||||||
private Integer payStatus;
|
|
||||||
/**
|
|
||||||
* 总金额
|
|
||||||
*/
|
|
||||||
@NotNull(message = "总金额不能为空")
|
|
||||||
@MinMoney(value = 0, message = "总金额不能小于0")
|
|
||||||
@MaxMoney(value = 100000, message = "总金额必须小于100000")
|
|
||||||
private Integer totalAmount;
|
|
||||||
/**
|
|
||||||
* 付款金额
|
|
||||||
*/
|
|
||||||
@NotNull(message = "付款金额不能为空")
|
|
||||||
@MinMoney(value = 0, message = "付款金额不能小于0")
|
|
||||||
@MaxMoney(value = 100000, message = "付款金额必须小于100000")
|
|
||||||
private Integer paymentAmount;
|
|
||||||
}
|
|
|
@ -1,102 +0,0 @@
|
||||||
package com.mcwl.pay.domain;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import org.springframework.format.annotation.DateTimeFormat;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Author:ChenYan
|
|
||||||
* @Project:McWl
|
|
||||||
* @Package:com.mcwl.pay.domain
|
|
||||||
* @Filename:PaymentResult
|
|
||||||
* @Description TODO
|
|
||||||
* @Date:2025/1/3 17:30
|
|
||||||
*/
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
@Data
|
|
||||||
public class PaymentResult {
|
|
||||||
private boolean success;
|
|
||||||
private String message;
|
|
||||||
private String transactionId;
|
|
||||||
private String errorCode;
|
|
||||||
private BigDecimal amount;
|
|
||||||
private String currency;
|
|
||||||
private String paymentMethod;
|
|
||||||
private LocalDateTime timestamp;
|
|
||||||
private Map<String, Object> extraData;
|
|
||||||
|
|
||||||
|
|
||||||
public static class Builder {
|
|
||||||
private final PaymentResult result = new PaymentResult();
|
|
||||||
|
|
||||||
public Builder setSuccess(boolean success) {
|
|
||||||
result.success = success;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder setMessage(String message) {
|
|
||||||
result.message = message;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder setTransactionId(String transactionId) {
|
|
||||||
result.transactionId = transactionId;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder setErrorCode(String errorCode) {
|
|
||||||
result.errorCode = errorCode;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder setAmount(BigDecimal amount) {
|
|
||||||
result.amount = amount;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder setCurrency(String currency) {
|
|
||||||
result.currency = currency;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder setPaymentMethod(String paymentMethod) {
|
|
||||||
result.paymentMethod = paymentMethod;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder setTimestamp(LocalDateTime timestamp) {
|
|
||||||
result.timestamp = timestamp;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder setExtraData(Map<String, Object> extraData) {
|
|
||||||
result.extraData = extraData;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public PaymentResult build() {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "PaymentResult{" +
|
|
||||||
"success=" + success +
|
|
||||||
", message='" + message + '\'' +
|
|
||||||
", transactionId='" + transactionId + '\'' +
|
|
||||||
", errorCode='" + errorCode + '\'' +
|
|
||||||
", amount=" + amount +
|
|
||||||
", currency='" + currency + '\'' +
|
|
||||||
", paymentMethod='" + paymentMethod + '\'' +
|
|
||||||
", timestamp=" + timestamp +
|
|
||||||
", extraData=" + extraData +
|
|
||||||
'}';
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,33 +0,0 @@
|
||||||
package com.mcwl.pay.domain.enums;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Author:ChenYan
|
|
||||||
* @Project:McWl
|
|
||||||
* @Package:com.mcwl.pay.domain
|
|
||||||
* @Filename:PaymentStatus
|
|
||||||
* @Description TODO
|
|
||||||
* @Date:2025/1/3 17:24
|
|
||||||
*/
|
|
||||||
|
|
||||||
public enum PaymentStatus {
|
|
||||||
|
|
||||||
PENDING("待支付"),
|
|
||||||
COMPLETED("已支付"),
|
|
||||||
FAILED("支付失败"),
|
|
||||||
REFUNDED("已退款");
|
|
||||||
|
|
||||||
private final String description;
|
|
||||||
|
|
||||||
PaymentStatus(String description) {
|
|
||||||
this.description = description;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDescription() {
|
|
||||||
return description;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return name() + "(" + description + ")";
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,21 +0,0 @@
|
||||||
package com.mcwl.pay.mapper;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|
||||||
import com.mcwl.pay.domain.OrderTrade;
|
|
||||||
import com.mcwl.pay.domain.PaymentResult;
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Author:ChenYan
|
|
||||||
* @Project:McWl
|
|
||||||
* @Package:com.mcwl.pay.mapper
|
|
||||||
* @Filename:OrderTradeMapper
|
|
||||||
* @Description TODO
|
|
||||||
* @Date:2025/1/3 14:51
|
|
||||||
*/
|
|
||||||
@Mapper
|
|
||||||
public interface OrderTradeMapper extends BaseMapper<OrderTrade> {
|
|
||||||
|
|
||||||
PaymentResult chargeCard(Integer totalAmount, String paymentMethod);
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,28 +0,0 @@
|
||||||
package com.mcwl.pay.service;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
|
||||||
import com.mcwl.common.domain.IdsParam;
|
|
||||||
import com.mcwl.pay.domain.OrderTrade;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Author:ChenYan
|
|
||||||
* @Project:McWl
|
|
||||||
* @Package:com.mcwl.pay.service
|
|
||||||
* @Filename:OrderTradeService
|
|
||||||
* @Description TODO
|
|
||||||
* @Date:2025/1/3 14:51
|
|
||||||
*/
|
|
||||||
public interface OrderTradeService extends IService<OrderTrade> {
|
|
||||||
List<OrderTrade> selectMallProductList(OrderTrade orderTrade);
|
|
||||||
|
|
||||||
int insertMallProduct(OrderTrade orderTrade);
|
|
||||||
|
|
||||||
void deleteMallProductByIds(IdsParam ids);
|
|
||||||
|
|
||||||
int updateMallProduct(OrderTrade orderTrade);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,104 +0,0 @@
|
||||||
package com.mcwl.pay.service.impl;
|
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
||||||
import com.mcwl.common.domain.IdsParam;
|
|
||||||
import com.mcwl.common.utils.StringUtils;
|
|
||||||
import com.mcwl.pay.domain.OrderTrade;
|
|
||||||
import com.mcwl.pay.domain.PaymentResult;
|
|
||||||
import com.mcwl.pay.domain.enums.PaymentStatus;
|
|
||||||
import com.mcwl.pay.mapper.OrderTradeMapper;
|
|
||||||
import com.mcwl.pay.service.OrderTradeService;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Author:ChenYan
|
|
||||||
* @Project:McWl
|
|
||||||
* @Package:com.mcwl.pay.service.impl
|
|
||||||
* @Filename:OrderTradeServiceImpl
|
|
||||||
* @Description TODO
|
|
||||||
* @Date:2025/1/3 14:51
|
|
||||||
*/
|
|
||||||
@Service
|
|
||||||
public class OrderTradeServiceImpl extends ServiceImpl<OrderTradeMapper, OrderTrade> implements OrderTradeService {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private OrderTradeMapper orderTradeMapper;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<OrderTrade> selectMallProductList(OrderTrade orderTrade) {
|
|
||||||
// 创建一个 LambdaQueryWrapper 实例
|
|
||||||
LambdaQueryWrapper<OrderTrade> queryWrapper = new LambdaQueryWrapper<>();
|
|
||||||
|
|
||||||
// 使用非空检查来添加查询条件
|
|
||||||
if (StringUtils.isNotNull(orderTrade.getCode())) {
|
|
||||||
queryWrapper.eq(OrderTrade::getCode, orderTrade.getCode());
|
|
||||||
}
|
|
||||||
if (StringUtils.isNotNull(orderTrade.getUserId())) {
|
|
||||||
queryWrapper.eq(OrderTrade::getUserId, orderTrade.getUserId());
|
|
||||||
}
|
|
||||||
if (StringUtils.isNotNull(orderTrade.getProductId())) {
|
|
||||||
queryWrapper.eq(OrderTrade::getProductId, orderTrade.getProductId());
|
|
||||||
}
|
|
||||||
if (StringUtils.isNotNull(orderTrade.getProductName())) {
|
|
||||||
queryWrapper.like(OrderTrade::getProductName, orderTrade.getProductName());
|
|
||||||
}
|
|
||||||
if (StringUtils.isNotNull(orderTrade.getUserName())) {
|
|
||||||
queryWrapper.eq(OrderTrade::getUserName, orderTrade.getUserName());
|
|
||||||
}
|
|
||||||
if (StringUtils.isNotNull(orderTrade.getOrderTime())) {
|
|
||||||
queryWrapper.eq(OrderTrade::getOrderTime, orderTrade.getOrderTime());
|
|
||||||
}
|
|
||||||
if (StringUtils.isNotNull(orderTrade.getOrderStatus())) {
|
|
||||||
queryWrapper.eq(OrderTrade::getOrderStatus, orderTrade.getOrderStatus());
|
|
||||||
}
|
|
||||||
if (StringUtils.isNotNull(orderTrade.getPayStatus())) {
|
|
||||||
queryWrapper.eq(OrderTrade::getPayStatus, orderTrade.getPayStatus());
|
|
||||||
}
|
|
||||||
if (StringUtils.isNotNull(orderTrade.getTotalAmount())) {
|
|
||||||
queryWrapper.eq(OrderTrade::getTotalAmount, orderTrade.getTotalAmount());
|
|
||||||
}
|
|
||||||
if (StringUtils.isNotNull(orderTrade.getPaymentAmount())) {
|
|
||||||
queryWrapper.eq(OrderTrade::getPaymentAmount, orderTrade.getPaymentAmount());
|
|
||||||
}
|
|
||||||
|
|
||||||
return orderTradeMapper.selectList(queryWrapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int insertMallProduct(OrderTrade orderTrade) {
|
|
||||||
PaymentResult paymentResult = orderTradeMapper.chargeCard(orderTrade.getTotalAmount(), orderTrade.getPaymentMethod());
|
|
||||||
|
|
||||||
if (paymentResult.isSuccess()) {
|
|
||||||
// 支付成功后的处理:更新订单状态、生成激活码、更新用户权限等
|
|
||||||
orderTrade.setOrderStatus(PaymentStatus.COMPLETED.ordinal());
|
|
||||||
|
|
||||||
// 保存订单
|
|
||||||
return orderTradeMapper.insert(orderTrade);
|
|
||||||
} else {
|
|
||||||
// 支付失败处理...
|
|
||||||
orderTrade.setOrderStatus(PaymentStatus.FAILED.ordinal());
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void deleteMallProductByIds(IdsParam ids) {
|
|
||||||
orderTradeMapper.deleteBatchIds(ids.getIds());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int updateMallProduct(OrderTrade orderTrade) {
|
|
||||||
return orderTradeMapper.updateById(orderTrade);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -28,11 +28,11 @@ public class MallProduct extends BaseEntity {
|
||||||
* ID
|
* ID
|
||||||
*/
|
*/
|
||||||
@TableId
|
@TableId
|
||||||
private Long productId;
|
private Integer productId;
|
||||||
/**
|
/**
|
||||||
* 用户ID
|
* 用户ID
|
||||||
*/
|
*/
|
||||||
private Long userId;
|
private Integer userId;
|
||||||
/**
|
/**
|
||||||
* 商品名称
|
* 商品名称
|
||||||
*/
|
*/
|
||||||
|
|
1
pom.xml
1
pom.xml
|
@ -239,7 +239,6 @@
|
||||||
<module>mcwl-myInvitation</module>
|
<module>mcwl-myInvitation</module>
|
||||||
<module>mcwl-resource</module>
|
<module>mcwl-resource</module>
|
||||||
<module>mcwl-memberCenter</module>
|
<module>mcwl-memberCenter</module>
|
||||||
<module>mcwl-pay</module>
|
|
||||||
</modules>
|
</modules>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue