Merchant.php 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <?php namespace Pay\Yspay;
  2. use Dever;
  3. class Merchant
  4. {
  5. public function selectRelate_api()
  6. {
  7. $value = Dever::input('value');
  8. $id = Dever::input('id');
  9. $data = array();
  10. if ($id) {
  11. $data = Dever::db('pay/yspay_merchant')->find($id);
  12. if ($value != $data['project_id']) {
  13. $data['relate_id'] = -1;
  14. }
  15. }
  16. $config['relate_id'] = Dever::db('pay/yspay_merchant')->config['struct']['relate_id'];
  17. $config['relate_id']['update'] = 'select';
  18. $config['relate_id']['update_search'] = 'pay/yspay/merchant.search?project_id=' . $value;
  19. $result = Dever::load('manage/database')->update_struct(array('struct' => $config), false, $data, -1, '', true);
  20. return $result;
  21. }
  22. public function search_api()
  23. {
  24. $id = Dever::input('id');
  25. $keyword = Dever::input('keyword');
  26. $where = array();
  27. if ($keyword) {
  28. $where['name'] = $keyword;
  29. }
  30. $id = Dever::input('where_id');
  31. if ($id) {
  32. $where['id_no'] = $id;
  33. }
  34. $project_id = Dever::input('project_id', 1);
  35. $project = Dever::db('pay/yspay_project')->find($project_id);
  36. return Dever::search($project['table'], $where);
  37. }
  38. public function up($account_id, $project_id, $id, $name)
  39. {
  40. $data = array();
  41. $data['account_id'] = $account_id;
  42. $data['project_id'] = $project_id;
  43. $data['relate_id'] = $id;
  44. $info = Dever::db('pay/yspay_merchant')->find($data);
  45. if (!$info) {
  46. $data['name'] = $name;
  47. $data['type'] = 1;
  48. $data['status'] = 2;
  49. return Dever::db('pay/yspay_merchant')->insert($data);
  50. }
  51. return false;
  52. }
  53. public function getInfo($account_id, $project_id, $id, $parent)
  54. {
  55. $table = array();
  56. $table['head'] = array('银联商户号', '操作');
  57. $table['body'] = array();
  58. $where = array();
  59. $where['account_id'] = $account_id;
  60. $where['project_id'] = $project_id;
  61. $where['relate_id'] = $id;
  62. $data = Dever::db('pay/yspay_merchant')->select($where);
  63. if ($data) {
  64. foreach ($data as $k => $v) {
  65. $status_name = '已签约';
  66. $step = false;
  67. if ($v['status'] == 2) {
  68. $status_name = '未签约';
  69. $sign = Dever::db('pay/yspay_sign')->one(array('merchant_id' => $v['id']));
  70. if ($sign && $sign['step']) {
  71. $step = $sign['step'];
  72. }
  73. }
  74. $url = Dever::url('project/database/update?project=pay&table=yspay_merchant&set=1&where_id='.$v['id'], 'manage');
  75. $oper = '<a class="layui-btn" onclick="fastEdit($(this),\''.$url.'\',\'编辑信息\', \'\')">编辑</a>';
  76. if ($v['status'] == 1) {
  77. $url = Dever::url('project/database/list?project=pay&table=yspay_cash&search_option_merchant_id='.$v['id'].'&search_option_account_id='.$v['account_id'].'&parent='.$parent, 'manage');
  78. $oper .= '<a class="layui-btn" href="'.$url.'">资金流水</a>';
  79. }
  80. if ($v['status'] == 2) {
  81. $url = Dever::url('project/database/update?project=pay&table=yspay_sign&search_option_merchant_id='.$v['id'].'&search_option_account_id='.$v['account_id'].'&where_id='.$v['id'].'&parent='.$parent, 'manage');
  82. $oper .= '<a class="layui-btn" onclick="fastEdit($(this),\''.$url.'\',\'签约资料\', \'\')">签约资料</a>';
  83. if ($step == -1) {
  84. $content = '';
  85. $title = '';
  86. $url = Dever::url('pay/yspay/sign.handle?sign_id=' . $v['id']);
  87. $oper .= '<a class="layui-btn"href="javascript:;" onclick="load(\'' . $url . '\', \'' . $content . '\', \'' . $title . '\')">签约提审</a>';
  88. }
  89. if ($step == 2) {
  90. $url = Dever::url('project/database/update?project=pay&table=yspay_sign&col=cashwhere_id='.$v['id'], 'manage');
  91. $oper = '<a class="layui-btn" onclick="fastEdit($(this),\''.$url.'\',\'签约打款\', \'\')">签约打款</a>';
  92. }
  93. if ($step == 4) {
  94. $url = Dever::load('pay/yspay/sign.getAgreement', $v['id']);
  95. $oper .= '<a style="cursor:pointer" data-clipboard-text="'.$url.'" class="clipboard"><button type="button" class="btn btn-info btn-rounded waves-effect waves-light m-b-5 ">签约合同</button></a>';
  96. }
  97. }
  98. $table['body'][$k][] = $v['mid'];
  99. $table['body'][$k][] = $oper;
  100. }
  101. }
  102. $body[''] = array
  103. (
  104. 'type' => 'table',
  105. 'content' => $table,
  106. );
  107. if ($table['body']) {
  108. return Dever::show('', $body);
  109. } else {
  110. return '暂无';
  111. }
  112. }
  113. }