微信模块整理

This commit is contained in:
xuwenbo
2020-09-08 14:50:10 +08:00
parent d32349b235
commit d4f57c94d8
84 changed files with 1019 additions and 1030 deletions

View File

@ -361,7 +361,7 @@ public class YxStoreCombinationServiceImpl extends BaseServiceImpl<YxStoreCombin
//取最小价格
Double minPrice = ListMapToListBean(attrs)
.stream()
.map(ProductFormatDto::getPrice)
.map(ProductFormatDto::getPinkPrice)
.min(Comparator.naturalOrder())
.orElse(0d);
@ -379,7 +379,7 @@ public class YxStoreCombinationServiceImpl extends BaseServiceImpl<YxStoreCombin
//计算库存
Integer stock = ListMapToListBean(attrs)
.stream()
.map(ProductFormatDto::getStock)
.map(ProductFormatDto::getPinkStock)
.reduce(Integer::sum)
.orElse(0);

View File

@ -313,7 +313,7 @@ public class YxStoreSeckillServiceImpl extends BaseServiceImpl<YxStoreSeckillMap
//取最小价格
Double minPrice = ListMapToListBean(attrs)
.stream()
.map(ProductFormatDto::getPrice)
.map(ProductFormatDto::getSeckillPrice)
.min(Comparator.naturalOrder())
.orElse(0d);
@ -331,7 +331,7 @@ public class YxStoreSeckillServiceImpl extends BaseServiceImpl<YxStoreSeckillMap
//计算库存
Integer stock = ListMapToListBean(attrs)
.stream()
.map(ProductFormatDto::getStock)
.map(ProductFormatDto::getSeckillStock)
.reduce(Integer::sum)
.orElse(0);

View File

@ -139,8 +139,13 @@ public class YxStoreProductServiceImpl extends BaseServiceImpl<StoreProductMappe
yxStoreProductAttrService.decProductAttrStock(num,productId,unique, type);
}
int res = 0;
if("combination".equals(type)){
res = storeProductMapper.decCombinationStockIncSales(num,productId,activityId);
}else if("seckill".equals(type)){
res = storeProductMapper.decSeckillStockIncSales(num,productId,activityId);
}else {
res = storeProductMapper.decStockIncSales(num,productId);
}
if(res == 0) {
throw new YshopException("商品库存不足");

View File

@ -1,112 +0,0 @@
/**
* Copyright (C) 2018-2020
* All rights reserved, Designed By www.yixiang.co
*/
package co.yixiang.modules.wechat.domain;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import co.yixiang.domain.BaseDomain;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import javax.validation.constraints.NotBlank;
/**
* @author hupeng
* @date 2020-05-12
*/
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("yx_article")
public class YxArticle extends BaseDomain {
/** 文章管理ID */
@TableId
private Integer id;
/** 分类id */
private String cid;
/** 文章标题 */
@NotBlank(message = "请输入文章标题")
private String title;
/** 文章作者 */
@NotBlank(message = "请输入文章作者")
private String author;
/** 文章图片 */
@NotBlank(message = "请上传文章图片")
private String imageInput;
/** 文章简介 */
@NotBlank(message = "请填写文章简介")
private String synopsis;
@NotBlank(message = "请填写文章详情")
private String content;
/** 文章分享标题 */
private String shareTitle;
/** 文章分享简介 */
private String shareSynopsis;
/** 浏览次数 */
private String visit;
/** 排序 */
private Integer sort;
/** 原文链接 */
private String url;
/** 状态 */
private Integer status;
/** 是否隐藏 */
private Integer hide;
/** 管理员id */
private Integer adminId;
/** 商户id */
private Integer merId;
/** 产品关联id */
private Integer productId;
/** 是否热门(小程序) */
private Integer isHot;
/** 是否轮播图(小程序) */
private Integer isBanner;
public void copy(YxArticle source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
}
}

View File

@ -1,131 +0,0 @@
/**
* Copyright (C) 2018-2020
* All rights reserved, Designed By www.yixiang.co
* 注意:
* 本软件为www.yixiang.co开发研制未经购买不得使用
* 购买后可获得全部源代码禁止转卖、分享、上传到码云、github等开源平台
* 一经发现盗用、分享等行为,将追究法律责任,后果自负
*/
package co.yixiang.modules.wechat.domain;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;
/**
* @author hupeng
* @date 2020-08-10
*/
@Data
@TableName("yx_wechat_live")
public class YxWechatLive implements Serializable {
/** 直播间id */
@TableId(type = IdType.INPUT)
private Long roomId;
/** 直播间标题 */
@NotBlank
private String name;
/** 背景图 */
@TableField(exist = false)
private String coverImg;
/** 分享图片 */
@TableField(exist = false)
private String shareImg;
/** 背景图 */
@NotBlank
private String coverImge;
/** 分享图片 */
@NotBlank
private String shareImge;
/** 主播头像 */
private String anchorImge;
/**
* 101直播中102未开始103已结束104禁播105暂停106异常107已过期
*/
/** 直播间状态 */
private Integer liveStatus;
/** 开始时间 */
private Long startTime;
/** 预计结束时间 */
private Long endTime;
/** 开始时间 */
@NotNull
@TableField(exist = false)
private Date startDate;
/** 预计结束时间 */
@NotNull
@TableField(exist = false)
private Date endDate;
/** 主播昵称 */
@NotBlank
private String anchorName;
/** 主播微信号 */
@NotBlank
private String anchorWechat;
/** 主播头像 */
@TableField(exist = false)
private String anchorImg;
/** 直播间类型 1推流 0手机直播 */
@NotNull
private Integer type;
/** 横屏、竖屏 【1横屏0竖屏】 */
@NotNull
private Integer screenType;
/** 是否关闭点赞 【0开启1关闭】 */
@NotNull
private Integer closeLike;
/** 是否关闭货架 【0开启1关闭】 */
@NotNull
private Integer closeGoods;
/** 是否关闭评论 【0开启1关闭】 */
@NotNull
private Integer closeComment;
private String productId;
public void copy(YxWechatLive source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
}
}

View File

@ -1,85 +0,0 @@
/**
* Copyright (C) 2018-2020
* All rights reserved, Designed By www.yixiang.co
* 注意:
* 本软件为www.yixiang.co开发研制未经购买不得使用
* 购买后可获得全部源代码禁止转卖、分享、上传到码云、github等开源平台
* 一经发现盗用、分享等行为,将追究法律责任,后果自负
*/
package co.yixiang.modules.wechat.domain;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
/**
* @author hupeng
* @date 2020-08-11
*/
@Data
@TableName("yx_wechat_live_goods")
public class YxWechatLiveGoods implements Serializable {
/** 直播商品id */
@TableId(type = IdType.INPUT)
private Long goodsId;
/** 关联商品id */
private Long productId;
/** 商品图片 */
@TableField(exist = false)
private String coverImgUrl;
/** 商品图片 */
@NotBlank
private String coverImgeUrl;
/** 商品小程序路径 */
@NotBlank
private String url;
/** 价格类型 1一口价只需要传入priceprice2不传 2价格区间price字段为左边界price2字段为右边界price和price2必传 3显示折扣价price字段为原价price2字段为现价 price和price2必传 */
@NotBlank
private String priceType;
@NotBlank
private String price;
private String price2;
/** 商品名称 */
@NotBlank
private String name;
/** 1, 2表示是为api添加商品否则是直播控制台添加的商品 */
private String thirdPartyTag;
/** 审核单id */
private Long auditId;
/** 审核状态 0未审核1审核中2:审核通过3审核失败 */
private Integer auditStatus;
public void copy(YxWechatLiveGoods source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
}
}

View File

@ -1,42 +0,0 @@
/**
* Copyright (C) 2018-2020
* All rights reserved, Designed By www.yixiang.co
*/
package co.yixiang.modules.wechat.domain;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable;
/**
* @author hupeng
* @date 2020-05-12
*/
@Data
@TableName("yx_wechat_menu")
public class YxWechatMenu implements Serializable {
@TableId(value = "`key`")
private String key;
/** 缓存数据 */
private String result;
/** 缓存时间 */
@TableField(fill= FieldFill.INSERT)
private Integer addTime;
public void copy(YxWechatMenu source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
}
}

View File

@ -1,54 +0,0 @@
/**
* Copyright (C) 2018-2020
* All rights reserved, Designed By www.yixiang.co
*/
package co.yixiang.modules.wechat.domain;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable;
/**
* @author hupeng
* @date 2020-05-12
*/
@Data
@TableName("yx_wechat_reply")
public class YxWechatReply implements Serializable {
/** 微信关键字回复id */
@TableId
private Integer id;
/** 关键字 */
@TableField(value = "`key`")
private String key;
/** 回复类型 */
private String type;
/** 回复数据 */
private String data;
/** 0=不可用 1 =可用 */
private Integer status;
/** 是否隐藏 */
private Integer hide;
public void copy(YxWechatReply source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
}
}

View File

@ -1,56 +0,0 @@
/**
* Copyright (C) 2018-2020
* All rights reserved, Designed By www.yixiang.co
*/
package co.yixiang.modules.wechat.domain;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import co.yixiang.domain.BaseDomain;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* @author hupeng
* @date 2020-05-12
*/
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("yx_wechat_template")
public class YxWechatTemplate extends BaseDomain {
/** 模板id */
@TableId
private Integer id;
/** 模板编号 */
private String tempkey;
/** 模板名 */
private String name;
/** 回复内容 */
private String content;
/** 模板ID */
private String tempid;
/** 状态 */
private Integer status;
/** 类型template:模板消息 subscribe:订阅消息 */
private String type;
public void copy(YxWechatTemplate source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
}
}

View File

@ -1,70 +0,0 @@
/**
* Copyright (C) 2018-2020
* All rights reserved, Designed By www.yixiang.co
* 注意:
* 本软件为www.yixiang.co开发研制未经购买不得使用
* 购买后可获得全部源代码禁止转卖、分享、上传到码云、github等开源平台
* 一经发现盗用、分享等行为,将追究法律责任,后果自负
*/
package co.yixiang.modules.wechat.service;
import co.yixiang.common.service.BaseService;
import co.yixiang.modules.wechat.domain.YxArticle;
import co.yixiang.modules.wechat.service.dto.YxArticleDto;
import co.yixiang.modules.wechat.service.dto.YxArticleQueryCriteria;
import co.yixiang.modules.wechat.vo.YxArticleQueryVo;
import org.springframework.data.domain.Pageable;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
import java.util.Map;
/**
* @author hupeng
* @date 2020-05-12
*/
public interface YxArticleService extends BaseService<YxArticle>{
/**
* 获取文章列表
* @param page 页码
* @param limit 条数
* @return List
*/
List<YxArticleQueryVo> getList(int page, int limit);
/**
* 获取文章详情
* @param id id
* @return YxArticleQueryVo
*/
YxArticleQueryVo getDetail(int id);
void incVisitNum(int id);
/**
* 查询数据分页
* @param criteria 条件
* @param pageable 分页参数
* @return Map<String,Object>
*/
Map<String,Object> queryAll(YxArticleQueryCriteria criteria, Pageable pageable);
/**
* 查询所有数据不分页
* @param criteria 条件参数
* @return List<YxArticleDto>
*/
List<YxArticle> queryAll(YxArticleQueryCriteria criteria);
/**
* 导出数据
* @param all 待导出的数据
* @param response /
* @throws IOException /
*/
void download(List<YxArticleDto> all, HttpServletResponse response) throws IOException;
}

View File

@ -1,76 +0,0 @@
/**
* Copyright (C) 2018-2020
* All rights reserved, Designed By www.yixiang.co
* 注意:
* 本软件为www.yixiang.co开发研制未经购买不得使用
* 购买后可获得全部源代码禁止转卖、分享、上传到码云、github等开源平台
* 一经发现盗用、分享等行为,将追究法律责任,后果自负
*/
package co.yixiang.modules.wechat.service;
import co.yixiang.common.service.BaseService;
import co.yixiang.modules.wechat.domain.YxWechatLiveGoods;
import co.yixiang.modules.wechat.service.dto.YxWechatLiveGoodsDto;
import co.yixiang.modules.wechat.service.dto.YxWechatLiveGoodsQueryCriteria;
import org.springframework.data.domain.Pageable;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
import java.util.Map;
/**
* @author hupeng
* @date 2020-08-11
*/
public interface YxWechatLiveGoodsService extends BaseService<YxWechatLiveGoods>{
/**
* 查询数据分页
* @param criteria 条件
* @param pageable 分页参数
* @return Map<String,Object>
*/
Map<String,Object> queryAll(YxWechatLiveGoodsQueryCriteria criteria, Pageable pageable);
/**
* 查询所有数据不分页
* @param criteria 条件参数
* @return List<YxWechatLiveGoodsDto>
*/
List<YxWechatLiveGoods> queryAll(YxWechatLiveGoodsQueryCriteria criteria);
/**
* 导出数据
* @param all 待导出的数据
* @param response /
* @throws IOException /
*/
void download(List<YxWechatLiveGoodsDto> all, HttpServletResponse response) throws IOException;
/**
* 保存直播商品信息
* @param resources
* @return
*/
boolean saveGoods(YxWechatLiveGoods resources);
/**
* 同步商品更新审核状态
* @param goodsIds
* @return
*/
boolean synchroWxOlLive(List<Integer> goodsIds);
/**
* 根据id删除直播商品信息
* @param id
*/
void removeGoods(Long id);
/**
* 更新直播商品信息
* @param resources
*/
void updateGoods(YxWechatLiveGoods resources);
}

View File

@ -1,71 +0,0 @@
/**
* Copyright (C) 2018-2020
* All rights reserved, Designed By www.yixiang.co
* 注意:
* 本软件为www.yixiang.co开发研制未经购买不得使用
* 购买后可获得全部源代码禁止转卖、分享、上传到码云、github等开源平台
* 一经发现盗用、分享等行为,将追究法律责任,后果自负
*/
package co.yixiang.modules.wechat.service;
import cn.binarywang.wx.miniapp.bean.WxMaLiveResult;
import co.yixiang.common.service.BaseService;
import co.yixiang.modules.wechat.domain.YxWechatLive;
import co.yixiang.modules.wechat.service.dto.YxWechatLiveDto;
import co.yixiang.modules.wechat.service.dto.YxWechatLiveQueryCriteria;
import co.yixiang.modules.wechat.vo.WechatLiveVo;
import org.springframework.data.domain.Pageable;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
import java.util.Map;
/**
* @author hupeng
* @date 2020-08-10
*/
public interface YxWechatLiveService extends BaseService<YxWechatLive>{
/**
* 同步直播间
* @return
*/
boolean synchroWxOlLive();
/**
* 查询数据分页
* @param criteria 条件
* @param pageable 分页参数
* @return Map<String,Object>
*/
WechatLiveVo queryAll(YxWechatLiveQueryCriteria criteria, Pageable pageable);
/**
* 查询所有数据不分页
* @param criteria 条件参数
* @return List<YxWechatLiveDto>
*/
List<YxWechatLive> queryAll(YxWechatLiveQueryCriteria criteria);
boolean saveLive(YxWechatLive resources);
/**
* 导出数据
* @param all 待导出的数据
* @param response /
* @throws IOException /
*/
void download(List<YxWechatLiveDto> all, HttpServletResponse response) throws IOException;
/**
* 获取直播回放
* @param roomId
* @return
*/
List<WxMaLiveResult.LiveReplay> getLiveReplay(Integer roomId);
}

View File

@ -1,49 +0,0 @@
/**
* Copyright (C) 2018-2020
* All rights reserved, Designed By www.yixiang.co
*/
package co.yixiang.modules.wechat.service;
import co.yixiang.common.service.BaseService;
import co.yixiang.modules.wechat.domain.YxWechatMenu;
import co.yixiang.modules.wechat.service.dto.YxWechatMenuDto;
import co.yixiang.modules.wechat.service.dto.YxWechatMenuQueryCriteria;
import org.springframework.data.domain.Pageable;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
import java.util.Map;
/**
* @author hupeng
* @date 2020-05-12
*/
public interface YxWechatMenuService extends BaseService<YxWechatMenu>{
/**
* 查询数据分页
* @param criteria 条件
* @param pageable 分页参数
* @return Map<String,Object>
*/
Map<String,Object> queryAll(YxWechatMenuQueryCriteria criteria, Pageable pageable);
/**
* 查询所有数据不分页
* @param criteria 条件参数
* @return List<YxWechatMenuDto>
*/
List<YxWechatMenu> queryAll(YxWechatMenuQueryCriteria criteria);
/**
* 导出数据
* @param all 待导出的数据
* @param response /
* @throws IOException /
*/
void download(List<YxWechatMenuDto> all, HttpServletResponse response) throws IOException;
Boolean isExist(String wechat_menus);
}

View File

@ -1,53 +0,0 @@
/**
* Copyright (C) 2018-2020
* All rights reserved, Designed By www.yixiang.co
*/
package co.yixiang.modules.wechat.service;
import co.yixiang.common.service.BaseService;
import co.yixiang.modules.wechat.domain.YxWechatReply;
import co.yixiang.modules.wechat.service.dto.YxWechatReplyDto;
import co.yixiang.modules.wechat.service.dto.YxWechatReplyQueryCriteria;
import org.springframework.data.domain.Pageable;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
import java.util.Map;
/**
* @author hupeng
* @date 2020-05-12
*/
public interface YxWechatReplyService extends BaseService<YxWechatReply>{
/**
* 查询数据分页
* @param criteria 条件
* @param pageable 分页参数
* @return Map<String,Object>
*/
Map<String,Object> queryAll(YxWechatReplyQueryCriteria criteria, Pageable pageable);
/**
* 查询所有数据不分页
* @param criteria 条件参数
* @return List<YxWechatReplyDto>
*/
List<YxWechatReply> queryAll(YxWechatReplyQueryCriteria criteria);
/**
* 导出数据
* @param all 待导出的数据
* @param response /
* @throws IOException /
*/
void download(List<YxWechatReplyDto> all, HttpServletResponse response) throws IOException;
YxWechatReply isExist(String subscribe);
void create(YxWechatReply yxWechatReply);
void upDate(YxWechatReply yxWechatReply);
}

View File

@ -1,49 +0,0 @@
/**
* Copyright (C) 2018-2020
* All rights reserved, Designed By www.yixiang.co
*/
package co.yixiang.modules.wechat.service;
import co.yixiang.common.service.BaseService;
import co.yixiang.modules.wechat.domain.YxWechatTemplate;
import co.yixiang.modules.wechat.service.dto.YxWechatTemplateDto;
import co.yixiang.modules.wechat.service.dto.YxWechatTemplateQueryCriteria;
import org.springframework.data.domain.Pageable;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
import java.util.Map;
/**
* @author hupeng
* @date 2020-05-12
*/
public interface YxWechatTemplateService extends BaseService<YxWechatTemplate>{
/**
* 查询数据分页
* @param criteria 条件
* @param pageable 分页参数
* @return Map<String,Object>
*/
Map<String,Object> queryAll(YxWechatTemplateQueryCriteria criteria, Pageable pageable);
/**
* 查询所有数据不分页
* @param criteria 条件参数
* @return List<YxWechatTemplateDto>
*/
List<YxWechatTemplate> queryAll(YxWechatTemplateQueryCriteria criteria);
/**
* 导出数据
* @param all 待导出的数据
* @param response /
* @throws IOException /
*/
void download(List<YxWechatTemplateDto> all, HttpServletResponse response) throws IOException;
YxWechatTemplate findByTempkey(String recharge_success_key);
}

View File

@ -1,82 +0,0 @@
/**
* Copyright (C) 2018-2020
* All rights reserved, Designed By www.yixiang.co
*/
package co.yixiang.modules.wechat.service.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* @author hupeng
* @date 2020-05-12
*/
@Data
public class YxArticleDto implements Serializable {
/** 文章管理ID */
private Integer id;
/** 分类id */
private String cid;
/** 文章标题 */
private String title;
/** 文章作者 */
private String author;
/** 文章图片 */
private String imageInput;
/** 文章简介 */
private String synopsis;
private String content;
/** 文章分享标题 */
private String shareTitle;
/** 文章分享简介 */
private String shareSynopsis;
/** 浏览次数 */
private String visit;
/** 排序 */
private Integer sort;
/** 原文链接 */
private String url;
/** 状态 */
private Integer status;
/** 添加时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
private Date createTime;
/** 是否隐藏 */
private Integer hide;
/** 管理员id */
private Integer adminId;
/** 商户id */
private Integer merId;
/** 产品关联id */
private Integer productId;
/** 是否热门(小程序) */
private Integer isHot;
/** 是否轮播图(小程序) */
private Integer isBanner;
private String thumbMediaId;
}

View File

@ -1,16 +0,0 @@
/**
* Copyright (C) 2018-2020
* All rights reserved, Designed By www.yixiang.co
*/
package co.yixiang.modules.wechat.service.dto;
import lombok.Data;
/**
* @author hupeng
* @date 2020-05-12
*/
@Data
public class YxArticleQueryCriteria{
}

View File

@ -1,97 +0,0 @@
/**
* Copyright (C) 2018-2020
* All rights reserved, Designed By www.yixiang.co
* 注意:
* 本软件为www.yixiang.co开发研制未经购买不得使用
* 购买后可获得全部源代码禁止转卖、分享、上传到码云、github等开源平台
* 一经发现盗用、分享等行为,将追究法律责任,后果自负
*/
package co.yixiang.modules.wechat.service.dto;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* @author hupeng
* @date 2020-08-10
*/
@Data
public class YxWechatLiveDto implements Serializable {
/** 直播间id */
/** 防止精度丢失 */
@JsonSerialize(using= ToStringSerializer.class)
@ApiModelProperty(value = "直播间id")
private Long roomId;
private Long id;
/** 直播间标题 */
@ApiModelProperty(value = "直播间标题")
private String name;
/** 背景图 */
@ApiModelProperty(value = "背景图")
private String coverImge;
/** 分享图片 */
@ApiModelProperty(value = "分享图片")
private String shareImge;
/** 直播间状态 */
@ApiModelProperty(value = "直播间状态 101直播中102未开始103 已结束104 禁播105暂停106异常107已过期")
private Integer liveStatus;
/** 开始时间 */
@ApiModelProperty(value = "开始时间")
private Long startTime;
/** 预计结束时间 */
@ApiModelProperty(value = "预计结束时间")
private Long endTime;
/** 主播昵称 */
@ApiModelProperty(value = "主播昵称")
private String anchorName;
/** 主播微信号 */
@ApiModelProperty(value = "主播微信号")
private String anchorWechat;
/** 主播头像 */
@ApiModelProperty(value = "主播头像")
private String anchorImge;
/** 直播间类型 1推流 0手机直播 */
@ApiModelProperty(value = "直播间类型 1推流 0手机直播")
private Integer type;
/** 横屏、竖屏 【1横屏0竖屏】 */
@ApiModelProperty(value = "横屏、竖屏 【1横屏0竖屏】")
private Integer screenType;
/** 是否关闭点赞 【0开启1关闭】 */
@ApiModelProperty(value = "是否关闭点赞 【0开启1关闭】")
private Integer closeLike;
/** 是否关闭评论 【0开启1关闭】 */
@ApiModelProperty(value = "是否关闭评论 【0开启1关闭】")
private Integer closeComment;
/** 是否关闭货架 【0开启1关闭】 */
@ApiModelProperty(value = "是否关闭货架 【0开启1关闭】")
private Integer closeGoods;
/**
* 关联商品id多个隔开
*/
private String productId;
private List<YxWechatLiveGoodsDto> product;
}

View File

@ -1,59 +0,0 @@
/**
* Copyright (C) 2018-2020
* All rights reserved, Designed By www.yixiang.co
* 注意:
* 本软件为www.yixiang.co开发研制未经购买不得使用
* 购买后可获得全部源代码禁止转卖、分享、上传到码云、github等开源平台
* 一经发现盗用、分享等行为,将追究法律责任,后果自负
*/
package co.yixiang.modules.wechat.service.dto;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.Data;
import java.io.Serializable;
/**
* @author hupeng
* @date 2020-08-11
*/
@Data
public class YxWechatLiveGoodsDto implements Serializable {
private Long id;
/** 直播商品id */
/** 防止精度丢失 */
@JsonSerialize(using= ToStringSerializer.class)
private Long goodsId;
/** 关联商品id */
private Long productId;
/** 商品图片 */
private String coverImgeUrl;
/** 商品小程序路径 */
private String url;
/** 价格类型 1一口价只需要传入priceprice2不传 2价格区间price字段为左边界price2字段为右边界price和price2必传 3显示折扣价price字段为原价price2字段为现价 price和price2必传 */
private String priceType;
private String price;
private String price2;
/** 商品名称 */
private String name;
/** 1, 2表示是为api添加商品否则是直播控制台添加的商品 */
private String thirdPartyTag;
/** 审核单id */
private Long auditId;
/** 审核状态 0未审核1审核中2:审核通过3审核失败 */
private Integer auditStatus;
}

View File

@ -1,24 +0,0 @@
/**
* Copyright (C) 2018-2020
* All rights reserved, Designed By www.yixiang.co
* 注意:
* 本软件为www.yixiang.co开发研制未经购买不得使用
* 购买后可获得全部源代码禁止转卖、分享、上传到码云、github等开源平台
* 一经发现盗用、分享等行为,将追究法律责任,后果自负
*/
package co.yixiang.modules.wechat.service.dto;
import co.yixiang.annotation.Query;
import lombok.Data;
/**
* @author hupeng
* @date 2020-08-11
*/
@Data
public class YxWechatLiveGoodsQueryCriteria{
/** 模糊 */
@Query(type = Query.Type.INNER_LIKE)
private String name;
}

View File

@ -1,19 +0,0 @@
/**
* Copyright (C) 2018-2020
* All rights reserved, Designed By www.yixiang.co
* 注意:
* 本软件为www.yixiang.co开发研制未经购买不得使用
* 购买后可获得全部源代码禁止转卖、分享、上传到码云、github等开源平台
* 一经发现盗用、分享等行为,将追究法律责任,后果自负
*/
package co.yixiang.modules.wechat.service.dto;
import lombok.Data;
/**
* @author hupeng
* @date 2020-08-10
*/
@Data
public class YxWechatLiveQueryCriteria{
}

View File

@ -1,26 +0,0 @@
/**
* Copyright (C) 2018-2020
* All rights reserved, Designed By www.yixiang.co
*/
package co.yixiang.modules.wechat.service.dto;
import lombok.Data;
import java.io.Serializable;
/**
* @author hupeng
* @date 2020-05-12
*/
@Data
public class YxWechatMenuDto implements Serializable {
private String key;
/** 缓存数据 */
private String result;
/** 缓存时间 */
private Integer addTime;
}

View File

@ -1,16 +0,0 @@
/**
* Copyright (C) 2018-2020
* All rights reserved, Designed By www.yixiang.co
*/
package co.yixiang.modules.wechat.service.dto;
import lombok.Data;
/**
* @author hupeng
* @date 2020-05-12
*/
@Data
public class YxWechatMenuQueryCriteria{
}

View File

@ -1,36 +0,0 @@
/**
* Copyright (C) 2018-2020
* All rights reserved, Designed By www.yixiang.co
*/
package co.yixiang.modules.wechat.service.dto;
import lombok.Data;
import java.io.Serializable;
/**
* @author hupeng
* @date 2020-05-12
*/
@Data
public class YxWechatReplyDto implements Serializable {
/** 微信关键字回复id */
private Integer id;
/** 关键字 */
private String key;
/** 回复类型 */
private String type;
/** 回复数据 */
private String data;
/** 0=不可用 1 =可用 */
private Integer status;
/** 是否隐藏 */
private Integer hide;
}

View File

@ -1,16 +0,0 @@
/**
* Copyright (C) 2018-2020
* All rights reserved, Designed By www.yixiang.co
*/
package co.yixiang.modules.wechat.service.dto;
import lombok.Data;
/**
* @author hupeng
* @date 2020-05-12
*/
@Data
public class YxWechatReplyQueryCriteria{
}

View File

@ -1,41 +0,0 @@
/**
* Copyright (C) 2018-2020
* All rights reserved, Designed By www.yixiang.co
*/
package co.yixiang.modules.wechat.service.dto;
import lombok.Data;
import java.io.Serializable;
/**
* @author hupeng
* @date 2020-05-12
*/
@Data
public class YxWechatTemplateDto implements Serializable {
/** 模板id */
private Integer id;
/** 模板编号 */
private String tempkey;
/** 模板名 */
private String name;
/** 回复内容 */
private String content;
/** 模板ID */
private String tempid;
/** 添加时间 */
private String addTime;
/** 状态 */
private Integer status;
/** 类型template:模板消息 subscribe:订阅消息 */
private String type;
}

View File

@ -1,16 +0,0 @@
/**
* Copyright (C) 2018-2020
* All rights reserved, Designed By www.yixiang.co
*/
package co.yixiang.modules.wechat.service.dto;
import lombok.Data;
/**
* @author hupeng
* @date 2020-05-12
*/
@Data
public class YxWechatTemplateQueryCriteria{
}

View File

@ -1,142 +0,0 @@
/**
* Copyright (C) 2018-2020
* All rights reserved, Designed By www.yixiang.co
* 注意:
* 本软件为www.yixiang.co开发研制未经购买不得使用
* 购买后可获得全部源代码禁止转卖、分享、上传到码云、github等开源平台
* 一经发现盗用、分享等行为,将追究法律责任,后果自负
*/
package co.yixiang.modules.wechat.service.impl;
import co.yixiang.common.service.impl.BaseServiceImpl;
import co.yixiang.common.utils.QueryHelpPlus;
import co.yixiang.dozer.service.IGenerator;
import co.yixiang.modules.wechat.domain.YxArticle;
import co.yixiang.modules.wechat.service.YxArticleService;
import co.yixiang.modules.wechat.service.dto.YxArticleDto;
import co.yixiang.modules.wechat.service.dto.YxArticleQueryCriteria;
import co.yixiang.modules.wechat.service.mapper.ArticleMapper;
import co.yixiang.modules.wechat.vo.YxArticleQueryVo;
import co.yixiang.utils.FileUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
/**
* @author hupeng
* @date 2020-05-12
*/
@Slf4j
@Service
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
public class YxArticleServiceImpl extends BaseServiceImpl<ArticleMapper, YxArticle> implements YxArticleService {
private final IGenerator generator;
private final ArticleMapper articleMapper;
@Value("${file.path}")
private String uploadDirStr;
public YxArticleServiceImpl(IGenerator generator,ArticleMapper articleMapper) {
this.generator = generator;
this.articleMapper = articleMapper;
}
/**
* 获取文章列表
* @param page 页码
* @param limit 条数
* @return List
*/
@Override
public List<YxArticleQueryVo> getList(int page, int limit){
Page<YxArticle> pageModel = new Page<>(page, limit);
IPage<YxArticle> pageList = articleMapper.selectPage(pageModel, Wrappers.<YxArticle>lambdaQuery()
.orderByDesc(YxArticle::getId));
return generator.convert(pageList.getRecords(),YxArticleQueryVo.class);
}
/**
* 获取文章详情
* @param id id
* @return YxArticleQueryVo
*/
@Override
public YxArticleQueryVo getDetail(int id){
return generator.convert(this.getById(id),YxArticleQueryVo.class);
}
@Override
public void incVisitNum(int id) {
articleMapper.incVisitNum(id);
}
@Override
//@Cacheable
public Map<String, Object> queryAll(YxArticleQueryCriteria criteria, Pageable pageable) {
getPage(pageable);
PageInfo<YxArticle> page = new PageInfo<>(queryAll(criteria));
Map<String, Object> map = new LinkedHashMap<>(2);
map.put("content", generator.convert(page.getList(), YxArticleDto.class));
map.put("totalElements", page.getTotal());
return map;
}
@Override
//@Cacheable
public List<YxArticle> queryAll(YxArticleQueryCriteria criteria){
return baseMapper.selectList(QueryHelpPlus.getPredicate(YxArticle.class, criteria));
}
@Override
public void download(List<YxArticleDto> all, HttpServletResponse response) throws IOException {
List<Map<String, Object>> list = new ArrayList<>();
for (YxArticleDto yxArticle : all) {
Map<String,Object> map = new LinkedHashMap<>();
map.put("分类id", yxArticle.getCid());
map.put("文章标题", yxArticle.getTitle());
map.put("文章作者", yxArticle.getAuthor());
map.put("文章图片", yxArticle.getImageInput());
map.put("文章简介", yxArticle.getSynopsis());
map.put(" content", yxArticle.getContent());
map.put("文章分享标题", yxArticle.getShareTitle());
map.put("文章分享简介", yxArticle.getShareSynopsis());
map.put("浏览次数", yxArticle.getVisit());
map.put("排序", yxArticle.getSort());
map.put("原文链接", yxArticle.getUrl());
map.put("状态", yxArticle.getStatus());
map.put("是否隐藏", yxArticle.getHide());
map.put("管理员id", yxArticle.getAdminId());
map.put("商户id", yxArticle.getMerId());
map.put("产品关联id", yxArticle.getProductId());
map.put("是否热门(小程序)", yxArticle.getIsHot());
map.put("是否轮播图(小程序)", yxArticle.getIsBanner());
list.add(map);
}
FileUtil.downloadExcel(list, response);
}
}

View File

@ -1,219 +0,0 @@
/**
* Copyright (C) 2018-2020
* All rights reserved, Designed By www.yixiang.co
* 注意:
* 本软件为www.yixiang.co开发研制未经购买不得使用
* 购买后可获得全部源代码禁止转卖、分享、上传到码云、github等开源平台
* 一经发现盗用、分享等行为,将追究法律责任,后果自负
*/
package co.yixiang.modules.wechat.service.impl;
import cn.binarywang.wx.miniapp.api.WxMaService;
import cn.binarywang.wx.miniapp.bean.WxMaLiveInfo;
import cn.binarywang.wx.miniapp.bean.WxMaLiveResult;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONUtil;
import co.yixiang.common.service.impl.BaseServiceImpl;
import co.yixiang.common.utils.QueryHelpPlus;
import co.yixiang.dozer.service.IGenerator;
import co.yixiang.enums.LiveGoodsEnum;
import co.yixiang.exception.BadRequestException;
import co.yixiang.modules.wechat.domain.YxWechatLiveGoods;
import co.yixiang.modules.wechat.service.YxWechatLiveGoodsService;
import co.yixiang.modules.wechat.service.dto.YxWechatLiveGoodsDto;
import co.yixiang.modules.wechat.service.dto.YxWechatLiveGoodsQueryCriteria;
import co.yixiang.modules.wechat.service.mapper.YxWechatLiveGoodsMapper;
import co.yixiang.tools.config.WxMaConfiguration;
import co.yixiang.utils.FileUtil;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.api.WxConsts;
import me.chanjar.weixin.common.bean.result.WxMediaUploadResult;
import me.chanjar.weixin.common.error.WxErrorException;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
/**
* @author hupeng
* @date 2020-08-11
*/
@Slf4j
@Service
//@CacheConfig(cacheNames = "yxWechatLiveGoods")
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = Exception.class)
public class YxWechatLiveGoodsServiceImpl extends BaseServiceImpl<YxWechatLiveGoodsMapper, YxWechatLiveGoods> implements YxWechatLiveGoodsService {
private final IGenerator generator;
@Value("${file.path}")
private String uploadDirStr;
public YxWechatLiveGoodsServiceImpl(IGenerator generator) {
this.generator = generator;
}
/**
* 同步商品更新审核状态
* @return
*/
//@Cacheable
@Override
public boolean synchroWxOlLive(List<Integer> goodsIds) {
try {
WxMaService wxMaService = WxMaConfiguration.getWxMaService();
WxMaLiveResult liveInfos = wxMaService.getLiveGoodsService().getGoodsWareHouse(goodsIds);
List<YxWechatLiveGoods> convert = generator.convert(liveInfos.getGoods(), YxWechatLiveGoods.class);
this.saveOrUpdateBatch(convert);
} catch (WxErrorException e) {
e.printStackTrace();
}
return true;
}
@Override
public void removeGoods(Long id) {
this.removeById(id);
try {
WxMaService wxMaService = WxMaConfiguration.getWxMaService();
wxMaService.getLiveGoodsService().deleteGoods(id.intValue());
} catch (WxErrorException e) {
e.printStackTrace();
}
}
/**
* 更新直播商品信息
* @param resources
*/
@Override
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(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(LiveGoodsEnum.IS_Audit_1.getValue().equals(wechatLiveGoods.getAuditStatus())){
throw new BadRequestException("商品审核中不允许修改");
}
}
WxMaLiveInfo.Goods goods = generator.convert(resources, WxMaLiveInfo.Goods.class);
boolean wxMaLiveResult = wxMaService.getLiveGoodsService().updateGoods(goods);
this.saveOrUpdate(resources);
} catch (WxErrorException e) {
throw new BadRequestException(e.toString());
}
}
/**
* 查询数据分页
* @param criteria 条件
* @param pageable 分页参数
* @return Map<String,Object>
*/
@Override
//@Cacheable
public Map<String, Object> queryAll(YxWechatLiveGoodsQueryCriteria criteria, Pageable pageable) {
getPage(pageable);
PageInfo<YxWechatLiveGoods> page = new PageInfo<>(queryAll(criteria));
Map<String, Object> map = new LinkedHashMap<>(2);
List<YxWechatLiveGoodsDto> goodsDtos = generator.convert(page.getList(), YxWechatLiveGoodsDto.class);
goodsDtos.forEach(i ->{
i.setId(i.getGoodsId());
});
map.put("content",goodsDtos);
map.put("totalElements", page.getTotal());
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<>();
for (YxWechatLiveGoodsDto yxWechatLiveGoods : all) {
Map<String,Object> map = new LinkedHashMap<>();
map.put("关联商品id", yxWechatLiveGoods.getProductId());
map.put("商品图片", yxWechatLiveGoods.getCoverImgeUrl());
map.put("商品小程序路径", yxWechatLiveGoods.getUrl());
map.put("价格类型 1一口价只需要传入priceprice2不传 2价格区间price字段为左边界price2字段为右边界price和price2必传 3显示折扣价price字段为原价price2字段为现价 price和price2必传", yxWechatLiveGoods.getPriceType());
map.put(" price", yxWechatLiveGoods.getPrice());
map.put(" price2", yxWechatLiveGoods.getPrice2());
map.put("商品名称", yxWechatLiveGoods.getName());
map.put("1, 2表示是为api添加商品否则是直播控制台添加的商品", yxWechatLiveGoods.getThirdPartyTag());
map.put("审核单id", yxWechatLiveGoods.getAuditId());
map.put("审核状态 0未审核1审核中2:审核通过3审核失败", yxWechatLiveGoods.getAuditStatus());
list.add(map);
}
FileUtil.downloadExcel(list, response);
}
/**
* 保存直播商品信息
* @param resources
* @return
*/
@Override
public boolean saveGoods(YxWechatLiveGoods resources) {
WxMaService wxMaService = WxMaConfiguration.getWxMaService();
try {
resources.setCoverImgUrl(uploadPhotoToWx(wxMaService,resources.getCoverImgeUrl()).getMediaId());
WxMaLiveInfo.Goods goods = generator.convert(resources, WxMaLiveInfo.Goods.class);
WxMaLiveResult wxMaLiveResult = wxMaService.getLiveGoodsService().addGoods(goods);
resources.setGoodsId(Long.valueOf(wxMaLiveResult.getGoodsId()));
resources.setAuditId(Long.valueOf(wxMaLiveResult.getAuditId()));
this.save(resources);
} catch (WxErrorException e) {
throw new BadRequestException(e.toString());
}
return true;
}
/**
* 上传临时素材
* @param wxMaService WxMaService
* @param picPath 图片路径
* @return WxMpMaterialUploadResult
* @throws WxErrorException
*/
private WxMediaUploadResult uploadPhotoToWx(WxMaService wxMaService, String picPath) throws WxErrorException {
String filename = (int) System.currentTimeMillis() + ".png";
String downloadPath = uploadDirStr + filename;
long size = HttpUtil.downloadFile(picPath, cn.hutool.core.io.FileUtil.file(downloadPath));
picPath = downloadPath;
File picFile = new File( picPath );
log.info( "picFile name : {}", picFile.getName() );
WxMediaUploadResult wxMediaUploadResult = wxMaService.getMediaService().uploadMedia( WxConsts.MediaFileType.IMAGE, picFile );
log.info( "wxMpMaterialUploadResult : {}", JSONUtil.toJsonStr( wxMediaUploadResult ) );
return wxMediaUploadResult;
}
}

View File

@ -1,209 +0,0 @@
/**
* Copyright (C) 2018-2020
* All rights reserved, Designed By www.yixiang.co
* 注意:
* 本软件为www.yixiang.co开发研制未经购买不得使用
* 购买后可获得全部源代码禁止转卖、分享、上传到码云、github等开源平台
* 一经发现盗用、分享等行为,将追究法律责任,后果自负
*/
package co.yixiang.modules.wechat.service.impl;
import cn.binarywang.wx.miniapp.api.WxMaService;
import cn.binarywang.wx.miniapp.bean.WxMaLiveInfo;
import cn.binarywang.wx.miniapp.bean.WxMaLiveResult;
import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONUtil;
import co.yixiang.common.service.impl.BaseServiceImpl;
import co.yixiang.common.utils.QueryHelpPlus;
import co.yixiang.dozer.service.IGenerator;
import co.yixiang.exception.BadRequestException;
import co.yixiang.modules.wechat.domain.YxWechatLive;
import co.yixiang.modules.wechat.domain.YxWechatLiveGoods;
import co.yixiang.modules.wechat.service.YxWechatLiveGoodsService;
import co.yixiang.modules.wechat.service.YxWechatLiveService;
import co.yixiang.modules.wechat.service.dto.YxWechatLiveDto;
import co.yixiang.modules.wechat.service.dto.YxWechatLiveGoodsDto;
import co.yixiang.modules.wechat.service.dto.YxWechatLiveQueryCriteria;
import co.yixiang.modules.wechat.service.mapper.YxWechatLiveMapper;
import co.yixiang.modules.wechat.vo.WechatLiveVo;
import co.yixiang.tools.config.WxMaConfiguration;
import co.yixiang.utils.FileUtil;
import co.yixiang.utils.OrderUtil;
import co.yixiang.utils.StringUtils;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.api.WxConsts;
import me.chanjar.weixin.common.bean.result.WxMediaUploadResult;
import me.chanjar.weixin.common.error.WxErrorException;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
/**
* @author hupeng
* @date 2020-08-10
*/
@Service
//@CacheConfig(cacheNames = "yxWechatLive")
@Slf4j
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = Exception.class)
public class YxWechatLiveServiceImpl extends BaseServiceImpl<YxWechatLiveMapper, YxWechatLive> implements YxWechatLiveService {
private final IGenerator generator;
@Value("${file.path}")
private String uploadDirStr;
private final YxWechatLiveGoodsService wechatLiveGoodsService;
public YxWechatLiveServiceImpl(IGenerator generator, YxWechatLiveGoodsService wechatLiveGoodsService) {
this.generator = generator;
this.wechatLiveGoodsService = wechatLiveGoodsService;
}
/**
* 同步直播间
* @return
*/
//@Cacheable
@Override
public boolean synchroWxOlLive() {
try {
WxMaService wxMaService = WxMaConfiguration.getWxMaService();
List<WxMaLiveResult.RoomInfo> liveInfos = wxMaService.getLiveService().getLiveInfos();
List<YxWechatLive> convert = generator.convert(liveInfos, YxWechatLive.class);
this.saveOrUpdateBatch(convert);
} catch (WxErrorException e) {
e.printStackTrace();
}
return true;
}
@Override
//@Cacheable
public WechatLiveVo queryAll(YxWechatLiveQueryCriteria criteria, Pageable pageable) {
String order=null;
if(pageable.getSort()!=null){
order= pageable.getSort().toString();
order=order.replace(":","");
if("UNSORTED".equals(order)){
order="start_time desc";
}
}
PageHelper.startPage(pageable.getPageNumber()+1, pageable.getPageSize(),order);
PageInfo<YxWechatLive> page = new PageInfo<>(queryAll(criteria));
WechatLiveVo wechatLiveVo = new WechatLiveVo();
// 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());
});
wechatLiveVo.setContent(liveDtos);
wechatLiveVo.setTotalElements(page.getTotal());
return wechatLiveVo;
}
@Override
public boolean saveLive(YxWechatLive resources){
WxMaService wxMaService = WxMaConfiguration.getWxMaService();
try {
resources.setStartTime(Long.valueOf(OrderUtil.dateToTimestamp(resources.getStartDate())));
resources.setEndTime(Long.valueOf(OrderUtil.dateToTimestamp(resources.getEndDate())));
resources.setAnchorImg(uploadPhotoToWx(wxMaService,resources.getAnchorImge()).getMediaId());
resources.setCoverImg(uploadPhotoToWx(wxMaService,resources.getCoverImge()).getMediaId());
resources.setShareImg(uploadPhotoToWx(wxMaService,resources.getShareImge()).getMediaId());
WxMaLiveInfo.RoomInfo roomInfo = generator.convert(resources, WxMaLiveInfo.RoomInfo.class);
Integer status = wxMaService.getLiveService().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));
}
//添加商品
wxMaService.getLiveService().addGoodsToRoom(status, pids);
}
this.save(resources);
} catch (WxErrorException e) {
e.printStackTrace();
throw new BadRequestException(e.toString());
}
return false;
}
@Override
//@Cacheable
public List<YxWechatLive> queryAll(YxWechatLiveQueryCriteria criteria){
return baseMapper.selectList(QueryHelpPlus.getPredicate(YxWechatLive.class, criteria));
}
@Override
//@Cacheable
public List<WxMaLiveResult.LiveReplay> getLiveReplay(Integer roomId){
WxMaService wxMaService = WxMaConfiguration.getWxMaService();
WxMaLiveResult get_replay = new WxMaLiveResult();
try {
get_replay = wxMaService.getLiveService().getLiveReplay("get_replay", roomId, 0, 100);
} catch (WxErrorException e) {
e.printStackTrace();
}
return get_replay.getLiveReplay();
}
@Override
public void download(List<YxWechatLiveDto> all, HttpServletResponse response) throws IOException {
List<Map<String, Object>> list = new ArrayList<>();
for (YxWechatLiveDto yxWechatLive : all) {
Map<String,Object> map = new LinkedHashMap<>();
map.put("直播间标题", yxWechatLive.getName());
map.put("背景图", yxWechatLive.getCoverImge());
map.put("分享图片", yxWechatLive.getShareImge());
map.put("直播间状态", yxWechatLive.getLiveStatus());
map.put("开始时间", yxWechatLive.getStartTime());
map.put("预计结束时间", yxWechatLive.getEndTime());
map.put("主播昵称", yxWechatLive.getAnchorName());
map.put("主播微信号", yxWechatLive.getAnchorWechat());
map.put("主播头像", yxWechatLive.getAnchorImge());
map.put("直播间类型 1推流 0手机直播", yxWechatLive.getType());
map.put("横屏、竖屏 【1横屏0竖屏】", yxWechatLive.getScreenType());
map.put("是否关闭货架 【0开启1关闭】", yxWechatLive.getCloseLike());
map.put("是否关闭评论 【0开启1关闭】", yxWechatLive.getCloseComment());
list.add(map);
}
FileUtil.downloadExcel(list, response);
}
/**
* 上传临时素材
* @param wxMaService WxMaService
* @param picPath 图片路径
* @return WxMpMaterialUploadResult
* @throws WxErrorException
*/
private WxMediaUploadResult uploadPhotoToWx(WxMaService wxMaService, String picPath) throws WxErrorException {
String filename = (int) System.currentTimeMillis() + ".png";
String downloadPath = uploadDirStr + filename;
long size = HttpUtil.downloadFile(picPath, cn.hutool.core.io.FileUtil.file(downloadPath));
picPath = downloadPath;
File picFile = new File( picPath );
log.info( "picFile name : {}", picFile.getName() );
WxMediaUploadResult wxMediaUploadResult = wxMaService.getMediaService().uploadMedia( WxConsts.MediaFileType.IMAGE, picFile );
log.info( "wxMpMaterialUploadResult : {}", JSONUtil.toJsonStr( wxMediaUploadResult ) );
return wxMediaUploadResult;
}
}

View File

@ -1,89 +0,0 @@
/**
* Copyright (C) 2018-2020
* All rights reserved, Designed By www.yixiang.co
*/
package co.yixiang.modules.wechat.service.impl;
import co.yixiang.common.service.impl.BaseServiceImpl;
import co.yixiang.common.utils.QueryHelpPlus;
import co.yixiang.dozer.service.IGenerator;
import co.yixiang.modules.wechat.domain.YxWechatMenu;
import co.yixiang.modules.wechat.service.YxWechatMenuService;
import co.yixiang.modules.wechat.service.dto.YxWechatMenuDto;
import co.yixiang.modules.wechat.service.dto.YxWechatMenuQueryCriteria;
import co.yixiang.modules.wechat.service.mapper.WechatMenuMapper;
import co.yixiang.utils.FileUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageInfo;
import lombok.AllArgsConstructor;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
// 默认不使用缓存
//import org.springframework.cache.annotation.CacheConfig;
//import org.springframework.cache.annotation.CacheEvict;
//import org.springframework.cache.annotation.Cacheable;
/**
* @author hupeng
* @date 2020-05-12
*/
@Service
@AllArgsConstructor
//@CacheConfig(cacheNames = "yxWechatMenu")
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
public class YxWechatMenuServiceImpl extends BaseServiceImpl<WechatMenuMapper, YxWechatMenu> implements YxWechatMenuService {
private final IGenerator generator;
@Override
//@Cacheable
public Map<String, Object> queryAll(YxWechatMenuQueryCriteria criteria, Pageable pageable) {
getPage(pageable);
PageInfo<YxWechatMenu> page = new PageInfo<>(queryAll(criteria));
Map<String, Object> map = new LinkedHashMap<>(2);
map.put("content", generator.convert(page.getList(), YxWechatMenuDto.class));
map.put("totalElements", page.getTotal());
return map;
}
@Override
//@Cacheable
public List<YxWechatMenu> queryAll(YxWechatMenuQueryCriteria criteria){
return baseMapper.selectList(QueryHelpPlus.getPredicate(YxWechatMenu.class, criteria));
}
@Override
public void download(List<YxWechatMenuDto> all, HttpServletResponse response) throws IOException {
List<Map<String, Object>> list = new ArrayList<>();
for (YxWechatMenuDto yxWechatMenu : all) {
Map<String,Object> map = new LinkedHashMap<>();
map.put("缓存数据", yxWechatMenu.getResult());
map.put("缓存时间", yxWechatMenu.getAddTime());
list.add(map);
}
FileUtil.downloadExcel(list, response);
}
@Override
public Boolean isExist(String wechat_menus) {
YxWechatMenu yxWechatMenu = this.getOne(new QueryWrapper<YxWechatMenu>().lambda()
.eq(YxWechatMenu::getKey,wechat_menus));
if(yxWechatMenu == null){
return false;
}
return true;
}
}

View File

@ -1,110 +0,0 @@
/**
* Copyright (C) 2018-2020
* All rights reserved, Designed By www.yixiang.co
*/
package co.yixiang.modules.wechat.service.impl;
import co.yixiang.common.service.impl.BaseServiceImpl;
import co.yixiang.common.utils.QueryHelpPlus;
import co.yixiang.dozer.service.IGenerator;
import co.yixiang.exception.EntityExistException;
import co.yixiang.modules.wechat.domain.YxWechatReply;
import co.yixiang.modules.wechat.service.YxWechatReplyService;
import co.yixiang.modules.wechat.service.dto.YxWechatReplyDto;
import co.yixiang.modules.wechat.service.dto.YxWechatReplyQueryCriteria;
import co.yixiang.modules.wechat.service.mapper.WechatReplyMapper;
import co.yixiang.utils.FileUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageInfo;
import lombok.AllArgsConstructor;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
// 默认不使用缓存
//import org.springframework.cache.annotation.CacheConfig;
//import org.springframework.cache.annotation.CacheEvict;
//import org.springframework.cache.annotation.Cacheable;
/**
* @author hupeng
* @date 2020-05-12
*/
@Service
@AllArgsConstructor
//@CacheConfig(cacheNames = "yxWechatReply")
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
public class YxWechatReplyServiceImpl extends BaseServiceImpl<WechatReplyMapper, YxWechatReply> implements YxWechatReplyService {
private final IGenerator generator;
@Override
//@Cacheable
public Map<String, Object> queryAll(YxWechatReplyQueryCriteria criteria, Pageable pageable) {
getPage(pageable);
PageInfo<YxWechatReply> page = new PageInfo<>(queryAll(criteria));
Map<String, Object> map = new LinkedHashMap<>(2);
map.put("content", generator.convert(page.getList(), YxWechatReplyDto.class));
map.put("totalElements", page.getTotal());
return map;
}
@Override
//@Cacheable
public List<YxWechatReply> queryAll(YxWechatReplyQueryCriteria criteria){
return baseMapper.selectList(QueryHelpPlus.getPredicate(YxWechatReply.class, criteria));
}
@Override
public void download(List<YxWechatReplyDto> all, HttpServletResponse response) throws IOException {
List<Map<String, Object>> list = new ArrayList<>();
for (YxWechatReplyDto yxWechatReply : all) {
Map<String,Object> map = new LinkedHashMap<>();
map.put("关键字", yxWechatReply.getKey());
map.put("回复类型", yxWechatReply.getType());
map.put("回复数据", yxWechatReply.getData());
map.put("0=不可用 1 =可用", yxWechatReply.getStatus());
map.put("是否隐藏", yxWechatReply.getHide());
list.add(map);
}
FileUtil.downloadExcel(list, response);
}
@Override
public YxWechatReply isExist(String key) {
YxWechatReply yxWechatReply = this.getOne(new QueryWrapper<YxWechatReply>().lambda()
.eq(YxWechatReply::getKey,key));
return yxWechatReply;
}
@Override
public void create(YxWechatReply yxWechatReply) {
if(this.isExist(yxWechatReply.getKey()) != null){
throw new EntityExistException(YxWechatReply.class,"key",yxWechatReply.getKey());
}
this.save(yxWechatReply);
}
@Override
public void upDate(YxWechatReply resources) {
YxWechatReply yxWechatReply = this.getById(resources.getId());
YxWechatReply yxWechatReply1;
yxWechatReply1 = this.isExist(resources.getKey());
if(yxWechatReply1 != null && !yxWechatReply1.getId().equals(yxWechatReply.getId())){
throw new EntityExistException(YxWechatReply.class,"key",resources.getKey());
}
yxWechatReply.copy(resources);
this.saveOrUpdate(yxWechatReply);
}
}

View File

@ -1,89 +0,0 @@
/**
* Copyright (C) 2018-2020
* All rights reserved, Designed By www.yixiang.co
*/
package co.yixiang.modules.wechat.service.impl;
import co.yixiang.common.service.impl.BaseServiceImpl;
import co.yixiang.common.utils.QueryHelpPlus;
import co.yixiang.dozer.service.IGenerator;
import co.yixiang.modules.wechat.domain.YxWechatTemplate;
import co.yixiang.modules.wechat.service.YxWechatTemplateService;
import co.yixiang.modules.wechat.service.dto.YxWechatTemplateDto;
import co.yixiang.modules.wechat.service.dto.YxWechatTemplateQueryCriteria;
import co.yixiang.modules.wechat.service.mapper.WechatTemplateMapper;
import co.yixiang.utils.FileUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageInfo;
import lombok.AllArgsConstructor;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
// 默认不使用缓存
//import org.springframework.cache.annotation.CacheConfig;
//import org.springframework.cache.annotation.CacheEvict;
//import org.springframework.cache.annotation.Cacheable;
/**
* @author hupeng
* @date 2020-05-12
*/
@Service
@AllArgsConstructor
//@CacheConfig(cacheNames = "yxWechatTemplate")
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
public class YxWechatTemplateServiceImpl extends BaseServiceImpl<WechatTemplateMapper, YxWechatTemplate> implements YxWechatTemplateService {
private final IGenerator generator;
@Override
//@Cacheable
public Map<String, Object> queryAll(YxWechatTemplateQueryCriteria criteria, Pageable pageable) {
getPage(pageable);
PageInfo<YxWechatTemplate> page = new PageInfo<>(queryAll(criteria));
Map<String, Object> map = new LinkedHashMap<>(2);
map.put("content", generator.convert(page.getList(), YxWechatTemplateDto.class));
map.put("totalElements", page.getTotal());
return map;
}
@Override
//@Cacheable
public List<YxWechatTemplate> queryAll(YxWechatTemplateQueryCriteria criteria){
return baseMapper.selectList(QueryHelpPlus.getPredicate(YxWechatTemplate.class, criteria));
}
@Override
public void download(List<YxWechatTemplateDto> all, HttpServletResponse response) throws IOException {
List<Map<String, Object>> list = new ArrayList<>();
for (YxWechatTemplateDto yxWechatTemplate : all) {
Map<String,Object> map = new LinkedHashMap<>();
map.put("模板编号", yxWechatTemplate.getTempkey());
map.put("模板名", yxWechatTemplate.getName());
map.put("回复内容", yxWechatTemplate.getContent());
map.put("模板ID", yxWechatTemplate.getTempid());
map.put("添加时间", yxWechatTemplate.getAddTime());
map.put("状态", yxWechatTemplate.getStatus());
list.add(map);
}
FileUtil.downloadExcel(list, response);
}
@Override
public YxWechatTemplate findByTempkey(String recharge_success_key) {
return this.getOne(new QueryWrapper<YxWechatTemplate>().lambda()
.eq(YxWechatTemplate::getTempkey,recharge_success_key));
}
}

View File

@ -1,24 +0,0 @@
/**
* Copyright (C) 2018-2020
* All rights reserved, Designed By www.yixiang.co
*/
package co.yixiang.modules.wechat.service.mapper;
import co.yixiang.common.mapper.CoreMapper;
import co.yixiang.modules.wechat.domain.YxArticle;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;
/**
* @author hupeng
* @date 2020-05-12
*/
@Repository
public interface ArticleMapper extends CoreMapper<YxArticle> {
@Update("update yx_article set visit=visit+1 " +
"where id=#{id}")
int incVisitNum(@Param("id") int id);
}

View File

@ -1,19 +0,0 @@
/**
* Copyright (C) 2018-2020
* All rights reserved, Designed By www.yixiang.co
*/
package co.yixiang.modules.wechat.service.mapper;
import co.yixiang.common.mapper.CoreMapper;
import co.yixiang.modules.wechat.domain.YxWechatMenu;
import org.springframework.stereotype.Repository;
/**
* @author hupeng
* @date 2020-05-12
*/
@Repository
public interface WechatMenuMapper extends CoreMapper<YxWechatMenu> {
}

View File

@ -1,19 +0,0 @@
/**
* Copyright (C) 2018-2020
* All rights reserved, Designed By www.yixiang.co
*/
package co.yixiang.modules.wechat.service.mapper;
import co.yixiang.common.mapper.CoreMapper;
import co.yixiang.modules.wechat.domain.YxWechatReply;
import org.springframework.stereotype.Repository;
/**
* @author hupeng
* @date 2020-05-12
*/
@Repository
public interface WechatReplyMapper extends CoreMapper<YxWechatReply> {
}

View File

@ -1,19 +0,0 @@
/**
* Copyright (C) 2018-2020
* All rights reserved, Designed By www.yixiang.co
*/
package co.yixiang.modules.wechat.service.mapper;
import co.yixiang.common.mapper.CoreMapper;
import co.yixiang.modules.wechat.domain.YxWechatTemplate;
import org.springframework.stereotype.Repository;
/**
* @author hupeng
* @date 2020-05-12
*/
@Repository
public interface WechatTemplateMapper extends CoreMapper<YxWechatTemplate> {
}

View File

@ -1,22 +0,0 @@
/**
* Copyright (C) 2018-2020
* All rights reserved, Designed By www.yixiang.co
* 注意:
* 本软件为www.yixiang.co开发研制未经购买不得使用
* 购买后可获得全部源代码禁止转卖、分享、上传到码云、github等开源平台
* 一经发现盗用、分享等行为,将追究法律责任,后果自负
*/
package co.yixiang.modules.wechat.service.mapper;
import co.yixiang.common.mapper.CoreMapper;
import co.yixiang.modules.wechat.domain.YxWechatLiveGoods;
import org.springframework.stereotype.Repository;
/**
* @author hupeng
* @date 2020-08-11
*/
@Repository
public interface YxWechatLiveGoodsMapper extends CoreMapper<YxWechatLiveGoods> {
}

View File

@ -1,22 +0,0 @@
/**
* Copyright (C) 2018-2020
* All rights reserved, Designed By www.yixiang.co
* 注意:
* 本软件为www.yixiang.co开发研制未经购买不得使用
* 购买后可获得全部源代码禁止转卖、分享、上传到码云、github等开源平台
* 一经发现盗用、分享等行为,将追究法律责任,后果自负
*/
package co.yixiang.modules.wechat.service.mapper;
import co.yixiang.common.mapper.CoreMapper;
import co.yixiang.modules.wechat.domain.YxWechatLive;
import org.springframework.stereotype.Repository;
/**
* @author hupeng
* @date 2020-08-10
*/
@Repository
public interface YxWechatLiveMapper extends CoreMapper<YxWechatLive> {
}

View File

@ -1,14 +0,0 @@
package co.yixiang.modules.wechat.vo;
import co.yixiang.modules.wechat.service.dto.YxWechatLiveDto;
import lombok.Data;
import java.util.List;
@Data
public class WechatLiveVo {
private List<YxWechatLiveDto> content;
private Long totalElements;
}

View File

@ -1,65 +0,0 @@
package co.yixiang.modules.wechat.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* <p>
* 文章管理表 查询结果对象
* </p>
*
* @author hupeng
* @date 2019-10-02
*/
@Data
@ApiModel(value = "YxArticleQueryVo对象", description = "文章管理表查询参数")
public class YxArticleQueryVo implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "文章管理ID")
private Integer id;
@ApiModelProperty(value = "文章标题")
private String title;
@ApiModelProperty(value = "文章作者")
private String author;
@ApiModelProperty(value = "文章图片")
private String imageInput;
@ApiModelProperty(value = "文章简介")
private String synopsis;
@ApiModelProperty(value = "文章分享标题")
private String shareTitle;
@ApiModelProperty(value = "文章分享简介")
private String shareSynopsis;
@ApiModelProperty(value = "浏览次数")
private String visit;
@ApiModelProperty(value = "排序")
private Integer sort;
@ApiModelProperty(value = "原文链接")
private String url;
@ApiModelProperty(value = "状态")
private Boolean status;
@ApiModelProperty(value = "添加时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
@JsonProperty(value = "addTime")
private String createTime;
@ApiModelProperty(value = "文章内容")
private String content;
}