Commit c28a6e51 by 朱继来

调整币种

parent 0a6e11f2
Showing with 36 additions and 29 deletions
...@@ -284,7 +284,6 @@ class QuoteModel extends Model ...@@ -284,7 +284,6 @@ class QuoteModel extends Model
$classArr = (new SearchModel())->getClassName(\GuzzleHttp\json_encode($param)); $classArr = (new SearchModel())->getClassName(\GuzzleHttp\json_encode($param));
$CommonModel = new CommonModel; $CommonModel = new CommonModel;
$rate = $CommonModel->getRate();
#拼接批量插入明细 #拼接批量插入明细
foreach ($input as $k=>&$v){ foreach ($input as $k=>&$v){
...@@ -297,19 +296,23 @@ class QuoteModel extends Model ...@@ -297,19 +296,23 @@ class QuoteModel extends Model
} }
} }
if ($v['currency'] == 2) { if ($v['currency'] != 1) {
$v['price_rmb'] = $rate ? number_format($v['price_origin'] * $rate, 6) : 0; // 美元需计算汇率(排序用) $rate = $CommonModel->getRate($v['currency']);
$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"); $quote_sn = $this->where(["inquiry_items_id"=>$inquiry_items_id,"raw_goods_sn"=>$v["raw_goods_sn"]])->value("quote_sn");
if ($quote_sn){ #存在更新 if ($quote_sn){ #存在更新
$v["create_time"] = time(); $v["create_time"] = time();
$this->where(["inquiry_items_id"=>$inquiry_items_id,"raw_goods_sn"=>$v["raw_goods_sn"]])->update($v) ; $this->where(["inquiry_items_id"=>$inquiry_items_id,"raw_goods_sn"=>$v["raw_goods_sn"]])->update($v) ;
$currency_sign = array_get(Config('quote.currency_sign'), $v['currency'], '¥');
OpLogModel::log([ OpLogModel::log([
'types'=>2, 'types'=>2,
'relation_id'=>$inquiry_items_id, 'relation_id'=>$inquiry_items_id,
'relation_sn'=>$quote_sn, 'relation_sn'=>$quote_sn,
'content'=>'自动报价-更新,价格:'+($v["currency"] == "1" ? "¥".$v["price_rmb"] : "$".$v["price_origin"]), 'content'=>'自动报价-更新,价格:'+($v["currency"] == "1" ? "¥".$v["price_rmb"] : $currency_sign.$v["price_origin"]),
'create_name'=>"系统", 'create_name'=>"系统",
]); ]);
}else{ }else{
...@@ -371,8 +374,11 @@ class QuoteModel extends Model ...@@ -371,8 +374,11 @@ class QuoteModel extends Model
unset($quote_info['brand_s']); unset($quote_info['brand_s']);
$CommonModel = new CommonModel; $CommonModel = new CommonModel;
if ($quote_info['currency'] == 2) {
$rate = $CommonModel->getRate(); if ($quote_info['currency'] != 1) {
$currency_val = array_get(Config('quote.currency'), $quote_info['currency'], '美元');
$rate = $CommonModel->getRate($currency_val);
$quote_info['price_rmb'] = $rate ? number_format($quote_info['price_origin'] * $rate, 6) : 0; $quote_info['price_rmb'] = $rate ? number_format($quote_info['price_origin'] * $rate, 6) : 0;
} }
...@@ -431,11 +437,7 @@ class QuoteModel extends Model ...@@ -431,11 +437,7 @@ class QuoteModel extends Model
$InquiryModel = new InquiryModel; $InquiryModel = new InquiryModel;
$inquiry_uid = $InquiryModel->where('id', $quote_info['inquiry_id'])->value('create_uid'); // 询价人 $inquiry_uid = $InquiryModel->where('id', $quote_info['inquiry_id'])->value('create_uid'); // 询价人
if ($quote_info['currency'] == 1) { $price = array_get(Config('quote.currency_sign'), $quote_info['currency'], '¥').$quote_info['price_origin'];
$price = '¥'.$quote_info['price_rmb'];
} else {
$price = '$'.$quote_info['price_origin'];
}
$contents = $input['user_name'].'已报价,请及时查看!报价单号:'.$quote_info['quote_sn'].',型号:'.$quote_info['goods_name'].',单价:'.$price; $contents = $input['user_name'].'已报价,请及时查看!报价单号:'.$quote_info['quote_sn'].',型号:'.$quote_info['goods_name'].',单价:'.$price;
$CommonModel->send_msg($inquiry_uid, $contents); $CommonModel->send_msg($inquiry_uid, $contents);
...@@ -479,13 +481,13 @@ class QuoteModel extends Model ...@@ -479,13 +481,13 @@ class QuoteModel extends Model
$ApiController = new ApiController; $ApiController = new ApiController;
$CommonModel = new CommonModel; $CommonModel = new CommonModel;
$rate = $CommonModel->getRate(); // 获取汇率
foreach ($excel as &$v) { foreach ($excel as &$v) {
if ($v['currency'] == 'RMB') { if ($v['currency'] == '人民币') {
$v['currency'] = 1; $v['currency'] = 1;
} else { } else {
$v['currency'] = 2; $rate = $CommonModel->getRate($v['currency']); // 获取汇率
$v['currency'] = array_search($v['currency'], Config('quote.currency'));
$v['price_rmb'] = $rate ? number_format($v['price_origin'] * $rate, 6) : 0; $v['price_rmb'] = $rate ? number_format($v['price_origin'] * $rate, 6) : 0;
} }
...@@ -506,7 +508,7 @@ class QuoteModel extends Model ...@@ -506,7 +508,7 @@ class QuoteModel extends Model
$v['create_time'] = time(); $v['create_time'] = time();
$v['update_time'] = time(); $v['update_time'] = time();
} }
dd($excel);
$res = $this->insert($excel); // 批量插入 $res = $this->insert($excel); // 批量插入
if ($res === false) return [1, '添加报价草稿失败']; if ($res === false) return [1, '添加报价草稿失败'];
...@@ -553,27 +555,32 @@ class QuoteModel extends Model ...@@ -553,27 +555,32 @@ class QuoteModel extends Model
}); });
$required_keys = array_keys($required); // 必填项keys $required_keys = array_keys($required); // 必填项keys
$CommonModel = new CommonModel();
$err = []; // 提示信息 $err = []; // 提示信息
array_walk($excel, function($val, $key) use($required, $required_keys, &$err) { array_walk($excel, function($val, $key) use($required, $required_keys, &$err) {
// 跳过第一条 // 跳过第一条
if ($key != 0) { if ($key != 0) {
if ($val['currency'] == 'USD' && $val['price_origin'] <= 0) { if ($val['goods_name']) { // 判断型号是否存在
}
if ($val['currency'] != '人民币' && $val['price_origin'] <= 0) {
$err[] = '第'.($key+1).'行,单价等于或小于0'; $err[] = '第'.($key+1).'行,单价等于或小于0';
return; return;
} }
if ($val['currency'] == 'USD' && !preg_match('/^\d{0,9}(\.\d{0,6})?$/', $val['price_origin'])) { if ($val['currency'] != '人民币' && !preg_match('/^\d{0,9}(\.\d{0,6})?$/', $val['price_origin'])) {
$err[] = '第'.($key+1).'行,单价格式错误'; $err[] = '第'.($key+1).'行,单价格式错误';
return; return;
} }
if ($val['currency'] == 'RMB' && $val['price_rmb'] <= 0) { if ($val['currency'] == '人民币' && $val['price_rmb'] <= 0) {
$err[] = '第'.($key+1).'行,含税价格等于或小于0'; $err[] = '第'.($key+1).'行,含税价格等于或小于0';
return; return;
} }
if ($val['currency'] == 'RMB' && !preg_match('/^\d{0,9}(\.\d{0,6})?$/', $val['price_rmb'])) { if ($val['currency'] == '人民币' && !preg_match('/^\d{0,9}(\.\d{0,6})?$/', $val['price_rmb'])) {
$err[] = '第'.($key+1).'行,含税价格格式错误'; $err[] = '第'.($key+1).'行,含税价格格式错误';
return; return;
} }
...@@ -749,8 +756,10 @@ class QuoteModel extends Model ...@@ -749,8 +756,10 @@ class QuoteModel extends Model
$CommonModel = new CommonModel; $CommonModel = new CommonModel;
if ($quote_info['currency'] == 2) { if ($quote_info['currency'] != 1) {
$rate = $CommonModel->getRate(); $currency_val = array_get(Config('quote.currency'), $quote_info['currency'], '美元');
$rate = $CommonModel->getRate($currency_val);
$quote_info['price_rmb'] = $rate ? number_format($quote_info['price_origin'] * $rate, 6) : 0; $quote_info['price_rmb'] = $rate ? number_format($quote_info['price_origin'] * $rate, 6) : 0;
} }
...@@ -780,11 +789,9 @@ class QuoteModel extends Model ...@@ -780,11 +789,9 @@ class QuoteModel extends Model
$this->where('id', $input['quote_id'])->update($quote_info); $this->where('id', $input['quote_id'])->update($quote_info);
if ($quote_info['currency'] == 1) { if ($quote_info['currency'] == 1) {
$price = '¥'.$quote_info['price_rmb']; $price_log = '含税单价:¥'.$quote_info['price_rmb'];
$price_log = '含税单价:'.$quote_info['price_rmb'];
} else { } else {
$price = '$'.$quote_info['price_origin']; $price_log = '单价:'.array_get(Config('quote.currency_sign'), $quote_info['currency'], '¥').$quote_info['price_origin'];
$price_log = '单价:'.$quote_info['price_origin'];
} }
$content = '修改报价,报价单号:'.$input['quote_sn'].',型号:'.$quote_info['goods_name'].','.$price_log.',批次:'.$quote_info['batch'].',货期:'.$quote_info['delivery_time']; $content = '修改报价,报价单号:'.$input['quote_sn'].',型号:'.$quote_info['goods_name'].','.$price_log.',批次:'.$quote_info['batch'].',货期:'.$quote_info['delivery_time'];
......
...@@ -35,9 +35,9 @@ return [ ...@@ -35,9 +35,9 @@ return [
'currency_sign' => [ 'currency_sign' => [
1 => '¥', 1 => '¥',
2 => '$', 2 => '$',
3 => '', 3 => 'HK$',
4 => '£', 4 => '€',
5 => 'HK$', 5 => '£',
], ],
]; ];
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