diff --git a/PROJECT_DESCRIPTION.md b/PROJECT_DESCRIPTION.md new file mode 100644 index 0000000..5315ed0 --- /dev/null +++ b/PROJECT_DESCRIPTION.md @@ -0,0 +1,334 @@ +# kfzgw-info 项目技术文档 + +## 项目概述 + +**kfzgw-info** 是一个基于 Go 语言开发的桌面应用程序,主要功能是作为 **"核价软件更新器"**,自动检测、下载和更新 "核价软件"(VerifyPriceApp)及相关 DLL 组件。项目同时包含了与 **孔夫子旧书网(kongfz.com)**、**拼多多(PDD)**、**ERP 系统**等平台的 API 集成模块。 + +> 项目名称中的 "kfzgw" 推测为 "孔夫子旧书网" 的缩写(KongFuZi - 古玩/旧书网)。 + +--- + +## 技术栈 + +| 技术 | 用途 | +|------|------| +| **Go 1.26** | 主要开发语言 | +| **Gio UI (gioui.org)** | 桌面图形界面框架 | +| **Gin** | HTTP Web 框架 | +| **Elasticsearch** | 搜索引擎客户端 | +| **Redis** | 缓存/消息队列 | +| **MySQL (go-sql-driver)** | 关系型数据库 | +| **SQLite (modernc.org/sqlite)** | 嵌入式数据库 | +| **Excelize** | Excel 文件读写 | +| **chromedp** | Chrome DevTools Protocol(无头浏览器) | +| **goquery** | HTML 解析(类 jQuery) | +| **gorequest** | HTTP 请求库 | +| **gozxing / qrcode / barcode** | 二维码/条码生成与识别 | +| **imaging / gg / freetype** | 图像处理与文字渲染 | +| **fasthttp** | 高性能 HTTP 客户端 | +| **YAML / INI** | 配置文件解析 | + +--- + +## 项目结构 + +``` +kfzgw-info/ +│ +├── walkingWithBooks.go # ▶ 主入口文件(GUI + 控制台更新器) +├── main.go # 旧版入口(已全部注释) +├── main_so.go # SO/DLL 导出封装(已注释) +├── newWalkingWithBooks.go # 新版入口(已注释,未使用) +├── dyso.go # 动态加载 SO 的 HTTP 服务(已注释) +├── go.mod / go.sum # Go 模块依赖 +├── version.yaml # 本地版本配置文件 +├── config.ini # 应用配置文件 +├── test.db # SQLite 测试数据库 +│ +├── config/ # 配置管理模块 +│ ├── config.go # - 配置文件读取器(支持 JSON/YAML/INI) +│ ├── configDll.go # - DLL 导出函数 +│ └── config.json # - 配置文件示例 +│ +├── csv/ # CSV 文件处理模块 +│ ├── csv.go # - CSV 读写(带句柄管理、自动关闭) +│ ├── newcsv.go # - 新版 CSV 处理 +│ ├── csvDll.go # - DLL 导出函数 +│ └── taskLog.csv # - 任务日志 CSV +│ +├── erp/ # ERP 接口转发模块 +│ └── erp.go # - API 转发(GET/POST/PUT) +│ +├── es/ # Elasticsearch 模块 +│ ├── es.go # - ES 客户端封装(索引管理、CRUD) +│ ├── esDll.go # - DLL 导出函数 +│ └── test.go # - 测试文件 +│ +├── excel/ # Excel 处理模块 +│ ├── excel_so.go # - Excel 合并/拆分(SO 导出) +│ └── main.go # - 示例/测试 +│ +├── expressDeliveryOrder/ # 快递单号处理模块 +│ └── expressDeliveryOrder.go +│ +├── gin/ # Gin Web 框架示例 +│ └── gin.go # - 简单的 HTTP 服务示例 +│ +├── goroutine-pool/ # 协程池 +│ ├── goroutine_pool.go # - 通用协程池实现 +│ └── goroutine_pool_test.go +│ +├── image/ # 图片处理模块 +│ ├── image.go # - 图片裁剪、缩放、水印、格式转换、二维码生成 +│ ├── imageDllTest.go # - DLL 测试 +│ └── imageTest.go # - 测试文件 +│ +├── kongfz/ # 孔夫子旧书网 API 模块 +│ ├── kongfz.go # - 图书/商品搜索、登录、发货等 API +│ ├── kongfzDll.go # - DLL 导出函数 +│ └── kongfzLao.go # - 旧版实现 +│ +├── listener/ # 文件监听器 +│ ├── listener.go # - 文件系统监听 +│ └── ceshi.go # - 测试 +│ +├── logger/ # 日志模块 +│ ├── logger.go # - 分级日志(支持分片、滚动) +│ └── loggerDll.go # - DLL 导出函数 +│ +├── monitor/ # 监控模块 +│ └── main.go # - 系统监控 +│ +├── pdd/ # 拼多多 API 模块 +│ ├── pdd.go # - 拼多多开放平台 API 封装(签名、商品管理) +│ └── pddDll.go # - DLL 导出函数 +│ +├── pddTask/ # 拼多多任务模块 +│ ├── pdd-task.go # - 拼多多定时任务 +│ └── common/pddDll.go # - DLL 调用公共组件 +│ +├── proxy/ # 代理管理模块 +│ ├── proxy.go # - 小象/尾巴代理动态切换 +│ ├── proxyLao.go # - 旧版代理实现 +│ └── proxy_so.go # - SO 导出函数 +│ +├── redis/ # Redis 客户端模块 +│ ├── redis.go # - Redis 客户端封装 +│ └── redisDll.go # - DLL 导出函数 +│ +├── sqlite/ # SQLite 模块 +│ └── sqLite.go # - SQLite CRUD 示例 +│ +├── timer/ # 定时器模块 +│ └── timer.go # - 时间轮定时器实现 +│ +├── xy/ # XY 模块(用途未知) +│ └── xy.go +│ +├── dll/ # Windows DLL 文件目录 +│ ├── csv.dll +│ ├── kongfz.dll +│ ├── logger.dll +│ ├── module-centerBook.dll +│ ├── module-erp.dll +│ ├── module-kongfz.dll +│ ├── module-login.dll +│ ├── module-taskPool.dll +│ ├── module-verifyPrice.dll +│ ├── picTool.dll +│ ├── proxy.dll +│ └── config/config.dll +│ +├── so/ # Linux .so 文件目录 +│ ├── erp.so +│ ├── kongfz.so +│ ├── pdd.so +│ └── xy.so +│ +└── md/ # 各模块文档目录 + ├── config.md + ├── csv.md + ├── es.md + ├── image.md + ├── kongfz.md + ├── logger.md + └── ... +``` + +--- + +## 模块详解 + +### 1. 主程序 — [walkingWithBooks.go](file:///d:/source/kfzgw-info/walkingWithBooks.go) + +这是当前**实际运行的主入口文件**,提供两种运行模式: + +#### GUI 模式(默认) +- 使用 **Gio UI** 框架构建桌面图形界面 +- 窗口大小 800×600,最小 600×400 +- 显示标题、状态信息、进度条、文件信息、日志区域 +- 底部控制按钮(暂停/继续/启动软件) +- 日志区域按类型显示不同颜色(信息=蓝、成功=绿、警告=黄、错误=红、下载=紫) + +#### 控制台模式(`--console` 参数) +- 使用 ANSI 彩色终端输出 +- 与旧版 main.go 相同的更新逻辑 + +#### 更新流程 +``` +初始化 → 检查核价软件版本 → 检查主程序并下载 +→ 检查 DLL 组件版本 → 更新所有 DLL +→ 完成 → 自动/手动启动核价软件 +``` + +--- + +### 2. 各模块功能 + +| 模块 | 包名 | 功能描述 | +|------|------|----------| +| **config** | `main` | 配置文件读取器,支持 JSON/YAML/INI 三种格式;提供 DLL 导出接口 | +| **csv** | `main` | CSV 文件的高效读写,支持句柄管理、自动关闭、线程安全 | +| **erp** | `main` | ERP 系统的 API 请求转发,支持 GET/POST/PUT | +| **es** | `main` | Elasticsearch 客户端封装,索引管理(创建/删除/查询/统计) | +| **excel** | `main` | Excel 文件的合并、拆分操作 | +| **goroutine-pool** | `main` | 通用协程池,管理和复用 goroutine | +| **image** | `main` | 图片处理:裁剪、缩放、旋转、水印、格式转换、二维码/条码生成与识别 | +| **kongfz** | `main` | 孔夫子旧书网接口:商品搜索、商品详情、登录、图片获取、快递费查询 | +| **listener** | `main` | 文件系统事件监听 | +| **logger** | `main` | 分级日志系统,支持按月/日/时/分/秒分片,按大小/数量滚动 | +| **pdd** | `main` | 拼多多开放平台 API:商品管理、订单处理、签名生成 | +| **proxy** | `main` | 动态代理管理,支持小象代理、尾巴代理等多种代理类型 | +| **redis** | `main` | Redis 客户端封装,支持连接池配置 | +| **sqlite** | `main` | SQLite 嵌入式数据库的 CRUD 操作示例 | +| **timer** | `main` | 基于时间轮的定时器实现,支持任务调度 | + +--- + +### 3. 孔夫子旧书网 API 集成(核心业务) + +[kongfz.go](file:///d:/source/kfzgw-info/kongfz/kongfz.go) 封装了大量孔网 API: + +| 函数 | 功能 | +|------|------| +| `outLogin()` | 账号密码登录,获取 PHPSESSID Token | +| `outGetUserMsg()` | 获取用户信息(ID、昵称、手机号) | +| `outGetGoodsTplMsg()` | 获取商品发布模板字段 | +| `outGetGoodsListMsgFromSelfShop()` | 查询自己的商品列表(支持分页/价格筛选) | +| `outDelGoodsFromSelfShop()` | 删除自有店铺中的商品 | +| `outAddGoods()` | 新增商品发布 | +| `outGetImageByIsbn()` | 根据 ISBN 获取图书官图/实拍图 | +| `outGetImageFilterShopId()` | 获取图片时过滤指定店铺 | +| `outGetGoodsListMsgByShopId()` | 按店铺 ID 拉取商品列表 | +| `outGetGoodsMsgByDetailUrl()` | 通过详情页 URL 获取商品信息(含快递费) | +| `outGetTopGoodsListMsg()` | 获取销量榜商品列表 | +| `FetchProductInfoWithChromedp()` | 使用无头浏览器获取店铺页动态内容 | +| `FetchBookDetailsShippingFee()` | 获取商品详情页快递费 | + +--- + +### 4. 配置文件 + +#### [config.ini](file:///d:/source/kfzgw-info/config.ini) + +```ini +[app] +max_retry_times = 3 # HTTP 请求最大重试次数 +rate_limit_delay = 500ms # 请求间隔 +size = 5 # 线程数/并发数 + +[proxy] +servers = http-dynamic.xiaoxiangdaili.com,... # 代理服务器列表 +username = ... # 代理账号 +password = ... # 代理密码 + +[api] +login_url = https://login.kongfz.com/... # 孔网登录接口 +book_search_url = ... # 图书搜索接口 +product_search_url = ... # 商品搜索接口 + +[server] +port = 9999 # HTTP 服务端口 + +[image] +target_dir = /file/goods_img/ # 图片保存路径 +domain = book.center.image.buzhiyushu.cn # 图片 CDN 域名 + +[database] +host = 146.56.227.42:3306 # MySQL 数据库 +name = newadmin +``` + +#### [version.yaml](file:///d:/source/kfzgw-info/version.yaml) + +```yaml +verifyPriceLatestVersion: v1.0 # 本地核价软件版本号 +``` + +--- + +### 5. 远程版本服务器 + +更新器从以下远程服务获取版本信息: + +| 地址 | 用途 | +|------|------| +| `https://newverifyprice.buzhiyushu.cn/verify_price_version.json` | 核价软件主程序版本信息 | +| `http://36.212.20.113:53300/version.json` | DLL 组件版本信息 | +| `http://36.212.20.113:53300/api/downLoad` | DLL 组件下载接口 | + +--- + +### 6. 编译与构建 + +项目主入口 [walkingWithBooks.go](file:///d:/source/kfzgw-info/walkingWithBooks.go) 编译为 Windows 可执行文件: + +```bash +# 编译 GUI 版本 +go build -o kfzgw-info.exe . + +# 可通过 --console 参数切换到控制台模式 +kfzgw-info.exe --console +``` + +部分子模块(如 `pdd`、`kongfz`、`csv`、`es`、`image`、`logger` 等)可编译为 **DLL** 供其他程序调用,通过 `//export` 注释导出 C 接口。 + +--- + +### 7. 关键依赖 + +``` +gioui.org # GUI 框架 +github.com/chromedp/chromedp # 无头浏览器操作 +github.com/PuerkitoBio/goquery # HTML 解析 +github.com/elastic/go-elasticsearch/v8 # ES 客户端 +github.com/gin-gonic/gin # Web 框架 +github.com/redis/go-redis/v9 # Redis 客户端 +github.com/xuri/excelize/v2 # Excel 操作 +github.com/parnurzeal/gorequest # HTTP 请求 +modernc.org/sqlite # SQLite 数据库 +github.com/valyala/fasthttp # 高性能 HTTP +gopkg.in/yaml.v3 # YAML 解析 +gopkg.in/ini.v1 # INI 解析 +``` + +--- + +## 架构特点 + +1. **模块化设计**:每个功能模块独立目录,部分可编译为 DLL 动态库 +2. **双模式运行**:支持 GUI 桌面模式和命令行控制台模式 +3. **远程版本管理**:自动检测远程版本号,增量更新 +4. **安全下载机制**:使用临时文件 + 重命名策略,防止文件损坏 +5. **代理支持**:内置小象/尾巴代理切换,支持爬虫场景 +6. **多平台兼容**:支持 Windows(DLL)和 Linux(SO)的动态库加载 + +--- + +## 使用场景 + +- **核价软件自动更新**:图书定价系统的基础设施 +- **孔夫子旧书网数据采集**:商品搜索、图片获取、价格监控 +- **拼多多商品管理**:商品上架/下架/订单处理 +- **ERP 系统对接**:与外部 ERP 系统的数据接口 +- **图片处理服务**:批量图片处理(裁剪、水印、格式转换) diff --git a/expressDeliveryOrder/dll/expressDeliveryOrder.dll b/expressDeliveryOrder/dll/expressDeliveryOrder.dll new file mode 100644 index 0000000..a9b11f3 Binary files /dev/null and b/expressDeliveryOrder/dll/expressDeliveryOrder.dll differ diff --git a/expressDeliveryOrder/dll/expressDeliveryOrder.h b/expressDeliveryOrder/dll/expressDeliveryOrder.h new file mode 100644 index 0000000..6233f60 --- /dev/null +++ b/expressDeliveryOrder/dll/expressDeliveryOrder.h @@ -0,0 +1,118 @@ +/* Code generated by cmd/cgo; DO NOT EDIT. */ + +/* package command-line-arguments */ + + +#line 1 "cgo-builtin-export-prolog" + +#include + +#ifndef GO_CGO_EXPORT_PROLOGUE_H +#define GO_CGO_EXPORT_PROLOGUE_H + +#ifndef GO_CGO_GOSTRING_TYPEDEF +typedef struct { const char *p; ptrdiff_t n; } _GoString_; +extern size_t _GoStringLen(_GoString_ s); +extern const char *_GoStringPtr(_GoString_ s); +#endif + +#endif + +/* Start of preamble from import "C" comments. */ + + +#line 3 "expressDeliveryOrder.go" + +#include + +#line 1 "cgo-generated-wrapper" + + +/* End of preamble from import "C" comments. */ + + +/* Start of boilerplate cgo prologue. */ +#line 1 "cgo-gcc-export-header-prolog" + +#ifndef GO_CGO_PROLOGUE_H +#define GO_CGO_PROLOGUE_H + +typedef signed char GoInt8; +typedef unsigned char GoUint8; +typedef short GoInt16; +typedef unsigned short GoUint16; +typedef int GoInt32; +typedef unsigned int GoUint32; +typedef long long GoInt64; +typedef unsigned long long GoUint64; +typedef GoInt64 GoInt; +typedef GoUint64 GoUint; +typedef size_t GoUintptr; +typedef float GoFloat32; +typedef double GoFloat64; +#ifdef _MSC_VER +#if !defined(__cplusplus) || _MSVC_LANG <= 201402L +#include +typedef _Fcomplex GoComplex64; +typedef _Dcomplex GoComplex128; +#else +#include +typedef std::complex GoComplex64; +typedef std::complex GoComplex128; +#endif +#else +typedef float _Complex GoComplex64; +typedef double _Complex GoComplex128; +#endif + +/* + static assertion to make sure the file is being used on architecture + at least with matching size of GoInt. +*/ +typedef char _check_for_64_bit_pointer_matching_GoInt[sizeof(void*)==64/8 ? 1:-1]; + +#ifndef GO_CGO_GOSTRING_TYPEDEF +typedef _GoString_ GoString; +#endif +typedef void *GoMap; +typedef void *GoChan; +typedef struct { void *t; void *v; } GoInterface; +typedef struct { void *data; GoInt len; GoInt cap; } GoSlice; + +#endif + +/* End of boilerplate cgo prologue. */ + +#ifdef __cplusplus +extern "C" { +#endif + +extern char* ZtoOpenCreateOrder(char* requestJSON, char* appKey, char* appSecret); +extern char* ZtoOpenCancelPreOrder(char* requestJSON, char* appKey, char* appSecret); +extern char* ZtoOpenGetOrderInfo(char* requestJSON, char* appKey, char* appSecret); +extern char* ZtoOpenQueryAvailableBalanceNew(char* requestJSON, char* appKey, char* appSecret); +extern char* ZtoOpenOrderPrint(char* requestJSON, char* appKey, char* appSecret); +extern char* ZtoOpenBindingEaccount(char* requestJSON, char* appKey, char* appSecret); +extern char* ZtoVipQuerySiteInfoByCode(char* requestJSON, char* appKey, char* appSecret); +extern char* JtOrderAddOrder(char* bizContentJSON, char* apiAccount, char* privateKey); +extern char* JtOrderV2AddOrder(char* bizContentJSON, char* apiAccount, char* privateKey); +extern char* JtOrderGetOrders(char* bizContentJSON, char* apiAccount, char* privateKey); +extern char* JtOrderCancelOrder(char* bizContentJSON, char* apiAccount, char* privateKey); +extern char* JtVipCheckCusPwd(char* bizContentJSON, char* apiAccount, char* privateKey); +extern char* JtEssBalance(char* bizContentJSON, char* apiAccount, char* privateKey); +extern char* JtBillCodeGetBatchBillCode(char* bizContentJSON, char* apiAccount, char* privateKey); +extern char* JtOrderPrintOrder(char* bizContentJSON, char* apiAccount, char* privateKey); +extern char* EmsAmpApiOpen(char* apiCode, char* senderNo, char* authorization, char* secretKey, char* requestJSON); +extern char* StoOmsExpressOrderCreate(char* requestJSON, char* fromAppkey, char* secretKey, char* fromCode); +extern char* YdCancelBmOrder(char* requestJSON, char* appKey, char* appSecret); +extern char* YdCreateBmOrder(char* requestJSON, char* appKey, char* appSecret); +extern char* YdSearchCount(char* requestJSON, char* appKey, char* appSecret); +extern char* YdBmGetPdfInfo(char* requestJSON, char* appKey, char* appSecret); +extern char* YdUpdateBmOrder(char* requestJSON, char* appKey, char* appSecret); +extern void FreeCString(char* str); +extern char* RequestSto(char* apiName, char* appkey, char* code, char* secretKey, char* toKey, char* requestJSON); +extern char* RequestYto(char* apiName, char* customerCode, char* secretKey, char* requestJSON); + +#ifdef __cplusplus +} +#endif diff --git a/expressDeliveryOrder/expressDeliveryOrder.go b/expressDeliveryOrder/expressDeliveryOrder.go index 82c062a..ecb8171 100644 --- a/expressDeliveryOrder/expressDeliveryOrder.go +++ b/expressDeliveryOrder/expressDeliveryOrder.go @@ -14,7 +14,9 @@ import ( "io" "mime/multipart" "net/http" + "net/url" "sort" + "strconv" "strings" "time" "unsafe" @@ -1260,7 +1262,10 @@ func ydSearchCount(requestJSON, appKey, appSecret string) (string, error) { if err != nil { return "", fmt.Errorf("排序失败: %v", err) } - fmt.Println("排序后的JSON字符串:", key) + + sign := ydGenerateSign(key, appSecret) + + fmt.Println("appKey=", appKey, " appSecret=", appSecret, " requestJSON=", requestJSON, " sign=", sign) // 3. 构建 Headers(根据文档) timestamp := time.Now().UnixMilli() @@ -1268,7 +1273,7 @@ func ydSearchCount(requestJSON, appKey, appSecret string) (string, error) { "Content-Type": "application/json; charset=UTF-8", "app-key": appKey, "req-time": fmt.Sprintf("%d", timestamp), - "sign": ydGenerateSign(key, appSecret), // 需要实现签名方法 + "sign": sign, // 需要实现签名方法 } // 4. 发送请求 @@ -2062,26 +2067,26 @@ func (m *MultipartFormData) AddFile(fieldName, fileName string, fileData []byte) ///**********************************************************申通开始***************************************************************// // 构建请求数据 -func getStoHeader(apiName string, appkey string, code string, secretKey string, content string) map[string]string { +func getStoHeader(apiName string, appkey string, code string, secretKey string, toKey string, content string) map[string]string { dataDigest := getStoSignature(content, secretKey) var param = map[string]string{ "api_name": apiName, "content": content, "from_appkey": appkey, "from_code": code, - "to_appkey": "sto_oms", - "to_code": "sto_oms", + "to_appkey": toKey, + "to_code": toKey, "data_digest": dataDigest, } return param } -func requestSto(apiName string, appkey string, code string, secretKey string, content string) (string, error) { +func requestSto(apiName string, appkey string, code string, secretKey string, toKey string, content string) (string, error) { //var url = "http://cloudinter-linkgatewaytest.sto.cn/gateway/link.do" url := "https://cloudinter-linkgateway.sto.cn/gateway/link.do" // 获取请求参数 - params := getStoHeader(apiName, appkey, code, secretKey, content) + params := getStoHeader(apiName, appkey, code, secretKey, toKey, content) // 创建 multipart form-data 请求体 body := &bytes.Buffer{} @@ -2137,13 +2142,14 @@ func getStoSignature(content, secretKey string) string { // RequestSto 申通快递统一请求为入口 // //export RequestSto -func RequestSto(apiName, appkey, code, secretKey, requestJSON *C.char) *C.char { +func RequestSto(apiName, appkey, code, secretKey, toKey, requestJSON *C.char) *C.char { apiNameStr := C.GoString(apiName) appkeyStr := C.GoString(appkey) codeStr := C.GoString(code) secretKeyStr := C.GoString(secretKey) + toKeyStr := C.GoString(toKey) requestJSONStr := C.GoString(requestJSON) - info, err := requestSto(apiNameStr, appkeyStr, codeStr, secretKeyStr, requestJSONStr) + info, err := requestSto(apiNameStr, appkeyStr, codeStr, secretKeyStr, toKeyStr, requestJSONStr) if err != nil { return C.CString(err.Error()) } @@ -2152,6 +2158,70 @@ func RequestSto(apiName, appkey, code, secretKey, requestJSON *C.char) *C.char { ///**********************************************************申通结束***************************************************************// +///**********************************************************圆通开始***************************************************************// + +func requestYto(apiName, customerCode, secretKey, requestJSON string) (string, error) { + // 构建URL + //urlStr := fmt.Sprintf("https://openuat.yto56test.com:6443/open/%s/v1/zc0IzW/%s", apiName, customerCode) + urlStr := fmt.Sprintf("https://openapi.yto.net.cn:11443/open/%s/v1/zc0IzW/%s", apiName, customerCode) + + // 当前毫秒级时间戳(13位) + timestamp := strconv.FormatInt(time.Now().UnixMilli(), 10) + + // 构建待签名字符串: param + method + v + // 注意:method应该是apiName,版本号根据URL中的v1确定 + dataToSign := requestJSON + apiName + "v1" + + // 生成签名 + sign := EncryptSignForOpen(dataToSign, secretKey) + + // 构建请求参数 + params := url.Values{} + params.Set("timestamp", timestamp) + params.Set("param", requestJSON) + params.Set("sign", sign) + params.Set("format", "JSON") + + // 发送POST请求 + resp, err := http.PostForm(urlStr, params) + if err != nil { + return "", err + } + defer resp.Body.Close() + + // 读取响应 + body, err := io.ReadAll(resp.Body) + if err != nil { + return "", err + } + return string(body), nil +} + +// EncryptSignForOpen 开放平台公共加密方法 +func EncryptSignForOpen(data string, secret string) string { + combined := data + secret + hash := md5.Sum([]byte(combined)) + sign := base64.StdEncoding.EncodeToString(hash[:]) + return sign +} + +// RequestYto 申通快递统一请求为入口 +// +//export RequestYto +func RequestYto(apiName, customerCode, secretKey, requestJSON *C.char) *C.char { + apiNameStr := C.GoString(apiName) + customerCodeStr := C.GoString(customerCode) + secretKeytr := C.GoString(secretKey) + requestJSONStr := C.GoString(requestJSON) + info, err := requestYto(apiNameStr, customerCodeStr, secretKeytr, requestJSONStr) + if err != nil { + return C.CString(err.Error()) + } + return C.CString(info) +} + +///**********************************************************圆通结束***************************************************************// + // 主函数 func main() { //apiName := "OMS_EXPRESS_ORDER_CREATE" @@ -2159,10 +2229,29 @@ func main() { //code := "CAKgwDceADOybmU" //secretKey := "2kLMr75pURbVh3FnWzY6SCr7SM6qsoO3" //content := "{\"orderNo\":\"8885452262\",\"orderSource\":\"****\",\"billType\":\"00\",\"orderType\":\"01\",\"sender\":{\"name\":\"测试名称\",\"tel\":\"0558-45778586\",\"mobile\":\"18775487548\",\"postCode\":\"100001\",\"country\":\"中国\",\"province\":\"安徽\",\"city\":\"合肥\",\"area\":\"泸州\",\"town\":\"测试镇\",\"address\":\"XX街道XX小区XX楼888\"},\"receiver\":{\"name\":\"测试名称\",\"tel\":\"0556-45778586\",\"mobile\":\"15575487548\",\"postCode\":\"100001\",\"country\":\"中国\",\"province\":\"河北\",\"city\":\"湖州\",\"area\":\"江汉\",\"town\":\"收件镇\",\"address\":\"XX街道XX小区XX楼666\",\"safeNo\":\"13466666632-0011\"},\"cargo\":{\"battery\":\"10\",\"goodsType\":\"大件\",\"goodsName\":\"XX物\",\"goodsCount\":10,\"spaceX\":10,\"spaceY\":10,\"spaceZ\":10,\"weight\":10,\"goodsAmount\":\"100\",\"cargoItemList\":[{\"serialNumber\":\"8451234\",\"referenceNumber\":\"88838783634\",\"productId\":\"001\",\"name\":\"小商品\",\"qty\":10,\"unitPrice\":1,\"amount\":10,\"currency\":\"美元\",\"weight\":10,\"remark\":\"无\"}]},\"customer\":{\"siteCode\":\"666666\",\"customerName\":\"666666000001\",\"sitePwd\":\"***\",\"monthCustomerCode\":\"9000000\"},\"internationalAnnex\":{\"internationalProductType\":\"01\",\"customsDeclaration\":false,\"senderCountry\":\"中国\",\"receiverCountry\":\"俄罗斯\"},\"waybillNo\":\"59635456632\",\"assignAnnex\":{\"takeCompanyCode\":\"862456565466\",\"takeUserCode\":\"9000000007\"},\"codValue\":\"2000\",\"freightCollectValue\":\"20\",\"timelessType\":\"01\",\"productType\":\"01\",\"serviceTypeList\":[\"***\"],\"extendFieldMap\":{\"mapValue\":\"***\"},\"remark\":\"无备注\",\"expressDirection\":\"01\",\"createChannel\":\"01\",\"regionType\":\"01\",\"insuredAnnex\":{\"insuredValue\":\"6.66\",\"goodsValue\":\"6.66\"},\"expectValue\":\"10\",\"payModel\":\"1\"}" - //info, err := requestSto(apiName, appkey, code, secretKey, content) + + //apiName := "BILL_CODE_QUERY_USER_STOCK" + //appkey := "CAKDVcNVcjgqoKH" + //code := "CAKDVcNVcjgqoKH" + //secretKey := "3ySS5owwn6ENOSespB2c9fROojSAllA0" + //toKey := "billcode_open" + //content := "{\"siteCode\":\"130370\",\"userCode\":\"130370000295\",\"timestamp\":\"1781318163\",\"userType\":\"0\",\"password\":\"123456\",\"billSource\":\"0\"}" + // + //info, err := requestSto(apiName, appkey, code, secretKey, toKey, content) //if err != nil { // fmt.Println(err) // return //} + //fmt.Println(info) + //apiName := "privacy_create_adapter" + //customerCode := "K24079264" + //secretKey := "XII4ecRl" + //requestJSON := "{\"logisticsNo\":\"o362rAIY6DO\",\"senderName\":\"测试1\",\"senderProvinceName\":\"上海\",\"senderCityName\":\"上海市\",\"senderCountyName\":\"青浦区\",\"senderAddress\":\"汇金路100号\",\"senderMobile\":\"15900521555\",\"recipientName\":\"测试\",\"recipientProvinceName\":\"重庆\",\"recipientCityName\":\"重庆市\",\"recipientCountyName\":\"万州区\",\"recipientAddress\":\"汇金路100好\",\"recipientMobile\":\"021-59815121\",\"remark\":\"remark-test\",\"gotCode\":\"123\",\"increments\":[{\"type\":4,\"amount\":888}],\"goods\":[{\"name\":\"mobile\",\"weight\":5,\"length\":10,\"width\":20,\"height\":5,\"price\":100,\"quantity\":1},{\"name\":\"mobile1\",\"weight\":1,\"length\":1,\"width\":1,\"height\":1,\"price\":1,\"quantity\":1}],\"startTime\":\"2022-09-07 17:25:01\",\"endTime\":\"2022-09-07 17:25:01\",\"cstOrderNo\":\"csorderno\",\"weight\":5,\"productCode\":\"PK\"}" + //yto, err := requestYto(apiName, customerCode, secretKey, requestJSON) + //if err != nil { + // fmt.Println(err) + // return + //} + //fmt.Println(yto) } diff --git a/expressDeliveryOrder/so/expressDeliveryOrder.h b/expressDeliveryOrder/so/expressDeliveryOrder.h new file mode 100644 index 0000000..6233f60 --- /dev/null +++ b/expressDeliveryOrder/so/expressDeliveryOrder.h @@ -0,0 +1,118 @@ +/* Code generated by cmd/cgo; DO NOT EDIT. */ + +/* package command-line-arguments */ + + +#line 1 "cgo-builtin-export-prolog" + +#include + +#ifndef GO_CGO_EXPORT_PROLOGUE_H +#define GO_CGO_EXPORT_PROLOGUE_H + +#ifndef GO_CGO_GOSTRING_TYPEDEF +typedef struct { const char *p; ptrdiff_t n; } _GoString_; +extern size_t _GoStringLen(_GoString_ s); +extern const char *_GoStringPtr(_GoString_ s); +#endif + +#endif + +/* Start of preamble from import "C" comments. */ + + +#line 3 "expressDeliveryOrder.go" + +#include + +#line 1 "cgo-generated-wrapper" + + +/* End of preamble from import "C" comments. */ + + +/* Start of boilerplate cgo prologue. */ +#line 1 "cgo-gcc-export-header-prolog" + +#ifndef GO_CGO_PROLOGUE_H +#define GO_CGO_PROLOGUE_H + +typedef signed char GoInt8; +typedef unsigned char GoUint8; +typedef short GoInt16; +typedef unsigned short GoUint16; +typedef int GoInt32; +typedef unsigned int GoUint32; +typedef long long GoInt64; +typedef unsigned long long GoUint64; +typedef GoInt64 GoInt; +typedef GoUint64 GoUint; +typedef size_t GoUintptr; +typedef float GoFloat32; +typedef double GoFloat64; +#ifdef _MSC_VER +#if !defined(__cplusplus) || _MSVC_LANG <= 201402L +#include +typedef _Fcomplex GoComplex64; +typedef _Dcomplex GoComplex128; +#else +#include +typedef std::complex GoComplex64; +typedef std::complex GoComplex128; +#endif +#else +typedef float _Complex GoComplex64; +typedef double _Complex GoComplex128; +#endif + +/* + static assertion to make sure the file is being used on architecture + at least with matching size of GoInt. +*/ +typedef char _check_for_64_bit_pointer_matching_GoInt[sizeof(void*)==64/8 ? 1:-1]; + +#ifndef GO_CGO_GOSTRING_TYPEDEF +typedef _GoString_ GoString; +#endif +typedef void *GoMap; +typedef void *GoChan; +typedef struct { void *t; void *v; } GoInterface; +typedef struct { void *data; GoInt len; GoInt cap; } GoSlice; + +#endif + +/* End of boilerplate cgo prologue. */ + +#ifdef __cplusplus +extern "C" { +#endif + +extern char* ZtoOpenCreateOrder(char* requestJSON, char* appKey, char* appSecret); +extern char* ZtoOpenCancelPreOrder(char* requestJSON, char* appKey, char* appSecret); +extern char* ZtoOpenGetOrderInfo(char* requestJSON, char* appKey, char* appSecret); +extern char* ZtoOpenQueryAvailableBalanceNew(char* requestJSON, char* appKey, char* appSecret); +extern char* ZtoOpenOrderPrint(char* requestJSON, char* appKey, char* appSecret); +extern char* ZtoOpenBindingEaccount(char* requestJSON, char* appKey, char* appSecret); +extern char* ZtoVipQuerySiteInfoByCode(char* requestJSON, char* appKey, char* appSecret); +extern char* JtOrderAddOrder(char* bizContentJSON, char* apiAccount, char* privateKey); +extern char* JtOrderV2AddOrder(char* bizContentJSON, char* apiAccount, char* privateKey); +extern char* JtOrderGetOrders(char* bizContentJSON, char* apiAccount, char* privateKey); +extern char* JtOrderCancelOrder(char* bizContentJSON, char* apiAccount, char* privateKey); +extern char* JtVipCheckCusPwd(char* bizContentJSON, char* apiAccount, char* privateKey); +extern char* JtEssBalance(char* bizContentJSON, char* apiAccount, char* privateKey); +extern char* JtBillCodeGetBatchBillCode(char* bizContentJSON, char* apiAccount, char* privateKey); +extern char* JtOrderPrintOrder(char* bizContentJSON, char* apiAccount, char* privateKey); +extern char* EmsAmpApiOpen(char* apiCode, char* senderNo, char* authorization, char* secretKey, char* requestJSON); +extern char* StoOmsExpressOrderCreate(char* requestJSON, char* fromAppkey, char* secretKey, char* fromCode); +extern char* YdCancelBmOrder(char* requestJSON, char* appKey, char* appSecret); +extern char* YdCreateBmOrder(char* requestJSON, char* appKey, char* appSecret); +extern char* YdSearchCount(char* requestJSON, char* appKey, char* appSecret); +extern char* YdBmGetPdfInfo(char* requestJSON, char* appKey, char* appSecret); +extern char* YdUpdateBmOrder(char* requestJSON, char* appKey, char* appSecret); +extern void FreeCString(char* str); +extern char* RequestSto(char* apiName, char* appkey, char* code, char* secretKey, char* toKey, char* requestJSON); +extern char* RequestYto(char* apiName, char* customerCode, char* secretKey, char* requestJSON); + +#ifdef __cplusplus +} +#endif diff --git a/expressDeliveryOrder/so/expressDeliveryOrder.so b/expressDeliveryOrder/so/expressDeliveryOrder.so new file mode 100644 index 0000000..ff8a6dc Binary files /dev/null and b/expressDeliveryOrder/so/expressDeliveryOrder.so differ diff --git a/kongfz/kongfz.go b/kongfz/kongfz.go index c9c19dd..a0ab51e 100644 --- a/kongfz/kongfz.go +++ b/kongfz/kongfz.go @@ -3299,6 +3299,7 @@ func kongfzOrderSynchronization(appId int, appSecret, accessToken string, shippi shippingCom = "other" userDefined = shippingComName } + fmt.Println(shippingComName) // 执行订单发货 orderDeliver, err := kongfzOrderDeliver(appId, appSecret, accessToken, orderId, shippingId, shippingCom, shipmentNum, userDefined, moreShipmentNum) if err != nil { @@ -3403,7 +3404,7 @@ func kongfzImageUpload(appId int, appSecret, accessToken string, filePath, saveP resp, respBody, errs := request.Post(kUrl). Timeout(30*time.Second). Set("Content-Type", writer.FormDataContentType()). // 设置Content-Type - Send(body.String()). // 发送请求体 + Send(body.String()). // 发送请求体 End() if len(errs) > 0 { return "", fmt.Errorf("请求失败: %v", errs) @@ -5566,8 +5567,8 @@ func GetVersion() *C.char { func main() { //appid := 576 //key := "256e10220c5b307f5172b1a49c11467a6cfa8038bbe2a7feccc42231852324f8" - //token := "8642f80ddb95826c9ad36877784c69c26a0f84d73184d08ab026ca6c851dd964" - //list, err := kongfzOrderSynchronization(appid, key, token, "中国邮政", 0, "", "", "", "", "") + //token := "3441e3f7bc09d71396736b722890ffb2fd26198b12099cf02ec3326d8bae1206" + //list, err := kongfzOrderSynchronization(appid, key, token, "极兔速递", 0, "", "", "", "", "") //if err != nil { // fmt.Println(err.Error()) // return diff --git a/kongfz/so/kongfz.h b/kongfz/so/kongfz.h new file mode 100644 index 0000000..8cd69c2 --- /dev/null +++ b/kongfz/so/kongfz.h @@ -0,0 +1,134 @@ +/* Code generated by cmd/cgo; DO NOT EDIT. */ + +/* package command-line-arguments */ + + +#line 1 "cgo-builtin-export-prolog" + +#include + +#ifndef GO_CGO_EXPORT_PROLOGUE_H +#define GO_CGO_EXPORT_PROLOGUE_H + +#ifndef GO_CGO_GOSTRING_TYPEDEF +typedef struct { const char *p; ptrdiff_t n; } _GoString_; +extern size_t _GoStringLen(_GoString_ s); +extern const char *_GoStringPtr(_GoString_ s); +#endif + +#endif + +/* Start of preamble from import "C" comments. */ + + +#line 3 "kongfz.go" + +#include + +#line 1 "cgo-generated-wrapper" + + +/* End of preamble from import "C" comments. */ + + +/* Start of boilerplate cgo prologue. */ +#line 1 "cgo-gcc-export-header-prolog" + +#ifndef GO_CGO_PROLOGUE_H +#define GO_CGO_PROLOGUE_H + +typedef signed char GoInt8; +typedef unsigned char GoUint8; +typedef short GoInt16; +typedef unsigned short GoUint16; +typedef int GoInt32; +typedef unsigned int GoUint32; +typedef long long GoInt64; +typedef unsigned long long GoUint64; +typedef GoInt64 GoInt; +typedef GoUint64 GoUint; +typedef size_t GoUintptr; +typedef float GoFloat32; +typedef double GoFloat64; +#ifdef _MSC_VER +#if !defined(__cplusplus) || _MSVC_LANG <= 201402L +#include +typedef _Fcomplex GoComplex64; +typedef _Dcomplex GoComplex128; +#else +#include +typedef std::complex GoComplex64; +typedef std::complex GoComplex128; +#endif +#else +typedef float _Complex GoComplex64; +typedef double _Complex GoComplex128; +#endif + +/* + static assertion to make sure the file is being used on architecture + at least with matching size of GoInt. +*/ +typedef char _check_for_64_bit_pointer_matching_GoInt[sizeof(void*)==64/8 ? 1:-1]; + +#ifndef GO_CGO_GOSTRING_TYPEDEF +typedef _GoString_ GoString; +#endif +typedef void *GoMap; +typedef void *GoChan; +typedef struct { void *t; void *v; } GoInterface; +typedef struct { void *data; GoInt len; GoInt cap; } GoSlice; + +#endif + +/* End of boilerplate cgo prologue. */ + +#ifdef __cplusplus +extern "C" { +#endif + +extern char* OutKfzLogin(char* username, char* password); +extern char* OutKfzGetUserInfo(char* token); +extern char* OutGetKfzShippingTemplate(char* token); +extern char* OutGetGoodsTplMsg(char* token, char* proxy, char* itemId); +extern char* OutGetGoodsListMsgFromSelfShop(char* token, char* proxy, char* itemSn, char* mouldId, char* priceMin, char* priceMax, char* startCreateTime, char* endCreateTime, char* requestType, int isItemSnEqual, int page, int size); +extern char* OutGetTplFields(char* token, char* proxy, char* itemId); +extern char* OutAddGoods(char* token, char* proxy, char* formData); +extern char* OutUpdateGoodsPrice(char* token, char* proxy, char* itemId, char* updateType, char* value); +extern char* OutGetBaseSelectData(char* token); +extern char* OutAddGoodsAndFile(char* token, char* proxy, char* filePath, char* formData); +extern char* OutDelGoodsFromSelfShop(char* token, char* proxy, char* itemId); +extern char* OutGetImageFilterShopId(char* token, char* proxy, char* isbn, int shopId, int isLiveImage, int isReturnMsg); +extern char* OutGetImageByIsbn(char* token, char* proxy, char* isbn, int isLiveImage, int isReturnMsg); +extern char* OutGetAllGoods(char* token, char* proxy, int queryIndex, char* isbn, char* quality, char* itemName, char* author, char* press); +extern char* OutGetMidDetail(char* token, char* mid); +extern char* OutGetGoodsListMsgByShopId(char* token, int shopId, char* proxy, int retPrice, int isImage, char* sortType, char* sort, float priceMin, float priceMax, int pageNum, int returnNum); +extern char* OutGetHisGoodsList(char* token, char* shopId, char* proxy, char* retPrice, char* isImage, char* sortType, char* sort, char* priceMin, char* priceMax, int pageNum, int returnNum); +extern char* OutGetGoodsMsgByDetailUrl(char* detailUrl, char* proxy); +extern char* OutGetTopGoodsListMsg(int catId, char* proxy); +extern char* KongfzDeliveryMethodList(int appId, char* appSecret, char* accessToken); +extern char* KongfzOrderDeliver(int appId, char* appSecret, char* accessToken, int orderId, char* shippingId, char* shippingCom, char* shipmentNum, char* userDefined, char* moreShipmentNum); +extern char* KongfzOrderSynchronization(int appId, char* appSecret, char* accessToken, char* shippingComName, int orderId, char* shippingId, char* shippingCom, char* shipmentNum, char* userDefined, char* moreShipmentNum); +extern char* KongfzImageUpload(int appId, char* appSecret, char* accessToken, char* filePath, char* savePath); +extern char* KongfzShopItemAdd(int appId, char* appSecret, char* accessToken, char* shopItemAddJson); +extern char* KongfzOrderList(int appId, char* appSecret, char* accessToken, char* orderListJson); +extern char* KongfzOrderGet(int appId, char* appSecret, char* accessToken, char* userType, int orderId); +extern char* KongfzOrderRedeliver(int appId, char* appSecret, char* accessToken, char* requestJson); +extern char* KongfzOrderFlagAdd(int appId, char* appSecret, char* accessToken, char* requestJson); +extern char* KongfzOrderFlagDel(int appId, char* appSecret, char* accessToken, char* requestJson); +extern char* KongfzShopCategoryNameList(int appId, char* appSecret, char* accessToken); +extern char* KongfzCommonCategory(int appId, char* appSecret, char* accessToken); +extern char* KongfzShopItemDelisting(int appId, char* appSecret, char* accessToken, char* requestJson); +extern char* KongfzShopItemList(int appId, char* appSecret, char* accessToken, char* requestJson); +extern char* KongfzShopItemDetail(int appId, char* appSecret, char* accessToken, char* requestJson); +extern char* KongfzShopItemListing(int appId, char* appSecret, char* accessToken, char* requestJson); +extern char* KongfzShopItemNumberUpdate(int appId, char* appSecret, char* accessToken, char* requestJson); +extern char* KongfzShopItemPriceUpdate(int appId, char* appSecret, char* accessToken, char* requestJson); +extern char* KongfzShopItemDelete(int appId, char* appSecret, char* accessToken, char* requestJson); +extern char* Initialize(char* configJSON); +extern void FreeCString(char* str); +extern char* GetVersion(void); + +#ifdef __cplusplus +} +#endif diff --git a/kongfz/so/kongfz.so b/kongfz/so/kongfz.so new file mode 100644 index 0000000..2940a72 Binary files /dev/null and b/kongfz/so/kongfz.so differ diff --git a/listener/1.jpg b/listener/1.jpg new file mode 100644 index 0000000..6187454 Binary files /dev/null and b/listener/1.jpg differ diff --git a/listener/output.ico b/listener/output.ico new file mode 100644 index 0000000..ffd4403 Binary files /dev/null and b/listener/output.ico differ diff --git a/proxy/dll/proxy.dll b/proxy/dll/proxy.dll new file mode 100644 index 0000000..cab645f Binary files /dev/null and b/proxy/dll/proxy.dll differ diff --git a/proxy/dll/proxy.h b/proxy/dll/proxy.h new file mode 100644 index 0000000..4bbe322 --- /dev/null +++ b/proxy/dll/proxy.h @@ -0,0 +1,101 @@ +/* Code generated by cmd/cgo; DO NOT EDIT. */ + +/* package command-line-arguments */ + + +#line 1 "cgo-builtin-export-prolog" + +#include + +#ifndef GO_CGO_EXPORT_PROLOGUE_H +#define GO_CGO_EXPORT_PROLOGUE_H + +#ifndef GO_CGO_GOSTRING_TYPEDEF +typedef struct { const char *p; ptrdiff_t n; } _GoString_; +extern size_t _GoStringLen(_GoString_ s); +extern const char *_GoStringPtr(_GoString_ s); +#endif + +#endif + +/* Start of preamble from import "C" comments. */ + + +#line 3 "proxy.go" + +#include + +#line 1 "cgo-generated-wrapper" + + +/* End of preamble from import "C" comments. */ + + +/* Start of boilerplate cgo prologue. */ +#line 1 "cgo-gcc-export-header-prolog" + +#ifndef GO_CGO_PROLOGUE_H +#define GO_CGO_PROLOGUE_H + +typedef signed char GoInt8; +typedef unsigned char GoUint8; +typedef short GoInt16; +typedef unsigned short GoUint16; +typedef int GoInt32; +typedef unsigned int GoUint32; +typedef long long GoInt64; +typedef unsigned long long GoUint64; +typedef GoInt64 GoInt; +typedef GoUint64 GoUint; +typedef size_t GoUintptr; +typedef float GoFloat32; +typedef double GoFloat64; +#ifdef _MSC_VER +#if !defined(__cplusplus) || _MSVC_LANG <= 201402L +#include +typedef _Fcomplex GoComplex64; +typedef _Dcomplex GoComplex128; +#else +#include +typedef std::complex GoComplex64; +typedef std::complex GoComplex128; +#endif +#else +typedef float _Complex GoComplex64; +typedef double _Complex GoComplex128; +#endif + +/* + static assertion to make sure the file is being used on architecture + at least with matching size of GoInt. +*/ +typedef char _check_for_64_bit_pointer_matching_GoInt[sizeof(void*)==64/8 ? 1:-1]; + +#ifndef GO_CGO_GOSTRING_TYPEDEF +typedef _GoString_ GoString; +#endif +typedef void *GoMap; +typedef void *GoChan; +typedef struct { void *t; void *v; } GoInterface; +typedef struct { void *data; GoInt len; GoInt cap; } GoSlice; + +#endif + +/* End of boilerplate cgo prologue. */ + +#ifdef __cplusplus +extern "C" { +#endif + +extern char* GetProxyByType(char* proxyType, char* machineCode); +extern char* GetTailProxyURL(char* machineCode); +extern char* GetMachineCode(char* tailCardSecret); +extern char* RechargeCard(char* tailCardSecret, char* machineCode); +extern char* GetProxies(char* machineCode); +extern char* CheckTailCardSecretExpired(char* tailCardSecret); +extern void FreeCString(char* str); +extern char* GetVersion(void); + +#ifdef __cplusplus +} +#endif