Search in sources :

Example 61 with ApiRest

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

the class ElemeService method setBookingStatus.

/**
 * 设置是否支持预定单及预定天数
 *
 * @param setBookingStatusModel
 * @return
 * @throws IOException
 */
public ApiRest setBookingStatus(SetBookingStatusModel setBookingStatusModel) throws IOException {
    BigInteger tenantId = setBookingStatusModel.getTenantId();
    BigInteger branchId = setBookingStatusModel.getBranchId();
    Branch branch = findBranch(tenantId, branchId);
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("shopId", branch.getShopId());
    params.put("enable", setBookingStatusModel.getEnabled());
    ApplicationHandler.ifNotNullPut(params, "maxBookingDays", setBookingStatusModel.getMaxBookingDays());
    ApiRest callElemeSystemApiRest = ElemeUtils.callElemeSystem(tenantId.toString(), branchId.toString(), branch.getElemeAccountType(), "eleme.shop.setBookingStatus", params);
    Validate.isTrue(callElemeSystemApiRest.isSuccessful(), callElemeSystemApiRest.getError());
    return new ApiRest(callElemeSystemApiRest.getData(), "设置是否支持预定单及预定天数成功!");
}
Also used : HashMap(java.util.HashMap) BigInteger(java.math.BigInteger) JSONObject(net.sf.json.JSONObject) ApiRest(build.dream.common.api.ApiRest)

Example 62 with ApiRest

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

the class ElemeService method confirmOrderLite.

/**
 * 确认订单
 *
 * @param confirmOrderLiteModel
 * @return
 * @throws IOException
 */
public ApiRest confirmOrderLite(ConfirmOrderLiteModel confirmOrderLiteModel) throws IOException {
    BigInteger tenantId = confirmOrderLiteModel.getTenantId();
    BigInteger branchId = confirmOrderLiteModel.getBranchId();
    BigInteger elemeOrderId = confirmOrderLiteModel.getElemeOrderId();
    Branch branch = findBranch(tenantId, branchId);
    ElemeOrder elemeOrder = findElemeOrder(tenantId, branchId, elemeOrderId);
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("orderId", elemeOrder.getOrderId());
    ApiRest callElemeSystemApiRest = ElemeUtils.callElemeSystem(tenantId.toString(), branchId.toString(), branch.getElemeAccountType(), "eleme.order.confirmOrderLite", params);
    Validate.isTrue(callElemeSystemApiRest.isSuccessful(), callElemeSystemApiRest.getError());
    return new ApiRest(callElemeSystemApiRest.getData(), "确认订单成功!");
}
Also used : HashMap(java.util.HashMap) BigInteger(java.math.BigInteger) JSONObject(net.sf.json.JSONObject) ApiRest(build.dream.common.api.ApiRest)

Example 63 with ApiRest

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

the class ElemeService method getCommodities.

/**
 * 获取指定订单菜品活动价格
 *
 * @param getCommoditiesModel
 * @return
 * @throws IOException
 */
public ApiRest getCommodities(GetCommoditiesModel getCommoditiesModel) throws IOException {
    BigInteger tenantId = getCommoditiesModel.getTenantId();
    BigInteger branchId = getCommoditiesModel.getBranchId();
    Branch branch = findBranch(tenantId, branchId);
    ElemeOrder elemeOrder = findElemeOrder(tenantId, branchId, getCommoditiesModel.getElemeOrderId());
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("orderId", elemeOrder.getOrderId());
    ApiRest callElemeSystemApiRest = ElemeUtils.callElemeSystem(tenantId.toString(), branchId.toString(), branch.getElemeAccountType(), "eleme.order.getCommodities", params);
    Validate.isTrue(callElemeSystemApiRest.isSuccessful(), callElemeSystemApiRest.getError());
    return new ApiRest(callElemeSystemApiRest.getData(), "获取指定订单菜品活动价格成功!");
}
Also used : HashMap(java.util.HashMap) BigInteger(java.math.BigInteger) JSONObject(net.sf.json.JSONObject) ApiRest(build.dream.common.api.ApiRest)

Example 64 with ApiRest

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

the class ElemeService method batchGetOrders.

/**
 * 批量查询订单
 *
 * @param batchGetOrdersModel
 * @return
 * @throws IOException
 */
@Transactional(readOnly = true)
public ApiRest batchGetOrders(BatchGetOrdersModel batchGetOrdersModel) throws IOException {
    BigInteger tenantId = batchGetOrdersModel.getTenantId();
    BigInteger branchId = batchGetOrdersModel.getBranchId();
    Branch branch = findBranch(tenantId, branchId);
    List<ElemeOrder> elemeOrders = findAllElemeOrders(tenantId, branchId, batchGetOrdersModel.getElemeOrderIds());
    List<String> orderIds = obtainOrderIds(elemeOrders);
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("orderIds", orderIds);
    ApiRest callElemeSystemApiRest = ElemeUtils.callElemeSystem(tenantId.toString(), branchId.toString(), branch.getElemeAccountType(), "eleme.order.mgetOrders", params);
    Validate.isTrue(callElemeSystemApiRest.isSuccessful(), callElemeSystemApiRest.getError());
    return new ApiRest(callElemeSystemApiRest.getData(), "批量查询订单成功!");
}
Also used : HashMap(java.util.HashMap) BigInteger(java.math.BigInteger) JSONObject(net.sf.json.JSONObject) ApiRest(build.dream.common.api.ApiRest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 65 with ApiRest

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

the class ElemeService method tenantAuthorize.

@Transactional(readOnly = true)
public ApiRest tenantAuthorize(TenantAuthorizeModel tenantAuthorizeModel) throws IOException {
    BigInteger tenantId = tenantAuthorizeModel.getTenantId();
    BigInteger branchId = tenantAuthorizeModel.getBranchId();
    BigInteger userId = tenantAuthorizeModel.getUserId();
    SearchModel searchModel = new SearchModel(true);
    searchModel.addSearchCondition("tenant_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, tenantId);
    searchModel.addSearchCondition("id", Constants.SQL_OPERATION_SYMBOL_EQUALS, branchId);
    Branch branch = branchMapper.find(searchModel);
    Validate.notNull(branch, "门店不存在!");
    Map<String, String> checkIsAuthorizeRequestParameters = new HashMap<String, String>();
    checkIsAuthorizeRequestParameters.put("tenantId", tenantId.toString());
    checkIsAuthorizeRequestParameters.put("branchId", branchId.toString());
    String elemeAccountType = branch.getElemeAccountType().toString();
    checkIsAuthorizeRequestParameters.put("elemeAccountType", elemeAccountType);
    String checkIsAuthorizeResult = ProxyUtils.doGetOriginalWithRequestParameters(Constants.SERVICE_NAME_OUT, "eleme", "checkIsAuthorize", checkIsAuthorizeRequestParameters);
    ApiRest checkIsAuthorizeApiRest = ApiRest.fromJson(checkIsAuthorizeResult);
    Validate.isTrue(checkIsAuthorizeApiRest.isSuccessful(), checkIsAuthorizeApiRest.getError());
    Map<String, Object> checkIsAuthorizeApiRestData = (Map<String, Object>) checkIsAuthorizeApiRest.getData();
    boolean isAuthorize = (boolean) checkIsAuthorizeApiRestData.get("isAuthorize");
    String data = null;
    if (isAuthorize) {
        String serviceName = ConfigurationUtils.getConfiguration(Constants.SERVICE_NAME);
        data = SystemPartitionUtils.getOutsideUrl(Constants.SERVICE_NAME_POSAPI, "eleme", "bindingStore") + "?serviceName=" + serviceName + "&controllerName=eleme&actionName=bindingStore" + "&tenantId=" + tenantId + "&branchId=" + branchId + "&userId=" + userId;
    } else {
        String elemeUrl = ConfigurationUtils.getConfiguration(Constants.ELEME_SERVICE_URL);
        String elemeAppKey = ConfigurationUtils.getConfiguration(Constants.ELEME_APP_KEY);
        String outServiceOutsideServiceDomain = SystemPartitionUtils.getOutsideServiceDomain(Constants.SERVICE_NAME_OUT);
        data = String.format(Constants.ELEME_TENANT_AUTHORIZE_URL_FORMAT, elemeUrl + "/" + "authorize", "code", elemeAppKey, URLEncoder.encode(outServiceOutsideServiceDomain + "/eleme/tenantAuthorizeCallback", Constants.CHARSET_NAME_UTF_8), tenantId + "Z" + branchId + "Z" + userId + "Z" + elemeAccountType, "all");
    }
    ApiRest apiRest = new ApiRest(data, "生成授权链接成功!");
    return apiRest;
}
Also used : HashMap(java.util.HashMap) BigInteger(java.math.BigInteger) JSONObject(net.sf.json.JSONObject) ApiRest(build.dream.common.api.ApiRest) HashMap(java.util.HashMap) Map(java.util.Map) Transactional(org.springframework.transaction.annotation.Transactional)

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