Commit 2d29ea27 authored by wuxiaoli's avatar wuxiaoli

行情详情

parent 4e9ee995
......@@ -81,12 +81,13 @@ class Index extends Common
public function market()
{
$req = request();
$market = $req::instance()->param('market');
$code = $req::instance()->param('code');
$uid = $req::instance()->param('uid');
if ($code === null) {
return json(['data' => null, 'status' => 0, 'message' => '缺少参数code,操作失败']);
}
$data = z_market($code);
$data = z_market(strtolower($market).$code);
if (!$data) {
return json(['data' => $data, 'status' => 0, 'message' => '操作失败']);
}
......@@ -94,7 +95,7 @@ class Index extends Common
$data['price_range'] = round($p_range,2);
$data['price_rate'] = round(($p_range/$data['yesterday_price']*100),2);
$self = new StockSubAccountSelf();
$ret = $self->myadd($uid, $code);//查找是否存在
$ret = $self->myadd($uid, $market,$code);//查找是否存在
if ($ret) {
$data['myselect'] = 1;
}else{
......@@ -263,22 +264,23 @@ class Index extends Common
$req = request();
$uid = $req::instance()->param('uid');
$name = $req::instance()->param('name');
$market = $req::instance()->param('market');
$code = $req::instance()->param('code');
$self = new StockSubAccountSelf();
if (!empty($name) && !empty($code) && $uid == MID) {
$ret = $self->myadd($uid, $code);//查找是否存在
$ret = $self->myadd($uid,$market, $code);//查找是否存在
if ($ret) {
return json(['status' => 0, 'message' => '此股票已存在,添加失败']);
}
$res = $self->addmyselect($uid, $name, $code);
$res = $self->addmyselect($uid, $name,$market, $code);
} else {
$res = false;
}
if (!$res) {
return json(['status' => 0, 'message' => '添加失败']);
}
$data = $self->myadd($uid, $code);
$data = $self->myadd($uid,$market, $code);
if (!$data) {
return json(['status' => 0, 'message' => '系统错误']);
}
......@@ -298,11 +300,12 @@ class Index extends Common
$uid = MID;
$req = request();
$code = intval($req::instance()->param('code'));
$market = intval($req::instance()->param('market'));
if ($code === null) {
return json(['status' => 0, 'message' => '缺少参数code,操作失败']);
} else {
$self = new StockSubAccountSelf();
$res = $self->delmyselectbycode($uid, $code);
$res = $self->delmyselectbycode($uid,$market, $code);
}
if (!$res) {
return json(['status' => 0, 'message' => '删除失败']);
......@@ -320,10 +323,11 @@ class Index extends Common
json(['status' => 0, 'message' => '请登录!']);
}
$uid = MID;
if(!uid){
if(!$uid){
return json(['status' => 0, 'message' => '请登录后操作']);
}
$req = request();
$marketarr = trim($req::instance()->param('market'));
$code = trim($req::instance()->param('code'));
$codeArr = explode(',',$code);
if(!is_array($codeArr)){
......@@ -335,7 +339,8 @@ class Index extends Common
$self = new StockSubAccountSelf();
foreach($codeArr as $k=>$v){
$delcode = intval($v);
$res = $self->delmyselectbycode($uid, $delcode);
$market = $marketarr[$k];
$res = $self->delmyselectbycode($uid,$market, $delcode);
}
}
if (!$res) {
......
......@@ -22,9 +22,10 @@ class StockSubAccountSelf extends Model{
* $code 股票代码
* $sub_id 子账户id
*/
public function addmyselect($uid,$name,$code,$sub_id=0){
public function addmyselect($uid,$name,$market,$code,$sub_id=0){
$data['uid']=$uid;
$data['sub_id']=$sub_id;
$data['market'] =$market;
$data['gupiao_name']=$name;
$data['gupiao_code']=$code;
$data['creat_time']=time();
......@@ -43,9 +44,10 @@ class StockSubAccountSelf extends Model{
/*
* 查找我的自选
*/
public function myadd($uid,$code){
public function myadd($uid,$market,$code){
$data=Db::name('stock_subaccount_self')
->where('uid='.$uid)
->where('market='.$market)
->where('gupiao_code='.$code)
->find();
return $data;
......@@ -53,9 +55,10 @@ class StockSubAccountSelf extends Model{
/*
* 删除我的自选
*/
public function delmyselectbycode($uid,$code){
public function delmyselectbycode($uid,$market,$code){
$data=Db::name('stock_subaccount_self')
->where('uid='.$uid)
->where('market='.$market)
->where('gupiao_code='.$code)
->delete();
return $data;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment