2.7号功能提交
parent
3e363d65d5
commit
53ba2c7698
@ -0,0 +1,164 @@
|
||||
<?php
|
||||
namespace Base\Factory;
|
||||
|
||||
class SpecialCompoentCaculateFactory {
|
||||
|
||||
public function __construct(){}
|
||||
|
||||
/**
|
||||
* 订单相关金额重算
|
||||
* @param array $statement_info
|
||||
* @param int $company_type
|
||||
* @param int $company_id
|
||||
* @return array|bool
|
||||
*/
|
||||
public function caculateStatementInfo($statement_info = [],$company_type = 2,$company_id = 0) {
|
||||
|
||||
if (!$statement_info) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$company_id) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$platform_amount = 0;
|
||||
$statement_amount = 0;
|
||||
|
||||
$promote_id = M("promote","tab_")
|
||||
->field("id")
|
||||
->where(['company_id'=>$company_id])
|
||||
->select();
|
||||
if ($promote_id) {
|
||||
$map['promote_id'] = ['in',array_column($promote_id,'id')];
|
||||
} else {
|
||||
$map['promote_id'] = '-1';
|
||||
}
|
||||
$map['tab_spend.pay_status'] = 1;
|
||||
|
||||
if ($company_type == 2) {
|
||||
|
||||
foreach($statement_info as $key => $value) {
|
||||
|
||||
$game_list = $value["game_list"];
|
||||
|
||||
foreach ($game_list as $gk => $gv) {
|
||||
$start_time = str_replace('.','-',$gv['statement_begin_time']);
|
||||
$end_time = str_replace('.','-',$gv['statement_end_time']);
|
||||
$map['relation_game_id'] = $gv['relation_game_id'];
|
||||
$map['payed_time'] = ['between', [strtotime($start_time), strtotime($end_time)+86399]];
|
||||
$amount = M("spend","tab_")
|
||||
->field("sum(pay_amount) pay_amount")
|
||||
->join("left join tab_game game on tab_spend.game_id=game.id")
|
||||
->where($map)
|
||||
->find()['pay_amount'];
|
||||
|
||||
$statement_info[$key]['game_list'][$gk]['pay_amount'] = floatval($amount);
|
||||
$statement_info[$key]['game_list'][$gk]['sum_money'] = (string)(number_format($amount*($gv['increment_ratio']/100),2,'.',''));
|
||||
$platform_amount += $amount;
|
||||
$statement_amount += floatval($amount*($gv['increment_ratio']/100));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
foreach($statement_info as $key => $value) {
|
||||
|
||||
$start_time = str_replace('.','-',$value['statement_begin_time']);
|
||||
$end_time = str_replace('.','-',$value['statement_end_time']);
|
||||
$map['relation_game_id'] = $value['relation_game_id'];
|
||||
$map['payed_time'] = ['between', [strtotime($start_time), strtotime($end_time)+86399]];
|
||||
|
||||
$amount = M("spend","tab_")
|
||||
->field("sum(pay_amount) pay_amount")
|
||||
->join("left join tab_game game on tab_spend.game_id=game.id")
|
||||
->where($map)
|
||||
->find()['pay_amount'];
|
||||
|
||||
$statement_info[$key]['pay_amount'] = floatval($amount);
|
||||
$statement_info[$key]['sum_money'] = (string)(number_format($amount*($value['increment_ratio']/100),2,'.',''));
|
||||
$platform_amount += $amount;
|
||||
$statement_amount += floatval($amount*($value['increment_ratio']/100));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return [$statement_info,$platform_amount,$statement_amount];
|
||||
}
|
||||
|
||||
/**
|
||||
* 公司信息更新
|
||||
* @param int $company_id
|
||||
* @param string $nickname
|
||||
* @return array
|
||||
*/
|
||||
public function updateCompanyInfo($company_id = 0,$nickname = '') {
|
||||
|
||||
$company_data = M("promote_company","tab_")->where(['id'=>$company_id])->find();
|
||||
|
||||
$company_type = M("company_relation","tab_")
|
||||
->where("(first_company_id={$company_id} and first_company_type =2) or (second_company_id={$company_id} and second_company_type=2)")
|
||||
->find();
|
||||
|
||||
$proCompany_info['id'] = $company_data['id'];
|
||||
$proCompany_info['partner'] =$company_data['company_name'];
|
||||
$proCompany_info['link_man'] = $company_data['settlement_contact'];
|
||||
$proCompany_info['link_phone'] =$company_data['contact_phone'];
|
||||
$proCompany_info['address'] = $company_data['address'];
|
||||
$proCompany_info['payee_name'] =$company_data['bank_address'];
|
||||
|
||||
$proCompany_info['bank_account'] = $company_data['bank_card'];
|
||||
$proCompany_info['opening_bank'] =$company_data['bank_name'];
|
||||
$proCompany_info['fax_ratio'] = $company_data['fax_ratio'];
|
||||
$proCompany_info['taxation_rate'] = $company_data['taxation_rate'];
|
||||
|
||||
$proCompany_info['company_belong'] = $company_data['company_belong'];
|
||||
$proCompany_info['company_type'] = $company_data['company_type'];
|
||||
$proCompany_info['develop_type'] = $company_data['develop_type'];
|
||||
$proCompany_info['ali_user'] = $company_data['ali_user'];
|
||||
$proCompany_info['ali_account'] =$company_data['ali_account'];
|
||||
$proCompany_info['has_server_fee'] = $company_data['has_server_fee'];
|
||||
$proCompany_info['server_fee'] =$company_data['server_fee'];
|
||||
|
||||
$proCompany_info['has_ratio'] = $company_data['has_ratio'];
|
||||
$proCompany_info['turnover_ratio'] =$company_data['turnover_ratio'];
|
||||
$proCompany_info['invoice_type'] = $company_type['invoice_type'];
|
||||
$proCompany_info['invoice_content'] = $company_type['invoice_content'];
|
||||
|
||||
$nickname?($proCompany_info['nickname'] = $nickname):'';
|
||||
|
||||
if ($company_type['first_company_id'] == $company_id) {
|
||||
$weCompany = M("company_info","tab_")->where(['id'=>$company_type['second_company_id']])->find();
|
||||
} elseif ($company_type['second_company_id'] == $company_id) {
|
||||
$weCompany = M("company_info","tab_")->where(['id'=>$company_type['first_company_id']])->find();
|
||||
}
|
||||
|
||||
$secord_info['id'] = $weCompany['id'];
|
||||
$secord_info['partner'] =$weCompany['partner'];
|
||||
$secord_info['link_man'] = $weCompany['link_man'];
|
||||
$secord_info['link_phone'] =$weCompany['link_phone'];
|
||||
$secord_info['address'] = $weCompany['address'];
|
||||
$secord_info['company_tax_no'] = $weCompany['company_tax_no'];
|
||||
$secord_info['payee_name'] =$weCompany['payee_name'];
|
||||
|
||||
$secord_info['bank_account'] = $weCompany['bank_account'];
|
||||
$secord_info['opening_bank'] =$weCompany['opening_bank'];
|
||||
$secord_info['invoice_type'] = $company_type['invoice_type'];
|
||||
$secord_info['invoice_content'] = $company_type['invoice_content'];
|
||||
|
||||
if ($company_type['first_company_id'] == $company_id) {
|
||||
$first_party_info = $proCompany_info;
|
||||
$second_party_info = $secord_info;
|
||||
} elseif ($company_type['second_company_id'] == $company_id) {
|
||||
$second_party_info = $proCompany_info;
|
||||
$first_party_info = $secord_info;
|
||||
}
|
||||
|
||||
return [$first_party_info,$second_party_info];
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,86 @@
|
||||
<?php
|
||||
namespace Base\Factory;
|
||||
|
||||
class SpecialCompoentFactory {
|
||||
|
||||
static $DBModel = "";
|
||||
private $user = '';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
self::$DBModel = SM("CompanyStatement","tab_");
|
||||
|
||||
|
||||
$this->user = $_SESSION['onethink_admin']['user_auth']['username'];
|
||||
}
|
||||
|
||||
/**
|
||||
* 重算特殊补点主方法
|
||||
*/
|
||||
public function updateSpecialStatement($id = 0,$withdraw_type = 0) {
|
||||
|
||||
if (!$id || !$withdraw_type) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$dbres = self::$DBModel->field("id,verify_status,verify_log,withdraw_type,company_type,company_id,statement_info")->where(['id'=>$id])->find();
|
||||
|
||||
if ($dbres['withdraw_type']!=3) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$statement_info = json_decode($dbres['statement_info'],true);
|
||||
|
||||
list($statement_info,$platform_amount,$statement_amount,$first_party_info,$second_party_info) =
|
||||
$this->caculateFunction($statement_info,$dbres['company_type'],$dbres['company_id'],$statement_info[0]['nickname']?$statement_info[0]['nickname']:'');
|
||||
|
||||
$verify = ["create_user"=>$this->user,"create_time"=>date("Y-m-d H:i:s")];
|
||||
|
||||
self::$DBModel
|
||||
->where(['id'=>$id])
|
||||
->save([
|
||||
'statement_info'=>json_encode($statement_info),
|
||||
'first_party_info'=>json_encode($first_party_info),
|
||||
'second_party_info'=>json_encode($second_party_info),
|
||||
'pay_amount'=>$platform_amount,
|
||||
'platform_amount'=>$platform_amount,
|
||||
'statement_money'=>$statement_amount,
|
||||
'verify_log'=>json_encode($verify),
|
||||
'verify_status'=>0,
|
||||
]);
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 重新计算数据
|
||||
* @param array $statement_info
|
||||
* @param int $company_type
|
||||
* @param int $company_id
|
||||
* @param string $nickname
|
||||
* @return array|bool
|
||||
*/
|
||||
private function caculateFunction($statement_info = [],$company_type=0,$company_id = 0,$nickname = '') {
|
||||
|
||||
if (!$statement_info||!$company_id) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//工厂模式调用特殊补点重算详细方法
|
||||
$baseClass = BaseFactory::getInstance();
|
||||
$caculateClass = $baseClass->factoryClass("SpecialCompoentCaculate");
|
||||
|
||||
//订单详细信息重算
|
||||
list($statement_info,$platform_amount,$statement_amount) = $caculateClass->caculateStatementInfo($statement_info,$company_type,$company_id);
|
||||
|
||||
//公司信息重新录入
|
||||
list($first_party_info,$second_party_info) = $caculateClass->updateCompanyInfo($company_id,$nickname);
|
||||
|
||||
return [$statement_info,$platform_amount,$statement_amount,$first_party_info,$second_party_info];
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -1 +1 @@
|
||||
|
||||
dsafsadsaf111dsaf
|
Loading…
Reference in New Issue