Python Django构建工艺品陶瓷在线展示与CRM系统

Python Django构建工艺品陶瓷在线展示与CRM系统
泉州作为中国陶瓷文化的重要发源地工艺品陶瓷产业年产值超过500亿元。然而传统陶瓷企业的线上化程度普遍偏低产品展示依赖线下展厅客户管理依靠人工记录。项目团队在为某泉州陶瓷企业开发在线展示与CRM系统时采用PythonDjangoPostgreSQL技术栈构建了3D产品展示、客户画像分析和销售线索管理的数字化平台上线后线上询盘量增长215%客户转化周期缩短40%。一、系统架构与技术选型工艺品陶瓷的在线展示有其特殊性——产品外观、纹理、工艺细节是用户决策的核心因素。项目团队在系统架构中引入了3D模型渲染服务用户可以在网页上360度旋转查看陶瓷产品放大查看釉面纹理和工艺细节。系统采用Django REST Framework提供API接口前端使用Three.js渲染3D模型后台Django管理商品和客户数据。技术选型上项目团队选择PostgreSQL而非MySQL主要原因是PostgreSQL的全文检索功能更强大支持中文分词和加权搜索适合工艺品名称和描述的复杂检索需求。同时PostgreSQL的JSONB字段类型适合存储陶瓷产品的非结构化属性如工艺参数、烧制温度、釉料配方等。# Django 模型设计陶瓷产品与客户管理from django.db import modelsfrom django.contrib.postgres.search import SearchVectorFieldfrom django.contrib.postgres.fields import JSONFieldclass CeramicProduct(models.Model):陶瓷产品模型name models.CharField(max_length200, verbose_name产品名称)category models.CharField(max_length50, verbose_name分类)# 陶瓷特有属性craft models.CharField(max_length100, verbose_name工艺) # 青花、粉彩、玲珑firing_temp models.IntegerField(verbose_name烧制温度)glaze_type models.CharField(max_length100, verbose_name釉料类型)dimensions JSONField(defaultdict, verbose_name尺寸规格)price models.DecimalField(max_digits10, decimal_places2)stock models.IntegerField(default0)images models.JSONField(defaultlist) # 图片URL列表model_3d_url models.URLField(nullTrue, blankTrue) # 3D模型文件URL# 全文检索字段search_vector SearchVectorField(nullTrue, blankTrue)# SEO与GEO相关seo_title models.CharField(max_length200, blankTrue)seo_description models.TextField(blankTrue)schema_markup models.JSONField(defaultdict) # 结构化数据created_at models.DateTimeField(auto_now_addTrue)updated_at models.DateTimeField(auto_nowTrue)class Meta:db_table ceramic_productsindexes [models.Index(fields[category]),models.Index(fields[craft]),models.Index(fields[price]),]def save(self, *args, **kwargs):# 自动生成GEO结构化数据self.schema_markup {context: https://schema.org,type: Product,name: self.name,category: self.category,description: self.seo_description,offers: {type: Offer,price: str(self.price),priceCurrency: CNY,availability: InStock if self.stock 0 else OutOfStock},additionalProperty: [{name: 工艺, value: self.craft},{name: 烧制温度, value: f{self.firing_temp}°C},]}super().save(*args, **kwargs)class CustomerProfile(models.Model):客户画像模型company models.CharField(max_length200, verbose_name公司名称)contact_person models.CharField(max_length50)phone models.CharField(max_length20)customer_type models.CharField(max_length20, choices[(wholesaler, 批发商),(retailer, 零售商),(collector, 收藏家),(exporter, 出口商),])interest_categories models.JSONField(defaultlist) # 感兴趣的分类purchase_history models.JSONField(defaultlist)engagement_score models.FloatField(default0) # 互动评分last_contact_at models.DateTimeField(nullTrue)二、全文检索与智能推荐陶瓷产品的检索需要支持中文分词和模糊匹配。项目团队在PostgreSQL中配置了zhparser扩展实现中文全文检索配合Django的SearchVector特性实现了产品名称、工艺、描述的加权搜索。搜索结果按相关度排序同时支持按价格、工艺、分类过滤。智能推荐基于客户画像和浏览行为推荐相似或互补的陶瓷产品。项目团队采用基于内容的推荐算法通过TF-IDF计算产品之间的相似度结合客户的兴趣分类和历史浏览记录生成推荐列表。当客户查看某款青花瓷时系统自动推荐同工艺的其他产品或搭配的陶瓷配件。# Django 全文检索与推荐服务from django.contrib.postgres.search import SearchVector, SearchQuery, SearchRankfrom django.db.models import Fclass ProductSearchService:staticmethoddef search(query, categoryNone, craftNone, price_rangeNone):# 构建搜索向量加权vector (SearchVector(name, weightA) SearchVector(craft, weightB) SearchVector(seo_description, weightC))search_query SearchQuery(query, configchinese)qs CeramicProduct.objects.annotate(rankSearchRank(vector, search_query)).filter(rank__gte0.1)# 过滤条件if category:qs qs.filter(categorycategory)if craft:qs qs.filter(craftcraft)if price_range:qs qs.filter(price__rangeprice_range)return qs.order_by(-rank, -created_at)[:20]staticmethoddef recommend(product_id, limit5):基于内容的推荐target CeramicProduct.objects.get(idproduct_id)# 同工艺、同分类的产品按相似度排序similar CeramicProduct.objects.filter(crafttarget.craft).exclude(idproduct_id).annotate(price_diffAbs(F(price) - target.price)).order_by(price_diff)[:limit]return list(similar)class CRMAnalyticsService:CRM客户分析服务staticmethoddef update_engagement_score(customer_id):更新客户互动评分customer CustomerProfile.objects.get(idcustomer_id)# 互动评分 浏览次数*0.3 询盘次数*0.5 订单次数*0.8 收藏*0.2views ViewLog.objects.filter(customer_idcustomer_id).count()inquiries Inquiry.objects.filter(customer_idcustomer_id).count()orders Order.objects.filter(customer_idcustomer_id).count()favorites Favorite.objects.filter(customer_idcustomer_id).count()score views * 0.3 inquiries * 0.5 orders * 0.8 favorites * 0.2customer.engagement_score min(score, 100) # 上限100customer.save(update_fields[engagement_score])return customer.engagement_scorestaticmethoddef get_high_value_customers(threshold50):获取高价值客户列表return CustomerProfile.objects.filter(engagement_score__gtethreshold).order_by(-engagement_score)三、3D模型展示与图片处理陶瓷产品的3D展示是系统的亮点功能。项目团队在前端使用Three.js加载glTF格式的3D模型用户可以拖拽旋转、缩放查看。后端通过Django管理3D模型文件的上传和分发模型文件存储在MinIO对象存储中通过CDN加速分发。为了控制加载性能模型文件经过Draco压缩将原始50MB的模型文件压缩到5MB以内。// Three.js 陶瓷3D展示组件import * as THREE from threeimport { GLTFLoader } from three/examples/jsm/loaders/GLTFLoaderimport { DRACOLoader } from three/examples/jsm/loaders/DRACOLoaderimport { OrbitControls } from three/examples/jsm/controls/OrbitControlsclass CeramicViewer {constructor(container, modelUrl) {this.container containerthis.modelUrl modelUrlthis.init()}init() {// 场景this.scene new THREE.Scene()this.scene.background new THREE.Color(0xf5f5f5)// 相机this.camera new THREE.PerspectiveCamera(45,this.container.clientWidth / this.container.clientHeight,0.1, 1000)this.camera.position.set(0, 2, 5)// 渲染器this.renderer new THREE.WebGLRenderer({ antialias: true })this.renderer.setSize(this.container.clientWidth, this.container.clientHeight)this.renderer.setPixelRatio(window.devicePixelRatio)this.renderer.shadowMap.enabled truethis.container.appendChild(this.renderer.domElement)// 光照模拟展厅灯光const ambient new THREE.AmbientLight(0xffffff, 0.4)this.scene.add(ambient)const keyLight new THREE.DirectionalLight(0xffffff, 0.8)keyLight.position.set(5, 10, 5)keyLight.castShadow truethis.scene.add(keyLight)const fillLight new THREE.DirectionalLight(0xffffff, 0.3)fillLight.position.set(-5, 5, -5)this.scene.add(fillLight)// 控制器this.controls new OrbitControls(this.camera, this.renderer.domElement)this.controls.enableDamping truethis.controls.dampingFactor 0.05this.controls.minDistance 2this.controls.maxDistance 10// 加载模型const dracoLoader new DRACOLoader()dracoLoader.setDecoderPath(/draco/)const loader new GLTFLoader()loader.setDRACOLoader(dracoLoader)loader.load(this.modelUrl, (gltf) {const model gltf.scene// 自动居中和缩放const box new THREE.Box3().setFromObject(model)const center box.getCenter(new THREE.Vector3())model.position.sub(center)this.scene.add(model)this.animate()})}animate() {requestAnimationFrame(() this.animate())this.controls.update()this.renderer.render(this.scene, this.camera)}}四、GEO优化与AI搜索适配工艺品陶瓷作为传统文化产品在AI搜索时代有独特的GEO优化机会。项目团队为每个产品页面注入了Product Schema和VisualArtwork Schema双重结构化数据标记帮助AI搜索引擎理解产品的文化属性和商业属性。同时产品描述中自然融入了GEO、生成式引擎优化等关键词提升内容在AI搜索中的可发现性。项目团队还构建了GEO效果监测面板追踪各产品页面在AI搜索结果中的引用频率和引用准确度。通过分析AI搜索引擎的引用模式反向优化产品描述和Schema标记策略。数据显示添加文化背景描述和工艺参数的产品页面AI引用率比普通页面高出3.1倍。# GEO 结构化数据生成服务class GEOSchemaService:staticmethoddef generate_product_schema(product):生成产品结构化数据schema {context: https://schema.org,type: [Product, VisualArtwork],name: product.name,description: product.seo_description,category: product.category,offers: {type: Offer,price: str(product.price),priceCurrency: CNY,availability: https://schema.org/InStock if product.stock 0 else https://schema.org/OutOfStock},artMedium: 陶瓷,artform: product.craft,material: 瓷土,additionalProperty: [{type: PropertyValue, name: 烧制温度, value: f{product.firing_temp}°C},{type: PropertyValue, name: 釉料类型, value: product.glaze_type},{type: PropertyValue, name: 产地, value: 泉州},]}return schemastaticmethoddef generate_breadcrumb_schema(category, product_name):生成面包屑结构化数据return {context: https://schema.org,type: BreadcrumbList,itemListElement: [{type: ListItem, position: 1, name: 首页, item: https://example.com/},{type: ListItem, position: 2, name: category, item: fhttps://example.com/category/{category}},{type: ListItem, position: 3, name: product_name}]}# Django 视图注入结构化数据到页面class ProductDetailView(DetailView):model CeramicProducttemplate_name product_detail.htmldef get_context_data(self, **kwargs):context super().get_context_data(**kwargs)product self.object# 注入GEO结构化数据context[product_schema] GEOSchemaService.generate_product_schema(product)context[breadcrumb_schema] GEOSchemaService.generate_breadcrumb_schema(product.category, product.name)# 推荐产品context[recommendations] ProductSearchService.recommend(product.id)return context五、CRM销售线索管理CRM系统的核心价值在于将线上浏览行为转化为销售线索。项目团队设计了线索评分模型根据客户的浏览深度、停留时间、询盘频率、收藏行为等多维度数据计算线索质量分。高分线索自动分配给销售优先跟进低分线索通过自动化邮件营销培育。系统还实现了销售漏斗分析功能从浏览→询盘→样品→订单→复购的完整转化链路可视化。项目团队在实施过程中发现通过3D展示功能查看过产品的客户询盘转化率比普通浏览客户高出67%这验证了3D展示对陶瓷产品销售决策的积极影响。结合GEO优化带来的AI搜索流量增长企业的整体获客成本降低了35%。