execpp.php 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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 execpp extends Command
  12. {
  13. protected $db="";
  14. protected function configure()
  15. {
  16. // 指令配置
  17. $this->setName('CopyData')
  18. ->setDescription('the CopyData command');
  19. }
  20. protected function execute(Input $input, Output $output)
  21. {
  22. $qrd = $this->GetData();
  23. //var_dump($qrd);
  24. Db::startTrans();
  25. try{
  26. foreach ($qrd as $value){
  27. $source =Db::table("source_all")->where(["productNo"=>$value['productNo']])->find();
  28. $value['qrd_pay_status'] = $value['qrd_pay_status']=='未回'?1 :3;
  29. $value['qrd_inv_status'] = $value['qrd_inv_status']=='未开'?1 :3;
  30. // if($source==false){
  31. // Db::table("source_all")->insert($value);
  32. // }
  33. // $cgd = Db::table("cgd")->where(["cgdNo"=>$value['cgdNo']])->find();
  34. // if($cgd){
  35. // Db::table("source_all")->where(["productNo"=>$value['productNo']])->save($cgd);
  36. // }
  37. // $qrd =Db::name("qrd")->where(["sequenceNo"=>$value['qrdNo']])->find();
  38. // if($qrd==false){
  39. // $qrdData=[
  40. // "name"=>'网络部确认单'.$value['qrdNo'],
  41. // 'createdTime'=>date("Y-m-d H:i:s"),
  42. // 'sequenceNo'=>$value['qrdNo'],
  43. // 'sales_name'=>$value['sale_name'],
  44. // 'sales_depart'=>$value['suppitem'],
  45. // 'customer'=>isset($value['companyName']) ? $value['companyName'] : "",
  46. // 'total_fee'=>$value['sale_total'],
  47. // 'mobile'=>'',
  48. // 'contactor'=>'',
  49. // 'qrddate'=>date("Y-m-d H:i:s"),
  50. // 'companyNo'=>$value['companyNo'],
  51. // 'supplerName'=>$value['supperinfo'],
  52. // 'addr'=>'',
  53. // 'depart'=>$value['suppitem'],
  54. // 'type'=>1,
  55. // 'apay_fee'=>$value['qrd_apay_fee'],
  56. // 'pay_fee'=>0,
  57. // 'wpay_fee'=>$value['qrd_wpay_fee'],
  58. // 'ainv_fee'=>$value['qrd_ainv_fee'],
  59. // 'inv_fee'=>0,
  60. // 'winv_fee'=>$value['qrd_winv_fee'],
  61. // 'inv_status'=>$value['qrd_inv_status'],
  62. // 'pay_status'=>$value['qrd_pay_status'] ,
  63. // 'status'=>1,
  64. // 'addtime'=>date("Y-m-d H:i:s"),
  65. // 'updatetime'=>date("Y-m-d H:i:s")
  66. // ];
  67. // Db::name("qrd")->insert($qrdData);
  68. // }
  69. $qrdinfo =Db::name("qrd_info")->where(["sequenceNo"=>$value['qrdNo']])->find();
  70. if($qrdinfo==false){
  71. $data = [
  72. 'name' => '网络部确认单',
  73. 'createdTime' => date("Y-m-d H:i:s"),
  74. 'startTime' => date("Y-m-d H:i:s"),
  75. 'finishTime' => date("Y-m-d H:i:s"),
  76. "Date1617081795606"=>date("Y-m-d H:i:s"),
  77. // 'ownerName'=>date("Y-m-d H:i:s"),
  78. // 'departmentName'=>date("Y-m-d H:i:s"),
  79. 'sequenceNo' => $value['qrdNo'],
  80. 'sequenceStatus' => 1,
  81. 'ShortText1617022967356' => '网络部',
  82. 'text1617499162303'=>$value['product_code'],
  83. 'ShortText1617365292699' => $value['product_name'],
  84. "ShortText1617367958909" => $value['tax'],
  85. 'text1617365646297'=> $value['poNo'],
  86. "ShortText1618447165317"=>$value['companyName'],
  87. "Number1617365688048" => $value['order_num'],
  88. 'ShortText1617650669915' => $value['qrd_type'],
  89. 'ShortText1617650701648' =>$value['qrdNo'],
  90. "Number1618248810624" => $value['sale_price'],
  91. 'Number1618248813613' =>$value['sale_total'],
  92. "Number1618249015661" =>$value['order_num'],
  93. "number1618249149738" => $value['qrd_wpay_fee'], //wpay
  94. 'Number1618249146997'=>$value['qrd_apay_fee'],// apayaw
  95. "Number1618249205231" => $value['qrd_winv_fee'],//winv
  96. "Number1618249202608" => $value['qrd_ainv_fee'], //ainv
  97. 'ShortText1618446949933' =>'',
  98. 'ShortText1618446973813' => '',
  99. 'LongText1618446982973' =>'',
  100. 'ShortText1618559007040' => 3,
  101. 'ShortText1618559043560' => $value['qrd_pay_status'],
  102. 'ShortText1618559274859' => $value['qrd_inv_status'],
  103. "ShortText1617499192065"=>$value['cat_f'],
  104. 'StaffSelector1619488013389' => $value['sale_name'],
  105. 'ShortText1619523689586' => $value['suppitem'],
  106. 'ShortText1620750298602' =>isset($source['supplierNo'])?$source['supplierNo']:"",
  107. 'ShortText1620750301301' => isset($source['supplierName']) ? $source['supplierName'] : "",
  108. 'Date1620370378620' => date("Y-m-d H:i:s"),
  109. 'departmentName' => $value['suppitem'],
  110. 'ShortText1619542951283' =>$value['companyNo'],
  111. 'ShortText1619523892833' => isset($value['companyName']) ? $value['companyName'] : "",
  112. 'StaffSelector1618445844046' => $value['sale_name'],
  113. 'StaffSelector1618445850209' => $value['suppitem'],
  114. 'ownerName' =>$value['sale_name'],
  115. ];
  116. Db::name("qrd_info")->save($data);
  117. }
  118. }
  119. Db::commit();
  120. }catch (\Exception $e){
  121. echo $e->getMessage();
  122. Db::rollback();
  123. }
  124. $output->writeln('CopyData');
  125. }
  126. protected function GetData(){
  127. $isT= Db::table("qrd")->select();
  128. return $isT;
  129. }
  130. protected function GetCGD(){
  131. $isT= Db::table("cgd")->select();
  132. return $isT;
  133. }
  134. }