def import_orders_from_jd_bk(self, cr, uid, ids, context=None): shop_id = self.browse(cr, uid, ids[0], context= context) req = OrderSearchRequest(shop_id.apiurl, 443, shop_id.appkey, shop_id.appsecret) req.fields = 'ware_id,skus,cid,brand_id,vender_id,shop_id,ware_status,title,item_num,upc_code,market_price,stock_num,status,weight,shop_categorys,property_alias' req.ware_ids = '1950500375,1954692765,1954700506,1954996897,1951075519' resp= req.getResponse(shop_id.sessionkey or shop_id.access_token) total_results = resp.get('360buy_wares_list_get_response').get('wareListResponse').get('wares')
def import_orders_from_jd(self, cr, uid, ids, context=None): shop_id = self.browse(cr, uid, ids[0], context=context) req = OrderSearchRequest(shop_id.apiurl, 443, shop_id.appkey, shop_id.appsecret) req.optional_fields = 'order_id,order_source,order_total_price,order_payment,freight_price,order_state,vender_remark,order_start_time,consignee_info,item_info_list,payment_confirm_time,waybill,logistics_id,store_order,parent_order_id' req.page_size = 100 req.page = 1 req.order_state = 'WAIT_SELLER_STOCK_OUT,WAIT_GOODS_RECEIVE_CONFIRM' req.end_date = datetime.now().strftime("%Y-%m-%d %H:%M:%S") hours_interval = shop_id.sync_interval req.start_date = ( datetime.now() - timedelta(hours=hours_interval)).strftime('%Y-%m-%d %H:%M:%S') resp = req.getResponse(shop_id.sessionkey or shop_id.access_token) order_info_list = resp.get('order_search_response').get( 'order_search').get('order_info_list') orders = self.clean_jdi_orders(cr, uid, ids, order_info_list, shop_id, context=context) self.create_order_for_jd(cr, uid, ids, orders, context=context)
def import_orders_from_jd(self, cr, uid, ids, context=None): shop_id = self.browse(cr, uid, ids[0], context=context) req = OrderSearchRequest(shop_id.apiurl, 443, shop_id.appkey, shop_id.appsecret) req.optional_fields = 'order_id,order_payment,order_state,vender_remark,consignee_info,item_info_list,payment_confirm_time,waybill,logistics_id' req.page_size = 20 req.page = 1 req.dateType = 1 req.sortType = 1 req.order_state = 'WAIT_SELLER_STOCK_OUT,WAIT_SELLER_DELIVERY' ctx_start_time = context.get('start_time', False) ctx_start_time = ctx_start_time and (datetime.strptime( ctx_start_time, '%Y-%m-%d %H:%M:%S') + timedelta(hours=8)) ctx_end_time = context.get( 'end_time', False) # datetime.strptime(string, "%Y-%m-%d-%H") ctx_end_time = ctx_end_time and datetime.strptime( ctx_end_time, '%Y-%m-%d %H:%M:%S') + timedelta(hours=8) req.end_date = ctx_end_time and ctx_end_time.strftime( '%Y-%m-%d %H:%M:%S') or self.get_datetime_now() hours_interval = shop_id.sync_interval if not hours_interval: hours_interval = 24 req.start_date = ctx_start_time or ( ctx_end_time and (ctx_end_time - timedelta(hours=hours_interval) ).strftime('%Y-%m-%d %H:%M:%S')) or (datetime.now() - timedelta( hours=hours_interval - 8)).strftime('%Y-%m-%d %H:%M:%S') order_total = 100 total_get = 0 order_info_list = [] while total_get < order_total: resp = req.getResponse(shop_id.sessionkey or shop_id.access_token) order_total = resp.get('order_search_response').get( 'order_search').get('order_total') if order_total > 0: order_info_list += resp.get('order_search_response').get( 'order_search').get('order_info_list') total_get += req.page_size req.page = req.page + 1 hk_list, jaycee_list, sz_list = self.clean_jdi_orders(cr, uid, ids, order_info_list, shop_id, context=context) self.create_order_for_jd(cr, uid, ids, hk_list, context=context) self.create_sz_erp_salesorder(cr, uid, ids, jaycee_list + sz_list, context=context)
def import_orders_from_jd(self, cr, uid, ids, context=None): shop_id = self.browse(cr, uid, ids[0], context=context) req = OrderSearchRequest(shop_id.apiurl, 443, shop_id.appkey, shop_id.appsecret) req.optional_fields = 'order_id,order_payment,order_state,vender_remark,consignee_info,item_info_list,order_start_time,payment_confirm_time,pin,waybill,logistics_id' req.page_size = 100 req.page = 1 req.dateType = 1 #req.sortType = 1 req.order_state = 'WAIT_SELLER_STOCK_OUT,WAIT_SELLER_DELIVERY' ctx_end_time = context.get('end_time', False) end_time = ctx_end_time and ( datetime.strptime(ctx_end_time, '%Y-%m-%d %H:%M:%S') + timedelta(hours=8)) or self.get_datetime_now() end_time_str = end_time.strftime('%Y-%m-%d %H:%M:%S') req.end_date = end_time_str hours_interval = shop_id.sync_interval # shop # if not hours_interval : hours_interval = 24 ctx_start_time = context.get('start_time', False) start_time = ctx_start_time and (datetime.strptime( ctx_start_time, '%Y-%m-%d %H:%M:%S') + timedelta(hours=8)) if hours_interval: start_time = start_time or ( end_time and (end_time - timedelta(hours=hours_interval))) or ( datetime.now() - timedelta(hours=hours_interval - 8)) start_time_str = start_time and start_time.strftime( '%Y-%m-%d %H:%M:%S') if start_time_str: req.start_date = start_time_str order_total = 1000 total_get = 0 order_info_list = [] while total_get < order_total: resp = req.getResponse(shop_id.sessionkey or shop_id.access_token) order_total = resp.get('order_search_response').get( 'order_search').get('order_total') if order_total > 0: order_info_list += resp.get('order_search_response').get( 'order_search').get('order_info_list') total_get += req.page_size req.page = req.page + 1 hk_list, si_fang_list = self.clean_jdi_orders(cr, uid, ids, order_info_list, shop_id, context=context) order_id = order_id2 = 0 if hk_list: order_id = self.create_order_for_jd(cr, uid, ids, hk_list, context=context) #if si_fang_list : order_id2 = self.create_order_for_jd( cr, uid, ids, si_fang_list, context=context.update({'is_si_fang':True}) ) if order_id: #or order_id2 : shop_id.write({'import_salesorder': order_id}) return order_id
def import_orders_from_jd(self, cr, uid, ids, context=None): shop_id = self.browse(cr, uid, ids[0], context= context) req = OrderSearchRequest(shop_id.apiurl, 443, shop_id.appkey, shop_id.appsecret) req.optional_fields = 'order_id,order_payment,order_state,vender_remark,consignee_info,item_info_list,payment_confirm_time,waybill,logistics_id' req.page_size = 20 req.page = 1 req.dateType = 1 req.sortType = 1 req.order_state = 'WAIT_SELLER_STOCK_OUT,WAIT_SELLER_DELIVERY' req.end_date = (datetime.now() + timedelta(hours=8)).strftime('%Y-%m-%d %H:%M:%S') hours_interval = shop_id.sync_interval if hours_interval : hours_interval -= 8 else: hours_interval = 16 req.start_date = (datetime.now() - timedelta(hours=hours_interval)).strftime('%Y-%m-%d %H:%M:%S') order_total = 100 total_get = 0 order_info_list = [] while total_get < order_total : resp= req.getResponse(shop_id.sessionkey or shop_id.access_token) order_total = resp.get('order_search_response').get('order_search').get('order_total') if order_total > 0: order_info_list += resp.get('order_search_response').get('order_search').get('order_info_list') total_get += req.page_size req.page = req.page + 1 orders = self.clean_jdi_orders(cr, uid, ids, order_info_list, shop_id, context=context) self.create_order_for_jd(cr, uid, ids, orders, context=context)