use of build.dream.common.api.ApiRest in project erp-catering by liuyandong33.
the class MeiTuanService method obtainMeiTuanOrder.
/**
* 拉取美团订单
*
* @param obtainMeiTuanOrderModel
* @return
*/
@Transactional(readOnly = true)
public ApiRest obtainMeiTuanOrder(ObtainMeiTuanOrderModel obtainMeiTuanOrderModel) {
SearchModel meiTuanOrderSearchModel = new SearchModel(true);
meiTuanOrderSearchModel.addSearchCondition("tenant_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, obtainMeiTuanOrderModel.getTenantId());
meiTuanOrderSearchModel.addSearchCondition("branch_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, obtainMeiTuanOrderModel.getBranchId());
meiTuanOrderSearchModel.addSearchCondition("id", Constants.SQL_OPERATION_SYMBOL_EQUALS, obtainMeiTuanOrderModel.getMeiTuanOrderId());
MeiTuanOrder meiTuanOrder = meiTuanOrderMapper.find(meiTuanOrderSearchModel);
Validate.notNull(meiTuanOrder, "订单不存在!");
SearchModel meiTuanOrderDetailSearchModel = new SearchModel(true);
meiTuanOrderDetailSearchModel.addSearchCondition("mei_tuan_order_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, meiTuanOrder.getId());
List<MeiTuanOrderDetail> meiTuanOrderDetails = meiTuanOrderDetailMapper.findAll(meiTuanOrderDetailSearchModel);
SearchModel meiTuanOrderExtraSearchModel = new SearchModel(true);
meiTuanOrderExtraSearchModel.addSearchCondition("mei_tuan_order_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, meiTuanOrder.getId());
List<MeiTuanOrderExtra> meiTuanOrderExtras = meiTuanOrderExtraMapper.findAll(meiTuanOrderExtraSearchModel);
SearchModel meiTuanOrderPoiReceiveDetailSearchModel = new SearchModel(true);
meiTuanOrderPoiReceiveDetailSearchModel.addSearchCondition("mei_tuan_order_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, meiTuanOrder.getId());
MeiTuanOrderPoiReceiveDetail meiTuanOrderPoiReceiveDetail = meiTuanOrderPoiReceiveDetailMapper.find(meiTuanOrderPoiReceiveDetailSearchModel);
Map<String, Object> poiReceiveDetail = new HashMap<String, Object>();
if (meiTuanOrderPoiReceiveDetail != null) {
SearchModel actOrderChargeByMtSearchModel = new SearchModel(true);
actOrderChargeByMtSearchModel.addSearchCondition("mei_tuan_order_poi_receive_detail_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, meiTuanOrderPoiReceiveDetail.getId());
List<ActOrderChargeByMt> actOrderChargeByMts = actOrderChargeByMtMapper.findAll(actOrderChargeByMtSearchModel);
SearchModel actOrderChargeByPoiSearchModel = new SearchModel(true);
actOrderChargeByPoiSearchModel.addSearchCondition("mei_tuan_order_poi_receive_detail_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, meiTuanOrderPoiReceiveDetail.getId());
List<ActOrderChargeByPoi> actOrderChargeByPois = actOrderChargeByPoiMapper.findAll(actOrderChargeByPoiSearchModel);
poiReceiveDetail.put("foodShareFeeChargeByPoi", meiTuanOrderPoiReceiveDetail.getFoodShareFeeChargeByPoi());
poiReceiveDetail.put("logisticsFee", meiTuanOrderPoiReceiveDetail.getLogisticsFee());
poiReceiveDetail.put("onlinePayment", meiTuanOrderPoiReceiveDetail.getOnlinePayment());
poiReceiveDetail.put("wmPoiReceiveCent", meiTuanOrderPoiReceiveDetail.getWmPoiReceiveCent());
List<Map<String, Object>> actOrderChargeByMtData = new ArrayList<Map<String, Object>>();
if (CollectionUtils.isNotEmpty(actOrderChargeByMts)) {
for (ActOrderChargeByMt actOrderChargeByMt : actOrderChargeByMts) {
Map<String, Object> actOrderChargeByMtMap = new HashMap<String, Object>();
actOrderChargeByMtMap.put("comment", actOrderChargeByMt.getComment());
actOrderChargeByMtMap.put("feeTypeDesc", actOrderChargeByMt.getFeeTypeDesc());
actOrderChargeByMtMap.put("feeTypeId", actOrderChargeByMt.getFeeTypeId());
actOrderChargeByMtMap.put("moneyCent", actOrderChargeByMt.getMoneyCent());
actOrderChargeByMtData.add(actOrderChargeByMtMap);
}
poiReceiveDetail.put("actOrderChargeByMt", actOrderChargeByMtData);
}
List<Map<String, Object>> actOrderChargeByPoiData = new ArrayList<Map<String, Object>>();
if (CollectionUtils.isNotEmpty(actOrderChargeByPois)) {
for (ActOrderChargeByPoi actOrderChargeByPoi : actOrderChargeByPois) {
Map<String, Object> actOrderChargeByPoiMap = new HashMap<String, Object>();
actOrderChargeByPoiMap.put("comment", actOrderChargeByPoi.getComment());
actOrderChargeByPoiMap.put("feeTypeDesc", actOrderChargeByPoi.getFeeTypeDesc());
actOrderChargeByPoiMap.put("feeTypeId", actOrderChargeByPoi.getFeeTypeId());
actOrderChargeByPoiMap.put("moneyCent", actOrderChargeByPoi.getMoneyCent());
actOrderChargeByPoiData.add(actOrderChargeByPoiMap);
}
poiReceiveDetail.put("actOrderChargeByPoi", actOrderChargeByPoiData);
}
}
Map<String, Object> meiTuanOrderMap = BeanUtils.beanToMap(meiTuanOrder);
meiTuanOrderMap.put("poiReceiveDetail", poiReceiveDetail);
List<Map<String, Object>> detail = new ArrayList<Map<String, Object>>();
for (MeiTuanOrderDetail meiTuanOrderDetail : meiTuanOrderDetails) {
Map<String, Object> meiTuanDetailMap = new HashMap<String, Object>();
meiTuanDetailMap.put("app_food_code", meiTuanOrderDetail.getAppFoodCode());
meiTuanDetailMap.put("box_num", meiTuanOrderDetail.getBoxNum());
meiTuanDetailMap.put("box_price", meiTuanOrderDetail.getBoxPrice());
meiTuanDetailMap.put("food_name", meiTuanOrderDetail.getFoodName());
meiTuanDetailMap.put("price", meiTuanOrderDetail.getPrice());
meiTuanDetailMap.put("sku_id", meiTuanOrderDetail.getSkuId());
meiTuanDetailMap.put("quantity", meiTuanOrderDetail.getQuantity());
meiTuanDetailMap.put("unit", meiTuanOrderDetail.getUnit());
meiTuanDetailMap.put("food_discount", meiTuanOrderDetail.getFoodDiscount());
meiTuanDetailMap.put("food_property", meiTuanOrderDetail.getFoodProperty());
meiTuanDetailMap.put("foodShareFeeChargeByPoi", meiTuanOrderDetail.getFoodShareFeeChargeByPoi());
meiTuanDetailMap.put("cart_id", meiTuanOrderDetail.getCartId());
detail.add(meiTuanDetailMap);
}
meiTuanOrderMap.put("detail", detail);
List<Map<String, Object>> extras = new ArrayList<Map<String, Object>>();
for (MeiTuanOrderExtra meiTuanOrderExtra : meiTuanOrderExtras) {
Map<String, Object> meiTuanOrderExtraMap = new HashMap<String, Object>();
meiTuanOrderExtraMap.put("mt_charge", meiTuanOrderExtra.getMtCharge());
meiTuanOrderExtraMap.put("poi_charge", meiTuanOrderExtra.getPoiCharge());
meiTuanOrderExtraMap.put("reduce_fee", meiTuanOrderExtra.getReduceFee());
meiTuanOrderExtraMap.put("remark", meiTuanOrderExtra.getRemark());
meiTuanOrderExtraMap.put("type", meiTuanOrderExtra.getType());
extras.add(meiTuanOrderExtraMap);
}
meiTuanOrderMap.put("extras", extras);
ApiRest apiRest = new ApiRest();
apiRest.setData(meiTuanOrderMap);
apiRest.setMessage("获取美团订单成功!");
apiRest.setSuccessful(true);
return apiRest;
}
use of build.dream.common.api.ApiRest in project erp-catering by liuyandong33.
the class MeiTuanService method generateBindingStoreLink.
/**
* 生成门店绑定链接
*
* @param generateBindingStoreLinkModel
* @return
* @throws IOException
*/
@Transactional(readOnly = true)
public ApiRest generateBindingStoreLink(GenerateBindingStoreLinkModel generateBindingStoreLinkModel) throws IOException {
BigInteger tenantId = generateBindingStoreLinkModel.getTenantId();
BigInteger branchId = generateBindingStoreLinkModel.getBranchId();
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, "门店不存在!");
String meiTuanErpServiceUrl = ConfigurationUtils.getConfiguration(Constants.MEI_TUAN_ERP_SERVICE_URL);
String meiTuanDeveloperId = ConfigurationUtils.getConfiguration(Constants.MEI_TUAN_DEVELOPER_ID);
String meiTuanSignKey = ConfigurationUtils.getConfiguration(Constants.MEI_TUAN_SIGN_KEY);
StringBuffer bindingStoreLink = new StringBuffer(meiTuanErpServiceUrl);
bindingStoreLink.append(Constants.MEI_TUAN_STORE_MAP_URI);
bindingStoreLink.append("?developerId=").append(meiTuanDeveloperId);
bindingStoreLink.append("&businessId=").append(generateBindingStoreLinkModel.getBusinessId());
bindingStoreLink.append("&ePoiId=").append(tenantId).append("Z").append(branchId);
bindingStoreLink.append("&signKey=").append(meiTuanSignKey);
bindingStoreLink.append("&ePoiName=").append(branch.getName());
bindingStoreLink.append("×tamp=").append(System.currentTimeMillis());
ApiRest apiRest = new ApiRest();
apiRest.setData(bindingStoreLink.toString());
apiRest.setMessage("生成门店绑定链接成功!");
apiRest.setSuccessful(true);
return apiRest;
}
use of build.dream.common.api.ApiRest in project erp-catering by liuyandong33.
the class ActivityService method saveSpecialGoodsActivity.
/**
* 保存特价商品活动
*
* @param saveSpecialGoodsActivityModel
* @return
* @throws ParseException
*/
public ApiRest saveSpecialGoodsActivity(SaveSpecialGoodsActivityModel saveSpecialGoodsActivityModel) throws ParseException {
BigInteger tenantId = saveSpecialGoodsActivityModel.getTenantId();
String tenantCode = saveSpecialGoodsActivityModel.getTenantCode();
BigInteger branchId = saveSpecialGoodsActivityModel.getBranchId();
BigInteger userId = saveSpecialGoodsActivityModel.getUserId();
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(Constants.DEFAULT_DATE_PATTERN);
Date startTime = simpleDateFormat.parse(saveSpecialGoodsActivityModel.getStartTime() + " 00:00:00");
Date endTime = simpleDateFormat.parse(saveSpecialGoodsActivityModel.getEndTime() + " 23:59:59");
Validate.isTrue(endTime.after(startTime), "活动结束时间必须大于开始时间!");
String sql = "SELECT * " + "FROM activity " + "WHERE tenant_id = #{tenantId} " + "AND branch_id = #{branchId} " + "AND deleted = 0 " + "AND type = 3 " + "AND status IN (1, 2) " + "AND ((start_time <= #{startTime} AND end_time >= #{endTime}) OR (start_time >= #{startTime} AND start_time <= #{endTime}) OR (end_time >= #{startTime} AND end_time <= #{endTime})) " + "LIMIT 0, 1";
Map<String, Object> findActivityParameters = new HashMap<String, Object>();
findActivityParameters.put("sql", sql);
findActivityParameters.put("tenantId", tenantId);
findActivityParameters.put("branchId", branchId);
findActivityParameters.put("startTime", startTime);
findActivityParameters.put("endTime", endTime);
Map<String, Object> activityMap = universalMapper.executeUniqueResultQuery(findActivityParameters);
if (MapUtils.isNotEmpty(activityMap)) {
throw new RuntimeException("活动日期与促销活动【" + activityMap.get("name") + "】在时间上冲突!");
}
List<SaveSpecialGoodsActivityModel.SpecialGoodsActivityInfo> specialGoodsActivityInfos = saveSpecialGoodsActivityModel.getSpecialGoodsActivityInfos();
List<BigInteger> goodsIds = new ArrayList<BigInteger>();
List<BigInteger> goodsSpecificationIds = new ArrayList<BigInteger>();
for (SaveSpecialGoodsActivityModel.SpecialGoodsActivityInfo specialGoodsActivityInfo : specialGoodsActivityInfos) {
goodsIds.add(specialGoodsActivityInfo.getGoodsId());
goodsSpecificationIds.add(specialGoodsActivityInfo.getGoodsSpecificationId());
}
// 查询出涉及的所有商品
SearchModel goodsSearchModel = new SearchModel(true);
goodsSearchModel.addSearchCondition("id", Constants.SQL_OPERATION_SYMBOL_IN, goodsIds);
goodsSearchModel.addSearchCondition("tenant_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, tenantId);
goodsSearchModel.addSearchCondition("branch_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, branchId);
List<Goods> goodses = goodsMapper.findAll(goodsSearchModel);
// 封装商品id与商品之间的map
Map<BigInteger, Goods> goodsMap = new HashMap<BigInteger, Goods>();
for (Goods goods : goodses) {
goodsMap.put(goods.getId(), goods);
}
SearchModel canNotOperateReasonSearchModel = new SearchModel();
canNotOperateReasonSearchModel.addSearchCondition("tenant_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, tenantId);
canNotOperateReasonSearchModel.addSearchCondition("branch_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, branchId);
canNotOperateReasonSearchModel.addSearchCondition("table_id", Constants.SQL_OPERATION_SYMBOL_IN, goodsIds);
canNotOperateReasonSearchModel.addSearchCondition("operate_type", Constants.SQL_OPERATION_SYMBOL_EQUALS, 4);
CanNotOperateReason persistenceCanNotOperateReason = canNotOperateReasonMapper.find(canNotOperateReasonSearchModel);
if (persistenceCanNotOperateReason != null) {
Goods goods = goodsMap.get(persistenceCanNotOperateReason.getTableId());
Validate.notNull(goods, "商品不存在!");
throw new RuntimeException(String.format(persistenceCanNotOperateReason.getReason(), goods.getName()));
}
// 查询出涉及的所有商品规格
SearchModel goodsSpecificationSearchModel = new SearchModel(true);
goodsSpecificationSearchModel.addSearchCondition("id", Constants.SQL_OPERATION_SYMBOL_IN, goodsSpecificationIds);
goodsSpecificationSearchModel.addSearchCondition("tenant_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, tenantId);
goodsSpecificationSearchModel.addSearchCondition("branch_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, branchId);
List<GoodsSpecification> goodsSpecifications = goodsSpecificationMapper.findAll(goodsSpecificationSearchModel);
// 封装商品规格id与商品规格之间的map
Map<BigInteger, GoodsSpecification> goodsSpecificationMap = new HashMap<BigInteger, GoodsSpecification>();
for (GoodsSpecification goodsSpecification : goodsSpecifications) {
goodsSpecificationMap.put(goodsSpecification.getId(), goodsSpecification);
}
Activity activity = ActivityUtils.constructActivity(tenantId, tenantCode, branchId, saveSpecialGoodsActivityModel.getName(), 3, startTime, endTime, userId, "保存活动信息!");
activityMapper.insert(activity);
List<SpecialGoodsActivity> specialGoodsActivities = new ArrayList<SpecialGoodsActivity>();
List<CanNotOperateReason> canNotOperateReasons = new ArrayList<CanNotOperateReason>();
for (SaveSpecialGoodsActivityModel.SpecialGoodsActivityInfo specialGoodsActivityInfo : specialGoodsActivityInfos) {
Goods goods = goodsMap.get(specialGoodsActivityInfo.getGoodsId());
Validate.notNull(goods, "商品不存在!");
GoodsSpecification goodsSpecification = goodsSpecificationMap.get(specialGoodsActivityInfo.getGoodsSpecificationId());
Validate.notNull(goodsSpecification, "商品规格不存在!");
SpecialGoodsActivity specialGoodsActivity = new SpecialGoodsActivity();
specialGoodsActivity.setTenantId(tenantId);
specialGoodsActivity.setTenantCode(tenantCode);
specialGoodsActivity.setBranchId(branchId);
specialGoodsActivity.setActivityId(activity.getId());
specialGoodsActivity.setGoodsId(goods.getId());
specialGoodsActivity.setGoodsSpecificationId(goodsSpecification.getId());
int discountType = specialGoodsActivityInfo.getDiscountType();
specialGoodsActivity.setDiscountType(discountType);
if (discountType == 1) {
specialGoodsActivity.setSpecialPrice(specialGoodsActivityInfo.getSpecialPrice());
} else if (discountType == 2) {
specialGoodsActivity.setDiscountRate(specialGoodsActivityInfo.getDiscountRate());
}
specialGoodsActivity.setCreateUserId(userId);
specialGoodsActivity.setLastUpdateUserId(userId);
specialGoodsActivity.setLastUpdateRemark("保存特价商品活动!");
specialGoodsActivities.add(specialGoodsActivity);
String reason = "该商品已参与促销活动【" + activity.getName() + "】,活动期间不可%s!如需更改,请先取消活动!";
CanNotOperateReason canNotOperateReason = CanNotOperateReasonUtils.constructCanNotOperateReason(tenantId, tenantCode, branchId, goods.getId(), "goods", activity.getId(), "activity", 3, reason);
canNotOperateReasons.add(canNotOperateReason);
String usedOtherActivityReason = "商品【%s】已参与促销活动【" + activity.getName() + "】,不可参与其他促销活动!";
CanNotOperateReason canNotUsedOtherActivityReason = CanNotOperateReasonUtils.constructCanNotOperateReason(tenantId, tenantCode, branchId, goods.getId(), "goods", activity.getId(), "activity", 4, usedOtherActivityReason);
canNotOperateReasons.add(canNotUsedOtherActivityReason);
}
specialGoodsActivityMapper.insertAll(specialGoodsActivities);
canNotOperateReasonMapper.insertAll(canNotOperateReasons);
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 AnubisService method order.
/**
* 蜂鸟配送
*
* @param orderModel
* @return
* @throws IOException
*/
@Transactional(rollbackFor = Exception.class)
public ApiRest order(OrderModel orderModel) throws IOException {
BigInteger tenantId = orderModel.getTenantId();
BigInteger branchId = orderModel.getBranchId();
BigInteger userId = orderModel.getUserId();
BigInteger dietOrderId = orderModel.getDietOrderId();
// 查询门店信息
SearchModel branchSearchModel = new SearchModel(true);
branchSearchModel.addSearchCondition("tenant_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, tenantId);
branchSearchModel.addSearchCondition("id", Constants.SQL_OPERATION_SYMBOL_EQUALS, branchId);
Branch branch = branchMapper.find(branchSearchModel);
Validate.notNull(branch, "门店不存在!");
// 查询订单信息
SearchModel dietOrderSearchModel = new SearchModel(true);
dietOrderSearchModel.addSearchCondition("tenant_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, tenantId);
dietOrderSearchModel.addSearchCondition("branch_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, branchId);
dietOrderSearchModel.addSearchCondition("id", Constants.SQL_OPERATION_SYMBOL_EQUALS, dietOrderId);
DietOrder dietOrder = dietOrderMapper.find(dietOrderSearchModel);
Validate.notNull(dietOrder, "订单不存在!");
SearchModel dietOrderGroupSearchModel = new SearchModel(true);
dietOrderGroupSearchModel.addSearchCondition("tenant_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, tenantId);
dietOrderGroupSearchModel.addSearchCondition("branch_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, branchId);
dietOrderGroupSearchModel.addSearchCondition("diet_order_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, dietOrderId);
List<DietOrderGroup> dietOrderGroups = dietOrderGroupMapper.findAll(dietOrderGroupSearchModel);
// 查询出订单详情信息
SearchModel dietOrderDetailSearchModel = new SearchModel(true);
dietOrderDetailSearchModel.addSearchCondition("tenant_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, tenantId);
dietOrderDetailSearchModel.addSearchCondition("branch_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, branchId);
dietOrderDetailSearchModel.addSearchCondition("diet_order_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, dietOrderId);
List<DietOrderDetail> dietOrderDetails = dietOrderDetailMapper.findAll(dietOrderDetailSearchModel);
Map<String, Object> data = new HashMap<String, Object>();
ApplicationHandler.ifNotNullPut(data, "partner_remark", orderModel.getPartnerRemark());
data.put("partner_order_code", dietOrder.getOrderNumber());
String notifyUrl = SystemPartitionUtils.getUrl(ConfigurationUtils.getConfiguration(Constants.PARTITION_CODE), Constants.SERVICE_NAME_CATERING, "anubis", "anubisCallback");
data.put("notify_url", notifyUrl);
data.put("order_type", 1);
data.put("chain_store_code", branch.getTenantCode() + "Z" + branch.getCode());
Map<String, Object> transportInfo = new HashMap<String, Object>();
transportInfo.put("transport_name", branch.getTenantCode() + "Z" + branch.getCode() + "Z" + branch.getName());
transportInfo.put("transport_address", branch.getProvinceName() + branch.getCityName() + branch.getDistrictName() + branch.getAddress());
transportInfo.put("transport_longitude", branch.getLongitude());
transportInfo.put("transport_latitude", branch.getLatitude());
transportInfo.put("position_source", Constants.POSITION_SOURCE_BAIDU_MAP);
transportInfo.put("transport_tel", branch.getContactPhone());
ApplicationHandler.ifNotNullPut(transportInfo, "transport_remark", orderModel.getTransportRemark());
data.put("transport_info", transportInfo);
data.put("order_add_time", dietOrder.getActiveTime().getTime());
data.put("order_total_amount", dietOrder.getTotalAmount());
data.put("order_actual_amount", dietOrder.getPayableAmount());
data.put("order_weight", 1);
data.put("order_remark", dietOrder.getRemark());
boolean invoiced = dietOrder.isInvoiced();
data.put("is_invoiced", invoiced ? 1 : 0);
if (invoiced) {
data.put("invoice", dietOrder.getInvoice());
}
data.put("order_payment_status", 1);
data.put("order_payment_method", 1);
data.put("is_agent_payment", 0);
// 需要代收时客户应付金额
// data.put("require_payment_pay", 10);
data.put("goods_count", dietOrderGroups.size());
data.put("require_receive_time", dietOrder.getDeliverTime().getTime());
Map<String, Object> receiverInfo = new HashMap<String, Object>();
receiverInfo.put("receiver_name", dietOrder.getConsignee());
receiverInfo.put("receiver_primary_phone", dietOrder.getTelephoneNumber());
// 收货人备用联系方式
// receiverInfo.put("receiver_second_phone", dietOrder.getTelephoneNumber());
receiverInfo.put("receiver_address", dietOrder.getDeliveryAddress());
receiverInfo.put("receiver_longitude", dietOrder.getDeliveryLongitude());
receiverInfo.put("receiver_latitude", dietOrder.getDeliveryLatitude());
receiverInfo.put("position_source", Constants.POSITION_SOURCE_BAIDU_MAP);
data.put("receiver_info", receiverInfo);
List<Map<String, Object>> itemInfos = new ArrayList<Map<String, Object>>();
for (DietOrderDetail dietOrderDetail : dietOrderDetails) {
Map<String, Object> itemInfo = new HashMap<String, Object>();
itemInfo.put("item_id", dietOrderDetail.getGoodsId() + "_" + dietOrderDetail.getGoodsSpecificationId());
String itemName = dietOrderDetail.getGoodsName();
if (StringUtils.isNotBlank(dietOrderDetail.getGoodsSpecificationName())) {
itemName = itemName + "_" + dietOrderDetail.getGoodsSpecificationName();
}
itemInfo.put("item_name", itemName);
itemInfo.put("item_quantity", dietOrderDetail.getQuantity());
itemInfo.put("item_price", dietOrderDetail.getTotalAmount());
itemInfo.put("item_actual_price", dietOrderDetail.getPayableAmount());
// 商品尺寸
// itemInfo.put("item_size", 10);
// 商品备注
// itemInfo.put("item_remark", "商品备注");
itemInfo.put("is_need_package", 0);
itemInfo.put("is_agent_purchase", 0);
// 代购进价, 如果需要代购 此项必填
// itemInfo.put("agent_purchase_price", 10);
itemInfos.add(itemInfo);
}
data.put("items_json", itemInfos);
data.put("serial_number", dietOrder.getDaySerialNumber());
String url = ConfigurationUtils.getConfiguration(Constants.ANUBIS_SERVICE_URL) + Constants.ANUBIS_ORDER_URI;
String appId = ConfigurationUtils.getConfiguration(Constants.ANUBIS_APP_ID);
ApiRest apiRest = AnubisUtils.callAnubisSystem(url, appId, data);
return apiRest;
}
use of build.dream.common.api.ApiRest in project erp-catering by liuyandong33.
the class MeiTuanService method handleBindingStoreCallback.
/**
* 处理门店绑定回调
*
* @param callbackParametersJsonObject
* @return
*/
@Transactional(rollbackFor = Exception.class)
public ApiRest handleBindingStoreCallback(JSONObject callbackParametersJsonObject, String uuid, int type) {
String ePoiId = callbackParametersJsonObject.getString("ePoiId");
String appAuthToken = callbackParametersJsonObject.getString("appAuthToken");
String poiId = callbackParametersJsonObject.getString("poiId");
String poiName = callbackParametersJsonObject.getString("poiName");
String[] tenantIdAndBranchIdArray = ePoiId.split("Z");
BigInteger tenantId = NumberUtils.createBigInteger(tenantIdAndBranchIdArray[0]);
BigInteger branchId = NumberUtils.createBigInteger(tenantIdAndBranchIdArray[1]);
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, "门店不存在!");
branch.setAppAuthToken(appAuthToken);
branch.setPoiId(poiId);
branch.setPoiName(poiName);
branchMapper.update(branch);
ApiRest apiRest = new ApiRest();
apiRest.setMessage("美团门店绑定回调处理成功!");
apiRest.setSuccessful(true);
return apiRest;
}
Aggregations