use of build.dream.common.api.ApiRest in project erp-catering by liuyandong33.
the class ElemeService method batchGetEvaluationInfos.
/**
* 批量获取骑手评价信息
*
* @param batchGetEvaluationInfosModel
* @return
* @throws IOException
*/
public ApiRest batchGetEvaluationInfos(BatchGetEvaluationInfosModel batchGetEvaluationInfosModel) throws IOException {
BigInteger tenantId = batchGetEvaluationInfosModel.getTenantId();
BigInteger branchId = batchGetEvaluationInfosModel.getBranchId();
Branch branch = findBranch(tenantId, branchId);
List<ElemeOrder> elemeOrders = findAllElemeOrders(tenantId, branchId, batchGetEvaluationInfosModel.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.mgetEvaluationInfos", 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 receivedOrderLite.
/**
* 订单确认送达
*
* @param receivedOrderLiteModel
* @return
* @throws IOException
*/
public ApiRest receivedOrderLite(ReceivedOrderLiteModel receivedOrderLiteModel) throws IOException {
BigInteger tenantId = receivedOrderLiteModel.getTenantId();
BigInteger branchId = receivedOrderLiteModel.getBranchId();
Branch branch = findBranch(tenantId, branchId);
ElemeOrder elemeOrder = findElemeOrder(tenantId, branchId, receivedOrderLiteModel.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.receivedOrderLite", 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 batchGetCommodities.
/**
* 批量获取订单菜品活动价格成功
*
* @param batchGetCommoditiesModel
* @return
*/
public ApiRest batchGetCommodities(BatchGetCommoditiesModel batchGetCommoditiesModel) throws IOException {
BigInteger tenantId = batchGetCommoditiesModel.getTenantId();
BigInteger branchId = batchGetCommoditiesModel.getBranchId();
Branch branch = findBranch(tenantId, branchId);
List<ElemeOrder> elemeOrders = findAllElemeOrders(tenantId, branchId, batchGetCommoditiesModel.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.mgetCommodities", 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 replyReminder.
/**
* 回复催单
*
* @param replyReminderModel
* @return
* @throws IOException
*/
public ApiRest replyReminder(ReplyReminderModel replyReminderModel) throws IOException {
BigInteger tenantId = replyReminderModel.getTenantId();
BigInteger branchId = replyReminderModel.getBranchId();
Branch branch = findBranch(tenantId, branchId);
ElemeOrder elemeOrder = findElemeOrder(tenantId, branchId, replyReminderModel.getElemeOrderId());
Map<String, Object> params = new HashMap<String, Object>();
params.put("orderId", elemeOrder.getOrderId());
params.put("type", replyReminderModel.getType());
ApplicationHandler.ifNotNullPut(params, "content", replyReminderModel.getContent());
ApiRest callElemeSystemApiRest = ElemeUtils.callElemeSystem(tenantId.toString(), branchId.toString(), branch.getElemeAccountType(), "eleme.order.replyReminder", 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 obtainElemeOrder.
@Transactional(readOnly = true)
public ApiRest obtainElemeOrder(ObtainElemeOrderModel obtainElemeOrderModel) {
BigInteger tenantId = obtainElemeOrderModel.getTenantId();
BigInteger branchId = obtainElemeOrderModel.getBranchId();
BigInteger elemeOrderId = obtainElemeOrderModel.getElemeOrderId();
// 查询订单
SearchModel elemeOrderSearchModel = new SearchModel(true);
elemeOrderSearchModel.addSearchCondition("tenant_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, tenantId);
elemeOrderSearchModel.addSearchCondition("branch_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, branchId);
elemeOrderSearchModel.addSearchCondition("id", Constants.SQL_OPERATION_SYMBOL_EQUALS, elemeOrderId);
ElemeOrder elemeOrder = elemeOrderMapper.find(elemeOrderSearchModel);
Validate.notNull(elemeOrder, "订单不存在!");
// 查询订单分组
SearchModel elemeOrderGroupSearchModel = new SearchModel(true);
elemeOrderGroupSearchModel.addSearchCondition("tenant_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, tenantId);
elemeOrderGroupSearchModel.addSearchCondition("branch_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, branchId);
elemeOrderGroupSearchModel.addSearchCondition("eleme_order_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, elemeOrderId);
List<ElemeOrderGroup> elemeOrderGroups = elemeOrderGroupMapper.findAll(elemeOrderGroupSearchModel);
// 查询所有订单分组明细
SearchModel elemeOrderItemSearchModel = new SearchModel(true);
elemeOrderItemSearchModel.addSearchCondition("tenant_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, tenantId);
elemeOrderItemSearchModel.addSearchCondition("branch_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, branchId);
elemeOrderItemSearchModel.addSearchCondition("eleme_order_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, elemeOrderId);
List<ElemeOrderItem> elemeOrderItems = elemeOrderItemMapper.findAll(elemeOrderItemSearchModel);
// 查询出所有的商品规格
SearchModel elemeOrderItemNewSpecSearchModel = new SearchModel(true);
elemeOrderItemNewSpecSearchModel.addSearchCondition("tenant_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, tenantId);
elemeOrderItemNewSpecSearchModel.addSearchCondition("branch_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, branchId);
elemeOrderItemNewSpecSearchModel.addSearchCondition("eleme_order_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, elemeOrderId);
List<ElemeOrderItemNewSpec> elemeOrderItemNewSpecs = elemeOrderItemNewSpecMapper.findAll(elemeOrderItemNewSpecSearchModel);
// 查询出所有的商品属性
SearchModel elemeOrderItemAttributeSearchModel = new SearchModel(true);
elemeOrderItemAttributeSearchModel.addSearchCondition("tenant_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, tenantId);
elemeOrderItemAttributeSearchModel.addSearchCondition("branch_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, branchId);
elemeOrderItemAttributeSearchModel.addSearchCondition("eleme_order_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, elemeOrderId);
List<ElemeOrderItemAttribute> elemeOrderItemAttributes = elemeOrderItemAttributeMapper.findAll(elemeOrderItemAttributeSearchModel);
// 查询出订单包含的所有活动
SearchModel elemeOrderActivitySearchModel = new SearchModel(true);
elemeOrderActivitySearchModel.addSearchCondition("tenant_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, tenantId);
elemeOrderActivitySearchModel.addSearchCondition("branch_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, branchId);
elemeOrderActivitySearchModel.addSearchCondition("eleme_order_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, elemeOrder.getId());
List<ElemeOrderActivity> elemeActivities = elemeOrderActivityMapper.findAll(elemeOrderActivitySearchModel);
// 封装订单分组与订单明细之间的 map
Map<BigInteger, List<ElemeOrderItem>> elemeOrderItemMap = new HashMap<BigInteger, List<ElemeOrderItem>>();
for (ElemeOrderItem elemeOrderItem : elemeOrderItems) {
List<ElemeOrderItem> elemeOrderItemList = elemeOrderItemMap.get(elemeOrderItem.getElemeOrderGroupId());
if (elemeOrderItemList == null) {
elemeOrderItemList = new ArrayList<ElemeOrderItem>();
elemeOrderItemMap.put(elemeOrderItem.getElemeOrderGroupId(), elemeOrderItemList);
}
elemeOrderItemList.add(elemeOrderItem);
}
// 封装订单明细与商品规格之间的 map
Map<BigInteger, List<ElemeOrderItemNewSpec>> elemeOrderItemNewSpecMap = new HashMap<BigInteger, List<ElemeOrderItemNewSpec>>();
for (ElemeOrderItemNewSpec elemeOrderItemNewSpec : elemeOrderItemNewSpecs) {
List<ElemeOrderItemNewSpec> elemeOrderItemNewSpecList = elemeOrderItemNewSpecMap.get(elemeOrderItemNewSpec.getElemeOrderItemId());
if (elemeOrderItemNewSpecList == null) {
elemeOrderItemNewSpecList = new ArrayList<ElemeOrderItemNewSpec>();
elemeOrderItemNewSpecMap.put(elemeOrderItemNewSpec.getElemeOrderItemId(), elemeOrderItemNewSpecList);
}
elemeOrderItemNewSpecList.add(elemeOrderItemNewSpec);
}
// 封装订单明细与商品属性之间的 map
Map<BigInteger, List<ElemeOrderItemAttribute>> elemeOrderItemAttributeMap = new HashMap<BigInteger, List<ElemeOrderItemAttribute>>();
for (ElemeOrderItemAttribute elemeOrderItemAttribute : elemeOrderItemAttributes) {
List<ElemeOrderItemAttribute> elemeOrderItemAttributeList = elemeOrderItemAttributeMap.get(elemeOrderItemAttribute.getElemeOrderItemId());
if (elemeOrderItemAttributeList == null) {
elemeOrderItemAttributeList = new ArrayList<ElemeOrderItemAttribute>();
elemeOrderItemAttributeMap.put(elemeOrderItemAttribute.getElemeOrderItemId(), elemeOrderItemAttributeList);
}
elemeOrderItemAttributeList.add(elemeOrderItemAttribute);
}
List<Map<String, Object>> groups = new ArrayList<Map<String, Object>>();
for (ElemeOrderGroup elemeOrderGroup : elemeOrderGroups) {
Map<String, Object> elemeGroupMap = new HashMap<String, Object>();
elemeGroupMap.put("name", elemeOrderGroup.getName());
elemeGroupMap.put("type", elemeOrderGroup.getType());
List<Map<String, Object>> items = new ArrayList<Map<String, Object>>();
List<ElemeOrderItem> elemeOrderItemList = elemeOrderItemMap.get(elemeOrderGroup.getId());
for (ElemeOrderItem elemeOrderItem : elemeOrderItemList) {
Map<String, Object> item = new HashMap<String, Object>();
item.put("id", elemeOrderItem.getElemeItemId());
item.put("skuId", elemeOrderItem.getSkuId());
item.put("name", elemeOrderItem.getName());
item.put("categoryId", elemeOrderItem.getCategoryId());
item.put("price", elemeOrderItem.getPrice());
item.put("quantity", elemeOrderItem.getQuantity());
item.put("total", elemeOrderItem.getTotal());
List<ElemeOrderItemNewSpec> elemeOrderItemNewSpecList = elemeOrderItemNewSpecMap.get(elemeOrderItem.getId());
List<Map<String, String>> newSpecs = new ArrayList<Map<String, String>>();
if (CollectionUtils.isNotEmpty(elemeOrderItemNewSpecList)) {
for (ElemeOrderItemNewSpec elemeOrderItemNewSpec : elemeOrderItemNewSpecList) {
Map<String, String> newSpec = new HashMap<String, String>();
newSpec.put("name", elemeOrderItemNewSpec.getName());
newSpec.put("value", elemeOrderItemNewSpec.getValue());
newSpecs.add(newSpec);
}
}
item.put("newSpecs", newSpecs);
List<ElemeOrderItemAttribute> elemeOrderItemAttributeList = elemeOrderItemAttributeMap.get(elemeOrderItem.getId());
List<Map<String, String>> attributes = new ArrayList<Map<String, String>>();
if (CollectionUtils.isNotEmpty(elemeOrderItemAttributeList)) {
for (ElemeOrderItemAttribute elemeOrderItemAttribute : elemeOrderItemAttributeList) {
Map<String, String> attribute = new HashMap<String, String>();
attribute.put("name", elemeOrderItemAttribute.getName());
attribute.put("value", elemeOrderItemAttribute.getValue());
attributes.add(attribute);
}
}
item.put("attributes", attributes);
item.put("extendCode", elemeOrderItem.getExtendCode());
item.put("barCode", elemeOrderItem.getBarCode());
item.put("weight", elemeOrderItem.getWeight());
item.put("userPrice", elemeOrderItem.getUserPrice());
item.put("shopPrice", elemeOrderItem.getShopPrice());
item.put("vfoodId", elemeOrderItem.getVfoodId());
items.add(item);
}
elemeGroupMap.put("items", items);
groups.add(elemeGroupMap);
}
Map<String, Object> elemeOrderMap = BeanUtils.beanToMap(elemeOrder);
elemeOrderMap.put("groups", groups);
List<Map<String, Object>> orderActivities = new ArrayList<Map<String, Object>>();
if (CollectionUtils.isNotEmpty(elemeActivities)) {
for (ElemeOrderActivity elemeOrderActivity : elemeActivities) {
Map<String, Object> elemeActivityMap = new HashMap<String, Object>();
elemeActivityMap.put("id", elemeOrderActivity.getElemeActivityId());
elemeActivityMap.put("name", elemeOrderActivity.getName());
elemeActivityMap.put("categoryId", elemeOrderActivity.getCategoryId());
elemeActivityMap.put("elemePart", elemeOrderActivity.getElemePart());
elemeActivityMap.put("restaurantPart", elemeOrderActivity.getRestaurantPart());
elemeActivityMap.put("amount", elemeOrderActivity.getAmount());
orderActivities.add(elemeActivityMap);
}
}
elemeOrderMap.put("orderActivities", orderActivities);
ApiRest apiRest = new ApiRest();
apiRest.setData(elemeOrderMap);
apiRest.setMessage("获取饿了么订单成功!");
apiRest.setSuccessful(true);
return apiRest;
}
Aggregations