我已经帮你写好了这个加工厂,将该加工厂代码新增到方案的事件 AfterTargetGenerate 即可。
<?php
use Domain\Datahub\Instance\Storage\LogStorage;
/**
* 把明细里面的价格合并放到外面
*/
class AfterTargetGenerate
{
protected $params = [];
protected $ids = [];
public function __construct(&$params, $ids)
{
$this->params = &$params;
$this->ids = $ids;
}
public function run()
{
$log = new LogStorage('f4fde6ce-7a74-3af1-bce1-9dfdccf13af8', 'a751f891-4278-36ab-96ba-340ac62aa9bb');
$log->insertOne(['text' => 'this->params', 'json' => $this->params ]);
foreach ($this->params[1]['Model'] as $index => &$item){
$amount=floatval(str_replace(",","",$item['amo']));
$year = date('Y');
$currentDate = date($item['Completeddate']);
if($currentDate < '2023-07-01'){
$item['FDATE'] = '2023-07-01';
} else {
$item['FDATE'] = $currentDate;
}
$Date5 = date('Y-m-d', strtotime($currentDate . ' +5 days'));
if($amount>200000){
$item['FEntityDetail'][] = [
'FTaxPrice' => ($amount-10000)/2,
'FPriceQty' => 1,
'FEntryTaxRate' => 3,
'FComment' => '',
'F_VRKB_Base5' => ['FNumber'=> 'Tuition'],
'F_VRKB_Date_qtr' => $Date5
];
$item['FEntityDetail'][] = [
'FTaxPrice' => ($amount-10000)/2 ,
'FPriceQty' => 1,
'FEntryTaxRate' => 3,
'FComment' => '',
'F_VRKB_Base5' => ['FNumber'=> 'Tuition'],
'F_VRKB_Date_qtr' => $Date5
];
$item['FEntityPlan'][0] = [
'FENDDATE' => $Date5,
'FPAYRATE' => round(((($amount-10000)/2 +10000) / $amount)*100,6),
'FPAYAMOUNTFOR' => (($amount-10000)/2 +10000),
'F_XKLR_MS' => ['FNumber'=> 'Tuition']
];
$item['FEntityPlan'][] = [
'FENDDATE' => date($year . '-11-01') ,
'FPAYRATE' => 100 - round(((($amount-10000)/2 +10000) / $amount)*100,6),
'FPAYAMOUNTFOR' => (($amount-10000)/2),
'F_XKLR_MS' => ['FNumber'=> 'Tuition']
];
}else{
$item['FEntityDetail'][] = [
'FTaxPrice' => ($amount-10000),
'FPriceQty' => 1,
'FEntryTaxRate' => 3,
'FComment' => '',
'F_VRKB_Base5' => ['FNumber'=> 'Tuition'],
'F_VRKB_Date_qtr' => $Date5
];
$item['FEntityPlan'][0] = [
'FENDDATE' => $Date5,
'FPAYRATE' => 100,
'FPAYAMOUNTFOR' => $amount,
'F_XKLR_MS' => ['FNumber'=> 'Tuition']
];
}
}
}
}