110 lines
4.3 KiB
PHP
110 lines
4.3 KiB
PHP
<?php
|
|
|
|
namespace app\api\command;
|
|
|
|
use app\admin\model\AuthRule;
|
|
use app\admin\model\JunkaCardunlock;
|
|
use app\api\model\JunkaCard;
|
|
use fast\Http;
|
|
use ReflectionClass;
|
|
use ReflectionMethod;
|
|
use think\Cache;
|
|
use think\Config;
|
|
use think\console\Command;
|
|
use think\console\Input;
|
|
use think\console\input\Option;
|
|
use think\console\Output;
|
|
use think\Exception;
|
|
use think\Loader;
|
|
|
|
class Lock extends Command
|
|
{
|
|
protected $model = null;
|
|
|
|
protected function configure()
|
|
{
|
|
$this->setName('lock')->setDescription('Build auth menu from controller');
|
|
}
|
|
|
|
protected function execute(Input $input, Output $output)
|
|
{
|
|
$junka_card_list = JunkaCard::where(['status' => 3])->select();
|
|
$arr = [];
|
|
if($junka_card_list) {
|
|
foreach ($junka_card_list as $k => $junka_card) {
|
|
// 到期
|
|
if(time() >= $junka_card->end_time) {
|
|
$d_arr = [];
|
|
$d_arr[] = [
|
|
'card_number' => $junka_card->card_number,
|
|
'card_price' => $junka_card->card_price
|
|
];
|
|
$arr[] = $d_arr;
|
|
// 去解锁
|
|
$card = $d_arr;
|
|
$bill_id = 0;
|
|
$msg = '';
|
|
$money_save_card = [];
|
|
$is_j = false;
|
|
foreach ($card as $k => $v) {
|
|
$get_arr = [
|
|
'agent_id' => config('junka.agent_id'),
|
|
'account_type' => 2,
|
|
'card_no' => $v['card_number'],
|
|
'card_par_amt' => $v['card_price'],
|
|
'card_style' => 1,
|
|
'lock_type' => 2, // 解锁
|
|
'time_stamp' => date('YmdHis'),
|
|
];
|
|
$string = http_build_query($get_arr) . '|||4FC3D043CBE3';
|
|
$string = md5($string);
|
|
$get_arr['sign'] = $string;
|
|
$res = Http::get('http://Service.800j.com/UCard/UCardLock.aspx', $get_arr);
|
|
$data = iconv("gbk", "utf-8", $res);
|
|
$res_data = explode('&', $data);
|
|
$res = [];
|
|
foreach ($res_data as $kk => $vv) {
|
|
$n_res = explode('=', $vv);
|
|
$res[$n_res[0]] = $n_res[1];
|
|
}
|
|
$msg .= '【' .$res['ret_msg'] . '】';
|
|
if($res['ret_code'] == 0) { // 解锁
|
|
$money_save_card[] = $v['card_number'];
|
|
\app\api\model\JunkaCard::where(['card_number' => $v['card_number']])->update(['status' => 1, 'status_notes' => $res['ret_msg']]);
|
|
$is_j = true;
|
|
}
|
|
// 解锁记录
|
|
JunkaCardunlock::create([
|
|
'bill_id' => $bill_id,
|
|
'card_number' => $v['card_number'],
|
|
'ret_code' => $res['ret_code'],
|
|
'ret_msg' => $res['ret_msg'],
|
|
]);
|
|
}
|
|
if($is_j) {
|
|
if($bill_id) {
|
|
// 改状态
|
|
$log = \app\admin\model\JunkaPurchcardLog::where(['bill_id' => $bill_id])->find();
|
|
if($log) {
|
|
$log->status = 1;
|
|
$log->save();
|
|
}
|
|
}else {
|
|
$log = \app\admin\model\JunkaPurchcardLog::where('data', 'like', '%' . $card[0]['card_number'] . '%')->select();
|
|
if($log) {
|
|
foreach ($log as $k => $v) {
|
|
if($v->status == 5) {
|
|
$v->status = 1;
|
|
$v->save();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
$output->writeln(json_encode($arr));
|
|
}
|
|
}
|