xiaoyu 2 年之前
父节点
当前提交
70acaa0736
共有 2 个文件被更改,包括 77 次插入16 次删除
  1. 75 13
      admin/control/provider.php
  2. 2 3
      admin/templates/default/remit.config.php

+ 75 - 13
admin/control/provider.php

@@ -702,32 +702,57 @@ class providerControl extends SystemControl
 
     private function remit_commit($items, $refill_company)
     {
+        $mod = Model('');
         $admininfo = $this->getAdminInfo();
         $provider_list = $this->providers();
         foreach ($provider_list as $provider) {
             $providers[$provider['provider_id']] = $provider;
         }
         $bz = '批量打款';
+        $cur_time = time();
         $remit_data = [];
+        $remit_cfg = $this->remit_cfg();
+        $remit_max = $remit_cfg['remit_max'];
+
         foreach ($items as $co_id => $item)
         {
-            $remit_total = 0;
-            foreach ($item as $pid => $money)
-            {
-                $amount_data = [
-                    'pointsnum' => $money,
+            try {
+                $trans = new trans_wapper($mod, __METHOD__);
+                $remit_total = 0;
+                foreach ($item as $pid => $money)
+                {
+                    $amount_data = [
+                        'pointsnum' => $money,
+                        'operation' => $admininfo['name'],
+                        'bz' => $bz
+                    ];
+                    $this->credit_save_money($money, 'add', $providers[$pid]['account_id'], $bz);
+                    $this->ct_provider_amount($amount_data, $providers[$pid]);
+                    $remit_total += $money;
+                }
+                $remit_record = [
+                    'co_id' => $co_id,
+                    'amount' => $remit_total,
                     'operation' => $admininfo['name'],
-                    'bz' => $bz
+                    'add_time' => $cur_time
                 ];
-                $this->credit_save_money($money, 'add', $providers[$pid]['account_id'], $bz);
-                $this->ct_provider_amount($amount_data, $providers[$pid]);
-                $remit_total += $money;
+                Model('')->table('refill_company_remit')->insert($remit_record);
+                for ($i = $remit_total / $remit_max; $i<=0; $i--)
+                {
+                    if($i == 0) {
+                        $refill_company[$co_id]['money'] = $remit_total % $remit_max;
+                    }else{
+                        $refill_company[$co_id]['money'] = $remit_max;
+                    }
+                    $remit_data[] = $refill_company[$co_id];
+                }
+                $trans->commit();
+            } catch (Exception $e) {
+                $trans->rollback();
+                Log::record("remit_commit err: {$e->getMessage()}", Log::ERR);
             }
-            $remit_data[$co_id] = [
-                'refill_company' => $refill_company[$co_id],
-                'remit' => $remit_total
-            ];
         }
+        $this->remit_excel($remit_data);
     }
 
     private function remit_cfg()
@@ -740,4 +765,41 @@ class providerControl extends SystemControl
         }
         return $config;
     }
+
+    private function remit_excel($remit_data)
+    {
+        Language::read('export');
+        import('libraries.excel');
+        $excel_obj = new Excel();
+        $excel_data = [];
+        //设置样式
+        $excel_obj->setStyle(['id' => 's_title', 'Font' => ['FontName' => '宋体', 'Size' => '12', 'Bold' => '1']]);
+        //header
+        $excel_data[0][] = ['styleid' => 's_title', 'data' => '序号'];
+        $excel_data[0][] = ['styleid' => 's_title', 'data' => '收款人姓名'];
+        $excel_data[0][] = ['styleid' => 's_title', 'data' => '银行卡号'];
+        $excel_data[0][] = ['styleid' => 's_title', 'data' => '银行编码'];
+        $excel_data[0][] = ['styleid' => 's_title', 'data' => '省/直辖市'];
+        $excel_data[0][] = ['styleid' => 's_title', 'data' => '城市'];
+        $excel_data[0][] = ['styleid' => 's_title', 'data' => '开户行名称'];
+        $excel_data[0][] = ['styleid' => 's_title', 'data' => '付款金额'];
+
+        //data
+        foreach ($remit_data as $key => $data) {
+            $tmp = [];
+            $tmp[] = ['data' => $key+1];
+            $tmp[] = ['data' => $data['bank_username']];
+            $tmp[] = ['data' => $data['bank_card_no']];
+            $tmp[] = ['data' => $data['bank_code']];
+            $tmp[] = ['data' => $data['province']];
+            $tmp[] = ['data' => $data['city']];
+            $tmp[] = ['data' => $data['bank_name']];
+            $tmp[] = ['data' => $data['money']];
+            $excel_data[] = $tmp;
+        }
+        $excel_data = $excel_obj->charset($excel_data, CHARSET);
+        $excel_obj->addArray($excel_data);
+        $excel_obj->addWorksheet($excel_obj->charset(L('exp_od_order'), CHARSET));
+        $excel_obj->generateXML('批量打款-' . date('Y-m-d-H', time()));
+    }
 }

+ 2 - 3
admin/templates/default/remit.config.php

@@ -13,7 +13,6 @@
     </div>
     <div class="fixed-empty"></div>
     <form id="user_form" enctype="multipart/form-data" method="post">
-        <input type="hidden" name="form_submit" value="ok"/>
         <table class="table tb-type2">
             <tbody>
             <tr class="noborder">
@@ -24,10 +23,10 @@
                 <td class="vatop tips"></td>
             </tr>
             <tr class="noborder">
-                <td colspan="2" class="required"><label class="validation" for="max_money">单条记录最大金额:</label></td>
+                <td colspan="2" class="required"><label class="validation" for="remit_max">单条记录最大金额:</label></td>
             </tr>
             <tr class="noborder">
-                <td class="vatop rowform"><input type="text" value="<?php echo $output['config']['max_money'] ?? 0;?>" name="max_money" id="max_money" class="txt"></td>
+                <td class="vatop rowform"><input type="text" value="<?php echo $output['config']['remit_max'] ?? 0;?>" name="remit_max" class="txt"></td>
                 <td class="vatop tips"></td>
             </tr>
             </tbody>