<?php
/**
*跑街令CRM
*/
class crmAction extends baseAction
{
	/**
	  * @method 自动调整当前业务员和客户之间的关系
	  * @http  get
	  * @param  token              string [必填] 调用接口凭证 (post|get)
	  * @param ctr_id int   [必填]  客户ID
	  * @param au_uid int   [必填]  业务员用户ID 
	  * @author soul
	  * @copyright 2017/9/30
	  * @return 
	  {"status":true,"data": [],"code":""}
	  {"status":false,"data":'失败原因',"code":''}
	  */
	public function changeCtrAutoStatus()
	{
		$Params = mvc::$URL_PARAMS;
		$CrmMain = new CrmMain();
		$res = $CrmMain->changeCtrAutoStatus($Params['ctr_id'], $Params['au_uid']);
		LibFc::EchoJson($res);
	}

	/**
	 * @method 将uid自动加入到crm活跃用户
	 * @http  get
	 * @param  token              string [必填] 调用接口凭证 (post|get)
	 * @param uid int   [必填]  用户ID 
	 * @author zhengweihua 
	 * @copyright 2023-05-22
	 * @return 
	 {"status":true,"data": [],"code":""}
	 {"status":false,"data":'失败原因',"code":''}
	 */
	public function addCrmCustomerByUid()
	{
		$Params = mvc::$URL_PARAMS;
		$CrmMain = new CrmMain();
		$res = $CrmMain->addCrmCustomerByUid($Params['uid']);
		LibFc::EchoJson($res);
	}


	/**
	  * @method 根据现有合同初始化客户状态
	  * @http  get
	  * @param  token              string [必填] 调用接口凭证 (post|get)
	  * @param ctr_id  int [必填]  客户ID
	  * @author soul
	  * @copyright 2017/9/30
	  * @return 
	  {"status":true,"data": [],"code":""}
	  {"status":false,"data":'失败原因',"code":''}
	  */
	public function initCtrStatus()
	{
		$Params = mvc::$URL_PARAMS;
		$CrmMain = new CrmMain();
		$res = $CrmMain->initCtrStatus($Params['ctr_id']);
		LibFc::EchoJson($res);
	}

	/**
	  * @method 通过手机号码创建客户
	  * @param  mobile 手机号码
	  * @param  au_uid 业务员ID
	  * @author soul
	  * @copyright 2024/2/19
	  * @return {"status":true,"data": 客户ctr_id,"code":""}
	  */
	public function addCtrByMobile($mobile)
	{
		$Params = mvc::$URL_PARAMS;
		$CrmMain = new CrmMain();
		$res = $CrmMain->addCtrByMobile($Params['mobile'], $Params['au_uid']);
		LibFc::EchoJson($res);
	}

	/**
	  * @method 通过手机号码查找所属业务员
	  * @param  mobile 手机号码
	  * @author soul
	  * @copyright 2025/11/22
	  * @return {"status":true,"data":{"org_ctr_id":"96477","ctr_id":"25396","cca_level_id":"5","au_uid":"334744","end_time":"1797004800"},"code":0,"runtime":209}
		org_ctr_id:手机号码对应的客户ID,  ctr_id:归属主客户
	  */
	public function checkMobileSales($mobile)
	{
		$Params = mvc::$URL_PARAMS;
		$CrmMain = new CrmMain();
		$res = $CrmMain->checkMobileSales($Params['mobile']);
		LibFc::EchoJson($res);
	}
}