微信小程序直播V0.2
This commit is contained in:
parent
c049552fc7
commit
910b665d8a
@ -44,7 +44,7 @@ public class Commodity extends BaseEntity {
|
|||||||
private String url;
|
private String url;
|
||||||
|
|
||||||
@ApiModelProperty(value = "微信程序直播商品ID")
|
@ApiModelProperty(value = "微信程序直播商品ID")
|
||||||
private String liveGoodsId;
|
private Integer liveGoodsId;
|
||||||
|
|
||||||
@ApiModelProperty(value = "审核单ID")
|
@ApiModelProperty(value = "审核单ID")
|
||||||
private String auditId;
|
private String auditId;
|
||||||
|
@ -78,7 +78,7 @@ public class Studio extends BaseEntity {
|
|||||||
|
|
||||||
|
|
||||||
@ApiModelProperty(value = "房间ID")
|
@ApiModelProperty(value = "房间ID")
|
||||||
private String roomId;
|
private Integer roomId;
|
||||||
|
|
||||||
@ApiModelProperty(value = "店铺ID")
|
@ApiModelProperty(value = "店铺ID")
|
||||||
private String storeId;
|
private String storeId;
|
||||||
|
@ -0,0 +1,48 @@
|
|||||||
|
package cn.lili.modules.broadcast.entity.dos;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import javax.persistence.Column;
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.Id;
|
||||||
|
import javax.persistence.Table;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author liushuai(liushuai711 @ gmail.com)
|
||||||
|
* @version v4.1
|
||||||
|
* @Description:
|
||||||
|
* @since 2021/5/17 3:10 下午
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Entity
|
||||||
|
@ApiModel(value = "直播商品")
|
||||||
|
@TableName("li_studio_commodity")
|
||||||
|
@Table(name = "li_studio_commodity")
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class StudioCommodity {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@TableId
|
||||||
|
@TableField
|
||||||
|
@Column(columnDefinition = "bigint(20)")
|
||||||
|
@ApiModelProperty(value = "唯一标识", hidden = true)
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "房间ID")
|
||||||
|
private Integer roomId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "商品ID")
|
||||||
|
private Integer goodsId;
|
||||||
|
|
||||||
|
public StudioCommodity(Integer roomId,Integer goodsId){
|
||||||
|
this.roomId=roomId;
|
||||||
|
this.goodsId=goodsId;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,21 @@
|
|||||||
|
package cn.lili.modules.broadcast.entity.vos;
|
||||||
|
|
||||||
|
import cn.lili.modules.broadcast.entity.dos.Commodity;
|
||||||
|
import cn.lili.modules.broadcast.entity.dos.Studio;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author liushuai(liushuai711 @ gmail.com)
|
||||||
|
* @version v4.1
|
||||||
|
* @Description:
|
||||||
|
* @since 2021/5/17 3:04 下午
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class StudioVO extends Studio {
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "直播间商品列表")
|
||||||
|
private List<Commodity> CommodityList;
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
package cn.lili.modules.broadcast.mapper;
|
||||||
|
|
||||||
|
import cn.lili.modules.broadcast.entity.dos.StudioCommodity;
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 直播间-商品关联持久层
|
||||||
|
* @author Bulbasaur
|
||||||
|
* @date: 2021/5/17 3:14 下午
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public interface StudioCommodityMapper extends BaseMapper<StudioCommodity> {
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
package cn.lili.modules.broadcast.service;
|
package cn.lili.modules.broadcast.service;
|
||||||
|
|
||||||
import cn.lili.modules.broadcast.entity.dos.Commodity;
|
import cn.lili.modules.broadcast.entity.dos.Commodity;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 直播商品业务层
|
* 直播商品业务层
|
||||||
@ -8,7 +9,7 @@ import cn.lili.modules.broadcast.entity.dos.Commodity;
|
|||||||
* @author Bulbasaur
|
* @author Bulbasaur
|
||||||
* @date: 2021/5/17 10:39 上午
|
* @date: 2021/5/17 10:39 上午
|
||||||
*/
|
*/
|
||||||
public interface CommodityService {
|
public interface CommodityService extends IService<Commodity> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加直播商品
|
* 添加直播商品
|
||||||
|
@ -0,0 +1,13 @@
|
|||||||
|
package cn.lili.modules.broadcast.service;
|
||||||
|
|
||||||
|
import cn.lili.modules.broadcast.entity.dos.StudioCommodity;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 直播间-商品关联业务层
|
||||||
|
*
|
||||||
|
* @author Bulbasaur
|
||||||
|
* @date: 2021/5/17 3:19 下午
|
||||||
|
*/
|
||||||
|
public interface StudioCommodityService extends IService<StudioCommodity> {
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
package cn.lili.modules.broadcast.service;
|
package cn.lili.modules.broadcast.service;
|
||||||
|
|
||||||
import cn.lili.modules.broadcast.entity.dos.Studio;
|
import cn.lili.modules.broadcast.entity.dos.Studio;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 直播间业务层
|
* 直播间业务层
|
||||||
@ -8,7 +9,7 @@ import cn.lili.modules.broadcast.entity.dos.Studio;
|
|||||||
* @author Bulbasaur
|
* @author Bulbasaur
|
||||||
* @date: 2021/5/17 10:02 上午
|
* @date: 2021/5/17 10:02 上午
|
||||||
*/
|
*/
|
||||||
public interface StudioService {
|
public interface StudioService extends IService<Studio> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建直播间
|
* 创建直播间
|
||||||
@ -26,5 +27,19 @@ public interface StudioService {
|
|||||||
*/
|
*/
|
||||||
String getLiveInfo(String roomId);
|
String getLiveInfo(String roomId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 推送商品
|
||||||
|
* @param roomId 店铺ID
|
||||||
|
* @param goodsId 商品ID
|
||||||
|
* @return 操作结果
|
||||||
|
*/
|
||||||
|
Boolean push(Integer roomId,Integer goodsId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除商品
|
||||||
|
* @param roomId 店铺ID
|
||||||
|
* @param goodsId 商品ID
|
||||||
|
* @return 操作结果
|
||||||
|
*/
|
||||||
|
Boolean goodsDeleteInRoom(Integer roomId,Integer goodsId);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package cn.lili.modules.broadcast.serviceimpl;
|
package cn.lili.modules.broadcast.serviceimpl;
|
||||||
|
|
||||||
|
import cn.hutool.core.convert.Convert;
|
||||||
import cn.hutool.json.JSONObject;
|
import cn.hutool.json.JSONObject;
|
||||||
import cn.lili.common.security.context.UserContext;
|
import cn.lili.common.security.context.UserContext;
|
||||||
import cn.lili.modules.broadcast.entity.dos.Commodity;
|
import cn.lili.modules.broadcast.entity.dos.Commodity;
|
||||||
@ -8,6 +9,7 @@ import cn.lili.modules.broadcast.service.CommodityService;
|
|||||||
import cn.lili.modules.broadcast.util.WechatLivePlayerUtil;
|
import cn.lili.modules.broadcast.util.WechatLivePlayerUtil;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -18,6 +20,7 @@ import java.util.Map;
|
|||||||
* @author Bulbasaur
|
* @author Bulbasaur
|
||||||
* @date: 2021/5/17 11:16 上午
|
* @date: 2021/5/17 11:16 上午
|
||||||
*/
|
*/
|
||||||
|
@Service
|
||||||
public class CommodityServiceImpl extends ServiceImpl<CommodityMapper, Commodity> implements CommodityService {
|
public class CommodityServiceImpl extends ServiceImpl<CommodityMapper, Commodity> implements CommodityService {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
@ -26,7 +29,7 @@ public class CommodityServiceImpl extends ServiceImpl<CommodityMapper, Commodity
|
|||||||
@Override
|
@Override
|
||||||
public boolean addCommodity(Commodity commodity) {
|
public boolean addCommodity(Commodity commodity) {
|
||||||
JSONObject json =wechatLivePlayerUtil.addGoods(commodity);
|
JSONObject json =wechatLivePlayerUtil.addGoods(commodity);
|
||||||
commodity.setLiveGoodsId(json.getStr("goodsId"));
|
commodity.setLiveGoodsId(Convert.toInt(json.getStr("goodsId")));
|
||||||
commodity.setAuditId(json.getStr("auditId"));
|
commodity.setAuditId(json.getStr("auditId"));
|
||||||
commodity.setStoreId(UserContext.getCurrentUser().getStoreId());
|
commodity.setStoreId(UserContext.getCurrentUser().getStoreId());
|
||||||
return this.save(commodity);
|
return this.save(commodity);
|
||||||
|
@ -0,0 +1,17 @@
|
|||||||
|
package cn.lili.modules.broadcast.serviceimpl;
|
||||||
|
|
||||||
|
import cn.lili.modules.broadcast.entity.dos.StudioCommodity;
|
||||||
|
import cn.lili.modules.broadcast.mapper.StudioCommodityMapper;
|
||||||
|
import cn.lili.modules.broadcast.service.StudioCommodityService;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 直播间-商品关联业务层实现
|
||||||
|
*
|
||||||
|
* @author Bulbasaur
|
||||||
|
* @date: 2021/5/17 3:20 下午
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class StudioCommodityServiceImpl extends ServiceImpl<StudioCommodityMapper, StudioCommodity> implements StudioCommodityService {
|
||||||
|
}
|
@ -2,11 +2,15 @@ package cn.lili.modules.broadcast.serviceimpl;
|
|||||||
|
|
||||||
import cn.lili.common.security.context.UserContext;
|
import cn.lili.common.security.context.UserContext;
|
||||||
import cn.lili.modules.broadcast.entity.dos.Studio;
|
import cn.lili.modules.broadcast.entity.dos.Studio;
|
||||||
|
import cn.lili.modules.broadcast.entity.dos.StudioCommodity;
|
||||||
import cn.lili.modules.broadcast.mapper.StudioMapper;
|
import cn.lili.modules.broadcast.mapper.StudioMapper;
|
||||||
|
import cn.lili.modules.broadcast.service.StudioCommodityService;
|
||||||
import cn.lili.modules.broadcast.service.StudioService;
|
import cn.lili.modules.broadcast.service.StudioService;
|
||||||
import cn.lili.modules.broadcast.util.WechatLivePlayerUtil;
|
import cn.lili.modules.broadcast.util.WechatLivePlayerUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 小程序直播间业务层实现
|
* 小程序直播间业务层实现
|
||||||
@ -14,16 +18,18 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
* @author Bulbasaur
|
* @author Bulbasaur
|
||||||
* @date: 2021/5/17 10:04 上午
|
* @date: 2021/5/17 10:04 上午
|
||||||
*/
|
*/
|
||||||
|
@Service
|
||||||
public class StudioServiceImpl extends ServiceImpl<StudioMapper, Studio> implements StudioService {
|
public class StudioServiceImpl extends ServiceImpl<StudioMapper, Studio> implements StudioService {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private WechatLivePlayerUtil wechatLivePlayerUtil;
|
private WechatLivePlayerUtil wechatLivePlayerUtil;
|
||||||
|
@Autowired
|
||||||
|
private StudioCommodityService studioCommodityService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean create(Studio studio) {
|
public Boolean create(Studio studio) {
|
||||||
|
|
||||||
//创建小程序直播
|
//创建小程序直播
|
||||||
String roomId=wechatLivePlayerUtil.create(studio);
|
Integer roomId=wechatLivePlayerUtil.create(studio);
|
||||||
studio.setRoomId(roomId);
|
studio.setRoomId(roomId);
|
||||||
studio.setStoreId(UserContext.getCurrentUser().getStoreId());
|
studio.setStoreId(UserContext.getCurrentUser().getStoreId());
|
||||||
return this.save(studio);
|
return this.save(studio);
|
||||||
@ -43,6 +49,29 @@ public class StudioServiceImpl extends ServiceImpl<StudioMapper, Studio> implem
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean push(Integer roomId, Integer goodsId) {
|
||||||
|
//调用微信接口添加直播间商品并进行记录
|
||||||
|
if(wechatLivePlayerUtil.pushGoods(roomId,goodsId)){
|
||||||
|
return studioCommodityService.save(new StudioCommodity(roomId,goodsId));
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean goodsDeleteInRoom(Integer roomId, Integer goodsId) {
|
||||||
|
//调用微信接口删除直播间商品并进行记录
|
||||||
|
if(wechatLivePlayerUtil.goodsDeleteInRoom(roomId,goodsId)){
|
||||||
|
return studioCommodityService.remove(new QueryWrapper<StudioCommodity>().eq("room_id",roomId).eq("goods_id",goodsId));
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据直播间ID获取直播间
|
||||||
|
* @param roomId 直播间ID
|
||||||
|
* @return 直播间
|
||||||
|
*/
|
||||||
private Studio getByRoomId(String roomId){
|
private Studio getByRoomId(String roomId){
|
||||||
return this.getOne(this.lambdaQuery().eq(Studio::getRoomId,roomId)) ;
|
return this.getOne(this.lambdaQuery().eq(Studio::getRoomId,roomId)) ;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
package cn.lili.modules.broadcast.util;
|
package cn.lili.modules.broadcast.util;
|
||||||
|
|
||||||
|
import cn.hutool.core.convert.Convert;
|
||||||
|
import cn.hutool.http.HttpRequest;
|
||||||
|
import cn.hutool.http.HttpResponse;
|
||||||
|
import cn.hutool.http.Method;
|
||||||
import cn.hutool.json.JSONObject;
|
import cn.hutool.json.JSONObject;
|
||||||
import cn.lili.modules.base.entity.enums.ClientTypeEnum;
|
import cn.lili.modules.base.entity.enums.ClientTypeEnum;
|
||||||
import cn.lili.modules.broadcast.entity.dos.Commodity;
|
import cn.lili.modules.broadcast.entity.dos.Commodity;
|
||||||
@ -11,6 +15,7 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -28,22 +33,40 @@ public class WechatLivePlayerUtil {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private WechatAccessTokenUtil wechatAccessTokenUtil;
|
private WechatAccessTokenUtil wechatAccessTokenUtil;
|
||||||
|
|
||||||
|
private void test(Studio studio){
|
||||||
|
HttpRequest httpRequest = new HttpRequest("https://api.weixin.qq.com/cgi-bin/media/upload");
|
||||||
|
httpRequest.setMethod(Method.POST);
|
||||||
|
File logoFile = new File(studio.getMediaUrl());
|
||||||
|
httpRequest.setConnectionTimeout(30000);
|
||||||
|
httpRequest.form("access_token",wechatAccessTokenUtil.cgiAccessToken(ClientTypeEnum.WECHAT_MP));
|
||||||
|
httpRequest.form("type", "image");
|
||||||
|
httpRequest.form("media", logoFile);
|
||||||
|
HttpResponse reqResult = httpRequest.execute();
|
||||||
|
System.out.println(reqResult.body());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建小程序直播间
|
* 创建小程序直播间
|
||||||
* @param studio 小程序直播
|
* @param studio 小程序直播
|
||||||
* @return 房间ID
|
* @return 房间ID
|
||||||
*/
|
*/
|
||||||
public String create(Studio studio){
|
public Integer create(Studio studio){
|
||||||
|
test(studio);
|
||||||
//获取token
|
//获取token
|
||||||
String token = wechatAccessTokenUtil.cgiAccessToken(ClientTypeEnum.H5);
|
String token = wechatAccessTokenUtil.cgiAccessToken(ClientTypeEnum.WECHAT_MP);
|
||||||
//发送url
|
//发送url
|
||||||
String url = "https://api.weixin.qq.com/wxaapi/broadcast/room/create?access_token="+ token;
|
String url = "https://api.weixin.qq.com/wxaapi/broadcast/room/create?access_token="+ token;
|
||||||
Map<String, String> map = new HashMap<>();
|
Map<String, String> map = new HashMap<>();
|
||||||
|
|
||||||
// 直播间名字
|
|
||||||
map.put("name", studio.getName());
|
|
||||||
// 背景图
|
// 背景图
|
||||||
map.put("coverImg", studio.getCoverImg());
|
map.put("coverImg", studio.getCoverImg());
|
||||||
|
// 分享图
|
||||||
|
map.put("shareImg", studio.getShareImg());
|
||||||
|
// 购物直播频道封面图
|
||||||
|
map.put("feedsImg", studio.getFeedsImg());
|
||||||
|
|
||||||
|
// 直播间名字
|
||||||
|
map.put("name", studio.getName());
|
||||||
// 直播计划开始时间
|
// 直播计划开始时间
|
||||||
map.put("startTime", studio.getStartTime());
|
map.put("startTime", studio.getStartTime());
|
||||||
// 直播计划结束时间
|
// 直播计划结束时间
|
||||||
@ -52,10 +75,6 @@ public class WechatLivePlayerUtil {
|
|||||||
map.put("anchorName", studio.getAnchorName());
|
map.put("anchorName", studio.getAnchorName());
|
||||||
// 主播微信号
|
// 主播微信号
|
||||||
map.put("anchorWechat", studio.getAnchorWechat());
|
map.put("anchorWechat", studio.getAnchorWechat());
|
||||||
// 分享图
|
|
||||||
map.put("shareImg", studio.getShareImg());
|
|
||||||
// 购物直播频道封面图
|
|
||||||
map.put("feedsImg", studio.getFeedsImg());
|
|
||||||
// 直播间类型
|
// 直播间类型
|
||||||
map.put("type", "0");
|
map.put("type", "0");
|
||||||
// 是否关闭点赞
|
// 是否关闭点赞
|
||||||
@ -70,7 +89,7 @@ public class WechatLivePlayerUtil {
|
|||||||
String content = HttpUtils.doPostWithJson(url, map);
|
String content = HttpUtils.doPostWithJson(url, map);
|
||||||
JSONObject json = new JSONObject(content);
|
JSONObject json = new JSONObject(content);
|
||||||
log.info("微信小程序直播间创建结果:" + content);
|
log.info("微信小程序直播间创建结果:" + content);
|
||||||
return json.getStr("roomId");
|
return Convert.toInt(json.getStr("roomId"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -80,7 +99,7 @@ public class WechatLivePlayerUtil {
|
|||||||
*/
|
*/
|
||||||
public String getLiveInfo(String roomId){
|
public String getLiveInfo(String roomId){
|
||||||
//获取token
|
//获取token
|
||||||
String token = wechatAccessTokenUtil.cgiAccessToken(ClientTypeEnum.H5);
|
String token = wechatAccessTokenUtil.cgiAccessToken(ClientTypeEnum.WECHAT_MP);
|
||||||
//发送url
|
//发送url
|
||||||
String url = "https://api.weixin.qq.com/wxa/business/getliveinfo?access_token="+ token;
|
String url = "https://api.weixin.qq.com/wxa/business/getliveinfo?access_token="+ token;
|
||||||
Map<String, String> map = new HashMap<>();
|
Map<String, String> map = new HashMap<>();
|
||||||
@ -100,6 +119,50 @@ public class WechatLivePlayerUtil {
|
|||||||
return json.getStr("live_replay");
|
return json.getStr("live_replay");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 推送直播间商品
|
||||||
|
* @param roomId 房间ID
|
||||||
|
* @param goodsId 商品ID
|
||||||
|
* @return 操作结果
|
||||||
|
*/
|
||||||
|
public Boolean pushGoods(Integer roomId,Integer goodsId){
|
||||||
|
//获取token
|
||||||
|
String token = wechatAccessTokenUtil.cgiAccessToken(ClientTypeEnum.WECHAT_MP);
|
||||||
|
//发送url
|
||||||
|
String url = "https://api.weixin.qq.com/wxaapi/broadcast/goods/push?access_token="+ token;
|
||||||
|
Map<String, Integer> map = new HashMap<>();
|
||||||
|
// 直播间回放
|
||||||
|
map.put("goodsId", goodsId);
|
||||||
|
// 商品ID
|
||||||
|
map.put("roomId", roomId);
|
||||||
|
String content = HttpUtils.doPostWithJson(url, map);
|
||||||
|
JSONObject json = new JSONObject(content);
|
||||||
|
log.info("微信小程序直播间推送商品:" + content);
|
||||||
|
return json.getStr("errcode").equals("0");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除直播间商品
|
||||||
|
* @param roomId 房间ID
|
||||||
|
* @param goodsId 商品ID
|
||||||
|
* @return 操作结果
|
||||||
|
*/
|
||||||
|
public Boolean goodsDeleteInRoom(Integer roomId,Integer goodsId){
|
||||||
|
//获取token
|
||||||
|
String token = wechatAccessTokenUtil.cgiAccessToken(ClientTypeEnum.WECHAT_MP);
|
||||||
|
//发送url
|
||||||
|
String url = "https://api.weixin.qq.com/wxaapi/broadcast/goods/deleteInRoom?access_token="+ token;
|
||||||
|
Map<String, Integer> map = new HashMap<>();
|
||||||
|
// 直播间回放
|
||||||
|
map.put("goodsId", goodsId);
|
||||||
|
// 商品ID
|
||||||
|
map.put("roomId", roomId);
|
||||||
|
String content = HttpUtils.doPostWithJson(url, map);
|
||||||
|
JSONObject json = new JSONObject(content);
|
||||||
|
log.info("微信小程序直播间删除商品:" + content);
|
||||||
|
return json.getStr("errcode").equals("0");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加直播商品
|
* 添加直播商品
|
||||||
* @param commodity 直播商品
|
* @param commodity 直播商品
|
||||||
@ -107,7 +170,7 @@ public class WechatLivePlayerUtil {
|
|||||||
*/
|
*/
|
||||||
public JSONObject addGoods(Commodity commodity){
|
public JSONObject addGoods(Commodity commodity){
|
||||||
//获取token
|
//获取token
|
||||||
String token = wechatAccessTokenUtil.cgiAccessToken(ClientTypeEnum.H5);
|
String token = wechatAccessTokenUtil.cgiAccessToken(ClientTypeEnum.WECHAT_MP);
|
||||||
//发送url
|
//发送url
|
||||||
String url = "https://api.weixin.qq.com/wxaapi/broadcast/goods/add?access_token="+ token;
|
String url = "https://api.weixin.qq.com/wxaapi/broadcast/goods/add?access_token="+ token;
|
||||||
GoodsInfo goodsInfo=new GoodsInfo(commodity);
|
GoodsInfo goodsInfo=new GoodsInfo(commodity);
|
||||||
@ -124,7 +187,7 @@ public class WechatLivePlayerUtil {
|
|||||||
*/
|
*/
|
||||||
public JSONObject deleteGoods(String goodsId){
|
public JSONObject deleteGoods(String goodsId){
|
||||||
//获取token
|
//获取token
|
||||||
String token = wechatAccessTokenUtil.cgiAccessToken(ClientTypeEnum.H5);
|
String token = wechatAccessTokenUtil.cgiAccessToken(ClientTypeEnum.WECHAT_MP);
|
||||||
//发送url
|
//发送url
|
||||||
String url = "https://api.weixin.qq.com/wxaapi/broadcast/goods/delete?access_token="+ token;
|
String url = "https://api.weixin.qq.com/wxaapi/broadcast/goods/delete?access_token="+ token;
|
||||||
String content = HttpUtils.doPostWithJson(url, goodsId);
|
String content = HttpUtils.doPostWithJson(url, goodsId);
|
||||||
@ -140,7 +203,7 @@ public class WechatLivePlayerUtil {
|
|||||||
*/
|
*/
|
||||||
public JSONObject deleteGoods(List<String> goodsIdList){
|
public JSONObject deleteGoods(List<String> goodsIdList){
|
||||||
//获取token
|
//获取token
|
||||||
String token = wechatAccessTokenUtil.cgiAccessToken(ClientTypeEnum.H5);
|
String token = wechatAccessTokenUtil.cgiAccessToken(ClientTypeEnum.WECHAT_MP);
|
||||||
//发送url
|
//发送url
|
||||||
String url = "https://api.weixin.qq.com/wxa/business/getgoodswarehouse?access_token="+ token;
|
String url = "https://api.weixin.qq.com/wxa/business/getgoodswarehouse?access_token="+ token;
|
||||||
String content = HttpUtils.doPostWithJson(url, goodsIdList);
|
String content = HttpUtils.doPostWithJson(url, goodsIdList);
|
||||||
|
@ -65,6 +65,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -86,7 +87,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|||||||
@Autowired
|
@Autowired
|
||||||
private TimeTrigger timeTrigger;
|
private TimeTrigger timeTrigger;
|
||||||
//订单货物数据层
|
//订单货物数据层
|
||||||
@Autowired
|
@Resource
|
||||||
private OrderItemMapper orderItemMapper;
|
private OrderItemMapper orderItemMapper;
|
||||||
//发票
|
//发票
|
||||||
@Autowired
|
@Autowired
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package cn.lili.controller.other;
|
package cn.lili.controller.other.article;
|
||||||
|
|
||||||
import cn.lili.common.utils.ResultUtil;
|
import cn.lili.common.utils.ResultUtil;
|
||||||
import cn.lili.common.vo.ResultMessage;
|
import cn.lili.common.vo.ResultMessage;
|
@ -0,0 +1,54 @@
|
|||||||
|
package cn.lili.controller.other.broadcast;
|
||||||
|
|
||||||
|
import cn.lili.common.enums.ResultCode;
|
||||||
|
import cn.lili.common.utils.PageUtil;
|
||||||
|
import cn.lili.common.utils.ResultUtil;
|
||||||
|
import cn.lili.common.vo.PageVO;
|
||||||
|
import cn.lili.common.vo.ResultMessage;
|
||||||
|
import cn.lili.modules.broadcast.entity.dos.Commodity;
|
||||||
|
import cn.lili.modules.broadcast.service.CommodityService;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 店铺端,直播商品接口
|
||||||
|
* @author Bulbasaur
|
||||||
|
* @date: 2021/5/17 2:05 下午
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@Api(tags = "店铺端,直播商品接口")
|
||||||
|
@RequestMapping("/store/broadcast/commodity")
|
||||||
|
public class CommodityController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CommodityService commodityService;
|
||||||
|
|
||||||
|
@ApiOperation(value = "获取店铺直播商品列表")
|
||||||
|
@GetMapping
|
||||||
|
public ResultMessage<IPage<Commodity>> page(PageVO pageVO) {
|
||||||
|
return ResultUtil.data(commodityService.page(PageUtil.initPage(pageVO)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "添加店铺直播商品")
|
||||||
|
@PostMapping
|
||||||
|
public ResultMessage<Object> addCommodity(@Validated Commodity commodity) {
|
||||||
|
if(commodityService.addCommodity(commodity)){
|
||||||
|
return ResultUtil.success(ResultCode.SUCCESS);
|
||||||
|
}
|
||||||
|
return ResultUtil.error(ResultCode.ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "删除店铺直播商品")
|
||||||
|
@DeleteMapping
|
||||||
|
public ResultMessage<Object> delete(String goodsId) {
|
||||||
|
if(commodityService.deleteCommodity(goodsId)){
|
||||||
|
return ResultUtil.success(ResultCode.SUCCESS);
|
||||||
|
}
|
||||||
|
return ResultUtil.error(ResultCode.ERROR);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,81 @@
|
|||||||
|
package cn.lili.controller.other.broadcast;
|
||||||
|
|
||||||
|
import cn.lili.common.enums.ResultCode;
|
||||||
|
import cn.lili.common.utils.PageUtil;
|
||||||
|
import cn.lili.common.utils.ResultUtil;
|
||||||
|
import cn.lili.common.vo.PageVO;
|
||||||
|
import cn.lili.common.vo.ResultMessage;
|
||||||
|
import cn.lili.modules.broadcast.entity.dos.Studio;
|
||||||
|
import cn.lili.modules.broadcast.service.StudioService;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiImplicitParam;
|
||||||
|
import io.swagger.annotations.ApiImplicitParams;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.apache.ibatis.annotations.Delete;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 店铺端,直播间接口
|
||||||
|
* @author Bulbasaur
|
||||||
|
* @date: 2021/5/17 2:05 下午
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@Api(tags = "店铺端,直播间接口")
|
||||||
|
@RequestMapping("/store/broadcast/studio")
|
||||||
|
public class StudioController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private StudioService studioService;
|
||||||
|
|
||||||
|
@ApiOperation(value = "获取店铺直播间列表")
|
||||||
|
@GetMapping
|
||||||
|
public ResultMessage<IPage<Studio>> page(PageVO pageVO) {
|
||||||
|
return ResultUtil.data(studioService.page(PageUtil.initPage(pageVO)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "获取店铺直播间详情")
|
||||||
|
@ApiImplicitParam(name = "studioId", value = "直播间ID", required = true, dataType = "String", paramType = "path")
|
||||||
|
@GetMapping("/studioInfo/{studioId}")
|
||||||
|
public ResultMessage<Studio> studioInfo(@PathVariable String studioId) {
|
||||||
|
return ResultUtil.data(studioService.getById(studioId));
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "添加直播间")
|
||||||
|
@PostMapping
|
||||||
|
public ResultMessage<Object> add(@Validated Studio studio) {
|
||||||
|
if(studioService.create(studio)){
|
||||||
|
return ResultUtil.success(ResultCode.SUCCESS);
|
||||||
|
}
|
||||||
|
return ResultUtil.error(ResultCode.ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "店铺直播间添加商品")
|
||||||
|
@ApiImplicitParams({
|
||||||
|
@ApiImplicitParam(name = "roomId", value = "房间ID", required = true, dataType = "Integer", paramType = "path"),
|
||||||
|
@ApiImplicitParam(name = "liveGoodsId", value = "直播商品ID", required = true, dataType = "Integer", paramType = "path")
|
||||||
|
})
|
||||||
|
@PutMapping(value = "/push/{roomId}/{liveGoodsId}")
|
||||||
|
public ResultMessage<Studio> push(@PathVariable Integer roomId,@PathVariable Integer liveGoodsId) {
|
||||||
|
if(studioService.push(roomId,liveGoodsId)){
|
||||||
|
return ResultUtil.success(ResultCode.SUCCESS);
|
||||||
|
}
|
||||||
|
return ResultUtil.error(ResultCode.ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "店铺直播间删除商品")
|
||||||
|
@ApiImplicitParams({
|
||||||
|
@ApiImplicitParam(name = "roomId", value = "房间ID", required = true, dataType = "Integer", paramType = "path"),
|
||||||
|
@ApiImplicitParam(name = "liveGoodsId", value = "直播商品ID", required = true, dataType = "Integer", paramType = "path")
|
||||||
|
})
|
||||||
|
@Delete(value = "/deleteInRoom/{roomId}/{liveGoodsId}")
|
||||||
|
public ResultMessage<Studio> deleteInRoom(@PathVariable Integer roomId,@PathVariable Integer liveGoodsId) {
|
||||||
|
if(studioService.goodsDeleteInRoom(roomId,liveGoodsId)){
|
||||||
|
return ResultUtil.success(ResultCode.SUCCESS);
|
||||||
|
}
|
||||||
|
return ResultUtil.error(ResultCode.ERROR);
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user