发放传参
This commit is contained in:
@@ -24,7 +24,7 @@ public class UChatCouponController {
|
|||||||
*/
|
*/
|
||||||
@PostMapping("/grant")
|
@PostMapping("/grant")
|
||||||
public CzgResult<Boolean> grantChatCoupon(@RequestBody ChatCouponGrantDTO chatCouponGrant) {
|
public CzgResult<Boolean> grantChatCoupon(@RequestBody ChatCouponGrantDTO chatCouponGrant) {
|
||||||
chatCouponService.grantChatCoupon(chatCouponGrant.getId(), chatCouponGrant.getShopUserId(), chatCouponGrant.getUserId());
|
chatCouponService.grantChatCoupon(chatCouponGrant.getId(), chatCouponGrant.getShopId(), chatCouponGrant.getUserId());
|
||||||
return CzgResult.success(true);
|
return CzgResult.success(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,6 +31,11 @@ public interface ShopUserService extends IService<ShopUser> {
|
|||||||
*/
|
*/
|
||||||
Page<InviteUserVO> getInviteUser(Long getDistributionUserId, Long shopId, Long shopUserId, Long distributionLevelId, Integer page, Integer size);
|
Page<InviteUserVO> getInviteUser(Long getDistributionUserId, Long shopId, Long shopUserId, Long distributionLevelId, Integer page, Integer size);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 会自动获取到用户的主店铺id 然后获取用户信息
|
||||||
|
* 获取用户信息
|
||||||
|
*/
|
||||||
|
ShopUser getUserInfo(Long shopId, Long userId);
|
||||||
|
|
||||||
boolean updateInfo(ShopUser shopUser);
|
boolean updateInfo(ShopUser shopUser);
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,10 @@ public class ChatCouponGrantDTO {
|
|||||||
* 店铺用户ID
|
* 店铺用户ID
|
||||||
*/
|
*/
|
||||||
private Long shopUserId;
|
private Long shopUserId;
|
||||||
|
/**
|
||||||
|
* 店铺ID
|
||||||
|
*/
|
||||||
|
private Long shopId;
|
||||||
/**
|
/**
|
||||||
* 用户ID
|
* 用户ID
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ public interface ChatCouponService extends IService<ChatCoupon> {
|
|||||||
/**
|
/**
|
||||||
* 发放优惠券
|
* 发放优惠券
|
||||||
*/
|
*/
|
||||||
void grantChatCoupon(Long id, Long shopUserId, Long userId);
|
void grantChatCoupon(Long id, Long shopId, Long userId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分页查询优惠券发放记录
|
* 分页查询优惠券发放记录
|
||||||
|
|||||||
@@ -63,6 +63,12 @@ public class ShopUserServiceImpl extends ServiceImpl<ShopUserMapper, ShopUser> i
|
|||||||
return shopUser;
|
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
|
@Override
|
||||||
public boolean updateInfo(ShopUser shopUser) {
|
public boolean updateInfo(ShopUser shopUser) {
|
||||||
return super.updateById(shopUser);
|
return super.updateById(shopUser);
|
||||||
@@ -71,13 +77,9 @@ public class ShopUserServiceImpl extends ServiceImpl<ShopUserMapper, ShopUser> i
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ShopUser getShopUserInfo(Long shopId, long userId) {
|
public ShopUser getShopUserInfo(Long shopId, long userId) {
|
||||||
Long mainShopId = shopInfoService.getMainIdByShopId(shopId);
|
ShopUser shopUser = getUserInfo(shopId, userId);
|
||||||
ShopUser shopUser = queryChain().eq(ShopUser::getUserId, userId).and(q -> {
|
|
||||||
q.eq(ShopUser::getMainShopId, mainShopId).or(q1 -> {
|
|
||||||
q1.eq(ShopUser::getSourceShopId, shopId);
|
|
||||||
});
|
|
||||||
}).one();
|
|
||||||
if (shopUser == null) {
|
if (shopUser == null) {
|
||||||
|
Long mainShopId = shopInfoService.getMainIdByShopId(shopId);
|
||||||
shopUser = new ShopUser();
|
shopUser = new ShopUser();
|
||||||
UserInfo userInfo = userInfoService.getById(userId);
|
UserInfo userInfo = userInfoService.getById(userId);
|
||||||
BeanUtil.copyProperties(userInfo, shopUser);
|
BeanUtil.copyProperties(userInfo, shopUser);
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package com.czg.service.market.service.impl;
|
package com.czg.service.market.service.impl;
|
||||||
|
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
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.exception.CzgException;
|
||||||
import com.czg.market.dto.ChatCouponDTO;
|
import com.czg.market.dto.ChatCouponDTO;
|
||||||
import com.czg.market.dto.MkShopCouponGiftDTO;
|
import com.czg.market.dto.MkShopCouponGiftDTO;
|
||||||
@@ -17,6 +19,7 @@ import com.czg.market.service.ChatCouponService;
|
|||||||
import com.czg.service.market.mapper.ChatCouponMapper;
|
import com.czg.service.market.mapper.ChatCouponMapper;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.dubbo.config.annotation.DubboReference;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
@@ -33,6 +36,9 @@ public class ChatCouponServiceImpl extends ServiceImpl<ChatCouponMapper, ChatCou
|
|||||||
private ShopCouponService couponService;
|
private ShopCouponService couponService;
|
||||||
@Resource
|
@Resource
|
||||||
private MkShopCouponRecordService recordService;
|
private MkShopCouponRecordService recordService;
|
||||||
|
@DubboReference
|
||||||
|
private ShopUserService shopUserService;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@@ -94,7 +100,7 @@ public class ChatCouponServiceImpl extends ServiceImpl<ChatCouponMapper, ChatCou
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public void grantChatCoupon(Long id, Long shopUserId, Long userId) {
|
public void grantChatCoupon(Long id, Long shopId, Long userId) {
|
||||||
ChatCoupon coupon = getById(id);
|
ChatCoupon coupon = getById(id);
|
||||||
if (coupon == null) {
|
if (coupon == null) {
|
||||||
throw new CzgException("活动不存在");
|
throw new CzgException("活动不存在");
|
||||||
@@ -105,7 +111,7 @@ public class ChatCouponServiceImpl extends ServiceImpl<ChatCouponMapper, ChatCou
|
|||||||
boolean exists = recordService.exists(QueryWrapper.create()
|
boolean exists = recordService.exists(QueryWrapper.create()
|
||||||
.eq(MkShopCouponRecord::getSource, "群聊发放")
|
.eq(MkShopCouponRecord::getSource, "群聊发放")
|
||||||
.eq(MkShopCouponRecord::getSourceId, coupon.getId())
|
.eq(MkShopCouponRecord::getSourceId, coupon.getId())
|
||||||
.eq(MkShopCouponRecord::getShopUserId, shopUserId)
|
.eq(MkShopCouponRecord::getShopId, shopId)
|
||||||
.eq(MkShopCouponRecord::getUserId, userId)
|
.eq(MkShopCouponRecord::getUserId, userId)
|
||||||
);
|
);
|
||||||
if (exists) {
|
if (exists) {
|
||||||
@@ -122,16 +128,20 @@ public class ChatCouponServiceImpl extends ServiceImpl<ChatCouponMapper, ChatCou
|
|||||||
coupon.setStatus(3);
|
coupon.setStatus(3);
|
||||||
}
|
}
|
||||||
updateById(coupon);
|
updateById(coupon);
|
||||||
|
ShopUser shopUser = shopUserService.getUserInfo(shopId, userId);
|
||||||
|
|
||||||
MkShopCouponRecord record = JSONObject.parseObject(coupon.getCouponJson(), MkShopCouponRecord.class);
|
// MkShopCouponRecord record = JSONObject.parseObject(coupon.getCouponJson(), MkShopCouponRecord.class);
|
||||||
record.setShopUserId(shopUserId);
|
// record.setShopUserId(shopUserId);
|
||||||
record.setUserId(userId);
|
// record.setUserId(userId);
|
||||||
// recordService.grantChatCoupon(record, coupon.getGetLimit());
|
// recordService.grantChatCoupon(record, coupon.getGetLimit());
|
||||||
|
if (shopUser == null) {
|
||||||
|
throw new CzgException("用户不存在");
|
||||||
|
}
|
||||||
MkShopCouponGiftDTO giftDTO = new MkShopCouponGiftDTO()
|
MkShopCouponGiftDTO giftDTO = new MkShopCouponGiftDTO()
|
||||||
.setCouponId(coupon.getCouponId())
|
.setCouponId(coupon.getCouponId())
|
||||||
.setShopId(coupon.getShopId())
|
.setShopId(shopId)
|
||||||
.setSourceId(coupon.getId())
|
.setSourceId(coupon.getId())
|
||||||
.setShopUserId(shopUserId)
|
.setShopUserId(shopUser.getId())
|
||||||
.setSource("群聊发放");
|
.setSource("群聊发放");
|
||||||
recordService.receiveCoupon(giftDTO, coupon.getGetLimit(), false);
|
recordService.receiveCoupon(giftDTO, coupon.getGetLimit(), false);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user