Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
黄成意
/
php_frq_api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
3c752037
authored
Mar 10, 2021
by
hcy001
Browse files
Options
_('Browse Files')
Download
Plain Diff
Merge branch 'master' of
ssh://119.23.72.7:22611/q578953158/php_frq_api
parents
814339c1
cffeceaa
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
20 deletions
app/Model/QuoteModel.php
app/Model/QuoteModel.php
View file @
3c752037
...
...
@@ -7,8 +7,9 @@ use App\map\QuoteMap;
use
Illuminate\Database\Eloquent\Model
;
use
Request
;
use
DB
;
use
App\Model\Op
l
ogModel
;
use
App\Model\Op
L
ogModel
;
use
App\Model\UserModel
;
use
App\Model\InquiryItemsModel
;
use
App\Http\Controllers\PermController
;
use
App\Http\Controllers\ApiController
;
use
RedisDB
;
...
...
@@ -182,7 +183,7 @@ class QuoteModel extends Model
return
$data
;
}
// 撤销
// 撤销
报价
public
function
cancel
(
$input
)
{
$id
=
$input
[
'id'
];
...
...
@@ -191,10 +192,13 @@ class QuoteModel extends Model
if
(
!
$id
)
return
[
-
1
,
'参数缺失'
];
try
{
$res
=
$this
->
where
(
'id'
,
$id
)
->
update
([
'status'
=>
-
1
,
'cancel_reason'
=>
$cancel_reason
]);
$quote_info
=
$this
->
find
(
$id
);
if
(
$quote_info
[
'status'
]
==
-
1
)
return
[
1
,
'该报价已撤销,请刷新页面查看'
];
if
(
$quote_info
[
'status'
]
>
1
)
return
[
1
,
'当前报价状态不能撤销,请刷新页面查看'
];
$res
=
$this
->
where
(
'id'
,
$id
)
->
update
([
'status'
=>
-
1
,
'cancel_reason'
=>
$cancel_reason
]);
$UserModel
=
new
UserModel
;
$data
=
[];
...
...
@@ -205,7 +209,7 @@ class QuoteModel extends Model
$data
[
'create_uid'
]
=
$input
[
'user_id'
];
$data
[
'create_name'
]
=
$UserModel
->
FinduserInfoName
(
$input
[
'user_id'
]);
Op
l
ogModel
::
log
(
$data
);
Op
L
ogModel
::
log
(
$data
);
}
catch
(
Exception
$e
)
{
return
[
1
,
$e
->
getMessage
()];
}
...
...
@@ -221,24 +225,36 @@ class QuoteModel extends Model
if
(
!
$quote_info
)
return
[
1
,
'报价数据不存在'
];
try
{
$res
=
$this
->
create
(
$quote_info
);
// 询价明细单状态
$inquiry_items_status
=
InquiryItemsModel
::
where
(
'id'
,
$quote_info
[
'inquiry_items_id'
])
->
value
(
'status'
);
if
(
$inquiry_items_status
==
-
1
)
return
[
1
,
'新增报价失败,该询价明细已关闭'
];
$UserModel
=
new
UserModel
;
$create_name
=
$UserModel
->
FinduserInfoName
(
$input
[
'user_id'
]);
$quote_info
[
'status'
]
=
1
;
// 已报价
$quote_info
[
'create_uid'
]
=
$input
[
'user_id'
];
$quote_info
[
'create_uid'
]
=
$create_name
;
$res
=
$this
->
create
(
$quote_info
);
if
(
$res
===
false
)
return
[
2
,
'新增报价失败'
];
if
(
$inquiry_items_status
==
1
)
{
// 询价明细为待报价时,更新为已报价
InquiryItemsModel
::
where
(
'id'
,
$quote_info
[
'inquiry_items_id'
])
->
update
([
'status'
=>
2
]);
}
// 通知询价人,放入redis
RedisDB
::
set
(
'frq_quote_urge'
,
$quote_info
[
'inquiry_items_id'
]);
$UserModel
=
new
UserModel
;
$data
=
[];
$data
[
'types'
]
=
2
;
$data
[
'relation_id'
]
=
$quote_info
[
'inquiry_items_id'
];
$data
[
'relation_sn'
]
=
''
;
$data
[
'content'
]
=
'新增报价,报价单号:'
.
$quote_info
[
'quote_sn'
];
$data
[
'create_uid'
]
=
$input
[
'user_id'
];
$data
[
'create_name'
]
=
$
UserModel
->
FinduserInfoName
(
$input
[
'user_id'
])
;
$data
[
'create_name'
]
=
$
create_name
;
Op
l
ogModel
::
log
(
$data
);
Op
L
ogModel
::
log
(
$data
);
}
catch
(
Exception
$e
)
{
return
[
1
,
$e
->
getMessage
()];
}
...
...
@@ -249,6 +265,10 @@ class QuoteModel extends Model
// 报价导入
public
function
import
(
$input
)
{
// 询价明细单状态
$inquiry_items_status
=
InquiryItemsModel
::
where
(
'id'
,
$input
[
'inquiry_items_id'
])
->
value
(
'status'
);
if
(
$inquiry_items_status
==
-
1
)
return
[
1
,
'导入报价失败,该询价明细已关闭'
];
$file
=
$_FILES
[
'file'
];
// $request->file('file')
$filePath
=
$file
[
'tmp_name'
];
// 临时路径
...
...
@@ -300,7 +320,7 @@ class QuoteModel extends Model
$data
[
'create_uid'
]
=
$input
[
'user_id'
];
$data
[
'create_name'
]
=
$UserModel
->
FinduserInfoName
(
$input
[
'user_id'
]);
Op
l
ogModel
::
log
(
$data
);
Op
L
ogModel
::
log
(
$data
);
}
catch
(
Exception
$e
)
{
return
[
1
,
$e
->
getMessage
()];
}
...
...
@@ -418,7 +438,7 @@ class QuoteModel extends Model
$data
[
'create_uid'
]
=
$input
[
'user_id'
];
$data
[
'create_name'
]
=
$UserModel
->
FinduserInfoName
(
$input
[
'user_id'
]);
Op
l
ogModel
::
log
(
$data
);
Op
L
ogModel
::
log
(
$data
);
}
catch
(
Exception
$e
)
{
return
[
1
,
$e
->
getMessage
()];
}
...
...
@@ -431,6 +451,10 @@ class QuoteModel extends Model
{
if
(
!
$input
[
'inquiry_items_id'
])
return
[
-
1
,
'参数缺失'
];
// 询价明细单状态
$inquiry_items_status
=
InquiryItemsModel
::
where
(
'id'
,
$input
[
'inquiry_items_id'
])
->
value
(
'status'
);
if
(
$inquiry_items_status
==
-
1
)
return
[
1
,
'批量提交报价失败,该询价明细已关闭'
];
try
{
$map
=
[];
$map
[
'inquiry_items_id'
]
=
$input
[
'inquiry_items_id'
];
...
...
@@ -443,6 +467,10 @@ class QuoteModel extends Model
$this
->
where
(
$map
)
->
update
([
'status'
=>
1
]);
if
(
$inquiry_items_status
==
1
)
{
// 询价明细为待报价时,更新为已报价
InquiryItemsModel
::
where
(
'id'
,
$input
[
'inquiry_items_id'
])
->
update
([
'status'
=>
2
]);
}
// 通知询价人,放入redis
RedisDB
::
sadd
(
'frq_quote_urge'
,
$input
[
'inquiry_items_id'
]);
...
...
@@ -456,7 +484,7 @@ class QuoteModel extends Model
$data
[
'create_uid'
]
=
$input
[
'user_id'
];
$data
[
'create_name'
]
=
$UserModel
->
FinduserInfoName
(
$input
[
'user_id'
]);
Op
l
ogModel
::
log
(
$data
);
Op
L
ogModel
::
log
(
$data
);
}
catch
(
Exception
$e
)
{
return
[
1
,
$e
->
getMessage
()];
}
...
...
@@ -482,7 +510,7 @@ class QuoteModel extends Model
$data
[
'create_uid'
]
=
$input
[
'user_id'
];
$data
[
'create_name'
]
=
$UserModel
->
FinduserInfoName
(
$input
[
'user_id'
]);
Op
l
ogModel
::
log
(
$data
);
Op
L
ogModel
::
log
(
$data
);
}
catch
(
Exception
$e
)
{
return
[
1
,
$e
->
getMessage
()];
}
...
...
@@ -502,7 +530,7 @@ class QuoteModel extends Model
$start_time
=
$curr_zero_time
+
$i
*
3600
;
$end_time
=
$start_time
+
3600
;
$data
[
'today_quote'
][]
=
$this
->
getTodayQoutCount
(
$input
,
$start_time
);
$data
[
'today_quote'
][]
=
$this
->
getTodayQoutCount
(
$input
,
$start_time
,
$end_time
);
$data
[
'today_no_quote'
][]
=
$this
->
getTodayNoQoutCount
(
$input
,
$start_time
,
$end_time
);
$data
[
'x_axis_data'
][]
=
$i
.
'点'
;
}
...
...
@@ -513,7 +541,7 @@ class QuoteModel extends Model
$start_time
=
$curr_zero_time
-
$i
*
86400
;
$end_time
=
$start_time
+
86399
;
$data
[
'today_quote'
][]
=
$this
->
getTodayQoutCount
(
$input
,
$start_time
);
$data
[
'today_quote'
][]
=
$this
->
getTodayQoutCount
(
$input
,
$start_time
,
$end_time
);
$data
[
'today_no_quote'
][]
=
$this
->
getTodayNoQoutCount
(
$input
,
$start_time
,
$end_time
);
$data
[
'x_axis_data'
][]
=
date
(
'Y-m-d'
,
$curr_zero_time
-
$i
*
86400
);
}
...
...
@@ -524,7 +552,7 @@ class QuoteModel extends Model
$start_time
=
$curr_zero_time
-
$i
*
86400
;
$end_time
=
$start_time
+
86399
;
$data
[
'today_quote'
][]
=
$this
->
getTodayQoutCount
(
$input
,
$start_time
);
$data
[
'today_quote'
][]
=
$this
->
getTodayQoutCount
(
$input
,
$start_time
,
$end_time
);
$data
[
'today_no_quote'
][]
=
$this
->
getTodayNoQoutCount
(
$input
,
$start_time
,
$end_time
);
$data
[
'x_axis_data'
][]
=
date
(
'Y-m-d'
,
$curr_zero_time
-
$i
*
86400
);
}
...
...
@@ -536,9 +564,9 @@ class QuoteModel extends Model
}
// 当日报价数
public
function
getTodayQoutCount
(
$input
,
$start_time
)
public
function
getTodayQoutCount
(
$input
,
$start_time
,
$end_time
)
{
return
$this
->
where
(
'create_uid'
,
$input
[
'user_id'
])
->
where
(
'create_time'
,
'>='
,
$start_time
)
->
count
();
return
$this
->
where
(
'create_uid'
,
$input
[
'user_id'
])
->
where
Between
(
'create_time'
,
[
$start_time
,
$end_time
]
)
->
count
();
}
// 当日未报价数
...
...
@@ -574,7 +602,7 @@ class QuoteModel extends Model
$data
[
'create_uid'
]
=
$input
[
'user_id'
];
$data
[
'create_name'
]
=
$UserModel
->
FinduserInfoName
(
$input
[
'user_id'
]);
Op
l
ogModel
::
log
(
$data
);
Op
L
ogModel
::
log
(
$data
);
}
catch
(
Exception
$e
)
{
return
[
1
,
$e
->
getMessage
()];
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment