cgddiff.php 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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\Cache;
  10. use think\facade\Db;
  11. class cgddiff extends Command
  12. {
  13. protected function configure()
  14. {
  15. // 指令配置
  16. $this->setName('datacopy')
  17. ->setDescription('the datacopy command');
  18. }
  19. protected function execute(Input $input, Output $output)
  20. {
  21. $redis = Cache::store('redis');
  22. $iscgd = $redis->get("diff");
  23. if($iscgd==0){
  24. $redis->set("diff",1,1200);
  25. }else{
  26. return;
  27. }
  28. $iscgd = $redis->get("diff");
  29. $ist = Db::name("diff_price")->where('status', "=", 0)->select();
  30. if (empty($ist)) {
  31. $redis->set("diff", 0);
  32. return;
  33. }
  34. try {
  35. foreach ($ist as $value) {
  36. $cgd = Db::name("cgd_info")->where("ShortText1618315935182", "=", $value['cgdNo'])->find();
  37. if (empty($cgd)) {
  38. continue;
  39. }
  40. $cgd['Number1618330472961'] -= $value['diff_fee'];
  41. $cgd['Number1618330543270'] -= $value['diff_fee'];
  42. $cgd['Number1619632826654'] = $value['diff_fee'];
  43. $cgd['Number1619632830397'] = $value['diff_weight'];
  44. $update_cgd = Db::name("cgd_info")->save($cgd);
  45. if ($value['is_qrd'] == 1) {
  46. $qrd = Db::name("qrd_info")->where([["ShortText1617650701648", "=", $value['qrdNo']], ["ShortText1619487657199", "=", $value['cgdNo']]])->find();
  47. if (empty($qrd)) {
  48. continue;
  49. }
  50. $qrd['number1618249149738'] -= $value['diff_fee'];
  51. $qrd['Number1618249205231'] -= $value['diff_fee'];
  52. $qrd['Number1619403908740'] = $value['diff_fee'];
  53. $qrd['Number1619403905454'] = $value['diff_weight'];
  54. $update_qrd = Db::name("qrd_info")->save($qrd);
  55. if ($update_qrd && $update_cgd) {
  56. $value['status'] = 1;
  57. Db::name("diff_price")->save($value);
  58. }
  59. } else {
  60. if ($update_cgd) {
  61. $value['status'] = 1;
  62. Db::name("diff_price")->save($value);
  63. }
  64. }
  65. }
  66. $redis->set("diff", 0);
  67. } catch (\Exception $e) {
  68. $redis->set("diff", 0);
  69. }
  70. $redis->set("diff", 0);
  71. $output->writeln('diff');
  72. }
  73. }