dct 7 mesi fa
parent
commit
b2a8194127

+ 6 - 6
src/api/ticketPricePlan.js

@@ -2,22 +2,22 @@ import http from '@/utils/request'
 
 // 票种价格方案
 export function addTicketPricePlan (params) {
-  return http.post('ticketpriceplan/add', params)
+  return http.post('/admin/ticketSaleCalendar/add', { data: params })
 }
 
 export function getTicketPricePlanList (params) {
-  return http.post('ticketpriceplan/list', params)
+  return http.post('ticketpriceplan/list', { data: params })
 }
 export function getPricePlan (params) {
-  return http.post('ticketpriceplan/getPricePlan', params)
+  return http.post('/admin/ticketSaleCalendar/list', { data: params })
 }
 export function setPricePlan (params) {
-  return http.post('ticketpriceplan/setPricePlan', params)
+  return http.post('ticketpriceplan/setPricePlan', { data: params })
 }
 export function updateTicketPricePlan (params) {
-  return http.post('ticketpriceplan/update', params)
+  return http.post('ticketpriceplan/update', { data: params })
 }
 
 export function deleteTicketPricePlan (id) {
-  return http.delete(`ticketpriceplan/${id}`)
+  return http.post('/admin/ticketSaleCalendar/delete', { data: { idList: [id] } })
 }

+ 11 - 6
src/pages/ticketSetting/ticket.vue

@@ -128,6 +128,13 @@
             >
               编辑
             </el-link>
+            <el-link
+              type="primary"
+              size="small"
+              @click="showDialog('priceCalendar', scope.row)"
+            >
+              价格日历
+            </el-link>
             <br>
             <el-link
               type="primary"
@@ -179,7 +186,6 @@
 <script>
 import moment from 'moment'
 import { getTicketTypeList, deleteTicket, getScenic, updateTicket, listInvoiceSales } from '@/api/ticketType'
-import { getTicketPricePlanList } from '@/api/ticketPricePlan'
 import { getTicketTypeTagList } from '@/api/ticketTypeTag'
 import { getMemberType } from '@/api/member'
 import ElDialog from '@/components/Dialog'
@@ -247,11 +253,6 @@ export default {
         this.InvoiceSeller = res?.data
       })
     },
-    getTicketPricePlanList () {
-      getTicketPricePlanList({}).then(res => {
-        this.ticketPricePlanList = res.list
-      })
-    },
     getTicketTagList () {
       getTicketTypeTagList({}).then(res => {
         this.ticketTagList = res.children
@@ -264,6 +265,10 @@ export default {
       })
     },
     showDialog (type, item) {
+      if (type === 'priceCalendar') {
+        this.$refs.priceCalendar.show(item)
+        return
+      }
       this.dialogType = type
       this.curItem = item
       this.dialogVisible = true

+ 93 - 81
src/pages/ticketSetting/ticket/PriceCalendar.vue

@@ -8,29 +8,17 @@
   >
     <div
       class="wrap">
-      <div v-loading="loading">
-        <div class="block-title">
-          票种价格方案
-        </div>
-        <el-select v-model="plan_id">
-          <el-option
-            v-for="item in ticketPricePlanList"
-            :key="item.id"
-            :value="item.id"
-            :label="item.name">
-          </el-option>
-        </el-select>
-      </div>
-      <div v-loading="loading">
+      <el-alert type="warning" :closable="false" title="当前价格优先级:日期段价格 > 周价格 > 日常价格" />
+      <!-- <div v-loading="loading">
         <div class="block-title">
           基础价格
         </div>
         <el-input
           placeholder="请输入内容"
-          v-model="basic_price"
+          v-model="basicPrice"
           style="width: 160px">
         </el-input>
-      </div>
+      </div> -->
       <div v-loading="weekLoading">
         <div class="block-title">
           周价格
@@ -121,9 +109,18 @@
 <script>
 import moment from 'moment'
 
-import { getPricePlan, setPricePlan } from '@/api/ticketPricePlan'
+import { getPricePlan, addTicketPricePlan } from '@/api/ticketPricePlan'
 
 const week = ['周一', '周二', '周三', '周四', '周五', '周六', '周日']
+const weekMap = {
+  '周日': 1,
+  '周一': 2,
+  '周二': 3,
+  '周三': 4,
+  '周四': 5,
+  '周五': 6,
+  '周六': 7
+}
 
 const stragegiesMap = {
   PERIOD: '日期段价格',
@@ -141,73 +138,49 @@ export default {
       visible: false,
       weekLoading: false,
       confirmLoading: false,
-      basic_price: '',
+      basicPrice: '',
       ticketPricePlanList: [],
       priceList: [],
       weekDayPriceList: [],
-      plan_id: '',
-      form: {
-        plan_id: 0,
-        period_price: {
-          price: []
-        },
-        weekday_price: {
-          price: {}
-        },
-        ticketTypeId: 0
-      }
-    }
-  },
-  watch: {
-    plan_id (newName, oldName) {
-      this.priceList = []
-      this.getPricePlan(newName)
+      ticketInfo: {}
     }
   },
   methods: {
-    moment,
-    show (id, ticketPricePlanList) {
-      Object.assign(this.$data, this.$options.data())
-      this.visible = true
-      this.ticketTypeId = id
-      this.ticketPricePlanList = ticketPricePlanList
-      if (!this.plan_id && ticketPricePlanList.length) {
-        this.plan_id = ticketPricePlanList[0].id
-      }
+    show (ticket) {
+      this.ticketInfo = ticket
       this.weekDayPriceList = week.map((val, index) => {
         return {
           label: val,
           value: null
         }
       })
-      this.getPricePlan()
-    },
-    getPricePlan (e) {
-      let params = {
-        'batch_config_id': 0,
-        'plan_id': e || 1,
-        'seat_area_id': 0,
-        'ticketTypeId': this.ticketTypeId }
-      getPricePlan(params).then(res => {
-        try {
-          this.basic_price = res.basic_price
-          let priceList = res.period_price.price
-          priceList && priceList.forEach(item => {
-            item.dateRange = [new Date(item.start), new Date(item.end)]
+      getPricePlan({
+        ticketTypeId: ticket.id,
+        pageSize: 10,
+        pageNum: -1
+      }).then(res => {
+        if (res.code === '200') {
+          const list = res.data || []
+
+          list.filter(l => l.weekdays).forEach(l => {
+            this.weekDayPriceList.forEach(w => {
+              if (l.weekdays.includes(weekMap[w.label])) {
+                w.value = l.price
+              }
+            })
           })
-          this.priceList = priceList || []
 
-          const weekPrice = res.weekday_price.price
-          this.weekDayPriceList = week.map((val, index) => {
+          this.priceList = list.filter(l => !l.weekdays).map(l => {
+            const { startDate, endDate, specificDate, price } = l
             return {
-              label: val,
-              value: (weekPrice && weekPrice[index]) || null
+              dateRange: [moment(specificDate || startDate), moment(specificDate || endDate)],
+              price: price
             }
-          })
-        } catch (e) {
-          console.log(e)
+          }).reverse()
         }
       })
+      this.visible = true
+      this.ticketTypeId = ticket.id
     },
     handleCancel () {
       this.visible = false
@@ -243,22 +216,61 @@ export default {
     },
     handleOk () {
       this.confirmLoading = true
-      let weekPrice = this.weekDayPriceList.map(i => i.value)
-      weekPrice = Object.assign({}, weekPrice)
-      let params = {}
-      params = JSON.parse(JSON.stringify(this.form))
-      params.plan_id = this.plan_id
-      params.period_price.price = this.priceList
-      params.weekday_price.price = weekPrice
-      params.ticketTypeId = this.ticketTypeId
-      params.basic_price = this.basic_price
-      let plan_list = []
-      plan_list.push(params)
-      setPricePlan({ plan_list: plan_list }).then(res => {
-        this.$message.success('设置成功')
-        this.handleCancel()
+      const { id, isSale } = this.ticketInfo
+      const planList = []
+      const weekPriceList = []
+      let priority = 0
+      const wpList = this.weekDayPriceList.filter(wp => wp.value !== null || wp.value !== undefined)
+      wpList.forEach(wp => {
+        const hasPrice = weekPriceList.find(item => wp.value === item.price)
+
+        if (hasPrice) {
+          hasPrice.weekdays += `,${weekMap[wp.label]}`
+        } else {
+          weekPriceList.push({
+            ticketTypeId: id,
+            isSale,
+            priority,
+            price: wp.value,
+            weekdays: weekMap[wp.label]
+          })
+        }
+      })
+      planList.push(...weekPriceList)
+
+      this.priceList.forEach(item => {
+        priority--
+        const { start, end, price } = item
+        const startDate = moment(start).format('YYYY-MM-DD')
+        const endDate = moment(end).format('YYYY-MM-DD')
+
+        if (startDate === endDate) {
+          planList.push({
+            ticketTypeId: id,
+            isSale,
+            priority,
+            price,
+            specificDate: startDate
+          })
+        } else {
+          planList.push({
+            ticketTypeId: id,
+            isSale,
+            priority,
+            price,
+            startDate,
+            endDate
+          })
+        }
+      })
+
+      addTicketPricePlan(planList).then(res => {
+        if (res.code === '200') {
+          this.$message.success('设置成功')
+          this.handleCancel()
+        }
       }).finally(() => {
-        this.confirmLoadingading = false
+        this.loading = false
       })
     }
   }