购物车+订单

main
Ruikang Zhang 2024-07-10 18:58:53 +08:00
parent da34dac07a
commit 7ad83f1600
159 changed files with 11531 additions and 0 deletions

View File

@ -0,0 +1,103 @@
package com.ruoyi.system.domain.Dto;
import com.ruoyi.common.core.annotation.Excel;
import com.ruoyi.system.domain.vo.EsDocBaseVo;
import com.ruoyi.system.domain.vo.PageVo;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiParam;
import lombok.Data;
import java.math.BigDecimal;
import java.util.List;
@Data
public class EsDocSelectDto extends EsDocBaseVo {
@Excel(name = "商品名称")
@ApiParam("商品名称")
private String name;
@ApiModelProperty("检索字段")
private List<String> searchlist;
@ApiModelProperty("高亮字段")
private List<String> hitslist;
/** 商品描述 */
@Excel(name = "商品描述")
private String productDesc;
/** 商品类型 */
@Excel(name = "商品类型")
private String type;
/** 冗余字段 */
@Excel(name = "冗余字段")
private String typeIds;
@Excel(name = "规格信息")
private Long ruleId;
@Excel(name = "商品评论数")
private Long commentCount;
/** 商品收藏人气 */
@Excel(name = "商品收藏人气")
private Long collectCount;
/** 品牌信息 */
@Excel(name = "品牌信息")
private String brand;
/** 商品状态 */
@Excel(name = "商品状态")
private String status;
/** 单位 */
@Excel(name = "单位")
private String unit;
@Excel(name = "规格名称")
private String ruleName;
@Excel(name = "类型名称")
private String typeName;
@Excel(name = "品牌名称")
private String brandName;
/** 规格详情 */
@Excel(name = "规格详情")
private String ruleAttr;
@Excel(name = "商品库存")
private Long stock;
/** 商品价格 */
@Excel(name = "商品价格")
private BigDecimal price;
/** 商品进价 */
@Excel(name = "商品进价")
private BigDecimal purchasePrice;
/** 商品售价 */
@Excel(name = "商品售价")
private BigDecimal sellingPrice;
/** 规格图片 */
@Excel(name = "规格图片")
private String image;
/** 编号 */
@Excel(name = "编号")
private String number;
/** 重量 */
@Excel(name = "重量")
private BigDecimal weight;
/** 体积 */
@Excel(name = "体积")
private BigDecimal volume;
@ApiModelProperty("全文检索关键字")
private String keyWord;
@ApiModelProperty("分页条件")
private PageVo pageVo = new PageVo();
}

View File

@ -0,0 +1,21 @@
package com.ruoyi.system.domain.model;
import java.lang.reflect.Field;
import java.util.Arrays;
public class ReflectionExample {
private int privateField;
public String publicField;
public static void main(String[] args) {
Class<?> clazz = ReflectionExample.class;
Field[] fields = clazz.getDeclaredFields();
for (Field field : fields) {
System.out.println("Field name: " + field.getName());
System.out.println("Field type: " + field.getType());
System.out.println("Field modifiers: " + Arrays.toString(new int[]{field.getModifiers()}));
System.out.println("------------------------");
}
}
}

View File

@ -0,0 +1,14 @@
package com.ruoyi.system.domain.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel("es访问必须参数")
public class EsDocBaseVo {
@ApiModelProperty(value = "索引名称",required = true)
private String indexName="skulist_info";
@ApiModelProperty(value = "类型名称默认_doc",required = true)
private String typeName="_doc";
}

View File

@ -0,0 +1,19 @@
package com.ruoyi.system.domain.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Map;
@Data
@ApiModel("删除Es数据实体")
public class EsDocDeleteVo extends EsDocBaseVo {
@ApiModelProperty("数据唯一id")
public String id;
@ApiModelProperty(value = "数据内容",required = true)
private Map<String,Object> data;
@ApiModelProperty("是否立即刷新磁盘")
private boolean reflush = true;
}

View File

@ -0,0 +1,19 @@
package com.ruoyi.system.domain.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Map;
@Data
@ApiModel("插入Es数据实体")
public class EsDocInsertVo extends EsDocBaseVo {
@ApiModelProperty("数据唯一id")
public String id;
@ApiModelProperty(value = "数据内容",required = true)
private Map<String,Object> data;
@ApiModelProperty("是否立即刷新磁盘")
private boolean reflush = true;
}

View File

@ -0,0 +1,24 @@
package com.ruoyi.system.domain.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.util.Map;
@Data
@ApiModel("es文档查询参数")
public class EsDocQueryVo extends EsDocBaseVo{
@ApiModelProperty(value = "query参数",required = false)
private Map<String,Object> queryObj;
@ApiModelProperty(value = "全文检索关键字",required = false)
@NotBlank
private String keyWord;
@ApiModelProperty("分页条件")
private PageVo pageVo = new PageVo();
@ApiModelProperty("查询的条件")
private String queryname;
}

View File

@ -0,0 +1,96 @@
package com.ruoyi.system.domain.vo;
import com.ruoyi.common.core.annotation.Excel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiParam;
import lombok.Data;
import java.math.BigDecimal;
@Data
public class EsDocSelectVo extends EsDocBaseVo{
@Excel(name = "商品名称")
@ApiParam("商品名称")
private String name;
/** 商品描述 */
@Excel(name = "商品描述")
private String productDesc;
/** 商品类型 */
@Excel(name = "商品类型")
private String type;
/** 冗余字段 */
@Excel(name = "冗余字段")
private String typeIds;
@Excel(name = "规格信息")
private Long ruleId;
@Excel(name = "商品评论数")
private Long commentCount;
/** 商品收藏人气 */
@Excel(name = "商品收藏人气")
private Long collectCount;
/** 品牌信息 */
@Excel(name = "品牌信息")
private String brand;
/** 商品状态 */
@Excel(name = "商品状态")
private String status;
/** 单位 */
@Excel(name = "单位")
private String unit;
@Excel(name = "规格名称")
private String ruleName;
@Excel(name = "类型名称")
private String typeName;
@Excel(name = "品牌名称")
private String brandName;
/** 规格详情 */
@Excel(name = "规格详情")
private String ruleAttr;
@Excel(name = "商品库存")
private Long stock;
/** 商品价格 */
@Excel(name = "商品价格")
private BigDecimal price;
/** 商品进价 */
@Excel(name = "商品进价")
private BigDecimal purchasePrice;
/** 商品售价 */
@Excel(name = "商品售价")
private BigDecimal sellingPrice;
/** 规格图片 */
@Excel(name = "规格图片")
private String image;
/** 编号 */
@Excel(name = "编号")
private String number;
/** 重量 */
@Excel(name = "重量")
private BigDecimal weight;
/** 体积 */
@Excel(name = "体积")
private BigDecimal volume;
@ApiModelProperty("全文检索关键字")
private String keyWord;
@ApiModelProperty("分页条件")
private PageVo pageVo = new PageVo();
}

View File

@ -0,0 +1,21 @@
package com.ruoyi.system.domain.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Map;
import java.util.Objects;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class MappingAndSettingRequest {
@ApiModelProperty
private Map<String, Objects> settings;
@ApiModelProperty
private Map<String, Objects> mappings;
@ApiModelProperty
private String indexName;
}

View File

@ -0,0 +1,17 @@
package com.ruoyi.system.domain.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel("分页参数")
public class PageVo {
@ApiModelProperty("每页条数")
private int pageSize = 10;
@ApiModelProperty("当前页")
private Integer currentPage = 1;
@ApiModelProperty("总数")
private Long totalDocs;
}

View File

@ -0,0 +1,21 @@
package com.ruoyi.es;
import com.ruoyi.common.security.annotation.EnableRyFeignClients;
import com.ruoyi.common.swagger.annotation.EnableCustomSwagger2;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
* es
*
* @author ruoyi
*/
@EnableCustomSwagger2
@EnableRyFeignClients
@SpringBootApplication
public class RuoYiEsApplication {
public static void main(String[] args) {
SpringApplication.run(RuoYiEsApplication.class, args);
System.out.println("(♥◠‿◠)ノ゙ Es全文检索模块启动成功 ლ(´ڡ`ლ)゙ ");
}
}

View File

@ -0,0 +1,9 @@
package com.ruoyi.es.conf;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@Component
@Slf4j
public class EsConfiguration {
}

View File

@ -0,0 +1,62 @@
package com.ruoyi.es.controller;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.es.service.EsDocService;
import com.ruoyi.system.domain.Dto.EsDocSelectDto;
import com.ruoyi.system.domain.vo.EsDocInsertVo;
import com.ruoyi.system.domain.vo.EsDocQueryVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@Api(tags = "Es文档管理")
public class EsDocController {
@Autowired
private EsDocService esDocService;
@PostMapping("/batchInsertDocs")
@ApiOperation(value = "批量插入文档")
public R<Boolean> batchInsertDocs(@RequestBody List<EsDocInsertVo> esDocInsertVo){
return esDocService.batchInsertDocs(esDocInsertVo);
}
@PostMapping("/queryDocs")
@ApiOperation(value = "根据传入条件查询Es的文档数据")
public R queryDocs(@RequestBody EsDocQueryVo esDocInsertVo){
return esDocService.queryDocs(esDocInsertVo);
}
@DeleteMapping("/querydelDoce")
@ApiOperation(value = "根据传入条件删除Es的文档数据")
public R<Boolean> querydelDoce(@RequestBody List<EsDocInsertVo> esDocInsertVo){
return esDocService.batchInsertdelDocs(esDocInsertVo);
}
@PostMapping("/queryDocsproduct")
@ApiOperation(value = "根据传入条件查询Es的文档数据(多个字段与高亮)")
public TableDataInfo queryDocsproduct(@RequestBody EsDocSelectDto esDocSelectDto){
return esDocService.queryDocsproduct(esDocSelectDto, esDocSelectDto.getSearchlist());
}
@PostMapping("/queryDocsAuto")
@ApiOperation(value = "根据传入条件查询Es的文档数据")
public R queryDocsAuto(@RequestBody EsDocQueryVo esDocInsertVo){
return esDocService.queryDocsAuto(esDocInsertVo);
}
@PostMapping("/queryDocsSuggest/{indexName}")
@ApiOperation(value = "自动补全联想")
public R<List<String>> queryDocsSuggest(@PathVariable String indexName,
@RequestParam("keyWord") String keyWord,
@RequestParam("suggestFiled") String suggestFiled){
return esDocService.queryDocsSuggest(indexName,keyWord,suggestFiled);
}
}

View File

@ -0,0 +1,99 @@
package com.ruoyi.es.controller;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.es.service.EsIndexService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.Map;
@RestController
@RequestMapping("/esIndex")
@Api(value = "ES索引管理",tags = "ES索引管理")
public class EsIndexController {
@Autowired
private EsIndexService esIndexService;
/**
*
*
* @return
*/
/**
*
*
* @return
*/
@GetMapping("/create")
@ApiOperation(value = "根据索引名称创建索引")
public R<Boolean> indexCreate(String indexName) {
return esIndexService.indexCreate(indexName);
}
/**
*
*
* @return
*/
@GetMapping("/createWithMapping")
@ApiOperation(value = "根据索引名称、映射结构创建索引")
public R<Boolean> indexCreateWithMapping(String indexName, String indexMapping) {
return esIndexService.indexCreateWithMapping(indexName,indexMapping);
}
/**
*
*
* @return
*/
@GetMapping("/indexExit")
@ApiOperation(value = "根据索引名称查询索引是否存在")
public R<Boolean> indexExit(String indexName) {
return esIndexService.indexExit(indexName);
}
/**
*
*
* @return
*/
@GetMapping("/indexDelete")
@ApiOperation(value = "根据索引名称删除索引")
public R<Boolean> indexDelete(String indexName) {
return esIndexService.indexDelete(indexName);
}
/**
* mapping
*
* @return
*/
@GetMapping("/indexGetMapping")
@ApiOperation(value = "根据索引名称删除索引")
public R<Map> indexGetMapping(String indexName) {
return esIndexService.indexGetMapping(indexName);
}
@GetMapping("/indexAll")
@ApiOperation("查询所有索引名称")
public R indexAll(){
return R.ok(esIndexService.indexAll());
}
@GetMapping("/indexAllmapping")
@ApiOperation("查询所有索引mapping")
public R indexAllmapping(@RequestParam String indexname){
return R.ok(esIndexService.indexAllmapping(indexname));
}
}

View File

@ -0,0 +1,26 @@
package com.ruoyi.es.service;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.system.domain.Dto.EsDocSelectDto;
import com.ruoyi.system.domain.vo.EsDocInsertVo;
import com.ruoyi.system.domain.vo.EsDocQueryVo;
import java.util.List;
public interface EsDocService {
R<Boolean> batchInsertDocs(List<EsDocInsertVo> esDocInsertVo);
R queryDocs(EsDocQueryVo esDocInsertVo);
R<Boolean> batchInsertdelDocs(List<EsDocInsertVo> esDocInsertVo);
TableDataInfo queryDocsproduct(EsDocSelectDto esDocSelectDto,List<String> selectlist);
R queryDocsAuto(EsDocQueryVo esDocInsertVo);
R<List<String>> queryDocsSuggest(String indexName, String keyWord, String suggestFiled);
}

View File

@ -0,0 +1,24 @@
package com.ruoyi.es.service;
import com.ruoyi.common.core.domain.R;
import java.util.List;
import java.util.Map;
public interface EsIndexService {
R<Boolean> indexCreate(String indexName);
R<Boolean> indexExit(String indexName);
R<Boolean> indexDelete(String indexName);
R<Boolean> indexCreateWithMapping(String indexName, String indexMapping);
R<Map> indexGetMapping(String indexName);
List<String> indexAll();
Map<String, Object> indexAllmapping(String indexname);
}

View File

@ -0,0 +1,292 @@
package com.ruoyi.es.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.exception.ServiceException;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.es.service.EsDocService;
import com.ruoyi.es.service.EsIndexService;
import com.ruoyi.system.domain.Dto.EsDocSelectDto;
import com.ruoyi.system.domain.vo.EsDocInsertVo;
import com.ruoyi.system.domain.vo.EsDocQueryVo;
import lombok.extern.slf4j.Slf4j;
import org.apache.lucene.search.TotalHits;
import org.elasticsearch.action.bulk.BulkRequest;
import org.elasticsearch.action.bulk.BulkResponse;
import org.elasticsearch.action.delete.DeleteRequest;
import org.elasticsearch.action.index.IndexRequest;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.common.text.Text;
import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.SearchHits;
import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.elasticsearch.search.fetch.subphase.highlight.HighlightBuilder;
import org.elasticsearch.search.fetch.subphase.highlight.HighlightField;
import org.elasticsearch.search.suggest.Suggest;
import org.elasticsearch.search.suggest.SuggestBuilder;
import org.elasticsearch.search.suggest.SuggestBuilders;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
@Service
@Slf4j
public class EsDocServiceImpl implements EsDocService {
@Autowired
private RestHighLevelClient restHighLevelClient;
@Autowired
private EsIndexService esIndexService;
@Override
public R<Boolean> batchInsertDocs(List<EsDocInsertVo> esDocInsertVo) {
BulkRequest request = new BulkRequest();
esDocInsertVo.forEach(e -> {
IndexRequest source = new IndexRequest(e.getIndexName()).source(e.getData(), XContentType.JSON);
if (StringUtils.isNotEmpty(e.getId())) {
source.id(e.getId());
}
request.add(source);
});
try {
BulkResponse bulk = restHighLevelClient.bulk(request, RequestOptions.DEFAULT);
return R.ok(true, "插入成功");
} catch (IOException e) {
e.printStackTrace();
}
return R.fail(false, "插入失败");
}
@Override
public R queryDocs(EsDocQueryVo esDocInsertVo) {
SearchRequest request = new SearchRequest(esDocInsertVo.getIndexName());
//构建查询参数
SearchSourceBuilder builder = new SearchSourceBuilder();
builder.query(QueryBuilders.matchAllQuery());
//构建分页参数
builder.from((esDocInsertVo.getPageVo().getCurrentPage() - 1) * esDocInsertVo.getPageVo().getPageSize());
builder.size(esDocInsertVo.getPageVo().getPageSize());
//构建排序参数
try {
SearchResponse search = restHighLevelClient.search(request, RequestOptions.DEFAULT);
log.info("查询结果:{}", JSONObject.toJSONString(search));
SearchHit[] hits = search.getHits().getHits();
List<Map<String,Object>> resultData = new ArrayList<>(hits.length);
Arrays.stream(hits).forEach(h->{
Map<String, Object> sourceAsMap = h.getSourceAsMap();
resultData.add(sourceAsMap);
});
} catch (IOException e) {
log.error("根据条件查询es数据失败{}", e);
}
return null;
}
@Override
public R<Boolean> batchInsertdelDocs(List<EsDocInsertVo> esDocInsertVo) {
if(esDocInsertVo==null && esDocInsertVo.isEmpty()){
throw new ServiceException("esDocInsertVo不能为空");
}
BulkRequest request = new BulkRequest();
esDocInsertVo.forEach(e -> {
DeleteRequest deleteRequest = new DeleteRequest(e.getIndexName());
if (StringUtils.hasText(e.getId())) { // 确保ID不为空
deleteRequest.id(e.getId());
} else {
// 如果ID为空可能需要处理这种情况因为无法确定要删除的文档
// 这里可以抛出异常或者记录日志并跳过此条
// throw new IllegalArgumentException("Document ID cannot be empty.");
// 或者
log.warn("Skipping delete operation for document with empty ID in index: {}", e.getIndexName());
return;
}
request.add(deleteRequest);
});
try {
BulkResponse bulkResponse = restHighLevelClient.bulk(request, RequestOptions.DEFAULT);
if (bulkResponse.hasFailures()) {
// 如果有失败的请求,可以根据需要处理
// 这里简单地返回失败结果,实际应用中可能需要更详细的错误处理
return R.fail(false, "部分文档删除失败");
}
return R.ok(true, "所有文档删除成功");
} catch (IOException e) {
e.printStackTrace();
return R.fail(false, "删除失败");
}
}
@Override
public TableDataInfo queryDocsproduct(EsDocSelectDto esDocSelectDto,List<String> selectlist) {
if(StringUtils.isEmpty(esDocSelectDto.getKeyWord())){
throw new ServiceException("搜索参数不能为空");
}
long total=0;
List<Map> list = new ArrayList<>();
TableDataInfo tableDataInfo = new TableDataInfo();
try {
SearchRequest searchRequest = new SearchRequest(esDocSelectDto.getIndexName());
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
BoolQueryBuilder boolQueryBuilder = new BoolQueryBuilder();
if(!StringUtils.isEmpty(esDocSelectDto.getKeyWord())){
String[] strings = new String[selectlist.size()];
for (int i = 0; i < selectlist.size(); i++) {
strings[i]= selectlist.get(i);
}
boolQueryBuilder.must(QueryBuilders.multiMatchQuery(esDocSelectDto.getKeyWord(),strings));
}
searchSourceBuilder.query(boolQueryBuilder);
HighlightBuilder highlightBuilder = new HighlightBuilder();
//@ApiModelProperty("高亮字段必须包含在fields如果不传默认对fields进行全部高亮")
List<String> hitslist = esDocSelectDto.getHitslist();
if(CollectionUtils.isEmpty(hitslist)){
List<String> searchlist = esDocSelectDto.getSearchlist();
for (String s : searchlist) {
highlightBuilder.field(s).
preTags("<span style=\"color:red;\">").
postTags("</span>");
searchSourceBuilder.highlighter(highlightBuilder);
}
}else{
List<String> hitslist1 = esDocSelectDto.getHitslist();
for (String s : hitslist1) {
highlightBuilder.field(s).
preTags("<span style=\"color:red;\">").
postTags("</span>");
searchSourceBuilder.highlighter(highlightBuilder);
}
}
searchSourceBuilder.sort("sellingPrice");
searchSourceBuilder.from((esDocSelectDto.getPageVo().getCurrentPage()-1)*esDocSelectDto.getPageVo().getPageSize());
searchSourceBuilder.size(esDocSelectDto.getPageVo().getPageSize());
searchRequest.source(searchSourceBuilder);
SearchResponse search = restHighLevelClient.search(searchRequest, RequestOptions.DEFAULT);
SearchHits hits = search.getHits();
SearchHit[] hits1 = hits.getHits();
TotalHits totalHits = hits.getTotalHits();
total=totalHits.value;
for (SearchHit documentFields : hits1) {
String sourceAsString = documentFields.getSourceAsString();
Map map = JSONObject.parseObject(sourceAsString, Map.class);
Map<String, HighlightField> highlightFields = documentFields.getHighlightFields();
if(highlightFields!=null){
for (String s : selectlist) {
HighlightField highlightField = highlightFields.get(s);
if(highlightField!=null){
Text[] fragments = highlightField.getFragments();
if(fragments!=null){
StringBuilder stringBuilder = new StringBuilder();
for (Text fragment : fragments) {
stringBuilder.append(fragment);
}
map.put(s,stringBuilder.toString());
}
}
}
}
list.add(map);
}
} catch (IOException e) {
throw new RuntimeException(e+"es查询列表失败");
}
tableDataInfo.setTotal(total);
tableDataInfo.setCode(200);
tableDataInfo.setRows(list);
return tableDataInfo;
}
@Override
public R queryDocsAuto(EsDocQueryVo esDocInsertVo) {
String keyWord = esDocInsertVo.getKeyWord();
if(StringUtils.isEmpty(keyWord)){
throw new RuntimeException("关键字不能为空");
}
SearchRequest request = new SearchRequest(esDocInsertVo.getIndexName());
request.source().suggest(new SuggestBuilder().addSuggestion(
"suggestion",
SuggestBuilders
.completionSuggestion(esDocInsertVo.getQueryname())
.prefix(keyWord)
.skipDuplicates(true)
.size(10)
));
SearchResponse response = null;
try {
response = restHighLevelClient.search(request, RequestOptions.DEFAULT);
} catch (IOException e) {
throw new RuntimeException(e);
}
Suggest suggest = response.getSuggest();
List<String> list = new ArrayList<>();
suggest.getSuggestion("suggestion").forEach(suggestion -> {
suggestion.getOptions().forEach(entry -> {
list.add(entry.getText().string());
});
});
return R.ok(list);
}
@Override
public R<List<String>> queryDocsSuggest(String indexName, String keyWord, String suggestFiled) {
if(StringUtils.isEmpty(keyWord)){
throw new RuntimeException("关键字不能为空");
}
Boolean data = esIndexService.indexExit(indexName).getData();
if (!data){
throw new RuntimeException("索引不存在");
}
SearchRequest request = new SearchRequest(indexName);
request.source().suggest(new SuggestBuilder().addSuggestion(
"suggestion",
SuggestBuilders
.completionSuggestion(keyWord)
.prefix(suggestFiled)
.skipDuplicates(true)
.size(10)
));
SearchResponse response = null;
try {
response = restHighLevelClient.search(request, RequestOptions.DEFAULT);
} catch (IOException e) {
throw new RuntimeException(e);
}
Suggest suggest = response.getSuggest();
List<String> list = new ArrayList<>();
suggest.getSuggestion("suggestion").forEach(suggestion -> {
suggestion.getOptions().forEach(entry -> {
list.add(entry.getText().string());
});
});
return R.ok(list);
}
}

View File

@ -0,0 +1,159 @@
package com.ruoyi.es.service.impl;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.exception.ServiceException;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.es.service.EsIndexService;
import lombok.extern.slf4j.Slf4j;
import org.elasticsearch.action.admin.indices.alias.get.GetAliasesRequest;
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest;
import org.elasticsearch.action.support.master.AcknowledgedResponse;
import org.elasticsearch.client.GetAliasesResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.client.indices.*;
import org.elasticsearch.cluster.metadata.AliasMetaData;
import org.elasticsearch.cluster.metadata.MappingMetaData;
import org.elasticsearch.common.xcontent.XContentType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.io.IOException;
import java.util.*;
@Service
@Slf4j
public class EsIndexServiceImpl implements EsIndexService {
@Autowired
private RestHighLevelClient restHighLevelClient;
@Override
public R<Boolean> indexCreate(String indexName) {
//如果索引为空 抛出异常
if (StringUtils.isEmpty(indexName)) {
throw new ServiceException("索引名称不能为空");
}
CreateIndexRequest request = new CreateIndexRequest(indexName);
try {
CreateIndexResponse createIndexResponse = restHighLevelClient.indices().create(request, RequestOptions.DEFAULT);
if (createIndexResponse.isAcknowledged()) {
return R.ok(true);
}
} catch (IOException e) {
log.error("连接ES服务异常:{}", e);
throw new RuntimeException("创建索引失败,请联系管理员或查看服务日志");
}
return R.fail(false, "索引创建失败");
}
@Override
public R<Boolean> indexExit(String indexName) {
if (StringUtils.isEmpty(indexName)) {
throw new ServiceException("indexName不能为空");
}
GetIndexRequest indexRequest = new GetIndexRequest(indexName);
try {
boolean exists = restHighLevelClient.indices().exists(indexRequest, RequestOptions.DEFAULT);
return R.ok(exists);
} catch (IOException e) {
e.printStackTrace();
}
return R.fail(false, "查询失败!");
}
@Override
public R<Boolean> indexDelete(String indexName) {
if (StringUtils.isEmpty(indexName)) {
throw new ServiceException("indexName不能为空 ");
}
DeleteIndexRequest request = new DeleteIndexRequest(indexName);
try {
AcknowledgedResponse delete = restHighLevelClient.indices().delete(request, RequestOptions.DEFAULT);
if (delete.isAcknowledged()) {
return R.ok(true, "删除成功!");
}
} catch (IOException e) {
log.error("删除索引失败:{}", e);
throw new RuntimeException("调用es服务删除索引失败详情请查看日志");
}
return R.fail(false, "删除索引失败");
}
@Override
public R<Boolean> indexCreateWithMapping(String indexName, String indexMapping) {
if (StringUtils.isEmpty(indexName) ||
StringUtils.isEmpty(indexMapping)) {
throw new ServiceException("indexName、indexMapping不能为空");
}
CreateIndexRequest request = new CreateIndexRequest(indexName);
request.source(indexMapping, XContentType.JSON);
try {
CreateIndexResponse createIndexResponse = restHighLevelClient.indices().create(request, RequestOptions.DEFAULT);
if (createIndexResponse.isAcknowledged()){
return R.ok(true,"创建索引成功");
}
} catch (IOException e) {
log.error("调用es创建索引异常{}",e);
throw new RuntimeException("创建索引失败");
}
return R.fail(false,"创建索引失败");
}
@Override
public R<Map> indexGetMapping(String indexName) {
if (StringUtils.isEmpty(indexName)){
throw new ServiceException("indexName不能为空");
}
GetMappingsRequest request = new GetMappingsRequest().indices(indexName);
try {
GetMappingsResponse response = restHighLevelClient.indices().getMapping(request, RequestOptions.DEFAULT);
Map<String, MappingMetaData> mappings = response.mappings();
MappingMetaData mappingMetaData = mappings.get(indexName);
Map<String, Object> stringObjectMap = mappingMetaData.sourceAsMap();
return R.ok(stringObjectMap,"操作成功");
} catch (IOException e) {
log.error("根据索引名称获取Mapping异常:{}",e);
throw new RuntimeException("根据索引名称获取Mapping异常");
}
}
@Override
public List<String> indexAll() {
List<String> list = new ArrayList<>();
try {
GetAliasesRequest request = new GetAliasesRequest();
GetAliasesResponse getAliasesResponse = restHighLevelClient.indices().getAlias(request,RequestOptions.DEFAULT);
Map<String, Set<AliasMetaData>> map = getAliasesResponse.getAliases();
Set<String> indices = map.keySet();
for (String key : indices) {
list.add(key);
}
} catch (IOException e) {
e.printStackTrace();
}
return list;
}
@Override
public Map<String, Object> indexAllmapping(String indexname) {
Map<String, Object> mapping=new HashMap<>();
//构建请求
GetMappingsRequest request = new GetMappingsRequest().indices(indexname);
//使用RestHighLevelClient发起请求
GetMappingsResponse response = null;
try {
response = restHighLevelClient.indices().getMapping(request, RequestOptions.DEFAULT);
Map<String, MappingMetaData> mappingMap = response.mappings();
MappingMetaData indexMapping = mappingMap.get(indexname);
mapping = indexMapping.sourceAsMap();
} catch (IOException e) {
throw new RuntimeException(e);
}
return mapping;
}
}

View File

@ -0,0 +1,38 @@
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### IntelliJ IDEA ###
.idea/modules.xml
.idea/jarRepositories.xml
.idea/compiler.xml
.idea/libraries/
*.iws
*.iml
*.ipr
### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/
### Mac OS ###
.DS_Store

View File

@ -0,0 +1,38 @@
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### IntelliJ IDEA ###
.idea/modules.xml
.idea/jarRepositories.xml
.idea/compiler.xml
.idea/libraries/
*.iws
*.iml
*.ipr
### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/
### Mac OS ###
.DS_Store

View File

@ -0,0 +1,16 @@
package com.ruoyi.mall.car.config;
import org.springframework.stereotype.Component;
@Component
public class AliPayConstants {
/**
*
*/
public static final String PRIVATE_KEY="MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCexq";
/**
*
*/
public static final String PUBLIC_KEY="MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtIR3PTbTkyGY4GNeDOT";
}

View File

@ -0,0 +1,54 @@
package com.ruoyi.mall.car.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
/**
* @Authorzrk
* @Packagecom.ruoyi.java.com.ruoyi.mall.car.domain
* @Projectmall_cloud
* @nameCarAssociation
* @Date2024/5/6 16:21
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@TableName(value = "car_association")
public class CarAssociation {
/**
* id
*/
@TableId(type = IdType.AUTO)
private Long id;
/**
* id
*/
private String carId;
/**
* id
*/
private Long userId;
/**
*
*/
private String image;
/**
*
*/
private Date createTime;
/**
*
*/
private String orderPrice;
}

View File

@ -0,0 +1,33 @@
package com.ruoyi.mall.car.domain;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
/**
*
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class CarDetailInfo {
/**
*
*/
private List<ProductDetailInfo> productDetailInfoList;
/**
*
*/
private PriceDetail priceDetail;
/** 5.9
*
*/
private List<Coupon> couponList;
}

View File

@ -0,0 +1,80 @@
package com.ruoyi.mall.car.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;
import java.math.BigDecimal;
import java.util.Date;
/**
* @Authorzrk
* @Packagecom.ruoyi.java.com.ruoyi.mall.car.domain
* @Projectmall_cloud
* @nameCarInfo
* @Date2024/5/6 16:06
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@TableName(value = "car_info")
public class CarInfo {
/**
* id
*/
@TableId(type = IdType.AUTO)
private Long id;
/**
* id
*/
private String carId;
/**
* skuid
*/
private Long skuId;
/**
*
*/
private Integer number;
/**
* id
*/
private Long userId;
/**
*
*/
private BigDecimal totalAmount;
/**
*
*/
private String createBy;
/**
*
*/
@DateTimeFormat(pattern = "yyyy年MM月dd日:HH:mm:ss")
@JsonFormat(pattern = "yyyy年MM月dd日:HH:mm:ss",timezone = "GMT+8")
private Date createTime;
/**
*
*/
private String updateBy;
/**
*
*/
@DateTimeFormat(pattern = "yyyy年MM月dd日:HH:mm:ss")
@JsonFormat(pattern = "yyyy年MM月dd日:HH:mm:ss",timezone = "GMT+8")
private Date updateTime;
/**
*
*/
private Integer status;
}

View File

@ -0,0 +1,67 @@
package com.ruoyi.mall.car.domain;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.math.BigDecimal;
/**
* @Authorzrk
* @Packagecom.ruoyi.java.com.ruoyi.mall.car.domain
* @Projectmall_cloud
* @nameCopon
* @Date2024/5/9 16:08
*/
/**
*
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class Coupon {
/**
* id
*/
private Long couponId;
/**
*
*/
private String name;
/**
* 使 0
*/
private BigDecimal threshold;
/**
* 1 2
*/
private Integer couponType;
/**
*
*/
private BigDecimal discount;
/**
*
*/
private BigDecimal amount;
/**
*
*/
private String startTime;
/**
*
*/
private String endTime;
/**
*
*/
private Integer num;
/**
* 0
*/
private Integer maxNum;
}

View File

@ -0,0 +1,45 @@
package com.ruoyi.mall.car.domain;
/**
* @Authorzrk
* @Packagecom.ruoyi.java.com.ruoyi.mall.car.domain
* @Projectmall_cloud
* @nameCouponMiddle
* @Date2024/5/9 16:16
*/
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
*
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class CouponRel {
/**
* id
*/
private Long id;
/**
* id
*/
private Long couponId;
/**
* id
*/
private Long userId;
/**
*
*/
private Integer status;
/**
*
*/
private String getTime;
}

View File

@ -0,0 +1,64 @@
package com.ruoyi.mall.car.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.math.BigDecimal;
import java.util.Date;
/**
* @Authorzrk
* @Packagecom.ruoyi.java.com.ruoyi.mall.car.domain
* @Projectmall_cloud
* @nameOrderAssociation
* @Date2024/5/10 20:43
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@TableName("order_association")
public class OrderAssociation {
/**
* id
*/
@TableId(type = IdType.AUTO)
private Long id;
/**
* skuid
*/
private Long skuId;
/**
* id
*/
private Long orderId;
/**
*
*/
private String skuTitle;
/**
*
*/
private String image;
/**
*
*/
private Date createTime;
/**
*
*/
private BigDecimal orderPrice;
/**
*
*/
private Long stock;
}

View File

@ -0,0 +1,110 @@
package com.ruoyi.mall.car.domain;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
/**
* @Authorzrk
* @Packagecom.ruoyi.java.com.ruoyi.mall.car.domain
* @Projectmall_cloud
* @nameOrdernfo
* @Date2024/5/9 17:03
*/
/**
*
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@TableName(value = "order_info")
public class OrderInfo {
/**
*
*/
private Long orderId;
/**
*
*/
private BigDecimal totalPrice;
/**
* 0- 1- 2- 3- 4- 5-
*/
private Integer status = 0;
/**
*
*/
private Date createTime;
/**
*
*/
private String updateTime;
/**
*
*/
private String payTime;
/**
*
*/
private String deliveryTime;
/**
*
*/
private String receiveTime;
/**
*
*/
private String closeTime;
/**
* 0-线 1- 2-
*/
private Integer payType;
/**
* 0 - 1 -
*/
private Integer payWay;
/**
*
*/
private String payNo;
/**
*
*/
private Long userId;
/**
* skuid
*/
private Long skuId;
/**
*
*/
private List<ProductDetailInfo> productDetails;
/**
* id
*/
private List<Integer> couponIds;
/**
*
*/
private Integer integral;
}

View File

@ -0,0 +1,46 @@
package com.ruoyi.mall.car.domain;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.math.BigDecimal;
/**
* @Authorzrk
* @Packagecom.ruoyi.java.com.ruoyi.mall.car.domain
* @Projectmall_cloud
* @namePriceDetail
* @Date2024/5/8 10:28
*/
/**
*
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class PriceDetail {
/**
*
*/
private BigDecimal totalPrice;
/**
*
*/
private BigDecimal memberPrice;
/**
*
* pointPrice;
*/
/**
*
*/
private BigDecimal finalPrice;
}

View File

@ -0,0 +1,58 @@
package com.ruoyi.mall.car.domain;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.math.BigDecimal;
/**
* @Authorzrk
* @Packagecom.ruoyi.java.com.ruoyi.mall.car.domain
* @Projectmall_cloud
* @nameProductDetailInfo
* @Date2024/5/8 10:27
*/
/**
*
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class ProductDetailInfo {
/**
* skuId
*/
private Long skuId;
/**
*
*/
private String name;
/**
*
*/
private BigDecimal price;
/**
*
*/
private Integer buyNumber;
/**
*
*/
private String productTitle;
/**
*
*/
private String skuImg;
/**
* sku
*/
private Integer skuStock;
/**
* userId
* orderId
*/
}

View File

@ -0,0 +1,39 @@
package com.ruoyi.mall.car.domain.request;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
/**
* @Authorzrk
* @Packagecom.ruoyi.java.com.ruoyi.mall.car.domain.request
* @Projectmall_cloud
* @nameOrderRequest
* @Date2024/5/9 17:17
*/
/**
*
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class OrderRequest {
/**
* skuIds
*/
private List<Long> skuIds;
/**
* id
*/
private List<Integer> couponIds;
/**
*
*/
private Integer payWay;
}

View File

@ -0,0 +1,34 @@
package com.ruoyi.mall.car.domain.response;
/**
* @Authorzrk
* @Packagecom.ruoyi.java.com.ruoyi.mall.car.domain.response
* @Projectmall_cloud
* @nameOrderResp
* @Date2024/5/12 20:27
*/
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.math.BigDecimal;
/**
*
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class OrderDetailResp {
private Long orderId;
private BigDecimal totalPrice;
private String createTime;
private Long userId;
private String image;
private String sku;
private Long stock;
private String name;
}

View File

@ -0,0 +1,38 @@
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### IntelliJ IDEA ###
.idea/modules.xml
.idea/jarRepositories.xml
.idea/compiler.xml
.idea/libraries/
*.iws
*.iml
*.ipr
### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/
### Mac OS ###
.DS_Store

View File

@ -0,0 +1,38 @@
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### IntelliJ IDEA ###
.idea/modules.xml
.idea/jarRepositories.xml
.idea/compiler.xml
.idea/libraries/
*.iws
*.iml
*.ipr
### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/
### Mac OS ###
.DS_Store

View File

@ -0,0 +1,23 @@
package com.ruoyi.car;
import com.ruoyi.common.security.annotation.EnableCustomConfig;
import com.ruoyi.common.security.annotation.EnableRyFeignClients;
import com.ruoyi.common.swagger.annotation.EnableCustomSwagger2;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.scheduling.annotation.EnableScheduling;
@EnableCustomConfig
@EnableCustomSwagger2
@EnableRyFeignClients
@SpringBootApplication
@EnableScheduling//定时器
@ComponentScan("com.ruoyi")
public class RuoYiMallCarApplication {
public static void main(String[] args) {
SpringApplication.run(RuoYiMallCarApplication.class,args);
System.out.println("(♥◠‿◠)ノ゙ 商城 - 购物车模块启动成功 ლ(´ڡ`ლ)゙ ");
}
}

View File

@ -0,0 +1,110 @@
package com.ruoyi.car.config;
import com.ruoyi.common.rabbit.config.RabbitMQConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.*;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.amqp.support.converter.MessageConverter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import javax.annotation.PostConstruct;
@Configuration
public class CarRabbitMQConfig implements RabbitTemplate.ConfirmCallback,RabbitTemplate.ReturnsCallback{
public static final String QUEUE = "msgQueue";
public static final String EXCHANGE = "msgExchange";
public static final String ROUTINGKEY = "msgKey";
public static final Logger logger = LoggerFactory.getLogger(RabbitMQConfig.class);
@Autowired
private RabbitTemplate rabbitTemplate;
//创建消息转换器
@Bean
public MessageConverter messageConverter(){
return new Jackson2JsonMessageConverter();
}
@Bean
public Queue queue(){
return new Queue(QUEUE,true);
}
@Bean
public DirectExchange directExchange(){
return new DirectExchange(EXCHANGE);
}
@Bean
public Binding binding(){
return BindingBuilder.bind(queue()).to(directExchange()).with(ROUTINGKEY);
}
// @Primary
// @Bean
// public RabbitTemplate rabbitTemplate(ConnectionFactory connectionFactory){
// RabbitTemplate rabbitTemplate = new RabbitTemplate(connectionFactory);
// rabbitTemplate.setMessageConverter(messageConverter());
//
// this.rabbitTemplate = rabbitTemplate;
// rabbitTemplate();
// return rabbitTemplate;
// }
/**
* :使
* @param connectionFactory
* @return
*/
// @Bean
// public RabbitTransactionManager transactionManager(ConnectionFactory connectionFactory){
// return new RabbitTransactionManager(connectionFactory);
// }
@PostConstruct
public void rabbitTemplate(){
rabbitTemplate.setConfirmCallback(this);
rabbitTemplate.setReturnsCallback(this);
}
@Override
public void confirm(CorrelationData correlationData, boolean ack, String s) {
if (ack){
logger.info("{}消息到达交换机",correlationData.getId());
}else {
logger.info("{}消息丢失", correlationData.getId());
}
}
@Override
public void returnedMessage(ReturnedMessage returnedMessage) {
logger.error("{}消息未到达队列",returnedMessage.getMessage().getMessageProperties().getMessageId());
}
}

View File

@ -0,0 +1,24 @@
package com.ruoyi.car.config;
import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
@Component
@Data
@ConfigurationProperties(prefix = "pay.ali")
public class PayConfig {
@Value("${pay.ali.appid}")
private String appid;
private String gatewayUrl;
private String privateKey;
private String notifyUrl;
private String returnUrl;
private String format = "json";
private String charset;
private String alipayPublicKey;
private String signType;
}

View File

@ -0,0 +1,24 @@
package com.ruoyi.car.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.GenericToStringSerializer;
import org.springframework.data.redis.serializer.StringRedisSerializer;
@Configuration
public class RedisTemplateConfig {
@Bean
public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory connectionFactory) {
RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>();
redisTemplate.setConnectionFactory(connectionFactory);
GenericToStringSerializer genericToStringSerializer = new GenericToStringSerializer(Object.class);
redisTemplate.setValueSerializer(genericToStringSerializer);
redisTemplate.setKeySerializer(new StringRedisSerializer());
redisTemplate.afterPropertiesSet();
return redisTemplate;
}
}

View File

@ -0,0 +1,44 @@
package com.ruoyi.car.consumer;
import com.ruoyi.car.config.CarRabbitMQConfig;
import com.ruoyi.common.redis.service.RedisService;
import com.rabbitmq.client.Channel;
import com.ruoyi.mall.car.domain.OrderAssociation;
import lombok.extern.log4j.Log4j2;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
//监听队列
@RabbitListener(queues = CarRabbitMQConfig.QUEUE)
@Log4j2
public class RabbitConsumer {
@Autowired
private RedisService redisService;
@RabbitHandler
public void pushOrder(OrderAssociation orderAssociation, Channel channel, Message message) {
String messageId = message.getMessageProperties().getMessageId();
long deliveryTag = message.getMessageProperties().getDeliveryTag();
log.info("messageId:" + messageId, "签证:" + deliveryTag);
redisService.setCacheObject("orderAssociation:",orderAssociation);
try {
log.info("订单信息已经保存:"+orderAssociation);
System.out.println("mq中的消息"+orderAssociation);
// 确认消息已被消费
channel.basicNack(deliveryTag,false,false);
} catch (Exception e) {
log.info("处理订单失败"+e.getMessage());
try {
// 拒绝消息并重新放入队列
channel.basicNack(deliveryTag,false,true);
} catch (Exception ex) {
throw new RuntimeException(ex);
}
throw new RuntimeException(e);
}
}
}

View File

@ -0,0 +1,56 @@
package com.ruoyi.car.controller;
import com.ruoyi.car.service.CarService;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.mall.car.domain.CarDetailInfo;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/car")
@ApiOperation(value = "购物车操作", tags = "首页")
public class CarController {
@Autowired
private CarService carService;
@PostMapping("/addCar")
@ApiOperation("新增购物车信息")
public R addCar(@RequestParam Long skuId, @RequestParam Integer status){
carService.addCar(skuId,status);
return R.ok();
}
@PostMapping("/updateCar")
@ApiOperation("修改购物车数量")
public R updateCarNumber(@RequestParam Long skuId,@RequestParam Integer number){
carService.updateCarNumber(skuId,number);
return R.ok();
}
@PostMapping("/deleteCar")
@ApiOperation("清除购物车")
public R deleteCar(){
carService.deleteCar();
return R.ok();
}
@PostMapping("/selectCarInfo")
@ApiOperation("根据token查询购物车信息")
public R<CarDetailInfo> carInfo(){
return R.ok(carService.selectCarInfo());
}
/**
*
* @param flag
* @return
*/
@PostMapping("/detail")
@ApiOperation("详情")
public R<CarDetailInfo> getDetail(int flag){
carService.getDetail(flag);
return R.ok();
}
}

View File

@ -0,0 +1,37 @@
package com.ruoyi.car.controller;
import com.ruoyi.car.service.OrderService;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.mall.car.domain.request.OrderRequest;
import com.ruoyi.mall.car.domain.response.OrderDetailResp;
import io.swagger.annotations.ApiOperation;
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.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
*
*/
@ApiOperation(value = "订单操作", tags = "首页")
@RestController
@RequestMapping("/order")
public class OrderController {
@Autowired
private OrderService orderService;
@ApiOperation("创建订单")
@PostMapping("/info")
public R<Long> createOrder(@RequestBody OrderRequest orderRequest){
return R.ok(orderService.createOrder(orderRequest));
}
@ApiOperation("订单详情")
@PostMapping("/getOrderDetail")
public R<List<OrderDetailResp>> getOrderDetail(@RequestBody OrderRequest orderRequest){
List<OrderDetailResp> orderDetail = orderService.getOrderDetail(orderRequest);
return R.ok(orderDetail);
}
}

View File

@ -0,0 +1,54 @@
package com.ruoyi.car.img;
import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
public class ImgMain {
public static void main(String[] args) {
/**
* http://127.0.0.1:9300/statics/2024/05/10/wallhaven-g7elo3_20240510152959A001.jpg
*/
// String inputImagePath = "http://127.0.0.1:9300/statics/2024/05/10/wallhaven-g7elo3_20240510152959A001.jpg";
//图片路径
String inputImagePath = "D:\\wallhaven-g7elo3.jpg";
// 输出图片路径
String outputImagePath ="D:\\wallhavenTarget.jpg";
/**
*
*/
int targetWidth =180;
int targetHeight =180;
try {
BufferedImage inputImage = ImageIO.read(new File(inputImagePath));
// 获取原始图片尺寸
int originalWidth = inputImage.getWidth();
int originalHeight = inputImage.getHeight();
// 创建一个新的BufferedImage 存放出来后的图片
BufferedImage outputImage = new BufferedImage(targetWidth, targetHeight, inputImage.getType());
// 创建一个 Graphics2D 对象,用于绘制新图片
Graphics2D graphics =outputImage.createGraphics();
//如果原始图片大于目标尺寸,进行压缩
if (originalWidth > targetWidth || originalHeight > targetHeight){
Image scaledImage = inputImage.getScaledInstance(targetWidth,targetHeight,Image.SCALE_SMOOTH);
graphics.drawImage(scaledImage,0,0,null);
}else {
// 如果原始尺寸小于目标尺寸 进行拉伸
graphics.drawImage(inputImage,0,0,targetWidth,targetHeight,null);
}
//释放资源
graphics.dispose();
// 保存处理后的图片
ImageIO.write(outputImage,"jpg",new File(outputImagePath));
System.out.println("输出路径为"+outputImagePath+"宽高为"+targetWidth+"*"+targetHeight);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}

View File

@ -0,0 +1,117 @@
package com.ruoyi.car.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.mall.car.domain.CarAssociation;
import com.ruoyi.mall.car.domain.CarInfo;
import com.ruoyi.mall.car.domain.OrderInfo;
import com.ruoyi.mall.product.domain.MallProductInfo;
import com.ruoyi.mall.product.domain.MallProductSkuInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.math.BigDecimal;
import java.util.List;
@Mapper
public interface CarMapper extends BaseMapper<CarInfo> {
/**
* carId
* @return
*/
CarInfo findByCarInfo(@Param("carId") String carId);
/**
*
*/
void addCarAssociation(CarAssociation carAssociation);
/**
* carId
*/
CarAssociation findByCarAssociationByCarId(@Param("carId") String carId);
/**
*sku
* skuIdsku
*/
MallProductSkuInfo findByMallProductSkuInfo(@Param("id") Long id);
/**
*
*/
void updateCarNumber(CarInfo carInfo);
/**
* id
* @param carId
* @return
*/
CarAssociation findByCarAssociation(Long carId);
/**
*
* @return
*/
// CarAssociation selectCarAssociation();
/**
*
*/
void deleteCar(@Param("carId") String carId);
/**
* (2)
* @param id
*/
void deleteCarAssociation(@Param("id") Long id);
/**
* idcar carId
*/
CarInfo findByUserIdGetByCarId(@Param("userId") Long userId);
/**
*
* @param id
* @return
*/
List<MallProductSkuInfo> selectProductList(@Param("id") Long id);
/**
*
* @param skuId
* @return
*/
MallProductInfo selectProductInfo(Long skuId);
/**
* skuId
*/
CarInfo selectFindSkuIdByCar(@Param("skuId") Long skuId);
/**
* skuId
*/
CarAssociation selectCarAssociationBySkuId(@Param("skuId") Long skuId);
/**
* skuIds
* @param skuIds
* @return
*/
MallProductSkuInfo selectSkuIds(List<Long> skuIds);
/**
* id
* @param userId
* @return
*/
BigDecimal findSumPrice(@Param("userId") Long userId);
/**
*
* @return
*/
List<OrderInfo> selectOrderInfo();
}

View File

@ -0,0 +1,23 @@
package com.ruoyi.car.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.mall.car.domain.OrderAssociation;
import com.ruoyi.mall.car.domain.OrderInfo;
import com.ruoyi.mall.car.domain.response.OrderDetailResp;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper
public interface OrderMapper extends BaseMapper<OrderInfo> {
/**
*
* @param orderAssociation
* @return
*/
void insertOrderAssociation(OrderAssociation orderAssociation);
/**
*
* @return
*/
List<OrderDetailResp> selectOrderList();
}

View File

@ -0,0 +1,79 @@
package com.ruoyi.car.pay;
import com.alibaba.fastjson2.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;
/* *
*AlipayConfig
*
*
*2017-04-05
*
*便,使
*使
*/
public class AlipayConfig {
public static void main(String[] args) throws AlipayApiException {
AlipayClient alipayClient = new DefaultAlipayClient(
// 支付宝网关地址
"https://openapi-sandbox.dl.alipaydev.com/gateway.do",
"9021000136690041",
"MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCexq+5q7A8QZBhRicv2gqG7k/5H2PhHYJ60QXnWwvbzixgZcEVJU1aRHFZxrSxQ2TZE7gQniPy0Gnob9xuhACytEA2XloKS1/pzP94qdF3wRj85irTTT+Wc3GLH7Oatd7zbDx2tiospsNy13PPFWnMbla+9TVV3ix9AHF4YD+pnacWSBPJoAgg/Jx1JOHBj4ffMCXHPlln5Zd46f9nUzpbtagmiIEAPj8Mz4dRnU7HXMOKr4MDiYkYBVdcrMdYGl8UOU/35a8RCjrpKPtkF+pbRoD75l+cVxmhfWdce5qqwi88CiMkQkopV4o9hEc08lGX+y30rIA57sv5TnDTbfzlAgMBAAECggEAFZnKRmRJMalpzxIQOr5bOEgrsSTIHdQ58COHvhXw4xKFjwfI4OuWPnWZRjF2W7djfPTl0bzx/xLDlc/CGXbz8Vv8cGkdrtDaV6CAERZpXPV0RNO7d8vGnt1N0TOa561ei5dqEmxuCG0XogQVyVKMdjd8rbYGb4wuWUM6LLpLbvPAwVgAHZMkX7h1/GdCfsfiVgFTYFer5tgFSMoYxORXJeDzwUqHnqf5lXll8SYeO8MW+GkKhvDohtswSeA3xPaZ0MKpXo3F60pog71TKoek1FQ15CaA14SSaXIe8HD3wLWqhKfeSM5xow/DQAx48i+3EqzZYsPTz48Tw3+0iqdicQKBgQDawj8eoC+DfJdCu4S5dWCi8UcQmanlp4T5TBQ4wld2CbO/KtW/Nu7KVoIAN6n7p0DyiMQboSqBCP6Vg8bpxGTJWmqzxeHHUJTu9UbIor1/QXP+/26NPKu+VjprIH5+E5T66ZZvzcCCntckBr3X7FvsnH+KvIjGkkJ53jcu5rmwZwKBgQC5zlQHCH+8uLNI0T+3HK6TN4nyj3WM8jlzUByX7f77RQbNPXEJayUvL7psCd6rZA/LKh3adtSnId6zAEbdxdShHUDTDwK+QrA4XdZJClEiSXR/OC23GKbSczbM17pDefbJrMUoz07UtJx4mGfFHWKPo0fWrtv8K6rY3Yvxk7Ko0wKBgQDDKbDuPbKl961q16idXF6Of/sKkEzGmiFD19/ik18764P09N4k7Xk0AuGQGBkKbji/J8ztaWdmHwQhl6MKQzA3gvbW05+OFhII7cHslWPB+D7oLDIQxyPhd0Q+9opjKE0tXN/ddw5ceiEt/uW3kSKhgS04NONBZJLx7pIEwcq/2QKBgHb3vyGJtZA2isSzBiLOgJDOXMssQ83tQg+tWcGFp19nQQWks32eVv6xhqGqaCJBPUOOQfMhZuNkcl0WbkmNY6mNO3ZoBA+iT4anvo6hxnU3pxnV9J9pb1cMYigicKbHrtZOgyawJf9XbWBh5P924yapG1RAPaZmp0uX/wS81wX1AoGBAM+IjIJT9s8DWotmo4XPAIj4ILrZfGkSBBBJwVgwmyj5XXbU6OMWdZxzjgPpBheTgcNxb6bcywF0KsMee/9bLy2SYcAX6+50j2OUp3stbmFYxNNDDgo8KV/xpweWDQYWr3QZVDUm28G1UdSgau1ohD6op8IACpBqdHWXwQhuq8p7\n",
"json",
"UTF-8",
"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtIR3PTbTkyGY4GNeDOT+dhGq9Mdxn7oDspHABx0ZvMb0gMAwNMOkCJHRlXD+WB1E1SIEYFfC8iyB/n7EZ7xKsEkIqydx3RNq/GMXtOuGoPpLRqBbQJKhXoiOZy10iCu/eR3uQvS/rIJVK6Fy686Vd0+SrCx4M1u1E9tuenhjyQ+5r7/IpnWD+6Z/J2cmYLxDCJ771nsBSFtX6u+QhNN0WLtjwdkHV5ixqYXNoyjjHpoh5sfz5jDEW4bP0nmtSiFyWF6UAh19f1iBmeJ3wKBYXIRy9pNeqWLmDST2yqhDK/H0NWak/akZcbXnRBzWt72bwseqrcs0OQD/x+qJHI0tuQIDAQAB\n",
"RSA2");
AlipayTradePagePayRequest request = new AlipayTradePagePayRequest();
//异步接收地址仅支持http/https公网可访问
request.setNotifyUrl("");
//同步跳转地址仅支持http/https
request.setReturnUrl("");
/******必传参数******/
JSONObject bizContent = new JSONObject();
//商户订单号,商家自定义,保持唯一性
bizContent.put("out_trade_no", "20210817010101004");
//支付金额最小值0.01元
bizContent.put("total_amount", 0.01);
//订单标题,不可使用特殊符号
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", 0.01);
//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("调用失败");
}
}
}

View File

@ -0,0 +1,46 @@
package com.ruoyi.car.pay.PayController;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.car.config.PayConfig;
import com.ruoyi.car.pay.service.PayService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Map;
@RestController
@RequestMapping("/pay")
public class PayController {
@Autowired
private PayService payService;
@Autowired
PayConfig payConfig;
@GetMapping("/toPay")
public void createOrder(@RequestParam Long orderId, HttpServletResponse response) {
// payService.toPay(orderId);
response.setContentType("text/html;charset=" + payConfig.getCharset());
try {
response.getWriter().write(payService.toPay(orderId));
response.getWriter().flush();
response.getWriter().close();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
@PostMapping("/notify")
public R notify(HttpServletRequest request) {
// 从request中获取所有参数
Map<String, String[]> parameterMap = request.getParameterMap();
for (String key : parameterMap.keySet()) {
String[] values = parameterMap.get(key);
for (String value : values) {
System.out.println(key + ":" + value);
}
}
return R.ok();
}
}

View File

@ -0,0 +1,5 @@
package com.ruoyi.car.pay.service;
public interface PayService {
public String toPay(Long orderId);
}

View File

@ -0,0 +1,100 @@
package com.ruoyi.car.pay.service.impl;
import com.alibaba.fastjson2.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;
import com.ruoyi.car.config.PayConfig;
import com.ruoyi.car.pay.service.PayService;
import com.ruoyi.common.redis.service.RedisService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
@Slf4j
public class PayServiceImpl implements PayService {
@Autowired
private PayConfig payConfig;
@Autowired
private RedisService redisService;
@Override
public String toPay(Long orderId) {
AlipayClient alipayClient = new DefaultAlipayClient(
// 支付宝网关地址
"https://openapi-sandbox.dl.alipaydev.com/gateway.do",
"9021000136690041",
"MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCexq+5q7A8QZBhRicv2gqG7k/5H2PhHYJ60QXnWwvbzixgZcEVJU1aRHFZxrSxQ2TZE7gQniPy0Gnob9xuhACytEA2XloKS1/pzP94qdF3wRj85irTTT+Wc3GLH7Oatd7zbDx2tiospsNy13PPFWnMbla+9TVV3ix9AHF4YD+pnacWSBPJoAgg/Jx1JOHBj4ffMCXHPlln5Zd46f9nUzpbtagmiIEAPj8Mz4dRnU7HXMOKr4MDiYkYBVdcrMdYGl8UOU/35a8RCjrpKPtkF+pbRoD75l+cVxmhfWdce5qqwi88CiMkQkopV4o9hEc08lGX+y30rIA57sv5TnDTbfzlAgMBAAECggEAFZnKRmRJMalpzxIQOr5bOEgrsSTIHdQ58COHvhXw4xKFjwfI4OuWPnWZRjF2W7djfPTl0bzx/xLDlc/CGXbz8Vv8cGkdrtDaV6CAERZpXPV0RNO7d8vGnt1N0TOa561ei5dqEmxuCG0XogQVyVKMdjd8rbYGb4wuWUM6LLpLbvPAwVgAHZMkX7h1/GdCfsfiVgFTYFer5tgFSMoYxORXJeDzwUqHnqf5lXll8SYeO8MW+GkKhvDohtswSeA3xPaZ0MKpXo3F60pog71TKoek1FQ15CaA14SSaXIe8HD3wLWqhKfeSM5xow/DQAx48i+3EqzZYsPTz48Tw3+0iqdicQKBgQDawj8eoC+DfJdCu4S5dWCi8UcQmanlp4T5TBQ4wld2CbO/KtW/Nu7KVoIAN6n7p0DyiMQboSqBCP6Vg8bpxGTJWmqzxeHHUJTu9UbIor1/QXP+/26NPKu+VjprIH5+E5T66ZZvzcCCntckBr3X7FvsnH+KvIjGkkJ53jcu5rmwZwKBgQC5zlQHCH+8uLNI0T+3HK6TN4nyj3WM8jlzUByX7f77RQbNPXEJayUvL7psCd6rZA/LKh3adtSnId6zAEbdxdShHUDTDwK+QrA4XdZJClEiSXR/OC23GKbSczbM17pDefbJrMUoz07UtJx4mGfFHWKPo0fWrtv8K6rY3Yvxk7Ko0wKBgQDDKbDuPbKl961q16idXF6Of/sKkEzGmiFD19/ik18764P09N4k7Xk0AuGQGBkKbji/J8ztaWdmHwQhl6MKQzA3gvbW05+OFhII7cHslWPB+D7oLDIQxyPhd0Q+9opjKE0tXN/ddw5ceiEt/uW3kSKhgS04NONBZJLx7pIEwcq/2QKBgHb3vyGJtZA2isSzBiLOgJDOXMssQ83tQg+tWcGFp19nQQWks32eVv6xhqGqaCJBPUOOQfMhZuNkcl0WbkmNY6mNO3ZoBA+iT4anvo6hxnU3pxnV9J9pb1cMYigicKbHrtZOgyawJf9XbWBh5P924yapG1RAPaZmp0uX/wS81wX1AoGBAM+IjIJT9s8DWotmo4XPAIj4ILrZfGkSBBBJwVgwmyj5XXbU6OMWdZxzjgPpBheTgcNxb6bcywF0KsMee/9bLy2SYcAX6+50j2OUp3stbmFYxNNDDgo8KV/xpweWDQYWr3QZVDUm28G1UdSgau1ohD6op8IACpBqdHWXwQhuq8p7\n",
"json",
"UTF-8",
"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtIR3PTbTkyGY4GNeDOT+dhGq9Mdxn7oDspHABx0ZvMb0gMAwNMOkCJHRlXD+WB1E1SIEYFfC8iyB/n7EZ7xKsEkIqydx3RNq/GMXtOuGoPpLRqBbQJKhXoiOZy10iCu/eR3uQvS/rIJVK6Fy686Vd0+SrCx4M1u1E9tuenhjyQ+5r7/IpnWD+6Z/J2cmYLxDCJ771nsBSFtX6u+QhNN0WLtjwdkHV5ixqYXNoyjjHpoh5sfz5jDEW4bP0nmtSiFyWF6UAh19f1iBmeJ3wKBYXIRy9pNeqWLmDST2yqhDK/H0NWak/akZcbXnRBzWt72bwseqrcs0OQD/x+qJHI0tuQIDAQAB\n",
"RSA2");
AlipayTradePagePayRequest request = new AlipayTradePagePayRequest();
//异步接收地址仅支持http/https公网可访问
request.setNotifyUrl(payConfig.getNotifyUrl());
//同步跳转地址仅支持http/https
request.setReturnUrl(payConfig.getReturnUrl());
/******必传参数******/
// Object cacheObject = redisService.getCacheObject("orderId:"+orderId);
// if (cacheObject == null){
// throw new RuntimeException("订单不存在");
// }
// OrderInfo orderInfo = JSONObject.parseObject(JSONObject.toJSONString(cacheObject), OrderInfo.class);
JSONObject bizContent = new JSONObject();
//商户订单号,商家自定义,保持唯一性
bizContent.put("out_trade_no", orderId);
//支付金额最小值0.01元
bizContent.put("total_amount", 0.01);
//订单标题,不可使用特殊符号
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", 0.01);
//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 = null;
try {
response = alipayClient.pageExecute(request, "POST");
} catch (AlipayApiException e) {
throw new RuntimeException("調用支付网关异常,");
}
// 如果需要返回GET请求请使用
// AlipayTradePagePayResponse response = alipayClient.pageExecute(request,"GET");
String pageRedirectionData = response.getBody();
log.info(pageRedirectionData);
if (response.isSuccess()) {
log.info("调用成功");
return pageRedirectionData;
} else {
log.error("调用失败");
throw new RuntimeException("调通支付网关异常!");
}
}
}

View File

@ -0,0 +1,30 @@
package com.ruoyi.car.producer;
import com.ruoyi.car.config.CarRabbitMQConfig;
import com.ruoyi.common.core.utils.uuid.UUID;
import com.ruoyi.mall.car.domain.OrderAssociation;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
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.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/mq")
public class Producer {
@Autowired
private RabbitTemplate rabbitTemplate;
@PostMapping("pushOrder2")
public void pushOrder(@RequestBody OrderAssociation orderAssociation) {
rabbitTemplate.convertAndSend(CarRabbitMQConfig.EXCHANGE, CarRabbitMQConfig.ROUTINGKEY, orderAssociation,
message -> {
message.getMessageProperties().setMessageId(UUID.randomUUID().toString());
return message;
}, new CorrelationData(UUID.randomUUID().toString()));
}
}

View File

@ -0,0 +1,34 @@
package com.ruoyi.car.producer;
import com.ruoyi.car.config.CarRabbitMQConfig;
import com.ruoyi.common.core.utils.uuid.UUID;
import com.ruoyi.mall.car.domain.OrderAssociation;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
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.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* mq
*/
@RestController
@RequestMapping("/mq")
public class RabbitProducer {
@Autowired
private RabbitTemplate rabbitTemplate;
@PostMapping("/pushOrder")
public void pushOrder(@RequestBody OrderAssociation orderAssociation){
rabbitTemplate.convertAndSend(CarRabbitMQConfig.EXCHANGE,CarRabbitMQConfig.ROUTINGKEY,orderAssociation,
message -> {
//唯一标识 生成UUID作为消息ID 讲ID设置到消息的属行中
message.getMessageProperties().setMessageId(UUID.randomUUID().toString());
return message;
},new CorrelationData(UUID.randomUUID().toString()));
}
}

View File

@ -0,0 +1,38 @@
package com.ruoyi.car.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.mall.car.domain.CarDetailInfo;
import com.ruoyi.mall.car.domain.CarInfo;
public interface CarService extends IService<CarInfo> {
/**
*
* @param skuId
* @param status
*/
void addCar(Long skuId, Integer status);
/**
*
* @param skuId
* @param number
*/
void updateCarNumber(Long skuId, Integer number);
/**
*
*/
void deleteCar();
/**
*
* @return
*/
CarDetailInfo selectCarInfo();
CarDetailInfo getDetail(int flag);
// BigDecimal getTotalPrice(List<Long> skuIds);
}

View File

@ -0,0 +1,29 @@
package com.ruoyi.car.service;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.mall.car.domain.OrderInfo;
import com.ruoyi.mall.car.domain.request.OrderRequest;
import com.ruoyi.mall.car.domain.response.OrderDetailResp;
import java.util.List;
/**
*
*/
public interface OrderService extends IService<OrderInfo> {
/**
*
* @param orderRequest
* @return
*/
Long createOrder(OrderRequest orderRequest);
/**
*
* @param orderRequest
* @return
*/
List<OrderDetailResp> getOrderDetail(OrderRequest orderRequest);
}

View File

@ -0,0 +1,279 @@
package com.ruoyi.car.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.car.mapper.CarMapper;
import com.ruoyi.car.service.CarService;
import com.ruoyi.common.redis.service.RedisService;
import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.mall.car.domain.*;
import com.ruoyi.mall.product.domain.MallProductInfo;
import com.ruoyi.mall.product.domain.MallProductSkuInfo;
import com.ruoyi.system.domain.model.LoginUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;
@Service
public class CarServiceImpl extends ServiceImpl<CarMapper, CarInfo>
implements CarService {
@Autowired
private CarMapper carMapper;
@Autowired
private RedisService redisService;
@Override
public void addCar(Long skuId, Integer status) {
// 1添加数量 2-减少数量
if (skuId == null || status != 1 && status != 2) {
throw new RuntimeException("skuId不存在 或状态值不合法");
}
// 根据用户id查询购物车id购物车信息表
LoginUser loginUser = SecurityUtils.getLoginUser();
Long userid = loginUser.getUserid();
CarAssociation byCarAssociation = carMapper.findByCarAssociation(userid);
//不存在 新增一条
if (byCarAssociation == null) {
// 根据传过来的skuId获取信息 skuInfo
MallProductSkuInfo skuInfo = carMapper.findByMallProductSkuInfo(skuId);
CarInfo carInfo = new CarInfo();
String uuId = UUID.randomUUID().toString();
carInfo.setCarId(uuId);
carInfo.setNumber(1);
carInfo.setUserId(userid);
carInfo.setSkuId(skuInfo.getId());
carInfo.setCreateBy(SecurityUtils.getUsername());
carInfo.setCreateTime(new Date());
//新增购物车表
this.save(carInfo);
//增加购物车关联表
CarAssociation carAssociation = CarAssociation.builder()
.carId(carInfo.getCarId())
.userId(userid)
.build();
carMapper.addCarAssociation(carAssociation);
} else if (status == 1){
// 存在则修改数量(+1
List<CarInfo> carInfoList = this.list();
//TODO stream流过滤
carInfoList.stream()
.filter(info -> info.getSkuId().equals(skuId))
.forEach(info -> {
info.setNumber(info.getNumber() + 1);
info.setUpdateTime(new Date());
carMapper.updateCarNumber(info);
});
}else {
List<CarInfo> carInfoList = this.list();
carInfoList.stream()
.filter(info -> info.getSkuId().equals(skuId))
.forEach(info -> {
info.setNumber(info.getNumber() - 1);
info.setUpdateTime(new Date());
carMapper.updateCarNumber(info);
});
}
}
@Override
public void updateCarNumber(Long skuId, Integer number) {
if (skuId == null || number<0 ) {
throw new RuntimeException("skuId不存在,或数量不合法");
}
// 根据用户id查询购物车id购物车信息表
LoginUser loginUser = SecurityUtils.getLoginUser();
Long userid = loginUser.getUserid();
CarAssociation byCarAssociation = carMapper.findByCarAssociation(userid);
if (byCarAssociation == null){
throw new RuntimeException("购物车内无信息!");
}
// 根据关联的购物车id 修改 购物车数量 f0ca9549-3001-4e8a-8fb6-1316442c432e
CarAssociation carInfos = carMapper.findByCarAssociationByCarId(byCarAssociation.getCarId());
// TODO Mybatis-Plus不能用 这里的carId不是主键!----> CarInfo carInfo = this.getById(carInfos.getCarId());
CarInfo byCarInfo = carMapper.findByCarInfo(carInfos.getCarId());
byCarInfo.setNumber(number);
this.updateById(byCarInfo);
}
@Override
public void deleteCar() {
// 根据用户id查询购物车id购物车信息表
LoginUser loginUser = SecurityUtils.getLoginUser();
Long userid = loginUser.getUserid();
// 根据token找到购物车id
CarAssociation byCarAssociation = carMapper.findByCarAssociation(userid);
carMapper.deleteCar(byCarAssociation.getCarId());
carMapper.deleteCarAssociation(byCarAssociation.getId());
}
@Override
public CarDetailInfo selectCarInfo() {
CarDetailInfo carDetailInfo =new CarDetailInfo();
String carId = getCarId();
// 根据购物车id 查询购物车信息
LambdaQueryWrapper<CarInfo> queryWrapper = new LambdaQueryWrapper<CarInfo>() {{
eq(CarInfo::getCarId, carId);
}};
CarInfo carInfo = getOne(queryWrapper);
// TODO 数据库查询信息 findByCarId 根据carId
// 根据购物车中的skuId 获取 购物车详情信息
// 返回对象.
MallProductSkuInfo skuInfo = carMapper.findByMallProductSkuInfo(carInfo.getSkuId());
if (skuInfo == null){
throw new RuntimeException("没有查到信息");
}
if (skuInfo.getId() == null){
throw new RuntimeException("skuId不存在");
}
// 根据skuid查询 信息
List<MallProductSkuInfo> mallProductSkuInfos = carMapper.selectProductList(carInfo.getSkuId());
// 根据购物车id查询商品信息
MallProductInfo productInfo = carMapper.selectProductInfo(carInfo.getSkuId());
List<ProductDetailInfo> productDetailInfoList = new ArrayList<>();
ProductDetailInfo productDetailInfos = new ProductDetailInfo();
mallProductSkuInfos.forEach(item ->{
productDetailInfos.setProductTitle(item.getSku());
productDetailInfos.setSkuImg(item.getImage());
productDetailInfos.setSkuId(item.getId());
productDetailInfos.setName(productInfo.getName());
productDetailInfos.setPrice(item.getPrice());
productDetailInfos.setProductTitle(item.getSku());
productDetailInfos.setBuyNumber(Integer.valueOf(item.getNumber()));
productDetailInfoList.add(productDetailInfos);
carDetailInfo.setProductDetailInfoList(productDetailInfoList);
});
// 如果redis有这个数据 直接查出来返回
if (redisService.hasKey("list")){
List<ProductDetailInfo> list = redisService.getCacheList("list");
for (ProductDetailInfo productDetailInfo : list) {
productDetailInfoList.add(productDetailInfo);
carDetailInfo.setProductDetailInfoList(productDetailInfoList);
return carDetailInfo;
}
}
redisService.setCacheList("list",productDetailInfoList);
return carDetailInfo;
}
@Override
public CarDetailInfo getDetail(int flag) {
Long userId = SecurityUtils.getUserId();
CarDetailInfo carDetailInfo =new CarDetailInfo();
String carId = getCarId();
// 根据购物车id 查询购物车信息
LambdaQueryWrapper<CarInfo> queryWrapper = new LambdaQueryWrapper<CarInfo>() {{
eq(CarInfo::getCarId, carId);
}};
CarInfo carInfo = getOne(queryWrapper);
// TODO 数据库查询信息 findByCarId 根据carId
// 根据购物车中的skuId 获取 购物车详情信息
// 返回对象.
MallProductSkuInfo skuInfo = carMapper.findByMallProductSkuInfo(carInfo.getSkuId());
if (skuInfo == null){
throw new RuntimeException("没有查到信息");
}
if (skuInfo.getId() == null){
throw new RuntimeException("skuId不存在");
}
// 根据skuid查询 信息
List<MallProductSkuInfo> mallProductSkuInfos = carMapper.selectProductList(carInfo.getSkuId());
// 根据购物车id查询商品信息
MallProductInfo productInfo = carMapper.selectProductInfo(carInfo.getSkuId());
List<ProductDetailInfo> productDetailInfoList = new ArrayList<>();
ProductDetailInfo productDetailInfos = new ProductDetailInfo();
mallProductSkuInfos.forEach(item ->{
productDetailInfos.setProductTitle(item.getSku());
productDetailInfos.setSkuImg(item.getImage());
productDetailInfos.setSkuId(item.getId());
productDetailInfos.setName(productInfo.getName());
productDetailInfos.setPrice(item.getPrice());
productDetailInfos.setProductTitle(item.getSku());
productDetailInfoList.add(productDetailInfos);
carDetailInfo.setProductDetailInfoList(productDetailInfoList);
// 拿到ids 集合
});
List<Long> skuIds = productDetailInfoList.stream().map(ProductDetailInfo::getSkuId).collect(Collectors.toList());
// TODO 计算价格
// 或 总价
carDetailInfo.setPriceDetail(getPriceDetail(productDetailInfoList));
// TODO 优惠券id
carDetailInfo.setCouponList(getCouponList(userId));
if (flag == 1){
carDetailInfo.setCouponList(getCouponList(userId));
}
return carDetailInfo;
}
// @Override
// public BigDecimal getTotalPrice(List<Long> skuIds) {
// Long userId = SecurityUtils.getUserId();
// carMapper.selectSkuIds(skuIds);
//// TODO 通过skuId查询
// return null;
// }
private List<Coupon> getCouponList(Long userId) {
// TODO 优惠券id 根据userId获取 关联查询优惠券列表
return null;
}
// 价格详情 计算价格
private PriceDetail getPriceDetail(List<ProductDetailInfo> productDetailInfoList) {
// 总价
BigDecimal totalPrice = new BigDecimal(0);
for (ProductDetailInfo productDetailInfo : productDetailInfoList) {// 总价
// 单品总价
BigDecimal multiply = productDetailInfo.getPrice().multiply(new BigDecimal(productDetailInfo.getBuyNumber()));
totalPrice = totalPrice.add(multiply);
// 会员优惠价
BigDecimal memberPrice = new BigDecimal(0);
if (true){
memberPrice = totalPrice.multiply(new BigDecimal(0.01));
}
// 最终价
BigDecimal finalPrice = totalPrice.subtract(memberPrice);
PriceDetail priceDetail = new PriceDetail();
priceDetail.setTotalPrice(totalPrice);
priceDetail.setMemberPrice(memberPrice);
priceDetail.setFinalPrice(finalPrice);
return priceDetail;
}
return null;
}
private String getCarId() {
// 根据用户id查询购物车id
LoginUser loginUser = SecurityUtils.getLoginUser();
if (loginUser == null){
throw new RuntimeException("用户不存在");
}
Long userid = loginUser.getUserid();
if (userid == 0L){
throw new RuntimeException("用户未登录");
}
// 根据用户id查询购物车
CarInfo carInfo = carMapper.findByUserIdGetByCarId(userid);
String carId = carInfo.getCarId();
if (carId == null){
throw new RuntimeException("该用户没有购物车");
}
return carId;
}
}

View File

@ -0,0 +1,154 @@
package com.ruoyi.car.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.car.mapper.CarMapper;
import com.ruoyi.car.mapper.OrderMapper;
import com.ruoyi.car.producer.RabbitProducer;
import com.ruoyi.car.service.OrderService;
import com.ruoyi.common.redis.service.RedisService;
import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.mall.car.domain.CarInfo;
import com.ruoyi.mall.car.domain.OrderAssociation;
import com.ruoyi.mall.car.domain.OrderInfo;
import com.ruoyi.mall.car.domain.PriceDetail;
import com.ruoyi.mall.car.domain.request.OrderRequest;
import com.ruoyi.mall.car.domain.response.OrderDetailResp;
import com.ruoyi.mall.product.domain.MallProductInfo;
import com.ruoyi.mall.product.domain.MallProductSkuInfo;
import com.ruoyi.system.domain.model.LoginUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Random;
import java.util.Set;
import java.util.stream.Collectors;
@Service
public class OrderServiceImpl extends ServiceImpl<OrderMapper, OrderInfo>
implements OrderService {
@Autowired
private OrderMapper orderMapper;
@Autowired
private CarMapper carMapper;
@Autowired
private RedisService redisService;
@Autowired
private RabbitProducer rabbitProducer;
@Override
public Long createOrder(OrderRequest orderRequest) {
List<OrderInfo> orderInfos = carMapper.selectOrderInfo();
List<Long> skuIds = orderInfos.stream()
.map(OrderInfo::getSkuId).collect(Collectors.toList());
// 获取用户id
LoginUser loginUser = SecurityUtils.getLoginUser();
Long userid = loginUser.getUserid();
if (userid == 0L) {
throw new RuntimeException("用户未登录");
}
OrderInfo orderInfo = new OrderInfo();
// 购物车信息
CarInfo carInfo = this.carMapper.findByUserIdGetByCarId(userid);
// 根据购物车信息 获取sku信息
MallProductSkuInfo skuInfo = carMapper.findByMallProductSkuInfo(carInfo.getSkuId());
MallProductInfo productInfo = this.carMapper.selectProductInfo(skuInfo.getId());
// 给订单赋值 生成订单编号
orderInfo.setOrderId(Long.parseLong(
System.currentTimeMillis()
+ String.format("%05d", new Random().nextInt(90000) + 10000)
));
redisService.setCacheObject("orderId:", orderInfo.getOrderId());
orderInfo.setTotalPrice(getTotalPrice(orderRequest));
orderInfo.setUserId(userid);
orderInfo.setSkuId(skuInfo.getId());
orderInfo.setSkuId(skuInfo.getId());
orderInfo.setCreateTime(new Date());
//新增关联表信息
OrderAssociation orderAssociation = OrderAssociation
.builder()
.orderId(orderInfo.getOrderId())
.skuId(skuInfo.getId())
.skuTitle(productInfo.getName())
.image(productInfo.getImg())
.createTime(new Date())
.orderPrice(orderInfo.getTotalPrice())
.stock(skuInfo.getStock())
.build();
orderMapper.insertOrderAssociation(orderAssociation);
//推送到mq
rabbitProducer.pushOrder(orderAssociation);
System.out.println(orderAssociation);
System.out.println(orderInfo);
// 生成订单
this.save(orderInfo);
return orderInfo.getOrderId();
}
@Override
public List<OrderDetailResp> getOrderDetail(OrderRequest orderRequest) {
LoginUser loginUser = SecurityUtils.getLoginUser();
Long userid = loginUser.getUserid();
if (userid == null) {
throw new RuntimeException("请先登录!");
}
List<OrderDetailResp> orderInfos = this.orderMapper.selectOrderList();
if (orderInfos == null) {
throw new RuntimeException("没有该信息");
}
return orderInfos.stream()
.map(orderDetailResp ->
OrderDetailResp.builder()
.orderId(orderDetailResp.getOrderId())
.name(orderDetailResp.getName())
.sku(orderDetailResp.getSku())
.totalPrice(orderDetailResp.getTotalPrice())
.image(orderDetailResp.getImage())
.createTime(orderDetailResp.getCreateTime())
.stock(orderDetailResp.getStock())
.userId(orderDetailResp.getUserId())
.build()
).collect(Collectors.toList());
}
private BigDecimal getTotalPrice(OrderRequest orderRequest) {
LoginUser loginUser = SecurityUtils.getLoginUser();
Long userid = loginUser.getUserid();
if (userid == null) {
throw new RuntimeException("用户信息不存在");
}
PriceDetail priceDetail = new PriceDetail();
BigDecimal sumPrice = carMapper.findSumPrice(userid);
if (sumPrice == null) {
throw new RuntimeException("购物车为空");
}
// 总价赋值
priceDetail.setTotalPrice(sumPrice);
// TODO
Set<String> roles = loginUser.getRoles();
BigDecimal bigDecimal = new BigDecimal(0);
for (String role : roles) {
if ("vip".equals(role)) {
bigDecimal = sumPrice.multiply(new BigDecimal(0.01));
priceDetail.setMemberPrice(bigDecimal);
}
}
CarInfo carInfo = carMapper.findByUserIdGetByCarId(userid);
MallProductSkuInfo skuInfo =
carMapper.findByMallProductSkuInfo(carInfo.getSkuId());
List<MallProductSkuInfo> mallProductSkuInfoList =
carMapper.selectProductList(skuInfo.getId());
// 获取skuIds
List<Long> skuIds = mallProductSkuInfoList.stream().
map(MallProductSkuInfo::getId).collect(Collectors.toList());
orderRequest.setSkuIds(skuIds);
orderRequest.setPayWay(1);
return sumPrice;
}
}

View File

@ -0,0 +1,53 @@
package com.ruoyi.car.sync;
import com.ruoyi.car.mapper.CarMapper;
import com.ruoyi.car.service.CarService;
import com.ruoyi.common.redis.service.RedisService;
import com.ruoyi.mall.car.domain.CarInfo;
import com.ruoyi.mall.car.domain.ProductDetailInfo;
import com.ruoyi.mall.product.domain.MallProductSkuInfo;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.util.Date;
import java.util.List;
@Component
@Log4j2
public class RedisSync {
@Autowired
private RedisService redisService;
@Autowired
private CarService carService;
@Autowired
private CarMapper carMapper;
@Scheduled(cron = "0/5 * * * * ?")
public void getRedisCarInfo() {
List<ProductDetailInfo> list = redisService.getCacheList("list");
System.out.println("缓存中数据" + list);
if (redisService.hasKey("list")) {
for (ProductDetailInfo productDetailInfo : list) {
MallProductSkuInfo skuInfo = carMapper.findByMallProductSkuInfo(productDetailInfo.getSkuId());
Long id = skuInfo.getId();
CarInfo carInfo = carMapper.selectFindSkuIdByCar(id);
carInfo.setCarId(carInfo.getCarId());
carInfo.setNumber(productDetailInfo.getBuyNumber());
carInfo.setSkuId(carInfo.getSkuId());
carInfo.setUpdateTime(new Date());
log.info(carInfo);
if (carInfo.getSkuId().equals(productDetailInfo.getSkuId())) {
carService.updateById(carInfo);
}else {
carService.save(carInfo);
}
}
}
}
}

View File

@ -0,0 +1,2 @@
Spring Boot Version: ${spring-boot.version}
Spring Application Name: ${spring.application.name}

View File

@ -0,0 +1,60 @@
# Tomcat
server:
port: 9306
# Spring
spring:
application:
# 应用名称
name: mall-car
profiles:
# 环境配置
active: dev
cloud:
nacos:
discovery:
# 服务注册地址
server-addr: 115.159.78.103:8848
namespace: 09mall
config:
# 配置中心地址
server-addr: 115.159.78.103:8848
# 配置文件格式
file-extension: yml
# 共享配置
shared-configs:
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
namespace: 09mall
rabbitmq:
host: 115.159.78.103
port: 5672
username: guest
password: guest
main:
# 解决问题的 远程调用覆盖
allow-bean-definition-overriding: true
#支付配置
pay:
#支付宝支付
ali:
#appid
appid: 9021000136690041
#支付宝网关url
gateway-url: https://openapi-sandbox.dl.alipaydev.com
#私有密钥
priave-key: MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCexq
# 回调地址
# notify-url: https://10.1.22.101:9306/pay/notify
notify-url: http://hdkb3x.natappfree.cc/pay/notify/
return-url: https://www.baidu.com/
format: json
#编码格式
charset: UTF-8
#阿里公钥
alipay-public-key: MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtIR3PTbTkyGY4GNeDOT
sign-type:

View File

@ -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.ruoyi" 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>

View File

@ -0,0 +1,107 @@
<?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">
<!--
1.在mybats的开发中namespace有特殊的意思一定要是对应接口的全限定名
通过namespace可以简历mapper.xml和接口之间的关系(名字不重要,位置不重要)
-->
<mapper namespace="com.ruoyi.car.mapper.CarMapper">
<insert id="addCarAssociation">
INSERT INTO `mall_product`.`car_association`
( `car_id`, `user_id`)
VALUES ( #{carId}, #{userId});
</insert>
<update id="updateCarNumber">
UPDATE `mall_product`.`car_info` SET `car_id` = #{carId}, `number` = #{number}, `update_by` = #{updateBy}, `update_time` = now() WHERE `id` =#{id};
</update>
<delete id="deleteCar">
delete from car_info where car_id=#{carId}
</delete>
<delete id="deleteCarAssociation">
delete from car_association where id=#{id}
</delete>
<!-- 添加 -->
<select id="findByCarInfo" resultType="com.ruoyi.mall.car.domain.CarInfo">
SELECT * FROM car_info where car_id=#{carId}
</select>
<select id="findByMallProductSkuInfo" resultType="com.ruoyi.mall.product.domain.MallProductSkuInfo">
SELECT
*
FROM
mall_product_sku_info sk
LEFT JOIN mall_product_info sp ON sk.product_id = sp.id
WHERE
sk.id = #{id}
</select>
<select id="selectCarByUserId" resultType="com.ruoyi.mall.product.domain.MallProductInfo">
select *
from mall_product_info
<where>
<if test="userId!=null">
</if>
</where>
</select>
<select id="findByCarAssociation" resultType="com.ruoyi.mall.car.domain.CarAssociation">
SELECT *FROM car_association where user_id=#{userId}
</select>
<select id="selectCarAssociation" resultType="com.ruoyi.mall.car.domain.CarAssociation">
select *from car_association
</select>
<select id="findByCarAssociationByCarId"
resultType="com.ruoyi.mall.car.domain.CarAssociation">
select *from car_association where car_id=#{carId}
</select>
<select id="findByUserIdGetByCarId" resultType="com.ruoyi.mall.car.domain.CarInfo">
select *from car_info where user_id=#{userId}
</select>
<select id="selectProductList" resultType="com.ruoyi.mall.product.domain.MallProductSkuInfo">
SELECT
*
FROM
mall_product_sku_info sk
LEFT JOIN mall_product_info sp ON sk.product_id = sp.id
WHERE
sk.id in (#{id})
</select>
<select id="selectProductInfo" resultType="com.ruoyi.mall.product.domain.MallProductInfo">
SELECT
*
FROM
mall_product_sku_info sk
LEFT JOIN mall_product_info sp ON sk.product_id = sp.id
WHERE
sk.id in (#{id})
</select>
<select id="selectFindSkuIdByCar" resultType="com.ruoyi.mall.car.domain.CarInfo">
select *from car_info where sku_id=#{skuId}
</select>
<select id="selectCarAssociationBySkuId"
resultType="com.ruoyi.mall.car.domain.CarAssociation">
select *from car_association where sku_id=#{skuId}
</select>
<select id="findSumPrice" resultType="java.math.BigDecimal">
SELECT
sum( car_info.number * price )
FROM
car_info
LEFT JOIN mall_product_sku_info ON car_info.sku_id = mall_product_sku_info.id
WHERE
user_id =#{userId}
</select>
<select id="selectOrderInfo" resultType="com.ruoyi.mall.car.domain.OrderInfo">
select *from order_info
</select>
</mapper>

View File

@ -0,0 +1,32 @@
<?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">
<!--
1.在mybats的开发中namespace有特殊的意思一定要是对应接口的全限定名
通过namespace可以简历mapper.xml和接口之间的关系(名字不重要,位置不重要)
-->
<mapper namespace="com.ruoyi.car.mapper.OrderMapper">
<!-- 添加 -->
<insert id="insertOrderAssociation">
INSERT INTO `mall_product`.`order_association`
( `order_id`, `sku_id`, `sku_title`, `image`, `craete_time`, `order_price` , `stock`)
VALUES ( #{orderId}, #{skuId}, #{skuTitle}, #{image}, #{createTime}, #{orderPrice},#{stock});
</insert>
<select id="selectOrderList" resultType="com.ruoyi.mall.car.domain.response.OrderDetailResp">
SELECT
oi.order_id,
total_price,
oi.create_time,
user_id,
os.image,
mpsi.sku,
mpsi.stock,
mpi.name
FROM
order_info oi
LEFT JOIN order_association os ON oi.order_id = os.order_id
LEFT JOIN mall_product_sku_info mpsi ON oi.sku_id = mpsi.id
LEFT JOIN mall_product_info mpi ON mpsi.product_id = mpi.id
</select>
</mapper>

View File

@ -0,0 +1,36 @@
package com.ruoyi.mall.product.domain;
import lombok.Data;
/**
* @Author
* @Packagecom.ruoyi.mall.product.domain
* @Projectmall_cloud
* @nameCMallProductAddress
* @Date2024/6/30 11:56
*/
@Data
public class CMallProductAddress {
private Integer id;
private Long memberId;
private String name;
private String phoneNumber;
private Integer defaultStatus;
private String postCode;
private String province;
private String city;
private String region;
private String detailAddress;
private String detailaddress;
private String defaultstatus;
}

View File

@ -0,0 +1,12 @@
package com.ruoyi.mall.product.domain;
import lombok.Data;
import java.util.List;
@Data
public class CMallProductInfo {
private List productAttributeList;
private List productAttributeValueList;
private List skuStockList;
}

View File

@ -0,0 +1,54 @@
package com.ruoyi.mall.product.domain;
import lombok.Data;
@Data
public class CMalllAdvertise {
/**
* 广id
*/
private Integer id;
/**
* 广
*/
private String name;
/**
*
*/
private Integer clickCount;
/**
*
*/
private Integer orderCount;
/**
*
*/
private String pic;
/**
*
*/
private String startTime;
/**
*
*/
private String endTime;
/**
*
*/
private Integer sort;
/**
*
*/
private Integer status;
/**
*
*/
private String url;
/**
*
*/
private Integer type;
}

View File

@ -0,0 +1,29 @@
package com.ruoyi.mall.product.domain;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Author
* @Packagecom.ruoyi.mall.product.domain
* @Projectmall_cloud
* @nameCusProductBrandAttentionInfo
* @Date2024/6/29 20:46
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class CusProductBrandAttentionInfo {
private String id;
private Integer brandId;
private String brandLogo;
private String brandName;
private String brandCity;
private String createtime;
private String memberIcon;
private Long memberid;
private String membernickname;
private String attentiondate;
}

View File

@ -0,0 +1,8 @@
package com.ruoyi.mall.product.domain;
import lombok.Data;
@Data
public class EsMallProductInfo extends MallProductInfo{
}

View File

@ -0,0 +1,186 @@
package com.ruoyi.mall.product.domain;
import com.ruoyi.common.core.annotation.Excel;
import com.ruoyi.common.core.web.domain.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
/**
* @Author
* @Packagecom.ruoyi.mall.product.domain.request
* @Projectmall_cloud
* @nameMallCBrandInfo
* @Date2024/6/28 19:13
*/
public class MallCBrandInfoInfo extends BaseEntity {
private static final long serialVersionUID = 1L;
/** ID */
private Long id;
/** 品牌名称 */
@Excel(name = "品牌名称")
private String name;
/** 品牌描述 */
@Excel(name = "品牌故事")
private String brandStory;
/** 品牌介绍 */
private String bigPic;
/** 品牌logo */
@Excel(name = "品牌logo")
private String logo;
/** 品牌状态 */
@Excel(name = "品牌状态")
private String showStatus;
/** 乐观锁 */
private Long revision;
/**
*
*/
private String sort;
public void setId(Long id) {
this.id = id;
}
public void setName(String name) {
this.name = name;
}
public void setLogo(String logo) {
this.logo = logo;
}
public void setRevision(Long revision) {
this.revision = revision;
}
public void setSort(String sort) {
this.sort = sort;
}
public void setCreateby(String createby) {
this.createby = createby;
}
public void setFirstLetter(String firstLetter) {
this.firstLetter = firstLetter;
}
public void setProductCommentCount(Integer productCommentCount) {
this.productCommentCount = productCommentCount;
}
public void setProductCount(Integer productCount) {
this.productCount = productCount;
}
/**
*
*/
private String createby;
/**
*
*/
private String firstLetter;
/**
*
*/
private Integer productCommentCount;
/**
*
*/
private Integer productCount;
public Long getId() {
return id;
}
public String getName() {
return name;
}
public String getLogo() {
return logo;
}
public Long getRevision() {
return revision;
}
public String getCreateby() {
return createby;
}
public String getFirstLetter() {
return firstLetter;
}
public Integer getProductCommentCount() {
return productCommentCount;
}
public Integer getProductCount() {
return productCount;
}
public String getSort() {
return sort;
}
public String getBigPic() {
return bigPic;
}
public String getShowStatus() {
return showStatus;
}
public void setBigPic(String bigPic) {
this.bigPic = bigPic;
}
public void setShowStatus(String showStatus) {
this.showStatus = showStatus;
}
public String getBrandStory() {
return brandStory;
}
public void setBrandStory(String brandStory) {
this.brandStory = brandStory;
}
@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("name", getName())
.append("productDesc", getBrandStory())
.append("content", getBigPic())
.append("logo", getLogo())
.append("status", getSort())
.append("revision", getRevision())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.toString();
}
}

View File

@ -0,0 +1,55 @@
package com.ruoyi.mall.product.domain;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class MallCProductSkuInfoAll {
// 商品品牌
private Integer brandId;
private String brandName;
private Integer giftGrowth;
private Integer giftPoint;
private Integer price;
private Integer originalPrice;
// 商品
private Integer id;
private String keywords;
private String name;
private Integer type;
private Integer brand;
private String pic;
//商品类型
private Integer productCategoryId;
private String productCategoryName;
private String subTitle;
private Integer publishStatus;
private Integer recommandStatus;
private Integer sort=100;
private Integer sale=99;
private Integer newStatus= 1;
private Integer stock=100;
private String productSn= "7437788";
private Integer promotionPerLimit= 0;
private Integer promotionType= 3;
private String serviceIds= "1";
private String unit="";
private Integer usePointLimit=0;
private Integer verifyStatus= 0;
private Integer weight=0;
private Integer ruleId;
}

View File

@ -0,0 +1,123 @@
package com.ruoyi.mall.product.domain;
import com.ruoyi.common.core.annotation.Excel;
import com.ruoyi.common.core.web.domain.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
/**
* mall_product_brand_info
*
* @author DongZeLiang
* @date 2022-09-15
*/
public class MallProductBrandInfo extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** ID */
private Long id;
/** 品牌名称 */
@Excel(name = "品牌名称")
private String name;
/** 品牌描述 */
@Excel(name = "品牌描述")
private String productDesc;
/** 品牌介绍 */
private String content;
/** 品牌logo */
@Excel(name = "品牌logo")
private String logo;
/** 品牌状态 */
@Excel(name = "品牌状态")
private String status;
/** 乐观锁 */
private Long revision;
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
public void setName(String name)
{
this.name = name;
}
public String getName()
{
return name;
}
public void setProductDesc(String productDesc)
{
this.productDesc = productDesc;
}
public String getProductDesc()
{
return productDesc;
}
public void setContent(String content)
{
this.content = content;
}
public String getContent()
{
return content;
}
public void setLogo(String logo)
{
this.logo = logo;
}
public String getLogo()
{
return logo;
}
public void setStatus(String status)
{
this.status = status;
}
public String getStatus()
{
return status;
}
public void setRevision(Long revision)
{
this.revision = revision;
}
public Long getRevision()
{
return revision;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("name", getName())
.append("productDesc", getProductDesc())
.append("content", getContent())
.append("logo", getLogo())
.append("status", getStatus())
.append("revision", getRevision())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.toString();
}
}

View File

@ -0,0 +1,250 @@
package com.ruoyi.mall.product.domain;
import com.ruoyi.common.core.annotation.Excel;
import com.ruoyi.common.core.web.domain.BaseEntity;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
/**
* mall_product_info
*
* @author DongZeLiang
* @date 2022-09-19
*/
public class MallProductInfo extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** ID */
@ApiParam("ID自增")
private Long id;
/** 商品名称 */
@Excel(name = "商品名称")
@ApiParam("商品名称")
private String name;
/** 商品描述 */
@Excel(name = "商品描述")
private String productDesc;
/** 商品类型 */
@Excel(name = "商品类型")
private String type;
/** 冗余字段 */
@Excel(name = "冗余字段")
private String typeIds;
/** 商品主图 */
@Excel(name = "商品主图")
private String img;
/** 商品轮播图 */
@Excel(name = "商品轮播图")
private String carouselImages;
/** 商品评论数 */
@Excel(name = "商品评论数")
private Long commentCount;
/** 商品收藏人气 */
@Excel(name = "商品收藏人气")
private Long collectCount;
/** 品牌信息 */
@Excel(name = "品牌信息")
private String brand;
/** 商品状态 */
@Excel(name = "商品状态")
private String status;
/** 单位 */
@Excel(name = "单位")
private String unit;
/** 搜索关键字 */
@Excel(name = "搜索关键字")
private String keywords;
/** 规格信息 */
@Excel(name = "规格信息")
private Long ruleId;
@Excel(name = "上下架")
private Integer islisting;
public Integer getIslisting() {
return islisting;
}
public void setIslisting(Integer islisting) {
this.islisting = islisting;
}
/** 乐观锁 */
private Long revision;
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
public void setName(String name)
{
this.name = name;
}
public String getName()
{
return name;
}
public void setProductDesc(String productDesc)
{
this.productDesc = productDesc;
}
public String getProductDesc()
{
return productDesc;
}
public void setType(String type)
{
this.type = type;
}
public String getType()
{
return type;
}
public void setTypeIds(String typeIds)
{
this.typeIds = typeIds;
}
public String getTypeIds()
{
return typeIds;
}
public void setImg(String img)
{
this.img = img;
}
public String getImg()
{
return img;
}
public void setCarouselImages(String carouselImages)
{
this.carouselImages = carouselImages;
}
public String getCarouselImages()
{
return carouselImages;
}
public void setCommentCount(Long commentCount)
{
this.commentCount = commentCount;
}
public Long getCommentCount()
{
return commentCount;
}
public void setCollectCount(Long collectCount)
{
this.collectCount = collectCount;
}
public Long getCollectCount()
{
return collectCount;
}
public void setBrand(String brand)
{
this.brand = brand;
}
public String getBrand()
{
return brand;
}
public void setStatus(String status)
{
this.status = status;
}
public String getStatus()
{
return status;
}
public void setUnit(String unit)
{
this.unit = unit;
}
public String getUnit()
{
return unit;
}
public void setKeywords(String keywords)
{
this.keywords = keywords;
}
public String getKeywords()
{
return keywords;
}
public void setRuleId(Long ruleId)
{
this.ruleId = ruleId;
}
public Long getRuleId()
{
return ruleId;
}
public void setRevision(Long revision)
{
this.revision = revision;
}
public Long getRevision()
{
return revision;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("name", getName())
.append("productDesc", getProductDesc())
.append("type", getType())
.append("typeIds", getTypeIds())
.append("img", getImg())
.append("carouselImages", getCarouselImages())
.append("commentCount", getCommentCount())
.append("collectCount", getCollectCount())
.append("brand", getBrand())
.append("status", getStatus())
.append("unit", getUnit())
.append("keywords", getKeywords())
.append("ruleId", getRuleId())
.append("revision", getRevision())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.append("islisting", getIslisting())
.toString();
}
}

View File

@ -0,0 +1,154 @@
package com.ruoyi.mall.product.domain;
import com.ruoyi.common.core.annotation.Excel;
import com.ruoyi.common.core.web.domain.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import java.math.BigDecimal;
/**
* mall_product_review_info
*
* @author DongZeLiang
* @date 2022-09-26
*/
public class MallProductReviewInfo extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** ID */
private Long id;
/** 商品名称 */
@Excel(name = "商品名称")
private Long productId;
/** 商品SKU */
@Excel(name = "商品SKU")
private Long productSkuId;
/** 商品评价图片 */
@Excel(name = "商品评价图片")
private String reviewImages;
/** 商品评价信息 */
@Excel(name = "商品评价信息")
private String content;
/** 评论分数 */
@Excel(name = "评论分数")
private BigDecimal start;
/** 是否隐藏 */
@Excel(name = "是否隐藏")
private String isDispaly;
/** 是否删除 */
@Excel(name = "是否删除")
private String isDel;
/** 乐观锁 */
private Long revision;
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
public void setProductId(Long productId)
{
this.productId = productId;
}
public Long getProductId()
{
return productId;
}
public void setProductSkuId(Long productSkuId)
{
this.productSkuId = productSkuId;
}
public Long getProductSkuId()
{
return productSkuId;
}
public void setReviewImages(String reviewImages)
{
this.reviewImages = reviewImages;
}
public String getReviewImages()
{
return reviewImages;
}
public void setContent(String content)
{
this.content = content;
}
public String getContent()
{
return content;
}
public void setStart(BigDecimal start)
{
this.start = start;
}
public BigDecimal getStart()
{
return start;
}
public void setIsDispaly(String isDispaly)
{
this.isDispaly = isDispaly;
}
public String getIsDispaly()
{
return isDispaly;
}
public void setIsDel(String isDel)
{
this.isDel = isDel;
}
public String getIsDel()
{
return isDel;
}
public void setRevision(Long revision)
{
this.revision = revision;
}
public Long getRevision()
{
return revision;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("productId", getProductId())
.append("productSkuId", getProductSkuId())
.append("reviewImages", getReviewImages())
.append("content", getContent())
.append("start", getStart())
.append("isDispaly", getIsDispaly())
.append("isDel", getIsDel())
.append("revision", getRevision())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.toString();
}
}

View File

@ -0,0 +1,92 @@
package com.ruoyi.mall.product.domain;
import com.ruoyi.common.core.annotation.Excel;
import com.ruoyi.common.core.web.domain.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
/**
* mall_product_rule_attr_info
*
* @author DongZeLiang
* @date 2022-09-16
*/
public class MallProductRuleAttrInfo extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** ID */
private Long id;
/** 规格 */
@Excel(name = "规格")
private Long ruleId;
/** 类目名称 */
@Excel(name = "类目名称")
private String name;
/** 规格值 */
@Excel(name = "规格值")
private String attrValue;
/** 乐观锁 */
private Long revision;
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
public void setRuleId(Long ruleId)
{
this.ruleId = ruleId;
}
public Long getRuleId()
{
return ruleId;
}
public void setName(String name)
{
this.name = name;
}
public String getName()
{
return name;
}
public void setAttrValue(String attrValue)
{
this.attrValue = attrValue;
}
public String getAttrValue()
{
return attrValue;
}
public void setRevision(Long revision)
{
this.revision = revision;
}
public Long getRevision()
{
return revision;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("ruleId", getRuleId())
.append("name", getName())
.append("attrValue", getAttrValue())
.append("revision", getRevision())
.toString();
}
}

View File

@ -0,0 +1,96 @@
package com.ruoyi.mall.product.domain;
import com.ruoyi.common.core.annotation.Excel;
import com.ruoyi.common.core.web.domain.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
/**
* mall_product_rule_info
*
* @author DongZeLiang
* @date 2022-09-16
*/
public class MallProductRuleInfo extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** ID */
private Long id;
/** 规格名称 */
@Excel(name = "规格名称")
private String name;
/** 规格详情 */
@Excel(name = "规格详情")
private String ruleAttr;
/** 规格状态 */
@Excel(name = "规格状态")
private String status;
/** 乐观锁 */
private Long revision;
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
public void setName(String name)
{
this.name = name;
}
public String getName()
{
return name;
}
public void setRuleAttr(String ruleAttr)
{
this.ruleAttr = ruleAttr;
}
public String getRuleAttr()
{
return ruleAttr;
}
public void setStatus(String status)
{
this.status = status;
}
public String getStatus()
{
return status;
}
public void setRevision(Long revision)
{
this.revision = revision;
}
public Long getRevision()
{
return revision;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("name", getName())
.append("ruleAttr", getRuleAttr())
.append("status", getStatus())
.append("revision", getRevision())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.toString();
}
}

View File

@ -0,0 +1,197 @@
package com.ruoyi.mall.product.domain;
import com.ruoyi.common.core.annotation.Excel;
import com.ruoyi.common.core.web.domain.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import java.math.BigDecimal;
/**
* SKU mall_product_sku_info
*
* @author DongZeLiang
* @date 2022-09-19
*/
public class MallProductSkuInfo extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** ID */
private Long id;
/** 商品信息 */
@Excel(name = "商品信息")
private Long productId;
/** 商品规格 */
@Excel(name = "商品规格")
private String sku;
/** 商品库存 */
@Excel(name = "商品库存")
private Long stock;
/** 商品价格 */
@Excel(name = "商品价格")
private BigDecimal price;
/** 商品进价 */
@Excel(name = "商品进价")
private BigDecimal purchasePrice;
/** 商品售价 */
@Excel(name = "商品售价")
private BigDecimal sellingPrice;
/** 规格图片 */
@Excel(name = "规格图片")
private String image;
/** 编号 */
@Excel(name = "编号")
private String number;
/** 重量 */
@Excel(name = "重量")
private BigDecimal weight;
/** 体积 */
@Excel(name = "体积")
private BigDecimal volume;
/** 乐观锁 */
@Excel(name = "乐观锁")
private Long revision;
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
public void setProductId(Long productId)
{
this.productId = productId;
}
public Long getProductId()
{
return productId;
}
public void setSku(String sku)
{
this.sku = sku;
}
public String getSku()
{
return sku;
}
public void setStock(Long stock)
{
this.stock = stock;
}
public Long getStock()
{
return stock;
}
public void setPrice(BigDecimal price)
{
this.price = price;
}
public BigDecimal getPrice()
{
return price;
}
public void setPurchasePrice(BigDecimal purchasePrice)
{
this.purchasePrice = purchasePrice;
}
public BigDecimal getPurchasePrice()
{
return purchasePrice;
}
public void setSellingPrice(BigDecimal sellingPrice)
{
this.sellingPrice = sellingPrice;
}
public BigDecimal getSellingPrice()
{
return sellingPrice;
}
public void setImage(String image)
{
this.image = image;
}
public String getImage()
{
return image;
}
public void setNumber(String number)
{
this.number = number;
}
public String getNumber()
{
return number;
}
public void setWeight(BigDecimal weight)
{
this.weight = weight;
}
public BigDecimal getWeight()
{
return weight;
}
public void setVolume(BigDecimal volume)
{
this.volume = volume;
}
public BigDecimal getVolume()
{
return volume;
}
public void setRevision(Long revision)
{
this.revision = revision;
}
public Long getRevision()
{
return revision;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("productId", getProductId())
.append("sku", getSku())
.append("stock", getStock())
.append("price", getPrice())
.append("purchasePrice", getPurchasePrice())
.append("sellingPrice", getSellingPrice())
.append("image", getImage())
.append("number", getNumber())
.append("weight", getWeight())
.append("volume", getVolume())
.append("revision", getRevision())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.toString();
}
}

View File

@ -0,0 +1,111 @@
package com.ruoyi.mall.product.domain;
import com.ruoyi.common.core.annotation.Excel;
import com.ruoyi.common.core.web.domain.TreeEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
/**
* mall_product_type_info
*
* @author DongZeLiang
* @date 2022-09-16
*/
public class MallProductTypeInfo extends TreeEntity
{
private static final long serialVersionUID = 1L;
/** ID */
private Long id;
/** 类型名称 */
@Excel(name = "类型名称")
private String name;
/** 类型图片 */
@Excel(name = "类型图片")
private String image;
/** 类型状态 */
@Excel(name = "类型状态")
private String status;
/** 类型排序 */
@Excel(name = "类型排序")
private Long orderBy;
/** 乐观锁 */
private Long revision;
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
public void setName(String name)
{
this.name = name;
}
public String getName()
{
return name;
}
public void setImage(String image)
{
this.image = image;
}
public String getImage()
{
return image;
}
public void setStatus(String status)
{
this.status = status;
}
public String getStatus()
{
return status;
}
public void setOrderBy(Long orderBy)
{
this.orderBy = orderBy;
}
public Long getOrderBy()
{
return orderBy;
}
public void setRevision(Long revision)
{
this.revision = revision;
}
public Long getRevision()
{
return revision;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("name", getName())
.append("image", getImage())
.append("status", getStatus())
.append("orderBy", getOrderBy())
.append("parentId", getParentId())
.append("revision", getRevision())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.toString();
}
}

View File

@ -0,0 +1,25 @@
package com.ruoyi.mall.product.domain;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
/**
* @Author
* @Packagecom.ruoyi.mall.product.domain
* @Projectmall_cloud
* @nameProductMallAll
* @Date2024/6/28 20:30
*/
@Data
public class ProductMallAll {
private List<CMalllAdvertise> advertiseList;
private List<MallCBrandInfoInfo> brandList;
private ArrayList hotProductList;
private ArrayList newProductList;
private ArrayList subjectList;
}

View File

@ -0,0 +1,185 @@
package com.ruoyi.mall.product.domain.model;
import com.ruoyi.common.core.web.domain.BaseEntity;
/**
* @author DongZl
* @description: -
* @Date 2022-10-18 01:57
*/
public class ProductModel extends BaseEntity {
/** ID */
private Long id;
/** 商品名称 */
private String name;
/** 商品描述 */
private String productDesc;
/** 商品类型 */
private String type;
private String typeName;
/** 冗余字段 */
private String typeIds;
/** 商品主图 */
private String img;
/** 商品轮播图 */
private String carouselImages;
/** 商品评论数 */
private Long commentCount;
/** 商品收藏人气 */
private Long collectCount;
/** 品牌信息 */
private String brand;
private String brandName;
/** 商品状态 */
private String status;
/** 单位 */
private String unit;
/** 搜索关键字 */
private String keywords;
/** 规格信息 */
private Long ruleId;
private Integer islisting;
public Long getId () {
return id;
}
public void setId (Long id) {
this.id = id;
}
public String getName () {
return name;
}
public void setName (String name) {
this.name = name;
}
public String getProductDesc () {
return productDesc;
}
public void setProductDesc (String productDesc) {
this.productDesc = productDesc;
}
public String getType () {
return type;
}
public void setType (String type) {
this.type = type;
}
public String getTypeName () {
return typeName;
}
public void setTypeName (String typeName) {
this.typeName = typeName;
}
public String getTypeIds () {
return typeIds;
}
public void setTypeIds (String typeIds) {
this.typeIds = typeIds;
}
public String getImg () {
return img;
}
public void setImg (String img) {
this.img = img;
}
public String getCarouselImages () {
return carouselImages;
}
public void setCarouselImages (String carouselImages) {
this.carouselImages = carouselImages;
}
public Long getCommentCount () {
return commentCount;
}
public void setCommentCount (Long commentCount) {
this.commentCount = commentCount;
}
public Long getCollectCount () {
return collectCount;
}
public void setCollectCount (Long collectCount) {
this.collectCount = collectCount;
}
public String getBrand () {
return brand;
}
public void setBrand (String brand) {
this.brand = brand;
}
public String getBrandName () {
return brandName;
}
public void setBrandName (String brandName) {
this.brandName = brandName;
}
public String getStatus () {
return status;
}
public void setStatus (String status) {
this.status = status;
}
public String getUnit () {
return unit;
}
public void setUnit (String unit) {
this.unit = unit;
}
public String getKeywords () {
return keywords;
}
public void setKeywords (String keywords) {
this.keywords = keywords;
}
public Long getRuleId () {
return ruleId;
}
public void setRuleId (Long ruleId) {
this.ruleId = ruleId;
}
}

View File

@ -0,0 +1,42 @@
package com.ruoyi.mall.product.domain.model;
import java.util.List;
import java.util.stream.Collectors;
/**
* @author DongZl
* @description:
* @Date 2022-9-17 09:28
*/
public class RuleAttrModel {
private String ruleType;
private List<String> ruleAttrList;
private String ruleAttrStr;
public String getRuleType () {
return ruleType;
}
public void setRuleType (String ruleType) {
this.ruleType = ruleType;
}
public List<String> getRuleAttrList () {
return ruleAttrList;
}
public void setRuleAttrList (List<String> ruleAttrList) {
this.ruleAttrList = ruleAttrList;
if (this.ruleAttrList != null){
this.ruleAttrStr = this.ruleAttrList.stream().collect(Collectors.joining(","));
}
}
public String getRuleAttrStr () {
return ruleAttrStr;
}
}

View File

@ -0,0 +1,31 @@
package com.ruoyi.mall.product.domain.model;
import java.util.List;
/**
* @author DongZl
* @description:
* @Date 2022-9-17 09:33
*/
public class RuleModel {
private Long ruleId;
private List<RuleAttrModel> ruleList;
public Long getRuleId () {
return ruleId;
}
public void setRuleId (Long ruleId) {
this.ruleId = ruleId;
}
public List<RuleAttrModel> getRuleList () {
return ruleList;
}
public void setRuleList (List<RuleAttrModel> ruleList) {
this.ruleList = ruleList;
}
}

View File

@ -0,0 +1,50 @@
package com.ruoyi.mall.product.domain.model;
import com.ruoyi.common.core.exception.ServiceException;
import com.ruoyi.mall.product.domain.MallProductSkuInfo;
import java.util.List;
/**
* @author DongZl
* @description: sku
* @Date 2022-9-24 10:23
*/
public class SkuModel {
private Long productId;
private List<MallProductSkuInfo> skuInfoList;
private SkuModel () {
}
private SkuModel (Long productId, List<MallProductSkuInfo> skuInfoList) {
this.productId = productId;
this.skuInfoList = skuInfoList;
}
public static SkuModel builderSkuModel(Long productId, List<MallProductSkuInfo> skuInfoList){
if (productId == null){
throw new ServiceException("商品ID不可为空");
}
return new SkuModel(productId, skuInfoList);
}
public Long getProductId () {
return productId;
}
public void setProductId (Long productId) {
this.productId = productId;
}
public List<MallProductSkuInfo> getSkuInfoList () {
return skuInfoList;
}
public void setSkuInfoList (List<MallProductSkuInfo> skuInfoList) {
this.skuInfoList = skuInfoList;
}
}

View File

@ -0,0 +1,54 @@
package com.ruoyi.mall.product.domain.reponse;
import com.ruoyi.mall.product.domain.MallProductRuleInfo;
import com.ruoyi.mall.product.domain.MallProductSkuInfo;
import com.ruoyi.mall.product.domain.model.ProductModel;
import java.util.List;
/**
* @author DongZl
* @description:
* @Date 2022-10-18 02:00
*/
public class ProductDetailsResponse {
/**
*
*/
private ProductModel product;
/**
* sku
*/
private List<MallProductSkuInfo> skuList;
/**
*
*/
private MallProductRuleInfo productRule;
public ProductModel getProduct () {
return product;
}
public void setProduct (ProductModel product) {
this.product = product;
}
public List<MallProductSkuInfo> getSkuList () {
return skuList;
}
public void setSkuList (List<MallProductSkuInfo> skuList) {
this.skuList = skuList;
}
public MallProductRuleInfo getProductRule () {
return productRule;
}
public void setProductRule (MallProductRuleInfo productRule) {
this.productRule = productRule;
}
}

View File

@ -0,0 +1,24 @@
package com.ruoyi.mall.product.domain.reponse;
import com.ruoyi.mall.product.domain.MallProductInfo;
import com.ruoyi.mall.product.domain.MallProductSkuInfo;
import java.util.List;
/**
* @author DongZl
* @description:
* @Date 2022-9-24 11:27
*/
public class ProductInfoResponse extends MallProductInfo {
private List<MallProductSkuInfo> skuInfoList;
public List<MallProductSkuInfo> getSkuInfoList () {
return skuInfoList;
}
public void setSkuInfoList (List<MallProductSkuInfo> skuInfoList) {
this.skuInfoList = skuInfoList;
}
}

View File

@ -0,0 +1,26 @@
package com.ruoyi.mall.product.domain.request;
import com.ruoyi.mall.product.domain.MallProductInfo;
import com.ruoyi.mall.product.domain.MallProductSkuInfo;
import io.swagger.annotations.ApiParam;
import java.util.List;
/**
* @author DongZl
* @description:
* @Date 2022-9-24 10:34
*/
public class ProductInfoRequest extends MallProductInfo {
@ApiParam("sku集合")
private List<MallProductSkuInfo> skuInfoList;
public List<MallProductSkuInfo> getSkuInfoList () {
return skuInfoList;
}
public void setSkuInfoList (List<MallProductSkuInfo> skuInfoList) {
this.skuInfoList = skuInfoList;
}
}

View File

@ -0,0 +1,25 @@
package com.ruoyi.mall.product.domain.request;
import com.ruoyi.mall.product.domain.MallProductRuleInfo;
import com.ruoyi.mall.product.domain.model.RuleAttrModel;
import java.util.List;
/**
* @author DongZl
* @description:
* @Date 2022-9-17 09:29
*/
public class RuleRequest extends MallProductRuleInfo {
private List<RuleAttrModel> ruleList;
public List<RuleAttrModel> getRuleList () {
return ruleList;
}
public void setRuleList (List<RuleAttrModel> ruleList) {
this.ruleList = ruleList;
}
}

View File

@ -0,0 +1,25 @@
package com.ruoyi.mall.product;
import com.ruoyi.common.security.annotation.EnableCustomConfig;
import com.ruoyi.common.security.annotation.EnableRyFeignClients;
import com.ruoyi.common.swagger.annotation.EnableCustomSwagger2;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
*
*
* @author DongZeLiang
*/
@EnableCustomConfig
@EnableCustomSwagger2
@EnableRyFeignClients
@SpringBootApplication
public class RuoYiMallProductApplication
{
public static void main(String[] args)
{
SpringApplication.run(RuoYiMallProductApplication.class, args);
System.out.println("(♥◠‿◠)ノ゙ 商城 - 商品模块启动成功 ლ(´ڡ`ლ)゙ ");
}
}

View File

@ -0,0 +1,34 @@
package com.ruoyi.mall.product.config;
import org.apache.http.HttpResponse;
import org.apache.http.util.EntityUtils;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.Map;
@Component
public class AnalyzeAddres {
String host = "https://jmkddzjx.market.alicloudapi.com";
String path = "/express/address-parse";
String method = "POST";
static String appcode = "6b97a20bb2de4db8a30664716094c257"; // 替换为你的实际 AppCode
public String analyzeAddres(String str) {
Map<String, String> headers = new HashMap<String, String>();
//最后在header中的格式(中间是英文空格)为Authorization:APPCODE 83359fd73fe94948385f570e3c139105
headers.put("Authorization", "APPCODE " + appcode);
//根据API的要求定义相对应的Content-Type
headers.put("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
Map<String, String> querys = new HashMap<String, String>();
Map<String, String> bodys = new HashMap<String, String>();
bodys.put("address", str);
try {
HttpResponse response = HttpUtils.doPost(host, path, method, headers, querys, bodys);
return EntityUtils.toString(response.getEntity());
//获取response的body
//System.out.println(EntityUtils.toString(response.getEntity()));
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException();
}
}
}

View File

@ -0,0 +1,311 @@
package com.ruoyi.mall.product.config;
import org.apache.commons.lang.StringUtils;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpDelete;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpPut;
import org.apache.http.conn.ClientConnectionManager;
import org.apache.http.conn.scheme.Scheme;
import org.apache.http.conn.scheme.SchemeRegistry;
import org.apache.http.conn.ssl.SSLSocketFactory;
import org.apache.http.entity.ByteArrayEntity;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class HttpUtils {
/**
* get
*
* @param host
* @param path
* @param method
* @param headers
* @param querys
* @return
* @throws Exception
*/
public static HttpResponse doGet(String host, String path, String method,
Map<String, String> headers,
Map<String, String> querys)
throws Exception {
HttpClient httpClient = wrapClient(host);
HttpGet request = new HttpGet(buildUrl(host, path, querys));
for (Map.Entry<String, String> e : headers.entrySet()) {
request.addHeader(e.getKey(), e.getValue());
}
return httpClient.execute(request);
}
/**
* post form
*
* @param host
* @param path
* @param method
* @param headers
* @param querys
* @param bodys
* @return
* @throws Exception
*/
public static HttpResponse doPost(String host, String path, String method,
Map<String, String> headers,
Map<String, String> querys,
Map<String, String> bodys)
throws Exception {
HttpClient httpClient = wrapClient(host);
HttpPost request = new HttpPost(buildUrl(host, path, querys));
for (Map.Entry<String, String> e : headers.entrySet()) {
request.addHeader(e.getKey(), e.getValue());
}
if (bodys != null) {
List<NameValuePair> nameValuePairList = new ArrayList<NameValuePair>();
for (String key : bodys.keySet()) {
nameValuePairList.add(new BasicNameValuePair(key, bodys.get(key)));
}
UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(nameValuePairList, "utf-8");
formEntity.setContentType("application/x-www-form-urlencoded; charset=UTF-8");
request.setEntity(formEntity);
}
return httpClient.execute(request);
}
/**
* Post String
*
* @param host
* @param path
* @param method
* @param headers
* @param querys
* @param body
* @return
* @throws Exception
*/
public static HttpResponse doPost(String host, String path, String method,
Map<String, String> headers,
Map<String, String> querys,
String body)
throws Exception {
HttpClient httpClient = wrapClient(host);
HttpPost request = new HttpPost(buildUrl(host, path, querys));
for (Map.Entry<String, String> e : headers.entrySet()) {
request.addHeader(e.getKey(), e.getValue());
}
if (StringUtils.isNotBlank(body)) {
request.setEntity(new StringEntity(body, "utf-8"));
}
return httpClient.execute(request);
}
/**
* Post stream
*
* @param host
* @param path
* @param method
* @param headers
* @param querys
* @param body
* @return
* @throws Exception
*/
public static HttpResponse doPost(String host, String path, String method,
Map<String, String> headers,
Map<String, String> querys,
byte[] body)
throws Exception {
HttpClient httpClient = wrapClient(host);
HttpPost request = new HttpPost(buildUrl(host, path, querys));
for (Map.Entry<String, String> e : headers.entrySet()) {
request.addHeader(e.getKey(), e.getValue());
}
if (body != null) {
request.setEntity(new ByteArrayEntity(body));
}
return httpClient.execute(request);
}
/**
* Put String
* @param host
* @param path
* @param method
* @param headers
* @param querys
* @param body
* @return
* @throws Exception
*/
public static HttpResponse doPut(String host, String path, String method,
Map<String, String> headers,
Map<String, String> querys,
String body)
throws Exception {
HttpClient httpClient = wrapClient(host);
HttpPut request = new HttpPut(buildUrl(host, path, querys));
for (Map.Entry<String, String> e : headers.entrySet()) {
request.addHeader(e.getKey(), e.getValue());
}
if (StringUtils.isNotBlank(body)) {
request.setEntity(new StringEntity(body, "utf-8"));
}
return httpClient.execute(request);
}
/**
* Put stream
* @param host
* @param path
* @param method
* @param headers
* @param querys
* @param body
* @return
* @throws Exception
*/
public static HttpResponse doPut(String host, String path, String method,
Map<String, String> headers,
Map<String, String> querys,
byte[] body)
throws Exception {
HttpClient httpClient = wrapClient(host);
HttpPut request = new HttpPut(buildUrl(host, path, querys));
for (Map.Entry<String, String> e : headers.entrySet()) {
request.addHeader(e.getKey(), e.getValue());
}
if (body != null) {
request.setEntity(new ByteArrayEntity(body));
}
return httpClient.execute(request);
}
/**
* Delete
*
* @param host
* @param path
* @param method
* @param headers
* @param querys
* @return
* @throws Exception
*/
public static HttpResponse doDelete(String host, String path, String method,
Map<String, String> headers,
Map<String, String> querys)
throws Exception {
HttpClient httpClient = wrapClient(host);
HttpDelete request = new HttpDelete(buildUrl(host, path, querys));
for (Map.Entry<String, String> e : headers.entrySet()) {
request.addHeader(e.getKey(), e.getValue());
}
return httpClient.execute(request);
}
private static String buildUrl(String host, String path, Map<String, String> querys) throws UnsupportedEncodingException {
StringBuilder sbUrl = new StringBuilder();
sbUrl.append(host);
if (!StringUtils.isBlank(path)) {
sbUrl.append(path);
}
if (null != querys) {
StringBuilder sbQuery = new StringBuilder();
for (Map.Entry<String, String> query : querys.entrySet()) {
if (0 < sbQuery.length()) {
sbQuery.append("&");
}
if (StringUtils.isBlank(query.getKey()) && !StringUtils.isBlank(query.getValue())) {
sbQuery.append(query.getValue());
}
if (!StringUtils.isBlank(query.getKey())) {
sbQuery.append(query.getKey());
if (!StringUtils.isBlank(query.getValue())) {
sbQuery.append("=");
sbQuery.append(URLEncoder.encode(query.getValue(), "utf-8"));
}
}
}
if (0 < sbQuery.length()) {
sbUrl.append("?").append(sbQuery);
}
}
return sbUrl.toString();
}
private static HttpClient wrapClient(String host) {
HttpClient httpClient = new DefaultHttpClient();
if (host.startsWith("https://")) {
sslClient(httpClient);
}
return httpClient;
}
private static void sslClient(HttpClient httpClient) {
try {
SSLContext ctx = SSLContext.getInstance("TLS");
X509TrustManager tm = new X509TrustManager() {
public X509Certificate[] getAcceptedIssuers() {
return null;
}
public void checkClientTrusted(X509Certificate[] xcs, String str) {
}
public void checkServerTrusted(X509Certificate[] xcs, String str) {
}
};
ctx.init(null, new TrustManager[] { tm }, null);
SSLSocketFactory ssf = new SSLSocketFactory(ctx);
ssf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
ClientConnectionManager ccm = httpClient.getConnectionManager();
SchemeRegistry registry = ccm.getSchemeRegistry();
registry.register(new Scheme("https", 443, ssf));
} catch (KeyManagementException ex) {
throw new RuntimeException(ex);
} catch (NoSuchAlgorithmException ex) {
throw new RuntimeException(ex);
}
}
}

View File

@ -0,0 +1,16 @@
package com.ruoyi.mall.product.config;
import lombok.Data;
@Data
public class MallProductAddress {
private Integer id;
private Integer memberId;
private String name;
private String phoneNumber;
private Integer defaultStatus;
private String postCode;
private String province;
private String city;
private String region;
private String detailAddress;
}

View File

@ -0,0 +1,85 @@
package com.ruoyi.mall.product.controller;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.mall.product.domain.CusProductBrandAttentionInfo;
import com.ruoyi.mall.product.service.CusProductBrandIntoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequestMapping("/brand")
@Api(tags = "商品品牌管理")
public class CusProductBrandInfoController {
@Autowired
private CusProductBrandIntoService brandIntoService;
/**
*
* @return
*/
@GetMapping("/findAttention")
@ApiOperation("查询品牌关注信息")
public R<List<CusProductBrandAttentionInfo>> findAttention(){
List<CusProductBrandAttentionInfo> attentionInfos = brandIntoService.findAttention();
if(attentionInfos.size()==0){
return R.ok();
}
return R.ok(attentionInfos);
}
/**
*
* @return
*/
@DeleteMapping("/clear")
@ApiOperation("清空品牌关注信息")
public R delectAttention(){
int attentionInfos = brandIntoService.delectAttention();
return R.ok(attentionInfos);
}
/**
* id
* @return
*/
@GetMapping("/attentionDetail")
@ApiOperation("根据id查询品牌关注信息")
public R<CusProductBrandAttentionInfo> attentionDetail(@RequestParam Integer brandId){
CusProductBrandAttentionInfo attentionInfo = brandIntoService.attentionDetail(brandId);
if(attentionInfo==null){
R.ok() ;
}
return R.ok(attentionInfo);
}
/**
*
* @return
*/
@PostMapping("/addAttention")
@ApiOperation("添加品牌关注信息")
public R addAttention(@RequestBody CusProductBrandAttentionInfo cusProductBrandAttentionInfo){
int i = brandIntoService.addAttention(cusProductBrandAttentionInfo);
return R.ok(i);
}
/**
*
* @return
*/
@PostMapping("/delAttention")
@ApiOperation("删除品牌关注信息")
public R delAttention(@RequestParam Integer brandId){
brandIntoService.delAttention(brandId);
return R.ok();
}
}

View File

@ -0,0 +1,161 @@
package com.ruoyi.mall.product.controller;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.mall.product.config.AnalyzeAddres;
import com.ruoyi.mall.product.config.MallProductAddress;
import com.ruoyi.mall.product.domain.*;
import com.ruoyi.mall.product.service.IMallCProductInfoService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;
/**
* Controller
*
* @author DongZeLiang
* @date 2022-09-19
*/
@RestController
@RequestMapping("/cproduct")
@Api(tags = "商品维护 - API")
public class MallCProductInfoController extends BaseController
{
@Autowired
private IMallCProductInfoService mallCProductInfoService;
@Autowired
private AnalyzeAddres analyzeAddres;
/**
*
*/
@GetMapping("/brand/productList")
public TableDataInfo syncList (@RequestParam(required = false) Integer brandId,
@RequestParam Integer pageNum,
@RequestParam Integer pageSize,
@RequestBody(required = false) MallCProductSkuInfoAll mallProductInfo)
{
startPage();
MallCProductSkuInfoAll mallCProductSkuInfoAll = new MallCProductSkuInfoAll();
if(brandId!=null){
mallCProductSkuInfoAll.setBrandId(brandId);
}
List<MallCProductSkuInfoAll> list = mallCProductInfoService.selectMallProductInfoList(mallCProductSkuInfoAll);
return getDataTable(list);
}
/**
*
*/
@PostMapping("/count")
public R<Long> count(@RequestBody MallProductInfo mallProductInfo)
{
return R.ok(mallCProductInfoService.selectMallProductInfoCount(mallProductInfo));
}
/**
*
*/
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return AjaxResult.success(mallCProductInfoService.selectMallProductInfoById(id));
}
/**
*
*/
@PostMapping("/addressadd")
public R addressadd(@RequestBody CMallProductAddress mallProductAddress,HttpServletRequest request){
int add= mallCProductInfoService.addressadd(mallProductAddress,request);
return R.ok();
}
/**
*
*/
@PostMapping("/updaaddress/{id}")
public R updaaddress(@PathVariable Integer id,@RequestBody(required = false) CMallProductAddress mallProductAddress,HttpServletRequest request){
int updaaddress= mallCProductInfoService.updaaddress(mallProductAddress,request,id,request);
return R.ok();
}
/**
*
*/
@GetMapping("/selectaddressId/{addressId}")
public R selectaddressId(@PathVariable Integer addressId, HttpServletRequest request){
CMallProductAddress selectaddressId= mallCProductInfoService.selectaddressId(addressId,request);
return R.ok(selectaddressId);
}
//删除地址
@PostMapping("/delectaddress/{addressId}")
public R delectaddress(@PathVariable Integer addressId, HttpServletRequest request){
int delectaddress= mallCProductInfoService.delectaddress(addressId,request);
return R.ok();
}
/**
*
*/
@PostMapping("/addresslist")
public R addresslist( HttpServletRequest request){
ArrayList<CMallProductAddress> list= mallCProductInfoService.addresslist(request);
return R.ok(list);
}
/**
*
* @param id
* @return
*/
@GetMapping("/detail/{id}")
public R<CMallProductInfo> getProductResponse(@PathVariable("id") Long id){
return R.ok(mallCProductInfoService.selectProductDetailsById(id));
}
@PostMapping("/address/{zdaddress}")
public R address(@PathVariable String zdaddress){
String str="木可-15038933321 河南省郑州市中原区河工大社区";
String s = analyzeAddres.analyzeAddres(zdaddress);
JSONObject jsonObject = JSONObject.parseObject(s);
JSONObject data = jsonObject.getJSONObject("data");
String province = data.getString("province");
String city = data.getString("city");
String county = data.getString("county");
String town = data.getString("town");
String phoneNum = data.getString("phoneNum");
String person = data.getString("person");
String detail = data.getString("detail");
MallProductAddress address = new MallProductAddress();
address.setId(1);
address.setMemberId(11);
address.setName(person);
address.setPhoneNumber(phoneNum);
address.setPostCode("518000");
address.setProvince(province);
address.setCity(city);
address.setRegion(county);
address.setDetailAddress(town+detail);
return R.ok(address);
}
}

View File

@ -0,0 +1,110 @@
package com.ruoyi.mall.product.controller;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.mall.product.domain.MallProductBrandInfo;
import com.ruoyi.mall.product.service.IMallProductBrandInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
* Controller
*
* @author DongZeLiang
* @date 2022-09-15
*/
@RestController
@RequestMapping("/brand")
public class MallProductBrandInfoController extends BaseController
{
@Autowired
private IMallProductBrandInfoService mallProductBrandInfoService;
/**
*
*/
@RequiresPermissions("product:brand:list")
@GetMapping("/list")
public TableDataInfo list(MallProductBrandInfo mallProductBrandInfo)
{
startPage();
List<MallProductBrandInfo> list = mallProductBrandInfoService.selectMallProductBrandInfoList(mallProductBrandInfo);
return getDataTable(list);
}
/**
*
*/
@RequiresPermissions("product:brand:export")
@Log(title = "商品品牌", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, MallProductBrandInfo mallProductBrandInfo)
{
List<MallProductBrandInfo> list = mallProductBrandInfoService.selectMallProductBrandInfoList(mallProductBrandInfo);
ExcelUtil<MallProductBrandInfo> util = new ExcelUtil<MallProductBrandInfo>(MallProductBrandInfo.class);
util.exportExcel(response, list, "商品品牌数据");
}
/**
*
*/
@RequiresPermissions("product:brand:query")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
MallProductBrandInfo mallProductBrandInfo = mallProductBrandInfoService.selectMallProductBrandInfoById(id);
return AjaxResult.success(mallProductBrandInfo);
}
@RequiresPermissions("product:brand:query")
@GetMapping(value = "/getInfo1/{id}")
public MallProductBrandInfo getInfo1(@PathVariable("id") Long id)
{
MallProductBrandInfo mallProductBrandInfo = mallProductBrandInfoService.selectMallProductBrandInfoById(id);
return mallProductBrandInfo;
}
/**
*
*/
@RequiresPermissions("product:brand:add")
@Log(title = "商品品牌", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody MallProductBrandInfo mallProductBrandInfo)
{
return toAjax(mallProductBrandInfoService.insertMallProductBrandInfo(mallProductBrandInfo));
}
/**
*
*/
@RequiresPermissions("product:brand:edit")
@Log(title = "商品品牌", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody MallProductBrandInfo mallProductBrandInfo)
{
return toAjax(mallProductBrandInfoService.updateMallProductBrandInfo(mallProductBrandInfo));
}
/**
*
*/
@RequiresPermissions("product:brand:remove")
@Log(title = "商品品牌", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(mallProductBrandInfoService.deleteMallProductBrandInfoByIds(ids));
}
}

View File

@ -0,0 +1,63 @@
package com.ruoyi.mall.product.controller;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.mall.product.domain.CMalllAdvertise;
import com.ruoyi.mall.product.domain.MallCBrandInfoInfo;
import com.ruoyi.mall.product.domain.ProductMallAll;
import com.ruoyi.mall.product.service.IMallProductCBrandInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* @Author
* @Packagecom.ruoyi.mall.product.controller
* @Projectmall_cloud
* @nameMallProductCBrandInfoController
* @Date2024/6/28 19:51
*/
@RestController
@RequestMapping("/home")
public class MallProductCBrandInfoController extends BaseController {
@Autowired
private IMallProductCBrandInfoService iMallProductCBrandInfoService;
/**
*
*/
@GetMapping("/content")
public R list(@RequestBody(required = false) MallCBrandInfoInfo mallCBrandInfoInfo)
{
startPage();
List<MallCBrandInfoInfo> list = iMallProductCBrandInfoService.selectMallProductBrandInfoList(mallCBrandInfoInfo);
List<CMalllAdvertise> addvertiseList=iMallProductCBrandInfoService.selectMallAAdviseList();
ProductMallAll productMallAll = new ProductMallAll();
productMallAll.setBrandList(list);
productMallAll.setAdvertiseList(addvertiseList);
TableDataInfo dataTable = getDataTable(list);
return R.ok(productMallAll);
}
@GetMapping("/brand/recommendList")
public R recommendProductList(@RequestParam Integer pageNum,@RequestParam Integer pageSize,@RequestBody(required = false)MallCBrandInfoInfo mallCBrandInfoInfo)
{
startPage();
List<MallCBrandInfoInfo> list = iMallProductCBrandInfoService.selectMallProductBrandInfoList(mallCBrandInfoInfo);
ProductMallAll productMallAll = new ProductMallAll();
productMallAll.setBrandList(list);
TableDataInfo dataTable = getDataTable(list);
return R.ok(dataTable.getRows());
}
@GetMapping(value = "/brand/detail/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
MallCBrandInfoInfo mallCBrandInfoInfo = iMallProductCBrandInfoService.selectMallProductBrandInfoById(id);
return AjaxResult.success(mallCBrandInfoInfo);
}
}

View File

@ -0,0 +1,167 @@
package com.ruoyi.mall.product.controller;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.mall.product.domain.MallProductInfo;
import com.ruoyi.mall.product.domain.reponse.ProductDetailsResponse;
import com.ruoyi.mall.product.domain.reponse.ProductInfoResponse;
import com.ruoyi.mall.product.domain.request.ProductInfoRequest;
import com.ruoyi.mall.product.service.IMallProductInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
* Controller
*
* @author DongZeLiang
* @date 2022-09-19
*/
@RestController
@RequestMapping("/info")
@Api(tags = "商品维护 - API")
public class MallProductInfoController extends BaseController
{
@Autowired
private IMallProductInfoService mallProductInfoService;
/**
*
*/
@RequiresPermissions("product:info:list")
@RequestMapping(value = "/list", method = {RequestMethod.GET, RequestMethod.POST})
public TableDataInfo list(MallProductInfo mallProductInfo)
{
startPage();
List<MallProductInfo> list = mallProductInfoService.selectMallProductInfoList(mallProductInfo);
return getDataTable(list);
}
@PostMapping("/syncList")
public TableDataInfo syncList(@RequestBody MallProductInfo mallProductInfo)
{
startPage();
List<MallProductInfo> list = mallProductInfoService.selectMallProductInfoList(mallProductInfo);
return getDataTable(list);
}
/**
*
*/
@RequiresPermissions("product:info:list")
@PostMapping("/count")
public R<Long> count(@RequestBody MallProductInfo mallProductInfo)
{
return R.ok(mallProductInfoService.selectMallProductInfoCount(mallProductInfo));
}
/**
*
*/
@RequiresPermissions("product:info:export")
@Log(title = "商品信息", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, MallProductInfo mallProductInfo)
{
List<MallProductInfo> list = mallProductInfoService.selectMallProductInfoList(mallProductInfo);
ExcelUtil<MallProductInfo> util = new ExcelUtil<MallProductInfo>(MallProductInfo.class);
util.exportExcel(response, list, "商品信息数据");
}
/**
*
*/
@RequiresPermissions("product:info:query")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return AjaxResult.success(mallProductInfoService.selectMallProductInfoById(id));
}
@GetMapping(value = "/getlisting/{id}")
@ApiOperation("上架商品")
public R uploadInfo(@PathVariable("id") Long id,Boolean isupload) {
mallProductInfoService.getuploadInfo(id,isupload);
return R.ok();
}
/**
*
*/
@GetMapping(value = "/upload/{id}")
@ApiOperation("上架商品")
public R uploadInfo(@PathVariable("id") Long id,boolean isUpload)
{
return mallProductInfoService.uploadInfo(id);
}
@GetMapping(value = "/uploadling/{id}/{isUpload}")
@ApiOperation("上架商品")
public R getuploadInfo1(@PathVariable("id") Long id,@PathVariable("isUpload") boolean isUpload)
{
mallProductInfoService.uploadInfo1(id,isUpload);
return R.ok();
}
@GetMapping(value = "/result/{id}")
public R<ProductInfoResponse> getResultInfo(@PathVariable("id") Long id)
{
return R.ok(mallProductInfoService.selectMallProductInfoById(id));
}
/**
*
* @param id
* @return
*/
@GetMapping("/details/{id}")
public R<ProductDetailsResponse> getProductResponse(@PathVariable("id") Long id){
return R.ok(mallProductInfoService.selectProductDetailsById(id));
}
/**
*
*/
@RequiresPermissions("product:info:add")
@Log(title = "商品信息", businessType = BusinessType.INSERT)
@PostMapping
@ApiOperation("商品添加")
public AjaxResult add(@RequestBody @ApiParam("商品请求实体类") ProductInfoRequest productInfoRequest)
{
return toAjax(mallProductInfoService.insertMallProductInfo(productInfoRequest));
}
/**
*
*/
@RequiresPermissions("product:info:edit")
@Log(title = "商品信息", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody ProductInfoRequest productInfoRequest)
{
return toAjax(mallProductInfoService.updateMallProductInfo(productInfoRequest));
}
/**
*
*/
@RequiresPermissions("product:info:remove")
@Log(title = "商品信息", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(mallProductInfoService.deleteMallProductInfoByIds(ids));
}
}

View File

@ -0,0 +1,98 @@
package com.ruoyi.mall.product.controller;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.mall.product.domain.MallProductReviewInfo;
import com.ruoyi.mall.product.service.IMallProductReviewInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
* Controller
*
* @author DongZeLiang
* @date 2022-09-26
*/
@RestController
@RequestMapping("/review")
public class MallProductReviewInfoController extends BaseController
{
@Autowired
private IMallProductReviewInfoService mallProductReviewInfoService;
/**
*
*/
@RequiresPermissions("product:review:list")
@GetMapping("/list")
public TableDataInfo list(MallProductReviewInfo mallProductReviewInfo)
{
startPage();
List<MallProductReviewInfo> list = mallProductReviewInfoService.selectMallProductReviewInfoList(mallProductReviewInfo);
return getDataTable(list);
}
/**
*
*/
@RequiresPermissions("product:review:export")
@Log(title = "商品评价", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, MallProductReviewInfo mallProductReviewInfo)
{
List<MallProductReviewInfo> list = mallProductReviewInfoService.selectMallProductReviewInfoList(mallProductReviewInfo);
ExcelUtil<MallProductReviewInfo> util = new ExcelUtil<MallProductReviewInfo>(MallProductReviewInfo.class);
util.exportExcel(response, list, "商品评价数据");
}
/**
*
*/
@RequiresPermissions("product:review:query")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return AjaxResult.success(mallProductReviewInfoService.selectMallProductReviewInfoById(id));
}
/**
*
*/
@RequiresPermissions("product:review:add")
@Log(title = "商品评价", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody MallProductReviewInfo mallProductReviewInfo)
{
return toAjax(mallProductReviewInfoService.insertMallProductReviewInfo(mallProductReviewInfo));
}
/**
*
*/
@RequiresPermissions("product:review:edit")
@Log(title = "商品评价", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody MallProductReviewInfo mallProductReviewInfo)
{
return toAjax(mallProductReviewInfoService.updateMallProductReviewInfo(mallProductReviewInfo));
}
/**
*
*/
@RequiresPermissions("product:review:remove")
@Log(title = "商品评价", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(mallProductReviewInfoService.deleteMallProductReviewInfoByIds(ids));
}
}

View File

@ -0,0 +1,98 @@
package com.ruoyi.mall.product.controller;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.mall.product.domain.MallProductRuleAttrInfo;
import com.ruoyi.mall.product.service.IMallProductRuleAttrInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
* Controller
*
* @author DongZeLiang
* @date 2022-09-16
*/
@RestController
@RequestMapping("/attr")
public class MallProductRuleAttrInfoController extends BaseController
{
@Autowired
private IMallProductRuleAttrInfoService mallProductRuleAttrInfoService;
/**
*
*/
@RequiresPermissions("product:attr:list")
@GetMapping("/list")
public TableDataInfo list(MallProductRuleAttrInfo mallProductRuleAttrInfo)
{
startPage();
List<MallProductRuleAttrInfo> list = mallProductRuleAttrInfoService.selectMallProductRuleAttrInfoList(mallProductRuleAttrInfo);
return getDataTable(list);
}
/**
*
*/
@RequiresPermissions("product:attr:export")
@Log(title = "商品规格详情", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, MallProductRuleAttrInfo mallProductRuleAttrInfo)
{
List<MallProductRuleAttrInfo> list = mallProductRuleAttrInfoService.selectMallProductRuleAttrInfoList(mallProductRuleAttrInfo);
ExcelUtil<MallProductRuleAttrInfo> util = new ExcelUtil<MallProductRuleAttrInfo>(MallProductRuleAttrInfo.class);
util.exportExcel(response, list, "商品规格详情数据");
}
/**
*
*/
@RequiresPermissions("product:attr:query")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return AjaxResult.success(mallProductRuleAttrInfoService.selectMallProductRuleAttrInfoById(id));
}
/**
*
*/
@RequiresPermissions("product:attr:add")
@Log(title = "商品规格详情", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody MallProductRuleAttrInfo mallProductRuleAttrInfo)
{
return toAjax(mallProductRuleAttrInfoService.insertMallProductRuleAttrInfo(mallProductRuleAttrInfo));
}
/**
*
*/
@RequiresPermissions("product:attr:edit")
@Log(title = "商品规格详情", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody MallProductRuleAttrInfo mallProductRuleAttrInfo)
{
return toAjax(mallProductRuleAttrInfoService.updateMallProductRuleAttrInfo(mallProductRuleAttrInfo));
}
/**
*
*/
@RequiresPermissions("product:attr:remove")
@Log(title = "商品规格详情", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(mallProductRuleAttrInfoService.deleteMallProductRuleAttrInfoByIds(ids));
}
}

View File

@ -0,0 +1,107 @@
package com.ruoyi.mall.product.controller;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.mall.product.domain.MallProductRuleInfo;
import com.ruoyi.mall.product.domain.request.RuleRequest;
import com.ruoyi.mall.product.service.IMallProductRuleInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
* Controller
*
* @author DongZeLiang
* @date 2022-09-16
*/
@RestController
@RequestMapping("/rule")
public class MallProductRuleInfoController extends BaseController
{
@Autowired
private IMallProductRuleInfoService mallProductRuleInfoService;
/**
*
*/
@RequiresPermissions("product:rule:list")
@GetMapping("/list")
public TableDataInfo list(MallProductRuleInfo mallProductRuleInfo)
{
startPage();
List<MallProductRuleInfo> list = mallProductRuleInfoService.selectMallProductRuleInfoList(mallProductRuleInfo);
return getDataTable(list);
}
@RequiresPermissions("product:rule:list")
@GetMapping("/all")
public R all()
{
List<MallProductRuleInfo> list = mallProductRuleInfoService.selectMallProductRuleInfoList(new MallProductRuleInfo());
return R.ok(list);
}
/**
*
*/
@RequiresPermissions("product:rule:export")
@Log(title = "商品规格", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, MallProductRuleInfo mallProductRuleInfo)
{
List<MallProductRuleInfo> list = mallProductRuleInfoService.selectMallProductRuleInfoList(mallProductRuleInfo);
ExcelUtil<MallProductRuleInfo> util = new ExcelUtil<MallProductRuleInfo>(MallProductRuleInfo.class);
util.exportExcel(response, list, "商品规格数据");
}
/**
*
*/
@RequiresPermissions("product:rule:query")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return AjaxResult.success(mallProductRuleInfoService.selectMallProductRuleInfoById(id));
}
/**
*
*/
@RequiresPermissions("product:rule:add")
@Log(title = "商品规格", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody RuleRequest ruleRequest)
{
return toAjax(mallProductRuleInfoService.insertMallProductRuleInfo(ruleRequest));
}
/**
*
*/
@RequiresPermissions("product:rule:edit")
@Log(title = "商品规格", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody RuleRequest ruleRequest)
{
return toAjax(mallProductRuleInfoService.updateMallProductRuleInfo(ruleRequest));
}
/**
*
*/
@RequiresPermissions("product:rule:remove")
@Log(title = "商品规格", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(mallProductRuleInfoService.deleteMallProductRuleInfoByIds(ids));
}
}

View File

@ -0,0 +1,98 @@
package com.ruoyi.mall.product.controller;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.mall.product.domain.MallProductSkuInfo;
import com.ruoyi.mall.product.service.IMallProductSkuInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
* SKUController
*
* @author DongZeLiang
* @date 2022-09-19
*/
@RestController
@RequestMapping("/sku")
public class MallProductSkuInfoController extends BaseController
{
@Autowired
private IMallProductSkuInfoService mallProductSkuInfoService;
/**
* SKU
*/
@RequiresPermissions("product:sku:list")
@GetMapping("/list")
public TableDataInfo list(MallProductSkuInfo mallProductSkuInfo)
{
startPage();
List<MallProductSkuInfo> list = mallProductSkuInfoService.selectMallProductSkuInfoList(mallProductSkuInfo);
return getDataTable(list);
}
/**
* SKU
*/
@RequiresPermissions("product:sku:export")
@Log(title = "商品SKU", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, MallProductSkuInfo mallProductSkuInfo)
{
List<MallProductSkuInfo> list = mallProductSkuInfoService.selectMallProductSkuInfoList(mallProductSkuInfo);
ExcelUtil<MallProductSkuInfo> util = new ExcelUtil<MallProductSkuInfo>(MallProductSkuInfo.class);
util.exportExcel(response, list, "商品SKU数据");
}
/**
* SKU
*/
@RequiresPermissions("product:sku:query")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return AjaxResult.success(mallProductSkuInfoService.selectMallProductSkuInfoById(id));
}
/**
* SKU
*/
@RequiresPermissions("product:sku:add")
@Log(title = "商品SKU", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody MallProductSkuInfo mallProductSkuInfo)
{
return toAjax(mallProductSkuInfoService.insertMallProductSkuInfo(mallProductSkuInfo));
}
/**
* SKU
*/
@RequiresPermissions("product:sku:edit")
@Log(title = "商品SKU", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody MallProductSkuInfo mallProductSkuInfo)
{
return toAjax(mallProductSkuInfoService.updateMallProductSkuInfo(mallProductSkuInfo));
}
/**
* SKU
*/
@RequiresPermissions("product:sku:remove")
@Log(title = "商品SKU", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(mallProductSkuInfoService.deleteMallProductSkuInfoByIds(ids));
}
}

View File

@ -0,0 +1,107 @@
package com.ruoyi.mall.product.controller;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.mall.product.domain.MallProductTypeInfo;
import com.ruoyi.mall.product.service.IMallProductTypeInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
* Controller
*
* @author DongZeLiang
* @date 2022-09-16
*/
@RestController
@RequestMapping("/type")
public class MallProductTypeInfoController extends BaseController
{
@Autowired
private IMallProductTypeInfoService mallProductTypeInfoService;
/**
*
*/
@RequiresPermissions("product:type:list")
@GetMapping("/list")
public AjaxResult list(MallProductTypeInfo mallProductTypeInfo)
{
List<MallProductTypeInfo> list = mallProductTypeInfoService.selectMallProductTypeInfoList(mallProductTypeInfo);
return AjaxResult.success(list);
}
@RequiresPermissions("product:type:list")
@GetMapping("/tree")
public AjaxResult tree()
{
MallProductTypeInfo mallProductTypeInfo = new MallProductTypeInfo();
mallProductTypeInfo.setParentId(0L);
List<MallProductTypeInfo> list = mallProductTypeInfoService.selectMallProductTypeInfoList(mallProductTypeInfo);
return AjaxResult.success(list);
}
/**
*
*/
@RequiresPermissions("product:type:export")
@Log(title = "商品类型", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, MallProductTypeInfo mallProductTypeInfo)
{
List<MallProductTypeInfo> list = mallProductTypeInfoService.selectMallProductTypeInfoList(mallProductTypeInfo);
ExcelUtil<MallProductTypeInfo> util = new ExcelUtil<MallProductTypeInfo>(MallProductTypeInfo.class);
util.exportExcel(response, list, "商品类型数据");
}
/**
*
*/
@RequiresPermissions("product:type:query")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return AjaxResult.success(mallProductTypeInfoService.selectMallProductTypeInfoById(id));
}
/**
*
*/
@RequiresPermissions("product:type:add")
@Log(title = "商品类型", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody MallProductTypeInfo mallProductTypeInfo)
{
return toAjax(mallProductTypeInfoService.insertMallProductTypeInfo(mallProductTypeInfo));
}
/**
*
*/
@RequiresPermissions("product:type:edit")
@Log(title = "商品类型", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody MallProductTypeInfo mallProductTypeInfo)
{
return toAjax(mallProductTypeInfoService.updateMallProductTypeInfo(mallProductTypeInfo));
}
/**
*
*/
@RequiresPermissions("product:type:remove")
@Log(title = "商品类型", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(mallProductTypeInfoService.deleteMallProductTypeInfoByIds(ids));
}
}

View File

@ -0,0 +1,51 @@
package com.ruoyi.mall.product.controller;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.rabbit.domain.Message;
import com.ruoyi.common.rabbit.enums.QueueEnum;
import com.ruoyi.mall.product.cache.ProductInfoCache;
import com.ruoyi.mall.product.domain.reponse.ProductDetailsResponse;
import com.ruoyi.mall.product.service.IMallProductInfoService;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
* @author DongZl
* @description:
* @Date 2022-10-19 02:46
*/
@RestController
@RequestMapping("/test")
public class TestController {
@Autowired
private ProductInfoCache productInfoCache;
@Autowired
private RabbitTemplate rabbitTemplate;
@Autowired
private IMallProductInfoService productInfoService;
@GetMapping("/{id}")
public R get(@PathVariable Long id){
ProductDetailsResponse productDetailsResponse = productInfoCache.get(id);
return R.ok(productDetailsResponse);
}
@GetMapping("/refreshData/{id}")
private R refreshData(@PathVariable Long id){
return R.ok(productInfoCache.refreshData(id));
}
@PostMapping("/sendMsg/{msg}")
public R sendMsg(@PathVariable("msg") String msg){
// ProductInfoResponse productInfoResponse = productInfoService.selectMallProductInfoById(10L);
rabbitTemplate.convertAndSend(QueueEnum.PRODUCT_ADD.queueName(),
Message.builderMsg(11L));
return R.ok();
}
}

View File

@ -0,0 +1,39 @@
package com.ruoyi.mall.product.mapper;
import com.ruoyi.mall.product.domain.CusProductBrandAttentionInfo;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface CusProductBrandInfoMapper {
/**
*
* @return
*/
List<CusProductBrandAttentionInfo> findAttention(@Param("id") Long id);
/**
* id
* @param brandId
* @return
*/
CusProductBrandAttentionInfo attentionDetail(@Param("brandId") Integer brandId, @Param("id") Long id);
/**
*
* @param cusProductBrandAttentionInfo
*/
int addAttention(CusProductBrandAttentionInfo cusProductBrandAttentionInfo);
/**
*
* @param brandId
*/
void delAttention(@Param("brandId") Integer brandId, @Param("id") Long id);
int delectAttention();
}

View File

@ -0,0 +1,88 @@
package com.ruoyi.mall.product.mapper;
import com.ruoyi.mall.product.domain.CMallProductAddress;
import com.ruoyi.mall.product.domain.MallCProductSkuInfoAll;
import com.ruoyi.mall.product.domain.MallProductInfo;
import com.ruoyi.mall.product.domain.model.ProductModel;
import com.ruoyi.mall.user.domain.CusUser;
import org.apache.ibatis.annotations.Param;
import java.util.ArrayList;
import java.util.List;
/**
* Mapper
*
* @author DongZeLiang
* @date 2022-09-19
*/
public interface MallCProductInfoMapper
{
/**
*
*
* @param id
* @return
*/
public MallProductInfo selectMallProductInfoById(@Param("id")Long id);
public ProductModel selectProductModelById(@Param("id") Long id);
/**
*
*
* @param mallProductInfo
* @return
*/
public List<MallCProductSkuInfoAll> selectMallProductInfoList(MallCProductSkuInfoAll mallProductInfo);
/**
*
*
* @param mallProductInfo
* @return
*/
public int insertMallProductInfo(MallProductInfo mallProductInfo);
/**
*
*
* @param mallProductInfo
* @return
*/
public int updateMallProductInfo(MallProductInfo mallProductInfo);
/**
*
*
* @param id
* @return
*/
public int deleteMallProductInfoById(Long id);
/**
*
*
* @param ids
* @return
*/
public int deleteMallProductInfoByIds(Long[] ids);
/**
*
* @param mallProductInfo
* @return
*/
Long selectMallProductInfoCount (MallProductInfo mallProductInfo);
int updaload(@Param("id") Long id, @Param("isUpload") boolean isUpload);
int addressadd(CMallProductAddress mallProductAddress);
ArrayList<CMallProductAddress> listaddress(CusUser cusUser);
CMallProductAddress selectaddressId(@Param("addressId") Integer addressId, @Param("id") Long id);
int delectaddress(@Param("addressId")Integer addressId, @Param("id") Long id);
}

View File

@ -0,0 +1,62 @@
package com.ruoyi.mall.product.mapper;
import com.ruoyi.mall.product.domain.MallProductBrandInfo;
import java.util.List;
/**
* Mapper
*
* @author DongZeLiang
* @date 2022-09-15
*/
public interface MallProductBrandInfoMapper
{
/**
*
*
* @param id
* @return
*/
public MallProductBrandInfo selectMallProductBrandInfoById(Long id);
/**
*
*
* @param mallProductBrandInfo
* @return
*/
public List<MallProductBrandInfo> selectMallProductBrandInfoList(MallProductBrandInfo mallProductBrandInfo);
/**
*
*
* @param mallProductBrandInfo
* @return
*/
public int insertMallProductBrandInfo(MallProductBrandInfo mallProductBrandInfo);
/**
*
*
* @param mallProductBrandInfo
* @return
*/
public int updateMallProductBrandInfo(MallProductBrandInfo mallProductBrandInfo);
/**
*
*
* @param id
* @return
*/
public int deleteMallProductBrandInfoById(Long id);
/**
*
*
* @param ids
* @return
*/
public int deleteMallProductBrandInfoByIds(Long[] ids);
}

Some files were not shown because too many files have changed in this diff Show More