Search in sources :

Example 1 with Branch

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

the class ElemeController method setOrderPackingFee.

/**
 * 设置订单餐盒费
 *
 * @return
 */
@RequestMapping(value = "/setOrderPackingFee")
@ResponseBody
public String setOrderPackingFee() {
    ApiRest apiRest = null;
    Map<String, String> requestParameters = ApplicationHandler.getRequestParameters();
    try {
        SetOrderPackingFeeModel setOrderPackingFeeModel = ApplicationHandler.instantiateObject(SetOrderPackingFeeModel.class, requestParameters);
        setOrderPackingFeeModel.validateAndThrow();
        Branch branch = elemeService.findBranch(setOrderPackingFeeModel.getTenantId(), setOrderPackingFeeModel.getBranchId());
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("shopId", branch.getShopId());
        params.put("status", setOrderPackingFeeModel.getStatus());
        ApplicationHandler.ifNotNullPut(params, "packingFee", setOrderPackingFeeModel.getPackingFee());
        ApiRest callElemeSystemApiRest = ElemeUtils.callElemeSystem(setOrderPackingFeeModel.getTenantId().toString(), setOrderPackingFeeModel.getBranchId().toString(), branch.getElemeAccountType(), "eleme.product.item.setOrderPackingFee", params);
        Validate.isTrue(callElemeSystemApiRest.isSuccessful(), callElemeSystemApiRest.getError());
        apiRest = new ApiRest();
        apiRest.setMessage("设置订单餐盒费成功!");
        apiRest.setSuccessful(true);
    } catch (Exception e) {
        LogUtils.error("设置订单餐盒费失败", controllerSimpleName, "setOrderPackingFee", 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 2 with Branch

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

the class ElemeController method queryItemByPage.

/**
 * 分页获取店铺下的商品
 *
 * @return
 */
@RequestMapping(value = "/queryItemByPage")
@ResponseBody
public String queryItemByPage() {
    ApiRest apiRest = null;
    Map<String, String> requestParameters = ApplicationHandler.getRequestParameters();
    try {
        QueryItemByPageModel queryItemByPageModel = ApplicationHandler.instantiateObject(QueryItemByPageModel.class, requestParameters);
        queryItemByPageModel.validateAndThrow();
        Branch branch = elemeService.findBranch(queryItemByPageModel.getTenantId(), queryItemByPageModel.getBranchId());
        Map<String, Object> queryPage = new HashMap<String, Object>();
        queryPage.put("shopId", branch.getShopId());
        queryPage.put("offset", queryItemByPageModel.getOffset());
        queryPage.put("limit", queryItemByPageModel.getLimit());
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("queryPage", queryPage);
        apiRest = ElemeUtils.callElemeSystem(queryItemByPageModel.getTenantId().toString(), queryItemByPageModel.getBranchId().toString(), branch.getElemeAccountType(), "eleme.product.item.queryItemByPage", params);
    } catch (Exception e) {
        LogUtils.error("分页获取店铺下的商品失败", controllerSimpleName, "queryItemByPage", 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 3 with Branch

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

the class ElemeController method getShopCategoriesWithChildren.

@RequestMapping(value = "/getShopCategoriesWithChildren")
@ResponseBody
public String getShopCategoriesWithChildren() {
    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, branchId, branch.getElemeAccountType(), "eleme.product.category.getShopCategoriesWithChildren", params);
    } catch (Exception e) {
        LogUtils.error("查询店铺商品分类失败", controllerSimpleName, "getShopCategoriesWithChildren", 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 4 with Branch

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

the class ElemeController method createCategoryWithChildren.

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

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

the class BranchService method deleteBranch.

/**
 * 删除门店信息
 *
 * @param deleteBranchModel
 * @return
 * @throws IOException
 */
@Transactional(rollbackFor = Exception.class)
public ApiRest deleteBranch(DeleteBranchModel deleteBranchModel) throws IOException {
    SearchModel searchModel = new SearchModel(true);
    searchModel.addSearchCondition("id", Constants.SQL_OPERATION_SYMBOL_EQUALS, deleteBranchModel.getBranchId());
    searchModel.addSearchCondition("tenant_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, deleteBranchModel.getTenantId());
    Branch branch = branchMapper.find(searchModel);
    Validate.notNull(branch, "门店不存在!");
    branch.setDeleted(true);
    branch.setLastUpdateUserId(deleteBranchModel.getUserId());
    branch.setLastUpdateRemark("删除门店信息!");
    branchMapper.update(branch);
    String findUserIdsSql = "SELECT user_id FROM merge_user_branch WHERE tenant_id = #{tenantId} AND branch_id = #{branchId} AND deleted = 0";
    Map<String, Object> findUserIdsParameters = new HashMap<String, Object>();
    findUserIdsParameters.put("sql", findUserIdsSql);
    findUserIdsParameters.put("tenantId", deleteBranchModel.getTenantId());
    findUserIdsParameters.put("branchId", deleteBranchModel.getBranchId());
    List<Map<String, Object>> results = universalMapper.executeQuery(findUserIdsParameters);
    List<BigInteger> userIds = new ArrayList<BigInteger>();
    for (Map<String, Object> map : results) {
        userIds.add(BigInteger.valueOf(MapUtils.getLongValue(map, "userId")));
    }
    String deleteMergeUserBranchSql = "UPDATE merge_user_branch SET deleted = 1 WHERE tenant_id = #{tenantId} AND branch_id = #{branchId} AND deleted = 0";
    Map<String, Object> deleteMergeUserBranchParameters = new HashMap<String, Object>();
    deleteMergeUserBranchParameters.put("sql", deleteMergeUserBranchSql);
    deleteMergeUserBranchParameters.put("tenantId", deleteBranchModel.getTenantId());
    deleteMergeUserBranchParameters.put("branchId", deleteBranchModel.getBranchId());
    universalMapper.executeUpdate(deleteMergeUserBranchParameters);
    Map<String, String> batchDeleteUserRequestParameters = new HashMap<String, String>();
    batchDeleteUserRequestParameters.put("userIds", StringUtils.join(userIds, ","));
    ApiRest batchDeleteUserApiRest = ProxyUtils.doPostWithRequestParameters(Constants.SERVICE_NAME_PLATFORM, "user", "batchDeleteUser", batchDeleteUserRequestParameters);
    Validate.isTrue(batchDeleteUserApiRest.isSuccessful(), batchDeleteUserApiRest.getError());
    ApiRest apiRest = new ApiRest();
    apiRest.setMessage("删除门店信息成功!");
    apiRest.setSuccessful(true);
    return apiRest;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ApiRest(build.dream.common.api.ApiRest) Branch(build.dream.common.erp.catering.domains.Branch) BigInteger(java.math.BigInteger) HashMap(java.util.HashMap) Map(java.util.Map) Transactional(org.springframework.transaction.annotation.Transactional)

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