UpdateGod.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <?php
  2. declare (strict_types = 1);
  3. namespace app\command;
  4. use think\console\Command;
  5. use think\console\Input;
  6. use think\console\input\Argument;
  7. use think\console\input\Option;
  8. use think\console\Output;
  9. use think\facade\Db;
  10. class UpdateGod extends Command
  11. {
  12. protected function configure()
  13. {
  14. // 指令配置
  15. $this->setName('updategod')
  16. ->setDescription('the updategod command');
  17. }
  18. protected function execute(Input $input, Output $output)
  19. {
  20. // 指令输出
  21. $this->GetData();
  22. $this->GetData2();
  23. $output->writeln('updategod');
  24. }
  25. public function GetData(){
  26. $date = date("Y-m-d H:i:s",strtotime("-1 day"));
  27. $data = Db::table("good")->where("updatetime>='{$date}'")->field("CONCAT('GD-',good_code) as good_code,
  28. item,
  29. good_name,
  30. technology 'good_desc',
  31. brand,
  32. unit_price 'original_price',
  33. cg_saler,
  34. good_type,
  35. good_addr,
  36. supply_area,
  37. market_fee,
  38. unit,
  39. gys_code,
  40. is_step ,
  41. tax,
  42. is_online,
  43. fund,
  44. sort_f,
  45. sort_s,
  46. sort_t,
  47. 1 status,
  48. 0 is_del,
  49. createtime 'addtime',
  50. updatetime")->select();
  51. foreach ($data as $value){
  52. $isT = Db::name("good")->where("good_code","=",$value['good_code'])->find();
  53. if($isT){
  54. Db::name("good")->where($isT)->save($value);
  55. }else{
  56. Db::name("good")->save($value);
  57. }
  58. }
  59. }
  60. public function GetData2(){
  61. $date = date("Y-m-d H:i:s",strtotime("-1 day"));
  62. $data = Db::table("good")->where("updatetime>='{$date}'")->field("CONCAT('GD-',good_code) as good_code,
  63. good_code 'type_code',
  64. model 'attribute',
  65. color,
  66. material,
  67. specs,
  68. is_main,
  69. is_diff,
  70. good_weight,
  71. box_weight,
  72. box_size,
  73. box_specs,
  74. pack_size,
  75. bar_code,
  76. min_num,
  77. order_minnum,
  78. duration,
  79. sampling_period,
  80. sample_fee,
  81. cost_fee,
  82. logistics,
  83. logistics_fee,
  84. cert_fee,
  85. packing_fee,
  86. mark_fee,
  87. tech_fee,
  88. unit_price,
  89. noble_metal,
  90. tax,
  91. 1 status,
  92. 0 is_del,
  93. createtime 'addtime',
  94. updatetime")->select();
  95. foreach ($data as $value){
  96. $isT = Db::name("good_type")->where("good_code","=",$value['good_code'])->find();
  97. if($isT){
  98. Db::name("good_type")->where($isT)->save($value);
  99. }else{
  100. Db::name("good_type")->save($value);
  101. }
  102. }
  103. }
  104. }