瀏覽代碼

admin refill third

xiaoyu 3 年之前
父節點
當前提交
1121c76d2d

+ 82 - 0
admin/control/refill_third.php

@@ -1 +1,83 @@
 <?php
 <?php
+
+class refill_thirdControl extends SystemControl
+{
+    public function __construct()
+    {
+        parent::__construct();
+    }
+
+    public function indexOp()
+    {
+        $mod = Model('refill_third');
+
+        $condition = [];
+        if (trim($_GET['product_name']) != '') {
+            $condition['product_name'] = ['like', '%' . $_GET['product_name'] . '%'];
+        }
+        $list = $mod->getThirdProductList($condition, 30);
+
+        Tpl::output('product_list', $list);
+        Tpl::output('page', $mod->showpage());
+        Tpl::showpage('third.product.list');
+    }
+
+    public function product_addOp()
+    {
+        if (chksubmit()) {
+            $obj_validate = new Validator();
+            $obj_validate->validateparam = [
+                ["input" => trim($_POST["product_name"]), "require" => "true", "message" => '产品名称不能为空'],
+                ["input" => trim($_POST["refill_amount"]), "require" => "true", "message" => '产品面值不能为空'],
+            ];
+            $error = $obj_validate->validate();
+            if ($error != '') {
+                showMessage($error);
+            } else {
+                $mod = Model('refill_third');
+                $insert['product_name'] = trim($_POST['product_name']);
+                $insert['refill_amount'] = trim($_POST['refill_amount']);
+                $last_item = $mod->table('third_product')->order('system_code desc')->find();
+                if (empty($last_item)) {
+                    $system_code = 'XYZ100001';
+                } else {
+                    $last_code = $last_item['system_code'];
+                    $last_code = explode('XYZ',$last_code);
+                    $system_code = intval($last_code[1] + 1);
+                    $system_code = "XYZ{$system_code}";
+                }
+                $insert['system_code'] = $system_code;
+                $result = $mod->addThirdProduct($insert);
+                if ($result) {
+                    showMessage('添加成功', 'index.php?act=refill_third&op=index');
+                } else {
+                    showMessage('添加失败');
+                }
+            }
+        }
+        Tpl::showpage('third.product.add');
+    }
+
+    public function product_editOp()
+    {
+        $system_code = $_GET['system_code'] ?? $_POST['system_code'];
+        $mod = Model('refill_third');
+        $third_product = $mod->findThirdProduct($system_code);
+        if(empty($third_product)) {
+            showMessage('产品不存在');
+        }
+        if(chksubmit()) {
+            $updata['product_name'] = trim($_POST['product_name']);
+            $updata['refill_amount'] = trim($_POST['refill_amount']);
+            $result = $mod->editGroup($system_code, $updata);
+            if ($result) {
+                showMessage('编辑成功', 'index.php?act=refill_third&op=index');
+            } else {
+                showMessage('编辑失败');
+            }
+        }else{
+            Tpl::output('third_product', $third_product);
+            Tpl::showpage('third.product.edit');
+        }
+    }
+}

+ 1 - 0
admin/include/menu.php

@@ -101,6 +101,7 @@ $arr = array(
 					array('args'=>'index,ordersendlist,merchant',			'text'=>'订单监控'),
 					array('args'=>'index,ordersendlist,merchant',			'text'=>'订单监控'),
 					array('args'=>'index,orderstats,merchant',				'text'=>'对账管理'),
 					array('args'=>'index,orderstats,merchant',				'text'=>'对账管理'),
 					array('args'=>'stats,card_key,merchant',				'text'=>'卡密管理'),
 					array('args'=>'stats,card_key,merchant',				'text'=>'卡密管理'),
+					array('args'=>'index,refill_third,merchant',			'text'=>'增值业务管理'),
 					array('args'=>'index,refill_stock,merchant',			'text'=>'库存管理'),
 					array('args'=>'index,refill_stock,merchant',			'text'=>'库存管理'),
 					array('args'=>'index,refill_successful,merchant',		'text'=>'成功率监控'),
 					array('args'=>'index,refill_successful,merchant',		'text'=>'成功率监控'),
 					array('args'=>'index,refill_order_manual,merchant',		'text'=>'订单手动处理'),
 					array('args'=>'index,refill_order_manual,merchant',		'text'=>'订单手动处理'),

+ 78 - 0
admin/templates/default/third.product.add.php

@@ -0,0 +1,78 @@
+<?php defined('InShopNC') or exit('Access Invalid!'); ?>
+
+<div class="page">
+    <div class="fixed-bar">
+        <div class="item-title">
+            <h3>增值业务管理</h3>
+            <ul class="tab-base">
+                <li><a href="index.php?act=refill_third&op=index"><span><?php echo $lang['nc_manage'] ?></span></a></li>
+                <li><a href="JavaScript:void(0);" class="current"><span><?php echo $lang['nc_new'] ?>产品</span></a></li>
+            </ul>
+        </div>
+    </div>
+    <div class="fixed-empty"></div>
+    <form id="user_form" enctype="multipart/form-data" method="post">
+        <input type="hidden" name="form_submit" value="ok"/>
+        <table class="table tb-type2">
+            <tbody>
+            <tr class="noborder">
+                <td colspan="2" class="required"><label class="validation" for="product_name">产品名称:</label></td>
+            </tr>
+            <tr class="noborder">
+                <td class="vatop rowform"><input type="text" value="" name="product_name" id="product_name" class="txt"></td>
+                <td class="vatop tips"></td>
+            </tr>
+            <tr class="noborder">
+                <td colspan="2" class="required"><label class="validation" for="refill_amount">产品面值:</label></td>
+            </tr>
+            <tr class="noborder">
+                <td class="vatop rowform"><input type="text" value="" name="refill_amount" id="refill_amount" class="txt"></td>
+                <td class="vatop tips"></td>
+            </tr>
+            </tbody>
+            <tfoot>
+            <tr class="tfoot">
+                <td colspan="15"><a href="JavaScript:void(0);" class="btn" id="submitBtn"><span><?php echo $lang['nc_submit']; ?></span></a></td>
+            </tr>
+            </tfoot>
+        </table>
+    </form>
+</div>
+<script type="text/javascript" src="<?php echo RESOURCE_SITE_URL; ?>/js/dialog/dialog.js" id="dialog_js"
+        charset="utf-8"></script>
+<script type="text/javascript" src="<?php echo RESOURCE_SITE_URL; ?>/js/jquery-ui/jquery.ui.js"></script>
+<script type="text/javascript" src="<?php echo RESOURCE_SITE_URL; ?>/js/ajaxfileupload/ajaxfileupload.js"></script>
+<script type="text/javascript" src="<?php echo RESOURCE_SITE_URL; ?>/js/jquery.Jcrop/jquery.Jcrop.js"></script>
+<link href="<?php echo RESOURCE_SITE_URL; ?>/js/jquery.Jcrop/jquery.Jcrop.min.css" rel="stylesheet" type="text/css"
+      id="cssfile2"/>
+<script type="text/javascript">
+    $(function () {
+        //按钮先执行验证再提交表单
+        $("#submitBtn").click(function () {
+            if ($("#user_form").valid()) {
+                $("#user_form").submit();
+            }
+        });
+        $('#user_form').validate({
+            errorPlacement: function (error, element) {
+                error.appendTo(element.parent().parent().prev().find('td:first'));
+            },
+            rules: {
+                product_name: {
+                    required: true
+                },
+                refill_amount: {
+                    required: true
+                }
+            },
+            messages: {
+                product_name: {
+                    required: '产品名称不能为空',
+                },
+                refill_amount: {
+                    required: '产品面值不能为空',
+                }
+            }
+        });
+    });
+</script>

+ 103 - 0
admin/templates/default/third.product.list.php

@@ -0,0 +1,103 @@
+<?php defined('InShopNC') or exit('Access Invalid!'); ?>
+
+<div class="page">
+    <div class="fixed-bar">
+        <div class="item-title">
+            <h3>增值业务管理</h3>
+            <ul class="tab-base">
+                <li><a href="JavaScript:void(0);" class="current"><span>增值产品列表</span></a></li>
+                <li><a href="index.php?act=refill_third&op=product_add"><span><?php echo $lang['nc_new'] ?>产品</span></a></li>
+            </ul>
+        </div>
+    </div>
+    <div class="fixed-empty"></div>
+    <form method="get" name="formSearch" id="formSearch">
+        <input type="hidden" value="refill_third" name="act">
+        <input type="hidden" value="index" name="op">
+        <table class="tb-type1 noborder search">
+            <tbody>
+            <tr>
+                <th><label for="product_name">通道组名称</label></th>
+                <td><input type="text" name="product_name" id="product_name" class="txt"  value="<?php echo $_GET['product_name']; ?>"></td>
+                <td><a href="javascript:void(0);" id="ncsubmit" class="btn-search "
+                       title="<?php echo $lang['nc_query']; ?>">&nbsp;</a>
+                    <?php if ($_GET['product_name'] != '') { ?>
+                        <a href="index.php?act=refill_third&op=index" class="btns "
+                           title="<?php echo $lang['nc_cancel_search']; ?>"><span><?php echo $lang['nc_cancel_search']; ?></span></a>
+                    <?php } ?></td>
+            </tr>
+            </tbody>
+        </table>
+    </form>
+    <!--   <table class="table tb-type2" id="prompt">-->
+    <!--    <tbody>-->
+    <!--      <tr class="space odd">-->
+    <!--        <th colspan="12"><div class="title">-->
+    <!--            <h5>--><?php //echo $lang['nc_prompts'];?><!--</h5>-->
+    <!--            <span class="arrow"></span></div></th>-->
+    <!--      </tr>-->
+    <!--      <tr>-->
+    <!--        <td><ul>-->
+    <!--            <li>--><?php //echo $lang['store_help1'];?><!--</li>-->
+    <!--          </ul></td>-->
+    <!--      </tr>-->
+    <!--    </tbody>-->
+    <!--  </table>-->
+    <form method="post" id="merchant_name_form">
+        <input type="hidden" name="form_submit" value="ok"/>
+        <table class="table tb-type2">
+            <thead>
+            <tr class="thead">
+                <th>产品编码</th>
+                <th>产品名称</th>
+                <th>面值</th>
+                <th class="align-center">操作</th>
+            </tr>
+            </thead>
+            <tbody>
+            <?php if (!empty($output['product_list']) && is_array($output['product_list'])) { ?>
+                <?php foreach ($output['product_list'] as $k => $v) { ?>
+                    <tr class="trFlex">
+                        <td><?php echo $v['system_code']; ?></td>
+                        <td><?php echo $v['product_name']; ?></td>
+                        <td><?php echo $v['refill_amount']; ?></td>
+                        <td class="align-center w200">
+                            <a href="index.php?act=refill_third&op=product_edit&system_code=<?php echo $v['system_code'] ?>">编辑</a>
+<!--                           | <a href="index.php?act=provider_group&op=provider_choose&group_id=--><?php //echo $v['group_id'] ?><!--">编辑组内通道</a>-->
+                        </td>
+                    </tr>
+                <?php } ?>
+            <?php } else { ?>
+                <tr class="no_data">
+                    <td colspan="4"><?php echo $lang['nc_no_record']; ?></td>
+                </tr>
+            <?php } ?>
+            </tbody>
+            <tfoot>
+            <tr class="tfoot">
+                <td></td>
+                <td colspan="4">
+                    <div class="pagination"><?php echo $output['page']; ?></div>
+                </td>
+            </tr>
+            </tfoot>
+        </table>
+    </form>
+</div>
+<script type="text/javascript" src="<?php echo RESOURCE_SITE_URL; ?>/js/jquery.edit.js" charset="utf-8"></script>
+<script>
+    $(function () {
+        $('#ncsubmit').click(function () {
+            $('input[name="op"]').val('index');
+            $('#formSearch').submit();
+        });
+        // 表格hover时背景
+        $('.trFlex').each(function () {
+            $(this).hover(function () {
+                $(this)[0].style.backgroundColor = '#cbe9f3'
+            },function() {
+                $(this)[0].style.backgroundColor = '#fff'
+            })
+        })
+    });
+</script>

+ 10 - 1
data/model/refill_third.model.php

@@ -14,6 +14,15 @@ class refill_thirdModel extends Model
 
 
     public function addThirdProduct($insert)
     public function addThirdProduct($insert)
     {
     {
-        return $this->insert($insert);
+        return $this->table('third_product')->insert($insert);
+    }
+
+    public function findThirdProduct($system_code)
+    {
+        return $this->table('third_product')->where(['system_code' => $system_code])->find();
+    }
+
+    public function editThirdProduct($system_code, $data){
+        return $this->table('third_product')->where(['system_code' => $system_code])->update($data);
     }
     }
 }
 }