DayPay.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. namespace app\command;
  3. use app\extra\jhfPay\Pay;
  4. use app\extra\tools\CodeExtend;
  5. use app\extra\tools\DataExtend;
  6. use app\model\system\SystemUserBankcard;
  7. use app\model\system\SystemUserMoney;
  8. use Symfony\Component\Console\Command\Command;
  9. use Symfony\Component\Console\Input\InputInterface;
  10. use Symfony\Component\Console\Output\OutputInterface;
  11. class DayPay extends Command
  12. {
  13. protected static string $defaultName = 'day:pay';
  14. protected static string $defaultDescription = '每日结算金额发放';
  15. protected function execute(InputInterface $input, OutputInterface $output): int
  16. {
  17. $card = (new SystemUserBankcard)->select();
  18. $day = date("Y-m-d",strtotime("-1 day"));
  19. $cardData = unique_arr($card->toArray(),"member_id");
  20. $respJhf = (new Pay)->config([
  21. "appid" => sConf("wechat.jhf_appid"),
  22. "mch_id" => sConf("wechat.jhf_mch_id"),
  23. "aeskey" => sConf("wechat.jhf_aeskey"),
  24. "pubkey" => sConf("wechat.jhf_pubkey"),
  25. "prikey" => sConf("wechat.jhf_prikey"),
  26. ]);
  27. if (!empty($cardData)) {
  28. foreach ($cardData as $val)
  29. {
  30. $jsResp = $respJhf->createBalanceWithdraw([
  31. "app_id" => sConf("wechat.jhf_appid"),
  32. "order_no" => $val['member_id'].CodeExtend::uniqidDate(14),
  33. "member_id" => $val['member_id'],
  34. "remark" => "{$day}-结算",
  35. "notify_url" => "https://panel.huiyinduo.cn/notify/withdraw",
  36. ]);
  37. echo getDateFull()."=={$val['user_name']}==开始结算\n";
  38. echo json_encode($jsResp)."\n";
  39. }
  40. }
  41. return self::SUCCESS;
  42. }
  43. }