Search in sources :

Example 31 with ApiRest

use of build.dream.common.api.ApiRest in project erp-catering by liuyandong33.

the class MeiTuanController method checkIsBinding.

/**
 * 查询门店是否绑定美团
 *
 * @return
 */
@RequestMapping(value = "/checkIsBinding")
@ResponseBody
public String checkIsBinding() {
    ApiRest apiRest = null;
    Map<String, String> requestParameters = ApplicationHandler.getRequestParameters();
    try {
        CheckIsBindingModel checkIsBindingModel = ApplicationHandler.instantiateObject(CheckIsBindingModel.class, requestParameters);
        checkIsBindingModel.validateAndThrow();
        apiRest = meiTuanService.checkIsBinding(checkIsBindingModel);
    } catch (Exception e) {
        LogUtils.error("查询门店是否绑定美团失败!", controllerSimpleName, "checkIsBinding", e, requestParameters);
        apiRest = new ApiRest(e);
    }
    return GsonUtils.toJson(apiRest);
}
Also used : ApiRest(build.dream.common.api.ApiRest) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 32 with ApiRest

use of build.dream.common.api.ApiRest in project erp-catering by liuyandong33.

the class MeiTuanController method obtainMeiTuanOrder.

/**
 * 拉取美团订单
 *
 * @return
 */
@RequestMapping(value = "/obtainMeiTuanOrder")
@ResponseBody
public String obtainMeiTuanOrder() {
    ApiRest apiRest = null;
    Map<String, String> requestParameters = ApplicationHandler.getRequestParameters();
    try {
        ObtainMeiTuanOrderModel obtainMeiTuanOrderModel = ApplicationHandler.instantiateObject(ObtainMeiTuanOrderModel.class, requestParameters);
        obtainMeiTuanOrderModel.validateAndThrow();
        apiRest = meiTuanService.obtainMeiTuanOrder(obtainMeiTuanOrderModel);
    } catch (Exception e) {
        LogUtils.error("拉取美团订单失败!", controllerSimpleName, "pullMeiTuanOrder", e, requestParameters);
        apiRest = new ApiRest(e);
    }
    return GsonUtils.toJson(apiRest);
}
Also used : ApiRest(build.dream.common.api.ApiRest) ObtainMeiTuanOrderModel(build.dream.catering.models.meituan.ObtainMeiTuanOrderModel) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 33 with ApiRest

use of build.dream.common.api.ApiRest in project erp-catering by liuyandong33.

the class MiniProgramController method obtainSessionWithJsCode.

@RequestMapping(value = "/obtainSessionWithJsCode")
@ResponseBody
public String obtainSessionWithJsCode() {
    ApiRest apiRest = null;
    Map<String, String> requestParameters = ApplicationHandler.getRequestParameters();
    try {
        ObtainSessionWithJsCodeModel obtainSessionWithJsCodeModel = ApplicationHandler.instantiateObject(ObtainSessionWithJsCodeModel.class, requestParameters);
        obtainSessionWithJsCodeModel.validateAndThrow();
        Map<String, String> obtainSessionRequestParameters = new HashMap<String, String>();
        obtainSessionRequestParameters.put("appid", "wxc375e036b110a28f");
        obtainSessionRequestParameters.put("secret", "415627f3ec7bf51497a98e94546affa7");
        obtainSessionRequestParameters.put("js_code", obtainSessionWithJsCodeModel.getCode());
        obtainSessionRequestParameters.put("grant_type", "authorization_code");
        String obtainSessionResult = WebUtils.doGetWithRequestParameters("https://api.weixin.qq.com/sns/jscode2session", obtainSessionRequestParameters);
        JSONObject obtainSessionResultJsonObject = JSONObject.fromObject(obtainSessionResult);
        Validate.isTrue(!obtainSessionResultJsonObject.has("errcode"), obtainSessionResultJsonObject.optString("errmsg"));
        apiRest = new ApiRest();
        apiRest.setData(obtainSessionResultJsonObject);
        apiRest.setMessage("处理成功!");
        apiRest.setSuccessful(true);
    } catch (Exception e) {
        LogUtils.error("code换取session_key失败", controllerSimpleName, "obtainSessionWithJsCode", e, requestParameters);
        apiRest = new ApiRest(e);
    }
    return GsonUtils.toJson(apiRest);
}
Also used : JSONObject(net.sf.json.JSONObject) HashMap(java.util.HashMap) ApiRest(build.dream.common.api.ApiRest) ObtainSessionWithJsCodeModel(build.dream.catering.models.miniprogram.ObtainSessionWithJsCodeModel) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 34 with ApiRest

use of build.dream.common.api.ApiRest in project erp-catering by liuyandong33.

the class ActivityController method saveBuyGiveActivity.

/**
 * 保存买A赠B活动
 *
 * @return
 */
@RequestMapping(value = "/saveBuyGiveActivity")
@ResponseBody
public String saveBuyGiveActivity() {
    ApiRest apiRest = null;
    Map<String, String> requestParameters = ApplicationHandler.getRequestParameters();
    try {
        SaveBuyGiveActivityModel saveBuyGiveActivityModel = ApplicationHandler.instantiateObject(SaveBuyGiveActivityModel.class, requestParameters);
        String buyGiveActivityInfos = requestParameters.get("buyGiveActivityInfos");
        saveBuyGiveActivityModel.setBuyGiveActivityInfos(buyGiveActivityInfos);
        saveBuyGiveActivityModel.validateAndThrow();
        apiRest = activityService.saveBuyGiveActivity(saveBuyGiveActivityModel);
    } catch (Exception e) {
        LogUtils.error("保存买A赠B活动失败", controllerSimpleName, "saveBuyGiveActivity", e, requestParameters);
        apiRest = new ApiRest(e);
    }
    return GsonUtils.toJson(apiRest);
}
Also used : SaveBuyGiveActivityModel(build.dream.catering.models.activity.SaveBuyGiveActivityModel) ApiRest(build.dream.common.api.ApiRest) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 35 with ApiRest

use of build.dream.common.api.ApiRest in project erp-catering by liuyandong33.

the class AnubisController method chainStoreQuery.

/**
 * 查询门店信息
 *
 * @return
 */
@RequestMapping(value = "/chainStoreQuery")
@ResponseBody
public String chainStoreQuery() {
    ApiRest apiRest = null;
    Map<String, String> requestParameters = ApplicationHandler.getRequestParameters();
    try {
        List<String> chainStoreCodes = new ArrayList<String>();
        chainStoreCodes.add("A001");
        chainStoreCodes.add("A002");
        Map<String, Object> data = new HashMap<String, Object>();
        data.put("chain_store_code", chainStoreCodes);
        String url = ConfigurationUtils.getConfiguration(Constants.ANUBIS_SERVICE_URL) + Constants.ANUBIS_CHAIN_STORE_QUERY_URI;
        String appId = ConfigurationUtils.getConfiguration(Constants.ANUBIS_APP_ID);
        apiRest = AnubisUtils.callAnubisSystem(url, appId, data);
    } catch (Exception e) {
        LogUtils.error("查询门店信息失败", controllerSimpleName, "chainStoreQuery", e, requestParameters);
        apiRest = new ApiRest(e);
    }
    return GsonUtils.toJson(apiRest);
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ApiRest(build.dream.common.api.ApiRest) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

ApiRest (build.dream.common.api.ApiRest)187 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)101 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)101 BigInteger (java.math.BigInteger)78 HashMap (java.util.HashMap)68 IOException (java.io.IOException)59 JSONObject (net.sf.json.JSONObject)56 Transactional (org.springframework.transaction.annotation.Transactional)36 SearchModel (build.dream.common.utils.SearchModel)19 Branch (build.dream.common.erp.catering.domains.Branch)14 ArrayList (java.util.ArrayList)8 SimpleDateFormat (java.text.SimpleDateFormat)6 Map (java.util.Map)6 GoodsCategory (build.dream.common.erp.catering.domains.GoodsCategory)5 SaveBuyGiveActivityModel (build.dream.catering.models.activity.SaveBuyGiveActivityModel)2 SaveSpecialGoodsActivityModel (build.dream.catering.models.activity.SaveSpecialGoodsActivityModel)2 SaveDietOrderModel (build.dream.catering.models.dietorder.SaveDietOrderModel)2 Pos (build.dream.common.erp.catering.domains.Pos)2 Vip (build.dream.common.erp.catering.domains.Vip)2 UpdateModel (build.dream.common.utils.UpdateModel)2