|
@@ -5,12 +5,21 @@ import java.util.List;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.chelvc.cloud.vehicle.api.constant.CategoryType;
|
|
|
import com.chelvc.cloud.vehicle.api.dto.GoodsDTO;
|
|
|
+import com.chelvc.cloud.vehicle.api.dto.GoodsDetailDTO;
|
|
|
+import com.chelvc.cloud.vehicle.api.param.CommentQueryParam;
|
|
|
import com.chelvc.cloud.vehicle.api.param.GoodsQueryParam;
|
|
|
+import com.chelvc.cloud.vehicle.server.copier.GoodsCopier;
|
|
|
import com.chelvc.cloud.vehicle.server.dao.GoodsMapper;
|
|
|
import com.chelvc.cloud.vehicle.server.entity.Goods;
|
|
|
+import com.chelvc.cloud.vehicle.server.service.CommentService;
|
|
|
+import com.chelvc.cloud.vehicle.server.service.CouponService;
|
|
|
import com.chelvc.cloud.vehicle.server.service.GoodsService;
|
|
|
+import com.chelvc.framework.base.context.SessionContextHolder;
|
|
|
+import com.chelvc.framework.database.context.DatabaseContextHolder;
|
|
|
import lombok.NonNull;
|
|
|
+import lombok.RequiredArgsConstructor;
|
|
|
import org.apache.dubbo.config.annotation.DubboService;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
/**
|
|
@@ -19,9 +28,13 @@ import org.springframework.util.CollectionUtils;
|
|
|
* @author Woody
|
|
|
* @date 2023/7/17
|
|
|
*/
|
|
|
+@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
|
|
@DubboService(interfaceClass = com.chelvc.cloud.vehicle.api.service.GoodsService.class)
|
|
|
public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements GoodsService,
|
|
|
com.chelvc.cloud.vehicle.api.service.GoodsService {
|
|
|
+ private final CouponService couponService;
|
|
|
+ private final CommentService commentService;
|
|
|
+
|
|
|
@Override
|
|
|
public List<CategoryType> listMerchantGoodsCategoryTypes(@NonNull Long merchantId) {
|
|
|
List<CategoryType> types = this.baseMapper.listMerchantGoodsCategoryTypes(merchantId);
|
|
@@ -31,6 +44,26 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
|
|
return types;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public GoodsDetailDTO getGoodsDetail(@NonNull Long id) {
|
|
|
+ GoodsDetailDTO detail = GoodsDetailDTO.builder().build();
|
|
|
+
|
|
|
+ // 获取商品信息
|
|
|
+ Goods goods = DatabaseContextHolder.getRequireEntity(this, id, "商品不存在");
|
|
|
+ detail.setGoods(GoodsCopier.INSTANCE.copying(goods));
|
|
|
+
|
|
|
+ // 获取用户可用优惠券
|
|
|
+ if (!CollectionUtils.isEmpty(goods.getCouponIds())) {
|
|
|
+ Long userId = SessionContextHolder.getId();
|
|
|
+ detail.setCoupons(this.couponService.listUserGoodsActiveCoupons(userId, goods.getCouponIds()));
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取商品评价列表
|
|
|
+ CommentQueryParam param = CommentQueryParam.builder().size(10).build();
|
|
|
+ detail.setComments(this.commentService.listGoodsComments(id, param));
|
|
|
+ return detail;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public List<GoodsDTO> listMerchantSimpleGoods(@NonNull Long merchantId, @NonNull GoodsQueryParam param) {
|
|
|
return this.baseMapper.listMerchantSimpleGoods(merchantId, param);
|