Kaynağa Gözat

Merge branch 'liuzj-permission-dev' into test

liuzejian 1 yıl önce
ebeveyn
işleme
a801ee0fd1
47 değiştirilmiş dosya ile 18 ekleme ve 3325 silme
  1. 4 0
      modules/Channel/Http/Controllers/PayTemplateController.php
  2. 0 17
      modules/ContentManage/Exceptions/ContentBusinessException.php
  3. 0 20
      modules/ContentManage/Exceptions/ContentManageForbidden.php
  4. 0 9
      modules/ContentManage/Exceptions/Errors.php
  5. 0 298
      modules/ContentManage/Http/Controllers/BookController.php
  6. 0 149
      modules/ContentManage/Http/Controllers/CpListController.php
  7. 0 254
      modules/ContentManage/Http/Controllers/CpSubscribeStatisticDataController.php
  8. 0 176
      modules/ContentManage/Http/Controllers/OutputController.php
  9. 0 54
      modules/ContentManage/Http/Controllers/System/NoticeTypesController.php
  10. 0 163
      modules/ContentManage/Http/Controllers/System/NoticesController.php
  11. 0 14
      modules/ContentManage/Http/Controllers/TestController.php
  12. 0 50
      modules/ContentManage/Http/Requests/BookRequest.php
  13. 0 54
      modules/ContentManage/Http/Requests/CpRequest.php
  14. 0 61
      modules/ContentManage/Http/Requests/NoticeRequest.php
  15. 0 51
      modules/ContentManage/Http/Requests/NoticeTypeRequest.php
  16. 0 32
      modules/ContentManage/Installer.php
  17. 0 25
      modules/ContentManage/Middlewares/ContentManageGate.php
  18. 0 30
      modules/ContentManage/Models/BaseModel.php
  19. 0 16
      modules/ContentManage/Models/Book.php
  20. 0 23
      modules/ContentManage/Models/BookCategories.php
  21. 0 13
      modules/ContentManage/Models/BookChapterContents.php
  22. 0 19
      modules/ContentManage/Models/BookChapters.php
  23. 0 13
      modules/ContentManage/Models/Cp/CpCollection.php
  24. 0 11
      modules/ContentManage/Models/Cp/CpSubscribeStatisticDataModel.php
  25. 0 83
      modules/ContentManage/Models/Cp/Cps.php
  26. 0 15
      modules/ContentManage/Models/CpSubscribeStatisticData.php
  27. 0 15
      modules/ContentManage/Models/NoticeTypes.php
  28. 0 73
      modules/ContentManage/Models/Notices.php
  29. 0 23
      modules/ContentManage/Models/Output/OutputChannel.php
  30. 0 20
      modules/ContentManage/Models/Output/OutputMapping.php
  31. 0 14
      modules/ContentManage/Models/UserNotice.php
  32. 0 31
      modules/ContentManage/Providers/ContentManageServiceProvider.php
  33. 0 10
      modules/ContentManage/README.md
  34. 0 210
      modules/ContentManage/Services/Books/BooksService.php
  35. 0 129
      modules/ContentManage/Services/Books/ChapterService.php
  36. 0 250
      modules/ContentManage/Services/CpManage/BookSettlement.php
  37. 0 136
      modules/ContentManage/Services/CpManage/BookSubscribe.php
  38. 0 83
      modules/ContentManage/Services/CpManage/CpService.php
  39. 0 170
      modules/ContentManage/Services/CpManage/SyncSubscribe.php
  40. 0 88
      modules/ContentManage/Services/Notice/NoitceTypeService.php
  41. 0 248
      modules/ContentManage/Services/Notice/NoticesService.php
  42. 0 10
      modules/ContentManage/config/cpManage.php
  43. 0 4
      modules/ContentManage/config/ok.php
  44. 0 4
      modules/ContentManage/config/oks.php
  45. 0 15
      modules/ContentManage/config/zhushuyunpublicapi.php
  46. 0 142
      modules/ContentManage/routes/route.php
  47. 14 0
      modules/CpManage/Http/Controllers/CpSubscribeStatisticDataController.php

+ 4 - 0
modules/Channel/Http/Controllers/PayTemplateController.php

@@ -102,6 +102,10 @@ class PayTemplateController extends CatchController
 
         $default_optioin = $default_optioin>0?$default_optioin:$option_list[0]['price'];
 
+        if($status == 1){
+            $this->payTemplate->where('uid',$uid)->update(['status'=>0]);
+        }
+
         $pay_template_info = $this->payTemplate->create(['name'=>$name,'uid'=>$uid,'status'=>$status]);
 
         foreach($option_list as $option){

+ 0 - 17
modules/ContentManage/Exceptions/ContentBusinessException.php

@@ -1,17 +0,0 @@
-<?php
-
-namespace Modules\ContentManage\Exceptions;
-
-use Throwable;
-
-class ContentBusinessException extends \RuntimeException
-{
-    public function __construct($message = "", $code = 0, Throwable $previous = null)
-    {
-        parent::__construct($message, $code, $previous);
-    }
-
-    public static function throwError($error, Throwable $previous = null) {
-        throw (new static($error[1], $error[0], $previous));
-    }
-}

+ 0 - 20
modules/ContentManage/Exceptions/ContentManageForbidden.php

@@ -1,20 +0,0 @@
-<?php
-
-namespace Modules\ContentManage\Exceptions;
-
-use Catch\Enums\Code;
-use Catch\Exceptions\CatchException;
-use Symfony\Component\HttpFoundation\Response;
-
-class ContentManageForbidden extends CatchException
-{
-    protected $message = 'permission forbidden';
-
-    protected $code = Code::PERMISSION_FORBIDDEN;
-
-
-    public function statusCode(): int
-    {
-        return Response::HTTP_FORBIDDEN;
-    }
-}

+ 0 - 9
modules/ContentManage/Exceptions/Errors.php

@@ -1,9 +0,0 @@
-<?php
-
-namespace Modules\ContentManage\Exceptions;
-
-class Errors
-{
-    public const REQUEST_HTTP_STATUS_ERROR = [500001, '请求上游接口返回http状态码有误'];
-    public const REQUEST_CODE_STATUS_ERROR = [500002, '请求上游接口返回code状态码有误'];
-}

+ 0 - 298
modules/ContentManage/Http/Controllers/BookController.php

@@ -1,298 +0,0 @@
-<?php
-/**
- * ${CARET}
- * @file:BookController.php
- * @Created by gnitif
- * @Date: 2023/3/22
- * @Time: 13:36
- */
-
-
-namespace Modules\ContentManage\Http\Controllers;
-
-use Catch\Base\CatchController as Controller;
-use Catch\Exceptions\FailedException;
-use Illuminate\Contracts\Pagination\LengthAwarePaginator;
-use Illuminate\Database\Eloquent\Model;
-use Illuminate\Http\Request;
-use Modules\ContentManage\Enums\BookEnum;
-use Modules\ContentManage\Http\Requests\BookRequest;
-use Modules\ContentManage\Models\Book;
-use Modules\ContentManage\Models\BookCategories;
-use Modules\ContentManage\Services\Books\BooksService;
-use Modules\ContentManage\Services\Books\ChapterService;
-use Storage;
-
-class BookController extends Controller
-{
-
-    /**
-     * 书籍列表
-     * name: list
-     * @param Request $request
-     * @return LengthAwarePaginator
-     * date 2023/03/23 13:49
-     */
-    public function list(Request $request)
-    {
-        $where = $this->getCondition($request);
-        $pageSize = $request->input('limit', 20);
-        $list = BooksService::bookList($where, [], $pageSize);
-        $settlementTypes = array_column($this->settlementTypes(), null, 'value');
-        if (!$list->isEmpty()) {
-            foreach ($list as $value) {
-                $value->is_on_shelf = 0;
-                if (!is_empty($value->end_date) && $value->end_date < date("Y-m-d")) {
-                    $value->is_on_shelf = 1;
-                }
-                $value->settlement_type_text = $settlementTypes[$value->settlement_type]['name'] ?? "";
-                $value->status_text = $value->status == 1 ? "完本" : "连载";
-                $value->channel_text = $value->channel == 1 ? "男频" : "女频";
-            }
-        }
-        return $list;
-    }
-
-    /**
-     *  结算方式
-     * name: settlementTypes
-     * @return \string[][]
-     * date 2023/03/23 13:49
-     */
-    public function settlementTypes()
-    {
-        return [
-            ['value' => 'buyout', 'name' => '买断'],
-            ['value' => 'bottomline', 'name' => '保底'],
-            ['value' => 'share', 'name' => '分成'],
-            //['value' => 'zhuishuyun', 'name' => '追书云计算'],
-        ];
-    }
-
-    // 查询条件拼接
-    private function getCondition(Request $request): array
-    {
-        $where = [];
-
-        if (!empty($request->input('name', ""))) {
-            $where['name'] = $request->input('name');
-        }
-        if (!empty($request->input('cp_id', 0))) {
-            $where['cp_id'] = $request->input('cp_id', 0);
-        }
-        if (!empty($request->input('settlement_type', ''))) {
-            $where['settlement_type'] = $request->input('settlement_type', '');
-        }
-        if (!empty($request->input('bid', 0))) {
-            $where['id'] = $request->input('bid', 0);
-        }
-
-        if (!empty($request->input('author', 0))) {
-            $where['author'] = $request->input('author', 0);
-        }
-
-        $createStart = $request->input("create_start", "");
-        $createEnd = $request->input("create_end", "");
-        if (!empty($createStart) || !empty($createEnd)) {
-            if ($createStart == $createEnd) {
-                $createEnd = date("Y-m-d H:i:s", strtotime($createStart) + 86400);
-            }
-            if ($createStart > $createEnd) {
-                $temp = $createEnd;
-                $createEnd = $createStart;
-                $createStart = $temp;
-            }
-            $where['create_start'] = $createStart;
-            if (!empty($createEnd)) {
-                $where['create_end'] = $createEnd;
-            }
-
-        }
-        $createStart = $request->input("start_date", "");
-        $createEnd = $request->input("end_date", "");
-        if (!empty($createStart) || !empty($createEnd)) {
-            if ($createStart == $createEnd) {
-                $createEnd = date("Y-m-d", strtotime($createStart) + 86400);
-            }
-            if ($createStart > $createEnd) {
-                $temp = $createEnd;
-                $createEnd = $createStart;
-                $createStart = $temp;
-            }
-            $where['start_date'] = $createStart;
-            if (!empty($createEnd)) {
-                $where['end_date'] = $createEnd;
-            }
-        }
-        $where['is_export'] = $request->input('is_export', 0);
-        return $where;
-    }
-
-    /**
-     *  编辑版权时间和结算方式
-     * name: editAuthorByBid
-     * @param BookRequest $request
-     * @return bool
-     * date 2023/03/23 13:49
-     */
-    public function editAuthorByBid(BookRequest $request)
-    {
-        $bids = explode(',', $request->input('bid'));
-        $param = [];
-        if ($request->has("status")){
-            $status = $request->input('status');
-            if (!in_array($status,[0,1])){
-                throw new FailedException('连载状态不正确');
-            }
-            $param['status'] = $status;
-        }
-        if ($request->has("settlement_type")){
-            if (!in_array($request->input('settlement_type'), array_column($this->settlementTypes(), 'value'))) {
-                throw new FailedException('结算方式不正确');
-            }
-            $param['settlement_type'] = $request->input('settlement_type');
-            if ($param['settlement_type'] == 'bottomline') {
-                if (!$request->has('bottomline')) {
-                    throw new FailedException('保底金额必填!');
-                }
-                $bottomline = $request->input('bottomline');
-                if (!is_numeric($bottomline) || $bottomline < 0) {
-                    throw new FailedException('保底金额不正确!');
-                }
-                $param['bottomline'] = $bottomline;
-            }
-        }
-
-
-        if (!empty($request->input('start_date', ''))) {
-            $param['start_date'] = $request->input('start_date');
-        }
-        if (!empty($request->input('end_date', ''))) {
-            $param['end_date'] = $request->input('end_date');
-        }
-
-
-        $distributePrivilege = $request->input('distribution_privilege');
-        if($distributePrivilege) {
-            foreach ($bids as $bid) {
-                BooksService::distributeSubmit($bid, $distributePrivilege);
-            }
-        }
-        if (!empty($param)){
-            return BooksService::editAuthorByBids($bids, $param);
-        }
-        return true;
-    }
-
-    /**
-     *   书籍编辑时获取书籍信息
-     * name: bookInfo
-     * @param $bid
-     * @return Model|null
-     * date 2023/03/23 15:35
-     */
-    public function bookInfo($bid)
-    {
-        return (new Book())->firstBy($bid);
-    }
-
-    /**
-     *  获取书籍版权分库信息
-     * name: distributeInfo
-     * @param $bid
-     * date 2023/03/23 15:51
-     */
-    public function distributeInfo($bid)
-    {
-        return BooksService::distributeInfo($bid);
-    }
-
-    /**
-     *  获取书籍版权分库信息
-     * name: distributeInfo
-     * @param $bid
-     * date 2023/03/23 15:51
-     */
-    public function distributeSubmit($bid, Request $request)
-    {
-        $param = $request->input('channels');
-        return BooksService::distributeSubmit($bid, $param);
-    }
-
-    public function export($bid)
-    {
-        return  BooksService::exportByBid($bid);
-    }
-
-
-    public function createBook(Request $request){
-        $cp_id = $request->post('cp_id');
-        $cp_name = $request->post('cp_name');
-        $book_name = $request->post('book_name');
-        $author  = $request->post('author');
-        $channel = $request->post('channel');
-        $status = $request->post('status',1);
-        $category_id = $request->post('category_id');
-        $category_name = $request->post('category_name');
-        $vip_start = $request->post('vip_start',10);
-        $path = $request->post('path');
-        \Log::info('import',['path'=>$path]);
-        
-        $result = BooksService::createBook([
-            'cp_name'=>$cp_name,'cp_id'=>$cp_id,'name'=>$book_name,'author'=>$author,'intro'=>'','cover'=>'','category_id'=>$category_id,
-            'category_name'=>$category_name,'status'=>$status,'channel'=>$channel
-        ]);
-        if(!$result){
-            throw new FailedException('已经导过了');
-        }
-        $chapter_result = ChapterService::createChapterFromFile($result->id,1,$vip_start,storage_path('app/'.$path));
-        Storage::delete($path);
-        $result->size = $chapter_result['size'];
-        $result->chapter_count = $chapter_result['chapter_count'];
-        $result->first_cid = $chapter_result['first_cid'];
-        $result->last_cid = $chapter_result['last_cid'];
-        $result->last_chapter = $chapter_result['last_chapter'];
-        $result->save();
-        $chapter_result['bid'] = $result->id;
-        return $chapter_result;
-    }
-
-
-    public function import(Request $request){
-        if (!$request->hasFile('file')) {
-            throw new FailedException('缺少文件哦');
-        }
-
-        $file = $request->file('file');
-        $path = $file->path();
-        \Log::info('import',['path'=>$path]);
-        $extension = $request->file->extension();
-        $name = \Str::random(40).'.'.$extension;
-        $path = $request->file->storeAs('book',$name);
-        return ['path'=>$path];
-    }
-
-    public function categoryList(Request $request){
-        $bookCategories = new BookCategories();
-        $category_list = $bookCategories->show()
-        ->select('id','category_name','channel_id','channel_name','pid')->get();
-        $result = [
-            ['channel_id'=>1,'channel_name'=>'男频','list'=>[]],
-            ['channel_id'=>2,'channel_name'=>'女频','list'=>[]],
-        ];
-        foreach ($category_list as $item){
-            //if($item->pid == 0) continue;
-            $temp = ['category_id'=>$item->id,'category_name'=>$item->category_name];
-            if($item->channel_id == 1){
-                $result[0]['list'][] = $temp;
-            }
-            if($item->channel_id == 2){
-                $result[1]['list'][] = $temp;
-            }
-        }
-        return $result;
-    }
-
-}
-
-

+ 0 - 149
modules/ContentManage/Http/Controllers/CpListController.php

@@ -1,149 +0,0 @@
-<?php
-/**
- * ${CARET}
- * @file:CpListController.php
- * @Created by gnitif
- * @Date: 2023/3/20
- * @Time: 16:25
- */
-
-
-namespace Modules\ContentManage\Http\Controllers;
-
-use Catch\Base\CatchController as Controller;
-use Catch\Exceptions\FailedException;
-use Illuminate\Http\Request;
-use Modules\ContentManage\Http\Requests\CpRequest;
-use Modules\ContentManage\Models\Cp\CpCollection;
-use Modules\ContentManage\Models\Cp\Cps;
-use Modules\ContentManage\Services\CpManage\CpService;
-
-class CpListController extends Controller
-{
-    /**
-     * @param Cps $model
-     */
-    public function __construct(protected readonly Cps $model,protected readonly CpCollection $cpCollectionModel)
-    {
-
-    }
-
-    /**
-     * cp列表
-     * name: index
-     * @param CpRequest $request
-     * @return mixed
-     * date 2023/03/20 16:26
-     */
-    public function index(Request $request)
-    {
-        $where =[ ['is_deleted','=',0]];
-        if (!empty($request->get("cp_name", ''))){
-            $where[] = ['cp_name','like',"%".$request->get("cp_name", ''). "%"];
-        }
-        if (!empty($request->get("cp_company", ''))) {
-            $where[] = ['cp_company','like',"%".$request->get("cp_company", ''). "%"];
-        }
-
-        return  CpService::getCpList($where,$request->get('limit',15));
-    }
-
-    /**
-     *  添加
-     * name: store
-     * @param CpRequest $request
-     * @return mixed
-     * date 2023/03/23 13:50
-     */
-    public function store(CpRequest $request)
-    {
-        $params = $request->all();
-        // $params['share_per'] = $params['share_per_before'] .":" .$params['share_per_after'];
-        return $this->model->storeBy($params);
-    }
-
-    /**
-     *  获取cp信息
-     * name: show
-     * @param $id
-     * @return mixed
-     * date 2023/03/23 13:50
-     */
-    public function show($id)
-    {
-
-        $cp =  $this->model->where('cp_id', $id)->first();
-        // [$cp['share_per_before'],$cp['share_per_after']] = explode(':',$cp['share_per']);
-        return $cp;
-    }
-
-    /**
-     *  编辑
-     * name: update
-     * @param $id
-     * @param CpRequest $request
-     * @return mixed
-     * date 2023/03/23 13:51
-     */
-    public function update($id, CpRequest $request)
-    {
-        $params = $request->all();
-        // $params['share_per'] = $params['share_per_before'] .":" .$params['share_per_after'];
-        if(isset($params['cp_name'])){
-            unset($params['cp_name']);
-        }
-        return $this->model->updateBy($id, $params);
-    }
-
-    /**
-     *  删除
-     * name: destroy
-     * @param $id
-     * date 2023/03/23 13:51
-     */
-    public function destroy($id)
-    {
-        return $this->model->deleteBy($id);
-    }
-
-    /**
-     * 获取cp现在选
-     * name: selectOptions
-     * @param Request $request
-     * @return mixed
-     * date 2023/03/23 13:51
-     */
-    public function selectOptions(Request $request)
-    {
-        $cpName = $request->input('cp_name','');
-        return CpService::selectOptions($cpName);
-
-    }
-
-
-    /**
-     * 采集
-     * @param Request $request
-     * @return void
-     */
-    public function cpCollection(Request $request){
-        $cpName = $request->get('cp_name');
-        $cpId = $request->get('cp_id');
-
-        if(empty($cpName) || empty($cpId) ){
-            throw new FailedException('缺少参数');
-        }
-
-        
-        $status = $this->cpCollectionModel->where('cp_id',$cpId)->whereIn('spider_status',[0,1])->count();
-        if($status >0){
-            throw new FailedException('正在采集中');
-        }
-
-        $this->cpCollectionModel->create(['cp_id'=>$cpId,'cp_name'=>$cpName,'spider_status'=>0,'spider_result'=>'']);
-
-        return [];
-
-    }
-
-}

+ 0 - 254
modules/ContentManage/Http/Controllers/CpSubscribeStatisticDataController.php

@@ -1,254 +0,0 @@
-<?php
-
-namespace Modules\ContentManage\Http\Controllers;
-
-use Catch\Base\CatchController;
-use Illuminate\Foundation\Validation\ValidatesRequests;
-use Illuminate\Http\Request;
-use Illuminate\Support\Facades\DB;
-
-
-class CpSubscribeStatisticDataController extends CatchController
-{
-    use ValidatesRequests;
-    use \Modules\User\Http\Controllers\UserTrait;
-
-
-    /**
-     * cp结算数据中心列表
-     * @param Request $request
-     * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
-     * @throws \Illuminate\Validation\ValidationException
-     */
-    public function list(Request $request) {
-        $this->validate($request, [
-            'book_name' => 'nullable|string|max:256',
-            'bid' => 'nullable|integer|min:1',
-            'cp_name' => 'nullable|string|min:1',
-            'start_date' => 'nullable|date_format:Y-m-d',
-            'end_date' => 'nullable|date_format:Y-m-d',
-            'page' => 'required|integer|min:1',
-            'limit' => 'integer|min:10|max:300',
-            'is_export' => 'nullable|integer|in:0,1',   // 是否导出全部, 1-是,0-否
-            'final_amount_gt0' => 'nullable|integer|in:0,1', // 应结算金额是否要大于0,
-            'book_settlement_type' => 'nullable|in:share,bottomline', // 书籍合作模式
-        ]);
-        $bookName = $request->input('book_name');
-        $bid = $request->input('bid');
-        $cpName = $request->input('cp_name');
-        $startDate = $request->input('start_date');
-        $endDate = $request->input('end_date');
-        $perPage = $request->input('limit', 15);
-        $isExport = $request->input('is_export', 0);
-        $finalAmountGt0 = $request->input('final_amount_gt0', 0);
-        $bookSettlementType = $request->input('book_settlement_type');
-        $settlementTypes = [
-            'buyout' => '买断', 'bottomline' => '保底', 'share' => '分成', 'zhuishuyun' => '追书云计算'
-        ];
-
-        $cpName = $this->getUserCpName() ?? $cpName;
-
-        /**
-         * 临时代码,
-         */
-        $sql = DB::table('cp_subscribe_statistic_data')
-            ->where('id', -1);
-        if($isExport) {
-            return $sql->get();
-        } else {
-            return $sql->paginate($perPage);
-        }
-
-
-        $sql = DB::table('cp_subscribe_statistic_data as statistic')
-            ->leftJoin('books as book', 'statistic.bid' , 'book.id')
-            ->when($bookName, function ($query, $bookName) {
-                return $query->where('book.name', 'like', '%'.$bookName. '%');
-            })->when($bid , function ($query, $bid) {
-                return $query->where(['statistic.bid' => $bid]);
-            })->when($cpName, function ($query, $cpName) {
-                return $query->where(['statistic.cp_name' => $cpName]);
-            })->when($startDate, function ($query, $startDate) {
-                $realStartDate = date_add(date_create($startDate), date_interval_create_from_date_string('1 day'))
-                    ->format('Y-m-d');
-                return $query->where('statistic.calculate_date', '>=', $realStartDate);
-            })->when($endDate, function ($query, $endDate) {
-                $realEndDate = date_add(date_create($endDate), date_interval_create_from_date_string('1 day'))
-                    ->format('Y-m-d');
-                return $query->where('statistic.calculate_date', '<=', $realEndDate);
-            })->when($finalAmountGt0, function ($query) {
-                return $query->where('statistic.yesterday_final_amount', '>', 0);
-            })->when($bookSettlementType, function ($query, $bookSettlementType){
-                return $query->where('statistic.book_settlement_type', $bookSettlementType);
-            })
-            ->select('statistic.bid', 'book.name as book_name', 'statistic.cp_name',
-            'statistic.yesterday_total_coins', 'statistic.yesterday_available_amount', 'statistic.yesterday_final_amount',
-            'statistic.calculate_date', 'statistic.book_settlement_type')
-            ->orderBy('statistic.calculate_date', 'desc')
-            ->orderBy('statistic.bid', 'desc');
-
-
-        if($isExport) {
-            return $sql->get()->map(function ($item) use($settlementTypes) {
-                $item->date = date_sub(date_create($item->calculate_date), date_interval_create_from_date_string('1 day'))
-                    ->format('Y-m-d');
-                $item->book_settlement_type_str = $settlementTypes[$item->book_settlement_type] ?? '';
-                return $item;
-            });
-        } else {
-            return $sql->paginate($perPage)->through(function ($item) use ($settlementTypes) {
-                $item->date = date_sub(date_create($item->calculate_date), date_interval_create_from_date_string('1 day'))
-                    ->format('Y-m-d');
-                $item->book_settlement_type_str = $settlementTypes[$item->book_settlement_type] ?? '';
-                return $item;
-            });
-        }
-
-
-
-    }
-
-    public function listStatistic(Request $request) {
-        $this->validate($request, [
-            'book_name' => 'nullable|string|max:256',
-            'bid' => 'nullable|integer|min:1',
-            'cp_name' => 'nullable|string|min:1',
-            'start_date' => 'nullable|date_format:Y-m-d',
-            'end_date' => 'nullable|date_format:Y-m-d',
-            'book_settlement_type' => 'nullable|in:share,bottomline'
-        ]);
-        $bookName = $request->input('book_name');
-        $bid = $request->input('bid');
-        $cpName = $request->input('cp_name');
-        $startDate = $request->input('start_date');
-        $endDate = $request->input('end_date');
-        $bookSettlementType = $request->input('book_settlement_type');
-
-        return [
-            'yesterday_total_coins' => 0,
-            'yesterday_available_amount' => 0,
-            'yesterday_final_amount' => 0,
-        ];
-
-        $cpName = $this->getUserCpName() ?? $cpName;
-
-
-
-        $res = DB::table('cp_subscribe_statistic_data as statistic')
-            ->leftJoin('books as book', 'statistic.bid' , 'book.id')
-            ->when($bookName, function ($query, $bookName) {
-                return $query->where('book.name', 'like', '%'.$bookName. '%');
-            })->when($bid , function ($query, $bid) {
-                return $query->where(['statistic.bid' => $bid]);
-            })->when($cpName, function ($query, $cpName) {
-                return $query->where(['statistic.cp_name' => $cpName]);
-            })->when($startDate, function ($query, $startDate) {
-                $realStartDate = date_add(date_create($startDate), date_interval_create_from_date_string('1 day'))
-                    ->format('Y-m-d');
-                return $query->where('statistic.calculate_date', '>=', $realStartDate);
-            })->when($endDate, function ($query, $endDate) {
-                $realEndDate = date_add(date_create($endDate), date_interval_create_from_date_string('1 day'))
-                    ->format('Y-m-d');
-                return $query->where('statistic.calculate_date', '<=', $realEndDate);
-            })->when($bookSettlementType, function ($query, $bookSettlementType){
-                return $query->where('statistic.book_settlement_type', $bookSettlementType);
-            })
-            ->select(
-                DB::raw('sum(yesterday_total_coins) as yesterday_total_coins'),
-                DB::raw('sum(yesterday_available_amount) as yesterday_available_amount'),
-                DB::raw('sum(yesterday_final_amount) as yesterday_final_amount')
-            )->first();
-
-        return $res;
-    }
-
-    /**
-     * cp结算列表
-     * @param Request $request
-     * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
-     * @throws \Illuminate\Validation\ValidationException
-     */
-    public function monthList(Request $request) {
-        $this->validate($request, [
-            'cp_name' => 'nullable|string',
-            'start_month' => 'nullable|date_format:Y-m',
-            'end_month' => 'nullable|date_format:Y-m',
-            'page' => 'required|integer|min:1',
-            'limit' => 'integer|min:10',
-            'is_export' => 'integer|in:0,1'
-        ]);
-
-        $cpName = $request->input('cp_name');
-        $startMonth = $request->input('start_month');
-        $endMonth = $request->input('end_month');
-        $isExport = $request->input('is_export', 0);
-        $finalStateMap = ['notCheck' => '未结算', 'done' => '已结算'];
-
-        $cpName = $this->getUserCpName() ?? $cpName;
-        $sql =  DB::table('cp_subscribe_month_statistic_data as data')
-            ->leftJoin('cps as cp' , 'cp.cp_name', 'data.cp_name')
-            ->when($cpName, function ($query, $cpName){
-                return $query->where(['data.cp_name' => $cpName]);
-            })->when($startMonth, function ($query, $startMonth){
-                return $query->where('data.month', '>=', $startMonth);
-            })->when($endMonth, function ($query, $endMonth){
-                return $query->where('data.month', '<=', $endMonth);
-            })
-            ->select('data.id','data.month', 'cp.cp_id', 'cp.cp_name', 'cp.cp_company',
-            'data.book_num', 'data.final_amount', 'data.final_state', 'data.final_time')
-            ->orderBy('data.month', 'desc')
-            ->orderBy('cp.cp_id', 'desc');
-
-
-        if($isExport) {
-            return $sql->get()->map(function ($item) use ($finalStateMap){
-                $item->final_state_str = $finalStateMap[$item->final_state] ?? '';
-                return $item;
-            });
-        }else {
-            return $sql->paginate($request->integer('limit', 10));
-        }
-    }
-
-    public function saveFinalState(Request $request){
-        $this->validate($request, [
-            'id' => 'required|integer|min:1',
-            'final_state' => 'required|string|in:done'
-        ]);
-        $now = date('Y-m-d H:i:s');
-        DB::table('cp_subscribe_month_statistic_data')
-            ->where(['id' => $request->input('id'), 'final_state' => 'notCheck'])
-            ->update([
-                'final_state' => $request->input('final_state'),
-                'final_time' => $now,
-                'updated_at' => $now,
-            ]);
-        return 'ok';
-    }
-
-    /**
-     * 导出某个cp某个月的各个书籍的应结算金额
-     * @param Request $request
-     * @return \Illuminate\Support\Collection
-     * @throws \Illuminate\Validation\ValidationException
-     */
-    public function listCpMonthFinalAmount(Request $request) {
-        $this->validate($request, [
-            'cp_name' => 'required|string',
-            'month' => 'required|date_format:Y-m'
-        ]);
-        $cpName = $request->input('cp_name');
-        $cpName = $this->getUserCpName() ?? $cpName;
-        return DB::table('cp_book_month_final_amounts as mfa')
-            ->leftJoin('books', 'books.id', 'mfa.bid')
-            ->where([
-                'mfa.is_enabled' => 1,
-                'mfa.cp_name' => $cpName,
-                'mfa.month' => $request->input('month')
-            ])
-            ->select('mfa.id', 'mfa.bid', 'books.name as book_name', 'mfa.final_amount', 'mfa.cp_name','mfa.month')
-            ->get();
-
-
-    }
-}

+ 0 - 176
modules/ContentManage/Http/Controllers/OutputController.php

@@ -1,176 +0,0 @@
-<?php
-
-namespace Modules\ContentManage\Http\Controllers;
-
-use Catch\Base\CatchController as Controller;
-use Illuminate\Http\Request;
-use Catch\Exceptions\FailedException;
-use Modules\ContentManage\Models\Book;
-use Modules\ContentManage\Models\BookCategories;
-use Modules\ContentManage\Models\BookChapterContents;
-use Modules\ContentManage\Models\BookChapters;
-use Modules\ContentManage\Models\Output\OutputChannel;
-use Modules\ContentManage\Models\Output\OutputMapping;
-
-/**
- * 书籍输出
- */
-final class OutputController extends Controller{
-
-    private $output_channel_id = 0;
-    private $channel_name = '';
-    public function __construct(protected readonly Book $book,
-    protected readonly OutputChannel $outputChannel,
-    protected readonly OutputMapping $outputMapping,
-    protected readonly BookChapters $bookChapters,
-    protected readonly BookChapterContents $bookChapterContents,
-    protected readonly BookCategories $bookCategories,
-    Request $request)
-    {
-        $this->checkAccess($request);
-    }
-
-
-    /**
-     * 渠道参数检验
-     *
-     * @param Request $request
-     * @return void
-     */
-    private function checkAccess(Request $request){
-        $channel_name = $request->get('channel_name');
-        $channel_key = $request->get('channel_key');
-        if(empty($channel_name) || empty($channel_key)){
-            throw new FailedException("缺少参数",11001);
-        }
-
-        $output_channel_info = $this->outputChannel->active()
-        ->where('channel_name',$channel_name)->select('id','api_key')->first();
-        if(!$output_channel_info || $output_channel_info->api_key != $channel_key){
-            throw new FailedException("渠道参数错误",11002);
-        }
-        $this->output_channel_id = $output_channel_info->id;
-        $this->channel_name = $channel_name;
-        return ;
-
-    }
-
-    /**
-     * bid校验
-     *
-     * @param [type] $bid
-     * @return void
-     */
-    private  function checkBid($bid){
-        if(!is_numeric($bid)){
-            throw new FailedException("参数错误",11003);
-        }
-
-        if($this->channel_name == 'zhuishuyun'){
-            return true;
-        }
-
-        $map_exists = $this->outputMapping->active()->where('bid',$bid)->count();
-        if(!$map_exists){
-            throw new FailedException("书籍不存在",11004);
-        }
-    }
-
-    /**
-     * 书籍列表
-     *
-     * @return void
-     */
-    public final function bookList(Request $request){
-        $cp_name = $request->get('cp_name');
-        if($cp_name ){
-            return $this->outputMapping->active()
-            ->join('books','books.id','=','book_output_mappings.bid')
-            ->where('books.cp_name',$cp_name)
-            ->where('output_channel_id',$this->output_channel_id)
-            ->select('book_output_mappings.bid','books.name as book_name')->get();
-        }
-        return $this->outputMapping->active()
-        ->join('books','books.id','=','book_output_mappings.bid')
-        ->where('output_channel_id',$this->output_channel_id)
-        ->where('chapter_count','>',0)
-        ->select('book_output_mappings.bid','books.name as book_name')->get();
-    }
-
-    /**
-     * 书籍详情
-     *
-     * @param integer $bid
-     * @return void
-     */
-    public final function bookDetail($bid){
-        $this->checkBid($bid);
-        return $this->book->firstBy($bid,'id',[
-            'id as bid',
-        'name as book_name','author','intro as Introduction','cover','status','channel as channelid','cp_name as cp',
-        'keyword','size as booklength','category_name','category_id','updated_at','end_date as copyright_end_date'
-        ]);
-    }
-
-   /**
-    * 章节列表
-    *
-    * @param integer $bid
-    * @return void
-    */
-    public final function chapterList($bid){
-        $this->checkBid($bid);
-        return $this->bookChapters->where('bid',$bid)
-        ->select('id as chapter_id','bid','name as chapter_name','sequence','is_vip','size','updated_at')
-        ->get();
-    }
-
-    /**
-     * 章节内容
-     *
-     * @param integer $bid
-     * @param integer $chapter_id
-     * @return void
-     */
-    public final function chapterContent($bid,$chapter_id){
-        if(!is_numeric($chapter_id)){
-            throw new FailedException("参数错误",11003);
-        }
-        $this->checkBid($bid);
-        $chapter_info = $this->bookChapters->firstBy($chapter_id,'id',['bid','chapter_content_id','name']);
-        if(!$chapter_info || $chapter_info->bid != $bid || !$chapter_info->chapter_content_id){
-            throw new FailedException("章节不存在",11004);
-        }
-
-        $content_info = $this->bookChapterContents->firstBy($chapter_info->chapter_content_id,'id',['content']);
-        return [
-            'chapter_id'=>$chapter_id,
-            'chapter_name'=>$chapter_info->name,
-            'chapter_content'=>$content_info->content
-        ];
-    }
-
-
-    public final function listCategories(){
-        $category_list = $this->bookCategories->show()
-        ->select('id','category_name','channel_id','channel_name','pid')->get();
-        $result = [
-            ['channel_id'=>1,'channel_name'=>'男频','list'=>[]],
-            ['channel_id'=>2,'channel_name'=>'女频','list'=>[]],
-        ];
-        foreach ($category_list as $item){
-            //if($item->pid == 0) continue;
-            $temp = ['category_id'=>$item->id,'category_name'=>$item->category_name];
-            if($item->channel_id == 1){
-                $result[0]['list'][] = $temp;
-            }
-            if($item->channel_id == 2){
-                $result[1]['list'][] = $temp;
-            }
-        }
-        return $result;
-    }
-
-
- 
-}

+ 0 - 54
modules/ContentManage/Http/Controllers/System/NoticeTypesController.php

@@ -1,54 +0,0 @@
-<?php
-/**
- * ${CARET}
- * @file:NoticeTypesController.php
- * @Created by gnitif
- * @Date: 2023/3/27
- * @Time: 11:52
- */
-
-
-namespace Modules\ContentManage\Http\Controllers\System;
-
-use Catch\Base\CatchController as Controller;
-
-use Illuminate\Http\Request;
-use Modules\ContentManage\Http\Requests\NoticeTypeRequest;
-use Modules\ContentManage\Services\Notice\NoitceTypeService;
-
-class NoticeTypesController extends Controller
-{
-
-    /**
-     * 获取通知分类列表
-     * name: list
-     * @param Request $request
-     * date 2023/03/27 18:20
-     */
-    public function  list(Request $request)
-    {
-        $param  =  $request->all();
-        $list =  NoitceTypeService::list($param, $request->input('is_all',false) == true);
-        return $list;
-    }
-
-    /**
-     *  添加分类
-     * name: add
-     * @param NoticeTypeRequest $request
-     * @return mixed
-     * date 2023/03/28 18:03
-     */
-    public function  add(NoticeTypeRequest $request)
-    {
-        $param = $request->all();
-        return  NoitceTypeService::store($param);
-    }
-
-    public function  delete($id)
-    {
-        return  NoitceTypeService::del($id);
-    }
-
-
-}

+ 0 - 163
modules/ContentManage/Http/Controllers/System/NoticesController.php

@@ -1,163 +0,0 @@
-<?php
-/**
- * ${CARET}
- * @file:NoticesController.php
- * @Created by gnitif
- * @Date: 2023/3/27
- * @Time: 11:18
- */
-
-
-namespace Modules\ContentManage\Http\Controllers\System;
-
-
-use Catch\Base\CatchController as Controller;
-use Catch\Exceptions\FailedException;
-use Illuminate\Contracts\Pagination\LengthAwarePaginator;
-use Illuminate\Http\Request;
-use Modules\ContentManage\Http\Requests\NoticeRequest;
-use Modules\ContentManage\Models\NoticeTypes;
-use Modules\ContentManage\Services\Notice\NoticesService;
-
-class NoticesController extends Controller
-{
-    public function list(Request $request)
-    {
-        return NoticesService::list();
-
-    }
-
-    /**
-     *  添加通知
-     * name: addNotice
-     * @param NoticeRequest $request
-     * @return mixed
-     * date 2023/03/29 14:47
-     */
-    public function addNotice(NoticeRequest $request)
-    {
-        return NoticesService::addNotice($request->all());
-    }
-
-    /**
-     *  删除通知
-     * name: delete
-     * @param $id
-     * date 2023/03/29 14:48
-     */
-    public function delete($id)
-    {
-        return NoticesService::delete($id);
-    }
-
-    /**
-     *  获取通知详情
-     * name: info
-     * @param $id
-     * @return mixed
-     * date 2023/03/29 14:59
-     */
-    public function info($id)
-    {
-        return NoticesService::getDetail($id);
-    }
-
-    public function edit($id, Request $request)
-    {
-        $title = $request->input('title', '');
-        $content = $request->input('content', '');
-        $notice_type_id = $request->input('notice_type_id', 0);
-
-        if (empty($title)) {
-            throw new FailedException('通知标题不能为空!');
-        }
-        if (empty($content)) {
-            throw new FailedException('通知内容不能为空!');
-        }
-        if (empty($notice_type_id)) {
-            throw new FailedException('通知类型必填!');
-        }
-        $tye = NoticeTypes::where('id', $notice_type_id)->where('is_deleted', 0)->value('id');
-        if (empty($tye)) {
-            throw new FailedException('通知类型不正确!');
-        }
-        $param = [
-            'title' => $title,
-            'content' => $content,
-            'notice_type_id' => $notice_type_id,
-            'sort' => $request->input('sort',0),
-        ];
-        NoticesService::update($id, $param);
-    }
-
-    /**
-     *  我的通知
-     * name: myNotices
-     * @param Request $request
-     * @return LengthAwarePaginator
-     * date 2023/03/29 23:48
-     */
-    public function myNotices(Request $request)
-    {
-        return NoticesService::myNoticesList($request->all());
-    }
-
-    /**
-     *  已读
-     * name: setRead
-     * @param $id
-     * date 2023/03/29 23:51
-     */
-    public function setRead($id): mixed
-    {
-         NoticesService::setRead($id);
-         return response()->json(['code' => 10000, "message" => "操作成功",'data' => []]);
-    }
-
-    /**
-     *  用户删除
-     * name: userDel
-     * @param $id
-     * @return mixed
-     * date 2023/03/29 23:55
-     */
-    public function userDel($id): mixed
-    {
-        return NoticesService::userDel($id);
-    }
-
-    /**
-     *  阅读详情
-     * name: detail
-     * @param $id
-     * date 2023/03/30 00:06
-     */
-    public function detail($id)
-    {
-        return NoticesService::detail($id);
-    }
-
-    /**
-     *  获取通知人群选项
-     * name: objOption
-     * @param Request $request
-     * date 2023/03/30 10:20
-     */
-    public function objOption(Request $request)
-    {
-        $type = $request->input('type', '2');
-        $name = $request->input('name', '');
-        $type = $type == "3" ? "role" : "user";
-        return NoticesService::objOption($type, $name);
-    }
-
-    /**
-     *  home页弹窗公告
-     * name: getPopup
-     * date 2023/03/30 16:41
-     */
-    public function getPopup(){
-        return  NoticesService:: getPopup();
-    }
-
-}

+ 0 - 14
modules/ContentManage/Http/Controllers/TestController.php

@@ -1,14 +0,0 @@
-<?php
-
-namespace Modules\ContentManage\Http\Controllers;
-
-use Catch\Base\CatchController;
-use Illuminate\Http\Request;
-use Modules\Common\Support\Upload\Uploader;
-
-class TestController extends CatchController
-{
-    public function test1(Request $request) {
-        return huaweiObsUpload($request->file('photo'));
-    }
-}

+ 0 - 50
modules/ContentManage/Http/Requests/BookRequest.php

@@ -1,50 +0,0 @@
-<?php
-/**
- * ${CARET}
- * @file:CpRequest.php
- * @Created by gnitif
- * @Date: 2023/3/22
- * @Time: 17:06
- */
-
-
-namespace Modules\ContentManage\Http\Requests;
-
-use Illuminate\Foundation\Http\FormRequest;
-use Modules\ContentManage\Models\Cp\Cps;
-
-
-class BookRequest extends  FormRequest
-{
-
-    /**
-     * rules
-     *
-     * @return array
-     */
-    public function rules(): array
-    {
-        return [
-            "bid" =>  "|required|string|min:1",
-            // "settlement_type" =>  "|required|string|min:1",
-            // "start_date" =>  "|required|string|date",
-            // "end_date" =>  "|required|string|date",
-        ];
-    }
-
-
-    /**
-     * messages
-     *
-     * @return string[]
-     */
-    public function messages(): array
-    {
-        return [
-            "bid" => "编辑书籍不能为空",
-            'settlement_type' => '合作模式必填',
-            'start_date' => '版权开始日期必填',
-            'end_date' => '版权到期日期必填',
-        ];
-    }
-}

+ 0 - 54
modules/ContentManage/Http/Requests/CpRequest.php

@@ -1,54 +0,0 @@
-<?php
-/**
- * ${CARET}
- * @file:CpRequest.php
- * @Created by gnitif
- * @Date: 2023/3/22
- * @Time: 17:06
- */
-
-
-namespace Modules\ContentManage\Http\Requests;
-
-use Illuminate\Foundation\Http\FormRequest;
-use Modules\ContentManage\Models\Cp\Cps;
-
-
-class CpRequest extends  FormRequest
-{
-
-    /**
-     * rules
-     *
-     * @return array
-     */
-    public function rules(): array
-    {
-        return [
-            'cp_name' => sprintf('required|unique:%s,%s,%s', Cps::class, 'cp_name', $this->get('cp_id')),
-            "cp_company" =>  "|required|string|min:1",
-            "cp_nick" =>  "|required|string|min:1",
-            "share_per" =>  "|required|Integer|min:0|max:100",
-            // "share_per_before" =>  "|required|Integer|min:1|max:100",
-            // "share_per_after" =>  "|required|Integer|min:1|max:100",
-        ];
-    }
-    /**
-     * messages
-     *
-     * @return string[]
-     */
-    public function messages(): array
-    {
-        return [
-            'cp_name.required' => 'cp名称必须填写',
-            'cp_name.unique' => 'cp名称已存在',
-            'cp_company' => '所属公司必填',
-            'cp_nick' => 'cp简称必填',
-            'address' => '公司地址必填',
-            "share_per" => "分成比例不正确",
-            "share_per_before" => "分成比例不正确",
-            "share_per_after" => "分成比例不正确",
-        ];
-    }
-}

+ 0 - 61
modules/ContentManage/Http/Requests/NoticeRequest.php

@@ -1,61 +0,0 @@
-<?php
-/**
- * ${CARET}
- * @file:CpRequest.php
- * @Created by gnitif
- * @Date: 2023/3/22
- * @Time: 17:06
- */
-
-
-namespace Modules\ContentManage\Http\Requests;
-
-use Illuminate\Foundation\Http\FormRequest;
-use Modules\ContentManage\Models\NoticeTypes;
-
-
-class NoticeRequest extends FormRequest
-{
-
-    /**
-     * rules
-     *
-     * @return array
-     */
-    public function rules(): array
-    {
-        return [
-            'title' => "required|string",
-            'notice_type_id' => [
-                'required',
-                function ($attribute, $value, $fail) {
-                    $has = NoticeTypes::where('is_deleted', 0)->where('id', $value)->value('id');
-                    if (empty($has)) {
-                        $fail("所选分类不存在!");
-                    }
-                }
-            ],
-            'type'=> "required|Integer|in:1,2,3", // 通知人群 1全部 2,指定人,3指定角色
-            'is_popup' => "required|Integer|in:0,1",
-            'content' => "required|string",
-        ];
-    }
-
-    /**
-     * messages
-     *
-     * @return string[]
-     */
-    public function messages(): array
-    {
-        return [
-            'title' => '通知标题必填',
-            'notice_type_id.required' => '通知分类必填',
-            'type.required' => '通知展示人类型必填',
-            'type' => '通知展示人类型不正确',
-            'is_popup' => '展示类型不正确',
-            'content' => '通知内容必填',
-            'notice_obj' => "通知对象必填",
-        ];
-    }
-}

+ 0 - 51
modules/ContentManage/Http/Requests/NoticeTypeRequest.php

@@ -1,51 +0,0 @@
-<?php
-/**
- * ${CARET}
- * @file:CpRequest.php
- * @Created by gnitif
- * @Date: 2023/3/22
- * @Time: 17:06
- */
-
-
-namespace Modules\ContentManage\Http\Requests;
-
-use Illuminate\Foundation\Http\FormRequest;
-use Modules\ContentManage\Models\Cp\Cps;
-use Modules\ContentManage\Models\NoticeTypes;
-
-
-class NoticeTypeRequest extends  FormRequest
-{
-
-    /**
-     * rules
-     *
-     * @return array
-     */
-    public function rules(): array
-    {
-        return [
-                'name' => [
-                'required',
-                function ($attribute, $value, $fail) {
-                    $has = NoticeTypes::where('is_deleted', 0)->where('name', $value)->value('id');
-                    if (!empty($has)) {
-                        $fail("分类已存在!");
-                    }
-                }
-            ]
-        ];
-    }
-    /**
-     * messages
-     *
-     * @return string[]
-     */
-    public function messages(): array
-    {
-        return [
-            'name.required' => '分类名称必须填写',
-        ];
-    }
-}

+ 0 - 32
modules/ContentManage/Installer.php

@@ -1,32 +0,0 @@
-<?php
-
-namespace Modules\ContentManage;
-
-use Catch\Support\Module\Installer as ModuleInstaller;
-use Modules\ContentManage\Providers\ContentManageServiceProvider;
-
-class Installer extends ModuleInstaller
-{
-    protected function info(): array
-    {
-        // TODO: Implement info() method.
-        return [
-            'title' => '内容中台',
-            'name' => 'contentManage',
-            'path' => 'contentManage',
-            'keywords' => '内容中台',
-            'description' => '内容中台管理模块',
-            'provider' => ContentManageServiceProvider::class
-        ];
-    }
-
-    protected function requirePackages(): void
-    {
-        // TODO: Implement requirePackages() method.
-    }
-
-    protected function removePackages(): void
-    {
-        // TODO: Implement removePackages() method.
-    }
-}

+ 0 - 25
modules/ContentManage/Middlewares/ContentManageGate.php

@@ -1,25 +0,0 @@
-<?php
-
-namespace Modules\ContentManage\Middlewares;
-
-use Illuminate\Http\Request;
-use Modules\ContentManage\Exceptions\PermissionForbidden;
-use Modules\User\Models\User;
-
-class ContentManageGate
-{
-    public function handle(Request $request, \Closure $next)
-    {
-        if ($request->isMethod('get')) {
-            return $next($request);
-        }
-
-        /* @var User $user */
-        $user = $request->user(getGuardName());
-
-        if (! $user->can()) {
-            throw new PermissionForbidden();
-        }
-        return $next($request);
-    }
-}

+ 0 - 30
modules/ContentManage/Models/BaseModel.php

@@ -1,30 +0,0 @@
-<?php
-
-namespace Modules\ContentManage\Models;
-
-use Catch\Base\CatchModel as Model;
-use Illuminate\Database\Eloquent\Builder;
-
-
-abstract class BaseModel extends Model
-{
-
-    protected array $defaultHidden = [];
-
-    protected array $defaultCasts = [
-        'created_at' => 'datetime:Y-m-d H:i:s',
-
-        'updated_at' => 'datetime:Y-m-d H:i:s',
-    ];
-    protected $dateFormat = '';
-
-    public static function bootSoftDeletes(): void{
-
-    }
-
-
-    public function scopeActive(Builder $query): void
-    {
-        $query->where($this->table.'.is_enabled', 1);
-    }
-}

+ 0 - 16
modules/ContentManage/Models/Book.php

@@ -1,16 +0,0 @@
-<?php
-
-namespace Modules\ContentManage\Models;
-
-
-class Book extends BaseModel
-{
-
-    protected $table = 'books';
-    protected $dates = [];
-    protected $forceDeleting = true;
-    protected $fillable = [
-        'id', 'cp_name', 'cp_bid', 'cp_id', 'name', 'author', 'intro', 'cover', 'size', 'keyword', 'category_id', 'category_name', 'status', 'chapter_count', 'first_cid', 'last_cid', 'last_chapter', 'created_at', 'updated_at',
-    ];
-
-}

+ 0 - 23
modules/ContentManage/Models/BookCategories.php

@@ -1,23 +0,0 @@
-<?php
-
-namespace Modules\ContentManage\Models;
-
-use Illuminate\Database\Eloquent\Builder;
-
-
-class BookCategories extends BaseModel
-{
-    protected $table = 'book_categories';
-
-    protected $fillable = [
-        'id', 'category_name', 'channel_id', 'channel_name', 'sequence', 'pid', 'is_show', 'created_at', 'updated_at',
-    ];
-
-
-
-    public function scopeShow(Builder $query): void
-    {
-        $query->where($this->table.'.is_show', 1);
-    }
-
-}

+ 0 - 13
modules/ContentManage/Models/BookChapterContents.php

@@ -1,13 +0,0 @@
-<?php
-
-namespace Modules\ContentManage\Models;
-
-class BookChapterContents extends BaseModel
-{
-    protected $table = 'book_chapter_contents';
-
-    protected $fillable = [
-        'id', 'bid', 'chapter_name', 'content', 'created_at', 'updated_at',
-    ];
-
-}

+ 0 - 19
modules/ContentManage/Models/BookChapters.php

@@ -1,19 +0,0 @@
-<?php
-
-namespace Modules\ContentManage\Models;
-
-
-class BookChapters extends BaseModel
-{
-    protected string $sortField = 'sequence';
-
-    // 排序规则
-    protected bool $sortDesc = false;
-
-    protected $table = 'book_chapters';
-
-    protected $fillable = [
-        'id', 'bid', 'chapter_content_id', 'name', 'sequence', 'size', 'is_vip', 'prev_cid', 'next_cid', 'recent_update_at', 'source_chapter_id', 'created_at', 'updated_at',
-    ];
-
-}

+ 0 - 13
modules/ContentManage/Models/Cp/CpCollection.php

@@ -1,13 +0,0 @@
-<?php
-
-namespace Modules\ContentManage\Models\Cp;
-
-use Modules\ContentManage\Models\BaseModel;
-
-class CpCollection extends BaseModel
-{
-    protected $table = 'cp_collections';
-    protected $dates = [];
-    protected $forceDeleting = true;
-    protected $fillable = ['cp_id','cp_name','spider_status','spider_result','created_at', 'updated_at'];
-}

+ 0 - 11
modules/ContentManage/Models/Cp/CpSubscribeStatisticDataModel.php

@@ -1,11 +0,0 @@
-<?php
-
-namespace Modules\ContentManage\Models\Cp;
-
-use Illuminate\Database\Eloquent\Model;
-
-class CpSubscribeStatisticDataModel extends Model
-{
-    protected $table = 'cp_subscribe_statistic_data';
-    protected $guarded = [];
-}

+ 0 - 83
modules/ContentManage/Models/Cp/Cps.php

@@ -1,83 +0,0 @@
-<?php
-/**
- *cp管理
- * @file:Cps.php
- * @Created by gnitif
- * @Date: 2023/3/20
- * @Time: 13:57
- */
-
-
-namespace Modules\ContentManage\Models\Cp;
-
-use Catch\Exceptions\FailedException;
-use Illuminate\Database\Eloquent\Model;
-use Illuminate\Support\Facades\DB;
-use Modules\ContentManage\Services\CpManage\CpService;
-
-class Cps extends Model
-{
-    protected $table = "cps";
-    protected $primaryKey = "cp_id";
-    protected $fillable = [
-        'cp_id', 'cp_nick', 'cp_name', 'cp_company', 'manager', 'phone', 'email', 'share_per', 'settlement_type', 'address', 'is_deleted', 'created_at', 'updated_at', 'deleted_at',
-    ];
-    protected array $fields = ['cp_id', 'cp_nick', 'cp_name', 'cp_company', 'manager', 'phone', 'email', 'share_per','address', 'created_at', 'updated_at'];
-    protected array $form =  ['cp_nick',  'cp_name',  'cp_company',  'manager',  'phone',  'email',  'settlement_type','share_per',   'address'];
-
-    public function storeBy(array $data): mixed
-    {
-        DB::beginTransaction();
-        try {
-            if ($this->create($this->filterData($data))){
-                #上报
-                CpService::reportCpUser(['cp_name' => $data['cp_name']]);
-                DB::commit();
-                return  $this->getKey();
-            }else{
-                throw new \Exception("添加失效");
-            }
-
-        }catch (\Exception $exception){
-            DB::rollBack();
-            throw new FailedException('添加失败!请刷新重试');
-        }
-       return false;
-    }
-
-    public function updateBy($id, array $data)
-    {
-
-        $updated = $this->where($this->getKeyName(), $id)->update($this->filterData($data));
-        return $updated;
-    }
-
-    public function deleteBy($id)
-    {
-        $this->where($this->getKeyName(), $id)->update(['is_deleted' => 1,'deleted_at' => date("Y-m-d H:i:s")]);
-    }
-
-    protected function filterData(array $data): array
-    {
-        // 表单保存的数据集合
-        $fillable = array_unique(array_merge($this->getFillable(), property_exists($this, 'form') ? $this->form : []));
-
-        foreach ($data as $k => $val) {
-            if (is_null($val) || (is_string($val) && ! $val)) {
-                unset($data[$k]);
-            }
-
-            if (! empty($fillable) && ! in_array($k, $fillable)) {
-                unset($data[$k]);
-            }
-
-            if (in_array($k, [$this->getUpdatedAtColumn(), $this->getCreatedAtColumn()])) {
-                unset($data[$k]);
-            }
-        }
-
-        return $data;
-    }
-
-
-}

+ 0 - 15
modules/ContentManage/Models/CpSubscribeStatisticData.php

@@ -1,15 +0,0 @@
-<?php
-
-namespace Modules\ContentManage\Models;
-
-
-
-class CpSubscribeStatisticData extends BaseModel
-{
-    protected $table = 'cp_subscribe_statistic_data';
-
-    protected $fillable = [
-        'id', 'cp_user_id', 'bid', 'calculate_date', 'month', 'book_name', 'available_amount', 'last_amount', 'total_amount', 'current_month_book_num', 'cp_source', 'yesterday_charge_balance', 'yesterday_available_amount', 'yesterday_last_amount', 'yesterday_total_amount', 'data_source_id', 'data_source_from', 'data_source_created_at', 'data_source_updated_at', 'created_at', 'updated_at',
-    ];
-
-}

+ 0 - 15
modules/ContentManage/Models/NoticeTypes.php

@@ -1,15 +0,0 @@
-<?php
-
-namespace Modules\ContentManage\Models;
-
-
-
-class NoticeTypes extends BaseModel
-{
-    protected $table = 'notice_types';
-
-    protected $fillable = [
-        'id', 'name', 'is_deleted', 'created_at', 'updated_at', 'deleted_at',
-    ];
-
-}

+ 0 - 73
modules/ContentManage/Models/Notices.php

@@ -1,73 +0,0 @@
-<?php
-
-namespace Modules\ContentManage\Models;
-
-
-class Notices extends BaseModel
-{
-    protected $table = 'notices';
-
-    protected $fillable = [
-        'id', 'title', 'content', 'notice_type_id', "sort", 'type', 'notice_obj', 'is_popup', 'is_deleted', 'created_at', 'updated_at', 'deleted_at',
-    ];
-
-    /**
-     * @var array
-     */
-    protected array $fields = ['id', 'title', 'content', "sort", 'notice_type_id', 'type', 'notice_obj', 'is_popup', 'created_at', 'updated_at'];
-
-    /**
-     * @var array
-     */
-    protected array $form = ['title', 'content', 'notice_type_id',"sort", 'type', 'notice_obj', 'is_popup'];
-
-
-    protected $casts = ['notice_obj' => 'array'];
-
-    public array $searchable = [
-        'title' => 'like',
-        'notice_type_id' => '=',
-        'type' => '=',
-
-    ];
-
-    protected string $sortField = 'sort';
-
-
-
-    /**
-     *  添加通知
-     * @param array $data
-     * @return bool
-     * @throws \ReflectionException
-     */
-    public function storeBy(array $data): mixed
-    {
-        $result = '';
-        $this->beginTransaction();
-        try {
-            $result = $this->create($this->filterData($data));
-            if (isset($data['user_ids']) && !empty($data['user_ids'])) {
-                $this->addUserNotice($data['user_ids'], $result->id);
-            }
-            $this->commit();
-        } catch (\Exception $exception) {
-            $this->rollback();
-        }
-        return $result->id ?? 0;
-    }
-
-    private function addUserNotice(mixed $userIds, mixed $id)
-    {
-        $list = [];
-        foreach ($userIds as $val) {
-            $list[] = ['user_id' => $val, 'notice_id' => $id];
-        }
-        if (!empty($list)) {
-            UserNotice::insert($list);
-        }
-        return true;
-    }
-
-
-}

+ 0 - 23
modules/ContentManage/Models/Output/OutputChannel.php

@@ -1,23 +0,0 @@
-<?php
-
-namespace Modules\ContentManage\Models\Output;
-
-
-use Modules\ContentManage\Models\BaseModel;
-
-class OutputChannel extends BaseModel
-{
-
-    protected $primaryKey = 'id';
-
-    protected array $defaultHidden = [];
-    protected array $defaultCasts = [];
-
-
-    protected $table = 'book_output_channels';
-
-    protected $fillable = [
-        'id', 'channel_name','remark', 'api_key', 'is_enabled', 'created_at', 'updated_at',
-    ];
-
-}

+ 0 - 20
modules/ContentManage/Models/Output/OutputMapping.php

@@ -1,20 +0,0 @@
-<?php
-
-namespace Modules\ContentManage\Models\Output;
-
-
-use Modules\ContentManage\Models\BaseModel;
-
-class OutputMapping extends BaseModel
-{
-    protected $table = 'book_output_mappings';
-
-    protected array $defaultHidden = [];
-    protected array $defaultCasts = [];
-
-
-    protected $fillable = [
-        'id', 'output_channel_id', 'bid', 'is_enabled', 'created_at', 'updated_at',
-    ];
-
-}

+ 0 - 14
modules/ContentManage/Models/UserNotice.php

@@ -1,14 +0,0 @@
-<?php
-
-namespace Modules\ContentManage\Models;
-
-
-class UserNotice extends BaseModel
-{
-    protected $table = 'user_notice';
-
-    protected $fillable = [
-        'id', 'user_id', 'notice_id', 'is_deleted', 'is_read', 'created_at', 'updated_at', 'deleted_at',
-    ];
-
-}

+ 0 - 31
modules/ContentManage/Providers/ContentManageServiceProvider.php

@@ -1,31 +0,0 @@
-<?php
-
-namespace Modules\ContentManage\Providers;
-
-use Catch\CatchAdmin;
-use Catch\Providers\CatchModuleServiceProvider;
-use Modules\ContentManage\Middlewares\ContentManageGate;
-
-class ContentManageServiceProvider extends CatchModuleServiceProvider
-{
-    /**
-     * middlewares
-     *
-     * @return string[]
-     */
-    protected function middlewares(): array
-    {
-       return [ContentManageGate::class];
-    }
-
-    /**
-     * route path
-     *
-     * @return string|array
-     */
-    public function moduleName(): string|array
-    {
-        // TODO: Implement path() method.
-        return 'contentManage';
-    }
-}

+ 0 - 10
modules/ContentManage/README.md

@@ -1,10 +0,0 @@
-#内容中台管理模块
-关于内容中台 相关的后台接口,对外api接口,都写在这里
-配置文件放在: config目录下,读取配置文件示例:config('contentManage.zhushuyunpublicapi.public_domain');
-config("模块名.配置文件名.配置项");
-
-数据库模型文件放在:Models 目录下面
-服务层文件放在:Services 目录下面
-控制器放在:modules/ContentManage/Http/Controllers 目录下面
-中间件放在:modules/ContentManage/Middlewares 目录下面
-路由只能现在 modules/ContentManage/rout/route.php 文件里

+ 0 - 210
modules/ContentManage/Services/Books/BooksService.php

@@ -1,210 +0,0 @@
-<?php
-/**
- * ${CARET}
- * @file:BooksService.php
- * @Created by gnitif
- * @Date: 2023/3/22
- * @Time: 11:46
- */
-
-
-namespace Modules\ContentManage\Services\Books;
-
-use Catch\Exceptions\FailedException;
-use Illuminate\Support\Facades\Storage;
-use Modules\ContentManage\Models\Book;
-use Modules\ContentManage\Models\BookChapterContents;
-use Modules\ContentManage\Models\BookChapters;
-use Modules\ContentManage\Models\Output\OutputChannel;
-use Modules\ContentManage\Models\Output\OutputMapping;
-
-class BooksService
-{
-
-    /***
-     *  书籍列表分页
-     * name: bookList
-     * @param array $where
-     * @param array $order
-     * @param int $pageSize
-     * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
-     * date 2023/03/23 11:52
-     */
-    public static function bookList($where = [], $order = [], $pageSize = 20)
-    {
-
-        $list = Book::leftJoin('cps', 'cps.cp_id', 'books.cp_id')
-            ->select("books.id",
-                "books.name",
-                "books.author",
-                "books.intro",
-                "books.cover",
-                "books.size",
-                "books.keyword",
-                "books.status",
-                "books.chapter_count",
-                "books.category_name",
-                "books.channel",
-                "books.settlement_type",
-                "books.bottomline",
-                "books.start_date",
-                "books.end_date",
-                "books.created_at",
-                "cps.cp_name")->orderBy('books.id','desc');
-        $isExport = $where['is_export'] ?? 0;
-        $where = self::getCondition($where);
-        if (!is_empty($where)) {
-            $list->where($where);
-        }
-        if($isExport) {
-            return $list->get();
-        } else {
-            return $list->paginate($pageSize);
-        }
-    }
-
-    /**
-     * 查询条件拼接
-     * name: getCondition
-     * @param array $params
-     * @return array
-     * date 2023/03/23 11:52
-     */
-    private static function getCondition($params = [])
-    {
-        $where = [];
-        if (isset($params['name']) && !empty(isset($params['name']))) {
-            $where[] = ['books.name', 'like', "%{$params['name']}%"];
-        }
-        if (isset($params['id']) && !empty(isset($params['id']))) {
-            $where[] = ['books.id', '=', $params['id']];
-        }
-        if (isset($params['author']) && !empty(isset($params['author']))) {
-            $where[] = ['books.author', '=', $params['author']];
-        }
-        if (isset($params['settlement_type']) && !empty(isset($params['settlement_type']))) {
-            $where[] = ['books.settlement_type', '=', $params['settlement_type']];
-        }
-        if (isset($params['cp_id']) && !empty(isset($params['cp_id']))) {
-            $where[] = ['books.cp_id', '=', $params['cp_id']];
-        }
-        if (isset($params['create_start']) && !empty(isset($params['create_start']))) {
-            $where[] = ['books.created_at', '>', $params['create_start']];
-        }
-        if (isset($params['create_end']) && !empty(isset($params['create_end']))) {
-            $where[] = ['books.created_at', '<', $params['create_end']];
-        }
-        if (isset($params['start_date']) && !empty(isset($params['start_date']))) {
-            $where[] = ['books.end_date', '>=', $params['start_date']];
-        }
-        if (isset($params['end_date']) && !empty(isset($params['end_date']))) {
-            $where[] = ['books.end_date', '<=', $params['end_date']];
-        }
-        return $where;
-    }
-
-    /**
-     *  编辑书籍版权日期,结算方式
-     * name: editAuthorByBids
-     * @param $bids
-     * @param array $param
-     * date 2023/03/23 11:52
-     */
-    public static function editAuthorByBids($bids, $param = [])
-    {
-        return Book::whereIn('id', $bids)->update($param);
-    }
-
-    /**
-     *  保存书籍版权分库信息
-     * name: distributeInfo
-     * @param $bid
-     * date 2023/03/23 15:51
-     */
-    public static function distributeSubmit($bid, $params)
-    {
-        foreach ($params as $value) {
-            $data = [
-                'output_channel_id' => $value['channel_id'],
-                'is_enabled' => $value['is_enabled'] == 1 ? 1 : 0,
-                'bid' => $bid
-            ];
-            $info = OutputMapping::where('bid', $bid)->where('output_channel_id', $value['channel_id'])->first();
-
-            if ($info) {
-                $info->is_enabled = $value['is_enabled'] == 1 ? 1 : 0;
-                $info->update($data);
-            }else{
-                OutputMapping::create($data);
-            }
-        }
-        return true;
-    }
-
-    /**
-     *  获取书籍版权分库信息
-     * name: distributeInfo
-     * @param $bid
-     * date 2023/03/23 15:51
-     */
-    public static function distributeInfo($bid)
-    {
-        $channels = OutputChannel::where('is_enabled', 1)->select('id as channel_id', 'channel_name', 'remark')->get();
-        if ($channels->isEmpty()) {
-            return $channels;
-        }
-        $channelIds = array_column($channels->toArray(), 'channel_id');
-        $auth = OutputMapping::where('bid', $bid)->whereIn('output_channel_id', $channelIds)->select()->get()->toArray();
-
-        if (!empty($auth)) {
-            $auth = array_column($auth, null, 'output_channel_id');
-        }
-        foreach ($channels as $val) {
-            $info = $auth[$val->channel_id] ?? [];
-            $val->is_enabled = $info['is_enabled'] ?? 0;
-        }
-
-        return $channels;
-    }
-
-    /**
-     *  导出书籍
-     * name: exportByBid
-     * @param $bid
-     * date 2023/03/24 13:30
-     */
-    public static function exportByBid($bid)
-    {
-        $bookInfo = Book::where('id', $bid)->select('name', 'id')->first();
-        if (is_empty($bookInfo)) {
-            throw new FailedException('请选择正确的书籍');
-        }
-        $chapters = BookChapters::where('bid', $bid)->select('chapter_content_id as cid', 'name')->orderBy('sequence',"asc")->get();
-        $fileName = $bookInfo->name . '-' . $bookInfo->id . ".txt";
-        $model = new  BookChapterContents();
-        $contents =  $bookInfo->name . "\r\n";
-        if (!empty($chapters)) {
-            foreach ($chapters as  $val ){
-                $contents .= "###". $val->name."\r\n";
-                $content = $model->where('bid',$bid)->where('id',$val->cid)->value('content');
-                if ($content){
-                    $contents .= $content."\r\n";
-                }
-            }
-        }
-        return  response()->streamDownload(function () use ($contents){
-            echo $contents;
-        },$fileName);
-    }
-
-
-    public static function createBook(array $data){
-        $exists = Book::where('cp_id', $data['cp_id'])->where('name', $data['name'])->count();
-        if( $exists){
-            return null;
-        }
-        return Book::create($data);
-    }
-
-}
-

+ 0 - 129
modules/ContentManage/Services/Books/ChapterService.php

@@ -1,129 +0,0 @@
-<?php
-/**
-
- */
-
-namespace Modules\ContentManage\Services\Books;
-
-use Modules\ContentManage\Models\BookChapterContents;
-use Modules\ContentManage\Models\BookChapters;
-
-class ChapterService{
-
-
-
-    /**
-     * 解析导入的文件,可以从中间章节导入,但是比空虚连续,比如可以从第5章导入$start_sequence=5,可以支持覆盖导入
-     * 比如如果之前导入的第10-20章有问题,可以重新导入第10-20章,此时$start_sequence=10,会覆盖之前第10-20章的内容
-     * @param [int] $bid 
-     * @param [itn] $start_sequence   开始序号,可以支持
-     * @param [int] $vip_start        vip起始章节
-     * @param [string] $path          文件目录  
-     * @return void
-     */
-    public static function createChapterFromFile($bid,$start_sequence,$vip_start,$path){
-        if( !file_exists($path)){
-            return ;
-        }
-        $handle = fopen($path, "r");
-        $i = $start_sequence;
-        $content = '';
-        $last_name = '';
-        $last_chapter = '';
-        $size = 0;
-        $first_cid = 0;
-        $last_cid = 0;
-        //一行行读入文件,如果当前行是以###开头,则表示此行是章节标题,直到读到下一个标题,两个标题中间的内容就是正文
-        while (($buffer = fgets($handle)) !== false) {
-            $buffer = trim($buffer);
-            $buffer = trim($buffer,' ');
-            $buffer = preg_replace('/\s+/','',$buffer);
-            if (!$buffer) continue;
-            $temp =$buffer;
-            //解析标题
-            if($name = self::parseName($temp)){
-                if(!$last_name){
-                    //第一行直接过
-                    $last_name = $name;
-                }else{
-                    //第二行,中间的部分是内容,此时可以保存数据库
-                    $is_vip = $i >= $vip_start? 1:0;
-                    $size += mb_strlen($content);
-                    $cid = self::createOrUpdateContent($bid,$i,$last_name,$content,$is_vip);
-                    if($i  == $start_sequence){
-                        $first_cid = $cid;
-                    }
-                    $i++;$content = '';
-                    $last_name = $name;
-                }
-            }else{
-                $content .= $temp."\r\n";
-            }
-        }
-        //当前是最后一张
-        $is_vip = $i >= $vip_start? 1:0;
-        $last_cid = self::createOrUpdateContent($bid,$i,$last_name,$content,$is_vip);
-        $last_chapter = $last_name;
-        $size += mb_strlen($content);
-        fclose($handle);
-        return ['size'=>$size,'chapter_count'=>$i,'first_cid'=>$first_cid,'last_cid'=>$last_cid,'last_chapter'=>$last_chapter];
-    }
-
-    /**
-     * 保存章节,支持覆盖
-     *
-     * @param [type] $bid
-     * @param [type] $sequence
-     * @param [type] $name
-     * @param [type] $content
-     * @param [type] $is_vip
-     * @return void
-     */
-    private static function createOrUpdateContent($bid,$sequence,$name,$content,$is_vip){
-        $name = mb_convert_encoding($name,'UTF-8');
-        $content = mb_convert_encoding($content,'UTF-8');
-        $chapter_info = BookChapters::where('bid',$bid)->where('sequence',$sequence)->first();
-        if($chapter_info){
-            $content_info = BookChapterContents::where('id',$chapter_info->chapter_content_id)->first();
-            if($content_info){
-                $content_info->chapter_name = $name;
-                $content_info->content = $content;
-                $content_info->save();
-            }else{
-                $content_info = BookChapterContents::create(['bid'=>$bid,'chapter_name'=>$name,'content'=>$content]);
-            }
-            $chapter_info->name = $name;
-            $chapter_info->size = mb_strlen($content);
-            $chapter_info->chapter_content_id = $content_info->id;
-            $chapter_info->save();
-        }else{
-            $content_info =  BookChapterContents::create(['bid'=>$bid,'chapter_name'=>$name,'content'=>$content]);
-            $chapter_info = BookChapters::create([
-                'bid'=>$bid,'name'=>$name,'sequence'=>$sequence,'size'=>mb_strlen($content),
-                'is_vip'=>$is_vip,'prev_cid'=>0,'next_cid'=>0,'chapter_content_id'=>$content_info->id
-            ]);
-        }
-        return $chapter_info->id;
-    }
-
-
-
-    /**
-     * 解析章节标题
-     *
-     * @param [type] $content
-     * @return void
-     */
-    private static function parseName($content){
-        if(stripos($content,'###') !== false){
-            return str_replace('###','',$content);
-        }
-        /*
-        $status = preg_match('/^第.*?章/',$content);
-        if($status){
-            return  $content;
-        }*/
-        return '';
-    }
-
-}

+ 0 - 250
modules/ContentManage/Services/CpManage/BookSettlement.php

@@ -1,250 +0,0 @@
-<?php
-
-namespace Modules\ContentManage\Services\CpManage;
-
-use Illuminate\Support\Facades\DB;
-use Modules\Common\Support\Trace\CustomizeLogger;
-use Modules\Common\Support\Trace\TraceContext;
-
-class BookSettlement
-{
-    private $settlementResult = [];
-    private $bid;
-    // 初始的结算模式信息
-    private $initialSettlementModeInfo = null;
-    private $month;
-    private $lastMonthLastDate;
-    private $currentMonthLastDate;
-    private $currentMonthFirstDate;
-    private $settlementModeInfos = null;
-    private $finalAmounts = null;
-    private $logger;
-    /**
-     * @var TraceContext
-     */
-    public $traceContext;
-
-    public function __construct($bid, $month)
-    {
-        $this->bid = $bid;
-        $this->month = $month;
-        $this->currentMonthFirstDate = $this->month . '-01';
-        $this->lastMonthLastDate = date_sub(date_create($this->currentMonthFirstDate),
-            date_interval_create_from_date_string('1 day'))->format('Y-m-d');
-        $this->currentMonthLastDate = date_sub(date_add(date_create($this->month),
-            date_interval_create_from_date_string('1 month')),
-            date_interval_create_from_date_string('1 day'))->format('Y-m-d');
-        $this->logger = CustomizeLogger::getLogger('bookMonthSettlement', 'debug');
-        $this->traceContext = app(TraceContext::class);
-    }
-
-    private function initSettlementModeInfo() {
-        $record = DB::table('book_settlement_mode_history')
-            ->where(['bid' => $this->bid, 'is_enabled' => 1])
-            ->where('effective_date', '<', $this->currentMonthFirstDate)
-            ->orderBy('id', 'desc')
-            ->first();
-        if(!$record) {
-            $bookInfo = DB::table('books')
-                ->where(['id' => $this->bid])
-                ->select('id', 'settlement_type', 'bottomline')
-                ->first();
-            $modeInfo = [
-                'settlement_mode' => $bookInfo->settlement_type,
-                'bottomline' => $bookInfo->bottomline,
-                'effective_date' => '2000-01-01',
-                'total_amount' => 0,
-                'change_reason' => 'manual',
-            ];
-        } else {
-            $modeInfo = [
-                'settlement_mode' => $record->settlement_mode,
-                'bottomline' => $record->bottomline,
-                'effective_date' => $record->effective_date,
-                'total_amount' => $record->total_amount,
-                'change_reason' => $record->change_reason,
-            ];
-        }
-
-        if('bottomline' == $modeInfo['settlement_mode']) {
-            if('manual' == $modeInfo['change_reason']) {
-                $modeInfo['total_amount'] = $this->getBookTotalAmount($modeInfo['effective_date']);
-            }
-            if($modeInfo['total_amount'] >= $modeInfo['bottomline']) {
-                $modeInfo['settlement_mode'] = 'out_bottomline';
-            }
-        }
-        $this->logger->debug('初始结算状态', [
-            'traceInfo' => $this->traceContext->getTraceInfo(),
-            'modeInfo' => $modeInfo]);
-        return $modeInfo;
-    }
-
-    private function getBookTotalAmount($effectiveDate) {
-        return DB::table('cp_subscribe_statistic_data')
-            ->where([
-                ['settlement_date', '>=', $effectiveDate],
-                ['settlement_date', '<=', $this->lastMonthLastDate],
-                ['bid' , '=', $this->bid],
-            ])->sum('yesterday_final_amount');
-    }
-
-    private function getInitialSettlementModeInfo(){
-        if(is_null($this->initialSettlementModeInfo)) {
-            $this->initialSettlementModeInfo = $this->initSettlementModeInfo();
-        }
-        return $this->initialSettlementModeInfo;
-    }
-
-    /**
-     * 获取本月可用结算模式
-     * @return null
-     */
-    private function getSettlementModes() {
-        if(is_null($this->settlementModeInfos)) {
-            $initSettlementMode = $this->getInitialSettlementModeInfo();
-            $this->settlementModeInfos[$initSettlementMode['effective_date']] = $initSettlementMode;
-            $historyList = DB::table('book_settlement_mode_history')
-                ->whereBetween('effective_date', [$this->currentMonthFirstDate, $this->currentMonthLastDate])
-                ->where(['is_enabled' => 1, 'bid' => $this->bid])
-                ->orderBy('id', 'asc')
-                ->get();
-
-            foreach ($historyList as $history) {
-                $this->settlementModeInfos[$history->effective_date] = [
-                    'settlement_mode' => $history->settlement_mode,
-                    'bottomline' => $history->bottomline,
-                    'effective_date' => $history->effective_date,
-                    'total_amount' => $history->total_amount
-                ];
-            }
-        }
-
-        return $this->settlementModeInfos;
-    }
-
-    /**
-     * 获取本月每日原始应结算金额明细
-     * @return \Illuminate\Support\Collection
-     */
-    private function getFinalAmounts() {
-        if (is_null($this->finalAmounts)) {
-            $this->finalAmounts = DB::table('cp_subscribe_statistic_data')
-                ->whereBetween('settlement_date', [$this->currentMonthFirstDate, $this->currentMonthLastDate])
-                ->select('yesterday_final_amount', 'settlement_date', 'bid')
-                ->where(['bid' => $this->bid])
-                ->get()->keyBy('settlement_date');
-        }
-
-        return $this->finalAmounts;
-    }
-
-    /**
-     * 获取 {month} 中各天的应结算金额
-     * @return array
-     * <pre>
-     * [
-     *      "2023-03-01"=> 2.5,
-     *      "2023-03-02"=> 2.5,
-     *      ...
-     *      "2023-03-30"=> 2.5,
-     *      "2023-03-31"=> 2.5,
-     * ]
-     * </pre>
-     */
-    public function detail() {
-        $this->logger->debug('开始处理书籍', [
-            'traceInfo' => $this->traceContext->getTraceInfo(),
-            'bid' => $this->bid, 'month' => $this->month,
-        ]);
-        $date = $this->currentMonthFirstDate;
-        $settlementModes = $this->getSettlementModes();
-        $this->logger->debug('结算状态集合', ['traceInfo' => $this->traceContext->getTraceInfo(),
-            'settlementModeInfos' => $settlementModes]);
-        $finalAmounts = $this->getFinalAmounts();
-        $this->logger->debug('原始应结算金额', ['traceInfo' => $this->traceContext->getTraceInfo(),
-            'sourceFinalAmounts' => $finalAmounts->toArray()]);
-        while ($date <= $this->currentMonthLastDate) {
-            $this->logger->debug('开始处理日期:'. $date, ['traceInfo' => $this->traceContext->getTraceInfo(),
-                'date' => $date]);
-            $nextDate = date_add(date_create($date), date_interval_create_from_date_string('1 day'))
-                ->format('Y-m-d');
-            if($finalAmounts->has($date)) {
-                $currentSettlementMode = null;
-                ksort($settlementModes);
-                foreach ($settlementModes as $settlementMode) {
-                    if($date >= $settlementMode['effective_date']) {
-                        $currentSettlementMode = $settlementMode;
-                    }
-                }
-                $sourceFinalAmount = $finalAmounts->get($date)->yesterday_final_amount;
-                $this->logger->debug('该天有原始应结算金额数据', ['traceInfo' => $this->traceContext->getTraceInfo(),
-                    'sourceFinalAmount' => $sourceFinalAmount]);
-                $this->logger->debug('该日期可用的结算模式', ['traceInfo' => $this->traceContext->getTraceInfo(),
-                    'settlementMode' => $currentSettlementMode]);
-                if('bottomline' == $currentSettlementMode['settlement_mode']) {
-                    $settlementModes[$currentSettlementMode['effective_date']]['total_amount'] += $sourceFinalAmount;
-                    if($settlementModes[$currentSettlementMode['effective_date']]['total_amount'] >
-                        $settlementModes[$currentSettlementMode['effective_date']]['bottomline']) {
-
-                        $this->settlementResult[$date] = $settlementModes[$currentSettlementMode['effective_date']]['total_amount'] -
-                            $settlementModes[$currentSettlementMode['effective_date']]['bottomline'];
-                        $this->logger->debug('当前原始应结算金额累计超出书籍保底金额',
-                            ['traceInfo' => $this->traceContext->getTraceInfo(),
-                                'currentSettlementMode' => $settlementModes[$currentSettlementMode['effective_date']],
-                                'realFinalAmount' => $this->settlementResult[$date]]);
-                        if(!key_exists($nextDate, $settlementModes)) {
-                            $this->logger->debug('下一天没有对应结算模式故可增加一个超保底结算模式,保证下一天按超保底结算',
-                                ['traceInfo' => $this->traceContext->getTraceInfo(), 'nextDate' => $nextDate]);
-                            $settlementModes[$nextDate] = [
-                                'settlement_mode' => 'out_bottomline',
-                                'effective_date' => $nextDate,
-                                'total_amount' => 0,
-                                'bottomline' => 0,
-                            ];
-                        }
-                    } else {
-                        $this->logger->debug('当前原始应结算金额没有超出书籍保底金额',
-                            ['traceInfo' => $this->traceContext->getTraceInfo(), 'realFinalAmount' => 0]);
-                        $this->settlementResult[$date] = 0;
-                    }
-                }
-                elseif ('buyout' == $currentSettlementMode['settlement_mode']) {
-                    $this->logger->debug('当前书籍结算模式为买断,故该天最终结算0',
-                        ['traceInfo' => $this->traceContext->getTraceInfo(), 'realFinalAmount' => 0]);
-                    $this->settlementResult[$date] = 0;
-                }
-                else {
-                    $this->logger->debug('其他的结算模式,应结算金额保持不变',
-                        ['traceInfo' => $this->traceContext->getTraceInfo(), 'realFinalAmount' => $sourceFinalAmount]);
-                    $this->settlementResult[$date] = $sourceFinalAmount;
-                }
-
-            } else {
-                $this->settlementResult[$date] = 0;
-            }
-            $date = $nextDate;
-        }
-
-        ksort($settlementModes);
-        $lastMonthLastDateSettlementMode = \last($settlementModes);
-        $now = date('Y-m-d H:i:s');
-        if('out_bottomline' == $lastMonthLastDateSettlementMode['settlement_mode']) {
-            $this->logger->debug('入库保存本月最后一个结算模式', ['traceInfo' => $this->traceContext->getTraceInfo(),
-                'lastMonthLastDateSettlementMode' => $lastMonthLastDateSettlementMode]);
-            DB::table('book_settlement_mode_history')
-                ->insert([
-                    'bid' => $this->bid,
-                    'effective_date' => $this->currentMonthLastDate,
-                    'settlement_mode' => $lastMonthLastDateSettlementMode['settlement_mode'],
-                    'bottomline' => $lastMonthLastDateSettlementMode['bottomline'],
-                    'total_amount' => $lastMonthLastDateSettlementMode['total_amount'],
-                    'change_reason' => 'auto',
-                    'created_at' => $now,
-                    'updated_at' => $now
-                ]);
-        }
-
-        return $this->settlementResult;
-    }
-}

+ 0 - 136
modules/ContentManage/Services/CpManage/BookSubscribe.php

@@ -1,136 +0,0 @@
-<?php
-
-namespace Modules\ContentManage\Services\CpManage;
-
-use Illuminate\Support\Facades\DB;
-use Modules\Common\Support\Trace\CustomizeLogger;
-use Modules\Common\Support\Trace\TraceContext;
-
-class BookSubscribe
-{
-    /**
-     * 从追书云拉取的订阅信息
-     * <pre>
-     * [
-     *      'zhiyu_book_id' => 1,  // 植宇书籍id
-     *      'cp_source' => xxx,  // 植宇cp
-     *      'yestoday_available_amount' => xxx,  // 订阅金额
-     *      'yestoday_total_amount' => xxx , // 订阅结算统计书币
-     *      'yestoday_last_amount' => xxx, // 应结算金额
-     * ]
-     * </pre>
-     * @var array
-     */
-    public $subscribeInfo;
-    // cp 信息
-    private $cp = null;
-    // 书籍信息
-    private $book = null;
-    // 日志对象
-    private $logger;
-
-    public function __construct(array $subscribeInfo)
-    {
-        $this->subscribeInfo = $subscribeInfo;
-        $this->logger = CustomizeLogger::getSubscribeLogger();
-    }
-
-    public function getBook() {
-        if(!$this->book) {
-            $this->book = DB::table('books')
-                ->where(['id' => $this->subscribeInfo['zhiyu_book_id']])
-                ->select('id', 'settlement_type', 'cp_id')->first();
-        }
-        return $this->book;
-    }
-
-    public function getCp() {
-        if(!$this->cp) {
-            $this->cp = DB::table('cps')
-                ->where(['cp_id' => $this->getBook()->cp_id])
-                ->select('cp_id as id', 'share_per', 'cp_name')
-                ->first();
-        }
-        return $this->cp;
-    }
-
-    /**
-     * 是否需要将拉取的cp书籍订阅数据入库
-     * @return bool
-     */
-    private function needSave() {
-        $book = $this->getBook();
-        if(!$book) {
-            $this->logger->error('书籍信息不存在', [
-                'traceInfo' => app(TraceContext::class)->getTraceInfo(),
-                'zhiyu_book_id'  => $this->subscribeInfo['zhiyu_book_id'],
-            ]);
-            return false;
-        }
-
-        $cp = $this->getCp();
-        if(!$cp) {
-            $this->logger->error('cp信息不存在', [
-                'traceInfo' => app(TraceContext::class)->getTraceInfo(),
-                'cp_id'  => $book->cp_id,
-            ]);
-            return false;
-        }
-
-        if('buyout' == $book->settlement_type) {
-            $this->logger->info('买断书籍不入cp订阅数据', [
-                'traceInfo' => app(TraceContext::class)->getTraceInfo(),
-                'bid'  => $book->id,
-            ]);
-            return false;
-        }
-
-        return true;
-    }
-
-    /**
-     * 获取书籍订阅数据
-     * 如果  settlement_type  是 zhuishuyun   则采用 这个接口的计算数据
-     * 如果使用  share  分成的模式;则 应结算金额 =  订阅金额 * 分成比例(cp表的); 保留两位小数,其他小数位舍去,例如 计算的结果是 16.129 那么保存 16.12
-     * 买断模式: 数据中心不记录 书籍相关订阅数据;
-     * @return array|null
-     * <pre>
-     * [
-     *      'yesterday_available_amount' => xxx , // zy_cp_subscribe_statistic_data.yesterday_available_amount
-     *      'yesterday_final_amount' => xxx , // zy_cp_subscribe_statistic_data.yesterday_final_amount
-     *      'yesterday_total_coins' => xxx , // zy_cp_subscribe_statistic_data.yesterday_total_coins
-     *      'cp_name' => xxx, // cp唯一名称
-     *      'zy_bid' => xx, // zy_books.id
-     *      'calculate_date' => xxx', // 结算日期,结算的数据是前一个日期的 zy_cp_subscribe_statistic_data.calculate_date
-     *      'month' => xxx,  // 月份
-     * ]
-     * </pre>
-     */
-    public function dealSubscribeInfo() {
-        if(!$this->needSave()) {
-            return null;
-        }
-        $book = $this->getBook();
-        $cp = $this->getCp();
-        $data['yesterday_available_amount'] = intval(($this->subscribeInfo['yestoday_available_amount'] ?? 0) * 100) / 100;
-        $data['yesterday_total_coins'] = intval(($this->subscribeInfo['yestoday_total_amount'] ?? 0) * 100) / 100;
-        $data['yesterday_final_amount'] = intval(($this->subscribeInfo['yestoday_last_amount'] ?? 0) * 100) / 100;
-        $data['cp_name'] = $cp->cp_name;
-        $data['zy_bid'] = $book->id;
-        $data['calculate_date'] = $this->subscribeInfo['calculate_date'];
-        $data['month'] = $this->subscribeInfo['month'];
-        $data['book_settlement_type'] = $book->settlement_type;
-
-        if('share' == $book->settlement_type) {
-            $data['yesterday_final_amount'] = intval(round(
-                $data['yesterday_available_amount'] * (intval($cp->share_per)),2)) / 100;
-        }
-
-        $this->logger->debug('cp订阅数据入库信息', [
-            'traceInfo' => app(TraceContext::class)->getTraceInfo(),
-            'beforeSubscribeInfo'  => $this->subscribeInfo,
-            'afterSubscribeInfo' => $data
-        ]);
-        return $data;
-    }
-}

+ 0 - 83
modules/ContentManage/Services/CpManage/CpService.php

@@ -1,83 +0,0 @@
-<?php
-/**
- * ${CARET}
- * @file:CpService.php
- * @Created by gnitif
- * @Date: 2023/3/21
- * @Time: 20:24
- */
-
-
-namespace Modules\ContentManage\Services\CpManage;
-
-use GuzzleHttp\Client;
-use Illuminate\Contracts\Pagination\LengthAwarePaginator;
-use Illuminate\Support\Facades\DB;
-use Illuminate\Support\Facades\Log;
-use Modules\ContentManage\Models\Book;
-use Modules\ContentManage\Models\Cp\Cps;
-use function Symfony\Component\Translation\t;
-
-class CpService
-{
-
-    public static function reportCpUser($user)
-    {
-        $params = [
-            'username' => $user['cp_name'],
-            'is_enabled' => 1,
-            'is_show_total_amount' => $user['is_show_total_amount'] ?? 0,
-            'is_union_sign' => $user['is_union_sign'] ?? 0,
-            'timestamp' => time(),
-        ];
-        $params['sign'] = self::getSign($params['timestamp']);
-        $url = config('contentManage.zhushuyunpublicapi.public_domain', 'https://pubapi.zhuishuyun.com') . '/inapi/cpUers/createUser';
-
-        $client = new Client(['base_uri' => $url,'timeout' => 2]);
-        $response =  $client->request('post','',['query' => $params]);
-        $result = $response->getBody()->getContents();
-        $result = json_decode($result, true);
-        if (!isset($result['code']) || $result['code'] != 0) {
-            Log::error("cp创建用户接口请求异常,请求结果为:" . var_export($result, true));
-            throw new  \Exception("cp创建用户接口请求异常");
-        }
-        return true;
-    }
-
-    private static function getSign(mixed $timestamp)
-    {
-        $key =  config('contentManage.zhushuyunpublicapi.external_private_key', 'ZSY_2021!KEY');
-        $string = md5($timestamp . $key) . $key;
-        return md5($string);
-    }
-
-    public static function selectOptions($cpName = "")
-    {
-        $list = Cps::select('cp_id','cp_name','cp_nick','cp_company');
-        if (!empty($cpName)){
-            $list->where('cp_name','like',"%{$cpName}%");
-        }
-        return $list->get();
-    }
-
-    /**
-     *  查询产品列表
-     * name: getCpList
-     * @param  $where
-     * @param int $pageSize
-     * @return LengthAwarePaginator
-     * date 2023/03/22 20:49
-     */
-    public static function getCpList($where , int $pageSize = 20)
-    {
-        $list =  DB::table('cps')->where($where)->orderBy('cp_id','desc')->paginate($pageSize);
-        if(!$list->isEmpty()){
-            foreach ($list as  $value){
-                $value->book_count = Book::where('cp_id', $value->cp_id)->count();
-            }
-        }
-        return  $list;
-    }
-
-
-}

+ 0 - 170
modules/ContentManage/Services/CpManage/SyncSubscribe.php

@@ -1,170 +0,0 @@
-<?php
-
-namespace Modules\ContentManage\Services\CpManage;
-
-use GuzzleHttp\Client;
-use Modules\Common\Support\Trace\CustomizeLogger;
-use Modules\Common\Support\Trace\TraceContext;
-use Modules\ContentManage\Exceptions\ChannelBusinessException;
-use Modules\ContentManage\Exceptions\Errors;
-use Modules\ContentManage\Models\Cp\CpSubscribeStatisticDataModel;
-
-class SyncSubscribe
-{
-    private $httpClient = null;
-    public $syncUrl;
-    public $syncStartDate;
-    public $syncEndDate;
-    private $logger;
-    private $perPage = 200;
-
-    public function __construct()
-    {
-        $this->httpClient = new Client(['timeout' => 10]);
-
-        $this->logger = CustomizeLogger::getSubscribeLogger();
-    }
-
-    private function getSyncUrl() {
-        return $this->syncUrl ?:
-            join('/', [
-                trim(config('contentManage.zhushuyunpublicapi.public_domain'), '/'),
-                'outapi/zhiyu/getSubsByZhiyu'
-            ]);
-    }
-
-    private function buildQuery($page = 0)
-    {
-        $query = [];
-        if ($this->syncStartDate) {
-            $query['start_time'] = $this->syncStartDate;
-        }
-        if ($this->syncEndDate) {
-            $query['end_time'] = $this->syncEndDate;
-        }
-        $query['is_all'] = 0;
-        $query['page'] = $page;
-        $query['per_page'] = $this->perPage;
-        $query['timestamp'] = time();
-        $privateKey = config('contentManage.zhushuyunpublicapi.external_private_key');
-        $query['sign'] = md5(md5($query['timestamp'] . $privateKey) . $privateKey);
-        return $query;
-    }
-
-    public function sync()
-    {
-        try {
-            $this->doSync();
-        } catch (\Exception $exception) {
-            $this->logger->error('同步失败,再次重试', [
-                'traceInfo' => app(TraceContext::class)->getTraceInfo(),
-                'errCode' => $exception->getCode(), 'errMsg' => $exception->getMessage()
-            ]);
-            usleep(500000);
-            $this->doSync();
-        }
-    }
-
-    private function doSync()
-    {
-        $page = 0;
-        $dataCollect = collect();
-        while (true) {
-            try {
-                $result = $this->httpClient->get($this->getSyncUrl(), [
-                    'query' => $this->buildQuery($page)
-                ]);
-            } catch (\Exception $exception) {
-                $this->logger->error('请求上游接口报错,准备重试', [
-                    'traceInfo' => app(TraceContext::class)->getTraceInfo(),
-                    'errCode' => $exception->getCode(), 'errMsg' => $exception->getMessage()
-                ]);
-                usleep(500000);
-                $result = $this->httpClient->get($this->getSyncUrl(), [
-                    'query' => $this->buildQuery($page)
-                ]);
-            }
-            $parsedResult = $this->parseResult($result);
-            if (0 == count($parsedResult['data'])) {
-                break;
-            }
-            foreach ($parsedResult['data'] as $tempData) {
-                $tempData['bid'] = 0;
-                if($dataCollect->has($tempData['zhiyu_book_id'])) {
-                    $t = $dataCollect->get($tempData['zhiyu_book_id']);
-                    $t['yestoday_available_amount'] += $tempData['yestoday_available_amount'];
-                    $t['yestoday_last_amount'] += $tempData['yestoday_last_amount'];
-                    $t['yestoday_total_amount'] += $tempData['yestoday_total_amount'];
-                    $dataCollect->put($tempData['zhiyu_book_id'], $t);
-                } else {
-                    $dataCollect->put($tempData['zhiyu_book_id'], $tempData);
-                }
-            }
-
-            $page = $parsedResult['current_page'] + 1;
-            if ($page > $parsedResult['last_page']) {
-                break;
-            }
-        }
-        $this->saveResult($dataCollect);
-    }
-
-    /**
-     * note1:
-     * 接口中的书籍id(zhiyu_book_id)去植宇书库zy_books去查,
-     * @param $datas
-     */
-    private function saveResult($datas)
-    {
-        foreach ($datas as $data) {
-            $bookSubscribe = new BookSubscribe($data);
-            $insertData = $bookSubscribe->dealSubscribeInfo();
-            if(is_null($insertData)) {
-                continue;
-            }
-
-            CpSubscribeStatisticDataModel::updateOrCreate([
-                'cp_name' => $insertData['cp_name'], 'bid' => $insertData['zy_bid'],
-                'calculate_date' => $insertData['calculate_date']
-            ], [
-                'month' => $insertData['month'],
-                'settlement_date' => date_sub(date_create($insertData['calculate_date']),
-                    date_interval_create_from_date_string('1 day'))->format('Y-m-d'),
-                'yesterday_available_amount' => $insertData['yesterday_available_amount'],
-                'yesterday_final_amount' => $insertData['yesterday_final_amount'],
-                'yesterday_total_coins' => $insertData['yesterday_total_coins'],
-                'book_settlement_type' => $insertData['book_settlement_type'],
-                'data_source_id' => $data['id'] ?? 0,
-                'data_source_from' => 'zhuishuyun',
-                'data_source_bid' => $data['bid'] ?? 0,
-            ]);
-        }
-    }
-
-    private function parseResult($rawResult)
-    {
-        $httpStatus = $rawResult->getStatusCode();
-        if (200 != $httpStatus) {
-            ChannelBusinessException::throwError(Errors::REQUEST_HTTP_STATUS_ERROR);
-        }
-        $rawContent = $rawResult->getBody()->getContents();
-        $parsedContent = \json_decode($rawContent, true);
-        $this->logger->debug('请求接口结果', [
-            'traceInfo' => app(TraceContext::class)->getTraceInfo(),
-            'url' => $this->syncUrl,
-            'parsedContent' => $parsedContent,
-        ]);
-
-        $code = $parsedContent['code'] ?? -1;
-        if (0 != $code) {
-            ChannelBusinessException::throwError(Errors::REQUEST_CODE_STATUS_ERROR);
-        }
-
-        return [
-            'current_page' => $parsedContent['data']['current_page'],
-            'last_page' => $parsedContent['data']['last_page'],
-            'data' => $parsedContent['data']['data']
-        ];
-    }
-
-}

+ 0 - 88
modules/ContentManage/Services/Notice/NoitceTypeService.php

@@ -1,88 +0,0 @@
-<?php
-/**
- * ${CARET}
- * @file:NoitceTypeService.php
- * @Created by gnitif
- * @Date: 2023/3/27
- * @Time: 11:54
- */
-
-
-namespace Modules\ContentManage\Services\Notice;
-
-use Illuminate\Support\Facades\DB;
-use Modules\ContentManage\Models\NoticeTypes;
-
-class NoitceTypeService
-{
-
-    /**
-     *  添加分类
-     * name: store
-     * @param array $param
-     * $param [
-     *      'name' => "平台通知"
-     * ];
-     * date 2023/03/27 18:14
-     */
-    public static function store(array $param)
-    {
-        return self::getModel()->storeBy($param);
-    }
-
-    protected static function getModel(){
-         return new NoticeTypes();
-    }
-
-    /**
-     *  获取通知分类列表分类
-     * name: list
-     * @param mixed $param
-     *  $param = [
-     *      'name' => '系统通知', // 分类名称模糊搜索
-     *      'page' => 1, //  页码
-     *      'limit' => 15, //  每页条数
-     * ]
-     * @param mixed $isAll // 是否获取所有数据 默认否
-     * date 2023/03/28 17:05
-     */
-    public static function list($param = [], $isAll = false)
-    {
-        $where = self::getCondition($param);
-        if ($isAll){
-            return   NoticeTypes::where($where)->select('id','name')->get();
-        }else {
-            $pageSize = $param['limit'] ?? 15;
-            return   NoticeTypes::where($where)->select('id', 'name', 'created_at')->paginate($pageSize);
-        }
-
-    }
-
-    /**
-     *  拼接查询条件
-     * name: getCondition
-     * @param mixed $param
-     * @return \string[][]
-     * date 2023/03/28 17:19
-     */
-    private static function getCondition(mixed $param)
-    {
-        $where = [['is_deleted', '=', '0']];
-        if (isset($param['name']) && !empty($param['name'])) {
-            $where[] = ['name', 'like', "%" . $param['name'] . "%"];
-        }
-        return $where;
-    }
-
-    /**
-     *  删除分类,软删除
-     * name: del
-     * @param $id
-     * @return mixed
-     * date 2023/03/29 11:05
-     */
-    public static function del($id)
-    {
-        return self::getModel()->updateBy($id,['is_deleted' => 1,'deleted_at' => date("Y-m-d H:i:s")]);
-    }
-}

+ 0 - 248
modules/ContentManage/Services/Notice/NoticesService.php

@@ -1,248 +0,0 @@
-<?php
-/**
- * ${CARET}
- * @file:NoitceService.php
- * @Created by gnitif
- * @Date: 2023/3/27
- * @Time: 11:54
- */
-
-
-namespace Modules\ContentManage\Services\Notice;
-
-use Catch\Exceptions\FailedException;
-use Illuminate\Database\Eloquent\Model;
-use Illuminate\Support\Facades\Auth;
-use Illuminate\Support\Facades\DB;
-use Modules\ContentManage\Models\Notices;
-use Modules\ContentManage\Models\UserNotice;
-use Modules\Permissions\Models\Roles;
-use Modules\User\Models\User;
-use PharIo\Manifest\Author;
-
-class NoticesService
-{
-
-    protected static function getModel()
-    {
-        return new Notices();
-    }
-
-    /**
-     *  添加通知
-     * name: addNotice
-     * @param array $param
-     *  $param = [
-     *      'title' => '测试', // 通知标题
-     *      'notice_type_id' =>  2, // 通知分类id
-     *      'type' => '2', // 通知人群 1全部 2,指定人,3指定角色
-     *      'notice_obj' => [['id' =>  1,'name' => "超管"]] , // 通知对象
-     *      'is_popup' => '1', // 是否是弹窗 1弹窗  0 普通
-     *       'content' => '312312', // 通知内容
-     * ];
-     *
-     * date 2023/03/29 14:25
-     */
-    public static function addNotice(array $param)
-    {
-
-        if ($param['type'] != 1 && (!isset($param['notice_obj']) || empty($param['notice_obj']))) {
-            throw new FailedException('通知对象不能为空!');
-        }
-
-        if ($param['type'] == 3) {
-            $roleIds = array_column($param['notice_obj'], 'id');
-            $userIds = DB::table('user_has_roles')->whereIn('role_id', $roleIds)->pluck('user_id')->toArray();
-        } else if ($param['type'] == 2) {
-            $userIds = array_column($param['notice_obj'], 'id');
-        } else {
-            $userIds = User::pluck('id')->toArray();
-            $param['notice_obj'] = [];
-        }
-        $param['user_ids'] = $userIds;
-        return self::getModel()->storeBy($param);
-    }
-
-    public static function delete($id)
-    {
-        return self::getModel()->updateBy($id, ['is_deleted' => 1, 'deleted_at' => get_date()]);
-    }
-
-    /**
-     *  获取通知详情
-     * name: getDetail
-     * @param $id
-     * @return \Illuminate\Database\Eloquent\Collection|\Illuminate\Support\Collection|Notices[]
-     * date 2023/03/29 15:12
-     */
-    public static function getDetail($id)
-    {
-        $info = Notices::leftJoin('notice_types', 'notice_types.id', 'notices.notice_type_id')
-            ->select('notices.*', 'notice_types.name as notice_type_name')->where('notices.id', $id)->first();
-        return $info;
-    }
-
-    /**
-     *  更新
-     * name: update
-     * @param $id
-     * @param array $param
-     * date 2023/03/29 18:32
-     */
-    public static function update($id, array $param)
-    {
-       return  self::getModel()->updateBy($id, $param);
-    }
-
-    /**
-     *  管理员操作通知列表
-     * name: list
-     * @return mixed
-     * date 2023/03/29 22:49
-     */
-    public static function  list()
-    {
-        $list = self::getModel()->setBeforeGetList(function ($query) {
-            return $query->where('is_deleted', 0)->orderBy('created_at','desc');
-        })->getList();
-        if (!$list->isEmpty()) {
-            $cate = NoitceTypeService::list([], true);
-            if ($cate->isEmpty()) {
-                $cate = [];
-            } else {
-                $cate = array_column($cate->toArray(), null, 'id');
-            }
-
-            foreach ($list as $value) {
-                $value->notice_type_txt = $cate[$value->notice_type_id]['name'] ?? "";
-                $value->type_txt = $value->type == 1 ? "全部" : ($value->type == 2 ? "指定用户" : "指定角色");
-            }
-        }
-        return $list;
-    }
-
-    /**
-     * 我的通知
-     * name: myNoticesList
-     * date 2023/03/29 22:49
-     */
-    public static function myNoticesList($param = [])
-    {
-        $type = $param['type'] ?? "";
-        $noticeTypeId = $param['notice_type_id'] ?? 0;
-        $title = $param['title'] ?? "";
-        $pageSize = $param['limit'] ?? 0;
-        $pageSize = $pageSize < 1 ? 15 : $pageSize;
-        $userId = Auth::guard(getGuardName())->id();
-        $where = [
-            ['user_notice.is_deleted', '=', 0],
-            ['user_notice.user_id', '=', $userId],
-            ['notices.is_deleted', '=', 0],
-            ['user_notice.is_deleted', '=', 0],
-        ];
-        if ($type) {
-            $where[] = ['notices.type', '=', $type];
-        }
-        if ($noticeTypeId) {
-            $where[] = ['notices.notice_type_id', '=', $noticeTypeId];
-        }
-        if ($title) {
-            $where[] = ['notices.title', 'like', "%" . $title . "%"];
-        }
-
-        $list = UserNotice::leftJoin('notices', 'notices.id', "user_notice.notice_id")->where($where)->select('notices.id', 'notices.title', 'notices.is_popup', "user_notice.is_read", 'notices.created_at')
-            ->orderBy('notices.created_at', 'desc')->orderBy('sort', 'desc')->paginate($pageSize);
-        if (!$list->isEmpty()) {
-            foreach ($list as $val) {
-                $val->is_read_txt = $val->is_read == 1 ? "已读" : "未读";
-            }
-        }
-        return $list;
-    }
-
-    /**
-     *  设置已读
-     * name: setRead
-     * @param $id
-     * date 2023/03/29 23:51
-     */
-    public static function setRead($id)
-    {
-        $userId = Auth::guard(getGuardName())->id();
-        return UserNotice::where('user_id', $userId)->where('notice_id', $id)->update(['is_read' => 1, 'read_at' => get_date()]);
-    }
-
-    /**
-     *  用户删除
-     * name: userDel
-     * @param $id
-     * date 2023/03/29 23:55
-     */
-    public static function userDel($id)
-    {
-        $userId = Auth::guard(getGuardName())->id();
-        return UserNotice::where('user_id', $userId)->where('notice_id', $id)->update(['is_deleted' => 1, 'deleted_at' => get_date()]);
-    }
-
-    /**
-     *  阅读详情
-     * name: detail
-     * @param $id
-     * @return Notices
-     * date 2023/03/30 00:09
-     */
-    public static function detail($id)
-    {
-        return Notices::where('id', $id)->where('is_deleted', 0)->select('title', 'id', 'is_popup', 'content')->first();
-    }
-
-    /**
-     *  获取指定对象选择项
-     * name: objOption
-     * @param $type
-     * @param string $name
-     * @return array
-     * date 2023/03/30 10:23
-     */
-    public static function objOption($type, $name = ""): mixed
-    {
-        if ($type == 'user') {
-            if ($name) {
-                return  User::where("username", 'like', "%" . $name . "%")->without(['roles','jobs'])->select('id','username as name')->get();
-            }
-            return User::select('id','username as name')->without(['roles','jobs'])->get();
-        } else if ($type == "role") {
-            if ($name) {
-                return Roles::where("role_name", 'like', "%" . $name . "%")->select('id','role_name as name')->get();
-            }
-            return Roles::select('id','role_name as name')->get();
-        }
-        return [];
-    }
-
-    /**
-     *  一条获取弹窗信息
-     * name: getPopup
-     * @return Model|UserNotice|object|null
-     * date 2023/03/30 16:45
-     */
-    public static function getPopup()
-    {
-        $where = [
-            ['user_notice.is_deleted', '=', 0],
-            ['user_notice.user_id', '=',  Auth::guard(getGuardName())->id()],
-            ['notices.is_deleted', '=', 0],
-            ['notices.is_popup', '=', 1],
-            ['user_notice.is_read', '=', 0],
-        ];
-
-         $info =  UserNotice::leftJoin('notices', 'notices.id', "user_notice.notice_id")->where($where)->select('notices.id', 'notices.title', 'notices.content')
-             ->orderBy('notices.created_at', 'desc')->orderBy('sort', 'desc')->first();
-         if (empty($info)){
-             return  [];
-         }
-         return  $info;
-    }
-
-
-}

+ 0 - 10
modules/ContentManage/config/cpManage.php

@@ -1,10 +0,0 @@
-<?php
-
-return [
-    /**
-     * 同步cp订阅配置
-     */
-    'syncCpSubscribe' => [
-        'logLevel' => env('CONTENT_MANAGE_CP_SYNC_SUBSCRIBE_LOG_LEVEL', 'info')
-    ]
-];

+ 0 - 4
modules/ContentManage/config/ok.php

@@ -1,4 +0,0 @@
-<?php
-return [
-    'is_ok' => true
-];

+ 0 - 4
modules/ContentManage/config/oks.php

@@ -1,4 +0,0 @@
-<?php
-return [
-    'is_ok' => true
-];

+ 0 - 15
modules/ContentManage/config/zhushuyunpublicapi.php

@@ -1,15 +0,0 @@
-<?php
-/**
- *  追书云public配置
- * @file:zhushuyunpublicapi.php
- * @Created by gnitif
- * @Date: 2023/3/21
- * @Time: 20:43
- */
-
-return [
-    #public接口域名
-    'public_domain' => env('PUBLIC_DOMAIN','https://pubapi.zhuishuyun.com'),
-    #加密秘钥
-    'external_private_key' =>   env('EXTERNAL_PRIVATE_KEY', 'ZSY_2021!KEY'),
-];

+ 0 - 142
modules/ContentManage/routes/route.php

@@ -1,142 +0,0 @@
-<?php
-
-use Illuminate\Support\Facades\Route;
-use Modules\ContentManage\Http\Controllers\BookController;
-use Modules\ContentManage\Http\Controllers\CpListController;
-use Modules\ContentManage\Http\Controllers\OutputController;
-use Modules\ContentManage\Http\Controllers\CpSubscribeStatisticDataController;
-use Modules\ContentManage\Http\Controllers\System\NoticesController;
-use Modules\ContentManage\Http\Controllers\System\NoticeTypesController;
-use Modules\ContentManage\Http\Controllers\TestController;
-
-Route::prefix('contentManage')->group(function () {
-    Route::prefix('cp')->group(function () {
-        Route::apiResource('manage/cp_list', CpListController::class);
-        // cp选择项
-        Route::any('options',[CpListController::class,"selectOptions"]);
-        /**
-         * cp结算数据中心
-         */
-        Route::get('subscribeStatisticData/list', [CpSubscribeStatisticDataController::class, 'list']);
-        /**
-         * cp结算数据中心统计数据
-         */
-        Route::get('subscribeStatisticData/listStatistic', [CpSubscribeStatisticDataController::class, 'listStatistic']);
-        /**
-         * cp结算
-         */
-        Route::get('subscribeStatisticData/monthList', [CpSubscribeStatisticDataController::class, 'monthList']);
-        /**
-         * 导出某个cp某个月的各个书籍的应结算金额
-         */
-        Route::get('subscribeStatisticData/listCpMonthFinalAmount', [CpSubscribeStatisticDataController::class, 'listCpMonthFinalAmount']);
-        /**
-         * 修改cp结算状态
-         */
-        Route::post('subscribeStatisticData/saveFinalState',
-            [CpSubscribeStatisticDataController::class, 'saveFinalState']);
-
-        Route::post('test/test1', [TestController::class, 'test1'])->withoutMiddleware(config('catch.route.middlewares'));
-
-        Route::get('cpCollection',[CpListController::class,"cpCollection"])->withoutMiddleware(config('catch.route.middlewares'));
-	});
-
-    // 书籍管理
-    Route::prefix('book')->group(function (){
-        // 书籍列表
-        Route::any('list',[BookController::class, 'list']);
-        // 结算方式选项
-        Route::any('settlementypes',[BookController::class, 'settlementTypes']);
-        // 保存书籍版权时间,结算方式,单本和批量
-        Route::post('edit_author',[BookController::class, 'editAuthorByBid']);
-        // 书籍编辑时获取书籍信息
-        Route::get('edit_author/{bid}',[BookController::class, 'bookInfo']);
-         // 获取书籍分库权限信息
-        Route::get('distribute/{bid}',[BookController::class, 'distributeInfo']);
-         // 获取书籍分库权限信息提交
-        Route::post('distribute/{bid}',[BookController::class, 'distributeSubmit']);
-         // 导出书籍
-        Route::get('export/{bid}',[BookController::class, 'export'])->withoutMiddleware(config('catch.route.middlewares'));
-        //导入书籍
-        Route::post('import',[BookController::class, 'import'])->withoutMiddleware(config('catch.route.middlewares'));;
-        Route::post('createBook',[BookController::class, 'createBook']);
-        //分类列表
-        Route::get('categorylist',[BookController::class, 'categoryList'])->withoutMiddleware(config('catch.route.middlewares'));
-
-    });
-    // 通知管理
-    Route::prefix('notices')->group(function(){
-        // 通知分类
-        Route::prefix('types')->group(function (){
-            // 添加通知分类
-            Route::post('add',[NoticeTypesController::class, 'add']);
-            // 通知分类列表
-            Route::any('list',[NoticeTypesController::class, 'list']);
-            //  删除通知分类
-            Route::post('del/{id}',[NoticeTypesController::class, 'delete']);
-        });
-        // 通知管理
-        Route::prefix('notice')->group(function(){
-            // 添加通知
-            Route::post('add',[NoticesController::class, 'addNotice']);
-            // 通知列表
-            Route::any('list',[NoticesController::class, 'list']);
-            //  删除通知
-            Route::post('del/{id}',[NoticesController::class, 'delete']);
-            //   修改通知状态
-            Route::post('enable/{id}',[NoticesController::class, 'enable']);
-            // 获取编辑信息
-            Route::get('edit/{id}',[NoticesController::class, 'info']);
-            // 保存编辑
-            Route::post('edit/{id}',[NoticesController::class, 'edit']);
-
-            // 不判断权限
-            Route::prefix("")->group(function (){
-                // 通知对象接口
-                Route::any('obj_option',[NoticesController::class, 'objOption'])->withoutMiddleware(config('catch.route.middlewares'));
-                // 我的通知
-                Route::any('mine',[NoticesController::class, 'myNotices'])->withoutMiddleware(config('catch.route.middlewares'));
-                //  已读
-                Route::get('read/{id}',[NoticesController::class, 'setRead'])->withoutMiddleware(config('catch.route.middlewares'));
-                // 用户删除
-                Route::get('user_del/{id}',[NoticesController::class, 'userDel'])->withoutMiddleware(config('catch.route.middlewares'));
-                // 查看通知信息
-                Route::any('detail/{id}',[NoticesController::class, 'detail'])->withoutMiddleware(config('catch.route.middlewares'));
-                // 获取首页弹窗消息
-                Route::any('popup',[NoticesController::class, 'getPopup'])->withoutMiddleware(config('catch.route.middlewares'));
-
-            });
-
-        });
-
-    });
-
-});
-
-
-/**
- * 书籍输出
- */
-Route::prefix('output')->group(function () {
-
-    //书籍列表
-    Route::get('booklist',[OutputController::class,'bookList'])
-    ->withoutMiddleware(config('catch.route.middlewares'));
-
-    //书籍详情
-    Route::get('bookdetail/{bid}',[OutputController::class,'bookDetail'])
-    ->withoutMiddleware(config('catch.route.middlewares'));
-
-    //章节列表
-    Route::get('chapterlist/{bid}',[OutputController::class,'chapterList'])
-    ->withoutMiddleware(config('catch.route.middlewares'));
-    //章节内容
-    Route::get('chaptercontent/{bid}/chapterid/{chapter_id}',[OutputController::class,'chapterContent'])
-    ->withoutMiddleware(config('catch.route.middlewares'));
-
-    //分类
-    Route::get('listCategories',[OutputController::class,'listCategories'])
-    ->withoutMiddleware(config('catch.route.middlewares'));
-
-});
-

+ 14 - 0
modules/CpManage/Http/Controllers/CpSubscribeStatisticDataController.php

@@ -45,6 +45,14 @@ class CpSubscribeStatisticDataController extends CatchController
             'buyout' => '买断', 'bottomline' => '保底', 'share' => '分成', 'zhuishuyun' => '追书云计算'
         ];
 
+        $sql = DB::table('cp_subscribe_statistic_data')
+            ->where('id', -1);
+        if($isExport) {
+            return $sql->get();
+        } else {
+            return $sql->paginate($perPage);
+        }
+
         $cpName = $this->getUserCpName() ?? $cpName;
 
 
@@ -112,6 +120,12 @@ class CpSubscribeStatisticDataController extends CatchController
         $endDate = $request->input('end_date');
         $bookSettlementType = $request->input('book_settlement_type');
 
+        return [
+            'yesterday_total_coins' => 0,
+            'yesterday_available_amount' => 0,
+            'yesterday_final_amount' => 0
+        ];
+
         $cpName = $this->getUserCpName() ?? $cpName;
 
         $res = DB::table('cp_subscribe_statistic_data as statistic')