diff --git a/Application/Payment/Controller/PaymentController.class.php b/Application/Payment/Controller/PaymentController.class.php
index 04d7237b0..60390aef6 100644
--- a/Application/Payment/Controller/PaymentController.class.php
+++ b/Application/Payment/Controller/PaymentController.class.php
@@ -110,7 +110,7 @@ class PaymentController extends BaseController
->join("left join tab_company_statement_pool p ON p.id = s.pool_id")
->where($map)
->page($page,$row)
- ->order("FIELD(s.pay_status,0,-1,1),s.verify_status desc")
+ ->order("statement_num desc")
->select();
$handleData = [];
@@ -135,6 +135,8 @@ class PaymentController extends BaseController
$v['verify_status_str']="信息配置不全";
$v['can_pay'] = 0;
}
+ $v['ali_user'] = $companypay_info['ali_user'];
+ $v['ali_account'] = $companypay_info['ali_account'];
if($v['pay_check'] == 0){
$v['pay_check_detail'] = "--";
@@ -223,12 +225,121 @@ class PaymentController extends BaseController
$this->assign('_page', $page);
}
$this->meta_title = '打款结算单';
+ // dd($CompanyInfo);
$this->assign("data",$CompanyInfo);
$this->assign("money",$money);
$this->assign("CompanyType", $this->CompanyType);
$this->assign("PayStatus", $this->PayStatus);
$this->display();
}
+ //是否需要更新支付信息
+ public function IsCanChangeCompanyInfo($id = 0)
+ {
+ //获取原值
+ list($oldInfo, $newCompanyInfo) = $this->getStatementCompanyInfo($id);
+ $oldCompanyInfo = json_decode($oldInfo['company_info'],true);
+ if( ($oldCompanyInfo['ali_user'] == $newCompanyInfo['ali_user']) && ($oldCompanyInfo['ali_account'] == $newCompanyInfo['ali_account']) ){
+ $this->ajaxReturn(['status' =>0 ,'msg'=>'支付宝打款信息已是最新,无需更新','data'=>[]]);
+ }
+ $this->ajaxReturn(['status' =>1 ,'msg'=>'ok','data'=>[
+ 'id'=>$id,
+ 'company_name'=>$oldInfo['company_name'],
+ 'old_ali_user'=>$oldCompanyInfo['ali_user'],
+ 'old_ali_account'=>$oldCompanyInfo['ali_account'],
+ 'new_ali_user'=>$newCompanyInfo['ali_user'],
+ 'new_ali_account'=>$newCompanyInfo['ali_account']
+ ]]);
+ }
+ //执行更新支付信息
+ public function DoChangeCompanyInfo()
+ {
+ $id = I("post.id",0);
+ list($oldInfo, $newCompanyInfo) = $this->getStatementCompanyInfo($id);
+ //子单修改
+ $sWhere = [
+ 'company_id' => $oldInfo['company_id'],
+ 'pay_status'=> ['neq',1],
+ 'statement_info_id' => $id
+ ];
+ $PayStatementDB = M("pay_statement_info","tab_");
+ $statementInfo = $PayStatementDB
+ ->where($sWhere)
+ ->field('id,company_info')
+ ->select();
+ foreach ($statementInfo as $k => $v) {
+ $v['company_info'] = $this->changeAliInfo($v['company_info'],$newCompanyInfo);
+ $PayStatementDB->save($v);
+ }
+ //修改结算单
+ if($oldInfo['company_type'] != 2 || $oldInfo['withdraw_type'] == 3){
+ //获取汇总单号
+ $statement_num = M("company_statement_pool","tab_")->where("id = {$oldInfo['pool_id']}")->getField("statement_num");
+ $StatementDB = M("company_statement","tab_");
+ $statementList = $StatementDB->field('id,pay_type,first_party_info,second_party_info')->where(['verify_log'=>["like","%{$statement_num}%"],'company_id'=>$oldInfo['company_id']])->select();
+ foreach ($statementList as $k => $v) {
+ if($v['pay_type'] == 1){
+ $v['first_party_info'] = $this->changeAliInfo($v['first_party_info'],$newCompanyInfo);
+ }else{
+ $v['second_party_info'] = $this->changeAliInfo($v['second_party_info'],$newCompanyInfo);
+ }
+ $StatementDB->save($v);
+ }
+ }
+ //修改自身
+ $oldInfo['company_info'] = $this->changeAliInfo($oldInfo['company_info'],$newCompanyInfo);
+ $res = M("company_statement_info","tab_")->save($oldInfo);
+ if(empty($res)){
+ $this->ajaxReturn(['status' =>0 ,'msg'=>'更新信息失败','data'=>[]]);
+ }
+ $this->ajaxReturn(['status' =>1 ,'msg'=>'支付信息更新成功','data'=>[]]);
+
+ }
+ //获取新旧公司信息
+ protected function getStatementCompanyInfo($id = 0){
+ $oldInfo = M("company_statement_info","tab_")->field("id,company_info,company_id,company_type,company_name,pool_id,withdraw_type")->where("id = {$id}")->find();
+ if(empty($oldInfo)){
+ $this->ajaxReturn(['status' =>0 ,'msg'=>'未找到此结算单信息','data'=>[]]);
+ }
+ //获取新值
+ if($oldInfo['company_type'] == 3){
+ $Model = M("partner","tab_");
+ }else{
+ $Model = M("promote_company","tab_");
+ }
+ $newCompanyInfo = $Model->field("ali_user,ali_account")->where("id = {$oldInfo['company_id']}")->find();
+ return [$oldInfo,$newCompanyInfo];
+ }
+ //改变支付宝信息
+ protected function changeAliInfo($item,$newInfo)
+ {
+ $companyInfo = json_decode($item,true);
+ $companyInfo['ali_user'] = $newInfo['ali_user'];
+ $companyInfo['ali_account'] = $newInfo['ali_account'];
+ return json_encode($companyInfo,JSON_UNESCAPED_UNICODE);
+ }
+ //线上转线下
+ public function setStatementPayTapy()
+ {
+ $id = I("post.id",0);
+ $PayStatementDB = M("pay_statement_info","tab_");
+ //判断线上打款
+ $sWhere = [
+ 'company_id' => $oldInfo['company_id'],
+ 'statement_info_id' => $id
+ ];
+ $sCount = $PayStatementDB->where($sWhere)->where("pay_status = 1")->count();
+ if($sCount > 0) {
+ $this->ajaxReturn(['status' =>0 ,'msg'=>'已有付款成功的子单,无法转线下','data'=>[]]);
+ }
+ //删除打款
+ $PayStatementDB->where($sWhere)->delete();
+ //修改自身
+ $res = M("company_statement_info","tab_")->where("id = {$id}")->save(['verify_status' => 2, 'pay_check' => 0, 'pay_check_member_id' => 0, 'pay_check_time' => 0]);
+ if(empty($res)){
+ $this->ajaxReturn(['status' =>0 ,'msg'=>'转换失败','data'=>[]]);
+ }
+ $this->ajaxReturn(['status' =>1 ,'msg'=>'成功转为线下确认','data'=>[]]);
+ }
//导出
public function export() {
@@ -242,7 +353,7 @@ class PaymentController extends BaseController
->field("s.*,p.statement_num statement_pool_num")
->join("left join tab_company_statement_pool p ON p.id = s.pool_id")
->where(['s.id'=>['in',$id]])
- ->order("FIELD(s.pay_status,0,-1,1),s.verify_status desc")
+ ->order("statement_num desc")
->select();
foreach ($data as $key => $value) {
diff --git a/Application/Payment/View/Payment/lists.html b/Application/Payment/View/Payment/lists.html
index b6bccb2ef..1ba38c90e 100644
--- a/Application/Payment/View/Payment/lists.html
+++ b/Application/Payment/View/Payment/lists.html
@@ -8,7 +8,7 @@
-
+