|  | @@ -55,8 +55,8 @@ class HealthyPassPortController extends Controller
 | 
	
		
			
			| 55 | 55 |          $healthNickname = $request->healthNickname; //暱稱
 | 
	
		
			
			| 56 | 56 |          $healthGender = $request->healthGender; //性別
 | 
	
		
			
			| 57 | 57 |          $healthGenderRole = $request->healthGenderRole;//性別 male or female
 | 
	
		
			
			| 58 |  | -        
 | 
	
		
			
			| 59 |  | -        $survey_fill_content = ["healthAction" => $healthAction, 
 | 
	
		
			
			|  | 58 | +
 | 
	
		
			
			|  | 59 | +        $survey_fill_content = ["healthAction" => $healthAction,
 | 
	
		
			
			| 60 | 60 |                                  "healthTopic" => $healthTopic,
 | 
	
		
			
			| 61 | 61 |                                  "healthStatus" => $healthStatus,
 | 
	
		
			
			| 62 | 62 |                                  "healthAdapt" => $healthAdapt,
 | 
	
	
		
			
			|  | @@ -73,7 +73,7 @@ class HealthyPassPortController extends Controller
 | 
	
		
			
			| 73 | 73 |              }
 | 
	
		
			
			| 74 | 74 |              $statusCode = $this->botActionsSend($lineUserId,$clearAction);
 | 
	
		
			
			| 75 | 75 |          }
 | 
	
		
			
			| 76 |  | -        
 | 
	
		
			
			|  | 76 | +
 | 
	
		
			
			| 77 | 77 |          //準備將填寫內容過API寫入 botbonnie 後台
 | 
	
		
			
			| 78 | 78 |          $buildActions = [];
 | 
	
		
			
			| 79 | 79 |          array_push($buildActions, $this->buildActionsRequest("addTag", $healthAction));
 | 
	
	
		
			
			|  | @@ -83,7 +83,7 @@ class HealthyPassPortController extends Controller
 | 
	
		
			
			| 83 | 83 |          array_push($buildActions, $this->buildActionsRequest("addTag", $healthThought));
 | 
	
		
			
			| 84 | 84 |          array_push($buildActions, $this->buildActionsRequest("addTag", $healthAge));
 | 
	
		
			
			| 85 | 85 |          array_push($buildActions, $this->buildActionsRequest("addTag", $healthGender));
 | 
	
		
			
			| 86 |  | -        if($healthGenderRole != "")array_push($buildActions, $this->buildActionsRequest("saveParams", $healthGenderRole, "demographics", "gender"));       
 | 
	
		
			
			|  | 86 | +        if($healthGenderRole != "")array_push($buildActions, $this->buildActionsRequest("saveParams", $healthGenderRole, "demographics", "gender"));
 | 
	
		
			
			| 87 | 87 |  
 | 
	
		
			
			| 88 | 88 |          $statusCode = $this->botActionsSend($lineUserId,$buildActions);
 | 
	
		
			
			| 89 | 89 |          if($statusCode == 200){
 | 
	
	
		
			
			|  | @@ -118,7 +118,7 @@ class HealthyPassPortController extends Controller
 | 
	
		
			
			| 118 | 118 |              }
 | 
	
		
			
			| 119 | 119 |              array_push($clearAction, $this->buildActionsRequest("removeTag", config("botApi.doneSurvey")));
 | 
	
		
			
			| 120 | 120 |              array_push($clearAction, $this->buildActionsRequest("setMenu", "default"));
 | 
	
		
			
			| 121 |  | -            
 | 
	
		
			
			|  | 121 | +
 | 
	
		
			
			| 122 | 122 |              $statusCode = $this->botActionsSend($lineUserId,$clearAction);
 | 
	
		
			
			| 123 | 123 |              if($statusCode == 200){
 | 
	
		
			
			| 124 | 124 |                  $survey_data->delete();
 | 
	
	
		
			
			|  | @@ -157,7 +157,31 @@ class HealthyPassPortController extends Controller
 | 
	
		
			
			| 157 | 157 |          }
 | 
	
		
			
			| 158 | 158 |      }
 | 
	
		
			
			| 159 | 159 |  
 | 
	
		
			
			| 160 |  | -    function botActionsSend($lineUserId,$actions){
 | 
	
		
			
			|  | 160 | +    function botActionsSend($lineUserId, $actions){
 | 
	
		
			
			|  | 161 | +
 | 
	
		
			
			|  | 162 | +        $tagType = [];
 | 
	
		
			
			|  | 163 | +        foreach ($actions as $k => $action) {
 | 
	
		
			
			|  | 164 | +            if (!isset($tagType[$action['type']])) {
 | 
	
		
			
			|  | 165 | +                $tagType[$action['type']] = [];
 | 
	
		
			
			|  | 166 | +            }
 | 
	
		
			
			|  | 167 | +            switch ($action['type']) {
 | 
	
		
			
			|  | 168 | +                case "addTag":
 | 
	
		
			
			|  | 169 | +                case "removeTag":
 | 
	
		
			
			|  | 170 | +                    foreach ($action['value'] as $value) {
 | 
	
		
			
			|  | 171 | +                        $tagType[$action['type']]['value'][] = $value;
 | 
	
		
			
			|  | 172 | +                    }
 | 
	
		
			
			|  | 173 | +                    unset($actions[$k]);
 | 
	
		
			
			|  | 174 | +                    break;
 | 
	
		
			
			|  | 175 | +            }
 | 
	
		
			
			|  | 176 | +        }
 | 
	
		
			
			|  | 177 | +
 | 
	
		
			
			|  | 178 | +        $actions = array_merge($actions, [[
 | 
	
		
			
			|  | 179 | +            'type' => 'addTag',
 | 
	
		
			
			|  | 180 | +            'value' => $tagType['addTag']['value']
 | 
	
		
			
			|  | 181 | +        ]]);
 | 
	
		
			
			|  | 182 | +
 | 
	
		
			
			|  | 183 | +        $actions = array_values($actions);
 | 
	
		
			
			|  | 184 | +
 | 
	
		
			
			| 161 | 185 |          $client = new Client();
 | 
	
		
			
			| 162 | 186 |          $res_users = $client->request('POST', config('botApi.botActions'),[
 | 
	
		
			
			| 163 | 187 |              'headers'=>$this->api_header,
 |