public function get_latest_touch($blog_id, $types) { $type_user = false; if (is_array($types)) { $array = preg_grep('/author/', $types); if (!empty($array)) { $type_user = true; } } else { $type_user = $types == 'author'; } $blog_filter = ''; if (!empty($blog_id)) { if ($type_user) { $blog_filter = 'and touch_blog_id = 0'; } else { $blog_filter = 'and touch_blog_id = ' . $blog_id; } } $type_filter = ''; if (!empty($types)) { if ($type_user) { $type_filter = 'and touch_object_type ="author"'; } else { if (is_array($types)) { foreach ($types as $type) { if ($type_filter != '') { $type_filter .= ','; } $type_filter .= "'{$type}'"; } $type_filter = 'and touch_object_type in (' . $type_filter . ')'; } else { $type_filter = "and touch_object_type ='{$types}'"; } } } $where = "1 = 1\n {$blog_filter}\n {$type_filter}\n order by\n touch_modified_on desc"; $extras['limit'] = 1; require_once 'class.mt_touch.php'; $touch = new Touch(); $touches = $touch->Find($where, false, false, $extras); if (!empty($touches)) { return $touches[0]; } return false; }
/** * 验证表单 * */ public function actiongetlogin() { $ret = array('status' => 1, 'msg' => '', 'data' => 10); try { $unmae = trim(urldecode(Yii::app()->request->getParam("unmae"))); $upwo = Yii::app()->request->getParam('upwo'); $code = Yii::app()->request->getParam('code'); if (!$this->login_type && $code != $_SESSION['Checknum']) { $ret['data'] = 1; //验证码错误 throw new Exception('验证码错误'); } $ret = permission::userLogin($unmae, $upwo); if ($this->login_type) { //C# 软件登录 $ret['msg'] = $ret['data']; $ret['data'] = array(); if ($ret['msg'] == 4) { //获取用户访问权限 $user = WebUser::getusersById($_SESSION['user_id']); if ($user['status'] == 0) { throw new Exception(2); } if (empty($user['data']->touchid)) { throw new Exception(6); } $touch_arr = json_decode($user['data']->touchid, true); //用户绑定的搭配屏 $touch_ret = Touch::touchSelectById($touch_arr[0]); //根据搭配屏获取品牌 if ($touch_ret['status'] == 0 || empty($touch_ret['data']['brandid'])) { throw new Exception(6); } try { $brand_ret = Brand::brandSelectById($touch_ret['data']['brandid']); if (count($brand_ret) == 0) { throw new Exception(''); } $qiniu = new erp_qiniu(); //七牛的接口类 $brand_qiniu_account = $qiniu->getAccountByBrand($touch_ret['data']['brandid']); //获取品牌的七牛子账号信息 if (count($brand_qiniu_account) == 0) { throw new Exception('品牌暂未绑定七牛帐号'); } $ret['data']['domain'] = $brand_qiniu_account[0]['domain']; $ret['data']['brandname'] = $brand_ret[0]['name']; $ret['data']['erpak'] = empty($brand_ret[0]['erpak']) ? '' : $brand_ret[0]['erpak']; $ret['data']['erpsk'] = empty($brand_ret[0]['erpsk']) ? '' : $brand_ret[0]['erpsk']; $ret['data']['code_start'] = $brand_ret[0]['code_start']; $ret['data']['code_end'] = $brand_ret[0]['code_end']; } catch (Exception $e) { throw new Exception(6); } $ret['data']['brandid'] = $touch_ret['data']['brandid']; $ret['data']['type'] = $_SESSION['type']; } } else { $ret['href'] = '/erp/manage'; } $ret['status'] = 1; } catch (Exception $e) { $ret['mag'] = $e->getMessage(); } echo json_encode($ret); }
/** * 根据条件查询所有显示品牌列表(品牌id,名,英文名) * @param $touchid:int (可不填,触摸屏id 默认0) * @return array('status'=>0,'msg'=>'','data'=>array()) 成功status为1 有data数据 */ public static function brandSelectForAllName($touchid = 0) { $ret = array('status' => 0, 'msg' => ''); try { $touch_data = array(); $touchid = trim($touchid); //获取触摸屏下的品牌 if (!empty($touchid)) { //当搭配屏ID不为空 $arr = Touch::touchBrand($touchid); if ($arr['status'] == 0) { throw new Exception($arr['msg']); } $touch_data = array_keys($arr['data']); if (!in_array(Yii::app()->params['cocoa_brandid'], $touch_data)) { $touch_data[] = Yii::app()->params['cocoa_brandid']; } } $brand_all_ret = self::brandSelectAll(); if ($brand_all_ret['status'] == 0) { throw new Exception($brand_all_ret['msg']); } if (count($touch_data) > 0) { foreach ($brand_all_ret['data'] as $key => $value) { if (!in_array($value['id'], $touch_data)) { unset($brand_all_ret['data'][$key]); } } } if (count($brand_all_ret['data']) == 0) { throw new Exception('未找到品牌!'); } $ret['data'] = $brand_all_ret['data']; $ret['status'] = 1; } catch (Exception $e) { $ret['msg'] = $e->getMessage(); } return $ret; }
public static function touchdateget() { $rowsPer = 500; $data = Yii::app()->beudb->createCommand()->select('*')->from('tconfig')->queryAll(); if (count($data) > 0) { $data = Comm::Conversion($data, "GBK", "UTF-8"); foreach ($data as $value) { $arr = array(); $arr['id'] = $value['id']; $arr['name'] = $value['name']; $arr['brandid'] = $value['brandid']; $arr['enddate'] = $value['enddate']; $arr['lock'] = $value['lock']; // echo $value['clothescategory'];exit(); $arr['apikey'] = $value['apikey']; $arr['headtail'] = json_encode(array('head' => array('touch' => $value['header'], 'ipad' => $value['ipadheader']), 'tail' => array('touch' => $value['footer'], 'ipad' => $value['ipadfooter']))); $arr['modellimit'] = $value['modellimit']; $arr['modeldefault'] = $value['modeldefault']; $arr['modelhead'] = json_encode(unserialize($value['modelhead'])); $arr['modelsethead'] = json_encode(unserialize($value['modelsethead'])); $arr['isshow'] = json_encode(unserialize($value['isshow'])); $arr['description'] = $value['description']; $arr['openkey'] = $value['openkey']; $arr['ver'] = 0; $arr['sqlver'] = 0; $arr['databaseupdate'] = $value['databaseupdate']; // Touch::touchForAdd($arr); self::tclothesSelectByTouchid($value['id']); //统计此触摸屏下的品牌并将其更新到触摸屏下 // } } } else { echo "null"; } }