first commit
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
package com.peanut.modules.book.service;
|
||||
|
||||
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.modules.book.entity.ActivityEntity;
|
||||
import com.peanut.modules.book.entity.BuyOrderEntity;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 订单表
|
||||
*
|
||||
* @author yl
|
||||
* @email yl328572838@163.com
|
||||
* @date 2022-08-29 15:27:44
|
||||
*/
|
||||
public interface ActivityService extends IService<ActivityEntity> {
|
||||
|
||||
PageUtils queryPage(Map<String, Object> params);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
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.AuthorEntity;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 作者表
|
||||
*
|
||||
* @author yl
|
||||
* @email yl328572838@163.com
|
||||
* @date 2022-08-04 15:36:59
|
||||
*/
|
||||
public interface AuthorService extends IService<AuthorEntity> {
|
||||
|
||||
PageUtils queryPage(Map<String, Object> params);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
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.BookBrowseRecordsEntity;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 阅读记录
|
||||
*
|
||||
* @author yl
|
||||
* @email yl328572838@163.com
|
||||
* @date 2022-08-29 15:27:44
|
||||
*/
|
||||
public interface BookBrowseRecordsService extends IService<BookBrowseRecordsEntity> {
|
||||
|
||||
PageUtils queryPage(Map<String, Object> params);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
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.BookBuyConfigEntity;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author yl
|
||||
* @email yl328572838@163.com
|
||||
* @date 2022-10-17 14:54:08
|
||||
*/
|
||||
public interface BookBuyConfigService extends IService<BookBuyConfigEntity> {
|
||||
|
||||
PageUtils queryPage(Map<String, Object> params);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
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.BookChapterContentEntity;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author yl
|
||||
* @email yl328572838@163.com
|
||||
* @date 2022-08-16 14:32:06
|
||||
*/
|
||||
public interface BookChapterContentService extends IService<BookChapterContentEntity> {
|
||||
|
||||
PageUtils queryPage(Map<String, Object> params);
|
||||
|
||||
void getBookVoices(Integer id);
|
||||
|
||||
boolean getWordChapterParagraph(Integer bookId);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
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.BookChapterEntity;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author yl
|
||||
* @email yl328572838@163.com
|
||||
* @date 2022-08-12 09:53:25
|
||||
*/
|
||||
public interface BookChapterService extends IService<BookChapterEntity> {
|
||||
|
||||
PageUtils queryPage(Map<String, Object> params);
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
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.BookReadRateEntity;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 阅读进度表
|
||||
*
|
||||
* @author yl
|
||||
* @email yl328572838@163.com
|
||||
* @date 2022-08-29 15:27:44
|
||||
*/
|
||||
public interface BookReadRateService extends IService<BookReadRateEntity> {
|
||||
|
||||
PageUtils queryPage(Map<String, Object> params);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
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.BookEntity;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 图书表
|
||||
*
|
||||
* @author yl
|
||||
* @email yl328572838@163.com
|
||||
* @date 2022-08-04 15:36:59
|
||||
*/
|
||||
public interface BookService extends IService<BookEntity> {
|
||||
|
||||
PageUtils queryPage(Map<String, Object> params);
|
||||
|
||||
void getChapter(Integer id);
|
||||
|
||||
PageUtils getBestBook(Map<String, Object> params);
|
||||
|
||||
PageUtils getNewBook(Map<String, Object> params);
|
||||
|
||||
PageUtils getSaleBook(Map<String, Object> params);
|
||||
|
||||
//获取Word电子书章节
|
||||
boolean getWordChapter(Integer bookId);
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
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.BookShelfEntity;
|
||||
import com.peanut.modules.book.vo.BookShelfVo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 书架表
|
||||
*
|
||||
* @author yl
|
||||
* @email yl328572838@163.com
|
||||
* @date 2022-08-29 15:27:44
|
||||
*/
|
||||
public interface BookShelfService extends IService<BookShelfEntity> {
|
||||
|
||||
PageUtils queryPage(Map<String, Object> params);
|
||||
|
||||
List<BookShelfVo> getUserBookshelf(Integer userId);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
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.BuyOrderDetailEntity;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 商品订单详情表
|
||||
*
|
||||
* @author yl
|
||||
* @email yl328572838@163.com
|
||||
* @date 2022-08-29 15:27:44
|
||||
*/
|
||||
public interface BuyOrderDetailService extends IService<BuyOrderDetailEntity> {
|
||||
|
||||
PageUtils queryPage(Map<String, Object> params);
|
||||
|
||||
PageUtils querySheet(Map<String, Object> params);
|
||||
|
||||
public void batchUpdateByShippingSns(String[] shippingSnList);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.peanut.modules.book.service;
|
||||
|
||||
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.modules.book.entity.BuyOrderEntity;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 订单表
|
||||
*
|
||||
* @author yl
|
||||
* @email yl328572838@163.com
|
||||
* @date 2022-08-29 15:27:44
|
||||
*/
|
||||
public interface BuyOrderService extends IService<BuyOrderEntity> {
|
||||
|
||||
PageUtils queryPage(Map<String, Object> params);
|
||||
PageUtils queryPage1(Map<String, Object> params);
|
||||
|
||||
//更新订单状态
|
||||
void updateOrderStatus(Integer userId,String orderSn,String type);
|
||||
|
||||
// 发送快递
|
||||
public void sendFMS(Integer[] orderIds,String shipperCode,String shipperName);
|
||||
|
||||
// 取消快递
|
||||
public void cancelFMS(String orderSn, String shipperCode, String expNo);
|
||||
|
||||
// 及时查询
|
||||
public JSONObject queryFMS(String shipperCode, String expNo);
|
||||
|
||||
// 查询勾选的订单是否有可合并
|
||||
public List checkOrder(Integer[] orderIds);
|
||||
|
||||
// 查询所有订单是否有可合并
|
||||
public Page checkOrder(Map<String, Object> params);
|
||||
|
||||
// 批量发货功能
|
||||
public void blendSendFMS(Integer[] orderDetailIds,String shipperCode,String shipperName);
|
||||
|
||||
|
||||
public int getProductGoodsType (Map<String, Object> param,Map<String, Object> productMap);
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
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.CityEntity;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 市
|
||||
*
|
||||
* @author yl
|
||||
* @email yl328572838@163.com
|
||||
* @date 2022-10-27 16:07:59
|
||||
*/
|
||||
public interface CityService extends IService<CityEntity> {
|
||||
|
||||
PageUtils queryPage(Map<String, Object> params);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
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.CountyEntity;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 县/区
|
||||
*
|
||||
* @author yl
|
||||
* @email yl328572838@163.com
|
||||
* @date 2022-10-27 16:07:59
|
||||
*/
|
||||
public interface CountyService extends IService<CountyEntity> {
|
||||
|
||||
PageUtils queryPage(Map<String, Object> params);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
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.CouponEntity;
|
||||
import com.peanut.modules.book.entity.CouponHistoryEntity;
|
||||
import com.peanut.modules.book.vo.UserCouponVo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author yl
|
||||
* @email yl328572838@163.com
|
||||
* @date 2022-10-28 17:38:29
|
||||
*/
|
||||
public interface CouponHistoryService extends IService<CouponHistoryEntity> {
|
||||
|
||||
PageUtils queryPage(Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 执行更新 用户已领取券超过有效期后设置状态为过期
|
||||
*/
|
||||
void runCouponsUserStatusTimeOutToExpired();
|
||||
|
||||
List<CouponEntity> appGetCoupon();
|
||||
|
||||
List<UserCouponVo> appGetUserCoupon(Integer userId , String amount,String type);
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
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.CouponProductCategoryRelationEntity;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author yl
|
||||
* @email yl328572838@163.com
|
||||
* @date 2022-10-28 17:38:29
|
||||
*/
|
||||
public interface CouponProductCategoryRelationService extends IService<CouponProductCategoryRelationEntity> {
|
||||
|
||||
PageUtils queryPage(Map<String, Object> params);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
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.CouponProductRelationEntity;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author yl
|
||||
* @email yl328572838@163.com
|
||||
* @date 2022-10-28 17:38:29
|
||||
*/
|
||||
public interface CouponProductRelationService extends IService<CouponProductRelationEntity> {
|
||||
|
||||
PageUtils queryPage(Map<String, Object> params);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
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.CouponEntity;
|
||||
import com.peanut.modules.book.vo.UserCouponVo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author yl
|
||||
* @email yl328572838@163.com
|
||||
* @date 2022-10-28 17:38:29
|
||||
*/
|
||||
public interface CouponService extends IService<CouponEntity> {
|
||||
|
||||
PageUtils queryPage(Map<String, Object> params);
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
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.FMSOrderDetailEntity;
|
||||
import com.peanut.modules.book.entity.FMSOrderEntity;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface FMSOrderDetailService extends IService<FMSOrderDetailEntity> {
|
||||
|
||||
PageUtils queryPage(Map<String, Object> params);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
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.MyUserEntity;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author yl
|
||||
* @email yl328572838@163.com
|
||||
* @date 2022-08-10 14:20:12
|
||||
*/
|
||||
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 openMember(Integer customerId,Integer openMonth);
|
||||
//充值花生币
|
||||
boolean rechargeHSPoint(Integer customerId,Integer HSPoint);
|
||||
//电子书购买
|
||||
String buyEbook(String userId, String bookId,String couponId);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
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.OrderCartEntity;
|
||||
import com.peanut.modules.book.vo.ShopCartVo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 购物车
|
||||
*
|
||||
* @author yl
|
||||
* @email yl328572838@163.com
|
||||
* @date 2022-08-29 15:27:44
|
||||
*/
|
||||
public interface OrderCartService extends IService<OrderCartEntity> {
|
||||
|
||||
PageUtils queryPage(Map<String, Object> params);
|
||||
|
||||
List<ShopCartVo> getCartList(Integer userId);
|
||||
|
||||
OrderCartEntity getDeteleOrderCarts(Integer userId,Integer productId);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
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.PayPaymentOrderEntity;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 充值订单表
|
||||
*
|
||||
* @author yl
|
||||
* @email yl328572838@163.com
|
||||
* @date 2022-08-29 15:27:44
|
||||
*/
|
||||
public interface PayPaymentOrderService extends IService<PayPaymentOrderEntity> {
|
||||
|
||||
PageUtils queryPage(Map<String, Object> params);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
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.PayZfbOrderEntity;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 支付宝订单表
|
||||
*
|
||||
* @author yl
|
||||
* @email yl328572838@163.com
|
||||
* @date 2022-08-29 15:27:44
|
||||
*/
|
||||
public interface PayZfbOrderService extends IService<PayZfbOrderEntity> {
|
||||
|
||||
PageUtils queryPage(Map<String, Object> params);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
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.ProvinceEntity;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 省
|
||||
*
|
||||
* @author yl
|
||||
* @email yl328572838@163.com
|
||||
* @date 2022-10-27 16:07:59
|
||||
*/
|
||||
public interface ProvinceService extends IService<ProvinceEntity> {
|
||||
|
||||
PageUtils queryPage(Map<String, Object> params);
|
||||
|
||||
List<ProvinceEntity> getCity();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
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.PublisherEntity;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 出版商表
|
||||
*
|
||||
* @author yl
|
||||
* @email yl328572838@163.com
|
||||
* @date 2022-08-04 15:36:59
|
||||
*/
|
||||
public interface PublisherService extends IService<PublisherEntity> {
|
||||
|
||||
PageUtils queryPage(Map<String, Object> params);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
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.SeckillProdRelationEntity;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 秒杀商品表
|
||||
*
|
||||
* @author yl
|
||||
* @email yl328572838@163.com
|
||||
* @date 2022-10-28 11:24:05
|
||||
*/
|
||||
public interface SeckillProdRelationService extends IService<SeckillProdRelationEntity> {
|
||||
|
||||
PageUtils queryPage(Map<String, Object> params);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
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.ShopCategoryEntity;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 商品三级分类
|
||||
*
|
||||
* @author yl
|
||||
* @email yl328572838@163.com
|
||||
* @date 2022-08-30 15:06:20
|
||||
*/
|
||||
public interface ShopCategoryService extends IService<ShopCategoryEntity> {
|
||||
|
||||
PageUtils queryPage(Map<String, Object> params);
|
||||
|
||||
List<ShopCategoryEntity> listTree();
|
||||
|
||||
List<Integer> findPoid(Integer oid);
|
||||
|
||||
void removeCheckByIds(List<String> asList);
|
||||
|
||||
List<ShopCategoryEntity> getOneLevel();
|
||||
|
||||
List<ShopCategoryEntity> getTwoLevel(Integer catId);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
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.ShopProductEntity;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 商品表
|
||||
*
|
||||
* @author yl
|
||||
* @email yl328572838@163.com
|
||||
* @date 2022-10-28 09:43:14
|
||||
*/
|
||||
public interface ShopProductService extends IService<ShopProductEntity> {
|
||||
|
||||
PageUtils queryPage(Map<String, Object> params);
|
||||
|
||||
PageUtils appQueryPage(Map<String, Object> params);
|
||||
|
||||
List<ShopProductEntity> appGetCategoryList(Integer catId);
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
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.ShopSeckillEntity;
|
||||
import com.peanut.modules.book.to.SeckillRedisTo;
|
||||
import com.peanut.modules.book.vo.SeckillProdVo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 秒杀库存表
|
||||
*
|
||||
* @author yl
|
||||
* @email yl328572838@163.com
|
||||
* @date 2022-10-28 11:24:05
|
||||
*/
|
||||
public interface ShopSeckillService extends IService<ShopSeckillEntity> {
|
||||
|
||||
PageUtils queryPage(Map<String, Object> params);
|
||||
|
||||
List<ShopSeckillEntity> getSeckilProd3Days();
|
||||
|
||||
void uploadSeckilProd3Days();
|
||||
|
||||
List<SeckillRedisTo> getCurrentSeckillProd();
|
||||
|
||||
String kill(String killId,String key,Integer num,Integer userId);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
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.TransactionDetailsEntity;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 交易明细
|
||||
*
|
||||
* @author yl
|
||||
* @email yl328572838@163.com
|
||||
* @date 2022-08-29 15:47:50
|
||||
*/
|
||||
public interface TransactionDetailsService extends IService<TransactionDetailsEntity> {
|
||||
|
||||
PageUtils queryPage(Map<String, Object> params);
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
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.UserAddressEntity;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author yl
|
||||
* @email yl328572838@163.com
|
||||
* @date 2022-10-31 11:20:32
|
||||
*/
|
||||
public interface UserAddressService extends IService<UserAddressEntity> {
|
||||
|
||||
PageUtils queryPage(Map<String, Object> params);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
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.UserEbookBuyEntity;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 用户购买书籍表
|
||||
*
|
||||
* @author yl
|
||||
* @email yl328572838@163.com
|
||||
* @date 2022-10-18 16:28:20
|
||||
*/
|
||||
public interface UserEbookBuyService extends IService<UserEbookBuyEntity> {
|
||||
|
||||
PageUtils queryPage(Map<String, Object> params);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
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.core.toolkit.ObjectUtils;
|
||||
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.ActivityDao;
|
||||
import com.peanut.modules.book.dao.BuyOrderDao;
|
||||
import com.peanut.modules.book.entity.ActivityEntity;
|
||||
import com.peanut.modules.book.service.ActivityService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@Service("activityService")
|
||||
public class ActivityServiceImpl extends ServiceImpl<ActivityDao, ActivityEntity> implements ActivityService {
|
||||
|
||||
|
||||
protected Logger logger = LoggerFactory.getLogger(ActivityServiceImpl.class);
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
|
||||
IPage<ActivityEntity> page = null;
|
||||
if ("0".equals(params.get("currentState"))) {
|
||||
page = this.page(
|
||||
new Query<ActivityEntity>().getPage(params),
|
||||
new QueryWrapper<ActivityEntity>()
|
||||
);
|
||||
} else {
|
||||
page = this.page(
|
||||
new Query<ActivityEntity>().getPage(params),
|
||||
new QueryWrapper<ActivityEntity>().eq("current_state", params.get("currentState"))
|
||||
);
|
||||
}
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
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.AuthorDao;
|
||||
import com.peanut.modules.book.entity.AuthorEntity;
|
||||
import com.peanut.modules.book.service.AuthorService;
|
||||
|
||||
|
||||
@Service("authorService")
|
||||
public class AuthorServiceImpl extends ServiceImpl<AuthorDao, AuthorEntity> implements AuthorService {
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
IPage<AuthorEntity> page = this.page(
|
||||
new Query<AuthorEntity>().getPage(params),
|
||||
new QueryWrapper<AuthorEntity>()
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import com.peanut.modules.book.entity.BookChapterEntity;
|
||||
import com.peanut.modules.book.entity.BookEntity;
|
||||
import com.peanut.modules.book.entity.BookReadRateEntity;
|
||||
import com.peanut.modules.book.service.BookChapterService;
|
||||
import com.peanut.modules.book.service.BookReadRateService;
|
||||
import com.peanut.modules.book.service.BookService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
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;
|
||||
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.BookBrowseRecordsDao;
|
||||
import com.peanut.modules.book.entity.BookBrowseRecordsEntity;
|
||||
import com.peanut.modules.book.service.BookBrowseRecordsService;
|
||||
|
||||
|
||||
@Service("bookBrowseRecordsService")
|
||||
public class BookBrowseRecordsServiceImpl extends ServiceImpl<BookBrowseRecordsDao, BookBrowseRecordsEntity> implements BookBrowseRecordsService {
|
||||
|
||||
@Autowired
|
||||
private BookService bookService;
|
||||
@Autowired
|
||||
private BookChapterService bookChapterService;
|
||||
@Autowired
|
||||
private BookReadRateService bookReadRateService;
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
String userId = (String) params.get("userId");
|
||||
|
||||
IPage<BookBrowseRecordsEntity> page = this.page(
|
||||
new Query<BookBrowseRecordsEntity>().getPage(params),
|
||||
new QueryWrapper<BookBrowseRecordsEntity>()
|
||||
.eq("user_id",Integer.valueOf(userId)).orderByDesc("update_time")
|
||||
);
|
||||
List<BookBrowseRecordsEntity> records = page.getRecords();
|
||||
|
||||
for (BookBrowseRecordsEntity bookBrowseRecord: records) {
|
||||
Integer bookId = bookBrowseRecord.getBookId();
|
||||
BookEntity bookEntity = bookService.getById(bookId);
|
||||
BookReadRateEntity bookReadRate = bookReadRateService.getOne(new QueryWrapper<BookReadRateEntity>().eq("book_id", bookId).eq("user_id", userId));
|
||||
if (bookReadRate != null) {
|
||||
Integer chapterId = bookReadRate.getChapterId();
|
||||
BookChapterEntity bookChapterEntity = bookChapterService.getById(chapterId);
|
||||
if (bookChapterEntity != null) {
|
||||
bookBrowseRecord.setChapterId(chapterId);
|
||||
bookBrowseRecord.setChapterName(bookChapterEntity.getChapter());
|
||||
bookBrowseRecord.setChapterNum(bookChapterEntity.getNumber());
|
||||
String images = bookEntity.getImages();
|
||||
bookBrowseRecord.setImages(images);
|
||||
}
|
||||
}
|
||||
// this.baseMapper.updateById(bookBrowseRecord);
|
||||
}
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
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.BookBuyConfigDao;
|
||||
import com.peanut.modules.book.entity.BookBuyConfigEntity;
|
||||
import com.peanut.modules.book.service.BookBuyConfigService;
|
||||
|
||||
|
||||
@Service("bookBuyConfigService")
|
||||
public class BookBuyConfigServiceImpl extends ServiceImpl<BookBuyConfigDao, BookBuyConfigEntity> implements BookBuyConfigService {
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
IPage<BookBuyConfigEntity> page = this.page(
|
||||
new Query<BookBuyConfigEntity>().getPage(params),
|
||||
new QueryWrapper<BookBuyConfigEntity>()
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,166 @@
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import com.peanut.common.utils.FileDownloadUtil;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.book.entity.BookChapterEntity;
|
||||
import com.peanut.modules.book.entity.BookEntity;
|
||||
import com.peanut.modules.book.service.BookChapterService;
|
||||
import com.peanut.modules.book.service.BookService;
|
||||
import com.spire.doc.Document;
|
||||
import com.spire.doc.Section;
|
||||
import com.spire.doc.documents.Paragraph;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.text.BreakIterator;
|
||||
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.BookChapterContentDao;
|
||||
import com.peanut.modules.book.entity.BookChapterContentEntity;
|
||||
import com.peanut.modules.book.service.BookChapterContentService;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
|
||||
@Service("bookChapterContentService")
|
||||
public class BookChapterContentServiceImpl extends ServiceImpl<BookChapterContentDao, BookChapterContentEntity> implements BookChapterContentService {
|
||||
|
||||
@Autowired
|
||||
private BookChapterService bookChapterService;
|
||||
@Autowired
|
||||
private BookService bookService;
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
Object chapterid = params.get("chapterid");
|
||||
System.out.println(chapterid);
|
||||
IPage<BookChapterContentEntity> page = this.page(
|
||||
new Query<BookChapterContentEntity>().getPage(params),
|
||||
new QueryWrapper<BookChapterContentEntity>().eq("book_id",params.get("bookid"))
|
||||
.eq("book_chatper_id",params.get("chapterid"))
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBookVoices(Integer id) {
|
||||
BookEntity bookEntity = bookService.getBaseMapper().selectById(id);
|
||||
|
||||
List<BookChapterEntity> books = bookChapterService.getBaseMapper().selectList(new QueryWrapper<BookChapterEntity>().eq("book_id", id));
|
||||
if(CollectionUtils.isEmpty(books)){
|
||||
bookEntity.setContentStatus("3");
|
||||
}else {
|
||||
for (BookChapterEntity book:books) {
|
||||
int count = 0;
|
||||
Integer bookId = book.getBookId();
|
||||
Integer chapterId = book.getId();
|
||||
String content = book.getContent();
|
||||
// String[] split = content.split("。");
|
||||
BreakIterator iterator = BreakIterator.getSentenceInstance();
|
||||
|
||||
iterator.setText(content);
|
||||
int start = iterator.first();
|
||||
|
||||
for (int end = iterator.next(); end != BreakIterator.DONE; start = end,end = iterator.next()) {
|
||||
BookChapterContentEntity bcce = new BookChapterContentEntity();
|
||||
bcce.setBookId(bookId);
|
||||
bcce.setBookChatperId(chapterId);
|
||||
bcce.setContent(content.substring(start,end));
|
||||
bcce.setNumber(++count);
|
||||
save(bcce);
|
||||
System.out.println(content.substring(start,end));
|
||||
|
||||
}
|
||||
}
|
||||
bookEntity.setContentStatus("2");
|
||||
}
|
||||
|
||||
bookService.updateById(bookEntity);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getWordChapterParagraph(Integer bookId) {
|
||||
BookEntity bookEntity = bookService.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);
|
||||
//获取标题
|
||||
if (paragraph.getStyleName().equals("Heading1") && StringUtils.isNotBlank(paragraph.getText()))//段落样式为“标题1”的内容
|
||||
{
|
||||
//如果 是标题 1 为一级 目录
|
||||
|
||||
String level1 = paragraph.getText();
|
||||
|
||||
BookChapterEntity chapterEntity = bookChapterService.getOne(new QueryWrapper<BookChapterEntity>()
|
||||
.eq("chapter", level1).eq("book_id", bookId));
|
||||
|
||||
Integer chapterId = chapterEntity.getId();
|
||||
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
int num1 = 0;
|
||||
do {
|
||||
int cj = 0;
|
||||
|
||||
BookChapterContentEntity contentEntity = new BookChapterContentEntity();
|
||||
// builder.append(section.getParagraphs().get(j).getText() + "\n");
|
||||
String text = section.getParagraphs().get(j).getText();
|
||||
if (StringUtils.isNotBlank(text)) {
|
||||
num1++;
|
||||
//存放进数据库
|
||||
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;
|
||||
}
|
||||
|
||||
contentEntity.setContent(text);
|
||||
contentEntity.setLevel(cj);
|
||||
contentEntity.setBookChatperId(chapterId);
|
||||
contentEntity.setBookId(bookId);
|
||||
contentEntity.setNumber(num1);
|
||||
this.save(contentEntity);
|
||||
}
|
||||
|
||||
j++;
|
||||
|
||||
//防止index超出异常发生
|
||||
if (j >= section.getParagraphs().getCount()) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
// System.out.println(section.getParagraphs().get(j).getStyleName());
|
||||
} while (!section.getParagraphs().get(j).getStyleName().equals("Heading1"));
|
||||
//获取段落标题内容
|
||||
// String text = builder.toString();
|
||||
j--; //由于do..while的特性,这里需要-1
|
||||
// System.out.println("标题1和内容: " + i + ":" + text + ":" + (j - 1) + "\r");
|
||||
}
|
||||
}
|
||||
}
|
||||
doc.close();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
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.BookChapterDao;
|
||||
import com.peanut.modules.book.entity.BookChapterEntity;
|
||||
import com.peanut.modules.book.service.BookChapterService;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
|
||||
@Service("bookChapterService")
|
||||
public class BookChapterServiceImpl extends ServiceImpl<BookChapterDao, BookChapterEntity> implements BookChapterService {
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
IPage<BookChapterEntity> page = this.page(
|
||||
new Query<BookChapterEntity>().getPage(params),
|
||||
new QueryWrapper<BookChapterEntity>().eq("book_id",params.get("bookid"))
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
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.BookReadRateDao;
|
||||
import com.peanut.modules.book.entity.BookReadRateEntity;
|
||||
import com.peanut.modules.book.service.BookReadRateService;
|
||||
|
||||
|
||||
@Service("bookReadRateService")
|
||||
public class BookReadRateServiceImpl extends ServiceImpl<BookReadRateDao, BookReadRateEntity> implements BookReadRateService {
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
IPage<BookReadRateEntity> page = this.page(
|
||||
new Query<BookReadRateEntity>().getPage(params),
|
||||
new QueryWrapper<BookReadRateEntity>()
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,466 @@
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import com.aliyun.oss.OSS;
|
||||
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.modules.book.entity.*;
|
||||
import com.peanut.modules.book.entity.SysDictDataEntity;
|
||||
import com.peanut.modules.book.service.BookChapterContentService;
|
||||
import com.peanut.modules.book.service.BookChapterService;
|
||||
import com.peanut.modules.book.service.PublisherService;
|
||||
import com.peanut.modules.book.vo.BookIndexVo;
|
||||
import com.peanut.modules.sys.service.SysDictDataService;
|
||||
import com.spire.doc.Document;
|
||||
import com.spire.doc.Section;
|
||||
import com.spire.doc.documents.Paragraph;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URLDecoder;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
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;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
|
||||
@Service("bookService")
|
||||
public class BookServiceImpl extends ServiceImpl<BookDao, BookEntity> implements BookService {
|
||||
|
||||
@Autowired
|
||||
private SysDictDataService sysDictDataService;
|
||||
@Autowired
|
||||
private PublisherService publisherService;
|
||||
@Autowired
|
||||
private AuthorServiceImpl authorService;
|
||||
@Autowired
|
||||
private BookChapterService bookChapterService;
|
||||
@Autowired
|
||||
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
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
//出版社
|
||||
String publisherName1 = (String) params.get("publisherName");
|
||||
String state = (String) params.get("state");
|
||||
// String[] publisherName1split1 = publisherName1.split(",");
|
||||
// String join = StringUtils.join(publisherName1split1, "','");
|
||||
// 多查询语句
|
||||
// String sql = "IN_SET(publisher_id, (SELECT GROUP_CONCAT(id) FROM publisher WHERE publisher_name in ('\"+ join +\"'))) = 1";
|
||||
//类型
|
||||
String typeC = (String) params.get("type");
|
||||
//作者
|
||||
String authorName1 = (String) params.get("authorName");
|
||||
//书名
|
||||
String bookName = (String) params.get("bookName");
|
||||
IPage<BookEntity> page = this.page(
|
||||
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)")
|
||||
);
|
||||
for (BookEntity book : page.getRecords()) {
|
||||
String authorName = "";
|
||||
String publisherName = "";
|
||||
ArrayList<Object> list = new ArrayList<>();
|
||||
//处理字典值
|
||||
String type = book.getType();
|
||||
String chapterStatus = book.getChapterStatus();
|
||||
String contentStatus = book.getContentStatus();
|
||||
String voicesStatus = book.getVoicesStatus();
|
||||
|
||||
SysDictDataEntity chapter = sysDictDataService.getBaseMapper().selectOne(new QueryWrapper<SysDictDataEntity>()
|
||||
.eq("dict_type", chapterStatus).eq("dict_label", "processing_results"));
|
||||
|
||||
SysDictDataEntity content = sysDictDataService.getBaseMapper().selectOne(new QueryWrapper<SysDictDataEntity>()
|
||||
.eq("dict_type", contentStatus).eq("dict_label", "processing_results"));
|
||||
|
||||
SysDictDataEntity voices = sysDictDataService.getBaseMapper().selectOne(new QueryWrapper<SysDictDataEntity>()
|
||||
.eq("dict_type", voicesStatus).eq("dict_label", "processing_results"));
|
||||
|
||||
String chapterStatusName = chapter.getDictValue();
|
||||
|
||||
String contentStatusName = content.getDictValue();
|
||||
|
||||
String voicesStatusName = voices.getDictValue();
|
||||
|
||||
|
||||
String[] split = type.split(",");
|
||||
for (String tp : split) {
|
||||
SysDictDataEntity dict = sysDictDataService.getBaseMapper().selectOne(new QueryWrapper<SysDictDataEntity>()
|
||||
.eq("dict_type", tp).eq("dict_label", "book_type"));
|
||||
if(dict != null){
|
||||
list.add(dict.getDictValue());
|
||||
}
|
||||
}
|
||||
String authorId = book.getAuthorId();
|
||||
String publisherId = book.getPublisherId();
|
||||
|
||||
String[] authorIds = authorId.split(",");
|
||||
String[] publisherIds = publisherId.split(",");
|
||||
|
||||
List<String> authorList = Arrays.asList(authorIds);
|
||||
List<String> publisherList = Arrays.asList(publisherIds);
|
||||
|
||||
List<PublisherEntity> publisherEntities = publisherService.getBaseMapper().selectList(new QueryWrapper<PublisherEntity>().in("id", publisherList));
|
||||
List<AuthorEntity> authorEntities = authorService.getBaseMapper().selectList(new QueryWrapper<AuthorEntity>().in("id", authorList));
|
||||
for (AuthorEntity authorEntity : authorEntities) {
|
||||
authorName += "," + authorEntity.getAuthorName();
|
||||
}
|
||||
for (PublisherEntity publisherEntity : publisherEntities) {
|
||||
publisherName += "," + publisherEntity.getPublisherName();
|
||||
}
|
||||
authorName = authorName.startsWith(",") ? authorName.substring(1) : authorName;
|
||||
publisherName = publisherName.startsWith(",") ? publisherName.substring(1) : publisherName;
|
||||
|
||||
if (!CollectionUtils.isEmpty(list)) {
|
||||
book.setType(Joiner.on(",").join(list));
|
||||
}
|
||||
if (!StringUtils.isEmpty(authorName)) {
|
||||
book.setAuthorName(authorName);
|
||||
}
|
||||
if (!StringUtils.isEmpty(publisherName)) {
|
||||
book.setPublisherName(publisherName);
|
||||
}
|
||||
if (!StringUtils.isEmpty(chapterStatusName)) {
|
||||
book.setChapterStatus(chapterStatusName);
|
||||
}
|
||||
if (!StringUtils.isEmpty(contentStatusName)) {
|
||||
book.setContentStatus(contentStatusName);
|
||||
}
|
||||
if (!StringUtils.isEmpty(voicesStatusName)) {
|
||||
book.setVoicesStatus(voicesStatusName);
|
||||
}
|
||||
}
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getChapter(Integer id) {
|
||||
|
||||
BookEntity bookEntity = this.baseMapper.selectById(id);
|
||||
|
||||
String novel = bookEntity.getNovel();
|
||||
|
||||
Integer bookEntityId = bookEntity.getId();
|
||||
|
||||
// String fileName = novel.split("/")[novel.split("/").length - 1];
|
||||
|
||||
String fileName = novel.replace("https://ehh-private-01.oss-cn-beijing.aliyuncs.com/", "");
|
||||
|
||||
Long count = (long) 0;
|
||||
boolean bflag = false;
|
||||
int n = 0;
|
||||
String newStr = null;
|
||||
String titleName = null; //旧章节
|
||||
String newChapterName = null;//新章节名称
|
||||
String substring = null;
|
||||
int indexOf = 0;
|
||||
int indexOf1 = 0;
|
||||
int linecount = 0;
|
||||
|
||||
// ArrayList<Object> chapterList = new ArrayList<>();
|
||||
// ArrayList<Object> contentList = new ArrayList<>();
|
||||
|
||||
|
||||
// 创建OSSClient实例。
|
||||
OSS ossClient = new OSSClientBuilder().build(constantPropertiesUtils.END_POIND, constantPropertiesUtils.ACCESS_KEY_ID, constantPropertiesUtils.ACCESS_KEY_SECRET);
|
||||
try {
|
||||
// ossObject包含文件所在的存储空间名称、文件名称、文件元信息以及一个输入流。
|
||||
OSSObject ossObject = ossClient.getObject(constantPropertiesUtils.BUCKET_NAME, fileName);
|
||||
|
||||
// 读取文件内容。
|
||||
// System.out.println("Object content:");
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(ossObject.getObjectContent(), "UTF-8"));
|
||||
while (true) {
|
||||
String line = reader.readLine();
|
||||
|
||||
if (line == null) break;
|
||||
|
||||
|
||||
BookChapterEntity content = new BookChapterEntity();
|
||||
|
||||
count++;
|
||||
// 正则表达式
|
||||
Pattern p = Pattern.compile("(^\\s*第)(.{1,9})[章节卷集部篇回讲](\\s{1})(.*)($\\s*)");
|
||||
|
||||
Matcher matcher = p.matcher(line);
|
||||
Matcher matcher1 = p.matcher(line);
|
||||
|
||||
newStr = newStr + line;
|
||||
|
||||
|
||||
while (matcher.find()) {
|
||||
|
||||
if (StringUtils.isNotBlank(newChapterName)) {
|
||||
content.setChapter(newChapterName.trim());
|
||||
}
|
||||
titleName = matcher.group();
|
||||
//章节去空
|
||||
newChapterName = titleName.trim();
|
||||
|
||||
//获取章节
|
||||
// System.out.println(newChapterName);
|
||||
// content.setChapter(newChapterName);
|
||||
// content.setNumber(++linecount);
|
||||
// chapterList.add(newChapterName);
|
||||
indexOf1 = indexOf;
|
||||
// System.out.println("indexOf" + indexOf);
|
||||
indexOf = newStr.indexOf(newChapterName);
|
||||
|
||||
|
||||
|
||||
// System.out.println(newChapterName + ":" + "第" + count + "行"); // 得到返回的章
|
||||
if (bflag) {
|
||||
bflag = false;
|
||||
break;
|
||||
}
|
||||
if (n == 0) {
|
||||
indexOf1 = newStr.indexOf(newChapterName);
|
||||
System.out.println("indexOf1" + indexOf1);
|
||||
}
|
||||
n = 1;
|
||||
bflag = true;
|
||||
//System.out.println(chapter);
|
||||
}
|
||||
|
||||
|
||||
while (matcher1.find()) {
|
||||
if (indexOf != indexOf1 && indexOf > indexOf1) {
|
||||
//根据章节数量生成
|
||||
substring = newStr.substring(indexOf1, indexOf);
|
||||
content.setContent(substring.trim());
|
||||
content.setBookId(bookEntityId);
|
||||
content.setNumber(++linecount);
|
||||
// System.out.println(substring);
|
||||
// contentList.add(substring);
|
||||
// System.out.println(content.toString());
|
||||
bookChapterService.save(content);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
// 数据读取完成后,获取的流必须关闭,否则会造成连接泄漏,导致请求无连接可用,程序无法正常工作。
|
||||
reader.close();
|
||||
// ossObject对象使用完毕后必须关闭,否则会造成连接泄漏,导
|
||||
// 致请求无连接可用,程序无法正常工作。
|
||||
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, "
|
||||
+ "but was rejected with an error response for some reason.");
|
||||
System.out.println("Error Message:" + oe.getErrorMessage());
|
||||
System.out.println("Error Code:" + oe.getErrorCode());
|
||||
System.out.println("Request ID:" + oe.getRequestId());
|
||||
System.out.println("Host ID:" + oe.getHostId());
|
||||
} catch (Throwable ce) {
|
||||
bookEntity.setChapterStatus("3");
|
||||
System.out.println("Caught an ClientException, which means the client encountered "
|
||||
+ "a serious internal problem while trying to communicate with OSS, "
|
||||
+ "such as not being able to access the network.");
|
||||
System.out.println("Error Message:" + ce.getMessage());
|
||||
} finally {
|
||||
if (ossClient != null) {
|
||||
ossClient.shutdown();
|
||||
}
|
||||
}
|
||||
updateById(bookEntity);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageUtils getBestBook(Map<String, Object> params) {
|
||||
|
||||
IPage<BookEntity> page = this.page(
|
||||
new Query<BookEntity>().getPage(params),
|
||||
new QueryWrapper<BookEntity>().eq("state",1).eq("istop", 1).orderByDesc("sort")
|
||||
);
|
||||
|
||||
List<BookEntity> newBookList = page.getRecords();
|
||||
|
||||
for (BookEntity book : newBookList) {
|
||||
String authorName = "";
|
||||
String publisherName = "";
|
||||
String authorId = book.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;
|
||||
|
||||
|
||||
String publisherId = book.getPublisherId();
|
||||
String[] publisherIds = publisherId.split(",");
|
||||
List<String> publisherList = Arrays.asList(publisherIds);
|
||||
List<PublisherEntity> publisherEntities = publisherService.getBaseMapper().selectList(new QueryWrapper<PublisherEntity>().in("id", publisherList));
|
||||
|
||||
for (PublisherEntity publisherEntity : publisherEntities) {
|
||||
publisherName += "," + publisherEntity.getPublisherName();
|
||||
}
|
||||
publisherName = publisherName.startsWith(",") ? publisherName.substring(1) : publisherName;
|
||||
book.setPublisherName(publisherName);
|
||||
book.setAuthorName(authorName);
|
||||
}
|
||||
|
||||
|
||||
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")
|
||||
);
|
||||
|
||||
List<BookEntity> newBookList = page.getRecords();
|
||||
|
||||
for (BookEntity book : newBookList) {
|
||||
String authorName = "";
|
||||
String publisherName = "";
|
||||
String authorId = book.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;
|
||||
|
||||
|
||||
String publisherId = book.getPublisherId();
|
||||
String[] publisherIds = publisherId.split(",");
|
||||
List<String> publisherList = Arrays.asList(publisherIds);
|
||||
List<PublisherEntity> publisherEntities = publisherService.getBaseMapper().selectList(new QueryWrapper<PublisherEntity>().in("id", publisherList));
|
||||
|
||||
for (PublisherEntity publisherEntity : publisherEntities) {
|
||||
publisherName += "," + publisherEntity.getPublisherName();
|
||||
}
|
||||
publisherName = publisherName.startsWith(",") ? publisherName.substring(1) : publisherName;
|
||||
book.setPublisherName(publisherName);
|
||||
book.setAuthorName(authorName);
|
||||
}
|
||||
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
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")
|
||||
);
|
||||
|
||||
List<BookEntity> newBookList = page.getRecords();
|
||||
|
||||
for (BookEntity book : newBookList) {
|
||||
String authorName = "";
|
||||
String publisherName = "";
|
||||
String authorId = book.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;
|
||||
|
||||
|
||||
String publisherId = book.getPublisherId();
|
||||
String[] publisherIds = publisherId.split(",");
|
||||
List<String> publisherList = Arrays.asList(publisherIds);
|
||||
List<PublisherEntity> publisherEntities = publisherService.getBaseMapper().selectList(new QueryWrapper<PublisherEntity>().in("id", publisherList));
|
||||
|
||||
for (PublisherEntity publisherEntity : publisherEntities) {
|
||||
publisherName += "," + publisherEntity.getPublisherName();
|
||||
}
|
||||
publisherName = publisherName.startsWith(",") ? publisherName.substring(1) : publisherName;
|
||||
book.setPublisherName(publisherName);
|
||||
book.setAuthorName(authorName);
|
||||
}
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getWordChapter(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);
|
||||
//获取标题
|
||||
if (paragraph.getStyleName().equals("Heading1") && StringUtils.isNotBlank(paragraph.getText().trim()))//段落样式为“标题1”的内容
|
||||
{
|
||||
num++;
|
||||
//如果 是标题 1 为一级 目录
|
||||
String level1 = paragraph.getText();
|
||||
BookChapterEntity bookChapterEntity = new BookChapterEntity();
|
||||
bookChapterEntity.setBookId(bookId);
|
||||
bookChapterEntity.setNumber(num);
|
||||
bookChapterEntity.setChapter(level1);
|
||||
bookChapterService.save(bookChapterEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
doc.close();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
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;
|
||||
|
||||
|
||||
@Service("bookShelfService")
|
||||
public class BookShelfServiceImpl extends ServiceImpl<BookShelfDao, BookShelfEntity> implements BookShelfService {
|
||||
|
||||
@Autowired
|
||||
private BookService bookService;
|
||||
@Autowired
|
||||
private AuthorService authorService;
|
||||
@Autowired
|
||||
private BookReadRateService bookReadRateService;
|
||||
@Autowired
|
||||
private BookChapterService bookChapterService;
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
IPage<BookShelfEntity> page = this.page(
|
||||
new Query<BookShelfEntity>().getPage(params),
|
||||
new QueryWrapper<BookShelfEntity>()
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BookShelfVo> getUserBookshelf(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));
|
||||
String percent = "";
|
||||
if (bookReadRateEntity == null) {
|
||||
|
||||
percent = "0%";
|
||||
} else {
|
||||
Integer chapterId = bookReadRateEntity.getChapterId();
|
||||
String chapterName = bookReadRateEntity.getChapterName();
|
||||
//4. 根据 章节id 去书籍表查询
|
||||
|
||||
BookChapterEntity bookChapterEntity = bookChapterService.getBaseMapper().selectById(chapterId);
|
||||
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 {
|
||||
float xx = (float)number / idNumber;
|
||||
|
||||
DecimalFormat df = new DecimalFormat("##.00%");
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import jodd.util.StringUtil;
|
||||
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;
|
||||
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.BuyOrderDetailDao;
|
||||
import com.peanut.modules.book.entity.BuyOrderDetailEntity;
|
||||
import com.peanut.modules.book.service.BuyOrderDetailService;
|
||||
|
||||
|
||||
@Service("buyOrderDetailService")
|
||||
public class BuyOrderDetailServiceImpl extends ServiceImpl<BuyOrderDetailDao, BuyOrderDetailEntity> implements BuyOrderDetailService {
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
Integer orderId = Integer.valueOf((String) params.get("orderId"));
|
||||
IPage<BuyOrderDetailEntity> page = this.page(
|
||||
new Query<BuyOrderDetailEntity>().getPage(params),
|
||||
new QueryWrapper<BuyOrderDetailEntity>()
|
||||
.eq("order_id",orderId)
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 去重查询未打印的面单信息
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public PageUtils querySheet(Map<String, Object> params) {
|
||||
IPage<BuyOrderDetailEntity> page = this.page(
|
||||
new Query<BuyOrderDetailEntity>().getPage(params),
|
||||
new QueryWrapper<BuyOrderDetailEntity>().eq("is_print","0")
|
||||
.groupBy("shipping_sn")
|
||||
);
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void batchUpdateByShippingSns(String[] shippingSnList) {
|
||||
List<BuyOrderDetailEntity> buyOrderDetailEntityList = this.list(new QueryWrapper<BuyOrderDetailEntity>());
|
||||
for(String sn : shippingSnList){
|
||||
for(BuyOrderDetailEntity buyOrderDetailEntity : buyOrderDetailEntityList){
|
||||
if(StringUtil.isNotEmpty(buyOrderDetailEntity.getShippingSn()) && buyOrderDetailEntity.getShippingSn().equals(sn)){
|
||||
buyOrderDetailEntity.setIsPrint("1");
|
||||
}
|
||||
}
|
||||
}
|
||||
this.updateBatchById(buyOrderDetailEntityList);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,702 @@
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
||||
import com.baomidou.mybatisplus.extension.conditions.query.QueryChainWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.peanut.common.Interface.KdApiEOrder;
|
||||
import com.peanut.common.utils.HttpClientUtils;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.common.utils.Query;
|
||||
import com.peanut.modules.book.dao.*;
|
||||
import com.peanut.modules.book.entity.*;
|
||||
import com.peanut.modules.book.service.*;
|
||||
import com.peanut.modules.book.vo.ProductVo;
|
||||
import com.peanut.modules.book.vo.UserOrderVo;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
@Service("buyOrderService")
|
||||
public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrderEntity> implements BuyOrderService {
|
||||
|
||||
@Autowired
|
||||
private BuyOrderDetailService buyOrderDetailService;
|
||||
@Autowired
|
||||
private ShopProductService shopProductService;
|
||||
@Autowired
|
||||
private MyUserService myUserService;
|
||||
@Autowired
|
||||
private BuyOrderDao buyOrderDao;
|
||||
@Autowired
|
||||
private BuyOrderDetailDao buyOrderDetailDao;
|
||||
@Autowired
|
||||
private FMSOrderDetailService fmsOrderDetailService;
|
||||
|
||||
protected Logger logger = LoggerFactory.getLogger(BuyOrderServiceImpl.class);
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
|
||||
IPage<BuyOrderEntity> page = null;
|
||||
if (ObjectUtils.isEmpty(params.get("orderStatus"))) {
|
||||
page = this.page(
|
||||
new Query<BuyOrderEntity>().getPage(params),
|
||||
new QueryWrapper<BuyOrderEntity>()
|
||||
);
|
||||
} else {
|
||||
page = this.page(
|
||||
new Query<BuyOrderEntity>().getPage(params),
|
||||
new QueryWrapper<BuyOrderEntity>().eq("order_status", params.get("orderStatus"))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
List<BuyOrderEntity> records = page.getRecords();
|
||||
for (BuyOrderEntity record : records) {
|
||||
Integer userId = record.getUserId();
|
||||
MyUserEntity myUserEntity = myUserService.getById(userId);
|
||||
record.setUserName(myUserEntity.getName());
|
||||
record.setProducts(buyOrderDetailService.list(new QueryWrapper<BuyOrderDetailEntity>()
|
||||
.eq("order_id", record.getOrderId())));
|
||||
}
|
||||
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage1(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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateOrderStatus(Integer userId, String orderSn, String type) {
|
||||
|
||||
// 支付成功 0
|
||||
|
||||
// 发货成功 1
|
||||
|
||||
// 交易成功 2
|
||||
|
||||
// 交易失败 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")) {
|
||||
orderEntity.setOrderStatus("4");
|
||||
} else if (type.equals("1")) {
|
||||
orderEntity.setOrderStatus("2");
|
||||
} else if (type.equals("2")) {
|
||||
orderEntity.setOrderStatus("3");
|
||||
}
|
||||
updateById(orderEntity);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Param shipperCode 快递公司编码
|
||||
* @Param sendType 0:订单列表发货 1:商品列表发货
|
||||
* @Param type 合并发货/拆分发货
|
||||
* @Param ids 订单or商品id串
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public void sendFMS(Integer[] orderIds, String shipperCode, String shipperName) {
|
||||
|
||||
logger.info("##########################开始批量发货!时间:"+ new Date());
|
||||
try {
|
||||
String timeId = IdWorker.getTimeId();
|
||||
List<FMSOrderEntity> fmsOrderList = new ArrayList<>();
|
||||
// 查询订单详情
|
||||
List<BuyOrderEntity> orderList = this.buyOrderDao.queryListByOrderIds(orderIds);
|
||||
Map<Integer,Object> userMap = new HashMap<>();
|
||||
// 清洗出有哪些用户
|
||||
for(BuyOrderEntity order : orderList){
|
||||
order.setOrderCode(timeId+order.getUserId());
|
||||
userMap.put(order.getUserId(),order);
|
||||
}
|
||||
this.saveOrUpdateBatch(orderList);
|
||||
List<Integer> keys = userMap.keySet().stream().collect(Collectors.toList());
|
||||
List<BuyOrderDetailEntity> buyOrderDetailList = this.buyOrderDetailDao.queryListByOrderIds(orderIds);
|
||||
for(int k : keys){
|
||||
Object o = userMap.get(k);
|
||||
BuyOrderEntity order = new ObjectMapper().convertValue(o,BuyOrderEntity.class);
|
||||
|
||||
FMSOrderEntity fmsOrder = new FMSOrderEntity();
|
||||
// 生成一个新的订单号保存到订单表中
|
||||
fmsOrder.setOrderCode(order.getOrderCode());
|
||||
fmsOrder.setShipperCode(shipperCode);
|
||||
fmsOrder.setReceiverName(order.getShippingUser());
|
||||
fmsOrder.setReceiverMobile(order.getUserPhone());
|
||||
fmsOrder.setReceiverProvinceName(order.getProvince());
|
||||
fmsOrder.setReceiverCityName(order.getCity());
|
||||
fmsOrder.setReceiverExpAreaName(order.getDistrict());
|
||||
fmsOrder.setReceiverAddress(order.getAddress());
|
||||
fmsOrder.setRemark(order.getRemark());
|
||||
List<FMSCommodity> fmsCommoditylist = new ArrayList<>();
|
||||
for (BuyOrderDetailEntity orderDetail : buyOrderDetailList){
|
||||
if(orderDetail.getUserId().equals(k)){
|
||||
FMSCommodity fmsCommodity = new FMSCommodity();
|
||||
fmsCommodity.setGoodsName(orderDetail.getProductName());
|
||||
fmsCommodity.setGoodsQuantity(orderDetail.getQuantity());
|
||||
fmsCommodity.setGoodsPrice(orderDetail.getProductPrice());
|
||||
fmsCommodity.setGoodsWeight(orderDetail.getWeight());
|
||||
fmsCommodity.setGoodsDesc(orderDetail.getRemark());
|
||||
fmsCommodity.setFmsOrderId(orderDetail.getOrderId());
|
||||
fmsCommoditylist.add(fmsCommodity);
|
||||
fmsOrder.setCommodityList(fmsCommoditylist);
|
||||
}
|
||||
}
|
||||
fmsOrderList.add(fmsOrder);
|
||||
}
|
||||
|
||||
// 消息队列批量保存
|
||||
// fmsOrderDao.batchInsert(fmsOrderList);
|
||||
// fmsCommodityDao.batchInsert(fmsCommoditylist);
|
||||
|
||||
JSONArray jsonArr = KdApiEOrder.orderOnlineByJson(fmsOrderList);
|
||||
for (Object jsobj : jsonArr) {
|
||||
JSONObject json = JSONObject.parseObject(jsobj.toString());
|
||||
if ("true".equals(json.getString("Success"))) {
|
||||
JSONObject jsonObj = JSONObject.parseObject(json.getString("Order"));
|
||||
// 业务数据
|
||||
Map<Integer,Object> objMap = new HashMap<>();
|
||||
List<BuyOrderEntity> list = this.list(new QueryWrapper<BuyOrderEntity>().eq("order_code", jsonObj.getString("OrderCode")));
|
||||
for(BuyOrderEntity order : list){
|
||||
// 改变订单状态为已发货
|
||||
order.setOrderStatus("2");
|
||||
// 改变订单信息为已有商品发货
|
||||
order.setIsSend("1");
|
||||
this.updateById(order);
|
||||
objMap.put(order.getOrderId(),order);
|
||||
}
|
||||
List<Integer> orderIdList = objMap.keySet().stream().collect(Collectors.toList());
|
||||
Integer [] oIds = orderIdList.toArray(new Integer[orderIdList.size()]);
|
||||
List<BuyOrderDetailEntity> buyOrderEntityList = this.buyOrderDetailDao.queryListByOrderIds(oIds);
|
||||
String SortingCode = jsonObj.getString("SortingCode");
|
||||
for(BuyOrderDetailEntity buy :buyOrderEntityList){
|
||||
buy.setFmsHtml(json.getString("PrintTemplate"));
|
||||
buy.setCreatTime(new Date());
|
||||
buy.setShippingSn(SortingCode.substring(0,SortingCode.indexOf("/")));
|
||||
buy.setShipperCode(jsonObj.getString("ShipperCode"));
|
||||
buy.setShipperName(shipperName);
|
||||
buy.setIsPrint("0");
|
||||
this.buyOrderDetailService.updateById(buy);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
logger.info("##########################结束批量发货!时间:"+ new Date());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消快递信息
|
||||
*
|
||||
* @param orderSn 订单编号
|
||||
* @param shipperCode 快递公司编码
|
||||
* @param expNo 快递单号
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public void cancelFMS(String orderSn, String shipperCode, String expNo) {
|
||||
|
||||
Map<String, Object> param = new HashMap<>();
|
||||
param.put("orderSn", orderSn);
|
||||
param.put("ShipperCode", shipperCode);
|
||||
param.put("ExpNo", expNo);
|
||||
try {
|
||||
KdApiEOrder.cancelOrderByJson(param);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 及时查询快递信息
|
||||
*
|
||||
* @param shipperCode 快递公司编码
|
||||
* @param expNo 快递单号
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public JSONObject queryFMS(String shipperCode, String expNo) {
|
||||
Map<String, Object> param = new HashMap<>();
|
||||
param.put("ShipperCode", shipperCode);
|
||||
param.put("LogisticCode", expNo);
|
||||
try {
|
||||
String rntStr = KdApiEOrder.queryOrderOnlineByJson(param);
|
||||
JSONObject jsonObject = JSONObject.parseObject(rntStr);
|
||||
if ("true".equals(jsonObject.getString("Success"))) {
|
||||
return jsonObject;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询勾选的订单是否有可合并
|
||||
*
|
||||
* @param orderIds
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public List checkOrder(Integer[] orderIds) {
|
||||
|
||||
// 查询出所有的订单信息(携带订单商品)
|
||||
List<BuyOrderEntity> orderList = new ArrayList<>();
|
||||
List<BuyOrderEntity> buyOrderList = this.list(
|
||||
new QueryWrapper<BuyOrderEntity>().eq("del_flag", "0").eq("order_status", "1")
|
||||
);
|
||||
for (BuyOrderEntity order : buyOrderList) {
|
||||
order.setProducts(buyOrderDetailService.list(new QueryWrapper<BuyOrderDetailEntity>()
|
||||
.eq("order_id", order.getOrderId())));
|
||||
orderList.add(order);
|
||||
}
|
||||
// 清洗数据 (与前端传来的id对比后)
|
||||
List<BuyOrderEntity> washOrderList = new ArrayList<>();
|
||||
for (BuyOrderEntity order : orderList) {
|
||||
for (int o : orderIds) {
|
||||
if (o == order.getOrderId()) {
|
||||
washOrderList.add(order);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Map<Integer,Object> map = new HashMap<>();
|
||||
// 使用清洗后的List获得其中有多少个用户
|
||||
for(BuyOrderEntity o : washOrderList){
|
||||
map.put(o.getUserId(), o);
|
||||
}
|
||||
//获取map的所有key转为list
|
||||
List<Integer> keys = map.keySet().stream().collect(Collectors.toList());
|
||||
List<UserOrderVo> userOrderVoList = new ArrayList<>();
|
||||
for(int key : keys){
|
||||
UserOrderVo userOrderVo = new UserOrderVo();
|
||||
List<BuyOrderEntity> orderEntityList = new ArrayList<>();
|
||||
for(BuyOrderEntity o : buyOrderList){
|
||||
if(o.getUserId().equals(key)){
|
||||
userOrderVo.setTel(o.getUserPhone());
|
||||
userOrderVo.setUserName(o.getShippingUser());
|
||||
userOrderVo.setAddress(o.getProvince()+o.getCity()+o.getDistrict()+o.getAddress());
|
||||
orderEntityList.add(o);
|
||||
userOrderVo.setOrderList(orderEntityList);
|
||||
}
|
||||
}
|
||||
userOrderVoList.add(userOrderVo);
|
||||
}
|
||||
// 判断订单是否有可合并的如果没有移除掉该值
|
||||
for (UserOrderVo u : userOrderVoList) {
|
||||
if(u.getOrderList().size() <= 1){
|
||||
userOrderVoList.remove(u);
|
||||
u.getOrderList().remove(0);
|
||||
}
|
||||
if(u.getOrderList().size() == 0){
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return userOrderVoList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询所有订单是否有可合并
|
||||
*
|
||||
* @return+-
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public Page checkOrder(Map<String, Object> params){
|
||||
|
||||
// 查询所有订单信息
|
||||
List<BuyOrderEntity> orderList = new ArrayList<>();
|
||||
List<UserOrderVo> userOrderVoList = new ArrayList<>();
|
||||
// 返回的list
|
||||
List<UserOrderVo> rntList = new ArrayList<>();
|
||||
Page<UserOrderVo> rntPage = new Page<>();
|
||||
IPage<BuyOrderEntity> buyOrderList = this.page(
|
||||
new Query<BuyOrderEntity>().getPage(params),
|
||||
new QueryWrapper<BuyOrderEntity>().eq("del_flag", "0").eq("order_status", "1").eq("is_send", "0")
|
||||
);
|
||||
for (BuyOrderEntity order : buyOrderList.getRecords()) {
|
||||
order.setProducts(buyOrderDetailService.list(new QueryWrapper<BuyOrderDetailEntity>()
|
||||
.eq("order_id", order.getOrderId())));
|
||||
orderList.add(order);
|
||||
}
|
||||
// 获取有订单的所有用户
|
||||
Map<Integer,Object> map = new HashMap<>();
|
||||
|
||||
for(BuyOrderEntity order : orderList){
|
||||
map.put(order.getUserId(), order);
|
||||
}
|
||||
//获取map的所有key转为list
|
||||
List<Integer> keys = map.keySet().stream().collect(Collectors.toList());
|
||||
|
||||
for(int key : keys){
|
||||
UserOrderVo userOrderVo = new UserOrderVo();
|
||||
List<BuyOrderEntity> orderEntityList = new ArrayList<>();
|
||||
for(BuyOrderEntity o : buyOrderList.getRecords()){
|
||||
if(o.getUserId().equals(key)){
|
||||
userOrderVo.setUserName(o.getShippingUser());
|
||||
userOrderVo.setTel(o.getUserPhone());
|
||||
userOrderVo.setAddress(o.getProvince()+o.getCity()+o.getDistrict()+o.getAddress());
|
||||
orderEntityList.add(o);
|
||||
userOrderVo.setOrderList(orderEntityList);
|
||||
}
|
||||
}
|
||||
userOrderVoList.add(userOrderVo);
|
||||
}
|
||||
|
||||
for(UserOrderVo userOrder : userOrderVoList){
|
||||
if(userOrder.getOrderList().size() > 1){
|
||||
rntList.add(userOrder);
|
||||
|
||||
}
|
||||
}
|
||||
rntPage.setRecords(rntList);
|
||||
return rntPage;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 混合发货
|
||||
*
|
||||
* @param orderDetailIds
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public void blendSendFMS(Integer[] orderDetailIds,String shipperCode,String shipperName) {
|
||||
|
||||
logger.info("##########################开始混合发货!时间:"+ new Date());
|
||||
try {
|
||||
// 生成订单号
|
||||
String timeId = IdWorker.getTimeId();
|
||||
List<FMSOrderDetailEntity> fmsList = new ArrayList<>();
|
||||
List<BuyOrderDetailEntity> washDetailList = new ArrayList<>();
|
||||
List<BuyOrderDetailEntity> detailList = this.buyOrderDetailService.list(new QueryWrapper<BuyOrderDetailEntity>());
|
||||
|
||||
for(BuyOrderDetailEntity buy : detailList){
|
||||
for(int orderDetailId : orderDetailIds){
|
||||
if(buy.getAllOrderId() == orderDetailId){
|
||||
FMSOrderDetailEntity fms = new FMSOrderDetailEntity();
|
||||
fms.setDetailId(buy.getAllOrderId());
|
||||
fms.setOrderCode(timeId+buy.getUserId());
|
||||
fms.setOrderId(buy.getOrderId());
|
||||
fmsList.add(fms);
|
||||
|
||||
washDetailList.add(buy);
|
||||
}
|
||||
}
|
||||
}
|
||||
fmsOrderDetailService.saveBatch(fmsList);
|
||||
|
||||
FMSOrderEntity fmsOrder = new FMSOrderEntity();
|
||||
// 初始化快递订单信息
|
||||
List<FMSOrderEntity> fmsOrderList = new ArrayList<>();
|
||||
// 初始化快递商品信息
|
||||
List<FMSCommodity> fmsCommoditylist = new ArrayList<>();
|
||||
|
||||
if(washDetailList != null && washDetailList.size() > 0){
|
||||
BuyOrderEntity order = this.getById(washDetailList.get(0).getOrderId());
|
||||
fmsOrder.setOrderCode(timeId+order.getUserId());
|
||||
fmsOrder.setShipperCode(shipperCode);
|
||||
fmsOrder.setReceiverName(order.getShippingUser());
|
||||
fmsOrder.setReceiverMobile(order.getUserPhone());
|
||||
fmsOrder.setReceiverProvinceName(order.getProvince());
|
||||
fmsOrder.setReceiverCityName(order.getCity());
|
||||
fmsOrder.setReceiverExpAreaName(order.getDistrict());
|
||||
fmsOrder.setReceiverAddress(order.getAddress());
|
||||
for(BuyOrderDetailEntity buy : washDetailList){
|
||||
FMSCommodity fmsCommodity = new FMSCommodity();
|
||||
fmsCommodity.setGoodsName(buy.getProductName());
|
||||
fmsCommodity.setGoodsQuantity(buy.getQuantity());
|
||||
fmsCommodity.setGoodsPrice(buy.getProductPrice());
|
||||
fmsCommodity.setGoodsWeight(buy.getWeight());
|
||||
fmsCommodity.setGoodsDesc(buy.getRemark());
|
||||
fmsCommodity.setFmsOrderId(buy.getOrderId());
|
||||
fmsCommoditylist.add(fmsCommodity);
|
||||
}
|
||||
fmsOrder.setCommodityList(fmsCommoditylist);
|
||||
fmsOrderList.add(fmsOrder);
|
||||
JSONArray jsonArr = KdApiEOrder.orderOnlineByJson(fmsOrderList);
|
||||
JSONObject json = JSONObject.parseObject(jsonArr.getString(0));
|
||||
if ("true".equals(json.getString("Success"))) {
|
||||
JSONObject jsonObj = JSONObject.parseObject(json.getString("Order"));
|
||||
String orderCode = jsonObj.getString("OrderCode");
|
||||
List<FMSOrderDetailEntity> fmsOrderDetailList = this.fmsOrderDetailService.list(new QueryWrapper<FMSOrderDetailEntity>().eq("order_code", orderCode));
|
||||
String SortingCode = jsonObj.getString("SortingCode");
|
||||
for(FMSOrderDetailEntity fms : fmsOrderDetailList){
|
||||
BuyOrderEntity o = this.getById(fms.getOrderId());
|
||||
BuyOrderDetailEntity detail = this.buyOrderDetailService.getById(fms.getDetailId());
|
||||
detail.setOrderStatus("1");
|
||||
detail.setFmsHtml(json.getString("PrintTemplate"));
|
||||
detail.setCreatTime(new Date());
|
||||
detail.setShippingSn(SortingCode.substring(0,SortingCode.indexOf("/")));
|
||||
detail.setShipperCode(jsonObj.getString("ShipperCode"));
|
||||
detail.setShipperName(shipperName);
|
||||
detail.setIsPrint("0");
|
||||
this.buyOrderDetailService.updateById(detail);
|
||||
List<BuyOrderDetailEntity> list = this.buyOrderDetailService.list(new QueryWrapper<BuyOrderDetailEntity>().eq("order_id", fms.getOrderId()).eq("order_status", "0"));
|
||||
if(list.size() == 0){
|
||||
o.setIsSend("1");
|
||||
o.setOrderStatus("2");
|
||||
}else{
|
||||
o.setIsSend("1");
|
||||
}
|
||||
this.updateById(o);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
logger.info("##########################结束混合发货!时间:"+ new Date());
|
||||
}catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据商品类型计算快递费
|
||||
*
|
||||
* @param param
|
||||
* @param productMap
|
||||
* @return
|
||||
*/
|
||||
|
||||
@Override
|
||||
public int getProductGoodsType(Map<String, Object> param,Map<String, Object> productMap){
|
||||
// param : key商品Id,value商品数量
|
||||
// 定义不同种类的数组
|
||||
Map<String,Object> pictureMap = new HashMap<>();
|
||||
Map<String,Object> bookMap = new HashMap<>();
|
||||
List<ProductVo> advanceBookingList = new ArrayList<>();
|
||||
List<ProductVo> deviceList = new ArrayList<>();
|
||||
|
||||
int transPrice = 0;
|
||||
|
||||
if(!ObjectUtils.isEmpty(productMap)){
|
||||
Set set = productMap.keySet();
|
||||
Iterator ite = set.iterator();
|
||||
while (ite.hasNext()) {
|
||||
int i = 1;
|
||||
Object next =ite.next();
|
||||
// 根据Id查询信息后 计算出各个种类商品的总重量
|
||||
ShopProductEntity product = this.shopProductService.getById(Integer.valueOf(next.toString()));
|
||||
if("01".equals(product.getGoodsType())){
|
||||
if(ObjectUtils.isEmpty(pictureMap)){
|
||||
pictureMap.put("picture",(float)product.getWeight() * Integer.valueOf(productMap.get(next.toString()).toString()));
|
||||
}else{
|
||||
pictureMap.put("picture",(float)pictureMap.get("picture") + (float)product.getWeight() * Integer.valueOf(productMap.get(next.toString()).toString()));
|
||||
}
|
||||
}
|
||||
if("02".equals(product.getGoodsType())){
|
||||
if(ObjectUtils.isEmpty(bookMap)){
|
||||
bookMap.put("book",(float)product.getWeight() * Integer.valueOf(productMap.get(next.toString()).toString()));
|
||||
}else{
|
||||
bookMap.put("book",(float)bookMap.get("book") + (float)product.getWeight() * Integer.valueOf(productMap.get(next.toString()).toString()));
|
||||
}
|
||||
}
|
||||
if("03".equals(product.getGoodsType())){
|
||||
ProductVo p = new ProductVo();
|
||||
p.setKdCode(param.get("kdCode").toString());
|
||||
p.setArea(param.get("area").toString());
|
||||
p.setNum(Integer.valueOf(productMap.get(next.toString()).toString()));
|
||||
p.setWeight(product.getWeight().intValue());
|
||||
deviceList.add(p);
|
||||
}
|
||||
if("04".equals(product.getGoodsType())){
|
||||
ProductVo p = new ProductVo();
|
||||
p.setKdCode(param.get("kdCode").toString());
|
||||
p.setArea(param.get("area").toString());
|
||||
p.setNum(Integer.valueOf(productMap.get(next.toString()).toString()));
|
||||
p.setWeight(product.getWeight().intValue());
|
||||
advanceBookingList.add(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!ObjectUtils.isEmpty(pictureMap)){
|
||||
pictureMap.put("kdCode",param.get("kdCode"));
|
||||
pictureMap.put("area",param.get("area"));
|
||||
pictureMap.put("weight",pictureMap.get("picture"));
|
||||
transPrice += this.getTransPrice(pictureMap);
|
||||
}
|
||||
if(!ObjectUtils.isEmpty(bookMap)){
|
||||
bookMap.put("kdCode",param.get("kdCode"));
|
||||
bookMap.put("area",param.get("area"));
|
||||
bookMap.put("weight",bookMap.get("book"));
|
||||
transPrice += this.getTransPrice(bookMap);
|
||||
}
|
||||
if(!ObjectUtils.isEmpty(deviceList)){
|
||||
transPrice += this.getTransPrice(deviceList);
|
||||
}
|
||||
if(!ObjectUtils.isEmpty(advanceBookingList)){
|
||||
transPrice += this.getTransPrice(advanceBookingList);
|
||||
}
|
||||
return transPrice;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 计算仪器,预售快递费用
|
||||
*
|
||||
* @param productList
|
||||
* @return
|
||||
*/
|
||||
public int getTransPrice(List<ProductVo> productList){
|
||||
|
||||
// 首重
|
||||
int amount = 0;
|
||||
// 续重
|
||||
int continuousWeight = 0;
|
||||
// 费用
|
||||
int fare = 0;
|
||||
for(ProductVo p : productList){
|
||||
String prov = p.getArea().substring(0,p.getArea().indexOf("_"));
|
||||
float weight = p.getNum() * p.getWeight();
|
||||
// 韵达计费规则
|
||||
if("YD".equals(p.getKdCode())){
|
||||
// 如果ID等于71 说明是天津发天津
|
||||
if("71".equals(prov)){
|
||||
amount = 6;
|
||||
continuousWeight = 3;
|
||||
}
|
||||
// 首重十元 续重四元
|
||||
String tenStr [] = {"70","73","75","76","77","79","81","82","83","84","85","86","87","88","91","92","96","80","78"};
|
||||
boolean tenBoolean = Arrays.asList(tenStr).contains(prov);
|
||||
if(tenBoolean){
|
||||
amount = 10;
|
||||
continuousWeight = 4;
|
||||
}
|
||||
// 首重十二元
|
||||
String twelveStr[] = {"74","89","90","93","94","97","98","99"};
|
||||
boolean twelveBoolean = Arrays.asList(twelveStr).contains(prov);
|
||||
if(twelveBoolean){
|
||||
amount = 12;
|
||||
continuousWeight = 5;
|
||||
// 甘肃 97,青海 98,内蒙古 74 ,海南90 续重 6元
|
||||
if(prov.equals("97") || prov.equals("98")|| prov.equals("74") || prov.equals("90")){
|
||||
continuousWeight = 6;
|
||||
}
|
||||
}
|
||||
// 首重二十元,续重二十元
|
||||
if("100".equals(prov)){
|
||||
amount = 20;
|
||||
continuousWeight = 20;
|
||||
}
|
||||
|
||||
if(weight <= 1000){
|
||||
fare += amount;
|
||||
}else {
|
||||
fare += (int) (amount + (continuousWeight * Math.floor(weight / 1000)));
|
||||
}
|
||||
}
|
||||
}
|
||||
return fare;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 计算快递费用
|
||||
* @param param
|
||||
*/
|
||||
public int getTransPrice(Map<String, Object> param) {
|
||||
|
||||
int fare = 0;
|
||||
String KDCode = param.get("kdCode").toString();
|
||||
String area = param.get("area").toString();
|
||||
String prov = area.substring(0,area.indexOf("_"));
|
||||
float weight = (float)param.get("weight");
|
||||
// 韵达计费规则
|
||||
if("YD".equals(KDCode)){
|
||||
// 如果ID等于71 说明是天津发天津
|
||||
int amount = 0;
|
||||
int continuousWeight = 0;
|
||||
if("71".equals(prov)){
|
||||
amount = 6;
|
||||
continuousWeight = 3;
|
||||
}
|
||||
// 首重十元 续重四元
|
||||
String tenStr [] = {"70","73","75","76","77","79","81","82","83","84","85","86","87","88","91","92","96","80","78"};
|
||||
boolean tenBoolean = Arrays.asList(tenStr).contains(prov);
|
||||
if(tenBoolean){
|
||||
amount = 10;
|
||||
continuousWeight = 4;
|
||||
}
|
||||
// 首重十二元
|
||||
String twelveStr[] = {"74","89","90","93","94","97","98","99"};
|
||||
boolean twelveBoolean = Arrays.asList(twelveStr).contains(prov);
|
||||
if(twelveBoolean){
|
||||
amount = 12;
|
||||
continuousWeight = 5;
|
||||
// 甘肃 97,青海 98,内蒙古 74 ,海南90 续重 6元
|
||||
if(prov.equals("97") || prov.equals("98")|| prov.equals("74") || prov.equals("90")){
|
||||
continuousWeight = 6;
|
||||
}
|
||||
}
|
||||
// 首重二十元,续重二十元
|
||||
if("100".equals(prov)){
|
||||
amount = 20;
|
||||
continuousWeight = 20;
|
||||
}
|
||||
|
||||
if(weight <= 1000){
|
||||
return amount;
|
||||
}else {
|
||||
return (int) (amount + (continuousWeight * Math.floor(weight / 1000)));
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import com.peanut.modules.book.entity.CityEntity;
|
||||
import org.springframework.stereotype.Service;
|
||||
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.CityDao;
|
||||
import com.peanut.modules.book.service.CityService;
|
||||
|
||||
|
||||
@Service("cityService")
|
||||
public class CityServiceImpl extends ServiceImpl<CityDao, CityEntity> implements CityService {
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
IPage<CityEntity> page = this.page(
|
||||
new Query<CityEntity>().getPage(params),
|
||||
new QueryWrapper<CityEntity>()
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import com.peanut.modules.book.entity.CountyEntity;
|
||||
import org.springframework.stereotype.Service;
|
||||
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.CountyDao;
|
||||
import com.peanut.modules.book.service.CountyService;
|
||||
|
||||
|
||||
@Service("countyService")
|
||||
public class CountyServiceImpl extends ServiceImpl<CountyDao, CountyEntity> implements CountyService {
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
IPage<CountyEntity> page = this.page(
|
||||
new Query<CountyEntity>().getPage(params),
|
||||
new QueryWrapper<CountyEntity>()
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,242 @@
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import com.peanut.common.utils.DateUtil;
|
||||
import com.peanut.modules.book.entity.*;
|
||||
import com.peanut.modules.book.service.*;
|
||||
import com.peanut.modules.book.vo.UserCouponVo;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
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.CouponHistoryDao;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
@Slf4j
|
||||
@Service("couponHistoryService")
|
||||
public class CouponHistoryServiceImpl extends ServiceImpl<CouponHistoryDao, CouponHistoryEntity> implements CouponHistoryService {
|
||||
|
||||
@Autowired
|
||||
private CouponService couponService;
|
||||
@Autowired
|
||||
private CouponProductCategoryRelationService categoryRelationService;
|
||||
@Autowired
|
||||
private CouponProductRelationService productRelationService;
|
||||
@Autowired
|
||||
private ShopProductServiceImpl shopProductService;
|
||||
@Autowired
|
||||
private BookService bookService;
|
||||
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
String userId = (String) params.get("userId");
|
||||
IPage<CouponHistoryEntity> page = this.page(
|
||||
new Query<CouponHistoryEntity>().getPage(params),
|
||||
new QueryWrapper<CouponHistoryEntity>()
|
||||
.eq(StringUtils.isNotBlank(userId), "member_id", Integer.parseInt(userId))
|
||||
);
|
||||
List<CouponHistoryEntity> records = page.getRecords();
|
||||
for (CouponHistoryEntity record : records) {
|
||||
Long couponId = record.getCouponId();
|
||||
CouponEntity byId = couponService.getById(couponId);
|
||||
if(byId != null) {
|
||||
record.setCouponName(byId.getCouponName());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Async
|
||||
public void runCouponsUserStatusTimeOutToExpired() {
|
||||
log.info("runCouponsUserStatusTimeOutToExpired start.......time={}", System.currentTimeMillis());
|
||||
Long startTime01 = System.currentTimeMillis();
|
||||
//查找到所有用户已领取,但未使用的用户券列表
|
||||
List<CouponHistoryEntity> couponsUserList = findListByUseStatus();
|
||||
log.info("runCouponsUserStatusTimeOutToExpired couponsUserList.size={}", couponsUserList.size());
|
||||
if (couponsUserList.size() > 0) {
|
||||
List<CouponHistoryEntity> needCouponsUserList = new ArrayList<>();
|
||||
Date currentDate = new Date();
|
||||
for (int i = 0; i < couponsUserList.size(); i++) {
|
||||
CouponHistoryEntity couponsUser = couponsUserList.get(i);
|
||||
Long couponId = couponsUser.getCouponId();
|
||||
CouponEntity couponEntity = couponService.getById(couponId);
|
||||
Date effDate = couponEntity.getTakeEffectDate();
|
||||
Date expDate = couponEntity.getExpirationDate();
|
||||
boolean isEffective = DateUtil.isEffectiveDate(currentDate, effDate, expDate);
|
||||
//券已失效 则修改用户券的状态为已过期
|
||||
if (!isEffective) {
|
||||
couponsUser.setUseStatus(2);
|
||||
needCouponsUserList.add(couponsUser); //需要更新状态的券
|
||||
}
|
||||
}
|
||||
|
||||
if (needCouponsUserList.size() > 0) {
|
||||
log.info("runCouponsUserStatusTimeOutToExpired update needCouponsUserList.size={}", needCouponsUserList.size());
|
||||
saveOrUpdateBatch(needCouponsUserList);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Long endTime02 = System.currentTimeMillis();
|
||||
log.info("runCouponsUserStatusTimeOutToExpired end second={},mills={}", (endTime02 - startTime01) / 1000, (endTime02 - startTime01) % 1000);
|
||||
}
|
||||
|
||||
private List<CouponHistoryEntity> findListByUseStatus() {
|
||||
List<CouponHistoryEntity> list = this.getBaseMapper().selectList(new QueryWrapper<CouponHistoryEntity>().eq("use_status", 0));
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CouponEntity> appGetCoupon() {
|
||||
|
||||
//获取 当前时间 有效期内的优惠券
|
||||
|
||||
Date date = new Date();
|
||||
|
||||
List<CouponEntity> list = new ArrayList<>();
|
||||
|
||||
List<CouponEntity> couponEntityList = couponService.list(new QueryWrapper<CouponEntity>());
|
||||
|
||||
for (CouponEntity couponEntity : couponEntityList) {
|
||||
Date endTime = couponEntity.getTakeEffectDate();
|
||||
Date enableTime = couponEntity.getTakeEffectDate();
|
||||
// 判断结束日期 是否大于 当前 时间 以及 领取日期 是否 小于当前日期
|
||||
if (endTime.getTime() - date.getTime() > 0 && enableTime.getTime() - date.getTime() <= 0) {
|
||||
list.add(couponEntity);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserCouponVo> appGetUserCoupon(Integer userId, String amount,String type) {
|
||||
|
||||
// 查询用户当前 拥有的优惠券
|
||||
// 商品 :0 ,电子书 :1
|
||||
List<CouponHistoryEntity> couponHistoryEntities = null;
|
||||
if("0".equals(type)){
|
||||
couponHistoryEntities = this.getBaseMapper().selectList(new QueryWrapper<CouponHistoryEntity>()
|
||||
.eq("member_id", userId)
|
||||
.eq("use_status", 0)
|
||||
.eq("coupon_pro_type","0")
|
||||
);
|
||||
}else{
|
||||
couponHistoryEntities = this.getBaseMapper().selectList(new QueryWrapper<CouponHistoryEntity>()
|
||||
.eq("member_id", userId)
|
||||
.eq("use_status", 0)
|
||||
.eq("coupon_pro_type","1")
|
||||
);
|
||||
}
|
||||
|
||||
// 可使用优惠券列表
|
||||
ArrayList<UserCouponVo> list = new ArrayList<>();
|
||||
|
||||
for (CouponHistoryEntity couponHistoryEntity : couponHistoryEntities) {
|
||||
Long couponId = couponHistoryEntity.getCouponId();
|
||||
CouponEntity couponEntity = couponService.getById(couponId);
|
||||
// 判断当前优惠券是否过期
|
||||
Date startTime = couponEntity.getExpirationDate();
|
||||
// 判断结束日期 是否大于 当前 时间
|
||||
if (startTime.after(new Date())){
|
||||
if(Integer.parseInt(amount) >= couponEntity.getUseLevel()){
|
||||
UserCouponVo userCouponVo = new UserCouponVo();
|
||||
BeanUtils.copyProperties(couponHistoryEntity, userCouponVo);
|
||||
userCouponVo.setCoupons(couponEntity);
|
||||
list.add(userCouponVo);
|
||||
}
|
||||
// boolean result = couponCanUseCategory(products, couponId, String.valueOf(couponEntity.getCouponType()));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
// 判断组合分类 是否 符合优惠券规则
|
||||
private boolean couponCanUseCategory(String products, Long couponId, String userType) {
|
||||
|
||||
List list1 = new ArrayList<>();
|
||||
|
||||
if (!userType.equals("0")) {
|
||||
|
||||
if (userType.equals("1")) {
|
||||
|
||||
List<CouponProductCategoryRelationEntity> couponC = categoryRelationService.getBaseMapper().selectList(new QueryWrapper<CouponProductCategoryRelationEntity>()
|
||||
.eq("coupon_id", couponId));
|
||||
|
||||
ArrayList<Object> list = new ArrayList<>();
|
||||
String[] split = products.split(",");
|
||||
for (CouponProductCategoryRelationEntity couponProductCategoryRelationEntity : couponC) {
|
||||
// platform 0 1.判断商品 是否为 同一分类下
|
||||
|
||||
for (String s : split) {
|
||||
// 多商品的 判断商品 是否为同一个分类 下
|
||||
ShopProductEntity spe = shopProductService.getById(Integer.parseInt(s));
|
||||
Integer productPid = spe.getProductPid();
|
||||
Long productCategoryId = couponProductCategoryRelationEntity.getProductCategoryId();
|
||||
if (productCategoryId.intValue() == productPid) {
|
||||
list.add(productCategoryId);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (split.length == list.size()){
|
||||
return true;
|
||||
}else {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
} else if (userType.equals("2")) {
|
||||
|
||||
List<CouponProductRelationEntity> couponC = productRelationService.getBaseMapper().selectList(new QueryWrapper<CouponProductRelationEntity>()
|
||||
.eq("coupon_id", couponId));
|
||||
|
||||
ArrayList<Object> list = new ArrayList<>();
|
||||
String[] split = products.split(",");
|
||||
for (CouponProductRelationEntity couponProductCategoryRelationEntity : couponC) {
|
||||
// platform 0 1.判断商品 是否为 同一分类下
|
||||
for (String s : split) {
|
||||
// 多商品的 判断商品 是否为同一个分类 下
|
||||
// Long productId = couponProductCategoryRelationEntity.getProductId();
|
||||
Long productId = couponProductCategoryRelationEntity.getProductId();
|
||||
if (Long.parseLong(s) == productId) {
|
||||
list.add(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (split.length == list.size()){
|
||||
return true;
|
||||
}else {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
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.CouponProductCategoryRelationDao;
|
||||
import com.peanut.modules.book.entity.CouponProductCategoryRelationEntity;
|
||||
import com.peanut.modules.book.service.CouponProductCategoryRelationService;
|
||||
|
||||
|
||||
@Service("couponProductCategoryRelationService")
|
||||
public class CouponProductCategoryRelationServiceImpl extends ServiceImpl<CouponProductCategoryRelationDao, CouponProductCategoryRelationEntity> implements CouponProductCategoryRelationService {
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
String couponId = (String) params.get("couponId");
|
||||
IPage<CouponProductCategoryRelationEntity> page = this.page(
|
||||
new Query<CouponProductCategoryRelationEntity>().getPage(params),
|
||||
new QueryWrapper<CouponProductCategoryRelationEntity>().eq("coupon_id",Integer.valueOf(couponId))
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
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.CouponProductRelationDao;
|
||||
import com.peanut.modules.book.entity.CouponProductRelationEntity;
|
||||
import com.peanut.modules.book.service.CouponProductRelationService;
|
||||
|
||||
|
||||
@Service("couponProductRelationService")
|
||||
public class CouponProductRelationServiceImpl extends ServiceImpl<CouponProductRelationDao, CouponProductRelationEntity> implements CouponProductRelationService {
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
String couponId = (String) params.get("couponId");
|
||||
IPage<CouponProductRelationEntity> page = this.page(
|
||||
new Query<CouponProductRelationEntity>().getPage(params),
|
||||
new QueryWrapper<CouponProductRelationEntity>().eq("coupon_id",Integer.valueOf(couponId))
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import com.peanut.modules.book.service.CouponHistoryService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
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.CouponDao;
|
||||
import com.peanut.modules.book.entity.CouponEntity;
|
||||
import com.peanut.modules.book.service.CouponService;
|
||||
|
||||
|
||||
@Service("couponService")
|
||||
public class CouponServiceImpl extends ServiceImpl<CouponDao, CouponEntity> implements CouponService {
|
||||
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
IPage<CouponEntity> page = null;
|
||||
String cu = params.get("currentState").toString();
|
||||
if("0".equals(cu)){
|
||||
page = this.page(
|
||||
new Query<CouponEntity>().getPage(params),
|
||||
new QueryWrapper<CouponEntity>()
|
||||
);
|
||||
}else{
|
||||
page = this.page(
|
||||
new Query<CouponEntity>().getPage(params),
|
||||
new QueryWrapper<CouponEntity>().eq("current_state",cu)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.modules.book.dao.FMSOrderDetailDao;
|
||||
import com.peanut.modules.book.entity.FMSOrderDetailEntity;
|
||||
import com.peanut.modules.book.service.FMSOrderDetailService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@Service("fmsOrderService")
|
||||
public class FMSOrderDetailServiceImpl extends ServiceImpl<FMSOrderDetailDao, FMSOrderDetailEntity>
|
||||
implements FMSOrderDetailService {
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,309 @@
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.aliyun.dysmsapi20170525.models.SendSmsRequest;
|
||||
import com.aliyun.dysmsapi20170525.models.SendSmsResponse;
|
||||
import com.aliyun.dysmsapi20170525.models.SendSmsResponseBody;
|
||||
import com.aliyun.tea.TeaException;
|
||||
import com.aliyun.teautil.Common;
|
||||
import com.aliyun.teautil.models.RuntimeOptions;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.config.DelayQueueConfig;
|
||||
import com.peanut.modules.app.config.SMSConfig;
|
||||
import com.peanut.modules.app.config.Sample;
|
||||
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.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;
|
||||
|
||||
@Slf4j
|
||||
@Service("myuserService")
|
||||
public class MyUserServiceImpl extends ServiceImpl<MyUserDao, MyUserEntity> implements MyUserService {
|
||||
|
||||
|
||||
@Autowired
|
||||
private SMSConfig smsConfig;
|
||||
@Autowired
|
||||
private BookService bookService;
|
||||
@Autowired
|
||||
private RabbitMqService rabbitMqService;
|
||||
@Autowired
|
||||
private TransactionDetailsService transactionDetailsService;
|
||||
@Autowired
|
||||
private UserEbookBuyService userEbookBuyService;
|
||||
@Autowired
|
||||
private AuthorService authorService;
|
||||
@Autowired
|
||||
private CouponService couponService;
|
||||
@Autowired
|
||||
private CouponHistoryService couponHistoryService;
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
IPage<MyUserEntity> page = this.page(
|
||||
new Query<MyUserEntity>().getPage(params),
|
||||
new QueryWrapper<MyUserEntity>()
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendCodeForRegister(String phone, String code) throws Exception {
|
||||
String scode = code.split("_")[0];
|
||||
sendCode(phone,scode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean bookAuthenticate(Integer bookId, Integer userId) {
|
||||
|
||||
//查询书籍 类型
|
||||
BookEntity book = bookService.getById(bookId);
|
||||
Integer isVip = book.getIsVip(); // 0 - 免费 1- 会免 2 - 付费
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean openMember(Integer customerId,Integer openMonth) {
|
||||
|
||||
MyUserEntity user = this.getById(customerId);
|
||||
if (user == null) {
|
||||
return false;
|
||||
}
|
||||
long ttl = 0;
|
||||
Date validDate = new Date();
|
||||
Date date = new Date();
|
||||
if (user.getVip().equals("1")) {
|
||||
//如果当前已经是会员进行续期操作
|
||||
validDate = user.getVipValidtime();
|
||||
Calendar calendar = new GregorianCalendar();
|
||||
calendar.setTime(validDate);
|
||||
|
||||
if (openMonth == 1){
|
||||
Integer openDays = 31;
|
||||
// 把日期往后增加一天,整数 往后推,负数往前移动
|
||||
calendar.add(Calendar.DAY_OF_YEAR, openDays);
|
||||
// 这个时间就是日期往后推一天的结果
|
||||
Date endDate = calendar.getTime();
|
||||
user.setVipValidtime(endDate);
|
||||
ttl = endDate.getTime() - date.getTime() ;
|
||||
}else {
|
||||
//月份
|
||||
calendar.add(Calendar.MONTH, openMonth);
|
||||
Date endDate = calendar.getTime();
|
||||
user.setVipValidtime(endDate);
|
||||
ttl = endDate.getTime() - date.getTime() ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}else {
|
||||
//获取系统当前日期
|
||||
user.setVip("1");
|
||||
|
||||
Calendar calendar = new GregorianCalendar();
|
||||
calendar.setTime(date);
|
||||
|
||||
|
||||
if (openMonth == 1){
|
||||
Integer openDays = 31;
|
||||
// 把日期往后增加一天,整数 往后推,负数往前移动
|
||||
calendar.add(Calendar.DAY_OF_YEAR, openDays);
|
||||
// 这个时间就是日期往后推一天的结果
|
||||
Date endDate = calendar.getTime();
|
||||
user.setVipValidtime(endDate);
|
||||
ttl = endDate.getTime() - date.getTime() ;
|
||||
}else {
|
||||
//月份
|
||||
calendar.add(Calendar.MONTH, openMonth);
|
||||
Date endDate = calendar.getTime();
|
||||
user.setVipValidtime(endDate);
|
||||
ttl = endDate.getTime() - date.getTime() ;
|
||||
}
|
||||
|
||||
}
|
||||
user.setVipStartTime(date);
|
||||
|
||||
this.updateById(user);
|
||||
|
||||
|
||||
|
||||
//mq
|
||||
// 手动指定消息过期时间
|
||||
|
||||
Map<String, Object> msgMap = Maps.newHashMapWithExpectedSize(3);
|
||||
msgMap.put("msg", customerId);
|
||||
msgMap.put("time", LocalDateTime.now());
|
||||
msgMap.put("ttl", ttl);
|
||||
|
||||
// 注意这里发送的交换机是 延时交换机
|
||||
rabbitMqService.send(DelayQueueConfig.DELAY_EXCHANGE, DelayQueueConfig.DELAY_QUEUE_ROUTING_KEY, JSONObject.toJSONString(msgMap), ttl);
|
||||
log.info("消息发送成功:{}", JSONObject.toJSONString(msgMap));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean rechargeHSPoint(Integer customerId,Integer HSPoint) {
|
||||
MyUserEntity user = this.getById(customerId);
|
||||
if (user == null) {
|
||||
return false;
|
||||
}
|
||||
Integer peanutCoin = user.getPeanutCoin();
|
||||
user.setPeanutCoin(peanutCoin + HSPoint);
|
||||
this.updateById(user);
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public String buyEbook(String userId, String bookId,String couponId) {
|
||||
|
||||
String authorName = "";
|
||||
|
||||
//避免重复购买
|
||||
TransactionDetailsEntity entity = transactionDetailsService.getBaseMapper().selectOne(new QueryWrapper<TransactionDetailsEntity>().eq("user_id", userId)
|
||||
.eq("relation_id", bookId));
|
||||
|
||||
if (entity != null) {
|
||||
return "余额不足,请充值!";
|
||||
}
|
||||
|
||||
CouponEntity coupon = this.couponService.getById(couponId);
|
||||
|
||||
BigDecimal salePrice = new BigDecimal(0);
|
||||
|
||||
// 查询书籍 价格
|
||||
BookEntity book = bookService.getById(Integer.valueOf(bookId));
|
||||
|
||||
// 是否为秒杀
|
||||
|
||||
Integer isSale = book.getIsSale();
|
||||
|
||||
if (isSale == 1) {
|
||||
salePrice = book.getSalePrice().subtract(coupon.getCouponAmount());
|
||||
}else {
|
||||
salePrice = book.getPrice().subtract(coupon.getCouponAmount());
|
||||
}
|
||||
|
||||
|
||||
//查询用户
|
||||
MyUserEntity user = this.getById(Integer.valueOf(userId));
|
||||
Double peanutCoin = user.getPeanutCoin() - salePrice.doubleValue();
|
||||
if (peanutCoin < 0) {
|
||||
return "当前书籍以购买,请勿重复购买!";
|
||||
}
|
||||
user.setPeanutCoin(peanutCoin.intValue());
|
||||
this.updateById(user);
|
||||
|
||||
|
||||
TransactionDetailsEntity detailsEntity = new TransactionDetailsEntity();
|
||||
detailsEntity.setUserId(Integer.valueOf(userId));
|
||||
detailsEntity.setChangeAmount(salePrice.negate());
|
||||
detailsEntity.setUserBalance(new BigDecimal(user.getPeanutCoin()));
|
||||
detailsEntity.setRemark("购买:"+book.getName());
|
||||
detailsEntity.setOrderType("购买电子书");
|
||||
detailsEntity.setRelationId(Integer.valueOf(bookId));
|
||||
transactionDetailsService.save(detailsEntity);
|
||||
|
||||
// 插入购买记录
|
||||
UserEbookBuyEntity userEbookBuyEntity = new UserEbookBuyEntity();
|
||||
userEbookBuyEntity.setUserId(Integer.valueOf(userId));
|
||||
userEbookBuyEntity.setBookId(Integer.valueOf(bookId));
|
||||
userEbookBuyEntity.setBookName(book.getName());
|
||||
String authorId = book.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;
|
||||
|
||||
|
||||
userEbookBuyEntity.setAuthor(authorName);
|
||||
userEbookBuyEntity.setImage(book.getImages());
|
||||
userEbookBuyEntity.setPayStatus("支付成功");
|
||||
userEbookBuyEntity.setPayType("point");
|
||||
userEbookBuyEntity.setPayTime(new Date());
|
||||
userEbookBuyService.save(userEbookBuyEntity);
|
||||
|
||||
CouponHistoryEntity historyEntity = this.couponHistoryService.getOne(new QueryWrapper<CouponHistoryEntity>().eq("member_id", userId).eq("coupon_id", couponId));
|
||||
historyEntity.setUseStatus(2);
|
||||
this.couponHistoryService.updateById(historyEntity);
|
||||
|
||||
return "购买成功!";
|
||||
}
|
||||
|
||||
|
||||
private void sendCode(String phone,String code) throws Exception {
|
||||
com.aliyun.dysmsapi20170525.Client client = Sample.createClient(smsConfig.getAccessKeyId(),smsConfig.getAccessKeySecret());
|
||||
SendSmsRequest sendSmsRequest = new SendSmsRequest()
|
||||
.setSignName(smsConfig.getSingName())
|
||||
.setTemplateCode(smsConfig.getTemplateCode())
|
||||
.setPhoneNumbers(phone)
|
||||
.setTemplateParam("{\"code\":\""+ code +"\"}");
|
||||
RuntimeOptions runtime = new RuntimeOptions();
|
||||
try {
|
||||
// 复制代码运行请自行打印 API 的返回值
|
||||
SendSmsResponse sendSmsResponse = client.sendSmsWithOptions(sendSmsRequest, runtime);
|
||||
SendSmsResponseBody body = sendSmsResponse.getBody();
|
||||
System.out.println(body.getMessage());
|
||||
|
||||
} catch (TeaException error) {
|
||||
// 如有需要,请打印 error
|
||||
Common.assertAsString(error.message);
|
||||
} catch (Exception _error) {
|
||||
TeaException error = new TeaException(_error.getMessage(), _error);
|
||||
// 如有需要,请打印 error
|
||||
com.aliyun.teautil.Common.assertAsString(error.message);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import com.peanut.modules.book.entity.ShopProductEntity;
|
||||
import com.peanut.modules.book.service.ShopProductService;
|
||||
import com.peanut.modules.book.vo.ShopCartVo;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
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.OrderCartDao;
|
||||
import com.peanut.modules.book.entity.OrderCartEntity;
|
||||
import com.peanut.modules.book.service.OrderCartService;
|
||||
|
||||
|
||||
@Service("orderCartService")
|
||||
public class OrderCartServiceImpl extends ServiceImpl<OrderCartDao, OrderCartEntity> implements OrderCartService {
|
||||
|
||||
@Autowired
|
||||
private ShopProductService shopProductService;
|
||||
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
IPage<OrderCartEntity> page = this.page(
|
||||
new Query<OrderCartEntity>().getPage(params),
|
||||
new QueryWrapper<OrderCartEntity>()
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ShopCartVo> getCartList(Integer userId) {
|
||||
|
||||
List<OrderCartEntity> list = this.list(new QueryWrapper<OrderCartEntity>().eq("user_id", userId));
|
||||
|
||||
List cartList = new ArrayList<>();
|
||||
|
||||
for (OrderCartEntity orderCartEntity : list) {
|
||||
|
||||
Integer productId = orderCartEntity.getProductId();
|
||||
|
||||
ShopProductEntity productEntity = shopProductService.getById(productId);
|
||||
|
||||
ShopCartVo shopCartVo = new ShopCartVo();
|
||||
|
||||
BeanUtils.copyProperties(orderCartEntity, shopCartVo);
|
||||
|
||||
shopCartVo.setImage(productEntity.getProductImages());
|
||||
|
||||
shopCartVo.setProductName(productEntity.getProductName());
|
||||
|
||||
shopCartVo.setWeight(productEntity.getWeight().doubleValue());
|
||||
|
||||
shopCartVo.setProductStock(productEntity.getProductStock());
|
||||
|
||||
cartList.add(shopCartVo);
|
||||
}
|
||||
|
||||
|
||||
return cartList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OrderCartEntity getDeteleOrderCarts(Integer userId, Integer productId) {
|
||||
return this.getBaseMapper().getDeteleOrderCart(userId,productId);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
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.PayPaymentOrderDao;
|
||||
import com.peanut.modules.book.entity.PayPaymentOrderEntity;
|
||||
import com.peanut.modules.book.service.PayPaymentOrderService;
|
||||
|
||||
|
||||
@Service("payPaymentOrderService")
|
||||
public class PayPaymentOrderServiceImpl extends ServiceImpl<PayPaymentOrderDao, PayPaymentOrderEntity> implements PayPaymentOrderService {
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
IPage<PayPaymentOrderEntity> page = this.page(
|
||||
new Query<PayPaymentOrderEntity>().getPage(params),
|
||||
new QueryWrapper<PayPaymentOrderEntity>()
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
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.PayZfbOrderDao;
|
||||
import com.peanut.modules.book.entity.PayZfbOrderEntity;
|
||||
import com.peanut.modules.book.service.PayZfbOrderService;
|
||||
|
||||
|
||||
@Service("payZfbOrderService")
|
||||
public class PayZfbOrderServiceImpl extends ServiceImpl<PayZfbOrderDao, PayZfbOrderEntity> implements PayZfbOrderService {
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
IPage<PayZfbOrderEntity> page = this.page(
|
||||
new Query<PayZfbOrderEntity>().getPage(params),
|
||||
new QueryWrapper<PayZfbOrderEntity>()
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import com.peanut.modules.book.entity.CityEntity;
|
||||
import com.peanut.modules.book.entity.CountyEntity;
|
||||
import com.peanut.modules.book.entity.ProvinceEntity;
|
||||
import com.peanut.modules.book.service.CityService;
|
||||
import com.peanut.modules.book.service.CountyService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
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;
|
||||
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.ProvinceDao;
|
||||
import com.peanut.modules.book.service.ProvinceService;
|
||||
|
||||
|
||||
@Service("provinceService")
|
||||
public class ProvinceServiceImpl extends ServiceImpl<ProvinceDao, ProvinceEntity> implements ProvinceService {
|
||||
|
||||
@Autowired
|
||||
private CityService cityService;
|
||||
@Autowired
|
||||
private CountyService countyService;
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
IPage<ProvinceEntity> page = this.page(
|
||||
new Query<ProvinceEntity>().getPage(params),
|
||||
new QueryWrapper<ProvinceEntity>()
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ProvinceEntity> getCity() {
|
||||
List<ProvinceEntity> provinceList = this.baseMapper.selectList(new QueryWrapper<ProvinceEntity>());
|
||||
for (ProvinceEntity province:provinceList){
|
||||
List<CityEntity> prov = cityService.getBaseMapper().selectList(new QueryWrapper<CityEntity>()
|
||||
.eq("prov_id", province.getProvId()));
|
||||
|
||||
if (prov.size() > 0) {
|
||||
for (CityEntity cityEntity : prov) {
|
||||
List<CountyEntity> countyList = countyService.getBaseMapper().selectList(new QueryWrapper<CountyEntity>().eq("city_id", cityEntity.getCityId()));
|
||||
if (countyList != null) {
|
||||
cityEntity.setCountyList(countyList);
|
||||
}
|
||||
}
|
||||
province.setCityList(prov);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return provinceList;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
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.PublisherDao;
|
||||
import com.peanut.modules.book.entity.PublisherEntity;
|
||||
import com.peanut.modules.book.service.PublisherService;
|
||||
|
||||
|
||||
@Service("publisherService")
|
||||
public class PublisherServiceImpl extends ServiceImpl<PublisherDao, PublisherEntity> implements PublisherService {
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
IPage<PublisherEntity> page = this.page(
|
||||
new Query<PublisherEntity>().getPage(params),
|
||||
new QueryWrapper<PublisherEntity>()
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
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.SeckillProdRelationDao;
|
||||
import com.peanut.modules.book.entity.SeckillProdRelationEntity;
|
||||
import com.peanut.modules.book.service.SeckillProdRelationService;
|
||||
|
||||
|
||||
@Service("seckillProdRelationService")
|
||||
public class SeckillProdRelationServiceImpl extends ServiceImpl<SeckillProdRelationDao, SeckillProdRelationEntity> implements SeckillProdRelationService {
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
|
||||
String promotionSeckillId = (String) params.get("promotionSeckillId");
|
||||
|
||||
IPage<SeckillProdRelationEntity> page = this.page(
|
||||
new Query<SeckillProdRelationEntity>().getPage(params),
|
||||
new QueryWrapper<SeckillProdRelationEntity>().eq("promotion_seckill_id",promotionSeckillId)
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
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.ShopCategoryDao;
|
||||
import com.peanut.modules.book.entity.ShopCategoryEntity;
|
||||
import com.peanut.modules.book.service.ShopCategoryService;
|
||||
|
||||
|
||||
@Service("shopCategoryService")
|
||||
public class ShopCategoryServiceImpl extends ServiceImpl<ShopCategoryDao, ShopCategoryEntity> implements ShopCategoryService {
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
IPage<ShopCategoryEntity> page = this.page(
|
||||
new Query<ShopCategoryEntity>().getPage(params),
|
||||
new QueryWrapper<ShopCategoryEntity>()
|
||||
);
|
||||
|
||||
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;
|
||||
}).sorted((menu1,menu2)->{
|
||||
return (menu1.getSort() == null? 0 : menu1.getSort()) - (menu2.getSort()==null?0:menu2.getSort());
|
||||
}).collect(Collectors.toList());
|
||||
return level1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeCheckByIds(List<String> asList) {
|
||||
|
||||
|
||||
this.baseMapper.deleteBatchIds(asList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ShopCategoryEntity> getOneLevel() {
|
||||
List<ShopCategoryEntity> list = this.list(new QueryWrapper<ShopCategoryEntity>().eq("parent_cid", 1).eq("show_status", 1));
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ShopCategoryEntity> getTwoLevel(Integer catId) {
|
||||
List<ShopCategoryEntity> list = this.list(new QueryWrapper<ShopCategoryEntity>().eq("parent_cid", catId).eq("show_status", 1));
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Integer> findPoid(Integer oid) {
|
||||
List<Integer> list = new ArrayList<>();
|
||||
List<Integer> poidPList = findPoidPList(oid, list);
|
||||
Collections.reverse(poidPList);
|
||||
|
||||
return poidPList;
|
||||
}
|
||||
|
||||
private List<Integer> findPoidPList(Integer oid,List<Integer> list){
|
||||
list.add(oid);
|
||||
ShopCategoryEntity byId = this.getById(oid);
|
||||
if (byId.getParentCid() != 0){
|
||||
findPoidPList(byId.getParentCid().intValue(),list);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private List<ShopCategoryEntity> getChildrens(ShopCategoryEntity root,List<ShopCategoryEntity> all){
|
||||
|
||||
List<ShopCategoryEntity> children = all.stream().filter(catalogueEntity -> {
|
||||
return root.getCatId().equals(catalogueEntity.getParentCid());
|
||||
}).map(catalogueEntity -> {
|
||||
catalogueEntity.setChildren(getChildrens(catalogueEntity, all));
|
||||
return catalogueEntity;
|
||||
}).sorted((menu1,menu2)->{
|
||||
return (menu1.getSort()==null?0:menu1.getSort()) - (menu2.getSort()==null?0:menu2.getSort());
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
return children;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
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.ShopProductDao;
|
||||
import com.peanut.modules.book.entity.ShopProductEntity;
|
||||
import com.peanut.modules.book.service.ShopProductService;
|
||||
|
||||
|
||||
@Service("shopProductService")
|
||||
public class ShopProductServiceImpl extends ServiceImpl<ShopProductDao, ShopProductEntity> implements ShopProductService {
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
IPage<ShopProductEntity> page = this.page(
|
||||
new Query<ShopProductEntity>().getPage(params),
|
||||
new QueryWrapper<ShopProductEntity>()
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageUtils appQueryPage(Map<String, Object> params) {
|
||||
IPage<ShopProductEntity> page = this.page(
|
||||
new Query<ShopProductEntity>().getPage(params),
|
||||
new QueryWrapper<ShopProductEntity>()
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ShopProductEntity> appGetCategoryList(Integer catId) {
|
||||
List<ShopProductEntity> list = this.getBaseMapper().appGetCategoryList(catId);
|
||||
return list;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,245 @@
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.TypeReference;
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.book.entity.SeckillProdRelationEntity;
|
||||
import com.peanut.modules.book.entity.ShopProductEntity;
|
||||
import com.peanut.modules.book.service.SeckillProdRelationService;
|
||||
import com.peanut.modules.book.service.ShopProductService;
|
||||
import com.peanut.modules.book.to.SeckillRedisTo;
|
||||
import com.peanut.modules.book.vo.ProdInfoVo;
|
||||
import com.peanut.modules.book.vo.SeckillProdVo;
|
||||
import com.peanut.modules.book.vo.SeckillSessionWithProdVo;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.redisson.api.RSemaphore;
|
||||
import org.redisson.api.RedissonClient;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.BoundHashOperations;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
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.ShopSeckillDao;
|
||||
import com.peanut.modules.book.entity.ShopSeckillEntity;
|
||||
import com.peanut.modules.book.service.ShopSeckillService;
|
||||
|
||||
@Slf4j
|
||||
@Service("shopSeckillService")
|
||||
public class ShopSeckillServiceImpl extends ServiceImpl<ShopSeckillDao, ShopSeckillEntity> implements ShopSeckillService {
|
||||
|
||||
@Autowired
|
||||
private SeckillProdRelationService seckillProdRelationService;
|
||||
@Autowired
|
||||
StringRedisTemplate stringRedisTemplate;
|
||||
@Autowired
|
||||
private ShopProductService shopProductService;
|
||||
@Autowired
|
||||
RedissonClient redissonClient;
|
||||
|
||||
private final String SESSIONS_CACHE_PREFIX = "seckill:sessions:";
|
||||
private final String PROKILL_CACHE_PREFIX = "prokill:pro";
|
||||
private final String PRO_STOCK_SEMAPHORE = "seckill:stock:";
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
IPage<ShopSeckillEntity> page = this.page(
|
||||
new Query<ShopSeckillEntity>().getPage(params),
|
||||
new QueryWrapper<ShopSeckillEntity>()
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ShopSeckillEntity> getSeckilProd3Days() {
|
||||
List<ShopSeckillEntity> list = this.baseMapper.selectList(new QueryWrapper<ShopSeckillEntity>().between("start_time", startTime(), endTime()));
|
||||
if (list != null && list.size() > 0) {
|
||||
list.stream().map(session -> {
|
||||
Long seckillId = session.getSeckillId();
|
||||
List<SeckillProdRelationEntity> seckillList = seckillProdRelationService.list(new QueryWrapper<SeckillProdRelationEntity>().eq("promotion_seckill_id", seckillId));
|
||||
session.setRelationProd(seckillList);
|
||||
return session;
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void uploadSeckilProd3Days() {
|
||||
List<ShopSeckillEntity> seckilProd = this.getSeckilProd3Days();
|
||||
List<SeckillSessionWithProdVo> seckilProdVo = JSON.parseObject(JSON.toJSONString(seckilProd), new TypeReference<List<SeckillSessionWithProdVo>>() {
|
||||
});
|
||||
saveSessionInfo(seckilProdVo);
|
||||
saveSessionProdInfo(seckilProdVo);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SeckillRedisTo> getCurrentSeckillProd() {
|
||||
long time = new Date().getTime();
|
||||
|
||||
Set<String> keys = stringRedisTemplate.keys(SESSIONS_CACHE_PREFIX + "*");
|
||||
|
||||
for (String key : keys) {
|
||||
String replace = key.replace(SESSIONS_CACHE_PREFIX, "");
|
||||
String[] s = replace.split("_");
|
||||
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);
|
||||
BoundHashOperations<String, String, Object> operations = stringRedisTemplate.boundHashOps(PROKILL_CACHE_PREFIX);
|
||||
List<Object> objects = operations.multiGet(list);
|
||||
if (objects.size() > 0) {
|
||||
List<SeckillRedisTo> collect = objects.stream().map(item -> {
|
||||
SeckillRedisTo seckillRedisTo = JSON.parseObject(item.toString(), SeckillRedisTo.class);
|
||||
// seckillRedisTo.setRandomCode(null);
|
||||
return seckillRedisTo;
|
||||
}).collect(Collectors.toList());
|
||||
return collect;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String kill(String killId, String key, Integer num , Integer userId) {
|
||||
|
||||
|
||||
BoundHashOperations<String, String, String> hashOps = stringRedisTemplate.boundHashOps(PROKILL_CACHE_PREFIX);
|
||||
String o = hashOps.get(killId);
|
||||
if (StringUtils.isEmpty(o)){
|
||||
return null;
|
||||
}else {
|
||||
SeckillRedisTo seckillRedisTo = JSON.parseObject(o, SeckillRedisTo.class);
|
||||
Long startTime = seckillRedisTo.getStartTime();
|
||||
Long endTime = seckillRedisTo.getEndTime();
|
||||
|
||||
long time = new Date().getTime();
|
||||
|
||||
long ttl = endTime - time;
|
||||
if ( time >= startTime && time <= endTime){
|
||||
String randomCode = seckillRedisTo.getRandomCode();
|
||||
String prodId = seckillRedisTo.getPromotionSeckillId() + "_" + seckillRedisTo.getProdId();
|
||||
if( randomCode.equals(key) && killId.equals(prodId)){
|
||||
if (num <= Integer.valueOf(seckillRedisTo.getSeckillLimit())) {
|
||||
String redisKey = userId + "_" + prodId;
|
||||
Boolean aBoolean = stringRedisTemplate.opsForValue().setIfAbsent(redisKey, num.toString(), ttl, TimeUnit.MILLISECONDS);
|
||||
if (aBoolean) {
|
||||
RSemaphore semaphore = redissonClient.getSemaphore(PRO_STOCK_SEMAPHORE + randomCode);
|
||||
try {
|
||||
boolean b = semaphore.tryAcquire(num, 100, TimeUnit.MILLISECONDS);
|
||||
// 秒杀成功
|
||||
String timeId = IdWorker.getTimeId();
|
||||
return timeId;
|
||||
|
||||
} catch (InterruptedException e) {
|
||||
return null;
|
||||
}
|
||||
}else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}else {
|
||||
return null;
|
||||
}
|
||||
}else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private void saveSessionInfo(List<SeckillSessionWithProdVo> seckilProdVo) {
|
||||
seckilProdVo.stream().forEach(session -> {
|
||||
long startTime = session.getStartTime().getTime();
|
||||
long endTime = session.getEndTime().getTime();
|
||||
String key = SESSIONS_CACHE_PREFIX + startTime + "_" + endTime;
|
||||
|
||||
Boolean aBoolean = stringRedisTemplate.hasKey(key);
|
||||
if (!aBoolean) {
|
||||
List<String> collect = session.getRelationProd().stream().map(item -> item.getPromotionSeckillId() + "_" + item.getProdId().toString()).collect(Collectors.toList());
|
||||
stringRedisTemplate.opsForList().leftPushAll(key, collect);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void saveSessionProdInfo(List<SeckillSessionWithProdVo> seckilProdVos) {
|
||||
|
||||
seckilProdVos.stream().forEach(seckilProdVo -> {
|
||||
|
||||
BoundHashOperations<String, Object, Object> ops = stringRedisTemplate.boundHashOps(PROKILL_CACHE_PREFIX);
|
||||
|
||||
seckilProdVo.getRelationProd().stream().forEach(seckilProd -> {
|
||||
String token = UUID.randomUUID().toString().replace("-", "");
|
||||
if (!ops.hasKey(seckilProd.getPromotionSeckillId().toString() + "_" + seckilProd.getProdId().toString())) {
|
||||
SeckillRedisTo seckillRedisTo = new SeckillRedisTo();
|
||||
|
||||
ShopProductEntity productEntity = shopProductService.getById(seckilProd.getProdId());
|
||||
ProdInfoVo prodInfoVo = JSON.parseObject(JSON.toJSONString(productEntity), new TypeReference<ProdInfoVo>() {
|
||||
});
|
||||
seckillRedisTo.setProdInfo(prodInfoVo);
|
||||
BeanUtils.copyProperties(seckilProd, seckillRedisTo);
|
||||
|
||||
seckillRedisTo.setStartTime(seckilProdVo.getStartTime().getTime());
|
||||
seckillRedisTo.setEndTime(seckilProdVo.getEndTime().getTime());
|
||||
|
||||
seckillRedisTo.setRandomCode(token);
|
||||
|
||||
|
||||
String string = JSON.toJSONString(seckillRedisTo);
|
||||
ops.put(seckilProd.getPromotionSeckillId().toString() + "_" + seckilProd.getProdId().toString(), string);
|
||||
|
||||
RSemaphore semaphore = redissonClient.getSemaphore(PRO_STOCK_SEMAPHORE + token);
|
||||
semaphore.trySetPermits(Integer.valueOf(seckilProd.getSeckillCount()));
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
private String startTime() {
|
||||
LocalDate now = LocalDate.now();
|
||||
LocalTime min = LocalTime.MIN;
|
||||
LocalDateTime start = LocalDateTime.of(now, min);
|
||||
String format = start.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||
return format;
|
||||
}
|
||||
|
||||
private String endTime() {
|
||||
LocalDate now = LocalDate.now();
|
||||
LocalDate localDate = now.plusDays(2);
|
||||
LocalDateTime of = LocalDateTime.of(localDate, LocalTime.MAX);
|
||||
String format = of.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||
return format;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import com.peanut.modules.book.entity.BookEntity;
|
||||
import com.peanut.modules.book.entity.MyUserEntity;
|
||||
import com.peanut.modules.book.service.BookService;
|
||||
import com.peanut.modules.book.service.MyUserService;
|
||||
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")
|
||||
public class TransactionDetailsServiceImpl extends ServiceImpl<TransactionDetailsDao, TransactionDetailsEntity> implements TransactionDetailsService {
|
||||
|
||||
@Autowired
|
||||
private BookService bookService;
|
||||
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
String userId = (String) params.get("userId");
|
||||
|
||||
IPage<TransactionDetailsEntity> page = this.page(
|
||||
new Query<TransactionDetailsEntity>().getPage(params),
|
||||
new QueryWrapper<TransactionDetailsEntity>().eq(StringUtils.isNotBlank(userId),"user_id",userId)
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
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.UserAddressDao;
|
||||
import com.peanut.modules.book.entity.UserAddressEntity;
|
||||
import com.peanut.modules.book.service.UserAddressService;
|
||||
|
||||
|
||||
@Service("userAddressService")
|
||||
public class UserAddressServiceImpl extends ServiceImpl<UserAddressDao, UserAddressEntity> implements UserAddressService {
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
IPage<UserAddressEntity> page = this.page(
|
||||
new Query<UserAddressEntity>().getPage(params),
|
||||
new QueryWrapper<UserAddressEntity>()
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
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.UserEbookBuyDao;
|
||||
import com.peanut.modules.book.entity.UserEbookBuyEntity;
|
||||
import com.peanut.modules.book.service.UserEbookBuyService;
|
||||
|
||||
|
||||
@Service("userEbookBuyService")
|
||||
public class UserEbookBuyServiceImpl extends ServiceImpl<UserEbookBuyDao, UserEbookBuyEntity> implements UserEbookBuyService {
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
String userId = (String) params.get("userId");
|
||||
IPage<UserEbookBuyEntity> page = this.page(
|
||||
new Query<UserEbookBuyEntity>().getPage(params),
|
||||
new QueryWrapper<UserEbookBuyEntity>().eq("user_id",userId)
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user