|
@@ -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()));
|
|
|
+ }
|
|
|
}
|