店铺会员mq新增
This commit is contained in:
parent
9b558f2bd3
commit
2bfe7c48dc
@ -1,20 +1,11 @@
|
|||||||
package com.suisung.mall.account.listener;
|
package com.suisung.mall.account.listener;
|
||||||
|
|
||||||
import cn.hutool.core.convert.Convert;
|
|
||||||
import cn.hutool.json.JSONUtil;
|
import cn.hutool.json.JSONUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
||||||
import com.rabbitmq.client.Channel;
|
import com.rabbitmq.client.Channel;
|
||||||
import com.suisung.mall.account.service.AccountUserBindConnectService;
|
|
||||||
import com.suisung.mall.account.service.AccountUserInfoService;
|
import com.suisung.mall.account.service.AccountUserInfoService;
|
||||||
import com.suisung.mall.common.api.BindCode;
|
import com.suisung.mall.account.service.ShopStoreMemberService;
|
||||||
import com.suisung.mall.common.constant.CommonConstant;
|
|
||||||
import com.suisung.mall.common.constant.MqConstant;
|
import com.suisung.mall.common.constant.MqConstant;
|
||||||
import com.suisung.mall.common.feignService.ShopService;
|
|
||||||
import com.suisung.mall.common.modules.account.AccountUserBindConnect;
|
|
||||||
import com.suisung.mall.common.modules.account.AccountUserInfo;
|
import com.suisung.mall.common.modules.account.AccountUserInfo;
|
||||||
import com.suisung.mall.common.modules.store.ShopStoreBase;
|
|
||||||
import com.suisung.mall.common.modules.store.ShopStoreMember;
|
|
||||||
import com.suisung.mall.common.modules.store.ShopStoreMemberLevel;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.amqp.core.Message;
|
import org.springframework.amqp.core.Message;
|
||||||
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
|
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
|
||||||
@ -24,7 +15,6 @@ import org.springframework.stereotype.Service;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@ -34,10 +24,7 @@ public class DealUserInfoListener {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private AccountUserInfoService accountUserInfoService;
|
private AccountUserInfoService accountUserInfoService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private ShopService shopService;
|
private ShopStoreMemberService shopStoreMemberService;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private AccountUserBindConnectService accountUserBindConnectService;
|
|
||||||
|
|
||||||
@RabbitHandler
|
@RabbitHandler
|
||||||
public void listener(byte[] data, Channel channel, Message message) throws IOException, InterruptedException {
|
public void listener(byte[] data, Channel channel, Message message) throws IOException, InterruptedException {
|
||||||
@ -55,7 +42,12 @@ public class DealUserInfoListener {
|
|||||||
boolean flag = accountUserInfoService.saveOrUpdate(accountUserInfo);
|
boolean flag = accountUserInfoService.saveOrUpdate(accountUserInfo);
|
||||||
if (flag) {
|
if (flag) {
|
||||||
channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
|
channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
|
||||||
dealStoreMember(accountUserInfo);
|
log.info("MQ处理活动开始:accountUserInfo:{}", JSONUtil.toJsonStr(accountUserInfo));
|
||||||
|
if(accountUserInfo.getStore_id()!=null){
|
||||||
|
AccountUserInfo updateAccountUserInfo= accountUserInfoService.get(accountUserInfo.getStore_id());
|
||||||
|
updateAccountUserInfo.setStore_name(accountUserInfo.getStore_name());
|
||||||
|
shopStoreMemberService.dealStoreMember(updateAccountUserInfo);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
log.error("消息消费失败,执行dealUserInfo异常,当前用户编号:{}", accountUserInfo.getUser_id());
|
log.error("消息消费失败,执行dealUserInfo异常,当前用户编号:{}", accountUserInfo.getUser_id());
|
||||||
channel.basicReject(message.getMessageProperties().getDeliveryTag(), true);
|
channel.basicReject(message.getMessageProperties().getDeliveryTag(), true);
|
||||||
@ -67,57 +59,4 @@ public class DealUserInfoListener {
|
|||||||
Thread.sleep(1000);
|
Thread.sleep(1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void dealStoreMember(AccountUserInfo accountUserInfo){
|
|
||||||
if(null!=accountUserInfo.getStore_id()){
|
|
||||||
log.info("MQ店铺会员开始:accountUserInfo:{}", JSONUtil.toJsonStr(accountUserInfo));
|
|
||||||
Integer store_id = accountUserInfo.getStore_id();
|
|
||||||
Integer user_id = accountUserInfo.getUser_id();
|
|
||||||
ShopStoreMember params=new ShopStoreMember();
|
|
||||||
params.setUserId(user_id);
|
|
||||||
params.setStoreId(store_id);
|
|
||||||
List<ShopStoreMember> shopStoreMembers= shopService.findShopStoreMemberList(params);
|
|
||||||
ShopStoreBase shopStoreBase= shopService.getShopStoreBase(store_id);
|
|
||||||
if(shopStoreMembers.isEmpty()&&shopStoreBase!=null){
|
|
||||||
QueryWrapper<AccountUserBindConnect> queryWrapper = new QueryWrapper<>();
|
|
||||||
queryWrapper.eq("bind_id", "+86"+accountUserInfo.getUser_mobile())//+86的
|
|
||||||
.eq("bind_type", BindCode.MOBILE)
|
|
||||||
.eq("user_type", 0)
|
|
||||||
.eq("user_id", user_id)
|
|
||||||
.eq("bind_active", CommonConstant.Enable)
|
|
||||||
.orderByAsc("bind_time");
|
|
||||||
List<AccountUserBindConnect> accountUserBindConnectList = accountUserBindConnectService.list(queryWrapper);
|
|
||||||
if (!accountUserBindConnectList.isEmpty()){
|
|
||||||
AccountUserBindConnect accountUserBindConnect= accountUserBindConnectList.get(0);
|
|
||||||
ShopStoreMember shopStoreMember = new ShopStoreMember();
|
|
||||||
shopStoreMember.setStoreName(shopStoreBase.getStore_name());
|
|
||||||
shopStoreMember.setStoreId(shopStoreBase.getStore_id());
|
|
||||||
shopStoreMember.setUserId(user_id);
|
|
||||||
shopStoreMember.setBind_openid(accountUserBindConnect.getBind_openid());
|
|
||||||
shopStoreMember.setUserNickname(accountUserBindConnect.getBind_nickname());
|
|
||||||
shopStoreMember.setUserAccount(accountUserBindConnect.getBind_id());
|
|
||||||
ShopStoreMember saveShopStoreMember= shopService.saveShopStoreMember(shopStoreMember);
|
|
||||||
ShopStoreMemberLevel shopStoreMemberLevel = getShopStoreMemberLevel(shopStoreBase, saveShopStoreMember);
|
|
||||||
shopStoreMemberLevel.setUserId(user_id);
|
|
||||||
shopService.saveShopStoreMemberLevel(shopStoreMemberLevel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 店铺会员初始化信息
|
|
||||||
* @param shopStoreBase
|
|
||||||
* @param shopStoreMember
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private ShopStoreMemberLevel getShopStoreMemberLevel(ShopStoreBase shopStoreBase, ShopStoreMember shopStoreMember) {
|
|
||||||
ShopStoreMemberLevel shopStoreMemberLevel=new ShopStoreMemberLevel();
|
|
||||||
shopStoreMemberLevel.setStoreId(shopStoreBase.getStore_id());
|
|
||||||
shopStoreMemberLevel.setStoreMemberId(shopStoreMember.getStore_member_id());
|
|
||||||
shopStoreMemberLevel.setUserLevelName("v1");
|
|
||||||
shopStoreMemberLevel.setUserLevelId(1001);
|
|
||||||
shopStoreMemberLevel.setMemberLevelId(1001);
|
|
||||||
shopStoreMemberLevel.setMemberLevelName("v1");
|
|
||||||
return shopStoreMemberLevel;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user