where('store_id', $order['store_id'])->find(); if (!$product) { $product = StoreProduct::where('id', $find['product_id'])->find(); } if ($product) { if ($user_ship == 5) { $top_cate_id = StoreBranchProduct::where('product_id', $find['product_id'])->value('top_cate_id'); if ($top_cate_id == 15189) { $this->b($find, $order, $product); return true; } } else { $this->a($find, $order, $village_uid, $brigade_uid, $user_ship, $product); } return true; } } /** * 零售价结算 */ public function a($find, $order, $village_uid, $brigade_uid, $user_ship, $product) { // $rose = bcdiv($product['rose'], 100, 2); $total_price = bcmul($product['price'], $find['cart_num']); // $Distribution = Distribution::where('rate', $rose)->find(); //门店 $data[] = [ 'store_id' => $order['store_id'], 'product_id' => $find['product_id'], 'other_uid' => 0, 'number' => bcmul($total_price, 0.05, 2), 'oid' => $order['id'], 'type' => 1, 'status' => 1, ]; //平台 $data[] = [ 'store_id' => $order['store_id'], 'product_id' => $find['product_id'], 'other_uid' => 0, 'number' => bcmul($total_price, 0.02, 2), 'oid' => $order['id'], 'type' => 2, 'status' => 1, ]; //村长 $data[] = [ 'store_id' => $order['store_id'], 'product_id' => $find['product_id'], 'other_uid' => $village_uid, 'number' => bcmul($total_price, 0.01, 2), 'oid' => $order['id'], 'type' => 3, 'status' => 1, ]; //队长 $data[] = [ 'store_id' => $order['store_id'], 'product_id' => $find['product_id'], 'other_uid' => $brigade_uid, 'number' => bcmul($total_price, 0.01, 2), 'oid' => $order['id'], 'type' => 4, 'status' => 1, ]; //会员 if ($user_ship == 1) { $uid = $order['spread_uid']; } else { $uid = 0; } // $data[] = [ // 'store_id' => $order['store_id'], // 'product_id' => $find['product_id'], // 'other_uid' => $uid, // 'number' => bcmul($total_price, $Distribution['user'], 2), // 'oid' => $order['id'], // 'type' => 0, // 'status' => 1, // ]; //个人店铺 if ($order['spread_uid'] > 0) { $data[] = [ 'store_id' => $order['store_id'], 'product_id' => $find['product_id'], 'other_uid' => $order['spread_uid'], 'number' => bcmul($total_price, 0.07, 2), 'oid' => $order['id'], 'type' => 5, 'status' => 1, ]; } $data[] = [ 'store_id' => $order['store_id'], 'product_id' => $find['product_id'], 'other_uid' => 0, 'number' => bcmul($total_price, 0.01, 2), 'oid' => $order['id'], 'type' => 6, 'status' => 1, ]; (new StoreFinanceFlowProduct())->saveAll($data); } /** * 商户价结算 */ public function b($find, $order, $product) { // $rose = bcdiv($product['rose'], 100, 2); $total_price = bcmul($product['purchase'], $find['cart_num']); //门店 $data[] = [ 'store_id' => $order['store_id'], 'product_id' => $find['product_id'], 'other_uid' => 0, 'number' => bcmul($total_price, 0.05, 2), 'oid' => $order['id'], 'type' => 1, 'status' => 1, ]; //平台 $data[] = [ 'store_id' => $order['store_id'], 'product_id' => $find['product_id'], 'other_uid' => 0, 'number' => bcmul($total_price, 0.02, 2), 'oid' => $order['id'], 'type' => 2, 'status' => 1, ]; (new StoreFinanceFlowProduct())->saveAll($data); } }