bug--直播商品加入枚举

This commit is contained in:
taozi
2020-08-12 09:28:12 +08:00
parent a4f2800ee7
commit f4e9cc2934
8 changed files with 94 additions and 18 deletions

View File

@ -0,0 +1,27 @@
/**
* Copyright (C) 2018-2020
* All rights reserved, Designed By www.yixiang.co
*/
package co.yixiang.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* @author hupeng
* 直播商品相关枚举
*/
@Getter
@AllArgsConstructor
public enum LiveGoodsEnum {
IS_Audit_0(0,"未审核"),
IS_Audit_1(1,"审核中"),
IS_Audit_2(2,"审核通过"),
IS_Audit_3(3,"审核失败");
private Integer value;
private String desc;
}

View File

@ -70,7 +70,7 @@ public class YxWechatLiveGoodsController {
@ApiOperation("修改yxWechatLiveGoods")
@PreAuthorize("@el.check('admin','yxWechatLiveGoods:edit')")
public ResponseEntity<Object> update(@Validated @RequestBody YxWechatLiveGoods resources){
yxWechatLiveGoodsService.updategoods(resources);
yxWechatLiveGoodsService.updateGoods(resources);
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
@ -80,7 +80,7 @@ public class YxWechatLiveGoodsController {
@DeleteMapping
public ResponseEntity<Object> deleteAll(@RequestBody Long[] ids) {
Arrays.asList(ids).forEach(id->{
yxWechatLiveGoodsService.removegoods(id);
yxWechatLiveGoodsService.removeGoods(id);
});
return new ResponseEntity<>(HttpStatus.OK);
}

View File

@ -46,11 +46,29 @@ public interface YxWechatLiveGoodsService extends BaseService<YxWechatLiveGoods
*/
void download(List<YxWechatLiveGoodsDto> all, HttpServletResponse response) throws IOException;
/**
* 保存直播商品信息
* @param resources
* @return
*/
boolean saveGoods(YxWechatLiveGoods resources);
/**
* 同步商品更新审核状态
* @param goodsIds
* @return
*/
boolean synchroWxOlLive(List<Integer> goodsIds);
void removegoods(Long id);
/**
* 根据id删除直播商品信息
* @param id
*/
void removeGoods(Long id);
void updategoods(YxWechatLiveGoods resources);
/**
* 更新直播商品信息
* @param resources
*/
void updateGoods(YxWechatLiveGoods resources);
}

View File

@ -26,9 +26,13 @@ public interface YxWechatLiveService extends BaseService<YxWechatLive>{
/**
* 同步直播间
* @return
*/
boolean synchroWxOlLive();
/**
/**
* 查询数据分页
* @param criteria 条件
* @param pageable 分页参数

View File

@ -146,7 +146,7 @@ public class WxMaLiveGoodsServiceImpl implements WxMaLiveGoodsService {
* @throws WxErrorException
*/
private WxMediaUploadResult uploadPhotoToWx(WxMaService wxMaService, String picPath) throws WxErrorException {
String filename = String.valueOf( (int)System.currentTimeMillis() ) + ".png";
String filename = (int) System.currentTimeMillis() + ".png";
String downloadPath = uploadDirStr + filename;
long size = HttpUtil.downloadFile(picPath, cn.hutool.core.io.FileUtil.file(downloadPath));
picPath = downloadPath;

View File

@ -12,8 +12,8 @@ import cn.binarywang.wx.miniapp.api.WxMaService;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONUtil;
import co.yixiang.enums.LiveGoodsEnum;
import co.yixiang.exception.BadRequestException;
import co.yixiang.modules.wechat.domain.YxWechatLive;
import co.yixiang.modules.wechat.domain.YxWechatLiveGoods;
import co.yixiang.common.service.impl.BaseServiceImpl;
import co.yixiang.dozer.service.IGenerator;
@ -75,6 +75,7 @@ public class YxWechatLiveGoodsServiceImpl extends BaseServiceImpl<YxWechatLiveGo
* @return
*/
//@Cacheable
@Override
public boolean synchroWxOlLive(List<Integer> goodsIds) {
try {
WxMaLiveResult liveInfos = wxMaLiveGoodsService.getGoodsWareHouse(goodsIds);
@ -90,7 +91,7 @@ public class YxWechatLiveGoodsServiceImpl extends BaseServiceImpl<YxWechatLiveGo
}
@Override
public void removegoods(Long id) {
public void removeGoods(Long id) {
this.removeById(id);
try {
wxMaLiveGoodsService.deleteGoods(id.intValue());
@ -99,17 +100,22 @@ public class YxWechatLiveGoodsServiceImpl extends BaseServiceImpl<YxWechatLiveGo
}
}
/**
* 更新直播商品信息
* @param resources
*/
@Override
public void updategoods(YxWechatLiveGoods resources) {
public void updateGoods(YxWechatLiveGoods resources) {
YxWechatLiveGoods wechatLiveGoods = this.getById(resources.getGoodsId());
try {
WxMaService wxMaService = WxMaConfiguration.getWxMaService();
if(ObjectUtil.isNotEmpty(wechatLiveGoods)){
/** 审核状态 0未审核1审核中2:审核通过3审核失败 */
if("2".equals(wechatLiveGoods.getAuditStatus())){
}else if("0".equals(wechatLiveGoods.getAuditStatus())){
if(LiveGoodsEnum.IS_Audit_2.getValue().equals(wechatLiveGoods.getAuditStatus())){
}else if(LiveGoodsEnum.IS_Audit_0.getValue().equals(wechatLiveGoods.getAuditStatus())){
resources.setCoverImgUrl(uploadPhotoToWx(wxMaService,resources.getCoverImgeUrl()).getMediaId());
}else if("1".equals(wechatLiveGoods.getAuditStatus())){
}else if(LiveGoodsEnum.IS_Audit_1.getValue().equals(wechatLiveGoods.getAuditStatus())){
throw new BadRequestException("商品审核中不允许修改");
}
}
@ -121,6 +127,12 @@ public class YxWechatLiveGoodsServiceImpl extends BaseServiceImpl<YxWechatLiveGo
}
}
/**
* 查询数据分页
* @param criteria 条件
* @param pageable 分页参数
* @return Map<String,Object>
*/
@Override
//@Cacheable
public Map<String, Object> queryAll(YxWechatLiveGoodsQueryCriteria criteria, Pageable pageable) {
@ -136,14 +148,23 @@ public class YxWechatLiveGoodsServiceImpl extends BaseServiceImpl<YxWechatLiveGo
return map;
}
/**
* 查询所有数据不分页
* @param criteria 条件参数
* @return List<YxWechatLiveGoodsDto>
*/
@Override
//@Cacheable
public List<YxWechatLiveGoods> queryAll(YxWechatLiveGoodsQueryCriteria criteria){
return baseMapper.selectList(QueryHelpPlus.getPredicate(YxWechatLiveGoods.class, criteria));
}
/**
* 导出数据
* @param all 待导出的数据
* @param response /
* @throws IOException /
*/
@Override
public void download(List<YxWechatLiveGoodsDto> all, HttpServletResponse response) throws IOException {
List<Map<String, Object>> list = new ArrayList<>();
@ -164,6 +185,11 @@ public class YxWechatLiveGoodsServiceImpl extends BaseServiceImpl<YxWechatLiveGo
FileUtil.downloadExcel(list, response);
}
/**
* 保存直播商品信息
* @param resources
* @return
*/
@Override
public boolean saveGoods(YxWechatLiveGoods resources) {
WxMaService wxMaService = WxMaConfiguration.getWxMaService();
@ -188,7 +214,7 @@ public class YxWechatLiveGoodsServiceImpl extends BaseServiceImpl<YxWechatLiveGo
* @throws WxErrorException
*/
private WxMediaUploadResult uploadPhotoToWx(WxMaService wxMaService, String picPath) throws WxErrorException {
String filename = String.valueOf( (int)System.currentTimeMillis() ) + ".png";
String filename = (int) System.currentTimeMillis() + ".png";
String downloadPath = uploadDirStr + filename;
long size = HttpUtil.downloadFile(picPath, cn.hutool.core.io.FileUtil.file(downloadPath));
picPath = downloadPath;

View File

@ -75,6 +75,7 @@ public class YxWechatLiveServiceImpl extends BaseServiceImpl<YxWechatLiveMapper,
* @return
*/
//@Cacheable
@Override
public boolean synchroWxOlLive() {
try {
List<WxMaLiveResult.RoomInfo> liveInfos = wxMaLiveService.getLiveInfos();
@ -163,7 +164,7 @@ public class YxWechatLiveServiceImpl extends BaseServiceImpl<YxWechatLiveMapper,
* @throws WxErrorException
*/
private WxMediaUploadResult uploadPhotoToWx(WxMaService wxMaService, String picPath) throws WxErrorException {
String filename = String.valueOf( (int)System.currentTimeMillis() ) + ".png";
String filename = (int) System.currentTimeMillis() + ".png";
String downloadPath = uploadDirStr + filename;
long size = HttpUtil.downloadFile(picPath, cn.hutool.core.io.FileUtil.file(downloadPath));
picPath = downloadPath;

View File

@ -101,7 +101,7 @@ public class YxWechatReplyServiceImpl extends BaseServiceImpl<WechatReplyMapper,
@Override
public void upDate(YxWechatReply resources) {
YxWechatReply yxWechatReply = this.getById(resources.getId());
YxWechatReply yxWechatReply1 = null;
YxWechatReply yxWechatReply1;
yxWechatReply1 = this.isExist(resources.getKey());
if(yxWechatReply1 != null && !yxWechatReply1.getId().equals(yxWechatReply.getId())){
throw new EntityExistException(YxWechatReply.class,"key",resources.getKey());