Search in sources :

Example 11 with SearchModel

use of build.dream.common.utils.SearchModel 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 12 with SearchModel

use of build.dream.common.utils.SearchModel in project erp-catering by liuyandong33.

the class VipService method obtainVipInfo.

/**
 * 获取会员信息
 *
 * @param obtainVipInfoModel
 * @return
 */
@Transactional(readOnly = true)
public ApiRest obtainVipInfo(ObtainVipInfoModel obtainVipInfoModel) {
    SearchModel searchModel = new SearchModel(true);
    searchModel.addSearchCondition("tenant_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, obtainVipInfoModel.getTenantId());
    searchModel.addSearchCondition("branch_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, obtainVipInfoModel.getBranchId());
    if (obtainVipInfoModel.getVipId() != null) {
        searchModel.addSearchCondition("id", Constants.SQL_OPERATION_SYMBOL_EQUALS, obtainVipInfoModel.getVipId());
    }
    if (StringUtils.isNotBlank(obtainVipInfoModel.getVipCode())) {
        searchModel.addSearchCondition("vip_code", Constants.SQL_OPERATION_SYMBOL_EQUALS, obtainVipInfoModel.getVipCode());
    }
    if (StringUtils.isNotBlank(obtainVipInfoModel.getPhoneNumber())) {
        searchModel.addSearchCondition("phone_number", Constants.SQL_OPERATION_SYMBOL_EQUALS, obtainVipInfoModel.getPhoneNumber());
    }
    if (StringUtils.isNotBlank(obtainVipInfoModel.getOpenId())) {
        searchModel.addSearchCondition("open_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, obtainVipInfoModel.getOpenId());
    }
    if (StringUtils.isNotBlank(obtainVipInfoModel.getAlipayUserId())) {
        searchModel.addSearchCondition("alipay_user_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, obtainVipInfoModel.getAlipayUserId());
    }
    Vip vip = vipMapper.find(searchModel);
    return new ApiRest(vip, "获取会员信息成功!");
}
Also used : SearchModel(build.dream.common.utils.SearchModel) Vip(build.dream.common.erp.catering.domains.Vip) ApiRest(build.dream.common.api.ApiRest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 13 with SearchModel

use of build.dream.common.utils.SearchModel 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)

Example 14 with SearchModel

use of build.dream.common.utils.SearchModel in project erp-catering by liuyandong33.

the class VipService method saveVipInfo.

/**
 * 保存会员信息
 *
 * @param saveVipInfoModel
 * @return
 */
@Transactional(rollbackFor = Exception.class)
public ApiRest saveVipInfo(SaveVipInfoModel saveVipInfoModel) {
    BigInteger tenantId = saveVipInfoModel.getTenantId();
    BigInteger branchId = saveVipInfoModel.getBranchId();
    BigInteger userId = saveVipInfoModel.getUserId();
    if (saveVipInfoModel.getVipId() != null) {
        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("id", Constants.SQL_OPERATION_SYMBOL_EQUALS, saveVipInfoModel.getVipId());
        Vip vip = vipMapper.find(searchModel);
        Validate.notNull(vip, "会员不存在!");
        if (StringUtils.isNotBlank(saveVipInfoModel.getVipName())) {
            vip.setVipName(saveVipInfoModel.getVipName());
        }
        if (saveVipInfoModel.getBirthday() != null) {
            vip.setBirthday(saveVipInfoModel.getBirthday());
        }
        vip.setOpenId(saveVipInfoModel.getOpenId());
        vip.setMainOpenId(saveVipInfoModel.getMainOpenId());
        vip.setAlipayUserId(saveVipInfoModel.getAlipayUserId());
        vip.setLastUpdateUserId(userId);
        vip.setLastUpdateRemark("修改会员信息!");
        vipMapper.update(vip);
    } else {
        String phoneNumber = saveVipInfoModel.getPhoneNumber();
        SearchModel searchModel = new SearchModel(true);
        searchModel.addSearchCondition("tenant_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, tenantId);
        searchModel.addSearchCondition("phone_number", Constants.SQL_OPERATION_SYMBOL_EQUALS, phoneNumber);
        long count = vipMapper.count(searchModel);
        Validate.isTrue(count == 0, "手机号已存在!");
        Vip vip = new Vip();
        vip.setTenantId(saveVipInfoModel.getTenantId());
        vip.setTenantCode(saveVipInfoModel.getTenantCode());
        vip.setBranchId(saveVipInfoModel.getBranchId());
        String vipCode = new SimpleDateFormat("yyyyMMdd").format(new Date()) + SerialNumberGenerator.nextSerialNumber(8, sequenceMapper.nextValue("vip_number"));
        vip.setVipCode(vipCode);
        vip.setVipName(saveVipInfoModel.getVipName());
        vip.setBirthday(saveVipInfoModel.getBirthday());
        vip.setPhoneNumber(phoneNumber);
        vip.setOpenId(saveVipInfoModel.getOpenId());
        vip.setMainOpenId(saveVipInfoModel.getMainOpenId());
        vip.setAlipayUserId(saveVipInfoModel.getAlipayUserId());
        vip.setLastUpdateUserId(saveVipInfoModel.getUserId());
        vip.setCreateUserId(userId);
        vip.setLastUpdateUserId(userId);
        vip.setLastUpdateRemark("新增会员信息!");
        vipMapper.insert(vip);
    }
    ApiRest apiRest = new ApiRest();
    apiRest.setMessage("保存会员信息成功!");
    apiRest.setSuccessful(true);
    return apiRest;
}
Also used : SearchModel(build.dream.common.utils.SearchModel) BigInteger(java.math.BigInteger) Vip(build.dream.common.erp.catering.domains.Vip) ApiRest(build.dream.common.api.ApiRest) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) Transactional(org.springframework.transaction.annotation.Transactional)

Example 15 with SearchModel

use of build.dream.common.utils.SearchModel in project erp-catering by liuyandong33.

the class AnubisService method chainStoreUpdate.

/**
 * 更新门店信息
 *
 * @param chainStoreUpdateModel
 * @return
 * @throws IOException
 */
@Transactional(rollbackFor = Exception.class)
public ApiRest chainStoreUpdate(ChainStoreUpdateModel chainStoreUpdateModel) throws IOException {
    BigInteger tenantId = chainStoreUpdateModel.getTenantId();
    BigInteger branchId = chainStoreUpdateModel.getBranchId();
    BigInteger userId = chainStoreUpdateModel.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_UPDATE_URI;
    String appId = ConfigurationUtils.getConfiguration(Constants.ANUBIS_APP_ID);
    ApiRest apiRest = AnubisUtils.callAnubisSystem(url, appId, data);
    return apiRest;
}
Also used : SearchModel(build.dream.common.utils.SearchModel) BigInteger(java.math.BigInteger) JSONObject(net.sf.json.JSONObject) ApiRest(build.dream.common.api.ApiRest) Transactional(org.springframework.transaction.annotation.Transactional)

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