You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

85 lines
2.6 KiB

  1. <?php
  2. /**
  3. *
  4. * ============================================================================
  5. * * 版权所有 蜘蛛出行 * *
  6. * 网站地址: http://www.zhizhuchuxing.com
  7. * ----------------------------------------------------------------------------
  8. * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和
  9. * 使用;不允许对程序代码以任何形式任何目的的再发布。
  10. * ============================================================================
  11. * Author By: 倪宗锋
  12. * PhpStorm AliPayController.php
  13. * Create By 2016/12/12 11:13 $
  14. */
  15. namespace Alipay\Controller;
  16. use Base\Tool\AliPayService;
  17. class AliPayController
  18. {
  19. public function indexAction()
  20. {
  21. //交易参数
  22. $params['body'] = '购买测试商品900元';
  23. $params['subject'] = '测试';
  24. $params['order_id'] = time() . rand(100, 999);
  25. $params['price'] = '900';
  26. $params['timeout_express'] = '1m';
  27. $params['goType'] = 1;
  28. $params['method'] = 'alipay.trade.wap.pay';
  29. $getUrl = AliPayService::getAliPayUrl($params, 1);
  30. // return $getUrl['data'];
  31. header('location:' . $getUrl['url']);
  32. return;
  33. }
  34. /**
  35. * Function Description:取消订单
  36. * Function Name: cancelOrderAction
  37. *
  38. * @return array
  39. *
  40. * @author 倪宗锋
  41. */
  42. public function cancelOrderAction()
  43. {
  44. $params = array(
  45. 'out_trade_no' => '1481598211483',//订单号
  46. 'refund_amount' => '900',//金额
  47. 'refund_reason' => '正常退款',//退款原因
  48. 'method' => 'alipay.trade.refund'//
  49. );
  50. $result = AliPayService::cancelOrder($params);
  51. return json_encode($result);
  52. }
  53. public function orderRturnAction()
  54. {
  55. $arr = $_POST;
  56. $get = json_encode($arr);
  57. $logs = date('Y-m-d H:i:s') . ' get: ' . $get . PHP_EOL;
  58. file_put_contents(ROOT_PATH . '/data/log/curl/' . date('Y-m-d') . '.log', $logs . PHP_EOL, FILE_APPEND);
  59. return true;
  60. }
  61. public function testAction()
  62. {
  63. $total=20;//红包总金额
  64. $num=10;// 分成10个红包,支持10人随机领取
  65. $min=0.01;//每个人最少能收到0.01元
  66. for ($i=1;$i<$num;$i++)
  67. {
  68. $safe_total=($total-($num-$i)*$min)/($num-$i);//随机安全上限
  69. $money=mt_rand($min*100,$safe_total*100)/100;
  70. $total=$total-$money;
  71. echo '第'.$i.'个红包:'.$money.' 元,余额:'.$total.' 元 ';
  72. }
  73. echo '第'.$num.'个红包:'.$total.' 元,余额:0 元';
  74. }
  75. }