merge 自提、IM功能
This commit is contained in:
commit
cc12cecc2a
@ -6,4 +6,4 @@ CREATE TABLE `li_member_coupon_sign` (
|
||||
`invalid_time` datetime NULL DEFAULT NULL COMMENT '过期时间',
|
||||
`create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin ROW_FORMAT = DYNAMIC;
|
||||
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin ROW_FORMAT = DYNAMIC;git
|
@ -1,14 +1,17 @@
|
||||
package cn.lili.controller.member;
|
||||
|
||||
import cn.lili.common.enums.ResultUtil;
|
||||
import cn.lili.common.security.context.UserContext;
|
||||
import cn.lili.common.vo.PageVO;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.member.entity.dto.FootPrintQueryParams;
|
||||
import cn.lili.modules.member.service.FootprintService;
|
||||
import cn.lili.modules.search.entity.dos.EsGoodsIndex;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.catalina.User;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@ -35,8 +38,9 @@ public class FootprintController {
|
||||
|
||||
@ApiOperation(value = "分页获取")
|
||||
@GetMapping
|
||||
public ResultMessage<IPage<EsGoodsIndex>> getByPage(PageVO page) {
|
||||
return ResultUtil.data(footprintService.footPrintPage(page));
|
||||
public ResultMessage<IPage<EsGoodsIndex>> getByPage(FootPrintQueryParams params) {
|
||||
params.setMemberId(UserContext.getCurrentUser().getId());
|
||||
return ResultUtil.data(footprintService.footPrintPage(params));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "根据id删除")
|
||||
|
@ -189,20 +189,38 @@ public class CartController {
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation(value = "选择自提地址")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "storeAddressId", value = "自提地址id ", required = true, paramType = "query"),
|
||||
@ApiImplicitParam(name = "way", value = "购物车类型 ", paramType = "query")
|
||||
})
|
||||
@GetMapping("/storeAddress")
|
||||
public ResultMessage<Object> shippingSelfPickAddress(@NotNull(message = "自提地址ID不能为空") String storeAddressId,
|
||||
String way) {
|
||||
try {
|
||||
cartService.shippingSelfAddress(storeAddressId, way);
|
||||
return ResultUtil.success();
|
||||
} catch (ServiceException se) {
|
||||
log.error(ResultCode.SHIPPING_NOT_APPLY.message(), se);
|
||||
throw new ServiceException(ResultCode.SHIPPING_NOT_APPLY);
|
||||
} catch (Exception e) {
|
||||
log.error(ResultCode.CART_ERROR.message(), e);
|
||||
throw new ServiceException(ResultCode.CART_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation(value = "选择配送方式")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "shippingMethod", value = "配送方式:SELF_PICK_UP(自提)," +
|
||||
"LOCAL_TOWN_DELIVERY(同城配送)," +
|
||||
"LOGISTICS(物流) ", required = true, paramType = "query"),
|
||||
@ApiImplicitParam(name = "selleId", value = "店铺id", paramType = "query"),
|
||||
@ApiImplicitParam(name = "way", value = "购物车类型 ", paramType = "query")
|
||||
})
|
||||
@GetMapping("/shippingMethod")
|
||||
@PutMapping("/shippingMethod")
|
||||
public ResultMessage<Object> shippingMethod(@NotNull(message = "配送方式不能为空") String shippingMethod,
|
||||
String selleId,
|
||||
String way) {
|
||||
try {
|
||||
cartService.shippingMethod(selleId, shippingMethod, way);
|
||||
cartService.shippingMethod( shippingMethod, way);
|
||||
return ResultUtil.success();
|
||||
} catch (ServiceException se) {
|
||||
log.error(se.getMsg(), se);
|
||||
@ -213,6 +231,21 @@ public class CartController {
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取用户可选择的物流方式")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "way", value = "购物车类型 ", paramType = "query")
|
||||
})
|
||||
@GetMapping("/shippingMethodList")
|
||||
public ResultMessage<Object> shippingMethodList(String way) {
|
||||
try {
|
||||
return ResultUtil.data(cartService.shippingMethodList(way));
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return ResultUtil.error(ResultCode.ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation(value = "选择发票")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "way", value = "购物车购买:CART/立即购买:BUY_NOW/拼团购买:PINTUAN / 积分购买:POINT ", required = true, paramType = "query"),
|
||||
|
@ -0,0 +1,53 @@
|
||||
package cn.lili.controller.store;
|
||||
|
||||
import cn.lili.common.enums.ResultUtil;
|
||||
import cn.lili.common.security.OperationalJudgment;
|
||||
import cn.lili.common.security.context.UserContext;
|
||||
import cn.lili.common.vo.PageVO;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.store.entity.dos.StoreAddress;
|
||||
import cn.lili.modules.store.service.StoreAddressService;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
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;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 买家端,商家地址(自提点)接口
|
||||
*
|
||||
* @author chc
|
||||
* @since 2022/6/2114:46
|
||||
*/
|
||||
@RestController
|
||||
@Api(tags = "买家端,商家地址(自提点)接口")
|
||||
@RequestMapping("/buyer/store/address")
|
||||
public class StoreAddressBuyerController {
|
||||
|
||||
/**
|
||||
* 店铺自提点
|
||||
*/
|
||||
@Autowired
|
||||
private StoreAddressService storeAddressService;
|
||||
|
||||
@ApiOperation(value = "获取商家自提点分页")
|
||||
@ApiImplicitParam(name = "storeId", value = "店铺Id", required = true, dataType = "String", paramType = "path")
|
||||
@GetMapping("/page/{storeId}")
|
||||
public ResultMessage<IPage<StoreAddress>> get(PageVO pageVo,@PathVariable String storeId) {
|
||||
return ResultUtil.data(storeAddressService.getStoreAddress(storeId, pageVo));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取商家自提点信息")
|
||||
@ApiImplicitParam(name = "id", value = "自提点ID", required = true, paramType = "path")
|
||||
@GetMapping("/{id}")
|
||||
public ResultMessage<StoreAddress> get(@PathVariable String id) {
|
||||
StoreAddress address = OperationalJudgment.judgment(storeAddressService.getById(id));
|
||||
return ResultUtil.data(address);
|
||||
}
|
||||
}
|
@ -265,6 +265,8 @@ lili:
|
||||
order-group: lili_order_group
|
||||
member-topic: lili_member_topic
|
||||
member-group: lili_member_group
|
||||
store-topic: lili_store_topic
|
||||
store-group: lili_store_group
|
||||
other-topic: lili_other_topic
|
||||
other-group: lili_other_group
|
||||
notice-topic: lili_notice_topic
|
||||
|
@ -0,0 +1,17 @@
|
||||
package cn.lili.event;
|
||||
|
||||
import cn.lili.modules.member.entity.dos.Member;
|
||||
|
||||
/**
|
||||
* @author chc
|
||||
* @since 2022/6/2114:46
|
||||
*/
|
||||
public interface MemberInfoChangeEvent {
|
||||
|
||||
/**
|
||||
* 会员信息更改消息
|
||||
*
|
||||
* @param member 会员信息
|
||||
*/
|
||||
void memberInfoChange(Member member);
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package cn.lili.event;
|
||||
|
||||
|
||||
import cn.lili.modules.store.entity.dos.Store;
|
||||
|
||||
/**
|
||||
* @author chc
|
||||
* @since 2022/6/2114:46
|
||||
*/
|
||||
public interface StoreSettingChangeEvent {
|
||||
|
||||
/**
|
||||
* 店铺信息更改消息
|
||||
*
|
||||
* @param store 店铺信息
|
||||
*/
|
||||
void storeSettingChange(Store store);
|
||||
}
|
@ -44,8 +44,9 @@ public class DistributionOrderExecute implements OrderStatusChangeEvent, EveryDa
|
||||
public void orderChange(OrderMessage orderMessage) {
|
||||
|
||||
switch (orderMessage.getNewStatus()) {
|
||||
//订单带校验/订单代发货,则记录分销信息
|
||||
//订单带校验/订单代发货/待自提,则记录分销信息
|
||||
case TAKE:
|
||||
case STAY_PICKED_UP:
|
||||
case UNDELIVERED: {
|
||||
//记录分销订单
|
||||
distributionOrderService.calculationDistribution(orderMessage.getOrderSn());
|
||||
|
60
consumer/src/main/java/cn/lili/event/impl/ImTalkExecute.java
Normal file
60
consumer/src/main/java/cn/lili/event/impl/ImTalkExecute.java
Normal file
@ -0,0 +1,60 @@
|
||||
package cn.lili.event.impl;
|
||||
|
||||
import cn.lili.event.MemberInfoChangeEvent;
|
||||
import cn.lili.event.StoreSettingChangeEvent;
|
||||
import cn.lili.modules.im.entity.dos.ImTalk;
|
||||
import cn.lili.modules.im.service.ImTalkService;
|
||||
import cn.lili.modules.member.entity.dos.Member;
|
||||
import cn.lili.modules.store.entity.dos.Store;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Im对话消息
|
||||
*
|
||||
* @author chc
|
||||
* @since 2022/6/2114:46
|
||||
*/
|
||||
@Service
|
||||
public class ImTalkExecute implements MemberInfoChangeEvent, StoreSettingChangeEvent {
|
||||
|
||||
@Autowired
|
||||
private ImTalkService imTalkService;
|
||||
|
||||
@Override
|
||||
public void memberInfoChange(Member member) {
|
||||
//当与UserId1相等时
|
||||
List<ImTalk> imTalkList1 = imTalkService.list(new LambdaQueryWrapper<ImTalk>().eq(ImTalk::getUserId1, member.getId()));
|
||||
for (ImTalk imTalk : imTalkList1) {
|
||||
imTalk.setName1(member.getNickName());
|
||||
imTalk.setFace1(member.getFace());
|
||||
}
|
||||
imTalkService.updateBatchById(imTalkList1);
|
||||
List<ImTalk> imTalkList2 = imTalkService.list(new LambdaQueryWrapper<ImTalk>().eq(ImTalk::getUserId2, member.getId()));
|
||||
for (ImTalk imTalk : imTalkList2) {
|
||||
imTalk.setName2(member.getNickName());
|
||||
imTalk.setFace2(member.getFace());
|
||||
}
|
||||
imTalkService.updateBatchById(imTalkList2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void storeSettingChange(Store store) {
|
||||
//当与UserId1相等时
|
||||
List<ImTalk> imTalkList1 = imTalkService.list(new LambdaQueryWrapper<ImTalk>().eq(ImTalk::getUserId1, store.getId()));
|
||||
for (ImTalk imTalk : imTalkList1) {
|
||||
imTalk.setName1(store.getStoreName());
|
||||
imTalk.setFace1(store.getStoreLogo());
|
||||
}
|
||||
imTalkService.updateBatchById(imTalkList1);
|
||||
List<ImTalk> imTalkList2 = imTalkService.list(new LambdaQueryWrapper<ImTalk>().eq(ImTalk::getUserId2, store.getId()));
|
||||
for (ImTalk imTalk : imTalkList2) {
|
||||
imTalk.setName2(store.getStoreName());
|
||||
imTalk.setFace2(store.getStoreLogo());
|
||||
}
|
||||
imTalkService.updateBatchById(imTalkList2);
|
||||
}
|
||||
}
|
@ -31,7 +31,7 @@ public class VerificationOrderExecute implements OrderStatusChangeEvent {
|
||||
@Override
|
||||
public void orderChange(OrderMessage orderMessage) {
|
||||
//订单状态为待核验,添加订单添加核验码
|
||||
if (orderMessage.getNewStatus().equals(OrderStatusEnum.TAKE)) {
|
||||
if (orderMessage.getNewStatus().equals(OrderStatusEnum.TAKE) || orderMessage.getNewStatus().equals(OrderStatusEnum.STAY_PICKED_UP)) {
|
||||
//获取订单信息
|
||||
Order order = orderService.getBySn(orderMessage.getOrderSn());
|
||||
//获取随机数,判定是否存在
|
||||
|
@ -42,6 +42,7 @@ public class WechatMessageExecute implements OrderStatusChangeEvent, TradeEvent
|
||||
case PAID:
|
||||
case UNDELIVERED:
|
||||
case DELIVERED:
|
||||
case STAY_PICKED_UP:
|
||||
case COMPLETED:
|
||||
try {
|
||||
wechatMessageUtil.sendWechatMessage(orderMessage.getOrderSn());
|
||||
|
@ -1,10 +1,8 @@
|
||||
package cn.lili.listener;
|
||||
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import cn.lili.event.MemberLoginEvent;
|
||||
import cn.lili.event.MemberPointChangeEvent;
|
||||
import cn.lili.event.MemberRegisterEvent;
|
||||
import cn.lili.event.MemberWithdrawalEvent;
|
||||
import cn.lili.event.*;
|
||||
import cn.lili.event.impl.ImTalkExecute;
|
||||
import cn.lili.modules.member.entity.dos.Member;
|
||||
import cn.lili.modules.member.entity.dos.MemberSign;
|
||||
import cn.lili.modules.member.entity.dto.MemberPointMessage;
|
||||
@ -58,6 +56,9 @@ public class MemberMessageListener implements RocketMQListener<MessageExt> {
|
||||
@Autowired
|
||||
private List<MemberLoginEvent> memberLoginEvents;
|
||||
|
||||
@Autowired
|
||||
private List<MemberInfoChangeEvent> memberInfoChangeEvents;
|
||||
|
||||
|
||||
@Override
|
||||
public void onMessage(MessageExt messageExt) {
|
||||
@ -110,6 +111,20 @@ public class MemberMessageListener implements RocketMQListener<MessageExt> {
|
||||
}
|
||||
}
|
||||
break;
|
||||
//会员信息更改
|
||||
case MEMBER_INFO_EDIT:
|
||||
for (MemberInfoChangeEvent memberInfoChangeEvent : memberInfoChangeEvents) {
|
||||
try {
|
||||
Member member = JSONUtil.toBean(new String(messageExt.getBody()), Member.class);
|
||||
memberInfoChangeEvent.memberInfoChange(member);
|
||||
} catch (Exception e) {
|
||||
log.error("会员{},在{}业务中,提现事件执行异常",
|
||||
new String(messageExt.getBody()),
|
||||
memberInfoChangeEvent.getClass().getName(),
|
||||
e);
|
||||
}
|
||||
}
|
||||
break;
|
||||
//会员提现
|
||||
case MEMBER_WITHDRAWAL:
|
||||
for (MemberWithdrawalEvent memberWithdrawalEvent : memberWithdrawalEvents) {
|
||||
|
@ -0,0 +1,51 @@
|
||||
package cn.lili.listener;
|
||||
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import cn.lili.event.MemberRegisterEvent;
|
||||
import cn.lili.event.StoreSettingChangeEvent;
|
||||
import cn.lili.modules.member.entity.dos.Member;
|
||||
import cn.lili.modules.store.entity.dos.Store;
|
||||
import cn.lili.rocketmq.tags.StoreTagsEnum;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.rocketmq.common.message.MessageExt;
|
||||
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
|
||||
import org.apache.rocketmq.spring.core.RocketMQListener;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 店铺消息
|
||||
* @author chc
|
||||
* @since 2022/6/2114:46
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
@RocketMQMessageListener(topic = "${lili.data.rocketmq.store-topic}", consumerGroup = "${lili.data.rocketmq.store-group}")
|
||||
public class StoreMessageListener implements RocketMQListener<MessageExt> {
|
||||
@Autowired
|
||||
private List<StoreSettingChangeEvent> storeSettingChangeEventList;
|
||||
|
||||
@Override
|
||||
public void onMessage(MessageExt messageExt) {
|
||||
switch (StoreTagsEnum.valueOf(messageExt.getTags())){
|
||||
//修改店铺
|
||||
case EDIT_STORE_SETTING:
|
||||
for (StoreSettingChangeEvent storeSettingChangeEvent : storeSettingChangeEventList) {
|
||||
try {
|
||||
Store store = JSONUtil.toBean(new String(messageExt.getBody()), Store.class);
|
||||
storeSettingChangeEvent.storeSettingChange(store);
|
||||
} catch (Exception e) {
|
||||
log.error("会员{},在{}业务中,状态修改事件执行异常",
|
||||
new String(messageExt.getBody()),
|
||||
storeSettingChangeEvent.getClass().getName(),
|
||||
e);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
@ -260,6 +260,8 @@ lili:
|
||||
order-group: lili_order_group
|
||||
member-topic: lili_member_topic
|
||||
member-group: lili_member_group
|
||||
store-topic: lili_store_topic
|
||||
store-group: lili_store_group
|
||||
other-topic: lili_other_topic
|
||||
other-group: lili_other_group
|
||||
notice-topic: lili_notice_topic
|
||||
|
@ -51,7 +51,10 @@
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-websocket</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
|
@ -70,6 +70,12 @@ public class AuthUser implements Serializable {
|
||||
*/
|
||||
private Boolean isSuper = false;
|
||||
|
||||
/**
|
||||
* 租户id
|
||||
*/
|
||||
private String tenantId;
|
||||
|
||||
|
||||
public AuthUser(String username, String id, String nickName, String face, UserEnums role) {
|
||||
this.username = username;
|
||||
this.face = face;
|
||||
|
@ -14,7 +14,8 @@ public enum UserEnums {
|
||||
MEMBER("会员"),
|
||||
STORE("商家"),
|
||||
MANAGER("管理员"),
|
||||
SYSTEM("系统");
|
||||
SYSTEM("系统"),
|
||||
SEAT("坐席");
|
||||
private final String role;
|
||||
|
||||
UserEnums(String role) {
|
||||
|
@ -81,6 +81,32 @@ public class Swagger2Config {
|
||||
.securitySchemes(securitySchemes())
|
||||
.securityContexts(securityContexts());
|
||||
}
|
||||
@Bean
|
||||
public Docket orderRestApi() {
|
||||
return new Docket(DocumentationType.SWAGGER_2)
|
||||
.groupName("订单")
|
||||
.apiInfo(apiInfo()).select()
|
||||
//扫描所有有注解的api,用这种方式更灵活
|
||||
// .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
|
||||
.apis(RequestHandlerSelectors.basePackage("cn.lili.controller.order"))
|
||||
.paths(PathSelectors.any())
|
||||
.build()
|
||||
.securitySchemes(securitySchemes())
|
||||
.securityContexts(securityContexts());
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Docket imRestApi() {
|
||||
return new Docket(DocumentationType.SWAGGER_2)
|
||||
.groupName("im")
|
||||
.apiInfo(apiInfo()).select()
|
||||
//扫描所有有注解的api,用这种方式更灵活
|
||||
.apis(RequestHandlerSelectors.basePackage("cn.lili.controller.im"))
|
||||
.paths(PathSelectors.any())
|
||||
.build()
|
||||
.securitySchemes(securitySchemes())
|
||||
.securityContexts(securityContexts());
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Docket memberRestApi() {
|
||||
|
@ -327,7 +327,7 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
||||
|
||||
//记录用户足迹
|
||||
if (UserContext.getCurrentUser() != null) {
|
||||
FootPrint footPrint = new FootPrint(UserContext.getCurrentUser().getId(), goodsId, skuId);
|
||||
FootPrint footPrint = new FootPrint(UserContext.getCurrentUser().getId(), goodsIndex.getStoreId(), goodsId, skuId);
|
||||
String destination = rocketmqCustomProperties.getGoodsTopic() + ":" + GoodsTagsEnum.VIEW_GOODS.name();
|
||||
rocketMQTemplate.asyncSend(destination, footPrint, RocketmqSendCallbackBuilder.commonCallback());
|
||||
}
|
||||
|
@ -0,0 +1,34 @@
|
||||
package cn.lili.modules.im.config;
|
||||
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
|
||||
import javax.websocket.server.ServerEndpointConfig;
|
||||
|
||||
/**
|
||||
* CustomSpringConfigurator
|
||||
*
|
||||
* @author Chopper
|
||||
* @version v1.0
|
||||
* 2021-12-31 11:53
|
||||
*/
|
||||
public class CustomSpringConfigurator extends ServerEndpointConfig.Configurator implements ApplicationContextAware {
|
||||
|
||||
/**
|
||||
* Spring application context.
|
||||
*/
|
||||
private static volatile BeanFactory context;
|
||||
|
||||
@Override
|
||||
public <T> T getEndpointInstance(Class<T> clazz) throws InstantiationException {
|
||||
return context.getBean(clazz);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
||||
CustomSpringConfigurator.context = applicationContext;
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package cn.lili.modules.im.config;
|
||||
|
||||
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* WebSocketConfigurator
|
||||
*
|
||||
* @author Chopper
|
||||
* @version v1.0
|
||||
* 2021-12-31 11:53
|
||||
*/
|
||||
@ConditionalOnWebApplication
|
||||
@Configuration
|
||||
public class WebSocketConfigurator {
|
||||
|
||||
@Bean
|
||||
public CustomSpringConfigurator customSpringConfigurator() {
|
||||
// This is just to get context
|
||||
return new CustomSpringConfigurator();
|
||||
}
|
||||
}
|
@ -0,0 +1,69 @@
|
||||
package cn.lili.modules.im.entity.dos;
|
||||
|
||||
import cn.lili.common.utils.SnowFlake;
|
||||
import cn.lili.modules.im.entity.enums.MessageTypeEnum;
|
||||
import cn.lili.modules.im.entity.vo.MessageOperation;
|
||||
import cn.lili.mybatis.BaseEntity;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author Chopper
|
||||
*/
|
||||
@Data
|
||||
@TableName("li_im_message")
|
||||
@ApiModel(value = "Im消息")
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ImMessage extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 发送者
|
||||
*/
|
||||
private String fromUser;
|
||||
|
||||
/**
|
||||
* 接收者
|
||||
*/
|
||||
private String toUser;
|
||||
|
||||
/**
|
||||
* 已阅
|
||||
*/
|
||||
private Boolean isRead;
|
||||
|
||||
/**
|
||||
* 消息类型
|
||||
*/
|
||||
private MessageTypeEnum messageType;
|
||||
|
||||
/**
|
||||
* 聊天id
|
||||
*/
|
||||
private String talkId;
|
||||
|
||||
/**
|
||||
* 消息实体
|
||||
*/
|
||||
private String text;
|
||||
|
||||
|
||||
public ImMessage(MessageOperation messageOperation){
|
||||
this.setFromUser(messageOperation.getFrom());
|
||||
this.setMessageType(messageOperation.getMessageType());
|
||||
this.setIsRead(false);
|
||||
this.setText(messageOperation.getContext());
|
||||
this.setTalkId(messageOperation.getTalkId());
|
||||
this.setCreateTime(new Date());
|
||||
this.setToUser(messageOperation.getTo());
|
||||
this.setId(SnowFlake.getIdStr());
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,102 @@
|
||||
package cn.lili.modules.im.entity.dos;
|
||||
|
||||
|
||||
import cn.lili.common.utils.SnowFlake;
|
||||
import cn.lili.mybatis.BaseTenantEntity;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author Chopper
|
||||
*/
|
||||
@Data
|
||||
@TableName("li_im_talk")
|
||||
@ApiModel(value = "聊天")
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ImTalk extends BaseTenantEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty("用户1 id")
|
||||
private String userId1;
|
||||
|
||||
@ApiModelProperty("用户2 id")
|
||||
private String userId2;
|
||||
|
||||
@ApiModelProperty("用户1置顶")
|
||||
private Boolean top1;
|
||||
|
||||
@ApiModelProperty("用户2置顶")
|
||||
private Boolean top2;
|
||||
|
||||
@ApiModelProperty("用户1 不可见")
|
||||
private Boolean disable1;
|
||||
|
||||
@ApiModelProperty("用户2 不可见")
|
||||
private Boolean disable2;
|
||||
|
||||
@ApiModelProperty("用户1名字")
|
||||
private String name1;
|
||||
|
||||
@ApiModelProperty("用户2名字")
|
||||
private String name2;
|
||||
|
||||
@ApiModelProperty("用户1头像")
|
||||
private String face1;
|
||||
|
||||
@ApiModelProperty("用户2头像")
|
||||
private String face2;
|
||||
|
||||
@ApiModelProperty("用户1的店铺标识")
|
||||
private Boolean storeFlag1;
|
||||
|
||||
@ApiModelProperty("用户2的店铺标识")
|
||||
private Boolean storeFlag2;
|
||||
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty(value = "最后聊天时间", hidden = true)
|
||||
private Date lastTalkTime;
|
||||
|
||||
@ApiModelProperty(value = "最后聊天内容")
|
||||
private String lastTalkMessage;
|
||||
|
||||
@ApiModelProperty(value = "最后发送消息类型")
|
||||
private String lastMessageType;
|
||||
|
||||
@ApiModelProperty(value = "坐席Id")
|
||||
private String tenantId;
|
||||
|
||||
@ApiModelProperty(value = "坐席名称")
|
||||
private String tenantName;
|
||||
|
||||
|
||||
public ImTalk(String userId1, String userId2,
|
||||
String face1, String face2,
|
||||
String name1, String name2
|
||||
) {
|
||||
this.userId1 = userId1;
|
||||
this.userId2 = userId2;
|
||||
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 = face1;
|
||||
this.face2 = face2;
|
||||
this.name1 = name1;
|
||||
this.name2 = name2;
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package cn.lili.modules.im.entity.dos;
|
||||
|
||||
import cn.lili.mybatis.BaseEntity;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 问题答案
|
||||
*
|
||||
* @author Chopper
|
||||
* @version v1.0
|
||||
* 2022-02-09 17:59
|
||||
*/
|
||||
@Data
|
||||
@TableName("li_qa")
|
||||
@ApiModel(value = "租户问答")
|
||||
@NoArgsConstructor
|
||||
public class QA extends BaseEntity {
|
||||
|
||||
@ApiModelProperty(value = "租户id")
|
||||
private Integer tenantId;
|
||||
|
||||
@ApiModelProperty(value = "问题")
|
||||
private String question;
|
||||
|
||||
@ApiModelProperty(value = "答案")
|
||||
private String answer;
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
package cn.lili.modules.im.entity.dos;
|
||||
|
||||
import cn.lili.mybatis.BaseTenantEntity;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
|
||||
/**
|
||||
* 坐席
|
||||
*
|
||||
* @author Chopper
|
||||
* @version v1.0
|
||||
* 2022-02-09 17:08
|
||||
*/
|
||||
@Data
|
||||
@TableName("li_seat")
|
||||
@ApiModel(value = "坐席")
|
||||
@NoArgsConstructor
|
||||
public class Seat extends BaseTenantEntity {
|
||||
|
||||
@ApiModelProperty(value = "租户id")
|
||||
private String tenantId;
|
||||
|
||||
@ApiModelProperty(value = "坐席用户名")
|
||||
private String username;
|
||||
|
||||
@ApiModelProperty(value = "会员头像")
|
||||
private String face;
|
||||
|
||||
@ApiModelProperty(value = "坐席密码")
|
||||
private String password;
|
||||
|
||||
@ApiModelProperty(value = "昵称")
|
||||
private String nickName;
|
||||
|
||||
@ApiModelProperty(value = "坐席状态")
|
||||
private Boolean disabled;
|
||||
|
||||
@NotEmpty(message = "手机号码不能为空")
|
||||
@ApiModelProperty(value = "手机号码", required = true)
|
||||
private String mobile;
|
||||
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package cn.lili.modules.im.entity.dos;
|
||||
|
||||
import cn.lili.mybatis.BaseTenantEntity;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 坐席设置
|
||||
*
|
||||
* @author Chopper
|
||||
* @version v1.0
|
||||
* 2022-02-09 17:55
|
||||
*/
|
||||
@Data
|
||||
@TableName("li_seat_setting")
|
||||
@ApiModel(value = "坐席设置")
|
||||
@NoArgsConstructor
|
||||
public class SeatSetting extends BaseTenantEntity {
|
||||
|
||||
@ApiModelProperty(value = "租户idid")
|
||||
private String tenantId;
|
||||
|
||||
@ApiModelProperty(value = "欢迎语")
|
||||
private String welcome;
|
||||
|
||||
@ApiModelProperty(value = "离线自动回复")
|
||||
private String outLineAutoReply;
|
||||
|
||||
@ApiModelProperty(value = "长时间自动回复")
|
||||
private String longTermAutoReply;
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package cn.lili.modules.im.entity.dto;
|
||||
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import cn.lili.common.vo.PageVO;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author chc
|
||||
* @since 2022/6/2114:46
|
||||
*/
|
||||
@Data
|
||||
@ApiModel
|
||||
public class ImQueryParams extends PageVO {
|
||||
|
||||
@ApiModelProperty("用户Id")
|
||||
private String memberId;
|
||||
|
||||
@ApiModelProperty("店铺Id")
|
||||
private String storeId;
|
||||
|
||||
public <T> QueryWrapper<T> queryWrapper() {
|
||||
QueryWrapper<T> queryWrapper = new QueryWrapper<>();
|
||||
if (CharSequenceUtil.isNotEmpty(memberId)) {
|
||||
queryWrapper.eq("member_id", memberId);
|
||||
}
|
||||
if (CharSequenceUtil.isNotEmpty(storeId)) {
|
||||
queryWrapper.eq("store_id", storeId);
|
||||
}
|
||||
queryWrapper.eq("delete_flag",false);
|
||||
queryWrapper.orderByDesc("create_time");
|
||||
return queryWrapper;
|
||||
}
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
package cn.lili.modules.im.entity.dto;
|
||||
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.exception.ServiceException;
|
||||
import cn.lili.common.utils.StringUtils;
|
||||
import cn.lili.common.vo.PageVO;
|
||||
import cn.lili.modules.im.entity.dos.ImMessage;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* MessageQueryParams
|
||||
*
|
||||
* @author Chopper
|
||||
* @version v1.0
|
||||
* 2022-01-20 17:16
|
||||
*/
|
||||
@Data
|
||||
public class MessageQueryParams extends PageVO {
|
||||
/**
|
||||
* 聊天窗口
|
||||
*/
|
||||
private String talkId;
|
||||
/**
|
||||
* 最后一个消息
|
||||
*/
|
||||
private String lastMessageId;
|
||||
/**
|
||||
* 获取消息数量
|
||||
*/
|
||||
private Integer num;
|
||||
|
||||
public LambdaQueryWrapper<ImMessage> initQueryWrapper() {
|
||||
if (StringUtils.isEmpty(talkId)) {
|
||||
throw new ServiceException(ResultCode.ERROR);
|
||||
}
|
||||
if (num == null || num > 50) {
|
||||
num = 50;
|
||||
}
|
||||
|
||||
LambdaQueryWrapper<ImMessage> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.eq(ImMessage::getTalkId, talkId);
|
||||
if (StringUtils.isNotEmpty(lastMessageId)) {
|
||||
lambdaQueryWrapper.lt(ImMessage::getId, lastMessageId);
|
||||
}
|
||||
lambdaQueryWrapper.orderByDesc(ImMessage::getCreateTime);
|
||||
// lambdaQueryWrapper.last("limit " + num);
|
||||
return lambdaQueryWrapper;
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package cn.lili.modules.im.entity.enums;
|
||||
|
||||
/**
|
||||
* 返回消息类型枚举
|
||||
*
|
||||
* @author liushuai
|
||||
*/
|
||||
public enum MessageResultType {
|
||||
/**
|
||||
* 返回消息类型枚举
|
||||
* <p>
|
||||
* 好友列表
|
||||
* 增加好友
|
||||
* 消息
|
||||
* 阅读消息
|
||||
* 未读消息
|
||||
* 历史消息
|
||||
* 系统提示
|
||||
*/
|
||||
FRIENDS,
|
||||
ADD_FRIENDS,
|
||||
MESSAGE,
|
||||
READ_MESSAGE,
|
||||
UN_READ,
|
||||
HISTORY,
|
||||
SYSTEM_TIPS
|
||||
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package cn.lili.modules.im.entity.enums;
|
||||
|
||||
/**
|
||||
* 消息的类型
|
||||
*
|
||||
* @author liushuai(liushuai711 @ gmail.com)
|
||||
* @version v4.0
|
||||
* @Description:
|
||||
* @since 2022/2/10 16:36
|
||||
*/
|
||||
public enum MessageStatusEnum {
|
||||
//socket刚打开时发送的消息,这个一般是是刚打开socket链接,进行登录,传入token用
|
||||
CONNECT,
|
||||
//心跳类型的消息,此种类型的消息只有 type 、 text 两种属性
|
||||
HEARTBEAT,
|
||||
//用户打开一个对话框,准备跟某人聊天时
|
||||
OPEN,
|
||||
//客服进行自动回复。客户端发起这种类型请求,则是在拉取对方是否有自动回复,如果有,服务端就会给客户端发送过自动回复的信息
|
||||
AUTO_REPLY,
|
||||
//正常收发消息沟通,文字、表情等沟通
|
||||
MSG,
|
||||
//扩展。比如发送商品、发送订单
|
||||
EXTEND,
|
||||
//系统提示,如提示 对方已离线
|
||||
SYSTEM,
|
||||
//服务端发送到客户端,用于设置客户端的用户信息。会吧 com.xnx3.yunkefu.core.vo.bean.User 传过去
|
||||
SET_USER,
|
||||
//结束服务
|
||||
CLOSE_SERVICE;
|
||||
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package cn.lili.modules.im.entity.enums;
|
||||
|
||||
/**
|
||||
* 消息类型
|
||||
*
|
||||
* @author liushuai
|
||||
*/
|
||||
public enum MessageTypeEnum {
|
||||
/**
|
||||
* 消息类型枚举
|
||||
* <p>
|
||||
* 普通消息
|
||||
* 图片
|
||||
* 语音
|
||||
* 视频
|
||||
*/
|
||||
MESSAGE,
|
||||
PICTURE,
|
||||
VOICE,
|
||||
GOODS,
|
||||
ORDER,
|
||||
VIDEO
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package cn.lili.modules.im.entity.enums;
|
||||
|
||||
/**
|
||||
* 坐席在线状态
|
||||
*
|
||||
* @author Chopper
|
||||
* @version v1.0
|
||||
* 2022-02-10 16:37
|
||||
*/
|
||||
public enum OnlineStatusEnum {
|
||||
// 在线/下线
|
||||
ONLINE,
|
||||
OUTLINE;
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package cn.lili.modules.im.entity.enums;
|
||||
|
||||
/**
|
||||
* 操作类型枚举
|
||||
*
|
||||
* @author liushuai
|
||||
*/
|
||||
public enum OperationType {
|
||||
/**
|
||||
* 消息类型枚举
|
||||
* <p>
|
||||
* 心跳检测
|
||||
* 发起聊天
|
||||
* 发起消息
|
||||
* 查询历史消息
|
||||
* 阅读消息
|
||||
* 查询未读消息
|
||||
*/
|
||||
PING,
|
||||
CREATE,
|
||||
MESSAGE,
|
||||
HISTORY,
|
||||
READ,
|
||||
UNREAD,
|
||||
|
||||
}
|
@ -0,0 +1,82 @@
|
||||
package cn.lili.modules.im.entity.vo;
|
||||
|
||||
import cn.lili.modules.im.entity.dos.ImTalk;
|
||||
import cn.lili.mybatis.BaseTenantEntity;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author Chopper
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value = "聊天")
|
||||
public class ImTalkVO extends BaseTenantEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty("id")
|
||||
private String id;
|
||||
|
||||
@ApiModelProperty("用户 id")
|
||||
private String userId;
|
||||
|
||||
@ApiModelProperty("置顶")
|
||||
private Boolean top;
|
||||
|
||||
@ApiModelProperty("用户 不可见")
|
||||
private Boolean disable;
|
||||
|
||||
@ApiModelProperty("用户名字")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty("用户头像")
|
||||
private String face;
|
||||
|
||||
@ApiModelProperty("店铺标识")
|
||||
private Boolean storeFlag;
|
||||
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty(value = "最后聊天时间", hidden = true)
|
||||
private Date lastTalkTime;
|
||||
|
||||
@ApiModelProperty(value = "最后聊天内容")
|
||||
private String lastTalkMessage;
|
||||
|
||||
@ApiModelProperty(value = "最后发送消息类型")
|
||||
private String lastMessageType;
|
||||
|
||||
@ApiModelProperty(value = "未读数量")
|
||||
private Long unread;
|
||||
|
||||
public ImTalkVO() {
|
||||
|
||||
}
|
||||
|
||||
public ImTalkVO(ImTalk imTalk, String currentUser) {
|
||||
if (imTalk.getUserId2().equals(currentUser)) {
|
||||
userId = imTalk.getUserId1();
|
||||
top = imTalk.getTop1();
|
||||
disable = imTalk.getDisable1();
|
||||
name = imTalk.getName1();
|
||||
face = imTalk.getFace1();
|
||||
storeFlag = imTalk.getStoreFlag1();
|
||||
} else {
|
||||
userId = imTalk.getUserId2();
|
||||
top = imTalk.getTop2();
|
||||
disable = imTalk.getDisable2();
|
||||
name = imTalk.getName2();
|
||||
face = imTalk.getFace2();
|
||||
storeFlag = imTalk.getStoreFlag2();
|
||||
}
|
||||
lastTalkMessage = imTalk.getLastTalkMessage();
|
||||
lastTalkTime = imTalk.getLastTalkTime();
|
||||
lastMessageType = imTalk.getLastMessageType();
|
||||
id = imTalk.getId();
|
||||
}
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
package cn.lili.modules.im.entity.vo;
|
||||
|
||||
import cn.lili.common.utils.StringUtils;
|
||||
import cn.lili.modules.im.entity.enums.MessageTypeEnum;
|
||||
import cn.lili.modules.im.entity.enums.OperationType;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author liushuai
|
||||
*/
|
||||
@Data
|
||||
public class MessageOperation {
|
||||
|
||||
/**
|
||||
* 消息类型
|
||||
*/
|
||||
private OperationType operationType;
|
||||
/**
|
||||
* 与某人聊天记录
|
||||
*/
|
||||
private String to;
|
||||
|
||||
/**
|
||||
* 发送者
|
||||
*/
|
||||
private String from;
|
||||
|
||||
/**
|
||||
* 聊天id
|
||||
*/
|
||||
private String talkId;
|
||||
|
||||
/**
|
||||
* 消息类型
|
||||
*/
|
||||
private MessageTypeEnum messageType;
|
||||
/**
|
||||
* 消息内容
|
||||
*/
|
||||
private String context;
|
||||
|
||||
public void setOperationType(String operationType) {
|
||||
if (!StringUtils.isEmpty(operationType)) {
|
||||
this.operationType = OperationType.valueOf(operationType);
|
||||
}
|
||||
}
|
||||
|
||||
public void setMessageType(String messageType) {
|
||||
if (!StringUtils.isEmpty(messageType)) {
|
||||
this.messageType = MessageTypeEnum.valueOf(messageType);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package cn.lili.modules.im.entity.vo;
|
||||
|
||||
import cn.lili.modules.im.entity.enums.MessageResultType;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* MessageVO
|
||||
*
|
||||
* @author Chopper
|
||||
* @version v1.0
|
||||
* 2021-12-30 15:51
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class MessageVO {
|
||||
|
||||
/**
|
||||
* 消息类型
|
||||
*/
|
||||
private MessageResultType messageResultType;
|
||||
/**
|
||||
* 消息内容
|
||||
*/
|
||||
private Object result;
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package cn.lili.modules.im.entity.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* ReadMessage
|
||||
*
|
||||
* @author Chopper
|
||||
* @version v1.0
|
||||
* 2021-12-31 11:13
|
||||
*/
|
||||
@Data
|
||||
public class ReadMessage {
|
||||
private List<String> readMessageList;
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package cn.lili.modules.im.entity.vo;
|
||||
|
||||
import cn.lili.modules.im.entity.dos.Seat;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 客服VO
|
||||
*
|
||||
* @author Chopper
|
||||
* @version v1.0
|
||||
* 2022-02-10 15:02
|
||||
*/
|
||||
@Data
|
||||
public class SeatVO extends Seat {
|
||||
|
||||
/**
|
||||
* 在线状态
|
||||
*/
|
||||
private String onlineStatus;
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package cn.lili.modules.im.mapper;
|
||||
|
||||
import cn.lili.modules.im.entity.dos.ImMessage;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* Im消息 Dao层
|
||||
* @author Chopper
|
||||
*/
|
||||
public interface ImMessageMapper extends BaseMapper<ImMessage> {
|
||||
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package cn.lili.modules.im.mapper;
|
||||
|
||||
import cn.lili.modules.im.entity.dos.ImTalk;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* 聊天 Dao层
|
||||
* @author Chopper
|
||||
*/
|
||||
public interface ImTalkMapper extends BaseMapper<ImTalk> {
|
||||
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package cn.lili.modules.im.mapper;
|
||||
|
||||
|
||||
import cn.lili.modules.im.entity.dos.QA;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* 问答处理层
|
||||
*
|
||||
* @author pikachu
|
||||
* @since 2020-02-18 15:18:56
|
||||
*/
|
||||
public interface QAMapper extends BaseMapper<QA> {
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package cn.lili.modules.im.mapper;
|
||||
|
||||
|
||||
import cn.lili.modules.im.entity.dos.Seat;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* 坐席处理层
|
||||
*
|
||||
* @author pikachu
|
||||
* @since 2020-02-18 15:18:56
|
||||
*/
|
||||
public interface SeatMapper extends BaseMapper<Seat> {
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package cn.lili.modules.im.mapper;
|
||||
|
||||
|
||||
import cn.lili.modules.im.entity.dos.SeatSetting;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* 坐席设置处理层
|
||||
*
|
||||
* @author pikachu
|
||||
* @since 2020-02-18 15:18:56
|
||||
*/
|
||||
public interface SeatSettingMapper extends BaseMapper<SeatSetting> {
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
package cn.lili.modules.im.service;
|
||||
|
||||
import cn.lili.modules.im.entity.dos.ImMessage;
|
||||
import cn.lili.modules.im.entity.dto.MessageQueryParams;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Im消息 业务层
|
||||
*
|
||||
* @author Chopper
|
||||
*/
|
||||
public interface ImMessageService extends IService<ImMessage> {
|
||||
|
||||
/**
|
||||
* 阅读消息
|
||||
*
|
||||
* @param talkId
|
||||
* @param accessToken
|
||||
*/
|
||||
void read(String talkId, String accessToken);
|
||||
|
||||
/**
|
||||
* 未读消息列表
|
||||
*
|
||||
* @param accessToken
|
||||
*/
|
||||
List<ImMessage> unReadMessages(String accessToken);
|
||||
|
||||
/**
|
||||
* 历史消息
|
||||
*
|
||||
* @param accessToken
|
||||
* @param to
|
||||
*/
|
||||
List<ImMessage> historyMessage(String accessToken, String to);
|
||||
|
||||
/**
|
||||
* 是否有新消息
|
||||
* @param accessToken
|
||||
* @return
|
||||
*/
|
||||
Boolean hasNewMessage(String accessToken);
|
||||
|
||||
/**
|
||||
* 分页获取消息列表
|
||||
* @param messageQueryParams 查询条件
|
||||
* @return 消息列表
|
||||
*/
|
||||
List<ImMessage> getList(MessageQueryParams messageQueryParams);
|
||||
|
||||
/**
|
||||
* 获取所有未读消息
|
||||
* @return
|
||||
*/
|
||||
Long unreadMessageCount();
|
||||
|
||||
/**
|
||||
* 清空所有未读消息
|
||||
*/
|
||||
void cleanUnreadMessage();
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
package cn.lili.modules.im.service;
|
||||
|
||||
import cn.lili.modules.im.entity.dos.ImTalk;
|
||||
import cn.lili.modules.im.entity.vo.ImTalkVO;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 聊天 业务层
|
||||
*
|
||||
* @author Chopper
|
||||
*/
|
||||
public interface ImTalkService extends IService<ImTalk> {
|
||||
|
||||
/**
|
||||
* 获取与某人的聊天框
|
||||
*
|
||||
* @param userId1
|
||||
* @param userId2
|
||||
* @return
|
||||
*/
|
||||
ImTalk getTalkByUser(String userId1, String userId2);
|
||||
|
||||
/**
|
||||
* 置顶消息
|
||||
*
|
||||
* @param id
|
||||
* @param top
|
||||
*/
|
||||
void top(String id, Boolean top);
|
||||
|
||||
/**
|
||||
* 禁用(前端不做展示)聊天
|
||||
*
|
||||
* @param id
|
||||
*/
|
||||
void disable(String id);
|
||||
|
||||
/**
|
||||
* 获取用户聊天列表
|
||||
* @return
|
||||
*/
|
||||
List<ImTalkVO> getUserTalkList(String userName);
|
||||
|
||||
/**
|
||||
* 获取商家聊天列表
|
||||
* @return
|
||||
*/
|
||||
List<ImTalkVO> getStoreTalkList();
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package cn.lili.modules.im.service;
|
||||
|
||||
|
||||
import cn.lili.common.vo.PageVO;
|
||||
import cn.lili.modules.im.entity.dos.QA;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* 问答
|
||||
*
|
||||
* @author pikachu
|
||||
* @since 2020-02-18 16:18:56
|
||||
*/
|
||||
public interface QAService extends IService<QA> {
|
||||
|
||||
/**
|
||||
* 查询店铺问题
|
||||
* @param word
|
||||
* @param pageVO
|
||||
* @return
|
||||
*/
|
||||
IPage<QA> getStoreQA(String word, PageVO pageVO);
|
||||
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
package cn.lili.modules.im.service;
|
||||
|
||||
|
||||
import cn.lili.common.security.token.Token;
|
||||
import cn.lili.modules.im.entity.dos.Seat;
|
||||
import cn.lili.modules.im.entity.vo.SeatVO;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 坐席业务
|
||||
*
|
||||
* @author pikachu
|
||||
* @since 2020-02-18 16:18:56
|
||||
*/
|
||||
public interface SeatService extends IService<Seat> {
|
||||
|
||||
|
||||
/**
|
||||
* 获取坐席列表
|
||||
*
|
||||
* @param storeId 店铺id
|
||||
* @return
|
||||
*/
|
||||
List<SeatVO> seatVoList(String storeId);
|
||||
|
||||
/**
|
||||
* 坐席登录
|
||||
*
|
||||
* @param username
|
||||
* @param password
|
||||
* @return
|
||||
*/
|
||||
Token usernameLogin(String username, String password);
|
||||
|
||||
/**
|
||||
* 快捷登录code 生成
|
||||
*
|
||||
* @param username 用户名
|
||||
* @return
|
||||
*/
|
||||
String createQuickLoginCode(String username);
|
||||
|
||||
/**
|
||||
* 快捷登录
|
||||
*
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
Token quickLogin(String code);
|
||||
|
||||
/**
|
||||
* 查询坐席
|
||||
*
|
||||
* @param username
|
||||
* @return
|
||||
*/
|
||||
Seat findByUsername(String username);
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package cn.lili.modules.im.service;
|
||||
|
||||
import cn.lili.modules.im.entity.dos.SeatSetting;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* 坐席设置业务
|
||||
*
|
||||
* @author pikachu
|
||||
* @since 2020-02-18 16:18:56
|
||||
*/
|
||||
public interface SeatSettingService extends IService<SeatSetting> {
|
||||
|
||||
|
||||
/**
|
||||
* 根据店铺id获取坐席配置
|
||||
*
|
||||
* @param storeId
|
||||
* @return
|
||||
*/
|
||||
SeatSetting getSetting(String storeId);
|
||||
|
||||
/**
|
||||
* 根据店铺修改坐席设置
|
||||
*
|
||||
* @param seatSetting 坐席设置
|
||||
* @return
|
||||
*/
|
||||
SeatSetting updateByStore(SeatSetting seatSetting);
|
||||
}
|
@ -0,0 +1,143 @@
|
||||
package cn.lili.modules.im.serviceimpl;
|
||||
|
||||
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.modules.im.entity.dos.ImMessage;
|
||||
import cn.lili.modules.im.entity.dto.MessageQueryParams;
|
||||
import cn.lili.modules.im.mapper.ImMessageMapper;
|
||||
import cn.lili.modules.im.service.ImMessageService;
|
||||
import cn.lili.modules.im.service.ImTalkService;
|
||||
import cn.lili.mybatis.util.PageUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
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;
|
||||
|
||||
/**
|
||||
* Im消息 业务实现
|
||||
*
|
||||
* @author Chopper
|
||||
*/
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
||||
public class ImMessageServiceImpl extends ServiceImpl<ImMessageMapper, ImMessage> implements ImMessageService {
|
||||
|
||||
@Autowired
|
||||
private ImTalkService imTalkService;
|
||||
|
||||
@Override
|
||||
public void read(String talkId, String accessToken) {
|
||||
LambdaUpdateWrapper<ImMessage> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
String userId = UserContext.getAuthUser(accessToken).getId();
|
||||
updateWrapper.eq(ImMessage::getTalkId, talkId);
|
||||
updateWrapper.eq(ImMessage::getToUser, userId);
|
||||
updateWrapper.set(ImMessage::getIsRead, true);
|
||||
this.update(updateWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ImMessage> unReadMessages(String accessToken) {
|
||||
String userId = UserContext.getAuthUser(accessToken).getId();
|
||||
LambdaQueryWrapper<ImMessage> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(ImMessage::getToUser, userId);
|
||||
queryWrapper.eq(ImMessage::getIsRead, false);
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ImMessage> historyMessage(String accessToken, String to) {
|
||||
String userId = UserContext.getAuthUser(accessToken).getId();
|
||||
LambdaQueryWrapper<ImMessage> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.and(i -> i.eq(ImMessage::getToUser, userId).and(j -> j.eq(ImMessage::getFromUser, to)));
|
||||
queryWrapper.or(i -> i.eq(ImMessage::getToUser, to).and(j -> j.eq(ImMessage::getFromUser, userId)));
|
||||
queryWrapper.orderByDesc(ImMessage::getCreateTime);
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean hasNewMessage(String accessToken) {
|
||||
String userId = UserContext.getAuthUser(accessToken).getId();
|
||||
LambdaQueryWrapper<ImMessage> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(ImMessage::getIsRead, false);
|
||||
queryWrapper.eq(ImMessage::getToUser, userId);
|
||||
return this.list(queryWrapper).size() > 0;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ImMessage> getList(MessageQueryParams messageQueryParams) {
|
||||
List<ImMessage> messageList = this.page(PageUtil.initPage(messageQueryParams), messageQueryParams.initQueryWrapper()).getRecords();
|
||||
ListSort(messageList);
|
||||
readMessage(messageList);
|
||||
return messageList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long unreadMessageCount() {
|
||||
AuthUser currentUser = UserContext.getCurrentUser();
|
||||
if(currentUser == null){
|
||||
throw new ServiceException(ResultCode.USER_NOT_LOGIN);
|
||||
}
|
||||
return this.count(new LambdaQueryWrapper<ImMessage>().eq(ImMessage::getToUser,currentUser.getId()).eq(ImMessage::getIsRead,false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cleanUnreadMessage() {
|
||||
AuthUser currentUser = UserContext.getCurrentUser();
|
||||
if(currentUser == null){
|
||||
throw new ServiceException(ResultCode.USER_NOT_LOGIN);
|
||||
}
|
||||
this.update(new LambdaUpdateWrapper<ImMessage>().eq(ImMessage::getToUser,currentUser.getId()).set(ImMessage::getIsRead,true));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据时间倒叙
|
||||
*
|
||||
* @param list
|
||||
*/
|
||||
private static void ListSort(List<ImMessage> list) {
|
||||
list.sort(new Comparator<ImMessage>() {
|
||||
@Override
|
||||
public int compare(ImMessage e1, ImMessage e2) {
|
||||
try {
|
||||
if (e1.getCreateTime().before(e2.getCreateTime())) {
|
||||
return -1;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 阅读消息
|
||||
*
|
||||
* @param messageList 消息列表
|
||||
*/
|
||||
private void readMessage(List<ImMessage> messageList) {
|
||||
if (messageList.size() > 0) {
|
||||
for (ImMessage imMessage : messageList) {
|
||||
if(Boolean.FALSE.equals(imMessage.getIsRead())){
|
||||
imMessage.setIsRead(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
this.updateBatchById(messageList);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,187 @@
|
||||
package cn.lili.modules.im.serviceimpl;
|
||||
|
||||
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.dos.ImTalk;
|
||||
import cn.lili.modules.im.entity.vo.ImTalkVO;
|
||||
import cn.lili.modules.im.mapper.ImTalkMapper;
|
||||
import cn.lili.modules.im.service.ImMessageService;
|
||||
import cn.lili.modules.im.service.ImTalkService;
|
||||
import cn.lili.modules.member.entity.dos.Member;
|
||||
import cn.lili.modules.member.service.MemberService;
|
||||
import cn.lili.modules.store.entity.dos.Store;
|
||||
import cn.lili.modules.store.service.StoreService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
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.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 聊天 业务实现
|
||||
*
|
||||
* @author Chopper
|
||||
*/
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
||||
public class ImTalkServiceImpl extends ServiceImpl<ImTalkMapper, ImTalk> implements ImTalkService {
|
||||
|
||||
@Autowired
|
||||
private MemberService memberService;
|
||||
|
||||
@Autowired
|
||||
private StoreService storeService;
|
||||
|
||||
@Autowired
|
||||
private ImMessageService imMessageService;
|
||||
|
||||
@Override
|
||||
public ImTalk getTalkByUser(String userId1, String userId2) {
|
||||
LambdaQueryWrapper<ImTalk> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(ImTalk::getUserId2, userId2);
|
||||
queryWrapper.eq(ImTalk::getUserId1, userId1);
|
||||
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);
|
||||
//没有这个用户信息
|
||||
Member other = memberService.getById(userId2);
|
||||
if(other == null){
|
||||
return null;
|
||||
}
|
||||
//自己为店铺其他人必定为用户
|
||||
imTalk = new ImTalk(userId1, userId2, selfStore.getStoreLogo(), other.getFace(), selfStore.getStoreName(), other.getNickName());
|
||||
imTalk.setStoreFlag1(true);
|
||||
}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;
|
||||
}
|
||||
}
|
||||
this.save(imTalk);
|
||||
} else {
|
||||
imTalk = check(imTalk);
|
||||
}
|
||||
return imTalk;
|
||||
}
|
||||
|
||||
/**
|
||||
* 发起聊天后,如果聊天不可见为true,则需要修正
|
||||
*
|
||||
* @param imTalk
|
||||
*/
|
||||
private ImTalk check(ImTalk imTalk) {
|
||||
if (imTalk.getDisable1() || imTalk.getDisable2()) {
|
||||
imTalk.setDisable1(false);
|
||||
imTalk.setDisable2(false);
|
||||
this.updateById(imTalk);
|
||||
|
||||
}
|
||||
return imTalk;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void top(String id, Boolean top) {
|
||||
ImTalk imTalk = this.getById(id);
|
||||
if (imTalk.getUserId1().equals(UserContext.getCurrentUser().getId())) {
|
||||
imTalk.setTop1(top);
|
||||
} else if (imTalk.getUserId2().equals(UserContext.getCurrentUser().getId())) {
|
||||
imTalk.setTop2(top);
|
||||
} else {
|
||||
throw new ServiceException(ResultCode.ERROR);
|
||||
}
|
||||
this.updateById(imTalk);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable(String id) {
|
||||
ImTalk imTalk = this.getById(id);
|
||||
if (imTalk.getUserId1().equals(UserContext.getCurrentUser().getId())) {
|
||||
imTalk.setDisable1(true);
|
||||
this.updateById(imTalk);
|
||||
} else if (imTalk.getUserId2().equals(UserContext.getCurrentUser().getId())) {
|
||||
imTalk.setDisable2(true);
|
||||
this.updateById(imTalk);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ImTalkVO> getUserTalkList(String userName) {
|
||||
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.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());
|
||||
getUnread(imTalkVOList);
|
||||
return imTalkVOList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ImTalkVO> getStoreTalkList() {
|
||||
AuthUser authUser = UserContext.getCurrentUser();
|
||||
if(authUser == null){
|
||||
throw new ServiceException(ResultCode.STORE_NOT_LOGIN_ERROR);
|
||||
}
|
||||
LambdaQueryWrapper<ImTalk> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.and(wq->{
|
||||
wq.like(ImTalk::getUserId1, authUser.getStoreId()).or().like(ImTalk::getUserId2,authUser.getStoreId());
|
||||
});
|
||||
queryWrapper.orderByDesc(ImTalk::getLastTalkTime);
|
||||
List<ImTalk> imTalks = this.list(queryWrapper);
|
||||
|
||||
List<ImTalkVO> imTalkVOList = imTalks.stream().map(imTalk -> {
|
||||
return new ImTalkVO(imTalk, authUser.getStoreId());
|
||||
}).collect(Collectors.toList());
|
||||
getUnread(imTalkVOList);
|
||||
return imTalkVOList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取未读消息数量
|
||||
* @param imTalkVOList
|
||||
*/
|
||||
private void getUnread(List<ImTalkVO> imTalkVOList){
|
||||
if(imTalkVOList.size() > 0){
|
||||
for (ImTalkVO imTalkVO : imTalkVOList) {
|
||||
long count = imMessageService.count(new LambdaQueryWrapper<ImMessage>().eq(ImMessage::getFromUser, imTalkVO.getUserId()).eq(ImMessage::getIsRead, false));
|
||||
imTalkVO.setUnread(count);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package cn.lili.modules.im.serviceimpl;
|
||||
|
||||
import cn.lili.common.security.context.UserContext;
|
||||
import cn.lili.common.vo.PageVO;
|
||||
import cn.lili.modules.im.entity.dos.QA;
|
||||
import cn.lili.modules.im.mapper.QAMapper;
|
||||
import cn.lili.modules.im.service.QAService;
|
||||
import cn.lili.mybatis.util.PageUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* 坐席业务层实现
|
||||
*
|
||||
* @author pikachu
|
||||
* @since 2020-02-18 16:18:56
|
||||
*/
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class QAServiceImpl extends ServiceImpl<QAMapper, QA> implements QAService {
|
||||
|
||||
@Override
|
||||
public IPage<QA> getStoreQA(String word, PageVO pageVo) {
|
||||
LambdaQueryWrapper<QA> qaLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
qaLambdaQueryWrapper.eq(QA::getTenantId, UserContext.getCurrentUser().getTenantId());
|
||||
qaLambdaQueryWrapper.like(QA::getQuestion, word);
|
||||
return this.page(PageUtil.initPage(pageVo), qaLambdaQueryWrapper);
|
||||
}
|
||||
}
|
@ -0,0 +1,111 @@
|
||||
package cn.lili.modules.im.serviceimpl;
|
||||
|
||||
import cn.lili.cache.Cache;
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.exception.ServiceException;
|
||||
import cn.lili.common.security.token.Token;
|
||||
import cn.lili.common.utils.StringUtils;
|
||||
import cn.lili.modules.im.entity.dos.Seat;
|
||||
import cn.lili.modules.im.entity.enums.OnlineStatusEnum;
|
||||
import cn.lili.modules.im.entity.vo.SeatVO;
|
||||
import cn.lili.modules.im.mapper.SeatMapper;
|
||||
import cn.lili.modules.im.service.SeatService;
|
||||
import cn.lili.modules.im.token.SeatTokenGenerate;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 坐席业务层实现
|
||||
*
|
||||
* @author pikachu
|
||||
* @since 2020-02-18 16:18:56
|
||||
*/
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class SeatServiceImpl extends ServiceImpl<SeatMapper, Seat> implements SeatService {
|
||||
|
||||
|
||||
@Autowired
|
||||
private SeatTokenGenerate seatTokenGenerate;
|
||||
|
||||
@Autowired
|
||||
private Cache<String> cache;
|
||||
|
||||
/**
|
||||
* 快捷登录缓存前缀
|
||||
*/
|
||||
private static String prefix = "{quick_login}_";
|
||||
|
||||
|
||||
@Override
|
||||
public List<SeatVO> seatVoList(String storeId) {
|
||||
|
||||
LambdaQueryWrapper<Seat> seatLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
seatLambdaQueryWrapper.eq(Seat::getTenantId, storeId);
|
||||
List<Seat> list = this.list(seatLambdaQueryWrapper);
|
||||
|
||||
//转换模型为VO
|
||||
List<SeatVO> results = list.stream().map(item -> (SeatVO) item).collect(Collectors.toList());
|
||||
//填充坐席当前状态
|
||||
//todo
|
||||
results.forEach(item -> {
|
||||
item.setOnlineStatus(OnlineStatusEnum.ONLINE.name());
|
||||
});
|
||||
return results;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Token usernameLogin(String username, String password) {
|
||||
|
||||
Seat seat = this.findByUsername(username);
|
||||
//判断用户是否存在
|
||||
if (seat == null || !seat.getDisabled()) {
|
||||
throw new ServiceException(ResultCode.ERROR);
|
||||
}
|
||||
//判断密码是否输入正确
|
||||
if (!new BCryptPasswordEncoder().matches(password, seat.getPassword())) {
|
||||
throw new ServiceException(ResultCode.ERROR);
|
||||
}
|
||||
return seatTokenGenerate.createToken(seat, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuickLoginCode(String username) {
|
||||
String code = UUID.randomUUID().toString();
|
||||
cache.put(prefix + code, username, 20L);
|
||||
return code;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Token quickLogin(String code) {
|
||||
String username = cache.get(prefix + code);
|
||||
cache.remove(prefix + code);
|
||||
if (StringUtils.isEmpty(username)) {
|
||||
throw new ServiceException(ResultCode.ERROR);
|
||||
}
|
||||
return seatTokenGenerate.createToken(findByUsername(username), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询坐席
|
||||
*
|
||||
* @param username
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Seat findByUsername(String username) {
|
||||
LambdaQueryWrapper<Seat> seatLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
seatLambdaQueryWrapper.eq(Seat::getUsername, username);
|
||||
return this.getOne(seatLambdaQueryWrapper);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
package cn.lili.modules.im.serviceimpl;
|
||||
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.exception.ServiceException;
|
||||
import cn.lili.modules.im.entity.dos.SeatSetting;
|
||||
import cn.lili.modules.im.mapper.SeatSettingMapper;
|
||||
import cn.lili.modules.im.service.SeatSettingService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* 坐席设置业务层实现
|
||||
*
|
||||
* @author pikachu
|
||||
* @since 2020-02-18 16:18:56
|
||||
*/
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class SeatSettingServiceImpl extends ServiceImpl<SeatSettingMapper, SeatSetting> implements SeatSettingService {
|
||||
@Override
|
||||
public SeatSetting getSetting(String storeId) {
|
||||
LambdaQueryWrapper<SeatSetting> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(SeatSetting::getTenantId, storeId);
|
||||
SeatSetting seatSetting = this.baseMapper.selectOne(queryWrapper);
|
||||
if (seatSetting == null) {
|
||||
seatSetting = new SeatSetting();
|
||||
seatSetting.setOutLineAutoReply("您好,我现在不在线,请您留下关键内容和联系方式,我看到后会立马回电。");
|
||||
seatSetting.setLongTermAutoReply("您好,我正在查阅相关资料,请您稍等。");
|
||||
seatSetting.setWelcome("您好,请问有什么可以帮您?");
|
||||
seatSetting.setTenantId(storeId);
|
||||
this.save(seatSetting);
|
||||
}
|
||||
return seatSetting;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SeatSetting updateByStore(SeatSetting seatSetting) {
|
||||
SeatSetting oldSetting = this.baseMapper.selectById(seatSetting.getId());
|
||||
if (oldSetting.getTenantId().equals(seatSetting.getTenantId())) {
|
||||
this.updateById(seatSetting);
|
||||
} else {
|
||||
throw new ServiceException(ResultCode.ERROR);
|
||||
}
|
||||
return seatSetting;
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package cn.lili.modules.im.token;
|
||||
|
||||
import cn.lili.common.security.AuthUser;
|
||||
import cn.lili.common.security.enums.UserEnums;
|
||||
import cn.lili.common.security.token.Token;
|
||||
import cn.lili.common.security.token.TokenUtil;
|
||||
import cn.lili.common.security.token.base.AbstractTokenGenerate;
|
||||
import cn.lili.modules.im.entity.dos.Seat;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 会员token生成
|
||||
*
|
||||
* @author Chopper
|
||||
* @version v4.0
|
||||
* @since 2020/11/16 10:50
|
||||
*/
|
||||
@Component
|
||||
public class SeatTokenGenerate extends AbstractTokenGenerate<Seat> {
|
||||
@Autowired
|
||||
private TokenUtil tokenUtil;
|
||||
|
||||
@Override
|
||||
public Token createToken(Seat seat, Boolean longTerm) {
|
||||
AuthUser authUser = new AuthUser(
|
||||
seat.getUsername(),
|
||||
seat.getId(),
|
||||
seat.getNickName(),
|
||||
seat.getFace(),
|
||||
UserEnums.SEAT);
|
||||
authUser.setTenantId(seat.getTenantId());
|
||||
//登陆成功生成token
|
||||
return tokenUtil.createToken(seat.getUsername(), authUser, longTerm, UserEnums.SEAT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Token refreshToken(String refreshToken) {
|
||||
return tokenUtil.refreshToken(refreshToken, UserEnums.SEAT);
|
||||
}
|
||||
|
||||
}
|
@ -28,6 +28,9 @@ public class FootPrint extends BaseEntity {
|
||||
@ApiModelProperty(value = "会员ID")
|
||||
private String memberId;
|
||||
|
||||
@ApiModelProperty(value = "店铺Id")
|
||||
private String storeId;
|
||||
|
||||
@ApiModelProperty(value = "商品ID")
|
||||
private String goodsId;
|
||||
|
||||
|
@ -0,0 +1,36 @@
|
||||
package cn.lili.modules.member.entity.dto;
|
||||
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import cn.lili.common.vo.PageVO;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author chc
|
||||
* @since 2022/6/2114:46
|
||||
*/
|
||||
@Data
|
||||
@ApiModel
|
||||
public class FootPrintQueryParams extends PageVO {
|
||||
|
||||
@ApiModelProperty("用户Id")
|
||||
private String memberId;
|
||||
|
||||
@ApiModelProperty("店铺Id")
|
||||
private String storeId;
|
||||
|
||||
public <T> QueryWrapper<T> queryWrapper() {
|
||||
QueryWrapper<T> queryWrapper = new QueryWrapper<>();
|
||||
if (CharSequenceUtil.isNotEmpty(memberId)) {
|
||||
queryWrapper.eq("member_id", memberId);
|
||||
}
|
||||
if (CharSequenceUtil.isNotEmpty(storeId)) {
|
||||
queryWrapper.eq("store_id", storeId);
|
||||
}
|
||||
queryWrapper.eq("delete_flag",false);
|
||||
queryWrapper.orderByDesc("create_time");
|
||||
return queryWrapper;
|
||||
}
|
||||
}
|
@ -2,6 +2,7 @@ package cn.lili.modules.member.service;
|
||||
|
||||
import cn.lili.common.vo.PageVO;
|
||||
import cn.lili.modules.member.entity.dos.FootPrint;
|
||||
import cn.lili.modules.member.entity.dto.FootPrintQueryParams;
|
||||
import cn.lili.modules.search.entity.dos.EsGoodsIndex;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
@ -42,10 +43,10 @@ public interface FootprintService extends IService<FootPrint> {
|
||||
/**
|
||||
* 获取会员浏览历史分页
|
||||
*
|
||||
* @param pageVO 分页
|
||||
* @param params 分页
|
||||
* @return 会员浏览历史列表
|
||||
*/
|
||||
IPage<EsGoodsIndex> footPrintPage(PageVO pageVO);
|
||||
IPage<EsGoodsIndex> footPrintPage(FootPrintQueryParams params);
|
||||
|
||||
/**
|
||||
* 获取当前会员的浏览记录数量
|
||||
@ -53,4 +54,5 @@ public interface FootprintService extends IService<FootPrint> {
|
||||
* @return 当前会员的浏览记录数量
|
||||
*/
|
||||
long getFootprintNum();
|
||||
|
||||
}
|
@ -252,7 +252,6 @@ public interface MemberService extends IService<Member> {
|
||||
void logout(UserEnums userEnums);
|
||||
|
||||
/**
|
||||
* <<<<<<< HEAD
|
||||
* 修改会员是否拥有店铺
|
||||
*
|
||||
* @param haveStore 是否拥有店铺
|
||||
|
@ -3,6 +3,7 @@ package cn.lili.modules.member.serviceimpl;
|
||||
import cn.lili.common.security.context.UserContext;
|
||||
import cn.lili.common.vo.PageVO;
|
||||
import cn.lili.modules.member.entity.dos.FootPrint;
|
||||
import cn.lili.modules.member.entity.dto.FootPrintQueryParams;
|
||||
import cn.lili.modules.member.mapper.FootprintMapper;
|
||||
import cn.lili.modules.member.service.FootprintService;
|
||||
import cn.lili.modules.search.entity.dos.EsGoodsIndex;
|
||||
@ -43,19 +44,17 @@ public class FootprintServiceImpl extends ServiceImpl<FootprintMapper, FootPrint
|
||||
queryWrapper.eq(FootPrint::getGoodsId, footPrint.getGoodsId());
|
||||
//如果已存在某商品记录,则更新其修改时间
|
||||
//如果不存在则添加记录
|
||||
//为了保证足迹的排序,将原本足迹删除后重新添加
|
||||
List<FootPrint> oldPrints = list(queryWrapper);
|
||||
if (oldPrints != null && !oldPrints.isEmpty()) {
|
||||
FootPrint oldPrint = oldPrints.get(0);
|
||||
oldPrint.setSkuId(footPrint.getSkuId());
|
||||
this.updateById(oldPrint);
|
||||
return oldPrint;
|
||||
} else {
|
||||
footPrint.setCreateTime(new Date());
|
||||
this.save(footPrint);
|
||||
//删除超过100条后的记录
|
||||
this.baseMapper.deleteLastFootPrint(footPrint.getMemberId());
|
||||
return footPrint;
|
||||
this.removeById(oldPrint.getId());
|
||||
}
|
||||
footPrint.setCreateTime(new Date());
|
||||
this.save(footPrint);
|
||||
//删除超过100条后的记录
|
||||
this.baseMapper.deleteLastFootPrint(footPrint.getMemberId());
|
||||
return footPrint;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -74,15 +73,8 @@ public class FootprintServiceImpl extends ServiceImpl<FootprintMapper, FootPrint
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<EsGoodsIndex> footPrintPage(PageVO pageVO) {
|
||||
|
||||
LambdaQueryWrapper<FootPrint> lambdaQueryWrapper = Wrappers.lambdaQuery();
|
||||
lambdaQueryWrapper.eq(FootPrint::getMemberId, UserContext.getCurrentUser().getId());
|
||||
lambdaQueryWrapper.eq(FootPrint::getDeleteFlag, false);
|
||||
lambdaQueryWrapper.orderByDesc(FootPrint::getCreateTime);
|
||||
IPage<FootPrint> footPrintPages = this.page(PageUtil.initPage(pageVO), lambdaQueryWrapper);
|
||||
|
||||
|
||||
public IPage<EsGoodsIndex> footPrintPage(FootPrintQueryParams params) {
|
||||
IPage<FootPrint> footPrintPages = this.page(PageUtil.initPage(params), params.queryWrapper());
|
||||
//定义结果
|
||||
IPage<EsGoodsIndex> esGoodsIndexIPage = new Page<>();
|
||||
|
||||
@ -90,7 +82,7 @@ public class FootprintServiceImpl extends ServiceImpl<FootprintMapper, FootPrint
|
||||
return esGoodsIndexIPage;
|
||||
} else {
|
||||
List<EsGoodsIndex> list = esGoodsSearchService.getEsGoodsBySkuIds(
|
||||
footPrintPages.getRecords().stream().map(FootPrint::getSkuId).collect(Collectors.toList()), pageVO);
|
||||
footPrintPages.getRecords().stream().map(FootPrint::getSkuId).collect(Collectors.toList()), params);
|
||||
|
||||
esGoodsIndexIPage.setPages(footPrintPages.getPages());
|
||||
esGoodsIndexIPage.setRecords(list);
|
||||
|
@ -40,13 +40,16 @@ import cn.lili.modules.store.entity.dos.Store;
|
||||
import cn.lili.modules.store.entity.enums.StoreStatusEnum;
|
||||
import cn.lili.modules.store.service.StoreService;
|
||||
import cn.lili.mybatis.util.PageUtil;
|
||||
import cn.lili.rocketmq.RocketmqSendCallbackBuilder;
|
||||
import cn.lili.rocketmq.tags.MemberTagsEnum;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.apache.rocketmq.spring.core.RocketMQTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
@ -94,6 +97,9 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, Member> impleme
|
||||
@Autowired
|
||||
private RocketmqCustomProperties rocketmqCustomProperties;
|
||||
|
||||
@Autowired
|
||||
private RocketMQTemplate rocketMQTemplate;
|
||||
|
||||
@Autowired
|
||||
private ApplicationEventPublisher applicationEventPublisher;
|
||||
/**
|
||||
@ -183,7 +189,8 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, Member> impleme
|
||||
@Override
|
||||
public Token usernameStoreLogin(String username, String password) {
|
||||
|
||||
Member member = this.findMember(username);
|
||||
// Member member = this.findMember(username);
|
||||
Member member = this.getOne(new LambdaQueryWrapper<Member>().eq(Member::getMobile,username));
|
||||
//判断用户是否存在
|
||||
if (member == null || !member.getDisabled()) {
|
||||
throw new ServiceException(ResultCode.USER_NOT_EXIST);
|
||||
@ -301,6 +308,9 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, Member> impleme
|
||||
BeanUtil.copyProperties(memberEditDTO, member);
|
||||
//修改会员
|
||||
this.updateById(member);
|
||||
String destination = rocketmqCustomProperties.getMemberTopic() + ":" + MemberTagsEnum.MEMBER_INFO_EDIT.name();
|
||||
//发送订单变更mq消息
|
||||
rocketMQTemplate.asyncSend(destination, member, RocketmqSendCallbackBuilder.commonCallback());
|
||||
return member;
|
||||
}
|
||||
|
||||
|
@ -11,6 +11,7 @@ import cn.lili.modules.order.order.entity.vo.OrderVO;
|
||||
import cn.lili.modules.order.order.entity.vo.ReceiptVO;
|
||||
import cn.lili.modules.promotion.entity.dos.MemberCoupon;
|
||||
import cn.lili.modules.promotion.entity.vos.MemberCouponVO;
|
||||
import cn.lili.modules.store.entity.dos.StoreAddress;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@ -106,6 +107,10 @@ public class TradeDTO implements Serializable {
|
||||
*/
|
||||
private MemberAddress memberAddress;
|
||||
|
||||
/**
|
||||
* 自提地址
|
||||
*/
|
||||
private StoreAddress storeAddress;
|
||||
|
||||
/**
|
||||
* 客户端类型
|
||||
|
@ -160,35 +160,37 @@ public class CheckDataRender implements CartRenderStep {
|
||||
private void groupStore(TradeDTO tradeDTO) {
|
||||
//渲染的购物车
|
||||
List<CartVO> cartList = new ArrayList<>();
|
||||
|
||||
//根据店铺分组
|
||||
Map<String, List<CartSkuVO>> storeCollect = tradeDTO.getSkuList().stream().collect(Collectors.groupingBy(CartSkuVO::getStoreId));
|
||||
for (Map.Entry<String, List<CartSkuVO>> storeCart : storeCollect.entrySet()) {
|
||||
if (!storeCart.getValue().isEmpty()) {
|
||||
CartVO cartVO = new CartVO(storeCart.getValue().get(0));
|
||||
if (CharSequenceUtil.isEmpty(cartVO.getDeliveryMethod())) {
|
||||
cartVO.setDeliveryMethod(DeliveryMethodEnum.LOGISTICS.name());
|
||||
}
|
||||
cartVO.setSkuList(storeCart.getValue());
|
||||
try {
|
||||
//筛选属于当前店铺的优惠券
|
||||
storeCart.getValue().forEach(i -> i.getPromotionMap().forEach((key, value) -> {
|
||||
if (key.contains(PromotionTypeEnum.COUPON.name())) {
|
||||
JSONObject promotionsObj = JSONUtil.parseObj(value);
|
||||
Coupon coupon = JSONUtil.toBean(promotionsObj, Coupon.class);
|
||||
if (key.contains(PromotionTypeEnum.COUPON.name()) && coupon.getStoreId().equals(storeCart.getKey())) {
|
||||
cartVO.getCanReceiveCoupon().add(new CouponVO(coupon));
|
||||
if(tradeDTO.getCartList() == null || tradeDTO.getCartList().size() == 0){
|
||||
//根据店铺分组
|
||||
Map<String, List<CartSkuVO>> storeCollect = tradeDTO.getSkuList().stream().collect(Collectors.groupingBy(CartSkuVO::getStoreId));
|
||||
for (Map.Entry<String, List<CartSkuVO>> storeCart : storeCollect.entrySet()) {
|
||||
if (!storeCart.getValue().isEmpty()) {
|
||||
CartVO cartVO = new CartVO(storeCart.getValue().get(0));
|
||||
if (CharSequenceUtil.isEmpty(cartVO.getDeliveryMethod())) {
|
||||
cartVO.setDeliveryMethod(DeliveryMethodEnum.LOGISTICS.name());
|
||||
}
|
||||
cartVO.setSkuList(storeCart.getValue());
|
||||
try {
|
||||
//筛选属于当前店铺的优惠券
|
||||
storeCart.getValue().forEach(i -> i.getPromotionMap().forEach((key, value) -> {
|
||||
if (key.contains(PromotionTypeEnum.COUPON.name())) {
|
||||
JSONObject promotionsObj = JSONUtil.parseObj(value);
|
||||
Coupon coupon = JSONUtil.toBean(promotionsObj, Coupon.class);
|
||||
if (key.contains(PromotionTypeEnum.COUPON.name()) && coupon.getStoreId().equals(storeCart.getKey())) {
|
||||
cartVO.getCanReceiveCoupon().add(new CouponVO(coupon));
|
||||
}
|
||||
}
|
||||
}
|
||||
}));
|
||||
} catch (Exception e) {
|
||||
log.error("筛选属于当前店铺的优惠券发生异常!", e);
|
||||
}));
|
||||
} catch (Exception e) {
|
||||
log.error("筛选属于当前店铺的优惠券发生异常!", e);
|
||||
}
|
||||
storeCart.getValue().stream().filter(i -> Boolean.TRUE.equals(i.getChecked())).findFirst().ifPresent(cartSkuVO -> cartVO.setChecked(true));
|
||||
cartList.add(cartVO);
|
||||
}
|
||||
storeCart.getValue().stream().filter(i -> Boolean.TRUE.equals(i.getChecked())).findFirst().ifPresent(cartSkuVO -> cartVO.setChecked(true));
|
||||
cartList.add(cartVO);
|
||||
}
|
||||
tradeDTO.setCartList(cartList);
|
||||
}
|
||||
tradeDTO.setCartList(cartList);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3,10 +3,12 @@ package cn.lili.modules.order.cart.render.impl;
|
||||
import cn.lili.common.utils.CurrencyUtil;
|
||||
import cn.lili.modules.member.entity.dos.MemberAddress;
|
||||
import cn.lili.modules.order.cart.entity.dto.TradeDTO;
|
||||
import cn.lili.modules.order.cart.entity.enums.DeliveryMethodEnum;
|
||||
import cn.lili.modules.order.cart.entity.enums.RenderStepEnums;
|
||||
import cn.lili.modules.order.cart.entity.vo.CartSkuVO;
|
||||
import cn.lili.modules.order.cart.render.CartRenderStep;
|
||||
import cn.lili.modules.store.entity.dos.FreightTemplateChild;
|
||||
import cn.lili.modules.store.entity.dos.StoreAddress;
|
||||
import cn.lili.modules.store.entity.dto.FreightTemplateChildDTO;
|
||||
import cn.lili.modules.store.entity.enums.FreightTemplateEnum;
|
||||
import cn.lili.modules.store.entity.vos.FreightTemplateVO;
|
||||
@ -42,71 +44,77 @@ public class SkuFreightRender implements CartRenderStep {
|
||||
List<CartSkuVO> cartSkuVOS = tradeDTO.getCheckedSkuList();
|
||||
//会员收货地址问题处理
|
||||
MemberAddress memberAddress = tradeDTO.getMemberAddress();
|
||||
StoreAddress storeAddress = tradeDTO.getStoreAddress();
|
||||
//如果收货地址为空,则抛出异常
|
||||
if (memberAddress == null) {
|
||||
if (memberAddress == null && storeAddress == null) {
|
||||
return;
|
||||
}
|
||||
//运费分组信息
|
||||
Map<String, List<String>> freightGroups = freightTemplateGrouping(cartSkuVOS);
|
||||
//选择物流的时候计算价格
|
||||
if(DeliveryMethodEnum.LOGISTICS.name().equals(tradeDTO.getCartList().get(0).getDeliveryMethod())){
|
||||
if (memberAddress != null) {
|
||||
//运费分组信息
|
||||
Map<String, List<String>> freightGroups = freightTemplateGrouping(cartSkuVOS);
|
||||
|
||||
//循环运费模版
|
||||
for (Map.Entry<String, List<String>> freightTemplateGroup : freightGroups.entrySet()) {
|
||||
//循环运费模版
|
||||
for (Map.Entry<String, List<String>> freightTemplateGroup : freightGroups.entrySet()) {
|
||||
|
||||
//商品id列表
|
||||
List<String> skuIds = freightTemplateGroup.getValue();
|
||||
//商品id列表
|
||||
List<String> skuIds = freightTemplateGroup.getValue();
|
||||
|
||||
//当前购物车商品列表
|
||||
List<CartSkuVO> currentCartSkus = cartSkuVOS.stream().filter(item -> skuIds.contains(item.getGoodsSku().getId())).collect(Collectors.toList());
|
||||
//当前购物车商品列表
|
||||
List<CartSkuVO> currentCartSkus = cartSkuVOS.stream().filter(item -> skuIds.contains(item.getGoodsSku().getId())).collect(Collectors.toList());
|
||||
|
||||
//寻找对应对商品运费计算模版
|
||||
FreightTemplateVO freightTemplate = freightTemplateService.getFreightTemplate(freightTemplateGroup.getKey());
|
||||
if (freightTemplate != null
|
||||
&& freightTemplate.getFreightTemplateChildList() != null
|
||||
&& !freightTemplate.getFreightTemplateChildList().isEmpty()) {
|
||||
//店铺模版免运费则跳过
|
||||
if (freightTemplate.getPricingMethod().equals(FreightTemplateEnum.FREE.name())) {
|
||||
break;
|
||||
}
|
||||
//寻找对应对商品运费计算模版
|
||||
FreightTemplateVO freightTemplate = freightTemplateService.getFreightTemplate(freightTemplateGroup.getKey());
|
||||
if (freightTemplate != null
|
||||
&& freightTemplate.getFreightTemplateChildList() != null
|
||||
&& !freightTemplate.getFreightTemplateChildList().isEmpty()) {
|
||||
//店铺模版免运费则跳过
|
||||
if (freightTemplate.getPricingMethod().equals(FreightTemplateEnum.FREE.name())) {
|
||||
break;
|
||||
}
|
||||
|
||||
//运费模版
|
||||
FreightTemplateChild freightTemplateChild = null;
|
||||
//运费模版
|
||||
FreightTemplateChild freightTemplateChild = null;
|
||||
|
||||
//获取市级别id匹配运费模版
|
||||
String addressId = memberAddress.getConsigneeAddressIdPath().split(",")[1];
|
||||
for (FreightTemplateChild templateChild : freightTemplate.getFreightTemplateChildList()) {
|
||||
//模版匹配判定
|
||||
if (templateChild.getAreaId().contains(addressId)) {
|
||||
freightTemplateChild = templateChild;
|
||||
break;
|
||||
//获取市级别id匹配运费模版
|
||||
String addressId = memberAddress.getConsigneeAddressIdPath().split(",")[1];
|
||||
for (FreightTemplateChild templateChild : freightTemplate.getFreightTemplateChildList()) {
|
||||
//模版匹配判定
|
||||
if (templateChild.getAreaId().contains(addressId)) {
|
||||
freightTemplateChild = templateChild;
|
||||
break;
|
||||
}
|
||||
}
|
||||
//如果没有匹配到物流规则,则说明不支持配送
|
||||
if (freightTemplateChild == null) {
|
||||
if (tradeDTO.getNotSupportFreight() == null) {
|
||||
tradeDTO.setNotSupportFreight(new ArrayList<>());
|
||||
}
|
||||
tradeDTO.getNotSupportFreight().addAll(currentCartSkus);
|
||||
continue;
|
||||
}
|
||||
|
||||
//物流规则模型创立
|
||||
FreightTemplateChildDTO freightTemplateChildDTO = new FreightTemplateChildDTO(freightTemplateChild);
|
||||
//模型写入运费模版设置的计费方式
|
||||
freightTemplateChildDTO.setPricingMethod(freightTemplate.getPricingMethod());
|
||||
|
||||
//计算运费总数
|
||||
Double count = currentCartSkus.stream().mapToDouble(item ->
|
||||
// 根据计费规则 累加计费基数
|
||||
freightTemplateChildDTO.getPricingMethod().equals(FreightTemplateEnum.NUM.name()) ?
|
||||
item.getNum().doubleValue() :
|
||||
CurrencyUtil.mul(item.getNum(), item.getGoodsSku().getWeight())
|
||||
).sum();
|
||||
|
||||
//计算运费
|
||||
Double countFreight = countFreight(count, freightTemplateChildDTO);
|
||||
|
||||
//写入SKU运费
|
||||
resetFreightPrice(FreightTemplateEnum.valueOf(freightTemplateChildDTO.getPricingMethod()), count, countFreight, currentCartSkus);
|
||||
}
|
||||
}
|
||||
//如果没有匹配到物流规则,则说明不支持配送
|
||||
if (freightTemplateChild == null) {
|
||||
if (tradeDTO.getNotSupportFreight() == null) {
|
||||
tradeDTO.setNotSupportFreight(new ArrayList<>());
|
||||
}
|
||||
tradeDTO.getNotSupportFreight().addAll(currentCartSkus);
|
||||
continue;
|
||||
}
|
||||
|
||||
//物流规则模型创立
|
||||
FreightTemplateChildDTO freightTemplateChildDTO = new FreightTemplateChildDTO(freightTemplateChild);
|
||||
//模型写入运费模版设置的计费方式
|
||||
freightTemplateChildDTO.setPricingMethod(freightTemplate.getPricingMethod());
|
||||
|
||||
//计算运费总数
|
||||
Double count = currentCartSkus.stream().mapToDouble(item ->
|
||||
// 根据计费规则 累加计费基数
|
||||
freightTemplateChildDTO.getPricingMethod().equals(FreightTemplateEnum.NUM.name()) ?
|
||||
item.getNum().doubleValue() :
|
||||
CurrencyUtil.mul(item.getNum(), item.getGoodsSku().getWeight())
|
||||
).sum();
|
||||
|
||||
//计算运费
|
||||
Double countFreight = countFreight(count, freightTemplateChildDTO);
|
||||
|
||||
//写入SKU运费
|
||||
resetFreightPrice(FreightTemplateEnum.valueOf(freightTemplateChildDTO.getPricingMethod()), count, countFreight, currentCartSkus);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,8 @@ import cn.lili.modules.order.cart.entity.vo.TradeParams;
|
||||
import cn.lili.modules.order.order.entity.dos.Trade;
|
||||
import cn.lili.modules.order.order.entity.vo.ReceiptVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 购物车业务层
|
||||
*
|
||||
@ -111,6 +113,14 @@ public interface CartService {
|
||||
*/
|
||||
void shippingAddress(String shippingAddressId, String way);
|
||||
|
||||
/**
|
||||
* 选择自提地址
|
||||
*
|
||||
* @param shopAddressId 收货地址id
|
||||
* @param way 购物车类型
|
||||
*/
|
||||
void shippingSelfAddress(String shopAddressId, String way);
|
||||
|
||||
/**
|
||||
* 选择发票
|
||||
*
|
||||
@ -123,11 +133,10 @@ public interface CartService {
|
||||
/**
|
||||
* 选择配送方式
|
||||
*
|
||||
* @param storeId 店铺id
|
||||
* @param deliveryMethod 配送方式
|
||||
* @param way 购物车类型
|
||||
*/
|
||||
void shippingMethod(String storeId, String deliveryMethod, String way);
|
||||
void shippingMethod(String deliveryMethod, String way);
|
||||
|
||||
/**
|
||||
* 获取购物车商品数量
|
||||
@ -160,4 +169,11 @@ public interface CartService {
|
||||
* @return 交易信息
|
||||
*/
|
||||
Trade createTrade(TradeParams tradeParams);
|
||||
|
||||
/***
|
||||
* 获取可使用的配送方式
|
||||
* @param way
|
||||
* @return
|
||||
*/
|
||||
List<String> shippingMethodList(String way);
|
||||
}
|
||||
|
@ -46,6 +46,10 @@ import cn.lili.modules.promotion.service.PointsGoodsService;
|
||||
import cn.lili.modules.promotion.service.PromotionGoodsService;
|
||||
import cn.lili.modules.search.entity.dos.EsGoodsIndex;
|
||||
import cn.lili.modules.search.service.EsGoodsSearchService;
|
||||
import cn.lili.modules.store.entity.dos.Store;
|
||||
import cn.lili.modules.store.entity.dos.StoreAddress;
|
||||
import cn.lili.modules.store.service.StoreAddressService;
|
||||
import cn.lili.modules.store.service.StoreService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -116,6 +120,12 @@ public class CartServiceImpl implements CartService {
|
||||
@Autowired
|
||||
private WholesaleService wholesaleService;
|
||||
|
||||
@Autowired
|
||||
private StoreService storeService;
|
||||
|
||||
@Autowired
|
||||
private StoreAddressService storeAddressService;
|
||||
|
||||
@Override
|
||||
public void add(String skuId, Integer num, String cartType, Boolean cover) {
|
||||
AuthUser currentUser = Objects.requireNonNull(UserContext.getCurrentUser());
|
||||
@ -438,6 +448,20 @@ public class CartServiceImpl implements CartService {
|
||||
this.resetTradeDTO(tradeDTO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shippingSelfAddress(String shopAddressId, String way) {
|
||||
//默认购物车
|
||||
CartTypeEnum cartTypeEnum = CartTypeEnum.CART;
|
||||
if (CharSequenceUtil.isNotEmpty(way)) {
|
||||
cartTypeEnum = CartTypeEnum.valueOf(way);
|
||||
}
|
||||
|
||||
TradeDTO tradeDTO = this.readDTO(cartTypeEnum);
|
||||
StoreAddress storeAddress = storeAddressService.getById(shopAddressId);
|
||||
tradeDTO.setStoreAddress(storeAddress);
|
||||
this.resetTradeDTO(tradeDTO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 选择发票
|
||||
*
|
||||
@ -459,23 +483,21 @@ public class CartServiceImpl implements CartService {
|
||||
/**
|
||||
* 选择配送方式
|
||||
*
|
||||
* @param storeId 店铺id
|
||||
* @param deliveryMethod 配送方式
|
||||
* @param way 购物车类型
|
||||
*/
|
||||
@Override
|
||||
public void shippingMethod(String storeId, String deliveryMethod, String way) {
|
||||
public void shippingMethod(String deliveryMethod, String way) {
|
||||
CartTypeEnum cartTypeEnum = CartTypeEnum.CART;
|
||||
if (CharSequenceUtil.isNotEmpty(way)) {
|
||||
cartTypeEnum = CartTypeEnum.valueOf(way);
|
||||
}
|
||||
TradeDTO tradeDTO = this.readDTO(cartTypeEnum);
|
||||
TradeDTO tradeDTO = this.getCheckedTradeDTO(cartTypeEnum);
|
||||
for (CartVO cartVO : tradeDTO.getCartList()) {
|
||||
if (cartVO.getStoreId().equals(storeId)) {
|
||||
cartVO.setDeliveryMethod(DeliveryMethodEnum.valueOf(deliveryMethod).name());
|
||||
}
|
||||
cartVO.setDeliveryMethod(DeliveryMethodEnum.valueOf(deliveryMethod).name());
|
||||
}
|
||||
this.resetTradeDTO(tradeDTO);
|
||||
TradeDTO neTradeDTO = (TradeDTO) cache.get(this.getOriginKey(cartTypeEnum));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -547,8 +569,10 @@ public class CartServiceImpl implements CartService {
|
||||
tradeDTO.setStoreRemark(tradeParams.getRemark());
|
||||
tradeDTO.setParentOrderSn(tradeParams.getParentOrderSn());
|
||||
//订单无收货地址校验
|
||||
if (tradeDTO.getMemberAddress() == null) {
|
||||
throw new ServiceException(ResultCode.MEMBER_ADDRESS_NOT_EXIST);
|
||||
if(tradeDTO.getStoreAddress() == null){
|
||||
if (tradeDTO.getMemberAddress() == null) {
|
||||
throw new ServiceException(ResultCode.MEMBER_ADDRESS_NOT_EXIST);
|
||||
}
|
||||
}
|
||||
//构建交易
|
||||
Trade trade = tradeBuilder.createTrade(tradeDTO);
|
||||
@ -556,6 +580,22 @@ public class CartServiceImpl implements CartService {
|
||||
return trade;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> shippingMethodList(String way) {
|
||||
List<String> list = new ArrayList<String>();
|
||||
list.add(DeliveryMethodEnum.LOGISTICS.name());
|
||||
TradeDTO tradeDTO = this.getCheckedTradeDTO(CartTypeEnum.valueOf(way));
|
||||
if(tradeDTO.getCartList().size()==1){
|
||||
for (CartVO cartVO : tradeDTO.getCartList()) {
|
||||
Store store = storeService.getById(cartVO.getStoreId());
|
||||
if(store.getSelfPickFlag() != null && store.getSelfPickFlag()){
|
||||
list.add(DeliveryMethodEnum.SELF_PICK_UP.name());
|
||||
}
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取购物车类型
|
||||
|
@ -210,6 +210,15 @@ public class Order extends BaseEntity {
|
||||
@ApiModelProperty(value = "qrCode 实物为提货码 虚拟货物为账号")
|
||||
private String qrCode;
|
||||
|
||||
@ApiModelProperty(value = "自提点地址")
|
||||
private String storeAddressPath;
|
||||
|
||||
@ApiModelProperty(value = "自提点电话")
|
||||
private String storeAddressMobile;
|
||||
|
||||
@ApiModelProperty(value = "自提点地址经纬度")
|
||||
private String storeAddressCenter;
|
||||
|
||||
/**
|
||||
* 构建订单
|
||||
*
|
||||
@ -233,11 +242,19 @@ public class Order extends BaseEntity {
|
||||
this.setRemark(cartVO.getRemark());
|
||||
this.setFreightPrice(tradeDTO.getPriceDetailDTO().getFreightPrice());
|
||||
//会员收件信息
|
||||
this.setConsigneeAddressIdPath(tradeDTO.getMemberAddress().getConsigneeAddressIdPath());
|
||||
this.setConsigneeAddressPath(tradeDTO.getMemberAddress().getConsigneeAddressPath());
|
||||
this.setConsigneeDetail(tradeDTO.getMemberAddress().getDetail());
|
||||
this.setConsigneeMobile(tradeDTO.getMemberAddress().getMobile());
|
||||
this.setConsigneeName(tradeDTO.getMemberAddress().getName());
|
||||
if(DeliveryMethodEnum.LOGISTICS.name().equals(cartVO.getDeliveryMethod())){
|
||||
this.setConsigneeAddressIdPath(tradeDTO.getMemberAddress().getConsigneeAddressIdPath());
|
||||
this.setConsigneeAddressPath(tradeDTO.getMemberAddress().getConsigneeAddressPath());
|
||||
this.setConsigneeDetail(tradeDTO.getMemberAddress().getDetail());
|
||||
this.setConsigneeMobile(tradeDTO.getMemberAddress().getMobile());
|
||||
this.setConsigneeName(tradeDTO.getMemberAddress().getName());
|
||||
}
|
||||
//自提点信息
|
||||
if(DeliveryMethodEnum.SELF_PICK_UP.name().equals(cartVO.getDeliveryMethod())){
|
||||
this.setStoreAddressPath(tradeDTO.getStoreAddress().getAddress());
|
||||
this.setStoreAddressMobile(tradeDTO.getStoreAddress().getMobile());
|
||||
this.setStoreAddressCenter(tradeDTO.getStoreAddress().getCenter());
|
||||
}
|
||||
//平台优惠券判定
|
||||
if (tradeDTO.getPlatformCoupon() != null) {
|
||||
this.setUsePlatformMemberCouponId(tradeDTO.getPlatformCoupon().getMemberCoupon().getId());
|
||||
|
@ -16,6 +16,7 @@ public enum OrderStatusEnum {
|
||||
UNDELIVERED("待发货"),
|
||||
DELIVERED("已发货"),
|
||||
COMPLETED("已完成"),
|
||||
STAY_PICKED_UP("待自提"),
|
||||
/**
|
||||
* 虚拟订单需要核验商品
|
||||
*/
|
||||
|
@ -63,7 +63,7 @@ public class AllowOperation implements Serializable {
|
||||
}
|
||||
|
||||
//新订单
|
||||
if (CharSequenceUtil.equalsAny(status, OrderStatusEnum.UNPAID.name(), OrderStatusEnum.PAID.name(), OrderStatusEnum.UNDELIVERED.name())) {
|
||||
if (CharSequenceUtil.equalsAny(status, OrderStatusEnum.UNPAID.name(), OrderStatusEnum.PAID.name(), OrderStatusEnum.UNDELIVERED.name(), OrderStatusEnum.STAY_PICKED_UP.name())) {
|
||||
this.cancel = true;
|
||||
}
|
||||
//新订单,允许支付
|
||||
|
@ -183,6 +183,15 @@ public interface OrderService extends IService<Order> {
|
||||
*/
|
||||
Order take(String orderSn, String verificationCode);
|
||||
|
||||
|
||||
/**
|
||||
* 订单核验
|
||||
*
|
||||
* @param verificationCode 验证码
|
||||
* @return 订单
|
||||
*/
|
||||
Order take(String verificationCode);
|
||||
|
||||
/**
|
||||
* 根据核验码获取订单信息
|
||||
*
|
||||
|
@ -16,10 +16,12 @@ import cn.lili.common.properties.RocketmqCustomProperties;
|
||||
import cn.lili.common.security.OperationalJudgment;
|
||||
import cn.lili.common.security.context.UserContext;
|
||||
import cn.lili.common.security.enums.UserEnums;
|
||||
import cn.lili.common.utils.ObjectUtil;
|
||||
import cn.lili.common.utils.SnowFlake;
|
||||
import cn.lili.modules.goods.entity.dto.GoodsCompleteMessage;
|
||||
import cn.lili.modules.member.entity.dto.MemberAddressDTO;
|
||||
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;
|
||||
import cn.lili.modules.order.order.entity.dos.*;
|
||||
import cn.lili.modules.order.order.entity.dto.OrderBatchDeliverDTO;
|
||||
@ -290,12 +292,13 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
||||
Order order = OperationalJudgment.judgment(this.getBySn(orderSn));
|
||||
//如果订单促销类型不为空&&订单是拼团订单,并且订单未成团,则抛出异常
|
||||
if (OrderPromotionTypeEnum.PINTUAN.name().equals(order.getOrderPromotionType())
|
||||
&& !order.getOrderStatus().equals(OrderStatusEnum.UNDELIVERED.name())) {
|
||||
&& !CharSequenceUtil.equalsAny(order.getOrderStatus(),OrderStatusEnum.UNDELIVERED.name(),OrderStatusEnum.STAY_PICKED_UP.name())) {
|
||||
throw new ServiceException(ResultCode.ORDER_CAN_NOT_CANCEL);
|
||||
}
|
||||
if (CharSequenceUtil.equalsAny(order.getOrderStatus(),
|
||||
OrderStatusEnum.UNDELIVERED.name(),
|
||||
OrderStatusEnum.UNPAID.name(),
|
||||
OrderStatusEnum.STAY_PICKED_UP.name(),
|
||||
OrderStatusEnum.PAID.name())) {
|
||||
|
||||
order.setOrderStatus(OrderStatusEnum.CANCELLED.name());
|
||||
@ -472,11 +475,24 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
||||
return order;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Order take(String verificationCode) {
|
||||
String storeId = OperationalJudgment.judgment(UserContext.getCurrentUser()).getStoreId();
|
||||
Order order = this.getOne(new LambdaQueryWrapper<Order>().eq(Order::getVerificationCode, verificationCode).eq(Order::getStoreId, storeId));
|
||||
if(order == null){
|
||||
throw new ServiceException(ResultCode.ORDER_NOT_EXIST);
|
||||
}
|
||||
order.setOrderStatus(OrderStatusEnum.COMPLETED.name());
|
||||
//订单完成
|
||||
this.complete(order.getSn());
|
||||
return order;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Order getOrderByVerificationCode(String verificationCode) {
|
||||
String storeId = Objects.requireNonNull(UserContext.getCurrentUser()).getStoreId();
|
||||
return this.getOne(new LambdaQueryWrapper<Order>()
|
||||
.eq(Order::getOrderStatus, OrderStatusEnum.TAKE.name())
|
||||
.in(Order::getOrderStatus, OrderStatusEnum.TAKE.name(),OrderStatusEnum.STAY_PICKED_UP.name())
|
||||
.eq(Order::getStoreId, storeId)
|
||||
.eq(Order::getVerificationCode, verificationCode));
|
||||
}
|
||||
@ -938,13 +954,20 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void normalOrderConfirm(String orderSn) {
|
||||
OrderStatusEnum orderStatusEnum = null;
|
||||
Order order = this.getBySn(orderSn);
|
||||
if(DeliveryMethodEnum.SELF_PICK_UP.name().equals(order.getDeliveryMethod())){
|
||||
orderStatusEnum = OrderStatusEnum.STAY_PICKED_UP;
|
||||
}else if (DeliveryMethodEnum.LOGISTICS.name().equals(order.getDeliveryMethod())){
|
||||
orderStatusEnum = OrderStatusEnum.UNDELIVERED;
|
||||
}
|
||||
//修改订单
|
||||
this.update(new LambdaUpdateWrapper<Order>()
|
||||
.eq(Order::getSn, orderSn)
|
||||
.set(Order::getOrderStatus, OrderStatusEnum.UNDELIVERED.name()));
|
||||
.set(Order::getOrderStatus, orderStatusEnum.name()));
|
||||
//修改订单
|
||||
OrderMessage orderMessage = new OrderMessage();
|
||||
orderMessage.setNewStatus(OrderStatusEnum.UNDELIVERED);
|
||||
orderMessage.setNewStatus(orderStatusEnum);
|
||||
orderMessage.setOrderSn(orderSn);
|
||||
this.sendUpdateStatusMessage(orderMessage);
|
||||
}
|
||||
|
File diff suppressed because one or more lines are too long
@ -1,6 +1,7 @@
|
||||
package cn.lili.modules.permission.service;
|
||||
|
||||
|
||||
import cn.lili.common.security.enums.UserEnums;
|
||||
import cn.lili.common.security.token.Token;
|
||||
import cn.lili.modules.permission.entity.dos.AdminUser;
|
||||
import cn.lili.modules.permission.entity.dto.AdminUserDTO;
|
||||
@ -99,4 +100,11 @@ public interface AdminUserService extends IService<AdminUser> {
|
||||
*/
|
||||
Token refreshToken(String refreshToken);
|
||||
|
||||
/**
|
||||
* 登出
|
||||
*
|
||||
* @param userEnums token角色类型
|
||||
*/
|
||||
void logout(UserEnums userEnums);
|
||||
|
||||
}
|
||||
|
@ -1,10 +1,13 @@
|
||||
package cn.lili.modules.permission.serviceimpl;
|
||||
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import cn.lili.cache.Cache;
|
||||
import cn.lili.cache.CachePrefix;
|
||||
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.common.security.token.Token;
|
||||
import cn.lili.common.utils.BeanUtil;
|
||||
import cn.lili.common.utils.StringUtils;
|
||||
@ -53,6 +56,10 @@ public class AdminUserServiceImpl extends ServiceImpl<AdminUserMapper, AdminUser
|
||||
private MenuService menuService;
|
||||
@Autowired
|
||||
private ManagerTokenGenerate managerTokenGenerate;
|
||||
|
||||
@Autowired
|
||||
private Cache cache;
|
||||
|
||||
/**
|
||||
* 角色长度
|
||||
*/
|
||||
@ -132,6 +139,14 @@ public class AdminUserServiceImpl extends ServiceImpl<AdminUserMapper, AdminUser
|
||||
return managerTokenGenerate.refreshToken(refreshToken);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void logout(UserEnums userEnums) {
|
||||
String currentUserToken = UserContext.getCurrentUserToken();
|
||||
if (CharSequenceUtil.isNotEmpty(currentUserToken)) {
|
||||
cache.remove(CachePrefix.ACCESS_TOKEN.getPrefix(userEnums) + currentUserToken);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public AdminUser findByUsername(String username) {
|
||||
|
@ -47,5 +47,8 @@ public class StoreIndexStatisticsVO {
|
||||
@ApiModelProperty(value = "未对账结算单数量")
|
||||
private Long waitPayBill;
|
||||
|
||||
@ApiModelProperty(value = "待自提数量")
|
||||
private Long selfPickNum;
|
||||
|
||||
|
||||
}
|
||||
|
@ -200,7 +200,8 @@ public class IndexStatisticsServiceImpl implements IndexStatisticsService {
|
||||
storeIndexStatisticsVO.setUnDeliveredOrder(orderStatisticsService.orderNum(OrderStatusEnum.UNDELIVERED.name()));
|
||||
//待收货订单数量
|
||||
storeIndexStatisticsVO.setDeliveredOrder(orderStatisticsService.orderNum(OrderStatusEnum.DELIVERED.name()));
|
||||
|
||||
//待自提数量
|
||||
storeIndexStatisticsVO.setSelfPickNum(orderStatisticsService.orderNum(OrderStatusEnum.STAY_PICKED_UP.name()));
|
||||
//待处理退货数量
|
||||
storeIndexStatisticsVO.setReturnGoods(afterSaleStatisticsService.applyNum(AfterSaleTypeEnum.RETURN_GOODS.name()));
|
||||
//待处理退款数量
|
||||
|
@ -103,6 +103,9 @@ public class Store extends BaseEntity {
|
||||
@ApiModelProperty(value = "默认页面是否开启")
|
||||
private Boolean pageShow;
|
||||
|
||||
@ApiModelProperty(value = "是否开启自提")
|
||||
private Boolean selfPickFlag;
|
||||
|
||||
public Store(Member member) {
|
||||
this.memberId = member.getId();
|
||||
this.memberName = member.getUsername();
|
||||
|
@ -36,4 +36,7 @@ public class StoreSettingDTO {
|
||||
@ApiModelProperty(value = "默认页面是否开启")
|
||||
private Boolean pageShow;
|
||||
|
||||
@ApiModelProperty(value = "是否开启自提")
|
||||
private Boolean selfPickFlag;
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package cn.lili.modules.store.service;
|
||||
|
||||
import cn.lili.common.vo.PageVO;
|
||||
import cn.lili.modules.goods.entity.dos.GoodsSku;
|
||||
import cn.lili.modules.member.entity.dto.CollectionDTO;
|
||||
import cn.lili.modules.store.entity.dos.Store;
|
||||
import cn.lili.modules.store.entity.dto.*;
|
||||
@ -9,6 +10,8 @@ import cn.lili.modules.store.entity.vos.StoreVO;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 店铺业务层
|
||||
*
|
||||
@ -117,5 +120,15 @@ public interface StoreService extends IService<Store> {
|
||||
*/
|
||||
void updateStoreCollectionNum(CollectionDTO collectionDTO);
|
||||
|
||||
/**
|
||||
* 重新生成所有店铺
|
||||
*/
|
||||
void storeToClerk();
|
||||
|
||||
/**
|
||||
* 店铺获取该会员的访问记录
|
||||
* @param memberId 会员Id
|
||||
* @return
|
||||
*/
|
||||
List<GoodsSku> getToMemberHistory(String memberId);
|
||||
}
|
@ -25,6 +25,8 @@ import cn.lili.modules.store.service.StoreDetailService;
|
||||
import cn.lili.modules.store.service.StoreService;
|
||||
import cn.lili.rocketmq.RocketmqSendCallbackBuilder;
|
||||
import cn.lili.rocketmq.tags.GoodsTagsEnum;
|
||||
import cn.lili.rocketmq.tags.MemberTagsEnum;
|
||||
import cn.lili.rocketmq.tags.StoreTagsEnum;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
@ -99,6 +101,9 @@ public class StoreDetailServiceImpl extends ServiceImpl<StoreDetailMapper, Store
|
||||
if (result) {
|
||||
this.updateStoreGoodsInfo(store);
|
||||
}
|
||||
String destination = rocketmqCustomProperties.getStoreTopic() + ":" + StoreTagsEnum.EDIT_STORE_SETTING.name();
|
||||
//发送订单变更mq消息
|
||||
rocketMQTemplate.asyncSend(destination, store, RocketmqSendCallbackBuilder.commonCallback());
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -6,16 +6,21 @@ import cn.lili.cache.Cache;
|
||||
import cn.lili.cache.CachePrefix;
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.exception.ServiceException;
|
||||
import cn.lili.common.properties.RocketmqCustomProperties;
|
||||
import cn.lili.common.security.AuthUser;
|
||||
import cn.lili.common.security.context.UserContext;
|
||||
import cn.lili.common.utils.BeanUtil;
|
||||
import cn.lili.common.vo.PageVO;
|
||||
import cn.lili.modules.goods.entity.dos.GoodsSku;
|
||||
import cn.lili.modules.goods.service.GoodsService;
|
||||
import cn.lili.modules.goods.service.GoodsSkuService;
|
||||
import cn.lili.modules.member.entity.dos.Clerk;
|
||||
import cn.lili.modules.member.entity.dos.FootPrint;
|
||||
import cn.lili.modules.member.entity.dos.Member;
|
||||
import cn.lili.modules.member.entity.dto.ClerkAddDTO;
|
||||
import cn.lili.modules.member.entity.dto.CollectionDTO;
|
||||
import cn.lili.modules.member.service.ClerkService;
|
||||
import cn.lili.modules.member.service.FootprintService;
|
||||
import cn.lili.modules.member.service.MemberService;
|
||||
import cn.lili.modules.store.entity.dos.Store;
|
||||
import cn.lili.modules.store.entity.dos.StoreDetail;
|
||||
@ -27,12 +32,15 @@ import cn.lili.modules.store.mapper.StoreMapper;
|
||||
import cn.lili.modules.store.service.StoreDetailService;
|
||||
import cn.lili.modules.store.service.StoreService;
|
||||
import cn.lili.mybatis.util.PageUtil;
|
||||
import cn.lili.rocketmq.RocketmqSendCallbackBuilder;
|
||||
import cn.lili.rocketmq.tags.StoreTagsEnum;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.apache.rocketmq.spring.core.RocketMQTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@ -66,12 +74,24 @@ public class StoreServiceImpl extends ServiceImpl<StoreMapper, Store> implements
|
||||
*/
|
||||
@Autowired
|
||||
private GoodsService goodsService;
|
||||
|
||||
@Autowired
|
||||
private GoodsSkuService goodsSkuService;
|
||||
/**
|
||||
* 店铺详情
|
||||
*/
|
||||
@Autowired
|
||||
private StoreDetailService storeDetailService;
|
||||
|
||||
@Autowired
|
||||
private RocketmqCustomProperties rocketmqCustomProperties;
|
||||
|
||||
@Autowired
|
||||
private RocketMQTemplate rocketMQTemplate;
|
||||
|
||||
@Autowired
|
||||
private FootprintService footprintService;
|
||||
|
||||
@Autowired
|
||||
private Cache cache;
|
||||
|
||||
@ -159,7 +179,11 @@ public class StoreServiceImpl extends ServiceImpl<StoreMapper, Store> implements
|
||||
if (result) {
|
||||
storeDetailService.updateStoreGoodsInfo(store);
|
||||
}
|
||||
String destination = rocketmqCustomProperties.getStoreTopic() + ":" + StoreTagsEnum.EDIT_STORE_SETTING.name();
|
||||
//发送订单变更mq消息
|
||||
rocketMQTemplate.asyncSend(destination, store, RocketmqSendCallbackBuilder.commonCallback());
|
||||
}
|
||||
|
||||
cache.remove(CachePrefix.STORE.getPrefix() + storeEditDTO.getStoreId());
|
||||
return store;
|
||||
}
|
||||
@ -352,6 +376,18 @@ public class StoreServiceImpl extends ServiceImpl<StoreMapper, Store> implements
|
||||
clerkService.saveBatch(clerkList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GoodsSku> getToMemberHistory(String memberId) {
|
||||
AuthUser currentUser = UserContext.getCurrentUser();
|
||||
List<String> skuIdList = new ArrayList<>();
|
||||
for (FootPrint footPrint : footprintService.list(new LambdaUpdateWrapper<FootPrint>().eq(FootPrint::getStoreId, currentUser.getStoreId()).eq(FootPrint::getMemberId, memberId))) {
|
||||
if(footPrint.getSkuId() != null){
|
||||
skuIdList.add(footPrint.getSkuId());
|
||||
}
|
||||
}
|
||||
return goodsSkuService.getGoodsSkuByIdFromCache(skuIdList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前登录操作的店铺
|
||||
*
|
||||
|
@ -0,0 +1,24 @@
|
||||
package cn.lili.mybatis;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
|
||||
/**
|
||||
* 租户超级类
|
||||
*
|
||||
* @author Chopper
|
||||
* @version v1.0
|
||||
* @since 2020/8/20 14:34
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public abstract class BaseTenantEntity extends BaseEntity {
|
||||
|
||||
@ApiModelProperty(value = "租户id", hidden = true)
|
||||
private String tenantId;
|
||||
|
||||
}
|
@ -23,6 +23,10 @@ public enum MemberTagsEnum {
|
||||
* 会员提现
|
||||
*/
|
||||
MEMBER_WITHDRAWAL("会员提现"),
|
||||
/**
|
||||
* 会员信息更改
|
||||
*/
|
||||
MEMBER_INFO_EDIT("会员信息更改"),
|
||||
/**
|
||||
* 会员积分变动
|
||||
*/
|
||||
|
@ -0,0 +1,20 @@
|
||||
package cn.lili.rocketmq.tags;
|
||||
|
||||
/**
|
||||
* @author chc
|
||||
* @since 2022/6/2114:46
|
||||
*/
|
||||
public enum StoreTagsEnum {
|
||||
|
||||
EDIT_STORE_SETTING("修改商家设置");
|
||||
|
||||
private final String description;
|
||||
|
||||
StoreTagsEnum(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String description() {
|
||||
return description;
|
||||
}
|
||||
}
|
34
im-api/pom.xml
Normal file
34
im-api/pom.xml
Normal file
@ -0,0 +1,34 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>im-api</artifactId>
|
||||
|
||||
<parent>
|
||||
<groupId>cn.lili</groupId>
|
||||
<artifactId>lili-shop-parent</artifactId>
|
||||
<version>${revision}</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>cn.lili</groupId>
|
||||
<artifactId>framework</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
||||
</project>
|
31
im-api/src/main/java/cn/lili/ImApiApplication.java
Normal file
31
im-api/src/main/java/cn/lili/ImApiApplication.java
Normal file
@ -0,0 +1,31 @@
|
||||
package cn.lili;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.web.socket.server.standard.ServerEndpointExporter;
|
||||
|
||||
|
||||
/**
|
||||
* @author liushuai
|
||||
*/
|
||||
@SpringBootApplication
|
||||
public class ImApiApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ImApiApplication.class, args);
|
||||
}
|
||||
|
||||
/**
|
||||
* 如果使用独立的servlet容器,
|
||||
* 而不是直接使用springboot的内置容器,
|
||||
* 就不要注入ServerEndpointExporter,
|
||||
* 因为它将由容器自己提供和管理
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
public ServerEndpointExporter serverEndpointExporter() {
|
||||
return new ServerEndpointExporter();
|
||||
}
|
||||
}
|
@ -0,0 +1,83 @@
|
||||
package cn.lili.controller.goods;
|
||||
|
||||
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.goods.service.GoodsService;
|
||||
import cn.lili.modules.goods.service.GoodsSkuService;
|
||||
import cn.lili.modules.search.service.EsGoodsSearchService;
|
||||
import cn.lili.modules.search.service.HotWordsService;
|
||||
import cn.lili.modules.statistics.aop.PageViewPoint;
|
||||
import cn.lili.modules.statistics.aop.enums.PageViewEnum;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
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;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* IM端,商品接口
|
||||
*
|
||||
* @author chc
|
||||
* @since 2022-12-28 18:30:33
|
||||
*/
|
||||
@Slf4j
|
||||
@Api(tags = "IM端,商品接口")
|
||||
@RestController
|
||||
@RequestMapping("/im/goods/goods")
|
||||
public class GoodsImController {
|
||||
|
||||
/**
|
||||
* 商品
|
||||
*/
|
||||
@Autowired
|
||||
private GoodsService goodsService;
|
||||
/**
|
||||
* 商品SKU
|
||||
*/
|
||||
@Autowired
|
||||
private GoodsSkuService goodsSkuService;
|
||||
/**
|
||||
* ES商品搜索
|
||||
*/
|
||||
@Autowired
|
||||
private EsGoodsSearchService goodsSearchService;
|
||||
|
||||
@Autowired
|
||||
private HotWordsService hotWordsService;
|
||||
|
||||
@ApiOperation(value = "通过id获取商品信息")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "goodsId", value = "商品ID", required = true, paramType = "path"),
|
||||
@ApiImplicitParam(name = "skuId", value = "skuId", required = true, paramType = "path")
|
||||
})
|
||||
@GetMapping(value = "/sku/{goodsId}/{skuId}")
|
||||
@PageViewPoint(type = PageViewEnum.SKU, id = "#id")
|
||||
public ResultMessage<Map<String, Object>> getSku(@NotNull(message = "商品ID不能为空") @PathVariable("goodsId") String goodsId,
|
||||
@NotNull(message = "SKU ID不能为空") @PathVariable("skuId") String skuId) {
|
||||
try {
|
||||
// 读取选中的列表
|
||||
Map<String, Object> map = goodsSkuService.getGoodsSkuDetail(goodsId, skuId);
|
||||
return ResultUtil.data(map);
|
||||
} catch (ServiceException se) {
|
||||
log.info(se.getMsg(), se);
|
||||
throw se;
|
||||
} catch (Exception e) {
|
||||
log.error(ResultCode.GOODS_ERROR.message(), e);
|
||||
return ResultUtil.error(ResultCode.GOODS_ERROR);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,175 @@
|
||||
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.security.AuthUser;
|
||||
import cn.lili.common.security.context.UserContext;
|
||||
import cn.lili.common.security.enums.UserEnums;
|
||||
import cn.lili.common.security.token.Token;
|
||||
import cn.lili.common.utils.StringUtils;
|
||||
import cn.lili.common.vo.PageVO;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.common.vo.SearchVO;
|
||||
import cn.lili.modules.permission.entity.dos.AdminUser;
|
||||
import cn.lili.modules.permission.entity.dto.AdminUserDTO;
|
||||
import cn.lili.modules.permission.entity.vo.AdminUserVO;
|
||||
import cn.lili.modules.permission.service.AdminUserService;
|
||||
import cn.lili.modules.permission.service.DepartmentService;
|
||||
import cn.lili.mybatis.util.PageUtil;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@Api(tags = "管理员")
|
||||
@RequestMapping("/im/manager/im/passport/user")
|
||||
@Validated
|
||||
public class ImManagerController {
|
||||
@Autowired
|
||||
private AdminUserService adminUserService;
|
||||
@Autowired
|
||||
private DepartmentService departmentService;
|
||||
|
||||
@PostMapping(value = "/login")
|
||||
@ApiOperation(value = "登录管理员")
|
||||
public ResultMessage<Token> login(@NotNull(message = "用户名不能为空") String username,
|
||||
@NotNull(message = "密码不能为空") String password) {
|
||||
return ResultUtil.data(adminUserService.login(username, password));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "注销接口")
|
||||
@PostMapping("/logout")
|
||||
public ResultMessage<Object> logout() {
|
||||
this.adminUserService.logout(UserEnums.MANAGER);
|
||||
return ResultUtil.success();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "刷新token")
|
||||
@GetMapping("/refresh/{refreshToken}")
|
||||
public ResultMessage<Object> refreshToken(@NotNull(message = "刷新token不能为空") @PathVariable String refreshToken) {
|
||||
return ResultUtil.data(this.adminUserService.refreshToken(refreshToken));
|
||||
}
|
||||
|
||||
|
||||
@GetMapping(value = "/info")
|
||||
@ApiOperation(value = "获取当前登录用户接口")
|
||||
public ResultMessage<AdminUserVO> getUserInfo() {
|
||||
AuthUser tokenUser = UserContext.getCurrentUser();
|
||||
if (tokenUser != null) {
|
||||
AdminUserVO adminUser = new AdminUserVO(adminUserService.findByUsername(tokenUser.getUsername()));
|
||||
if (StringUtils.isNotEmpty(adminUser.getDepartmentId())) {
|
||||
adminUser.setDepartmentTitle(departmentService.getById(adminUser.getDepartmentId()).getTitle());
|
||||
}
|
||||
adminUser.setPassword(null);
|
||||
return ResultUtil.data(adminUser);
|
||||
}
|
||||
throw new ServiceException(ResultCode.USER_NOT_LOGIN);
|
||||
}
|
||||
|
||||
@PutMapping(value = "/edit")
|
||||
@ApiOperation(value = "修改用户自己资料", notes = "用户名密码不会修改")
|
||||
public ResultMessage<Object> editOwner(AdminUser adminUser) {
|
||||
|
||||
AuthUser tokenUser = UserContext.getCurrentUser();
|
||||
if (tokenUser != null) {
|
||||
//查询当前管理员
|
||||
AdminUser oldAdminUser = adminUserService.findByUsername(tokenUser.getUsername());
|
||||
oldAdminUser.setAvatar(adminUser.getAvatar());
|
||||
oldAdminUser.setNickName(adminUser.getNickName());
|
||||
if (!adminUserService.updateById(oldAdminUser)) {
|
||||
throw new ServiceException(ResultCode.USER_EDIT_ERROR);
|
||||
}
|
||||
return ResultUtil.success(ResultCode.USER_EDIT_SUCCESS);
|
||||
}
|
||||
throw new ServiceException(ResultCode.USER_NOT_LOGIN);
|
||||
}
|
||||
|
||||
@PutMapping(value = "/admin/edit")
|
||||
@ApiOperation(value = "超级管理员修改其他管理员资料")
|
||||
public ResultMessage<Object> edit(@Valid AdminUser adminUser,
|
||||
@RequestParam(required = false) List<String> roles) {
|
||||
if (!adminUserService.updateAdminUser(adminUser, roles)) {
|
||||
throw new ServiceException(ResultCode.USER_EDIT_ERROR);
|
||||
}
|
||||
return ResultUtil.success(ResultCode.USER_EDIT_SUCCESS);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改密码
|
||||
*
|
||||
* @param password
|
||||
* @param newPassword
|
||||
* @return
|
||||
*/
|
||||
@PutMapping(value = "/editPassword")
|
||||
@ApiOperation(value = "修改密码")
|
||||
public ResultMessage<Object> editPassword(String password, String newPassword) {
|
||||
adminUserService.editPassword(password, newPassword);
|
||||
return ResultUtil.success(ResultCode.USER_EDIT_SUCCESS);
|
||||
}
|
||||
|
||||
@PostMapping(value = "/resetPassword/{ids}")
|
||||
@ApiOperation(value = "重置密码")
|
||||
public ResultMessage<Object> resetPassword(@PathVariable List ids) {
|
||||
adminUserService.resetPassword(ids);
|
||||
return ResultUtil.success(ResultCode.USER_EDIT_SUCCESS);
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
@ApiOperation(value = "多条件分页获取用户列表")
|
||||
public ResultMessage<IPage<AdminUserVO>> getByCondition(AdminUserDTO user,
|
||||
SearchVO searchVo,
|
||||
PageVO pageVo) {
|
||||
IPage<AdminUserVO> page = adminUserService.adminUserPage(PageUtil.initPage(pageVo), PageUtil.initWrapper(user, searchVo));
|
||||
|
||||
return ResultUtil.data(page);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping
|
||||
@ApiOperation(value = "添加用户")
|
||||
public ResultMessage<Object> register(@Valid AdminUserDTO adminUser,
|
||||
@RequestParam(required = false) List<String> roles) {
|
||||
int rolesMaxSize = 10;
|
||||
try {
|
||||
if (roles != null && roles.size() >= rolesMaxSize) {
|
||||
throw new ServiceException(ResultCode.PERMISSION_BEYOND_TEN);
|
||||
}
|
||||
adminUserService.saveAdminUser(adminUser, roles);
|
||||
} catch (Exception e) {
|
||||
log.error("添加用户错误", e);
|
||||
}
|
||||
return ResultUtil.success();
|
||||
}
|
||||
|
||||
@PutMapping(value = "/enable/{userId}")
|
||||
@ApiOperation(value = "禁/启 用 用户")
|
||||
public ResultMessage<Object> disable(@ApiParam("用户唯一id标识") @PathVariable String userId, Boolean status) {
|
||||
AdminUser user = adminUserService.getById(userId);
|
||||
if (user == null) {
|
||||
throw new ServiceException(ResultCode.USER_NOT_EXIST);
|
||||
}
|
||||
user.setStatus(status);
|
||||
adminUserService.updateById(user);
|
||||
return ResultUtil.success();
|
||||
}
|
||||
|
||||
@DeleteMapping(value = "/{ids}")
|
||||
@ApiOperation(value = "批量通过ids删除")
|
||||
public ResultMessage<Object> delAllByIds(@PathVariable List<String> ids) {
|
||||
adminUserService.deleteCompletely(ids);
|
||||
return ResultUtil.success();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,89 @@
|
||||
package cn.lili.controller.im;
|
||||
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.enums.ResultUtil;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.im.entity.dos.ImMessage;
|
||||
import cn.lili.modules.im.entity.dto.MessageQueryParams;
|
||||
import cn.lili.modules.im.service.ImMessageService;
|
||||
import io.swagger.annotations.Api;
|
||||
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.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* @author Chopper
|
||||
*/
|
||||
@RestController
|
||||
@Api(tags = "Im消息接口")
|
||||
@RequestMapping("/im/message")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
||||
public class ImMessageController {
|
||||
|
||||
private final ImMessageService imMessageService;
|
||||
|
||||
@GetMapping(value = "/{id}")
|
||||
@ApiOperation(value = "查看Im消息详情")
|
||||
public ResultMessage<ImMessage> get(@PathVariable String id) {
|
||||
ImMessage imMessage = imMessageService.getById(id);
|
||||
return new ResultUtil<ImMessage>().setData(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);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@ApiOperation(value = "新增Im消息")
|
||||
public ResultMessage<ImMessage> save(ImMessage imMessage) {
|
||||
if (imMessageService.save(imMessage)) {
|
||||
return new ResultUtil<ImMessage>().setData(imMessage);
|
||||
}
|
||||
return new ResultUtil<ImMessage>().setErrorMsg(ResultCode.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 new ResultUtil<ImMessage>().setErrorMsg(ResultCode.ERROR);
|
||||
}
|
||||
|
||||
@DeleteMapping(value = "/{ids}")
|
||||
@ApiOperation(value = "删除Im消息")
|
||||
public ResultMessage<Object> delAllByIds(@PathVariable List ids) {
|
||||
imMessageService.removeByIds(ids);
|
||||
return ResultUtil.success(ResultCode.SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
@GetMapping(value = "/newMessage")
|
||||
@ApiOperation(value = "查看是否有新消息")
|
||||
public ResultMessage<Boolean> hasNewMessage(String accessToken) {
|
||||
return ResultUtil.data(imMessageService.hasNewMessage(accessToken));
|
||||
}
|
||||
|
||||
@GetMapping(value = "/unredMessage")
|
||||
@ApiOperation(value = "获取所有未读消息")
|
||||
public ResultMessage<Long> getUnreadMessageCount() {
|
||||
return ResultUtil.data(imMessageService.unreadMessageCount());
|
||||
}
|
||||
|
||||
@PutMapping(value = "/clean/unred")
|
||||
@ApiOperation(value = "清除所有未读消息")
|
||||
public ResultMessage<Object> cleanUnreadMessage() {
|
||||
imMessageService.cleanUnreadMessage();
|
||||
return ResultUtil.success();
|
||||
}
|
||||
}
|
@ -0,0 +1,88 @@
|
||||
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;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
/**
|
||||
* @author Chopper
|
||||
*/
|
||||
@RestController
|
||||
@Api(tags = "聊天接口")
|
||||
@RequestMapping("/im/talk")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
||||
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);
|
||||
}
|
||||
|
||||
@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));
|
||||
}
|
||||
|
||||
@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()));
|
||||
}
|
||||
|
||||
@GetMapping(value = "/top")
|
||||
@ApiOperation(value = "查看与某人聊天详情")
|
||||
public ResultMessage 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));
|
||||
}
|
||||
|
||||
@GetMapping("/store/list")
|
||||
@ApiOperation(value = "分页获取商家聊天")
|
||||
public ResultMessage<List<ImTalkVO>> getStoreTalkList() {
|
||||
return ResultUtil.data(imTalkService.getStoreTalkList());
|
||||
}
|
||||
|
||||
@DeleteMapping(value = "/{id}")
|
||||
@ApiOperation(value = "删除聊天")
|
||||
public ResultMessage<Object> disable(@PathVariable String id) {
|
||||
imTalkService.disable(id);
|
||||
return ResultUtil.success(ResultCode.SUCCESS);
|
||||
}
|
||||
}
|
@ -0,0 +1,81 @@
|
||||
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.FootPrint;
|
||||
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));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
package cn.lili.controller.im;
|
||||
|
||||
import cn.lili.common.enums.ResultUtil;
|
||||
import cn.lili.common.vo.PageVO;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.im.entity.dos.QA;
|
||||
import cn.lili.modules.im.service.QAService;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 管理端,自定义分词接口
|
||||
*
|
||||
* @author paulG
|
||||
* @since 2020/10/16
|
||||
**/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@Api(tags = "管理端,自定义分词接口")
|
||||
@RequestMapping("/im/store/qa")
|
||||
public class QAStoreController {
|
||||
|
||||
@Autowired
|
||||
private QAService qaService;
|
||||
|
||||
@ApiOperation(value = "添加问答")
|
||||
@PostMapping
|
||||
public ResultMessage<QA> addCustomWords(@Valid QA qa) {
|
||||
qaService.save(qa);
|
||||
return ResultUtil.data(qa);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "修改自定义问答")
|
||||
@PutMapping
|
||||
public ResultMessage<QA> updateCustomWords(@Valid QA qa) {
|
||||
qaService.updateById(qa);
|
||||
return ResultUtil.data(qa);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "删除自定义分词")
|
||||
@DeleteMapping("/{id}")
|
||||
public ResultMessage<String> deleteCustomWords(@NotNull @PathVariable String id) {
|
||||
qaService.removeById(id);
|
||||
return ResultUtil.success();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "分页获取自定义分词")
|
||||
@ApiImplicitParam(name = "word", value = "问题", required = true, dataType = "String", paramType = "query")
|
||||
@GetMapping("/page")
|
||||
public ResultMessage<IPage<QA>> getCustomWords(@RequestParam String word, PageVO pageVo) {
|
||||
return ResultUtil.data(qaService.getStoreQA(word, pageVo));
|
||||
}
|
||||
|
||||
}
|
188
im-api/src/main/java/cn/lili/controller/im/WebSocketServer.java
Normal file
188
im-api/src/main/java/cn/lili/controller/im/WebSocketServer.java
Normal file
@ -0,0 +1,188 @@
|
||||
package cn.lili.controller.im;
|
||||
|
||||
import cn.lili.cache.Cache;
|
||||
import cn.lili.common.security.AuthUser;
|
||||
import cn.lili.common.security.context.UserContext;
|
||||
import cn.lili.common.security.enums.UserEnums;
|
||||
import cn.lili.common.utils.SnowFlake;
|
||||
import cn.lili.modules.im.config.CustomSpringConfigurator;
|
||||
import cn.lili.modules.im.entity.dos.ImMessage;
|
||||
import cn.lili.modules.im.entity.dos.ImTalk;
|
||||
import cn.lili.modules.im.entity.enums.MessageResultType;
|
||||
import cn.lili.modules.im.entity.vo.MessageOperation;
|
||||
import cn.lili.modules.im.entity.vo.MessageVO;
|
||||
import cn.lili.modules.im.service.ImMessageService;
|
||||
import cn.lili.modules.im.service.ImTalkService;
|
||||
import cn.lili.modules.member.entity.dos.Member;
|
||||
import cn.lili.modules.member.service.MemberService;
|
||||
import cn.lili.modules.store.entity.dos.Store;
|
||||
import cn.lili.modules.store.service.StoreService;
|
||||
import com.alibaba.druid.util.StringUtils;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.websocket.*;
|
||||
import javax.websocket.server.PathParam;
|
||||
import javax.websocket.server.ServerEndpoint;
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* @author liushuai
|
||||
*/
|
||||
@Component
|
||||
@ServerEndpoint(value = "/lili/webSocket/{accessToken}", configurator = CustomSpringConfigurator.class)
|
||||
@Slf4j
|
||||
public class WebSocketServer {
|
||||
/**
|
||||
* 消息服务
|
||||
*/
|
||||
@Autowired
|
||||
private ImMessageService imMessageService;
|
||||
|
||||
/**
|
||||
* im用户服务
|
||||
*/
|
||||
@Autowired
|
||||
private MemberService memberService;
|
||||
|
||||
@Autowired
|
||||
private StoreService storeService;
|
||||
|
||||
@Autowired
|
||||
private ImTalkService imTalkService;
|
||||
|
||||
|
||||
@Autowired
|
||||
private Cache cache;
|
||||
/**
|
||||
* 在线人数
|
||||
* PS 注意,只能单节点,如果多节点部署需要自行寻找方案
|
||||
*/
|
||||
private static ConcurrentHashMap<String, Session> sessionPools = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
* 建立连接
|
||||
*
|
||||
* @param session
|
||||
*/
|
||||
@OnOpen
|
||||
public void onOpen(@PathParam("accessToken") String accessToken, Session session) throws IOException {
|
||||
AuthUser authUser = UserContext.getAuthUser(accessToken);
|
||||
Object message = null;
|
||||
if (UserEnums.STORE.equals(authUser.getRole())) {
|
||||
message = storeService.getById(authUser.getStoreId());
|
||||
sessionPools.put(authUser.getStoreId(), session);
|
||||
|
||||
} else if (UserEnums.MEMBER.equals(authUser.getRole())) {
|
||||
message = memberService.getById(authUser.getId());
|
||||
sessionPools.put(authUser.getId(), session);
|
||||
}
|
||||
MessageVO messageVO = new MessageVO(MessageResultType.FRIENDS, message);
|
||||
sendMessage(authUser.getId(), messageVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭连接
|
||||
*/
|
||||
@OnClose
|
||||
public void onClose(@PathParam("accessToken") String accessToken) {
|
||||
log.info("断开连接:{}", accessToken);
|
||||
sessionPools.remove(UserContext.getAuthUser(accessToken).getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送消息
|
||||
*
|
||||
* @param msg
|
||||
* @throws IOException
|
||||
*/
|
||||
@OnMessage
|
||||
public void onMessage(@PathParam("accessToken") String accessToken, String msg) {
|
||||
log.error(msg);
|
||||
MessageOperation messageOperation = JSON.parseObject(msg, MessageOperation.class);
|
||||
operation(accessToken, messageOperation);
|
||||
}
|
||||
|
||||
/**
|
||||
* IM操作
|
||||
*
|
||||
* @param accessToken
|
||||
* @param messageOperation
|
||||
*/
|
||||
private void operation(String accessToken, MessageOperation messageOperation) {
|
||||
|
||||
AuthUser authUser = UserContext.getAuthUser(accessToken);
|
||||
switch (messageOperation.getOperationType()) {
|
||||
case PING:
|
||||
break;
|
||||
case MESSAGE:
|
||||
//保存消息
|
||||
ImMessage imMessage = new ImMessage(messageOperation);
|
||||
imMessageService.save(imMessage);
|
||||
//修改最后消息信息
|
||||
imTalkService.update(new LambdaUpdateWrapper<ImTalk>().eq(ImTalk::getId,messageOperation.getTalkId()).set(ImTalk::getLastTalkMessage,messageOperation.getContext())
|
||||
.set(ImTalk::getLastTalkTime,imMessage.getCreateTime())
|
||||
.set(ImTalk::getLastMessageType,imMessage.getMessageType()));
|
||||
//发送消息
|
||||
sendMessage(messageOperation.getTo(), new MessageVO(MessageResultType.MESSAGE, imMessage));
|
||||
break;
|
||||
case READ:
|
||||
if (!StringUtils.isEmpty(messageOperation.getContext())) {
|
||||
imMessageService.read(messageOperation.getTalkId(), accessToken);
|
||||
}
|
||||
break;
|
||||
case UNREAD:
|
||||
sendMessage(authUser.getId(), new MessageVO(MessageResultType.UN_READ, imMessageService.unReadMessages(accessToken)));
|
||||
break;
|
||||
case HISTORY:
|
||||
sendMessage(authUser.getId(), new MessageVO(MessageResultType.HISTORY, imMessageService.historyMessage(accessToken, messageOperation.getTo())));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送消息
|
||||
*
|
||||
* @param key 密钥
|
||||
* @param message 消息对象
|
||||
*/
|
||||
private void sendMessage(String key, MessageVO message) {
|
||||
Session session = sessionPools.get(key);
|
||||
if (session != null) {
|
||||
try {
|
||||
session.getBasicRemote().sendText(JSON.toJSONString(message, true));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* socket exception
|
||||
*
|
||||
* @param session
|
||||
* @param throwable
|
||||
*/
|
||||
@OnError
|
||||
public void onError(Session session, Throwable throwable) {
|
||||
throwable.printStackTrace();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取店铺id
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private String storeKey(String storeId) {
|
||||
return "STORE_" + storeId;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package cn.lili.controller.orders;
|
||||
|
||||
import cn.lili.common.enums.ResultUtil;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.im.entity.dto.ImQueryParams;
|
||||
import cn.lili.modules.member.entity.dto.FootPrintQueryParams;
|
||||
import cn.lili.modules.order.order.entity.dos.Order;
|
||||
import cn.lili.modules.order.order.entity.dto.OrderSearchParams;
|
||||
import cn.lili.modules.order.order.entity.vo.OrderSimpleVO;
|
||||
import cn.lili.modules.order.order.service.OrderService;
|
||||
import cn.lili.modules.search.entity.dos.EsGoodsIndex;
|
||||
import cn.lili.mybatis.util.PageUtil;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* IM端,订单接口
|
||||
*
|
||||
* @author chc
|
||||
* @since 2022/6/2114:46
|
||||
*/
|
||||
@Slf4j
|
||||
@Api(tags = "IM端,订单接口")
|
||||
@RestController
|
||||
@RequestMapping("/im/orders/orders")
|
||||
public class ImOrderComtroller {
|
||||
|
||||
@Autowired
|
||||
private OrderService orderService;
|
||||
|
||||
@GetMapping("")
|
||||
@ApiOperation(value = "获取会员订单列表")
|
||||
public ResultMessage<IPage<OrderSimpleVO>> getMemberHistory(OrderSearchParams params) {
|
||||
return ResultUtil.data(orderService.queryByParams(params));
|
||||
}
|
||||
}
|
59
im-api/src/main/java/cn/lili/controller/seat/SeatLogin.java
Normal file
59
im-api/src/main/java/cn/lili/controller/seat/SeatLogin.java
Normal file
@ -0,0 +1,59 @@
|
||||
package cn.lili.controller.seat;
|
||||
|
||||
import cn.lili.common.enums.ResultUtil;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.im.service.SeatService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* 坐席登录接口
|
||||
*
|
||||
* @author Chopper
|
||||
* @version v1.0
|
||||
* 2022-02-10 16:40
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@Api(tags = "坐席端")
|
||||
@RequestMapping("/seat/login")
|
||||
public class SeatLogin {
|
||||
|
||||
@Autowired
|
||||
private SeatService seatService;
|
||||
|
||||
@ApiOperation(value = "登录接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "username", value = "用户名", required = true, paramType = "query"),
|
||||
@ApiImplicitParam(name = "password", value = "密码", required = true, paramType = "query")
|
||||
})
|
||||
@PostMapping("/userLogin")
|
||||
public ResultMessage<Object> userLogin(String username, String password) {
|
||||
return ResultUtil.data(this.seatService.usernameLogin(username, password));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "商家快捷登录客服")
|
||||
@PostMapping("/quicklogin")
|
||||
public ResultMessage<Object> quickLogin(String code) {
|
||||
return ResultUtil.data(this.seatService.quickLogin(code));
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation(value = "登出")
|
||||
@PostMapping("/logout")
|
||||
public ResultMessage<Object> logout() {
|
||||
//todo
|
||||
// UserContext.getCurrentUser().getId()
|
||||
// verificationServiceClient.check(uuid);
|
||||
return ResultUtil.success();
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
package cn.lili.controller.seat;
|
||||
|
||||
import cn.lili.common.enums.ResultUtil;
|
||||
import cn.lili.common.security.context.UserContext;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.im.entity.dos.SeatSetting;
|
||||
import cn.lili.modules.im.service.SeatSettingService;;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
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.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* 店铺端,分类绑定参数组管理接口
|
||||
*
|
||||
* @author pikachu
|
||||
* @since 2020-02-18 15:18:56
|
||||
*/
|
||||
@RestController
|
||||
@Api(tags = "店铺端,坐席设置")
|
||||
@RequestMapping("/store/seat/setting")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class SeatSettingStoreController {
|
||||
|
||||
@Autowired
|
||||
private SeatSettingService seatSettingService;
|
||||
|
||||
@ApiOperation(value = "查询坐席设置")
|
||||
@GetMapping
|
||||
public ResultMessage<SeatSetting> getSetting() {
|
||||
return ResultUtil.data(seatSettingService.getSetting(UserContext.getCurrentUser().getTenantId()));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "更新坐席设置")
|
||||
@PutMapping
|
||||
public void update(SeatSetting seatSetting) {
|
||||
seatSetting.setTenantId(UserContext.getCurrentUser().getTenantId());
|
||||
seatSettingService.updateByStore(seatSetting);
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package cn.lili.controller.seat;
|
||||
|
||||
import cn.lili.common.enums.ResultUtil;
|
||||
import cn.lili.common.security.context.UserContext;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.im.entity.vo.SeatVO;
|
||||
import cn.lili.modules.im.service.SeatService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
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.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* SeatController
|
||||
*
|
||||
* @author Chopper
|
||||
* @version v1.0
|
||||
* 2022-02-10 11:50
|
||||
*/
|
||||
@RestController
|
||||
@Api(tags = "店铺端,坐席管理")
|
||||
@RequestMapping("/store/seat/setting")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class SeatStoreController {
|
||||
|
||||
|
||||
@Autowired
|
||||
private SeatService seatService;
|
||||
|
||||
@ApiOperation(value = "分页获取坐席")
|
||||
@GetMapping("/list")
|
||||
public ResultMessage<List<SeatVO>> getSeats() {
|
||||
return ResultUtil.data(seatService.seatVoList(UserContext.getCurrentUser().getTenantId()));
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package cn.lili.controller.seat;
|
||||
|
||||
import cn.lili.common.enums.ResultUtil;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.im.entity.vo.SeatVO;
|
||||
import cn.lili.modules.im.service.SeatService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
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.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* SeatController
|
||||
*
|
||||
* @author Chopper
|
||||
* @version v1.0
|
||||
* 2022-02-10 11:50
|
||||
*/
|
||||
@RestController
|
||||
@Api(tags = "店铺端,坐席管理")
|
||||
@RequestMapping("/manager/seat/setting")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class SeatStoreManagerController {
|
||||
|
||||
@Autowired
|
||||
private SeatService seatService;
|
||||
|
||||
@ApiOperation(value = "查看店铺坐席列表")
|
||||
@GetMapping("/list")
|
||||
public ResultMessage<List<SeatVO>> getSeats(String storeId) {
|
||||
return ResultUtil.data(seatService.seatVoList(storeId));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
package cn.lili.controller.security;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
|
||||
import org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer;
|
||||
import org.springframework.web.cors.CorsConfigurationSource;
|
||||
|
||||
/**
|
||||
* spring Security 核心配置类 通用安全
|
||||
*
|
||||
* @author Chopper
|
||||
* @version v4.0
|
||||
* @since 2020/11/14 16:20
|
||||
*/
|
||||
@Slf4j
|
||||
@Configuration
|
||||
@EnableGlobalMethodSecurity(prePostEnabled = true)
|
||||
public class ImSecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
|
||||
|
||||
/**
|
||||
* spring security -》 权限不足处理
|
||||
*/
|
||||
@Autowired
|
||||
private CorsConfigurationSource corsConfigurationSource;
|
||||
|
||||
@Override
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
|
||||
ExpressionUrlAuthorizationConfigurer<HttpSecurity>.ExpressionInterceptUrlRegistry registry = http
|
||||
.authorizeRequests();
|
||||
registry
|
||||
.and()
|
||||
//禁止网页iframe
|
||||
.headers().frameOptions().disable()
|
||||
.and()
|
||||
.authorizeRequests()
|
||||
//任何请求
|
||||
.anyRequest()
|
||||
//需要身份认证
|
||||
.permitAll()
|
||||
.and()
|
||||
//允许跨域
|
||||
.cors().configurationSource(corsConfigurationSource).and()
|
||||
//关闭跨站请求防护
|
||||
.csrf().disable();
|
||||
}
|
||||
|
||||
}
|
277
im-api/src/main/resources/application.yml
Normal file
277
im-api/src/main/resources/application.yml
Normal file
@ -0,0 +1,277 @@
|
||||
server:
|
||||
port: 8885
|
||||
|
||||
servlet:
|
||||
context-path: /
|
||||
|
||||
tomcat:
|
||||
uri-encoding: UTF-8
|
||||
threads:
|
||||
min-spare: 50
|
||||
max: 1000
|
||||
|
||||
# 与Spring Boot 2一样,默认情况下,大多数端点都不通过http公开,我们公开了所有端点。对于生产,您应该仔细选择要公开的端点。
|
||||
management:
|
||||
# health:
|
||||
# elasticsearch:
|
||||
# enabled: false
|
||||
# datasource:
|
||||
# enabled: false
|
||||
endpoints:
|
||||
web:
|
||||
exposure:
|
||||
include: '*'
|
||||
spring:
|
||||
application:
|
||||
name: im-api
|
||||
# 要在其中注册的Spring Boot Admin Server的URL。
|
||||
boot:
|
||||
admin:
|
||||
client:
|
||||
url: http://127.0.0.1:8000
|
||||
cache:
|
||||
type: redis
|
||||
# Redis
|
||||
redis:
|
||||
host: 127.0.0.1
|
||||
port: 6379
|
||||
password: lilishop
|
||||
lettuce:
|
||||
pool:
|
||||
# 连接池最大连接数(使用负值表示没有限制) 默认 8
|
||||
max-active: 200
|
||||
# 连接池最大阻塞等待时间(使用负值表示没有限制) 默认 -1
|
||||
max-wait: 20
|
||||
# 连接池中的最大空闲连接 默认 8
|
||||
max-idle: 10
|
||||
# 连接池中的最小空闲连接 默认 8
|
||||
min-idle: 8
|
||||
# 文件大小上传配置
|
||||
servlet:
|
||||
multipart:
|
||||
max-file-size: 20MB
|
||||
max-request-size: 20MB
|
||||
jackson:
|
||||
time-zone: GMT+8
|
||||
serialization:
|
||||
#关闭jackson 对json做解析
|
||||
fail-on-empty-beans: false
|
||||
|
||||
shardingsphere:
|
||||
datasource:
|
||||
# 数据库名称,可自定义,可以为多个,以逗号隔开,每个在这里定义的库,都要在下面定义连接属性
|
||||
names: default-datasource
|
||||
default-datasource:
|
||||
type: com.alibaba.druid.pool.DruidDataSource
|
||||
driverClassName: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:mysql://127.0.0.1:3306/lilishop?useUnicode=true&characterEncoding=utf-8&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
|
||||
username: root
|
||||
password: lilishop
|
||||
maxActive: 20
|
||||
initialSize: 5
|
||||
maxWait: 60000
|
||||
minIdle: 5
|
||||
timeBetweenEvictionRunsMillis: 60000
|
||||
minEvictableIdleTimeMillis: 300000
|
||||
validationQuery: SELECT 1 FROM DUAL
|
||||
testWhileIdle: true
|
||||
testOnBorrow: false
|
||||
testOnReturn: false
|
||||
#是否缓存preparedStatement,也就是PSCache。在mysql下建议关闭。 PSCache对支持游标的数据库性能提升巨大,比如说oracle。
|
||||
poolPreparedStatements: false
|
||||
#要启用PSCache,-1为关闭 必须配置大于0,当大于0时,poolPreparedStatements自动触发修改为true 可以把这个数值配置大一些,比如说100
|
||||
maxOpenPreparedStatements: -1
|
||||
#配置监控统计拦截的filters,去掉后监控界面sql无法统计,'wall'用于防火墙
|
||||
filters: stat,wall,log4j2
|
||||
#通过connectProperties属性来打开mergeSql功能;慢SQL记录
|
||||
connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000
|
||||
#合并多个DruidDataSource的监控数据
|
||||
useGlobalDataSourceStat: true
|
||||
loginUsername: druid
|
||||
loginPassword: druid
|
||||
# sharding:
|
||||
# default-data-source-name: default-datasource
|
||||
# #需要拆分的表,可以设置多个 在 li_order 级别即可
|
||||
# tables:
|
||||
# #需要进行分表的逻辑表名
|
||||
# li_order:
|
||||
# #实际的表结点,下面代表的是li_order_为开头的所有表,如果能确定表的范围例如按月份分表,这里的写法是data2020.li_order_$->{2020..2021}_$->{01..12} 表示例如 li_order_2020_01 li_order_2020_03 li_order_2021_01
|
||||
# actual-data-nodes: data2020.li_order_$->{2019..2021}_$->{01..12}
|
||||
# table-strategy:
|
||||
# # 分表策略,根据创建日期
|
||||
# standard:
|
||||
# sharding-column: create_time
|
||||
# #分表策略
|
||||
# precise-algorithm-class-name: cn.lili.mybatis.sharding.CreateTimeShardingTableAlgorithm
|
||||
# #范围查询实现
|
||||
# range-algorithm-class-name: cn.lili.mybatis.sharding.CreateTimeShardingTableAlgorithm
|
||||
props:
|
||||
#是否打印逻辑SQL语句和实际SQL语句,建议调试时打印,在生产环境关闭
|
||||
sql:
|
||||
show: false
|
||||
|
||||
# 忽略鉴权url
|
||||
ignored:
|
||||
urls:
|
||||
- /editor-app/**
|
||||
- /actuator**
|
||||
- /actuator/**
|
||||
- /MP_verify_qSyvBPhDsPdxvOhC.txt
|
||||
- /weixin/**
|
||||
- /source/**
|
||||
- /manager/passport/user/login
|
||||
- /manager/passport/user/refresh/**
|
||||
- /manager/other/elasticsearch
|
||||
- /manager/other/customWords
|
||||
- /druid/**
|
||||
- /swagger-ui.html
|
||||
- /doc.html
|
||||
- /swagger-resources/**
|
||||
- /swagger/**
|
||||
- /webjars/**
|
||||
- /v2/api-docs
|
||||
- /configuration/ui
|
||||
- /boot-admin
|
||||
- /**/*.js
|
||||
- /**/*.css
|
||||
- /**/*.png
|
||||
- /**/*.ico
|
||||
|
||||
# Swagger界面内容配置
|
||||
swagger:
|
||||
title: lili API接口文档
|
||||
description: lili Api Documentation
|
||||
version: 1.0.0
|
||||
termsOfServiceUrl: https://pickmall.cn
|
||||
contact:
|
||||
name: lili
|
||||
url: https://pickmall.cn
|
||||
email: admin@pickmall.com
|
||||
|
||||
# Mybatis-plus
|
||||
mybatis-plus:
|
||||
mapper-locations: classpath*:mapper/*.xml
|
||||
configuration:
|
||||
#缓存开启
|
||||
cache-enabled: true
|
||||
#日志
|
||||
# log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||
|
||||
# 日志
|
||||
logging:
|
||||
config: classpath:logback-spring.xml
|
||||
# 输出级别
|
||||
level:
|
||||
cn.lili: info
|
||||
# org.hibernate: debug
|
||||
# org.springframework: debug
|
||||
file:
|
||||
# 指定路径
|
||||
path: lili-logs
|
||||
logback:
|
||||
rollingpolicy:
|
||||
# 最大保存天数
|
||||
max-history: 7
|
||||
# 每个文件最大大小
|
||||
max-file-size: 5MB
|
||||
#加密参数
|
||||
jasypt:
|
||||
encryptor:
|
||||
password: lili
|
||||
|
||||
lili:
|
||||
system:
|
||||
isDemoSite: true
|
||||
# 脱敏级别:
|
||||
# 0:不做脱敏处理
|
||||
# 1:管理端用户手机号等信息脱敏
|
||||
# 2:商家端信息脱敏(为2时,表示管理端,商家端同时脱敏)
|
||||
sensitiveLevel: 1
|
||||
statistics:
|
||||
# 在线人数统计 X 小时。这里设置48,即统计过去48小时每小时在线人数
|
||||
onlineMember: 48
|
||||
# 当前在线人数刷新时间间隔,单位秒,设置为600,则每10分钟刷新一次
|
||||
currentOnlineUpdate: 600
|
||||
#qq lbs 申请
|
||||
lbs:
|
||||
key: 4BYBZ-7MT6S-PUAOA-6BNWL-FJUD7-UUFXT
|
||||
sk: zhNKVrJK6UPOhqIjn8AQvG37b9sz6
|
||||
#域名
|
||||
domain:
|
||||
pc: https://pc.b2b2c.pickmall.cn
|
||||
wap: https://m.b2b2c.pickmall.cn
|
||||
store: https://store.b2b2c.pickmall.cn
|
||||
admin: https://admin.b2b2c.pickmall.cn
|
||||
#api地址
|
||||
api:
|
||||
buyer: https://buyer-api.pickmall.cn
|
||||
common: https://common-api.pickmall.cn
|
||||
manager: https://admin-api.pickmall.cn
|
||||
store: https://store-api.pickmall.cn
|
||||
|
||||
# jwt 细节设定
|
||||
jwt-setting:
|
||||
# token过期时间(分钟)
|
||||
tokenExpireTime: 60
|
||||
|
||||
# 使用Spring @Cacheable注解失效时间
|
||||
cache:
|
||||
# 过期时间 单位秒 永久不过期设为-1
|
||||
timeout: 1500
|
||||
#多线程配置
|
||||
thread:
|
||||
corePoolSize: 5
|
||||
maxPoolSize: 50
|
||||
queueCapacity: 50
|
||||
data:
|
||||
elasticsearch:
|
||||
cluster-name: elasticsearch
|
||||
cluster-nodes: 127.0.0.1:9200
|
||||
index:
|
||||
number-of-replicas: 0
|
||||
number-of-shards: 3
|
||||
index-prefix: lili
|
||||
schema: http
|
||||
# account:
|
||||
# username: elastic
|
||||
# password: LiLiShopES
|
||||
logstash:
|
||||
server: 127.0.0.1:4560
|
||||
rocketmq:
|
||||
promotion-topic: lili_promotion_topic
|
||||
promotion-group: lili_promotion_group
|
||||
msg-ext-topic: lili_msg_topic
|
||||
msg-ext-group: lili_msg_group
|
||||
goods-topic: lili_goods_topic
|
||||
goods-group: lili_goods_group
|
||||
order-topic: lili_order_topic
|
||||
order-group: lili_order_group
|
||||
member-topic: lili_member_topic
|
||||
member-group: lili_member_group
|
||||
store-topic: lili_store_topic
|
||||
store-group: lili_store_group
|
||||
other-topic: lili_other_topic
|
||||
other-group: lili_other_group
|
||||
notice-topic: lili_notice_topic
|
||||
notice-group: lili_notice_group
|
||||
notice-send-topic: lili_send_notice_topic
|
||||
notice-send-group: lili_send_notice_group
|
||||
after-sale-topic: lili_after_sale_topic
|
||||
after-sale-group: lili_after_sale_group
|
||||
rocketmq:
|
||||
name-server: 127.0.0.1:9876
|
||||
producer:
|
||||
group: lili_group
|
||||
send-message-timeout: 30000
|
||||
|
||||
xxl:
|
||||
job:
|
||||
admin:
|
||||
addresses: http://127.0.0.1:9001/xxl-job-admin
|
||||
executor:
|
||||
appname: xxl-job-executor-lilishop
|
||||
address:
|
||||
ip:
|
||||
port: 8891
|
||||
logpath: ./xxl-job/executor
|
||||
logretentiondays: 7
|
58
im-api/src/main/resources/logback-spring.xml
Normal file
58
im-api/src/main/resources/logback-spring.xml
Normal file
@ -0,0 +1,58 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE configuration>
|
||||
<configuration>
|
||||
<include resource="org/springframework/boot/logging/logback/defaults.xml"/>
|
||||
<include resource="org/springframework/boot/logging/logback/console-appender.xml"/>
|
||||
<!--应用名称-->
|
||||
<springProperty scope="context" name="APP_NAME" source="spring.application.name"/>
|
||||
<!--日志文件保存路径-->
|
||||
<springProperty scope="context" name="LOG_FILE_PATH" source="logging.file.path"/>
|
||||
<springProperty scope="context" name="LOGSTASH_SERVER" source="lili.data.logstash.server"/>
|
||||
<contextName>${APP_NAME}</contextName>
|
||||
|
||||
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<fileNamePattern>${LOG_FILE_PATH}/${APP_NAME}-%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||
<maxHistory>30</maxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>${FILE_LOG_PATTERN}</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<appender name="RocketmqClientAppender" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${LOG_FILE_PATH}/rocketmq.log</file>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<fileNamePattern>${LOG_FILE_PATH}/rocketmq/rocketmq-%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||
<maxHistory>30</maxHistory>
|
||||
<totalSizeCap>30MB</totalSizeCap>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>%d{yy-MM-dd.HH:mm:ss.SSS} [%-16t] %-5p %-22c{0} %X{ServiceId} - %m%n</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
<logger name="RocketmqClient" additivity="false">
|
||||
<level value="info" />
|
||||
<appender-ref ref="RocketmqClientAppender"/>
|
||||
</logger>
|
||||
|
||||
<!--输出到elk的LOGSTASH-->
|
||||
<appender name="LOGSTASH" class="net.logstash.logback.appender.LogstashTcpSocketAppender">
|
||||
<!-- 配置elk日志收集 配饰的是 LOGSTASH 的地址-->
|
||||
<destination>${LOGSTASH_SERVER}</destination>
|
||||
<encoder charset="UTF-8" class="net.logstash.logback.encoder.LogstashEncoder">
|
||||
<providers>
|
||||
<timestamp>
|
||||
<timeZone>UTC</timeZone>
|
||||
</timestamp>
|
||||
</providers>
|
||||
<!--自定义字段 区分项目-->
|
||||
<customFields>{"appName":"${APP_NAME}"}</customFields>
|
||||
</encoder>
|
||||
</appender>
|
||||
<root level="INFO">
|
||||
<appender-ref ref="CONSOLE"/>
|
||||
<appender-ref ref="FILE"/>
|
||||
<appender-ref ref="LOGSTASH"/>
|
||||
</root>
|
||||
</configuration>
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user