1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- <?php
- declare (strict_types = 1);
- namespace app\command;
- use think\console\Command;
- use think\console\Input;
- use think\console\input\Argument;
- use think\console\input\Option;
- use think\console\Output;
- use think\facade\Db;
- class gold extends Command
- {
- protected function configure()
- {
- // 指令配置
- $this->setName('gold')
- ->setDescription('the gold command');
- }
- protected function execute(Input $input, Output $output)
- {
- // 指令输出
- $lsu=$this->getData();
- foreach ($lsu as $value){
- $uqi = Db::name("gold_price")->where(["uiq"=>$value['uiq']])->find();
- $value['type']=$value['type'] =="18K" ? 1 :($value['type'] =="24K" ? 2 :3);
- if($uqi){
- // Db::name("gold_price")->where(["uiq"=>$value['uiq']])->save($value);
- continue;
- }else{
- Db::name("gold_price")->save($value);
- }
- echo $value['addtime'];
- }
- $output->writeln('gold');
- }
- public function getData(){
- $date=date("Y-m-d H:i:s",strtotime("-1 day"));
- $db = Db::connect("mysql2");
- $var=" SELECT id as 'uiq', SUBSTRING(`name`,1,3) AS 'action_name',createdTime AS 'addtime',
- ShortText1619628038544 AS 'type',ifnull(Number1619628088467,0) AS 'price' FROM iw48m_GXJJ where createdTime>='{$date}' ";
- $list=$db->query($var);
- return $list;
- }
- }
|