Search in sources :

Example 11 with Branch

use of build.dream.common.erp.catering.domains.Branch in project erp-catering by liuyandong33.

the class ElemeController method getShopSalesItems.

/**
 * 查询店铺活动商品
 *
 * @return
 */
@RequestMapping(value = "/getShopSalesItems")
@ResponseBody
public String getShopSalesItems() {
    ApiRest apiRest = null;
    Map<String, String> requestParameters = ApplicationHandler.getRequestParameters();
    try {
        GetShopSalesItemsModel getShopSalesItemsModel = ApplicationHandler.instantiateObject(GetShopSalesItemsModel.class, requestParameters);
        getShopSalesItemsModel.validateAndThrow();
        Branch branch = elemeService.findBranch(getShopSalesItemsModel.getTenantId(), getShopSalesItemsModel.getBranchId());
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("shopId", branch.getShopId());
        ApiRest callElemeSystemApiRest = ElemeUtils.callElemeSystem(getShopSalesItemsModel.getTenantId().toString(), getShopSalesItemsModel.getBranchId().toString(), branch.getElemeAccountType(), "eleme.product.item.getShopSalesItems", params);
        Validate.isTrue(callElemeSystemApiRest.isSuccessful(), callElemeSystemApiRest.getError());
        apiRest = new ApiRest();
        apiRest.setData(callElemeSystemApiRest.getData());
        apiRest.setMessage("查询店铺活动商品成功!");
        apiRest.setSuccessful(true);
    } catch (Exception e) {
        LogUtils.error("查询店铺活动商品失败", controllerSimpleName, "getShopSalesItems", e, requestParameters);
        apiRest = new ApiRest(e);
    }
    return GsonUtils.toJson(apiRest);
}
Also used : HashMap(java.util.HashMap) Branch(build.dream.common.erp.catering.domains.Branch) ApiRest(build.dream.common.api.ApiRest) IOException(java.io.IOException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 12 with Branch

use of build.dream.common.erp.catering.domains.Branch in project erp-catering by liuyandong33.

the class ElemeController method removeCategory.

@RequestMapping(value = "/removeCategory")
@ResponseBody
public String removeCategory() {
    ApiRest apiRest = null;
    Map<String, String> requestParameters = ApplicationHandler.getRequestParameters();
    try {
        String tenantId = requestParameters.get("tenantId");
        Validate.notNull(tenantId, "参数(tenantId)不能为空!");
        String branchId = requestParameters.get("branchId");
        Validate.notNull(branchId, "参数(branchId)不能为空!");
        String categoryId = requestParameters.get("categoryId");
        Validate.notNull(categoryId, ApplicationHandler.obtainParameterErrorMessage("categoryId"));
        BigInteger bigIntegerTenantId = NumberUtils.createBigInteger(tenantId);
        BigInteger bigIntegerBranchId = NumberUtils.createBigInteger(branchId);
        BigInteger bigIntegerCategoryId = NumberUtils.createBigInteger(categoryId);
        Branch branch = elemeService.findBranch(bigIntegerTenantId, bigIntegerBranchId);
        GoodsCategory goodsCategory = elemeService.findGoodsCategoryInfo(bigIntegerTenantId, bigIntegerBranchId, bigIntegerCategoryId);
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("categoryId", goodsCategory.getId());
        apiRest = ElemeUtils.callElemeSystem(tenantId, branchId, branch.getElemeAccountType(), "eleme.product.category.removeCategory", params);
    } catch (Exception e) {
        LogUtils.error("删除商品分类失败", controllerSimpleName, "removeCategory", e, requestParameters);
        apiRest = new ApiRest(e);
    }
    return GsonUtils.toJson(apiRest);
}
Also used : HashMap(java.util.HashMap) Branch(build.dream.common.erp.catering.domains.Branch) GoodsCategory(build.dream.common.erp.catering.domains.GoodsCategory) BigInteger(java.math.BigInteger) ApiRest(build.dream.common.api.ApiRest) IOException(java.io.IOException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 13 with Branch

use of build.dream.common.erp.catering.domains.Branch in project erp-catering by liuyandong33.

the class ElemeController method getCategoryWithChildren.

@RequestMapping(value = "/getCategoryWithChildren")
@ResponseBody
public String getCategoryWithChildren() {
    ApiRest apiRest = null;
    Map<String, String> requestParameters = ApplicationHandler.getRequestParameters();
    try {
        String tenantId = requestParameters.get("tenantId");
        Validate.notNull(tenantId, "参数(tenantId)不能为空!");
        String branchId = requestParameters.get("branchId");
        Validate.notNull(branchId, "参数(branchId)不能为空!");
        Branch branch = elemeService.findBranch(NumberUtils.createBigInteger(tenantId), NumberUtils.createBigInteger(branchId));
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("shopId", branch.getShopId());
        apiRest = ElemeUtils.callElemeSystem(tenantId, branchId, branch.getElemeAccountType(), "eleme.product.category.getShopCategoriesWithChildren", params);
    } catch (Exception e) {
        LogUtils.error("查询商品分类详情失败", controllerSimpleName, "getCategoryWithChildren", e, requestParameters);
        apiRest = new ApiRest(e);
    }
    return GsonUtils.toJson(apiRest);
}
Also used : HashMap(java.util.HashMap) Branch(build.dream.common.erp.catering.domains.Branch) ApiRest(build.dream.common.api.ApiRest) IOException(java.io.IOException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 14 with Branch

use of build.dream.common.erp.catering.domains.Branch in project erp-catering by liuyandong33.

the class ElemeController method createCategory.

@RequestMapping(value = "/createCategory")
@ResponseBody
public String createCategory() {
    ApiRest apiRest = null;
    Map<String, String> requestParameters = ApplicationHandler.getRequestParameters();
    try {
        String tenantId = requestParameters.get("tenantId");
        Validate.notNull(tenantId, "参数(tenantId)不能为空!");
        String branchId = requestParameters.get("branchId");
        Validate.notNull(branchId, "参数(branchId)不能为空!");
        String categoryId = requestParameters.get("categoryId");
        Validate.notNull(categoryId, ApplicationHandler.obtainParameterErrorMessage("categoryId"));
        BigInteger bigIntegerTenantId = NumberUtils.createBigInteger(tenantId);
        BigInteger bigIntegerBranchId = NumberUtils.createBigInteger(branchId);
        BigInteger bigIntegerCategoryId = NumberUtils.createBigInteger(categoryId);
        Branch branch = elemeService.findBranch(bigIntegerTenantId, bigIntegerBranchId);
        GoodsCategory goodsCategory = elemeService.findGoodsCategoryInfo(bigIntegerTenantId, bigIntegerBranchId, bigIntegerCategoryId);
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("shopId", branch.getShopId());
        params.put("name", goodsCategory.getName());
        params.put("description", goodsCategory.getDescription());
        apiRest = ElemeUtils.callElemeSystem(tenantId, branchId, branch.getElemeAccountType(), "eleme.product.category.createCategory", params);
    } catch (Exception e) {
        LogUtils.error("添加商品分类失败", controllerSimpleName, "createCategory", e, requestParameters);
        apiRest = new ApiRest(e);
    }
    return GsonUtils.toJson(apiRest);
}
Also used : HashMap(java.util.HashMap) Branch(build.dream.common.erp.catering.domains.Branch) GoodsCategory(build.dream.common.erp.catering.domains.GoodsCategory) BigInteger(java.math.BigInteger) ApiRest(build.dream.common.api.ApiRest) IOException(java.io.IOException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

ApiRest (build.dream.common.api.ApiRest)14 Branch (build.dream.common.erp.catering.domains.Branch)14 HashMap (java.util.HashMap)12 IOException (java.io.IOException)11 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)11 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)11 BigInteger (java.math.BigInteger)8 GoodsCategory (build.dream.common.erp.catering.domains.GoodsCategory)5 Transactional (org.springframework.transaction.annotation.Transactional)3 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1