Răsfoiți Sursa

refactor: clean up review logic (remove unused var, fix computed, add log separators)

iwt 1 săptămână în urmă
părinte
comite
8598920555

+ 5 - 2
cfc-backend/src/main/java/com/etotem/cfc/service/ProductOrderService.java

@@ -1372,8 +1372,7 @@ public class ProductOrderService {
         // ===== 1. 修改价格 =====
         Integer newUnitPrice = params.get("unitPrice") != null ? ((Number) params.get("unitPrice")).intValue() : null;
         if (newUnitPrice != null && newUnitPrice >= 0) {
-            int oldPrice = order.getUnitPrice() != null ? order.getUnitPrice() : 0;
-            int oldTotal = order.getTotalAmount() != null ? order.getTotalAmount() : 0;
+        int oldTotal = order.getTotalAmount() != null ? order.getTotalAmount() : 0;
             order.setUnitPrice(newUnitPrice);
             int newTotal = newUnitPrice * (order.getQuantity() != null ? order.getQuantity() : 1);
             order.setTotalAmount(newTotal);
@@ -1382,6 +1381,7 @@ public class ProductOrderService {
             order.setMoneyAmount(Math.max(moneyAmount, 0));
             hasChange = true;
             if (oldTotal != newTotal) {
+                if (changeLog.length() > 0) changeLog.append(";");
                 changeLog.append(String.format("价格:%d元 → %d元", oldTotal / 100, newTotal / 100));
             }
         }
@@ -1409,6 +1409,7 @@ public class ProductOrderService {
                 int oldMethod = order.getDeliveryMethod() != null ? order.getDeliveryMethod() : 1;
                 order.setDeliveryMethod(newDeliveryMethod);
                 hasChange = true;
+                if (changeLog.length() > 0) changeLog.append(";");
                 changeLog.append(String.format("配送方式:%d → %d", oldMethod, newDeliveryMethod));
             }
         }
@@ -1447,6 +1448,7 @@ public class ProductOrderService {
                 familyCouponMapper.insert(fc);
             }
             hasChange = true;
+            if (changeLog.length() > 0) changeLog.append(";");
             changeLog.append(String.format("新增优惠券:减免%d元", couponValue / 100));
         }
 
@@ -1473,6 +1475,7 @@ public class ProductOrderService {
                 productOrderGiftMapper.insert(orderGift);
 
                 hasChange = true;
+                if (changeLog.length() > 0) changeLog.append(";");
                 changeLog.append(String.format("新增赠品:%s x%d",
                     giftProductName != null ? giftProductName : "赠品", quantity));
             }

+ 5 - 8
cfc-frontend/pages/vendor/order-review/order-review.vue

@@ -146,6 +146,11 @@ export default {
       this.loadDetail()
     }
   },
+  computed: {
+    giftCount() {
+      return this.giftList.length
+    }
+  },
   methods: {
     loadDetail() {
       this.loading = true
@@ -153,11 +158,6 @@ export default {
         this.loading = false
         if (res.code === 200 && res.data) {
           this.order = res.data
-          var self = this
-          // 恢复已有赠品列表
-          this.$nextTick(function () {
-            // 后端目前不返回 giftList,前端从 remark 解析或初始为空
-          })
         } else {
           uni.showToast({ title: res.message || '加载失败', icon: 'none' })
         }
@@ -253,9 +253,6 @@ export default {
     formatPrice(value) {
       if (!value && value !== 0) return '-'
       return (value / 100).toFixed(2)
-    },
-    get giftCount() {
-      return this.giftList.length
     }
   }
 }