市场结算生成下游对账单代码优化

master
zhengyongxing 5 years ago
parent 136f565f9f
commit 4c42ee90e3

@ -295,11 +295,14 @@ class AjaxController extends ThinkController{
$data['game_ratio'] = $handleStatementData;
$data['company_name'] = $second_party_info['partner'];
$data['mobile_phone'] = $second_party_info['link_phone'];
$data['bank_card'] = $second_party_info['bank_account'];
$data['account_openin'] = $second_party_info['opening_bank'];
$data['settlement_type'] = $second_party_info['settlement_type'];
$data['address'] = $second_party_info['address'];
$data['real_name'] = $second_party_info['link_man'];
$data['bank_account_name'] = $second_party_info['bank_account_name'];
$data['settlement_type_value'] = $getStatementData['settlement_type'];
$data['settlement_type_value'] = $getStatementData['settlement_type'];
$data['invoice_item'] = $second_party_info['invoice_item'];
$data['invoice_type'] = $second_party_info['invoice_type'];

@ -1474,11 +1474,12 @@ class QueryController extends ThinkController
$spendMap['tab_spend.sdk_version'] = $_REQUEST['device'];
}
$spendMap['pay_status'] = 1;
$spendMap['tab_spend.pay_status'] = 1;
//获取spend表中的数据同时根据会长id进行group分类
$data = M('Spend','tab_')
->field("FROM_UNIXTIME(pay_time,'%Y-%m') as my_time,sum(pay_amount) as pay_amount,game_id,game_name,SUBSTRING_INDEX(`game_name`,\"(\",1) as game_names,promote_id,promote_account,company_relation,company_belong,CASE WHEN SUBSTRING_INDEX(SUBSTRING_INDEX(`chain`,\"/\",2),\"/\",-1)='' THEN promote_id ELSE SUBSTRING_INDEX(SUBSTRING_INDEX(`chain`,\"/\",2),\"/\",-1) END as root_id ")
->field("FROM_UNIXTIME(pay_time,'%Y-%m') as my_time,sum(pay_amount) as pay_amount,game_id,tab_spend.game_name,SUBSTRING_INDEX(tab_spend.`game_name`,\"(\",1) as game_names,promote_id,promote_account,company_relation,company_belong,CASE WHEN SUBSTRING_INDEX(SUBSTRING_INDEX(`chain`,\"/\",2),\"/\",-1)='' THEN promote_id ELSE SUBSTRING_INDEX(SUBSTRING_INDEX(`chain`,\"/\",2),\"/\",-1) END as root_id,tab_game.ratio ")
->join("left join tab_promote on promote_id = tab_promote.id")
->join("left join tab_game on tab_game.id=tab_spend.game_id")
->where($spendMap)
->group("my_time,game_names,root_id")
->order("my_time Desc")
@ -1495,7 +1496,7 @@ class QueryController extends ThinkController
//关联表获取会长账号名
$data = M()->table('('.$data.') as a')
->field("my_time,pay_amount,a.game_id,game_name,game_names,a.promote_id,a.promote_account,a.company_relation,a.company_belong,CASE WHEN root_id is null THEN 0 ELSE root_id END as root_id,CASE WHEN account is null THEN '官方渠道' ELSE account END as account,tab_ratio.ratio as ratio,turnover_ratio")
->field("my_time,pay_amount,a.game_id,game_name,game_names,a.promote_id,a.promote_account,a.company_relation,a.company_belong,CASE WHEN root_id is null THEN 0 ELSE root_id END as root_id,CASE WHEN account is null THEN '官方渠道' ELSE account END as account,tab_ratio.ratio as ratio,turnover_ratio,a.ratio as game_ratio")
->join("left join tab_promote on root_id = tab_promote.id")
->join("left join tab_promote_game_ratio as tab_ratio on tab_ratio.game_id = a.game_id and tab_ratio.promote_id=root_id")
// ->join("left join tab_cp_game_ratio as game_ratio on game_ratio.game_id = a.game_id")
@ -1522,10 +1523,9 @@ class QueryController extends ThinkController
if ($value['ratio']) {
$data[$key]['downstream'] = $value['pay_amount'] * ($value['ratio']*0.01);
} else {
$data[$key]['downstream'] = $value['pay_amount'] * 0;
$data[$key]['downstream'] = $value['pay_amount'] * ($value['game_ratio']*0.01);
}
$value['turnover_ratio'] = json_decode($value['turnover_ratio'],true);
// dd($value);

@ -211,6 +211,7 @@
//搜索功能
$("#ext_field").change(function(){
key = 0;
var ext_field = $("#ext_field").val();
console.log(ext_field);
$("tbody").empty();
@ -259,7 +260,7 @@
console.log(data)
for (var i in data){
if (data[i].company_id) {
add += "<option company_id='" + data[i].company_id + "' value='" + data[i].company_id + "' " + ('selected') + ">" + data[i].company_name + "</option>"
add += "<option company_id='" + data[i].company_id + "' value='" + data[i].company_name + "' " + ('selected') + ">" + data[i].company_name + "</option>"
}
}
$("#company_name").empty();
@ -334,6 +335,7 @@
//搜索功能
$("#company_name").change(function(){
key = 0;
var ext_field = $("#company_name option:selected").attr('company_id');
console.log(ext_field);
$("tbody").empty();

@ -52,7 +52,7 @@
</div>
<div class="input-list input-list-promote search_label_rehab" style="width: 50%">
银行账号:
<input type="text" readonly id="bank_card" name="bank_card" class="" value="" placeholder="银行账号" style="width: 50%"/>
<input type="text" id="bank_card" name="bank_card" class="" value="" placeholder="银行账号" style="width: 50%"/>
</div>
<div class="input-list input-list-promote search_label_rehab" style="width: 50%">
@ -204,7 +204,7 @@
success:function(data){
console.log($("#company_name option:selected").attr('company-type'))
$("#company_name").val(data.data.company_name);
$("#company_name").append("<option value='"+data.data.company_name+"' selected='selected'>"+data.data.company_name+"</option>");
$("#settlement_type").text(data.data.settlement_type);
$("#bank_card").val(data.data.bank_card);
$("#account_openin").val(data.data.account_openin);

Loading…
Cancel
Save