新增游戏订单退款

master
chenzhi 4 years ago
parent a2dec0e79b
commit f349603e7c

@ -1146,6 +1146,11 @@ class ExportController extends Controller
unset($_REQUEST['is_check']); unset($_REQUEST['is_check']);
} }
if (isset($_REQUEST['is_refund'])) {
$map['is_refund'] = (int)($_REQUEST['is_refund']);
unset($_REQUEST['is_refund']);
}
if ($_REQUEST['merchant_id']) { if ($_REQUEST['merchant_id']) {
$map['merchant_id'] = $_REQUEST['merchant_id']; $map['merchant_id'] = $_REQUEST['merchant_id'];
unset($_REQUEST['merchant_id']); unset($_REQUEST['merchant_id']);
@ -1236,6 +1241,7 @@ class ExportController extends Controller
'pay_amount' => '实付金额', 'pay_amount' => '实付金额',
'pay_way' => '充值方式', 'pay_way' => '充值方式',
'pay_status' => L('Order_status'), 'pay_status' => L('Order_status'),
'is_refund' => '退款状态',
'pay_game_status' => '游戏通知状态', 'pay_game_status' => '游戏通知状态',
'is_check' => '是否参与结算', 'is_check' => '是否参与结算',
'promote_id' => "消费"."{$total}", 'promote_id' => "消费"."{$total}",
@ -1314,6 +1320,7 @@ class ExportController extends Controller
$value['game_id'] = $thisGameInfo['partner_name']; $value['game_id'] = $thisGameInfo['partner_name'];
$value['is_check'] = D("Spend")::IsCheckStr[$value['is_check']]; $value['is_check'] = D("Spend")::IsCheckStr[$value['is_check']];
$value['is_refund'] = D("Spend")::IsRefundStr[$value['is_refund']];
$value['company_name'] = $promoters[$value['promote_id']] == 0 ? '官方渠道' : ($companys[$promoters[$value['promote_id']]] ?? ''); $value['company_name'] = $promoters[$value['promote_id']] == 0 ? '官方渠道' : ($companys[$promoters[$value['promote_id']]] ?? '');
unset($value['promote_id']); unset($value['promote_id']);

@ -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;
}
} }

@ -26,6 +26,10 @@ class SpendModel extends Model
"1"=>"是", "1"=>"是",
"2"=>"否" "2"=>"否"
]; ];
const IsRefundStr=[
"0"=>"--",
"1"=>"已退款"
];
/* 自动完成规则 */ /* 自动完成规则 */
protected $_auto = array( protected $_auto = array(

@ -199,6 +199,14 @@
</select> </select>
</div> </div>
<div class="input-list search_item input-list-gamenoticestatus">
<select id="is_refund" name="is_refund" class="select_gallery">
<option value="">退款状态</option>
<option value="1">已退款</option>
<option value="0">--</option>
</select>
</div>
<input type="hidden" name="" value="" class="sortBy"> <input type="hidden" name="" value="" class="sortBy">
<div class="input-list search_item"> <div class="input-list search_item">
@ -254,6 +262,7 @@
</a></th> </a></th>
<th>充值方式</th> <th>充值方式</th>
<th>订单状态</th> <th>订单状态</th>
<th>退款状态</th>
<th>游戏通知状态</th> <th>游戏通知状态</th>
<th>是否参与结算</th> <th>是否参与结算</th>
<th>操作</th> <th>操作</th>
@ -266,7 +275,7 @@
<else/> <else/>
<volist name="list_data" id="data"> <volist name="list_data" id="data">
<tr> <tr>
<td ><input class="ids" type="checkbox" data-ischeck="{$data.is_check}" value="{$data['id']}" name="ids[]"></td> <td ><input class="ids" type="checkbox" data-ischeck="{$data.is_check}" data-isrefund="{$data.is_refund}" value="{$data['id']}" name="ids[]"></td>
<td> <td>
<if condition="$show_data_power eq true "> <if condition="$show_data_power eq true ">
{$data.pay_order_number} {$data.pay_order_number}
@ -339,6 +348,7 @@
{:get_info_status($data['pay_status'],9)} {:get_info_status($data['pay_status'],9)}
</if> </if>
</td> </td>
<td>{$data.is_refund_str}</td>
<td> <td>
<if condition="$data['pay_status'] eq 1"><span class="game_notice_status_color">{:get_info_status($data['pay_game_status'],14)}</span> <if condition="$data['pay_status'] eq 1"><span class="game_notice_status_color">{:get_info_status($data['pay_game_status'],14)}</span>
<elseif condition="$data.pay_status eq 0"/> <elseif condition="$data.pay_status eq 0"/>
@ -354,19 +364,15 @@
if (!(substr($data['pay_order_number'], 0, 3) == "PF_" && if (!(substr($data['pay_order_number'], 0, 3) == "PF_" &&
substr($data['pay_order_number'], -2) == '_1')) { substr($data['pay_order_number'], -2) == '_1')) {
?> ?>
<if condition="($data['pay_game_status'] eq 0 or $data['pay_game_status'] eq 2) and $data['pay_status'] eq 1"> <if condition="($data['pay_game_status'] eq 0 or $data['pay_game_status'] eq 2) and $data['pay_status'] eq 1 and $data['is_refund'] eq 0">
<a class=" budan" href="javascript:void(0);" <a class=" budan" href="javascript:void(0);"
href-data="{$data.pay_order_number}" href-hhh="{:U('Repair/repairEdit')}" style="width:100%;">补单</a> href-data="{$data.pay_order_number}" href-hhh="{:U('Repair/repairEdit')}" style="width:100%;">补单</a>
<else/>
<span>补单</span>
</if> </if>
<?php }?> <?php }?>
<br /> <br />
<if condition="($data['pay_game_status'] eq 0 or $data['pay_game_status'] eq 2) and ($data['pay_status'] eq 0 or $data['pay_status'] eq 2)"> <if condition="($data['pay_game_status'] eq 0 or $data['pay_game_status'] eq 2) and ($data['pay_status'] eq 0 or $data['pay_status'] eq 2) and $data['is_refund'] eq 0">
<a class="pay_repair" href="javascript:void(0);" <a class="pay_repair" href="javascript:void(0);"
href-data="{$data.pay_order_number}" href-hhh="{:U('Repair/noticePayed')}" style="width:100%;">通知到账</a> href-data="{$data.pay_order_number}" href-hhh="{:U('Repair/noticePayed')}" style="width:100%;">通知到账</a>
</if> </if>
@ -380,7 +386,7 @@
<if condition="$rule_count_check"> <if condition="$rule_count_check">
<tr class="data_summary"> <tr class="data_summary">
<td colspan="2">汇总</td> <td colspan="2">汇总</td>
<td colspan="21"> <td colspan="22">
当页充值:{:null_to_0(array_sum(array_column(array_status2value('pay_status','',$list_data),'pay_amount')))} 当页充值:{:null_to_0(array_sum(array_column(array_status2value('pay_status','',$list_data),'pay_amount')))}
累计充值:{$total}(此处只汇总充值成功的订单) 累计充值:{$total}(此处只汇总充值成功的订单)
@ -770,10 +776,59 @@
} }
}); });
}); });
})
$("#addRefund,#removeRefund").on("click",function(){
var id = $(this).attr("id");
if(id == "addRefund"){
var opname = "登记退款";
var opurl = "{:U('addRefund')}";
var opst ="[未退款]";
var status = [0];
}else if(id=="removeRefund"){
var opname = "取消退款";
var opurl = "{:U('removeRefund')}";
var opst ="[已退款]";
var status = [1];
}
var flag = false;
var text = $("input:checkbox[name='ids[]']:checked").map(function(index,elem) {
const isrefund = $(elem).data("isrefund");
if($.inArray(isrefund,status) > -1){
return $(elem).val();
}
}).get();
if(text.length < 1){
layer.msg("<font style='color:white'>" + '无需要'+opname+'的操作,仅'+opst+'状态可以进行'+opname+"</font>");
return;
}
text = text.join(",");
layer.confirm('【提示】'+opname+'退款功能仅用于登记相关数据,未引入结算', {
btn: ['确认','取消'],
title:false
}, function(index){
layer.close(index);
layer.load(2);
$.ajax({
type: "POST",
url: opurl,
dataType: 'json',
async: true,
data: {ids:text},
success:function(data){
layer.closeAll('loading');
if(data.status==1){
layer.msg("<font style='color:white'>" + data.info + "</font>");
setTimeout(function(){
window.location.reload();
},1500);
}else{
layer.msg("<font style='color:white'>" + data.info + "</font>");
return false;
}
}
});
});
}) })
/** /**

Loading…
Cancel
Save