yshop1.9.6,H5(公众号)端新增商品海报功能,管理后台配置新增排序与可隐藏选项,修复小程序bug等

This commit is contained in:
hupeng
2020-02-11 14:12:21 +08:00
parent 7e94789793
commit b954dcf6f2
8 changed files with 105 additions and 14 deletions

View File

@ -112,7 +112,7 @@ public class StoreCombinationController extends BaseController {
return ApiResult.fail("未配置h5地址");
}
String apiUrl = systemConfigService.getData("api_url");
if(StrUtil.isEmpty(siteUrl)){
if(StrUtil.isEmpty(apiUrl)){
return ApiResult.fail("未配置api地址");
}
YxStorePink storePink = storePinkService.getPinkUserOne(pinkId);
@ -130,8 +130,15 @@ public class StoreCombinationController extends BaseController {
//生成二维码
//String fileDir = path+"qrcode"+File.separator;
File file = FileUtil.mkdir(new File(fileDir));
QrCodeUtil.generate(siteUrl+"/activity/group_rule/"+pinkId+"?spread="+uid, 180, 180,
FileUtil.file(fileDir+name));
if(userInfo.getUserType().equals("routine")){
siteUrl = siteUrl+"/pink/";
QrCodeUtil.generate(siteUrl+"?pinkId="+pinkId+"&spread="+uid, 180, 180,
FileUtil.file(fileDir+name));
}else{
QrCodeUtil.generate(siteUrl+"/activity/group_rule/"+pinkId+"?spread="+uid, 180, 180,
FileUtil.file(fileDir+name));
}
systemAttachmentService.attachmentAdd(name,String.valueOf(FileUtil.size(file)),
fileDir+name,"qrcode/"+name);

View File

@ -50,7 +50,7 @@ public class YxSystemGroupDataServiceImpl extends BaseServiceImpl<YxSystemGroupD
List<Map<String,Object>> list = new ArrayList<>();
wrapper.eq("group_name",name).eq("status",1);
wrapper.eq("group_name",name).eq("status",1).orderByDesc("sort");
List<YxSystemGroupData> systemGroupDatas = baseMapper.selectList(wrapper);
for (YxSystemGroupData yxSystemGroupData : systemGroupDatas) {

View File

@ -83,16 +83,15 @@ public class IndexController {
for (Map<String,Object> map : list) {
stringList.add(map.get("title").toString());
}
//System.out.println(stringList);
return ApiResult.ok(stringList);
}
@AnonymousAccess
@PostMapping("/image_base64")
@ApiOperation(value = "获取图片base64",notes = "获取图片base64")
@Deprecated
public ApiResult<List<String>> imageBase64(){
//Map<String,Object> map = new LinkedHashMap<>();
return ApiResult.ok(null);
}

View File

@ -1,5 +1,10 @@
package co.yixiang.modules.shop.web.controller;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.qrcode.QrCodeUtil;
import cn.hutool.http.HttpUtil;
import co.yixiang.annotation.AnonymousAccess;
import co.yixiang.aop.log.Log;
import co.yixiang.common.api.ApiResult;
@ -7,19 +12,26 @@ import co.yixiang.common.web.controller.BaseController;
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.web.dto.ProductDTO;
import co.yixiang.modules.shop.web.param.YxStoreProductQueryParam;
import co.yixiang.modules.shop.web.param.YxStoreProductRelationQueryParam;
import co.yixiang.modules.shop.web.vo.YxStoreProductQueryVo;
import co.yixiang.modules.user.entity.YxSystemAttachment;
import co.yixiang.modules.user.service.YxSystemAttachmentService;
import co.yixiang.modules.user.service.YxUserService;
import co.yixiang.modules.user.web.vo.YxUserQueryVo;
import co.yixiang.utils.SecurityUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.io.File;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@ -41,6 +53,12 @@ public class StoreProductController extends BaseController {
private final YxStoreProductService storeProductService;
private final YxStoreProductRelationService productRelationService;
private final YxStoreProductReplyService replyService;
private final YxSystemConfigService systemConfigService;
private final YxSystemAttachmentService systemAttachmentService;
private final YxUserService yxUserService;
@Value("${file.path}")
private String path;
/**
@ -97,7 +115,53 @@ public class StoreProductController extends BaseController {
@ApiOperation(value = "普通商品详情",notes = "普通商品详情")
public ApiResult<ProductDTO> detail(@PathVariable Integer id){
int uid = SecurityUtils.getUserId().intValue();
return ApiResult.ok(storeProductService.goodsDetail(id,0,uid));
ProductDTO productDTO = storeProductService.goodsDetail(id,0,uid);
// 海报
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 name = id+"_"+uid + "_"+userInfo.getIsPromoter()+"_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(userInfo.getUserType().equals("routine")){
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;
}else{
qrcodeUrl = attachment.getAttDir();
}
try {
String base64CodeImg = co.yixiang.utils.FileUtil.fileToBase64(new File(qrcodeUrl));
productDTO.getStoreInfo().setCodeBase("data:image/jpeg;base64," + base64CodeImg);
} catch (Exception e) {
e.printStackTrace();
}
return ApiResult.ok(productDTO);
}
/**

View File

@ -36,6 +36,8 @@ public class YxStoreProductQueryVo implements Serializable {
private String image_base;
private String codeBase;
public String getImage_base() {
return image;
}

View File

@ -13,7 +13,9 @@ import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
@ -35,9 +37,13 @@ public class YxSystemGroupDataController {
@ApiOperation(value = "查询数据配置")
@GetMapping(value = "/yxSystemGroupData")
@PreAuthorize("@el.check('admin','YXSYSTEMGROUPDATA_ALL','YXSYSTEMGROUPDATA_SELECT')")
public ResponseEntity getYxSystemGroupDatas(YxSystemGroupDataQueryCriteria criteria, Pageable pageable){
return new ResponseEntity(yxSystemGroupDataService.queryAll(criteria,pageable),HttpStatus.OK);
public ResponseEntity getYxSystemGroupDatas(YxSystemGroupDataQueryCriteria criteria,
Pageable pageable){
Sort sort = new Sort(Sort.Direction.DESC, "sort");
Pageable pageableT = new PageRequest(pageable.getPageNumber(),
pageable.getPageSize(),
sort);
return new ResponseEntity(yxSystemGroupDataService.queryAll(criteria,pageableT),HttpStatus.OK);
}
@Log("新增数据配置")
@ -77,7 +83,8 @@ public class YxSystemGroupDataController {
yxSystemGroupData.setGroupName(jsonObject.get("groupName").toString());
jsonObject.remove("groupName");
yxSystemGroupData.setValue(jsonObject.toJSONString());
yxSystemGroupData.setStatus(1);
yxSystemGroupData.setStatus(jsonObject.getInteger("status"));
yxSystemGroupData.setSort(jsonObject.getInteger("sort"));
yxSystemGroupData.setAddTime(OrderUtil.getSecondTimestampTwo());
return new ResponseEntity(yxSystemGroupDataService.create(yxSystemGroupData),HttpStatus.CREATED);
@ -113,6 +120,19 @@ public class YxSystemGroupDataController {
yxSystemGroupData.setGroupName(jsonObject.get("groupName").toString());
jsonObject.remove("groupName");
yxSystemGroupData.setValue(jsonObject.toJSONString());
if(jsonObject.getInteger("status") == null){
yxSystemGroupData.setStatus(1);
}else{
yxSystemGroupData.setStatus(jsonObject.getInteger("status"));
}
if(jsonObject.getInteger("sort") == null){
yxSystemGroupData.setSort(0);
}else{
yxSystemGroupData.setSort(jsonObject.getInteger("sort"));
}
yxSystemGroupData.setId(Integer.valueOf(jsonObject.get("id").toString()));
yxSystemGroupDataService.update(yxSystemGroupData);
return new ResponseEntity(HttpStatus.NO_CONTENT);

View File

@ -50,7 +50,6 @@ public class YxSystemGroupDataServiceImpl implements YxSystemGroupDataService {
map.put("content",systemGroupDataDTOS);
map.put("totalElements",page.getTotalElements());
return map;
//return PageUtil.toPage(page.map(yxSystemGroupDataMapper::toDto));
}
@Override

View File

@ -33,7 +33,7 @@ public class YxSystemConfigController {
private YxSystemConfigService yxSystemConfigService;
@Log("查询")
@ApiOperation(value = "查询YxSystemConfig")
@ApiOperation(value = "查询")
@GetMapping(value = "/yxSystemConfig")
@PreAuthorize("@el.check('admin','YXSYSTEMCONFIG_ALL','YXSYSTEMCONFIG_SELECT')")
public ResponseEntity getYxSystemConfigs(YxSystemConfigQueryCriteria criteria, Pageable pageable){
@ -41,7 +41,7 @@ public class YxSystemConfigController {
}
@Log("新增或修改")
@ApiOperation(value = "新增YxSystemConfig")
@ApiOperation(value = "新增或修改")
@PostMapping(value = "/yxSystemConfig")
@PreAuthorize("@el.check('admin','YXSYSTEMCONFIG_ALL','YXSYSTEMCONFIG_CREATE')")
public ResponseEntity create(@RequestBody String jsonStr){