Explorar o código

Merge branch 'master' of gitee.com:yiguanjia/php

seamong %!s(int64=7) %!d(string=hai) anos
pai
achega
0e5f0f3ea6

+ 3 - 3
www/protected/controllers/GiftController.php

@@ -53,7 +53,7 @@ class GiftController extends AdminController
         $title = Yii::app()->request->getParam('title','');
         $gift_num = Yii::app()->request->getParam('gift_num','');
         $desc = Yii::app()->request->getParam('desc','');
-        $type = Yii::app()->request->getParam('type','');
+        $type = (int)Yii::app()->request->getParam('type','');
         $supplier = Yii::app()->request->getParam('supplier','');
         if ($type == 100) {
             CommonFn::requestAjax(false,'请选择礼包类型');exit;
@@ -71,7 +71,7 @@ class GiftController extends AdminController
         $gift->gift_num = $gift_num;
         $gift->desc = $desc;
         $gift->supplier = $supplier;
-        $gift->type = $type;
+        $gift->type = (int)$type;
         $gift->save();
         CommonFn::requestAjax(true,'保存成功');exit;
     }
@@ -92,7 +92,7 @@ class GiftController extends AdminController
         $gift->title = $title;
         $gift->gift_num = $gift_num;
         $gift->desc = $desc;
-        $gift->type = $type;
+        $gift->type = (int)$type;
         $gift->supplier = $supplier;
         $gift->save();
         CommonFn::requestAjax(true,'保存成功');exit;

+ 19 - 5
www/protected/controllers/JRecordController.php

@@ -12,6 +12,7 @@ class JRecordController extends AdminController
     public function actionIndex()
     {
         $status = CommonFn::getComboboxData(JRecord::$status_options, 100, true, 100);
+        $type = CommonFn::getComboboxData(Gift::$type_options, 100, true, 100);
         $tmp = Business::model()->findAll();
 //        foreach ($tmp as $k) {
 //            $k->delete();
@@ -30,7 +31,8 @@ class JRecordController extends AdminController
 //        }
 
         $this->render('index',array(
-            'status' => $status
+            'status' => $status,
+            'type' => $type,
         ));
 
     }
@@ -124,9 +126,10 @@ class JRecordController extends AdminController
     {
         $start_time = Yii::app()->request->getParam('start_time','');
         $end_time = Yii::app()->request->getParam('end_time','');
+        $type = (int)Yii::app()->request->getParam('type','');
         $criteria = new EMongoCriteria();
-        $criteria->addCond('time','>=',strtotime(date('Y-m-d 00:00:00',strtotime($start_time))));
-        $criteria->addCond('time','<=',strtotime(date('Y-m-d 23:59:59',strtotime($start_time))));
+        $criteria->addCond('time','>=',strtotime(date('Y-m-d H:i:s',strtotime($start_time))));
+        $criteria->addCond('time','<=',strtotime(date('Y-m-d H:i:s',strtotime($end_time))));
         $cursor = JRecord::model()->findAll($criteria);
 
 
@@ -136,8 +139,19 @@ class JRecordController extends AdminController
             $item->status = 2;
             $item->save();
         }
-
-        $res=Service::factory('JRecordService')->push($parsedRows);
+        $data = [];
+        if ($type != 100) {
+            foreach ($parsedRows as &$row) {
+                if ($row['type'] == $type) {
+                    $data[] = $row;
+                }
+            }
+            $type_name = Gift::$type_options[$type]['name'];
+        } else {
+            $data = $parsedRows;
+            $type_name = '全部';
+        }
+        $res=Service::factory('JRecordService')->push($data,$type_name);
     }
 
 

+ 1 - 1
www/protected/modules/j/controllers/JRecordController.php

@@ -21,7 +21,7 @@
 
          $coupon = JCoupon::getByPwdOne($pwd);
          if (empty($coupon)) {
-             CommonFn::requestAjax(false,'兑换码或验证码错误');exit;
+             CommonFn::requestAjax(false,'兑换码错误');exit;
          }
          if ($coupon->status >= 2) {
              CommonFn::requestAjax(false,'兑换券已过期');exit;

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

@@ -68,6 +68,7 @@ class JRecord extends MongoAr
         $newRow['pwd'] = $coupon->pwd;
         $newRow['gift_name'] = $gift->title;
         $newRow['gift_type'] = Gift::$type_options[$gift->type]['name'];
+        $newRow['type'] = $gift->type;
         $newRow['gift_id'] = $gift->gift_num;
         $newRow['address'] = CommonFn::get_val_if_isset($row,'address','');
         $newRow['user_id'] = CommonFn::get_val_if_isset($row,'user_id','');

+ 2 - 2
www/protected/services/JRecordService.php

@@ -14,7 +14,7 @@ class JRecordService extends Service
      * @param string $name 导出的excel名称
      * @param $export 导出的类型  execute_export 执行订单汇总 order订单明细 tech保洁师明细
      */
-    public function push($data) {
+    public function push($data,$type) {
         error_reporting(E_ALL);
         date_default_timezone_set('Asia/Shanghai');
         $channel_option = ROrder::$channel_option;
@@ -60,7 +60,7 @@ class JRecordService extends Service
         $objPHPExcel->getActiveSheet()->setTitle('User');
         $objPHPExcel->setActiveSheetIndex(0);
         header('Content-Type: application/vnd.ms-excel');
-        $name = date('Y-m-d').'提货记录导出记录';
+        $name = date('Y-m-d').'提货记录导出记录-'.$type;
         header('Content-Disposition: attachment;filename="' . $name . '.xls"');
         header('Cache-Control: max-age=0');
         $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');

+ 17 - 1
www/protected/views/jRecord/index.php

@@ -25,6 +25,13 @@
             <div style="margin: 3px 2px;padding:5px;border: 1px solid #95B8E7;">
                 开始 <input type="text" id="server_start_time" />
                 结束 <input type="text" id="server_end_time" />
+                <div class="tb_line">
+                    <span class="tb_label">类型: </span>
+                    <input id="filter_type" />
+                    <!--                <div class="left">-->
+                    <!--                    查询:<input id="ss" />-->
+                    <!--                </div>-->
+                </div>
                 <a href="#" class='easyui-linkbutton' iconCls="icon-add" plain="true" onclick="export_order();return false;">导出提货记录 </a>
 
             </div>
@@ -301,6 +308,7 @@
   var jq_dg_content = $('#dg_content');
   var jq_content_form = $('#content_form');
   var jq_filter_status = $('#filter_status');
+  var jq_filter_type = $('#filter_type');
   var module_router = site_root + '/index.php?r=JRecord';
   var jq_setStatus = $('#setStatus');
   var jq_setStatus_add = $('#setStatus_add');
@@ -310,6 +318,7 @@
   var jq_add_dialog = $('#add_dialog');
   var jq_add_form = $('#add_form');
   var status_data = <?php echo json_encode($status); ?>;
+  var type_data = <?php echo json_encode($type); ?>;
   var jq_set_precedence = $('#set_precedence');
   var jq_action_info = $('#action_info');
   var jq_acc = $('#acc_container');
@@ -371,6 +380,11 @@
         search_content();
       }
     });
+    jq_filter_type.combobox({
+      width: 100,
+      data: type_data,
+      editable: false
+    });
 
 
     var p_width = parseInt(w_width / 2);
@@ -657,9 +671,11 @@
     if (!start_time && !end_time) {
       alert('请选择时间');
     } else {
-      window.location.href = module_router+'/OutputExcel&start_time='+start_time+'&end_time='+end_time;
+      const type = jq_filter_type.combobox('getValue');
+      window.location.href = module_router+'/OutputExcel&start_time='+start_time+'&end_time='+end_time + '&type=' + type;
       $('#server_start_time').datebox('setValue','');
       $('#server_end_time').datebox('setValue','');
+      jq_filter_type.combobox('setValue',100);
     }
 
   }