@@ -134,6 +134,13 @@ public class StripeController {
|
|||||||
public Response<String> retrievePromotionCode(@RequestParam String retrievePromotionCode){
|
public Response<String> retrievePromotionCode(@RequestParam String retrievePromotionCode){
|
||||||
return Response.success(stripeService.retrievePromotionCode(retrievePromotionCode));
|
return Response.success(stripeService.retrievePromotionCode(retrievePromotionCode));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation("更新推广码信息")
|
||||||
|
@GetMapping("/updatePromCodeInfo")
|
||||||
|
public Response<ProductCoupons> updateCouponsInfo(@RequestParam Long id, @RequestParam(required = false) Long paidCommission,
|
||||||
|
@RequestParam(required = false) String cooperator, @RequestParam(required = false) String remark){
|
||||||
|
return Response.success(stripeService.updateCouponsInfo(id, paidCommission, cooperator, remark));
|
||||||
|
}
|
||||||
/*@ApiOperation("临时 取消订阅")
|
/*@ApiOperation("临时 取消订阅")
|
||||||
@GetMapping("/cancelSubscriptionTemp")
|
@GetMapping("/cancelSubscriptionTemp")
|
||||||
public Response<String> cancelSubscriptionTemp(@RequestParam String subscriptionId) {
|
public Response<String> cancelSubscriptionTemp(@RequestParam String subscriptionId) {
|
||||||
|
|||||||
@@ -3,10 +3,12 @@ package com.ai.da.mapper.primary.entity;
|
|||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@Data
|
@Data
|
||||||
@TableName("t_product_coupons")
|
@TableName("t_product_coupons")
|
||||||
|
@NoArgsConstructor
|
||||||
public class ProductCoupons extends BaseEntity{
|
public class ProductCoupons extends BaseEntity{
|
||||||
// 优惠券id
|
// 优惠券id
|
||||||
private String couponId;
|
private String couponId;
|
||||||
@@ -35,16 +37,15 @@ public class ProductCoupons extends BaseEntity{
|
|||||||
// 备注
|
// 备注
|
||||||
private String remark;
|
private String remark;
|
||||||
|
|
||||||
public ProductCoupons() {
|
public ProductCoupons(String couponId, Long redeemBy, String promotionCodeId, String promotionCode, Long maxRedemptions, float percentOff, float commissionRate, String cooperator, String remark) {
|
||||||
}
|
|
||||||
|
|
||||||
public ProductCoupons(String couponId, Long redeemBy, String promotionCodeId, String promotionCode, Long maxRedemptions, float percentOff, float commissionRate) {
|
|
||||||
this.couponId = couponId;
|
this.couponId = couponId;
|
||||||
this.redeemBy = redeemBy;
|
this.redeemBy = redeemBy;
|
||||||
this.promotionCodeId = promotionCodeId;
|
this.promotionCodeId = promotionCodeId;
|
||||||
this.promotionCode = promotionCode;
|
this.promotionCode = promotionCode;
|
||||||
this.maxRedemptions = maxRedemptions;
|
this.maxRedemptions = maxRedemptions;
|
||||||
this.percentOff = percentOff;
|
this.percentOff = percentOff;
|
||||||
|
this.cooperator = cooperator;
|
||||||
|
this.remark = remark;
|
||||||
this.commissionRate = commissionRate;
|
this.commissionRate = commissionRate;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,4 +17,8 @@ public class CreateCouponDTO {
|
|||||||
private Long timestamp;
|
private Long timestamp;
|
||||||
@ApiModelProperty("推广码最大使用次数")
|
@ApiModelProperty("推广码最大使用次数")
|
||||||
private Long maxRedemptions;
|
private Long maxRedemptions;
|
||||||
|
@ApiModelProperty("合作者/机构名")
|
||||||
|
private String cooperator;
|
||||||
|
@ApiModelProperty("备注")
|
||||||
|
private String remark;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,6 +61,8 @@ public interface StripeService {
|
|||||||
|
|
||||||
CheckCouponsVO checkProductCoupon(String promotionCode, Long price);
|
CheckCouponsVO checkProductCoupon(String promotionCode, Long price);
|
||||||
|
|
||||||
|
ProductCoupons updateCouponsInfo(Long id, Long paidCommission, String cooperator, String remark);
|
||||||
|
|
||||||
ProductCoupons getProductCoupon(String promotionCode, String promotionCodeId);
|
ProductCoupons getProductCoupon(String promotionCode, String promotionCodeId);
|
||||||
|
|
||||||
String retrieveCoupon(String couponId);
|
String retrieveCoupon(String couponId);
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.ai.da.service.impl;
|
|||||||
import cn.hutool.core.collection.CollectionUtil;
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
import com.ai.da.common.config.FileProperties;
|
import com.ai.da.common.config.FileProperties;
|
||||||
import com.ai.da.common.config.exception.BusinessException;
|
import com.ai.da.common.config.exception.BusinessException;
|
||||||
|
import com.ai.da.common.constant.CommonConstant;
|
||||||
import com.ai.da.common.context.UserContext;
|
import com.ai.da.common.context.UserContext;
|
||||||
import com.ai.da.common.enums.*;
|
import com.ai.da.common.enums.*;
|
||||||
import com.ai.da.common.response.ResultEnum;
|
import com.ai.da.common.response.ResultEnum;
|
||||||
@@ -17,13 +18,16 @@ import com.ai.da.model.enums.StyleEnum;
|
|||||||
import com.ai.da.model.vo.*;
|
import com.ai.da.model.vo.*;
|
||||||
import com.ai.da.python.PythonService;
|
import com.ai.da.python.PythonService;
|
||||||
import com.ai.da.python.vo.DesignPythonItem;
|
import com.ai.da.python.vo.DesignPythonItem;
|
||||||
|
import com.ai.da.python.vo.ImageSegmentation;
|
||||||
import com.ai.da.service.*;
|
import com.ai.da.service.*;
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
import com.google.gson.Gson;
|
||||||
import io.netty.util.internal.StringUtil;
|
import io.netty.util.internal.StringUtil;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
@@ -33,6 +37,7 @@ import org.springframework.stereotype.Service;
|
|||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -78,6 +83,8 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
|
|||||||
private String collectionElement;
|
private String collectionElement;
|
||||||
@Value("${minio.bucketName.gradient}")
|
@Value("${minio.bucketName.gradient}")
|
||||||
private String gradientBucketName;
|
private String gradientBucketName;
|
||||||
|
@Value("${minio.bucketName.users}")
|
||||||
|
private String userBucketName;
|
||||||
@Resource
|
@Resource
|
||||||
private RedisUtil redisUtil;
|
private RedisUtil redisUtil;
|
||||||
|
|
||||||
@@ -608,6 +615,22 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
|
|||||||
LibraryModelPoint modelPoint = libraryModelPointService.getByRelationId(byId.getId(), designDTO.getModelType());
|
LibraryModelPoint modelPoint = libraryModelPointService.getByRelationId(byId.getId(), designDTO.getModelType());
|
||||||
elementVO.setDesignLibraryModelPoint(calculateTemplatePointTemplate(modelPoint, 700, 320, byId.getUrl()));
|
elementVO.setDesignLibraryModelPoint(calculateTemplatePointTemplate(modelPoint, 700, 320, byId.getUrl()));
|
||||||
}
|
}
|
||||||
|
// todo 开发分支代码,暂时以注释形式存在
|
||||||
|
/*
|
||||||
|
if (!StringUtils.isEmpty(designDTO.getModelType())) {
|
||||||
|
if (designDTO.getModelType().equals(ModelType.LIBRARY.getValue())) {
|
||||||
|
Library byId = libraryService.getById(designDTO.getTemplateId());
|
||||||
|
LibraryModelPoint modelPoint = libraryModelPointService.getByRelationId(byId.getId(), designDTO.getModelType());
|
||||||
|
elementVO.setDesignLibraryModelPoint(calculateTemplatePointTemplate(modelPoint, byId.getHigh(), byId.getWidth(), byId.getUrl()));
|
||||||
|
} else if (designDTO.getModelType().equals(ModelType.SYSTEM.getValue())) {
|
||||||
|
SysFileVO byId = sysFileService.getById(designDTO.getTemplateId());
|
||||||
|
if (!StringUtils.isEmpty(byId.getLevel3Type()) && byId.getLevel2Type().equals("Female")) {
|
||||||
|
elementVO.setStyle(byId.getLevel3Type());
|
||||||
|
}
|
||||||
|
LibraryModelPoint modelPoint = libraryModelPointService.getByRelationId(byId.getId(), designDTO.getModelType());
|
||||||
|
elementVO.setDesignLibraryModelPoint(calculateTemplatePointTemplate(modelPoint, 700, 320, byId.getUrl()));
|
||||||
|
}
|
||||||
|
}*/
|
||||||
elementVO.setModelSex(designDTO.getModelSex());
|
elementVO.setModelSex(designDTO.getModelSex());
|
||||||
elementVO.setRequestIdList(designDTO.getRequestIdList());
|
elementVO.setRequestIdList(designDTO.getRequestIdList());
|
||||||
if (null != designDTO.getDesignNum()) {
|
if (null != designDTO.getDesignNum()) {
|
||||||
@@ -946,4 +969,98 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
|
|||||||
|
|
||||||
return generateDetail;
|
return generateDetail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 对于上传图片或者从library选择的图片进行图片分割
|
||||||
|
public List<CollectionElementVO> selectedImageSeg(List<MultipartFile> files, Long id, String type) {
|
||||||
|
Long accountId = UserContext.getUserHolder().getId();
|
||||||
|
List<CollectionElementVO> resp = new ArrayList<>();
|
||||||
|
List<ImageSegmentation.ImageDate> imageDates = new ArrayList<>();
|
||||||
|
|
||||||
|
boolean isUploadMode = !files.isEmpty();
|
||||||
|
Library library = null;
|
||||||
|
|
||||||
|
// 判断是否是上传的图片
|
||||||
|
if (isUploadMode) {
|
||||||
|
String objectName = accountId + "/ImageSegment/input";
|
||||||
|
for (MultipartFile file : files) {
|
||||||
|
String md5 = MD5Utils.encryptFile(file);
|
||||||
|
String segmentedResult = redisUtil.getFromString(RedisUtil.IMAGE_SEGMENTATION + md5);
|
||||||
|
// 判断上传的图片是否有已分割的数据
|
||||||
|
if (StringUtil.isNullOrEmpty(segmentedResult)) {
|
||||||
|
String path = minioUtil.upload(userBucketName, objectName, file);
|
||||||
|
ImageSegmentation.ImageDate imageDate = new ImageSegmentation().new ImageDate();
|
||||||
|
imageDate.setImage_url(path);
|
||||||
|
imageDate.setImage_type(type);
|
||||||
|
imageDates.add(imageDate);
|
||||||
|
} else {
|
||||||
|
ImageSegmentation.ImageDate imageData = JSONObject.parseObject(segmentedResult, ImageSegmentation.ImageDate.class);
|
||||||
|
resp.add(createCollectionElementVO(accountId, null, null, imageData.getImage_url(), imageData.getClothing_url()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (Objects.nonNull(id)) {
|
||||||
|
library = libraryService.getById(id);
|
||||||
|
// 判断从library中选择的图片是否有分割数据
|
||||||
|
if (Objects.isNull(library)) {
|
||||||
|
throw new BusinessException("library.not.found");
|
||||||
|
}
|
||||||
|
if (StringUtil.isNullOrEmpty(library.getSegmentedData())) {
|
||||||
|
ImageSegmentation.ImageDate imageDate = new ImageSegmentation().new ImageDate();
|
||||||
|
imageDate.setImage_url(library.getUrl());
|
||||||
|
imageDate.setImage_type(type);
|
||||||
|
imageDates.add(imageDate);
|
||||||
|
} else {
|
||||||
|
List<String> restoredList = Arrays.asList(library.getSegmentedData().split(","));
|
||||||
|
resp.add(createCollectionElementVO(accountId, id, library.getLevel1Type(), library.getUrl(), restoredList));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理需要分割的图片
|
||||||
|
if (!imageDates.isEmpty()) {
|
||||||
|
// 准备图片分割的参数
|
||||||
|
ImageSegmentation imageSegmentation = new ImageSegmentation();
|
||||||
|
imageSegmentation.setUser_id(accountId);
|
||||||
|
imageSegmentation.setImage_data(imageDates);
|
||||||
|
// 图片分割
|
||||||
|
List<ImageSegmentation.ImageDate> segmented = pythonService.imageSegmentation(imageSegmentation);
|
||||||
|
// 处理图片分割结果
|
||||||
|
for (ImageSegmentation.ImageDate imageData : segmented) {
|
||||||
|
if (isUploadMode) {
|
||||||
|
// 上传的图片需要添加到redis中存一天
|
||||||
|
String key = RedisUtil.IMAGE_SEGMENTATION +
|
||||||
|
MD5Utils.encryptFile
|
||||||
|
(minioUtil.getPreSignedUrl
|
||||||
|
(imageData.getImage_url(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME), false);
|
||||||
|
redisUtil.addToString(key, new Gson().toJson(imageData), CommonConstant.GENERATE_RESULT_EXPIRE_TIME);
|
||||||
|
resp.add(createCollectionElementVO(accountId, null, null, imageData.getImage_url(), imageData.getClothing_url()));
|
||||||
|
} else {
|
||||||
|
// 从library中选择的图片需要更新数据库中对应图片的分割数据
|
||||||
|
String segmentedData = String.join(",", imageData.getClothing_url());
|
||||||
|
library.setSegmentedData(segmentedData);
|
||||||
|
library.setUpdateDate(new Date());
|
||||||
|
libraryService.updateById(library);
|
||||||
|
resp.add(createCollectionElementVO(accountId, id, library.getLevel1Type(), library.getUrl(), imageData.getClothing_url()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return resp;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 准备返回数据
|
||||||
|
private CollectionElementVO createCollectionElementVO(Long accountId, Long id, String level1Type,
|
||||||
|
String imageUrl, List<String> clothingUrls) {
|
||||||
|
CollectionElementVO vo = new CollectionElementVO();
|
||||||
|
vo.setAccountId(accountId);
|
||||||
|
vo.setId(id);
|
||||||
|
vo.setLevel1Type(level1Type);
|
||||||
|
vo.setUrl(minioUtil.getPreSignedUrl(imageUrl, CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
|
||||||
|
vo.setMinIOPath(imageUrl);
|
||||||
|
|
||||||
|
List<String> segUrls = new ArrayList<>();
|
||||||
|
for (String seg : clothingUrls) {
|
||||||
|
segUrls.add(minioUtil.getPreSignedUrl(seg, CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
|
||||||
|
}
|
||||||
|
vo.setSegmentedImages(segUrls);
|
||||||
|
return vo;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1396,7 +1396,8 @@ public class StripeServiceImpl implements StripeService {
|
|||||||
PromotionCode promotionCode = createPromotionCode(coupon.getId(), createCouponDTO.getMaxRedemptions());
|
PromotionCode promotionCode = createPromotionCode(coupon.getId(), createCouponDTO.getMaxRedemptions());
|
||||||
// 3、落库
|
// 3、落库
|
||||||
ProductCoupons productCoupons = new ProductCoupons(coupon.getId(), createCouponDTO.getTimestamp(), promotionCode.getId(),
|
ProductCoupons productCoupons = new ProductCoupons(coupon.getId(), createCouponDTO.getTimestamp(), promotionCode.getId(),
|
||||||
promotionCode.getCode(), createCouponDTO.getMaxRedemptions(), createCouponDTO.getPercentOff(), createCouponDTO.getCommissionRate());
|
promotionCode.getCode(), createCouponDTO.getMaxRedemptions(), createCouponDTO.getPercentOff(),
|
||||||
|
createCouponDTO.getCommissionRate(), createCouponDTO.getCooperator(), createCouponDTO.getRemark());
|
||||||
productCoupons.setCreateTime(LocalDateTime.now());
|
productCoupons.setCreateTime(LocalDateTime.now());
|
||||||
productCouponsMapper.insert(productCoupons);
|
productCouponsMapper.insert(productCoupons);
|
||||||
|
|
||||||
@@ -1422,6 +1423,31 @@ public class StripeServiceImpl implements StripeService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ProductCoupons updateCouponsInfo(Long id, Long paidCommission, String cooperator, String remark){
|
||||||
|
ProductCoupons productCoupons = productCouponsMapper.selectById(id);
|
||||||
|
if (Objects.isNull(productCoupons)){
|
||||||
|
throw new BusinessException("Unknown Promotion Code");
|
||||||
|
}
|
||||||
|
boolean flag = false;
|
||||||
|
if (!StringUtil.isNullOrEmpty(cooperator)){
|
||||||
|
productCoupons.setCooperator(cooperator);
|
||||||
|
flag = true;
|
||||||
|
}
|
||||||
|
if (!StringUtil.isNullOrEmpty(remark)){
|
||||||
|
productCoupons.setRemark(remark);
|
||||||
|
flag = true;
|
||||||
|
}
|
||||||
|
if (Objects.nonNull(paidCommission)){
|
||||||
|
productCoupons.setPaidCommission(paidCommission);
|
||||||
|
flag = true;
|
||||||
|
}
|
||||||
|
if (flag){
|
||||||
|
productCoupons.setUpdateTime(LocalDateTime.now());
|
||||||
|
productCouponsMapper.updateById(productCoupons);
|
||||||
|
}
|
||||||
|
return productCoupons;
|
||||||
|
}
|
||||||
|
|
||||||
public ProductCoupons checkProductCoupon(String promotionCode){
|
public ProductCoupons checkProductCoupon(String promotionCode){
|
||||||
Stripe.apiKey = privateKey;
|
Stripe.apiKey = privateKey;
|
||||||
Long accountId = UserContext.getUserHolder().getId();
|
Long accountId = UserContext.getUserHolder().getId();
|
||||||
|
|||||||
Reference in New Issue
Block a user