-
Notifications
You must be signed in to change notification settings - Fork 3
/
BMSYSTEM.sql
3655 lines (3599 loc) · 234 KB
/
BMSYSTEM.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
--create database BMSYSTEM
USE [BMSYSTEM]
GO
/****** Object: Table [dbo].[DEPART_INFO] Script Date: 09/24/2015 19:14:12 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[DEPART_INFO](
[DPID] [int] IDENTITY(1,1) NOT NULL,
[DPNAME] [varchar](50) NULL,
[DPPLACE] [varchar](200) NULL,
[ISDELETE] [bit] NULL,
[MARK] [nvarchar](50) NULL,
[DPPCMAC] [varchar](50) NULL,
[ADDDATE] [datetime] NULL,
PRIMARY KEY CLUSTERED
(
[DPID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object: Table [dbo].[BIKE_BORROW_KIND] Script Date: 09/24/2015 19:14:12 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[BIKE_BORROW_KIND](
[BKID] [int] IDENTITY(1,1) NOT NULL,
[BBKNAME] [varchar](50) NULL,
[ISDELETE] [bit] NULL,
[MARK] [nvarchar](50) NULL,
PRIMARY KEY CLUSTERED
(
[BKID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object: Table [dbo].[DEPART_YEAR_FORM] Script Date: 09/24/2015 19:14:12 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[DEPART_YEAR_FORM](
[DYID] [int] IDENTITY(1,1) NOT NULL,
[DPID] [int] NULL,
[VIPCOST] [money] NOT NULL,
[VIPNOCOST] [money] NOT NULL,
[TIME] [datetime] NOT NULL,
[ISDELETE] [bit] NULL,
[MARK] [nvarchar](50) NULL,
[NewVipIncome] [money] NOT NULL,
[VipCharge] [money] NOT NULL,
[VipNoCharge] [money] NOT NULL,
[VipBalance] [money] NOT NULL,
[VipNoBalance] [money] NOT NULL,
[Total] [money] NOT NULL,
PRIMARY KEY CLUSTERED
(
[DYID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[DEPART_MONTH_FORM] Script Date: 09/24/2015 19:14:12 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[DEPART_MONTH_FORM](
[DMID] [int] IDENTITY(1,1) NOT NULL,
[DPID] [int] NOT NULL,
[VIPCOST] [money] NOT NULL,
[VIPNOCOST] [money] NOT NULL,
[TIME] [datetime] NULL,
[ISDELETE] [bit] NULL,
[MARK] [nvarchar](50) NULL,
[NewVipIncome] [money] NOT NULL,
[VipCharge] [money] NOT NULL,
[VipNoCharge] [money] NOT NULL,
[VipBalance] [money] NOT NULL,
[VipNoBalance] [money] NOT NULL,
[Total] [money] NOT NULL,
CONSTRAINT [PK_DEPART_MONTH_FORM] PRIMARY KEY CLUSTERED
(
[DMID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[EXCEPTION_INFO] Script Date: 09/24/2015 19:14:12 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[EXCEPTION_INFO](
[EXID] [int] IDENTITY(1,1) NOT NULL,
[EXCONTENT] [varchar](max) NULL,
[ECFUNC] [varchar](50) NULL,
[EXTIME] [datetime] NULL,
[ISDELETE] [bit] NULL,
[MARK] [nvarchar](50) NULL,
PRIMARY KEY CLUSTERED
(
[EXID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object: Table [dbo].[COST_RULE_INFO] Script Date: 09/24/2015 19:14:12 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[COST_RULE_INFO](
[CRID] [int] IDENTITY(1,1) NOT NULL,
[CRNAME] [varchar](50) NULL,
[COSTPH] [money] NULL,
[COSTTIME] [int] NULL,
[CRKID] [int] NULL,
[COSTBEGIN] [money] NULL,
[ISDELETE] [bit] NULL,
[MARK] [nvarchar](50) NULL,
[CONTIME] [int] NULL,
[LVID] [int] NULL,
PRIMARY KEY CLUSTERED
(
[CRID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object: Table [dbo].[BIKE_RETURN_INFO] Script Date: 09/24/2015 19:14:12 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[BIKE_RETURN_INFO](
[RBKID] [int] IDENTITY(1,1) NOT NULL,
[BBKID] [int] NULL,
[RBKTIME] [datetime] NULL,
[VIPID] [int] NULL,
[DPID] [int] NULL,
[BUCOST] [money] NOT NULL,
[BUTIME] [datetime] NULL,
[BRNUMBER] [int] NULL,
[ISDELETE] [bit] NULL,
[MARK] [nvarchar](50) NULL,
[ISVIP] [bit] NULL,
[USERID] [int] NULL,
PRIMARY KEY CLUSTERED
(
[RBKID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[LOG_INFO] Script Date: 09/24/2015 19:14:12 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[LOG_INFO](
[LOGID] [int] IDENTITY(1,1) NOT NULL,
[USERID] [int] NULL,
[CONTENT] [varchar](200) NULL,
[LOGTIME] [datetime] NULL,
[ISDELETE] [bit] NULL,
[MARK] [nvarchar](50) NULL,
[DPID] [int] NULL,
PRIMARY KEY CLUSTERED
(
[LOGID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object: Table [dbo].[MONTH_COST_RULE] Script Date: 09/24/2015 19:14:12 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[MONTH_COST_RULE](
[CRID] [int] IDENTITY(1,1) NOT NULL,
[CRNAME] [varchar](50) NOT NULL,
[COSTPH] [money] NULL,
[COSTTIME] [time](7) NULL,
[COSTBEGIN] [money] NULL,
[ISDELETE] [bit] NOT NULL,
[MARK] [nvarchar](50) NOT NULL,
CONSTRAINT [PK_MONTH_COST_RULE] PRIMARY KEY CLUSTERED
(
[CRID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object: StoredProcedure [dbo].[MONTH_COST] Script Date: 09/24/2015 19:14:16 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROC [dbo].[MONTH_COST]
@BBKTIME DATETIME,
@RBKTIME DATETIME,
@COSTTIME INT,--每月扣费时间
@COSTPH INT,--每天扣费金额
@CONTIME INT,--起始金额包含时间是几天
@COSTBEGIN MONEY,--起始扣费金额
@BRNUMBER INT,--还车辆数
@USEMONEY MONEY OUTPUT,
@USETIME DATETIME OUTPUT
AS
BEGIN
DECLARE @TIMESPAN DATETIME
DECLARE @HOURSPAN INT
DECLARE @DAYSPAN INT
DECLARE @HOURUSER INT
SELECT @DAYSPAN =DATEDIFF(DAY,@BBKTIME,@RBKTIME)--后面的时间减去前面的时间只算小时
SET @USETIME='1900-1-1 00:00:00'
SET @HOURUSER=DATEDIFF(HOUR,@BBKTIME,@RBKTIME)
SET @USETIME=DATEADD(DAY,@HOURUSER/24,@USETIME)--1900-1-1 00:00:00时间为起始算出租的天数加到起始时间上
SET @USETIME=DATEADD(HOUR,@HOURUSER%24,@USETIME)--上面的时间为准,算出租的小时数加到时间上
IF(@DAYSPAN<@CONTIME)
SET @USEMONEY=@COSTBEGIN*@BRNUMBER
ELSE
SELECT @BBKTIME= DATEADD(DAY,@COSTBEGIN,@BBKTIME)--将起租日期延后使计算时间除去已经包含的天数
SELECT @DAYSPAN=DATEDIFF(DAY,@BBKTIME,@RBKTIME)--算出天数差
SELECT @BBKTIME=DATEADD(DAY,@DAYSPAN,@BBKTIME)--为了算小时差将时间加到同一天
SELECT @HOURSPAN=DATEDIFF(HOUR,@BBKTIME,@RBKTIME)--算出小时差
IF(@HOURSPAN<@COSTTIME)--看小时差是否小于规定时间
BEGIN
SET @USEMONEY=(@COSTBEGIN+(@COSTPH*@DAYSPAN))*@BRNUMBER--如果小于那么当天不算
END
ELSE
BEGIN
SET @USEMONEY=(@COSTBEGIN+(@COSTPH*(@DAYSPAN+1)))*@BRNUMBER--如果不小于那当天也算
END
SELECT @USEMONEY,@USETIME
END
GO
/****** Object: Table [dbo].[NIGHT_COST_RULE] Script Date: 09/24/2015 19:14:16 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[NIGHT_COST_RULE](
[ID] [int] NOT NULL,
[VIPCOST] [int] NOT NULL,
[BEGINTIME] [int] NOT NULL,
[ENDTIME] [int] NOT NULL,
[ISDELET] [bit] NOT NULL,
[MARK] [varchar](50) NULL
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object: StoredProcedure [dbo].[RULE_KIND_RELATION_UPDATE] Script Date: 09/24/2015 19:14:16 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: 海学权
-- Create date: 2013.12.1
-- Description: 修改租车类型与扣费规则的关系
-- =============================================
CREATE PROCEDURE [dbo].[RULE_KIND_RELATION_UPDATE]
@RKRID INT,
@LVID INT,
@BRKID INT,
@RUID INT
AS
BEGIN
UPDATE RULE_KIND_RELATION SET LVID=@LVID,BRKID=@BRKID,RUID=@RUID WHERE BRKID=@BRKID
END
GO
/****** Object: StoredProcedure [dbo].[RULE_KIND_RELATION_SELECT_BY_ID] Script Date: 09/24/2015 19:14:16 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: 海学权
-- Create date: 2013.12.1
-- Description: 根据ID获取租车类型与扣费规则之间的关系
-- =============================================
CREATE PROCEDURE [dbo].[RULE_KIND_RELATION_SELECT_BY_ID]
@RKRID INT
AS
BEGIN
SELECT RKRID,LVID,BRKID,RUID,ISDELETE FROM RULE_KIND_RELATION WHERE RKRID=@RKRID
END
GO
/****** Object: StoredProcedure [dbo].[RULE_KIND_RELATION_SELECT] Script Date: 09/24/2015 19:14:16 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: 海学权
-- Create date: 2013.12.1
-- Description: 获取所有租车类型与扣费规则之间的关系
-- =============================================
CREATE PROCEDURE [dbo].[RULE_KIND_RELATION_SELECT]
AS
BEGIN
SELECT RKRID,LVID,BRKID,RUID,ISDELETE FROM RULE_KIND_RELATION WHERE ISDELETE!='1'
END
GO
/****** Object: StoredProcedure [dbo].[RULE_KIND_RELATION_INSERT] Script Date: 09/24/2015 19:14:16 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: 海学权
-- Create date: 2013.12.1
-- Description: 添加租车类型与扣费规则关系
-- =============================================
CREATE PROCEDURE [dbo].[RULE_KIND_RELATION_INSERT]
@LVID INT,
@BRKID INT,
@RUID INT
AS
BEGIN
INSERT INTO RULE_KIND_RELATION (LVID,BRKID,RUID) VALUES (@LVID,@BRKID,@RUID)
END
GO
/****** Object: StoredProcedure [dbo].[RULE_KIND_RELATION_DELETE] Script Date: 09/24/2015 19:14:16 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: 海学权
-- Create date: 2013.12.1
-- Description: 删除租车类型与扣费规则之间的关系
-- =============================================
CREATE PROCEDURE [dbo].[RULE_KIND_RELATION_DELETE]
@RKRID INT
AS
BEGIN
UPDATE RULE_KIND_RELATION SET ISDELETE='1' WHERE RKRID=@RKRID
END
GO
/****** Object: Table [dbo].[USER_INFO] Script Date: 09/24/2015 19:14:16 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[USER_INFO](
[USERID] [int] IDENTITY(1,1) NOT NULL,
[USERNAME] [varchar](50) NULL,
[USERPWD] [varchar](50) NULL,
[USERCONTROLPWD] [varchar](50) NULL,
[USERPHONE] [varchar](50) NULL,
[USERCARD] [varchar](200) NULL,
[USERPHOTO] [image] NULL,
[DPID] [int] NULL,
[ISDELETE] [bit] NULL,
[MARK] [nvarchar](50) NULL,
PRIMARY KEY CLUSTERED
(
[USERID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object: Table [dbo].[VIP_BORROW_INFO] Script Date: 09/24/2015 19:14:16 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[VIP_BORROW_INFO](
[BBKID] [int] IDENTITY(1,1) NOT NULL,
[VIPID] [int] NULL,
[BBKTIME] [datetime] NULL,
[DPID] [int] NULL,
[BBKNUM] [int] NULL,
[ISDELETE] [bit] NULL,
[MARK] [varchar](1000) NULL,
[RKRID] [int] NULL,
[ISRETURN] [bit] NULL,
[LEFTNUM] [int] NULL,
[USERID] [int] NULL,
[ISNIGHT] [bit] NULL,
CONSTRAINT [PK__VIP_BORR__7F82637B1A14E395] PRIMARY KEY CLUSTERED
(
[BBKID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object: Table [dbo].[VIP_INFO] Script Date: 09/24/2015 19:14:16 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[VIP_INFO](
[VIPID] [int] IDENTITY(1,1) NOT NULL,
[VIPNUMBER] [varchar](200) NULL,
[VIPNAME] [varchar](50) NULL,
[VIPSEX] [bit] NULL,
[VIPPHOTO] [image] NULL,
[VIPLEVELID] [int] NULL,
[VIPPWD] [varchar](50) NULL,
[VIPPHONE] [varchar](50) NULL,
[VIPCARD] [varchar](200) NULL,
[VIPBIRTHDAY] [date] NULL,
[VIPADDRESS] [varchar](200) NULL,
[ISDELETE] [bit] NULL,
[MARK] [varchar](1000) NULL,
[DPID] [int] NULL,
[ADDDATE] [datetime] NULL,
[USERID] [int] NULL,
CONSTRAINT [PK__VIP_INFO__E98EA37B1DE57479] PRIMARY KEY CLUSTERED
(
[VIPID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object: Table [dbo].[U_INFO] Script Date: 09/24/2015 19:14:16 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[U_INFO](
[UID] [int] IDENTITY(1,1) NOT NULL,
[UINFO] [varchar](50) NULL,
[ISDELETE] [bit] NULL,
[MARK] [nvarchar](50) NULL,
[ADDDATE] [datetime] NULL,
[ISADMIN] [bit] NULL,
[DPID] [int] NULL,
[IDENTIFY] [varchar](50) NULL,
PRIMARY KEY CLUSTERED
(
[UID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object: Table [dbo].[VIP_LEVEL_INFO] Script Date: 09/24/2015 19:14:16 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[VIP_LEVEL_INFO](
[LVID] [int] IDENTITY(1,1) NOT NULL,
[LVNAME] [varchar](50) NULL,
[ISDELETE] [bit] NULL,
[MARK] [nvarchar](50) NULL,
[ISVIP] [bit] NULL,
PRIMARY KEY CLUSTERED
(
[LVID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object: Table [dbo].[VIP_MONEY_INFO] Script Date: 09/24/2015 19:14:16 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[VIP_MONEY_INFO](
[VMID] [int] IDENTITY(1,1) NOT NULL,
[VIPID] [int] NULL,
[VMBALANCE] [money] NOT NULL,
[ISDELETE] [bit] NULL,
[MARK] [nvarchar](50) NULL,
[ISVIP] [bit] NULL,
[INTEGRAL] [varchar](200) NULL,
PRIMARY KEY CLUSTERED
(
[VMID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object: Table [dbo].[VIP_NO_BORROW_INFO] Script Date: 09/24/2015 19:14:16 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[VIP_NO_BORROW_INFO](
[BBKID] [int] IDENTITY(1,1) NOT NULL,
[VIPID] [int] NULL,
[DPID] [int] NULL,
[RKRID] [int] NULL,
[VNNAME] [varchar](50) NULL,
[VNPHONE] [varchar](50) NULL,
[VNCARD] [varchar](200) NULL,
[VNNUMBER] [int] NULL,
[ISDELETE] [bit] NULL,
[MARK] [varchar](1000) NULL,
[BBKTIME] [datetime] NULL,
[ISRETURN] [bit] NULL,
[LEFTNUM] [int] NULL,
[USERID] [int] NULL,
[ISNIGHT] [bit] NULL,
CONSTRAINT [PK__VIP_NO_B__7F82637B29572725] PRIMARY KEY CLUSTERED
(
[BBKID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object: Table [dbo].[VIP_NO_INFO] Script Date: 09/24/2015 19:14:16 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[VIP_NO_INFO](
[VIPID] [int] IDENTITY(1,1) NOT NULL,
[VIPNUMBER] [varchar](200) NULL,
[VIPNAME] [varchar](50) NULL,
[VIPPWD] [varchar](50) NULL,
[VIPPHONE] [varchar](50) NULL,
[VIPCARD] [varchar](200) NULL,
[ISDELETE] [bit] NULL,
[MARK] [varchar](1000) NULL,
[DPID] [int] NULL,
[LVID] [int] NULL,
[ADDDATE] [datetime] NULL,
CONSTRAINT [PK__VIP_NO_I__E98EA37B25869641] PRIMARY KEY CLUSTERED
(
[VIPID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object: Table [dbo].[VIP_YEAR_FORM] Script Date: 09/24/2015 19:14:16 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[VIP_YEAR_FORM](
[VYID] [int] IDENTITY(1,1) NOT NULL,
[VIPID] [int] NULL,
[VYCOST] [money] NOT NULL,
[VYTIMES] [int] NULL,
[TIME] [datetime] NOT NULL,
[ISDELETE] [bit] NULL,
[MARK] [nvarchar](50) NULL,
CONSTRAINT [PK_VIP_YEAR_FORM] PRIMARY KEY CLUSTERED
(
[VYID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[WHOLE_CONFIG] Script Date: 09/24/2015 19:14:16 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[WHOLE_CONFIG](
[ID] [int] IDENTITY(1,1) NOT NULL,
[MEANING] [varchar](200) NULL,
[VALUE] [varchar](200) NULL,
[ISDELETE] [bit] NULL,
[MARK] [varchar](50) NULL,
PRIMARY KEY CLUSTERED
(
[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object: Table [dbo].[YEAR_COST_RULE] Script Date: 09/24/2015 19:14:16 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[YEAR_COST_RULE](
[CRID] [int] IDENTITY(1,1) NOT NULL,
[CRNAME] [varchar](50) NOT NULL,
[COSTPH] [money] NULL,
[COSTTIME] [time](7) NULL,
[COSTBEGIN] [money] NULL,
[ISDELETE] [bit] NOT NULL,
[MARK] [nvarchar](50) NOT NULL,
CONSTRAINT [PK_YEAR_COST_RULE] PRIMARY KEY CLUSTERED
(
[CRID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object: StoredProcedure [dbo].[YEAR_COST] Script Date: 09/24/2015 19:14:16 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROC [dbo].[YEAR_COST]
@BBKTIME DATETIME,
@RBKTIME DATETIME,
@COSTTIME INT,--每小时起扣时间
@COSTPH MONEY,--每次扣费金额
@CONTIME INT,--起始价包含时间小时数
@COSTBEGIN MONEY,--每小时扣费金额
@BRNUMBER INT,--还车辆数
@USEMONEY MONEY OUTPUT,
@USETIME DATETIME OUTPUT
AS
BEGIN
DECLARE @TIMESTAP DATETIME--临时时间
DECLARE @MONTHTENP INT
DECLARE @DAYTEMP INT
DECLARE @DAYUSER INT
SELECT @MONTHTENP =DATEDIFF(MONTH,@BBKTIME,@RBKTIME)--后面的时间减去前面的时间只算YUE
SET @USETIME='1900-1-1 00:00:00'
SET @USETIME=DATEADD(MONTH,@MONTHTENP,@USETIME)
SET @TIMESTAP=DATEADD(MONTH,@MONTHTENP,@BBKTIME)
SET @DAYUSER=DATEDIFF(DAY,@TIMESTAP,@RBKTIME)
IF(@DAYTEMP<0)
BEGIN
SET @TIMESTAP=DATEADD(MONTH,-1,@TIMESTAP)
SET @USETIME=DATEADD(MONTH,-1,@USETIME)
SET @DAYUSER=DATEDIFF(DAY,@TIMESTAP,@RBKTIME)
SET @USETIME=DATEADD(DAY,@DAYUSER,@USETIME)
END
ELSE
BEGIN
SET @DAYUSER=DATEDIFF(DAY,@TIMESTAP,@RBKTIME)
SET @USETIME=DATEADD(DAY,@DAYUSER,@USETIME)
END
IF(@MONTHTENP<@CONTIME)
BEGIN
SET @USEMONEY=@COSTBEGIN*@BRNUMBER
END
ELSE
BEGIN
SELECT @BBKTIME=DATEADD(MONTH,@CONTIME,@BBKTIME)--将起租时间延后起始价包含的时间然后再计算金额
SELECT @MONTHTENP =DATEDIFF(MONTH,@BBKTIME,@RBKTIME)--后面的时间减去前面的时间只算月
SELECT @BBKTIME=DATEADD(MONTH,@MONTHTENP,@BBKTIME)--将租车时间放到还车时间同一个月方便计算天数
SELECT @DAYTEMP=DATEDIFF(DAY,@BBKTIME,@RBKTIME)--计算天数
IF(@DAYTEMP<@COSTTIME)
BEGIN
SET @USEMONEY=(@MONTHTENP*@COSTPH+@COSTBEGIN)*@BRNUMBER--算出花费
END
ELSE
BEGIN
SET @USEMONEY=((@MONTHTENP+1)*@COSTPH+@COSTBEGIN)*@BRNUMBER--算出花费
END
SELECT @USEMONEY,@USETIME
END
END
GO
/****** Object: Table [dbo].[RECHARGE_INFO] Script Date: 09/24/2015 19:14:16 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[RECHARGE_INFO](
[ID] [int] IDENTITY(1,1) NOT NULL,
[VIPID] [int] NULL,
[ISVIP] [bit] NULL,
[CHARGETIME] [datetime] NULL,
[BALANCE] [money] NULL,
[CHARGEMONEY] [money] NULL,
[DEPARTMENTID] [int] NULL,
[USERID] [int] NULL,
[ISDELETE] [bit] NULL,
[MARK] [nvarchar](50) NULL,
CONSTRAINT [PK__RECHARGE__3214EC271FCDBCEB] PRIMARY KEY CLUSTERED
(
[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 1) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: StoredProcedure [dbo].[YEAR_COST_RULE_UPDATE] Script Date: 09/24/2015 19:14:16 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: 海学权
-- Create date: 2013.11.30
-- Description: 修改年租扣费规则
-- =============================================
CREATE PROCEDURE [dbo].[YEAR_COST_RULE_UPDATE]
@CRID int,
@CRNAME varchar(50),
@COSTPH money,
@COSTTIME time,
@COSTBEGIN money
AS
BEGIN
UPDATE YEAR_COST_RULE SET CRNAME=@CRNAME,COSTPH=@COSTPH,COSTTIME=@COSTTIME,COSTBEGIN=@COSTBEGIN WHERE CRID=@CRID
END
GO
/****** Object: StoredProcedure [dbo].[YEAR_COST_RULE_SELECT_BY_CRID] Script Date: 09/24/2015 19:14:16 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: 海学权
-- Create date: 2013.11.30
-- Description: 根据Id获取年租扣费规则
-- =============================================
CREATE PROCEDURE [dbo].[YEAR_COST_RULE_SELECT_BY_CRID]
@CRID INT
AS
BEGIN
SELECT CRID,CRNAME,COSTPH,COSTTIME,COSTBEGIN FROM YEAR_COST_RULE WHERE CRID=@CRID
END
GO
/****** Object: StoredProcedure [dbo].[YEAR_COST_RULE_SELECT] Script Date: 09/24/2015 19:14:16 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: 海学权
-- Create date: 2013.11.30
-- Description: 获取所有年租扣费规则
-- =============================================
CREATE PROCEDURE [dbo].[YEAR_COST_RULE_SELECT]
AS
BEGIN
SELECT CRID,CRNAME,COSTPH,COSTTIME,COSTBEGIN FROM YEAR_COST_RULE WHERE ISDELETE!='1'
END
GO
/****** Object: StoredProcedure [dbo].[YEAR_COST_RULE_INSERT] Script Date: 09/24/2015 19:14:16 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: 海学权
-- Create date: 2013.11.30
-- Description: 添加年租扣费规则
-- =============================================
CREATE PROCEDURE [dbo].[YEAR_COST_RULE_INSERT]
@CRNAME varchar(50),
@COSTPH money,
@COSTTIME time,
@COSTBEGIN money
AS
BEGIN
INSERT INTO YEAR_COST_RULE (CRNAME,COSTPH,COSTTIME,COSTBEGIN) VALUES (@CRNAME,@COSTPH,@COSTTIME,@COSTBEGIN)
END
GO
/****** Object: StoredProcedure [dbo].[YEAR_COST_RULE_DELETE] Script Date: 09/24/2015 19:14:16 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: 海学权
-- Create date: 2013.11.30
-- Description: 删除年租扣费规则
-- =============================================
CREATE PROCEDURE [dbo].[YEAR_COST_RULE_DELETE]
@CRID int
AS
BEGIN
UPDATE YEAR_COST_RULE SET ISDELETE='1' WHERE CRID=@CRID
END
GO
/****** Object: StoredProcedure [dbo].[RECHARGE_ADD] Script Date: 09/24/2015 19:14:16 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE proc [dbo].[RECHARGE_ADD]
@VIPID int,
@ISVIP bit,
@CHARGEMONEY money,
@DEPARTMENTID int,
@USERID int
as
begin
INSERT INTO RECHARGE_INFO (VIPID,ISVIP,CHARGEMONEY,DEPARTMENTID,USERID) VALUES (@VIPID,@ISVIP,@CHARGEMONEY,@DEPARTMENTID,@USERID)
update RECHARGE_INFO SET VIPID=1 where vipid=0
END
GO
/****** Object: StoredProcedure [dbo].[WHOLE_CONFIG_UPDATE] Script Date: 09/24/2015 19:14:16 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROC [dbo].[WHOLE_CONFIG_UPDATE]
@ID INT,
@MEANING VARCHAR(200),
@VALUE VARCHAR(200),
@ISDELETE BIT
AS
BEGIN
UPDATE WHOLE_CONFIG SET MEANING=@MEANING,VALUE=@VALUE,ISDELETE=@ISDELETE WHERE ID=@ID
END
GO
/****** Object: StoredProcedure [dbo].[WHOLE_CONFIG_SELECT] Script Date: 09/24/2015 19:14:16 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROC [dbo].[WHOLE_CONFIG_SELECT]
@ID INT
AS
BEGIN
SELECT ID,MEANING,VALUE,ISDELETE FROM WHOLE_CONFIG WHERE ID=@ID AND ISDELETE!=1
END
GO
/****** Object: StoredProcedure [dbo].[VIPNOTNIGHTBORROW] Script Date: 09/24/2015 19:14:16 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: 郑传哲
-- Create date: 2014-8-23
-- Description: 取消包夜功能
-- =============================================
CREATE PROCEDURE [dbo].[VIPNOTNIGHTBORROW]
@BBID INT,
@ISVIP BIT
AS
BEGIN
--非会员
IF @ISVIP =0
BEGIN
UPDATE VIP_NO_BORROW_INFO SET ISNIGHT=0 WHERE BBKID =@BBID
END
ELSE
BEGIN
UPDATE VIP_BORROW_INFO SET ISNIGHT =0 WHERE BBKID =@BBID
END
END
GO
/****** Object: StoredProcedure [dbo].[VIPNIGHTBORROW] Script Date: 09/24/2015 19:14:16 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: 郑传哲
-- Create date: 2014-08-23
-- Description: vip租车转为包夜租车
-- =============================================
CREATE PROCEDURE [dbo].[VIPNIGHTBORROW]
@BBID INT,
@ISVIP BIT
AS
BEGIN
--非会员
IF @ISVIP =0
BEGIN
UPDATE VIP_NO_BORROW_INFO SET ISNIGHT=1 WHERE BBKID =@BBID
END
ELSE
BEGIN
UPDATE VIP_BORROW_INFO SET ISNIGHT =1 WHERE BBKID =@BBID
END
END
GO
/****** Object: StoredProcedure [dbo].[VIP_YEAR_FORM_SELECT_BY_TIME] Script Date: 09/24/2015 19:14:16 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: 海学权
-- Create date: 2013.11.27
-- Description: 根据时间段选出会员消费
-- =============================================
CREATE PROCEDURE [dbo].[VIP_YEAR_FORM_SELECT_BY_TIME]
@BEGINTIME datetime,
@ENDTIME datetime,
@DPID int
AS
BEGIN
--SELECT VYID,VIPID,VYCOST,VYTIMES,TIME,ISDELETE FROM VIP_YEAR_FORM WHERE TIME<@ENDTIME AND TIME>@BEGINTIME AND ISDELETE!=2
SELECT VYID,V.VIPID,V.VIPNAME,VYCOST,VYTIMES,TIME,VYF.ISDELETE FROM VIP_YEAR_FORM VYF,DEPART_INFO D,VIP_INFO V WHERE D.DPID=V.VIPID AND V.VIPID=VYF.VIPID AND TIME<@ENDTIME AND TIME>@BEGINTIME AND VYF.ISDELETE=1 AND D.DPID=@DPID AND D.ISDELETE!=1 UNION
SELECT VYID,V.VIPID,V.VIPNAME,VYCOST,VYTIMES,TIME,VYF.ISDELETE FROM VIP_YEAR_FORM VYF,DEPART_INFO D,VIP_NO_INFO V WHERE D.DPID=V.VIPID AND V.VIPID=VYF.VIPID AND TIME<@ENDTIME AND TIME>@BEGINTIME AND VYF.ISDELETE=0 AND D.DPID=@DPID AND D.ISDELETE!=1
--SELECT vyf.VYID,vyf.VIPID,vyf.VYCOST,vyf.VYTIMES,vyf.TIME,vyf.ISDELETE FROM VIP_YEAR_FORM vyf,VIP_INFO v,DEPART_INFO d WHERE vyf.VIPID=v.VIPID AND v.DPID=d.DPID AND d.DPID=@DPID AND vyf.TIME<@ENDTIME AND vyf.TIME>@BEGINTIME AND vyf.ISDELETE!=2
END
GO
/****** Object: StoredProcedure [dbo].[VIP_YEAR_FORM_INSERT] Script Date: 09/24/2015 19:14:16 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROC [dbo].[VIP_YEAR_FORM_INSERT]
--每天每个VIP一个记录
AS
BEGIN
--DECLARE @BEGIN DATETIME
--DECLARE @END DATETIME
declare @dayBegin datetime
declare @dayEnd datetime
set @dayBegin=DATEADD(HOUR ,-4,CONVERT(VARCHAR(10),GETDATE (),111))--当天开始时间
set @dayEnd= DATEADD(HOUR ,20,CONVERT(VARCHAR(10),GETDATE (),111))--当天结束时间
--SET @END=GETDATE()
--SET @BEGIN=dateadd(dd,-day(dateadd(month,-1,getdate()))+1,dateadd(month,-1,getdate()))--上个月一号
--选择会员
SELECT VIP_INFO.VIPID AS VIPID,ISNULL(SUM(BIKE_RETURN_INFO.BUCOST),0) AS COST,COUNT(*) AS TIMES INTO #TEMP FROM VIP_INFO LEFT JOIN BIKE_RETURN_INFO ON VIP_INFO.VIPID=BIKE_RETURN_INFO.VIPID AND BIKE_RETURN_INFO.ISVIP=1 AND VIP_INFO.ISDELETE!=1 AND BIKE_RETURN_INFO.RBKTIME>@dayBegin AND BIKE_RETURN_INFO.RBKTIME<@dayEnd GROUP BY VIP_INFO.VIPID
--插入报表中,会员用ISDELETE为1来表示
INSERT INTO VIP_YEAR_FORM (VIPID,VYCOST,VYTIMES,TIME,ISDELETE) SELECT #TEMP.VIPID,#TEMP.COST,#TEMP.TIMES,getdate(),1 FROM #TEMP
--选择非会员
SELECT VIP_NO_INFO.VIPID AS VIPID,ISNULL(SUM(BIKE_RETURN_INFO.BUCOST),0) AS COST,COUNT(*) AS TIMES INTO #TEMPNO FROM VIP_NO_INFO LEFT JOIN BIKE_RETURN_INFO ON VIP_NO_INFO.VIPID=BIKE_RETURN_INFO.VIPID AND BIKE_RETURN_INFO.ISVIP=0 AND VIP_NO_INFO.ISDELETE!=1 AND BIKE_RETURN_INFO.RBKTIME>@dayBegin AND BIKE_RETURN_INFO.RBKTIME<@dayEnd GROUP BY VIP_NO_INFO.VIPID
--插入报表,非会员用ISDELETE为0表示
INSERT INTO VIP_YEAR_FORM (VIPID,VYCOST,VYTIMES,TIME,ISDELETE) SELECT #TEMPNO.VIPID,#TEMPNO.COST,#TEMPNO.TIMES,getdate(),0 FROM #TEMPNO
END
GO
/****** Object: StoredProcedure [dbo].[VIP_UPDATE] Script Date: 09/24/2015 19:14:16 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROC [dbo].[VIP_UPDATE]
@VIPID INT,
@VIPNUMBER VARCHAR(200),
@VIPNAME VARCHAR(50),
@VIPSEX BIT,
@VIPPHOTO IMAGE,
@VIPLEVELID INT,
@VIPPWD VARCHAR(50),
@VIPPHONE VARCHAR(50),
@VIPCARD VARCHAR(200),
@VIPBIRTHDAY DATE,
@VIPADDRESS VARCHAR(200),
@DPID INT,
@VIPMARK VARCHAR(1000)
AS
BEGIN
UPDATE VIP_INFO SET MARK =@VIPMARK , VIPNUMBER=@VIPNUMBER,VIPNAME=@VIPNAME,VIPSEX=@VIPSEX,VIPPHOTO=@VIPPHOTO,VIPLEVELID=@VIPLEVELID,VIPPWD=@VIPPWD,VIPPHONE=@VIPPHONE,VIPBIRTHDAY=@VIPBIRTHDAY,VIPADDRESS=@VIPADDRESS,DPID=@DPID WHERE VIPID=@VIPID
END
GO
/****** Object: StoredProcedure [dbo].[VIP_SUM_MONEY_BALANCE_BY_DPID] Script Date: 09/24/2015 19:14:16 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: 郑传哲
-- Create date: 2014/8/6
-- Description: 取出会员总余额
-- =============================================
CREATE PROCEDURE [dbo].[VIP_SUM_MONEY_BALANCE_BY_DPID]