feat: 集成顺丰开放平台功能,增加商家忘记密码,手机号登录功能
This commit is contained in:
parent
07d4a2cda9
commit
06fb54c65c
@ -457,6 +457,13 @@
|
||||
<artifactId>sdk</artifactId>
|
||||
<version>${kuaidi100-api.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.qiyuesuo.sdk</groupId>
|
||||
<artifactId>SDK</artifactId>
|
||||
<version>2.1.7</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/src/main/resources/maven-repository/SF-CSIM-EXPRESS-SDK-V2.1.7.jar</systemPath>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
|
@ -416,6 +416,7 @@ public enum ResultCode {
|
||||
STORE_DELIVER_GOODS_ADDRESS(50007,"请填写商家发货地址"),
|
||||
FREIGHT_TEMPLATE_NOT_EXIST(50010, "当前模版不存在"),
|
||||
STORE_STATUS_ERROR(50011, "店铺状态异常,无法申请"),
|
||||
STORE_DELIVER_ADDRESS_EXIST(50012,"请填写发货地址"),
|
||||
|
||||
/**
|
||||
* 结算单
|
||||
|
@ -2,9 +2,12 @@ package cn.lili.modules.logistics;
|
||||
|
||||
import cn.lili.modules.logistics.entity.dto.LabelOrderDTO;
|
||||
import cn.lili.modules.logistics.entity.enums.LogisticsEnum;
|
||||
import cn.lili.modules.order.order.entity.vo.OrderDetailVO;
|
||||
import cn.lili.modules.system.entity.dos.Logistics;
|
||||
import cn.lili.modules.system.entity.vo.Traces;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 物流插件接口
|
||||
*
|
||||
@ -48,6 +51,8 @@ public interface LogisticsPlugin {
|
||||
* @param labelOrderDTO 电子面单DTO
|
||||
* @return
|
||||
*/
|
||||
String labelOrder(LabelOrderDTO labelOrderDTO);
|
||||
Map labelOrder(LabelOrderDTO labelOrderDTO);
|
||||
|
||||
String createOrder(OrderDetailVO orderDetailVO);
|
||||
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import cn.lili.common.exception.ServiceException;
|
||||
import cn.lili.modules.logistics.entity.enums.LogisticsEnum;
|
||||
import cn.lili.modules.logistics.plugin.kdniao.KdniaoPlugin;
|
||||
import cn.lili.modules.logistics.plugin.kuaidi100.Kuaidi100Plugin;
|
||||
import cn.lili.modules.logistics.plugin.shunfeng.ShunfengPlugin;
|
||||
import cn.lili.modules.system.entity.dos.Setting;
|
||||
import cn.lili.modules.system.entity.dto.LogisticsSetting;
|
||||
import cn.lili.modules.system.entity.enums.SettingEnum;
|
||||
@ -44,6 +45,8 @@ public class LogisticsPluginFactory {
|
||||
return new KdniaoPlugin(logisticsSetting);
|
||||
case KUAIDI100:
|
||||
return new Kuaidi100Plugin(logisticsSetting);
|
||||
case SHUNFENG:
|
||||
return new ShunfengPlugin(logisticsSetting);
|
||||
default:
|
||||
throw new ServiceException();
|
||||
}
|
||||
|
@ -11,5 +11,5 @@ public enum LogisticsEnum {
|
||||
/**
|
||||
* 快递查询渠道
|
||||
*/
|
||||
KDNIAO, KUAIDI100;
|
||||
KDNIAO, KUAIDI100,SHUNFENG;
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import cn.lili.modules.logistics.entity.dto.LabelOrderDTO;
|
||||
import cn.lili.modules.logistics.entity.enums.LogisticsEnum;
|
||||
import cn.lili.modules.order.order.entity.dos.Order;
|
||||
import cn.lili.modules.order.order.entity.dos.OrderItem;
|
||||
import cn.lili.modules.order.order.entity.vo.OrderDetailVO;
|
||||
import cn.lili.modules.store.entity.dos.StoreLogistics;
|
||||
import cn.lili.modules.store.entity.dto.StoreDeliverGoodsAddressDTO;
|
||||
import cn.lili.modules.system.entity.dos.Logistics;
|
||||
@ -111,8 +112,9 @@ public class KdniaoPlugin implements LogisticsPlugin {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String labelOrder(LabelOrderDTO labelOrderDTO) {
|
||||
public Map<String,Object> labelOrder(LabelOrderDTO labelOrderDTO) {
|
||||
try {
|
||||
Map<String,Object> resultMap = new HashMap();
|
||||
//订单
|
||||
Order order = labelOrderDTO.getOrder();
|
||||
//订单货物
|
||||
@ -198,18 +200,24 @@ public class KdniaoPlugin implements LogisticsPlugin {
|
||||
JSONObject obj = JSONObject.parseObject(result);
|
||||
log.info("电子面单响应:{}", result);
|
||||
if (!"100".equals(obj.getString("ResultCode"))) {
|
||||
return obj.getString("Reason");
|
||||
resultMap.put("Reason",obj.getString("Reason"));
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
JSONObject orderJson = JSONObject.parseObject(obj.getString("Order"));
|
||||
|
||||
return obj.getString("PrintTemplate");
|
||||
resultMap.put("printTemplate",obj.getString("PrintTemplate"));
|
||||
return resultMap;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createOrder(OrderDetailVO orderDetailVO) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* MD5加密
|
||||
|
@ -6,6 +6,7 @@ import cn.lili.modules.logistics.entity.enums.LogisticsEnum;
|
||||
import cn.lili.modules.logistics.plugin.kuaidi100.utils.Kuaidi100SignUtils;
|
||||
import cn.lili.modules.order.order.entity.dos.Order;
|
||||
import cn.lili.modules.order.order.entity.dos.OrderItem;
|
||||
import cn.lili.modules.order.order.entity.vo.OrderDetailVO;
|
||||
import cn.lili.modules.store.entity.dos.StoreLogistics;
|
||||
import cn.lili.modules.store.entity.dto.StoreDeliverGoodsAddressDTO;
|
||||
import cn.lili.modules.system.entity.dos.Logistics;
|
||||
@ -121,7 +122,7 @@ public class Kuaidi100Plugin implements LogisticsPlugin {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String labelOrder(LabelOrderDTO labelOrderDTO) {
|
||||
public Map<String,Object> labelOrder(LabelOrderDTO labelOrderDTO) {
|
||||
try {
|
||||
//订单
|
||||
Order order = labelOrderDTO.getOrder();
|
||||
@ -181,4 +182,10 @@ public class Kuaidi100Plugin implements LogisticsPlugin {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createOrder(OrderDetailVO orderDetailVO) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,243 @@
|
||||
package cn.lili.modules.logistics.plugin.shunfeng;
|
||||
|
||||
import cn.hutool.json.JSONArray;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.exception.ServiceException;
|
||||
import cn.lili.common.utils.SpringContextUtil;
|
||||
import cn.lili.modules.logistics.LogisticsPlugin;
|
||||
import cn.lili.modules.logistics.entity.dto.LabelOrderDTO;
|
||||
import cn.lili.modules.logistics.entity.enums.LogisticsEnum;
|
||||
import cn.lili.modules.order.order.entity.dos.Order;
|
||||
import cn.lili.modules.order.order.entity.dos.OrderItem;
|
||||
import cn.lili.modules.order.order.entity.vo.OrderDetailVO;
|
||||
import cn.lili.modules.store.entity.dto.StoreDeliverGoodsAddressDTO;
|
||||
import cn.lili.modules.store.service.StoreDetailService;
|
||||
import cn.lili.modules.system.entity.dos.Logistics;
|
||||
import cn.lili.modules.system.entity.dto.LogisticsSetting;
|
||||
import cn.lili.modules.system.entity.vo.Traces;
|
||||
import com.sf.csim.express.service.CallExpressServiceTools;
|
||||
import com.sf.csim.express.service.HttpClientUtil;
|
||||
import com.sf.csim.express.service.IServiceCodeStandard;
|
||||
import com.sf.csim.express.service.code.ExpressServiceCodeEnum;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 顺丰插件
|
||||
* @author admin
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class ShunfengPlugin implements LogisticsPlugin {
|
||||
|
||||
/**
|
||||
* ExpressServiceCodeEnum 对应速运类-快递APIs
|
||||
* POSTServiceCodeEnum 对应速运类-驿站APIs
|
||||
* YJTServiceCodeEnum 对应解决方案-医寄通APIs
|
||||
* EPSServiceCodeEnum 对应解决方案-快递管家APIs
|
||||
* 详情见code目录下枚举类,客户可自行修改引用的该类
|
||||
**/
|
||||
private LogisticsSetting logisticsSetting;
|
||||
|
||||
public ShunfengPlugin(){}
|
||||
|
||||
public ShunfengPlugin(LogisticsSetting logisticsSetting) {
|
||||
this.logisticsSetting = logisticsSetting;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LogisticsEnum pluginName() {
|
||||
return LogisticsEnum.SHUNFENG;
|
||||
}
|
||||
|
||||
/**
|
||||
* 文档地址:https://open.sf-express.com/Api/ApiDetails?level3=393&interName=%E4%B8%8B%E8%AE%A2%E5%8D%95%E6%8E%A5%E5%8F%A3-EXP_RECE_CREATE_ORDER
|
||||
*
|
||||
* @param orderDetailVO
|
||||
*/
|
||||
public String createOrder(OrderDetailVO orderDetailVO) {
|
||||
StoreDetailService storeService = SpringContextUtil.getBean(StoreDetailService.class);
|
||||
StoreDeliverGoodsAddressDTO storeDeliverGoodsAddressDTO = storeService.getStoreDeliverGoodsAddressDto(orderDetailVO.getOrder().getStoreId());
|
||||
if(storeDeliverGoodsAddressDTO == null){
|
||||
throw new ServiceException(ResultCode.STORE_DELIVER_ADDRESS_EXIST);
|
||||
}
|
||||
try {
|
||||
Order order = orderDetailVO.getOrder();
|
||||
Map<String, Object> msgDataMap = new HashMap<String, Object>();
|
||||
msgDataMap.put("language", "zh-CN");
|
||||
msgDataMap.put("orderId", order.getSn());
|
||||
//托寄物信息
|
||||
List<Map<String, Object>> cargoDetails = new ArrayList<>();
|
||||
for (OrderItem orderItem : orderDetailVO.getOrderItems()) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("name", orderItem.getGoodsName());
|
||||
cargoDetails.add(map);
|
||||
}
|
||||
msgDataMap.put("cargoDetails", cargoDetails);
|
||||
|
||||
//收寄双方信息
|
||||
List<Map<String, Object>> contactInfoList = new ArrayList<>();
|
||||
Map<String, Object> storeContactInfoMap = new HashMap<>();
|
||||
storeContactInfoMap.put("contactType", 1);
|
||||
storeContactInfoMap.put("contact", storeDeliverGoodsAddressDTO.getSalesConsignorName());
|
||||
storeContactInfoMap.put("mobile", storeDeliverGoodsAddressDTO.getSalesConsignorMobile());
|
||||
//国家或地区2位代码 参照附录
|
||||
storeContactInfoMap.put("country", "CN");
|
||||
//详细地址,若有四级行政区划,如镇/街道等信息可拼接至此字段,格式样例:镇/街道+详细地址。若province/city 字段的值不传,此字段必须包含省市信息,避免影响原寄地代码识别,如:广东省深圳市福田区新洲十一街万基商务大厦10楼;此字段地址必须详细,否则会影响目的地中转识别;
|
||||
storeContactInfoMap.put("address", storeDeliverGoodsAddressDTO.getSalesConsignorAddressPath() + storeDeliverGoodsAddressDTO.getSalesConsignorDetail());
|
||||
contactInfoList.add(storeContactInfoMap);
|
||||
|
||||
Map<String, Object> memberContactInfoMap = new HashMap<>();
|
||||
memberContactInfoMap.put("contactType", 2);
|
||||
memberContactInfoMap.put("contact", order.getConsigneeName());
|
||||
memberContactInfoMap.put("mobile", order.getConsigneeMobile());
|
||||
//国家或地区2位代码 参照附录
|
||||
memberContactInfoMap.put("country", "CN");
|
||||
//详细地址,若有四级行政区划,如镇/街道等信息可拼接至此字段,格式样例:镇/街道+详细地址。若province/city 字段的值不传,此字段必须包含省市信息,避免影响原寄地代码识别,如:广东省深圳市福田区新洲十一街万基商务大厦10楼;此字段地址必须详细,否则会影响目的地中转识别;
|
||||
memberContactInfoMap.put("address", order.getConsigneeAddressPath() + order.getConsigneeDetail());
|
||||
contactInfoList.add(memberContactInfoMap);
|
||||
msgDataMap.put("contactInfoList", contactInfoList);
|
||||
|
||||
msgDataMap.put("expressTypeId", 1);
|
||||
msgDataMap.put("isReturnRoutelabel", 1);
|
||||
|
||||
|
||||
String result = sendPost(ExpressServiceCodeEnum.EXP_RECE_CREATE_ORDER, msgDataMap);
|
||||
JSONObject resultData = JSONUtil.parseObj(result).getJSONObject("apiResultData");
|
||||
if(Boolean.TRUE.toString().equals(resultData.get("success").toString())){
|
||||
return resultData.getJSONObject("msgData").getJSONArray("waybillNoInfoList").getJSONObject(0).get("waybillNo").toString();
|
||||
}
|
||||
throw new ServiceException(resultData.get("errorMsg").toString());
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 文档地址:https://open.sf-express.com/Api/ApiDetails?apiServiceCode=EXP_RECE_SEARCH_ROUTES&category=1&apiClassify=1&interName=%E8%B7%AF%E7%94%B1%E6%9F%A5%E8%AF%A2%E6%8E%A5%E5%8F%A3-EXP_RECE_SEARCH_ROUTES
|
||||
*
|
||||
* @param logistics 物流公司
|
||||
* @param expNo
|
||||
* @param phone
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Traces pollQuery(Logistics logistics, String expNo, String phone) {
|
||||
try {
|
||||
Map<String, Object> msgDataMap = new HashMap<String, Object>();
|
||||
msgDataMap.put("language", "zh-CN");
|
||||
/**
|
||||
* 查询号类别:
|
||||
* 1:根据顺丰运单号查询,trackingNumber将被当作顺丰运单号处理
|
||||
* 2:根据客户订单号查询,trackingNumber将被当作客户订单号处理
|
||||
*/
|
||||
msgDataMap.put("trackingType", 1);
|
||||
List<String> trackingNumber = new ArrayList<>();
|
||||
trackingNumber.add(expNo);
|
||||
msgDataMap.put("trackingNumber", trackingNumber);
|
||||
JSONObject result = JSONUtil.parseObj(sendPost(ExpressServiceCodeEnum.EXP_RECE_SEARCH_ROUTES, msgDataMap));
|
||||
JSONObject resultData = result.getJSONObject("apiResultData");
|
||||
if(Boolean.TRUE.toString().equals(resultData.get("success").toString())){
|
||||
JSONArray routesJson = resultData.getJSONObject("msgData").getJSONArray("routeResps").getJSONObject(0).getJSONArray("routes");
|
||||
List<Map> routes = routesJson.toList(Map.class);
|
||||
return new Traces(logistics.getName(),expNo,routes);
|
||||
}
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Traces pollMapTrack(Logistics logistics, String expNo, String phone, String from, String to) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 文档地址:http://open.sf-express.com/Api/ApiDetails?level3=317&interName=%E4%BA%91%E6%89%93%E5%8D%B0%E9%9D%A2%E5%8D%952.0%E6%8E%A5%E5%8F%A3-COM_RECE_CLOUD_PRINT_WAYBILLS
|
||||
*
|
||||
* @param labelOrderDTO 电子面单DTO
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Map<String,Object> labelOrder(LabelOrderDTO labelOrderDTO) {
|
||||
try {
|
||||
Map<String, Object> msgDataMap = new HashMap<>();
|
||||
//模板编码
|
||||
//关联云打印接口后,点击查看,可在接口详情页获取模板编码,类似:fm_76130_standard_{partnerId}
|
||||
msgDataMap.put("templateCode", logisticsSetting.getTemplateCode());
|
||||
//业务数据
|
||||
Map<String, Object> documents = new HashMap<>();
|
||||
documents.put("masterWaybillNo", labelOrderDTO.getOrder().getLogisticsNo());
|
||||
msgDataMap.put("documents",documents);
|
||||
msgDataMap.put("sync",true);
|
||||
/**
|
||||
* 版本号,传固定值:2.0
|
||||
*/
|
||||
msgDataMap.put("version", "2.0");
|
||||
JSONObject result = JSONUtil.parseObj(sendPost(ExpressServiceCodeEnum.COM_RECE_CLOUD_PRINT_WAYBILLS, msgDataMap));
|
||||
JSONObject resultData = result.getJSONObject("apiResultData");
|
||||
if(Boolean.TRUE.toString().equals(resultData.get("success").toString())){
|
||||
return resultData.getJSONObject("obj").getJSONArray("files").toList(Map.class).get(0);
|
||||
}
|
||||
throw new ServiceException(resultData.getJSONArray("errorMessage").get(0).toString());
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 文档地址:https://open.sf-express.com/Api/ApiDetails?level3=409&interName=%E9%A2%84%E8%AE%A1%E6%B4%BE%E9%80%81%E6%97%B6%E9%97%B4%E6%8E%A5%E5%8F%A3-EXP_RECE_SEARCH_PROMITM
|
||||
*
|
||||
* @param searchNo
|
||||
* @param checkNos
|
||||
*/
|
||||
public String searchPromitm(String searchNo, String checkNos) {
|
||||
try {
|
||||
Map<String, Object> msgDataMap = new HashMap<String, Object>();
|
||||
//顺丰运单号
|
||||
msgDataMap.put("searchNo", searchNo);
|
||||
//校验类型 1,电话号码校验 2,月结卡号校验
|
||||
msgDataMap.put("checkType", 1);
|
||||
//校验值 当校验类型为1时传电话号码 当校验类型为2时传月结卡号
|
||||
List<String> mobileList= new ArrayList<>();
|
||||
mobileList.add(checkNos);
|
||||
msgDataMap.put("checkNos", mobileList);
|
||||
JSONObject result = JSONUtil.parseObj(sendPost(ExpressServiceCodeEnum.EXP_RECE_SEARCH_PROMITM, msgDataMap));
|
||||
JSONObject resultData = result.getJSONObject("apiResultData");
|
||||
if(Boolean.TRUE.toString().equals(resultData.get("success").toString())){
|
||||
return resultData.getJSONObject("msgData").get("promiseTm").toString();
|
||||
}
|
||||
throw new ServiceException(resultData.get("errorMsg").toString());
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private String sendPost(IServiceCodeStandard standardService, Map<String, Object> msgDataMap) throws UnsupportedEncodingException {
|
||||
CallExpressServiceTools tools = CallExpressServiceTools.getInstance();
|
||||
Map<String, String> params = new HashMap<String, String>();
|
||||
String timeStamp = String.valueOf(System.currentTimeMillis());
|
||||
// 顾客编码
|
||||
params.put("partnerID", logisticsSetting.getClientCode());
|
||||
params.put("requestID", UUID.randomUUID().toString().replace("-", ""));
|
||||
// 接口服务码
|
||||
params.put("serviceCode", standardService.getCode());
|
||||
params.put("timestamp", timeStamp);
|
||||
params.put("msgData", JSONUtil.toJsonStr(msgDataMap));
|
||||
|
||||
params.put("msgDigest", tools.getMsgDigest(params.get("msgData"), timeStamp, logisticsSetting.getCheckWord()));
|
||||
String result = HttpClientUtil.post(logisticsSetting.getCallUrl(), params);
|
||||
|
||||
log.info("===调用地址 ===" + logisticsSetting.getCallUrl());
|
||||
log.info("===顾客编码 ===" + logisticsSetting.getClientCode());
|
||||
log.info("===返回结果:" + result);
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
@ -74,6 +74,14 @@ public interface MemberService extends IService<Member> {
|
||||
*/
|
||||
Token usernameStoreLogin(String username, String password);
|
||||
|
||||
/**
|
||||
* 商家登录:用户名、密码登录
|
||||
*
|
||||
* @param mobilePhone 用户名
|
||||
* @return token
|
||||
*/
|
||||
Token mobilePhoneStoreLogin(String mobilePhone);
|
||||
|
||||
/**
|
||||
* 注册:手机号、验证码登录
|
||||
*
|
||||
|
@ -198,6 +198,22 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, Member> impleme
|
||||
throw new ServiceException(ResultCode.USER_PASSWORD_ERROR);
|
||||
}
|
||||
//对店铺状态的判定处理
|
||||
return checkMemberStore(member);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Token mobilePhoneStoreLogin(String mobilePhone) {
|
||||
Member member = this.findMember(mobilePhone);
|
||||
//如果手机号不存在则自动注册用户
|
||||
if (member == null) {
|
||||
throw new ServiceException(ResultCode.USER_NOT_EXIST);
|
||||
}
|
||||
loginBindUser(member);
|
||||
//对店铺状态的判定处理
|
||||
return checkMemberStore(member);
|
||||
}
|
||||
|
||||
private Token checkMemberStore(Member member) {
|
||||
if (Boolean.TRUE.equals(member.getHaveStore())) {
|
||||
Store store = storeService.getById(member.getStoreId());
|
||||
if (!store.getStoreDisable().equals(StoreStatusEnum.OPEN.name())) {
|
||||
@ -206,7 +222,6 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, Member> impleme
|
||||
} else {
|
||||
throw new ServiceException(ResultCode.USER_NOT_EXIST);
|
||||
}
|
||||
|
||||
return storeTokenGenerate.createToken(member, false);
|
||||
}
|
||||
|
||||
|
@ -165,6 +165,14 @@ public interface OrderService extends IService<Order> {
|
||||
*/
|
||||
Order delivery(String orderSn, String invoiceNumber, String logisticsId);
|
||||
|
||||
/**
|
||||
* 订单发货
|
||||
*
|
||||
* @param orderSn 订单编号
|
||||
* @return 订单
|
||||
*/
|
||||
Order shunFengDelivery(String orderSn);
|
||||
|
||||
/**
|
||||
* 获取物流踪迹
|
||||
*
|
||||
|
@ -18,7 +18,9 @@ import cn.lili.common.security.context.UserContext;
|
||||
import cn.lili.common.security.enums.UserEnums;
|
||||
import cn.lili.common.utils.SnowFlake;
|
||||
import cn.lili.modules.goods.entity.dto.GoodsCompleteMessage;
|
||||
import cn.lili.modules.logistics.entity.enums.LogisticsEnum;
|
||||
import cn.lili.modules.member.entity.dto.MemberAddressDTO;
|
||||
import cn.lili.modules.member.service.StoreLogisticsService;
|
||||
import cn.lili.modules.order.cart.entity.dto.TradeDTO;
|
||||
import cn.lili.modules.order.cart.entity.enums.DeliveryMethodEnum;
|
||||
import cn.lili.modules.order.order.aop.OrderLogPoint;
|
||||
@ -44,6 +46,7 @@ import cn.lili.modules.store.entity.dto.StoreDeliverGoodsAddressDTO;
|
||||
import cn.lili.modules.store.service.StoreDetailService;
|
||||
import cn.lili.modules.system.aspect.annotation.SystemLogPoint;
|
||||
import cn.lili.modules.system.entity.dos.Logistics;
|
||||
import cn.lili.modules.system.entity.dto.LogisticsSetting;
|
||||
import cn.lili.modules.system.entity.vo.Traces;
|
||||
import cn.lili.modules.system.service.LogisticsService;
|
||||
import cn.lili.mybatis.util.PageUtil;
|
||||
@ -460,6 +463,15 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
||||
return order;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Order shunFengDelivery(String orderSn) {
|
||||
OrderDetailVO orderDetailVO = this.queryDetail(orderSn);
|
||||
String logisticsNo = logisticsService.sfCreateOrder(orderDetailVO);
|
||||
Logistics logistics = logisticsService.getOne(new LambdaQueryWrapper<Logistics>().eq(Logistics::getCode,"SF"));
|
||||
return delivery(orderSn,logisticsNo,logistics.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Traces getTraces(String orderSn) {
|
||||
//获取订单信息
|
||||
|
@ -1,5 +1,7 @@
|
||||
package cn.lili.modules.system.entity.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import cn.lili.modules.logistics.entity.enums.LogisticsEnum;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
@ -16,6 +18,7 @@ public class LogisticsSetting implements Serializable {
|
||||
|
||||
/**
|
||||
* 快递查询类型
|
||||
* @see LogisticsEnum
|
||||
*/
|
||||
private String type;
|
||||
|
||||
@ -36,4 +39,29 @@ public class LogisticsSetting implements Serializable {
|
||||
* 快递100 Key
|
||||
*/
|
||||
private String kuaidi100Key;
|
||||
|
||||
/**
|
||||
* 顺丰顾客编码
|
||||
*/
|
||||
String clientCode;
|
||||
|
||||
/**
|
||||
* 顺丰校验码
|
||||
*/
|
||||
String checkWord;
|
||||
|
||||
/**
|
||||
* 顺丰请求地址
|
||||
*/
|
||||
String callUrl;
|
||||
|
||||
/**
|
||||
* 顺丰打印模板
|
||||
*/
|
||||
String templateCode;
|
||||
|
||||
/**
|
||||
* 顺丰月结号
|
||||
*/
|
||||
String monthlyCardNo;
|
||||
}
|
||||
|
@ -1,10 +1,13 @@
|
||||
package cn.lili.modules.system.service;
|
||||
|
||||
import cn.lili.modules.order.order.entity.vo.OrderDetailVO;
|
||||
import cn.lili.modules.system.entity.dos.Logistics;
|
||||
import cn.lili.modules.system.entity.dto.LogisticsSetting;
|
||||
import cn.lili.modules.system.entity.vo.Traces;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 物流公司业务层
|
||||
@ -24,10 +27,31 @@ public interface LogisticsService extends IService<Logistics> {
|
||||
*/
|
||||
Traces getLogisticTrack(String logisticsId, String logisticsNo, String phone);
|
||||
|
||||
|
||||
/**
|
||||
* 获取物流信息
|
||||
* @param logisticsId
|
||||
* @param logisticsNo
|
||||
* @param phone
|
||||
* @param from
|
||||
* @param to
|
||||
* @return
|
||||
*/
|
||||
Traces getLogisticMapTrack(String logisticsId, String logisticsNo, String phone, String from, String to);
|
||||
|
||||
String labelOrder(String orderSn, String logisticsId);
|
||||
/**
|
||||
* 打印电子面单
|
||||
* @param orderSn 订单编号
|
||||
* @param logisticsId 物流Id
|
||||
* @return
|
||||
*/
|
||||
Map labelOrder(String orderSn, String logisticsId);
|
||||
|
||||
/**
|
||||
* 顺丰平台下单
|
||||
* @param orderDetailVO 订单信息
|
||||
* @return 顺丰单号
|
||||
*/
|
||||
String sfCreateOrder(OrderDetailVO orderDetailVO);
|
||||
|
||||
/**
|
||||
* 获取已开启的物流公司列表
|
||||
@ -35,4 +59,10 @@ public interface LogisticsService extends IService<Logistics> {
|
||||
* @return 物流公司列表
|
||||
*/
|
||||
List<Logistics> getOpenLogistics();
|
||||
|
||||
/**
|
||||
* 获取物流设置
|
||||
* @return
|
||||
*/
|
||||
LogisticsSetting getLogisticsSetting();
|
||||
}
|
@ -1,25 +1,33 @@
|
||||
package cn.lili.modules.system.serviceimpl;
|
||||
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.enums.SwitchEnum;
|
||||
import cn.lili.common.exception.ServiceException;
|
||||
import cn.lili.common.security.OperationalJudgment;
|
||||
import cn.lili.common.utils.BeanUtil;
|
||||
import cn.lili.modules.logistics.LogisticsPluginFactory;
|
||||
import cn.lili.modules.logistics.entity.dto.LabelOrderDTO;
|
||||
import cn.lili.modules.logistics.entity.enums.LogisticsEnum;
|
||||
import cn.lili.modules.member.service.StoreLogisticsService;
|
||||
import cn.lili.modules.order.order.entity.dos.Order;
|
||||
import cn.lili.modules.order.order.entity.dos.OrderItem;
|
||||
import cn.lili.modules.order.order.entity.enums.DeliverStatusEnum;
|
||||
import cn.lili.modules.order.order.entity.enums.OrderStatusEnum;
|
||||
import cn.lili.modules.order.order.entity.vo.OrderDetailVO;
|
||||
import cn.lili.modules.order.order.service.OrderItemService;
|
||||
import cn.lili.modules.order.order.service.OrderService;
|
||||
import cn.lili.modules.store.entity.dos.StoreLogistics;
|
||||
import cn.lili.modules.store.entity.dto.StoreDeliverGoodsAddressDTO;
|
||||
import cn.lili.modules.store.service.StoreDetailService;
|
||||
import cn.lili.modules.system.entity.dos.Logistics;
|
||||
import cn.lili.modules.system.entity.dos.Setting;
|
||||
import cn.lili.modules.system.entity.dto.LogisticsSetting;
|
||||
import cn.lili.modules.system.entity.enums.SettingEnum;
|
||||
import cn.lili.modules.system.entity.vo.Traces;
|
||||
import cn.lili.modules.system.mapper.LogisticsMapper;
|
||||
import cn.lili.modules.system.service.LogisticsService;
|
||||
import cn.lili.modules.system.service.SettingService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
@ -28,6 +36,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 物流公司业务层实现
|
||||
@ -49,6 +58,9 @@ public class LogisticsServiceImpl extends ServiceImpl<LogisticsMapper, Logistics
|
||||
@Autowired
|
||||
private StoreDetailService storeDetailService;
|
||||
|
||||
@Autowired
|
||||
private SettingService settingService;
|
||||
|
||||
@Override
|
||||
public Traces getLogisticTrack(String logisticsId, String logisticsNo, String phone) {
|
||||
try {
|
||||
@ -72,20 +84,26 @@ public class LogisticsServiceImpl extends ServiceImpl<LogisticsMapper, Logistics
|
||||
}
|
||||
|
||||
@Override
|
||||
public String labelOrder(String orderSn, String logisticsId) {
|
||||
|
||||
public Map labelOrder(String orderSn, String logisticsId) {
|
||||
//获取设置
|
||||
LogisticsSetting logisticsSetting = this.getLogisticsSetting();
|
||||
//获取订单及子订单
|
||||
Order order = OperationalJudgment.judgment(orderService.getBySn(orderSn));
|
||||
if (order.getDeliverStatus().equals(DeliverStatusEnum.UNDELIVERED.name())
|
||||
&& order.getOrderStatus().equals(OrderStatusEnum.UNDELIVERED.name())) {
|
||||
|
||||
if ((LogisticsEnum.SHUNFENG.name().equals(logisticsSetting.getType()) && order.getDeliverStatus().equals(DeliverStatusEnum.DELIVERED.name()) && order.getOrderStatus().equals(OrderStatusEnum.DELIVERED.name()))
|
||||
|| (order.getDeliverStatus().equals(DeliverStatusEnum.UNDELIVERED.name()) && order.getOrderStatus().equals(OrderStatusEnum.UNDELIVERED.name()))) {
|
||||
//订单货物
|
||||
List<OrderItem> orderItems = orderItemService.getByOrderSn(orderSn);
|
||||
//获取对应物流
|
||||
Logistics logistics = this.getById(logisticsId);
|
||||
Logistics logistics;
|
||||
|
||||
if(LogisticsEnum.SHUNFENG.name().equals(logisticsSetting.getType())){
|
||||
logistics = this.getOne(new LambdaQueryWrapper<Logistics>().eq(Logistics::getCode,"SF"));
|
||||
}else{
|
||||
logistics = this.getById(logisticsId);
|
||||
}
|
||||
// 店铺-物流公司设置
|
||||
LambdaQueryWrapper<StoreLogistics> lambdaQueryWrapper = Wrappers.lambdaQuery();
|
||||
lambdaQueryWrapper.eq(StoreLogistics::getLogisticsId, logisticsId);
|
||||
lambdaQueryWrapper.eq(StoreLogistics::getLogisticsId, logistics.getId());
|
||||
lambdaQueryWrapper.eq(StoreLogistics::getStoreId, order.getStoreId());
|
||||
StoreLogistics storeLogistics = storeLogisticsService.getOne(lambdaQueryWrapper);
|
||||
//获取店家信息
|
||||
@ -105,6 +123,12 @@ public class LogisticsServiceImpl extends ServiceImpl<LogisticsMapper, Logistics
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String sfCreateOrder(OrderDetailVO orderDetailVO) {
|
||||
return logisticsPluginFactory.filePlugin().createOrder(orderDetailVO);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<Logistics> getOpenLogistics() {
|
||||
LambdaQueryWrapper<Logistics> queryWrapper = new LambdaQueryWrapper<>();
|
||||
@ -112,4 +136,10 @@ public class LogisticsServiceImpl extends ServiceImpl<LogisticsMapper, Logistics
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LogisticsSetting getLogisticsSetting() {
|
||||
Setting setting = settingService.get(SettingEnum.LOGISTICS_SETTING.name());
|
||||
return JSONUtil.toBean(setting.getSettingValue(), LogisticsSetting.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
Binary file not shown.
@ -120,6 +120,14 @@ public class OrderStoreController {
|
||||
return ResultUtil.data(orderService.delivery(orderSn, logisticsNo, logisticsId));
|
||||
}
|
||||
|
||||
@PreventDuplicateSubmissions
|
||||
@ApiOperation(value = "订单顺丰发货")
|
||||
@ApiImplicitParam(name = "orderSn", value = "订单sn", required = true, dataType = "String", paramType = "path")
|
||||
@PostMapping(value = "/{orderSn}/shunfeng/delivery")
|
||||
public ResultMessage<Object> shunFengDelivery(@NotNull(message = "参数非法") @PathVariable String orderSn) {
|
||||
return ResultUtil.data(orderService.shunFengDelivery(orderSn));
|
||||
}
|
||||
|
||||
@PreventDuplicateSubmissions
|
||||
@ApiOperation(value = "取消订单")
|
||||
@ApiImplicitParams({
|
||||
@ -200,7 +208,7 @@ public class OrderStoreController {
|
||||
@ApiImplicitParam(name = "logisticsId", value = "物流公司", required = true, dataType = "String", paramType = "query")
|
||||
})
|
||||
public ResultMessage<Object> createElectronicsFaceSheet(@NotNull(message = "参数非法") @PathVariable String orderSn,
|
||||
@NotNull(message = "请选择物流公司") String logisticsId) throws Exception {
|
||||
@NotNull(message = "请选择物流公司") String logisticsId) {
|
||||
return ResultUtil.data(logisticsService.labelOrder(orderSn, logisticsId));
|
||||
}
|
||||
}
|
@ -1,13 +1,21 @@
|
||||
package cn.lili.controller.other;
|
||||
|
||||
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.enums.ResultUtil;
|
||||
import cn.lili.common.exception.ServiceException;
|
||||
import cn.lili.common.security.context.UserContext;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.member.service.StoreLogisticsService;
|
||||
import cn.lili.modules.store.entity.dos.StoreLogistics;
|
||||
import cn.lili.modules.store.entity.dto.StoreLogisticsCustomerDTO;
|
||||
import cn.lili.modules.system.entity.dos.Setting;
|
||||
import cn.lili.modules.system.entity.dto.ImSetting;
|
||||
import cn.lili.modules.system.entity.dto.LogisticsSetting;
|
||||
import cn.lili.modules.system.entity.enums.SettingEnum;
|
||||
import cn.lili.modules.system.entity.vo.StoreLogisticsVO;
|
||||
import cn.lili.modules.system.service.SettingService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
@ -36,6 +44,9 @@ public class LogisticsStoreController {
|
||||
@Autowired
|
||||
private StoreLogisticsService storeLogisticsService;
|
||||
|
||||
@Autowired
|
||||
private SettingService settingService;
|
||||
|
||||
@ApiOperation(value = "获取商家物流公司列表,如果已选择则checked有值")
|
||||
@GetMapping
|
||||
public ResultMessage<List<StoreLogisticsVO>> get() {
|
||||
@ -99,4 +110,18 @@ public class LogisticsStoreController {
|
||||
return ResultUtil.data(storeLogisticsService.getStoreLogisticsInfo(logisticsId));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取IM接口前缀")
|
||||
@GetMapping("/setting")
|
||||
public ResultMessage<String> getUrl() {
|
||||
String logisticsType;
|
||||
try {
|
||||
Setting logisticsSettingVal = settingService.get(SettingEnum.LOGISTICS_SETTING.name());
|
||||
LogisticsSetting logisticsSetting = JSONUtil.toBean(logisticsSettingVal.getSettingValue(), LogisticsSetting.class);
|
||||
logisticsType = logisticsSetting.getType();
|
||||
} catch (Exception e) {
|
||||
throw new ServiceException(ResultCode.ORDER_LOGISTICS_ERROR);
|
||||
}
|
||||
return ResultUtil.data(logisticsType);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ import cn.lili.common.security.enums.UserEnums;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.member.entity.dos.Member;
|
||||
import cn.lili.modules.member.service.MemberService;
|
||||
import cn.lili.modules.sms.SmsUtil;
|
||||
import cn.lili.modules.verification.entity.enums.VerificationEnums;
|
||||
import cn.lili.modules.verification.service.VerificationService;
|
||||
import io.swagger.annotations.Api;
|
||||
@ -41,6 +42,9 @@ public class StorePassportController {
|
||||
@Autowired
|
||||
private MemberService memberService;
|
||||
|
||||
@Autowired
|
||||
private SmsUtil smsUtil;
|
||||
|
||||
@Autowired
|
||||
private VerificationService verificationService;
|
||||
|
||||
@ -59,6 +63,22 @@ public class StorePassportController {
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation(value = "短信登录接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "mobile", value = "手机号", required = true, paramType = "query"),
|
||||
@ApiImplicitParam(name = "code", value = "验证码", required = true, paramType = "query")
|
||||
})
|
||||
@PostMapping("/smsLogin")
|
||||
public ResultMessage<Object> smsLogin(@NotNull(message = "手机号为空") @RequestParam String mobile,
|
||||
@NotNull(message = "验证码为空") @RequestParam String code,
|
||||
@RequestHeader String uuid) {
|
||||
if (smsUtil.verifyCode(mobile, VerificationEnums.LOGIN, uuid, code)) {
|
||||
return ResultUtil.data(memberService.mobilePhoneStoreLogin(mobile));
|
||||
} else {
|
||||
throw new ServiceException(ResultCode.VERIFICATION_SMS_CHECKED_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation(value = "注销接口")
|
||||
@PostMapping("/logout")
|
||||
public ResultMessage<Object> logout() {
|
||||
@ -66,6 +86,33 @@ public class StorePassportController {
|
||||
return ResultUtil.success();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "通过短信重置密码")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "mobile", value = "手机号", required = true, paramType = "query"),
|
||||
@ApiImplicitParam(name = "password", value = "是否保存登录", required = true, paramType = "query")
|
||||
})
|
||||
@PostMapping("/resetByMobile")
|
||||
public ResultMessage<Member> resetByMobile(@NotNull(message = "手机号为空") @RequestParam String mobile,
|
||||
@NotNull(message = "验证码为空") @RequestParam String code,
|
||||
@RequestHeader String uuid) {
|
||||
//校验短信验证码是否正确
|
||||
if (smsUtil.verifyCode(mobile, VerificationEnums.FIND_USER, uuid, code)) {
|
||||
//校验是否通过手机号可获取会员,存在则将会员信息存入缓存,有效时间3分钟
|
||||
memberService.findByMobile(uuid, mobile);
|
||||
return ResultUtil.success();
|
||||
} else {
|
||||
throw new ServiceException(ResultCode.VERIFICATION_SMS_CHECKED_ERROR);
|
||||
}
|
||||
}
|
||||
@ApiOperation(value = "修改密码")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "password", value = "密码", required = true, paramType = "query")
|
||||
})
|
||||
@PostMapping("/resetPassword")
|
||||
public ResultMessage<Object> resetByMobile(@NotNull(message = "密码为空") @RequestParam String password, @RequestHeader String uuid) {
|
||||
return ResultUtil.data(memberService.resetByMobile(uuid, password));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "修改密码")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "password", value = "旧密码", required = true, paramType = "query"),
|
||||
@ -86,7 +133,4 @@ public class StorePassportController {
|
||||
public ResultMessage<Object> refreshToken(@NotNull(message = "刷新token不能为空") @PathVariable String refreshToken) {
|
||||
return ResultUtil.data(this.memberService.refreshStoreToken(refreshToken));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user