Wxpay.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Bear
  5. * Date: 2019/4/9
  6. * Time: 下午7:40
  7. */
  8. namespace app\clientwebapi\controller;
  9. use app\common\controller\ClientWebApi;
  10. use app\main\service\AdminService;
  11. use app\main\service\WebUserService;
  12. use app\main\service\WxH5PayService;
  13. class Wxpay extends ClientWebApi
  14. {
  15. public function pay()
  16. {
  17. if (!WebUserService::instance()->getUserInfo()->id) {
  18. $this->error("请登录后重试");
  19. }
  20. $goods_id = $this->request->request('id');
  21. $category = $this->request->request('category');
  22. if(!$goods_id || !$category){
  23. $this->error("参数错误");
  24. }
  25. $channel_id = WebUserService::instance()->getUserInfo()->channel_id;
  26. $adminInfo = AdminService::instance()->getAdminConfigModel()->getAdminInfo($channel_id);
  27. $wxpayid = $adminInfo['wxpay_id'];
  28. $platformid = $adminInfo['platform_id'];
  29. $result = WxH5PayService::instance()->getPayUrl($goods_id, $category, $platformid, $wxpayid);
  30. return redirect($result->data);
  31. }
  32. }