diff --git a/luoo_eureka/src/main/resources/bootstrap.yml b/luoo_eureka/src/main/resources/bootstrap.yml index 6d7503c..9e499ed 100644 --- a/luoo_eureka/src/main/resources/bootstrap.yml +++ b/luoo_eureka/src/main/resources/bootstrap.yml @@ -4,5 +4,4 @@ spring: name: eureka profile: dev label: master -# uri: http://116.62.145.60:12000 - uri: http://127.0.0.1:12000 \ No newline at end of file + uri: http://116.62.145.60:12000 diff --git a/luoo_user/src/main/java/com/luoo/user/config/MallConfig.java b/luoo_user/src/main/java/com/luoo/user/config/MallConfig.java new file mode 100644 index 0000000..0919bd7 --- /dev/null +++ b/luoo_user/src/main/java/com/luoo/user/config/MallConfig.java @@ -0,0 +1,73 @@ +package com.luoo.user.config; + +import lombok.Getter; +import lombok.Setter; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +/** + * @Author: yawei.huang + * @Package: com.luoo.music.config + * @Project: luoo_parent + * @Date: 2024/5/8 9:23 + * @Filename: MallConfig + * @Describe: + */ +@Getter +@Setter +@Component +@ConfigurationProperties(prefix = "mall") +public class MallConfig { + // 表pms_product属性 + /** + * 品牌id,雀乐固定 + */ + private Long brandId; + + /** + * 品牌名称,固定雀乐 + */ + private String brandName; + /** + * 分类id,固定歌曲 + */ + private Long productCategoryId; + + /** + * 分类名称,固定歌曲 + */ + private String productCategoryName; + /** + * 产品属性分类表id,固定歌曲 + */ + private Long productAttributeCategoryId; + + + // 表pms_product_attribute_value属性 + /** + * 属性音乐人id + */ + private Long artistId; + /** + * 属性音乐人名称 + */ + private Long artistName; + /** + * 属性专辑id + */ + private Long albumId; + /** + * 属性专辑名称 + */ + private Long albumName; + /** + * 属性歌曲id + */ + private Long songId; + + // 其他 + /** + * 获取商品的url接口 + */ + private String productUrl; +} diff --git a/luoo_user/src/main/java/com/luoo/user/dao/RegionDao.java b/luoo_user/src/main/java/com/luoo/user/dao/RegionDao.java index 10fb2df..6f807dc 100644 --- a/luoo_user/src/main/java/com/luoo/user/dao/RegionDao.java +++ b/luoo_user/src/main/java/com/luoo/user/dao/RegionDao.java @@ -12,4 +12,6 @@ public interface RegionDao extends JpaRepository, List getRegionsByPidOrderById(Integer parentId); +// Region findRegionById(Integer id); + } diff --git a/luoo_user/src/main/java/com/luoo/user/service/LotteryService.java b/luoo_user/src/main/java/com/luoo/user/service/LotteryService.java index f0c9266..c0bebfe 100644 --- a/luoo_user/src/main/java/com/luoo/user/service/LotteryService.java +++ b/luoo_user/src/main/java/com/luoo/user/service/LotteryService.java @@ -5,6 +5,7 @@ import cn.hutool.core.util.ObjectUtil; import com.fasterxml.jackson.databind.ObjectMapper; import com.luoo.user.Scheduler.DrawLotteryScheduler; import com.luoo.user.config.EnvConfig; +import com.luoo.user.config.MallConfig; import com.luoo.user.dao.*; import com.luoo.user.dto.point.DrawDTO; import com.luoo.user.dto.point.LotteryParticipatedSearchDto; @@ -21,14 +22,14 @@ import constants.Constants; import constants.ErrorConstants; import constants.RabbitmqConstants; import constants.TaskPointIdConstants; +import dto.MallProduct; +import dto.MallProductAttributeValue; import dto.UserLoginDto; -import enums.PointEnums; -import enums.UserBetaEnum; -import enums.UserTypeEnum; -import enums.UserVipStatusEnum; +import enums.*; import exception.BizException; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.ObjectUtils; import org.springframework.amqp.rabbit.core.RabbitTemplate; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -47,11 +48,9 @@ import javax.persistence.criteria.CriteriaQuery; import javax.persistence.criteria.Predicate; import javax.persistence.criteria.Root; import java.io.IOException; +import java.math.BigDecimal; import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Objects; +import java.util.*; import java.util.concurrent.atomic.AtomicReference; /** @@ -99,6 +98,9 @@ public class LotteryService { @Autowired private CommentDao commentDao; + @Autowired + private MallConfig mallConfig; + public LotteryService(LotteryDao lotteryDao, JwtUtil jwtUtil, IdWorker idWorker, RedisLockUtil redisLockUtil, RegionService regionService, LotteryRegionDao lotteryRegionDao, UserInfoDao userInfoDao, RabbitTemplate rabbitTemplate, LotteryUserDao lotteryUserDao, DrawLotteryScheduler drawLotteryScheduler, JPAQueryFactory jpaQueryFactory, EnvConfig envConfig, UserinfoShippingAddressService userinfoShippingAddressService, UserPointLogService userPointLogService, UserPointLogDao userPointLogDao) { this.lotteryDao = lotteryDao; @@ -317,6 +319,7 @@ public class LotteryService { lottery.setStatus(PointEnums.LOTTERY_STATUS_SIGN.getCode()); lotteryDao.save(lottery); + shelving(lottery); String result = drawLotteryScheduler.scheduleDraw(lottery.getApplyEndTime(), id); @@ -328,6 +331,40 @@ public class LotteryService { } + /** + * 上架操作 + * + * @param lottery 积分活动对象 + */ + private void shelving(Lottery lottery) { + // 只有待上架允许上架 + + MallProduct mallProduct = MallProduct.builder() + .brandId(mallConfig.getBrandId()) + .brandName(mallConfig.getBrandName()) + .productCategoryName(mallConfig.getProductCategoryName()) + .productCategoryId(mallConfig.getProductCategoryId()) + .productAttributeCategoryId(mallConfig.getProductAttributeCategoryId()) + .name(lottery.getTitle()) + .pic(lottery.getImage()) + .subTitle(lottery.getTitle()) + .price(new BigDecimal(lottery.getPoint())) + .build(); + + List attributeValueList = new ArrayList<>(); + attributeValueList.add(MallProductAttributeValue.builder().productAttributeId(mallConfig.getAlbumId()).value(lottery.getId()).build()); + attributeValueList.add(MallProductAttributeValue.builder().productAttributeId(mallConfig.getAlbumName()).value(lottery.getTitle()).build()); +// attributeValueList.add(MallProductAttributeValue.builder().productAttributeId(mallConfig.getSongId()).value(lottery.getId()).build()); +// attributeValueList.add(MallProductAttributeValue.builder().productAttributeId(mallConfig.getArtistId()).value(lottery.getId()).build()); + attributeValueList.add(MallProductAttributeValue.builder().productAttributeId(mallConfig.getArtistName()).value(lottery.getTitle()).build()); + Map mallMqMap = new HashMap<>(); + mallMqMap.put("lotteryId", lottery.getId()); + mallMqMap.put("mallProduct", mallProduct); + mallMqMap.put("attributeValueList", attributeValueList); + + rabbitTemplate.convertAndSend("luoo_mall_lottery_product_add", mallMqMap); + } + /** * 停止抽奖 * diff --git a/luoo_user/src/main/java/com/luoo/user/service/UserPointLogService.java b/luoo_user/src/main/java/com/luoo/user/service/UserPointLogService.java index ee3e3b9..e13117c 100644 --- a/luoo_user/src/main/java/com/luoo/user/service/UserPointLogService.java +++ b/luoo_user/src/main/java/com/luoo/user/service/UserPointLogService.java @@ -2,10 +2,7 @@ package com.luoo.user.service; import api.PageResult; import com.fasterxml.jackson.databind.ObjectMapper; -import com.luoo.user.dao.LotteryUserDao; -import com.luoo.user.dao.TaskPointDao; -import com.luoo.user.dao.UserInfoDao; -import com.luoo.user.dao.UserPointLogDao; +import com.luoo.user.dao.*; import com.luoo.user.dto.point.DrawDTO; import com.luoo.user.dto.point.UserPointLogSearchDto; import com.luoo.user.pojo.*; @@ -19,6 +16,8 @@ import com.querydsl.jpa.impl.JPAQueryFactory; import constants.ErrorConstants; import constants.RabbitmqConstants; import constants.TaskPointIdConstants; +import dto.MallProduct; +import dto.MallProductAttributeValue; import dto.UserLoginDto; import enums.PointEnums; import exception.BizException; @@ -37,7 +36,9 @@ import java.io.IOException; import java.time.LocalDate; import java.time.format.DateTimeFormatter; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; /** * @program: luoo_parent @@ -67,6 +68,12 @@ public class UserPointLogService { private final LotteryUserDao lotteryUserDao; + @Autowired + private UserinfoShippingAddressDao userinfoShippingAddressDao; + + @Autowired + private RegionDao regionDao; + public UserPointLogService(UserPointLogDao userPointLogDao, IdWorker idWorker, JwtUtil jwtUtil, TaskPointDao taskPointDao, RabbitTemplate rabbitTemplate, UserInfoDao userInfoDao, JPAQueryFactory jpaQueryFactory, LotteryUserDao lotteryUserDao) { @@ -210,8 +217,47 @@ public class UserPointLogService { .build(); lotteryUserDao.save(lotteryUser); + // 发消息创建订单 + createOrder(lotteryUser); + } + /** + * 创建订单 + * + * @param lotteryUser 积分活动对象 + */ + private void createOrder(LotteryUser lotteryUser) { + // 只有待上架允许上架 + + + Map mallMqMap = new HashMap<>(); + mallMqMap.put("lotteryId", lotteryUser.getLotteryId()); +// mallMqMap.put("mallProduct", mallProduct); +// mallMqMap.put("attributeValueList", attributeValueList); +// userid + mallMqMap.put("userId", lotteryUser.getUserId()); + + // username + UserInfo userInfo = userInfoDao.findById(lotteryUser.getUserId()).get(); + mallMqMap.put("nickName", userInfo.getNickName()); + List byUserIdAndAcquiesce = userinfoShippingAddressDao.findByUserIdAndAcquiesce(lotteryUser.getUserId(), 1); + mallMqMap.put("receiverProvince",""); + mallMqMap.put("receiverCity",""); + mallMqMap.put("receiverRegion",""); + mallMqMap.put("receiverDetailAddress",""); + mallMqMap.put("receiverName",""); + mallMqMap.put("receiverPhone",""); + // 地址 + if (null != byUserIdAndAcquiesce) { + mallMqMap.put("receiverProvince",regionDao.findById(byUserIdAndAcquiesce.get(0).getProvinceId()).get().getName()); + + mallMqMap.put("receiverCity",regionDao.findById(byUserIdAndAcquiesce.get(0).getCityId()).get().getName()); + mallMqMap.put("receiverRegion",regionDao.findById(byUserIdAndAcquiesce.get(0).getDistrictId()).get().getName()); + mallMqMap.put("receiverDetailAddress",byUserIdAndAcquiesce.get(0).getAddress()); + mallMqMap.put("receiverName",byUserIdAndAcquiesce.get(0).getConsignee()); + mallMqMap.put("receiverPhone",byUserIdAndAcquiesce.get(0).getPhone()); + } + rabbitTemplate.convertAndSend("luoo_mall_lottery_order_add", mallMqMap); } - /** * 每日签到 * diff --git a/luoo_user/src/main/resources/bootstrap.yml b/luoo_user/src/main/resources/bootstrap.yml index 18edd12..d74d026 100644 --- a/luoo_user/src/main/resources/bootstrap.yml +++ b/luoo_user/src/main/resources/bootstrap.yml @@ -57,3 +57,16 @@ wx: applePay: certificate: https://sandbox.itunes.apple.com/verifyReceipt +mall: + brandId: 60 + brandName: 雀乐 + productCategoryId: 57 + productCategoryName: 歌曲 + productAttributeCategoryId: 16 + artistId: 74 + artistName: 75 + albumId: 76 + albumName: 77 + songId: 78 + productUrl: http://43.248.137.154:8085/product/luoo/detail/{id} +