|
@@ -17,55 +17,10 @@ Class Manage
|
|
} else {
|
|
} else {
|
|
$uid = $data['uid'];
|
|
$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,
|
|
|
|
- 'channel_id' => 1,
|
|
|
|
- 'system_source' => 1,
|
|
|
|
- 'account_id' => 8,
|
|
|
|
- 'order_id' => $data['order_num'],
|
|
|
|
- 'refund_cash' => $price,
|
|
|
|
- //'refund_order_id' => '',
|
|
|
|
- );
|
|
|
|
- if ($data['status'] != 2) {
|
|
|
|
- Dever::alert('此状态下不可退款');
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- if ($data['price'] > 0) {
|
|
|
|
- $result = Dever::load('pay/api.refund', $param);
|
|
|
|
-
|
|
|
|
- if (!$result) {
|
|
|
|
- # 退款失败,抛出错误
|
|
|
|
- //throw new \Exception('退款失败');
|
|
|
|
- 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));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ $this->common($data,1);
|
|
return 'reload';
|
|
return 'reload';
|
|
}
|
|
}
|
|
|
|
+
|
|
public function insertInfoRefund ($id,$name,$data)
|
|
public function insertInfoRefund ($id,$name,$data)
|
|
{
|
|
{
|
|
$num = Dever::param('num',$data);
|
|
$num = Dever::param('num',$data);
|
|
@@ -85,52 +40,14 @@ Class Manage
|
|
{
|
|
{
|
|
$num = Dever::param('num',$data);
|
|
$num = Dever::param('num',$data);
|
|
$order_id = Dever::param('order_id',$data);
|
|
$order_id = Dever::param('order_id',$data);
|
|
|
|
+ $code_id = Dever::param('code_id',$data);
|
|
$data = Dever::db('active/order')->find($order_id);
|
|
$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']);
|
|
|
|
- // if (time() >= $active['act_start']) {
|
|
|
|
- // Dever::alert('活动已开始,不能退款');
|
|
|
|
- // }
|
|
|
|
- // if ($num > $data['num']) {
|
|
|
|
- // Dever::alert('退款数量大于购买数量');
|
|
|
|
- // }
|
|
|
|
-
|
|
|
|
- $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) {
|
|
|
|
- # 退款失败,抛出错误
|
|
|
|
- //throw new \Exception('退款失败');
|
|
|
|
- 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));
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ // $info = Dever::db('active/info_refund')->state(array('order_id'=>$order_id));
|
|
|
|
+ // $active = Dever::db('active/info')->find($data['active_id']);
|
|
|
|
+ $this->common($data,2,$num,$id);
|
|
return 'reload';
|
|
return 'reload';
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
public function show($id)
|
|
public function show($id)
|
|
{
|
|
{
|
|
$data = Dever::db('active/order')->find($id);
|
|
$data = Dever::db('active/order')->find($id);
|
|
@@ -250,6 +167,7 @@ Class Manage
|
|
return 'ok';
|
|
return 'ok';
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
public function list()
|
|
public function list()
|
|
{
|
|
{
|
|
$id = Dever::input('id');
|
|
$id = Dever::input('id');
|
|
@@ -261,6 +179,17 @@ Class Manage
|
|
$user = Dever::db('active/user')->find($info['mid']);
|
|
$user = Dever::db('active/user')->find($info['mid']);
|
|
$info['uid'] = $user['id'];
|
|
$info['uid'] = $user['id'];
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ $code = Dever::db('active/code')->getCode(array('order_id' => $id,'status'=>'1,2'));
|
|
|
|
+ $use_code = count($code);#已领取的所有数量
|
|
|
|
+
|
|
|
|
+ if (!$info['refund_num']) {
|
|
|
|
+ $info['refund_num'] = 0;
|
|
|
|
+ }
|
|
|
|
+ $no_code = $info['num'] - $use_code - $info['refund_num'];#未使用的数量
|
|
|
|
+ if ($info['mid'] && $info['mid'] > 0) {
|
|
|
|
+ $user = Dever::db('active/user')->find($info['mid']);
|
|
|
|
+ $member = Dever::db('agent/member')->find($info['mid']);
|
|
$code = Dever::db('active/code')->state(array('order_id' => $id));
|
|
$code = Dever::db('active/code')->state(array('order_id' => $id));
|
|
$use_code = count($code);
|
|
$use_code = count($code);
|
|
$no_code = $info['num'] - $use_code;
|
|
$no_code = $info['num'] - $use_code;
|
|
@@ -314,6 +243,7 @@ Class Manage
|
|
(
|
|
(
|
|
array('已使用', $use_code),
|
|
array('已使用', $use_code),
|
|
array('未使用', $no_code),
|
|
array('未使用', $no_code),
|
|
|
|
+ array('退款数量', $info['refund_num']),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
);
|
|
@@ -330,6 +260,19 @@ Class Manage
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
);
|
|
|
|
+ $button = array();
|
|
|
|
+ if ($info['status'] > 1 && $no_code > 0) {
|
|
|
|
+ if (Dever::load('manage/auth')->checkFunc('active.order', 'editrefund', '未使用退款')) {
|
|
|
|
+ $purl = Dever::url('project/database/update?project=active&table=info_refund&search_option_order_id='.$info['id'].'&col=num,order_id', 'manage');
|
|
|
|
+ $button[] = array
|
|
|
|
+ (
|
|
|
|
+ 'type' => 'edit',
|
|
|
|
+ 'link' => $purl,
|
|
|
|
+ 'name' => '未使用退款',
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
if ($use_code > 0) {
|
|
if ($use_code > 0) {
|
|
$result += $this->table($id);
|
|
$result += $this->table($id);
|
|
|
|
|
|
@@ -337,7 +280,7 @@ Class Manage
|
|
$head = array
|
|
$head = array
|
|
(
|
|
(
|
|
'name' => '基本资料',
|
|
'name' => '基本资料',
|
|
- 'btn' => '',
|
|
|
|
|
|
+ 'btn' => $button,
|
|
);
|
|
);
|
|
$html = Dever::show($head, $result);
|
|
$html = Dever::show($head, $result);
|
|
return $html;
|
|
return $html;
|
|
@@ -347,7 +290,7 @@ Class Manage
|
|
{
|
|
{
|
|
$data = Dever::db('active/code')->state(array('order_id' => $id));
|
|
$data = Dever::db('active/code')->state(array('order_id' => $id));
|
|
if ($data) {
|
|
if ($data) {
|
|
- $head = array('参加人信息', '核销码', '核销状态', '领取时间', '核销时间','核销人');
|
|
|
|
|
|
+ $head = array('参加人信息', '核销码', '核销状态', '领取时间', '核销时间', '核销人', '管理');
|
|
$body = array();
|
|
$body = array();
|
|
foreach ($data as $k => $v) {
|
|
foreach ($data as $k => $v) {
|
|
$user = Dever::db('active/user')->find($v['join_uid']);
|
|
$user = Dever::db('active/user')->find($v['join_uid']);
|
|
@@ -358,7 +301,7 @@ Class Manage
|
|
$admin_name = '';
|
|
$admin_name = '';
|
|
if ($v['status'] == 1) {
|
|
if ($v['status'] == 1) {
|
|
$status = '待核销';
|
|
$status = '待核销';
|
|
- } else {
|
|
|
|
|
|
+ } elseif($v['status'] == 2) {
|
|
$status = '已核销';
|
|
$status = '已核销';
|
|
if ($v['audit_admin'] && $v['audit_admin'] >0) {
|
|
if ($v['audit_admin'] && $v['audit_admin'] >0) {
|
|
$admin = Dever::load('manage/admin-find',$v['audit_admin']);
|
|
$admin = Dever::load('manage/admin-find',$v['audit_admin']);
|
|
@@ -373,6 +316,8 @@ Class Manage
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ } else {
|
|
|
|
+ $status = '已作废';
|
|
}
|
|
}
|
|
$cdate = '';
|
|
$cdate = '';
|
|
if ($v['cdate']) {
|
|
if ($v['cdate']) {
|
|
@@ -382,6 +327,11 @@ Class Manage
|
|
if ($v['offdate']) {
|
|
if ($v['offdate']) {
|
|
$offdate = date('Y-m-d H:i',$v['offdate']);
|
|
$offdate = date('Y-m-d H:i',$v['offdate']);
|
|
}
|
|
}
|
|
|
|
+ $m = '';
|
|
|
|
+ if ($v['status'] == 1) {
|
|
|
|
+ $url = Dever::url('lib/manage.setOrder&order_id=' . $v['order_id'].'&code_id='.$v['id'], 'active');
|
|
|
|
+ $m = '<a href="javascript:;" onclick="load( \''.$url.'\')" class="layui-btn">退款</a>';
|
|
|
|
+ }
|
|
$d = array
|
|
$d = array
|
|
(
|
|
(
|
|
$join_name,
|
|
$join_name,
|
|
@@ -390,6 +340,7 @@ Class Manage
|
|
$cdate,
|
|
$cdate,
|
|
$offdate,
|
|
$offdate,
|
|
$admin_name,
|
|
$admin_name,
|
|
|
|
+ $m,
|
|
);
|
|
);
|
|
$body[] = $d;
|
|
$body[] = $d;
|
|
}
|
|
}
|
|
@@ -405,17 +356,111 @@ Class Manage
|
|
return $result;
|
|
return $result;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- // #将已经注册活动的用户放到用户表中
|
|
|
|
- // public function user_cron()
|
|
|
|
- // {
|
|
|
|
- // $data = Dever::db('active/order')->state();
|
|
|
|
- // foreach ($data as $k => $v) {
|
|
|
|
- // $user = Dever::db('active/user')->find(array('mid'=>$v['mid']));
|
|
|
|
- // if (!$user) {
|
|
|
|
- // $member = Dever::db('agent/member')->find($v['mid']);
|
|
|
|
- // $where['mobile'] = $member['mobile'];
|
|
|
|
- // $where['idcard'] = $member['idcard'];
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
|
|
+ public function setOrder_api($order_id,$code_id){
|
|
|
|
+ $data = Dever::db('active/order')->find($order_id);
|
|
|
|
+ $ids = $this->common($data,3,'',$code_id);
|
|
|
|
+ if ($ids) {
|
|
|
|
+ $w['where_id'] = $code_id;
|
|
|
|
+ $w['status'] = 3;
|
|
|
|
+ Dever::db('active/code')->update($w);
|
|
|
|
+ }
|
|
|
|
+ return 'reload';
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public function common($data,$type,$num=false,$refund_id=false){
|
|
|
|
+ $active = Dever::db('active/info')->find($data['active_id']);
|
|
|
|
+ $info = Dever::db('active/info_refund')->state(array('order_id'=>$data['id']));
|
|
|
|
+ if (time() > $active['act_start']) {
|
|
|
|
+ Dever::alert('活动已开始,不能退款');
|
|
|
|
+ }
|
|
|
|
+ if ($type == 1) {
|
|
|
|
+ if ($data['status'] != 2) {
|
|
|
|
+ Dever::alert('此状态下不可退款');
|
|
|
|
+ }
|
|
|
|
+ $refund_num = $data['num'];
|
|
|
|
+ $price = $data['price'];
|
|
|
|
+ }
|
|
|
|
+ if ($type == 2) {
|
|
|
|
+ $price = $num * $active['price'];
|
|
|
|
+ $refund_num = $num;
|
|
|
|
+ }
|
|
|
|
+ if ($type == 3) {
|
|
|
|
+ $refund_num = 1;
|
|
|
|
+ $price = $active['price'];
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $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' => '',
|
|
|
|
+ );
|
|
|
|
+ if ($type != 1) {
|
|
|
|
+ $param['refund_order_id'] = $data['order_num'] . '_' . count($info);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if ($data['price'] > 0) {
|
|
|
|
+ $result = Dever::load('pay/api.refund', $param);
|
|
|
|
+
|
|
|
|
+ if (!$result) {
|
|
|
|
+ # 退款失败,抛出错误
|
|
|
|
+ //throw new \Exception('退款失败');
|
|
|
|
+ Dever::alert('退款失败,请联系管理员');
|
|
|
|
+ } else {
|
|
|
|
+ $admin = Dever::load('manage/auth.data');
|
|
|
|
+ $time = time();
|
|
|
|
+ $where['where_id'] = $data['id'];
|
|
|
|
+ $where['status'] = 6;
|
|
|
|
+ $where['refund_admin'] = $admin['id'];
|
|
|
|
+ $where['rdate'] = $time;
|
|
|
|
+ if (!$data['refund_num']) {
|
|
|
|
+ $data['refund_num'] = 0;
|
|
|
|
+ }
|
|
|
|
+ $where['refund_num'] = $refund_num + $data['refund_num'];
|
|
|
|
+
|
|
|
|
+ if ($type == 1 || ($type == 2 && $price = $data['price'])) {
|
|
|
|
+ Dever::db('active/order')->update($where);
|
|
|
|
+ } elseif (($type == 2 && $price != $data['price']) || $type == 3) {
|
|
|
|
+ $where['status'] = 5;
|
|
|
|
+ $ids = Dever::db('active/order')->update($where);
|
|
|
|
+ return $ids;
|
|
|
|
+ }
|
|
|
|
+ if ($type == 2) {
|
|
|
|
+ $insert['status'] = 2;
|
|
|
|
+ $insert['where_id'] = $refund_id;
|
|
|
|
+ $insert['audit_admin'] = $admin['id'];
|
|
|
|
+ Dever::db('active/info_refund')->update($insert);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ #更新数量
|
|
|
|
+ public function upNum_api($order_id)
|
|
|
|
+ {
|
|
|
|
+ $data = Dever::db('active/order')->find($order_id);
|
|
|
|
+ if (!$data['refund_num']) {
|
|
|
|
+ $w['refund_num'] = 0;
|
|
|
|
+ } else {
|
|
|
|
+ $w['refund_num'] =$data['refund_num'];
|
|
|
|
+ }
|
|
|
|
+ if (!$data['code_num']) {
|
|
|
|
+ $w['code_num'] = 0;
|
|
|
|
+ }
|
|
|
|
+ if (!$data['no_num']) {
|
|
|
|
+ $w['no_num'] = 0;
|
|
|
|
+ }
|
|
|
|
+ #已使用的数量
|
|
|
|
+ $code = Dever::db('active/code')->getCode(array('order_id'=>$data['id'],'status'=>'1,2'));
|
|
|
|
+ $w['code_num'] = count($code);
|
|
|
|
+ #待核销的数量
|
|
|
|
+ $no_code = Dever::db('active/code')->getCode(array('order_id'=>$data['id'],'status'=>1));
|
|
|
|
+ $w['no_num'] = count($no_code);
|
|
|
|
+ $w['where_id'] = $data['id'];
|
|
|
|
+ Dever::db('active_order')->update($w);
|
|
|
|
+ }
|
|
}
|
|
}
|