Task.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <?php
  2. namespace app\admin\command;
  3. use app\admin\controller\user\User;
  4. use think\console\Command;
  5. use think\console\Input;
  6. use app\admin\model\Importregion;
  7. use app\common\model\ProductOrder;
  8. use think\console\Output;
  9. use think\Exception;
  10. use app\common\model\Region;
  11. use app\common\model\UserPledge;
  12. class Task extends Command
  13. {
  14. protected function configure()
  15. {
  16. $this->setName('task')->setDescription('Compress js and css file');
  17. }
  18. protected function execute1(Input $input, Output $output)
  19. {
  20. $reg = new Region();
  21. $list = $reg::where('level', '=', 1)->column('id,name');
  22. $arr = array();
  23. $i = 0;
  24. foreach ($list as $key => $item) {
  25. $arr[$i]['label'] = $item;
  26. $arr[$i]['id'] = $key;
  27. $list1 =$reg::where('parent_id', '=', $key)->column('id,name');
  28. $j = 0;
  29. foreach ($list1 as $key1 => $item1) {
  30. $arr[$i]['children'][$j]['label'] = $item1;
  31. $arr[$i]['children'][$j]['id'] = $key1;
  32. $list2 =$reg::where('parent_id', '=', $key1)->column('id,name');
  33. $s = 0;
  34. foreach ($list2 as $key2 => $item2) {
  35. $arr[$i]['children'][$j]['children'][$s]['label'] = $item2;
  36. $arr[$i]['children'][$j]['children'][$s]['id'] = $key2;
  37. $list3 =$reg::where('parent_id', '=', $key2)->column('id,name');
  38. $d = 0;
  39. foreach ($list3 as $key3 => $item3) {
  40. if(!empty($item3)){
  41. $arr[$i]['children'][$j]['children'][$s]['children'][$d]['label'] = $item3;
  42. $arr[$i]['children'][$j]['children'][$s]['children'][$d]['id'] = $key3;
  43. $d += 1;
  44. }
  45. }
  46. $s +=1;
  47. }
  48. $j +=1;
  49. }
  50. $i +=1;
  51. }
  52. file_put_contents('./11.txt', json_encode($arr, JSON_UNESCAPED_UNICODE));
  53. $output->info("Ok Successed!");
  54. }
  55. //山西省-大同市-平城区
  56. //地区导出格式 140213 平城区 140214 云冈区
  57. public function execute(Input $input, Output $output){
  58. //
  59. $rows = UserPledge::where('status', '>', 0)->select();
  60. $model = new ProductOrder();
  61. foreach ($rows as $row) {
  62. //修改详情
  63. $detail = json_decode($row['details'], true);
  64. foreach ($detail as &$item) {
  65. $item['id'] = $model::where('order_no', '=', $item['order_no'])->value('id');
  66. //修改订单状态
  67. if($row['user_id'] == 1073 && $row['status'] == UserPledge::Remove){
  68. $model::where('id', '=', $item['id'])->setField('status', ProductOrder::Paid);
  69. }
  70. }
  71. $row->details = json_encode($detail, JSON_UNESCAPED_UNICODE);
  72. $row->save();
  73. }
  74. }
  75. }