diff --git a/admin/controllers/receiver/Tag.php b/admin/controllers/receiver/Tag.php new file mode 100644 index 00000000..dd0ce3e1 --- /dev/null +++ b/admin/controllers/receiver/Tag.php @@ -0,0 +1,275 @@ + ['title' => '客户标签', 'url' => '/receiver/tag'], + 2 => ['title' => '车主标签', 'url' => '/receiver/ownersTag'], + 3 => ['title' => '战败标签', 'url' => '/receiver/tag?tag_type=1'], + 4 => ['title' => '意向标签', 'url' => '/receiver/tag?tag_type=2'] + ]; + + public function __construct() + { + parent::__construct(); + $this->load->model('receiver/receiver_customer_tag_model', 'mdCustomerTag'); + } + + //首页信息 + public function index() + { + return $this->lists(); + } + + //数据列表 + public function lists() + { + $params = $this->input->get(); + $params['page'] = $params['page'] ? intval($params['page']) : 1; + $params['size'] = $params['size'] ? intval($params['size']) : 20; + #$params['tab'] = $params['tag_type'] ? 3 : 1; + $params['tab'] = $params['tag_type'] ? $params['tag_type'] + 2 : 1; + $statusAry = $this->mdCustomerTag->statusAry(); + $typeAry = $this->mdCustomerTag->typeAry(); + $showAry = $this->mdCustomerTag->showAry(); + $lists = array(); + $where = ["status<>-1" => null, 'pid' => 0]; + $where['tag_type'] = $params['tag_type'] ? $params['tag_type'] : 0; + if (strlen($params['status'])) { + $where['status'] = $params['status']; + } + if (strlen($params['show'])) { + $where['show'] = $params['show']; + } + if ($params['type']) { + $where['type'] = $params['type']; + } + $count = $this->mdCustomerTag->count($where); + if ($count) { + $res = $this->mdCustomerTag->select($where, "sort desc,id desc", $params['page'], $params['size']); + foreach ($res as $key => $value) { + $setValue = array(); + $setValue['id'] = $value['id']; + $setValue['name'] = $value['name']; + $setValue['sort'] = $value['sort']; + $setValue['type_name'] = $typeAry[$value['type']]; + $setValue['status'] = $value['status']; + $setValue['status_name'] = $statusAry[$value['status']]; + $setValue['show_name'] = $showAry[$value['show']]; + $options = ''; + $res_tag = $this->mdCustomerTag->select(["status" => 1, 'pid' => $value['id']], "sort desc,id desc", 0, 0, 'id,name,sort'); + $res_tag && $options = implode(',', array_column($res_tag, 'name')); + $setValue['options'] = $options; + $lists[] = $setValue; + } + } + $this->data['lists'] = $lists; + $this->data['params'] = $params; + $this->data['showInfo'] = ['statusAry' => $statusAry, 'typeAry' => $typeAry, 'showAry' => $showAry, 'tabAry' => $this->tabAry]; + $this->data['_title'] = '客户标签列表'; + $this->data['pager'] = array('count' => ceil($count / $params['size']), 'curr' => $params['page'], 'totle' => $count); + return $this->show_view('/receiver/tag/lists', true); + } + + public function get_options() + { + $id = intval($this->input->post('id')); + if (!$id) { + return $this->show_json(SYS_CODE_FAIL, '参数错误!'); + } + $res_tag = $this->mdCustomerTag->select(["status" => 1, 'pid' => $id], "sort desc,id desc", 0, 0, 'id,name,sort,status,qy_id'); + $this->data['lists'] = $res_tag; + return $this->show_json(SYS_CODE_SUCCESS); + } + + //展示单条数据 + public function get() + { + $id = intval($this->input->get('id')); + $tag_type = $this->input->get('tag_type'); + !$tag_type && $tag_type = 0; + if ($id) { + $url = "/receiver/tag/edit"; + $re = $this->mdCustomerTag->get(['id' => $id]); + if (!$re) { + return $this->show_json(SYS_CODE_FAIL, '客户标签不存在!'); + } + $name = $re['name']; + $sort = $re['sort']; + $type = $re['type']; + $show = $re['show']; + } else { + $url = "/receiver/tag/add"; + $name = ''; + $sort = $show = 0; + $type = 'checkbox'; + } + $this->data['showInfo'] = ['id' => $id, 'name' => $name, 'sort' => $sort, 'type' => $type, 'show' => $show, + 'typeAry' => $this->mdCustomerTag->typeAry(), 'showAry' => $this->mdCustomerTag->showAry(), 'url' => $url,'tag_type'=>$tag_type]; + return $this->show_view('/receiver/tag/edit'); + } + + //添加单条数据 + public function add() + { + $params = $this->input->post(); + if (!$params['name']) { + return $this->show_json(SYS_CODE_FAIL, '标签名称不能为空!'); + } + $re = $this->mdCustomerTag->get(array('name' => $params['name'])); + if ($re) { + return $this->show_json(SYS_CODE_FAIL, '标签名称已存在了!'); + } + $add_data = [ + 'name' => $params['name'], + 'sort' => $params['sort'], + 'type' => $params['type'], + 'show' => $params['show'] + ]; + $params['tag_type'] && $add_data['tag_type'] = $params['tag_type']; + $id = $this->mdCustomerTag->add($add_data); + if (!$id) { + return $this->show_json(SYS_CODE_FAIL, '保存失败'); + } + return $this->show_json(SYS_CODE_SUCCESS, '保存成功'); + } + + //编辑单条数据 + public function edit() + { + $params = $this->input->post(); + if (!$params['id']) { + return $this->show_json(SYS_CODE_FAIL, '参数错误'); + } + if (!$params['name']) { + return $this->show_json(SYS_CODE_FAIL, '请输入标签名称'); + } + $re = $this->mdCustomerTag->get(array('name' => $params['name'], 'status' => 1)); + if ($re && $re['id'] != $params['id']) { + return $this->show_json(SYS_CODE_FAIL, '标签名称已存在了!'); + } + $re = $this->mdCustomerTag->get(['id' => $params['id']]); + if (false !== strpos($_SERVER['HTTP_HOST'], 'admin.liche.cn') && $re['qy_id']) {//正试才能修改企业标签 + $this->load->library('wx_qyapi', ['app' => 'lichene']); + $this->wx_qyapi->get_external_contact(['url' => 'edit_corp_tag', 'id' => $re['qy_id'] + , 'name' => $params['name'], 'order' => $params['sort']]); + } + $this->mdCustomerTag->update(['name' => $params['name'], 'sort' => $params['sort'], 'type' => $params['type'] + , 'show' => $params['show']], ['id' => $params['id']]); + return $this->show_json(SYS_CODE_SUCCESS, '保存成功'); + } + + //删除单条数据 + public function del() + { + $id = $this->input->post('id'); + if (!$id) { + $this->show_json(SYS_CODE_FAIL, '参数错误'); + } + $re = $this->mdCustomerTag->get(['id' => $id]); + if (!$re) { + return $this->show_json(SYS_CODE_FAIL, '标签不存在!'); + } + if ($re['tag_type'] == 2) { + return $this->show_json(SYS_CODE_FAIL, '该标签不能删除!'); + } + $this->mdCustomerTag->update(['status' => '-1'], ['id' => $id]); + if (false !== strpos($_SERVER['HTTP_HOST'], 'admin.liche.cn') && $re['qy_id']) {//正试才能修改企业标签 + $this->load->library('wx_qyapi', ['app' => 'lichene']); + $this->wx_qyapi->get_external_contact(['url' => 'del_corp_tag', 'group_id' => $re['qy_id']]); + } + return $this->show_json(SYS_CODE_SUCCESS, '操作成功'); + } + + //修改标签选项 + function edit_options() + { + $pid = $this->input->post('id'); + $options = $this->input->post('options'); + if (!$pid || !$options) { + return $this->show_json(SYS_CODE_FAIL, '参数错误!'); + } + $re = $this->mdCustomerTag->get(['id' => $pid]); + if (!$re) { + return $this->show_json(SYS_CODE_FAIL, '客户标签不存在!'); + } + $add_tag = $del_tag = $edit_tag = []; + foreach ($options as $key => $value) { + $sort = intval($value['sort']); + $data = ['name' => $value['name'], 'status' => $value['status'], 'sort' => $sort, 'tag_type' => $re['tag_type']]; + if ($value['status'] == -1 && $value['qy_id']) {//删除标签 + $del_tag[] = $value['qy_id']; + } + if ($value['name']) { + if ($value['id']) {//修改 + if ($value['status'] == 1 && $value['qy_id']) { + $edit_tag[] = ['id' => $value['qy_id'], 'name' => $value['name'], 'order' => $sort]; + } + $this->mdCustomerTag->update($data, ['id' => $value['id']]); + } else {//新增 + $add_tag[] = ['name' => $value['name'], 'order' => $sort]; + $data['pid'] = $pid; + $this->mdCustomerTag->add($data); + } + } + } + if (false !== strpos($_SERVER['HTTP_HOST'], 'admin.liche.cn') && !$re['tag_type']) {//正试才能修改企业标签 + $this->load->library('wx_qyapi', ['app' => 'lichene']); + if (count($add_tag)) {//新增标签 + if (!$re['qy_id']) { + $add_corp_tag = ['url' => 'add_corp_tag', 'group_id' => '', 'group_name' => $re['name'] + , 'order' => $re['sort'], 'tag' => $add_tag]; + } else { + $add_corp_tag = ['url' => 'add_corp_tag', 'group_id' => $re['qy_id'], 'tag' => $add_tag]; + } + $re_yq = $this->wx_qyapi->get_external_contact($add_corp_tag); + if ($re_yq['errcode'] == 0) { + if (!$re['qy_id'] && $re_yq['tag_group']['group_id']) {//更新企微标签组id + $this->mdCustomerTag->update(['qy_id' => $re_yq['tag_group']['group_id']], ['id' => $pid]); + } + foreach ($re_yq['tag_group']['tag'] as $key => $value) { + if ($value['id']) {//更新企微标签id + $this->mdCustomerTag->update(['qy_id' => $value['id']], ['pid' => $pid, 'name' => $value['name']]); + } + } + } + } else if (count($edit_tag)) {//编辑标签 + foreach ($edit_tag as $key => $value) { + $this->wx_qyapi->get_external_contact(['url' => 'edit_corp_tag', 'id' => $value['id'] + , 'name' => $value['name'], 'order' => $value['order']]); + } + } else if (count($del_tag)) {//删除标签 + foreach ($del_tag as $key => $value) { + $this->wx_qyapi->get_external_contact(['url' => 'del_corp_tag', 'tag_id' => $value]); + } + } + //$this->data = ['options' => $options, 'add_tag' => $add_tag, 'edit_tag' => $edit_tag, 'del_tag' => $del_tag]; + } + return $this->show_json(SYS_CODE_SUCCESS, '保存成功'); + } + + function edit_status() + { + $id = $this->input->post('id'); + $stauts = intval($this->input->post('status')); + if (!$id) { + $this->show_json(SYS_CODE_FAIL, '参数错误'); + } + $this->mdCustomerTag->update(['status' => $stauts], ['id' => $id]); + return $this->show_json(SYS_CODE_SUCCESS, '操作成功'); + } + + //批量操作(默认修改状态) + public function batch() + { + + } + + //导出数据列表 + public function export() + { + + } +} \ No newline at end of file diff --git a/admin/views/receiver/tag/edit.php b/admin/views/receiver/tag/edit.php new file mode 100644 index 00000000..bea5d10e --- /dev/null +++ b/admin/views/receiver/tag/edit.php @@ -0,0 +1,43 @@ +
+ + +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ + 越大越靠前 +
+
+
+ +
+
\ No newline at end of file diff --git a/admin/views/receiver/tag/lists.php b/admin/views/receiver/tag/lists.php new file mode 100644 index 00000000..fa8336aa --- /dev/null +++ b/admin/views/receiver/tag/lists.php @@ -0,0 +1,267 @@ +
+ +
+
+ +
+
共有条数据
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
名称标签选项类型显示排序状态
+ 编辑选项 + 编辑标签 + + 关闭 + + + 开启 + + + 删除 + +
+ +
+
+
+
+
+ +
+
+
+ \ No newline at end of file diff --git a/api/controllers/wxapp/app/City.php b/api/controllers/wxapp/app/City.php index bdd87646..363a8b03 100644 --- a/api/controllers/wxapp/app/City.php +++ b/api/controllers/wxapp/app/City.php @@ -73,15 +73,20 @@ class City extends Wxapp protected function get_lists() { - $city_lists = [430000, 350000]; //开发城省份 湖南 福建 + + if ($this->session['province_id']) { + $province_lists[] = $this->session['province_id']; + } else { + $province_lists = [430000, 350000]; //开发城省份 湖南 福建 + } $lists = []; - foreach ($city_lists as $item) { + foreach ($province_lists as $item) { $where['province_id'] = $item; $rows = $this->mdArea->select_groupby('city_id', $where, '', 0, 100, 'city_id,city_name,id,province_name'); $children = []; foreach ($rows as $k => $item2) { - if(!$k){ - $children[] =['city_id' => 0, 'name' => '全省']; + if (!$k) { + $children[] = ['city_id' => 0, 'name' => '全省']; } $children[] = ['city_id' => $item2['city_id'], 'name' => $item2['city_name']]; } @@ -89,7 +94,7 @@ class City extends Wxapp } $data = [ 'area_list' => $lists, - 'default_area_id' => [430000, 0] + 'default_area_id' => [$province_lists[0], 0] ]; return $data; } @@ -108,8 +113,8 @@ class City extends Wxapp switch ($type) { case 'city': !$pid && $pid = 350000;//默认福建 - if($this->biz_id){ - $biz = $this->biz_model->get(['id'=>$this->biz_id]); + if ($this->biz_id) { + $biz = $this->biz_model->get(['id' => $this->biz_id]); $biz['province_id'] && $pid = $biz['province_id']; } $res = $this->mdArea->select(['province_id' => $pid], null, null, null, 'distinct(city_id), city_name'); diff --git a/api/controllers/wxapp/licheb/Cusorder.php b/api/controllers/wxapp/licheb/Cusorder.php index ce94de68..545bec48 100644 --- a/api/controllers/wxapp/licheb/Cusorder.php +++ b/api/controllers/wxapp/licheb/Cusorder.php @@ -28,6 +28,7 @@ class Cusorder extends Wxapp $this->load->model("biz/biz_model"); $this->load->library('receiver/customers_entity'); + $this->load->library('receiver/orders_entity'); $this->load->library('receiver/order_datas_entity'); $this->biz_id = $this->get_biz_id(); } @@ -112,6 +113,8 @@ class Cusorder extends Wxapp //更新客户 $this->customers_model->update(['status' => 2, 'order_time' => date('Y-m-d H:i:s')], ['id' => $cus_id]); $this->customers_entity->add_log($cus_id, $this->session['uid'], $this->session['uname'], '生成订单', 6); + //数据提交汽车之家 + $this->orders_entity->post_auto($o_id); return ['id' => $o_id]; } else { throw new Exception('创建失败', ERR_PARAMS_ERROR); diff --git a/api/controllers/wxapp/licheb/Customers.php b/api/controllers/wxapp/licheb/Customers.php index f2fb2ec4..08dc43a0 100644 --- a/api/controllers/wxapp/licheb/Customers.php +++ b/api/controllers/wxapp/licheb/Customers.php @@ -861,7 +861,7 @@ class Customers extends Wxapp $lists = []; if ($count) { $fileds = 'id,name,admin_id,mobile,level,car_json,is_top,cf_title,brand_id,cont_time,c_time,if_defeat - ,of_id,of2_id,wxqy,status,biz_id,cs_biz_id,county_id'; + ,of_id,of2_id,wxqy,status,biz_id,cs_biz_id,county_id,cid'; $rows = $this->customers_model->select($where, $orderby, $page, $size, $fileds); $lists = $this->listCustomerField(['rows' => $rows, 'biz_type' => $biz_type, 'group_id' => $group_id]); } @@ -935,6 +935,7 @@ class Customers extends Wxapp 'tip' => $tip, 'level' => $val['level'], 'reassign' => $val['cs_biz_id'] > 0 ? '他店改派' : '', + 'cid' => $val['cid'], ]; } return $lists; @@ -1150,10 +1151,10 @@ class Customers extends Wxapp } if ($count) { $fileds = 'id,name,admin_id,mobile,level,car_json,is_top,cf_title,brand_id,sales_id,cont_time,c_time,if_defeat - ,of_id,of2_id,wxqy,status,biz_id,cs_biz_id,county_id'; + ,of_id,of2_id,wxqy,status,biz_id,cs_biz_id,county_id,cid'; if ($visit == 1) { $fileds = 'a.id,a.name,a.admin_id,a.mobile,a.level,a.is_top,a.cont_time,a.c_time,a.if_defeat,a.cf_title - ,a.of_id,a.of2_id,a.status,a.biz_id,a.county_id'; + ,a.of_id,a.of2_id,a.status,a.biz_id,a.county_id,cid'; $rows = $this->mdCustomerVisitData->select_visit($where, 'a.id desc', $page, $size, $fileds); $lists = $this->listCustomerField(['rows' => $rows, 'biz_type' => $biz_type, 'group_id' => $group_id]); } else if ($visit == 4) { diff --git a/api/controllers/wxapp/licheb/User.php b/api/controllers/wxapp/licheb/User.php index ac3a1fe1..3338369d 100644 --- a/api/controllers/wxapp/licheb/User.php +++ b/api/controllers/wxapp/licheb/User.php @@ -577,6 +577,7 @@ class User extends Wxapp $this->session['group_id'] = $user['group_id1']; $this->session['biz_id'] = $user['biz_id1']; $this->session['city_id'] = $user['city_id1']; + $this->session['province_id'] = $user['province_id1']; $this->session['group_id_type'] = $group_id_type; $this->session['new_biz_id'] = intval($user['biz_id1']); @@ -584,6 +585,7 @@ class User extends Wxapp $this->session['group_id'] = $user['group_id']; $this->session['biz_id'] = $user['biz_id']; $this->session['city_id'] = $user['city_id']; + $this->session['province_id'] = $user['province_id']; $this->session['group_id_type'] = ''; $this->session['new_biz_id'] = ''; diff --git a/common/helpers/comm_helper.php b/common/helpers/comm_helper.php index f7cd2c5a..e7d21185 100644 --- a/common/helpers/comm_helper.php +++ b/common/helpers/comm_helper.php @@ -1162,7 +1162,7 @@ if (!function_exists('myTrim')) { if (!function_exists('is_product')) { function is_product() { - if (false !== strpos($_SERVER['HTTP_HOST'], 'dev') || false !== strpos($_SERVER['HTTP_HOST'], 'test')) { //dev 测试 + if (false !== strpos($_SERVER['HTTP_HOST'], 'ss')) { //dev 测试 return false; } else { // 正式 return true; diff --git a/common/libraries/CarHome.php b/common/libraries/CarHome.php index fb5c686a..7055bef3 100644 --- a/common/libraries/CarHome.php +++ b/common/libraries/CarHome.php @@ -9,16 +9,24 @@ class CarHome const METHOD_GET = 'GET'; const METHOD_POST = 'POST'; - const SAVE_ORDER = 'https://ahohcrm-test.autohome.com.cn/api/community/outOrder/saveOrderInfo'; -// const SAVE_ORDER = 'http://127.0.0.1:8000/user/cc'; + const SAVE_ORDER = 'outOrder/saveOrderInfo'; - const KEY = 'ahoh-crm-apiA0EoJwyA'; - const SECRET = 'lDMDpzflU3gj'; + private $base_url = 'https://apiahoh.autohome.com.cn/'; + private $key = 'ahoh-crm-apiA0EoJwyA'; + private $secret = 'lDMDpzflU3gj'; + private $storeId = 3479; //之家空间站ID + private $outSystemCode = 1001;//外部系统编号 1001 爱能 public function __construct() { $this->client = new Client(); + if (!is_product()) { //测试环境 + $this->base_url = 'https://ahohcrm-test.autohome.com.cn/api/community/'; + $this->storeId = 50; + } + } + //autohomeOrderId Long 否 之家订单id 更新时必传 //outSystemCode int 是 外部系统编号 1001 爱能 //buyerType int 是 购⻋主体 1个⼈ 2公户 //buyerName String 是 客户姓名 不超过50个字符 @@ -64,9 +72,11 @@ class CarHome public function saveOrder($data) { try { - $data['outSystemCode'] = 1001; + $post_url = $this->base_url . self::SAVE_ORDER; + $data['outSystemCode'] = $this->outSystemCode; + $data['specId'] = $this->storeId; debug_log("post_data:" . json_encode($data, JSON_UNESCAPED_UNICODE)); - $req = $this->send(self::SAVE_ORDER, $data, self::METHOD_POST); + $req = $this->send($post_url, $data, self::METHOD_POST); debug_log("result:" . $req); $reqArr = json_decode($req, true); if (isset($reqArr['returncode']) && intval($reqArr['returncode']) == 0) { @@ -85,7 +95,7 @@ class CarHome */ public function authorization() { - $res = "Basic " . base64_encode(self::KEY . ':' . self::SECRET); + $res = "Basic " . base64_encode($this->key . ':' . $this->secret); return $res; } diff --git a/common/libraries/receiver/Orders_entity.php b/common/libraries/receiver/Orders_entity.php new file mode 100644 index 00000000..163174d9 --- /dev/null +++ b/common/libraries/receiver/Orders_entity.php @@ -0,0 +1,73 @@ +ci = &get_instance(); + $this->ci->load->model('receiver/receiver_customers_model', 'customers_model'); + + $this->ci->load->model('receiver/order/receiver_orders_model', 'orders_model'); + $this->ci->load->model('auto/auto_cars_model'); + $this->ci->load->library('carHome'); + } + + /** + * 订单数据提交汽车之家 + * @param $oid + * @return array|void + */ + public function post_auto($oid) + { + $order_row = $this->ci->orders_model->get($oid); + if (!$order_row) { + return ['code' => 0, 'msg' => '订单不存在']; + } + return ['code' => 0, 'msg' => '订单不存在']; + $post_data = [ + 'buyerType' => $order_row['main_type'] ? 2 : 1, + 'buyerName' => $order_row['name'], + 'buyerPhone' => $order_row['mobile'], + 'specId' => 67998, + 'storeId' => 50, + 'outOrderId' => create_order_no(), + 'outLeadId' => 2, + 'outOrderCreateTime' => date('Y-m-d H:i:s', time()), + 'registerCityId' => 433100, + ]; + $data['autohomeOrderId'] = 20; +// $data['invoiceAmount'] = 7000; +// $data['isRegisterInStore'] = 1; +// $data['registerAmount'] = 700; +// $data['isInsured'] = 1; +// $data['isLoan'] = 1; +// $data['loanAmount'] = 500000; +// $data['loanPeriods'] = 36; +// $data['monthlyPayment'] = 3000; +// $data['carryCarDate'] = '2024-06-02'; +// $data['payDate'] = '2024-05-27'; +// $data['contractImg'] = $img; +// $data['invoiceImg'] = $img; +// $data['payImg'] = $img; +// $data['outColor'] = '黑色'; +// $data['inColor'] = '蓝色'; +// $data['deliveryDate'] = '2024-06-15'; +// $data['downpaymentType'] = 1; +// $data['confirmAmount'] = 4000; +// $data['discountAmount'] = 0; +// $data['isLocalInvoice'] = 0; +// $data['idCardNo'] = '350522198910148675'; +// $data['carDocumentImg'] = $img; +// $data['insuranceImg'] = $img; +// $data['deliveryPhoto'] = $img; +// $data['priceRightsConfirmDoc'] = $img; + $req = $this->ci->carhome->saveOrder($post_data); + } +} + +?>