zz 6 lat temu
rodzic
commit
71016b6cd2
28 zmienionych plików z 13 dodań i 4339 usunięć
  1. 0 115
      app/Http/Controllers/WapAlipay/BaseController.php
  2. 0 69
      app/Http/Controllers/WapAlipay/Book/BookCategoryController.php
  3. 0 667
      app/Http/Controllers/WapAlipay/Book/BookController.php
  4. 0 733
      app/Http/Controllers/WapAlipay/Book/ChapterController.php
  5. 0 46
      app/Http/Controllers/WapAlipay/Book/Transformers/BookTransformer.php
  6. 0 24
      app/Http/Controllers/WapAlipay/Book/Transformers/ChapterListTransformer.php
  7. 0 28
      app/Http/Controllers/WapAlipay/Book/Transformers/ChapterTransformer.php
  8. 0 86
      app/Http/Controllers/WapAlipay/Oauth/UsersController.php
  9. 0 323
      app/Http/Controllers/WapAlipay/Order/OrdersController.php
  10. 0 17
      app/Http/Controllers/WapAlipay/Order/Transformers/BookOrderTransformer.php
  11. 0 19
      app/Http/Controllers/WapAlipay/Order/Transformers/ChapterOrderTransformer.php
  12. 0 16
      app/Http/Controllers/WapAlipay/Order/Transformers/ChargeListTransformer.php
  13. 0 19
      app/Http/Controllers/WapAlipay/Order/Transformers/OrderTransformer.php
  14. 0 44
      app/Http/Controllers/WapAlipay/Other/ErrorCollectionController.php
  15. 0 1090
      app/Http/Controllers/WapAlipay/Pay/OrdersController.php
  16. 0 231
      app/Http/Controllers/WapAlipay/User/ReadRecordController.php
  17. 0 20
      app/Http/Controllers/WapAlipay/User/Transformers/ReadRecordTransformer.php
  18. 0 13
      app/Http/Controllers/WapAlipay/User/Transformers/SignRecordTransformer.php
  19. 0 24
      app/Http/Controllers/WapAlipay/User/Transformers/UserShelfBooksTransformer.php
  20. 0 153
      app/Http/Controllers/WapAlipay/User/UserController.php
  21. 0 217
      app/Http/Controllers/WapAlipay/User/UserShelfBooksController.php
  22. 0 43
      app/Http/Controllers/WapAlipay/User/UserbehaviorController.php
  23. 0 123
      app/Http/Controllers/WapAlipay/Web/RedirectController.php
  24. 0 129
      app/Http/Controllers/WapAlipay/Web/WelcomeController.php
  25. 0 15
      app/Http/Controllers/WapAlipay/apidoc.json
  26. 0 4
      app/Http/Controllers/WapAlipay/header.md
  27. 3 28
      app/Modules/User/Models/UserSign.php
  28. 10 43
      app/Modules/User/Services/UserSignService.php

+ 0 - 115
app/Http/Controllers/WapAlipay/BaseController.php

@@ -1,115 +0,0 @@
-<?php
-
-namespace App\Http\Controllers\WapAlipay;
-use Illuminate\Routing\Controller;
-
-use Illuminate\Http\Request;
-use Cookie;
-use App\Modules\User\Services\UserService;
-class BaseController extends Controller
-{
-    /**
-     * 请求接口的地址前缀
-     * @var mixed
-     */
-    protected $_url_prefix;
-
-
-    /**
-     * 用户id
-     * @var int
-     */
-    protected $uid;
-
-    /**
-     * 公众号接口签名密钥
-     * @var string
-     */
-    protected $secret_key = 'zhuishuyun#_2017';
-
-    /**
-     * 渠道id
-     * @var
-     */
-    protected $distribution_channel_id;
-
-    function __construct(Request $request)
-    {
-        $domain = _domain();
-        $this->distribution_channel_id = str_replace('site','',explode('.',$domain)[0]);
-        if(!is_numeric($this->distribution_channel_id)){
-            $this->distribution_channel_id = decodeDistributionChannelId($this->distribution_channel_id);
-        }
-        $this->_url_prefix = env('PUBLIC_BASE_API');
-        $user_cookie = Cookie::get(env('COOKIE_AUTH_WEB_WECHAT'));
-        $this->uid = $user_cookie ? decrypt($user_cookie) : null;
-        //$this->uid = 13;
-    }
-
-    protected function userInfo($uid){
-        $user = UserService::getById($uid);
-        return  $user;
-    }
-
-    protected function checkUid(){
-        if(!$this->uid) return false;
-        return true;
-    }
-
-    public function __get($name)
-    {
-        if($name == '_user_info'){
-            return $this->userInfo($this->uid);
-        }
-        return null;
-     }
-
-    protected function joinUrl($url)
-    {
-        if (stripos($url, '/') === 0) {
-            $url = substr($url, 1);
-        }
-        return $this->_url_prefix . $url;
-    }
-
-
-    /**
-     * 公众号签名@华灯初上
-     * @param $params
-     * @return string
-     */
-    protected function getSign($params)
-    {
-        $url = $this->arr_to_url($params, false);
-        $url = $url . '&key=' . $this->secret_key;
-
-        $sign = md5($url);
-        return $sign;
-    }
-
-    /**
-     * 公众号签名@华灯初上
-     * @param $array
-     * @param bool $has_sign
-     * @return string
-     */
-    protected function arr_to_url($array, $has_sign = false)
-    {
-        ksort($array);
-        reset($array);
-        $arg = "";
-        while (list ($name, $val) = each($array)) {
-            if ($name == 'sign' && !$has_sign) continue;
-            if (strpos($name, "_") === 0)
-                continue;
-            if (is_array($val))
-                $val = join(',', $val);
-            if ($val === "")
-                continue;
-            $arg .= $name . "=" . $val . "&";
-        }
-        $arg = substr($arg, 0, count($arg) - 2);
-
-        return $arg;
-    }
-}

+ 0 - 69
app/Http/Controllers/WapAlipay/Book/BookCategoryController.php

@@ -1,69 +0,0 @@
-<?php
-
-namespace App\Http\Controllers\WapAlipay\Book;
-
-use Illuminate\Http\Request;
-use App\Http\Controllers\Controller;
-use App\Modules\Book\Services\BookCategoryService;
-class BookCategoryController extends Controller
-{
-    /**
-     * @apiDefine Book 图书
-     */
-
-    /**
-     * @apiVersion 1.0.0
-     * @apiDescription 获取分类
-     * @api {get}
-     * 获取分类
-     * @apiGroup Book
-     * @apiName getCategory
-     * @apiSuccess {int}         code 状态码
-     * @apiSuccess {String}      msg  信息
-     * @apiSuccess {object}      data 结果集
-     * @apiSuccessExample {json} Success-Response:
-     *     HTTP/1.1 200 OK
-     *     {
-     *       code: 0,
-     *       msg: "",
-     *       data:  [
-     *                   {
-     *                   id: 1,
-     *                   name: "男频",
-     *                   children: [
-     *                           {
-     *                               id: 7,
-     *                               name: "灵异鬼怪"
-     *                           },
-     *                           {
-     *                               id: 8,
-     *                               name: "历史穿越"
-     *                           },
-     *                           {
-     *                               id: 30,
-     *                               name: "青春爱情"
-     *                           }
-     *                       ]
-     *                   },
-     *                   {
-     *                   id: 2,
-     *                   name: "女频",
-     *                   children: [
-     *                           {
-     *                               id: 26,
-     *                               name: "豪门总裁"
-     *                           },
-     *                           {
-     *                               id: 35,
-     *                               name: "民国爱情"
-     *                           }
-     *                       ]
-     *                   }
-     *               ]
-     *       }
-     */
-    public function getCategory(Request $request){
-        $res = BookCategoryService::getCategory(true);
-        return response()->success($res);
-    }
-}

Plik diff jest za duży
+ 0 - 667
app/Http/Controllers/WapAlipay/Book/BookController.php


+ 0 - 733
app/Http/Controllers/WapAlipay/Book/ChapterController.php

@@ -1,733 +0,0 @@
-<?php
-
-namespace App\Http\Controllers\Wap\Book;
-
-use App\Modules\Book\Services\BookService;
-use Illuminate\Http\Request;
-use App\Http\Controllers\Wap\BaseController;
-use Cookie;
-use Redis;
-use App\Modules\Book\Services\ChapterService;
-use App\Modules\User\Services\ReadRecordService;
-use App\Http\Controllers\Wap\Book\Transformers\ChapterTransformer;
-use App\Modules\Book\Services\BookConfigService;
-use App\Http\Controllers\Wap\Book\Transformers\ChapterListTransformer;
-use App\Modules\Subscribe\Services\BookOrderService;
-use App\Modules\Subscribe\Services\ChapterOrderService;
-use App\Modules\Subscribe\Services\YearOrderService;
-use App\Modules\OfficialAccount\Services\ForceSubscribeService;
-use App\Modules\Subscribe\Services\ChapterReminderService;
-use App\Modules\OfficialAccount\Services\OfficialAccountService;
-use Hashids;
-use GuzzleHttp\Client;
-use Log;
-use DB;
-use App\Modules\User\Services\UserSignService;
-use App\Modules\SendOrder\Services\SendOrderService;
-use App\Modules\User\Services\UserDeepReadTagService;
-use App\Modules\Book\Services\BookSubscribleChapterService;
-use App\Modules\Channel\Services\ChannelSubscribeSettingService;
-
-class ChapterController extends BaseController
-{
-
-    /**
-     * @apiDefine Chapter 章节
-     */
-
-    /**
-     * @apiVersion 1.0.0
-     * @apiDescription 章节列表不分页
-     * @api {get} books/{bid}/allcatalog 章节列表不分页
-     * @apiGroup Chapter
-     * @apiName getCatalog
-     * @apiSuccess {int}         code 状态码
-     * @apiSuccess {String}      msg  信息
-     * @apiSuccess {object}      data 结果集
-     * @apiSuccess {Array}       data.list 分页结果集
-     * @apiSuccess {Int}         data.list.bid   bid
-     * @apiSuccess {Int}         data.list.chapter_id   章节id
-     * @apiSuccess {String}      data.list.chapter_name   章节名称
-     * @apiSuccess {Int}         data.list.chapter_sequence   序号
-     * @apiSuccess {Int}         data.list.chapter_is_vip   是否vip
-     * @apiSuccess {Int}         data.list.chapter_size   章节大小
-     * @apiSuccess {Int}         data.list.prev_cid   上一章节id
-     * @apiSuccess {Int}         data.list.next_cid   下一章节
-     * @apiSuccess {String}      data.list.recent_update_at   更新时间
-     * @apiSuccess {String}      data.list.is_need_subscirbe   是否强制关注
-     * @apiSuccess {String}      data.list.is_show_price   是否显示价格
-     * @apiSuccess {String}      data.list.price   价格
-     * @apiSuccess {object}      data.meta   分页信息
-     * @apiSuccess {Int}         data.meta.total  总条数
-     * @apiSuccess {Int}         data.meta.per_page  每页条数
-     * @apiSuccess {Int}         data.meta.current_page 当前页
-     * @apiSuccess {Int}         data.meta.last_page  最后页
-     * @apiSuccess {String}      data.meta.next_page_url  下一页
-     * @apiSuccess {String}      data.meta.prev_page_url  上一页
-     * @apiSuccessExample {json} Success-Response:
-     *     HTTP/1.1 200 OK
-     *     {
-     *       code: 0,
-     *       msg: "",
-     *       data:
-     *            [
-     *             {
-     *               bid: 5,
-     *               chapter_id: 5,
-     *               chapter_name: "第1240章 不是我",
-     *               chapter_sequence: 1239,
-     *               chapter_is_vip: 1,
-     *               chapter_size: 2422,
-     *               prev_cid: 0,
-     *               next_cid: 0,
-     *               recent_update_at: 2017-11-20 15:01:56,
-     *               is_need_subscirbe: 1,
-     *            },
-     *             {
-     *               bid: 5,
-     *               chapter_id: 5,
-     *               chapter_name: "第1240章 不是我",
-     *               chapter_sequence: 1239,
-     *               chapter_is_vip: 1,
-     *               chapter_size: 2422,
-     *               prev_cid: 0,
-     *               next_cid: 0,
-     *               recent_update_at: 2017-11-20 15:01:56,
-     *               is_need_subscirbe: 1,
-     *            },
-     *          ]
-     *       }
-     */
-    public function getCatalog(Request $request, $t, $domain, $bid)
-    {
-        $bid = Hashids::decode($bid)[0];
-        $lists = ChapterService::getChapterLists($bid);
-        $book_info = BookConfigService::getBookById($bid);
-        if(!$book_info){
-            return response()->error('PARAM_ERROR');
-        }
-        $is_show_price = $this->showChapterPrice($bid,$book_info->charge_type);
-        foreach ($lists as $v) {
-            $v->is_show_price = $is_show_price;
-            $v->price = '';
-            if($is_show_price){
-                $v->price = $this->getPrice($book_info,$v);
-            }
-        }
-        return response()->collection(new ChapterListTransformer, $lists);
-    }
-
-    /**
-     * @apiVersion 1.0.0
-     * @apiDescription 章节列表分页
-     * @api {get} books/{bid}/catalog 章节列表分页
-     * @apiGroup Chapter
-     * @apiName getCatalogPerPage
-     * @apiParam   {Int}         page_size  分页大小(默认15)
-     * @apiParam   {Int}         page  页码(默认1)
-     * @apiSuccess {int}         code 状态码
-     * @apiSuccess {String}      msg  信息
-     * @apiSuccess {object}      data 结果集
-     * @apiSuccess {Array}       data.list 分页结果集
-     * @apiSuccess {Int}         data.list.bid   bid
-     * @apiSuccess {Int}         data.list.chapter_id   章节id
-     * @apiSuccess {String}      data.list.chapter_name   章节名称
-     * @apiSuccess {Int}         data.list.chapter_sequence   序号
-     * @apiSuccess {Int}         data.list.chapter_is_vip   是否vip
-     * @apiSuccess {Int}         data.list.chapter_size   章节大小
-     * @apiSuccess {Int}         data.list.prev_cid   上一章节id
-     * @apiSuccess {Int}         data.list.next_cid   下一章节
-     * @apiSuccess {String}      data.list.recent_update_at   更新时间
-     * @apiSuccess {String}      data.list.is_need_subscirbe   是否强制关注
-     * @apiSuccess {String}      data.list.is_show_price   是否显示价格
-     * @apiSuccess {String}      data.list.price   价格
-     * @apiSuccess {object}      data.meta   分页信息
-     * @apiSuccess {Int}         data.meta.total  总条数
-     * @apiSuccess {Int}         data.meta.per_page  每页条数
-     * @apiSuccess {Int}         data.meta.current_page 当前页
-     * @apiSuccess {Int}         data.meta.last_page  最后页
-     * @apiSuccess {String}      data.meta.next_page_url  下一页
-     * @apiSuccess {String}      data.meta.prev_page_url  上一页
-     * @apiSuccessExample {json} Success-Response:
-     *     HTTP/1.1 200 OK
-     *     {
-     *       code: 0,
-     *       msg: "",
-     *       data:
-     *            list:[
-     *             {
-     *               bid: 5,
-     *               chapter_id: 5,
-     *               chapter_name: "第1240章 不是我",
-     *               chapter_sequence: 1239,
-     *               chapter_is_vip: 1,
-     *               chapter_size: 2422,
-     *               prev_cid: 0,
-     *               next_cid: 0,
-     *               recent_update_at: 2017-11-20 15:01:56,
-     *               is_need_subscirbe: 1,
-     *            },
-     *             {
-     *               bid: 5,
-     *               chapter_id: 5,
-     *               chapter_name: "第1240章 不是我",
-     *               chapter_sequence: 1239,
-     *               chapter_is_vip: 1,
-     *               chapter_size: 2422,
-     *               prev_cid: 0,
-     *               next_cid: 0,
-     *               recent_update_at: 2017-11-20 15:01:56,
-     *               is_need_subscirbe: 1,
-     *            },
-     *          ]
-     *          meta:{
-     *              total: 1253,
-     *              per_page: 15,
-     *              current_page: 1,
-     *              last_page: 84,
-     *              next_page_url: "http://myapi.cn/api/books/1/chapter?page=2",
-     *              prev_page_url: ""
-     *         }
-     *       }
-     */
-    public function getCatalogPerPage(Request $request, $t, $domain, $bid)
-    {
-        $bid_array = Hashids::decode($bid);
-
-        if (isset($bid_array[0])) {
-            $bid = $bid_array[0];
-        } else {
-            return response()->error('PARAM_ERROR');
-        }
-        $book_info = BookConfigService::getBookById($bid);
-        if (!$book_info) {
-            return response()->error('PARAM_ERROR');
-        }
-        $page_size = $request->input('page_size', 15);
-
-        $res = ChapterService::getChapterListsPage($bid, $page_size);
-        $is_show_price = $this->showChapterPrice($bid,$book_info->charge_type);
-        foreach ($res as $v) {
-            $v->is_show_price = $is_show_price;
-            $v->price = '';
-            if($is_show_price){
-                $v->price = $this->getPrice($book_info,$v);
-            }
-        }
-        return response()->pagination(new ChapterListTransformer, $res);
-    }
-
-
-    /**
-     * @apiVersion 1.0.0
-     * @apiDescription 章节内容
-     * @api {get} books/{bid}/chapters/{chapter_id} 章节内容
-     * @apiGroup Chapter
-     * @apiName index
-     * @apiSuccess {int}         code 状态码
-     * @apiSuccess {String}      msg  信息
-     * @apiSuccess {object}      data 结果集
-     * @apiSuccess {Int}         data.chapter_id   章节id
-     * @apiSuccess {String}      data.chapter_name   章节名称
-     * @apiSuccess {Int}         data.chapter_sequence   序号
-     * @apiSuccess {Int}         data.chapter_is_vip   是否vip
-     * @apiSuccess {Int}         data.chapter_size   章节大小
-     * @apiSuccess {Int}         data.prev_cid   上一章节id
-     * @apiSuccess {Int}         data.next_cid   下一章节
-     * @apiSuccess {String}      data.recent_update_at   更新时间
-     * @apiSuccess {String}      data.chapter_content  章节内容
-     * @apiSuccess {Int}         data.is_need_subscirbe  是否强制关注(删除)
-     * @apiSuccess {Int}         data.is_show_subscribe_link  是否显示底部强关链接
-     * @apiSuccessExample {json} Success-Response:
-     *     HTTP/1.1 200 OK
-     *     {
-     *       code: 0,
-     *       msg: "",
-     *       data: {
-     *               chapter_id: 5,
-     *               chapter_name: "第1240章 不是我",
-     *               chapter_sequence: 1239,
-     *               chapter_is_vip: 1,
-     *               chapter_size: 2422,
-     *               prev_cid: 0,
-     *               next_cid: 0,
-     *               recent_update_at: 2017-11-20 15:01:56,
-     *               chapter_content: "叶妩被司行霈的阴阳怪气一吓,思路偏得太远了。 她张口结舌,忘记了自己要说什么。",
-     *            }
-     *       }
-     */
-    public function index(Request $request, $t, $domain, $bid, $cid)
-    {
-        if (!$this->checkUid()) {
-            return response()->error('WAP_NOT_LOGIN');
-        }
-        $oldbid = $bid;
-        $bid = Hashids::decode($bid)[0];
-        //获取图书信息
-        $book_info = BookConfigService::getBookById($bid);
-
-
-        if (empty($book_info)) return response()->error('WAP_SYS_ERROR');
-
-        //图书域名,book_configs表的promotion_domain 要跟当前的主机名匹配
-        if ($this->isVisitDomainEqualBookDomain($book_info->promotion_domain)) {
-            $send_order_id = Cookie::get('send_order_id') ? Cookie::get('send_order_id') : 0;
-            //promotion_domain可以是多个,以逗号隔开
-            $domain_head = explode('.', _domain());
-            $book_domain = explode(',', $book_info->promotion_domain);
-            $from_type = Cookie::get('from') ? Cookie::get('from') : 'main';
-            $url = 'https://' . $domain_head[0] . '.' . $book_domain[0] . '/reader?bid=' . $oldbid . '&cid=' . $cid . '&send_order_id=' . $send_order_id . '&fromtype=' . $from_type;
-            return response()->error('WAP_DOMAIN_NOT_MATCH', [
-                'url' => $url
-            ]);
-        }
-
-        //下架图书不能看
-        if ($book_info->is_on_shelf == 0 || $book_info->is_on_shelf == 3) {
-            return response()->error('WAP_OFF_SHELF');
-        }
-        //屏蔽一本书
-        if ($bid == 1042 && $this->distribution_channel_id == 123) {
-            return response()->error('WAP_OFF_SHELF');
-        }
-
-        if ($book_info->is_on_shelf == 4) {
-            //版权到期,有阅读记录还可以继续阅读,订购
-            if (!ReadRecordService::getRecordByUidBid($this->uid, $bid)) {
-                return response()->error('WAP_OFF_SHELF');
-            }
-            //版权到期 只可以阅读订购过的章节
-            /*if (!$this->getOrderRecord($bid, $cid)) {
-                return response()->error('WAP_OFF_SHELF');
-            }*/
-        }
-        //获取章节信息
-        $chapter = ChapterService::getChapterNameById($cid, $bid);
-        if (!$chapter) {
-            return response()->error('WAP_SYS_ERROR');
-        }
-
-        //阅读记录
-        ReadRecordService::addReadRecord(['uid' => $this->uid, 'bid' => $bid, 'book_name' => $book_info->book_name,
-            'cid' => $cid, 'chapter_name' => $chapter->name]);
-
-        if ( $chapter->is_vip == 0) {
-            $content = $this->getChapter($bid, $cid, $chapter, 0, 1);
-            $content->is_had_subscribe = 0;
-            return response()->item(new ChapterTransformer, $content);
-        }
-        //已经付费
-        if ($this->getOrderRecord($bid, $cid)) {
-            $content = $this->getChapter($bid, $cid, $chapter, 0, 0);
-            $content->is_had_subscribe = 0;
-            return response()->item(new ChapterTransformer, $content);
-        }
-        //以上都是不用付费的情况******************************************************
-        //未付费
-        $user_info = $this->_user_info;
-        //获取价格
-        $fee = $this->getPrice($book_info, $chapter);
-        //返回的价格信息
-        $data = [
-            'book_id' => $oldbid,
-            'book_name' => $book_info->book_name,
-            'chapter_name' => $chapter->name,
-            'chapter_id' => $cid,
-            'pay_type' => $book_info->charge_type,
-            'fee' => $fee,
-            'user_balance' => $user_info->balance,
-            'product_id' => $book_info->product_id,
-            'uid' => $this->uid,
-            'distribution_channel_id' => $this->distribution_channel_id,
-            'is_discount' => 0,
-            'discount_fee' => '',
-            'discount' => ''
-
-        ];
-        //余额不足 弹窗提醒
-        if ($user_info['balance'] < $fee) {
-            if ($book_info->charge_type == 'BOOK') {
-                return response()->error('WAP_BOOK_BALANCE_PAY', $data);
-                //return response()->error('WAP_BOOK_SECOND_BALANCE_PAY',$data);
-            } else if ($book_info->charge_type == 'CHAPTER') {
-                //return response()->error('WAP_CHAPTER_INSUFFICIENT_BALANCE',$data);
-                return response()->error('WAP_CHAPTER_SECOND_BALANCE_PAY', $data);
-            } else {
-                return response()->error('WAP_SYS_ERROR');
-            }
-        }
-        //余额充足 单本弹窗提醒,章节直接扣费
-        if ($this->isOrderRemind($bid) && $book_info->charge_type == 'BOOK') {
-            return response()->error('WAP_BOOK_BUY', $data);
-        }
-        //付费 不提醒
-        if ($this->balancePay($book_info, $chapter, 0)) {
-            $content = $this->getChapter($bid, $cid, $chapter, 0, 1);
-            $content->is_had_subscribe = 1;
-            return response()->item(new ChapterTransformer, $content);
-        } else {
-            //不需要提醒
-            if ($book_info->charge_type == 'BOOK') {
-                return response()->error('WAP_BOOK_SECOND_BALANCE_PAY', $data);
-            } elseif ($book_info->charge_type == 'CHAPTER') {
-                return response()->error('WAP_CHAPTER_SECOND_BALANCE_PAY', $data);
-            } else {
-                return response()->error('WAP_SYS_ERROR');
-            }
-        }
-    }
-
-
-    /**
-     * @apiVersion 1.0.0
-     * @apiDescription 余额支付
-     * @api {get} books/{bid}/balance/chapterOrders/{cid} 余额支付
-     * @apiGroup Chapter
-     * @apiName pay
-     * @apiParam   (Int)         remind 提醒
-     * @apiSuccess {int}         code 状态码
-     * @apiSuccess {String}      msg  信息
-     * @apiSuccess {object}      data 结果集
-     * @apiSuccess {Int}         data.chapter_id   章节id
-     * @apiSuccess {String}      data.chapter_name   章节名称
-     * @apiSuccess {Int}         data.chapter_sequence   序号
-     * @apiSuccess {Int}         data.chapter_is_vip   是否vip
-     * @apiSuccess {Int}         data.chapter_size   章节大小
-     * @apiSuccess {Int}         data.prev_cid   上一章节id
-     * @apiSuccess {Int}         data.next_cid   下一章节
-     * @apiSuccess {String}      data.recent_update_at   更新时间
-     * @apiSuccess {String}      data.chapter_content  章节内容
-     * @apiSuccess {Int}         data.is_need_subscirbe  是否强制关注(删除)
-     * @apiSuccessExample {json} Success-Response:
-     *     HTTP/1.1 200 OK
-     *     {
-     *       code: 0,
-     *       msg: "",
-     *       data: {
-     *               chapter_id: 5,
-     *               chapter_name: "第1240章 不是我",
-     *               chapter_sequence: 1239,
-     *               chapter_is_vip: 1,
-     *               chapter_size: 2422,
-     *               prev_cid: 0,
-     *               next_cid: 0,
-     *               recent_update_at: 2017-11-20 15:01:56,
-     *               chapter_content: "叶妩被司行霈的阴阳怪气一吓,思路偏得太远了。 她张口结舌,忘记了自己要说什么。",
-     *            }
-     *       }
-     */
-    public function pay(Request $request, $t, $domain, $bid, $cid)
-    {
-
-        if (!$this->checkUid()) {
-            return response()->error('NOT_LOGIN');
-        }
-        $remind = (int)$request->input('remind');
-        $oldbid = $bid;
-        $bid = Hashids::decode($bid)[0];
-        $book_info = BookConfigService::getBookById($bid);;
-        if (empty($book_info)) response()->error('WAP_SYS_ERROR');
-
-        if ($book_info->is_on_shelf == 0 || $book_info->is_on_shelf == 3) {
-            if (!$this->isBookOrdered($bid)) {
-                response()->error('WAP_OFF_SHELF');
-            }
-        }
-        //获取章节
-        $chapter = ChapterService::getChapterNameById($cid, $bid);
-        if (!$chapter) {
-            return response()->error('WAP_SYS_ERROR');
-        }
-
-
-        if ($this->balancePay($book_info, $chapter, $remind)) {
-            ReadRecordService::addReadRecord(['uid' => $this->uid, 'bid' => $bid, 'book_name' => $book_info->book_name,
-                'cid' => $cid, 'chapter_name' => $chapter->name]);
-            $content = $this->getChapter($bid, $cid, $chapter, 0, 1);
-            $content->is_had_subscribe = 0;
-            return response()->item(new ChapterTransformer, $content);
-        } else {
-            $fee = $this->getPrice($book_info, $chapter);
-            $data = [
-                'book_id' => $oldbid,
-                'book_name' => $book_info->book_name,
-                'chapter_name' => $chapter->name,
-                'chapter_id' => $cid,
-                'pay_type' => $book_info->charge_type,
-                'fee' => $fee,
-                'user_balance' => $this->_user_info['balance'],
-                'product_id' => $book_info->product_id,
-                'uid' => $this->uid,
-                'distribution_channel_id' => $this->distribution_channel_id,
-                'is_discount' => 0,
-                'discount_fee' => '',
-                'discount' => ''
-            ];
-            //不需要提醒
-            if ($book_info->charge_type == 'BOOK') {
-                return response()->error('WAP_BOOK_SECOND_BALANCE_PAY', $data);
-            } elseif ($book_info->charge_type == 'CHAPTER') {
-                return response()->error('WAP_CHAPTER_SECOND_BALANCE_PAY', $data);
-            } else {
-                return response()->error('WAP_SYS_ERROR');
-            }
-        }
-    }
-
-
-    /**
-     * 余额支付
-     * @param $book_info
-     * @param $chapter_id
-     * @param $chapter_size
-     * @return bool
-     */
-    protected function balancePay($book_info, $chapter, $is_remind)
-    {
-        $fee = $this->getPrice($book_info, $chapter);
-        if ($this->_user_info->is_new == 1) {
-            //$fee = ceil($fee*0.3);
-        }
-        if ((int)$this->_user_info['balance'] >= $fee) {
-            if ($this->bookOrderOrChapterOrder($book_info, $chapter->id, $fee, $chapter->name, $is_remind)) {
-                try {
-                    $day = date('Y--m-d');
-                    Redis::hincrby('wap:chapterandbookorder:bid:' . $book_info->bid, $day, $fee);
-                } catch (\Exception $e) {
-
-                }
-                return true;
-            }
-            return false;
-        } else {
-            return false;
-        }
-
-    }
-
-
-    /**
-     * 获取章节内容
-     * @param $bid
-     * @param $cid
-     * @return bool|mixed
-     */
-    protected function getChapter($bid, $cid, $chapter, $is_show_subscribe_link = 0, $is_subscribe = 0)
-    {
-        //$this->readRecordOther($chapter);
-        $chapter_content = ChapterService::getChapter($bid, $cid);
-        if (!$chapter_content) return false;
-        $chapter->content = str_replace($chapter_content->name, '', $chapter_content->content);
-
-        $sign_status = $this->userSign($this->uid);
-        $chapter->sign_status = $sign_status ? 1 : 0;
-        $chapter->sign_reard = $sign_status;
-
-        $chapter->is_show_subscribe_link = $is_show_subscribe_link;
-        return $chapter;
-    }
-
-    /**
-     * 签到
-     * @param $uid
-     * @return int
-     */
-    protected function userSign($uid)
-    {
-
-        if ($this->distribution_channel_id != 5) {
-            //return 0;
-        }
-
-        $day = date('Y-m-d');
-        $sign_stat = UserSignService::isSigni($uid, $day);
-        if (!$sign_stat) {
-            return 0;
-        }
-        if (UserSignService::sign($uid, $day, $sign_stat)) {
-            $sign_key = 'leyuee:wap:usersigni';
-            Redis::hset($sign_key, $uid, $sign_stat);
-            return $sign_stat;
-        }
-        return 0;
-
-    }
-
-    /**
-     * 添加订购记录
-     * @param $book_info
-     * @param $chapter_id
-     * @param $fee
-     * @return bool
-     */
-    protected function bookOrderOrChapterOrder($book_info, $chapter_id, $fee, $chapter_name, $is_remind)
-    {
-
-        if ($book_info['charge_type'] == 'BOOK') {
-            $data = [
-                'uid' => $this->uid,
-                'fee' => $fee,
-                'u' => Cookie::get('send_order_id'),
-                'distribution_channel_id' => $this->distribution_channel_id,
-                'bid' => $book_info->bid,
-                'book_name' => $book_info->book_name,
-                'send_order_id' => Cookie::get('send_order_id') ? Cookie::get('send_order_id') : 0,
-            ];
-            return BookOrderService::addOrderRecodeAndDecrUserBalance($data, $this->uid);
-        } else {
-            $data = [
-                'uid' => $this->uid,
-                'fee' => $fee,
-                'cid' => $chapter_id,
-                'bid' => $book_info->bid,
-                'distribution_channel_id' => $this->distribution_channel_id,
-                'book_name' => $book_info->book_name,
-                'chapter_name' => $chapter_name,
-                'send_order_id' => Cookie::get('send_order_id') ? Cookie::get('send_order_id') : 0,
-                'is_remind' => $is_remind
-            ];
-            //print_r($data);
-            if ($is_remind) {
-                $this->addOrderRemind($book_info->bid);
-            }
-            return ChapterOrderService::addOrderAndDecrUserBalance($data, $this->uid);
-        }
-    }
-
-
-    protected function addOrderRemind($bid)
-    {
-        if (ChapterReminderService::checkIsNoReminder($this->uid, $bid)) {
-            return true;
-        } else {
-            ChapterReminderService::add($this->uid, $bid);
-            return true;
-        }
-    }
-
-    /**
-     * 是否订购提醒
-     * @param $chapter_id
-     * @return bool
-     */
-    protected function isOrderRemind($bid)
-    {
-        $is_no_reminder = ChapterReminderService::checkIsNoReminder($this->uid, $bid) ? 1 : 0;
-        return $is_no_reminder == 0;
-    }
-
-
-
-    /**
-     * 获取订购记录
-     * @param $book_info
-     * @param $chapter_id
-     * @return bool
-     */
-    protected function getOrderRecord($bid, $chapter_id)
-    {
-        //包年记录
-        $uid = $this->uid;
-        $res = YearOrderService::getRecord($uid);
-        if ($res) return true;
-        $res = null;
-
-        //单本订购记录
-        $res = BookOrderService::getRecordByuidBid($uid, $bid);
-        if ($res) return true;
-        $res = null;
-
-        //章节订购记录
-        $chapterOrder = new ChapterOrderService();
-
-        if ($chapterOrder->checkIsOrdered($uid, $bid, $chapter_id)) return true;
-
-        return false;
-    }
-
-
-    /**
-     * 计算价格
-     * @param $book_info
-     * @param $chapter_size
-     * @return float
-     */
-    protected function getPrice($book_info, $chapter)
-    {
-        if ($book_info->charge_type == 'BOOK') {
-            $fee = $book_info->price * 100;
-        } else {
-            //$fee = ceil($chapter->size/100);
-            //$channel_fee = BookService::getChapterPrice()
-            $channel_fee = BookService::getChapterPrice($this->distribution_channel_id);
-            if ($channel_fee) {
-                $price_rate = $channel_fee / 100;
-            } else {
-                //$price_rate = 0.012;
-                $price_rate = env('DEFAULT_CHAPTER_PRICE', 0.015);
-            }
-            //Log::info($price_rate);
-            $fee = ceil($chapter->size * $price_rate);
-        }
-        //首个计费章节书币价格以35书币为基准,低于35提升至35,原价高于35书币,维持原价
-        if (isset($chapter->sequence) && isset($book_info->vip_seq)) {
-            if ($chapter->sequence == $book_info->vip_seq) {
-                if ($fee < 35) {
-                    $fee = 35;
-                }
-            }
-        }
-        return $fee;
-    }
-
-
-    /**
-     * 判断访问的域名和数据库指定的域名是否一致,一致返回false ,不一致 true
-     * @param $book_domain
-     * @return bool
-     */
-    protected function isVisitDomainEqualBookDomain($book_domain)
-    {
-        return stripos(_domain(), $book_domain) === false;
-    }
-
-
-
-    protected function isBookOrdered($bid)
-    {
-
-        $chapter_order = ChapterOrderService::checkBookIsOrdered($this->uid, $bid);
-        if ($chapter_order) return true;
-
-        $res = BookOrderService::getRecordByuidBid($this->uid, $bid);
-        if ($res) return true;
-        return false;
-    }
-
-    private function showChapterPrice($bid, $charge_type)
-    {
-        if ($charge_type == 'BOOK') {
-            return false;
-        }
-        $show_chapter_price_bid = env('SHOW_CHAPTER_PRICE_BID', 'all');
-        if ($show_chapter_price_bid != 'all') {
-            $show_chapter_price_bid_array = explode(',', $show_chapter_price_bid);
-            if (!in_array($bid, $show_chapter_price_bid_array)) {
-                return false;
-            }
-        }
-        $show_chapter_price_channel = env('SHOW_CHAPTER_PRICE_CHANNEL', '');
-        if (!$show_chapter_price_channel) {
-            return false;
-        }
-
-        if ($show_chapter_price_channel == 'all') {
-            return true;
-        }
-        $show_chapter_price_channel_array = explode(',', $show_chapter_price_channel);
-        if (in_array($this->distribution_channel_id, $show_chapter_price_channel_array)) {
-            return true;
-        }
-        return false;
-    }
-}

+ 0 - 46
app/Http/Controllers/WapAlipay/Book/Transformers/BookTransformer.php

@@ -1,46 +0,0 @@
-<?php
-/**
- * Created by PhpStorm.
- * Date: 2017/3/31
- * Time: 14:02
- */
-
-namespace App\Http\Controllers\WapAlipay\Book\Transformers;
-use Hashids;
-class BookTransformer
-{
-    public function transform($book){
-        return [
-            'book_id'=>Hashids::encode($book->bid),
-            //'book_id_no_hash'=>$book->bid,
-            'book_name'=>$book->book_name,
-            'book_summary'=>$book->intro,
-            'book_author'=>$book->author,
-            'cover_url'=>$book->cover,
-            'book_word_count'=>$book->size,
-            'book_chapter_total'=>$book->chapter_count,
-            'book_category_id'=>$book->category_id,
-            'book_category'=>$book->category_name,
-            'book_end_status'=>$book->status,
-            'book_published_time'=>is_null($book->updated_at)?'':$book->updated_at,
-            'copyright'=>is_null($book->copyright)? '':$book->copyright,
-            'charge_type'=>is_null($book->charge_type)?'':$book->charge_type,
-            'force_subscribe_chapter_id'=>$book->force_subscribe_chapter_seq,
-            'update_time'=>$book->updated_at,
-            'is_on_shelf'=>$book->is_on_shelf,
-            'book_price'=>is_null($book->price)?0:$book->price,
-            'keyword'=>$book->keyword,
-            'recommend_index'=> $book->recommend_index,
-            'is_show_index_content'=>$book->is_show_index_content,
-            'click_count'=>$book->click_count,
-            'product_id'=>$book->product_id,
-            'sex_preference'=>$book->channel_name,
-            'last_cid'=>$book->last_cid,
-            'last_chapter'=>$book->last_chapter,
-            'first_cid'=>$book->first_cid,
-            'is_on_user_shelf'=>$book->is_on_user_shelf,
-            'last_chapter_is_vip'=>$book->last_chapter_is_vip,
-            'last_update_time'=>isset($book->last_update_time)?$book->last_update_time:''
-        ];
-    }
-}

+ 0 - 24
app/Http/Controllers/WapAlipay/Book/Transformers/ChapterListTransformer.php

@@ -1,24 +0,0 @@
-<?php
-
-namespace App\Http\Controllers\WapAlipay\Book\Transformers;
-use Hashids;
-class ChapterListTransformer
-{
-
-    public function transform($chapter){
-        return [
-            'bid'       =>  Hashids::encode($chapter->bid),
-            //'bid_no_hash'       =>  ($chapter->bid),
-            'chapter_id'       =>  $chapter->id,
-            'chapter_name'   =>  $chapter->name,
-            'chapter_sequence'   =>  $chapter->sequence,
-            'chapter_is_vip'   =>  $chapter->is_vip,
-            'chapter_size'   =>  $chapter->size,
-            'prev_cid'   =>  $chapter->prev_cid,
-            'next_cid'   =>  $chapter->next_cid,
-            'recent_update_at'   =>  $chapter->recent_update_at,
-            'is_show_price'=>isset($chapter->is_show_price)?$chapter->is_show_price:'',
-            'price'=>isset($chapter->price)?$chapter->price:'',
-        ];
-    }
-}

+ 0 - 28
app/Http/Controllers/WapAlipay/Book/Transformers/ChapterTransformer.php

@@ -1,28 +0,0 @@
-<?php
-
-namespace App\Http\Controllers\WapAlipay\Book\Transformers;
-use Hashids;
-class ChapterTransformer
-{
-    public function transform($chapter){
-        return [
-            'bid'       =>  Hashids::encode($chapter->bid),
-            //'bid_no_hash'       =>  $chapter->bid,
-            'chapter_id'       =>  $chapter->id,
-            'chapter_name'   =>  $chapter->name,
-            'chapter_sequence'   =>  $chapter->sequence,
-            'chapter_is_vip'   =>  $chapter->is_vip,
-            'chapter_size'   =>  $chapter->size,
-            'prev_cid'   =>  $chapter->prev_cid,
-            'next_cid'   =>  $chapter->next_cid,
-            'recent_update_at'   =>  $chapter->recent_update_at,
-            'chapter_content'   =>  $chapter->content,
-            'sign_status'   =>  $chapter->sign_status,
-            'sign_reard'   =>  isset($chapter->sign_reard)?$chapter->sign_reard:0,
-            'is_show_subscribe_link' =>isset($chapter->is_show_subscribe_link)?$chapter->is_show_subscribe_link:0,
-            'is_had_subscribe'=>(isset($chapter->is_had_subscribe) && !empty($chapter->is_had_subscribe))?1:0
-            //'is_had_subscribe'=>0
-            //'is_need_subscirbe'   =>  $chapter->is_need_subscirbe,
-        ];
-    }
-}

+ 0 - 86
app/Http/Controllers/WapAlipay/Oauth/UsersController.php

@@ -1,86 +0,0 @@
-<?php
-
-namespace App\Http\Controllers\WapAlipay\Oauth;
-
-use Illuminate\Http\Request;
-use App\Http\Controllers\Controller;
-use Cookie;
-use App\Modules\User\Services\UserService;
-use Log;
-use DB;
-use GuzzleHttp\Client;
-
-class UsersController extends Controller
-{
-
-    /**
-     * 微信授权回掉
-     * @param Request $request
-     * @return \Illuminate\Http\RedirectResponse
-     */
-    public function Aliback(Request $request,$distribution_channel_id)
-    {
-        if(!is_numeric($distribution_channel_id)){
-            $distribution_channel_id = decodeDistributionChannelId($distribution_channel_id);
-        }
-        $url = Cookie::get('auth_redirect');
-        //auth_code、app_id、scope
-
-        $auth_code = $request->get('auth_code');
-        $app_id = $request->get('app_id');
-        $scope = $request->get('scope');
-
-        return redirect()->to(urldecode($url));
-    }
-
-    /**
-     * 授权用户信息
-     * @param $data
-     * @return bool
-     */
-    protected function createUser($data)
-    {
-        if (empty($data['unionid']) || empty($data['openid'])) return false;
-        $user = UserService::getUserByUnionAndChannelId($data['openid'],$data['distribution_channel_id']);
-        if ($user) return $user;
-        return UserService::addUser(
-            ['openid' => $data['openid'],
-                'unionid' => $data['unionid'],
-                'distribution_channel_id' => $data['distribution_channel_id'],
-                'send_order_id'=>$data['send_order_id'],
-                'is_new'=>1
-            ]);
-    }
-
-    /**
-     *使用auth_code换取接口access_token及用户userId
-     * @param string $auth_code
-     * @return string
-     */
-    private function authToUserInfo(string $auth_code):string{
-        $client = new Client([
-            'timeout'  => 3,
-        ]);
-        $res = null;
-        try{
-            $res = $client->request('POST','https://openapi.alipay.com/gateway.do',[
-                'form_params'=>[
-                    'grant_type'=>'authorization_code',
-                    'code'=>$auth_code
-                ]
-            ])->getBody()->getContents();
-        }catch (\Exception $e){
-            return '';
-        }
-        if(empty($res)){
-            return '';
-        }
-
-        $res = json_decode($res,1);
-        if(isset($res['alipay_system_oauth_token_response'])){
-              return   $res['alipay_system_oauth_token_response']['user_id'];
-        }
-
-        return '';
-    }
-}

+ 0 - 323
app/Http/Controllers/WapAlipay/Order/OrdersController.php

@@ -1,323 +0,0 @@
-<?php
-
-namespace App\Http\Controllers\WapAlipay\Order;
-
-use App\Http\Controllers\WapAlipay\BaseController;
-use Illuminate\Http\Request;
-use App\Modules\Subscribe\Services\BookOrderService;
-use App\Modules\Subscribe\Services\ChapterOrderService;
-use App\Modules\Subscribe\Services\OrderService;
-use App\Http\Controllers\WapAlipay\Order\Transformers\BookOrderTransformer;
-use App\Http\Controllers\WapAlipay\Order\Transformers\ChapterOrderTransformer;
-use App\Http\Controllers\WapAlipay\Order\Transformers\ChargeListTransformer;
-
-
-use App\Modules\Product\Services\ProductService;
-
-class OrdersController extends BaseController
-{
-    /**
-     * @apiDefine Order 订单
-     */
-
-
-    /**
-     * @apiVersion 1.0.0
-     * @apiDescription 充值列表
-     * @api {get} order/chargeList 充值列表
-     * @apiGroup Order
-     * @apiName chargeList
-     * @apiSuccess {int}         code 状态码
-     * @apiSuccess {String}      msg  信息
-     * @apiSuccess {object}      data 结果集
-     * @apiSuccessExample {json} Success-Response:
-     *     HTTP/1.1 200 OK
-     *     {
-     *       code: 0,
-     *       msg: "",
-     *       data: [
-     *               {
-     *                   product_id: 1,
-     *                   price: "30.00元",
-     *                   vip: 0,
-     *                   intro: [
-     *                       {
-     *                           label: 3000,
-     *                           important: false
-     *                       },
-     *                       {
-     *                           label: "书币",
-     *                           important: true
-     *                       }
-     *                   ]
-     *               },
-     *               {
-     *                   product_id: 2,
-     *                   price: "50.00元",
-     *                   vip: 1,
-     *                   intro: [
-     *                       {
-     *                           label: 5000,
-     *                           important: false
-     *                       },
-     *                       {
-     *                           label: "1000+",
-     *                           important: true
-     *                       },
-     *                       {
-     *                           label: "书币",
-     *                           important: false
-     *                       }
-     *                       ]
-     *               },
-     *               {
-     *                   product_id: 5,
-     *                   price: "365.00元",
-     *                   vip: 0,
-     *                   intro: [
-     *                       {
-     *                       label: "年费VIP会员",
-     *                       important: true
-     *                       }
-     *                   ]
-     *               }
-     *               ]
-     *       }
-     */
-    public function chargeList(Request $request)
-    {
-        if (!$this->checkUid()) {
-            return response()->error('WAP_NOT_LOGIN');
-        }
-        $res = ProductService::getChargeProduct();
-        if (!$res->isEmpty()) {
-            $data = [];
-            foreach ($res as $v) {
-                $intro = [];
-                if ($v->given > 0 && $v->type == 'TICKET_RECHARGE') {
-                    $intro = [
-                        [
-                            'label' => ($v->price * 100) . "+",
-                            'important' => false,
-                        ],
-                        [
-                            'label' => $v->given,
-                            'important' => true,
-                        ],
-                        [
-                            'label' => '书币',
-                            'important' => false,
-                        ]
-
-                    ];
-                    $intro2 = [
-                        ['label'=>'多送','important'=>false],
-                        ['label'=>(int)($v->given/100),'important'=>true],
-                        ['label'=>'元','important'=>false],
-                    ];
-                    $v->vip = 0;
-                }
-                if ($v->given == 0 && $v->type == 'TICKET_RECHARGE') {
-                    $intro = [
-                        [
-                            'label' => $v->price * 100,
-                            'important' => false,
-                        ],
-                        [
-                            'label' => '书币',
-                            'important' => false,
-                        ]
-                    ];
-                    $v->vip = 0;
-                    $intro2 = [];
-                }
-                if ($v->given == 0 && $v->type == 'YEAR_ORDER') {
-                    $intro = [
-                        [
-                            'label' => '年费VIP会员',
-                            'important' => true,
-                        ]
-                    ];
-                    $v->vip = 1;
-                    $intro2 = [
-                        ['label'=>'每天1元,全年免费看','important'=>false],
-                    ];
-                }
-                $data[] = [
-                    'product_id' => $v->id,
-                    'price' => (int)$v->price . '元',
-                    'vip' => $v->vip,
-                    'intro' => $intro,
-                    'intro2'=>$intro2,
-                    'is_default' => $v->is_default,
-                ];
-            }
-            return response()->success($data);
-        } else {
-            return response()->error('WAP_SYS_ERROR');
-        }
-    }
-
-
-    /**
-     * @apiVersion 1.0.0
-     * @apiDescription 单本消费记录
-     * @api {get} order/bookOrderList 单本消费记录
-     * @apiGroup Order
-     * @apiName bookOrderList
-     * @apiSuccess {int}         code 状态码
-     * @apiSuccess {String}      msg  信息
-     * @apiSuccess {object}      data 结果集
-     * @apiSuccess {Int}         uid uid
-     * @apiSuccess {Int}         bid bid
-     * @apiSuccess {Int}         book_name 书名
-     * @apiSuccess {Int}         fee 钱
-     * @apiSuccess {String}      created_at 时间
-     * @apiSuccessExample {json} Success-Response:
-     *     HTTP/1.1 200 OK
-     *     {
-     *       code: 0,
-     *       msg: "",
-     *       data: list:[
-     *               {
-     *                   uid: 4,
-     *                   bid: 1,
-     *                   book_name: "dfsedfertrwet",
-     *                   fee: 100,
-     *                   created_at: "2017-12-02 16:24:54"
-     *                   }
-     *               ]
-     *            meta: {
-     *                       total: 1,
-     *                       per_page: 15,
-     *                       current_page: 1,
-     *                       last_page: 1,
-     *                       next_page_url: "",
-     *                       prev_page_url: ""
-     *               }
-     *       }
-     */
-    public function bookOrderList(Request $request)
-    {
-        if (!$this->checkUid()) {
-            return response()->error('WAP_NOT_LOGIN');
-        }
-        $page_size = $request->input('page_size', 15);
-        $book_order = BookOrderService::getRecord($this->uid, $page_size);
-        //$book_order = BookOrder::where('uid', $this->uid)->select('bid', 'uid', 'book_name', 'created_at', 'fee')->paginate($page_size);
-
-        return response()->pagination(new BookOrderTransformer(), $book_order);
-    }
-
-
-    /**
-     * @apiVersion 1.0.0
-     * @apiDescription 章节消费记录
-     * @api {get} order/chapterOrderList 章节消费记录
-     * @apiGroup Order
-     * @apiName chapterOrderList
-     * @apiSuccess {int}         code 状态码
-     * @apiSuccess {String}      msg  信息
-     * @apiSuccess {object}      data 结果集
-     * @apiSuccess {Int}         uid uid
-     * @apiSuccess {Int}         bid bid
-     * @apiSuccess {Int}         cid cid
-     * @apiSuccess {Int}         chapter_name 章节名
-     * @apiSuccess {Int}         book_name 书名
-     * @apiSuccess {Int}         fee 钱
-     * @apiSuccess {String}      created_at 时间
-     * @apiSuccessExample {json} Success-Response:
-     *     HTTP/1.1 200 OK
-     *     {
-     *       code: 0,
-     *       msg: "",
-     *       data: list:[
-     *               {
-     *                   uid: 4,
-     *                   bid: 1,
-     *                   cid: 1,
-     *                   chapter_name: "sdfsd",
-     *                   book_name: "dfsedfertrwet",
-     *                   fee: 100,
-     *                   created_at: "2017-12-02 16:24:54"
-     *                   }
-     *               ]
-     *            meta: {
-     *                       total: 1,
-     *                       per_page: 15,
-     *                       current_page: 1,
-     *                       last_page: 1,
-     *                       next_page_url: "",
-     *                       prev_page_url: ""
-     *               }
-     *       }
-     */
-    public function chapterOrderList(Request $request)
-    {
-        if (!$this->checkUid()) {
-            return response()->error('WAP_NOT_LOGIN');
-        }
-        $chapter_model = new ChapterOrderService();
-        $page_size = $request->input('page_size', 15);
-        $chapter_order = $chapter_model->getByUid($this->uid, $page_size);
-        return response()->pagination(new ChapterOrderTransformer(), $chapter_order);
-    }
-
-
-    /**
-     * @apiVersion 1.0.0
-     * @apiDescription 充值记录
-     * @api {get} order/chargeRecordLists 充值记录
-     * @apiGroup Order
-     * @apiName chargeRecordLists
-     * @apiSuccess {int}         code 状态码
-     * @apiSuccess {String}      msg  信息
-     * @apiSuccess {object}      data 结果集
-     * @apiSuccess {String}      data.price       价格
-     * @apiSuccess {String}      data.status      状态
-     * @apiSuccess {String}      data.trade_no    订单号
-     * @apiSuccess {String}      data.created_at  时间
-     * @apiSuccessExample {json} Success-Response:
-     *     HTTP/1.1 200 OK
-     *    {
-     *       code: 0,
-     *       msg: "",
-     *           data: {
-     *               list: [
-     *               {
-     *                    id: 134,
-     *                    price: "1.00",
-     *                    status: "PAID",
-     *                    trade_no: "201712021915481585670623626232",
-     *                    created_at: "2017-12-02 19:15:56"
-     *           }
-     *       ],
-     *           meta: {
-     *               total: 1,
-     *               per_page: 15,
-     *               current_page: 1,
-     *               last_page: 1,
-     *               next_page_url: "",
-     *               prev_page_url: ""
-     *           }
-     *       }
-     *    }
-     */
-    public function chargeRecordLists(Request $request)
-    {
-        $page_size = $request->input('page_size', 15);
-        $res = OrderService::getOrderList($this->uid, $page_size);
-        return response()->pagination(new ChargeListTransformer(), $res);
-    }
-
-    //订单是否成功
-    public function isSuccess(Request $request){
-        $order = $request->input('order');
-        $order_info = OrderService::getByTradeNo($order);
-        if($order_info && $order_info->status == 'PAID'){
-            return response()->success();
-        }
-        return response()->error('WAP_SYS_ERROR');
-    }
-
-}

+ 0 - 17
app/Http/Controllers/WapAlipay/Order/Transformers/BookOrderTransformer.php

@@ -1,17 +0,0 @@
-<?php
-
-namespace App\Http\Controllers\WapAlipay\Order\Transformers;
-use Hashids;
-class BookOrderTransformer
-{
-    public function transform($res){
-        return [
-            //'bid_no_hash'          =>  $res->uid,
-            'bid'          =>  Hashids::encode($res->bid),
-            'book_name'    =>  $res->book_name,
-            'uid'            =>  $res->uid,
-            'created_at'      => date("Y-m-d H:i:s",strtotime($res->created_at)),
-            'fee'            =>  $res->fee,
-        ];
-    }
-}

+ 0 - 19
app/Http/Controllers/WapAlipay/Order/Transformers/ChapterOrderTransformer.php

@@ -1,19 +0,0 @@
-<?php
-
-namespace App\Http\Controllers\WapAlipay\Order\Transformers;
-use Hashids;
-class ChapterOrderTransformer
-{
-    public function transform($res){
-        return [
-            'uid'          		=>  $res->uid,
-            //'bid_no_hash'       =>  $res->bid,
-            'bid'            	=>  Hashids::encode($res->bid),
-            'cid'   		    =>  $res->cid,
-            'book_name'         =>  $res->book_name,
-            'chapter_name'      =>  $res->chapter_name,
-            'fee'               =>  $res->fee,
-            'created_at'        =>  date("Y-m-d H:i:s",strtotime($res->created_at)),
-        ];
-    }
-}

+ 0 - 16
app/Http/Controllers/WapAlipay/Order/Transformers/ChargeListTransformer.php

@@ -1,16 +0,0 @@
-<?php
-
-namespace App\Http\Controllers\WapAlipay\Order\Transformers;
-class ChargeListTransformer
-{
-
-    public function transform($res){
-        return [
-            'id'       =>  $res->id,
-            'price'       =>  $res->price,
-            'status'   =>  $res->status,
-            'trade_no'=>$res->trade_no,
-            'created_at'   =>  date("Y-m-d H:i:s",strtotime($res->created_at))
-        ];
-    }
-}

+ 0 - 19
app/Http/Controllers/WapAlipay/Order/Transformers/OrderTransformer.php

@@ -1,19 +0,0 @@
-<?php
-
-namespace App\Http\Controllers\WapAlipay\Order\Transformers;
-
-class OrderTransformer
-{
-    public function transform($order){
-        return [
-            'merchant_order_id'       =>  $order->merchant_order_id,
-            'user_id'       =>  $order->user_id,
-            'user_nickname'       =>  $order->user_nickname,
-            'pay_money'       =>  (int)$order->pay_money/100,
-            'pay_flag'   =>  $order->pay_flag,
-            'pay_time'   =>  $order->pay_time ? date('Y-m-d H:i:s',$order->pay_time) : '',
-            'send_order_id' => isset($order->send_order_id) ? $order->send_order_id : 0,
-            'send_order_name' => isset($order->send_order_name) ? $order->send_order_name : ''
-        ];
-    }
-}

+ 0 - 44
app/Http/Controllers/WapAlipay/Other/ErrorCollectionController.php

@@ -1,44 +0,0 @@
-<?php
-
-namespace App\Http\Controllers\WapAlipay\Other;
-
-use Illuminate\Http\Request;
-use App\Http\Controllers\Controller;
-use DB;
-class ErrorCollectionController extends Controller
-{
-    /**
-     * @apiDefine Exception 异常收集
-     */
-
-
-    /**
-     * @apiVersion 1.0.0
-     * @apiDescription undefined错误收集
-     * @api {POST} error/undefinedCollect undefined错误收集
-     * @apiGroup Exception
-     * @apiName undefinedCollect
-     * @apiParam {String}         name 状态码
-     * @apiParam {String}         content  信息
-     * @apiSuccessExample {json} Success-Response:
-     *     HTTP/1.1 200 OK
-     *     {
-     *       code: 0,
-     *       msg: "",
-     *       data:{}
-     *       }
-     */
-    public function undefinedCollect(Request $request){
-        $name = $request->input('name','unkown');
-        $content = $request->input('content','');
-        if($name || $content){
-            DB::table('wap_error')->insert([
-                'tag'=>$name,
-                'content'=>$content,
-                'created_at'=>date('Y-m-d H:i:s'),
-                'updated_at'=>date('Y-m-d H:i:s'),
-            ]);
-        }
-        return response()->success();
-    }
-}

Plik diff jest za duży
+ 0 - 1090
app/Http/Controllers/WapAlipay/Pay/OrdersController.php


+ 0 - 231
app/Http/Controllers/WapAlipay/User/ReadRecordController.php

@@ -1,231 +0,0 @@
-<?php
-
-namespace App\Http\Controllers\WapAlipay\User;
-
-use Illuminate\Http\Request;
-use App\Http\Controllers\WapAlipay\BaseController;
-use App\Modules\Book\Services\BookConfigService;
-use App\Modules\Book\Services\UserShelfBooksService;
-use App\Http\Controllers\WapAlipay\User\Transformers\ReadRecordTransformer;
-use App\Modules\User\Services\ReadRecordService;
-use Hashids;
-use Cookie;
-use Redis;
-use Log;
-class ReadRecordController extends BaseController
-{
-
-    /**
-     * @apiDefine ReadRecord 阅读记录
-     */
-
-
-
-    /**
-     * @apiVersion 1.0.0
-     * @apiDescription 获取阅读记录
-     * @api {get} readrecord 获取阅读记录
-     * @apiGroup ReadRecord
-     * @apiName index
-     * @apiSuccess {int}         code 状态码
-     * @apiSuccess {String}      msg  信息
-     * @apiSuccess {object}      data 结果集
-     * @apiSuccess {Int}         data.book_name    书名
-     * @apiSuccess {String}      data.chapter_name  章节名
-     * @apiSuccess {Int}         data.bid   bid
-     * @apiSuccess {Int}         data.time   时间
-     * @apiSuccess {Int}         data.cid    章节id
-     * @apiSuccess {Int}         data.chapter_name    章节名
-     * @apiSuccess {Int}         data.cover    封面
-     * @apiSuccess {Int}         data.last_chapter    最后一张
-     * @apiSuccessExample {json} Success-Response:
-     *     HTTP/1.1 200 OK
-     *     {
-     *       code: 0,
-     *       msg: "",
-     *       data:[
-     *           {
-     *               book_name: "我来好好爱你",
-     *               bid: 2,
-     *               cid: 10402,
-     *               time: 1511783120,
-     *               chapter_name: "你言重了"
-     *           },
-     *           {
-     *               book_name: "京华烟云",
-     *               bid: 1,
-     *               cid: 4,
-     *               time: 1511783068,
-     *               chapter_name: "背水一战"
-     *           }
-     *           ]
-     */
-    public function index(Request $request){
-        if(!$this->checkUid()){
-            return response()->error('NOT_LOGIN');
-        }
-
-        $res = ReadRecordService::getReadRecord($this->uid);
-        if($res){
-            $id_arr = [];
-            foreach ($res as $key => $value) {
-                $id_arr[] = $value['bid'];
-            }
-
-            $book = BookConfigService::getBooksByIds($id_arr);
-            foreach ($res as $key => &$value) {
-                $value['cover'] = '';
-                $value['last_chapter'] = 0;
-                foreach ($book as  $val) {
-                    if($value['bid'] == $val->bid){
-                        $value['cover'] = $val->cover;
-                        $value['last_chapter'] = $val->last_chapter;
-                        break;
-                    }
-                }
-            }
-
-            $shelf = UserShelfBooksService::getUserShelfBooksListByUid($this->uid);
-            foreach ($res as &$v){
-                $v['is_on_user_shelf'] = 0;
-                foreach ($shelf as $val){
-                    if($v['bid'] == $val->bid){
-                        $v['is_on_user_shelf'] = 1;
-                        break;
-                    }
-                }
-            }
-        }
-        usort($res,function($a,$b){
-            if($a['time'] >= $b['time']) return -1;
-            return 1;
-
-        });
-        $res = json_encode($res);
-        $res = json_decode($res);
-        return response()->collection(new ReadRecordTransformer(),$res);
-    }
-
-
-    /**
-     * @apiVersion 1.0.0
-     * @apiDescription 添加阅读记录
-     * @api {post} readrecord 添加阅读记录
-     * @apiGroup ReadRecord
-     * @apiName addReadRecord
-     *
-     * @apiParam   {Int}         book_name    书名
-     * @apiParam   {String}      chapter_name  章节名
-     * @apiParam   {Int}         bid     bid
-     * @apiParam   {Int}         cid    章节id
-     * @apiSuccess {int}         code 状态码
-     * @apiSuccess {String}      msg  信息
-     * @apiSuccess {object}      data 结果集
-     * @apiSuccessExample {json} Success-Response:
-     *     HTTP/1.1 200 OK
-     *     {
-     *       code: 0,
-     *       msg: "",
-     *       data:{}
-     *
-     */
-    public function addReadRecord(Request $request){
-        if(!$this->checkUid()){
-            return response()->error('NOT_LOGIN');
-        }
-        $param = $request->except('_url');
-        if(checkParam($param,['bid','cid','chapter_name'])){
-            return response()->error('LACK_PARAM');
-        }
-        //Redis::hset('book_read:' . $uid, $bid, "{$cid}_{$book_name}_{$chapter_name}_" . time());
-
-        $param['uid'] = $this->uid;
-        $param['bid'] = Hashids::decode($param['bid'])[0];
-        $record_info = Redis::hget('book_read:'.$this->uid,$param['bid']);
-        $param['book_name'] = '';
-        if($record_info){
-            //$param['book_name'] = explode('_',$record_info)[1];
-        }
-
-        ReadRecordService::addReadRecord($param);
-        return response()->success();
-
-    }
-
-
-    /**
-     * @apiVersion 1.0.0
-     * @apiDescription 删除阅读记录
-     * @api {get} readrecord/delete 删除阅读记录
-     * @apiGroup ReadRecord
-     * @apiName delReadRecord
-     * @apiParam   {Int}         bid     bid
-     * @apiSuccess {int}         code 状态码
-     * @apiSuccess {String}      msg  信息
-     * @apiSuccess {object}      data 结果集
-     * @apiSuccessExample {json} Success-Response:
-     *     HTTP/1.1 200 OK
-     *     {
-     *       code: 0,
-     *       msg: "",
-     *       data:{}
-     *
-     */
-    public function delReadRecord(Request $request){
-        if(!$this->checkUid()){
-            return response()->error('NOT_LOGIN');
-        }
-        $param = $request->except('_url');
-        if(checkParam($param,['bid'])){
-            return response()->error('LACK_PARAM');
-        }
-        $param['bid'] = Hashids::decode($param['bid'])[0];
-        ReadRecordService::delReadRecord($this->uid,$param['bid']);
-        return response()->success();
-    }
-
-    //继续阅读
-    public function latestRead(Request $request){
-
-        $from = $request->input('from');
-        if($from){
-            Cookie::queue('fromcustomermsgenter',$from);
-            $key = "fromcustomermsgenter:distribution_channel_id:".$this->distribution_channel_id.'from:'.$from;
-            Redis::hincrby($key,date('Y-m-d'),1);
-        }
-        $send_order_id = Cookie::get('send_order_id');
-        $continue_cookie = Cookie::get('send_order_continue');
-        if($send_order_id && !$continue_cookie){
-            Redis::hincrby("send_order:continue:{$send_order_id}",date('Y-m-d'),1);
-            Redis::hincrby("send_order:continue:{$send_order_id}",'total',1);
-            Cookie::queue('send_order_continue',$send_order_id, env('U_COOKIE_EXPIRE'), null, null, false, false);
-        }
-
-        $subscribe_info = Cookie::get('subscribe_url');
-        if($subscribe_info){
-            $subscribe_info_arr = explode('_',$subscribe_info);
-            if($subscribe_info_arr){
-                Cookie::queue('subscribe_url','', 1);
-                $bid = Hashids::encode($subscribe_info_arr[1]);
-                $url = parse_url(secure_url('/'))['scheme'].'://'._domain().'/reader?bid='.$bid.'&cid='.$subscribe_info_arr[0];
-                Log::info('cookie-------------'.$url);
-                return redirect()->to($url);
-            }
-        }
-
-        $last = Redis::hget('book_read:'.$this->uid, 'last_read');
-        if($last){
-            $last_arr = explode('_',$last);
-            if(isset($last_arr[0]) && $last_arr[0] && isset($last_arr[1]) && $last_arr[1]){
-                $bid = Hashids::encode($last_arr[0]);
-                $url = parse_url(secure_url('/'))['scheme'].'://'._domain().'/reader?bid='.$bid.'&cid='.$last_arr[1];
-                Log::info('redis-------------'.$url);
-                return redirect()->to($url);
-            }
-        }
-        Log::info('default-------------'.parse_url(secure_url('/'))['scheme'].'://'._domain());
-        return redirect()->to(parse_url(secure_url('/'))['scheme'].'://'._domain());
-
-    }
-
-}

+ 0 - 20
app/Http/Controllers/WapAlipay/User/Transformers/ReadRecordTransformer.php

@@ -1,20 +0,0 @@
-<?php
-
-namespace App\Http\Controllers\WapAlipay\User\Transformers;
-use Hashids;
-class ReadRecordTransformer
-{
-    public function transform($res)
-    {
-        return [
-            'bid' => Hashids::encode($res->bid),
-            'cid' => $res->cid,
-            'book_name' => $res->book_name,
-            'chapter_name' => $res->chapter_name,
-            'time' => $res->time,
-            'cover' => $res->cover,
-            'last_chapter' => $res->last_chapter,
-            'is_on_user_shelf'=>$res->is_on_user_shelf
-        ];
-    }
-}

+ 0 - 13
app/Http/Controllers/WapAlipay/User/Transformers/SignRecordTransformer.php

@@ -1,13 +0,0 @@
-<?php
-namespace App\Http\Controllers\WapAlipay\User\Transformers;
-class SignRecordTransformer{
-    public function transform($record)
-    {
-        return [
-            'reward' =>$record->price,
-            'sign_time' =>date('Y-m-d H:i:s',$record->sign_time),
-        ];
-    }
-}
-
-

+ 0 - 24
app/Http/Controllers/WapAlipay/User/Transformers/UserShelfBooksTransformer.php

@@ -1,24 +0,0 @@
-<?php
-
-namespace App\Http\Controllers\WapAlipay\User\Transformers;
-
-use Hashids;
-
-class UserShelfBooksTransformer
-{
-    public function transform($userShelfBook)
-    {
-        return [
-            'id' => $userShelfBook->id,
-            'uid' => $userShelfBook->uid,
-            'distribution_channel_id' => $userShelfBook->distribution_channel_id,
-            //'bid_no_hash' => $userShelfBook->bid,
-            'bid' => Hashids::encode($userShelfBook->bid),
-            'book_name' => $userShelfBook->book_name,
-            'cover' => $userShelfBook->cover,
-            'updated_at' => strtotime($userShelfBook->updated_at),
-            'first_cid' => $userShelfBook->first_cid,
-            'last_cid' => $userShelfBook->last_cid,
-        ];
-    }
-}

+ 0 - 153
app/Http/Controllers/WapAlipay/User/UserController.php

@@ -1,153 +0,0 @@
-<?php
-
-namespace App\Http\Controllers\WapAlipay\User;
-
-use Illuminate\Http\Request;
-use App\Http\Controllers\WapAlipay\BaseController;
-use App\Modules\Subscribe\Services\YearOrderService;
-use App\Modules\User\Services\UserService;
-use App\Modules\User\Services\UserSignService;
-use App\Http\Controllers\WapAlipay\User\Transformers\SignRecordTransformer;
-use Log;
-use Redis;
-use Cookie;
-use DB;
-
-class UserController extends BaseController
-{
-    /**
-     * @apiDefine User 用户
-     */
-
-
-    /**
-     * @apiVersion 1.0.0
-     * @apiDescription 获取用户信息
-     * @api {GET} userinfo 获取用户信息
-     * @apiGroup User
-     * @apiName index
-     * @apiSuccess {Number}  id 用户ID.
-     * @apiSuccess {String}  openid 微信openid.
-     * @apiSuccess {String}  unionid 微信unionid.
-     * @apiSuccess {Number}  distribution_channel_id 分销渠道ID.
-     * @apiSuccess {String}  province 省份.
-     * @apiSuccess {String}  city 城市.
-     * @apiSuccess {String}  country 国家.
-     * @apiSuccess {String}  headimgurl 头像地址.
-     * @apiSuccess {Number}  send_order_id 派单ID.
-     * @apiSuccess {Number=0,1}  sex 性别.
-     * @apiSuccess {String}  balance 书币余额.
-     * @apiSuccess {Int}     is_vip 是否vip
-     * @apiSuccess {String}  vip_days 364天.
-     * @apiSuccessExample {json} Success-Response:
-     *
-     *     {
-     *         "code": 0,
-     *         "msg": "",
-     *         "data": {
-     *             "id": 56,
-     *             "openid": "sdfs34ssdfdsf",
-     *             "unionid": "SDFSD3343S",
-     *             "distribution_channel_id": 1212,
-     *             "province": "浙江省",
-     *             "city": "杭州",
-     *             "country": "中国",
-     *             "headimgurl": "http://.."
-     *             "send_order_id": 323
-     *             "balance": 8956
-     *             "register_time": "2017-12-12 12:12:12"
-     *         }
-     *     }
-     */
-    public function index(){
-        if(!$this->checkUid()){
-            return response()->error('NOT_LOGIN');
-        }
-
-        $data = UserService::getById($this->uid);
-
-        $data['is_vip'] = 0;
-        $data['vip_days'] = 0;
-        $year_record = YearOrderService::getRecord($this->uid);
-        if($year_record){
-            $data['is_vip'] = 1;
-            
-            $time = strtotime($year_record['end_time'])-time();
-            if($time>=86400){
-                  $data['vip_days'] = floor($time/86400).'天';  
-            }elseif ($time>3600) {
-                 $data['vip_days'] = floor($time/3600).'小时';  
-            }elseif ($time>60) {
-                 $data['vip_days'] = floor($time/60).'分钟';  
-            }else{
-                $data['vip_days'] = $time.'秒';  
-            }
-        }
-        return response()->success($data);
-    }
-
-
-    /**
-     * @apiVersion 1.0.0
-     * @apiDescription 用户签到记录
-     * @api {GET} user/sign_record 用户签到记录
-     * @apiGroup User
-     * @apiName signRecord
-     * @apiSuccess {int}         code 状态码
-     * @apiSuccess {String}      msg  信息
-     * @apiSuccess {object}      data 结果集
-     * @apiSuccess {reward}     data.reward 奖励金额.
-     * @apiSuccess {sign_time}  data.sign_time 签到时间.
-     * @apiParam {page}  page
-     * @apiSuccessExample {json} Success-Response:
-     *
-     *    {
-     *       code: 0,
-     *       msg: "",
-     *       data: {
-     *           list: [
-     *           {
-     *               reward: 50,
-     *               sign_time: "2018-03-20 13:43:11"
-     *           },
-     *           {
-     *               reward: 50,
-     *               sign_time: "2018-01-18 16:22:33"
-     *           },
-     *       ],
-     *       meta: {
-     *           total: 12,
-     *           per_page: 15,
-     *           current_page: 1,
-     *           last_page: 1,
-     *           next_page_url: "",
-     *           prev_page_url: ""
-     *       }
-     *       }
-     *   }
-     */
-    public function signRecord(Request $request){
-        return response()->pagination(new SignRecordTransformer(),UserSignService::getUserSignRecord($this->uid));
-    }
-
-    public function getCoupons(Request $request){
-        $activity_id = $request->input('activity_id');
-        if(!DB::table('discount_coupons')->where('uid',$this->uid)->where('activity_id',$activity_id)->count()){
-            DB::table('discount_coupons')->insert([
-                'uid'=>$this->uid,
-                'activity_id'=>$activity_id,
-                'created_at'=>date('Y-m-d H:i:s'),
-                'updated_at'=>date('Y-m-d H:i:s')
-            ]);
-        }
-
-        return response()->success();
-    }
-
-    function logout()
-    {
-        setcookie(env('COOKIE_AUTH_WEB_WECHAT'), '', -1);
-        setcookie('u', '', -1);
-        return response('logout');
-    }
-}

+ 0 - 217
app/Http/Controllers/WapAlipay/User/UserShelfBooksController.php

@@ -1,217 +0,0 @@
-<?php
-
-namespace App\Http\Controllers\WapAlipay\User;
-
-use Illuminate\Http\Request;
-use App\Http\Controllers\WapAlipay\BaseController;
-use Redis;
-use App\Modules\Book\Services\UserShelfBooksService;
-use App\Http\Controllers\WapAlipay\User\Transformers\UserShelfBooksTransformer;
-use App\Modules\User\Services\ReadRecordService;
-use Hashids;
-use Log;
-class UserShelfBooksController extends BaseController
-{
-
-    /**
-     * @apiDefine UserShelfBooks 书架
-     */
-
-
-
-    /**
-     * @apiVersion 1.0.0
-     * @apiDescription 获取书架
-     * @api {get} userShelfBooks 获取书架
-     * @apiGroup UserShelfBooks
-     * @apiName getChapter
-     * @apiSuccess {int}         code 状态码
-     * @apiSuccess {String}      msg  信息
-     * @apiSuccess {object}      data 结果集
-     * @apiSuccess {Int}         data.id   编号
-     * @apiSuccess {String}      data.distribution_channel_id   分销
-     * @apiSuccess {Int}         data.uid   uid
-     * @apiSuccess {Int}         data.bid   bid
-     * @apiSuccess {Int}         data.book_name   书名
-     * @apiSuccess {Int}         data.cover   封面
-     * @apiSuccess {Int}         data.last_cid   章节id
-     * @apiSuccessExample {json} Success-Response:
-     *     HTTP/1.1 200 OK
-     *     {
-     *       code: 0,
-     *       msg: "",
-     *       data: {
-     *          [
-     *               {
-     *                   id: 6,
-     *                   uid: 4,
-     *                   distribution_channel_id: 1,
-     *                   bid: 1,
-     *                   book_name: "京华烟云",
-     *                   cover: "https://leyue-bucket.oss-cn-hangzhou.aliyuncs.com/ycsd_cover/covermiddle/0/1.jpg",
-     *                   updated_at: 1511783068,
-     *                   last_cid: 4
-     *               },
-     *               {
-     *                   id: 7,
-     *                   uid: 4,
-     *                   distribution_channel_id: 1,
-     *                   bid: 1,
-     *                   book_name: "我来好好爱你",
-     *                   cover: "https://leyue-bucket.oss-cn-hangzhou.aliyuncs.com/ycsd_cover/covermiddle/0/11.jpg",
-     *                   updated_at: 1511783068,
-     *                   last_cid: 4
-     *               }
-     *           ]
-     *       }
-     */
-    public function index(Request $request){
-        if(!$this->checkUid()){
-            return response()->error('WAP_NOT_LOGIN');
-        }
-
-        $res = UserShelfBooksService::getUserShelfBooksListByUid($this->uid);
-
-        if($res->isEmpty()){
-            return response()->success();
-        }
-
-        $record = ReadRecordService::getReadRecord($this->uid);
-
-        //if(empty($record))   return response()->success($res);
-
-        foreach ($res as &$v){
-            $v['last_cid'] = $v['first_cid'];
-            foreach ($record as $val){
-                if($v['bid'] == $val['bid']){
-                    $v['updated_at'] = $val['time'];
-                    $v['last_cid'] = $val['cid'];
-                    break;
-                }
-            }
-        }
-
-        /*
-        usort($res,function($a,$b){
-            if($a['updated_at'] >= $b['updated_at']) return -1;
-            return 1;
-
-        });*/
-        return response()->collection(new UserShelfBooksTransformer(),$res);
-    }
-
-    /**
-     * @apiVersion 1.0.0
-     * @apiDescription 添加书架
-     * @api {post} userShelfBooks 添加书架
-     * @apiGroup UserShelfBooks
-     * @apiName addShelf
-     * @apiParam   {int}         bid bid
-     * @apiSuccess {int}         code 状态码
-     * @apiSuccess {String}      msg  信息
-     * @apiSuccess {object}      data 结果集
-     * @apiSuccessExample {json} Success-Response:
-     *     HTTP/1.1 200 OK
-     *     {
-     *       code: 0,
-     *       msg: "",
-     *       data: {}
-     */
-    public function addShelf(Request $request){
-        if(!$this->checkUid()){
-            return response()->error('WAP_NOT_LOGIN');
-        }
-        $param = $request->except('_url');
-        if(checkParam($param,['bid'])){
-            return response()->error('WAP_LACK_PARAM');
-        }
-
-        $param['uid'] = $this->uid;
-        $param['bid'] = Hashids::decode($param['bid'])[0];
-        $param['distribution_channel_id'] = $this->distribution_channel_id;
-        $res = null;
-        try{
-            $res = UserShelfBooksService::create($param);
-        }catch (\Exception $e){
-            return response()->error('WAP_HAD_ON_SHELF');
-        }
-
-        if($res){
-            return response()->success($res);
-        }
-        return response()->error('WAP_SYS_ERROR');
-    }
-
-
-    /**
-     * @apiVersion 1.0.0
-     * @apiDescription 删除书架
-     * @api {get} userShelfBooks/delete 删除书架
-     * @apiGroup UserShelfBooks
-     * @apiName delShelf
-     * @apiParam   {int}         bid bid
-     * @apiSuccess {int}         code 状态码
-     * @apiSuccess {String}      msg  信息
-     * @apiSuccess {object}      data 结果集
-     * @apiSuccessExample {json} Success-Response:
-     *     HTTP/1.1 200 OK
-     *     {
-     *       code: 0,
-     *       msg: "",
-     *       data: {}
-     */
-    public function delShelf(Request $request){
-        if(!$this->checkUid()){
-            return response()->error('WAP_NOT_LOGIN');
-        }
-        $bid = $request->input('bid');
-        if(empty($bid)) return response()->error('WAP_LACK_PARAM');
-        $param['uid'] = $this->uid;
-        $param['bid'] = Hashids::decode($bid)[0];
-        $res = UserShelfBooksService::del($this->uid,$param['bid']);
-        if($res){
-            return response()->success();
-        }
-        return response()->error('WAP_SYS_ERROR');
-    }
-    
-
-    /**
-     * @apiVersion 1.0.0
-     * @apiDescription 是否在书架上
-     * @api {get} userShelfBooks/isonshelf 是否在书架上
-     * @apiGroup UserShelfBooks
-     * @apiName isOnshelf
-     * @apiParam   {int}         bid bid
-     * @apiSuccess {int}         code 状态码
-     * @apiSuccess {String}      msg  信息
-     * @apiSuccess {object}      data 结果集
-     * @apiSuccess {Int}         data.is_on 是否在书架上(0|1)
-     * @apiSuccessExample {json} Success-Response:
-     *     HTTP/1.1 200 OK
-     *     {
-     *       code: 0,
-     *       msg: "",
-     *       data: {
-     *               is_on:0
-     *           }
-     */
-    public function  isOnshelf(Request $request){
-        if(!$this->checkUid()){
-            return response()->error('NOT_LOGIN');
-        }
-        $bid = $request->input('bid');
-        if(!$bid) return response()->error('LACK_PARAM');
-        $bid = Hashids::decode($bid)[0];
-        //$param['uid'] = $this->uid;
-        //$res = $this->apiClient->get($this->joinUrl('Read/isonshelf'),$param);
-        $res = UserShelfBooksService::getUserShelfBooksListByUidAndBid($this->uid,$bid);
-        if($res){
-            $data['is_on'] = 1;
-        }else{
-            $data['is_on'] = 0;
-        }
-        return response()->success($data);
-    }
-
-}

+ 0 - 43
app/Http/Controllers/WapAlipay/User/UserbehaviorController.php

@@ -1,43 +0,0 @@
-<?php
-
-namespace App\Http\Controllers\WapAlipay\User;
-
-use Illuminate\Http\Request;
-use App\Http\Controllers\Controller;
-use App\Modules\User\Models\BackActive;
-
-class UserbehaviorController extends Controller
-{
-
-    /**
-     * @apiDefine User 用户
-     */
-
-
-    /**
-     * @apiVersion 1.0.0
-     * @apiDescription 用户行为
-     * @api {POST} userBehavior 用户行为
-     * @apiGroup User
-     * @apiName collectionBehavior
-     * @apiParam {Number}  uid 用户ID.
-     * @apiParam {String}  current_url 当前连接
-     * @apiSuccessExample {json} Success-Response:
-     *
-     *     {
-     *         "code": 0,
-     *         "msg": "",
-     *         "data": {
-     *         }
-     *     }
-     */
-    public function collectionBehavior(Request $request){
-        $uid = $request->input('uid');
-        $current_url = $request->input('current_url');
-        if(empty($uid) || empty($current_url)){
-        }else{
-            BackActive::create(compact('uid','current_url'));
-        }
-        return response()->success();
-    }
-}

+ 0 - 123
app/Http/Controllers/WapAlipay/Web/RedirectController.php

@@ -1,123 +0,0 @@
-<?php
-
-namespace App\Http\Controllers\WapAlipay\Web;
-
-use Illuminate\Routing\Controller;
-use Illuminate\Http\Request;
-use Cookie;
-use DB;
-use Redis;
-use App\Modules\SendOrder\Services\SendOrderService;
-
-class RedirectController extends Controller
-{
-    /**
-     * 推广链接跳转
-     * @param Request $request
-     * @param $param
-     * @return \Illuminate\Http\RedirectResponse
-     */
-    public function index(Request $request, $t, $domain, $param)
-    {
-        $h5_scheme = 'https';
-        if(is_numeric($t)){
-            //不是加密site 重定向到加密site
-            $domain_distribution_channel_id = $t;
-        }else{
-            $domain_distribution_channel_id = decodeDistributionChannelId($t);
-        }
-
-        if(empty($domain_distribution_channel_id)){
-            return response()->error('UNKNOWN_ERROR');
-        }
-        $uid = Cookie::get(env('COOKIE_AUTH_WEB_WECHAT'));
-        if($uid){
-            try{
-                Redis::hset('book_read:' . $uid, 'send_order_id', $param);
-            }catch (\Exception $e){}
-        }
-        $link = SendOrderService::getRedirectUrlById($param);
-        $query_param = $request->except('_url');
-        $query_param['soid'] = $param;
-        $query_param['source'] = 'wechatmsg';
-        $query = '';
-        if ($query_param) {
-            $query = http_build_query($query_param);
-        }
-        if ($link) {
-            //访问时的site id与派单的site id 不一致 直接返回首页
-            if($link->distribution_channel_id != $domain_distribution_channel_id){
-                return redirect()->to($h5_scheme.'://' . _domain());
-            }
-            $key = date('Y-m-d');
-            Cookie::queue('send_order_id', $param, env('U_COOKIE_EXPIRE'), null, null, false, false);
-            $url = secure_url('/') . $link->redirect_url;
-            if ($query) {
-                if (strpos($link->redirect_url, '?')) {
-                    $url = secure_url('/') . $link->redirect_url . '&' . $query;
-                } else {
-                    $url = secure_url('/') . $link->redirect_url . '?&' . $query;
-                }
-            }
-            $send_order_flag = Cookie::get('send_order_flag');
-            $send_orders = explode(',', $send_order_flag);
-            //uv
-            if (!in_array($param, $send_orders)) {
-                Redis::hincrby('send_order_uv_' . $param, $key, 1);
-                Redis::hincrby('send_order_uv_' . $param, 'total', 1);
-                array_push($send_orders, $param);
-                $str = implode(',', $send_orders);
-                Cookie::queue('send_order_flag', $str, env('U_COOKIE_EXPIRE'), null, null, false, false);
-            }
-            //pv
-            Redis::hincrby('send_order_pv_' . $param, $key, 1);//每天
-            Redis::hincrby('send_order_pv_' . $param, 'total', 1);//汇总
-            Redis::sadd('send_order' . $key, $param);
-            //$key = date('Y-m-d');
-            if (!$link->send_time) {
-                $uv = Redis::hget('send_order_uv_' . $param, $key);
-                $this->updateSendOrderTime($param, $uv);
-            }
-            //
-            $redirect_path = $request->get('redirect_path');
-           if($redirect_path){
-               $redirect_path = urldecode($redirect_path);
-               $url = secure_url('/') .$redirect_path;
-               return redirect()->to($url);
-           }else{
-               return redirect()->to($url);
-           }
-        }
-        return redirect()->to(parse_url(url()->current())['scheme'] . '://' . _domain() . '/?' . $query);
-    }
-
-
-    public function testLogin(Request $request)
-    {
-
-        $siteid = $request->input('siteid');
-        if (env('APP_ENV', '') == 'local') {
-            echo encodeDistributionChannelId($siteid);
-            Cookie::queue(env('COOKIE_AUTH_WEB_WECHAT'), 1, env('U_COOKIE_EXPIRE'), null, null, false, false);
-        }
-    }
-
-    public function help()
-    {
-        $title = '帮助';
-        return view('wap.help', compact('title'));
-    }
-
-    protected function updateSendOrderTime($send_order_id, $uv)
-    {
-        if ($uv && $uv >= 20) {
-            try {
-                SendOrderService::updateSendOrderTime($send_order_id);
-                return true;
-            } catch (\Exception $e) {
-
-            }
-        }
-        return false;
-    }
-}

+ 0 - 129
app/Http/Controllers/WapAlipay/Web/WelcomeController.php

@@ -1,129 +0,0 @@
-<?php
-
-namespace App\Http\Controllers\WapAlipay\Web;
-
-use Illuminate\Http\Request;
-use App\Http\Controllers\WapAlipay\BaseController;
-use Cookie;
-use App\Modules\OfficialAccount\Services\CustomMsgService;
-use App\Modules\Activity\Services\ActivityService;
-use App\Modules\Activity\Models\Activity;
-use App\Modules\OfficialAccount\Services\OfficialAccountService;
-
-class WelcomeController extends BaseController
-{
-
-    /**
-     * 首页
-     */
-    public function index(Request $request)
-    {
-        //site标题
-        $title = $this->getSiteTitle($request);
-        //客服图片
-        $customer_service = $this->getCustomerServiceImg();
-        //活动配置
-        $activity_options = $this->activityOptions();
-        $url = $activity_options['url'];
-        $is_show_activity = $activity_options['is_show_activity'];
-        $activity_title = $activity_options['activity_title'];
-        $bottom_show_type = $activity_options['bottom_show_type'];
-        $activity_img = $activity_options['activity_img'];
-        //$user = $activity_options['user'];
-        $hidden_reader_menus = false;
-        $send_order_id = Cookie::get('send_order_id');
-        //隐藏阅读页面菜单
-        if($send_order_id && in_array($send_order_id,explode(',',env('HIDDEN_READER_MENUS')))){
-            $hidden_reader_menus = true;
-        }
-        $options = json_encode([
-            'distribution_channel_id' => (int)$this->distribution_channel_id,
-            'send_order_id' => $send_order_id,
-            'uid' => $this->uid,
-            'pay_url' => env('CREATE_PAY_URL'),
-            'title' => $title,
-            'kefu' => $customer_service,
-            'background' => env('WEB_READER_BACKGROUND'),
-            'font_size' => env('WEB_READER_FONT_SIZE'),
-            'page_style' => env('WEB_READER_PAGE_STYLE'),
-            'from' => Cookie::get('from') ? Cookie::get('from') : 'main',
-            'is_show_activity' => $is_show_activity,
-            'activity_url' => $url,
-            'activity_title' => $activity_title,
-            'bottom_show_type' => $bottom_show_type,
-            'activity_img' => $activity_img,
-            'special_bottom_sub_banner'=>'',
-            'hidden_reader_menus'=>$hidden_reader_menus
-        ]);
-        return view('wap.index', compact('options', 'title'));
-    }
-
-
-    /**
-     * 获取活动配置信息
-     */
-    private function activityOptions(){
-        $url = '';
-        $is_show_activity = 0;
-        $activity_title = '';
-        $bottom_show_type = 1;
-        $activity_img = '';
-        $user = $this->userInfo($this->uid);
-        $no_participate_activity = env('no_participate_activity','');
-        if($no_participate_activity && in_array($this->distribution_channel_id, explode(',',$no_participate_activity))){
-            return compact('url','is_show_activity','activity_title','bottom_show_type','activity_img','user');
-        }
-        $activity_setting = ActivityService::getActivitySetting();
-        $h5_scheme = env('H5_SCHEME', 'https');
-        if ($activity_setting) {
-            $activity_id = isset($activity_setting['activity_id']) ? $activity_setting['activity_id'] : 0;
-            $activity_info = Activity::find($activity_id);
-
-            if ($activity_info &&
-                time() > strtotime($activity_info->start_time) &&
-                time() < strtotime($activity_info->end_time) &&
-                $user &&
-                isset($user->created_at) &&
-                (time() - strtotime($user->created_at)) >= 86400 * 2
-            ) {
-                $activity_img = isset($activity_setting['wap_bottom_img']) ? $activity_setting['wap_bottom_img'] : '';
-                $url = $h5_scheme . '://' . _domain() . $activity_info->activity_page . '&fromtype=reader';
-                $activity_title = isset($activity_setting['activity_title']) ? $activity_setting['activity_title'] : '';
-                $is_show_activity = 1;
-                $bottom_show_type = 2;
-            }
-        }
-        return compact('url','is_show_activity','activity_title','bottom_show_type','activity_img','user');
-    }
-
-    /**
-     * 获取site标题
-     */
-    private function getSiteTitle(Request $request){
-        $title = "追书云";
-        $subscribe = $request->cookie('force_subscribe_name');
-        if ($subscribe) {
-            $title = $subscribe;
-        } else {
-            $res = OfficialAccountService::canUseOfficialAccountByChannelId(['distribution_channel_id' => $this->distribution_channel_id]);
-            if ($res && isset($res->nickname) && !empty($res->nickname)) {
-                Cookie::queue('force_subscribe_name', $res->nickname, 12 * 3600);
-                $title = $res->nickname;
-            }
-        }
-        return $title;
-    }
-
-    /**
-     * 获取客服图片
-     */
-    private function getCustomerServiceImg(){
-        $setting = CustomMsgService::customerImgUrlByChannelId($this->distribution_channel_id);
-        if ($setting && $setting->customer_img_url) {
-            $customer_service = $setting->customer_img_url;
-        } else {
-            $customer_service = "https://cdn-novel.iycdm.com/static/img/kefu20180724.jpg";
-        }
-        return $customer_service;
-    }
-}

+ 0 - 15
app/Http/Controllers/WapAlipay/apidoc.json

@@ -1,15 +0,0 @@
-{
-"name": "追书云h5平台接口",
-"version": "1.0.0",
-"description": "追书云h5平台接口",
-"title": "追书云h5平台接口",
-"url": "http://site1.test.zhuishuyun.com/api/",
-"template": {
-"withCompare": true,
-"withGenerator": true
-},
-"header": {
-    "title": "概述",
-    "filename": "header.md"
-  }
-}

+ 0 - 4
app/Http/Controllers/WapAlipay/header.md

@@ -1,4 +0,0 @@
-状态码:<br>
-
-	0:     正常
-    

+ 3 - 28
app/Modules/User/Models/UserSign.php

@@ -10,38 +10,13 @@ class UserSign extends Model
     protected $fillable = ['uid','price','day','sign_time'];
 
     public function setCurrentTable($time=''){
+        if($time == '201906'){
+            $time = '';
+        }
         if($time){
             $this->setTable('user_sign'.$time);
         }else{
             $this->setTable('user_sign');
         }
     }
-
-    /**
-     * 用户是否已签到
-     * @param $uid
-     * @param $day
-     * @return mixed
-     */
-    public static function isSign($uid,$day){
-        return self::where('uid',$uid)->where('day',$day)->first();
-    }
-
-    /**
-     * 签到
-     * @param $uid
-     * @param $day
-     * @return mixed
-     */
-    public static function sign($uid,$day,$fee){
-        $data = ['uid'=>$uid,'price'=>$fee,'day'=>$day,'sign_time'=>time()];
-        return self::create($data);
-    }
-
-    /**
-     * 用户签到记录
-     */
-    public static function getUserSignRecord($uid){
-        return self::where('uid',$uid)->where('day','<',date('Y-m-d'))->select('price','sign_time')->orderBy('sign_time','desc')->paginate();
-    }
 }

+ 10 - 43
app/Modules/User/Services/UserSignService.php

@@ -39,41 +39,14 @@ class UserSignService
         return false;
     }
 
-    /**
-     * 新用户首次签到获得书币调整为30书币,连续签到2天后,赠送书币量提升至50,断签后重新按30开始
-     * 用户是否已签到(升级版)
-     * @param $uid
-     * @param $day
-     * @return mixed
-     */
-    public static function isSigni($uid, $day)
-    {
-        $day_2 = date('Y-m-d', strtotime($day) - 86400 * 2);
-        $sign_stat = UserSign::where('uid', $uid)->where('day', '>=', $day_2)->select('day')->orderBy('id', 'desc')->limit(3)->get();
-
-        if (!$sign_stat->isEmpty()) {
-            $day_1 = date('Y-m-d', strtotime($day) - 86400);
-            $sign_day = [];
-            foreach ($sign_stat as $v) {
-                $sign_day[] = $v->day;
-            }
-            if (in_array($day, $sign_day)) {
-                return 0;
-            }
-            if (in_array($day_1, $sign_day) && in_array($day_2, $sign_day)) {
-                return 50;
-            }
-            return 30;
-        }
-        return 30;
-    }
 
     /**
      * 用户签到记录
      */
     public static function getUserSignRecord($uid)
     {
-        return UserSign::getUserSignRecord($uid);
+        $UserSignModel = new UserSign();
+        return $UserSignModel->where('uid',$uid)->where('day','<',date('Y-m-d'))->select('price','sign_time')->orderBy('sign_time','desc')->paginate();
     }
 
     /**
@@ -129,7 +102,10 @@ class UserSignService
             Redis::hset('user_sign:uid:info', $uid, json_encode($sign_data));
             ReadRecordService::setSignInfo($uid, json_encode($sign_data));
         } else {
-            UserSign::sign($uid, $day, $fee);
+            $user_sign_model = new UserSign();
+            $user_sign_model->setCurrentTable(date('Ym'));
+            $data = ['uid'=>$uid,'price'=>$fee,'day'=>$day,'sign_time'=>time()];
+            $user_sign_model->create($data);
         }
         return $return_fee;
     }
@@ -180,7 +156,10 @@ class UserSignService
             Redis::hset('user_sign:uid:info', $uid, json_encode($sign_data));
             ReadRecordService::setSignInfo($uid, json_encode($sign_data));
         } else {
-            UserSign::sign($uid, $day, $fee);
+            $user_sign_model = new UserSign();
+            $user_sign_model->setCurrentTable(date('Ym'));
+            $data = ['uid'=>$uid,'price'=>$fee,'day'=>$day,'sign_time'=>time()];
+            $user_sign_model->create($data);
         }
         return $fee;
     }
@@ -508,16 +487,4 @@ class UserSignService
 
         return false;
     }
-
-    /**
-     * 签到统计
-     */
-    public static function getSignTotalByChnnelId(array $data = [])
-    {
-        $search_obj = UserSign::join('users', 'user_sign.uid', '=', 'users.id');
-        if (isset($params['distribution_channel_id'])) $search_obj->where('users.distribution_channel_id', $params['distribution_channel_id']);
-        if (isset($params['begin_time']) && $params['begin_time']) $search_obj->where('user_sign.created_at', '>=', $params['begin_time']);
-        if (isset($params['end_time']) && $params['end_time']) $search_obj->where('user_sign.created_at', '<=', $params['end_time']);
-        return $search_obj->groupBy('user_sign.day', 'users.distribution_channel_id')->select(DB::raw('count(*) as sign_num'), DB::raw('user_sign.day as day'), 'users.distribution_channel_id')->get();
-    }
 }