Recharge.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. /**
  3. * 前台书籍控制器
  4. */
  5. namespace app\clientweb\controller;
  6. use app\common\controller\ClientWeb;
  7. use app\main\constants\ClientWebConstants;
  8. use app\main\constants\PayConstants;
  9. use app\main\service\AdminService;
  10. use app\main\service\FinancialService;
  11. use app\main\service\WebUserService;
  12. use think\Config;
  13. use think\Url;
  14. class Recharge extends ClientWeb
  15. {
  16. public function pay(){
  17. if(!$this->isLogin){
  18. $this->redirect('Bindphone/register',['action'=>ClientWebConstants::REDIRECT_ACTION_RECHARGE]);
  19. }
  20. $this->userInfo = WebUserService::instance()->getUserInfo();
  21. $uid = $this->userInfo->id;
  22. $kandian = FinancialService::instance()->getTotalKandianAndFreeKandian($uid)->data;
  23. $is_test = AdminService::instance()->checkIsTestChannel($this->userInfo->agent_id,$this->userInfo->channel_id);
  24. $list = model('Goods')->getGoodsList(PayConstants::BUSINESS_APP, PayConstants::GOODS_CATEGORY_RECHARGE, null, $is_test, $this->userInfo->is_pay);
  25. $pay_list = model('Wxpay')->getListByBusiness(PayConstants::BUSINESS_APP);
  26. if ($this->request->has('book_id')) {
  27. $book_id = $this->request->get('book_id');
  28. $bookInfo = model('Book')->BookInfo($book_id);
  29. if ($bookInfo) {
  30. if ($bookInfo['billing_type'] == 2 && $bookInfo['price'] > 0) { //按本收费
  31. $this->assign('bookBillingTip', '本书是VIP书籍(' . $bookInfo['price'] . '书币/本)');
  32. } elseif ($bookInfo['price'] > 0) { //按章收费,且自定义了价格
  33. $this->assign('bookBillingTip', '本章是VIP章节(' . $bookInfo['price'] . '书币/章)');
  34. } else { //按章收费,默认价格
  35. $this->assign('bookBillingTip', '本章是VIP章节(' . Config::get('site.book_chapter_price') . '书币/章)');
  36. }
  37. }
  38. }
  39. $this->assign('select_goods_id', $this->request->param('goods_id')??0);
  40. $this->assign('list', $list);
  41. $this->assign('business_line', PayConstants::BUSINESS_APP);
  42. $this->assign('user', $this->userInfo->toArray());
  43. $this->assign('kandian', $kandian);
  44. $this->assign('channel_id', $this->userInfo->channel_id);
  45. $this->assign('recent_url', Url::build('/index/user/recent', null, true));
  46. $this->assign('pay_list', $pay_list);
  47. return $this->view->fetch();
  48. }
  49. }