/** *根据ordersn取得下次审核人Id的array */ public static function getNextAuditorIdForWh($ordersn) { //审核人id $auditorIdArr = array(); //定义一个数组用来存放下一级对ordersn审核人Id if (empty($ordersn)) { return $auditorIdArr; } //根据ordersn取出对应的invoiceTypeId,storeId $tName = 'wh_iostore'; $select = 'invoiceTypeId,storeId'; $where = "WHERE is_delete=0 AND ordersn='{$ordersn}'"; $whIostoreList = WhAuditModel::getTNameList($tName, $select, $where); if (empty($whIostoreList)) { //ioStore表中不存在ordersn这条记录 return $auditorIdArr; } $invoiceTypeId = $whIostoreList[0]['invoiceTypeId']; //出入库单据类型 $storeId = $whIostoreList[0]['storeId']; //仓库id $whARByOrdersn = WhAuditModel::getAuditRecordsByOrdersn($ordersn); //根据ordersn在records表中查找出最大id,其最大id所在的auditrelationId所关联的auditlevel就是该ordersn已经存在的最大审核级别记录 if (empty($whARByOrdersn)) { //如果$whARByOrdersn为空,则表示records表中没有该ordersn的记录, $minALevel = WhAuditModel::getMinALevelByIS($invoiceTypeId, $storeId); //取出list表中invoiceTypeId,storeId下已经开启的最小的auditLevel if (empty($minALevel)) { //如果$minALevel为空,表示list表中不存在开启的$invoiceTypeId,$storeId的记录 return $auditorIdArr; } $whAuditorIdsList = WhAuditModel::getAuditorIdsByISL($invoiceTypeId, $storeId, $minALevel); //取得invoiceTypeId,storeId下和本次auditorId匹配的最小level的list中的对应的auditorId列表 if (!empty($whAuditorIdsList)) { //如果不为空 foreach ($whAuditorIdsList as $value) { $auditorIdArr[] = $value['auditorId']; } } return $auditorIdArr; } else { //如果$whARByOrdersn不为空,则表示records表中有该ordersn的记录,此时需要找出记录中最大的auditlevel $whARAidsArray = array(); //定义一个数组存放$whARByOrdersn中的auditRelationId foreach ($whARByOrdersn as $value) { $whARAidsArray[] = $value['auditRelationId']; } $whARAidsString = implode(',', $whARAidsArray); //将$whARAidsArray转化成id1,id2,id3形式的字符串 $maxALevel = WhAuditModel::getMaxLevelByAIds($whARAidsString); //查找出$whARAidsString中auditLevel最大的 if (empty($maxALevel)) { //如果为空,表示$whARAidsString中在list中都没有已经开启的记录,可能是全被人禁用了 return $auditorIdArr; } $whNextALevel = WhAuditModel::getNextLevelByISL($invoiceTypeId, $storeId, $maxALevel); //根据当前最大的auditLevel取得下一个auditLevel的值 if (empty($whNextALevel)) { //如果$whNextALevel为空,表示当前record表中最大的审核等级已经是list中最大的审核等级,不存在下一级审核了 return $auditorIdArr; } $whAuditorIdsList = WhAuditModel::getAuditorIdsByISL($invoiceTypeId, $storeId, $whNextALevel); //取得invoiceTypeId,storeId下和本次auditorLevel匹配的auditorId if (!empty($whAuditorIdsList)) { //如果不为空 foreach ($whAuditorIdsList as $value) { $auditorIdArr[] = $value['auditorId']; } } return $auditorIdArr; } }