3 CRM 销售与客户

 1、销售与客户的表结构

1、公共客户与我的客户

---公共客户(公共资源)
1、没有报名
2、3天没有跟进
3、15天没有成单

客户分布表
龙泰 男 yuan 2018-5-1 3天未跟进
龙泰 男 三江 2018-5-5 15天未成单
龙泰 男 暴雨 2018-5-21 正在跟进

---我的客户(抢单)
crontab:
2018-5-15 12:00 龙泰 男 三江 2018-5-15 正在跟进

2018-5-16 0:0
2018-5-17 0:0
2018-5-18 0:0
2018-5-19 0:0 龙泰 男 三江 2018-5-19 3天未跟进


key: CustomerDistrbute为什么创建 ,为什么不能直接用Customer

2、思考

因为:销售可以查看,自己的客户是否已过期,是否正在跟进,月底可以算业绩!
不能说没谈成,就没有业绩!!

我的客户与公共用户不能冲突!

我的客户要一直存在,月末要进行绩效统计,他的状态可以是,正在跟进,3天未跟进

一过期,就改了。linux定时脚本来完成!!
linux 固定时间,执行脚本 os 去做,
每天00:00去监测!

隔半天或隔一天,脚本每天凌晨监测一遍过期就放到公共客户。

刷新状态,或者把过期的用户移动到公共客户池子

可以通过,定时脚本,每天0:0进行

3、添加新的表

class CustomerDistrbute(models.Model):
    customer = models.ForeignKey("Customer", related_name="customers",on_delete=True)
    consultant = models.ForeignKey(verbose_name="课程顾问", to="UserInfo", limit_choices_to={"depart_id": 1001},on_delete=True)
    date = models.DateField()
    status = (
        (1, "正在跟进"),
        (2, "已报名"),
        (3, "三天未跟进"),
        (4, "15天未成单"),
    )
    status = models.IntegerField(choices=status, default=1)

    memo = models.CharField(max_length=255)

    def __str__(self):
        return self.customer.name+":"+self.consultant.name

 

4、新的表结构

 2、公共客户池

class CusotmerConfig(ModelStark):


    def public_customer(self,request):
        """公共客户"""
        # 未报名 且3天未跟进或者15天未成单


        import datetime
        now =datetime.datetime.now()
        print(now)
        '''
        datetime.datetime
        datetime.time
        datetime.date
        datetime.timedelta(days=7)
        '''

        # 3天未跟进 now - last_consult_date > 3   ----> last_consult_date < now-3
        # 15天未成单 now - recv_date > 3   ----> recv_date < now-15
        delta_day3 = datetime.timedelta(days=3)
        delta_day15 = datetime.timedelta(days=15)

        from django.db.models import Q

        # Customer.objects.filter(status=2,last_consult_date__lt=now-3)
        # customer_list = Customer.objects.filter(Q(last_consult_date__lt=now-delta_day3)|Q(recv_date__lt=now-delta_day15),status=2)

        # 过滤掉 我的客户
        user_id = 2
        customer_list = Customer.objects.filter(Q(last_consult_date__lt=now-delta_day3)|Q(recv_date__lt=now-delta_day15),status=2).exclude(consultant=user_id)
        print(customer_list.query)
        """
            SELECT "crm_customer"."id", "crm_customer"."qq", 
                "crm_customer"."name", "crm_customer"."gender", 
                "crm_customer"."education", "crm_customer"."graduation_school", 
                "crm_customer"."major", "crm_customer"."experience", 
                "crm_customer"."work_status", "crm_customer"."company", 
                "crm_customer"."salary", "crm_customer"."source",
                 "crm_customer"."referral_from_id", "crm_customer"."status",
                  "crm_customer"."consultant_id", "crm_customer"."date",
                   "crm_customer"."recv_date", "crm_customer"."last_consult_date" 
            FROM "crm_customer" 
            WHERE (("crm_customer"."last_consult_date" < 2018-06-24 
              OR "crm_customer"."recv_date" < 2018-06-12) 
              AND "crm_customer"."status" = 2)

        """
        
        print('public_customer_list',customer_list)

        return render(request,'public.html',locals())

    

    def extra_url(self):
        temp = []
        temp.append(url(r"cancel_course/(\d+)/(\d+)", self.cancel_course))
        temp.append(url(r"public/", self.public_customer))
        return temp

site.register(Customer, CusotmerConfig)

1、添加public的url

    def extra_url(self):
        temp = []
        temp.append(url(r"cancel_course/(\d+)/(\d+)", self.cancel_course))
        temp.append(url(r"public/", self.public_customer))
        return temp

 2、 datetime.timedelta ( 时间 + - )

        import datetime
        now =datetime.datetime.now()
        print(now)
        '''
        datetime.datetime
        datetime.time
        datetime.date
        datetime.timedelta(days=7)
        '''

        # 3天未跟进 now - last_consult_date > 3   ----> last_consult_date < now-3
        # 15天未成单 now - recv_date > 3   ----> recv_date < now-15
        delta_day3 = datetime.timedelta(days=3)
        delta_day15 = datetime.timedelta(days=15)

 

3、未报名 且3天未跟进或者15天未成单 

 Q查询 last_consult_date__lt recv_date__lt
        from django.db.models import Q
# Customer.objects.filter(status=2,last_consult_date__lt=now-3) customer_list = Customer.objects.filter(Q(last_consult_date__lt=now-delta_day3)|Q(recv_date__lt=now-delta_day15),status=2)

 

4. exclude(排除)

 # 不应该让之前的课程顾问 再看到这个已经放到公共名单的人了
        # 过滤掉 我的客户
        user_id = 2
        customer_list = Customer.objects.filter(Q(last_consult_date__lt=now-delta_day3)|Q(recv_date__lt=now-delta_day15),status=2).exclude(consultant=user_id)

5. customer_list.query( sql 语句 )

        # print(customer_list.query)
        """
        SELECT "crm_customer"."id", "crm_customer"."qq", 
            "crm_customer"."name", "crm_customer"."gender", 
            "crm_customer"."education", "crm_customer"."graduation_school", 
            "crm_customer"."major", "crm_customer"."experience", 
            "crm_customer"."work_status", "crm_customer"."company", 
            "crm_customer"."salary", "crm_customer"."source",
             "crm_customer"."referral_from_id", "crm_customer"."status",
              "crm_customer"."consultant_id", "crm_customer"."date",
               "crm_customer"."recv_date", "crm_customer"."last_consult_date" 
        FROM "crm_customer" 
        WHERE (("crm_customer"."last_consult_date" < 2018-06-24 
          OR "crm_customer"."recv_date" < 2018-06-12) 
          AND "crm_customer"."status" = 2)

        """

 6、跳转标签

                            <td><a href="/stark/crm/consultrecord/?customer={{ customer.pk }}">跟进记录</a></td>
                            <td><a href="/stark/crm/customer/further/{{ customer.pk }}"></a></td>

7、public.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="/static/bootstrap/css/bootstrap.css">
    <script src="/static/js/jquery-1.12.4.min.js"></script>
</head>
<body>
<h3>公共客户</h3>
<div class="container">
    <div class="row">
        <div class="col-md-9 col-md-offset-1">
            <form action="" method="post">
                {% csrf_token %}
                <table class="table table-bordered table-striped">
                    <thead>
                    <tr>
                        <th>ID</th>
                        <th>姓名</th>
                        <th>QQ</th>
                        <th>跟进详情</th>
                        <th>是否跟进</th>
                    </tr>
                    </thead>

                    <tbody>
                    {% for customer in customer_list %}
                        <tr>
                            <td>{{ forloop.counter }}</td>
                            <td>{{ customer.name }}</td>
                            <td>{{ customer.qq }}</td>
                            <td><a href="/stark/crm/consultrecord/?customer={{ customer.pk }}">跟进记录</a></td>
                            <td><a href="/stark/crm/customer/further/{{ customer.pk }}"></a></td>
                        </tr>
                    {% endfor %}

                    </tbody>
                </table>
            </form>
        </div>

    </div>
</div>
</body>
</html>
View Code

3、确认跟进

  

2

 

3

4

5

67

7

8

9

猜你喜欢

转载自www.cnblogs.com/venicid/p/9581659.html