const https = require("../utils/https.js")
const { query } = require("../interface/cx-wechat-query.js")
/**
* 查询高峰管控
*/
const queryBusyControlStrategy = (orderInfo) => {
/**
* 解析高峰管控产品代码
* ---------- 快递员上门、扫码寄件、港澳台 ----------
* | 顺丰标快 | T4 | SE0001 |
* | 顺丰特惠 | T6 | SE0004 |
* | 顺丰即日(专享) | T103 | SE0093 |
* | 顺丰即日 | T104 | SE0002 |
* | 高铁极速达次晨 | T109 | SE0097 |
* | 顺丰次晨 | T801 | SE0003 |
* | 高铁极速达 | T108 | SE0096 |
* ---------- 寄大件 ----------
* SE0100 SE0101 保持不变
* ---------- 医药寄 ----------
* | 医药安心递 | SP321 | SE0001(使用顺丰标快代替) |
* ---------- 生鲜寄 ----------
* | 大闸蟹专递 | SP334 | SE0034|
* | 生鲜速配 | SP330 | SE0027 |
* ----------- 冷运 -----------
* | 冷运零担 | SE0030 | SE0030 |
*/
const productCodeMap = {
'T4': 'SE0001',
'T6': 'SE0004',
'T103': 'SE0093',
'T104': 'SE0002',
'T109': 'SE0097',
'T801': 'SE0003',
'T108': 'SE0096',
'SE0100': 'SE0100',
'SE0101': 'SE0101',
'SP321': 'SE0001',
'SP334': 'SE0034',
'SP330': 'SE0027',
'SE0030': 'SE0030'
}
const needUseProductCode = productCodeMap[orderInfo.productCode] || 'SE0001'
const requestParam = {
language : 'zh_cn',
customerType: orderInfo.customerType, //客户属性 -- 1:散单,2:月结 (预约上门没有月结卡号)
customerCode: orderInfo.customerCode, //客户卡号/手机号(寄件人的) -- 散单传手机号码,月结传客户卡号
channelCode: 'wxapp', //渠道编码 -- 一般为系统编码 cx
srcZoneCode: orderInfo.srcZoneCode || '', //原寄地 -- 必须是网点或者城市
destZoneCode: orderInfo.destZoneCode || '', //目的地 -- 必须是网点或者城市
srcAddress: orderInfo.srcAddress,
destAddress: orderInfo.destAddress,
productCode: needUseProductCode, //产品类型 -- 月结是,散单非必传;传代码如SE00001,如果不传产品代码那三个维度必须要传如T4,B1,C201()
// limitTypeCode: orderInfo.productCode || 'T4', //时效类型
// cargoTypeCode: orderInfo.productCode === 'T6' ? 'T6' : 'C201', //快件内容
// expressTypeCode: 'B1', //业务类型
consignedTm: '', //下单时间(只支持yyyy-MM-dd hh:mm:ss这种格式)----后端自己填充,不用前端下发
srcDivisionCode: orderInfo.srcDivisionCode, //原寄地行政区代码
destDivisionCode: orderInfo.destDivisionCode
}
return https.api({
url: query.busyControlStrategy,
contentType: 'application/json;charset=UTF-8',
data : requestParam
}).then((res) => {
const data = res.data
const curBusyControlStrategy = {}
if (data && data.success && data.obj) {
curBusyControlStrategy.isOpen = true
// 存高峰管控策略
curBusyControlStrategy.controlStrategy = data.obj.controlStrategy || 0
// 存高峰管控策略描述
curBusyControlStrategy.notificationMsg = data.obj.notificationMsg || ''
return curBusyControlStrategy
}
curBusyControlStrategy.isOpen = false
return curBusyControlStrategy
}).catch(() => {
return {
isOpen: false
}
})
}
export {
queryBusyControlStrategy
}