Commit 80e00bb9 authored by zhuwei's avatar zhuwei

新增-客户电话跟进 1.新增验证规则,字段验证 2.bug修复

parent 8ff04a97
......@@ -269,43 +269,31 @@ class Broker extends Basic
{
header('Access-Control-Allow-Origin:*');
$params = $this->params;
/*$params['content']='跟进内容';//跟进内容
/*
$params['content']='跟进内容';//跟进内容
$params['labels_id']=1;//g_labels表主键
$params['user_id']=1;//u_users ID用户表id
$params['agent_id']=1;//agent表id-当前登录用户id
$params['type']='1';//B端agent表*/
$params['type']='1';//0电话跟进 1普通跟进
*/
if (!isset($params['content']) || !isset($params['user_id']) || !isset($params['agent_id']) ) {
return $this->response("300", "参数不全", [ 'remote_groupid' => '' ]);
$checkResult = $this->validate($params, "BrokerValidate.verifyStatus");
if (true !== $checkResult) {
return $this->response("300", $checkResult);
}
$content = $params['content'];
$labels_id = empty($params['labels_id']) ? 0 : $params['labels_id'];
$user_id = $params['user_id'];
$agent_id = $params['agent_id'];
$user_status = $params['user_status'];
$type = $params['type'];//0电话跟进 1普通跟进
//修复20180802 bug 此功能待完善 zw
if($agent_id == 0){
return $this->response("300", "请传入正确的经纪人id", [ 'remote_groupid' => '' ]);
}
//主表查询商铺详细信息
$UPhoneFollowPp = new UPhoneFollowPp();
$UPhoneFollowPp->content = $content;
$UPhoneFollowPp->labels_id = $labels_id;
$UPhoneFollowPp->user_id = $user_id;
$UPhoneFollowPp->agent_id = $agent_id;
$UPhoneFollowPp->type = $type;
$UPhoneFollowPp->user_status = $user_status;
$UPhoneFollowPp->save();
//dump($UPhoneFollowPp->id);exit;
$result = $UPhoneFollowPp->savePhoneFollow($params);
//跟进,对客户状态进行更新 0:求租;1:已租;-1:无效
$Users = new Users();
$Users->update_user_status([ 'id' => $user_id, 'user_status' => $user_status ]);
if ($UPhoneFollowPp->id) {
return $this->response("200", "success!", $UPhoneFollowPp->id);
if ($result == 1) {
return $this->response("200", "success!", $result);
} else {
return $this->response("101", "失败!");
}
......
<?php
namespace app\api_broker\validate;
use think\Validate;
/**
* Created by PhpStorm.
* User: zhuwei
* Date: 2018/8/3
* Time: 上午10:11
*/
class BrokerValidate extends Validate{
protected $rule = [
'type' => 'require|in:0,1,2',
'agent_id' => 'require|number|gt:0',
'labels_id' => 'number',
'user_id' => 'require|number|gt:0',
'user_status' => 'require|in:-1,0,1'
];
protected $message = [
'type.require' => 'type为必填字段',
'type.number' => 'type只能为数字',
'agent_id.require' => 'agent_id为必填字段',
'agent_id.number' => 'agent_id只能为数字',
'labels_id.number' => 'labels_id只能为数字',
'user_id.require' => 'user_id为必填字段',
'user_id.number' => 'user_id只能为数字',
'user_status.require' => 'user_status为必填字段',
'user_status.number' => 'user_status只能为数字'
];
protected $scene = [
'add_phone_follow_up_verify' => [ 'labels_id', 'user_id', 'agent_id', 'user_status', 'type' ],
];
}
......@@ -16,6 +16,16 @@ class UPhoneFollowPp extends BaseModel
$this->UPhoneFollowPp = Db($this->table);
}
/**
* 新增电话跟进-插入数据
* @param $data
* @return int|string
*/
public function savePhoneFollow($data) {
$result = $this->UPhoneFollowPp->insert($data);
return $result;
}
/**
* @return array|false|\PDOStatement|string|\think\Model
* @throws \think\db\exception\DataNotFoundException
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment