You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
87 lines
2.7 KiB
PHTML
87 lines
2.7 KiB
PHTML
4 years ago
|
<?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];
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
}
|