<?php
/**
 * 会员接口入口，不是南宁，这个是费司的需求
 *
 * ============================================================================
 * 版权所有 2017北京素玄科技，并保留所有权利。
 *
 * 网站地址: http://www.suxuantech.com
 * ----------------------------------------------------------------------------
 * 这不是一个自由软件！未经允许的情况下，您不能对本系统代码做任何修改 .
 * 不允许对程序代码以任何形式任何目的的再发布。
 * 如有修改需求，请联系素玄科技有限公司：contact@suxuantech.cn
 * ============================================================================
 * $Author: lwh<liwenhua@suxuantech.cn> 2021-4-20 $
 */
namespace app\index\api;

use think\Exception;
class FeiSi{
    /**
     * 根据电话查询客资
     * @param  customer_tel    客户电话
     * @return array
     * @author lwh<liwenhua@suxuantech.cn>
     */
    public function getCustomerList($param){
        $where['is_status'] = 1;
        $where['c_from'] = 1;
        $where['customer_tel'] = $param['customer_tel'];

        $field = 'id,customer_channel,consultation_type,is_valid,is_intostore,is_success,customer_name,customer_sex,customer_tel,customer_wechat,customer_weibo,customer_qq,consulation_shop,customer_type,dj_day,is_fp,dj_staff,sales_staff,last_trackday,brandclass,shop_name,add_shop_name';

        $customerList = db('c_customerinfo')
            ->where($where)
            ->field($field)
            ->select();
        return $customerList;
    }

    /**
     * 根据电话查询订单
     * @param  customer_tel    客户电话
     * @return array
     * @author lwh<liwenhua@suxuantech.cn>
     */
    public function getOrderList($param){
        $where['c.is_status'] = 1;
        $where['c.c_from'] = 1;
        $where['c.customer_tel'] = $param['customer_tel'];

        $field = 'c.id,c.customer_name,c.customer_tel,c.customer_wechat,c.customer_channel,c.dj_staff,c.add_shop_name,c.dj_day,c.sales_staff,c.jr_day,c.shop_name,c.is_success,o.target_time,o.valid_time,o.order_fact,o.order_amount,o.order_sn,o.order_fact,o.order_amount';

        $orderList = db('c_customerinfo')->alias('c')
            ->join('c_customer_order o','c.id = o.customer_id')
            ->where($where)
            ->field($field)
            ->select();
        return $orderList;
    }
}