123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- <?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 = 0;
- $record->flow = $flow;
- $record->flow_number = $flow_number;
- $record->time = time();
- $record->save();
- $coupon->status = 2;
- $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','');
- $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);
- $res=Service::factory('JRecordService')->push($parsedRows);
- }
- }
|