|
@@ -133,7 +133,7 @@ class OrderCostService{
|
133
|
133
|
];
|
134
|
134
|
}
|
135
|
135
|
|
136
|
|
- self::mjOrderStore($data);
|
|
136
|
+// self::mjOrderStore($data);
|
137
|
137
|
$res = self::mjOrderInsert($data);
|
138
|
138
|
|
139
|
139
|
if($res){
|
|
@@ -288,17 +288,43 @@ class OrderCostService{
|
288
|
288
|
*/
|
289
|
289
|
public static function mjOrderInsert($ex_data)
|
290
|
290
|
{
|
291
|
|
- $data = array();
|
|
291
|
+ $insertData = $storeData = array();
|
292
|
292
|
foreach($ex_data as $k=>$v){
|
|
293
|
+ $month = gmdate('Y-m-01', \PHPExcel_Shared_Date::ExcelToPHP($v['month']));
|
|
294
|
+ $storeKey = $v['task_id_origin'].'@'.$month;
|
|
295
|
+
|
|
296
|
+ if($v['cost_type'] == '流量助推'){
|
|
297
|
+ $storeKey = $v['task_id_origin'].'-1@'.$month;
|
|
298
|
+ }
|
|
299
|
+
|
|
300
|
+ if( !isset($storeData[$storeKey]) ){
|
|
301
|
+ $storeData[$storeKey] = [
|
|
302
|
+ 'task_id' => $v['task_id_origin'],
|
|
303
|
+ 'month' => $month,
|
|
304
|
+ 'internet_celebrity_name' => $v['internet_celebrity_name'],
|
|
305
|
+ 'internet_celebrity_id' => $v['internet_celebrity_id'],
|
|
306
|
+ 'cost_sign_company' => $v['cost_sign_company'],
|
|
307
|
+ 'advertiser_account' => $v['advertiser_account'],
|
|
308
|
+ 'advertiser_id' => $v['advertiser_id'],
|
|
309
|
+ 'if_public' => $v['if_public'] == '是' ? 1:0,
|
|
310
|
+ 'order_part_id' => $v['order_part_id'],
|
|
311
|
+ 'amount' => $v['cost_money'],
|
|
312
|
+ 'cost_type' => $v['cost_type'] == '流量助推' ? 2 : 1,
|
|
313
|
+ 'is_cash' => $v['is_cash'] == '授信' ? 2 : 1, //现金1 授信2,默认现金
|
|
314
|
+ 'media_name' => $v['cost_type']
|
|
315
|
+ ];
|
|
316
|
+ } else {
|
|
317
|
+ $storeData[$storeKey]['amount'] += $v['cost_money'];
|
|
318
|
+ }
|
293
|
319
|
|
294
|
320
|
if($v['is_exists']==0 || $v['is_already']==1){
|
295
|
321
|
continue;
|
296
|
322
|
}
|
297
|
323
|
|
298
|
|
- $month = gmdate('Y-m-01', \PHPExcel_Shared_Date::ExcelToPHP($v['month']));
|
299
|
|
- $key = $v['task_id'].'@'.$month;
|
300
|
|
- if( !isset($data[$key]) ){
|
301
|
|
- $data[$key] = [
|
|
324
|
+// $month = gmdate('Y-m-01', \PHPExcel_Shared_Date::ExcelToPHP($v['month']));
|
|
325
|
+ $insertKey = $v['task_id'].'@'.$month;
|
|
326
|
+ if( !isset($insertData[$insertKey]) ){
|
|
327
|
+ $insertData[$insertKey] = [
|
302
|
328
|
'task_id' => $v['task_id'],
|
303
|
329
|
'month' => $month,
|
304
|
330
|
'if_public' => $v['if_public'],
|
|
@@ -311,15 +337,26 @@ class OrderCostService{
|
311
|
337
|
'media_name' => $v['cost_type']
|
312
|
338
|
];
|
313
|
339
|
} else {
|
314
|
|
- $data[$key]['traffic_boost_sum'] += $v['cost_type'] == '流量助推' ? $v['cost_money'] : 0;
|
315
|
|
- $data[$key]['traffic_boost_money'] += $v['cost_type'] == '流量助推' ? $v['cost_money'] : 0;
|
316
|
|
- $data[$key]['cost'] += $v['cost_type'] != '流量助推' ? $v['cost_money'] : 0;
|
|
340
|
+ $insertData[$insertKey]['traffic_boost_sum'] += $v['cost_type'] == '流量助推' ? $v['cost_money'] : 0;
|
|
341
|
+ $insertData[$insertKey]['traffic_boost_money'] += $v['cost_type'] == '流量助推' ? $v['cost_money'] : 0;
|
|
342
|
+ $insertData[$insertKey]['cost'] += $v['cost_type'] != '流量助推' ? $v['cost_money'] : 0;
|
317
|
343
|
}
|
318
|
344
|
}
|
319
|
345
|
|
320
|
346
|
DB::beginTransaction();
|
321
|
347
|
try{
|
322
|
|
- foreach($data as $k=>$v){
|
|
348
|
+ foreach($storeData as $k=>$v){
|
|
349
|
+ $con = [
|
|
350
|
+ 'task_id' => $v['task_id'],
|
|
351
|
+ 'month' => $v['month'],
|
|
352
|
+ 'cost_type' => $v['cost_type'],
|
|
353
|
+ 'enable' => 1
|
|
354
|
+ ];
|
|
355
|
+
|
|
356
|
+ MjOrdersImport::updateOrCreate($con, $v);
|
|
357
|
+ }
|
|
358
|
+
|
|
359
|
+ foreach($insertData as $k=>$v){
|
323
|
360
|
|
324
|
361
|
$up = array_filter($v);
|
325
|
362
|
|
|
@@ -347,7 +384,6 @@ class OrderCostService{
|
347
|
384
|
}
|
348
|
385
|
|
349
|
386
|
return true;
|
350
|
|
-
|
351
|
387
|
}
|
352
|
388
|
|
353
|
389
|
/*
|
|
@@ -790,7 +826,6 @@ class OrderCostService{
|
790
|
826
|
}
|
791
|
827
|
|
792
|
828
|
return true;
|
793
|
|
-
|
794
|
829
|
}
|
795
|
830
|
|
796
|
831
|
/**
|