|
@@ -24,8 +24,8 @@ class CustomCustomerView(View):
|
|
|
def validation(self, request, request_dict, operation):
|
|
|
language = request_dict.get('language', 'en')
|
|
|
response = ResponseObject(language)
|
|
|
- if operation == 'getCustomCustomerList': # 查詢定制客户信息
|
|
|
- return self.get_custom_customer_list(request_dict, response)
|
|
|
+ if operation == 'getCustomCustomer': # APP查詢定制客户信息
|
|
|
+ return self.get_custom_customer(request_dict, response)
|
|
|
elif operation == 'addCustomCustomer': # 添加定制客户信息接口
|
|
|
return self.add_custom_customer(request_dict, response)
|
|
|
elif operation == 'addCustomerDevice': # 定制客户设备扫码添加接口
|
|
@@ -36,51 +36,22 @@ class CustomCustomerView(View):
|
|
|
return response.json(414)
|
|
|
|
|
|
@staticmethod
|
|
|
- def get_custom_customer_list(request_dict, response):
|
|
|
+ def get_custom_customer(request_dict, response):
|
|
|
"""
|
|
|
- 查询定制客户信息
|
|
|
+ APP查询定制客户信息
|
|
|
:param request_dict:
|
|
|
:param response:
|
|
|
:return:
|
|
|
"""
|
|
|
order_number = request_dict.get('orderNumber', None)
|
|
|
- name = request_dict.get('name', None)
|
|
|
- email = request_dict.get('email', None)
|
|
|
- page = request_dict.get('pageNo', 1)
|
|
|
- page_size = request_dict.get('pageSize', 10)
|
|
|
+ if not order_number:
|
|
|
+ return response.json(444)
|
|
|
try:
|
|
|
- # 初始化查询集
|
|
|
- custom_customer_qs = CustomCustomerOrderInfo.objects.all()
|
|
|
-
|
|
|
- if order_number:
|
|
|
- custom_customer_qs = custom_customer_qs.filter(order_number__icontains=order_number)
|
|
|
- if name:
|
|
|
- custom_customer_qs = custom_customer_qs.filter(name__icontains=name)
|
|
|
- if email:
|
|
|
- custom_customer_qs = custom_customer_qs.filter(email__icontains=email)
|
|
|
-
|
|
|
- paginator = Paginator(custom_customer_qs.order_by('id'), page_size)
|
|
|
- customers = paginator.page(page)
|
|
|
-
|
|
|
- customer_list = []
|
|
|
- for customer in customers.object_list:
|
|
|
- customer_list.append({
|
|
|
- 'cId': customer.id,
|
|
|
- 'orderNumber': customer.order_number,
|
|
|
- 'name': customer.name,
|
|
|
- 'email': customer.email,
|
|
|
- 'countryId': customer.country_id,
|
|
|
- 'quantity': customer.quantity,
|
|
|
- 'createdTime': customer.created_time,
|
|
|
- })
|
|
|
-
|
|
|
- # 返回分页结果
|
|
|
- data = {
|
|
|
- 'total': paginator.count,
|
|
|
- 'list': list(customer_list), # 当前页的记录列表
|
|
|
- }
|
|
|
-
|
|
|
- return response.json(0, data)
|
|
|
+ custom_customer = CustomCustomerOrderInfo.objects.filter(order_number=order_number).first()
|
|
|
+ if custom_customer:
|
|
|
+ return response.json(173)
|
|
|
+ custom_customer_data = {'cId': custom_customer.id}
|
|
|
+ return response.json(0, custom_customer_data)
|
|
|
except Exception as e:
|
|
|
return response.json(500, 'error_line:{}, error_msg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
|
|
|
|