dev798
parent
8dc71ff9dc
commit
1e24c67a5b
|
@ -4,8 +4,10 @@ import com.muyu.common.core.constant.ServiceNameConstants;
|
|||
import com.muyu.common.core.domain.R;
|
||||
import com.muyu.common.system.domain.SysFile;
|
||||
import com.muyu.common.system.remote.factory.RemoteFileFallbackFactory;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestPart;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
@ -15,6 +17,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|||
*
|
||||
* @author muyu
|
||||
*/
|
||||
|
||||
@FeignClient(contextId = "remoteFileService", value = ServiceNameConstants.FILE_SERVICE, fallbackFactory = RemoteFileFallbackFactory.class)
|
||||
public interface RemoteFileService {
|
||||
/**
|
||||
|
|
|
@ -102,4 +102,5 @@ public class Product extends BaseEntity {
|
|||
@ApiModelProperty(value = "PC端信息")
|
||||
private String pcInformation;
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -109,4 +109,7 @@ public class ProductResp {
|
|||
@ApiModelProperty(value = "类型名称")
|
||||
private String typeName;
|
||||
|
||||
@ApiModelProperty(value = "图片")
|
||||
private String imagesUrl;
|
||||
|
||||
}
|
||||
|
|
|
@ -6,6 +6,9 @@ import com.muyu.common.swagger.annotation.EnableCustomSwagger2;
|
|||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
/**
|
||||
* @author A3385
|
||||
*/
|
||||
@EnableCustomConfig
|
||||
@EnableCustomSwagger2
|
||||
@EnableMyFeignClients
|
||||
|
|
|
@ -18,4 +18,6 @@ public interface ProductMapper {
|
|||
void insertProduct(Product product);
|
||||
|
||||
void updateMothodId(Integer id);
|
||||
|
||||
Integer findProductNumber(ProductReq productReq);
|
||||
}
|
||||
|
|
|
@ -15,4 +15,6 @@ public interface ProductSkuMapper {
|
|||
void insertProductSku(List<ProductSku> productSkuList);
|
||||
|
||||
void insertProductSkuAttr(List<ProductSkuAttr> productSkuAttrs);
|
||||
|
||||
Integer findSkuId(List<ProductSku> productSkus);
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@ import com.muyu.product.domain.DTO.*;
|
|||
import com.muyu.product.domain.DTO.Number;
|
||||
import com.muyu.product.domain.Resp.ProductResp;
|
||||
import com.muyu.product.domain.req.ProductReq;
|
||||
import com.muyu.product.domain.req.ProductSkuNew;
|
||||
import com.muyu.product.domain.req.QueryProductReq;
|
||||
import com.muyu.product.mapper.ProductMapper;
|
||||
import com.muyu.product.mapper.ProductSkuMapper;
|
||||
|
@ -22,12 +21,12 @@ import org.springframework.stereotype.Service;
|
|||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
|
||||
/**
|
||||
* @Author: wangxinyuan
|
||||
* @Date: 2024/3/29 17:06
|
||||
*/
|
||||
@Service
|
||||
@Log4j2
|
||||
public class ProductServiceImpl implements ProductService {
|
||||
|
@ -49,6 +48,49 @@ public class ProductServiceImpl implements ProductService {
|
|||
private ProductSkuMapper productSkuMapper;
|
||||
|
||||
|
||||
public void checkProductParams(ProductReq productReq){
|
||||
CompletableFuture<ValidationResult>methodTypeFuture =
|
||||
CompletableFuture.supplyAsync(() -> checkMethodType(productReq));
|
||||
CompletableFuture<ValidationResult>skuIdFuture =
|
||||
CompletableFuture.supplyAsync(() -> findSkuId(productReq));
|
||||
CompletableFuture<ValidationResult>productNumberFuture =
|
||||
CompletableFuture.supplyAsync(() -> checkProductNumber(productReq));
|
||||
CompletableFuture<String>allValidFuture =
|
||||
methodTypeFuture.thenCombine(skuIdFuture,
|
||||
(methodTypeResult,skuIdResult)->
|
||||
methodTypeResult.isValid()&& skuIdResult.isValid())
|
||||
.thenCombine(productNumberFuture,(previousResult,productNumberResult)
|
||||
->previousResult&&productNumberResult.isValid())
|
||||
.thenApply(allValid->allValid ? "所有检查通过":"存在检查未通过")
|
||||
.exceptionally(throwable -> "检验过程发送异常" + throwable.getMessage());
|
||||
|
||||
allValidFuture.thenAccept(System.out::println);
|
||||
}
|
||||
|
||||
private ValidationResult checkProductNumber(ProductReq productReq) {
|
||||
Integer productNumber = productMapper.findProductNumber(productReq);
|
||||
if(productNumber>=Integer.valueOf(Number.zero.getValue())){
|
||||
return new ValidationResult(false,"productNumber不能重复");
|
||||
}
|
||||
return new ValidationResult(true,"通过");
|
||||
}
|
||||
|
||||
private ValidationResult findSkuId(ProductReq productReq) {
|
||||
Integer skuId = productSkuMapper.findSkuId(productReq.getProductSkus());
|
||||
if(skuId>=Integer.valueOf(Number.zero.getValue())){
|
||||
return new ValidationResult(false,"skuID不能重复");
|
||||
}
|
||||
return new ValidationResult(true,"通过");
|
||||
}
|
||||
|
||||
private ValidationResult checkMethodType(ProductReq productReq) {
|
||||
if(productReq.getProduct().getMethodType() == null){
|
||||
return new ValidationResult(false,"method type 不能空");
|
||||
}
|
||||
return new ValidationResult(true,"通过");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public PageInfo<ProductResp> queryProduct(QueryProductReq productReq) {
|
||||
PageHelper.startPage(productReq.getPageNum(),productReq.getPageSize());
|
||||
|
@ -156,4 +198,22 @@ public class ProductServiceImpl implements ProductService {
|
|||
private void insertProduct(Product product) {
|
||||
productMapper.insertProduct(product);
|
||||
}
|
||||
|
||||
private void calculateProductPrice(ProductReq productReq){
|
||||
Integer methodType = productReq.getProduct().getMethodType();
|
||||
|
||||
//特价
|
||||
if(Number.one.getValue().equals(String.valueOf(methodType))){
|
||||
|
||||
LocalDateTime now=LocalDateTime.now();
|
||||
|
||||
LocalDateTime start = productReq.getPreference().getPreferenceStartTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
|
||||
LocalDateTime end = productReq.getPreference().getPreferenceEndTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
|
||||
|
||||
|
||||
if(now.isAfter(start)&&now.isBefore(end)){
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
product_information,product_unit,product_weight,product_sort,product_points,
|
||||
product_growth,product_max_points,product_foreknow,product_status,product_new,
|
||||
product_recommended,details_title,details_information,details_key_word,details_remark,
|
||||
method_type,t_product_brand.brand_name,t_product_type.type_name,sale_price
|
||||
method_type,t_product_brand.brand_name,t_product_type.type_name,sale_price,images_url
|
||||
</sql>
|
||||
|
||||
<insert id="insertProduct">
|
||||
|
@ -74,6 +74,7 @@
|
|||
LEFT JOIN t_product_brand ON t_product.brand_id = t_product_brand.id
|
||||
LEFT join t_product_type ON t_product.type_id = t_product_type.id
|
||||
left JOIN t_product_sku on t_product_sku.product_id = t_product.id
|
||||
left join t_product_images on t_product.id = t_product_images.product_id
|
||||
<where>
|
||||
t_product.id_delete = 1
|
||||
<if test="productName != null and productName != ''">
|
||||
|
@ -97,6 +98,9 @@
|
|||
</where>
|
||||
order by product_sort
|
||||
</select>
|
||||
<select id="findProductNumber" resultType="java.lang.Integer">
|
||||
|
||||
</select>
|
||||
|
||||
|
||||
<!-- 添加其他操作方法如插入、更新、删除等 -->
|
||||
|
|
|
@ -45,5 +45,11 @@
|
|||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
<select id="findSkuId" resultType="java.lang.Integer">
|
||||
select count(id) from t_product_sku where id in
|
||||
<foreach collection="productSkus" separator="," open="(" close=")" item="id">
|
||||
#{id}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
|
Loading…
Reference in New Issue