Subversion Repositories SmartDukaan

Rev

Rev 13955 | Rev 14081 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 13955 Rev 13995
Line 19... Line 19...
19
           'User-agent':'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11',
19
           'User-agent':'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11',
20
            'Accept' : 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',      
20
            'Accept' : 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',      
21
            'Accept-Language' : 'en-US,en;q=0.8',                     
21
            'Accept-Language' : 'en-US,en;q=0.8',                     
22
            'Accept-Charset' : 'ISO-8859-1,utf-8;q=0.7,*;q=0.3'
22
            'Accept-Charset' : 'ISO-8859-1,utf-8;q=0.7,*;q=0.3'
23
        }
23
        }
24
CASHBACK_URL = 'http://api.profittill.com/cashbacks/index/%s/%s'
24
CASHBACK_URL = 'http://104.200.25.40:8057/Catalog/cashBack/?identifier=%s&source_id=%s'
25
USER_LOOKUP_URL = 'http://api.profittill.com/user_accounts/saholic/%s'
25
USER_LOOKUP_URL = 'http://api.profittill.com/user_accounts/saholic/%s'
26
WALLET_CREDIT_URL = 'http://shop2020.in:8080/mobileapi/wallet!batchUpdate'
26
WALLET_CREDIT_URL = 'http://shop2020.in:8080/mobileapi/wallet!batchUpdate'
27
 
27
 
28
def getStore(source_id):
28
def getStore(source_id):
29
    #module = sourceMap[source_id]
29
    #module = sourceMap[source_id]
Line 109... Line 109...
109
            #merchantOder 
109
            #merchantOder 
110
        except Exception as e:
110
        except Exception as e:
111
            traceback.print_exc()
111
            traceback.print_exc()
112
    
112
    
113
    def getCashbackAmount(self, productCode, amount):
113
    def getCashbackAmount(self, productCode, amount):
114
        alagvar = CASHBACK_URL % (self.store_id,productCode)
114
        alagvar = CASHBACK_URL % (productCode,self.store_id)
115
        filehandle = urllib2.Request(alagvar,headers=headers)
115
        filehandle = urllib2.Request(alagvar,headers=headers)
116
        x= urllib2.urlopen(filehandle)
116
        x= urllib2.urlopen(filehandle)
117
        map = json.loads(x.read())
117
        rmap = json.loads(str(x.read()))
118
        if map['cashback']==0:
118
        if len(rmap)==0:
119
            return (0,0)
119
            return (0,0)
120
        else:
120
        else:
121
            if map['cashback_type'] == 'percentage':
121
            if rmap['cash_back_description'] == 'PERCENTAGE':
122
                return (math.floor((amount * map['cashback'])/100), map['cashback'])
122
                return (math.floor((amount * rmap['cash_back_status'])/100), rmap['cash_back_status'])
123
            else:
123
            else:
124
                return (map['cashback'], 0)
124
                return (rmap['cash_back_status'], 0)
125
            
125
            
126
    
126
    
127
    '''
127
    '''
128
    Parses the order for specific store
128
    Parses the order for specific store
129
    
129
    
Line 220... Line 220...
220
        traceback.print_exc()
220
        traceback.print_exc()
221
        tprint("Could not batch refund")
221
        tprint("Could not batch refund")
222
        return False
222
        return False
223
    
223
    
224
def main():
224
def main():
225
    #store = getStore(3)
225
    store = getStore(3)
226
    #print store.getCashbackAmount('864683341', 100)
226
    print store.getCashbackAmount('832308321', 100)
227
    #data = urllib.urlencode({'orderId':6000, 'amount':200})
227
    #data = urllib.urlencode({'orderId':6000, 'amount':200})
228
    #request = urllib2.Request(WALLET_CREDIT_URL % (483649), headers=headers)
228
    #request = urllib2.Request(WALLET_CREDIT_URL % (483649), headers=headers)
229
    #response = urllib2.urlopen(request, data)
229
    #response = urllib2.urlopen(request, data)
230
    #print response.read()
230
    #print response.read()
231
    settlePayBack()
231
    #settlePayBack()
232
    
232
    
233
        
233
        
234
 
234
 
235
 
235
 
236
###
236
###