Merge branch 'master' into Bulbsaur

This commit is contained in:
pikachu1995@126.com 2023-03-08 18:27:39 +08:00
commit 36a3a0a0e1
30 changed files with 659 additions and 191 deletions

View File

@ -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>

View File

@ -414,8 +414,10 @@ public enum ResultCode {
STORE_NOT_OPEN(50004, "该会员未开通店铺"),
STORE_NOT_LOGIN_ERROR(50005, "未登录店铺"),
STORE_CLOSE_ERROR(50006, "店铺关闭,请联系管理员"),
STORE_DELIVER_GOODS_ADDRESS(50007,"请填写商家发货地址"),
FREIGHT_TEMPLATE_NOT_EXIST(50010, "当前模版不存在"),
STORE_STATUS_ERROR(50011, "店铺状态异常,无法申请"),
STORE_DELIVER_ADDRESS_EXIST(50012,"请填写发货地址"),
/**
* 结算单
@ -492,6 +494,12 @@ public enum ResultCode {
WECHAT_ERROR(80307, "微信接口异常"),
APP_VERSION_EXIST(80307, "APP版本已存在"),
/**
* IM
*/
IM_MESSAGE_ADD_ERROR(80400,"IM消息发送错误"),
IM_MESSAGE_EDIT_ERROR(80400,"IM消息更新错误"),
/**
* 其他
*/

View File

@ -427,6 +427,7 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
LambdaUpdateWrapper<Goods> lambdaUpdateWrapper = Wrappers.lambdaUpdate();
lambdaUpdateWrapper.set(Goods::getTemplateId, templateId);
lambdaUpdateWrapper.in(Goods::getId, goodsIds);
cache.multiDel(goodsIds);
return this.update(lambdaUpdateWrapper);
}

View File

@ -2,6 +2,8 @@ package cn.lili.modules.im.entity.dos;
import cn.lili.common.utils.SnowFlake;
import cn.lili.modules.member.entity.dos.Member;
import cn.lili.modules.store.entity.dos.Store;
import cn.lili.mybatis.BaseTenantEntity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
@ -99,4 +101,71 @@ public class ImTalk extends BaseTenantEntity {
this.name1 = name1;
this.name2 = name2;
}
public ImTalk(Member member1,Member member2){
if(Long.parseLong(member1.getId()) > Long.parseLong(member2.getId())){
this.userId1 = member2.getId();
this.userId2 = member1.getId();
this.top1 = false;
this.top2 = false;
this.disable1 = false;
this.disable2 = false;
this.storeFlag1 = false;
this.storeFlag2 = false;
this.setId(SnowFlake.getIdStr());
this.lastTalkTime = new Date();
this.face1 = member2.getFace();
this.face2 = member1.getFace();
this.name1 = member2.getNickName();
this.name2 = member1.getNickName();
}else{
this.userId1 = member1.getId();
this.userId2 = member2.getId();
this.top1 = false;
this.top2 = false;
this.disable1 = false;
this.disable2 = false;
this.storeFlag1 = false;
this.storeFlag2 = false;
this.setId(SnowFlake.getIdStr());
this.lastTalkTime = new Date();
this.face1 = member1.getFace();
this.face2 = member2.getFace();
this.name1 = member1.getNickName();
this.name2 = member2.getNickName();
}
}
public ImTalk(Member member, Store store){
if(Long.parseLong(member.getId()) > Long.parseLong(store.getId())){
this.userId1 = store.getId();
this.userId2 = member.getId();
this.top1 = false;
this.top2 = false;
this.disable1 = false;
this.disable2 = false;
this.storeFlag1 = true;
this.storeFlag2 = false;
this.setId(SnowFlake.getIdStr());
this.lastTalkTime = new Date();
this.face1 = store.getStoreLogo();
this.face2 = member.getFace();
this.name1 = store.getStoreName();
this.name2 = member.getNickName();
}else{
this.userId1 = member.getId();
this.userId2 = store.getId();
this.top1 = false;
this.top2 = false;
this.disable1 = false;
this.disable2 = false;
this.storeFlag1 = false;
this.storeFlag2 = true;
this.setId(SnowFlake.getIdStr());
this.lastTalkTime = new Date();
this.face1 = member.getFace();
this.face2 = store.getStoreLogo();
this.name1 = member.getNickName();
this.name2 = store.getStoreName();
}
}
}

View File

@ -16,29 +16,32 @@ public interface ImMessageService extends IService<ImMessage> {
/**
* 阅读消息
*
* @param talkId
* @param accessToken
* @param talkId 对话Id
* @param accessToken 验证token
*/
void read(String talkId, String accessToken);
/**
* 未读消息列表
*
* @param accessToken
* @param accessToken 验证token
* @return 未读消息列表
*/
List<ImMessage> unReadMessages(String accessToken);
/**
* 历史消息
*
* @param accessToken
* @param to
* @param accessToken 验证token
* @param to 接收人
*
* @return 历史消息列表
*/
List<ImMessage> historyMessage(String accessToken, String to);
/**
* 是否有新消息
* @param accessToken
* @param accessToken 验证token
* @return
*/
Boolean hasNewMessage(String accessToken);
@ -52,7 +55,7 @@ public interface ImMessageService extends IService<ImMessage> {
/**
* 获取所有未读消息
* @return
* @return 未读数量
*/
Long unreadMessageCount();

View File

@ -17,10 +17,9 @@ public interface ImTalkService extends IService<ImTalk> {
* 获取与某人的聊天框
*
* @param userId1
* @param userId2
* @return
*/
ImTalk getTalkByUser(String userId1, String userId2);
ImTalk getTalkByUser(String userId1);
/**
* 置顶消息
@ -41,7 +40,7 @@ public interface ImTalkService extends IService<ImTalk> {
* 获取用户聊天列表
* @return
*/
List<ImTalkVO> getUserTalkList(String userName);
List<ImTalkVO> getUserTalkList();
/**
* 获取商家聊天列表

View File

@ -4,6 +4,7 @@ import cn.lili.common.enums.ResultCode;
import cn.lili.common.exception.ServiceException;
import cn.lili.common.security.AuthUser;
import cn.lili.common.security.context.UserContext;
import cn.lili.common.security.enums.UserEnums;
import cn.lili.modules.im.entity.dos.ImMessage;
import cn.lili.modules.im.entity.dto.MessageQueryParams;
import cn.lili.modules.im.mapper.ImMessageMapper;
@ -18,9 +19,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Objects;
/**
* Im消息 业务实现
@ -130,9 +131,18 @@ public class ImMessageServiceImpl extends ServiceImpl<ImMessageMapper, ImMessage
* @param messageList 消息列表
*/
private void readMessage(List<ImMessage> messageList) {
if (messageList.size() > 0) {
if (!messageList.isEmpty()) {
//判断用户类型
AuthUser authUser = Objects.requireNonNull(UserContext.getCurrentUser());
String toUserId = "";
if(UserEnums.MEMBER.equals(authUser.getRole())){
toUserId = authUser.getId();
}else if(UserEnums.STORE.equals(authUser.getRole())){
toUserId = authUser.getStoreId();
}
//发送给自己的未读信息进行已读操作
for (ImMessage imMessage : messageList) {
if(Boolean.FALSE.equals(imMessage.getIsRead())){
if(Boolean.FALSE.equals(imMessage.getIsRead()) && imMessage.getToUser().equals(toUserId)){
imMessage.setIsRead(true);
}
}

View File

@ -21,9 +21,9 @@ import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.stringtemplate.v4.ST;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
@ -45,47 +45,44 @@ public class ImTalkServiceImpl extends ServiceImpl<ImTalkMapper, ImTalk> impleme
@Autowired
private ImMessageService imMessageService;
@Override
public ImTalk getTalkByUser(String userId1, String userId2) {
public ImTalk getTalkByUser(String userId) {
LambdaQueryWrapper<ImTalk> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(ImTalk::getUserId2, userId2);
queryWrapper.eq(ImTalk::getUserId1, userId1);
AuthUser currentUser = Objects.requireNonNull(UserContext.getCurrentUser());
//登录用户的Id
String selfId = "";
//查看当前用户角色对Id进行赋值
if(UserEnums.STORE.equals(currentUser.getRole())){
selfId = currentUser.getStoreId();
}else if(UserEnums.MEMBER.equals(currentUser.getRole())){
selfId = currentUser.getId();
}
//小数在前保证永远是同一个对话
String finalSelfId = selfId;
queryWrapper.and(wq-> wq.eq(ImTalk::getUserId2, userId).eq(ImTalk::getUserId1, finalSelfId).or().eq(ImTalk::getUserId2, finalSelfId).eq(ImTalk::getUserId1, userId));
ImTalk imTalk = this.getOne(queryWrapper);
AuthUser currentUser = UserContext.getCurrentUser();
//如果没有聊天则创建聊天
if (imTalk == null) {
// 没有登录的这个账户信息
if (currentUser == null) {
return null;
}
//当自己为店铺时
if(UserEnums.STORE.equals(currentUser.getRole())){
Store selfStore = storeService.getById(userId1);
Store selfStore = storeService.getById(selfId);
//没有这个用户信息
Member other = memberService.getById(userId2);
Member other = memberService.getById(userId);
if(other == null){
return null;
}
//自己为店铺其他人必定为用户
imTalk = new ImTalk(userId1, userId2, selfStore.getStoreLogo(), other.getFace(), selfStore.getStoreName(), other.getNickName());
imTalk.setStoreFlag1(true);
imTalk = new ImTalk(other,selfStore);
}else if(UserEnums.MEMBER.equals(currentUser.getRole())){
//没有这个店铺信息
Member self = memberService.getById(userId1);
Member otherMember = memberService.getById(userId2);
Store otherStore = storeService.getById(userId2);
if(otherStore != null){
imTalk = new ImTalk(userId1, userId2, self.getFace(), otherStore.getStoreLogo(), self.getNickName(), otherStore.getStoreName());
imTalk.setStoreFlag2(true);
}else if (otherMember != null){
imTalk = new ImTalk(userId1, userId2, self.getFace(), otherMember.getFace(), self.getNickName(), otherMember.getNickName());
}else{
return null;
}
Member self = memberService.getById(selfId);
Member otherMember = memberService.getById(userId);
Store otherStore = storeService.getById(userId);
if(otherStore != null){
imTalk = new ImTalk(self, otherStore);
}else if (otherMember != null){
imTalk = new ImTalk(self, otherMember);
}
}
this.save(imTalk);
} else {
imTalk = check(imTalk);
}
return imTalk;
}
@ -93,7 +90,7 @@ public class ImTalkServiceImpl extends ServiceImpl<ImTalkMapper, ImTalk> impleme
/**
* 发起聊天后如果聊天不可见为true则需要修正
*
* @param imTalk
* @param imTalk 对话信息
*/
private ImTalk check(ImTalk imTalk) {
if (imTalk.getDisable1() || imTalk.getDisable2()) {
@ -131,23 +128,16 @@ public class ImTalkServiceImpl extends ServiceImpl<ImTalkMapper, ImTalk> impleme
}
@Override
public List<ImTalkVO> getUserTalkList(String userName) {
public List<ImTalkVO> getUserTalkList() {
AuthUser authUser = UserContext.getCurrentUser();
if(authUser == null){
throw new ServiceException(ResultCode.USER_NOT_LOGIN);
}
LambdaQueryWrapper<ImTalk> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.and(wq->{
wq.like(ImTalk::getName1, userName).or().like(ImTalk::getName2,userName);
});
queryWrapper.and(wq->{
wq.like(ImTalk::getUserId1, authUser.getId()).or().like(ImTalk::getUserId2,authUser.getId());
});
queryWrapper.and(wq-> wq.eq(ImTalk::getUserId1, authUser.getId()).or().eq(ImTalk::getUserId2,authUser.getId()));
queryWrapper.orderByDesc(ImTalk::getLastTalkTime);
List<ImTalk> imTalks = this.list(queryWrapper);
List<ImTalkVO> imTalkVOList = imTalks.stream().map(imTalk -> {
return new ImTalkVO(imTalk, authUser.getId());
}).collect(Collectors.toList());
List<ImTalkVO> imTalkVOList = imTalks.stream().map(imTalk -> new ImTalkVO(imTalk, authUser.getId())).collect(Collectors.toList());
getUnread(imTalkVOList);
return imTalkVOList;
}
@ -160,7 +150,7 @@ public class ImTalkServiceImpl extends ServiceImpl<ImTalkMapper, ImTalk> impleme
}
LambdaQueryWrapper<ImTalk> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.and(wq->{
wq.like(ImTalk::getUserId1, authUser.getStoreId()).or().like(ImTalk::getUserId2,authUser.getStoreId());
wq.eq(ImTalk::getUserId1, authUser.getStoreId()).or().eq(ImTalk::getUserId2,authUser.getStoreId());
});
queryWrapper.orderByDesc(ImTalk::getLastTalkTime);
List<ImTalk> imTalks = this.list(queryWrapper);
@ -174,12 +164,12 @@ public class ImTalkServiceImpl extends ServiceImpl<ImTalkMapper, ImTalk> impleme
/**
* 获取未读消息数量
* @param imTalkVOList
* @param imTalkVOList 消息列表
*/
private void getUnread(List<ImTalkVO> imTalkVOList){
if(imTalkVOList.size() > 0){
if(!imTalkVOList.isEmpty()){
for (ImTalkVO imTalkVO : imTalkVOList) {
long count = imMessageService.count(new LambdaQueryWrapper<ImMessage>().eq(ImMessage::getFromUser, imTalkVO.getUserId()).eq(ImMessage::getIsRead, false));
long count = imMessageService.count(new LambdaQueryWrapper<ImMessage>().eq(ImMessage::getFromUser, imTalkVO.getUserId()).eq(ImMessage::getTalkId,imTalkVO.getId()).eq(ImMessage::getIsRead, false));
imTalkVO.setUnread(count);
}
}

View File

@ -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);
}

View File

@ -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();
}

View File

@ -11,5 +11,5 @@ public enum LogisticsEnum {
/**
* 快递查询渠道
*/
KDNIAO, KUAIDI100;
KDNIAO, KUAIDI100,SHUNFENG;
}

View File

@ -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加密

View File

@ -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;
}
}

View File

@ -0,0 +1,242 @@
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
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;
}
}

View File

@ -75,6 +75,14 @@ public interface MemberService extends IService<Member> {
*/
Token usernameStoreLogin(String username, String password);
/**
* 商家登录用户名密码登录
*
* @param mobilePhone 用户名
* @return token
*/
Token mobilePhoneStoreLogin(String mobilePhone);
/**
* 注册手机号验证码登录
*

View File

@ -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);
}

View File

@ -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);
/**
* 获取物流踪迹
*

View File

@ -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) {
//获取订单信息

View File

@ -12,6 +12,7 @@ import cn.lili.common.utils.CommonUtil;
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.sms.plugin.SmsPluginFactory;
import cn.lili.modules.system.entity.dos.Setting;
import cn.lili.modules.system.entity.dto.SmsSetting;
import cn.lili.modules.system.entity.enums.SettingEnum;
@ -44,6 +45,8 @@ public class SmsUtilAliImplService implements SmsUtil {
private SettingService settingService;
@Autowired
private MemberService memberService;
@Autowired
private SmsPluginFactory smsPluginFactory;
@Autowired
private SmsTemplateProperties smsTemplateProperties;
@ -118,7 +121,7 @@ public class SmsUtilAliImplService implements SmsUtil {
} else {
log.info("接收手机:{},验证码:{}", mobile, code);
//发送短信
this.sendSmsCode(smsSetting.getSignName(), mobile, params, templateCode);
smsPluginFactory.smsPlugin().sendSmsCode(smsSetting.getSignName(), mobile, params, templateCode);
}
//缓存中写入要验证的信息
cache.put(cacheKey(verificationEnums, mobile, uuid), code, 300L);
@ -139,13 +142,9 @@ public class SmsUtilAliImplService implements SmsUtil {
@Override
public void sendBatchSms(String signName, List<String> mobile, String templateCode) {
smsPluginFactory.smsPlugin().sendBatchSms(signName, mobile, templateCode);
}
private void sendSmsCode(String signName, String mobile, Map<String, String> param, String templateCode) {
}
/**
* 生成缓存key

View File

@ -3,7 +3,6 @@ package cn.lili.modules.sms.plugin;
import cn.lili.modules.sms.entity.dos.SmsSign;
import cn.lili.modules.sms.entity.dos.SmsTemplate;
import cn.lili.modules.sms.entity.enums.SmsEnum;
import com.tencentcloudapi.common.exception.TencentCloudSDKException;
import java.util.List;
import java.util.Map;
@ -29,7 +28,7 @@ public interface SmsPlugin {
* @param templateCode 模版code
* @param signName 签名名称
*/
void sendSmsCode(String signName, String mobile, Map<String, String> param, String templateCode) throws TencentCloudSDKException;
void sendSmsCode(String signName, String mobile, Map<String, String> param, String templateCode);
/**
* 短信批量发送

View File

@ -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;
}

View File

@ -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();
}

View File

@ -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);
}
}

View File

@ -2,6 +2,7 @@ package cn.lili.controller.im;
import cn.lili.common.enums.ResultCode;
import cn.lili.common.enums.ResultUtil;
import cn.lili.common.exception.ServiceException;
import cn.lili.common.vo.ResultMessage;
import cn.lili.modules.im.entity.dos.ImMessage;
import cn.lili.modules.im.entity.dto.MessageQueryParams;
@ -32,39 +33,39 @@ public class ImMessageController {
@ApiOperation(value = "查看Im消息详情")
public ResultMessage<ImMessage> get(@PathVariable String id) {
ImMessage imMessage = imMessageService.getById(id);
return new ResultUtil<ImMessage>().setData(imMessage);
return ResultUtil.data(imMessage);
}
@GetMapping
@ApiOperation(value = "分页获取Im消息")
public ResultMessage<List<ImMessage>> historyMessage(MessageQueryParams messageQueryParams) {
List<ImMessage> data = imMessageService.getList(messageQueryParams);
return new ResultUtil<List<ImMessage>>().setData(data);
return ResultUtil.data(data);
}
@PostMapping
@ApiOperation(value = "新增Im消息")
public ResultMessage<ImMessage> save(ImMessage imMessage) {
if (imMessageService.save(imMessage)) {
return new ResultUtil<ImMessage>().setData(imMessage);
return ResultUtil.data(imMessage);
}
return new ResultUtil<ImMessage>().setErrorMsg(ResultCode.ERROR);
throw new ServiceException(ResultCode.IM_MESSAGE_ADD_ERROR);
}
@PutMapping("/{id}")
@ApiOperation(value = "更新Im消息")
public ResultMessage<ImMessage> update(@PathVariable String id, ImMessage imMessage) {
if (imMessageService.updateById(imMessage)) {
return new ResultUtil<ImMessage>().setData(imMessage);
return ResultUtil.data(imMessage);
}
return new ResultUtil<ImMessage>().setErrorMsg(ResultCode.ERROR);
throw new ServiceException(ResultCode.IM_MESSAGE_EDIT_ERROR);
}
@DeleteMapping(value = "/{ids}")
@ApiOperation(value = "删除Im消息")
public ResultMessage<Object> delAllByIds(@PathVariable List ids) {
imMessageService.removeByIds(ids);
return ResultUtil.success(ResultCode.SUCCESS);
return ResultUtil.success();
}

View File

@ -2,16 +2,11 @@ package cn.lili.controller.im;
import cn.lili.common.enums.ResultCode;
import cn.lili.common.enums.ResultUtil;
import cn.lili.common.security.AuthUser;
import cn.lili.common.security.context.UserContext;
import cn.lili.common.vo.ResultMessage;
import cn.lili.modules.im.entity.dos.ImTalk;
import cn.lili.modules.im.entity.vo.ImTalkVO;
import cn.lili.modules.im.service.ImTalkService;
import cn.lili.modules.store.service.StoreService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
@ -19,7 +14,6 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.stream.Collectors;
/**
@ -34,43 +28,38 @@ public class ImTalkController {
private final ImTalkService imTalkService;
@Autowired
private StoreService storeService;
@GetMapping(value = "/{id}")
@ApiOperation(value = "查看聊天详情")
public ResultMessage<ImTalk> get(@PathVariable String id) {
ImTalk imTalk = imTalkService.getById(id);
return new ResultUtil<ImTalk>().setData(imTalk);
return ResultUtil.data(imTalk);
}
@GetMapping(value = "/user/{uid}")
@ApiOperation(value = "查看与某人聊天详情")
public ResultMessage<ImTalk> getUser(@PathVariable String uid) {
AuthUser authUser = UserContext.getCurrentUser();
return ResultUtil.data(imTalkService.getTalkByUser(authUser.getId(), uid));
//通过长度判断,保证每次都是同一个聊天
return ResultUtil.data(imTalkService.getTalkByUser(uid));
}
@GetMapping(value = "/by/user/{userId}")
@ApiOperation(value = "查看与某人聊天详情")
public ResultMessage<ImTalkVO> getByUser(@PathVariable String userId) {
AuthUser authUser = UserContext.getCurrentUser();
return ResultUtil.data(new ImTalkVO(imTalkService.getTalkByUser(authUser.getId(), userId), authUser.getId()));
return ResultUtil.data(new ImTalkVO(imTalkService.getTalkByUser(userId),userId));
}
@GetMapping(value = "/top")
@ApiOperation(value = "查看与某人聊天详情")
public ResultMessage top(String id, Boolean top) {
public ResultMessage<Object> top(String id, Boolean top) {
imTalkService.top(id, top);
return ResultUtil.success();
}
@GetMapping("/list")
@ApiOperation(value = "分页获取聊天")
@ApiImplicitParam(name = "userName", value = "用户名称", paramType = "query", dataType = "String")
public ResultMessage<List<ImTalkVO>> getUserTalkList(String userName) {
return ResultUtil.data(imTalkService.getUserTalkList(userName));
@ApiOperation(value = "分页获取用户聊天")
public ResultMessage<List<ImTalkVO>> getUserTalkList() {
return ResultUtil.data(imTalkService.getUserTalkList());
}
@GetMapping("/store/list")

View File

@ -1,80 +0,0 @@
package cn.lili.controller.im;
import cn.lili.common.enums.ResultUtil;
import cn.lili.common.security.AuthUser;
import cn.lili.common.security.context.UserContext;
import cn.lili.common.vo.ResultMessage;
import cn.lili.modules.member.entity.dos.Member;
import cn.lili.modules.member.entity.dto.FootPrintQueryParams;
import cn.lili.modules.member.service.FootprintService;
import cn.lili.modules.member.service.MemberService;
import cn.lili.modules.search.entity.dos.EsGoodsIndex;
import cn.lili.modules.store.entity.dos.Store;
import cn.lili.modules.store.service.StoreService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @author Chopper
*/
@RestController
@Api(tags = "Im消息接口")
@RequestMapping("/im/user")
@Transactional(rollbackFor = Exception.class)
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class ImUserController {
private final MemberService memberService;
@Autowired
private StoreService storeService;
@Autowired
private FootprintService footprintService;
@GetMapping
@ApiOperation(value = "获取用户信息")
public ResultMessage<Member> getImUser() {
AuthUser authUser = UserContext.getCurrentUser();
return ResultUtil.data(memberService.getById(authUser.getId()));
}
@GetMapping("/store")
@ApiOperation(value = "获取店铺信息")
public ResultMessage<Store> getStoreUser() {
AuthUser authUser = UserContext.getCurrentUser();
return ResultUtil.data(storeService.getById(authUser.getStoreId()));
}
@GetMapping("/{memberId}")
@ApiImplicitParam(name = "memberId", value = "店铺Id", required = true, dataType = "String", paramType = "path")
@ApiOperation(value = "获取用户信息")
public ResultMessage<Member> getImUserDetail(@PathVariable String memberId) {
return ResultUtil.data(memberService.getById(memberId));
}
@GetMapping("/store/{storeId}")
@ApiImplicitParam(name = "storeId", value = "店铺Id", required = true, dataType = "String", paramType = "path")
@ApiOperation(value = "获取店铺信息")
public ResultMessage<Store> getStoreUserDetail(@PathVariable String storeId) {
return ResultUtil.data(storeService.getById(storeId));
}
@GetMapping("/history")
@ApiOperation(value = "获取会员的历史足迹")
public ResultMessage<IPage<EsGoodsIndex>> getMemberHistory(FootPrintQueryParams params) {
return ResultUtil.data(footprintService.footPrintPage(params));
}
}

View File

@ -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));
}
}

View File

@ -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);
}
}

View File

@ -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));
}
}