good.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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 good extends Command
  11. {
  12. private $db;
  13. protected function configure()
  14. { $this->setName('good')
  15. ->setDescription('the good command');
  16. }
  17. protected function execute(Input $input, Output $output)
  18. {
  19. $this->db =Db::connect("mysql2");
  20. $data = $this->Getdata();
  21. foreach ($data as $value){
  22. $isT=Db::table("good")->where("good_code","=",$value['good_code'])->find();
  23. if($isT){
  24. Db::table("good")->where($isT)->save($value);
  25. }else{
  26. Db::table("good")->save($value);
  27. }
  28. }
  29. }
  30. public function Getdata(){
  31. $date = date("Y-m-d H:i:s",strtotime("-1 day"));
  32. $sql="SELECT
  33. b.Date1618678149288 as 'createtime',
  34. b.ShortText1621438752474 as 'good_code',
  35. b.ShortText1615776172238 as 'item',
  36. b.text1615776332933 as 'good_name',
  37. b.ShortText1622973543024 as 'old_item',
  38. b.ShortText1618630964434 as 'tkcode',
  39. b.text1615776271768 as 'item_code',
  40. b.text1618981719029 as 'spucode',
  41. b.text1615776440661 as 'model',
  42. b.text1615776695388 as 'color',
  43. b.text1615776685415 as 'material',
  44. b.text1618677034797 as 'technology',
  45. b.ShortText1615776786473 as 'unit',
  46. b.text1618677035673 as 'good_type',
  47. b.text1619509430228 as 'specs',
  48. b.ShortText1618677119629 as 'is_main',
  49. b.ShortText1617875730953 as 'is_diff',
  50. b.Number1618677207590 as 'good_weight',
  51. b.Number1619054377997 as 'box_weight',
  52. b.ShortText1618677229373 as 'box_specs',
  53. b.text1618677251640 as 'box_size',
  54. b.text1618677252567 as 'pack_size',
  55. b.ShortText1618677280883 as 'bar_code',
  56. b.ShortText1618677293358 as 'good_addr',
  57. b.ShortText1618677303623 as 'fk_day',
  58. b.ShortText1618677324610 as 'supply_area',
  59. b.text1619517580239 as 'shipment',
  60. b.ShortText1615776990102 as 'gys_code',
  61. b.Number1618677463881 as 'min_num',
  62. b.number1619054436137 as 'order_minnum',
  63. b.Number1617867853654 as 'duration',
  64. b.Number1618677510201 as 'sampling_period',
  65. b.Number1618677523586 as 'sample_fee',
  66. b.number1615788597819 as 'cost_fee',
  67. b.number1617867867574 as 'logistics',
  68. b.number1615788674789 as 'logistics_fee',
  69. b.number1615788650916 as 'cert_fee',
  70. b.number1615788639684 as 'packing_fee',
  71. b.number1615788611295 as 'mark_fee',
  72. b.number1617875705335 as 'tech_fee',
  73. b.number1615788686735 as 'unit_price',
  74. b.ShortText1615454226082 as 'noble_metal',
  75. b.number1618677641446 as 'metal_weight',
  76. b.Number1616399256021 as 'market_fee',
  77. b.ShortText1616119282513 as 'wsm_nature',
  78. b.ShortText1619054472299 as 'is_step',
  79. b.ShortText1618677768792 as 'tax',
  80. b.Number1618677857395 as 'step_num_1',
  81. b.Number1619054496274 as 'step_post_1',
  82. b.Number1618677862829 as 'step_price_1',
  83. b.number1618677888101 as 'step_num_2',
  84. b.number1619054497412 as 'step_post_2',
  85. b.number1618677890766 as 'step_price_2',
  86. b.number1618677920417 as 'step_num_3',
  87. b.number1619054516068 as 'step_post_3',
  88. b.number1618677922828 as 'step_price_3',
  89. b.number1618677997457 as 'sale_1',
  90. b.number1618677998335 as 'sale_2',
  91. b.number1618678013601 as 'sale_3',
  92. b.number1618964483608 as 'sale_other',
  93. (SELECT
  94. b_.`name`
  95. FROM
  96. h_org_user b_
  97. WHERE b_.id = JSON_EXTRACT (
  98. b.StaffSelector1616205980618,
  99. '$[0].id'
  100. )) as 'cg_saler',
  101. b.ShortText1618678061783 as 'is_online',
  102. b.ShortText1618678132819 as 'fund',
  103. b.ShortText1615802884401 as 'brand',
  104. b.ShortText1615776612618 as 'sort_f',
  105. b.text1615776646788 as 'sort_s',
  106. b.ShortText1618558317611 as 'sort_t',
  107. b.ShortText1616222832962 as 'supplier',
  108. b.ShortText1631180192195 as 'change',
  109. b.modifiedTime as 'updatetime'
  110. from ibt0b_SPXX b where modifiedTime>='{$date}'";
  111. $result = $this->db->query($sql);
  112. return $result;
  113. }
  114. }