notify.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. /**
  3. * [WeEngine System] Copyright (c) 2014 WE7.CC
  4. * WeEngine is NOT a free software, it under the license terms, visited http://www.we7.cc/ for more details.
  5. */
  6. define('IN_MOBILE', true);
  7. require '../../framework/bootstrap.inc.php';
  8. $_GPC['i'] = !empty($_GPC['i']) ? intval($_GPC['i']) : intval($_GET['extra']);
  9. require '../../app/common/bootstrap.app.inc.php';
  10. load()->app('template');
  11. load()->web('common');
  12. load()->classs('coupon');
  13. $_W['uniacid'] = $_W['weid'] = intval($_GPC['i']);
  14. $_W['uniaccount'] = $_W['account'] = uni_fetch($_W['uniacid']);
  15. $_W['acid'] = $_W['uniaccount']['acid'];
  16. $setting = uni_setting($_W['uniacid'], array('payment'));
  17. if(!is_array($setting['payment'])) {
  18. exit('没有设定支付参数.');
  19. }
  20. $payment = $setting['payment']['baifubao'];
  21. require 'bfb_sdk.php';
  22. $bfb_sdk = new bfb_sdk();
  23. if (!empty($_GPC['pay_result']) && $_GPC['pay_result'] == '1') {
  24. if (true === $bfb_sdk->check_bfb_pay_result_notify()) {
  25. $sql = 'SELECT * FROM ' . tablename('core_paylog') . ' WHERE `uniontid`=:uniontid';
  26. $params = array();
  27. $params[':uniontid'] = $_GPC['order_no'];
  28. WeUtility::logging('pay', var_export($_GPC, true));
  29. $log = pdo_fetch($sql, $params);
  30. if(!empty($log) && $log['status'] == '0' && (($_GPC['total_amount'] / 100) == $log['card_fee'])) {
  31. $log['tag'] = iunserializer($log['tag']);
  32. $log['tag']['bfb_order_no'] = $_POST['bfb_order_no'];
  33. $record = array();
  34. $record['status'] = 1;
  35. $record['tag'] = iserializer($log['tag']);
  36. pdo_update('core_paylog', $record, array('plid' => $log['plid']));
  37. if ($log['is_usecard'] == 1 && !empty($log['encrypt_code'])) {
  38. $coupon_info = pdo_get('coupon', array('id' => $log['card_id']), array('id'));
  39. $coupon_record = pdo_get('coupon_record', array('code' => $log['encrypt_code'], 'status' => '1'));
  40. load()->model('activity');
  41. $status = activity_coupon_use($coupon_info['id'], $coupon_record['id'], $log['module']);
  42. }
  43. $site = WeUtility::createModuleSite($log['module']);
  44. if(!is_error($site)) {
  45. $method = 'payResult';
  46. if (method_exists($site, $method)) {
  47. $ret = array();
  48. $ret['weid'] = $log['uniacid'];
  49. $ret['uniacid'] = $log['uniacid'];
  50. $ret['result'] = 'success';
  51. $ret['type'] = $log['type'];
  52. $ret['from'] = 'notify';
  53. $ret['tid'] = $log['tid'];
  54. $ret['uniontid'] = $log['uniontid'];
  55. $ret['user'] = $log['openid'];
  56. $ret['fee'] = $log['fee'];
  57. $ret['tag'] = $log['tag'];
  58. $site->$method($ret);
  59. $bfb_sdk->notify_bfb();
  60. exit('success');
  61. }
  62. }
  63. }
  64. }
  65. }
  66. $bfb_sdk->notify_bfb();
  67. exit('fail');