12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- <?php
- /**
- * Created by: PhpStorm
- * User: lytian
- * Date: 2020/3/11
- * Time: 19:02
- */
- namespace app\admin\command;
- use app\common\model\User;
- use think\console\Command;
- use think\console\Input;
- use think\console\Output;
- use think\Request;
- class DoWithdraw extends Command
- {
- /**
- * @var User
- */
- private $model = null;
- private $redis = null;
- protected function configure()
- {
- $this->setName('DoWithdraw')
- ->setDescription('提现');
- }
- protected function execute(Input $input, Output $output)
- {
- Request::instance()->module('admin'); //cli模式下无法获取到当前的项目模块,手动指定一下
- die;
- $channel_ids = [17278, 17279, 17281, 17282, 17283, 17284, 17285, 17286, 17287, 17288, 18545, 18546, 18547];
- foreach ($channel_ids as $channel_id) {
- $admin_money = model("AdminMoney")->where("admin_id", 'eq', $channel_id)->find();
- if (empty($admin_money)) {
- echo "渠道商{$channel_id} 没有汇总 因此跳过";
- continue;
- }
- $total_collect = model("OrdersCollect")->sumCollect($channel_id, 1, 3, '20181001', '20200229');
- $channelTotalSplitMoney = $total_collect['split_money'] ?? 0;
- $no_cash_money = ($total_collect['recharge_money_benefit'] ?? 0) - $admin_money['cash_money'] - $admin_money['count_cash_money'] - $channelTotalSplitMoney;
- $no_cash_money = (string)sprintf("%.2f", $no_cash_money);
- if ($no_cash_money < 10) {
- //直接跳过 记录日志
- echo "渠道商{$channel_id} 可提现金额小于10元 因此跳过";
- echo "可提现金额小于10元 因此跳过";
- continue;
- }
- $save['etime'] = '20200229';
- $stime = model('withdraw')->where('admin_id', $channel_id)->field('etime')->order('id desc')->find();
- if (empty($stime['etime'])) {
- $save['stime'] = null;
- } else {
- $save['stime'] = date('Ymd', strtotime($stime['etime']) + 3600 * 24);
- }
- $save['admin_id'] = $channel_id;
- $save['money'] = $no_cash_money;//含手续费
- $save['state'] = 1;
- $save['createtime'] = time();
- $save['updatetime'] = time();
- var_dump($save);die;
- if (model('withdraw')->insertGetId($save)) {
- model('AdminMoney')->where('admin_id', $channel_id)->setInc('cash_money', $no_cash_money);
- echo "提现成功";
- }
- }
- }
- }
|