新增商户固定

master
chenzhi 4 years ago
parent ad49a9a419
commit c4849ffc7c

@ -4,6 +4,7 @@ namespace Admin\Controller;
use User\Api\UserApi as UserApi; use User\Api\UserApi as UserApi;
use Base\Service\PaymentMerchantService; use Base\Service\PaymentMerchantService;
use Base\Service\MerchantMainService;
use Base\Service\PaymentRuleService; use Base\Service\PaymentRuleService;
use Base\Service\PromoteCompanyService; use Base\Service\PromoteCompanyService;
use Base\Service\GameService; use Base\Service\GameService;
@ -19,7 +20,8 @@ class PaymentMerchantController extends ThinkController
$page = I('p', 1); $page = I('p', 1);
$row = I('row', 10); $row = I('row', 10);
$name = I('name', ''); $name = I('name', '');
$mainName = I('main_name', ''); // $mainName = I('main_name', '');
$mainId = I('main_id', 0);
$adminId = I('admin_id', 0); $adminId = I('admin_id', 0);
$channel = I('channel', 0); $channel = I('channel', 0);
$account = I('account', ''); $account = I('account', '');
@ -32,8 +34,8 @@ class PaymentMerchantController extends ThinkController
if ($name != '') { if ($name != '') {
$conditions['name'] = ['like', '%' . $name . '%']; $conditions['name'] = ['like', '%' . $name . '%'];
} }
if ($mainName != '') { if ($mainId != 0) {
$conditions['main_name'] = ['like', '%' . $mainName . '%']; $conditions['main_id'] = $mainId;
} }
if ($account != '') { if ($account != '') {
$conditions['account'] = ['like', '%' . $account . '%']; $conditions['account'] = ['like', '%' . $account . '%'];
@ -98,6 +100,8 @@ class PaymentMerchantController extends ThinkController
$this->assign('ways', PaymentMerchantService::$ways); $this->assign('ways', PaymentMerchantService::$ways);
$this->assign('statusList', PaymentMerchantService::$statusList); $this->assign('statusList', PaymentMerchantService::$statusList);
$this->assign('channels', PaymentMerchantService::$channels); $this->assign('channels', PaymentMerchantService::$channels);
$MerchantMainService = new MerchantMainService();
$this->assign('merchantMain', $MerchantMainService->getSelectList());
$this->display(); $this->display();
} }
@ -105,6 +109,8 @@ class PaymentMerchantController extends ThinkController
{ {
$this->meta_title = '添加收款商户'; $this->meta_title = '添加收款商户';
$this->assign('channels', PaymentMerchantService::$channels); $this->assign('channels', PaymentMerchantService::$channels);
$MerchantMainService = new MerchantMainService();
$this->assign('merchantMain', $MerchantMainService->getSelectList());
$this->display('form'); $this->display('form');
} }
@ -158,6 +164,8 @@ class PaymentMerchantController extends ThinkController
$this->assign('record', $merchant); $this->assign('record', $merchant);
$this->assign('config', $config); $this->assign('config', $config);
$this->assign('ways', $ways); $this->assign('ways', $ways);
$MerchantMainService = new MerchantMainService();
$this->assign('merchantMain', $MerchantMainService->getSelectList());
$this->display('form'); $this->display('form');
} }
@ -171,7 +179,7 @@ class PaymentMerchantController extends ThinkController
$account = I('account', ''); $account = I('account', '');
$config = I('config', []); $config = I('config', []);
$ways = I('ways', []); $ways = I('ways', []);
$mainName = I('main_name', ''); $mainId = I('main_id', 0);
if ($name == '') { if ($name == '') {
$this->ajaxReturn([ $this->ajaxReturn([
@ -179,10 +187,10 @@ class PaymentMerchantController extends ThinkController
'message' => '请输入支付配置名称', 'message' => '请输入支付配置名称',
]); ]);
} }
if ($mainName == '') { if ($mainId === 0) {
$this->ajaxReturn([ $this->ajaxReturn([
'status' => 0, 'status' => 0,
'message' => '请输入商户商户主体', 'message' => '请选择商户商户主体',
]); ]);
} }
if ($account == '') { if ($account == '') {
@ -205,6 +213,9 @@ class PaymentMerchantController extends ThinkController
$paymentMerchantService = new PaymentMerchantService(); $paymentMerchantService = new PaymentMerchantService();
$waysValue = $paymentMerchantService->getWaysValue($ways); $waysValue = $paymentMerchantService->getWaysValue($ways);
$MerchantMainService = new MerchantMainService();
$mainName = $MerchantMainService->getNameById($mainId);
$userAuth = session('user_auth'); $userAuth = session('user_auth');
$data = []; $data = [];
@ -217,6 +228,7 @@ class PaymentMerchantController extends ThinkController
$data['config'] = json_encode($config); $data['config'] = json_encode($config);
$data['update_time'] = time(); $data['update_time'] = time();
$data['main_name'] = $mainName; $data['main_name'] = $mainName;
$data['main_id'] = $mainId;
if ($id == 0) { if ($id == 0) {
$data['create_time'] = time(); $data['create_time'] = time();
$data['channel'] = $channel; $data['channel'] = $channel;
@ -233,6 +245,7 @@ class PaymentMerchantController extends ThinkController
]); ]);
} else { } else {
$this->changeSpendPartnerType($mainId,$id);
$data['identifier'] = $paymentMerchantService->getIdentifierByConfig($config, $merchant['channel']); $data['identifier'] = $paymentMerchantService->getIdentifierByConfig($config, $merchant['channel']);
M('payment_merchant', 'tab_')->where(['id' => $id])->save($data); M('payment_merchant', 'tab_')->where(['id' => $id])->save($data);
@ -252,6 +265,18 @@ class PaymentMerchantController extends ThinkController
]); ]);
} }
private function changeSpendPartnerType($mainId,$merchantId)
{
$oldMainId = M('payment_merchant', 'tab_')->where(['id' => $merchantId])->getField("main_id");
if($oldMainId != $mainId){
//更改支付表
$save = [
'partner_type'=>$mainId
];
M("Spend","tab_")->where("merchant_id = '{$merchantId}'")->save($save);
}
}
public function delete() public function delete()

@ -89,10 +89,20 @@
</tr> </tr>
<tr> <tr>
<td class="l"><i class="mustmark">*</i>商户主体:</td> <td class="l"><i class="mustmark">*</i>商户主体:</td>
<td class="r table_radio"> <td class="r">
<input type="text" class="txt ratio" name="main_name" id="main_name" value="<?=$record?$record['main_name']:''?>" placeholder="请输入商户主体"> <select name="main_id" id="main_id" class="select_gallery">
<option value="">请选择商户主体</option>
<?php foreach($merchantMain as $key => $name):?>
<option value="<?=$key?>" <?php if($record && $record['main_id'] == $key):?>selected<?php endif;?>><?=$name?></option>
<?php endforeach;?>
</select>
<span class="notice-text"></span> <span class="notice-text"></span>
</td> </td>
<!-- <td class="r table_radio">
<input type="text" class="txt ratio" name="main_name" id="main_name" value="<?=$record?$record['main_name']:''?>" placeholder="请输入商户主体">
<span class="notice-text"></span>
</td> -->
</tr> </tr>
<tr> <tr>
<td class="l"><i class="mustmark">*</i>商户账号:</td> <td class="l"><i class="mustmark">*</i>商户账号:</td>

@ -95,9 +95,19 @@
<div class="input-list"> <div class="input-list">
<input type="text" name="name" placeholder="请输入支付配置名称" class="" value="" style="width: 150px"> <input type="text" name="name" placeholder="请输入支付配置名称" class="" value="" style="width: 150px">
</div> </div>
<div class="input-list"> <!-- <div class="input-list">
<input type="text" name="main_name" placeholder="请输入商户主体" class="" value="" style="width: 150px"> <input type="text" name="main_name" placeholder="请输入商户主体" class="" value="" style="width: 150px">
</div> -->
<div class="input-list">
<select id="merchant_main_select" name="main_id" class="select_gallery" style="width:200px;">
<option value="0">请选择商户主体</option>
<?php foreach($merchantMain as $key => $name):?>
<option value="<?=$key?>"><?=$name?></option>
<?php endforeach;?>
</select>
</div> </div>
<div class="input-list"> <div class="input-list">
<input type="text" name="account" placeholder="请输入商户账号" class="" value="" style="width: 150px"> <input type="text" name="account" placeholder="请输入商户账号" class="" value="" style="width: 150px">
</div> </div>

@ -0,0 +1,16 @@
<?php
namespace Base\Service;
use Base\Facade\Request;
class MerchantMainService {
public function getSelectList()
{
return M("MerchantMain","tab_")->getField("id,name",true);
}
public function getNameById($id)
{
return M("MerchantMain","tab_")->where("id = '{$id}'")->getField("name");
}
}
Loading…
Cancel
Save