use of build.dream.common.api.ApiRest 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成功!");
}
use of build.dream.common.api.ApiRest in project erp-catering by liuyandong33.
the class UserService method listUsers.
@Transactional(readOnly = true)
public ApiRest listUsers(Map<String, String> parameters) throws IOException {
String tenantId = parameters.get("tenantId");
Validate.notNull(tenantId, "参数(tenantId)不能为空!");
String branchId = parameters.get("branchId");
Validate.notNull(branchId, "参数(branchId)不能为空!");
PagedSearchModel pagedSearchModel = new PagedSearchModel();
pagedSearchModel.addSearchCondition("tenant_id", "=", BigInteger.valueOf(Long.valueOf(tenantId)));
pagedSearchModel.addSearchCondition("branch_id", "=", BigInteger.valueOf(Long.valueOf(branchId)));
String page = parameters.get("page");
if (StringUtils.isBlank(page)) {
page = "1";
}
String rows = parameters.get("rows");
if (StringUtils.isBlank(rows)) {
rows = "20";
}
pagedSearchModel.setPage(Integer.valueOf(page));
pagedSearchModel.setRows(Integer.valueOf(rows));
List<BigInteger> userIds = branchMapper.findAllUserIds(pagedSearchModel);
Map<String, String> findAllUsersRequestParameters = new HashMap<String, String>();
findAllUsersRequestParameters.put("userIds", StringUtils.join(userIds, ","));
String findAllUsersResult = ProxyUtils.doGetOriginalWithRequestParameters(Constants.SERVICE_NAME_PLATFORM, "user", "findAllUsers", findAllUsersRequestParameters);
ApiRest findAllUsersApiRest = ApiRest.fromJson(findAllUsersResult);
Validate.isTrue(findAllUsersApiRest.isSuccessful(), findAllUsersApiRest.getError());
Map<String, Object> data = new HashMap<String, Object>();
long total = branchMapper.countUsers(pagedSearchModel);
data.put("total", total);
data.put("rows", findAllUsersApiRest.getData());
ApiRest apiRest = new ApiRest(data, "查询员工列表成功!");
return apiRest;
}
use of build.dream.common.api.ApiRest 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, "获取会员信息成功!");
}
use of build.dream.common.api.ApiRest in project erp-catering by liuyandong33.
the class AnubisUtils method callAnubisSystem.
public static ApiRest callAnubisSystem(String url, String appId, Map<String, Object> data) throws IOException {
String accessToken = getAccessToken();
int salt = RandomUtils.nextInt(1000, 9999);
String signature = generateSignature(appId, GsonUtils.toJson(data), salt, accessToken);
Map<String, Object> requestBody = new HashMap<String, Object>();
requestBody.put("app_id", appId);
requestBody.put("data", data);
requestBody.put("salt", salt);
requestBody.put("signature", signature);
Map<String, String> callAnubisSystemRequestParameters = new HashMap<String, String>();
callAnubisSystemRequestParameters.put("url", url);
callAnubisSystemRequestParameters.put("requestBody", GsonUtils.toJson(requestBody));
ApiRest apiRest = ProxyUtils.doPostWithRequestParameters(Constants.SERVICE_NAME_OUT, "anubis", "callAnubisSystem", callAnubisSystemRequestParameters);
return apiRest;
}
use of build.dream.common.api.ApiRest in project erp-catering by liuyandong33.
the class AnubisUtils method obtainAccessToken.
public static Map<String, Object> obtainAccessToken(String url, String appId, String appSecret) throws IOException {
int salt = RandomUtils.nextInt(1000, 9999);
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("app_id=" + appId);
stringBuilder.append("&salt=" + salt);
stringBuilder.append("&secret_key=" + appSecret);
String signature = DigestUtils.md5Hex(URLEncoder.encode(stringBuilder.toString(), Constants.CHARSET_NAME_UTF_8));
Map<String, String> obtainAccessTokenRequestParameters = new HashMap<String, String>();
obtainAccessTokenRequestParameters.put("url", url);
obtainAccessTokenRequestParameters.put("appId", appId);
obtainAccessTokenRequestParameters.put("salt", String.valueOf(salt));
obtainAccessTokenRequestParameters.put("signature", signature);
ApiRest obtainAccessTokenApiRest = ProxyUtils.doGetWithRequestParameters(Constants.SERVICE_NAME_OUT, "anubis", "obtainAccessToken", obtainAccessTokenRequestParameters);
Validate.isTrue(obtainAccessTokenApiRest.isSuccessful(), obtainAccessTokenApiRest.getError());
return (Map<String, Object>) obtainAccessTokenApiRest.getData();
}
Aggregations