def get(request): account_user_profile = account_models.UserProfile.objects.get( user_id=request.user.id, is_active=True) postage_configs = models.PostageConfig.objects.filter( owner_id=request.user.id, is_deleted=False).order_by('-id') postages = [] for postage_config in postage_configs: postages.append({ "postageId": postage_config.id, "postageName": postage_config.name, "hasSpecialConfig": postage_config.is_enable_special_config, "hasFreeConfig": postage_config.is_enable_free_config, "isUsed": postage_config.is_used }) c = RequestContext( request, { 'first_nav_name': FIRST_NAV, 'second_navs': nav.get_second_navs(), 'second_nav_name': SECOND_NAV, 'postages': json.dumps(postages), 'service_tel': account_user_profile.customer_service_tel, 'service_qq_first': account_user_profile.customer_service_qq_first, 'service_qq_second': account_user_profile.customer_service_qq_second }) return render_to_response('postage_list/postage_list.html', c)
def get(request): #获取用户数据 user_id = request.GET.get('id', None) frontend_data = FrontEndData() if user_id: user = auth_models.User.objects.get(id=user_id) user_profile = UserProfile.objects.get(user_id=user.id) status = user_profile.status user_data = { 'id': user.id, 'name': user.username, 'displayName': user.first_name, 'status': str(status), 'selfUserName': user_profile.woid } frontend_data.add('user', user_data) else: frontend_data.add('user', None) c = RequestContext(request, { 'first_nav_name': FIRST_NAV, 'second_navs': nav.get_second_navs(), 'second_nav_name': SECOND_NAV, 'frontend_data': frontend_data }) return render_to_response('config/user.html', c)
def get(request): c = RequestContext( request, { 'first_nav_name': FIRST_NAV, 'second_navs': nav.get_second_navs(), 'second_nav_name': SECOND_NAV }) return render_to_response('shipper_manage/shipper_manage.html', c)
def get(request): """ """ c = RequestContext(request, { 'first_nav_name': FIRST_NAV, 'second_navs': nav.get_second_navs(), 'second_nav_name': SECOND_NAV }) return render_to_response('product_limit_zone/product_limit_zone.html', c)
def get(request): """ 响应GET """ c = RequestContext(request, { 'first_nav_name': FIRST_NAV, 'second_navs': nav.get_second_navs(), 'second_nav_name': SECOND_NAV }) return render_to_response('manager/account_no_product_list.html', c)
def get(request): """ 显示商品列表 """ c = RequestContext( request, { 'first_nav_name': FIRST_NAV, 'second_navs': nav.get_second_navs(), 'second_nav_name': SECOND_NAV }) return render_to_response('product_catalog/product_catalogs.html', c)
def get(request): """ 显示入驻申请列表 """ c = RequestContext(request, { 'first_nav_name': FIRST_NAV, 'second_navs': nav.get_second_navs(), 'second_nav_name': SECOND_NAV }) return render_to_response('business/business_manager.html', c)
def get(request): """ 显示商品列表 """ c = RequestContext( request, { 'first_nav_name': FIRST_NAV, 'second_navs': nav.get_second_navs(), 'second_nav_name': SECOND_NAV }) return render_to_response('message_list.html', c)
def get(request): """ 显示标签列表 """ c = RequestContext(request, { 'first_nav_name': FIRST_NAV, 'second_navs': nav.get_second_navs(), 'second_nav_name': SECOND_NAV, }) return render_to_response('label/label_manager.html', c)
def get(request): """ 响应GET """ c = RequestContext(request, { 'first_nav_name': FIRST_NAV, 'second_navs': nav.get_second_navs(), 'second_nav_name': SECOND_NAV }) return render_to_response('outline/datas.html', c)
def get(request): """ 响应GET """ c = RequestContext( request, { 'first_nav_name': FIRST_NAV, 'second_navs': nav.get_second_navs(), 'second_nav_name': SECOND_NAV }) return render_to_response('interface/supplier_api.html', c)
def get(request): """ 响应GET """ c = RequestContext( request, { 'first_nav_name': FIRST_NAV, 'second_navs': nav.get_second_navs(), 'second_nav_name': SECOND_NAV }) return render_to_response('application_audit/application_audit.html', c)
def get(request): """ 显示商品列表 """ c = RequestContext(request, { 'first_nav_name': FIRST_NAV, 'second_navs': nav.get_second_navs(request), 'second_nav_name': SECOND_NAV, 'first_catalog_id': request.GET.get('first_catalog_id', ''), 'second_catalog_id': request.GET.get('second_catalog_id', '') }) return render_to_response('product/product_relation.html', c)
def get(request): """ 显示商品列表 """ user_id = request.GET.get('user_id', '') c = RequestContext( request, { 'first_nav_name': FIRST_NAV, 'second_navs': nav.get_second_navs(), 'second_nav_name': SECOND_NAV, 'user_id': user_id }) return render_to_response('customer/statistics_report.html', c)
def get(request): user_profile = account_models.UserProfile.objects.filter( user_id=request.user.id) pre_sale_tel = user_profile[0].pre_sale_tel after_sale_tel = user_profile[0].after_sale_tel c = RequestContext( request, { 'first_nav_name': FIRST_NAV, 'second_navs': nav.get_second_navs(), 'second_nav_name': SECOND_NAV, 'pre_sale_tel': str(pre_sale_tel) if pre_sale_tel else '-1', 'after_sale_tel': str(after_sale_tel) if after_sale_tel else '-1' }) return render_to_response('freight_service/service.html', c)
def get(request): """ 响应GET """ jsons = {'items': []} rows = get_all_synced_self_shops(request, is_for_search=True)['rows'] jsons['items'].append(('typeOptions', json.dumps(rows))) c = RequestContext( request, { 'first_nav_name': FIRST_NAV, 'second_navs': nav.get_second_navs(), 'second_nav_name': SECOND_NAV, 'jsons': jsons }) return render_to_response('order/yunying_orders_list.html', c)
def get(request): #获取业务数据 order_id = request.GET.get('id', 0) jsons = {'items':[]} orders = getOrderDetail(order_id, request) order_datas = { 'orders': orders } jsons['items'].append(('orderDatas', json.dumps(order_datas))) c = RequestContext(request, { 'jsons': jsons, 'first_nav_name': FIRST_NAV, 'second_navs': nav.get_second_navs(), 'second_nav_name': SECOND_NAV, 'order_id': order_id }) return render_to_response('order/customer_order_detail.html', c)
def get(request): """ 显示商品列表 """ account_user_profile = account_models.UserProfile.objects.get( user_id=request.user.id, is_active=True) c = RequestContext( request, { 'first_nav_name': FIRST_NAV, 'second_navs': nav.get_second_navs(), 'second_nav_name': SECOND_NAV, 'service_tel': account_user_profile.customer_service_tel, 'service_qq_first': account_user_profile.customer_service_qq_first, 'service_qq_second': account_user_profile.customer_service_qq_second }) return render_to_response('product_limit_zone/product_limit_zone.html', c)
def get(request): """ 用户提交信息页面 """ customer_id = request.GET.get('customer_id', -1) frontend_data = FrontEndData() if customer_id != -1: customer_message = models.CustomerMessage.objects.get( user=request.user, id=customer_id) customer_data = { 'id': customer_message.id, 'name': customer_message.name, 'mobileNumber': customer_message.mobile_number, 'email': customer_message.email, 'serverIp': customer_message.server_ip, 'interfaceUrl': customer_message.interface_url, 'serverIps': [] } #更多服务器ip customer_server_ips = models.CustomerServerIps.objects.filter( customer_id=customer_message) for server_ip in customer_server_ips: customer_data['serverIps'].append({'ipName': server_ip.name}) frontend_data.add('customer', customer_data) else: frontend_data.add('customer', None) c = RequestContext( request, { 'first_nav_name': FIRST_NAV, 'second_navs': nav.get_second_navs(), 'second_nav_name': SECOND_NAV, 'frontend_data': frontend_data }) return render_to_response('customer/messages.html', c)
def get(request): """ 响应GET """ jsons = {'items':[]} account_user_profile = account_models.UserProfile.objects.get(user_id=request.user.id, is_active=True) express_bill_accounts = postage_models.ExpressBillAccounts.objects.filter(owner=request.user, is_deleted=False) shipper_messages = postage_models.ShipperMessages.objects.filter(owner=request.user, is_deleted=False, is_active=True) options_for_express = [] options_for_express.append({ 'text': u'请选择', 'value': -1 }) for express_bill_account in express_bill_accounts: options_for_express.append({ 'text': options2text[express_bill_account.express_name], 'value': express_bill_account.id, }) hasShipper = { 'hasShipper': True if shipper_messages else False } contact ={ 'service_tel': account_user_profile.customer_service_tel, 'service_qq_first': account_user_profile.customer_service_qq_first, 'service_qq_second': account_user_profile.customer_service_qq_second } jsons['items'].append(('optionsForExpress', json.dumps(options_for_express))) jsons['items'].append(('hasShipper', json.dumps(hasShipper))) jsons['items'].append(('customerServiceContact', json.dumps(contact))) c = RequestContext(request, { 'jsons': jsons, 'first_nav_name': FIRST_NAV, 'second_navs': nav.get_second_navs(), 'second_nav_name': SECOND_NAV }) return render_to_response('order/customer_orders_list.html', c)
def get(request): """ 显示商品列表 """ user_has_products = models.Product.objects.filter( owner_id=request.user.id, is_deleted=False).count() account_user_profile = UserProfile.objects.get(user_id=request.user.id, is_active=True) user_profile = request.user.get_profile() if user_profile.max_product <= user_has_products: can_created = False else: can_created = True c = RequestContext( request, { 'first_nav_name': FIRST_NAV, 'second_navs': nav.get_second_navs(request), 'second_nav_name': SECOND_NAV, 'user_has_products': user_has_products, 'can_created': can_created, 'purchaseMethod': user_profile.purchase_method, 'service_tel': account_user_profile.customer_service_tel, 'service_qq_first': account_user_profile.customer_service_qq_first, 'service_qq_second': account_user_profile.customer_service_qq_second }) return render_to_response('product/product_list.html', c)
def get(request): """ 显示商品列表 """ user_has_freight = models.UserHasFreight.objects.filter( user_id=request.user.id) free_freight_money = '' if not user_has_freight else user_has_freight[ 0].free_freight_money need_freight_money = '' if not user_has_freight else user_has_freight[ 0].need_freight_money c = RequestContext( request, { 'first_nav_name': FIRST_NAV, 'second_navs': nav.get_second_navs(), 'second_nav_name': SECOND_NAV, 'free_freight_money': free_freight_money if free_freight_money else '-1', 'need_freight_money': need_freight_money if need_freight_money else '-1' }) return render_to_response('freight_service/freight.html', c)
def get(request): """ 响应GET """ business_id = request.GET.get('id', None) jsons = {'items': []} apply_catalogs = [] upload_business_qualifications = [] if business_id: business = models.Business.objects.get(id=business_id) #得到所属的二级分类数据 product_catalog_ids = business.product_catalog_ids.split('_') for product_catalog_id in product_catalog_ids: apply_catalogs.append(product_catalog_id) #得到商家上传的特殊资质 all_qualifications = product_catalog_models.ProductCatalogQualification.objects.filter( catalog_id__in=product_catalog_ids) qualification_id2name = dict( (qualification.id, qualification.name) for qualification in all_qualifications) qualification_id2catalog_id = dict( (qualification.id, qualification.catalog_id) for qualification in all_qualifications) qualifications = models.BusinessQualification.objects.filter( business_id=business_id) for qualification in qualifications: upload_business_qualifications.append({ 'belong_catalog_id': qualification_id2catalog_id[ qualification.qualification_id], 'qualification_id': qualification.qualification_id, 'qualification_name': qualification_id2name[qualification.qualification_id], 'img': [{ 'id': 1, 'path': qualification.path }], 'qualification_time': qualification.qualification_time.strftime("%Y-%m-%d %H:%M") if qualification.qualification_time else '' }) business_data = { 'id': business.id, 'company_type': business.company_type, 'company_name': business.company_name, 'company_money': business.company_money, 'legal_representative': business.legal_representative, 'contacter': business.contacter, 'phone': business.phone, 'e_mail': business.e_mail, 'we_chat_and_qq': business.we_chat_and_qq, 'company_location': business.company_location, 'address': business.address, 'business_license': [{ 'id': 1, 'path': business.business_license }], 'business_license_time': business.business_license_time.strftime("%Y-%m-%d %H:%M") if business.business_license_time else '', 'tax_registration_certificate': [{ 'id': 1, 'path': business.tax_registration_certificate }], 'tax_registration_certificate_time': business.tax_registration_certificate_time.strftime( "%Y-%m-%d %H:%M") if business.tax_registration_certificate_time else '', 'organization_code_certificate': [{ 'id': 1, 'path': business.organization_code_certificate }], 'organization_code_certificate_time': business.organization_code_certificate_time.strftime( "%Y-%m-%d %H:%M") if business.organization_code_certificate_time else '', 'account_opening_license': [{ 'id': 1, 'path': business.account_opening_license }], 'account_opening_license_time': business.account_opening_license_time.strftime( "%Y-%m-%d %H:%M") if business.account_opening_license_time else '', 'apply_catalogs': apply_catalogs, 'uploadBusinessQualifications': upload_business_qualifications } jsons['items'].append(('business_data', json.dumps(business_data))) c = RequestContext( request, { 'first_nav_name': FIRST_NAV, 'second_navs': nav.get_second_navs(), 'second_nav_name': SECOND_NAV, 'jsons': jsons }) return render_to_response('business/business_detail.html', c)
def get(request): postage_id = request.GET.get('postage_id', None) #获取省份 provinces = product_models.Province.objects.all() province_id2name = { province.id: province.name for province in provinces } jsons = {'items': []} if postage_id: postages = { 'postage_id': postage_id, 'postage_name': '', 'default_postages': [], 'special_postages': [], 'free_postages': [] } #默认运费配置 postage_configs = models.PostageConfig.objects.filter( id=postage_id, is_deleted=False) for postage_config in postage_configs: postages['postage_name'] = postage_config.name postages['default_postages'].append({ 'firstWeight': '%s' % postage_config.first_weight, 'firstWeightPrice': '%s' % postage_config.first_weight_price, 'addedWeight': '%s' % postage_config.added_weight, 'addedWeightPrice': '%s' % postage_config.added_weight_price, }) #特殊地区运费配置 postage_config_specials = models.SpecialPostageConfig.objects.filter( postage_config_id=postage_id) for postage_config_special in postage_config_specials: destinations = postage_config_special.destination.split(',') postages['special_postages'].append({ 'firstWeight': '%s' % postage_config_special.first_weight, 'firstWeightPrice': '%s' % postage_config_special.first_weight_price, 'addedWeight': '%s' % postage_config_special.added_weight, 'addedWeightPrice': '%s' % postage_config_special.added_weight_price, 'selectedIds': destinations }) #包邮配置 free_postage_configs = models.FreePostageConfig.objects.filter( postage_config_id=postage_id) for free_postage_config in free_postage_configs: destinations = free_postage_config.destination.split(',') postages['free_postages'].append({ 'condition': free_postage_config.condition, 'conditionValue': '%s' % free_postage_config.condition_value, 'selectedIds': destinations }) jsons['items'].append(('postages', json.dumps(postages))) else: jsons['items'].append(('postages', json.dumps(None))) provinceId2name = {'province_id2name': province_id2name} jsons['items'].append(('provinceId2name', json.dumps(provinceId2name))) c = RequestContext( request, { 'jsons': jsons, 'first_nav_name': FIRST_NAV, 'second_navs': nav.get_second_navs(), 'second_nav_name': SECOND_NAV }) return render_to_response('new_config/new_config.html', c)
def get(request): #获取业务数据 product_id = request.GET.get('id', None) jsons = {'items': []} if product_id: product = models.Product.objects.get(owner=request.user, id=product_id) product_data = { 'id': product.id, 'name': product.name, 'weight': product.weight, 'price': product.price, 'is_join_promotion': product.is_join_promotion, 'promotion_finish_date': product.promotion_finish_time.strftime('%Y-%m-%d %H:%M'), 'channels': product.channels, 'detail': string_util.raw_html(product.detail), 'models': [], 'images': [], 'documents': [], 'created_at': product.created_at.strftime('%Y-%m-%d %H:%M') } #获取商品规格 product_models = models.ProductModel.objects.filter( product_id=product_id) for product_model in product_models: product_data['models'].append({ 'id': product_model.id, 'name': product_model.name, 'stocks': product_model.stocks }) #获取商品图片 product_image_ids = [ product_image.image_id for product_image in models.ProductImage.objects.filter( product_id=product_id) ] for image in resource_models.Image.objects.filter( id__in=product_image_ids): product_data['images'].append({ 'id': image.id, 'path': image.path }) #获取商品文档 product_document_ids = [ product_document.document_id for product_document in models.ProductDocument.objects.filter( product_id=product_id) ] for document in resource_models.Document.objects.filter( id__in=product_document_ids): product_data['documents'].append({ 'id': document.id, 'type': document.type, 'name': document.filename, 'path': document.path }) jsons['items'].append(('product', json.dumps(product_data))) else: jsons['items'].append(('product', json.dumps(None))) c = RequestContext( request, { 'first_nav_name': FIRST_NAV, 'second_navs': nav.get_second_navs(), 'second_nav_name': SECOND_NAV, 'jsons': jsons }) return render_to_response('outline/data.html', c)
def get(request): """ 响应GET """ user_profile_id = request.GET.get('id', None) is_edit = False jsons = {'items' : []} if user_profile_id: user_profile = UserProfile.objects.get(id=user_profile_id) # 采购方式:零售价返点(团购扣点) group_points = AccountHasGroupPoint.objects.filter(user_id=user_profile.user_id) # 采购方式:首月55分成 rebate_proports = AccountHasRebateProport.objects.filter(user_id=user_profile.user_id) self_user_names = [] if group_points and user_profile.purchase_method == 2:#采购方式:零售价返点 for group_point in group_points: self_user_name = group_point.self_user_name self_user_names.append({ 'selfUserName': self_user_name, self_user_name+'_value': group_point.group_points }) rebates = [] if rebate_proports and user_profile.purchase_method == 3:#采购方式:首月55分成 for rebate_proport in rebate_proports: if rebate_proport.order_money_condition: rebates.append({ 'orderMoneyCondition': '%.0f' % rebate_proport.order_money_condition, 'rebateProportCondition': rebate_proport.rebate_proport_condition, 'defaultRebateProportCondition': rebate_proport.default_rebate_proport_condition, 'validateFromCondition': rebate_proport.valid_time_from.strftime("%Y-%m-%d %H:%M"), 'validateToCondition': rebate_proport.valid_time_to.strftime("%Y-%m-%d %H:%M") }) if user_profile.role == CUSTOMER: user_profile_data = { 'id': user_profile.id, 'name': user_profile.name, 'company_name': user_profile.company_name, 'company_type': user_profile.company_type if user_profile.company_type != '' else '[]', 'purchase_method': user_profile.purchase_method, 'points': user_profile.points, 'contacter': user_profile.contacter, 'phone': user_profile.phone, 'valid_time_from': '' if not user_profile.valid_time_from else user_profile.valid_time_from.strftime("%Y-%m-%d %H:%M"), 'valid_time_to': '' if not user_profile.valid_time_to else user_profile.valid_time_to.strftime("%Y-%m-%d %H:%M"), 'username': User.objects.get(id=user_profile.user_id).username, 'account_type': user_profile.role, 'note': user_profile.note, 'self_user_names': [] if not self_user_names else json.dumps(self_user_names), 'rebates': [] if not rebates else json.dumps(rebates), 'max_product': user_profile.max_product, 'settlement_period': user_profile.settlement_period, 'customerServiceTel': user_profile.customer_service_tel, 'customerServiceQQFirst': user_profile.customer_service_qq_first, 'customerServiceQQSecond': user_profile.customer_service_qq_second } if rebate_proports and user_profile.purchase_method == 3:#采购方式:首月55分成 for rebate_proport in rebate_proports: if rebate_proport.order_money: user_profile_data['order_money'] = '%.0f' % rebate_proport.order_money user_profile_data['rebate_proport'] = rebate_proport.rebate_proport user_profile_data['default_rebate_proport'] = rebate_proport.default_rebate_proport if rebate_proports and user_profile.purchase_method == 4:#采购方式:首月55分成 for rebate_proport in rebate_proports: user_profile_data['rebate_proport'] = rebate_proport.rebate_proport user_profile_data['default_rebate_proport'] = rebate_proport.default_rebate_proport else: user_profile_data = { 'id': user_profile.id, 'name': user_profile.name, 'username': User.objects.get(id=user_profile.user_id).username, 'account_type': user_profile.role, 'note': user_profile.note } jsons['items'].append(('user_profile_data', json.dumps(user_profile_data))) is_edit = True else: jsons['items'].append(('user_profile_data', json.dumps(None))) c = RequestContext(request, { 'first_nav_name': FIRST_NAV, 'second_navs': nav.get_second_navs(), 'second_nav_name': SECOND_NAV, 'jsons': jsons, 'is_edit': is_edit }) return render_to_response('manager/account_create.html', c)
def get(request): """ 显示商品创建页面 """ #获取业务数据 product_id = request.GET.get('id', None) second_level_id = request.GET.get('second_level_id', 0) jsons = {'items': []} user_profile = UserProfile.objects.get(user_id=request.user.id) role = user_profile.role purchase_method = user_profile.purchase_method #采购方式 points = user_profile.points #零售价返点 product_has_model = 0 if product_id: product = models.Product.objects.get(id=product_id) product_models = models.ProductModel.objects.filter( product_id=product_id, is_deleted=False) product_has_model = 1 limit_clear_price = '' if product.limit_clear_price and product.limit_clear_price != -1: limit_clear_price = product.limit_clear_price # product_models = models.ProductModel.objects.filter(product_id=product_id,owner=request.user) product_model_ids = [ product_model.id for product_model in product_models ] property_values = models.ProductModelHasPropertyValue.objects.filter( model_id__in=product_model_ids) #获取规格值 value_ids = set([ str(property_value.property_value_id) for property_value in property_values ]) product_model_property_values = models.ProductModelPropertyValue.objects.filter( id__in=value_ids) model_values = get_product_model_property_values( product_model_property_values) #获取商品分类 product_catalog = catalog_models.ProductCatalog.objects.filter( id=product.catalog_id) first_level_name = '' second_level_name = '' if product_catalog: second_level_name = product_catalog[0].name first_level_name = catalog_models.ProductCatalog.objects.get( id=product_catalog[0].father_id).name product_data = { 'id': product.id, 'product_name': product.product_name, 'promotion_title': product.promotion_title, 'product_price': '%s' % product.product_price if product.product_price > 0 else '%s' % product.clear_price, 'clear_price': '%s' % product.clear_price, 'product_weight': '%s' % product.product_weight, 'product_store': product.product_store, 'has_limit_time': '%s' % (1 if product.has_limit_time else 0), 'valid_time_from': '' if not product.valid_time_from else product.valid_time_from.strftime("%Y-%m-%d %H:%M"), 'valid_time_to': '' if not product.valid_time_to else product.valid_time_to.strftime("%Y-%m-%d %H:%M"), 'limit_clear_price': '%s' % limit_clear_price, 'remark': string_util.raw_html(product.remark), 'has_product_model': '%s' % (1 if product.has_product_model else 0), 'model_values': json.dumps(model_values), 'images': [], 'catalog_name': '' if not first_level_name else ('%s--%s') % (first_level_name, second_level_name), 'second_catalog_id': product.catalog_id, 'value_ids': ','.join(value_ids) } #组织多规格数据 for product_model in product_models: model_Id = product_model.name product_data['product_price_' + model_Id] = '%s' % ('%.2f' % product_model.price) product_data['limit_clear_price_' + model_Id] = '%s' % ( '%.2f' % product_model.limit_clear_price) product_data['clear_price_' + model_Id] = '%s' % ('%.2f' % product_model.market_price) product_data['product_weight_' + model_Id] = '%s' % product_model.weight product_data['product_store_' + model_Id] = '%s' % product_model.stocks product_data['product_code_' + model_Id] = '%s' % product_model.user_code product_data[ 'valid_time_from_' + model_Id] = '%s' % product_model.valid_time_from.strftime( "%Y-%m-%d %H:%M" ) if product_model.valid_time_from else '' product_data[ 'valid_time_to_' + model_Id] = '%s' % product_model.valid_time_to.strftime( "%Y-%m-%d %H:%M" ) if product_model.valid_time_to else '' #获取商品图片 product_image_ids = [ product_image.image_id for product_image in models.ProductImage.objects.filter( product_id=product_id) ] for image in resource_models.Image.objects.filter( id__in=product_image_ids): product_data['images'].append({ 'id': image.id, 'path': image.path }) #修改的商品旧数据 old_product = models.OldProduct.objects.filter( product_id=product_id).order_by('-id') old_product = old_product[0] old_product_model_ids = [] if not old_product.product_model_ids else old_product.product_model_ids.split( ',') old_property_values = models.ProductModelHasPropertyValue.objects.filter( model_id__in=old_product_model_ids, is_deleted=True) #获取规格值 old_value_ids = set([ str(property_value.property_value_id) for property_value in old_property_values ]) old_product_model_property_values = models.ProductModelPropertyValue.objects.filter( id__in=old_value_ids) old_model_values = get_product_model_property_values( old_product_model_property_values) #获取商品分类 old_product_catalog = catalog_models.ProductCatalog.objects.filter( id=old_product.catalog_id) old_first_level_name = '' old_second_level_name = '' if old_product_catalog: old_second_level_name = old_product_catalog[0].name old_first_level_name = catalog_models.ProductCatalog.objects.get( id=old_product_catalog[0].father_id).name old_product_data = { 'old_product_name': old_product.product_name, 'old_promotion_title': old_product.promotion_title, 'old_product_price': '%s' % old_product.product_price, 'old_clear_price': '%s' % old_product.clear_price, 'old_product_weight': old_product.product_weight, 'old_product_store': old_product.product_store, 'old_remark': '' if not old_product.remark else string_util.raw_html( old_product.remark), 'old_has_product_model': '%s' % (-1 if old_product.has_product_model == -1 else old_product.has_product_model), 'old_models': json.dumps(old_model_values), 'old_images': [] if not old_product.images else json.loads(old_product.images), 'old_catalog_name': '' if not old_first_level_name else ('%s--%s') % (old_first_level_name, old_second_level_name), 'old_second_catalog_id': old_product.catalog_id, 'old_value_ids': ','.join(old_value_ids) } #组织多规格数据 for product_model in models.ProductModel.objects.filter( id__in=old_product_model_ids): model_Id = product_model.name old_product_data['old_product_price_' + model_Id] = '%s' % ('%.2f' % product_model.price) old_product_data['old_limit_clear_price_' + model_Id] = '%s' % ( '%.2f' % product_model.limit_clear_price) old_product_data[ 'old_clear_price_' + model_Id] = '%s' % ('%.2f' % product_model.market_price) old_product_data['old_product_weight_' + model_Id] = '%s' % product_model.weight old_product_data['old_product_store_' + model_Id] = '%s' % product_model.stocks old_product_data['old_product_code_' + model_Id] = '%s' % product_model.user_code old_product_data[ 'old_valid_time_from_' + model_Id] = '%s' % product_model.valid_time_from.strftime( "%Y-%m-%d %H:%M" ) if product_model.valid_time_from else '' old_product_data[ 'old_valid_time_to_' + model_Id] = '%s' % product_model.valid_time_to.strftime( "%Y-%m-%d %H:%M" ) if product_model.valid_time_to else '' product_data.update(old_product_data) jsons['items'].append(('product', json.dumps(product_data))) c = RequestContext( request, { 'first_nav_name': FIRST_NAV, 'second_navs': nav.get_second_navs(request), 'second_nav_name': SECOND_NAV, 'jsons': jsons, 'second_level_id': second_level_id, 'role': role, 'points': points, 'purchase_method': purchase_method, 'product_has_model': product_has_model, 'catalog_name': '' if not first_level_name else ('%s--%s') % (first_level_name, second_level_name) }) return render_to_response('product/product_contrast.html', c)
def get(request): """ 显示商品创建页面 """ #获取业务数据 product_id = request.GET.get('id', None) second_level_id = request.GET.get('second_level_id', 0) jsons = {'items': []} user_profile = UserProfile.objects.get(user_id=request.user.id) role = user_profile.role purchase_method = user_profile.purchase_method #采购方式 points = user_profile.points #零售价返点 product_has_model = 0 product_status_value = 0 postage_configs = postage_models.PostageConfig.objects.filter( owner=request.user, is_deleted=False, is_used=True) if product_id: # 因为是实时从weapp拿更新数据,这个是单规格的商品id:weapp库存 standard_product_to_store = {} if role == YUN_YING: product = models.Product.objects.get(id=product_id) # 从云伤痛获取商品详情(已入库的),更新库存 product_relation = models.ProductHasRelationWeapp.objects.filter( product_id=product_id).last() if product_relation: standard_product_to_store = update_product_store( product_2_weapp_product={ product_relation.weapp_product_id: product_relation.product_id }, products=[product]) product_models = models.ProductModel.objects.filter( product_id=product_id, is_deleted=False) product_has_model = 1 owner_id = product.owner_id postage_configs = postage_models.PostageConfig.objects.filter( owner_id=owner_id, is_deleted=False, is_used=True) current_owner_info = UserProfile.objects.get(user_id=owner_id) purchase_method = current_owner_info.purchase_method #当前商品所属客户的采购方式 points = current_owner_info.points #当前商品所属客户的零售价返点 else: product = models.Product.objects.get(owner=request.user, id=product_id) # 从云伤痛获取商品详情(已入库的),更新库存 product_relation = models.ProductHasRelationWeapp.objects.filter( product_id=product_id).last() if product_relation: standard_product_to_store = update_product_store( product_2_weapp_product={ product_relation.weapp_product_id: product_relation.product_id }, products=[product]) model_properties = models.ProductModelProperty.objects.filter( owner=request.user) property_ids = [ model_propertie.id for model_propertie in model_properties ] property_values = models.ProductModelPropertyValue.objects.filter( property_id__in=property_ids) product_has_model = len(property_values) product_models = models.ProductModel.objects.filter( product_id=product_id, owner=request.user, is_deleted=False) limit_clear_price = '' if product.limit_clear_price and product.limit_clear_price != -1: limit_clear_price = product.limit_clear_price # product_models = models.ProductModel.objects.filter(product_id=product_id,owner=request.user) product_model_ids = [ product_model.id for product_model in product_models ] property_values = models.ProductModelHasPropertyValue.objects.filter( model_id__in=product_model_ids, is_deleted=False) #获取规格值 value_ids = set([ str(property_value.property_value_id) for property_value in property_values ]) product_model_property_values = models.ProductModelPropertyValue.objects.filter( id__in=value_ids) model_values = get_product_model_property_values( product_model_property_values) #获取商品分类 product_catalog = catalog_models.ProductCatalog.objects.filter( id=product.catalog_id) first_level_name = '' second_level_name = '' if product_catalog: second_level_name = product_catalog[0].name first_level_name = catalog_models.ProductCatalog.objects.get( id=product_catalog[0].father_id).name product_store = product.product_store if not standard_product_to_store.get(product.id) \ else standard_product_to_store.get(product.id) #入库状态 has_relation_weapps = models.ProductHasRelationWeapp.objects.filter( product_id=product.id) has_relation_p_ids = set([ has_relation_weapp.product_id for has_relation_weapp in has_relation_weapps ]) reject_logs = models.ProductRejectLogs.objects.filter( product_id=product.id) has_reject_p_ids = [ reject_log.product_id for reject_log in reject_logs ] product_status_text, product_status_value = get_product_status( product, has_relation_p_ids, has_reject_p_ids) product_data = { 'id': product.id, 'product_name': product.product_name, 'promotion_title': product.promotion_title, 'product_price': '%s' % product.product_price if product.product_price > 0 else '%s' % product.clear_price, 'clear_price': '%s' % product.clear_price, 'product_weight': '%s' % product.product_weight, 'product_store': product_store, 'has_limit_time': '%s' % (1 if product.has_limit_time else 0), 'valid_time_from': '' if not product.valid_time_from else product.valid_time_from.strftime("%Y-%m-%d %H:%M"), 'valid_time_to': '' if not product.valid_time_to else product.valid_time_to.strftime("%Y-%m-%d %H:%M"), 'limit_clear_price': '%s' % limit_clear_price, 'remark': string_util.raw_html(product.remark), 'has_product_model': '%s' % (1 if product.has_product_model else 0), 'model_values': json.dumps(model_values), 'images': [], 'catalog_name': '' if not first_level_name else ('%s--%s') % (first_level_name, second_level_name), 'old_second_catalog_id': product.catalog_id, 'value_ids': ','.join(value_ids), 'limit_zone_type': product.limit_zone_type, 'limit_zone_id': product.limit_zone, 'has_same_postage': '1' if product.has_same_postage else '0', 'postage_money': '%s' % ('%.2f' % product.postage_money) } #组织多规格数据 for product_model in product_models: model_Id = product_model.name product_data['product_price_' + model_Id] = '%s' % ('%.2f' % product_model.price) product_data['limit_clear_price_' + model_Id] = '%s' % product_model.limit_clear_price product_data['clear_price_' + model_Id] = '%s' % product_model.market_price product_data['product_weight_' + model_Id] = '%s' % product_model.weight product_data['product_store_' + model_Id] = '%s' % product_model.stocks product_data['product_code_' + model_Id] = '%s' % product_model.user_code product_data[ 'valid_time_from_' + model_Id] = '%s' % product_model.valid_time_from.strftime( "%Y-%m-%d %H:%M" ) if product_model.valid_time_from else '' product_data[ 'valid_time_to_' + model_Id] = '%s' % product_model.valid_time_to.strftime( "%Y-%m-%d %H:%M" ) if product_model.valid_time_to else '' #获取商品图片 product_image_ids = [ product_image.image_id for product_image in models.ProductImage.objects.filter( product_id=product_id) ] for image in resource_models.Image.objects.filter( id__in=product_image_ids): product_data['images'].append({ 'id': image.id, 'path': image.path }) jsons['items'].append(('product', json.dumps(product_data))) else: jsons['items'].append(('product', json.dumps(None))) model_properties = models.ProductModelProperty.objects.filter( owner=request.user) property_ids = [ model_propertie.id for model_propertie in model_properties ] property_values = models.ProductModelPropertyValue.objects.filter( property_id__in=property_ids) product_has_model = len(property_values) product_catalog = catalog_models.ProductCatalog.objects.filter( id=second_level_id) first_level_name = '' second_level_name = '' if product_catalog: second_level_name = product_catalog[0].name first_level_name = catalog_models.ProductCatalog.objects.get( id=product_catalog[0].father_id).name if product_id: # 获取所有的限制 limit_zones = limit_zone_models.ProductLimitZoneTemplate.objects.filter( is_deleted=False, owner_id=product.owner_id) else: limit_zones = limit_zone_models.ProductLimitZoneTemplate.objects.filter( is_deleted=False, owner_id=request.user.id) template_ids = [template.id for template in limit_zones] not_null_template = limit_zone_models.LimitTemplateHasZone.objects.filter(template_id__in=template_ids) \ .values('template_id').distinct() not_template_ids = [t.get('template_id') for t in not_null_template] limit_zones_not_null = limit_zones.filter(id__in=not_template_ids) limit_zone_info = [ dict(text=limit_zone.name, value=limit_zone.id) for limit_zone in limit_zones_not_null ] limit_zone_info.append({'text': '请选择区域', 'value': 0}) has_postage_config = { 'has_postage_config': True if postage_configs else False, 'postage_name': postage_configs[0].name if postage_configs else '', } jsons['items'].append(('limit_zone_info', json.dumps(limit_zone_info))) jsons['items'].append( ('has_postage_config', json.dumps(has_postage_config))) c = RequestContext( request, { 'first_nav_name': FIRST_NAV, 'second_navs': nav.get_second_navs(request), 'second_nav_name': SECOND_NAV if role == CUSTOMER else 'product-relation-list', #为了兼容运营查看商品详情页 'jsons': jsons, 'second_level_id': second_level_id, 'role': role, 'points': points, 'purchase_method': purchase_method, 'product_has_model': product_has_model, 'catalog_name': '' if not first_level_name else ('%s--%s') % (first_level_name, second_level_name), 'product_status_value': product_status_value }) return render_to_response('product/new_product.html', c)