Search in sources :

Example 1 with Pos

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

the class PosService method initPos.

/**
 * 上线POS
 *
 * @param onlinePosModel
 * @return
 */
public ApiRest initPos(OnlinePosModel onlinePosModel) {
    BigInteger tenantId = onlinePosModel.getTenantId();
    BigInteger branchId = onlinePosModel.getBranchId();
    BigInteger userId = onlinePosModel.getUserId();
    String registrationId = onlinePosModel.getRegistrationId();
    String type = onlinePosModel.getType();
    String version = onlinePosModel.getVersion();
    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("user_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, userId);
    Pos pos = posMapper.find(searchModel);
    if (pos == null) {
        pos = new Pos();
        pos.setTenantId(tenantId);
        pos.setTenantCode(onlinePosModel.getTenantCode());
        pos.setBranchId(branchId);
        pos.setBranchCode(onlinePosModel.getBranchCode());
        pos.setUserId(userId);
        pos.setRegistrationId(registrationId);
        pos.setType(type);
        pos.setVersion(version);
        pos.setOnline(true);
        pos.setCreateUserId(userId);
        pos.setLastUpdateUserId(userId);
        pos.setLastUpdateRemark("POS不存在,新增POS并且设置为在线状态!");
        posMapper.insert(pos);
    } else {
        pos.setUserId(userId);
        pos.setRegistrationId(registrationId);
        pos.setType(type);
        pos.setVersion(version);
        pos.setOnline(true);
        pos.setLastUpdateUserId(userId);
        pos.setLastUpdateRemark("POS存在,设置为在线状态!");
        posMapper.update(pos);
    }
    return new ApiRest(pos, "上线POS成功!");
}
Also used : SearchModel(build.dream.common.utils.SearchModel) Pos(build.dream.common.erp.catering.domains.Pos) BigInteger(java.math.BigInteger) ApiRest(build.dream.common.api.ApiRest)

Example 2 with Pos

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

the class PosService method offlinePos.

/**
 * 下线POS
 *
 * @param offlinePosModel
 * @return
 */
@Transactional(rollbackFor = Exception.class)
public ApiRest offlinePos(OfflinePosModel offlinePosModel) {
    BigInteger tenantId = offlinePosModel.getTenantId();
    BigInteger branchId = offlinePosModel.getBranchId();
    BigInteger userId = offlinePosModel.getUserId();
    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("user_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, userId);
    Pos pos = posMapper.find(searchModel);
    Validate.notNull(pos, "POS不存在!");
    pos.setOnline(false);
    posMapper.update(pos);
    return new ApiRest(pos, "下线POS成功!");
}
Also used : SearchModel(build.dream.common.utils.SearchModel) Pos(build.dream.common.erp.catering.domains.Pos) BigInteger(java.math.BigInteger) ApiRest(build.dream.common.api.ApiRest) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

ApiRest (build.dream.common.api.ApiRest)2 Pos (build.dream.common.erp.catering.domains.Pos)2 SearchModel (build.dream.common.utils.SearchModel)2 BigInteger (java.math.BigInteger)2 Transactional (org.springframework.transaction.annotation.Transactional)1