新增商户固定

master
chenzhi 4 years ago
parent ad49a9a419
commit c4849ffc7c

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

@ -89,10 +89,20 @@
</tr>
<tr>
<td class="l"><i class="mustmark">*</i>商户主体:</td>
<td class="r table_radio">
<td class="r">
<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>
</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>
</td> -->
</tr>
<tr>
<td class="l"><i class="mustmark">*</i>商户账号:</td>

@ -95,9 +95,19 @@
<div class="input-list">
<input type="text" name="name" placeholder="请输入支付配置名称" class="" value="" style="width: 150px">
</div>
<div class="input-list">
<!-- <div class="input-list">
<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 class="input-list">
<input type="text" name="account" placeholder="请输入商户账号" class="" value="" style="width: 150px">
</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