Bläddra i källkod

后台充值券的管理

DengTao 8 år sedan
förälder
incheckning
90ab09f046

+ 58 - 58
www/protected/controllers/ROrderController.php

@@ -128,7 +128,7 @@ class ROrderController extends AdminController{
 
         // 服务站处理
         // if ($station != 'all') {
-           // $criteria->station = new MongoId($station);
+        // $criteria->station = new MongoId($station);
         //}
 
         $cursor = ROrder::model()->findAll($criteria);
@@ -159,7 +159,7 @@ class ROrderController extends AdminController{
         $technician_ids = array();
         $technician_names = array();
         $technicians = array();
-       // $nums = Yii::app()->request->getParam('tech_nums')+1;
+        // $nums = Yii::app()->request->getParam('tech_nums')+1;
 
         for($i=0;$i<500;$i++) {
             if(Yii::app()->request->getParam('extra_add_info_'.$i)) {
@@ -183,10 +183,10 @@ class ROrderController extends AdminController{
                     $technicians[$key]['technician_name']  = $technician_obj->name;
                 } else {
                     CommonFn::requestAjax(false, '保洁师不存在');
-                   break;
+                    break;
                 }
             }
-        // ID为0时根据输入框信息查询
+            // ID为0时根据输入框信息查询
         } else if (isset($technician_names)) {
             $criteria = new EMongoCriteria();
             foreach($technician_names as $key => $technician_name) {
@@ -203,7 +203,7 @@ class ROrderController extends AdminController{
         } else {
             $technician_obj = null;
             //$technician_id = 0;
-           // $technician_name = '';
+            // $technician_name = '';
             foreach($technicians as $key => $value) {
                 $technicians[$key]['$technician_id'] = 0;
                 $technicians[$key]['$technician_name'] = 0;
@@ -344,7 +344,7 @@ class ROrderController extends AdminController{
         //$order->technician_name = $technician_name;
         $order->technicians = $technicians;
 
-       //var_dump($order);exit;
+        //var_dump($order);exit;
         $arr_order = array('cancel_time','refund_time','finish_time','status','booking_time','deal_time','remark', 'station', 'technicians');
         $success = $order->save(true,$arr_order);
 
@@ -501,8 +501,8 @@ class ROrderController extends AdminController{
         }
 
         //if($channel == 'wz_app' || $channel == 'wx_pub'){
-            //CommonFn::requestAjax(false, '不能录入渠道为壹管家微信||壹管家APP的订单', array());
-            //exit;
+        //CommonFn::requestAjax(false, '不能录入渠道为壹管家微信||壹管家APP的订单', array());
+        //exit;
         //}
 
         // 时间处理
@@ -662,19 +662,19 @@ class ROrderController extends AdminController{
                 // ID为0时根据输入框信息查询
             } else {
                 foreach ($technician_names as $key => $technician_name)
-                if ($technician_name != '') {
-                    $criteria = new EMongoCriteria();
-                    $criteria->name = $technician_name;
-                    $technician_obj = TechInfo::model()->find($criteria);
-                    if ($technician_obj) {
-                        $technicians[$key]['technician_id'] = $technician_obj->_id;
-                        $technicians[$key]['technician_name']  = $technician_obj->name;
+                    if ($technician_name != '') {
+                        $criteria = new EMongoCriteria();
+                        $criteria->name = $technician_name;
+                        $technician_obj = TechInfo::model()->find($criteria);
+                        if ($technician_obj) {
+                            $technicians[$key]['technician_id'] = $technician_obj->_id;
+                            $technicians[$key]['technician_name']  = $technician_obj->name;
+                        } else {
+                            CommonFn::requestAjax(false, '保洁师不存在');
+                        }
                     } else {
-                        CommonFn::requestAjax(false, '保洁师不存在');
+                        CommonFn::requestAjax(false, '保洁师姓名不能为空');
                     }
-                } else {
-                    CommonFn::requestAjax(false, '保洁师姓名不能为空');
-                }
 
             }
             $technician_objs[] = $technician_obj;
@@ -689,52 +689,52 @@ class ROrderController extends AdminController{
         $order->technicians = $technicians;
         $success = $order->save(true, array('technicians'));
 
-            if ($toTech && $success) {
-                foreach ($technician_objs as $technician_obj) {
-                    // 发送给被分配保洁师
-                    $wechat = O2oApp::getWechatActive();
-                    $url_prefix = ENVIRONMENT == 'product' ? 'http://api.yiguanjia.me' : 'http://apitest.yiguanjia.me';
-                    if (!empty($technician_obj->weixin_userid)) {
-                        $wechat_data = array(
-                            'touser' => $technician_obj->weixin_userid,
-                            'msgtype' => 'news',
-                            'agentid' => '24',
-                            'news' => array(
-                                'articles' => array(
-                                    array(
-                                        'title' => '壹管家提示-新订单',
-                                        'description' => $technician_obj->name . '你好!刚刚有一个新的订单被分配给你,请点击查看。',
-                                        'url' => $url_prefix . '/index.php?r=o2o/myOrder/info&order=' . $id . '&user=' . $technician_obj->_id,
-                                    ),
+        if ($toTech && $success) {
+            foreach ($technician_objs as $technician_obj) {
+                // 发送给被分配保洁师
+                $wechat = O2oApp::getWechatActive();
+                $url_prefix = ENVIRONMENT == 'product' ? 'http://api.yiguanjia.me' : 'http://apitest.yiguanjia.me';
+                if (!empty($technician_obj->weixin_userid)) {
+                    $wechat_data = array(
+                        'touser' => $technician_obj->weixin_userid,
+                        'msgtype' => 'news',
+                        'agentid' => '24',
+                        'news' => array(
+                            'articles' => array(
+                                array(
+                                    'title' => '壹管家提示-新订单',
+                                    'description' => $technician_obj->name . '你好!刚刚有一个新的订单被分配给你,请点击查看。',
+                                    'url' => $url_prefix . '/index.php?r=o2o/myOrder/info&order=' . $id . '&user=' . $technician_obj->_id,
                                 ),
                             ),
-                        );
-                        $wechat->sendMessage($wechat_data);
-                    }
+                        ),
+                    );
+                    $wechat->sendMessage($wechat_data);
                 }
+            }
 
-                // 发送给原保洁师
-                foreach ($fromTechs as $fromTech) {
-                    $fromTechObj = TechInfo::get($fromTech);
-                    if (!empty($fromTechObj) && !empty($fromTechObj->weixin_userid)) {
-                        $wechat_data = array(
-                            'touser' => $fromTechObj->weixin_userid,
-                            'msgtype' => 'news',
-                            'agentid' => '24',
-                            'news' => array(
-                                'articles' => array(
-                                    array(
-                                        'title' => '壹管家提示-订单已被重新分配',
-                                        'description' => $fromTechObj->name . '你好!预定时间在' . date('m月d日H:i', $order->booking_time) . '的订单已被分配给其他保洁师。',
-                                        'url' => $url_prefix . '/index.php?r=o2o/myOrder/info&order=' . $id . '&user=' . $technician_obj->_id,
-                                    ),
+            // 发送给原保洁师
+            foreach ($fromTechs as $fromTech) {
+                $fromTechObj = TechInfo::get($fromTech);
+                if (!empty($fromTechObj) && !empty($fromTechObj->weixin_userid)) {
+                    $wechat_data = array(
+                        'touser' => $fromTechObj->weixin_userid,
+                        'msgtype' => 'news',
+                        'agentid' => '24',
+                        'news' => array(
+                            'articles' => array(
+                                array(
+                                    'title' => '壹管家提示-订单已被重新分配',
+                                    'description' => $fromTechObj->name . '你好!预定时间在' . date('m月d日H:i', $order->booking_time) . '的订单已被分配给其他保洁师。',
+                                    'url' => $url_prefix . '/index.php?r=o2o/myOrder/info&order=' . $id . '&user=' . $technician_obj->_id,
                                 ),
                             ),
-                        );
-                        $wechat->sendMessage($wechat_data);
-                    }
+                        ),
+                    );
+                    $wechat->sendMessage($wechat_data);
                 }
+            }
         }
         CommonFn::requestAjax($success, '', array());
     }
-}
+}

+ 152 - 0
www/protected/controllers/RechargeController.php

@@ -0,0 +1,152 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: PHP
+ * Date: 2016/9/28
+ * Time: 9:29
+ */
+class RechargeController extends AdminController {
+    public function actionIndex() {
+        $status_option = Recharge::$status_option;
+        $status = CommonFn::getComboboxData($status_option, 100, true, 100);
+
+        // 代金券信息
+        $criteria_main = new EMongoCriteria();
+        $criteria_main->status('==', 1);
+        $conpon_main = Coupon::model()->findAll($criteria_main);
+        $rows_main = CommonFn::getRowsFromCursor($conpon_main);
+        $main_row = array();
+        foreach($rows_main as $row){
+            $ids = (string)$row['_id'];
+            $main_row[$ids] = array('name' =>$row['name']);
+        }
+        $main_coupons = CommonFn::getComboboxData($main_row, 100, true, 100);
+
+        $this->render('index', array(
+            'status'         => $status,
+            'main_coupons' => $main_coupons,
+
+        ));
+    }
+
+
+    public function actionList() {
+
+        $search = Yii::app()->request->getParam('search', '');
+        $id = Yii::app()->request->getParam('id', '');
+
+
+        $params = CommonFn::getPageParams();
+
+        $criteria = new EMongoCriteria($params);
+
+
+        if ($id != ''){
+            $recharge_id = new MongoId($id);
+            $criteria->_id('==', $recharge_id);
+        }
+
+        if ($search != ''){
+            if(CommonFn::isMongoId($search)){
+                $criteria->_id('==', new MongoId($search));
+
+                $criteria->addCond('_id','or',new MongoId($search));
+                $criteria->addCond('user','or',new MongoId($search));
+            }
+
+        }
+
+        //var_dump($criteria);
+        $recharge = Recharge::model()->findAll($criteria);
+
+        $total = $recharge->count();
+
+        $rows = CommonFn::getRowsFromCursor($recharge);
+
+        $parsedRows = Recharge::model()->parse($rows);
+
+        echo CommonFn::composeDatagridData($parsedRows, $total);
+    }
+    //添加充值卡信息
+    public function actionAdd () {
+        $denomination = Yii::app()->request->getParam('denomination', '');
+        $cash_back = Yii::app()->request->getParam('cash_back', '0');
+        $status = Yii::app()->request->getParam('status', -1);
+        $desc = Yii::app()->request->getParam('desc', '');
+        $flag = empty($denomination);
+        $flag = $flag || $status == -1;
+        if ($flag) {
+            CommonFn::requestAjax(false, '请检查数据完整性', array());
+            exit;
+        }
+        $recharge = new Recharge();
+        $recharge->denomination = intval($denomination);//充值面额
+        $recharge->cash_back = intval($cash_back);//返现金额
+        $recharge->desc = $desc;//描述
+        $recharge->status = intval($status);//状态
+
+        $addRecharge_arr = array('denomination','cash_back','status','desc');
+        $success = $recharge->save(true, $addRecharge_arr);
+
+        CommonFn::requestAjax($success, '', array());
+
+    }
+
+
+    public function actionEdit() {
+        $denomination = intval(Yii::app()->request->getParam('denomination',''));//面额
+        $desc = Yii::app()->request->getParam('desc', '');//描述
+        $status = Yii::app()->request->getParam('status', '');
+        $id = Yii::app()->request->getParam('id', '');
+        $coupons = array();//代金券
+        $select_fun = Yii::app()->request->getParam('select_fun', '');
+
+        //指定状态
+        if ($status == 100) {
+            CommonFn::requestAjax(false, '必须指定状态!');
+        }
+        //填写面额
+        if (!isset($denomination)) {
+            CommonFn::requestAjax(false, '必须填写面额!');
+        }
+
+        if ($select_fun == 'coupon') {
+            //数组分割处理
+            $coupons = explode("<br />",nl2br(trim(Yii::app()->request->getParam('coupons'))));
+
+            foreach ($coupons as $coupon) {
+                foreach($coupons as $v){
+                    if ($v == $coupon) {
+                        CommonFn::requestAjax(false, '代金券重复 ');
+                        break;
+                    }
+                }
+                $coupon = new MongoId(rtrim(trim($coupon),','));
+                $coupon_obj = Coupon::get($coupon);
+
+                if (!$coupon_obj) {
+                    CommonFn::requestAjax(false, '代金券不存在');
+                    break;
+                }
+            }
+
+        } else{
+            //返现
+            $cash_back = intval(Yii::app()->request->getParam('cash_back', ''));
+        }
+        $criteria = new EMongoCriteria();
+        $criteria->_id = new MongoId($id);
+        $recharge = Recharge::model()->find($criteria);
+
+        $recharge->coupons = $coupons;
+        $recharge->cash_back = $cash_back;
+        $recharge->desc = $desc;
+        $recharge->denomination = $denomination;
+        $recharge->status = $status;
+        //保存修改的充值券信息
+        $addRecharge_arr = array('denomination','cash_back','status','desc','coupons');
+        $success = $recharge->save(true, $addRecharge_arr);
+        CommonFn::requestAjax($success, '', array());
+
+    }
+}

+ 1 - 1
www/protected/extensions/YiiMongoDbSuite/EMongoDocument.php

@@ -715,7 +715,7 @@ abstract class EMongoDocument extends EMongoEmbeddedDocument
 					)
 				);
 				
-			}			
+			}
 
 			if($result !== false) // strict comparison needed
 			{

+ 2 - 1
www/protected/modules/o2o/models/Recharge.php

@@ -72,7 +72,8 @@ class Recharge extends MongoAr
                 $coupons[] = $v;
             }
         }
-        $newRow['coupons'] = $coupons;
+
+        $newRow['coupons'] = CommonFn::get_val_if_isset($row,'coupons');
 
         $newRow['status'] = CommonFn::get_val_if_isset($row,'status',1);
         $newRow['action_user'] = CommonFn::get_val_if_isset($row,'action_user',"");

+ 624 - 0
www/protected/views/Recharge/index.php

@@ -0,0 +1,624 @@
+<style>
+    .f_label {width: 90px;}
+    .accordion-body {padding: 0;}
+    #view_select_position {
+        display:inline-block;
+        padding:1px 4px 1px 4px;
+        border:1px solid #999999;
+        text-decoration:none;
+        color:#333333;
+    }
+</style>
+
+<div id="main">
+    <div region="west" border="false" id="west_panel">
+        <table id="dg_content"></table>
+        <div id="tb_content">
+            <div class="tb_line">
+                <input id="ss" />
+                <span class="tb_label">服务</span>
+                <input id="filter_type" style="width:100px"/>
+            </div>
+            <div class="tb_line">
+                <span class="tb_label">状态: </span>
+                <input id="filter_status" />
+
+            </div>
+
+            <div style="margin: 3px 2px;padding:5px;border: 1px solid #95B8E7;">
+                <a href="#" class='easyui-linkbutton' plain="true" iconCls="icon-add" onclick="add_content();return false;">新增充值卡</a>
+            </div>
+        </div>
+    </div>
+    <div id="acc_container" class="accordion" region="center">
+        <div region="center" title="充值卡" data-options="iconCls:'icon-save',selected:true">
+            <div class="easyui-layout detail_layout">
+                <div data-options="region:'center'" class="detail_center">
+                    <div class="detail_main">
+                        <form id="content_form" method="post">
+                            <ul>
+                                <li class="f_item">
+                                    <div class="box">
+                                        <div class="f_label">
+                                            <span>ID: </span>
+                                        </div>
+                                        <div class="box_flex f_content">
+                                            <input type="hidden" name="id" id="recharge_id" value='' />
+                                            <span id="id_str"></span>
+                                        </div>
+                                    </div>
+                                </li>
+                                <li class="f_item">
+                                    <div class="box">
+                                        <div class="f_label">
+                                            <span>充值面额: </span>
+                                        </div>
+                                        <div class="box_flex f_content">
+                                            <input type="text" name="denomination" id="edit_denomination" value='' />
+                                            <span id="id_str"></span>
+                                        </div>
+                                    </div>
+                                </li>
+
+                                <li class="f_item">
+                                    <div class="box">
+                                        <div class="f_label">
+                                            <span>选择方式: </span>
+                                        </div>
+
+                                        <div class="box_flex f_content">
+                                        <input type="radio" name="select_fun" id="edit_cash_back" checked="true" value='cash_back' />返现金额
+                                            <span id="id_str"></span>
+                                        <input type="radio" name="select_fun" id="edit_coupon"  value="coupon" />使用代金券
+                                        </div>
+
+                                </li>
+
+                                <li class="f_item">
+                                    <div class="box">
+                                        <div class="f_label">
+                                            <span></span>
+                                        </div>
+                                        <div class="box_flex f_content" id="cash">
+                                            <input type="text" name="cash_back" id="edit_cash_back" value='' />
+                                        </div>
+                                        <div class="box_flex f_content" id="coupons" style="display: none;">
+                                            <div id="coupons_items"></div>
+                                            <textarea id="text_coupons" name="coupons" style="width: 250px;min-height: 50px" placeholder="若使用代金券,填写代金券id,多个代金券时用换行分割"></textarea>
+                                        </div>
+                                    </div>
+                                </li>
+
+                                <li class="f_item">
+                                    <div class="box">
+                                        <div class="f_label">
+                                            <span>介绍: </span>
+                                        </div>
+                                        <div class="box_flex f_content">
+                                            <textarea name="desc" style="width: 250px;min-height: 100px"></textarea>
+                                        </div>
+                                    </div>
+                                </li>
+
+
+                                <li class="f_item">
+                                    <div class="box">
+                                        <div class="f_label">
+                                            <span>状态:</span>
+                                        </div>
+                                        <div class="box_flex f_content">
+                                            <input id="setStatus" name="status" />
+                                        </div>
+                                    </div>
+                                </li>
+                                <li class="f_item">
+                                    <div class="box">
+                                        <div class="f_label">
+                                        </div>
+                                        <div class="box_flex f_content">
+                                            <span id="action_info" style="color:green;"></span>
+                                        </div>
+                                    </div>
+                                </li>
+
+                            </ul>
+                        </form>
+                    </div>
+                    <div data-options="region:'south'" class="detail_south">
+                        <div class="detail_toolbar">
+                            <a href="#" class="easyui-linkbutton set_button" iconCls="icon-save" onclick="save_content();return false;">保存</a>
+                        </div>
+                    </div>
+                </div>
+            </div>
+        </div>
+    </div>
+</div>
+<div style="display: none;">
+    <div id="add_dialog" style="padding: 15px 0;">
+        <form id="add_form" method="post">
+            <ul>
+                <li class="f_item">
+                    <div class="box">
+                        <div class="f_label">
+                            <span>充值面额: </span>
+                        </div>
+                        <div class="box_flex f_content">
+                            <input id="denomination" name="denomination" style="width: 250px;"  />
+                        </div>
+                    </div>
+                </li>
+
+                <li class="f_item">
+                    <div class="box">
+                        <div class="f_label">
+                            <span>返现的金额: </span>
+                        </div>
+                        <div class="box_flex f_content">
+                            <input id="cash_back" name="cash_back" style="width: 250px;"  />
+                        </div>
+                    </div>
+                </li>
+                <li class="f_item">
+                    <div class="box">
+                        <div class="f_label">
+                            <span>状态: </span>
+                        </div>
+                        <div class="box_flex f_content">
+                            <input id="setStatus_add" name="status" />
+                        </div>
+                    </div>
+                </li>
+
+                <li class="f_item">
+                    <div class="box">
+                        <div class="f_label">
+                            <span>介绍: </span>
+                        </div>
+                        <div class="box_flex f_content">
+                            <textarea name="desc" style="width: 250px;min-height: 100px"></textarea>
+                        </div>
+                    </div>
+                </li>
+
+
+
+            </ul>
+        </form>
+    </div>
+
+</div>
+
+<div style="display:none;">
+    <div id="refund_tip_dialog" style="padding: 30px 0;">
+        <div style="text-align:center;"><span id="refund_tip"></span></div>
+    </div>
+</div>
+<script language="javascript" type="text/javascript" src="<?php echo Yii::app()->request->baseUrl; ?>/js/coolautosuggest/jquery.coolautosuggest.js"></script>
+<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/js/coolautosuggest/jquery.coolautosuggest.css" />
+<script type="text/javascript">
+    var jq_dg_content = $('#dg_content');
+    var jq_content_form = $('#content_form');
+    var jq_filter_status = $('#filter_status');
+    var jq_setStatus_add = $('#setStatus_add');
+    var module_router = site_root + '/index.php?r=Recharge';
+    var status_data = <?php echo json_encode($status); ?>;
+    var main_coupons = <?php echo json_encode($main_coupons); ?>;
+    var jq_setStatus = $('#setStatus');
+    var w_width = $(window).width();
+    var w_height = $(window).height();
+    var jq_ss = $('#ss');
+    var jq_filter_coupons = $('#coupon');
+
+    var jq_add_dialog = $('#add_dialog');
+    var jq_add_form = $('#add_form');
+
+    var jq_date_start_order = $('#date_start_order');
+    var jq_date_end_order = $('#date_end_order');
+    var jq_date_start_book = $('#date_start_book');
+    var jq_date_end_book = $('#date_end_book');
+
+    var jq_set_precedence = $('#set_precedence');
+
+
+    var jq_acc = $('#acc_container');
+
+    $(function(){
+
+        jq_acc.accordion({
+            height: w_height - 18,
+            onSelect: function(title) {
+
+            }
+        });
+
+       /* jq_filter_coupons.combobox({
+            editable : false,
+            data : main_coupons,
+            onSelect : function () {
+                search_content();
+            }
+        })*/
+
+        jq_date_start_order.datebox({});
+        jq_date_end_order.datebox({});
+
+        jq_date_start_book.datebox({});
+        jq_date_end_book.datebox({});
+
+
+
+
+        var buttons = $.extend([], $.fn.datebox.defaults.buttons);
+        buttons[0].text = '确定';
+        buttons[0].handler=function(){
+            var vals = $('#booking_time').datetimebox('spinner').spinner('getValue').split(':');
+            $('#booking_time_str').val(  parseInt($('#booking_time_str').val())-(parseInt($('#booking_time_str').val())+8*3600)%86400 +vals[0]*3600+vals[1]*60);
+
+            var d=new Date(parseInt($('#booking_time_str').val())*1000);
+
+            $('#booking_time').datetimebox('setText',formatDate(d));
+            $('#booking_time').datetimebox('hidePanel');
+        };
+
+        $('#booking_time').datetimebox({
+            required: false,
+            showSeconds:false,
+            buttons:buttons,
+            onSelect: function(date){
+                var currentDate = new Date();
+                //console.log(date)
+                // if(currentDate>=date){
+                //     $.messager.show({
+                //         title: '提示',
+                //         msg: '必须选择现在之后的日期',
+                //         timeout: 3500,
+                //         showType: 'slide'
+                //     });
+                // }else{
+                    $('#booking_time_str').val(date.getTime()/1000);
+                // }
+            }
+        });
+
+       $('#booking_time_add').datetimebox({
+            required: false,
+            showSeconds:false,
+            //buttons:buttons_add,
+            onSelect: function(date){
+                var currentDate = new Date();
+                $('#booking_time_str_add').val(date.getTime()/1000);
+            }
+        });
+
+        $('#order_time_add').datetimebox({
+            required: false,
+            showSeconds:false,
+            //buttons:buttons_add,
+            // onSelect: function(date){
+            //     var currentDate = new Date();
+            //     $('#order_time_str_add').val(date.getTime()/1000);
+            // }
+        });
+
+        $('#deal_time').datetimebox({
+            required: false,
+            showSeconds:false,
+            //buttons:buttons_deal,
+            // onSelect: function(date){
+            //     console.log(date);
+            //     $('#deal_time_str').val(date.getTime()/1000);
+            // }
+        });
+
+
+
+        jq_setStatus.combobox({
+            editable: false,
+            data: status_data
+        });
+
+
+        jq_setStatus_add.combobox({
+            editable: false,
+            data: (function () {
+                var status_data_temp = new Array();
+                $.extend(status_data_temp, status_data);
+                status_data_temp.shift();
+
+                return status_data_temp;
+            })()
+        });
+
+
+
+
+
+
+
+    var p_width = parseInt(w_width / 2);
+    if (p_width < 520){
+        p_width = 520;
+    }
+    var d_width = p_width - 10;
+    $('#west_panel').css({width : p_width});
+    $('#main').css({width: w_width - 25, height: w_height - 18}).layout();
+
+    jq_ss.searchbox({
+        width: 130,
+        searcher:function(value){
+            search_content();
+        },
+        prompt: '请输入关键字'
+    });
+
+    jq_setStatus.combobox({
+        editable: false,
+        data: status_data
+    });
+
+
+    jq_add_dialog.dialog({
+        title: '新建充值卡',
+        width: 500,
+        height: 500,
+        closed: true,
+        modal: true,
+        buttons:[{
+            text: '确认',
+            iconCls: 'icon-ok',
+            handler: function(){
+                // ------ 数据完整性检查 ------
+                var check = checkAddForm();
+                if (!check) {
+                    return false;
+                } else {
+                    $.messager.progress();
+                    jq_add_form.submit();
+                }
+            }
+        },{
+            text: '取消',
+            iconCls: 'icon-cancel',
+            handler: function(){
+                jq_add_dialog.dialog('close');
+            }
+        }],
+        onOpen:function(){
+            jq_add_form.form('clear');
+            jq_add_form.form('load', {});
+            jq_set_precedence.combobox('setValue', 0);
+            $('#extra_items').html('');
+
+            $('#re_address').html('');
+        }
+    });
+
+    jq_dg_content.datagrid({
+        url: module_router + '/list',
+        title: '充值卡列表',
+        width: d_width,
+        height: w_height - 18,
+        fitColumns: true,
+        autoRowHeight: true,
+        striped: true,
+        toolbar: '#tb_content',
+        singleSelect: true,
+        selectOnCheck: false,
+        checkOnSelect: false,
+        rowStyler: function(index,row){
+            if (row.status==1){
+                return 'color:red;';
+            }else if(row.status==-3){
+                return 'color:green;';
+            }
+        },
+        pagination: true,
+        pageList: [20, 30, 50],
+        pageSize: 20,
+        nowrap: false,
+        idField: 'id',
+        sortName: 'order_time',
+        sortOrder: 'desc',
+        queryParams: get_param_obj(),
+        frozenColumns:[[
+            {field:'ck',checkbox:true}
+        ]],
+        columns:[[
+            {field:'id', title:'id', hidden:true},
+            {field:'denomination', title:'充值面额', width:25,sortable:false
+            },
+            {field:'cash_back', title:'返现金额', width:25,sortable:false},
+            {field:'status', title:'状态', width:50, sortable: true,
+                formatter: function(value, row){
+                    return get_filed_text(value, status_data);
+                }
+            }
+        ]],
+
+
+
+
+        onSelect: function(index, row){
+
+            var data = $.extend({}, row);
+            $('#id_str').html(data.id);
+            $('#recharge_id').val(data.id);
+            jq_content_form.form('load', data);
+
+            $('#admins_edit_info').html('');
+//            var _html = '';
+//            for (i in data.coupons){
+//                console.log(JSON.stringify(data.coupons[i]));
+//                _html += data.coupons[i]+'<br/>';
+//            }
+//
+//            $('#coupons_items').html(_html);
+            if (data['action_user'] != ''){
+                jq_action_info.html('信息已被编辑: ' + data['action_user'] + ' ' + data['action_time']);
+            } else {
+                jq_action_info.html('');
+            }
+
+
+
+
+
+        }
+
+
+
+
+
+
+    });
+
+    jq_ss.searchbox({
+        width: 140,
+        searcher:function(value){
+            search_content();
+        },
+        prompt: '请输入关键字'
+    });
+
+    jq_filter_status.combobox({
+        width: 100,
+        data: status_data,
+        editable: false,
+        onSelect: function(){
+            search_content();
+        }
+    });
+
+
+
+
+
+    jq_content_form.form({
+        url: module_router + '/edit',
+        onSubmit: function(param){
+            if ($('#order_id').val() == ""){
+                return false;
+            }
+            var isValid = $(this).form('validate');
+            if (!isValid){
+                $.messager.progress('close');
+            }
+            return isValid;
+        },
+        success: function(res){
+            $.messager.progress('close');
+            var res = JSON.parse(res);
+
+            if (res.success){
+                jq_dg_content.datagrid('reload');
+            }
+            if(res.success){
+                $.messager.show({
+                    title: '提示',
+                    msg: '保存成功',
+                    timeout: 3500,
+                    showType: 'slide'
+                });
+
+                $('#technician_id').val(0);
+            }else{
+                $.messager.show({
+                    title: '提示',
+                    msg: res.message,
+                    timeout: 3500,
+                    showType: 'slide'
+                });
+            }
+        }
+    });
+
+    jq_add_form.form({
+        url : module_router + '/add',
+        onSubmit : function (param) {
+            var isValid = $(this).form('validate');
+            if (!isValid){
+                $.messager.progress('close');
+            }
+            return isValid;
+        },
+        success : function (res) {
+            $.messager.progress('close');
+            var res = JSON.parse(res);
+
+            if (res.success) {
+                $.messager.show({
+                    title : '提示',
+                    msg : '保存成功',
+                    timeout : 3500,
+                    showType : 'slide'
+                });
+                jq_add_dialog.dialog('close');
+                jq_dg_content.datagrid('reload');
+            } else {
+                $.messager.show({
+                    title : '提示',
+                    msg : res.message,
+                    timeout : 3500,
+                    showType : 'slide'
+                });
+            }
+        }
+    });
+    $('#edit_coupon').change(function(){
+        $('#cash').hide();
+        $('#coupons').show();
+    });
+    $('#edit_cash_back').change(function(){
+
+        $('#cash').show();
+        $('#coupons').hide();
+    });
+
+
+});
+
+function save_content(){
+    if ($('#recharge_id').val() == ""){
+        return false;
+    }
+
+    if (jq_setStatus.combobox('getValue') <0 ){
+        $.messager.confirm('注意', '确认 取消/退款 该订单吗?', function(r){
+            $.messager.progress();
+            jq_content_form.submit();
+        });
+        return true;
+    }
+
+
+
+    $.messager.progress();
+    jq_content_form.submit();
+}
+function checkAddForm () {
+    // 空数据检查
+
+    if ($('#denomination').val() == '') {
+        $.messager.alert('提示', '请输入充值面额', 'warning');
+        return false;
+    }
+    if ($('#cash_back').val() == '') {
+        $.messager.alert('提示', '请输入返现的金额', 'warning');
+        return false;
+    }
+
+
+    if ($('#setStatus_add').combobox('getValue') == '') {
+        $.messager.alert('提示', '请选择充值卡状态', 'warning');
+        return false;
+    }
+
+    return true;
+}
+
+function add_content(){
+    jq_add_dialog.dialog('open');
+}
+
+</script>