菜单优化
This commit is contained in:
7
.idea/diff-generator.xml
generated
7
.idea/diff-generator.xml
generated
@@ -1,8 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="DiffGenerationConfig" isInitGenerateDdl="true">
|
<component name="DiffGenerationConfig">
|
||||||
<option name="initGenerateDdl" value="true" />
|
<option name="sourceModelValue" value="jd:entityManagerFactory" />
|
||||||
<option name="sourceModelValue" value="jd:jd" />
|
<option name="targetDbValue" value="31c422ff-86c8-4fe9-ba98-f496d4f1b534" />
|
||||||
<option name="targetDbValue" value="eb8a6f9c-c8ff-4224-9875-8dd3cf91a680" />
|
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
2
.idea/jpb-settings.xml
generated
2
.idea/jpb-settings.xml
generated
@@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="DatabaseMigrationSettings" lastSelectedDirectory="src\main\java\cn\van\business\model" />
|
<component name="DatabaseMigrationSettings" lastSelectedDirectory="src\main\java\cn\van\business\model\jd" />
|
||||||
</project>
|
</project>
|
||||||
@@ -1,6 +1,10 @@
|
|||||||
package cn.van.business.model.jd;
|
package cn.van.business.model.jd;
|
||||||
|
|
||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
@@ -9,6 +13,10 @@ import java.util.Date;
|
|||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "product_order")
|
@Table(name = "product_order")
|
||||||
|
@Setter
|
||||||
|
@Getter
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
public class ProductOrder {
|
public class ProductOrder {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -29,7 +37,7 @@ public class ProductOrder {
|
|||||||
* 商品类型。
|
* 商品类型。
|
||||||
*/
|
*/
|
||||||
@Column(name = "sku_type")
|
@Column(name = "sku_type")
|
||||||
private String skuType;
|
private Integer skuType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 订单号。
|
* 订单号。
|
||||||
@@ -82,225 +90,10 @@ public class ProductOrder {
|
|||||||
private String recipientPhone;
|
private String recipientPhone;
|
||||||
@Column(name = "recipient_address")
|
@Column(name = "recipient_address")
|
||||||
private String recipientAddress;
|
private String recipientAddress;
|
||||||
|
// 谁的单
|
||||||
|
@Column(name = "who_order")
|
||||||
|
private String whoOrder;
|
||||||
|
@Column(name = "from_wxid")
|
||||||
|
private String fromWxid;
|
||||||
|
|
||||||
public Boolean getReviewed() {
|
|
||||||
return isReviewed;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setReviewed(Boolean reviewed) {
|
|
||||||
isReviewed = reviewed;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Boolean getCashbackReceived() {
|
|
||||||
return isCashbackReceived;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCashbackReceived(Boolean cashbackReceived) {
|
|
||||||
isCashbackReceived = cashbackReceived;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getRecipientName() {
|
|
||||||
return recipientName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRecipientName(String recipientName) {
|
|
||||||
this.recipientName = recipientName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getRecipientPhone() {
|
|
||||||
return recipientPhone;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRecipientPhone(String recipientPhone) {
|
|
||||||
this.recipientPhone = recipientPhone;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getRecipientAddress() {
|
|
||||||
return recipientAddress;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRecipientAddress(String recipientAddress) {
|
|
||||||
this.recipientAddress = recipientAddress;
|
|
||||||
}
|
|
||||||
// Getters and Setters
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取主键ID。
|
|
||||||
*
|
|
||||||
* @return 主键ID
|
|
||||||
*/
|
|
||||||
public Long getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 设置主键ID。
|
|
||||||
*
|
|
||||||
* @param id 主键ID
|
|
||||||
*/
|
|
||||||
public void setId(Long id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取商品名称。
|
|
||||||
*
|
|
||||||
* @return 商品名称
|
|
||||||
*/
|
|
||||||
public String getSkuName() {
|
|
||||||
return skuName;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 设置商品名称。
|
|
||||||
*
|
|
||||||
* @param skuName 商品名称
|
|
||||||
*/
|
|
||||||
public void setSkuName(String skuName) {
|
|
||||||
this.skuName = skuName;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取商品类型。
|
|
||||||
*
|
|
||||||
* @return 商品类型
|
|
||||||
*/
|
|
||||||
public String getSkuType() {
|
|
||||||
return skuType;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 设置商品类型。
|
|
||||||
*
|
|
||||||
* @param skuType 商品类型
|
|
||||||
*/
|
|
||||||
public void setSkuType(String skuType) {
|
|
||||||
this.skuType = skuType;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取订单号。
|
|
||||||
*
|
|
||||||
* @return 订单号
|
|
||||||
*/
|
|
||||||
public String getOrderId() {
|
|
||||||
return orderId;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 设置订单号。
|
|
||||||
*
|
|
||||||
* @param orderId 订单号
|
|
||||||
*/
|
|
||||||
public void setOrderId(String orderId) {
|
|
||||||
this.orderId = orderId;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取下单时间。
|
|
||||||
*
|
|
||||||
* @return 下单时间
|
|
||||||
*/
|
|
||||||
public Date getOrderTime() {
|
|
||||||
return orderTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 设置下单时间。
|
|
||||||
*
|
|
||||||
* @param orderTime 下单时间
|
|
||||||
*/
|
|
||||||
public void setOrderTime(Date orderTime) {
|
|
||||||
this.orderTime = orderTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取下单账号。
|
|
||||||
*
|
|
||||||
* @return 下单账号
|
|
||||||
*/
|
|
||||||
public String getOrderAccount() {
|
|
||||||
return orderAccount;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 设置下单账号。
|
|
||||||
*
|
|
||||||
* @param orderAccount 下单账号
|
|
||||||
*/
|
|
||||||
public void setOrderAccount(String orderAccount) {
|
|
||||||
this.orderAccount = orderAccount;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取是否晒图登记。
|
|
||||||
*
|
|
||||||
* @return 是否晒图登记
|
|
||||||
*/
|
|
||||||
public Boolean getIsReviewed() {
|
|
||||||
return isReviewed;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 设置是否晒图登记。
|
|
||||||
*
|
|
||||||
* @param isReviewed 是否晒图登记
|
|
||||||
*/
|
|
||||||
public void setIsReviewed(Boolean isReviewed) {
|
|
||||||
this.isReviewed = isReviewed;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取晒图时间。
|
|
||||||
*
|
|
||||||
* @return 晒图时间
|
|
||||||
*/
|
|
||||||
public Date getReviewTime() {
|
|
||||||
return reviewTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 设置晒图时间。
|
|
||||||
*
|
|
||||||
* @param reviewTime 晒图时间
|
|
||||||
*/
|
|
||||||
public void setReviewTime(Date reviewTime) {
|
|
||||||
this.reviewTime = reviewTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取是否返现到账。
|
|
||||||
*
|
|
||||||
* @return 是否返现到账
|
|
||||||
*/
|
|
||||||
public Boolean getIsCashbackReceived() {
|
|
||||||
return isCashbackReceived;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 设置是否返现到账。
|
|
||||||
*
|
|
||||||
* @param isCashbackReceived 是否返现到账
|
|
||||||
*/
|
|
||||||
public void setIsCashbackReceived(Boolean isCashbackReceived) {
|
|
||||||
this.isCashbackReceived = isCashbackReceived;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取到账时间。
|
|
||||||
*
|
|
||||||
* @return 到账时间
|
|
||||||
*/
|
|
||||||
public Date getCashbackTime() {
|
|
||||||
return cashbackTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 设置到账时间。
|
|
||||||
*
|
|
||||||
* @param cashbackTime 到账时间
|
|
||||||
*/
|
|
||||||
public void setCashbackTime(Date cashbackTime) {
|
|
||||||
this.cashbackTime = cashbackTime;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
19
src/main/java/cn/van/business/model/jd/update-schema.sql
Normal file
19
src/main/java/cn/van/business/model/jd/update-schema.sql
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
CREATE TABLE product_order
|
||||||
|
(
|
||||||
|
id BIGINT AUTO_INCREMENT NOT NULL,
|
||||||
|
sku_name VARCHAR(255) NULL,
|
||||||
|
sku_type INT NULL,
|
||||||
|
order_id VARCHAR(255) NULL,
|
||||||
|
order_time datetime NULL,
|
||||||
|
order_account VARCHAR(255) NULL,
|
||||||
|
is_reviewed BIT(1) NULL,
|
||||||
|
review_time datetime NULL,
|
||||||
|
is_cashback_received BIT(1) NULL,
|
||||||
|
cashback_time datetime NULL,
|
||||||
|
recipient_name VARCHAR(255) NULL,
|
||||||
|
recipient_phone VARCHAR(255) NULL,
|
||||||
|
recipient_address VARCHAR(255) NULL,
|
||||||
|
who_order VARCHAR(255) NULL,
|
||||||
|
from_wxid VARCHAR(255) NULL,
|
||||||
|
CONSTRAINT pk_product_order PRIMARY KEY (id)
|
||||||
|
);
|
||||||
18
src/main/java/cn/van/business/model/update-schema.sql
Normal file
18
src/main/java/cn/van/business/model/update-schema.sql
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
CREATE TABLE product_order
|
||||||
|
(
|
||||||
|
id BIGINT AUTO_INCREMENT NOT NULL,
|
||||||
|
sku_name VARCHAR(255) NULL,
|
||||||
|
sku_type INT NULL,
|
||||||
|
order_id VARCHAR(255) NULL,
|
||||||
|
order_time datetime NULL,
|
||||||
|
order_account VARCHAR(255) NULL,
|
||||||
|
is_reviewed BIT(1) NULL,
|
||||||
|
review_time datetime NULL,
|
||||||
|
is_cashback_received BIT(1) NULL,
|
||||||
|
cashback_time datetime NULL,
|
||||||
|
recipient_name VARCHAR(255) NULL,
|
||||||
|
recipient_phone VARCHAR(255) NULL,
|
||||||
|
recipient_address VARCHAR(255) NULL,
|
||||||
|
who_order VARCHAR(255) NULL,
|
||||||
|
CONSTRAINT pk_product_order PRIMARY KEY (id)
|
||||||
|
);
|
||||||
@@ -43,6 +43,7 @@ import java.util.stream.Stream;
|
|||||||
|
|
||||||
import static cn.van.business.util.JDUtil.UserInteractionState.GiftMoneyStep.*;
|
import static cn.van.business.util.JDUtil.UserInteractionState.GiftMoneyStep.*;
|
||||||
import static cn.van.business.util.JDUtil.UserInteractionState.ProcessState.*;
|
import static cn.van.business.util.JDUtil.UserInteractionState.ProcessState.*;
|
||||||
|
import static cn.van.business.util.JDUtil.UserInteractionState.ProductOrderStep.*;
|
||||||
import static cn.van.business.util.WXUtil.super_admins;
|
import static cn.van.business.util.WXUtil.super_admins;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1241,6 +1242,117 @@ public class JDUtil {
|
|||||||
// 实现实际的开通接口调用
|
// 实现实际的开通接口调用
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
public void handleProductOrderRegistration(String fromWxid, String message, UserInteractionState state) {
|
||||||
|
switch (state.getCurrentProductOrderStep()) {
|
||||||
|
case STEP_ORDER_ID:
|
||||||
|
if (!message.matches("^\\d{10,20}$")) {
|
||||||
|
wxUtil.sendTextMessage(fromWxid, "⚠️ 订单号格式错误(需10-20位数字)", 1, fromWxid);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
state.getCollectedFields().put("orderId", message);
|
||||||
|
state.setCurrentProductOrderStep(STEP_PRODUCT_INFO);
|
||||||
|
wxUtil.sendTextMessage(fromWxid,
|
||||||
|
"请输入商品信息(格式:商品名称-类型编号)\n类型对照:1-家电 2-数码 3-服饰\n示例:格力空调-1", 1, fromWxid);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case STEP_PRODUCT_INFO:
|
||||||
|
String[] productInfo = message.split("-");
|
||||||
|
if (productInfo.length != 2 || !productInfo[1].matches("[1-3]")) {
|
||||||
|
wxUtil.sendTextMessage(fromWxid, "❌ 格式错误或类型编号无效", 1, fromWxid);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
state.getCollectedFields().put("skuName", productInfo[0]);
|
||||||
|
state.getCollectedFields().put("skuType", productInfo[1]);
|
||||||
|
|
||||||
|
state.setCurrentProductOrderStep(UserInteractionState.ProductOrderStep.STEP_RECIPIENT_INFO);
|
||||||
|
wxUtil.sendTextMessage(fromWxid,
|
||||||
|
"请输入收件信息(格式:姓名-电话-地址)\n示例:张三-13812345678-北京市朝阳区", 1, fromWxid);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case STEP_RECIPIENT_INFO:
|
||||||
|
String[] recipientInfo = message.split("-");
|
||||||
|
if (recipientInfo.length < 3) {
|
||||||
|
wxUtil.sendTextMessage(fromWxid, "❌ 格式错误,请按示例格式输入", 1, fromWxid);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
state.getCollectedFields().put("recipientName", recipientInfo[0]);
|
||||||
|
state.getCollectedFields().put("recipientPhone", recipientInfo[1]);
|
||||||
|
state.getCollectedFields().put("recipientAddress", String.join("-", Arrays.copyOfRange(recipientInfo, 2, recipientInfo.length)));
|
||||||
|
|
||||||
|
// 生成确认信息
|
||||||
|
String confirmMsg = buildConfirmMessage(state);
|
||||||
|
wxUtil.sendTextMessage(fromWxid, confirmMsg, 1, fromWxid);
|
||||||
|
state.setCurrentProductOrderStep(STEP_REVIEW_CONFIRM);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case STEP_REVIEW_CONFIRM:
|
||||||
|
if ("确认".equals(message)) {
|
||||||
|
boolean success = saveFullProductOrder(state, fromWxid);
|
||||||
|
wxUtil.sendTextMessage(fromWxid,
|
||||||
|
success ? "✅ 订单登记成功!" : "❌ 保存失败,请联系管理员", 1, fromWxid);
|
||||||
|
state.reset();
|
||||||
|
} else {
|
||||||
|
state.setCurrentProductOrderStep(STEP_ORDER_ID);
|
||||||
|
wxUtil.sendTextMessage(fromWxid, "请重新输入订单号:", 1, fromWxid);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 构建确认信息模板
|
||||||
|
private String buildConfirmMessage(UserInteractionState state) {
|
||||||
|
return "📋 请确认登记信息:\n" +
|
||||||
|
"────────────────\n" +
|
||||||
|
"▪ 订单号:" + state.getCollectedFields().get("orderId") + "\n" +
|
||||||
|
"▪ 商品名称:" + state.getCollectedFields().get("skuName") + "\n" +
|
||||||
|
"▪ 商品类型:" + getTypeDesc(state.getCollectedFields().get("skuType")) + "\n" +
|
||||||
|
"▪ 收件人:" + state.getCollectedFields().get("recipientName") + "\n" +
|
||||||
|
"▪ 联系方式:" + state.getCollectedFields().get("recipientPhone") + "\n" +
|
||||||
|
"▪ 收货地址:" + state.getCollectedFields().get("recipientAddress") + "\n" +
|
||||||
|
"────────────────\n" +
|
||||||
|
"回复【确认】提交,其他内容重新开始";
|
||||||
|
}
|
||||||
|
|
||||||
|
// 保存完整订单
|
||||||
|
private boolean saveFullProductOrder(UserInteractionState state, String fromWxid) {
|
||||||
|
try {
|
||||||
|
ProductOrder order = new ProductOrder();
|
||||||
|
order.setOrderId(state.getCollectedFields().get("orderId"));
|
||||||
|
order.setSkuName(state.getCollectedFields().get("skuName"));
|
||||||
|
order.setSkuType(Integer.valueOf(state.getCollectedFields().get("skuType")));
|
||||||
|
order.setRecipientName(state.getCollectedFields().get("recipientName"));
|
||||||
|
order.setRecipientPhone(state.getCollectedFields().get("recipientPhone"));
|
||||||
|
order.setRecipientAddress(state.getCollectedFields().get("recipientAddress"));
|
||||||
|
order.setOrderTime(new Date()); // 设置下单时间为当前时间
|
||||||
|
order.setWhoOrder(state.getCollectedFields().get("recipientName")); // 关联管理员信息
|
||||||
|
order.setIsReviewed(false); // 默认是否晒图登记
|
||||||
|
order.setIsCashbackReceived(false); // 默认是否返现到账
|
||||||
|
order.setFromWxid(fromWxid); // 设置当前交互的wxid
|
||||||
|
|
||||||
|
productOrderRepository.save(order);
|
||||||
|
logger.info("订单登记成功:{}", order);
|
||||||
|
return true;
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("订单保存异常:{}", e.getMessage());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取商品类型描述
|
||||||
|
private String getTypeDesc(String skuType) {
|
||||||
|
switch (skuType) {
|
||||||
|
case "1":
|
||||||
|
return "家电";
|
||||||
|
case "2":
|
||||||
|
return "数码";
|
||||||
|
case "3":
|
||||||
|
return "服饰";
|
||||||
|
default:
|
||||||
|
return "未知类型";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 定义一个内部类来存储用户交互状态
|
// 定义一个内部类来存储用户交互状态
|
||||||
@Getter
|
@Getter
|
||||||
@@ -1248,19 +1360,27 @@ public class JDUtil {
|
|||||||
static class UserInteractionState {
|
static class UserInteractionState {
|
||||||
// 推荐使用枚举管理状态
|
// 推荐使用枚举管理状态
|
||||||
public enum ProcessState {
|
public enum ProcessState {
|
||||||
INIT, GIFT_MONEY_FLOW, DISINFECTANT_CABINET
|
INIT, GIFT_MONEY_FLOW, DISINFECTANT_CABINET,PRODUCT_ORDER_REGISTRATION
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum GiftMoneyStep {
|
public enum GiftMoneyStep {
|
||||||
STEP_PRODUCT_LINK, STEP_AMOUNT, STEP_QUANTITY
|
STEP_PRODUCT_LINK, STEP_AMOUNT, STEP_QUANTITY
|
||||||
}
|
}
|
||||||
|
// 在UserInteractionState类中新增步骤枚举
|
||||||
|
public enum ProductOrderStep {
|
||||||
|
STEP_ORDER_ID,
|
||||||
|
STEP_PRODUCT_INFO,
|
||||||
|
STEP_RECIPIENT_INFO,
|
||||||
|
STEP_REVIEW_CONFIRM,
|
||||||
|
STEP_CASHBACK_TRACK
|
||||||
|
}
|
||||||
private GiftMoneyStep currentStep; // 新增当前步骤字段
|
private GiftMoneyStep currentStep; // 新增当前步骤字段
|
||||||
|
|
||||||
private String lastInteractionTime;
|
private String lastInteractionTime;
|
||||||
private ProcessState currentState;
|
private ProcessState currentState;
|
||||||
private Map<String, String> collectedFields; // 用于存储收集到的字段值
|
private Map<String, String> collectedFields; // 用于存储收集到的字段值
|
||||||
private String currentField; // 当前正在询问的字段
|
private String currentField; // 当前正在询问的字段
|
||||||
|
private ProductOrderStep currentProductOrderStep;
|
||||||
|
|
||||||
public UserInteractionState() {
|
public UserInteractionState() {
|
||||||
this.lastInteractionTime = LocalDateTime.now().format(DATE_TIME_FORMATTER);
|
this.lastInteractionTime = LocalDateTime.now().format(DATE_TIME_FORMATTER);
|
||||||
|
|||||||
Reference in New Issue
Block a user