Commit c98f7f36 c98f7f36800bde51e84241734c64d45d343e2ef0 by lemon

*

1 parent 2c597757
......@@ -2,6 +2,10 @@
namespace App\Console\Commands\Test;
use App\Models\Legal\Bills;
use App\Models\Legal\Company;
use App\Models\Legal\StakeholderIncomeSyncApp;
use App\Models\Legal\StakeholderIncomeSyncAppDetails;
use App\Services\ApiService;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
......@@ -14,13 +18,16 @@ use Illuminate\Support\Facades\Log;
*/
class StakeholderIncomeSync extends Command
{
use \App\Traits\Bills;
const TYPE_BILLS = "1001601"; //账单分成
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'test:stakeholder:income:sync';
protected $signature = 'test:stakeholder:income:sync {serial_no?}';
/**
* The console command description.
......@@ -47,12 +54,61 @@ class StakeholderIncomeSync extends Command
*/
public function handle()
{
$data = '{"busiId":"301655656836890628","cardNo":"422202199304102431","cost":"0.0000000000000000","deductAmount":"0.0000000000000000","faxMoney":"0.0000000000000000","money":"610.8682662596855292","totalMoney":"610.8682662596855292","type":"1001601","title":"04-07\u6708TME\u7248\u7a0e\u8d26\u5355","paymentCompany":"\u6b66\u6c49\u55e8\u5e93\u6587\u5316\u4f20\u5a92\u6709\u9650\u516c\u53f8","addLevelTwoIncomeRequests":[{"actualTime":"2021-11-17T01:51:50.000000Z","busiId":"301655656832696320","faxMoney":"0.0000000000000000","money":"187.0116067929763017","totalMoney":"187.0116067929763017","paymentCompany":"\u6b66\u6c49\u55e8\u5e93\u6587\u5316\u4f20\u5a92\u6709\u9650\u516c\u53f8","songNum":12,"title":"202104\u6708\u8d26\u5355","type":"1001601"},{"actualTime":"2021-11-17T01:51:50.000000Z","busiId":"301655656836890624","faxMoney":"0.0000000000000000","money":"186.9999441787542127","totalMoney":"186.9999441787542127","paymentCompany":"\u6b66\u6c49\u55e8\u5e93\u6587\u5316\u4f20\u5a92\u6709\u9650\u516c\u53f8","songNum":12,"title":"202105\u6708\u8d26\u5355","type":"1001601"},{"actualTime":"2021-11-17T01:51:50.000000Z","busiId":"301655656836890626","faxMoney":"0.0000000000000000","money":"135.9242163789635148","totalMoney":"135.9242163789635148","paymentCompany":"\u6b66\u6c49\u55e8\u5e93\u6587\u5316\u4f20\u5a92\u6709\u9650\u516c\u53f8","songNum":12,"title":"202106\u6708\u8d26\u5355","type":"1001601"},{"actualTime":"2021-11-17T01:51:50.000000Z","busiId":"301655656836890627","faxMoney":"0.0000000000000000","money":"100.9324989089915000","totalMoney":"100.9324989089915000","paymentCompany":"\u6b66\u6c49\u55e8\u5e93\u6587\u5316\u4f20\u5a92\u6709\u9650\u516c\u53f8","songNum":12,"title":"202107\u6708\u8d26\u5355","type":"1001601"}]}';
$data = json_decode($data, true);
$serial_no = $this->argument('serial_no');
if ($income = StakeholderIncomeSyncApp::query()->where(['serial_no'=>$serial_no, 'sync_status'=>0])->first()) {
$income_detail = StakeholderIncomeSyncAppDetails::query()->where(['track_serial_no'=>$serial_no])->orderBy('month')->get();
$http_res = ApiService::walletAddIncome($data);
echo '<pre>';
print_r($http_res);
if ($income_detail->isNotEmpty()) {
$res = $this->formatHttpBody($income, $income_detail);
print_r($res);
exit();
}
}
exit('xxx');
}
/**
* @param $income
* @param $income_detail
* @return array
*/
private function formatHttpBody($income, $income_detail)
{
$company = Company::query()->find($income->company_id);
$bills = Bills::query()->find($income->related_id);
$body = [
'busiId' => $income->serial_no,
'cardNo' => $income->identifier,
'cost' => $income->cost_amount,
'deductAmount' => $income->deduct_prepaid,
'faxMoney' => $income->fax_money,
'money' => $income->money,
'totalMoney' => $income->total_money,
'type' => self::TYPE_BILLS,
'title' => $this->billsTitle($bills),//账单标题
'paymentCompany'=> $company->receipt_name, //付款公司营业执照全称
'addLevelTwoIncomeRequests' => [],
];
foreach ($income_detail as $item) {
$body['addLevelTwoIncomeRequests'][] = [
'actualTime' => $item->created_at,
'busiId' => $item->serial_no,
'faxMoney' => $item->fax_money,
'money' => $item->money,
'totalMoney' => $item->total_money,
'paymentCompany' => $company->receipt_name, //付款公司营业执照全称
'songNum' => $item->song_num,
'title' => $this->billsSubTitle($item->month),
'type' => self::TYPE_BILLS,
];
}
return $body;
}
}
......