Hotfix/bug repair
This commit is contained in:
@ -0,0 +1,55 @@
|
||||
package co.yixiang.listener;
|
||||
|
||||
import co.yixiang.enums.RedisKeyEnum;
|
||||
import co.yixiang.modules.shop.entity.YxSystemConfig;
|
||||
import co.yixiang.modules.shop.service.YxSystemConfigService;
|
||||
import co.yixiang.utils.StringUtils;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
|
||||
/**
|
||||
* api服务启动初始化reids
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
||||
public class RedisKeyInitialization {
|
||||
|
||||
|
||||
private final YxSystemConfigService systemConfigService;
|
||||
|
||||
private final RedisTemplate<Object, Object> redisTemplate;
|
||||
|
||||
@PostConstruct
|
||||
public void redisKeyInitialization(){
|
||||
try {
|
||||
List<RedisKeyEnum> redisKeyEnums = Stream.of(RedisKeyEnum.values()).collect(Collectors.toList());
|
||||
List<YxSystemConfig> systemConfigs = systemConfigService.list();
|
||||
for (RedisKeyEnum redisKeyEnum : redisKeyEnums) {
|
||||
Object redisKey = redisTemplate.opsForValue().get(redisKeyEnum.getValue());
|
||||
if(redisKey == null){
|
||||
String dbKey = "";
|
||||
for (YxSystemConfig systemConfig : systemConfigs) {
|
||||
if(systemConfig.getMenuName().equals(redisKeyEnum.getValue())){
|
||||
dbKey = systemConfig.getValue();
|
||||
}
|
||||
}
|
||||
redisTemplate.opsForValue().set(redisKeyEnum.getValue(),dbKey);
|
||||
}
|
||||
}
|
||||
log.info("---------------redisKey初始化成功---------------");
|
||||
}catch (Exception e){
|
||||
log.info("redisKey初始化失败: {}",e);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -259,10 +259,10 @@ public class StoreBargainController extends BaseController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 拼团海报
|
||||
* 砍价海报
|
||||
*/
|
||||
@PostMapping("/bargain/poster")
|
||||
@ApiOperation(value = "拼团海报",notes = "拼团海报")
|
||||
@ApiOperation(value = "砍价海报",notes = "砍价海报")
|
||||
public ApiResult<Object> poster(@RequestBody String jsonStr){
|
||||
JSONObject jsonObject = JSON.parseObject(jsonStr);
|
||||
Integer bargainId = jsonObject.getInteger("bargainId");
|
||||
@ -310,7 +310,12 @@ public class StoreBargainController extends BaseController {
|
||||
File file = FileUtil.mkdir(new File(fileDir));
|
||||
if(userType.equals(AppFromEnum.ROUNTINE.getValue())){
|
||||
siteUrl = siteUrl+"/bargain/";
|
||||
QrCodeUtil.generate(siteUrl+"?bargainId="+bargainId+"&uid="+uid+"&spread="+uid, 180, 180,
|
||||
QrCodeUtil.generate(siteUrl+"?bargainId="+bargainId+"&uid="+uid+"&spread="+uid+"&pageType=dargain&codeType="+AppFromEnum.ROUNTINE.getValue(), 180, 180,
|
||||
FileUtil.file(fileDir+name));
|
||||
}
|
||||
else if(userType.equals(AppFromEnum.APP.getValue())){
|
||||
siteUrl = siteUrl+"/bargain/";
|
||||
QrCodeUtil.generate(siteUrl+"?bargainId="+bargainId+"&uid="+uid+"&spread="+uid+"&pageType=dargain&codeType="+AppFromEnum.APP.getValue(), 180, 180,
|
||||
FileUtil.file(fileDir+name));
|
||||
}else{
|
||||
QrCodeUtil.generate(siteUrl+"/activity/dargain_detail/"+bargainId+"/"+uid+"?spread="+uid, 180, 180,
|
||||
|
@ -151,9 +151,15 @@ public class StoreCombinationController extends BaseController {
|
||||
File file = FileUtil.mkdir(new File(fileDir));
|
||||
if(userType.equals(AppFromEnum.ROUNTINE.getValue())){
|
||||
siteUrl = siteUrl+"/pink/";
|
||||
QrCodeUtil.generate(siteUrl+"?pinkId="+pinkId+"&spread="+uid, 180, 180,
|
||||
QrCodeUtil.generate(siteUrl+"?pinkId="+pinkId+"&spread="+uid+"&pageType=group&codeType="+AppFromEnum.ROUNTINE.getValue(), 180, 180,
|
||||
FileUtil.file(fileDir+name));
|
||||
}else{
|
||||
}
|
||||
else if(userType.equals(AppFromEnum.APP.getValue())){
|
||||
siteUrl = siteUrl+"/pink/";
|
||||
QrCodeUtil.generate(siteUrl+"?pinkId="+pinkId+"&spread="+uid+"&pageType=group&codeType="+AppFromEnum.ROUNTINE.getValue(), 180, 180,
|
||||
FileUtil.file(fileDir+name));
|
||||
}
|
||||
else {
|
||||
QrCodeUtil.generate(siteUrl+"/activity/group_rule/"+pinkId+"?spread="+uid, 180, 180,
|
||||
FileUtil.file(fileDir+name));
|
||||
}
|
||||
|
@ -52,10 +52,7 @@ import co.yixiang.modules.shop.web.vo.YxSystemStoreQueryVo;
|
||||
import co.yixiang.modules.user.entity.YxUser;
|
||||
import co.yixiang.modules.user.entity.YxUserBill;
|
||||
import co.yixiang.modules.user.entity.YxWechatUser;
|
||||
import co.yixiang.modules.user.service.YxUserAddressService;
|
||||
import co.yixiang.modules.user.service.YxUserBillService;
|
||||
import co.yixiang.modules.user.service.YxUserService;
|
||||
import co.yixiang.modules.user.service.YxWechatUserService;
|
||||
import co.yixiang.modules.user.service.*;
|
||||
import co.yixiang.modules.user.web.vo.YxUserAddressQueryVo;
|
||||
import co.yixiang.modules.user.web.vo.YxUserQueryVo;
|
||||
import co.yixiang.modules.user.web.vo.YxWechatUserQueryVo;
|
||||
@ -164,8 +161,8 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<YxStoreOrderMapper,
|
||||
private YxMiniPayService miniPayService;
|
||||
@Autowired
|
||||
private YxTemplateService templateService;
|
||||
|
||||
|
||||
@Autowired
|
||||
private YxUserLevelService userLevelService;
|
||||
|
||||
|
||||
/**
|
||||
@ -590,6 +587,8 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<YxStoreOrderMapper,
|
||||
//分销计算
|
||||
userService.backOrderBrokerage(order);
|
||||
|
||||
//检查是否符合会员升级条件
|
||||
userLevelService.setLevelComplete(uid);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -614,6 +613,9 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<YxStoreOrderMapper,
|
||||
|
||||
//分销计算
|
||||
userService.backOrderBrokerage(order);
|
||||
|
||||
//检查是否符合会员升级条件
|
||||
userLevelService.setLevelComplete(order.getUid());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -19,6 +19,7 @@ import co.yixiang.common.web.controller.BaseController;
|
||||
import co.yixiang.enums.AppFromEnum;
|
||||
import co.yixiang.enums.OrderInfoEnum;
|
||||
import co.yixiang.enums.PayTypeEnum;
|
||||
import co.yixiang.enums.RedisKeyEnum;
|
||||
import co.yixiang.exception.BadRequestException;
|
||||
import co.yixiang.exception.ErrorRequestException;
|
||||
import co.yixiang.express.ExpressService;
|
||||
@ -455,7 +456,7 @@ public class StoreOrderController extends BaseController {
|
||||
|
||||
//门店
|
||||
if(OrderInfoEnum.SHIPPIING_TYPE_2.getValue().equals(storeOrder.getShippingType())){
|
||||
String mapKey = RedisUtil.get("tengxun_map_key");
|
||||
String mapKey = RedisUtil.get(RedisKeyEnum.TENGXUN_MAP_KEY.getValue());
|
||||
if(StrUtil.isBlank(mapKey)) return ApiResult.fail("请配置腾讯地图key");
|
||||
String apiUrl = systemConfigService.getData("api_url");
|
||||
if(StrUtil.isEmpty(apiUrl)){
|
||||
|
@ -22,6 +22,7 @@ import co.yixiang.common.api.ApiCode;
|
||||
import co.yixiang.common.api.ApiResult;
|
||||
import co.yixiang.constant.ShopConstants;
|
||||
import co.yixiang.enums.AppFromEnum;
|
||||
import co.yixiang.enums.RedisKeyEnum;
|
||||
import co.yixiang.exception.ErrorRequestException;
|
||||
import co.yixiang.modules.notify.NotifyService;
|
||||
import co.yixiang.modules.notify.NotifyType;
|
||||
@ -309,8 +310,8 @@ public class AuthController {
|
||||
String spread = loginParam.getSpread();
|
||||
try {
|
||||
//读取redis配置
|
||||
String appId = RedisUtil.get("wxapp_appId");
|
||||
String secret = RedisUtil.get("wxapp_secret");
|
||||
String appId = RedisUtil.get(RedisKeyEnum.WXAPP_APPID.getValue());
|
||||
String secret = RedisUtil.get(RedisKeyEnum.WXAPP_SECRET.getValue());
|
||||
if (StrUtil.isBlank(appId) || StrUtil.isBlank(secret)) {
|
||||
throw new ErrorRequestException("请先配置小程序");
|
||||
}
|
||||
|
@ -0,0 +1,12 @@
|
||||
package co.yixiang.modules.shop.service;
|
||||
|
||||
import co.yixiang.modules.shop.entity.YxStoreProduct;
|
||||
import co.yixiang.modules.shop.web.dto.ProductDTO;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.IOException;
|
||||
|
||||
public interface CreatShareProductService {
|
||||
|
||||
String creatProductPic(YxStoreProduct productDTO, String qrcode, String spreadPicName, String spreadPicPath, String apiUrl) throws IOException, FontFormatException;
|
||||
}
|
@ -28,6 +28,8 @@ import java.util.List;
|
||||
*/
|
||||
public interface YxStoreProductService extends BaseService<YxStoreProduct> {
|
||||
|
||||
YxStoreProduct getProductInfo(int id);
|
||||
|
||||
|
||||
void incProductStock(int num,int productId,String unique);
|
||||
|
||||
|
@ -0,0 +1,185 @@
|
||||
package co.yixiang.modules.shop.service.impl;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import co.yixiang.modules.shop.entity.YxStoreProduct;
|
||||
import co.yixiang.modules.shop.service.CreatShareProductService;
|
||||
import co.yixiang.modules.shop.web.dto.ProductDTO;
|
||||
import co.yixiang.modules.user.entity.YxSystemAttachment;
|
||||
import co.yixiang.modules.user.service.YxSystemAttachmentService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.imageio.stream.ImageInputStream;
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.util.UUID;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
||||
public class CreatShareProductServiceImpl implements CreatShareProductService {
|
||||
|
||||
private final YxSystemAttachmentService systemAttachmentService;
|
||||
|
||||
public String creatProductPic(YxStoreProduct productDTO, String shareCode, String spreadPicName, String spreadPicPath, String apiUrl) throws IOException, FontFormatException {
|
||||
YxSystemAttachment attachmentT = systemAttachmentService.getInfo(spreadPicName);
|
||||
String spreadUrl = "";
|
||||
if(ObjectUtil.isNull(attachmentT)){
|
||||
//创建图片
|
||||
BufferedImage img = new BufferedImage(750, 1334, BufferedImage.TYPE_INT_RGB);
|
||||
//开启画图
|
||||
Graphics g = img.getGraphics();
|
||||
//背景 -- 读取互联网图片
|
||||
InputStream stream = getClass().getClassLoader().getResourceAsStream("background.png");
|
||||
ImageInputStream background = ImageIO.createImageInputStream(stream);
|
||||
BufferedImage back = ImageIO.read(background);
|
||||
|
||||
g.drawImage(back.getScaledInstance(750, 1334, Image.SCALE_DEFAULT), 0, 0, null); // 绘制缩小后的图
|
||||
//商品 banner图
|
||||
//读取互联网图片
|
||||
BufferedImage priductUrl = null;
|
||||
try {
|
||||
priductUrl = ImageIO.read(new URL(productDTO.getImage()));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
g.drawImage(priductUrl.getScaledInstance(750,590,Image.SCALE_DEFAULT),0,0,null);
|
||||
InputStream streamT = getClass().getClassLoader()
|
||||
.getResourceAsStream("Alibaba-PuHuiTi-Regular.otf");
|
||||
File newFileT = new File("Alibaba-PuHuiTi-Regular.otf");
|
||||
FileUtils.copyInputStreamToFile(streamT, newFileT);
|
||||
Font font = Font.createFont(Font.TRUETYPE_FONT, newFileT);
|
||||
//文案标题
|
||||
g.setFont(font.deriveFont(Font.BOLD,34));
|
||||
g.setColor(new Color(29,29,29));
|
||||
//绘制文字
|
||||
g.drawString(productDTO.getStoreName(), 31, 638);
|
||||
//文案
|
||||
g.setFont(font.deriveFont(Font.PLAIN,30));
|
||||
g.setColor(new Color(47,47,47));
|
||||
int fontlen = getWatermarkLength(productDTO.getStoreInfo(), g);
|
||||
//文字长度相对于图片宽度应该有多少行
|
||||
int line = fontlen / (back.getWidth() - 90);
|
||||
//高度
|
||||
int y = back.getHeight() - (line + 1) * 30 + 200;
|
||||
//文字叠加,自动换行叠加
|
||||
int tempX = 32;
|
||||
int tempY = y;
|
||||
//单字符长度
|
||||
int tempCharLen = 0;
|
||||
//单行字符总长度临时计算
|
||||
int tempLineLen = 0;
|
||||
StringBuffer sb =new StringBuffer();
|
||||
for(int i=0; i < productDTO.getStoreInfo().length(); i++) {
|
||||
char tempChar = productDTO.getStoreInfo().charAt(i);
|
||||
tempCharLen = getCharLen(tempChar, g);
|
||||
tempLineLen += tempCharLen;
|
||||
if(tempLineLen >= (back.getWidth()-90)) {
|
||||
//长度已经满一行,进行文字叠加
|
||||
g.drawString(sb.toString(), tempX, tempY + 50);
|
||||
//清空内容,重新追加
|
||||
sb.delete(0, sb.length());
|
||||
//每行文字间距50
|
||||
tempY += 50;
|
||||
tempLineLen =0;
|
||||
}
|
||||
//追加字符
|
||||
sb.append(tempChar);
|
||||
}
|
||||
//最后叠加余下的文字
|
||||
g.drawString(sb.toString(), tempX, tempY + 50);
|
||||
|
||||
//价格背景
|
||||
//读取互联网图片
|
||||
BufferedImage bground = null;//
|
||||
InputStream redStream = getClass().getClassLoader().getResourceAsStream("red.jpg");
|
||||
try {
|
||||
ImageInputStream red = ImageIO.createImageInputStream(redStream);
|
||||
bground = ImageIO.read(red);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
// 绘制缩小后的图
|
||||
g.drawImage(bground.getScaledInstance(160, 40, Image.SCALE_DEFAULT), 30, 1053, null);
|
||||
|
||||
//限时促销价
|
||||
g.setFont(font.deriveFont(Font.PLAIN,24));
|
||||
g.setColor(new Color(255,255,255));
|
||||
g.drawString("限时促销价", 50, 1080);
|
||||
|
||||
//价格
|
||||
g.setFont(font.deriveFont(Font.PLAIN,50));
|
||||
g.setColor(new Color(249,64,64));
|
||||
g.drawString("¥" +productDTO.getPrice(), 29, 1162);
|
||||
|
||||
//原价
|
||||
g.setFont(font.deriveFont(Font.PLAIN,36));
|
||||
g.setColor(new Color(171,171,171));
|
||||
String price = "¥" + productDTO.getOtPrice();
|
||||
g.drawString(price, 260, 1160);
|
||||
g.drawLine(250,1148,260+150,1148);
|
||||
|
||||
//商品名称
|
||||
g.setFont(font.deriveFont(Font.PLAIN,32));
|
||||
g.setColor(new Color(29,29,29));
|
||||
g.drawString(productDTO.getStoreName(), 30, 1229);
|
||||
|
||||
//生成二维码返回链接
|
||||
String url = shareCode;
|
||||
//读取互联网图片
|
||||
BufferedImage qrCode = null;
|
||||
try {
|
||||
qrCode = ImageIO.read(new URL(url));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
// 绘制缩小后的图
|
||||
g.drawImage(qrCode.getScaledInstance(174, 174, Image.SCALE_DEFAULT), 536, 1057, null);
|
||||
|
||||
//二维码字体
|
||||
g.setFont(font.deriveFont(Font.PLAIN,25));
|
||||
g.setColor(new Color(171,171,171));
|
||||
//绘制文字
|
||||
g.drawString("扫描或长按小程序码", 515, 1260);
|
||||
|
||||
g.dispose();
|
||||
//先将画好的海报写到本地
|
||||
File file = new File(spreadPicPath);
|
||||
try {
|
||||
ImageIO.write(img, "jpg",file);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
systemAttachmentService.attachmentAdd(spreadPicName,
|
||||
String.valueOf(FileUtil.size(new File(spreadPicPath))),
|
||||
spreadPicPath,"qrcode/"+spreadPicName);
|
||||
spreadUrl = apiUrl + "/api/file/qrcode/"+spreadPicName;
|
||||
//保存到本地 生成文件名字
|
||||
}else {
|
||||
spreadUrl = apiUrl + "/api/file/" + attachmentT.getSattDir();
|
||||
}
|
||||
|
||||
return spreadUrl;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取水印文字总长度
|
||||
*@paramwaterMarkContent水印的文字
|
||||
*@paramg
|
||||
*@return水印文字总长度
|
||||
*/
|
||||
public static int getWatermarkLength(String waterMarkContent, Graphics g) {
|
||||
return g.getFontMetrics(g.getFont()).charsWidth(waterMarkContent.toCharArray(),0, waterMarkContent.length());
|
||||
}
|
||||
public static int getCharLen(char c, Graphics g) {
|
||||
return g.getFontMetrics(g.getFont()).charWidth(c);
|
||||
}
|
||||
}
|
@ -14,6 +14,7 @@ import co.yixiang.common.service.impl.BaseServiceImpl;
|
||||
import co.yixiang.common.web.vo.Paging;
|
||||
import co.yixiang.enums.CommonEnum;
|
||||
import co.yixiang.enums.ProductEnum;
|
||||
import co.yixiang.enums.RedisKeyEnum;
|
||||
import co.yixiang.exception.ErrorRequestException;
|
||||
import co.yixiang.modules.shop.entity.YxStoreProduct;
|
||||
import co.yixiang.modules.shop.entity.YxStoreProductAttrValue;
|
||||
@ -127,6 +128,18 @@ public class YxStoreProductServiceImpl extends BaseServiceImpl<YxStoreProductMap
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public YxStoreProduct getProductInfo(int id) {
|
||||
QueryWrapper<YxStoreProduct> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("is_del",0).eq("is_show",1).eq("id",id);
|
||||
YxStoreProduct storeProduct = yxStoreProductMapper.selectOne(wrapper);
|
||||
if(ObjectUtil.isNull(storeProduct)){
|
||||
throw new ErrorRequestException("商品不存在或已下架");
|
||||
}
|
||||
|
||||
return storeProduct;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProductDTO goodsDetail(int id, int type,int uid,String latitude,String longitude) {
|
||||
QueryWrapper<YxStoreProduct> wrapper = new QueryWrapper<>();
|
||||
@ -160,7 +173,7 @@ public class YxStoreProductServiceImpl extends BaseServiceImpl<YxStoreProductMap
|
||||
|
||||
//门店
|
||||
productDTO.setSystemStore(systemStoreService.getStoreInfo(latitude,longitude));
|
||||
productDTO.setMapKey(RedisUtil.get("tengxun_map_key"));
|
||||
productDTO.setMapKey(RedisUtil.get(RedisKeyEnum.TENGXUN_MAP_KEY.getValue()));
|
||||
|
||||
return productDTO;
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ import cn.hutool.core.util.StrUtil;
|
||||
import co.yixiang.annotation.AnonymousAccess;
|
||||
import co.yixiang.common.api.ApiResult;
|
||||
import co.yixiang.constant.ShopConstants;
|
||||
import co.yixiang.enums.RedisKeyEnum;
|
||||
import co.yixiang.modules.shop.service.YxStoreProductService;
|
||||
import co.yixiang.modules.shop.service.YxSystemGroupDataService;
|
||||
import co.yixiang.modules.shop.service.YxSystemStoreService;
|
||||
@ -83,7 +84,7 @@ public class IndexController {
|
||||
//滚动
|
||||
map.put("roll",systemGroupDataService.getDatas(ShopConstants.YSHOP_HOME_ROLL_NEWS));
|
||||
|
||||
map.put("mapKey",RedisUtil.get("tengxun_map_key"));
|
||||
map.put("mapKey",RedisUtil.get(RedisKeyEnum.TENGXUN_MAP_KEY.getValue()));
|
||||
|
||||
return ApiResult.ok(map);
|
||||
}
|
||||
|
@ -19,10 +19,8 @@ import co.yixiang.common.api.ApiResult;
|
||||
import co.yixiang.common.web.controller.BaseController;
|
||||
import co.yixiang.enums.AppFromEnum;
|
||||
import co.yixiang.enums.ProductEnum;
|
||||
import co.yixiang.modules.shop.service.YxStoreProductRelationService;
|
||||
import co.yixiang.modules.shop.service.YxStoreProductReplyService;
|
||||
import co.yixiang.modules.shop.service.YxStoreProductService;
|
||||
import co.yixiang.modules.shop.service.YxSystemConfigService;
|
||||
import co.yixiang.modules.shop.entity.YxStoreProduct;
|
||||
import co.yixiang.modules.shop.service.*;
|
||||
import co.yixiang.modules.shop.web.dto.ProductDTO;
|
||||
import co.yixiang.modules.shop.web.param.YxStoreProductQueryParam;
|
||||
import co.yixiang.modules.shop.web.param.YxStoreProductRelationQueryParam;
|
||||
@ -42,7 +40,9 @@ import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -67,7 +67,7 @@ public class StoreProductController extends BaseController {
|
||||
private final YxSystemConfigService systemConfigService;
|
||||
private final YxSystemAttachmentService systemAttachmentService;
|
||||
private final YxUserService yxUserService;
|
||||
|
||||
private final CreatShareProductService creatShareProductService;
|
||||
@Value("${file.path}")
|
||||
private String path;
|
||||
|
||||
@ -115,19 +115,14 @@ public class StoreProductController extends BaseController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 普通商品详情
|
||||
* 商品详情海报
|
||||
*/
|
||||
@Log(value = "查看商品详情",type = 1)
|
||||
@GetMapping("/product/detail/{id}")
|
||||
@ApiOperation(value = "普通商品详情",notes = "普通商品详情")
|
||||
public ApiResult<ProductDTO> detail(@PathVariable Integer id,
|
||||
@RequestParam(value = "",required=false) String latitude,
|
||||
@RequestParam(value = "",required=false) String longitude,
|
||||
@RequestParam(value = "",required=false) String from){
|
||||
@GetMapping("/product/poster/{id}")
|
||||
@ApiOperation(value = "商品详情海报",notes = "商品详情海报")
|
||||
public ApiResult<String> prodoctPoster(@PathVariable Integer id) throws IOException, FontFormatException {
|
||||
int uid = SecurityUtils.getUserId().intValue();
|
||||
|
||||
ProductDTO productDTO = storeProductService.goodsDetail(id,0,uid,latitude,longitude);
|
||||
|
||||
YxStoreProduct storeProduct = storeProductService.getProductInfo(id);
|
||||
// 海报
|
||||
String siteUrl = systemConfigService.getData("site_url");
|
||||
if(StrUtil.isEmpty(siteUrl)){
|
||||
@ -137,66 +132,115 @@ public class StoreProductController extends BaseController {
|
||||
if(StrUtil.isEmpty(apiUrl)){
|
||||
return ApiResult.fail("未配置api地址");
|
||||
}
|
||||
|
||||
YxUserQueryVo userInfo = yxUserService.getYxUserById(uid);
|
||||
String userType = userInfo.getUserType();
|
||||
if(!userType.equals(AppFromEnum.ROUNTINE.getValue())) {
|
||||
userType = AppFromEnum.H5.getValue();
|
||||
}
|
||||
//app类型
|
||||
if(StrUtil.isNotBlank(from) && AppFromEnum.APP.getValue().equals(from)){
|
||||
String name = id+"_"+uid + "_"+from+"_product_detail_wap.jpg";
|
||||
YxSystemAttachment attachment = systemAttachmentService.getInfo(name);
|
||||
String inviteCode = OrderUtil.createShareCode();
|
||||
if(ObjectUtil.isNull(attachment)){
|
||||
systemAttachmentService.newAttachmentAdd(name, "", "","",uid,inviteCode);
|
||||
}else{
|
||||
inviteCode = attachment.getInviteCode();
|
||||
}
|
||||
|
||||
productDTO.getStoreInfo().setCodeBase(inviteCode);
|
||||
}else {
|
||||
String name = id+"_"+uid + "_"+userType+"_product_detail_wap.jpg";
|
||||
YxSystemAttachment attachment = systemAttachmentService.getInfo(name);
|
||||
String fileDir = path+"qrcode"+ File.separator;
|
||||
String qrcodeUrl = "";
|
||||
String routineQrcodeUrl = "";
|
||||
if(ObjectUtil.isNull(attachment)){
|
||||
//生成二维码
|
||||
File file = FileUtil.mkdir(new File(fileDir));
|
||||
if(userType.equals(AppFromEnum.ROUNTINE.getValue())){
|
||||
//下载图片
|
||||
siteUrl = siteUrl+"/product/";
|
||||
QrCodeUtil.generate(siteUrl+"?productId="+id+"&spread="+uid, 180, 180,
|
||||
FileUtil.file(fileDir+name));
|
||||
}else{
|
||||
QrCodeUtil.generate(siteUrl+"/detail/"+id+"?spread="+uid, 180, 180,
|
||||
FileUtil.file(fileDir+name));
|
||||
}
|
||||
|
||||
systemAttachmentService.attachmentAdd(name,String.valueOf(FileUtil.size(file)),
|
||||
fileDir+name,"qrcode/"+name);
|
||||
|
||||
qrcodeUrl = fileDir+name;
|
||||
routineQrcodeUrl = apiUrl + "/api/file/qrcode/"+name;
|
||||
}else{
|
||||
qrcodeUrl = attachment.getAttDir();
|
||||
routineQrcodeUrl = apiUrl + "/api/file/" + attachment.getSattDir();
|
||||
}
|
||||
|
||||
String name = id+"_"+uid + "_"+userType+"_product_detail_wap.jpg";
|
||||
YxSystemAttachment attachment = systemAttachmentService.getInfo(name);
|
||||
String fileDir = path+"qrcode"+ File.separator;
|
||||
String qrcodeUrl = "";
|
||||
if(ObjectUtil.isNull(attachment)){
|
||||
File file = FileUtil.mkdir(new File(fileDir));
|
||||
//如果类型是小程序
|
||||
if(userType.equals(AppFromEnum.ROUNTINE.getValue())){
|
||||
productDTO.getStoreInfo().setCodeBase(routineQrcodeUrl);
|
||||
}else{
|
||||
try {
|
||||
String base64CodeImg = co.yixiang.utils.FileUtil.fileToBase64(new File(qrcodeUrl));
|
||||
productDTO.getStoreInfo().setCodeBase("data:image/jpeg;base64," + base64CodeImg);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
//h5地址
|
||||
siteUrl = siteUrl+"/product/";
|
||||
//生成二维码
|
||||
QrCodeUtil.generate(siteUrl+"?productId="+id+"&spread="+uid+"&pageType=good&codeType="+AppFromEnum.ROUNTINE.getValue(), 180, 180,
|
||||
FileUtil.file(fileDir+name));
|
||||
}
|
||||
else if(userType.equals(AppFromEnum.APP.getValue())){
|
||||
//h5地址
|
||||
siteUrl = siteUrl+"/product/";
|
||||
//生成二维码
|
||||
QrCodeUtil.generate(siteUrl+"?productId="+id+"&spread="+uid+"&pageType=good&codeType="+AppFromEnum.APP.getValue(), 180, 180,
|
||||
FileUtil.file(fileDir+name));
|
||||
}else{//如果类型是h5
|
||||
//生成二维码
|
||||
QrCodeUtil.generate(siteUrl+"detail/"+id+"?spread="+uid, 180, 180,
|
||||
FileUtil.file(fileDir+name));
|
||||
}
|
||||
systemAttachmentService.attachmentAdd(name,String.valueOf(FileUtil.size(file)),
|
||||
fileDir+name,"qrcode/"+name);
|
||||
|
||||
qrcodeUrl = apiUrl + "/api/file/qrcode/"+name;
|
||||
}else{
|
||||
qrcodeUrl = apiUrl + "/api/file/" + attachment.getSattDir();
|
||||
}
|
||||
String spreadPicName = id+"_"+uid + "_"+userType+"_product_user_spread.jpg";
|
||||
String spreadPicPath = fileDir+spreadPicName;
|
||||
String rr = creatShareProductService.creatProductPic(storeProduct,qrcodeUrl,
|
||||
spreadPicName,spreadPicPath,apiUrl);
|
||||
//productDTO.getStoreInfo().setCodeBase(rr);
|
||||
return ApiResult.ok(rr);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 普通商品详情
|
||||
*/
|
||||
@Log(value = "查看商品详情",type = 1)
|
||||
@GetMapping("/product/detail/{id}")
|
||||
@ApiOperation(value = "普通商品详情",notes = "普通商品详情")
|
||||
public ApiResult<ProductDTO> detail(@PathVariable Integer id,
|
||||
@RequestParam(value = "",required=false) String latitude,
|
||||
@RequestParam(value = "",required=false) String longitude,
|
||||
@RequestParam(value = "",required=false) String from) {
|
||||
int uid = SecurityUtils.getUserId().intValue();
|
||||
ProductDTO productDTO = storeProductService.goodsDetail(id,0,uid,latitude,longitude);
|
||||
// 海报
|
||||
// String siteUrl = systemConfigService.getData("site_url");
|
||||
// if(StrUtil.isEmpty(siteUrl)){
|
||||
// return ApiResult.fail("未配置h5地址");
|
||||
// }
|
||||
// String apiUrl = systemConfigService.getData("api_url");
|
||||
// if(StrUtil.isEmpty(apiUrl)){
|
||||
// return ApiResult.fail("未配置api地址");
|
||||
// }
|
||||
// YxUserQueryVo userInfo = yxUserService.getYxUserById(uid);
|
||||
// String userType = userInfo.getUserType();
|
||||
// if(!userType.equals(AppFromEnum.ROUNTINE.getValue())) {
|
||||
// userType = AppFromEnum.H5.getValue();
|
||||
// }
|
||||
// String name = id+"_"+uid + "_"+userType+"_product_detail_wap.jpg";
|
||||
// YxSystemAttachment attachment = systemAttachmentService.getInfo(name);
|
||||
// String fileDir = path+"qrcode"+ File.separator;
|
||||
// String qrcodeUrl = "";
|
||||
// if(ObjectUtil.isNull(attachment)){
|
||||
// File file = FileUtil.mkdir(new File(fileDir));
|
||||
// //如果类型是小程序
|
||||
// if(userType.equals(AppFromEnum.ROUNTINE.getValue())){
|
||||
// //h5地址
|
||||
// siteUrl = siteUrl+"/product/";
|
||||
// //生成二维码
|
||||
// QrCodeUtil.generate(siteUrl+"?productId="+id+"&spread="+uid+"&pageType=good&codeType="+AppFromEnum.ROUNTINE.getValue(), 180, 180,
|
||||
// FileUtil.file(fileDir+name));
|
||||
// }
|
||||
// else if(userType.equals(AppFromEnum.APP.getValue())){
|
||||
// //h5地址
|
||||
// siteUrl = siteUrl+"/product/";
|
||||
// //生成二维码
|
||||
// QrCodeUtil.generate(siteUrl+"?productId="+id+"&spread="+uid+"&pageType=good&codeType="+AppFromEnum.APP.getValue(), 180, 180,
|
||||
// FileUtil.file(fileDir+name));
|
||||
// }else{//如果类型是h5
|
||||
// //生成二维码
|
||||
// QrCodeUtil.generate(siteUrl+"detail/"+id+"?spread="+uid, 180, 180,
|
||||
// FileUtil.file(fileDir+name));
|
||||
// }
|
||||
// systemAttachmentService.attachmentAdd(name,String.valueOf(FileUtil.size(file)),
|
||||
// fileDir+name,"qrcode/"+name);
|
||||
//
|
||||
// // qrcodeUrl = apiUrl + "/api/file/qrcode/"+name;
|
||||
// }else{
|
||||
// // qrcodeUrl = apiUrl + "/api/file/" + attachment.getSattDir();
|
||||
// }
|
||||
// //String spreadPicName = id+"_"+uid + "_"+userType+"_product_user_spread.jpg";
|
||||
// // String spreadPicPath = fileDir+spreadPicName;
|
||||
//// String rr = creatShareProductService.creatProductPic(productDTO,qrcodeUrl,spreadPicName,spreadPicPath,apiUrl);
|
||||
//// productDTO.getStoreInfo().setCodeBase(rr);
|
||||
return ApiResult.ok(productDTO);
|
||||
}
|
||||
|
||||
@ -246,16 +290,5 @@ public class StoreProductController extends BaseController {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ public interface YxUserLevelService extends BaseService<YxUserLevel> {
|
||||
|
||||
UserLevelInfoDTO getUserLevelInfo(int id);
|
||||
|
||||
int getUserLevel(int uid,int grade);
|
||||
YxUserLevel getUserLevel(int uid,int grade);
|
||||
|
||||
/**
|
||||
* 根据ID获取查询对象
|
||||
|
@ -133,7 +133,7 @@ public class YxSystemUserLevelServiceImpl extends BaseServiceImpl<YxSystemUserLe
|
||||
*/
|
||||
@Override
|
||||
public UserLevelDTO getLevelInfo(int uid,boolean isTask) {
|
||||
int id = userLevelService.getUserLevel(uid,0); //用户当前等级id
|
||||
int id = userLevelService.getUserLevel(uid,0).getId(); //用户当前等级id
|
||||
UserLevelInfoDTO userLevelInfoDTO = null;
|
||||
if(id > 0) userLevelInfoDTO = userLevelService.getUserLevelInfo(id);
|
||||
int levelId = 0;
|
||||
|
@ -119,7 +119,7 @@ public class YxUserLevelServiceImpl extends BaseServiceImpl<YxUserLevelMapper, Y
|
||||
YxUserQueryVo userQueryVo = userService.getYxUserById(uid);
|
||||
if(ObjectUtil.isNull(userQueryVo)) return false;
|
||||
|
||||
int levelId = getUserLevel(uid,9);
|
||||
int levelId = getUserLevel(uid,9).getLevelId();
|
||||
|
||||
int nextLevelId = systemUserLevelService.getNextLevelId(levelId);
|
||||
if(nextLevelId == 0) return false;
|
||||
@ -152,14 +152,14 @@ public class YxUserLevelServiceImpl extends BaseServiceImpl<YxUserLevelMapper, Y
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public int getUserLevel(int uid, int grade) {
|
||||
public YxUserLevel getUserLevel(int uid, int grade) {
|
||||
QueryWrapper<YxUserLevel> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("is_del",0).eq("status",1)
|
||||
.eq("uid",uid).orderByDesc("grade");
|
||||
if(grade > 0) wrapper.lt("grade",grade);
|
||||
YxUserLevel userLevel = yxUserLevelMapper.selectOne(wrapper);
|
||||
if(ObjectUtil.isNull(userLevel)) return 0;
|
||||
if(userLevel.getIsForever() == 1) return userLevel.getId();
|
||||
YxUserLevel userLevel = this.getOne(wrapper,false);
|
||||
if(ObjectUtil.isNull(userLevel)) return new YxUserLevel();
|
||||
if(userLevel.getIsForever() == 1) return userLevel;
|
||||
int nowTime = OrderUtil.getSecondTimestampTwo();
|
||||
if(nowTime > userLevel.getValidTime()){
|
||||
if(userLevel.getStatus() == 1){
|
||||
@ -169,7 +169,7 @@ public class YxUserLevelServiceImpl extends BaseServiceImpl<YxUserLevelMapper, Y
|
||||
|
||||
return getUserLevel(uid,userLevel.getGrade());
|
||||
}
|
||||
return userLevel.getId();
|
||||
return userLevel;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -22,6 +22,7 @@ import co.yixiang.modules.user.entity.YxUserSign;
|
||||
import co.yixiang.modules.user.mapper.YxUserBillMapper;
|
||||
import co.yixiang.modules.user.mapper.YxUserSignMapper;
|
||||
import co.yixiang.modules.user.service.YxUserBillService;
|
||||
import co.yixiang.modules.user.service.YxUserLevelService;
|
||||
import co.yixiang.modules.user.service.YxUserService;
|
||||
import co.yixiang.modules.user.service.YxUserSignService;
|
||||
import co.yixiang.modules.user.web.dto.SignDTO;
|
||||
@ -65,8 +66,7 @@ public class YxUserSignServiceImpl extends BaseServiceImpl<YxUserSignMapper, YxU
|
||||
private YxSystemGroupDataService systemGroupDataService;
|
||||
private YxUserService yxUserService;
|
||||
private YxUserBillService billService;
|
||||
|
||||
|
||||
private YxUserLevelService userLevelService;
|
||||
|
||||
/**
|
||||
* 用户签到
|
||||
@ -132,6 +132,8 @@ public class YxUserSignServiceImpl extends BaseServiceImpl<YxUserSignMapper, YxU
|
||||
userBill.setAddTime(OrderUtil.getSecondTimestampTwo());
|
||||
billService.save(userBill);
|
||||
|
||||
//检查是否符合会员升级条件
|
||||
userLevelService.setLevelComplete(uid);
|
||||
return signNumber;
|
||||
}
|
||||
|
||||
|
@ -17,6 +17,7 @@ import cn.hutool.core.util.RandomUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import co.yixiang.annotation.AnonymousAccess;
|
||||
import co.yixiang.common.api.ApiResult;
|
||||
import co.yixiang.enums.RedisKeyEnum;
|
||||
import co.yixiang.exception.ErrorRequestException;
|
||||
import co.yixiang.modules.notify.NotifyType;
|
||||
import co.yixiang.modules.notify.SmsResult;
|
||||
@ -107,8 +108,8 @@ public class WxMaUserController {
|
||||
}
|
||||
|
||||
//读取redis配置
|
||||
String appId = RedisUtil.get("wxapp_appId");
|
||||
String secret = RedisUtil.get("wxapp_secret");
|
||||
String appId = RedisUtil.get(RedisKeyEnum.WXAPP_APPID.getValue());
|
||||
String secret = RedisUtil.get(RedisKeyEnum.WXAPP_SECRET.getValue());
|
||||
if (StrUtil.isBlank(appId) || StrUtil.isBlank(secret)) {
|
||||
throw new ErrorRequestException("请先配置小程序");
|
||||
}
|
||||
|
BIN
yshop-api/src/main/resources/background.png
Normal file
BIN
yshop-api/src/main/resources/background.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.2 KiB |
@ -47,7 +47,7 @@ spring:
|
||||
database: 0
|
||||
host: 127.0.0.1
|
||||
port: 6379
|
||||
password:
|
||||
password: root
|
||||
#连接超时时间
|
||||
timeout: 5000
|
||||
|
||||
@ -75,8 +75,8 @@ swagger:
|
||||
|
||||
# 文件存储路径
|
||||
file:
|
||||
path: E:\yshop\file\
|
||||
avatar: E:\yshop\avatar\
|
||||
path: D:\yshop\file\
|
||||
avatar: D:\yshop\avatar\
|
||||
# 文件大小 /M
|
||||
maxSize: 100
|
||||
avatarMaxSize: 5
|
||||
|
BIN
yshop-api/src/main/resources/red.jpg
Normal file
BIN
yshop-api/src/main/resources/red.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 419 B |
Reference in New Issue
Block a user