This commit is contained in:
2025-08-18 01:58:23 +08:00
parent 33567109ed
commit 5e8c9614ef
71 changed files with 6864 additions and 6 deletions

View File

@@ -0,0 +1,24 @@
package com.ruoyi.erp.domain;
/**
* 食品生产地信息
*/
@lombok.Data
public class Address {
/**
* 生产地城市ID
*/
private long city;
/**
* 详细地址
*/
private String detail;
/**
* 生产地地区ID
*/
private long district;
/**
* 生产地省份ID
*/
private long province;
}

View File

@@ -0,0 +1,25 @@
package com.ruoyi.erp.domain;
/**
* @author Leo
* @version 1.0
* @create 2025/4/10 15:15
* @description
*/
/**
* 闲鱼特卖信息,闲鱼特卖类型为临期非食品行业时必传
*
* 闲鱼特卖信息
*/
@lombok.Data
public class AdventData {
/**
* 有效期信息
*/
private AdventDataExpire expire;
/**
* 生产信息
*/
private AdventDataProduction production;
}

View File

@@ -0,0 +1,16 @@
package com.ruoyi.erp.domain;
/**
* 有效期信息
*/
@lombok.Data
public class AdventDataExpire {
/**
* 保质期
*/
private long num;
/**
* 单位
*/
private PurpleUnit unit;
}

View File

@@ -0,0 +1,12 @@
package com.ruoyi.erp.domain;
/**
* 生产信息
*/
@lombok.Data
public class AdventDataProduction {
/**
* 生产日期
*/
private String date;
}

View File

@@ -0,0 +1,22 @@
package com.ruoyi.erp.domain;
import java.io.IOException; /**
* 验货费规则
*/
public enum AssumeRule {
BUYER, SELLER;
public String toValue() {
switch (this) {
case BUYER: return "buyer";
case SELLER: return "seller";
}
return null;
}
public static AssumeRule forValue(String value) throws IOException {
if (value.equals("buyer")) return BUYER;
if (value.equals("seller")) return SELLER;
throw new IOException("Cannot deserialize AssumeRule");
}
}

View File

@@ -0,0 +1,34 @@
package com.ruoyi.erp.domain;
import java.util.List; /**
* 美妆信息
*/
@lombok.Data
public class BeautyMakeup {
/**
* 品牌
*/
private String brand;
/**
* 验货图片
*/
private List<String> images;
/**
* 成色
*/
private String level;
/**
* 检测机构ID枚举值
* 181 : 维鉴
* 182 : 中检科深
*/
private long orgid;
/**
* 检测机构名称
*/
private String orgName;
/**
* 规格
*/
private String spec;
}

View File

@@ -0,0 +1,24 @@
package com.ruoyi.erp.domain;
/**
* 图书信息
*/
@lombok.Data
public class BookData {
/**
* 图书作者
*/
private String author;
/**
* 图书ISBN码
*/
private String isbn;
/**
* 图书出版社
*/
private String publisher;
/**
* 图书标题
*/
private String title;
}

View File

@@ -0,0 +1,24 @@
package com.ruoyi.erp.domain;
import java.util.List; /**
* 品牌捡漏信息
*/
@lombok.Data
public class BrandData {
/**
* 有效期信息
*/
private BrandDataExpire expire;
/**
* 资质证明
*/
private List<Image> images;
/**
* 生产信息
*/
private BrandDataProduction production;
/**
* 供应商名称
*/
private String supplier;
}

View File

@@ -0,0 +1,16 @@
package com.ruoyi.erp.domain;
/**
* 有效期信息
*/
@lombok.Data
public class BrandDataExpire {
/**
* 保质期
*/
private long num;
/**
* 单位
*/
private FluffyUnit unit;
}

View File

@@ -0,0 +1,12 @@
package com.ruoyi.erp.domain;
/**
* 生产信息
*/
@lombok.Data
public class BrandDataProduction {
/**
* 生产日期
*/
private String date;
}

View File

@@ -0,0 +1,31 @@
package com.ruoyi.erp.domain;
import com.alibaba.fastjson2.annotation.JSONField;
/**
* 商品属性,通过`查询商品属性`接口获取属性参数
*
* 商品属性
*/
@lombok.Data
public class Channelpv {
/**
* 属性ID必填
*/
@JSONField(name = "property_id")
private String propertyid;
/**
* 属性名称(必填)
*/
@JSONField(name = "property_name")
private String propertyName;
/**
* 属性值ID必填
*/
@JSONField(name = "value_id")
private String valueid;
/**
* 属性值名称(必填)
*/
@JSONField(name = "value_name")
private String valueName;
}

View File

@@ -0,0 +1,44 @@
package com.ruoyi.erp.domain;
import java.util.List; /**
* 文玩信息
*/
@lombok.Data
public class Curio {
/**
* 验货图片
*/
private List<String> images;
/**
* 材料
*/
private String material;
/**
* 检测机构ID枚举值
* 191 : NGC评级
* 192 : PMG评级
* 193 : 公博评级
* 194 : PCGS评级
* 195 : 众诚评级
* 196 : 保粹评级
* 197 : 华夏评级
* 198 : 爱藏评级
* 199 : 华龙盛世
* 1910 : 国鉴鉴定
* 1911 : 信泰评级
* 1912 : 闻德评级
*/
private long orgid;
/**
* 检测机构名称
*/
private String orgName;
/**
* 验货编码
*/
private String qcNo;
/**
* 尺寸
*/
private String size;
}

View File

@@ -0,0 +1,126 @@
package com.ruoyi.erp.domain;
import com.alibaba.fastjson2.annotation.JSONField;
/**
* @author Leo
* @version 1.0
* @create 2025/4/10 15:13
* @description
*/
// ERPShop.java
import java.util.List;
@lombok.Data
public class ERPShop {
/**
* 闲鱼特卖信息,闲鱼特卖类型为临期非食品行业时必传
*/
private AdventData adventData;
/**
* 图书信息
*/
private BookData bookData;
/**
* 品牌捡漏信息
*/
private BrandData brandData;
/**
* 商品类目ID必填
* 通过“查询商品类目”接口获取;与 item_biz_type、sp_biz_type 存在依赖关系
*/
@JSONField(name = "channel_cat_id")
private String channelCatid;
/**
* 商品属性,通过`查询商品属性`接口获取属性参数
*/
@JSONField(name = "channel_pv")
private List<Channelpv> channelpv;
/**
* 详情图片(选填)
*/
@JSONField(name = "detail_images")
private List<Image> detailImages;
/**
* 运费(分)(必填)
*/
@JSONField(name = "express_fee")
private long expressFee;
/**
* 闲鱼特卖类型(选填)
* 特卖/品牌捡漏类型按需传入
*/
@JSONField(name = "flash_sale_type")
private Long flashSaleType;
/**
* 食品信息
*/
private FoodData foodData;
/**
* 验货宝信息item_biz_type=10 时必填)
*/
@JSONField(name = "inspect_data")
private Empty inspectData;
/**
* 商品类型(必填)
*/
@JSONField(name = "item_biz_type")
private long itemBizType;
/**
* 商品原价(分)(选填)
* 当 item_biz_type=24闲鱼特卖时必填
*/
@JSONField(name = "original_price")
private Long originalPrice;
/**
* 商家编码(选填)
* 一个中文按2个字符算长度 1-64
*/
@JSONField(name = "outer_id")
private String outerid;
/**
* 商品售价(分)(必填)
* 多规格商品时,必须是 SKU 其中一个金额
*/
private long price;
/**
* 发布店铺(必填)
* 至少 1 个店铺;用于指明发布到哪个闲鱼店铺
*/
@JSONField(name = "publish_shop")
private List<PublishShop> publishShop;
/**
* 验货报告信息,注意:已验货类型的商品按需必填
*/
private ReportData reportData;
/**
* 规格图片
*/
@JSONField(name = "sku_images")
private List<SkuImage> skuImages;
/**
* 商品多规格信息(选填)
* 多规格商品需传入至少一组 SKU总库存须与 stock 保持一致
*/
@JSONField(name = "sku_items")
private List<SkuItems> skuItems;
/**
* 商品行业(必填)
*/
@JSONField(name = "sp_biz_type")
private long spBizType;
/**
* 商品库存(必填)
* 取值范围 1-399960多规格商品为各 SKU 库存之和
*/
private long stock;
/**
* 商品成色(选填)
* 非普通商品类型时必填
*/
@JSONField(name = "stuff_status")
private Integer stuffStatus;
}

View File

@@ -0,0 +1,18 @@
package com.ruoyi.erp.domain;
/**
* 验货宝信息,商品类型为验货宝时必传
*
* 验货宝信息
*/
@lombok.Data
public class Empty {
/**
* 验货费规则
*/
private AssumeRule assumeRule;
/**
* 交易规则
*/
private TradeRule tradeRule;
}

View File

@@ -0,0 +1,20 @@
package com.ruoyi.erp.domain;
import java.io.IOException; /**
* 单位
*/
public enum FluffyUnit {
EMPTY;
public String toValue() {
switch (this) {
case EMPTY: return "\u5929";
}
return null;
}
public static FluffyUnit forValue(String value) throws IOException {
if (value.equals("\u5929")) return EMPTY;
throw new IOException("Cannot deserialize FluffyUnit");
}
}

View File

@@ -0,0 +1,28 @@
package com.ruoyi.erp.domain;
/**
* 食品信息
*/
@lombok.Data
public class FoodData {
/**
* 食品品牌
*/
private String brand;
/**
* 食品有效期信息
*/
private FoodDataExpire expire;
/**
* 食品包装
*/
private String pack;
/**
* 食品生产信息
*/
private FoodDataProduction production;
/**
* 食品规格
*/
private String spec;
}

View File

@@ -0,0 +1,16 @@
package com.ruoyi.erp.domain;
/**
* 食品有效期信息
*/
@lombok.Data
public class FoodDataExpire {
/**
* 保质期
*/
private long num;
/**
* 单位
*/
private PurpleUnit unit;
}

View File

@@ -0,0 +1,16 @@
package com.ruoyi.erp.domain;
/**
* 食品生产信息
*/
@lombok.Data
public class FoodDataProduction {
/**
* 食品生产地信息
*/
private Address address;
/**
* 食品生产日期
*/
private String date;
}

View File

@@ -0,0 +1,28 @@
package com.ruoyi.erp.domain;
import java.util.List; /**
* 游戏信息
*/
@lombok.Data
public class Game {
/**
* 验货图片
*/
private List<String> images;
/**
* 游戏平台
*/
private String platform;
/**
* 验货描述
*/
private String qcDesc;
/**
* 验货编码
*/
private String qcNo;
/**
* 报告标题
*/
private String title;
}

View File

@@ -0,0 +1,22 @@
package com.ruoyi.erp.domain;
/**
* 资质证明
*
* 新图片信息
*/
@lombok.Data
public class Image {
/**
* 图片高度
*/
private long height;
/**
* 图片地址
*/
private String src;
/**
* 图片宽度
*/
private long width;
}

View File

@@ -0,0 +1,36 @@
package com.ruoyi.erp.domain;
import java.util.List; /**
* 珠宝信息
*/
@lombok.Data
public class Jewelry {
/**
* 颜色
*/
private String color;
/**
* 验货图片
*/
private List<String> images;
/**
* 检测机构名称
*/
private String orgName;
/**
* 验货描述
*/
private String qcDesc;
/**
* 验货编码
*/
private String qcNo;
/**
* 形状
*/
private String shape;
/**
* 重量
*/
private String weight;
}

View File

@@ -0,0 +1,52 @@
package com.ruoyi.erp.domain;
import java.util.List;
import com.alibaba.fastjson2.annotation.JSONField;
@lombok.Data
public class PublishShop {
/**
* 商品发货城市(必填)
*/
private long city;
/**
* 商品描述(必填)
* 注意一个中文按2个字符算不支持HTML可用 \n 换行;长度 5-5000
*/
private String content;
/**
* 商品发货地区(必填)
*/
private long district;
/**
* 商品图片URL必填
* 注意:第 1 张作为商品主图,前 9 张发布到闲鱼 App
*/
private List<String> images;
/**
* 商品发货省份(必填)
*/
private long province;
/**
* 商品服务(选填)
* 多个以英文逗号分隔。如SDR,NFR
*/
@JSONField(name = "service_support")
private String serviceSupport;
/**
* 商品标题(必填)
* 注意:一个中文按 2 个字符算;长度 1-60
*/
private String title;
/**
* 闲鱼会员名(必填)
*/
@JSONField(name = "user_name")
private String userName;
/**
* 商品白底图URL选填
* 注意:如传入会在闲鱼商品详情显示且不可删除;当 item_biz_type=24特卖时必填
*/
@JSONField(name = "white_images")
private String whiteImages;
}

View File

@@ -0,0 +1,24 @@
package com.ruoyi.erp.domain;
import java.io.IOException; /**
* 单位
*/
public enum PurpleUnit {
EMPTY, PURPLE, UNIT;
public String toValue() {
switch (this) {
case EMPTY: return "\u5929";
case PURPLE: return "\u5e74";
case UNIT: return "\u6708";
}
return null;
}
public static PurpleUnit forValue(String value) throws IOException {
if (value.equals("\u5929")) return EMPTY;
if (value.equals("\u5e74")) return PURPLE;
if (value.equals("\u6708")) return UNIT;
throw new IOException("Cannot deserialize PurpleUnit");
}
}

View File

@@ -0,0 +1,22 @@
package com.ruoyi.erp.domain;
/**
* 行政区划原始表实体,映射 xgj_region
*/
@lombok.Data
public class Region {
/** 省级行政区划代码 */
private Integer provId;
/** 省级名称 */
private String provName;
/** 市级行政区划代码 */
private Integer cityId;
/** 市级名称 */
private String cityName;
/** 区县级行政区划代码 */
private Integer areaId;
/** 区县名称 */
private String areaName;
}

View File

@@ -0,0 +1,35 @@
package com.ruoyi.erp.domain;
/**
* 验货报告信息,注意:已验货类型的商品按需必填
*
* 验货报告信息
*/
@lombok.Data
public class ReportData {
/**
* 美妆信息
*/
private BeautyMakeup beautyMakeup;
/**
* 文玩信息
*/
private Curio curio;
/**
* 游戏信息
*/
private Game game;
/**
* 珠宝信息
*/
private Jewelry jewelry;
/**
* 二手车信息
*/
private UsedCar usedCar;
/**
* 奢品信息
*/
private Valuable valuable;
private The3C yx3C;
}

View File

@@ -0,0 +1,33 @@
package com.ruoyi.erp.domain;
@lombok.Data
public class ReportItem {
/**
* 选项描述
*/
private String answerDesc;
/**
* 选项ID
*/
private long answerid;
/**
* 选项名称
*/
private String answerName;
/**
* 选项类型
*/
private long answerType;
/**
* 分类名称
*/
private String categoryName;
/**
* 分组名称
*/
private String groupName;
/**
* 问题名称
*/
private String questionName;
}

View File

@@ -0,0 +1,26 @@
package com.ruoyi.erp.domain;
import com.alibaba.fastjson2.annotation.JSONField;
/**
* 规格图片
*/
@lombok.Data
public class SkuImage {
/**
* 图片高度(必填)
*/
private long height;
/**
* 规格属性(必填)
*/
@JSONField(name = "sku_text")
private String skuText;
/**
* 图片地址(必填)
*/
private String src;
/**
* 图片宽度(必填)
*/
private long width;
}

View File

@@ -0,0 +1,30 @@
package com.ruoyi.erp.domain;
import com.alibaba.fastjson2.annotation.JSONField;
/**
* SKU信息
*/
@lombok.Data
public class SkuItems {
/**
* SKU商品编码选填
* 注意:一个中文按 2 个字符算;长度 0-64
*/
@JSONField(name = "outer_id")
private String outerid;
/**
* SKU售价必填
*/
private long price;
/**
* SKU规格必填
* 格式:规格:属性;多个用 ";" 拼接。如:颜色:白色;容量:128G
*/
@JSONField(name = "sku_text")
private String skuText;
/**
* SKU库存必填
* 取值范围 0-9999
*/
private long stock;
}

View File

@@ -0,0 +1,52 @@
package com.ruoyi.erp.domain;
import java.util.List; /**
* 严选3c信息
*/
@lombok.Data
public class The3C {
/**
* 质检选项ID内部存储不对外展示
*/
private List<Long> answerids;
/**
* 品牌ID
*/
private long brandid;
/**
* 品牌名称
*/
private String brandName;
/**
* 品类ID
*/
private long classid;
/**
* 机型ID
*/
private long modelid;
/**
* 机型名称
*/
private String modelName;
/**
* IMEI/序列号
*/
private String modelSn;
/**
* 质检报告项,体现在商品验货报告页
*/
private List<ReportItem> reportItems;
/**
* 质检时间,体现在商品验货报告页
*/
private String reportTime;
/**
* 质检人,体现在商品验货报告页
*/
private String reportUser;
/**
* 子类ID
*/
private long subclassid;
}

View File

@@ -0,0 +1,22 @@
package com.ruoyi.erp.domain;
import java.io.IOException; /**
* 交易规则
*/
public enum TradeRule {
YHB_ONLY, YHB_OPTIONAL;
public String toValue() {
switch (this) {
case YHB_ONLY: return "yhbOnly";
case YHB_OPTIONAL: return "yhbOptional";
}
return null;
}
public static TradeRule forValue(String value) throws IOException {
if (value.equals("yhbOnly")) return YHB_ONLY;
if (value.equals("yhbOptional")) return YHB_OPTIONAL;
throw new IOException("Cannot deserialize TradeRule");
}
}

View File

@@ -0,0 +1,34 @@
package com.ruoyi.erp.domain;
/**
* 二手车信息
*
* OpenProductReportUsedCar
*/
@lombok.Data
public class UsedCar {
/**
* 营业执照图片
*/
private String businessLicenseFront;
/**
* 使用性质 : 营运/非营运
*/
private String carFunction;
/**
* 车辆识别代码VIN码
*/
private String carVin;
/**
* 行驶证车辆页图片
*/
private String drivingLicenseCarPhoto;
/**
* 行驶证主页图片
*/
private String drivingLicenseInfo;
/**
* 验货报告链接
*/
private String reporturl;
}

View File

@@ -0,0 +1,32 @@
package com.ruoyi.erp.domain;
import java.util.List; /**
* 奢品信息
*/
@lombok.Data
public class Valuable {
/**
* 验货图片
*/
private List<String> images;
/**
* 检测机构ID枚举值
* 161 : 中检
* 162 : 国检
* 163 : 华测
* 164 : 中溯
*/
private long orgid;
/**
* 检测机构名称
*/
private String orgName;
/**
* 验货描述
*/
private String qcDesc;
/**
* 验货编码
*/
private String qcNo;
}

View File

@@ -0,0 +1,23 @@
package com.ruoyi.erp.domain.enums;
/** 闲鱼特卖类型(含品牌捡漏扩展) */
public enum FlashSaleType {
LINQI(1),
GUPIN(2),
DUANMA(3),
WEIXIA(4),
WEIHUO(5),
OFFICIAL_REFURB(6),
BRAND_NEW(7),
LUCKY_BAG(8),
OTHER(99),
BRAND_WEIXIA(2601),
BRAND_LINQI(2602),
BRAND_CLEAR(2603),
BRAND_REFURB(2604);
public final int code;
FlashSaleType(int code) { this.code = code; }
}

View File

@@ -0,0 +1,17 @@
package com.ruoyi.erp.domain.enums;
/** 商品类型 */
public enum ItemBizType {
NORMAL(2),
CHECKED(0),
YANHUOBAO(10),
BRAND_AUTH(16),
SELECTED(19),
FLASH_SALE(24),
BRAND_CLEARANCE(26);
public final int code;
ItemBizType(int code) { this.code = code; }
}

View File

@@ -0,0 +1,14 @@
package com.ruoyi.erp.domain.enums;
/** 商品服务项(可按逗号拼接多个) */
public enum ServiceSupport {
SDR, // 七天无理由退货
NFR, // 描述不符包邮退
VNR, // 描述不符全额退(虚拟类)
FD_10MS, // 10分钟极速发货虚拟类
FD_24HS, // 24小时极速发货
FD_48HS, // 48小时极速发货
FD_GPA; // 正品保障
}

View File

@@ -0,0 +1,32 @@
package com.ruoyi.erp.domain.enums;
/** 行业类型(节选,完整可按文档扩充) */
public enum SpBizType {
PHONE(1),
FASHION(2),
APPLIANCE(3),
INSTRUMENT(8),
DIGITAL_3C(9),
LUXURY(16),
MOM_BABY(17),
BEAUTY(18),
JEWELRY(19),
GAME(20),
HOME(21),
VIRTUAL(22),
RENT_ACCOUNT(23),
BOOK(24),
COUPON(25),
FOOD(27),
TOY(28),
CAR(29),
PET_PLANT(30),
GIFT(31),
CAR_SERVICE(33),
OTHER(99);
public final int code;
SpBizType(int code) { this.code = code; }
}

View File

@@ -0,0 +1,24 @@
package com.ruoyi.erp.domain.enums;
/** 商品成色 */
public enum StuffStatus {
NONE(0),
NEW_100(100),
LIKE_NEW(-1),
NINETY_NINE(99),
NINETY_FIVE(95),
NINETY(90),
EIGHTY(80),
SEVENTY(70),
SIXTY(60),
FIFTY(50),
BRAND_CLEAR_40(40),
BRAND_CLEAR_30(30),
BRAND_CLEAR_20(20),
BRAND_CLEAR_10(10);
public final int code;
StuffStatus(int code) { this.code = code; }
}

View File

@@ -0,0 +1,18 @@
package com.ruoyi.erp.mapper;
import com.ruoyi.erp.domain.Region;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper
public interface RegionMapper {
List<Region> selectProvinces();
List<Region> selectCitiesByProv(@Param("provId") Integer provId);
List<Region> selectAreasByCity(@Param("provId") Integer provId, @Param("cityId") Integer cityId);
}

View File

@@ -0,0 +1,35 @@
package com.ruoyi.erp.request;
import com.alibaba.fastjson2.JSONObject;
/**
* 授权列表查询请求(示例类)
*/
public class AuthorizeListQueryRequest extends ERPRequestBase {
public AuthorizeListQueryRequest(ERPAccount erpAccount) {
super("https://open.goofish.pro/api/open/user/authorize/list", erpAccount);
}
/**
* 设置分页参数
* @param pageNum 页码
* @param pageSize 每页数量
*/
public void setPagination(int pageNum, int pageSize) {
JSONObject params = new JSONObject();
params.put("page_num", pageNum);
params.put("page_size", pageSize);
this.requestBody = params;
}
/**
* 设置过滤条件
* @param status 授权状态
*/
public void setFilter(String status) {
if (requestBody == null) {
requestBody = new JSONObject();
}
requestBody.put("status", status);
}
}

View File

@@ -0,0 +1,31 @@
package com.ruoyi.erp.request;
import lombok.Getter;
/**
* @author Leo
* @version 1.0
* @create 2025/4/10 15:20
* @descriptionERP账户枚举类
*/
@Getter
public enum ERPAccount {
// 胡歌1016208368633221
ACCOUNT_HUGE("1016208368633221", "waLiRMgFcixLbcLjUSSwo370Hp1nBcBu","余生请多关照66","海尔胡歌"),
// 刘强东anotherApiKey
ACCOUNT_LQD("anotherApiKey", "anotherApiSecret","刘强东","方案小号");
private final String apiKey;
private final String apiKeySecret;
private final String xyName;
private final String remark;
ERPAccount(String apiKey, String apiKeySecret, String xyName,String remark) {
this.apiKey = apiKey;
this.apiKeySecret = apiKeySecret;
this.xyName = xyName;
this.remark = remark;
}
}

View File

@@ -0,0 +1,99 @@
package com.ruoyi.erp.request;
import com.alibaba.fastjson2.JSONObject;
import com.ruoyi.common.utils.http.HttpUtils;
import lombok.Setter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
/**
* ERP请求基类支持开放平台签名规范
*/
public abstract class ERPRequestBase {
private static final Logger log = LoggerFactory.getLogger(ERPRequestBase.class);
protected String url;
protected String sign;
protected ERPAccount erpAccount;
@Setter
protected JSONObject requestBody;
protected long timestamp; // 统一时间戳字段
public ERPRequestBase(String url, ERPAccount erpAccount) {
this.url = url;
this.erpAccount = erpAccount;
}
/**
* 生成MD5签名兼容官方示例
* @param str 需要签名的原始字符串
* @return 十六进制小写MD5值
*/
public String genMd5(String str) {
try {
MessageDigest md = MessageDigest.getInstance("MD5");
byte[] digest = md.digest(str.getBytes(StandardCharsets.UTF_8));
StringBuilder result = new StringBuilder();
for (byte b : digest) {
result.append(String.format("%02x", b & 0xff)); // 保证小写十六进制
}
return result.toString();
} catch (NoSuchAlgorithmException e) {
log.error("MD5算法初始化失败", e);
throw new RuntimeException("MD5算法初始化失败", e);
}
}
/**
* 生成请求签名(与官方示例保持完全一致的拼接逻辑)
*/
public void genSign(long timestamp) {
this.timestamp = timestamp;
String jsonStr = getRequestBody(); // 使用getRequestBody()方法
String data = erpAccount.getApiKey() + "," + genMd5(jsonStr) + "," + timestamp + "," + erpAccount.getApiKeySecret();
this.sign = genMd5(data);
}
/**
* 获取带签名的请求URL
* @return 包含签名参数的完整URL
*/
public String getRequestUrl() {
return url + "?appid=" + erpAccount.getApiKey() + "&timestamp=" + timestamp + "&sign=" + sign;
}
/**
* 获取请求体内容(空时返回空对象)
* @return JSON字符串格式的请求体
*/
public String getRequestBody() {
return requestBody != null ? requestBody.toJSONString() : "{}";
}
/**
* 执行HTTP请求并获取响应
* @return 接口返回的原始JSON字符串
*/
public String getResponseBody() {
try {
long timestamp = System.currentTimeMillis() / 1000;
genSign(timestamp);
String requestUrl = getRequestUrl();
String body = getRequestBody();
System.out.println("请求地址: " + requestUrl);
System.out.println("请求体: " + body);
if (requestBody == null) {
return HttpUtils.sendPost(requestUrl, body); // 保持 body 一致
}
return HttpUtils.sendJsonPost(requestUrl, body);
} catch (Exception e) {
log.error("HTTP请求失败: {}", e.getMessage(), e);
throw new RuntimeException("ERP接口调用失败: " + e.getMessage(), e);
}
}
}

View File

@@ -0,0 +1,14 @@
package com.ruoyi.erp.request;
/**
* 查询快递公司请求
*
* 对应接口POST /api/open/express/companies
*/
public class ExpressCompaniesQueryRequest extends ERPRequestBase {
public ExpressCompaniesQueryRequest(ERPAccount erpAccount) {
super("https://open.goofish.pro/api/open/express/companies", erpAccount);
}
}

View File

@@ -0,0 +1,106 @@
package com.ruoyi.erp.request;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
public class HttpTest {
private static final String apiKey = "1016208368633221"; // 开放平台提供的应用KEY
private static final String apiKeySecret = "waLiRMgFcixLbcLjUSSwo370Hp1nBcBu"; // 开放平台提供的应用密钥
private static final String domain = "https://open.goofish.pro"; // 域名
public static void main(String[] args) {
// 获取当前时间戳
long timestamp = System.currentTimeMillis() / 1000L;
System.out.println("timestamp: " + timestamp);
// 请求体JSON字符串
String jsonBody = "{}";
// 生成签名
String sign = genSign(timestamp, jsonBody);
System.out.println("sign: " + sign);
// 拼接请求地址
String apiUrl = domain + "/api/open/product/list?appid=" + apiKey + "&timestamp=" + timestamp + "&sign="
+ sign;
try {
// 创建URL对象
URL url = new URL(apiUrl);
// 打开连接
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
// 设置请求方法为POST
connection.setRequestMethod("POST");
// 设置请求头部
connection.setRequestProperty("Content-Type", "application/json");
connection.setRequestProperty("Accept", "application/json");
// 启用输出流
connection.setDoOutput(true);
// 获取输出流并写入请求体
OutputStream outputStream = connection.getOutputStream();
outputStream.write(jsonBody.getBytes(StandardCharsets.UTF_8));
outputStream.close();
// 获取响应状态码
int responseCode = connection.getResponseCode();
System.out.println("API Response Code: " + responseCode);
// 读取响应内容
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String line;
StringBuilder response = new StringBuilder();
while ((line = bufferedReader.readLine()) != null) {
response.append(line);
}
bufferedReader.close();
// 关闭连接
connection.disconnect();
System.out.println("API Response: " + response.toString());
} catch (IOException e) {
// 在此处处理异常
e.printStackTrace();
}
}
// md5加密
private static String genMd5(String str) {
StringBuilder result = new StringBuilder();
try {
MessageDigest md = MessageDigest.getInstance("MD5");
byte[] digest = md.digest(str.getBytes(StandardCharsets.UTF_8));
for (byte b : digest) {
result.append(String.format("%02x", b & 0xff));
}
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException(e);
}
return result.toString();
}
// 生成签名
private static String genSign(long timestamp, String jsonStr) {
// 拼接字符串
String data = apiKey + "," + genMd5(jsonStr) + "," + timestamp + "," + apiKeySecret;
// 商务对接模式 拼接字符串
// String data = apiKey + "," + genMd5(jsonStr) + "," + timestamp + "," + seller_id + "," + apiKeySecret;
// 生成签名
return genMd5(data);
}
}

View File

@@ -0,0 +1,23 @@
package com.ruoyi.erp.request;
import com.alibaba.fastjson2.JSONObject;
/**
* 查询订单详情请求
*
* 对应接口POST /api/open/order/detail
*/
public class OrderDetailQueryRequest extends ERPRequestBase {
public OrderDetailQueryRequest(ERPAccount erpAccount) {
super("https://open.goofish.pro/api/open/order/detail", erpAccount);
}
public void setOrderNo(String orderNo) {
ensureBody();
this.requestBody.put("order_no", orderNo);
}
private void ensureBody() { if (this.requestBody == null) this.requestBody = new JSONObject(); }
}

View File

@@ -0,0 +1,23 @@
package com.ruoyi.erp.request;
import com.alibaba.fastjson2.JSONObject;
/**
* 订单卡密列表请求
*
* 对应接口POST /api/open/order/kam/list
*/
public class OrderKamListQueryRequest extends ERPRequestBase {
public OrderKamListQueryRequest(ERPAccount erpAccount) {
super("https://open.goofish.pro/api/open/order/kam/list", erpAccount);
}
public void setOrderNo(String orderNo) {
ensureBody();
this.requestBody.put("order_no", orderNo);
}
private void ensureBody() { if (this.requestBody == null) this.requestBody = new JSONObject(); }
}

View File

@@ -0,0 +1,35 @@
package com.ruoyi.erp.request;
import com.alibaba.fastjson2.JSONObject;
/**
* 查询订单列表请求
*
* 对应接口POST /api/open/order/list
*/
public class OrderListQueryRequest extends ERPRequestBase {
public OrderListQueryRequest(ERPAccount erpAccount) {
super("https://open.goofish.pro/api/open/order/list", erpAccount);
}
public void setAuthorizeId(long authorizeId) { ensureBody(); this.requestBody.put("authorize_id", authorizeId); }
public void setOrderStatus(Integer orderStatus) { putIfNotNull("order_status", orderStatus); }
public void setRefundStatus(Integer refundStatus) { putIfNotNull("refund_status", refundStatus); }
public void setOrderTime(long start, long end) { setRange("order_time", start, end); }
public void setPayTime(long start, long end) { setRange("pay_time", start, end); }
public void setConsignTime(long start, long end) { setRange("consign_time", start, end); }
public void setConfirmTime(long start, long end) { setRange("confirm_time", start, end); }
public void setRefundTime(long start, long end) { setRange("refund_time", start, end); }
public void setUpdateTime(long start, long end) { setRange("update_time", start, end); }
public void setPageNo(int pageNo) { ensureBody(); this.requestBody.put("page_no", pageNo); }
public void setPageSize(int pageSize) { ensureBody(); this.requestBody.put("page_size", pageSize); }
public void setPage(int pageNo, int pageSize) { ensureBody(); this.requestBody.put("page_no", pageNo); this.requestBody.put("page_size", pageSize); }
private void setRange(String key, long start, long end) { ensureBody(); this.requestBody.put(key, new long[]{start, end}); }
private void putIfNotNull(String key, Object value) { if (value != null) { ensureBody(); this.requestBody.put(key, value); } }
private void ensureBody() { if (this.requestBody == null) this.requestBody = new JSONObject(); }
}

View File

@@ -0,0 +1,22 @@
package com.ruoyi.erp.request;
import com.alibaba.fastjson2.JSONObject;
/**
* 订单修改价格请求
*
* 对应接口POST /api/open/order/modify/price
*/
public class OrderModifyPriceRequest extends ERPRequestBase {
public OrderModifyPriceRequest(ERPAccount erpAccount) {
super("https://open.goofish.pro/api/open/order/modify/price", erpAccount);
}
public void setOrderNo(String orderNo) { ensureBody(); this.requestBody.put("order_no", orderNo); }
public void setExpressFee(long expressFee) { ensureBody(); this.requestBody.put("express_fee", expressFee); }
public void setOrderPrice(long orderPrice) { ensureBody(); this.requestBody.put("order_price", orderPrice); }
private void ensureBody() { if (this.requestBody == null) this.requestBody = new JSONObject(); }
}

View File

@@ -0,0 +1,31 @@
package com.ruoyi.erp.request;
import com.alibaba.fastjson2.JSONObject;
/**
* 订单物流发货请求
*
* 对应接口POST /api/open/order/ship
*/
public class OrderShipRequest extends ERPRequestBase {
public OrderShipRequest(ERPAccount erpAccount) {
super("https://open.goofish.pro/api/open/order/ship", erpAccount);
}
public void setOrderNo(String orderNo) { put("order_no", orderNo); }
public void setShipName(String shipName) { put("ship_name", shipName); }
public void setShipMobile(String shipMobile) { put("ship_mobile", shipMobile); }
public void setShipDistrictId(Integer shipDistrictId) { put("ship_district_id", shipDistrictId); }
public void setShipProvName(String shipProvName) { put("ship_prov_name", shipProvName); }
public void setShipCityName(String shipCityName) { put("ship_city_name", shipCityName); }
public void setShipAreaName(String shipAreaName) { put("ship_area_name", shipAreaName); }
public void setShipAddress(String shipAddress) { put("ship_address", shipAddress); }
public void setWaybillNo(String waybillNo) { put("waybill_no", waybillNo); }
public void setExpressCode(String expressCode) { put("express_code", expressCode); }
public void setExpressName(String expressName) { put("express_name", expressName); }
private void put(String key, Object value) { if (value != null) { ensureBody(); this.requestBody.put(key, value); } }
private void ensureBody() { if (this.requestBody == null) this.requestBody = new JSONObject(); }
}

View File

@@ -0,0 +1,231 @@
package com.ruoyi.erp.request;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import java.util.Collection;
import java.util.List;
/**
* 创建商品(批量)请求
*
* 对应接口POST /api/open/product/batchCreate
* 限制每批次最多50个商品
*/
public class ProductBatchCreateRequest extends ERPRequestBase {
public ProductBatchCreateRequest(ERPAccount erpAccount) {
super("https://open.goofish.pro/api/open/product/batchCreate", erpAccount);
}
/**
* 设置一批商品数据,覆盖已有的 product_data
*/
public void setProducts(Collection<ProductBuilder> products) {
ensureRequestBodyInitialized();
if (products == null || products.isEmpty()) {
throw new IllegalArgumentException("product_data不能为空");
}
if (products.size() > 50) {
throw new IllegalArgumentException("每批次最多创建50个商品");
}
JSONArray array = new JSONArray();
for (ProductBuilder builder : products) {
array.add(builder.build());
}
this.requestBody.put("product_data", array);
}
/**
* 在原有 product_data 基础上追加一个商品
*/
public void addProduct(ProductBuilder product) {
ensureRequestBodyInitialized();
JSONArray array = this.requestBody.getJSONArray("product_data");
if (array == null) {
array = new JSONArray();
this.requestBody.put("product_data", array);
}
if (array.size() >= 50) {
throw new IllegalStateException("每批次最多创建50个商品");
}
array.add(product.build());
}
private void ensureRequestBodyInitialized() {
if (this.requestBody == null) {
this.requestBody = new JSONObject();
}
}
/**
* 单个商品数据构建器
*/
public static class ProductBuilder {
private final JSONObject data = new JSONObject();
private final JSONArray channelPv = new JSONArray();
private final JSONArray publishShop = new JSONArray();
private final JSONArray skuItems = new JSONArray();
public ProductBuilder setItemKey(String itemKey) {
data.put("item_key", itemKey);
return this;
}
public ProductBuilder setItemBizType(int itemBizType) {
data.put("item_biz_type", itemBizType);
return this;
}
public ProductBuilder setSpBizType(int spBizType) {
data.put("sp_biz_type", spBizType);
return this;
}
public ProductBuilder setChannelCatId(String channelCatId) {
data.put("channel_cat_id", channelCatId);
return this;
}
public ProductBuilder setPrice(long price) {
data.put("price", price);
return this;
}
public ProductBuilder setOriginalPrice(Long originalPrice) {
if (originalPrice != null) {
data.put("original_price", originalPrice);
}
return this;
}
public ProductBuilder setExpressFee(Long expressFee) {
if (expressFee != null) {
data.put("express_fee", expressFee);
}
return this;
}
public ProductBuilder setStock(int stock) {
data.put("stock", stock);
return this;
}
public ProductBuilder setOuterId(String outerId) {
if (outerId != null) {
data.put("outer_id", outerId);
}
return this;
}
public ProductBuilder setStuffStatus(Integer stuffStatus) {
if (stuffStatus != null) {
data.put("stuff_status", stuffStatus);
}
return this;
}
public ProductBuilder addChannelPv(String propertyId, String propertyName, String valueId, String valueName) {
JSONObject pv = new JSONObject();
pv.put("property_id", propertyId);
pv.put("property_name", propertyName);
pv.put("value_id", valueId);
pv.put("value_name", valueName);
channelPv.add(pv);
return this;
}
public ProductBuilder addPublishShop(String userName, int province, int city, int district, String title, String content, List<String> images, String whiteImages, String serviceSupport) {
JSONObject shop = new JSONObject();
shop.put("user_name", userName);
shop.put("province", province);
shop.put("city", city);
shop.put("district", district);
shop.put("title", title);
shop.put("content", content);
if (images != null && !images.isEmpty()) {
JSONArray imgs = new JSONArray();
imgs.addAll(images);
shop.put("images", imgs);
}
if (whiteImages != null) {
shop.put("white_images", whiteImages);
}
if (serviceSupport != null) {
shop.put("service_support", serviceSupport);
}
publishShop.add(shop);
return this;
}
public ProductBuilder addSkuItem(long price, int stock, String skuText, String outerId) {
JSONObject sku = new JSONObject();
sku.put("price", price);
sku.put("stock", stock);
sku.put("sku_text", skuText);
if (outerId != null) {
sku.put("outer_id", outerId);
}
skuItems.add(sku);
return this;
}
public ProductBuilder setDetailImages(JSONArray images) {
if (images != null) {
data.put("detail_images", images);
}
return this;
}
public ProductBuilder setSkuImages(JSONArray images) {
if (images != null) {
data.put("sku_images", images);
}
return this;
}
public ProductBuilder setBookData(JSONObject bookData) { return putIfNotNull("book_data", bookData); }
public ProductBuilder setFoodData(JSONObject foodData) { return putIfNotNull("food_data", foodData); }
public ProductBuilder setReportData(JSONObject reportData) { return putIfNotNull("report_data", reportData); }
public ProductBuilder setFlashSaleType(Integer flashSaleType) { if (flashSaleType != null) data.put("flash_sale_type", flashSaleType); return this; }
public ProductBuilder setAdventData(JSONObject adventData) { return putIfNotNull("advent_data", adventData); }
public ProductBuilder setInspectData(JSONObject inspectData) { return putIfNotNull("inspect_data", inspectData); }
public ProductBuilder setBrandData(JSONObject brandData) { return putIfNotNull("brand_data", brandData); }
private ProductBuilder putIfNotNull(String key, Object value) {
if (value != null) {
data.put(key, value);
}
return this;
}
private void finalizeArrays() {
if (!channelPv.isEmpty()) {
data.put("channel_pv", channelPv);
}
if (!publishShop.isEmpty()) {
data.put("publish_shop", publishShop);
}
if (!skuItems.isEmpty()) {
data.put("sku_items", skuItems);
}
}
private void validateRequired() {
if (!data.containsKey("item_key")) throw new IllegalStateException("缺少必填字段: item_key");
if (!data.containsKey("item_biz_type")) throw new IllegalStateException("缺少必填字段: item_biz_type");
if (!data.containsKey("sp_biz_type")) throw new IllegalStateException("缺少必填字段: sp_biz_type");
if (!data.containsKey("channel_cat_id")) throw new IllegalStateException("缺少必填字段: channel_cat_id");
if (!data.containsKey("price")) throw new IllegalStateException("缺少必填字段: price");
if (!data.containsKey("stock")) throw new IllegalStateException("缺少必填字段: stock");
if (publishShop.isEmpty()) throw new IllegalStateException("缺少必填字段: publish_shop");
}
private JSONObject build() {
finalizeArrays();
validateRequired();
return data;
}
}
}

View File

@@ -0,0 +1,59 @@
package com.ruoyi.erp.request;
import com.alibaba.fastjson2.JSONObject;
/**
* 查询商品类目请求
*
* 对应接口POST /api/open/product/category/list
* 请求体字段:
* - item_biz_type必填商品类型
* - sp_biz_type选填行业类型
* - flash_sale_type选填闲鱼特卖类型
*/
public class ProductCategoryListQueryRequest extends ERPRequestBase {
public ProductCategoryListQueryRequest(ERPAccount erpAccount) {
super("https://open.goofish.pro/api/open/product/category/list", erpAccount);
}
/**
* 设置商品类型(必填)
* @param itemBizType 商品类型
*/
public void setItemBizType(int itemBizType) {
ensureRequestBodyInitialized();
this.requestBody.put("item_biz_type", itemBizType);
}
/**
* 设置行业类型(选填)
* @param spBizType 行业类型
*/
public void setSpBizType(Integer spBizType) {
if (spBizType == null) {
return;
}
ensureRequestBodyInitialized();
this.requestBody.put("sp_biz_type", spBizType);
}
/**
* 设置闲鱼特卖类型(选填)
* @param flashSaleType 闲鱼特卖类型
*/
public void setFlashSaleType(Integer flashSaleType) {
if (flashSaleType == null) {
return;
}
ensureRequestBodyInitialized();
this.requestBody.put("flash_sale_type", flashSaleType);
}
private void ensureRequestBodyInitialized() {
if (this.requestBody == null) {
this.requestBody = new JSONObject();
}
}
}

View File

@@ -0,0 +1,142 @@
package com.ruoyi.erp.request;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import java.util.List;
/**
* 创建商品(单个)请求
*
* 对应接口POST /api/open/product/create
*/
public class ProductCreateRequest extends ERPRequestBase {
private final JSONArray channelPv = new JSONArray();
private final JSONArray publishShop = new JSONArray();
private final JSONArray skuItems = new JSONArray();
public ProductCreateRequest(ERPAccount erpAccount) {
super("https://open.goofish.pro/api/open/product/create", erpAccount);
}
public void setItemBizType(int itemBizType) {
ensureRequestBodyInitialized();
this.requestBody.put("item_biz_type", itemBizType);
}
public void setSpBizType(int spBizType) {
ensureRequestBodyInitialized();
this.requestBody.put("sp_biz_type", spBizType);
}
public void setChannelCatId(String channelCatId) {
ensureRequestBodyInitialized();
this.requestBody.put("channel_cat_id", channelCatId);
}
public void addChannelPv(String propertyId, String propertyName, String valueId, String valueName) {
JSONObject pv = new JSONObject();
pv.put("property_id", propertyId);
pv.put("property_name", propertyName);
pv.put("value_id", valueId);
pv.put("value_name", valueName);
channelPv.add(pv);
ensureRequestBodyInitialized();
this.requestBody.put("channel_pv", channelPv);
}
public void setPrice(long price) {
ensureRequestBodyInitialized();
this.requestBody.put("price", price);
}
public void setOriginalPrice(Long originalPrice) {
if (originalPrice == null) return;
ensureRequestBodyInitialized();
this.requestBody.put("original_price", originalPrice);
}
public void setExpressFee(long expressFee) {
ensureRequestBodyInitialized();
this.requestBody.put("express_fee", expressFee);
}
public void setStock(int stock) {
ensureRequestBodyInitialized();
this.requestBody.put("stock", stock);
}
public void setOuterId(String outerId) {
if (outerId == null) return;
ensureRequestBodyInitialized();
this.requestBody.put("outer_id", outerId);
}
public void setStuffStatus(Integer stuffStatus) {
if (stuffStatus == null) return;
ensureRequestBodyInitialized();
this.requestBody.put("stuff_status", stuffStatus);
}
public void addPublishShop(String userName, int province, int city, int district, String title, String content, List<String> images, String whiteImages, String serviceSupport) {
JSONObject shop = new JSONObject();
shop.put("user_name", userName);
shop.put("province", province);
shop.put("city", city);
shop.put("district", district);
shop.put("title", title);
shop.put("content", content);
if (images != null && !images.isEmpty()) {
JSONArray imgs = new JSONArray();
imgs.addAll(images);
shop.put("images", imgs);
}
if (whiteImages != null) {
shop.put("white_images", whiteImages);
}
if (serviceSupport != null) {
shop.put("service_support", serviceSupport);
}
publishShop.add(shop);
ensureRequestBodyInitialized();
this.requestBody.put("publish_shop", publishShop);
}
public void addSkuItem(long price, int stock, String skuText, String outerId) {
JSONObject sku = new JSONObject();
sku.put("price", price);
sku.put("stock", stock);
sku.put("sku_text", skuText);
if (outerId != null) {
sku.put("outer_id", outerId);
}
skuItems.add(sku);
ensureRequestBodyInitialized();
this.requestBody.put("sku_items", skuItems);
}
public void setBookData(JSONObject bookData) { putIfNotNull("book_data", bookData); }
public void setFoodData(JSONObject foodData) { putIfNotNull("food_data", foodData); }
public void setReportData(JSONObject reportData) { putIfNotNull("report_data", reportData); }
public void setFlashSaleType(Integer flashSaleType) { if (flashSaleType != null) { ensureRequestBodyInitialized(); this.requestBody.put("flash_sale_type", flashSaleType); } }
public void setAdventData(JSONObject adventData) { putIfNotNull("advent_data", adventData); }
public void setInspectData(JSONObject inspectData) { putIfNotNull("inspect_data", inspectData); }
public void setBrandData(JSONObject brandData) { putIfNotNull("brand_data", brandData); }
public void setDetailImages(JSONArray images) { if (images != null) { ensureRequestBodyInitialized(); this.requestBody.put("detail_images", images); } }
public void setSkuImages(JSONArray images) { if (images != null) { ensureRequestBodyInitialized(); this.requestBody.put("sku_images", images); } }
private void putIfNotNull(String key, Object value) {
if (value != null) {
ensureRequestBodyInitialized();
this.requestBody.put(key, value);
}
}
private void ensureRequestBodyInitialized() {
if (this.requestBody == null) {
this.requestBody = new JSONObject();
}
}
}

View File

@@ -0,0 +1,25 @@
package com.ruoyi.erp.request;
import com.alibaba.fastjson2.JSONObject;
/**
* 删除商品请求
*
* 对应接口POST /api/open/product/delete
*/
public class ProductDeleteRequest extends ERPRequestBase {
public ProductDeleteRequest(ERPAccount erpAccount) {
super("https://open.goofish.pro/api/open/product/delete", erpAccount);
}
public void setProductId(long productId) {
ensureBody();
this.requestBody.put("product_id", productId);
}
private void ensureBody() {
if (this.requestBody == null) this.requestBody = new JSONObject();
}
}

View File

@@ -0,0 +1,33 @@
package com.ruoyi.erp.request;
import com.alibaba.fastjson2.JSONObject;
/**
* 查询商品详情请求
*
* 对应接口POST /api/open/product/detail
* 请求体字段:
* - product_id必填管家商品ID
*/
public class ProductDetailQueryRequest extends ERPRequestBase {
public ProductDetailQueryRequest(ERPAccount erpAccount) {
super("https://open.goofish.pro/api/open/product/detail", erpAccount);
}
/**
* 设置管家商品ID必填
* @param productId 管家商品ID
*/
public void setProductId(long productId) {
ensureRequestBodyInitialized();
this.requestBody.put("product_id", productId);
}
private void ensureRequestBodyInitialized() {
if (this.requestBody == null) {
this.requestBody = new JSONObject();
}
}
}

View File

@@ -0,0 +1,25 @@
package com.ruoyi.erp.request;
import com.alibaba.fastjson2.JSONObject;
/**
* 下架商品请求
*
* 对应接口POST /api/open/product/downShelf
*/
public class ProductDownShelfRequest extends ERPRequestBase {
public ProductDownShelfRequest(ERPAccount erpAccount) {
super("https://open.goofish.pro/api/open/product/downShelf", erpAccount);
}
public void setProductId(long productId) {
ensureBody();
this.requestBody.put("product_id", productId);
}
private void ensureBody() {
if (this.requestBody == null) this.requestBody = new JSONObject();
}
}

View File

@@ -0,0 +1,89 @@
package com.ruoyi.erp.request;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import java.util.List;
/**
* 编辑商品请求(按需传入要修改的字段)
*
* 对应接口POST /api/open/product/edit
*/
public class ProductEditRequest extends ERPRequestBase {
private final JSONArray channelPv = new JSONArray();
private final JSONArray publishShop = new JSONArray();
private final JSONArray skuItems = new JSONArray();
public ProductEditRequest(ERPAccount erpAccount) {
super("https://open.goofish.pro/api/open/product/edit", erpAccount);
}
public void setProductId(long productId) { ensureBody(); this.requestBody.put("product_id", productId); }
public void setItemBizType(Integer itemBizType) { putIfNotNull("item_biz_type", itemBizType); }
public void setSpBizType(Integer spBizType) { putIfNotNull("sp_biz_type", spBizType); }
public void setCategoryId(Integer categoryId) { putIfNotNull("category_id", categoryId); }
public void setChannelCatId(String channelCatId) { putIfNotNull("channel_cat_id", channelCatId); }
public void addChannelPv(String propertyId, String propertyName, String valueId, String valueName) {
JSONObject pv = new JSONObject();
pv.put("property_id", propertyId);
pv.put("property_name", propertyName);
pv.put("value_id", valueId);
pv.put("value_name", valueName);
channelPv.add(pv);
ensureBody();
this.requestBody.put("channel_pv", channelPv);
}
public void setTitle(String title) { putIfNotNull("title", title); }
public void setPrice(Long price) { putIfNotNull("price", price); }
public void setOriginalPrice(Long originalPrice) { putIfNotNull("original_price", originalPrice); }
public void setExpressFee(Long expressFee) { putIfNotNull("express_fee", expressFee); }
public void setStock(Integer stock) { putIfNotNull("stock", stock); }
public void setOuterId(String outerId) { putIfNotNull("outer_id", outerId); }
public void setStuffStatus(Integer stuffStatus) { putIfNotNull("stuff_status", stuffStatus); }
public void addPublishShop(String userName, Integer province, Integer city, Integer district, String title, String content, List<String> images, String whiteImages, String serviceSupport) {
JSONObject shop = new JSONObject();
if (userName != null) shop.put("user_name", userName);
if (province != null) shop.put("province", province);
if (city != null) shop.put("city", city);
if (district != null) shop.put("district", district);
if (title != null) shop.put("title", title);
if (content != null) shop.put("content", content);
if (images != null && !images.isEmpty()) {
JSONArray imgs = new JSONArray();
imgs.addAll(images);
shop.put("images", imgs);
}
if (whiteImages != null) shop.put("white_images", whiteImages);
if (serviceSupport != null) shop.put("service_support", serviceSupport);
publishShop.add(shop);
ensureBody();
this.requestBody.put("publish_shop", publishShop);
}
public void addSkuItem(Long price, Integer stock, String skuText, String outerId) {
JSONObject sku = new JSONObject();
if (price != null) sku.put("price", price);
if (stock != null) sku.put("stock", stock);
if (skuText != null) sku.put("sku_text", skuText);
if (outerId != null) sku.put("outer_id", outerId);
skuItems.add(sku);
ensureBody();
this.requestBody.put("sku_items", skuItems);
}
public void setBookData(JSONObject bookData) { putIfNotNull("book_data", bookData); }
public void setFoodData(JSONObject foodData) { putIfNotNull("food_data", foodData); }
public void setReportData(JSONObject reportData) { putIfNotNull("report_data", reportData); }
public void setNotifyUrl(String notifyUrl) { putIfNotNull("notify_url", notifyUrl); }
public void setFlashSaleType(Integer flashSaleType) { putIfNotNull("flash_sale_type", flashSaleType); }
public void setAdventData(JSONObject adventData) { putIfNotNull("advent_data", adventData); }
public void setInspectData(JSONObject inspectData) { putIfNotNull("inspect_data", inspectData); }
public void setBrandData(JSONObject brandData) { putIfNotNull("brand_data", brandData); }
public void setDetailImages(JSONArray images) { putIfNotNull("detail_images", images); }
public void setSkuImages(JSONArray images) { putIfNotNull("sku_images", images); }
private void ensureBody() { if (this.requestBody == null) this.requestBody = new JSONObject(); }
private void putIfNotNull(String key, Object value) { if (value != null) { ensureBody(); this.requestBody.put(key, value); } }
}

View File

@@ -0,0 +1,37 @@
package com.ruoyi.erp.request;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
/**
* 编辑库存请求
*
* 对应接口POST /api/open/product/edit/stock
*/
public class ProductEditStockRequest extends ERPRequestBase {
public ProductEditStockRequest(ERPAccount erpAccount) {
super("https://open.goofish.pro/api/open/product/edit/stock", erpAccount);
}
public void setProductId(long productId) { ensureBody(); this.requestBody.put("product_id", productId); }
public void setPrice(Long price) { putIfNotNull("price", price); }
public void setOriginalPrice(Long originalPrice) { putIfNotNull("original_price", originalPrice); }
public void setStock(Integer stock) { putIfNotNull("stock", stock); }
public void addSkuItem(long skuId, Integer stock, Long price, String outerId) {
ensureBody();
JSONArray arr = this.requestBody.getJSONArray("sku_items");
if (arr == null) { arr = new JSONArray(); this.requestBody.put("sku_items", arr); }
JSONObject sku = new JSONObject();
sku.put("sku_id", skuId);
if (stock != null) sku.put("stock", stock);
if (price != null) sku.put("price", price);
if (outerId != null) sku.put("outer_id", outerId);
arr.add(sku);
}
private void ensureBody() { if (this.requestBody == null) this.requestBody = new JSONObject(); }
private void putIfNotNull(String key, Object value) { if (value != null) { ensureBody(); this.requestBody.put(key, value); } }
}

View File

@@ -0,0 +1,69 @@
package com.ruoyi.erp.request;
import com.alibaba.fastjson2.JSONObject;
public class ProductListQueryRequest extends ERPRequestBase {
public ProductListQueryRequest(ERPAccount erpAccount) {
super("https://open.goofish.pro/api/open/product/list", erpAccount);
}
public void setOnlineTime(long start, long end) {
ensureRequestBodyInitialized();
this.requestBody.put("online_time", new long[]{start, end});
}
public void setOfflineTime(long start, long end) {
ensureRequestBodyInitialized();
this.requestBody.put("offline_time", new long[]{start, end});
}
public void setSoldTime(long start, long end) {
ensureRequestBodyInitialized();
this.requestBody.put("sold_time", new long[]{start, end});
}
public void setUpdateTime(long start, long end) {
ensureRequestBodyInitialized();
this.requestBody.put("update_time", new long[]{start, end});
}
public void setCreateTime(long start, long end) {
ensureRequestBodyInitialized();
this.requestBody.put("create_time", new long[]{start, end});
}
public void setProductStatus(int productStatus) {
ensureRequestBodyInitialized();
this.requestBody.put("product_status", productStatus);
}
public void setSaleStatus(Integer saleStatus) {
if (saleStatus == null) {
return;
}
ensureRequestBodyInitialized();
this.requestBody.put("sale_status", saleStatus);
}
public void setPageNo(int pageNo) {
ensureRequestBodyInitialized();
this.requestBody.put("page_no", pageNo);
}
public void setPageSize(int pageSize) {
ensureRequestBodyInitialized();
this.requestBody.put("page_size", pageSize);
}
public void setPage(int pageNo, int pageSize) {
ensureRequestBodyInitialized();
this.requestBody.put("page_no", pageNo);
this.requestBody.put("page_size", pageSize);
}
private void ensureRequestBodyInitialized() {
if (this.requestBody == null) {
this.requestBody = new JSONObject();
}
}
}

View File

@@ -0,0 +1,66 @@
package com.ruoyi.erp.request;
import com.alibaba.fastjson2.JSONObject;
/**
* 查询商品属性请求
*
* 对应接口POST /api/open/product/pv/list
* 请求体字段:
* - item_biz_type必填商品类型
* - sp_biz_type必填行业类型
* - channel_cat_id必填渠道类目ID
* - sub_property_id选填属性值ID用于二级属性查询
*/
public class ProductPropertyListQueryRequest extends ERPRequestBase {
public ProductPropertyListQueryRequest(ERPAccount erpAccount) {
super("https://open.goofish.pro/api/open/product/pv/list", erpAccount);
}
/**
* 设置商品类型(必填)
* @param itemBizType 商品类型
*/
public void setItemBizType(int itemBizType) {
ensureRequestBodyInitialized();
this.requestBody.put("item_biz_type", itemBizType);
}
/**
* 设置行业类型(必填)
* @param spBizType 行业类型
*/
public void setSpBizType(int spBizType) {
ensureRequestBodyInitialized();
this.requestBody.put("sp_biz_type", spBizType);
}
/**
* 设置渠道类目ID必填
* @param channelCatId 渠道类目ID
*/
public void setChannelCatId(String channelCatId) {
ensureRequestBodyInitialized();
this.requestBody.put("channel_cat_id", channelCatId);
}
/**
* 设置下级属性ID选填
* @param subPropertyId 下级属性ID
*/
public void setSubPropertyId(String subPropertyId) {
if (subPropertyId == null || subPropertyId.isEmpty()) {
return;
}
ensureRequestBodyInitialized();
this.requestBody.put("sub_property_id", subPropertyId);
}
private void ensureRequestBodyInitialized() {
if (this.requestBody == null) {
this.requestBody = new JSONObject();
}
}
}

View File

@@ -0,0 +1,45 @@
package com.ruoyi.erp.request;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
/**
* 上架商品请求
*
* 对应接口POST /api/open/product/publish
*/
public class ProductPublishRequest extends ERPRequestBase {
public ProductPublishRequest(ERPAccount erpAccount) {
super("https://open.goofish.pro/api/open/product/publish", erpAccount);
}
public void setProductId(long productId) {
ensureBody();
this.requestBody.put("product_id", productId);
}
public void setUserName(String userName) {
ensureBody();
JSONArray arr = new JSONArray();
arr.add(userName);
this.requestBody.put("user_name", arr);
}
public void setSpecifyPublishTime(String time) {
if (time == null) return;
ensureBody();
this.requestBody.put("specify_publish_time", time);
}
public void setNotifyUrl(String notifyUrl) {
if (notifyUrl == null) return;
ensureBody();
this.requestBody.put("notify_url", notifyUrl);
}
private void ensureBody() {
if (this.requestBody == null) this.requestBody = new JSONObject();
}
}

View File

@@ -0,0 +1,58 @@
package com.ruoyi.erp.request;
import com.alibaba.fastjson2.JSONObject;
import java.util.Collection;
/**
* 查询商品规格请求(仅多规格商品)
*
* 对应接口POST /api/open/product/sku/list
* 请求体字段:
* - product_id必填管家商品ID数组最多100个
*/
public class ProductSkuListQueryRequest extends ERPRequestBase {
public ProductSkuListQueryRequest(ERPAccount erpAccount) {
super("https://open.goofish.pro/api/open/product/sku/list", erpAccount);
}
/**
* 设置商品ID数组必填最多100个
*/
public void setProductIds(long... productIds) {
if (productIds == null || productIds.length == 0) {
throw new IllegalArgumentException("productIds不能为空");
}
if (productIds.length > 100) {
throw new IllegalArgumentException("productIds数量不能超过100");
}
ensureRequestBodyInitialized();
this.requestBody.put("product_id", productIds);
}
/**
* 设置商品ID集合必填最多100个
*/
public void setProductIds(Collection<Long> productIds) {
if (productIds == null || productIds.isEmpty()) {
throw new IllegalArgumentException("productIds不能为空");
}
if (productIds.size() > 100) {
throw new IllegalArgumentException("productIds数量不能超过100");
}
long[] ids = new long[productIds.size()];
int i = 0;
for (Long id : productIds) {
ids[i++] = id == null ? 0L : id;
}
setProductIds(ids);
}
private void ensureRequestBodyInitialized() {
if (this.requestBody == null) {
this.requestBody = new JSONObject();
}
}
}

View File

@@ -0,0 +1,17 @@
package com.ruoyi.erp.request;
/**
* @author Leo
* @version 1.0
* @create 2025/8/16 19:02
* @description
*/
public class RequestDemo {
public static void main(String[] args) {
ERPAccount erpAccount = ERPAccount.ACCOUNT_HUGE;
ProductListQueryRequest request = new ProductListQueryRequest(erpAccount);
String responseBody = request.getResponseBody();
System.out.println("响应结果: " + responseBody);
}
}

View File

@@ -0,0 +1,11 @@
package com.ruoyi.erp.service;
import java.util.List;
public interface IRegionService {
List<?> listProvinces();
List<?> listCities(Integer provId);
List<?> listAreas(Integer provId, Integer cityId);
}

View File

@@ -0,0 +1,52 @@
package com.ruoyi.erp.service.impl;
import com.ruoyi.erp.mapper.RegionMapper;
import com.ruoyi.erp.domain.Region;
import com.ruoyi.erp.service.IRegionService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import java.util.stream.Collectors;
@Service
public class RegionServiceImpl implements IRegionService {
@Resource
private RegionMapper regionMapper;
@Override
public List<?> listProvinces() {
List<Region> list = regionMapper.selectProvinces();
return list.stream()
.map(r -> new Option(r.getProvId(), r.getProvName()))
.distinct()
.collect(Collectors.toList());
}
@Override
public List<?> listCities(Integer provId) {
List<Region> list = regionMapper.selectCitiesByProv(provId);
return list.stream()
.map(r -> new Option(r.getCityId(), r.getCityName()))
.distinct()
.collect(Collectors.toList());
}
@Override
public List<?> listAreas(Integer provId, Integer cityId) {
List<Region> list = regionMapper.selectAreasByCity(provId, cityId);
return list.stream()
.map(r -> new Option(r.getAreaId(), r.getAreaName()))
.distinct()
.collect(Collectors.toList());
}
public static class Option {
public final Integer value;
public final String label;
public Option(Integer value, String label) { this.value = value; this.label = label; }
}
}