|
@@ -3,10 +3,34 @@
|
|
|
namespace Active\Lib;
|
|
|
|
|
|
use Dever;
|
|
|
-Class Manage {
|
|
|
+Class Manage
|
|
|
+{
|
|
|
|
|
|
- public function refund_api($id){
|
|
|
+ public function refund_api($id)
|
|
|
+ {
|
|
|
$data = Dever::db('active/order')->find($id);
|
|
|
+ if ($data['mid'] && $data['mid'] > 0) {
|
|
|
+ $user = Dever::db('active/user')->find(array('mid'=>$data['mid']));
|
|
|
+ if ($user && $user['id']) {
|
|
|
+ $uid = $user['id'];
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ $uid = $data['uid'];
|
|
|
+ }
|
|
|
+ $active = Dever::db('active/info')->find($data['active_id']);
|
|
|
+ if (time() > $active['act_start']) {
|
|
|
+ Dever::alert('活动已开始,不能退款');
|
|
|
+ }
|
|
|
+ $code = Dever::db('active/code')->state(array('order_id'=>$data['id'],'buy_uid'=>$uid));
|
|
|
+ $icode = Dever::db('active/code')->state(array('order_id'=>$data['id'],'buy_uid'=>$uid,'status'=>1));
|
|
|
+ $count = count($code);
|
|
|
+ $num = $data['num'] - $count;
|
|
|
+ if ($count == 0 ) {
|
|
|
+ $price = $data['price'];
|
|
|
+ } elseif ( $count > 0 && $num > 0) {
|
|
|
+ $inum = count($icode);
|
|
|
+ $price = ($num + $inum) * $active['price'];
|
|
|
+ }
|
|
|
$param = array
|
|
|
(
|
|
|
'project_id' => 6,
|
|
@@ -14,13 +38,14 @@ Class Manage {
|
|
|
'system_source' => 1,
|
|
|
'account_id' => 8,
|
|
|
'order_id' => $data['order_num'],
|
|
|
- 'refund_cash' => $data['price'],
|
|
|
+ 'refund_cash' => $price,
|
|
|
|
|
|
);
|
|
|
- if($data['status'] != 2){
|
|
|
+ if ($data['status'] != 2) {
|
|
|
Dever::alert('此状态下不可退款');
|
|
|
}
|
|
|
|
|
|
+
|
|
|
if ($data['price'] > 0) {
|
|
|
$result = Dever::load('pay/api.refund', $param);
|
|
|
|
|
@@ -28,16 +53,86 @@ Class Manage {
|
|
|
|
|
|
|
|
|
Dever::alert('退款失败,请联系管理员');
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
$admin = Dever::load('manage/auth.data');
|
|
|
$time = time();
|
|
|
- Dever::db('active/order')->update(array('where_id'=>$id,'set_status'=>6,'set_refund_admin'=>$admin['id'],'set_rdate'=>$time));
|
|
|
+ if ($price == $data['price']) {
|
|
|
+ Dever::db('active/order')->update(array('where_id'=>$id,'set_status'=>6,'set_refund_admin'=>$admin['id'],'set_rdate'=>$time));
|
|
|
+ } else {
|
|
|
+ Dever::db('active/order')->update(array('where_id'=>$id,'set_status'=>5,'set_refund_admin'=>$admin['id'],'set_rdate'=>$time));
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
return 'reload';
|
|
|
}
|
|
|
+ public function insertInfoRefund ($id,$name,$data)
|
|
|
+ {
|
|
|
+ $num = Dever::param('num',$data);
|
|
|
+ $order_id = Dever::param('order_id',$data);
|
|
|
+ $data = Dever::db('active/order')->find($order_id);
|
|
|
+ if($num > $data['num']) {
|
|
|
+ Dever::alert('退款数量大于购买数量');
|
|
|
+ }
|
|
|
+ $info = Dever::db('active/info_refund')->state(array('order_id'=>$order_id));
|
|
|
+ $count = $data['num'] - count($info);
|
|
|
+ if ($num > $count) {
|
|
|
+ Dever::alert('退款数量大于购买数量');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public function updateInfoRefund ($id,$name,$data)
|
|
|
+ {
|
|
|
+ $num = Dever::param('num',$data);
|
|
|
+ $order_id = Dever::param('order_id',$data);
|
|
|
+ $data = Dever::db('active/order')->find($order_id);
|
|
|
+ $info = Dever::db('active/info_refund')->state(array('order_id'=>$order_id));
|
|
|
+ $active = Dever::db('active/info')->find($data['active_id']);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ $price = $num * $active['price'];
|
|
|
+ $refund_num = $data['order_num'] . '_' . count($info);
|
|
|
+ $param = array
|
|
|
+ (
|
|
|
+ 'project_id' => 6,
|
|
|
+ 'channel_id' => 1,
|
|
|
+ 'system_source' => 1,
|
|
|
+ 'account_id' => 8,
|
|
|
+ 'order_id' => $data['order_num'],
|
|
|
+ 'refund_cash' => $price,
|
|
|
+ 'refund_order_id' => $refund_num,
|
|
|
+ );
|
|
|
+ if ($data['status'] != 2) {
|
|
|
+ Dever::alert('此状态下不可退款');
|
|
|
+ }
|
|
|
+ if ($price > 0) {
|
|
|
+ $result = Dever::load('pay/api.refund', $param);
|
|
|
+
|
|
|
+ if (!$result) {
|
|
|
+
|
|
|
+
|
|
|
+ Dever::alert('退款失败,请联系管理员');
|
|
|
+ } else {
|
|
|
+
|
|
|
+ $admin = Dever::load('manage/auth.data');
|
|
|
+ $time = time();
|
|
|
+ if ($price == $data['price']) {
|
|
|
+ Dever::db('active/order')->update(array('where_id'=>$id,'set_status'=>6,'set_refund_admin'=>$admin['id'],'set_rdate'=>$time));
|
|
|
+ } else {
|
|
|
+ Dever::db('active/order')->update(array('where_id'=>$id,'set_status'=>5,'set_refund_admin'=>$admin['id'],'set_rdate'=>$time));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return 'reload';
|
|
|
+ }
|
|
|
|
|
|
- public function show($id){
|
|
|
+ public function show($id)
|
|
|
+ {
|
|
|
$data = Dever::db('active/order')->find($id);
|
|
|
$refund_admin = '-';
|
|
|
$rdate = '-';
|
|
@@ -47,7 +142,284 @@ Class Manage {
|
|
|
$rdate = date('Y-m-d H:i',$data['rdate']);
|
|
|
}
|
|
|
$html = $refund_admin.'<br/>'.$rdate;
|
|
|
-
|
|
|
return $html;
|
|
|
}
|
|
|
+
|
|
|
+ public function active($id)
|
|
|
+ {
|
|
|
+ $data = Dever::db('active/info')->find($id);
|
|
|
+ $html = array();
|
|
|
+ $html['active_name'] = $data['name'];
|
|
|
+ $info = Dever::db('active/code')->find($id);
|
|
|
+ if ($info && isset($info['audit_admin']) && $info['audit_admin'] && $info['audit_admin'] > 0) {
|
|
|
+ $aduit = Dever::load('manage/admin-find',$info['audit_admin']);
|
|
|
+ $html['admin_name'] = $aduit['username'];
|
|
|
+ } elseif ($info && $info['top_admin']) {
|
|
|
+ $off = Dever::db('active/off')->find($info['top_admin']);
|
|
|
+ $html['admin_name'] = $off['name'];
|
|
|
+ }
|
|
|
+ return $html;
|
|
|
+ }
|
|
|
+ public function user($id)
|
|
|
+ {
|
|
|
+ $data = Dever::db('active/user')->find($id);
|
|
|
+ $html = $data['name'].'<br/>'.$data['mobile'];
|
|
|
+ return $html;
|
|
|
+ }
|
|
|
+ public function dOff($id)
|
|
|
+ {
|
|
|
+ $data = Dever::db('active/code')->state(array('active_id' => $id,'status'=>1));
|
|
|
+ $html = count($data);
|
|
|
+ return $html;
|
|
|
+ }
|
|
|
+ public function insertInfoCode($id, $name, $data)
|
|
|
+ {
|
|
|
+ $code = Dever::param('code',$data);
|
|
|
+ if ($code) {
|
|
|
+ $info = Dever::db('active/info_code')->find(array('code'=>$code));
|
|
|
+ if ($info['code']) {
|
|
|
+ Dever::alert('核销码已核销');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ public function updateInfoCode($id, $name, $data)
|
|
|
+ {
|
|
|
+ $code = Dever::param('code',$data);
|
|
|
+ $data = Dever::db('active/code')->find(array('write_code'=>$code));
|
|
|
+ if ($data) {
|
|
|
+ $where['where_id'] = $data['id'];
|
|
|
+ $where['status'] = 2;
|
|
|
+ $where['offdate'] = time();
|
|
|
+ $admin = Dever::load('manage/admin-find');
|
|
|
+ $where['audit_admin'] = $admin['id'];
|
|
|
+ Dever::db('active/code')->update($where);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ public function get()
|
|
|
+ {
|
|
|
+ $data[0]['name'] = '头衔';
|
|
|
+ $data[0]['child'] = Dever::db('setting/title')->select();
|
|
|
+ $data['state'] = 1;
|
|
|
+ return $data;
|
|
|
+ }
|
|
|
+ public function search_api()
|
|
|
+ {
|
|
|
+ $value = Dever::input('value');
|
|
|
+ if (!$value) {
|
|
|
+ return '核销码不存在';
|
|
|
+ }
|
|
|
+ if ($value) {
|
|
|
+ $data = Dever::db('active/code')->one(array('write_code' => $value,'state' =>1));
|
|
|
+ $table = array();
|
|
|
+ if ($data) {
|
|
|
+ $user = Dever::db('active/user')->find(array('id'=>$data['join_uid']));
|
|
|
+ $parent = Dever::db('active/user')->find(array('id'=>$data['buy_uid']));
|
|
|
+ $table = array();
|
|
|
+ $table['head'] = array('姓名', '手机号','邀请人', '邀请人手机号');
|
|
|
+ $table['body'] = array();
|
|
|
+ $table['body'] = array($user['name'], $user['mobile'],$parent['name'], $parent['mobile']);
|
|
|
+
|
|
|
+ $result[] = array
|
|
|
+ (
|
|
|
+ 'type' => 'table',
|
|
|
+ 'content' => $table,
|
|
|
+ );
|
|
|
+
|
|
|
+ $html = Dever::show('', $result, false, false);
|
|
|
+ return $html;
|
|
|
+ }else{
|
|
|
+ return '核销码不存在';
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return '';
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public function checkMcode()
|
|
|
+ {
|
|
|
+ $mobile = Dever::input('mobile');
|
|
|
+ $code = Dever::input('mcode');
|
|
|
+ if (!$code) {
|
|
|
+ Dever::alert('请输入验证码');
|
|
|
+ }
|
|
|
+ $code = Dever::load('passport/reg')->mcode($mobile, $code, 2);
|
|
|
+ if (!$code) {
|
|
|
+ Dever::alert('验证码输入错误');
|
|
|
+ }
|
|
|
+ return 'ok';
|
|
|
+ }
|
|
|
+
|
|
|
+ public function list()
|
|
|
+ {
|
|
|
+ $id = Dever::input('id');
|
|
|
+ $info = Dever::db('active/order')->find($id);
|
|
|
+ $active = Dever::db('active/info')->find($info['active_id']);
|
|
|
+ $config = Dever::db('active/order')->config['config_status'];
|
|
|
+ $status = Dever::status($config,$info['status']);
|
|
|
+ if ( !$info['uid']) {
|
|
|
+ $user = Dever::db('active/user')->find($info['mid']);
|
|
|
+ $info['uid'] = $user['id'];
|
|
|
+ }
|
|
|
+ $code = Dever::db('active/code')->state(array('order_id' => $id, 'buy_uid'=>$info['uid']));
|
|
|
+ $use_code = count($code);
|
|
|
+ $no_code = $info['num'] - $use_code;
|
|
|
+ if ($info['mid'] && $info['mid'] > 0) {
|
|
|
+ $user = Dever::db('active/user')->find($info['mid']);
|
|
|
+ $member = Dever::db('agent/member')->find($info['mid']);
|
|
|
+ if ($member) {
|
|
|
+ $role = Dever::db('setting/role')->find($member['role']);
|
|
|
+ if (isset($role) && $role && isset($role['name']) && $role['name']) {
|
|
|
+ $role_name = '<br/>'.$role['name'];
|
|
|
+ } else {
|
|
|
+ $role_name = '';
|
|
|
+ }
|
|
|
+ $title = Dever::db('setting/title')->find($member['title_id']);
|
|
|
+ if (isset($title) && $title && isset($title['name']) && $title['name']) {
|
|
|
+ $title_name = '('.$title['name'].')';
|
|
|
+ } else {
|
|
|
+ $title_name = '';
|
|
|
+ }
|
|
|
+ $level = Dever::db('setting/level')->find($member['level_id']);
|
|
|
+ if (isset($level) && $level && isset($level['name']) && $level['name']) {
|
|
|
+ $level_name = '('.$level['name'].')';
|
|
|
+ } else {
|
|
|
+ $level_name = '';
|
|
|
+ }
|
|
|
+ $user_name = $member['name'].$role_name.$title_name.$level_name;
|
|
|
+ $user_mobile = $member['mobile'];
|
|
|
+ $user_idcard = $member['idcard'];
|
|
|
+ }
|
|
|
+ } elseif ($info['uid'] && $info['uid'] > 0) {
|
|
|
+ $user = Dever::db('active/user')->find($info['uid']);
|
|
|
+ if ($user) {
|
|
|
+ $user_name = $user['name'];
|
|
|
+ $user_mobile = $user['mobile'];
|
|
|
+ $user_idcdard = $user['idcard'];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $result['订单信息'] = array
|
|
|
+ (
|
|
|
+ 'type' => 'info',
|
|
|
+ 'content' => array
|
|
|
+ (
|
|
|
+ array
|
|
|
+ (
|
|
|
+ array('订单单号', $info['order_num']),
|
|
|
+ array('活动名称', $active['name']),
|
|
|
+ array('订单状态', $status),
|
|
|
+ ),
|
|
|
+ array
|
|
|
+ (
|
|
|
+ array('购买数量', $info['num']),
|
|
|
+ array('支付金额', $info['price']),
|
|
|
+ ),
|
|
|
+ array
|
|
|
+ (
|
|
|
+ array('已使用', $use_code),
|
|
|
+ array('未使用', $no_code),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ );
|
|
|
+ $result['用户信息'] = array
|
|
|
+ (
|
|
|
+ 'type' => 'info',
|
|
|
+ 'content' => array
|
|
|
+ (
|
|
|
+ array
|
|
|
+ (
|
|
|
+ array('用户姓名', $user_name),
|
|
|
+ array('用户电话', $user_mobile),
|
|
|
+ array('用户身份证号', $user_idcard),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ );
|
|
|
+ if ($use_code > 0) {
|
|
|
+ $result += $this->table($id,$user['id']);
|
|
|
+
|
|
|
+ }
|
|
|
+ $head = array
|
|
|
+ (
|
|
|
+ 'name' => '基本资料',
|
|
|
+ 'btn' => '',
|
|
|
+ );
|
|
|
+ $html = Dever::show($head, $result);
|
|
|
+ return $html;
|
|
|
+ }
|
|
|
+
|
|
|
+ private function table ($id,$uid)
|
|
|
+ {
|
|
|
+ $data = Dever::db('active/code')->state(array('order_id' => $id, 'join_uid' => $uid));
|
|
|
+ if ($data) {
|
|
|
+ $head = array('参加人信息', '核销码', '核销状态', '领取时间', '核销时间','核销人');
|
|
|
+ $body = array();
|
|
|
+ foreach ($data as $k => $v) {
|
|
|
+ $user = Dever::db('active/user')->find($v['join_uid']);
|
|
|
+ $join_name = '';
|
|
|
+ if ($user) {
|
|
|
+ $join_name = $user['name'].'<br/>'.$user['mobile'];
|
|
|
+ }
|
|
|
+ $admin_name = '';
|
|
|
+ if ($v['status'] == 1) {
|
|
|
+ $status = '待核销';
|
|
|
+ } else {
|
|
|
+ $status = '已核销';
|
|
|
+ if ($v['audit_admin'] && $v['audit_admin'] >0) {
|
|
|
+ $admin = Dever::load('manage/admin-find',$v['audit_admin']);
|
|
|
+ if ($admin) {
|
|
|
+ $admin_name = $admin['username'];
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if ($v['top_admin'] && $v['top_admin'] > 0) {
|
|
|
+ $admin = Dever::db('active/info_off')->find($v['top_admin']);
|
|
|
+ if ($admin) {
|
|
|
+ $admin_name = $admin['name'];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $cdate = '';
|
|
|
+ if ($v['cdate']) {
|
|
|
+ $cdate = date('Y-m-d H:i',$v['cdate']);
|
|
|
+ }
|
|
|
+ $offdate = '';
|
|
|
+ if ($v['offdate']) {
|
|
|
+ $offdate = date('Y-m-d H:i',$v['offdate']);
|
|
|
+ }
|
|
|
+ $d = array
|
|
|
+ (
|
|
|
+ $join_name,
|
|
|
+ $v['write_code'],
|
|
|
+ $status,
|
|
|
+ $cdate,
|
|
|
+ $offdate,
|
|
|
+ $admin_name,
|
|
|
+ );
|
|
|
+ $body[] = $d;
|
|
|
+ }
|
|
|
+ $result['核销码使用列表'] = array
|
|
|
+ (
|
|
|
+ 'type' => 'table',
|
|
|
+ 'content' => array
|
|
|
+ (
|
|
|
+ 'head' => $head,
|
|
|
+ 'body' => $body,
|
|
|
+ )
|
|
|
+ );
|
|
|
+ return $result;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|