Search in sources :

Example 1 with SearchModel

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, "获取订单配送记录成功!");
}
Also used : SearchModel(build.dream.common.utils.SearchModel) BigInteger(java.math.BigInteger) ApiRest(build.dream.common.api.ApiRest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with SearchModel

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;
}
Also used : JSONObject(net.sf.json.JSONObject) SearchModel(build.dream.common.utils.SearchModel) BigInteger(java.math.BigInteger) ApiRest(build.dream.common.api.ApiRest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 3 with SearchModel

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;
}
Also used : SearchModel(build.dream.common.utils.SearchModel)

Example 4 with SearchModel

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 ? "编辑" : "删除"));
        }
    }
}
Also used : SearchModel(build.dream.common.utils.SearchModel) CanNotDeleteException(build.dream.catering.exceptions.CanNotDeleteException) CanNotOperateReason(build.dream.common.erp.catering.domains.CanNotOperateReason) CanNotEditException(build.dream.catering.exceptions.CanNotEditException) CanNotEditAndDeleteException(build.dream.catering.exceptions.CanNotEditAndDeleteException)

Example 5 with SearchModel

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);
}
Also used : SearchModel(build.dream.common.utils.SearchModel)

Aggregations

SearchModel (build.dream.common.utils.SearchModel)22 ApiRest (build.dream.common.api.ApiRest)19 Transactional (org.springframework.transaction.annotation.Transactional)17 BigInteger (java.math.BigInteger)16 JSONObject (net.sf.json.JSONObject)5 SimpleDateFormat (java.text.SimpleDateFormat)4 ArrayList (java.util.ArrayList)3 Pos (build.dream.common.erp.catering.domains.Pos)2 Vip (build.dream.common.erp.catering.domains.Vip)2 UpdateModel (build.dream.common.utils.UpdateModel)2 HashMap (java.util.HashMap)2 BuyGiveActivityBean (build.dream.catering.beans.BuyGiveActivityBean)1 FullReductionActivityBean (build.dream.catering.beans.FullReductionActivityBean)1 SpecialGoodsActivityBean (build.dream.catering.beans.SpecialGoodsActivityBean)1 ZTreeNode (build.dream.catering.beans.ZTreeNode)1 CanNotDeleteException (build.dream.catering.exceptions.CanNotDeleteException)1 CanNotEditAndDeleteException (build.dream.catering.exceptions.CanNotEditAndDeleteException)1 CanNotEditException (build.dream.catering.exceptions.CanNotEditException)1 SaveBuyGiveActivityModel (build.dream.catering.models.activity.SaveBuyGiveActivityModel)1 SaveSpecialGoodsActivityModel (build.dream.catering.models.activity.SaveSpecialGoodsActivityModel)1