抽取统计打印方法
This commit is contained in:
@@ -17,6 +17,7 @@ import com.jd.open.api.sdk.request.kplunion.UnionOpenOrderRowQueryRequest;
|
|||||||
import com.jd.open.api.sdk.request.kplunion.UnionOpenPromotionBysubunionidGetRequest;
|
import com.jd.open.api.sdk.request.kplunion.UnionOpenPromotionBysubunionidGetRequest;
|
||||||
import com.jd.open.api.sdk.response.kplunion.UnionOpenOrderRowQueryResponse;
|
import com.jd.open.api.sdk.response.kplunion.UnionOpenOrderRowQueryResponse;
|
||||||
import com.jd.open.api.sdk.response.kplunion.UnionOpenPromotionBysubunionidGetResponse;
|
import com.jd.open.api.sdk.response.kplunion.UnionOpenPromotionBysubunionidGetResponse;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
@@ -462,6 +463,22 @@ public class JDUtil {
|
|||||||
// 具体逻辑
|
// 具体逻辑
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private OrderStats calculateStats(List<OrderRow> orders) {
|
||||||
|
long paid = orders.stream().filter(o -> o.getValidCode() == 16).count();
|
||||||
|
long pending = orders.stream().filter(o -> o.getValidCode() == 15).count();
|
||||||
|
long canceled = orders.stream().filter(o -> o.getValidCode() != 16 && o.getValidCode() != 17).count();
|
||||||
|
long completed = orders.stream().filter(o -> o.getValidCode() == 17).count();
|
||||||
|
|
||||||
|
return new OrderStats(orders.size(), orders.size() - canceled, paid, orders.stream().filter(o -> o.getValidCode() == 16).mapToDouble(OrderRow::getEstimateFee).sum(), pending, orders.stream().filter(o -> o.getValidCode() == 15).mapToDouble(OrderRow::getEstimateFee).sum(), canceled, completed, orders.stream().filter(o -> o.getValidCode() == 17).mapToDouble(OrderRow::getEstimateFee).sum(), getStreamForWeiGui(orders).count(), getStreamForWeiGui(orders).mapToDouble(o -> o.getEstimateCosPrice() * o.getCommissionRate() * 0.01).sum());
|
||||||
|
}
|
||||||
|
|
||||||
|
private StringBuilder buildStatsContent(String title, OrderStats stats) {
|
||||||
|
StringBuilder content = new StringBuilder();
|
||||||
|
content.append(title).append(":\n").append("订单总数:").append(stats.getTotalOrders()).append("\r").append("订单总数(不含取消):").append(stats.getValidOrders()).append("\r\n").append("已付款:").append(stats.getPaidOrders()).append("\r").append("已付款佣金:").append(stats.getPaidCommission()).append("\r\n").append("待付款:").append(stats.getPendingOrders()).append("\r") // 修正了原代码中的Stream未终止问题
|
||||||
|
.append("待付款佣金:").append(stats.getPendingCommission()).append("\r\n").append("已取消:").append(stats.getCanceledOrders()).append("\r").append("已完成:").append(stats.getCompletedOrders()).append("\r").append("已完成佣金:").append(stats.getCompletedCommission()).append("\r").append("违规:").append(stats.getViolations()).append("\r").append("违规佣金:").append(stats.getViolationCommission());
|
||||||
|
return content;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 接收京粉指令指令
|
* 接收京粉指令指令
|
||||||
*/
|
*/
|
||||||
@@ -525,37 +542,18 @@ public class JDUtil {
|
|||||||
}
|
}
|
||||||
case "今日统计": {
|
case "今日统计": {
|
||||||
content = new StringBuilder();
|
content = new StringBuilder();
|
||||||
|
|
||||||
List<OrderRow> todayOrders = filterOrdersByDate(orderRows, 0);
|
|
||||||
// 订单总数,已付款,已取消,佣金总计
|
// 订单总数,已付款,已取消,佣金总计
|
||||||
content.append("今日统计:\n");
|
List<OrderRow> todayOrders = filterOrdersByDate(orderRows, 0);
|
||||||
content.append("订单总数:").append(todayOrders.size()).append("\r");
|
OrderStats stats = calculateStats(todayOrders);
|
||||||
content.append("订单总数(不含取消):").append(todayOrders.size() - todayOrders.stream().filter(orderRow -> orderRow.getValidCode() != 16 && orderRow.getValidCode() != 17).count()).append("\r");
|
contents.add(buildStatsContent("今日统计", stats));
|
||||||
content.append("已付款:").append(todayOrders.stream().filter(orderRow -> orderRow.getValidCode() == 16).count()).append("\r");
|
|
||||||
content.append("已取消:").append(todayOrders.stream().filter(orderRow -> orderRow.getValidCode() != 16 && orderRow.getValidCode() != 17).count()).append("\r");
|
|
||||||
content.append("已完成:").append(todayOrders.stream().filter(orderRow -> orderRow.getValidCode() == 17).count()).append("\r");
|
|
||||||
content.append("违规:").append(getStreamForWeiGui(todayOrders).count()).append("\r");
|
|
||||||
content.append("已付款佣金:").append(todayOrders.stream().filter(orderRow -> orderRow.getValidCode() == 16).mapToDouble(OrderRow::getEstimateFee).sum()).append("\r");
|
|
||||||
content.append("已完成佣金:").append(todayOrders.stream().filter(orderRow -> orderRow.getValidCode() == 17).mapToDouble(OrderRow::getEstimateFee).sum());
|
|
||||||
content.append("\r" + "违规佣金:").append(getStreamForWeiGui(todayOrders).mapToDouble(orderRow -> orderRow.getEstimateCosPrice() * orderRow.getCommissionRate() * 0.01).sum());
|
|
||||||
|
|
||||||
contents.add(content);
|
contents.add(content);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "昨日统计": {
|
case "昨日统计": {
|
||||||
content = new StringBuilder();
|
content = new StringBuilder();
|
||||||
List<OrderRow> yesterdayOrders = filterOrdersByDate(orderRows, 1);
|
List<OrderRow> yesterdayOrders = filterOrdersByDate(orderRows, 1);
|
||||||
content.append("昨日统计:\n");
|
OrderStats stats = calculateStats(yesterdayOrders);
|
||||||
content.append("订单总数:").append(yesterdayOrders.size()).append("\r");
|
contents.add(buildStatsContent("昨日统计", stats));
|
||||||
content.append("订单总数(不含取消):").append(yesterdayOrders.size() - yesterdayOrders.stream().filter(orderRow -> orderRow.getValidCode() != 16 && orderRow.getValidCode() != 17).count()).append("\r");
|
|
||||||
|
|
||||||
content.append("已付款:").append(yesterdayOrders.stream().filter(orderRow -> orderRow.getValidCode() == 16).count()).append("\r");
|
|
||||||
content.append("已取消:").append(yesterdayOrders.stream().filter(orderRow -> orderRow.getValidCode() != 16 && orderRow.getValidCode() != 17).count()).append("\r");
|
|
||||||
content.append("已完成:").append(yesterdayOrders.stream().filter(orderRow -> orderRow.getValidCode() == 17).count()).append("\r");
|
|
||||||
content.append("违规:").append(getStreamForWeiGui(yesterdayOrders).count()).append("\r");
|
|
||||||
content.append("已付款佣金:").append(yesterdayOrders.stream().filter(orderRow -> orderRow.getValidCode() == 16).mapToDouble(OrderRow::getEstimateFee).sum()).append("\r");
|
|
||||||
content.append("已完成佣金:").append(yesterdayOrders.stream().filter(orderRow -> orderRow.getValidCode() == 17).mapToDouble(OrderRow::getEstimateFee).sum());
|
|
||||||
content.append("\r" + "违规佣金:").append(getStreamForWeiGui(yesterdayOrders).mapToDouble(orderRow -> orderRow.getEstimateCosPrice() * orderRow.getCommissionRate() * 0.01).sum());
|
|
||||||
contents.add(content);
|
contents.add(content);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@@ -563,17 +561,8 @@ public class JDUtil {
|
|||||||
case "三日统计": {
|
case "三日统计": {
|
||||||
content = new StringBuilder();
|
content = new StringBuilder();
|
||||||
List<OrderRow> last3DaysOrders = filterOrdersByDate(orderRows, 3);
|
List<OrderRow> last3DaysOrders = filterOrdersByDate(orderRows, 3);
|
||||||
content.append("三日统计:\n");
|
OrderStats stats = calculateStats(last3DaysOrders);
|
||||||
content.append("订单总数:").append(last3DaysOrders.size()).append("\r");
|
contents.add(buildStatsContent("三日统计", stats));
|
||||||
content.append("订单总数(不含取消):").append(last3DaysOrders.size() - last3DaysOrders.stream().filter(orderRow -> orderRow.getValidCode() != 16 && orderRow.getValidCode() != 17).count()).append("\r");
|
|
||||||
|
|
||||||
content.append("已付款:").append(last3DaysOrders.stream().filter(orderRow -> orderRow.getValidCode() == 16).count()).append("\r");
|
|
||||||
content.append("已取消:").append(last3DaysOrders.stream().filter(orderRow -> orderRow.getValidCode() != 16 && orderRow.getValidCode() != 17).count()).append("\r");
|
|
||||||
content.append("已完成:").append(last3DaysOrders.stream().filter(orderRow -> orderRow.getValidCode() == 17).count()).append("\r");
|
|
||||||
content.append("违规:").append(getStreamForWeiGui(last3DaysOrders).count()).append("\r");
|
|
||||||
content.append("已付款佣金:").append(last3DaysOrders.stream().filter(orderRow -> orderRow.getValidCode() == 16).mapToDouble(OrderRow::getEstimateFee).sum()).append("\r");
|
|
||||||
content.append("已完成佣金:").append(last3DaysOrders.stream().filter(orderRow -> orderRow.getValidCode() == 17).mapToDouble(OrderRow::getEstimateFee).sum());
|
|
||||||
content.append("\r" + "违规佣金:").append(getStreamForWeiGui(last3DaysOrders).mapToDouble(orderRow -> orderRow.getEstimateCosPrice() * orderRow.getCommissionRate() * 0.01).sum());
|
|
||||||
|
|
||||||
contents.add(content);
|
contents.add(content);
|
||||||
break;
|
break;
|
||||||
@@ -581,35 +570,16 @@ public class JDUtil {
|
|||||||
case "七日统计": {
|
case "七日统计": {
|
||||||
content = new StringBuilder();
|
content = new StringBuilder();
|
||||||
List<OrderRow> last7DaysOrders = filterOrdersByDate(orderRows, 7);
|
List<OrderRow> last7DaysOrders = filterOrdersByDate(orderRows, 7);
|
||||||
content.append("七日统计:\n");
|
OrderStats stats = calculateStats(last7DaysOrders);
|
||||||
content.append("订单总数:").append(last7DaysOrders.size()).append("\r");
|
contents.add(buildStatsContent("七日统计", stats));
|
||||||
content.append("订单总数(不含取消):").append(last7DaysOrders.size() - last7DaysOrders.stream().filter(orderRow -> orderRow.getValidCode() != 16 && orderRow.getValidCode() != 17).count()).append("\r");
|
|
||||||
content.append("已付款:").append(last7DaysOrders.stream().filter(orderRow -> orderRow.getValidCode() == 16).count()).append("\r");
|
|
||||||
content.append("已取消:").append(last7DaysOrders.stream().filter(orderRow -> orderRow.getValidCode() != 16 && orderRow.getValidCode() != 17).count()).append("\r");
|
|
||||||
content.append("已完成:").append(last7DaysOrders.stream().filter(orderRow -> orderRow.getValidCode() == 17).count()).append("\r");
|
|
||||||
content.append("违规:").append(getStreamForWeiGui(last7DaysOrders).count()).append("\r");
|
|
||||||
content.append("已付款佣金:").append(last7DaysOrders.stream().filter(orderRow -> orderRow.getValidCode() == 16).mapToDouble(OrderRow::getEstimateFee).sum()).append("\r");
|
|
||||||
content.append("已完成佣金:").append(last7DaysOrders.stream().filter(orderRow -> orderRow.getValidCode() == 17).mapToDouble(OrderRow::getEstimateFee).sum());
|
|
||||||
content.append("\r" + "违规佣金:").append(getStreamForWeiGui(last7DaysOrders).mapToDouble(orderRow -> orderRow.getEstimateCosPrice() * orderRow.getCommissionRate() * 0.01).sum());
|
|
||||||
|
|
||||||
contents.add(content);
|
contents.add(content);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "一个月统计": {
|
case "一个月统计": {
|
||||||
content = new StringBuilder();
|
content = new StringBuilder();
|
||||||
List<OrderRow> last30DaysOrders = filterOrdersByDate(orderRows, 30);
|
List<OrderRow> last30DaysOrders = filterOrdersByDate(orderRows, 30);
|
||||||
content.append("一个月统计:\n");
|
OrderStats stats = calculateStats(last30DaysOrders);
|
||||||
content.append("订单总数:").append(last30DaysOrders.size()).append("\r");
|
contents.add(buildStatsContent("一个月统计", stats));
|
||||||
content.append("订单总数(不含取消):").append(last30DaysOrders.size() - last30DaysOrders.stream().filter(orderRow -> orderRow.getValidCode() != 16 && orderRow.getValidCode() != 17).count()).append("\r");
|
|
||||||
|
|
||||||
content.append("已付款:").append(last30DaysOrders.stream().filter(orderRow -> orderRow.getValidCode() == 16).count()).append("\r");
|
|
||||||
content.append("已取消:").append(last30DaysOrders.stream().filter(orderRow -> orderRow.getValidCode() != 16 && orderRow.getValidCode() != 17).count()).append("\r");
|
|
||||||
content.append("已完成:").append(last30DaysOrders.stream().filter(orderRow -> orderRow.getValidCode() == 17).count()).append("\r");
|
|
||||||
content.append("违规:").append(getStreamForWeiGui(last30DaysOrders).count()).append("\r");
|
|
||||||
content.append("已付款佣金:").append(last30DaysOrders.stream().filter(orderRow -> orderRow.getValidCode() == 16).mapToDouble(OrderRow::getEstimateFee).sum()).append("\r");
|
|
||||||
content.append("已完成佣金:").append(last30DaysOrders.stream().filter(orderRow -> orderRow.getValidCode() == 17).mapToDouble(OrderRow::getEstimateFee).sum());
|
|
||||||
content.append("\r" + "违规佣金:").append(getStreamForWeiGui(last30DaysOrders).mapToDouble(orderRow -> orderRow.getEstimateCosPrice() * orderRow.getCommissionRate() * 0.01).sum());
|
|
||||||
|
|
||||||
contents.add(content);
|
contents.add(content);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -617,18 +587,8 @@ public class JDUtil {
|
|||||||
|
|
||||||
content = new StringBuilder();
|
content = new StringBuilder();
|
||||||
List<OrderRow> last60DaysOrders = filterOrdersByDate(orderRows, 60);
|
List<OrderRow> last60DaysOrders = filterOrdersByDate(orderRows, 60);
|
||||||
content.append("两个月统计:\n");
|
OrderStats stats = calculateStats(last60DaysOrders);
|
||||||
content.append("订单总数:").append(last60DaysOrders.size()).append("\r");
|
contents.add(buildStatsContent("两个月统计", stats));
|
||||||
content.append("订单总数(不含取消):").append(last60DaysOrders.size() - last60DaysOrders.stream().filter(orderRow -> orderRow.getValidCode() != 16 && orderRow.getValidCode() != 17).count()).append("\r");
|
|
||||||
|
|
||||||
content.append("已付款:").append(last60DaysOrders.stream().filter(orderRow -> orderRow.getValidCode() == 16).count()).append("\r");
|
|
||||||
content.append("已取消:").append(last60DaysOrders.stream().filter(orderRow -> orderRow.getValidCode() != 16 && orderRow.getValidCode() != 17).count()).append("\r");
|
|
||||||
content.append("已完成:").append(last60DaysOrders.stream().filter(orderRow -> orderRow.getValidCode() == 17).count()).append("\r");
|
|
||||||
content.append("违规:").append(getStreamForWeiGui(last60DaysOrders).count()).append("\r");
|
|
||||||
content.append("已付款佣金:").append(last60DaysOrders.stream().filter(orderRow -> orderRow.getValidCode() == 16).mapToDouble(OrderRow::getEstimateFee).sum()).append("\r");
|
|
||||||
content.append("已完成佣金:").append(last60DaysOrders.stream().filter(orderRow -> orderRow.getValidCode() == 17).mapToDouble(OrderRow::getEstimateFee).sum());
|
|
||||||
content.append("\r" + "违规佣金:").append(getStreamForWeiGui(last60DaysOrders).mapToDouble(orderRow -> orderRow.getEstimateCosPrice() * orderRow.getCommissionRate() * 0.01).sum());
|
|
||||||
|
|
||||||
contents.add(content);
|
contents.add(content);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -636,17 +596,8 @@ public class JDUtil {
|
|||||||
|
|
||||||
content = new StringBuilder();
|
content = new StringBuilder();
|
||||||
List<OrderRow> last90DaysOrders = filterOrdersByDate(orderRows, 90);
|
List<OrderRow> last90DaysOrders = filterOrdersByDate(orderRows, 90);
|
||||||
content.append("订单总数:").append(last90DaysOrders.size()).append("\r");
|
OrderStats stats = calculateStats(last90DaysOrders);
|
||||||
content.append("订单总数(不含取消):").append(last90DaysOrders.size() - last90DaysOrders.stream().filter(orderRow -> orderRow.getValidCode() != 16 && orderRow.getValidCode() != 17).count()).append("\r");
|
contents.add(buildStatsContent("三个月统计", stats));
|
||||||
|
|
||||||
content.append("已付款:").append(last90DaysOrders.stream().filter(orderRow -> orderRow.getValidCode() == 16).count()).append("\r");
|
|
||||||
content.append("已取消:").append(last90DaysOrders.stream().filter(orderRow -> orderRow.getValidCode() != 16 && orderRow.getValidCode() != 17).count()).append("\r");
|
|
||||||
content.append("已完成:").append(last90DaysOrders.stream().filter(orderRow -> orderRow.getValidCode() == 17).count()).append("\r");
|
|
||||||
content.append("违规:").append(getStreamForWeiGui(last90DaysOrders).count()).append("\r");
|
|
||||||
content.append("已付款佣金:").append(last90DaysOrders.stream().filter(orderRow -> orderRow.getValidCode() == 16).mapToDouble(OrderRow::getEstimateFee).sum()).append("\r");
|
|
||||||
content.append("已完成佣金:").append(last90DaysOrders.stream().filter(orderRow -> orderRow.getValidCode() == 17).mapToDouble(OrderRow::getEstimateFee).sum());
|
|
||||||
content.append("\r" + "违规佣金:").append(getStreamForWeiGui(last90DaysOrders).mapToDouble(orderRow -> orderRow.getEstimateCosPrice() * orderRow.getCommissionRate() * 0.01).sum());
|
|
||||||
|
|
||||||
contents.add(content);
|
contents.add(content);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -656,19 +607,8 @@ public class JDUtil {
|
|||||||
// 计算出距离1号有几天
|
// 计算出距离1号有几天
|
||||||
int days = LocalDate.now().getDayOfMonth();
|
int days = LocalDate.now().getDayOfMonth();
|
||||||
List<OrderRow> thisMonthOrders = filterOrdersByDate(orderRows, days);
|
List<OrderRow> thisMonthOrders = filterOrdersByDate(orderRows, days);
|
||||||
|
OrderStats stats = calculateStats(thisMonthOrders);
|
||||||
content.append("本月统计:\n");
|
contents.add(buildStatsContent("这个月统计", stats));
|
||||||
content.append("订单总数:").append(thisMonthOrders.size()).append("\r");
|
|
||||||
content.append("订单总数(不含取消):").append(thisMonthOrders.size() - thisMonthOrders.stream().filter(orderRow -> orderRow.getValidCode() != 16 && orderRow.getValidCode() != 17).count()).append("\r");
|
|
||||||
|
|
||||||
content.append("已付款:").append(thisMonthOrders.stream().filter(orderRow -> orderRow.getValidCode() == 16).count()).append("\r");
|
|
||||||
content.append("已取消:").append(thisMonthOrders.stream().filter(orderRow -> orderRow.getValidCode() != 16 && orderRow.getValidCode() != 17).count()).append("\r");
|
|
||||||
content.append("已完成:").append(thisMonthOrders.stream().filter(orderRow -> orderRow.getValidCode() == 17).count()).append("\r");
|
|
||||||
content.append("违规:").append(getStreamForWeiGui(thisMonthOrders).count()).append("\r");
|
|
||||||
content.append("已付款佣金:").append(thisMonthOrders.stream().filter(orderRow -> orderRow.getValidCode() == 16).mapToDouble(OrderRow::getEstimateFee).sum()).append("\r");
|
|
||||||
content.append("已完成佣金:").append(thisMonthOrders.stream().filter(orderRow -> orderRow.getValidCode() == 17).mapToDouble(OrderRow::getEstimateFee).sum());
|
|
||||||
content.append("\r" + "违规佣金:").append(getStreamForWeiGui(thisMonthOrders).mapToDouble(orderRow -> orderRow.getEstimateCosPrice() * orderRow.getCommissionRate() * 0.01).sum());
|
|
||||||
|
|
||||||
contents.add(content);
|
contents.add(content);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -682,18 +622,8 @@ public class JDUtil {
|
|||||||
List<OrderRow> thisMonthOrders = filterOrdersByDate(orderRows, days);
|
List<OrderRow> thisMonthOrders = filterOrdersByDate(orderRows, days);
|
||||||
lastMonthOrders = lastMonthOrders.stream().filter(orderRow -> !thisMonthOrders.contains(orderRow)).collect(Collectors.toList());
|
lastMonthOrders = lastMonthOrders.stream().filter(orderRow -> !thisMonthOrders.contains(orderRow)).collect(Collectors.toList());
|
||||||
|
|
||||||
content.append("上个月统计:\n");
|
OrderStats stats = calculateStats(lastMonthOrders);
|
||||||
content.append("订单总数:").append(lastMonthOrders.size()).append("\r");
|
contents.add(buildStatsContent("上个月统计", stats));
|
||||||
content.append("订单总数(不含取消):").append(lastMonthOrders.size() - lastMonthOrders.stream().filter(orderRow -> orderRow.getValidCode() != 16 && orderRow.getValidCode() != 17).count()).append("\r");
|
|
||||||
|
|
||||||
content.append("已付款:").append(lastMonthOrders.stream().filter(orderRow -> orderRow.getValidCode() == 16).count()).append("\r");
|
|
||||||
content.append("已取消:").append(lastMonthOrders.stream().filter(orderRow -> orderRow.getValidCode() != 16 && orderRow.getValidCode() != 17).count()).append("\r");
|
|
||||||
content.append("已完成:").append(lastMonthOrders.stream().filter(orderRow -> orderRow.getValidCode() == 17).count()).append("\r");
|
|
||||||
content.append("违规:").append(getStreamForWeiGui(lastMonthOrders).count()).append("\r");
|
|
||||||
content.append("已付款佣金:").append(lastMonthOrders.stream().filter(orderRow -> orderRow.getValidCode() == 16).mapToDouble(OrderRow::getEstimateFee).sum()).append("\r");
|
|
||||||
content.append("已完成佣金:").append(lastMonthOrders.stream().filter(orderRow -> orderRow.getValidCode() == 17).mapToDouble(OrderRow::getEstimateFee).sum());
|
|
||||||
content.append("\r" + "违规佣金:").append(getStreamForWeiGui(lastMonthOrders).mapToDouble(orderRow -> orderRow.getEstimateCosPrice() * orderRow.getCommissionRate() * 0.01).sum());
|
|
||||||
|
|
||||||
contents.add(content);
|
contents.add(content);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -703,18 +633,8 @@ public class JDUtil {
|
|||||||
case "总统计": {
|
case "总统计": {
|
||||||
|
|
||||||
content = new StringBuilder();
|
content = new StringBuilder();
|
||||||
content.append("总统计:\n");
|
OrderStats stats = calculateStats(orderRows);
|
||||||
content.append("订单总数:").append(orderRows.size()).append("\r");
|
contents.add(buildStatsContent("总统计", stats));
|
||||||
content.append("订单总数(不含取消):").append(orderRows.size() - orderRows.stream().filter(orderRow -> orderRow.getValidCode() != 16 && orderRow.getValidCode() != 17).count()).append("\r");
|
|
||||||
|
|
||||||
content.append("已付款:").append(orderRows.stream().filter(orderRow -> orderRow.getValidCode() == 16).count()).append("\r");
|
|
||||||
content.append("已取消:").append(orderRows.stream().filter(orderRow -> orderRow.getValidCode() != 16 && orderRow.getValidCode() != 17).count()).append("\r");
|
|
||||||
content.append("已完成:").append(orderRows.stream().filter(orderRow -> orderRow.getValidCode() == 17).count()).append("\r");
|
|
||||||
content.append("违规:").append(getStreamForWeiGui(orderRows).count()).append("\r");
|
|
||||||
content.append("已付款佣金:").append(orderRows.stream().filter(orderRow -> orderRow.getValidCode() == 16).mapToDouble(OrderRow::getEstimateFee).sum()).append("\r");
|
|
||||||
content.append("已完成佣金:").append(orderRows.stream().filter(orderRow -> orderRow.getValidCode() == 17).mapToDouble(OrderRow::getEstimateFee).sum());
|
|
||||||
content.append("\r" + "违规佣金:").append(getStreamForWeiGui(orderRows).mapToDouble(orderRow -> orderRow.getEstimateCosPrice() * orderRow.getCommissionRate() * 0.01).sum());
|
|
||||||
|
|
||||||
contents.add(content);
|
contents.add(content);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -725,19 +645,8 @@ public class JDUtil {
|
|||||||
content = new StringBuilder();
|
content = new StringBuilder();
|
||||||
List<OrderRow> todayOrders = filterOrdersByDate(orderRows, 0);
|
List<OrderRow> todayOrders = filterOrdersByDate(orderRows, 0);
|
||||||
// 订单总数,已付款,已取消,佣金总计
|
// 订单总数,已付款,已取消,佣金总计
|
||||||
content.append("今日统计:\n");
|
OrderStats stats = calculateStats(todayOrders);
|
||||||
content.append("订单总数:").append(todayOrders.size()).append("\r");
|
contents.add(buildStatsContent("今日统计", stats));
|
||||||
content.append("订单总数(不含取消):").append(todayOrders.size() - todayOrders.stream().filter(orderRow -> orderRow.getValidCode() != 16 && orderRow.getValidCode() != 17).count()).append("\r");
|
|
||||||
|
|
||||||
content.append("已付款:").append(todayOrders.stream().filter(orderRow -> orderRow.getValidCode() == 16).count()).append("\r");
|
|
||||||
content.append("已取消:").append(todayOrders.stream().filter(orderRow -> orderRow.getValidCode() != 16 && orderRow.getValidCode() != 17).count()).append("\r");
|
|
||||||
content.append("已完成:").append(todayOrders.stream().filter(orderRow -> orderRow.getValidCode() == 17).count()).append("\r");
|
|
||||||
content.append("违规:").append(getStreamForWeiGui(todayOrders).count()).append("\r");
|
|
||||||
content.append("已付款佣金:").append(todayOrders.stream().filter(orderRow -> orderRow.getValidCode() == 16).mapToDouble(OrderRow::getEstimateFee).sum()).append("\r");
|
|
||||||
content.append("已完成佣金:").append(todayOrders.stream().filter(orderRow -> orderRow.getValidCode() == 17).mapToDouble(OrderRow::getEstimateFee).sum());
|
|
||||||
content.append("\r" + "违规佣金:").append(getStreamForWeiGui(todayOrders).mapToDouble(orderRow -> orderRow.getEstimateCosPrice() * orderRow.getCommissionRate() * 0.01).sum());
|
|
||||||
|
|
||||||
|
|
||||||
if (!todayOrders.isEmpty()) {
|
if (!todayOrders.isEmpty()) {
|
||||||
orderUtil.orderToWxBatch(todayOrders);
|
orderUtil.orderToWxBatch(todayOrders);
|
||||||
}
|
}
|
||||||
@@ -751,18 +660,8 @@ public class JDUtil {
|
|||||||
List<OrderRow> yesterdayOrders = filterOrdersByDate(orderRows, 1);
|
List<OrderRow> yesterdayOrders = filterOrdersByDate(orderRows, 1);
|
||||||
List<OrderRow> todayOrders = filterOrdersByDate(orderRows, 0);
|
List<OrderRow> todayOrders = filterOrdersByDate(orderRows, 0);
|
||||||
yesterdayOrders.removeAll(todayOrders);
|
yesterdayOrders.removeAll(todayOrders);
|
||||||
content.append("昨日统计:\n");
|
OrderStats stats = calculateStats(yesterdayOrders);
|
||||||
content.append("订单总数:").append(yesterdayOrders.size()).append("\r");
|
contents.add(buildStatsContent("昨日统计", stats));
|
||||||
content.append("订单总数(不含取消):").append(yesterdayOrders.size() - yesterdayOrders.stream().filter(orderRow -> orderRow.getValidCode() != 16 && orderRow.getValidCode() != 17).count()).append("\r");
|
|
||||||
|
|
||||||
content.append("已付款:").append(yesterdayOrders.stream().filter(orderRow -> orderRow.getValidCode() == 16).count()).append("\r");
|
|
||||||
content.append("已取消:").append(yesterdayOrders.stream().filter(orderRow -> orderRow.getValidCode() != 16 && orderRow.getValidCode() != 17).count()).append("\r");
|
|
||||||
content.append("已完成:").append(yesterdayOrders.stream().filter(orderRow -> orderRow.getValidCode() == 17).count()).append("\r");
|
|
||||||
content.append("违规:").append(getStreamForWeiGui(yesterdayOrders).count()).append("\r");
|
|
||||||
content.append("已付款佣金:").append(yesterdayOrders.stream().filter(orderRow -> orderRow.getValidCode() == 16).mapToDouble(OrderRow::getEstimateFee).sum()).append("\r");
|
|
||||||
content.append("已完成佣金:").append(yesterdayOrders.stream().filter(orderRow -> orderRow.getValidCode() == 17).mapToDouble(OrderRow::getEstimateFee).sum());
|
|
||||||
content.append("\r" + "违规佣金:").append(getStreamForWeiGui(yesterdayOrders).mapToDouble(orderRow -> orderRow.getEstimateCosPrice() * orderRow.getCommissionRate() * 0.01).sum());
|
|
||||||
|
|
||||||
if (!yesterdayOrders.isEmpty()) {
|
if (!yesterdayOrders.isEmpty()) {
|
||||||
orderUtil.orderToWxBatch(todayOrders);
|
orderUtil.orderToWxBatch(todayOrders);
|
||||||
}
|
}
|
||||||
@@ -775,18 +674,8 @@ public class JDUtil {
|
|||||||
List<OrderRow> last7DaysOrders = filterOrdersByDate(orderRows, 1);
|
List<OrderRow> last7DaysOrders = filterOrdersByDate(orderRows, 1);
|
||||||
List<OrderRow> todayOrders = filterOrdersByDate(orderRows, 0);
|
List<OrderRow> todayOrders = filterOrdersByDate(orderRows, 0);
|
||||||
last7DaysOrders.removeAll(todayOrders);
|
last7DaysOrders.removeAll(todayOrders);
|
||||||
content.append("七日统计:\n");
|
OrderStats stats = calculateStats(last7DaysOrders);
|
||||||
content.append("订单总数:").append(last7DaysOrders.size()).append("\r");
|
contents.add(buildStatsContent("七日统计", stats));
|
||||||
content.append("订单总数(不含取消):").append(last7DaysOrders.size() - last7DaysOrders.stream().filter(orderRow -> orderRow.getValidCode() != 16 && orderRow.getValidCode() != 17).count()).append("\r");
|
|
||||||
|
|
||||||
|
|
||||||
content.append("已付款:").append(last7DaysOrders.stream().filter(orderRow -> orderRow.getValidCode() == 16).count()).append("\r");
|
|
||||||
content.append("已取消:").append(last7DaysOrders.stream().filter(orderRow -> orderRow.getValidCode() != 16 && orderRow.getValidCode() != 17).count()).append("\r");
|
|
||||||
content.append("已完成:").append(last7DaysOrders.stream().filter(orderRow -> orderRow.getValidCode() == 17).count()).append("\r");
|
|
||||||
content.append("违规:").append(getStreamForWeiGui(last7DaysOrders).count()).append("\r");
|
|
||||||
content.append("已付款佣金:").append(last7DaysOrders.stream().filter(orderRow -> orderRow.getValidCode() == 16).mapToDouble(OrderRow::getEstimateFee).sum()).append("\r");
|
|
||||||
content.append("已完成佣金:").append(last7DaysOrders.stream().filter(orderRow -> orderRow.getValidCode() == 17).mapToDouble(OrderRow::getEstimateFee).sum());
|
|
||||||
content.append("\r" + "违规佣金:").append(getStreamForWeiGui(last7DaysOrders).mapToDouble(orderRow -> orderRow.getEstimateCosPrice() * orderRow.getCommissionRate() * 0.01).sum());
|
|
||||||
|
|
||||||
if (!last7DaysOrders.isEmpty()) {
|
if (!last7DaysOrders.isEmpty()) {
|
||||||
orderUtil.orderToWxBatch(last7DaysOrders);
|
orderUtil.orderToWxBatch(last7DaysOrders);
|
||||||
@@ -846,12 +735,11 @@ public class JDUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
/**
|
|
||||||
* 接收京粉指令指令
|
* 接收京粉指令指令
|
||||||
* 高级菜单
|
* 高级菜单
|
||||||
*/
|
*/
|
||||||
public void sendOrderToWxByOrderJDAdvanced(String order, String fromWxid) {
|
public void sendOrderToWxByOrderJDAdvanced(String order, String fromWxid) {
|
||||||
int[] param = {-1};
|
int[] param = {-1};
|
||||||
WXUtil.SuperAdmin superAdmin = super_admins.get(fromWxid);
|
WXUtil.SuperAdmin superAdmin = super_admins.get(fromWxid);
|
||||||
String unionId = superAdmin.getUnionId();
|
String unionId = superAdmin.getUnionId();
|
||||||
@@ -990,9 +878,9 @@ public class JDUtil {
|
|||||||
wxUtil.sendTextMessage(fromWxid, stringBuilder.toString(), 1, fromWxid);
|
wxUtil.sendTextMessage(fromWxid, stringBuilder.toString(), 1, fromWxid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取订单列表
|
* 获取订单列表
|
||||||
*
|
*
|
||||||
* @param start 开始时间
|
* @param start 开始时间
|
||||||
@@ -1000,7 +888,7 @@ public class JDUtil {
|
|||||||
* @return
|
* @return
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public UnionOpenOrderRowQueryResponse getUnionOpenOrderRowQueryResponse(LocalDateTime start, LocalDateTime end, Integer pageIndex, String appKey, String secretKey) throws Exception {
|
public UnionOpenOrderRowQueryResponse getUnionOpenOrderRowQueryResponse(LocalDateTime start, LocalDateTime end, Integer pageIndex, String appKey, String secretKey) throws Exception {
|
||||||
String startTime = start.format(DATE_TIME_FORMATTER);
|
String startTime = start.format(DATE_TIME_FORMATTER);
|
||||||
String endTime = end.format(DATE_TIME_FORMATTER);
|
String endTime = end.format(DATE_TIME_FORMATTER);
|
||||||
// 模拟 API 调用
|
// 模拟 API 调用
|
||||||
@@ -1027,13 +915,13 @@ public class JDUtil {
|
|||||||
|
|
||||||
|
|
||||||
return client.execute(request);
|
return client.execute(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 接口描述:通过商品链接、领券链接、活动链接获取普通推广链接或优惠券二合一推广链接
|
* 接口描述:通过商品链接、领券链接、活动链接获取普通推广链接或优惠券二合一推广链接
|
||||||
* jd.union.open.promotion.bysubunionid.get
|
* jd.union.open.promotion.bysubunionid.get
|
||||||
*/
|
*/
|
||||||
String transfer(String url) throws Exception {
|
String transfer(String url) throws Exception {
|
||||||
JdClient client = new DefaultJdClient(SERVER_URL, ACCESS_TOKEN, LPF_APP_KEY_DG, LPF_SECRET_KEY_DG);
|
JdClient client = new DefaultJdClient(SERVER_URL, ACCESS_TOKEN, LPF_APP_KEY_DG, LPF_SECRET_KEY_DG);
|
||||||
|
|
||||||
UnionOpenPromotionBysubunionidGetRequest request = new UnionOpenPromotionBysubunionidGetRequest();
|
UnionOpenPromotionBysubunionidGetRequest request = new UnionOpenPromotionBysubunionidGetRequest();
|
||||||
@@ -1069,29 +957,13 @@ public class JDUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
//public UnionOpenGoodsBigfieldQueryResponse getUnionOpenGoodsBigfieldQueryResponse(){
|
|
||||||
// JdClient client = new DefaultJdClient(SERVER_URL, ACCESS_TOKEN, APP_KEY, SECRET_KEY);
|
|
||||||
//
|
|
||||||
// UnionOpenGoodsBigfieldQueryRequest request=new UnionOpenGoodsBigfieldQueryRequest();
|
|
||||||
// BigFieldGoodsReq goodsReq=new BigFieldGoodsReq();
|
|
||||||
// goodsReq.setSkuIds();
|
|
||||||
// request.setGoodsReq(goodsReq);
|
|
||||||
// request.setVersion("1.0");
|
|
||||||
// UnionOpenGoodsBigfieldQueryResponse response= null;
|
|
||||||
// try {
|
|
||||||
// response = client.execute(request);
|
|
||||||
// } catch (Exception e) {
|
|
||||||
// throw new RuntimeException(e);
|
|
||||||
// }
|
|
||||||
// return response;
|
|
||||||
//}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 消毒柜部分的业务逻辑
|
* 消毒柜部分的业务逻辑
|
||||||
*/
|
*/
|
||||||
@Scheduled(fixedRate = 60000) // 每分钟执行一次
|
@Scheduled(fixedRate = 60000) // 每分钟执行一次
|
||||||
public void cleanUpTimeoutStates() {
|
public void cleanUpTimeoutStates() {
|
||||||
LocalDateTime now = LocalDateTime.now();
|
LocalDateTime now = LocalDateTime.now();
|
||||||
redisTemplate.keys(INTERACTION_STATE_PREFIX + "*").forEach(key -> {
|
redisTemplate.keys(INTERACTION_STATE_PREFIX + "*").forEach(key -> {
|
||||||
String stateJson = redisTemplate.opsForValue().get(key);
|
String stateJson = redisTemplate.opsForValue().get(key);
|
||||||
@@ -1106,9 +978,25 @@ public class JDUtil {
|
|||||||
logger.error("Error parsing interaction state: {}", e.getMessage());
|
logger.error("Error parsing interaction state: {}", e.getMessage());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
//public UnionOpenGoodsBigfieldQueryResponse getUnionOpenGoodsBigfieldQueryResponse(){
|
||||||
|
// JdClient client = new DefaultJdClient(SERVER_URL, ACCESS_TOKEN, APP_KEY, SECRET_KEY);
|
||||||
|
//
|
||||||
|
// UnionOpenGoodsBigfieldQueryRequest request=new UnionOpenGoodsBigfieldQueryRequest();
|
||||||
|
// BigFieldGoodsReq goodsReq=new BigFieldGoodsReq();
|
||||||
|
// goodsReq.setSkuIds();
|
||||||
|
// request.setGoodsReq(goodsReq);
|
||||||
|
// request.setVersion("1.0");
|
||||||
|
// UnionOpenGoodsBigfieldQueryResponse response= null;
|
||||||
|
// try {
|
||||||
|
// response = client.execute(request);
|
||||||
|
// } catch (Exception e) {
|
||||||
|
// throw new RuntimeException(e);
|
||||||
|
// }
|
||||||
|
// return response;
|
||||||
|
//}
|
||||||
|
|
||||||
public void handleUserInteraction(String fromWxid, String message) {
|
public void handleUserInteraction(String fromWxid, String message) {
|
||||||
String key = INTERACTION_STATE_PREFIX + fromWxid;
|
String key = INTERACTION_STATE_PREFIX + fromWxid;
|
||||||
String stateJson = redisTemplate.opsForValue().get(key);
|
String stateJson = redisTemplate.opsForValue().get(key);
|
||||||
UserInteractionState state;
|
UserInteractionState state;
|
||||||
@@ -1168,12 +1056,10 @@ public class JDUtil {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("Error saving interaction state: {}", e.getMessage());
|
logger.error("Error saving interaction state: {}", e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 新增礼金流程处理方法
|
||||||
|
private void handleGiftMoneyFlow(String fromWxid, String message, UserInteractionState state) {
|
||||||
// 新增礼金流程处理方法
|
|
||||||
private void handleGiftMoneyFlow(String fromWxid, String message, UserInteractionState state) {
|
|
||||||
if ("礼金".equals(message)) {
|
if ("礼金".equals(message)) {
|
||||||
state.reset(); // 重置流程
|
state.reset(); // 重置流程
|
||||||
wxUtil.sendTextMessage(fromWxid, "流程已重置,请重新开始", 1, fromWxid);
|
wxUtil.sendTextMessage(fromWxid, "流程已重置,请重新开始", 1, fromWxid);
|
||||||
@@ -1223,30 +1109,32 @@ public class JDUtil {
|
|||||||
wxUtil.sendTextMessage(fromWxid, "系统异常,流程已终止", 1, fromWxid);
|
wxUtil.sendTextMessage(fromWxid, "系统异常,流程已终止", 1, fromWxid);
|
||||||
state.reset();
|
state.reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private String parseSkuFromUrl(String url) {
|
|
||||||
|
private String parseSkuFromUrl(String url) {
|
||||||
// 实现从URL中解析SKU的逻辑
|
// 实现从URL中解析SKU的逻辑
|
||||||
return "123456"; // 示例返回值
|
return "123456"; // 示例返回值
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isValidAmount(String input) {
|
private boolean isValidAmount(String input) {
|
||||||
return input.matches("^\\d+(\\.\\d{1,2})?$");
|
return input.matches("^\\d+(\\.\\d{1,2})?$");
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<String, String> queryProductInfo(String skuId) {
|
private Map<String, String> queryProductInfo(String skuId) {
|
||||||
// 调用京东商品查询API(需要实现)
|
// 调用京东商品查询API(需要实现)
|
||||||
return Map.of("name", "示例商品", "price", "299.00");
|
return Map.of("name", "示例商品", "price", "299.00");
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isValidQuantity(String input) {
|
private boolean isValidQuantity(String input) {
|
||||||
return input.matches("^\\d+$");
|
return input.matches("^\\d+$");
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean activateGiftMoney(String skuId, double amount, int quantity) {
|
private boolean activateGiftMoney(String skuId, double amount, int quantity) {
|
||||||
// 实现实际的开通接口调用
|
// 实现实际的开通接口调用
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
private void handleProductOrderRegistration(String fromWxid, String message, UserInteractionState state) {
|
|
||||||
|
private void handleProductOrderRegistration(String fromWxid, String message, UserInteractionState state) {
|
||||||
switch (state.getCurrentProductOrderStep()) {
|
switch (state.getCurrentProductOrderStep()) {
|
||||||
case STEP_ORDER_ID:
|
case STEP_ORDER_ID:
|
||||||
if (!message.matches("^\\d{10,20}$")) {
|
if (!message.matches("^\\d{10,20}$")) {
|
||||||
@@ -1255,8 +1143,7 @@ public class JDUtil {
|
|||||||
}
|
}
|
||||||
state.getCollectedFields().put("orderId", message);
|
state.getCollectedFields().put("orderId", message);
|
||||||
state.setCurrentProductOrderStep(STEP_PRODUCT_INFO);
|
state.setCurrentProductOrderStep(STEP_PRODUCT_INFO);
|
||||||
wxUtil.sendTextMessage(fromWxid,
|
wxUtil.sendTextMessage(fromWxid, "请输入商品信息(格式:商品名称-类型编号)\n类型对照:1-家电 2-数码 3-服饰\n示例:格力空调-1", 1, fromWxid);
|
||||||
"请输入商品信息(格式:商品名称-类型编号)\n类型对照:1-家电 2-数码 3-服饰\n示例:格力空调-1", 1, fromWxid);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case STEP_PRODUCT_INFO:
|
case STEP_PRODUCT_INFO:
|
||||||
@@ -1269,8 +1156,7 @@ public class JDUtil {
|
|||||||
state.getCollectedFields().put("skuType", productInfo[1]);
|
state.getCollectedFields().put("skuType", productInfo[1]);
|
||||||
|
|
||||||
state.setCurrentProductOrderStep(UserInteractionState.ProductOrderStep.STEP_RECIPIENT_INFO);
|
state.setCurrentProductOrderStep(UserInteractionState.ProductOrderStep.STEP_RECIPIENT_INFO);
|
||||||
wxUtil.sendTextMessage(fromWxid,
|
wxUtil.sendTextMessage(fromWxid, "请输入收件信息(格式:姓名-电话-地址)\n示例:张三-13812345678-北京市朝阳区", 1, fromWxid);
|
||||||
"请输入收件信息(格式:姓名-电话-地址)\n示例:张三-13812345678-北京市朝阳区", 1, fromWxid);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case STEP_RECIPIENT_INFO:
|
case STEP_RECIPIENT_INFO:
|
||||||
@@ -1292,8 +1178,7 @@ public class JDUtil {
|
|||||||
case STEP_REVIEW_CONFIRM:
|
case STEP_REVIEW_CONFIRM:
|
||||||
if ("确认".equals(message)) {
|
if ("确认".equals(message)) {
|
||||||
boolean success = saveFullProductOrder(state, fromWxid);
|
boolean success = saveFullProductOrder(state, fromWxid);
|
||||||
wxUtil.sendTextMessage(fromWxid,
|
wxUtil.sendTextMessage(fromWxid, success ? "✅ 订单登记成功!" : "❌ 保存失败,请联系管理员", 1, fromWxid);
|
||||||
success ? "✅ 订单登记成功!" : "❌ 保存失败,请联系管理员", 1, fromWxid);
|
|
||||||
state.reset();
|
state.reset();
|
||||||
} else {
|
} else {
|
||||||
state.setCurrentProductOrderStep(STEP_ORDER_ID);
|
state.setCurrentProductOrderStep(STEP_ORDER_ID);
|
||||||
@@ -1301,23 +1186,13 @@ public class JDUtil {
|
|||||||
}
|
}
|
||||||
break;
|
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 String buildConfirmMessage(UserInteractionState state) {
|
private boolean saveFullProductOrder(UserInteractionState state, String fromWxid) {
|
||||||
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 {
|
try {
|
||||||
ProductOrder order = new ProductOrder();
|
ProductOrder order = new ProductOrder();
|
||||||
order.setOrderId(state.getCollectedFields().get("orderId"));
|
order.setOrderId(state.getCollectedFields().get("orderId"));
|
||||||
@@ -1339,19 +1214,16 @@ public class JDUtil {
|
|||||||
logger.error("订单保存异常:{}", e.getMessage());
|
logger.error("订单保存异常:{}", e.getMessage());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getTypeDesc(String skuType) {
|
private String getTypeDesc(String skuType) {
|
||||||
return switch (skuType) {
|
return switch (skuType) {
|
||||||
case "1" -> "家电";
|
case "1" -> "家电";
|
||||||
case "2" -> "数码";
|
case "2" -> "数码";
|
||||||
case "3" -> "服饰";
|
case "3" -> "服饰";
|
||||||
default -> "未知类型";
|
default -> "未知类型";
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 定义一个内部类来存储用户交互状态
|
// 定义一个内部类来存储用户交互状态
|
||||||
@Getter
|
@Getter
|
||||||
@@ -1401,24 +1273,41 @@ public class JDUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 限流异常类(需自定义)
|
// 限流异常类(需自定义)
|
||||||
public static class RateLimitExceededException extends RuntimeException {
|
public static class RateLimitExceededException extends RuntimeException {
|
||||||
public RateLimitExceededException(String message) {
|
public RateLimitExceededException(String message) {
|
||||||
super(message);
|
super(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Setter
|
@Setter
|
||||||
@Getter
|
@Getter
|
||||||
public static class OrderInfo {
|
public static class OrderInfo {
|
||||||
private String skuName;
|
private String skuName;
|
||||||
private Long count;
|
private Long count;
|
||||||
private Long orderId;
|
private Long orderId;
|
||||||
private Date orderDate;
|
private Date orderDate;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 统计指标DTO
|
||||||
|
@Getter
|
||||||
|
@AllArgsConstructor
|
||||||
|
class OrderStats {
|
||||||
|
private long totalOrders; // 总订单数
|
||||||
|
private long validOrders; // 有效订单数(不含取消)
|
||||||
|
private long paidOrders; // 已付款订单
|
||||||
|
private double paidCommission; // 已付款佣金
|
||||||
|
private long pendingOrders; // 待付款订单
|
||||||
|
private double pendingCommission; // 待付款佣金
|
||||||
|
private long canceledOrders; // 已取消订单
|
||||||
|
private long completedOrders; // 已完成订单
|
||||||
|
private double completedCommission;// 已完成佣金
|
||||||
|
private long violations; // 违规订单数
|
||||||
|
private double violationCommission;// 违规佣金
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user