发放传参
This commit is contained in:
@@ -63,6 +63,12 @@ public class ShopUserServiceImpl extends ServiceImpl<ShopUserMapper, ShopUser> i
|
||||
return shopUser;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ShopUser getUserInfo(Long shopId, Long userId) {
|
||||
Long mainShopId = shopInfoService.getMainIdByShopId(shopId);
|
||||
return getOne(QueryWrapper.create().eq(ShopUser::getUserId, userId).eq(ShopUser::getMainShopId, mainShopId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateInfo(ShopUser shopUser) {
|
||||
return super.updateById(shopUser);
|
||||
@@ -71,13 +77,9 @@ public class ShopUserServiceImpl extends ServiceImpl<ShopUserMapper, ShopUser> i
|
||||
|
||||
@Override
|
||||
public ShopUser getShopUserInfo(Long shopId, long userId) {
|
||||
Long mainShopId = shopInfoService.getMainIdByShopId(shopId);
|
||||
ShopUser shopUser = queryChain().eq(ShopUser::getUserId, userId).and(q -> {
|
||||
q.eq(ShopUser::getMainShopId, mainShopId).or(q1 -> {
|
||||
q1.eq(ShopUser::getSourceShopId, shopId);
|
||||
});
|
||||
}).one();
|
||||
ShopUser shopUser = getUserInfo(shopId, userId);
|
||||
if (shopUser == null) {
|
||||
Long mainShopId = shopInfoService.getMainIdByShopId(shopId);
|
||||
shopUser = new ShopUser();
|
||||
UserInfo userInfo = userInfoService.getById(userId);
|
||||
BeanUtil.copyProperties(userInfo, shopUser);
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.czg.service.market.service.impl;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.czg.account.entity.ShopUser;
|
||||
import com.czg.account.service.ShopUserService;
|
||||
import com.czg.exception.CzgException;
|
||||
import com.czg.market.dto.ChatCouponDTO;
|
||||
import com.czg.market.dto.MkShopCouponGiftDTO;
|
||||
@@ -17,6 +19,7 @@ import com.czg.market.service.ChatCouponService;
|
||||
import com.czg.service.market.mapper.ChatCouponMapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@@ -33,6 +36,9 @@ public class ChatCouponServiceImpl extends ServiceImpl<ChatCouponMapper, ChatCou
|
||||
private ShopCouponService couponService;
|
||||
@Resource
|
||||
private MkShopCouponRecordService recordService;
|
||||
@DubboReference
|
||||
private ShopUserService shopUserService;
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@@ -94,7 +100,7 @@ public class ChatCouponServiceImpl extends ServiceImpl<ChatCouponMapper, ChatCou
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void grantChatCoupon(Long id, Long shopUserId, Long userId) {
|
||||
public void grantChatCoupon(Long id, Long shopId, Long userId) {
|
||||
ChatCoupon coupon = getById(id);
|
||||
if (coupon == null) {
|
||||
throw new CzgException("活动不存在");
|
||||
@@ -105,7 +111,7 @@ public class ChatCouponServiceImpl extends ServiceImpl<ChatCouponMapper, ChatCou
|
||||
boolean exists = recordService.exists(QueryWrapper.create()
|
||||
.eq(MkShopCouponRecord::getSource, "群聊发放")
|
||||
.eq(MkShopCouponRecord::getSourceId, coupon.getId())
|
||||
.eq(MkShopCouponRecord::getShopUserId, shopUserId)
|
||||
.eq(MkShopCouponRecord::getShopId, shopId)
|
||||
.eq(MkShopCouponRecord::getUserId, userId)
|
||||
);
|
||||
if (exists) {
|
||||
@@ -122,16 +128,20 @@ public class ChatCouponServiceImpl extends ServiceImpl<ChatCouponMapper, ChatCou
|
||||
coupon.setStatus(3);
|
||||
}
|
||||
updateById(coupon);
|
||||
ShopUser shopUser = shopUserService.getUserInfo(shopId, userId);
|
||||
|
||||
MkShopCouponRecord record = JSONObject.parseObject(coupon.getCouponJson(), MkShopCouponRecord.class);
|
||||
record.setShopUserId(shopUserId);
|
||||
record.setUserId(userId);
|
||||
// MkShopCouponRecord record = JSONObject.parseObject(coupon.getCouponJson(), MkShopCouponRecord.class);
|
||||
// record.setShopUserId(shopUserId);
|
||||
// record.setUserId(userId);
|
||||
// recordService.grantChatCoupon(record, coupon.getGetLimit());
|
||||
if (shopUser == null) {
|
||||
throw new CzgException("用户不存在");
|
||||
}
|
||||
MkShopCouponGiftDTO giftDTO = new MkShopCouponGiftDTO()
|
||||
.setCouponId(coupon.getCouponId())
|
||||
.setShopId(coupon.getShopId())
|
||||
.setShopId(shopId)
|
||||
.setSourceId(coupon.getId())
|
||||
.setShopUserId(shopUserId)
|
||||
.setShopUserId(shopUser.getId())
|
||||
.setSource("群聊发放");
|
||||
recordService.receiveCoupon(giftDTO, coupon.getGetLimit(), false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user