findAll(); // foreach ($tmp as $k) { // $k->delete(); //// } // $tmp = JRecord::model()->findAll(); // foreach ($tmp as $k) { // $k->delete(); // } // $tmp = JCoupon::model()->findAll(); // foreach ($tmp as $k) { // $k->delete(); // } // $tmp = Gift::model()->findAll(); // foreach ($tmp as $k) { // $k->delete(); // } $this->render('index',array( 'status' => $status, 'type' => $type, )); } 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',''); $flow_time = Yii::app()->request->getParam('flow_time',''); $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; // 改动前后不想等 则判断为修改物流信息 则发送短信 if ($flow != $record->flow || $flow_number != $record->flow_number || $flow_time != $record->flow_time) { } $record->flow = $flow; $record->flow_number = $flow_number; $record->flow_time = strtotime($flow_time); $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',''); $pwd = Yii::app()->request->getParam('pwd',''); // $coding_num = Yii::app()->request->getParam('coding_num',''); if (!$name ||!$mobile || !$address || !$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 = 0; $record->time = time(); $record->save(); $coupon->status = 1; $coupon->save(); CommonFn::requestAjax(true,'生成成功');exit; } public function actionOutputExcel() { $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 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); $rows = CommonFn::getRowsFromCursor($cursor); $parsedRows = JRecord::model()->parse($rows); foreach ($cursor as $item) { $item->status = 2; $item->save(); } $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,['start' => $start_time, 'end' => $end_time]); } }