diff --git a/system/login/urls.py b/system/login/urls.py index 70071685b91746fb9f045946b29d3a0b30d3fa71..c822970f15f10d837437b9754d8560a897633855 100644 --- a/system/login/urls.py +++ b/system/login/urls.py @@ -1,4 +1,4 @@ -from django.urls import path +from django.urls import path, include from django.urls import re_path as url from . import views from . import view1 @@ -13,7 +13,7 @@ urlpatterns = [ url(r'^bar/$', view1.ChartView_bar.as_view(), name='i_graph1'), path('i_graph1/', view1.bar_page, name='i_graph1'), path('index1/Proc_index/', views.proc_index, name='proc_index'), - path('index1/Sales_index/', views.sale_index, name='sale_index'), + path('index1/Sales_index/', include('sales.urls')), path('index1/Warehouse_index/', views.Warehouse_index, name='warehouse_index'), path('index1/live_info', views.Stream_info, name='stream_info'), url(r'^line/$', view1.ChartView.as_view(), name='demo'), diff --git a/system/login/views.py b/system/login/views.py index cf1fa0a36f3ace979f81a12eb66efa4a6f1a9751..afaa01b7568dc52448884b49994e1e049177f702 100644 --- a/system/login/views.py +++ b/system/login/views.py @@ -65,11 +65,6 @@ def create(request):##注册并登录界面, def proc_index(request): return render(request, '../templates/Procurement/index.html') - -def sale_index(request): - return render(request, '../templates/Sales/index.html') - - def Warehouse_index(request): return render(request, '../templates/Warehouse/index.html') diff --git a/system/sales/models.py b/system/sales/models.py index 71a836239075aa6e6e4ecb700e9c42c95c022d91..af5af8fec80c66efe6a7ddfc61e5eb832841041a 100644 --- a/system/sales/models.py +++ b/system/sales/models.py @@ -1,3 +1,486 @@ +# This is an auto-generated Django model module. +# You'll have to do the following manually to clean this up: +# * Rearrange models' order +# * Make sure each model has one field with primary_key=True +# * Make sure each ForeignKey and OneToOneField has `on_delete` set to the desired behavior +# * Remove `managed = False` lines if you wish to allow Django to create, modify, and delete the table +# Feel free to rename the models, but don't rename db_table values or field names. from django.db import models -# Create your models here. + +class AuthGroup(models.Model): + name = models.CharField(unique=True, max_length=150) + + class Meta: + managed = False + db_table = 'auth_group' + + +class AuthGroupPermissions(models.Model): + id = models.BigAutoField(primary_key=True) + group = models.ForeignKey(AuthGroup, models.DO_NOTHING) + permission = models.ForeignKey('AuthPermission', models.DO_NOTHING) + + class Meta: + managed = False + db_table = 'auth_group_permissions' + unique_together = (('group', 'permission'),) + + +class AuthPermission(models.Model): + name = models.CharField(max_length=255) + content_type = models.ForeignKey('DjangoContentType', models.DO_NOTHING) + codename = models.CharField(max_length=100) + + class Meta: + managed = False + db_table = 'auth_permission' + unique_together = (('content_type', 'codename'),) + + +class AuthUser(models.Model): + password = models.CharField(max_length=128) + last_login = models.DateTimeField(blank=True, null=True) + is_superuser = models.IntegerField() + username = models.CharField(unique=True, max_length=150) + first_name = models.CharField(max_length=150) + last_name = models.CharField(max_length=150) + email = models.CharField(max_length=254) + is_staff = models.IntegerField() + is_active = models.IntegerField() + date_joined = models.DateTimeField() + + class Meta: + managed = False + db_table = 'auth_user' + + +class AuthUserGroups(models.Model): + id = models.BigAutoField(primary_key=True) + user = models.ForeignKey(AuthUser, models.DO_NOTHING) + group = models.ForeignKey(AuthGroup, models.DO_NOTHING) + + class Meta: + managed = False + db_table = 'auth_user_groups' + unique_together = (('user', 'group'),) + + +class AuthUserUserPermissions(models.Model): + id = models.BigAutoField(primary_key=True) + user = models.ForeignKey(AuthUser, models.DO_NOTHING) + permission = models.ForeignKey(AuthPermission, models.DO_NOTHING) + + class Meta: + managed = False + db_table = 'auth_user_user_permissions' + unique_together = (('user', 'permission'),) + + +class BackgroundEmp(models.Model): + eid = models.OneToOneField('EmployeeInfo', models.DO_NOTHING, db_column='eid', primary_key=True) + bge_name = models.CharField(max_length=10, blank=True, null=True) + bge_duty = models.CharField(max_length=10, blank=True, null=True) + login_status = models.IntegerField(blank=True, null=True) + + class Meta: + managed = False + db_table = 'background_emp' + + +class CollectingNotes(models.Model): + collect_id = models.CharField(primary_key=True, max_length=20) + recv = models.ForeignKey('Receivables', models.DO_NOTHING) + collect_name = models.CharField(max_length=20, blank=True, null=True) + collect_way = models.CharField(max_length=20, blank=True, null=True) + collect_num = models.FloatField(blank=True, null=True) + + class Meta: + managed = False + db_table = 'collecting_notes' + + +class CustomerInfo(models.Model): + cid = models.CharField(primary_key=True, max_length=20) + clevel = models.CharField(max_length=10, blank=True, null=True) + + class Meta: + managed = False + db_table = 'customer_info' + + +class Danmu(models.Model): + dm_id = models.CharField(primary_key=True, max_length=25) + live_record = models.ForeignKey('LiveRecord', models.DO_NOTHING) + user_name = models.CharField(max_length=50, blank=True, null=True) + send_time = models.DateTimeField(blank=True, null=True) + send_text = models.CharField(max_length=256, blank=True, null=True) + + class Meta: + managed = False + db_table = 'danmu' + + +class DjangoAdminLog(models.Model): + action_time = models.DateTimeField() + object_id = models.TextField(blank=True, null=True) + object_repr = models.CharField(max_length=200) + action_flag = models.PositiveSmallIntegerField() + change_message = models.TextField() + content_type = models.ForeignKey('DjangoContentType', models.DO_NOTHING, blank=True, null=True) + user = models.ForeignKey(AuthUser, models.DO_NOTHING) + + class Meta: + managed = False + db_table = 'django_admin_log' + + +class DjangoContentType(models.Model): + app_label = models.CharField(max_length=100) + model = models.CharField(max_length=100) + + class Meta: + managed = False + db_table = 'django_content_type' + unique_together = (('app_label', 'model'),) + + +class DjangoMigrations(models.Model): + id = models.BigAutoField(primary_key=True) + app = models.CharField(max_length=255) + name = models.CharField(max_length=255) + applied = models.DateTimeField() + + class Meta: + managed = False + db_table = 'django_migrations' + + +class DjangoSession(models.Model): + session_key = models.CharField(primary_key=True, max_length=40) + session_data = models.TextField() + expire_date = models.DateTimeField() + + class Meta: + managed = False + db_table = 'django_session' + + +class EmployeeInfo(models.Model): + eid = models.CharField(primary_key=True, max_length=10) + ename = models.CharField(max_length=10, blank=True, null=True) + psword = models.CharField(max_length=20, blank=True, null=True) + etype = models.CharField(max_length=20, blank=True, null=True) + + class Meta: + managed = False + db_table = 'employee_info' + + +class GoodsInfo(models.Model): + goods_id = models.CharField(primary_key=True, max_length=10) + goods_name = models.CharField(max_length=20, blank=True, null=True) + goods_type = models.CharField(max_length=20, blank=True, null=True) + gprice = models.FloatField(blank=True, null=True) + + class Meta: + managed = False + db_table = 'goods_info' + + +class GoodsInv(models.Model): + inv_id = models.CharField(primary_key=True, max_length=10) + eid = models.ForeignKey('StockAdmin', models.DO_NOTHING, db_column='eid') + inv_time = models.DateTimeField() + + class Meta: + managed = False + db_table = 'goods_inv' + + +class Inventory(models.Model): + inv = models.OneToOneField(GoodsInv, models.DO_NOTHING, primary_key=True) # The composite primary key (inv_id, goods_id) found, that is not supported. The first column is selected. + goods = models.ForeignKey('StockInfo', models.DO_NOTHING) + + class Meta: + managed = False + db_table = 'inventory' + unique_together = (('inv', 'goods'),) + + +class Jbj4Renqi(models.Model): + tim = models.DateTimeField(blank=True, null=True) + peo = models.IntegerField(blank=True, null=True) + + class Meta: + managed = False + db_table = 'jbj4_renqi' + + +class Jbj5Renqi(models.Model): + tim = models.DateTimeField(blank=True, null=True) + peo = models.IntegerField(blank=True, null=True) + + class Meta: + managed = False + db_table = 'jbj5_renqi' + + +class Jbj6Renqi(models.Model): + tim = models.DateTimeField(blank=True, null=True) + peo = models.IntegerField(blank=True, null=True) + + class Meta: + managed = False + db_table = 'jbj6_renqi' + + +class Jbj7Renqi(models.Model): + tim = models.DateTimeField(blank=True, null=True) + peo = models.IntegerField(blank=True, null=True) + + class Meta: + managed = False + db_table = 'jbj7_renqi' + + +class Jbj8Renqi(models.Model): + tim = models.DateTimeField(blank=True, null=True) + peo = models.IntegerField(blank=True, null=True) + + class Meta: + managed = False + db_table = 'jbj8_renqi' + + +class LiveRecord(models.Model): + live_record_id = models.CharField(primary_key=True, max_length=20) + liveroom = models.ForeignKey('LiveroomInfo', models.DO_NOTHING) + eid = models.ForeignKey('ZbInfo', models.DO_NOTHING, db_column='eid') + live_starttime = models.DateTimeField(blank=True, null=True) + live_endtime = models.DateTimeField(blank=True, null=True) + + class Meta: + managed = False + db_table = 'live_record' + + +class LiveroomInfo(models.Model): + liveroom_id = models.CharField(primary_key=True, max_length=10) + liveroom_status = models.IntegerField(blank=True, null=True) + + class Meta: + managed = False + db_table = 'liveroom_info' + + +class LogisticsInfo(models.Model): + logi_id = models.CharField(max_length=10, unique=True) + sup = models.OneToOneField('ProcureOrder', models.DO_NOTHING, primary_key=True) # The composite primary key (sup_id, logi_id, procure_id) found, that is not supported. The first column is selected. + procure = models.ForeignKey('ProcureOrder', models.DO_NOTHING, to_field='procure_id', related_name='logisticsinfo_procure_set', unique=True) + start_time = models.DateTimeField() + logi_status = models.CharField(max_length=10) + arrival_time = models.DateTimeField(blank=True, null=True) + + class Meta: + managed = False + db_table = 'logistics_info' + unique_together = (('sup', 'logi_id', 'procure'),) + + +class OrderDetails(models.Model): + order_id = models.CharField(primary_key=True, max_length=25) # The composite primary key (order_id, goods_id) found, that is not supported. The first column is selected. + goods = models.ForeignKey(GoodsInfo, models.DO_NOTHING) + goods_num = models.IntegerField(blank=True, null=True) + + class Meta: + managed = False + db_table = 'order_details' + unique_together = (('order_id', 'goods'),) + + +class OrderInfo(models.Model): + order_id = models.CharField(primary_key=True, max_length=25) + live_record = models.ForeignKey(LiveRecord, models.DO_NOTHING) + cid = models.CharField(max_length=20) + eid = models.ForeignKey('SalesInfo', models.DO_NOTHING, db_column='eid') + order_time = models.DateTimeField(blank=True, null=True) + address = models.CharField(max_length=100, blank=True, null=True) + sum_price = models.FloatField(blank=True, null=True) + process_status = models.CharField(max_length=10, blank=True, null=True) + + class Meta: + managed = False + db_table = 'order_info' + + +class ProcureAdmin(models.Model): + eid = models.OneToOneField(EmployeeInfo, models.DO_NOTHING, db_column='eid', primary_key=True) + pro_name = models.CharField(max_length=10, blank=True, null=True) + + class Meta: + managed = False + db_table = 'procure_admin' + + +class ProcureOrder(models.Model): + sup = models.OneToOneField('SupplyInfo', models.DO_NOTHING, primary_key=True) # The composite primary key (sup_id, procure_id) found, that is not supported. The first column is selected. + procure = models.ForeignKey('ProcurePlan', models.DO_NOTHING, unique=True) + procure_price = models.FloatField() + procure_num = models.IntegerField() + + class Meta: + managed = False + db_table = 'procure_order' + unique_together = (('sup', 'procure'),) + + +class ProcurePlan(models.Model): + procure = models.OneToOneField('ReplenishRequest', models.DO_NOTHING, primary_key=True) + check_status = models.CharField(max_length=8) + project_intro = models.CharField(max_length=1024, blank=True, null=True) + procure_rule = models.CharField(max_length=1024, blank=True, null=True) + procure_comtent = models.CharField(max_length=1024, blank=True, null=True) + + class Meta: + managed = False + db_table = 'procure_plan' + + +class QualityInfo(models.Model): + sup = models.OneToOneField(LogisticsInfo, models.DO_NOTHING, primary_key=True) # The composite primary key (sup_id, logi_id, procure_id) found, that is not supported. The first column is selected. + logi = models.ForeignKey(LogisticsInfo, models.DO_NOTHING, to_field='logi_id', related_name='qualityinfo_logi_set') + procure = models.ForeignKey(LogisticsInfo, models.DO_NOTHING, to_field='procure_id', related_name='qualityinfo_procure_set') + quality_status = models.CharField(max_length=10) + quality_result = models.CharField(max_length=10) + details_info = models.CharField(max_length=1024, blank=True, null=True) + + class Meta: + managed = False + db_table = 'quality_info' + unique_together = (('sup', 'logi', 'procure'),) + + +class Receivables(models.Model): + recv_id = models.CharField(primary_key=True, max_length=20) + order = models.ForeignKey(OrderInfo, models.DO_NOTHING) + invoice_id = models.CharField(max_length=20, blank=True, null=True) + + class Meta: + managed = False + db_table = 'receivables' + + +class ReplenishRequest(models.Model): + request_num = models.IntegerField() + request_time = models.DateTimeField() + procure_id = models.CharField(primary_key=True, max_length=10) + eid = models.ForeignKey(ProcureAdmin, models.DO_NOTHING, db_column='eid') + goods = models.ForeignKey('StockInfo', models.DO_NOTHING, blank=True, null=True) + + class Meta: + managed = False + db_table = 'replenish_request' + + +class ReturnInfo(models.Model): + return_id = models.CharField(primary_key=True, max_length=20) + order = models.ForeignKey(OrderInfo, models.DO_NOTHING) + apply_time = models.DateTimeField(blank=True, null=True) + process_time = models.DateTimeField(blank=True, null=True) + process_way = models.CharField(max_length=20, blank=True, null=True) + retrun_status = models.CharField(max_length=20, blank=True, null=True) + + class Meta: + managed = False + db_table = 'return_info' + + +class SalesIndex(models.Model): + goods = models.OneToOneField(GoodsInfo, models.DO_NOTHING, primary_key=True) # The composite primary key (goods_id, index_month) found, that is not supported. The first column is selected. + profit_rate = models.FloatField(blank=True, null=True) + sales_num = models.IntegerField(blank=True, null=True) + return_rate = models.FloatField(blank=True, null=True) + kpi_rate = models.FloatField(blank=True, null=True) + index_month = models.DateTimeField() + + class Meta: + managed = False + db_table = 'sales_index' + unique_together = (('goods', 'index_month'),) + + +class SalesInfo(models.Model): + eid = models.OneToOneField(EmployeeInfo, models.DO_NOTHING, db_column='eid', primary_key=True) + sales_name = models.CharField(max_length=10, blank=True, null=True) + sales_duty = models.CharField(max_length=20, blank=True, null=True) + login_status = models.IntegerField(blank=True, null=True) + salary = models.FloatField(blank=True, null=True) + + class Meta: + managed = False + db_table = 'sales_info' + + +class SalesPerformance(models.Model): + sales_performance = models.IntegerField(blank=True, null=True) + performance_rank = models.IntegerField(blank=True, null=True) + performance_month = models.DateTimeField(primary_key=True) # The composite primary key (performance_month, eid) found, that is not supported. The first column is selected. + eid = models.ForeignKey(EmployeeInfo, models.DO_NOTHING, db_column='eid') + + class Meta: + managed = False + db_table = 'sales_performance' + unique_together = (('performance_month', 'eid'),) + + +class StockAdmin(models.Model): + eid = models.OneToOneField(EmployeeInfo, models.DO_NOTHING, db_column='eid', primary_key=True) + st_name = models.CharField(max_length=10, blank=True, null=True) + + class Meta: + managed = False + db_table = 'stock_admin' + + +class StockInfo(models.Model): + goods = models.OneToOneField(GoodsInfo, models.DO_NOTHING, primary_key=True) + goods_details = models.CharField(max_length=1024, blank=True, null=True) + stock_num = models.IntegerField() + + class Meta: + managed = False + db_table = 'stock_info' + + +class StockOut(models.Model): + goods = models.OneToOneField(StockInfo, models.DO_NOTHING, primary_key=True) + out_time = models.DateTimeField() + out_num = models.IntegerField() + + class Meta: + managed = False + db_table = 'stock_out' + + +class SupplyInfo(models.Model): + sup_id = models.CharField(primary_key=True, max_length=10) + sup_name = models.CharField(max_length=20) + sup_contact = models.CharField(max_length=15) + sup_serve = models.CharField(max_length=1024) + sup_level = models.CharField(max_length=10) + + class Meta: + managed = False + db_table = 'supply_info' + + +class ZbInfo(models.Model): + eid = models.OneToOneField(EmployeeInfo, models.DO_NOTHING, db_column='eid', primary_key=True) + zbname = models.CharField(max_length=10, blank=True, null=True) + zblevel = models.CharField(max_length=1024, blank=True, null=True) + login_status = models.IntegerField(blank=True, null=True) + + class Meta: + managed = False + db_table = 'zb_info' diff --git a/system/sales/urls.py b/system/sales/urls.py index c2805f93ca55909c0410bc25966af845e15240c4..7f3ad81b20cec26ad55f77d5064be850bb52f301 100644 --- a/system/sales/urls.py +++ b/system/sales/urls.py @@ -6,6 +6,11 @@ app_name='sales'#需要添加app名称,不然include无法找到该model,在ht urlpatterns = [ # 主页,用来显示类别等其他数据 + path('', views.sale_index, name='sale_index'), path('order', views.sale_order, name='sale_order'), + path('order_p', views.order_process, name='next_order'), + path('out', views.deliver_process, name='delivery'), + path('inc', views.income_process, name="income"), + path('move', views.sales_movement, name="movement"), ] diff --git a/system/sales/views.py b/system/sales/views.py index 5bde43ec61f86918dea0eb28e2cce55479be7799..1cb609fda3223b6bddfab807c790b91e23f9ad9e 100644 --- a/system/sales/views.py +++ b/system/sales/views.py @@ -1,8 +1,100 @@ from django.shortcuts import render - +import datetime +from pyecharts.charts import Bar, Page +from pyecharts.globals import ThemeType +from pyecharts import options as opt +from sales import models +from django.http import HttpResponse # Create your views here. -from django.http import HttpResponse + +def sale_index(request): + info = models.OrderInfo.objects.filter(eid='SA42376', process_status='未处理') + if info.exists(): + return render(request, '../templates/Sales/index.html', {'order': info}) + else: + return render(request, '../templates/Sales/index.html') + def sale_order(request): - return render(request, '../templates/Sales/order-page.html') \ No newline at end of file + info = models.OrderInfo.objects.filter(eid='SA42376', process_status='未处理') + if info.exists(): + order = info[0] + goods = models.OrderDetails.objects.filter(order_id=order.order_id) + if goods.exists(): + return render(request, '../templates/Sales/order-page.html', + {'order': order, 'goods': goods}) + else: + return render(request, '../templates/Sales/order-page.html') + + +def order_process(request): + if request.method == "POST": + order_id = request.POST["order_id"] + order_number = request.POST["TotalSum"] + models.OrderInfo.objects.filter(order_id=order_id).update(process_status="已处理") + # order.process_status = "已处理" + # order.save() + if float(order_number) < 0: + # 退货处理订单,规定其总价为负数。 + models.ReturnInfo.objects.create(return_id=f"RET+{order_id}", order=order_id, + apply_time=models.OrderInfo.objects.filter(order_id=order_id).order_time, + process_time=datetime.datetime.now(), + process_way="退货", retrun_status="已处理") + return sale_order(request) + else: + return sale_order(request) + + +def deliver_process(request): + deliver_list = models.OrderInfo.objects.filter(eid='SA42376', process_status='已处理') + if deliver_list.exists(): + goods_list = dict() + for order in deliver_list: + goods = models.OrderDetails.objects.filter(order_id=order.order_id) + for good in goods: + goods_list[good.goods] = goods_list.get(good.goods, 0) + good.goods_num + deliver_list.update(process_status="已发货") + for good in goods_list.keys(): + models.StockOut.objects.create(goods=models.StockInfo.objects.get(goods=good), + out_time=datetime.datetime.now(), out_num=goods_list[good]) + return sale_index(request) + + +def income_process(request): + income_list = models.OrderInfo.objects.filter(eid='SA42376', process_status='已发货') + if income_list.exists(): + # 由于没有实现财务相关内容,此功能仅做保留 + income_list.update(process_status="已结算") + return sale_index(request) + else: + return sale_index(request) + + +def sales_movement(request): + goods_list = list() + goods_number = list() + goods_sale_sum = list() + for item in models.GoodsInfo.objects.all(): + goods_list.append(item.goods_name) + tot_num_for_this_id = 0 + for order in models.OrderDetails.objects.filter(goods=item.goods_id): + tot_num_for_this_id += order.goods_num + goods_number.append(tot_num_for_this_id) + goods_sale_sum.append(tot_num_for_this_id * item.gprice) + bar_sum = Bar(init_opts=opt.InitOpts(theme=ThemeType.VINTAGE, width="1200px", height="600px")) + bar_sum.add_xaxis(goods_list) + bar_sum.add_yaxis("销售额", goods_sale_sum) + bar_sum.reversal_axis() + bar_sum.set_series_opts(label_opts=opt.LabelOpts(position="right")) + bar_sum.set_global_opts(title_opts=opt.TitleOpts(title="销售额对比")) + + bar_qtt = Bar(init_opts=opt.InitOpts(theme=ThemeType.VINTAGE, width="1200px", height="600px")) + bar_qtt.add_xaxis(goods_list) + bar_qtt.add_yaxis("销售量", goods_number) + bar_qtt.reversal_axis() + bar_qtt.set_series_opts(label_opts=opt.LabelOpts(position="right")) + bar_qtt.set_global_opts(title_opts=opt.TitleOpts(title="销售量对比")) + page = Page().add(bar_qtt).add(bar_sum) + page.render("Django_structure/system/templates/Pye_chart/sales_index_movement.html") + return render(request, "../templates/pye_chart/sales_index_movement.html") diff --git a/system/templates/Pye_chart/sales_index_movement.html b/system/templates/Pye_chart/sales_index_movement.html new file mode 100644 index 0000000000000000000000000000000000000000..048f7885ec58a20854b2cc6cd2bde86f627e4473 --- /dev/null +++ b/system/templates/Pye_chart/sales_index_movement.html @@ -0,0 +1,406 @@ + + +
+ +
-
+
-
+
-
+
diff --git a/system/templates/index.html b/system/templates/index.html
index 991135301c4bbb0979b127ce8731a2eb260204a0..782d2257b44eda0ad7f423d48996c8708adac907 100644
--- a/system/templates/index.html
+++ b/system/templates/index.html
@@ -59,7 +59,7 @@
-
+