Commit a9cbebe2 by 朱继来

调整美元报价,换算汇率

parent 89582261
Showing with 23 additions and 4 deletions
......@@ -12,6 +12,7 @@ use App\Model\UserModel;
use App\Model\InquiryItemsModel;
use App\Model\InquiryItemsAssignModel;
use App\Model\SearchModel;
use App\Model\CommonModel;
use App\Http\Controllers\PermController;
use App\Http\Controllers\ApiController;
use RedisDB;
......@@ -259,6 +260,9 @@ class QuoteModel extends Model
}
$classArr = (new SearchModel())->getClassName(\GuzzleHttp\json_encode($param));
$CommonModel = new CommonModel;
$rate = $CommonModel->getRate();
#拼接批量插入明细
foreach ($input as $k=>&$v){
if ($classArr !== false){
......@@ -270,6 +274,10 @@ class QuoteModel extends Model
}
}
if ($v['currency'] == 2) { // 美元需计算汇率(排序用)
$v['price_rmb'] = $rate ? number_format($v['price_origin'] * $rate, 6) : 0;
}
$quote_sn = $this->where(["inquiry_items_id"=>$inquiry_items_id,"raw_goods_sn"=>$v["raw_goods_sn"]])->value("quote_sn");
if ($quote_sn){ #存在更新
$v["create_time"] = time();
......@@ -329,8 +337,10 @@ class QuoteModel extends Model
$quote_info['brand_name'] = $brand[0]['brand_name'];
unset($quote_info['brand_s']);
if ($quote_info['currency'] == 2) { // 美元时,含税单价为0
$quote_info['price_rmb'] = 0;
if ($quote_info['currency'] == 2) {
$CommonModel = new CommonModel;
$rate = $CommonModel->getRate();
$quote_info['price_rmb'] = $rate ? number_format($quote_info['price_origin'] * $rate, 6) : 0;
}
$params = [];
......@@ -417,13 +427,16 @@ class QuoteModel extends Model
// 插入到报价表 -- 状态:草稿
try {
$ApiController = new ApiController;
$CommonModel = new CommonModel;
$rate = $CommonModel->getRate(); // 获取汇率
foreach ($excel as &$v) {
if ($v['currency'] == 'RMB') {
$v['currency'] = 1;
} else {
$v['currency'] = 2;
$v['price_rmb'] = 0; // 美元时,含税单价为0
$v['currency'] = 2;
$v['price_rmb'] = $rate ? number_format($v['price_origin'] * $rate, 6) : 0;
}
$v['quote_sn'] = $ApiController->createSn($this, 'quote_sn', 'B');
......@@ -640,6 +653,12 @@ class QuoteModel extends Model
$quote_info = $input['quote_info'];
if ($quote_info['currency'] == 2) {
$CommonModel = new CommonModel;
$rate = $CommonModel->getRate();
$quote_info['price_rmb'] = $rate ? number_format($quote_info['price_origin'] * $rate, 6) : 0;
}
$brand = json_decode($quote_info['brand_s'], true);
$quote_info['brand_id'] = $brand[0]['brand_id'];
......
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 sign in to comment