Exemple #1
0
    def _get_data(self,result={}):
        '''
            根据product返回result
        '''
        #该接口mouser需要登陆才行
        result['is_mouser_login'] = True

        #调用RealTimePrice
        rt = RealTimePrice(**result)
        args = rt.get_remote_data()

        #获取库存
        result['stock'] = args.get('stock',0)
        #如果欲询价数量大于库存,就以库存为准
        if result['qty'] > result['stock'] and not result.get('allow_stock',False):
            result['qty'] = result['stock']        
        #分别获取各个地区价格
        part_price = args.get('part_price',[])#(price_break,us_hk,rmb_hk,hk_hk,rmb_dl)
        result['part_price'] = part_price
        #if str(product.supplier) in '29':#
            #part_price = args.get('cost_price_list')
        pc = PriceCalc(supplier=result['supplier'],partno=result['partno'],mfr=result.get('mfr',''),slug=result.get('slug',''))        
        if part_price:
            price_list = pc.get_source_price_list(part_price,result['qty'])
            result['price_list'] = [price_list[1],price_list[2],price_list[4]]
            result['price_list_all'] = [price_list[1],price_list[2],price_list[3],price_list[4]]
        else:
            result['price_list'] = [0.0,0.0,0.0]        
            result['price_list_all'] = [0.0,0.0,0.0,0.0]
        #获取进价
        ourprice = pc._get_purch_price(args.get('p_new',[]),result['qty'],args.get('purchases_new',[]))
        
        result['category_tax'] = args.get('category_tax',1.0)
            
        result['ourprice'] = str(ourprice)
        
        #禁运标志
        result['ccc_flag'] = args.get('ccc_flag','')
        
        #Stock_info # @@ $$  %%  &&
        result['stock_info'] = args.get('stock_info','')
        
        return result
    def get_part_price(self, args):
        """
            根据各种条件来生成icgoo的最终报价列表
        """
        pc = PriceCalc(supplier=self.supplier, partno=self.partno, mfr=self.mfr, slug=self.slug)

        # 将获取的原始数据集进行利润率的计算(供应商有的是用原始价跟定价规则来算,有的则是用进价跟定价规则来算)
        p_new = pc.get_best_price_list(args["p_new"], args["purchases_new"])

        part_price = []
        if p_new:
            for price_break, price in p_new:
                rmb_hk = pc.calc_unit_price(1, price, 1)
                us_hk = pc.calc_unit_price(2, price, 1)
                hk_hk = pc.calc_unit_price(3, price, 1)
                rmb_dl = pc.calc_unit_price(4, price, args["category_tax"])

                part_price.append((price_break, us_hk, rmb_hk, hk_hk, rmb_dl))

        if part_price:
            # 合并part_price
            temp_qty = 0
            temp_price = 0
            count = 0
            remove_list = []
            for i in part_price:
                if count == 0:
                    temp_qty = i[0]
                    temp_price = i[1]
                    count += 1
                    continue
                # 数量不一样,但价格是一样的段,取最小数量那段
                if temp_price == i[1] and temp_qty <= i[0]:
                    remove_list.append(i)
                # 数量一样,但价格不一样的段,取最小价格那段
                if temp_qty == i[0] and temp_price <= i[1]:
                    remove_list.append(i)

            for i in remove_list:
                part_price.remove(i)

        return part_price
Exemple #3
0
 def getSalePriceToJiayou(self,supplier,mfr='',costprice=0.0):
     '''
         给你详细的信息+进价
         返回销售价信息
     '''
     pc = PriceCalc(partno=self.partno,supplier=supplier,mfr=mfr)
     #获取一个正序的定价规则
     purchases_list = pc.purchases_list
     purchases_list.reverse()
     
     #美金销价
     price = float(costprice) * pc.get_source_price(purchases_list,float(self.qty)*float(costprice))
     #额外关税
     try:
         category_tax = CategoryChecklist.objects.get(partno=self.partno).get_product_tax['tax__max']
     except Exception,e:
         try:
             category_tax = Product.objects.filter(name=self.partno,active=True)[0].get_product_tax['tax__max']
         except Exception,e:
             category_tax = 1.0