添加购物车,订单
parent
2635487e21
commit
7e32dcf236
|
@ -0,0 +1,23 @@
|
|||
package com.bawei.common.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 模糊查询对象
|
||||
*
|
||||
* @program: mall_cloud
|
||||
* @ClassName: FuzzyQuery
|
||||
* @author: Gyc
|
||||
* @create: 2024-04-28 20:37
|
||||
**/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class FuzzyQuery {
|
||||
//根据多个字段查询
|
||||
private String[] fields;
|
||||
//值
|
||||
private String value;
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package com.bawei.common.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @program: mall_cloud
|
||||
* @ClassName: MultiQuery
|
||||
* @author: Gyc
|
||||
* @create: 2024-04-28 12:27
|
||||
**/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class MultiQuery {
|
||||
|
||||
private String indexName;
|
||||
//模糊查询对象
|
||||
private FuzzyQuery fuzzyQuery;
|
||||
//精确查询对象
|
||||
private PreciseQuery preciseQuery;
|
||||
//区间查询对象
|
||||
private SectionQuery sectionQuery;
|
||||
//排序对象
|
||||
private Sort sort;
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package com.bawei.common.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 精确查询对象
|
||||
*
|
||||
* @program: mall_cloud
|
||||
* @ClassName: PreciseQuery
|
||||
* @author: Gyc
|
||||
* @create: 2024-04-28 20:37
|
||||
**/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class PreciseQuery {
|
||||
//字段
|
||||
private String field;
|
||||
//值
|
||||
private String value;
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package com.bawei.common.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 区间查询对象
|
||||
*
|
||||
* @program: mall_cloud
|
||||
* @ClassName: SectionQuery
|
||||
* @author: Gyc
|
||||
* @create: 2024-04-28 12:21
|
||||
**/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class SectionQuery {
|
||||
//对多个字段进行区间查询
|
||||
private String field;
|
||||
//区间查询的起始值
|
||||
private Object start;
|
||||
//区间查询的结束值
|
||||
private Object end;
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package com.bawei.common.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 排序对象
|
||||
*
|
||||
* @program: mall_cloud
|
||||
* @ClassName: Sort
|
||||
* @author: Gyc
|
||||
* @create: 2024-04-28 20:38
|
||||
**/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class Sort {
|
||||
// 排序字段
|
||||
private Integer pageNum=1;
|
||||
// 每页显示条数
|
||||
private Integer pageSize = 10 ;
|
||||
}
|
|
@ -18,6 +18,12 @@
|
|||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<!--当使用get请求需要携带 body中的参数的时候 需要重写Http 版本号必须是4.3以上版本-->
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
<version>4.5.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.xiaoymin</groupId>
|
||||
<artifactId>knife4j-openapi3-spring-boot-starter</artifactId>
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
package com.bawei.es.config;
|
||||
|
||||
import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
|
||||
import org.apache.http.client.methods.HttpUriRequest;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
public class HttpComponentsClientRestfulHttpRequestFactory extends HttpComponentsClientHttpRequestFactory {
|
||||
@Override
|
||||
protected HttpUriRequest createHttpUriRequest(HttpMethod httpMethod, URI uri) {
|
||||
|
||||
if (httpMethod == HttpMethod.GET) {
|
||||
return new HttpGetRequestWithEntity(uri);
|
||||
}
|
||||
return super.createHttpUriRequest(httpMethod, uri);
|
||||
}
|
||||
|
||||
/**
|
||||
* 定义HttpGetRequestWithEntity实现HttpEntityEnclosingRequestBase抽象类,以支持GET请求携带body数据
|
||||
*/
|
||||
private static final class HttpGetRequestWithEntity extends HttpEntityEnclosingRequestBase {
|
||||
public HttpGetRequestWithEntity(final URI uri) {
|
||||
super.setURI(uri);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMethod() {
|
||||
return HttpMethod.GET.name();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
package com.bawei.es.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.http.client.ClientHttpRequestFactory;
|
||||
import org.springframework.http.client.SimpleClientHttpRequestFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
@Component
|
||||
public class RestTemplateConfig {
|
||||
|
||||
@Bean
|
||||
public RestTemplate restTemplate(){
|
||||
RestTemplate restTemplate = new RestTemplate(clientHttpRequestFactory());
|
||||
//支持http请求get方式以json对象的形式请求
|
||||
restTemplate.setRequestFactory(new HttpComponentsClientRestfulHttpRequestFactory());
|
||||
return restTemplate;
|
||||
}
|
||||
|
||||
// 设置超时时间
|
||||
public ClientHttpRequestFactory clientHttpRequestFactory(){
|
||||
//创建一个httpClient简单工厂
|
||||
SimpleClientHttpRequestFactory factory=new SimpleClientHttpRequestFactory();
|
||||
//设置连接超时时间,单位ms
|
||||
factory.setConnectTimeout(15000);
|
||||
//设置读取超时时间,单位ms
|
||||
factory.setReadTimeout(10000);
|
||||
return factory;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
package com.bawei.es.demo;
|
||||
|
||||
import com.bawei.es.config.RestTemplateConfig;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
* @program: mall_cloud
|
||||
* @ClassName: demo
|
||||
* @author: Gyc
|
||||
* @create: 2024-04-29 12:28
|
||||
**/
|
||||
public class demo {
|
||||
public static void main(String[] args) {
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package com.bawei.es.demo.pojo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @program: mall_cloud
|
||||
* @ClassName: User
|
||||
* @author: Gyc
|
||||
* @create: 2024-05-01 14:08
|
||||
**/
|
||||
@Data
|
||||
public class User {
|
||||
private String name;
|
||||
private Integer age;
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -41,7 +41,11 @@ import java.util.*;
|
|||
public class EsDocServiceImpl implements EsDocService {
|
||||
@Autowired
|
||||
private RestHighLevelClient restHighLevelClient;
|
||||
|
||||
/**
|
||||
* 批量添加文档
|
||||
* @param indexName
|
||||
* @param docMsg
|
||||
*/
|
||||
@Override
|
||||
public void batchAddDoc(String indexName, Map<String, Object> docMsg) {
|
||||
BulkRequest bulkRequest = new BulkRequest();
|
||||
|
@ -62,6 +66,11 @@ public class EsDocServiceImpl implements EsDocService {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
* @param indexName
|
||||
* @param ids
|
||||
*/
|
||||
@Override
|
||||
public void bathDeleteDoc(String indexName, List<String> ids) {
|
||||
BulkRequest bulkRequest = new BulkRequest();
|
||||
|
@ -83,6 +92,12 @@ public class EsDocServiceImpl implements EsDocService {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* 搜索
|
||||
* @param indexName
|
||||
* @param docMsg
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public R queryList(String indexName, Map<String, Object> docMsg) {
|
||||
// 验证索引名称
|
||||
|
@ -103,6 +118,11 @@ public class EsDocServiceImpl implements EsDocService {
|
|||
return R.ok(response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 搜索请求
|
||||
* @param searchResponse
|
||||
* @return
|
||||
*/
|
||||
private ConmtMap processSearchResponse(SearchResponse searchResponse) {
|
||||
ConmtMap conmtMap = new ConmtMap();
|
||||
long total = searchResponse.getHits().getTotalHits().value;
|
||||
|
@ -124,6 +144,11 @@ public class EsDocServiceImpl implements EsDocService {
|
|||
return conmtMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 高亮请求
|
||||
* @param highlightFields
|
||||
* @param parsedObject
|
||||
*/
|
||||
private void addHighlightedFields(Map<String, HighlightField> highlightFields, Map<String, Object> parsedObject) {
|
||||
if (!highlightFields.isEmpty()) {
|
||||
for (Map.Entry<String, HighlightField> entry : highlightFields.entrySet()) {
|
||||
|
@ -151,7 +176,8 @@ public class EsDocServiceImpl implements EsDocService {
|
|||
|
||||
// 设置排序参数
|
||||
setSortParameters(docMsg,sourceBuilder);
|
||||
|
||||
//精确查找
|
||||
setFuzzyParameters(docMsg,sourceBuilder);
|
||||
// 设置高亮参数
|
||||
setHighlightParameters(docMsg,sourceBuilder);
|
||||
|
||||
|
@ -162,6 +188,17 @@ public class EsDocServiceImpl implements EsDocService {
|
|||
return request;
|
||||
}
|
||||
|
||||
private void setFuzzyParameters(Map<String, Object> docMsg, SearchSourceBuilder sourceBuilder) {
|
||||
|
||||
Map<String, Object> fuzzy = (Map<String, Object>) docMsg.get("fuzzy");
|
||||
if (fuzzy!=null){
|
||||
BoolQueryBuilder boolQueryBuilder = new BoolQueryBuilder();
|
||||
boolQueryBuilder.must(QueryBuilders.termQuery((String) fuzzy.get("field"),(String) fuzzy.get("value")));
|
||||
sourceBuilder.query(boolQueryBuilder);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void setHighlightParameters(Map<String, Object> docMsg, SearchSourceBuilder sourceBuilder) {
|
||||
// 获取高亮参数
|
||||
Map<String,Object> highlight = (Map<String, Object>) docMsg.get("highlight");
|
||||
|
|
|
@ -51,11 +51,3 @@ feign:
|
|||
min-request-size: 8192
|
||||
response:
|
||||
enabled: true
|
||||
# feign 配置
|
||||
feign:
|
||||
compression:
|
||||
request:
|
||||
enabled: true
|
||||
min-request-size: 8192
|
||||
response:
|
||||
enabled: true
|
||||
|
|
|
@ -8,6 +8,7 @@ import com.bawei.common.core.context.SecurityContextHolder;
|
|||
import com.bawei.common.core.utils.ServletUtils;
|
||||
import com.bawei.common.core.utils.StringUtils;
|
||||
import com.bawei.system.domain.model.LoginUser;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 权限获取工具类
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
<?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.bawei</groupId>
|
||||
<artifactId>bawei-mall-car</artifactId>
|
||||
<version>3.6.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>bawei-mall-car-common</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<!-- 项目公共核心依赖 -->
|
||||
<dependency>
|
||||
<groupId>com.bawei</groupId>
|
||||
<artifactId>bawei-common-core</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,47 @@
|
|||
package com.bawei.mall.car.config;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author GYC
|
||||
*/ /* *
|
||||
*类名:AlipayConfig
|
||||
*功能:基础配置类
|
||||
*详细:设置帐户有关信息及返回路径
|
||||
*修改日期:2017-04-05
|
||||
*说明:
|
||||
*以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己网站的需要,按照技术文档编写,并非一定要使用该代码。
|
||||
*该代码仅供学习和研究支付宝接口使用,只是提供一个参考。
|
||||
*/
|
||||
public class AlipayConfig {
|
||||
|
||||
//↓↓↓↓↓↓↓↓↓↓请在这里配置您的基本信息↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
|
||||
|
||||
// 应用ID,您的APPID,收款账号既是您的APPID对应支付宝账号
|
||||
public static String app_id = "9021000136694024";
|
||||
|
||||
// 商户私钥,您的PKCS8格式RSA2私钥
|
||||
public static String merchant_private_key = "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCFz/238QvZGbGw9EXAihMzA/wBLprkwCZN2PlZAWBJRI28L+rO8xAtgeC6AVarRGF6e0qMZ4LLWtOgL1RyfxOL2I/Ny+F8jmY0wEZABt6WKI1/l9HliZ/hxNoko4IHo6tf7NEhZJMmAce088PB3IVmFWv1aaSOL7/WaZlSiz/80ZA2v7oHzntblVm1FHFok7kCumndzdj8SgaPtZRA964lx3zhQHWV2O22ThhqN6zksJzXsQoPFvIv8Ic5ymYPzCvnSs7U5jyHMwQ1btYXgUMbv1Uqo9It2U0Gq3P4rZFMjfPn5FSdLaWepTpSg69Ittqo3YCzBmlKZjVmBc5W9thHAgMBAAECggEAF3AJ2akP0TPt6reua/4DROFCx5Y5LS32x5XkftF94vdt9/NQpnTudXoVOZ84ZgExLbngod0TjLjY7mq72N4nN0x0S7CVSzLJ9h1jcJ2DaTurJRkbe5/ycCIBr38wLFRflQquyrGKEJMpPqmftRoCB5Ji+XZKi1kTueN/JnUbfRWavAagK6YK8qlZYAiQr+PXiLcF2U3qcB7BgqVb7BJU5g/IiotHE+0ijtqWcT+X9ElIqw5mgmkvRZBPy5iVeD/b2F5b4Mbr9MvQkaICzt+P8QZCTKyd31GOhSV6zYguaisN16uC5DKRNZ4d1nbWOSR5ifCu1FH8t1cGy+OstVFzIQKBgQDFP9ZKc1wo5U/+zL8Bz9JteWEs1X6NzHu9yF62pgHg6G8L+YnQhFUtR8yQ1f782Fkdsl6YyXv89PXAcYHQJJax5JK2ONQD+tb6BUhOt2kq1d2ZJhX4nDeUJfpsKuaXnbsRc5A9D/HmUlZvsAxZoZ367WOi6WudP6DwDlG0g58xlwKBgQCtqx99lENuTQ0K8qNuSwWvQb+APf6zlGdqT7G1rQTPtNJ79ZyECQNUC9FzsIstQIWvLQO6PzYpa/aTZst44sWFPtyqTY0+ECUO5/KC/Ap5AROuy1/rMEaUQ93hT54TTLVm0g3fwnUCOJX9iUXJk63gxXCdyCi+8ZkLNEcwWa8E0QKBgBNJUqKk9PXqtg+r5WE/+MtLevzvQxiKTe8YkGo7gSOElpcNJzSEO+/ZfV8MDYqbfNsyfZ1i1gS9zumqL48yhKmQN+gpVlGtTSfVLGTF+jp9/tTirHNKkwShUgMRjsp0Wb4zFn9h970Vf+4bwJli/Bd07rEXMbaGai4OuF52IDKxAoGAHeN4jPVKUZ5jI0I1DFNPDCWFnr2Mqz1cOviyPfEkBdc57mmL4VFnyDwsdPuqSER1fXuCy7f7S0+wZRfo5sooclEqSwkDyO2gYxtaKl7UMpUT3R5VSLXLP9MaSZ+ZNfsasTJvftYJqzMv5S2N3C5VW3y/b/g1wv7zdvEtW03kCDECgYEAnY21ReTt6HtLcX4iGAX1PKfGU251b5a2Kw4xcX/oNkzWHeVL9URDmlB93paNLg6QuskeSiwgPmitUGtKWNAfyZnWESAfCZkGza0+aJjni4LbxcnFHJcYMmuWMZxLB6IaOlDPnneKv0DWSydIkotDCDnFz4BPnim962ilILRLnWY=";
|
||||
|
||||
// 支付宝公钥,查看地址:https://openhome.alipay.com/platform/keyManage.htm 对应APPID下的支付宝公钥。
|
||||
public static String alipay_public_key = "";
|
||||
|
||||
// 服务器异步通知页面路径 需http://格式的完整路径,不能加?id=123这类自定义参数,必须外网可以正常访问
|
||||
public static String notify_url = "";
|
||||
|
||||
// 页面跳转同步通知页面路径 需http://格式的完整路径,不能加?id=123这类自定义参数,必须外网可以正常访问
|
||||
public static String return_url = "";
|
||||
|
||||
// 签名方式
|
||||
public static String sign_type = "RSA2";
|
||||
|
||||
// 字符编码格式
|
||||
public static String charset = "utf-8";
|
||||
|
||||
// 支付宝网关
|
||||
public static String gatewayUrl = "https://openapi.alipay.com/gateway.do";
|
||||
|
||||
// 支付宝网关
|
||||
public static String log_path = "C:\\";
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
package com.bawei.mall.car.domain;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @program: mall_cloud
|
||||
* @ClassName: Car
|
||||
* @author: Gyc
|
||||
* @create: 2024-05-06 15:55
|
||||
**/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class Car {
|
||||
@ApiModelProperty(value = "主键")
|
||||
private Integer id;
|
||||
@ApiModelProperty(value = "购物车id")
|
||||
private String carId;
|
||||
@ApiModelProperty(value = "用户id")
|
||||
private Integer userId;
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
package com.bawei.mall.car.domain;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 中间表
|
||||
*
|
||||
* @program: mall_cloud
|
||||
* @ClassName: CarBySku
|
||||
* @author: Gyc
|
||||
* @create: 2024-05-06 15:58
|
||||
**/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class CarBySku {
|
||||
@ApiModelProperty(value = "主键")
|
||||
private Integer id;
|
||||
@ApiModelProperty(value = "购物车id")
|
||||
private String carId;
|
||||
@ApiModelProperty(value = "skuId")
|
||||
private Integer skuId;
|
||||
@ApiModelProperty(value = "数量")
|
||||
private Integer number;
|
||||
@ApiModelProperty(value = "创建人")
|
||||
private Integer createBy;
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private Date createTime;
|
||||
@ApiModelProperty(value = "更新人")
|
||||
private Integer updateBy;
|
||||
@ApiModelProperty(value = "更新时间")
|
||||
private Date updateTime;
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package com.bawei.mall.car.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 购物车
|
||||
*
|
||||
* @program: mall_cloud
|
||||
* @ClassName: MallProductSkuCarInfo
|
||||
* @author: Gyc
|
||||
* @create: 2024-05-08 10:30
|
||||
**/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class MallProductSkuCarInfo {
|
||||
|
||||
private List<ProductSkuInfo> productSkuInfo;
|
||||
|
||||
private ProductPrices productPrices;
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
package com.bawei.mall.car.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 订单表
|
||||
*
|
||||
* @program: mall_cloud
|
||||
* @ClassName: Order
|
||||
* @author: Gyc
|
||||
* @create: 2024-05-10 15:20
|
||||
**/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
public class Order {
|
||||
//主键
|
||||
private Integer id;
|
||||
//skuId
|
||||
private Integer skuId;
|
||||
//订单号
|
||||
private String orderId;
|
||||
//商品名称
|
||||
private String productName;
|
||||
//商品sku名称
|
||||
private String productSku;
|
||||
//商品图片
|
||||
private String productUrl;
|
||||
//商品价格
|
||||
private BigDecimal productPrice;
|
||||
//商品数量
|
||||
private Integer productNum;
|
||||
//购买数量
|
||||
private Integer buyNumber;
|
||||
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
package com.bawei.mall.car.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 订单用户关联表
|
||||
*
|
||||
* @program: mall_cloud
|
||||
* @ClassName: OrderByUser
|
||||
* @author: Gyc
|
||||
* @create: 2024-05-10 19:32
|
||||
**/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
public class OrderByUser {
|
||||
private Integer id;
|
||||
private String orderId;
|
||||
private Integer userId;
|
||||
private Integer discountId;
|
||||
//订单状态 0未支付 1已支付 2已取消 3已退款 4已过期
|
||||
private Integer status;
|
||||
//购买数量
|
||||
private Integer number;
|
||||
//订单创建时间
|
||||
private Date createTime;
|
||||
//订单支付时间
|
||||
private Date payTime;
|
||||
//订单总金额
|
||||
private BigDecimal totalPrice;
|
||||
//订单支付类型
|
||||
private Integer payType;
|
||||
//优惠金额
|
||||
private BigDecimal discountPrice;
|
||||
//订单实际支付金额
|
||||
private BigDecimal payPrice;
|
||||
//支付积分
|
||||
private Integer payIntegral;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
package com.bawei.mall.car.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @program: mall_cloud
|
||||
* @ClassName: OrderByUserInfo
|
||||
* @author: Gyc
|
||||
* @create: 2024-05-10 12:43
|
||||
**/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
public class OrderByUserInfo {
|
||||
private List<Order> orderList;
|
||||
private OrderByUser orderByUser;
|
||||
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package com.bawei.mall.car.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @program: mall_cloud
|
||||
* @ClassName: OrderInfo
|
||||
* @author: Gyc
|
||||
* @create: 2024-05-10 20:03
|
||||
**/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class OrderInfo {
|
||||
//订单编号
|
||||
private Integer orderId;
|
||||
//订单状态
|
||||
private Integer productStatus;
|
||||
//商品信息
|
||||
private ProductSkuInfo productSkuInfo;
|
||||
//订单价格
|
||||
private ProductPrices productPrices;
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package com.bawei.mall.car.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* @program: mall_cloud
|
||||
* @ClassName: ProductPrices
|
||||
* @author: Gyc
|
||||
* @create: 2024-05-08 14:01
|
||||
**/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ProductPrices {
|
||||
//总价格
|
||||
private BigDecimal price;
|
||||
//优惠
|
||||
private BigDecimal specialOffer;
|
||||
//优惠后价格
|
||||
private BigDecimal afterDiscounts;
|
||||
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
package com.bawei.mall.car.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* @program: mall_cloud
|
||||
* @ClassName: ProductSkuInfo
|
||||
* @author: Gyc
|
||||
* @create: 2024-05-08 10:31
|
||||
**/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ProductSkuInfo implements Serializable {
|
||||
//skuId
|
||||
private Long skuId;
|
||||
//购物车编号
|
||||
private String carId;
|
||||
//sku名称
|
||||
private String skuName;
|
||||
//价格
|
||||
private BigDecimal skuPrice;
|
||||
//商品名称
|
||||
private String title;
|
||||
//主图
|
||||
private String image;
|
||||
//商品数量
|
||||
private Integer buyNumber;
|
||||
//购买数量
|
||||
private Integer number;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,109 @@
|
|||
<?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.bawei</groupId>
|
||||
<artifactId>bawei-mall-car</artifactId>
|
||||
<version>3.6.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>bawei-mall-car-server</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>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.alipay.sdk</groupId>
|
||||
<artifactId>alipay-sdk-java</artifactId>
|
||||
<version>4.39.70.ALL</version>
|
||||
</dependency>
|
||||
<!-- SpringCloud Alibaba Nacos -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringCloud Alibaba Nacos Config -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringCloud Alibaba Sentinel -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringBoot Actuator -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Swagger UI -->
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger-ui</artifactId>
|
||||
<version>${swagger.fox.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Mysql Connector -->
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- BaWei Common DataSource -->
|
||||
<dependency>
|
||||
<groupId>com.bawei</groupId>
|
||||
<artifactId>bawei-common-datasource</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- BaWei Common DataScope -->
|
||||
<dependency>
|
||||
<groupId>com.bawei</groupId>
|
||||
<artifactId>bawei-common-datascope</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- BaWei Common Log -->
|
||||
<dependency>
|
||||
<groupId>com.bawei</groupId>
|
||||
<artifactId>bawei-common-log</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- BaWei Common Swagger -->
|
||||
<dependency>
|
||||
<groupId>com.bawei</groupId>
|
||||
<artifactId>bawei-common-swagger</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.bawei</groupId>
|
||||
<artifactId>bawei-mall-car-common</artifactId>
|
||||
<version>3.6.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-redis</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.bawei</groupId>
|
||||
<artifactId>bawei-common-security</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.bawei</groupId>
|
||||
<artifactId>bawei-common-swagger</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.bawei</groupId>
|
||||
<artifactId>bawei-mall-product-common</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</project>
|
|
@ -0,0 +1,26 @@
|
|||
package com.bawei.mall.car;
|
||||
|
||||
import com.bawei.common.security.annotation.EnableCustomConfig;
|
||||
import com.bawei.common.security.annotation.EnableRyFeignClients;
|
||||
import com.bawei.common.swagger.annotation.EnableCustomSwagger2;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
|
||||
/**
|
||||
* @program: mall_cloud
|
||||
* @ClassName: BaweiMallCarApplication
|
||||
* @author: Gyc
|
||||
* @create: 2024-05-06 11:54
|
||||
**/
|
||||
@EnableCustomConfig
|
||||
@EnableCustomSwagger2
|
||||
@EnableRyFeignClients
|
||||
@SpringBootApplication
|
||||
@EnableScheduling
|
||||
public class BaweiMallCarApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(BaweiMallCarApplication.class,args);
|
||||
System.out.println("(♥◠‿◠)ノ゙ 购物车模块启动成功 ლ(´ڡ`ლ)゙ ");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
package com.bawei.mall.car.controller;
|
||||
|
||||
import com.bawei.common.core.domain.R;
|
||||
import com.bawei.mall.car.service.CarService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.lang.reflect.Array;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* 购物车控制层
|
||||
*
|
||||
* @program: mall_cloud
|
||||
* @ClassName: CarController
|
||||
* @author: Gyc
|
||||
* @create: 2024-05-06 16:02
|
||||
**/
|
||||
@RestController
|
||||
public class CarController {
|
||||
@Autowired
|
||||
private CarService carService;
|
||||
|
||||
@PostMapping("/addCar")
|
||||
public R addCar(@RequestParam Integer skuId,@RequestParam Integer status){
|
||||
carService.addCar(skuId, status);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@PostMapping("/updCar")
|
||||
public R updCar(@RequestParam Integer skuId, @RequestParam Integer num){
|
||||
carService.updCar(skuId, num);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@PostMapping("/cleanCar")
|
||||
public R delCar(){
|
||||
carService.delCar();
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@PostMapping("/delById")
|
||||
public R delById(@RequestParam("skuIds") String skuIds){
|
||||
carService.delById(skuIds);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
//查询接口
|
||||
@PostMapping("/calculate")
|
||||
public R calculate(){
|
||||
return R.ok(carService.calculate());
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package com.bawei.mall.car.controller;
|
||||
|
||||
import com.bawei.common.core.domain.R;
|
||||
import com.bawei.mall.car.service.OrderService;
|
||||
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.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 订单控制层
|
||||
*
|
||||
* @program: mall_cloud
|
||||
* @ClassName: OrderController
|
||||
* @author: Gyc
|
||||
* @create: 2024-05-10 19:33
|
||||
**/
|
||||
@RestController
|
||||
public class OrderController {
|
||||
@Autowired
|
||||
private OrderService orderService;
|
||||
|
||||
@PostMapping("/addOrder")
|
||||
public R addOrder(@RequestBody List<Integer> skuIds) {
|
||||
return R.ok( orderService.addOrder(skuIds));
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package com.bawei.mall.car.controller;
|
||||
|
||||
import com.bawei.mall.car.service.PaymentService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* 支付控制层
|
||||
*
|
||||
* @program: mall_cloud
|
||||
* @ClassName: PaymentController
|
||||
* @author: Gyc
|
||||
* @create: 2024-05-12 16:24
|
||||
**/
|
||||
@RestController
|
||||
public class PaymentController {
|
||||
@Autowired
|
||||
private PaymentService paymentService;
|
||||
|
||||
@GetMapping("/pay/{orderId}")
|
||||
public String pay(@PathVariable String orderId) {
|
||||
return paymentService.pay(orderId);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
package com.bawei.mall.car.demo;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alipay.api.AlipayApiException;
|
||||
import com.alipay.api.AlipayClient;
|
||||
import com.alipay.api.DefaultAlipayClient;
|
||||
import com.alipay.api.request.AlipayTradePagePayRequest;
|
||||
import com.alipay.api.response.AlipayTradePagePayResponse;
|
||||
|
||||
/**
|
||||
* @program: mall_cloud
|
||||
* @ClassName: demo
|
||||
* @author: Gyc
|
||||
* @create: 2024-05-12 15:54
|
||||
**/
|
||||
public class demo {
|
||||
public static void main(String[] args) throws Exception {
|
||||
AlipayClient alipayClient = new DefaultAlipayClient("https://openapi-sandbox.dl.alipaydev.com/gateway.do",
|
||||
"9021000136694024",
|
||||
"MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCFz/238QvZGbGw9EXAihMzA/wBLprkwCZN2PlZAWBJRI28L+rO8xAtgeC6AVarRGF6e0qMZ4LLWtOgL1RyfxOL2I/Ny+F8jmY0wEZABt6WKI1/l9HliZ/hxNoko4IHo6tf7NEhZJMmAce088PB3IVmFWv1aaSOL7/WaZlSiz/80ZA2v7oHzntblVm1FHFok7kCumndzdj8SgaPtZRA964lx3zhQHWV2O22ThhqN6zksJzXsQoPFvIv8Ic5ymYPzCvnSs7U5jyHMwQ1btYXgUMbv1Uqo9It2U0Gq3P4rZFMjfPn5FSdLaWepTpSg69Ittqo3YCzBmlKZjVmBc5W9thHAgMBAAECggEAF3AJ2akP0TPt6reua/4DROFCx5Y5LS32x5XkftF94vdt9/NQpnTudXoVOZ84ZgExLbngod0TjLjY7mq72N4nN0x0S7CVSzLJ9h1jcJ2DaTurJRkbe5/ycCIBr38wLFRflQquyrGKEJMpPqmftRoCB5Ji+XZKi1kTueN/JnUbfRWavAagK6YK8qlZYAiQr+PXiLcF2U3qcB7BgqVb7BJU5g/IiotHE+0ijtqWcT+X9ElIqw5mgmkvRZBPy5iVeD/b2F5b4Mbr9MvQkaICzt+P8QZCTKyd31GOhSV6zYguaisN16uC5DKRNZ4d1nbWOSR5ifCu1FH8t1cGy+OstVFzIQKBgQDFP9ZKc1wo5U/+zL8Bz9JteWEs1X6NzHu9yF62pgHg6G8L+YnQhFUtR8yQ1f782Fkdsl6YyXv89PXAcYHQJJax5JK2ONQD+tb6BUhOt2kq1d2ZJhX4nDeUJfpsKuaXnbsRc5A9D/HmUlZvsAxZoZ367WOi6WudP6DwDlG0g58xlwKBgQCtqx99lENuTQ0K8qNuSwWvQb+APf6zlGdqT7G1rQTPtNJ79ZyECQNUC9FzsIstQIWvLQO6PzYpa/aTZst44sWFPtyqTY0+ECUO5/KC/Ap5AROuy1/rMEaUQ93hT54TTLVm0g3fwnUCOJX9iUXJk63gxXCdyCi+8ZkLNEcwWa8E0QKBgBNJUqKk9PXqtg+r5WE/+MtLevzvQxiKTe8YkGo7gSOElpcNJzSEO+/ZfV8MDYqbfNsyfZ1i1gS9zumqL48yhKmQN+gpVlGtTSfVLGTF+jp9/tTirHNKkwShUgMRjsp0Wb4zFn9h970Vf+4bwJli/Bd07rEXMbaGai4OuF52IDKxAoGAHeN4jPVKUZ5jI0I1DFNPDCWFnr2Mqz1cOviyPfEkBdc57mmL4VFnyDwsdPuqSER1fXuCy7f7S0+wZRfo5sooclEqSwkDyO2gYxtaKl7UMpUT3R5VSLXLP9MaSZ+ZNfsasTJvftYJqzMv5S2N3C5VW3y/b/g1wv7zdvEtW03kCDECgYEAnY21ReTt6HtLcX4iGAX1PKfGU251b5a2Kw4xcX/oNkzWHeVL9URDmlB93paNLg6QuskeSiwgPmitUGtKWNAfyZnWESAfCZkGza0+aJjni4LbxcnFHJcYMmuWMZxLB6IaOlDPnneKv0DWSydIkotDCDnFz4BPnim962ilILRLnWY=",
|
||||
"json",
|
||||
"UTF-8",
|
||||
"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEApxRIYvq+Kr7RLyD3gWevRWKfIM7vGGNtCmQ7yP/Gooz6i8GzLWCZgrp5j1bazhECaPvCsvuZPU6DHd3rETWuaDGrFPvGwPl+VUX7NlYIG8QdKdMmBHA+/UbqvytEIrRqkP3/s+yrbRGzGmN8Ht8wNmPEn51IlTZVcvi2cxs1CY0CY9k70pkWnZBmhxxOG3EvgM1dV/61aWQkJk3OFhITSIWlf9FQBxH1E1RfciSoEWgjew/KoWyKp83rqKuUtHehILdNsfqHFHO/lzDp2XhVBPKNqafIQvAhcWyBwhGD9Cs83YvLldvJ9DE2LGFi8eF+IvVbcFrCfkkxrT4kBoxGYwIDAQAB",
|
||||
"RSA2");
|
||||
AlipayTradePagePayRequest request = new AlipayTradePagePayRequest();
|
||||
//异步接收地址,仅支持http/https,公网可访问
|
||||
request.setNotifyUrl("");
|
||||
//同步跳转地址,仅支持http/https
|
||||
request.setReturnUrl("");
|
||||
/******必传参数******/
|
||||
JSONObject bizContent = new JSONObject();
|
||||
//商户订单号,商家自定义,保持唯一性
|
||||
bizContent.put("out_trade_no", "20210817010101006");
|
||||
//支付金额,最小值0.01元
|
||||
bizContent.put("total_amount", 200.00);
|
||||
//订单标题,不可使用特殊符号
|
||||
bizContent.put("subject", "测试商品");
|
||||
//电脑网站支付场景固定传值FAST_INSTANT_TRADE_PAY
|
||||
bizContent.put("product_code", "FAST_INSTANT_TRADE_PAY");
|
||||
|
||||
/******可选参数******/
|
||||
//bizContent.put("time_expire", "2022-08-01 22:00:00");
|
||||
|
||||
////// 商品明细信息,按需传入
|
||||
//JSONArray goodsDetail = new JSONArray();
|
||||
//JSONObject goods1 = new JSONObject();
|
||||
//goods1.put("goods_id", "goodsNo1");
|
||||
//goods1.put("goods_name", "子商品1");
|
||||
//goods1.put("quantity", 1);
|
||||
//goods1.put("price", 200.00);
|
||||
//goodsDetail.add(goods1);
|
||||
//bizContent.put("goods_detail", goodsDetail);
|
||||
|
||||
//// 扩展信息,按需传入
|
||||
//JSONObject extendParams = new JSONObject();
|
||||
//extendParams.put("sys_service_provider_id", "2088511833207846");
|
||||
//bizContent.put("extend_params", extendParams);
|
||||
|
||||
request.setBizContent(bizContent.toString());
|
||||
AlipayTradePagePayResponse response = alipayClient.pageExecute(request,"POST");
|
||||
// 如果需要返回GET请求,请使用
|
||||
// AlipayTradePagePayResponse response = alipayClient.pageExecute(request,"GET");
|
||||
String pageRedirectionData = response.getBody();
|
||||
System.out.println(pageRedirectionData);
|
||||
|
||||
if(response.isSuccess()){
|
||||
System.out.println("调用成功");
|
||||
} else {
|
||||
System.out.println("调用失败");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
package com.bawei.mall.car.mapper;
|
||||
|
||||
import com.bawei.mall.car.domain.Car;
|
||||
import com.bawei.mall.car.domain.CarBySku;
|
||||
import com.bawei.mall.car.domain.ProductSkuInfo;
|
||||
import com.bawei.mall.product.domain.MallProductSkuInfo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @program: mall_cloud
|
||||
* @ClassName: CarMapper
|
||||
* @author: Gyc
|
||||
* @create: 2024-05-06 16:03
|
||||
**/
|
||||
@Mapper
|
||||
public interface CarMapper {
|
||||
|
||||
|
||||
String queryCar(Long userId);
|
||||
|
||||
|
||||
void insertCar(@Param("userId") Long userId, @Param("carId") String carId);
|
||||
|
||||
void addCarBySkuId(@Param("skuId") Integer skuId, @Param("carId") String carId, @Param("userId") Long userId);
|
||||
|
||||
CarBySku showCarBySkuId(@Param("skuId") Integer skuId, @Param("carId") String carId);
|
||||
|
||||
void updCarBySkuId(@Param("skuId") Integer skuId, @Param("carId") String carId, @Param("i") int i);
|
||||
|
||||
void delCarBySkuId(String carId);
|
||||
|
||||
void delCar(Long userId);
|
||||
|
||||
void delCarBySkuIdInfo(@Param("skuId") Integer skuId, @Param("carId") String carId);
|
||||
//查询这个用户所有的skuId
|
||||
List<Integer> querySkuId(String carId);
|
||||
|
||||
MallProductSkuInfo querySku(Integer skuId);
|
||||
//查询所有的sku和商品表
|
||||
List<ProductSkuInfo> querySkus(@Param("skuIds") List<Integer> skuIds, @Param("carId") String carId);
|
||||
|
||||
List<ProductSkuInfo> ProductBySkuIdList();
|
||||
|
||||
Car queryCarByCarId(String carId);
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package com.bawei.mall.car.mapper;
|
||||
|
||||
import com.bawei.mall.car.domain.Order;
|
||||
import com.bawei.mall.car.domain.OrderByUser;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @program: mall_cloud
|
||||
* @ClassName: OrderMapper
|
||||
* @author: Gyc
|
||||
* @create: 2024-05-10 19:35
|
||||
**/
|
||||
@Mapper
|
||||
public interface OrderMapper {
|
||||
|
||||
|
||||
void insertOrder(@Param("orderList") List<Order> orderList);
|
||||
|
||||
void insertOrderByUser( OrderByUser build);
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package com.bawei.mall.car.service;
|
||||
|
||||
import com.bawei.mall.car.domain.MallProductSkuCarInfo;
|
||||
|
||||
/**
|
||||
* @program: mall_cloud
|
||||
* @ClassName: CarService
|
||||
* @author: Gyc
|
||||
* @create: 2024-05-06 16:03
|
||||
**/
|
||||
public interface CarService {
|
||||
void addCar(Integer skuId, Integer status);
|
||||
|
||||
void updCar(Integer skuId, Integer num);
|
||||
|
||||
void delCar();
|
||||
|
||||
void delById(String skuIds);
|
||||
|
||||
MallProductSkuCarInfo calculate();
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package com.bawei.mall.car.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @program: mall_cloud
|
||||
* @ClassName: OrderService
|
||||
* @author: Gyc
|
||||
* @create: 2024-05-10 19:34
|
||||
**/
|
||||
public interface OrderService {
|
||||
Object addOrder(List<Integer> skuIds);
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package com.bawei.mall.car.service;
|
||||
|
||||
/**
|
||||
* @program: mall_cloud
|
||||
* @ClassName: PaymentService
|
||||
* @author: Gyc
|
||||
* @create: 2024-05-12 16:24
|
||||
**/
|
||||
public interface PaymentService {
|
||||
String pay(String orderId);
|
||||
|
||||
}
|
|
@ -0,0 +1,299 @@
|
|||
package com.bawei.mall.car.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.bawei.common.core.utils.JwtUtils;
|
||||
import com.bawei.common.security.utils.SecurityUtils;
|
||||
import com.bawei.mall.car.domain.CarBySku;
|
||||
import com.bawei.mall.car.domain.MallProductSkuCarInfo;
|
||||
import com.bawei.mall.car.domain.ProductPrices;
|
||||
import com.bawei.mall.car.domain.ProductSkuInfo;
|
||||
import com.bawei.mall.car.mapper.CarMapper;
|
||||
import com.bawei.mall.car.service.CarService;
|
||||
import com.bawei.mall.product.domain.MallProductSkuInfo;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import io.jsonwebtoken.Claims;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
/**
|
||||
* 购物车服务实现类
|
||||
*/
|
||||
@Service
|
||||
@Log4j2
|
||||
public class CarServiceImpl implements CarService {
|
||||
/**
|
||||
* 购物车Mapper依赖注入
|
||||
*/
|
||||
@Autowired
|
||||
private CarMapper carMapper;
|
||||
@Autowired
|
||||
private RedisTemplate<String,String> redisTemplate;
|
||||
/**
|
||||
* 添加商品到购物车
|
||||
*
|
||||
* @param skuId 商品ID
|
||||
* @param status 状态(0:添加,非0:删除)
|
||||
*/
|
||||
@Override
|
||||
public void addCar(Integer skuId, Integer status) {
|
||||
if (skuId == null || skuId==0||skuId<0) {
|
||||
throw new RuntimeException("商品ID不能为空");
|
||||
}
|
||||
if (status==null||status<0){
|
||||
throw new RuntimeException("状态不能为空");
|
||||
}
|
||||
|
||||
String token = queryUserId();
|
||||
// 获取用户ID
|
||||
Long userId = Long.valueOf(JwtUtils.getUserId(token));
|
||||
//查询sku
|
||||
MallProductSkuInfo mallProductSkuInfo=carMapper.querySku(skuId);
|
||||
if (mallProductSkuInfo==null){
|
||||
throw new RuntimeException("商品不存在");
|
||||
}
|
||||
// 查询购物车
|
||||
String carId = carMapper.queryCar(userId);
|
||||
if (carId == null) {
|
||||
carId= UUID.randomUUID().toString().replaceAll("-", "");
|
||||
// 新增购物车
|
||||
carMapper.insertCar(userId, carId);
|
||||
// 将商品信息和购物车ID进行关联
|
||||
carMapper.addCarBySkuId(skuId, carId, userId);
|
||||
}
|
||||
//查询购物车
|
||||
CarBySku carBySku = carMapper.showCarBySkuId(skuId, carId);
|
||||
if (carBySku==null){
|
||||
carMapper.addCarBySkuId(skuId,carId,userId);
|
||||
}else {
|
||||
// 根据状态进行操作
|
||||
if (status == 0) {
|
||||
toAddCar(skuId, carId);
|
||||
} else {
|
||||
toDelCar(skuId, carId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 减少商品数量(从购物车中删除商品)
|
||||
*
|
||||
* @param skuId 商品ID
|
||||
* @param carId 购物车ID
|
||||
*/
|
||||
private void toDelCar(Integer skuId, String carId) {
|
||||
// 查询购物车数量
|
||||
CarBySku carBySku = carMapper.showCarBySkuId(skuId, carId);
|
||||
// 判断购物车数量
|
||||
if (carBySku.getNumber() <= 1) {
|
||||
throw new RuntimeException("购物车数量为1,不能再减了");
|
||||
} else {
|
||||
// 更新购物车商品数量
|
||||
carMapper.updCarBySkuId(skuId, carId, carBySku.getNumber() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 增加商品数量(向购物车中添加商品)
|
||||
*
|
||||
* @param skuId 商品ID
|
||||
* @param carId 购物车ID
|
||||
*/
|
||||
private void toAddCar(Integer skuId, String carId) {
|
||||
// 查询购物车商品信息
|
||||
CarBySku carBySku = carMapper.showCarBySkuId(skuId, carId);
|
||||
if (carBySku==null){
|
||||
throw new RuntimeException("购物车商品不存在");
|
||||
}
|
||||
// 更新购物车商品数量
|
||||
carMapper.updCarBySkuId(skuId, carId, carBySku.getNumber() + 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前登录用户ID
|
||||
*
|
||||
* @return 用户ID
|
||||
*/
|
||||
private String queryUserId() {
|
||||
// 获取用户ID
|
||||
String token = SecurityUtils.getToken();
|
||||
JwtUtils.parseToken(token);
|
||||
return token;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 更新购物车商品数量
|
||||
*
|
||||
* @param skuId 商品ID
|
||||
* @param num 商品数量
|
||||
*/
|
||||
@Override
|
||||
public void updCar(Integer skuId, Integer num) {
|
||||
String token = queryUserId();
|
||||
// 获取用户ID
|
||||
Long userId = Long.valueOf(JwtUtils.getUserId(token));
|
||||
|
||||
// 查询购物车
|
||||
String carId = carMapper.queryCar(userId);
|
||||
if (carId == null) {
|
||||
throw new RuntimeException("购物车错误");
|
||||
}
|
||||
// 更新购物车商品数量
|
||||
carMapper.updCarBySkuId(skuId, carId, num);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除整个购物车
|
||||
*/
|
||||
@Override
|
||||
public void delCar() {
|
||||
String token = queryUserId();
|
||||
// 获取用户ID
|
||||
Long userId = Long.valueOf(JwtUtils.getUserId(token));
|
||||
// 查询购物车
|
||||
String carId = carMapper.queryCar(userId);
|
||||
if (carId == null) {
|
||||
throw new RuntimeException("购物车不存在");
|
||||
}
|
||||
// 删除购物车关联记录
|
||||
carMapper.delCarBySkuId(carId);
|
||||
// 删除购物车记录
|
||||
carMapper.delCar(userId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据商品ID列表批量删除购物车商品
|
||||
*
|
||||
* @param skuIds 商品ID列表
|
||||
*/
|
||||
@Override
|
||||
public void delById(String skuIds) {
|
||||
// 检查商品ID列表是否为空
|
||||
if (skuIds.isEmpty()) {
|
||||
throw new RuntimeException("skuIds不能为空");
|
||||
}
|
||||
|
||||
String token = queryUserId();
|
||||
// 获取用户ID
|
||||
Long userId = Long.valueOf(JwtUtils.getUserId(token));
|
||||
String carId = carMapper.queryCar(userId);
|
||||
String[] split = skuIds.split(",");
|
||||
// 遍历商品ID列表并删除购物车关联记录
|
||||
for (String skuId : split) {
|
||||
carMapper.delCarBySkuIdInfo(Integer.valueOf(skuId), carId);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public MallProductSkuCarInfo calculate() {
|
||||
MallProductSkuCarInfo mallProductSkuCarInfo = new MallProductSkuCarInfo();
|
||||
List<ProductSkuInfo> productSkuInfos = new ArrayList<>();
|
||||
ProductPrices productPrices = new ProductPrices();
|
||||
String token = queryUserId();
|
||||
Long userId = Long.valueOf(JwtUtils.getUserId(token));
|
||||
String carId = carMapper.queryCar(userId);
|
||||
List<Integer> skuIds = carMapper.querySkuId(carId);
|
||||
if (skuIds.size()==0){
|
||||
throw new RuntimeException("购物车为空");
|
||||
}
|
||||
//查询reids里面的数据,如果redis里面没有就去数据库查
|
||||
if (redisTemplate.hasKey("car")){
|
||||
List<String> car = redisTemplate.opsForList().range("car", 0, -1);
|
||||
productSkuInfos = car.stream()
|
||||
.map(carProductInfo -> JSON.parseObject(carProductInfo,ProductSkuInfo.class))
|
||||
.collect(Collectors.toList());
|
||||
mallProductSkuCarInfo.setProductSkuInfo(productSkuInfos);
|
||||
}else {
|
||||
productSkuInfos = carMapper.querySkus(skuIds,carId);
|
||||
redisTemplate.opsForList().rightPushAll("car",JSON.toJSONString(productSkuInfos));
|
||||
}
|
||||
|
||||
if (productSkuInfos.size()==0){
|
||||
throw new RuntimeException("购物车商品不存在");
|
||||
}
|
||||
mallProductSkuCarInfo.setProductSkuInfo(productSkuInfos);
|
||||
productPrices.setPrice(new BigDecimal(0));
|
||||
productPrices.setSpecialOffer(new BigDecimal(0));
|
||||
productPrices.setAfterDiscounts(new BigDecimal(0));
|
||||
BigDecimal bigDecimal = new BigDecimal(0);
|
||||
for (ProductSkuInfo productSkuInfo : productSkuInfos) {
|
||||
BigDecimal skuPrice = productSkuInfo.getSkuPrice();
|
||||
BigDecimal number = BigDecimal.valueOf(productSkuInfo.getNumber());
|
||||
|
||||
// 使用bigDecimal的add()方法,并将结果保存回bigDecimal
|
||||
bigDecimal = bigDecimal.add(skuPrice.multiply(number));
|
||||
}
|
||||
productPrices.setPrice(bigDecimal);
|
||||
|
||||
//TODO 假设有个VIP
|
||||
Claims claims = JwtUtils.parseToken(token);
|
||||
log.info("claims:{}",claims);
|
||||
String VIP="admin";
|
||||
if (VIP.equals(JwtUtils.getUserName(claims))){
|
||||
getVIP(productPrices);
|
||||
}
|
||||
mallProductSkuCarInfo.setProductPrices(productPrices);
|
||||
return mallProductSkuCarInfo;
|
||||
}
|
||||
|
||||
private void getVIP(ProductPrices productPrices) {
|
||||
// 计算VIP折扣后的价格
|
||||
BigDecimal vipDiscountRate = new BigDecimal("0.9");
|
||||
BigDecimal afterDiscounts = productPrices.getPrice().multiply(vipDiscountRate);
|
||||
productPrices.setAfterDiscounts(afterDiscounts);
|
||||
|
||||
// 计算VIP优惠与原价的差距
|
||||
BigDecimal specialOffer = productPrices.getPrice().subtract(afterDiscounts);
|
||||
productPrices.setSpecialOffer(specialOffer);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,203 @@
|
|||
package com.bawei.mall.car.service.impl;
|
||||
|
||||
import com.bawei.common.core.utils.JwtUtils;
|
||||
import com.bawei.common.security.utils.SecurityUtils;
|
||||
import com.bawei.mall.car.domain.*;
|
||||
import com.bawei.mall.car.mapper.CarMapper;
|
||||
import com.bawei.mall.car.mapper.OrderMapper;
|
||||
import com.bawei.mall.car.service.OrderService;
|
||||
import io.jsonwebtoken.Claims;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @program: mall_cloud
|
||||
* @ClassName: OrderServiceImpl
|
||||
* @author: Gyc
|
||||
* @create: 2024-05-10 19:34
|
||||
**/
|
||||
@Service
|
||||
public class OrderServiceImpl implements OrderService {
|
||||
private static final Logger log = LoggerFactory.getLogger(OrderServiceImpl.class);
|
||||
@Autowired
|
||||
private OrderMapper orderMolder;
|
||||
@Autowired
|
||||
private CarMapper carMapper;
|
||||
@Autowired
|
||||
private OrderMapper orderMapper;
|
||||
|
||||
@Override
|
||||
public Object addOrder(List<Integer> skuIds) {
|
||||
String token = SecurityUtils.getToken();
|
||||
String userId = JwtUtils.getUserId(token);
|
||||
String carId = carMapper.queryCar(Long.valueOf(userId));
|
||||
if (carId == null){
|
||||
throw new RuntimeException("购物车为空");
|
||||
}
|
||||
String orderId = generateOrderId();
|
||||
ArrayList<CarBySku> carBySkus = new ArrayList<>();
|
||||
List<ProductSkuInfo> productSkuInfoList = carMapper.querySkus(skuIds, carId);
|
||||
List<Order> orderList = productSkuInfoList.stream()
|
||||
.map(productSkuInfo -> {
|
||||
Order order = new Order();
|
||||
Order build = order.builder()
|
||||
.skuId(Math.toIntExact(productSkuInfo.getSkuId()))
|
||||
.productUrl(productSkuInfo.getImage())
|
||||
.productPrice(productSkuInfo.getSkuPrice())
|
||||
.productName(productSkuInfo.getTitle())
|
||||
.productSku(productSkuInfo.getSkuName())
|
||||
.orderId(orderId)
|
||||
.productNum(productSkuInfo.getNumber())
|
||||
.buyNumber(productSkuInfo.getBuyNumber())
|
||||
.build();
|
||||
return build;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
orderMolder.insertOrder(orderList);
|
||||
//查询需要购买的数量
|
||||
skuIds.forEach(skuId -> {
|
||||
CarBySku carBySku = carMapper.showCarBySkuId(skuId, carId);
|
||||
carBySkus.add(carBySku);
|
||||
});
|
||||
for (int i = 0; i < carBySkus.size() - 1; i++) {
|
||||
//比较商品数量
|
||||
if (carBySkus.get(i).getNumber()>orderList.get(i).getBuyNumber()){
|
||||
throw new RuntimeException("商品数量不足");
|
||||
}
|
||||
}
|
||||
// orderMapper.insertOrderByUser(orderId,userId);
|
||||
|
||||
OrderByUser orderByUser = new OrderByUser();
|
||||
OrderByUser build = orderByUser.builder()
|
||||
.orderId(orderId)
|
||||
.userId(Integer.valueOf(userId))
|
||||
.status(0)
|
||||
.createTime(new Date())
|
||||
//TODO 没有优惠卷
|
||||
.discountId(0)
|
||||
.build();
|
||||
getVIP(orderList,build);
|
||||
OrderByUserInfo orderByUserInfo = new OrderByUserInfo();
|
||||
orderByUserInfo.setOrderList(orderList);
|
||||
orderByUserInfo.setOrderByUser(build);
|
||||
orderMapper.insertOrderByUser(build);
|
||||
return orderByUserInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算价格
|
||||
*
|
||||
* @param orderList
|
||||
* @param orderByUser
|
||||
*/
|
||||
private void getVIP(List<Order> orderList, OrderByUser orderByUser) {
|
||||
orderByUser.setTotalPrice(new BigDecimal(0));
|
||||
orderByUser.setDiscountPrice(new BigDecimal(0));
|
||||
orderByUser.setPayPrice(new BigDecimal(0));
|
||||
BigDecimal bigDecimal = new BigDecimal(0);
|
||||
for (Order order : orderList) {
|
||||
BigDecimal skuPrice = order.getProductPrice();
|
||||
BigDecimal number = BigDecimal.valueOf(order.getProductNum());
|
||||
// 使用bigDecimal的add()方法,并将结果保存回bigDecimal
|
||||
bigDecimal = bigDecimal.add(skuPrice.multiply(number));
|
||||
orderByUser.setTotalPrice(bigDecimal);
|
||||
|
||||
}
|
||||
if (orderByUser.getDiscountId()!=0){
|
||||
//TODO 进行优惠
|
||||
}
|
||||
//TODO 假设有个VIP
|
||||
String token = SecurityUtils.getToken();
|
||||
Claims claims = JwtUtils.parseToken(token);
|
||||
log.info("claims:{}",claims);
|
||||
String VIP="admin";
|
||||
if (VIP.equals(JwtUtils.getUserName(claims))){
|
||||
// 计算VIP折扣后的价格
|
||||
BigDecimal vipDiscountRate = new BigDecimal("0.99");
|
||||
BigDecimal afterDiscounts =orderByUser.getTotalPrice().multiply(vipDiscountRate);
|
||||
orderByUser.setPayPrice(afterDiscounts);
|
||||
|
||||
// 计算VIP优惠与原价的差距
|
||||
BigDecimal specialOffer = orderByUser.getTotalPrice().subtract(afterDiscounts);
|
||||
orderByUser.setDiscountPrice(specialOffer);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成基于时间戳和十个随机数字的订单ID。
|
||||
*
|
||||
* @return 订单ID字符串
|
||||
*/
|
||||
public static String generateOrderId() {
|
||||
// 获取当前时间的毫秒时间戳
|
||||
long timestamp = Instant.now().toEpochMilli();
|
||||
|
||||
// 创建一个随机数生成器
|
||||
Random random = new Random();
|
||||
|
||||
// 生成十个0-9之间的随机数字,拼接成一个字符串
|
||||
StringBuilder randomNumbers = new StringBuilder();
|
||||
for (int i = 0; i < 4; i++) {
|
||||
randomNumbers.append(random.nextInt(10));
|
||||
}
|
||||
|
||||
// 将时间戳和随机数字拼接成订单ID,这里以某种格式组合,例如:时间戳_随机数
|
||||
// 注意根据实际需要调整格式,确保唯一性和长度控制
|
||||
String orderId = timestamp + randomNumbers.toString();
|
||||
|
||||
return orderId;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,83 @@
|
|||
package com.bawei.mall.car.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alipay.api.AlipayClient;
|
||||
import com.alipay.api.DefaultAlipayClient;
|
||||
import com.alipay.api.request.AlipayTradePagePayRequest;
|
||||
import com.alipay.api.response.AlipayTradePagePayResponse;
|
||||
import com.bawei.mall.car.service.PaymentService;
|
||||
import lombok.SneakyThrows;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @program: mall_cloud
|
||||
* @ClassName: PaymentServiceImpl
|
||||
* @author: Gyc
|
||||
* @create: 2024-05-12 16:24
|
||||
**/
|
||||
@Service
|
||||
public class PaymentServiceImpl implements PaymentService {
|
||||
|
||||
|
||||
@SneakyThrows
|
||||
@Override
|
||||
public String pay(String orderId) {
|
||||
|
||||
AlipayClient alipayClient = new DefaultAlipayClient("https://openapi-sandbox.dl.alipaydev.com/gateway.do",
|
||||
"9021000136694024",
|
||||
"MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCFz/238QvZGbGw9EXAihMzA/wBLprkwCZN2PlZAWBJRI28L+rO8xAtgeC6AVarRGF6e0qMZ4LLWtOgL1RyfxOL2I/Ny+F8jmY0wEZABt6WKI1/l9HliZ/hxNoko4IHo6tf7NEhZJMmAce088PB3IVmFWv1aaSOL7/WaZlSiz/80ZA2v7oHzntblVm1FHFok7kCumndzdj8SgaPtZRA964lx3zhQHWV2O22ThhqN6zksJzXsQoPFvIv8Ic5ymYPzCvnSs7U5jyHMwQ1btYXgUMbv1Uqo9It2U0Gq3P4rZFMjfPn5FSdLaWepTpSg69Ittqo3YCzBmlKZjVmBc5W9thHAgMBAAECggEAF3AJ2akP0TPt6reua/4DROFCx5Y5LS32x5XkftF94vdt9/NQpnTudXoVOZ84ZgExLbngod0TjLjY7mq72N4nN0x0S7CVSzLJ9h1jcJ2DaTurJRkbe5/ycCIBr38wLFRflQquyrGKEJMpPqmftRoCB5Ji+XZKi1kTueN/JnUbfRWavAagK6YK8qlZYAiQr+PXiLcF2U3qcB7BgqVb7BJU5g/IiotHE+0ijtqWcT+X9ElIqw5mgmkvRZBPy5iVeD/b2F5b4Mbr9MvQkaICzt+P8QZCTKyd31GOhSV6zYguaisN16uC5DKRNZ4d1nbWOSR5ifCu1FH8t1cGy+OstVFzIQKBgQDFP9ZKc1wo5U/+zL8Bz9JteWEs1X6NzHu9yF62pgHg6G8L+YnQhFUtR8yQ1f782Fkdsl6YyXv89PXAcYHQJJax5JK2ONQD+tb6BUhOt2kq1d2ZJhX4nDeUJfpsKuaXnbsRc5A9D/HmUlZvsAxZoZ367WOi6WudP6DwDlG0g58xlwKBgQCtqx99lENuTQ0K8qNuSwWvQb+APf6zlGdqT7G1rQTPtNJ79ZyECQNUC9FzsIstQIWvLQO6PzYpa/aTZst44sWFPtyqTY0+ECUO5/KC/Ap5AROuy1/rMEaUQ93hT54TTLVm0g3fwnUCOJX9iUXJk63gxXCdyCi+8ZkLNEcwWa8E0QKBgBNJUqKk9PXqtg+r5WE/+MtLevzvQxiKTe8YkGo7gSOElpcNJzSEO+/ZfV8MDYqbfNsyfZ1i1gS9zumqL48yhKmQN+gpVlGtTSfVLGTF+jp9/tTirHNKkwShUgMRjsp0Wb4zFn9h970Vf+4bwJli/Bd07rEXMbaGai4OuF52IDKxAoGAHeN4jPVKUZ5jI0I1DFNPDCWFnr2Mqz1cOviyPfEkBdc57mmL4VFnyDwsdPuqSER1fXuCy7f7S0+wZRfo5sooclEqSwkDyO2gYxtaKl7UMpUT3R5VSLXLP9MaSZ+ZNfsasTJvftYJqzMv5S2N3C5VW3y/b/g1wv7zdvEtW03kCDECgYEAnY21ReTt6HtLcX4iGAX1PKfGU251b5a2Kw4xcX/oNkzWHeVL9URDmlB93paNLg6QuskeSiwgPmitUGtKWNAfyZnWESAfCZkGza0+aJjni4LbxcnFHJcYMmuWMZxLB6IaOlDPnneKv0DWSydIkotDCDnFz4BPnim962ilILRLnWY=",
|
||||
"json",
|
||||
"UTF-8",
|
||||
"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEApxRIYvq+Kr7RLyD3gWevRWKfIM7vGGNtCmQ7yP/Gooz6i8GzLWCZgrp5j1bazhECaPvCsvuZPU6DHd3rETWuaDGrFPvGwPl+VUX7NlYIG8QdKdMmBHA+/UbqvytEIrRqkP3/s+yrbRGzGmN8Ht8wNmPEn51IlTZVcvi2cxs1CY0CY9k70pkWnZBmhxxOG3EvgM1dV/61aWQkJk3OFhITSIWlf9FQBxH1E1RfciSoEWgjew/KoWyKp83rqKuUtHehILdNsfqHFHO/lzDp2XhVBPKNqafIQvAhcWyBwhGD9Cs83YvLldvJ9DE2LGFi8eF+IvVbcFrCfkkxrT4kBoxGYwIDAQAB",
|
||||
"RSA2");
|
||||
AlipayTradePagePayRequest request = new AlipayTradePagePayRequest();
|
||||
//异步接收地址,仅支持http/https,公网可访问
|
||||
request.setNotifyUrl("");
|
||||
//同步跳转地址,仅支持http/https
|
||||
request.setReturnUrl("");
|
||||
/******必传参数******/
|
||||
JSONObject bizContent = new JSONObject();
|
||||
//商户订单号,商家自定义,保持唯一性
|
||||
bizContent.put("out_trade_no",orderId);
|
||||
//支付金额,最小值0.01元
|
||||
bizContent.put("total_amount", 200.00);
|
||||
//订单标题,不可使用特殊符号
|
||||
bizContent.put("subject", "测试商品");
|
||||
//电脑网站支付场景固定传值FAST_INSTANT_TRADE_PAY
|
||||
bizContent.put("product_code", "FAST_INSTANT_TRADE_PAY");
|
||||
|
||||
/******可选参数******/
|
||||
//bizContent.put("time_expire", "2022-08-01 22:00:00");
|
||||
|
||||
////// 商品明细信息,按需传入
|
||||
//JSONArray goodsDetail = new JSONArray();
|
||||
//JSONObject goods1 = new JSONObject();
|
||||
//goods1.put("goods_id", "goodsNo1");
|
||||
//goods1.put("goods_name", "子商品1");
|
||||
//goods1.put("quantity", 1);
|
||||
//goods1.put("price", 200.00);
|
||||
//goodsDetail.add(goods1);
|
||||
//bizContent.put("goods_detail", goodsDetail);
|
||||
|
||||
//// 扩展信息,按需传入
|
||||
//JSONObject extendParams = new JSONObject();
|
||||
//extendParams.put("sys_service_provider_id", "2088511833207846");
|
||||
//bizContent.put("extend_params", extendParams);
|
||||
|
||||
request.setBizContent(bizContent.toString());
|
||||
AlipayTradePagePayResponse response = alipayClient.pageExecute(request,"POST");
|
||||
// 如果需要返回GET请求,请使用
|
||||
// AlipayTradePagePayResponse response = alipayClient.pageExecute(request,"GET");
|
||||
String pageRedirectionData = response.getBody();
|
||||
System.out.println(pageRedirectionData);
|
||||
|
||||
if(response.isSuccess()){
|
||||
System.out.println("调用成功");
|
||||
} else {
|
||||
System.out.println("调用失败");
|
||||
}
|
||||
|
||||
|
||||
return "";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
package com.bawei.mall.car.utils;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.bawei.common.redis.service.RedisService;
|
||||
import com.bawei.mall.car.domain.Car;
|
||||
import com.bawei.mall.car.domain.CarBySku;
|
||||
import com.bawei.mall.car.domain.ProductSkuInfo;
|
||||
import com.bawei.mall.car.mapper.CarMapper;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.fasterxml.jackson.databind.type.LogicalType.Collection;
|
||||
|
||||
/**
|
||||
* @program: mall_cloud
|
||||
* @ClassName: RedisTiming
|
||||
* @author: Gyc
|
||||
* @create: 2024-05-08 15:12
|
||||
**/
|
||||
@Component
|
||||
@Log4j2
|
||||
public class RedisTiming {
|
||||
@Autowired
|
||||
private RedisTemplate<String,String> redisTemplate;
|
||||
@Autowired
|
||||
private CarMapper carMapper;
|
||||
//定时存
|
||||
@Scheduled(cron = "0 0/30 * * * ?")
|
||||
public void timingSave() {
|
||||
//编写一个定时任务,将redis的购物车信息,更新到mysql数据库
|
||||
List<String> car = redisTemplate.opsForList().range("car", 0, -1);
|
||||
List<ProductSkuInfo> productSkuInfos = car.stream()
|
||||
.map(carProductInfo -> JSON.parseObject(carProductInfo,ProductSkuInfo.class))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (productSkuInfos.size() == 0){
|
||||
return;
|
||||
}else {
|
||||
productSkuInfos.forEach(productSkuInfo -> {
|
||||
carMapper.delCarBySkuIdInfo(Math.toIntExact(productSkuInfo.getSkuId()), productSkuInfo.getCarId());
|
||||
carMapper.addCarBySkuId(Math.toIntExact(productSkuInfo.getSkuId()), productSkuInfo.getCarId(), 0L);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//定时取
|
||||
@Scheduled(cron = "0 0/15 * * * ? ")
|
||||
public void timingGet() {
|
||||
if (redisTemplate.hasKey("car")){
|
||||
redisTemplate.delete("car");
|
||||
}
|
||||
//编写一个定时任务,将mysql数据库的购物车信息,更新到redis
|
||||
List<ProductSkuInfo> productSkuInfos = carMapper.ProductBySkuIdList();
|
||||
productSkuInfos.forEach(productSkuInfo -> {
|
||||
redisTemplate.opsForList().rightPushAll("car",JSON.toJSONString(productSkuInfo));
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
Spring Boot Version: ${spring-boot.version}
|
||||
Spring Application Name: ${spring.application.name}
|
|
@ -0,0 +1,47 @@
|
|||
# Tomcat
|
||||
server:
|
||||
port: 9303
|
||||
# Spring
|
||||
spring:
|
||||
application:
|
||||
# 应用名称
|
||||
name: mall-car
|
||||
profiles:
|
||||
# 环境配置
|
||||
active: dev
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 127.0.0.1:8848
|
||||
namespace: 12345678
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 127.0.0.1:8848
|
||||
namespace: 12345678
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
shared-configs:
|
||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||
rabbitmq:
|
||||
host: 127.0.0.1
|
||||
api-docs:
|
||||
path: v3/api-docs # 指定生成文档的路径,网关会访问这个路径来拉取文档
|
||||
group-configs:
|
||||
- group: 'default'
|
||||
paths-to-match: '/**'
|
||||
packages-to-scan: com.keyl1me.edu.controller # 指定要扫描的包
|
||||
|
||||
knife4j:
|
||||
enable: true # 开启knife4j接口文档美化
|
||||
setting:
|
||||
language: zh_cn # 指定语言
|
||||
# feign 配置
|
||||
feign:
|
||||
compression:
|
||||
request:
|
||||
enabled: true
|
||||
min-request-size: 8192
|
||||
response:
|
||||
enabled: true
|
|
@ -0,0 +1,74 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration scan="true" scanPeriod="60 seconds" debug="false">
|
||||
<!-- 日志存放路径 -->
|
||||
<property name="log.path" value="logs/mall/product" />
|
||||
<!-- 日志输出格式 -->
|
||||
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n" />
|
||||
|
||||
<!-- 控制台输出 -->
|
||||
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>${log.pattern}</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<!-- 系统日志输出 -->
|
||||
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${log.path}/info.log</file>
|
||||
<!-- 循环政策:基于时间创建日志文件 -->
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!-- 日志文件名格式 -->
|
||||
<fileNamePattern>${log.path}/info.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||
<!-- 日志最大的历史 60天 -->
|
||||
<maxHistory>60</maxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>${log.pattern}</pattern>
|
||||
</encoder>
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<!-- 过滤的级别 -->
|
||||
<level>INFO</level>
|
||||
<!-- 匹配时的操作:接收(记录) -->
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<!-- 不匹配时的操作:拒绝(不记录) -->
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
</appender>
|
||||
|
||||
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${log.path}/error.log</file>
|
||||
<!-- 循环政策:基于时间创建日志文件 -->
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!-- 日志文件名格式 -->
|
||||
<fileNamePattern>${log.path}/error.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||
<!-- 日志最大的历史 60天 -->
|
||||
<maxHistory>60</maxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>${log.pattern}</pattern>
|
||||
</encoder>
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<!-- 过滤的级别 -->
|
||||
<level>ERROR</level>
|
||||
<!-- 匹配时的操作:接收(记录) -->
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<!-- 不匹配时的操作:拒绝(不记录) -->
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
</appender>
|
||||
|
||||
<!-- 系统模块日志级别控制 -->
|
||||
<logger name="com.bawei" level="info" />
|
||||
<!-- Spring日志级别控制 -->
|
||||
<logger name="org.springframework" level="warn" />
|
||||
|
||||
<root level="info">
|
||||
<appender-ref ref="console" />
|
||||
</root>
|
||||
|
||||
<!--系统操作日志-->
|
||||
<root level="info">
|
||||
<appender-ref ref="file_info" />
|
||||
<appender-ref ref="file_error" />
|
||||
</root>
|
||||
</configuration>
|
|
@ -0,0 +1,75 @@
|
|||
<?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.bawei.mall.car.mapper.CarMapper">
|
||||
|
||||
<update id="updCarBySkuId">
|
||||
update mall_sku_car_info set number=#{i} where sku_id=#{skuId} and car_id=#{carId}
|
||||
</update>
|
||||
<delete id="delCarBySkuId">
|
||||
delete from mall_sku_car_info where car_id= #{carId}
|
||||
</delete>
|
||||
<delete id="delCar">
|
||||
delete from mall_product_car where user_id= #{userId}
|
||||
</delete>
|
||||
<delete id="delCarBySkuIdInfo">
|
||||
delete from mall_sku_car_info where sku_id= #{skuId} and car_id= #{carId}
|
||||
</delete>
|
||||
|
||||
|
||||
<select id="queryCar" resultType="java.lang.String">
|
||||
select car_id from mall_product_car where user_id= #{userId}
|
||||
</select>
|
||||
<select id="showCarBySkuId" resultType="com.bawei.mall.car.domain.CarBySku">
|
||||
select * from mall_sku_car_info where sku_id= #{skuId} and car_id= #{carId}
|
||||
</select>
|
||||
<select id="querySkuId" resultType="java.lang.Integer">
|
||||
select sku_id from mall_sku_car_info where car_id= #{carId}
|
||||
</select>
|
||||
<select id="querySku" resultType="com.bawei.mall.product.domain.MallProductSkuInfo">
|
||||
select * from mall_product_sku_info where id = #{skuId}
|
||||
</select>
|
||||
<select id="querySkus" resultType="com.bawei.mall.car.domain.ProductSkuInfo">
|
||||
SELECT
|
||||
s.id skuId,
|
||||
s.sku skuName,
|
||||
s.price skuPrice,
|
||||
pi.NAME title,
|
||||
pi.img image,
|
||||
s.stock buyNumber ,
|
||||
sc.number number
|
||||
FROM
|
||||
mall_product_sku_info s
|
||||
LEFT JOIN mall_product_info pi ON s.product_id = pi.id
|
||||
LEFT JOIN mall_sku_car_info sc ON s.id = sc.sku_id
|
||||
where s.id in
|
||||
<foreach collection="skuIds" item="skuId" open="(" separator="," close=")">
|
||||
#{skuId}
|
||||
</foreach>
|
||||
</select>
|
||||
<select id="ProductBySkuIdList" resultType="com.bawei.mall.car.domain.ProductSkuInfo">
|
||||
SELECT
|
||||
s.id skuId,
|
||||
sc.car_id carId,
|
||||
s.sku skuName,
|
||||
s.price skuPrice,
|
||||
pi.NAME title,
|
||||
pi.img image,
|
||||
sc.number number
|
||||
FROM
|
||||
mall_sku_car_info sc
|
||||
LEFT JOIN mall_product_sku_info s ON sc.sku_id = s.id
|
||||
LEFT JOIN mall_product_info pi ON s.product_id = pi.id
|
||||
</select>
|
||||
<select id="queryCarByCarId" resultType="com.bawei.mall.car.domain.Car">
|
||||
select * from mall_product_car where car_id= #{carId}
|
||||
</select>
|
||||
|
||||
<insert id="insertCar" >
|
||||
insert into mall_product_car(car_id,user_id) values(#{carId},#{userId})
|
||||
</insert>
|
||||
<insert id="addCarBySkuId">
|
||||
insert into mall_sku_car_info (car_id,sku_id,number,create_by,create_time) values(#{carId},#{skuId},1,#{userId},now())
|
||||
</insert>
|
||||
</mapper>
|
|
@ -0,0 +1,41 @@
|
|||
<?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.bawei.mall.car.mapper.OrderMapper">
|
||||
|
||||
|
||||
<insert id="insertOrderByUser">
|
||||
INSERT INTO `mall-product-gyc`.`mall_order_user_info`
|
||||
( `order_id`,
|
||||
`user_id`,
|
||||
`discount_id`,
|
||||
`status`,
|
||||
`total_price`,
|
||||
`discount_price`,
|
||||
`pay_price`,
|
||||
`payt_time`,
|
||||
`create_time`)
|
||||
VALUES (#{orderId},
|
||||
#{userId},
|
||||
#{discountId},
|
||||
#{status},
|
||||
#{totalPrice},
|
||||
#{discountPrice},
|
||||
#{payPrice},
|
||||
#{payTime},
|
||||
#{createTime});
|
||||
|
||||
</insert>
|
||||
<!-- 根据给出的循坏来添加商品-->
|
||||
<insert id="insertOrder" >
|
||||
|
||||
INSERT INTO `mall-product-gyc`.`mall_product_order` ( `order_id`, sku_id, `product_name`, product_sku, `product_url`, `product_price`, `product_num`,number)
|
||||
VALUES
|
||||
<foreach collection="orderList" item="order" separator=",">
|
||||
( #{order.orderId},#{order.skuId}, #{order.productName},#{order.productSku}, #{order.productUrl}, #{order.productPrice}, #{order.productNum},#{order.buyNumber})
|
||||
</foreach>
|
||||
|
||||
|
||||
</insert>
|
||||
</mapper>
|
|
@ -0,0 +1,25 @@
|
|||
<?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.bawei</groupId>
|
||||
<artifactId>bawei-mall</artifactId>
|
||||
<version>3.6.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>bawei-mall-car</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<modules>
|
||||
<module>bawei-mall-car-server</module>
|
||||
<module>bawei-mall-car-common</module>
|
||||
</modules>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,37 @@
|
|||
package com.bawei.mall.product.controller;
|
||||
|
||||
import com.bawei.common.core.web.controller.BaseController;
|
||||
import com.bawei.mall.product.service.EsProductInfoService;
|
||||
import io.swagger.annotations.Api;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* es查询
|
||||
*
|
||||
* @program: mall_cloud
|
||||
* @ClassName: EsProductInfoController
|
||||
* @author: Gyc
|
||||
* @create: 2024-04-28 20:31
|
||||
**/
|
||||
@RestController
|
||||
@RequestMapping("/es")
|
||||
@Api("es查询")
|
||||
public class EsProductInfoController extends BaseController {
|
||||
@Autowired
|
||||
private EsProductInfoService esProductInfoService;
|
||||
|
||||
public void add(){
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
package com.bawei.mall.product.service;
|
||||
|
||||
/**
|
||||
* @program: mall_cloud
|
||||
* @ClassName: EsProductInfoService
|
||||
* @author: Gyc
|
||||
* @create: 2024-04-28 20:33
|
||||
**/
|
||||
public interface EsProductInfoService {
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
package com.bawei.mall.product.service.impl;
|
||||
|
||||
import com.bawei.es.remote.EsDocRemoteService;
|
||||
import com.bawei.es.remote.EsIndexRemoteService;
|
||||
import com.bawei.mall.product.service.EsProductInfoService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @program: mall_cloud
|
||||
* @ClassName: EsProductInfoServiceImpl
|
||||
* @author: Gyc
|
||||
* @create: 2024-04-28 20:34
|
||||
**/
|
||||
@Service
|
||||
public class EsProductInfoServiceImpl implements EsProductInfoService {
|
||||
@Autowired
|
||||
private EsIndexRemoteService esIndexRemoteService;
|
||||
@Autowired
|
||||
private EsDocRemoteService esDocRemoteService;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -14,6 +14,7 @@
|
|||
<modules>
|
||||
<module>bawei-mall-product</module>
|
||||
<module>bawei-mall-search</module>
|
||||
<module>bawei-mall-car</module>
|
||||
</modules>
|
||||
|
||||
<properties>
|
||||
|
|
Loading…
Reference in New Issue