Commit 6dbab836 by lzzzzl

测试goodsModel

parent cc4670c2
Showing with 11 additions and 2 deletions
...@@ -57,6 +57,15 @@ class GoodsModel extends Model ...@@ -57,6 +57,15 @@ class GoodsModel extends Model
* 写入DB物料 * 写入DB物料
*/ */
public function InsertGoodsInfo($arr) { public function InsertGoodsInfo($arr) {
// 判断ERP ID是否存在,存在则直接执行更新操作
$erpId_exist = $this->redis->hget('scm_goods_erp_id', md5($arr['erp_goods_id']));
if ($erpId_exist) {
unset($arr['add_time']);
$this->updateGoodsInfo($arr);
return true;
}
$start = microtime(true); $start = microtime(true);
$str = DB::connection($this->connection)->transaction(function() use($arr, $start){ $str = DB::connection($this->connection)->transaction(function() use($arr, $start){
$end1 = microtime(true); $end1 = microtime(true);
...@@ -136,7 +145,7 @@ class GoodsModel extends Model ...@@ -136,7 +145,7 @@ class GoodsModel extends Model
// 判断是否需要更新品牌 // 判断是否需要更新品牌
if (!empty($arr['brand_name'])) { if (!empty($arr['brand_name'])) {
$brand_name = $arr['brand_name']; $brand_name = $arr['brand_name'];
$brand_exist = DB::connection('mysql')->table('brand')->select('brand_id')->where('brand_name','=',$brand_name)->first(); $brand_exist = $this->redis->hget('scm_brand_name', md5($brand_name));
$brand_params = array( $brand_params = array(
'brand_name' => $brand_name, 'brand_name' => $brand_name,
'admin_name' => $admin_name, 'admin_name' => $admin_name,
...@@ -147,7 +156,7 @@ class GoodsModel extends Model ...@@ -147,7 +156,7 @@ class GoodsModel extends Model
if (!$brand_exist) { if (!$brand_exist) {
$brand_id = DB::connection('mysql')->table('brand')->insertGetId($brand_params); $brand_id = DB::connection('mysql')->table('brand')->insertGetId($brand_params);
} else { } else {
$brand_id = $brand_exist->brand_id; $brand_id = $brand_exist;
} }
// 更新DB // 更新DB
......
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