20240603
This commit is contained in:
@@ -0,0 +1,275 @@
|
||||
<?php
|
||||
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Tag extends HD_Controller
|
||||
{
|
||||
private $tabAry = [
|
||||
1 => ['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()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<form id="vue-edit" class="am-form am-form-horizontal" action="<?= $showInfo['url'] ?>" data-auto="true"
|
||||
method="post" style="width: 90%;padding-top: 10px" onsubmit="return false">
|
||||
<input type="hidden" value="<?= $showInfo['id'] ?>" name="id"/>
|
||||
<input type="hidden" value="<?= $showInfo['tag_type'] ?>" name="tag_type"/>
|
||||
<div class="am-form-group">
|
||||
<label class="am-para-label">名称:</label>
|
||||
<div class="am-para-input">
|
||||
<input type="text" placeholder="输入名称" value="<?= $showInfo['name'] ?>" name="name"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="am-form-group">
|
||||
<label class="am-para-label">选项类型:</label>
|
||||
<div class="am-para-input" style="width: 30%">
|
||||
<select name="type">
|
||||
<? foreach ($showInfo['typeAry'] as $key => $value) { ?>
|
||||
<option value="<?= $key ?>" <?= $key == $showInfo['type'] ? 'selected' : '' ?>
|
||||
><?= $value ?></option>
|
||||
<? } ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="am-form-group">
|
||||
<label class="am-para-label">显示:</label>
|
||||
<div class="am-para-input" style="width: 30%">
|
||||
<select name="show">
|
||||
<? foreach ($showInfo['showAry'] as $key => $value) { ?>
|
||||
<option value="<?= $key ?>" <?= $key == $showInfo['show'] ? 'selected' : '' ?>
|
||||
><?= $value ?></option>
|
||||
<? } ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="am-form-group">
|
||||
<label class="am-para-label">排序:</label>
|
||||
<div class="am-para-input" style="width: 30%">
|
||||
<input type="text" placeholder="输入排序" value="<?= $showInfo['sort'] ?>" name="sort"/>
|
||||
<small class="text-muted">越大越靠前</small>
|
||||
</div>
|
||||
</div>
|
||||
<div class="am-form-group" style="margin-bottom: 2rem">
|
||||
<button class="am-btn ml20 am-btn-sm am-btn-success w100" style="margin-left: 3.5rem" type="submit">保存</button>
|
||||
</div>
|
||||
</form>
|
||||
@@ -0,0 +1,267 @@
|
||||
<div class="bs-example bs-example-tabs" data-example-id="togglable-tabs" style="font-size:15px;margin-bottom: 20px;">
|
||||
<ul class="nav nav-tabs" role="tablist">
|
||||
<? foreach ($showInfo['tabAry'] as $key => $val) { ?>
|
||||
<li role="presentation"
|
||||
class="<?= strlen($params['tab']) && $params['tab'] == $key ? 'active' : '' ?>">
|
||||
<a href="javascript:void (0);" data-open="<?= $val['url'] ?>">
|
||||
<?= $val['title'] ?>
|
||||
</a>
|
||||
</li>
|
||||
<? } ?>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="coms-table-wrap mt10">
|
||||
<form id="vue-app" class=" form-search coms-table-hd clearfix no-border" onsubmit="return false"
|
||||
action="receiver/tag">
|
||||
<input type="hidden" value="<?=$params['tag_type']?>" name="tag_type">
|
||||
<div class="am-form am-form-horizontal">
|
||||
<div class="am-form-group fl">
|
||||
<label class="am-para-label w80">类型:</label>
|
||||
<div class="am-para-inline w100">
|
||||
<select name="type">
|
||||
<option value="">选择类型</option>
|
||||
<? foreach ($showInfo['typeAry'] as $key => $value) { ?>
|
||||
<option value="<?= $key ?>" <?= $key == $params['type'] ? 'selected' : '' ?>
|
||||
><?= $value ?></option>
|
||||
<? } ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="am-form-group fl">
|
||||
<label class="am-para-label w80">显示:</label>
|
||||
<div class="am-para-inline w100">
|
||||
<select name="show">
|
||||
<option value="">选择显示</option>
|
||||
<? foreach ($showInfo['showAry'] as $key => $value) { ?>
|
||||
<option value="<?= $key ?>" <?= strlen($params['show']) && $key == $params['show'] ? 'selected' : '' ?>
|
||||
><?= $value ?></option>
|
||||
<? } ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="am-form-group fl">
|
||||
<label class="am-para-label w80">状态:</label>
|
||||
<div class="am-para-inline w100">
|
||||
<select name="status">
|
||||
<option value="">选择状态</option>
|
||||
<? foreach ($showInfo['statusAry'] as $key => $value) { ?>
|
||||
<option value="<?= $key ?>" <?= strlen($params['status']) && $key == $params['status'] ? 'selected' : '' ?>
|
||||
><?= $value ?></option>
|
||||
<? } ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="am-form-group fl ml30">
|
||||
<div class="am-form-group fl ml10">
|
||||
<button type="submit" class="am-btn am-btn-success am-btn-sm w100">搜索</button>
|
||||
</div>
|
||||
<? if ($params['tag_type'] < 2) { ?>
|
||||
<div class="am-form-group fl ml10">
|
||||
<button data-modal="/receiver/tag/get?tag_type=<?=$params['tag_type']?>" type="button" data-title="新增标签"
|
||||
class="am-btn am-btn-success am-btn-sm w100">
|
||||
新增
|
||||
</button>
|
||||
</div>
|
||||
<? } ?>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<div class="coms-table-bd" id="vue-show">
|
||||
<div class="fr">共有<?= $pager['totle'] ?>条数据</div>
|
||||
<table class="am-table am-table-bordered">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="25%"><span>名称</span></th>
|
||||
<th width="45%"><span>标签选项</span></th>
|
||||
<th width="7%"><span>类型</span></th>
|
||||
<th width="5%"><span>显示</span></th>
|
||||
<th width="5%"><span>排序</span></th>
|
||||
<th width="5%"><span>状态</span></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php if ($lists) {
|
||||
foreach ($lists as $v) { ?>
|
||||
<tr>
|
||||
<td><?= $v['name'] ?></td>
|
||||
<td><?= $v['options'] ?></td>
|
||||
<td><?= $v['type_name'] ?></td>
|
||||
<td><?= $v['show_name'] ?></td>
|
||||
<td><?= $v['sort'] ?></td>
|
||||
<td><?= $v['status_name'] ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="6" class="align-r">
|
||||
<a href="javascript:void(0);" @click="optionsModal(<?= $v['id'] ?>,'<?= $v['name'] ?>')"
|
||||
class="am-btn am-btn-primary am-btn-xs">编辑选项</a>
|
||||
<a href="javascript:void(0);" data-modal="/receiver/tag/get?id=<?= $v['id'] ?>"
|
||||
data-title="编辑标签" class="am-btn am-btn-primary am-btn-xs">编辑标签</a>
|
||||
<? if ($v['status'] == 1 && $params['tag_type'] < 2) { ?>
|
||||
<a data-ajax="post" data-action="/receiver/tag/edit_status"
|
||||
class="am-btn am-btn-danger am-btn-xs"
|
||||
data-params-id="<?= $v['id'] ?>" data-params-status="0">关闭</a>
|
||||
<?
|
||||
} ?>
|
||||
<? if ($v['status'] == 0 && $params['tag_type'] < 2) { ?>
|
||||
<a data-ajax="post" data-action="/receiver/tag/edit_status"
|
||||
class="am-btn am-btn-success am-btn-xs"
|
||||
data-params-id="<?= $v['id'] ?>" data-params-status="1">开启</a>
|
||||
<? } ?>
|
||||
<? if ($params['tag_type'] < 2) { ?>
|
||||
<a data-ajax="post" data-action="/receiver/tag/del" class="am-btn am-btn-danger am-btn-xs"
|
||||
data-params-id="<?= $v['id'] ?>">删除</a>
|
||||
<? } ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php }
|
||||
} ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<div id="options-modal" style="display: none;">
|
||||
<table class="table table-hover table-middle" style="table-layout:fixed">
|
||||
<colgroup>
|
||||
<col width="65%">
|
||||
<col width="15%">
|
||||
<col width="">
|
||||
</colgroup>
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="text-center">标题</th>
|
||||
<th class="text-center">排序</th>
|
||||
<th class="text-right">
|
||||
<a href="javascript:" style="margin-top: 2px;" class="btn btn-primary btn-sm"
|
||||
@click='addOptions()'>添加</a>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<template v-for="(item,index) in optionsList">
|
||||
<tr v-if="item.status==1">
|
||||
<td class="text-center">
|
||||
<input :id="'name_'+index" @blur="editName(index)" class="form-control"
|
||||
v-model="item.name" placeholder="请输入标题"></td>
|
||||
<td class="text-center">
|
||||
<input :id="'group_name_'+index" @blur="editGroupName(index)" class="form-control"
|
||||
v-model="item.sort" type="number" placeholder="请输入排序值">
|
||||
</td>
|
||||
<td class="text-right">
|
||||
<a href="javascript:void(0);" style="margin-top:2px;"
|
||||
class="btn btn-danger btn-sm" @click='delOptions(index)'>删除</a>
|
||||
</td>
|
||||
</tr>
|
||||
</template>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="coms-table-ft clearfix">
|
||||
<div class="hander am-form">
|
||||
</div>
|
||||
<div class="coms-pagination fr mr20">
|
||||
<?php page_view($pager) ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
var vue_obj;
|
||||
$(function () {
|
||||
vue_obj = new Vue({
|
||||
el: '#vue-show',
|
||||
data: {
|
||||
optionsList: [],
|
||||
},
|
||||
mounted: function () {
|
||||
},
|
||||
methods: {
|
||||
optionsModal: function (id, name) {
|
||||
layer.open({
|
||||
type: 1,
|
||||
area: ['50%', '50%'], //宽高
|
||||
content: $('#options-modal'),
|
||||
title: '编辑【' + name + '】选项',
|
||||
shade: false,
|
||||
btn: ['保存', '取消'],
|
||||
yes: function (index) {
|
||||
$.ajax({
|
||||
url: '/receiver/tag/edit_options',
|
||||
type: 'post',
|
||||
dataType: 'json',
|
||||
data: {id: id, options: that.optionsList},
|
||||
beforeSend: function () {
|
||||
layer.load(1, {
|
||||
shade: [0.1, '#fff'] //0.1透明度的白色背景
|
||||
});
|
||||
},
|
||||
success: function (data) {
|
||||
if (data['code']) {
|
||||
layer.msg(data.msg, {
|
||||
icon: 1,
|
||||
time: 2000
|
||||
}, function () {
|
||||
$.form.reload();
|
||||
});
|
||||
} else {
|
||||
layer.msg(data.msg, {icon: 2});
|
||||
}
|
||||
},
|
||||
complete: function () {
|
||||
layer.closeAll('loading');
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
var that = this;
|
||||
$.ajax({
|
||||
url: '/receiver/tag/get_options',
|
||||
type: 'post',
|
||||
dataType: 'json',
|
||||
data: {id: id},
|
||||
beforeSend: function () {
|
||||
},
|
||||
success: function (re) {
|
||||
if (re.code) {
|
||||
that.optionsList = re.data.lists;
|
||||
} else {
|
||||
layer.msg(re.msg, {icon: 2});
|
||||
}
|
||||
},
|
||||
complete: function () {
|
||||
}
|
||||
});
|
||||
},
|
||||
addOptions: function () {
|
||||
var that = this;
|
||||
that.optionsList.push({id: 0, name: '', status: 1, qy_id: '', sort: 50});
|
||||
},
|
||||
delOptions: function (index) {
|
||||
var that = this;
|
||||
if (that.optionsList[index]['id'] > 0) {
|
||||
that.optionsList[index]['status'] = -1;
|
||||
} else {
|
||||
that.optionsList.splice(index, 1);
|
||||
}
|
||||
},
|
||||
editName: function (index) {
|
||||
var name = $("#name_" + index).val();
|
||||
if (name == '') {
|
||||
layer.msg("标题不能为空!", {icon: 2});
|
||||
return false;
|
||||
}
|
||||
},
|
||||
// 修改排序
|
||||
editGroupName: function (index) {
|
||||
var order_view = $("#group_name_" + index).val();
|
||||
if (order_view == '') {
|
||||
layer.msg("排序值不能为空!", {icon: 2});
|
||||
return false;
|
||||
}
|
||||
this.optionsList.sort(function (a, b) {
|
||||
return b.sort - a.sort;
|
||||
})
|
||||
},
|
||||
},
|
||||
watch: {}
|
||||
});
|
||||
<?php page_script($pager) ?>
|
||||
});
|
||||
</script>
|
||||
@@ -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');
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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'] = '';
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 订单
|
||||
*/
|
||||
class Orders_entity
|
||||
{
|
||||
private $ci;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->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);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user