|
|
@@ -15,12 +15,15 @@
|
|
|
namespace app\common\service;
|
|
|
|
|
|
|
|
|
+use app\adminapi\logic\equity\UserEquityLogic;
|
|
|
use app\adminapi\logic\financial\MasterSettlementDetailsLogic;
|
|
|
use app\common\enum\FileEnum;
|
|
|
+use app\common\model\equity\UserEquity;
|
|
|
use app\common\model\export\Export;
|
|
|
use app\common\model\file\File;
|
|
|
use app\common\model\financial\FinancialPaymentRecords;
|
|
|
use app\common\model\goods_category\GoodsCategory;
|
|
|
+use app\common\model\user\User;
|
|
|
use app\common\service\storage\Driver as StorageDriver;
|
|
|
use excel\ExcelWriter;
|
|
|
use Exception;
|
|
|
@@ -35,6 +38,7 @@ class ExcelExportService
|
|
|
public $download_type = [
|
|
|
'1' => 'EngineerBillDownload',
|
|
|
'2' => 'MasterWorkerServiceOrderDownload',
|
|
|
+ '3' => 'UserEquityDownload',
|
|
|
];
|
|
|
public function __construct()
|
|
|
{
|
|
|
@@ -57,44 +61,6 @@ class ExcelExportService
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * @notes 工程师 -上月最后结算余额 导出
|
|
|
- */
|
|
|
- public function EngineerBillDownload_Bak($infoExport)
|
|
|
- {
|
|
|
- try{
|
|
|
- $filename = $infoExport['name'];
|
|
|
- $params = $infoExport['params']?:[];
|
|
|
- if($params){ }
|
|
|
- $firstDay = date('Y-m-01 00:00:00', strtotime('first day of last month'));
|
|
|
- $lastDay = date('Y-m-t 23:59:59', strtotime('last day of last month'));
|
|
|
- $lists = Db::name('master_worker')->alias('a')->field([
|
|
|
- 'a.id','a.real_name','a.nickname','a.worker_number','e.account_holder','e.bank_name','e.opening_branch','e.account as bank_account',
|
|
|
- Db::raw("IFNULL(c.maxid,0) as maxid"),Db::raw("IFNULL(d.left_amount,0) as left_amount")
|
|
|
- ])
|
|
|
- ->leftJoin([Db::name('master_worker_account_log')
|
|
|
- ->where('create_time','between',[strtotime($firstDay),strtotime($lastDay)])
|
|
|
- ->field('worker_id as master_worker_id, max(id) as maxid')
|
|
|
- ->group('worker_id')
|
|
|
- ->buildSql() => 'c'], 'a.id = c.master_worker_id')
|
|
|
- ->leftJoin('master_worker_account_log d', 'c.maxid = d.id')
|
|
|
- ->leftJoin('bank_account e', 'a.id = e.worker_id')
|
|
|
- //->where('d.left_amount', '>', 0)
|
|
|
- ->select()->toArray();
|
|
|
- $filename = ($filename?:'').('-'.date('YmdHis').'-'.$infoExport->id);
|
|
|
- $this->sheet->generateExcelFile([
|
|
|
- '工程师ID', '工程师编号', '工程师姓名', '工程师银行卡号', '工程师开户行及支行信息','上月最后结算余额'
|
|
|
- ], $lists,$filename, ['id','worker_number','real_name','bank_account','bank_name','left_amount']);
|
|
|
- $infoExport->file_url = $this->sheet->fileUrl();
|
|
|
- $infoExport->generate_status = 1;
|
|
|
- $infoExport->updatetime = time();
|
|
|
- $infoExport->save();
|
|
|
- return $infoExport->file_url;
|
|
|
- }catch (\Exception $e){
|
|
|
- throw new Exception($e->getMessage());
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* @notes 工程师 -截止某日最后结算余额 导出
|
|
|
*/
|
|
|
@@ -217,6 +183,48 @@ class ExcelExportService
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ // 权益卡编码导出
|
|
|
+ public function UserEquityDownload($infoExport){
|
|
|
+ try{
|
|
|
+ $filename = $infoExport['name'];
|
|
|
+ $params = $infoExport['params']?:[];
|
|
|
+ $where = [];
|
|
|
+ if($params){
|
|
|
+ if (isset($params['select_ids']) && !empty($params['select_ids'])) {
|
|
|
+ $where[] = ['id','in' ,$params['select_ids']];
|
|
|
+ }
|
|
|
+ if (isset($params['equity_id']) && !empty($params['equity_id'])) {
|
|
|
+ $where[] = ['equity_id','=' ,$params['equity_id']];
|
|
|
+ }
|
|
|
+ if (isset($params['mobile']) && !empty($params['mobile'])) {
|
|
|
+ $userId = User::where('mobile',$params['mobile'])->value('id')??-1;
|
|
|
+ $where[] = ['user_id','=' ,$userId];
|
|
|
+ }
|
|
|
+ if (isset($params['is_binding']) && !empty($params['is_binding'])) {
|
|
|
+ if((int)$params['is_binding'] === 1){
|
|
|
+ $where[] = ['user_id','>',0];
|
|
|
+ }else{
|
|
|
+ $where[] = ['user_id','=',0];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $lists = UserEquity::with(['equityConfig', 'goods','user'])
|
|
|
+ ->where($where)
|
|
|
+ ->field(['id', 'user_id', 'equity_id', 'goods_id', 'number', "IF(end_time=0,'',FROM_UNIXTIME(end_time, '%Y-%m-%d %H:%i:%s')) AS end_time",'code','IF(user_id=0,2,1) as is_binding'])
|
|
|
+ ->select()
|
|
|
+ ->toArray();
|
|
|
+ $filename = ($filename?:'').('-'.date('YmdHis').'-'.$infoExport->id);
|
|
|
+ $this->sheet->generateExcelFile([
|
|
|
+ '用户','编码', '权益卡名称','商品','预售价','权益总次数','剩余次数','权益截止时间'
|
|
|
+ ], $lists,$filename, ['user.nickname','code','equityConfig.equity_name','goods.goods_name','equityConfig.price','equityConfig.number','number','end_time']);
|
|
|
+ $infoExport->file_url = $this->sheet->fileUrl();
|
|
|
+ $infoExport->generate_status = 1;
|
|
|
+ $infoExport->updatetime = time();
|
|
|
+ $infoExport->save();
|
|
|
+ return $infoExport->file_url;
|
|
|
+ }catch (\Exception $e){
|
|
|
+ throw new Exception($e->getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
}
|