Commit 8b45881e authored by hangjun83's avatar hangjun83

乐妍]

parent 36c467d7
......@@ -118,11 +118,11 @@ class LeyanService
->where('b_id', $bId)
->update(['p_status' => 0, 'p_show' => 0, 'modifytime' => time()]);
foreach($product as $item){
foreach($product['productStockPrices'] as $package){
$p_tod = '无货,请咨询';
$status = 0;
if(!empty($item['productStockInfos'])){
foreach($item['productStockInfos'] as $stock){
if(!empty($package['productStockInfos'])){
foreach($package['productStockInfos'] as $stock){
if ($stock['city'] == '上海' && $stock['number'] > 0) {
$p_tod = '现货';
$status = 1;
......@@ -130,59 +130,57 @@ class LeyanService
}
}
}
foreach($item['productStockPrices'] as $package){
$p_code = $item['catalogNo'] . '-' . $package['size'];
$productRow = $dbConnect->table('products')
->where('b_id', $bId)
->where('c_id', $chemicalsRow->c_id)
->where('p_code', 'like', $p_code)
->get()->toArray();
$pro_data = [];
if (empty($productRow)) {
$pro_data['b_id'] = $bId;
$pro_data['c_id'] = $chemicalsRow->c_id;
$pro_data['p_code'] = $p_code;
if (!$product['productNameCn']) {
$pro_data['p_cn_name'] = '';
} else {
$pro_data['p_cn_name'] = $product['productNameCn'];
}
if (!$product['productNameEn']) {
$pro_data['p_en_name'] = '';
} else {
$pro_data['p_en_name'] = $product['productNameEn'];
}
$pro_data['p_level'] = $product['purity'];
$pro_data['p_pack'] = $package['size'];
$pro_data['p_price'] = $package['price'];
$pro_data['p_tod'] = $p_tod;
$pro_data['p_weight'] = '0.01';
$pro_data['p_status'] = $status;
$pro_data['p_show'] = 0;
$pro_data['prom_from'] = 0;
$pro_data['prom_to'] = 0;
$id = $dbConnect->table('products')->insertGetId($pro_data);
} else {
$p_code = $product['catalogNo'] . '-' . $package['size'];
$productRow = current($productRow);
$productRow = $dbConnect->table('products')
->where('b_id', $bId)
->where('c_id', $chemicalsRow->c_id)
->where('p_code', 'like', $p_code)
->get()->toArray();
$pro_data['p_status'] = $status;
$pro_data['p_show'] = 0;
$pro_data['p_price'] = $package['price'];
$pro_data['p_tod'] = $p_tod;
$pro_data['modifytime'] = time();
$dbConnect->table('products')
->where('p_id', $productRow->p_id)
->update($pro_data);
$pro_data = [];
if (empty($productRow)) {
$id = $productRow->p_id;
$pro_data['b_id'] = $bId;
$pro_data['c_id'] = $chemicalsRow->c_id;
$pro_data['p_code'] = $p_code;
if (!$product['productNameCn']) {
$pro_data['p_cn_name'] = '';
} else {
$pro_data['p_cn_name'] = $product['productNameCn'];
}
if (!$product['productNameEn']) {
$pro_data['p_en_name'] = '';
} else {
$pro_data['p_en_name'] = $product['productNameEn'];
}
$pro_data['p_level'] = $product['purity'];
$pro_data['p_pack'] = $package['size'];
$pro_data['p_price'] = $package['price'];
$pro_data['p_tod'] = $p_tod;
$pro_data['p_weight'] = '0.01';
$pro_data['p_status'] = $status;
$pro_data['p_show'] = 0;
$pro_data['prom_from'] = 0;
$pro_data['prom_to'] = 0;
$id = $dbConnect->table('products')->insertGetId($pro_data);
} else {
$productRow = current($productRow);
$pro_data['p_status'] = $status;
$pro_data['p_show'] = 0;
$pro_data['p_price'] = $package['price'];
$pro_data['p_tod'] = $p_tod;
$pro_data['modifytime'] = time();
$dbConnect->table('products')
->where('p_id', $productRow->p_id)
->update($pro_data);
$id = $productRow->p_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 to comment