package com.engine.htsc.payment.web;


import com.engine.common.util.ParamUtil;
import com.engine.common.util.ServiceUtil;
import com.engine.htsc.payment.pojo.AutoRequestParam;
import com.engine.htsc.payment.service.StaffCodService;
import com.engine.htsc.payment.service.impl.StaffCodServiceImpl;
import com.engine.htsc.trip.util.AjaxResult;

import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import java.util.Map;

public class StaffCondolencesAction {

  private StaffCodService getService(){
    return ServiceUtil.getService(StaffCodServiceImpl.class);
  }

  @POST
  @Path("/autoTriggerLaborUnionPayment")
  @Produces(MediaType.APPLICATION_JSON)
  public AjaxResult<Map<String, String>> travelControlBudget(@Context HttpServletRequest request) {
    try {
      Map<String, Object> params = ParamUtil.request2Map(request);
      String rids = (String) params.getOrDefault("rids", "");
      AutoRequestParam autoRequestParam = getService().generateAutoRequestParamByStaffCodRid(rids);
      Map<String, String> resp = this.getService().autoTriggerLaborUnionPayment(autoRequestParam);
      return AjaxResult.ok(resp);
    } catch (Exception e) {
      return AjaxResult.error("自动触发工会流程,发生异常:" + e.getMessage());
    }
  }
}
