*
Showing
1 changed file
with
63 additions
and
7 deletions
| ... | @@ -2,6 +2,10 @@ | ... | @@ -2,6 +2,10 @@ |
| 2 | 2 | ||
| 3 | namespace App\Console\Commands\Test; | 3 | namespace App\Console\Commands\Test; |
| 4 | 4 | ||
| 5 | use App\Models\Legal\Bills; | ||
| 6 | use App\Models\Legal\Company; | ||
| 7 | use App\Models\Legal\StakeholderIncomeSyncApp; | ||
| 8 | use App\Models\Legal\StakeholderIncomeSyncAppDetails; | ||
| 5 | use App\Services\ApiService; | 9 | use App\Services\ApiService; |
| 6 | use Illuminate\Console\Command; | 10 | use Illuminate\Console\Command; |
| 7 | use Illuminate\Support\Facades\DB; | 11 | use Illuminate\Support\Facades\DB; |
| ... | @@ -14,13 +18,16 @@ use Illuminate\Support\Facades\Log; | ... | @@ -14,13 +18,16 @@ use Illuminate\Support\Facades\Log; |
| 14 | */ | 18 | */ |
| 15 | class StakeholderIncomeSync extends Command | 19 | class StakeholderIncomeSync extends Command |
| 16 | { | 20 | { |
| 21 | use \App\Traits\Bills; | ||
| 22 | |||
| 23 | const TYPE_BILLS = "1001601"; //账单分成 | ||
| 17 | 24 | ||
| 18 | /** | 25 | /** |
| 19 | * The name and signature of the console command. | 26 | * The name and signature of the console command. |
| 20 | * | 27 | * |
| 21 | * @var string | 28 | * @var string |
| 22 | */ | 29 | */ |
| 23 | protected $signature = 'test:stakeholder:income:sync'; | 30 | protected $signature = 'test:stakeholder:income:sync {serial_no?}'; |
| 24 | 31 | ||
| 25 | /** | 32 | /** |
| 26 | * The console command description. | 33 | * The console command description. |
| ... | @@ -47,12 +54,61 @@ class StakeholderIncomeSync extends Command | ... | @@ -47,12 +54,61 @@ class StakeholderIncomeSync extends Command |
| 47 | */ | 54 | */ |
| 48 | public function handle() | 55 | public function handle() |
| 49 | { | 56 | { |
| 50 | $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"}]}'; | 57 | $serial_no = $this->argument('serial_no'); |
| 51 | $data = json_decode($data, true); | 58 | |
| 59 | if ($income = StakeholderIncomeSyncApp::query()->where(['serial_no'=>$serial_no, 'sync_status'=>0])->first()) { | ||
| 60 | $income_detail = StakeholderIncomeSyncAppDetails::query()->where(['track_serial_no'=>$serial_no])->orderBy('month')->get(); | ||
| 61 | |||
| 62 | if ($income_detail->isNotEmpty()) { | ||
| 63 | $res = $this->formatHttpBody($income, $income_detail); | ||
| 64 | |||
| 65 | print_r($res); | ||
| 66 | exit(); | ||
| 67 | } | ||
| 68 | } | ||
| 69 | |||
| 70 | exit('xxx'); | ||
| 71 | } | ||
| 72 | |||
| 73 | /** | ||
| 74 | * @param $income | ||
| 75 | * @param $income_detail | ||
| 76 | * @return array | ||
| 77 | */ | ||
| 78 | private function formatHttpBody($income, $income_detail) | ||
| 79 | { | ||
| 80 | |||
| 81 | $company = Company::query()->find($income->company_id); | ||
| 82 | $bills = Bills::query()->find($income->related_id); | ||
| 83 | |||
| 84 | $body = [ | ||
| 85 | 'busiId' => $income->serial_no, | ||
| 86 | 'cardNo' => $income->identifier, | ||
| 87 | 'cost' => $income->cost_amount, | ||
| 88 | 'deductAmount' => $income->deduct_prepaid, | ||
| 89 | 'faxMoney' => $income->fax_money, | ||
| 90 | 'money' => $income->money, | ||
| 91 | 'totalMoney' => $income->total_money, | ||
| 92 | 'type' => self::TYPE_BILLS, | ||
| 93 | 'title' => $this->billsTitle($bills),//账单标题 | ||
| 94 | 'paymentCompany'=> $company->receipt_name, //付款公司营业执照全称 | ||
| 95 | 'addLevelTwoIncomeRequests' => [], | ||
| 96 | ]; | ||
| 97 | |||
| 98 | foreach ($income_detail as $item) { | ||
| 99 | $body['addLevelTwoIncomeRequests'][] = [ | ||
| 100 | 'actualTime' => $item->created_at, | ||
| 101 | 'busiId' => $item->serial_no, | ||
| 102 | 'faxMoney' => $item->fax_money, | ||
| 103 | 'money' => $item->money, | ||
| 104 | 'totalMoney' => $item->total_money, | ||
| 105 | 'paymentCompany' => $company->receipt_name, //付款公司营业执照全称 | ||
| 106 | 'songNum' => $item->song_num, | ||
| 107 | 'title' => $this->billsSubTitle($item->month), | ||
| 108 | 'type' => self::TYPE_BILLS, | ||
| 109 | ]; | ||
| 110 | } | ||
| 52 | 111 | ||
| 53 | $http_res = ApiService::walletAddIncome($data); | 112 | return $body; |
| 54 | echo '<pre>'; | ||
| 55 | print_r($http_res); | ||
| 56 | exit(); | ||
| 57 | } | 113 | } |
| 58 | } | 114 | } | ... | ... |
-
Please register or sign in to post a comment