Skip to content

Commit

Permalink
Merge branch 'master-jdk17' of https://gitee.com/zhijiantianya/yudao-…
Browse files Browse the repository at this point in the history
…cloud

# Conflicts:
#	yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/history/ProductBrowseHistoryController.java
#	yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/social/AppSocialUserController.java
#	yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletRechargeServiceImpl.java
#	yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/social/SocialClientApi.java
#	yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/socail/SocialClientController.java
#	yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImpl.java
  • Loading branch information
YunaiV committed Aug 2, 2024
2 parents b4087e7 + 45095b5 commit cce77b8
Show file tree
Hide file tree
Showing 41 changed files with 553 additions and 86 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cn.iocoder.yudao.framework.ip.core;

import cn.iocoder.yudao.framework.ip.core.enums.AreaTypeEnum;
import com.fasterxml.jackson.annotation.JsonBackReference;
import com.fasterxml.jackson.annotation.JsonManagedReference;
import lombok.AllArgsConstructor;
import lombok.Data;
Expand Down Expand Up @@ -54,7 +55,7 @@ public class Area {
/**
* 子节点
*/
@JsonManagedReference
@JsonBackReference
private List<Area> children;

}
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ public static String randomEmail() {
return randomString() + "@qq.com";
}

public static String randomMobile() {
return "13800138" + RandomUtil.randomNumbers(3);
}

public static String randomURL() {
return "https://www.iocoder.cn/" + randomString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import cn.hutool.core.util.ObjUtil;
import cn.iocoder.yudao.framework.ai.core.model.midjourney.api.MidjourneyApi;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.ai.controller.admin.image.vo.AiImageDrawReqVO;
Expand Down Expand Up @@ -41,7 +40,7 @@ public class AiImageController {

@GetMapping("/my-page")
@Operation(summary = "获取【我的】绘图分页")
public CommonResult<PageResult<AiImageRespVO>> getImagePageMy(@Validated PageParam pageReqVO) {
public CommonResult<PageResult<AiImageRespVO>> getImagePageMy(@Validated AiImagePageReqVO pageReqVO) {
PageResult<AiImageDO> pageResult = imageService.getImagePageMy(getLoginUserId(), pageReqVO);
return success(BeanUtils.toBean(pageResult, AiImageRespVO.class));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.springframework.format.annotation.DateTimeFormat;

import java.time.LocalDateTime;
Expand All @@ -21,6 +19,9 @@ public class AiImagePageReqVO extends PageParam {
@Schema(description = "平台", example = "OpenAI")
private String platform;

@Schema(description = "提示词", example = "1")
private String prompt;

@Schema(description = "绘画状态", example = "1")
private Integer status;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package cn.iocoder.yudao.module.ai.dal.mysql.image;

import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
Expand All @@ -19,7 +18,7 @@
public interface AiImageMapper extends BaseMapperX<AiImageDO> {

default AiImageDO selectByTaskId(String taskId) {
return this.selectOne(AiImageDO::getTaskId, taskId);
return selectOne(AiImageDO::getTaskId, taskId);
}

default PageResult<AiImageDO> selectPage(AiImagePageReqVO reqVO) {
Expand All @@ -32,9 +31,13 @@ default PageResult<AiImageDO> selectPage(AiImagePageReqVO reqVO) {
.orderByDesc(AiImageDO::getId));
}

default PageResult<AiImageDO> selectPage(Long userId, PageParam pageReqVO) {
return selectPage(pageReqVO, new LambdaQueryWrapperX<AiImageDO>()
.eq(AiImageDO::getUserId, userId)
default PageResult<AiImageDO> selectPageMy(Long userId, AiImagePageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<AiImageDO>()
.likeIfPresent(AiImageDO::getPrompt, reqVO.getPrompt())
// 情况一:公开
.eq(Boolean.TRUE.equals(reqVO.getPublicStatus()), AiImageDO::getPublicStatus, reqVO.getPublicStatus())
// 情况二:私有
.eq(Boolean.FALSE.equals(reqVO.getPublicStatus()), AiImageDO::getUserId, userId)
.orderByDesc(AiImageDO::getId));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package cn.iocoder.yudao.module.ai.service.image;

import cn.iocoder.yudao.framework.ai.core.model.midjourney.api.MidjourneyApi;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.ai.controller.admin.image.vo.AiImageDrawReqVO;
import cn.iocoder.yudao.module.ai.controller.admin.image.vo.AiImagePageReqVO;
Expand All @@ -27,7 +26,7 @@ public interface AiImageService {
* @param pageReqVO 分页条件
* @return 绘图分页
*/
PageResult<AiImageDO> getImagePageMy(Long userId, PageParam pageReqVO);
PageResult<AiImageDO> getImagePageMy(Long userId, AiImagePageReqVO pageReqVO);

/**
* 获得绘图记录
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import cn.hutool.http.HttpUtil;
import cn.iocoder.yudao.framework.ai.core.enums.AiPlatformEnum;
import cn.iocoder.yudao.framework.ai.core.model.midjourney.api.MidjourneyApi;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.ai.controller.admin.image.vo.AiImageDrawReqVO;
Expand Down Expand Up @@ -63,8 +62,8 @@ public class AiImageServiceImpl implements AiImageService {
private AiApiKeyService apiKeyService;

@Override
public PageResult<AiImageDO> getImagePageMy(Long userId, PageParam pageReqVO) {
return imageMapper.selectPage(userId, pageReqVO);
public PageResult<AiImageDO> getImagePageMy(Long userId, AiImagePageReqVO pageReqVO) {
return imageMapper.selectPageMy(userId, pageReqVO);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ private AiChatModelDO getModel(AiChatRoleDO role) {
if (role != null && role.getModelId() != null) {
model = chatModalService.getChatModel(role.getModelId());
}
if (model != null) {
if (model == null) {
model = chatModalService.getRequiredDefaultChatModel();
}
Assert.notNull(model, "[AI] 获取不到模型");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ private AiChatModelDO getModel(AiChatRoleDO writeRole) {
if (Objects.nonNull(writeRole) && Objects.nonNull(writeRole.getModelId())) {
model = chatModalService.getChatModel(writeRole.getModelId());
}
if (Objects.isNull(model)) {
if (model == null) {
model = chatModalService.getRequiredDefaultChatModel();
}
Assert.notNull(model, "[AI] 获取不到模型");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,30 @@
package cn.iocoder.yudao.module.product.controller.admin.history;

import cn.hutool.core.collection.CollUtil;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.product.controller.admin.history.vo.ProductBrowseHistoryPageReqVO;
import cn.iocoder.yudao.module.product.controller.admin.history.vo.ProductBrowseHistoryRespVO;
import cn.iocoder.yudao.module.product.dal.dataobject.history.ProductBrowseHistoryDO;
import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO;
import cn.iocoder.yudao.module.product.service.history.ProductBrowseHistoryService;
import cn.iocoder.yudao.module.product.service.spu.ProductSpuService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.Map;
import java.util.Optional;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;

@Tag(name = "管理后台 - 商品浏览记录")
@RestController
Expand All @@ -28,13 +34,24 @@ public class ProductBrowseHistoryController {

@Resource
private ProductBrowseHistoryService browseHistoryService;
@Resource
private ProductSpuService productSpuService;

@GetMapping("/page")
@Operation(summary = "获得商品浏览记录分页")
@PreAuthorize("@ss.hasPermission('product:browse-history:query')")
public CommonResult<PageResult<ProductBrowseHistoryRespVO>> getBrowseHistoryPage(@Valid ProductBrowseHistoryPageReqVO pageReqVO) {
PageResult<ProductBrowseHistoryDO> pageResult = browseHistoryService.getBrowseHistoryPage(pageReqVO);
return success(BeanUtils.toBean(pageResult, ProductBrowseHistoryRespVO.class));
if (CollUtil.isEmpty(pageResult.getList())) {
return success(PageResult.empty());
}

// 得到商品 spu 信息
Map<Long, ProductSpuDO> spuMap = productSpuService.getSpuMap(
convertSet(pageResult.getList(), ProductBrowseHistoryDO::getSpuId));
return success(BeanUtils.toBean(pageResult, ProductBrowseHistoryRespVO.class,
vo -> Optional.ofNullable(spuMap.get(vo.getSpuId()))
.ifPresent(spu -> vo.setSpuName(spu.getName()).setPicUrl(spu.getPicUrl()).setPrice(spu.getPrice()))));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,28 @@

import java.time.LocalDateTime;

import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.REQUIRED;

@Schema(description = "管理后台 - 商品浏览记录 Response VO")
@Data
@ExcelIgnoreUnannotated
public class ProductBrowseHistoryRespVO {

@Schema(description = "记录编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "26055")
@ExcelProperty("记录编号")
@Schema(description = "编号", requiredMode = REQUIRED, example = "1")
private Long id;

@Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "4314")
@ExcelProperty("用户编号")
private Long userId;
@Schema(description = "商品 SPU 编号", requiredMode = REQUIRED, example = "29502")
private Long spuId;

// ========== 商品相关字段 ==========

@Schema(description = "用户是否删除", example = "false")
private Boolean userDeleted;
@Schema(description = "商品 SPU 名称", example = "赵六")
private String spuName;

@Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "42")
@ExcelProperty("商品 SPU 编号")
private Long spuId;
@Schema(description = "商品封面图", example = "https://domain/pic.png")
private String picUrl;

@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("创建时间")
private LocalDateTime createTime;
@Schema(description = "商品单价", example = "100")
private Integer price;

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cn.iocoder.yudao.module.product.service.spu;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuPageReqVO;
import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuSaveReqVO;
import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuUpdateStatusReqVO;
Expand Down Expand Up @@ -58,6 +59,17 @@ public interface ProductSpuService {
*/
List<ProductSpuDO> getSpuList(Collection<Long> ids);

/**
* 获得商品 SPU Map
*
* @param ids 编号数组
* @return 商品 SPU Map
*/
default Map<Long, ProductSpuDO> getSpuMap(Collection<Long> ids) {
List<ProductSpuDO> list = getSpuList(ids);
return CollectionUtils.convertMap(list, ProductSpuDO::getId);
}

/**
* 获得指定状态的商品 SPU 列表
*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package cn.iocoder.yudao.module.promotion.enums;

/**
* 通知模板枚举类
*
* @author HUIHUI
*/
public interface MessageTemplateConstants {

//======================= 小程序订阅消息模版 =======================

String COMBINATION_SUCCESS = "拼团结果通知";

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@
import cn.iocoder.yudao.module.product.api.category.ProductCategoryApi;
import cn.iocoder.yudao.module.product.api.sku.ProductSkuApi;
import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi;
import cn.iocoder.yudao.module.system.api.social.SocialClientApi;
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
import cn.iocoder.yudao.module.trade.api.order.TradeOrderApi;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Configuration;

@Configuration(proxyBeanMethods = false)
@EnableFeignClients(clients = {ProductSkuApi.class, ProductSpuApi.class, ProductCategoryApi.class,
MemberUserApi.class, TradeOrderApi.class, AdminUserApi.class,
MemberUserApi.class, TradeOrderApi.class, AdminUserApi.class, SocialClientApi.class,
WebSocketSenderApi.class})
public class RpcConfiguration {
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import cn.hutool.extra.spring.SpringUtil;
import cn.iocoder.yudao.framework.common.core.KeyValue;
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
import cn.iocoder.yudao.module.member.api.user.MemberUserApi;
Expand All @@ -23,9 +24,12 @@
import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationRecordDO;
import cn.iocoder.yudao.module.promotion.dal.mysql.combination.CombinationRecordMapper;
import cn.iocoder.yudao.module.promotion.enums.combination.CombinationRecordStatusEnum;
import cn.iocoder.yudao.module.system.api.social.SocialClientApi;
import cn.iocoder.yudao.module.system.api.social.dto.SocialWxaSubscribeMessageSendReqDTO;
import cn.iocoder.yudao.module.trade.api.order.TradeOrderApi;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Lazy;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
Expand All @@ -40,6 +44,7 @@
import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.afterNow;
import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.beforeNow;
import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*;
import static cn.iocoder.yudao.module.promotion.enums.MessageTemplateConstants.COMBINATION_SUCCESS;

// TODO 芋艿:等拼团记录做完,完整 review 下

Expand All @@ -66,8 +71,10 @@ public class CombinationRecordServiceImpl implements CombinationRecordService {
private ProductSkuApi productSkuApi;

@Resource
@Lazy
@Lazy // 延迟加载,避免循环依赖
private TradeOrderApi tradeOrderApi;
@Resource
public SocialClientApi socialClientApi;

// TODO @芋艿:在详细预览下;
@Override
Expand Down Expand Up @@ -205,7 +212,25 @@ private void updateCombinationRecordWhenCreate(Long headId, CombinationActivityD
}
updateRecords.add(updateRecord);
});
combinationRecordMapper.updateBatch(updateRecords);
Boolean updateSuccess = combinationRecordMapper.updateBatch(updateRecords);

// 3. 拼团成功发送订阅消息
if (updateSuccess && isFull) {
records.forEach(item -> {
getSelf().sendCombinationResultMessage(item);
});
}
}

@Async
public void sendCombinationResultMessage(CombinationRecordDO record) {
// 构建并发送模版消息
socialClientApi.sendWxaSubscribeMessage(new SocialWxaSubscribeMessageSendReqDTO()
.setUserId(record.getUserId()).setUserType(UserTypeEnum.MEMBER.getValue())
.setTemplateTitle(COMBINATION_SUCCESS)
.setPage("pages/order/detail?id=" + record.getOrderId()) // 订单详情页
.addMessage("thing1", "商品拼团活动") // 活动标题
.addMessage("thing2", "恭喜您拼团成功!我们将尽快为您发货。")); // 温馨提示
}

@Override
Expand Down
Loading

0 comments on commit cce77b8

Please sign in to comment.