12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- <?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\Cache;
- use think\facade\Db;
- class cgddiff extends Command
- {
- protected function configure()
- {
- // 指令配置
- $this->setName('datacopy')
- ->setDescription('the datacopy command');
- }
- protected function execute(Input $input, Output $output)
- {
- $redis = Cache::store('redis');
- $iscgd = $redis->get("diff");
- if($iscgd==0){
- $redis->set("diff",1,1200);
- }else{
- return;
- }
- $iscgd = $redis->get("diff");
- $ist = Db::name("diff_price")->where('status', "=", 0)->select();
- if (empty($ist)) {
- $redis->set("diff", 0);
- return;
- }
- try {
- foreach ($ist as $value) {
- $cgd = Db::name("cgd_info")->where("ShortText1618315935182", "=", $value['cgdNo'])->find();
- if (empty($cgd)) {
- continue;
- }
- $cgd['Number1618330472961'] -= $value['diff_fee'];
- $cgd['Number1618330543270'] -= $value['diff_fee'];
- $cgd['Number1619632826654'] = $value['diff_fee'];
- $cgd['Number1619632830397'] = $value['diff_weight'];
- $update_cgd = Db::name("cgd_info")->save($cgd);
- if ($value['is_qrd'] == 1) {
- $qrd = Db::name("qrd_info")->where([["ShortText1617650701648", "=", $value['qrdNo']], ["ShortText1619487657199", "=", $value['cgdNo']]])->find();
- if (empty($qrd)) {
- continue;
- }
- $qrd['number1618249149738'] -= $value['diff_fee'];
- $qrd['Number1618249205231'] -= $value['diff_fee'];
- $qrd['Number1619403908740'] = $value['diff_fee'];
- $qrd['Number1619403905454'] = $value['diff_weight'];
- $update_qrd = Db::name("qrd_info")->save($qrd);
- if ($update_qrd && $update_cgd) {
- $value['status'] = 1;
- Db::name("diff_price")->save($value);
- }
- } else {
- if ($update_cgd) {
- $value['status'] = 1;
- Db::name("diff_price")->save($value);
- }
- }
- }
- $redis->set("diff", 0);
- } catch (\Exception $e) {
- $redis->set("diff", 0);
- }
- $redis->set("diff", 0);
- $output->writeln('diff');
- }
- }
|