Commit 40b60386 by hcy001
parents b93b14a4 72c288c7
......@@ -6,6 +6,7 @@ use Illuminate\Database\Eloquent\Model;
use Request;
use DB;
use App\Model\CmsModel;
use App\Model\Mongo\SpuModel;
//公共模型
class CommonModel extends Model
......@@ -203,7 +204,22 @@ class CommonModel extends Model
}
// 判断型号是否存在
public function isGoodsNameExists($goods_name)
{
return DB::connection('mongodb')->collection('spu')->where('spu_name', $goods_name)->value('_id');
}
// 判断品牌是否存在
public function isBrandNameExists($brand_name)
{
return DB::connection("spu")->table('brand')->where('brand_name', $brand_name)->value('brand_id');
}
// 判断供应商是否存在
public function isSupplierNameExists($supplier_name)
{
return DB::connection('ass')->table('supplier_channel')->where('supplier_name', $supplier_name)->value('supplier_id');
}
}
\ No newline at end of file
......@@ -48,11 +48,10 @@ class QuoteModel extends Model
->toArray();
if (!$list) return [20001, '没有数据'];
foreach ($list['data'] as $k=>&$v){
$currency_sign = InquiryMap::$currency_sign[$v["currency"]];
$v["price_origin"] = $v["currency"] >1 ? $currency_sign.$v["price_origin"] : "--";
$v["price_rmb"] = $v["currency"] == 1 ? $currency_sign.$v["price_rmb"]:"--";
$v["price_origin"] = $v["currency"] == 2 ? "$".$v["price_origin"] : "--";
$v["price_rmb"] = $v["currency"] == 1 ? "¥".$v["price_rmb"]:"--";
$v['status'] = QuoteMap::$status[$v["status"]];
if ($v["remark"] == "digikey"){
if ($v["create_name"] == "digikey"){
$v["create_name"] = "digikey(包装:".$v["raw_goods_packing"].")";
}
}
......@@ -201,16 +200,13 @@ class QuoteModel extends Model
case "brand_name":
$query->where('it.brand_name', 'like',$b.'%');
break;
case "inquiry_items_id":
$query->where('it.id', '<>',$b);
break;
}
}
$query->whereIn('q.status', [1,2,3]);
});
$list = $list->orderBy('id', 'desc')->paginate($limit, ['*'], 'page', $page)->toArray();
foreach ( $list['data'] as $b=>&$v) {
foreach ($list['data'] as $b=>&$v) {
if ($v['currency'] == 1){
$v["price_origin"] = "--";
}else{
......@@ -239,7 +235,7 @@ class QuoteModel extends Model
foreach ($data as &$v) {
$currency_sign = $v['currency'] == 1 ? '¥' : '$';
$v['currency_val'] = $v['currency'] == 1 ? 'RMB' : 'USD';
$v['currency_val'] = array_get(Config('quote.currency'), $v['currency'], '人民币');
$v['price'] = $v['currency'] == 1 ? $currency_sign.$v['price_rmb'] : $currency_sign.$v['price_origin'];
$v['status_val'] = array_get(Config('quote.quote_status'), $v['status'], '');
......@@ -560,7 +556,7 @@ class QuoteModel extends Model
$v['create_time'] = time();
$v['update_time'] = time();
}
dd($excel);
$res = $this->insert($excel); // 批量插入
if ($res === false) return [1, '添加报价草稿失败'];
......@@ -610,11 +606,34 @@ dd($excel);
$CommonModel = new CommonModel();
$err = []; // 提示信息
array_walk($excel, function($val, $key) use($required, $required_keys, &$err) {
array_walk($excel, function($val, $key) use($CommonModel, $required, $required_keys, &$err) {
// 跳过第一条
if ($key != 0) {
if ($val['goods_name']) { // 判断型号是否存在
$res = $CommonModel->isGoodsNameExists($val['goods_name']);
if (!$res) {
$err[] = '第'.($key+1).'行,型号'.$val['goods_name'].'不存在于系统';
return;
}
}
if ($val['brand_name']) { // 判断品牌是否存在
$res = $CommonModel->isBrandNameExists($val['brand_name']);
if (!$res) {
$err[] = '第'.($key+1).'行,品牌'.$val['brand_name'].'不存在于系统';
return;
}
}
if ($val['supplier_name']) { // 判断供应商是否存在
$res = $CommonModel->isSupplierNameExists($val['supplier_name']);
if (!$res) {
$err[] = '第'.($key+1).'行,供应商'.$val['supplier_name'].'不存在于系统';
return;
}
}
if ($val['currency'] != '人民币' && $val['price_origin'] <= 0) {
......
......@@ -29,7 +29,7 @@ return [
2 => '美元',
3 => '港币',
4 => '欧元',
5 => '英',
5 => '英',
],
'currency_sign' => [
......
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