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(), "设置是否支持预定单及预定天数成功!");
}
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(), "确认订单成功!");
}
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(), "获取指定订单菜品活动价格成功!");
}
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(), "批量查询订单成功!");
}
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;
}
Aggregations