-- 新版提交

This commit is contained in:
yc13649764453
2023-09-09 13:51:35 +08:00
parent 763e24b4e0
commit 0b193caa03
92 changed files with 3451 additions and 1120 deletions

View File

@@ -1,5 +1,6 @@
package com.peanut;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

View File

@@ -317,6 +317,7 @@ public class KdApiEOrder {
params.put("RequestData", KdUtils.urlEncoder(RequestData, "UTF-8"));
params.put("EBusinessID", EBusinessID);
params.put("RequestType", "8008");//在途监控订阅接口指令8008/地图版订阅接口指令8005
// params.put("RequestType", "8005");//在途监控订阅接口指令8008/地图版订阅接口指令8005
String dataSign=KdUtils.encrypt(RequestData, ApiKey, "UTF-8");
params.put("DataSign", KdUtils.urlEncoder(dataSign, "UTF-8"));
params.put("DataType", "2");

View File

@@ -10,17 +10,23 @@ import java.util.UUID;
public class BaiduVoicesUtils {
// 填写申请百度语音申请的appkey 申请地址百度AI开放平台
private final static String appKey = "aKDun6vXyqPLhWMdoIsv87Ez";
//todo private final static String appKey = "aKDun6vXyqPLhWMdoIsv87Ez";
// private final static String appKey = "eaPPX40oIazH8R4oWsD9U4IT";
private final static String appKey = "xkyZMti9hu6KSQ8PdRDsadqI";
// 填写申请百度语音申请的APP SECRET
private final static String secretKey = "ew9dMb4yGmwF1g4qutxNvogzjd9eP5tb";
// todo private final static String secretKey = "ew9dMb4yGmwF1g4qutxNvogzjd9eP5tb";
// private final static String secretKey = "DTN0ioQywwM23IoT2ZzEBmvfBe63ATEY";
private final static String secretKey = "KQvdrrADpV7hBzptqvakwG56dYuGljeg";
// text 的内容为"欢迎使用百度语音合成"的urlencode,utf-8 编码
private final String text = "百度百科是百度公司推出的一部内容开放、自由的网络百科全书。";
// 发音人选择, 0为普通女声1为普通男生3为情感合成-度逍遥4为情感合成-度丫丫,默认为普通女声
private final static int per = 3;
// 基础 发音人选择, 0为普通女声1为普通男生3为情感合成-度逍遥4为情感合成-度丫丫,默认为普通女声
//度逍遥(精品)=5003度小鹿=5118度博文=106度小童=110度小萌=111度米朵=103度小娇=5
// private final static int per = 3;
private final static int per =3;
// 语速取值0-9默认为5中语速
private final static int spd = 5;
// 音调取值0-9默认为5中语调
@@ -36,7 +42,13 @@ public class BaiduVoicesUtils {
TokenHolder holder = new TokenHolder(appKey, secretKey, TokenHolder.ASR_SCOPE);
holder.resfresh();
String token = holder.getToken();
String token1 = holder.getToken();
final String s = ConnUtil.urlEncode(content);
String url21 = url +"?tex=" + s;
url21 +="&per="+ per;
url21 +=""+cuid;
url21 +=""+vol;
long expiresAt = holder.getExpiresAt();
// for (String a:list) {
String url2 = url + "?tex=" + ConnUtil.urlEncode(content);
url2 += "&per=" + per;

View File

@@ -220,7 +220,7 @@ public class MD5Utils {
}
public static void main(String[] args) {
MD5Utils md = new MD5Utils();
String strMD5 = new String("12345");
String strMD5 = new String("696c23c1e04f330c55a635f571ee949f");
System.out.println("原始:" + strMD5);
System.out.println("东东的:" + md.getStrrMD5(strMD5));

View File

@@ -27,6 +27,10 @@ public class Query<T> {
return this.getPage(params, null, false);
}
public IPage<T> getPage(Map<String, Object> params, String defaultOrderField, boolean isAsc) {
//分页参数
long curPage = 1;

View File

@@ -8,6 +8,8 @@
package com.peanut.common.utils;
import lombok.Data;
import lombok.experimental.Accessors;
import org.apache.http.HttpStatus;
import java.util.HashMap;
@@ -18,6 +20,8 @@ import java.util.Map;
*
* @author Mark sunlightcs@gmail.com
*/
@Data
//@Accessors(chain = true)
public class R extends HashMap<String, Object> {
private static final long serialVersionUID = 1L;
@@ -25,14 +29,44 @@ public class R extends HashMap<String, Object> {
put("code", 0);
put("msg", "success");
}
public static R error() {
return error(HttpStatus.SC_INTERNAL_SERVER_ERROR, "未知异常,请联系管理员");
// return error(HttpStatus.SC_INTERNAL_SERVER_ERROR, "未知异常,请联系管理员");
return error(HttpStatus.SC_INTERNAL_SERVER_ERROR, "");
}
public static R error(String msg) {
return error(HttpStatus.SC_INTERNAL_SERVER_ERROR, msg);
}
/**
* int SC_NOT_IMPLEMENTED = 501;
* int SC_BAD_GATEWAY = 502;
* int SC_SERVICE_UNAVAILABLE = 503;
* int SC_GATEWAY_TIMEOUT = 504;
* @param
* @param msg
* @return
*/
public static R error1(String msg) {
return error(HttpStatus.SC_NOT_IMPLEMENTED, msg);
}
public static R error2() {
return error(HttpStatus.SC_BAD_GATEWAY,"");
}
public static R error3(String msg) {
return error(HttpStatus.SC_SERVICE_UNAVAILABLE, msg);
}
public static R error4(String msg) {
return error(HttpStatus.SC_GATEWAY_TIMEOUT, msg);
}
public static R error(int code, String msg) {
R r = new R();

View File

@@ -54,6 +54,8 @@ public class ShiroConfig {
filterMap.put("/image/**","anon");
filterMap.put("/book/book/listForWebsite","anon"); // 网站接口
filterMap.put("/book/shopproduct/forWebList","anon"); // 网站接口
filterMap.put("forum/articles/desccreatelist","anon"); // 网站接口
filterMap.put("book/task/list","anon"); // 网站接口
filterMap.put("/pay/aliPay/notify","anon"); // 支付宝回调接口
filterMap.put("/pay/payNotify","anon"); // 微信回调接口
filterMap.put("/weChat/**","anon");
@@ -70,6 +72,10 @@ public class ShiroConfig {
filterMap.put("/captcha.jpg", "anon");
filterMap.put("/aaa.txt", "anon");
filterMap.put("/**", "oauth2");
filterMap.put("/cent/**","anon");
//todo 过滤 用户隐私协议未生效
// filterMap.put("sys/agreement/list","anon");
shiroFilter.setFilterChainDefinitionMap(filterMap);

View File

@@ -10,12 +10,8 @@ import java.util.concurrent.Executors;
import com.alibaba.druid.util.StringUtils;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.peanut.common.utils.BaiduVoicesUtils;
import com.peanut.modules.book.entity.BookChapterEntity;
import com.peanut.modules.book.entity.BookEntity;
import com.peanut.modules.book.entity.MyUserEntity;
import com.peanut.modules.book.service.BookChapterService;
import com.peanut.modules.book.service.BookService;
import com.peanut.modules.book.service.MyUserService;
import com.peanut.modules.book.entity.*;
import com.peanut.modules.book.service.*;
import com.peanut.modules.oss.service.OssService;
import lombok.SneakyThrows;
import org.apache.commons.io.IOUtils;
@@ -28,8 +24,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.peanut.modules.book.entity.BookChapterContentEntity;
import com.peanut.modules.book.service.BookChapterContentService;
import com.peanut.common.utils.PageUtils;
import com.peanut.common.utils.R;
import org.springframework.web.multipart.MultipartFile;
@@ -55,6 +49,8 @@ public class BookChapterContentController {
private BookChapterService bookChapterService;
@Autowired
private MyUserService myUserService;
@Autowired
private UserEbookBuyService userEbookBuyService;
/**
* 列表
@@ -124,14 +120,13 @@ public class BookChapterContentController {
singleThreadExecutor.execute(new Runnable() {
@Override
public void run() {
// bookChapterContentService.getBookVoices(id);
bookChapterContentService.getWordChapterParagraph(14);
bookChapterContentService.getWordChapterParagraph(id);
}
});
BookEntity bookEntity = bookService.getBaseMapper().selectById(id);
bookEntity.setContentStatus("1");
bookEntity.setContentStatus("2");
bookService.updateById(bookEntity);
return R.ok();
@@ -141,9 +136,8 @@ public class BookChapterContentController {
*/
@RequestMapping("/signVoices")
public R signVoices(@RequestParam("content") String content) throws Exception {
//调用百度语音合成 API
String voices = BaiduVoicesUtils.run(content);
File file = new File(voices);
if (!file.exists()) {
return R.error("语音文件未生成");
@@ -173,7 +167,7 @@ public class BookChapterContentController {
public R allVoices(@RequestParam("id") Integer id) throws Exception {
BookEntity bookEntity = bookService.getBaseMapper().selectById(id);
//创建单线程
ExecutorService singleThreadExecutor = Executors.newSingleThreadExecutor();
singleThreadExecutor.execute(new Runnable() {
@SneakyThrows
@@ -185,7 +179,7 @@ public class BookChapterContentController {
for (BookChapterContentEntity bookContent:book_id) {
String content = bookContent.getContent();
//生成相应的语音文件
String voices = BaiduVoicesUtils.run(content);
File file = new File(voices);
@@ -194,9 +188,12 @@ public class BookChapterContentController {
}
FileInputStream fileInputStream = new FileInputStream(file);
//把 voices 音频文件读入到内存中并将其转换成MultipartFile格式文件 multipartFile 用于OSS上传
// application/x-www-form-urlencoded form表单数据被编码为key/value格式发送到服务器
// text/plain 纯文本格式
// MultipartFile multipartFile =new MockMultipartFile("file", file.getName(), "text/plain", IOUtils.toByteArray(fileInputStream));
MultipartFile multipartFile =new MockMultipartFile("file", file.getName(), "text/plain", IOUtils.toByteArray(fileInputStream));
//上传 multipartFile 文件到阿里云OSS上
String path = ossService.uploadFileAvatar(multipartFile);
bookContent.setVoices(path);
@@ -218,6 +215,232 @@ public class BookChapterContentController {
bookService.updateById(bookEntity);
return R.ok();
}
//章节2.0转音频
@RequestMapping("/AllVOices")
public R allVoicess2(@RequestParam("id") Integer id) throws Exception {
BookEntity bookEntity = bookService.getBaseMapper().selectById(id);
//创建单线程
ExecutorService singleThreadExecutor = Executors.newSingleThreadExecutor();
singleThreadExecutor.execute(new Runnable() {
@SneakyThrows
@Override
public void run() {
BookEntity bookEntity = bookService.getBaseMapper().selectById(id);
List<BookChapterEntity> book_id = bookChapterService.getBaseMapper().selectList(new QueryWrapper<BookChapterEntity>().eq("book_id", id));
for (BookChapterEntity bookChapter:book_id) {
String content = bookChapter.getContent();
//生成相应的语音文件
String voices = BaiduVoicesUtils.run(content);
File file = new File(voices);
if (!file.exists()) {
bookEntity.setVoicesStatus("3");
}
FileInputStream fileInputStream = new FileInputStream(file);
MultipartFile multipartFile =new MockMultipartFile("file", file.getName(), "text/plain", IOUtils.toByteArray(fileInputStream));
//上传 multipartFile 文件到阿里云OSS上
String path = ossService.uploadFileAvatar(multipartFile);
bookChapter.setVoices(path);
fileInputStream.close();
file.delete();
bookChapterService.updateById(bookChapter);
if (StringUtils.isEmpty(path)){
bookEntity.setVoicesStatus("3");
}
}
bookEntity.setVoicesStatus("2");
bookService.updateById(bookEntity);
}
});
bookEntity.setVoicesStatus("1");
bookService.updateById(bookEntity);
return R.ok();
}
/**
* 鉴权获取章节
* @param bookid
* @param userId
* @return
*/
@RequestMapping("/getBooksCatal")
public R getBooksCatal(@RequestParam("id") Integer id,
@RequestParam("bookid") Integer bookid,
@RequestParam("userId") Integer userId) {
// TODO 验证 当前请求的书 是否存在免费章节数
BookEntity bookEntity = bookService.getBaseMapper().selectById(bookid);
Integer freeChapterCount = bookEntity.getFreeChapterCount();
//TODO 0-免费 1-会免(改为电子书听书) 2-付费 // 阅读章节数 大于 免费章节数
Integer isVip = bookEntity.getIsVip();
if ((bookid > freeChapterCount) || freeChapterCount == 0) {
// 书籍为 会免
if (isVip == 1) {
//查询用户身份
MyUserEntity user = myUserService.getById(userId);
String vip = user.getVip();
if (!"1".equals(vip)) {
return R.error("当前为VIP");
}
}
}
if (isVip == 2) {
// 鉴权 查询权限表中 用户是否开通
boolean b = myUserService.bookAuthenticate(bookid, userId);
if (!b) {
return R.error(500, "请购买书籍!");
}
}
if(isVip == 3){
boolean b = myUserService.bookAuthenticate(bookid,userId);
if (!b){
List<BookChapterEntity> book = bookChapterService.getBaseMapper().selectList(new QueryWrapper<BookChapterEntity>()
.eq("book_id", bookid));
ArrayList<Object> chapterList = new ArrayList<>();
int chapterIndex=0;
for (BookChapterEntity chapter : book) {
if (chapterIndex >= freeChapterCount) {
break; // 取出前freeChapterCount条记录后退出循环
}
//获取条数记录取出对应name,url
Map<String, Object> map = new HashMap<>();
map.put("name", chapter.getChapter());
map.put("url", chapter.getVoices());
chapterList.add(map);
chapterIndex++;
}
return R.ok("当前为试听章节:"+chapterList).put("bookCatalogue", chapterList).put("image", bookEntity.getImages()).put("chapterIndex",chapterIndex);
}
}
List<BookChapterEntity> book = bookChapterService.getBaseMapper().selectList(new QueryWrapper<BookChapterEntity>()
.eq("book_id", bookid));
ArrayList<Object> chapterList = new ArrayList<>();
for (BookChapterEntity chapter : book) {
Map<String, Object> map = new HashMap<>();
map.put("name",chapter.getChapter());
map.put("url",chapter.getVoices());
chapterList.add(map);
}
return R.ok().put("bookCatalogue", chapterList).put("image", bookEntity.getImages());
}
/**
* app 获取电子书章节内容 2.0 (在用鉴权)
*/
@RequestMapping("/appBooksChapterContent")
public R getBooksCatalogue(@RequestParam("chapterid") Integer id,
@RequestParam("bookid") Integer bookid,
@RequestParam("userId") Integer userId) {
// TODO 验证 当前请求的书 是否存在免费章节数
BookEntity bookEntity = bookService.getBaseMapper().selectById(bookid);
Integer freeChapterCount = bookEntity.getFreeChapterCount();
BookChapterEntity bookChapterEntity = bookChapterService.getBaseMapper().selectById(id);
Integer number = bookChapterEntity.getNumber();
//TODO 0-免费 1-会免(改为电子书听书) 2-付费 // 阅读章节数 大于 免费章节数
Integer isVip = bookEntity.getIsVip();
Boolean canListen = bookEntity.getCanListen();
//todo 暂未开通听书功能
// if (canListen==false) {
// return R.error1("暂未开通听书功能");
// }
if ((number > freeChapterCount) || freeChapterCount == 0) {
// 书籍为 会免
if (isVip == 1) {
//查询用户身份
MyUserEntity user = myUserService.getById(userId);
String vip = user.getVip();
if (!"1".equals(vip)) {
return R.error("当前为VIP");
}
}
if(canListen == true){
boolean b = myUserService.bookAuthenticate(bookid,userId);
if (!b) {
return R.error("未购买书籍!");
}
}
}
if (isVip == 2) {
// 鉴权 查询权限表中 用户是否开通
boolean b = myUserService.bookAuthenticate(bookid, userId);
if (!b) {
return R.error(500, "请购买书籍!").put("code",500);
}
}
ArrayList<Object> chapterList = new ArrayList<>();
Map<String, Object> map = new HashMap<>();
map.put("name",bookChapterEntity.getChapter());
map.put("url",bookChapterEntity.getVoices());
map.put("bookid",bookChapterEntity.getBookId());
map.put("chapterid",bookChapterEntity.getId());
//todo sort先注释调
// map.put("sort",bookChapterEntity.getSort());
chapterList.add(map);
return R.ok().put("bookCatalogue", chapterList).put("image", bookEntity.getImages());
}
/**
* app 获取电子书章节内容
*/
@@ -227,20 +450,14 @@ public class BookChapterContentController {
@RequestParam("userId") Integer userId){
// TODO 验证 当前请求的书 是否存在免费章节数
BookEntity bookEntity = bookService.getBaseMapper().selectById(bookid);
Integer freeChapterCount = bookEntity.getFreeChapterCount();
Integer isVip = bookEntity.getIsVip(); // 0-免费 1-会免 2-付费
BookChapterEntity bookChapterEntity = bookChapterService.getBaseMapper().selectById(chapterid);
Integer number = bookChapterEntity.getNumber();
if ((number > freeChapterCount) || freeChapterCount ==0){ // 阅读章节数 大于 免费章节数
// 书籍为 会免
// 阅读章节数 大于 免费章节数
if ((number > freeChapterCount) || freeChapterCount ==0){
if (isVip == 1) {
//查询用户身份
MyUserEntity user = myUserService.getById(userId);
String vip = user.getVip();
if (!"1".equals(vip)) {
@@ -248,13 +465,10 @@ public class BookChapterContentController {
}
}
if (isVip == 2) {
// 鉴权 查询权限表中 用户是否开通
boolean b = myUserService.bookAuthenticate(bookid, userId);
if (!b) {
return R.error(500,"开通会员或购买此书籍!");
return R.error(500,"请购买此书籍!");
}
}
}
@@ -262,8 +476,6 @@ public class BookChapterContentController {
ArrayList<Object> list = new ArrayList<>();
List<BookChapterContentEntity> bookChapterContentEntities = bookChapterContentService.getBaseMapper().selectList(new QueryWrapper<BookChapterContentEntity>()
.eq("book_id",bookid)
.eq("book_chatper_id",chapterid));
@@ -273,7 +485,6 @@ public class BookChapterContentController {
String substring = "";
if (bookChapterContentEntity.getOtherContent() != null){
// substring = bookChapterContentEntity.getOtherContent().substring(3, bookChapterContentEntity.getOtherContent().length() - 3);
substring = bookChapterContentEntity.getOtherContent().replace("<p>","").replace("</p>","");
}
StringBuffer stringBuffer = new StringBuffer(substring);
@@ -286,8 +497,6 @@ public class BookChapterContentController {
String chapter = chapterEntity.getChapter();
content = bookChapterContentEntity.getContent().replace(chapter, "");
}
// System.out.println(content.length());
// System.out.println(content.replaceAll("[\\\\s\\\\u00A0]",""));
bookChapterContentEntity.setPicAndWord(content.replaceAll(" ","") + stringBuffer);
list.add(bookChapterContentEntity);
}

View File

@@ -1,9 +1,10 @@
package com.peanut.modules.book.controller;
import java.io.IOException;
import java.util.Arrays;
import java.util.Map;
import java.text.Collator;
import java.util.*;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
@@ -36,7 +37,6 @@ public class BookChapterController {
* 列表
*/
@RequestMapping("/list")
// @RequiresPermissions("book:bookchapter:list")
public R list(@RequestParam Map<String, Object> params){
PageUtils page = bookChapterService.queryPage(params);
@@ -44,11 +44,19 @@ public class BookChapterController {
}
@RequestMapping("/booklist")
public R booklist(@RequestParam Map<String, Object> params){
PageUtils page = bookChapterService.queryPage1(params);
return R.ok().put("page", page);
}
/**
* 信息
*/
@RequestMapping("/info/{id}")
// @RequiresPermissions("book:bookchapter:info")
public R info(@PathVariable("id") Integer id){
BookChapterEntity bookChapter = bookChapterService.getById(id);
@@ -59,36 +67,176 @@ public class BookChapterController {
* 保存
*/
@RequestMapping("/save")
// @RequiresPermissions("book:bookchapter:save")
public R save(@RequestBody BookChapterEntity bookChapter){
bookChapterService.save(bookChapter);
public R save(@RequestBody BookChapterEntity bookChapter) {
BookChapterEntity bookChapterEntity = new BookChapterEntity();
Integer number = bookChapter.getNumber();
Integer bookId = bookChapter.getBookId();
List<BookChapterEntity> bookChapterEntities = this.bookChapterService.getBaseMapper().selectList(new QueryWrapper<BookChapterEntity>()
.eq("book_id", bookId)
.ge("number", number));
for(BookChapterEntity entity: bookChapterEntities){
entity.setNumber(entity.getNumber() + 1);
this.bookChapterService.updateById(entity);
}
bookChapterService.save(bookChapter);
// if (number != null && bookId != null) {
// BookChapterEntity chapter = bookChapterService.getBaseMapper().selectOne(new QueryWrapper<BookChapterEntity>()
// .eq("number", number)
// .eq("book_id", bookId));
// if (chapter != null) {
// return R.error("该章节已存在,请修改或重新上传");
// } else {
// bookChapterEntity.setBookId(bookChapter.getBookId());
// bookChapterEntity.setNumber(bookChapter.getNumber());
// bookChapterEntity.setContent(bookChapter.getContent());
// bookChapterEntity.setChapter(bookChapter.getChapter());
// bookChapterEntity.setVoices(bookChapter.getVoices());
// bookChapterService.save(bookChapterEntity);
// }
//
// }
return R.ok();
}
/**
* 修改
*/
@RequestMapping("/contentupdate")
public R contentupdate(@RequestBody BookChapterEntity bookChapter) {
Integer id = bookChapter.getId();
String content = bookChapter.getContent();
//
// bookChapterService.updateById(bookChapter); // 更新对象的属性
//
// return R.ok();
BookChapterEntity byId = bookChapterService.getById(id);
String content1 = byId.getContent();
if (content.equals(content1)) {
} else {
// 如果content字段和原来数据库的content内容不同则voices字段为空
bookChapter.setVoices(""); // 设置voices字段为空
}
bookChapterService.updateById(bookChapter); // 更新对象的属性
return R.ok();
}
/**
* 修改
*/
@RequestMapping("/update")
// @RequiresPermissions("book:bookchapter:update")
public R update(@RequestBody BookChapterEntity bookChapter){
bookChapterService.updateById(bookChapter);
public R update(@RequestBody BookChapterEntity bookChapter) {
bookChapterService.updateById(bookChapter); // 更新对象的属性
return R.ok();
}
public static List<BookChapterEntity> sort(List<BookChapterEntity> list){
//根据指定比较器产生的顺序对指定列表进行排序。
Collections.sort(list, new Comparator<BookChapterEntity>() {
@Override
public int compare(BookChapterEntity o1, BookChapterEntity o2) {
//获取所需语言环境的 Collator根据所需切换其他语言环境
//Collator collator = Collator.getInstance(Locale.ENGLISH);
//return collator.compare(o1.getAddress(), o2.getAddress());
Collator collator = Collator.getInstance(Locale.CANADA);
return collator.compare(o1.getNumber(), o2.getNumber());
}
});
return list;
}
/**
* 优化删除,暂时报错未修改
*/
//TODO 优化删除,暂时报错未修改
@RequestMapping("/deletess")
public R deletess(@RequestBody Integer[] ids){
for(Integer id : ids){
BookChapterEntity chapter = bookChapterService.getBaseMapper().selectOne(new QueryWrapper<BookChapterEntity>()
.eq("id", id)
);
List<BookChapterEntity> bookChapterEntities = this.bookChapterService.getBaseMapper().selectList(new QueryWrapper<BookChapterEntity>()
.eq("book_id", chapter.getBookId())
.gt("number", chapter.getNumber()));
this.bookChapterService.removeById(id);
for(BookChapterEntity entity: bookChapterEntities){
entity.setNumber(entity.getNumber() - 1);
}
List<BookChapterEntity> bookChapterEntities2 = sort(bookChapterEntities);
List<BookChapterEntity> tempEntity = this.bookChapterService.getBaseMapper().selectList(new QueryWrapper<BookChapterEntity>()
.eq("book_id", chapter.getBookId()).orderByAsc("number")
);
int index = tempEntity.size() - bookChapterEntities.size();
for(BookChapterEntity entity: bookChapterEntities2){
index ++;
entity.setNumber(index);
this.bookChapterService.updateById(entity);
}
}
return R.ok();
}
/**
* 删除
*/
@RequestMapping("/delete")
// @RequiresPermissions("book:bookchapter:delete")
public R delete(@RequestBody Integer[] ids){
bookChapterService.removeByIds(Arrays.asList(ids));
public R delete(@RequestBody Integer[] ids) {
for(Integer id : ids){
BookChapterEntity chapter = bookChapterService.getBaseMapper().selectOne(new QueryWrapper<BookChapterEntity>()
.eq("id", id)
);
List<BookChapterEntity> bookChapterEntities = this.bookChapterService.getBaseMapper().selectList(new QueryWrapper<BookChapterEntity>()
.eq("book_id", chapter.getBookId())
.gt("number", chapter.getNumber()));
this.bookChapterService.removeById(id);
for(BookChapterEntity entity: bookChapterEntities){
entity.setNumber(entity.getNumber() - 1);
this.bookChapterService.updateById(entity);
}
List<BookChapterEntity> tempEntity = this.bookChapterService.getBaseMapper().selectList(new QueryWrapper<BookChapterEntity>()
.eq("book_id", chapter.getBookId()).orderByAsc("number")
);
int index = 0;
for(BookChapterEntity entity: tempEntity){
index ++;
entity.setNumber(index);
this.bookChapterService.updateById(entity);
}
}
return R.ok();
}
}
}

View File

@@ -1,28 +1,18 @@
package com.peanut.modules.book.controller;
import java.util.*;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.peanut.common.utils.ReadProvinceUtil;
import com.peanut.modules.book.entity.*;
import com.peanut.modules.book.service.*;
import com.peanut.modules.book.vo.BookIndexVo;
import org.apache.commons.lang.StringUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.*;
import com.peanut.common.utils.PageUtils;
import com.peanut.common.utils.R;
import javax.servlet.http.HttpServletRequest;
/**
* 图书表
*
@@ -55,7 +45,8 @@ public class BookController {
private CityService cityService;
@Autowired
private CountyService countyService;
@Autowired
private UserEbookBuyService userEbookBuyService;
final ExecutorService fixedThreadPool = Executors.newFixedThreadPool(10);
/**
@@ -69,6 +60,17 @@ public class BookController {
return R.ok().put("page", page);
}
/**
* 信息
*/
@@ -89,12 +91,15 @@ public class BookController {
public R appinfo(@PathVariable("id") Integer id,
@PathVariable("userId") Integer userId) {
System.out.println("++++++id"+id);
System.out.println("++++++userId"+userId);
// 判断用户是否够买书籍
BookEntity book = bookService.getById(id);
book.setIsBuy(1);
book.setIsBuy(0);
Boolean canListen = book.getCanListen();
// Integer isVip = book.getIsVip(); // 0-免费 1-会免 2-付费
boolean b = myUserService.bookAuthenticate(id, userId);
@@ -103,31 +108,10 @@ public class BookController {
book.setIsBuy(0);
}
// // 书籍为 会免
// if (isVip == 1) {
// //查询用户身份
// MyUserEntity user = myUserService.getById(userId);
// String vip = user.getVip();
// if (!"1".equals(vip)) {
//
// //TODO 判断 非会员 是否购买会免书籍
//
// // 无权限
// book.setIsBuy(0);
// }
//
//
// }
//
// if (isVip == 2) {
// // 鉴权 查询权限表中 用户是否开通
// boolean b = myUserService.bookAuthenticate(id, userId);
//
// if (!b) {
// // 无权限
// book.setIsBuy(0);
// }
// }
// if (canListen==false) {
// // 无权限
// return R.error("该图书暂未开通听书功能");
// }
String authorName = "";
@@ -193,7 +177,7 @@ public class BookController {
book.setPublisherName(publisherName);
book.setFlag(flag);
return R.ok().put("book", book);
return R.ok().put("book", book).put("canListen",canListen);
}
/**
@@ -231,7 +215,7 @@ public class BookController {
}
/**
* 章节拆分
* 常规章节拆分
*/
@RequestMapping("/getChapter")
public R getChapter(@RequestParam("id") Integer id) {
@@ -240,51 +224,124 @@ public class BookController {
singleThreadExecutor.execute(new Runnable() {
@Override
public void run() {
bookService.getWordChapter(id);
// bookService.getWordChapter(id);
// bookService.getChapter(id);
// bookService.getWord(id);
bookService.getWordSection(id);
}
});
BookEntity bookEntity = bookService.getBaseMapper().selectById(id);
bookEntity.setChapterStatus("2");
bookService.updateById(bookEntity);
return R.ok();
}
/**
* 章节拆分 2.0
*/
@RequestMapping("/getWord")
public R getWord(@RequestParam("id") Integer id) {
ExecutorService singleThreadExecutor = Executors.newSingleThreadExecutor();
singleThreadExecutor.execute(new Runnable() {
@Override
public void run() {
//2.0
bookService.getWord(id);
}
});
BookEntity bookEntity = bookService.getBaseMapper().selectById(id);
bookEntity.setChapterStatus("2");
bookService.updateById(bookEntity);
return R.ok();
}
/**
* 章节拆分 3.0小节
*/
@RequestMapping("/WordSection")
public R getWordSection(@RequestParam("id") Integer id) {
// List<BookChapterEntity> kid = bookChapterService.getBaseMapper().selectList(new QueryWrapper<BookChapterEntity>().eq("book_id", id));
// if (kid != null) {
// for (BookChapterEntity bookChapterEntity : kid) {
// // 调用删除方法进行删除
// Integer id1 = bookChapterEntity.getId();
// System.out.println("===========id1=="+id1);
//// bookChapterService.removeById(id1);
// }
//
//
// }
ExecutorService singleThreadExecutor = Executors.newSingleThreadExecutor();
singleThreadExecutor.execute(new Runnable() {
@Override
public void run() {
//3.0 大小章拆分
bookService.getWordSection(id);
// bookService.getChapter(id);
}
});
BookEntity bookEntity = bookService.getBaseMapper().selectById(id);
bookEntity.setChapterStatus("1");
bookEntity.setChapterStatus("2");
bookService.updateById(bookEntity);
return R.ok();
return R.ok();
}
/**
* app 获取电子书目录
*/
@RequestMapping("/getBookCatalogue")
public R getBookCatalogue(@RequestParam("bookid") Integer id) {
public R getBookCatalogue(@RequestParam("bookid") Integer id,
@RequestParam("userid") Integer userid) {
//优化查询速度 目录放入redis中
String s = redisTemplate.opsForValue().get("bookCatalogue" + String.valueOf(id));
List<Map<String, Object>> listData = new ArrayList<>();
if (StringUtils.isNotBlank(s)) {
List<Object> redisData = JSONArray.parseArray(s);
for (Object object : redisData) {
Map<String, Object> ret = (Map<String, Object>) object;//取出list里面的值转为map
listData.add(ret);
}
return R.ok().put("bookCatalogue", listData);
BookEntity bookEntity = bookService.getBaseMapper().selectById(id);
if (bookEntity.getImages()==null) {
return R.error("电子书目录为空");
}
String images = bookEntity.getImages() ;
ArrayList<Object> list = new ArrayList<>();
Integer freeChapterCount = bookEntity.getFreeChapterCount();
UserEbookBuyEntity userEbookBuyEntity1 = userEbookBuyService.getBaseMapper().selectOne(new QueryWrapper<UserEbookBuyEntity>().eq("book_id", id).eq("user_id", userid));
List<BookChapterEntity> bookChapterEntities = bookChapterService.getBaseMapper().selectList(new QueryWrapper<BookChapterEntity>().eq("book_id", id));
for (BookChapterEntity bookEntity : bookChapterEntities) {
List<HashMap<Object, Object>> chapterList = new ArrayList<>();
for (BookChapterEntity bookEntitys : bookChapterEntities) {
HashMap<Object, Object> map = new HashMap<>();
String chapter = bookEntity.getChapter();
// map.put(bookEntity.getId(),chapter);
map.put("chapterId", bookEntity.getId());
map.put("chapterName", chapter);
list.add(map);
}
redisTemplate.opsForValue().set("bookCatalogue" + String.valueOf(id), JSON.toJSONString(list));
map.put("bookid",id);
map.put("number", bookEntitys.getNumber());
map.put("chapterId", bookEntitys.getId());
map.put("chapterName", bookEntitys.getChapter());
//freeChapterCount
return R.ok().put("bookCatalogue", list);
map.put("images",images);
chapterList.add(map);
}
//true免费 false付费
if (userEbookBuyEntity1!=null) {
return R.ok().put("BookCatalogue", chapterList).put("buy",true);
}
return R.ok().put("BookCatalogue", chapterList).put("buy",false).put("freeChapterCount",freeChapterCount);
}
@@ -517,4 +574,7 @@ public class BookController {
}
}

View File

@@ -57,10 +57,10 @@ public class BookReadRateController {
/**
* 保存
*/
@RequestMapping("book/bookreadrate/save")
// @RequiresPermissions("book:bookreadrate:save")
public R save(@RequestBody BookReadRateEntity bookReadRate){
@RequestMapping("/save")
// @RequiresPermissions("book:bookreadrate:save") @RequestBody
public R save(@RequestBody BookReadRateEntity bookReadRate){
Integer bookId = bookReadRate.getBookId();
Integer userId = bookReadRate.getUserId();
BookReadRateEntity bookReadRateEntity = bookReadRateService.getBaseMapper().selectOne(new QueryWrapper<BookReadRateEntity>().eq("book_id", bookId)
@@ -68,10 +68,10 @@ public class BookReadRateController {
if (bookReadRateEntity != null) {
return R.ok().put("bookReadId",bookReadRateEntity.getId());
}else {
bookReadRateService.save(bookReadRate);
}
bookReadRateService.save(bookReadRate);
return R.ok();
}
@@ -83,6 +83,7 @@ public class BookReadRateController {
public R update(@RequestBody BookReadRateEntity bookReadRate){
bookReadRateService.updateById(bookReadRate);
return R.ok();
}

View File

@@ -70,9 +70,10 @@ public class BookShelfController {
// 加入前判断数据库是否加入过 这本书
Integer integer = bookShelfService.getBaseMapper().selectCount(new QueryWrapper<BookShelfEntity>()
.eq("book_id", bookShelf.getBookId())
.eq("user_id", bookShelf.getUserId()));
System.out.println("bookShelf"+bookShelf);
if (integer > 0){
return R.error(500,"当前书籍已加入书架");
}
@@ -119,4 +120,16 @@ public class BookShelfController {
return R.ok().put("userBookshelf",userBookshelf);
}
/**
* 获取用户听书书架 getUserBookChapterRead
*/
@RequestMapping("/getUserBookChapterRead")
public R getUserBookChapterRead(@RequestParam Integer userId){
List<BookShelfVo> bookShelfVos = bookShelfService.getUserBookChapterRead(userId);
return R.ok().put("bookShelfVos",bookShelfVos);
}
}

View File

@@ -1,29 +1,20 @@
package com.peanut.modules.book.controller;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import java.util.*;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import java.util.stream.Collectors;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.baomidou.mybatisplus.extension.conditions.query.QueryChainWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.peanut.common.utils.MD5Util;
import com.peanut.common.utils.MD5Utils;
import com.peanut.modules.book.entity.*;
import com.peanut.modules.book.service.*;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import lombok.var;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
@@ -32,7 +23,6 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.peanut.common.utils.PageUtils;
import com.peanut.common.utils.R;
@@ -61,15 +51,34 @@ public class BuyOrderController {
private CouponHistoryService couponHistoryService;
@Autowired
private OrderCartService orderCartService;
@Autowired
private MyUserService myUserService;
@Autowired
private TransactionDetailsService transactionDetailsService;
@Autowired
private AuthorService authorService;
@Autowired
private UserEbookBuyService userEbookBuyService;
@Autowired
private BookService bookService;
@Autowired
private BookShelfService bookShelfService;
@Autowired
private UserRecordService userRecordService;
@Autowired
private UserFollowUpService userFollowUpService;
@Autowired
private PayWechatOrderService payWechatOrderService;
@Autowired
private PayZfbOrderService payZfbOrderService;
// @Autowired
// private
/**
* 列表
*/
@RequestMapping("/list")
// @RequiresPermissions("book:buyorder:list")
public R list(@RequestParam Map<String, Object> params){
public R list(@RequestParam Map<String, Object> params) throws Exception {
if("all".equals(params.get("orderStatus"))){
params.remove("orderStatus");
@@ -79,6 +88,29 @@ public class BuyOrderController {
}
/**
*
* @param params
* @return 听书未购买页面展示
* (销量最多的书,最先放最前面展示。最新上线的书,预售的书,放最前面展示
* @throws Exception
*/
@RequestMapping("/lists")
// @RequiresPermissions("book:buyorder:list")
public R lists(@RequestParam Map<String, Object> params) throws Exception {
if("all".equals(params.get("orderStatus"))){
params.remove("orderStatus");
}
PageUtils page = buyOrderService.queryPages(params);
return R.ok().put("page", page);
}
/**
* 信息
*/
@@ -90,6 +122,7 @@ public class BuyOrderController {
return R.ok().put("buyOrder", buyOrder);
}
/**
* 保存
*/
@@ -127,7 +160,6 @@ public class BuyOrderController {
product.setProductStock(product.getProductStock() - buyOrderDetail.getQuantity());
product.setSumSales(product.getSumSales() + buyOrderDetail.getQuantity());
shopProductService.updateById(product);
BeanUtils.copyProperties(buyOrderDetail,buyOrderDetailEntity);
buyOrderDetailEntity.setProductName(product.getProductName());
buyOrderDetailEntity.setProductPrice(product.getPrice());
@@ -136,6 +168,10 @@ public class BuyOrderController {
System.out.println(buyOrder.getAddressId());
buyOrderDetailEntity.setOrderStatus("0");
list.add(buyOrderDetailEntity);
}
Integer couponId = buyOrder.getCouponId();
@@ -149,28 +185,25 @@ public class BuyOrderController {
}
if (buyOrder.getShippingMoney() != null) {
System.out.println("bigDecimal1============>"+bigDecimal1);
System.out.println("ShippingMoney============>"+buyOrder.getShippingMoney());
bigDecimal1 = bigDecimal1.add(buyOrder.getShippingMoney());
}
// 减去优惠券金额
realMoney = buyOrder.getRealMoney();
System.out.println("realMoney============>"+realMoney);
System.out.println("bigDecimal1============>"+bigDecimal1);
if (bigDecimal1.compareTo(realMoney) == 0) {
String timeId = IdWorker.getTimeId();
//特定格式的时间ID
String timeId = IdWorker.getTimeId().substring(0,32);
buyOrder.setOrderSn(timeId);
if("4".equals(buyOrder.getPaymentMethod())){
buyOrder.setOrderStatus("1");
}
//todo 增加结束时间
buyOrder.setPaymentDate(new Date());
buyOrderService.save(buyOrder);
System.out.println("orderId====================>"+buyOrder.getOrderId());
for (BuyOrderDetailEntity buyOrderDetailEntity : list) {
buyOrderDetailEntity.setOrderId(buyOrder.getOrderId());
buyOrderDetailEntity.setUserId(buyOrder.getUserId());
@@ -182,7 +215,6 @@ public class BuyOrderController {
// 更改购物车 状态
List<OrderCartEntity> list1 = orderCartService.getBaseMapper().selectList(new QueryWrapper<OrderCartEntity>()
.eq("user_id", buyOrder.getUserId()).eq("product_id", buyOrderDetailEntity.getProductId()));
if (list1.size() > 0){
List<Integer> collect = list1.stream().map(orderCartEntity -> {
Integer cartId = orderCartEntity.getCartId();
@@ -205,8 +237,26 @@ public class BuyOrderController {
one.setOrderSn(buyOrder.getOrderSn());
couponHistoryService.updateById(one);
}
if("4".equals(buyOrder.getPaymentMethod())){
MyUserEntity user = this.myUserService.getById(buyOrder.getUserId());
if(user.getPeanutCoin().compareTo(realMoney) >= 0){
user.setPeanutCoin(user.getPeanutCoin().subtract(realMoney));
this.myUserService.updateById(user);
// 添加消费信息
TransactionDetailsEntity transactionDetailsEntity = new TransactionDetailsEntity();
transactionDetailsEntity.setRemark("购买健康超市用品!订单编号为《 "+ buyOrder.getOrderSn() + "");
transactionDetailsEntity.setUserId(user.getId());
transactionDetailsEntity.setUserName(user.getNickname());
transactionDetailsEntity.setChangeAmount(realMoney.negate());
transactionDetailsEntity.setUserBalance(user.getPeanutCoin());
transactionDetailsEntity.setTel(user.getTel());
transactionDetailsEntity.setOrderType("购买健康超市用品!");
transactionDetailsService.save(transactionDetailsEntity);
}else{
return R.error("余额不足!");
}
}
}
}catch (Exception e){
e.printStackTrace();
@@ -214,13 +264,261 @@ public class BuyOrderController {
l.unlock();
}
return R.ok().put("orderSn",buyOrder.getOrderSn()).put("money",realMoney);
}
/**
* 修改
* 修改购买书籍(赠送电子书,加鉴权)
* @param buyOrder 订单表
* @return
*/
@RequestMapping("/buysave")
@Transactional
public R buysave(@RequestBody BuyOrderEntity buyOrder) {
BigDecimal realMoney = new BigDecimal(0);
Lock l = new ReentrantLock();
l.lock();
try {
List<BuyOrderDetailEntity> products = buyOrder.getProducts();
BigDecimal bigDecimal1 = new BigDecimal(0);
ArrayList<BuyOrderDetailEntity> list = new ArrayList<>();
// 遍历商品 查询价格
for (BuyOrderDetailEntity buyOrderDetail : products) {
BuyOrderDetailEntity buyOrderDetailEntity = new BuyOrderDetailEntity();
Integer productId = buyOrderDetail.getProductId();
ShopProductEntity product = shopProductService.getById(productId);
BigDecimal price = product.getPrice();
Integer quantity = buyOrderDetail.getQuantity();
//价格*数量 = 单价*购买数量赋值给bigDecimal1
BigDecimal bigDecimal = new BigDecimal(price.doubleValue() * quantity);
bigDecimal1 = bigDecimal1.add(bigDecimal);
if (product.getProductStock() - buyOrderDetail.getQuantity() < 0) {
return R.error(500, "库存不足");
}
// 改写 商品库存
product.setProductStock(product.getProductStock() - buyOrderDetail.getQuantity());
product.setSumSales(product.getSumSales() + buyOrderDetail.getQuantity());
shopProductService.updateById(product);
//buyOrderDetail 对象中的属性值复制到 buyOrderDetailEntity 对象中的属性值中
BeanUtils.copyProperties(buyOrderDetail, buyOrderDetailEntity);
buyOrderDetailEntity.setProductName(product.getProductName());
buyOrderDetailEntity.setProductPrice(product.getPrice());
buyOrderDetailEntity.setAddressId(buyOrder.getAddressId());
buyOrderDetailEntity.setProductUrl(product.getProductImages());
buyOrderDetailEntity.setOrderStatus("0");
list.add(buyOrderDetailEntity);
}
//优惠券Id couponId
Integer couponId = buyOrder.getCouponId();
if (couponId != null) {
CouponHistoryEntity byId = couponHistoryService.getById(couponId);
CouponEntity coupon = couponService.getById(byId.getCouponId());
BigDecimal amount = coupon.getCouponAmount();
bigDecimal1 = bigDecimal1.subtract(amount);
}
if (buyOrder.getShippingMoney() != null) {
bigDecimal1 = bigDecimal1.add(buyOrder.getShippingMoney());
}
// 减去优惠券金额
realMoney = buyOrder.getRealMoney();
if (bigDecimal1.compareTo(realMoney) == 0) {
//特定格式的时间ID
String timeId = IdWorker.getTimeId().substring(0, 32);
buyOrder.setOrderSn(timeId);
if ("4".equals(buyOrder.getPaymentMethod())) {
buyOrder.setOrderStatus("1");
}
//todo 增加结束时间
buyOrder.setPaymentDate(new Date());
buyOrderService.save(buyOrder);
for (BuyOrderDetailEntity buyetailEntity : list) {
buyetailEntity.setOrderId(buyOrder.getOrderId());
buyetailEntity.setUserId(buyOrder.getUserId());
// 判断结算状态 下单 位置 0- 商品页直接下单 1- 购物车结算
String buyType = buyOrder.getBuyType();
if (buyType.equals("1")) {
// 更改购物车 状态
List<OrderCartEntity> list1 = orderCartService.getBaseMapper().selectList(new QueryWrapper<OrderCartEntity>()
.eq("user_id", buyOrder.getUserId()).eq("product_id", buyetailEntity.getProductId()));
//将购物车列表转换为流,并从中提取每个购物车的 cartId。removeByIds() 方法从数据库中删除这些购物车记录。
if (list1.size() > 0) {
List<Integer> collect = list1.stream().map(orderCartEntity -> {
Integer cartId = orderCartEntity.getCartId();
return cartId;
}).collect(Collectors.toList());
orderCartService.removeByIds(collect);
}
}
}
buyOrderDetailService.saveBatch(list);
if (couponId != null) {
//更改优惠券状态
CouponHistoryEntity one = couponHistoryService.getById(couponId);
one.setUseStatus(1);
one.setUseTime(new Date());
one.setOrderId(Long.valueOf(buyOrder.getOrderId()));
one.setOrderSn(buyOrder.getOrderSn());
couponHistoryService.updateById(one);
}
// 购买书籍直接赠送电子书听书
TransactionDetailsEntity transaction = new TransactionDetailsEntity();
//避免重复购买
TransactionDetailsEntity entity = transactionDetailsService.getBaseMapper().selectOne(new QueryWrapper<TransactionDetailsEntity>().eq("user_id", transaction.getUserId())
.eq("relation_id", transaction.getRelationId()));
if (entity != null) {
return R.error("余额不足,请充值!!!!!!!!!!!!!!!!");
}
List<BuyOrderDetailEntity> produ = buyOrder.getProducts();
// 遍历商品 查询价格
for (BuyOrderDetailEntity buyOrdr : produ) {
Integer pId = buyOrdr.getProductId();
ShopProductEntity product1 = shopProductService.getById(pId);
// 如果是虚拟币购买 减少用户的虚拟币数量
if ("4".equals(buyOrder.getPaymentMethod())) {
MyUserEntity user = this.myUserService.getById(buyOrder.getUserId());
if (user.getPeanutCoin().compareTo(realMoney) >= 0) {
user.setPeanutCoin(user.getPeanutCoin().subtract(realMoney));
this.myUserService.updateById(user);
// 添加消费信息
TransactionDetailsEntity transactionDetailsEntity = new TransactionDetailsEntity();
transactionDetailsEntity.setRemark("购买健康超市用品!订单编号为《 " + buyOrder.getOrderSn() + "");
transactionDetailsEntity.setUserId(user.getId());
transactionDetailsEntity.setUserName(user.getNickname());
transactionDetailsEntity.setChangeAmount(realMoney.negate());
transactionDetailsEntity.setUserBalance(user.getPeanutCoin());
transactionDetailsEntity.setTel(user.getTel());
transactionDetailsEntity.setOrderType("赠送本书听书图书");
transactionDetailsService.save(transactionDetailsEntity);
} else {
return R.error("余额不足!");
}
}
}
// }
for (BuyOrderDetailEntity buyOrderDetail : products) {
Integer productId = buyOrderDetail.getProductId();
ShopProductEntity product = shopProductService.getById(productId);
// 如果不等于空 则进行往下走
String authorName = "";
String bookId = product.getBookId();
if(null != bookId && !"".equals(bookId)){
List<String> bkids = new ArrayList<String>();
if(bookId.indexOf(",") == -1){
bkids.add(bookId);
}else {
for(String idObj : bookId.split(",")){
bkids.add(idObj);
}
}
for(String b_id : bkids){
if (b_id != null) {
List<BookEntity> book = bookService.getBaseMapper().selectList(new QueryWrapper<BookEntity>().eq("id", b_id));
for (BookEntity bo : book) {
Integer id = bo.getId();
String name = bo.getName();
String images = bo.getImages();
String authorId = bo.getAuthorId();
if (book != null) {
UserEbookBuyEntity userEbookBuyEntity = new UserEbookBuyEntity();
userEbookBuyEntity.setUserId(Integer.valueOf(buyOrder.getUserId()));
userEbookBuyEntity.setBookId(Integer.valueOf(id));
String[] authorIds = authorId.split(",");
List<String> authorList = Arrays.asList(authorIds);
List<AuthorEntity> authorEntities = authorService.getBaseMapper().selectList(new QueryWrapper<AuthorEntity>().in("id", authorList));
//购买书籍表 userId bookName 商品订单详情表 userId productName
List<UserEbookBuyEntity> userId = userEbookBuyService.getBaseMapper().selectList(new QueryWrapper<UserEbookBuyEntity>()
.eq("user_Id", buyOrder.getUserId())
.eq("book_id", id));
for (AuthorEntity authorEntity : authorEntities) {
authorName += "," + authorEntity.getAuthorName();
}
//查询dengyu则往下执行赠送电子书详情
if (userId != null && !userId.isEmpty()) {
// 如果userId不等于空则不赠送图书不执行任何方法
// return R.ok("此书已存在于您的书架");
} else {
authorName = authorName.startsWith(",") ? authorName.substring(1) : authorName;
userEbookBuyEntity.setAuthor(authorName);
userEbookBuyEntity.setImage(images);
userEbookBuyEntity.setPayStatus("赠送成功");
//这里后期需要修改字段内容
userEbookBuyEntity.setPayType("point");
userEbookBuyEntity.setPayTime(new Date());
userEbookBuyEntity.setBookName(name);
userEbookBuyService.save(userEbookBuyEntity);
//判断是否加入书架如果没有就加入听书书架
Integer integer = bookShelfService.getBaseMapper().selectCount(new QueryWrapper<BookShelfEntity>()
.eq("book_id", id)
.eq("user_id", userId));
//如果integer<0代表数据库没有这条数据则添加有就不执行下面操作
if (integer < 0) {
//保存到书架表中
BookShelfEntity bookShelfEntity = new BookShelfEntity();
bookShelfEntity.setBookId(id);
bookShelfEntity.setBookName(name);
bookShelfEntity.setUserId(buyOrder.getUserId());
bookShelfEntity.setCreateTime(new Date());
bookShelfService.save(bookShelfEntity);
}
// }
// else {
// return R.error().put("赠送失败",buyOrder.getOrderSn());
// }
}
}
}
}
}
}
}
}
}catch (Exception e){
e.printStackTrace();
}finally {
l.unlock();
}
return R.ok().put("orderSn",buyOrder.getOrderSn()).put("money",realMoney);
}
/**
* 修改
*/
@RequestMapping("/update")
// @RequiresPermissions("book:buyorder:update")
public R update(@RequestBody BuyOrderEntity buyOrder){
@@ -312,21 +610,35 @@ public class BuyOrderController {
return R.ok();
}
@RequestMapping("/randomOrderCode")
@Transactional
public R randomOrderCode(@RequestBody BuyOrderEntity buyOrder){
// String re= String.valueOf(buyOrderService.randomOrderCode(buyOrder));
// buyOrderService.save(re);
return R.ok();
}
/**
* 充值专用订单生成接口
*/
@RequestMapping("/rechargeSave")
@Transactional
// @RequiresPermissions("book:buyorder:save")
public R rechargeSave(@RequestBody BuyOrderEntity buyOrder){
String timeId = IdWorker.getTimeId();
buyOrder.setOrderSn(timeId);
buyOrderService.save(buyOrder);
return R.ok().put("orderSn",timeId);
}
String timeId = IdWorker.getTimeId().substring(0,32);
buyOrder.setOrderSn(timeId);
buyOrderService.save(buyOrder);
return R.ok().put("orderSn",timeId);
}
@@ -334,16 +646,24 @@ public class BuyOrderController {
* 信息
*/
@RequestMapping("/appGetOrderInfo/{type}")
// @RequiresPermissions("book:buyorder:info")
// @RequiresPermissions("book:buyorder:info") 就是这个
public R appGetOrderInfo(@PathVariable String type , @RequestParam("orderId") Integer orderId){
BuyOrderEntity buyOrder = buyOrderService.getById(orderId);
List<BuyOrderDetailEntity> orderDetail = null;
if("1".equals(type)){
orderDetail = buyOrderDetailService.getBaseMapper().selectList(new QueryWrapper<BuyOrderDetailEntity>()
.eq("order_id", orderId));
}else{
orderDetail = buyOrderDetailService.getBaseMapper().selectList(new QueryWrapper<BuyOrderDetailEntity>()
.eq("order_id", orderId).groupBy("shipping_sn"));
}
for (BuyOrderDetailEntity buyOrderDetailEntity : orderDetail) {
@@ -351,10 +671,40 @@ public class BuyOrderController {
buyOrderDetailEntity.setImage(prod.getProductImages());
}
buyOrder.setProducts(orderDetail);
return R.ok().put("buyOrder", buyOrder);
List<BuyOrderDetailEntity> resultOrder = new ArrayList<BuyOrderDetailEntity>();
Set<String> sn_no = new HashSet<String>();
for(BuyOrderDetailEntity buyOrderDetailEntity : orderDetail){
resultOrder.add(buyOrderDetailEntity);
sn_no.add(buyOrderDetailEntity.getShippingSn());
}
UserRecordEntity userRecordEntity = userRecordService.getBaseMapper().selectOne(new QueryWrapper<UserRecordEntity>()
.eq("orderSn", buyOrder.getOrderSn())
.eq("userid", buyOrder.getUserId())
.eq("orderdid",buyOrder.getOrderId())
.last("LIMIT 1"));
Integer id =null;
if (userRecordEntity != null) {
id = userRecordEntity.getId();
}
buyOrder.setProducts(resultOrder);
Date createDate = buyOrder.getCreateTime();
return R.ok().put("buyOrder", buyOrder).put("CreateTime",createDate).put("userRecordid",id);
}
/**
@@ -390,15 +740,7 @@ public class BuyOrderController {
}
/**
* 后台取消订单接口
*/
@RequestMapping("/cancelFMS")
public R cancelFMS(@RequestParam Map<String,Object> params){
buyOrderService.cancelFMS(params.get("orderSn").toString(), params.get("shipperCode").toString(),
params.get("expNo").toString());
return R.ok();
}
/**
@@ -408,13 +750,15 @@ public class BuyOrderController {
public R queryFMS(@RequestParam Map< String,String> params){
List<BuyOrderDetailEntity> detailList = this.buyOrderDetailService.getBaseMapper().selectList(new QueryWrapper<BuyOrderDetailEntity>().eq("order_id", params.get("orderId")));
List<JSONObject> jsonList = new ArrayList<>();
JSONObject jsonObj =null;
for (BuyOrderDetailEntity detail : detailList) {
JSONObject jsonObj = buyOrderService.queryFMS(detail.getShipperCode(), detail.getShippingSn());
jsonObj = buyOrderService.queryFMS(detail.getShipperCode(), detail.getShippingSn());
if(Objects.isNull(jsonObj)){
return R.ok("暂未查到物流信息!");
}
jsonObj.put("ShipperName",detail.getShipperName());
jsonList.add(jsonObj);
}
return R.ok().put("rntStr",jsonList);
}
@@ -456,9 +800,37 @@ public class BuyOrderController {
@RequestMapping("/blendSendFMS/{shipperCode}")
public R blendSendFMS(@PathVariable("shipperCode") String shipperCode,@RequestParam("shipperName") String shipperName,@RequestBody Integer[] orderDetailIds){
buyOrderService.blendSendFMS(orderDetailIds,shipperCode,shipperName);
return R.ok();
}
/**
* 后台取消订单接口
*/
@RequestMapping("/cancelFMS")
public R cancelFMS(@RequestParam Map<String,Object> params){
buyOrderService.cancelFMS(params.get("orderSn").toString(), params.get("shipperCode").toString(),
params.get("expNo").toString());
// return R.ok()
return R.ok().put("paramsTEXT",params);
}
/**
* 去重查询可打印面单
*
* @param params
* @return
*/
@RequestMapping("/querySheetPage")
public R querySheetPage(@RequestParam Map<String, Object> params){
PageUtils page = buyOrderDetailService.querySheet(params);
return R.ok().put("page", page);
}
}

View File

@@ -32,6 +32,10 @@ public class BuyOrderDetailController {
@Autowired
private BuyOrderDetailService buyOrderDetailService;
/**
* 列表
*/
@@ -43,7 +47,17 @@ public class BuyOrderDetailController {
return R.ok().put("page", page);
}
/**
* 查询已购买书籍
* @param params
* @return
*/
@RequestMapping("/querybuy")
public R querybuy(@RequestParam Map<String, Object> params){
PageUtils page = buyOrderDetailService.querybuy(params);
return R.ok().put("page", page);
}
/**
* 去重查询可打印面单
*
@@ -62,7 +76,6 @@ public class BuyOrderDetailController {
* 信息
*/
@RequestMapping("/info/{allOrderId}")
// @RequiresPermissions("book:buyorderdetail:info")
public R info(@PathVariable("allOrderId") Long allOrderId){
BuyOrderDetailEntity buyOrderDetail = buyOrderDetailService.getById(allOrderId);

View File

@@ -75,6 +75,11 @@ public class CouponController {
Calendar cal = Calendar.getInstance();
cal.add(Calendar.DATE,Integer.valueOf(coupon.getValidity()).intValue());
coupon.setExpirationDate(cal.getTime());
}else{
Calendar cal = Calendar.getInstance();
cal.setTime(coupon.getTakeEffectDate());
cal.add(Calendar.DATE,Integer.valueOf(coupon.getValidity()).intValue());
coupon.setExpirationDate(cal.getTime());
}
couponService.save(coupon);
@@ -90,10 +95,14 @@ public class CouponController {
if(0 == coupon.getTakeEffectType()){
coupon.setTakeEffectDate(new Date());
Calendar cal = Calendar.getInstance();
cal.add(Calendar.DATE,Integer.valueOf(coupon.getValidity()).intValue());
coupon.setExpirationDate(cal.getTime());
}else{
Calendar cal = Calendar.getInstance();
cal.setTime(coupon.getTakeEffectDate());
cal.add(Calendar.DATE,Integer.valueOf(coupon.getValidity()).intValue());
coupon.setExpirationDate(cal.getTime());
}
couponService.updateById(coupon);

View File

@@ -11,25 +11,23 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.peanut.common.utils.MD5Utils;
import com.peanut.modules.book.entity.CouponHistoryEntity;
import com.peanut.modules.book.entity.PayPaymentOrderEntity;
import com.peanut.modules.book.entity.TransactionDetailsEntity;
import com.peanut.modules.book.service.CouponHistoryService;
import com.peanut.modules.book.service.PayPaymentOrderService;
import com.peanut.modules.book.service.TransactionDetailsService;
import com.peanut.modules.book.entity.*;
import com.peanut.modules.book.service.*;
import com.peanut.modules.sys.service.SysUserTokenService;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import io.swagger.models.auth.In;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.peanut.modules.book.entity.MyUserEntity;
import com.peanut.modules.book.service.MyUserService;
import com.peanut.common.utils.PageUtils;
import com.peanut.common.utils.R;
@@ -48,12 +46,18 @@ public class MyUserController {
@Autowired
private MyUserService userService;
@Autowired
private BuyOrderService buyOrderService;
@Autowired
private StringRedisTemplate redisTemplate;
@Autowired
private SysUserTokenService sysUserTokenService;
@Autowired
private CouponHistoryService couponHistoryService;
@Autowired
private BookBuyConfigService bookBuyConfigService;
@Autowired
private BookService bookService;
@Autowired
private TransactionDetailsService transactionDetailsService;
/**
@@ -107,8 +111,10 @@ public class MyUserController {
String password = user.getPassword();
String saltMD5 = MD5Utils.getSaltMD5(password);
user.setPassword(saltMD5);
userService.updateById(user);
}else{
userService.update(user);
}
userService.updateById(user);
return R.ok();
}
@@ -321,7 +327,9 @@ public class MyUserController {
String cellPhone = jsonObject.getJSONObject("obj").getString("cellPhone");
String customerIcons = jsonObject.getJSONObject("obj").getString("customerIcons");
String nameCN = jsonObject.getJSONObject("obj").getString("nameCN");
System.out.println(yljkOid);
// String password = jsonObject.getJSONObject("obj").getString("pass");
System.out.println("=====================yljkOid=============================="+yljkOid);
//查询 当前 花生账号 和 当前绑定的 一路健康账号是否有绑定 关系
@@ -398,7 +406,7 @@ public class MyUserController {
myUserEntity.setAvatar(customerIcons);
userService.save(myUserEntity);
R r = sysUserTokenService.createToken(myUserEntity.getId());
return R.ok().put("userInfo",myUserEntity).put("token",r);
return R.ok().put("userInfo",myUserEntity).put("token",r);
}
//判断当前手机号用户是否绑定过一路健康账号
if (userEntity.getYljkOid() != null){
@@ -411,7 +419,9 @@ public class MyUserController {
userEntity.setAvatar(customerIcons);
userService.updateById(userEntity);
R r = sysUserTokenService.createToken(userEntity.getId());
// todo 为什么验证成功以后不能实现页面跳转登录 R返回更新生成的token和电话
return R.ok().put("userInfo",userEntity).put("token",r);
}
@RequestMapping("/test")
@@ -426,10 +436,19 @@ public class MyUserController {
*/
@RequestMapping("/buyEbook")
public R buyEbook(@RequestParam Map<String, Object> params){
String msg = "";
String bookId = (String) params.get("bookId");
String userId = (String) params.get("userId");
String couponId = (String) params.get("couponId");
String msg = userService.buyEbook(userId, bookId,couponId);
BookEntity book = this.bookService.getById(bookId);
MyUserEntity user = this.userService.getById(userId);
if(1 == book.getIsVip()){
if(!"1".equals(user.getVip())){
msg ="当前书籍为VIP书籍请开通VIP后购买";
return R.ok().put("msg", msg).put("status","error");
}
}
msg = userService.buyEbook(userId, bookId,couponId);
if (msg.equals("当前书籍以购买,请勿重复购买!")) {
return R.ok().put("msg",msg).put("status","error");
@@ -452,12 +471,12 @@ public class MyUserController {
MyUserEntity byId = userService.getById(id);
int i = 0;
if (pointType.equals("0")) {
i = byId.getPeanutCoin() + Integer.valueOf(pointAmount);
byId.setPeanutCoin(i);
i = byId.getPeanutCoin().intValue() + Integer.valueOf(pointAmount);
byId.setPeanutCoin(new BigDecimal(i));
}else {
i = byId.getPeanutCoin() - Integer.valueOf(pointAmount);
i = byId.getPeanutCoin().intValue() - Integer.valueOf(pointAmount);
if (i >= 0) {
byId.setPeanutCoin(i);
byId.setPeanutCoin(new BigDecimal(i));
}else {
return R.error("余额不足!扣除失败!");
}
@@ -466,11 +485,15 @@ public class MyUserController {
TransactionDetailsEntity transactionDetailsEntity = new TransactionDetailsEntity();
transactionDetailsEntity.setUserId(Integer.valueOf(id));
transactionDetailsEntity.setChangeAmount(new BigDecimal(Integer.valueOf(pointAmount)));
transactionDetailsEntity.setOrderType("后台充值操作");
transactionDetailsEntity.setOrderType("后台充扣操作");
transactionDetailsEntity.setTel(byId.getTel());
transactionDetailsEntity.setUserName(byId.getNickname());
transactionDetailsEntity.setNote(params.get("note"));
if (pointType.equals("0")) {
transactionDetailsEntity.setChangeAmount(new BigDecimal(Integer.valueOf(pointAmount)));
transactionDetailsEntity.setRemark("充值");
}else {
transactionDetailsEntity.setChangeAmount(new BigDecimal(Integer.valueOf(pointAmount)).negate());
transactionDetailsEntity.setRemark("扣费");
}
BigDecimal balance = new BigDecimal(i);
@@ -479,7 +502,7 @@ public class MyUserController {
// 插入 花生币 充值记录
// PayPaymentOrderEntity payPaymentOrderEntity = new PayPaymentOrderEntity();
// IosPayOrderEntity payPaymentOrderEntity = new IosPayOrderEntity();
// payPaymentOrderEntity.setUserId(Integer.valueOf(id));
// payPaymentOrderEntity.setRealAmount(new BigDecimal(byId.getPeanutCoin()));
// payPaymentOrderEntity.setRechargeAmount(new BigDecimal(i));
@@ -487,9 +510,72 @@ public class MyUserController {
// payPaymentOrderEntity.setRechargeStatus("success");
// payPaymentOrderEntity.setSuccessTime(new Date());
// payPaymentOrderService.save(payPaymentOrderEntity);
userService.updateById(byId);
return R.ok();
}
/**
* 使用虚拟币开通vip
* @return
*/
@RequestMapping("/openVipByVirtualCoin")
public R openVipByVirtualCoin(@RequestParam Map<String,Object> params){
Integer configId = Integer.valueOf(params.get("configId").toString());
String orderSn = params.get("orderSn").toString();
Integer userId = Integer.valueOf(params.get("userId").toString());
// 根据userId查找用户信息
MyUserEntity user = this.userService.getById(userId);
BookBuyConfigEntity bookBuyConfigEntity = bookBuyConfigService.getById(configId);
String month = bookBuyConfigEntity.getMonth();
BigDecimal amount = new BigDecimal(bookBuyConfigEntity.getRealMoney());
if(user.getPeanutCoin().compareTo(amount) >= 0){
user.setPeanutCoin(user.getPeanutCoin().subtract(amount));
this.userService.updateById(user);
// 添加消费信息
TransactionDetailsEntity transactionDetailsEntity = new TransactionDetailsEntity();
transactionDetailsEntity.setRemark("购买"+bookBuyConfigEntity.getType()+",金额"+bookBuyConfigEntity.getMoney());
transactionDetailsEntity.setUserId(user.getId());
transactionDetailsEntity.setUserName(user.getNickname());
transactionDetailsEntity.setChangeAmount(amount.negate());
transactionDetailsEntity.setUserBalance(user.getPeanutCoin());
transactionDetailsEntity.setTel(user.getTel());
transactionDetailsEntity.setOrderType("购买会员!");
transactionDetailsService.save(transactionDetailsEntity);
userService.openMember(userId,Integer.valueOf(month));
// 插入 开通记录
buyOrderService.updateOrderStatus(userId,orderSn,"2");
}else{
return R.error(500,"余额不足,请检查后操作!");
}
return R.ok();
}
/**
* @Description: app微信登陆
* @Author: z.hw
*/
@RequestMapping("/appUserAuthorLogin")
// @ApiOperation(value = "getUserInfoByAppCode", notes = "不分页", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
// @ApiResponses(value = {
// @ApiResponse(code = 404, message = "Not Found"),
// @ApiResponse(code = 400, message = "No Name Provided"),
// })
public R getUserInfoByApp(@Validated @RequestBody UserAppAuthorEntity userAppAuthorEntity) {
return userService.getUserInfoByApp(userAppAuthorEntity);
}
}

View File

@@ -74,7 +74,6 @@ public class OrderCartController {
// @RequiresPermissions("book:ordercart:update")
public R update(@RequestBody OrderCartEntity orderCart){
orderCartService.updateById(orderCart);
return R.ok();
}
@@ -96,7 +95,6 @@ public class OrderCartController {
// @RequiresPermissions("book:ordercart:delete")
public R getCartList(@RequestParam("userId") Integer userId){
List<ShopCartVo> cartList = orderCartService.getCartList(userId);
return R.ok().put("cartList",cartList);
}

View File

@@ -101,6 +101,7 @@ public class PublisherController {
@RequestMapping("/save")
@RequiresPermissions("book:publisher:save")
public R save(@RequestBody PublisherEntity publisher){
publisher.setDelFlag(0);
publisherService.save(publisher);
return R.ok();

View File

@@ -116,7 +116,6 @@ public class ShopCategoryController {
@RequestMapping("/getOneLevel")
public R getOneLevel(){
List<ShopCategoryEntity> list = shopCategoryService.getOneLevel();
return R.ok().put("list",list);
}
@@ -127,7 +126,6 @@ public class ShopCategoryController {
@RequestMapping("/getTwoLevel")
public R getTwoLevel(@RequestParam("catId") Integer catId){
List<ShopCategoryEntity> list = shopCategoryService.getTwoLevel(catId);
return R.ok().put("list",list);
}

View File

@@ -1,22 +1,20 @@
package com.peanut.modules.book.controller;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.peanut.modules.book.entity.BookEntity;
import com.peanut.modules.book.entity.BuyOrderDetailEntity;
import com.peanut.modules.book.service.BookService;
import com.peanut.modules.book.service.BuyOrderDetailService;
import com.peanut.modules.book.service.ShopCategoryService;
import com.peanut.modules.book.vo.ShopProductVo;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.peanut.modules.book.entity.ShopProductEntity;
import com.peanut.modules.book.service.ShopProductService;
import com.peanut.common.utils.PageUtils;
@@ -38,7 +36,10 @@ public class ShopProductController {
private ShopProductService shopProductService;
@Autowired
private ShopCategoryService shopCategoryService;
@Autowired
private BuyOrderDetailService buyOrderDetailService;
@Autowired
private BookService bookService;
/**
* 列表
*/
@@ -46,45 +47,209 @@ public class ShopProductController {
// @RequiresPermissions("book:shopproduct:list")
public R list(@RequestParam Map<String, Object> params){
PageUtils page = shopProductService.queryPage(params);
return R.ok().put("page", page);
}
/**
* 列表
*/
@RequestMapping("/selectList")
public R selectList(@RequestParam Map<String, Object> params){
PageUtils page = shopProductService.selectListqueryPage(params);
return R.ok().put("page", page);
}
//新书
@RequestMapping("/getNewBook")
public R getNewBook(@RequestParam Map<String, Object> params) {
PageUtils page = shopProductService.getNewBook(params);
return R.ok().put("page", page);
}
/**
* 未购买书列表
* @param userId 用户id
* @return
*/
//todo 9.7未调试
@RequestMapping("/booklist")
public R booklistss(@RequestParam("userId") Integer userId
) {
//查询已购买的书籍
List<BuyOrderDetailEntity> buyOrderDetailEntities = buyOrderDetailService.getBaseMapper().selectList(new QueryWrapper<BuyOrderDetailEntity>()
.eq("user_id", userId));
//hashset不重复 且无序
Set<String> purchasedProductIds = new HashSet<>();
ArrayList<Object> list = new ArrayList<>();
Map<String, Object> map = new HashMap<>();
for (BuyOrderDetailEntity buyOrderDetailEntity : buyOrderDetailEntities) {
map.put("ProductId", String.valueOf(buyOrderDetailEntity.getProductId()));
list.add(map);
//去重取出以后买书籍的id
purchasedProductIds.add(String.valueOf(buyOrderDetailEntity.getProductId()));
}
//查询商品表并过滤已购买商品id,根据时间倒叙展示
List<ShopProductEntity> allProductEntities = shopProductService.getBaseMapper().selectList(new QueryWrapper<ShopProductEntity>()
.notIn("product_id", purchasedProductIds)
.orderByDesc("create_time")
// .notLike("book_ids",",")
.isNotNull("book_ids")
);
List lists = new ArrayList<>();
for (ShopProductEntity product : allProductEntities) {
Map<String, Object> productMap = new HashMap<>();
productMap.put("product",product);
lists.add(productMap);
}
return R.ok().put("pages", lists); // 返回未购买的书籍分页
}
@RequestMapping("/bookinfo/{productId}")
public R bookinfo(@PathVariable("productId") Integer productId){
ShopProductEntity shopProductEntity = shopProductService.getBaseMapper().selectOne(new QueryWrapper<ShopProductEntity>().eq("book_ids", productId));
Integer poid = shopProductEntity.getProductPid();
List<Integer> poids = shopCategoryService.findPoid(poid);
shopProductEntity.setPoids(poids);
ArrayList<String> list = new ArrayList<>();
String bookId = shopProductEntity.getBookId();
list.add(bookId);
shopProductEntity.setBookids(list);
String bookId1 = shopProductEntity.getBookId();
ArrayList<Map<String, String>> imagesUrl = new ArrayList<Map<String,String>>();
for(String s : bookId1.split(",")){
if(null != s && !"".equals(s)){
BookEntity book = this.bookService.getById(s);
Map<String, String> urlMap = new HashMap<String, String>();
// urlMap.put("",s,book.getImages());
urlMap.put("id",s);
urlMap.put("images",book.getImages());
urlMap.put("name",book.getName());
imagesUrl.add(urlMap)
;
}
}
shopProductEntity.setBookidsimages(imagesUrl);
return R.ok().put("shopProduct", shopProductEntity);
}
/**
* 信息
* @param productId
* @return
*/
@RequestMapping("/info/{productId}")
// @RequiresPermissions("book:shopproduct:info")
public R info(@PathVariable("productId") Integer productId){
ShopProductEntity shopProduct = shopProductService.getById(productId);
Integer poid = shopProduct.getProductPid();
ShopProductEntity shopProductEntity = shopProductService.getBaseMapper().selectOne(new QueryWrapper<ShopProductEntity>().eq("product_id", productId));
Integer poid = shopProductEntity.getProductPid();
String bookids = shopProductEntity.getBookId();
List<Integer> poids = shopCategoryService.findPoid(poid);
shopProduct.setPoids(poids);
return R.ok().put("shopProduct", shopProduct);
shopProductEntity.setPoids(poids);
ArrayList<String> list = new ArrayList<>();
String bookId = shopProductEntity.getBookId();
list.add(bookId);
shopProductEntity.setBookids(list);
String bookId1 = shopProductEntity.getBookId();
ArrayList<Map<String, String>> imagesUrl = new ArrayList<Map<String,String>>();
ArrayList<Map<String, String>> imagesUrls = new ArrayList<Map<String,String>>();
Boolean canListen=null;
for(String s : bookId1.split(",")){
if(null != s && !"".equals(s)){
BookEntity book = this.bookService.getById(s);
String canListen1 =String.valueOf(book.getCanListen()) ;
Map<String, String> urlMap = new HashMap<String, String>();
urlMap.put("id",s);
//如果图书删除了,商品页面会报错
urlMap.put("images",book.getImages());
urlMap.put("name",book.getName());
urlMap.put("canListen",canListen1);
imagesUrl.add(urlMap)
;
}
}
shopProductEntity.setBookidsimages(imagesUrl);
return R.ok().put("shopProduct", shopProductEntity);
}
/**
* 保存
*/
@RequestMapping("/save")
// @RequiresPermissions("book:shopproduct:save")
public R save(@RequestBody ShopProductEntity shopProduct){
shopProduct.setCreateTime(new Date());
//用list集合接收数组转String类型字符串
String bkids = "";
for(String s : shopProduct.getBookids()){
bkids += s+",";
}
if (bkids!=null &&!bkids.isEmpty()){
String substring = bkids.substring(0, bkids.length() - 1);
shopProduct.setBookId(substring);
}
shopProduct.setBookId("");
shopProduct.setCreateTime(new Date());
shopProductService.save(shopProduct);
return R.ok();
}
/**
* 修改
*/
@RequestMapping("/update")
// @RequiresPermissions("book:shopproduct:update")
@RequestMapping("/update")
public R update(@RequestBody ShopProductEntity shopProduct){
shopProductService.updateById(shopProduct);
String bkids = "";
for(String s : shopProduct.getBookids()){
bkids += s+",";
}
if (bkids!=null &&!bkids.isEmpty()){
String substring = bkids.substring(0, bkids.length() - 1);
shopProduct.setBookId(substring);
}else {
shopProduct.setBookId("");
}
shopProductService.updateById(shopProduct);
return R.ok();
}
@@ -115,8 +280,10 @@ public class ShopProductController {
*/
@RequestMapping("/appGetCategoryList")
public R appGetCategoryList(@RequestParam("catId") Integer catId){
if(catId == 0){
catId = null;
}
List<ShopProductEntity> list = shopProductService.appGetCategoryList(catId);
return R.ok().put("list", list);
}

View File

@@ -1,53 +1,135 @@
package com.peanut.modules.book.controller;
import java.util.Arrays;
import java.util.Map;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.peanut.modules.book.entity.UserEbookBuyEntity;
import com.peanut.modules.book.service.UserEbookBuyService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.peanut.common.utils.PageUtils;
import com.peanut.common.utils.R;
import com.peanut.modules.book.entity.BookEntity;
import com.peanut.modules.book.entity.UserEbookBuyEntity;
import com.peanut.modules.book.service.BookService;
import com.peanut.modules.book.service.UserEbookBuyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.*;
/**
* 用户购买书籍表
*
* @author yl
* @email yl328572838@163.com
* @date 2022-10-18 16:28:20
*
*/
@RestController
@RequestMapping("book/userebookbuy")
public class UserEbookBuyController {
@Autowired
private UserEbookBuyService userEbookBuyService;
@Autowired
private BookService bookService;
/**
* 列表
*/
@RequestMapping("/list")
// @RequiresPermissions("book:userebookbuy:list")
public R list(@RequestParam Map<String, Object> params){
String userId = (String) params.get("userId");
PageUtils page = userEbookBuyService.queryPage(params);
return R.ok().put("page", page);
}
/**
* 列表
*/
@RequestMapping("/appbooklist")
public R appbooklist(@RequestParam("userId") Integer userId) {
String user = String.valueOf(userId);
ArrayList<Object> maplist = new ArrayList<>();
ArrayList<Integer> list = new ArrayList<>();
List<UserEbookBuyEntity> user_id = userEbookBuyService.getBaseMapper().selectList(new QueryWrapper<UserEbookBuyEntity>().eq("user_id", user));
if (user_id==null){
return R.error("您打卡列表暂未添加内容");
}
for (UserEbookBuyEntity userEbookBuyEntity : user_id) {
Integer bookId = userEbookBuyEntity.getBookId();
list.add(bookId);
}
int index =0;
for (Object S : list) {
List<BookEntity> books = bookService.getBaseMapper().selectList(new QueryWrapper<BookEntity>()
.eq("clock_in", 1)
.eq("id", S));
for (BookEntity book : books) {
Map<String,Object> map = new HashMap<>();
Integer id = book.getId();
map.put("book",book);
index++;
maplist.add(map);
}
}
if (maplist==null&&maplist.size() > 0){
return R.error("您暂未参与打卡");
}
return R.ok().put("resultlist",maplist).put("total",index);
}
@RequestMapping("/buylist")
public R buylist(@RequestParam Map<String, Object> params){
String userId = (String) params.get("id");
List list = new ArrayList<>();
List<UserEbookBuyEntity> user_id = userEbookBuyService.getBaseMapper().selectList(new QueryWrapper<UserEbookBuyEntity>().eq("user_id", userId));
for (UserEbookBuyEntity userEbookBuyEntity : user_id) {
Map<String, Object> map = new HashMap<>();
Integer bookId = userEbookBuyEntity.getBookId();
Integer userId1 = userEbookBuyEntity.getUserId();
String bookName = userEbookBuyEntity.getBookName();
Integer buyId = userEbookBuyEntity.getBuyId();
String image = userEbookBuyEntity.getImage();
String author = userEbookBuyEntity.getAuthor();
List<BookEntity> id = bookService.getBaseMapper().selectList(new QueryWrapper<BookEntity>().eq("id", bookId));
for (BookEntity bookEntity : id) {
String name = bookEntity.getName();
Boolean canListen = bookEntity.getCanListen();
map.put("canListen", canListen);
map.put("bookId",bookId);
map.put("userId",userId1);
map.put("bookName",bookName);
map.put("buyId",buyId);
map.put("image",image);
map.put("author",author);
list.add(map);
}
}
Collections.reverse(list);
return R.ok().put("page", list);
}
/**
* 信息
*/
@RequestMapping("/info/{buyId}")
// @RequiresPermissions("book:userebookbuy:info")
public R info(@PathVariable("buyId") Integer buyId){
UserEbookBuyEntity userEbookBuy = userEbookBuyService.getById(buyId);
@@ -58,8 +140,8 @@ public class UserEbookBuyController {
* 保存
*/
@RequestMapping("/save")
// @RequiresPermissions("book:userebookbuy:save")
public R save(@RequestBody UserEbookBuyEntity userEbookBuy){
userEbookBuyService.save(userEbookBuy);
return R.ok();
@@ -69,7 +151,6 @@ public class UserEbookBuyController {
* 修改
*/
@RequestMapping("/update")
// @RequiresPermissions("book:userebookbuy:update")
public R update(@RequestBody UserEbookBuyEntity userEbookBuy){
userEbookBuyService.updateById(userEbookBuy);
@@ -80,7 +161,6 @@ public class UserEbookBuyController {
* 删除
*/
@RequestMapping("/delete")
// @RequiresPermissions("book:userebookbuy:delete")
public R delete(@RequestBody Integer[] buyIds){
userEbookBuyService.removeByIds(Arrays.asList(buyIds));

View File

@@ -13,5 +13,7 @@ import org.apache.ibatis.annotations.Mapper;
*/
@Mapper
public interface MyUserDao extends BaseMapper<MyUserEntity> {
void update(MyUserEntity user);
}

View File

@@ -53,7 +53,6 @@ public class BookBrowseRecordsEntity implements Serializable {
/**
* 图片
*/
@TableField(exist = false)
private String images;
/**
* 创建时间

View File

@@ -8,7 +8,7 @@ import lombok.Data;
/**
*
*
* 章节表
* @author yl
* @email yl328572838@163.com
* @date 2022-08-12 09:53:25
@@ -39,6 +39,8 @@ public class BookChapterEntity implements Serializable {
* 内容
*/
private String content;
/**
* 音频文件地址
*/
@@ -54,7 +56,7 @@ public class BookChapterEntity implements Serializable {
@TableField(fill = FieldFill.INSERT_UPDATE)//更新注解
private Date updateTime;
/**
*
* 0免费1限制
*/
private Integer sort;
/**
@@ -63,4 +65,10 @@ public class BookChapterEntity implements Serializable {
@TableLogic
private Integer delFlag;
@TableField(exist = false)
private String picAndWord;
}

View File

@@ -112,6 +112,10 @@ public class BookEntity implements Serializable {
* 音频处理状态 0-未处理 1-处理中 2-成功 3-失败
*/
private String voicesStatus;
/**
* 1为标题拆分2为小节拆分
*/
private String splits;
/**
* 创建日期
*/
@@ -153,4 +157,13 @@ public class BookEntity implements Serializable {
@TableField(exist = false)
private Integer isBuy;
@TableField("can_listen")
private Boolean canListen;
private Integer clockIn;
}

View File

@@ -10,6 +10,8 @@ import java.io.Serializable;
import java.util.Date;
import lombok.Data;
import javax.xml.soap.Text;
/**
* 商品订单详情表
*
@@ -102,5 +104,7 @@ public class BuyOrderDetailEntity implements Serializable {
* 商品图片地址
*/
private String productUrl;
@TableField("record_id")
private Integer recordId;
}

View File

@@ -66,7 +66,7 @@ public class BuyOrderEntity implements Serializable {
*/
private String address;
/**
* 支付方式 1支付宝2微信3ios内购
* 支付方式 1支付宝2微信3ios内购 4虚拟币
*/
private String paymentMethod;
/**
@@ -173,6 +173,9 @@ public class BuyOrderEntity implements Serializable {
* 支付时间
*/
private Date paymentDate;
@TableField("product_id")
private String productId;
@TableField("record_id")
private Integer recordId;
}

View File

@@ -3,6 +3,7 @@ package com.peanut.modules.book.entity;
import com.baomidou.mybatisplus.annotation.*;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import lombok.Data;
@@ -66,7 +67,7 @@ public class MyUserEntity implements Serializable {
/**
* 花生币
*/
private Integer peanutCoin;
private BigDecimal peanutCoin;
/**
* 阅读时间
*/
@@ -106,4 +107,7 @@ public class MyUserEntity implements Serializable {
@TableField(exist = false)
private Integer conponsCount;
private String remark;
}

View File

@@ -62,4 +62,8 @@ public class PayPaymentOrderEntity implements Serializable {
@TableField(fill = FieldFill.INSERT_UPDATE)
private Date successTime;
private String userName;
private String tel;
}

View File

@@ -3,7 +3,10 @@ package com.peanut.modules.book.entity;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import org.joda.time.DateTime;
import javax.persistence.Column;
import javax.xml.soap.Text;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
@@ -72,4 +75,7 @@ public class PayWechatOrderEntity implements Serializable {
private Integer buyOrderId;
// private Date endtime;
}

View File

@@ -25,51 +25,57 @@ public class PayZfbOrderEntity implements Serializable {
@TableId
private Long id;
/**
*
* 唯一标识符。 这个标识符可以用来识别特定的用户并进行相关的操作。 通过微信的开放接口来获取用户的customerOid字段。
*/
private String customerid;
/**
*
* 支付宝生成的商户订单号,用于唯一标识一笔交易。商户需要保证商户订单号在自身系统中唯一,且不重复。
*/
private String outTradeNo;
/**
*
* 订单号 支付宝交易号
*/
private String tradeNo;
/**
*
* 异步通知时间指示支付宝服务器向商户发送异步通知的时间。该字段的格式为yyyy-MM-dd HH:mm:ss。
*/
private Date notifyTime;
/**
*
* 支付宝用于标识当前异步通知的类型的字段。具体来说,
* 该字段的值表示当前异步通知的类型,例如交易支付成功、退款成功等。通过这个字段,开发者可以根据不同的类型进行不同的业务处理。
*/
private String notifyType;
/**
*
* 服务器用来标识该交易的唯一性的一个参数也就是交易通知中的ID。当商户接收到支付宝服务器的交易通知消息之后
* 可以通过该参数来判断本次通知是否是重复通知如果notifyId已经被处理过那么就可以忽略该交易通知以避免重复处理。
*/
private String notifyId;
/**
*
* appid
*/
private String appId;
/**
*
* 标识授权商户的AppId即在支付宝开放平台创建的应用的AppId。
* 在接入支付宝支付时商户需要使用自己的AppId进行授权将authAppId字段设置为正确的值
* 以确保支付宝能够正确地识别授权商户的身份。
*/
private String authAppId;
/**
/**charset字段在支付宝支付中是用来指定商户网站使用的编码格式它主要是用来解决中文乱码的问题。
* 当商户在支付宝平台上进行支付接口的对接时,
* 需要将charset字段设置为UTF-8编码格式以确保交易信息能够正常传输和处理
*
*/
private String charset;
/**
*
表示接口的版本号
*/
private String version;
/**
*
* 指定签名算法类型。在请求支付宝接口时,需要使用商户私钥对请求参数进行签名,以确保请求参数的完整性和安全性
*/
private String signType;
/**
*
* 签名
*/
private String sign;
/**
@@ -125,7 +131,8 @@ public class PayZfbOrderEntity implements Serializable {
*/
private String subject;
/**
*
* 支付宝支付中的Body字段主要用于传输具体的交易信息例如商品详情、价格、数量等。在调用支付宝支付接口时
* 开发者需要将交易相关的信息以JSON字符串的形式作为Body字段传递给支付宝接口以便支付宝服务器能够正确处理该笔交易。
*/
private String body;
/**

View File

@@ -49,6 +49,7 @@ public class PublisherEntity implements Serializable {
* 删除标记
*/
@TableLogic
private Integer delFlag;
}

View File

@@ -1,5 +1,6 @@
package com.peanut.modules.book.entity;
import com.baomidou.mybatisplus.annotation.FieldStrategy;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
@@ -8,6 +9,8 @@ import java.math.BigDecimal;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import lombok.Data;
@@ -36,6 +39,10 @@ public class ShopProductEntity implements Serializable {
* 商品价格
*/
private BigDecimal price;
/**
* 商品价格
*/
private BigDecimal activityPrice;
/**
* 商品重量
*/
@@ -102,7 +109,8 @@ public class ShopProductEntity implements Serializable {
/**
* 出版时间
*/
private Date pubDate;
@TableField(value = "pub_date" , updateStrategy = FieldStrategy.IGNORED)
private String pubDate;
/**
* 开本
*/
@@ -110,6 +118,7 @@ public class ShopProductEntity implements Serializable {
/**
* 页数
*/
@TableField(value = "page_num" , updateStrategy = FieldStrategy.IGNORED)
private Integer pageNum;
/**
* 内文用纸材质
@@ -120,8 +129,38 @@ public class ShopProductEntity implements Serializable {
*/
private Integer sumSales;
/**
* 商品类型
* 商品类型 1: 画册 2书 3仪器4预售书
*/
private String goodsType;
private String goodsTypeCode;
/**
* 是否包邮 0包邮 1不包邮
*/
private Object isFreeMail;
/**
* 绑定电子书id,
*/
@TableField("book_ids")
private String bookId;
/**
* 多个电子书Id
*/
@TableField(exist = false)
private ArrayList<String> bookids;
/**
* 多个电子书Id
*/
@TableField(exist = false)
private ArrayList<Map<String,String>> bookidsimages;
// private Object bookidsimages;
//
//e
}

View File

@@ -55,4 +55,10 @@ public class TransactionDetailsEntity implements Serializable {
@TableField(fill = FieldFill.INSERT)//创建注解
private Date createTime;
private String userName;
private String tel;
private String note;
}

View File

@@ -58,4 +58,6 @@ public class UserEbookBuyEntity implements Serializable {
private String author;
private String ordersn;
}

View File

@@ -6,6 +6,7 @@ import com.peanut.modules.book.entity.BookChapterEntity;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.util.List;
import java.util.Map;
/**
@@ -19,5 +20,9 @@ public interface BookChapterService extends IService<BookChapterEntity> {
PageUtils queryPage(Map<String, Object> params);
PageUtils queryPage1(Map<String, Object> params);
// List<BookChapterEntity> getUse(Integer userId);
List<BookChapterEntity> getUserBookChapter(Integer userId);
}

View File

@@ -21,12 +21,21 @@ public interface BookService extends IService<BookEntity> {
PageUtils getBestBook(Map<String, Object> params);
PageUtils getbooklist(Map<String, Object> params);
PageUtils getNewBook(Map<String, Object> params);
PageUtils getSaleBook(Map<String, Object> params);
//获取Word电子书章节
boolean getWordChapter(Integer bookId);
//获取Word电子书章节并按照章节保存内容
boolean getWord(Integer bookId);
//获取Word电子书章按照章节中小节拆分
boolean getWordSection (Integer bookId);
}

View File

@@ -20,5 +20,7 @@ public interface BookShelfService extends IService<BookShelfEntity> {
PageUtils queryPage(Map<String, Object> params);
List<BookShelfVo> getUserBookshelf(Integer userId);
List<BookShelfVo> getUserBookChapterRead(Integer userId);
}

View File

@@ -19,6 +19,9 @@ public interface BuyOrderDetailService extends IService<BuyOrderDetailEntity> {
PageUtils querySheet(Map<String, Object> params);
PageUtils querybuy(Map<String,Object>params);
PageUtils querybuyss(Map<String,Object>params);
public void batchUpdateByShippingSns(String[] shippingSnList);
}

View File

@@ -4,8 +4,10 @@ import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.peanut.common.utils.PageUtils;
import com.peanut.common.utils.R;
import com.peanut.modules.book.entity.BuyOrderEntity;
import javax.xml.soap.Text;
import java.util.List;
import java.util.Map;
@@ -18,7 +20,7 @@ import java.util.Map;
*/
public interface BuyOrderService extends IService<BuyOrderEntity> {
PageUtils queryPage(Map<String, Object> params);
PageUtils queryPage(Map<String, Object> params) throws Exception;
PageUtils queryPage1(Map<String, Object> params);
//更新订单状态
@@ -40,10 +42,19 @@ public interface BuyOrderService extends IService<BuyOrderEntity> {
public Page checkOrder(Map<String, Object> params);
// 批量发货功能
public void blendSendFMS(Integer[] orderDetailIds,String shipperCode,String shipperName);
public void blendSendFMS(Integer[] orderDetailIds, String shipperCode, String shipperName);
public int getProductGoodsType (Map<String, Object> param,Map<String, Object> productMap);
public R randomOrderCode( BuyOrderEntity buyOrder);
PageUtils querySheet(Map<String, Object> params);
PageUtils queryPages(Map<String, Object> params);
}

View File

@@ -2,9 +2,12 @@ package com.peanut.modules.book.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.peanut.common.utils.PageUtils;
import com.peanut.common.utils.R;
import com.peanut.modules.book.entity.MyUserEntity;
import com.peanut.modules.book.entity.UserAppAuthorEntity;
import org.springframework.context.annotation.Lazy;
import javax.persistence.Entity;
import java.util.Map;
/**
@@ -14,6 +17,7 @@ import java.util.Map;
* @email yl328572838@163.com
* @date 2022-08-10 14:20:12
*/
public interface MyUserService extends IService<MyUserEntity> {
PageUtils queryPage(Map<String, Object> params);
@@ -21,11 +25,20 @@ public interface MyUserService extends IService<MyUserEntity> {
void sendCodeForRegister(String phone, String code) throws Exception;
boolean bookAuthenticate(Integer bookId,Integer userId);
//电子书鉴权
boolean bookAuthenti(Integer bookId,Integer userId);
//会员开通 电话 开通 期限
boolean openMember(Integer customerId,Integer openMonth);
//充值花生币
boolean rechargeHSPoint(Integer customerId,Integer HSPoint);
//电子书购买
String buyEbook(String userId, String bookId,String couponId);
void update (MyUserEntity user);
//第三方微信登录
R getUserInfoByApp(UserAppAuthorEntity userAppAuthorEntity);
boolean bookEbookBuy(Integer bookid,Integer userId);
}

View File

@@ -27,5 +27,7 @@ public interface ShopCategoryService extends IService<ShopCategoryEntity> {
List<ShopCategoryEntity> getOneLevel();
List<ShopCategoryEntity> getTwoLevel(Integer catId);
List<String> findBookId(String bookId);
}

View File

@@ -18,9 +18,14 @@ public interface ShopProductService extends IService<ShopProductEntity> {
PageUtils queryPage(Map<String, Object> params);
PageUtils appQueryPage(Map<String, Object> params);
List<ShopProductEntity> appGetCategoryList(Integer catId);
PageUtils getNewBook(Map<String, Object> params);
PageUtils selectListqueryPage(Map<String, Object> params);
}

View File

@@ -16,5 +16,16 @@ import java.util.Map;
public interface UserEbookBuyService extends IService<UserEbookBuyEntity> {
PageUtils queryPage(Map<String, Object> params);
PageUtils queryPages(Map<String, Object> params);
}

View File

@@ -1,11 +1,13 @@
package com.peanut.modules.book.service.impl;
import com.peanut.modules.book.vo.BookShelfVo;
import org.springframework.stereotype.Service;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -24,13 +26,44 @@ public class BookChapterServiceImpl extends ServiceImpl<BookChapterDao, BookChap
@Override
public PageUtils queryPage(Map<String, Object> params) {
Object bookid = params.get("bookid");
IPage<BookChapterEntity> page = this.page(
new Query<BookChapterEntity>().getPage(params),
new QueryWrapper<BookChapterEntity>().eq("book_id",params.get("bookid"))
//8.24修改根据number升序 排序
new QueryWrapper<BookChapterEntity>().eq("book_id",bookid).orderByAsc("number")
);
return new PageUtils(page);
}
@Override
public PageUtils queryPage1(Map<String, Object> params) {
Object chapterid = params.get("chapterid");
System.out.println(chapterid);
IPage<BookChapterEntity> page = this.page(
new Query<BookChapterEntity>().getPage(params),
new QueryWrapper<BookChapterEntity>().eq("book_id",params.get("bookid"))
.eq("number",params.get("number"))
);
return new PageUtils(page);
}
@Override
public List<BookChapterEntity> getUserBookChapter(Integer userId) {
return null;
}
}

View File

@@ -5,8 +5,7 @@ import com.aliyun.oss.OSSClientBuilder;
import com.aliyun.oss.OSSException;
import com.aliyun.oss.model.OSSObject;
import com.google.common.base.Joiner;
import com.peanut.common.utils.ConstantPropertiesUtils;
import com.peanut.common.utils.FileDownloadUtil;
import com.peanut.common.utils.*;
import com.peanut.modules.book.entity.*;
import com.peanut.modules.book.entity.SysDictDataEntity;
import com.peanut.modules.book.service.BookChapterContentService;
@@ -18,10 +17,12 @@ import com.spire.doc.Document;
import com.spire.doc.Section;
import com.spire.doc.documents.Paragraph;
import org.apache.commons.lang.StringUtils;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URLDecoder;
@@ -32,8 +33,6 @@ import java.util.regex.Pattern;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.peanut.common.utils.PageUtils;
import com.peanut.common.utils.Query;
import com.peanut.modules.book.dao.BookDao;
import com.peanut.modules.book.service.BookService;
@@ -55,10 +54,6 @@ public class BookServiceImpl extends ServiceImpl<BookDao, BookEntity> implements
ConstantPropertiesUtils constantPropertiesUtils;
// String endpoint = ConstantPropertiesUtils.END_POIND;
// String accessKeyId = ConstantPropertiesUtils.ACCESS_KEY_ID;
// String accessKeySecret = ConstantPropertiesUtils.ACCESS_KEY_SECRET;
// String bucketName = ConstantPropertiesUtils.BUCKET_NAME;
@Override
@@ -80,10 +75,11 @@ public class BookServiceImpl extends ServiceImpl<BookDao, BookEntity> implements
new Query<BookEntity>().getPage(params),
new QueryWrapper<BookEntity>()
.like(StringUtils.isNotBlank(bookName), "name", bookName)
.eq(StringUtils.isNotBlank(state),"state",state)
.apply(StringUtils.isNotBlank(typeC),"FIND_IN_SET ("+ typeC +",type)")
.apply(StringUtils.isNotBlank(publisherName1) , "FIND_IN_SET((SELECT id FROM publisher WHERE publisher_name LIKE concat( '%','" + publisherName1 + "','%')),publisher_id)")
.apply(StringUtils.isNotBlank(authorName1),"FIND_IN_SET((SELECT id FROM author WHERE author_name LIKE concat( '%','" + authorName1 + "','%')),author_id)")
.eq(StringUtils.isNotBlank(state), "state", state)
.orderByDesc("create_time")
.apply(StringUtils.isNotBlank(typeC), "FIND_IN_SET (" + typeC + ",type)")
.apply(StringUtils.isNotBlank(publisherName1), "FIND_IN_SET((SELECT id FROM publisher WHERE publisher_name LIKE concat( '%','" + publisherName1 + "','%')),publisher_id)")
.apply(StringUtils.isNotBlank(authorName1), "FIND_IN_SET((SELECT id FROM author WHERE author_name LIKE concat( '%','" + authorName1 + "','%')),author_id)")
);
for (BookEntity book : page.getRecords()) {
String authorName = "";
@@ -115,7 +111,7 @@ public class BookServiceImpl extends ServiceImpl<BookDao, BookEntity> implements
for (String tp : split) {
SysDictDataEntity dict = sysDictDataService.getBaseMapper().selectOne(new QueryWrapper<SysDictDataEntity>()
.eq("dict_type", tp).eq("dict_label", "book_type"));
if(dict != null){
if (dict != null) {
list.add(dict.getDictValue());
}
}
@@ -236,7 +232,6 @@ public class BookServiceImpl extends ServiceImpl<BookDao, BookEntity> implements
indexOf = newStr.indexOf(newChapterName);
// System.out.println(newChapterName + ":" + "第" + count + "行"); // 得到返回的章
if (bflag) {
bflag = false;
@@ -259,9 +254,9 @@ public class BookServiceImpl extends ServiceImpl<BookDao, BookEntity> implements
content.setContent(substring.trim());
content.setBookId(bookEntityId);
content.setNumber(++linecount);
// System.out.println(substring);
System.out.println(substring);
// contentList.add(substring);
// System.out.println(content.toString());
System.out.println(content.toString());
bookChapterService.save(content);
}
@@ -275,12 +270,11 @@ public class BookServiceImpl extends ServiceImpl<BookDao, BookEntity> implements
// 致请求无连接可用,程序无法正常工作。
ossObject.close();
bookEntity.setChapterStatus("2");
//
// System.out.println(chapterList);
// System.out.println(contentList);
} catch (OSSException oe) {
bookEntity.setChapterStatus("3");
System.out.println("Caught an OSSException, which means your request made it to OSS, "
@@ -309,7 +303,7 @@ public class BookServiceImpl extends ServiceImpl<BookDao, BookEntity> implements
IPage<BookEntity> page = this.page(
new Query<BookEntity>().getPage(params),
new QueryWrapper<BookEntity>().eq("state",1).eq("istop", 1).orderByDesc("sort")
new QueryWrapper<BookEntity>().eq("state", 1).eq("istop", 1).orderByDesc("sort")
);
List<BookEntity> newBookList = page.getRecords();
@@ -348,11 +342,20 @@ public class BookServiceImpl extends ServiceImpl<BookDao, BookEntity> implements
}
@Override
public PageUtils getNewBook(Map<String, Object> params) {
public PageUtils getbooklist(Map<String, Object> params) {
Object id = params.get("id");
IPage<BookEntity> page = this.page(
new Query<BookEntity>().getPage(params),
new QueryWrapper<BookEntity>().eq("id",id)
);
return new PageUtils(page);
}
@Override
public PageUtils getNewBook(Map<String, Object> params) {
IPage<BookEntity> page = this.page(
new Query<BookEntity>().getPage(params),
new QueryWrapper<BookEntity>().eq("state",1).orderByDesc("create_time")
new QueryWrapper<BookEntity>().eq("state", 1).orderByDesc("create_time")
);
List<BookEntity> newBookList = page.getRecords();
@@ -394,7 +397,7 @@ public class BookServiceImpl extends ServiceImpl<BookDao, BookEntity> implements
public PageUtils getSaleBook(Map<String, Object> params) {
IPage<BookEntity> page = this.page(
new Query<BookEntity>().getPage(params),
new QueryWrapper<BookEntity>().eq("is_sale", 1).eq("state",1).orderByDesc("sort")
new QueryWrapper<BookEntity>().eq("is_sale", 1).eq("state", 1).orderByDesc("sort")
);
List<BookEntity> newBookList = page.getRecords();
@@ -443,11 +446,15 @@ public class BookServiceImpl extends ServiceImpl<BookDao, BookEntity> implements
//遍历Paragraph每个小节下有若干段落
for (int j = 0; j < section.getParagraphs().getCount() - 1; j++) {
Paragraph paragraph = section.getParagraphs().get(j);
System.out.println(paragraph.getStyleName() + "-----");
System.out.println(paragraph.getText().trim());
System.out.println(StringUtils.isNotBlank(paragraph.getText().trim()));
//获取标题
if (paragraph.getStyleName().equals("Heading1") && StringUtils.isNotBlank(paragraph.getText().trim()))//段落样式为“标题1”的内容
// if (paragraph.getStyleName().equals("Normal") && StringUtils.isNotBlank(paragraph.getText().trim()))//段落样式为“标题1”的内容
{
num++;
//如果 是标题 1 为一级 目录
String level1 = paragraph.getText();
BookChapterEntity bookChapterEntity = new BookChapterEntity();
bookChapterEntity.setBookId(bookId);
@@ -462,5 +469,197 @@ public class BookServiceImpl extends ServiceImpl<BookDao, BookEntity> implements
return false;
}
//todo 章节拆分 按照章节保存
@Override
public boolean getWord(Integer bookId) {
BookEntity bookEntity = this.getBaseMapper().selectById(bookId);
String novel = bookEntity.getNovel();
InputStream inputStream = FileDownloadUtil.getInputStream(novel);
Document doc = new Document(inputStream);
int num = 0;
for (int i = 0; i < doc.getSections().getCount(); i++) {
Section section = doc.getSections().get(i);
//遍历Paragraph每个小节下有若干段落
for (int j = 0; j < section.getParagraphs().getCount() - 1; j++) {
//插入分页符到小节下若干段落
Paragraph paragraph = section.getParagraphs().get(j);
//插入分页符到第五个段落
// Paragraph paragraph = section.getParagraphs().get(4);
//获取标题
// int cj = 0;
// if (section.getParagraphs().get(j).getStyleName().equals("Heading2")) {
// cj = 2;
// }
// if (section.getParagraphs().get(j).getStyleName().equals("Heading3")) {
// cj = 3;
// }
// if (section.getParagraphs().get(j).getStyleName().equals("Heading4")) {
// cj = 4;
// }
// int cj= 0;
// if (section.getParagraphs().get(j).getStyleName().equals("Heading2")) {
//// cj = 2;
// }
// if(section.getParagraphs().get(j).getStyleName().equals(""))
if (paragraph.getStyleName().equals("Heading1") && StringUtils.isNotBlank(paragraph.getText().trim())) {
StringBuilder builder = new StringBuilder();
do {
builder.append(section.getParagraphs().get(j).getText());
j++;
//防止index超出异常发生
if (j >= section.getParagraphs().getCount()) {
break;
}
} while (!section.getParagraphs().get(j).getStyleName().equals("Heading1"));
//获取段落标题内容
String text = builder.toString();
num++;
//如果 是标题 1 为一级 目录
String level1 = paragraph.getText();
BookChapterEntity bookChapterEntity = new BookChapterEntity();
bookChapterEntity.setBookId(bookId);
bookChapterEntity.setNumber(num);
bookChapterEntity.setChapter(level1);
bookChapterEntity.setContent(text);
bookChapterService.save(bookChapterEntity);
}
}
}
doc.close();
return false;
}
/**
* number章节号变小节号
* 如果上传文档为只有heading1标题则按照标题1进行拆分
* 如果上传文档的heading1标题下有heading2标题则按照标题2进行拆分
* @param bookId 图书ID
*
* @return0
*/
@Override
public boolean getWordSection(Integer bookId) {
BookEntity bookEntity = this.getBaseMapper().selectById(bookId);
String novel = bookEntity.getNovel();
InputStream inputStream = FileDownloadUtil.getInputStream(novel);
Document doc = new Document(inputStream);
int nums = 0;
String title2Text = "";
int num1=0;
Map<String,List<String[]>> paraMap = new HashMap<>();
Map<String,String> headMap = new HashMap<>();
List<String> title_list = new ArrayList<>();
for (int i = 0; i < doc.getSections().getCount(); i++) {
String currentTitle = "";
Section section = doc.getSections().get(i);
for (int j = 0; j < section.getParagraphs().getCount() - 1; j++) {
Paragraph paragraph = section.getParagraphs().get(j);
if (paragraph.getStyleName().equals("Heading1") ) {
//
String textq = paragraph.getText();
currentTitle = textq;
title_list.add(currentTitle);
List<String[]> secondTitleList = new ArrayList<>();
paraMap.put(currentTitle,secondTitleList);
if(!section.getParagraphs().get(j+1).getStyleName().matches("Heading2")){
int head_index = j ;
StringBuilder builder = new StringBuilder();
do {
builder.append(section.getParagraphs().get(head_index).getText());
head_index++;
//防止index超出异常发生
if (head_index >= section.getParagraphs().getCount()) {
break;
}
} while (!section.getParagraphs().get(head_index).getStyleName().equals("Heading2"));
String head_text = builder.toString();
headMap.put(currentTitle,head_text);
}
} else if (paragraph.getStyleName().equals("Heading2") && StringUtils.isNotBlank(paragraph.getText().trim())) {
StringBuilder builder = new StringBuilder();
boolean isRun = false;
do {
if(isRun){
builder.append(section.getParagraphs().get(j).getText());
}
isRun = true;
j++;
//防止index超出异常发生
if (j >= section.getParagraphs().getCount()) {
break;
}
} while (!section.getParagraphs().get(j).getStyleName().equals("Heading2")&&!section.getParagraphs().get(j).getStyleName().equals("Heading1"));
j --;
String text = builder.toString();
nums++;
title2Text = paragraph.getText(); // 获取标题二的文本内容
if(null != title2Text && !"".equals(title2Text)){
String [] s = new String[]{title2Text,text};
paraMap.get(currentTitle).add(s);
}
}
}
}
int index = 0;
for(String title: title_list){
if(null == paraMap.get(title) || paraMap.get(title).size() == 0){
index ++ ;
BookChapterEntity bookChapterEntity = new BookChapterEntity();
bookChapterEntity.setBookId(bookId);
bookChapterEntity.setNumber(index);
bookChapterEntity.setChapter(title);
bookChapterEntity.setSort(1);
if(null != headMap.get(title)){
bookChapterEntity.setContent(headMap.get(title));
}else {
bookChapterEntity.setContent("");
}
bookChapterService.save(bookChapterEntity);
}else {
for(String[] t : paraMap.get(title)){
index ++;
BookChapterEntity bookChapterEntity = new BookChapterEntity();
bookChapterEntity.setBookId(bookId);
bookChapterEntity.setSort(2);
bookChapterEntity.setNumber(index);
bookChapterEntity.setChapter(title+","+t[0]);
bookChapterEntity.setContent(t[1]);
bookChapterService.save(bookChapterEntity);
}
}
}
return false;
}
}
}

View File

@@ -1,23 +1,19 @@
package com.peanut.modules.book.service.impl;
import com.peanut.modules.book.entity.*;
import com.peanut.modules.book.service.*;
import com.peanut.modules.book.vo.BookShelfVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.peanut.common.utils.PageUtils;
import com.peanut.common.utils.Query;
import com.peanut.modules.book.dao.BookShelfDao;
@@ -32,12 +28,14 @@ public class BookShelfServiceImpl extends ServiceImpl<BookShelfDao, BookShelfEnt
private BookReadRateService bookReadRateService;
@Autowired
private BookChapterService bookChapterService;
@Autowired
private BookListeningService bookListeningService;
@Override
public PageUtils queryPage(Map<String, Object> params) {
IPage<BookShelfEntity> page = this.page(
new Query<BookShelfEntity>().getPage(params),
new QueryWrapper<BookShelfEntity>()
new QueryWrapper<BookShelfEntity>().orderByDesc("update_time")
);
return new PageUtils(page);
@@ -78,6 +76,9 @@ public class BookShelfServiceImpl extends ServiceImpl<BookShelfDao, BookShelfEnt
BookReadRateEntity bookReadRateEntity = bookReadRateService.getBaseMapper().selectOne(new QueryWrapper<BookReadRateEntity>()
.eq("user_id", userId)
.eq("book_id", bookid));
// BookReadRateEntity bookReadRateEntity = bookReadRateService.getOne(new QueryWrapper<BookReadRateEntity>()
// .eq("user_id", userId)
// .eq("book_id", bookid));
String percent = "";
if (bookReadRateEntity == null) {
@@ -87,7 +88,7 @@ public class BookShelfServiceImpl extends ServiceImpl<BookShelfDao, BookShelfEnt
String chapterName = bookReadRateEntity.getChapterName();
//4. 根据 章节id 去书籍表查询
BookChapterEntity bookChapterEntity = bookChapterService.getBaseMapper().selectById(chapterId);
BookChapterEntity bookChapterEntity = bookChapterService.getBaseMapper().selectById(bookReadRateEntity.getContentId());
if (bookChapterEntity == null) {
percent = "0%";
}else {
@@ -100,6 +101,8 @@ public class BookShelfServiceImpl extends ServiceImpl<BookShelfDao, BookShelfEnt
if (idNumber == 0){
percent = "0%";
}else {
//todo 章节号等于3 idnumber章节数13 3除以13等于阅读进度
float xx = (float)number / idNumber;
DecimalFormat df = new DecimalFormat("##.00%");
@@ -131,4 +134,100 @@ public class BookShelfServiceImpl extends ServiceImpl<BookShelfDao, BookShelfEnt
return list;
}
@Override
public List<BookShelfVo> getUserBookChapterRead(Integer userId) {
List list = new ArrayList();
//1.获取 用户的 书架列表
List<BookShelfEntity> bookShelf = this.baseMapper.selectList(new QueryWrapper<BookShelfEntity>().eq("user_id", userId).orderByDesc("update_time"));
//2. 遍历 获取书 的 详情
for (BookShelfEntity bookShelfEntity : bookShelf) {
String authorName = "";
Integer bookid = bookShelfEntity.getBookId();
BookShelfVo bookShelfVo = new BookShelfVo();
BookEntity bookEntity = bookService.getBaseMapper().selectById(bookid);
String name = bookEntity.getName();
String images = bookEntity.getImages();
String authorId = bookEntity.getAuthorId();
String[] authorIds = authorId.split(",");
List<String> authorList = Arrays.asList(authorIds);
List<AuthorEntity> authorEntities = authorService.getBaseMapper().selectList(new QueryWrapper<AuthorEntity>().in("id", authorList));
for (AuthorEntity authorEntity : authorEntities) {
authorName += "," + authorEntity.getAuthorName();
}
authorName = authorName.startsWith(",") ? authorName.substring(1) : authorName;
//3. 根据 userid bookid 查询书籍 阅读进度
// BookReadRateEntity bookReadRateEntity = bookReadRateService.getBaseMapper().selectOne(new QueryWrapper<BookReadRateEntity>()
// .eq("user_id", userId)
// .eq("book_id", bookid));
BookListeningEntity bookListeningEntity = bookListeningService.getBaseMapper().selectOne(new QueryWrapper<BookListeningEntity>()
.eq("user_id", userId)
.eq("book_id", bookid));
String percent = "";
if (bookListeningEntity == null) {
percent = "0%";
} else {
Integer chapterId = bookListeningEntity.getChapterId();
String chapterName = bookListeningEntity.getChapterName();
//4. 根据 章节id 去书籍表查询
BookChapterEntity bookChapterEntity = bookChapterService.getBaseMapper().selectById(bookListeningEntity.getContentId());
if (bookChapterEntity == null) {
percent = "0%";
}else {
Integer number = bookChapterEntity.getNumber();
BookChapterEntity book_id = bookChapterService.getBaseMapper().selectOne(new QueryWrapper<BookChapterEntity>()
.select("max(number) as number")
.eq("book_id", bookid));
Integer idNumber = book_id.getNumber();
if (idNumber == 0){
percent = "0%";
}else {
//todo 章节号等于3 idnumber章节数13 3除以13等于阅读进度
float xx = (float)number / idNumber;
DecimalFormat df = new DecimalFormat("##.00%");
// float xx = (float) number / idNumber;
// int df = (int) (xx * 3600); // 将百分比转换为秒数
if (Math.abs(xx) < 0.000000000001) {
percent = "0.00%";
} else {
percent = df.format(xx);
}
bookShelfVo.setChapterNum(number);
}
}
bookShelfVo.setChapterId(chapterId);
bookShelfVo.setChapterName(chapterName);
}
bookShelfVo.setBookShelfId(bookShelfEntity.getId());
bookShelfVo.setBookid(bookid);
bookShelfVo.setBookName(name);
bookShelfVo.setAuthorName(authorName);
bookShelfVo.setImage(images);
bookShelfVo.setPrecent(percent);
list.add(bookShelfVo);
}
return list;
}
}

View File

@@ -1,8 +1,15 @@
package com.peanut.modules.book.service.impl;
import com.peanut.modules.book.entity.BookEntity;
import com.peanut.modules.book.entity.ShopProductEntity;
import com.peanut.modules.book.service.BookService;
import com.peanut.modules.book.service.ShopProductService;
import jodd.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.awt.print.Book;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -32,6 +39,13 @@ public class BuyOrderDetailServiceImpl extends ServiceImpl<BuyOrderDetailDao, Bu
}
/**
* 去重查询未打印的面单信息
* @param params
@@ -47,6 +61,26 @@ public class BuyOrderDetailServiceImpl extends ServiceImpl<BuyOrderDetailDao, Bu
return new PageUtils(page);
}
@Override
public PageUtils querybuy(Map<String, Object> params) {
Integer userid = Integer.valueOf((String) params.get("id"));
IPage<BuyOrderDetailEntity> page = this.page(
new Query<BuyOrderDetailEntity>().getPage(params),
new QueryWrapper<BuyOrderDetailEntity>()
.eq("user_id",userid)
);
System.out.println("=====querybuy=====userid================"+userid);
return new PageUtils(page);
}
@Override
public PageUtils querybuyss(Map<String, Object> params) {
return null;
}
@Override
public void batchUpdateByShippingSns(String[] shippingSnList) {

View File

@@ -1,5 +1,6 @@
package com.peanut.modules.book.service.impl;
import cn.com.marsoft.tool.ToolObject;
import com.alibaba.druid.mock.MockConnection;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
@@ -28,6 +29,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import javax.xml.soap.Text;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
@@ -45,13 +47,16 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrderEntity
private ShopProductService shopProductService;
@Autowired
private MyUserService myUserService;
@Autowired
//todo 6.2 buyOrderDao buyOrderDetailDao因为报红把 @Autowired 换成JDK注解 @Resource它不检查所以也就不会报红。
@Resource
private BuyOrderDao buyOrderDao;
@Autowired
@Resource
private BuyOrderDetailDao buyOrderDetailDao;
@Autowired
private FMSOrderDetailService fmsOrderDetailService;
protected Logger logger = LoggerFactory.getLogger(BuyOrderServiceImpl.class);
private MockConnection connection;
@@ -148,6 +153,7 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrderEntity
// 交易失败 9
BuyOrderEntity orderEntity = this.getOne(new QueryWrapper<BuyOrderEntity>().eq("user_id", userId)
.eq("order_sn", orderSn));
if (type.equals("0")) {
orderEntity.setOrderStatus("1");
} else if (type.equals("9")) {
@@ -294,6 +300,8 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrderEntity
Map<String, Object> param = new HashMap<>();
param.put("ShipperCode", shipperCode);
param.put("LogisticCode", expNo);
//todo 如果使用顺丰需要加上CustomerName手机号后四位才可以
// param.put("CustomerName",phone)
try {
//todo expNo不等于1则执行第一个代码块否则执行第二个代码块。 5.5
// if (!expNo.equals(1)) {
@@ -309,7 +317,11 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrderEntity
return jsonObject;
}
}else {
return null;
String rntStr = KdApiEOrder.queryOrderOnlineByJson(param);
JSONObject jsonObject = JSONObject.parseObject(rntStr);
if ("true".equals(jsonObject.getString("Success"))) {
return jsonObject;
}
}
String rntStr = KdApiEOrder.queryOrderOnlineByJson(param);
@@ -520,7 +532,13 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrderEntity
BuyOrderEntity o = this.getById(fms.getOrderId());
BuyOrderDetailEntity detail = this.buyOrderDetailService.getById(fms.getDetailId());
detail.setOrderStatus("1");
detail.setFmsHtml(PrintTemplate);
if (PrintTemplate.equals(buyOrderDetailService.getById(detail))){
return;
}else {
detail.setFmsHtml(PrintTemplate);
}
// detail.setFmsHtml(PrintTemplate);
detail.setCreatTime(new Date());
detail.setShippingSn(SortingCode);
detail.setShipperCode(ShipperCode);
@@ -539,6 +557,14 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrderEntity
}
this.updateById(o);
buyOrderDao.updateById(o);
//todo 混合发货原本属于订单A的的信息无缘无故跑到订单B。或者订单C里面去
// todo 打印面单快递单号重复 主要问题在html表格里面有 可能是数据太多导致混乱把数据清除再做一次混合发货 查看错误
Map<String, Object> map = new HashMap<>();
buyOrderDetailService.querySheet(map);
}
}
@@ -656,6 +682,52 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrderEntity
}
return R.ok(Xsode) ;
}
/*
打印时查重
*/
@Override
public PageUtils querySheet(Map<String, Object> params) {
IPage<BuyOrderEntity> page = this.page(
new Query<BuyOrderEntity>().getPage(params),
new QueryWrapper<BuyOrderEntity>().eq("is_print","0")
.groupBy("shipping_sn")
);
return new PageUtils(page);
}
@Override
public PageUtils queryPages(Map<String, Object> params) {
String orderStatus = (String) params.get("orderStatus");
if (orderStatus.equals("9")) {
orderStatus = null;
}
String userId = (String) params.get("userId");
IPage<BuyOrderEntity> page = this.page(
new Query<BuyOrderEntity>().getPage(params),
new QueryWrapper<BuyOrderEntity>()
.eq("user_id", userId)
.eq(StringUtils.isNotBlank(orderStatus), "order_status", orderStatus)
.orderByDesc("create_time")
);
List<BuyOrderEntity> records = page.getRecords();
for (BuyOrderEntity buyOrderEntity : records) {
Integer orderId = buyOrderEntity.getOrderId();
List<BuyOrderDetailEntity> entities = buyOrderDetailService.getBaseMapper().selectList(new QueryWrapper<BuyOrderDetailEntity>()
.eq("order_id", orderId));
for (BuyOrderDetailEntity entity : entities) {
Integer productId = entity.getProductId();
ShopProductEntity shopPro = shopProductService.getById(productId);
entity.setImage(shopPro.getProductImages());
}
buyOrderEntity.setProducts(entities);
}
return new PageUtils(page);
}
/**
@@ -774,4 +846,4 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrderEntity
return 0;
}
}
}

View File

@@ -82,6 +82,8 @@ public class CouponHistoryServiceImpl extends ServiceImpl<CouponHistoryDao, Coup
if (!isEffective) {
couponsUser.setUseStatus(2);
needCouponsUserList.add(couponsUser); //需要更新状态的券
couponEntity.setCurrentState("2");
this.couponService.updateById(couponEntity);
}
}

View File

@@ -1,5 +1,6 @@
package com.peanut.modules.book.service.impl;
import com.peanut.common.utils.ExcludeEmptyQueryWrapper;
import com.peanut.modules.book.service.CouponHistoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -27,12 +28,12 @@ public class CouponServiceImpl extends ServiceImpl<CouponDao, CouponEntity> impl
if("0".equals(cu)){
page = this.page(
new Query<CouponEntity>().getPage(params),
new QueryWrapper<CouponEntity>()
new ExcludeEmptyQueryWrapper<CouponEntity>().like("coupon_name",params.get("key"))
);
}else{
page = this.page(
new Query<CouponEntity>().getPage(params),
new QueryWrapper<CouponEntity>().eq("current_state",cu)
new ExcludeEmptyQueryWrapper<CouponEntity>().eq("current_state",cu).like("coupon_name",params.get("key"))
);
}

View File

@@ -1,6 +1,7 @@
package com.peanut.modules.book.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.alipay.api.domain.Member;
import com.aliyun.dysmsapi20170525.models.SendSmsRequest;
import com.aliyun.dysmsapi20170525.models.SendSmsResponse;
import com.aliyun.dysmsapi20170525.models.SendSmsResponseBody;
@@ -9,7 +10,7 @@ import com.aliyun.teautil.Common;
import com.aliyun.teautil.models.RuntimeOptions;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.google.common.collect.Maps;
import com.peanut.common.utils.R;
import com.peanut.common.utils.*;
import com.peanut.config.DelayQueueConfig;
import com.peanut.modules.app.config.SMSConfig;
import com.peanut.modules.app.config.Sample;
@@ -17,19 +18,17 @@ import com.peanut.modules.book.entity.*;
import com.peanut.modules.book.service.*;
import com.peanut.modules.mq.service.RabbitMqService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.beanutils.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.util.*;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.peanut.common.utils.PageUtils;
import com.peanut.common.utils.Query;
import com.peanut.modules.book.dao.MyUserDao;
@@ -54,12 +53,14 @@ public class MyUserServiceImpl extends ServiceImpl<MyUserDao, MyUserEntity> impl
private CouponService couponService;
@Autowired
private CouponHistoryService couponHistoryService;
@Autowired
private MyUserDao myUserDao;
@Override
public PageUtils queryPage(Map<String, Object> params) {
IPage<MyUserEntity> page = this.page(
new Query<MyUserEntity>().getPage(params),
new QueryWrapper<MyUserEntity>()
new ExcludeEmptyQueryWrapper<MyUserEntity>().like("name",params.get("key")).or().eq("tel",params.get("key"))
);
return new PageUtils(page);
@@ -77,6 +78,7 @@ public class MyUserServiceImpl extends ServiceImpl<MyUserDao, MyUserEntity> impl
//查询书籍 类型
BookEntity book = bookService.getById(bookId);
Integer isVip = book.getIsVip(); // 0 - 免费 1- 会免 2 - 付费
Boolean canListen = book.getCanListen();
if (isVip == 1) {
// 查询 用户是否为 vip 0 - 普通 1- 会员
MyUserEntity myUserEntity = this.getBaseMapper().selectById(userId);
@@ -95,6 +97,7 @@ public class MyUserServiceImpl extends ServiceImpl<MyUserDao, MyUserEntity> impl
}
if (isVip == 2) {
// TODO 查询 购买表中是否有用户购买记录
TransactionDetailsEntity transactionDetailsEntity = transactionDetailsService.getBaseMapper().selectOne(new QueryWrapper<TransactionDetailsEntity>().eq("user_id", userId)
.eq("relation_id", bookId));
@@ -104,11 +107,53 @@ public class MyUserServiceImpl extends ServiceImpl<MyUserDao, MyUserEntity> impl
}
}
//vip等于3为听书付费
if (isVip == 3){
UserEbookBuyEntity userid = userEbookBuyService.getBaseMapper().selectOne(new QueryWrapper<UserEbookBuyEntity>()
.eq("user_id", userId)
.eq("book_id",bookId));
if (userid == null) {
return false;
}
}
if (canListen == true){
UserEbookBuyEntity userid = userEbookBuyService.getBaseMapper().selectOne(new QueryWrapper<UserEbookBuyEntity>()
.eq("user_id", userId)
.eq("book_id",bookId));
if (userid == null) {
return false;
}
}
return true;
}
@Override
public boolean bookAuthenti(Integer bookId, Integer userId) {
//查询书籍 类型
BookEntity book = bookService.getById(bookId);
Integer isVip = book.getIsVip(); // 0 - 免费 1- 会免 2 - 付费
UserEbookBuyEntity userid = userEbookBuyService.getBaseMapper().selectOne(new QueryWrapper<UserEbookBuyEntity>()
.eq("user_id", userId)
.eq("book_id",bookId));
System.out.println("userid==========="+userid);
if (userid == null) {
return false;
}
return true;
}
@Override
public boolean openMember(Integer customerId,Integer openMonth) {
@@ -195,8 +240,9 @@ public class MyUserServiceImpl extends ServiceImpl<MyUserDao, MyUserEntity> impl
if (user == null) {
return false;
}
Integer peanutCoin = user.getPeanutCoin();
user.setPeanutCoin(peanutCoin + HSPoint);
BigDecimal hs = new BigDecimal(HSPoint);
BigDecimal peanutCoin = user.getPeanutCoin();
user.setPeanutCoin(peanutCoin.add(hs));
this.updateById(user);
return true;
}
@@ -217,6 +263,7 @@ public class MyUserServiceImpl extends ServiceImpl<MyUserDao, MyUserEntity> impl
BigDecimal salePrice = new BigDecimal(0);
// 查询书籍 价格
BookEntity book = bookService.getById(Integer.valueOf(bookId));
@@ -240,21 +287,23 @@ public class MyUserServiceImpl extends ServiceImpl<MyUserDao, MyUserEntity> impl
//查询用户
MyUserEntity user = this.getById(Integer.valueOf(userId));
Double peanutCoin = user.getPeanutCoin() - salePrice.doubleValue();
Double peanutCoin = user.getPeanutCoin().doubleValue() - salePrice.doubleValue();
if (peanutCoin < 0) {
return "当前书籍以购买,请勿重复购买!";
}
user.setPeanutCoin(peanutCoin.intValue());
user.setPeanutCoin(new BigDecimal(peanutCoin));
this.updateById(user);
TransactionDetailsEntity detailsEntity = new TransactionDetailsEntity();
detailsEntity.setUserId(Integer.valueOf(userId));
detailsEntity.setChangeAmount(salePrice.negate());
detailsEntity.setUserBalance(new BigDecimal(user.getPeanutCoin()));
detailsEntity.setUserBalance(user.getPeanutCoin());
detailsEntity.setRemark("购买:"+book.getName());
detailsEntity.setOrderType("购买电子书");
detailsEntity.setRelationId(Integer.valueOf(bookId));
detailsEntity.setUserName(user.getNickname());
detailsEntity.setTel(user.getTel());
transactionDetailsService.save(detailsEntity);
// 插入购买记录
@@ -291,6 +340,60 @@ public class MyUserServiceImpl extends ServiceImpl<MyUserDao, MyUserEntity> impl
return "购买成功!";
}
/**
* 更新
*
* @param user
*/
@Override
public void update(MyUserEntity user) {
myUserDao.update(user);
}
/**
* 微信授权登录
*
* @param userAppAuthorEntity
*/
@Override
public R getUserInfoByApp(UserAppAuthorEntity userAppAuthorEntity) {
// todo CommConfig WeiXinParam 表未建
try {
Member member = new Member();
BeanUtils.copyProperties(userAppAuthorEntity, member);
CommConfig commConfig = new CommConfig();
//调用微信授权
// WeixinLoginUtils appWeiXinUserInfo1 = weixinLoginUtils1.getAppWeiXinUserInfo(commConfig.);
WeixinLoginUtils weixinLoginUtils = new WeixinLoginUtils();
StringBuilder stringBuilder = weixinLoginUtils.getAccessTokenBycode(commConfig.getUserAppID(), commConfig.getUserAppSecret(), userAppAuthorEntity.getCode());
if (stringBuilder != null) {
if (stringBuilder.toString().trim().contains("errcode")) {
return R.error();
}
JSONObject object = JSONObject.parseObject(stringBuilder.toString().trim());
String accessToken = object.getString("access_token"); //接口调用凭证
String openID = object.getString("openid"); //授权用户唯一标识
//获取微信用户基本信息
WeiXinParam appWeiXinUserInfo = weixinLoginUtils.getAppWeiXinUserInfo(accessToken, openID, WeiXinParam.class);
// TODO 业务逻辑
return R.ok().put("member",member);
}
} catch (Exception e) {
e.printStackTrace();
}
return R.ok("sec");
}
@Override
public boolean bookEbookBuy(Integer bookid, Integer userId) {
return false;
}
private void sendCode(String phone,String code) throws Exception {
com.aliyun.dysmsapi20170525.Client client = Sample.createClient(smsConfig.getAccessKeyId(),smsConfig.getAccessKeySecret());

View File

@@ -1,5 +1,7 @@
package com.peanut.modules.book.service.impl;
import com.peanut.common.utils.ExcludeEmptyQueryWrapper;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -20,7 +22,10 @@ public class PayPaymentOrderServiceImpl extends ServiceImpl<PayPaymentOrderDao,
public PageUtils queryPage(Map<String, Object> params) {
IPage<PayPaymentOrderEntity> page = this.page(
new Query<PayPaymentOrderEntity>().getPage(params),
new QueryWrapper<PayPaymentOrderEntity>()
new ExcludeEmptyQueryWrapper<PayPaymentOrderEntity>()
.eq("tel",params.get("key"))
.or().like("user_name",params.get("key")).orderByDesc("create_time")
);
return new PageUtils(page);

View File

@@ -20,7 +20,7 @@ public class PublisherServiceImpl extends ServiceImpl<PublisherDao, PublisherEnt
public PageUtils queryPage(Map<String, Object> params) {
IPage<PublisherEntity> page = this.page(
new Query<PublisherEntity>().getPage(params),
new QueryWrapper<PublisherEntity>()
new QueryWrapper<PublisherEntity>().orderByDesc("create_time")
);
return new PageUtils(page);

View File

@@ -32,12 +32,14 @@ public class ShopCategoryServiceImpl extends ServiceImpl<ShopCategoryDao, ShopCa
return new PageUtils(page);
}
@Override
public List<ShopCategoryEntity> listTree() {
List<ShopCategoryEntity> entities = baseMapper.selectList(null);
//一级菜单
List<ShopCategoryEntity> level1 = entities.stream().filter((catalogueEntity) ->
catalogueEntity.getParentCid() == 0
).map((menu)->{
menu.setChildren(getChildrens(menu,entities));
return menu;
@@ -56,7 +58,8 @@ public class ShopCategoryServiceImpl extends ServiceImpl<ShopCategoryDao, ShopCa
@Override
public List<ShopCategoryEntity> getOneLevel() {
List<ShopCategoryEntity> list = this.list(new QueryWrapper<ShopCategoryEntity>().eq("parent_cid", 1).eq("show_status", 1));
// List<ShopCategoryEntity> list = this.list(new QueryWrapper<ShopCategoryEntity>().eq("parent_cid", 1).eq("show_status", 1));
List<ShopCategoryEntity> list = this.list(new QueryWrapper<ShopCategoryEntity>().eq("name", "医学视频").eq("show_status", 1));
return list;
}
@@ -68,6 +71,11 @@ public class ShopCategoryServiceImpl extends ServiceImpl<ShopCategoryDao, ShopCa
return list;
}
@Override
public List<String> findBookId(String bookId) {
return null;
}
@Override
public List<Integer> findPoid(Integer oid) {
List<Integer> list = new ArrayList<>();

View File

@@ -1,5 +1,6 @@
package com.peanut.modules.book.service.impl;
import com.peanut.common.utils.ExcludeEmptyQueryWrapper;
import com.peanut.modules.book.entity.ShopCategoryEntity;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
@@ -11,7 +12,6 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.peanut.common.utils.PageUtils;
import com.peanut.common.utils.Query;
import com.peanut.modules.book.dao.ShopProductDao;
import com.peanut.modules.book.entity.ShopProductEntity;
import com.peanut.modules.book.service.ShopProductService;
@@ -22,14 +22,12 @@ public class ShopProductServiceImpl extends ServiceImpl<ShopProductDao, ShopProd
@Override
public PageUtils queryPage(Map<String, Object> params) {
String userid = (String) params.get("userid");
IPage<ShopProductEntity> page = this.page(
new Query<ShopProductEntity>().getPage(params),
new QueryWrapper<ShopProductEntity>()
new ExcludeEmptyQueryWrapper<ShopProductEntity>().like("product_name", params.get("key"))
.notLike("book_ids",",")
);
return new PageUtils(page);
}
@@ -39,7 +37,6 @@ public class ShopProductServiceImpl extends ServiceImpl<ShopProductDao, ShopProd
new Query<ShopProductEntity>().getPage(params),
new QueryWrapper<ShopProductEntity>()
);
return new PageUtils(page);
}
@@ -49,4 +46,24 @@ public class ShopProductServiceImpl extends ServiceImpl<ShopProductDao, ShopProd
return list;
}
@Override
public PageUtils getNewBook(Map<String, Object> params) {
IPage<ShopProductEntity> page = this.page(
new Query<ShopProductEntity>().getPage(params),
new QueryWrapper<ShopProductEntity>().orderByDesc("create_time")
);
return new PageUtils(page);
}
@Override
public PageUtils selectListqueryPage(Map<String, Object> params) {
Object name = params.get("name");
IPage<ShopProductEntity> page = this.page(
new Query<ShopProductEntity>().getPage(params),
new ExcludeEmptyQueryWrapper<ShopProductEntity>().like("product_name", params.get("key"))
);
return new PageUtils(page);
}
}

View File

@@ -23,6 +23,7 @@ import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
@@ -63,6 +64,7 @@ public class ShopSeckillServiceImpl extends ServiceImpl<ShopSeckillDao, ShopSeck
IPage<ShopSeckillEntity> page = this.page(
new Query<ShopSeckillEntity>().getPage(params),
new QueryWrapper<ShopSeckillEntity>()
);
return new PageUtils(page);
@@ -90,6 +92,17 @@ public class ShopSeckillServiceImpl extends ServiceImpl<ShopSeckillDao, ShopSeck
saveSessionInfo(seckilProdVo);
saveSessionProdInfo(seckilProdVo);
Set<String> keys = stringRedisTemplate.keys(SESSIONS_CACHE_PREFIX + "*");
long time = new Date().getTime();
for(String key : keys){
String replace = key.replace(SESSIONS_CACHE_PREFIX, "");
String[] s = replace.split("_");
long endTime = Long.parseLong(s[1]);
if(endTime <= time){
stringRedisTemplate.delete(key);
}
}
}
@Override
@@ -104,6 +117,7 @@ public class ShopSeckillServiceImpl extends ServiceImpl<ShopSeckillDao, ShopSeck
long startTime = Long.parseLong(s[0]);
long endTime = Long.parseLong(s[1]);
if (time >= startTime && time <= endTime ) {
List<String> list = stringRedisTemplate.opsForList().range(key, -100, 100);

View File

@@ -1,24 +1,19 @@
package com.peanut.modules.book.service.impl;
import com.peanut.modules.book.entity.BookEntity;
import com.peanut.modules.book.entity.MyUserEntity;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.peanut.common.utils.ExcludeEmptyQueryWrapper;
import com.peanut.common.utils.PageUtils;
import com.peanut.common.utils.Query;
import com.peanut.modules.book.dao.TransactionDetailsDao;
import com.peanut.modules.book.entity.TransactionDetailsEntity;
import com.peanut.modules.book.service.BookService;
import com.peanut.modules.book.service.MyUserService;
import com.peanut.modules.book.service.TransactionDetailsService;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.peanut.common.utils.PageUtils;
import com.peanut.common.utils.Query;
import com.peanut.modules.book.dao.TransactionDetailsDao;
import com.peanut.modules.book.entity.TransactionDetailsEntity;
import com.peanut.modules.book.service.TransactionDetailsService;
@Service("transactionDetailsService")
@@ -34,7 +29,9 @@ public class TransactionDetailsServiceImpl extends ServiceImpl<TransactionDetail
IPage<TransactionDetailsEntity> page = this.page(
new Query<TransactionDetailsEntity>().getPage(params),
new QueryWrapper<TransactionDetailsEntity>().eq(StringUtils.isNotBlank(userId),"user_id",userId)
new ExcludeEmptyQueryWrapper<TransactionDetailsEntity>()
.eq(StringUtils.isNotBlank(userId),"user_id",userId)
.eq("tel",params.get("key")).or().like("user_name",params.get("key")).orderByDesc("create_time")
);
return new PageUtils(page);

View File

@@ -1,6 +1,9 @@
package com.peanut.modules.book.service.impl;
import com.peanut.modules.book.entity.BuyOrderEntity;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -26,5 +29,39 @@ public class UserEbookBuyServiceImpl extends ServiceImpl<UserEbookBuyDao, UserEb
return new PageUtils(page);
}
@Override
public PageUtils queryPages(Map<String, Object> params) {
Integer userid = Integer.valueOf((String) params.get("id"));
IPage<UserEbookBuyEntity> page = this.page(
new Query<UserEbookBuyEntity>().getPage(params),
new QueryWrapper<UserEbookBuyEntity>()
.eq("user_id",userid)
);
return new PageUtils(page);
}
}

View File

@@ -4,7 +4,7 @@ public interface VerifyReceiptConstant {
/**
* ios 端app bundle id
* 也可以配置在nacos里面,动态获取
* URL_SANDBOX 沙盒测试
* URL_VERIFY 正式
*/
@@ -15,7 +15,7 @@ public interface VerifyReceiptConstant {
String URL_VERIFY = "https://sandbox.itunes.apple.com/verifyReceipt";
// String URL_VERIFY = "https://buy.itunes.apple.com/verifyReceipt";

View File

@@ -72,7 +72,7 @@ public class AppController {
try {
System.out.println("==============veri=================================" + dto);
// 1. 校验入参
if (dto == null)
return Result.error("入参不能为空");
@@ -90,13 +90,15 @@ public class AppController {
IapResponseDTO receipt = iapVerifyReceiptService.verifyIapReceipt(dto.getReceiptData(), dto.isSandBox());
BuyOrderEntity order2 = this.buyOrderService.getOne(new QueryWrapper<BuyOrderEntity>().eq("order_sn", dto.getOrderId()).eq("del_flag", "0"));
order2.setPaymentDate(new Date());
System.out.println("============order2=================" + order2);
order2.setProductId(dto.getProductId());
this.buyOrderService.updateById(order2);
IosPayOrderEntity order = new IosPayOrderEntity();
//todo 判断状态 订单状态 0-未付款 1-待发货 2-已发货 3-交易成功 4-交易失败
System.out.println("============保存中=================" + order);
String order01 = order.getOrderid();
String order02 = order2.getOrderSn();
if (order01 == order02) {
@@ -142,7 +144,7 @@ public class AppController {
String body = dto.getProductId();
if ("point".equals(subject)) {
// 插入花生币 变动记录
System.out.printf("body====:" + body);
BookBuyConfigEntity bookBuyConfigEntity = this.bookBuyConfigService.getById(Integer.valueOf(body));
String realMoney = bookBuyConfigEntity.getMoney();
Integer money = Integer.valueOf(realMoney);
@@ -153,7 +155,6 @@ public class AppController {
transactionDetailsEntity.setOrderType("充值");
transactionDetailsEntity.setRelationId(order.getId());
transactionDetailsEntity.setRemark("充值");
System.out.println("===============进入了point获取ID=========================" + order.getId());
MyUserEntity user = userService.getById(Integer.valueOf(customerid));
BigDecimal peanutCoin = user.getPeanutCoin();
transactionDetailsEntity.setUserBalance(peanutCoin);
@@ -176,12 +177,12 @@ public class AppController {
order.setMoney(Integer.valueOf(bookBuyConfigEntity.getRealMoney()));
order.setUsername(user.getName());
orderService.saveOrUpdate(order);
System.out.println("==========ok================================================================================================================================================");
}
orderService.update();
System.out.println("==========ok================================================================================================================================================");
@@ -200,7 +201,7 @@ public class AppController {
lock.unlock();
}
// return null;
}
@@ -210,24 +211,21 @@ public class AppController {
*/
@RequestMapping(value = "/failure")
// @RequestBody
public Result update(@Validated @RequestBody IapRequestDTO vo) {
System.out.println("=========entity1111================"+vo);
IosPayOrderEntity order = new IosPayOrderEntity();
order.setOrderid(vo.getOrderId());
order.setReceiptData(vo.getReceiptData());
order.setProductID(vo.getProductId());
order.setTransactionId(vo.getTransactionId());
System.out.println("=========dto.getTransactionId()============" + vo.getTransactionId());
order.setCustomerOid(vo.getCustomerOid());
order.setCloseOrder(0);
order.setCreateTime(new Date());
order.setFailureflag(vo.getFailureflag());
System.out.println("============v0===================================================================================="+vo.getFailureflag());
orderService.saveOrUpdate(order);
System.out.println("=======order================"+order);

View File

@@ -1,9 +1,6 @@
package com.peanut.modules.pay.IOSPay.model.entities;
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 com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
@@ -88,6 +85,7 @@ public class IosPayOrderEntity implements Serializable {
*删除标记 1 -未删除 0-已删除
*/
@TableField("del_flag")
@TableLogic
private Integer delFlag;

File diff suppressed because one or more lines are too long

View File

@@ -11,30 +11,31 @@ import com.alipay.api.DefaultAlipayClient;
public class AliPayConfig {
/**
* 花生appId 沙箱id 2021000117696096
* 花生appId 沙箱id 2021002161620176
*/
public static final String HS_APP_ID = "2021000118600784";
public static final String HS_APP_ID ="2021003191621137";
/**
* 花生应用私钥
*/
public static final String HS_MERCHANT_PRIVATE_KEY = "MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCIrSciDRMFvEopt/F8O/SpQBZcyUXUcqe3rz2Sl0StpP5eu1IoB4GsX2wbYmOe6a0jfVrRLhvJINjYLrZiWUVGdSD3pkVtfQyp0pjmvi7sv/xtiUMhR7TZ2xWHieVN4h/4JsmdGMbirCnxJcqIKsdOkzHpm2CkmvwaBcLW1t5CGF5p2QKYAWVrtRfZemeXbseIHSQI0yhNVNA2moVVNny7+DMEY7jBwG/rsT5vymRa0R+Em4aBsi5LdR3h71hCxNwuizM8Z9WWamO6L0xj8s/FsaIxizprgcUH2WagqY0il5KBaOr3Kp/Tb8NvcTT4P9etwYV9YZAXqAkCHOo6zqbLAgMBAAECggEACPg8IjrzbaPuxhAhVALnSpg/H3XCFHA125Mvmkg9JJw4aWUnviLH+tUEVkO9v/cb+sFGTYYWIrv6Hy3poEi1iCs1r6sE0WusghSlHjeLAtSSr2mbszpufwGmxw9gshzN9k4tWxb+LnAYDJBrW0ZbcCeu1eLxk7vsIZURNWJCkdnIV2ColgqRPydvLAxPQTzz6P93BaG9jQrBBDhjpfqd1MI3QoRDSkFmSDAfv78DKV1G893lGWcbdDWdXNyR4EVmOLcT/Mmod1wY9dZSwT/faCYMekoVvXYl/r1KMq8HjgcHXArBELGayiA1dis2qO+Biz6t+ImJyHAK1LTsIRg4AQKBgQDsMWAzS8hbmj23EfPotmOLUZdIjfRlOLZ+zQ9PXn+Uxr0qWRmf3FFvcHm76onHFfkkYjIjqfibBVPeVP4cyYexEiHJSWbMNa8sRJAs8+2nyxufQqiN5l65KGGEVVREN6xWpacTdYGcF3RLeHlGrVYgJrAvkpCia2nLIUoIC0hyywKBgQCUI1eKJvQYiViG2BpjK1BUj12Pd0DmvyDI318N0xrpqWXjTklVwWHgESBM5lhtoTG4SKIclxKglnqsn9CC6IbiugFyxC6dWJpXi5Fl0R8CPcIUSwzQJAFUjgbMNqpx+9j/UkG/BETfFdvyb8GJ7mhKJIwOHzlPK3MzD3GEUegcAQKBgF8hU/nVIBGlAg5mMLMeIuHOLvyOEE1kljxkIzJ4gTJPCYmw8V0tw676wk0pneyNsRcyZbdvki3961W1LdQyZ3CuOOV1pu3BAZj21IsGhEX8zFdM5c6hZq100jIWnCYNtl//wFdaEKXp3HE5SL9quTGh43yFr7N7R9UEx2iOAtQZAoGANMJlkhmPhBGeit/6felWQdeRnd/+KHBXz9LmOrk984xWcl9WdQlbv365/0lmoxzu5VBRFFel1bXiWQrOK2F/cM6IZ4SBiZ6d0aIulZGmNpkiPzH/jT3Vj3TJ7P9nMxNcVIrKSarOkJlrbWvqBSL417cufnUWZyD1dXEBn/u/7AECgYB2722mJNfoRX6NAdP1VgJQ2i7Mt4Gv4RVLgYC9f3p/QETaexDvwuwbxzhTHPPBtcfCtlMlLhA5b6seFiQkBZJS+2NuJp/r7VRAw99ZBTb3Yn6NXXu713VUnZsisokKlqzNvLoH722NWPOVAmA8eAQnZqmWtPOkIcq6rjaGOKpnTA==";
public static final String HS_MERCHANT_PRIVATE_KEY = "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCa+oIVGBAKp+VjHIeE/IFUFWifnUWQYBPwffWEC5+EKJbqEC/wcVSfZPKXpPAB3T0c6V6yxCOMxguUZEdeRM5W93Wf0jktrtius34Xo79vgnLXsj2TtAN1ku9Qp5ebVVw+WPdpIl1nOFNwCoiaSPmwXOsVIT5MccxUvmGUDNUg8dYVoD9WHYu13O30c4vm+jYGCu7lviRqcjnEFooJ/ORocLqJbHFaTzWMGiiAYnUUSTL1BI5vhDNJDhm3B5wUZ7/j49EWQYZbV0fXlCrZRerfPLrAgXYR95P+62K9Xh8edzThTrPXmLXP9/jTqz2118ijXSoF8EgfhVD2NLCSDid3AgMBAAECggEAR3cPN0TyWMeVer+0Knn59Vkt9rSiWHJFn5el+K8Xbuz8spCmWp0YJax6Rb10Q5fOz5854PubXRYSTupzEqBt+iKApiNd5JgFKYJxudrzsysXZCm4RX00PypzmuC9g464S7Pg2yVSpv+NUlQ5K9RM96vRZ9v9i2jKjaWA/7FvMpI3auOJgrJVoSbPYNx6/QIN1b9imukCMSga9OzF66LhfzACWxJx+DzgAX+7GcfhTF8PbhytPPg9LhlfcGq2gA/TcG6zUorFz5Qy+k//g4rxIvjcPnGfcRgoT+Xgi7I8wnm3O5icIZ6k6+B+wwN3zRTBSmXwbwsgdncGA1RUhe2tAQKBgQDweYu2ij8Io/g7KCvCtVpGHqhzKxgaOZXy0nvPFXY5KFcrrapACriztCaxjvRTXm7t25KJQazICs50OvyTZL5+U3GHp/8GK7KwzZKz5NkHHMtKoKwQADBNau/nHdro4E+PnvL9ucaFX69JF4DZqiw2aDkQkDB/BablHyvuTagJgQKBgQCk++uzero6bXOxFMadLLyWTvlOJP71U1fVSf4Nou+L4ce7k2bMpSDyEDNDOUW3WOO7zz9i8mFGCTUaoX3mhC+B9UQqKZXK2rjFgZtkNDumoCTzvjuPIWTMNN6ABetiLxbq/UD0O1xwThVQNmYwTOzwMHUMkT21ynD23KXE0JL89wKBgGg1Q8YmwooMBFYeYlhOHoCkaHsAAcHbko9Xhy+GLWU3hg73gv+dpcy6FMp9GIPIOGn67NVuEGHfzPexWCLHVYWIw3n14x3ZceYML7alRSc/4xjD58xHSKdD4BJXbbXc/p1OVB5/kvfZLyyNctjgVah+Ibx7v4hL+rbveyoZnOgBAoGAG34je+giqmPc2JB2vHBdCMsmPkBqACWgSFmpLUqOkofQSdC5W7bUs6HBeR1NIc19Pam+jVWIoiwcnlB083nplMVzU3dUj9Y83iTH6T3PBug+4CM+N47ABkt1HG5gGB9yuTv0m/5cXBaW9KPsCXZ4MVpR1wNI/kc65dhFA3QiWmcCgYEA6CfUjOWe201IC332e142WfPGp7hy8p6RHrPtlXS5YnuxVsJVusyuncVdG10kPkvPHakFokqNNUW76Trf++IPnNooMP9ucYj060hYTM7JK9F0mAdx0Mo/+nDC7voXw8rBSsLZHAWfxMh/KjQ5D7L6E2S71wP6ep25hoOuuuLTnrI=";
/**
* 花生支付宝应用公钥
* 应用公钥
*/
public static final String HS_ALIPAY_PUBLIC_KEY = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAiK0nIg0TBbxKKbfxfDv0qUAWXMlF1HKnt689kpdEraT+XrtSKAeBrF9sG2JjnumtI31a0S4bySDY2C62YllFRnUg96ZFbX0MqdKY5r4u7L/8bYlDIUe02dsVh4nlTeIf+CbJnRjG4qwp8SXKiCrHTpMx6ZtgpJr8GgXC1tbeQhheadkCmAFla7UX2Xpnl27HiB0kCNMoTVTQNpqFVTZ8u/gzBGO4wcBv67E+b8pkWtEfhJuGgbIuS3Ud4e9YQsTcLoszPGfVlmpjui9MY/LPxbGiMYs6a4HFB9lmoKmNIpeSgWjq9yqf02/Db3E0+D/XrcGFfWGQF6gJAhzqOs6mywIDAQAB";
//沙箱支付宝公钥
public static final String HS_ALI_PUBLIC_KEY ="MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmjFqCkYZ7/2TmINtDlFap8MUu/Z+SN6anxJH73LojB5qmQAHlUN5n55NvhcY+eaE6khpn9BCQDJ8URWs2DDhVKSw6EUwEFafkXmWNEAAjhpT9O5YrMACg8d0zhQirS4zrG/6tjPvx9X2X/CIohlu8jif79m46o11NI+iUmdiaT/IU4gMSUFqZ9KR9Qz6xzjJQ0tULHl+7S9qTQLbqqfJgzDEh06SU9F7KnQ0T9wIIPI7KCfn72kNMRUC2DGOZxFA8eztg1bprRhwufrT52ijEH+z/8hkyYVz1+MrrCaDGvSrC9xVj1FFzAofsMQxgKtSgjbgs0+reLoJ/uL/SKXWpQIDAQAB";
public static final String HS_ALIPAY_PUBLIC_KEY = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmvqCFRgQCqflYxyHhPyBVBVon51FkGAT8H31hAufhCiW6hAv8HFUn2Tyl6TwAd09HOlessQjjMYLlGRHXkTOVvd1n9I5La7YrrN+F6O/b4Jy17I9k7QDdZLvUKeXm1VcPlj3aSJdZzhTcAqImkj5sFzrFSE+THHMVL5hlAzVIPHWFaA/Vh2Ltdzt9HOL5vo2Bgru5b4kanI5xBaKCfzkaHC6iWxxWk81jBoogGJ1FEky9QSOb4QzSQ4ZtwecFGe/4+PRFkGGW1dH15Qq2UXq3zy6wIF2EfeT/utivV4fHnc04U6z15i1z/f406s9tdfIo10qBfBIH4VQ9jSwkg4ndwIDAQAB";
/**
* 回调地址
* 支付宝公钥
*/
public static final String HS_ALI_PUBLIC_KEY = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAiVLUVTnNuq+2C1FRtcIRcG3rCgtVVulkz2QljKbPr7NNWTJJIIfGwyhNuH76s5D1lvNmn2NkuoqM0cMJCSd+W+JW9KpdQ0dgumFHCoRA/OWUoqpLvEOmm2hRMaWpvd+OQq2aPz+p+z6pqZ9SAlgUIolzrUn4idCvgIycqRaGsf1sEJFR5W+rneqtMhNYHdwemqaqnysInwshHR3cHs1AC6y/eL6pcQhaYJ5qVMIRg54/6Lr4CU114Rmph7UM9C28ulmHkFMN/DKPUDbM1+glxjzmqHQChY293Db0dlwZeiDWF3Tli2BVd6pz5KEkQlUsGeLW1O0rT9T9sxzsavxArwIDAQAB";
/**
* 回调地址 因为是内网开发 目前为内网穿透地址
*/
public static final String NOTIFY_URL = "http://59.110.212.44:9100/pb/pay/aliPay/notify";
// public static final String NOTIFY_URL = "http://kvv6y4.natappfree.cc/pb/pay/aliPay/notify";
/**
* 页面跳转同步通知页面路径 需http://格式的完整路径,不能加?id=123这类自定义参数

View File

@@ -44,8 +44,8 @@ public class AliPayController {
Map<String, String[]> parameterMap = request.getParameterMap();
String jsonStr = JSONObject.toJSONString(parameterMap);
System.out.println("支付宝回调信息=============》"+jsonStr);
aliPayService.aliNotify(request);
return R.ok();
String aliNotify = aliPayService.aliNotify(request);
return R.ok().put("aliNotify",aliNotify);
}
}

View File

@@ -124,7 +124,7 @@ public class AliPayServiceImpl implements AliPayService {
return "success";
}
PayZfbOrderEntity oldPayZfbOrderEntity = payZfbOrderService.getOne(new QueryWrapper<PayZfbOrderEntity>().eq("out_trade_no", aliNotifyDto.getOutTradeNo()));
CopyUtils.copyProperties(aliNotifyDto,oldPayZfbOrderEntity);
CopyUtils.copyProperties(aliNotifyDto,oldPayZfbOrderEntity);
payZfbOrderService.updateById(oldPayZfbOrderEntity);
@@ -160,10 +160,12 @@ public class AliPayServiceImpl implements AliPayService {
transactionDetailsEntity.setOrderType("充值");
transactionDetailsEntity.setRelationId(oldPayZfbOrderEntity.getId().intValue());
transactionDetailsEntity.setRemark("充值");
MyUserEntity user = userService.getById(Integer.valueOf(customerid));
Integer peanutCoin = user.getPeanutCoin();
BigDecimal balance = new BigDecimal(peanutCoin);
transactionDetailsEntity.setUserBalance(balance);
BigDecimal peanutCoin = user.getPeanutCoin();
transactionDetailsEntity.setUserBalance(peanutCoin);
transactionDetailsEntity.setUserName(user.getNickname());
transactionDetailsEntity.setTel(user.getTel());
transactionDetailsService.save(transactionDetailsEntity);
// 插入 花生币 充值记录
PayPaymentOrderEntity payPaymentOrderEntity = new PayPaymentOrderEntity();
@@ -174,15 +176,20 @@ public class AliPayServiceImpl implements AliPayService {
payPaymentOrderEntity.setRechargeChannel(bookBuyConfigEntity.getQudao());
payPaymentOrderEntity.setRechargeStatus("success");
payPaymentOrderEntity.setSuccessTime(new Date());
payPaymentOrderEntity.setUserName(user.getNickname());
payPaymentOrderEntity.setTel(user.getTel());
payPaymentOrderService.save(payPaymentOrderEntity);
buyOrderService.updateOrderStatus(Integer.valueOf(customerid),oldPayZfbOrderEntity.getRelevanceoid(),"2");
}
if ("order".equals(subject)) {
System.out.println("=====到order更新字段==================================================================================================================");
BuyOrderEntity orderEntity = buyOrderService.getBaseMapper().selectOne(new QueryWrapper<BuyOrderEntity>().eq("order_sn", oldPayZfbOrderEntity.getRelevanceoid()));
System.out.println("======orderEntity=========="+orderEntity);
BigDecimal realMoney = orderEntity.getRealMoney();
System.out.println("======realMoney=========="+realMoney);
BigDecimal bigDecimal = new BigDecimal(oldPayZfbOrderEntity.getBuyerPayAmount());
System.out.println("======bigDecimal=========="+bigDecimal);
//更新 订单 记录
if (bigDecimal.compareTo(realMoney) == 0) {
buyOrderService.updateOrderStatus(Integer.valueOf(customerid),oldPayZfbOrderEntity.getRelevanceoid(),"0");

View File

@@ -1,5 +1,7 @@
package com.peanut.modules.pay.weChatPay.config;
import cn.hutool.core.io.resource.ClassPathResource;
import cn.hutool.core.io.resource.Resource;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.wechat.pay.contrib.apache.httpclient.WechatPayHttpClientBuilder;
import com.wechat.pay.contrib.apache.httpclient.auth.*;
@@ -7,9 +9,11 @@ import com.wechat.pay.contrib.apache.httpclient.cert.CertificatesManager;
import com.wechat.pay.contrib.apache.httpclient.exception.HttpCodeException;
import com.wechat.pay.contrib.apache.httpclient.exception.NotFoundException;
import com.wechat.pay.contrib.apache.httpclient.util.PemUtil;
import io.swagger.annotations.ApiOperation;
import lombok.Data;
import lombok.Value;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.FileUtils;
import org.apache.http.impl.client.CloseableHttpClient;
import org.junit.After;
import org.junit.Before;
@@ -18,11 +22,18 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;
import org.springframework.util.ResourceUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.net.URI;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.security.GeneralSecurityException;
import java.security.PrivateKey;
import java.util.Enumeration;
/**
@@ -94,15 +105,47 @@ public class WechatPayConfig implements Serializable {
private String domain;
//获取私钥工具
public PrivateKey getPrivateKey(String keyPemPath) {
try {
return PemUtil.loadPrivateKey(new FileInputStream(keyPemPath));
/*
解决方案
1. 将私钥文件放在应用的外部,然后通过文件路径来读取。例如:
privateKeyPath = "/etc/myapp/apiclient_key.pem";
File file = new File(privateKeyPath);
return PemUtil.loadPrivateKey(new FileInputStream(file));
这样你就可以将 privateKeyPath 设置为任意位置的文件路径。
2.如果你确实需要将私钥文件打包到应用中,你可以使用 ResourceUtils.getURL(filename).openStream() 来获取文件内容,例如:
privateKeyPath = "classpath:cert/apiclient_key.pem";
return PemUtil.loadPrivateKey(ResourceUtils.getURL(privateKeyPath).openStream());
这样你就可以从应用的 classpath 中读取文件内容。
ResourceUtils.getURL(filename).openStream() 来获取资源这是与平台无关的所以在Windows、Linux以及其他任何支持Java的平台上都能正常使用。只要你的资源文件在这个例子中是私钥文件被正确的包含在了你的应用的classpath中那么你就可以在任何平台上使用这个方法来读取资源文件的内容。
这里需要注意的是classpath: 是一个特殊的协议前缀它表示资源是从classpath中获取的。当你的资源文件被打包进jar或war时它们就位于应用的classpath中因此你可以使用 classpath: 前缀来获取这些文件。
因此无论你的应用运行在Windows还是Linux或者是其他任何操作系统上使用方法2都不会有问题。只要你的资源文件被正确地打包进了应用那么就可以使用这种方法来读取文件内容。
*/
// 修改后的方法
return PemUtil.loadPrivateKey(ResourceUtils.getURL(keyPemPath).openStream());
} catch (FileNotFoundException e) {
//抛出异常,并把错误文件继续向上抛出
throw new RuntimeException("私钥文件不存在",e);
throw new RuntimeException("私钥文件不存在", e);
} catch (IOException e) {
throw new RuntimeException("私钥文件流失败", e);
}
}
@@ -119,7 +162,8 @@ public class WechatPayConfig implements Serializable {
log.info("获取证书管理器实例");
//获取商户私钥
// PrivateKey privateKey = getPrivateKey(keyPemPath);
PrivateKey privateKey = getPrivateKey(keyPemPath);
//私钥签名对象
@@ -146,12 +190,13 @@ public class WechatPayConfig implements Serializable {
* @return
*/
@Bean(name = "wxPayClient")
// @Bean
public CloseableHttpClient getWxPayClient(Verifier verifier) {
log.info("获取HttpClient");
//获取商户私钥
PrivateKey privateKey = getPrivateKey(keyPemPath);
WechatPayHttpClientBuilder builder = WechatPayHttpClientBuilder.create()
@@ -168,12 +213,11 @@ public class WechatPayConfig implements Serializable {
/**
* 获取HttpClient无需进行应答签名验证跳过验签的流程
*/
@Bean(name = "wxPayNoSignClient")
public CloseableHttpClient getWxPayNoSignClient() {
//获取商户私钥
PrivateKey privateKey = getPrivateKey(keyPemPath);
//用于构造HttpClient
WechatPayHttpClientBuilder builder = WechatPayHttpClientBuilder.create()
//设置商户信息

View File

@@ -88,11 +88,6 @@ public class WeChatPayController {
@RequestMapping(value = "/Vxtext", method = RequestMethod.POST)
public String vxPAYtext(@RequestBody Integer user) {
return "=============================test============"+user;
}
/**
@@ -106,39 +101,7 @@ public class WeChatPayController {
@RequestMapping(value = "/placeAnOrder/app")
@Transactional(rollbackFor = Exception.class)
public R pay(@RequestBody WechatDto dto ) throws Exception{
// Date afterDate = new Date(nowDate.getTime()+300000*3);
//
// Date nowDate = new Date();
// Date afterDate = new Date(nowDate.getTime() + 60000);
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd-HH:mm:ssXXX");
// sdf.setTimeZone(TimeZone.getTimeZone("GMT+8"));
//
// String dateString = sdf.format(afterDate); // 将修改后的时间转换为字符串
//
// ZoneId zoneId = ZoneId.of("Asia/Shanghai");
// Instant now = Instant.now();
// Instant after = now.plus(60, ChronoUnit.SECONDS);
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd-HH:mm:ssXXX");
//// .withZone(zoneId);
// sdf.setTimeZone(TimeZone.getTimeZone(zoneId));
//
// String afterString = sdf.format(after);
//
//
//
//
//
//
// System.out.println("修改后时间:" + afterString);
System.out.println("==========ordersn================"+dto.getOrderSn());
log.info("生成订单");
log.info("微信生成订单");
List<BuyOrderEntity> one = this.buyOrderService.getBaseMapper().selectList(new QueryWrapper<BuyOrderEntity>().eq("order_sn", dto.getOrderSn()));
BuyOrderEntity order = one.get(0);
// 获取订单
@@ -154,12 +117,27 @@ public class WeChatPayController {
// paramMap.put("time_expire",afterString);
// 实收金额0.38乘100=38
BigDecimal realsmoney= order.getRealMoney();
BigDecimal hand=new BigDecimal("100");
realsmoney =realsmoney.multiply(hand) ;
BigDecimal hand=new BigDecimal("100");
realsmoney =realsmoney.multiply(hand) ;
Map<String,Object> amountMap = new HashMap<>();
amountMap.put("total",realsmoney);
amountMap.put("currency","CNY");
BigDecimal money= order.getRealMoney();
BigDecimal han=new BigDecimal("100");
realsmoney =realsmoney.multiply(han) ;
Map<String,Object> amount = new HashMap<>();
amount.put("total",realsmoney);
amount.put("currency","CNY");
if (dto.getTotalAmount()!=order.getRealMoney()) {
}
paramMap.put("amount",amountMap);
JSONObject json = JSONObject.parseObject(JSON.toJSONString(paramMap));
log.info("请求参数"+paramMap);
com.alibaba.fastjson.JSONObject jsonObject1 = wxPayUtil.doPostWexinV3("https://api.mch.weixin.qq.com/v3/pay/transactions/app", json.toJSONString());
@@ -204,7 +182,7 @@ public class WeChatPayController {
wechat.setCreateTime(new Date()); //创建订单时间
wechat.setOrderSn(order.getOrderSn()); //订单编号
wechat.setPrepayId(prepayid); //预支付回话标识 标识为响应体EntityUtils.toString(response.getEntity())
wechat.setTotalAmount(order.getRealMoney()); //支付实收金额
wechat.setTotalAmount(dto.getTotalAmount()); //支付实收金额
wechat.setSystemLog(response.toString()); //日志
wechat.setPayType(order.getOrderType()); //交易类型
wechat.setOrderId(order.getOrderSn()); //订单号
@@ -258,13 +236,13 @@ public class WeChatPayController {
@PostMapping("/payNotify")
public R payNotify(HttpServletRequest request, HttpServletResponse response) {
log.info("##############################微信支付回调#######################");
PayWechatOrderEntity wechatEntity = new PayWechatOrderEntity();
// 处理通知参数
Map<String,Object> bodyMap = getNotifyBody(request);
if(bodyMap==null){
return null;
}
log.warn("=========== 在对业务数据进行状态检查和处理之前,要采用数据锁进行并发控制,以避免函数重入造成的数据混乱 ===========");
if(lock.tryLock()) {
try {
// 解密resource中的通知数据
@@ -272,19 +250,21 @@ public class WeChatPayController {
Map<String, Object> resourceMap = WechatPayValidator.decryptFromResource(resource, wechatPayConfig.getApiV3Key(),1);
String orderNo = resourceMap.get("out_trade_no").toString();
String transactionId = resourceMap.get("transaction_id").toString();
System.out.println("===================回调解密transactionId================================"+transactionId);
// 根据订单号,做幂等处理,并且在对业务数据进行状态检查和处理之前,要采用数据锁进行并发控制,以避免函数重入造成的数据混乱
BuyOrderEntity order = this.buyOrderService.getOne(new QueryWrapper<BuyOrderEntity>().eq("order_sn", orderNo));
PayWechatOrderEntity wechatEntity = new PayWechatOrderEntity();
if(!ObjectUtils.isEmpty(order)){
wechatEntity = this.payWechatOrderService.getOne(new QueryWrapper<PayWechatOrderEntity>().eq("order_id", order.getOrderId()));
wechatEntity = this.payWechatOrderService.getOne(new QueryWrapper<PayWechatOrderEntity>().eq("order_sn", order.getOrderSn()));
}else{
log.error("无效订单!");
return R.error(500,"无效订单!");
}
// 1.根据订单id获取订单信息
log.warn("=========== 根据订单号,做幂等处理 ===========");
if("order".equals(order.getOrderType())){
BuyOrderEntity orderEntity = buyOrderService.getBaseMapper().selectOne(new QueryWrapper<BuyOrderEntity>().eq("order_sn", wechatEntity.getOrderId()));
BuyOrderEntity orderEntity = buyOrderService.getBaseMapper().selectOne(new QueryWrapper<BuyOrderEntity>().eq("order_sn", wechatEntity.getOrderSn()));
BigDecimal realMoney = orderEntity.getRealMoney();
//更新 订单 记录
@@ -373,4 +353,99 @@ public class WeChatPayController {
}
@RequestMapping(value = "/placeAnOrder/shoppingpay")
@Transactional(rollbackFor = Exception.class)
public R shoppingpay(@RequestBody WechatDto dto ) throws Exception{
log.info("生成订单");
List<BuyOrderEntity> one = this.buyOrderService.getBaseMapper().selectList(new QueryWrapper<BuyOrderEntity>().eq("order_sn", dto.getOrderSn()));
BuyOrderEntity order = one.get(0);
// 获取订单
Map<String,Object> paramMap = new HashMap<>();
paramMap.put("appid",appId);
paramMap.put("mchid",mchId);
paramMap.put("description","微信充值");
// 订单编号
paramMap.put("out_trade_no",order.getOrderSn());
// paramMap.put("attach",""); //自定义数据 支付完成后才能显示 在查询API和支付通知中原样返回可作为自定义参数使用
paramMap.put("notify_url",wechatPayConfig.getNotifyUrl());
BigDecimal realsmoney= dto.getTotalAmount();
BigDecimal hand=new BigDecimal("100");
realsmoney =realsmoney.multiply(hand) ;
Map<String,Object> amountMap = new HashMap<>();
amountMap.put("total",realsmoney);
amountMap.put("currency","CNY");
paramMap.put("amount",amountMap);
JSONObject json = JSONObject.parseObject(JSON.toJSONString(paramMap));
log.info("请求参数"+paramMap);
com.alibaba.fastjson.JSONObject jsonObject1 = wxPayUtil.doPostWexinV3("https://api.mch.weixin.qq.com/v3/pay/transactions/app", json.toJSONString());
String prepayid = jsonObject1.getString("prepay_id");
// 传入参数 payUrl 发送post请求
HttpPost httpPost = new HttpPost(payUrl);
// 将json数据转换成字符串
StringEntity entity = new StringEntity(json.toString(),"utf-8");
// 设置该请求的Content-Type为application/json 都是json格式
entity.setContentType("application/json");
// 将实体对象设置到HttpPost表示要传递该数据到服务器端。
httpPost.setEntity(entity);
// 设置请求头部的Accept属性为"application/json"表示客户端希望接收的为json。
httpPost.setHeader("Accept", "application/json");
CloseableHttpResponse response = wxPayClient.execute(httpPost);
// 向微信支付平台发送请求,处理响应结果,并将订单信息保存到数据库中。
String bodyAsString = EntityUtils.toString(response.getEntity());//响应体
// 时间戳
Long timestamp = System.currentTimeMillis()/1000;
// 随机串
String nonceStr = UUID.randomUUID().toString().replace("-","");
String sign = wxPayUtil.getSign(WxPayUtil.appId,timestamp,nonceStr,prepayid);
log.info("签名:"+sign);
Map Map = new HashMap();
Map.put("prepayid",prepayid);
Map.put("timestamp",timestamp+"");
Map.put("noncestr",nonceStr);
Map.put("sign",sign);
Map.put("appid",appId);
Map.put("package","Sign=WXPay");
Map.put("extData","sign");
Map.put("partnerid",mchId);
try {
int statusCode = response.getStatusLine().getStatusCode(); //响应状态码
if (statusCode == 200) { //处理成功
System.out.println("成功,返回结果 = " + bodyAsString); //返回响应体 EntityUtils.toString(response.getEntity())
// 添加微信支付订单信息
PayWechatOrderEntity wechat = new PayWechatOrderEntity();
wechat.setCustomerId(order.getUserId()); //用户id
wechat.setCreateTime(new Date()); //创建订单时间
wechat.setOrderSn(order.getOrderSn()); //订单编号
wechat.setPrepayId(prepayid); //预支付回话标识 标识为响应体EntityUtils.toString(response.getEntity())
wechat.setTotalAmount(order.getRealMoney()); //支付实收金额
wechat.setSystemLog(response.toString()); //日志
wechat.setPayType(order.getOrderType()); //交易类型
wechat.setOrderId(order.getOrderSn()); //订单号
wechat.setBuyOrderId(dto.getBuyOrderId()); //购买配置id
// wechat.setEndtime(after);
this.payWechatOrderService.save(wechat); //微信订单表拿到数据保存数据库
} else if (statusCode == 204) { //处理成功无返回Body
System.out.println("成功");
} else {
System.out.println("下单失败 = " + statusCode + ",返回结果 = " + bodyAsString);
throw new IOException("request failed");
}
}finally {
response.close();
}
// 返回url和订单号
return R.ok().put("paramMap" ,paramMap).put("Map",Map);
}
}

View File

@@ -2,18 +2,28 @@ package com.peanut.modules.pay.weChatPay.dto;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
@Data
public class WechatDto implements Serializable {
//totalAmount: payItem.realMoney,
// customerId:
private String orderSn;
private Integer buyOrderId;
private BigDecimal totalAmount;
public BigDecimal getTotalAmount() {
return totalAmount;
}
public void setTotalAmount(BigDecimal totalAmount) {
this.totalAmount = totalAmount;
}
public String getOrderSn() {
return orderSn;

View File

@@ -1,9 +1,15 @@
package com.peanut.modules.pay.weChatPay.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.peanut.common.utils.R;
import com.peanut.modules.book.entity.PayWechatOrderEntity;
import com.peanut.modules.pay.weChatPay.dto.WechatDto;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestBody;
@Service
public interface WxpayService extends IService<PayWechatOrderEntity> {
}

View File

@@ -1,42 +0,0 @@
package com.peanut.modules.pay.weChatPay.util;
import com.peanut.modules.pay.weChatPay.dto.WxchatCallbackRefundData;
import java.lang.reflect.Type;
/**
* 退款处理接口,为了防止项目开发人员,不手动判断退款失败的情况
* 退款失败:退款到银行发现用户的卡作废或者冻结了,导致原路退款银行卡失败,可前往商户平台-交易中心,手动处理此笔退款
*/
public interface WechatRefundCallback {
/*
* WxchatCallbackRefundData是微信支付退款回调数据的格式在退款请求完成后微信支付会将退款结果发送给商户的服务器
* 以此通知商户退款结果。refundData表示退款回调的数据包含退款结果的各种信息如退款金额、退款状态、退款时间等等。
* */
/**
* 退款成功处理情况
*/
void success(WxchatCallbackRefundData refundData);
/**
* 退款失败处理情况
*/
void find(WxchatCallbackRefundData refundData);
}

View File

@@ -32,17 +32,18 @@ import java.util.Base64;
public static final String apiV3Key = "4aYFklzaULeGlr7oJPZ6rHWKcxjihZUF"; // apiV3秘钥
//商户私钥路径
public static final String privateKeyUrl = "C:\\Users\\Administrator\\IdeaProjects\\peanut_book\\src\\main\\resources\\cent\\apiclient_key.pem";
public static final String privateKeyUrl = "/usr/local/hs/peanut_book/target/classes/cent/apiclient_key.pem";
// public static final String privateKeyUrl = "C:/Users/Administrator/IdeaProjects/peanut_book/src/main/resources/cent/apiclient_key.pem";
//平台证书路径
public static final String wechatPayCertificateUrl = "C:\\Users\\Administrator\\IdeaProjects\\peanut_book\\src\\main\\resources\\cent\\wechatpay_7B5676E3CDF56680D0414A009CE501C844DBE2D6.pem";
public static final String wechatPayCertificateUrl = "/usr/local/hs/peanut_book/target/classes/cent/wechatpay_7B5676E3CDF56680D0414A009CE501C844DBE2D6.pem";
// public static final String wechatPayCertificateUrl = "C:/Users/Administrator/IdeaProjects/peanut_book/src/main/resources/cent/wechatpay_7B5676E3CDF56680D0414A009CE501C844DBE2D6.pem";
//第一步申请完证书后在API证书哪里点击管理证书就能看到
public static final String mchSerialNo = "679AECB2F7AC4183033F713828892BA640E4EEE3"; // 商户证书序列号
private CloseableHttpClient httpClient;
public void setup() {
// PrivateKey merchantPrivateKey = PemUtil.loadPrivateKey(privateKey);
PrivateKey merchantPrivateKey = null;
X509Certificate wechatPayCertificate = null;
@@ -137,7 +138,7 @@ import java.util.Base64;
e.printStackTrace();
}
Signature sign = Signature.getInstance("SHA256withRSA");
//这里需要一个PrivateKey类型的参数就是商户的私钥。
sign.initSign(merchantPrivateKey);
sign.update(message);
return Base64.getEncoder().encodeToString(sign.sign());

View File

@@ -16,6 +16,7 @@ import com.peanut.common.validator.ValidatorUtils;
import com.peanut.modules.sys.entity.SysRoleEntity;
import com.peanut.modules.sys.service.SysRoleMenuService;
import com.peanut.modules.sys.service.SysRoleService;
import com.peanut.modules.sys.service.SysUserRoleService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@@ -36,6 +37,8 @@ public class SysRoleController extends AbstractController {
private SysRoleService sysRoleService;
@Autowired
private SysRoleMenuService sysRoleMenuService;
@Autowired
private SysUserRoleService sysUserRoleService;
/**
* 角色列表
@@ -44,7 +47,12 @@ public class SysRoleController extends AbstractController {
@RequiresPermissions("sys:role:list")
public R list(@RequestParam Map<String, Object> params){
//如果不是超级管理员,则只查询自己创建的角色列表
if(getUserId() != Constant.SUPER_ADMIN){
// if(getUserId() != Constant.SUPER_ADMIN){
// params.put("createUserId", getUserId());
// }
List<Long> longs = this.sysUserRoleService.queryRoleIdList(getUserId());
if(!longs.contains(1L)){
params.put("createUserId", getUserId());
}
@@ -62,9 +70,15 @@ public class SysRoleController extends AbstractController {
Map<String, Object> map = new HashMap<>();
//如果不是超级管理员,则只查询自己所拥有的角色列表
if(getUserId() != Constant.SUPER_ADMIN){
// if(getUserId() != Constant.SUPER_ADMIN){
// map.put("create_user_id", getUserId());
// }
List<Long> longs = this.sysUserRoleService.queryRoleIdList(getUserId());
if(!longs.contains(1L)){
map.put("create_user_id", getUserId());
}
List<SysRoleEntity> list = (List<SysRoleEntity>) sysRoleService.listByMap(map);
return R.ok().put("list", list);

View File

@@ -50,7 +50,11 @@ public class SysUserController extends AbstractController {
@RequiresPermissions("sys:user:list")
public R list(@RequestParam Map<String, Object> params){
//只有超级管理员,才能查看所有管理员列表
if(getUserId() != Constant.SUPER_ADMIN){
// if(getUserId() != Constant.SUPER_ADMIN){
// params.put("createUserId", getUserId());
// }
List<Long> longs = this.sysUserRoleService.queryRoleIdList(getUserId());
if(!longs.contains(1L)){
params.put("createUserId", getUserId());
}
PageUtils page = sysUserService.queryPage(params);

View File

@@ -13,6 +13,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.peanut.common.exception.RRException;
import com.peanut.common.utils.Constant;
import com.peanut.common.utils.ExcludeEmptyQueryWrapper;
import com.peanut.common.utils.PageUtils;
import com.peanut.common.utils.Query;
import com.peanut.modules.sys.dao.SysRoleDao;
@@ -52,7 +53,7 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleDao, SysRoleEntity> i
IPage<SysRoleEntity> page = this.page(
new Query<SysRoleEntity>().getPage(params),
new QueryWrapper<SysRoleEntity>()
new ExcludeEmptyQueryWrapper<SysRoleEntity>()
.like(StringUtils.isNotBlank(roleName),"role_name", roleName)
.eq(createUserId != null,"create_user_id", createUserId)
);

View File

@@ -13,6 +13,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.peanut.common.exception.RRException;
import com.peanut.common.utils.Constant;
import com.peanut.common.utils.ExcludeEmptyQueryWrapper;
import com.peanut.common.utils.PageUtils;
import com.peanut.common.utils.Query;
import com.peanut.modules.sys.dao.SysUserDao;
@@ -52,7 +53,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserDao, SysUserEntity> i
IPage<SysUserEntity> page = this.page(
new Query<SysUserEntity>().getPage(params),
new QueryWrapper<SysUserEntity>()
new ExcludeEmptyQueryWrapper<SysUserEntity>()
.like(StringUtils.isNotBlank(username),"username", username)
.eq(createUserId != null,"create_user_id", createUserId)
);
@@ -137,7 +138,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserDao, SysUserEntity> i
//查询用户创建的角色列表
List<Long> roleIdList = sysRoleService.queryRoleIdList(user.getCreateUserId());
//判断是否越权
// 判断是否越权
if(!roleIdList.containsAll(user.getRoleIdList())){
throw new RRException("新增用户所选角色,不是本人创建");
}

View File

@@ -23,6 +23,7 @@ public class WeixinApiController {
@Autowired
private MyUserService userInfoService;
//微信扫描后回调的方法
// @GetMapping("callback")
// public String callback(String code,String state) {

View File

@@ -4,7 +4,7 @@ spring:
druid:
driver-class-name: com.mysql.cj.jdbc.Driver
# url: jdbc:mysql://82.157.238.238:3309/e_book?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
url: jdbc:mysql://59.110.212.44:3306/e_book?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&allowMultiQueries=true
url: jdbc:mysql://59.110.212.44:3306/book_test?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&allowMultiQueries=true
username: root
password: HSXY1234hsxy
initial-size: 10
@@ -75,4 +75,5 @@ aliyun:
# driver-class-name: org.postgresql.Driver
# url: jdbc:postgresql://localhost:5432/renren_security
# username: renren
# password: 123456

View File

@@ -7,6 +7,7 @@ server:
port: 9100
servlet:
context-path: /pb
connection-timeout: 6000000ms
spring:
# 环境 dev|test|prod
@@ -82,4 +83,7 @@ renren:
secret: f4e2e52034348f86b67cde581c0f9eb5[www.renren.io]
# token有效时长7天单位秒
expire: 604800
header: token
header: token
spring.jackson.serialization.FAIL_ON_EMPTY_BEANS: false

View File

@@ -13,6 +13,7 @@
<result property="updateTime" column="update_time"/>
<result property="sort" column="sort"/>
<result property="delFlag" column="del_flag"/>
<result property="images" column="images"/>
</resultMap>

View File

@@ -32,6 +32,9 @@
<result property="updateTime" column="update_time"/>
<result property="sort" column="sort"/>
<result property="delFlag" column="del_flag"/>
<result property="splits" column="splits"/>
<result property="canListen" column="can_listen"/>
<result property="clockIn" column="clock_in"/>
</resultMap>
<select id="queryBookInOther" resultType="com.peanut.modules.book.entity.BookEntity">

View File

@@ -23,7 +23,19 @@
<result property="createTime" column="create_time"/>
<result property="updateTime" column="update_time"/>
<result property="delFlag" column="del_flag"/>
<result property="remark" column="remark"/>
</resultMap>
<update id="update">
update user
<set>
age = #{age}, sex = #{sex} ,avatar=#{avatar} ,nickname =#{nickname}
</set>
where id = #{id}
</update>
</mapper>

View File

@@ -14,6 +14,8 @@
<result property="rechargeStatus" column="recharge_status"/>
<result property="createTime" column="create_time"/>
<result property="successTime" column="success_time"/>
<result property="userName" column="user_name"/>
<result property="tel" column="tel"/>
</resultMap>

View File

@@ -15,6 +15,8 @@
<result property="payType" column="pay_type"/>
<result property="orderId" column="order_id"/>
<result property="buyOrderId" column="buy_order_id"/>
<result property="endtime" column="endtime"/>
</resultMap>

View File

@@ -14,6 +14,8 @@
<result property="icon" column="icon"/>
<result property="productUnit" column="product_unit"/>
<result property="productCount" column="product_count"/>
</resultMap>
</mapper>

View File

@@ -30,6 +30,15 @@
<result property="sumSales" column="sum_sales" />
<result property="goodsType" column="goods_type" />
<result property="goodsTypeCode" column="goods_type_code" />
<result property="activityPrice" column="activity_price" />
<result property="isFreeMail" column="is_free_mail" />
<result property="bookId" column="book_ids" />
<!-- <result property="bookidsimages" column="bookidsimages" />-->
<!-- <result property="bookids" column="book_ids" />-->
<!-- <result property="bookidsimages" column="bookidsimages" />-->
</resultMap>
@@ -39,10 +48,11 @@
FROM
`shop_product` a
LEFT JOIN shop_category b ON a.product_pid = b.cat_id
WHERE
<if test="catId != null and catId != ''">
b.cat_id = #{catId}
</if>
<where>
<if test="catId != null and catId != ''">
b.cat_id = #{catId}
</if>
</where>
order by a.sort desc
</select>

View File

@@ -13,6 +13,9 @@
<result property="remark" column="remark"/>
<result property="userBalance" column="user_balance"/>
<result property="createTime" column="create_time"/>
<result property="userName" column="user_name"/>
<result property="tel" column="tel"/>
<result property="note" column="note"/>
</resultMap>

View File

@@ -7,15 +7,43 @@ wxpay.mchId: 1612860909
wxpay.apiV3Key: 4aYFklzaULeGlr7oJPZ6rHWKcxjihZUF
# 微信支付V3-url前缀
wxpay.baseUrl: https://api.mch.weixin.qq.com/v3
#po9k1ezoyexk.ngrok.xiaomiqiu123.top 内网穿透地址 测试ok
wxpay.notifyUrl: http://po9k1ezoyexk.ngrok.xiaomiqiu123.top/pb/pay/payNotify
#po9k1ezoyexk.ngrok.xiaomiqiu123.top 内网穿透地址 测试ok 正式环境下切换服务器地址
#wxpay.notifyUrl: http://101.201.146.165:9100
wxpay.notifyUrl: http://59.110.212.44:9100/pb/pay/payNotify
# 退款通知回调, pjm6m9.natappfree.cc 为内网穿透地址
wxpay.refundNotifyUrl: http://pjm6m9.natappfree.cc/pay/refundNotify
# 密钥路径,resources下
wxpay.keyPemPath:C:\\Users\\Administrator\\IdeaProjects\\peanut_book\\src\\main\\resources\\cent\\apiclient_key.pem
# 密钥路径,resources下 /usr/local/hs/peanut_book/target/classes/cent/apiclient_key.pem
wxpay.keyPemPath:C:/Users/Administrator/IdeaProjects/peanut_book/src/main/resources/cent/apiclient_key.pem
#商户证书序列号
wxpay.serialNo: 679AECB2F7AC4183033F713828892BA640E4EEE3
#微信服务器地址
wxpay.domain: https://api.mch.weixin.qq.com
#wxpay:
##应用编号
#wxpay.appId: wx47134a8f15083734
##商户号
#wxpay.mchId: 1612860909
## APIv3密钥
#wxpay.apiV3Key: 4aYFklzaULeGlr7oJPZ6rHWKcxjihZUF
## 微信支付V3-url前缀
#wxpay.baseUrl: https://api.mch.weixin.qq.com/v3
##po9k1ezoyexk.ngrok.xiaomiqiu123.top 内网穿透地址 测试ok 正式环境下切换服务器地址
#
##wxpay.notifyUrl: http://101.201.146.165:9100
#
#wxpay.notifyUrl: http://59.110.212.44:9100/pb/pay/payNotify
#
## 退款通知回调, pjm6m9.natappfree.cc 为内网穿透地址
#wxpay.refundNotifyUrl: http://pjm6m9.natappfree.cc/pay/refundNotify
## 密钥路径,resources下 /usr/local/hs/peanut_book/target/classes/cent/apiclient_key.pem
#
#wxpay.keyPemPath:/usr/local/hs/peanut_book/target/classes/cent/apiclient_key.pem
##商户证书序列号
#wxpay.serialNo: 679AECB2F7AC4183033F713828892BA640E4EEE3
##微信服务器地址
#wxpay.domain: https://api.mch.weixin.qq.com