use of build.dream.common.api.ApiRest in project erp-catering by liuyandong33.
the class DingtalkUtils method send.
public static ApiRest send(String sender, String chatId, String content) throws IOException {
Map<String, Object> sendRequestBody = new HashMap<String, Object>();
sendRequestBody.put("sender", sender);
sendRequestBody.put("chatId", chatId);
sendRequestBody.put("msgtype", "text");
Map<String, Object> textMap = new HashMap<String, Object>();
textMap.put("content", content);
sendRequestBody.put("text", textMap);
String url = ConfigurationUtils.getConfiguration(Constants.DINGTALK_SERVICE_URL) + Constants.DINGTALK_CHAT_SEND_URI + "?access_token=" + obtainAccessToken();
Map<String, String> doPostRequestParameters = new HashMap<String, String>();
doPostRequestParameters.put("url", url);
doPostRequestParameters.put("requestBody", GsonUtils.toJson(sendRequestBody));
doPostRequestParameters.put("headers", HEADERS);
String result = ProxyUtils.doPostOriginalWithRequestParameters(Constants.SERVICE_NAME_OUT, "proxy", "doPost", doPostRequestParameters);
JSONObject resultJsonObject = JSONObject.fromObject(result);
int errcode = resultJsonObject.getInt("errcode");
Validate.isTrue(errcode == 0, resultJsonObject.optString("errmsg"));
Map<String, Object> data = new HashMap<String, Object>();
data.put("messageId", resultJsonObject.getString("messageId"));
return new ApiRest(data, "发送群消息成功!");
}
use of build.dream.common.api.ApiRest in project erp-catering by liuyandong33.
the class MeiTuanUtils method callMeiTuanSystem.
public static ApiRest callMeiTuanSystem(String tenantId, String branchId, String signKey, Map<String, String> requestParameters, String url, String requestMethod) throws IOException {
putSystemLevelParameter(tenantId, branchId, signKey, requestParameters);
ApiRest apiRest = null;
if (WebUtils.RequestMethod.GET.equals(requestMethod)) {
requestParameters.put("url", url);
apiRest = ProxyUtils.doGetWithRequestParameters(Constants.SERVICE_NAME_OUT, "meiTuan", "callMeiTuanSystem", requestParameters);
} else if (WebUtils.RequestMethod.POST.equals(requestMethod)) {
StringBuffer requestUrl = new StringBuffer(url).append("?");
requestUrl.append("?").append("appAuthToken").append("=").append(requestParameters.remove("appAuthToken"));
requestUrl.append("&").append("charset").append("=").append(requestParameters.remove("charset"));
requestUrl.append("&").append("timestamp").append("=").append(requestParameters.remove("timestamp"));
requestUrl.append("&").append("version").append("=").append(requestParameters.remove("version"));
requestUrl.append("&").append("sign").append("=").append(requestParameters.remove("sign"));
requestParameters.put("url", requestUrl.toString());
apiRest = ProxyUtils.doPostWithRequestParameters(Constants.SERVICE_NAME_OUT, "meiTuan", "callMeiTuanSystem", requestParameters);
}
return apiRest;
}
use of build.dream.common.api.ApiRest 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成功!");
}
use of build.dream.common.api.ApiRest 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;
}
use of build.dream.common.api.ApiRest in project erp-catering by liuyandong33.
the class ElemeConsumerThread method markHandleFailureMessage.
private void markHandleFailureMessage(String uuid) {
try {
Map<String, String> markHandleFailureMessageRequestParameters = new HashMap<String, String>();
markHandleFailureMessageRequestParameters.put("uuid", uuid);
ApiRest saveElemeCallbackMessageApiRest = ProxyUtils.doPostWithRequestParameters(Constants.SERVICE_NAME_PLATFORM, "elemeCallbackMessage", "markHandleFailureMessage", markHandleFailureMessageRequestParameters);
Validate.isTrue(saveElemeCallbackMessageApiRest.isSuccessful(), saveElemeCallbackMessageApiRest.getError());
} catch (Exception e) {
LogUtils.error("标记处理失败消息失败", ELEME_CONSUMER_THREAD_SIMPLE_NAME, "markHandleFailureMessage", e);
}
}
Aggregations