yunlin 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +276 -0
  2. package/package.json +11 -0
package/index.js ADDED
@@ -0,0 +1,276 @@
1
+ function showLog(title = '看看我啊') {
2
+ console.log(title);
3
+ }
4
+
5
+ /**
6
+ * 计价数据格式处理
7
+ * @param {Object} valList 价格数据数组
8
+ * @param {Object} hbfh 货币符号
9
+ * @param {Object} title 自定义标题
10
+ */
11
+ function handleCosting(valList, hbfh = '', titles = {
12
+ people: '人員費用',
13
+ service: '附加服務',
14
+ trip: '附加行程',
15
+ other: '其他費用',
16
+ reduction: '減免費用',
17
+ totalprice: '總計',
18
+ airtax: '機場稅',
19
+ }, keys = {
20
+ //键名对应 数据返回键名对应显示标题 与其他拓展
21
+ adult: '成人',
22
+ child: '兒童',
23
+ childusebed: '兒童[占床]',
24
+ infant: '嬰兒',
25
+ half: '拼房',
26
+ //其他拓展
27
+ tip: '小費',
28
+ elder: '長者減免',
29
+ vip: '會員減免',
30
+ promotion: '促銷',
31
+ insure: '保險費用',
32
+ coupon: '優惠券',
33
+ point: '積分',
34
+ tax: '稅金',
35
+ viprecharge: '會員充值',
36
+ r: '人',
37
+ t: '天',
38
+ }) {
39
+ let list = []
40
+ const rideIcon = ' * '
41
+
42
+
43
+ //取出人员明细
44
+ const peopleList = valList.filter(item => item.strLx == 'base')
45
+ if (peopleList.length) {
46
+ let val = {
47
+ title: titles['people'],
48
+ type: 'base',
49
+ list: []
50
+ }
51
+ peopleList.map(item => {
52
+ val.list.push({
53
+ title: keys[item.strJgbm], //标题
54
+ info: hbfh + item.fLsjUnit + rideIcon + item.nRs, //描述
55
+ nRs: item.nRs, //人数
56
+ unit: item.fLsjUnit, //单价
57
+ cb: item.fJcbzlsjUnit, //成本
58
+ type: 'base'
59
+ })
60
+ })
61
+ list.push(val)
62
+ }
63
+
64
+ //附加服务
65
+ const serviceList = valList.filter(item => item.strLx == 'service')
66
+ if (serviceList.length) {
67
+ let val = {
68
+ title: titles['service'],
69
+ type: 'service',
70
+ list: []
71
+ }
72
+ serviceList.map(item => {
73
+ val.list.push({
74
+ title: item.name + `[${item.itemname}]`, //标题
75
+ info: hbfh + item.unitprice + rideIcon + item.num, //描述
76
+ nRs: item.num, //人数
77
+ unit: item.unitprice, //单价
78
+ cb: item.baseprice, //成本
79
+ type: 'service'
80
+ })
81
+ })
82
+ list.push(val)
83
+ }
84
+
85
+ //附加行程
86
+ const tripList = valList.filter(item => item.strLx == 'trip')
87
+ if (tripList.length) {
88
+ let val = {
89
+ title: titles['trip'],
90
+ type: 'trip',
91
+ list: []
92
+ }
93
+ tripList.map(item => {
94
+ if (item.adultnum != '0') {
95
+ val.list.push({
96
+ title: item.name + `[${keys['adult']}]`, //成人
97
+ info: hbfh + item.adultprice + rideIcon + item.adultnum, //描述
98
+ nRs: item.adultnum, //人数
99
+ unit: item.adultprice, //单价
100
+ cb: item.baseadultprice, //成本
101
+ type: 'trip'
102
+ })
103
+ }
104
+ if (item.childnum != '0') {
105
+ val.list.push({
106
+ title: item.name + `[${keys['child']}]`, //儿童
107
+ info: hbfh + item.childprice + rideIcon + item.childnum, //描述
108
+ nRs: item.childnum, //人数
109
+ unit: item.childprice, //单价
110
+ cb: item.basechildprice, //成本
111
+ type: 'trip'
112
+ })
113
+ }
114
+ })
115
+ list.push(val)
116
+ }
117
+
118
+ let reductionList = []
119
+ //长者减免
120
+ const elderList = valList.filter(item => item.strLx == 'elder')
121
+ if (elderList.length) {
122
+ elderList.map(item => {
123
+ const parts = item.name.split("|") || [''];
124
+ reductionList.push({
125
+ title: keys['elder'] + `[${parts[0]}]`,
126
+ info: hbfh + item.money, //描述
127
+ unit: item.money, //单价
128
+ cb: item.money, //成本
129
+ type: 'elder'
130
+ })
131
+ })
132
+ }
133
+ //会员减免
134
+ const vipList = valList.filter(item => item.strLx == 'vipdiscounted')
135
+ if (vipList.length) {
136
+ vipList.map(item => {
137
+ reductionList.push({
138
+ title: keys['vip'] + `[${item.name}]`,
139
+ info: hbfh + item.money, //描述
140
+ unit: item.money, //单价
141
+ cb: item.money, //成本
142
+ type: 'vip'
143
+ })
144
+ })
145
+ }
146
+ //促销
147
+ const promotionList = valList.filter(item => item.strLx == 'promotion')
148
+ if (promotionList.length) {
149
+ promotionList.map(item => {
150
+ reductionList.push({
151
+ title: keys['promotion'],
152
+ info: hbfh + item.money, //描述
153
+ unit: item.money, //单价
154
+ cb: item.money, //成本
155
+ type: 'promotion'
156
+ })
157
+ })
158
+ }
159
+
160
+ //减免或促销费用
161
+ if (reductionList.length) {
162
+ list.push({
163
+ title: titles['reduction'],
164
+ type: 'reduction',
165
+ list: reductionList
166
+ })
167
+ }
168
+
169
+ //机场税
170
+ const airtaxList = valList.filter(item => item.strLx == 'airtax')
171
+ if (airtaxList.length) {
172
+ let val = {
173
+ title: titles['airtax'],
174
+ type: 'airtax',
175
+ list: []
176
+ }
177
+ airtaxList.map(item => {
178
+ val.list.push({
179
+ title: keys[item.rylx], //标题
180
+ info: hbfh + item.unitprice + rideIcon + item.sl, //描述
181
+ nRs: item.sl, //人数
182
+ unit: item.unitprice, //单价
183
+ cb: item.unitpricewb, //其他币种
184
+ type: item.rylx
185
+ })
186
+ })
187
+ list.push(val)
188
+ }
189
+
190
+ const listKey = ['base', 'service', 'trip', 'elder', 'vipdiscounted', 'promotion', 'airtax'] //数据格式参数
191
+ //取出其他信息
192
+ const otherList = valList.filter(item => !listKey.includes(item.strLx));
193
+
194
+ let otherVal = {
195
+ title: titles['other'],
196
+ type: 'other',
197
+ list: []
198
+ }
199
+
200
+ for (var i = 0; i < otherList.length; i++) {
201
+ const item = otherList[i]
202
+ //会员充值
203
+ if (item.strLx == 'viprecharge') {
204
+ otherVal.list.push({
205
+ title: keys['viprecharge'] + `[${item.name}]`,
206
+ info: hbfh + item.money,
207
+ unit: item.money, //单价
208
+ type: item.strLx
209
+ })
210
+ }
211
+ //保险
212
+ if (item.strLx == 'insure') {
213
+ otherVal.list.push({
214
+ title: keys['insure'] + `[${item.name}]`,
215
+ info: hbfh + item.unit + rideIcon + item.users + keys['r'], //描述
216
+ nRs: item.users, //人数
217
+ unit: item.unit, //单价
218
+ cb: item.unit, //成本
219
+ type: 'insure'
220
+ })
221
+ }
222
+ //优惠券-积分
223
+ if (item.strLx == 'coupon' || item.strLx == 'point') {
224
+ otherVal.list.push({
225
+ title: keys[item.strLx],
226
+ info: hbfh + item.money,
227
+ unit: item.money, //单价
228
+ type: item.strLx
229
+ })
230
+ }
231
+ //小费
232
+ if (item.strLx == 'tip') {
233
+ otherVal.list.push({
234
+ title: keys[item.strLx], //标题
235
+ info: hbfh + item.tip + rideIcon + item.tipuser + keys['r'] + rideIcon + item.tipday +
236
+ keys['t'], //描述
237
+ nRs: item.tipuser, //人数
238
+ count: item.tipday, //天数,数量等
239
+ unit: item.tip, //单价
240
+ type: item.strLx //类型
241
+ })
242
+ }
243
+ //税
244
+ if (item.strLx == 'tax') {
245
+ otherVal.list.push({
246
+ title: keys[item.strLx],
247
+ info: hbfh + item.totaltax,
248
+ unit: item.totaltax,
249
+ type: item.strLx
250
+ })
251
+ }
252
+ }
253
+ if (otherVal.list.length) {
254
+ list.push(otherVal)
255
+ }
256
+
257
+ const totalprice = valList.filter(item => item.strLx == 'totalprice')
258
+ //总价(实付价格)
259
+ if (totalprice.length) {
260
+ list.push({
261
+ title: titles['totalprice'],
262
+ type: 'totalprice',
263
+ list: [{
264
+ title: titles['totalprice'],
265
+ info: hbfh + totalprice[0].price
266
+ }]
267
+ })
268
+ }
269
+ return list
270
+ }
271
+
272
+
273
+ module.exports = {
274
+ showLog,
275
+ handleCosting
276
+ };
package/package.json ADDED
@@ -0,0 +1,11 @@
1
+ {
2
+ "name": "yunlin",
3
+ "version": "1.0.0",
4
+ "main": "index.js",
5
+ "scripts": {
6
+ "test": "echo \"Error: no test specified\" && exit 1"
7
+ },
8
+ "keywords": [],
9
+ "author": "",
10
+ "license": "ISC"
11
+ }