member_vr_buy.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <?php
  2. /**
  3. * 购买
  4. *
  5. *
  6. *
  7. *
  8. */
  9. //use Shopnc\Tpl;
  10. defined('InShopNC') or exit('Access Invalid!');
  11. class member_vr_buyControl extends mbMemberControl
  12. {
  13. public function __construct()
  14. {
  15. parent::__construct();
  16. }
  17. /**
  18. * 虚拟商品购买第一步,设置购买数量
  19. * POST
  20. * 传入:cart_id:商品ID,quantity:购买数量
  21. */
  22. public function buy_step1Op()
  23. {
  24. $_POST['goods_id'] = $_POST['cart_id'];
  25. $logic_buy_virtual = Logic('buy_virtual');
  26. $result = $logic_buy_virtual->getBuyStep2Data($_POST['goods_id'], $_POST['quantity'], $this->member_info['member_id']);
  27. if (!$result['state']) {
  28. output_error($result['msg']);
  29. } else {
  30. $result = $result['data'];
  31. }
  32. unset($result['member_info']);
  33. output_data($result);
  34. }
  35. /**
  36. * 虚拟商品购买第二步,设置接收手机号
  37. * POST
  38. * 传入:goods_id:商品ID,quantity:购买数量
  39. */
  40. public function buy_step2Op()
  41. {
  42. $token = trim($_GET['key']);
  43. if (false == $this->checkToken($token)) {
  44. return joutput_error($this->err_code);
  45. }
  46. $logic_buy_virtual = Logic('buy_virtual');
  47. $result = $logic_buy_virtual->getBuyStep2Data($_POST['goods_id'], $_POST['quantity'], $this->member_info['member_id']);
  48. if (!$result['state']) {
  49. output_error($result['msg']);
  50. } else {
  51. $result = $result['data'];
  52. $member_info = array();
  53. $member_info['member_mobile'] = $result['member_info']['member_mobile'];
  54. $member_info['available_predeposit'] = $result['member_info']['available_predeposit'];
  55. $member_info['available_rc_balance'] = $result['member_info']['available_rc_balance'];
  56. unset($result['member_info']);
  57. $result['member_info'] = $member_info;
  58. output_data($result);
  59. }
  60. }
  61. /**
  62. * 虚拟订单第三步,产生订单
  63. * POST
  64. * 传入:goods_id:商品ID,quantity:购买数量,buyer_phone:接收手机,buyer_msg:下单留言,pd_pay:是否使用预存款支付0否1是,password:支付密码
  65. */
  66. public function buy_step3Op()
  67. {
  68. $token = trim($_GET['key']);
  69. if (false == $this->checkToken($token)) {
  70. return joutput_error($this->err_code);
  71. }
  72. $logic_buy_virtual = Logic('buy_virtual');
  73. $input = array();
  74. $input['goods_id'] = $_POST['goods_id'];
  75. $input['quantity'] = $_POST['quantity'];
  76. $input['buyer_phone'] = $_POST['buyer_phone'];
  77. $input['buyer_msg'] = $_POST['buyer_msg'];
  78. //支付密码
  79. $input['password'] = $_POST['password'];
  80. //是否使用充值卡支付0是/1否
  81. $input['rcb_pay'] = intval($_POST['rcb_pay']);
  82. //是否使用预存款支付0是/1否
  83. $input['pd_pay'] = intval($_POST['pd_pay']);
  84. $input['order_from'] = 2;
  85. $result = $logic_buy_virtual->buyStep3($input, $this->member_info['member_id']);
  86. if (!$result['state']) {
  87. output_error($result['msg']);
  88. } else {
  89. output_data($result['data']);
  90. }
  91. }
  92. }