123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203 |
- <?php namespace Pay\Yspay;
- use Dever;
- class Merchant
- {
- public function selectRelate_api()
- {
- $value = Dever::input('value');
- $id = Dever::input('id');
- $data = array();
- if ($id) {
- $data = Dever::db('pay/yspay_merchant')->find($id);
- if ($value != $data['project_id']) {
- $data['relate_id'] = -1;
- }
- }
-
- $config['relate_id'] = Dever::db('pay/yspay_merchant')->config['struct']['relate_id'];
- $config['relate_id']['update'] = 'select';
- $config['relate_id']['update_search'] = 'pay/yspay/merchant.search?project_id=' . $value;
- $result = Dever::load('manage/database')->update_struct(array('struct' => $config), false, $data, -1, '', true);
- return $result;
- }
- public function search_api()
- {
- $id = Dever::input('id');
- $keyword = Dever::input('keyword');
- $where = array();
- if ($keyword) {
- $where['name'] = $keyword;
- }
- $id = Dever::input('where_id');
- if ($id) {
- $where['id_no'] = $id;
- }
- $project_id = Dever::input('project_id', 1);
- $project = Dever::db('pay/yspay_project')->find($project_id);
- return Dever::search($project['table'], $where);
- }
- public function up($account_id, $project_id, $id, $name)
- {
- $data = array();
- $data['account_id'] = $account_id;
- $data['project_id'] = $project_id;
- $data['relate_id'] = $id;
- $info = Dever::db('pay/yspay_merchant')->find($data);
- if (!$info) {
- $data['name'] = $name;
- $data['type'] = 1;
- $data['status'] = 2;
- return Dever::db('pay/yspay_merchant')->insert($data);
- }
- return false;
- }
- public function getOther($account_id, $table, $relate_id, $order_num, $cash, $fenzhang = 0)
- {
- $result = array();
- $yspay = Dever::db('pay/yspay')->find(array('account_id' => $account_id));
- if ($cash && $cash > 0 && $yspay && $yspay['type'] == 2) {
- # 分账拆单
- $merchant = array();
- if ($table == 2) {
- $merchant = Dever::db('pay/yspay_merchant')->find(array('account_id' => $account_id, 'type' => 2));
- if (strstr($order_num, '_')) {
- $temp = explode('_', $order_num);
- $order_num = $temp[0];
- }
- $order_num .= '_O';
- } else {
- $project = Dever::db('pay/yspay_project')->find(array('table' => $table));
- if ($project) {
- $merchant = Dever::db('pay/yspay_merchant')->find(array('account_id' => $account_id, 'project_id' => $project['id'], 'relate_id' => $relate_id));
- }
- }
- if ($merchant && $merchant['mid']) {
- $result = array(
- 'merchant_id' => $merchant['id'],
- 'mid' => $merchant['mid'],
- 'order_id' => $order_num,
- 'amount' => $cash,
- 'fenzhang' => $fenzhang,
- );
- }
-
- }
- return $result;
- }
- public function getInfo($account_id, $project_id, $id, $parent, $array = false)
- {
- list($project, $table) = explode('/', $parent);
- $where = array();
- $where['account_id'] = $account_id;
- $where['project_id'] = $project_id;
- $where['relate_id'] = $id;
- $data = Dever::db('pay/yspay_merchant')->find($where);
- if ($array) {
- return $data;
- }
- $html = '';
- if ($data) {
- if (!$data['mid']) {
- $data['mid'] = '编辑信息';
- }
- $url = Dever::url('project/database/update?project=pay&table=yspay_merchant&set=1&where_id='.$data['id'], 'manage');
- $html .= '<a style="cursor:pointer" onclick="fastEdit($(this),\''.$url.'\',\'编辑信息\', \'\')">'.$data['mid'].'</a>';
- $step = false;
- if ($data['status'] == 2) {
- $sign = Dever::db('pay/yspay_sign')->one(array('merchant_id' => $data['id']));
- if ($sign && $sign['step']) {
- $step = $sign['step'];
- }
- }
-
- if ($data['status'] == 1) {
- $url = Dever::url('project/database/list?project=pay&table=yspay_cash&search_option_merchant_id='.$data['id'].'&search_option_account_id='.$data['account_id'].'&oper_table='.$table.'&oper_project=' . $project, 'manage');
- $html .= ' <a style="cursor:pointer" href="'.$url.'">[资金流水]</a>';
- }
- if ($data['status'] == 2) {
- $url = Dever::url('project/database/update?project=pay&table=yspay_sign&search_option_merchant_id='.$data['id'].'&search_option_account_id='.$data['account_id'].'&where_id='.$data['id'].'&oper_table='.$table.'&oper_project=' . $project, 'manage');
- $html .= ' <a style="cursor:pointer" onclick="fastEdit($(this),\''.$url.'\',\'签约资料\', \'\')">[签约资料]</a>';
- if ($step == -1) {
- $content = '';
- $title = '';
- $url = Dever::url('pay/yspay/sign.handle?sign_id=' . $data['id']);
- $html .= ' <a style="cursor:pointer" href="javascript:;" onclick="load(\'' . $url . '\', \'' . $content . '\', \'' . $title . '\')">[签约提审]</a>';
- }
- if ($step == 2) {
- $url = Dever::url('project/database/update?project=pay&table=yspay_sign&col=cashwhere_id='.$data['id'], 'manage');
- $html .= ' <a style="cursor:pointer" onclick="fastEdit($(this),\''.$url.'\',\'签约打款\', \'\')">[签约打款]</a>';
- }
- if ($step == 4) {
- $url = Dever::load('pay/yspay/sign.getAgreement', $data['id']);
- $html .= ' <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>';
- }
- }
- return $html;
- } else {
- return '暂无';
- }
- }
- public function log($merchant_id, $account_id, $type, $cash, $name)
- {
- $merchant = Dever::db('pay/yspay_merchant')->one(array('id' => $merchant_id, 'clear' => true));
- if ($merchant) {
- if (!$merchant['hf_cash']) {
- $merchant['hf_cash'] = $cash;
- }
- $yue = $merchant['hf_cash'] - $merchant['hf_tx_cash'];
- $data = array();
- $data['account_id'] = $account_id;
- $data['merchant_id'] = $merchant_id;
- $data['type'] = $type;
- $data['cash'] = $cash;
- $data['yue'] = $yue;
- $data['name'] = $name;
- Dever::db('pay/yspay_merchant_log')->insert($data);
- }
- }
- # 更新提现状态
- public function updateLog($id, $name, $data)
- {
- $tixian_status = Dever::param('tixian_status', $data);
- if ($tixian_status) {
- $info = Dever::db('pay/yspay_merchant_log')->one($id);
- if ($info) {
- if ($tixian_status == 1) {
- $cash = $info['cash'];
- } else {
- $cash = $info['cash'] * -1;
- }
-
- Dever::db('pay/yspay_merchant')->updateTxCash(array('where_id' => $info['merchant_id'], 'hf_tx_cash' => $cash));
- }
- }
- }
- # 检测提现状态
- public function checkTixian()
- {
- $where['type'] = 3;
- $where['tixian_status'] = 2;
- $data = Dever::db('pay/yspay_merchant_log')->select($where);
- if ($data) {
- foreach ($data as $k => $v) {
-
- }
- }
- }
- }
|