123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298 |
- <?php
- /**
- * Created by north.Deng's MAC
- * User: north.Deng
- * Date: 2018/1/9
- * Time: 上午10:02
- * description :
- */
- class HouseKeepingController extends JBaseController
- {
- public function actionList()
- {
- $id = (Yii::app()->request->getParam('id'));
- $store_id = Yii::app()->request->getParam('store_id','');
- $criteria = new EMongoCriteria();
- if (!empty($store_id)) {
- $criteria->store_id('==', intval($store_id));
- }
- // id筛选
- if (!empty($id)) {
- $criteria->user_id('==', $id);
- }
- $criteria->sort('time',EMongoCriteria::SORT_DESC);
- $cursor = HouseKeeping::model()->findAll($criteria);
- $rows = CommonFn::getRowsFromCursor($cursor);
- $parsedRows = HouseKeeping::model()->parse($rows);
- $total = $cursor->count();
- echo CommonFn::composeDatagridData($parsedRows, $total);
- }
- public function actionGetUser()
- {
- $id = (Yii::app()->request->getParam('user_id'));
- $c= new EMongoCriteria();
- $c->user_id('==',new MongoId($id));
- $tmp = JEmploye::model()->find($c);
- $data = array();
- if (empty($tmp) ) {
- $c1 = new EMongoCriteria();
- $c1->user_id('==',new MongoId($id));
- $emp = JGEmploye::model()->find($c1);
- if (empty($emp)) {
- $data['user_id'] = '';
- $data['store_id'] = '';
- $data['is_teacher'] = 0;//用户
- echo json_encode($data);exit;
- }
- $data['user_id'] = $emp->user_id;
- $data['store_id'] = $emp->store_id;
- $data['is_teacher'] = 1;//家政
- echo json_encode($data);exit;
- }
- $data['user_id'] = $tmp->user_id;
- $data['store_id'] = $tmp->owned_stores;
- $data['is_teacher'] = 2;//门店老师
- echo json_encode($data);
- }
- public function actionGetStore()
- {
- $c= new EMongoCriteria();
- $c->status('==',2);
- $tmp = Store::model()->findAll($c);
- $i = 0;
- $data = array();
- foreach ($tmp as $k => $v) {
- $data[$i]['store_id'] = $v->store_id;
- $data[$i]['store_name'] = $v->store_name;
- $data[$i]['mobile'] = $v->mobile;
- $data[$i++]['address'] = $v->address;
- }
- echo json_encode($data);
- }
- public function actionEdit()
- {
- $status = intval(Yii::app()->request->getParam('status', ''));
- $flag = intval(Yii::app()->request->getParam('flag', 0));
- $contract = intval(Yii::app()->request->getParam('contract', ''));
- $type = intval(Yii::app()->request->getParam('type', ''));
- $cart = intval(Yii::app()->request->getParam('cart', ''));
- $skill = Yii::app()->request->getParam('skill', '');
- $age = intval(Yii::app()->request->getParam('age', 0));
- $tech = (Yii::app()->request->getParam('tech', ''));
- $tech_mobile = (Yii::app()->request->getParam('tech_mobile', ''));
- $desc = (Yii::app()->request->getParam('desc', ''));
- $yc_time = intval(Yii::app()->request->getParam('yc_time', ''));
- $server_start_time = intval(Yii::app()->request->getParam('server_start_time', ''));
- $status_time = intval(Yii::app()->request->getParam('status_time', ''));
- $server_end_time = intval(Yii::app()->request->getParam('server_end_time', ''));
- $id = Yii::app()->request->getParam('id');
- $cancel_cause = Yii::app()->request->getParam('cancel_cause','');
- if (!CommonFn::isMongoId($id)) {
- CommonFn::requestAjax(false, '修改失败', array());
- }
- $h = HouseKeeping::get(new MongoId($id));
- if (!empty($contract)) {
- $h->contract = $contract;
- }
- if (!empty($type)) {
- $h->type = $type;
- }
- if (!empty($cart)) {
- $h->cart = $cart;
- }
- if (!empty($skill)) {
- $h->skill = $skill;
- }
- if (!empty($age)) {
- $h->age = $age;
- }
- if (!empty($desc)) {
- $h->desc = $desc;
- }
- if (!empty($status)) {
- $h->status = $status;
- if (intval($status) == 4) {
- if (!empty($cancel_cause)) {
- $h->cancel_cause = $cancel_cause;
- }
- }
- }
- if (!empty($status_time)) {
- $h->status_time = $status_time;
- }
- if (!empty($server_start_time)) {
- $h->server_start_time = $server_start_time;
- }
- if (!empty($server_end_time)) {
- $h->server_end_time = $server_end_time;
- }
- if (!empty($yc_time)) {
- $h->yc_time = $yc_time;
- }
- if (!empty($tech)) {
- $h->tech = $tech;
- }
- if (!empty($tech_mobile)) {
- $h->tech_mobile = $tech_mobile;
- }
- $success = $h->save();
- if ($success && $flag == 1) {//status_time
- $c = new EMongoCriteria();
- $c->store_id('==',$h->store_id);
- $store = Store::model()->find($c);
- CommonSMS::send('jinguo_order_retrieve', array(
- 'user_name' => $h->user_name,
- 'year' => date('Y',$h->status_time),
- 'month' => date('m',$h->status_time),
- 'day' => date('d',$h->status_time),
- 'hour' => date('H',$h->status_time),
- 'minute' => date('i',$h->status_time),
- 'Interviewt' => '面试',
- 'store' => $store->store_name,
- 'address' => $store->address,
- 'phone' => $store->mobile,
- 'mobile' => $h->mobile,
- ));
- }
- CommonFn::requestAjax($success, '修改成功', array());
- }
- public function actionFlag()
- {
- $id = Yii::app()->request->getParam('id');
- if (!CommonFn::isMongoId($id)) {
- CommonFn::requestAjax(false, '修改失败', array());
- }
- $h = HouseKeeping::get(new MongoId($id));
- $h->flag = 1;
- $success = $h->save();
- CommonFn::requestAjax($success, '修改成功', array());
- }
- public function actionAdd()
- {
- $mobile = (Yii::app()->request->getParam('mobile', ''));
- $user_name = (Yii::app()->request->getParam('user_name', ''));
- $user_id = (Yii::app()->request->getParam('user_id', ''));
- $type = intval(Yii::app()->request->getParam('type', 1));
- $cart = intval(Yii::app()->request->getParam('cart', 1));
- $skill = json_decode(Yii::app()->request->getParam('skill'));
- $age = intval(Yii::app()->request->getParam('age', 1));
- $address = Yii::app()->request->getParam('address', '');
- $tech = (Yii::app()->request->getParam('tech', ''));
- $desc = (Yii::app()->request->getParam('desc', ''));
- $yc_time = intval(Yii::app()->request->getParam('yc_time', ''));
- $server_start_time = intval(Yii::app()->request->getParam('server_start_time', ''));
- $status_time = intval(Yii::app()->request->getParam('status_time', ''));
- $server_end_time = intval(Yii::app()->request->getParam('server_end_time', ''));
- $store_id = intval(Yii::app()->request->getParam('store_id', ''));
- $h = new HouseKeeping();
- $h->store_id = $store_id;
- $h->user_name = $user_name;
- $h->user_id = $user_id;
- $h->mobile = $mobile;
- $h->type = $type;
- $h->cart = $cart;
- $h->address = $address;
- $h->server_start_time = $server_start_time;
- $h->server_end_time = $server_end_time;
- $h->skill = $skill;
- $h->yc_time = $yc_time;
- $h->age = $age;
- $h->desc = $desc;
- $h->status = 1;
- $h->status_time = $status_time;
- $h->tech = $tech;
- $h->contract = 1;
- $h->flag = 0;
- $h->time = time();
- $result = $h->save();
- $c = new EMongoCriteria();
- $c->owned_stores('==',$store_id);
- $c->flag('==',1);
- $remp = JEmploye::model()->findAll($c);
- $c1 = new EMongoCriteria();
- $c1->store_id('==',$store_id);
- $store_name = Store::model()->find($c1)->store_name;
- foreach ($remp as $value) {
- CommonSMS::send('jinguo_mianshi_retrieve', array(
- 'user_name' => $value->user_name,
- 'store' => $store_name,
- 'kill' => HouseKeeping::$type_option[$type],
- 'mobile' => $value->mobile
- ));
- }
- if ($result) {
- CommonFn::requestAjax($result, '添加成功', array());
- } else {
- CommonFn::requestAjax($result, '添加失败', array());
- }
- }
- public function actionAddUserInfo()
- {
- $user_id = Yii::app()->request->getParam('user_id','');
- if (empty($user_id) || !CommonFn::isMongoId($user_id)) {
- CommonFn::requestAjax(false, '添加失败1', array());
- }
- $mobile = Yii::app()->request->getParam('mobile','');
- $name = Yii::app()->request->getParam('name','');
- $user = RUser::get(new MongoId($user_id));
- $user->user_info = array('mobile' => $mobile,'name' => $name);
- if ($user->save()) {
- CommonFn::requestAjax(true, '添加成功', array());
- } else {
- CommonFn::requestAjax(false, '添加失败', array());
- }
- }
- public function actionServer()
- {
- $user_name = Yii::app()->request->getParam('user_name','');
- $servers = Yii::app()->request->getParam('servers','');
- $status_time = Yii::app()->request->getParam('status_time','');
- $store = Yii::app()->request->getParam('store','');
- $address = Yii::app()->request->getParam('address','');
- $mobile = Yii::app()->request->getParam('mobile','');
- $phone = Yii::app()->request->getParam('phone','');
- CommonSMS::send('jinguo_mianshi_retrieve', array(
- 'user_name' => $user_name,
- 'year' => date('Y',$status_time),
- 'month' => date('m',$status_time),
- 'day' => date('d',$status_time),
- 'hour' => date('H',$status_time),
- 'minute' => date('i',$status_time),
- 'store' => $store,
- 'Interviewt' => '面试',
- 'servers' => $servers,
- 'address' => $address,
- 'mobile' => $mobile,
- 'phone' => $phone,
- ));
- }
- }
|