sale-client 3.6.19 → 3.6.21

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.
@@ -1,2068 +1,2110 @@
1
- import Vue from 'vue'
2
- import co from 'co'
3
-
4
- let CardService = {
5
- install (Vue, options) {
6
- // 给vue增添对话框显示方法
7
- Vue.CardService = Vue.prototype.$CardService = CardService
8
- },
9
- // 判断是否插卡
10
- hasCard () {
11
- let has = hasCardGen()
12
- return co(has)
13
- },
14
- // 读卡
15
- readCard () {
16
- let read = readCard()
17
- return co(read)
18
- },
19
- // 开户发卡
20
- initCard (model, row, allot) {
21
- // let init = initCardGen(model, row, allot ? this.getallotdata(allot, row, '发卡售气') : null)
22
- // return co(init)
23
-
24
- let f_serial_number = ''
25
- let f_price = ''
26
- let inputprice = '0'
27
- if (model.f_serial_number) {
28
- f_serial_number = model.f_serial_number
29
- }
30
- if (model.f_price && (model.f_price - 0) > 0) {
31
- f_price = model.f_price
32
- inputprice = '1'
33
- }
34
- let f_privilege_gas = 0
35
- if (model.f_privilege_gas) {
36
- f_privilege_gas = model.f_privilege_gas
37
- }
38
- let param = {
39
- garbage_number: model.garbage_number,
40
- garbage_money: model.garbage_money,
41
- f_serial_id: model.f_serial_id,
42
- f_userinfo_id: row.f_userinfo_id,
43
- f_serial_number: f_serial_number,
44
- f_user_id: row.f_user_id,
45
- f_price: f_price,
46
- inputprice: inputprice,
47
- f_userfiles_id: row.f_userfiles_id,
48
- f_pregas: model.f_pregas,
49
- f_preamount: model.f_preamount,
50
- f_balance: row.f_balance,
51
- f_meter_type: row.f_meter_type,
52
- f_calculation: row.f_calculation,
53
- f_collection_type: row.f_collection_type,
54
- f_total_gas: (row.f_total_gas - 0) + (model.f_pregas - 0),
55
- f_write_money: model.xiekamoney,
56
- f_write_totalgas: (row.f_write_totalgas - 0) + (model.f_pregas - 0),
57
- f_write_totalfee: (row.f_write_totalfee - 0) + (model.xiekamoney - 0),
58
- f_total_fee: (row.f_total_fee - 0) + (model.f_preamount - 0),
59
- f_open_fee: model.f_open_fee,
60
- f_collection: model.f_collection,
61
- f_payment: model.f_payment.toString(),
62
- payments: model.payments,
63
- f_print: model.f_print.toString(),
64
- f_voucher_number: model.f_voucher_number,
65
- userinfo_version: row.userinfo_version,
66
- version: row.version,
67
- // 优惠金额
68
- f_privilege_money: model.f_privilege_money,
69
- f_privilege_gas: f_privilege_gas,
70
- f_after_discount: model.f_after_discount,
71
-
72
- f_operator: Vue.$login.f.name,
73
- f_operatorid: Vue.$login.f.id,
74
- f_orgid: Vue.$login.f.orgid,
75
- f_orgname: Vue.$login.f.orgs,
76
- f_depid: Vue.$login.f.depids,
77
- f_depname: Vue.$login.f.deps,
78
- f_zoneid: Vue.$login.f.zoneid,
79
- f_zones: Vue.$login.f.zones,
80
- f_comments: model.f_comments
81
- }
82
- console.log('发卡售气前参数', row)
83
- return sendCardSaleGasGen(param, row)
84
- },
85
- resetinitCard (model, row) {
86
- let f_serial_number = ''
87
- let f_price = ''
88
- let inputprice = '0'
89
- if (model.f_serial_number) {
90
- f_serial_number = model.f_serial_number
91
- }
92
- if (model.f_price && (model.f_price - 0) > 0) {
93
- f_price = model.f_price
94
- inputprice = '1'
95
- }
96
- let f_privilege_gas = 0
97
- if (model.f_privilege_gas) {
98
- f_privilege_gas = model.f_privilege_gas
99
- }
100
- let param = {
101
- f_serial_id: model.f_serial_id,
102
- f_userinfo_id: row.f_userinfo_id,
103
- f_user_name: row.f_user_name,
104
- f_serial_number: f_serial_number,
105
- f_user_id: row.f_user_id,
106
- f_price: f_price,
107
- inputprice: inputprice,
108
- f_userfiles_id: row.f_userfiles_id,
109
- f_pregas: model.f_pregas,
110
- f_preamount: model.f_preamount,
111
- f_balance: row.f_balance,
112
- f_meter_type: row.f_meter_type,
113
- f_calculation: row.f_calculation,
114
- f_collection_type: row.f_collection_type,
115
- f_total_gas: (row.f_total_gas - 0) + (model.f_pregas - 0),
116
- f_write_totalgas: (row.f_write_totalgas - 0) + (model.f_pregas - 0),
117
- f_write_totalfee: (row.f_write_totalfee - 0) + (model.f_preamount - 0),
118
- f_total_fee: (row.f_total_fee - 0) + (model.f_preamount - 0),
119
- f_open_fee: model.f_open_fee,
120
- f_collection: model.f_collection,
121
- // f_print: model.f_print.toString(),
122
- f_user_type: row.f_user_type,
123
- f_gasproperties: row.f_gasproperties,
124
- f_address: row.f_address,
125
- f_meter_brand: row.f_meter_brand,
126
- f_voucher_number: model.f_voucher_number,
127
- userinfo_version: row.userinfo_version,
128
- version: row.version,
129
-
130
- f_operator: Vue.$login.f.name,
131
- f_operatorid: Vue.$login.f.id,
132
- f_orgid: Vue.$login.f.orgid,
133
- f_orgname: Vue.$login.f.orgs,
134
- f_depid: Vue.$login.f.depids,
135
- f_depname: Vue.$login.f.deps,
136
- f_zoneid: Vue.$login.f.zoneid,
137
- f_zones: Vue.$login.f.zones,
138
- f_comments: model.f_comments
139
- }
140
- console.log('重发卡售气前参数', row)
141
- return resetsendCardSaleGasGen(param, row)
142
- },
143
- // 补气开户发卡
144
- remanentinitCard (model, row, allot) {
145
- let param = {
146
- f_share_times: row.f_share_times,
147
- f_hascard: row.f_hascard,
148
- f_open_way: row.f_open_type,
149
- f_serial_id: model.f_serial_id,
150
- f_userinfo_id: row.f_userinfo_id,
151
- f_user_id: row.f_user_id,
152
- // 补气量
153
- f_fill_gas: model.f_fill_gas,
154
- f_fill_money: model.f_fill_money,
155
- f_remanent_gas: row.f_remanent_gas === 0 ? model.f_fill_gas : row.f_remanent_gas,
156
- f_remanent_price: row.f_remanent_price,
157
- f_remanent_money: row.f_remanent_money === 0 ? model.f_fill_money : row.f_remanent_money,
158
- f_remanent_type: row.f_remanent_type,
159
- f_userfiles_id: row.f_userfiles_id,
160
- f_user_name: row.f_user_name,
161
- f_user_type: row.f_user_type,
162
- f_gasproperties: row.f_gasproperties,
163
- f_address: row.f_address,
164
- f_meter_brand: row.f_meter_brand,
165
- f_meter_type: row.f_meter_type,
166
- f_collection_type: row.f_collection_type,
167
- // 购气量
168
- f_pregas: (model.f_pregas - 0) === 0 ? model.f_fill_gas : (model.f_pregas - 0),
169
- f_preamount: (model.f_preamount - 0) === 0 ? model.f_fill_money : (model.f_preamount - 0),
170
- f_totalcost: model.f_totalcost - 0,
171
- f_balance: row.f_balance,
172
- f_open_fee: model.f_open_fee,
173
- f_collection: model.f_collection,
174
- f_payment: model.f_payment.toString(),
175
- payments: model.payments,
176
- f_print: model.f_print.toString(),
177
- f_voucher_number: model.f_voucher_number,
178
- userinfo_version: row.userinfo_version,
179
- version: row.version,
180
- f_operator: Vue.$login.f.name,
181
- f_operatorid: Vue.$login.f.id,
182
- f_orgid: Vue.$login.f.orgid,
183
- f_orgname: Vue.$login.f.orgs,
184
- f_depid: Vue.$login.f.depids,
185
- f_depname: Vue.$login.f.deps,
186
- f_zoneid: Vue.$login.f.zoneid,
187
- f_zones: Vue.$login.f.zones,
188
- f_comments: model.f_comments
189
- }
190
-
191
- if (row.f_remanent_type === 1) {
192
- param.f_total_gas = (row.f_total_gas - 0) + (model.f_pregas - 0)
193
- param.f_total_fee = (row.f_total_fee - 0) + (model.f_preamount - 0)
194
- } else {
195
- if ((model.f_pregas - 0) > (model.f_fill_gas - 0)) {
196
- param.f_total_gas = (row.f_total_gas - 0) + ((model.f_pregas - 0) - (model.f_fill_gas - 0))
197
- param.f_total_fee = (row.f_total_fee - 0) + (model.f_preamount - 0)
198
- } else {
199
- param.f_total_gas = (row.f_total_gas - 0)
200
- param.f_total_fee = (row.f_total_fee - 0)
201
- }
202
- }
203
- param.f_write_totalgas = (row.f_write_totalgas - 0) + (model.f_pregas - 0)
204
- param.f_write_totalfee = (row.f_write_totalfee - 0) + (model.f_preamount - 0)
205
- return sendCardSaleGasGenremanent(param, row)
206
- },
207
-
208
- offlineWrite (row) {
209
- return offlineWriteGen(row)
210
- },
211
- // 余量补差
212
- margin (model, row) {
213
- let f_serial_number = ''
214
- let f_price = ''
215
- let inputprice = '0'
216
- let f_privilege_gas = 0
217
- if (model.f_serial_number) {
218
- f_serial_number = model.f_serial_number
219
- }
220
- if (model.f_price && (model.f_price - 0) > 0) {
221
- f_price = model.f_price
222
- inputprice = '1'
223
- }
224
- if (model.f_privilege_gas) {
225
- f_privilege_gas = model.f_privilege_gas
226
- }
227
- let param = {
228
- garbage_number: model.garbage_number,
229
- garbage_money: model.garbage_money,
230
- f_serial_id: model.f_serial_id,
231
- f_userinfo_id: row.f_userinfo_id,
232
- f_serial_number: f_serial_number,
233
- f_write_money: model.xiekamoney,
234
- f_price: f_price,
235
- inputprice: inputprice,
236
- // 补气量
237
- f_remanent_gas: row.f_remanent_gas,
238
- f_remanent_price: row.f_remanent_price,
239
- f_user_id: row.f_user_id,
240
- f_calculation: row.f_calculation,
241
- f_collection_type: row.f_collection_type,
242
- f_userfiles_id: row.f_userfiles_id,
243
- f_pregas: model.f_pregas,
244
- f_totalcost: model.f_totalcost,
245
- f_balance: row.f_balance,
246
- f_meter_type: row.f_meter_type,
247
- f_preamount: model.f_preamount,
248
- f_total_gas: (row.f_total_gas - 0) + (model.f_pregas - 0),
249
- f_write_totalgas: (row.f_write_totalgas - 0) + (model.f_pregas - 0),
250
- f_write_totalfee: (row.f_write_totalfee - 0) + (model.xiekamoney - 0),
251
- f_total_fee: (row.f_total_fee - 0) + (model.f_preamount - 0),
252
- f_collection: model.f_collection,
253
- // 优惠金额
254
- f_privilege_money: model.f_privilege_money,
255
- f_privilege_gas: f_privilege_gas,
256
- f_after_discount: model.f_after_discount,
257
- f_payment: model.f_payment.toString(),
258
- payments: model.payments,
259
- f_print: model.f_print.toString(),
260
- f_voucher_number: model.f_voucher_number,
261
- userinfo_version: row.userinfo_version,
262
- version: row.version,
263
- f_meter_base: row.f_meter_base,
264
- f_operator: Vue.$login.f.name,
265
- f_operatorid: Vue.$login.f.id,
266
- f_orgid: Vue.$login.f.orgid,
267
- f_orgname: Vue.$login.f.orgs,
268
- f_depid: Vue.$login.f.depids,
269
- f_depname: Vue.$login.f.deps,
270
- f_zoneid: Vue.$login.f.zoneid,
271
- f_zones: Vue.$login.f.zones,
272
- f_comments: model.f_comments,
273
- f_sys_balance: model.f_sys_balance
274
- }
275
- return marginGen(param, row)
276
- },
277
- // 卡表收费
278
- sellgas (model, row) {
279
- let f_serial_number = ''
280
- let f_price = ''
281
- let inputprice = '0'
282
- let f_privilege_gas = 0
283
- if (model.f_serial_number) {
284
- f_serial_number = model.f_serial_number
285
- }
286
- if (model.f_price && (model.f_price - 0) > 0) {
287
- f_price = model.f_price
288
- inputprice = '1'
289
- }
290
- if (model.f_privilege_gas) {
291
- f_privilege_gas = model.f_privilege_gas
292
- }
293
- let param = {
294
- garbage_number: model.garbage_number,
295
- garbage_money: model.garbage_money,
296
- f_serial_id: model.f_serial_id,
297
- f_userinfo_id: row.f_userinfo_id,
298
- f_serial_number: f_serial_number,
299
- f_write_money: model.xiekamoney,
300
- f_price: f_price,
301
- inputprice: inputprice,
302
- // 补气量
303
- f_remanent_gas: row.f_remanent_gas,
304
- f_remanent_price: row.f_remanent_price,
305
- f_user_id: row.f_user_id,
306
- f_calculation: row.f_calculation,
307
- f_collection_type: row.f_collection_type,
308
- f_userfiles_id: row.f_userfiles_id,
309
- f_pregas: model.f_pregas,
310
- f_totalcost: model.f_totalcost,
311
- f_balance: row.f_balance,
312
- f_meter_type: row.f_meter_type,
313
- f_preamount: model.f_preamount,
314
- f_total_gas: (row.f_total_gas - 0) + (model.f_pregas - 0),
315
- f_write_totalgas: (row.f_write_totalgas - 0) + (model.f_pregas - 0),
316
- f_write_totalfee: (row.f_write_totalfee - 0) + (model.xiekamoney - 0),
317
- f_total_fee: (row.f_total_fee - 0) + (model.f_preamount - 0),
318
- f_collection: model.f_collection,
319
- // 优惠金额
320
- f_privilege_money: model.f_privilege_money,
321
- f_privilege_gas: f_privilege_gas,
322
- f_after_discount: model.f_after_discount,
323
- f_payment: model.f_payment.toString(),
324
- payments: model.payments,
325
- f_print: model.f_print.toString(),
326
- f_voucher_number: model.f_voucher_number,
327
- userinfo_version: row.userinfo_version,
328
- version: row.version,
329
- f_meter_base: row.f_meter_base,
330
- f_operator: Vue.$login.f.name,
331
- f_operatorid: Vue.$login.f.id,
332
- f_orgid: Vue.$login.f.orgid,
333
- f_orgname: Vue.$login.f.orgs,
334
- f_depid: Vue.$login.f.depids,
335
- f_depname: Vue.$login.f.deps,
336
- f_zoneid: Vue.$login.f.zoneid,
337
- f_zones: Vue.$login.f.zones,
338
- f_comments: model.f_comments,
339
- f_sys_balance: model.f_sys_balance
340
- }
341
- return sellgasGen(param, row)
342
- },
343
-
344
- // 补气卡表收费
345
- remanentsellgas (model, row) {
346
- let param = {
347
- f_user_name: row.f_user_name,
348
- f_user_type: row.f_user_type,
349
- f_gasproperties: row.f_gasproperties,
350
- f_userinfo_id: row.f_userinfo_id,
351
- f_address: row.f_address,
352
- f_meter_brand: row.f_meter_brand,
353
- f_meter_type: row.f_meter_type,
354
- f_collection_type: row.f_collection_type,
355
- f_card_id: row.f_card_id,
356
- f_write_money: model.xiekamoney,
357
- // 补气信息
358
- f_fill_gas: model.f_fill_gas,
359
- f_fill_money: model.f_fill_money,
360
-
361
- f_remanent_gas: row.f_remanent_gas,
362
- f_remanent_price: row.f_remanent_price,
363
- f_remanent_type: row.f_remanent_type,
364
- f_user_id: row.f_user_id,
365
- f_userfiles_id: row.f_userfiles_id,
366
- f_pregas: model.f_pregas,
367
- f_balance: row.f_balance,
368
- f_preamount: model.f_preamount,
369
- f_totalcost: model.f_totalcost,
370
- f_collection: model.f_collection,
371
- f_payment: model.f_payment.toString(),
372
- payments: model.payments,
373
- f_print: model.f_print.toString(),
374
- f_voucher_number: model.f_voucher_number,
375
- userinfo_version: row.userinfo_version,
376
- version: row.version,
377
- f_operator: Vue.$login.f.name,
378
- f_operatorid: Vue.$login.f.id,
379
- f_orgid: Vue.$login.f.orgid,
380
- f_orgname: Vue.$login.f.orgs,
381
- f_depid: Vue.$login.f.depids,
382
- f_depname: Vue.$login.f.deps,
383
- f_zoneid: Vue.$login.f.zoneid,
384
- f_zones: Vue.$login.f.zones,
385
- f_comments: model.f_comments
386
- }
387
-
388
- // 0:代表清零补气, 累购量不加 1:代表换表补气 累购量加
389
- if (row.f_remanent_type === 1) {
390
- param.f_total_gas = (row.f_total_gas - 0) + (model.f_pregas - 0)
391
- param.f_total_fee = (row.f_total_fee - 0) + (model.f_preamount - 0)
392
- } else {
393
- if (model.f_pregas > row.f_remanent_gas) {
394
- param.f_total_gas = (row.f_total_gas - 0) + (model.f_pregas - row.f_remanent_gas)
395
- param.f_total_fee = (row.f_total_fee - 0) + (model.f_preamount - 0)
396
- } else {
397
- param.f_total_gas = (row.f_total_gas - 0)
398
- param.f_total_fee = (row.f_total_fee - 0)
399
- }
400
- }
401
- param.f_write_totalgas = (row.f_write_totalgas - 0) + (model.f_pregas - 0)
402
- param.f_write_totalfee = (row.f_write_totalfee - 0) + (model.xiekamoney - 0)
403
- return sellgasRemanentGen(param, row)
404
- },
405
- // 数码表收费
406
- DigtialSellGas (model, row) {
407
- let f_serial_number = ''
408
- if (model.f_serial_number) {
409
- f_serial_number = model.f_serial_number
410
- }
411
- let param = {
412
- f_userinfo_id: row.f_userinfo_id,
413
- f_serial_number: f_serial_number,
414
- f_user_id: row.f_user_id,
415
- f_userfiles_id: row.f_userfiles_id,
416
- f_pregas: model.f_pregas,
417
- f_write_money: model.f_write_money,
418
- f_balance: row.f_balance,
419
- f_preamount: model.f_preamount,
420
- f_total_gas: (row.f_total_gas - 0) + (model.f_pregas - 0),
421
- f_write_totalgas: (row.f_write_totalgas - 0) + (model.f_pregas - 0),
422
- f_write_totalfee: (row.f_write_totalfee - 0) + (model.f_write_money - 0),
423
- f_total_fee: (row.f_total_fee - 0) + (model.f_preamount - 0),
424
- f_collection: model.f_collection,
425
- f_payment: model.f_payment.toString(),
426
- payments: model.payments,
427
- f_print: model.f_print.toString(),
428
- f_voucher_number: model.f_voucher_number,
429
- userinfo_version: row.userinfo_version,
430
- version: row.version,
431
- f_operator: Vue.$login.f.name,
432
- f_operatorid: Vue.$login.f.id,
433
- f_orgid: Vue.$login.f.orgid,
434
- f_orgname: Vue.$login.f.orgs,
435
- f_depid: Vue.$login.f.depids,
436
- f_depname: Vue.$login.f.deps,
437
- f_zoneid: Vue.$login.f.zoneid,
438
- f_zones: Vue.$login.f.zones
439
-
440
- }
441
-
442
- return DigtialSellGasGen(param, row)
443
- },
444
- // 无卡收费
445
- noCardSellGas (model, row) {
446
- let f_serial_number = ''
447
- if (model.f_serial_number) {
448
- f_serial_number = model.f_serial_number
449
- }
450
- let f_write_card = ''
451
- if (model.f_write_card) {
452
- f_write_card = model.f_write_card
453
- }
454
- let param = {
455
- f_userinfo_id: row.f_userinfo_id,
456
- f_serial_number: f_serial_number,
457
- f_user_id: row.f_user_id,
458
- f_userfiles_id: row.f_userfiles_id,
459
- f_pregas: model.f_pregas,
460
- f_write_money: model.f_write_money,
461
- f_balance: row.f_balance,
462
- f_preamount: model.f_preamount,
463
- f_total_gas: (row.f_total_gas - 0) + (model.f_pregas - 0),
464
- f_write_totalgas: (row.f_write_totalgas - 0) + (model.f_pregas - 0),
465
- f_write_totalfee: (row.f_write_totalfee - 0) + (model.f_write_money - 0),
466
- f_total_fee: (row.f_total_fee - 0) + (model.f_preamount - 0),
467
- f_collection: model.f_collection,
468
- f_payment: model.f_payment.toString(),
469
- payments: model.payments,
470
- f_print: model.f_print.toString(),
471
- f_voucher_number: model.f_voucher_number,
472
- userinfo_version: row.userinfo_version,
473
- version: row.version,
474
- f_write_card: f_write_card === '不写卡' ? '不写卡' : '未写卡',
475
- f_operator: Vue.$login.f.name,
476
- f_operatorid: Vue.$login.f.id,
477
- f_orgid: Vue.$login.f.orgid,
478
- f_orgname: Vue.$login.f.orgs,
479
- f_depid: Vue.$login.f.depids,
480
- f_depname: Vue.$login.f.deps,
481
- f_zoneid: Vue.$login.f.zoneid,
482
- f_zones: Vue.$login.f.zones
483
-
484
- }
485
-
486
- return noCardSellGasGen(param, row)
487
- },
488
-
489
- // 补卡写卡
490
- replaceCard (model, row, allot) {
491
- // 磁条卡走了 replaceCiTiaoCard 不走这里
492
- // if (row.f_meter_type.indexOf('卡表') === -1 && row.f_meter_type.indexOf('物联网表') === -1) {
493
- // model.f_type = '补磁条卡'
494
- // let replace = replaceCiTiaoCardGen(model, row)
495
- // return co(replace)
496
- // }
497
- let replace = replaceCardGen(model, row, allot ? this.getallotdata(allot, row, '补卡') : null)
498
- return co(replace)
499
- },
500
- // 磁条卡补卡写卡
501
- replaceCiTiaoCard (model, row, allot) {
502
- let replace = replaceCiTiaoCardGen(model, row)
503
- return co(replace)
504
- },
505
- // 机表写卡
506
- replaceCardJB (model, row) {
507
- let replace = replaceCardGenJB(model, row)
508
- return co(replace)
509
- },
510
- // 物联网写卡
511
- replaceCardWeb (model, row) {
512
- let replace = replaceCardGenWeb(model, row)
513
- return co(replace)
514
- },
515
- replacecXq (model, row) {
516
- let replace = replaceXq(model, row)
517
- return co(replace)
518
- }
519
- }
520
-
521
- // 判断是否有卡插入
522
- let hasCardGen = async function () {
523
- return await Vue.resetpost('http://127.0.0.1:8003/HasCard', {}, {resolveMsg: null, rejectMsg: null})
524
- }
525
- // 读卡
526
- let readCard = async function () {
527
- return await Vue.resetpost('http://127.0.0.1:8003/ReadCard', {data: {}}, {resolveMsg: null, rejectMsg: null})
528
- }
529
-
530
- let replaceCiTiaoCardGen = async function (model, row) {
531
- // 1.存库 2.写卡
532
- let result = null
533
- let getCardNumber = {data: {cardNumber: null}}
534
- try {
535
- const OperatorInfo = {
536
- f_operator: Vue.$login.f.name,
537
- f_operatorid: Vue.$login.f.id,
538
- f_orgid: Vue.$login.f.orgid,
539
- f_orgname: Vue.$login.f.orgs,
540
- f_depid: Vue.$login.f.depids,
541
- f_depname: Vue.$login.f.deps
542
- }
543
- // 获取卡号
544
- // if (!row.f_card_id) {
545
- // getCardNumber = await Vue.resetpost('rs/logic/getCardNumber', {data: {id: row.brand_id}}, {
546
- // resolveMsg: null,
547
- // rejectMsg: '发卡售气获取卡号失败!!'
548
- // })
549
- // console.log('获取卡号、、', getCardNumber)
550
- // } else {
551
- // getCardNumber.data.cardNumber = row.f_card_id
552
- // console.log('档案自带卡号、、', getCardNumber)
553
- // }
554
- if (row.f_userinfo_code) {
555
- getCardNumber.data.cardNumber = row.f_card_id
556
- }
557
- result = await Vue.resetpost('rs/logic/sendCiTiaoCardRemanentGas', {
558
- data: {
559
- model,
560
- getCardNumber,
561
- row,
562
- OperatorInfo
563
- }
564
- }, {resolveMsg: null, rejectMsg: '发卡售气存库失败'})
565
- // 存库
566
- console.log('换表发卡存库返回', result)
567
- // 写卡
568
- Vue.showAlert('请刷卡', 'warning', 50000)
569
- // 组织写卡数据
570
- let params = {
571
- kh: result.data.cardnumber
572
- }
573
- let cardRes = await Vue.resetpost('http://127.0.0.1:8003/WriteCard_HEC', params, {
574
- resolveMsg: null,
575
- rejectMsg: '开户卡服务错误'
576
- })
577
- Vue.closeAlert()
578
- if (!result || cardRes.data.Err || cardRes.data.Exception) {
579
- // 写卡异常
580
- await Vue.resetpost('rs/logic/sendCiTiaoCardRemanentGas', {
581
- data: {
582
- model,
583
- getCardNumber,
584
- row,
585
- Chongzheng: true,
586
- fill_id: result.data.id
587
- }
588
- }, {resolveMsg: null, rejectMsg: null})
589
- throw new Error(`卡服务错误:${cardRes.data.Err}${cardRes.data.Exception},请联系开发人员处理!!`)
590
- } else {
591
- // 写卡成功
592
- Vue.showAlert('写卡成功', 'success', 2000)
593
- return result
594
- }
595
- } catch (error) {
596
- console.log('换表发卡出错。。', error)
597
- if (result) {
598
- // 出错进行回滚
599
- row.f_user_id = row.f_user_id + ''
600
- if (result) {
601
- await Vue.resetpost('rs/logic/sendCiTiaoCardRemanentGas', {
602
- data: {
603
- model,
604
- getCardNumber,
605
- row,
606
- Chongzheng: true,
607
- fill_id: result.data.id
608
- }
609
- }, {resolveMsg: null, rejectMsg: null})
610
- }
611
- }
612
- if (error.data) {
613
- throw new Error(error.data)
614
- } else {
615
- throw error
616
- }
617
- }
618
- }
619
-
620
- let sendCardSaleGasGenremanent = async function (model, row) {
621
- // 1.存库 2.写卡
622
- let result = null
623
- try {
624
- let cardState = await hasCardGen()
625
- console.log('判卡函数返回:', cardState)
626
- if (JSON.parse(cardState.data).state === 1) {
627
- // 获取卡号
628
- let getCardNumber = {data: {cardNumber: null}}
629
- if (!row.f_card_id) {
630
- getCardNumber = await Vue.resetpost('rs/logic/getCardNumber', {data: {id: row.brand_id}}, {resolveMsg: null, rejectMsg: '发卡售气获取卡号失败!!'})
631
- console.log('获取卡号、、', getCardNumber)
632
- } else {
633
- getCardNumber.data.cardNumber = row.f_card_id
634
- console.log('档案自带卡号、、', getCardNumber)
635
- }
636
- if (row.f_alias && row.f_alias.includes('SmartCard_TP')) {
637
- model.cardNumber = row.f_meternumber
638
- } else if (getCardNumber.data.cardNumber) {
639
- model.cardNumber = getCardNumber.data.cardNumber + ''
640
- } else {
641
- throw new Error('获取卡号失败!请核实参数管理中的卡号重新换表发卡售气。')
642
- }
643
- result = await Vue.resetpost('rs/logic/sendCardRemanentGas', {data: model}, {resolveMsg: null, rejectMsg: '发卡售气存库失败'})
644
- // 存库
645
- console.log('换表发卡存库返回', result)
646
- // 写卡
647
- let cardParams = await getParamGen(result.data.cardnumber, row.f_alias, row.f_user_id, row.f_userfiles_id)
648
-
649
- // 组织写卡数据
650
- let params = {
651
- factory: row.f_alias,
652
- kmm: '0', // 2019-12-22 查旭说的。给一个0 卡密码,写卡后返回新密码, 不论补卡还是先开户都没有密码
653
- kzt: '0', // 卡状态,0开户卡,1用户卡(0新开户,1补卡)
654
- kh: result.data.cardnumber, // 卡号
655
- yhh: row.f_meterid ? row.f_meterid : 0, // 用户号,档案中自己输
656
- ql: model.f_pregas, // 预购气量
657
- csql: '0', // 上次购气量,新开户为0
658
- ccsql: '0', // 上上次购气量,新开户为0
659
- cs: '1', // 求购气次数,先开户为1
660
- ljgql: (row.f_total_gas - 0) + (model.f_pregas - 0), // 当前累计购气量
661
- ljgqje: (row.f_total_fee - 0) + (model.f_preamount - 0), // 累计购气金额
662
- bkcs: '0', // 新开户卡,为0
663
- ljyql: '0', // 累积用气量,有些表要累加原来用气量,新开户卡,为0
664
- bjql: row.f_police_gas, // 报警气量,t_gasbrand表中
665
- czsx: row.f_topup_ceil, // 充值上线,t_gasbrand表中
666
- tzed: row.f_overdr_lines, // 透支额度,t_gasbrand表中
667
- cssqrq: '0', // 上次售气日期,格式为YYYYMMDD
668
- meterid: row.f_meternumber, // 表号
669
- money: model.f_preamount, // 购气金额
670
- dqdm: row.f_area_code, // 精益工业地区代码
671
- klx: row.f_coding
672
- }
673
- // 判断是否是累购表
674
- if (row.f_support_purchase === '是') {
675
- params.ljgql = (row.f_write_totalgas - 0) + (model.f_pregas - 0)
676
- params.ljgqje = (row.f_write_totalfee - 0) + (model.f_preamount - 0)
677
- }
678
- params = Object.assign({}, Vue.CommonService.writeCardParams(cardParams), params)
679
- console.log('换表发卡写卡参数', params)
680
- let cardRes = await Vue.resetpost('http://127.0.0.1:8003/WriteNewCard', params, {
681
- resolveMsg: null,
682
- rejectMsg: '开户卡服务错误'
683
- })
684
- if (!cardParams || ((model.f_pregas > model.f_remanent_gas) && !result) || cardRes.data.Err || cardRes.data.Exception) {
685
- // 写卡异常
686
- // 数据回滚操作
687
- // 由于数据太长,将f_user_id 更改为字符串
688
- row.f_userfiles_id = row.f_userfiles_id + ''
689
-
690
- await Vue.resetpost('rs/logic/remanentRollback', {data: {fillgasid: result.data.fillgasid, sellid: result.data.sellid, row: row}}, {
691
- resolveMsg: null,
692
- rejectMsg: '开户失败'
693
- })
694
- throw new Error(`卡服务错误:${cardRes.data.Err}${cardRes.data.Exception},请联系开发人员处理!!`)
695
- } else {
696
- // 写卡成功
697
- // 更新卡密码
698
- row.version = result.data.version - 1,
699
- await Vue.CommonService.updatePassword(row, cardRes)
700
- Vue.showAlert('补气购气成功', 'success', 2000)
701
- return result
702
- }
703
- } else {
704
- throw new Error(`请检查卡是否插好!!`)
705
- }
706
- } catch (error) {
707
- console.log('换表发卡出错。。', error)
708
-
709
- if (result) {
710
- // 出错进行回滚
711
- row.f_user_id = row.f_user_id + ''
712
- if (result) {
713
- await Vue.resetpost('rs/logic/remanentRollback', {data: {fillgasid: result.data.fillgasid, sellid: result.data.sellid, row: row}}, {
714
- resolveMsg: null,
715
- rejectMsg: '写卡失败,数据回滚失败,请联系技术人员处理!!'
716
- })
717
- }
718
- }
719
-
720
- if (error.data) {
721
- throw new Error(error.data)
722
- } else {
723
- throw error
724
- }
725
- }
726
- }
727
- let resetsendCardSaleGasGen = async function (model, row) {
728
- // 1.存库 2.写卡
729
- let result = null
730
- try {
731
- let cardState = await hasCardGen()
732
- console.log('判卡函数返回:', cardState)
733
- if (JSON.parse(cardState.data).state === 1) {
734
- // 获取卡号
735
- let getCardNumber = await Vue.resetpost('rs/logic/getCardNumber', {data: {id: row.brand_id}}, {resolveMsg: null, rejectMsg: '重发卡售气获取卡号失败!!'})
736
- console.log('获取卡号、、', getCardNumber)
737
- if (getCardNumber.data.cardNumber) {
738
- // 当卡的别名是泰鹏普通卡的时候卡号和表号一致
739
- console.log('开始验证是不是泰鹏普通卡')
740
- if (row.f_alias && row.f_alias.includes('SmartCard_TP')) {
741
- model.cardNumber = row.f_meternumber
742
- } else {
743
- model.cardNumber = getCardNumber.data.cardNumber + ''
744
- model.f_card_id = getCardNumber.data.cardNumber + ''
745
- }
746
- } else {
747
- throw new Error('获取卡号失败!请核实参数管理中的卡号重新发卡售气。')
748
- }
749
- // 存库
750
- result = await Vue.resetpost('rs/logic/sale_resetsendCardSaleGas_logic', {data: model}, {resolveMsg: null, rejectMsg: '重发卡售气存库失败'})
751
- console.log('重发卡售气存库返回', result)
752
- // 写卡
753
- let cardParams = await getParamGen(result.data.cardnumber, row.f_alias, row.f_user_id, row.f_userfiles_id)
754
-
755
- // 组织写卡数据
756
- let params = {
757
- factory: row.f_alias,
758
- kmm: '0', // 2019-12-22 查旭说的。给一个0 卡密码,写卡后返回新密码, 不论补卡还是先开户都没有密码
759
- kzt: '0', // 卡状态,0开户卡,1用户卡(0新开户,1补卡)
760
- kh: result.data.cardnumber, // 卡号
761
- yhh: row.f_meterid ? row.f_meterid : 0, // 用户号,档案中自己输
762
- ql: model.f_pregas, // 预购气量
763
- csql: '0', // 上次购气量,新开户为0
764
- ccsql: '0', // 上上次购气量,新开户为0
765
- cs: '1', // 求购气次数,先开户为1
766
- // ljgql: model.f_pregas, // 当前累计购气量
767
- bkcs: '0', // 新开户卡,为0
768
- ljyql: '0', // 累积用气量,有些表要累加原来用气量,新开户卡,为0
769
- bjql: row.f_police_gas, // 报警气量,t_gasbrand表中
770
- czsx: row.f_topup_ceil, // 充值上线,t_gasbrand表中
771
- tzed: row.f_overdr_lines, // 透支额度,t_gasbrand表中
772
- cssqrq: '0', // 上次售气日期,格式为YYYYMMDD
773
- meterid: row.f_meternumber, // 表号
774
- money: model.f_preamount, // 购气金额
775
- dqdm: row.f_area_code, // 精益工业地区代码
776
- klx: row.f_coding,
777
- ljgql: (row.f_total_gas - 0) + (model.f_pregas - 0), // 当前累计购气量
778
- ljgqje: (row.f_total_fee - 0) + (model.f_preamount - 0) // 累计购气金额
779
- }
780
- // 判断是否是累购表
781
- if (row.f_support_purchase === '是') {
782
- params.ljgql = (row.f_write_totalgas - 0) + (model.f_pregas - 0)
783
- params.ljgqje = (row.f_write_totalfee - 0) + (model.f_preamount - 0)
784
- }
785
- params = Object.assign({}, Vue.CommonService.writeCardParams(cardParams), params)
786
- console.log('重发卡售气写卡参数', params)
787
- let cardRes = await Vue.resetpost('http://127.0.0.1:8003/WriteNewCard', params, {
788
- resolveMsg: null,
789
- rejectMsg: '重开户卡服务错误'
790
- })
791
- if (!cardParams || !result || cardRes.data.Err || cardRes.data.Exception) {
792
- // 写卡异常
793
- // 数据回滚操作
794
- throw `卡服务错误:${cardRes.data.Err}${cardRes.data.Exception},请联系开发人员处理!!`
795
- } else {
796
- // 写卡成功
797
- // 更新卡密码
798
- await Vue.CommonService.updatePassword(row, cardRes)
799
- Vue.showAlert('初始化卡成功', 'success', 2000)
800
- return result
801
- }
802
- } else {
803
- throw new Error(`请检查卡是否插好!!`)
804
- }
805
- } catch (error) {
806
- if (result) {
807
- // 出错进行回滚
808
- row.f_userfiles_id = row.f_userfiles_id + ''
809
- if (result) {
810
- await Vue.resetpost('rs/logic/salecardrollback', {data: {id: result.data.id, row: row}}, {
811
- resolveMsg: null,
812
- rejectMsg: '写卡失败,数据回滚失败,请联系技术人员处理!!'
813
- })
814
- }
815
- }
816
- if (error.data) {
817
- throw new Error(error.data)
818
- } else {
819
- throw error
820
- }
821
- }
822
- }
823
-
824
- let sendCardSaleGasGen = async function (model, row) {
825
- // 1.存库 2.写卡
826
- let result = null
827
- try {
828
- let cardState = await hasCardGen()
829
- console.log('判卡函数返回:', cardState)
830
- if (JSON.parse(cardState.data).state === 1) {
831
- // 获取卡号
832
- let getCardNumber = {data: {cardNumber: null}}
833
- if (!row.f_card_id) {
834
- getCardNumber = await Vue.resetpost('rs/logic/getCardNumber', {data: {id: row.brand_id}}, {resolveMsg: null, rejectMsg: '发卡售气获取卡号失败!!'})
835
- console.log('获取卡号、、', getCardNumber)
836
- } else {
837
- getCardNumber.data.cardNumber = row.f_card_id
838
- console.log('档案自带卡号、、', getCardNumber)
839
- }
840
- if (getCardNumber.data.cardNumber) {
841
- // 当卡的别名是泰鹏普通卡的时候卡号和表号一致
842
- console.log('开始验证是不是泰鹏普通卡')
843
- if (row.f_alias && row.f_alias.includes('SmartCard_TP')) {
844
- model.cardNumber = row.f_meternumber
845
- } else if (row.f_alias && row.f_alias.includes('LaiDeRF')) {
846
- model.cardNumber = row.f_card_id
847
- } else {
848
- model.cardNumber = getCardNumber.data.cardNumber + ''
849
- }
850
- } else {
851
- throw new Error('获取卡号失败!请核实参数管理中的卡号重新发卡售气。')
852
- }
853
- // 存库
854
- result = await Vue.resetpost('rs/logic/sale_sendCardSaleGas_logic', {data: model}, {resolveMsg: null, rejectMsg: '发卡售气存库失败'})
855
- console.log('发卡售气存库返回', result)
856
- // 写卡
857
- let cardParams = await getParamGen(result.data.cardnumber, row.f_alias, row.f_user_id, row.f_userfiles_id)
858
-
859
- // 组织写卡数据
860
- let params = {
861
- factory: row.f_alias,
862
- kmm: '0', // 2019-12-22 查旭说的。给一个0 卡密码,写卡后返回新密码, 不论补卡还是先开户都没有密码
863
- kzt: '0', // 卡状态,0开户卡,1用户卡(0新开户,1补卡)
864
- kh: result.data.cardnumber, // 卡号
865
- yhh: row.f_meterid ? row.f_meterid : 0, // 用户号,档案中自己输
866
- ql: model.f_pregas, // 预购气量
867
- csql: '0', // 上次购气量,新开户为0
868
- ccsql: '0', // 上上次购气量,新开户为0
869
- cs: '1', // 求购气次数,先开户为1
870
- // ljgql: model.f_pregas, // 当前累计购气量
871
- bkcs: '0', // 新开户卡,为0
872
- ljyql: '0', // 累积用气量,有些表要累加原来用气量,新开户卡,为0
873
- bjql: row.f_police_gas, // 报警气量,t_gasbrand表中
874
- czsx: row.f_topup_ceil, // 充值上线,t_gasbrand表中
875
- tzed: row.f_overdr_lines, // 透支额度,t_gasbrand表中
876
- cssqrq: '0', // 上次售气日期,格式为YYYYMMDD
877
- meterid: row.f_meternumber, // 表号
878
- money: model.f_write_money, // 购气金额
879
- dqdm: row.f_area_code, // 精益工业地区代码
880
- klx: row.f_coding,
881
- ljgql: (row.f_write_totalgas - 0) + (model.f_pregas - 0), // 当前累计购气量
882
- ljgqje: (row.f_write_totalfee - 0) + (model.f_write_money - 0) // 累计购气金额
883
- }
884
- // 天源表发卡售气时,cs默认给0
885
- if (row.f_alias && row.f_alias.includes('TianYuan')) {
886
- console.log('天源表发卡售气时,写卡次数给:', params.cs)
887
- params.cs = '0'
888
- }
889
- // 判断是否是累购表
890
- if (row.f_support_purchase === '是') {
891
- params.ljgql = (row.f_write_totalgas - 0) + (model.f_pregas - 0)
892
- params.ljgqje = (row.f_write_totalfee - 0) + (model.f_preamount - 0)
893
- }
894
- params = Object.assign({}, Vue.CommonService.writeCardParams(cardParams), params)
895
- console.log('发卡售气写卡参数', params)
896
- let cardRes = await Vue.resetpost('http://127.0.0.1:8003/WriteNewCard', params, {
897
- resolveMsg: null,
898
- rejectMsg: '开户卡服务错误'
899
- })
900
- if (!cardParams || !result || cardRes.data.Err || cardRes.data.Exception) {
901
- // 写卡异常
902
- // 数据回滚操作
903
- throw `卡服务错误:${cardRes.data.Err}${cardRes.data.Exception},请联系开发人员处理!!`
904
- } else {
905
- // 写卡成功
906
- // 更新卡密码
907
- await Vue.CommonService.updatePassword(row, cardRes)
908
- Vue.showAlert('发卡售气成功', 'success', 2000)
909
- return result
910
- }
911
- } else {
912
- throw new Error(`请检查卡是否插好!!`)
913
- }
914
- } catch (error) {
915
- if (result) {
916
- // 出错进行回滚
917
- row.f_userfiles_id = row.f_userfiles_id + ''
918
- if (result) {
919
- await Vue.resetpost('rs/logic/salecardrollback', {data: {id: result.data.id, row: row}}, {
920
- resolveMsg: null,
921
- rejectMsg: '写卡失败,数据回滚失败,请联系技术人员处理!!'
922
- })
923
- }
924
- }
925
- if (error.data) {
926
- throw new Error(error.data)
927
- } else {
928
- throw error
929
- }
930
- }
931
- }
932
-
933
- let replaceCardGen2 = function * (model, row, allot) {
934
- let result = yield co(reissueCardGen(model, row))
935
- let data = {
936
- userfiles: {},
937
- record: {
938
- id: result.data.id,
939
- f_state: '有效'
940
- }
941
- }
942
- return yield Vue.resetpost('rs/logic/updatemark', {data: data}, {resolveMsg: '补卡成功', rejectMsg: '补卡修改状态失败'})
943
- }
944
- // 物联网表发卡管理
945
- let replaceCardGenWeb = function * (model, row) {
946
- let result = null
947
- let allotback
948
- try {
949
- // 判断是否有卡
950
- let cardState = yield co(hasCardGen())
951
- if (JSON.parse(cardState.data).state === 1) {
952
- let cardId = ''
953
- if (row.f_card_id && row.f_card_id !== 'null') {
954
- cardId = row.f_card_id
955
- } else {
956
- let getCardNumber = yield co(getCardNumberGen(row.f_gasbrand_id))
957
- console.log('获取卡号、、', getCardNumber)
958
- cardId = getCardNumber.data.cardNumber
959
- }
960
- if (row.f_tag) {
961
- // 截取用户编号后四位
962
- cardId = row.f_tag + row.f_card_id
963
- }
964
- model.f_card_id = cardId
965
- // 存库
966
- result = yield co(reissueCardGenJB(model, row))
967
- // 获取气价和售气情况参数
968
- let cardParams = yield co(getParamGen(cardId, row.f_alias, row.f_user_id, row.f_userfiles_id))
969
- // 写卡
970
- let params = {
971
- factory: row.f_alias,
972
- kh: cardId, // 卡号
973
- kmm: row.f_card_password, // 卡密码,写卡后返回新密码, 不论补卡还是先开户都没有密码
974
- bjql: row.f_police_gas, // 报警气量,t_gasbrand表中
975
- czsx: row.f_topup_ceil, // 充值上线,t_gasbrand表中
976
- tzed: row.f_overdr_lines, // 透支额度,t_gasbrand表中
977
- ljgql: (row.f_total_gas - 0), // 当前累计购气量
978
- ljgqje: (row.f_total_fee - 0), // 累计购气金额
979
- kzt: '1', // 卡状态,0开户卡,1用户卡(0新开户,1补卡)
980
- bkcs: row.f_fillcard_times + 1, // 补卡次数,从补卡表里通过表编号获得
981
- cs: row.f_times, // 求购气次数,先开户为1
982
- yhh: row.f_meterid ? row.f_meterid : 0, // 用户号
983
- meterid: row.f_meternumber, // 表号
984
- meternumber: row.f_meternumber,
985
- dqdm: row.f_area_code, // 精益工业地区代码
986
- money: 0, // 购气金额
987
- klx: row.f_coding
988
- }
989
- // 判断是否是累购表
990
- if (row.f_support_purchase === '是') {
991
- params.ljgql = (row.f_write_totalgas - 0) + (model.f_pregas - 0)
992
- params.ljgqje = (row.f_write_totalfee - 0) + (model.f_preamount - 0)
993
- }
994
- params = Object.assign({}, Vue.CommonService.writeCardParams(cardParams), params)
995
- console.log('补卡是写的次数。。。。', params)
996
- let cardRes = yield co(Vue.resetpost('http://127.0.0.1:8003/WriteNewCard', params, {
997
- resolveMsg: null,
998
- rejectMsg: '补卡卡服务错误'
999
- }))
1000
- // 卡服务写卡异常,业务逻辑回滚
1001
- if (!cardParams || !result || cardRes.data.Err || cardRes.data.Exception) {
1002
- Vue.$showAlert('物联网表补卡失败!!', 'danger', 0)
1003
- let rollbackParam = {
1004
- id: result.data.id,
1005
- f_card_id: row.f_card_id,
1006
- f_whether_hairpin: row.f_whether_hairpin,
1007
- f_user_id: row.f_user_id
1008
- }
1009
- if (row.f_tag) {
1010
- rollbackParam.f_tag = row.f_tag
1011
- }
1012
- yield Vue.resetpost('rs/logic/repairCardRoolBack', {data: rollbackParam}, {
1013
- resolveMsg: null,
1014
- rejectMsg: null
1015
- })
1016
- } else {
1017
- // 如果成功修改标识(更新状态为有效)
1018
- // 没有更新过表档案,这里版本号减一
1019
- row.version = (row.version - 0) - 1
1020
- yield co(Vue.CommonService.updatePassword(row, cardRes))
1021
- let data = {
1022
- userfiles: {
1023
- f_card_id: row.f_card_id,
1024
- f_whether_hairpin: '已发'
1025
- },
1026
- record: {
1027
- id: result.data.id,
1028
- f_state: '有效'
1029
- }
1030
- }
1031
- return yield Vue.resetpost('rs/logic/updatemark', {data: data}, {resolveMsg: '物联网表补卡成功', rejectMsg: '补卡修改状态失败'})
1032
- }
1033
- } else {
1034
- Vue.showAlert('请检查卡是否插好!!', 'danger', 3000)
1035
- }
1036
- } catch (error) {
1037
- let msg = ''
1038
- if (error.status === 612) {
1039
- msg = '请检查读卡器时候连接,或者卡服务是否启动!!'
1040
- } else {
1041
- msg = '补卡失败!!'
1042
-
1043
- let rollbackParam = {
1044
- id: result.data.id,
1045
- f_card_id: null,
1046
- f_whether_hairpin: row.f_whether_hairpin,
1047
- f_user_id: row.f_user_id
1048
- }
1049
- if (row.f_tag) {
1050
- rollbackParam.f_tag = row.f_tag
1051
- }
1052
- yield Vue.resetpost('rs/logic/repairCardRoolBack', {data: rollbackParam}, {
1053
- resolveMsg: null,
1054
- rejectMsg: '物联网表补卡失败!!'
1055
- })
1056
- }
1057
- Vue.showAlert(msg, 'danger', 0)
1058
- }
1059
- }
1060
- // 机表补卡管理
1061
- let replaceCardGenJB = function * (model, row) {
1062
- let result = null
1063
- let allotback
1064
- try {
1065
- // 判断是否有卡
1066
- let cardState = yield co(hasCardGen())
1067
- if (JSON.parse(cardState.data).state === 1) {
1068
- let cardId = row.f_card_id
1069
- if (row.f_tag) {
1070
- // 截取用户编号后四位
1071
- cardId = row.f_tag + row.f_card_id
1072
- }
1073
- model.f_card_id = cardId
1074
- // 存库
1075
- result = yield co(reissueCardGenJB(model, row))
1076
- // 获取气价和售气情况参数
1077
- let cardParams = yield co(getParamGen(cardId, row.f_alias, row.f_user_id, row.f_userfiles_id))
1078
- // 写卡
1079
- let params = {
1080
- factory: row.f_alias,
1081
- kh: cardId, // 卡号
1082
- kmm: row.f_card_password, // 卡密码,写卡后返回新密码, 不论补卡还是先开户都没有密码
1083
- bjql: row.f_police_gas, // 报警气量,t_gasbrand表中
1084
- czsx: row.f_topup_ceil, // 充值上线,t_gasbrand表中
1085
- tzed: row.f_overdr_lines, // 透支额度,t_gasbrand表中
1086
- ljgql: (row.f_total_gas - 0) + (model.f_pregas - 0), // 当前累计购气量
1087
- ljgqje: (row.f_total_fee - 0) + (model.f_preamount - 0), // 累计购气金额
1088
- kzt: '1', // 卡状态,0开户卡,1用户卡(0新开户,1补卡)
1089
- bkcs: row.f_fillcard_times + 1, // 补卡次数,从补卡表里通过表编号获得
1090
- cs: row.f_times, // 求购气次数,先开户为1
1091
- yhh: row.f_meterid ? row.f_meterid : 0, // 用户号
1092
- meterid: row.f_meternumber, // 表号
1093
- meternumber: row.f_meternumber,
1094
- dqdm: row.f_area_code, // 精益工业地区代码
1095
- money: 0, // 购气金额
1096
- klx: row.f_coding
1097
- }
1098
- // 判断是否是累购表
1099
- if (row.f_support_purchase === '是') {
1100
- params.ljgql = (row.f_write_totalgas - 0) + (model.f_pregas - 0)
1101
- params.ljgqje = (row.f_write_totalfee - 0) + (model.f_preamount - 0)
1102
- }
1103
- params = Object.assign({}, Vue.CommonService.writeCardParams(cardParams), params)
1104
- console.log('补卡是写的次数。。。。', params)
1105
- let cardRes = yield co(Vue.resetpost('http://127.0.0.1:8003/WriteNewCard', params, {
1106
- resolveMsg: null,
1107
- rejectMsg: '补卡卡服务错误'
1108
- }))
1109
- // 卡服务写卡异常,业务逻辑回滚
1110
- if (!cardParams || !result || cardRes.data.Err || cardRes.data.Exception) {
1111
- Vue.$showAlert('机表补卡失败!!', 'danger', 0)
1112
- let rollbackParam = {
1113
- id: result.data.id,
1114
- f_card_id: row.f_card_id,
1115
- f_whether_hairpin: row.f_whether_hairpin,
1116
- f_user_id: row.f_user_id
1117
- }
1118
- if (row.f_tag) {
1119
- rollbackParam.f_tag = row.f_tag
1120
- }
1121
- yield Vue.resetpost('rs/logic/repairCardRoolBack', {data: rollbackParam}, {
1122
- resolveMsg: null,
1123
- rejectMsg: null
1124
- })
1125
- } else {
1126
- // 如果成功修改标识(更新状态为有效)
1127
- // 没有更新过表档案,这里版本号减一
1128
- row.version = (row.version - 0) - 1
1129
- yield co(Vue.CommonService.updatePassword(row, cardRes))
1130
- let data = {
1131
- userfiles: {
1132
- f_card_id: row.f_card_id,
1133
- f_whether_hairpin: '已发'
1134
- },
1135
- record: {
1136
- id: result.data.id,
1137
- f_state: '有效'
1138
- }
1139
- }
1140
- return yield Vue.resetpost('rs/logic/updatemark', {data: data}, {resolveMsg: '机表补卡成功', rejectMsg: '补卡修改状态失败'})
1141
- }
1142
- } else {
1143
- Vue.showAlert('请检查卡是否插好!!', 'danger', 3000)
1144
- }
1145
- } catch (error) {
1146
- let msg = ''
1147
- if (error.status === 612) {
1148
- msg = '请检查读卡器时候连接,或者卡服务是否启动!!'
1149
- } else {
1150
- msg = '补卡失败!!'
1151
-
1152
- let rollbackParam = {
1153
- id: result.data.id,
1154
- f_card_id: null,
1155
- f_whether_hairpin: row.f_whether_hairpin,
1156
- f_user_id: row.f_user_id
1157
- }
1158
- if (row.f_tag) {
1159
- rollbackParam.f_tag = row.f_tag
1160
- }
1161
- yield Vue.resetpost('rs/logic/repairCardRoolBack', {data: rollbackParam}, {
1162
- resolveMsg: null,
1163
- rejectMsg: '机表补卡失败!!'
1164
- })
1165
- }
1166
- Vue.showAlert(msg, 'danger', 0)
1167
- }
1168
- }
1169
- // 擦虚气
1170
- let replaceXq = function * (model, row) {
1171
- let result = null
1172
- let cardState = yield co(hasCardGen())
1173
- if (JSON.parse(cardState.data).state === 1) {
1174
- let params = {
1175
- factory: row.f_alias,
1176
- kh: row.f_card_id, // 卡号
1177
- kmm: row.f_card_password, // 卡密码,写卡后返回新密码, 不论补卡还是先开户都没有密码
1178
- bjql: row.f_police_gas, // 报警气量,t_gasbrand表中
1179
- czsx: row.f_topup_ceil, // 充值上线,t_gasbrand表中
1180
- tzed: row.f_overdr_lines, // 透支额度,t_gasbrand表中
1181
- ljgql: (row.f_total_gas - 0), // 当前累计购气量
1182
- ljgqje: (row.f_total_fee - 0), // 累计购气金额
1183
- kzt: '1', // 卡状态,0开户卡,1用户卡(0新开户,1补卡)
1184
- bkcs: row.f_fillcard_times + 1, // 补卡次数,从补卡表里通过表编号获得
1185
- cs: row.f_times, // 求购气次数,先开户为1
1186
- yhh: row.f_meterid ? row.f_meterid : 0, // 用户号
1187
- meterid: row.f_meternumber, // 表号
1188
- meternumber: row.f_meternumber,
1189
- dqdm: row.f_area_code, // 精益工业地区代码
1190
- money: 0, // 购气金额
1191
- klx: row.f_coding
1192
- }
1193
- let cardRes = yield co(Vue.resetpost('http://127.0.0.1:8003/WriteNewCard', params, {
1194
- resolveMsg: null,
1195
- rejectMsg: '擦虚气服务错误'
1196
- }))
1197
- if (cardRes.data.Err || cardRes.data.Exception) {
1198
- return {status: 1}
1199
- } else {
1200
- return {status: 0}
1201
- }
1202
- } else {
1203
- Vue.showAlert('请检查卡是否插好!!', 'danger', 3000)
1204
- }
1205
- }
1206
-
1207
- // 补卡管理
1208
- let replaceCardGen = function * (model, row, allot) {
1209
- let result = null
1210
- let allotback
1211
- try {
1212
- // 判断是否有卡
1213
- let cardState = yield co(hasCardGen())
1214
- if (JSON.parse(cardState.data).state === 1) {
1215
- let cardId = row.f_card_id
1216
- // 如果当前是物联网表,表未发卡,进行补需要获取卡号
1217
- if (!(row.f_hascard == null) && !(row.f_share_times == null) && row.f_meter_type === '物联网表' && row.f_hascard === '是' && row.f_share_times === '是' && (row.f_card_id == null || row.f_card_id === '')) {
1218
- let getCardNumber = yield Vue.resetpost('rs/logic/getCardNumber', {data: {id: row.brand_id}}, {resolveMsg: null, rejectMsg: '发卡售气获取卡号失败!!'})
1219
- console.log('获取卡号、、', getCardNumber)
1220
- if (getCardNumber.data.cardNumber) {
1221
- cardId = getCardNumber.data.cardNumber
1222
- } else {
1223
- throw new Error('获取卡号失败!请核实参数管理中的卡号重新发卡售气。')
1224
- }
1225
- }
1226
- if (row.f_tag) {
1227
- // 截取用户编号后四位
1228
- cardId = row.f_tag + row.f_card_id
1229
- }
1230
- model.f_card_id = cardId
1231
- // 存库
1232
- result = yield co(reissueCardGen(model, row))
1233
- if (allot) {
1234
- allotback = yield Vue.resetpost('rs/logic/saveAllotData', {data: allot}, {
1235
- resolveMsg: null,
1236
- rejectMsg: '更新发卡信息失败'
1237
- })
1238
- }
1239
- // 获取气价和售气情况参数
1240
- let cardParams = yield co(getParamGen(cardId, row.f_alias, row.f_user_id, row.f_userfiles_id))
1241
- console.log('补卡是写的次数111。。。。', row, model)
1242
- // 写卡
1243
- let params = {
1244
- factory: row.f_alias,
1245
- kh: cardId, // 卡号
1246
- kmm: row.f_card_password, // 卡密码,写卡后返回新密码, 不论补卡还是先开户都没有密码
1247
- bjql: row.f_police_gas, // 报警气量,t_gasbrand表中
1248
- czsx: row.f_topup_ceil, // 充值上线,t_gasbrand表中
1249
- tzed: row.f_overdr_lines, // 透支额度,t_gasbrand表中
1250
- ljgql: (row.f_total_gas - 0), // 当前累计购气量
1251
- ljgqje: (row.f_total_fee - 0), // 累计购气金额
1252
- kzt: '1', // 卡状态,0开户卡,1用户卡(0新开户,1补卡)
1253
- bkcs: row.f_fillcard_times + 1, // 补卡次数,从补卡表里通过表编号获得
1254
- cs: row.f_times, // 求购气次数,先开户为1
1255
- yhh: row.f_meterid ? row.f_meterid : 0, // 用户号
1256
- meterid: row.f_meternumber, // 表号
1257
- meternumber: row.f_meternumber,
1258
- dqdm: row.f_area_code, // 精益工业地区代码
1259
- money: 0, // 购气金额
1260
- klx: row.f_coding
1261
- }
1262
- // 判断是否是累购表
1263
- if (row.f_support_purchase === '是') {
1264
- params.ljgql = (row.f_write_totalgas - 0)
1265
- params.ljgqje = (row.f_write_totalfee - 0)
1266
- }
1267
- // 判断是否接表,如果未接表(次数减一)已过表(次数为档案里面的次数) 针对不补气的
1268
- if (model.f_ispick_table) {
1269
- params.cs = (model.f_ispick_table === '未过表' ? row.f_times - 1 : row.f_times)
1270
- }
1271
-
1272
- params = Object.assign({}, Vue.CommonService.writeCardParams(cardParams), params)
1273
- // if (row.f_alias === 'HaiLiJE' || row.f_alias === 'HaiLiQL' || row.f_alias === 'CangNanTY') {
1274
- // params.klx = yield co(getmodelbrandGen(row))
1275
- // params.klx = params.klx.data[0].f_coding
1276
- // }
1277
- console.log('补卡是写的次数。。。。', params)
1278
-
1279
- let cardRes = yield co(Vue.resetpost('http://127.0.0.1:8003/WriteNewCard', params, {
1280
- resolveMsg: null,
1281
- rejectMsg: '补卡卡服务错误'
1282
- }))
1283
- // 卡服务写卡异常,业务逻辑回滚
1284
- if (!cardParams || !result || cardRes.data.Err || cardRes.data.Exception) {
1285
- Vue.$showAlert('补卡失败!!', 'danger', 0)
1286
- let rollbackParam = {
1287
- id: result.data.id,
1288
- f_card_id: row.f_card_id,
1289
- f_user_id: row.f_user_id
1290
- }
1291
- if (row.f_tag) {
1292
- rollbackParam.f_tag = row.f_tag
1293
- }
1294
- yield Vue.resetpost('rs/logic/repairCardRoolBack', {data: rollbackParam}, {
1295
- resolveMsg: null,
1296
- rejectMsg: null
1297
- })
1298
- // 更新卡状态为作废
1299
- if (allot) {
1300
- yield Vue.resetpost('rs/logic/allotDataRollback', {data: allotback.data}, {resolveMsg: null, rejectMsg: null})
1301
- }
1302
- } else {
1303
- // 如果成功修改标识(更新状态为有效)
1304
- // 没有更新过表档案,这里版本号减一
1305
- row.version = (row.version - 0) - 1
1306
- yield co(Vue.CommonService.updatePassword(row, cardRes))
1307
- let data = {
1308
- userfiles: {},
1309
- record: {
1310
- id: result.data.id,
1311
- f_state: '有效'
1312
- }
1313
- }
1314
- return yield Vue.resetpost('rs/logic/updatemark', {data: data}, {resolveMsg: '补卡成功', rejectMsg: '补卡修改状态失败'})
1315
- }
1316
- } else {
1317
- Vue.showAlert('请检查卡是否插好!!', 'danger', 3000)
1318
- }
1319
- } catch (error) {
1320
- let msg = ''
1321
- if (error.status === 612) {
1322
- msg = '请检查读卡器时候连接,或者卡服务是否启动!!'
1323
- } else {
1324
- msg = '补卡失败!!'
1325
-
1326
- let rollbackParam = {
1327
- id: result.data.id,
1328
- f_card_id: row.f_card_id,
1329
- f_user_id: row.f_user_id
1330
- }
1331
- if (row.f_tag) {
1332
- rollbackParam.f_tag = row.f_tag
1333
- }
1334
- yield Vue.resetpost('rs/logic/repairCardRoolBack', {data: rollbackParam}, {
1335
- resolveMsg: null,
1336
- rejectMsg: '补卡失败!!'
1337
- })
1338
- }
1339
- // 更新卡状态为作废
1340
- if (allot) {
1341
- yield Vue.resetpost('rs/logic/allotDataRollback', {data: allotback.data}, {resolveMsg: null, rejectMsg: null})
1342
- }
1343
- Vue.showAlert(msg, 'danger', 0)
1344
- }
1345
- }
1346
-
1347
- let offlineWriteGen2 = async function (row) {
1348
- let update = {
1349
- id: row.unWriteSell[0].id,
1350
- f_write_operator: Vue.$login.f.name,
1351
- f_write_date: Vue.$login.toStandardTimeString()
1352
- }
1353
- await Vue.resetpost('rs/logic/offlineWrite', update, {resolveMsg: '写卡成功', rejectMsg: '写卡成功,更新数据失败'})
1354
- }
1355
-
1356
- let offlineWriteGen = async function (row) {
1357
- console.log('线下写卡', row)
1358
- try {
1359
- // 写卡前调用(该为特殊业务逻辑根据需要写到project工程) (有些第三方缴费柜台写卡,用户缴费之后,如果在规定时间内不写卡,就会进行退款。所以写卡前调用第三方锁定订单。写卡成功或失败调用对应的接口告知第三方)
1360
-
1361
- let beforeParam = {
1362
- id: row.unWriteSell[0].id,
1363
- f_operatorid: Vue.$login.f.id,
1364
- f_depid: Vue.$login.f.depids
1365
- }
1366
-
1367
- await Vue.resetpost('rs/logic/sale_write_before', {data: beforeParam}, {resolveMsg: null, rejectMsg: '线下写卡前调用第三方失败!!'})
1368
-
1369
- let cardState = await hasCardGen()
1370
- if (JSON.parse(cardState.data).state === 1) {
1371
- // 获取
1372
- let result = await Vue.resetpost('rs/logic/sale_getLastOper', {data: {f_userfiles_id: row.f_userfiles_id}}, {resolveMsg: null, rejectMsg: '获取最后一次操作失败'})
1373
- console.log('获取最后一次的操作。。', result)
1374
- // 先把收费记录状态改成 已写卡在进行操作
1375
- // 写卡成功 更新收费记录
1376
- let update = {
1377
- id: row.unWriteSell[0].id,
1378
- f_write_comments: !row.f_write_comments ? '' : row.f_write_comments,
1379
- f_write_operator: Vue.$login.f.name,
1380
- f_write_date: Vue.$login.toStandardTimeString()
1381
- }
1382
- await Vue.resetpost('rs/logic/offlineWrite', update, {resolveMsg: '写卡成功', rejectMsg: '写卡成功,更新数据失败'})
1383
- let cardid = row.f_card_id
1384
- if (row.f_tag) {
1385
- // 截取用户编号后四位
1386
- cardid = row.f_tag + row.f_card_id
1387
- }
1388
- // 执行写卡操作
1389
- let cardParams = await getParamGen(row.f_card_id, row.f_alias, row.f_user_id, row.f_userfiles_id)
1390
- let param = {
1391
- factory: row.f_alias,
1392
- kh: cardid,
1393
- cs: row.unWriteSell[0].f_times,
1394
- yhh: row.cardInfo.Yhh ? row.cardInfo.Yhh : row.f_meterid,
1395
- meterid: row.f_meternumber ? row.f_meternumber : 0,
1396
- meternumber: row.f_meternumber ? row.f_meternumber : 0,
1397
- kmm: row.f_card_password,
1398
- ljgql: (row.f_write_totalgas - 0), // 当前累计购气量
1399
- ljgqje: (row.f_write_totalfee - 0), // 累计购气金额
1400
- bjql: row.f_police_gas,
1401
- czsx: row.f_topup_ceil,
1402
- tzed: row.f_overdr_lines,
1403
- bkcs: row.f_fillcard_times,
1404
- dqdm: row.f_area_code,
1405
- klx: row.f_coding,
1406
- ql: row.unWriteSell[0].f_pregas,
1407
- money: row.unWriteSell[0].f_write_money
1408
- }
1409
- param = Object.assign({}, Vue.CommonService.writeCardParams(cardParams), param)
1410
- let cardRes
1411
- if (result.data.last_oper == null) result.data.last_oper = ''
1412
- if (row.states === '补卡' || result.data.last_oper === '补卡') {
1413
- param.kzt = result.data.ispick === '未过表' && result.data.lastsell_oper === '发卡售气' ? '0' : '1'
1414
- param.cs = row.cardInfo.Times + 1
1415
- param.bkcs = param.bkcs + 1
1416
- cardRes = await Vue.resetpost('http://127.0.0.1:8003/WriteNewCard', param, {resolveMsg: null, rejectMsg: '写卡失败'})
1417
- } else if (row.states === '换表') {
1418
- param.kzt = '0'
1419
- param.bkcs = param.bkcs + 1
1420
- param.cs = 1
1421
- cardRes = await Vue.resetpost('http://127.0.0.1:8003/WriteNewCard', param, {resolveMsg: null, rejectMsg: '写卡失败'})
1422
- } else {
1423
- cardRes = await Vue.resetpost('http://127.0.0.1:8003/WriteGasCard', param, {resolveMsg: null, rejectMsg: '写卡失败'})
1424
- }
1425
- if (!cardParams || cardRes.data.Err || cardRes.data.Exception) {
1426
- let sql = `update t_sellinggas set
1427
- f_write_card = '未写卡'
1428
- where id = '${row.unWriteSell[0].id}'`
1429
- let data = {
1430
- sql: sql
1431
- }
1432
- await Vue.resetpost('rs/logic/runSQL', data)
1433
- throw new Error(`卡服务错误:${cardRes.data.Err}${cardRes.data.Exception},请联系开发人员处理!!`)
1434
- }
1435
- } else {
1436
- Vue.showAlert('请检查卡是否插好!!', 'danger', 3000)
1437
- }
1438
- } catch (error) {
1439
- // 考虑到这里报错可能是因为 写卡请求超时报的错,但是请求已经发到卡服务,可能已经写上卡,所以先不做处理
1440
- // let sql = `update t_sellinggas set
1441
- // f_write_card = '未写卡',
1442
- // where id = '${row.unWriteSell[0].id}'`
1443
- // let data = {
1444
- // sql: sql
1445
- // }
1446
- // await this.$resetpost('rs/logic/runSQL', data)
1447
- throw error
1448
- }
1449
- }
1450
-
1451
- let DigtialSellGasGen = async function (model, row) {
1452
- try {
1453
- let result = await Vue.resetpost('rs/logic/sale_digtialCharge_logic', {data: model}, {resolveMsg: '收费成功', rejectMsg: '卡表收费存库失败'})
1454
- return result.data.id
1455
- } catch (error) {
1456
- if (error.data) {
1457
- throw new Error(error.data)
1458
- } else {
1459
- throw error
1460
- }
1461
- }
1462
- }
1463
- let noCardSellGasGen = async function (model, row) {
1464
- try {
1465
- let result = await Vue.resetpost('rs/logic/sale_cardCharge_logic', {data: model}, {resolveMsg: '收费成功', rejectMsg: '卡表收费存库失败'})
1466
- return result.data.id
1467
- } catch (error) {
1468
- if (error.data) {
1469
- throw new Error(error.data)
1470
- } else {
1471
- throw error
1472
- }
1473
- }
1474
- }
1475
-
1476
- // 补气卡表收费
1477
- let sellgasRemanentGen = async function (model, row) {
1478
- let result = null
1479
- try {
1480
- let cardState = await hasCardGen()
1481
- if (JSON.parse(cardState.data).state === 1) {
1482
- // 将卡上次数写入数据库
1483
- model.f_times = row.cardInfo.Times + 1
1484
- // 将回写表号或者用户号
1485
- model.f_meterid = row.cardInfo.Yhh ? row.cardInfo.Yhh : row.f_meterid
1486
-
1487
- let cardid = row.f_card_id
1488
- if (row.f_tag) {
1489
- // 截取用户编号后四位
1490
- cardid = model.f_card_id = row.f_tag + row.f_card_id
1491
- }
1492
- result = await Vue.resetpost('rs/logic/sellgasRemanentGas', {data: model}, {resolveMsg: null, rejectMsg: '卡表收费存库失败'})
1493
- // 获取气价和售气情况参数
1494
- let cardParams = await getParamGen(cardid, row.f_alias, row.f_user_id, row.f_userfiles_id)
1495
- console.log('写卡次数和获取的写卡参数...', row.cardInfo.Times, cardParams)
1496
- // 写卡
1497
- let params = {
1498
- factory: row.f_alias, // 气表厂家
1499
- kh: cardid, // 卡号
1500
- yhh: row.f_meterid ? row.f_meterid : 0, // 用户号,档案中自己输
1501
- kmm: row.f_card_password, // 卡密码,写卡后返回新密码, 不论补卡还是先开户都没有密码
1502
- bjql: row.f_police_gas, // 报警气量,t_gasbrand表中
1503
- czsx: row.f_topup_ceil, // 充值上线,t_gasbrand表中
1504
- tzed: row.f_overdr_lines, // 透支额度,t_gasbrand表中
1505
- ljgql: (row.f_write_totalgas - 0) + (model.f_pregas - 0), // 当前累计购气量
1506
- ljgqje: (row.f_write_totalfee - 0) + (model.f_write_money - 0), // 累计购气金额
1507
- bkcs: row.f_fillcard_times, // 补卡次数,从补卡表里通过表编号获得
1508
- ql: model.f_pregas, // 预购气量
1509
- cs: row.cardInfo.Times + 1, // 求购气次数,先开户为1
1510
- money: model.f_write_money, // 购气金额
1511
- meterid: row.f_meternumber ? row.f_meternumber : 0, // 表号
1512
- dqdm: row.f_area_code, // 精益工业地区代码
1513
- klx: row.f_coding
1514
- }
1515
- params = Object.assign({}, Vue.CommonService.writeCardParams(cardParams), params)
1516
- console.log('购气最后操作。。', result)
1517
- let cardRes = await Vue.resetpost('http://127.0.0.1:8003/WriteGasCard', params, {resolveMsg: null, rejectMsg: '卡表收费失败'})
1518
- console.log('卡表收费返回写卡参数值', cardRes)
1519
- // 卡服务写卡异常,业务逻辑回滚
1520
- if (!cardParams || ((model.f_pregas > model.f_remanent_gas) && !result) || cardRes.data.Err || cardRes.data.Exception) {
1521
- let data = {
1522
- id: result.data.id,
1523
- userinfo: {
1524
- f_userinfo_id: row.f_userinfo_id,
1525
- version: row.userinfo_version + 1,
1526
- f_balance: row.f_balance,
1527
- userfiles: {
1528
- f_user_id: model.f_user_id,
1529
- f_userfiles_id: model.f_userfiles_id,
1530
- f_card_id: row.f_card_id,
1531
- f_total_gas: row.f_total_gas,
1532
- f_write_totalgas: row.f_write_totalgas,
1533
- f_write_totalfee: row.f_write_totalfee,
1534
- f_total_fee: row.f_total_fee,
1535
- f_times: row.cardInfo.Times,
1536
- version: row.version + 1
1537
- }
1538
- }
1539
- }
1540
- if (row.f_tag) {
1541
- data.userinfo.userfiles.f_tag = row.f_tag
1542
- }
1543
- await Vue.resetpost('rs/logic/sellgasremanentRollback', {data: data}, {resolveMsg: null, rejectMsg: '卡表收费回滚出错!!'})
1544
- throw new Error(`卡服务错误:${cardRes.data.Err}${cardRes.data.Exception},请联系开发人员处理!!`)
1545
- } else {
1546
- // 更新卡密码
1547
- await Vue.CommonService.updatePassword(row, cardRes)
1548
- Vue.showAlert('换表补气成功', 'success', 2000)
1549
- return result
1550
- }
1551
- } else {
1552
- throw new Error(`请检查卡是否插好!!`)
1553
- }
1554
- } catch (error) {
1555
- if (result) {
1556
- let data = {
1557
- sellid: result.data.sellid,
1558
- fillgasid: result.data.fillgasid,
1559
- userinfo: {
1560
- f_userinfo_id: row.f_userinfo_id,
1561
- version: row.userinfo_version + 1,
1562
- f_balance: row.f_balance,
1563
- userfiles: {
1564
- f_user_id: model.f_user_id,
1565
- f_total_gas: row.f_total_gas,
1566
- f_write_totalgas: row.f_write_totalgas,
1567
- f_write_totalfee: row.f_write_totalfee,
1568
- f_total_fee: row.f_total_fee,
1569
- f_card_id: row.f_card_id,
1570
- f_times: row.cardInfo.Times,
1571
- version: row.version + 1
1572
- }
1573
- }
1574
- }
1575
- if (row.f_tag) {
1576
- data.userinfo.userfiles.f_tag = row.f_tag
1577
- }
1578
- await Vue.resetpost('rs/logic/sellgasremanentRollback', {data: data}, {resolveMsg: '卡表收费失败', rejectMsg: '卡表收费失败'})
1579
- }
1580
- throw error
1581
- }
1582
- }
1583
- // 余量补差
1584
- let marginGen = async function (model, row) {
1585
- let result = null
1586
- let cardparam
1587
- let cardpost
1588
- try {
1589
- let cardState = await hasCardGen()
1590
- if (JSON.parse(cardState.data).state === 1) {
1591
- // 将卡上次数写入数据库
1592
- if (!(row.f_hascard == null) && !(row.f_share_times == null) && row.f_hascard === '是' && row.f_share_times === '是') {
1593
- model.f_times = row.f_times + 1
1594
- } else {
1595
- model.f_times = row.cardInfo.Times + 1
1596
- }
1597
- // 将回写表号或者用户号
1598
- model.f_meterid = row.cardInfo.Yhh ? row.cardInfo.Yhh : row.f_meterid
1599
-
1600
- let cardid = row.f_card_id
1601
- if (row.f_tag) {
1602
- // 截取用户编号后四位
1603
- cardid = model.f_card_id = row.f_tag + row.f_card_id
1604
- }
1605
- // 存库
1606
- result = await Vue.resetpost('rs/logic/marginCharge', {data: model}, {resolveMsg: null, rejectMsg: '卡表收费存库失败'})
1607
- // 获取气价和售气情况参数
1608
- let cardParams = await getParamGen(cardid, row.f_alias, row.f_user_id, row.f_userfiles_id)
1609
- console.log('写卡次数和获取的写卡参数...', row.cardInfo.Times, cardParams)
1610
- // 写卡
1611
- let params = {
1612
- factory: row.f_alias, // 气表厂家
1613
- kh: cardid, // 卡号
1614
- yhh: row.f_meterid ? row.f_meterid : 0, // 用户号,档案中自己输
1615
- kmm: row.f_card_password, // 卡密码,写卡后返回新密码, 不论补卡还是先开户都没有密码
1616
- bjql: row.f_police_gas,
1617
- ljgql: (row.f_write_totalgas - 0) + (model.f_pregas - 0), // 当前累计购气量
1618
- ljgqje: (row.f_write_totalfee - 0) + (model.f_write_money - 0), // 累计购气金额
1619
- czsx: row.f_topup_ceil, // 充值上线,t_gasbrand表中
1620
- tzed: row.f_overdr_lines, // 透支额度,t_gasbrand表中
1621
- bkcs: row.f_fillcard_times, // 补卡次数,从补卡表里通过表编号获得
1622
- ql: model.f_pregas, // 预购气量
1623
- cs: row.cardInfo.Times + 1, // 求购气次数,先开户为1
1624
- money: model.f_write_money, // 购气金额
1625
- dqdm: row.f_area_code, // 精益工业地区代码
1626
- klx: row.f_coding,
1627
- meterid: row.f_meternumber ? row.f_meternumber : 0 // 表号
1628
- }
1629
- params = Object.assign({}, Vue.CommonService.writeCardParams(cardParams), params)
1630
- // if (row.f_alias === 'HaiLiJE' || row.f_alias === 'HaiLiQL' || row.f_alias === 'CangNanTY') {
1631
- // params.klx = yield co(getmodelbrandGen(row))
1632
- // params.klx = params.klx.data[0].f_coding
1633
- // }
1634
-
1635
- let params2 = {
1636
- factory: row.f_alias,
1637
- kh: cardid, // 卡号
1638
- kmm: row.f_card_password, // 卡密码,写卡后返回新密码, 不论补卡还是先开户都没有密码
1639
- bjql: row.f_police_gas, // 报警气量,t_gasbrand表中
1640
- czsx: row.f_topup_ceil, // 充值上线,t_gasbrand表中
1641
- tzed: row.f_overdr_lines, // 透支额度,t_gasbrand表中
1642
- ljgql: (row.f_write_totalgas - 0) + (model.f_pregas - 0), // 当前累计购气量
1643
- ljgqje: (row.f_write_totalfee - 0) + (model.f_write_money - 0), // 累计购气金额
1644
- kzt: '1', // 卡状态,0开户卡,1用户卡(0新开户,1补卡)
1645
- bkcs: row.f_fillcard_times, // 补卡次数,从补卡表里通过表编号获得
1646
- ql: model.f_pregas, // 预购气量
1647
- cs: row.cardInfo.Times + 1, // 求购气次数,先开户为1
1648
- sxrq: model.f_startdate, // 生效日期,价格管理中取
1649
- meterid: row.f_meternumber ? row.f_meternumber : 0, // 表号
1650
- // meternumber: row.f_meternumber ? row.f_meternumber : 0, // 海力金额表号
1651
- dqdm: row.f_area_code, // 精益工业地区代码
1652
- money: model.f_write_money, // 购气金额
1653
- klx: row.f_coding
1654
- }
1655
-
1656
- params2 = Object.assign({}, Vue.CommonService.writeCardParams(cardParams), params2)
1657
- // if (row.f_alias === 'HaiLiJE' || row.f_alias === 'HaiLiQL' || row.f_alias === 'CangNanTY') {
1658
- // params2.klx = yield co(getmodelbrandGen(row))
1659
- // params2.klx = params2.klx.data[0].f_coding
1660
- // }
1661
-
1662
- let params3 = {
1663
- factory: row.f_alias,
1664
- kh: cardid, // 卡号
1665
- kmm: row.f_card_password, // 卡密码,写卡后返回新密码, 不论补卡还是先开户都没有密码
1666
- bjql: row.f_police_gas, // 报警气量,t_gasbrand表中
1667
- czsx: row.f_topup_ceil, // 充值上线,t_gasbrand表中
1668
- tzed: row.f_overdr_lines, // 透支额度,t_gasbrand表中
1669
- ljgql: (row.f_write_totalgas - 0) + (model.f_pregas - 0), // 当前累计购气量
1670
- ljgqje: (row.f_write_totalfee - 0) + (model.f_write_money - 0), // 累计购气金额
1671
- kzt: '0', // 卡状态,0开户卡,1用户卡(0新开户,1补卡)
1672
- bkcs: row.f_fillcard_times, // 补卡次数,从补卡表里通过表编号获得
1673
- ql: model.f_pregas, // 预购气量
1674
- cs: 1, // 求购气次数,先开户为1
1675
- sxrq: model.f_startdate, // 生效日期,价格管理中取
1676
- meterid: row.f_meternumber ? row.f_meternumber : 0, // 表号
1677
- // meternumber: row.f_meternumber ? row.f_meternumber : 0, // 海力金额表号
1678
- dqdm: row.f_area_code, // 精益工业地区代码
1679
- money: model.f_write_money, // 购气金额
1680
- klx: row.f_coding
1681
- }
1682
- params3 = Object.assign({}, Vue.CommonService.writeCardParams(cardParams), params3)
1683
- // if (row.f_alias === 'HaiLiJE' || row.f_alias === 'HaiLiQL' || row.f_alias === 'CangNanTY') {
1684
- // params3.klx = yield co(getmodelbrandGen(row))
1685
- // params3.klx = params3.klx.data[0].f_coding
1686
- // }
1687
- console.log('购气最后操作。。', result)
1688
- if (!(row.f_hascard == null) && !(row.f_share_times == null) && row.f_meter_type === '物联网表' && row.f_hascard === '是' && row.f_share_times === '是') {
1689
- params.cs = row.f_times + 1
1690
- params2.cs = row.f_times + 1
1691
- }
1692
- let cardRes
1693
- if (result.data.last_oper === '补卡') {
1694
- // 此次验证开户之后未过表补卡验证问题
1695
- params2.kzt = result.data.ispick === '未过表' && result.data.lastsell_oper === '发卡售气' ? '0' : '1'
1696
- cardparam = JSON.stringify(params2)
1697
- cardpost = 'WriteNewCard'
1698
- cardRes = await Vue.resetpost('http://127.0.0.1:8003/WriteNewCard', params2, {resolveMsg: null, rejectMsg: '卡表收费失败'})
1699
- } else if (result.data.last_oper === '换表') {
1700
- console.log('我走的是写新卡换表')
1701
- cardparam = JSON.stringify(params3)
1702
- cardpost = 'WriteNewCard'
1703
- cardRes = await Vue.resetpost('http://127.0.0.1:8003/WriteNewCard', params3, {resolveMsg: null, rejectMsg: '卡表收费失败'})
1704
- } else if (result.data.last_oper === '换表补气') {
1705
- // 累购金额需要将上次购气金额加上
1706
- console.log('我走的是正常的收费', params)
1707
- cardparam = JSON.stringify(params)
1708
- cardpost = 'WriteGasCard'
1709
- cardRes = await Vue.resetpost('http://127.0.0.1:8003/WriteGasCard', params, {resolveMsg: null, rejectMsg: '卡表收费失败'})
1710
- } else {
1711
- console.log('我走的是正常的收费', params)
1712
- cardparam = JSON.stringify(params)
1713
- cardpost = 'WriteGasCard'
1714
- cardRes = await Vue.resetpost('http://127.0.0.1:8003/WriteGasCard', params, {resolveMsg: null, rejectMsg: '卡表收费失败'})
1715
- }
1716
- console.log('卡表收费返回写卡参数值', cardRes)
1717
- // 卡服务写卡异常,业务逻辑回滚
1718
- if (!cardParams || !result || cardRes.data.Err || cardRes.data.Exception) {
1719
- throw `卡服务错误:${cardRes.data.Err}${cardRes.data.Exception},请联系开发人员处理!!`
1720
- } else {
1721
- // 调用读卡进行校验
1722
- let readCardInfo = await Vue.resetpost('http://127.0.0.1:8003/ReadCard', {kmm: row.f_card_password}, {resolveMsg: null, rejectMsg: '读卡失败!!'})
1723
- if (readCardInfo.data && Vue.$login.r.includes('读卡2')) {
1724
- console.log('读卡验证', readCardInfo.data, row)
1725
- if (row.f_collection_type === '按金额') {
1726
- if (readCardInfo.data.Money !== model.f_preamount || readCardInfo.data.Factory !== row.f_alias || readCardInfo.data.CardID !== row.f_card_id) {
1727
- Vue.showAlert('读卡参数和缴费参数不一致,请核实!!', 'warning', 2000)
1728
- return result.data.id
1729
- }
1730
- } else {
1731
- if (readCardInfo.data.Gas !== Number((model.f_pregas - 0).toFixed(2)) || readCardInfo.data.Factory !== row.f_alias || readCardInfo.data.CardID !== row.f_card_id) {
1732
- Vue.showAlert('读卡参数和缴费参数不一致,请核实!!', 'warning', 2000)
1733
- return result.data.id
1734
- }
1735
- }
1736
- }
1737
- // 更新卡密码
1738
- await Vue.CommonService.updatePassword(row, cardRes)
1739
- Vue.showAlert('售气成功', 'success', 2000)
1740
- return result.data.id
1741
- }
1742
- } else {
1743
- throw new Error(`请检查卡是否插好!!`)
1744
- }
1745
- } catch (error) {
1746
- if (result) {
1747
- let data = {
1748
- cardparam: cardparam,
1749
- cardpost: cardpost,
1750
- id: result.data.id,
1751
- userinfo: {
1752
- f_userinfo_id: row.f_userinfo_id,
1753
- version: row.userinfo_version + 1,
1754
- f_balance: row.f_balance,
1755
- userfiles: {
1756
- f_user_id: model.f_user_id,
1757
- f_userfiles_id: row.f_userfiles_id,
1758
- f_total_gas: row.f_total_gas,
1759
- f_write_totalgas: row.f_write_totalgas,
1760
- f_write_totalfee: row.f_write_totalfee,
1761
- f_total_fee: row.f_total_fee,
1762
- f_card_id: row.f_card_id,
1763
- f_times: row.cardInfo.Times,
1764
- version: row.version + 1
1765
- }
1766
- }
1767
- }
1768
- if (row.f_tag) {
1769
- data.userinfo.userfiles.f_tag = row.f_tag
1770
- }
1771
- if (!(row.f_hascard == null) && !(row.f_share_times == null) && row.f_meter_type === '物联网表' && row.f_hascard === '是' && row.f_share_times === '是') {
1772
- data.userinfo.userfiles.f_times = row.f_times
1773
- }
1774
- await Vue.resetpost('rs/logic/cardChargeRollback', {data: data}, {resolveMsg: '卡表收费失败', rejectMsg: '卡表收费失败'})
1775
- }
1776
- throw error
1777
- }
1778
- }
1779
- // 卡表收费
1780
- let sellgasGen = async function (model, row) {
1781
- let result = null
1782
- let cardparam
1783
- let cardpost
1784
- try {
1785
- let cardState = await hasCardGen()
1786
- if (JSON.parse(cardState.data).state === 1) {
1787
- // 将卡上次数写入数据库
1788
- if (!(row.f_hascard == null) && !(row.f_share_times == null) && row.f_hascard === '是' && row.f_share_times === '是') {
1789
- model.f_times = row.f_times + 1
1790
- } else {
1791
- model.f_times = row.cardInfo.Times + 1
1792
- }
1793
- // 将回写表号或者用户号
1794
- model.f_meterid = row.cardInfo.Yhh ? row.cardInfo.Yhh : row.f_meterid
1795
-
1796
- let cardid = row.f_card_id
1797
- if (row.f_tag) {
1798
- // 截取用户编号后四位
1799
- cardid = model.f_card_id = row.f_tag + row.f_card_id
1800
- }
1801
- // 存库
1802
- result = await Vue.resetpost('rs/logic/sale_cardCharge_logic', {data: model}, {resolveMsg: null, rejectMsg: '卡表收费存库失败'})
1803
- // 获取气价和售气情况参数
1804
- let cardParams = await getParamGen(cardid, row.f_alias, row.f_user_id, row.f_userfiles_id)
1805
- console.log('写卡次数和获取的写卡参数...', row.cardInfo.Times, cardParams)
1806
- // 写卡
1807
- let params = {
1808
- factory: row.f_alias, // 气表厂家
1809
- kh: cardid, // 卡号
1810
- yhh: row.f_meterid ? row.f_meterid : 0, // 用户号,档案中自己输
1811
- kmm: row.f_card_password, // 卡密码,写卡后返回新密码, 不论补卡还是先开户都没有密码
1812
- bjql: row.f_police_gas,
1813
- ljgql: (row.f_write_totalgas - 0) + (model.f_pregas - 0), // 当前累计购气量
1814
- ljgqje: (row.f_write_totalfee - 0) + (model.f_write_money - 0), // 累计购气金额
1815
- czsx: row.f_topup_ceil, // 充值上线,t_gasbrand表中
1816
- tzed: row.f_overdr_lines, // 透支额度,t_gasbrand表中
1817
- bkcs: row.f_fillcard_times, // 补卡次数,从补卡表里通过表编号获得
1818
- ql: model.f_pregas, // 预购气量
1819
- cs: row.cardInfo.Times + 1, // 求购气次数,先开户为1
1820
- money: model.f_write_money, // 购气金额
1821
- dqdm: row.f_area_code, // 精益工业地区代码
1822
- klx: row.f_coding,
1823
- meterid: row.f_meternumber ? row.f_meternumber : 0 // 表号
1824
- }
1825
- params = Object.assign({}, Vue.CommonService.writeCardParams(cardParams), params)
1826
- // if (row.f_alias === 'HaiLiJE' || row.f_alias === 'HaiLiQL' || row.f_alias === 'CangNanTY') {
1827
- // params.klx = yield co(getmodelbrandGen(row))
1828
- // params.klx = params.klx.data[0].f_coding
1829
- // }
1830
-
1831
- let params2 = {
1832
- factory: row.f_alias,
1833
- kh: cardid, // 卡号
1834
- kmm: row.f_card_password, // 卡密码,写卡后返回新密码, 不论补卡还是先开户都没有密码
1835
- bjql: row.f_police_gas, // 报警气量,t_gasbrand表中
1836
- czsx: row.f_topup_ceil, // 充值上线,t_gasbrand表中
1837
- tzed: row.f_overdr_lines, // 透支额度,t_gasbrand表中
1838
- ljgql: (row.f_write_totalgas - 0) + (model.f_pregas - 0), // 当前累计购气量
1839
- ljgqje: (row.f_write_totalfee - 0) + (model.f_write_money - 0), // 累计购气金额
1840
- kzt: '1', // 卡状态,0开户卡,1用户卡(0新开户,1补卡)
1841
- bkcs: row.f_fillcard_times, // 补卡次数,从补卡表里通过表编号获得
1842
- ql: model.f_pregas, // 预购气量
1843
- cs: row.cardInfo.Times + 1, // 求购气次数,先开户为1
1844
- sxrq: model.f_startdate, // 生效日期,价格管理中取
1845
- meterid: row.f_meternumber ? row.f_meternumber : 0, // 表号
1846
- // meternumber: row.f_meternumber ? row.f_meternumber : 0, // 海力金额表号
1847
- dqdm: row.f_area_code, // 精益工业地区代码
1848
- money: model.f_write_money, // 购气金额
1849
- klx: row.f_coding
1850
- }
1851
-
1852
- params2 = Object.assign({}, Vue.CommonService.writeCardParams(cardParams), params2)
1853
- // if (row.f_alias === 'HaiLiJE' || row.f_alias === 'HaiLiQL' || row.f_alias === 'CangNanTY') {
1854
- // params2.klx = yield co(getmodelbrandGen(row))
1855
- // params2.klx = params2.klx.data[0].f_coding
1856
- // }
1857
-
1858
- let params3 = {
1859
- factory: row.f_alias,
1860
- kh: cardid, // 卡号
1861
- kmm: row.f_card_password, // 卡密码,写卡后返回新密码, 不论补卡还是先开户都没有密码
1862
- bjql: row.f_police_gas, // 报警气量,t_gasbrand表中
1863
- czsx: row.f_topup_ceil, // 充值上线,t_gasbrand表中
1864
- tzed: row.f_overdr_lines, // 透支额度,t_gasbrand表中
1865
- ljgql: (row.f_write_totalgas - 0) + (model.f_pregas - 0), // 当前累计购气量
1866
- ljgqje: (row.f_write_totalfee - 0) + (model.f_write_money - 0), // 累计购气金额
1867
- kzt: '0', // 卡状态,0开户卡,1用户卡(0新开户,1补卡)
1868
- bkcs: row.f_fillcard_times, // 补卡次数,从补卡表里通过表编号获得
1869
- ql: model.f_pregas, // 预购气量
1870
- cs: 1, // 求购气次数,先开户为1
1871
- sxrq: model.f_startdate, // 生效日期,价格管理中取
1872
- meterid: row.f_meternumber ? row.f_meternumber : 0, // 表号
1873
- // meternumber: row.f_meternumber ? row.f_meternumber : 0, // 海力金额表号
1874
- dqdm: row.f_area_code, // 精益工业地区代码
1875
- money: model.f_write_money, // 购气金额
1876
- klx: row.f_coding
1877
- }
1878
- params3 = Object.assign({}, Vue.CommonService.writeCardParams(cardParams), params3)
1879
- // if (row.f_alias === 'HaiLiJE' || row.f_alias === 'HaiLiQL' || row.f_alias === 'CangNanTY') {
1880
- // params3.klx = yield co(getmodelbrandGen(row))
1881
- // params3.klx = params3.klx.data[0].f_coding
1882
- // }
1883
- console.log('购气最后操作。。', result)
1884
- if (!(row.f_hascard == null) && !(row.f_share_times == null) && row.f_meter_type === '物联网表' && row.f_hascard === '是' && row.f_share_times === '是') {
1885
- params.cs = row.f_times + 1
1886
- params2.cs = row.f_times + 1
1887
- }
1888
- let cardRes
1889
- if (result.data.last_oper === '补卡') {
1890
- // 此次验证开户之后未过表补卡验证问题
1891
- params2.kzt = result.data.ispick === '未过表' && result.data.lastsell_oper === '发卡售气' ? '0' : '1'
1892
- cardparam = JSON.stringify(params2)
1893
- cardpost = 'WriteNewCard'
1894
- cardRes = await Vue.resetpost('http://127.0.0.1:8003/WriteNewCard', params2, {resolveMsg: null, rejectMsg: '卡表收费失败'})
1895
- } else if (result.data.last_oper === '换表') {
1896
- console.log('我走的是写新卡换表')
1897
- cardparam = JSON.stringify(params3)
1898
- cardpost = 'WriteNewCard'
1899
- cardRes = await Vue.resetpost('http://127.0.0.1:8003/WriteNewCard', params3, {resolveMsg: null, rejectMsg: '卡表收费失败'})
1900
- } else if (result.data.last_oper === '换表补气') {
1901
- // 累购金额需要将上次购气金额加上
1902
- console.log('我走的是正常的收费', params)
1903
- cardparam = JSON.stringify(params)
1904
- cardpost = 'WriteGasCard'
1905
- cardRes = await Vue.resetpost('http://127.0.0.1:8003/WriteGasCard', params, {resolveMsg: null, rejectMsg: '卡表收费失败'})
1906
- } else {
1907
- console.log('我走的是正常的收费', params)
1908
- cardparam = JSON.stringify(params)
1909
- cardpost = 'WriteGasCard'
1910
- cardRes = await Vue.resetpost('http://127.0.0.1:8003/WriteGasCard', params, {resolveMsg: null, rejectMsg: '卡表收费失败'})
1911
- }
1912
- console.log('卡表收费返回写卡参数值', cardRes)
1913
- // 卡服务写卡异常,业务逻辑回滚
1914
- if (!cardParams || !result || cardRes.data.Err || cardRes.data.Exception) {
1915
- throw `卡服务错误:${cardRes.data.Err}${cardRes.data.Exception},请联系开发人员处理!!`
1916
- } else {
1917
- // 调用读卡进行校验
1918
- let readCardInfo = await Vue.resetpost('http://127.0.0.1:8003/ReadCard', {kmm: row.f_card_password}, {resolveMsg: null, rejectMsg: '读卡失败!!'})
1919
- if (readCardInfo.data && Vue.$login.r.includes('读卡2')) {
1920
- console.log('读卡验证', readCardInfo.data, row)
1921
- if (row.f_collection_type === '按金额') {
1922
- if (readCardInfo.data.Money !== model.f_preamount || readCardInfo.data.Factory !== row.f_alias || readCardInfo.data.CardID !== row.f_card_id) {
1923
- Vue.showAlert('读卡参数和缴费参数不一致,请核实!!', 'warning', 2000)
1924
- return result.data.id
1925
- }
1926
- } else {
1927
- if (readCardInfo.data.Gas !== Number((model.f_pregas - 0).toFixed(2)) || readCardInfo.data.Factory !== row.f_alias || readCardInfo.data.CardID !== row.f_card_id) {
1928
- Vue.showAlert('读卡参数和缴费参数不一致,请核实!!', 'warning', 2000)
1929
- return result.data.id
1930
- }
1931
- }
1932
- }
1933
- // 更新卡密码
1934
- await Vue.CommonService.updatePassword(row, cardRes)
1935
- Vue.showAlert('售气成功', 'success', 2000)
1936
- return result.data.id
1937
- }
1938
- } else {
1939
- throw new Error(`请检查卡是否插好!!`)
1940
- }
1941
- } catch (error) {
1942
- if (result) {
1943
- let data = {
1944
- cardparam: cardparam,
1945
- cardpost: cardpost,
1946
- id: result.data.id,
1947
- userinfo: {
1948
- f_userinfo_id: row.f_userinfo_id,
1949
- version: row.userinfo_version + 1,
1950
- f_balance: row.f_balance,
1951
- userfiles: {
1952
- f_user_id: model.f_user_id,
1953
- f_userfiles_id: row.f_userfiles_id,
1954
- f_total_gas: row.f_total_gas,
1955
- f_write_totalgas: row.f_write_totalgas,
1956
- f_write_totalfee: row.f_write_totalfee,
1957
- f_total_fee: row.f_total_fee,
1958
- f_card_id: row.f_card_id,
1959
- f_times: row.cardInfo.Times,
1960
- version: row.version + 1
1961
- }
1962
- }
1963
- }
1964
- if (row.f_tag) {
1965
- data.userinfo.userfiles.f_tag = row.f_tag
1966
- }
1967
- if (!(row.f_hascard == null) && !(row.f_share_times == null) && row.f_meter_type === '物联网表' && row.f_hascard === '是' && row.f_share_times === '是') {
1968
- data.userinfo.userfiles.f_times = row.f_times
1969
- }
1970
- await Vue.resetpost('rs/logic/cardChargeRollback', {data: data}, {resolveMsg: '卡表收费失败', rejectMsg: '卡表收费失败'})
1971
- }
1972
- throw error
1973
- }
1974
- }
1975
- let reissueCardGenJB = function * (model, row) {
1976
- if (model.f_cardfees === '') {
1977
- model.f_cardfees = 0
1978
- }
1979
- let data = {
1980
- f_user_id: row.f_user_id,
1981
- f_userfiles_id: row.f_userfiles_id,
1982
- f_user_type: row.f_user_type,
1983
- f_gasproperties: row.f_gasproperties,
1984
- f_address: row.f_address,
1985
- f_meter_brand: row.f_meter_brand,
1986
- f_type: model.f_type,
1987
- f_card_id: model.f_card_id,
1988
- f_ispick_table: model.f_ispick_table,
1989
- f_cardfees: model.f_cardfees,
1990
- f_payment: model.f_payment[0],
1991
- f_bill_style: model.f_print[0],
1992
- f_comments: model.f_comments,
1993
- record_userinfo: row.f_userinfo_id,
1994
- f_userinfo_id: row.f_userinfo_id,
1995
- f_user_name: row.f_user_name,
1996
- f_operat_type: '补卡',
1997
- f_describe: `${Vue.$login.f.name}对客户${row.f_user_name}进行${row.f_type}操作`,
1998
- f_state: '有效',
1999
- f_operator: Vue.$login.f.name,
2000
- f_operatorid: Vue.$login.f.id,
2001
- f_orgid: Vue.$login.f.orgid,
2002
- f_orgname: Vue.$login.f.orgs,
2003
- f_depid: Vue.$login.f.depids,
2004
- f_depname: Vue.$login.f.deps,
2005
- f_zoneid: Vue.$login.f.zoneid,
2006
- f_zones: Vue.$login.f.zones,
2007
- f_business_tracking_number: model.f_business_tracking_number
2008
- }
2009
-
2010
- return Vue.resetpost('rs/logic/sale_fillCard', data, {resolveMsg: null, rejectMsg: '补卡存库失败'})
2011
- }
2012
- let reissueCardGen = function * (model, row) {
2013
- if (model.f_cardfees === '') {
2014
- model.f_cardfees = 0
2015
- }
2016
- if (!model.f_fill_type) {
2017
- model.f_fill_type = ['']
2018
- }
2019
- let data = {
2020
- f_serial_id: model.f_serial_id,
2021
- f_user_id: row.f_user_id,
2022
- f_userfiles_id: row.f_userfiles_id,
2023
- f_user_type: row.f_user_type,
2024
- f_gasproperties: row.f_gasproperties,
2025
- f_address: row.f_address,
2026
- f_meter_brand: row.f_meter_brand,
2027
- f_type: model.f_type,
2028
- f_card_id: model.f_card_id,
2029
- f_ispick_table: model.f_ispick_table,
2030
- f_cardfees: model.f_cardfees,
2031
- f_payment: model.f_payment[0],
2032
- f_bill_style: model.f_print[0],
2033
- f_fill_type: model.f_fill_type[0],
2034
- f_comments: model.f_comments,
2035
- record_userinfo: row.f_userinfo_id,
2036
- f_userinfo_id: row.f_userinfo_id,
2037
- f_user_name: row.f_user_name,
2038
- f_operat_type: '补卡',
2039
- f_describe: `${Vue.$login.f.name}对客户${row.f_user_name}进行补卡操作`,
2040
- f_state: '有效',
2041
- f_operator: Vue.$login.f.name,
2042
- f_operatorid: Vue.$login.f.id,
2043
- f_orgid: Vue.$login.f.orgid,
2044
- f_orgname: Vue.$login.f.orgs,
2045
- f_depid: Vue.$login.f.depids,
2046
- f_depname: Vue.$login.f.deps,
2047
- f_zoneid: Vue.$login.f.zoneid,
2048
- f_zones: Vue.$login.f.zones,
2049
- f_business_tracking_number: model.f_business_tracking_number
2050
- }
2051
-
2052
- return Vue.resetpost('rs/logic/sale_fillCard', data, {resolveMsg: null, rejectMsg: '补卡存库失败'})
2053
- }
2054
-
2055
- let getParamGen = async function (cardid, alias, f_user_id, f_userfiles_id) {
2056
- let data = {
2057
- f_card_id: cardid + '',
2058
- f_alias: alias,
2059
- f_user_id: f_user_id,
2060
- f_userfiles_id: f_userfiles_id
2061
- }
2062
- return Vue.resetpost('rs/logic/stairCard', {data: data}, {resolveMsg: null, rejectMsg: '获取写卡参数失败'})
2063
- }
2064
-
2065
- let getCardNumberGen = async function (brand_id) {
2066
- return Vue.resetpost('rs/logic/getCardNumber', {data: {id: brand_id}}, {resolveMsg: null, rejectMsg: '发卡售气获取卡号失败!!'})
2067
- }
2068
- export default CardService
1
+ import Vue from 'vue'
2
+ import co from 'co'
3
+
4
+ let CardService = {
5
+ install (Vue, options) {
6
+ // 给vue增添对话框显示方法
7
+ Vue.CardService = Vue.prototype.$CardService = CardService
8
+ },
9
+ // 判断是否插卡
10
+ hasCard () {
11
+ let has = hasCardGen()
12
+ return co(has)
13
+ },
14
+ // 读卡
15
+ readCard () {
16
+ let read = readCard()
17
+ return co(read)
18
+ },
19
+ // 指令写卡
20
+ // 目前支持 承德海力物联网表
21
+ instructWriteCard (row) {
22
+ let read = instructWriteCardGen(row)
23
+ return co(read)
24
+ },
25
+ // 开户发卡
26
+ initCard (model, row, allot) {
27
+ // let init = initCardGen(model, row, allot ? this.getallotdata(allot, row, '发卡售气') : null)
28
+ // return co(init)
29
+
30
+ let f_serial_number = ''
31
+ let f_price = ''
32
+ let inputprice = '0'
33
+ if (model.f_serial_number) {
34
+ f_serial_number = model.f_serial_number
35
+ }
36
+ if (model.f_price && (model.f_price - 0) > 0) {
37
+ f_price = model.f_price
38
+ inputprice = '1'
39
+ }
40
+ let f_privilege_gas = 0
41
+ if (model.f_privilege_gas) {
42
+ f_privilege_gas = model.f_privilege_gas
43
+ }
44
+ let param = {
45
+ garbage_number: model.garbage_number,
46
+ garbage_money: model.garbage_money,
47
+ f_serial_id: model.f_serial_id,
48
+ f_userinfo_id: row.f_userinfo_id,
49
+ f_serial_number: f_serial_number,
50
+ f_user_id: row.f_user_id,
51
+ f_price: f_price,
52
+ inputprice: inputprice,
53
+ f_userfiles_id: row.f_userfiles_id,
54
+ f_pregas: model.f_pregas,
55
+ f_preamount: model.f_preamount,
56
+ f_balance: row.f_balance,
57
+ f_meter_type: row.f_meter_type,
58
+ f_calculation: row.f_calculation,
59
+ f_collection_type: row.f_collection_type,
60
+ f_total_gas: (row.f_total_gas - 0) + (model.f_pregas - 0),
61
+ f_write_money: model.xiekamoney,
62
+ f_write_totalgas: (row.f_write_totalgas - 0) + (model.f_pregas - 0),
63
+ f_write_totalfee: (row.f_write_totalfee - 0) + (model.xiekamoney - 0),
64
+ f_total_fee: (row.f_total_fee - 0) + (model.f_preamount - 0),
65
+ f_open_fee: model.f_open_fee,
66
+ f_collection: model.f_collection,
67
+ f_payment: model.f_payment.toString(),
68
+ payments: model.payments,
69
+ f_print: model.f_print.toString(),
70
+ f_voucher_number: model.f_voucher_number,
71
+ userinfo_version: row.userinfo_version,
72
+ version: row.version,
73
+ // 优惠金额
74
+ f_privilege_money: model.f_privilege_money,
75
+ f_privilege_gas: f_privilege_gas,
76
+ f_after_discount: model.f_after_discount,
77
+
78
+ f_operator: Vue.$login.f.name,
79
+ f_operatorid: Vue.$login.f.id,
80
+ f_orgid: Vue.$login.f.orgid,
81
+ f_orgname: Vue.$login.f.orgs,
82
+ f_depid: Vue.$login.f.depids,
83
+ f_depname: Vue.$login.f.deps,
84
+ f_zoneid: Vue.$login.f.zoneid,
85
+ f_zones: Vue.$login.f.zones,
86
+ f_comments: model.f_comments
87
+ }
88
+ console.log('发卡售气前参数', row)
89
+ return sendCardSaleGasGen(param, row)
90
+ },
91
+ resetinitCard (model, row) {
92
+ let f_serial_number = ''
93
+ let f_price = ''
94
+ let inputprice = '0'
95
+ if (model.f_serial_number) {
96
+ f_serial_number = model.f_serial_number
97
+ }
98
+ if (model.f_price && (model.f_price - 0) > 0) {
99
+ f_price = model.f_price
100
+ inputprice = '1'
101
+ }
102
+ let f_privilege_gas = 0
103
+ if (model.f_privilege_gas) {
104
+ f_privilege_gas = model.f_privilege_gas
105
+ }
106
+ let param = {
107
+ f_serial_id: model.f_serial_id,
108
+ f_userinfo_id: row.f_userinfo_id,
109
+ f_user_name: row.f_user_name,
110
+ f_serial_number: f_serial_number,
111
+ f_user_id: row.f_user_id,
112
+ f_price: f_price,
113
+ inputprice: inputprice,
114
+ f_userfiles_id: row.f_userfiles_id,
115
+ f_pregas: model.f_pregas,
116
+ f_preamount: model.f_preamount,
117
+ f_balance: row.f_balance,
118
+ f_meter_type: row.f_meter_type,
119
+ f_calculation: row.f_calculation,
120
+ f_collection_type: row.f_collection_type,
121
+ f_total_gas: (row.f_total_gas - 0) + (model.f_pregas - 0),
122
+ f_write_totalgas: (row.f_write_totalgas - 0) + (model.f_pregas - 0),
123
+ f_write_totalfee: (row.f_write_totalfee - 0) + (model.f_preamount - 0),
124
+ f_total_fee: (row.f_total_fee - 0) + (model.f_preamount - 0),
125
+ f_open_fee: model.f_open_fee,
126
+ f_collection: model.f_collection,
127
+ // f_print: model.f_print.toString(),
128
+ f_user_type: row.f_user_type,
129
+ f_gasproperties: row.f_gasproperties,
130
+ f_address: row.f_address,
131
+ f_meter_brand: row.f_meter_brand,
132
+ f_voucher_number: model.f_voucher_number,
133
+ userinfo_version: row.userinfo_version,
134
+ version: row.version,
135
+
136
+ f_operator: Vue.$login.f.name,
137
+ f_operatorid: Vue.$login.f.id,
138
+ f_orgid: Vue.$login.f.orgid,
139
+ f_orgname: Vue.$login.f.orgs,
140
+ f_depid: Vue.$login.f.depids,
141
+ f_depname: Vue.$login.f.deps,
142
+ f_zoneid: Vue.$login.f.zoneid,
143
+ f_zones: Vue.$login.f.zones,
144
+ f_comments: model.f_comments
145
+ }
146
+ console.log('重发卡售气前参数', row)
147
+ return resetsendCardSaleGasGen(param, row)
148
+ },
149
+ // 补气开户发卡
150
+ remanentinitCard (model, row, allot) {
151
+ let param = {
152
+ f_share_times: row.f_share_times,
153
+ f_hascard: row.f_hascard,
154
+ f_open_way: row.f_open_type,
155
+ f_serial_id: model.f_serial_id,
156
+ f_userinfo_id: row.f_userinfo_id,
157
+ f_user_id: row.f_user_id,
158
+ // 补气量
159
+ f_fill_gas: model.f_fill_gas,
160
+ f_fill_money: model.f_fill_money,
161
+ f_remanent_gas: row.f_remanent_gas === 0 ? model.f_fill_gas : row.f_remanent_gas,
162
+ f_remanent_price: row.f_remanent_price,
163
+ f_remanent_money: row.f_remanent_money === 0 ? model.f_fill_money : row.f_remanent_money,
164
+ f_remanent_type: row.f_remanent_type,
165
+ f_userfiles_id: row.f_userfiles_id,
166
+ f_user_name: row.f_user_name,
167
+ f_user_type: row.f_user_type,
168
+ f_gasproperties: row.f_gasproperties,
169
+ f_address: row.f_address,
170
+ f_meter_brand: row.f_meter_brand,
171
+ f_meter_type: row.f_meter_type,
172
+ f_collection_type: row.f_collection_type,
173
+ // 购气量
174
+ f_pregas: (model.f_pregas - 0) === 0 ? model.f_fill_gas : (model.f_pregas - 0),
175
+ f_preamount: (model.f_preamount - 0) === 0 ? model.f_fill_money : (model.f_preamount - 0),
176
+ f_totalcost: model.f_totalcost - 0,
177
+ f_balance: row.f_balance,
178
+ f_open_fee: model.f_open_fee,
179
+ f_collection: model.f_collection,
180
+ f_payment: model.f_payment.toString(),
181
+ payments: model.payments,
182
+ f_print: model.f_print.toString(),
183
+ f_voucher_number: model.f_voucher_number,
184
+ userinfo_version: row.userinfo_version,
185
+ version: row.version,
186
+ f_operator: Vue.$login.f.name,
187
+ f_operatorid: Vue.$login.f.id,
188
+ f_orgid: Vue.$login.f.orgid,
189
+ f_orgname: Vue.$login.f.orgs,
190
+ f_depid: Vue.$login.f.depids,
191
+ f_depname: Vue.$login.f.deps,
192
+ f_zoneid: Vue.$login.f.zoneid,
193
+ f_zones: Vue.$login.f.zones,
194
+ f_comments: model.f_comments
195
+ }
196
+
197
+ if (row.f_remanent_type === 1) {
198
+ param.f_total_gas = (row.f_total_gas - 0) + (model.f_pregas - 0)
199
+ param.f_total_fee = (row.f_total_fee - 0) + (model.f_preamount - 0)
200
+ } else {
201
+ if ((model.f_pregas - 0) > (model.f_fill_gas - 0)) {
202
+ param.f_total_gas = (row.f_total_gas - 0) + ((model.f_pregas - 0) - (model.f_fill_gas - 0))
203
+ param.f_total_fee = (row.f_total_fee - 0) + (model.f_preamount - 0)
204
+ } else {
205
+ param.f_total_gas = (row.f_total_gas - 0)
206
+ param.f_total_fee = (row.f_total_fee - 0)
207
+ }
208
+ }
209
+ param.f_write_totalgas = (row.f_write_totalgas - 0) + (model.f_pregas - 0)
210
+ param.f_write_totalfee = (row.f_write_totalfee - 0) + (model.f_preamount - 0)
211
+ return sendCardSaleGasGenremanent(param, row)
212
+ },
213
+
214
+ offlineWrite (row) {
215
+ return offlineWriteGen(row)
216
+ },
217
+ // 余量补差
218
+ margin (model, row) {
219
+ let f_serial_number = ''
220
+ let f_price = ''
221
+ let inputprice = '0'
222
+ let f_privilege_gas = 0
223
+ if (model.f_serial_number) {
224
+ f_serial_number = model.f_serial_number
225
+ }
226
+ if (model.f_price && (model.f_price - 0) > 0) {
227
+ f_price = model.f_price
228
+ inputprice = '1'
229
+ }
230
+ if (model.f_privilege_gas) {
231
+ f_privilege_gas = model.f_privilege_gas
232
+ }
233
+ let param = {
234
+ garbage_number: model.garbage_number,
235
+ garbage_money: model.garbage_money,
236
+ f_serial_id: model.f_serial_id,
237
+ f_userinfo_id: row.f_userinfo_id,
238
+ f_serial_number: f_serial_number,
239
+ f_write_money: model.xiekamoney,
240
+ f_price: f_price,
241
+ inputprice: inputprice,
242
+ // 补气量
243
+ f_remanent_gas: row.f_remanent_gas,
244
+ f_remanent_price: row.f_remanent_price,
245
+ f_user_id: row.f_user_id,
246
+ f_calculation: row.f_calculation,
247
+ f_collection_type: row.f_collection_type,
248
+ f_userfiles_id: row.f_userfiles_id,
249
+ f_pregas: model.f_pregas,
250
+ f_totalcost: model.f_totalcost,
251
+ f_balance: row.f_balance,
252
+ f_meter_type: row.f_meter_type,
253
+ f_preamount: model.f_preamount,
254
+ f_total_gas: (row.f_total_gas - 0) + (model.f_pregas - 0),
255
+ f_write_totalgas: (row.f_write_totalgas - 0) + (model.f_pregas - 0),
256
+ f_write_totalfee: (row.f_write_totalfee - 0) + (model.xiekamoney - 0),
257
+ f_total_fee: (row.f_total_fee - 0) + (model.f_preamount - 0),
258
+ f_collection: model.f_collection,
259
+ // 优惠金额
260
+ f_privilege_money: model.f_privilege_money,
261
+ f_privilege_gas: f_privilege_gas,
262
+ f_after_discount: model.f_after_discount,
263
+ f_payment: model.f_payment.toString(),
264
+ payments: model.payments,
265
+ f_print: model.f_print.toString(),
266
+ f_voucher_number: model.f_voucher_number,
267
+ userinfo_version: row.userinfo_version,
268
+ version: row.version,
269
+ f_meter_base: row.f_meter_base,
270
+ f_operator: Vue.$login.f.name,
271
+ f_operatorid: Vue.$login.f.id,
272
+ f_orgid: Vue.$login.f.orgid,
273
+ f_orgname: Vue.$login.f.orgs,
274
+ f_depid: Vue.$login.f.depids,
275
+ f_depname: Vue.$login.f.deps,
276
+ f_zoneid: Vue.$login.f.zoneid,
277
+ f_zones: Vue.$login.f.zones,
278
+ f_comments: model.f_comments,
279
+ f_sys_balance: model.f_sys_balance
280
+ }
281
+ return marginGen(param, row)
282
+ },
283
+ // 卡表收费
284
+ sellgas (model, row) {
285
+ let f_serial_number = ''
286
+ let f_price = ''
287
+ let inputprice = '0'
288
+ let f_privilege_gas = 0
289
+ if (model.f_serial_number) {
290
+ f_serial_number = model.f_serial_number
291
+ }
292
+ if (model.f_price && (model.f_price - 0) > 0) {
293
+ f_price = model.f_price
294
+ inputprice = '1'
295
+ }
296
+ if (model.f_privilege_gas) {
297
+ f_privilege_gas = model.f_privilege_gas
298
+ }
299
+ let param = {
300
+ garbage_number: model.garbage_number,
301
+ garbage_money: model.garbage_money,
302
+ f_serial_id: model.f_serial_id,
303
+ f_userinfo_id: row.f_userinfo_id,
304
+ f_serial_number: f_serial_number,
305
+ f_write_money: model.xiekamoney,
306
+ f_price: f_price,
307
+ inputprice: inputprice,
308
+ // 补气量
309
+ f_remanent_gas: row.f_remanent_gas,
310
+ f_remanent_price: row.f_remanent_price,
311
+ f_user_id: row.f_user_id,
312
+ f_calculation: row.f_calculation,
313
+ f_collection_type: row.f_collection_type,
314
+ f_userfiles_id: row.f_userfiles_id,
315
+ f_pregas: model.f_pregas,
316
+ f_totalcost: model.f_totalcost,
317
+ f_balance: row.f_balance,
318
+ f_meter_type: row.f_meter_type,
319
+ f_preamount: model.f_preamount,
320
+ f_total_gas: (row.f_total_gas - 0) + (model.f_pregas - 0),
321
+ f_write_totalgas: (row.f_write_totalgas - 0) + (model.f_pregas - 0),
322
+ f_write_totalfee: (row.f_write_totalfee - 0) + (model.xiekamoney - 0),
323
+ f_total_fee: (row.f_total_fee - 0) + (model.f_preamount - 0),
324
+ f_collection: model.f_collection,
325
+ // 优惠金额
326
+ f_privilege_money: model.f_privilege_money,
327
+ f_privilege_gas: f_privilege_gas,
328
+ f_after_discount: model.f_after_discount,
329
+ f_payment: model.f_payment.toString(),
330
+ payments: model.payments,
331
+ f_print: model.f_print.toString(),
332
+ f_voucher_number: model.f_voucher_number,
333
+ userinfo_version: row.userinfo_version,
334
+ version: row.version,
335
+ f_meter_base: row.f_meter_base,
336
+ f_operator: Vue.$login.f.name,
337
+ f_operatorid: Vue.$login.f.id,
338
+ f_orgid: Vue.$login.f.orgid,
339
+ f_orgname: Vue.$login.f.orgs,
340
+ f_depid: Vue.$login.f.depids,
341
+ f_depname: Vue.$login.f.deps,
342
+ f_zoneid: Vue.$login.f.zoneid,
343
+ f_zones: Vue.$login.f.zones,
344
+ f_comments: model.f_comments,
345
+ f_sys_balance: model.f_sys_balance
346
+ }
347
+ return sellgasGen(param, row)
348
+ },
349
+
350
+ // 补气卡表收费
351
+ remanentsellgas (model, row) {
352
+ let param = {
353
+ f_user_name: row.f_user_name,
354
+ f_user_type: row.f_user_type,
355
+ f_gasproperties: row.f_gasproperties,
356
+ f_userinfo_id: row.f_userinfo_id,
357
+ f_address: row.f_address,
358
+ f_meter_brand: row.f_meter_brand,
359
+ f_meter_type: row.f_meter_type,
360
+ f_collection_type: row.f_collection_type,
361
+ f_card_id: row.f_card_id,
362
+ f_write_money: model.xiekamoney,
363
+ // 补气信息
364
+ f_fill_gas: model.f_fill_gas,
365
+ f_fill_money: model.f_fill_money,
366
+
367
+ f_remanent_gas: row.f_remanent_gas,
368
+ f_remanent_price: row.f_remanent_price,
369
+ f_remanent_type: row.f_remanent_type,
370
+ f_user_id: row.f_user_id,
371
+ f_userfiles_id: row.f_userfiles_id,
372
+ f_pregas: model.f_pregas,
373
+ f_balance: row.f_balance,
374
+ f_preamount: model.f_preamount,
375
+ f_totalcost: model.f_totalcost,
376
+ f_collection: model.f_collection,
377
+ f_payment: model.f_payment.toString(),
378
+ payments: model.payments,
379
+ f_print: model.f_print.toString(),
380
+ f_voucher_number: model.f_voucher_number,
381
+ userinfo_version: row.userinfo_version,
382
+ version: row.version,
383
+ f_operator: Vue.$login.f.name,
384
+ f_operatorid: Vue.$login.f.id,
385
+ f_orgid: Vue.$login.f.orgid,
386
+ f_orgname: Vue.$login.f.orgs,
387
+ f_depid: Vue.$login.f.depids,
388
+ f_depname: Vue.$login.f.deps,
389
+ f_zoneid: Vue.$login.f.zoneid,
390
+ f_zones: Vue.$login.f.zones,
391
+ f_comments: model.f_comments
392
+ }
393
+
394
+ // 0:代表清零补气, 累购量不加 1:代表换表补气 累购量加
395
+ if (row.f_remanent_type === 1) {
396
+ param.f_total_gas = (row.f_total_gas - 0) + (model.f_pregas - 0)
397
+ param.f_total_fee = (row.f_total_fee - 0) + (model.f_preamount - 0)
398
+ } else {
399
+ if (model.f_pregas > row.f_remanent_gas) {
400
+ param.f_total_gas = (row.f_total_gas - 0) + (model.f_pregas - row.f_remanent_gas)
401
+ param.f_total_fee = (row.f_total_fee - 0) + (model.f_preamount - 0)
402
+ } else {
403
+ param.f_total_gas = (row.f_total_gas - 0)
404
+ param.f_total_fee = (row.f_total_fee - 0)
405
+ }
406
+ }
407
+ param.f_write_totalgas = (row.f_write_totalgas - 0) + (model.f_pregas - 0)
408
+ param.f_write_totalfee = (row.f_write_totalfee - 0) + (model.xiekamoney - 0)
409
+ return sellgasRemanentGen(param, row)
410
+ },
411
+ // 数码表收费
412
+ DigtialSellGas (model, row) {
413
+ let f_serial_number = ''
414
+ if (model.f_serial_number) {
415
+ f_serial_number = model.f_serial_number
416
+ }
417
+ let param = {
418
+ f_userinfo_id: row.f_userinfo_id,
419
+ f_serial_number: f_serial_number,
420
+ f_user_id: row.f_user_id,
421
+ f_userfiles_id: row.f_userfiles_id,
422
+ f_pregas: model.f_pregas,
423
+ f_write_money: model.f_write_money,
424
+ f_balance: row.f_balance,
425
+ f_preamount: model.f_preamount,
426
+ f_total_gas: (row.f_total_gas - 0) + (model.f_pregas - 0),
427
+ f_write_totalgas: (row.f_write_totalgas - 0) + (model.f_pregas - 0),
428
+ f_write_totalfee: (row.f_write_totalfee - 0) + (model.f_write_money - 0),
429
+ f_total_fee: (row.f_total_fee - 0) + (model.f_preamount - 0),
430
+ f_collection: model.f_collection,
431
+ f_payment: model.f_payment.toString(),
432
+ payments: model.payments,
433
+ f_print: model.f_print.toString(),
434
+ f_voucher_number: model.f_voucher_number,
435
+ userinfo_version: row.userinfo_version,
436
+ version: row.version,
437
+ f_operator: Vue.$login.f.name,
438
+ f_operatorid: Vue.$login.f.id,
439
+ f_orgid: Vue.$login.f.orgid,
440
+ f_orgname: Vue.$login.f.orgs,
441
+ f_depid: Vue.$login.f.depids,
442
+ f_depname: Vue.$login.f.deps,
443
+ f_zoneid: Vue.$login.f.zoneid,
444
+ f_zones: Vue.$login.f.zones
445
+
446
+ }
447
+
448
+ return DigtialSellGasGen(param, row)
449
+ },
450
+ // 无卡收费
451
+ noCardSellGas (model, row) {
452
+ let f_serial_number = ''
453
+ if (model.f_serial_number) {
454
+ f_serial_number = model.f_serial_number
455
+ }
456
+ let f_write_card = ''
457
+ if (model.f_write_card) {
458
+ f_write_card = model.f_write_card
459
+ }
460
+ let param = {
461
+ f_userinfo_id: row.f_userinfo_id,
462
+ f_serial_number: f_serial_number,
463
+ f_user_id: row.f_user_id,
464
+ f_userfiles_id: row.f_userfiles_id,
465
+ f_pregas: model.f_pregas,
466
+ f_write_money: model.f_write_money,
467
+ f_balance: row.f_balance,
468
+ f_preamount: model.f_preamount,
469
+ f_total_gas: (row.f_total_gas - 0) + (model.f_pregas - 0),
470
+ f_write_totalgas: (row.f_write_totalgas - 0) + (model.f_pregas - 0),
471
+ f_write_totalfee: (row.f_write_totalfee - 0) + (model.f_write_money - 0),
472
+ f_total_fee: (row.f_total_fee - 0) + (model.f_preamount - 0),
473
+ f_collection: model.f_collection,
474
+ f_payment: model.f_payment.toString(),
475
+ payments: model.payments,
476
+ f_print: model.f_print.toString(),
477
+ f_voucher_number: model.f_voucher_number,
478
+ userinfo_version: row.userinfo_version,
479
+ version: row.version,
480
+ f_write_card: f_write_card === '不写卡' ? '不写卡' : '未写卡',
481
+ f_operator: Vue.$login.f.name,
482
+ f_operatorid: Vue.$login.f.id,
483
+ f_orgid: Vue.$login.f.orgid,
484
+ f_orgname: Vue.$login.f.orgs,
485
+ f_depid: Vue.$login.f.depids,
486
+ f_depname: Vue.$login.f.deps,
487
+ f_zoneid: Vue.$login.f.zoneid,
488
+ f_zones: Vue.$login.f.zones
489
+
490
+ }
491
+
492
+ return noCardSellGasGen(param, row)
493
+ },
494
+
495
+ // 补卡写卡
496
+ replaceCard (model, row, allot) {
497
+ // 磁条卡走了 replaceCiTiaoCard 不走这里
498
+ // if (row.f_meter_type.indexOf('卡表') === -1 && row.f_meter_type.indexOf('物联网表') === -1) {
499
+ // model.f_type = '补磁条卡'
500
+ // let replace = replaceCiTiaoCardGen(model, row)
501
+ // return co(replace)
502
+ // }
503
+ let replace = replaceCardGen(model, row, allot ? this.getallotdata(allot, row, '补卡') : null)
504
+ return co(replace)
505
+ },
506
+ // 磁条卡补卡写卡
507
+ replaceCiTiaoCard (model, row, allot) {
508
+ let replace = replaceCiTiaoCardGen(model, row)
509
+ return co(replace)
510
+ },
511
+ // 机表写卡
512
+ replaceCardJB (model, row) {
513
+ let replace = replaceCardGenJB(model, row)
514
+ return co(replace)
515
+ },
516
+ // 物联网写卡
517
+ replaceCardWeb (model, row) {
518
+ let replace = replaceCardGenWeb(model, row)
519
+ return co(replace)
520
+ },
521
+ replacecXq (model, row) {
522
+ let replace = replaceXq(model, row)
523
+ return co(replace)
524
+ }
525
+ }
526
+
527
+ // 判断是否有卡插入
528
+ let hasCardGen = async function () {
529
+ return await Vue.resetpost('http://127.0.0.1:8003/HasCard', {}, {resolveMsg: null, rejectMsg: null})
530
+ }
531
+ // 读卡
532
+ let readCard = async function () {
533
+ return await Vue.resetpost('http://127.0.0.1:8003/ReadCard', {data: {}}, {resolveMsg: null, rejectMsg: null})
534
+ }
535
+
536
+ let replaceCiTiaoCardGen = async function (model, row) {
537
+ // 1.存库 2.写卡
538
+ let result = null
539
+ let getCardNumber = {data: {cardNumber: null}}
540
+ try {
541
+ const OperatorInfo = {
542
+ f_operator: Vue.$login.f.name,
543
+ f_operatorid: Vue.$login.f.id,
544
+ f_orgid: Vue.$login.f.orgid,
545
+ f_orgname: Vue.$login.f.orgs,
546
+ f_depid: Vue.$login.f.depids,
547
+ f_depname: Vue.$login.f.deps
548
+ }
549
+ // 获取卡号
550
+ // if (!row.f_card_id) {
551
+ // getCardNumber = await Vue.resetpost('rs/logic/getCardNumber', {data: {id: row.brand_id}}, {
552
+ // resolveMsg: null,
553
+ // rejectMsg: '发卡售气获取卡号失败!!'
554
+ // })
555
+ // console.log('获取卡号、、', getCardNumber)
556
+ // } else {
557
+ // getCardNumber.data.cardNumber = row.f_card_id
558
+ // console.log('档案自带卡号、、', getCardNumber)
559
+ // }
560
+ if (row.f_userinfo_code) {
561
+ getCardNumber.data.cardNumber = row.f_card_id
562
+ }
563
+ result = await Vue.resetpost('rs/logic/sendCiTiaoCardRemanentGas', {
564
+ data: {
565
+ model,
566
+ getCardNumber,
567
+ row,
568
+ OperatorInfo
569
+ }
570
+ }, {resolveMsg: null, rejectMsg: '发卡售气存库失败'})
571
+ // 存库
572
+ console.log('换表发卡存库返回', result)
573
+ // 写卡
574
+ Vue.showAlert('请刷卡', 'warning', 50000)
575
+ // 组织写卡数据
576
+ let params = {
577
+ kh: result.data.cardnumber
578
+ }
579
+ let cardRes = await Vue.resetpost('http://127.0.0.1:8003/WriteCard_HEC', params, {
580
+ resolveMsg: null,
581
+ rejectMsg: '开户卡服务错误'
582
+ })
583
+ Vue.closeAlert()
584
+ if (!result || cardRes.data.Err || cardRes.data.Exception) {
585
+ // 写卡异常
586
+ await Vue.resetpost('rs/logic/sendCiTiaoCardRemanentGas', {
587
+ data: {
588
+ model,
589
+ getCardNumber,
590
+ row,
591
+ Chongzheng: true,
592
+ fill_id: result.data.id
593
+ }
594
+ }, {resolveMsg: null, rejectMsg: null})
595
+ throw new Error(`卡服务错误:${cardRes.data.Err}${cardRes.data.Exception},请联系开发人员处理!!`)
596
+ } else {
597
+ // 写卡成功
598
+ Vue.showAlert('写卡成功', 'success', 2000)
599
+ return result
600
+ }
601
+ } catch (error) {
602
+ console.log('换表发卡出错。。', error)
603
+ if (result) {
604
+ // 出错进行回滚
605
+ row.f_user_id = row.f_user_id + ''
606
+ if (result) {
607
+ await Vue.resetpost('rs/logic/sendCiTiaoCardRemanentGas', {
608
+ data: {
609
+ model,
610
+ getCardNumber,
611
+ row,
612
+ Chongzheng: true,
613
+ fill_id: result.data.id
614
+ }
615
+ }, {resolveMsg: null, rejectMsg: null})
616
+ }
617
+ }
618
+ if (error.data) {
619
+ throw new Error(error.data)
620
+ } else {
621
+ throw error
622
+ }
623
+ }
624
+ }
625
+
626
+ let sendCardSaleGasGenremanent = async function (model, row) {
627
+ // 1.存库 2.写卡
628
+ let result = null
629
+ try {
630
+ let cardState = await hasCardGen()
631
+ console.log('判卡函数返回:', cardState)
632
+ if (JSON.parse(cardState.data).state === 1) {
633
+ // 获取卡号
634
+ let getCardNumber = {data: {cardNumber: null}}
635
+ if (!row.f_card_id) {
636
+ getCardNumber = await Vue.resetpost('rs/logic/getCardNumber', {data: {id: row.brand_id}}, {resolveMsg: null, rejectMsg: '发卡售气获取卡号失败!!'})
637
+ console.log('获取卡号、、', getCardNumber)
638
+ } else {
639
+ getCardNumber.data.cardNumber = row.f_card_id
640
+ console.log('档案自带卡号、、', getCardNumber)
641
+ }
642
+ if (row.f_alias && row.f_alias.includes('SmartCard_TP')) {
643
+ model.cardNumber = row.f_meternumber
644
+ } else if (getCardNumber.data.cardNumber) {
645
+ model.cardNumber = getCardNumber.data.cardNumber + ''
646
+ } else {
647
+ throw new Error('获取卡号失败!请核实参数管理中的卡号重新换表发卡售气。')
648
+ }
649
+ result = await Vue.resetpost('rs/logic/sendCardRemanentGas', {data: model}, {resolveMsg: null, rejectMsg: '发卡售气存库失败'})
650
+ // 存库
651
+ console.log('换表发卡存库返回', result)
652
+ // 写卡
653
+ let cardParams = await getParamGen(result.data.cardnumber, row.f_alias, row.f_user_id, row.f_userfiles_id)
654
+
655
+ // 组织写卡数据
656
+ let params = {
657
+ factory: row.f_alias,
658
+ kmm: '0', // 2019-12-22 查旭说的。给一个0 卡密码,写卡后返回新密码, 不论补卡还是先开户都没有密码
659
+ kzt: '0', // 卡状态,0开户卡,1用户卡(0新开户,1补卡)
660
+ kh: result.data.cardnumber, // 卡号
661
+ yhh: row.f_meterid ? row.f_meterid : 0, // 用户号,档案中自己输
662
+ ql: model.f_pregas, // 预购气量
663
+ csql: '0', // 上次购气量,新开户为0
664
+ ccsql: '0', // 上上次购气量,新开户为0
665
+ cs: '1', // 求购气次数,先开户为1
666
+ ljgql: (row.f_total_gas - 0) + (model.f_pregas - 0), // 当前累计购气量
667
+ ljgqje: (row.f_total_fee - 0) + (model.f_preamount - 0), // 累计购气金额
668
+ bkcs: '0', // 新开户卡,为0
669
+ ljyql: '0', // 累积用气量,有些表要累加原来用气量,新开户卡,为0
670
+ bjql: row.f_police_gas, // 报警气量,t_gasbrand表中
671
+ czsx: row.f_topup_ceil, // 充值上线,t_gasbrand表中
672
+ tzed: row.f_overdr_lines, // 透支额度,t_gasbrand表中
673
+ cssqrq: '0', // 上次售气日期,格式为YYYYMMDD
674
+ meterid: row.f_meternumber, // 表号
675
+ money: model.f_preamount, // 购气金额
676
+ dqdm: row.f_area_code, // 精益工业地区代码
677
+ klx: row.f_coding
678
+ }
679
+ // 判断是否是累购表
680
+ if (row.f_support_purchase === '') {
681
+ params.ljgql = (row.f_write_totalgas - 0) + (model.f_pregas - 0)
682
+ params.ljgqje = (row.f_write_totalfee - 0) + (model.f_preamount - 0)
683
+ }
684
+ params = Object.assign({}, Vue.CommonService.writeCardParams(cardParams), params)
685
+ console.log('换表发卡写卡参数', params)
686
+ let cardRes = await Vue.resetpost('http://127.0.0.1:8003/WriteNewCard', params, {
687
+ resolveMsg: null,
688
+ rejectMsg: '开户卡服务错误'
689
+ })
690
+ if (!cardParams || ((model.f_pregas > model.f_remanent_gas) && !result) || cardRes.data.Err || cardRes.data.Exception) {
691
+ // 写卡异常
692
+ // 数据回滚操作
693
+ // 由于数据太长,将f_user_id 更改为字符串
694
+ row.f_userfiles_id = row.f_userfiles_id + ''
695
+
696
+ await Vue.resetpost('rs/logic/remanentRollback', {data: {fillgasid: result.data.fillgasid, sellid: result.data.sellid, row: row}}, {
697
+ resolveMsg: null,
698
+ rejectMsg: '开户失败'
699
+ })
700
+ throw new Error(`卡服务错误:${cardRes.data.Err}${cardRes.data.Exception},请联系开发人员处理!!`)
701
+ } else {
702
+ // 写卡成功
703
+ // 更新卡密码
704
+ row.version = result.data.version - 1,
705
+ await Vue.CommonService.updatePassword(row, cardRes)
706
+ Vue.showAlert('补气购气成功', 'success', 2000)
707
+ return result
708
+ }
709
+ } else {
710
+ throw new Error(`请检查卡是否插好!!`)
711
+ }
712
+ } catch (error) {
713
+ console.log('换表发卡出错。。', error)
714
+
715
+ if (result) {
716
+ // 出错进行回滚
717
+ row.f_user_id = row.f_user_id + ''
718
+ if (result) {
719
+ await Vue.resetpost('rs/logic/remanentRollback', {data: {fillgasid: result.data.fillgasid, sellid: result.data.sellid, row: row}}, {
720
+ resolveMsg: null,
721
+ rejectMsg: '写卡失败,数据回滚失败,请联系技术人员处理!!'
722
+ })
723
+ }
724
+ }
725
+
726
+ if (error.data) {
727
+ throw new Error(error.data)
728
+ } else {
729
+ throw error
730
+ }
731
+ }
732
+ }
733
+ let resetsendCardSaleGasGen = async function (model, row) {
734
+ // 1.存库 2.写卡
735
+ let result = null
736
+ try {
737
+ let cardState = await hasCardGen()
738
+ console.log('判卡函数返回:', cardState)
739
+ if (JSON.parse(cardState.data).state === 1) {
740
+ // 获取卡号
741
+ let getCardNumber = await Vue.resetpost('rs/logic/getCardNumber', {data: {id: row.brand_id}}, {resolveMsg: null, rejectMsg: '重发卡售气获取卡号失败!!'})
742
+ console.log('获取卡号、、', getCardNumber)
743
+ if (getCardNumber.data.cardNumber) {
744
+ // 当卡的别名是泰鹏普通卡的时候卡号和表号一致
745
+ console.log('开始验证是不是泰鹏普通卡')
746
+ if (row.f_alias && row.f_alias.includes('SmartCard_TP')) {
747
+ model.cardNumber = row.f_meternumber
748
+ } else {
749
+ model.cardNumber = getCardNumber.data.cardNumber + ''
750
+ model.f_card_id = getCardNumber.data.cardNumber + ''
751
+ }
752
+ } else {
753
+ throw new Error('获取卡号失败!请核实参数管理中的卡号重新发卡售气。')
754
+ }
755
+ // 存库
756
+ result = await Vue.resetpost('rs/logic/sale_resetsendCardSaleGas_logic', {data: model}, {resolveMsg: null, rejectMsg: '重发卡售气存库失败'})
757
+ console.log('重发卡售气存库返回', result)
758
+ // 写卡
759
+ let cardParams = await getParamGen(result.data.cardnumber, row.f_alias, row.f_user_id, row.f_userfiles_id)
760
+
761
+ // 组织写卡数据
762
+ let params = {
763
+ factory: row.f_alias,
764
+ kmm: '0', // 2019-12-22 查旭说的。给一个0 卡密码,写卡后返回新密码, 不论补卡还是先开户都没有密码
765
+ kzt: '0', // 卡状态,0开户卡,1用户卡(0新开户,1补卡)
766
+ kh: result.data.cardnumber, // 卡号
767
+ yhh: row.f_meterid ? row.f_meterid : 0, // 用户号,档案中自己输
768
+ ql: model.f_pregas, // 预购气量
769
+ csql: '0', // 上次购气量,新开户为0
770
+ ccsql: '0', // 上上次购气量,新开户为0
771
+ cs: '1', // 求购气次数,先开户为1
772
+ // ljgql: model.f_pregas, // 当前累计购气量
773
+ bkcs: '0', // 新开户卡,为0
774
+ ljyql: '0', // 累积用气量,有些表要累加原来用气量,新开户卡,为0
775
+ bjql: row.f_police_gas, // 报警气量,t_gasbrand表中
776
+ czsx: row.f_topup_ceil, // 充值上线,t_gasbrand表中
777
+ tzed: row.f_overdr_lines, // 透支额度,t_gasbrand表中
778
+ cssqrq: '0', // 上次售气日期,格式为YYYYMMDD
779
+ meterid: row.f_meternumber, // 表号
780
+ money: model.f_preamount, // 购气金额
781
+ dqdm: row.f_area_code, // 精益工业地区代码
782
+ klx: row.f_coding,
783
+ ljgql: (row.f_total_gas - 0) + (model.f_pregas - 0), // 当前累计购气量
784
+ ljgqje: (row.f_total_fee - 0) + (model.f_preamount - 0) // 累计购气金额
785
+ }
786
+ // 判断是否是累购表
787
+ if (row.f_support_purchase === '') {
788
+ params.ljgql = (row.f_write_totalgas - 0) + (model.f_pregas - 0)
789
+ params.ljgqje = (row.f_write_totalfee - 0) + (model.f_preamount - 0)
790
+ }
791
+ params = Object.assign({}, Vue.CommonService.writeCardParams(cardParams), params)
792
+ console.log('重发卡售气写卡参数', params)
793
+ let cardRes = await Vue.resetpost('http://127.0.0.1:8003/WriteNewCard', params, {
794
+ resolveMsg: null,
795
+ rejectMsg: '重开户卡服务错误'
796
+ })
797
+ if (!cardParams || !result || cardRes.data.Err || cardRes.data.Exception) {
798
+ // 写卡异常
799
+ // 数据回滚操作
800
+ throw `卡服务错误:${cardRes.data.Err}${cardRes.data.Exception},请联系开发人员处理!!`
801
+ } else {
802
+ // 写卡成功
803
+ // 更新卡密码
804
+ await Vue.CommonService.updatePassword(row, cardRes)
805
+ Vue.showAlert('初始化卡成功', 'success', 2000)
806
+ return result
807
+ }
808
+ } else {
809
+ throw new Error(`请检查卡是否插好!!`)
810
+ }
811
+ } catch (error) {
812
+ if (result) {
813
+ // 出错进行回滚
814
+ row.f_userfiles_id = row.f_userfiles_id + ''
815
+ if (result) {
816
+ await Vue.resetpost('rs/logic/salecardrollback', {data: {id: result.data.id, row: row}}, {
817
+ resolveMsg: null,
818
+ rejectMsg: '写卡失败,数据回滚失败,请联系技术人员处理!!'
819
+ })
820
+ }
821
+ }
822
+ if (error.data) {
823
+ throw new Error(error.data)
824
+ } else {
825
+ throw error
826
+ }
827
+ }
828
+ }
829
+
830
+ let sendCardSaleGasGen = async function (model, row) {
831
+ // 1.存库 2.写卡
832
+ let result = null
833
+ try {
834
+ let cardState = await hasCardGen()
835
+ console.log('判卡函数返回:', cardState)
836
+ if (JSON.parse(cardState.data).state === 1) {
837
+ // 获取卡号
838
+ let getCardNumber = {data: {cardNumber: null}}
839
+ if (!row.f_card_id) {
840
+ getCardNumber = await Vue.resetpost('rs/logic/getCardNumber', {data: {id: row.brand_id}}, {resolveMsg: null, rejectMsg: '发卡售气获取卡号失败!!'})
841
+ console.log('获取卡号、、', getCardNumber)
842
+ } else {
843
+ getCardNumber.data.cardNumber = row.f_card_id
844
+ console.log('档案自带卡号、、', getCardNumber)
845
+ }
846
+ if (getCardNumber.data.cardNumber) {
847
+ // 当卡的别名是泰鹏普通卡的时候卡号和表号一致
848
+ console.log('开始验证是不是泰鹏普通卡')
849
+ if (row.f_alias && row.f_alias.includes('SmartCard_TP')) {
850
+ model.cardNumber = row.f_meternumber
851
+ } else if (row.f_alias && row.f_alias.includes('LaiDeRF')) {
852
+ model.cardNumber = row.f_card_id
853
+ } else {
854
+ model.cardNumber = getCardNumber.data.cardNumber + ''
855
+ }
856
+ } else {
857
+ throw new Error('获取卡号失败!请核实参数管理中的卡号重新发卡售气。')
858
+ }
859
+ // 存库
860
+ result = await Vue.resetpost('rs/logic/sale_sendCardSaleGas_logic', {data: model}, {resolveMsg: null, rejectMsg: '发卡售气存库失败'})
861
+ console.log('发卡售气存库返回', result)
862
+ // 写卡
863
+ let cardParams = await getParamGen(result.data.cardnumber, row.f_alias, row.f_user_id, row.f_userfiles_id)
864
+
865
+ // 组织写卡数据
866
+ let params = {
867
+ factory: row.f_alias,
868
+ kmm: '0', // 2019-12-22 查旭说的。给一个0 卡密码,写卡后返回新密码, 不论补卡还是先开户都没有密码
869
+ kzt: '0', // 卡状态,0开户卡,1用户卡(0新开户,1补卡)
870
+ kh: result.data.cardnumber, // 卡号
871
+ yhh: row.f_meterid ? row.f_meterid : 0, // 用户号,档案中自己输
872
+ ql: model.f_pregas, // 预购气量
873
+ csql: '0', // 上次购气量,新开户为0
874
+ ccsql: '0', // 上上次购气量,新开户为0
875
+ cs: '1', // 求购气次数,先开户为1
876
+ // ljgql: model.f_pregas, // 当前累计购气量
877
+ bkcs: '0', // 新开户卡,为0
878
+ ljyql: '0', // 累积用气量,有些表要累加原来用气量,新开户卡,为0
879
+ bjql: row.f_police_gas, // 报警气量,t_gasbrand表中
880
+ czsx: row.f_topup_ceil, // 充值上线,t_gasbrand表中
881
+ tzed: row.f_overdr_lines, // 透支额度,t_gasbrand表中
882
+ cssqrq: '0', // 上次售气日期,格式为YYYYMMDD
883
+ meterid: row.f_meternumber, // 表号
884
+ money: model.f_write_money, // 购气金额
885
+ dqdm: row.f_area_code, // 精益工业地区代码
886
+ klx: row.f_coding,
887
+ ljgql: (row.f_write_totalgas - 0) + (model.f_pregas - 0), // 当前累计购气量
888
+ ljgqje: (row.f_write_totalfee - 0) + (model.f_write_money - 0) // 累计购气金额
889
+ }
890
+ // 天源表发卡售气时,cs默认给0
891
+ if (row.f_alias && row.f_alias.includes('TianYuan')) {
892
+ console.log('天源表发卡售气时,写卡次数给:', params.cs)
893
+ params.cs = '0'
894
+ }
895
+ // 判断是否是累购表
896
+ if (row.f_support_purchase === '') {
897
+ params.ljgql = (row.f_write_totalgas - 0) + (model.f_pregas - 0)
898
+ params.ljgqje = (row.f_write_totalfee - 0) + (model.f_preamount - 0)
899
+ }
900
+ params = Object.assign({}, Vue.CommonService.writeCardParams(cardParams), params)
901
+ console.log('发卡售气写卡参数', params)
902
+ let cardRes = await Vue.resetpost('http://127.0.0.1:8003/WriteNewCard', params, {
903
+ resolveMsg: null,
904
+ rejectMsg: '开户卡服务错误'
905
+ })
906
+ if (!cardParams || !result || cardRes.data.Err || cardRes.data.Exception) {
907
+ // 写卡异常
908
+ // 数据回滚操作
909
+ throw `卡服务错误:${cardRes.data.Err}${cardRes.data.Exception},请联系开发人员处理!!`
910
+ } else {
911
+ // 写卡成功
912
+ // 更新卡密码
913
+ await Vue.CommonService.updatePassword(row, cardRes)
914
+ Vue.showAlert('发卡售气成功', 'success', 2000)
915
+ return result
916
+ }
917
+ } else {
918
+ throw new Error(`请检查卡是否插好!!`)
919
+ }
920
+ } catch (error) {
921
+ if (result) {
922
+ // 出错进行回滚
923
+ row.f_userfiles_id = row.f_userfiles_id + ''
924
+ if (result) {
925
+ await Vue.resetpost('rs/logic/salecardrollback', {data: {id: result.data.id, row: row}}, {
926
+ resolveMsg: null,
927
+ rejectMsg: '写卡失败,数据回滚失败,请联系技术人员处理!!'
928
+ })
929
+ }
930
+ }
931
+ if (error.data) {
932
+ throw new Error(error.data)
933
+ } else {
934
+ throw error
935
+ }
936
+ }
937
+ }
938
+
939
+ let replaceCardGen2 = function * (model, row, allot) {
940
+ let result = yield co(reissueCardGen(model, row))
941
+ let data = {
942
+ userfiles: {},
943
+ record: {
944
+ id: result.data.id,
945
+ f_state: '有效'
946
+ }
947
+ }
948
+ return yield Vue.resetpost('rs/logic/updatemark', {data: data}, {resolveMsg: '补卡成功', rejectMsg: '补卡修改状态失败'})
949
+ }
950
+ // 物联网表发卡管理
951
+ let replaceCardGenWeb = function * (model, row) {
952
+ let result = null
953
+ let allotback
954
+ try {
955
+ // 判断是否有卡
956
+ let cardState = yield co(hasCardGen())
957
+ if (JSON.parse(cardState.data).state === 1) {
958
+ let cardId = ''
959
+ if (row.f_card_id && row.f_card_id !== 'null') {
960
+ cardId = row.f_card_id
961
+ } else {
962
+ let getCardNumber = yield co(getCardNumberGen(row.f_gasbrand_id))
963
+ console.log('获取卡号、、', getCardNumber)
964
+ cardId = getCardNumber.data.cardNumber
965
+ }
966
+ if (row.f_tag) {
967
+ // 截取用户编号后四位
968
+ cardId = row.f_tag + row.f_card_id
969
+ }
970
+ model.f_card_id = cardId
971
+ // 存库
972
+ result = yield co(reissueCardGenJB(model, row))
973
+ // 获取气价和售气情况参数
974
+ let cardParams = yield co(getParamGen(cardId, row.f_alias, row.f_user_id, row.f_userfiles_id))
975
+ // 写卡
976
+ let params = {
977
+ factory: row.f_alias,
978
+ kh: cardId, // 卡号
979
+ kmm: row.f_card_password, // 卡密码,写卡后返回新密码, 不论补卡还是先开户都没有密码
980
+ bjql: row.f_police_gas, // 报警气量,t_gasbrand表中
981
+ czsx: row.f_topup_ceil, // 充值上线,t_gasbrand表中
982
+ tzed: row.f_overdr_lines, // 透支额度,t_gasbrand表中
983
+ ljgql: (row.f_total_gas - 0), // 当前累计购气量
984
+ ljgqje: (row.f_total_fee - 0), // 累计购气金额
985
+ kzt: '1', // 卡状态,0开户卡,1用户卡(0新开户,1补卡)
986
+ bkcs: row.f_fillcard_times + 1, // 补卡次数,从补卡表里通过表编号获得
987
+ cs: row.f_times, // 求购气次数,先开户为1
988
+ yhh: row.f_meterid ? row.f_meterid : 0, // 用户号
989
+ meterid: row.f_meternumber, // 表号
990
+ meternumber: row.f_meternumber,
991
+ dqdm: row.f_area_code, // 精益工业地区代码
992
+ money: 0, // 购气金额
993
+ klx: row.f_coding
994
+ }
995
+ // 判断是否是累购表
996
+ if (row.f_support_purchase === '') {
997
+ params.ljgql = (row.f_write_totalgas - 0) + (model.f_pregas - 0)
998
+ params.ljgqje = (row.f_write_totalfee - 0) + (model.f_preamount - 0)
999
+ }
1000
+ params = Object.assign({}, Vue.CommonService.writeCardParams(cardParams), params)
1001
+ console.log('补卡是写的次数。。。。', params)
1002
+ let cardRes = yield co(Vue.resetpost('http://127.0.0.1:8003/WriteNewCard', params, {
1003
+ resolveMsg: null,
1004
+ rejectMsg: '补卡卡服务错误'
1005
+ }))
1006
+ // 卡服务写卡异常,业务逻辑回滚
1007
+ if (!cardParams || !result || cardRes.data.Err || cardRes.data.Exception) {
1008
+ Vue.$showAlert('物联网表补卡失败!!', 'danger', 0)
1009
+ let rollbackParam = {
1010
+ id: result.data.id,
1011
+ f_card_id: row.f_card_id,
1012
+ f_whether_hairpin: row.f_whether_hairpin,
1013
+ f_user_id: row.f_user_id
1014
+ }
1015
+ if (row.f_tag) {
1016
+ rollbackParam.f_tag = row.f_tag
1017
+ }
1018
+ yield Vue.resetpost('rs/logic/repairCardRoolBack', {data: rollbackParam}, {
1019
+ resolveMsg: null,
1020
+ rejectMsg: null
1021
+ })
1022
+ } else {
1023
+ // 如果成功修改标识(更新状态为有效)
1024
+ // 没有更新过表档案,这里版本号减一
1025
+ row.version = (row.version - 0) - 1
1026
+ yield co(Vue.CommonService.updatePassword(row, cardRes))
1027
+ let data = {
1028
+ userfiles: {
1029
+ f_card_id: row.f_card_id,
1030
+ f_whether_hairpin: '已发'
1031
+ },
1032
+ record: {
1033
+ id: result.data.id,
1034
+ f_state: '有效'
1035
+ }
1036
+ }
1037
+ return yield Vue.resetpost('rs/logic/updatemark', {data: data}, {resolveMsg: '物联网表补卡成功', rejectMsg: '补卡修改状态失败'})
1038
+ }
1039
+ } else {
1040
+ Vue.showAlert('请检查卡是否插好!!', 'danger', 3000)
1041
+ }
1042
+ } catch (error) {
1043
+ let msg = ''
1044
+ if (error.status === 612) {
1045
+ msg = '请检查读卡器时候连接,或者卡服务是否启动!!'
1046
+ } else {
1047
+ msg = '补卡失败!!'
1048
+
1049
+ let rollbackParam = {
1050
+ id: result.data.id,
1051
+ f_card_id: null,
1052
+ f_whether_hairpin: row.f_whether_hairpin,
1053
+ f_user_id: row.f_user_id
1054
+ }
1055
+ if (row.f_tag) {
1056
+ rollbackParam.f_tag = row.f_tag
1057
+ }
1058
+ yield Vue.resetpost('rs/logic/repairCardRoolBack', {data: rollbackParam}, {
1059
+ resolveMsg: null,
1060
+ rejectMsg: '物联网表补卡失败!!'
1061
+ })
1062
+ }
1063
+ Vue.showAlert(msg, 'danger', 0)
1064
+ }
1065
+ }
1066
+ // 机表补卡管理
1067
+ let replaceCardGenJB = function * (model, row) {
1068
+ let result = null
1069
+ let allotback
1070
+ try {
1071
+ // 判断是否有卡
1072
+ let cardState = yield co(hasCardGen())
1073
+ if (JSON.parse(cardState.data).state === 1) {
1074
+ let cardId = row.f_card_id
1075
+ if (row.f_tag) {
1076
+ // 截取用户编号后四位
1077
+ cardId = row.f_tag + row.f_card_id
1078
+ }
1079
+ model.f_card_id = cardId
1080
+ // 存库
1081
+ result = yield co(reissueCardGenJB(model, row))
1082
+ // 获取气价和售气情况参数
1083
+ let cardParams = yield co(getParamGen(cardId, row.f_alias, row.f_user_id, row.f_userfiles_id))
1084
+ // 写卡
1085
+ let params = {
1086
+ factory: row.f_alias,
1087
+ kh: cardId, // 卡号
1088
+ kmm: row.f_card_password, // 卡密码,写卡后返回新密码, 不论补卡还是先开户都没有密码
1089
+ bjql: row.f_police_gas, // 报警气量,t_gasbrand表中
1090
+ czsx: row.f_topup_ceil, // 充值上线,t_gasbrand表中
1091
+ tzed: row.f_overdr_lines, // 透支额度,t_gasbrand表中
1092
+ ljgql: (row.f_total_gas - 0) + (model.f_pregas - 0), // 当前累计购气量
1093
+ ljgqje: (row.f_total_fee - 0) + (model.f_preamount - 0), // 累计购气金额
1094
+ kzt: '1', // 卡状态,0开户卡,1用户卡(0新开户,1补卡)
1095
+ bkcs: row.f_fillcard_times + 1, // 补卡次数,从补卡表里通过表编号获得
1096
+ cs: row.f_times, // 求购气次数,先开户为1
1097
+ yhh: row.f_meterid ? row.f_meterid : 0, // 用户号
1098
+ meterid: row.f_meternumber, // 表号
1099
+ meternumber: row.f_meternumber,
1100
+ dqdm: row.f_area_code, // 精益工业地区代码
1101
+ money: 0, // 购气金额
1102
+ klx: row.f_coding
1103
+ }
1104
+ // 判断是否是累购表
1105
+ if (row.f_support_purchase === '') {
1106
+ params.ljgql = (row.f_write_totalgas - 0) + (model.f_pregas - 0)
1107
+ params.ljgqje = (row.f_write_totalfee - 0) + (model.f_preamount - 0)
1108
+ }
1109
+ params = Object.assign({}, Vue.CommonService.writeCardParams(cardParams), params)
1110
+ console.log('补卡是写的次数。。。。', params)
1111
+ let cardRes = yield co(Vue.resetpost('http://127.0.0.1:8003/WriteNewCard', params, {
1112
+ resolveMsg: null,
1113
+ rejectMsg: '补卡卡服务错误'
1114
+ }))
1115
+ // 卡服务写卡异常,业务逻辑回滚
1116
+ if (!cardParams || !result || cardRes.data.Err || cardRes.data.Exception) {
1117
+ Vue.$showAlert('机表补卡失败!!', 'danger', 0)
1118
+ let rollbackParam = {
1119
+ id: result.data.id,
1120
+ f_card_id: row.f_card_id,
1121
+ f_whether_hairpin: row.f_whether_hairpin,
1122
+ f_user_id: row.f_user_id
1123
+ }
1124
+ if (row.f_tag) {
1125
+ rollbackParam.f_tag = row.f_tag
1126
+ }
1127
+ yield Vue.resetpost('rs/logic/repairCardRoolBack', {data: rollbackParam}, {
1128
+ resolveMsg: null,
1129
+ rejectMsg: null
1130
+ })
1131
+ } else {
1132
+ // 如果成功修改标识(更新状态为有效)
1133
+ // 没有更新过表档案,这里版本号减一
1134
+ row.version = (row.version - 0) - 1
1135
+ yield co(Vue.CommonService.updatePassword(row, cardRes))
1136
+ let data = {
1137
+ userfiles: {
1138
+ f_card_id: row.f_card_id,
1139
+ f_whether_hairpin: '已发'
1140
+ },
1141
+ record: {
1142
+ id: result.data.id,
1143
+ f_state: '有效'
1144
+ }
1145
+ }
1146
+ return yield Vue.resetpost('rs/logic/updatemark', {data: data}, {resolveMsg: '机表补卡成功', rejectMsg: '补卡修改状态失败'})
1147
+ }
1148
+ } else {
1149
+ Vue.showAlert('请检查卡是否插好!!', 'danger', 3000)
1150
+ }
1151
+ } catch (error) {
1152
+ let msg = ''
1153
+ if (error.status === 612) {
1154
+ msg = '请检查读卡器时候连接,或者卡服务是否启动!!'
1155
+ } else {
1156
+ msg = '补卡失败!!'
1157
+
1158
+ let rollbackParam = {
1159
+ id: result.data.id,
1160
+ f_card_id: null,
1161
+ f_whether_hairpin: row.f_whether_hairpin,
1162
+ f_user_id: row.f_user_id
1163
+ }
1164
+ if (row.f_tag) {
1165
+ rollbackParam.f_tag = row.f_tag
1166
+ }
1167
+ yield Vue.resetpost('rs/logic/repairCardRoolBack', {data: rollbackParam}, {
1168
+ resolveMsg: null,
1169
+ rejectMsg: '机表补卡失败!!'
1170
+ })
1171
+ }
1172
+ Vue.showAlert(msg, 'danger', 0)
1173
+ }
1174
+ }
1175
+ // 擦虚气
1176
+ let replaceXq = function * (model, row) {
1177
+ let result = null
1178
+ let cardState = yield co(hasCardGen())
1179
+ if (JSON.parse(cardState.data).state === 1) {
1180
+ let params = {
1181
+ factory: row.f_alias,
1182
+ kh: row.f_card_id, // 卡号
1183
+ kmm: row.f_card_password, // 卡密码,写卡后返回新密码, 不论补卡还是先开户都没有密码
1184
+ bjql: row.f_police_gas, // 报警气量,t_gasbrand表中
1185
+ czsx: row.f_topup_ceil, // 充值上线,t_gasbrand表中
1186
+ tzed: row.f_overdr_lines, // 透支额度,t_gasbrand表中
1187
+ ljgql: (row.f_total_gas - 0), // 当前累计购气量
1188
+ ljgqje: (row.f_total_fee - 0), // 累计购气金额
1189
+ kzt: '1', // 卡状态,0开户卡,1用户卡(0新开户,1补卡)
1190
+ bkcs: row.f_fillcard_times + 1, // 补卡次数,从补卡表里通过表编号获得
1191
+ cs: row.f_times, // 求购气次数,先开户为1
1192
+ yhh: row.f_meterid ? row.f_meterid : 0, // 用户号
1193
+ meterid: row.f_meternumber, // 表号
1194
+ meternumber: row.f_meternumber,
1195
+ dqdm: row.f_area_code, // 精益工业地区代码
1196
+ money: 0, // 购气金额
1197
+ klx: row.f_coding
1198
+ }
1199
+ let cardRes = yield co(Vue.resetpost('http://127.0.0.1:8003/WriteNewCard', params, {
1200
+ resolveMsg: null,
1201
+ rejectMsg: '擦虚气服务错误'
1202
+ }))
1203
+ if (cardRes.data.Err || cardRes.data.Exception) {
1204
+ return {status: 1}
1205
+ } else {
1206
+ return {status: 0}
1207
+ }
1208
+ } else {
1209
+ Vue.showAlert('请检查卡是否插好!!', 'danger', 3000)
1210
+ }
1211
+ }
1212
+
1213
+ // 补卡管理
1214
+ let replaceCardGen = function * (model, row, allot) {
1215
+ let result = null
1216
+ let allotback
1217
+ try {
1218
+ // 判断是否有卡
1219
+ let cardState = yield co(hasCardGen())
1220
+ if (JSON.parse(cardState.data).state === 1) {
1221
+ let cardId = row.f_card_id
1222
+ // 如果当前是物联网表,表未发卡,进行补需要获取卡号
1223
+ if (!(row.f_hascard == null) && !(row.f_share_times == null) && row.f_meter_type === '物联网表' && row.f_hascard === '是' && row.f_share_times === '是' && (row.f_card_id == null || row.f_card_id === '')) {
1224
+ let getCardNumber = yield Vue.resetpost('rs/logic/getCardNumber', {data: {id: row.brand_id}}, {resolveMsg: null, rejectMsg: '发卡售气获取卡号失败!!'})
1225
+ console.log('获取卡号、、', getCardNumber)
1226
+ if (getCardNumber.data.cardNumber) {
1227
+ cardId = getCardNumber.data.cardNumber
1228
+ } else {
1229
+ throw new Error('获取卡号失败!请核实参数管理中的卡号重新发卡售气。')
1230
+ }
1231
+ }
1232
+ if (row.f_tag) {
1233
+ // 截取用户编号后四位
1234
+ cardId = row.f_tag + row.f_card_id
1235
+ }
1236
+ model.f_card_id = cardId
1237
+ // 存库
1238
+ result = yield co(reissueCardGen(model, row))
1239
+ if (allot) {
1240
+ allotback = yield Vue.resetpost('rs/logic/saveAllotData', {data: allot}, {
1241
+ resolveMsg: null,
1242
+ rejectMsg: '更新发卡信息失败'
1243
+ })
1244
+ }
1245
+ // 获取气价和售气情况参数
1246
+ let cardParams = yield co(getParamGen(cardId, row.f_alias, row.f_user_id, row.f_userfiles_id))
1247
+ console.log('补卡是写的次数111。。。。', row, model)
1248
+ // 写卡
1249
+ let params = {
1250
+ factory: row.f_alias,
1251
+ kh: cardId, // 卡号
1252
+ kmm: row.f_card_password, // 卡密码,写卡后返回新密码, 不论补卡还是先开户都没有密码
1253
+ bjql: row.f_police_gas, // 报警气量,t_gasbrand表中
1254
+ czsx: row.f_topup_ceil, // 充值上线,t_gasbrand表中
1255
+ tzed: row.f_overdr_lines, // 透支额度,t_gasbrand表中
1256
+ ljgql: (row.f_total_gas - 0), // 当前累计购气量
1257
+ ljgqje: (row.f_total_fee - 0), // 累计购气金额
1258
+ kzt: '1', // 卡状态,0开户卡,1用户卡(0新开户,1补卡)
1259
+ bkcs: row.f_fillcard_times + 1, // 补卡次数,从补卡表里通过表编号获得
1260
+ cs: row.f_times, // 求购气次数,先开户为1
1261
+ yhh: row.f_meterid ? row.f_meterid : 0, // 用户号
1262
+ meterid: row.f_meternumber, // 表号
1263
+ meternumber: row.f_meternumber,
1264
+ dqdm: row.f_area_code, // 精益工业地区代码
1265
+ money: 0, // 购气金额
1266
+ klx: row.f_coding
1267
+ }
1268
+ // 判断是否是累购表
1269
+ if (row.f_support_purchase === '') {
1270
+ params.ljgql = (row.f_write_totalgas - 0)
1271
+ params.ljgqje = (row.f_write_totalfee - 0)
1272
+ }
1273
+ // 判断是否接表,如果未接表(次数减一)已过表(次数为档案里面的次数) 针对不补气的
1274
+ if (model.f_ispick_table) {
1275
+ params.cs = (model.f_ispick_table === '未过表' ? row.f_times - 1 : row.f_times)
1276
+ }
1277
+
1278
+ params = Object.assign({}, Vue.CommonService.writeCardParams(cardParams), params)
1279
+ // if (row.f_alias === 'HaiLiJE' || row.f_alias === 'HaiLiQL' || row.f_alias === 'CangNanTY') {
1280
+ // params.klx = yield co(getmodelbrandGen(row))
1281
+ // params.klx = params.klx.data[0].f_coding
1282
+ // }
1283
+ console.log('补卡是写的次数。。。。', params)
1284
+
1285
+ let cardRes = yield co(Vue.resetpost('http://127.0.0.1:8003/WriteNewCard', params, {
1286
+ resolveMsg: null,
1287
+ rejectMsg: '补卡卡服务错误'
1288
+ }))
1289
+ // 卡服务写卡异常,业务逻辑回滚
1290
+ if (!cardParams || !result || cardRes.data.Err || cardRes.data.Exception) {
1291
+ Vue.$showAlert('补卡失败!!', 'danger', 0)
1292
+ let rollbackParam = {
1293
+ id: result.data.id,
1294
+ f_card_id: row.f_card_id,
1295
+ f_user_id: row.f_user_id
1296
+ }
1297
+ if (row.f_tag) {
1298
+ rollbackParam.f_tag = row.f_tag
1299
+ }
1300
+ yield Vue.resetpost('rs/logic/repairCardRoolBack', {data: rollbackParam}, {
1301
+ resolveMsg: null,
1302
+ rejectMsg: null
1303
+ })
1304
+ // 更新卡状态为作废
1305
+ if (allot) {
1306
+ yield Vue.resetpost('rs/logic/allotDataRollback', {data: allotback.data}, {resolveMsg: null, rejectMsg: null})
1307
+ }
1308
+ } else {
1309
+ // 如果成功修改标识(更新状态为有效)
1310
+ // 没有更新过表档案,这里版本号减一
1311
+ row.version = (row.version - 0) - 1
1312
+ yield co(Vue.CommonService.updatePassword(row, cardRes))
1313
+ let data = {
1314
+ userfiles: {},
1315
+ record: {
1316
+ id: result.data.id,
1317
+ f_state: '有效'
1318
+ }
1319
+ }
1320
+ return yield Vue.resetpost('rs/logic/updatemark', {data: data}, {resolveMsg: '补卡成功', rejectMsg: '补卡修改状态失败'})
1321
+ }
1322
+ } else {
1323
+ Vue.showAlert('请检查卡是否插好!!', 'danger', 3000)
1324
+ }
1325
+ } catch (error) {
1326
+ let msg = ''
1327
+ if (error.status === 612) {
1328
+ msg = '请检查读卡器时候连接,或者卡服务是否启动!!'
1329
+ } else {
1330
+ msg = '补卡失败!!'
1331
+
1332
+ let rollbackParam = {
1333
+ id: result.data.id,
1334
+ f_card_id: row.f_card_id,
1335
+ f_user_id: row.f_user_id
1336
+ }
1337
+ if (row.f_tag) {
1338
+ rollbackParam.f_tag = row.f_tag
1339
+ }
1340
+ yield Vue.resetpost('rs/logic/repairCardRoolBack', {data: rollbackParam}, {
1341
+ resolveMsg: null,
1342
+ rejectMsg: '补卡失败!!'
1343
+ })
1344
+ }
1345
+ // 更新卡状态为作废
1346
+ if (allot) {
1347
+ yield Vue.resetpost('rs/logic/allotDataRollback', {data: allotback.data}, {resolveMsg: null, rejectMsg: null})
1348
+ }
1349
+ Vue.showAlert(msg, 'danger', 0)
1350
+ }
1351
+ }
1352
+
1353
+ let offlineWriteGen2 = async function (row) {
1354
+ let update = {
1355
+ id: row.unWriteSell[0].id,
1356
+ f_write_operator: Vue.$login.f.name,
1357
+ f_write_date: Vue.$login.toStandardTimeString()
1358
+ }
1359
+ await Vue.resetpost('rs/logic/offlineWrite', update, {resolveMsg: '写卡成功', rejectMsg: '写卡成功,更新数据失败'})
1360
+ }
1361
+
1362
+ let offlineWriteGen = async function (row) {
1363
+ console.log('线下写卡', row)
1364
+ try {
1365
+ // 写卡前调用(该为特殊业务逻辑根据需要写到project工程) (有些第三方缴费柜台写卡,用户缴费之后,如果在规定时间内不写卡,就会进行退款。所以写卡前调用第三方锁定订单。写卡成功或失败调用对应的接口告知第三方)
1366
+
1367
+ let beforeParam = {
1368
+ id: row.unWriteSell[0].id,
1369
+ f_operatorid: Vue.$login.f.id,
1370
+ f_depid: Vue.$login.f.depids
1371
+ }
1372
+
1373
+ await Vue.resetpost('rs/logic/sale_write_before', {data: beforeParam}, {resolveMsg: null, rejectMsg: '线下写卡前调用第三方失败!!'})
1374
+
1375
+ let cardState = await hasCardGen()
1376
+ if (JSON.parse(cardState.data).state === 1) {
1377
+ // 获取
1378
+ let result = await Vue.resetpost('rs/logic/sale_getLastOper', {data: {f_userfiles_id: row.f_userfiles_id}}, {resolveMsg: null, rejectMsg: '获取最后一次操作失败'})
1379
+ console.log('获取最后一次的操作。。', result)
1380
+ // 先把收费记录状态改成 已写卡在进行操作
1381
+ // 写卡成功 更新收费记录
1382
+ let update = {
1383
+ id: row.unWriteSell[0].id,
1384
+ f_write_comments: !row.f_write_comments ? '' : row.f_write_comments,
1385
+ f_write_operator: Vue.$login.f.name,
1386
+ f_write_date: Vue.$login.toStandardTimeString()
1387
+ }
1388
+ await Vue.resetpost('rs/logic/offlineWrite', update, {resolveMsg: '写卡成功', rejectMsg: '写卡成功,更新数据失败'})
1389
+ let cardid = row.f_card_id
1390
+ if (row.f_tag) {
1391
+ // 截取用户编号后四位
1392
+ cardid = row.f_tag + row.f_card_id
1393
+ }
1394
+ // 执行写卡操作
1395
+ let cardParams = await getParamGen(row.f_card_id, row.f_alias, row.f_user_id, row.f_userfiles_id)
1396
+ let param = {
1397
+ factory: row.f_alias,
1398
+ kh: cardid,
1399
+ cs: row.unWriteSell[0].f_times,
1400
+ yhh: row.cardInfo.Yhh ? row.cardInfo.Yhh : row.f_meterid,
1401
+ meterid: row.f_meternumber ? row.f_meternumber : 0,
1402
+ meternumber: row.f_meternumber ? row.f_meternumber : 0,
1403
+ kmm: row.f_card_password,
1404
+ ljgql: (row.f_write_totalgas - 0), // 当前累计购气量
1405
+ ljgqje: (row.f_write_totalfee - 0), // 累计购气金额
1406
+ bjql: row.f_police_gas,
1407
+ czsx: row.f_topup_ceil,
1408
+ tzed: row.f_overdr_lines,
1409
+ bkcs: row.f_fillcard_times,
1410
+ dqdm: row.f_area_code,
1411
+ klx: row.f_coding,
1412
+ ql: row.unWriteSell[0].f_pregas,
1413
+ money: row.unWriteSell[0].f_write_money
1414
+ }
1415
+ param = Object.assign({}, Vue.CommonService.writeCardParams(cardParams), param)
1416
+ let cardRes
1417
+ if (result.data.last_oper == null) result.data.last_oper = ''
1418
+ if (row.states === '补卡' || result.data.last_oper === '补卡') {
1419
+ param.kzt = result.data.ispick === '未过表' && result.data.lastsell_oper === '发卡售气' ? '0' : '1'
1420
+ param.cs = row.cardInfo.Times + 1
1421
+ param.bkcs = param.bkcs + 1
1422
+ cardRes = await Vue.resetpost('http://127.0.0.1:8003/WriteNewCard', param, {resolveMsg: null, rejectMsg: '写卡失败'})
1423
+ } else if (row.states === '换表') {
1424
+ param.kzt = '0'
1425
+ param.bkcs = param.bkcs + 1
1426
+ param.cs = 1
1427
+ cardRes = await Vue.resetpost('http://127.0.0.1:8003/WriteNewCard', param, {resolveMsg: null, rejectMsg: '写卡失败'})
1428
+ } else {
1429
+ cardRes = await Vue.resetpost('http://127.0.0.1:8003/WriteGasCard', param, {resolveMsg: null, rejectMsg: '写卡失败'})
1430
+ }
1431
+ if (!cardParams || cardRes.data.Err || cardRes.data.Exception) {
1432
+ let sql = `update t_sellinggas set
1433
+ f_write_card = '未写卡'
1434
+ where id = '${row.unWriteSell[0].id}'`
1435
+ let data = {
1436
+ sql: sql
1437
+ }
1438
+ await Vue.resetpost('rs/logic/runSQL', data)
1439
+ throw new Error(`卡服务错误:${cardRes.data.Err}${cardRes.data.Exception},请联系开发人员处理!!`)
1440
+ }
1441
+ } else {
1442
+ Vue.showAlert('请检查卡是否插好!!', 'danger', 3000)
1443
+ }
1444
+ } catch (error) {
1445
+ // 考虑到这里报错可能是因为 写卡请求超时报的错,但是请求已经发到卡服务,可能已经写上卡,所以先不做处理
1446
+ // let sql = `update t_sellinggas set
1447
+ // f_write_card = '未写卡',
1448
+ // where id = '${row.unWriteSell[0].id}'`
1449
+ // let data = {
1450
+ // sql: sql
1451
+ // }
1452
+ // await this.$resetpost('rs/logic/runSQL', data)
1453
+ throw error
1454
+ }
1455
+ }
1456
+
1457
+ let DigtialSellGasGen = async function (model, row) {
1458
+ try {
1459
+ let result = await Vue.resetpost('rs/logic/sale_digtialCharge_logic', {data: model}, {resolveMsg: '收费成功', rejectMsg: '卡表收费存库失败'})
1460
+ return result.data.id
1461
+ } catch (error) {
1462
+ if (error.data) {
1463
+ throw new Error(error.data)
1464
+ } else {
1465
+ throw error
1466
+ }
1467
+ }
1468
+ }
1469
+ let noCardSellGasGen = async function (model, row) {
1470
+ try {
1471
+ let result = await Vue.resetpost('rs/logic/sale_cardCharge_logic', {data: model}, {resolveMsg: '收费成功', rejectMsg: '卡表收费存库失败'})
1472
+ return result.data.id
1473
+ } catch (error) {
1474
+ if (error.data) {
1475
+ throw new Error(error.data)
1476
+ } else {
1477
+ throw error
1478
+ }
1479
+ }
1480
+ }
1481
+
1482
+ // 补气卡表收费
1483
+ let sellgasRemanentGen = async function (model, row) {
1484
+ let result = null
1485
+ try {
1486
+ let cardState = await hasCardGen()
1487
+ if (JSON.parse(cardState.data).state === 1) {
1488
+ // 将卡上次数写入数据库
1489
+ model.f_times = row.cardInfo.Times + 1
1490
+ // 将回写表号或者用户号
1491
+ model.f_meterid = row.cardInfo.Yhh ? row.cardInfo.Yhh : row.f_meterid
1492
+
1493
+ let cardid = row.f_card_id
1494
+ if (row.f_tag) {
1495
+ // 截取用户编号后四位
1496
+ cardid = model.f_card_id = row.f_tag + row.f_card_id
1497
+ }
1498
+ result = await Vue.resetpost('rs/logic/sellgasRemanentGas', {data: model}, {resolveMsg: null, rejectMsg: '卡表收费存库失败'})
1499
+ // 获取气价和售气情况参数
1500
+ let cardParams = await getParamGen(cardid, row.f_alias, row.f_user_id, row.f_userfiles_id)
1501
+ console.log('写卡次数和获取的写卡参数...', row.cardInfo.Times, cardParams)
1502
+ // 写卡
1503
+ let params = {
1504
+ factory: row.f_alias, // 气表厂家
1505
+ kh: cardid, // 卡号
1506
+ yhh: row.f_meterid ? row.f_meterid : 0, // 用户号,档案中自己输
1507
+ kmm: row.f_card_password, // 卡密码,写卡后返回新密码, 不论补卡还是先开户都没有密码
1508
+ bjql: row.f_police_gas, // 报警气量,t_gasbrand表中
1509
+ czsx: row.f_topup_ceil, // 充值上线,t_gasbrand表中
1510
+ tzed: row.f_overdr_lines, // 透支额度,t_gasbrand表中
1511
+ ljgql: (row.f_write_totalgas - 0) + (model.f_pregas - 0), // 当前累计购气量
1512
+ ljgqje: (row.f_write_totalfee - 0) + (model.f_write_money - 0), // 累计购气金额
1513
+ bkcs: row.f_fillcard_times, // 补卡次数,从补卡表里通过表编号获得
1514
+ ql: model.f_pregas, // 预购气量
1515
+ cs: row.cardInfo.Times + 1, // 求购气次数,先开户为1
1516
+ money: model.f_write_money, // 购气金额
1517
+ meterid: row.f_meternumber ? row.f_meternumber : 0, // 表号
1518
+ dqdm: row.f_area_code, // 精益工业地区代码
1519
+ klx: row.f_coding
1520
+ }
1521
+ params = Object.assign({}, Vue.CommonService.writeCardParams(cardParams), params)
1522
+ console.log('购气最后操作。。', result)
1523
+ let cardRes = await Vue.resetpost('http://127.0.0.1:8003/WriteGasCard', params, {resolveMsg: null, rejectMsg: '卡表收费失败'})
1524
+ console.log('卡表收费返回写卡参数值', cardRes)
1525
+ // 卡服务写卡异常,业务逻辑回滚
1526
+ if (!cardParams || ((model.f_pregas > model.f_remanent_gas) && !result) || cardRes.data.Err || cardRes.data.Exception) {
1527
+ let data = {
1528
+ id: result.data.id,
1529
+ userinfo: {
1530
+ f_userinfo_id: row.f_userinfo_id,
1531
+ version: row.userinfo_version + 1,
1532
+ f_balance: row.f_balance,
1533
+ userfiles: {
1534
+ f_user_id: model.f_user_id,
1535
+ f_userfiles_id: model.f_userfiles_id,
1536
+ f_card_id: row.f_card_id,
1537
+ f_total_gas: row.f_total_gas,
1538
+ f_write_totalgas: row.f_write_totalgas,
1539
+ f_write_totalfee: row.f_write_totalfee,
1540
+ f_total_fee: row.f_total_fee,
1541
+ f_times: row.cardInfo.Times,
1542
+ version: row.version + 1
1543
+ }
1544
+ }
1545
+ }
1546
+ if (row.f_tag) {
1547
+ data.userinfo.userfiles.f_tag = row.f_tag
1548
+ }
1549
+ await Vue.resetpost('rs/logic/sellgasremanentRollback', {data: data}, {resolveMsg: null, rejectMsg: '卡表收费回滚出错!!'})
1550
+ throw new Error(`卡服务错误:${cardRes.data.Err}${cardRes.data.Exception},请联系开发人员处理!!`)
1551
+ } else {
1552
+ // 更新卡密码
1553
+ await Vue.CommonService.updatePassword(row, cardRes)
1554
+ Vue.showAlert('换表补气成功', 'success', 2000)
1555
+ return result
1556
+ }
1557
+ } else {
1558
+ throw new Error(`请检查卡是否插好!!`)
1559
+ }
1560
+ } catch (error) {
1561
+ if (result) {
1562
+ let data = {
1563
+ sellid: result.data.sellid,
1564
+ fillgasid: result.data.fillgasid,
1565
+ userinfo: {
1566
+ f_userinfo_id: row.f_userinfo_id,
1567
+ version: row.userinfo_version + 1,
1568
+ f_balance: row.f_balance,
1569
+ userfiles: {
1570
+ f_user_id: model.f_user_id,
1571
+ f_total_gas: row.f_total_gas,
1572
+ f_write_totalgas: row.f_write_totalgas,
1573
+ f_write_totalfee: row.f_write_totalfee,
1574
+ f_total_fee: row.f_total_fee,
1575
+ f_card_id: row.f_card_id,
1576
+ f_times: row.cardInfo.Times,
1577
+ version: row.version + 1
1578
+ }
1579
+ }
1580
+ }
1581
+ if (row.f_tag) {
1582
+ data.userinfo.userfiles.f_tag = row.f_tag
1583
+ }
1584
+ await Vue.resetpost('rs/logic/sellgasremanentRollback', {data: data}, {resolveMsg: '卡表收费失败', rejectMsg: '卡表收费失败'})
1585
+ }
1586
+ throw error
1587
+ }
1588
+ }
1589
+ // 余量补差
1590
+ let marginGen = async function (model, row) {
1591
+ let result = null
1592
+ let cardparam
1593
+ let cardpost
1594
+ try {
1595
+ let cardState = await hasCardGen()
1596
+ if (JSON.parse(cardState.data).state === 1) {
1597
+ // 将卡上次数写入数据库
1598
+ if (!(row.f_hascard == null) && !(row.f_share_times == null) && row.f_hascard === '是' && row.f_share_times === '是') {
1599
+ model.f_times = row.f_times + 1
1600
+ } else {
1601
+ model.f_times = row.cardInfo.Times + 1
1602
+ }
1603
+ // 将回写表号或者用户号
1604
+ model.f_meterid = row.cardInfo.Yhh ? row.cardInfo.Yhh : row.f_meterid
1605
+
1606
+ let cardid = row.f_card_id
1607
+ if (row.f_tag) {
1608
+ // 截取用户编号后四位
1609
+ cardid = model.f_card_id = row.f_tag + row.f_card_id
1610
+ }
1611
+ // 存库
1612
+ result = await Vue.resetpost('rs/logic/marginCharge', {data: model}, {resolveMsg: null, rejectMsg: '卡表收费存库失败'})
1613
+ // 获取气价和售气情况参数
1614
+ let cardParams = await getParamGen(cardid, row.f_alias, row.f_user_id, row.f_userfiles_id)
1615
+ console.log('写卡次数和获取的写卡参数...', row.cardInfo.Times, cardParams)
1616
+ // 写卡
1617
+ let params = {
1618
+ factory: row.f_alias, // 气表厂家
1619
+ kh: cardid, // 卡号
1620
+ yhh: row.f_meterid ? row.f_meterid : 0, // 用户号,档案中自己输
1621
+ kmm: row.f_card_password, // 卡密码,写卡后返回新密码, 不论补卡还是先开户都没有密码
1622
+ bjql: row.f_police_gas,
1623
+ ljgql: (row.f_write_totalgas - 0) + (model.f_pregas - 0), // 当前累计购气量
1624
+ ljgqje: (row.f_write_totalfee - 0) + (model.f_write_money - 0), // 累计购气金额
1625
+ czsx: row.f_topup_ceil, // 充值上线,t_gasbrand表中
1626
+ tzed: row.f_overdr_lines, // 透支额度,t_gasbrand表中
1627
+ bkcs: row.f_fillcard_times, // 补卡次数,从补卡表里通过表编号获得
1628
+ ql: model.f_pregas, // 预购气量
1629
+ cs: row.cardInfo.Times + 1, // 求购气次数,先开户为1
1630
+ money: model.f_write_money, // 购气金额
1631
+ dqdm: row.f_area_code, // 精益工业地区代码
1632
+ klx: row.f_coding,
1633
+ meterid: row.f_meternumber ? row.f_meternumber : 0 // 表号
1634
+ }
1635
+ params = Object.assign({}, Vue.CommonService.writeCardParams(cardParams), params)
1636
+ // if (row.f_alias === 'HaiLiJE' || row.f_alias === 'HaiLiQL' || row.f_alias === 'CangNanTY') {
1637
+ // params.klx = yield co(getmodelbrandGen(row))
1638
+ // params.klx = params.klx.data[0].f_coding
1639
+ // }
1640
+
1641
+ let params2 = {
1642
+ factory: row.f_alias,
1643
+ kh: cardid, // 卡号
1644
+ kmm: row.f_card_password, // 卡密码,写卡后返回新密码, 不论补卡还是先开户都没有密码
1645
+ bjql: row.f_police_gas, // 报警气量,t_gasbrand表中
1646
+ czsx: row.f_topup_ceil, // 充值上线,t_gasbrand表中
1647
+ tzed: row.f_overdr_lines, // 透支额度,t_gasbrand表中
1648
+ ljgql: (row.f_write_totalgas - 0) + (model.f_pregas - 0), // 当前累计购气量
1649
+ ljgqje: (row.f_write_totalfee - 0) + (model.f_write_money - 0), // 累计购气金额
1650
+ kzt: '1', // 卡状态,0开户卡,1用户卡(0新开户,1补卡)
1651
+ bkcs: row.f_fillcard_times, // 补卡次数,从补卡表里通过表编号获得
1652
+ ql: model.f_pregas, // 预购气量
1653
+ cs: row.cardInfo.Times + 1, // 求购气次数,先开户为1
1654
+ sxrq: model.f_startdate, // 生效日期,价格管理中取
1655
+ meterid: row.f_meternumber ? row.f_meternumber : 0, // 表号
1656
+ // meternumber: row.f_meternumber ? row.f_meternumber : 0, // 海力金额表号
1657
+ dqdm: row.f_area_code, // 精益工业地区代码
1658
+ money: model.f_write_money, // 购气金额
1659
+ klx: row.f_coding
1660
+ }
1661
+
1662
+ params2 = Object.assign({}, Vue.CommonService.writeCardParams(cardParams), params2)
1663
+ // if (row.f_alias === 'HaiLiJE' || row.f_alias === 'HaiLiQL' || row.f_alias === 'CangNanTY') {
1664
+ // params2.klx = yield co(getmodelbrandGen(row))
1665
+ // params2.klx = params2.klx.data[0].f_coding
1666
+ // }
1667
+
1668
+ let params3 = {
1669
+ factory: row.f_alias,
1670
+ kh: cardid, // 卡号
1671
+ kmm: row.f_card_password, // 卡密码,写卡后返回新密码, 不论补卡还是先开户都没有密码
1672
+ bjql: row.f_police_gas, // 报警气量,t_gasbrand表中
1673
+ czsx: row.f_topup_ceil, // 充值上线,t_gasbrand表中
1674
+ tzed: row.f_overdr_lines, // 透支额度,t_gasbrand表中
1675
+ ljgql: (row.f_write_totalgas - 0) + (model.f_pregas - 0), // 当前累计购气量
1676
+ ljgqje: (row.f_write_totalfee - 0) + (model.f_write_money - 0), // 累计购气金额
1677
+ kzt: '0', // 卡状态,0开户卡,1用户卡(0新开户,1补卡)
1678
+ bkcs: row.f_fillcard_times, // 补卡次数,从补卡表里通过表编号获得
1679
+ ql: model.f_pregas, // 预购气量
1680
+ cs: 1, // 求购气次数,先开户为1
1681
+ sxrq: model.f_startdate, // 生效日期,价格管理中取
1682
+ meterid: row.f_meternumber ? row.f_meternumber : 0, // 表号
1683
+ // meternumber: row.f_meternumber ? row.f_meternumber : 0, // 海力金额表号
1684
+ dqdm: row.f_area_code, // 精益工业地区代码
1685
+ money: model.f_write_money, // 购气金额
1686
+ klx: row.f_coding
1687
+ }
1688
+ params3 = Object.assign({}, Vue.CommonService.writeCardParams(cardParams), params3)
1689
+ // if (row.f_alias === 'HaiLiJE' || row.f_alias === 'HaiLiQL' || row.f_alias === 'CangNanTY') {
1690
+ // params3.klx = yield co(getmodelbrandGen(row))
1691
+ // params3.klx = params3.klx.data[0].f_coding
1692
+ // }
1693
+ console.log('购气最后操作。。', result)
1694
+ if (!(row.f_hascard == null) && !(row.f_share_times == null) && row.f_meter_type === '物联网表' && row.f_hascard === '是' && row.f_share_times === '是') {
1695
+ params.cs = row.f_times + 1
1696
+ params2.cs = row.f_times + 1
1697
+ }
1698
+ let cardRes
1699
+ if (result.data.last_oper === '补卡') {
1700
+ // 此次验证开户之后未过表补卡验证问题
1701
+ params2.kzt = result.data.ispick === '未过表' && result.data.lastsell_oper === '发卡售气' ? '0' : '1'
1702
+ cardparam = JSON.stringify(params2)
1703
+ cardpost = 'WriteNewCard'
1704
+ cardRes = await Vue.resetpost('http://127.0.0.1:8003/WriteNewCard', params2, {resolveMsg: null, rejectMsg: '卡表收费失败'})
1705
+ } else if (result.data.last_oper === '换表') {
1706
+ console.log('我走的是写新卡换表')
1707
+ cardparam = JSON.stringify(params3)
1708
+ cardpost = 'WriteNewCard'
1709
+ cardRes = await Vue.resetpost('http://127.0.0.1:8003/WriteNewCard', params3, {resolveMsg: null, rejectMsg: '卡表收费失败'})
1710
+ } else if (result.data.last_oper === '换表补气') {
1711
+ // 累购金额需要将上次购气金额加上
1712
+ console.log('我走的是正常的收费', params)
1713
+ cardparam = JSON.stringify(params)
1714
+ cardpost = 'WriteGasCard'
1715
+ cardRes = await Vue.resetpost('http://127.0.0.1:8003/WriteGasCard', params, {resolveMsg: null, rejectMsg: '卡表收费失败'})
1716
+ } else {
1717
+ console.log('我走的是正常的收费', params)
1718
+ cardparam = JSON.stringify(params)
1719
+ cardpost = 'WriteGasCard'
1720
+ cardRes = await Vue.resetpost('http://127.0.0.1:8003/WriteGasCard', params, {resolveMsg: null, rejectMsg: '卡表收费失败'})
1721
+ }
1722
+ console.log('卡表收费返回写卡参数值', cardRes)
1723
+ // 卡服务写卡异常,业务逻辑回滚
1724
+ if (!cardParams || !result || cardRes.data.Err || cardRes.data.Exception) {
1725
+ throw `卡服务错误:${cardRes.data.Err}${cardRes.data.Exception},请联系开发人员处理!!`
1726
+ } else {
1727
+ // 调用读卡进行校验
1728
+ let readCardInfo = await Vue.resetpost('http://127.0.0.1:8003/ReadCard', {kmm: row.f_card_password}, {resolveMsg: null, rejectMsg: '读卡失败!!'})
1729
+ if (readCardInfo.data && Vue.$login.r.includes('读卡2')) {
1730
+ console.log('读卡验证', readCardInfo.data, row)
1731
+ if (row.f_collection_type === '按金额') {
1732
+ if (readCardInfo.data.Money !== model.f_preamount || readCardInfo.data.Factory !== row.f_alias || readCardInfo.data.CardID !== row.f_card_id) {
1733
+ Vue.showAlert('读卡参数和缴费参数不一致,请核实!!', 'warning', 2000)
1734
+ return result.data.id
1735
+ }
1736
+ } else {
1737
+ if (readCardInfo.data.Gas !== Number((model.f_pregas - 0).toFixed(2)) || readCardInfo.data.Factory !== row.f_alias || readCardInfo.data.CardID !== row.f_card_id) {
1738
+ Vue.showAlert('读卡参数和缴费参数不一致,请核实!!', 'warning', 2000)
1739
+ return result.data.id
1740
+ }
1741
+ }
1742
+ }
1743
+ // 更新卡密码
1744
+ await Vue.CommonService.updatePassword(row, cardRes)
1745
+ Vue.showAlert('售气成功', 'success', 2000)
1746
+ return result.data.id
1747
+ }
1748
+ } else {
1749
+ throw new Error(`请检查卡是否插好!!`)
1750
+ }
1751
+ } catch (error) {
1752
+ if (result) {
1753
+ let data = {
1754
+ cardparam: cardparam,
1755
+ cardpost: cardpost,
1756
+ id: result.data.id,
1757
+ userinfo: {
1758
+ f_userinfo_id: row.f_userinfo_id,
1759
+ version: row.userinfo_version + 1,
1760
+ f_balance: row.f_balance,
1761
+ userfiles: {
1762
+ f_user_id: model.f_user_id,
1763
+ f_userfiles_id: row.f_userfiles_id,
1764
+ f_total_gas: row.f_total_gas,
1765
+ f_write_totalgas: row.f_write_totalgas,
1766
+ f_write_totalfee: row.f_write_totalfee,
1767
+ f_total_fee: row.f_total_fee,
1768
+ f_card_id: row.f_card_id,
1769
+ f_times: row.cardInfo.Times,
1770
+ version: row.version + 1
1771
+ }
1772
+ }
1773
+ }
1774
+ if (row.f_tag) {
1775
+ data.userinfo.userfiles.f_tag = row.f_tag
1776
+ }
1777
+ if (!(row.f_hascard == null) && !(row.f_share_times == null) && row.f_meter_type === '物联网表' && row.f_hascard === '是' && row.f_share_times === '是') {
1778
+ data.userinfo.userfiles.f_times = row.f_times
1779
+ }
1780
+ await Vue.resetpost('rs/logic/cardChargeRollback', {data: data}, {resolveMsg: '卡表收费失败', rejectMsg: '卡表收费失败'})
1781
+ }
1782
+ throw error
1783
+ }
1784
+ }
1785
+ // 卡表收费
1786
+ let sellgasGen = async function (model, row) {
1787
+ let result = null
1788
+ let cardparam
1789
+ let cardpost
1790
+ try {
1791
+ let cardState = await hasCardGen()
1792
+ if (JSON.parse(cardState.data).state === 1) {
1793
+ // 将卡上次数写入数据库
1794
+ if (!(row.f_hascard == null) && !(row.f_share_times == null) && row.f_hascard === '是' && row.f_share_times === '是') {
1795
+ model.f_times = row.f_times + 1
1796
+ } else {
1797
+ model.f_times = row.cardInfo.Times + 1
1798
+ }
1799
+ // 将回写表号或者用户号
1800
+ model.f_meterid = row.cardInfo.Yhh ? row.cardInfo.Yhh : row.f_meterid
1801
+
1802
+ let cardid = row.f_card_id
1803
+ if (row.f_tag) {
1804
+ // 截取用户编号后四位
1805
+ cardid = model.f_card_id = row.f_tag + row.f_card_id
1806
+ }
1807
+ // 存库
1808
+ result = await Vue.resetpost('rs/logic/sale_cardCharge_logic', {data: model}, {resolveMsg: null, rejectMsg: '卡表收费存库失败'})
1809
+ // 获取气价和售气情况参数
1810
+ let cardParams = await getParamGen(cardid, row.f_alias, row.f_user_id, row.f_userfiles_id)
1811
+ console.log('写卡次数和获取的写卡参数...', row.cardInfo.Times, cardParams)
1812
+ // 写卡
1813
+ let params = {
1814
+ factory: row.f_alias, // 气表厂家
1815
+ kh: cardid, // 卡号
1816
+ yhh: row.f_meterid ? row.f_meterid : 0, // 用户号,档案中自己输
1817
+ kmm: row.f_card_password, // 卡密码,写卡后返回新密码, 不论补卡还是先开户都没有密码
1818
+ bjql: row.f_police_gas,
1819
+ ljgql: (row.f_write_totalgas - 0) + (model.f_pregas - 0), // 当前累计购气量
1820
+ ljgqje: (row.f_write_totalfee - 0) + (model.f_write_money - 0), // 累计购气金额
1821
+ czsx: row.f_topup_ceil, // 充值上线,t_gasbrand表中
1822
+ tzed: row.f_overdr_lines, // 透支额度,t_gasbrand表中
1823
+ bkcs: row.f_fillcard_times, // 补卡次数,从补卡表里通过表编号获得
1824
+ ql: model.f_pregas, // 预购气量
1825
+ cs: row.cardInfo.Times + 1, // 求购气次数,先开户为1
1826
+ money: model.f_write_money, // 购气金额
1827
+ dqdm: row.f_area_code, // 精益工业地区代码
1828
+ klx: row.f_coding,
1829
+ meterid: row.f_meternumber ? row.f_meternumber : 0 // 表号
1830
+ }
1831
+ params = Object.assign({}, Vue.CommonService.writeCardParams(cardParams), params)
1832
+ // if (row.f_alias === 'HaiLiJE' || row.f_alias === 'HaiLiQL' || row.f_alias === 'CangNanTY') {
1833
+ // params.klx = yield co(getmodelbrandGen(row))
1834
+ // params.klx = params.klx.data[0].f_coding
1835
+ // }
1836
+
1837
+ let params2 = {
1838
+ factory: row.f_alias,
1839
+ kh: cardid, // 卡号
1840
+ kmm: row.f_card_password, // 卡密码,写卡后返回新密码, 不论补卡还是先开户都没有密码
1841
+ bjql: row.f_police_gas, // 报警气量,t_gasbrand表中
1842
+ czsx: row.f_topup_ceil, // 充值上线,t_gasbrand表中
1843
+ tzed: row.f_overdr_lines, // 透支额度,t_gasbrand表中
1844
+ ljgql: (row.f_write_totalgas - 0) + (model.f_pregas - 0), // 当前累计购气量
1845
+ ljgqje: (row.f_write_totalfee - 0) + (model.f_write_money - 0), // 累计购气金额
1846
+ kzt: '1', // 卡状态,0开户卡,1用户卡(0新开户,1补卡)
1847
+ bkcs: row.f_fillcard_times, // 补卡次数,从补卡表里通过表编号获得
1848
+ ql: model.f_pregas, // 预购气量
1849
+ cs: row.cardInfo.Times + 1, // 求购气次数,先开户为1
1850
+ sxrq: model.f_startdate, // 生效日期,价格管理中取
1851
+ meterid: row.f_meternumber ? row.f_meternumber : 0, // 表号
1852
+ // meternumber: row.f_meternumber ? row.f_meternumber : 0, // 海力金额表号
1853
+ dqdm: row.f_area_code, // 精益工业地区代码
1854
+ money: model.f_write_money, // 购气金额
1855
+ klx: row.f_coding
1856
+ }
1857
+
1858
+ params2 = Object.assign({}, Vue.CommonService.writeCardParams(cardParams), params2)
1859
+ // if (row.f_alias === 'HaiLiJE' || row.f_alias === 'HaiLiQL' || row.f_alias === 'CangNanTY') {
1860
+ // params2.klx = yield co(getmodelbrandGen(row))
1861
+ // params2.klx = params2.klx.data[0].f_coding
1862
+ // }
1863
+
1864
+ let params3 = {
1865
+ factory: row.f_alias,
1866
+ kh: cardid, // 卡号
1867
+ kmm: row.f_card_password, // 卡密码,写卡后返回新密码, 不论补卡还是先开户都没有密码
1868
+ bjql: row.f_police_gas, // 报警气量,t_gasbrand表中
1869
+ czsx: row.f_topup_ceil, // 充值上线,t_gasbrand表中
1870
+ tzed: row.f_overdr_lines, // 透支额度,t_gasbrand表中
1871
+ ljgql: (row.f_write_totalgas - 0) + (model.f_pregas - 0), // 当前累计购气量
1872
+ ljgqje: (row.f_write_totalfee - 0) + (model.f_write_money - 0), // 累计购气金额
1873
+ kzt: '0', // 卡状态,0开户卡,1用户卡(0新开户,1补卡)
1874
+ bkcs: row.f_fillcard_times, // 补卡次数,从补卡表里通过表编号获得
1875
+ ql: model.f_pregas, // 预购气量
1876
+ cs: 1, // 求购气次数,先开户为1
1877
+ sxrq: model.f_startdate, // 生效日期,价格管理中取
1878
+ meterid: row.f_meternumber ? row.f_meternumber : 0, // 表号
1879
+ // meternumber: row.f_meternumber ? row.f_meternumber : 0, // 海力金额表号
1880
+ dqdm: row.f_area_code, // 精益工业地区代码
1881
+ money: model.f_write_money, // 购气金额
1882
+ klx: row.f_coding
1883
+ }
1884
+ params3 = Object.assign({}, Vue.CommonService.writeCardParams(cardParams), params3)
1885
+ // if (row.f_alias === 'HaiLiJE' || row.f_alias === 'HaiLiQL' || row.f_alias === 'CangNanTY') {
1886
+ // params3.klx = yield co(getmodelbrandGen(row))
1887
+ // params3.klx = params3.klx.data[0].f_coding
1888
+ // }
1889
+ console.log('购气最后操作。。', result)
1890
+ if (!(row.f_hascard == null) && !(row.f_share_times == null) && row.f_meter_type === '物联网表' && row.f_hascard === '是' && row.f_share_times === '是') {
1891
+ params.cs = row.f_times + 1
1892
+ params2.cs = row.f_times + 1
1893
+ }
1894
+ let cardRes
1895
+ if (result.data.last_oper === '补卡') {
1896
+ // 此次验证开户之后未过表补卡验证问题
1897
+ params2.kzt = result.data.ispick === '未过表' && result.data.lastsell_oper === '发卡售气' ? '0' : '1'
1898
+ cardparam = JSON.stringify(params2)
1899
+ cardpost = 'WriteNewCard'
1900
+ cardRes = await Vue.resetpost('http://127.0.0.1:8003/WriteNewCard', params2, {resolveMsg: null, rejectMsg: '卡表收费失败'})
1901
+ } else if (result.data.last_oper === '换表') {
1902
+ console.log('我走的是写新卡换表')
1903
+ cardparam = JSON.stringify(params3)
1904
+ cardpost = 'WriteNewCard'
1905
+ cardRes = await Vue.resetpost('http://127.0.0.1:8003/WriteNewCard', params3, {resolveMsg: null, rejectMsg: '卡表收费失败'})
1906
+ } else if (result.data.last_oper === '换表补气') {
1907
+ // 累购金额需要将上次购气金额加上
1908
+ console.log('我走的是正常的收费', params)
1909
+ cardparam = JSON.stringify(params)
1910
+ cardpost = 'WriteGasCard'
1911
+ cardRes = await Vue.resetpost('http://127.0.0.1:8003/WriteGasCard', params, {resolveMsg: null, rejectMsg: '卡表收费失败'})
1912
+ } else {
1913
+ console.log('我走的是正常的收费', params)
1914
+ cardparam = JSON.stringify(params)
1915
+ cardpost = 'WriteGasCard'
1916
+ cardRes = await Vue.resetpost('http://127.0.0.1:8003/WriteGasCard', params, {resolveMsg: null, rejectMsg: '卡表收费失败'})
1917
+ }
1918
+ console.log('卡表收费返回写卡参数值', cardRes)
1919
+ // 卡服务写卡异常,业务逻辑回滚
1920
+ if (!cardParams || !result || cardRes.data.Err || cardRes.data.Exception) {
1921
+ throw `卡服务错误:${cardRes.data.Err}${cardRes.data.Exception},请联系开发人员处理!!`
1922
+ } else {
1923
+ // 调用读卡进行校验
1924
+ let readCardInfo = await Vue.resetpost('http://127.0.0.1:8003/ReadCard', {kmm: row.f_card_password}, {resolveMsg: null, rejectMsg: '读卡失败!!'})
1925
+ if (readCardInfo.data && Vue.$login.r.includes('读卡2')) {
1926
+ console.log('读卡验证', readCardInfo.data, row)
1927
+ if (row.f_collection_type === '按金额') {
1928
+ if (readCardInfo.data.Money !== model.f_preamount || readCardInfo.data.Factory !== row.f_alias || readCardInfo.data.CardID !== row.f_card_id) {
1929
+ Vue.showAlert('读卡参数和缴费参数不一致,请核实!!', 'warning', 2000)
1930
+ return result.data.id
1931
+ }
1932
+ } else {
1933
+ if (readCardInfo.data.Gas !== Number((model.f_pregas - 0).toFixed(2)) || readCardInfo.data.Factory !== row.f_alias || readCardInfo.data.CardID !== row.f_card_id) {
1934
+ Vue.showAlert('读卡参数和缴费参数不一致,请核实!!', 'warning', 2000)
1935
+ return result.data.id
1936
+ }
1937
+ }
1938
+ }
1939
+ // 更新卡密码
1940
+ await Vue.CommonService.updatePassword(row, cardRes)
1941
+ Vue.showAlert('售气成功', 'success', 2000)
1942
+ return result.data.id
1943
+ }
1944
+ } else {
1945
+ throw new Error(`请检查卡是否插好!!`)
1946
+ }
1947
+ } catch (error) {
1948
+ if (result) {
1949
+ let data = {
1950
+ cardparam: cardparam,
1951
+ cardpost: cardpost,
1952
+ id: result.data.id,
1953
+ userinfo: {
1954
+ f_userinfo_id: row.f_userinfo_id,
1955
+ version: row.userinfo_version + 1,
1956
+ f_balance: row.f_balance,
1957
+ userfiles: {
1958
+ f_user_id: model.f_user_id,
1959
+ f_userfiles_id: row.f_userfiles_id,
1960
+ f_total_gas: row.f_total_gas,
1961
+ f_write_totalgas: row.f_write_totalgas,
1962
+ f_write_totalfee: row.f_write_totalfee,
1963
+ f_total_fee: row.f_total_fee,
1964
+ f_card_id: row.f_card_id,
1965
+ f_times: row.cardInfo.Times,
1966
+ version: row.version + 1
1967
+ }
1968
+ }
1969
+ }
1970
+ if (row.f_tag) {
1971
+ data.userinfo.userfiles.f_tag = row.f_tag
1972
+ }
1973
+ if (!(row.f_hascard == null) && !(row.f_share_times == null) && row.f_meter_type === '物联网表' && row.f_hascard === '是' && row.f_share_times === '是') {
1974
+ data.userinfo.userfiles.f_times = row.f_times
1975
+ }
1976
+ await Vue.resetpost('rs/logic/cardChargeRollback', {data: data}, {resolveMsg: '卡表收费失败', rejectMsg: '卡表收费失败'})
1977
+ }
1978
+ throw error
1979
+ }
1980
+ }
1981
+ let reissueCardGenJB = function * (model, row) {
1982
+ if (model.f_cardfees === '') {
1983
+ model.f_cardfees = 0
1984
+ }
1985
+ let data = {
1986
+ f_user_id: row.f_user_id,
1987
+ f_userfiles_id: row.f_userfiles_id,
1988
+ f_user_type: row.f_user_type,
1989
+ f_gasproperties: row.f_gasproperties,
1990
+ f_address: row.f_address,
1991
+ f_meter_brand: row.f_meter_brand,
1992
+ f_type: model.f_type,
1993
+ f_card_id: model.f_card_id,
1994
+ f_ispick_table: model.f_ispick_table,
1995
+ f_cardfees: model.f_cardfees,
1996
+ f_payment: model.f_payment[0],
1997
+ f_bill_style: model.f_print[0],
1998
+ f_comments: model.f_comments,
1999
+ record_userinfo: row.f_userinfo_id,
2000
+ f_userinfo_id: row.f_userinfo_id,
2001
+ f_user_name: row.f_user_name,
2002
+ f_operat_type: '补卡',
2003
+ f_describe: `${Vue.$login.f.name}对客户${row.f_user_name}进行${row.f_type}操作`,
2004
+ f_state: '有效',
2005
+ f_operator: Vue.$login.f.name,
2006
+ f_operatorid: Vue.$login.f.id,
2007
+ f_orgid: Vue.$login.f.orgid,
2008
+ f_orgname: Vue.$login.f.orgs,
2009
+ f_depid: Vue.$login.f.depids,
2010
+ f_depname: Vue.$login.f.deps,
2011
+ f_zoneid: Vue.$login.f.zoneid,
2012
+ f_zones: Vue.$login.f.zones,
2013
+ f_business_tracking_number: model.f_business_tracking_number
2014
+ }
2015
+
2016
+ return Vue.resetpost('rs/logic/sale_fillCard', data, {resolveMsg: null, rejectMsg: '补卡存库失败'})
2017
+ }
2018
+ let reissueCardGen = function * (model, row) {
2019
+ if (model.f_cardfees === '') {
2020
+ model.f_cardfees = 0
2021
+ }
2022
+ if (!model.f_fill_type) {
2023
+ model.f_fill_type = ['']
2024
+ }
2025
+ let data = {
2026
+ f_serial_id: model.f_serial_id,
2027
+ f_user_id: row.f_user_id,
2028
+ f_userfiles_id: row.f_userfiles_id,
2029
+ f_user_type: row.f_user_type,
2030
+ f_gasproperties: row.f_gasproperties,
2031
+ f_address: row.f_address,
2032
+ f_meter_brand: row.f_meter_brand,
2033
+ f_type: model.f_type,
2034
+ f_card_id: model.f_card_id,
2035
+ f_ispick_table: model.f_ispick_table,
2036
+ f_cardfees: model.f_cardfees,
2037
+ f_payment: model.f_payment[0],
2038
+ f_bill_style: model.f_print[0],
2039
+ f_fill_type: model.f_fill_type[0],
2040
+ f_comments: model.f_comments,
2041
+ record_userinfo: row.f_userinfo_id,
2042
+ f_userinfo_id: row.f_userinfo_id,
2043
+ f_user_name: row.f_user_name,
2044
+ f_operat_type: '补卡',
2045
+ f_describe: `${Vue.$login.f.name}对客户${row.f_user_name}进行补卡操作`,
2046
+ f_state: '有效',
2047
+ f_operator: Vue.$login.f.name,
2048
+ f_operatorid: Vue.$login.f.id,
2049
+ f_orgid: Vue.$login.f.orgid,
2050
+ f_orgname: Vue.$login.f.orgs,
2051
+ f_depid: Vue.$login.f.depids,
2052
+ f_depname: Vue.$login.f.deps,
2053
+ f_zoneid: Vue.$login.f.zoneid,
2054
+ f_zones: Vue.$login.f.zones,
2055
+ f_business_tracking_number: model.f_business_tracking_number
2056
+ }
2057
+
2058
+ return Vue.resetpost('rs/logic/sale_fillCard', data, {resolveMsg: null, rejectMsg: '补卡存库失败'})
2059
+ }
2060
+
2061
+ let getParamGen = async function (cardid, alias, f_user_id, f_userfiles_id) {
2062
+ let data = {
2063
+ f_card_id: cardid + '',
2064
+ f_alias: alias,
2065
+ f_user_id: f_user_id,
2066
+ f_userfiles_id: f_userfiles_id
2067
+ }
2068
+ return Vue.resetpost('rs/logic/stairCard', {data: data}, {resolveMsg: null, rejectMsg: '获取写卡参数失败'})
2069
+ }
2070
+
2071
+ let getCardNumberGen = async function (brand_id) {
2072
+ return Vue.resetpost('rs/logic/getCardNumber', {data: {id: brand_id}}, {resolveMsg: null, rejectMsg: '发卡售气获取卡号失败!!'})
2073
+ }
2074
+
2075
+ // 指令写卡
2076
+ // 目前支持 承德海力物联网表
2077
+ let instructWriteCardGen = function * (row) {
2078
+ try {
2079
+ // 判断是否有卡
2080
+ let cardState = yield co(hasCardGen())
2081
+ if (JSON.parse(cardState.data).state === 1) {
2082
+ // 写卡
2083
+ let params = {
2084
+ kh: row.f_card_id,
2085
+ meterid: row.f_meternumber
2086
+ }
2087
+ let cardRes = yield co(Vue.resetpost('http://127.0.0.1:8003/WriteNewCard', params, {
2088
+ resolveMsg: null,
2089
+ rejectMsg: '补卡卡服务错误'
2090
+ }))
2091
+ // 卡服务写卡异常,业务逻辑回滚
2092
+ if (cardRes.data.Err || cardRes.data.Exception) {
2093
+ Vue.$showAlert('指令写卡失败!!', 'danger', 0)
2094
+ } else {
2095
+ return cardRes
2096
+ }
2097
+ } else {
2098
+ Vue.showAlert('请检查卡是否插好!!', 'danger', 3000)
2099
+ return 0
2100
+ }
2101
+ } catch (error) {
2102
+ let msg = ''
2103
+ if (error.status === 612) {
2104
+ msg = '请检查读卡器时候连接,或者卡服务是否启动!!'
2105
+ }
2106
+ Vue.showAlert(msg, 'danger', 0)
2107
+ return 0
2108
+ }
2109
+ }
2110
+ export default CardService