use of build.dream.common.utils.SearchModel in project erp-catering by liuyandong33.
the class AnubisService method chainStoreDeliveryQuery.
/**
* 查询配送服务
*
* @param chainStoreDeliveryQueryModel
* @return
* @throws IOException
*/
@Transactional(readOnly = true)
public ApiRest chainStoreDeliveryQuery(ChainStoreDeliveryQueryModel chainStoreDeliveryQueryModel) throws IOException {
BigInteger tenantId = chainStoreDeliveryQueryModel.getTenantId();
BigInteger branchId = chainStoreDeliveryQueryModel.getBranchId();
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, "门店不存在!");
Map<String, Object> data = new HashMap<String, Object>();
data.put("chain_store_code", branch.getTenantCode() + "Z" + branch.getCode());
data.put("position_source", Constants.POSITION_SOURCE_BAIDU_MAP);
data.put("receiver_longitude", chainStoreDeliveryQueryModel.getReceiverLongitude());
data.put("receiver_latitude", chainStoreDeliveryQueryModel.getReceiverLatitude());
String url = ConfigurationUtils.getConfiguration(Constants.ANUBIS_SERVICE_URL) + Constants.ANUBIS_CHAIN_STORE_DELIVERY_QUERY_URI;
String appId = ConfigurationUtils.getConfiguration(Constants.ANUBIS_APP_ID);
ApiRest apiRest = AnubisUtils.callAnubisSystem(url, appId, data);
return apiRest;
}
use of build.dream.common.utils.SearchModel in project erp-catering by liuyandong33.
the class AnubisService method chainStore.
/**
* 添加门店
*
* @param chainStoreModel
* @return
* @throws IOException
*/
@Transactional(rollbackFor = Exception.class)
public ApiRest chainStore(ChainStoreModel chainStoreModel) throws IOException {
BigInteger tenantId = chainStoreModel.getTenantId();
BigInteger branchId = chainStoreModel.getBranchId();
BigInteger userId = chainStoreModel.getUserId();
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, "门店不存在!");
Map<String, Object> data = new HashMap<String, Object>();
data.put("chain_store_code", branch.getTenantCode() + "Z" + branch.getCode());
data.put("chain_store_name", branch.getTenantCode() + "Z" + branch.getCode() + "Z" + branch.getName());
data.put("contact_phone", branch.getContactPhone());
data.put("address", branch.getProvinceName() + branch.getCityName() + branch.getDistrictName() + branch.getAddress());
data.put("position_source", Constants.POSITION_SOURCE_BAIDU_MAP);
data.put("longitude", branch.getLongitude());
data.put("latitude", branch.getLatitude());
data.put("service_code", 1);
String url = ConfigurationUtils.getConfiguration(Constants.ANUBIS_SERVICE_URL) + Constants.ANUBIS_CHAIN_STORE_URI;
String appId = ConfigurationUtils.getConfiguration(Constants.ANUBIS_APP_ID);
ApiRest apiRest = AnubisUtils.callAnubisSystem(url, appId, data);
return apiRest;
}
use of build.dream.common.utils.SearchModel in project erp-catering by liuyandong33.
the class DietOrderService method obtainDietOrderInfo.
/**
* 获取订单明细
*
* @param obtainDietOrderInfoModel
* @return
*/
@Transactional(readOnly = true)
public ApiRest obtainDietOrderInfo(ObtainDietOrderInfoModel obtainDietOrderInfoModel) {
// 查询出订单信息
BigInteger tenantId = obtainDietOrderInfoModel.getTenantId();
BigInteger branchId = obtainDietOrderInfoModel.getBranchId();
BigInteger dietOrderId = obtainDietOrderInfoModel.getDietOrderId();
SearchModel dietOrderSearchModel = new SearchModel(true);
dietOrderSearchModel.addSearchCondition("id", Constants.SQL_OPERATION_SYMBOL_EQUALS, dietOrderId);
dietOrderSearchModel.addSearchCondition("tenant_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, tenantId);
dietOrderSearchModel.addSearchCondition("branch_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, branchId);
DietOrder dietOrder = dietOrderMapper.find(dietOrderSearchModel);
Validate.notNull(dietOrder, "订单不存在!");
// 查询出订单组信息
SearchModel dietOrderGroupSearchModel = new SearchModel(true);
dietOrderGroupSearchModel.addSearchCondition("diet_order_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, dietOrderId);
dietOrderGroupSearchModel.addSearchCondition("tenant_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, tenantId);
dietOrderGroupSearchModel.addSearchCondition("branch_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, branchId);
List<DietOrderGroup> dietOrderGroups = dietOrderGroupMapper.findAll(dietOrderGroupSearchModel);
// 查询出订单详情信息
SearchModel dietOrderDetailSearchModel = new SearchModel(true);
dietOrderDetailSearchModel.addSearchCondition("diet_order_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, dietOrderId);
dietOrderDetailSearchModel.addSearchCondition("tenant_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, tenantId);
dietOrderDetailSearchModel.addSearchCondition("branch_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, branchId);
List<DietOrderDetail> dietOrderDetails = dietOrderDetailMapper.findAll(dietOrderDetailSearchModel);
// 查询出订单口味信息
SearchModel dietOrderDetailGoodsFlavorSearchModel = new SearchModel(true);
dietOrderDetailGoodsFlavorSearchModel.addSearchCondition("diet_order_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, dietOrderId);
dietOrderDetailGoodsFlavorSearchModel.addSearchCondition("tenant_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, tenantId);
dietOrderDetailGoodsFlavorSearchModel.addSearchCondition("branch_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, branchId);
List<DietOrderDetailGoodsFlavor> dietOrderDetailGoodsFlavors = dietOrderDetailGoodsFlavorMapper.findAll(dietOrderDetailGoodsFlavorSearchModel);
SearchModel dietOrderActivitySearchModel = new SearchModel(true);
dietOrderActivitySearchModel.addSearchCondition("diet_order_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, dietOrderId);
dietOrderActivitySearchModel.addSearchCondition("tenant_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, tenantId);
dietOrderActivitySearchModel.addSearchCondition("branch_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, branchId);
List<DietOrderActivity> dietOrderActivities = dietOrderActivityMapper.findAll(dietOrderActivitySearchModel);
// 封装订单分组与订单详情之间的map
Map<BigInteger, List<DietOrderDetail>> dietOrderDetailMap = new HashMap<BigInteger, List<DietOrderDetail>>();
for (DietOrderDetail dietOrderDetail : dietOrderDetails) {
List<DietOrderDetail> dietOrderDetailList = dietOrderDetailMap.get(dietOrderDetail.getDietOrderGroupId());
if (dietOrderDetailList == null) {
dietOrderDetailList = new ArrayList<DietOrderDetail>();
dietOrderDetailMap.put(dietOrderDetail.getDietOrderGroupId(), dietOrderDetailList);
}
dietOrderDetailList.add(dietOrderDetail);
}
// 封装订单详情与订单口味之间的map
Map<BigInteger, List<DietOrderDetailGoodsFlavor>> dietOrderDetailGoodsFlavorMap = new HashMap<BigInteger, List<DietOrderDetailGoodsFlavor>>();
for (DietOrderDetailGoodsFlavor dietOrderDetailGoodsFlavor : dietOrderDetailGoodsFlavors) {
List<DietOrderDetailGoodsFlavor> dietOrderDetailGoodsFlavorList = dietOrderDetailGoodsFlavorMap.get(dietOrderDetailGoodsFlavor.getDietOrderDetailId());
if (dietOrderDetailGoodsFlavorList == null) {
dietOrderDetailGoodsFlavorList = new ArrayList<DietOrderDetailGoodsFlavor>();
dietOrderDetailGoodsFlavorMap.put(dietOrderDetailGoodsFlavor.getDietOrderDetailId(), dietOrderDetailGoodsFlavorList);
}
dietOrderDetailGoodsFlavorList.add(dietOrderDetailGoodsFlavor);
}
ApiRest apiRest = new ApiRest(buildDietOrderInfo(dietOrder, dietOrderGroups, dietOrderDetailMap, dietOrderDetailGoodsFlavorMap, dietOrderActivities), "获取订单信息成功!");
return apiRest;
}
use of build.dream.common.utils.SearchModel in project erp-catering by liuyandong33.
the class GoodsService method listGoodses.
@Transactional(readOnly = true)
public ApiRest listGoodses(ListGoodsesModel listGoodsesModel) {
BigInteger tenantId = listGoodsesModel.getTenantId();
BigInteger branchId = listGoodsesModel.getBranchId();
String queryGoodsInfosSql = "SELECT " + SELECT_GOODS_TABLE_COLUMN_NAMES + ", goods_category.name AS category_name, goods_category.description FROM goods LEFT OUTER JOIN goods_category ON goods_category.id = goods.category_id WHERE goods.tenant_id = #{tenantId} AND goods.branch_id = #{branchId} AND goods.deleted = 0";
Map<String, Object> queryGoodsInfosParameters = new HashMap<String, Object>();
queryGoodsInfosParameters.put("sql", queryGoodsInfosSql);
queryGoodsInfosParameters.put("tenantId", tenantId);
queryGoodsInfosParameters.put("branchId", branchId);
List<Map<String, Object>> goodsInfos = universalMapper.executeQuery(queryGoodsInfosParameters);
if (CollectionUtils.isNotEmpty(goodsInfos)) {
SearchModel goodsSpecificationSearchModel = new SearchModel(true);
goodsSpecificationSearchModel.addSearchCondition("tenant_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, tenantId);
goodsSpecificationSearchModel.addSearchCondition("branch_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, branchId);
List<GoodsSpecification> goodsSpecifications = goodsSpecificationMapper.findAll(goodsSpecificationSearchModel);
Map<BigInteger, List<GoodsSpecification>> goodsSpecificationMap = new HashMap<BigInteger, List<GoodsSpecification>>();
for (GoodsSpecification goodsSpecification : goodsSpecifications) {
List<GoodsSpecification> goodsSpecificationList = goodsSpecificationMap.get(goodsSpecification.getGoodsId());
if (goodsSpecificationList == null) {
goodsSpecificationList = new ArrayList<GoodsSpecification>();
goodsSpecificationMap.put(goodsSpecification.getGoodsId(), goodsSpecificationList);
}
goodsSpecificationList.add(goodsSpecification);
}
SearchModel goodsFlavorGroupSearchModel = new SearchModel(true);
goodsFlavorGroupSearchModel.addSearchCondition("tenant_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, tenantId);
goodsFlavorGroupSearchModel.addSearchCondition("branch_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, branchId);
List<GoodsFlavorGroup> goodsFlavorGroups = goodsFlavorGroupMapper.findAll(goodsFlavorGroupSearchModel);
Map<BigInteger, List<Map<String, Object>>> goodsFlavorGroupMap = new HashMap<BigInteger, List<Map<String, Object>>>();
if (CollectionUtils.isNotEmpty(goodsFlavorGroups)) {
SearchModel goodsFlavorSearchModel = new SearchModel(true);
goodsFlavorSearchModel.addSearchCondition("tenant_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, tenantId);
goodsFlavorSearchModel.addSearchCondition("branch_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, branchId);
List<GoodsFlavor> goodsFlavors = goodsFlavorMapper.findAll(goodsFlavorSearchModel);
Map<BigInteger, List<GoodsFlavor>> goodsFlavorMap = new HashMap<BigInteger, List<GoodsFlavor>>();
for (GoodsFlavor goodsFlavor : goodsFlavors) {
List<GoodsFlavor> goodsFlavorList = goodsFlavorMap.get(goodsFlavor.getGoodsFlavorGroupId());
if (goodsFlavorList == null) {
goodsFlavorList = new ArrayList<GoodsFlavor>();
goodsFlavorMap.put(goodsFlavor.getGoodsFlavorGroupId(), goodsFlavorList);
}
goodsFlavorList.add(goodsFlavor);
}
goodsFlavorGroupMap = buildFlavorGroups(goodsFlavorGroups, goodsFlavorMap);
}
for (Map<String, Object> goodsInfo : goodsInfos) {
BigInteger goodsId = BigInteger.valueOf(MapUtils.getLongValue(goodsInfo, "id"));
goodsInfo.put("goodsSpecifications", buildGoodsSpecificationInfos(goodsSpecificationMap.get(goodsId)));
goodsInfo.put("flavorGroups", goodsFlavorGroupMap.get(goodsId));
}
}
return new ApiRest(goodsInfos, "查询菜品信息成功!");
}
use of build.dream.common.utils.SearchModel in project erp-catering by liuyandong33.
the class GoodsService method deleteGoods.
/**
* 删除商品、商品规格、商品口味组、商品口味
* @param deleteGoodsModel
* @return
*/
@Transactional(rollbackFor = Exception.class)
public ApiRest deleteGoods(DeleteGoodsModel deleteGoodsModel) {
BigInteger tenantId = deleteGoodsModel.getTenantId();
BigInteger branchId = deleteGoodsModel.getBranchId();
BigInteger userId = deleteGoodsModel.getUserId();
BigInteger goodsId = deleteGoodsModel.getGoodsId();
SearchModel searchModel = new SearchModel(true);
searchModel.addSearchCondition("id", Constants.SQL_OPERATION_SYMBOL_EQUALS, goodsId);
searchModel.addSearchCondition("tenant_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, tenantId);
searchModel.addSearchCondition("branch_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, branchId);
Goods goods = goodsMapper.find(searchModel);
Validate.notNull(goods, "商品不存在!");
validateCanNotOperate(tenantId, branchId, "goods", goodsId, 2);
goods.setLastUpdateUserId(userId);
goods.setLastUpdateRemark("删除商品信息!");
goods.setDeleted(true);
goodsMapper.update(goods);
// 删除该商品的所有规格
UpdateModel goodsSpecificationUpdateModel = new UpdateModel(true);
goodsSpecificationUpdateModel.setTableName("goods_specification");
goodsSpecificationUpdateModel.addContentValue("deleted", 1);
goodsSpecificationUpdateModel.addContentValue("last_update_user_id", userId);
goodsSpecificationUpdateModel.addContentValue("last_update_remark", "删除商品规格信息!");
goodsSpecificationUpdateModel.addSearchCondition("goods_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, goodsId);
goodsSpecificationUpdateModel.addSearchCondition("tenant_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, tenantId);
goodsSpecificationUpdateModel.addSearchCondition("branch_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, branchId);
universalMapper.universalUpdate(goodsSpecificationUpdateModel);
// 删除该商品的所有口味组
UpdateModel goodsFlavorGroupUpdateModel = new UpdateModel(true);
goodsFlavorGroupUpdateModel.setTableName("goods_flavor_group");
goodsFlavorGroupUpdateModel.addContentValue("deleted", 1);
goodsFlavorGroupUpdateModel.addContentValue("last_update_user_id", userId);
goodsFlavorGroupUpdateModel.addContentValue("last_update_remark", "删除商品口味组信息!");
goodsFlavorGroupUpdateModel.addSearchCondition("goods_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, goodsId);
goodsFlavorGroupUpdateModel.addSearchCondition("tenant_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, tenantId);
goodsFlavorGroupUpdateModel.addSearchCondition("branch_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, branchId);
universalMapper.universalUpdate(goodsFlavorGroupUpdateModel);
// 删除该商品的所有口味
UpdateModel goodsFlavorUpdateModel = new UpdateModel(true);
goodsFlavorUpdateModel.setTableName("goods_flavor");
goodsFlavorUpdateModel.addContentValue("deleted", 1);
goodsFlavorUpdateModel.addContentValue("last_update_user_id", userId);
goodsFlavorUpdateModel.addContentValue("last_update_remark", "删除商品口味组信息!");
goodsFlavorUpdateModel.addSearchCondition("goods_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, goodsId);
goodsFlavorUpdateModel.addSearchCondition("tenant_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, tenantId);
goodsFlavorUpdateModel.addSearchCondition("branch_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, branchId);
universalMapper.universalUpdate(goodsFlavorUpdateModel);
ApiRest apiRest = new ApiRest();
apiRest.setMessage("删除商品信息成功!");
apiRest.setSuccessful(true);
return apiRest;
}
Aggregations