Skip to content

Commit

Permalink
merge 自提、IM功能
Browse files Browse the repository at this point in the history
  • Loading branch information
chopper711 committed Jan 9, 2023
2 parents 197a7bc + a38bc6b commit cc12cec
Show file tree
Hide file tree
Showing 104 changed files with 3,812 additions and 146 deletions.
2 changes: 1 addition & 1 deletion DB/version4.2.5toMASTER.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
@@ -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.*;

Expand All @@ -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删除")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,20 +189,38 @@ public ResultMessage<Object> shippingAddress(@NotNull(message = "收货地址ID
}
}

@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);
Expand All @@ -213,6 +231,21 @@ public ResultMessage<Object> shippingMethod(@NotNull(message = "配送方式不
}
}

@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"),
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
}
}
2 changes: 2 additions & 0 deletions buyer-api/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 17 additions & 0 deletions consumer/src/main/java/cn/lili/event/MemberInfoChangeEvent.java
Original file line number Diff line number Diff line change
@@ -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);
}
18 changes: 18 additions & 0 deletions consumer/src/main/java/cn/lili/event/StoreSettingChangeEvent.java
Original file line number Diff line number Diff line change
@@ -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);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
60 changes: 60 additions & 0 deletions consumer/src/main/java/cn/lili/event/impl/ImTalkExecute.java
Original file line number Diff line number Diff line change
@@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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());
//获取随机数,判定是否存在
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public void orderChange(OrderMessage orderMessage) {
case PAID:
case UNDELIVERED:
case DELIVERED:
case STAY_PICKED_UP:
case COMPLETED:
try {
wechatMessageUtil.sendWechatMessage(orderMessage.getOrderSn());
Expand Down
23 changes: 19 additions & 4 deletions consumer/src/main/java/cn/lili/listener/MemberMessageListener.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -110,6 +111,20 @@ public void onMessage(MessageExt 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) {
Expand Down
51 changes: 51 additions & 0 deletions consumer/src/main/java/cn/lili/listener/StoreMessageListener.java
Original file line number Diff line number Diff line change
@@ -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;
}
}
}
2 changes: 2 additions & 0 deletions consumer/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading

0 comments on commit cc12cec

Please sign in to comment.