where('product_id', $product_id)->find(); if ($product && $product['rose'] > 0) { if ($product['rose'] >= 4 && $product['rose'] < 8) { $rose = bcdiv($product['rose'], 100, 2); $commission = bcmul($product['purchase'], $rose, 2); StoreFinanceFlowProduct::create([ 'store_id' => $store_id, 'product_id' => $product_id, 'number' => $commission, 'oid' => $oid, 'type' => 2, 'status' => 1, ]); } elseif ($product['rose'] >= 8) { $rose = bcdiv($product['rose'], 100, 2); $Distribution = Distribution::where('rate', $rose)->find(); //门店 $data[] = [ 'store_id' => $store_id, 'product_id' => $product_id, 'number' => bcmul($product['purchase'], $Distribution['store'], 2), 'oid' => $oid, 'type' => 1, 'status' => 1, ]; //平台 $data[] = [ 'store_id' => $store_id, 'product_id' => $product_id, 'number' => bcmul($product['purchase'], $Distribution['platform'],2), 'oid' => $oid, 'type' => 2, 'status' => 1, ]; //村长 $data[] = [ 'store_id' => $store_id, 'product_id' => $product_id, 'other_uid' => $village_uid, 'number' => bcmul($product['purchase'], $Distribution['village'], 2), 'oid' => $oid, 'type' => 3, 'status' => 1, ]; //队长 $data[] = [ 'store_id' => $store_id, 'product_id' => $product_id, 'other_uid' => $brigade_uid, 'number' => bcmul($product['purchase'], $Distribution['brigade'], 2), 'oid' => $oid, 'type' => 4, 'status' => 1, ]; //会员 $data[] = [ 'store_id' => $store_id, 'product_id' => $product_id, 'other_uid' => $uid, 'number' => bcmul($product['purchase'], $Distribution['user'], 2), 'oid' => $oid, 'type' => 0, 'status' => 1, ]; //个人店铺 if ($spread_uid > 0) { $data[] = [ 'store_id' => $store_id, 'product_id' => $product_id, 'other_uid' => $uid, 'number' => bcmul($product['purchase'], $Distribution['person_store'], 2), 'oid' => $oid, 'type' => 5, 'status' => 1, ]; } (new StoreFinanceFlowProduct())->saveAll($data); } } } }