Cron.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <?php namespace Pay\Yspay;
  2. use Dever;
  3. class Cron
  4. {
  5. # 定时更新银联账户余额信息
  6. public function account_api()
  7. {
  8. # 获取有银联商户号的门店
  9. $where = array();
  10. $mid = Dever::input('mid');
  11. if ($mid) {
  12. $where['mid'] = $mid;
  13. }
  14. $merchant = Dever::db('pay/yspay_merchant')->select($where);
  15. if (!$merchant) {
  16. return 'error';
  17. }
  18. foreach ($merchant as $k => $v) {
  19. if ($v['mid']) {
  20. $config = Dever::db('pay/yspay')->one(array('account_id' => $v['account_id']));
  21. if ($config['type'] == 1) {
  22. $data = Dever::load('pay/yspay/account')->query($v['mid']);
  23. $update['where_id'] = $v['id'];
  24. $update['yue'] = $data;
  25. Dever::db('pay/yspay_merchant')->update($update);
  26. }
  27. }
  28. }
  29. return 'ok';
  30. }
  31. # 查询余额
  32. public function yue_api()
  33. {
  34. # 获取有银联商户号的门店
  35. $where = array();
  36. $where['mid'] = Dever::input('mid');
  37. $merchant = Dever::db('pay/yspay_merchant')->find($where);
  38. $config = Dever::db('pay/yspay')->one(array('account_id' => $merchant['account_id']));
  39. $data = Dever::load('pay/yspay/multi')->yue($config, $merchant);
  40. return $data;
  41. }
  42. # 定时获取银联提现信息
  43. public function tixian_api()
  44. {
  45. $num = Dever::input('num', 1);
  46. $start = Dever::input('start', date('Ymd', strtotime('-'.$num.' day')));
  47. $end = Dever::input('end', date('Ymd'));
  48. # 获取有银联商户号的门店
  49. $where = array();
  50. $mid = Dever::input('mid');
  51. if ($mid) {
  52. $where['mid'] = $mid;
  53. }
  54. $test = Dever::input('test');
  55. $merchant = Dever::db('pay/yspay_merchant')->select($where);
  56. if (!$merchant) {
  57. return 'error';
  58. }
  59. foreach ($merchant as $k => $v) {
  60. if ($v['mid']) {
  61. $data = Dever::load('pay/yspay/account')->record($v['mid'], $start, $end);
  62. if ($data) {
  63. if ($test == 1) {
  64. print_r($data);die;
  65. }
  66. foreach ($data as $k1 => $v1) {
  67. $update = array();
  68. $update['merchant_id'] = $v['id'];
  69. $update['type'] = $v1['trxTypeDtl'];
  70. $update['tdate'] = Dever::maketime($v1['trxTime']);
  71. $update['mid'] = $v1['mchntNo'];
  72. $update['cardNo'] = $v1['cardNo'];
  73. $update['order_num'] = $v1['sysOrderId'];
  74. $update['status'] = $v1['status'];
  75. $update['clear'] = true;
  76. $info = Dever::db('pay/yspay_tixian')->one($update);
  77. $update['cash'] = $v1['transAmt'];
  78. if (!$info) {
  79. Dever::db('pay/yspay_tixian')->insert($update);
  80. } else {
  81. $update['where_id'] = $info['id'];
  82. Dever::db('pay/yspay_tixian')->update($update);
  83. }
  84. $total = Dever::db('pay/yspay_tixian')->getTotal(array('shop_id' => $v['id'], 'status' => 4));
  85. if ($total) {
  86. $account_data['tx_cash'] = $total['cash'];
  87. $account_data['where_id'] = $v['id'];
  88. Dever::db('pay/yspay_merchant')->update($account_data);
  89. }
  90. }
  91. }
  92. }
  93. }
  94. return 'ok';
  95. }
  96. # 退款
  97. public function tui_api()
  98. {
  99. $order_num = Dever::input('order_num');
  100. $cash = Dever::input('cash');
  101. $param = array
  102. (
  103. 'project_id' => 2,
  104. 'channel_id' => 1,
  105. 'system_source' => 5,
  106. 'account_id' => 7,
  107. 'order_id' => $order_num,
  108. 'refund_cash' => $cash,
  109. //'refund_order_id' => '',
  110. );
  111. $result = Dever::load('pay/api.refund', $param);
  112. print_r($result);die;
  113. }
  114. }