An employee credit management method and system based on a multi-level approval workflow
The employee points management system, which utilizes a multi-level approval workflow, solves the problems of single permissions, disjointed approval processes, unclear points, and non-automated reports in existing technologies. It achieves multi-dimensional role-based permission management, transparent approval processes, real-time point calculation, and automated reporting, thereby improving the precision and transparency of employee points management.
Patent Information
- Application Number
- CN202611270813.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-20
- Publication Date
- 2026-11-27
AI Technical Summary
The existing employee points management system only supports a single role in access control, which cannot express multi-dimensional role relationships. The approval and calculation processes are not connected, the points calculation is unclear, the report generation lacks automation, and the assessment cycle management is incomplete, resulting in data chaos and opaque calculation.
It adopts a multi-level approval workflow, and realizes multi-role permission management, approval process automation, real-time point calculation and report generation automation through user and multi-dimensional role management module, multi-level state machine approval module, real-time point calculation module and group statistical report synthesis module. It supports a three-level organizational structure role permission system, uses a finite state machine model to drive the state flow of application records, calculates points independently in three dimensions, and generates structured reports on the cloud function side.
It enables flexible management of multi-dimensional role permissions, standardization and transparency of approval processes, clear and traceable point calculation, and automation and efficiency of report generation. It solves the problems of single permissions, disconnected approvals, unclear points and non-automation of reports in existing technologies, and improves the refinement and transparency of management.
Smart Images

Figure CN123180952A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer information management system technology, and in particular to an employee points management method and system based on a multi-level approval workflow. Background Technology
[0002] With the rapid development of information technology, computer information management systems are playing an increasingly important role in the daily management of various industries. In the field of organizational personnel management, the use of information technology to achieve quantitative assessment, behavior recording, and performance evaluation of members is becoming increasingly common.
[0003] Points-based management, as a common quantitative assessment method, can effectively support an organization's refined management needs by converting employee behavior into quantifiable and comparable point values. Daily performance evaluation of employees is a fundamental aspect of their work. Traditional employee points-based assessments primarily rely on manual recording, paper ledgers, and centralized review. With the development of information technology, some organizations have begun to experiment with using general-purpose spreadsheet software (such as Excel) or general-purpose office approval systems (such as the approval module of WeChat Work) for points-based management.
[0004] However, the existing points management solutions still have shortcomings. First, in terms of access control, current technologies typically only support flat access control for single roles, failing to concisely express multi-dimensional role relationships in array form, and unable to dynamically generate differentiated function menus based on different role combinations. Second, regarding the connection between approval and calculation, the application data and approval process are disconnected. After approval, data still needs to be manually transcribed into the points summary table, failing to achieve automatic conversion and real-time effectiveness of approval results into points data. Third, in terms of points calculation, existing solutions cannot independently calculate and differentiate the three different types of points: basic points, contribution points, and deduction points. The mixing of these three types leads to unclear points sources, opaque calculation processes, and difficulties in traceability. Fourth, in terms of report generation, when multiple groups exist, administrators need to extract data from each group individually, calculate separately, and then manually merge them, lacking automated group aggregation and structured report capabilities. Fifth, in terms of assessment cycle management, there is a lack of a mechanism to automatically create and switch assessment cycles based on system time, failing to effectively isolate points data from different cycles, leading to cross-cycle data interference. Summary of the Invention
[0005] The purpose of this invention is to provide an employee points management method and system based on a multi-level approval workflow, in order to solve the problems of existing technology such as single role in access control, lack of connection between approval and calculation, unclear points calculation, lack of automation in report generation, and lack of self-built and switchable assessment cycles.
[0006] To achieve the above objectives, the present invention provides the following technical solution: an employee points management system based on a multi-level approval workflow, comprising an interactive front-end mobile application and a back-end cloud development platform, wherein the system includes the following functional modules: The user and multi-dimensional role management module maps the organization's three-tier organizational structure to a system role and permission system. The roles are: ordinary employee, team leader, and administrator, which are three core system roles. The user roles are stored in the role field of the cloud data collection in the form of an array, and a single user can have multiple roles. The role field can be a single string value (such as "member") or an array containing multiple role identifiers (such as "["member", "leader"]"). The standard points application and supporting module is used for users to submit points application requests. The points application request includes at least: application type, application dimension, self-assessment score, details of the matter, and supporting documents. When applying, it supports uploading multiple images and multiple documents at the same time. After the application documents are uploaded to the cloud storage, the cloud file ID generated is concatenated with commas and stored in the file ID field of the application record collection. A multi-level state machine approval module is used to drive the state transition of application records in the approval process using a finite state machine model. The approval process includes at least a first approval node and a second approval node. The states include at least four states: pending review, pending deliberation, approved, and rejected. The reviewer at the first approval node performs a preliminary approval or rejection operation on the pending application records belonging to their group. After the preliminary approval is approved, the state changes from pending review to pending deliberation. The reviewer at the second approval node performs a final approval or rejection operation on the pending application records transferred from the previous approval node. After the final approval is approved, the state changes from pending deliberation to approved, and the corresponding score of the application record takes effect and is included in the total score. The rejected record is modified by the user and resubmitted, and the state is reset to pending review. The real-time points calculation module is used to recalculate points in response to users entering the points viewing page. The points calculation adopts a three-dimensional independent accounting model, which includes a base points channel, a contribution points channel, and a deduction points channel. The calculation of each channel is completed independently. After the independent calculation is completed, the points are integrated through the model, and the calculation results are rendered and displayed on the user interface in real time through a data binding mechanism. The grouped statistical report synthesis module is used to perform the following operations in response to the report export request from the cloud function end: query the user set, the declaration record set, and the deduction record set in parallel from the cloud database; group and aggregate the data according to the user's group field; call the xlsx library to generate a multi-sheet Excel workbook containing a summary table and independent sub-tables for each group; upload it to cloud storage and return a temporary download link. The public announcement and objection appeal module is used by administrators to publish public announcements of points and by employees to submit objection appeals and supporting materials regarding the points verification results. The administrator then processes the objection appeals.
[0007] Preferably, the user and multi-dimensional role management system module perform the following merge filtering operation when generating function menus: Step 1: Normalize the user role field into an array format; if role is the string "member", convert it to ["member"]; if role is already an array ["member", "leader"], leave it as is. Step 2: Detect whether the array contains management role identifiers (leader and / or committee) using the Array.includes() method; the management role identifiers must include at least the first approval node reviewer and the second approval node reviewer, or the first approval node reviewer or the second approval node reviewer; Step 3: If a management role identifier is detected, filter the ordinary employee role items from the array; Step 4: Iterate through the menu configuration list corresponding to the retained role items after filtering, use the menu item path as the deduplication key, and use JavaScript's Set data structure to merge and remove duplicates to generate the final function navigation menu list.
[0008] Preferably, the application types include bonus point applications and deduction point applications; the system presets multiple standardized bonus point dimensions for both bonus point applications and deduction point applications in the form of JavaScript constant arrays in the front-end code, and the bonus point applications at least include: outstanding contribution dimension, suggestion and advice dimension, role played dimension, and employee service dimension; the deduction point applications at least include: behavioral norms dimension, rule compliance dimension, training and learning dimension, and fee payment dimension; When submitting a declaration, after the user selects the declaration type, the system dynamically switches and displays the corresponding dimension selector for the user to choose from based on the declaration type. After the user completes the dimension selection, fills in the details of the matter, and enters the self-assessment value, one or more declaration records can be added to the declaration list and a batch submission operation can be performed. The supporting materials are images and documents. After being uploaded to cloud storage, the generated cloud file IDs are concatenated with commas and stored in the file ID field of the declaration record set.
[0009] Preferably, in the multi-level state machine approval module: when the first approval node reviewer reviews the application, the system performs data isolation filtering on the application records through the user's group field in the user set, so that the first approval node reviewer can only view and operate the application records submitted by employees within their own group; the first approval node reviewer has the authority to modify the score, and can modify the score field of the application record during the initial review, and the modified score is directly written to the database; the first approval node reviewer has the authority to make an initial review decision, and when clicking "Approve", the application record status changes from pending review to pending consideration, and when clicking "Reject", the application record status changes from pending review to rejected. The reviewer at the second approval node is not restricted by the group field and has the authority to view all application records. The reviewer at the second approval node also has the authority to modify the score field of the application record during the final review. The reviewer at the second approval node has the authority to make the final decision. When the reviewer clicks "Approve", the status of the application record changes from "Pending Review" to "Approved" and the score of the application record enters the points calculation process. When the reviewer clicks "Reject", the status of the application record changes from "Pending Review" to "Rejected". Each status change operation will automatically record the user ID and operation timestamp of the operator.
[0010] Preferably, in the real-time integral calculation module, the three-dimensional independent accounting model includes a base score channel, a contribution bonus channel, and a deduction channel. The calculations of the three channels are independent of each other, and the integral calculation execution flow is as follows: S1: The system calls the getCurrentCycle() method to retrieve the assessment cycle record with the current status of "in progress" from the assessment cycle set in the cloud database, and reads the cycle identifier of the record; S2: Execute two database queries in parallel from the application records in the cloud database to retrieve all application records of the current user from the set; S3: Based on all the application records obtained in step S2, use the JavaScript Array.filter() method to filter records that meet all of the following conditions as valid contribution records: the cycle identifier matches the current assessment cycle identifier obtained in step S1, the status is "passed", and the score is positive; sum the score field values of all valid contribution records to obtain the contribution score. S4: Retrieve all deduction records of the current user in the current assessment period from the deduction record set of the cloud database, sum the score field values of all deduction records to obtain the deduction value; S5: Calculate the total score according to the formula, and determine the corresponding score level according to the preset level division rules. The specific formula is: Total Score = MAX(0, MIN(Preset base score + Contribution bonus - Deduction, Preset upper limit of total score)), where the preset base score and the preset upper limit of total score are set through the system configuration object, and the total score is finally constrained within the range of [0, 100] by the MAX and MIN functions; the preset level division is as follows: total score ≥ 80 is "Excellent", 70-79 is "Good", 60-69 is "Pass", and below 60 is "Fail". At the same time, if the user has a veto record (query the vetos set), the level will be forcibly set to "Fail" regardless of the total score. S6: The total score, sub-values for each channel, and score level results calculated in step S5 are rendered and displayed on the user interface through the data binding mechanism (setData method) of the interactive front-end mobile application. The base score is always displayed as a fixed value of 50 points; the score level is visually distinguished by different colors: Excellent (green), Good (blue), Pass (orange), and Fail (red). This is achieved through WXSS style binding. S7: The points calculation responds to the user's operation of entering the points viewing interface by repeatedly executing steps S1 to S6 to realize the real-time recalculation and presentation of points data.
[0011] Preferably, the grouping statistics and report synthesis module performs the following operations by the cloud function: Step 1: In response to the report export request, use the cloud function Promise.all to query the user set, application record set, and deduction record set in the cloud database in parallel to obtain all user data, all approved application record data, and all deduction record data; if the deduction record set query fails, it is replaced with an empty array without interrupting the overall process; Step 2: Group all user data obtained in Step 1 according to the user's group field, and sort the users in each group in descending order of total score; Step 3: Use the xlsx library to create an Excel workbook. Generate a first sheet in the workbook as a summary table. The summary table includes the following: group name, number of people in the group, highest score in the group, lowest score in the group, average score in the group, breakdown score, and total score; wherein the breakdown score = average score in the group * 0.4. Step 4: Generate a separate sheet for each group in the workbook. Each group sheet includes the following: name, personnel category, base score, contribution points, deductions, total score, and details of points added and deducted. Step 5: Upload the generated Excel workbook to cloud storage and return a temporary download link with time-sensitive access authentication.
[0012] Preferably, the automatic synthesis method for the addition / subtraction details column is as follows: For each employee, iterate through all the employee's approved application records in the current assessment period, and concatenate them in the format "+{score}{application dimension}:{item details}" to generate each bonus point detail; iterate through all the employee's deduction records in the current assessment period, and concatenate them in the format "-{score}{deduction reason}" to generate each deduction detail; Link all generated bonus and deduction details in chronological order using line breaks to form the employee's bonus / deduction details text. If the details text exceeds the Excel cell character limit, it will be automatically truncated and a truncation mark will be added.
[0013] Preferably, the system employs a dual-channel authentication mechanism: Regular Employee Channel: Identity authentication is performed based on the program authorization protocol. After the user authorizes through the interactive front-end mobile program client, the system calls the cloud function to obtain the user's unique WeChat identifier. Based on the unique WeChat identifier, the system automatically matches an existing account in the user set to complete the login. If no corresponding account exists, the user is guided to complete the registration. Management Role Channel: An independent username and password authentication channel is adopted. The username and password are stored in an independent field of the user set. This authentication system is completely decoupled from the WeChat unique identification system. Users with management roles can log in by entering their username and password. After logging in, the system generates the corresponding management function menu based on the user role array.
[0014] Preferably, the system further includes an automatic assessment cycle creation module: when the system starts or when the administrator accesses the assessment cycle management page, the automatic assessment cycle creation module checks whether there are assessment cycle records with a status of "in progress" in the assessment cycle set of the cloud database. If it does not exist, the current quarter will be automatically calculated based on the current system date: Current quarter = current month divided by 3 and rounded up, generating cycle identifier = current year * 10 + current quarter; A new assessment cycle record is created based on the cycle identifier and the current quarter, and the initial status of the record is set to "in progress".
[0015] Preferably, an employee points management method based on a multi-level approval workflow, wherein the system implements the following steps: S1: When the system starts up or the administrator accesses the period management page, check if there is an ongoing assessment period. If not, automatically create an assessment period record based on the current date. S2: Employees authorize and log in to the system through the interactive front-end mobile application, select the standardized scoring dimension or deduction dimension, fill in the details of the matter and the self-assessment value, upload supporting materials and submit the points application request. The system writes the application record into the cloud database and initializes the status to pending review. S3: After the first approval node reviewer logs into the system, the system filters and isolates data based on the user's group, displaying a list of pending application records for the group to which the first approval node reviewer belongs. The first approval node reviewer selects one or more records for review, modifies the score, and clicks "Approve" or "Reject". If "Approve" is clicked, the application record status changes from "Pending Review" to "Pending Deliberation", and the reviewer's identifier and review time are recorded. If "Reject" is clicked, the application record status changes from "Pending Review" to "Rejected", and the reviewer's identifier and review time are recorded. S4: After logging into the system, the reviewer at the second approval node displays a list of all pending application records. The reviewer selects one or more records for final review, modifies the score, and clicks "Approve" or "Reject". If "Approve" is clicked, the application record status changes from pending review to approved, and the score of that record enters the points calculation process. If "Reject" is clicked, the application record status changes from pending review to rejected, and the reviewer's statement and review time are recorded. S5: When a user enters the points viewing page, the points calculation module retrieves the application records and deduction records with a positive status and score from the cloud database in real time within the current assessment period. It calculates the total points through a three-dimensional independent accounting model and renders the calculation results on the user interface in real time through a data binding mechanism. S6: After the administrator publishes the points announcement, employees view the announcement and submit objections and supporting materials regarding the points verification results. The administrator then processes the objections and appeals. S7: In response to the report export request, the cloud function queries the user set, the application record set, and the deduction record set in parallel, groups and aggregates them according to the user's group field, calls the xlsx library to generate a multi-sheet Excel workbook containing a summary table and independent sub-tables for each group, uploads it to cloud storage, and returns a temporary download link.
[0016] Compared with the prior art, the beneficial effects of the present invention are as follows: 1. This invention maps an organization's three-tier organizational structure to system roles through a user and multi-dimensional role management module. User roles are stored in a cloud database as an array, supporting multiple role combinations. A menu merging and filtering algorithm is used to dynamically generate and deduplicate function navigation menus. This effectively solves the problems in daily management where only single-role flat permission control is supported, making it impossible to concisely express multi-dimensional role relationships in array form, or dynamically generate differentiated function menus based on different role combinations. This achieves flexible management of multi-dimensional role permissions.
[0017] 2. This invention, through a multi-level state machine approval module, precisely defines the transition rules between the four states of "pending review → pending deliberation → approved / rejected" using a finite state machine model. It achieves a two-level progressive approval process of "team leader initial review + general manager's office final review," with each approval node having the authority to modify scores, and status changes automatically recording the operator's identifier and timestamp. Simultaneously, upon approval, the score of the application record automatically takes effect and enters the points calculation process. This effectively solves the problems of fragmented application data and approval processes, the need for manual data transcription after approval, and the lack of transparency and traceability in the approval process, achieving standardization, automation, and full traceability of the approval process.
[0018] 3. This invention utilizes a real-time integration calculation module, employing a three-dimensional independent calculation model for independent calculations. After independent calculation, each component is combined using MAX / MIN constraint functions to form the final integral. The integral is recalculated in real-time each time the page loads and rendered using a data binding mechanism. This effectively solves the problems of the inability to independently calculate and differentiate three types of integrals, the unclear source of the integral due to the mixing of these three types, and the lack of transparency and traceability in the calculation process. It achieves clear traceability of the integral source, transparency and reliability of the calculation process, and real-time presentation of the integral status.
[0019] 4. This invention, through its grouping statistics and report synthesis module, decentralizes report generation logic to the cloud function side for execution. It uses Promise.all to query three data sets in parallel: user, application records, and deduction records. Data is then grouped and aggregated according to the user's group field. The xlsx library is called to generate a multi-sheet Excel workbook containing a summary table and independent sub-tables for each group. Simultaneously, it supports the automatic synthesis of complete score change records for each member, detailing additions and subtractions. This effectively solves the technical problems of needing to extract data from each group individually, calculate separately, and then manually merge, as well as the lack of automated grouping aggregation and structured report generation capabilities when dealing with multiple groups. This achieves automated, structured, and efficient report generation. Attached Figure Description
[0020] Figure 1 This is a diagram showing the overall module structure of the employee points management system with multi-level approval workflow of the present invention. Figure 2 This is the overall flowchart of the employee points management method with multi-level approval workflow of the present invention. Detailed Implementation
[0021] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0022] Example 1 This invention provides an employee points management system based on a multi-level approval workflow, including an interactive front-end mobile application and a back-end cloud development platform. The system includes the following functional modules, see reference. Figure 1 : The user and multi-dimensional role management module maps the organization's three-tier organizational structure to a system role and permission system. The roles are: ordinary employee, team leader, and administrator—three core system roles. User roles are stored as an array in the `role` field of the cloud data collection, and a single user can have multiple roles. The `role` field can be a single string value (e.g., "member") or an array containing multiple role identifiers (e.g., "["member", "leader"]"). During role checks, the system uniformly standardizes the `role` field into an array format before making a judgment. Furthermore, when generating function menus, the user and multi-dimensional role management system module perform the following merge and filtering operations to address menu redundancy for users with multiple roles and the requirement that management roles should not display menus for ordinary employees: Step 1: Normalize the user role field into an array format; if role is the string "member", convert it to ["member"]; if role is already an array ["member", "leader"], leave it as is. Step 2: Check if the array contains management role identifiers (leader and / or committee) using the Array.includes() method; the management role identifier must contain at least the first approval node approver and the second approval node approver, or the first approval node approver or the second approval node approver. Step 3: The menu for the management role itself already covers its viewing permissions as an employee, so there is no need to display the menu for ordinary employees. Therefore, if the management role identifier is detected, the ordinary employee role "member" item is filtered from the array. Step 4: Iterate through the predefined menu configuration list corresponding to the retained role items after filtering. The menu configuration for each role is an array of menu items with a fixed path, defined in a constant object in the front-end code. Use the menu item path (path field) as the deduplication key and use JavaScript's Set data structure to merge and remove duplicates, generating the final function navigation menu list.
[0023] Furthermore, this system also employs a dual-channel authentication mechanism: For regular employees: After authentication based on the front-end program (WeChat client) authorization protocol, the system calls `wx.login()` to obtain the user's temporary login credential `code`, and then sends the `code` to the cloud function `login`. Internally, the cloud function calls the WeChat API's `auth.code2Session` interface to obtain the user's unique WeChat identifier (OpenID). Based on the OpenID, it queries the `users` collection for a matching existing account: if it exists, it returns the user information to complete the login; if it does not exist, it returns `isNew` with the flag set to `true`, guiding the user to complete the registration process. During registration, the cloud function `register` is called to create a new document in the `users` collection, writing the OpenID into the `_openid` field, and writing information such as name, group, and employee category into the corresponding fields. Management Role Channel: A username / password authentication channel independent of WeChat OAuth is used, completely decoupled from the WeChat OpenID system. Users enter their username (corresponding to the mgmtLoginName field in the users collection) and password on the administrator login page. The system directly retrieves matching records using the cloud database's where() query method: db.collection(“users”).where({mgmtLoginName:username,password:hashedPassword}).get(). After login, the system first checks whether the user's role array contains a leader or committee management role identifier; if not, login is denied.
[0024] In this embodiment, the system defines menu configurations for three roles (stored as JavaScript constant objects in the front-end utils / role.js file) instead of storing them in the cloud database. The reasons for this design are: (1) Menu items are strongly bound to the mini-program page path, modifying the menu means modifying the mini-program code and republishing, so there is no need to database the menu configuration; (2) Front-end constant access has no network latency and has the best performance; (3) Menu configuration does not involve dynamic changes and does not need to be dynamically read from the database at runtime. If the menu configuration needs to be modified, the constant definition in the source code needs to be modified and the mobile mini-program needs to be republished. Password security mechanism: Passwords are stored with salt using the SHA-256 hash algorithm. During registration, the system generates a random salt value (16 bytes), concatenates the "plaintext password + salt value" and calculates the SHA-256 hash, and stores the hash result and salt value in the password field and passwordSalt field of the users collection, respectively. During login verification, the system retrieves the user's salt value, performs the same hash calculation on the password entered by the user, compares the calculation result with the hash value stored in the database, and if they match, the verification is successful. Salt ensures that even if two users set the same password, their stored hash values will be different, preventing rainbow table attacks. Since WeChat Mini Program Cloud Development does not directly support Node.js's `crypto` module, in actual deployment, the `crypto` module on the cloud function side can be used for hash calculation: `const crypto = require("crypto"); const hash = crypto.createHash("sha256").update(password + salt).digest("hex");`. Self-approval protection mechanism: The system adds self-approval detection logic to the approval module: When the team leader approves and the administrator reviews, before rendering the list of pending approvals / reviews, the front end compares the `userId` field of all records with the `_id` field of the currently logged-in user. If `userId` equals the current user's `_id`, the record is marked as "self-approved, not allowed to self-approved," and the approval button is grayed out and disabled. Simultaneously, the cloud function side performs a secondary verification before executing the status update operation: it queries the `userId` field of the target declaration record; if it is the same as the current operator's `_id`, it directly returns an error and refuses to update. Dual verification ensures that no user can approve their own submitted records, eliminating the self-approval loophole of users with multiple roles (such as users who have both member and leader roles).
[0025] The standard points application and supporting documentation module is used for users to submit points application requests. A points application request must include at least: application type, application dimension, self-assessment score, details of the matter, and supporting documents. When applying, it is supported to upload multiple images and multiple documents at the same time. After the application documents are uploaded to the cloud storage, the cloud file ID generated is concatenated with commas and stored in the file ID field of the application record collection. Furthermore, the application types include bonus point applications and deduction point applications; the system pre-sets multiple standardized bonus point dimensions for both bonus point applications and deduction point applications in the form of JavaScript constant arrays in the front-end code. Bonus point applications at least include: outstanding contribution dimension, suggestions and advice dimension, role played dimension, and employee service dimension; deduction point applications at least include: code of conduct dimension, rule compliance dimension, training and learning dimension, and fee payment dimension. The application system adopts a two-stage file management model of "instant upload + association upon submission": Stage 1 (Instant Upload): After the user clicks the "Upload Image" or "Upload Document" button on the application page, the system immediately calls `wx.chooseImage()` or `wx.chooseMessageFile()` to select a file. After selection, `wx.cloud.uploadFile()` is immediately called to upload the file to the "contributions / " directory in cloud storage. Upon successful upload, the fileID returned by cloud storage is temporarily stored in the `fileList` array on the front-end page (in a temporary in-memory state). At this point, the file is stored in cloud storage but not yet associated with any application record. Stage 2 (Association upon Submission): When the user clicks the "Submit" button, the system iterates through the `fileList` array, concatenating the fileIDs of each file into a single string separated by commas (e.g., "cloud: / / xxx.jpg,cloud: / / yyy.pdf"), and writes this string as the value of the `fileID` field along with the application record into the `contributions` collection. Storing multiple file IDs separated by commas avoids creating a separate attachment association table.
[0026] In this embodiment, the preset values for bonus points and deductions are standardized by the organization, and the specific details are as follows: Bonus point application dimensions: (1) Outstanding contributions - 5 points are added for those who have won the title of advanced or above at the district level; 3 points are added for participating in skills competitions, project construction, etc.; (2) Suggestions and advice - 3 points are added for each reasonable suggestion, and an additional 5 points are added if the case is filed by the superior department; (3) Role played - 2 points are added for participating in special exchange and discussion and displaying on the board or sharing courses; (4) Serving employees - 1-5 points are added depending on the scale of the activity for participating in voluntary blood donation, volunteer service, etc.; Deduction point application dimensions: (1 (1) Code of Conduct - 1-5 points will be deducted for making inappropriate remarks on the Internet, in meetings, etc. that cause adverse effects; (2) Compliance with rules and regulations - 5 points will be deducted for general violations; serious violations of the company's rules and regulations will result in a veto; (3) Training and learning - 2 points will be deducted for each unexcused absence from the prescribed group activities; 2 points will be deducted for each uncompleted learning task; (4) Payment of fees - 1-2 points will be deducted for overdue payment of fees; 5 points will be deducted for unexcused arrears; The above scoring dimensions and deduction dimensions are all hard-coded in the Page data of the front-end pages / declare / declare.js file in the form of JavaScript constant arrays, rather than stored in the cloud database; When it is necessary to modify the assessment dimensions, it is necessary to issue a unified change instruction through the code, and simultaneously modify the four corresponding scoring standard constant arrays of addItems, addStandards, deductItems, and deductStandards in the source code and re-release the mobile applet.
[0027] In this embodiment, the automatic cleanup strategy for unsubmitted files is as follows: If a user selects a file, uploads it, and then exits the page without clicking submit, the file uploaded to cloud storage will become an "orphan file." The system uses a timed trigger (executed every 24 hours) set in a cloud function to scan for files in the "contributions / " directory that have not been referenced for more than 24 hours and automatically deletes them, ensuring that storage space is not wasted. Simultaneously, during the onUnload lifecycle of the mini-program page, if the fileList array is detected to be non-empty and the user has not initiated a submission operation, the user can be prompted "Save draft?".
[0028] In this embodiment, the transaction processing logic for batch submission is as follows: Users can add multiple declaration records to the declareList (a front-end memory variable) on the declaration page, and then perform batch writing after clicking the "Batch Submit" button. Since the WeChat Mini Program cloud database does not support transactions, the system adopts a "best-effort + failure compensation" strategy. (1) Iterate through the declareList array and call the add() method of the cloud database to write each declaration record in the array into the contributions collection.
[0029] (2) If all records are successfully written, the batch submission is completed, the front end clears declareList and displays a success message.
[0030] (3) If the Nth record fails to be written (due to network timeout, database rate limiting, etc.), the system records the index position of the current failure. The previous N-1 successfully written records are not rolled back (because cloud databases do not support cross-document transaction rollback). The system returns a "partially committed" status to the frontend: N-1 records were successful, and 1 record failed. The frontend retains the remaining records in declareList starting from the Nth record for the user to retry. The frontend clearly informs the user in a toast message: "N-1 records have been committed, the Nth record failed, please retry."
[0031] (4) Since each application record is an independent, self-contained data (containing complete fields such as userId, userName, and userGroup), partial success will not lead to data inconsistency. Resubmitting after rejection will create a new record instead of modifying the original record, thus avoiding modification conflicts.
[0032] Sorting rules for batch submissions: When iterating through submissions, entries are written sequentially according to the order of declareList (i.e., the order in which users added the entries). For successfully submitted records, each record in the declaration record collection contains a createTime field (cloud database serverDate()), which is used as the sorting basis for subsequent review and viewing. If two records have the same createTime (e.g., in the same batch submission), they are then sorted lexicographically by _id to ensure consistent query results in each query.
[0033] The multi-level state machine approval module is used to drive the state transition of application records in the approval process using a finite state machine model. The approval process includes at least a first approval node and a second approval node. The status includes at least four states: pending review, pending deliberation, approved, and rejected. The reviewer at the first approval node performs a preliminary approval or rejection operation on the pending application records belonging to their group. After the preliminary approval is approved, the status changes from pending review to pending deliberation. The reviewer at the second approval node performs a final approval or rejection operation on the pending application records transferred from the previous approval node. After the final approval is approved, the status changes from pending deliberation to approved, and the corresponding score of the application record takes effect and is included in the total score. If a rejected record is modified by the user and resubmitted, the status is reset to pending review. Furthermore, in the multi-level state machine approval module, when the first approval node reviewer reviews the application, the system uses the user's group field in the user set to perform data isolation filtering on the application records. This ensures that the first approval node reviewer can only view and operate on the application records submitted by employees within their own group that are pending review. The first approval node reviewer has the authority to modify the score, and can modify the score field of the application record during the initial review. The modified score is directly written to the database. The first approval node reviewer also has the authority to make an initial review decision. When the reviewer clicks "Approve," the application record status changes from pending review to pending consideration. When the reviewer clicks "Reject," the application record status changes from pending review to rejected. The second-level reviewer is not restricted by the group field and has the authority to view all application records. The second-level reviewer also has the authority to modify the score field of the application record during the final review. The second-level reviewer has the authority to make the final decision. When the reviewer clicks "Approve", the status of the application record changes from "Pending Review" to "Approved" and the score of the application record enters the points calculation process. When the reviewer clicks "Reject", the status of the application record changes from "Pending Review" to "Rejected". In addition, each status change operation will automatically record the user ID and operation timestamp of the operator.
[0034] In this embodiment, during the team leader's review process, the system implements data isolation through the WHERE condition in the database query layer, ensuring that the team leader can only view and manipulate pending application records submitted by employees within their own team. Specifically, the two-step filtering strategy for data isolation is as follows: Step 1 (Database Layer Filtering): When calling the getPendingContributions(group) method of the cloud database, a database query is constructed on the front end (pages / leader / leader.js), and a double filtering condition is applied by chaining the .where() method: (1) the status field equals "pending approval"; (2) if the current user is the group leader, the userGroup field is added to be equal to the current user's group field value. This query is directly transformed into a compound query statement of the cloud database, which is efficiently executed by the database engine on the server side, returning only the matching records.
[0035] The second step (front-end rendering layer filtering): The data returned by the database query is filtered again on the front end using JavaScriptArray.filter() to remove application records where userId equals the currently logged-in user's _id (self-approval protection), ensuring that no user can approve their own submitted application records. The final filtered result is rendered to the list on the interface using the setData() method.
[0036] When an administrator reviews submissions, the `getPendingContributions()` method is called without passing the `group` parameter, meaning no `userGroup` filtering condition is applied. This allows the administrator to view all pending submission records from all groups. This design achieves differentiated permissions through conditional query parameters, rather than maintaining a separate permission table.
[0037] In this embodiment, the specific implementation process for the group leader and administrator to modify the score at their respective approval nodes is as follows: Front-end score editing process: (1) When the review page displays the list of items to be reviewed / reviewed, the system maintains an editScores object (the key is the record ID, and the value is the edited score). The initial value is the same as the original score field of the record. When the reviewer modifies the score in the input box, the system temporarily stores the new score in the editScores object through the onScoreEdit event handler (only in front-end memory, not yet persisted). (2) When the reviewer clicks the "Modify Score" button, the system pops up a confirmation box "Modify the application score to {newScore} points". (3) After the user confirms, the system performs two operations simultaneously: calls db.collection("contributions").doc(id).update({ data: { score: newScore}}) to directly write the modified score to the score field of the database (overwrite update); and updates the score field of the corresponding list item on the front end synchronously and refreshes the interface through setData().
[0038] Audit traceability of score modification history: The system maintains two additional fields in each declaration record in the contributions collection to achieve audit traceability: The originalScore field records the applicant's original self-assessment score at the time of submission. Once written, this field is not modified and serves as the benchmark for auditing.
[0039] The `scoreModifiedBy` field records the name of the person who last modified the score. If the score has not been modified, this field is empty; if the team leader modified the score during the initial review, the field contains the team leader's name; if the administrator modified it again during the final review, the field is updated with the administrator's name. The front-end parses this field to determine if the score has been modified (if not empty, it displays a marker saying "Score has been modified by XXX"). In this embodiment, the reviewer changes the status by clicking the "Approve" or "Reject" button on the interface. The system mainly performs the following: (1) Front-end interaction process: After clicking the button, the "approveItem" or "rejectItem" event handling function is triggered (defined in pages / leader / leader.js and pages / statistics / statistics.js). The system first pops up the wx.showModal confirmation dialog box, and the reviewer confirms and then performs the subsequent operation; (2) Status update operation: The updateContributionStatus(id, status, reviewer) function in utils / data.js is called. This function internally calls the doc().update() method of the cloud database to modify the following fields of the target record: (i) the status field is updated to the target status value ("Pending review" / "Approved" / "Rejected"); (ii) the reviewer field is updated to the name of the current operator; (iii) the reviewDate field is updated to the current date (yyyy-MM-dd format). This operation is performed atomically at the single document level of the cloud database. (3) Post-Status Change Processing: After a successful update operation, the front-end calls the loadData() method to query the latest data from the cloud database and refresh the page list to ensure that the review status displayed on the interface is consistent with the database. At the same time, the system records the operation log (reviewer, review time, operation type, status change) in the fields of the application record itself, without the need for a separate log collection. (4) Cloud Function Call Description: The current system's status change operation is completed through the front-end directly connecting to the cloud database (wx.cloud.database()), without being transferred by a separate cloud function. Specifically: call db.collection("contributions").doc(id).update({ data: { status, reviewer, reviewDate}}). This update method accepts three parameters: target record ID (id), target status (status, string value), reviewer name (reviewer, string value), and returns a Promise (asynchronous operation result). If you need to introduce cloud functions for more rigorous operation validation, you can do so in the cloud function: Receive the parameters {id, status, reviewer}, first query the current status of the target record, and if the status does not meet the conversion rules (such as trying to reject a record that has been "passed" again), return an error; otherwise, perform an update operation and return success.
[0040] When a submission is rejected by the team leader or administrator (its status changes to "Rejected"), the employee can see the rejection status in their submission list. If the employee modifies the submission and resubmits it, the system creates a completely new submission record (rather than modifying the original). The new record initially has a status of "Pending Review," and all review fields (reviewer, reviewDate, etc.) are empty. The original rejection record is retained in the database as a complete audit trail. This design ensures the independence of each approval process and avoids the confusion in approval history caused by reusing original records.
[0041] In this embodiment, if concurrent editing conflicts occur, the system handles the following two concurrent scenarios: Scenario 1 (Group leader and administrator of the same group operate on the same record simultaneously): Assume that group leader A and administrator B both display a record with a status of "Pending Review" in their browsers (B may see this record through the management page). A clicks "Approve" first, updating the record's status to "Pending Review". B then clicks "Reject" or "Approve". At this time, the record status cached by B is still "Pending Review", but the record's status in the database has changed to "Pending Review". The system adopts optimistic concurrency control: conditional updates are used in the update operation, that is, not only specifying the target id, but also attaching the expected value of the status field as a condition: db.collection("contributions").where({ _id: id, status: "Pending Review"}).update({ data: { status: newStatus}}). If the record status has been modified by A first, the conditional update will not match any record (because the status is no longer "Pending Review"), and the update operation will fail silently. The front-end checks the stats.updated field (0 or 1) of the update operation to determine if the operation has taken effect: if it is 0, it means that the condition update did not match any records. The front-end can see the latest status after refreshing the list and prompt the user "The status of this record has changed. Please refresh and try again".
[0042] Scenario 2 (Group leader's continuous operations on the same record): The group leader modifies the score and immediately clicks "Approve" -- the score modification operation (updating the score field) and the status update operation (updating the status field) are two independent database calls. However, since the score modification has already been executed synchronously in the user confirmation dialog box (directly calling doc().update() to update the score), there is no intermediate state problem between the two operations after clicking "Approve".
[0043] The real-time points calculation module is used to recalculate points after a user enters the points viewing page. The points calculation adopts a three-dimensional independent accounting model, which includes a base points channel, a contribution points channel, and a deduction points channel. The calculation of each channel is completed independently. After the independent calculation is completed, the points are integrated through the model, and the calculation results are rendered and displayed on the user interface in real time through a data binding mechanism. Furthermore, in the real-time integral calculation module, the three-dimensional independent accounting model includes a basic score channel, a contribution bonus channel, and a deduction channel. The calculations of the three channels are independent of each other, and the integral calculation execution flow is as follows: S1 (Get Current Assessment Cycle): The system calls the `getCurrentCycle()` method to query the `cycles` collection in the cloud database and retrieves assessment cycle records with the status "In Progress". Query statement: `db.collection("cycles").where({ status: "In Progress"}).get()`. This method returns the `year`, `quarter`, and `id` (cycle identifier = year × 10 + quarter) fields of the record. If the query returns an empty result—that is, the database has no "In Progress" cycle—the system executes automatic creation logic: calculates the current quarter based on the current system date (`quarter = Math.ceil(month / 3)`), generates a cycle identifier (`id = year * 10 + quarter`), calls `db.collection("cycles").add()` to create a new cycle record and sets its status to "In Progress". If the query returns multiple "In Progress" records (due to system exceptions or data errors), the system retrieves the first record in descending order of `createTime`, records a warning log, and simultaneously prompts the administrator in the management backend to handle the abnormal data. S2 (Data Source Query): Two database queries are executed in parallel: (a) Query all declaration records of the current user in the `contributions` collection: `db.collection("contributions").where({ userId: userId}).orderBy("createTime", "desc").limit(100).get()`; (b) Query all deduction records of the current user in the current assessment period in the `deductions` collection: `db.collection("deductions").where({userId: userId}).get()`. The two queries are executed in parallel using `Promise.all` to improve response performance. If the `deductions` collection does not exist or the query fails (e.g., the system did not create the collection on first use), the system catches the exception and returns an empty array as the deduction result, without interrupting the calculation process. This exception handling strategy applies to query failure scenarios for all non-core data collections. S3 (Calculation of Contribution Bonus Channel): Based on all the application records obtained in step S2, use the JavaScriptArray.filter() method to filter records that meet all of the following conditions as valid contribution records: (i) the cycleId field matches the current assessment cycle identifier obtained in step S1; (ii) the status field equals "passed"; (iii) the score field is greater than 0 (only bonus points are counted, no deductions are counted). Then, for each valid contribution record in the filtering results, use the JavaScriptArray.reduce() method to sum the score field values to obtain the contribution bonus value contributionScore; S4 (Calculation of deduction channel): From all the deduction records obtained in step S2(b), sum the score field values of each record using the Array.reduce() method to obtain the deduction total. S5 (Total Score Calculation and Grade Classification): The total score is calculated according to the formula, and the corresponding score grade is determined according to the preset grade classification rules. The specific formula is: Total Score = MAX(0, MIN(Preset Base Score + Contribution Bonus Score - Deduction Score, Preset Upper Limit of Total Score)), where the preset base score and the preset upper limit of total score are set through the system configuration object. Finally, the MAX and MIN functions constrain the total score within the range of [0, 100]. The preset grade classification is: Total Score ≥ 80 is "Excellent", 70-79 is "Good", 60-69 is "Pass", and below 60 is "Fail". At the same time, if the user has a veto record (query the vetos set), the grade will be forcibly set to "Fail" regardless of the total score. S6 (Result Rendering and Score Level Display): The total score, sub-values for each channel, and score level results calculated in step S5 are rendered and displayed on the user interface using the data binding mechanism (setData method) of the interactive front-end mobile application. The base score is always displayed as a fixed value of 50 points; score levels are visually distinguished by different colors: Excellent (green), Good (blue), Pass (orange), and Fail (red). This is achieved through WXSS style binding. S7: In response to the user's entry into the points viewing interface, the points calculation repeats steps S1 to S6 to achieve real-time recalculation and presentation of points data.
[0044] In this embodiment, the points calculation adopts a "real-time calculation upon page load" mode. When a user enters the points viewing page (the onLoad and onShow lifecycle functions of pages / member / member.js), the points calculation engine is automatically triggered, executing steps S1-S7 described above in sequence. This design ensures that each time a user views their points, the displayed result is based on the latest database state, achieving "page refresh upon entry." To optimize performance and reduce unnecessary database queries, the system maintains the following memory cache variables in the front-end utils / data.js module: The specific steps for checking the caching strategy are as follows: Step 1 (Cache Existence Check): Check if the memory cache variable has been initialized (e.g., _usersCache.length === 0 or _currentCycle === null).
[0045] Step 2 (Cache Hit): If the cache has been initialized and is not empty, return the cached data directly without querying the database. This step greatly reduces the number of database reads when users frequently enter / exit the page.
[0046] Step 3 (Cache Miss - Initial Load): If the cache is empty, query the cloud database to retrieve the latest data and populate the cache. The initial query will retrieve a limit(100) record of user data, covering the user scale of most organizations.
[0047] Step 4 (Proactive Cache Refresh): When a user performs an operation that changes the database state (such as submitting a new application, approving / rejecting an application, or publishing an announcement), the system proactively calls the corresponding refresh function to refresh the cache in the success callback, rather than relying on a passive expiration strategy. For example, refreshAnnouncements() is called immediately after an announcement is published to update the announcement cache.
[0048] Cache invalidation strategy: Cache data does not have a TTL (Time To Live) expiration time. Instead, data consistency is ensured through two mechanisms: "active refresh after write operations" and "reloading the list during the onShow lifecycle". When a user's action (such as approval) modifies the database status, the frontend calls loadData() to re-query the database and update the page, and the corresponding cache variables are also updated.
[0049] The grouped statistical report synthesis module is run independently by the cloud function exportReport client. It is used by the cloud function client to perform the following operations in response to the report export request: query the user set, declaration record set and deduction record set in parallel from the cloud database, group and aggregate the data according to the user's group field, call the xlsx library to generate a multi-sheet Excel workbook containing a summary table and independent sub-tables for each group, upload it to cloud storage and return a temporary download link; Furthermore, the group statistics and report synthesis module performs the following operations by the cloud function: Step 1: In response to the report export request, the cloud function uses `Promise.all` to query the user set, application record set, and deduction record set in the cloud database in parallel, retrieving all user data, all approved application record data, and all deduction record data. If the deduction record set query fails, it is replaced with an empty array, without interrupting the overall process. If any query in `Promise.all` that is not wrapped in `try-catch` fails, the entire `Promise.all` is rejected, and the cloud function enters the `catch` branch and returns an error message. This design ensures partial fault tolerance of the system. Step 2: Group all user data obtained in Step 1 according to the user's group field (user.group), and construct a groupMap object (the key is the group name, and the value is an array of members in that group). The grouping algorithm has a time complexity of O(n), where n is the total number of users. For large-scale data scenarios (e.g., number of users > 500), cloud functions optimize performance during the query phase by creating database indexes: create an ascending index on the group field of the users collection; create a composite index on the userId, status, and cycleId fields of the contributions collection; and create an ascending index on the userId field of the deductions collection. During queries, the limit() pagination function controls the upper limit of the number of data returned in a single query: 200 records for the users collection, 500 records for the contributions collection, and 200 records for the deductions collection. For scenarios exceeding the upper limit, multiple cloud function pagination calls or increasing the limit value are used to handle the situation. Step 3: Use the xlsx library to create an Excel workbook. Generate a first sheet within the workbook as a summary table. The summary table includes the following: group name, number of members in the group, highest score in the group, lowest score in the group, average score in the group, breakdown score, and total score; where the breakdown score = average score in the group * 0.4. The complete data structure of the summary table report is shown below: Table 1 Summary Table .
[0050] Step 4: Generate a separate sheet for each group in the workbook. Each group's sheet should include the following: Name, Personnel Category, Base Score, Contribution Points, Deduction Points, Total Score, and Details of Points Added and Deducted. The complete data structure of each group's separate sheet is shown below: Table 2. Independent breakdown of each group .
[0051] Step 5: Upload the generated Excel workbook to cloud storage, and a temporary download link with time-sensitive and access authentication will be returned. This link is automatically generated by the cloud development platform and has the following security features: (1) Time limit: The temporary download link is valid for 2 hours (by default setting of the cloud development platform), and the link will automatically expire after the time limit.
[0052] (2) Access Authentication: The temporary download link contains an access token automatically embedded by the cloud development platform. Only requests with a valid token can download the file. This token is issued by the cloud development platform server and cannot be forged by the front end.
[0053] (3) Encrypted transmission: The download link uses the HTTPS protocol, and the data transmission process is encrypted.
[0054] (4) Access Control: After generating the download link in the cloud function, it is only returned to the administrator user who requested the export. Other users cannot obtain the file by directly accessing the URL because the link is not publicly available.
[0055] (5) Cloud storage security rules: The file access permissions under the reports / directory are configured to "only the creator can read" to ensure that files are not directly downloaded by unauthorized users through cloud.downloadFile().
[0056] In this embodiment, members in each group's sub-table are sorted in descending order of total score (from highest to lowest). When two or more members have the same total score, they are sorted in ascending order by name pinyin (using JavaScript's String.localeCompare("zh-CN") method) to ensure consistent and reproducible sorting results for each report. Entries in the addition / subtraction details column are sorted in ascending order (from earliest to latest) by the createTime field of the declaration record (i.e., the serverDate() timestamp when written to the contributions collection). If two declaration records have identical createTime fields (e.g., written consecutively in the same batch submission request), they are sorted lexicographically by document_id to ensure the deterministic nature of the details display order. Groups in the summary table are arranged in a predefined group order: ["Group 1", "Group 2", "Group 3", "Group 4", "Group 5", "General Manager's Office"]. If a group exists outside the predefined order (e.g., a newly added group), it is sorted in ascending order by group name pinyin after the predefined groups.
[0057] In this embodiment, the details column for additions and subtractions may exceed the text length limit of an Excel cell (32767 characters) in extreme cases (such as when an employee has a large number of declaration records within a period). The system adopts the following processing strategy: (1) Before generating the detailed text, check the total length of the text. If the length is ≤32767 characters, write the entire text.
[0058] (2) If the length is > 32767 characters, the system will process it according to the principle of "summarize first and then detail": first truncate the detail text at 32700 characters (retain 67 characters for truncation mark), and append "(truncated, the complete detail has {N} declaration records, please log in to the system for details)" to the end.
[0059] (3) At the same time, add a note to the summary sheet of the report: "Note: The details of individual employees' points addition and subtraction have been truncated due to the large number of items. Please log in to the system to view the complete details." Furthermore, the automatic synthesis method for the addition / subtraction details column is as follows: For each employee, iterate through all the employee's approved application records in the current assessment period, and concatenate them in the format "+{score}{application dimension}:{item details}" to generate each bonus point detail; iterate through all the employee's deduction records in the current assessment period, and concatenate them in the format "-{score}{deduction reason}" to generate each deduction detail; Link all generated bonus and deduction details in chronological order using line breaks to form the employee's bonus / deduction details text. If the details text exceeds the Excel cell character limit, it will be automatically truncated and a truncation mark will be added.
[0060] In this embodiment, the detailed calculation of points for each employee in the group is as follows: a. Contribution Points Calculation: From all approved records in the contributions data (status is "Approved" and score > 0), filter out records matching the userId, and sum the score field values to obtain the contributionScore. Simultaneously, generate detailed text for each contribution point (format: "+{score} {declaration dimension}:{item details}"), with multiple details connected by newlines.
[0061] b. Deduction Calculation: Filter records matching the userId from the deductions data and sum the score field values to obtain deductionTotal. Simultaneously, generate a detailed text for each deduction (format: "-{score} {reason for deduction}"), with multiple details connected by newlines.
[0062] c. Total Score Calculation: totalScore = Math.max(0, Math.min(50 +contributionScore - deductionTotal, 100)).
[0063] d. Merge the details of points added and deducted: Connect the text of points added generated by a and the text of points deducted generated by b with a newline character; if an employee has no declaration records or points deduction records, the details column will be displayed as "None".
[0064] The public announcement and objection appeal module is used by administrators to publish public announcements regarding points calculations, and by employees to submit objections and supporting materials regarding the points calculation results. Administrators then process these objection appeals. After filling in the title and content on the announcement page and clicking "Publish," the system calls the `data.addAnnouncement()` method to write the announcement to the `announcements` collection. The document structure of this collection is: `{ title, content, author, createTime:serverDate()}`. After a successful announcement publication, the front-end immediately refreshes the announcement cache and updates the announcement list. All employees can view the list of published announcements on the announcement page and click to view details.
[0065] In this embodiment, employees submit their appeals by filling in the appeal details and supporting materials on the appeal page, and the system creates an appeal record. Administrators can view the list of pending appeals and process them (adjusting points or rejecting the appeal after verification). Appeal records are stored in the `appeals` collection and include fields such as the appellant, appeal details, supporting material file ID, and processing status.
[0066] Furthermore, the system also includes an automatic assessment cycle creation module: Trigger 1: The automatic assessment cycle creation module is activated when the system starts: In the `onLaunch` lifecycle method of `app.js`, the system calls the `cloud.getCurrentCycle()` method. This method first checks if there is a record with a status of "in progress" in the `cycles` collection. If not, it automatically calculates the current quarter based on the current system date and creates a new cycle; Trigger 2: When an administrator accesses the assessment cycle management page: When a user enters the homepage (the `onLoad` lifecycle method of `pages / home / home.js`) or other pages that require the current cycle, the system calls the `data.getCurrentCycle()` method, which similarly performs the above checks and automatic creation logic.
[0067] In this embodiment, under normal circumstances, there is at most one record with the status "in progress" in the cycles set. If multiple records with the status "in progress" exist in the database due to system failure or abnormal data writing, the system will handle them according to the following strategy: (1) The query results of the getCurrentCycle() method are sorted in descending order by createTime, and only the first record (i.e. the most recently created) is returned as the valid current cycle; (2) At the same time as returning the first record, a warning log is output to the console: "{N} in progress cycle records have been detected, and there may be data abnormalities"; (3) After the administrator sees the warning prompt in the management backend, he / she can manually handle the extra abnormal cycle records (change the status of the extra cycles to "finished" or delete them directly). The assessment cycle includes three states: in progress, finished, and not started. The complete life cycle management of the cycle is as follows: Cycle start: Created by the automatic creation mechanism when no in progress cycle is detected for the first time, and the status is initially "in progress". The administrator can also manually create a new cycle in the management backend. Cycle end: The administrator can manually trigger the "end current cycle" operation in the management backend. This operation triggers the following processing flow: (1) Update the status field of the current cycle from "in progress" to "completed"; (2) Write the points snapshot of all employees in the current cycle to the scores collection as historical archives; (3) Prevent new applications from being submitted within the cycle (the front end checks the cycle status, and if it is "completed", disables the application button); (4) The system creates a new assessment cycle for the next quarter (status="in progress"). Cycle rollback: In special circumstances (such as the cycle ending early), the administrator can restore the "completed" cycle to the "in progress" status. This operation requires secondary confirmation and recording of the operation log.
[0068] In this embodiment, data flow and coupling between modules are achieved through cloud database. The specific data flow is as follows: (1) Application → Approval data flow: After an employee submits an application for points in the "Standard Points Application and Supporting Module", the system calls the add method of the contribution collection of the cloud database to write the application record into the database, where the status field is initialized to "pending review". This write operation also triggers the refresh of the list on the front-end interface. The "Multi-level State Machine Approval Module" obtains the list of pending review by querying the records in the contribution collection where the status is "pending review" and the userGroup field matches the group to which the current reviewer belongs. When the reviewer performs the pass or rejection operation, the system calls the doc().update() method of the cloud database to modify the status field of the target record to achieve status transition.
[0069] (2) Approval → Data Flow Calculation: After the administrator approves the application, the status field of the application record is updated from "Pending Review" to "Approved", and the record enters the points calculation process. When the user enters the points viewing page, the "Real-time Points Calculation Engine" is triggered: Query the current assessment cycle identifier → Query all application records of the current user with status "Approved" and score positive within the current cycle → Query the deduction records within the current cycle → Perform three-dimensional independent accounting → Render the calculation results to the interface through the data binding mechanism of the mini program.
[0070] (3) Calculation → Report Data Flow: The "Group Statistics and Report Synthesis Module" runs independently on the cloud function side. After receiving the report export request, it queries the data of the three sets of users, contributions, and deductions in parallel through the cloud database. On the server side, it performs group aggregation calculations by group field, generates an Excel workbook, uploads it to cloud storage, and returns a temporary download link. This process is executed entirely on the server side and does not depend on the intermediate results of front-end calculations.
[0071] The data coupling between the above modules is achieved through a cloud database as a unified data bus: the application module writes contribution records, the approval module reads and updates the status of contribution records, the calculation engine reads approved contribution records and deduction records for summary calculation, and the reporting module aggregates all data for grouped statistics and Excel generation. The modules do not need to communicate directly; loosely coupled collaboration is achieved through database status changes.
[0072] Furthermore, an employee points management method based on a multi-level approval workflow involves the following steps: S1: When the system starts up or the administrator accesses the period management page, check if there is an ongoing assessment period. If not, automatically create an assessment period record based on the current date. S2: Employees log in to the system through the interactive front-end mobile application, select the standardized scoring dimension or deduction dimension, fill in the details of the matter and the self-assessment value, upload supporting materials and submit the points application request. The system writes the application record into the cloud database and initializes the status to pending review. S3: After the first-approval node reviewer logs into the system, the system filters and isolates data based on the user's group, displaying a list of pending application records for the reviewer's group. The first-approval node reviewer selects one or more records for review, modifies the score, and clicks "Approve" or "Reject." If "Approve" is clicked, the application record status changes from "Pending Review" to "Pending Deliberation," and the reviewer's ID and review time are recorded. If "Reject" is clicked, the application record status changes from "Pending Review" to "Rejected," and the reviewer's ID and review time are recorded. S4: After logging into the system, the reviewer at the second approval node will see a list of all pending application records. The reviewer will select one or more records for final review, modify the score, and then click "Approve" or "Reject". If "Approve" is clicked, the application record status will change from pending review to approved, and the score for that record will be entered into the points calculation process. If "Reject" is clicked, the application record status will change from pending review to rejected, and the reviewer's comments and review time will be recorded. S5: When a user enters the points viewing page, the points calculation module retrieves the application records and deduction records with a positive status and score from the cloud database in real time within the current assessment period. It calculates the total points through a three-dimensional independent accounting model and renders the calculation results on the user interface in real time through a data binding mechanism. S6: After the administrator publishes the points announcement, employees view the announcement and submit objections and supporting materials regarding the points verification results. The administrator then processes the objections and appeals. S7: In response to the report export request, the cloud function queries the user set, the application record set, and the deduction record set in parallel, groups and aggregates them according to the user's group field, calls the xlsx library to generate a multi-sheet Excel workbook containing a summary table and independent sub-tables for each group, uploads it to cloud storage, and returns a temporary download link.
[0073] Example 2: Employee Points Application and Approval Employee Zhang San (belonging to Group 1, role: ordinary employee) logged into the system via WeChat authorization on the mobile mini-program. On the application page, Zhang San selected the "Bonus Points Application" type, chose the "Suggestions and Recommendations" dimension from the dimension selector, filled in the details "Propose suggestions to optimize the form of corporate activities," and gave himself a score of 5. Zhang San also uploaded a supporting PDF file, which was immediately uploaded to cloud storage via wx.cloud.uploadFile(), and the returned fileID was temporarily stored on the front end. After adding this application to the submission list, Zhang San clicked "Batch Submit." The system called db.collection("contributions").add() to write the record to the cloud database, where userId is Zhang San's user identifier, userGroup is "Group 1," cycleId is the current quarter identifier (e.g., 202601), score is 5, status is initialized to "Pending Review," fileID is the cloud storage ID of the uploaded file, and createTime is the server timestamp.
[0074] Team leader Li Si (belonging to Group 1, role as team leader) logs into the system via username / password and enters the "Group Points Review" page. The system calls getPendingContributions("Group 1"), constructs a compound query condition where({ status: "Pending Review", userGroup: "Group 1"}), and returns all pending review records of Group 1 from the cloud database. The front-end filters out applications submitted by Li Si himself (self-review prevention). Li Si sees Zhang San's application record in the list, believes that the actual contribution of the suggestion is limited, changes the score from 5 points to 3 points, and clicks the "Modify Score" button. After the system pops up a confirmation box, it calls db.collection("contributions").doc(id).update({data: { score: 3}}) to write the modified score to the database, and the front-end interface refreshes synchronously. Then Li Si clicked "Pass", and the system called updateContributionStatus(id, "Pending Review", "Li Si") to update the status of the record to "Pending Review", set the reviewer to "Li Si", and set the reviewDate to the current date.
[0075] Administrator Wang Wu logs into the system via username / password and enters the "Enterprise Points Review" page. The system calls getPendingContributions() (without passing the group parameter) and returns all pending records. Wang Wu sees Zhang San's application (which has already been initially approved by Li Si), deems the score reasonable, and clicks "Approved". The system calls updateContributionStatus(id, "Approved", "Wang Wu") to update the status to "Approved". Zhang San then enters the "My Points" page, triggering the points calculation engine: retrieves the current quarter identifier → queries Zhang San's record in the contributions set with a status of "Approved" → finds the suggestion record score=3 → accumulates 3 contribution points → total points = MIN(50 + base score 50 + contribution score 3, 100) = 53 points. Zhang San's interface updates the total points to 53, and the details of the points added and subtracted show "+3 Suggestions: Proposed suggestions to optimize the form of enterprise activities".
[0076] Meanwhile, employee Zhao Liu (belonging to Group 1, role: ordinary employee) submitted an "Outstanding Contribution" application, giving himself a score of 10. Group leader Li Si reviewed it and deemed the supporting materials insufficient, clicking "Reject." The system updated the record's status to "Rejected," set the reviewer to the group leader's name, and the reviewDate to the rejection date. Zhao Liu saw this record displayed as "Rejected" on his "My Points" page. After supplementing the supporting materials, Zhao Liu resubmitted the application. The system created a completely new contribution record (new _id), initializing its status to "Pending Review" (instead of reusing the original record). The original rejection record was retained in the database as audit traceability, its status remaining "Rejected." Upon seeing Zhao Liu's new application, the group leader approved it, and the status moved to "Pending Review."
[0077] At the end of the quarter, administrator Wang Wu clicked the "Export Report" button. The system called the cloud function `exportReport`, passing in the parameters `{year: 2026, quarter: 1}`. The cloud function queried the `users`, `contributions`, and `deductions` collections in parallel to retrieve all data. After grouping by team, the system calculated the points for each employee, constructing a summary table and five separate tables for each team. A multi-sheet workbook was generated using the `xlsx` library and uploaded to cloud storage, returning a temporary HTTPS download link valid for two hours. The administrator could preview the Excel file on a mobile device or save it to their computer via "Send to File Transfer Assistant".
[0078] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0079] Although embodiments of the invention have been shown and described, it will be understood by those skilled in the art that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of the invention, the scope of which is defined by the appended claims and their equivalents.
Claims
1. An employee points management system based on a multi-level approval workflow, characterized in that, The system includes an interactive front-end mobile application and a back-end cloud development platform, and comprises the following functional modules: The user and multi-dimensional role management module maps the organization's three-tier organizational structure to a system role and permission system. The user roles are stored in the cloud data in the form of an array in the role field, and a single user can have multiple roles. The standard points application and supporting module is used for users to submit points application requests. The points application request includes at least: application type, application dimension, self-assessment score, details of the matter, and supporting documents. The cloud file ID generated after the application documents are uploaded to cloud storage is concatenated with commas and stored in the file ID field of the application record set. A multi-level state machine approval module is provided, which uses a finite state machine model to drive the state transition of application records in the approval process. The approval process includes at least a first approval node and a second approval node. The states include at least four states: pending review, pending deliberation, approved, and rejected. The reviewer at the first approval node performs a preliminary approval or rejection operation on the pending application records belonging to their group. The reviewer at the second approval node performs a final approval or rejection operation on the pending application records transferred from the previous approval node. A real-time points calculation module, which is used to recalculate points in response to the user entering the points viewing page; The integral calculation adopts a three-dimensional independent accounting model, which includes a basic score channel, a contribution score channel, and a deduction score channel. The calculation results are rendered and displayed on the user interface in real time through the data binding mechanism of the front-end program. The grouped statistical report synthesis module is used to perform the following operations in response to the report export request from the cloud function end: query the user set, the declaration record set, and the deduction record set in parallel from the cloud database; group and aggregate the data according to the user's group field; call the xlsx library to generate a multi-sheet Excel workbook containing a summary table and independent sub-tables for each group; upload it to cloud storage and return a temporary download link. The public announcement and objection appeal module is used by administrators to publish public announcements of points and by employees to submit objection appeals and supporting materials regarding the points verification results. The administrator then processes the objection appeals.
2. The employee points management system based on a multi-level approval workflow according to claim 1, characterized in that, The user and multi-dimensional role management system module also needs to perform the following merging and filtering operations when generating the function menu: Step 1: Normalize the user role field into an array format; Step 2: Detect whether the array contains a management role identifier, wherein the management role identifier contains at least the first approval node reviewer and the second approval node reviewer, or the first approval node reviewer or the second approval node reviewer; Step 3: If a management role identifier is included, filter the ordinary employee role items from the array; Step 4: Traverse the menu configuration list corresponding to the retained role items after filtering, use the menu item path as the deduplication key to merge and deduplicate the Set structure, and generate the final function navigation menu.
3. The employee points management system based on a multi-level approval workflow according to claim 1, characterized in that, In the standard points declaration and supporting module: The application types include bonus point applications and deduction point applications; both bonus point applications and deduction point applications have multiple standardized bonus point dimensions. Bonus point applications include at least the following dimensions: outstanding contribution dimension, suggestions and advice dimension, role played dimension, and employee service dimension. Deduction point applications include at least the following dimensions: code of conduct dimension, rule compliance dimension, training and learning dimension, and fee payment dimension.
4. The employee points management system based on a multi-level approval workflow according to claim 1, characterized in that, In the multi-level state machine approval module: When the reviewer at the first approval node reviews the application, the system filters the application records by isolating the data through the user's group field in the user set, so that the reviewer can only view and operate the application records submitted by employees within their own group. The reviewer at the first approval node also has the authority to modify the score and make a preliminary review decision. The score modification authority allows the reviewer to modify the score field of the application record during the preliminary review, and the modified score is directly written to the database. The preliminary review decision authority allows the reviewer to switch the status of the application record from pending review to pending consideration when clicking "Approve" and switch the status of the application record from pending review to rejected when clicking "Reject". The reviewer at the second approval node is not restricted by the group field and has the authority to view all application records; The reviewer at the second approval node also has the authority to modify the score, and can modify the score field of the application record during the final review; the reviewer at the second approval node has the authority to make the final decision. When the reviewer clicks "Approve", the status of the application record changes from "Pending Review" to "Approved" and the score of the application record enters the points calculation process. When the reviewer clicks "Reject", the status of the application record changes from "Pending Review" to "Rejected". In addition, each status change operation will automatically record the user ID and operation timestamp of the operator.
5. An employee points management system based on a multi-level approval workflow according to claim 1, characterized in that, In the real-time integral calculation module, the three-dimensional independent accounting model includes a base score channel, a contribution bonus channel, and a deduction channel. The calculations of the three channels are independent of each other. The integral calculation execution flow is as follows: S1: Retrieve assessment cycle records with the current status "in progress" from the assessment cycle set in the cloud database, and read the cycle identifier of the record; S2: Retrieve all application records of the current user from the application record collection in the cloud database; S3: Based on all the application records obtained in step S2, select records that meet all of the following conditions as valid contribution records: (1) The cycle identifier matches the current assessment cycle identifier obtained in step S1; (2) The status is "passed"; (3) The score is positive; sum the score field values of all valid contribution records to obtain the contribution bonus value; S4: Retrieve all deduction records of the current user in the current assessment period from the deduction record set of the cloud database, sum the score field values of all deduction records to obtain the deduction value; S5: Calculate the total score according to the formula for calculating the total score, and determine the corresponding score level according to the preset level division rules. The specific formula is: Total score = MAX(0, MIN(base score preset value + contribution bonus value - deduction value, total score upper limit preset value)), where the base score preset value and the total score upper limit preset value are set through the system configuration object; S6: The total score and score level calculated in step S5 are rendered and displayed on the user interface through the data binding mechanism of the interactive front-end mobile program; S7: The points calculation responds to the user's operation of entering the points viewing interface by repeatedly executing steps S1 to S6 to realize the real-time recalculation and presentation of points data.
6. The employee points management system based on a multi-level approval workflow according to claim 1, characterized in that, The group statistics and report synthesis module performs the following operations via the cloud function: Step 1: In response to the report export request, use cloud functions to query the user set, application record set, and deduction record set in the cloud database in parallel to obtain all user data, all approved application record data, and all deduction record data; Step 2: Group all user data obtained in Step 1 according to the user's group field, and sort the users in each group in descending order of total score; Step 3: Use the xlsx library to create an Excel workbook. Generate a first sheet in the workbook as a summary table. The summary table includes the following: group name, number of people in the group, highest score in the group, lowest score in the group, average score in the group, breakdown score, and total score; wherein the breakdown score = average score in the group * 0.
4. Step 4: Generate a separate sheet for each group in the workbook. Each group sheet includes the following: name, personnel category, base score, contribution points, deductions, total score, and details of points added and deducted. Step 5: Upload the generated Excel workbook to cloud storage and return a temporary download link.
7. An employee points management system based on a multi-level approval workflow according to claim 1, characterized in that, The automatic synthesis method for the addition / subtraction details column is as follows: For each employee, iterate through all approved application records for that employee within the current assessment period, concatenate them in the format "+{score} {application dimension}: {item details}" to generate each bonus point detail; iterate through all deduction records for that employee within the current assessment period, concatenate them in the format "-{score} {deduction reason}" to generate each deduction point detail; Link all generated bonus and deduction details in chronological order using line breaks to form the bonus / deduction details text for that employee.
8. An employee points management system based on a multi-level approval workflow according to claim 1, characterized in that, The system employs a dual-channel authentication mechanism: Regular Employee Channel: Identity authentication is performed based on the program authorization protocol. After the user authorizes through the interactive front-end mobile program client, the system calls the cloud function to obtain the user's unique WeChat identifier. Based on the unique WeChat identifier, the system automatically matches an existing account in the user set to complete the login. If no corresponding account exists, the user is guided to complete the registration. Management Role Channel: An independent username and password authentication channel is adopted. The username and password are stored in an independent field of the user set. This authentication system is completely decoupled from the WeChat unique identification system. Users with management roles can log in by entering their username and password. After logging in, the system generates the corresponding management function menu based on the user role array.
9. An employee points management system based on a multi-level approval workflow according to claim 1, characterized in that, The system also includes an automatic assessment cycle creation module: The automatic assessment cycle creation module checks whether there are assessment cycle records with a status of "in progress" in the assessment cycle set of the cloud database when the system starts up or when the administrator accesses the assessment cycle management page. A new assessment cycle record is created based on the cycle identifier and the current quarter, and the initial status of the record is set to "in progress".
10. An employee points management method based on a multi-level approval workflow, characterized in that, The system performs the following steps: S1: When the system starts up or the administrator accesses the period management page, check if there is an ongoing assessment period. If not, automatically create an assessment period record based on the current date. S2: Employees authorize and log in to the system through the interactive front-end mobile application, select the standardized scoring dimension or deduction dimension, fill in the details of the matter and the self-assessment value, upload supporting materials and submit the points application request. The system writes the application record into the cloud database and initializes the status to pending review. S3: After the reviewer of the first approval node logs into the system, the system filters and isolates data through the user's group field, and displays a list of pending application records of the user's group; the reviewer selects one or more records for review, modifies the score, and clicks "Approve" or "Reject"; if "Approve" is clicked, the status of the application record changes from pending review to pending consideration, and the reviewer's identifier and review time are recorded; If you click "Reject", the application record status will change from "Pending Review" to "Rejected", and the reviewer's ID and review time will be recorded. S4: After logging into the system, the reviewer at the second approval node displays a list of all pending application records. The reviewer selects one or more records for final review, modifies the score, and clicks "Approve" or "Reject". If "Approve" is clicked, the application record status changes from pending review to approved, and the record's score enters the points calculation process. If "Reject" is clicked, the application record status changes from pending review to rejected, and the reviewer's identifier and review time are recorded. S5: When a user enters the points viewing page, the points calculation module retrieves the application records and deduction records with a positive status and score from the cloud database in real time within the current assessment period. It calculates the total points through a three-dimensional independent accounting model and renders the calculation results in real time on the user interface through the front-end program data binding mechanism. S6: After the administrator publishes the points announcement, employees view the announcement and submit objections and supporting materials regarding the points verification results. The administrator then processes the objections and appeals. S7: In response to the report export request, the cloud function queries the user set, the application record set, and the deduction record set in parallel, groups and aggregates them according to the user's group field, calls the xlsx library to generate a multi-sheet Excel workbook containing a summary table and independent sub-tables for each group, uploads it to cloud storage, and returns a temporary download link.
