use of build.dream.common.utils.SearchModel in project erp-catering by liuyandong33.
the class AnubisService method obtainDeliveryStates.
/**
* 获取订单配送记录
*
* @param obtainDeliveryStatesModel
* @return
*/
@Transactional(readOnly = true)
public ApiRest obtainDeliveryStates(ObtainDeliveryStatesModel obtainDeliveryStatesModel) {
BigInteger tenantId = obtainDeliveryStatesModel.getTenantId();
BigInteger branchId = obtainDeliveryStatesModel.getBranchId();
BigInteger dietOrderId = obtainDeliveryStatesModel.getDietOrderId();
SearchModel searchModel = new SearchModel(true);
searchModel.addSearchCondition("tenant_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, tenantId);
searchModel.addSearchCondition("branch_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, branchId);
searchModel.addSearchCondition("diet_order_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, dietOrderId);
List<DietOrderDeliveryState> dietOrderDeliveryStates = dietOrderDeliveryStateMapper.findAll(searchModel);
return new ApiRest(dietOrderDeliveryStates, "获取订单配送记录成功!");
}
use of build.dream.common.utils.SearchModel in project erp-catering by liuyandong33.
the class AnubisService method handleAnubisCallback.
/**
* 处理蜂鸟配送系统回调
*
* @param callbackRequestBody
* @return
* @throws UnsupportedEncodingException
*/
@Transactional(rollbackFor = Exception.class)
public ApiRest handleAnubisCallback(String callbackRequestBody) throws IOException {
JSONObject callbackRequestBodyJsonObject = JSONObject.fromObject(callbackRequestBody);
String data = URLDecoder.decode(callbackRequestBodyJsonObject.getString("data"), Constants.CHARSET_NAME_UTF_8);
String appId = ConfigurationUtils.getConfiguration(Constants.ANUBIS_APP_ID);
String signature = callbackRequestBodyJsonObject.getString("signature");
int salt = callbackRequestBodyJsonObject.getInt("salt");
Validate.isTrue(AnubisUtils.verifySignature(appId, data, salt, signature), "签名验证未通过!");
JSONObject dataJsonObject = JSONObject.fromObject(data);
String orderNumber = dataJsonObject.getString("partner_order_code");
SearchModel searchModel = new SearchModel(true);
searchModel.addSearchCondition("order_number", Constants.SQL_OPERATION_SYMBOL_EQUALS, orderNumber);
DietOrder dietOrder = dietOrderMapper.find(searchModel);
Validate.notNull(dietOrder, "订单不存在!");
DietOrderDeliveryState dietOrderDeliveryState = new DietOrderDeliveryState();
dietOrderDeliveryState.setTenantId(dietOrder.getTenantId());
dietOrderDeliveryState.setTenantCode(dietOrder.getTenantCode());
dietOrderDeliveryState.setBranchId(dietOrder.getBranchId());
dietOrderDeliveryState.setDietOrderId(dietOrder.getId());
dietOrderDeliveryState.setDietOrderNumber(orderNumber);
dietOrderDeliveryState.setStatus(dataJsonObject.getInt("order_status"));
dietOrderDeliveryState.setCarrierDriverName(dataJsonObject.optString("carrier_driver_name", null));
dietOrderDeliveryState.setCarrierDriverPhone(dataJsonObject.optString("carrier_driver_phone", null));
dietOrderDeliveryState.setDescription(dataJsonObject.optString("description", null));
dietOrderDeliveryState.setStationName(dataJsonObject.optString("station_name", null));
dietOrderDeliveryState.setStationTel(dataJsonObject.optString("station_tel", null));
int cancelReason = dataJsonObject.optInt("cancel_reason", -1);
dietOrderDeliveryState.setCancelReason(cancelReason == -1 ? null : cancelReason);
dietOrderDeliveryState.setErrorCode(dataJsonObject.optString("error_code", null));
dietOrderDeliveryState.setAddress(dataJsonObject.optString("address", null));
dietOrderDeliveryState.setLongitude(dataJsonObject.optString("longitude", null));
dietOrderDeliveryState.setLatitude(dataJsonObject.optString("latitude", null));
BigInteger userId = BigInteger.ZERO;
dietOrderDeliveryState.setCreateUserId(userId);
dietOrderDeliveryState.setLastUpdateUserId(userId);
long pushTime = dataJsonObject.getLong("push_time");
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(pushTime);
dietOrderDeliveryState.setPushTime(calendar.getTime());
dietOrderDeliveryStateMapper.insert(dietOrderDeliveryState);
ApiRest apiRest = new ApiRest();
apiRest.setMessage("处理成功!");
apiRest.setSuccessful(true);
return apiRest;
}
use of build.dream.common.utils.SearchModel in project erp-catering by liuyandong33.
the class AnubisService method findDietOrder.
/**
* 查询订单信息
*
* @param tenantId
* @param branchId
* @param dietOrderId
* @return
*/
private DietOrder findDietOrder(BigInteger tenantId, BigInteger branchId, BigInteger dietOrderId) {
SearchModel dietOrderSearchModel = new SearchModel(true);
dietOrderSearchModel.addSearchCondition("tenant_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, tenantId);
dietOrderSearchModel.addSearchCondition("branch_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, branchId);
dietOrderSearchModel.addSearchCondition("id", Constants.SQL_OPERATION_SYMBOL_EQUALS, dietOrderId);
DietOrder dietOrder = dietOrderMapper.find(dietOrderSearchModel);
Validate.notNull(dietOrder, "订单不存在!");
return dietOrder;
}
use of build.dream.common.utils.SearchModel in project erp-catering by liuyandong33.
the class BasicService method validateCanNotOperate.
public void validateCanNotOperate(BigInteger tenantId, BigInteger branchId, String tableName, BigInteger tableId, int operateType) {
SearchModel searchModel = new SearchModel();
searchModel.addSearchCondition("tenant_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, tenantId);
searchModel.addSearchCondition("branch_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, branchId);
searchModel.addSearchCondition("table_name", Constants.SQL_OPERATION_SYMBOL_EQUALS, tableName);
searchModel.addSearchCondition("table_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, tableId);
searchModel.addSearchCondition("operate_type", Constants.SQL_OPERATION_SYMBOL_IN, new int[] { operateType, 3 });
CanNotOperateReason canNotOperateReason = canNotOperateReasonMapper.find(searchModel);
if (canNotOperateReason != null) {
int persistenceOperateType = canNotOperateReason.getOperateType();
String reason = canNotOperateReason.getReason();
if (persistenceOperateType == 1) {
throw new CanNotDeleteException(reason);
} else if (persistenceOperateType == 2) {
throw new CanNotEditException(reason);
} else if (persistenceOperateType == 3) {
throw new CanNotEditAndDeleteException(String.format(reason, operateType == 1 ? "编辑" : "删除"));
}
}
}
use of build.dream.common.utils.SearchModel in project erp-catering by liuyandong33.
the class BasicService method deleteCanNotOperateReason.
public void deleteCanNotOperateReason(BigInteger tenantId, BigInteger branchId, String causeTableName, BigInteger causeTableId) {
SearchModel searchModel = new SearchModel();
searchModel.addSearchCondition("tenant_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, tenantId);
searchModel.addSearchCondition("branch_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, branchId);
searchModel.addSearchCondition("cause_table_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, causeTableId);
searchModel.addSearchCondition("cause_table_name", Constants.SQL_OPERATION_SYMBOL_EQUALS, causeTableName);
canNotOperateReasonMapper.delete(searchModel);
}
Aggregations