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
fb7729f4
authored
Mar 25, 2021
by
朱继来
Browse files
Options
_('Browse Files')
Download
Plain Diff
merge
parents
15498a38
c424a7bd
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
60 additions
and
26 deletions
app/Http/Controllers/ApiController.php
app/Model/InquiryItemsReportModel.php
app/Model/InquiryModel.php
app/Http/Controllers/ApiController.php
View file @
fb7729f4
...
...
@@ -218,10 +218,10 @@ class ApiController extends Controller
Export
((
new
QuoteModel
())
->
quoteCount
(
$input
));
}
//
修改销售报价信息
public
function
Api
UpdateReport
(
$input
,
$id
)
//
选中或者确定报价
public
function
Api
OpQuote
(
$input
,
$id
)
{
Export
((
new
InquiryItemsReportModel
())
->
updateReport
(
$input
));
Export
((
new
InquiryItemsReportModel
())
->
OpQuote
(
$input
));
}
//获取客户信息
...
...
app/Model/InquiryItemsReportModel.php
View file @
fb7729f4
...
...
@@ -112,34 +112,55 @@ class InquiryItemsReportModel extends Model
}
/*
*
更新内容
*
选中或者确定报价
*/
public
function
updateReport
(
$data
){
$inquiry_items_id
=
$data
[
"inquiry_items_id"
];
public
function
OpQuote
(
$data
){
$inquiry_items_id
=
$data
[
"inquiry_items_id"
];
#询价明细id
$quote_id
=
$data
[
"quote_id"
];
#报价id
if
(
$inquiry_items_id
<=
0
)
return
[
1001
,
"询价明细ID不得为空"
];
$temp
[
"price_origin"
]
=
@
$data
[
"price_origin"
]
?
$data
[
"price_origin"
]
:
0
;
$temp
[
"price_rmb"
]
=
@
$data
[
"price_rmb"
]
?
$data
[
"price_rmb"
]
:
0
;
$currency
=
@
$data
[
"currency"
]
?
$data
[
"currency"
]
:
1
;
#报价币种
$InquiryItemsModel
=
new
InquiryItemsModel
();
$inquiryItem
=
$InquiryItemsModel
->
select
(
"inquiry_id"
)
->
where
(
"id"
,
$inquiry_items_id
)
->
first
()
->
toArray
();
$inquiry
=
(
new
InquiryModel
())
->
select
(
"currency"
)
->
where
(
"id"
,
$inquiryItem
[
"inquiry_id"
])
->
first
()
->
toArray
();
$mainCurrency
=
$inquiry
[
"currency"
];
#询价币种
if
(
$quote_id
<=
0
)
return
[
1001
,
"报价ID不得为空"
];
$price
=
@
$data
[
"price"
]
?
$data
[
"price"
]
:
0
;
#销售报价
$QuoteModel
=
new
QuoteModel
();
$quoteItem
=
$QuoteModel
->
where
(
"id"
,
$quote_id
)
->
first
()
->
toArray
();
$currency
=
$quoteItem
[
"currency"
];
#报价币种
$inquiry
=
(
new
InquiryModel
())
->
select
(
"currency"
)
->
where
(
"id"
,
$quoteItem
[
"inquiry_id"
])
->
first
()
->
toArray
();
$mainCurrency
=
$inquiry
[
"currency"
];
#询价主单币种
$rate
=
(
new
CommonModel
())
->
getRate
(
"美元"
);
#获取美元汇率
$price_rmb
=
$price_origin
=
""
;
if
(
$mainCurrency
==
1
){
#询价币种人民币
$
temp
[
"price_rmb"
]
=
$currency
!=
$mainCurrency
?
round
(
$data
[
"price"
]
*
$rate
,
6
)
:
$data
[
"price"
]
;
$
price_rmb
=
$currency
!=
$mainCurrency
?
round
(
$price
*
$rate
,
6
)
:
$price
;
}
if
(
$mainCurrency
==
2
){
#询价币种美金
$
temp
[
"price_origin"
]
=
$currency
!=
$mainCurrency
?
round
(
$data
[
"price"
]
/
$rate
,
6
)
:
$data
[
"price"
]
;
$
price_origin
=
$currency
!=
$mainCurrency
?
round
(
$price
/
$rate
,
6
)
:
$price
;
}
$up
=
$this
->
where
(
"inquiry_items_id"
,
$inquiry_items_id
)
->
update
(
$temp
);
$temp
=
[
"currency"
=>
$mainCurrency
,
"goods_name"
=>
$quoteItem
[
"goods_name"
],
"goods_name_pro"
=>
$quoteItem
[
"goods_name"
],
"brand_id"
=>
$quoteItem
[
"brand_id"
],
"brand_name"
=>
$quoteItem
[
"brand_name"
],
"class_id2"
=>
$quoteItem
[
"class_id2"
],
"class_id2_name"
=>
$quoteItem
[
"class_id2_name"
],
"price_rmb"
=>
$price_rmb
,
"price_origin"
=>
$price_origin
,
"inquiry_number"
=>
$quoteItem
[
"quote_number"
],
"delivery_time"
=>
$quoteItem
[
"delivery_time"
],
"batch"
=>
$quoteItem
[
"batch"
],
"create_time"
=>
time
()
,
];
#更新报价报表
(
new
InquiryItemsReportModel
())
->
where
(
"inquiry_items_id"
,
$inquiry_items_id
)
->
update
(
$temp
);
#更新报价单
(
new
QuoteModel
())
->
where
(
"id"
,
$data
[
"quote_id"
])
->
update
([
"status"
=>
$data
[
"status"
]]);
#更新报价选中
#更新询价明细表状态
$InquiryItemsModel
->
where
(
"id"
,
$inquiry_items_id
)
->
update
([
"status"
=>
$data
[
"status"
]
==
2
?
3
:
5
]);
(
new
InquiryItemsModel
())
->
where
(
"id"
,
$inquiry_items_id
)
->
update
([
"status"
=>
$data
[
"status"
]
==
2
?
3
:
5
]);
return
[
0
,
"成功"
];
}
...
...
@@ -154,9 +175,15 @@ class InquiryItemsReportModel extends Model
* 判断是否能生成报价单
*/
public
function
checkReport
(
$input
){
$types
=
$input
[
"types"
];
#类型:1 报价pdf 2 销售单
$itemsIdArr
=
explode
(
","
,
$input
[
"inquiry_items_ids"
]);
$check
=
(
new
QuoteModel
())
->
where
(
"status"
,
3
)
->
whereIn
(
"inquiry_items_id"
,
$itemsIdArr
)
->
count
();
return
$check
!=
count
(
$itemsIdArr
)
?
[
1001
,
"没有销售报价的报价单不能生成销售订单"
]
:
[
0
,
"通过"
];
$InquiryItemsModel
=
new
InquiryItemsModel
();
if
(
$types
==
1
){
$check
=
$InquiryItemsModel
->
whereIn
(
"status"
,[
3
,
4
,
5
])
->
whereIn
(
"inquiry_items_id"
,
$itemsIdArr
)
->
count
();
}
else
{
$check
=
$InquiryItemsModel
->
where
(
"status"
,
5
)
->
whereIn
(
"inquiry_items_id"
,
$itemsIdArr
)
->
count
();
}
return
$check
!=
count
(
$itemsIdArr
)
?
[
1001
,
$types
==
1
?
"存在没选中的询价单!"
:
"存在没确定的询价单!"
]
:
[
0
,
"通过"
];
}
...
...
app/Model/InquiryModel.php
View file @
fb7729f4
...
...
@@ -102,11 +102,18 @@ class InquiryModel extends Model
}
$page
=
isset
(
$input
[
'p'
])
?
$input
[
'p'
]
:
$input
[
'page'
];
$list
=
$list
->
orderBy
(
'create_time'
,
'desc'
)
->
orderBy
(
'b.status'
,
'desc'
)
->
paginate
(
@
$input
[
'limit'
]
?
$input
[
"limit"
]
:
10
,
[
'*'
],
'p'
,
@
$page
?
$page
:
1
)
->
toArray
();
//getSql("rfq");
#排序
if
(
@
$input
[
"inquiry_number_sort"
]){
$list
=
$list
->
orderBy
(
'b.inquiry_number'
,
$input
[
"inquiry_number_sort"
]);
}
else
if
(
@
$input
[
"create_time_sort"
]){
$list
=
$list
->
orderBy
(
'b.create_time'
,
$input
[
"create_time_sort"
]);
}
else
{
$list
=
$list
->
orderBy
(
'b.id'
,
"desc"
);
}
$list
=
$list
->
paginate
(
@
$input
[
'limit'
]
?
$input
[
"limit"
]
:
10
,
[
'*'
],
'p'
,
@
$page
?
$page
:
1
)
->
toArray
();
if
(
!
$list
)
return
[
20001
,
'没有数据'
];
$QuoteModel
=
new
QuoteModel
();
...
...
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