lhch2015 6 днів тому
батько
коміт
603856275e

+ 8 - 0
admin-ui/src/api/order/cloth.js

@@ -290,3 +290,11 @@ export function getOrderPayResult(data) {
     params: data
   })
 }
+
+// 获取运费设置
+export function getSendClothOrderPrice() {
+  return request({
+    url: '/mapi/system/configRecord/getConfigValueByKey?configKeys=wash_delivery_amount;wash_delivery_free',
+    method: 'get',
+  })
+}

+ 67 - 33
admin-ui/src/components/payStatusPopup/index.vue

@@ -24,32 +24,49 @@
           <div class="btn" @click="close">关闭</div>
         </div>
       </div>
-      <!-- 未支付 -->
-      <div v-if="type === 2">
-        <div class="icon">
-
+      <!-- 未支付 / 支付失败-->
+      <div v-if="type === 2 || type == 4">
+        <div class="icon" v-if="type == 2">
           <i class="el-icon-warning warning"></i>
         </div>
-        <div class="message">请支付后取衣</div>
-        <div class="cell">
+        <div class="icon" v-if="type == 4">
+          <i class="el-icon-error error"></i>
+        </div>
+        <div class="message" v-if="type == 2">请支付后取衣</div>
+        <div class="message" v-if="type == 4">{{ errorMessage }}</div>
+        <div class="cell" v-if="type == 2">
           <div class="label">需支付金额</div>
           <div class="amount_box">
             <span>¥</span>
             <span>{{ orderInfo.payAmount }}</span>
           </div>
         </div>
-        <div class="cell">
+        <div class="cell" style="position: relative;" v-if="type == 2 || !hideUser">
           <div class="label">支付方式</div>
           <el-radio-group v-model="payType" @input="changePayType">
             <el-radio-button :label="3">余额</el-radio-button>
             <el-radio-button :label="2">现金</el-radio-button>
             <el-radio-button :label="0">微信/支付宝</el-radio-button>
           </el-radio-group>
+          <span style="position: absolute;bottom: 0; margin-left: 100px; font-size: 12px; color: #f56c6c;" v-if="payType == 3 && appUserInfo.balance < orderInfo.payAmount">
+            余额不足,需要额外支付¥{{ handelAmount(orderInfo.payAmount - appUserInfo.balance) }}
+          </span>
+        </div>         
+        <div class="cell" style="margin-top: 20px;" v-if="payType == 3 && appUserInfo.balance < orderInfo.payAmount">
+          <div class="label">额外支付方式</div>
+          <el-radio-group v-model="otherPayType" @input="changeOtherPayType">
+            <el-radio :label="2">现金</el-radio>
+            <el-radio :label="0">微信/支付宝</el-radio>
+          </el-radio-group>
+        </div>
+        <div class="cell" v-if="otherPayType === 0">
+          <div class="label">付款码</div>
+          <el-input ref="autoOtherFocus" v-model="authCode" clearable placeholder="请选择付款码" />
         </div>
         <el-descriptions border direction="vertical" :column="3" :labelStyle="{ width: '140px' }" v-if="payType == '3'" style="margin: 0 30px">
           <el-descriptions-item label="用户" v-if="appUserInfo">{{ appUserInfo.realName }}</el-descriptions-item>
-          <el-descriptions-item label="当前余额(元)" v-if="appUserInfo">{{ handelAmount(appUserInfo.rechargeBalance + appUserInfo.giveBalance) }}</el-descriptions-item>
-          <el-descriptions-item label="支付后余额(元)" v-if="appUserInfo">{{ handelAmount(appUserInfo.rechargeBalance + appUserInfo.giveBalance - orderInfo.payAmount) }}</el-descriptions-item>
+          <el-descriptions-item label="当前余额(元)" v-if="appUserInfo">{{ handelAmount(appUserInfo.balance) }}</el-descriptions-item>
+          <el-descriptions-item label="支付后余额(元)" v-if="appUserInfo">{{ handelAmount(appUserInfo.balance - orderInfo.payAmount) }}</el-descriptions-item>
         </el-descriptions>
         <div class="cell" v-if="payType == 0">
           <div class="label">付款码</div>
@@ -57,8 +74,8 @@
           <el-input ref="autoFocus" v-model="authCode" clearable placeholder="请选择付款码" />
         </div>
         <div class="btn_box">
-          <div class="btn" style="color: #67c23a" @click="pay">确认支付</div>
-          <div class="line"></div>
+          <div class="btn" style="color: #67c23a" @click="pay" v-if="type == 2 || !hideUser">确认支付</div>
+          <div class="line" v-if="type == 2 || !hideUser"></div>
           <div class="btn" @click="close">关闭</div>
         </div>
       </div>
@@ -72,11 +89,9 @@
         <el-button type="primary" style="width: 70%; height: 40px; margin: 20px 15%" @click="close" v-if="showPaySuccessBtn">已确认支付</el-button>
       </div>
       <!-- 支付失败 -->
-      <div v-if="type == 4">
-        <div class="icon">
-          <i class="el-icon-error error"></i>
-        </div>
-        <div class="message">{{ errorMessage }}</div>
+      <!-- <div v-if="type == 4">
+        
+       
         <div class="cell" v-if="!hideUser">
           <div class="label">支付方式</div>
           <el-radio-group v-model="payType" @input="changePayType">
@@ -87,12 +102,11 @@
         </div>
         <el-descriptions border direction="vertical" :column="3" :labelStyle="{ width: '140px' }" v-if="payType == '3' && !hideUser" style="margin: 0 30px">
           <el-descriptions-item label="用户" v-if="appUserInfo">{{ appUserInfo.realName }}</el-descriptions-item>
-          <el-descriptions-item label="当前余额(元)" v-if="appUserInfo">{{ appUserInfo.rechargeBalance + appUserInfo.giveBalance }}</el-descriptions-item>
-          <el-descriptions-item label="支付后余额(元)" v-if="appUserInfo">{{ appUserInfo.rechargeBalance + appUserInfo.giveBalance - orderInfo.payAmount }}</el-descriptions-item>
+          <el-descriptions-item label="当前余额(元)" v-if="appUserInfo">{{ appUserInfo.balance }}</el-descriptions-item>
+          <el-descriptions-item label="支付后余额(元)" v-if="appUserInfo">{{ appUserInfo.balance - orderInfo.payAmount }}</el-descriptions-item>
         </el-descriptions>
         <div class="cell" v-if="payType == 0 && !hideUser">
           <div class="label">付款码</div>
-          <!-- @change="handleQuery" -->
           <el-input ref="autoFocus" v-model="authCode" clearable placeholder="请选择付款码" />
         </div>
         <div class="btn_box">
@@ -100,7 +114,7 @@
           <div class="line" v-if="!hideUser"></div>
           <div class="btn" @click="close">关闭</div>
         </div>
-      </div>
+      </div> -->
       <!-- 支付成功打印小票 -->
       <div v-if="type === 6">
         <div class="icon">
@@ -162,7 +176,8 @@ export default {
       time: '',
       showPaySuccessBtn: false,
       resultCount: 0,
-      errorMessage: ''
+      errorMessage: '',
+      otherPayType: 2
     }
   },
 
@@ -184,6 +199,7 @@ export default {
 
   methods: {
     handelAmount(e) {
+      if (e < 0) return 0
       return e.toFixed(2)
     },
     openSelected(info) {
@@ -209,8 +225,9 @@ export default {
       }
       console.log(this.type, appUserInfo)
       if (appUserInfo) {
-          this.appUserInfo = appUserInfo
-        }
+        appUserInfo.balance = appUserInfo.rechargeBalance + appUserInfo.giveBalance + appUserInfo.welfareBalance
+        this.appUserInfo = appUserInfo
+      }
       if (type == 0) {
         //微信支付宝支付
         this.payType = 0
@@ -242,6 +259,7 @@ export default {
         this.payType = 3
         this.showPaySuccessBtn = false
         if (appUserInfo) {
+          appUserInfo.balance = appUserInfo.rechargeBalance + appUserInfo.giveBalance + appUserInfo.welfareBalance
           this.appUserInfo = appUserInfo
         }
         console.log('aasss', this.appUserInfo)
@@ -377,6 +395,7 @@ export default {
       getMemberInfoById({
         appUserId: id
       }).then((response) => {
+        response.data.balance = response.data.rechargeBalance + response.data.giveBalance + response.data.welfareBalance
         this.appUserInfo = response.data
       })
     },
@@ -389,34 +408,49 @@ export default {
       }
     },
 
+    changeOtherPayType() {
+      if (this.otherPayType == 0) {
+        this.$nextTick((_) => {
+          this.$refs.autoOtherFocus.focus()
+        })
+      }
+    },
+
     handleQuery(e, event) {
       console.log(event)
       console.log(this.authCode)
     },
 
     pay() {
-      if (this.payType == 0 && !this.authCode) {
+      if ((this.payType == 0 || this.otherPayType == 0) && !this.authCode) {
         this.type = 4
         this.errorMessage = '请先扫码'
         this.authCode = ''
         this.changePayType()
         return
       }
-      if (this.payType == 3 && this.appUserInfo.rechargeBalance + this.appUserInfo.giveBalance < this.orderInfo.payAmount) {
-        this.errorMessage = '余额不足'
-        this.type = 4
-        this.authCode = ''
-        this.changePayType()
-        return
-      }
+      // if (this.payType == 3 && this.appUserInfo.balance < this.orderInfo.payAmount) {
+      //   this.errorMessage = '余额不足'
+      //   this.type = 4
+      //   this.authCode = ''
+      //   this.changePayType()
+      //   return
+      // }
       this.type = 3
-      clothOrderPay({
+      // 
+      let params = {
         appUserId: this.orderInfo.appUserId,
         payType: this.payType,
         authCode: this.authCode,
         orderNo: this.orderInfo.orderNo,
         payAmount: this.orderInfo.payAmount
-      })
+      }
+      if (this.payType == 3 && this.appUserInfo.balance < this.orderInfo.payAmount) {
+        params.memberPayAmount = this.appUserInfo.balance
+        params.payType = 8
+        params.otherPayType = this.otherPayType
+      }
+      clothOrderPay(params)
         .then((res) => {
           console.log('支付结果', res)
           if (res) {

+ 28 - 4
admin-ui/src/views/order/cloth/collectCloth.vue

@@ -473,7 +473,7 @@
                                 <span style="margin-left: 5px">元 {{ clothSpecialForm.hedgingPrice && clothSpecialForm.isHedging ? '(¥' + clothSpecialForm.hedgingPrice * 0.01 + ')' : '' }}</span>
                             </el-form-item>
                             <template v-for="(item, index) in clothSpecialForm.clothSpeeds">
-                                <el-form-item v-if="item.isDefault != 'Y' && selectClothItemIndex > -1">
+                                <el-form-item v-if="item.isDefault != 'Y' && selectClothItemIndex > -1" :key="index">
                                     <el-checkbox v-model="item.isSelect" @change="changeClothSpeedSelect(index)" style="width: 100px" :disabled="clothSpecialForm.isHedging && index == 1">
                                         <span v-if="item.isSelect && orderClothItemDTOS[selectClothItemIndex]">{{ item.name + '(¥' + orderClothItemDTOS[selectClothItemIndex].defaultPrice * (item.multiple - 1) + ')' }}</span>
                                         <span v-else>{{ item.name }}</span>
@@ -492,7 +492,9 @@
         </el-dialog>
 
         <el-dialog title="收银" :visible.sync="confirmPayOpen" width="90%" :before-close="handleClose" destroy-on-close append-to-body>
-            <CashCloth ref="cashCloth" :orderForm="orderForm" :orderClothItemDTOS="orderClothItemDTOS" :appUserInfo="appUserInfo" :clothSpeeds="clothSpeeds" :deductCouponVOS="deductCouponVOS" :discountCouponVOS="discountCouponVOS" @onPaySuccess="onPaySuccess" @initOrderList="initOrderList" @confirm="handelPaySuccess"/>
+            <CashCloth ref="cashCloth" :orderForm="orderForm" :orderClothItemDTOS="orderClothItemDTOS" :appUserInfo="appUserInfo" :clothSpeeds="clothSpeeds" 
+                       :deductCouponVOS="deductCouponVOS" :discountCouponVOS="discountCouponVOS" :deliveryFree="deliveryFree" :deliveryAmount="deliveryAmount" 
+                       @onPaySuccess="onPaySuccess" @initOrderList="initOrderList" @confirm="handelPaySuccess"/>
         </el-dialog>
 
         <!-- 拍照上传 -->
@@ -562,7 +564,7 @@ import CashCloth from './component/cashCloth'
 import payStatusPopup from '@/components/payStatusPopup'
 import { listClothItem, getClothItem, delClothItem, addClothItem, updateClothItem, updateClothItemStatus } from '@/api/order/clothItem'
 import { uploadBase64OSS, uploadOSS, saveOrderClothPics } from '@/api/upload'
-import { getOrderStatusByOrderNo } from '../../../api/order/cloth'
+import { getOrderStatusByOrderNo, getSendClothOrderPrice } from '../../../api/order/cloth'
 
 import { allList } from '@/api/core/clothType'
 import { allClothItem } from '../../../api/core/clothItem'
@@ -691,7 +693,9 @@ export default {
             collectClothDetail: null,
             showAdvanceOrder: false,
             advanceOrderList: [],
-            confirmLoading: false
+            confirmLoading: false,
+            deliveryAmount: 0,
+            deliveryFree: []
         }
     },
     mounted() {
@@ -709,8 +713,28 @@ export default {
         allClothSpeed().then((speedRes) => {
             this.clothSpeeds = speedRes.data
         })
+        this.getDeliveryPrice()
     },
     methods: {
+        getDeliveryPrice() {
+            getSendClothOrderPrice().then((res) => {
+                this.deliveryAmount = Number(res.data.wash_delivery_amount)
+                let free = res.data.wash_delivery_free.split(';')
+                console.log(free)
+                let frees = []
+                for (let i = 0; i < free.length; i++) {
+                    let obj = {}
+                    let a = free[i].split(':')
+                    let b = a[0].split('-')
+                    obj.value = a[1]
+                    obj.min = b[0]
+                    obj.max = b[1]
+                    frees.push(obj)
+                }
+                console.log(frees)
+                this.deliveryFree = frees
+            })
+        },
         // 展示附件数量
         getFlawCount(e) {
             let count = 0

+ 78 - 17
admin-ui/src/views/order/cloth/component/cashCloth.vue

@@ -31,6 +31,10 @@
                                     <span class="label">配送费用:</span>
                                     <span class="value">¥{{ calculateDeliveryPrice() }}</span>
                                 </div>
+                                <div class="info-item">
+                                    <span class="label">运费优惠:</span>
+                                    <span class="value discount">-¥{{ deliveryFreeAmount }}</span>
+                                </div>
                                 <div class="info-item">
                                     <span class="label">优惠金额:</span>
                                     <span class="value discount">-¥{{ calculateTotalDiscountAmount() }}</span>
@@ -50,7 +54,7 @@
                                 </div>
                                 <div class="info-item">
                                     <span class="label">可用余额:</span>
-                                    <span class="value balance">¥{{ Math.round((appUserInfo.rechargeBalance + appUserInfo.giveBalance + appUserInfo.welfareBalance) * 100) / 100  }}</span>
+                                    <span class="value balance">¥{{ Math.round((getBalance()) * 100) / 100  }}</span>
                                 </div>
                             </div>
                         </el-card>
@@ -70,6 +74,21 @@
                                 </el-radio-group>
                             </div>
 
+                            <span style="margin-left: 10px; font-size: 12px; color: #f56c6c;" v-if="orderForm.payType == 3 && getOtherPayPrice() > 0">余额不足,需要额外支付¥{{ Math.round((getOtherPayPrice()) * 100) / 100 }}</span>
+                            <div v-if="orderForm.payType == 3 && getOtherPayPrice() > 0" style="margin-top: 10px; margin-left: 10px;">
+                                <div class="card-header" style="margin-bottom: 10px">
+                                    <span class="title" style="font-size: 15px;">额外支付方式</span>
+                                </div>
+                                <el-radio-group v-model="otherPayType" @input="changeOtherPayType">
+                                    <el-radio :label="2">现金</el-radio>
+                                    <el-radio :label="0">微信/支付宝</el-radio>
+                                </el-radio-group>
+                            </div>
+                             <!-- 扫码支付输入框 -->
+                             <div class="scan-input" v-if="otherPayType == 0 && getOtherPayPrice() > 0">
+                                <el-input ref="authOtherCode" v-model="orderForm.authCode" placeholder="请扫描客户付款码" prefix-icon="el-icon-camera" clearable autofocus> </el-input>
+                            </div>
+
                             <!-- 扫码支付输入框 -->
                             <div class="scan-input" v-if="orderForm.payType == '0'">
                                 <el-input ref="autoFocus" v-model="orderForm.authCode" placeholder="请扫描客户付款码" prefix-icon="el-icon-camera" clearable autofocus> </el-input>
@@ -391,13 +410,23 @@ export default {
             //可选择的折扣券
             type: Array,
             default: []
+        },
+        deliveryFree: {
+            //运费优惠
+            type: Array,
+            default: []
+        }, 
+        deliveryAmount: {
+            //运费
+            type: Number,
+            default: 0
         }
     },
     data() {
         return {
             dialogLoading: false,
             setCouponOpen: false, //是否选择优惠券
-
+            otherPayType: 2,
             loadingText: '',
             confirmCouponTabIndex: '0',
             confirmDeductTabIndex: '0',
@@ -435,7 +464,8 @@ export default {
                         trigger: 'change'
                     }
                 ]
-            }
+            },
+            deliveryFreeAmount: 0
         }
     },
     mounted() {
@@ -455,6 +485,23 @@ export default {
                 })
             }
         },
+
+        changeOtherPayType() {
+            if (this.otherPayType == 0) {
+                this.orderForm.authOtherCode = ''
+                this.$nextTick((_) => {
+                    this.$refs.autoFocus.focus()
+                })
+            }
+        },
+        getOtherPayPrice() {
+            let payAmount =  this.calculateTotalPrice() + this.calculateDeliveryPrice() - this.calculateTotalDiscountAmount()
+            console.log(payAmount, this.getBalance())
+            return payAmount - this.getBalance()
+        },
+        getBalance() {
+            return this.appUserInfo.rechargeBalance + this.appUserInfo.giveBalance + this.appUserInfo.welfareBalance
+        },
         // 处理现金金额
         handelPrice(e) {
             return Math.round(e * 100) / 100
@@ -486,17 +533,29 @@ export default {
             return specialPrice
         },
         calculateDeliveryPrice() {
-            if (this.calculateTotalPrice() >= 100) {
-                return 0
+            let totalPrice = this.calculateTotalPrice()
+            let freeAmount = 0
+            for (let i = 0; i < this.deliveryFree.length; i++) {
+                if (totalPrice > this.deliveryFree[i].min && totalPrice <= this.deliveryFree[i].max) {
+                    freeAmount = this.deliveryFree[i].value
+                    break
+                }
             }
+            // if (this.calculateTotalPrice() >= 100) {
+            //     return 0
+            // }
             var delivery = 0
-            if (this.orderForm.takeClothWay && this.orderForm.takeClothWay == '1') {
-                delivery += 10
+            if (this.orderForm.isAppointment === 'Y') {
+                delivery += this.deliveryAmount
             }
-            if (this.orderForm.sendClothWay && this.orderForm.sendClothWay == '1') {
-                delivery += 10
-            }
-            return delivery
+            // if (this.orderForm.takeClothWay && this.orderForm.takeClothWay == '1') {
+            //     delivery += this.deliveryAmount
+            // }
+            // if (this.orderForm.sendClothWay && this.orderForm.sendClothWay == '1') {
+            //     delivery += this.deliveryAmount
+            // }
+            this.deliveryFreeAmount = freeAmount
+            return delivery - freeAmount
         },
         //计算当前所有优惠金额
         calculateTotalDiscountAmount() {
@@ -851,6 +910,14 @@ export default {
 
                     params.sendClothWay = this.orderForm.sendClothWay;
 
+                    if (this.orderForm.payType == 3) {
+                        if (this.getOtherPayPrice() > 0) {
+                            params.memberPayAmount = this.getBalance()
+                            params.payType = 8
+                            params.otherPayType = this.otherPayType
+                        }
+                    }
+
                     // 修改 loading 配置,只覆盖表单区域
                     const loading = this.$loading({
                         target: '.cash-container', // 指定 loading 覆盖的目标元素
@@ -860,12 +927,6 @@ export default {
                         background: 'rgba(0, 0, 0, 0.7)'
                     });
 
-                    console.log(params)
-                    console.log(JSON.stringify(params))
-                    
-                    console.log(this.orderForm)
-                    console.log(JSON.stringify(this.orderForm))
-
                     collectCloth(params)
                         .then(res => {
                             loading.close();

+ 1 - 0
admin-ui/src/views/order/cloth/orderList.vue

@@ -169,6 +169,7 @@
                                 <template v-if="orderDetail.payType == '1'">支付宝</template>
                                 <template v-if="orderDetail.payType == '2'">现金</template>
                                 <template v-if="orderDetail.payType == '3'">余额</template>
+                                <template v-if="orderDetail.payType == '8'">组合支付</template>
                             </span>
                             ({{ orderDetail.payAmount }}元)
                         </el-descriptions-item>

+ 2 - 1
admin-ui/src/views/order/cloth/sendCloth.vue

@@ -612,7 +612,8 @@ export default {
                 0: '微信支付',
                 1: '支付宝',
                 2: '现金支付',
-                3: '余额支付'
+                3: '余额支付',
+                8: '组合支付'
             }
             return texts[type] || '其他'
         },