优化商品直播间同步逻辑,添加直播间的同时添加关联商品操作
This commit is contained in:
@ -119,6 +119,7 @@ public class YxWechatLive implements Serializable {
|
||||
@NotNull
|
||||
private Integer closeComment;
|
||||
|
||||
private String productId;
|
||||
|
||||
public void copy(YxWechatLive source){
|
||||
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
|
||||
|
@ -1,93 +0,0 @@
|
||||
/**
|
||||
* Copyright (C) 2018-2020
|
||||
* All rights reserved, Designed By www.yixiang.co
|
||||
* 注意:
|
||||
* 本软件为www.yixiang.co开发研制,未经购买不得使用
|
||||
* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台)
|
||||
* 一经发现盗用、分享等行为,将追究法律责任,后果自负
|
||||
*/
|
||||
package co.yixiang.modules.wechat.rest;
|
||||
import java.util.Arrays;
|
||||
import co.yixiang.dozer.service.IGenerator;
|
||||
import lombok.AllArgsConstructor;
|
||||
import co.yixiang.logging.aop.log.Log;
|
||||
import co.yixiang.modules.wechat.domain.YxWechatLive;
|
||||
import co.yixiang.modules.wechat.service.YxWechatLiveService;
|
||||
import co.yixiang.modules.wechat.service.dto.YxWechatLiveQueryCriteria;
|
||||
import co.yixiang.modules.wechat.service.dto.YxWechatLiveDto;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import io.swagger.annotations.*;
|
||||
import java.io.IOException;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* @author hupeng
|
||||
* @date 2020-08-10
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@Api(tags = "wxlive管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/yxWechatLive")
|
||||
public class YxWechatLiveController {
|
||||
|
||||
private final YxWechatLiveService yxWechatLiveService;
|
||||
private final IGenerator generator;
|
||||
|
||||
|
||||
@Log("导出数据")
|
||||
@ApiOperation("导出数据")
|
||||
@GetMapping(value = "/download")
|
||||
@PreAuthorize("@el.check('admin','yxWechatLive:list')")
|
||||
public void download(HttpServletResponse response, YxWechatLiveQueryCriteria criteria) throws IOException {
|
||||
yxWechatLiveService.download(generator.convert(yxWechatLiveService.queryAll(criteria), YxWechatLiveDto.class), response);
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
@Log("查询wxlive")
|
||||
@ApiOperation("查询wxlive")
|
||||
@PreAuthorize("@el.check('admin','yxWechatLive:list')")
|
||||
public ResponseEntity<Object> getYxWechatLives(YxWechatLiveQueryCriteria criteria, Pageable pageable){
|
||||
return new ResponseEntity<>(yxWechatLiveService.queryAll(criteria,pageable),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@Log("新增wxlive")
|
||||
@ApiOperation("新增wxlive")
|
||||
@PreAuthorize("@el.check('admin','yxWechatLive:add')")
|
||||
public ResponseEntity<Object> create(@Validated @RequestBody YxWechatLive resources){
|
||||
return new ResponseEntity<>(yxWechatLiveService.saveLive(resources),HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@Log("修改wxlive")
|
||||
@ApiOperation("修改wxlive")
|
||||
@PreAuthorize("@el.check('admin','yxWechatLive:edit')")
|
||||
public ResponseEntity<Object> update(@Validated @RequestBody YxWechatLive resources){
|
||||
yxWechatLiveService.updateById(resources);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@Log("删除wxlive")
|
||||
@ApiOperation("删除wxlive")
|
||||
@PreAuthorize("@el.check('admin','yxWechatLive:del')")
|
||||
@DeleteMapping
|
||||
public ResponseEntity<Object> deleteAll(@RequestBody Long[] ids) {
|
||||
Arrays.asList(ids).forEach(id->{
|
||||
yxWechatLiveService.removeById(id);
|
||||
});
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation("同步数据")
|
||||
@GetMapping("/synchro")
|
||||
public ResponseEntity<Object> synchroWxOlLive() {
|
||||
yxWechatLiveService.synchroWxOlLive();
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
}
|
@ -1,94 +0,0 @@
|
||||
/**
|
||||
* Copyright (C) 2018-2020
|
||||
* All rights reserved, Designed By www.yixiang.co
|
||||
* 注意:
|
||||
* 本软件为www.yixiang.co开发研制,未经购买不得使用
|
||||
* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台)
|
||||
* 一经发现盗用、分享等行为,将追究法律责任,后果自负
|
||||
*/
|
||||
package co.yixiang.modules.wechat.rest;
|
||||
import java.util.Arrays;
|
||||
import co.yixiang.dozer.service.IGenerator;
|
||||
import co.yixiang.modules.wechat.service.WxMaLiveGoodsService;
|
||||
import lombok.AllArgsConstructor;
|
||||
import co.yixiang.logging.aop.log.Log;
|
||||
import co.yixiang.modules.wechat.domain.YxWechatLiveGoods;
|
||||
import co.yixiang.modules.wechat.service.YxWechatLiveGoodsService;
|
||||
import co.yixiang.modules.wechat.service.dto.YxWechatLiveGoodsQueryCriteria;
|
||||
import co.yixiang.modules.wechat.service.dto.YxWechatLiveGoodsDto;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import io.swagger.annotations.*;
|
||||
import java.io.IOException;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* @author hupeng
|
||||
* @date 2020-08-11
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@Api(tags = "yxWechatLiveGoods管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/yxWechatLiveGoods")
|
||||
public class YxWechatLiveGoodsController {
|
||||
|
||||
private final YxWechatLiveGoodsService yxWechatLiveGoodsService;
|
||||
private final IGenerator generator;
|
||||
private final WxMaLiveGoodsService wxMaLiveGoodsService;
|
||||
|
||||
@Log("导出数据")
|
||||
@ApiOperation("导出数据")
|
||||
@GetMapping(value = "/download")
|
||||
@PreAuthorize("@el.check('admin','yxWechatLiveGoods:list')")
|
||||
public void download(HttpServletResponse response, YxWechatLiveGoodsQueryCriteria criteria) throws IOException {
|
||||
yxWechatLiveGoodsService.download(generator.convert(yxWechatLiveGoodsService.queryAll(criteria), YxWechatLiveGoodsDto.class), response);
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
@Log("查询yxWechatLiveGoods")
|
||||
@ApiOperation("查询yxWechatLiveGoods")
|
||||
@PreAuthorize("@el.check('admin','yxWechatLiveGoods:list')")
|
||||
public ResponseEntity<Object> getYxWechatLiveGoodss(YxWechatLiveGoodsQueryCriteria criteria, Pageable pageable){
|
||||
return new ResponseEntity<>(yxWechatLiveGoodsService.queryAll(criteria,pageable),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@Log("新增yxWechatLiveGoods")
|
||||
@ApiOperation("新增yxWechatLiveGoods")
|
||||
@PreAuthorize("@el.check('admin','yxWechatLiveGoods:add')")
|
||||
public ResponseEntity<Object> create(@Validated @RequestBody YxWechatLiveGoods resources){
|
||||
return new ResponseEntity<>(yxWechatLiveGoodsService.saveGoods(resources),HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@Log("修改yxWechatLiveGoods")
|
||||
@ApiOperation("修改yxWechatLiveGoods")
|
||||
@PreAuthorize("@el.check('admin','yxWechatLiveGoods:edit')")
|
||||
public ResponseEntity<Object> update(@Validated @RequestBody YxWechatLiveGoods resources){
|
||||
yxWechatLiveGoodsService.updateGoods(resources);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@Log("删除yxWechatLiveGoods")
|
||||
@ApiOperation("删除yxWechatLiveGoods")
|
||||
@PreAuthorize("@el.check('admin','yxWechatLiveGoods:del')")
|
||||
@DeleteMapping
|
||||
public ResponseEntity<Object> deleteAll(@RequestBody Long[] ids) {
|
||||
Arrays.asList(ids).forEach(id->{
|
||||
yxWechatLiveGoodsService.removeGoods(id);
|
||||
});
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ApiOperation("同步数据")
|
||||
@PostMapping("/synchro")
|
||||
public ResponseEntity<Object> synchroWxOlLiveGoods(@RequestBody Integer[] ids) {
|
||||
yxWechatLiveGoodsService.synchroWxOlLive(Arrays.asList(ids));
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
}
|
@ -10,6 +10,8 @@ package co.yixiang.modules.wechat.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
|
||||
@ -62,9 +64,17 @@ public class YxWechatLiveDto implements Serializable {
|
||||
/** 横屏、竖屏 【1:横屏,0:竖屏】 */
|
||||
private Integer screenType;
|
||||
|
||||
/** 是否关闭货架 【0:开启,1:关闭】 */
|
||||
/** 是否关闭点赞 【0:开启,1:关闭】 */
|
||||
private Integer closeLike;
|
||||
|
||||
/** 是否关闭评论 【0:开启,1:关闭】 */
|
||||
private Integer closeComment;
|
||||
|
||||
/** 是否关闭货架 【0:开启,1:关闭】 */
|
||||
private Integer closeGoods;
|
||||
/**
|
||||
* 关联商品id多个,隔开
|
||||
*/
|
||||
private String productId;
|
||||
private List<YxWechatLiveGoodsDto> product;
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ public class YxWechatLiveGoodsDto implements Serializable {
|
||||
private String thirdPartyTag;
|
||||
|
||||
/** 审核单id */
|
||||
private Long auditid;
|
||||
private Long auditId;
|
||||
|
||||
/** 审核状态 0:未审核,1:审核中,2:审核通过,3审核失败 */
|
||||
private Integer auditStatus;
|
||||
|
@ -80,9 +80,6 @@ public class YxWechatLiveGoodsServiceImpl extends BaseServiceImpl<YxWechatLiveGo
|
||||
try {
|
||||
WxMaLiveResult liveInfos = wxMaLiveGoodsService.getGoodsWareHouse(goodsIds);
|
||||
List<YxWechatLiveGoods> convert = generator.convert(liveInfos.getGoods(), YxWechatLiveGoods.class);
|
||||
convert.forEach(i ->{
|
||||
i.setCoverImgeUrl(i.getCoverImgUrl());
|
||||
});
|
||||
this.saveOrUpdateBatch(convert);
|
||||
} catch (WxErrorException e) {
|
||||
e.printStackTrace();
|
||||
@ -178,7 +175,7 @@ public class YxWechatLiveGoodsServiceImpl extends BaseServiceImpl<YxWechatLiveGo
|
||||
map.put(" price2", yxWechatLiveGoods.getPrice2());
|
||||
map.put("商品名称", yxWechatLiveGoods.getName());
|
||||
map.put("1, 2:表示是为api添加商品,否则是直播控制台添加的商品", yxWechatLiveGoods.getThirdPartyTag());
|
||||
map.put("审核单id", yxWechatLiveGoods.getAuditid());
|
||||
map.put("审核单id", yxWechatLiveGoods.getAuditId());
|
||||
map.put("审核状态 0:未审核,1:审核中,2:审核通过,3审核失败", yxWechatLiveGoods.getAuditStatus());
|
||||
list.add(map);
|
||||
}
|
||||
|
@ -15,18 +15,18 @@ import co.yixiang.exception.BadRequestException;
|
||||
import co.yixiang.modules.wechat.domain.YxWechatLive;
|
||||
import co.yixiang.common.service.impl.BaseServiceImpl;
|
||||
import co.yixiang.dozer.service.IGenerator;
|
||||
import co.yixiang.modules.wechat.domain.YxWechatLiveGoods;
|
||||
import co.yixiang.modules.wechat.service.WxMaLiveService;
|
||||
import co.yixiang.modules.wechat.service.dto.WxMaLiveInfo;
|
||||
import co.yixiang.modules.wechat.service.dto.WxMaLiveResult;
|
||||
import co.yixiang.modules.wechat.service.YxWechatLiveGoodsService;
|
||||
import co.yixiang.modules.wechat.service.dto.*;
|
||||
import co.yixiang.tools.config.WxMaConfiguration;
|
||||
import co.yixiang.utils.DateUtils;
|
||||
import co.yixiang.utils.OrderUtil;
|
||||
import co.yixiang.utils.StringUtils;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import co.yixiang.common.utils.QueryHelpPlus;
|
||||
import co.yixiang.utils.FileUtil;
|
||||
import co.yixiang.modules.wechat.service.YxWechatLiveService;
|
||||
import co.yixiang.modules.wechat.service.dto.YxWechatLiveDto;
|
||||
import co.yixiang.modules.wechat.service.dto.YxWechatLiveQueryCriteria;
|
||||
import co.yixiang.modules.wechat.service.mapper.YxWechatLiveMapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import me.chanjar.weixin.common.api.WxConsts;
|
||||
@ -43,12 +43,9 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
/**
|
||||
* @author hupeng
|
||||
@ -64,10 +61,12 @@ public class YxWechatLiveServiceImpl extends BaseServiceImpl<YxWechatLiveMapper,
|
||||
@Value("${file.path}")
|
||||
private String uploadDirStr;
|
||||
private final WxMaLiveService wxMaLiveService;
|
||||
private final YxWechatLiveGoodsService wechatLiveGoodsService;
|
||||
|
||||
public YxWechatLiveServiceImpl(IGenerator generator, WxMaLiveService wxMaLiveService) {
|
||||
public YxWechatLiveServiceImpl(IGenerator generator, WxMaLiveService wxMaLiveService, YxWechatLiveGoodsService wechatLiveGoodsService) {
|
||||
this.generator = generator;
|
||||
this.wxMaLiveService = wxMaLiveService;
|
||||
this.wechatLiveGoodsService = wechatLiveGoodsService;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -80,11 +79,6 @@ public class YxWechatLiveServiceImpl extends BaseServiceImpl<YxWechatLiveMapper,
|
||||
try {
|
||||
List<WxMaLiveResult.RoomInfo> liveInfos = wxMaLiveService.getLiveInfos();
|
||||
List<YxWechatLive> convert = generator.convert(liveInfos, YxWechatLive.class);
|
||||
convert.forEach(i ->{
|
||||
i.setAnchorImge(i.getAnchorImg());
|
||||
i.setCoverImge(i.getCoverImg());
|
||||
i.setShareImge(i.getShareImg());
|
||||
});
|
||||
this.saveOrUpdateBatch(convert);
|
||||
} catch (WxErrorException e) {
|
||||
e.printStackTrace();
|
||||
@ -99,7 +93,14 @@ public class YxWechatLiveServiceImpl extends BaseServiceImpl<YxWechatLiveMapper,
|
||||
Map<String, Object> map = new LinkedHashMap<>(2);
|
||||
// List<WxMaLiveResult.RoomInfo> liveInfos = wxMaLiveService.getLiveInfos();
|
||||
List<YxWechatLiveDto> liveDtos = generator.convert(page.getList(), YxWechatLiveDto.class);
|
||||
//获取所有商品
|
||||
liveDtos.forEach(i ->{
|
||||
if(StringUtils.isNotBlank(i.getProductId())){
|
||||
List<YxWechatLiveGoodsDto> wechatLiveGoodsDtos = generator.convert(
|
||||
wechatLiveGoodsService.list(new LambdaQueryWrapper<YxWechatLiveGoods>().in(YxWechatLiveGoods::getGoodsId,i.getProductId().split(",")))
|
||||
,YxWechatLiveGoodsDto.class);
|
||||
i.setProduct(wechatLiveGoodsDtos);
|
||||
}
|
||||
i.setId(i.getRoomid());
|
||||
});
|
||||
map.put("content",liveDtos);
|
||||
@ -118,6 +119,15 @@ public class YxWechatLiveServiceImpl extends BaseServiceImpl<YxWechatLiveMapper,
|
||||
WxMaLiveInfo.RoomInfo roomInfo = generator.convert(resources, WxMaLiveInfo.RoomInfo.class);
|
||||
Integer status = wxMaLiveService.createRoom(roomInfo);
|
||||
resources.setRoomid(Long.valueOf(status));
|
||||
if(StringUtils.isNotBlank(resources.getProductId())){
|
||||
String[] productIds = resources.getProductId().split(",");
|
||||
List<Integer> pids = new ArrayList<>();
|
||||
for (String productId : productIds) {
|
||||
pids.add(Integer.valueOf(productId));
|
||||
}
|
||||
//添加商品
|
||||
wxMaLiveService.addGoodsToRoom(status, pids);
|
||||
}
|
||||
this.save(resources);
|
||||
} catch (WxErrorException e) {
|
||||
e.printStackTrace();
|
||||
|
Reference in New Issue
Block a user