*
Showing
2 changed files
with
31 additions
and
17 deletions
| 1 | <?php | 1 | <?php |
| 2 | 2 | ||
| 3 | namespace App\Jobs; | 3 | namespace App\Console\Commands; |
| 4 | 4 | ||
| 5 | use App\Helper\CacheKeyTools; | 5 | use App\Helper\CacheKeyTools; |
| 6 | use App\Helper\RedisClient; | 6 | use App\Helper\RedisClient; |
| ... | @@ -8,43 +8,51 @@ use App\Models\Legal\Bills; | ... | @@ -8,43 +8,51 @@ use App\Models\Legal\Bills; |
| 8 | use App\Models\Legal\Company; | 8 | use App\Models\Legal\Company; |
| 9 | use App\Models\Legal\StakeholderIncomeByPayer; | 9 | use App\Models\Legal\StakeholderIncomeByPayer; |
| 10 | use App\Services\ApiService; | 10 | use App\Services\ApiService; |
| 11 | use App\Traits\TaxReckon; | 11 | use Illuminate\Console\Command; |
| 12 | use Illuminate\Bus\Queueable; | ||
| 13 | use Illuminate\Contracts\Queue\ShouldBeUnique; | ||
| 14 | use Illuminate\Contracts\Queue\ShouldQueue; | ||
| 15 | use Illuminate\Foundation\Bus\Dispatchable; | ||
| 16 | use Illuminate\Queue\InteractsWithQueue; | ||
| 17 | use Illuminate\Queue\SerializesModels; | ||
| 18 | use Illuminate\Support\Facades\Log; | 12 | use Illuminate\Support\Facades\Log; |
| 19 | 13 | ||
| 20 | /** | 14 | /** |
| 21 | * Class StakeholderIncomeSyncJob | 15 | * 合作伙同数据同步 |
| 22 | * @package App\Jobs | 16 | * Class StakeholderIncomeSyncCommand |
| 17 | * @package App\Console\Commands | ||
| 23 | */ | 18 | */ |
| 24 | class StakeholderIncomeSyncJob implements ShouldQueue | 19 | class StakeholderIncomeSyncCommand extends Command |
| 25 | { | 20 | { |
| 26 | use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, TaxReckon; | 21 | /** |
| 22 | * The name and signature of the console command. | ||
| 23 | * | ||
| 24 | * @var string | ||
| 25 | */ | ||
| 26 | protected $signature = 'stakeholder:income:sync'; | ||
| 27 | |||
| 28 | /** | ||
| 29 | * The console command description. | ||
| 30 | * | ||
| 31 | * @var string | ||
| 32 | */ | ||
| 33 | protected $description = '权益人收益同步'; | ||
| 27 | 34 | ||
| 35 | //常量定义 | ||
| 28 | const COUNT = 1; | 36 | const COUNT = 1; |
| 29 | const BLOCK_TIME = 3; | 37 | const BLOCK_TIME = 1000; |
| 30 | 38 | ||
| 31 | const TYPE_BILLS = 1001601; //账单分成 | 39 | const TYPE_BILLS = 1001601; //账单分成 |
| 32 | const TYPE_ROYALTY = 1001602; //合作伙伴打款 type = 1 版税分成 | 40 | const TYPE_ROYALTY = 1001602; //合作伙伴打款 type = 1 版税分成 |
| 33 | 41 | ||
| 34 | /** | 42 | /** |
| 35 | * Create a new job instance. | 43 | * Create a new command instance. |
| 36 | * | 44 | * |
| 37 | * @return void | 45 | * @return void |
| 38 | */ | 46 | */ |
| 39 | public function __construct() | 47 | public function __construct() |
| 40 | { | 48 | { |
| 41 | Log::info(__METHOD__."入账数据同步任务", ['time'=>now()->toDateTimeString()]); | 49 | parent::__construct(); |
| 42 | } | 50 | } |
| 43 | 51 | ||
| 44 | /** | 52 | /** |
| 45 | * Execute the job. | 53 | * Execute the console command. |
| 46 | * | 54 | * |
| 47 | * @return void | 55 | * @return int |
| 48 | */ | 56 | */ |
| 49 | public function handle() | 57 | public function handle() |
| 50 | { | 58 | { |
| ... | @@ -61,6 +69,8 @@ class StakeholderIncomeSyncJob implements ShouldQueue | ... | @@ -61,6 +69,8 @@ class StakeholderIncomeSyncJob implements ShouldQueue |
| 61 | $id = key($msg[$key]); | 69 | $id = key($msg[$key]); |
| 62 | $income_item = $msg[$key][$id]; | 70 | $income_item = $msg[$key][$id]; |
| 63 | 71 | ||
| 72 | Log::channel('api')->warning(__METHOD__."streamid:{$id}-即将处理任务", ['income_item'=>$income_item]); | ||
| 73 | |||
| 64 | $company = Company::query()->find($income_item['company_id']); | 74 | $company = Company::query()->find($income_item['company_id']); |
| 65 | $bills = Bills::query()->find($income_item['related_id']); | 75 | $bills = Bills::query()->find($income_item['related_id']); |
| 66 | $channel = 'TME'; | 76 | $channel = 'TME'; |
| ... | @@ -109,6 +119,8 @@ class StakeholderIncomeSyncJob implements ShouldQueue | ... | @@ -109,6 +119,8 @@ class StakeholderIncomeSyncJob implements ShouldQueue |
| 109 | } | 119 | } |
| 110 | } | 120 | } |
| 111 | } | 121 | } |
| 122 | |||
| 123 | echo now()->toDateTimeString()."\r\n"; | ||
| 112 | } | 124 | } |
| 113 | } | 125 | } |
| 114 | } | 126 | } | ... | ... |
| ... | @@ -3,6 +3,7 @@ | ... | @@ -3,6 +3,7 @@ |
| 3 | namespace App\Console; | 3 | namespace App\Console; |
| 4 | 4 | ||
| 5 | use App\Console\Commands\DealSongIp; | 5 | use App\Console\Commands\DealSongIp; |
| 6 | use App\Console\Commands\StakeholderIncomeSyncCommand; | ||
| 6 | use Illuminate\Console\Scheduling\Schedule; | 7 | use Illuminate\Console\Scheduling\Schedule; |
| 7 | use Illuminate\Foundation\Console\Kernel as ConsoleKernel; | 8 | use Illuminate\Foundation\Console\Kernel as ConsoleKernel; |
| 8 | 9 | ||
| ... | @@ -15,6 +16,7 @@ class Kernel extends ConsoleKernel | ... | @@ -15,6 +16,7 @@ class Kernel extends ConsoleKernel |
| 15 | */ | 16 | */ |
| 16 | protected $commands = [ | 17 | protected $commands = [ |
| 17 | DealSongIp::class, | 18 | DealSongIp::class, |
| 19 | StakeholderIncomeSyncCommand::class, | ||
| 18 | ]; | 20 | ]; |
| 19 | 21 | ||
| 20 | /** | 22 | /** | ... | ... |
-
Please register or sign in to post a comment