Search in sources :

Example 6 with Branch

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

the class BranchService method initializeBranch.

@Transactional(rollbackFor = Exception.class)
public ApiRest initializeBranch(InitializeBranchModel initializeBranchModel) {
    Branch branch = new Branch();
    branch.setTenantId(initializeBranchModel.getTenantId());
    branch.setTenantCode(initializeBranchModel.getTenantCode());
    String code = SerialNumberGenerator.nextSerialNumber(4, sequenceMapper.nextValue(initializeBranchModel.getTenantCode() + "_branch_count"));
    branch.setCode(code);
    branch.setName(initializeBranchModel.getName());
    branch.setType(initializeBranchModel.getType());
    branch.setStatus(initializeBranchModel.getStatus());
    branch.setProvinceCode(initializeBranchModel.getProvinceCode());
    branch.setProvinceName(initializeBranchModel.getProvinceName());
    branch.setCityCode(initializeBranchModel.getCityCode());
    branch.setCityName(initializeBranchModel.getCityName());
    branch.setDistrictCode(initializeBranchModel.getDistrictCode());
    branch.setDistrictName(initializeBranchModel.getDistrictName());
    branch.setAddress(initializeBranchModel.getAddress());
    branch.setLongitude(initializeBranchModel.getLongitude());
    branch.setLatitude(initializeBranchModel.getLatitude());
    branch.setLinkman(initializeBranchModel.getLinkman());
    branch.setContactPhone(initializeBranchModel.getContactPhone());
    branch.setElemeAccountType(Constants.ELEME_ACCOUNT_TYPE_CHAIN_ACCOUNT);
    branch.setShopId(null);
    branch.setSmartRestaurantStatus(initializeBranchModel.getSmartRestaurantStatus());
    branch.setAppAuthToken(null);
    branch.setPoiId(null);
    branch.setPoiName(null);
    BigInteger userId = initializeBranchModel.getUserId();
    branch.setCreateUserId(userId);
    branch.setLastUpdateUserId(userId);
    branchMapper.insert(branch);
    branchMapper.insertMergeUserBranch(userId, initializeBranchModel.getTenantId(), branch.getId());
    ApiRest apiRest = new ApiRest();
    apiRest.setData(branch);
    apiRest.setClassName(Branch.class.getName());
    apiRest.setMessage("初始化门店成功!");
    apiRest.setSuccessful(true);
    return apiRest;
}
Also used : Branch(build.dream.common.erp.catering.domains.Branch) BigInteger(java.math.BigInteger) ApiRest(build.dream.common.api.ApiRest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 7 with Branch

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

the class BranchService method obtainBranchInfo.

/**
 * 获取门店信息
 *
 * @param obtainBranchInfoModel
 * @return
 */
@Transactional(readOnly = true)
public ApiRest obtainBranchInfo(ObtainBranchInfoModel obtainBranchInfoModel) {
    BigInteger tenantId = obtainBranchInfoModel.getTenantId();
    BigInteger userId = obtainBranchInfoModel.getUserId();
    Branch branch = branchMapper.findByTenantIdAndUserId(tenantId, userId);
    Validate.notNull(branch, "门店不存在!");
    ApiRest apiRest = new ApiRest();
    apiRest.setData(branch);
    apiRest.setClassName(Branch.class.getName());
    apiRest.setMessage("获取门店信息成功!");
    apiRest.setSuccessful(true);
    return apiRest;
}
Also used : Branch(build.dream.common.erp.catering.domains.Branch) BigInteger(java.math.BigInteger) ApiRest(build.dream.common.api.ApiRest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 8 with Branch

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

the class ElemeController method updateCategory.

@RequestMapping(value = "/updateCategory")
@ResponseBody
public String updateCategory() {
    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());
        params.put("name", goodsCategory.getName());
        params.put("description", goodsCategory.getDescription());
        apiRest = ElemeUtils.callElemeSystem(tenantId, branchId, branch.getElemeAccountType(), "eleme.product.category.updateCategory", params);
    } catch (Exception e) {
        LogUtils.error("更新商品分类失败", controllerSimpleName, "updateCategory", 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 9 with Branch

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

the class ElemeController method getShopCategories.

@RequestMapping(value = "/getShopCategories")
@ResponseBody
public String getShopCategories() {
    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(BigInteger.valueOf(Long.valueOf(tenantId)), BigInteger.valueOf(Long.valueOf(branchId)));
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("shopId", branch.getShopId());
        apiRest = ElemeUtils.callElemeSystem(tenantId.toString(), branchId.toString(), branch.getElemeAccountType(), "eleme.product.category.getShopCategories", params);
    } catch (Exception e) {
        LogUtils.error("查询店铺商品分类失败", controllerSimpleName, "getShopCategories", 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 10 with Branch

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

the class ElemeController method updateCategoryWithChildren.

@RequestMapping(value = "/updateCategoryWithChildren")
@ResponseBody
public String updateCategoryWithChildren() {
    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());
        params.put("name", goodsCategory.getName());
        params.put("parentId", goodsCategory.getParentId());
        params.put("description", goodsCategory.getDescription());
        apiRest = ElemeUtils.callElemeSystem(tenantId, branchId, branch.getElemeAccountType(), "eleme.product.category.updateCategoryWithChildren", params);
    } catch (Exception e) {
        LogUtils.error("更新商品分类失败", controllerSimpleName, "updateCategoryWithChildren", 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