Commit 64955193 by lzzzzl

测试

parent c2721cf4
Showing with 19 additions and 8 deletions
......@@ -57,12 +57,15 @@ class GoodsModel extends Model
* 写入DB物料
*/
public function InsertGoodsInfo($arr) {
$str = DB::connection($this->connection)->transaction(function() use($arr){
$start = microtime(true);
$str = DB::connection($this->connection)->transaction(function() use($arr, $start){
$end1 = microtime(true);
$brand_name = $arr['brand_name'];
$admin_name = $arr['admin_name'];
$admin_id = $arr['admin_id'];
$erp_id = $arr['erp_goods_id'];
$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));
$end2 = microtime(true);
// 品牌参数
$brand_params = array(
'brand_name' => $brand_name,
......@@ -75,13 +78,12 @@ class GoodsModel extends Model
if (!$brand_exist) {
$brand_id = DB::connection('mysql')->table('brand')->insertGetId($brand_params);
} else {
$brand_id = $brand_exist->brand_id;
$brand_id = $brand_exist;
}
$end3 = microtime(true);
$arr['brand_id'] = $brand_id;
$start = microtime();
$arr['goods_sn'] = (new SnModel())->sn("goods_sn");
$end = microtime();
Log::error($end - $start);
$end4 = microtime(true);
// 判断goods_sn,没有正常生成,则退出
if (empty($arr['goods_sn']))
return false;
......@@ -89,7 +91,8 @@ class GoodsModel extends Model
// 写入DB
$goods_id = $this->insertGetId($arr);
$end5 = microtime(true);
// 品牌不存在
if (!$brand_exist) {
// 缓存品牌->品牌Id
......@@ -103,7 +106,15 @@ class GoodsModel extends Model
// GOODSID GOODS REDIS
// $this->goodsId2Goods($goods_id,json_encode($arr));
$end6 = microtime(true);
Log::error((($end1-$start)*1000).'ms');
Log::error((($end2-$start)*1000).'ms');
Log::error((($end3-$start)*1000).'ms');
Log::error((($end4-$start)*1000).'ms');
Log::error((($end5-$start)*1000).'ms');
Log::error((($end6-$start)*1000).'ms');
return true;
});
......
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