|
@@ -30,19 +30,36 @@ class merchantControl extends SystemControl
|
|
|
$lang = Language::getLangContent();
|
|
|
$model_merchant = Model('merchant');
|
|
|
|
|
|
- $condition['inner_status'] = 0;
|
|
|
if (trim($_GET['merchant_name']) != '') {
|
|
|
$condition['name'] = ['like', '%' . $_GET['merchant_name'] . '%'];
|
|
|
Tpl::output('merchant_name', $_GET['merchant_name']);
|
|
|
}
|
|
|
|
|
|
- $merchant_list = $model_merchant->getMerchantList($condition, 20, 'mchid desc');
|
|
|
+ $merchant_list = $model_merchant->getMerchantList($condition, 25, 'mchid desc');
|
|
|
|
|
|
+ $merchant_state_text = ['使用中', '已禁用'];
|
|
|
+ Tpl::output('merchant_state_text', $merchant_state_text);
|
|
|
Tpl::output('merchant_list', $merchant_list);
|
|
|
Tpl::output('page', $model_merchant->showpage('2'));
|
|
|
Tpl::showpage('merchant.index');
|
|
|
}
|
|
|
|
|
|
+ public function changeStateOp()
|
|
|
+ {
|
|
|
+ $mchid = intval($_GET['mchid']);
|
|
|
+ $state = intval($_GET['state']);
|
|
|
+ $model_merchant = Model('merchant');
|
|
|
+ $merchant_info = $model_merchant->getMerchantInfo(['mchid' => $mchid]);
|
|
|
+ if (empty($merchant_info) || !in_array($state , [1,2])) {
|
|
|
+ showMessage('操作成功', 'index.php?act=merchant&op=merchant');
|
|
|
+ }
|
|
|
+ $resp = $model_merchant->editMerchant(['merchant_state' => $state] , ['mchid' => $mchid]);
|
|
|
+ if(!$resp){
|
|
|
+ showMessage('操作失败', 'index.php?act=merchant&op=merchant', 'html', 'error');
|
|
|
+ }
|
|
|
+ showMessage('操作成功', 'index.php?act=merchant&op=merchant');
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 新增机构
|
|
|
*/
|
|
@@ -72,10 +89,10 @@ class merchantControl extends SystemControl
|
|
|
$model_member = Model('member');
|
|
|
try {
|
|
|
$trans = new trans_wapper($model_merchant, __METHOD__);
|
|
|
- $insert_member['member_name'] = md5($name.time());
|
|
|
+ $insert_member['member_name'] = md5($name . time());
|
|
|
$insert_member['member_passwd'] = $pwd;
|
|
|
$insert_id = $model_member->addMember($insert_member);
|
|
|
- if($insert_id == false){
|
|
|
+ if ($insert_id == false) {
|
|
|
$trans->rollback();
|
|
|
showMessage('操作失败', 'index.php?act=merchant&op=merchant', 'html', 'error');
|
|
|
}
|
|
@@ -114,8 +131,7 @@ class merchantControl extends SystemControl
|
|
|
public function priceOp()
|
|
|
{
|
|
|
$lang = Language::getLangContent();
|
|
|
- if (chksubmit())
|
|
|
- {
|
|
|
+ if (chksubmit()) {
|
|
|
$mchid = $_POST['mchid'];
|
|
|
|
|
|
//合并表单数据
|
|
@@ -124,8 +140,8 @@ class merchantControl extends SystemControl
|
|
|
$prices = $_POST['price'];
|
|
|
foreach ($card_types as $key => $card_type) {
|
|
|
$data['card_type'] = $card_type;
|
|
|
- $data['spec'] = intval($specs[$key]);
|
|
|
- $data['price'] = number_format($prices[$key],2,'.','');
|
|
|
+ $data['spec'] = intval($specs[$key]);
|
|
|
+ $data['price'] = number_format($prices[$key], 2, '.', '');
|
|
|
$params[] = $data;
|
|
|
}
|
|
|
|
|
@@ -141,12 +157,11 @@ class merchantControl extends SystemControl
|
|
|
$types[] = $item['card_type'];
|
|
|
}
|
|
|
$types = array_unique($types);
|
|
|
- return implode(',',$types);
|
|
|
+ return implode(',', $types);
|
|
|
};
|
|
|
|
|
|
$inserts = [];
|
|
|
- foreach ($spec_items as $spec => $items)
|
|
|
- {
|
|
|
+ foreach ($spec_items as $spec => $items) {
|
|
|
$price_items = [];
|
|
|
foreach ($items as $item) {
|
|
|
$price = $item['price'];
|
|
@@ -164,7 +179,7 @@ class merchantControl extends SystemControl
|
|
|
$inserts[] = $insert;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
$model_merchant = Model('merchant');
|
|
|
try {
|
|
|
$trans = new trans_wapper($model_merchant, __METHOD__);
|
|
@@ -206,17 +221,14 @@ class merchantControl extends SystemControl
|
|
|
$items = $model_merchant->table('merchant_price')->where(['mchid' => $mchid])->select();
|
|
|
|
|
|
$items = $this->PricesFormat($items);
|
|
|
- foreach ($goods as $key => $value)
|
|
|
- {
|
|
|
- foreach ($value as $amount)
|
|
|
- {
|
|
|
+ foreach ($goods as $key => $value) {
|
|
|
+ foreach ($value as $amount) {
|
|
|
$goods_name = $this->scard_type($key);
|
|
|
$data['goods_name'] = $goods_name;
|
|
|
$data['card_type'] = $key;
|
|
|
$data['spec'] = $amount;
|
|
|
$data['price'] = 0;
|
|
|
- foreach ($items as $item)
|
|
|
- {
|
|
|
+ foreach ($items as $item) {
|
|
|
if ($amount == $item['spec'] && $key == $item['card_type']) {
|
|
|
$data['price'] = $item['price'];
|
|
|
}
|