north 7 ani în urmă
părinte
comite
80a27d9a4a

+ 79 - 0
www/protected/controllers/BusinessController.php

@@ -0,0 +1,79 @@
+<?php
+
+/**
+ * Created by north.Deng's MAC
+ * User: north.Deng
+ * Date: 2018/2/28
+ * Time: 下午12:30
+ * description :
+ */
+class BusinessController extends AdminController
+{
+    public function actionIndex()
+    {
+        $status = CommonFn::getComboboxData(Business::$type_options, 100, true, 100);
+        $this->render('index',[
+            '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('source','or',new MongoRegex('/' . $search . '/'));
+        }
+        $cursor = Business::model()->findAll($criteria);
+        $rows = CommonFn::getRowsFromCursor($cursor);
+        $parsedRows = Business::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','');
+        $type = Yii::app()->request->getParam('status','');
+        $source = Yii::app()->request->getParam('source','');
+
+
+        if (!CommonFn::isMongoId($id)) {
+            CommonFn::requestAjax(false,'id错误');exit;
+        }
+
+
+        $business = Business::get(new MongoId($id));
+        $business->type = (int)$type;
+        $business->mobile = $mobile;
+        $business->name = $name;
+        $business->source = $source;
+        $business->save();
+        CommonFn::requestAjax(true,'保存成功');exit;
+    }
+
+    public function actionAdd()
+    {
+        $name = Yii::app()->request->getParam('name','');
+        $mobile = Yii::app()->request->getParam('mobile','');
+        $type = Yii::app()->request->getParam('status','');
+        $source = Yii::app()->request->getParam('source','');
+
+        $business = new Business();
+        $business->type = (int)$type;
+        $business->mobile = $mobile;
+        $business->name = $name;
+        $business->source = $source;
+        $business->save();
+        CommonFn::requestAjax(true,'保存成功');exit;
+    }
+
+
+}

+ 20 - 15
www/protected/controllers/GiftController.php

@@ -11,7 +11,19 @@ class GiftController extends AdminController
 {
     public function actionIndex()
     {
-        $this->render('index');
+        $c = new EMongoCriteria();
+        $c->type('==',0);
+        $bs = Business::model()->findAll($c);
+        $tmp =[];
+        foreach ($bs as $gift) {
+            $tmp[] = array('name' => $gift->source,'id' => (string)$gift->_id);
+        }
+
+
+        $tmp = CommonFn::getComboboxData($tmp, 0, false );
+        $this->render('index',[
+            'gifts' => $tmp
+        ]);
     }
 
     public function actionList()
@@ -37,10 +49,10 @@ class GiftController extends AdminController
     {
         $id = Yii::app()->request->getParam('id','');
         $title = Yii::app()->request->getParam('title','');
+        $gift_num = Yii::app()->request->getParam('gift_num','');
         $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)) {
@@ -51,12 +63,9 @@ class GiftController extends AdminController
 
         $gift = Gift::get(new MongoId($id));
         $gift->title = $title;
+        $gift->gift_num = $gift_num;
         $gift->desc = $desc;
-        $gift->supplier = array(
-            'supplier' => $supplier,
-            'name' => $supplier_name,
-            'mobile' => $supplier_mobile,
-        );
+        $gift->supplier = $supplier;
         $gift->save();
         CommonFn::requestAjax(true,'保存成功');exit;
     }
@@ -64,18 +73,14 @@ class GiftController extends AdminController
     {
         $title = Yii::app()->request->getParam('title','');
         $desc = Yii::app()->request->getParam('desc','');
+        $gift_num = Yii::app()->request->getParam('gift_num','');
         $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->gift_num = $gift_num;
         $gift->desc = $desc;
-        $gift->supplier = array(
-            'supplier' => $supplier,
-            'name' => $supplier_name,
-            'mobile' => $supplier_mobile,
-        );
+        $gift->supplier = $supplier;
         $gift->save();
         CommonFn::requestAjax(true,'保存成功');exit;
     }

+ 15 - 2
www/protected/controllers/JCouponController.php

@@ -18,9 +18,22 @@ class JCouponController extends AdminController
             $tmp[] = array('name' => $gift->title,'id' => (string)$gift->_id);
         }
         $tmp = CommonFn::getComboboxData($tmp, 0, false );
+
+        $c = new EMongoCriteria();
+        $c->type('==',1);
+        $bs = Business::model()->findAll($c);
+        $tmp1 =[];
+        foreach ($bs as $gift) {
+            $tmp1[] = array('name' => $gift->source,'id' => (string)$gift->_id);
+        }
+
+
+        $tmp1 = CommonFn::getComboboxData($tmp1, 0, false );
+
         $this->render('index',array(
             'status' => $status,
-            'gifts' => $tmp
+            'gifts' => $tmp,
+            'bus' => $tmp1
         ));
 
     }
@@ -65,7 +78,7 @@ class JCouponController extends AdminController
     {
         $num = (int)Yii::app()->request->getParam('num','');
         $gift_id = Yii::app()->request->getParam('gift_id','');
-        $channel = Yii::app()->request->getParam('channel','');
+        $channel = Yii::app()->request->getParam('bus_id','');
         $expire_time = Yii::app()->request->getParam('expire_time_str','');
         if (!$num ||!$channel || !$gift_id || !$expire_time) {
             CommonFn::requestAjax(false,'请填写完整信息');exit;

+ 6 - 2
www/protected/controllers/JRecordController.php

@@ -75,7 +75,7 @@ class JRecordController extends AdminController
         $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);
+//        $status = (int)Yii::app()->request->getParam('status',0);
         $pwd = Yii::app()->request->getParam('pwd','');
 
         if (!$name ||!$mobile || !$address || !$flow||!$flow_number  || !$pwd) {
@@ -93,7 +93,7 @@ class JRecordController extends AdminController
         );
         $record->address = $address;
         $record->coupon_id = (string)$coupon->_id;
-        $record->status = $status;
+        $record->status = 0;
         $record->flow = $flow;
         $record->flow_number = $flow_number;
         $record->time = time();
@@ -105,7 +105,11 @@ class JRecordController extends AdminController
 
     public function actionOutputExcel()
     {
+        $start_time = Yii::app()->request->getParam('start_time','');
+        $end_time = Yii::app()->request->getParam('end_time','');
         $criteria = new EMongoCriteria();
+        $criteria->time('>=',strtotime($start_time));
+        $criteria->time('<=',strtotime($end_time));
         $cursor = JRecord::model()->findAll($criteria);
         $rows = CommonFn::getRowsFromCursor($cursor);
         $parsedRows = JRecord::model()->parse($rows);

+ 71 - 0
www/protected/modules/j/models/Business.php

@@ -0,0 +1,71 @@
+<?php
+
+/**
+ * Created by north.Deng's MAC
+ * User: north.Deng
+ * Date: 2018/5/4
+ * Time: 上午10:10
+ * description :
+ * 礼包
+ */
+class Business extends MongoAr
+{
+    public $_id;
+    public $name;//手机号
+    public $mobile;//联系方式
+    public $type;//供货商 提货商
+    public $source;//公司名称
+
+
+    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_business';
+    }
+
+    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 $type_options = [
+        0 => ['name' => '供货商'],
+        1 => ['name' => '发行商']
+    ];
+
+
+
+    public function parseRow($row,$output=array()){
+
+        $newRow = array();
+        $newRow['id'] = (string)$row['_id'];
+        $newRow['name'] = CommonFn::get_val_if_isset($row,'name','');
+        $newRow['mobile'] = CommonFn::get_val_if_isset($row,'mobile','');
+        $newRow['source'] = CommonFn::get_val_if_isset($row,'source','');
+        $newRow['type'] = CommonFn::get_val_if_isset($row,'type','');
+        $newRow['type_str'] = self::$type_options[(int) $newRow['type']]['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);
+    }
+
+}

+ 8 - 4
www/protected/modules/j/models/Gift.php

@@ -12,8 +12,9 @@ class Gift extends MongoAr
 {
     public $_id;
     public $title;//标题
+    public $gift_num;//礼包编号
     public $desc;
-    public $supplier = array();//供货商 联系人 联系方式
+    public $supplier;//供货商 联系人 联系方式
 
 
 
@@ -33,6 +34,7 @@ class Gift extends MongoAr
         return 'j_gift';
     }
 
+
     public static function get($_id) {
         if(CommonFn::isMongoId($_id)){
             $criteria = new EMongoCriteria();
@@ -52,10 +54,12 @@ class Gift extends MongoAr
         $newRow = array();
         $newRow['id'] = (string)$row['_id'];
         $newRow['title'] = (string)$row['title'];
-        $newRow['supplier'] = CommonFn::get_val_if_isset($row,'supplier','');
+        $bus = Business::get(new MongoId($row['supplier']));
+        $newRow['supplier'] = $bus->source;
         $newRow['desc'] = CommonFn::get_val_if_isset($row,'desc','');
-        $newRow['mobile'] = $newRow['supplier']['mobile'];
-        $newRow['name'] = $newRow['supplier']['name'];
+        $newRow['gift_num'] = CommonFn::get_val_if_isset($row,'gift_num','');
+        $newRow['mobile'] = $bus->mobile;
+        $newRow['name'] =  $bus->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',"");

+ 6 - 5
www/protected/modules/j/models/JCoupon.php

@@ -19,10 +19,9 @@ class JCoupon extends MongoAr
     public $status = 0;// 0未发 1已发 2已提 3过期
 
     static public $status_options = array(
-        0 => array('name' => '未发'),
-        1 => array('name' => '已发'),
-        2 => array('name' => '已提'),
-        3 => array('name' => '过期'),
+        0 => array('name' => '已发'),
+        1 => array('name' => '已提'),
+        2 => array('name' => '过期'),
     );
 
 
@@ -82,9 +81,11 @@ class JCoupon extends MongoAr
         $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['channel_str'] = Business::get(new MongoId($newRow['channel']))->source;
         $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['pwd'] = '******';
+        //$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'];
 

+ 1 - 1
www/protected/modules/j/models/JRecord.php

@@ -62,7 +62,7 @@ class JRecord extends MongoAr
         $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['gift_id'] = $gift->gift_num;
         $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'];

+ 527 - 0
www/protected/views/business/index.php

@@ -0,0 +1,527 @@
+<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 type="text" name="source" id="source">
+                                        </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="name" id="name">
+                                        </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="mobile" id="mobile">
+                                        </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 type="text" name="source" >
+                        </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="name" >
+                        </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="mobile" >
+                        </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>
+
+
+            </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=Business';
+  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,
+    });
+
+    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();
+      }
+    });
+
+
+
+
+
+    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:'source', title:'公司名称',width:40 },
+        {field:'name', title:'联系人', width:40,sortable:false},
+        {field:'mobile', title:'联系方式', width:40,sortable:false},
+        {field:'type_str', title:'类型', width:40,sortable:false},
+
+      ]],
+
+      onSelect: function(index, row){
+
+        var data = $.extend({}, row);
+
+
+        $('#id').val(row.id);
+        $('#id_str').html(row.id);
+        $('#source').val(data.source);
+        $('#name').val(data.name);
+        $('#mobile').val(data.mobile);
+        $('#setStatus').combobox('setValue', row.type);
+
+
+
+      },
+      onLoadSuccess : function () {
+        $('#id').val('');
+        $('#id_str').html('');
+        $('#source').val('');
+        $('#name').val('');
+        $('#mobile').val('');
+        $('#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>

+ 36 - 28
www/protected/views/gift/index.php

@@ -55,6 +55,16 @@
                                         </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_gift_num" name="gift_num" style="width: 250px;"  />
+                                        </div>
+                                    </div>
+                                </li>
                                 <li class="f_item">
                                     <div class="box">
                                         <div class="f_label">
@@ -72,7 +82,7 @@
                                             <span>供货商: </span>
                                         </div>
                                         <div class="box_flex f_content">
-                                            <input id="edit_supplier" name="supplier" style="width: 250px;"  />
+                                            <input id="edit_supplier" name="supplier" style="width: 250px;" readonly  />
                                         </div>
                                     </div>
                                 </li>
@@ -82,7 +92,7 @@
                                             <span>供货商联系人: </span>
                                         </div>
                                         <div class="box_flex f_content">
-                                            <input id="edit_supplier_name" name="supplier_name" style="width: 250px;"  />
+                                            <input id="edit_supplier_name" name="supplier_name" style="width: 250px;"  readonly />
                                         </div>
                                     </div>
                                 </li>
@@ -92,7 +102,7 @@
                                             <span>供货商联系方式: </span>
                                         </div>
                                         <div class="box_flex f_content">
-                                            <input id="edit_supplier_mobile" name="supplier_mobile" style="width: 250px;"  />
+                                            <input id="edit_supplier_mobile" name="supplier_mobile" style="width: 250px;" readonly  />
                                         </div>
                                     </div>
                                 </li>
@@ -132,10 +142,10 @@
                 <li class="f_item">
                     <div class="box">
                         <div class="f_label">
-                            <span>内容描述: </span>
+                            <span>礼包编号: </span>
                         </div>
                         <div class="box_flex f_content">
-                            <textarea id="add_desc" name="desc" style="width: 250px;"  ></textarea>
+                            <input id="add_gift_num" name="gift_num" style="width: 250px;"  />
                         </div>
                     </div>
                 </li>
@@ -143,30 +153,22 @@
                 <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>
+                            <span>内容描述: </span>
                         </div>
                         <div class="box_flex f_content">
-                            <input id="add_supplier_name" name="supplier_name" style="width: 250px;"  />
+                            <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>
+                            <span>供货商: </span>
                         </div>
                         <div class="box_flex f_content">
-                            <input id="add_supplier_mobile" name="supplier_mobile" style="width: 250px;"  />
+                            <input id="gift" name="gift" style="width: 250px;"  />
+                            <input id="gift_id" name="supplier" type='hidden' style="width: 250px;"  />
                         </div>
                     </div>
                 </li>
@@ -224,12 +226,18 @@
     var jq_ss = $('#ss');
     var jq_add_dialog = $('#add_dialog');
     var jq_add_form = $('#add_form');
-
+    var gifts = <?php echo json_encode($gifts); ?>;
     var jq_set_precedence = $('#set_precedence');
     var jq_action_info = $('#action_info');
     var jq_acc = $('#acc_container');
-
-
+    console.log(gifts);
+    $('#gift').combobox({
+      editable: false,
+      data: gifts,
+      onSelect: function(e){
+        $('#gift_id').val(e.attributes.id);
+      }
+    });
     var jq_edit_extra_dialog = $('#edit_extra_dialog');
     $('body').on('click','.del_extra',function(){
         $(this).parent('div').remove();
@@ -469,11 +477,9 @@
             ]],
             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:'title', title:'标题', width:40,sortable:false},
+                {field:'gift_num', title:'礼包编号', width:40,sortable:false},
+                {field:'supplier', title:'供货商', width:40,sortable:false},
                 {field:'name', title:'联系人', width:40},
                 {field:'mobile', title:'联系方式', width:40}
             ]],
@@ -486,7 +492,8 @@
                 $('#id').val(row.id);
                 $('#id_str').html(row.id);
                 $('#edit_title').val(data.title);
-                $('#edit_supplier').val(data.supplier.supplier);
+                $('#edit_gift_num').val(data.gift_num);
+                $('#edit_supplier').val(data.supplier);
                 $('#edit_supplier_name').val(data.name);
                 $('#edit_supplier_mobile').val(data.mobile);
                 $('#edit_desc').val(data.desc);
@@ -498,6 +505,7 @@
               $('#id').val('');
               $('#id_str').html('');
               $('#edit_title').val('');
+              $('#edit_gift_num').val('');
               $('#edit_supplier').val('');
               $('#edit_supplier_name').val('');
               $('#edit_supplier_mobile').val('');

+ 11 - 2
www/protected/views/jCoupon/index.php

@@ -124,7 +124,8 @@
                             <span>发行渠道: </span>
                         </div>
                         <div class="box_flex f_content">
-                            <input id="channel" name="channel" style="width: 250px;"  />
+                            <input id="bus" name="bus" style="width: 250px;"  />
+                            <input id="bus_id" name="bus_id" type='hidden' style="width: 250px;"  />
                         </div>
                     </div>
                 </li>
@@ -208,6 +209,7 @@
   var jq_add_form = $('#add_form');
   var status_data = <?php echo json_encode($status); ?>;
   var gifts = <?php echo json_encode($gifts); ?>;
+  var bus = <?php echo json_encode($bus); ?>;
   var jq_set_precedence = $('#set_precedence');
   var jq_action_info = $('#action_info');
   var jq_acc = $('#acc_container');
@@ -251,6 +253,13 @@
         $('#gift_id').val(e.attributes.id);
       }
     });
+    $('#bus').combobox({
+      editable: false,
+      data: bus,
+      onSelect: function(e){
+        $('#bus_id').val(e.attributes.id);
+      }
+    });
     jq_setStatus_add.combobox({
       editable: false,
       data: (function () {
@@ -499,7 +508,7 @@
         $('#id_str').html(row.id);
         $('#gift_name').html(data.gift_name);
         $('#pwd').html(data.pwd);
-        $('#channel').html(data.channel);
+        $('#channel').html(data.channel_str);
         $('#setStatus').combobox('setValue', row.status);
 
 

+ 20 - 46
www/protected/views/jRecord/index.php

@@ -23,6 +23,8 @@
                 <!--                </div>-->
             </div>
             <div style="margin: 3px 2px;padding:5px;border: 1px solid #95B8E7;">
+                开始 <input type="text" id="server_start_time" />
+                结束 <input type="text" id="expire_time" />
                 <a href="#" class='easyui-linkbutton' iconCls="icon-add" plain="true" onclick="export_order();return false;">导出提货记录 </a>
                 <a href="#" class='easyui-linkbutton' plain="true" iconCls="icon-add" onclick="add_content();return false;">新增提货记录</a>
             </div>
@@ -103,7 +105,7 @@
                                             <span>提货密码: </span>
                                         </div>
                                         <div class="box_flex f_content">
-                                            <input id="edit_pwd" name="pwd" style="width: 250px;" readonly  />
+                                            <input id="edit_pwd" name="pwd" type="password" style="width: 250px;" readonly  />
                                         </div>
                                     </div>
                                 </li>
@@ -194,11 +196,11 @@
                             <span>提货密码: </span>
                         </div>
                         <div class="box_flex f_content">
-                            <input  name="pwd" style="width: 250px;"  />
+                            <input  name="pwd" type="password" style="width: 250px;"  />
                         </div>
                     </div>
                 </li>
-                <li class="f_item">
+                <!--<li class="f_item">
                     <div class="box">
                         <div class="f_label">
                             <span>状态: </span>
@@ -208,7 +210,7 @@
 
                         </div>
                     </div>
-                </li>
+                </li>-->
 
 
 
@@ -373,7 +375,7 @@
       }
     });
 
-    $('#birth_time').datetimebox({
+    $('#server_start_time').datetimebox({
       required: false,
       showSeconds:false,
       //buttons:buttons_add,
@@ -382,7 +384,7 @@
         $('#order_time_str_add').val(date.getTime()/1000);
       }
     });
-    $('#work_time').datetimebox({
+    $('#expire_time').datetimebox({
       required: false,
       showSeconds:false,
       //buttons:buttons_add,
@@ -391,46 +393,8 @@
         $('#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);
-      }
-    });
 
 
 
@@ -538,7 +502,9 @@
         {field:'id', title:'id', hidden:true},
         {field:'gift_name', title:'礼包名称', },
         {field:'gift_id', title:'礼包编号',},
-        {field:'pwd', title:'提货密码', },
+        {field:'pwd', title:'提货密码', formatter: function(value, row){
+            return   '******';
+          }},
         {field:'name', title:'姓名',width:40 },
         {field:'mobile', title:'手机号', width:40,sortable:false},
         {field:'address', title:'地址', width:40,sortable:false},
@@ -717,7 +683,15 @@
     return '<div data='+index+'>['+extra.type+'-'+extra.price+']'+'&nbsp;&nbsp;<a href="#"  class="del_extra">删除</a></div>';
   }
   function export_order() {
-    window.location.href = module_router+'/OutputExcel';
+    let start_time = $('#server_start_time').datebox('getValue');
+    let end_time = $('#expire_time').datebox('getValue');
+    console.log(start_time);
+    if (!start_time && !end_time) {
+      alert('请选择时间');
+    } else {
+      window.location.href = module_router+'/OutputExcel&start_time='+start_time+'&end_time='+end_time;
+    }
+
   }
 
 </script>