This commit is contained in:
yc13649764453
2023-09-18 09:41:19 +08:00
parent 8d3c128f3b
commit 9ada233eb7
60 changed files with 8255 additions and 655 deletions

View File

@@ -0,0 +1,10 @@
package com.peanut.common.utils;
import lombok.Data;
@Data
public class CommConfig {
String userAppID="";
String userAppSecret="";
}

View File

@@ -0,0 +1,47 @@
package com.peanut.common.utils;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.io.IOException;
/**
* 8.2上传测试工具类
*/
public class FileUtils {
/**
* @param file 文件
* @param path 文件存放路径
* @param fileName 保存的文件名
* @return
*/
public static boolean upload(MultipartFile file, String path, String fileName) {
//确定上传的文件名
String realPath = path + "\\" + fileName;
System.out.println("上传文件:" + realPath);
File dest = new File(realPath);
//判断文件父目录是否存在
if (!dest.getParentFile().exists()) {
dest.getParentFile().mkdir();
}
try {
//保存文件
file.transferTo(dest);
return true;
} catch (IllegalStateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return false;
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return false;
}
}
}

View File

@@ -0,0 +1,17 @@
package com.peanut.common.utils;
import lombok.Data;
@Data
public class WeiXinParam {
String openid = "";
String unionId = "";
String sex = "1";
String nickname = "";
String city = "";
String province = "";
String country = "";
String avatarUrl = "";
String headimgurl="";
}

View File

@@ -0,0 +1,150 @@
package com.peanut.common.utils;
import com.alibaba.fastjson.JSONObject;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.HttpClients;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URI;
/**
* @program:
* @description: app用户登陆
* @author:
**/
public class WeixinLoginUtils {
/**
* 微信登陆通过code获取accessToken
* @param appId
* @param userAppSecret
* @param code
* @return
* @throws Exception
*/
public StringBuilder getAccessTokenBycode(String appId,String userAppSecret,String code) throws Exception{
//查看官方文档 https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&t=resource/res_list&verify=1&id=open1419317853&token=&lang=
String url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid="+appId+"&secret="+
userAppSecret+"&code="+code+"&grant_type=authorization_code";
URI uri = URI.create(url);
HttpClient client = HttpClients.createDefault();
HttpGet get = new HttpGet(uri);
HttpResponse response=client.execute(get);
StringBuilder sb = new StringBuilder();
if (response.getStatusLine().getStatusCode() == 200) {
HttpEntity entity = response.getEntity();
BufferedReader reader = new BufferedReader(new InputStreamReader(entity.getContent(), "UTF-8"));
for (String temp = reader.readLine(); temp != null; temp = reader.readLine()) {
sb.append(temp);
}
}
return sb;
}
/**
* access_token是否有效的验证
* @param accessToken
* @param openID
* @return
*/
public boolean isAccessTokenIsInvalid(String accessToken,String openID) throws Exception{
String url = "https://api.weixin.qq.com/sns/auth?access_token=" + accessToken + "&openid=" + openID;
URI uri = URI.create(url);
HttpClient client = HttpClients.createDefault();
HttpGet get = new HttpGet(uri);
HttpResponse response = client.execute(get);
if (response.getStatusLine().getStatusCode() == 200) {
HttpEntity entity = response.getEntity();
BufferedReader reader = new BufferedReader(new InputStreamReader(entity.getContent(), "UTF-8"));
StringBuilder sb = new StringBuilder();
for (String temp = reader.readLine(); temp != null; temp = reader.readLine()) {
sb.append(temp);
}
JSONObject object = JSONObject.parseObject(sb.toString().trim());
int errcode = object.getInteger("errcode");
if (errcode == 0) {
//未失效
return true;
}
}
return false;
}
/**
* access_token 接口调用凭证
* expires_in access_token接口调用凭证超时时间单位
* refresh_token 用户刷新access_token
* openid 授权用户唯一标识
* scope 用户授权的作用域,使用逗号(,)分隔
* @param APP_ID
*/
public JSONObject refreshAccessToken(String APP_ID,String refreshToken) throws Exception{
/**
* access_token是调用授权关系接口的调用凭证由于access_token有效期目前为2个小时较短当access_token超时后可以使用refresh_token进行刷新access_token刷新结果有两种
*
* 1.若access_token已超时那么进行refresh_token会获取一个新的access_token新的超时时间
*
* 2.若access_token未超时那么进行refresh_token不会改变access_token但超时时间会刷新相当于续期access_token。
*
* refresh_token拥有较长的有效期30天且无法续期当refresh_token失效的后需要用户重新授权后才可以继续获取用户头像昵称。
*/
String uri = "https://api.weixin.qq.com/sns/oauth2/refresh_token?appid=" + APP_ID + "&grant_type=refresh_token&refresh_token=" + refreshToken;
HttpClient client = HttpClients.createDefault();
HttpGet get = new HttpGet(URI.create(uri));
HttpResponse response = client.execute(get);
JSONObject object =new JSONObject();
if (response.getStatusLine().getStatusCode() == 200) {
BufferedReader reader = new BufferedReader(new InputStreamReader(response.getEntity().getContent(), "UTF-8"));
StringBuilder builder = new StringBuilder();
for (String temp = reader.readLine(); temp != null; temp = reader.readLine()) {
builder.append(temp);
}
object = JSONObject.parseObject(builder.toString().trim());
}
return object;
}
/**
* 得到用户基本信息
* @param accessToken
* @param openId
* @param tClass
* @return
* @throws Exception
*/
public <T> T getAppWeiXinUserInfo(String accessToken, String openId, Class<T> tClass) throws Exception{
String uri = "https://api.weixin.qq.com/sns/userinfo?access_token="+accessToken+"&openid="+openId;
HttpClient client = HttpClients.createDefault();
HttpGet get = new HttpGet(URI.create(uri));
HttpResponse response = client.execute(get);
if (response.getStatusLine().getStatusCode() == 200) {
BufferedReader reader = new BufferedReader(new InputStreamReader(response.getEntity().getContent(), "UTF-8"));
StringBuilder builder = new StringBuilder();
for (String temp = reader.readLine(); temp != null; temp = reader.readLine()) {
System.out.println(temp);
builder.append(temp);
}
return JSONObject.parseObject(builder.toString(), tClass);
}
return null;
}
}

View File

@@ -1,10 +1,11 @@
package com.peanut.modules.book.controller;
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.BookCategoryEntity;
import com.peanut.modules.book.entity.ShopCategoryEntity;
import com.peanut.modules.book.entity.*;
import com.peanut.modules.book.service.BookCategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@@ -55,6 +56,9 @@ public class BookCategoryController {
@RequestMapping("/save")
public R save(@RequestBody BookCategoryEntity bookCategoryEntity){
bookCategoryEntity.setDelFlag(0);
Integer bookCid = bookCategoryEntity.getBookCid();
bookCategoryService.save(bookCategoryEntity);
return R.ok();
@@ -74,29 +78,23 @@ public class BookCategoryController {
* 删除
*/
@RequestMapping("/delete")
public R delete(@RequestBody Integer[] ids){
bookCategoryService.removeByIds(Arrays.asList(ids));
public R delete(@RequestParam Integer id){
// bookCategoryService.removeByIds(id);
bookCategoryService.removeById(id);
return R.ok();
}
/**
* 删除前检查
*/
@RequestMapping("/deleteCheck")
public R deleteCheck(@RequestBody String[] oids){
bookCategoryService.removeCheckByIds(Arrays.asList(oids));
return R.ok();
}
/**
* 获取图书 一级分类
*/
@RequestMapping("/getOneLevel")
public R getOneLevel(){
List<BookCategoryEntity> list = bookCategoryService.getOneLevel();
return R.ok().put("list",list);
List<BookCategoryEntity> book_cid = bookCategoryService.getBaseMapper().selectList(new QueryWrapper<BookCategoryEntity>().eq("book_cid", 0));
return R.ok().put("bookCategoryEntity",book_cid);
}

View File

@@ -80,25 +80,22 @@ public class BookController {
@PathVariable("userId") Integer userId) {
// 判断用户是否够买书籍
BookEntity book = bookService.getById(id);
book.setIsBuy(0);
Boolean canListen = book.getCanListen();
// Integer isVip = book.getIsVip(); // 0-免费 1-会免 2-付费
book.setIsBuy(true);
boolean b = myUserService.bookAuthenticate(id, userId);
boolean b = myUserService.bookAuthen(id, userId);
if (!b) {
// 无权限
book.setIsBuy(0);
book.setIsBuy(false);
}
//书籍详情返回,购买状态,免费章节数
// if (canListen==false) {
// // 无权限
// return R.error("该图书暂未开通听书功能");
// }
String authorName = "";
@@ -163,8 +160,7 @@ public class BookController {
book.setAuthorName(authorName);
book.setPublisherName(publisherName);
book.setFlag(flag);
return R.ok().put("book", book).put("canListen",canListen);
return R.ok().put("book", book);
}
/**
@@ -333,8 +329,68 @@ public class BookController {
/**
* 对外图标列表
* app 电子书目录
*/
@RequestMapping("/getCatalogue")
public R getCatalogue(@RequestParam("bookid") Integer id
) {
BookEntity bookEntity = bookService.getBaseMapper().selectById(id);
if (bookEntity == null) {
return R.error("当前图书不存在或已删除");
}
String images = bookEntity.getImages() ;
Integer number=null;
List<BookChapterEntity> bookChapterEntities = bookChapterService.getBaseMapper().selectList(new QueryWrapper<BookChapterEntity>().eq("book_id", id));
List<HashMap<Object, Object>> chapterList = new ArrayList<>();
for (BookChapterEntity bookEntitys : bookChapterEntities) {
number = bookEntitys.getNumber();
HashMap<Object, Object> map = new HashMap<>();
map.put("bookid",id);
map.put("number", bookEntitys.getNumber());
map.put("chapterId", bookEntitys.getId());
map.put("chapterName", bookEntitys.getChapter());
//freeChapterCount
map.put("images",images);
chapterList.add(map);
}
if (number==null) {
return R.error("当前电子书目录为空");
}else{
return R.ok().put("BookCatalogue",chapterList);
}
}
//书籍详情返回,购买状态,免费章节数
/**
* app 获取免费章节数
*/
@RequestMapping("/getfreeChapter")
public R getfreeChapter(@RequestParam("bookid") Integer id
) {
BookEntity bookEntity = bookService.getBaseMapper().selectById(id);
if (bookEntity == null) {
return R.error("当前图书不存在或已删除");
}
Integer freeChapterCount = bookEntity.getFreeChapterCount();
if (freeChapterCount == null) {
return R.error("当前电子书目录为空");
} else {
return R.ok().put("freeChapterCount", freeChapterCount);
}
}
/**
* 对外图标列表
*/
@RequestMapping("/listForWebsite")
// @RequiresPermissions("book:book:list")
public R listForWebsite(@RequestParam Map<String, Object> params) {

View File

@@ -148,9 +148,20 @@ public class BuyOrderController {
BuyOrderDetailEntity buyOrderDetailEntity = new BuyOrderDetailEntity();
Integer productId = buyOrderDetail.getProductId();
ShopProductEntity product = shopProductService.getById(productId);
BigDecimal price = product.getPrice();
BigDecimal activityPrice = product.getActivityPrice();
BigDecimal big = new BigDecimal(0);
BigDecimal price=null;
//activityPrice等于0则原价
if (activityPrice == big) {
price = product.getPrice();
}else {
price = product.getActivityPrice();
}
Integer quantity = buyOrderDetail.getQuantity();
BigDecimal bigDecimal = new BigDecimal(price.doubleValue() * quantity);
System.out.println("bigDecimal=================bigDecimal======================"+bigDecimal);
bigDecimal1 = bigDecimal1.add(bigDecimal);
if (product.getProductStock() - buyOrderDetail.getQuantity() < 0 ){
@@ -295,10 +306,23 @@ public class BuyOrderController {
BuyOrderDetailEntity buyOrderDetailEntity = new BuyOrderDetailEntity();
Integer productId = buyOrderDetail.getProductId();
ShopProductEntity product = shopProductService.getById(productId);
BigDecimal price = product.getPrice();
// BigDecimal price = product.getPrice();
Integer quantity = buyOrderDetail.getQuantity();
BigDecimal activityPrice = product.getActivityPrice();
BigDecimal big = new BigDecimal(0);
BigDecimal price=null;
//activityPrice等于0则原价
if (activityPrice == big) {
price = product.getPrice();
}else {
price = product.getActivityPrice();
}
//价格*数量 = 单价*购买数量赋值给bigDecimal1
BigDecimal bigDecimal = new BigDecimal(price.doubleValue() * quantity);
System.out.println("bigDecimal========bigDecimal=========bigDecimal======================"+bigDecimal);
bigDecimal1 = bigDecimal1.add(bigDecimal);
if (product.getProductStock() - buyOrderDetail.getQuantity() < 0) {

View File

@@ -62,6 +62,7 @@ public class OrderCartController {
@RequestMapping("/save")
// @RequiresPermissions("book:ordercart:save")
public R save(@RequestBody OrderCartEntity orderCart){
orderCartService.save(orderCart);
return R.ok();

View File

@@ -1,14 +1,11 @@
package com.peanut.modules.book.controller;
import java.math.BigDecimal;
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.entity.ShopCategoryEntity;
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.entity.*;
import com.peanut.modules.book.service.*;
import com.peanut.modules.book.vo.ShopProductVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
@@ -16,8 +13,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.modules.book.entity.ShopProductEntity;
import com.peanut.modules.book.service.ShopProductService;
import com.peanut.common.utils.PageUtils;
import com.peanut.common.utils.R;
@@ -42,8 +37,8 @@ public class ShopProductController {
@Autowired
private BookService bookService;
// 商品销量 productSalesVolume
@Autowired
private ShopProudictBookService shopProudictBookService;
@@ -158,31 +153,27 @@ public class ShopProductController {
@RequestMapping("/bookinfo/{productId}")
public R bookinfo(@PathVariable("productId") Integer productId){
ShopProductEntity shopProductEntity = shopProductService.getBaseMapper().selectOne(new QueryWrapper<ShopProductEntity>().eq("book_ids", productId));
ArrayList<Map<String, String>> imagesUrl = new ArrayList<Map<String,String>>();
ShopProductEntity shopProductEntity = shopProductService.getBaseMapper().selectOne(new QueryWrapper<ShopProductEntity>().eq("product_id", productId));
Integer poid = shopProductEntity.getProductPid();
List<Integer> poids = shopCategoryService.findPoid(poid);
Integer productId1 = shopProductEntity.getProductId();
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>>();
List<Object> list = new ArrayList<>();
ArrayList<String> booklist = new ArrayList<>();
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)
;
}
List<ShopProudictBookEntity> proudict = shopProudictBookService.getBaseMapper().selectList(new QueryWrapper<ShopProudictBookEntity>()
.eq("proudict_id", productId1));
for (ShopProudictBookEntity shopProudictBookEntity : proudict) {
Integer bookId = shopProudictBookEntity.getBookId();
BookEntity byId = bookService.getById(bookId);
booklist.add(String.valueOf(bookId));
list.add(byId);
}
shopProductEntity.setBookidsimages(imagesUrl);
shopProductEntity.setBookidsimages(list);
shopProductEntity.setBookids(booklist);
return R.ok().put("shopProduct", shopProductEntity);
}
@@ -200,45 +191,34 @@ public class ShopProductController {
public R info(@PathVariable("productId") Integer productId){
ShopProductEntity shopProductEntity = shopProductService.getBaseMapper().selectOne(new QueryWrapper<ShopProductEntity>().eq("product_id", productId));
ArrayList<Map<String, String>> imagesUrl = new ArrayList<Map<String,String>>();
ArrayList<Map<String, String>> imagesUrls = new ArrayList<Map<String,String>>();
Integer poid = shopProductEntity.getProductPid();
String bookids = shopProductEntity.getBookId();
Integer productId1 = shopProductEntity.getProductId();
System.out.println("productId1=============================="+productId1);
List<Integer> poids = shopCategoryService.findPoid(poid);
shopProductEntity.setPoids(poids);
ArrayList<String> list = new ArrayList<>();
String bookId = shopProductEntity.getBookId();
list.add(bookId);
shopProductEntity.setBookids(list);
//TODO 判定
if (shopProductEntity.getBookId() != null) {
String bookId1 = shopProductEntity.getBookId();
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)
;
}
}
List<Object> list = new ArrayList<>();
ArrayList<String> booklist = new ArrayList<>();
}else {
ShopProductEntity shopProduct = shopProductService.getById(productId);
return R.ok().put("shopProduct", shopProduct);
List<ShopProudictBookEntity> proudict = shopProudictBookService.getBaseMapper().selectList(new QueryWrapper<ShopProudictBookEntity>()
.eq("proudict_id", productId1));
for (ShopProudictBookEntity shopProudictBookEntity : proudict) {
Integer bookId = shopProudictBookEntity.getBookId();
BookEntity byId = bookService.getById(bookId);
booklist.add(String.valueOf(bookId));
list.add(byId);
}
Boolean canListen=null;
shopProductEntity.setBookidsimages(imagesUrl);
shopProductEntity.setBookidsimages(list);
shopProductEntity.setBookids(booklist);
return R.ok().put("shopProduct", shopProductEntity);
}
@@ -248,47 +228,62 @@ public class ShopProductController {
* 保存
*/
@RequestMapping("/save")
public R save(@RequestBody ShopProductEntity shopProduct){
public R save(@RequestBody ShopProductEntity shopProduct) {
shopProduct.setCreateTime(new Date());
//用list集合接收数组转String类型字符串
String bkids = "";
for(String s : shopProduct.getBookids()){
bkids += s+",";
// //用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);
// }else {
// shopProduct.setBookId("");
// }
shopProductService.save(shopProduct);
ShopProudictBookEntity shopProudictBookEntity = new ShopProudictBookEntity();
for (String s : shopProduct.getBookids()) {
String bookidlist = s;
if (bookidlist != null) {
Integer proudict = shopProduct.getProductId();
shopProudictBookEntity.setProudictId(proudict);
shopProudictBookEntity.setBookId(Integer.valueOf(bookidlist));
shopProudictBookService.save(shopProudictBookEntity);
}
}
if (bkids!=null &&!bkids.isEmpty()){
String substring = bkids.substring(0, bkids.length() - 1);
shopProduct.setBookId(substring);
}else {
shopProduct.setBookId("");
}
shopProduct.setCreateTime(new Date());
shopProductService.save(shopProduct);
return R.ok();
}
/**
* 修改
*/
@RequestMapping("/update")
public R update(@RequestBody ShopProductEntity 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("");
}
public R update(@RequestBody ShopProductEntity shopProduct) {
ShopProudictBookEntity shopProudictBookEntity = new ShopProudictBookEntity();
shopProductService.updateById(shopProduct);
return R.ok();
}
shopProductService.updateById(shopProduct);
return R.ok();
}
/**
* 删除
*/

View File

@@ -0,0 +1,108 @@
package com.peanut.modules.book.controller;
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.ShopProudictBookEntity;
import com.peanut.modules.book.service.ShopProudictBookService;
import com.peanut.modules.book.vo.ProudictBookqueryVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping("book/shopProudictBook")
public class ShopProudictBookController {
@Autowired
private ShopProudictBookService shopProudictBookService;
/**
* 列表
*/
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params ){
PageUtils page = shopProudictBookService.queryPage(params);
return R.ok().put("page", page);
}
/**
* 图书与商品信息
*/
@RequestMapping("/proudictBooklist")
public R proudictBooklist(@RequestParam Integer proudictId){
List<ProudictBookqueryVO> cartList = shopProudictBookService.getCartList(proudictId);
return R.ok().put("cartList", cartList);
}
/**
* 保存
*/
@RequestMapping("/save")
public R save(@RequestBody ShopProudictBookEntity shopProudictBookEntity){
for(Integer s : shopProudictBookEntity.getBookidlist()){
Integer bookidlist = s;
if (bookidlist!=null){
Integer proudict = shopProudictBookEntity.getProudictId();
shopProudictBookEntity.setProudictId(proudict);
shopProudictBookEntity.setBookId(bookidlist);
shopProudictBookService.save(shopProudictBookEntity);
}
}
return R.ok();
}
/**
* 修改
*/
@RequestMapping("/update")
public R update(@RequestBody ShopProudictBookEntity shopProudictBookEntity){
shopProudictBookService.updateById(shopProudictBookEntity);
return R.ok();
}
/**
* 删除
*/
@RequestMapping("/delete")
public R delete(@RequestParam Integer id){
shopProudictBookService.removeById(id);
return R.ok();
}
}

View File

@@ -33,6 +33,7 @@ public class UserRecordController {
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params ){
PageUtils page = userRecordService.queryPage(params);
return R.ok().put("page", page);
}
@@ -187,8 +188,8 @@ public class UserRecordController {
userRecordEntity.setBookid(bookid);
userRecordEntity.setUserid(userid);
userRecordEntity.setOrderSn(orderSn);
userRecordEntity.setOrderCode(userRecordEntity.getOrderCode());
userRecordEntity.setDelflag(0);
userRecordEntity.setProudictId(bookid);
userRecordService.saveOrUpdate(userRecordEntity);
return R.ok("成功").put("userRecordEntity",userRecordEntity);
}

View File

@@ -1,7 +1,9 @@
package com.peanut.modules.book.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.peanut.modules.book.entity.BookCategoryEntity;
import org.apache.ibatis.annotations.Mapper;
@@ -9,5 +11,7 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface BookCategoryDao extends BaseMapper<BookCategoryEntity> {
public interface BookCategoryDao extends BaseMapper<BookCategoryEntity> {
}

View File

@@ -0,0 +1,9 @@
package com.peanut.modules.book.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.peanut.modules.book.entity.ShopProudictBookEntity;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface ShopProudictBookDao extends BaseMapper<ShopProudictBookEntity> {
}

View File

@@ -156,7 +156,12 @@ public class BookEntity implements Serializable {
private Integer chapterNum;
@TableField(exist = false)
private Integer isBuy;
private Boolean isBuy;
// @TableField(exist = false)
// private Boolean bookAuthen;
@TableField("can_listen")

View File

@@ -32,6 +32,10 @@ public class OrderCartEntity implements Serializable {
* 商品id
*/
private Integer productId;
/**
* 套装参数
*/
private Integer proudictBook;
/**
* 商品数量
*/

View File

@@ -37,7 +37,7 @@ public class ShopProductEntity implements Serializable {
*/
private BigDecimal price;
/**
* 商品价格
* 商品活动价格
*/
private BigDecimal activityPrice;
/**
@@ -151,10 +151,14 @@ public class ShopProductEntity implements Serializable {
private ArrayList<String> bookids;
/**
* 多个电子书Id
* 多个电子书Id ArrayList<Map<String,String>>
*/
@TableField(exist = false)
private ArrayList<Map<String,String>> bookidsimages;
private List<Object> bookidsimages;
@TableField(exist = false)
private List<Object> shoproudBook;
// private Object bookidsimages;

View File

@@ -0,0 +1,45 @@
package com.peanut.modules.book.entity;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import java.util.ArrayList;
import java.util.Date;
@Data
@TableName("shop_proudict_book")
public class ShopProudictBookEntity {
@TableId
private Integer id;
/**
* 商品id
*/
@TableField("proudict_id")
private Integer proudictId;
/**
*图书id
*/
@TableField("book_id")
private Integer bookId;
/**
* 多个图书id (备用)
*/
@TableField("book_ids")
private Integer bookdIds;
@TableField("del_flag")
@TableLogic
private Integer delFlag;
/**
* 创建日期
*/
@TableField(fill = FieldFill.INSERT)
private Date createTime;
@TableField(exist = false)
private ArrayList<Integer> bookidlist;
}

View File

@@ -34,6 +34,9 @@ public class UserRecordEntity {
//快递单号
@TableField("orderCode")
private String orderCode;
@TableField("proudict_id")
private Integer proudictId;
//订单号
@TableField("orderSn")
private String orderSn;
@@ -72,4 +75,10 @@ public class UserRecordEntity {
private Integer orderdid;
@TableField(exist = false)
private Object avatar;
@TableField(exist = false)
private Object nickname;
}

View File

@@ -1,15 +1,18 @@
package com.peanut.modules.book.service;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.service.IService;
import com.peanut.common.utils.PageUtils;
import com.peanut.modules.book.entity.BookCategoryEntity;
import com.peanut.modules.book.entity.ShopCategoryEntity;
import java.util.List;
import java.util.Map;
public interface BookCategoryService extends IService<BookCategoryEntity> {
public interface BookCategoryService extends IService<BookCategoryEntity> {
PageUtils queryPage(Map<String, Object> params);
List<BookCategoryEntity> getOneLevel();

View File

@@ -23,10 +23,13 @@ public interface MyUserService extends IService<MyUserEntity> {
PageUtils queryPage(Map<String, Object> params);
void sendCodeForRegister(String phone, String code) throws Exception;
//电子书鉴权
boolean bookAuthenticate(Integer bookId,Integer userId);
//电子书鉴权
boolean bookAuthenti(Integer bookId,Integer userId);
//电子书针对听书鉴权
boolean bookAuthen(Integer bookId,Integer userId);
//会员开通 电话 开通 期限
boolean openMember(Integer customerId,Integer openMonth);
@@ -39,6 +42,6 @@ public interface MyUserService extends IService<MyUserEntity> {
//第三方微信登录
R getUserInfoByApp(UserAppAuthorEntity userAppAuthorEntity);
boolean bookEbookBuy(Integer bookid,Integer userId);
}

View File

@@ -0,0 +1,17 @@
package com.peanut.modules.book.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.peanut.common.utils.PageUtils;
import com.peanut.modules.book.entity.ShopProudictBookEntity;
import com.peanut.modules.book.vo.ProudictBookqueryVO;
import java.util.List;
import java.util.Map;
public interface ShopProudictBookService extends IService<ShopProudictBookEntity> {
PageUtils queryPage(Map<String, Object> params);
PageUtils proudictBookqueryPage(Map<String, Object> params);
List<ProudictBookqueryVO> getCartList(Integer proudictId);
}

View File

@@ -19,7 +19,7 @@ public interface UserRecordService extends IService<UserRecordEntity> {
PageUtils queryPage(Map<String, Object> params);
String uploadFile(MultipartFile file);
List<String> uploadFiles(List<MultipartFile> files);
;
}

View File

@@ -1,7 +1,9 @@
package com.peanut.modules.book.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
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;
@@ -9,6 +11,7 @@ import com.peanut.modules.book.dao.BookCategoryDao;
import com.peanut.modules.book.entity.BookCategoryEntity;
import com.peanut.modules.book.entity.ShopCategoryEntity;
import com.peanut.modules.book.service.BookCategoryService;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
@@ -43,7 +46,7 @@ public class BookCategoryServiceImpl extends ServiceImpl<BookCategoryDao, BookCa
@Override
public List<BookCategoryEntity> listTree() {
List<BookCategoryEntity> entities = baseMapper.selectList(null);
//0为父菜单列表
List<BookCategoryEntity> level1 = entities.stream().filter((catalogueEntity) ->
catalogueEntity.getBookCid() == 0
@@ -58,7 +61,7 @@ public class BookCategoryServiceImpl extends ServiceImpl<BookCategoryDao, BookCa
//子菜单列表
private List<BookCategoryEntity> getChildrens(BookCategoryEntity root,List<BookCategoryEntity> all){
List<BookCategoryEntity> children = all.stream().filter(catalogueEntity -> {

View File

@@ -75,81 +75,75 @@ public class MyUserServiceImpl extends ServiceImpl<MyUserDao, MyUserEntity> impl
@Override
public boolean bookAuthenticate(Integer bookId, Integer userId) {
//查询书籍 类型
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);
String vip = myUserEntity.getVip();
if (!"1".equals(vip)){
// 判断普通用 是否解锁书籍
TransactionDetailsEntity transactionDetailsEntity = transactionDetailsService.getBaseMapper().selectOne(new QueryWrapper<TransactionDetailsEntity>().eq("user_id", userId)
.eq("relation_id", bookId));
if (transactionDetailsEntity == null) {
return false;
}
}
}
if (isVip == 2) {
// TODO 查询 购买表中是否有用户购买记录
TransactionDetailsEntity transactionDetailsEntity = transactionDetailsService.getBaseMapper().selectOne(new QueryWrapper<TransactionDetailsEntity>().eq("user_id", userId)
.eq("relation_id", bookId));
if (transactionDetailsEntity == null) {
return false;
}
}
//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;
}
}
// //查询书籍 类型
// 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);
// String vip = myUserEntity.getVip();
// if (!"1".equals(vip)){
//
// // 判断普通用 是否解锁书籍
// TransactionDetailsEntity transactionDetailsEntity = transactionDetailsService.getBaseMapper().selectOne(new QueryWrapper<TransactionDetailsEntity>().eq("user_id", userId)
// .eq("relation_id", bookId));
//
// if (transactionDetailsEntity == null) {
// return false;
// }
//
// }
// }
// if (isVip == 2) {
//
//
// // TODO 查询 购买表中是否有用户购买记录
// TransactionDetailsEntity transactionDetailsEntity = transactionDetailsService.getBaseMapper().selectOne(new QueryWrapper<TransactionDetailsEntity>().eq("user_id", userId)
// .eq("relation_id", bookId));
//
// if (transactionDetailsEntity == null) {
// return false;
// }
//
// }
// //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) {
public boolean bookAuthen(Integer bookId, Integer userId) {
UserEbookBuyEntity userid = userEbookBuyService.getBaseMapper().selectOne(new QueryWrapper<UserEbookBuyEntity>()
.eq("user_id", userId)
.eq("book_id", bookId));
//查询书籍 类型
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;
}
if (userid == null) {
return false;
}
return true;
}
}
@@ -289,7 +283,7 @@ public class MyUserServiceImpl extends ServiceImpl<MyUserDao, MyUserEntity> impl
MyUserEntity user = this.getById(Integer.valueOf(userId));
Double peanutCoin = user.getPeanutCoin().doubleValue() - salePrice.doubleValue();
if (peanutCoin < 0) {
return "当前书籍购买,请勿重复购买!";
return "当前书籍购买,请勿重复购买!";
}
user.setPeanutCoin(new BigDecimal(peanutCoin));
this.updateById(user);
@@ -389,10 +383,6 @@ public class MyUserServiceImpl extends ServiceImpl<MyUserDao, MyUserEntity> impl
return R.ok("sec");
}
@Override
public boolean bookEbookBuy(Integer bookid, Integer userId) {
return false;
}
private void sendCode(String phone,String code) throws Exception {

View File

@@ -7,6 +7,7 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -50,7 +51,6 @@ public class OrderCartServiceImpl extends ServiceImpl<OrderCartDao, OrderCartEnt
Integer productId = orderCartEntity.getProductId();
ShopProductEntity productEntity = shopProductService.getById(productId);
ShopCartVo shopCartVo = new ShopCartVo();
BeanUtils.copyProperties(orderCartEntity, shopCartVo);
@@ -62,7 +62,19 @@ public class OrderCartServiceImpl extends ServiceImpl<OrderCartDao, OrderCartEnt
shopCartVo.setWeight(productEntity.getWeight().doubleValue());
shopCartVo.setProductStock(productEntity.getProductStock());
shopCartVo.setProudictBook(Integer.valueOf(productEntity.getBookId()));
BigDecimal activityPrice = productEntity.getActivityPrice();
BigDecimal big = new BigDecimal(0);
BigDecimal price=null;
//activityPrice等于0则原价
if (activityPrice == big) {
price = productEntity.getPrice();
}else {
price = productEntity.getActivityPrice();
}
shopCartVo.setActivityPrice(price);
cartList.add(shopCartVo);
}

View File

@@ -0,0 +1,85 @@
package com.peanut.modules.book.service.impl;
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.ShopProudictBookDao;
import com.peanut.modules.book.entity.BookEntity;
import com.peanut.modules.book.entity.ShopCategoryEntity;
import com.peanut.modules.book.entity.ShopProductEntity;
import com.peanut.modules.book.entity.ShopProudictBookEntity;
import com.peanut.modules.book.service.BookService;
import com.peanut.modules.book.service.ShopProductService;
import com.peanut.modules.book.service.ShopProudictBookService;
import com.peanut.modules.book.vo.ProudictBookqueryVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@Service("shopProudictBookService")
public class ShopProudictBookServiceImpl extends ServiceImpl<ShopProudictBookDao,ShopProudictBookEntity> implements ShopProudictBookService {
@Autowired
private ShopProductService shopProductService;
@Autowired
private BookService bookService;
@Override
public PageUtils queryPage(Map<String, Object> params) {
IPage<ShopProudictBookEntity> page = this.page(
new Query<ShopProudictBookEntity>().getPage(params),
new QueryWrapper<ShopProudictBookEntity>()
);
return new PageUtils(page);
}
@Override
public PageUtils proudictBookqueryPage(Map<String, Object> params) {
Object proudictId = params.get("proudictId");
IPage<ShopProudictBookEntity> page = this.page(
new Query<ShopProudictBookEntity>().getPage(params),
new QueryWrapper<ShopProudictBookEntity>().eq("proudict_id",proudictId)
);
List<ShopProudictBookEntity> records = page.getRecords();
return new PageUtils(page);
}
@Override
public List<ProudictBookqueryVO> getCartList(Integer proudictId) {
List<ShopProudictBookEntity> proudictBooklist = this.list(new QueryWrapper<ShopProudictBookEntity>().eq("proudict_id", proudictId));
List prList = new ArrayList<>();
for (ShopProudictBookEntity shopProudictBookEntity : proudictBooklist) {
Integer proudictId1 = shopProudictBookEntity.getProudictId();
Integer bookId = shopProudictBookEntity.getBookId();
System.out.println("proudictId1======="+proudictId1);
System.out.println("bookId======="+bookId);
BookEntity bookbyId = bookService.getById(bookId);
ShopProductEntity shopProductbyId = shopProductService.getById(proudictId1);
ProudictBookqueryVO queryVO = new ProudictBookqueryVO();
queryVO.setBookId(bookbyId.getId());
queryVO.setName(bookbyId.getName());
queryVO.setCanListen(bookbyId.getCanListen());
queryVO.setImages(bookbyId.getImages());
queryVO.setClockIn(bookbyId.getClockIn());
queryVO.setProudictId(shopProductbyId.getProductId());
queryVO.setProductName(shopProductbyId.getProductName());
queryVO.setPrice(shopProductbyId.getPrice());
queryVO.setActivityPrice(shopProductbyId.getActivityPrice());
queryVO.setSumSales(shopProductbyId.getSumSales());
prList.add(queryVO);
System.out.println("queryVO======="+queryVO);
}
return prList;
}
}

View File

@@ -6,9 +6,13 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.peanut.common.utils.*;
import com.peanut.modules.book.dao.UserRecordDao;
import com.peanut.modules.book.entity.BookEntity;
import com.peanut.modules.book.entity.MyUserEntity;
import com.peanut.modules.book.entity.UserRecordEntity;
import com.peanut.modules.book.service.MyUserService;
import com.peanut.modules.book.service.UserRecordService;
import org.joda.time.DateTime;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;
@@ -20,7 +24,8 @@ import java.util.*;
@Service("UserRecordServiceImpl")
public class UserRecordServiceImpl extends ServiceImpl<UserRecordDao, UserRecordEntity> implements UserRecordService {
@Autowired
private MyUserService myUserService;
@Override
@@ -33,19 +38,29 @@ public class UserRecordServiceImpl extends ServiceImpl<UserRecordDao, UserRecor
@Override
public PageUtils queryPage(Map<String, Object> params) {
String orderSn = (String) params.get("orderSn");
IPage<UserRecordEntity> page =page(
new Query<UserRecordEntity>().getPage(params),
new QueryWrapper<UserRecordEntity>()
//订单号,开始时间
.eq("orderSn",orderSn).orderByDesc("create_time")
String proudictid = (String) params.get("proudictId");
IPage<UserRecordEntity> page = page(
new Query<UserRecordEntity>().getPage(params),
new QueryWrapper<UserRecordEntity>()
//订单号,开始时间
.eq("bookid", proudictid).orderByDesc("create_date")
// .eq("")
);
);
for (UserRecordEntity userRecordEntity : page.getRecords()) {
Integer userid = userRecordEntity.getUserid();
MyUserEntity byId = myUserService.getById(userid);
String avatar = byId.getAvatar();
String nickname = byId.getNickname();
userRecordEntity.setAvatar(avatar);
userRecordEntity.setNickname(nickname);
return new PageUtils(page);
}
return new PageUtils(page);
}
@Override
public String uploadFile(MultipartFile file) {
@@ -76,36 +91,6 @@ public class UserRecordServiceImpl extends ServiceImpl<UserRecordDao, UserRecor
}
@Override
public List<String> uploadFiles(List<MultipartFile> files) {
String endpoint = ConstantPropertiesUtils.END_POIND;
String accessKeyId = ConstantPropertiesUtils.ACCESS_KEY_ID;
String accessKeySecret = ConstantPropertiesUtils.ACCESS_KEY_SECRET;
String bucketName = ConstantPropertiesUtils.BUCKET_NAME;
try {
//创建oss实例
OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
List<String> urls = new ArrayList<>();
for (MultipartFile file : files) {
InputStream inputStream = file.getInputStream();
String fileName = file.getOriginalFilename();
String uuid = UUID.randomUUID().toString().replaceAll("-", "");
fileName = uuid + fileName;
String datePath = new DateTime().toString("yyyy/MM/dd");
fileName = datePath + "/" + fileName;
ossClient.putObject(bucketName, fileName, inputStream);
urls.add("https://" + bucketName + "." + endpoint + "/" + fileName);
}
//关闭资源否则会导致OLD区逐渐的变大直到内存泄漏
ossClient.shutdown();
return urls;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
}

View File

@@ -0,0 +1,25 @@
package com.peanut.modules.book.vo;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
@Data
public class BookForumArticlesVO {
private String bookid;
private String bookName;
private String authorName;
private String bookimage;
private String image;
private String publisherName;
private String title;
private String content;
private Date create_time;
private Date update_time;
}

View File

@@ -0,0 +1,31 @@
package com.peanut.modules.book.vo;
import com.baomidou.mybatisplus.annotation.TableField;
import lombok.Data;
import java.math.BigDecimal;
@Data
public class ProudictBookqueryVO {
/**
*图书id
*/
private Integer bookId;
private String name;
private Boolean canListen;
private Integer clockIn;
private String images;
private Integer proudictId;
private String productName;
private BigDecimal price;
private BigDecimal activityPrice;
private Integer sumSales;
}

View File

@@ -27,6 +27,16 @@ public class ShopCartVo {
*/
private BigDecimal price;
/**
* 商品活动单价
*/
private BigDecimal activityPrice;
/**
* 商品活动单价
*/
private Integer proudictBook;
private String image;
private String productName;

View File

@@ -0,0 +1,116 @@
package com.peanut.modules.pay.applePay.utils;
import io.swagger.annotations.ApiModel;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
//购买所需参数类
@ApiModel(value = "支付数据字段对比")
@Data
@AllArgsConstructor //有参数的构造方法
@NoArgsConstructor //无参构造方法
public class AddIosOrderPM implements Serializable {
//
// /**
// * ios支付所需参数
// */
// private String receipt;
//
// /**
// * 用户id
// */
// private Integer userId;
//
/**
* 交易编号
* eg:1000000852134037 交易唯一标识符;
*/
private String transaction_id;
/**
* APP所有权类型 eg: PURCHASED为沙箱环境
* eg:PURCHASED
*/
private String in_app_ownership_type;
/**
* 原来的交易编号 原始购买标识符
* eg:1000000852108057
*/
private String original_transaction_id;
/**
* 数量
* eg:1 购买消耗品的数量
*/
private String quantity;
/**
* 唯一标识符
* eg:1e10a9ec617549f986765b8546eddd0a9f349f15
*/
private String unique_identifier;
/**
* item_id
* eg:1578853844
*/
private String item_id;
/**
* 处于介绍报价期
* eg:false
*/
private String is_in_intro_offer_period;
/**
* 购买日期
* eg:2021-08-02 03:57:56 America/Los_Angeles
*/
private String purchase_date_pst;
/**
* 原始购买日期 ms
* eg:1627900203000
*/
private String original_purchase_date_ms;
/**
* 原始购买日期
* eg:2021-08-02 03:30:03 America/Los_Angeles 太平洋时区
*/
private String original_purchase_date_pst;
/**
* 是试用期
* eg:false
*/
private String is_trial_period;
/**
* 原始购买日期
* eg:2021-08-02 10:30:03 Etc/GMT 原始购买时间 ISO 8601日期格式
*/
private String original_purchase_date;
/**
* 购买日期ms 时间日期
*/
private String purchase_date_ms;
/**
* 产品id 购买产品唯一标识符
* eg:2
*/
private String product_id;
private String bvrs;
/**
* 购买日期
* eg:2021-08-02 10:57:56 Etc/GMT 时间日期
*/
private String purchase_date;
private String bid;
/**
* 唯一供应商标识符
* eg:A1D7647F-019C-4D15-A23C-3A48CFBFF4E3
*/
private String unique_vendor_identifier;
}

View File

@@ -0,0 +1,21 @@
package com.peanut.modules.pay.applePay.utils;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class IPayNotifyPo {
@ApiModelProperty("苹果支付凭证")
private String transactionReceipt;
@ApiModelProperty("苹果支付单号")
private String payId;
@ApiModelProperty("用户id")
private String userId;
@ApiModelProperty("金额id")
private String moneyId;
}

View File

@@ -0,0 +1,79 @@
package com.peanut.modules.pay.applePay.utils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import java.io.Serializable;
@Data
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = true)
@ApiModel("订单号")
public class TsBill implements Serializable {
private static final long serialVersionUID = 1L;
// @ApiModelProperty("苹果支付凭证")
// private String transactionReceipt;
//
// @ApiModelProperty("苹果支付单号")
// private String payId;
// iOS端支付完成苹果返回给iOS端的那个receiptData app返回的数据
// @ApiModelProperty("用户id")
// private String userId;
//
// @ApiModelProperty("金额id")
// private String moneyId;
// @ApiModelProperty("")
// private String currentState;
// @ApiModelProperty("IOS内购商品Id")
// private String product_id; // IOS内购商品Id
// @ApiModelProperty("应用内购买的时间")
// private String purchase_date_pst; // 应用内购买的时间
// @ApiModelProperty("购买的消费品数量")
// private String quantity; // 购买的消费品数量
// @ApiModelProperty("交易的唯一标识符")
// private String transaction_id; //
//
// @ApiModelProperty("支付时间")
// private String purchase_date_ms; //
// @ApiModelProperty("拿到收据的MD5")
// private String receiptMd5; //
// @ApiModelProperty("拿到收据的MD5")
// private String BillNum; //
@ApiModelProperty("主键ID")
private String id;
@ApiModelProperty("用户ID")
private String usersId;
@ApiModelProperty("充值配置ID")
private String paymentConfigId;
@ApiModelProperty("交易单号根据当前的28位当前时间加上11位随机数字对上的")
private String billNum;
@ApiModelProperty("交易号")
private String tradeNo;
@ApiModelProperty("账单生成方式,比如充值,说说币之类的")
private String billContent;
@ApiModelProperty("账单对应的金额id")
private String billSumofmoney;
@ApiModelProperty("账单类型还是充值")
private Integer billState;
@ApiModelProperty(" 当前状态,0是支付失败,1是支付成功,10是待支付")
private Integer currentState;
@ApiModelProperty("支付方式0是虚拟币,1是支付宝,2是微信3是ios")
private Integer paymentMethod;
@ApiModelProperty("收据MD5,仅ios可用")
private String receipt;
@ApiModelProperty("创集时间")
private String createtdate;
@ApiModelProperty("修改时间")
private String updatedate;
}

View File

@@ -0,0 +1,13 @@
package com.peanut.modules.pay.applePay.utils;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
/**
* @author talkmate
*/
@Mapper
public interface TsBillMapper extends BaseMapper<TsBill>{
}

View File

@@ -0,0 +1,168 @@
package com.peanut.modules.pay.wechat.util;
import org.apache.http.Consts;
import org.apache.http.HttpEntity;
import org.apache.http.NameValuePair;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.*;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.conn.ssl.SSLContextBuilder;
import org.apache.http.conn.ssl.TrustStrategy;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
import javax.net.ssl.SSLContext;
import java.io.IOException;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import java.text.ParseException;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
/**
* http请求客户端
*/
public class HttpClientUtils {
private String url;
private Map<String, String> param;
private int statusCode;
private String content;
private String xmlParam;
private boolean isHttps;
public boolean isHttps() {
return isHttps;
}
public void setHttps(boolean isHttps) {
this.isHttps = isHttps;
}
public String getXmlParam() {
return xmlParam;
}
public void setXmlParam(String xmlParam) {
this.xmlParam = xmlParam;
}
public HttpClientUtils(String url, Map<String, String> param) {
this.url = url;
this.param = param;
}
public HttpClientUtils(String url) {
this.url = url;
}
public void setParameter(Map<String, String> map) {
param = map;
}
public void addParameter(String key, String value) {
if (param == null)
param = new HashMap<String, String>();
param.put(key, value);
}
public void post() throws ClientProtocolException, IOException {
HttpPost http = new HttpPost(url);
setEntity(http);
execute(http);
}
public void put() throws ClientProtocolException, IOException {
HttpPut http = new HttpPut(url);
setEntity(http);
execute(http);
}
public void get() throws ClientProtocolException, IOException {
if (param != null) {
StringBuilder url = new StringBuilder(this.url);
boolean isFirst = true;
for (String key : param.keySet()) {
if (isFirst) {
url.append("?");
isFirst = false;
}else {
url.append("&");
}
url.append(key).append("=").append(param.get(key));
}
this.url = url.toString();
}
HttpGet http = new HttpGet(url);
execute(http);
}
/**
* set http post,put param
*/
private void setEntity(HttpEntityEnclosingRequestBase http) {
if (param != null) {
List<NameValuePair> nvps = new LinkedList<NameValuePair>();
for (String key : param.keySet())
nvps.add(new BasicNameValuePair(key, param.get(key))); // 参数
http.setEntity(new UrlEncodedFormEntity(nvps, Consts.UTF_8)); // 设置参数
}
if (xmlParam != null) {
http.setEntity(new StringEntity(xmlParam, Consts.UTF_8));
}
}
private void execute(HttpUriRequest http) throws ClientProtocolException,
IOException {
CloseableHttpClient httpClient = null;
try {
if (isHttps) {
SSLContext sslContext = new SSLContextBuilder()
.loadTrustMaterial(null, new TrustStrategy() {
// 信任所有
public boolean isTrusted(X509Certificate[] chain,
String authType)
throws CertificateException {
return true;
}
}).build();
SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(
sslContext);
httpClient = HttpClients.custom().setSSLSocketFactory(sslsf)
.build();
} else {
httpClient = HttpClients.createDefault();
}
CloseableHttpResponse response = httpClient.execute(http);
try {
if (response != null) {
if (response.getStatusLine() != null)
statusCode = response.getStatusLine().getStatusCode();
HttpEntity entity = response.getEntity();
// 响应内容
content = EntityUtils.toString(entity, Consts.UTF_8);
}
} finally {
response.close();
}
} catch (Exception e) {
e.printStackTrace();
} finally {
httpClient.close();
}
}
public int getStatusCode() {
return statusCode;
}
public String getContent() throws ParseException, IOException {
return content;
}
}

View File

@@ -0,0 +1,47 @@
package com.peanut.modules.pay.wechat.util;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;
/**
* 订单号工具类
*
* @author y
* @since 1.0
*/
public class OrderNoUtils {
/**
* 获取订单编号
* @return
*/
public static String getOrderNo() {
return "ORDER_" + getNo();
}
/**
* 获取退款单编号
* @return
*/
public static String getRefundNo() {
return "REFUND_" + getNo();
}
/**
* 获取编号
* @return
*/
public static String getNo() {
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
String newDate = sdf.format(new Date());
String result = "";
Random random = new Random();
for (int i = 0; i < 3; i++) {
result += random.nextInt(10);
}
return newDate + result;
}
}

View File

@@ -0,0 +1,23 @@
package com.peanut.modules.pay.wechat.util;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
public class WXConfigUtil {
private byte[] certData;
public static final String APP_ID = ""; //app Id
public static final String KEY = "";//秘钥
public static final String MCH_ID = ""; //商户号
public WXConfigUtil() throws Exception {
String certPath = "------------------------";//从微信商户平台下载的安全证书存放的路径 eg:D:\apiclient_cert.p12
File file = new File(certPath);
InputStream certStream = new FileInputStream(file);
this.certData = new byte[(int) file.length()];
certStream.read(this.certData);
certStream.close();
}
}

View File

@@ -13,6 +13,8 @@
<result property="createTime" column="create_time"/>
<result property="updateTime" column="update_time"/>
<result property="delFlag" column="del_flag"/>
<result property="proudictBook" column="proudict_book"/>
</resultMap>
<select id="getDeteleOrderCart" resultType="com.peanut.modules.book.entity.OrderCartEntity">

View File

@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.peanut.modules.book.dao.ShopProudictBookDao">
<!-- 可根据自己的需求,是否要使用 -->
<resultMap type="com.peanut.modules.book.entity.ShopProudictBookEntity" id="ProudictBookMap">
<result property="id" column="id"/>
<result property="createTime" column="create_time"/>
<result property="proudictId" column="proudict_id"/>
<result property="delFlag" column="del_flag"/>
<result property="bookId" column="book_id"/>
<result property="bookdIds" column="book_ids"/>
</resultMap>
</mapper>

View File

@@ -14,6 +14,7 @@
<result property="orderCode" column="orderCode"/>
<result property="orderSn" column="orderSn"/>
<result property="starLevel" column="starLevel"/>
<result property="proudictId" column="proudict_id"/>
</resultMap>

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 279 KiB

View File

@@ -0,0 +1,36 @@
package com;
import com.peanut.modules.pay.weChatPay.config.WechatPayConfig;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import javax.annotation.Resource;
import java.security.PrivateKey;
@SpringBootTest
public class VxApiTest {
@Resource
private WechatPayConfig wechatPayConfig;
@Test
public void textgetPrivateKey(){
//获取私钥路径
String keyPemPath = wechatPayConfig.getKeyPemPath();
//获取私钥
PrivateKey privateKey = wechatPayConfig.getPrivateKey(keyPemPath);
//输出很长的字符串 如果有问题转json试试
System.out.println(privateKey);
}
@Test
public void getWxPayConfig(){
String mchId =wechatPayConfig.getMchId();
System.out.println(mchId);
}
}