pluck('value','key')->toArray(); self::$box_detail_header = Header_ext::where('type','box_detail')->pluck('value','key')->toArray(); self::$box_hook = BoxHookService::getInstance(); } /** * 包装 * @param $data * @return array */ public function boxIn($data){ // $param = $data['param']; $param = [ [ 'id'=>716, 'param'=>[ '1', '1' ], ],[ 'id'=>723, 'param'=>[ '40', '40' ], ], ]; $ids = []; $key_list = []; foreach ($param as $v){ $ids[] = $v['id']; $total = 0; foreach ($v['param'] as $vv){ $total += $vv; } $key_list[$v['id']] = [ 'detail' => $v['param'], 'total' => $total, ]; } $product_list = SaleOrdersProduct::wherein('id',$ids)->get()->toArray(); foreach ($product_list as $v){ $num_list = $key_list[$v['id']]; $total = $num_list['total']; $detail = $num_list['detail']; $un_box_num = $v['order_quantity'] - $v['box_num']; if($num_list['total'] > $un_box_num) return [false,$v['product_title'].'数量不足']; } //$data = [ // 'out_order_no' => 'test123', // 'top_id' => '1', // 'ext_1' => '1', // 'ext_2' => '2', // 'ext_3' => '3', // 'ext_4' => '4', // 'ext_5' => '5', // 'detail' => [ // [ // 'top_id' => '1', // 'code' => '001', // 'title' => '产品名称', // 'ext_1' => '1', // 'ext_2' => '2', // 'ext_3' => '3', // 'ext_4' => '4', // 'ext_5' => '5', // ],[ // 'top_id' => '2', // 'code' => '002', // 'title' => '产品名称1', // 'ext_1' => '11', // 'ext_2' => '22', // 'ext_3' => '33', // 'ext_4' => '44', // 'ext_5' => '55', // ], // ], // ]; return [true,'']; } /** * 包装详情1 * @param $data * @return array */ public function boxDetail($data){ list($status,$data) = self::$box_hook->boxList($data); if(!$status) return [false,$data]; return [true,$data]; } }