Commit 7764861f by hcy001

1

parent 67baa6cb
...@@ -22,7 +22,7 @@ class HdController extends Controller ...@@ -22,7 +22,7 @@ class HdController extends Controller
} }
//添加参数 //添加参数
private function cf(){ private function cf(){
$t = '{"data":{"0":{"inquiry_sn":"A161398670712345","inquiry_items_id":"1","currency":2,"goods_id":"353535","goods_name":"LM358","brand_id":"0","brand_name":"TI","supplier_id":7,"supplier_name":"digikey","quote_number":"25","status":1,"create_uid":0,"create_name":"digikey","create_time":1615880179,"update_time":1615880179,"price_origin":0.37,"raw_goods_sn":"497-1591-1-ND","raw_goods_packing":"Cut Tape (CT)","raw_brand_nam e":"STMicroelectronics"},"1":{"inquiry_sn":"A161398670712345","inquiry_items_id":"1","currency":2,"goods_id":"353535","goods_name":"LM358","brand_id":"0","brand_name":"TI","supplier_id":7,"supplier_name":"d igikey","quote_number":"25","status":1,"create_uid":0,"create_name":"digikey","create_time":1615880179,"update_time":1615880179,"price_origin":0.37,"raw_goods_sn":"497-1591-6-ND","raw_goods_packing":"Digi-R eel®","raw_brand_name":"STMicroelectronics"},"2":{"inquiry_sn":"A161398670712345","inquiry_items_id":"1","currency":2,"goods_id":"353535","goods_name":"LM358","brand_id":"0","brand_name":"TI","supplier_id":7,"supplier_name":"digikey","quote_number":"25","status":1,"create_uid":0,"create_name":"digikey","create_time":1615880179,"update_time":1615880179,"price_origin":0.65,"raw_goods_sn":"LM358DTCT-ND","raw_goo ds_packing":"Cut Tape (CT)","raw_brand_name":"Rohm Semiconductor"},"3":{"inquiry_sn":"A161398670712345","inquiry_items_id":"1","currency":2,"goods_id":"353535","goods_name":"LM358","brand_id":"0","brand_nam e":"TI","supplier_id":7,"supplier_name":"digikey","quote_number":"25","status":1,"create_uid":0,"create_name":"digikey","create_time":1615880179,"update_time":1615880179,"price_origin":0.65,"raw_goods_sn":" LM358DTDKR-ND","raw_goods_packing":"Digi-Reel®","raw_brand_name":"Rohm Semiconductor"}}}'; $t = '{"0":{"inquiry_id":"1","inquiry_sn":"A161398670712345","inquiry_items_id":"1","currency":2,"goods_id":"353535","goods_name":"LM358","brand_id":"0","brand_name":"TI","supplier_id":7,"supplier_name":"digikey","quote_number":"25","status":1,"create_uid":0,"create_name":"digikey","price_origin":2.9,"raw_goods_sn":"1597-1134-ND","raw_goods_packing":"Bulk","raw_brand_name":"Seeed Technology Co., Ltd"}}';
$res = (new QuoteModel())->addBatch($t); $res = (new QuoteModel())->addBatch($t);
} }
......
...@@ -225,7 +225,7 @@ class QuoteModel extends Model ...@@ -225,7 +225,7 @@ class QuoteModel extends Model
$input = json_decode($indata,true); $input = json_decode($indata,true);
if (!$input || count($input) == 0 ) return [1, '数据不得为空']; if (!$input || count($input) == 0 ) return [1, '数据不得为空'];
// 询价明细单状态 // 询价明细单状态
$inquiry_items_id = $input[0]['inquiry_items_id']; $inquiry_items_id = current($input)['inquiry_items_id'];
$inquiry_items_status = InquiryItemsModel::where('id', $inquiry_items_id)->value('status'); $inquiry_items_status = InquiryItemsModel::where('id', $inquiry_items_id)->value('status');
if ($inquiry_items_status == -1) return [1, '新增报价失败,该询价明细已关闭']; if ($inquiry_items_status == -1) return [1, '新增报价失败,该询价明细已关闭'];
...@@ -237,22 +237,21 @@ class QuoteModel extends Model ...@@ -237,22 +237,21 @@ class QuoteModel extends Model
#拼接批量插入明细 #拼接批量插入明细
foreach ($input as $k=>&$v){ foreach ($input as $k=>&$v){
$check = $this->where(["inquiry_items_id"=>$inquiry_items_id,"raw_goods_sn"=>$v["raw_goods_sn"]])->first(); $quote_sn = $this->where(["inquiry_items_id"=>$inquiry_items_id,"raw_goods_sn"=>$v["raw_goods_sn"]])->value("quote_sn");
if ($check){ #存在更新 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) ;
OpLogModel::log([ OpLogModel::log([
'types'=>2, 'types'=>2,
'relation_id'=>$inquiry_items_id, 'relation_id'=>$inquiry_items_id,
'relation_sn'=>$check->quote_sn, 'relation_sn'=>$quote_sn,
'content'=>'自动报价-更新,价格:'+($v["currency"] == "1" ? "¥".$v[""] : "$".$v[""]), 'content'=>'自动报价-更新,价格:'+($v["currency"] == "1" ? "¥".$v["price_rmb"] : "$".$v["price_origin"]),
'create_name'=>"系统", 'create_name'=>"系统",
]); ]);
}else{ }else{
$v["quote_sn"] = createSn($QuoteModel, 'quote_sn', 'B'); $v["quote_sn"] = createSn($QuoteModel, 'quote_sn', 'B');
$v["create_time"] = time(); $v["create_time"] = time();
$v["update_time"] = time(); $v["update_time"] = time();
print_r($v);
$this->insert($v); $this->insert($v);
OpLogModel::log([ OpLogModel::log([
......
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