|
@@ -1,7 +1,6 @@
|
|
|
package com.hys.app.service.kuaidiniao;
|
|
|
|
|
|
import cn.hutool.core.codec.Base64;
|
|
|
-import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import cn.hutool.crypto.digest.DigestUtil;
|
|
@@ -9,21 +8,21 @@ import cn.hutool.http.HttpUtil;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.hys.app.converter.erp.OrderConverter;
|
|
|
import com.hys.app.framework.context.user.AdminUserContext;
|
|
|
+import com.hys.app.framework.database.BaseQueryParam;
|
|
|
import com.hys.app.framework.exception.ServiceException;
|
|
|
import com.hys.app.framework.util.ScriptUtil;
|
|
|
+import com.hys.app.mapper.erp.KdnMapper;
|
|
|
import com.hys.app.mapper.goods.ProductMapper;
|
|
|
import com.hys.app.model.erp.dos.*;
|
|
|
import com.hys.app.model.erp.enums.OrderTypeEnum;
|
|
|
import com.hys.app.model.erp.enums.SaleOrderSendStatusEnum;
|
|
|
import com.hys.app.model.erp.enums.SaleOrderStatusEnum;
|
|
|
-import com.hys.app.model.erp.enums.SnCodeStatusEnum;
|
|
|
-import com.hys.app.model.erp.vo.OrderSendItemVO;
|
|
|
import com.hys.app.service.erp.ItemSnCodeManager;
|
|
|
import com.hys.app.service.erp.OrderManager;
|
|
|
import com.hys.app.service.erp.OrderSendManager;
|
|
|
-import com.hys.app.service.erp.ProductManager;
|
|
|
import com.hys.app.service.kuaidiniao.entity.*;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
@@ -32,7 +31,7 @@ import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.net.URLEncoder;
|
|
|
-import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
@@ -71,6 +70,9 @@ public class KuaiDiNiaoServiceImpl implements KuaiDiNiaoService {
|
|
|
@Autowired
|
|
|
private ProductMapper productMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private KdnMapper kdnMapper;
|
|
|
+
|
|
|
|
|
|
private static final Logger log = LoggerFactory.getLogger(ScriptUtil.class);
|
|
|
|
|
@@ -94,24 +96,80 @@ public class KuaiDiNiaoServiceImpl implements KuaiDiNiaoService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void createStore(CreateStoreModel createStoreModel) {
|
|
|
+ public void createStore(CreateStoreModel createStoreModel, String constants) {
|
|
|
+ Long modelId = createStoreModel.getId();
|
|
|
+ createStoreModel.setId(null);
|
|
|
+ fillParam(createStoreModel);
|
|
|
try {
|
|
|
String design = URLEncoder.encode(Base64.encode(DigestUtil.md5Hex(JSONUtil.toJsonStr(createStoreModel) + apiKey)), "UTF-8");
|
|
|
System.out.println("创建店铺签名--------------------------------------" + design);
|
|
|
//拼接参数
|
|
|
- String param = "interfaceType=" + KdConstants.createStore + "&customerCode=" + id + "&requestData=" + JSONUtil.toJsonStr(createStoreModel) + "&dataSign=" + design;
|
|
|
+ String param = "interfaceType=" + constants + "&customerCode=" + id + "&requestData=" + JSONUtil.toJsonStr(createStoreModel) + "&dataSign=" + design;
|
|
|
//发请求
|
|
|
String res = HttpUtil.post(url, param);
|
|
|
Map map = JSON.parseObject(res, Map.class);
|
|
|
- if (ObjectUtil.isNotNull(map.get("resultCode")) && !(100 == Integer.valueOf(map.get("resultCode").toString()))) {
|
|
|
+ if (ObjectUtil.isNotNull(map.get("resultCode")) && !(100 == Integer.parseInt(map.get("resultCode").toString()))) {
|
|
|
throw new ServiceException("店铺创建失败" + map.get("reason").toString());
|
|
|
}
|
|
|
+ Map dataMap = JSON.parseObject(JSON.toJSONString(map.get("data")), Map.class);
|
|
|
+ createStoreModel.setKdnStoreCode(dataMap.get("kdnStoreCode").toString());
|
|
|
+ if (ObjectUtil.isNotNull(modelId)){
|
|
|
+ createStoreModel.setId(modelId);
|
|
|
+ kdnMapper.updateById(createStoreModel);
|
|
|
+ }else {
|
|
|
+ kdnMapper.insert(createStoreModel);
|
|
|
+ }
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
throw new ServiceException("店铺创建异常");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Page<CreateStoreModel> getStoreList(BaseQueryParam baseQueryParam) {
|
|
|
+ return kdnMapper.selectPage(new Page<>(baseQueryParam.getPageNo(), baseQueryParam.getPageSize()), new LambdaQueryWrapper<>());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void selectAudit(CreateStoreModel createStoreModel) {
|
|
|
+ Map<String, Object> hashMap = new HashMap<>();
|
|
|
+ hashMap.put("storeCode",createStoreModel.getStoreCode());
|
|
|
+ try {
|
|
|
+ String design = URLEncoder.encode(Base64.encode(DigestUtil.md5Hex(JSONUtil.toJsonStr(hashMap) + apiKey)), "UTF-8");
|
|
|
+ System.out.println("获取门店状态签名--------------------------------------" + design);
|
|
|
+ //拼接参数
|
|
|
+ String param = "interfaceType=" + KdConstants.queryStoreStatus + "&customerCode=" + id + "&requestData=" + JSONUtil.toJsonStr(hashMap) + "&dataSign=" + design;
|
|
|
+ //发请求
|
|
|
+ String res = HttpUtil.post(url, param);
|
|
|
+ Map map = JSON.parseObject(res, Map.class);
|
|
|
+ if (ObjectUtil.isNotNull(map.get("resultCode")) && !(100 == Integer.parseInt(map.get("resultCode").toString()))) {
|
|
|
+ throw new ServiceException("请求状态失败" + map.get("reason").toString());
|
|
|
+ }
|
|
|
+ Map dataMap = JSON.parseObject(JSON.toJSONString(map.get("data")), Map.class);
|
|
|
+ List<Map> storeDetail = JSON.parseArray(dataMap.get("storeDetail").toString(), Map.class);
|
|
|
+ for (Map statusMap : storeDetail) {
|
|
|
+ switch (statusMap.get("intraCode").toString()) {
|
|
|
+ case "SS":
|
|
|
+ createStoreModel.setSsStatus(Integer.parseInt(statusMap.get("storeStatus").toString()));
|
|
|
+ createStoreModel.setSsReason(statusMap.get("operationFailReason").toString());
|
|
|
+ case "DD":
|
|
|
+ createStoreModel.setDdStatus(Integer.parseInt(statusMap.get("storeStatus").toString()));
|
|
|
+ createStoreModel.setDdReason(statusMap.get("operationFailReason").toString());
|
|
|
+ case "FN":
|
|
|
+ createStoreModel.setFnStatus(Integer.parseInt(statusMap.get("storeStatus").toString()));
|
|
|
+ createStoreModel.setFnReason(statusMap.get("operationFailReason").toString());
|
|
|
+ case "MTPS":
|
|
|
+ createStoreModel.setMtStatus(Integer.parseInt(statusMap.get("storeStatus").toString()));
|
|
|
+ createStoreModel.setMtReason(statusMap.get("operationFailReason").toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ kdnMapper.updateById(createStoreModel);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ throw new ServiceException("请求发生异常");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* @param dataJson 业务参数
|
|
@@ -165,6 +223,13 @@ public class KuaiDiNiaoServiceImpl implements KuaiDiNiaoService {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ private void fillParam(CreateStoreModel model) {
|
|
|
+ LongitudeLatitude longitudeLatitudeSender = GaoDeUtil.getLongitudeLatitude(model.getProvinceName() + model.getCityName() + model.getAreaName() + model.getAddress());
|
|
|
+ model.setLongitude(longitudeLatitudeSender.getLongitude());
|
|
|
+ model.setLatitude(longitudeLatitudeSender.getLatitude());
|
|
|
+ //填充送货人的经纬度
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 推送待接单状态 接口指令103,状态码100
|
|
|
* 推送业务员接单状态 接口指令103,状态码201
|