Search in sources :

Example 76 with ApiRest

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

the class ElemeService method doBindingStore.

@Transactional(rollbackFor = Exception.class)
public ApiRest doBindingStore(DoBindingStoreModel doBindingStoreModel) throws IOException {
    BigInteger tenantId = doBindingStoreModel.getTenantId();
    BigInteger branchId = doBindingStoreModel.getBranchId();
    BigInteger shopId = doBindingStoreModel.getShopId();
    BigInteger userId = doBindingStoreModel.getUserId();
    String lastUpdateRemark = "门店(" + branchId + ")绑定饿了么(" + shopId + "),清除绑定关系!";
    UpdateModel updateModel = new UpdateModel(true);
    updateModel.setTableName("branch");
    updateModel.addContentValue("shop_id", null);
    updateModel.addContentValue("last_update_user_id", userId);
    updateModel.addContentValue("last_update_remark", lastUpdateRemark);
    updateModel.addSearchCondition("shop_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, shopId);
    universalMapper.universalUpdate(updateModel);
    SearchModel searchModel = new SearchModel(true);
    searchModel.addSearchCondition("id", Constants.SQL_OPERATION_SYMBOL_EQUALS, branchId);
    searchModel.addSearchCondition("tenant_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, tenantId);
    Branch branch = branchMapper.find(searchModel);
    Validate.notNull(branch, "门店不存在!");
    branch.setShopId(doBindingStoreModel.getShopId());
    branchMapper.update(branch);
    Map<String, String> saveElemeBranchMappingRequestParameters = new HashMap<String, String>();
    saveElemeBranchMappingRequestParameters.put("tenantId", tenantId.toString());
    saveElemeBranchMappingRequestParameters.put("branchId", branchId.toString());
    saveElemeBranchMappingRequestParameters.put("shopId", shopId.toString());
    saveElemeBranchMappingRequestParameters.put("userId", userId.toString());
    ApiRest saveElemeBranchMappingApiRest = ProxyUtils.doPostWithRequestParameters(Constants.SERVICE_NAME_OUT, "eleme", "saveElemeBranchMapping", saveElemeBranchMappingRequestParameters);
    Validate.isTrue(saveElemeBranchMappingApiRest.isSuccessful(), saveElemeBranchMappingApiRest.getError());
    ApiRest apiRest = new ApiRest();
    apiRest.setMessage("饿了么门店绑定成功!");
    apiRest.setSuccessful(true);
    return apiRest;
}
Also used : HashMap(java.util.HashMap) BigInteger(java.math.BigInteger) ApiRest(build.dream.common.api.ApiRest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 77 with ApiRest

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

the class ElemeService method cancelOrderLite.

/**
 * 取消订单
 *
 * @param cancelOrderLiteModel
 * @return
 * @throws IOException
 */
public ApiRest cancelOrderLite(CancelOrderLiteModel cancelOrderLiteModel) throws IOException {
    BigInteger tenantId = cancelOrderLiteModel.getTenantId();
    BigInteger branchId = cancelOrderLiteModel.getBranchId();
    BigInteger elemeOrderId = cancelOrderLiteModel.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());
    params.put("type", cancelOrderLiteModel.getType());
    ApplicationHandler.ifNotNullPut(params, "remark", cancelOrderLiteModel.getRemark());
    ApiRest callElemeSystemApiRest = ElemeUtils.callElemeSystem(tenantId.toString(), branchId.toString(), branch.getElemeAccountType(), "eleme.order.cancelOrderLite", 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 78 with ApiRest

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

the class ElemeService method getUser.

/**
 * 获取商户账号信息
 *
 * @param getUserModel
 * @return
 * @throws IOException
 */
public ApiRest getUser(GetUserModel getUserModel) throws IOException {
    BigInteger tenantId = getUserModel.getTenantId();
    BigInteger branchId = getUserModel.getBranchId();
    Branch branch = findBranch(tenantId, branchId);
    ApiRest callElemeSystemApiRest = ElemeUtils.callElemeSystem(tenantId.toString(), branchId.toString(), branch.getElemeAccountType(), "eleme.user.getUser", null);
    Validate.isTrue(callElemeSystemApiRest.isSuccessful(), callElemeSystemApiRest.getError());
    return new ApiRest(callElemeSystemApiRest.getData(), "获取商户账号信息成功!");
}
Also used : BigInteger(java.math.BigInteger) ApiRest(build.dream.common.api.ApiRest)

Example 79 with ApiRest

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

the class ElemeService method queryCompensationOrders.

/**
 * 批量查询索赔结果
 *
 * @param queryCompensationOrdersModel
 * @return
 * @throws IOException
 */
public ApiRest queryCompensationOrders(QueryCompensationOrdersModel queryCompensationOrdersModel) throws IOException {
    BigInteger tenantId = queryCompensationOrdersModel.getTenantId();
    BigInteger branchId = queryCompensationOrdersModel.getBranchId();
    Branch branch = findBranch(tenantId, branchId);
    List<ElemeOrder> elemeOrders = findAllElemeOrders(tenantId, branchId, queryCompensationOrdersModel.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.queryCompensationOrders", 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 80 with ApiRest

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

the class ElemeService method cancelDelivery.

/**
 * 取消呼叫配送
 *
 * @param cancelDeliveryModel
 * @return
 * @throws IOException
 */
public ApiRest cancelDelivery(CancelDeliveryModel cancelDeliveryModel) throws IOException {
    BigInteger tenantId = cancelDeliveryModel.getTenantId();
    BigInteger branchId = cancelDeliveryModel.getBranchId();
    BigInteger elemeOrderId = cancelDeliveryModel.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.cancelDelivery", 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)

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