north %!s(int64=7) %!d(string=hai) anos
pai
achega
4a75312ce3

+ 88 - 0
www/protected/controllers/GiftController.php

@@ -0,0 +1,88 @@
+<?php
+
+/**
+ * Created by north.Deng's MAC
+ * User: north.Deng
+ * Date: 2018/2/28
+ * Time: 下午12:30
+ * description :
+ */
+class GiftController extends AdminController
+{
+    public function actionIndex()
+    {
+        $this->render('index');
+    }
+
+    public function actionList()
+    {
+        $pageParams = CommonFn::getPageParams();
+        $search = Yii::app()->request->getParam('search', '');
+        $status = intval(Yii::app()->request->getParam('status', 100));
+        $criteria = new EMongoCriteria($pageParams);
+        if ($status != 100 ) {
+            $criteria->status('==',$status);
+        }
+        if ($search) {
+            $criteria->addCond('title','or',new MongoRegex('/' . $search . '/'));
+        }
+        $cursor = Gift::model()->findAll($criteria);
+        $rows = CommonFn::getRowsFromCursor($cursor);
+        $parsedRows = Gift::model()->parse($rows);
+        $total = $cursor->count();
+        echo CommonFn::composeDatagridData($parsedRows, $total);
+    }
+
+    public function actionEdit()
+    {
+        $id = Yii::app()->request->getParam('id','');
+        $title = Yii::app()->request->getParam('title','');
+        $desc = Yii::app()->request->getParam('desc','');
+        $supplier = Yii::app()->request->getParam('supplier','');
+        $supplier_name = Yii::app()->request->getParam('supplier_name','');
+        $supplier_mobile = Yii::app()->request->getParam('supplier_mobile','');
+
+
+        if (!CommonFn::isMongoId($id)) {
+            CommonFn::requestAjax(false,'id错误');exit;
+        }
+
+
+
+        $gift = Gift::get(new MongoId($id));
+        $gift->title = $title;
+        $gift->desc = $desc;
+        $gift->supplier = array(
+            'supplier' => $supplier,
+            'name' => $supplier_name,
+            'mobile' => $supplier_mobile,
+        );
+        $gift->save();
+        CommonFn::requestAjax(true,'保存成功');exit;
+    }
+    public function actionAdd()
+    {
+        $title = Yii::app()->request->getParam('title','');
+        $desc = Yii::app()->request->getParam('desc','');
+        $supplier = Yii::app()->request->getParam('supplier','');
+        $supplier_name = Yii::app()->request->getParam('supplier_name','');
+        $supplier_mobile = Yii::app()->request->getParam('supplier_mobile','');
+
+        $gift = new Gift();
+        $gift->title = $title;
+        $gift->desc = $desc;
+        $gift->supplier = array(
+            'supplier' => $supplier,
+            'name' => $supplier_name,
+            'mobile' => $supplier_mobile,
+        );
+        $gift->save();
+        CommonFn::requestAjax(true,'保存成功');exit;
+    }
+
+    public function actionOutputExcel()
+    {
+        $data = JGEmploye::model()->findAll();
+        $res=Service::factory('ExcelService')->push($data);
+    }
+}

+ 101 - 0
www/protected/controllers/JCouponController.php

@@ -0,0 +1,101 @@
+<?php
+
+/**
+ * Created by north.Deng's MAC
+ * User: north.Deng
+ * Date: 2018/2/28
+ * Time: 下午12:30
+ * description :
+ */
+class JCouponController extends AdminController
+{
+    public function actionIndex()
+    {
+        $status = CommonFn::getComboboxData(JCoupon::$status_options, 100, true, 100);
+        $gifts = Gift::model()->findAll();
+        $tmp =[];
+        foreach ($gifts as $gift) {
+            $tmp[] = array('name' => $gift->title,'id' => (string)$gift->_id);
+        }
+        $tmp = CommonFn::getComboboxData($tmp, 0, false );
+        $this->render('index',array(
+            'status' => $status,
+            'gifts' => $tmp
+        ));
+
+    }
+
+    public function actionList()
+    {
+        $pageParams = CommonFn::getPageParams();
+        $search = Yii::app()->request->getParam('search', '');
+        $status = intval(Yii::app()->request->getParam('status', 100));
+        $criteria = new EMongoCriteria($pageParams);
+        if ($status != 100 ) {
+            $criteria->status('==',$status);
+        }
+        if ($search) {
+            $criteria->addCond('title','or',new MongoRegex('/' . $search . '/'));
+        }
+        $cursor = JCoupon::model()->findAll($criteria);
+        $rows = CommonFn::getRowsFromCursor($cursor);
+        $parsedRows = JCoupon::model()->parse($rows);
+        $total = $cursor->count();
+        echo CommonFn::composeDatagridData($parsedRows, $total);
+    }
+
+    public function actionEdit()
+    {
+        $id = Yii::app()->request->getParam('id','');
+        $status = (int)Yii::app()->request->getParam('status',0);
+
+
+        if (!CommonFn::isMongoId($id)) {
+            CommonFn::requestAjax(false,'id错误');exit;
+        }
+
+
+
+        $coupon = JCoupon::get(new MongoId($id));
+        $coupon->status = $status;
+        $coupon->save();
+        CommonFn::requestAjax(true,'保存成功');exit;
+    }
+    public function actionAdd()
+    {
+        $num = (int)Yii::app()->request->getParam('num','');
+        $gift_id = Yii::app()->request->getParam('gift_id','');
+        $channel = Yii::app()->request->getParam('channel','');
+        $expire_time = Yii::app()->request->getParam('expire_time_str','');
+        if (!$num ||!$channel || !$gift_id || !$expire_time) {
+            CommonFn::requestAjax(false,'请填写完整信息');exit;
+        }
+        $gift = Gift::get(new MongoId($gift_id));
+        if (empty($gift)) {
+            CommonFn::requestAjax(false,'礼包不存在');exit;
+        }
+
+        for($i=0; $i<$num; $i++) {
+            $coupon = new JCoupon();
+            $coupon->gift_id = $gift_id;
+            $flag = true;
+            while($flag) {
+                $pwd =  $coupon->generateRandomString(8);
+                $tmp = JCoupon::getByPwd($pwd);
+                if (empty(count($tmp))){
+                    $flag = false;
+                }
+            }
+
+            $coupon->pwd = $pwd;
+            $coupon->channel = $channel;
+            $coupon->status = 0;
+            $coupon->expire_time = $expire_time;
+            $coupon->save();
+        }
+
+        CommonFn::requestAjax(true,'生成成功');exit;
+    }
+
+
+}

+ 107 - 0
www/protected/controllers/JRecordController.php

@@ -0,0 +1,107 @@
+<?php
+
+/**
+ * Created by north.Deng's MAC
+ * User: north.Deng
+ * Date: 2018/2/28
+ * Time: 下午12:30
+ * description :
+ */
+class JRecordController extends AdminController
+{
+    public function actionIndex()
+    {
+        $status = CommonFn::getComboboxData(JRecord::$status_options, 100, true, 100);
+
+
+        $this->render('index',array(
+            'status' => $status
+        ));
+
+    }
+
+    public function actionList()
+    {
+        $pageParams = CommonFn::getPageParams();
+        $search = Yii::app()->request->getParam('search', '');
+        $status = intval(Yii::app()->request->getParam('status', 100));
+        $criteria = new EMongoCriteria($pageParams);
+        if ($status != 100 ) {
+            $criteria->status('==',$status);
+        }
+        if ($search) {
+            $criteria->addCond('title','or',new MongoRegex('/' . $search . '/'));
+        }
+        $cursor = JRecord::model()->findAll($criteria);
+        $rows = CommonFn::getRowsFromCursor($cursor);
+        $parsedRows = JRecord::model()->parse($rows);
+        $total = $cursor->count();
+        echo CommonFn::composeDatagridData($parsedRows, $total);
+    }
+
+    public function actionEdit()
+    {
+        $id = Yii::app()->request->getParam('id','');
+        $name = Yii::app()->request->getParam('name','');
+        $mobile = Yii::app()->request->getParam('mobile','');
+        $address = Yii::app()->request->getParam('address','');
+        $flow = Yii::app()->request->getParam('flow','');
+        $flow_number = Yii::app()->request->getParam('flow_number','');
+        $status = (int)Yii::app()->request->getParam('status',0);
+
+        if (!$name ||!$mobile || !$address || !$flow||!$flow_number  ) {
+            CommonFn::requestAjax(false,'请填写完整信息');exit;
+        }
+        if (!CommonFn::isMongoId($id)) {
+            CommonFn::requestAjax(false, '修改失败', array());
+        }
+
+        $record = JRecord::get(new MongoId($id));
+        $record->user_info = array(
+            'name' => $name,
+            'mobile' => $mobile,
+        );
+        $record->address = $address;
+        $record->status = $status;
+        $record->flow = $flow;
+        $record->flow_number = $flow_number;
+        $record->save();
+        CommonFn::requestAjax(true,'修改成功');exit;
+    }
+    public function actionAdd()
+    {
+        $name = Yii::app()->request->getParam('name','');
+        $mobile = Yii::app()->request->getParam('mobile','');
+        $address = Yii::app()->request->getParam('address','');
+        $flow = Yii::app()->request->getParam('flow','');
+        $flow_number = Yii::app()->request->getParam('flow_number','');
+        $status = (int)Yii::app()->request->getParam('status',0);
+        $pwd = Yii::app()->request->getParam('pwd','');
+
+        if (!$name ||!$mobile || !$address || !$flow||!$flow_number  || !$pwd) {
+            CommonFn::requestAjax(false,'请填写完整信息');exit;
+        }
+        $coupon = JCoupon::getByPwdOne($pwd);
+        if (empty($coupon) || $coupon->status >= 2) {
+            CommonFn::requestAjax(false,'兑换券不存在或已失效');exit;
+        }
+
+        $record = new JRecord();
+        $record->user_info = array(
+            'name' => $name,
+            'mobile' => $mobile,
+        );
+        $record->address = $address;
+        $record->coupon_id = (string)$coupon->_id;
+        $record->status = $status;
+        $record->flow = $flow;
+        $record->flow_number = $flow_number;
+        $record->time = time();
+        $record->save();
+        $coupon->status = 2;
+        $coupon->save();
+        CommonFn::requestAjax(true,'生成成功');exit;
+    }
+
+
+}

+ 44 - 0
www/protected/modules/j/controllers/JRecordController.php

@@ -0,0 +1,44 @@
+<?php
+/**
+ * Created by north.Deng's MAC
+ * User: north.Deng
+ * Date: 2018/6/12
+ * Time: 下午2:29
+ * description :
+ */
+ class JRecordController extends JBaseController {
+     public function actionRecord(){
+         $name = Yii::app()->request->getParam('name','');
+         $mobile = Yii::app()->request->getParam('mobile','');
+         $address = Yii::app()->request->getParam('address','');
+         $user_id = Yii::app()->request->getParam('user_id','');
+         $pwd = Yii::app()->request->getParam('pwd','');
+
+         if (!$name ||!$mobile || !$address  || !$pwd || !$user_id) {
+             CommonFn::requestAjax(false,'请填写完整信息');exit;
+         }
+         $coupon = JCoupon::getByPwdOne($pwd);
+         if (empty($coupon) || $coupon->status >= 2) {
+             CommonFn::requestAjax(false,'兑换券不存在或已失效');exit;
+         }
+
+         $record = new JRecord();
+         $record->user_info = array(
+             'name' => $name,
+             'mobile' => $mobile,
+         );
+         $record->address = $address;
+         $record->coupon_id = (string)$coupon->_id;
+         $record->status = 0;
+         $record->time = time();
+         $record->save();
+         $coupon->user_id = $user_id;
+         $coupon->status = 2;
+         $coupon->save();
+         $data['coupon'] = $coupon;
+         $data['gift'] = Gift::get(new MongoId($coupon->gift_id));
+         $data['record'] = $record;
+         CommonFn::requestAjax(true,'生成成功',$data);exit;
+     }
+ }
+ 

+ 68 - 0
www/protected/modules/j/models/Gift.php

@@ -0,0 +1,68 @@
+<?php
+
+/**
+ * Created by north.Deng's MAC
+ * User: north.Deng
+ * Date: 2018/5/4
+ * Time: 上午10:10
+ * description :
+ * 礼包
+ */
+class Gift extends MongoAr
+{
+    public $_id;
+    public $title;//标题
+    public $desc;
+    public $supplier = array();//供货商 联系人 联系方式
+
+
+
+    public function __construct($scenario='insert'){
+        $this->setMongoDBComponent(Yii::app()->getComponent('mongodb_o2o'));
+        parent::__construct($scenario);
+    }
+
+
+    public static function model($className=__CLASS__)
+    {
+        return parent::model($className);
+    }
+
+    public function getCollectionName()
+    {
+        return 'j_gift';
+    }
+
+    public static function get($_id) {
+        if(CommonFn::isMongoId($_id)){
+            $criteria = new EMongoCriteria();
+            $criteria->_id('==', $_id);
+            $model = self::model()->find($criteria);
+            return $model;
+        }else{
+            return false;
+        }
+    }
+
+
+
+
+    public function parseRow($row,$output=array()){
+
+        $newRow = array();
+        $newRow['id'] = (string)$row['_id'];
+        $newRow['title'] = (string)$row['title'];
+        $newRow['supplier'] = CommonFn::get_val_if_isset($row,'supplier','');
+        $newRow['desc'] = CommonFn::get_val_if_isset($row,'desc','');
+        $newRow['mobile'] = $newRow['supplier']['mobile'];
+        $newRow['name'] = $newRow['supplier']['name'];
+        if(APPLICATION=='admin'){
+            $newRow['action_user'] = CommonFn::get_val_if_isset($row,'action_user',"");
+            $newRow['action_time'] = CommonFn::get_val_if_isset($row,'action_time',"");
+            $newRow['action_log'] = CommonFn::get_val_if_isset($row,'action_log',"");
+
+        }
+        return $this->output($newRow,$output);
+    }
+
+}

+ 100 - 0
www/protected/modules/j/models/JCoupon.php

@@ -0,0 +1,100 @@
+<?php
+
+/**
+ * Created by north.Deng's MAC
+ * User: north.Deng
+ * Date: 2018/5/4
+ * Time: 上午10:10
+ * description :
+ * 礼包券
+ */
+class JCoupon extends MongoAr
+{
+    public $_id;
+    public $user_id;
+    public $gift_id;
+    public $pwd;//提货密码
+    public $expire_time;//过期时间
+    public $channel;//渠道
+    public $status = 0;// 0未发 1已发 2已提 3过期
+
+    static public $status_options = array(
+        0 => array('name' => '未发'),
+        1 => array('name' => '已发'),
+        2 => array('name' => '已提'),
+        3 => array('name' => '过期'),
+    );
+
+
+    public function __construct($scenario='insert'){
+        $this->setMongoDBComponent(Yii::app()->getComponent('mongodb_o2o'));
+        parent::__construct($scenario);
+    }
+
+    function generateRandomString($length = 10) {
+        $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
+        $randomString = '';
+        for ($i = 0; $i < $length; $i++) {
+            $randomString .= $characters[rand(0, strlen($characters) - 1)];
+        }
+        return $randomString;
+    }
+    public static function model($className=__CLASS__)
+    {
+        return parent::model($className);
+    }
+
+    public function getCollectionName()
+    {
+        return 'j_coupon';
+    }
+
+    public static function get($_id) {
+        if(CommonFn::isMongoId($_id)){
+            $criteria = new EMongoCriteria();
+            $criteria->_id('==', $_id);
+            $model = self::model()->find($criteria);
+            return $model;
+        }else{
+            return false;
+        }
+    }
+    public static function getByPwd($pwd) {
+        $criteria = new EMongoCriteria();
+        $criteria->pwd('==', $pwd);
+        $model = self::model()->findAll($criteria);
+        return $model;
+    }
+    public static function getByPwdOne($pwd) {
+        $criteria = new EMongoCriteria();
+        $criteria->pwd('==', $pwd);
+        $model = self::model()->find($criteria);
+        return $model;
+    }
+
+
+
+
+    public function parseRow($row,$output=array()){
+
+        $newRow = array();
+        $newRow['id'] = (string)$row['_id'];
+        $newRow['gift_id'] = (string)$row['gift_id'];
+        $newRow['gift_name'] = Gift::get(new MongoId((string)$row['gift_id']))->title;
+        $newRow['channel'] = CommonFn::get_val_if_isset($row,'channel','');
+        $newRow['expire_time'] = CommonFn::get_val_if_isset($row,'expire_time','');
+        $newRow['expire_time_str'] = date('Y-m-d H:i:s',$newRow['expire_time']);
+        $newRow['pwd'] = CommonFn::get_val_if_isset($row,'pwd','');
+        $newRow['status'] = CommonFn::get_val_if_isset($row,'status','');
+        $newRow['status_str'] = self::$status_options[$newRow['status']]['name'];
+
+        if(APPLICATION=='admin'){
+            $newRow['action_user'] = CommonFn::get_val_if_isset($row,'action_user',"");
+            $newRow['action_time'] = CommonFn::get_val_if_isset($row,'action_time',"");
+            $newRow['action_log'] = CommonFn::get_val_if_isset($row,'action_log',"");
+
+        }
+        return $this->output($newRow,$output);
+    }
+
+}

+ 85 - 0
www/protected/modules/j/models/JRecord.php

@@ -0,0 +1,85 @@
+<?php
+
+/**
+ * Created by north.Deng's MAC
+ * User: north.Deng
+ * Date: 2018/5/4
+ * Time: 上午10:10
+ * description :
+ * 提货记录
+ */
+class JRecord extends MongoAr
+{
+    public $_id;
+    public $user_info = array();//姓名 手机
+    public $address;
+    public $coupon_id;
+    public $status;//0未发货 1已发货
+    public $flow;//物流商
+    public $flow_number;//物流单号
+    public $time;
+
+
+    public function __construct($scenario='insert'){
+        $this->setMongoDBComponent(Yii::app()->getComponent('mongodb_o2o'));
+        parent::__construct($scenario);
+    }
+    static public $status_options = array(
+        0 => array('name' => '未发货'),
+        1 => array('name' => '已发货'),
+    );
+
+    public static function model($className=__CLASS__)
+    {
+        return parent::model($className);
+    }
+
+    public function getCollectionName()
+    {
+        return 'j_record';
+    }
+
+    public static function get($_id) {
+        if(CommonFn::isMongoId($_id)){
+            $criteria = new EMongoCriteria();
+            $criteria->_id('==', $_id);
+            $model = self::model()->find($criteria);
+            return $model;
+        }else{
+            return false;
+        }
+    }
+
+
+
+
+    public function parseRow($row,$output=array()){
+
+        $newRow = array();
+        $newRow['id'] = (string)$row['_id'];
+        $newRow['coupon_id'] = (string)$row['coupon_id'];
+        $coupon = JCoupon::get(new MongoId($newRow['coupon_id']));
+        $gift = Gift::get(new MongoId((string)$coupon->gift_id));
+        $newRow['pwd'] = $coupon->pwd;
+        $newRow['gift_name'] = $gift->title;
+        $newRow['gift_id'] = (string)$gift->_id;
+        $newRow['address'] = CommonFn::get_val_if_isset($row,'address','');
+        $newRow['user_info'] = CommonFn::get_val_if_isset($row,'user_info','');
+        $newRow['name'] = $newRow['user_info']['name'];
+        $newRow['mobile'] = $newRow['user_info']['mobile'];
+        $newRow['flow'] = CommonFn::get_val_if_isset($row,'flow','');
+        $newRow['flow_number'] = CommonFn::get_val_if_isset($row,'flow_number','');
+        $newRow['status'] = CommonFn::get_val_if_isset($row,'status','');
+        $newRow['time'] = CommonFn::get_val_if_isset($row,'time','');
+        $newRow['time_str'] = date('Y-m-d H:i:s',$newRow['time']);
+        $newRow['status_str'] = self::$status_options[$newRow['status']]['name'];
+        if(APPLICATION=='admin'){
+            $newRow['action_user'] = CommonFn::get_val_if_isset($row,'action_user',"");
+            $newRow['action_time'] = CommonFn::get_val_if_isset($row,'action_time',"");
+            $newRow['action_log'] = CommonFn::get_val_if_isset($row,'action_log',"");
+
+        }
+        return $this->output($newRow,$output);
+    }
+
+}

+ 646 - 0
www/protected/views/gift/index.php

@@ -0,0 +1,646 @@
+<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">
+                <div class="left">
+                    查询:<input id="ss" />
+                </div>
+            </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="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 id="edit_title" name="title" 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">
+                                            <textarea id="edit_desc" name="desc" style="width: 250px;"  ></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="edit_supplier" name="supplier" 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="edit_supplier_name" name="supplier_name" 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="edit_supplier_mobile" name="supplier_mobile" style="width: 250px;"  />
+                                        </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="add_title" name="title" 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">
+                            <textarea id="add_desc" name="desc" style="width: 250px;"  ></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="add_supplier" name="supplier" 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="add_supplier_name" name="supplier_name" 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="add_supplier_mobile" name="supplier_mobile" style="width: 250px;"  />
+                        </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>
+<div style="display: none;">
+    <div id="edit_extra_dialog" style="margin:5px 0 0 0;">
+        <ul>
+            <li class="f_item">
+                <div class="box">
+                    <div class="f_label">
+                        <span>开始时间段: </span>
+                    </div>
+                    <div class="box_flex f_content">
+                        <input type="text" id="edit_extra_type" 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 type="text" id="edit_extra_price" style="width: 250px;"/>
+                    </div>
+                </div>
+            </li>
+        </ul>
+    </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 module_router = site_root + '/index.php?r=Gift';
+    var jq_setStatus = $('#setStatus');
+    var w_width = $(window).width();
+    var w_height = $(window).height();
+    var jq_ss = $('#ss');
+    var jq_add_dialog = $('#add_dialog');
+    var jq_add_form = $('#add_form');
+
+    var jq_set_precedence = $('#set_precedence');
+    var jq_action_info = $('#action_info');
+    var jq_acc = $('#acc_container');
+
+
+    var jq_edit_extra_dialog = $('#edit_extra_dialog');
+    $('body').on('click','.del_extra',function(){
+        $(this).parent('div').remove();
+
+        var extras = new Array();
+        if($('#add_extra').val()){
+            extras = JSON.parse($('#add_extra').val());
+        }
+
+        extras.splice($(this).parent('div').attr('data'),1);
+
+        $('#extra_add_info').children('div').each(function(index,e){
+            console.log(index);
+            $(this).attr("data",index);
+        })
+
+        $('#add_extra').val(JSON.stringify(extras));
+    });
+    $(function(){
+        jq_acc.accordion({
+            height: w_height - 18,
+            onSelect: function(title) {
+
+            }
+        });
+
+
+
+
+        jq_edit_extra_dialog.dialog({
+            title: '添加时间段',
+            width: 440,
+            height: 160,
+            closed: true,
+            modal: true,
+            buttons:[{
+                text: '添加',
+                iconCls: 'icon-add',
+                handler: function(){
+                    var extras = new Array();
+                    if($('#add_extra').val()){
+                        extras = JSON.parse($('#add_extra').val());
+                    }
+
+                    var extra = {};
+                    extra.type = $('#edit_extra_type').val();
+                    extra.price = $('#edit_extra_price').val();
+                    if(!extra.type || !extra.price){
+                        $.messager.show({
+                            title: '提示',
+                            msg: '填错啦',
+                            timeout: 3500,
+                            showType: 'slide'
+                        });
+                        //jq_edit_coverage_dialog.dialog('close');
+                    }else{
+                        extras.push(extra);
+                        $('#add_extra').val(JSON.stringify(extras));
+
+                        $('#extra_add_info').html($('#extra_add_info').html()+parse_extra_item(extra,false,extras.length));
+                        jq_edit_extra_dialog.dialog('close');
+                    }
+                }
+            },{
+                text: '取消',
+                iconCls: 'icon-cancel',
+                handler: function(){
+                    jq_edit_extra_dialog.dialog('close');
+                }
+            }],
+            onOpen:function(){
+                $('#edit_extra_type').val('');
+                $('#edit_extra_price').val('');
+            }
+        });
+
+        $('#birth_time').datetimebox({
+            required: false,
+            showSeconds:false,
+            //buttons:buttons_add,
+            onSelect: function(date){
+                var currentDate = new Date();
+                $('#order_time_str_add').val(date.getTime()/1000);
+            }
+        });
+        $('#work_time').datetimebox({
+            required: false,
+            showSeconds:false,
+            //buttons:buttons_add,
+            onSelect: function(date){
+                var currentDate = new Date();
+                $('#order_time_str_add').val(date.getTime()/1000);
+            }
+        });
+        var buttons = $.extend([], $.fn.datebox.defaults.buttons);
+        buttons[0].text = '确定';
+        buttons[0].handler=function(){
+            var vals = $('#server_start_time').datetimebox('spinner').spinner('getValue').split(':');
+            $('#server_start_time_str').val(  parseInt($('#server_start_time_str').val())-(parseInt($('#server_start_time_str').val())+8*3600)%86400 +vals[0]*3600+vals[1]*60);
+
+            var d=new Date(parseInt($('#server_start_time_str').val())*1000);
+
+            $('#server_start_time').datetimebox('setText',formatDate(d));
+            $('#server_start_time').datetimebox('hidePanel');
+        };
+
+        $('#server_start_time').datetimebox({
+            required: false,
+            showSeconds:false,
+            buttons:buttons,
+            onSelect: function(date){
+                $('#server_start_time_str').val(date.getTime()/1000);
+            }
+        });
+        var buttons1 = $.extend([], $.fn.datebox.defaults.buttons);
+        buttons1[0].text = '确定';
+        buttons1[0].handler=function(){
+            var vals = $('#status_time').datetimebox('spinner').spinner('getValue').split(':');
+            $('#status_time_str').val(  parseInt($('#status_time_str').val())-(parseInt($('#status_time_str').val())+8*3600)%86400 +vals[0]*3600+vals[1]*60);
+
+            var d=new Date(parseInt($('#status_time_str').val())*1000);
+
+            $('#status_time').datetimebox('setText',formatDate(d));
+            $('#status_time').datetimebox('hidePanel');
+        };
+
+        $('#status_time').datetimebox({
+            required: false,
+            showSeconds:false,
+            buttons:buttons1,
+            onSelect: function(date){
+                $('#status_time_str').val(date.getTime()/1000);
+            }
+        });
+
+
+
+
+
+        var buttons = $.extend([], $.fn.datebox.defaults.buttons);
+        buttons[0].text = '确定';
+
+
+
+
+
+
+
+
+
+
+
+        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(value);
+            },
+            prompt: '请输入关键字'
+        });
+
+        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);
+            }
+        });
+      jq_ss.searchbox({
+        width: 130,
+        searcher:function(value){
+          search_content(value);
+        },
+        prompt: '请输入关键字'
+      });
+        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: 'id',
+            sortOrder: 'desc',
+            queryParams: get_param_obj(),
+            frozenColumns:[[
+                {field:'id',checkbox:true}
+            ]],
+            columns:[[
+                {field:'id', title:'id', hidden:true},
+                {field:'title', title:'标题', width:40,sortable:false
+                },
+                {field:'supplier', title:'供货商', width:40,sortable:false,formatter: function(value, row){
+                  return value.supplier;
+                }},
+                {field:'name', title:'联系人', width:40},
+                {field:'mobile', title:'联系方式', width:40}
+            ]],
+
+            onSelect: function(index, row){
+
+                var data = $.extend({}, row);
+
+
+                $('#id').val(row.id);
+                $('#id_str').html(row.id);
+                $('#edit_title').val(data.title);
+                $('#edit_supplier').val(data.supplier.supplier);
+                $('#edit_supplier_name').val(data.name);
+                $('#edit_supplier_mobile').val(data.mobile);
+                $('#edit_desc').val(data.desc);
+
+
+
+            },
+            onLoadSuccess : function () {
+              $('#id').val('');
+              $('#id_str').html('');
+              $('#edit_title').val('');
+              $('#edit_supplier').val('');
+              $('#edit_supplier_name').val('');
+              $('#edit_supplier_mobile').val('');
+              $('#edit_desc').val('');
+                $('#admins_edit_info').html('');
+
+                jq_action_info.html('');
+
+                jq_dg_content.datagrid('clearSelections');
+                jq_setStatus.combobox('setValue', 100);
+            }
+
+        });
+
+
+
+
+        jq_content_form.form({
+            url: module_router + '/edit',
+            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){
+                    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',
+            //url :'index.php?r=moonclub/xOrder/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'
+                    });
+                }
+            }
+        });
+    });
+
+    function search_content(value = ''){
+        var search = value;
+        jq_dg_content.datagrid({
+            pageNum: 1,
+            queryParams: {
+                search : search
+            }
+        });
+
+    };
+
+    function checkAddForm () {
+
+        return true;
+    }
+
+    function add_content(){
+        jq_add_dialog.dialog('open');
+    }
+    function   formatDate(now){
+        var   year=now.getFullYear();
+        var   month=now.getMonth()+1;
+        var   date=now.getDate();
+        var  hour = now.getHours();
+        var  minute = now.getMinutes();
+        return   year+"-"+month+"-"+date+" "+hour+":"+minute;
+    }
+    function save_content(){
+        $.messager.progress();
+        jq_content_form.submit();
+    }
+    function parse_time(data,attr){
+        if(data[attr]){
+            var d=new Date(data[attr]*1000);
+            return formatDate(d);
+        }else{
+            return '';
+        }
+    }
+    function   formatDate(now){
+        var   year=now.getFullYear();
+        var   month=now.getMonth()+1;
+        var   date=now.getDate();
+        var  hour = now.getHours();
+        var  minute = now.getMinutes();
+        return   year+"-"+month+"-"+date+" "+hour+":"+minute;
+    }
+    function add_extra(){
+        jq_edit_extra_dialog.dialog('open');
+    }
+    function parse_extra_item(extra,is_last,index){
+        return '<div data='+index+'>['+extra.type+'-'+extra.price+']'+'&nbsp;&nbsp;<a href="#"  class="del_extra">删除</a></div>';
+    }
+    function export_order(exp,export_type) {
+      window.location.href = module_router+'/OutputExcel';
+    }
+
+</script>

+ 656 - 0
www/protected/views/jCoupon/index.php

@@ -0,0 +1,656 @@
+<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">
+                <span class="tb_label">状态: </span>
+                <input id="filter_status" />
+<!--                <div class="left">-->
+<!--                    查询:<input id="ss" />-->
+<!--                </div>-->
+            </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="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">
+                                            <span id="gift_name"></span>
+                                        </div>
+                                    </div>
+                                </li>
+                                <li class="f_item">
+                                    <div class="box">
+                                        <div class="f_label">
+                                            <span>提货密码: </span>
+                                        </div>
+                                        <div class="box_flex f_content">
+                                            <span id="pwd"></span>
+                                        </div>
+                                    </div>
+                                </li>
+                                <li class="f_item">
+                                    <div class="box">
+                                        <div class="f_label">
+                                            <span>渠道: </span>
+                                        </div>
+                                        <div class="box_flex f_content">
+                                            <span id="channel"></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 id="setStatus" name="status" />
+                                        </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="num" name="num" 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="channel" name="channel" 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="gift" name="gift" style="width: 250px;"  />
+                            <input id="gift_id" name="gift_id" type='hidden' 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="expire_time" type="text" name="expire_time">
+                            <input type="hidden" id="expire_time_str" name="expire_time_str">
+                        </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>
+<div style="display: none;">
+    <div id="edit_extra_dialog" style="margin:5px 0 0 0;">
+        <ul>
+            <li class="f_item">
+                <div class="box">
+                    <div class="f_label">
+                        <span>开始时间段: </span>
+                    </div>
+                    <div class="box_flex f_content">
+                        <input type="text" id="edit_extra_type" 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 type="text" id="edit_extra_price" style="width: 250px;"/>
+                    </div>
+                </div>
+            </li>
+        </ul>
+    </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 module_router = site_root + '/index.php?r=JCoupon';
+  var jq_setStatus = $('#setStatus');
+  var jq_setStatus_add = $('#setStatus_add');
+  var w_width = $(window).width();
+  var w_height = $(window).height();
+  var jq_ss = $('#ss');
+  var jq_add_dialog = $('#add_dialog');
+  var jq_add_form = $('#add_form');
+  var status_data = <?php echo json_encode($status); ?>;
+  var gifts = <?php echo json_encode($gifts); ?>;
+  var jq_set_precedence = $('#set_precedence');
+  var jq_action_info = $('#action_info');
+  var jq_acc = $('#acc_container');
+
+
+  var jq_edit_extra_dialog = $('#edit_extra_dialog');
+  $('body').on('click','.del_extra',function(){
+    $(this).parent('div').remove();
+
+    var extras = new Array();
+    if($('#add_extra').val()){
+      extras = JSON.parse($('#add_extra').val());
+    }
+
+    extras.splice($(this).parent('div').attr('data'),1);
+
+    $('#extra_add_info').children('div').each(function(index,e){
+      console.log(index);
+      $(this).attr("data",index);
+    })
+
+    $('#add_extra').val(JSON.stringify(extras));
+  });
+  $(function(){
+    jq_acc.accordion({
+      height: w_height - 18,
+      onSelect: function(title) {
+
+      }
+    });
+
+
+    jq_setStatus.combobox({
+      editable: false,
+      data: status_data,
+    });
+    $('#gift').combobox({
+      editable: false,
+      data: gifts,
+      onSelect: function(e){
+        $('#gift_id').val(e.attributes.id);
+      }
+    });
+    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;
+      })()
+    });
+    jq_filter_status.combobox({
+      width: 100,
+      data: status_data,
+      editable: false,
+      onSelect: function(){
+        search_content();
+      }
+    });
+    jq_edit_extra_dialog.dialog({
+      title: '添加时间段',
+      width: 440,
+      height: 160,
+      closed: true,
+      modal: true,
+      buttons:[{
+        text: '添加',
+        iconCls: 'icon-add',
+        handler: function(){
+          var extras = new Array();
+          if($('#add_extra').val()){
+            extras = JSON.parse($('#add_extra').val());
+          }
+
+          var extra = {};
+          extra.type = $('#edit_extra_type').val();
+          extra.price = $('#edit_extra_price').val();
+          if(!extra.type || !extra.price){
+            $.messager.show({
+              title: '提示',
+              msg: '填错啦',
+              timeout: 3500,
+              showType: 'slide'
+            });
+            //jq_edit_coverage_dialog.dialog('close');
+          }else{
+            extras.push(extra);
+            $('#add_extra').val(JSON.stringify(extras));
+
+            $('#extra_add_info').html($('#extra_add_info').html()+parse_extra_item(extra,false,extras.length));
+            jq_edit_extra_dialog.dialog('close');
+          }
+        }
+      },{
+        text: '取消',
+        iconCls: 'icon-cancel',
+        handler: function(){
+          jq_edit_extra_dialog.dialog('close');
+        }
+      }],
+      onOpen:function(){
+        $('#edit_extra_type').val('');
+        $('#edit_extra_price').val('');
+      }
+    });
+
+    $('#birth_time').datetimebox({
+      required: false,
+      showSeconds:false,
+      //buttons:buttons_add,
+      onSelect: function(date){
+        var currentDate = new Date();
+        $('#order_time_str_add').val(date.getTime()/1000);
+      }
+    });
+    $('#work_time').datetimebox({
+      required: false,
+      showSeconds:false,
+      //buttons:buttons_add,
+      onSelect: function(date){
+        var currentDate = new Date();
+        $('#order_time_str_add').val(date.getTime()/1000);
+      }
+    });
+    var buttons = $.extend([], $.fn.datebox.defaults.buttons);
+    buttons[0].text = '确定';
+    buttons[0].handler=function(){
+      var vals = $('#server_start_time').datetimebox('spinner').spinner('getValue').split(':');
+      $('#server_start_time_str').val(  parseInt($('#server_start_time_str').val())-(parseInt($('#server_start_time_str').val())+8*3600)%86400 +vals[0]*3600+vals[1]*60);
+
+      var d=new Date(parseInt($('#server_start_time_str').val())*1000);
+
+      $('#server_start_time').datetimebox('setText',formatDate(d));
+      $('#server_start_time').datetimebox('hidePanel');
+    };
+
+    $('#server_start_time').datetimebox({
+      required: false,
+      showSeconds:false,
+      buttons:buttons,
+      onSelect: function(date){
+        $('#server_start_time_str').val(date.getTime()/1000);
+      }
+    });
+    var buttons1 = $.extend([], $.fn.datebox.defaults.buttons);
+    buttons1[0].text = '确定';
+    buttons1[0].handler=function(){
+      var vals = $('#expire_time').datetimebox('spinner').spinner('getValue').split(':');
+      $('#expire_time_str').val(  parseInt($('#expire_time_str').val())-(parseInt($('#expire_time_str').val())+8*3600)%86400 +vals[0]*3600+vals[1]*60);
+
+      var d=new Date(parseInt($('#expire_time_str').val())*1000);
+
+      $('#expire_time').datetimebox('setText',formatDate(d));
+      $('#expire_time').datetimebox('hidePanel');
+    };
+
+    $('#expire_time').datetimebox({
+      required: false,
+      showSeconds:false,
+      buttons:buttons1,
+      onSelect: function(date){
+        $('#expire_time_str').val(date.getTime()/1000);
+      }
+    });
+
+
+
+
+
+    var buttons = $.extend([], $.fn.datebox.defaults.buttons);
+    buttons[0].text = '确定';
+
+
+
+
+
+
+
+
+
+
+
+    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(value);
+      },
+      prompt: '请输入关键字'
+    });
+
+    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);
+      }
+    });
+    jq_ss.searchbox({
+      width: 130,
+      searcher:function(value){
+        search_content(value);
+      },
+      prompt: '请输入关键字'
+    });
+    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: 'id',
+      sortOrder: 'desc',
+      queryParams: get_param_obj(),
+      frozenColumns:[[
+        {field:'id',checkbox:true}
+      ]],
+      columns:[[
+        {field:'id', title:'id', hidden:true},
+        {field:'gift_name', title:'礼包名称',width:40 },
+        {field:'pwd', title:'提货密码', width:40,sortable:false
+        },
+        {field:'expire_time', title:'过期时间', width:40,sortable:true,formatter: function(value, row){
+          return   row.expire_time_str;
+        }},
+        {field:'status', title:'状态', width:40,sortable:true,formatter: function(value, row){
+          return   row.status_str;
+        }}
+      ]],
+
+      onSelect: function(index, row){
+
+        var data = $.extend({}, row);
+
+
+        $('#id').val(row.id);
+        $('#id_str').html(row.id);
+        $('#gift_name').html(data.gift_name);
+        $('#pwd').html(data.pwd);
+        $('#channel').html(data.channel);
+        $('#setStatus').combobox('setValue', row.status);
+
+
+
+      },
+      onLoadSuccess : function () {
+        $('#id').val('');
+        $('#id_str').html('');
+        $('#gift_name').html('');
+        $('#pwd').html('');
+        $('#channel').html('');
+        $('#setStatus').combobox('setValue', 100);
+        jq_action_info.html('');
+
+        jq_dg_content.datagrid('clearSelections');
+        jq_setStatus.combobox('setValue', 100);
+      }
+
+    });
+
+
+
+
+    jq_content_form.form({
+      url: module_router + '/edit',
+      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){
+          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',
+      //url :'index.php?r=moonclub/xOrder/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'
+          });
+        }
+      }
+    });
+  });
+
+  function search_content(value = ''){
+    var search = value;
+    var filter_status = jq_filter_status.combobox('getValue');
+    jq_dg_content.datagrid({
+      pageNum: 1,
+      queryParams: {
+        search : search,
+        status : filter_status
+      }
+    });
+
+  };
+
+  function checkAddForm () {
+
+    return true;
+  }
+
+  function add_content(){
+    jq_add_dialog.dialog('open');
+  }
+  function   formatDate(now){
+    var   year=now.getFullYear();
+    var   month=now.getMonth()+1;
+    var   date=now.getDate();
+    var  hour = now.getHours();
+    var  minute = now.getMinutes();
+    return   year+"-"+month+"-"+date+" "+hour+":"+minute;
+  }
+  function save_content(){
+    $.messager.progress();
+    jq_content_form.submit();
+  }
+  function parse_time(data,attr){
+    if(data[attr]){
+      var d=new Date(data[attr]*1000);
+      return formatDate(d);
+    }else{
+      return '';
+    }
+  }
+  function   formatDate(now){
+    var   year=now.getFullYear();
+    var   month=now.getMonth()+1;
+    var   date=now.getDate();
+    var  hour = now.getHours();
+    var  minute = now.getMinutes();
+    return   year+"-"+month+"-"+date+" "+hour+":"+minute;
+  }
+  function add_extra(){
+    jq_edit_extra_dialog.dialog('open');
+  }
+  function parse_extra_item(extra,is_last,index){
+    return '<div data='+index+'>['+extra.type+'-'+extra.price+']'+'&nbsp;&nbsp;<a href="#"  class="del_extra">删除</a></div>';
+  }
+  function export_order(exp,export_type) {
+    window.location.href = module_router+'/OutputExcel';
+  }
+
+</script>

+ 722 - 0
www/protected/views/jRecord/index.php

@@ -0,0 +1,722 @@
+<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">
+                <span class="tb_label">状态: </span>
+                <input id="filter_status" />
+                <!--                <div class="left">-->
+                <!--                    查询:<input id="ss" />-->
+                <!--                </div>-->
+            </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="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 id="edit_name" name="name" 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="edit_mobile" name="mobile" 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="edit_address" name="address" 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="edit_flow"  name="flow" 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="edit_flow_number" name="flow_number" 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="edit_pwd" name="pwd" style="width: 250px;" readonly  />
+                                        </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="edit_status" name="status" style="width: 250px;"  />
+
+                                        </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  name="name" 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  name="mobile" 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  name="address" 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  name="flow" 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  name="flow_number" 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  name="pwd" 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" style="width: 250px;"  />
+
+                        </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>
+<div style="display: none;">
+    <div id="edit_extra_dialog" style="margin:5px 0 0 0;">
+        <ul>
+            <li class="f_item">
+                <div class="box">
+                    <div class="f_label">
+                        <span>开始时间段: </span>
+                    </div>
+                    <div class="box_flex f_content">
+                        <input type="text" id="edit_extra_type" 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 type="text" id="edit_extra_price" style="width: 250px;"/>
+                    </div>
+                </div>
+            </li>
+        </ul>
+    </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 module_router = site_root + '/index.php?r=JRecord';
+  var jq_setStatus = $('#setStatus');
+  var jq_setStatus_add = $('#setStatus_add');
+  var w_width = $(window).width();
+  var w_height = $(window).height();
+  var jq_ss = $('#ss');
+  var jq_add_dialog = $('#add_dialog');
+  var jq_add_form = $('#add_form');
+  var status_data = <?php echo json_encode($status); ?>;
+  var jq_set_precedence = $('#set_precedence');
+  var jq_action_info = $('#action_info');
+  var jq_acc = $('#acc_container');
+
+
+  var jq_edit_extra_dialog = $('#edit_extra_dialog');
+  $('body').on('click','.del_extra',function(){
+    $(this).parent('div').remove();
+
+    var extras = new Array();
+    if($('#add_extra').val()){
+      extras = JSON.parse($('#add_extra').val());
+    }
+
+    extras.splice($(this).parent('div').attr('data'),1);
+
+    $('#extra_add_info').children('div').each(function(index,e){
+      console.log(index);
+      $(this).attr("data",index);
+    })
+
+    $('#add_extra').val(JSON.stringify(extras));
+  });
+  $(function(){
+    jq_acc.accordion({
+      height: w_height - 18,
+      onSelect: function(title) {
+
+      }
+    });
+
+
+    jq_setStatus.combobox({
+      editable: false,
+      data: status_data,
+    });
+    $('#edit_status').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;
+      })()
+    });
+    jq_filter_status.combobox({
+      width: 100,
+      data: status_data,
+      editable: false,
+      onSelect: function(){
+        search_content();
+      }
+    });
+    jq_edit_extra_dialog.dialog({
+      title: '添加时间段',
+      width: 440,
+      height: 160,
+      closed: true,
+      modal: true,
+      buttons:[{
+        text: '添加',
+        iconCls: 'icon-add',
+        handler: function(){
+          var extras = new Array();
+          if($('#add_extra').val()){
+            extras = JSON.parse($('#add_extra').val());
+          }
+
+          var extra = {};
+          extra.type = $('#edit_extra_type').val();
+          extra.price = $('#edit_extra_price').val();
+          if(!extra.type || !extra.price){
+            $.messager.show({
+              title: '提示',
+              msg: '填错啦',
+              timeout: 3500,
+              showType: 'slide'
+            });
+            //jq_edit_coverage_dialog.dialog('close');
+          }else{
+            extras.push(extra);
+            $('#add_extra').val(JSON.stringify(extras));
+
+            $('#extra_add_info').html($('#extra_add_info').html()+parse_extra_item(extra,false,extras.length));
+            jq_edit_extra_dialog.dialog('close');
+          }
+        }
+      },{
+        text: '取消',
+        iconCls: 'icon-cancel',
+        handler: function(){
+          jq_edit_extra_dialog.dialog('close');
+        }
+      }],
+      onOpen:function(){
+        $('#edit_extra_type').val('');
+        $('#edit_extra_price').val('');
+      }
+    });
+
+    $('#birth_time').datetimebox({
+      required: false,
+      showSeconds:false,
+      //buttons:buttons_add,
+      onSelect: function(date){
+        var currentDate = new Date();
+        $('#order_time_str_add').val(date.getTime()/1000);
+      }
+    });
+    $('#work_time').datetimebox({
+      required: false,
+      showSeconds:false,
+      //buttons:buttons_add,
+      onSelect: function(date){
+        var currentDate = new Date();
+        $('#order_time_str_add').val(date.getTime()/1000);
+      }
+    });
+    var buttons = $.extend([], $.fn.datebox.defaults.buttons);
+    buttons[0].text = '确定';
+    buttons[0].handler=function(){
+      var vals = $('#server_start_time').datetimebox('spinner').spinner('getValue').split(':');
+      $('#server_start_time_str').val(  parseInt($('#server_start_time_str').val())-(parseInt($('#server_start_time_str').val())+8*3600)%86400 +vals[0]*3600+vals[1]*60);
+
+      var d=new Date(parseInt($('#server_start_time_str').val())*1000);
+
+      $('#server_start_time').datetimebox('setText',formatDate(d));
+      $('#server_start_time').datetimebox('hidePanel');
+    };
+
+    $('#server_start_time').datetimebox({
+      required: false,
+      showSeconds:false,
+      buttons:buttons,
+      onSelect: function(date){
+        $('#server_start_time_str').val(date.getTime()/1000);
+      }
+    });
+    var buttons1 = $.extend([], $.fn.datebox.defaults.buttons);
+    buttons1[0].text = '确定';
+    buttons1[0].handler=function(){
+      var vals = $('#expire_time').datetimebox('spinner').spinner('getValue').split(':');
+      $('#expire_time_str').val(  parseInt($('#expire_time_str').val())-(parseInt($('#expire_time_str').val())+8*3600)%86400 +vals[0]*3600+vals[1]*60);
+
+      var d=new Date(parseInt($('#expire_time_str').val())*1000);
+
+      $('#expire_time').datetimebox('setText',formatDate(d));
+      $('#expire_time').datetimebox('hidePanel');
+    };
+
+    $('#expire_time').datetimebox({
+      required: false,
+      showSeconds:false,
+      buttons:buttons1,
+      onSelect: function(date){
+        $('#expire_time_str').val(date.getTime()/1000);
+      }
+    });
+
+
+
+
+
+    var buttons = $.extend([], $.fn.datebox.defaults.buttons);
+    buttons[0].text = '确定';
+
+
+
+
+
+
+
+
+
+
+
+    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(value);
+      },
+      prompt: '请输入关键字'
+    });
+
+    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);
+      }
+    });
+    jq_ss.searchbox({
+      width: 130,
+      searcher:function(value){
+        search_content(value);
+      },
+      prompt: '请输入关键字'
+    });
+    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: 'id',
+      sortOrder: 'desc',
+      queryParams: get_param_obj(),
+      frozenColumns:[[
+        {field:'id',checkbox:true}
+      ]],
+      columns:[[
+        {field:'id', title:'id', hidden:true},
+        {field:'gift_name', title:'礼包名称', },
+        {field:'gift_id', title:'礼包编号',},
+        {field:'pwd', title:'提货密码', },
+        {field:'name', title:'姓名',width:40 },
+        {field:'mobile', title:'手机号', width:40,sortable:false},
+        {field:'address', title:'地址', width:40,sortable:false},
+        {field:'flow', title:'物流商', width:40,sortable:false},
+        {field:'flow_number', title:'物流编号', width:40,sortable:false},
+        {field:'time', title:'兑换时间', width:40,sortable:true,formatter: function(value, row){
+          return   row.time_str;
+        }},
+        {field:'status', title:'状态', width:40,sortable:true,formatter: function(value, row){
+          return   row.status_str;
+        }}
+      ]],
+
+      onSelect: function(index, row){
+
+        var data = $.extend({}, row);
+
+
+        $('#id').val(row.id);
+        $('#id_str').html(row.id);
+        $('#edit_name').val(data.name);
+        $('#edit_mobile').val(data.mobile);
+        $('#edit_address').val(data.address);
+        $('#edit_flow').val(data.flow);
+        $('#edit_flow_number').val(data.flow_number);
+        $('#edit_pwd').val(data.pwd);
+        $('#edit_status').combobox('setValue', row.status);
+
+
+
+      },
+      onLoadSuccess : function () {
+        $('#id').val('');
+        $('#id_str').html('');
+        $('#edit_name').val('');
+        $('#edit_mobile').val('');
+        $('#edit_address').val('');
+        $('#edit_flow').val('');
+        $('#edit_flow_number').val('');
+        $('#edit_pwd').val('');
+        $('#edit_status').combobox('setValue', 100);
+
+
+        jq_dg_content.datagrid('clearSelections');
+      }
+
+    });
+
+
+
+
+    jq_content_form.form({
+      url: module_router + '/edit',
+      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){
+          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',
+      //url :'index.php?r=moonclub/xOrder/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'
+          });
+        }
+      }
+    });
+  });
+
+  function search_content(value = ''){
+    var search = value;
+    var filter_status = jq_filter_status.combobox('getValue');
+    jq_dg_content.datagrid({
+      pageNum: 1,
+      queryParams: {
+        search : search,
+        status : filter_status
+      }
+    });
+
+  };
+
+  function checkAddForm () {
+
+    return true;
+  }
+
+  function add_content(){
+    jq_add_dialog.dialog('open');
+  }
+  function   formatDate(now){
+    var   year=now.getFullYear();
+    var   month=now.getMonth()+1;
+    var   date=now.getDate();
+    var  hour = now.getHours();
+    var  minute = now.getMinutes();
+    return   year+"-"+month+"-"+date+" "+hour+":"+minute;
+  }
+  function save_content(){
+    $.messager.progress();
+    jq_content_form.submit();
+  }
+  function parse_time(data,attr){
+    if(data[attr]){
+      var d=new Date(data[attr]*1000);
+      return formatDate(d);
+    }else{
+      return '';
+    }
+  }
+  function   formatDate(now){
+    var   year=now.getFullYear();
+    var   month=now.getMonth()+1;
+    var   date=now.getDate();
+    var  hour = now.getHours();
+    var  minute = now.getMinutes();
+    return   year+"-"+month+"-"+date+" "+hour+":"+minute;
+  }
+  function add_extra(){
+    jq_edit_extra_dialog.dialog('open');
+  }
+  function parse_extra_item(extra,is_last,index){
+    return '<div data='+index+'>['+extra.type+'-'+extra.price+']'+'&nbsp;&nbsp;<a href="#"  class="del_extra">删除</a></div>';
+  }
+  function export_order(exp,export_type) {
+    window.location.href = module_router+'/OutputExcel';
+  }
+
+</script>