|
@@ -44,4 +44,91 @@ class AgentCustomerView(View):
|
|
|
|
|
|
def validation(self, request_dict, request, operation):
|
|
|
AgentCustomerInfo.objects.filter()
|
|
|
- pass
|
|
|
+ language = request_dict.get('language', 'en')
|
|
|
+ response = ResponseObject(language, 'pc')
|
|
|
+ if operation == 'getUnicomAndIcloud':
|
|
|
+ return self.get_unicom_and_icloud(response)
|
|
|
+ else:
|
|
|
+ return response.json(444, 'operation')
|
|
|
+
|
|
|
+ def get_unicom_and_icloud(self, response):
|
|
|
+ try:
|
|
|
+ # 云存储套餐查询,只包括is_show=1的记录
|
|
|
+ store_meal_qs = Store_Meal.objects.filter(is_show=1).values(
|
|
|
+ 'id',
|
|
|
+ 'bucket__bucket',
|
|
|
+ 'day',
|
|
|
+ 'expire',
|
|
|
+ 'commodity_type',
|
|
|
+ 'commodity_code',
|
|
|
+ 'is_discounts',
|
|
|
+ 'discount_price',
|
|
|
+ 'virtual_price',
|
|
|
+ 'price',
|
|
|
+ 'currency',
|
|
|
+ 'symbol',
|
|
|
+ 'is_show',
|
|
|
+ 'is_ai',
|
|
|
+ 'pixel_level',
|
|
|
+ 'add_time',
|
|
|
+ 'update_time'
|
|
|
+ )
|
|
|
+ store_meal_list = [{
|
|
|
+ 'storeMealID': store_meal['id'],
|
|
|
+ 'bucket': store_meal['bucket__bucket'],
|
|
|
+ 'day': store_meal['day'],
|
|
|
+ 'expire': store_meal['expire'],
|
|
|
+ 'commodity_type': store_meal['commodity_type'],
|
|
|
+ 'pay_type': [pay_type['id'] for pay_type in
|
|
|
+ Store_Meal.objects.get(id=store_meal['id']).pay_type.values('id')],
|
|
|
+ 'commodity_code': store_meal['commodity_code'],
|
|
|
+ 'is_discounts': store_meal['is_discounts'],
|
|
|
+ 'discount_price': store_meal['discount_price'],
|
|
|
+ 'virtual_price': store_meal['virtual_price'],
|
|
|
+ 'price': store_meal['price'],
|
|
|
+ 'currency': store_meal['currency'],
|
|
|
+ 'symbol': store_meal['symbol'],
|
|
|
+ 'is_show': store_meal['is_show'],
|
|
|
+ 'is_ai': store_meal['is_ai'],
|
|
|
+ 'pixel_level': store_meal['pixel_level'],
|
|
|
+ 'addTime': store_meal['add_time'].strftime("%Y-%m-%d %H:%M:%S"),
|
|
|
+ 'updTime': store_meal['update_time'].strftime("%Y-%m-%d %H:%M:%S"),
|
|
|
+ } for store_meal in store_meal_qs]
|
|
|
+
|
|
|
+ # 联通套餐查询,只包括is_show=1的记录
|
|
|
+ combo_qs = UnicomCombo.objects.filter(is_show=1, is_del=False).values(
|
|
|
+ 'id', 'status', 'combo_name',
|
|
|
+ 'flow_total', 'combo_type',
|
|
|
+ 'expiration_days',
|
|
|
+ 'expiration_type', 'price', 'is_unlimited',
|
|
|
+ 'updated_time', 'created_time',
|
|
|
+ 'remark', 'is_show', 'sort', 'virtual_price'
|
|
|
+ )
|
|
|
+ combo_list = [{
|
|
|
+ 'id': item['id'],
|
|
|
+ 'status': item['status'],
|
|
|
+ 'comboType': item['combo_type'],
|
|
|
+ 'comboName': item['combo_name'],
|
|
|
+ 'flowTotal': item['flow_total'],
|
|
|
+ 'expirationDays': item['expiration_days'],
|
|
|
+ 'expirationType': item['expiration_type'],
|
|
|
+ 'price': item['price'],
|
|
|
+ 'sort': item['sort'],
|
|
|
+ 'isUnlimited': item['is_unlimited'],
|
|
|
+ 'updatedTime': datetime.utcfromtimestamp(item['updated_time']).strftime("%Y-%m-%d %H:%M:%S"),
|
|
|
+ 'createdTime': datetime.utcfromtimestamp(item['created_time']).strftime("%Y-%m-%d %H:%M:%S"),
|
|
|
+ 'remark': item['remark'],
|
|
|
+ 'isShow': item['is_show'],
|
|
|
+ 'payTypes': [pay_type['id'] for pay_type in
|
|
|
+ UnicomCombo.objects.get(id=item['id']).pay_type.values('id')],
|
|
|
+ 'virtualPrice': item['virtual_price']
|
|
|
+ } for item in combo_qs]
|
|
|
+
|
|
|
+ # 合并结果并返回
|
|
|
+ return response.json(0, {
|
|
|
+ 'storeMealList': store_meal_list,
|
|
|
+ 'comboList': combo_list,
|
|
|
+ })
|
|
|
+ except Exception as e:
|
|
|
+ print(e)
|
|
|
+ return response.json(500, 'error_line:{}, error_msg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
|