|
@@ -143,17 +143,70 @@ class MayCurServerService extends Service
|
|
public function reimburseDetailGet($list){
|
|
public function reimburseDetailGet($list){
|
|
if(empty($list['list'])) return [true, $list];
|
|
if(empty($list['list'])) return [true, $list];
|
|
|
|
|
|
|
|
+ list($status,$departList) = $this->department();
|
|
|
|
+ if(! $status) return [false, $departList];
|
|
|
|
+
|
|
$return = [];
|
|
$return = [];
|
|
foreach ($list['list'] as $key => $value){
|
|
foreach ($list['list'] as $key => $value){
|
|
list($status, $msg) = $this->reimburseDetail($value);
|
|
list($status, $msg) = $this->reimburseDetail($value);
|
|
if(! $status) return [false, $msg];
|
|
if(! $status) return [false, $msg];
|
|
-
|
|
|
|
|
|
+ $parent = $this->findParent($departList,$value['departmentBizCode']);
|
|
|
|
+ $parent = array_reverse($parent);
|
|
|
|
+ $res = [];
|
|
|
|
+ foreach ($parent as $value){
|
|
|
|
+ $tmp2['code'] = $value['businessCode'];
|
|
|
|
+ $tmp2['value'] = $value['name'];
|
|
|
|
+ $res[] = $tmp2;
|
|
|
|
+ }
|
|
|
|
+ $msg['departmentList'] = $res;
|
|
$return[] = $msg;
|
|
$return[] = $msg;
|
|
}
|
|
}
|
|
|
|
|
|
return [true, ['list' => $return, 'hasNextPage' => $list['hasNextPage']]];
|
|
return [true, ['list' => $return, 'hasNextPage' => $list['hasNextPage']]];
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // 辅助函数用于递归查找父节点
|
|
|
|
+ function findParent($data, $businessCode) {
|
|
|
|
+ // 存储结果的数组
|
|
|
|
+ $result = [];
|
|
|
|
+
|
|
|
|
+ foreach ($data as $item) {
|
|
|
|
+ if ($item['businessCode'] == $businessCode) {
|
|
|
|
+ // 找到了当前节点的父节点
|
|
|
|
+ if ($item['parentBizCode'] != '') {
|
|
|
|
+ // 添加父节点到结果数组
|
|
|
|
+ $result[] = $item;
|
|
|
|
+ // 继续递归查找父节点的父节点
|
|
|
|
+ $result = array_merge($result, $this->findParent($data, $item['parentBizCode']));
|
|
|
|
+ }
|
|
|
|
+ break; // 找到后退出循环
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return $result;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ function findChildren($data, $businessCode) {
|
|
|
|
+ // 存储结果的数组
|
|
|
|
+ $result = [];
|
|
|
|
+
|
|
|
|
+ // 遍历数据,寻找匹配的子元素
|
|
|
|
+ foreach ($data as $item) {
|
|
|
|
+ if ($item['parentBizCode'] == $businessCode) {
|
|
|
|
+ // 如果找到了子元素,则将其添加到结果数组中
|
|
|
|
+ $result[] = $item;
|
|
|
|
+ // 递归查找该子元素的所有子元素
|
|
|
|
+ $children = $this->findChildren($data, $item['businessCode']);
|
|
|
|
+ if (!empty($children)) {
|
|
|
|
+ // 将找到的子元素合并到结果数组中
|
|
|
|
+ $result = array_merge($result, $children);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return $result;
|
|
|
|
+ }
|
|
|
|
+
|
|
public function reimburseDetail($data){
|
|
public function reimburseDetail($data){
|
|
if(empty($data['formCode'])) return [false, ["报销单详情请求缺失formCode"]];
|
|
if(empty($data['formCode'])) return [false, ["报销单详情请求缺失formCode"]];
|
|
|
|
|
|
@@ -257,11 +310,24 @@ class MayCurServerService extends Service
|
|
public function loanDetailGet($list){
|
|
public function loanDetailGet($list){
|
|
if(empty($list['list'])) return [true, $list];
|
|
if(empty($list['list'])) return [true, $list];
|
|
|
|
|
|
|
|
+ list($status,$departList) = $this->department();
|
|
|
|
+ if(! $status) return [false, $departList];
|
|
|
|
+
|
|
$return = [];
|
|
$return = [];
|
|
foreach ($list['list'] as $value){
|
|
foreach ($list['list'] as $value){
|
|
list($status, $msg) = $this->loanDetail($value);
|
|
list($status, $msg) = $this->loanDetail($value);
|
|
if(! $status) return [false, $msg];
|
|
if(! $status) return [false, $msg];
|
|
|
|
|
|
|
|
+ $parent = $this->findParent($departList,$value['departmentBizCode']);
|
|
|
|
+ $parent = array_reverse($parent);
|
|
|
|
+ $res = [];
|
|
|
|
+ foreach ($parent as $value){
|
|
|
|
+ $tmp2['code'] = $value['businessCode'];
|
|
|
|
+ $tmp2['value'] = $value['name'];
|
|
|
|
+ $res[] = $tmp2;
|
|
|
|
+ }
|
|
|
|
+ $msg['departmentList'] = $res;
|
|
|
|
+
|
|
$return[] = $msg;
|
|
$return[] = $msg;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -312,6 +378,52 @@ class MayCurServerService extends Service
|
|
return [true, $map];
|
|
return [true, $map];
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public function department(){
|
|
|
|
+ //获取token
|
|
|
|
+ list($status, $token) = $this->getToken();
|
|
|
|
+ if(! $status) return [false, $token];
|
|
|
|
+
|
|
|
|
+ $header = $this->head;
|
|
|
|
+ //每刻所有配置
|
|
|
|
+ $url_array = $this->param;
|
|
|
|
+ //组织获取参数
|
|
|
|
+ $url = $this->domain_url . $url_array['department'];
|
|
|
|
+ $header = array_merge(['Content-Type:application/json'], $header);
|
|
|
|
+
|
|
|
|
+ $return = [];
|
|
|
|
+ $offset = 1;
|
|
|
|
+ $count = 100;
|
|
|
|
+ do {
|
|
|
|
+ $post = [
|
|
|
|
+ 'pageNo' => $offset,
|
|
|
|
+ 'pageSize' => $count,
|
|
|
|
+ ];
|
|
|
|
+
|
|
|
|
+ list($status, $result) = $this->post_helper($url,$post, $header);
|
|
|
|
+ if(! $status) return [$status, $result];
|
|
|
|
+ if(isset($result['code']) && $result['code'] != 'ACK') return [false, $result['message']];
|
|
|
|
+
|
|
|
|
+ if(! empty($result['data']['list'])){
|
|
|
|
+ foreach ($result['data']['list'] as $value){
|
|
|
|
+ $return[] = [
|
|
|
|
+ 'name' => $value['name'],
|
|
|
|
+ 'businessCode' => $value['businessCode'],
|
|
|
|
+ 'parentBizCode' => $value['parentBizCode'],
|
|
|
|
+// 'fullName' => $value['fullName']
|
|
|
|
+ ];
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $next = $result['data']['hasNextPage'];
|
|
|
|
+
|
|
|
|
+ // 更新 offset
|
|
|
|
+ $offset += 1;
|
|
|
|
+
|
|
|
|
+ } while ($next);
|
|
|
|
+
|
|
|
|
+ return [true, $return];
|
|
|
|
+ }
|
|
|
|
+
|
|
public function post_helper($url, $data, $header = [], $timeout = 20){
|
|
public function post_helper($url, $data, $header = [], $timeout = 20){
|
|
Log::channel('apiMcLog')->info('每刻POST', ["api" => $url , "param" => $data ,"header" => $header]);
|
|
Log::channel('apiMcLog')->info('每刻POST', ["api" => $url , "param" => $data ,"header" => $header]);
|
|
|
|
|