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
| class CiOrder(models.Model): class Meta: db_table = 'ci_order' verbose_name = verbose_name_plural = '订单管理' ordering = ['order_number'] order_id = models.AutoField('ID', max_length=11, primary_key=True) order_pname = models.CharField('产品名称',max_length=255,null=True,blank=True) order_number = models.CharField('订单编码', max_length=255) order_customer = models.CharField('客户', max_length=50, null=True, blank=True) order_inprice = models.IntegerField('进货价格', max_length=11, null=True, blank=True) order_brand = models.CharField('品牌', max_length=50, null=True, blank=True) order_model = models.CharField('规格', max_length=50, null=True, blank=True) order_quantity = models.IntegerField('订单数量', max_length=11) order_unitprice = models.IntegerField('销售单价', max_length=11, null=True, blank=True) order_owner = models.CharField('业务员', max_length=50, null=True, blank=True) order_createdtime = models.DateTimeField('下单时间', default=timezone.now()) order_delivertime = models.DateTimeField('交付时间', default=timezone.now()) update_time = models.DateTimeField('更新时间', auto_now=True) order_order_pid = models.ForeignKey(CiProduct,default=1) GENDER_CHOICE1 = ( (0,u'直接销售'), (1,u'送货上门'), ) order_alias = models.IntegerField('订单类型',choices=GENDER_CHOICE1,default=0,max_length=8, null=True, blank=True) uniq_id = models.IntegerField(max_length=11, null=True, blank=True) GENDER_CHOICE = ( (0,u'有货'), (1,u'没货'), ) status = models.IntegerField('订单状态',choices=GENDER_CHOICE,default=0,max_length=8, null=True, blank=True)
def __str__(self): return self.order_number def total_price(self): total_price=0 groceryItems = CiOrder.objects.all()
for item in groceryItems: if(self.order_customer==item.order_customer): if(self.order_createdtime.hour==item.order_createdtime.hour): total_price += item.order_quantity*item.order_unitprice
return total_price def day_sale(self): time_sale=0 grceryItems1=CiOrder.objects.all() for item in grceryItems1: if(self.order_delivertime.day==item.order_delivertime.day): time_sale+=1 return time_sale def product_sale(self): product_sale=0 grceryItems2=CiOrder.objects.all() for item in grceryItems2: if(self.order_order_pid==item.order_order_pid): product_sale+= item.order_quantity*item.order_unitprice return product_sale def hour_sale(self): hour_sale=0 grceryItems3=CiOrder.objects.all() for item in grceryItems3: if(self.order_createdtime.hour==item.order_createdtime.hour): hour_sale+=1 return hour_sale
|