Subversion Repositories SmartDukaan

Rev

Rev 5470 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5470 Rev 5485
Line 3... Line 3...
3
 
3
 
4
@author: Varun Gupta
4
@author: Varun Gupta
5
 
5
 
6
Allows first 300 users to use the coupon
6
Allows first 300 users to use the coupon
7
 
7
 
8
Galaxy Y Pro Duos B5512       Discount: Rs.502
-
 
9
Chat 322 C3222        Discount: Rs.171
8
Chat 322 C3222        Discount: Rs.171
10
Champ Deluxe Duos C3312       Discount: Rs.211
-
 
11
Champ Duos E2652       Discount: Rs.155
9
Champ Duos E2652       Discount: Rs.155
12
Champ 3.5G S3770       Discount: Rs.255
10
Champ 3.5G S3770       Discount: Rs.255
13
Corby II S3850       Discount: Rs.361
11
Corby II S3850       Discount: Rs.361
14
Star 3 Duos S5222       Discount: Rs.151
-
 
15
Chat 527 S5270       Discount: Rs.205
12
Chat 527 S5270       Discount: Rs.205
16
Wave Y S5380       Discount: Rs.345
-
 
17
Metro C3530       Discount: Rs.251
13
Metro C3530       Discount: Rs.251
18
Primo S5610       Discount: Rs.241
14
Primo S5610       Discount: Rs.241
19
Star II S5263       Discount: Rs.301
15
Star II S5263       Discount: Rs.301
20
Star II Duos C6712       Discount: Rs.251
16
Star II Duos C6712       Discount: Rs.251
21
Wave 525 S5253       Discount: Rs.391
17
Wave 525 S5253       Discount: Rs.391
22
Galaxy Y Color S5360s       Discount: Rs.199
18
Galaxy Y Color S5360s       Discount: Rs.199
23
 
19
 
24
Champ Megacam C3303i    Discount: Rs.80
20
Champ Megacam C3303i    Discount: Rs.80
25
Champ Deluxe C3312s    Discount: Rs.191
21
Champ Deluxe C3312s    Discount: Rs.191
26
Metro Duos C3322    Discount: Rs.151
-
 
27
Metro C3520    Discount: Rs.40
22
Metro C3520    Discount: Rs.40
28
Star II Duos C6712    Discount: Rs.271
23
Star II Duos C6712    Discount: Rs.271
29
E1200, E1205    Discount: Rs.61
24
E1200, E1205    Discount: Rs.61
30
Guru FM E1220    Discount: Rs.51
25
Guru FM E1220    Discount: Rs.51
31
Omnia W I8350    Discount: Rs.701
26
Omnia W I8350    Discount: Rs.701
32
Galaxy S II I9100    Discount: Rs.905
-
 
33
Galaxy Note N7000    Discount: Rs.901
-
 
34
'''
27
'''
35
from shop2020.thriftpy.model.v1.user.ttypes import PromotionException, Discount
28
from shop2020.thriftpy.model.v1.user.ttypes import PromotionException, Discount
36
from shop2020.model.v1.user.impl.PromotionRuleDataUtilities import get_coupon_usage_count, get_coupon_usage_count_by_user
29
from shop2020.model.v1.user.impl.PromotionRuleDataUtilities import get_coupon_usage_count, get_coupon_usage_count_by_user
37
from shop2020.clients.UserClient import UserClient
30
from shop2020.clients.UserClient import UserClient
38
 
31
 
Line 67... Line 60...
67
                has_qualified_model = True
60
                has_qualified_model = True
68
                
61
                
69
                if line.actualPrice:
62
                if line.actualPrice:
70
                    discount_value = 171
63
                    discount_value = 171
71
            
64
            
72
            elif line.itemId in (3356, 4628, 5730, 2563, 3357):  #Champ Deluxe Duos C3312
-
 
73
                
-
 
74
                has_qualified_model = True
-
 
75
                
-
 
76
                if line.actualPrice:
-
 
77
                    discount_value = 211
-
 
78
            
-
 
79
            elif line.itemId in (1012, 1452, 1453):  #Metro C3530
65
            elif line.itemId in (1012, 1452, 1453):  #Metro C3530
80
                
66
                
81
                has_qualified_model = True
67
                has_qualified_model = True
82
                
68
                
83
                if line.actualPrice:
69
                if line.actualPrice:
Line 102... Line 88...
102
                has_qualified_model = True
88
                has_qualified_model = True
103
                
89
                
104
                if line.actualPrice:
90
                if line.actualPrice:
105
                    discount_value = 255
91
                    discount_value = 255
106
            
92
            
107
            elif line.itemId in (3358, 4643):  #Star 3 Duos S5222
-
 
108
                
-
 
109
                has_qualified_model = True
-
 
110
                
-
 
111
                if line.actualPrice:
-
 
112
                    discount_value = 151
-
 
113
            
-
 
114
            elif line.itemId in (2090, 2256):  #Primo S5610
93
            elif line.itemId in (2090, 2256):  #Primo S5610
115
                
94
                
116
                has_qualified_model = True
95
                has_qualified_model = True
117
                
96
                
118
                if line.actualPrice:
97
                if line.actualPrice:
Line 144... Line 123...
144
                has_qualified_model = True
123
                has_qualified_model = True
145
                
124
                
146
                if line.actualPrice:
125
                if line.actualPrice:
147
                    discount_value = 391
126
                    discount_value = 391
148
            
127
            
149
            elif line.itemId in (2537, 2622):  #Wave Y S5380
-
 
150
                
-
 
151
                has_qualified_model = True
-
 
152
                
-
 
153
                if line.actualPrice:
-
 
154
                    discount_value = 345
-
 
155
            
-
 
156
            elif line.itemId == 2446:  #Galaxy Y Color S5360s
128
            elif line.itemId == 2446:  #Galaxy Y Color S5360s
157
                
129
                
158
                has_qualified_model = True
130
                has_qualified_model = True
159
                
131
                
160
                if line.actualPrice:
132
                if line.actualPrice:
161
                    discount_value = 199
133
                    discount_value = 199
162
            
134
            
163
            elif line.itemId == 2630:  #Galaxy Y Pro Duos B5512
-
 
164
                
-
 
165
                has_qualified_model = True
-
 
166
                
-
 
167
                if line.actualPrice:
-
 
168
                    discount_value = 502
-
 
169
            
-
 
170
            elif line.itemId in (1001, 2226, 1004, 1011, 998): #Champ Megacam C3303i
135
            elif line.itemId in (1001, 2226, 1004, 1011, 998): #Champ Megacam C3303i
171
                has_qualified_model = True
136
                has_qualified_model = True
172
                
137
                
173
                if line.actualPrice:    discount_value = 80
138
                if line.actualPrice:    discount_value = 80
174
            
139
            
175
            elif line.itemId == 4629: #Champ Deluxe C3312s
140
            elif line.itemId == 4629: #Champ Deluxe C3312s
176
                has_qualified_model = True
141
                has_qualified_model = True
177
                
142
                
178
                if line.actualPrice:    discount_value = 191 
143
                if line.actualPrice:    discount_value = 191 
179
            
144
            
180
            elif line.itemId in (2532, 4689, 1500): #Metro Duos C3322
-
 
181
                has_qualified_model = True
-
 
182
                
-
 
183
                if line.actualPrice:    discount_value = 151 
-
 
184
            
-
 
185
            elif line.itemId in (2445, 4636): #Metro C3520
145
            elif line.itemId in (2445, 4636): #Metro C3520
186
                has_qualified_model = True
146
                has_qualified_model = True
187
                
147
                
188
                if line.actualPrice:    discount_value = 40
148
                if line.actualPrice:    discount_value = 40
189
            
149
            
Line 205... Line 165...
205
            elif line.itemId == 2470: #Omnia W I8350
165
            elif line.itemId == 2470: #Omnia W I8350
206
                has_qualified_model = True
166
                has_qualified_model = True
207
                
167
                
208
                if line.actualPrice:    discount_value = 701
168
                if line.actualPrice:    discount_value = 701
209
            
169
            
210
            elif line.itemId in (1493, 1502): #Galaxy S II I9100
-
 
211
                has_qualified_model = True
-
 
212
                
-
 
213
                if line.actualPrice:    discount_value = 905
-
 
214
            
-
 
215
            elif line.itemId in (2215, 2481): #Galaxy Note N7000
-
 
216
                has_qualified_model = True
-
 
217
                
-
 
218
                if line.actualPrice:    discount_value = 901
-
 
219
            
-
 
220
            if discount_value > 0:
170
            if discount_value > 0:
221
                discount = Discount()
171
                discount = Discount()
222
                discount.cart_id = cart.id
172
                discount.cart_id = cart.id
223
                discount.item_id = line.itemId
173
                discount.item_id = line.itemId
224
                discount.discount = discount_value
174
                discount.discount = discount_value
Line 240... Line 190...
240
 
190
 
241
def getDiscountOnItem(item):
191
def getDiscountOnItem(item):
242
    
192
    
243
    discount_expressions = [
193
    discount_expressions = [
244
            '171 if item.id in (1010, 1451) else None',
194
            '171 if item.id in (1010, 1451) else None',
245
            '211 if item.id in (3356, 4628, 5730, 2563, 3357) else None',
-
 
246
            '251 if item.id in (1012, 1452, 1453) else None',
195
            '251 if item.id in (1012, 1452, 1453) else None',
247
            '155 if item.id in (999, 988, 5702) else None',
196
            '155 if item.id in (999, 988, 5702) else None',
248
            '205 if item.id in (2576, 2067) else None',
197
            '205 if item.id in (2576, 2067) else None',
249
            '255 if item.id in (2073, 2621) else None',
198
            '255 if item.id in (2073, 2621) else None',
250
            '151 if item.id in (3358, 4643) else None',
-
 
251
            '241 if item.id in (2090, 2256) else None',
199
            '241 if item.id in (2090, 2256) else None',
252
            '301 if item.id in (968, 995) else None',
200
            '301 if item.id in (968, 995) else None',
253
            '361 if item.id in (996, 1000, 1524, 1563) else None',
201
            '361 if item.id in (996, 1000, 1524, 1563) else None',
254
            '251 if item.id in (1537, 2227) else None',
202
            '251 if item.id in (1537, 2227) else None',
255
            '391 if item.id in (949, 4690, 948) else None',
203
            '391 if item.id in (949, 4690, 948) else None',
256
            '345 if item.id in (2537, 2622) else None',
-
 
257
            '199 if item.id == 2446 else None',
204
            '199 if item.id == 2446 else None',
258
            '502 if item.id == 2630 else None',
-
 
259
            '80 if item.id in (1001, 2226, 1004, 1011, 998) else None',
205
            '80 if item.id in (1001, 2226, 1004, 1011, 998) else None',
260
            '191 if item.id == 4629 else None',
206
            '191 if item.id == 4629 else None',
261
            '151 if item.id in (2532, 4689, 1500) else None',
-
 
262
            '40 if item.id in (2445, 4636) else None',
207
            '40 if item.id in (2445, 4636) else None',
263
            '271 if item.id in (1537, 2227) else None',
208
            '271 if item.id in (1537, 2227) else None',
264
            '61 if item.id in (5700, 5701) else None',
209
            '61 if item.id in (5700, 5701) else None',
265
            '51 if item.id == 2603 else None',
210
            '51 if item.id == 2603 else None',
266
            '701 if item.id == 2470 else None',
211
            '701 if item.id == 2470 else None'
267
            '905 if item.id in (1493, 1502) else None',
-
 
268
            '901 if item.id in (2215, 2481) else None'
-
 
269
        ]
212
        ]
270
    for expression in discount_expressions:
213
    for expression in discount_expressions:
271
        discount = eval(expression)
214
        discount = eval(expression)
272
        
215
        
273
        if discount is not None:
216
        if discount is not None: