pull/26/head
张萌 2 years ago
parent 80d1af3d0d
commit 7c31cc34bf

@ -70,6 +70,10 @@ function resultArray($array)
} elseif (isset($array['error'])) { } elseif (isset($array['error'])) {
$code = 400; $code = 400;
$array['data'] = ''; $array['data'] = '';
} elseif (isset($array['success'])) {
$array['error'] = '';
$array['data'] =$array['success'] ;
$code = 200;
} }
return json([ return json([
'code' => $code, 'code' => $code,
@ -390,128 +394,128 @@ function advancedQuery($param, $m = '', $c = '', $a = '')
// 创建人、负责人 // 创建人、负责人
if (in_array($key, ['create_user_id', 'owner_user_id'])) { if (in_array($key, ['create_user_id', 'owner_user_id'])) {
if($value['condition'] == 'contains'){ if ($value['condition'] == 'contains') {
$result[$c . $key] = ['in', $value['value']]; $result[$c . $key] = ['in', $value['value']];
}else if ($value['condition'] == 'notContains') { } else if ($value['condition'] == 'notContains') {
$result[$c . $key] = ['not in', $value['value']]; $result[$c . $key] = ['not in', $value['value']];
}else if ($value['condition'] == 'isNull') { } else if ($value['condition'] == 'isNull') {
$result[$c . $key] = ['eq', '']; $result[$c . $key] = ['eq', ''];
}else if ($value['condition'] == 'isNotNull') { } else if ($value['condition'] == 'isNotNull') {
$result[$c . $key] = ['neq', '']; $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',])) { 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',])) {
$res = advancedQueryFormatForCommon($value['value'], $value['condition'], $value['form_type'], $key); $res = advancedQueryFormatForCommon($value['value'], $value['condition'], $value['form_type'], $key);
if($key == 'order_id'){ if ($key == 'order_id') {
$arr = []; $arr = [];
if($c == 'outbound.'){ if ($c == 'outbound.') {
$retreatOutboundIds = db('jxc_retreat') $retreatOutboundIds = db('jxc_retreat')
->alias('a') ->alias('a')
->join('jxc_outbound b','a.retreat_id = b.order_id') ->join('jxc_outbound b', 'a.retreat_id = b.order_id')
->where('a.order_number', [$res[0], $res[1]]) ->where('a.order_number', [$res[0], $res[1]])
->where('b.outbound_type', '采购退货出库') ->where('b.outbound_type', '采购退货出库')
// ->fetchSql() // ->fetchSql()
->column('outbound_id'); ->column('outbound_id');
$saleOutboundIds = db('jxc_sale') $saleOutboundIds = db('jxc_sale')
->alias('a') ->alias('a')
->join('jxc_outbound b','a.sale_id = b.order_id') ->join('jxc_outbound b', 'a.sale_id = b.order_id')
->where('a.order_number', [$res[0], $res[1]]) ->where('a.order_number', [$res[0], $res[1]])
->where('b.outbound_type', '销售出库') ->where('b.outbound_type', '销售出库')
// ->fetchSql() // ->fetchSql()
->column('outbound_id'); ->column('outbound_id');
$arr = empty($retreatOutboundIds) ? $saleOutboundIds : array_merge($retreatOutboundIds,$saleOutboundIds); $arr = empty($retreatOutboundIds) ? $saleOutboundIds : array_merge($retreatOutboundIds, $saleOutboundIds);
$result[$c . 'outbound_id'] = ['in', $arr]; $result[$c . 'outbound_id'] = ['in', $arr];
}elseif ($c == 'receipt.') { } elseif ($c == 'receipt.') {
$purchaseOutboundIds = db('jxc_purchase') $purchaseOutboundIds = db('jxc_purchase')
->alias('a') ->alias('a')
->join('jxc_receipt b','a.purchase_id = b.order_id') ->join('jxc_receipt b', 'a.purchase_id = b.order_id')
->where('a.order_number', [$res[0], $res[1]]) ->where('a.order_number', [$res[0], $res[1]])
->where('b.receipt_type', '采购入库') ->where('b.receipt_type', '采购入库')
// ->fetchSql() // ->fetchSql()
->column('b.receipt_id'); ->column('b.receipt_id');
$salereturnOutboundIds = db('jxc_salereturn') $salereturnOutboundIds = db('jxc_salereturn')
->alias('a') ->alias('a')
->join('jxc_receipt b','a.salereturn_id = b.order_id') ->join('jxc_receipt b', 'a.salereturn_id = b.order_id')
->where('a.order_number', [$res[0], $res[1]]) ->where('a.order_number', [$res[0], $res[1]])
->where('b.receipt_type', '销售退货入库') ->where('b.receipt_type', '销售退货入库')
// ->fetchSql() // ->fetchSql()
->column('b.receipt_id'); ->column('b.receipt_id');
$arr = empty($purchaseOutboundIds) ? $salereturnOutboundIds : array_merge($purchaseOutboundIds,$salereturnOutboundIds); $arr = empty($purchaseOutboundIds) ? $salereturnOutboundIds : array_merge($purchaseOutboundIds, $salereturnOutboundIds);
$result[$c . 'receipt_id'] = ['in', $arr]; $result[$c . 'receipt_id'] = ['in', $arr];
} }
}else if($key == 'related_id'){ } else if ($key == 'related_id') {
$arr = []; $arr = [];
if($c == 'collection.'){ if ($c == 'collection.') {
$retreatOutboundIds = db('jxc_retreat') $retreatOutboundIds = db('jxc_retreat')
->alias('a') ->alias('a')
->join('jxc_collection b','a.retreat_id = b.related_id') ->join('jxc_collection b', 'a.retreat_id = b.related_id')
->where('a.order_number', [$res[0], $res[1]]) ->where('a.order_number', [$res[0], $res[1]])
->where('b.collection_type', '采购退货') ->where('b.collection_type', '采购退货')
// ->fetchSql() // ->fetchSql()
->column('collection_note_id'); ->column('collection_note_id');
$saleOutboundIds = db('jxc_sale') $saleOutboundIds = db('jxc_sale')
->alias('a') ->alias('a')
->join('jxc_collection b','a.sale_id = b.related_id') ->join('jxc_collection b', 'a.sale_id = b.related_id')
->where('a.order_number', [$res[0], $res[1]]) ->where('a.order_number', [$res[0], $res[1]])
->where('b.collection_type', '销售回款') ->where('b.collection_type', '销售回款')
// ->fetchSql() // ->fetchSql()
->column('collection_note_id'); ->column('collection_note_id');
$arr = empty($retreatOutboundIds) ? $saleOutboundIds : array_merge($retreatOutboundIds,$saleOutboundIds); $arr = empty($retreatOutboundIds) ? $saleOutboundIds : array_merge($retreatOutboundIds, $saleOutboundIds);
$result[$c . 'collection_note_id'] = ['in', $arr]; $result[$c . 'collection_note_id'] = ['in', $arr];
}elseif ($c == 'payment.') { } elseif ($c == 'payment.') {
$purchaseOutboundIds = db('jxc_purchase') $purchaseOutboundIds = db('jxc_purchase')
->alias('a') ->alias('a')
->join('jxc_payment b','a.purchase_id = b.related_id') ->join('jxc_payment b', 'a.purchase_id = b.related_id')
->where('a.order_number', [$res[0], $res[1]]) ->where('a.order_number', [$res[0], $res[1]])
->where('b.payment_type', '采购') ->where('b.payment_type', '采购')
// ->fetchSql() // ->fetchSql()
->column('b.payment_note_id'); ->column('b.payment_note_id');
$salereturnOutboundIds = db('jxc_salereturn') $salereturnOutboundIds = db('jxc_salereturn')
->alias('a') ->alias('a')
->join('jxc_payment b','a.salereturn_id = b.related_id') ->join('jxc_payment b', 'a.salereturn_id = b.related_id')
->where('a.order_number', [$res[0], $res[1]]) ->where('a.order_number', [$res[0], $res[1]])
->where('b.payment_type', '销售退货') ->where('b.payment_type', '销售退货')
// ->fetchSql() // ->fetchSql()
->column('b.payment_note_id'); ->column('b.payment_note_id');
$arr = empty($purchaseOutboundIds) ? $salereturnOutboundIds : array_merge($purchaseOutboundIds,$salereturnOutboundIds); $arr = empty($purchaseOutboundIds) ? $salereturnOutboundIds : array_merge($purchaseOutboundIds, $salereturnOutboundIds);
$result[$c . 'payment_note_id'] = ['in', $arr]; $result[$c . 'payment_note_id'] = ['in', $arr];
} }
}else if($key == 'collection_object'){ } else if ($key == 'collection_object') {
$arr = []; $arr = [];
if($c == 'collection.'){ if ($c == 'collection.') {
$supplierOutboundIds = db('jxc_supplier') $supplierOutboundIds = db('jxc_supplier')
->alias('a') ->alias('a')
->join('jxc_collection b','a.supplier_id = b.collection_object') ->join('jxc_collection b', 'a.supplier_id = b.collection_object')
->where('a.supplier_name', [$res[0], $res[1]]) ->where('a.supplier_name', [$res[0], $res[1]])
->where('b.collection_type', '采购退货') ->where('b.collection_type', '采购退货')
// ->fetchSql() // ->fetchSql()
->column('collection_note_id'); ->column('collection_note_id');
$customerOutboundIds = db('crm_customer') $customerOutboundIds = db('crm_customer')
->alias('a') ->alias('a')
->join('jxc_collection b','a.customer_id = b.collection_object') ->join('jxc_collection b', 'a.customer_id = b.collection_object')
->where('a.name', [$res[0], $res[1]]) ->where('a.name', [$res[0], $res[1]])
->where('b.collection_type', '销售回款') ->where('b.collection_type', '销售回款')
// ->fetchSql() // ->fetchSql()
->column('collection_note_id'); ->column('collection_note_id');
$arr = empty($supplierOutboundIds) ? $customerOutboundIds : array_merge($supplierOutboundIds,$customerOutboundIds); $arr = empty($supplierOutboundIds) ? $customerOutboundIds : array_merge($supplierOutboundIds, $customerOutboundIds);
$result[$c . 'collection_note_id'] = ['in', $arr]; $result[$c . 'collection_note_id'] = ['in', $arr];
}elseif ($c == 'payment.') { } elseif ($c == 'payment.') {
$supplierOutboundIds = db('jxc_supplier') $supplierOutboundIds = db('jxc_supplier')
->alias('a') ->alias('a')
->join('jxc_payment b','a.supplier_id = b.collection_object') ->join('jxc_payment b', 'a.supplier_id = b.collection_object')
->where('a.supplier_name', [$res[0], $res[1]]) ->where('a.supplier_name', [$res[0], $res[1]])
->where('b.payment_type', '采购') ->where('b.payment_type', '采购')
// ->fetchSql() // ->fetchSql()
->column('b.payment_note_id'); ->column('b.payment_note_id');
$customerOutboundIds = db('crm_customer') $customerOutboundIds = db('crm_customer')
->alias('a') ->alias('a')
->join('jxc_payment b','a.customer_id = b.collection_object') ->join('jxc_payment b', 'a.customer_id = b.collection_object')
->where('a.name', [$res[0], $res[1]]) ->where('a.name', [$res[0], $res[1]])
->where('b.payment_type', '销售退货') ->where('b.payment_type', '销售退货')
// ->fetchSql() // ->fetchSql()
->column('b.payment_note_id'); ->column('b.payment_note_id');
$arr = empty($supplierOutboundIds) ? $customerOutboundIds : array_merge($supplierOutboundIds,$customerOutboundIds); $arr = empty($supplierOutboundIds) ? $customerOutboundIds : array_merge($supplierOutboundIds, $customerOutboundIds);
$result[$c . 'payment_note_id'] = ['in', $arr]; $result[$c . 'payment_note_id'] = ['in', $arr];
} }
// }else if($key == 'sp_data_value'){ // }else if($key == 'sp_data_value'){
@ -521,7 +525,7 @@ function advancedQuery($param, $m = '', $c = '', $a = '')
// $w['sp_data_value'] = ['like', $arr, 'OR']; // $w['sp_data_value'] = ['like', $arr, 'OR'];
// $product_ids = db('jxc_product')->where($w)->fetchSql()->column('product_id'); // $product_ids = db('jxc_product')->where($w)->fetchSql()->column('product_id');
// $result[$c . 'sp_data_value'] = [$res[0], $product_ids]; // $result[$c . 'sp_data_value'] = [$res[0], $product_ids];
}else{ } else {
$result[$c . $key] = advancedQueryFormatForCommon($value['value'], $value['condition'], $value['form_type'], $key); $result[$c . $key] = advancedQueryFormatForCommon($value['value'], $value['condition'], $value['form_type'], $key);
} }
} }
@ -729,9 +733,9 @@ function advancedQueryFormatForCommon($data, $condition, $formType, $key)
if (in_array($formType, ['checkbox']) && $condition == 'isNot') $condition = 'notContains'; if (in_array($formType, ['checkbox']) && $condition == 'isNot') $condition = 'notContains';
// 处理查询参数 // 处理查询参数
if(in_array($condition, ['contains', 'notContains']) && in_array($key,['create_user_id','owner_user_id'])){ if (in_array($condition, ['contains', 'notContains']) && in_array($key, ['create_user_id', 'owner_user_id'])) {
$data = advancedQueryDataUserform($data, $condition); $data = advancedQueryDataUserform($data, $condition);
}elseif (in_array($condition, ['contains', 'notContains', 'startWith', 'endWith'])){ } elseif (in_array($condition, ['contains', 'notContains', 'startWith', 'endWith'])) {
$data = advancedQueryDataTransform($data, $condition); $data = advancedQueryDataTransform($data, $condition);
} }
@ -753,7 +757,7 @@ function advancedQueryFormatForCommon($data, $condition, $formType, $key)
$data[0] = str_replace('已作废', 6, $data[0]); $data[0] = str_replace('已作废', 6, $data[0]);
} }
return advancedQueryWhere($condition, $data,$key); return advancedQueryWhere($condition, $data, $key);
} }
/** /**
@ -765,7 +769,7 @@ function advancedQueryFormatForCommon($data, $condition, $formType, $key)
* @since 2021-05-22 * @since 2021-05-22
* @author fanqi * @author fanqi
*/ */
function advancedQueryWhere($condition, $data, $key='') function advancedQueryWhere($condition, $data, $key = '')
{ {
$result = []; $result = [];
@ -774,9 +778,9 @@ function advancedQueryWhere($condition, $data, $key='')
if ($condition == "in") $result = ['in', $data]; // 等于 if ($condition == "in") $result = ['in', $data]; // 等于
if ($condition == 'is') $result = ['in', $data]; // 等于 if ($condition == 'is') $result = ['in', $data]; // 等于
if ($condition == 'isNot') $result = [['notin', $data],['null'],'OR']; // 不等于 if ($condition == 'isNot') $result = [['notin', $data], ['null'], 'OR']; // 不等于
if ($condition == 'contains') $result = ['like', $data, 'OR']; // 包含 if ($condition == 'contains') $result = ['like', $data, 'OR']; // 包含
if ($condition == 'notContains') $result = [['notlike', $data, 'AND'],['null'],'OR']; // 不包含 if ($condition == 'notContains') $result = [['notlike', $data, 'AND'], ['null'], 'OR']; // 不包含
if ($condition == 'startWith') $result = ['like', $data, 'OR']; // 开始于 if ($condition == 'startWith') $result = ['like', $data, 'OR']; // 开始于
if ($condition == 'endWith') $result = ['like', $data, 'OR']; // 结束于 if ($condition == 'endWith') $result = ['like', $data, 'OR']; // 结束于
if ($condition == 'gt') $result = ['gt', $data]; // 大于 if ($condition == 'gt') $result = ['gt', $data]; // 大于
@ -787,8 +791,8 @@ function advancedQueryWhere($condition, $data, $key='')
if ($condition == 'range') $result = ['between', $data]; // 处于某个时间段 if ($condition == 'range') $result = ['between', $data]; // 处于某个时间段
if ($condition == 'isNull') $result = [['eq', ''], ['null'], 'OR']; // 为空 if ($condition == 'isNull') $result = [['eq', ''], ['null'], 'OR']; // 为空
if ($condition == 'isNotNull') $result = [['neq', ''], ['not null'], 'AND']; // 不为空 if ($condition == 'isNotNull') $result = [['neq', ''], ['not null'], 'AND']; // 不为空
if ($condition == 'contains' && in_array($key,['create_user_id','owner_user_id'])) $result = ['in', $data]; // 暂定为创建人 负责人 包含 if ($condition == 'contains' && in_array($key, ['create_user_id', 'owner_user_id'])) $result = ['in', $data]; // 暂定为创建人 负责人 包含
if ($condition == 'notContains' && in_array($key,['create_user_id','owner_user_id'])) $result = ['notin', $data]; // 暂定为创建人 负责人不包含 if ($condition == 'notContains' && in_array($key, ['create_user_id', 'owner_user_id'])) $result = ['notin', $data]; // 暂定为创建人 负责人不包含
return $result; return $result;
} }
@ -834,7 +838,8 @@ function advancedQueryDataTransform($data, $condition)
* @version: 11.1.0 * @version: 11.1.0
* Date: 2021/9/2 14:44 * Date: 2021/9/2 14:44
*/ */
function advancedQueryDataUserform($data, $condition){ function advancedQueryDataUserform($data, $condition)
{
if (in_array($condition, ['contains', 'notContains'])) { if (in_array($condition, ['contains', 'notContains'])) {
array_walk($data, function ($value, $key) use (&$data) { array_walk($data, function ($value, $key) use (&$data) {
$data[$key] = $value; $data[$key] = $value;
@ -842,6 +847,7 @@ function advancedQueryDataUserform($data, $condition){
} }
return $data; return $data;
} }
/** /**
* 等于(时间段)数据处理 * 等于(时间段)数据处理
* *
@ -2891,7 +2897,7 @@ if (!function_exists('getFieldGrantStatus')) {
function getFieldGrantStatus($field, $grantData) function getFieldGrantStatus($field, $grantData)
{ {
# 默认状态都是不能查看、不能编辑,通过配置来取最大权限。 # 默认状态都是不能查看、不能编辑,通过配置来取最大权限。
$result = ['read' => 0, 'write' => 0,'maskType'=>0]; $result = ['read' => 0, 'write' => 0, 'maskType' => 0];
foreach ($grantData as $key => $value) { foreach ($grantData as $key => $value) {
$fieldBool = false; $fieldBool = false;
@ -2906,7 +2912,7 @@ if (!function_exists('getFieldGrantStatus')) {
$result['write'] = $va['write'] > $result['write'] ? $va['write'] : $result['write']; $result['write'] = $va['write'] > $result['write'] ? $va['write'] : $result['write'];
} }
if ($va['field'] == $field && $va['maskType'] != 0) { if ($va['field'] == $field && $va['maskType'] != 0) {
$result['maskType'] = !empty($va['maskType'])?$va['maskType']:0; $result['maskType'] = !empty($va['maskType']) ? $va['maskType'] : 0;
} }
if ($va['field'] == $field) $fieldBool = true; if ($va['field'] == $field) $fieldBool = true;
} }
@ -3301,50 +3307,50 @@ function advancedQueryFormatForTeam($requestMap, $c, $db_id)
// $result[$c . 'rw_user_id'] = advancedQueryFormatForPersonnel($v['value'], $v['condition']); // $result[$c . 'rw_user_id'] = advancedQueryFormatForPersonnel($v['value'], $v['condition']);
// } // }
// } // }
$date=[]; $date = [];
$date2=[]; $date2 = [];
$condition=$requestMap['condition']; $condition = $requestMap['condition'];
$z=''; $z = '';
foreach ($requestMap['value'] as $val){ foreach ($requestMap['value'] as $val) {
if($condition=='contains'){ if ($condition == 'contains') {
$z='like'; $z = 'like';
$val="'".'%,'.$val.',%'."'"; $val = "'" . '%,' . $val . ',%' . "'";
}elseif($condition=='notContains'){ } elseif ($condition == 'notContains') {
$z='NOT LIKE'; $z = 'NOT LIKE';
$val="'".'%,'.$val.',%'."'"; $val = "'" . '%,' . $val . ',%' . "'";
} }
$date[]=$prefix.'ro_user_id '.$z.$val; $date[] = $prefix . 'ro_user_id ' . $z . $val;
$date2[]=$prefix.'rw_user_id '.$z.$val; $date2[] = $prefix . 'rw_user_id ' . $z . $val;
} }
if($condition =='isNull'){ if ($condition == 'isNull') {
$z='IS NULL'; $z = 'IS NULL';
$date[]=$prefix.'ro_user_id '.'= '."''"; $date[] = $prefix . 'ro_user_id ' . '= ' . "''";
$date2[]=$prefix.'rw_user_id '.'= '."''"; $date2[] = $prefix . 'rw_user_id ' . '= ' . "''";
}elseif($condition =='isNotNull'){ } elseif ($condition == 'isNotNull') {
$z='IS NOT NULL'; $z = 'IS NOT NULL';
$date[]=$prefix.'ro_user_id '.'<> '."''"; $date[] = $prefix . 'ro_user_id ' . '<> ' . "''";
$date2[]=$prefix.'rw_user_id '.'<> '."''"; $date2[] = $prefix . 'rw_user_id ' . '<> ' . "''";
} }
if($date && $date2){ if ($date && $date2) {
$rest=''; $rest = '';
$date=implode('OR ', $date); $date = implode('OR ', $date);
$date2=implode('OR ', $date2); $date2 = implode('OR ', $date2);
$type=''; $type = '';
switch ($z){ switch ($z) {
case 'like': case 'like':
$rest='('.$date.')'.'OR'.'('.$date2.')'; $rest = '(' . $date . ')' . 'OR' . '(' . $date2 . ')';
break; break;
case 'NOT LIKE': case 'NOT LIKE':
$rest='('.$date.')'.'AND'.'('.$date2.')'; $rest = '(' . $date . ')' . 'AND' . '(' . $date2 . ')';
break; break;
case 'IS NULL': case 'IS NULL':
$rest='('.$date.')'.'OR'.'('.$date2.')'; $rest = '(' . $date . ')' . 'OR' . '(' . $date2 . ')';
break; break;
case 'IS NOT NULL': case 'IS NOT NULL':
$rest='('.$date.')'.'AND'.'('.$date2.')'; $rest = '(' . $date . ')' . 'AND' . '(' . $date2 . ')';
break; break;
default: default:
break; break;
@ -3363,15 +3369,15 @@ function advancedQueryFormatForTeam($requestMap, $c, $db_id)
*/ */
function getUserSuperior($structure_id, $level = 0) function getUserSuperior($structure_id, $level = 0)
{ {
if($level == 0){ if ($level == 0) {
$owner_user_id = db('admin_structure')->where('id', $structure_id)->value('owner_user_id'); $owner_user_id = db('admin_structure')->where('id', $structure_id)->value('owner_user_id');
if($owner_user_id == 0){ if ($owner_user_id == 0) {
$pid = db('admin_structure')->where('id', $structure_id)->value('pid'); $pid = db('admin_structure')->where('id', $structure_id)->value('pid');
$owner_user_id = db('admin_structure')->where('id', $pid)->value('owner_user_id'); $owner_user_id = db('admin_structure')->where('id', $pid)->value('owner_user_id');
} }
}else{ } else {
$pid = db('admin_structure')->where('id', $structure_id)->value('pid'); $pid = db('admin_structure')->where('id', $structure_id)->value('pid');
return getUserSuperior($pid, $level-1); return getUserSuperior($pid, $level - 1);
} }
return $owner_user_id; return $owner_user_id;

@ -390,7 +390,6 @@ class Business extends ApiCommon
$userModel = new \app\admin\model\User(); $userModel = new \app\admin\model\User();
$is_end = $param['is_end'] ?: 0; //1赢单2输单3无效 $is_end = $param['is_end'] ?: 0; //1赢单2输单3无效
$remark = $param['statusRemark']; $remark = $param['statusRemark'];
$param['check_user_id'] = 1;// 临时测试需删除
unset($param['examineStatus']); unset($param['examineStatus']);
if (!$param['business_id']) { if (!$param['business_id']) {
@ -411,12 +410,12 @@ class Business extends ApiCommon
// 审核判断(是否有符合条件的审批流) // 审核判断(是否有符合条件的审批流)
$examineFlowModel = new \app\admin\model\ExamineFlow(); $examineFlowModel = new \app\admin\model\ExamineFlow();
if (!$examineFlowModel->checkExamine($userInfo['id'], 'crm_business')) { if (!$examineFlowModel->checkExamine($userInfo['id'], 'crm_business')) {
return '暂无审批人,无法创建'; return resultArray(['error' => '暂无审批人,无法创建']);
} }
//添加审批相关信息 //添加审批相关信息
$examineFlowData = $examineFlowModel->getFlowByTypes($userInfo['id'], 'crm_business'); $examineFlowData = $examineFlowModel->getFlowByTypes($userInfo['id'], 'crm_business');
if (!$examineFlowData) { if (!$examineFlowData) {
return '无可用审批流,请联系管理员'; return resultArray(['error' => '无可用审批流,请联系管理员']);
} }
$data['flow_id'] = $examineFlowData['flow_id']; $data['flow_id'] = $examineFlowData['flow_id'];
//获取审批人信息 //获取审批人信息
@ -430,7 +429,8 @@ class Business extends ApiCommon
$check_user_id = $param['check_user_id'] ? ',' . $param['check_user_id'] . ',' : ''; $check_user_id = $param['check_user_id'] ? ',' . $param['check_user_id'] . ',' : '';
} }
if (!$check_user_id) { if (!$check_user_id) {
return '无可用审批人,请联系管理员';
return resultArray(['error' => '无可用审批人,请联系管理员']);
} }
$data['check_user_id'] = is_array($check_user_id) ? ',' . implode(',', $check_user_id) . ',' : $check_user_id; $data['check_user_id'] = is_array($check_user_id) ? ',' . implode(',', $check_user_id) . ',' : $check_user_id;
} else { } else {
@ -456,7 +456,6 @@ class Business extends ApiCommon
$send_user_id $send_user_id
); );
} }
# 创建待办事项的关联数据 # 创建待办事项的关联数据
$checkUserIds = db('crm_business')->where('business_id', $param['business_id'])->value('check_user_id'); $checkUserIds = db('crm_business')->where('business_id', $param['business_id'])->value('check_user_id');
$checkUserIdArray = stringToArray($checkUserIds); $checkUserIdArray = stringToArray($checkUserIds);
@ -703,8 +702,8 @@ class Business extends ApiCommon
} }
//已审批人ID //已审批人ID
$businessCheckData['flow_user_id'] = stringToArray($dataInfo['flow_user_id']) ? arrayToString(array_merge(stringToArray($dataInfo['flow_user_id']), [$user_id])) : arrayToString([$user_id]); $businessCheckData['flow_user_id'] = stringToArray($dataInfo['flow_user_id']) ? arrayToString(array_merge(stringToArray($dataInfo['flow_user_id']), [$user_id])) : arrayToString([$user_id]);
$resCustomerCheck = db('crm_business')->where(['business_id' => $param['id']])->update($businessCheckData); $resBusiness = db('crm_business')->where(['business_id' => $param['id']])->update($businessCheckData);
if ($resCustomerCheck) { if ($resBusiness) {
//审批记录 //审批记录
$resRecord = $examineRecordModel->createData($checkData); $resRecord = $examineRecordModel->createData($checkData);
//审核通过,修改相关信息 //审核通过,修改相关信息
@ -726,10 +725,11 @@ class Business extends ApiCommon
$businessData['statusRemark'] = $dataInfo['submit_remark']; $businessData['statusRemark'] = $dataInfo['submit_remark'];
$result = $this->advanceAfterCheck($businessData); $result = $this->advanceAfterCheck($businessData);
echo $result;
echo '\\n';
echo !empty($result);
if (!empty($result)) return resultArray(['error' => $result]); if (!empty($result)) return resultArray(['error' => $result]);
echo '12345';
return resultArray(['data' => '领取成功!']);
} else { } else {
if ($status) { if ($status) {
//发送站内信 //发送站内信
@ -754,7 +754,8 @@ class Business extends ApiCommon
); );
} }
} }
return resultArray(['data' => '审批成功']); echo '1234';
return resultArray(['success' => '审批成功']);
} else { } else {
return resultArray(['error' => '审批失败,请重试!']); return resultArray(['error' => '审批失败,请重试!']);
} }
@ -802,7 +803,7 @@ class Business extends ApiCommon
// } // }
$data['status_id'] = $status_id; $data['status_id'] = $status_id;
$data['status_time'] = time(); $data['status_time'] = time();
$data['submit_remark'] = $param['submit_remark']; $data['remark'] = $param['submit_remark'];
$res = db('crm_business')->where(['business_id' => $param['business_id']])->update($data); $res = db('crm_business')->where(['business_id' => $param['business_id']])->update($data);
if (!$res) { if (!$res) {
return resultArray(['error' => '推进失败,请重试']); return resultArray(['error' => '推进失败,请重试']);

@ -394,31 +394,6 @@ class Business extends Common
} }
} }
} }
//站内信
$send_user_id = stringToArray(getUserSuperior($param['create_user_id']));
(new Message())->send(
Message::CUSTOMER_CHECK_TO_DO,
[
'title' => $param['name'],
'action_id' => $this->business_id
],
$send_user_id
);
$data = [];
$data['business_id'] = $this->business_id;
# 创建待办事项的关联数据
$dealtData = [];
foreach ($send_user_id as $kk => $vv) {
$dealtData[] = [
'types' => 'crm_business_new',
'types_id' => $data['business_id'],
'user_id' => $vv
];
}
if (!empty($dealtData)) db('crm_dealt_relation')->insertAll($dealtData);
# 设置今日需联系商机 # 设置今日需联系商机
if (!empty($param['next_time']) && $param['next_time'] >= strtotime(date('Y-m-d 00:00:00'))) $param['is_dealt'] = 0; if (!empty($param['next_time']) && $param['next_time'] >= strtotime(date('Y-m-d 00:00:00'))) $param['is_dealt'] = 0;
@ -462,6 +437,30 @@ class Business extends Common
}); });
db('crm_business_data')->insertAll($businessData); db('crm_business_data')->insertAll($businessData);
//站内信
$send_user_id = stringToArray(getUserSuperior($param['create_user_id']));
(new Message())->send(
Message::CUSTOMER_CHECK_TO_DO,
[
'title' => $param['name'],
'action_id' => $this->business_id
],
$send_user_id
);
$data = [];
$data['business_id'] = $this->business_id;
# 创建待办事项的关联数据
$dealtData = [];
foreach ($send_user_id as $kk => $vv) {
$dealtData[] = [
'types' => 'crm_business_new',
'types_id' => $data['business_id'],
'user_id' => $vv
];
}
if (!empty($dealtData)) db('crm_dealt_relation')->insertAll($dealtData);
return $data; return $data;
} else { } else {
$this->error = '添加失败'; $this->error = '添加失败';

Loading…
Cancel
Save