Search in sources :

Example 96 with ApiRest

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, "发送群消息成功!");
}
Also used : JSONObject(net.sf.json.JSONObject) HashMap(java.util.HashMap) JSONObject(net.sf.json.JSONObject) ApiRest(build.dream.common.api.ApiRest)

Example 97 with ApiRest

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

Example 98 with 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成功!");
}
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 99 with ApiRest

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;
}
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 100 with 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);
    }
}
Also used : HashMap(java.util.HashMap) ApiRest(build.dream.common.api.ApiRest)

Aggregations

ApiRest (build.dream.common.api.ApiRest)187 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)101 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)101 BigInteger (java.math.BigInteger)78 HashMap (java.util.HashMap)68 IOException (java.io.IOException)59 JSONObject (net.sf.json.JSONObject)56 Transactional (org.springframework.transaction.annotation.Transactional)36 SearchModel (build.dream.common.utils.SearchModel)19 Branch (build.dream.common.erp.catering.domains.Branch)14 ArrayList (java.util.ArrayList)8 SimpleDateFormat (java.text.SimpleDateFormat)6 Map (java.util.Map)6 GoodsCategory (build.dream.common.erp.catering.domains.GoodsCategory)5 SaveBuyGiveActivityModel (build.dream.catering.models.activity.SaveBuyGiveActivityModel)2 SaveSpecialGoodsActivityModel (build.dream.catering.models.activity.SaveSpecialGoodsActivityModel)2 SaveDietOrderModel (build.dream.catering.models.dietorder.SaveDietOrderModel)2 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