one($id);
$info = Dever::db('agent/member')->find(array('mobile'=>$soft['mobile']));
if($info){
$update['where_id'] = $id;
$update['set_mid'] = $info['id'];
$update['set_role'] = $info['role'];
if (!$soft['order_num']) {
$update['set_order_num'] = $this->getOrderId($id);
}
if($cash){
$update['set_cash'] = $cash;
} else {
$cash = $soft['cash'];
}
if($price){
$update['set_price'] = $price;
}
if($pic){
$update['set_pic'] = $pic;
}
if($status){
$update['set_status'] = $status;
}
if($audit){
$update['set_audit'] = $audit;
}
if($audit_desc){
$update['set_audit_desc'] = $audit_desc;
}
if($soft){
if($audit == 3 ){
$update['set_status'] = 4;
} elseif($audit == 2){
$update['set_status'] = 3;
$update['set_zdate'] = time();
$order['role'] = $info['role'];
$order['soft_cash'] = $cash;
$order['price'] = $cash;
$order['cdate'] = $cdate;
$order['type'] = 3;
$order['sign'] = '';
$order['name'] = $info['name'];
$order['mobile'] = $info['mobile'];
$order['mid'] = $info['id'];
$order['id'] = $id;
$order['area'] = $info['area'];
$order['idcard'] = $info['idcard'];
$order['idcard_front'] = $info['idcard_front'];
$order['idcard_back'] = $info['idcard_back'];
$order['company_name'] = $info['company_name'];
$order['company_pic'] = $info['company_pic'];
// print_R($order);die;
$update['set_agreement_id'] = Dever::load('agent/lib/agreement')->up($order,1,3);
}
}
if (!$audit) {
if ($soft['status'] == 4) {
$update['status'] = 2;
}
}
if ($soft) {
if ($soft['audit_admin'] <1 || !$soft['audit_admin']) {
$admin = Dever::load('manage/auth.info');
$update['audit_admin'] = $admin['id'];
}
}
$ids=Dever::db('agent/soft_cash')->update($update);
}
}
public function admin_name($id)
{
if ($id < 1) {
return '';
} else {
$audit = Dever::db('manage/admin')->find($id);
// print_R($audit);die;
return $audit['username'];
}
}
public function getOrderId($id)
{
$order = Dever::order();
$info = Dever::db('agent/soft_cash')->one(array('order_num'=>$order));
if ($info) {
return $this->createOrderId($id);
} else {
return $order;
}
}
public function soft_show($id){
$info = Dever::db('agent/soft_cash')->find($id);
$html['num'] = $info['order_num'].''.date('Y-m-d',$info['buy_date']).'
'.date('Y-m-d',$info['cdate']);
return $html;
}
public function show(){
$id = Dever::input('id');
$info = Dever::db('agent/soft_cash')->one($id);
$member = Dever::db('agent/member')->one($info['mid']);
$type = Dever::db('agent/member')->config['config_type'];
$config_status = Dever::db('agent/soft_cash')->config['config_status'];
$status = Dever::status($config_status,$info['status']);
// print_R($status);die;
$buy_date = date('Y-m-d H:i',$info['buy_date']);
$role = Dever::db('setting/role')->one($member['role']);
$area = Dever::load("area/api.string", $member['area']);
$idcard_pic = '';
if ($member['idcard_back']) {
$idcard_pic .= '';
}
$picture = explode(',',$info['pic']);
$pic = '';
foreach ($picture as $k => $v){
$pic .= '';
}
$result['订单信息'] = array
(
'type' => 'info',
'content' => array
(
array
(
array('订单号', $info['order_num']),
array('订单状态', $status),
array('购买时间', $buy_date),
),
array
(
array('备注', $info['audit_desc']),
array('管理员备注', $info['admin_desc']),
// array('购买时间', $buy_date),
),
),
);
$result['代理商信息'] = array
(
'type' => 'info',
'content' => array
(
array
(
array('手机号', $member['mobile']),
array('名称', $member['name']),
array('类型', $type[$member['type']]),
),
array
(
array('代理商角色', $role['name']),
array('代理区域', $area),
array('身份证号', $member['idcard']),
),
array
(
array('身份证照片', $idcard_pic),
),
),
);
$result['费用信息'] = array
(
'type' => 'info',
'content' => array
(
array
(
array('软件服务费', $info['cash']),
array('原始期权价值', $info['price']),
),
array
(
array('支付凭证', $pic),
),
),
);
$button = $this->show_button($info);
if($info['status'] == 3 ){
$member_goods = Dever::db('agent/member_agreement')->find($info['agreement_id']);
if ($member_goods && $member_goods['sign']) {
$sign_pic = '';
} else {
$sign_pic = '暂无';
}
$this->show_agreement($info, $role, $sign_pic, $result);
}
$head = array
(
'name' => '基本信息',
'btn' => $button,
);
// $foot = $button;
$html = Dever::show($head, $result);
return $html;
}
public function show_button($info){
$button = array();
$purl = Dever::url('project/database/update?project=agent&table=soft_cash&where_id='.$info['id'].'&col=audit_desc', 'manage');
$button[] = array
(
'type' => 'edit',
'link' => $purl,
'name' => '备注',
);
$purl = Dever::url('project/database/update&project=agent&&page_type=2&table=soft_cash&menu=agent&search_option_state=1&where_id='.$info['id']);
if($info['status'] < 3 || $info['status'] == 4){
$button[] = array
(
'type' => 'edit',
'link' => $purl,
'name' => '修改信息',
);
}
$purl = Dever::url('project/database/update?project=agent&table=soft_cash&where_id='.$info['id'].'&audit=2&col=id,audit,audit_desc', 'manage');
// if($aduit)
if($info['status'] == 1){
$button[] = array
(
'type' => 'edit',
'link' => $purl,
'name' => '待业务初审',
);
}
$purl = Dever::url('project/database/update?project=agent&table=soft_cash&where_id='.$info['id'].'&audit=2&col=id,audit,audit_desc', 'manage');
if (Dever::load('manage/auth')->checkFunc('agent.soft_cash', 'edit1', '待财务终审')) {
if($info['status'] == 2){
$button[] = array
(
'type' => 'edit',
'link' => $purl,
'name' => '待财务终审',
);
}
}
$purl = Dever::url('project/database/update?project=agent&table=soft_cash&where_id='.$info['id'].'&audit=3&col=id,audit,audit_desc', 'manage');
if (Dever::load('manage/auth')->checkFunc('agent.soft_cash', 'edit2', '驳回')) {
if($info['status'] == 4){
}
}
if (Dever::load('manage/auth')->checkFunc('agent.soft_cash', 'close', '取消订单')) {
if ($info['status'] == 4) {
# 未完成审核的订单,可以随时挂起
$button[] = array
(
'type' => 'action',
'link' => Dever::url('lib/soft_cash.setOrderStatus?id=' . $info['id'] . '&value=4', 'agent'),
'name' => '取消订单',
);
}
}
$button[] = array
(
'type' => 'link',
'link' => 'refer',
'name' => '返回上一页',
);
return $button;
}
public function setOrderStatus_api()
{
$where['where_id'] = Dever::input('id');
$order = Dever::db('agent/soft_cash')->find($where['where_id']);
if ($order) {
$where['status'] = Dever::input('value');
if ($where['status'] == 4) {
$where['status'] = 5;
$where['state'] = 2;
}
// print_R($where);die;
Dever::db('agent/soft_cash')->update($where);
}
return 'reload';
}
private function show_agreement($info, $role, $sign_pic, &$result)
{
$table = array();
$table['head'] = array('合同类型', '合同名称', '合同签名', '合同状态');
$table['body'] = array();
$agreement_type = Dever::db('setting/agreement')->config['config_type'];
$agreement_status = Dever::db('agent/member_agreement')->config['status'];
if($info['status'] == 3 && $info['agreement_id']){
$agreement_title = '(已生成合同)';
$agreement_button = array();
$agreement = Dever::db('agent/member_agreement')->find(array('id' => $info['agreement_id']));
if($agreement){
$agreement_info = Dever::db('setting/agreement')->find($agreement['agreement_id']);
// print_r($agreement_info);die;
$agreement_status_name = Dever::status($agreement_status, $agreement['status']);
// echo dever::sql();die;
$table['body'] = array(Dever::status($agreement_type, $agreement_info['type']), Dever::load('agent/lib/agreement')->name($agreement_info, $agreement, $role, 2), $sign_pic, $agreement_status_name);
}else{
$agreement_title = '';
}
}
$result['生成软件服务合同' . $agreement_title] = array
(
'type' => 'table',
'head' => array('name' => ' ', 'btn' => $agreement_button),
'content' => $table
);
}
public function insertSoft($id,$name,$data){
$mobile = Dever::param('mobile',$data);
$member = Dever::db('agent/member')->find(array('mobile'=>$mobile));
if(!$member){
Dever::alert('代理商不存在');
}
}
public function search_api()
{
$value = Dever::input('value');
if(!preg_match('/^1[3|5|6|7|8|9]\d{9}$/', $value)){
return '代理商手机号不正确';
}
if ($value) {
$data = Dever::db('agent/member')->one(array('mobile' => $value,'state' =>1));
$table = array();
$table['body'] = array();
if ($data) {
$info = Dever::db('agent/soft_cash')->find(array('mobile'=>$value));
if ($info) {
$info['buy_date'] = '
'.date('Y-m-d H:i',$info['buy_date']).'
'; $table['head'] = array('序列号', '姓名', '手机号','上次购买时间'); $table['body'] = array($data['id'], $data['name'], $data['mobile'],$info['buy_date']); } else { $table['head'] = array('序列号', '姓名', '手机号'); $table['body'] = array($data['id'], $data['name'], $data['mobile']); } // $table['head'] = array('序列号', '姓名', '手机号','上次购买时间'); // $table['body'] = array($data['id'], $data['name'], $data['mobile']); // foreach ($data as $k => $v) { // $member = Dever::db('agent/member')->find($v['mid']); // $table['body'][] = array($k+1, $member['name'], $v['mobile']); // } $result[] = array ( 'type' => 'table', 'content' => $table, ); $html = Dever::show('', $result, false, false); return $html; }else{ return '代理商不存在'; // Dever::alert('代理商不存在'); } // Dever::alert('暂无账号'); // return '暂无账号'; } else { return ''; } } public function list($id){ $info = Dever::db('agent/soft_cash')->find(array('id'=>$id)); $config_status = Dever::db('agent/soft_cash')->config['config_status']; $data['status'] = Dever::status($config_status,$info['status'],true); $config_type = Dever::db('agent/soft_cash')->config['config_type']; $data['type'] = Dever::status($config_type,$info['type']); if($info['zdate']){ $data['zdate'] = date('Y-m-d H:i',$info['zdate']); }else{ $data['zdate'] = '-'; } if($info['fdate']){ $data['fdate'] = date('Y-m-d H:i',$info['fdate']); }else{ $data['fdate'] = '-'; } // print_R($data);die; $html = $data['status']; $html .= '