修复已知BUG

pull/1/head
Michael_xu 3 years ago
parent 25706b1136
commit 7ae1f9db4a

@ -183,7 +183,13 @@ class Field extends ApiCommon
if ($errorMessage) return resultArray(['error' => $errorMessage]);
# 兼容前端11.*.*版本的删除条件处理,通过比较差异,来确定谁被前端给删除了 todo 这段代码需要写在新增上面,不然会把新增的给删除掉
$oldFieldIds = Db::name('admin_field')->where('types', $types)->column('field_id');
// $oldFieldIds = Db::name('admin_field')->where('types', $types)->column('field_id'); 新增自定义字段时 成交状态被删除
if($types != 'crm_customer'){
$oldFieldIds = Db::name('admin_field')->where('types', $types)->column('field_id');
}else{
$oldFieldIds = Db::name('admin_field')->where('types', $types)->where(['field'=>['not in', ['deal_status']]])->column('field_id');
}
$deleteIds = array_diff($oldFieldIds, $fieldIds);
foreach ($deleteIds AS $key => $value) {
if (!in_array($value, $delParam)) $delParam[] = $value;

@ -61,6 +61,11 @@ class Index extends ApiCommon
if ($value['field'] == 'deal_status') $field_arr[$key]['form_type'] = 'deal_status';
if ($value['field'] == 'check_status') $field_arr[$key]['form_type'] = 'check_status';
if ($param['types'] == 'crm_visit' && $value['field'] == 'owner_user_id') $field_arr[$key]['name'] = '回访人';
if ($value['field'] == 'supplier_id') $field_arr[$key]['form_type'] = 'text';
if ($value['field'] == 'purchase_id') $field_arr[$key]['form_type'] = 'text';
if ($value['field'] == 'sale_id') $field_arr[$key]['form_type'] = 'text';
if ($value['field'] == 'collection_object') $field_arr[$key]['form_type'] = 'text';
}
if(in_array($param['types'],['crm_customer','crm_customer_pool','crm_contacts','crm_business','crm_contract','crm_receivables'])){
$field=[['field'=>'team_id','name'=>'相关团队','form_type'=>'text','setting'=>[]]];

@ -399,15 +399,15 @@ class Excel extends Common
}
// 排队中
// if (!$queue->canExec()) {
// return resultArray([
// 'data' => [
// 'page' => -2,
// 'export_queue_index' => $export_queue_index,
// 'info' => $queue->error
// ]
// ]);
// }
if (!$queue->canExec()) {
return resultArray([
'data' => [
'page' => -2,
'export_queue_index' => $export_queue_index,
'info' => $queue->error
]
]);
}
// 没有临时文件名,代表第一次导出,生成临时文件名称,并写入表头数据
if ($temp_file === null) {
@ -984,8 +984,7 @@ class Excel extends Common
}
} else {
if ($types == 'crm_customer' && !empty($param['pool_id'])) {
if (!in_array($param['create_user_id'], trim(stringToArray($owner), ',')) && $param['create_user_id'] != 1) {
if (in_array($param['create_user_id'], stringToArray($owner)) || $param['create_user_id'] == 1) {
$data = array_merge($data, $default_data);
$data['excel'] = 1;
if (!$resData = $dataModel->createData($data)) {
@ -1295,10 +1294,10 @@ class Excel extends Common
//获取总行数
$sheetCount = $ExcelObj->getSheet(0)->getHighestRow();
// if ($sheetCount > 2002) {
// if ($sheetCount > 2002) {
// $this->error = '单文件一次最多导入2000条数据';
// return false;
// }
// return false;
// }
//读取表头
$excelHeader = $sheetContent[1];
unset($sheetContent[0]);

@ -1855,7 +1855,7 @@ class Field extends Model
$fieldArr = $this
->where($where)
->field(['field', 'name', 'form_type', 'is_hidden'])
->order('field_id', 'asc')
->order('order_id', 'asc')
->select();
$res = [];

@ -138,7 +138,7 @@ class Customer extends ApiCommon
$sql[] = $customerModel->getAddDealSql($whereArr);
}
$sql = implode(' UNION ALL ', $sql);
p($sql);
$list = queryCache($sql);
return resultArray(['data' => $list]);
}

@ -400,10 +400,130 @@ function advancedQuery($param, $m = '', $c = '', $a = '')
$result[$c . $key] = ['neq', ''];
}
}
// 模块、审核状态、成交状态、产品分类、单行文本、多行文本、网址、手机、邮箱、下拉框、布尔值、多选、定位、创建人、负责人
if (isset($value['form_type']) && in_array($value['form_type'], ['module', 'check_status', 'deal_status', 'category', 'text', 'textarea', 'mobile', 'email', 'select', 'boolean_value', 'checkbox', 'location', 'website','user',])) {
$result[$c . $key] = advancedQueryFormatForCommon($value['value'], $value['condition'], $value['form_type'], $key);
$res = advancedQueryFormatForCommon($value['value'], $value['condition'], $value['form_type'], $key);
if($key == 'order_id'){
$arr = [];
if($c == 'outbound.'){
$retreatOutboundIds = db('jxc_retreat')
->alias('a')
->join('jxc_outbound b','a.retreat_id = b.order_id')
->where('a.order_number', [$res[0], $res[1]])
->where('b.outbound_type', '采购退货出库')
// ->fetchSql()
->column('outbound_id');
$saleOutboundIds = db('jxc_sale')
->alias('a')
->join('jxc_outbound b','a.sale_id = b.order_id')
->where('a.order_number', [$res[0], $res[1]])
->where('b.outbound_type', '销售出库')
// ->fetchSql()
->column('outbound_id');
$arr = empty($retreatOutboundIds) ? $saleOutboundIds : array_merge($retreatOutboundIds,$saleOutboundIds);
$result[$c . 'outbound_id'] = ['in', $arr];
}elseif ($c == 'receipt.') {
$purchaseOutboundIds = db('jxc_purchase')
->alias('a')
->join('jxc_receipt b','a.purchase_id = b.order_id')
->where('a.order_number', [$res[0], $res[1]])
->where('b.receipt_type', '采购入库')
// ->fetchSql()
->column('b.receipt_id');
$salereturnOutboundIds = db('jxc_salereturn')
->alias('a')
->join('jxc_receipt b','a.salereturn_id = b.order_id')
->where('a.order_number', [$res[0], $res[1]])
->where('b.receipt_type', '销售退货入库')
// ->fetchSql()
->column('b.receipt_id');
$arr = empty($purchaseOutboundIds) ? $salereturnOutboundIds : array_merge($purchaseOutboundIds,$salereturnOutboundIds);
$result[$c . 'receipt_id'] = ['in', $arr];
}
}else if($key == 'related_id'){
$arr = [];
if($c == 'collection.'){
$retreatOutboundIds = db('jxc_retreat')
->alias('a')
->join('jxc_collection b','a.retreat_id = b.related_id')
->where('a.order_number', [$res[0], $res[1]])
->where('b.collection_type', '采购退货')
// ->fetchSql()
->column('collection_note_id');
$saleOutboundIds = db('jxc_sale')
->alias('a')
->join('jxc_collection b','a.sale_id = b.related_id')
->where('a.order_number', [$res[0], $res[1]])
->where('b.collection_type', '销售回款')
// ->fetchSql()
->column('collection_note_id');
$arr = empty($retreatOutboundIds) ? $saleOutboundIds : array_merge($retreatOutboundIds,$saleOutboundIds);
$result[$c . 'collection_note_id'] = ['in', $arr];
}elseif ($c == 'payment.') {
$purchaseOutboundIds = db('jxc_purchase')
->alias('a')
->join('jxc_payment b','a.purchase_id = b.related_id')
->where('a.order_number', [$res[0], $res[1]])
->where('b.payment_type', '采购')
// ->fetchSql()
->column('b.payment_note_id');
$salereturnOutboundIds = db('jxc_salereturn')
->alias('a')
->join('jxc_payment b','a.salereturn_id = b.related_id')
->where('a.order_number', [$res[0], $res[1]])
->where('b.payment_type', '销售退货')
// ->fetchSql()
->column('b.payment_note_id');
$arr = empty($purchaseOutboundIds) ? $salereturnOutboundIds : array_merge($purchaseOutboundIds,$salereturnOutboundIds);
$result[$c . 'payment_note_id'] = ['in', $arr];
}
}else if($key == 'collection_object'){
$arr = [];
if($c == 'collection.'){
$supplierOutboundIds = db('jxc_supplier')
->alias('a')
->join('jxc_collection b','a.supplier_id = b.collection_object')
->where('a.supplier_name', [$res[0], $res[1]])
->where('b.collection_type', '采购退货')
// ->fetchSql()
->column('collection_note_id');
$customerOutboundIds = db('crm_customer')
->alias('a')
->join('jxc_collection b','a.customer_id = b.collection_object')
->where('a.name', [$res[0], $res[1]])
->where('b.collection_type', '销售回款')
// ->fetchSql()
->column('collection_note_id');
$arr = empty($supplierOutboundIds) ? $customerOutboundIds : array_merge($supplierOutboundIds,$customerOutboundIds);
$result[$c . 'collection_note_id'] = ['in', $arr];
}elseif ($c == 'payment.') {
$supplierOutboundIds = db('jxc_supplier')
->alias('a')
->join('jxc_payment b','a.supplier_id = b.collection_object')
->where('a.supplier_name', [$res[0], $res[1]])
->where('b.payment_type', '采购')
// ->fetchSql()
->column('b.payment_note_id');
$customerOutboundIds = db('crm_customer')
->alias('a')
->join('jxc_payment b','a.customer_id = b.collection_object')
->where('a.name', [$res[0], $res[1]])
->where('b.payment_type', '销售退货')
// ->fetchSql()
->column('b.payment_note_id');
$arr = empty($supplierOutboundIds) ? $customerOutboundIds : array_merge($supplierOutboundIds,$customerOutboundIds);
$result[$c . 'payment_note_id'] = ['in', $arr];
}
// }else if($key == 'sp_data_value'){
// foreach ($res[1] as $key => $v) {
// $arr[] = '%'.$v.'%';
// }
// $w['sp_data_value'] = ['like', $arr, 'OR'];
// $product_ids = db('jxc_product')->where($w)->fetchSql()->column('product_id');
// $result[$c . 'sp_data_value'] = [$res[0], $product_ids];
}else{
$result[$c . $key] = advancedQueryFormatForCommon($value['value'], $value['condition'], $value['form_type'], $key);
}
}
// 日期、日期时间、数字、货币、百分数、下次联系时间
@ -459,8 +579,34 @@ function advancedQueryParam($prefix, $field, $name)
'business_name' => 'business.',
'contract_name' => 'contract.',
'business_id' => 'business.',
'contacts_id' => 'contacts.'
'contacts_id' => 'contacts.',
'supplier_id' => 'supplier.',
'purchase_id' => 'purchase.',
'sale_id' => 'sale.',
'warehouse_id' => 'warehouse.',
'original_warehouse_id' => 'warehouse.',
'current_warehouse_id' => 'warehouse.',
];
# 处理供应商
if (in_array($field, ['supplier_id'])) {
$prefix = $prefixChange[$field];
$field = 'supplier_name';
}
# 处理仓库
if (in_array($field, ['warehouse_id'])) {
$prefix = $prefixChange[$field];
$field = 'warehouse_name';
}
if (in_array($field, ['original_warehouse_id', 'current_warehouse_id'])) {
$prefix = $prefixChange[$field];
$field = 'warehouse_name';
}
# 采购单、销售单
if (in_array($field, ['purchase_id', 'sale_id'])) {
$prefix = $prefixChange[$field];
$field = 'order_number';
}
// 处理客户名称、联系人名称、商机名称、合同名称字段
if (in_array($field, ['customer_name', 'contacts_name', 'business_name', 'contract_name']) && $name != '合同编号') {
@ -628,9 +774,9 @@ function advancedQueryWhere($condition, $data, $key='')
if ($condition == "in") $result = ['in', $data]; // 等于
if ($condition == 'is') $result = ['in', $data]; // 等于
if ($condition == 'isNot') $result = ['notin', $data]; // 不等于
if ($condition == 'isNot') $result = [['notin', $data],['null'],'OR']; // 不等于
if ($condition == 'contains') $result = ['like', $data, 'OR']; // 包含
if ($condition == 'notContains') $result = ['notlike', $data, 'AND']; // 不包含
if ($condition == 'notContains') $result = [['notlike', $data, 'AND'],['null'],'OR']; // 不包含
if ($condition == 'startWith') $result = ['like', $data, 'OR']; // 开始于
if ($condition == 'endWith') $result = ['like', $data, 'OR']; // 结束于
if ($condition == 'gt') $result = ['gt', $data]; // 大于

@ -200,7 +200,7 @@ class Customer extends ApiCommon
$resPool = db('crm_customer')->alias('customer')->where(['customer_id' => $v])->where($wherePool)->find();
if (!$resPool && !in_array($data['owner_user_id'], $auth_user_ids) && $isDel) {
$isDel = false;
$errorMessage[] = '名称为' . $data['name'] . '的客户删除失败,错误原因:无权操作';
$errorMessage[] = '无权操作';
}
// 公海 (原逻辑,公海仅允许管理员删除,修改为授权,不再限制)
// if ($resPool && !in_array($data['owner_user_id'],$adminId)) {
@ -212,21 +212,22 @@ class Customer extends ApiCommon
$resBusiness = db('crm_business')->where(['customer_id' => $v])->find();
if ($resBusiness) {
$isDel = false;
$errorMessage[] = '名称为' . $data['name'] . '的客户删除失败,错误原因:客户下存在商机,不能删除';
$errorMessage[] = '客户下存在商机,不能删除';
}
}
if ($isDel) {
$resContacts = db('crm_contacts')->where(['customer_id' => $v])->find();
if ($resContacts) {
$isDel = false;
$errorMessage[] = '名称为' . $data['name'] . '的客户删除失败,错误原因:客户下存在联系人,不能删除';
// $errorMessage[] = '名称为' . $data['name'] . '的客户删除失败,错误原因:客户下存在联系人,不能删除';
$errorMessage[] = '客户下存在联系人,不能删除';
}
}
if ($isDel) {
$resContract = db('crm_contract')->where(['customer_id' => $v])->find();
if ($resContract) {
$isDel = false;
$errorMessage[] = '名称为' . $data['name'] . '的客户删除失败,错误原因:客户下存在合同,不能删除';
$errorMessage[] = '客户下存在合同,不能删除';
}
}
if ($isDel) {

@ -954,7 +954,7 @@ class CustomerPoolLogic extends Common
private function getPoolQueryField($poolId)
{
# 自定义字段
$customerFields = db('crm_customer_pool_field_setting')->where('pool_id', $poolId)->column('field_name');
$customerFields = db('crm_customer_pool_field_setting')->where('pool_id', $poolId)->where('is_hidden',0)->column('field_name');
$customerFields[] = 'customer_id';
# 自定增加表别名

@ -109,8 +109,8 @@ class IndexLogic extends Common
$contractLastNum = (int)$resLastCount[3]['count1'] ?: 0;
$businessLastMoneyNum = $resLastCount[2]['count2'] ?: 0;
$contractLastMoneyNum = $resLastCount[3]['count2'] ?: 0;
$receivablesLastMoneyNum = $resLastCount[4]['count'] ?: 0;
$recordLastNum = (int)$resLastCount[5]['count'] ?: 0;
$receivablesLastMoneyNum = $resLastCount[4]['count1'] ?: 0;
$recordLastNum = (int)$resLastCount[5]['count1'] ?: 0;
$data = [];
$data['data']['customerNum'] = $customerNum;
$data['prev']['customerNum'] = $this->getProportion($customerNum, $customerLastNum);
@ -171,7 +171,7 @@ class IndexLogic extends Common
and owner_user_id IN (" . implode(',', $param['contract_auth_user_ids']) . ")
UNION ALL
SELECT
sum(money) AS count,
sum(money) AS count1,
0 count2
FROM 5kcrm_crm_receivables
WHERE create_time BETWEEN " . $param['start_time'] . " AND " . $param['end_time'] . "
@ -179,7 +179,7 @@ class IndexLogic extends Common
and owner_user_id IN (" . implode(',', $param['receivables_auth_user_ids']) . ")
UNION ALL
SELECT
count(1) AS count,
count(1) AS count1,
0 count2
FROM 5kcrm_crm_activity
WHERE create_time BETWEEN " . $param['start_time'] . " AND " . $param['end_time'] . "
@ -890,10 +890,11 @@ class IndexLogic extends Common
$list[$k]['fileList'] = $fileList ?: [];
$list[$k]['imgList'] = $imgList ?: [];
$dataInfo['customerList'] = $relation_list['customerList'] ?: [];
$dataInfo['contactsList'] = $relation_list['contactsList'] ?: [];
$dataInfo['businessList'] = $relation_list['businessList'] ?: [];
$dataInfo['contractList'] = $relation_list['contractList'] ?: [];
$list[$k]['customer_list'] = $relation_list['customerList'] ?: [];
$list[$k]['contacts_list'] = $relation_list['contactsList'] ?: [];
$list[$k]['business_list'] = $relation_list['businessList'] ?: [];
$list[$k]['contract_list'] = $relation_list['contractList'] ?: [];
$list[$k]['business_ids'] = implode(',',array_column($relation_list['businessList'],'name'));
$list[$k]['contacts_ids'] = implode(',',array_column($relation_list['contactsList'],'name'));
$list[$k]['thumb_img'] = $v['thumb_img'] ? getFullPath($v['thumb_img']) : '';
@ -963,10 +964,11 @@ class IndexLogic extends Common
}
$list[$k]['fileList'] = $fileList ?: [];
$list[$k]['imgList'] = $imgList ?: [];
$dataInfo['customerList'] = $relation_list['customerList'] ?: [];
$dataInfo['contactsList'] = $relation_list['contactsList'] ?: [];
$dataInfo['businessList'] = $relation_list['businessList'] ?: [];
$dataInfo['contractList'] = $relation_list['contractList'] ?: [];
$list[$k]['customer_list'] = $relation_list['customerList'] ?: [];
$list[$k]['contacts_list'] = $relation_list['contactsList'] ?: [];
$list[$k]['business_list'] = $relation_list['businessList'] ?: [];
$list[$k]['contract_list'] = $relation_list['contractList'] ?: [];
$list[$k]['thumb_img'] = $v['thumb_img'] ? getFullPath($v['thumb_img']) : '';
$list[$k]['dataInfo'] = $dataInfo ?: [];
}

@ -234,7 +234,7 @@ class Customer extends Common
->orderRaw($order)
// ->fetchSql()
->select();
// p(db('crm_customer')->getLastSql());
$readAuthIds = $userModel->getUserByPer('crm', 'customer', 'read');
$updateAuthIds = $userModel->getUserByPer('crm', 'customer', 'update');
$deleteAuthIds = $userModel->getUserByPer('crm', 'customer', 'delete');
@ -1886,4 +1886,119 @@ class Customer extends Common
return in_array($ownerUserId, $authUserIds);
}
/**
* 客户销售分析
*
* @param $id
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getCustomerSaleStatistics($param, $user_id)
{
$userModel = new \app\admin\model\User();
$type = $param['type'];
unset($param['type']);
# 日期条件
if ($type) {
$timeArr = getTimeByType($type);
$timeData['start_time'] = $timeArr[0];
$timeData['end_time'] = $timeArr[1];
} else {
if (!empty($timeData['start_time'])) $timeData['start_time'] = strtotime($timeData['start_time'] . ' 00:00:00');
if (!empty($timeData['end_time'])) $timeData['end_time'] = strtotime($timeData['end_time'] . ' 23:59:59');
}
if ($param['user_id']) {
$map_user_ids = array($param['user_id']);
} else {
if ($param['structure_id']) {
$map_user_ids = $userModel->getSubUserByStr($param['structure_id'], 2);
}
}
unset($param['user_id']);
# 格式化参数
$request = $this->fmtRequest( $param );
$perUserIds = $userModel->getUserByPer('jxc', 'bi', 'jxcProductPurchaseStatistics'); //权限范围内userIds
$userIds = $map_user_ids ? array_intersect($map_user_ids, $perUserIds) : $perUserIds; //数组交集
$dataCount = db('crm_customer')->alias('a')
->where(['owner_user_id'=>['in', $userIds]])
->count();
$list = db('crm_customer')->alias('a')
->where(['owner_user_id' => ['in', $userIds]])
->limit($request['offset'], $request['length'])
->field('customer_id, name')
->orderRaw('customer_id desc')
->select();
$userIds = implode(',', $userIds);
$prefix = config('database.prefix');
$start_time = date('Y-m-d', $timeData['start_time']);
$end_time = date('Y-m-d', $timeData['end_time']);
$arr = [];
foreach ($list as $key => $value) {
$sql = "SELECT
a.customer_id,
a.`name`,
count(distinct b.sale_id) AS sale_num,
IFNULL(
sum(c.sale_product_number),
0
) AS sale_product_number,
IFNULL(
sum(c.sale_product_subtotal),
0
) AS sale_product_subtotal
FROM
{$prefix}crm_customer as a
INNER JOIN {$prefix}jxc_sale as b ON a.customer_id = b.customer_id
INNER JOIN {$prefix}jxc_sale_product as c ON c.sale_id = b.sale_id
WHERE a.customer_id = {$value['customer_id']}
AND b.owner_user_id IN ({$userIds})
AND b.check_status IN (7, 2)
AND b.create_time BETWEEN {$timeData['start_time']} AND {$timeData['end_time']}";
$data = queryCache($sql);
$sql1 = "SELECT
a.customer_id,
a.`name`,
count(distinct b.salereturn_id) AS salereturn_num,
IFNULL(
sum(c.salereturn_number),
0
) AS salereturn_number,
IFNULL(
sum(c.salereturn_subtotal),
0
) AS salereturn_subtotal
FROM
{$prefix}crm_customer as a
INNER JOIN {$prefix}jxc_salereturn as b ON a.customer_id = b.customer_id
INNER JOIN {$prefix}jxc_salereturn_product as c ON c.salereturn_id = b.salereturn_id
WHERE a.customer_id = {$value['customer_id']}
AND b.owner_user_id IN ({$userIds})
AND b.check_status IN (7, 2)
AND b.create_time BETWEEN {$timeData['start_time']} AND {$timeData['end_time']}";
$data1 = queryCache($sql1);
$item = [];
foreach ($data as $key => $value) {
$item = array_merge($value, $data1[$key]);
}
$arr['items'][] = $item;
}
$data = [];
$data['list'] = $arr ? : [];
$data['dataCount'] = $dataCount ? : 0;
return $data;
}
}

@ -495,5 +495,5 @@ class ExamineLogic extends Common
return true;
}
}

@ -808,6 +808,7 @@ class LogLogic extends Common
$relation_list = [];
$f_where['module'] = 'crm_activity';
$relation_list = $recordModel->getListByRelationId('activity', $v['activity_id']);
$dataInfo = [];
$newFileList = [];
$newFileList = $fileModel->getDataList($f_where, 'all');
@ -822,10 +823,10 @@ class LogLogic extends Common
}
$list[$k]['fileList'] = $fileList ?: [];
$list[$k]['imgList'] = $imgList ?: [];
$dataInfo['customerList'] = $relation_list['customer_list'] ?: [];
$dataInfo['contactsList'] = $relation_list['contacts_list'] ?: [];
$dataInfo['businessList'] = $relation_list['business_list'] ?: [];
$dataInfo['contractList'] = $relation_list['contract_list'] ?: [];
$list[$k]['customer_list'] = $relation_list['customerList'] ?: [];
$list[$k]['contacts_list'] = $relation_list['contactsList'] ?: [];
$list[$k]['business_list'] = $relation_list['businessList'] ?: [];
$list[$k]['contract_list'] = $relation_list['contractList'] ?: [];
$list[$k]['dataInfo'] = $dataInfo ?: [];
}

@ -334,13 +334,13 @@ INSERT INTO `5kcrm_admin_field` VALUES (87, 'oa_examine', 5, 'remark', '备注',
INSERT INTO `5kcrm_admin_field` VALUES (88, 'oa_examine', 6, 'content', '借款事由', 'text', '', 0, 0, 1, '', '', 0, 3, 1553788800, 1553788800, 0, NULL, 0, 100, '0,1', NULL, NULL, NULL, NULL, NULL, NULL);
INSERT INTO `5kcrm_admin_field` VALUES (89, 'oa_examine', 6, 'money', '借款金额(元)', 'floatnumber', '', 0, 0, 1, '', '', 0, 3, 1553788800, 1553788800, 0, NULL, 0, 100, '0,2', NULL, NULL, NULL, NULL, NULL, NULL);
INSERT INTO `5kcrm_admin_field` VALUES (90, 'oa_examine', 6, 'remark', '备注', 'textarea', '', 0, 0, 0, '', '', 0, 3, 1553788800, 1553788800, 0, NULL, 0, 100, '0,3', NULL, NULL, NULL, NULL, NULL, NULL);
INSERT INTO `5kcrm_admin_field` VALUES (91, 'crm_receivables_plan', 0, 'customer_id', '客户名称', 'customer', '', 0, 0, 1, '', '', 1, 3, 1553788800, 1624439466, 0, NULL, 0, 50, '0,0', NULL, NULL, NULL, NULL, '', 1001);
INSERT INTO `5kcrm_admin_field` VALUES (92, 'crm_receivables_plan', 0, 'contract_id', '合同编号', 'contract', '', 0, 0, 1, '', '', 2, 3, 1553788800, 1624439466, 0, NULL, 0, 50, '0,1', NULL, NULL, NULL, NULL, '', 1002);
INSERT INTO `5kcrm_admin_field` VALUES (93, 'crm_receivables_plan', 0, 'money', '计划回款金额', 'floatnumber', '', 0, 0, 1, '', '', 3, 3, 1553788800, 1624439466, 6, NULL, 0, 50, '1,0', NULL, NULL, NULL, NULL, '', 1003);
INSERT INTO `5kcrm_admin_field` VALUES (94, 'crm_receivables_plan', 0, 'return_date', '计划回款日期', 'date', '', 0, 0, 1, '', '', 4, 3, 1553788800, 1624439466, 4, NULL, 0, 50, '1,1', NULL, NULL, NULL, NULL, '', 1004);
INSERT INTO `5kcrm_admin_field` VALUES (95, 'crm_receivables_plan', 0, 'return_type', '计划回款方式', 'select', '', 0, 0, 1, '', '支票\n现金\n邮政汇款\n电汇\n网上转账\n支付宝\n微信支付\n其他\n在线支付\n线下支付\n预存款\n返利\n预存款+返利', 5, 3, 1553788800, 1624439466, 3, NULL, 0, 50, '2,0', 2, NULL, NULL, NULL, '支票\n现金\n邮政汇款\n电汇\n网上转账\n支付宝\n微信支付\n其他\n在线支付\n线下支付\n预存款\n返利\n预存款+返利', 1005);
INSERT INTO `5kcrm_admin_field` VALUES (96, 'crm_receivables_plan', 0, 'remind', '提前几日提醒', 'number', '', 0, 0, 0, '', '', 6, 3, 1553788800, 1624439466, 5, NULL, 0, 50, '2,1', NULL, NULL, NULL, NULL, '', 1006);
INSERT INTO `5kcrm_admin_field` VALUES (97, 'crm_receivables_plan', 0, 'remark', '备注', 'textarea', '', 0, 0, 0, '', '', 7, 1, 1553788800, 1624439466, 2, NULL, 0, 100, '3,0', NULL, NULL, NULL, NULL, '', 1007);
INSERT INTO `5kcrm_admin_field` VALUES (91, 'crm_receivables_plan', 0, 'customer_id', '客户名称', 'customer', '', 0, 0, 1, '', '', 1, 181, 1553788800, 1624439466, 0, NULL, 0, 50, '0,0', NULL, NULL, NULL, NULL, '', 1001);
INSERT INTO `5kcrm_admin_field` VALUES (92, 'crm_receivables_plan', 0, 'contract_id', '合同编号', 'contract', '', 0, 0, 1, '', '', 2, 181, 1553788800, 1624439466, 0, NULL, 0, 50, '0,1', NULL, NULL, NULL, NULL, '', 1002);
INSERT INTO `5kcrm_admin_field` VALUES (93, 'crm_receivables_plan', 0, 'money', '计划回款金额', 'floatnumber', '', 0, 0, 1, '', '', 3, 181, 1553788800, 1624439466, 6, NULL, 0, 50, '1,0', NULL, NULL, NULL, NULL, '', 1003);
INSERT INTO `5kcrm_admin_field` VALUES (94, 'crm_receivables_plan', 0, 'return_date', '计划回款日期', 'date', '', 0, 0, 1, '', '', 4, 183, 1553788800, 1624439466, 4, NULL, 0, 50, '1,1', NULL, NULL, NULL, NULL, '', 1004);
INSERT INTO `5kcrm_admin_field` VALUES (95, 'crm_receivables_plan', 0, 'return_type', '计划回款方式', 'select', '', 0, 0, 1, '', '支票\n现金\n邮政汇款\n电汇\n网上转账\n支付宝\n微信支付\n其他\n在线支付\n线下支付\n预存款\n返利\n预存款+返利', 5, 191, 1553788800, 1624439466, 3, NULL, 0, 50, '2,0', 2, NULL, NULL, NULL, '支票\n现金\n邮政汇款\n电汇\n网上转账\n支付宝\n微信支付\n其他\n在线支付\n线下支付\n预存款\n返利\n预存款+返利', 1005);
INSERT INTO `5kcrm_admin_field` VALUES (96, 'crm_receivables_plan', 0, 'remind', '提前几日提醒', 'number', '', 0, 0, 0, '', '', 6, 191, 1553788800, 1624439466, 5, NULL, 0, 50, '2,1', NULL, NULL, NULL, NULL, '', 1006);
INSERT INTO `5kcrm_admin_field` VALUES (97, 'crm_receivables_plan', 0, 'remark', '备注', 'textarea', '', 0, 0, 0, '', '', 7, 191, 1553788800, 1624439466, 2, NULL, 0, 100, '3,0', NULL, NULL, NULL, NULL, '', 1007);
INSERT INTO `5kcrm_admin_field` VALUES (99, 'crm_customer', 0, 'mobile', '手机', 'mobile', '', 0, 0, 0, '', '', 6, 191, 1553788800, 1624439032, 7, '', 0, 50, '2,1', 0, '', '', '', '', 1031);
INSERT INTO `5kcrm_admin_field` VALUES (100, 'crm_customer', 0, 'email', '邮箱', 'email', '', 0, 0, 0, '', '', 7, 191, 1553788800, 1624439032, 14, '', 0, 50, '3,0', 0, '', '', '', '', 1032);
INSERT INTO `5kcrm_admin_field` VALUES (101, 'crm_visit', 0, 'number', '回访编号', 'text', '', 0, 0, 1, '', NULL, 1, 177, 1553788800, 1624439600, 1, '', 0, 50, '0,0', 0, '', '', '', NULL, 1001);
@ -1600,44 +1600,45 @@ CREATE TABLE `5kcrm_crm_contract_product` (
-- Table structure for 5kcrm_crm_customer
-- ----------------------------
DROP TABLE IF EXISTS `5kcrm_crm_customer`;
CREATE TABLE `5kcrm_crm_customer` (
CREATE TABLE `5kcrm_crm_customer` (
`customer_id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) DEFAULT NULL COMMENT '客户名称',
`is_lock` tinyint(1) NOT NULL DEFAULT '0' COMMENT '1锁定',
`name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '客户名称',
`is_lock` tinyint(1) NOT NULL DEFAULT 0 COMMENT '1锁定',
`deal_time` int(11) NOT NULL COMMENT '领取,分配,创建时间',
`level` varchar(500) DEFAULT NULL COMMENT '客户级别',
`industry` varchar(500) DEFAULT NULL COMMENT '客户行业',
`source` varchar(500) DEFAULT NULL COMMENT '客户来源',
`telephone` varchar(255) DEFAULT NULL COMMENT '电话',
`mobile` varchar(255) DEFAULT NULL COMMENT '手机',
`website` varchar(255) DEFAULT NULL COMMENT '网址',
`remark` text COMMENT '备注',
`level` varchar(500) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '客户级别',
`industry` varchar(500) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '客户行业',
`source` varchar(500) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '客户来源',
`telephone` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '电话',
`mobile` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '手机',
`website` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '网址',
`remark` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '备注',
`create_user_id` int(11) NOT NULL COMMENT '创建人ID',
`owner_user_id` int(11) NOT NULL COMMENT '负责人ID',
`ro_user_id` varchar(500) NOT NULL DEFAULT '' COMMENT '只读权限',
`rw_user_id` varchar(500) NOT NULL DEFAULT '' COMMENT '读写权限',
`address` varchar(255) NOT NULL DEFAULT '' COMMENT '省市区',
`location` varchar(255) NOT NULL DEFAULT '' COMMENT '定位信息',
`detail_address` varchar(255) NOT NULL DEFAULT '' COMMENT '详细地址',
`lng` double(14,11) DEFAULT NULL COMMENT '地理位置经度',
`lat` double(14,11) DEFAULT NULL COMMENT '地理位置维度',
`next_time` int(11) DEFAULT NULL COMMENT '下次联系时间',
`follow` varchar(20) DEFAULT NULL COMMENT '跟进',
`obtain_time` int(10) NOT NULL DEFAULT '0' COMMENT '负责人获取客户时间',
`ro_user_id` varchar(500) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '只读权限',
`rw_user_id` varchar(500) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '读写权限',
`address` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '省市区',
`location` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '定位信息',
`detail_address` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '详细地址',
`lng` double(14, 11) NULL DEFAULT NULL COMMENT '地理位置经度',
`lat` double(14, 11) NULL DEFAULT NULL COMMENT '地理位置维度',
`next_time` int(11) NULL DEFAULT NULL COMMENT '下次联系时间',
`follow` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '跟进',
`obtain_time` int(10) NOT NULL DEFAULT 0 COMMENT '负责人获取客户时间',
`create_time` int(11) NOT NULL COMMENT '创建时间',
`update_time` int(11) NOT NULL COMMENT '更新时间',
`is_dealt` tinyint(1) NOT NULL DEFAULT '1' COMMENT '是否已经处理待办事项1已处理0未处理',
`is_allocation` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否是分配给我的客户1是0不是',
`last_time` int(10) unsigned DEFAULT NULL COMMENT '最后跟进时间',
`last_record` varchar(512) DEFAULT NULL COMMENT '最后跟进记录',
`email` varchar(255) DEFAULT NULL COMMENT '邮箱',
`before_owner_user_id` int(10) unsigned DEFAULT '0' COMMENT '前负责人',
`into_pool_time` int(10) unsigned DEFAULT '0' COMMENT '进入公海时间',
`pool_remain` tinyint(1) NOT NULL DEFAULT '0' COMMENT '代办事项待进入公海1已处理0未处理',
`deal_status` varchar(10) NOT NULL DEFAULT '未成交' COMMENT '成交状态',
`is_dealt` tinyint(1) NOT NULL DEFAULT 1 COMMENT '是否已经处理待办事项1已处理0未处理',
`is_allocation` tinyint(1) NOT NULL DEFAULT 0 COMMENT '是否是分配给我的客户1是0不是',
`last_time` int(10) UNSIGNED NULL DEFAULT NULL COMMENT '最后跟进时间',
`last_record` varchar(512) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '最后跟进记录',
`email` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '邮箱',
`before_owner_user_id` int(10) UNSIGNED NULL DEFAULT 0 COMMENT '前负责人',
`into_pool_time` int(10) UNSIGNED NULL DEFAULT 0 COMMENT '进入公海时间',
`pool_remain` tinyint(1) NOT NULL DEFAULT 0 COMMENT '代办事项待进入公海1已处理0未处理',
`deal_status` varchar(10) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '未成交' COMMENT '成交状态',
PRIMARY KEY (`customer_id`) USING BTREE,
KEY `bi_analysis` (`create_time`,`owner_user_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='客户表';
INDEX `bi_analysis`(`create_time`, `owner_user_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '客户表' ROW_FORMAT = DYNAMIC;
-- ----------------------------
-- Records of 5kcrm_crm_customer
-- ----------------------------
@ -2323,9 +2324,13 @@ CREATE TABLE `5kcrm_crm_receivables_plan` (
`update_time` int(11) NOT NULL COMMENT '更新时间',
`file` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '附件',
`is_dealt` tinyint(1) NOT NULL DEFAULT 0 COMMENT '是否已经处理待办事项1已处理0未处理',
`real_money` decimal(18,2) NOT NULL DEFAULT '0.00' COMMENT '实际回款金额',
`real_data` date DEFAULT NULL COMMENT '实际回款日期',
`un_money` decimal(18,2) NOT NULL DEFAULT '0.00' COMMENT '未回金额',
PRIMARY KEY (`plan_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '回款计划表' ROW_FORMAT = DYNAMIC;
-- ----------------------------
-- Records of 5kcrm_crm_receivables_plan
-- ----------------------------

@ -1,5 +1,9 @@
ALTER TABLE `5kcrm_crm_receivables_plan` ADD COLUMN `real_money` decimal(18,2) NOT NULL DEFAULT '0.00' COMMENT '实际回款金额';
ALTER TABLE `5kcrm_crm_receivables_plan` ADD COLUMN `real_data` date DEFAULT NULL COMMENT '实际回款日期';
ALTER TABLE `5kcrm_crm_receivables_plan` ADD COLUMN `un_money` decimal(18,2) NOT NULL DEFAULT '0.00' COMMENT '未回金额';
--
--
--
ALTER TABLE `5kcrm_crm_receivables_plan` ADD `real_money` decimal(18,2) NOT NULL DEFAULT '0.00' COMMENT '实际回款金额';
ALTER TABLE `5kcrm_crm_receivables_plan` ADD `real_data` date DEFAULT NULL COMMENT '实际回款日期';
ALTER TABLE `5kcrm_crm_receivables_plan` ADD `un_money` decimal(18,2) NOT NULL DEFAULT '0.00' COMMENT '未回金额';
DELETE `5kcrm_admin_field` where `types` = 'crm_customer' AND`field` = 'deal_status';
INSERT INTO `5kcrm_admin_field` VALUES (18, 'crm_customer', 0, 'deal_status', '成交状态', 'select', '未成交', 0, 0, 1, '', '未成交\n已成交', 0, 191, 1553788800, 1553788800, 0, NULL, 0, 100, '', NULL, NULL, NULL, NULL, NULL, NULL);

Loading…
Cancel
Save