@ -29,6 +29,10 @@ class SpendController extends ThinkController
$map['is_check'] = (int)($_REQUEST['is_check']);
$map['is_check'] = (int)($_REQUEST['is_check']);
}
}
if (isset($_REQUEST['is_refund'])) {
$map['is_refund'] = (int)($_REQUEST['is_refund']);
}
if (isset($_REQUEST['user_account'])) {
if (isset($_REQUEST['user_account'])) {
$map['user_account'] = array('like', trim($_REQUEST['user_account']));
$map['user_account'] = array('like', trim($_REQUEST['user_account']));
unset($_REQUEST['user_account']);
unset($_REQUEST['user_account']);
@ -147,6 +151,7 @@ class SpendController extends ThinkController
($value['promote_account']=='官方渠道')?($value['promote_account']=C('OFFICIEL_CHANNEL')):'';
($value['promote_account']=='官方渠道')?($value['promote_account']=C('OFFICIEL_CHANNEL')):'';
$value['market_admin_username'] = $adminUsernameList[$value['market_admin_id']] ?? '无';
$value['market_admin_username'] = $adminUsernameList[$value['market_admin_id']] ?? '无';
$value['is_check_str'] = D(self::model_name)::IsCheckStr[$value['is_check']];
$value['is_check_str'] = D(self::model_name)::IsCheckStr[$value['is_check']];
$value['is_refund_str'] = D(self::model_name)::IsRefundStr[$value['is_refund']];
//拆分游戏名称和设备类型
//拆分游戏名称和设备类型
$game_arr = explode("(", rtrim($value['game_name'], ")"));
$game_arr = explode("(", rtrim($value['game_name'], ")"));
$value['game_name'] = $game_arr[0];
$value['game_name'] = $game_arr[0];
@ -178,6 +183,8 @@ class SpendController extends ThinkController
$mentBtn = [
$mentBtn = [
"addStatement"=>"< a class = 'butn' id = 'addStatement' > 参与结算< / a > ",
"addStatement"=>"< a class = 'butn' id = 'addStatement' > 参与结算< / a > ",
"removeStatement"=>"< a class = 'butn' id = 'removeStatement' style = 'background-color: red;' > 移出结算< / a > ",
"removeStatement"=>"< a class = 'butn' id = 'removeStatement' style = 'background-color: red;' > 移出结算< / a > ",
"addRefund"=>"< a class = 'butn' id = 'addRefund' > 登记退款< / a > ",
"removeRefund"=>"< a class = 'butn' id = 'removeRefund' style = 'background-color: red;' > 取消退款< / a > ",
];
];
$resarr = [];
$resarr = [];
foreach ($mentBtn as $k => $v) {
foreach ($mentBtn as $k => $v) {
@ -191,7 +198,7 @@ class SpendController extends ThinkController
}
}
return $resarr;
return $resarr;
}
}
//是否结算
public function addStatement()
public function addStatement()
{
{
if(!isset($_REQUEST['ids'])) $this->error("参数错误");
if(!isset($_REQUEST['ids'])) $this->error("参数错误");
@ -232,4 +239,51 @@ class SpendController extends ThinkController
addOperationLog(['op_type'=>1,'key'=>$key,"op_name"=>$op_name,"content"=>json_encode(["ids"=>$_REQUEST['ids'],"is_check"=>$newval])]);
addOperationLog(['op_type'=>1,'key'=>$key,"op_name"=>$op_name,"content"=>json_encode(["ids"=>$_REQUEST['ids'],"is_check"=>$newval])]);
return true;
return true;
}
}
//是否退款
public function addRefund()
{
if(!isset($_REQUEST['ids'])) $this->error("参数错误");
$ids = $_REQUEST['ids'];
$this->editOrderIsrefund($ids,0,1);
$this->ajaxReturn(array(
'status' => 1,
"info"=>"操作成功"
));
}
public function removeRefund()
{
if(!isset($_REQUEST['ids'])) $this->error("参数错误");
$ids = $_REQUEST['ids'];
$this->editOrderIsrefund($ids,1,0);
$this->ajaxReturn(array(
'status' => 1,
"info"=>"操作成功"
));
}
protected function editOrderIsrefund($ids,$oldval,$newval){
$time = time();
$dbres = D(self::model_name)->field("id as s_id,user_id,user_account,pay_amount as refund_amount,pay_time,{$time} as create_time")->where("id in ({$ids}) and is_refund = '{$oldval}' and pay_status = 1")->select();
if(empty($dbres)) return false;
$changeIds = implode(",",array_column($dbres,"s_id"));
//执行操作
$res = D(self::model_name)->where("id in ({$changeIds}) and is_refund = '{$oldval}'")->save(['is_refund'=>$newval]);
if(empty($res)) return false;
//日志
if($newval == 1){
$op_name = "登记退款";
$key = "addRefund";
SM('spend_refund',"tab_")->addAll($dbres);
}else{
$op_name = "取消退款";
$key = "removeRefund";
SM('spend_refund',"tab_")->where("s_id in ({$changeIds}) ")->delete();
}
addOperationLog(['op_type'=>1,'key'=>$key,"op_name"=>$op_name,"content"=>json_encode(["ids"=>$_REQUEST['ids'],"is_refund"=>$newval])]);
return true;
}
}
}