lowkeyman пре 2 месеци
родитељ
комит
22cdc5737f

+ 16 - 0
admin/control/refill_tax_quota_stats.php

@@ -45,6 +45,7 @@ class refill_tax_quota_statsControl extends SystemControl
             'quota_merchant' => $settings['quota_merchant'] ?? [],
             'quota_channel' => $settings['quota_channel'] ?? [],
             'quota_summary' => $settings['quota_summary'] ?? [],
+            'quota_condition' => $settings['quota_condition'] ?? [],
             'approval_task' => $settings['approval_task'] ?? [],
         ];
         $fields = function ($key)
@@ -101,6 +102,13 @@ class refill_tax_quota_statsControl extends SystemControl
 
         $mchids = explode(',', $_GET['mchids']);
 
+        $month = $_GET['month'] ?? '';
+        if ($month !== '') {
+            $start_time = strtotime($month . '-01');
+            $end_time = strtotime($month . '-01 +1 month');
+            $condition_counts['add_time'] = [['egt', $start_time], ['lt', $end_time], 'and'];
+        }
+
         $condition_counts['mchid'] = ['in', $mchids];
         $condition_counts['status'] = merchantModel::status_passed;
         $counts = Model('')->table('refill_evidence')
@@ -108,6 +116,7 @@ class refill_tax_quota_statsControl extends SystemControl
             ->where($condition_counts)
             ->group('mchid')
             ->select();
+
         $mch_stats = [];
         foreach ($counts as $count) {
             $mchid = $count['mchid'];
@@ -192,6 +201,13 @@ class refill_tax_quota_statsControl extends SystemControl
             return $item['provider_id'];
         }, $provider_items);
         $condition_stat['provider_amount.provider_id'] = ['in', $provider_ids];
+
+        $month = $_GET['month'] ?? '';
+        if ($month !== '') {
+            $start_time = strtotime($month . '-01');
+            $end_time = strtotime($month . '-01 +1 month');
+            $condition_stat['add_time'] = [['egt', $start_time], ['lt', $end_time], 'and'];
+        }
         $counts = Model()->table('provider_amount,refill_provider')
             ->where($condition_stat)
             ->join('inner')->on('provider_amount.provider_id=refill_provider.provider_id')

+ 26 - 6
admin/templates/default/js/stats-quota.js

@@ -4,15 +4,18 @@ class DataHandler {
         this[CONSTANTS.KEY_QUOTA_MERCHANT] = [];
         this[CONSTANTS.KEY_QUOTA_CHANNEL] = [];
         this[CONSTANTS.KEY_QUOTA_SUMMARY] = [];
+        this[CONSTANTS.KEY_QUOTA_CONDITION] = [];
         this.structureMapping = {
             // company结构: 排序(sort_order), 主体名称(name), 总额度(total_quota), 已用额度(used_quota), 备注(remark)
             [CONSTANTS.KEY_QUOTA_COMPANY]: ['sort', 'name', 'total_quota', 'used_quota', 'remark'],
             // merchant结构: 对应主体(subject), 机构id(mch_id), 已开票总金额(total_invoiced), 上次开票日期(last_invoice_date)
-            [CONSTANTS.KEY_QUOTA_MERCHANT]: ['sort','subject', 'mch_id', 'total_invoiced', 'last_invoice_date', 'remark'],
+            [CONSTANTS.KEY_QUOTA_MERCHANT]: ['sort','subject', 'mch_id', 'total_invoiced', 'last_invoice_date', 'remark', 'month_opened'],
             // channel结构: 对应主体(subject), 通道id(store_id), 已开票总金额(total_invoiced), 上次开票日期(last_invoice_date)
-            [CONSTANTS.KEY_QUOTA_CHANNEL]: ['sort', 'subject', 'store_id', 'total_invoiced', 'last_invoice_date', 'remark'],
+            [CONSTANTS.KEY_QUOTA_CHANNEL]: ['sort', 'subject', 'store_id', 'total_invoiced', 'last_invoice_date', 'remark', 'month_opened'],
             //summary结构: 主体(subject)
             [CONSTANTS.KEY_QUOTA_SUMMARY]: ['sort', 'subject'],
+            //condition结构: 月份(month)
+            [CONSTANTS.KEY_QUOTA_CONDITION]: ['month']
         };
     }
 
@@ -60,6 +63,14 @@ class DataHandler {
         return list;
     }
 
+    getConditionList() { //条件设置只会有一条数据
+        const list = [], that = this;
+        this[CONSTANTS.KEY_QUOTA_CONDITION].forEach((v) => {
+            list.push(that.translateToField(CONSTANTS.KEY_QUOTA_CONDITION, v));
+        });
+        return list;
+    }
+
     async addOrUpdateData(structure, newData, uni_key) {
         let list = this[structure];
         let translatedData = this.translateToIndex(structure, newData);
@@ -152,6 +163,15 @@ class DataHandler {
         }
         this.decompressData(CONSTANTS.KEY_QUOTA_SUMMARY, data);
     }
+
+    async loadCondition() {
+        const data = await statsApi.getStatsSettings([CONSTANTS.KEY_QUOTA_CONDITION]);
+        if (data.state !== true) {
+            showErr('网络异常,请刷新页面重试');
+            return;
+        }
+        this.decompressData(CONSTANTS.KEY_QUOTA_CONDITION, data);
+    }
 }
 
 class QuotaApiService extends BaseService {
@@ -174,8 +194,8 @@ class QuotaApiService extends BaseService {
         return this.request(endpoint, 'GET', {});
     };
 
-    getSysMchAmounts(mchids) {
-        const endpoint = '?act=refill_tax_quota_stats&op=sys_mchs_amounts&mchids=' + mchids;
+    getSysMchAmounts(mchids, month) {
+        const endpoint = `?act=refill_tax_quota_stats&op=sys_mchs_amounts&mchids=${mchids}&month=${month}` ;
         return this.request(endpoint, 'GET', {});
     };
 
@@ -184,8 +204,8 @@ class QuotaApiService extends BaseService {
         return this.request(endpoint, 'GET', {});
     };
 
-    getSysChanAmounts(storeIds) {
-        const endpoint = '?act=refill_tax_quota_stats&op=sys_chans_amounts&store_ids=' + storeIds;
+    getSysChanAmounts(storeIds, month) {
+        const endpoint = `?act=refill_tax_quota_stats&op=sys_chans_amounts&store_ids=${storeIds}&month=${month}`;
         return this.request(endpoint, 'GET', {});
     };
 }

+ 84 - 0
admin/templates/default/js/stats-utils.js

@@ -19,6 +19,7 @@ const CONSTANTS = {
     KEY_QUOTA_MERCHANT: 'quota_merchant', //带票额度统计:机构
     KEY_QUOTA_CHANNEL: 'quota_channel', //带票额度统计:通道
     KEY_QUOTA_SUMMARY: 'quota_summary', //带票额度统计:综合
+    KEY_QUOTA_CONDITION: 'quota_condition', //带票额度统计:条件
 };
 
 /*---------------------------------------------公共方法---------------------------------------*/
@@ -132,6 +133,14 @@ function deepCloneData(obj) {//数据深拷贝
     return clone;
 }
 
+function setEmptyFieldsToZero(obj, fields) {
+    fields.forEach(field => {
+        if (obj.hasOwnProperty(field) && obj[field] === '') {
+            obj[field] = '0';
+        }
+    });
+}
+
 function handleInputd2(event) {//限制金额输入框
     let element = event.target;
     let value = element.textContent;
@@ -234,6 +243,81 @@ function isValidDate(dateString) { //校验日期是否合法
     return date.getFullYear() === year && date.getMonth() + 1 === month && date.getDate() === day;
 }
 
+function getLastMonth() {
+    const date = new Date();
+
+    date.setMonth(date.getMonth() - 1);
+
+    const year = date.getFullYear();
+    const month = (date.getMonth() + 1).toString().padStart(2, '0');
+
+    return `${year}-${month}`;
+}
+
+function getCurrentMonth() {
+    const currentDate = new Date();
+    const year = currentDate.getFullYear();
+    let month = currentDate.getMonth() + 1;
+    month = month < 10 ? '0' + month : month;
+    return year + '-' + month;
+}
+
+function isValidMonth(month) {
+    const regex = /^\d{4}-(0[1-9]|1[0-2])$/;
+
+    return regex.test(month);
+}
+
+function getNextMonth(baseMonth = '') {
+    const date = new Date();
+
+    if (baseMonth !== '') {
+        const [year, monthStr] = baseMonth.split('-').map(Number);
+
+        date.setFullYear(year, monthStr - 1, 1);
+    }
+
+    date.setMonth(date.getMonth() + 1);
+
+    const year = date.getFullYear();
+    const month = (date.getMonth() + 1).toString().padStart(2, '0');
+
+    return `${year}-${month}`;
+}
+
+function getNextMonthFirstDay(month) {
+    const [year, monthStr] = month.split('-').map(Number);
+
+    const nextMonth = monthStr === 12 ? 1 : monthStr + 1;
+    const nextYear = monthStr === 12 ? year + 1 : year;
+
+    const nextMonthStr = nextMonth.toString().padStart(2, '0');
+    return `${nextYear}-${nextMonthStr}-01`;
+}
+
+function getLastDateOfMonth(yearMonth) {
+    const [year, month] = yearMonth.split('-').map(Number);
+    const date = new Date(year, month, 0);
+
+    const yearStr = date.getFullYear();
+    const monthStr = date.getMonth() + 1;
+    const dayStr = date.getDate();
+
+    return `${yearStr}年${monthStr}月${dayStr}日`;
+}
+
+function chineseYearMonth(dateStr) {
+    const parts = dateStr.split('-');
+    if (parts.length < 2) {
+        return dateStr;
+    }
+
+    const year = parts[0];
+    const month = parseInt(parts[1], 10);
+
+    return year + '年' + month + '月';
+}
+
 /*
  * 过滤json数组,仅保留需要的字段
  */

+ 0 - 67
admin/templates/default/refill_amount_stats.monthly_statement.php

@@ -343,73 +343,6 @@
     const systemTag = '<?php echo ADMIN_NAME;?>';
     let tMonth = getLastMonth();
 
-    function isValidMonth(month) {
-        const regex = /^\d{4}-(0[1-9]|1[0-2])$/;
-
-        return regex.test(month);
-    }
-
-    function getLastMonth() {
-        const date = new Date();
-
-        date.setMonth(date.getMonth() - 1);
-
-        const year = date.getFullYear();
-        const month = (date.getMonth() + 1).toString().padStart(2, '0');
-
-        return `${year}-${month}`;
-    }
-
-    function getNextMonth(baseMonth = '') {
-        const date = new Date();
-
-        if (baseMonth !== '') {
-            const [year, monthStr] = baseMonth.split('-').map(Number);
-
-            date.setFullYear(year, monthStr - 1, 1);
-        }
-
-        date.setMonth(date.getMonth() + 1);
-
-        const year = date.getFullYear();
-        const month = (date.getMonth() + 1).toString().padStart(2, '0');
-
-        return `${year}-${month}`;
-    }
-
-    function getNextMonthFirstDay(month) {
-        const [year, monthStr] = month.split('-').map(Number);
-
-        const nextMonth = monthStr === 12 ? 1 : monthStr + 1;
-        const nextYear = monthStr === 12 ? year + 1 : year;
-
-        const nextMonthStr = nextMonth.toString().padStart(2, '0');
-        return `${nextYear}-${nextMonthStr}-01`;
-    }
-
-    function getLastDateOfMonth(yearMonth) {
-        const [year, month] = yearMonth.split('-').map(Number);
-        const date = new Date(year, month, 0);
-
-        const yearStr = date.getFullYear();
-        const monthStr = date.getMonth() + 1;
-        const dayStr = date.getDate();
-
-        return `${yearStr}年${monthStr}月${dayStr}日`;
-    }
-
-    function chineseYearMonth(dateStr) {
-        const parts = dateStr.split('-');
-        if (parts.length < 2) {
-            return dateStr;
-        }
-
-        const year = parts[0];
-        const month = parseInt(parts[1], 10);
-
-        return year + '年' + month + '月';
-    }
-
     function addData(obj, date, value) {
         obj[date] = value;
 

+ 491 - 49
admin/templates/default/refill_quota_stats.index.php

@@ -24,13 +24,32 @@
         margin-top: 10px;
         display: flex;
         justify-content: space-between;
-        align-items: center;
-        /*border: 1px solid #ccc;*/
         padding: 10px;
     }
 
     .btn-container div:last-child {
-        text-align: right;
+        display: flex;
+        align-items: center;
+        gap: 10px;
+    }
+
+    .btn-container .layui-input,
+    .btn-container .layui-btn {
+        height: 40px;
+        line-height: 40px;
+        padding: 0 10px;
+        margin: 0;
+        box-sizing: border-box;
+    }
+
+    .btn-container .layui-btn {
+        background-color: #1E9FFF;
+        color: white;
+        border: none;
+        cursor: pointer;
+        display: flex;
+        align-items: center;
+        justify-content: center;
     }
 
     .layui-btn-sm {
@@ -42,7 +61,7 @@
     .stats-panel {
         margin-top: 40px;
         margin-left: 30px;
-        width: 1940px;
+        width: 2090px;
         overflow-x: hidden;
     }
 
@@ -228,9 +247,9 @@
         width: 1210px;
     }
 
-    .reset-bar {
+    .reset-bar, .reset-bar-c {
         margin: 0 10px;
-        width: 1930px;
+        width: 2080px;
         /*overflow-x: auto;*/
         white-space: nowrap;
         background-color: #fff;
@@ -238,7 +257,7 @@
         position: relative;
     }
 
-    .reset-bar button {
+    .reset-bar button, .reset-bar-c button {
         height: 28px;
         line-height: 28px;
         display: inline-block;
@@ -246,6 +265,18 @@
         width: 150px;
     }
 
+    .reset-bar-c button:first-child {
+        margin-left: 600px;
+    }
+
+    .reset-bar-c button:nth-child(2) {
+        margin-left: 150px;
+    }
+
+    .reset-bar-c button:nth-child(3) {
+        margin-left: 0;
+    }
+
     .company-checkbox {
         display: inline-flex;
         align-items: center;
@@ -337,6 +368,7 @@
 
         </div>
         <div>
+            <input class="layui-input query-input" type="text" readonly value="" name="query_month" id="query_month" autocomplete="off" />
             <button type="button" class="layui-btn layui-bg-blue" id="btn-update-all">更新数据</button>
         </div>
     </div>
@@ -345,6 +377,14 @@
     <!-- 主体 -->
     <div class="stats-panel layui-font-14">
         <company-set type="KEY_QUOTA_COMPANY" emit="updateCompany"></company-set>
+        <div class="reset-bar-c">
+            <button type="button" class="layui-btn layui-btn-light-yellow reset-col" data-table="tb-company" data-col="corrected_used_quota">一键清零</button>
+            <button type="button" class="layui-btn layui-bg-orange ac-batch-invoice" data-table="tb-company">批量提交</button>
+            <button type="button" class="layui-btn layui-bg-red ac-approve" data-table="tb-company">
+                审批
+                <span class="btn-badge" id="badge-approve-company">0</span>
+            </button>
+        </div>
         <table class="layui-hide" id="tb-company"></table>
     </div>
 
@@ -353,6 +393,7 @@
         <merchant-set type="KEY_QUOTA_MERCHANT" emit="updateMerchant"></merchant-set>
         <div class="reset-bar">
             <button type="button" class="layui-btn layui-btn-light-yellow reset-col" data-table="tb-merchant" data-col="total_invoiced">一键清零</button>
+            <button type="button" class="layui-btn layui-btn-light-yellow reset-col" data-table="tb-merchant" data-col="month_opened">一键清零</button>
             <button type="button" class="layui-btn layui-btn-light-yellow reset-col" data-table="tb-merchant" data-col="actual_invoice_amount">一键清零</button>
             <button type="button" class="layui-btn layui-bg-orange ac-batch-invoice" data-table="tb-merchant">批量提交</button>
             <button type="button" class="layui-btn layui-bg-red ac-approve" data-table="tb-merchant">
@@ -368,6 +409,7 @@
         <channel-set type="KEY_QUOTA_CHANNEL" emit="updateChannel"></channel-set>
         <div class="reset-bar">
             <button type="button" class="layui-btn layui-btn-light-yellow reset-col" data-table="tb-channel" data-col="total_invoiced">一键清零</button>
+            <button type="button" class="layui-btn layui-btn-light-yellow reset-col" data-table="tb-channel" data-col="month_opened">一键清零</button>
             <button type="button" class="layui-btn layui-btn-light-yellow reset-col" data-table="tb-channel" data-col="actual_invoice_amount">一键清零</button>
             <button type="button" class="layui-btn layui-bg-orange ac-batch-invoice" data-table="tb-channel">批量提交</button>
             <button type="button" class="layui-btn layui-bg-red ac-approve" data-table="tb-channel">
@@ -441,6 +483,8 @@
                     item.total_quota = formatDecimals(item.total_quota);
                     item.used_quota = formatDecimals(item.used_quota);
                     item.left_quota = formatDecimals(item.total_quota - item.used_quota);
+                    item.corrected_used_quota = '0';
+                    item.operator = '';
                 });
                 layui.table.render({
                     elem: '#' + this.tableId,
@@ -451,14 +495,20 @@
                         {field: 'total_quota', title: '总额度', width: 200},
                         {field: 'used_quota', title: '已用额度', width: 110},
                         {field: 'left_quota', title: '剩余额度', width: 150},
-                        {field: 'remark', title: '备注', width: 150}
+                        {field: 'corrected_used_quota', title: '已用额度矫正', width: 150},
+                        {field: 'operator', title: '操作人', width: 150},
+                        {field: 'remark', title: '备注', width: 150},
+                        {field: 'action', title: '操作', width: 150, templet: function(d){return '<button class="layui-btn layui-btn-sm invoice-apply-signle" style="margin: 0" data-index="'+d.LAY_TABLE_INDEX+'">矫正</button>';}}
                     ]],
                     done: function (res, curr, count) {
                         const tableItem = $('#' + that.tableId);
                         const trs = tableItem.next('.layui-table-view').find('.layui-table-body tbody tr');
 
                         trs.each(function(i, tr) {
-                            const editNumberColumns = ['total_quota', 'used_quota'];
+                            const editNumberColumns = ['corrected_used_quota'];
+                            if (isAdmin === true) {
+                                editNumberColumns.push('total_quota', 'used_quota');
+                            }
 
                             for(let col of editNumberColumns) {
                                 const td = $(tr).find('td[data-field="' + col + '"]').not('.layui-hide');
@@ -490,7 +540,7 @@
                                     });
                             }
 
-                            const editTextColumns = ['remark'];
+                            const editTextColumns = ['remark', 'operator'];
                             for(let col of editTextColumns) {
                                 const td = $(tr).find('td[data-field="' + col + '"]').not('.layui-hide');
                                 const valDiv = td.find('div');
@@ -519,6 +569,11 @@
                         });
 
                         that.setValueClass(['left_quota']);
+
+                        tableItem.next('.layui-table-view').off('click', '.invoice-apply-signle').on('click', '.invoice-apply-signle', function (){
+                            const index = $(this).data('index');
+                            that.applyOne(index);
+                        });
                     }
                 });
             }
@@ -554,6 +609,10 @@
                 await dataHelper.addOrUpdateData(CONSTANTS.KEY_QUOTA_COMPANY, item, 1);
                 summaryTable.renderTable();
             }
+
+            applyOne(index) {
+                batchCorrected.doApplyOne(this.tableId, index);
+            }
         }
 
         class MerchantTable extends LayuiTableBase {
@@ -565,9 +624,13 @@
                 const that = this;
 
                 const merchantList = dataHelper.getMerchantList();
+                merchantList.forEach(mItem => {
+                    setEmptyFieldsToZero(mItem, ['total_invoiced', 'month_opened']);
+                });
                 const mchIds = merchantList.map(item => item.mch_id).join(',')
 
-                const sysData = await statsApi.getSysMchAmounts(mchIds);
+                const currMonth = getCurrMonthCondition();
+                const sysData = await statsApi.getSysMchAmounts(mchIds, currMonth);
                 let sysMchData = [];
                 if (sysData.state === true) {
                     sysMchData = sysData.list;
@@ -607,6 +670,7 @@
                         {field: 'last_invoice_date', title: '上次开票日期', width: 150, templet: function(d){
                                 return '<input type="text" class="layui-input date-input" data-index="' + d.LAY_TABLE_INDEX + '" data-field="last_invoice_date" value="' + d.last_invoice_date + '">';
                             }},
+                        {field: 'month_opened', title: '本月已开票', width: 150},
                         {field: 'available_invoice_amount', title: '本月可开票总计', width: 150},
                         {field: 'estimated_invoice_amount', title: '预计本月开票金额', width: 150},
                         {field: 'actual_invoice_amount', title: '实际本次开票', width: 150},
@@ -615,7 +679,7 @@
                             }},
                         {field: 'operator', title: '操作人', width: 150},
                         {field: 'remark', title: '备注', width: 150},
-                        {field: 'delete', title: '操作', width: 100, templet: function(d){return '<button class="layui-btn layui-btn-sm invoice-apply-signle" style="margin: 0" data-index="'+d.LAY_TABLE_INDEX+'">申请</button>';}}
+                        {field: 'action', title: '操作', width: 100, templet: function(d){return '<button class="layui-btn layui-btn-sm invoice-apply-signle" style="margin: 0" data-index="'+d.LAY_TABLE_INDEX+'">申请</button>';}}
                     ]],
                     done: function (res, curr, count) {
                         const tableItem = $('#' + that.tableId);
@@ -629,11 +693,15 @@
 
                         that.deltaValue('amounts', 'total_invoiced', 'estimated_invoice_amount');
                         that.updateAvailableInvoiceAmount();
-                        that.setValueClass(['total_invoiced', 'available_invoice_amount', 'estimated_invoice_amount', 'actual_invoice_amount']);
+                        that.setValueClass(['total_invoiced', 'available_invoice_amount', 'estimated_invoice_amount', 'actual_invoice_amount', 'month_opened']);
                         that.updateColumnCnMoney(['total_invoiced']);
 
                         trs.each(function (i, tr) {
                             const editNumberColumns = ['total_invoiced', 'actual_invoice_amount'];
+                            if (isAdmin === true) {
+                                editNumberColumns.push('month_opened');
+                            }
+
                             for (let col of editNumberColumns) {
                                 const td = $(tr).find('td[data-field="' + col + '"]').not('.layui-hide');
                                 const valDiv = td.find('div');
@@ -659,14 +727,14 @@
                                         const index = $(this).parent().parent().data('index');
                                         await that.saveEdit(index);
 
-                                        if (col === 'total_invoiced') {
+                                        if (col === 'month_opened') {
                                             const subject = $(tr).find('td[data-field="subject"]').find('div').text();
                                             await that.updateCompanyUsedQuota(subject);
                                         }
 
                                         that.deltaValue('amounts', 'total_invoiced', 'estimated_invoice_amount');
                                         that.updateAvailableInvoiceAmount();
-                                        that.setValueClass(['total_invoiced', 'available_invoice_amount', 'estimated_invoice_amount', 'actual_invoice_amount']);
+                                        that.setValueClass(['total_invoiced', 'month_opened', 'available_invoice_amount', 'estimated_invoice_amount', 'actual_invoice_amount', 'month_opened']);
                                         that.updateColumnCnMoney(['total_invoiced']);
                                     });
                             }
@@ -695,7 +763,7 @@
 
                                         that.deltaValue('amounts', 'total_invoiced', 'estimated_invoice_amount');
                                         that.updateAvailableInvoiceAmount();
-                                        that.setValueClass(['total_invoiced', 'available_invoice_amount', 'estimated_invoice_amount', 'actual_invoice_amount']);
+                                        that.setValueClass(['total_invoiced', 'available_invoice_amount', 'estimated_invoice_amount', 'actual_invoice_amount', 'month_opened']);
                                     });
                             }
                         });
@@ -848,12 +916,14 @@
 
                 const tr = $('#' + this.tableId).next('.layui-table-view').find('.layui-table-body tbody tr[data-index="' + index + '"]');
                 const total_invoiced = tr.find('td[data-field="total_invoiced"]').find('div').text().trim();
+                const month_opened = tr.find('td[data-field="month_opened"]').find('div').text().trim();
                 const last_invoice_date = tr.find('td[data-field="last_invoice_date"]').find('div').find('input').val().trim();
                 const remark = tr.find('td[data-field="remark"]').find('div').text().trim();
 
                 let item = merchantData[index];
                 item.total_invoiced = total_invoiced || "0";
                 item.last_invoice_date = last_invoice_date || "0";
+                item.month_opened = month_opened || "0";
                 item.remark = remark;
 
                 await dataHelper.addOrUpdateData(CONSTANTS.KEY_QUOTA_MERCHANT, item, 2);
@@ -866,7 +936,7 @@
                     const merchantDataNew = dataHelper.getMerchantList();
                     const total = merchantDataNew
                         .filter(mItem => mItem.subject === subject)
-                        .reduce((sum, item) => sum + parseFloat(item.total_invoiced), 0);
+                        .reduce((sum, item) => sum + parseFloat(item.month_opened), 0);
                     activeCompany.used_quota = total.toString();
                 }
                 await dataHelper.updateAllData(CONSTANTS.KEY_QUOTA_COMPANY, companyList);
@@ -891,9 +961,13 @@
                 const that = this;
 
                 const channelList = dataHelper.getChannelList();
+                channelList.forEach(cItem => {
+                    setEmptyFieldsToZero(cItem, ['total_invoiced', 'month_opened']);
+                });
                 const storeIds = channelList.map(item => item.store_id).join(',')
 
-                const sysData = await statsApi.getSysChanAmounts(storeIds);
+                const currMonth = getCurrMonthCondition();
+                const sysData = await statsApi.getSysChanAmounts(storeIds, currMonth);
                 let sysChanData = [];
                 if (sysData.state === true) {
                     sysChanData = sysData.list;
@@ -933,6 +1007,7 @@
                         {field: 'last_invoice_date', title: '上次开票日期', width: 150, templet: function(d){
                                 return '<input type="text" class="layui-input date-input" data-index="' + d.LAY_TABLE_INDEX + '" data-field="last_invoice_date" value="' + d.last_invoice_date + '">';
                             }},
+                        {field: 'month_opened', title: '本月已开票', width: 150},
                         {field: 'available_invoice_amount', title: '本月可开票总计', width: 150},
                         {field: 'estimated_invoice_amount', title: '预计本月开票金额', width: 150},
                         {field: 'actual_invoice_amount', title: '实际本次开票', width: 150},
@@ -941,7 +1016,7 @@
                             }},
                         {field: 'operator', title: '操作人', width: 150},
                         {field: 'remark', title: '备注', width: 150},
-                        {field: 'delete', title: '操作', width: 100, templet: function(d){return '<button class="layui-btn layui-btn-sm invoice-apply-signle" style="margin: 0" data-index="'+d.LAY_TABLE_INDEX+'">申请</button>';}}
+                        {field: 'action', title: '操作', width: 100, templet: function(d){return '<button class="layui-btn layui-btn-sm invoice-apply-signle" style="margin: 0" data-index="'+d.LAY_TABLE_INDEX+'">申请</button>';}}
                     ]],
                     done: function (res, curr, count) {
                         const tableItem = $('#' + that.tableId);
@@ -955,11 +1030,15 @@
 
                         that.deltaValue('amounts', 'total_invoiced', 'estimated_invoice_amount');
                         that.updateAvailableInvoiceAmount();
-                        that.setValueClass(['total_invoiced', 'available_invoice_amount', 'estimated_invoice_amount', 'actual_invoice_amount']);
+                        that.setValueClass(['total_invoiced', 'available_invoice_amount', 'estimated_invoice_amount', 'actual_invoice_amount', 'month_opened']);
                         that.updateColumnCnMoney(['total_invoiced']);
 
                         trs.each(function (i, tr) {
                             const editNumberColumns = ['total_invoiced', 'actual_invoice_amount'];
+                            if (isAdmin === true) {
+                                editNumberColumns.push('month_opened');
+                            }
+
                             for (let col of editNumberColumns) {
                                 const td = $(tr).find('td[data-field="' + col + '"]').not('.layui-hide');
                                 const valDiv = td.find('div');
@@ -987,7 +1066,7 @@
 
                                         that.deltaValue('amounts', 'total_invoiced', 'estimated_invoice_amount');
                                         that.updateAvailableInvoiceAmount();
-                                        that.setValueClass(['total_invoiced', 'available_invoice_amount', 'estimated_invoice_amount', 'actual_invoice_amount']);
+                                        that.setValueClass(['total_invoiced', 'available_invoice_amount', 'estimated_invoice_amount', 'actual_invoice_amount', 'month_opened']);
                                     });
                             }
 
@@ -1015,7 +1094,7 @@
 
                                         that.deltaValue('amounts', 'total_invoiced', 'estimated_invoice_amount');
                                         that.updateAvailableInvoiceAmount();
-                                        that.setValueClass(['total_invoiced', 'available_invoice_amount', 'estimated_invoice_amount', 'actual_invoice_amount']);
+                                        that.setValueClass(['total_invoiced', 'available_invoice_amount', 'estimated_invoice_amount', 'actual_invoice_amount', 'month_opened']);
                                         that.updateColumnCnMoney(['total_invoiced']);
                                     });
                             }
@@ -1169,11 +1248,13 @@
 
                 const tr = $('#' + this.tableId).next('.layui-table-view').find('.layui-table-body tbody tr[data-index="' + index + '"]');
                 const total_invoiced = tr.find('td[data-field="total_invoiced"]').find('div').text().trim();
+                const month_opened = tr.find('td[data-field="month_opened"]').find('div').text().trim();
                 const last_invoice_date = tr.find('td[data-field="last_invoice_date"]').find('div').find('input').val().trim();
                 const remark = tr.find('td[data-field="remark"]').find('div').text().trim();
 
                 let item = channelData[index];
                 item.total_invoiced = total_invoiced || "0";
+                item.month_opened = month_opened || "0";
                 item.last_invoice_date = last_invoice_date || "0";
                 item.remark = remark;
 
@@ -1251,9 +1332,7 @@
                             }
 
                             const n_estimated_amount = parseFloat(estimated_amount);
-                            if (n_estimated_amount > 0) {
-                                channelQuota[subject].channel_invoice_quota += n_estimated_amount;
-                            }
+                            channelQuota[subject].channel_invoice_quota += n_estimated_amount;
 
                             channelQuota[subject].channel_amounts += parseFloat(channel_amounts);
                             channelQuota[subject].channel_total_invoiced += parseFloat(total_invoiced);
@@ -1439,8 +1518,7 @@
                 const targetRow = trs.eq(index);
                 const taskData = this.lineData(targetRow);
                 if (!isNumeric(taskData.actual_invoice_amount)
-                    || taskData.actual_invoice_amount === '0'
-                    || Number(taskData.actual_invoice_amount) < 0) {
+                    || taskData.actual_invoice_amount === '0') {
                     showErr(`${taskData.type_name} 金额设置无效`);
                     return;
                 }
@@ -1456,15 +1534,14 @@
                 this.doApply([taskData]);
             }
 
-            doApplyMore(tableId, channelData) {
+            doApplyMore(tableId) {
                 const that = this;
                 const trs = $('#' + tableId).next('.layui-table-view').find('.layui-table-body tbody tr');
                 const taskDatas = [], errs = [];
                 trs.each(function(i, targetRow) {
                     const taskData = that.lineData($(targetRow));
                     if (!isNumeric(taskData.actual_invoice_amount)
-                        || taskData.actual_invoice_amount === '0'
-                        || Number(taskData.actual_invoice_amount) < 0) {
+                        || taskData.actual_invoice_amount === '0') {
                         return;
                     }
                     if (!isValidDate(taskData.invoice_date)) {
@@ -1678,10 +1755,18 @@
                         if (that.type === 'mch') {
                             await dataHelper.loadMerchant();
                             typeData = dataHelper.getMerchantList();
+                            typeData.forEach(tItem => {
+                                setEmptyFieldsToZero(tItem, ['total_invoiced', 'month_opened']);
+                            });
+
                             typeField = 'mch_id';
                         } else {
                             await dataHelper.loadChannel();
                             typeData = dataHelper.getChannelList();
+                            typeData.forEach(tItem => {
+                                setEmptyFieldsToZero(tItem, ['total_invoiced', 'month_opened']);
+                            });
+
                             typeField = 'store_id';
                         }
 
@@ -1698,8 +1783,10 @@
 
                                     const typeItem = typeData.find(tItem => tItem[typeField] === aItem.type_id);
                                     const total_invoiced = parseFloat(typeItem.total_invoiced) + parseFloat(aItem.actual_invoice_amount);
+                                    const month_opened = parseFloat(typeItem.month_opened) + parseFloat(aItem.actual_invoice_amount);
                                     typeItem.total_invoiced = total_invoiced.toString();
                                     typeItem.last_invoice_date = aItem.invoice_date;
+                                    typeItem.month_opened = month_opened.toString();
 
                                     const activeCompany = companyData.find(cItem => cItem.name === aItem.subject);
                                     if (activeCompany !== undefined) {
@@ -1753,10 +1840,302 @@
             }
         }
 
+        class BatchCorrected {
+            constructor() {
+                this.workflow = new BatchWorkflow('company');
+                this.dv = 1; //数据版本,作用:由于需求变化导致存储的缓存数据格式发生变化,由该字段标记,审核的时候如果数据版本与当前dv版本不一致,需要手动作废审核重新操作。
+            }
+
+            lineData(targetRow) {
+                const name = targetRow.find('td[data-field="name"]').find('div').text().trim();
+                const corrected_used_quota = targetRow.find('td[data-field="corrected_used_quota"]').find('div').text().trim();
+                const operator = targetRow.find('td[data-field="operator"]').find('div').text().trim();
+                const remark = targetRow.find('td[data-field="remark"]').find('div').text().trim();
+
+                return {
+                    name,
+                    corrected_used_quota,
+                    operator,
+                    remark
+                };
+            }
+
+            doApplyOne(tableId, index) {
+                const trs = $('#' + tableId).next('.layui-table-view').find('.layui-table-body tbody tr');
+                const targetRow = trs.eq(index);
+                const taskData = this.lineData(targetRow);
+                if (!isNumeric(taskData.corrected_used_quota)
+                    || taskData.corrected_used_quota === '0') {
+                    showErr(`${taskData.name} 矫正金额设置无效`);
+                    return;
+                }
+                if (taskData.operator === '') {
+                    showErr(`${taskData.name} 操作人 设置无效`);
+                    return;
+                }
+
+                this.doApply([taskData]);
+            }
+
+            doApplyMore(tableId) {
+                const that = this;
+                const trs = $('#' + tableId).next('.layui-table-view').find('.layui-table-body tbody tr');
+                const taskDatas = [], errs = [];
+                trs.each(function(i, targetRow) {
+                    const taskData = that.lineData($(targetRow));
+                    if (!isNumeric(taskData.corrected_used_quota)
+                        || taskData.corrected_used_quota === '0'
+                        || Number(taskData.corrected_used_quota) < 0) {
+                        return;
+                    }
+                    if (taskData.operator === '') {
+                        const err = `${taskData.type_name} 操作人 设置错误`;
+                        if (!err.includes(err)) {
+                            err.push(err);
+                        }
+                        return;
+                    }
+
+                    taskDatas.push(taskData);
+                });
+
+                if (errs.length > 0) {
+                    showErr(errs.join('<br />'));
+                    return;
+                }
+                if (taskDatas.length === 0) {
+                    showErr('没有设置矫正项');
+                    return;
+                }
+
+                this.doApply(taskDatas);
+            }
+
+            async doApply(companyUnit) {
+                const that = this;
+                let errsNormal = [];
+
+                await this.workflow.initializeGlobalTaskList();
+                const pendingTasks = this.workflow.getPendingTasksByApprover();
+                pendingTasks.forEach(taskItem => {
+                    const currItems = taskItem.data.items || [];
+                    currItems.forEach(currItem => {
+                        const isPending = companyUnit.find(cItem => {
+                            return currItem.name === cItem.name;
+                        });
+                        if (isPending !== undefined) {
+                            const err = `${currItem.type_name} 存在处理中的矫正申请,审核后才能再次申请`;
+                            if (!errsNormal.includes(err)) {
+                                errsNormal.push(err);
+                            }
+                        }
+                    });
+                });
+
+                if (errsNormal.length > 0) {
+                    showErr(errsNormal.join('<br />'));
+                    return;
+                }
+
+                const applyTrnasfer = () => {
+                    const sortedCompanyUnit = sortByName(companyUnit, 'name');
+                    layui.table.render({
+                        elem: '#tb_apply',
+                        data: sortedCompanyUnit,
+                        limit: sortedCompanyUnit.length,
+                        cols: [[
+                            {field: 'name', title: '对应主体', width: 200},
+                            {field: 'corrected_used_quota', title: '矫正金额', width: 200},
+                            {field: 'operator', title: '操作人', width: 100},
+                            {field: 'remark', title: '备注', width: 200},
+                        ]],
+                        done: function (res, curr, count) {
+
+                        }
+                    });
+
+                    layer.open({
+                        type: 1,
+                        title: '已用额度矫正',
+                        area: ['1150px', '500px'],
+                        content: $('#rechargeManual'),
+                        btn: ['确定', '取消'],
+                        success: function (layero) {
+
+                        },
+                        btn1: function () {
+                            layer.closeAll();
+
+                            const taskData = filterJsonFields(companyUnit, ["name", "corrected_used_quota", "operator", "remark"]);
+                            const applyData = {
+                                items: taskData,
+                                dv: that.dv
+                            };
+                            that.workflow.addTask(applyData, systemUserName, 'admin')
+                                .then(succ => {
+                                    if (succ === true) {
+                                        showSuccess('已发起已用额度矫正申请');
+                                    } else {
+                                        showErr('处理失败,请重试');
+                                    }
+                                });
+                        },
+                    });
+                };
+
+                applyTrnasfer();
+            }
+
+            async doBatchCorrected() {
+                const that = this;
+                let sortedCompanyUnit = [], worklist = [], companyUnit = [], isCorrectVersion = true;
+
+                const loadCompanyUnit = async () => {
+                    await this.workflow.initializeGlobalTaskList();
+                    worklist = this.workflow.getPendingTasksByApprover();
+                    for (const task of worklist) {
+                        if (Number(task.data.dv) !== that.dv) {
+                            isCorrectVersion = false;
+                            break;
+                        }
+                    }
+
+                    companyUnit = this.workflow.getPendingTaskDetails();
+                    sortedCompanyUnit = sortByName(companyUnit, 'name');
+                };
+
+                const loadIndex = layer.load(2, {shade: [0.2, '#000']});
+
+                await loadCompanyUnit();
+
+                if (isCorrectVersion === false) {
+                    setTimeout(function() {
+                        showErr('数据与当前程序版本不匹配,请作废当前数据后重新加款');
+                    }, 500);
+                }
+
+                layui.table.render({
+                    elem: '#tb_approve',
+                    data: sortedCompanyUnit,
+                    limit: sortedCompanyUnit.length,
+                    cols: [[
+                        {field: 'name', title: '对应主体', width: 200},
+                        {field: 'corrected_used_quota', title: '矫正金额', width: 200},
+                        {field: 'operator', title: '操作人', width: 100},
+                        {field: 'remark', title: '备注', width: 200},
+                        {field: 'void_task', title: '', width: 100, templet: function(d){return '<button class="layui-btn layui-btn-sm layui-btn-primary task-void-btn" style="margin: 0" data-index="'+d.LAY_TABLE_INDEX+'">作废</button>';}}
+                    ]],
+                    done: function (res, curr, count) {
+                        const tbRoot = $('#tb_approve');
+                        const voidOneEvent = () => {
+                            tbRoot.next('.layui-table-view').off('click', '.task-void-btn').on('click', '.task-void-btn', function () {
+                                const index = $(this).data('index');
+                                layer.confirm(`确认作废 ${sortedCompanyUnit[index].name} 的矫正申请吗?`, {
+                                    title: '提示',
+                                    btn: ['确定', '取消']
+                                }, async (confirmIndex) => {
+                                    const loadIndex = layer.load(2, {shade: [0.2, '#000']});
+
+                                    await that.workflow.initializeGlobalTaskList();
+
+                                    const succ = await that.workflow.invalidateItem(sortedCompanyUnit[index].name);
+                                    if (succ === true) {
+                                        await loadCompanyUnit();
+                                        layui.table.reload('tb_approve', {
+                                            data: sortedCompanyUnit
+                                        });
+                                    } else {
+                                        showErr('作废失败');
+                                    }
+
+                                    layer.close(loadIndex);
+                                    layer.close(confirmIndex);
+                                });
+                            });
+                        };
+
+                        voidOneEvent();
+
+                        layer.close(loadIndex);
+                    }
+                });
+
+                layer.open({
+                    type: 1,
+                    title: '已用额度矫正审核',
+                    area: ['1280px', '500px'],
+                    content: $('#rechargeManualApprove'),
+                    btn: ['批准', '作废'],
+                    success: function (layero) {
+
+                    },
+                    btn1: async function () {
+                        if (worklist.length === 0) {
+                            showErr('没有待审核的矫正申请');
+                            return false;
+                        }
+
+                        if (isCorrectVersion === false) {
+                            showErr('数据与当前程序版本不匹配,请作废当前数据后重新加款');
+                            return false;
+                        }
+
+                        layer.load(2, {shade: [0.2, '#000']});
+
+                        await dataHelper.loadComapny();
+                        const companyData = dataHelper.getCompanyList();
+
+                        for (const task of worklist) {
+                            await that.workflow.executeTask(task.id, async () => {
+                                const applyItems = task.data.items;
+                                applyItems.forEach(aItem => {
+                                    const activeCompany = companyData.find(cItem => cItem.name === aItem.name);
+                                    const used_quota = parseFloat(activeCompany.used_quota) + parseFloat(aItem.corrected_used_quota);
+                                    activeCompany.used_quota = used_quota.toString();
+                                });
+                            });
+                        }
+
+                        await dataHelper.updateAllData(CONSTANTS.KEY_QUOTA_COMPANY, companyData);
+                        companyTable.renderTable();
+                        summaryTable.renderTable();
+
+                        layer.closeAll();
+                    },
+                    btn2: function () {
+                        if (worklist.length === 0) {
+                            showErr('没有可作废的申请');
+                            return;
+                        }
+
+                        layer.confirm(`确认批量作废 已用额度矫正 申请吗?`, {
+                            title: '提示',
+                            btn: ['确定', '取消']
+                        }, async () => {
+                            layer.load(2, {shade: [0.2, '#000']});
+
+                            for (const task of worklist) {
+                                await that.workflow.executeTask(task.id, async () => {});
+                            }
+
+                            layer.closeAll();
+                            showSuccess('已用额度矫正 申请已作废');
+                        });
+
+                        return false;
+                    }
+                });
+            }
+        }
+
         function loadMsgBadge () {
+            const companyWorkflow = new BatchWorkflow('company');
             const mchWorkflow = new BatchWorkflow('mch');
             const chanWorkflow = new BatchWorkflow('chan');
 
+            const companyBadge = $('#badge-approve-company');
+            companyBadge.hide();
+
             const mchBadge = $('#badge-approve-mch');
             mchBadge.hide();
 
@@ -1764,6 +2143,17 @@
             chanBadge.hide();
 
             const refreshApprovalMessage = () => {
+                companyWorkflow.initializeGlobalTaskList();
+                const comMsg = companyWorkflow.getPendingTaskDetails();
+                const comNum = comMsg.length || 0;
+
+                companyBadge.html(comNum);
+                if (comNum === 0) {
+                    companyBadge.hide();
+                } else {
+                    companyBadge.show();
+                }
+
                 mchWorkflow.initializeGlobalTaskList();
                 const mchMsg = mchWorkflow.getPendingTaskDetails();
                 const mchNum = mchMsg.length || 0;
@@ -1802,6 +2192,23 @@
             });
         }
 
+        async function conditionSet() {
+            const conditionList = dataHelper.getConditionList();
+            if (conditionList.length === 0) {
+                const month = getCurrentMonth();
+                const condition = {
+                    month
+                };
+                await dataHelper.addOrUpdateData(CONSTANTS.KEY_QUOTA_CONDITION, condition, 0);
+            }
+        }
+
+        function getCurrMonthCondition() {
+            const conditionList = dataHelper.getConditionList();
+            const condition = conditionList[0];
+            return condition.month;
+        }
+
         async function initPage() {
             const loadIndex = layer.load(2, {shade: [0.2, '#000']});
 
@@ -1809,6 +2216,11 @@
             await dataHelper.loadMerchant();
             await dataHelper.loadChannel();
             await dataHelper.loadSummary();
+            await dataHelper.loadCondition();
+
+            await conditionSet();
+            const currMonth = getCurrMonthCondition();
+            $('#query_month').val(currMonth);
 
             companyTable.renderTable();
             await merchantTable.renderTable();
@@ -1839,6 +2251,7 @@
 
         const batchMchInvoice = new BatchInvoice('mch');
         const batchChanInvoice = new BatchInvoice('chan');
+        const batchCorrected = new BatchCorrected();
         const companyTable = new CompanyTable();
         const merchantTable = new MerchantTable();
         const channelTable = new ChannelTable();
@@ -1854,6 +2267,8 @@
                 batchMchInvoice.doBatchInvoice();
             } else if (tableId === 'tb-channel') {
                 batchChanInvoice.doBatchInvoice();
+            } else if (tableId === 'tb-company') {
+                batchCorrected.doBatchCorrected();
             }
         });
 
@@ -1863,6 +2278,8 @@
                 batchMchInvoice.doApplyMore(tableId);
             } else if (tableId === 'tb-channel') {
                 batchChanInvoice.doApplyMore(tableId);
+            } else if (tableId === 'tb-company') {
+                batchCorrected.doApplyMore(tableId);
             }
         });
 
@@ -1894,8 +2311,7 @@
                 return data;
             };
 
-
-            if (tableId === 'tb-merchant' && col === 'total_invoiced') {
+            const updateMerchant = async (field) => {
                 const activeList = activeData();
                 const companyReduce = {};
                 const merchantList = dataHelper.getMerchantList();
@@ -1905,41 +2321,51 @@
                         if (!companyReduce[item.subject]) {
                             companyReduce[item.subject] = 0;
                         }
-                        companyReduce[item.subject] += parseFloat(item.total_invoiced);
+                        companyReduce[item.subject] += parseFloat(item.month_opened);
 
-                        item.total_invoiced = '0';
+                        item[field] = '0';
                     }
                 })
                 await dataHelper.updateAllData(CONSTANTS.KEY_QUOTA_MERCHANT, merchantList);
 
-                const companyList = dataHelper.getCompanyList();
-                companyList.forEach(item => {
-                    if (companyReduce[item.name] !== undefined) {
-                        const used_quota_up = parseFloat(item.used_quota) - companyReduce[item.name];
-                        if (item.used_quota < 0) {
-                            item.used_quota = 0;
+                if (field === 'month_opened') {
+                    const companyList = dataHelper.getCompanyList();
+                    companyList.forEach(item => {
+                        if (companyReduce[item.name] !== undefined) {
+                            const used_quota_up = parseFloat(item.used_quota) - companyReduce[item.name];
+                            if (item.used_quota < 0) {
+                                item.used_quota = 0;
+                            }
+                            item.used_quota = used_quota_up.toString();
                         }
-                        item.used_quota = used_quota_up.toString();
-                    }
-                });
-                await dataHelper.updateAllData(CONSTANTS.KEY_QUOTA_COMPANY, companyList);
+                    });
+                    await dataHelper.updateAllData(CONSTANTS.KEY_QUOTA_COMPANY, companyList);
+                }
 
                 await merchantTable.renderTable();
                 companyTable.renderTable();
                 summaryTable.renderTable();
-            } else if (tableId === 'tb-channel' && col === 'total_invoiced') {
+            };
+
+            const updateChannel = async (field) => {
                 const activeList = activeData();
                 const channelList = dataHelper.getChannelList();
                 channelList.forEach(item => {
                     const ac = activeList.find(aItem => aItem.type_id === item.store_id);
                     if (ac !== undefined) {
-                        item.total_invoiced = '0';
+                        item[field] = '0';
                     }
                 })
                 await dataHelper.updateAllData(CONSTANTS.KEY_QUOTA_CHANNEL, channelList);
 
                 await channelTable.renderTable();
                 summaryTable.renderTable();
+            };
+
+            if (tableId === 'tb-merchant') {
+                await updateMerchant(col);
+            } else if (tableId === 'tb-channel') {
+                await updateChannel(col);
             }
 
             layer.close(loadIndex);
@@ -1951,22 +2377,38 @@
 
         if (isAdmin === false) {
             $('.reset-bar button:first-child').hide();
-            $('.reset-bar button:nth-child(2)').css('margin-left', '750px');
+            $('.reset-bar button:nth-child(2)').css('margin-left', '900px');
             $('.reset-bar button:nth-child(3)').css('margin-left', '150px');
             $('.reset-bar button:nth-child(4)').css({
                 'margin-left': '75px',
                 'display': 'inline-block'
             });
+            $('.ac-approve').css('display', 'none');
         } else {
             $('.reset-bar button:first-child').css('margin-left', '595px');
-            $('.reset-bar button:nth-child(2)').css('margin-left', '445px');
-            $('.reset-bar button:nth-child(3)').css('margin-left', '150px');
+            $('.reset-bar button:nth-child(2)').css('margin-left', '150px');
+            $('.reset-bar button:nth-child(3)').css('margin-left', '300px');
             $('.reset-bar button:nth-child(4)').css({
                 'margin-left': '75px',
                 'display': 'inline-block'
             });
         }
 
+        const tMonth = getCurrentMonth();
+        laydate.render({
+            elem: '#query_month',
+            type: 'month',
+            trigger: 'click',
+            max: tMonth,
+            done: async function (value, date, endDate) {
+                const condition = {
+                    month: value
+                };
+                await dataHelper.updateAllData(CONSTANTS.KEY_QUOTA_CONDITION, [condition]);
+                await initPage();
+            }
+        });
+
         initPage();
     });
 </script>

+ 10 - 0
test/TestlAmountStats.php

@@ -91,4 +91,14 @@ class TestlAmountStats extends TestCase
             ->group('provider_amount.provider_id')
             ->find();
     }
+
+    public function test_month_cond()
+    {
+        $month = '2025-02';
+        $start_time = strtotime($month . '-01');
+        $end_time = strtotime($month . '-01 +1 month');
+
+        $start_time_f = date('Y-m-d H:i:s', $start_time);
+        $end_time_f = date('Y-m-d H:i:s', $end_time);
+    }
 }