From f9cfef17ea10d5893949283f791f99121bbe0549 Mon Sep 17 00:00:00 2001 From: quyixiao <2621048238@qq.com> Date: Mon, 17 Nov 2025 08:49:59 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/entity/vv/VvTradeOrderEntity.java | 43 +++++++++++++------ .../entity/vv/VvTradeOrderLineEntity.java | 21 ++++++++- .../java/com/test/xxx/MysqlMain_update.java | 4 +- .../java/com/heyu/api/jsapi/JsapiPrepay.java | 2 +- .../api/controller/vv/AppOrderController.java | 19 ++++---- 5 files changed, 65 insertions(+), 24 deletions(-) diff --git a/api-mapper/src/main/java/com/heyu/api/data/entity/vv/VvTradeOrderEntity.java b/api-mapper/src/main/java/com/heyu/api/data/entity/vv/VvTradeOrderEntity.java index d1bc49b..b28f6d3 100644 --- a/api-mapper/src/main/java/com/heyu/api/data/entity/vv/VvTradeOrderEntity.java +++ b/api-mapper/src/main/java/com/heyu/api/data/entity/vv/VvTradeOrderEntity.java @@ -10,7 +10,7 @@ import java.util.Date;import java.util.Date; /** *购物车 * @author quyixiao -* @since 2025-11-09 +* @since 2025-11-17 */ @Data @@ -29,7 +29,7 @@ private static final long serialVersionUID = 1L; public final static String buyer_phone = CLASS_NAME + "buyer_phone"; // 买家手机号 public final static String buyer_name = CLASS_NAME + "buyer_name"; // 买家名 public final static String buyer_weixin = CLASS_NAME + "buyer_weixin"; // 买家微信 - public final static String all_price = CLASS_NAME + "all_price"; // 总价 + public final static String pay_amount = CLASS_NAME + "pay_amount"; // 支付金额 public final static String refund_amount = CLASS_NAME + "refund_amount"; // 退款金额 public final static String refund_count = CLASS_NAME + "refund_count"; // 退货数量 public final static String buyer_id = CLASS_NAME + "buyer_id"; // 买家id @@ -48,6 +48,7 @@ private static final long serialVersionUID = 1L; public final static String trade_info = CLASS_NAME + "trade_info"; // 交易信息 public final static String transaction_id = CLASS_NAME + "transaction_id"; // 事务id public final static String buyer_address_id = CLASS_NAME + "buyer_address_id"; // 买家地址id + public final static String promotion_price = CLASS_NAME + "promotion_price"; // 促销价 // @TableId(value = "id", type = IdType.AUTO) private Long id; @@ -65,8 +66,8 @@ private static final long serialVersionUID = 1L; private String buyerName; //买家微信 private String buyerWeixin; - //总价 - private BigDecimal allPrice; + //支付金额 + private BigDecimal payAmount; //退款金额 private BigDecimal refundAmount; //退货数量 @@ -103,6 +104,8 @@ private static final long serialVersionUID = 1L; private String transactionId; //买家地址id private Long buyerAddressId; + //促销价 + private BigDecimal promotionPrice; /** * * @return @@ -224,18 +227,18 @@ private static final long serialVersionUID = 1L; } /** - * 总价 + * 支付金额 * @return */ - public BigDecimal getAllPrice() { - return allPrice; + public BigDecimal getPayAmount() { + return payAmount; } /** - * 总价 - * @param allPrice + * 支付金额 + * @param payAmount */ - public void setAllPrice(BigDecimal allPrice) { - this.allPrice = allPrice; + public void setPayAmount(BigDecimal payAmount) { + this.payAmount = payAmount; } /** @@ -508,6 +511,21 @@ private static final long serialVersionUID = 1L; this.buyerAddressId = buyerAddressId; } + /** + * 促销价 + * @return + */ + public BigDecimal getPromotionPrice() { + return promotionPrice; + } + /** + * 促销价 + * @param promotionPrice + */ + public void setPromotionPrice(BigDecimal promotionPrice) { + this.promotionPrice = promotionPrice; + } + @Override public String toString() { return "VvTradeOrderEntity{" + @@ -519,7 +537,7 @@ private static final long serialVersionUID = 1L; ",buyerPhone=" + buyerPhone + ",buyerName=" + buyerName + ",buyerWeixin=" + buyerWeixin + - ",allPrice=" + allPrice + + ",payAmount=" + payAmount + ",refundAmount=" + refundAmount + ",refundCount=" + refundCount + ",buyerId=" + buyerId + @@ -538,6 +556,7 @@ private static final long serialVersionUID = 1L; ",tradeInfo=" + tradeInfo + ",transactionId=" + transactionId + ",buyerAddressId=" + buyerAddressId + + ",promotionPrice=" + promotionPrice + "}"; } } \ No newline at end of file diff --git a/api-mapper/src/main/java/com/heyu/api/data/entity/vv/VvTradeOrderLineEntity.java b/api-mapper/src/main/java/com/heyu/api/data/entity/vv/VvTradeOrderLineEntity.java index 7e2d358..f9d1008 100644 --- a/api-mapper/src/main/java/com/heyu/api/data/entity/vv/VvTradeOrderLineEntity.java +++ b/api-mapper/src/main/java/com/heyu/api/data/entity/vv/VvTradeOrderLineEntity.java @@ -10,7 +10,7 @@ import java.util.Date;import java.util.Date; /** *购物车 * @author quyixiao -* @since 2025-11-16 +* @since 2025-11-17 */ @Data @@ -93,6 +93,7 @@ private static final long serialVersionUID = 1L; public final static String reject_sign_receipt_reason = CLASS_NAME + "reject_sign_receipt_reason"; // 拒绝签收原因 public final static String reject_sign_receipt_features = CLASS_NAME + "reject_sign_receipt_features"; // 拒绝签收的信息 public final static String close_reason = CLASS_NAME + "close_reason"; // 关闭原因 + public final static String pay_amount = CLASS_NAME + "pay_amount"; // 实付金额 // @TableId(value = "id", type = IdType.AUTO) private Long id; @@ -238,6 +239,8 @@ private static final long serialVersionUID = 1L; private String rejectSignReceiptFeatures; //关闭原因 private String closeReason; + //实付金额 + private BigDecimal payAmount; /** * * @return @@ -1318,6 +1321,21 @@ private static final long serialVersionUID = 1L; this.closeReason = closeReason; } + /** + * 实付金额 + * @return + */ + public BigDecimal getPayAmount() { + return payAmount; + } + /** + * 实付金额 + * @param payAmount + */ + public void setPayAmount(BigDecimal payAmount) { + this.payAmount = payAmount; + } + @Override public String toString() { return "VvTradeOrderLineEntity{" + @@ -1393,6 +1411,7 @@ private static final long serialVersionUID = 1L; ",rejectSignReceiptReason=" + rejectSignReceiptReason + ",rejectSignReceiptFeatures=" + rejectSignReceiptFeatures + ",closeReason=" + closeReason + + ",payAmount=" + payAmount + "}"; } } \ No newline at end of file diff --git a/api-mapper/src/test/java/com/test/xxx/MysqlMain_update.java b/api-mapper/src/test/java/com/test/xxx/MysqlMain_update.java index 1a845f9..4597df9 100644 --- a/api-mapper/src/test/java/com/test/xxx/MysqlMain_update.java +++ b/api-mapper/src/test/java/com/test/xxx/MysqlMain_update.java @@ -49,9 +49,9 @@ public class MysqlMain_update { List list = new ArrayList(); - list.add(new TablesBean("vv_trade_order_line_status_log")); + list.add(new TablesBean("vv_trade_order_line")); - //list.add(new TablesBean("vv_trade_order")); + list.add(new TablesBean("vv_trade_order")); Map map = MysqlUtil2ShowCreateTable.getComments(); diff --git a/api-third/src/main/java/com/heyu/api/jsapi/JsapiPrepay.java b/api-third/src/main/java/com/heyu/api/jsapi/JsapiPrepay.java index 0e353df..b34c5c3 100644 --- a/api-third/src/main/java/com/heyu/api/jsapi/JsapiPrepay.java +++ b/api-third/src/main/java/com/heyu/api/jsapi/JsapiPrepay.java @@ -235,7 +235,7 @@ public class JsapiPrepay { request.amount = new AmountReq(); Long refundAmount = BigDecimalUtil.multiply(vvReverseOrderEntity.getRefundAmount(), new BigDecimal(100)).longValue(); - Long tradeOrderAmount = BigDecimalUtil.multiply(vvTradeOrderEntity.getAllPrice(), new BigDecimal(100)).longValue(); + Long tradeOrderAmount = BigDecimalUtil.multiply(vvTradeOrderEntity.getPromotionPrice(), new BigDecimal(100)).longValue(); request.amount.refund =refundAmount; // 【退款金额】 退款金额,币种的最小单位,只能为整数,不能超过原订单支付金额。 diff --git a/api-web/api-interface/src/main/java/com/heyu/api/controller/vv/AppOrderController.java b/api-web/api-interface/src/main/java/com/heyu/api/controller/vv/AppOrderController.java index e90949f..3ce2aa7 100644 --- a/api-web/api-interface/src/main/java/com/heyu/api/controller/vv/AppOrderController.java +++ b/api-web/api-interface/src/main/java/com/heyu/api/controller/vv/AppOrderController.java @@ -166,8 +166,6 @@ public class AppOrderController { @RequestMapping("/add") public R add(@RequestBody VvTradeOrderDTO vvOrderRequest) { List vvTradeOrderLineEntityList = new ArrayList<>(); - BigDecimal allPrice = BigDecimal.ZERO; - int allNum = 0; List skuIds = new ArrayList<>(); for (VvTradeOrderLineDTO vvTradeOrderLineDTO : vvOrderRequest.getVvTradeOrderLineDTOList()) { @@ -212,6 +210,7 @@ public class AppOrderController { } Map productNumMap = new HashMap<>(); + VvBuyerAddressEntity vvBuyerAddress = vvBuyerAddressDao.selectVvBuyerAddressById(vvOrderRequest.getBuyerAddressId()); for (VvTradeOrderLineDTO vvTradeOrderLineDTO : vvOrderRequest.getVvTradeOrderLineDTOList()) { VvSkuEntity vvSkuEntity = skuEntityMap.get(vvTradeOrderLineDTO.getSkuId()); @@ -226,8 +225,6 @@ public class AppOrderController { allNum = allNum + vvTradeOrderLineDTO.getNum(); - allPrice = BigDecimalUtil.add(BigDecimalUtil.multiply(vvSkuEntity.getPromotionPrice(), new BigDecimal(vvTradeOrderLineDTO.getNum())), allPrice); - List vvSkuPropertyValueEntities = vvSkuPropertyValueMap.get(vvTradeOrderLineDTO.getSkuId()); VvProductEntity vvProduct = vvProductMap.get(vvSkuEntity.getProductId()); @@ -265,6 +262,7 @@ public class AppOrderController { vvTradeOrderLineEntity.setBuyerId(vvOrderRequest.getBuyerId()); vvTradeOrderLineEntity.setBuyerAddressId(vvOrderRequest.getBuyerAddressId()); vvTradeOrderLineEntity.setBatchNum(vvTradeOrderLineDTO.getNum()); + vvTradeOrderLineEntity.setPayAmount(vvSkuEntity.getPromotionPrice()); vvTradeOrderLineEntityList.add(vvTradeOrderLineEntity); } } @@ -274,7 +272,7 @@ public class AppOrderController { //创建时间 vvTradeOrderEntity.setCreateTime(new Date()); vvTradeOrderEntity.setModifyTime(new Date()); - vvTradeOrderEntity.setNum(allNum); + vvTradeOrderEntity.setNum(vvTradeOrderLineEntityList.size()); vvTradeOrderEntity.setBuyerPhone(vvBuyerEntity.getBuyerPhone()); vvTradeOrderEntity.setBuyerName(vvBuyerEntity.getBuyerName()); vvTradeOrderEntity.setBuyerWeixin(vvBuyerEntity.getBuyerWeixin()); @@ -285,11 +283,17 @@ public class AppOrderController { vvTradeOrderEntity.setCity(vvBuyerAddress.getCity()); vvTradeOrderEntity.setDistrict(vvBuyerAddress.getDistrict()); vvTradeOrderEntity.setBuyerDetailAddress(vvBuyerAddress.getDetail()); - vvTradeOrderEntity.setAllPrice(allPrice); + + + BigDecimal tradeOrderPromotionPrice = SanUtils.sum(vvTradeOrderLineEntityList, VvTradeOrderLineEntity::getPromotionPrice); + vvTradeOrderEntity.setPromotionPrice(tradeOrderPromotionPrice); + vvTradeOrderEntity.setBuyerId(vvOrderRequest.getBuyerId()); vvTradeOrderEntity.setCreateTimestamp(System.currentTimeMillis()); vvTradeOrderEntity.setModifyTimestamp(System.currentTimeMillis()); vvTradeOrderEntity.setBuyerAddressId(vvOrderRequest.getBuyerAddressId()); + BigDecimal tradePayAmount = SanUtils.sum(vvTradeOrderLineEntityList, VvTradeOrderLineEntity::getPayAmount); + vvTradeOrderEntity.setPayAmount(tradePayAmount); vvTradeOrderDao.insertVvTradeOrder(vvTradeOrderEntity); for (VvTradeOrderLineEntity tradeOrderLineEntity : vvTradeOrderLineEntityList) { @@ -303,9 +307,8 @@ public class AppOrderController { for (Map.Entry map : productNumMap.entrySet()) { vvProductDao.updateShowSaleCountAndSaleCount(map.getValue(), map.getValue(), map.getKey()); } - DirectAPIv3JsapiPrepayResponse jsapiPrepayResponse = jsapiPrepay.prePay(vvTradeOrderEntity.getId(), - BigDecimalUtil.multiply(vvTradeOrderEntity.getAllPrice(), new BigDecimal(100)).longValue(), + BigDecimalUtil.multiply(vvTradeOrderEntity.getPayAmount(), new BigDecimal(100)).longValue(), vvBuyerEntity.getOpenid() );