提交taoapi数据库设计

This commit is contained in:
启航 2024-02-28 18:12:46 +08:00
parent 09280d880f
commit 78f9ead2e9
11 changed files with 3393 additions and 3109 deletions

View File

@ -74,6 +74,29 @@ oms项目公用基础微服务主要功能包括
+ 运行`pnpm run dev`
+ 浏览网页`http://localhost:3000`
## 项目部署
```
# 项目打包
pnpm run build:prod
# 上传文件至远程服务器
将打包生成在 `dist` 目录下的文件拷贝至 `/usr/share/nginx/html` 目录
# nginx.cofig 配置
server {
listen 80;
server_name localhost;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
# 反向代理配置
location /prod-api/ {
proxy_pass http://vapi.youlai.tech/; # vapi.youlai.tech替换成你的后端API地址
}
}
```
💖 如果觉得有用记得点 Star⭐

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,51 @@
# 数据库设计
## 商品模块
### 淘宝商品表
| 字段 | 类型 | 示例值 | 描述 |
| --- | --- | ---- |-------------------------------|
|approve_status | String | onsale | 商品上传后的状态。onsale出售中instock库中 |
|iid | String | 13232 | 商品iid |
|num_iid | Number | 1489161932 | 商品数字id |
|title | String | Google test item 商品标题,不能超过60字节 |
|nick | String | tbtest561 | 卖家昵称 | |
|type | String | fixed | 商品类型(fixed:一口价;auction:拍卖)注:取消团购 |
|cid | Number | 132443 | 商品所属的叶子类目 id |
|seller_cids | String | 2234445,3344466,446434 | 商品所属的店铺内卖家自定义类目列表 |
|pic_url | String | ![](http://img03.taobao.net/bao/uploaded/i3/T1HXdXXgPSt0JxZ2.8_070458.jpg) | 商品主图片地址 |
|num | Number | 8888 | 商品数量 |
|props | String | 135255:344454 | 商品属性 格式pid:vid;pid:vid |
|valid_thru | Number | 7 | 有效期,7或者14默认是7天 |
|list_time | Date | 2009-10-22 14:22:06 | 上架时间格式yyyy-MM-dd HH:mm:ss |
|price | String | 5.00 | 商品价格格式5.00;单位:元;精确到:分 |
|has_discount | Boolean | true | 支持会员打折,true/false |
|has_invoice | Boolean | true | 是否有发票,true/false |
|has_warranty | Boolean | true | 是否有保修,true/false |
|has_showcase | Boolean | true | 橱窗推荐,true/false |
|modified | Date | 2000-01-01 00:00:00 | 商品修改时间格式yyyy-MM-dd HH:mm:ss |
|delist_time | Date | 2000-01-01 00:00:00 | 下架时间格式yyyy-MM-dd HH:mm:ss |
|postage_id | Number | 32 | 宝贝所属的运费模板ID如果没有返回则说明没有使用运费模板 |
|outer_id | String | 34143554352 | 商家外部编码(可与商家外部系统对接)。需要授权才能获取。 |
|is_ex | Boolean | true | 是否在外部网店显示 |
|is_virtual | Boolean | true | 虚拟商品的状态字段 |
|is_taobao | Boolean | true | 是否在淘宝显示 |
|sold_quantity | Number | 8888 | 商品销量 |
|is_cspu | Boolean | true | 是否为达尔文挂接成功了的商品 |
|first_starts_time | Date | 2000-01-01 00:00:00 | 商品首次上架时间 |
### 淘宝商品SKU表
| 名称 | 类型 | 示例值 | 描述 |
|------------------| --- | ---- |-------------------------------|
| sku_id |Number |123 |sku的id |
| iid |String |asdf12323adfaa |sku所属商品id(注意iid近期即将废弃请用num_iid参数) |
| num_iid |Number |12345 |sku所属商品数字id |
| properties |String |1243:1215;5626:5125 |sku的销售属性组合字符串颜色大小等等可通过类目API获取某类目下的销售属性,格式是p1:v1;p2:v2 |
| properties_name |String |20000:3275069:品牌:盈讯;1753146:3485013:型号:F908;-1234:-5678:自定义属性1:属性值1 |sku所对应的销售属性的中文名字串格式如pid1:vid1:pid_name1:vid_name1;pid2:vid2:pid_name2:vid_name2…… |
| quantity |Number |3 |属于这个sku的商品的数量 |
| price |String |200.07 |属于这个sku的商品的价格 取值范围:0-100000000;精确到2位小数;单位:元。如:200.07,表示:200元7分。 |
| outer_id |String |12345 |商家设置的外部id。天猫和集市的卖家需要登录才能获取到自己的商家编码不能获取到他人的商家编码。 |
| created |String | 2009-11-04 15:24:43 |sku创建日期 时间格式yyyy-MM-dd HH:mm:ss |
| modified |String |2009-11-04 15:24:43 | sku最后修改日期 时间格式yyyy-MM-dd HH:mm:ss |
| status |String |normal |sku状态。 | normal:正常-delete:删除 |
| sku_spec_id |Number |123 |表示SKu上的产品规格信息 |
| barcode |String | 6903244981002 |商品级别的条形码 |

3034
doc/sql/qihang-oms.sql Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,142 @@
package com.qihang.tao.controller;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class GoodsApiController {
/**
* @api {post} /api/v1/pull_goods 更新店铺商品列表
* @apiVersion 1.0.0
* @apiName pullGoods
* @apiGroup taoGood
* @apiParam {String} startTime 开始时间
* @apiParam {String} endTime 结束时间
* @apiParam {Number} shopId 店铺id(东方符号7)
* @apiSuccessExample {json} Success-Response:
* HTTP/1.1 200 OK{
"code": "0成功其他失败",
"msg": "成功或失败信息"
}
*/
@RequestMapping(value = "/pull_goods", method = RequestMethod.POST)
public ApiResult<Integer> getOrderList(@RequestBody DataRow reqData, HttpServletRequest request) throws Exception {
String startDate = reqData.getString("startTime");
String endDate = reqData.getString("endTime");
Integer shopId=reqData.getInt("shopId");
var checkResult = this.check(shopId);
if (checkResult.getCode() != EnumResultVo.SUCCESS.getIndex()) {
return new ApiResult<>(checkResult.getCode(), checkResult.getMsg());
}
Integer pageIndex = 1;
Integer pageSize = 40;
Long endTime = System.currentTimeMillis() / 1000;//更新结束时间
Long startTime = endTime-(60 * 60 * 24 * 7);//更新开始时间
if(!StringUtils.isEmpty(startDate))startTime = DateUtil.dateToStamp(startDate).longValue();
if (!StringUtils.isEmpty(endDate)) endTime = DateUtil.dateTimeToStamp(endDate + " 23:59:00").longValue();
long kaishidaojiesu = endTime - startTime;
long forSize = (kaishidaojiesu % (60 * 60 * 24 * 7) == 0) ? kaishidaojiesu / (60 * 60 * 24 * 7) : kaishidaojiesu / (60 * 60 * 24 * 7) + 1;//计算需要循环的次数
for (int i = 0; i < forSize; i++) {
Long startTime1 = startTime + i * 60 * 60 * 24 * 7;
Long endTime1 = startTime1 + 60 * 60 * 24 * 7;
Integer totalCount = pullGoods(checkResult.getData(),pageIndex,pageSize,startTime1,endTime1);
int totalPage = (totalCount % pageSize == 0) ? totalCount / pageSize : (totalCount / pageSize) + 1;
while (pageIndex < totalPage) {
pageIndex++;
pullGoods(checkResult.getData(),pageIndex,pageSize,startTime1,endTime1);
}
pageIndex=1;
}
return new ApiResult<>(EnumResultVo.SUCCESS.getIndex(), "SUCCESS");
}
public Integer pullGoods(DcSysThirdSettingEntity result, Integer pageNo, Integer pageSize, Long startTime, Long endTime) throws Exception{
String sendUrl="http://gw.api.taobao.com/router/rest";
Map<String, String> params = new HashMap<>();
params.put("method","taobao.items.onsale.get");
params.put("app_key",result.getAppKey());
params.put("sign_method","md5");
params.put("timestamp",String.valueOf(System.currentTimeMillis()));
params.put("session",result.getAccess_token());
params.put("v","2.0");
params.put("fields","approve_status,num_iid,title,pic_url,num,list_time,price,delist_time,outer_id,sold_quantity,modified");
params.put("nick",result.getName());
params.put("page_no",String.valueOf(pageNo));
params.put("page_size",String.valueOf(pageSize));
params.put("start_modified",DateUtil.stampToDateTime(startTime));
params.put("end_modified",DateUtil.stampToDateTime(endTime));
params.put("sign",ExpressClient.buildSign(params,result.getAppSecret()));
HttpResponse<String> response = HttpUtil.doPost(sendUrl,HttpUtil.map2Url(params));
var dd = XmlUtil.xmlToJson(response.body());
if(dd.getInteger("total_results").intValue()>0){
var jsonArray= dd.getJSONObject("items").getJSONArray("item");
taoGoodService.addTaoGoods(jsonArray);
}
return dd.getInteger("total_results");
}
/**
* @api {post} /pull_goods_comment 更新商品评价
* @apiVersion 1.0.0
* @apiName pullGoodsComment
* @apiGroup taoGood
* @apiSuccessExample {json} Success-Response:
* HTTP/1.1 200 OK
* {
* "code": 0:成功,
* "msg": "信息"
* }
*/
/* @RequestMapping(value = "/pull_goods_comment", method = RequestMethod.POST)
public ApiResult<Integer> pullGoodsComments(HttpServletRequest request){
Integer shopId=7;
Integer pageIndex = 1;
Integer pageSize = 100;
Date startDate=StringUtils.isEmpty(taoGoodService.getGoodCommentDate()) ? DateUtil.beforeDayDate(180) : taoGoodService.getGoodCommentDate();
System.out.println(startDate);
var result = pullTaoGoodsComment(shopId,pageIndex,pageSize,startDate);
if(result.getCode()==0){
while (result.getData().intValue()>pageSize.intValue()) {
pageIndex++;
System.out.println(pageIndex);
pullTaoGoodsComment(shopId,pageIndex,pageSize,startDate);
}
return new ApiResult<>(EnumResultVo.SUCCESS.getIndex(),"成功");
}else return new ApiResult<>(EnumResultVo.Fail.getIndex(),"失败");
}*/
/* public ApiResult<Integer> pullTaoGoodsComment(Integer shopId,Integer pageIndex,Integer pageSize,Date startDate){
var result = this.check(shopId).getData();
TaobaoClient client = new DefaultTaobaoClient(result.getRequest_url(), result.getAppKey(), result.getAppSecret());
TraderatesGetRequest req = new TraderatesGetRequest();
req.setFields("tid,oid,role,nick,result,totalResults,hasNext,created,rated_nick,item_title,item_price,content,reply,num_iid");
req.setRateType("get");
req.setRole("buyer");
req.setStartDate(startDate);
req.setPageNo(pageIndex.longValue());
req.setPageSize(pageSize.longValue());
req.setUseHasNext(true);
try {
TraderatesGetResponse rsp = client.execute(req, result.getAccess_token());
if(rsp.getTradeRates().size()>0){
List<DcTaoGoodsCommentEntity> list =new ArrayList<>();
rsp.getTradeRates().forEach(c->{
DcTaoGoodsCommentEntity comment=new DcTaoGoodsCommentEntity();
comment.setNumIid(c.getNumIid());
comment.setBuyer(c.getNick());
comment.setCreated(c.getCreated());
comment.setTid(c.getTid());
comment.setOid(c.getOid());
comment.setComment(c.getContent());
comment.setResult(c.getResult());
list.add(comment);
});
taoGoodService.addGoodComment(list);
return new ApiResult<>(EnumResultVo.SUCCESS.getIndex(),"成功",rsp.getTradeRates().size());
}else return new ApiResult<>(EnumResultVo.SUCCESS.getIndex(),"失败");
}catch (Exception e){
return new ApiResult<>(EnumResultVo.Fail.getIndex(),"失败",0);
}
}*/
}

View File

@ -0,0 +1,22 @@
package com.qihang.tao.controller;
import com.qihang.tao.domain.TaoGoods;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RequestMapping("/goods")
@RestController
public class GoodsController {
@RequestMapping(value = "/list", method = RequestMethod.GET)
public ApiResult<List<TaoGoods>> goodsList(String key) {
try {
var result=taoGoodService.getList(req);
return new ApiResult<>(EnumResultVo.SUCCESS.getIndex(),"成功",result);
}catch (Exception ex){
return new ApiResult<>(EnumResultVo.Fail.getIndex(),EnumResultVo.Fail.getName()+ex.getMessage());
}
}
}

View File

@ -25,7 +25,7 @@ HomeController {
public String get(HttpServletRequest request) {
String token = request.getHeader("Authorization");
System.out.println("tao-api token:"+token);
//https://open.taobao.com/v2/doc?spm=a219a.15212433.0.0.6aca669aUe3Kme#/abilityToOpen?treeId=780&docType=1&docId=102635
TaoGoods taoGoods = goodsMapper.selectById(1L);
return serverName;

View File

@ -3,9 +3,85 @@ package com.qihang.tao.domain;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.math.BigDecimal;
@Data
@TableName("tao_goods")
public class TaoGoods {
/**
* 主键id自增长
*/
private Long id;
private Long goodsId;
/**
* tao商品id
*/
private Long numIid;
/**
* 商品标题
*/
private String title;
/**
* 商品主图
*/
private String picUrl;
/**
* 商品价格
*/
private BigDecimal price;
/**
* 商品数量
*/
private Long num;
/**
* 商品状态onsale出售中instock库中
*/
private String approveStatus;
/**
* 商品外部编码
*/
private String outerId;
/**
* 商品销量
*/
private Long soldQuantity;
/**
* 上架时间
*/
private Long listTime;
/**
* 下架时间
*/
private Long delistTime;
/**
* 修改时间
*/
private Long modified;
/**
* 销售价
*/
private BigDecimal salesPrice;
/**
* 批发价
*/
private BigDecimal whslePrice;
/**
* 创建时间
*/
private Long createOn;
//标签
private String tag;
//评价数量
private Integer commentCount;
}

43
架构图.drawio Normal file
View File

@ -0,0 +1,43 @@
<mxfile host="app.diagrams.net" modified="2024-02-27T03:04:14.632Z" agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36" etag="xjO1iuWJkUFKg4xi2VTH" version="23.1.7" type="device">
<diagram name="第 1 页" id="VFYfww_sdWvGYr7hJFIg">
<mxGraphModel dx="1434" dy="746" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0">
<root>
<mxCell id="0" />
<mxCell id="1" parent="0" />
<mxCell id="7KIA_immedqvToHCkOJM-1" value="浏览器" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="100" y="70" width="440" height="60" as="geometry" />
</mxCell>
<mxCell id="7KIA_immedqvToHCkOJM-2" value="api网关" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="100" y="140" width="440" height="60" as="geometry" />
</mxCell>
<mxCell id="7KIA_immedqvToHCkOJM-3" value="sys-api" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="100" y="290" width="80" height="60" as="geometry" />
</mxCell>
<mxCell id="7KIA_immedqvToHCkOJM-4" value="tao-api" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="190" y="290" width="80" height="60" as="geometry" />
</mxCell>
<mxCell id="7KIA_immedqvToHCkOJM-5" value="jd-api" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="280" y="290" width="80" height="60" as="geometry" />
</mxCell>
<mxCell id="7KIA_immedqvToHCkOJM-6" value="doudian-api" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="370" y="290" width="80" height="60" as="geometry" />
</mxCell>
<mxCell id="7KIA_immedqvToHCkOJM-7" value="pdd-api" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="460" y="290" width="80" height="60" as="geometry" />
</mxCell>
<mxCell id="7KIA_immedqvToHCkOJM-8" value="Redis" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="100" y="450" width="120" height="60" as="geometry" />
</mxCell>
<mxCell id="7KIA_immedqvToHCkOJM-9" value="MySQL" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="240" y="450" width="300" height="60" as="geometry" />
</mxCell>
<mxCell id="7KIA_immedqvToHCkOJM-10" value="Nacos服务注册中心" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="100" y="213" width="440" height="60" as="geometry" />
</mxCell>
<mxCell id="7KIA_immedqvToHCkOJM-11" value="Nacos配置中心" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="100" y="362" width="440" height="60" as="geometry" />
</mxCell>
</root>
</mxGraphModel>
</diagram>
</mxfile>

BIN
软件架构图.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB