123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- <?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 diffprice 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("diffprice");
- if($iscgd==0){
- $redis->set("diffprice",1,1200);
- }else{
- return;
- }
- try {
- $data = $this->GetData();
- foreach ($data as $value) {
- $ist = Db::table("diff_price")->where('sequenceNo', "=", $value['sequenceNo'])->find();
- if (!$ist) {
- Db::table("diff_price")->insert($value);
- }
- }
- $redis->set("diffprice",0);
- $output->writeln('diff');
- }catch (\Exception $e){
- $redis->set("diffprice",0);
- $output->writeln('diff');
- }
- }
- public function getdata()
- {
- $this->db =Db::connect("mysql2");
- $date = date("Y-m-d H:i:s", strtotime("-11 day"));
- $sql = " SELECT
- NAME as name,
- (
- SELECT
- `b_`.`name`
- FROM
- `h_org_user` `b_`
- WHERE
- ( CONVERT ( `b_`.`id` USING utf8mb4 ) = `b`.`owner` )) AS ownername,
- (
- SELECT
- `b_`.`name`
- FROM
- `h_org_department` `b_`
- WHERE
- ( CONVERT ( `b_`.`id` USING utf8mb4 ) = `b`.`ownerDeptId` )) AS ownerDept,
- createdTime AS addtime,
- (
- SELECT
- `b_`.`name`
- FROM
- `h_org_user` `b_`
- WHERE
- ( CONVERT ( `b_`.`id` USING utf8mb4 ) = `b`.`modifier` )) AS modifier,
- modifiedTime AS updatetime,
- sequenceNo,
- sequenceStatus,
- ShortText1618324616212 'cgdNo',
- Date1618324623113 'cgdtime',
- (
- SELECT
- `b_`.`name`
- FROM
- `il150_Customer_info` `b_`
- WHERE
- ( CONVERT ( `b_`.`id` USING utf8mb4 ) = `b`.`RelevanceForm1618324639751` )) as khName,
- ShortText1618324650659 'khNo',
- ShortText1618324668256 'goodName',
- ShortText1618324670141 'goodNo',
- ShortText1618324697504 'materal',
- Number1618324752186 'good_weight',
- Number1618324771668 'goodNum',
- Number1618324774208 'diff_weight',
- Number1618325048841 'diff_fee',
- number1619456487393 'qrd_weight',
- number1619456505633 'qrd_fee',
- ShortText1619631384425 'qrdNo',
- if(ifnull(ShortText1625201144504,'否')='是',1,0) 'is_qrd'
- FROM
- iw48m_gongchadengji b where sequenceStatus= 'COMPLETED' and
- modifiedTime >='{$date}'";
- $data = $this->db->query($sql);
- return $data;
- }
- }
|